export class BrowserSubmissionGate { static evaluate(predictions, policy) { console.log("[BoomCast][Gate] Evaluating browser classification."); const relevant = new Set((policy.whitelist || []).map((name) => name.toLowerCase())); const speechNames = new Set((policy.privacy_sensitive_speech || []).map((name) => name.toLowerCase())); const matchThreshold = Number(policy.thresholds?.relevance ?? 0.5); const speechThreshold = Number(policy.thresholds?.speech ?? 0.5); const matches = predictions.filter((item) => relevant.has(item.class.toLowerCase()) && item.score >= matchThreshold); const speechDetected = predictions.some((item) => speechNames.has(item.class.toLowerCase()) && item.score >= speechThreshold); console.log("[BoomCast][Gate] Relevant whitelist matches:", matches); console.log("[BoomCast][Gate] Speech detected:", speechDetected); const result = matches.length ? "whitelist_match" : speechDetected ? "speech_only" : "no_match"; console.log(`[BoomCast][Gate] Decision: ${result.toUpperCase()}`); if (result !== "whitelist_match") console.log("[BoomCast][Gate] Automatic upload suppressed."); return { result, speechDetected, matches }; } }