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,QAAS,KAAMA,EAAK,KAAM,SAAU,EAAA,CAAM,CACnF,CAEO,SAASY,GAAqB,CACpCf,EAAQ,OAAQgB,IAAO,CAAE,GAAGA,EAAG,KAAM,GAAO,OAAQ,OAAW,SAAU,EAAA,EAAQ,CAClF,CAKO,SAASC,EACfC,EACAf,EACU,CAIV,MAHI,CAACe,GAAM,SAGPA,EAAK,cAAgBf,EAAK,OAAS,WAAaE,EAAK,KAAK,MAAc,IAC5EH,EAAYC,CAAI,EACT,GACR","names":["AGE_GATE_DONE_MESSAGE","AGE_GATE_RETURN_KEY","RESUME_AGE_GATE","AGE_GATE_RESULT_KEY","ageGate","writable","openAgeGate","opts","mode","page","deviceTapOffered","trackAgeGate","signInForAgeGate","SIGNED_OUT_TAP_FLAG","featureFlag","surface","saveResume","openAuthSheet","resumeAgeCheck","closeAgeGate","s","requireAge","data"],"sources":["../../../../../../src/lib/stores/ageGate.ts"],"sourcesContent":["import { writable } from 'svelte/store';\nimport { page } from '$app/state';\nimport { featureFlag, trackAgeGate } from '$lib/analytics';\nimport { saveResume } from '$lib/oauth-resume';\nimport { openAuthSheet } from '$lib/stores/authSheet';\nimport type { AgeGateMode, AgeGateSurface } from '$lib/age-gate';\n\n/** RAT-641: drives the one age-check sheet mounted in the root layout, the way\n *  authSheet drives the sign-in sheet. Any blurred tile or gated button opens\n *  it in place; nobody is sent to another page. */\n\n/** The frame's landing page tells the sheet the check has finished. */\nexport const AGE_GATE_DONE_MESSAGE = 'ratemyd:age-gate-done';\n/** sessionStorage: where to come back to when the check ran full screen, as\n *  JSON `{ back, surface, mode }`. */\nexport const AGE_GATE_RETURN_KEY = 'age_gate_return';\n/** sessionStorage: reopen the sheet once a signed-out visitor has signed in. */\nexport const RESUME_AGE_GATE = 'gate_age_check';\n/** sessionStorage: back on the page after a full-screen check, show how it\n *  went. JSON `{ surface, mode }`, set by /age/done, read once by the sheet. */\nexport const AGE_GATE_RESULT_KEY = 'age_gate_result';\n\n/** What the full-screen check leaves behind for the way back. */\nexport interface AgeGateReturn {\n\tback: string;\n\tsurface: AgeGateSurface;\n\tmode: AgeGateMode;\n\t/** Scroll position to put them back at. */\n\ty?: number;\n}\n\ninterface AgeGateState {\n\topen: boolean;\n\tsurface: AgeGateSurface;\n\tmode: AgeGateMode;\n\t/** Runs once the check passes: finishes what the tap was for. */\n\tonPass?: () => void;\n\t/** Back from a check that ran full screen: open straight on the result. */\n\tchecking?: boolean;\n}\n\nexport const ageGate = writable<AgeGateState>({ open: false, surface: 'feed', mode: 'view' });\n\nexport function openAgeGate(opts: {\n\tsurface: AgeGateSurface;\n\tmode?: AgeGateMode;\n\tonPass?: () => void;\n}): void {\n\tconst mode = opts.mode ?? 'view';\n\tif (!page.data.user) {\n\t\t// RAT-643: where no law asks for the check, viewing needs only the one\n\t\t// tap, right here, no account. Posting still needs one.\n\t\tif (mode === 'view' && deviceTapOffered()) {\n\t\t\tageGate.set({ open: true, surface: opts.surface, mode, onPass: opts.onPass });\n\t\t\ttrackAgeGate('shown', { surface: opts.surface, mode, status: 'device' });\n\t\t\treturn;\n\t\t}\n\t\tsignInForAgeGate(opts.surface, mode);\n\t\treturn;\n\t}\n\tageGate.set({ open: true, surface: opts.surface, mode, onPass: opts.onPass });\n\ttrackAgeGate('shown', { surface: opts.surface, mode });\n}\n\n/** RAT-669: the PostHog experiment on the signed-out tap (experiment 654355).\n *  `test` gets the one tap, `control` signs in as before. */\nconst SIGNED_OUT_TAP_FLAG = 'age-signedout-tap';\n\n/** RAT-643: can a signed-out visitor confirm 18+ with one tap from here? For\n *  now only the experiment's test half can. Reading the flag logs the\n *  exposure; before posthog-js and its flags have loaded the visitor signs in,\n *  outside the test. */\nexport function deviceTapOffered(): boolean {\n\tif (page.data.user || page.data.ageMode !== 'confirm' || !page.data.ageTapAllowed) return false;\n\treturn featureFlag(SIGNED_OUT_TAP_FLAG) === 'test';\n}\n\n/** Signed out where the check (or an account) is needed, there's nothing to\n *  check yet: the pass belongs to an account. The tap opens the plain sign-in\n *  sheet, since selfie talk before someone has joined only scares them off,\n *  and the sheet reopens the check by itself once they're in. */\nexport function signInForAgeGate(surface: AgeGateSurface, mode: AgeGateMode): void {\n\tsaveResume(RESUME_AGE_GATE, { surface, mode });\n\topenAuthSheet(page.url.pathname + page.url.search, 'gate_age_check');\n\ttrackAgeGate('signin', { surface, mode });\n}\n\n/** Back on the page after a check that ran full screen (phones): the sheet\n *  reopens on \"checking…\" and shows how it went. */\nexport function resumeAgeCheck(opts: { surface: AgeGateSurface; mode: AgeGateMode }): void {\n\tageGate.set({ open: true, surface: opts.surface, mode: opts.mode, checking: true });\n}\n\nexport function closeAgeGate(): void {\n\tageGate.update((s) => ({ ...s, open: false, onPass: undefined, checking: false }));\n}\n\n/** For click handlers in front of something gated: true when the user may go\n *  ahead now; otherwise opens the sheet (which runs `onPass` once they pass)\n *  and answers false. `data` is the page data the root layout fills. */\nexport function requireAge(\n\tdata: { ageGate?: boolean; ageVerified?: boolean } | null | undefined,\n\topts: { surface: AgeGateSurface; mode?: AgeGateMode; onPass?: () => void }\n): boolean {\n\tif (!data?.ageGate) return true;\n\t// RAT-643: a signed-out visitor's tap opens viewing only; posting still\n\t// goes through signing in.\n\tif (data.ageVerified && (opts.mode !== 'publish' || page.data.user)) return true;\n\topenAgeGate(opts);\n\treturn false;\n}\n"],"version":3}