@sentientui/core 0.41.1 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -2
- package/dist/chunk-BGZLWZUG.mjs +2 -0
- package/dist/chunk-BGZLWZUG.mjs.map +1 -0
- package/dist/chunk-JNQY3XNF.mjs +2 -0
- package/dist/chunk-JNQY3XNF.mjs.map +1 -0
- package/dist/chunk-LCYGZNFI.mjs +2 -0
- package/dist/chunk-LCYGZNFI.mjs.map +1 -0
- package/dist/chunk-QPJ6TL6L.mjs +2 -0
- package/dist/chunk-QPJ6TL6L.mjs.map +1 -0
- package/dist/chunk-WUFFNQHQ.mjs +2 -0
- package/dist/{chunk-J5EL7HKC.mjs.map → chunk-WUFFNQHQ.mjs.map} +1 -1
- package/dist/{index-DlJDNOWu.d.cts → index-Bz4QCRmF.d.cts} +26 -5
- package/dist/{index-C--aVpoo.d.ts → index-C36TXfry.d.ts} +26 -5
- package/dist/index-consent.js +1 -1
- package/dist/index-consent.js.map +1 -1
- package/dist/index-consent.mjs +1 -1
- package/dist/index-consent.mjs.map +1 -1
- package/dist/index-engagement.js +1 -1
- package/dist/index-engagement.js.map +1 -1
- package/dist/index-engagement.mjs +1 -1
- package/dist/index-engagement.mjs.map +1 -1
- package/dist/index-graph.d.cts +2 -2
- package/dist/index-graph.d.ts +2 -2
- package/dist/index-graph.js +1 -1
- package/dist/index-graph.js.map +1 -1
- package/dist/index-graph.mjs +1 -1
- package/dist/index-graph.mjs.map +1 -1
- package/dist/index-internal-traffic.d.cts +37 -0
- package/dist/index-internal-traffic.d.ts +37 -0
- package/dist/index-internal-traffic.js +2 -0
- package/dist/index-internal-traffic.js.map +1 -0
- package/dist/index-internal-traffic.mjs +2 -0
- package/dist/index-internal-traffic.mjs.map +1 -0
- package/dist/index-local.d.cts +1 -1
- package/dist/index-local.d.ts +1 -1
- package/dist/index-region.mjs +1 -1
- package/dist/index-server.d.cts +25 -1
- package/dist/index-server.d.ts +25 -1
- package/dist/index-server.js +1 -1
- package/dist/index-server.js.map +1 -1
- package/dist/index-server.mjs +1 -1
- package/dist/index-server.mjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/llms.txt +2 -1
- package/package.json +7 -2
- package/dist/chunk-FPOHOWJP.mjs +0 -2
- package/dist/chunk-FPOHOWJP.mjs.map +0 -1
- package/dist/chunk-J5EL7HKC.mjs +0 -2
- package/dist/chunk-KXA3X6T3.mjs +0 -2
- package/dist/chunk-KXA3X6T3.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/consent-sources.ts"],"sourcesContent":["// Consent sources: where the SDK reads a visitor's consent decision from, so a\n// site keeps its own consent manager (CMP) and we only OBSERVE it. Shared by\n// React (`consentFrom`), Next.js `AdaptiveRoot` (server read of the CMP's own\n// cookie → SSR for visitors who already consented) and the snippet.\n//\n// Presets encode each platform's documented API, verified 2026-09-24:\n// - Cookiebot: `Cookiebot.consent.{preferences,statistics,marketing}`; window\n// events CookiebotOnAccept / CookiebotOnDecline (both also fire on load for a\n// returning visitor) / CookiebotOnConsentReady; cookie `CookieConsent` =\n// `{stamp:'…',necessary:true,preferences:…,statistics:…,marketing:…,…}`,\n// \"0\" = declined, \"-1\" = consent not required in the visitor's region.\n// - OneTrust: `OnetrustActiveGroups` (\",C0001,C0002,\"), window event\n// OneTrustGroupsUpdated; cookie `OptanonConsent` with `groups=C0001:1,C0002:0`.\n// C0002 = Performance.\n// - CookieYes: `getCkyConsent().categories.{functional,analytics,performance,\n// advertisement}` (only after the banner loads); `cookieyes_consent_update`\n// dispatched on DOCUMENT; cookie `cookieyes-consent` observed as\n// `consentid:…,consent:yes,…,analytics:yes,…` (not officially documented —\n// used server-side only, and an unrecognised value is \"unknown\", not \"no\").\n// - IAB TCF v2.2: `__tcfapi('addEventListener', 2, cb)`; granted when GDPR\n// doesn't apply or every required purpose is satisfied (consent; or, for a\n// purpose the policy lets rest on it, legitimate interest) and — when a\n// `vendorId` is configured — the vendor has consent. Server: the TC string\n// in `euconsent-v2` (the de-facto cookie; not every CMP writes it).\n// - Google Consent Mode v2: the latest `consent default|update` command in\n// `dataLayer` for the storage type. Most CMPs (Cookiebot, OneTrust,\n// CookieYes, Usercentrics, Didomi…) drive it, so it is a universal adapter.\n// `default` may carry `region: ['ES', 'US-CA']`: region-scoped defaults beat\n// the global one for visitors in those regions (most specific wins); an\n// `update` applies everywhere.\n// - Shopify Customer Privacy API (shopify.dev/docs/api/customer-privacy):\n// `Shopify.customerPrivacy.analyticsProcessingAllowed()` — already combines\n// the merchant's region settings, the visitor's location and their choice;\n// loaded via `Shopify.loadFeatures([{name:'consent-tracking-api'}])`;\n// `visitorConsentCollected` on DOCUMENT when consent changes. Shopify's own\n// banner and every Shopify CMP app are required to report into it.\n//\n// Every read is re-done from the source on each signal — an event payload is\n// never trusted — and a revocation reads false, which the callers turn into a\n// teardown. Unknown ≠ granted: a source that can't be read gates.\n\nexport type ConsentPreset = 'cookiebot' | 'onetrust' | 'cookieyes' | 'tcf' | 'google-consent-mode' | 'shopify';\n\n/** TCF purposes the SDK's processing needs: 1 store/access on a device,\n * 5 build a personalised-content profile, 6 select personalised content from\n * it, 8 measure content performance. The old default was purpose 1 alone —\n * storage consent, which says nothing about profiling or measurement. */\nexport const TCF_DEFAULT_PURPOSES: readonly number[] = [1, 5, 6, 8];\n\nexport type ConsentSource =\n | ConsentPreset\n | { cmp: 'cookiebot'; category?: 'preferences' | 'statistics' | 'marketing' }\n | { cmp: 'onetrust'; group?: string }\n | { cmp: 'cookieyes'; category?: 'functional' | 'analytics' | 'performance' | 'advertisement' }\n | {\n cmp: 'tcf';\n /** Purposes that must be satisfied. @default TCF_DEFAULT_PURPOSES (1, 5, 6, 8) */\n purposes?: number[];\n /** Also require consent for this Global Vendor List id. SentientUI is a\n * processor for your site and has no GVL id of its own; set this only if\n * your CMP lists a vendor entry you map it to. */\n vendorId?: number;\n }\n | {\n cmp: 'google-consent-mode';\n type?: 'analytics_storage' | 'ad_storage' | 'personalization_storage' | 'functionality_storage';\n dataLayer?: string;\n /** The visitor's region (ISO 3166-1 alpha-2, optionally `-` ISO 3166-2\n * subdivision: 'ES', 'US-CA'), e.g. from your CDN's country header.\n * Resolves region-scoped `consent default` commands exactly. Without it\n * a region-scoped denial can't be ruled out, so it reads as denied. */\n region?: string;\n }\n | {\n cmp: 'shopify';\n /** Which Customer Privacy purpose to require. @default 'analytics' */\n category?: 'analytics' | 'marketing' | 'preferences';\n }\n | {\n cmp?: undefined;\n /** Cookie to read. Granted when its value equals `value`. */\n cookie?: string;\n /** Cookie value that means granted. @default 'accepted' */\n value?: string;\n /** Predicate for CMPs with a JS API. Takes precedence over `cookie`. */\n check?: () => boolean;\n /** Event that signals a decision (listened on window AND document). */\n event?: string;\n /** With `check`: true when the visitor has actually REFUSED (not merely\n * not answered yet). A predicate can't say why it returned false, so\n * without this a `check` source only pauses tracking and never forgets. */\n refused?: () => boolean;\n };\n\nexport type ConsentWatcher = {\n /** The decision right now: true/false, or null when the source can't tell\n * yet (CMP not loaded, no decision stored). Callers treat null as \"keep\n * whatever you knew\" — e.g. the server's read — and never as granted. */\n read(): boolean | null;\n /** True only when the source records an actual refusal — a \"no\" that\n * justifies deleting what the SDK stored (forget-me), not merely gating.\n * False while the platform is loading, while its banner is up (TCF\n * `cmpuishown`), for a region-conservative Consent Mode read, and for\n * `check()` sources (a predicate can't say why it returned false). */\n refused(): boolean;\n /** Call `onChange` whenever the decision may have changed. */\n subscribe(onChange: () => void): () => void;\n};\n\ntype AnyWin = Window & Record<string, unknown>;\n\nconst decode = (v: string): string => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n};\n\nfunction docCookie(doc: Document | undefined, name: string): string | undefined {\n if (!doc) return undefined;\n for (const part of doc.cookie.split(';')) {\n const i = part.indexOf('=');\n if (i > 0 && part.slice(0, i).trim() === name) return part.slice(i + 1).trim();\n }\n return undefined;\n}\n\n/** Listen to `names` on both window and document (CMPs use either). */\nfunction listen(win: Window, names: string[], cb: () => void): () => void {\n const targets: EventTarget[] = [win, ...(win.document ? [win.document] : [])];\n for (const t of targets) for (const n of names) t.addEventListener(n, cb);\n return () => {\n for (const t of targets) for (const n of names) t.removeEventListener(n, cb);\n };\n}\n\n// ── Cookie parsers (also used server-side) ────────────────────────────────\n\n/** Cookiebot `CookieConsent`: true/false for `category`, null when unknown. */\nexport function cookiebotCookieGrants(raw: string | undefined, category = 'statistics'): boolean | null {\n if (raw == null || raw === '') return null;\n const v = decode(raw).trim();\n if (v === '-1') return true; // consent not required in this region\n if (v === '0') return false;\n const m = new RegExp(`[{,]\\\\s*${category}\\\\s*:\\\\s*(true|false)`).exec(v);\n return m ? m[1] === 'true' : null;\n}\n\n/** OneTrust `OptanonConsent`: is `group` active? null when unknown. Pass the\n * raw cookie value, not a decoded one (see {@link consentFromCookies}). */\nexport function onetrustCookieGrants(raw: string | undefined, group = 'C0002'): boolean | null {\n if (raw == null || raw === '') return null;\n // Split on the RAW `&` first, then decode only the groups value: decoding\n // the whole cookie first let an encoded `&groups=C0002:1` inside\n // `landingPath` (the landing URL, before any answer) read as consent\n // (grader N7-1). The LAST `groups` field counts: a caller whose cookie jar\n // already decoded the value (Next's cookies() does) hands us that injected\n // field as a real one, and landingPath is written before OneTrust's own\n // `groups` (grader R8 NEW-1).\n let groups: string | undefined;\n for (const field of raw.split('&')) {\n if (field.startsWith('groups=')) groups = decode(field.slice('groups='.length));\n }\n if (groups == null) return null;\n for (const pair of groups.split(',')) {\n const [g, on] = pair.split(':');\n if (g === group) return on === '1';\n }\n return null;\n}\n\n/** CookieYes `cookieyes-consent`: `category:yes|no`, null when unrecognised. */\nexport function cookieyesCookieGrants(raw: string | undefined, category = 'analytics'): boolean | null {\n if (raw == null || raw === '') return null;\n const m = new RegExp(`(?:^|,)${category}:(yes|no)(?:,|$)`).exec(decode(raw));\n return m ? m[1] === 'yes' : null;\n}\n\nexport type TcConsents = {\n purposes: Set<number>;\n legitimateInterests: Set<number>;\n /** Vendor ids with consent; null when the vendor section is truncated. */\n vendors: Set<number> | null;\n /** The publisher segment (type 3): the site's own purposes. Empty sets when\n * the string carries none. */\n publisherPurposes: Set<number>;\n publisherLegitimateInterests: Set<number>;\n /** PurposeOneTreatment (bit 200): purpose 1 is not collected. */\n purposeOneTreatment: boolean;\n};\n\n/**\n * Decode an IAB TCF v2 TC string's core segment. Bit layout (TCF v2.2 spec):\n * Version 6 · Created 36 · LastUpdated 36 · CmpId 12 · CmpVersion 12 ·\n * ConsentScreen 6 · ConsentLanguage 12 · VendorListVersion 12 ·\n * TcfPolicyVersion 6 · IsServiceSpecific 1 · UseNonStandardTexts 1 ·\n * SpecialFeatureOptIns 12 · PurposesConsent 24 (bit 152) ·\n * PurposesLITransparency 24 (bit 176) · PurposeOneTreatment 1 · PublisherCC 12\n * · then the vendor-consent section at bit 213: MaxVendorId 16 ·\n * IsRangeEncoding 1 · a MaxVendorId-bit field, or NumEntries 12 and entries\n * of IsARange 1 · Start 16 · [End 16]. Null for anything that isn't v2.\n */\nconst B64URL = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';\nconst toBits = (seg: string): string => {\n let bits = '';\n for (const ch of seg) bits += B64URL.indexOf(ch).toString(2).padStart(6, '0');\n return bits;\n};\n\nexport function tcStringConsents(tc: string | undefined): TcConsents | null {\n if (!tc) return null;\n const segments = tc.split('.');\n const core = segments[0]!;\n if (!/^[A-Za-z0-9_-]+$/.test(core)) return null;\n const bits = toBits(core);\n if (bits.length < 200 || parseInt(bits.slice(0, 6), 2) !== 2) return null;\n const int = (at: number, len: number): number | null => (at + len <= bits.length ? parseInt(bits.slice(at, at + len), 2) : null);\n const purposes = new Set<number>();\n const legitimateInterests = new Set<number>();\n for (let p = 1; p <= 24; p++) {\n if (bits[151 + p] === '1') purposes.add(p);\n if (bits[175 + p] === '1') legitimateInterests.add(p);\n }\n let vendors: Set<number> | null = null;\n const max = int(213, 16);\n const isRange = int(229, 1);\n if (max !== null && isRange === 0) {\n if (230 + max <= bits.length) {\n vendors = new Set();\n for (let v = 1; v <= max; v++) if (bits[229 + v] === '1') vendors.add(v);\n }\n } else if (max !== null && isRange === 1) {\n const n = int(230, 12);\n let at = 242;\n const out = new Set<number>();\n let ok = n !== null;\n for (let i = 0; ok && i < (n ?? 0); i++) {\n const range = int(at, 1);\n const start = int(at + 1, 16);\n if (range === null || start === null) ok = false;\n else if (range === 1) {\n const end = int(at + 17, 16);\n if (end === null || end < start || end - start > 65535) ok = false;\n else for (let v = start; v <= end; v++) out.add(v);\n at += 33;\n } else {\n out.add(start);\n at += 17;\n }\n }\n if (ok) vendors = out;\n }\n // Publisher TC segment: SegmentType 3 · PubPurposesConsent 24 ·\n // PubPurposesLITransparency 24 (then custom purposes, unused here).\n const publisherPurposes = new Set<number>();\n const publisherLegitimateInterests = new Set<number>();\n for (const seg of segments.slice(1)) {\n if (!/^[A-Za-z0-9_-]+$/.test(seg)) continue;\n const pb = toBits(seg);\n if (pb.length < 51 || parseInt(pb.slice(0, 3), 2) !== 3) continue;\n for (let p = 1; p <= 24; p++) {\n if (pb[2 + p] === '1') publisherPurposes.add(p);\n if (pb[26 + p] === '1') publisherLegitimateInterests.add(p);\n }\n }\n return { purposes, legitimateInterests, vendors, publisherPurposes, publisherLegitimateInterests, purposeOneTreatment: bits[200] === '1' };\n}\n\n/** Purpose consents only — kept for callers of the pre-vendor parser. */\nexport function tcStringPurposes(tc: string | undefined): Set<number> | null {\n return tcStringConsents(tc)?.purposes ?? null;\n}\n\n// TCF policy: purposes 1, 3, 4, 5 and 6 need consent; the rest may rest on a\n// legitimate interest the visitor didn't object to.\nconst TCF_CONSENT_ONLY = new Set([1, 3, 4, 5, 6]);\n\nfunction tcfSatisfied(\n n: { purposes: readonly number[]; vendorId?: number },\n consent: (p: number) => boolean,\n li: (p: number) => boolean,\n vendor: (v: number) => boolean | null,\n): boolean | null {\n const purposesOk = n.purposes.every((p) => consent(p) || (!TCF_CONSENT_ONLY.has(p) && li(p)));\n if (!purposesOk) return false;\n if (n.vendorId === undefined) return true;\n return vendor(n.vendorId);\n}\n\n// ── Normalisation ─────────────────────────────────────────────────────────\n\ntype Norm =\n | { cmp: 'cookiebot'; category: string }\n | { cmp: 'onetrust'; group: string }\n | { cmp: 'cookieyes'; category: string }\n | { cmp: 'tcf'; purposes: readonly number[]; vendorId?: number }\n | { cmp: 'google-consent-mode'; type: string; dataLayer: string; region?: string }\n | { cmp: 'shopify'; category: 'analytics' | 'marketing' | 'preferences' }\n | { cmp: 'custom'; cookie?: string; value: string; check?: () => boolean; event?: string; refused?: () => boolean };\n\nfunction normalize(input: ConsentSource): Norm {\n const src = (typeof input === 'string' ? { cmp: input } : input) as Exclude<ConsentSource, string>;\n switch (src.cmp) {\n case 'cookiebot':\n return { cmp: 'cookiebot', category: src.category ?? 'statistics' };\n case 'onetrust':\n return { cmp: 'onetrust', group: src.group ?? 'C0002' };\n case 'cookieyes':\n return { cmp: 'cookieyes', category: src.category ?? 'analytics' };\n case 'tcf':\n return {\n cmp: 'tcf',\n purposes: src.purposes && src.purposes.length > 0 ? src.purposes : TCF_DEFAULT_PURPOSES,\n vendorId: typeof src.vendorId === 'number' && src.vendorId > 0 ? src.vendorId : undefined,\n };\n case 'google-consent-mode':\n return {\n cmp: 'google-consent-mode',\n type: src.type ?? 'analytics_storage',\n dataLayer: src.dataLayer ?? 'dataLayer',\n region: typeof src.region === 'string' && src.region.trim() !== '' ? src.region.trim().toUpperCase() : undefined,\n };\n case 'shopify':\n return { cmp: 'shopify', category: src.category ?? 'analytics' };\n default:\n return { cmp: 'custom', cookie: src.cookie, value: src.value ?? 'accepted', check: src.check, event: src.event, refused: src.refused };\n }\n}\n\n/**\n * Server-side read from the request's cookies (Next.js `AdaptiveRoot`).\n * true/false when the CMP's cookie decides it, null when it can't be known on\n * the server (no cookie yet, a JS-only source) — the caller then gates the\n * first paint and lets the browser decide.\n *\n * `getCookie` must return the value exactly as sent in the Cookie header,\n * NOT decoded: most server cookie jars (Next's cookies(), Express\n * cookie-parser) decode values, and a decoded OneTrust cookie lets a crafted\n * landing URL inject a `groups=` field that reads as consent.\n */\nexport function consentFromCookies(src: ConsentSource, getCookie: (name: string) => string | undefined): boolean | null {\n const n = normalize(src);\n switch (n.cmp) {\n case 'cookiebot':\n return cookiebotCookieGrants(getCookie('CookieConsent'), n.category);\n case 'onetrust':\n return onetrustCookieGrants(getCookie('OptanonConsent'), n.group);\n case 'cookieyes':\n return cookieyesCookieGrants(getCookie('cookieyes-consent'), n.category);\n case 'tcf': {\n const c = tcStringConsents(getCookie('euconsent-v2'));\n if (!c) return null;\n return tcfSatisfied(\n c.purposeOneTreatment ? { ...n, purposes: n.purposes.filter((p) => p !== 1) } : n,\n (p) => c.purposes.has(p) || c.publisherPurposes.has(p),\n (p) => c.legitimateInterests.has(p) || c.publisherLegitimateInterests.has(p),\n (v) => (c.vendors ? c.vendors.has(v) : null),\n );\n }\n case 'google-consent-mode':\n return null;\n case 'shopify':\n // `_tracking_consent` is undocumented; the browser API decides.\n return null;\n case 'custom':\n if (!n.cookie || n.check) return null;\n return getCookie(n.cookie) === n.value;\n }\n}\n\n/** Consent Mode state folded from dataLayer commands, one storage type. */\ntype ConsentModeState = {\n /** Latest `update` — applies in every region and beats any default. */\n update: boolean | null;\n /** Latest region-less `default`. */\n global: boolean | null;\n /** Latest region-scoped `default`, per upper-cased region code. */\n regions: Map<string, boolean>;\n};\n\nconst emptyConsentModeState = (): ConsentModeState => ({ update: null, global: null, regions: new Map() });\n\nfunction foldConsentMode(state: ConsentModeState, item: unknown, type: string): void {\n // gtag() pushes `arguments` objects; GTM templates push arrays.\n const args = item && typeof item === 'object' && 'length' in (item as object) ? Array.prototype.slice.call(item) : null;\n if (!args || args[0] !== 'consent' || (args[1] !== 'default' && args[1] !== 'update')) return;\n const params = args[2] as Record<string, unknown> | undefined;\n const raw = params?.[type];\n const v = raw === 'granted' ? true : raw === 'denied' ? false : null;\n if (v === null) return;\n if (args[1] === 'update') {\n state.update = v;\n return;\n }\n const region = params?.region;\n const list = Array.isArray(region) ? region : typeof region === 'string' ? [region] : [];\n const codes = list.filter((r): r is string => typeof r === 'string' && r.trim() !== '').map((r) => r.trim().toUpperCase());\n if (codes.length === 0) state.global = v;\n else for (const c of codes) state.regions.set(c, v);\n}\n\n/** A recorded \"denied\" is an `update` only. A `default` is the site's\n * starting state, pushed on every page before the CMP answers (Google's own\n * recommended setup) — treating `default: denied` as a refusal forgot every\n * consented visitor whose CMP pushed its `update` a moment after we read. */\nfunction consentModeRefused(state: ConsentModeState): boolean {\n return state.update === false;\n}\n\nfunction resolveConsentMode(state: ConsentModeState, region: string | undefined): boolean | null {\n if (state.update !== null) return state.update;\n if (region) {\n // Most specific wins: 'US-CA' over 'US' over the global default.\n const exact = state.regions.get(region);\n if (exact !== undefined) return exact;\n const country = region.split('-')[0]!;\n const byCountry = state.regions.get(country);\n if (byCountry !== undefined) return byCountry;\n // Country only ('US', the usual CDN header) but a subdivision-scoped\n // denial ('US-CA'): the visitor may be in it, so it reads as denied.\n if (region === country) {\n for (const [r, v] of state.regions) if (v === false && r.startsWith(`${country}-`)) return false;\n }\n return state.global;\n }\n // Region unknown: a region-scoped denial may be this visitor's. The old\n // reader ignored `region` entirely, so the common EU setup — global\n // granted, `region: [EU…]` denied — read as granted for EU visitors.\n for (const v of state.regions.values()) if (v === false) return false;\n if (state.global !== null) return state.global;\n // Only region-scoped grants: this visitor may be outside all of them.\n return state.regions.size > 0 ? false : null;\n}\n\n/**\n * The Consent Mode state for `type` in `dataLayer`, or null when no command\n * has decided it. `region` (e.g. 'ES', 'US-CA') resolves region-scoped\n * `consent default` commands; without it, any region-scoped denial reads as\n * denied until an `update` settles it.\n */\nexport function consentModeGranted(dataLayer: unknown, type = 'analytics_storage', region?: string): boolean | null {\n if (!Array.isArray(dataLayer)) return null;\n const state = emptyConsentModeState();\n for (const item of dataLayer) foldConsentMode(state, item, type);\n return resolveConsentMode(state, region?.trim().toUpperCase() || undefined);\n}\n\n// ── Browser watcher ───────────────────────────────────────────────────────\n\nexport function consentWatcher(src: ConsentSource, win: Window = window): ConsentWatcher {\n const n = normalize(src);\n const w = win as AnyWin;\n const doc = win.document;\n switch (n.cmp) {\n case 'cookiebot':\n return {\n read: () => {\n const cb = w.Cookiebot as { consent?: Record<string, unknown>; hasResponse?: unknown } | undefined;\n const cookie = cookiebotCookieGrants(docCookie(doc, 'CookieConsent'), n.category);\n // The stored answer wins until Cookiebot says it has one in memory:\n // a `consent` object read before uc.js finishes initialising can hold\n // defaults (all false), and reading those for a returning visitor\n // gated them — or, with refused(), forgot them (grader N-D).\n if (cb?.consent && typeof cb.consent[n.category] === 'boolean' && (cb.hasResponse === true || cookie === null)) {\n return cb.consent[n.category] === true;\n }\n return cookie;\n },\n subscribe: (cb) => listen(win, ['CookiebotOnAccept', 'CookiebotOnDecline', 'CookiebotOnConsentReady', 'CookiebotOnLoad'], cb),\n // Only once the visitor has answered: `consent.statistics` is also\n // false while the banner is pending. The cookie is written on answer.\n refused() {\n const cb = w.Cookiebot as { hasResponse?: unknown } | undefined;\n const answered = cb?.hasResponse === true || docCookie(doc, 'CookieConsent') !== undefined;\n return answered && this.read() === false;\n },\n };\n case 'onetrust':\n return {\n read: () => {\n const groups = w.OnetrustActiveGroups;\n if (typeof groups === 'string') return `,${groups},`.includes(`,${n.group},`);\n return onetrustCookieGrants(docCookie(doc, 'OptanonConsent'), n.group);\n },\n subscribe: (cb) => listen(win, ['OneTrustGroupsUpdated'], cb),\n // OneTrust writes OptanonAlertBoxClosed when the visitor answers; before\n // that, an opt-in region's active groups are just the defaults.\n refused() {\n return docCookie(doc, 'OptanonAlertBoxClosed') !== undefined && this.read() === false;\n },\n };\n case 'cookieyes':\n return {\n read: () => {\n const get = w.getCkyConsent as (() => { categories?: Record<string, unknown> }) | undefined;\n if (typeof get === 'function') {\n try {\n const cats = get()?.categories;\n if (cats && typeof cats[n.category] === 'boolean') return cats[n.category] === true;\n } catch {\n /* banner not ready — fall through to the cookie */\n }\n }\n return cookieyesCookieGrants(docCookie(doc, 'cookieyes-consent'), n.category);\n },\n subscribe: (cb) => listen(win, ['cookieyes_consent_update', 'cookieyes_banner_load', 'cookieyes_banner_loaded'], cb),\n // Answered = the API says the user acted, or the cookie records\n // `action:yes`; the categories read false while the banner is pending.\n refused() {\n let answered = /(?:^|,)action:yes(?:,|$)/.test(decode(docCookie(doc, 'cookieyes-consent') ?? ''));\n const get = w.getCkyConsent as (() => { isUserActionCompleted?: unknown }) | undefined;\n if (!answered && typeof get === 'function') {\n try {\n answered = get()?.isUserActionCompleted === true;\n } catch {\n /* not ready */\n }\n }\n return answered && this.read() === false;\n },\n };\n case 'tcf': {\n let granted: boolean | null = null;\n // The banner being up is \"no decision yet\" (or a re-prompt), never a refusal.\n let bannerUp = false;\n // Forget-me needs storage itself refused (purpose 1). A decision that\n // grants storage but lacks 5/6/8 or the vendor only gates: many CMPs never\n // OFFER those purposes, and \"not offered\" is indistinguishable from \"no\"\n // in the TC data — forgetting on it wiped every accepting visitor on each\n // page of such sites (review #6).\n let storageRefused = false;\n return {\n read: () => granted,\n refused: () => granted === false && !bannerUp && storageRefused,\n subscribe: (cb) => {\n type TcData = {\n gdprApplies?: boolean;\n eventStatus?: string;\n listenerId?: number;\n purpose?: { consents?: Record<string, boolean>; legitimateInterests?: Record<string, boolean> };\n vendor?: { consents?: Record<string, boolean> };\n publisher?: { consents?: Record<string, boolean>; legitimateInterests?: Record<string, boolean> };\n purposeOneTreatment?: boolean;\n };\n type TcfApi = (cmd: string, v: number, cb: (d: TcData, ok: boolean) => void, param?: unknown) => void;\n let listenerId: number | undefined;\n let stopped = false;\n let everDecided = false;\n const onData = (d: TcData, ok: boolean): void => {\n if (!ok || stopped) return;\n if (typeof d.listenerId === 'number') listenerId = d.listenerId;\n // cmpuishown = the banner is up: no decision yet.\n bannerUp = d.eventStatus === 'cmpuishown';\n // Only a completed decision: some CMPs emit early/empty tcData\n // (cmpStatus 'loading') with ok=true — not a refusal (review #9).\n // purposeOneTreatment: purpose 1 isn't collected in this\n // jurisdiction, so its absence is not a refusal.\n storageRefused =\n (d.eventStatus === 'tcloaded' || d.eventStatus === 'useractioncomplete') &&\n d.purposeOneTreatment !== true &&\n d.gdprApplies !== false &&\n d.purpose?.consents?.[1] !== true &&\n d.publisher?.consents?.[1] !== true;\n const decided = d.eventStatus === 'tcloaded' || d.eventStatus === 'useractioncomplete';\n if (decided) everDecided = true;\n if (bannerUp) granted = false;\n // A loading/empty callback is \"not known yet\" (null), never false:\n // reading it as false disposed a server-granted client on load\n // and re-sent its decides (grader N7-5). After a decision it\n // changes nothing: the SDKs now read null-after-an-answer as a\n // pause, so a stray one paused a consented visitor (review R11 #2).\n else if (!decided && d.gdprApplies !== false) {\n if (!everDecided) granted = null;\n }\n else\n granted =\n d.gdprApplies === false ||\n tcfSatisfied(\n // Purpose 1 isn't collected under purposeOneTreatment: not\n // required then, or those visitors could never be granted\n // (N7-8).\n d.purposeOneTreatment === true ? { ...n, purposes: n.purposes.filter((p) => p !== 1) } : n,\n // Publisher consent counts too: SentientUI processes for the\n // site, and some CMPs record the site's own purposes only in\n // the publisher segment.\n (p) => d.purpose?.consents?.[p] === true || d.publisher?.consents?.[p] === true,\n (p) => d.purpose?.legitimateInterests?.[p] === true || d.publisher?.legitimateInterests?.[p] === true,\n (v) => d.vendor?.consents?.[v] === true,\n ) === true;\n cb();\n };\n // CMPs install the IAB stub early, but a late one needs a moment.\n let tries = 0;\n const attach = (): void => {\n if (stopped) return;\n const api = w.__tcfapi as TcfApi | undefined;\n if (typeof api === 'function') api('addEventListener', 2, onData);\n else if (tries++ < 40) window.setTimeout(attach, 250);\n };\n attach();\n return () => {\n stopped = true;\n const api = w.__tcfapi as TcfApi | undefined;\n if (typeof api === 'function' && listenerId !== undefined) api('removeEventListener', 2, () => undefined, listenerId);\n };\n },\n };\n }\n case 'google-consent-mode': {\n // Folded incrementally: each read scans only entries pushed since the\n // last one (the old reader rescanned the whole dataLayer every second —\n // GTM sites push hundreds of entries). A replaced or shrunk array\n // restarts the fold.\n let seen: unknown[] | null = null;\n let upTo = 0;\n let state = emptyConsentModeState();\n const read = (): boolean | null => {\n const dl = w[n.dataLayer];\n if (!Array.isArray(dl)) return null;\n if (dl !== seen || dl.length < upTo) {\n seen = dl;\n upTo = 0;\n state = emptyConsentModeState();\n }\n for (; upTo < dl.length; upTo++) foldConsentMode(state, dl[upTo], n.type);\n return resolveConsentMode(state, n.region);\n };\n return {\n read,\n refused: () => read() === false && consentModeRefused(state),\n subscribe: (cb) => {\n // Wrap push ONCE per array, and never re-wrap: gtag.js and GTM\n // replace dataLayer.push with a function that chains to the previous\n // one (ours), so wrapping theirs again made the two call each other\n // forever (caught by the real-gtag.js e2e, 2026-09-25). A\n // replacement that doesn't chain is covered by the poll, which is\n // O(1) — it compares lengths and calls `cb` only when entries arrived\n // (the old poll called it every second, forever, re-scanning all).\n const wrappedArrays = new WeakSet<object>();\n let stopped = false;\n const unwrap: Array<() => void> = [];\n let lastLen = -1;\n const attach = (): void => {\n const dl = (w[n.dataLayer] ??= []) as unknown[] & { push: (...a: unknown[]) => number };\n if (!wrappedArrays.has(dl)) {\n wrappedArrays.add(dl);\n const original = dl.push;\n const wrapped = function (this: unknown, ...a: unknown[]): number {\n const r = original.apply(dl, a);\n lastLen = dl.length;\n // gtag/GTM chain onto this wrapper, so it can't always be\n // unhooked on unsubscribe; a stopped one must go quiet.\n if (!stopped) cb();\n return r;\n };\n dl.push = wrapped;\n unwrap.push(() => {\n if (dl.push === wrapped) dl.push = original;\n });\n }\n if (dl.length !== lastLen) {\n lastLen = dl.length;\n cb();\n }\n };\n attach();\n const timer = window.setInterval(attach, 1000);\n return () => {\n stopped = true;\n window.clearInterval(timer);\n for (const u of unwrap) u();\n };\n },\n };\n }\n case 'shopify': {\n type CustomerPrivacy = Partial<Record<'analyticsProcessingAllowed' | 'marketingAllowed' | 'preferencesProcessingAllowed', () => unknown>>;\n type ShopifyGlobal = {\n customerPrivacy?: CustomerPrivacy;\n loadFeatures?: (features: Array<{ name: string; version: string }>, cb: (err?: unknown) => void) => void;\n };\n const method =\n n.category === 'marketing' ? 'marketingAllowed' : n.category === 'preferences' ? 'preferencesProcessingAllowed' : 'analyticsProcessingAllowed';\n return {\n read: () => {\n const fn = (w.Shopify as ShopifyGlobal | undefined)?.customerPrivacy?.[method];\n if (typeof fn !== 'function') return null; // API not loaded yet\n try {\n const v = fn();\n return typeof v === 'boolean' ? v : null;\n } catch {\n return null;\n }\n },\n // analyticsProcessingAllowed() is also false before the visitor has\n // answered in a consent region; only an explicit 'no' is a refusal.\n refused() {\n const priv = (w.Shopify as { customerPrivacy?: { currentVisitorConsent?: () => Record<string, unknown> } } | undefined)?.customerPrivacy;\n if (typeof priv?.currentVisitorConsent !== 'function') return false;\n try {\n return priv.currentVisitorConsent()?.[n.category] === 'no';\n } catch {\n return false;\n }\n },\n subscribe: (cb) => {\n const stopListen = listen(win, ['visitorConsentCollected'], cb);\n // The API is not on the page until something loads it; a theme's\n // own banner usually does, but nothing guarantees it.\n let stopped = false;\n let tries = 0;\n const load = (): void => {\n if (stopped) return;\n const shop = w.Shopify as ShopifyGlobal | undefined;\n if (shop?.customerPrivacy) {\n cb();\n return;\n }\n if (typeof shop?.loadFeatures === 'function') {\n try {\n shop.loadFeatures([{ name: 'consent-tracking-api', version: '0.1' }], (err) => {\n if (!stopped && !err) cb();\n });\n } catch {\n /* a broken storefront API never breaks the site */\n }\n return;\n }\n if (tries++ < 40) window.setTimeout(load, 250);\n };\n load();\n return () => {\n stopped = true;\n stopListen();\n };\n },\n };\n }\n case 'custom':\n return {\n read: () => {\n if (n.check) {\n try {\n return n.check() === true;\n } catch {\n return false;\n }\n }\n if (!n.cookie) return null;\n const v = docCookie(doc, n.cookie);\n // No cookie yet = no decision yet; any other value = not granted.\n return v === undefined ? null : v === n.value;\n },\n // A cookie holding another value is an answer; a predicate isn't —\n // unless the site says so through `refused` (grader F4).\n refused: () => {\n if (n.check) {\n try {\n return n.refused?.() === true;\n } catch {\n return false;\n }\n }\n return !!n.cookie && docCookie(doc, n.cookie) !== undefined && docCookie(doc, n.cookie) !== n.value;\n },\n subscribe: (cb) => (n.event ? listen(win, [n.event], cb) : () => undefined),\n };\n }\n}\n"],"mappings":"sHA+CO,IAAMA,EAA0C,CAAC,EAAG,EAAG,EAAG,CAAC,EAgE5DC,EAAUC,GAAsB,CACpC,GAAI,CACF,OAAO,mBAAmBA,CAAC,CAC7B,OAAQC,EAAA,CACN,OAAOD,CACT,CACF,EAEA,SAASE,EAAUC,EAA2BC,EAAkC,CAC9E,GAAKD,EACL,QAAWE,KAAQF,EAAI,OAAO,MAAM,GAAG,EAAG,CACxC,IAAMG,EAAID,EAAK,QAAQ,GAAG,EAC1B,GAAIC,EAAI,GAAKD,EAAK,MAAM,EAAGC,CAAC,EAAE,KAAK,IAAMF,EAAM,OAAOC,EAAK,MAAMC,EAAI,CAAC,EAAE,KAAK,CAC/E,CAEF,CAGA,SAASC,EAAOC,EAAaC,EAAiBC,EAA4B,CACxE,IAAMC,EAAyB,CAACH,EAAK,GAAIA,EAAI,SAAW,CAACA,EAAI,QAAQ,EAAI,CAAC,CAAE,EAC5E,QAAWI,KAAKD,EAAS,QAAWE,KAAKJ,EAAOG,EAAE,iBAAiBC,EAAGH,CAAE,EACxE,MAAO,IAAM,CACX,QAAWE,KAAKD,EAAS,QAAWE,KAAKJ,EAAOG,EAAE,oBAAoBC,EAAGH,CAAE,CAC7E,CACF,CAKO,SAASI,EAAsBC,EAAyBC,EAAW,aAA8B,CACtG,GAAID,GAAO,MAAQA,IAAQ,GAAI,OAAO,KACtC,IAAMf,EAAID,EAAOgB,CAAG,EAAE,KAAK,EAC3B,GAAIf,IAAM,KAAM,MAAO,GACvB,GAAIA,IAAM,IAAK,MAAO,GACtB,IAAMiB,EAAI,IAAI,OAA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,CACH,OAAQT,EAAA,CAER,CACA,MACF,CACIwG,IAAU,IAAI,OAAO,WAAWmB,EAAM,GAAG,CAC/C,EACA,OAAAA,EAAK,EACE,IAAM,CACXxB,EAAU,GACVuB,EAAW,CACb,CACF,CACF,CACF,CACA,IAAK,SACH,MAAO,CACL,KAAM,IAAM,CACV,GAAI9G,EAAE,MACJ,GAAI,CACF,OAAOA,EAAE,MAAM,IAAM,EACvB,OAAQZ,EAAA,CACN,MAAO,EACT,CAEF,GAAI,CAACY,EAAE,OAAQ,OAAO,KACtB,IAAMb,EAAIE,EAAUC,EAAKU,EAAE,MAAM,EAEjC,OAAOb,IAAM,OAAY,KAAOA,IAAMa,EAAE,KAC1C,EAGA,QAAS,IAAM,CApvBvB,IAAAwC,EAqvBU,GAAIxC,EAAE,MACJ,GAAI,CACF,QAAOwC,EAAAxC,EAAE,UAAF,YAAAwC,EAAA,KAAAxC,MAAkB,EAC3B,OAAQZ,EAAA,CACN,MAAO,EACT,CAEF,MAAO,CAAC,CAACY,EAAE,QAAUX,EAAUC,EAAKU,EAAE,MAAM,IAAM,QAAaX,EAAUC,EAAKU,EAAE,MAAM,IAAMA,EAAE,KAChG,EACA,UAAYH,GAAQG,EAAE,MAAQN,EAAOC,EAAK,CAACK,EAAE,KAAK,EAAGH,CAAE,EAAI,IAAG,EAChE,CACJ,CACF","names":["TCF_DEFAULT_PURPOSES","decode","v","e","docCookie","doc","name","part","i","listen","win","names","cb","targets","t","n","cookiebotCookieGrants","raw","category","m","onetrustCookieGrants","group","groups","field","pair","g","on","cookieyesCookieGrants","B64URL","toBits","seg","bits","ch","tcStringConsents","tc","segments","core","int","at","len","purposes","legitimateInterests","p","vendors","max","isRange","out","ok","range","start","end","publisherPurposes","publisherLegitimateInterests","pb","tcStringPurposes","_a","_b","TCF_CONSENT_ONLY","tcfSatisfied","consent","li","vendor","normalize","input","_c","_d","_e","_f","_g","src","consentFromCookies","getCookie","c","__spreadProps","__spreadValues","emptyConsentModeState","foldConsentMode","state","item","type","args","params","region","codes","r","consentModeRefused","resolveConsentMode","exact","country","byCountry","consentModeGranted","dataLayer","consentWatcher","w","cookie","get","cats","answered","granted","bannerUp","storageRefused","listenerId","stopped","everDecided","onData","d","decided","tries","attach","api","seen","upTo","read","dl","wrappedArrays","unwrap","lastLen","original","wrapped","a","timer","u","method","fn","priv","stopListen","load","shop","err"]}
|
|
1
|
+
{"version":3,"sources":["../src/consent-sources.ts"],"sourcesContent":["// Consent sources: where the SDK reads a visitor's consent decision from, so a\n// site keeps its own consent manager (CMP) and we only OBSERVE it. Shared by\n// React (`consentFrom`), Next.js `AdaptiveRoot` (server read of the CMP's own\n// cookie → SSR for visitors who already consented) and the snippet.\n//\n// Presets encode each platform's documented API, verified 2026-09-24:\n// - Cookiebot: `Cookiebot.consent.{preferences,statistics,marketing}`; window\n// events CookiebotOnAccept / CookiebotOnDecline (both also fire on load for a\n// returning visitor) / CookiebotOnConsentReady; cookie `CookieConsent` =\n// `{stamp:'…',necessary:true,preferences:…,statistics:…,marketing:…,…}`,\n// \"0\" = declined, \"-1\" = consent not required in the visitor's region.\n// - OneTrust: `OnetrustActiveGroups` (\",C0001,C0002,\"), window event\n// OneTrustGroupsUpdated; cookie `OptanonConsent` with `groups=C0001:1,C0002:0`.\n// C0002 = Performance.\n// - CookieYes: `getCkyConsent().categories.{functional,analytics,performance,\n// advertisement}` (only after the banner loads); `cookieyes_consent_update`\n// dispatched on DOCUMENT; cookie `cookieyes-consent` observed as\n// `consentid:…,consent:yes,…,analytics:yes,…` (not officially documented —\n// used server-side only, and an unrecognised value is \"unknown\", not \"no\").\n// - IAB TCF v2.2: `__tcfapi('addEventListener', 2, cb)`; granted when GDPR\n// doesn't apply or every required purpose is satisfied (consent; or, for a\n// purpose the policy lets rest on it, legitimate interest) and — when a\n// `vendorId` is configured — the vendor has consent. Server: the TC string\n// in `euconsent-v2` (the de-facto cookie; not every CMP writes it).\n// - Google Consent Mode v2: the latest `consent default|update` command in\n// `dataLayer` for the storage type. Most CMPs (Cookiebot, OneTrust,\n// CookieYes, Usercentrics, Didomi…) drive it, so it is a universal adapter.\n// `default` may carry `region: ['ES', 'US-CA']`: region-scoped defaults beat\n// the global one for visitors in those regions (most specific wins); an\n// `update` applies everywhere.\n// - Shopify Customer Privacy API (shopify.dev/docs/api/customer-privacy):\n// `Shopify.customerPrivacy.analyticsProcessingAllowed()` — already combines\n// the merchant's region settings, the visitor's location and their choice;\n// loaded via `Shopify.loadFeatures([{name:'consent-tracking-api'}])`;\n// `visitorConsentCollected` on DOCUMENT when consent changes. Shopify's own\n// banner and every Shopify CMP app are required to report into it.\n//\n// Every read is re-done from the source on each signal — an event payload is\n// never trusted — and a revocation reads false, which the callers turn into a\n// teardown. Unknown ≠ granted: a source that can't be read gates.\n\nexport type ConsentPreset = 'cookiebot' | 'onetrust' | 'cookieyes' | 'tcf' | 'google-consent-mode' | 'shopify';\n\n/** TCF purposes the SDK's processing needs: 1 store/access on a device,\n * 5 build a personalised-content profile, 6 select personalised content from\n * it, 8 measure content performance. The old default was purpose 1 alone —\n * storage consent, which says nothing about profiling or measurement. */\nexport const TCF_DEFAULT_PURPOSES: readonly number[] = [1, 5, 6, 8];\n\nexport type ConsentSource =\n | ConsentPreset\n | { cmp: 'cookiebot'; category?: 'preferences' | 'statistics' | 'marketing' }\n | { cmp: 'onetrust'; group?: string }\n | { cmp: 'cookieyes'; category?: 'functional' | 'analytics' | 'performance' | 'advertisement' }\n | {\n cmp: 'tcf';\n /** Purposes that must be satisfied. @default TCF_DEFAULT_PURPOSES (1, 5, 6, 8) */\n purposes?: number[];\n /** Also require consent for this Global Vendor List id. SentientUI is a\n * processor for your site and has no GVL id of its own; set this only if\n * your CMP lists a vendor entry you map it to. */\n vendorId?: number;\n }\n | {\n cmp: 'google-consent-mode';\n type?: 'analytics_storage' | 'ad_storage' | 'personalization_storage' | 'functionality_storage';\n dataLayer?: string;\n /** The visitor's region (ISO 3166-1 alpha-2, optionally `-` ISO 3166-2\n * subdivision: 'ES', 'US-CA'), e.g. from your CDN's country header.\n * Resolves region-scoped `consent default` commands exactly. Without it\n * a region-scoped denial can't be ruled out, so it reads as denied. */\n region?: string;\n }\n | {\n cmp: 'shopify';\n /** Which Customer Privacy purpose to require. @default 'analytics' */\n category?: 'analytics' | 'marketing' | 'preferences';\n }\n | {\n cmp?: undefined;\n /** Cookie to read. Granted when its value equals `value`. */\n cookie?: string;\n /** Cookie value that means granted. @default 'accepted' */\n value?: string;\n /** Predicate for CMPs with a JS API. Takes precedence over `cookie`. */\n check?: () => boolean;\n /** Event that signals a decision (listened on window AND document). */\n event?: string;\n /** With `check`: true when the visitor has actually REFUSED (not merely\n * not answered yet). A predicate can't say why it returned false, so\n * without this a `check` source only pauses tracking and never forgets. */\n refused?: () => boolean;\n };\n\nexport type ConsentWatcher = {\n /** The decision right now: true/false, or null when the source can't tell\n * yet (CMP not loaded, no decision stored). Callers treat null as \"keep\n * whatever you knew\" — e.g. the server's read — and never as granted. */\n read(): boolean | null;\n /** True only when the source records an actual refusal — a \"no\" that\n * justifies deleting what the SDK stored (forget-me), not merely gating.\n * False while the platform is loading, while its banner is up (TCF\n * `cmpuishown`), for a region-conservative Consent Mode read, and for\n * `check()` sources (a predicate can't say why it returned false). */\n refused(): boolean;\n /** Call `onChange` whenever the decision may have changed. */\n subscribe(onChange: () => void): () => void;\n};\n\ntype AnyWin = Window & Record<string, unknown>;\n\nconst decode = (v: string): string => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n};\n\nfunction docCookie(doc: Document | undefined, name: string): string | undefined {\n if (!doc) return undefined;\n for (const part of doc.cookie.split(';')) {\n const i = part.indexOf('=');\n if (i > 0 && part.slice(0, i).trim() === name) return part.slice(i + 1).trim();\n }\n return undefined;\n}\n\n/** Listen to `names` on both window and document (CMPs use either). */\nfunction listen(win: Window, names: string[], cb: () => void): () => void {\n const targets: EventTarget[] = [win, ...(win.document ? [win.document] : [])];\n for (const t of targets) for (const n of names) t.addEventListener(n, cb);\n return () => {\n for (const t of targets) for (const n of names) t.removeEventListener(n, cb);\n };\n}\n\n// ── Cookie parsers (also used server-side) ────────────────────────────────\n\n/** Cookiebot `CookieConsent`: true/false for `category`, null when unknown. */\nexport function cookiebotCookieGrants(raw: string | undefined, category = 'statistics'): boolean | null {\n if (raw == null || raw === '') return null;\n const v = decode(raw).trim();\n if (v === '-1') return true; // consent not required in this region\n if (v === '0') return false;\n const m = new RegExp(`[{,]\\\\s*${category}\\\\s*:\\\\s*(true|false)`).exec(v);\n return m ? m[1] === 'true' : null;\n}\n\n/** OneTrust `OptanonConsent`: is `group` active? null when unknown. Pass the\n * raw cookie value, not a decoded one (see {@link consentFromCookies}). */\nexport function onetrustCookieGrants(raw: string | undefined, group = 'C0002'): boolean | null {\n if (raw == null || raw === '') return null;\n // Split on the RAW `&` first, then decode only the groups value: decoding\n // the whole cookie first let an encoded `&groups=C0002:1` inside\n // `landingPath` (the landing URL, before any answer) read as consent\n // (grader N7-1). The LAST `groups` field counts: a caller whose cookie jar\n // already decoded the value (Next's cookies() does) hands us that injected\n // field as a real one, and landingPath is written before OneTrust's own\n // `groups` (grader R8 NEW-1).\n let groups: string | undefined;\n for (const field of raw.split('&')) {\n if (field.startsWith('groups=')) groups = decode(field.slice('groups='.length));\n }\n if (groups == null) return null;\n for (const pair of groups.split(',')) {\n const [g, on] = pair.split(':');\n if (g === group) return on === '1';\n }\n return null;\n}\n\n/** CookieYes `cookieyes-consent`: `category:yes|no`, null when unrecognised. */\nexport function cookieyesCookieGrants(raw: string | undefined, category = 'analytics'): boolean | null {\n if (raw == null || raw === '') return null;\n const m = new RegExp(`(?:^|,)${category}:(yes|no)(?:,|$)`).exec(decode(raw));\n return m ? m[1] === 'yes' : null;\n}\n\nexport type TcConsents = {\n purposes: Set<number>;\n legitimateInterests: Set<number>;\n /** Vendor ids with consent; null when the vendor section is truncated. */\n vendors: Set<number> | null;\n /** The publisher segment (type 3): the site's own purposes. Empty sets when\n * the string carries none. */\n publisherPurposes: Set<number>;\n publisherLegitimateInterests: Set<number>;\n /** PurposeOneTreatment (bit 200): purpose 1 is not collected. */\n purposeOneTreatment: boolean;\n};\n\n/**\n * Decode an IAB TCF v2 TC string's core segment. Bit layout (TCF v2.2 spec):\n * Version 6 · Created 36 · LastUpdated 36 · CmpId 12 · CmpVersion 12 ·\n * ConsentScreen 6 · ConsentLanguage 12 · VendorListVersion 12 ·\n * TcfPolicyVersion 6 · IsServiceSpecific 1 · UseNonStandardTexts 1 ·\n * SpecialFeatureOptIns 12 · PurposesConsent 24 (bit 152) ·\n * PurposesLITransparency 24 (bit 176) · PurposeOneTreatment 1 · PublisherCC 12\n * · then the vendor-consent section at bit 213: MaxVendorId 16 ·\n * IsRangeEncoding 1 · a MaxVendorId-bit field, or NumEntries 12 and entries\n * of IsARange 1 · Start 16 · [End 16]. Null for anything that isn't v2.\n */\nconst B64URL = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';\nconst toBits = (seg: string): string => {\n let bits = '';\n for (const ch of seg) bits += B64URL.indexOf(ch).toString(2).padStart(6, '0');\n return bits;\n};\n\nexport function tcStringConsents(tc: string | undefined): TcConsents | null {\n if (!tc) return null;\n const segments = tc.split('.');\n const core = segments[0]!;\n if (!/^[A-Za-z0-9_-]+$/.test(core)) return null;\n const bits = toBits(core);\n if (bits.length < 200 || parseInt(bits.slice(0, 6), 2) !== 2) return null;\n const int = (at: number, len: number): number | null => (at + len <= bits.length ? parseInt(bits.slice(at, at + len), 2) : null);\n const purposes = new Set<number>();\n const legitimateInterests = new Set<number>();\n for (let p = 1; p <= 24; p++) {\n if (bits[151 + p] === '1') purposes.add(p);\n if (bits[175 + p] === '1') legitimateInterests.add(p);\n }\n let vendors: Set<number> | null = null;\n const max = int(213, 16);\n const isRange = int(229, 1);\n if (max !== null && isRange === 0) {\n if (230 + max <= bits.length) {\n vendors = new Set();\n for (let v = 1; v <= max; v++) if (bits[229 + v] === '1') vendors.add(v);\n }\n } else if (max !== null && isRange === 1) {\n const n = int(230, 12);\n let at = 242;\n const out = new Set<number>();\n let ok = n !== null;\n for (let i = 0; ok && i < (n ?? 0); i++) {\n const range = int(at, 1);\n const start = int(at + 1, 16);\n if (range === null || start === null) ok = false;\n else if (range === 1) {\n const end = int(at + 17, 16);\n if (end === null || end < start || end - start > 65535) ok = false;\n else for (let v = start; v <= end; v++) out.add(v);\n at += 33;\n } else {\n out.add(start);\n at += 17;\n }\n }\n if (ok) vendors = out;\n }\n // Publisher TC segment: SegmentType 3 · PubPurposesConsent 24 ·\n // PubPurposesLITransparency 24 (then custom purposes, unused here).\n const publisherPurposes = new Set<number>();\n const publisherLegitimateInterests = new Set<number>();\n for (const seg of segments.slice(1)) {\n if (!/^[A-Za-z0-9_-]+$/.test(seg)) continue;\n const pb = toBits(seg);\n if (pb.length < 51 || parseInt(pb.slice(0, 3), 2) !== 3) continue;\n for (let p = 1; p <= 24; p++) {\n if (pb[2 + p] === '1') publisherPurposes.add(p);\n if (pb[26 + p] === '1') publisherLegitimateInterests.add(p);\n }\n }\n return { purposes, legitimateInterests, vendors, publisherPurposes, publisherLegitimateInterests, purposeOneTreatment: bits[200] === '1' };\n}\n\n/** Purpose consents only — kept for callers of the pre-vendor parser. */\nexport function tcStringPurposes(tc: string | undefined): Set<number> | null {\n return tcStringConsents(tc)?.purposes ?? null;\n}\n\n// TCF policy: purposes 1, 3, 4, 5 and 6 need consent; the rest may rest on a\n// legitimate interest the visitor didn't object to.\nconst TCF_CONSENT_ONLY = new Set([1, 3, 4, 5, 6]);\n\nfunction tcfSatisfied(\n n: { purposes: readonly number[]; vendorId?: number },\n consent: (p: number) => boolean,\n li: (p: number) => boolean,\n vendor: (v: number) => boolean | null,\n): boolean | null {\n const purposesOk = n.purposes.every((p) => consent(p) || (!TCF_CONSENT_ONLY.has(p) && li(p)));\n if (!purposesOk) return false;\n if (n.vendorId === undefined) return true;\n return vendor(n.vendorId);\n}\n\n// ── Normalisation ─────────────────────────────────────────────────────────\n\ntype Norm =\n | { cmp: 'cookiebot'; category: string }\n | { cmp: 'onetrust'; group: string }\n | { cmp: 'cookieyes'; category: string }\n | { cmp: 'tcf'; purposes: readonly number[]; vendorId?: number }\n | { cmp: 'google-consent-mode'; type: string; dataLayer: string; region?: string }\n | { cmp: 'shopify'; category: 'analytics' | 'marketing' | 'preferences' }\n | { cmp: 'custom'; cookie?: string; value: string; check?: () => boolean; event?: string; refused?: () => boolean };\n\nfunction normalize(input: ConsentSource): Norm {\n const src = (typeof input === 'string' ? { cmp: input } : input) as Exclude<ConsentSource, string>;\n switch (src.cmp) {\n case 'cookiebot':\n return { cmp: 'cookiebot', category: src.category ?? 'statistics' };\n case 'onetrust':\n return { cmp: 'onetrust', group: src.group ?? 'C0002' };\n case 'cookieyes':\n return { cmp: 'cookieyes', category: src.category ?? 'analytics' };\n case 'tcf':\n return {\n cmp: 'tcf',\n purposes: src.purposes && src.purposes.length > 0 ? src.purposes : TCF_DEFAULT_PURPOSES,\n vendorId: typeof src.vendorId === 'number' && src.vendorId > 0 ? src.vendorId : undefined,\n };\n case 'google-consent-mode':\n return {\n cmp: 'google-consent-mode',\n type: src.type ?? 'analytics_storage',\n dataLayer: src.dataLayer ?? 'dataLayer',\n region: typeof src.region === 'string' && src.region.trim() !== '' ? src.region.trim().toUpperCase() : undefined,\n };\n case 'shopify':\n return { cmp: 'shopify', category: src.category ?? 'analytics' };\n default:\n return { cmp: 'custom', cookie: src.cookie, value: src.value ?? 'accepted', check: src.check, event: src.event, refused: src.refused };\n }\n}\n\n/**\n * Server-side read from the request's cookies (Next.js `AdaptiveRoot`).\n * true/false when the CMP's cookie decides it, null when it can't be known on\n * the server (no cookie yet, a JS-only source) — the caller then gates the\n * first paint and lets the browser decide.\n *\n * `getCookie` must return the value exactly as sent in the Cookie header,\n * NOT decoded: most server cookie jars (Next's cookies(), Express\n * cookie-parser) decode values, and a decoded OneTrust cookie lets a crafted\n * landing URL inject a `groups=` field that reads as consent.\n */\nexport function consentFromCookies(src: ConsentSource, getCookie: (name: string) => string | undefined): boolean | null {\n const n = normalize(src);\n switch (n.cmp) {\n case 'cookiebot':\n return cookiebotCookieGrants(getCookie('CookieConsent'), n.category);\n case 'onetrust':\n return onetrustCookieGrants(getCookie('OptanonConsent'), n.group);\n case 'cookieyes':\n return cookieyesCookieGrants(getCookie('cookieyes-consent'), n.category);\n case 'tcf': {\n const c = tcStringConsents(getCookie('euconsent-v2'));\n if (!c) return null;\n return tcfSatisfied(\n c.purposeOneTreatment ? { ...n, purposes: n.purposes.filter((p) => p !== 1) } : n,\n (p) => c.purposes.has(p) || c.publisherPurposes.has(p),\n (p) => c.legitimateInterests.has(p) || c.publisherLegitimateInterests.has(p),\n (v) => (c.vendors ? c.vendors.has(v) : null),\n );\n }\n case 'google-consent-mode':\n return null;\n case 'shopify':\n // `_tracking_consent` is undocumented; the browser API decides.\n return null;\n case 'custom':\n if (!n.cookie || n.check) return null;\n return getCookie(n.cookie) === n.value;\n }\n}\n\n/** Consent Mode state folded from dataLayer commands, one storage type. */\ntype ConsentModeState = {\n /** Latest `update` — applies in every region and beats any default. */\n update: boolean | null;\n /** Latest region-less `default`. */\n global: boolean | null;\n /** Latest region-scoped `default`, per upper-cased region code. */\n regions: Map<string, boolean>;\n};\n\nconst emptyConsentModeState = (): ConsentModeState => ({ update: null, global: null, regions: new Map() });\n\nfunction foldConsentMode(state: ConsentModeState, item: unknown, type: string): void {\n // gtag() pushes `arguments` objects; GTM templates push arrays.\n const args = item && typeof item === 'object' && 'length' in (item as object) ? Array.prototype.slice.call(item) : null;\n if (!args || args[0] !== 'consent' || (args[1] !== 'default' && args[1] !== 'update')) return;\n const params = args[2] as Record<string, unknown> | undefined;\n const raw = params?.[type];\n const v = raw === 'granted' ? true : raw === 'denied' ? false : null;\n if (v === null) return;\n if (args[1] === 'update') {\n state.update = v;\n return;\n }\n const region = params?.region;\n const list = Array.isArray(region) ? region : typeof region === 'string' ? [region] : [];\n const codes = list.filter((r): r is string => typeof r === 'string' && r.trim() !== '').map((r) => r.trim().toUpperCase());\n if (codes.length === 0) state.global = v;\n else for (const c of codes) state.regions.set(c, v);\n}\n\n/** A recorded \"denied\" is an `update` only. A `default` is the site's\n * starting state, pushed on every page before the CMP answers (Google's own\n * recommended setup) — treating `default: denied` as a refusal forgot every\n * consented visitor whose CMP pushed its `update` a moment after we read. */\nfunction consentModeRefused(state: ConsentModeState): boolean {\n return state.update === false;\n}\n\nfunction resolveConsentMode(state: ConsentModeState, region: string | undefined): boolean | null {\n if (state.update !== null) return state.update;\n if (region) {\n // Most specific wins: 'US-CA' over 'US' over the global default.\n const exact = state.regions.get(region);\n if (exact !== undefined) return exact;\n const country = region.split('-')[0]!;\n const byCountry = state.regions.get(country);\n if (byCountry !== undefined) return byCountry;\n // Country only ('US', the usual CDN header) but a subdivision-scoped\n // denial ('US-CA'): the visitor may be in it, so it reads as denied.\n if (region === country) {\n for (const [r, v] of state.regions) if (v === false && r.startsWith(`${country}-`)) return false;\n }\n return state.global;\n }\n // Region unknown: a region-scoped denial may be this visitor's. The old\n // reader ignored `region` entirely, so the common EU setup — global\n // granted, `region: [EU…]` denied — read as granted for EU visitors.\n for (const v of state.regions.values()) if (v === false) return false;\n if (state.global !== null) return state.global;\n // Only region-scoped grants: this visitor may be outside all of them.\n return state.regions.size > 0 ? false : null;\n}\n\n/**\n * The Consent Mode state for `type` in `dataLayer`, or null when no command\n * has decided it. `region` (e.g. 'ES', 'US-CA') resolves region-scoped\n * `consent default` commands; without it, any region-scoped denial reads as\n * denied until an `update` settles it.\n */\nexport function consentModeGranted(dataLayer: unknown, type = 'analytics_storage', region?: string): boolean | null {\n if (!Array.isArray(dataLayer)) return null;\n const state = emptyConsentModeState();\n for (const item of dataLayer) foldConsentMode(state, item, type);\n return resolveConsentMode(state, region?.trim().toUpperCase() || undefined);\n}\n\n// ── Browser watcher ───────────────────────────────────────────────────────\n\nexport function consentWatcher(src: ConsentSource, win: Window = window): ConsentWatcher {\n const n = normalize(src);\n const w = win as AnyWin;\n const doc = win.document;\n switch (n.cmp) {\n case 'cookiebot':\n return {\n read: () => {\n const cb = w.Cookiebot as { consent?: Record<string, unknown>; hasResponse?: unknown } | undefined;\n const cookie = cookiebotCookieGrants(docCookie(doc, 'CookieConsent'), n.category);\n // The stored answer wins until Cookiebot says it has one in memory:\n // a `consent` object read before uc.js finishes initialising can hold\n // defaults (all false), and reading those for a returning visitor\n // gated them — or, with refused(), forgot them (grader N-D).\n if (cb?.consent && typeof cb.consent[n.category] === 'boolean' && (cb.hasResponse === true || cookie === null)) {\n return cb.consent[n.category] === true;\n }\n return cookie;\n },\n subscribe: (cb) => listen(win, ['CookiebotOnAccept', 'CookiebotOnDecline', 'CookiebotOnConsentReady', 'CookiebotOnLoad'], cb),\n // Only once the visitor has answered: `consent.statistics` is also\n // false while the banner is pending. The cookie is written on answer.\n refused() {\n const cb = w.Cookiebot as { hasResponse?: unknown } | undefined;\n const answered = cb?.hasResponse === true || docCookie(doc, 'CookieConsent') !== undefined;\n return answered && this.read() === false;\n },\n };\n case 'onetrust':\n return {\n read: () => {\n const groups = w.OnetrustActiveGroups;\n if (typeof groups === 'string') return `,${groups},`.includes(`,${n.group},`);\n return onetrustCookieGrants(docCookie(doc, 'OptanonConsent'), n.group);\n },\n subscribe: (cb) => listen(win, ['OneTrustGroupsUpdated'], cb),\n // OneTrust writes OptanonAlertBoxClosed when the visitor answers; before\n // that, an opt-in region's active groups are just the defaults.\n refused() {\n return docCookie(doc, 'OptanonAlertBoxClosed') !== undefined && this.read() === false;\n },\n };\n case 'cookieyes':\n return {\n read: () => {\n const get = w.getCkyConsent as (() => { categories?: Record<string, unknown> }) | undefined;\n if (typeof get === 'function') {\n try {\n const cats = get()?.categories;\n if (cats && typeof cats[n.category] === 'boolean') return cats[n.category] === true;\n } catch {\n /* banner not ready — fall through to the cookie */\n }\n }\n return cookieyesCookieGrants(docCookie(doc, 'cookieyes-consent'), n.category);\n },\n subscribe: (cb) => listen(win, ['cookieyes_consent_update', 'cookieyes_banner_load', 'cookieyes_banner_loaded'], cb),\n // Answered = the API says the user acted, or the cookie records\n // `action:yes`; the categories read false while the banner is pending.\n refused() {\n let answered = /(?:^|,)action:yes(?:,|$)/.test(decode(docCookie(doc, 'cookieyes-consent') ?? ''));\n const get = w.getCkyConsent as (() => { isUserActionCompleted?: unknown }) | undefined;\n if (!answered && typeof get === 'function') {\n try {\n answered = get()?.isUserActionCompleted === true;\n } catch {\n /* not ready */\n }\n }\n return answered && this.read() === false;\n },\n };\n case 'tcf': {\n let granted: boolean | null = null;\n // The banner being up is \"no decision yet\" (or a re-prompt), never a refusal.\n let bannerUp = false;\n // Forget-me needs storage itself refused (purpose 1). A decision that\n // grants storage but lacks 5/6/8 or the vendor only gates: many CMPs never\n // OFFER those purposes, and \"not offered\" is indistinguishable from \"no\"\n // in the TC data — forgetting on it wiped every accepting visitor on each\n // page of such sites (review #6).\n let storageRefused = false;\n return {\n read: () => granted,\n refused: () => granted === false && !bannerUp && storageRefused,\n subscribe: (cb) => {\n type TcData = {\n gdprApplies?: boolean;\n eventStatus?: string;\n listenerId?: number;\n purpose?: { consents?: Record<string, boolean>; legitimateInterests?: Record<string, boolean> };\n vendor?: { consents?: Record<string, boolean> };\n publisher?: { consents?: Record<string, boolean>; legitimateInterests?: Record<string, boolean> };\n purposeOneTreatment?: boolean;\n };\n type TcfApi = (cmd: string, v: number, cb: (d: TcData, ok: boolean) => void, param?: unknown) => void;\n let listenerId: number | undefined;\n let stopped = false;\n let everDecided = false;\n const onData = (d: TcData, ok: boolean): void => {\n if (!ok || stopped) return;\n if (typeof d.listenerId === 'number') listenerId = d.listenerId;\n // cmpuishown = the banner is up: no decision yet.\n bannerUp = d.eventStatus === 'cmpuishown';\n // Only a completed decision: some CMPs emit early/empty tcData\n // (cmpStatus 'loading') with ok=true — not a refusal (review #9).\n // purposeOneTreatment: purpose 1 isn't collected in this\n // jurisdiction, so its absence is not a refusal.\n storageRefused =\n (d.eventStatus === 'tcloaded' || d.eventStatus === 'useractioncomplete') &&\n d.purposeOneTreatment !== true &&\n d.gdprApplies !== false &&\n d.purpose?.consents?.[1] !== true &&\n d.publisher?.consents?.[1] !== true;\n const decided = d.eventStatus === 'tcloaded' || d.eventStatus === 'useractioncomplete';\n if (decided) everDecided = true;\n if (bannerUp) granted = false;\n // A loading/empty callback is \"not known yet\" (null), never false:\n // reading it as false disposed a server-granted client on load\n // and re-sent its decides (grader N7-5). After a decision it\n // changes nothing: the SDKs now read null-after-an-answer as a\n // pause, so a stray one paused a consented visitor (review R11 #2).\n else if (!decided && d.gdprApplies !== false) {\n if (!everDecided) granted = null;\n }\n else\n granted =\n d.gdprApplies === false ||\n tcfSatisfied(\n // Purpose 1 isn't collected under purposeOneTreatment: not\n // required then, or those visitors could never be granted\n // (N7-8).\n d.purposeOneTreatment === true ? { ...n, purposes: n.purposes.filter((p) => p !== 1) } : n,\n // Publisher consent counts too: SentientUI processes for the\n // site, and some CMPs record the site's own purposes only in\n // the publisher segment.\n (p) => d.purpose?.consents?.[p] === true || d.publisher?.consents?.[p] === true,\n (p) => d.purpose?.legitimateInterests?.[p] === true || d.publisher?.legitimateInterests?.[p] === true,\n (v) => d.vendor?.consents?.[v] === true,\n ) === true;\n cb();\n };\n // CMPs install the IAB stub early, but a late one needs a moment.\n let tries = 0;\n const attach = (): void => {\n if (stopped) return;\n const api = w.__tcfapi as TcfApi | undefined;\n if (typeof api === 'function') api('addEventListener', 2, onData);\n else if (tries++ < 40) window.setTimeout(attach, 250);\n };\n attach();\n return () => {\n stopped = true;\n const api = w.__tcfapi as TcfApi | undefined;\n if (typeof api === 'function' && listenerId !== undefined) api('removeEventListener', 2, () => undefined, listenerId);\n };\n },\n };\n }\n case 'google-consent-mode': {\n // Folded incrementally: each read scans only entries pushed since the\n // last one (the old reader rescanned the whole dataLayer every second —\n // GTM sites push hundreds of entries). A replaced or shrunk array\n // restarts the fold.\n let seen: unknown[] | null = null;\n let upTo = 0;\n let state = emptyConsentModeState();\n const read = (): boolean | null => {\n const dl = w[n.dataLayer];\n if (!Array.isArray(dl)) return null;\n if (dl !== seen || dl.length < upTo) {\n seen = dl;\n upTo = 0;\n state = emptyConsentModeState();\n }\n for (; upTo < dl.length; upTo++) foldConsentMode(state, dl[upTo], n.type);\n return resolveConsentMode(state, n.region);\n };\n return {\n read,\n refused: () => read() === false && consentModeRefused(state),\n subscribe: (cb) => {\n // Wrap push ONCE per array, and never re-wrap: gtag.js and GTM\n // replace dataLayer.push with a function that chains to the previous\n // one (ours), so wrapping theirs again made the two call each other\n // forever (caught by the real-gtag.js e2e, 2026-09-25). A\n // replacement that doesn't chain is covered by the poll, which is\n // O(1) — it compares lengths and calls `cb` only when entries arrived\n // (the old poll called it every second, forever, re-scanning all).\n const wrappedArrays = new WeakSet<object>();\n let stopped = false;\n const unwrap: Array<() => void> = [];\n let lastLen = -1;\n const attach = (): void => {\n const dl = (w[n.dataLayer] ??= []) as unknown[] & { push: (...a: unknown[]) => number };\n if (!wrappedArrays.has(dl)) {\n wrappedArrays.add(dl);\n const original = dl.push;\n const wrapped = function (this: unknown, ...a: unknown[]): number {\n const r = original.apply(dl, a);\n lastLen = dl.length;\n // gtag/GTM chain onto this wrapper, so it can't always be\n // unhooked on unsubscribe; a stopped one must go quiet.\n if (!stopped) cb();\n return r;\n };\n dl.push = wrapped;\n unwrap.push(() => {\n if (dl.push === wrapped) dl.push = original;\n });\n }\n if (dl.length !== lastLen) {\n lastLen = dl.length;\n cb();\n }\n };\n attach();\n const timer = window.setInterval(attach, 1000);\n return () => {\n stopped = true;\n window.clearInterval(timer);\n for (const u of unwrap) u();\n };\n },\n };\n }\n case 'shopify': {\n type CustomerPrivacy = Partial<Record<'analyticsProcessingAllowed' | 'marketingAllowed' | 'preferencesProcessingAllowed', () => unknown>>;\n type ShopifyGlobal = {\n customerPrivacy?: CustomerPrivacy;\n loadFeatures?: (features: Array<{ name: string; version: string }>, cb: (err?: unknown) => void) => void;\n };\n const method =\n n.category === 'marketing' ? 'marketingAllowed' : n.category === 'preferences' ? 'preferencesProcessingAllowed' : 'analyticsProcessingAllowed';\n return {\n read: () => {\n const fn = (w.Shopify as ShopifyGlobal | undefined)?.customerPrivacy?.[method];\n if (typeof fn !== 'function') return null; // API not loaded yet\n try {\n const v = fn();\n return typeof v === 'boolean' ? v : null;\n } catch {\n return null;\n }\n },\n // analyticsProcessingAllowed() is also false before the visitor has\n // answered in a consent region; only an explicit 'no' is a refusal.\n refused() {\n const priv = (w.Shopify as { customerPrivacy?: { currentVisitorConsent?: () => Record<string, unknown> } } | undefined)?.customerPrivacy;\n if (typeof priv?.currentVisitorConsent !== 'function') return false;\n try {\n return priv.currentVisitorConsent()?.[n.category] === 'no';\n } catch {\n return false;\n }\n },\n subscribe: (cb) => {\n const stopListen = listen(win, ['visitorConsentCollected'], cb);\n // The API is not on the page until something loads it; a theme's\n // own banner usually does, but nothing guarantees it.\n let stopped = false;\n let tries = 0;\n const load = (): void => {\n if (stopped) return;\n const shop = w.Shopify as ShopifyGlobal | undefined;\n if (shop?.customerPrivacy) {\n cb();\n return;\n }\n if (typeof shop?.loadFeatures === 'function') {\n try {\n shop.loadFeatures([{ name: 'consent-tracking-api', version: '0.1' }], (err) => {\n if (!stopped && !err) cb();\n });\n } catch {\n /* a broken storefront API never breaks the site */\n }\n return;\n }\n if (tries++ < 40) window.setTimeout(load, 250);\n };\n load();\n return () => {\n stopped = true;\n stopListen();\n };\n },\n };\n }\n case 'custom':\n return {\n read: () => {\n if (n.check) {\n try {\n return n.check() === true;\n } catch {\n return false;\n }\n }\n if (!n.cookie) return null;\n const v = docCookie(doc, n.cookie);\n // No cookie yet = no decision yet; any other value = not granted.\n return v === undefined ? null : v === n.value;\n },\n // A cookie holding another value is an answer; a predicate isn't —\n // unless the site says so through `refused` (grader F4).\n refused: () => {\n if (n.check) {\n try {\n return n.refused?.() === true;\n } catch {\n return false;\n }\n }\n return !!n.cookie && docCookie(doc, n.cookie) !== undefined && docCookie(doc, n.cookie) !== n.value;\n },\n subscribe: (cb)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V,GAAI9G,EAAE,MACJ,GAAI,CACF,OAAOA,EAAE,MAAM,IAAM,EACvB,OAAQZ,EAAA,CACN,MAAO,EACT,CAEF,GAAI,CAACY,EAAE,OAAQ,OAAO,KACtB,IAAMb,EAAIE,EAAUC,EAAKU,EAAE,MAAM,EAEjC,OAAOb,IAAM,OAAY,KAAOA,IAAMa,EAAE,KAC1C,EAGA,QAAS,IAAM,CApvBvB,IAAAwC,EAqvBU,GAAIxC,EAAE,MACJ,GAAI,CACF,QAAOwC,EAAAxC,EAAE,UAAF,YAAAwC,EAAA,KAAAxC,MAAkB,EAC3B,OAAQZ,EAAA,CACN,MAAO,EACT,CAEF,MAAO,CAAC,CAACY,EAAE,QAAUX,EAAUC,EAAKU,EAAE,MAAM,IAAM,QAAaX,EAAUC,EAAKU,EAAE,MAAM,IAAMA,EAAE,KAChG,EACA,UAAYH,GAAQG,EAAE,MAAQN,EAAOC,EAAK,CAACK,EAAE,KAAK,EAAGH,CAAE,EAAI,IAAG,EAChE,CACJ,CACF","names":["TCF_DEFAULT_PURPOSES","decode","v","e","docCookie","doc","name","part","i","listen","win","names","cb","targets","t","n","cookiebotCookieGrants","raw","category","m","onetrustCookieGrants","group","groups","field","pair","g","on","cookieyesCookieGrants","B64URL","toBits","seg","bits","ch","tcStringConsents","tc","segments","core","int","at","len","purposes","legitimateInterests","p","vendors","max","isRange","out","ok","range","start","end","publisherPurposes","publisherLegitimateInterests","pb","tcStringPurposes","_a","_b","TCF_CONSENT_ONLY","tcfSatisfied","consent","li","vendor","normalize","input","_c","_d","_e","_f","_g","src","consentFromCookies","getCookie","c","__spreadProps","__spreadValues","emptyConsentModeState","foldConsentMode","state","item","type","args","params","region","codes","r","consentModeRefused","resolveConsentMode","exact","country","byCountry","consentModeGranted","dataLayer","consentWatcher","w","cookie","get","cats","answered","granted","bannerUp","storageRefused","listenerId","stopped","everDecided","onData","d","decided","tries","attach","api","seen","upTo","read","dl","wrappedArrays","unwrap","lastLen","original","wrapped","a","timer","u","method","fn","priv","stopListen","load","shop","err"]}
|
package/dist/index-engagement.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var z=Object.defineProperty,he=Object.defineProperties,Se=Object.getOwnPropertyDescriptor,be=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertyNames,te=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable;var ne=(e,t,n)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))oe.call(t,n)&&ne(e,n,t[n]);if(te)for(var n of te(t))we.call(t,n)&&ne(e,n,t[n]);return e},Q=(e,t)=>he(e,be(t));var Ee=(e,t)=>{for(var n in t)z(e,n,{get:t[n],enumerable:!0})},ke=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ve(t))!oe.call(e,o)&&o!==n&&z(e,o,{get:()=>t[o],enumerable:!(i=Se(t,o))||i.enumerable});return e};var Te=e=>ke(z({},"__esModule",{value:!0}),e);var We={};Ee(We,{INTERACTION_STATS_COMPONENT:()=>ee,SEMANTIC_TYPES:()=>J,classifyFeatures:()=>B,classifySection:()=>re,featuresFromElement:()=>q,startEngagementCapture:()=>ye});module.exports=Te(We);var J=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Ce={banner:"hero",navigation:"navigation",contentinfo:"footer"};function Re(e){let t=e.ariaRole?Ce[e.ariaRole.toLowerCase()]:void 0;if(t)return t;if(e.tag==="nav")return"navigation";if(e.tag==="footer")return"footer";if(e.tag==="header")return e.actionCount>=5?"navigation":"hero";let n=`${e.idClass} ${e.headingText}`.toLowerCase();return/\b(navbar|nav-bar|navigation|site-nav|main-nav|topbar|footer)\b/.test(n)?/footer/.test(n)?"footer":"navigation":/\b(hero|masthead|jumbotron)\b/i.test(e.idClass)?"hero":null}function Ie(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var _e=[["pricing",/\b(pricing|price list|per month|\/mo|subscriptions?)\b|\bplans?\b(?=[^.]{0,40}(from|start|month|year|[$€£]))/i],["faq",/\bfaq\b|frequently asked|common questions?/i],["comparison",/\b(compare|comparison|versus)\b|\bvs\./i],["social_proof",/\b(reviews?|ratings?|testimonial|brands?|galler(y|ies)|logos)\b|trusted by|loved by|case stud|what our customers say/i],["trust",/\b(insurance|warrant(y|ies)|guarantees?|certifi|accredit|security|privacy|compliance|gdpr|encrypt)\b|why choose|about us|our team/i],["cta",/\b(book|booking|reserve|appointments?|newsletter|subscribe)\b|contact us|get in touch|opening hours/i],["features",/\b(features?|benefits?|capabilit|services?|repairs?|menus?|products?)\b|how it works|our process|what we (do|offer)|what you get/i]],X=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|free returns?|returns? within|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]],se={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function Ae(e){var n;let t=e.querySelector("h1, h2, h3");return((n=t==null?void 0:t.textContent)!=null?n:"").slice(0,160)}function B(e){var o,a;let t=Re(e);if(t)return{type:(o=se[t])!=null?o:"generic",strength:"strong"};let n=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[d,l]of _e)if(l.test(n))return{type:d,strength:"strong"};for(let[d,l]of X)if(l.test(e.bodyText))return{type:d,strength:"strong"};let i=Ie(e);return{type:(a=se[i])!=null?a:"generic",strength:"weak"}}function q(e){var i,o;let t=((i=e.textContent)!=null?i:"").replace(/\s+/g," ").trim(),n=e.getAttribute("role");return C({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((o=e.className)!=null?o:"")}`,headingText:Ae(e),bodyText:t.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:t.length},n?{ariaRole:n}:{})}function re(e){return B(q(e)).type}var me=require("@sentientui/policy");var xe=require("@sentientui/policy");function ie(e,t,n,i){let o=[];{let l=!1,u=[],b=()=>{if(l)return;let y=Date.now();for(u.push(y);u.length>0&&y-u[0]>500;)u.shift();u.length>=3&&(l=!0,e("rage_click"))};t.addEventListener("click",b),o.push(()=>t.removeEventListener("click",b))}{let a=!1,d=l=>{if(a||!(l.target instanceof Node)||!t.contains(l.target)&&t!==l.target)return;a=!0;let u=typeof window!="undefined"?window.getSelection():null,b=u?u.toString().length:0;e("text_copy",{selectionLength:b})};document.addEventListener("copy",d),o.push(()=>document.removeEventListener("copy",d))}{let a=!1,d=!1,l=null,u=()=>{l!==null&&(clearTimeout(l),l=null)},b=()=>{a||!d||(u(),l=setTimeout(()=>{!a&&d&&(a=!0,e("scroll_hesitation"))},3e3))},y=()=>{u(),b()},S=k=>{for(let R of k)d=R.intersectionRatio>.3,d?b():u()},v=new IntersectionObserver(S,{threshold:[.3]});v.observe(t),window.addEventListener("scroll",y,{passive:!0}),o.push(()=>{v.disconnect(),window.removeEventListener("scroll",y),u()})}if((i==null?void 0:i.tabLoss)!==!1){let a=!1,d=n!=null?n:Date.now(),l=()=>{if(a||document.visibilityState!=="hidden")return;let u=Date.now()-d;u<15e3&&(a=!0,e("tab_loss",{timeOnPage:u}))};document.addEventListener("visibilitychange",l),o.push(()=>document.removeEventListener("visibilitychange",l))}return()=>{for(let a of o)a()}}function ae(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(t=>t==="1"||t==="yes")}var Oe=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function Z(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function De(e){return{tag:e.tagName.toLowerCase(),text:Z(e).slice(0,40)}}function le(e){return e.replace(/["\\\]]/g,"\\$&")}function H(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function ce(e,t){var d;let n=e.tagName.toLowerCase();if(!n)return null;let i=((d=e.getAttribute("class"))!=null?d:"").split(/\s+/).filter(l=>/^[a-zA-Z][\w-]*$/.test(l)),o=[n,...i.map(l=>`${n}.${l}`)];for(let l of o)if(H(t,l))return l;let a=e.parentElement;if(a&&a!==t){let l=ce(a,t);if(l){for(let S of o){let v=`${l} > ${S}`;if(H(t,v))return v}let u=Array.from(a.children).filter(S=>S.tagName.toLowerCase()===n),b=u.indexOf(e),y=u.some(S=>S!==e&&Z(S)!==Z(e));if(b>=0&&y){let S=`${l} > ${n}:nth-of-type(${b+1})`;if(H(t,S))return S}}}return null}function de(e,t){let n=De(e),i=e.getAttribute("id");if(i&&H(t,`#${le(i)}`))return{v:1,id:i,fingerprint:n};for(let a of Oe){let d=e.getAttribute(a);if(d&&H(t,`[${a}="${le(d)}"]`))return{v:1,dataAttr:{name:a,value:d},fingerprint:n}}let o=ce(e,t);return o?{v:1,selector:o,fingerprint:n}:null}var ue=[100,300,1e3,3e3,1e4],Pe=250,Ne=1e3,Me=new Set(["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function pe(e,t){e.n++;let n=t-e.mean;e.mean+=n/e.n,e.m2+=n*(t-e.mean)}var ge=e=>e.n>1?Math.sqrt(e.m2/e.n):0;function Le(e){var t;try{let n=e.createElement("canvas"),i=n.getContext("webgl")||n.getContext("experimental-webgl");if(!i)return"unknown";let o=i.getExtension("WEBGL_debug_renderer_info"),a=o?String((t=i.getParameter(o.UNMASKED_RENDERER_WEBGL))!=null?t:""):"";return a?/swiftshader|llvmpipe|softpipe|software|mesa offscreen/i.test(a)?"sw":"hw":"unknown"}catch(n){return"unknown"}}function fe(e,t=Date.now){var g,f;let n=(g=e.defaultView)!=null?g:typeof window!="undefined"?window:void 0,i={n:0,mean:0,m2:0},o={n:0,mean:0,m2:0},a=[0,0,0,0,0,0],d=0,l=0,u=0,b=0,y=0,S=0,v=0,k=0,R=0,I=0,O=-1/0,D=-1/0,h=null,P=null,x=null,N=(f=n==null?void 0:n.scrollY)!=null?f:0,M=0,w=e.hidden?null:t(),_=()=>{let s=t();if(x!=null){let m=s-x,E=0;for(;E<ue.length&&m>=ue[E];)E++;a[E]++}x=s},L=()=>{d++,O=t()},$=()=>{l++,D=t()},K=()=>{h=t()},j=()=>{h!=null&&(pe(i,t()-h),h=null)},G=()=>{let s=t();u++,s-O>Pe&&s-D>Ne&&b++,_()},A=()=>{y++},W=()=>{var m;let s=(m=n==null?void 0:n.scrollY)!=null?m:0;S+=Math.abs(s-N),N=s,_()},F=s=>{let m=t();v++,(s.key==="Backspace"||s.key==="Delete")&&R++,Me.has(s.key)&&I++,P!=null&&pe(o,m-P),P=m,_()},V=s=>{let m=s.data;typeof m=="string"&&(k+=m.length),_()},U=()=>{let s=t();e.hidden?w!=null&&(M+=s-w,w=null):w==null&&(w=s)},p={passive:!0,capture:!0};e.addEventListener("mousemove",L,p),e.addEventListener("touchstart",$,p),e.addEventListener("touchmove",A,p),e.addEventListener("mousedown",K,p),e.addEventListener("mouseup",j,p),e.addEventListener("click",G,p),e.addEventListener("wheel",A,p),e.addEventListener("keydown",F,p),e.addEventListener("input",V,p),e.addEventListener("visibilitychange",U),n==null||n.addEventListener("scroll",W,p);let r=Le(e),c=(()=>{var s;try{return((s=n==null?void 0:n.matchMedia)==null?void 0:s.call(n,"(prefers-reduced-motion: reduce)").matches)===!0}catch(m){return!1}})();return{snapshot(){var E,T;let s=t(),m=M+(w!=null?s-w:0);return{v:1,active_ms:Math.round(m),mm:d,mm_rate:m>0?Number((d*1e3/m).toFixed(2)):0,touches:l,clicks:u,hold_n:i.n,hold_mean:Math.round(i.mean),hold_std:Math.round(ge(i)),teleport:b,wheel:y,scroll_px:Math.round(S),keydowns:v,input_chars:k,ik_cv:o.mean>0?Number((ge(o)/o.mean).toFixed(2)):0,backspaces:R,gaps:[...a],reduced_motion:c,kb_nav:I,renderer:r,vp:[(E=n==null?void 0:n.innerWidth)!=null?E:0,(T=n==null?void 0:n.innerHeight)!=null?T:0],dpr:(n==null?void 0:n.devicePixelRatio)||1}},stop(){e.removeEventListener("mousemove",L,p),e.removeEventListener("touchstart",$,p),e.removeEventListener("touchmove",A,p),e.removeEventListener("mousedown",K,p),e.removeEventListener("mouseup",j,p),e.removeEventListener("click",G,p),e.removeEventListener("wheel",A,p),e.removeEventListener("keydown",F,p),e.removeEventListener("input",V,p),e.removeEventListener("visibilitychange",U),n==null||n.removeEventListener("scroll",W,p)}}}var $e="section, header, footer, nav, main > div, [data-sentient-section]",Ke=2e4,ee="__session__";function je(e){let t=Array.from(e.querySelectorAll($e)),n=t.filter(i=>t.filter(o=>o!==i&&i.contains(o)).length<2);return n.filter(i=>!n.some(o=>o!==i&&o.contains(i)))}function Ge(e,t,n,i){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:i})}).catch(()=>{})}catch(o){}}var Y=()=>{};function ye(e,t){var N,M,w,_,L,$,K,j,G,A,W,F,V,U,p;let n=(N=t.doc)!=null?N:typeof document!="undefined"?document:void 0;if(!n||typeof IntersectionObserver=="undefined"||ae()||!t.apiKey||!t.apiKey.startsWith("pk_"))return Y;let i=((M=t.apiBase)!=null?M:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),o=je(n);if(o.length===0)return Y;let a=new Map,d=[];for(let r of o){let c=(L=[(_=t.sectionTypes)==null?void 0:_[(w=r.getAttribute("data-sentient-id"))!=null?w:""],r.getAttribute("data-sentient-type")].find(T=>J.includes(T)))!=null?L:null,g=q(r),f=(K=c!=null?c:($=t.typeOf)==null?void 0:$.call(t,r))!=null?K:B(g).type,s=de(r,n),m=s?`nc-${f}-${(0,me.fnv1a)(JSON.stringify({id:(j=s.id)!=null?j:null,dataAttr:(G=s.dataAttr)!=null?G:null,selector:(A=s.selector)!=null?A:null})).toString(36)}`:`nc-${f}`;a.set(r,m);let E=X.filter(([,T])=>T.test(g.bodyText)).map(([T])=>T);d.push(Q(C({componentId:m,semanticType:f,source:c?"markup":"auto"},s?{locator:s}:{}),{observation:C(C({tag:g.tag,idClass:g.idClass.slice(0,200),headingText:g.headingText,textLength:g.textLength,actionCount:g.actionCount},g.ariaRole?{ariaRole:g.ariaRole}:{}),E.length>0?{patternFlags:E}:{})}))}let l=(U=(V=(F=(W=n.defaultView)!=null?W:typeof window!="undefined"?window:void 0)==null?void 0:F.location)==null?void 0:V.pathname)!=null?U:"/";Ge(t.apiKey,i,l,d);let u=fe(n),b=()=>{let r;try{r=u.snapshot()}catch(c){return}try{e.track({projectId:t.apiKey,componentId:ee,eventType:"interaction_stats",payload:r})}catch(c){}},y=new Map,S=r=>{let c=y.get(r);return c||(c={ms:0,scroll:0,enterAt:null,intersecting:!1},y.set(r,c)),c},v=new IntersectionObserver(r=>{for(let c of r){let g=a.get(c.target);if(!g)continue;let f=S(g);c.isIntersecting?(f.intersecting=!0,f.enterAt=Date.now(),c.intersectionRatio>f.scroll&&(f.scroll=c.intersectionRatio)):(f.intersecting=!1,f.enterAt!=null&&(f.ms+=Date.now()-f.enterAt,f.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let r of a.keys())v.observe(r);let k=(r=!1)=>{var g;let c=Date.now();for(let[f,s]of y)if(s.enterAt!=null&&(s.ms+=c-s.enterAt,s.enterAt=null),!(s.ms<=0)){try{e.track({projectId:t.apiKey,componentId:f,eventType:"dwell",payload:{dwell_time:Math.round(s.ms),scroll_depth:Number(s.scroll.toFixed(2))}})}catch(m){}s.ms=0}if(b(),r)try{(g=e.flush)==null||g.call(e)}catch(f){}},R=()=>{if(n.hidden)k(!0);else{let r=Date.now();for(let c of y.values())c.intersecting&&(c.enterAt=r)}},I=!1,O=r=>{if(k(!0),r!=null&&r.persisted){I=!0;return}try{v.disconnect()}catch(c){}},D=r=>{if(!(r!=null&&r.persisted)||!I)return;I=!1;let c=Date.now();for(let g of y.values())g.enterAt=g.intersecting&&!n.hidden?c:null};n.addEventListener("visibilitychange",R);let h=(p=n.defaultView)!=null?p:typeof window!="undefined"?window:void 0;h==null||h.addEventListener("pagehide",O),h==null||h.addEventListener("pageshow",D);let P=setInterval(()=>{if(n.hidden||I)return;k();let r=Date.now();for(let c of y.values())c.intersecting&&(c.enterAt=r)},Ke),x=[];return t.microSignals&&[...a.entries()].forEach(([r,c],g)=>{x.push(ie((f,s={})=>{try{e.track({projectId:t.apiKey,componentId:c,eventType:"micro_signal",payload:C({signalType:f},s)})}catch(m){}},r,void 0,{tabLoss:g===0}))}),()=>{k(!0),clearInterval(P),u.stop(),n.removeEventListener("visibilitychange",R),h==null||h.removeEventListener("pagehide",O),h==null||h.removeEventListener("pageshow",D);for(let r of x)r();try{v.disconnect()}catch(r){}}}0&&(module.exports={INTERACTION_STATS_COMPONENT,SEMANTIC_TYPES,classifyFeatures,classifySection,featuresFromElement,startEngagementCapture});
|
|
1
|
+
"use strict";var z=Object.defineProperty,he=Object.defineProperties,Se=Object.getOwnPropertyDescriptor,be=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertyNames,te=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable;var ne=(e,t,n)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))oe.call(t,n)&&ne(e,n,t[n]);if(te)for(var n of te(t))we.call(t,n)&&ne(e,n,t[n]);return e},Q=(e,t)=>he(e,be(t));var ke=(e,t)=>{for(var n in t)z(e,n,{get:t[n],enumerable:!0})},Ee=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ve(t))!oe.call(e,o)&&o!==n&&z(e,o,{get:()=>t[o],enumerable:!(i=Se(t,o))||i.enumerable});return e};var Te=e=>Ee(z({},"__esModule",{value:!0}),e);var We={};ke(We,{INTERACTION_STATS_COMPONENT:()=>ee,SEMANTIC_TYPES:()=>J,classifyFeatures:()=>U,classifySection:()=>re,featuresFromElement:()=>q,startEngagementCapture:()=>ye});module.exports=Te(We);var J=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Ce={banner:"hero",navigation:"navigation",contentinfo:"footer"};function Re(e){let t=e.ariaRole?Ce[e.ariaRole.toLowerCase()]:void 0;if(t)return t;if(e.tag==="nav")return"navigation";if(e.tag==="footer")return"footer";if(e.tag==="header")return e.actionCount>=5?"navigation":"hero";let n=`${e.idClass} ${e.headingText}`.toLowerCase();return/\b(navbar|nav-bar|navigation|site-nav|main-nav|topbar|footer)\b/.test(n)?/footer/.test(n)?"footer":"navigation":/\b(hero|masthead|jumbotron)\b/i.test(e.idClass)?"hero":null}function Ie(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var _e=[["pricing",/\b(pricing|price list|per month|\/mo|subscriptions?)\b|\bplans?\b(?=[^.]{0,40}(from|start|month|year|[$€£]))/i],["faq",/\bfaq\b|frequently asked|common questions?/i],["comparison",/\b(compare|comparison|versus)\b|\bvs\./i],["social_proof",/\b(reviews?|ratings?|testimonial|brands?|galler(y|ies)|logos)\b|trusted by|loved by|case stud|what our customers say/i],["trust",/\b(insurance|warrant(y|ies)|guarantees?|certifi|accredit|security|privacy|compliance|gdpr|encrypt)\b|why choose|about us|our team/i],["cta",/\b(book|booking|reserve|appointments?|newsletter|subscribe)\b|contact us|get in touch|opening hours/i],["features",/\b(features?|benefits?|capabilit|services?|repairs?|menus?|products?)\b|how it works|our process|what we (do|offer)|what you get/i]],X=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|free returns?|returns? within|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]],se={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function Ae(e){var n;let t=e.querySelector("h1, h2, h3");return((n=t==null?void 0:t.textContent)!=null?n:"").slice(0,160)}function U(e){var o,a;let t=Re(e);if(t)return{type:(o=se[t])!=null?o:"generic",strength:"strong"};let n=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[d,l]of _e)if(l.test(n))return{type:d,strength:"strong"};for(let[d,l]of X)if(l.test(e.bodyText))return{type:d,strength:"strong"};let i=Ie(e);return{type:(a=se[i])!=null?a:"generic",strength:"weak"}}function q(e){var i,o;let t=((i=e.textContent)!=null?i:"").replace(/\s+/g," ").trim(),n=e.getAttribute("role");return C({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((o=e.className)!=null?o:"")}`,headingText:Ae(e),bodyText:t.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:t.length},n?{ariaRole:n}:{})}function re(e){return U(q(e)).type}var me=require("@sentientui/policy");var xe=require("@sentientui/policy");function ie(e,t,n,i){let o=[];{let l=!1,u=[],b=()=>{if(l)return;let y=Date.now();for(u.push(y);u.length>0&&y-u[0]>500;)u.shift();u.length>=3&&(l=!0,e("rage_click"))};t.addEventListener("click",b),o.push(()=>t.removeEventListener("click",b))}{let a=!1,d=l=>{if(a||!(l.target instanceof Node)||!t.contains(l.target)&&t!==l.target)return;a=!0;let u=typeof window!="undefined"?window.getSelection():null,b=u?u.toString().length:0;e("text_copy",{selectionLength:b})};document.addEventListener("copy",d),o.push(()=>document.removeEventListener("copy",d))}{let a=!1,d=!1,l=null,u=()=>{l!==null&&(clearTimeout(l),l=null)},b=()=>{a||!d||(u(),l=setTimeout(()=>{!a&&d&&(a=!0,e("scroll_hesitation"))},3e3))},y=()=>{u(),b()},S=E=>{for(let R of E)d=R.intersectionRatio>.3,d?b():u()},v=new IntersectionObserver(S,{threshold:[.3]});v.observe(t),window.addEventListener("scroll",y,{passive:!0}),o.push(()=>{v.disconnect(),window.removeEventListener("scroll",y),u()})}if((i==null?void 0:i.tabLoss)!==!1){let a=!1,d=n!=null?n:Date.now(),l=()=>{if(a||document.visibilityState!=="hidden")return;let u=Date.now()-d;u<15e3&&(a=!0,e("tab_loss",{timeOnPage:u}))};document.addEventListener("visibilitychange",l),o.push(()=>document.removeEventListener("visibilitychange",l))}return()=>{for(let a of o)a()}}function ae(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(t=>t==="1"||t==="yes")}var Oe=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function Z(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function De(e){return{tag:e.tagName.toLowerCase(),text:Z(e).slice(0,40)}}function le(e){return e.replace(/["\\\]]/g,"\\$&")}function H(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function ce(e,t){var d;let n=e.tagName.toLowerCase();if(!n)return null;let i=((d=e.getAttribute("class"))!=null?d:"").split(/\s+/).filter(l=>/^[a-zA-Z][\w-]*$/.test(l)),o=[n,...i.map(l=>`${n}.${l}`)];for(let l of o)if(H(t,l))return l;let a=e.parentElement;if(a&&a!==t){let l=ce(a,t);if(l){for(let S of o){let v=`${l} > ${S}`;if(H(t,v))return v}let u=Array.from(a.children).filter(S=>S.tagName.toLowerCase()===n),b=u.indexOf(e),y=u.some(S=>S!==e&&Z(S)!==Z(e));if(b>=0&&y){let S=`${l} > ${n}:nth-of-type(${b+1})`;if(H(t,S))return S}}}return null}function de(e,t){let n=De(e),i=e.getAttribute("id");if(i&&H(t,`#${le(i)}`))return{v:1,id:i,fingerprint:n};for(let a of Oe){let d=e.getAttribute(a);if(d&&H(t,`[${a}="${le(d)}"]`))return{v:1,dataAttr:{name:a,value:d},fingerprint:n}}let o=ce(e,t);return o?{v:1,selector:o,fingerprint:n}:null}var ue=[100,300,1e3,3e3,1e4],Pe=250,Ne=1e3,Me=new Set(["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function pe(e,t){e.n++;let n=t-e.mean;e.mean+=n/e.n,e.m2+=n*(t-e.mean)}var ge=e=>e.n>1?Math.sqrt(e.m2/e.n):0;function Le(e){var t;try{let n=e.createElement("canvas"),i=n.getContext("webgl")||n.getContext("experimental-webgl");if(!i)return"unknown";let o=i.getExtension("WEBGL_debug_renderer_info"),a=o?String((t=i.getParameter(o.UNMASKED_RENDERER_WEBGL))!=null?t:""):"";return a?/swiftshader|llvmpipe|softpipe|software|mesa offscreen/i.test(a)?"sw":"hw":"unknown"}catch(n){return"unknown"}}function fe(e,t=Date.now){var g,f;let n=(g=e.defaultView)!=null?g:typeof window!="undefined"?window:void 0,i={n:0,mean:0,m2:0},o={n:0,mean:0,m2:0},a=[0,0,0,0,0,0],d=0,l=0,u=0,b=0,y=0,S=0,v=0,E=0,R=0,I=0,O=-1/0,D=-1/0,h=null,P=null,x=null,N=(f=n==null?void 0:n.scrollY)!=null?f:0,M=0,w=e.hidden?null:t(),_=()=>{let s=t();if(x!=null){let m=s-x,k=0;for(;k<ue.length&&m>=ue[k];)k++;a[k]++}x=s},L=()=>{d++,O=t()},$=()=>{l++,D=t()},K=()=>{h=t()},j=()=>{h!=null&&(pe(i,t()-h),h=null)},G=()=>{let s=t();u++,s-O>Pe&&s-D>Ne&&b++,_()},A=()=>{y++},W=()=>{var m;let s=(m=n==null?void 0:n.scrollY)!=null?m:0;S+=Math.abs(s-N),N=s,_()},F=s=>{let m=t();v++,(s.key==="Backspace"||s.key==="Delete")&&R++,Me.has(s.key)&&I++,P!=null&&pe(o,m-P),P=m,_()},V=s=>{let m=s.data;typeof m=="string"&&(E+=m.length),_()},B=()=>{let s=t();e.hidden?w!=null&&(M+=s-w,w=null):w==null&&(w=s)},p={passive:!0,capture:!0};e.addEventListener("mousemove",L,p),e.addEventListener("touchstart",$,p),e.addEventListener("touchmove",A,p),e.addEventListener("mousedown",K,p),e.addEventListener("mouseup",j,p),e.addEventListener("click",G,p),e.addEventListener("wheel",A,p),e.addEventListener("keydown",F,p),e.addEventListener("input",V,p),e.addEventListener("visibilitychange",B),n==null||n.addEventListener("scroll",W,p);let r=Le(e),c=(()=>{var s;try{return((s=n==null?void 0:n.matchMedia)==null?void 0:s.call(n,"(prefers-reduced-motion: reduce)").matches)===!0}catch(m){return!1}})();return{snapshot(){var k,T;let s=t(),m=M+(w!=null?s-w:0);return{v:1,active_ms:Math.round(m),mm:d,mm_rate:m>0?Number((d*1e3/m).toFixed(2)):0,touches:l,clicks:u,hold_n:i.n,hold_mean:Math.round(i.mean),hold_std:Math.round(ge(i)),teleport:b,wheel:y,scroll_px:Math.round(S),keydowns:v,input_chars:E,ik_cv:o.mean>0?Number((ge(o)/o.mean).toFixed(2)):0,backspaces:R,gaps:[...a],reduced_motion:c,kb_nav:I,renderer:r,vp:[(k=n==null?void 0:n.innerWidth)!=null?k:0,(T=n==null?void 0:n.innerHeight)!=null?T:0],dpr:(n==null?void 0:n.devicePixelRatio)||1}},stop(){e.removeEventListener("mousemove",L,p),e.removeEventListener("touchstart",$,p),e.removeEventListener("touchmove",A,p),e.removeEventListener("mousedown",K,p),e.removeEventListener("mouseup",j,p),e.removeEventListener("click",G,p),e.removeEventListener("wheel",A,p),e.removeEventListener("keydown",F,p),e.removeEventListener("input",V,p),e.removeEventListener("visibilitychange",B),n==null||n.removeEventListener("scroll",W,p)}}}var $e="section, header, footer, nav, main > div, [data-sentient-section]",Ke=2e4,ee="__session__";function je(e){let t=Array.from(e.querySelectorAll($e)),n=t.filter(i=>t.filter(o=>o!==i&&i.contains(o)).length<2);return n.filter(i=>!n.some(o=>o!==i&&o.contains(i)))}function Ge(e,t,n,i){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:i})}).catch(()=>{})}catch(o){}}var Y=()=>{};function ye(e,t){var N,M,w,_,L,$,K,j,G,A,W,F,V,B,p;let n=(N=t.doc)!=null?N:typeof document!="undefined"?document:void 0;if(!n||typeof IntersectionObserver=="undefined"||ae()||!t.apiKey||!t.apiKey.startsWith("pk_"))return Y;let i=((M=t.apiBase)!=null?M:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),o=je(n);if(o.length===0)return Y;let a=new Map,d=[];for(let r of o){let c=(L=[(_=t.sectionTypes)==null?void 0:_[(w=r.getAttribute("data-sentient-id"))!=null?w:""],r.getAttribute("data-sentient-type")].find(T=>J.includes(T)))!=null?L:null,g=q(r),f=(K=c!=null?c:($=t.typeOf)==null?void 0:$.call(t,r))!=null?K:U(g).type,s=de(r,n),m=s?`nc-${f}-${(0,me.fnv1a)(JSON.stringify({id:(j=s.id)!=null?j:null,dataAttr:(G=s.dataAttr)!=null?G:null,selector:(A=s.selector)!=null?A:null})).toString(36)}`:`nc-${f}`;a.set(r,m);let k=X.filter(([,T])=>T.test(g.bodyText)).map(([T])=>T);d.push(Q(C({componentId:m,semanticType:f,source:c?"markup":"auto"},s?{locator:s}:{}),{observation:C(C({tag:g.tag,idClass:g.idClass.slice(0,200),headingText:g.headingText,textLength:g.textLength,actionCount:g.actionCount},g.ariaRole?{ariaRole:g.ariaRole}:{}),k.length>0?{patternFlags:k}:{})}))}let l=(B=(V=(F=(W=n.defaultView)!=null?W:typeof window!="undefined"?window:void 0)==null?void 0:F.location)==null?void 0:V.pathname)!=null?B:"/";Ge(t.apiKey,i,l,d);let u=fe(n),b=()=>{let r;try{r=u.snapshot()}catch(c){return}try{e.track({projectId:t.apiKey,componentId:ee,eventType:"interaction_stats",payload:r})}catch(c){}},y=new Map,S=r=>{let c=y.get(r);return c||(c={ms:0,scroll:0,enterAt:null,intersecting:!1},y.set(r,c)),c},v=new IntersectionObserver(r=>{for(let c of r){let g=a.get(c.target);if(!g)continue;let f=S(g);c.isIntersecting?(f.intersecting=!0,f.enterAt=Date.now(),c.intersectionRatio>f.scroll&&(f.scroll=c.intersectionRatio)):(f.intersecting=!1,f.enterAt!=null&&(f.ms+=Date.now()-f.enterAt,f.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let r of a.keys())v.observe(r);let E=(r=!1)=>{var g;let c=Date.now();for(let[f,s]of y)if(s.enterAt!=null&&(s.ms+=c-s.enterAt,s.enterAt=null),!(s.ms<=0)){try{e.track({projectId:t.apiKey,componentId:f,eventType:"dwell",payload:{dwell_time:Math.round(s.ms),scroll_depth:Number(s.scroll.toFixed(2))}})}catch(m){}s.ms=0}if(b(),r)try{(g=e.flush)==null||g.call(e)}catch(f){}},R=()=>{if(n.hidden)E(!0);else{let r=Date.now();for(let c of y.values())c.intersecting&&(c.enterAt=r)}},I=!1,O=r=>{if(E(!0),r!=null&&r.persisted){I=!0;return}try{v.disconnect()}catch(c){}},D=r=>{if(!(r!=null&&r.persisted)||!I)return;I=!1;let c=Date.now();for(let g of y.values())g.enterAt=g.intersecting&&!n.hidden?c:null};n.addEventListener("visibilitychange",R);let h=(p=n.defaultView)!=null?p:typeof window!="undefined"?window:void 0;h==null||h.addEventListener("pagehide",O),h==null||h.addEventListener("pageshow",D);let P=setInterval(()=>{if(n.hidden||I)return;E();let r=Date.now();for(let c of y.values())c.intersecting&&(c.enterAt=r)},Ke),x=[];return t.microSignals&&[...a.entries()].forEach(([r,c],g)=>{x.push(ie((f,s={})=>{try{e.track({projectId:t.apiKey,componentId:c,eventType:"micro_signal",payload:C({signalType:f},s)})}catch(m){}},r,void 0,{tabLoss:g===0}))}),()=>{E(!0),clearInterval(P),u.stop(),n.removeEventListener("visibilitychange",R),h==null||h.removeEventListener("pagehide",O),h==null||h.removeEventListener("pageshow",D);for(let r of x)r();try{v.disconnect()}catch(r){}}}0&&(module.exports={INTERACTION_STATS_COMPONENT,SEMANTIC_TYPES,classifyFeatures,classifySection,featuresFromElement,startEngagementCapture});
|
|
2
2
|
//# sourceMappingURL=index-engagement.js.map
|