@sentientui/core 0.29.1 → 0.31.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.
Files changed (40) hide show
  1. package/README.md +21 -5
  2. package/dist/chunk-SFNOFZUH.mjs +2 -0
  3. package/dist/chunk-SFNOFZUH.mjs.map +1 -0
  4. package/dist/{index-B0PkJoeB.d.cts → index-DErBinAw.d.cts} +68 -3
  5. package/dist/{index-BIdUwF-v.d.ts → index-DxWcBI5U.d.ts} +68 -3
  6. package/dist/index-engagement.d.cts +8 -2
  7. package/dist/index-engagement.d.ts +8 -2
  8. package/dist/index-engagement.js +1 -1
  9. package/dist/index-engagement.js.map +1 -1
  10. package/dist/index-engagement.mjs +1 -1
  11. package/dist/index-engagement.mjs.map +1 -1
  12. package/dist/index-graph.d.cts +21 -5
  13. package/dist/index-graph.d.ts +21 -5
  14. package/dist/index-graph.js +1 -1
  15. package/dist/index-graph.js.map +1 -1
  16. package/dist/index-graph.mjs +1 -1
  17. package/dist/index-graph.mjs.map +1 -1
  18. package/dist/index-local.d.cts +2 -2
  19. package/dist/index-local.d.ts +2 -2
  20. package/dist/index-local.js +1 -1
  21. package/dist/index-local.js.map +1 -1
  22. package/dist/index-local.mjs +1 -1
  23. package/dist/index-local.mjs.map +1 -1
  24. package/dist/index-server.d.cts +14 -3
  25. package/dist/index-server.d.ts +14 -3
  26. package/dist/index-server.js +1 -1
  27. package/dist/index-server.js.map +1 -1
  28. package/dist/index-server.mjs +1 -1
  29. package/dist/index-server.mjs.map +1 -1
  30. package/dist/index.d.cts +2 -2
  31. package/dist/index.d.ts +2 -2
  32. package/dist/index.js +1 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/index.mjs +1 -1
  35. package/dist/{session-meta-CY_Luh5i.d.ts → session-meta-DydKfQiR.d.cts} +2 -0
  36. package/dist/{session-meta-CY_Luh5i.d.cts → session-meta-DydKfQiR.d.ts} +2 -0
  37. package/llms.txt +4 -4
  38. package/package.json +2 -2
  39. package/dist/chunk-HY23LTUY.mjs +0 -2
  40. package/dist/chunk-HY23LTUY.mjs.map +0 -1
package/README.md CHANGED
@@ -17,7 +17,6 @@ import { init } from '@sentientui/core';
17
17
 
18
18
  const client = init({
19
19
  apiKey: 'pk_your_key', // from sentient-ui.com → Settings
20
- context: 'saas', // 'landing' | 'ecommerce' | 'saas' | 'marketplace'
21
20
  });
22
21
 
23
22
  // Get a variant assignment for a component (returns null during SSR)
@@ -42,7 +41,7 @@ client.goal('trial_started', { plan: 'pro' });
42
41
  | Option | Type | Description |
43
42
  |--------|------|-------------|
44
43
  | `apiKey` | `string` | Public API key (`pk_…`) from the SentientUI dashboard. |
45
- | `context` | `'landing' \| 'ecommerce' \| 'saas' \| 'marketplace'` | Local label only — echoed in `debug` logs, never sent to the server. Analytics grouping comes from the project's context type configured in the dashboard. |
44
+ | `context` | `'landing' \| 'ecommerce' \| 'saas' \| 'marketplace'` *(optional, deprecated)* | Unused — the project's type is set in the dashboard. Safe to omit. |
46
45
  | `consent` | `boolean` *(default `true`)* | When `false`, returns a no-op client (no cookies, no events). **The default is `true`** — for GDPR-style opt-in, pass `false` until your banner is accepted (see `preConsentBehavior`). |
47
46
  | `preConsentBehavior` | `'control' \| 'statistical_winner'` | What to render while `consent` is `false`: `'control'` (the default — shows `variantIds[0]`), or the read-only statistical winner via `/v1/winner` (no session, no events). |
48
47
  | `respectDoNotTrack` | `boolean` *(default `true`)* | Honors the browser DNT signal — overrides `consent: true` and blocks `grantConsent()`. |
@@ -159,7 +158,7 @@ const outcome = await client.decide({
159
158
  // layoutOrder: string[] | null,
160
159
  // assignments: Record<string, string>,
161
160
  // slots: { hero: { tone: 'urgent' }, 'pricing-area': 'social_first' },
162
- // persona: 'buyer', confidence: 0.8,
161
+ // persona: 'admin', confidence: 1, // declared personas serve at full confidence
163
162
  // }
164
163
  client.getSlotResult('hero'); // sync read of a decided slot
165
164
  client.getPersona(); // { persona, confidence, band: 'low' | 'medium' | 'high' }
@@ -168,6 +167,23 @@ client.getPersona(); // { persona, confidence, band: 'low' | 'medium'
168
167
  Decisions are locked per session. Apply dims results as `data-<dim>` attributes and style them
169
168
  with CSS. At least one of `sections` / `components` / `slots` must be present.
170
169
 
170
+ ### `client.requestSlots(slotIds, baselineTexts?)` / `client.onSlotsChanged(listener)`
171
+
172
+ Optional client methods behind `@sentientui/react`'s generated-version `<Adaptive>` — regions
173
+ whose versions are written in the dashboard rather than in code. `requestSlots` asks for the
174
+ config of the regions actually mounted: calls made in the same tick are batched into one request
175
+ scoped to exactly those ids, and each id is requested at most once per client. Ids with nothing
176
+ published register as drafts; `baselineTexts` maps an id to the text the region shows today, sent
177
+ with that first registration. `onSlotsChanged` subscribes to the answer landing and returns the
178
+ unsubscribe.
179
+
180
+ ```ts
181
+ const unsubscribe = client.onSlotsChanged?.(() => {
182
+ const entry = client.getSlotConfig('hero-cta'); // null → keep rendering the original
183
+ });
184
+ client.requestSlots?.(['hero-cta'], { 'hero-cta': 'Start free trial' });
185
+ ```
186
+
171
187
  ## Decision snapshot (pre-paint on return visits)
172
188
 
173
189
  Every decide writes a snapshot (persona, confidence band, slot results, layout order) to
@@ -191,7 +207,7 @@ session, zero network — via the separate entry `@sentientui/core/local`:
191
207
  ```ts
192
208
  import { createLocalEngine } from '@sentientui/core/local';
193
209
 
194
- const engine = createLocalEngine({ sessionId, forcedPersona: 'deal_seeker' });
210
+ const engine = createLocalEngine({ sessionId, forcedPersona: 'evaluator' });
195
211
  const outcome = engine.decide({ slots: [{ id: 'hero', dims: { tone: ['calm', 'urgent'] } }] });
196
212
  ```
197
213
 
@@ -206,7 +222,7 @@ physically contain none of it. Production without a key short-circuits to defaul
206
222
  ```ts
207
223
  import { init } from '@sentientui/core/graph';
208
224
 
209
- const client = init({ apiKey: 'pk_…', context: 'saas', graph: true });
225
+ const client = init({ apiKey: 'pk_…', graph: true });
210
226
  ```
211
227
 
212
228
  A client created by the lean `init` can never activate graph mode later (`getGraph()` stays empty). The lean bundle is ~8 KB gzip (CI budget: 10 KB); graph adds ~3–4 KB gzip on top of the lean bundle (combined CI budget: 16 KB).
@@ -0,0 +1,2 @@
1
+ import{a as we,c as De,e as Pe,j as Le,k as Me,l as Ke,n as Ne,o as Ge,r as Fe,s as ke,u as Ue}from"./chunk-2NVSFI4V.mjs";import{a as P,b as ce}from"./chunk-TMCGHANO.mjs";function xe(){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 t="";for(let o=0;o<16;o++)t+=e[o].toString(16).padStart(2,"0"),(o===3||o===5||o===7||o===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var Bt="_snt_uid",Dt=365,be="_snt_uid";function Pt(){return xe()}function ft(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Lt(e,t,o){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${o}; SameSite=strict; path=/`}catch(p){}}function $e(e){try{return localStorage.getItem(e)}catch(t){return null}}function mt(e,t){try{return localStorage.setItem(e,t),!0}catch(o){return!1}}function yt(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function Mt(e,t){try{return sessionStorage.setItem(e,t),!0}catch(o){return!1}}function Kt(e){try{sessionStorage.removeItem(e)}catch(t){}}function Nt(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function Gt(e){try{localStorage.removeItem(e)}catch(t){}}function Ft(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Ut={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function Ee(e){var u,m,b,x,K,G,R;if(typeof window=="undefined")return Ut;let t=we(e==null?void 0:e.apiKey),o=(u=e==null?void 0:e.cookieName)!=null?u:De(e==null?void 0:e.apiKey),p=`${be}${t}`,S=`${be}_tomb${t}`,l=((m=e==null?void 0:e.cookieTTLDays)!=null?m:Dt)*24*60*60,c=L=>L&&L.length>0?L:null,g=()=>{var L,B;return t&&!(e!=null&&e.cookieName)&&$e(S)===null?(B=(L=c(ft(Bt)))!=null?L:c($e(be)))!=null?B:c(yt(be)):null},r=(R=(G=(K=(x=(b=c(ft(o)))!=null?b:c($e(p)))!=null?x:c(yt(p)))!=null?K:g())!=null?G:c(e==null?void 0:e.ssrSessionId))!=null?R:Pt();Lt(o,r,l);let s=mt(p,r),i=Nt(o),k=s?!1:Mt(p,r),O=!s&&!i&&!k;return{getSessionId:()=>r,isEphemeral:()=>O,destroy:()=>{r=null,Ft(o),Gt(p),Kt(p),t&&!(e!=null&&e.cookieName)&&mt(S,"1")}}}function Y(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function de(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function Ie(e,t){try{let o=localStorage.getItem(e);if(!o)return[];let p=JSON.parse(o);return Array.isArray(p)?(localStorage.removeItem(e),p.slice(-t)):[]}catch(o){return[]}}function oe(e,t,o){try{let p=(()=>{try{let d=localStorage.getItem(o);if(!d)return[];let l=JSON.parse(d);return Array.isArray(l)?l:[]}catch(d){return[]}})(),S=new Map;for(let d of p)S.set(d.id,d);for(let d of e)S.set(d.id,d);localStorage.setItem(o,JSON.stringify([...S.values()].slice(-t)))}catch(p){}}function _e(e,t){try{let o=localStorage.getItem(t);if(!o)return;let p=JSON.parse(o);if(!Array.isArray(p))return;let S=new Set(e),d=p.filter(l=>!S.has(l.id));if(d.length===p.length)return;d.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(d))}catch(o){}}var $t=500,Wt=56*1024;function We(e){return`_snt_retry_${e.slice(0,12)}`}var jt={push:()=>{},flush:()=>{},destroy:()=>{}};function St(e){var V,X,ge;if(typeof window=="undefined")return jt;let t=(V=e.flushIntervalMs)!=null?V:5e3,o=(X=e.maxBatchSize)!=null?X:20,p=(ge=e.maxRetrySize)!=null?ge:100,S=e.ingestUrl,d=e.apiKey,l=We(d),c=[],g=new Set,r=[],s=v=>{for(let T of v)i.delete(T),!g.has(T)&&(g.add(T),r.push(T));for(;r.length>$t;){let T=r.shift();T&&g.delete(T)}_e(v,l)},i=new Set,k=()=>{for(;c.length>p;){let v=c.shift();v&&i.delete(v.id)}},O=v=>{g.has(v.id)||i.has(v.id)||(i.add(v.id),c.push(v),k())},u=v=>{for(let T of v)g.has(T.id)||(i.add(T.id),c.push(T));k()},m=Ie(l,p);for(let v of m)O(v);let b=0,x=0,K=(v,T=!0)=>{if(v.length===0)return;let j=JSON.stringify(v),Q=v.map(H=>H.id),z;try{z=fetch(S,{method:"POST",keepalive:!0,body:j,headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`}})}catch(H){oe(v,p,l),u(v),x++,b=Date.now()+Y(x);return}let se=H=>{if(de(H)!=="retry"){if(!H.ok&&T){let re=v.filter(ie=>ie.eventType!=="pageview");if(re.length>0&&re.length<v.length){s(v.filter(ie=>ie.eventType==="pageview").map(ie=>ie.id)),K(re,!1);return}}s(Q),x=0,b=0;return}oe(v,p,l),u(v),x++,b=Date.now()+Y(x)};z instanceof Promise?z.then(se).catch(()=>{oe(v,p,l),u(v),x++,b=Date.now()+Y(x)}):se(z)},G=typeof TextEncoder!="undefined"?new TextEncoder:null,R=v=>G?G.encode(v).length:v.length,L=v=>{let T=[],j=2;for(let Q of v){let z=R(JSON.stringify(Q))+1;if(T.length>0&&j+z>Wt||T.length>=o)break;T.push(Q),j+=z}return T},B=()=>{try{if(Date.now()<b)return;for(;c.length>0&&!(Date.now()<b);){let v=c.filter(j=>!g.has(j.id));if(c.length=0,v.length===0)break;let T=L(v);if(T.length===0)break;T.length<v.length&&c.push(...v.slice(T.length)),K(T)}}catch(v){}},h=!0,I=null;I=setInterval(()=>{h&&B()},t);let Z=()=>{document.visibilityState==="hidden"&&B()},W=()=>{B()};return document.addEventListener("visibilitychange",Z),window.addEventListener("pagehide",W),{push(v){O(v),c.length>=o&&B()},flush:B,destroy(){h=!1,I!==null&&(clearInterval(I),I=null),document.removeEventListener("visibilitychange",Z),window.removeEventListener("pagehide",W),B()}}}var zt=200;function je(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Ht={send:()=>{},flush:()=>{},destroy:()=>{}};function ht(e){var R,L,B;if(typeof window=="undefined")return Ht;let t=(R=e.flushIntervalMs)!=null?R:5e3,o=(L=e.maxRetrySize)!=null?L:100,p=(B=e.maxPerFlush)!=null?B:5,S=je(e.apiKey),d=[],l=new Set,c=new Set,g=[],r=0,s=0,i=!1,k=h=>{for(l.delete(h.id),c.has(h.id)||(c.add(h.id),g.push(h.id));g.length>zt;){let I=g.shift();I&&c.delete(I)}_e([h.id],S)},O=h=>{oe([h],o,S),!c.has(h.id)&&!l.has(h.id)&&(l.add(h.id),d.push(h)),Date.now()>=r&&(s++,r=Date.now()+Y(s))},u=h=>{let I;try{I=fetch(e.url,{method:"POST",keepalive:!0,body:h.body,headers:e.headers})}catch(W){O(h);return}let Z=W=>{var X;let V=de(W);if(V==="retry"){O(h);return}V==="dropped"&&((X=e.onDrop)==null||X.call(e,h,W.status)),k(h),s=0,r=0};I instanceof Promise?I.then(Z).catch(()=>O(h)):Z(I)},m=()=>{try{if(i||Date.now()<r)return;let h=0;for(;d.length>0&&h<p&&!(Date.now()<r);){let I=d.shift();l.delete(I.id),!c.has(I.id)&&(h++,u(I))}}catch(h){}},b=Ie(S,o);for(let h of b)l.has(h.id)||(l.add(h.id),d.push(h));b.length>0&&oe(b,o,S);let x=setInterval(m,t),K=()=>{document.visibilityState==="hidden"&&m()},G=()=>m();return document.addEventListener("visibilitychange",K),window.addEventListener("pagehide",G),{send(h){if(!i&&!(c.has(h.id)||l.has(h.id))){if(Date.now()<r){oe([h],o,S),l.add(h.id),d.push(h);return}u(h)}},flush:m,destroy(){clearInterval(x),document.removeEventListener("visibilitychange",K),window.removeEventListener("pagehide",G),m(),i=!0}}}var Qt=1800*1e3;function Ce(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function vt(e=Qt,t){let o=new Map,p=`_snt_asgn${we(t)}_`,S=(r,s)=>`${p}${encodeURIComponent(r)}:${encodeURIComponent(s)}`,d=r=>{let s=r.slice(p.length),i=s.indexOf(":");if(i<0)return null;try{return{componentId:decodeURIComponent(s.slice(0,i)),segment:decodeURIComponent(s.slice(i+1))}}catch(k){return null}},l=()=>{try{let r=[];for(let s=0;s<localStorage.length;s++){let i=localStorage.key(s);i!=null&&i.startsWith(p)&&r.push(i)}return r}catch(r){return[]}},c=r=>r.assignedAt+(r.ttlMs&&r.ttlMs>0?r.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let r of l())try{let s=localStorage.getItem(r);if(!s)continue;let i=JSON.parse(s);if(c(i)){localStorage.removeItem(r);continue}let k=d(r);if(!k)continue;o.set(Ce(k.componentId,k.segment),i)}catch(s){}})(),{get(r,s){let i=o.get(Ce(r,s));return i?c(i)?(o.delete(Ce(r,s)),null):i:null},set(r,s,i){let k=Ce(r,s);o.set(k,i);try{localStorage.setItem(S(r,s),JSON.stringify(i))}catch(O){}},clear(){o.clear();for(let r of l())try{localStorage.removeItem(r)}catch(s){}}}}var ue="_snt_snap:",Jt=["low","medium","high"];function Se(e){try{let t=localStorage.getItem(ue+e);if(!t)return null;let o=JSON.parse(t);return!o||typeof o!="object"||o.v!==1||typeof o.persona!="string"||typeof o.band!="string"||!Jt.includes(o.band)||typeof o.slots!="object"||o.slots===null||Array.isArray(o.slots)||!(o.layoutOrder===null||Array.isArray(o.layoutOrder))||typeof o.savedAt!="number"||!(o.slotConfig===void 0||typeof o.slotConfig=="object"&&o.slotConfig!==null&&!Array.isArray(o.slotConfig))?null:o}catch(t){return null}}function he(e,t){try{localStorage.setItem(ue+e,JSON.stringify(t))}catch(o){}}function Vt(e){return"(function(){try{var r=localStorage.getItem("+JSON.stringify(ue+e).replace(/</g,"\\u003c")+');if(!r)return;var s=JSON.parse(r);if(!s||s.v!==1||typeof s.persona!=="string"||typeof s.band!=="string")return;var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",s.persona);d.setAttribute("data-sentient-confidence",s.band);}catch(e){}})();'}import{confidenceBand as Et}from"@sentientui/policy";import{confidenceBand as ze}from"@sentientui/policy";var He="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",kt="[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.",wt=!1,Te=!1;function Xt(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function xt(e){var r;let t=Ee({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),o=(r=t.getSessionId())!=null?r:"local",p=Xt(),S=import("@sentientui/core/local").then(s=>{let i=s;return i.LOCAL_ENGINE_AVAILABLE?(wt||(wt=!0,console.info(kt)),i):(Te||(Te=!0,console.error(He)),null)}).catch(()=>(Te||(Te=!0,console.error(He)),null)),d=null,l={low:.15,medium:.5,high:.85},c=(()=>{var i;if(e.initialPersona)return P({},e.initialPersona);let s=Se(e.apiKey||"local");return s?{persona:s.persona,confidence:(i=l[s.band])!=null?i:.15}:null})();function g(s){let i=document.documentElement;i.dataset.sentientPersona===void 0&&(i.dataset.sentientPersona=s.persona,i.dataset.sentientConfidence=ze(s.confidence))}return{isLocal:!0,async decide(s){var O,u,m;let i=await S;if(!i)return null;let k=i.createLocalEngine({sessionId:o,forcedPersona:p}).decide(s);return d=ce(P({},k),{layoutOrder:(u=(O=k.layoutOrder)!=null?O:d==null?void 0:d.layoutOrder)!=null?u:null,slots:P(P({},(m=d==null?void 0:d.slots)!=null?m:{}),k.slots)}),he(e.apiKey||"local",{v:1,persona:d.persona,band:ze(d.confidence),slots:d.slots,layoutOrder:d.layoutOrder,savedAt:Date.now()}),g(k),k},getSlotResult(s){var i,k,O;return(O=(k=d==null?void 0:d.slots[s])!=null?k:(i=e.initialSlots)==null?void 0:i[s])!=null?O:null},getSlotConfig(s){var i,k;return(k=(i=e.initialSlotConfig)==null?void 0:i[s])!=null?k:null},getSitePalette(){var s;return(s=e.initialPalette)!=null?s:null},reportSlots(){},getPersona(){let s=d!=null?d:c;return s?{persona:s.persona,confidence:s.confidence,band:ze(s.confidence)}:null},async assign(s,i){var u;let k=await S;return!k||!i||i.length===0?i!=null&&i[0]?{variantId:i[0],assignmentTtlMs:0}:null:{variantId:(u=k.createLocalEngine({sessionId:o,forcedPersona:p}).decide({components:[{id:s,variantIds:i}]}).assignments[s])!=null?u:i[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}var bt=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function Qe(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function qt(e,t){if(e===void 0||!bt.test(e))return!1;if(e==="*")return!0;let o=Qe(t);if(e.endsWith("/*")){let p=Qe(e.slice(0,-2));return o.startsWith(p==="/"?"/":`${p}/`)&&o!==p}return o===Qe(e)}var Rn=["none","sm","md","lg"],Bn=["start","center","end","stretch"],Dn=["start","center","end","between"],Pn=["sm","md","lg"],Ln=["normal","medium","bold"],Mn=["default","muted","accent"],Kn=["primary","secondary","ghost"],Nn=["left","center","right"],Gn=["auto","square","landscape","wide"],Fn=["cover","contain"],Un=[2,3,4],$n=[2,3,4],Wn=["default","raised"],jn=["none","sm","md","lg"],zn=["measure"],Hn=["input","textarea","select"],Qn=["text","email","number","tel"],Jn=5,Vn=8,Xn=64,qn=5,Yn=12,Zn=4,eo=500;function Yt(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.type==="form"?!0:Array.isArray(t.children)?t.children.some(Yt):!1}var Je="sentient-reveal",pe="sentient-revealed",Zt=240,Oe=!1;function en(){var e;Oe=!1,typeof document!="undefined"&&((e=document.getElementById(Je))==null||e.remove())}function tn(e){if(Oe||e.getElementById(Je)){Oe=!0;return}let t=e.createElement("style");t.id=Je,t.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${pe}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${pe}{animation:${pe} 240ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(t),Oe=!0}function nn(e,t={}){var S;let o=(S=t.doc)!=null?S:typeof document!="undefined"?document:void 0;if(!o||!(e instanceof Element)||(t.arm!==void 0&&e.setAttribute("data-sentient-arm",t.arm),t.persona!==void 0&&e.setAttribute("data-sentient-persona",t.persona),t.previous!==void 0&&t.previous===e.textContent))return!1;tn(o),e.classList.remove(pe),e.offsetWidth,e.classList.add(pe);let p=()=>{e.classList.remove(pe),e.removeEventListener("animationend",p)};return e.addEventListener("animationend",p),!0}function on(e,t,o,p){let S=[];{let c=!1,g=[],r=()=>{if(c)return;let s=Date.now();for(g.push(s);g.length>0&&s-g[0]>500;)g.shift();g.length>=3&&(c=!0,e("rage_click"))};t.addEventListener("click",r),S.push(()=>t.removeEventListener("click",r))}{let d=!1,l=c=>{if(d||!(c.target instanceof Node)||!t.contains(c.target)&&t!==c.target)return;d=!0;let g=typeof window!="undefined"?window.getSelection():null,r=g?g.toString().length:0;e("text_copy",{selectionLength:r})};document.addEventListener("copy",l),S.push(()=>document.removeEventListener("copy",l))}{let d=!1,l=!1,c=null,g=()=>{c!==null&&(clearTimeout(c),c=null)},r=()=>{d||!l||(g(),c=setTimeout(()=>{!d&&l&&(d=!0,e("scroll_hesitation"))},3e3))},s=()=>{g(),r()},i=O=>{for(let u of O)l=u.intersectionRatio>.3,l?r():g()},k=new IntersectionObserver(i,{threshold:[.3]});k.observe(t),window.addEventListener("scroll",s,{passive:!0}),S.push(()=>{k.disconnect(),window.removeEventListener("scroll",s),g()})}if((p==null?void 0:p.tabLoss)!==!1){let d=!1,l=o!=null?o:Date.now(),c=()=>{if(d||document.visibilityState!=="hidden")return;let g=Date.now()-l;g<15e3&&(d=!0,e("tab_loss",{timeOnPage:g}))};document.addEventListener("visibilitychange",c),S.push(()=>document.removeEventListener("visibilitychange",c))}return()=>{for(let d of S)d()}}function sn(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var It="https://api.sentient-ui.com/v1/events",$=new Map,_t=null;function Io(e,t){let o=$.get(e);o&&o.upgrade&&(o.reinit=t)}function rn(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var an=3;function Ve(){return xe()}function Ae(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function ln(){let e=new WeakMap,t=new Map,o=!1,p=(c,g,r)=>{let s=c.get(g);return r===null?s?!0:(c.set(g,new Set),!1):s?s.has(r)?!0:(s.add(r),!1):(c.set(g,new Set([r])),!1)},S=typeof window!="undefined"&&"event"in window,d=()=>{if(!S)return;let c=window.event;return typeof Event=="function"&&c instanceof Event?c:void 0},l=()=>{if(S){Promise.resolve().then(()=>{o=!1,t.clear()});return}let c=!1,g=()=>{c||(c=!0,o=!1,t.clear())};if(setTimeout(g,0),typeof MessageChannel=="function"){let r=new MessageChannel;r.port1.onmessage=()=>{r.port1.close(),r.port2.close(),g()},r.port2.postMessage(0)}};return{firedBefore(c,g){let r=d();if(r){let i=e.get(r);return i||(i=new Map,e.set(r,i)),p(i,c,g)}let s=p(t,c,g);return!s&&!o&&(o=!0,l()),s}}}var Ct=new Set;function cn(e,t,o){let p=typeof window=="undefined"?null:window.history;if(!p)return()=>{};let S=!1,d,l=()=>{if(S)return;let r=Ae();!r||r===d||(d=r,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),o(`${t}:${r}`))},c=[];for(let r of["pushState","replaceState"]){let s=p[r],i=function(...k){let O=s.apply(this,k);return l(),O};p[r]=i,c.push([r,s,i])}window.addEventListener("popstate",l);let g=Ae();return g&&Ct.has(`${t}:${g}`)?d=g:l(),()=>{if(!S){S=!0,window.removeEventListener("popstate",l);for(let[r,s,i]of c)p[r]===i&&(p[r]=s)}}}var ve={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function dn(){try{return Ne(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function Tt(e){return e.replace(/\/events\/?$/,"")}function Ot(){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")}function _o(e){var g;if(typeof window=="undefined")return;let t=e!=null?e:_t;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let o=$.get(t);if(!o){console.warn("[sentient] grantConsent() called before init()");return}let{config:p,upgrade:S,reinit:d}=o;if(!S){o.upgradeBlockedReason&&console.warn(o.upgradeBlockedReason);return}if(p.respectDoNotTrack!==!1&&Ot())return;let l=(d!=null?d:pn)(ce(P({},p),{consent:!0}));S(l);let c=(g=$.get(t))==null?void 0:g.dispose;$.set(t,{config:ce(P({},p),{consent:!0}),upgrade:null,dispose:c})}function un(e){var O;let t=e.preConsentBehavior==="statistical_winner",o=Tt((O=e.ingestUrl)!=null?O:It),p={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},S=new Map,d=new Map,l={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(u,m,b){if(!t)return Promise.resolve(null);let x=S.get(u);return x?Promise.resolve(x):Xe(d,u,async()=>{try{let K=new URLSearchParams({componentId:u});for(let B of m!=null?m:[])K.append("variantIds[]",B);let G=await fetch(`${o}/winner?${K.toString()}`,{headers:p});if(!G.ok)return m!=null&&m[0]?{variantId:m[0],assignmentTtlMs:0}:null;let L={variantId:(await G.json()).variantId,assignmentTtlMs:0};return S.set(u,L),L}catch(K){return m!=null&&m[0]?{variantId:m[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},c=!1,g=new Set,r=[],s=[],i={track:u=>l.track(u),goal:((u,m,b,x)=>l.goal(u,m,b,x)),componentGoal:(u,m,b)=>l.componentGoal(u,m,b),identify:u=>l.identify(u),getAssignment:(u,m)=>l.getAssignment(u,m),assign:(u,m,b,x)=>l.assign(u,m,b,x),decide:u=>l.decide(u),getSlotResult:u=>l.getSlotResult(u),isSlotDecided:u=>{var m,b;return(b=(m=l.isSlotDecided)==null?void 0:m.call(l,u))!=null?b:!0},getSlotConfig:u=>l.getSlotConfig(u),getSitePalette:()=>l.getSitePalette(),reportSlots:(u,m)=>l.reportSlots(u,m),requestSlots:(u,m)=>{var b;return c?(b=l.requestSlots)==null?void 0:b.call(l,u,m):r.push([u,m])},decideSlots:u=>{var m;return c?(m=l.decideSlots)==null?void 0:m.call(l,u):s.push(...u)},cancelSlots:u=>{var b;if(c)return(b=l.cancelSlots)==null?void 0:b.call(l,u);let m=new Set(u);for(let x of r)x[0]=x[0].filter(K=>!m.has(K));s=s.filter(x=>!m.has(x.id))},onSlotsChanged:u=>(g.add(u),()=>{g.delete(u)}),getPersona:()=>l.getPersona(),fetchWeights:()=>l.fetchWeights(),getGraph:()=>l.getGraph(),dispose:()=>l.dispose(),destroy:()=>l.destroy()};function k(u){var m,b,x;l=u,c=!0,(m=u.onSlotsChanged)==null||m.call(u,()=>g.forEach(K=>K()));for(let[K,G]of r.splice(0))K.length>0&&((b=u.requestSlots)==null||b.call(u,K,G));s.length>0&&((x=u.decideSlots)==null||x.call(u,s.splice(0)))}return{proxy:i,setInner:k}}function Xe(e,t,o){let p=e.get(t);if(p)return p;let S=(async()=>{try{return await o()}finally{e.delete(t)}})();return e.set(t,S),S}function pn(e){var nt,ot,st,rt,it,at,lt,ct,dt,ut;if(typeof window=="undefined")return ve;_t=e.apiKey||"local";let t=$.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(n){}let o=e.respectDoNotTrack!==!1&&Ot(),p=e.consent===!1||o,S=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!S&&e.localMode!==!1)return $.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."}),p?ve:xt(e);if(p){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."),$.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."}),ve;let{proxy:n,setInner:a}=un(e);return $.set(e.apiKey,{config:e,upgrade:o?null:a}),n}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."),ve;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),ve;let d=(nt=e.ingestUrl)!=null?nt:It,l=Date.now(),c=Ee({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),g=vt(void 0,e.apiKey),r=St({ingestUrl:d,apiKey:e.apiKey}),s=Tt(d),i={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},k=new Set,O=ht({url:`${s}/goals`,apiKey:e.apiKey,headers:i,onDrop:(n,a)=>{if(!e.debug){if(k.has(a))return;k.add(a)}console.warn(`[sentient] goal dropped (HTTP ${a}) \u2014 this will not be retried. `+(a===400?"The session was not found: call init() and let the session upsert complete before firing goals.":a===401||a===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),n)}}),u=Le((ot=navigator.userAgent)!=null?ot:""),m=window.location.origin,b=Me((st=document.referrer)!=null?st:"",m),x=(rt=e.sessionSegment)!=null?rt:`${u}:${b}`,K=new Map,G=new Map,R=new Map,L=new Set,B=new Map,h=null,I=null,Z=new Set,W=new Set,V=new Map,X=null,ge=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,v=new Set,T=new Set,j=new Set,Q=new Map,z=null,se=new Set,H=new Map,re=null,ie=2,qe=new Map,Re=!1,Ye=(n,a,f)=>{var y;let w=new Set,_=1;for(let E of n){a.delete(E);let C=((y=qe.get(E))!=null?y:0)+1;qe.set(E,C),C<=ie&&(w.add(E),C>_&&(_=C))}w.size>0&&setTimeout(()=>{Re||f(w)},Y(_))},Ze=n=>{for(let a of n)R.has(a.id)||R.set(a.id,ke(a))};if(e.initialSlots)for(let[n,a]of Object.entries(e.initialSlots))R.set(n,a),L.add(n);if(e.initialSlotConfig)for(let[n,a]of Object.entries(e.initialSlotConfig))B.set(n,a);e.initialPalette&&(h=e.initialPalette);let ee=Se(e.apiKey);if(ee){for(let[n,a]of Object.entries(ee.slots))R.has(n)||R.set(n,a);for(let[n,a]of Object.entries((it=ee.slotConfig)!=null?it:{}))B.has(n)||B.set(n,a);!h&&ee.palette&&(h=ee.palette)}let et={low:.15,medium:.5,high:.85};if(e.initialPersona)I=P({},e.initialPersona);else{let n=document.documentElement.dataset;n.sentientPersona?I={persona:n.sentientPersona,confidence:(lt=et[(at=n.sentientConfidence)!=null?at:"low"])!=null?lt:.15}:ee&&(I={persona:ee.persona,confidence:(ct=et[ee.band])!=null?ct:.15})}if(e.initialAssignments)for(let[n,a]of Object.entries(e.initialAssignments))g.set(n,x,{variantId:a,assignedAt:Date.now(),segment:x,confidence:1});let te=Promise.resolve(),tt=c.getSessionId();if(tt){let n=Ke((dt=document.referrer)!=null?dt:""),{utmParams:a,clickIds:f}=dn(),w=P(P(P(P({sessionId:tt,deviceClass:u,trafficSource:b,referrerDomain:n,utmParams:a,clickIds:f,timeOfDay:Ge(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:c.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Pe((ut=navigator.userAgent)!=null?ut:"")},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}:{}),_=async()=>{for(let y=0;;y++){try{let E=await fetch(`${s}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(w),headers:i});if(E.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(E.ok||de(E)==="dropped")return}catch(E){}if(y>=an){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(E=>setTimeout(E,Y(y+1)))}};try{te=_()}catch(y){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:r});let At=ln(),ae=null,Be=!1,N={goal(n,a={},f=1,w=0){var ne,fe,me,ye,le,A,q;let _=c.getSessionId();if(!_)return;let y=rn(a)?a:{metadata:a},E=[n,(ne=y.externalId)!=null?ne:"",(fe=y.stepIndex)!=null?fe:w,(me=y.weight)!=null?me:f].join("\0"),C=y.value!==void 0?`${y.value}\0${(ye=y.currency)!=null?ye:""}`:null;if(At.firedBefore(E,C)){e.debug&&console.log(`[sentient] goal("${n}") already recorded for this action \u2014 not sent twice`);return}let M=Ve(),F={sessionId:_,name:n,metadata:(le=y.metadata)!=null?le:{},weight:(A=y.weight)!=null?A:f,stepIndex:(q=y.stepIndex)!=null?q:w,goalId:M,value:y.value,currency:y.currency,externalId:y.externalId};e.debug&&console.log("[sentient] goal",F);let U={id:M,body:JSON.stringify(F)};te.then(()=>O.send(U))},componentGoal(n,a,f){var M,F,U;let w=c.getSessionId();if(!w)return;let _=g.get(n,x),y=_?null:(M=R.get(n))!=null?M:null;if(!_&&y===null){e.debug&&console.warn(`[sentient] componentGoal("${n}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}if(!_&&!L.has(n)){e.debug&&console.warn(`[sentient] componentGoal("${n}"): slot not decided this session \u2014 not attributed`);return}let E=_?_.variantId:Ue(y),C={id:Ve(),sessionId:w,projectId:e.apiKey,componentId:n,variantId:E,eventType:"goal_achieved",goalType:a,payload:P({reward:(F=f==null?void 0:f.reward)!=null?F:1,goalValue:f==null?void 0:f.value,currency:f==null?void 0:f.currency},(U=f==null?void 0:f.metadata)!=null?U:{}),timestamp:Date.now(),timeInSession:Date.now()-l,path:Ae()};e.debug&&console.log("[sentient] componentGoal",C),te.then(()=>r.push(C))},identify(n){let a=c.getSessionId();a&&te.then(()=>{fetch(`${s}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:a,userId:n,ephemeral:c.isEphemeral()}),headers:i}).catch(()=>{})})},track(n){let a=c.getSessionId();if(!a||n.eventType==="variant_assigned"&&R.get(n.componentId)!==void 0&&!L.has(n.componentId)&&!g.get(n.componentId,x))return;let f=ce(P({path:Ae()},n),{id:Ve(),sessionId:a,timestamp:Date.now(),timeInSession:Date.now()-l});e.debug&&console.log("[sentient] track",f),te.then(()=>r.push(f))},getAssignment(n,a){return g.get(n,a)},async assign(n,a,f,w){let _=c.getSessionId();if(!_)return null;let y=g.get(n,x);if(y&&(a!=null&&a.length||y.content!==void 0)){let E=y.ttlMs&&y.ttlMs>0?Math.max(0,y.assignedAt+y.ttlMs-Date.now()):0;return{variantId:y.variantId,assignmentTtlMs:E,content:y.content}}return Xe(K,n,async()=>{await te;try{let E={sessionId:_,componentId:n,variantIds:a};w!==void 0?E.agentDataByVariant=w:f!==void 0&&(E.agentData=f);let C=await fetch(`${s}/assign`,{method:"POST",body:JSON.stringify(E),headers:i});if(!C.ok)return null;let M=await C.json();return g.set(n,x,P({variantId:M.variantId,assignedAt:Date.now(),segment:x,confidence:1,content:M.content},M.assignmentTtlMs&&M.assignmentTtlMs>0?{ttlMs:M.assignmentTtlMs}:{})),M}catch(E){return null}})},async decide(n){var y,E;let a=c.getSessionId();if(!a)return null;let f=(y=n.slots)!=null?y:[],w={sessionId:a};n.sections&&n.sections.length>0&&(w.sections=n.sections.map(C=>({id:C}))),w.components=(E=n.components)!=null?E:[],f.length>0&&(w.slots=f.map(Fe)),n.slotsFrom==="registry"&&(w.slotsFrom="registry",n.registrySlotIds&&(w.registrySlotIds=n.registrySlotIds),n.bootstrap===!1&&(w.bootstrap=!1)),n.v&&(w.v=n.v),typeof n.pp=="number"&&(w.pp=n.pp),e.persona&&(w.persona=e.persona);let _=JSON.stringify(w);return Xe(G,_,async()=>{var C,M,F,U,ne,fe,me,ye;await te;try{let le=await fetch(`${s}/decide`,{method:"POST",body:_,headers:i});if(!le.ok)return Ze(f),null;let A=await le.json(),q={};for(let D of f){let J=(C=A.slots)==null?void 0:C[D.id];if(J!==void 0){q[D.id]=J,R.set(D.id,J),L.add(D.id);continue}let pt=R.get(D.id);if(pt!==void 0)q[D.id]=pt;else{let gt=ke(D);q[D.id]=gt,R.set(D.id,gt)}}if(A.slots)for(let[D,J]of Object.entries(A.slots))D in q||(q[D]=J,R.set(D,J),L.add(D));let Rt=I!=null&&I.persona!=="unknown";A.persona&&!(A.persona==="unknown"&&Rt)?I={persona:A.persona,confidence:(M=A.confidence)!=null?M:0}:I||(I={persona:"unknown",confidence:0});for(let[D,J]of Object.entries((F=A.assignments)!=null?F:{}))g.set(D,x,{variantId:J,assignedAt:Date.now(),segment:x,confidence:1});if(A.slotConfig)for(let[D,J]of Object.entries(A.slotConfig))B.set(D,J);A.palette&&(h=A.palette);for(let D of(U=n.registrySlotIds)!=null?U:[])(ne=A.slotConfig)!=null&&ne[D]||(B.delete(D),R.delete(D),L.delete(D));return he(e.apiKey,P(P({v:1,persona:I.persona,band:Et(I.confidence),slots:Object.fromEntries(R),layoutOrder:(fe=A.layoutOrder)!=null?fe:null,savedAt:Date.now()},B.size>0?{slotConfig:Object.fromEntries(B)}:{}),h?{palette:h}:{})),P(P(P(P({layoutOrder:(me=A.layoutOrder)!=null?me:null,assignments:(ye=A.assignments)!=null?ye:{},slots:q,persona:I.persona,confidence:I.confidence},A.slotConfig?{slotConfig:A.slotConfig}:{}),A.goals?{goals:A.goals}:{}),A.sectionMap?{sectionMap:A.sectionMap}:{}),A.palette?{palette:A.palette}:{})}catch(le){return Ze(f),null}})},getSlotResult(n){var a;return(a=R.get(n))!=null?a:null},isSlotDecided(n){return L.has(n)},getSlotConfig(n){var a;return(a=B.get(n))!=null?a:null},reportSlots(n,a){for(let f of n)if(!(typeof f!="string"||f.length===0)){if(!ge.test(f)){sn()&&!v.has(f)&&(v.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(!Z.has(f)){Z.add(f),W.add(f);let w=a==null?void 0:a[f];if(typeof w=="string"){let _=w.replace(/\s+/g," ").trim().slice(0,400);_!==""&&V.set(f,_)}}}W.size===0||X!=null||(X=setTimeout(()=>{X=null;let f=[...W];W.clear();for(let w=0;w<f.length;w+=20){let _=f.slice(w,w+20),y={};for(let E of _){let C=V.get(E);C!==void 0&&(y[E]=C,V.delete(E))}fetch(`${s}/slots/observed`,{method:"POST",headers:i,body:JSON.stringify(P({slotIds:_},Object.keys(y).length>0?{baselineTexts:y}:{}))}).catch(()=>{})}},1e3))},requestSlots(n,a){for(let f of n)j.has(f)||(j.add(f),ge.test(f)?Q.set(f,a==null?void 0:a[f]):N.reportSlots([f]));Q.size===0||z!=null||(z=setTimeout(()=>{z=null;let f=[...Q];Q.clear();for(let w=0;w<f.length;w+=50){let _=f.slice(w,w+50);N.decide({slotsFrom:"registry",registrySlotIds:_.map(([y])=>y),bootstrap:!1}).then(y=>{var E;if(y){let C={},M=[];for(let[F,U]of _)(E=y.slotConfig)!=null&&E[F]||(M.push(F),U&&(C[F]=U));M.length>0&&N.reportSlots(M,C)}else Ye(_.map(([C])=>C),j,C=>{var F;let M={};for(let[U,ne]of _)C.has(U)&&ne&&(M[U]=ne);(F=N.requestSlots)==null||F.call(N,[...C],M)});T.forEach(C=>C())})}},0))},decideSlots(n){for(let a of n)se.has(a.id)||(se.add(a.id),H.set(a.id,a));H.size===0||re!=null||(re=setTimeout(()=>{re=null;let a=[...H.values()];H.clear();for(let f=0;f<a.length;f+=30){let w=a.slice(f,f+30);N.decide({slots:w}).then(_=>{_||Ye(w.map(y=>y.id),se,y=>{var E;return(E=N.decideSlots)==null?void 0:E.call(N,w.filter(C=>y.has(C.id)))}),T.forEach(y=>y())})}},0))},cancelSlots(n){for(let a of n)Q.delete(a)&&j.delete(a),H.delete(a)&&se.delete(a)},onSlotsChanged(n){return T.add(n),()=>{T.delete(n)}},getSitePalette(){return h},getPersona(){return I?{persona:I.persona,confidence:I.confidence,band:Et(I.confidence)}:null},async fetchWeights(){var n;try{let a=await fetch(`${s}/weights`,{headers:i});return a.ok?(n=(await a.json()).components)!=null?n:[]:[]}catch(a){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var n;ae==null||ae(),Be=!0,Re=!0,r.destroy(),O.destroy(),((n=$.get(e.apiKey))==null?void 0:n.dispose)===N.dispose&&$.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var n;ae==null||ae(),Be=!0,Re=!0,r.destroy(),O.destroy(),c.destroy(),g.clear(),((n=$.get(e.apiKey))==null?void 0:n.dispose)===N.dispose&&$.delete(e.apiKey);try{localStorage.removeItem(ue+e.apiKey),localStorage.removeItem(We(e.apiKey)),localStorage.removeItem(je(e.apiKey))}catch(a){}e.debug&&console.log("[sentient] destroyed")}};if($.set(e.apiKey,{config:e,upgrade:null,dispose:N.dispose}),ae=cn(N,e.apiKey,n=>{te.then(()=>{Be||Ct.add(n)})}),e.debug){let n=window;n.__sentient&&(n.__sentient.client=N)}return N}export{ue as a,Se as b,he as c,Vt as d,He as e,kt as f,bt as g,qt as h,Rn as i,Bn as j,Dn as k,Pn as l,Ln as m,Mn as n,Kn as o,Nn as p,Gn as q,Fn as r,Un as s,$n as t,Wn as u,jn as v,zn as w,Hn as x,Qn as y,Jn as z,Vn as A,Xn as B,qn as C,Yn as D,Zn as E,eo as F,Yt as G,Zt as H,en as I,nn as J,on as K,Io as L,Ot as M,_o as N,pn as O};
2
+ //# sourceMappingURL=chunk-SFNOFZUH.mjs.map