@sentientui/core 0.40.2 → 0.41.1
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/dist/chunk-3HMJERH4.mjs +2 -0
- package/dist/chunk-3HMJERH4.mjs.map +1 -0
- package/dist/{chunk-ZTQXHKHU.mjs → chunk-KXA3X6T3.mjs} +2 -2
- package/dist/chunk-KXA3X6T3.mjs.map +1 -0
- package/dist/{index-BgEe5mKL.d.ts → index-C--aVpoo.d.ts} +1 -1
- package/dist/{index-B7s2gvyU.d.cts → index-DlJDNOWu.d.cts} +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-graph.d.cts +4 -4
- package/dist/index-graph.d.ts +4 -4
- 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-local.d.cts +2 -2
- package/dist/index-local.d.ts +2 -2
- package/dist/index-server.d.cts +2 -2
- package/dist/index-server.d.ts +2 -2
- 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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{session-meta-BG8w53d7.d.cts → session-meta-BqBaLZag.d.cts} +17 -1
- package/dist/{session-meta-D9Wx2PtC.d.ts → session-meta-D_kdNsaU.d.ts} +17 -1
- package/package.json +2 -2
- package/dist/chunk-NBDVEYI5.mjs +0 -2
- package/dist/chunk-NBDVEYI5.mjs.map +0 -1
- package/dist/chunk-ZTQXHKHU.mjs.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as s}from"./chunk-TMCGHANO.mjs";var c=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function y(e){return b(e)!==null}function b(e){var r;if(!e)return null;let t=e.toLowerCase();return(r=c.find(i=>t.includes(i.toLowerCase())))!=null?r:null}var S=["Googlebot","Bingbot","DuckDuckBot","YandexBot","Baiduspider","Applebot","Slurp","facebookexternalhit","LinkedInBot","Twitterbot"];function R(e){var i;let t=b(e);if(t)return t;if(!e)return null;let r=e.toLowerCase();return(i=S.find(n=>r.includes(n.toLowerCase())))!=null?i:null}var x={GPTBot:"training","ChatGPT-User":"user","OAI-SearchBot":"search",ClaudeBot:"training","Claude-User":"user","Claude-SearchBot":"search",PerplexityBot:"search","Perplexity-User":"user","Google-Extended":"training","Applebot-Extended":"training","Meta-ExternalAgent":"training",Bytespider:"training",CCBot:"training",Amazonbot:"other","cohere-ai":"training",Diffbot:"other"};function U(e){if(!e)return"other";let t=c.find(r=>r.toLowerCase()===e.toLowerCase());return t&&x[t]||"other"}function O(){var t;let e={user:[],search:[],training:[],other:[]};for(let r of c)e[(t=x[r])!=null?t:"other"].push(r);return e}function p(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function C(e,t,r){if(!e)return"direct";try{let i=new URL(e);if(t)try{if(new URL(t).host===i.host)return"direct"}catch(o){}let n=i.hostname.toLowerCase();return r&&`.${n}`.endsWith(`.${r}`)?"direct":/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(n)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(n)?"social":"referral"}catch(i){return"direct"}}function k(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var P=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function E(e){let t={},r={};try{let i=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([n,o])=>{let a=Array.isArray(o)?o[0]:o;return a===void 0?[]:[[n,a]]});for(let[n,o]of i)n.startsWith("utm_")?n in t||(t[n]=o):P.includes(n)&&(n in r||(r[n]=o))}catch(i){}return{utmParams:t,clickIds:r}}function I(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function _(e){let t=w("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function w(e,t){var a,l,g,u,d,f,m,h;let r=(l=(a=t==null?void 0:t.userAgent)==null?void 0:a.trim())!=null?l:"",i=(u=(g=t==null?void 0:t.referer)==null?void 0:g.trim())!=null?u:"",n=(d=t==null?void 0:t.now)!=null?d:new Date,o=R(r);return s(s({sessionId:e,ephemeral:!1,utmParams:(f=t==null?void 0:t.utmParams)!=null?f:{},clickIds:(m=t==null?void 0:t.clickIds)!=null?m:{},deviceClass:r?p(r):"desktop",trafficSource:i?C(i,t==null?void 0:t.appOrigin):"direct",referrerDomain:k(i),timeOfDay:I(n),dayOfWeek:(h=["sun","mon","tue","wed","thu","fri","sat"][n.getDay()])!=null?h:"sun",automation:(t==null?void 0:t.webdriver)===!0||y(r)},o?{agentToken:o}:{}),t!=null&&t.landingPath?{landingPath:t.landingPath.split(/[?#]/)[0]}:{})}import{canonicalArm as A,slotBaselineArm as D,slotResultFor as B}from"@sentientui/policy";function L(e){return s(s(s({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,r])=>[t,[...r]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function T(e){let t=L(e);return B(t,D(t))}function $(e){let t={};for(let r of e)t[r.id]=T(r);return t}function M(e){return typeof e=="string"?e:A(e)}export{c as a,y as b,b as c,S as d,R as e,x as f,U as g,O as h,p as i,C as j,k,P as l,E as m,I as n,_ as o,w as p,L as q,T as r,$ as s,M as t};
|
|
2
|
+
//# sourceMappingURL=chunk-3HMJERH4.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/session-meta.ts","../src/slots.ts"],"sourcesContent":["/** Session metadata helpers (browser + Node). No DOM APIs. */\n\n/**\n * Known AI-agent / crawler user-agent tokens. Matched case-insensitively as\n * substrings. This is maintained data — bot lists move monthly. Used both to\n * flag automation on sessions (agentic browsers that leak a token) and by the\n * server middleware / agent-feed route to identify crawler HTTP reads.\n */\nexport const agentUaList: readonly string[] = [\n 'GPTBot',\n 'ChatGPT-User',\n 'OAI-SearchBot',\n 'ClaudeBot',\n 'Claude-User',\n 'Claude-SearchBot',\n 'PerplexityBot',\n 'Perplexity-User',\n 'Google-Extended',\n 'Applebot-Extended',\n 'Meta-ExternalAgent',\n 'Bytespider',\n 'CCBot',\n 'Amazonbot',\n 'cohere-ai',\n 'Diffbot',\n];\n\n/** True when the user-agent contains a known AI-agent / crawler token. */\nexport function uaTokenMatch(userAgent: string): boolean {\n return matchedAgentToken(userAgent) !== null;\n}\n\n/** The first known agent token found in the user-agent, or null. */\nexport function matchedAgentToken(userAgent: string): string | null {\n if (!userAgent) return null;\n const s = userAgent.toLowerCase();\n return agentUaList.find((token) => s.includes(token.toLowerCase())) ?? null;\n}\n\n/**\n * Classic search / link-preview crawlers. DISPLAY-ONLY: these name a request in\n * the dashboard but must never join `agentUaList`, which also sets `automation`\n * (and so bandit exclusion) — a crawler that is merely named must not change\n * how the session is scored.\n */\nexport const CLASSIC_CRAWLER_TOKENS: readonly string[] = [\n 'Googlebot',\n 'Bingbot',\n 'DuckDuckBot',\n 'YandexBot',\n 'Baiduspider',\n 'Applebot',\n 'Slurp',\n 'facebookexternalhit',\n 'LinkedInBot',\n 'Twitterbot',\n];\n\n/**\n * Name the crawler behind a user-agent: AI-agent tokens first (so\n * `Applebot-Extended` is not swallowed by the shorter `Applebot`), then the\n * classic list. Returns the canonical spelling, or null.\n */\nexport function matchedCrawlerToken(userAgent: string): string | null {\n const agent = matchedAgentToken(userAgent);\n if (agent) return agent;\n if (!userAgent) return null;\n const s = userAgent.toLowerCase();\n return CLASSIC_CRAWLER_TOKENS.find((token) => s.includes(token.toLowerCase())) ?? null;\n}\n\n/**\n * Purpose category for an agent fetch, inferred from its published user-agent:\n * - `user` — a person asked an assistant to read the page, live (…-User UAs)\n * - `search` — indexing for an AI answer engine (…-SearchBot / SearchBot)\n * - `training` — model-training crawl (GPTBot, ClaudeBot, CCBot, …)\n * - `other` — not clearly AI, or an unknown/new token\n */\nexport type AgentIntent = 'user' | 'search' | 'training' | 'other';\n\n/** Intent per agent token. Maintained beside `agentUaList` — when you add or\n * rename a token above, set its intent here (a unit test enforces coverage). */\nexport const AGENT_INTENTS: Record<string, AgentIntent> = {\n 'GPTBot': 'training',\n 'ChatGPT-User': 'user',\n 'OAI-SearchBot': 'search',\n 'ClaudeBot': 'training',\n 'Claude-User': 'user',\n 'Claude-SearchBot': 'search',\n 'PerplexityBot': 'search',\n 'Perplexity-User': 'user',\n 'Google-Extended': 'training',\n 'Applebot-Extended': 'training',\n 'Meta-ExternalAgent': 'training',\n 'Bytespider': 'training',\n 'CCBot': 'training',\n 'Amazonbot': 'other',\n 'cohere-ai': 'training',\n 'Diffbot': 'other',\n};\n\n/** Intent for a matched bot token (case-insensitive); `other` for null/unknown. */\nexport function agentIntent(botName: string | null): AgentIntent {\n if (!botName) return 'other';\n const hit = agentUaList.find((t) => t.toLowerCase() === botName.toLowerCase());\n return (hit && AGENT_INTENTS[hit]) || 'other';\n}\n\n/** `agentUaList` grouped by intent — the \"which crawlers do you classify?\" reference. */\nexport function classifiedAgents(): Record<AgentIntent, string[]> {\n const out: Record<AgentIntent, string[]> = { user: [], search: [], training: [], other: [] };\n for (const t of agentUaList) out[AGENT_INTENTS[t] ?? 'other'].push(t);\n return out;\n}\n\nexport function detectDeviceClass(userAgent: string): string {\n const s = userAgent.toLowerCase();\n if (/ipad|tablet|playbook|kindle|silk/.test(s)) return 'tablet';\n if (/mobi|iphone|ipod|android.*mobile|phone/.test(s)) return 'mobile';\n return 'desktop';\n}\n\nexport function detectTrafficSource(referrer: string, appOrigin?: string, siteDomain?: string | null): string {\n if (!referrer) return 'direct';\n try {\n const refUrl = new URL(referrer);\n if (appOrigin) {\n try {\n if (new URL(appOrigin).host === refUrl.host) return 'direct';\n } catch {\n /* ignore invalid appOrigin */\n }\n }\n const host = refUrl.hostname.toLowerCase();\n // Another host of the same site (the shared cookie domain): example.com →\n // app.example.com is a page view inside the site, scored like one.\n if (siteDomain && `.${host}`.endsWith(`.${siteDomain}`)) return 'direct';\n if (/(^|\\.)(google|bing|duckduckgo|yahoo)\\./.test(host)) return 'search';\n // Anchor to the registrable domain (exact host or a subdomain of it) so\n // hosts like `x.company.com`, `t.company.io` or `linkedinsights.com` are not\n // misclassified as social by an unbounded substring match.\n if (/(^|\\.)(twitter\\.com|x\\.com|facebook\\.com|linkedin\\.com|reddit\\.com|t\\.co)$/.test(host)) return 'social';\n return 'referral';\n } catch {\n return 'direct';\n }\n}\n\nexport function referrerDomainFromReferer(referrer: string): string | null {\n if (!referrer) return null;\n try {\n return new URL(referrer).hostname;\n } catch {\n return null;\n }\n}\n\n/**\n * Ad-platform click-ID query params worth keeping. An ALLOWLIST, unlike the\n * `utm_` prefix match: unknown query keys here are unbounded-cardinality junk\n * (session tokens, cache busters) that would bloat the sessions table, so only\n * the IDs the major ad platforms actually append survive.\n *\n * gclid / gbraid / wbraid — Google Ads auto-tagging (search, YouTube, Display;\n * gbraid/wbraid are the iOS-14 privacy variants)\n * fbclid — Meta (Facebook + Instagram). Appended to EVERY outbound Meta\n * click, paid and organic alike — it identifies the platform, never spend.\n * ttclid — TikTok Ads\n * msclkid — Microsoft Ads (Bing)\n * twclid — X/Twitter Ads\n * li_fat_id — LinkedIn Ads\n */\nexport const CLICK_ID_KEYS: readonly string[] = [\n 'gclid',\n 'gbraid',\n 'wbraid',\n 'fbclid',\n 'ttclid',\n 'msclkid',\n 'twclid',\n 'li_fat_id',\n];\n\n/**\n * Splits a URL query into the attribution params the session upsert carries:\n * every `utm_`-prefixed key, plus allowlisted ad click IDs (CLICK_ID_KEYS).\n * Accepts a raw search string (\"?a=b\" or \"a=b\"), a URLSearchParams, or a\n * Next.js `searchParams` object (whose values may be string arrays — the\n * first occurrence wins, matching URLSearchParams iteration order).\n * Node-safe: no DOM APIs.\n */\nexport function extractTrackedParams(\n search: string | URLSearchParams | Record<string, string | string[] | undefined>,\n): { utmParams: Record<string, string>; clickIds: Record<string, string> } {\n const utmParams: Record<string, string> = {};\n const clickIds: Record<string, string> = {};\n try {\n const entries: Iterable<[string, string]> =\n typeof search === 'string' || search instanceof URLSearchParams\n ? new URLSearchParams(search)\n : Object.entries(search).flatMap(([k, v]): Array<[string, string]> => {\n const first = Array.isArray(v) ? v[0] : v;\n return first === undefined ? [] : [[k, first]];\n });\n for (const [k, v] of entries) {\n // First occurrence wins for duplicates — a repeated gclid in a mangled\n // URL must not let the later value silently replace the real one.\n if (k.startsWith('utm_')) {\n if (!(k in utmParams)) utmParams[k] = v;\n } else if (CLICK_ID_KEYS.includes(k)) {\n if (!(k in clickIds)) clickIds[k] = v;\n }\n }\n } catch {\n /* malformed input → empty attribution, never a throw at init() */\n }\n return { utmParams, clickIds };\n}\n\nexport function detectTimeOfDay(d: Date): string {\n const h = d.getHours();\n if (h < 6) return 'night';\n if (h < 12) return 'morning';\n if (h < 18) return 'afternoon';\n return 'evening';\n}\n\nexport type SessionUpsertPayload = {\n sessionId: string;\n ephemeral: boolean;\n utmParams: Record<string, string>;\n /** Allowlisted ad-platform click IDs from the landing URL (CLICK_ID_KEYS). */\n clickIds: Record<string, string>;\n deviceClass: string;\n trafficSource: string;\n /** Landing page path, no query string (arrival classification). */\n landingPath?: string;\n referrerDomain: string | null;\n timeOfDay: string;\n dayOfWeek: string;\n /**\n * True when this session is likely driven by automation — either\n * `navigator.webdriver` was set, or the user-agent carried a known agent\n * token. Probabilistic: a flag for metrics + bandit exclusion, never a gate.\n */\n automation: boolean;\n /** Which crawler / AI assistant requested a server-rendered page (canonical\n * token). Absent for ordinary browsers. Naming only — never sets `automation`. */\n agentToken?: string;\n};\n\n/** Bandit segment key: `<device_class>:<traffic_source>`. */\nexport function deriveSessionSegment(opts?: {\n userAgent?: string;\n referer?: string;\n appOrigin?: string;\n}): string {\n const body = buildSessionUpsertPayload('__segment__', opts);\n return `${body.deviceClass}:${body.trafficSource}`;\n}\n\n/**\n * Builds a session upsert body aligned with the browser SDK so SSR assign uses\n * the same segment key (`device:source`) as the client after hydration.\n */\nexport function buildSessionUpsertPayload(\n sessionId: string,\n opts?: {\n userAgent?: string;\n referer?: string;\n appOrigin?: string;\n utmParams?: Record<string, string>;\n clickIds?: Record<string, string>;\n now?: Date;\n /** `navigator.webdriver` value from the browser, when available. */\n webdriver?: boolean;\n /** The landing page's path (no query string), when the caller knows it. */\n landingPath?: string;\n },\n): SessionUpsertPayload {\n const ua = opts?.userAgent?.trim() ?? '';\n const referer = opts?.referer?.trim() ?? '';\n const now = opts?.now ?? new Date();\n const agentToken = matchedCrawlerToken(ua);\n return {\n sessionId,\n ephemeral: false,\n utmParams: opts?.utmParams ?? {},\n clickIds: opts?.clickIds ?? {},\n deviceClass: ua ? detectDeviceClass(ua) : 'desktop',\n trafficSource: referer\n ? detectTrafficSource(referer, opts?.appOrigin)\n : 'direct',\n referrerDomain: referrerDomainFromReferer(referer),\n timeOfDay: detectTimeOfDay(now),\n dayOfWeek: ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'][now.getDay()] ?? 'sun',\n automation: opts?.webdriver === true || uaTokenMatch(ua),\n ...(agentToken ? { agentToken } : {}),\n ...(opts?.landingPath ? { landingPath: opts.landingPath.split(/[?#]/)[0] } : {}),\n };\n}\n","/**\n * Slot declaration helpers shared by the browser client (decide) and the\n * server preload path. Pure wrappers over @sentientui/policy.\n */\nimport {\n canonicalArm,\n slotBaselineArm,\n slotResultFor,\n type SlotDecl,\n type SlotResult,\n} from '@sentientui/policy';\n\n/** SDK-facing slot declaration. `dims` accepts readonly arrays (`as const`). */\nexport type SlotDeclInput = {\n id: string;\n arms?: string[];\n dims?: Record<string, readonly string[]>;\n baseline?: string | Record<string, string>;\n};\n\nexport type { SlotResult };\n\n/**\n * Whitelists the wire fields of a slot declaration. Anything an SDK layer\n * attached (goal configs, refs, …) is stripped so it never reaches the zod\n * schema on the API. Also normalizes readonly arrays to mutable ones.\n */\nexport function toWireSlot(d: SlotDeclInput): SlotDecl {\n return {\n id: d.id,\n ...(d.arms ? { arms: [...d.arms] } : {}),\n ...(d.dims\n ? {\n dims: Object.fromEntries(\n Object.entries(d.dims).map(([dim, values]) => [dim, [...values]]),\n ),\n }\n : {}),\n ...(d.baseline !== undefined ? { baseline: d.baseline } : {}),\n };\n}\n\n/** The declared (or default first-declared) baseline result for a slot. */\nexport function baselineResultFor(d: SlotDeclInput): SlotResult {\n const decl = toWireSlot(d);\n return slotResultFor(decl, slotBaselineArm(decl));\n}\n\n/** Baseline results for a whole declaration list, keyed by slot id. */\nexport function baselineSlots(decls: SlotDeclInput[]): Record<string, SlotResult> {\n const out: Record<string, SlotResult> = {};\n for (const d of decls) out[d.id] = baselineResultFor(d);\n return out;\n}\n\n/**\n * Canonical arm string of a slot result: dims results encode as sorted\n * `dim=value` pairs joined with '|'; arms results are the arm id verbatim.\n */\nexport function armOfResult(result: SlotResult): string {\n return typeof result === 'string' ? result : canonicalArm(result);\n}\n"],"mappings":"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","names":["agentUaList","uaTokenMatch","userAgent","matchedAgentToken","_a","s","token","CLASSIC_CRAWLER_TOKENS","matchedCrawlerToken","agent","AGENT_INTENTS","agentIntent","botName","hit","t","classifiedAgents","out","detectDeviceClass","detectTrafficSource","referrer","appOrigin","siteDomain","refUrl","e","host","referrerDomainFromReferer","CLICK_ID_KEYS","extractTrackedParams","search","utmParams","clickIds","entries","k","v","first","detectTimeOfDay","d","h","deriveSessionSegment","opts","body","buildSessionUpsertPayload","sessionId","_b","_c","_d","_e","_f","_g","_h","ua","referer","now","agentToken","__spreadValues","canonicalArm","slotBaselineArm","slotResultFor","toWireSlot","d","__spreadValues","dim","values","baselineResultFor","decl","slotResultFor","slotBaselineArm","baselineSlots","decls","out","armOfResult","result","canonicalArm"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as je,b as ye,c as Se,e as ce,f as Fe,g as We,h as Kt,i as Nt,j as Gt,k as $t,l as Ut,m as jt,n as Ve}from"./chunk-FPOHOWJP.mjs";import{b as He,g as ze,h as qe,i as Je,k as Xe,l as Ye,o as Qe,p as Ee,r as Ze}from"./chunk-NBDVEYI5.mjs";import{a as le,c as Ue,d as Mt,e as we}from"./chunk-J5EL7HKC.mjs";import{a as E,b as ne}from"./chunk-TMCGHANO.mjs";var et;function tt(e){et=typeof e=="string"&&e!==""?e:void 0}function Ft(e=document){if(et)return et;try{let n=e.querySelector("script[nonce]");return(n==null?void 0:n.nonce)||(n==null?void 0:n.getAttribute("nonce"))||void 0}catch(n){return}}function nt(e,n=document){let a=Ft(n);return a&&e.setAttribute("nonce",a),e}function Ce(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let n="";for(let a=0;a<16;a++)n+=e[a].toString(16).padStart(2,"0"),(a===3||a===5||a===7||a===9)&&(n+="-");return n}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let n=Math.random()*16|0;return(e==="x"?n:n&3|8).toString(16)})}var Wt="_snt_uid",pn=365,de="_snt_uid";function gn(){return Ce()}function ue(e){try{let n=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return n?decodeURIComponent(n[1]):null}catch(n){return null}}function Ht(){try{return location.protocol==="https:"?"; Secure":""}catch(e){return""}}function Ae(e,n,a,y){try{document.cookie=`${e}=${encodeURIComponent(n)}; max-age=${a}; SameSite=lax; path=/${y?`; domain=${y}`:""}${Ht()}`}catch(w){}}function Ie(e){try{return localStorage.getItem(e)}catch(n){return null}}function Vt(e,n){try{return localStorage.setItem(e,n),!0}catch(a){return!1}}function ot(e){try{return sessionStorage.getItem(e)}catch(n){return null}}function fn(e,n){try{return sessionStorage.setItem(e,n),!0}catch(a){return!1}}function mn(e){try{sessionStorage.removeItem(e)}catch(n){}}function yn(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=lax; path=/${Ht()}`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(n){return!1}}function Sn(e){try{localStorage.removeItem(e)}catch(n){}}function _e(e,n){Ae(e,"",0,n)}var hn={getSessionId:()=>null,isEphemeral:()=>!1,domain:null,destroy:()=>{}};function kn(e,n){if(e===!1)return null;if(typeof e=="string")return e.replace(/^\./,"");for(let a of jt(location.hostname))if(Ae(n,"1",10,a),ue(n)==="1")return _e(n,a),a;return null}function Re(e){var q,X,oe,ie,ee,j,r;if(typeof window=="undefined")return hn;let n=le(e==null?void 0:e.apiKey),a=(q=e==null?void 0:e.cookieName)!=null?q:Ue(e==null?void 0:e.apiKey),y=`${de}${n}`,w=`${de}_tomb${n}`,C=((X=e==null?void 0:e.cookieTTLDays)!=null?X:pn)*24*60*60,o=d=>d&&d.length>0?d:null,p=()=>{var d,S;return n&&!(e!=null&&e.cookieName)&&Ie(w)===null?(S=(d=o(ue(Wt)))!=null?d:o(Ie(de)))!=null?S:o(ot(de)):null},l=kn(e==null?void 0:e.cookieDomain,`${a}_dom`),c=o(ue(a)),i=l?(_e(a),o(ue(a))):null,b=(r=(j=(ee=(ie=(oe=i!=null?i:c)!=null?oe:o(Ie(y)))!=null?ie:o(ot(y)))!=null?ee:p())!=null?j:o(e==null?void 0:e.ssrSessionId))!=null?r:gn();Ae(a,b,C,l),l&&ue(a)!==b&&(l=null,Ae(a,b,C));let R=Vt(y,b),L=yn(a),M=R?!1:fn(y,b),$=!R&&!L&&!M;return{getSessionId:()=>b,isEphemeral:()=>$,domain:l,destroy:()=>{b=null,_e(a),_e(a,l),Sn(y),mn(y),n&&!(e!=null&&e.cookieName)&&(ue(Wt)!==null||Ie(de)!==null||ot(de)!==null)&&Vt(w,"1")}}}var bn=1800*1e3;function Te(e,n){return`${encodeURIComponent(e)}:${encodeURIComponent(n)}`}function zt(e=bn,n){let a=new Map,y=`_snt_asgn${le(n)}_`,w=(l,c)=>`${y}${encodeURIComponent(l)}:${encodeURIComponent(c)}`,m=l=>{let c=l.slice(y.length),i=c.indexOf(":");if(i<0)return null;try{return{componentId:decodeURIComponent(c.slice(0,i)),segment:decodeURIComponent(c.slice(i+1))}}catch(b){return null}},C=()=>{try{let l=[];for(let c=0;c<localStorage.length;c++){let i=localStorage.key(c);i!=null&&i.startsWith(y)&&l.push(i)}return l}catch(l){return[]}},o=l=>l.assignedAt+(l.ttlMs&&l.ttlMs>0?l.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let l of C())try{let c=localStorage.getItem(l);if(!c)continue;let i=JSON.parse(c);if(o(i)){localStorage.removeItem(l);continue}let b=m(l);if(!b)continue;a.set(Te(b.componentId,b.segment),i)}catch(c){}})(),{get(l,c){let i=a.get(Te(l,c));return i?o(i)?(a.delete(Te(l,c)),null):i:null},set(l,c,i){let b=Te(l,c);a.set(b,i);try{localStorage.setItem(w(l,c),JSON.stringify(i))}catch(R){}},clear(){a.clear();for(let l of C())try{localStorage.removeItem(l)}catch(c){}}}}import{STAGE_KEYS as vn}from"@sentientui/policy";var st="data-sentient-stage";function rt(e,n){return!n||typeof e!="string"||!(e==="returning"||vn.includes(e))?null:n!=="detailed"&&(e==="customer"||e==="lapsed")?"returning":e}function it(e,n=document){try{e?n.documentElement.setAttribute(st,e):n.documentElement.removeAttribute(st)}catch(a){}}import{confidenceBand as tn}from"@sentientui/policy";import{confidenceBand as at}from"@sentientui/policy";var lt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Jt="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",qt=!1,Oe=!1;function xn(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(n){return}}function Xt(e){var l;let n=Re({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),a=(l=n.getSessionId())!=null?l:"local",y=xn(),w=import("@sentientui/core/local").then(c=>{let i=c;return i.LOCAL_ENGINE_AVAILABLE?(qt||(qt=!0,console.info(Jt)),i):(Oe||(Oe=!0,console.error(lt)),null)}).catch(()=>(Oe||(Oe=!0,console.error(lt)),null)),m=null,C={low:.15,medium:.5,high:.85},o=(()=>{var i;if(e.initialPersona)return E({},e.initialPersona);let c=ye(e.apiKey||"local");return c?{persona:c.persona,confidence:(i=C[c.band])!=null?i:.15}:null})();function p(c){let i=document.documentElement;i.dataset.sentientPersona===void 0&&(i.dataset.sentientPersona=c.persona,i.dataset.sentientConfidence=at(c.confidence))}return{isLocal:!0,async decide(c){var R,L,M;let i=await w;if(!i)return null;let b=i.createLocalEngine({sessionId:a,forcedPersona:y}).decide(c);return m=ne(E({},b),{layoutOrder:(L=(R=b.layoutOrder)!=null?R:m==null?void 0:m.layoutOrder)!=null?L:null,slots:E(E({},(M=m==null?void 0:m.slots)!=null?M:{}),b.slots)}),Se(e.apiKey||"local",{v:1,persona:m.persona,band:at(m.confidence),slots:m.slots,layoutOrder:m.layoutOrder,savedAt:Date.now()}),p(b),b},getSlotResult(c){var i,b,R;return(R=(b=m==null?void 0:m.slots[c])!=null?b:(i=e.initialSlots)==null?void 0:i[c])!=null?R:null},getSlotConfig(c){var i,b;return(b=(i=e.initialSlotConfig)==null?void 0:i[c])!=null?b:null},getSitePalette(){var c;return(c=e.initialPalette)!=null?c:null},reportSlots(){},getVisitorId:()=>null,getPersona(){let c=m!=null?m:o;return c?{persona:c.persona,confidence:c.confidence,band:at(c.confidence)}:null},async assign(c,i){var L;let b=await w;return!b||!i||i.length===0?i!=null&&i[0]?{variantId:i[0],assignmentTtlMs:0}:null:{variantId:(L=b.createLocalEngine({sessionId:a,forcedPersona:y}).decide({components:[{id:c,variantIds:i}]}).assignments[c])!=null?L:i[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>n.destroy()}}var Yt=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function ct(e){let n=e.split(/[?#]/)[0]||"/";return n.length>1?n.replace(/\/+$/,"")||"/":n}function wn(e,n){if(e===void 0||!Yt.test(e))return!1;if(e==="*")return!0;let a=ct(n);if(e.endsWith("/*")){let y=ct(e.slice(0,-2));return a.startsWith(y==="/"?"/":`${y}/`)&&a!==y}return a===ct(e)}function En(e,n){if(!e)return!1;if(e==="/")return n==="/";let a=e.endsWith("/")?e.slice(0,-1):e;return n===a||n.startsWith(`${a}/`)}function Cn(e){if(!/^https?:\/\//i.test(e))return e;try{return new URL(e).pathname||"/"}catch(n){return e}}var no=["none","sm","md","lg"],oo=["start","center","end","stretch"],so=["start","center","end","between"],ro=["sm","md","lg"],io=["normal","medium","bold"],ao=["default","muted","accent"],lo=["primary","secondary","ghost"],co=["left","center","right"],uo=["auto","square","landscape","wide"],po=["cover","contain"],go=[2,3,4],fo=[1,2,3,4],mo=["default","raised"],yo=["none","sm","md","lg"],So=["measure"],ho=["input","textarea","select"],ko=["text","email","number","tel"],bo=5,vo=8,xo=64,wo=5,Eo=12,Co=4,Io=500;function In(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let n=e;return n.type==="form"?!0:Array.isArray(n.children)?n.children.some(In):!1}var dt="sentient-reveal",pe="sentient-revealed",Qt=240,De=!1;function _n(){var e;De=!1,typeof document!="undefined"&&((e=document.getElementById(dt))==null||e.remove())}function An(e){if(De||e.getElementById(dt)){De=!0;return}let n=nt(e.createElement("style"),e);n.id=dt,n.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${pe}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${pe}{animation:${pe} ${Qt}ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(n),De=!0}function Rn(e,n={}){var w;let a=(w=n.doc)!=null?w:typeof document!="undefined"?document:void 0;if(!a||!(e instanceof Element)||(n.arm!==void 0&&e.setAttribute("data-sentient-arm",n.arm),n.persona!==void 0&&e.setAttribute("data-sentient-persona",n.persona),n.previous!==void 0&&n.previous===e.textContent))return!1;An(a),e.classList.remove(pe),e.offsetWidth,e.classList.add(pe);let y=()=>{e.classList.remove(pe),e.removeEventListener("animationend",y)};return e.addEventListener("animationend",y),!0}function Tn(e,n,a,y){let w=[];{let o=!1,p=[],l=()=>{if(o)return;let c=Date.now();for(p.push(c);p.length>0&&c-p[0]>500;)p.shift();p.length>=3&&(o=!0,e("rage_click"))};n.addEventListener("click",l),w.push(()=>n.removeEventListener("click",l))}{let m=!1,C=o=>{if(m||!(o.target instanceof Node)||!n.contains(o.target)&&n!==o.target)return;m=!0;let p=typeof window!="undefined"?window.getSelection():null,l=p?p.toString().length:0;e("text_copy",{selectionLength:l})};document.addEventListener("copy",C),w.push(()=>document.removeEventListener("copy",C))}{let m=!1,C=!1,o=null,p=()=>{o!==null&&(clearTimeout(o),o=null)},l=()=>{m||!C||(p(),o=setTimeout(()=>{!m&&C&&(m=!0,e("scroll_hesitation"))},3e3))},c=()=>{p(),l()},i=R=>{for(let L of R)C=L.intersectionRatio>.3,C?l():p()},b=new IntersectionObserver(i,{threshold:[.3]});b.observe(n),window.addEventListener("scroll",c,{passive:!0}),w.push(()=>{b.disconnect(),window.removeEventListener("scroll",c),p()})}if((y==null?void 0:y.tabLoss)!==!1){let m=!1,C=a!=null?a:Date.now(),o=()=>{if(m||document.visibilityState!=="hidden")return;let p=Date.now()-C;p<15e3&&(m=!0,e("tab_loss",{timeOnPage:p}))};document.addEventListener("visibilitychange",o),w.push(()=>document.removeEventListener("visibilitychange",o))}return()=>{for(let m of w)m()}}function On(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var on="https://api.sentient-ui.com/v1/events",F=new Map,sn=null;function os(e,n){let a=F.get(e);a&&a.upgrade&&(a.reinit=n)}function Dn(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Ln=3;function ut(){return Ce()}function Le(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function Pn(){let e=new WeakMap,n=new Map,a=!1,y=(o,p,l)=>{let c=o.get(p);return l===null?c?!0:(o.set(p,new Set),!1):c?c.has(l)?!0:(c.add(l),!1):(o.set(p,new Set([l])),!1)},w=typeof window!="undefined"&&"event"in window,m=()=>{if(!w)return;let o=window.event;return typeof Event=="function"&&o instanceof Event?o:void 0},C=()=>{if(w){Promise.resolve().then(()=>{a=!1,n.clear()});return}let o=!1,p=()=>{o||(o=!0,a=!1,n.clear())};if(setTimeout(p,0),typeof MessageChannel=="function"){let l=new MessageChannel;l.port1.onmessage=()=>{l.port1.close(),l.port2.close(),p()},l.port2.postMessage(0)}};return{firedBefore(o,p){let l=m();if(l){let i=e.get(l);return i||(i=new Map,e.set(l,i)),y(i,o,p)}let c=y(n,o,p);return!c&&!a&&(a=!0,C()),c}}}var rn=new Set;function Bn(e,n,a){let y=typeof window=="undefined"?null:window.history;if(!y)return()=>{};let w=!1,m,C=()=>{if(w)return;let l=Le();!l||l===m||(m=l,e.track({projectId:n,componentId:"__page__",eventType:"pageview",payload:{}}),a(`${n}:${l}`))},o=[];for(let l of["pushState","replaceState"]){let c=y[l],i=function(...b){let R=c.apply(this,b);return C(),R};y[l]=i,o.push([l,c,i])}window.addEventListener("popstate",C);let p=Le();return p&&rn.has(`${n}:${p}`)?m=p:C(),()=>{if(!w){w=!0,window.removeEventListener("popstate",C);for(let[l,c,i]of o)y[l]===i&&(y[l]=c)}}}var he={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getVisitorId:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}};function Mn(){try{return Xe(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function an(e){return e.replace(/\/events\/?$/,"")}function ln(){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(n=>n==="1"||n==="yes")}function ss(e){var p;if(typeof window=="undefined")return;let n=e!=null?e:sn;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let a=F.get(n);if(!a){console.warn("[sentient] grantConsent() called before init()");return}let{config:y,upgrade:w,reinit:m}=a;if(!w){a.upgradeBlockedReason&&console.warn(a.upgradeBlockedReason);return}if(y.respectDoNotTrack!==!1&&ln())return;let C=(m!=null?m:Nn)(ne(E({},y),{consent:!0}));w(C);let o=(p=F.get(n))==null?void 0:p.dispose;F.set(n,{config:ne(E({},y),{consent:!0}),upgrade:null,dispose:o})}function Kn(e,n){var j;let a=e.preConsentBehavior==="statistical_winner",y=an((j=e.ingestUrl)!=null?j:on),w={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},m=new Map,C=new Map,o={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(r,d,S){if(!a)return Promise.resolve(null);let I=m.get(r);return I?Promise.resolve(I):gt(C,r,async()=>{try{let O=new URLSearchParams({componentId:r});for(let se of d!=null?d:[])O.append("variantIds[]",se);let G=ce(5e3),W;try{let se=await fetch(`${y}/winner?${O.toString()}`,{headers:w,signal:G.signal});if(!se.ok)return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null;W=await se.json()}finally{G.clear()}let T={variantId:W.variantId,assignmentTtlMs:0};return m.set(r,T),T}catch(O){return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getVisitorId:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}},p=!1,l=new Set,c=[],i=[],b=[],R=()=>{for(let[,,r]of b.splice(0))r(null);L.length=0},L=[],M=!1,$=()=>{if(p)return;M=!0;let r=F.get(e.apiKey);(r==null?void 0:r.upgrade)===ee&&F.set(e.apiKey,{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): client released before consent; call init() again"})},q=[],X=()=>{setTimeout(()=>{var r;try{(r=q.shift())==null||r(o)}catch(d){}q.length&&X()})},oe=r=>{p?q.length?q.push(r):r(o):!n&&!M&&L.length<100?L.push(r):M&&e.debug&&console.warn("[sentient] goal dropped: client released")},ie={get gated(){return!p&&!n},get released(){return M&&!p},takeHeld:()=>L.splice(0),track:r=>o.track(r),goal:((r,d,S,I)=>oe(O=>O.goal(r,d,S,I))),componentGoal:(r,d,S)=>o.componentGoal(r,d,S),identify:(r,d)=>o.identify(r,d),getAssignment:(r,d)=>o.getAssignment(r,d),isUnified:r=>{var d,S;return(S=(d=o.isUnified)==null?void 0:d.call(o,r))!=null?S:!1},assign:(r,d,S,I,O)=>o.assign(r,d,S,I,O),decide:r=>p?o.decide(r):M||n?Promise.resolve(null):new Promise(d=>b.push([r,nn(),d])),getSlotResult:r=>o.getSlotResult(r),isSlotDecided:r=>{var d,S;return(S=(d=o.isSlotDecided)==null?void 0:d.call(o,r))!=null?S:!0},getSlotConfig:r=>o.getSlotConfig(r),getSitePalette:()=>o.getSitePalette(),getStyleVocabulary:()=>{var r,d;return(d=(r=o.getStyleVocabulary)==null?void 0:r.call(o))!=null?d:null},reportSlots:(r,d,S,I)=>o.reportSlots(r,d,S,I),reportSkeleton:(r,d)=>{var S;return(S=o.reportSkeleton)==null?void 0:S.call(o,r,d)},reportAgentData:(r,d,S)=>{var I;return(I=o.reportAgentData)==null?void 0:I.call(o,r,d,S)},reportDrift:(r,d,S,I)=>{var O;return(O=o.reportDrift)==null?void 0:O.call(o,r,d,S,I)},requestSlots:(r,d,S)=>{var I;return p?(I=o.requestSlots)==null?void 0:I.call(o,r,d,S):c.push([r,d,S])},decideSlots:r=>{var d;return p?(d=o.decideSlots)==null?void 0:d.call(o,r):i.push(...r)},cancelSlots:r=>{var S;if(p)return(S=o.cancelSlots)==null?void 0:S.call(o,r);let d=new Set(r);for(let I of c)I[0]=I[0].filter(O=>!d.has(O));i=i.filter(I=>!d.has(I.id))},onSlotsChanged:r=>(l.add(r),()=>{l.delete(r)}),getPersona:()=>o.getPersona(),getVisitorId:()=>{var r,d;return(d=(r=o.getVisitorId)==null?void 0:r.call(o))!=null?d:null},fetchWeights:()=>o.fetchWeights(),getGraph:()=>o.getGraph(),flush:()=>o.flush(),dispose:()=>($(),R(),o.dispose()),destroy:()=>($(),R(),p?o.destroy():Ve(e.apiKey))};function ee(r){var S,I,O;o=r,p=!0,L.length&&(q.push(...L.splice(0)),X());let d=nn();for(let[G,W,T]of b.splice(0))W!==d?T(null):r.decide(G).then(T,()=>T(null));(S=r.onSlotsChanged)==null||S.call(r,()=>l.forEach(G=>G()));for(let[G,W,T]of c.splice(0))G.length>0&&((I=r.requestSlots)==null||I.call(r,G,W,T));i.length>0&&((O=r.decideSlots)==null||O.call(r,i.splice(0)))}return{proxy:ie,setInner:ee}}function nn(){return typeof location=="undefined"?"":location.pathname+(/^#!?\//.test(location.hash)?location.hash:"")}function gt(e,n,a){let y=e.get(n);if(y)return y;let w=(async()=>{try{return await a()}finally{e.delete(n)}})();return e.set(n,w),w}function Nn(e){var wt,Et,Ct,It,_t,At,Rt,Tt,Ot,Dt,Lt;if(typeof window=="undefined")return he;e.nonce&&tt(e.nonce),sn=e.apiKey||"local";let n=F.get(e.apiKey||"local");if(n!=null&&n.dispose)try{n.dispose()}catch(t){}let a=e.respectDoNotTrack!==!1&&ln(),y=e.consent===!1||a,w=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!w&&e.localMode!==!1)return F.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),y?he:Xt(e);if(y){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),F.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),he;let{proxy:t,setInner:s}=Kn(e,a);return F.set(e.apiKey,{config:e,upgrade:a?null:s}),t}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),he;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),he;let m=(wt=e.ingestUrl)!=null?wt:on,C=Date.now(),o=Re({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey,cookieDomain:e.cookieDomain}),p=zt(void 0,e.apiKey),l=!1,c=we(e.apiKey),i=()=>!l&&we(e.apiKey)===c,b=new Set((Et=e.initialUnified)!=null?Et:[]),R=ne(E({},p),{get:(t,s)=>b.has(t)?null:p.get(t,s),set:(...t)=>{i()&&p.set(...t)}}),L=Gt({ingestUrl:m,apiKey:e.apiKey}),M=an(m),$={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},q=new Set,X=Ut({url:`${M}/goals`,apiKey:e.apiKey,headers:$,onDrop:(t,s)=>{if(!e.debug){if(q.has(s))return;q.add(s)}console.warn(`[sentient] goal dropped (HTTP ${s}) \u2014 this will not be retried. `+(s===400?"The session was not found: call init() and let the session upsert complete before firing goals.":s===401||s===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),t)}}),oe=ze((Ct=navigator.userAgent)!=null?Ct:""),ie=window.location.origin,ee=qe((It=document.referrer)!=null?It:"",ie,o.domain),j=(_t=e.sessionSegment)!=null?_t:`${oe}:${ee}`,r=new Map,d=new Map,S=new Map,I=new Set,O=new Map,G=null,W=null,T=null,se=new Set,ke=new Set,Pe=new Map,Be=new Map,ft=new Set,mt=new Set,yt=new Set,St=new Set,Me=null,ge=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,ht=new Set,be=new Set,ve=new Set,fe=new Map,Ke=null,xe=new Set,me=new Map,Ne=null,cn=2,kt=new Map,J=!1,bt=(t,s,u)=>{var g;let v=new Set,x=1;for(let f of t){s.delete(f);let h=((g=kt.get(f))!=null?g:0)+1;kt.set(f,h),h<=cn&&(v.add(f),h>x&&(x=h))}v.size>0&&setTimeout(()=>{J||u(v)},We(x))},Ge=t=>{for(let s of t)S.has(s.id)||S.set(s.id,Ee(s))};if(e.initialSlots)for(let[t,s]of Object.entries(e.initialSlots))S.set(t,s),I.add(t);if(e.initialSlotConfig)for(let[t,s]of Object.entries(e.initialSlotConfig))O.set(t,s);e.initialPalette&&(G=e.initialPalette),e.initialVocabulary&&(W=e.initialVocabulary);let Y=ye(e.apiKey);if(Y){for(let[t,s]of Object.entries(Y.slots))S.has(t)||S.set(t,s);for(let[t,s]of Object.entries((At=Y.slotConfig)!=null?At:{}))O.has(t)||O.set(t,s);!G&&Y.palette&&(G=Y.palette),!W&&Y.vocabulary&&(W=Y.vocabulary)}let vt={low:.15,medium:.5,high:.85};if(e.initialPersona)T=E({},e.initialPersona);else{let t=document.documentElement.dataset;t.sentientPersona?T={persona:t.sentientPersona,confidence:(Tt=vt[(Rt=t.sentientConfidence)!=null?Rt:"low"])!=null?Tt:.15}:Y&&(T={persona:Y.persona,confidence:(Ot=vt[Y.band])!=null?Ot:.15})}if(e.initialAssignments)for(let[t,s]of Object.entries(e.initialAssignments))R.set(t,j,{variantId:s,assignedAt:Date.now(),segment:j,confidence:1});let te=Promise.resolve(),xt=o.getSessionId();if(xt){let t=Je((Dt=document.referrer)!=null?Dt:""),{utmParams:s,clickIds:u}=Mn(),v=E(E(E(E({sessionId:xt,deviceClass:oe,trafficSource:ee,referrerDomain:t,utmParams:s,clickIds:u,landingPath:typeof location!="undefined"?location.pathname:void 0,timeOfDay:Ye(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:o.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||He((Lt=navigator.userAgent)!=null?Lt:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),e.sdk?{sdk:e.sdk.name,sdkVersion:e.sdk.version}:{}),x=async()=>{for(let g=0;;g++){if(J||!i())return;let f=ce(5e3);try{let h=await fetch(`${M}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(v),headers:$,signal:f.signal});if(h.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(h.ok||Kt(h)==="dropped")return}catch(h){}finally{f.clear()}if(g>=Ln){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(h=>setTimeout(h,We(g+1)))}};try{te=x()}catch(g){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:L});let dn=Pn(),re=null,$e=!1,N={goal(t,s={},u=1,v=0){var K,A,V,z,H,U,k;let x=o.getSessionId();if(!x||J||!i())return;let g=Dn(s)?s:{metadata:s},f=[t,(K=g.externalId)!=null?K:"",(A=g.stepIndex)!=null?A:v,(V=g.weight)!=null?V:u].join("\0"),h=g.value!==void 0?`${g.value}\0${(z=g.currency)!=null?z:""}`:null;if(dn.firedBefore(f,h)){e.debug&&console.log(`[sentient] goal("${t}") already recorded for this action \u2014 not sent twice`);return}let D=ut(),_={sessionId:x,name:t,metadata:(H=g.metadata)!=null?H:{},weight:(U=g.weight)!=null?U:u,stepIndex:(k=g.stepIndex)!=null?k:v,goalId:D,value:g.value,currency:g.currency,externalId:g.externalId};e.debug&&console.log("[sentient] goal",_);let P={id:D,body:JSON.stringify(_)};te.then(()=>X.send(P))},componentGoal(t,s,u){var D,_,P;let v=o.getSessionId();if(!v||J||!i())return;let x=R.get(t,j),g=x?null:(D=S.get(t))!=null?D:null;if(!x&&g===null){e.debug&&console.warn(`[sentient] componentGoal("${t}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}if(!x&&!I.has(t)){e.debug&&console.warn(`[sentient] componentGoal("${t}"): slot not decided this session \u2014 not attributed`);return}let f=x?x.variantId:Ze(g),h={id:ut(),sessionId:v,projectId:e.apiKey,componentId:t,variantId:f,eventType:"goal_achieved",goalType:s,payload:E({reward:(_=u==null?void 0:u.reward)!=null?_:1,goalValue:u==null?void 0:u.value,currency:u==null?void 0:u.currency},(P=u==null?void 0:u.metadata)!=null?P:{}),timestamp:Date.now(),timeInSession:Date.now()-C,path:Le()};e.debug&&console.log("[sentient] componentGoal",h),te.then(()=>{!J&&i()&&L.push(h)})},identify(t,s){let u=o.getSessionId();!u||J||!i()||te.then(()=>{fetch(`${M}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:u,userId:t,userHash:s==null?void 0:s.userHash,ephemeral:o.isEphemeral()}),headers:$}).catch(()=>{})})},track(t){let s=o.getSessionId();if(!s||J||!i()||t.eventType==="variant_assigned"&&S.get(t.componentId)!==void 0&&!I.has(t.componentId)&&!R.get(t.componentId,j))return;let u=ne(E({path:Le()},t),{id:ut(),sessionId:s,timestamp:Date.now(),timeInSession:Date.now()-C});e.debug&&console.log("[sentient] track",u),te.then(()=>L.push(u))},getAssignment(t,s){return R.get(t,s)},isUnified:t=>b.has(t),async assign(t,s,u,v,x){var D;let g=o.getSessionId();if(!g)return null;let f=(x==null?void 0:x.unified)===!0;if(f&&b.has(t))return{variantId:(D=s==null?void 0:s[0])!=null?D:"",assignmentTtlMs:0,unified:!0};let h=R.get(t,j);if(h&&(s!=null&&s.length||h.content!==void 0)){let _=h.ttlMs&&h.ttlMs>0?Math.max(0,h.assignedAt+h.ttlMs-Date.now()):0;return{variantId:h.variantId,assignmentTtlMs:_,content:h.content}}return gt(r,f?`${t}\0unified`:t,async()=>{if(!await Fe(te,2500)||J||!i())return null;let _=ce(3e4);try{let P={sessionId:g,componentId:t,variantIds:s};v!==void 0?P.agentDataByVariant=v:u!==void 0&&(P.agentData=u),f&&(P.caps={unified:!0});let K=await fetch(`${M}/assign`,{method:"POST",body:JSON.stringify(P),headers:$,signal:_.signal});if(!K.ok)return null;let A=await K.json();return A.unified===!0?f?(b.add(t),{variantId:A.variantId,assignmentTtlMs:0,unified:!0}):null:(R.set(t,j,E({variantId:A.variantId,assignedAt:Date.now(),segment:j,confidence:1,content:A.content},A.assignmentTtlMs&&A.assignmentTtlMs>0?{ttlMs:A.assignmentTtlMs}:{})),A)}catch(P){return null}finally{_.clear()}})},async decide(t){var g,f;let s=o.getSessionId();if(!s)return null;let u=(g=t.slots)!=null?g:[],v={sessionId:s};t.sections&&t.sections.length>0&&(v.sections=t.sections.map(h=>({id:h}))),v.components=(f=t.components)!=null?f:[],u.length>0&&(v.slots=u.map(Qe)),t.slotsFrom==="registry"&&(v.slotsFrom="registry",t.registrySlotIds&&(v.registrySlotIds=t.registrySlotIds),t.bootstrap===!1&&(v.bootstrap=!1),t.render&&Object.keys(t.render).length>0&&(v.render=t.render)),t.v&&(v.v=t.v),typeof t.pp=="number"&&(v.pp=t.pp),e.persona&&(v.persona=e.persona);let x=JSON.stringify(v);return gt(d,x,async()=>{var D,_,P,K,A,V,z,H;if(!await Fe(te,2500)||J||!i())return Ge(u),null;let h=ce(3e4);try{let U=await fetch(`${M}/decide`,{method:"POST",body:x,headers:$,signal:h.signal});if(!U.ok)return Ge(u),null;let k=await U.json(),Q=rt(k.stage,e.stageAttributes);e.stageAttributes&&it(Q);let ae={};for(let B of u){let Z=(D=k.slots)==null?void 0:D[B.id];if(Z!==void 0){ae[B.id]=Z,S.set(B.id,Z),I.add(B.id);continue}let Pt=S.get(B.id);if(Pt!==void 0)ae[B.id]=Pt;else{let Bt=Ee(B);ae[B.id]=Bt,S.set(B.id,Bt)}}if(k.slots)for(let[B,Z]of Object.entries(k.slots))B in ae||(ae[B]=Z,S.set(B,Z),I.add(B));let un=T!=null&&T.persona!=="unknown";k.persona&&!(k.persona==="unknown"&&un)?T={persona:k.persona,confidence:(_=k.confidence)!=null?_:0}:T||(T={persona:"unknown",confidence:0});for(let[B,Z]of Object.entries((P=k.assignments)!=null?P:{}))R.set(B,j,{variantId:Z,assignedAt:Date.now(),segment:j,confidence:1});if(k.slotConfig)for(let[B,Z]of Object.entries(k.slotConfig))O.set(B,Z);k.palette&&(G=k.palette),k.vocabulary&&(W=k.vocabulary);for(let B of(K=t.registrySlotIds)!=null?K:[])(A=k.slotConfig)!=null&&A[B]||(O.delete(B),S.delete(B),I.delete(B));return i()&&Se(e.apiKey,E(E(E(E({v:1,persona:T.persona,band:tn(T.confidence),slots:Object.fromEntries(S),layoutOrder:(V=k.layoutOrder)!=null?V:null,savedAt:Date.now()},O.size>0?{slotConfig:Object.fromEntries(O)}:{}),G?{palette:G}:{}),W?{vocabulary:W}:{}),Q?{stage:Q}:{})),E(E(E(E(E(E(E({layoutOrder:(z=k.layoutOrder)!=null?z:null,assignments:(H=k.assignments)!=null?H:{},slots:ae,persona:T.persona,confidence:T.confidence},k.slotConfig?{slotConfig:k.slotConfig}:{}),k.goals?{goals:k.goals}:{}),k.sectionMap?{sectionMap:k.sectionMap}:{}),k.palette?{palette:k.palette}:{}),k.vocabulary?{vocabulary:k.vocabulary}:{}),k.stage?{stage:k.stage}:{}),k.context?{context:k.context}:{})}catch(U){return Ge(u),null}finally{h.clear()}})},getSlotResult(t){var s;return(s=S.get(t))!=null?s:null},isSlotDecided(t){return I.has(t)},getSlotConfig(t){var s;return(s=O.get(t))!=null?s:null},reportSlots(t,s,u,v){var g;let x={};for(let[f,h]of Object.entries(v!=null?v:{}))for(let D of h){let _=`${f}|${D.key}`;!ge.test(f)||yt.has(_)||(yt.add(_),((g=x[f])!=null?g:x[f]=[]).push(D))}Object.keys(x).length>0&&fetch(`${M}/slots/observed`,{method:"POST",headers:$,body:JSON.stringify({slotIds:Object.keys(x),authoredArms:x})}).catch(()=>{});for(let f of t)if(!(typeof f!="string"||f.length===0)){if(!ge.test(f)){On()&&!ht.has(f)&&(ht.add(f),console.warn(`[sentient] reportSlots: slot id ${JSON.stringify(f)} will not register \u2014 ids must start with a letter or digit and contain only letters, digits, '_' or '-' (max 128 chars): /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.`));continue}if(!se.has(f)){se.add(f),ke.add(f);let h=s==null?void 0:s[f];if(typeof h=="string"){let _=h.replace(/\s+/g," ").trim().slice(0,400);_!==""&&Pe.set(f,_)}let D=u==null?void 0:u[f];D!==void 0&&Be.set(f,D)}}ke.size===0||Me!=null||(Me=setTimeout(()=>{Me=null;let f=[...ke];ke.clear();for(let h=0;h<f.length;h+=20){let D=f.slice(h,h+20),_={},P={};for(let K of D){let A=Pe.get(K);A!==void 0&&(_[K]=A,Pe.delete(K));let V=Be.get(K);V!==void 0&&(P[K]=V,Be.delete(K))}fetch(`${M}/slots/observed`,{method:"POST",headers:$,body:JSON.stringify(E(ne(E(E({slotIds:D},Object.keys(_).length>0?{baselineTexts:_}:{}),Object.keys(P).length>0?{baselineSkeletons:P}:{}),{pagePaths:Object.fromEntries(D.map(K=>[K,location.pathname]))}),Object.keys(_).length>0&&o.getSessionId()?{sessionId:o.getSessionId()}:{}))}).catch(()=>{})}},1e3))},reportSkeleton(t,s){!ge.test(t)||ft.has(t)||(ft.add(t),fetch(`${M}/slots/observed`,{method:"POST",headers:$,body:JSON.stringify({slotIds:[t],baselineSkeletons:{[t]:s}})}).catch(()=>{}))},reportAgentData(t,s,u){let v=`${t}|${s}`;!ge.test(t)||St.has(v)||(St.add(v),fetch(`${M}/slots/observed`,{method:"POST",headers:$,body:JSON.stringify(E(E({slotIds:[t],agentData:{[t]:{[s]:u}}},s.startsWith("authored.")?{authoredArms:{[t]:[{key:s.slice(9)}]}}:{}),o.getSessionId()?{sessionId:o.getSessionId()}:{}))}).catch(()=>{}))},reportDrift(t,s,u,v){let x=`${t}|${s}`,g=o.getSessionId();!g||mt.has(x)||(mt.add(x),fetch(`${M}/slots/drift`,{method:"POST",headers:$,body:JSON.stringify({sessionId:g,reports:[{slotId:t,expectedFp:s,observedFp:u,reason:v}]})}).catch(()=>{}))},requestSlots(t,s,u){var v,x;for(let g of t)ve.has(g)||(ve.add(g),ge.test(g)?fe.set(g,{text:s==null?void 0:s[g],render:(v=u==null?void 0:u.render)==null?void 0:v[g],skeleton:(x=u==null?void 0:u.skeletons)==null?void 0:x[g]}):N.reportSlots([g]));fe.size===0||Ke!=null||(Ke=setTimeout(()=>{Ke=null;let g=[...fe];fe.clear();for(let f=0;f<g.length;f+=50){let h=g.slice(f,f+50),D={};for(let[_,P]of h)P.render&&(D[_]=P.render);N.decide({slotsFrom:"registry",registrySlotIds:h.map(([_])=>_),bootstrap:!1,render:D}).then(_=>{var P,K;if(_){let A={},V={},z=[];for(let[H,U]of h){let k=(P=_.slotConfig)==null?void 0:P[H];if(k){k.needsSkeleton&&U.skeleton&&((K=N.reportSkeleton)==null||K.call(N,H,U.skeleton));continue}z.push(H),U.text&&(A[H]=U.text),U.skeleton&&(V[H]=U.skeleton)}z.length>0&&N.reportSlots(z,A,V)}else bt(h.map(([A])=>A),ve,A=>{var U;let V={},z={},H={};for(let[k,Q]of h)A.has(k)&&(Q.text&&(V[k]=Q.text),Q.render&&(z[k]=Q.render),Q.skeleton&&(H[k]=Q.skeleton));(U=N.requestSlots)==null||U.call(N,[...A],V,{render:z,skeletons:H})});be.forEach(A=>A())})}},0))},decideSlots(t){for(let s of t)xe.has(s.id)||(xe.add(s.id),me.set(s.id,s));me.size===0||Ne!=null||(Ne=setTimeout(()=>{Ne=null;let s=[...me.values()];me.clear();for(let u=0;u<s.length;u+=30){let v=s.slice(u,u+30);N.decide({slots:v}).then(x=>{x||bt(v.map(g=>g.id),xe,g=>{var f;return(f=N.decideSlots)==null?void 0:f.call(N,v.filter(h=>g.has(h.id)))}),be.forEach(g=>g())})}},0))},cancelSlots(t){for(let s of t)fe.delete(s)&&ve.delete(s),me.delete(s)&&xe.delete(s)},onSlotsChanged(t){return be.add(t),()=>{be.delete(t)}},getStyleVocabulary(){return W},getSitePalette(){return G},getVisitorId:()=>i()?o.getSessionId():null,getPersona(){return T?{persona:T.persona,confidence:T.confidence,band:tn(T.confidence)}:null},async fetchWeights(){var s;let t=ce(5e3);try{let u=await fetch(`${M}/weights`,{headers:$,signal:t.signal});return u.ok?(s=(await u.json()).components)!=null?s:[]:[]}catch(u){return[]}finally{t.clear()}},getGraph(){return{pageNodes:[],capturedAt:0}},flush(){L.flush(),X.flush()},dispose(){var t;re==null||re(),$e=!0,J=!0,L.destroy(),X.destroy(),((t=F.get(e.apiKey))==null?void 0:t.dispose)===N.dispose&&F.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var t;re==null||re(),$e=!0,J=!0,l=!0,Mt(e.apiKey),L.destroy({forget:!0}),X.destroy({forget:!0}),o.destroy(),R.clear(),((t=F.get(e.apiKey))==null?void 0:t.dispose)===N.dispose&&F.delete(e.apiKey);try{localStorage.removeItem(je+e.apiKey),localStorage.removeItem(Nt(e.apiKey)),localStorage.removeItem($t(e.apiKey)),localStorage.removeItem(`_snt_graph_nodes${le(e.apiKey)}`),localStorage.removeItem("_snt_graph_edges")}catch(s){}e.debug&&console.log("[sentient] destroyed")}};if(F.set(e.apiKey,{config:e,upgrade:null,dispose:N.dispose}),re=Bn(N,e.apiKey,t=>{te.then(()=>{$e||rn.add(t)})}),e.debug){let t=window;t.__sentient&&(t.__sentient.client=N)}return N}export{tt as a,Ft as b,nt as c,st as d,rt as e,it as f,lt as g,Jt as h,Yt as i,wn as j,En as k,Cn as l,no as m,oo as n,so as o,ro as p,io as q,ao as r,lo as s,co as t,uo as u,po as v,go as w,fo as x,mo as y,yo as z,So as A,ho as B,ko as C,bo as D,vo as E,xo as F,wo as G,Eo as H,Co as I,Io as J,In as K,Qt as L,_n as M,Rn as N,Tn as O,os as P,ln as Q,ss as R,nn as S,Nn as T};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as je,b as ye,c as Se,e as ce,f as We,g as Fe,h as Kt,i as Nt,j as Gt,k as $t,l as Ut,m as jt,n as Ve}from"./chunk-FPOHOWJP.mjs";import{b as He,i as ze,j as qe,k as Je,m as Xe,n as Ye,q as Qe,r as Ee,t as Ze}from"./chunk-3HMJERH4.mjs";import{a as le,c as Ue,d as Mt,e as we}from"./chunk-J5EL7HKC.mjs";import{a as E,b as ne}from"./chunk-TMCGHANO.mjs";var et;function tt(e){et=typeof e=="string"&&e!==""?e:void 0}function Wt(e=document){if(et)return et;try{let n=e.querySelector("script[nonce]");return(n==null?void 0:n.nonce)||(n==null?void 0:n.getAttribute("nonce"))||void 0}catch(n){return}}function nt(e,n=document){let a=Wt(n);return a&&e.setAttribute("nonce",a),e}function Ce(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let n="";for(let a=0;a<16;a++)n+=e[a].toString(16).padStart(2,"0"),(a===3||a===5||a===7||a===9)&&(n+="-");return n}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let n=Math.random()*16|0;return(e==="x"?n:n&3|8).toString(16)})}var Ft="_snt_uid",pn=365,de="_snt_uid";function gn(){return Ce()}function ue(e){try{let n=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return n?decodeURIComponent(n[1]):null}catch(n){return null}}function Ht(){try{return location.protocol==="https:"?"; Secure":""}catch(e){return""}}function Ae(e,n,a,y){try{document.cookie=`${e}=${encodeURIComponent(n)}; max-age=${a}; SameSite=lax; path=/${y?`; domain=${y}`:""}${Ht()}`}catch(w){}}function Ie(e){try{return localStorage.getItem(e)}catch(n){return null}}function Vt(e,n){try{return localStorage.setItem(e,n),!0}catch(a){return!1}}function ot(e){try{return sessionStorage.getItem(e)}catch(n){return null}}function fn(e,n){try{return sessionStorage.setItem(e,n),!0}catch(a){return!1}}function mn(e){try{sessionStorage.removeItem(e)}catch(n){}}function yn(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=lax; path=/${Ht()}`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(n){return!1}}function Sn(e){try{localStorage.removeItem(e)}catch(n){}}function _e(e,n){Ae(e,"",0,n)}var hn={getSessionId:()=>null,isEphemeral:()=>!1,domain:null,destroy:()=>{}};function kn(e,n){if(e===!1)return null;if(typeof e=="string")return e.replace(/^\./,"");for(let a of jt(location.hostname))if(Ae(n,"1",10,a),ue(n)==="1")return _e(n,a),a;return null}function Re(e){var q,X,oe,ie,ee,j,r;if(typeof window=="undefined")return hn;let n=le(e==null?void 0:e.apiKey),a=(q=e==null?void 0:e.cookieName)!=null?q:Ue(e==null?void 0:e.apiKey),y=`${de}${n}`,w=`${de}_tomb${n}`,C=((X=e==null?void 0:e.cookieTTLDays)!=null?X:pn)*24*60*60,o=d=>d&&d.length>0?d:null,p=()=>{var d,S;return n&&!(e!=null&&e.cookieName)&&Ie(w)===null?(S=(d=o(ue(Ft)))!=null?d:o(Ie(de)))!=null?S:o(ot(de)):null},l=kn(e==null?void 0:e.cookieDomain,`${a}_dom`),c=o(ue(a)),i=l?(_e(a),o(ue(a))):null,b=(r=(j=(ee=(ie=(oe=i!=null?i:c)!=null?oe:o(Ie(y)))!=null?ie:o(ot(y)))!=null?ee:p())!=null?j:o(e==null?void 0:e.ssrSessionId))!=null?r:gn();Ae(a,b,C,l),l&&ue(a)!==b&&(l=null,Ae(a,b,C));let R=Vt(y,b),L=yn(a),M=R?!1:fn(y,b),$=!R&&!L&&!M;return{getSessionId:()=>b,isEphemeral:()=>$,domain:l,destroy:()=>{b=null,_e(a),_e(a,l),Sn(y),mn(y),n&&!(e!=null&&e.cookieName)&&(ue(Ft)!==null||Ie(de)!==null||ot(de)!==null)&&Vt(w,"1")}}}var bn=1800*1e3;function Te(e,n){return`${encodeURIComponent(e)}:${encodeURIComponent(n)}`}function zt(e=bn,n){let a=new Map,y=`_snt_asgn${le(n)}_`,w=(l,c)=>`${y}${encodeURIComponent(l)}:${encodeURIComponent(c)}`,m=l=>{let c=l.slice(y.length),i=c.indexOf(":");if(i<0)return null;try{return{componentId:decodeURIComponent(c.slice(0,i)),segment:decodeURIComponent(c.slice(i+1))}}catch(b){return null}},C=()=>{try{let l=[];for(let c=0;c<localStorage.length;c++){let i=localStorage.key(c);i!=null&&i.startsWith(y)&&l.push(i)}return l}catch(l){return[]}},o=l=>l.assignedAt+(l.ttlMs&&l.ttlMs>0?l.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let l of C())try{let c=localStorage.getItem(l);if(!c)continue;let i=JSON.parse(c);if(o(i)){localStorage.removeItem(l);continue}let b=m(l);if(!b)continue;a.set(Te(b.componentId,b.segment),i)}catch(c){}})(),{get(l,c){let i=a.get(Te(l,c));return i?o(i)?(a.delete(Te(l,c)),null):i:null},set(l,c,i){let b=Te(l,c);a.set(b,i);try{localStorage.setItem(w(l,c),JSON.stringify(i))}catch(R){}},clear(){a.clear();for(let l of C())try{localStorage.removeItem(l)}catch(c){}}}}import{STAGE_KEYS as vn}from"@sentientui/policy";var st="data-sentient-stage";function rt(e,n){return!n||typeof e!="string"||!(e==="returning"||vn.includes(e))?null:n!=="detailed"&&(e==="customer"||e==="lapsed")?"returning":e}function it(e,n=document){try{e?n.documentElement.setAttribute(st,e):n.documentElement.removeAttribute(st)}catch(a){}}import{confidenceBand as tn}from"@sentientui/policy";import{confidenceBand as at}from"@sentientui/policy";var lt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Jt="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",qt=!1,Oe=!1;function xn(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(n){return}}function Xt(e){var l;let n=Re({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),a=(l=n.getSessionId())!=null?l:"local",y=xn(),w=import("@sentientui/core/local").then(c=>{let i=c;return i.LOCAL_ENGINE_AVAILABLE?(qt||(qt=!0,console.info(Jt)),i):(Oe||(Oe=!0,console.error(lt)),null)}).catch(()=>(Oe||(Oe=!0,console.error(lt)),null)),m=null,C={low:.15,medium:.5,high:.85},o=(()=>{var i;if(e.initialPersona)return E({},e.initialPersona);let c=ye(e.apiKey||"local");return c?{persona:c.persona,confidence:(i=C[c.band])!=null?i:.15}:null})();function p(c){let i=document.documentElement;i.dataset.sentientPersona===void 0&&(i.dataset.sentientPersona=c.persona,i.dataset.sentientConfidence=at(c.confidence))}return{isLocal:!0,async decide(c){var R,L,M;let i=await w;if(!i)return null;let b=i.createLocalEngine({sessionId:a,forcedPersona:y}).decide(c);return m=ne(E({},b),{layoutOrder:(L=(R=b.layoutOrder)!=null?R:m==null?void 0:m.layoutOrder)!=null?L:null,slots:E(E({},(M=m==null?void 0:m.slots)!=null?M:{}),b.slots)}),Se(e.apiKey||"local",{v:1,persona:m.persona,band:at(m.confidence),slots:m.slots,layoutOrder:m.layoutOrder,savedAt:Date.now()}),p(b),b},getSlotResult(c){var i,b,R;return(R=(b=m==null?void 0:m.slots[c])!=null?b:(i=e.initialSlots)==null?void 0:i[c])!=null?R:null},getSlotConfig(c){var i,b;return(b=(i=e.initialSlotConfig)==null?void 0:i[c])!=null?b:null},getSitePalette(){var c;return(c=e.initialPalette)!=null?c:null},reportSlots(){},getVisitorId:()=>null,getPersona(){let c=m!=null?m:o;return c?{persona:c.persona,confidence:c.confidence,band:at(c.confidence)}:null},async assign(c,i){var L;let b=await w;return!b||!i||i.length===0?i!=null&&i[0]?{variantId:i[0],assignmentTtlMs:0}:null:{variantId:(L=b.createLocalEngine({sessionId:a,forcedPersona:y}).decide({components:[{id:c,variantIds:i}]}).assignments[c])!=null?L:i[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>n.destroy()}}var Yt=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function ct(e){let n=e.split(/[?#]/)[0]||"/";return n.length>1?n.replace(/\/+$/,"")||"/":n}function wn(e,n){if(e===void 0||!Yt.test(e))return!1;if(e==="*")return!0;let a=ct(n);if(e.endsWith("/*")){let y=ct(e.slice(0,-2));return a.startsWith(y==="/"?"/":`${y}/`)&&a!==y}return a===ct(e)}function En(e,n){if(!e)return!1;if(e==="/")return n==="/";let a=e.endsWith("/")?e.slice(0,-1):e;return n===a||n.startsWith(`${a}/`)}function Cn(e){if(!/^https?:\/\//i.test(e))return e;try{return new URL(e).pathname||"/"}catch(n){return e}}var no=["none","sm","md","lg"],oo=["start","center","end","stretch"],so=["start","center","end","between"],ro=["sm","md","lg"],io=["normal","medium","bold"],ao=["default","muted","accent"],lo=["primary","secondary","ghost"],co=["left","center","right"],uo=["auto","square","landscape","wide"],po=["cover","contain"],go=[2,3,4],fo=[1,2,3,4],mo=["default","raised"],yo=["none","sm","md","lg"],So=["measure"],ho=["input","textarea","select"],ko=["text","email","number","tel"],bo=5,vo=8,xo=64,wo=5,Eo=12,Co=4,Io=500;function In(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let n=e;return n.type==="form"?!0:Array.isArray(n.children)?n.children.some(In):!1}var dt="sentient-reveal",pe="sentient-revealed",Qt=240,De=!1;function _n(){var e;De=!1,typeof document!="undefined"&&((e=document.getElementById(dt))==null||e.remove())}function An(e){if(De||e.getElementById(dt)){De=!0;return}let n=nt(e.createElement("style"),e);n.id=dt,n.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${pe}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${pe}{animation:${pe} ${Qt}ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(n),De=!0}function Rn(e,n={}){var w;let a=(w=n.doc)!=null?w:typeof document!="undefined"?document:void 0;if(!a||!(e instanceof Element)||(n.arm!==void 0&&e.setAttribute("data-sentient-arm",n.arm),n.persona!==void 0&&e.setAttribute("data-sentient-persona",n.persona),n.previous!==void 0&&n.previous===e.textContent))return!1;An(a),e.classList.remove(pe),e.offsetWidth,e.classList.add(pe);let y=()=>{e.classList.remove(pe),e.removeEventListener("animationend",y)};return e.addEventListener("animationend",y),!0}function Tn(e,n,a,y){let w=[];{let o=!1,p=[],l=()=>{if(o)return;let c=Date.now();for(p.push(c);p.length>0&&c-p[0]>500;)p.shift();p.length>=3&&(o=!0,e("rage_click"))};n.addEventListener("click",l),w.push(()=>n.removeEventListener("click",l))}{let m=!1,C=o=>{if(m||!(o.target instanceof Node)||!n.contains(o.target)&&n!==o.target)return;m=!0;let p=typeof window!="undefined"?window.getSelection():null,l=p?p.toString().length:0;e("text_copy",{selectionLength:l})};document.addEventListener("copy",C),w.push(()=>document.removeEventListener("copy",C))}{let m=!1,C=!1,o=null,p=()=>{o!==null&&(clearTimeout(o),o=null)},l=()=>{m||!C||(p(),o=setTimeout(()=>{!m&&C&&(m=!0,e("scroll_hesitation"))},3e3))},c=()=>{p(),l()},i=R=>{for(let L of R)C=L.intersectionRatio>.3,C?l():p()},b=new IntersectionObserver(i,{threshold:[.3]});b.observe(n),window.addEventListener("scroll",c,{passive:!0}),w.push(()=>{b.disconnect(),window.removeEventListener("scroll",c),p()})}if((y==null?void 0:y.tabLoss)!==!1){let m=!1,C=a!=null?a:Date.now(),o=()=>{if(m||document.visibilityState!=="hidden")return;let p=Date.now()-C;p<15e3&&(m=!0,e("tab_loss",{timeOnPage:p}))};document.addEventListener("visibilitychange",o),w.push(()=>document.removeEventListener("visibilitychange",o))}return()=>{for(let m of w)m()}}function On(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var on="https://api.sentient-ui.com/v1/events",W=new Map,sn=null;function rs(e,n){let a=W.get(e);a&&a.upgrade&&(a.reinit=n)}function Dn(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Ln=3;function ut(){return Ce()}function Le(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function Pn(){let e=new WeakMap,n=new Map,a=!1,y=(o,p,l)=>{let c=o.get(p);return l===null?c?!0:(o.set(p,new Set),!1):c?c.has(l)?!0:(c.add(l),!1):(o.set(p,new Set([l])),!1)},w=typeof window!="undefined"&&"event"in window,m=()=>{if(!w)return;let o=window.event;return typeof Event=="function"&&o instanceof Event?o:void 0},C=()=>{if(w){Promise.resolve().then(()=>{a=!1,n.clear()});return}let o=!1,p=()=>{o||(o=!0,a=!1,n.clear())};if(setTimeout(p,0),typeof MessageChannel=="function"){let l=new MessageChannel;l.port1.onmessage=()=>{l.port1.close(),l.port2.close(),p()},l.port2.postMessage(0)}};return{firedBefore(o,p){let l=m();if(l){let i=e.get(l);return i||(i=new Map,e.set(l,i)),y(i,o,p)}let c=y(n,o,p);return!c&&!a&&(a=!0,C()),c}}}var rn=new Set;function Bn(e,n,a){let y=typeof window=="undefined"?null:window.history;if(!y)return()=>{};let w=!1,m,C=()=>{if(w)return;let l=Le();!l||l===m||(m=l,e.track({projectId:n,componentId:"__page__",eventType:"pageview",payload:{}}),a(`${n}:${l}`))},o=[];for(let l of["pushState","replaceState"]){let c=y[l],i=function(...b){let R=c.apply(this,b);return C(),R};y[l]=i,o.push([l,c,i])}window.addEventListener("popstate",C);let p=Le();return p&&rn.has(`${n}:${p}`)?m=p:C(),()=>{if(!w){w=!0,window.removeEventListener("popstate",C);for(let[l,c,i]of o)y[l]===i&&(y[l]=c)}}}var he={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getVisitorId:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}};function Mn(){try{return Xe(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function an(e){return e.replace(/\/events\/?$/,"")}function ln(){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(n=>n==="1"||n==="yes")}function is(e){var p;if(typeof window=="undefined")return;let n=e!=null?e:sn;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let a=W.get(n);if(!a){console.warn("[sentient] grantConsent() called before init()");return}let{config:y,upgrade:w,reinit:m}=a;if(!w){a.upgradeBlockedReason&&console.warn(a.upgradeBlockedReason);return}if(y.respectDoNotTrack!==!1&&ln())return;let C=(m!=null?m:Nn)(ne(E({},y),{consent:!0}));w(C);let o=(p=W.get(n))==null?void 0:p.dispose;W.set(n,{config:ne(E({},y),{consent:!0}),upgrade:null,dispose:o})}function Kn(e,n){var j;let a=e.preConsentBehavior==="statistical_winner",y=an((j=e.ingestUrl)!=null?j:on),w={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},m=new Map,C=new Map,o={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(r,d,S){if(!a)return Promise.resolve(null);let I=m.get(r);return I?Promise.resolve(I):gt(C,r,async()=>{try{let O=new URLSearchParams({componentId:r});for(let se of d!=null?d:[])O.append("variantIds[]",se);let G=ce(5e3),F;try{let se=await fetch(`${y}/winner?${O.toString()}`,{headers:w,signal:G.signal});if(!se.ok)return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null;F=await se.json()}finally{G.clear()}let T={variantId:F.variantId,assignmentTtlMs:0};return m.set(r,T),T}catch(O){return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getVisitorId:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}},p=!1,l=new Set,c=[],i=[],b=[],R=()=>{for(let[,,r]of b.splice(0))r(null);L.length=0},L=[],M=!1,$=()=>{if(p)return;M=!0;let r=W.get(e.apiKey);(r==null?void 0:r.upgrade)===ee&&W.set(e.apiKey,{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): client released before consent; call init() again"})},q=[],X=()=>{setTimeout(()=>{var r;try{(r=q.shift())==null||r(o)}catch(d){}q.length&&X()})},oe=r=>{p?q.length?q.push(r):r(o):!n&&!M&&L.length<100?L.push(r):M&&e.debug&&console.warn("[sentient] goal dropped: client released")},ie={get gated(){return!p&&!n},get released(){return M&&!p},takeHeld:()=>L.splice(0),track:r=>o.track(r),goal:((r,d,S,I)=>oe(O=>O.goal(r,d,S,I))),componentGoal:(r,d,S)=>o.componentGoal(r,d,S),identify:(r,d)=>o.identify(r,d),getAssignment:(r,d)=>o.getAssignment(r,d),isUnified:r=>{var d,S;return(S=(d=o.isUnified)==null?void 0:d.call(o,r))!=null?S:!1},assign:(r,d,S,I,O)=>o.assign(r,d,S,I,O),decide:r=>p?o.decide(r):M||n?Promise.resolve(null):new Promise(d=>b.push([r,nn(),d])),getSlotResult:r=>o.getSlotResult(r),isSlotDecided:r=>{var d,S;return(S=(d=o.isSlotDecided)==null?void 0:d.call(o,r))!=null?S:!0},getSlotConfig:r=>o.getSlotConfig(r),getSitePalette:()=>o.getSitePalette(),getStyleVocabulary:()=>{var r,d;return(d=(r=o.getStyleVocabulary)==null?void 0:r.call(o))!=null?d:null},reportSlots:(r,d,S,I)=>o.reportSlots(r,d,S,I),reportSkeleton:(r,d)=>{var S;return(S=o.reportSkeleton)==null?void 0:S.call(o,r,d)},reportAgentData:(r,d,S)=>{var I;return(I=o.reportAgentData)==null?void 0:I.call(o,r,d,S)},reportDrift:(r,d,S,I)=>{var O;return(O=o.reportDrift)==null?void 0:O.call(o,r,d,S,I)},requestSlots:(r,d,S)=>{var I;return p?(I=o.requestSlots)==null?void 0:I.call(o,r,d,S):c.push([r,d,S])},decideSlots:r=>{var d;return p?(d=o.decideSlots)==null?void 0:d.call(o,r):i.push(...r)},cancelSlots:r=>{var S;if(p)return(S=o.cancelSlots)==null?void 0:S.call(o,r);let d=new Set(r);for(let I of c)I[0]=I[0].filter(O=>!d.has(O));i=i.filter(I=>!d.has(I.id))},onSlotsChanged:r=>(l.add(r),()=>{l.delete(r)}),getPersona:()=>o.getPersona(),getVisitorId:()=>{var r,d;return(d=(r=o.getVisitorId)==null?void 0:r.call(o))!=null?d:null},fetchWeights:()=>o.fetchWeights(),getGraph:()=>o.getGraph(),flush:()=>o.flush(),dispose:()=>($(),R(),o.dispose()),destroy:()=>($(),R(),p?o.destroy():Ve(e.apiKey))};function ee(r){var S,I,O;o=r,p=!0,L.length&&(q.push(...L.splice(0)),X());let d=nn();for(let[G,F,T]of b.splice(0))F!==d?T(null):r.decide(G).then(T,()=>T(null));(S=r.onSlotsChanged)==null||S.call(r,()=>l.forEach(G=>G()));for(let[G,F,T]of c.splice(0))G.length>0&&((I=r.requestSlots)==null||I.call(r,G,F,T));i.length>0&&((O=r.decideSlots)==null||O.call(r,i.splice(0)))}return{proxy:ie,setInner:ee}}function nn(){return typeof location=="undefined"?"":location.pathname+(/^#!?\//.test(location.hash)?location.hash:"")}function gt(e,n,a){let y=e.get(n);if(y)return y;let w=(async()=>{try{return await a()}finally{e.delete(n)}})();return e.set(n,w),w}function Nn(e){var wt,Et,Ct,It,_t,At,Rt,Tt,Ot,Dt,Lt;if(typeof window=="undefined")return he;e.nonce&&tt(e.nonce),sn=e.apiKey||"local";let n=W.get(e.apiKey||"local");if(n!=null&&n.dispose)try{n.dispose()}catch(t){}let a=e.respectDoNotTrack!==!1&&ln(),y=e.consent===!1||a,w=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!w&&e.localMode!==!1)return W.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),y?he:Xt(e);if(y){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),W.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),he;let{proxy:t,setInner:s}=Kn(e,a);return W.set(e.apiKey,{config:e,upgrade:a?null:s}),t}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),he;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),he;let m=(wt=e.ingestUrl)!=null?wt:on,C=Date.now(),o=Re({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey,cookieDomain:e.cookieDomain}),p=zt(void 0,e.apiKey),l=!1,c=we(e.apiKey),i=()=>!l&&we(e.apiKey)===c,b=new Set((Et=e.initialUnified)!=null?Et:[]),R=ne(E({},p),{get:(t,s)=>b.has(t)?null:p.get(t,s),set:(...t)=>{i()&&p.set(...t)}}),L=Gt({ingestUrl:m,apiKey:e.apiKey}),M=an(m),$={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},q=new Set,X=Ut({url:`${M}/goals`,apiKey:e.apiKey,headers:$,onDrop:(t,s)=>{if(!e.debug){if(q.has(s))return;q.add(s)}console.warn(`[sentient] goal dropped (HTTP ${s}) \u2014 this will not be retried. `+(s===400?"The session was not found: call init() and let the session upsert complete before firing goals.":s===401||s===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),t)}}),oe=ze((Ct=navigator.userAgent)!=null?Ct:""),ie=window.location.origin,ee=qe((It=document.referrer)!=null?It:"",ie,o.domain),j=(_t=e.sessionSegment)!=null?_t:`${oe}:${ee}`,r=new Map,d=new Map,S=new Map,I=new Set,O=new Map,G=null,F=null,T=null,se=new Set,ke=new Set,Pe=new Map,Be=new Map,ft=new Set,mt=new Set,yt=new Set,St=new Set,Me=null,ge=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,ht=new Set,be=new Set,ve=new Set,fe=new Map,Ke=null,xe=new Set,me=new Map,Ne=null,cn=2,kt=new Map,J=!1,bt=(t,s,u)=>{var g;let v=new Set,x=1;for(let f of t){s.delete(f);let h=((g=kt.get(f))!=null?g:0)+1;kt.set(f,h),h<=cn&&(v.add(f),h>x&&(x=h))}v.size>0&&setTimeout(()=>{J||u(v)},Fe(x))},Ge=t=>{for(let s of t)S.has(s.id)||S.set(s.id,Ee(s))};if(e.initialSlots)for(let[t,s]of Object.entries(e.initialSlots))S.set(t,s),I.add(t);if(e.initialSlotConfig)for(let[t,s]of Object.entries(e.initialSlotConfig))O.set(t,s);e.initialPalette&&(G=e.initialPalette),e.initialVocabulary&&(F=e.initialVocabulary);let Y=ye(e.apiKey);if(Y){for(let[t,s]of Object.entries(Y.slots))S.has(t)||S.set(t,s);for(let[t,s]of Object.entries((At=Y.slotConfig)!=null?At:{}))O.has(t)||O.set(t,s);!G&&Y.palette&&(G=Y.palette),!F&&Y.vocabulary&&(F=Y.vocabulary)}let vt={low:.15,medium:.5,high:.85};if(e.initialPersona)T=E({},e.initialPersona);else{let t=document.documentElement.dataset;t.sentientPersona?T={persona:t.sentientPersona,confidence:(Tt=vt[(Rt=t.sentientConfidence)!=null?Rt:"low"])!=null?Tt:.15}:Y&&(T={persona:Y.persona,confidence:(Ot=vt[Y.band])!=null?Ot:.15})}if(e.initialAssignments)for(let[t,s]of Object.entries(e.initialAssignments))R.set(t,j,{variantId:s,assignedAt:Date.now(),segment:j,confidence:1});let te=Promise.resolve(),xt=o.getSessionId();if(xt){let t=Je((Dt=document.referrer)!=null?Dt:""),{utmParams:s,clickIds:u}=Mn(),v=E(E(E(E({sessionId:xt,deviceClass:oe,trafficSource:ee,referrerDomain:t,utmParams:s,clickIds:u,landingPath:typeof location!="undefined"?location.pathname:void 0,timeOfDay:Ye(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:o.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||He((Lt=navigator.userAgent)!=null?Lt:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),e.sdk?{sdk:e.sdk.name,sdkVersion:e.sdk.version}:{}),x=async()=>{for(let g=0;;g++){if(J||!i())return;let f=ce(5e3);try{let h=await fetch(`${M}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(v),headers:$,signal:f.signal});if(h.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(h.ok||Kt(h)==="dropped")return}catch(h){}finally{f.clear()}if(g>=Ln){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(h=>setTimeout(h,Fe(g+1)))}};try{te=x()}catch(g){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:L});let dn=Pn(),re=null,$e=!1,N={goal(t,s={},u=1,v=0){var K,A,V,z,H,U,k;let x=o.getSessionId();if(!x||J||!i())return;let g=Dn(s)?s:{metadata:s},f=[t,(K=g.externalId)!=null?K:"",(A=g.stepIndex)!=null?A:v,(V=g.weight)!=null?V:u].join("\0"),h=g.value!==void 0?`${g.value}\0${(z=g.currency)!=null?z:""}`:null;if(dn.firedBefore(f,h)){e.debug&&console.log(`[sentient] goal("${t}") already recorded for this action \u2014 not sent twice`);return}let D=ut(),_={sessionId:x,name:t,metadata:(H=g.metadata)!=null?H:{},weight:(U=g.weight)!=null?U:u,stepIndex:(k=g.stepIndex)!=null?k:v,goalId:D,value:g.value,currency:g.currency,externalId:g.externalId};e.debug&&console.log("[sentient] goal",_);let P={id:D,body:JSON.stringify(_)};te.then(()=>X.send(P))},componentGoal(t,s,u){var D,_,P;let v=o.getSessionId();if(!v||J||!i())return;let x=R.get(t,j),g=x?null:(D=S.get(t))!=null?D:null;if(!x&&g===null){e.debug&&console.warn(`[sentient] componentGoal("${t}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}if(!x&&!I.has(t)){e.debug&&console.warn(`[sentient] componentGoal("${t}"): slot not decided this session \u2014 not attributed`);return}let f=x?x.variantId:Ze(g),h={id:ut(),sessionId:v,projectId:e.apiKey,componentId:t,variantId:f,eventType:"goal_achieved",goalType:s,payload:E({reward:(_=u==null?void 0:u.reward)!=null?_:1,goalValue:u==null?void 0:u.value,currency:u==null?void 0:u.currency},(P=u==null?void 0:u.metadata)!=null?P:{}),timestamp:Date.now(),timeInSession:Date.now()-C,path:Le()};e.debug&&console.log("[sentient] componentGoal",h),te.then(()=>{!J&&i()&&L.push(h)})},identify(t,s){let u=o.getSessionId();!u||J||!i()||te.then(()=>{fetch(`${M}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:u,userId:t,userHash:s==null?void 0:s.userHash,ephemeral:o.isEphemeral()}),headers:$}).catch(()=>{})})},track(t){let s=o.getSessionId();if(!s||J||!i()||t.eventType==="variant_assigned"&&S.get(t.componentId)!==void 0&&!I.has(t.componentId)&&!R.get(t.componentId,j))return;let u=ne(E({path:Le()},t),{id:ut(),sessionId:s,timestamp:Date.now(),timeInSession:Date.now()-C});e.debug&&console.log("[sentient] track",u),te.then(()=>L.push(u))},getAssignment(t,s){return R.get(t,s)},isUnified:t=>b.has(t),async assign(t,s,u,v,x){var D;let g=o.getSessionId();if(!g)return null;let f=(x==null?void 0:x.unified)===!0;if(f&&b.has(t))return{variantId:(D=s==null?void 0:s[0])!=null?D:"",assignmentTtlMs:0,unified:!0};let h=R.get(t,j);if(h&&(s!=null&&s.length||h.content!==void 0)){let _=h.ttlMs&&h.ttlMs>0?Math.max(0,h.assignedAt+h.ttlMs-Date.now()):0;return{variantId:h.variantId,assignmentTtlMs:_,content:h.content}}return gt(r,f?`${t}\0unified`:t,async()=>{if(!await We(te,2500)||J||!i())return null;let _=ce(3e4);try{let P={sessionId:g,componentId:t,variantIds:s};v!==void 0?P.agentDataByVariant=v:u!==void 0&&(P.agentData=u),f&&(P.caps={unified:!0});let K=await fetch(`${M}/assign`,{method:"POST",body:JSON.stringify(P),headers:$,signal:_.signal});if(!K.ok)return null;let A=await K.json();return A.unified===!0?f?(b.add(t),{variantId:A.variantId,assignmentTtlMs:0,unified:!0}):null:(R.set(t,j,E({variantId:A.variantId,assignedAt:Date.now(),segment:j,confidence:1,content:A.content},A.assignmentTtlMs&&A.assignmentTtlMs>0?{ttlMs:A.assignmentTtlMs}:{})),A)}catch(P){return null}finally{_.clear()}})},async decide(t){var g,f;let s=o.getSessionId();if(!s)return null;let u=(g=t.slots)!=null?g:[],v={sessionId:s};t.sections&&t.sections.length>0&&(v.sections=t.sections.map(h=>({id:h}))),v.components=(f=t.components)!=null?f:[],u.length>0&&(v.slots=u.map(Qe)),t.slotsFrom==="registry"&&(v.slotsFrom="registry",t.registrySlotIds&&(v.registrySlotIds=t.registrySlotIds),t.bootstrap===!1&&(v.bootstrap=!1),t.render&&Object.keys(t.render).length>0&&(v.render=t.render)),t.v&&(v.v=t.v),typeof t.pp=="number"&&(v.pp=t.pp),e.persona&&(v.persona=e.persona);let x=JSON.stringify(v);return gt(d,x,async()=>{var D,_,P,K,A,V,z,H;if(!await We(te,2500)||J||!i())return Ge(u),null;let h=ce(3e4);try{let U=await fetch(`${M}/decide`,{method:"POST",body:x,headers:$,signal:h.signal});if(!U.ok)return Ge(u),null;let k=await U.json(),Q=rt(k.stage,e.stageAttributes);e.stageAttributes&&it(Q);let ae={};for(let B of u){let Z=(D=k.slots)==null?void 0:D[B.id];if(Z!==void 0){ae[B.id]=Z,S.set(B.id,Z),I.add(B.id);continue}let Pt=S.get(B.id);if(Pt!==void 0)ae[B.id]=Pt;else{let Bt=Ee(B);ae[B.id]=Bt,S.set(B.id,Bt)}}if(k.slots)for(let[B,Z]of Object.entries(k.slots))B in ae||(ae[B]=Z,S.set(B,Z),I.add(B));let un=T!=null&&T.persona!=="unknown";k.persona&&!(k.persona==="unknown"&&un)?T={persona:k.persona,confidence:(_=k.confidence)!=null?_:0}:T||(T={persona:"unknown",confidence:0});for(let[B,Z]of Object.entries((P=k.assignments)!=null?P:{}))R.set(B,j,{variantId:Z,assignedAt:Date.now(),segment:j,confidence:1});if(k.slotConfig)for(let[B,Z]of Object.entries(k.slotConfig))O.set(B,Z);k.palette&&(G=k.palette),k.vocabulary&&(F=k.vocabulary);for(let B of(K=t.registrySlotIds)!=null?K:[])(A=k.slotConfig)!=null&&A[B]||(O.delete(B),S.delete(B),I.delete(B));return i()&&Se(e.apiKey,E(E(E(E({v:1,persona:T.persona,band:tn(T.confidence),slots:Object.fromEntries(S),layoutOrder:(V=k.layoutOrder)!=null?V:null,savedAt:Date.now()},O.size>0?{slotConfig:Object.fromEntries(O)}:{}),G?{palette:G}:{}),F?{vocabulary:F}:{}),Q?{stage:Q}:{})),E(E(E(E(E(E(E({layoutOrder:(z=k.layoutOrder)!=null?z:null,assignments:(H=k.assignments)!=null?H:{},slots:ae,persona:T.persona,confidence:T.confidence},k.slotConfig?{slotConfig:k.slotConfig}:{}),k.goals?{goals:k.goals}:{}),k.sectionMap?{sectionMap:k.sectionMap}:{}),k.palette?{palette:k.palette}:{}),k.vocabulary?{vocabulary:k.vocabulary}:{}),k.stage?{stage:k.stage}:{}),k.context?{context:k.context}:{})}catch(U){return Ge(u),null}finally{h.clear()}})},getSlotResult(t){var s;return(s=S.get(t))!=null?s:null},isSlotDecided(t){return I.has(t)},getSlotConfig(t){var s;return(s=O.get(t))!=null?s:null},reportSlots(t,s,u,v){var g;let x={};for(let[f,h]of Object.entries(v!=null?v:{}))for(let D of h){let _=`${f}|${D.key}`;!ge.test(f)||yt.has(_)||(yt.add(_),((g=x[f])!=null?g:x[f]=[]).push(D))}Object.keys(x).length>0&&fetch(`${M}/slots/observed`,{method:"POST",headers:$,body:JSON.stringify({slotIds:Object.keys(x),authoredArms:x})}).catch(()=>{});for(let f of t)if(!(typeof f!="string"||f.length===0)){if(!ge.test(f)){On()&&!ht.has(f)&&(ht.add(f),console.warn(`[sentient] reportSlots: slot id ${JSON.stringify(f)} will not register \u2014 ids must start with a letter or digit and contain only letters, digits, '_' or '-' (max 128 chars): /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.`));continue}if(!se.has(f)){se.add(f),ke.add(f);let h=s==null?void 0:s[f];if(typeof h=="string"){let _=h.replace(/\s+/g," ").trim().slice(0,400);_!==""&&Pe.set(f,_)}let D=u==null?void 0:u[f];D!==void 0&&Be.set(f,D)}}ke.size===0||Me!=null||(Me=setTimeout(()=>{Me=null;let f=[...ke];ke.clear();for(let h=0;h<f.length;h+=20){let D=f.slice(h,h+20),_={},P={};for(let K of D){let A=Pe.get(K);A!==void 0&&(_[K]=A,Pe.delete(K));let V=Be.get(K);V!==void 0&&(P[K]=V,Be.delete(K))}fetch(`${M}/slots/observed`,{method:"POST",headers:$,body:JSON.stringify(E(ne(E(E({slotIds:D},Object.keys(_).length>0?{baselineTexts:_}:{}),Object.keys(P).length>0?{baselineSkeletons:P}:{}),{pagePaths:Object.fromEntries(D.map(K=>[K,location.pathname]))}),Object.keys(_).length>0&&o.getSessionId()?{sessionId:o.getSessionId()}:{}))}).catch(()=>{})}},1e3))},reportSkeleton(t,s){!ge.test(t)||ft.has(t)||(ft.add(t),fetch(`${M}/slots/observed`,{method:"POST",headers:$,body:JSON.stringify({slotIds:[t],baselineSkeletons:{[t]:s}})}).catch(()=>{}))},reportAgentData(t,s,u){let v=`${t}|${s}`;!ge.test(t)||St.has(v)||(St.add(v),fetch(`${M}/slots/observed`,{method:"POST",headers:$,body:JSON.stringify(E(E({slotIds:[t],agentData:{[t]:{[s]:u}}},s.startsWith("authored.")?{authoredArms:{[t]:[{key:s.slice(9)}]}}:{}),o.getSessionId()?{sessionId:o.getSessionId()}:{}))}).catch(()=>{}))},reportDrift(t,s,u,v){let x=`${t}|${s}`,g=o.getSessionId();!g||mt.has(x)||(mt.add(x),fetch(`${M}/slots/drift`,{method:"POST",headers:$,body:JSON.stringify({sessionId:g,reports:[{slotId:t,expectedFp:s,observedFp:u,reason:v}]})}).catch(()=>{}))},requestSlots(t,s,u){var v,x;for(let g of t)ve.has(g)||(ve.add(g),ge.test(g)?fe.set(g,{text:s==null?void 0:s[g],render:(v=u==null?void 0:u.render)==null?void 0:v[g],skeleton:(x=u==null?void 0:u.skeletons)==null?void 0:x[g]}):N.reportSlots([g]));fe.size===0||Ke!=null||(Ke=setTimeout(()=>{Ke=null;let g=[...fe];fe.clear();for(let f=0;f<g.length;f+=50){let h=g.slice(f,f+50),D={};for(let[_,P]of h)P.render&&(D[_]=P.render);N.decide({slotsFrom:"registry",registrySlotIds:h.map(([_])=>_),bootstrap:!1,render:D}).then(_=>{var P,K;if(_){let A={},V={},z=[];for(let[H,U]of h){let k=(P=_.slotConfig)==null?void 0:P[H];if(k){k.needsSkeleton&&U.skeleton&&((K=N.reportSkeleton)==null||K.call(N,H,U.skeleton));continue}z.push(H),U.text&&(A[H]=U.text),U.skeleton&&(V[H]=U.skeleton)}z.length>0&&N.reportSlots(z,A,V)}else bt(h.map(([A])=>A),ve,A=>{var U;let V={},z={},H={};for(let[k,Q]of h)A.has(k)&&(Q.text&&(V[k]=Q.text),Q.render&&(z[k]=Q.render),Q.skeleton&&(H[k]=Q.skeleton));(U=N.requestSlots)==null||U.call(N,[...A],V,{render:z,skeletons:H})});be.forEach(A=>A())})}},0))},decideSlots(t){for(let s of t)xe.has(s.id)||(xe.add(s.id),me.set(s.id,s));me.size===0||Ne!=null||(Ne=setTimeout(()=>{Ne=null;let s=[...me.values()];me.clear();for(let u=0;u<s.length;u+=30){let v=s.slice(u,u+30);N.decide({slots:v}).then(x=>{x||bt(v.map(g=>g.id),xe,g=>{var f;return(f=N.decideSlots)==null?void 0:f.call(N,v.filter(h=>g.has(h.id)))}),be.forEach(g=>g())})}},0))},cancelSlots(t){for(let s of t)fe.delete(s)&&ve.delete(s),me.delete(s)&&xe.delete(s)},onSlotsChanged(t){return be.add(t),()=>{be.delete(t)}},getStyleVocabulary(){return F},getSitePalette(){return G},getVisitorId:()=>i()?o.getSessionId():null,getPersona(){return T?{persona:T.persona,confidence:T.confidence,band:tn(T.confidence)}:null},async fetchWeights(){var s;let t=ce(5e3);try{let u=await fetch(`${M}/weights`,{headers:$,signal:t.signal});return u.ok?(s=(await u.json()).components)!=null?s:[]:[]}catch(u){return[]}finally{t.clear()}},getGraph(){return{pageNodes:[],capturedAt:0}},flush(){L.flush(),X.flush()},dispose(){var t;re==null||re(),$e=!0,J=!0,L.destroy(),X.destroy(),((t=W.get(e.apiKey))==null?void 0:t.dispose)===N.dispose&&W.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var t;re==null||re(),$e=!0,J=!0,l=!0,Mt(e.apiKey),L.destroy({forget:!0}),X.destroy({forget:!0}),o.destroy(),R.clear(),((t=W.get(e.apiKey))==null?void 0:t.dispose)===N.dispose&&W.delete(e.apiKey);try{localStorage.removeItem(je+e.apiKey),localStorage.removeItem(Nt(e.apiKey)),localStorage.removeItem($t(e.apiKey)),localStorage.removeItem(`_snt_graph_nodes${le(e.apiKey)}`),localStorage.removeItem("_snt_graph_edges")}catch(s){}e.debug&&console.log("[sentient] destroyed")}};if(W.set(e.apiKey,{config:e,upgrade:null,dispose:N.dispose}),re=Bn(N,e.apiKey,t=>{te.then(()=>{$e||rn.add(t)})}),e.debug){let t=window;t.__sentient&&(t.__sentient.client=N)}return N}export{tt as a,Wt as b,nt as c,st as d,rt as e,it as f,lt as g,Jt as h,Yt as i,wn as j,En as k,Cn as l,no as m,oo as n,so as o,ro as p,io as q,ao as r,lo as s,co as t,uo as u,po as v,go as w,fo as x,mo as y,yo as z,So as A,ho as B,ko as C,bo as D,vo as E,xo as F,wo as G,Eo as H,Co as I,Io as J,In as K,Qt as L,_n as M,Rn as N,Tn as O,rs as P,ln as Q,is as R,nn as S,Nn as T};
|
|
2
|
+
//# sourceMappingURL=chunk-KXA3X6T3.mjs.map
|