@sentientui/core 0.32.0 → 0.34.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 (52) hide show
  1. package/dist/chunk-3FKD44SF.mjs +2 -0
  2. package/dist/chunk-3FKD44SF.mjs.map +1 -0
  3. package/dist/chunk-DGRAS5VP.mjs +2 -0
  4. package/dist/chunk-DGRAS5VP.mjs.map +1 -0
  5. package/dist/{index-CgkImSaM.d.ts → index-C2EOL-_c.d.cts} +43 -4
  6. package/dist/{index-COl_pfNm.d.cts → index-DrMXbLKP.d.ts} +43 -4
  7. package/dist/index-engagement.js +1 -1
  8. package/dist/index-engagement.js.map +1 -1
  9. package/dist/index-engagement.mjs +1 -1
  10. package/dist/index-engagement.mjs.map +1 -1
  11. package/dist/index-graph.d.cts +6 -4
  12. package/dist/index-graph.d.ts +6 -4
  13. package/dist/index-graph.js +1 -1
  14. package/dist/index-graph.js.map +1 -1
  15. package/dist/index-graph.mjs +1 -1
  16. package/dist/index-graph.mjs.map +1 -1
  17. package/dist/index-local.d.cts +4 -2
  18. package/dist/index-local.d.ts +4 -2
  19. package/dist/index-region.d.cts +40 -0
  20. package/dist/index-region.d.ts +40 -0
  21. package/dist/index-region.js +2 -0
  22. package/dist/index-region.js.map +1 -0
  23. package/dist/index-region.mjs +2 -0
  24. package/dist/index-region.mjs.map +1 -0
  25. package/dist/index-server.d.cts +74 -3
  26. package/dist/index-server.d.ts +74 -3
  27. package/dist/index-server.js +1 -1
  28. package/dist/index-server.js.map +1 -1
  29. package/dist/index-server.mjs +1 -1
  30. package/dist/index-server.mjs.map +1 -1
  31. package/dist/index-style-sample.d.cts +12 -0
  32. package/dist/index-style-sample.d.ts +12 -0
  33. package/dist/index-style-sample.js +2 -0
  34. package/dist/index-style-sample.js.map +1 -0
  35. package/dist/index-style-sample.mjs +2 -0
  36. package/dist/index-style-sample.mjs.map +1 -0
  37. package/dist/index.d.cts +4 -2
  38. package/dist/index.d.ts +4 -2
  39. package/dist/index.js +1 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/index.mjs +1 -1
  42. package/dist/region-skeleton-CQ4yhVw1.d.cts +56 -0
  43. package/dist/region-skeleton-CQ4yhVw1.d.ts +56 -0
  44. package/dist/session-meta-CWGtzFOQ.d.ts +226 -0
  45. package/dist/session-meta-KwDqU9a8.d.cts +226 -0
  46. package/dist/style-vocabulary-BqviEw9O.d.cts +285 -0
  47. package/dist/style-vocabulary-BqviEw9O.d.ts +285 -0
  48. package/package.json +11 -1
  49. package/dist/chunk-EVYMV2C6.mjs +0 -2
  50. package/dist/chunk-EVYMV2C6.mjs.map +0 -1
  51. package/dist/session-meta-DydKfQiR.d.cts +0 -416
  52. package/dist/session-meta-DydKfQiR.d.ts +0 -416
@@ -0,0 +1,2 @@
1
+ var e=40,t=120,o=300;export{e as a,t as b,o as c};
2
+ //# sourceMappingURL=chunk-3FKD44SF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/region-skeleton.ts"],"sourcesContent":["// Region skeleton (spec 2026-09-23 §4.1). The generator used to see a region\n// as its flattened textContent — \"Get in touch WhatsApp photos\" — and wrote a\n// heading + paragraph for what were two buttons. The skeleton is the region's\n// STRUCTURE: every element that carries text, its role, link, emphasis and\n// colour, so generation can write per-element edits and both SDKs can apply\n// them to the developer's own elements.\n//\n// Only the wrapped region is ever read (same scope as baselineText); query\n// strings and hashes never leave the page (tracking ids, sometimes PII).\n\nexport const MAX_SKELETON_NODES = 40;\nexport const MAX_SKELETON_LEAVES = 120;\nexport const MAX_SKELETON_TEXT = 300;\n\nexport type SkeletonRole = 'action' | 'heading' | 'text' | 'label' | 'image';\nexport type SkeletonNode = {\n tag: string;\n role: SkeletonRole;\n level?: 1 | 2 | 3 | 4 | 5 | 6;\n text: string; // joined normalized leaves of this node (image: alt)\n classes: string; // class attribute, whitespace-normalized\n filled?: boolean; // action only\n href?: string; // action only; same-origin → path; else origin+path; never query/hash\n src?: string; // image only; same rule\n color: string; // computed `color`\n group: number; // index of the node owner's parentElement among distinct parents\n restylable: boolean; // snippet: always true; React: set by annotateSkeletonForReact\n};\nexport type RegionSkeleton = {\n v: 1;\n root: { tag: string; classes: string; ambientBg: string | null; ambientBgAlt?: string; ambientText: string };\n nodes: SkeletonNode[];\n leaves: string[]; // normalized non-blank text leaves, document order\n leafToNode: number[]; // leaves[i] belongs to nodes[leafToNode[i]]\n fp: string;\n};\nexport type ArmEdits = {\n nodes: Record<string, { text?: string; hidden?: true; like?: number }>;\n order?: Record<string, number[]>;\n};\n/** What the requesting page can render for one slot (decide `render` field). */\nexport type RenderCaps = {\n fp?: string; // omitted = unknown (SSR): server assumes the stored skeleton\n forms: boolean; // a form-arm handler exists\n compose: boolean; // phase 2; always false in phase 1\n authored?: string[]; // phase 3\n content?: boolean; // false = a content arm cannot land (0 or >1 text leaves). Omitted = true.\n children?: boolean; // phase 3: false = no children to render, the first authored key is the baseline. Omitted = true.\n};\n/** How the server serves an `edits` arm (SlotConfigEntry.edits). */\nexport type ServedEdits = { edits: ArmEdits; fp: string; leafToNode: number[] };\n\n// DOM capture lives in ./region-capture.ts, exported from\n// `@sentientui/core/region`: only React and the snippet need it, and it would\n// otherwise ship in the lean entry every plain-JS install downloads.\n"],"mappings":"AAUO,IAAMA,EAAqB,GACrBC,EAAsB,IACtBC,EAAoB","names":["MAX_SKELETON_NODES","MAX_SKELETON_LEAVES","MAX_SKELETON_TEXT"]}
@@ -0,0 +1,2 @@
1
+ import{a as xe,c as Ke,e as Ge,j as Fe,k as $e,l as Ue,n as je,o as We,r as Ve,s as Ee,u as ze}from"./chunk-2NVSFI4V.mjs";import{a as T,b as pe}from"./chunk-TMCGHANO.mjs";function Ie(){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 Nt="_snt_uid",Kt=365,_e="_snt_uid";function Gt(){return Ie()}function vt(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Ft(e,t,o){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${o}; SameSite=strict; path=/`}catch(p){}}function He(e){try{return localStorage.getItem(e)}catch(t){return null}}function kt(e,t){try{return localStorage.setItem(e,t),!0}catch(o){return!1}}function bt(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function $t(e,t){try{return sessionStorage.setItem(e,t),!0}catch(o){return!1}}function Ut(e){try{sessionStorage.removeItem(e)}catch(t){}}function jt(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 Wt(e){try{localStorage.removeItem(e)}catch(t){}}function Vt(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var zt={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function Ce(e){var c,f,w,v,D,V,P;if(typeof window=="undefined")return zt;let t=xe(e==null?void 0:e.apiKey),o=(c=e==null?void 0:e.cookieName)!=null?c:Ke(e==null?void 0:e.apiKey),p=`${_e}${t}`,h=`${_e}_tomb${t}`,r=((f=e==null?void 0:e.cookieTTLDays)!=null?f:Kt)*24*60*60,d=K=>K&&K.length>0?K:null,g=()=>{var K,M;return t&&!(e!=null&&e.cookieName)&&He(h)===null?(M=(K=d(vt(Nt)))!=null?K:d(He(_e)))!=null?M:d(bt(_e)):null},i=(P=(V=(D=(v=(w=d(vt(o)))!=null?w:d(He(p)))!=null?v:d(bt(p)))!=null?D:g())!=null?V:d(e==null?void 0:e.ssrSessionId))!=null?P:Gt();Ft(o,i,r);let s=kt(p,i),l=jt(o),I=s?!1:$t(p,i),R=!s&&!l&&!I;return{getSessionId:()=>i,isEphemeral:()=>R,destroy:()=>{i=null,Vt(o),Wt(p),Ut(p),t&&!(e!=null&&e.cookieName)&&kt(h,"1")}}}function re(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function fe(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 Re(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 ce(e,t,o){try{let p=(()=>{try{let u=localStorage.getItem(o);if(!u)return[];let r=JSON.parse(u);return Array.isArray(r)?r:[]}catch(u){return[]}})(),h=new Map;for(let u of p)h.set(u.id,u);for(let u of e)h.set(u.id,u);localStorage.setItem(o,JSON.stringify([...h.values()].slice(-t)))}catch(p){}}function Oe(e,t){try{let o=localStorage.getItem(t);if(!o)return;let p=JSON.parse(o);if(!Array.isArray(p))return;let h=new Set(e),u=p.filter(r=>!h.has(r.id));if(u.length===p.length)return;u.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(u))}catch(o){}}var Ht=500,Jt=56*1024;function Je(e){return`_snt_retry_${e.slice(0,12)}`}var Qt={push:()=>{},flush:()=>{},destroy:()=>{}};function wt(e){var Y,oe,ge;if(typeof window=="undefined")return Qt;let t=(Y=e.flushIntervalMs)!=null?Y:5e3,o=(oe=e.maxBatchSize)!=null?oe:20,p=(ge=e.maxRetrySize)!=null?ge:100,h=e.ingestUrl,u=e.apiKey,r=Je(u),d=[],g=new Set,i=[],s=b=>{for(let A of b)l.delete(A),!g.has(A)&&(g.add(A),i.push(A));for(;i.length>Ht;){let A=i.shift();A&&g.delete(A)}Oe(b,r)},l=new Set,I=()=>{for(;d.length>p;){let b=d.shift();b&&l.delete(b.id)}},R=b=>{g.has(b.id)||l.has(b.id)||(l.add(b.id),d.push(b),I())},c=b=>{for(let A of b)g.has(A.id)||(l.add(A.id),d.push(A));I()},f=Re(r,p);for(let b of f)R(b);let w=0,v=0,D=(b,A=!0)=>{if(b.length===0)return;let se=JSON.stringify(b),ie=b.map(Z=>Z.id),Q;try{Q=fetch(h,{method:"POST",keepalive:!0,body:se,headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`}})}catch(Z){ce(b,p,r),c(b),v++,w=Date.now()+re(v);return}let Se=Z=>{if(fe(Z)!=="retry"){if(!Z.ok&&A){let ae=b.filter(X=>X.eventType!=="pageview");if(ae.length>0&&ae.length<b.length){s(b.filter(X=>X.eventType==="pageview").map(X=>X.id)),D(ae,!1);return}}s(ie),v=0,w=0;return}ce(b,p,r),c(b),v++,w=Date.now()+re(v)};Q instanceof Promise?Q.then(Se).catch(()=>{ce(b,p,r),c(b),v++,w=Date.now()+re(v)}):Se(Q)},V=typeof TextEncoder!="undefined"?new TextEncoder:null,P=b=>V?V.encode(b).length:b.length,K=b=>{let A=[],se=2;for(let ie of b){let Q=P(JSON.stringify(ie))+1;if(A.length>0&&se+Q>Jt||A.length>=o)break;A.push(ie),se+=Q}return A},M=()=>{try{if(Date.now()<w)return;for(;d.length>0&&!(Date.now()<w);){let b=d.filter(se=>!g.has(se.id));if(d.length=0,b.length===0)break;let A=K(b);if(A.length===0)break;A.length<b.length&&d.push(...b.slice(A.length)),D(A)}}catch(b){}},k=!0,L=null;L=setInterval(()=>{k&&M()},t);let G=()=>{document.visibilityState==="hidden"&&M()},ne=()=>{M()};return document.addEventListener("visibilitychange",G),window.addEventListener("pagehide",ne),{push(b){R(b),d.length>=o&&M()},flush:M,destroy(){k=!1,L!==null&&(clearInterval(L),L=null),document.removeEventListener("visibilitychange",G),window.removeEventListener("pagehide",ne),M()}}}var qt=200;function Qe(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Xt={send:()=>{},flush:()=>{},destroy:()=>{}};function xt(e){var P,K,M;if(typeof window=="undefined")return Xt;let t=(P=e.flushIntervalMs)!=null?P:5e3,o=(K=e.maxRetrySize)!=null?K:100,p=(M=e.maxPerFlush)!=null?M:5,h=Qe(e.apiKey),u=[],r=new Set,d=new Set,g=[],i=0,s=0,l=!1,I=k=>{for(r.delete(k.id),d.has(k.id)||(d.add(k.id),g.push(k.id));g.length>qt;){let L=g.shift();L&&d.delete(L)}Oe([k.id],h)},R=k=>{ce([k],o,h),!d.has(k.id)&&!r.has(k.id)&&(r.add(k.id),u.push(k)),Date.now()>=i&&(s++,i=Date.now()+re(s))},c=k=>{let L;try{L=fetch(e.url,{method:"POST",keepalive:!0,body:k.body,headers:e.headers})}catch(ne){R(k);return}let G=ne=>{var oe;let Y=fe(ne);if(Y==="retry"){R(k);return}Y==="dropped"&&((oe=e.onDrop)==null||oe.call(e,k,ne.status)),I(k),s=0,i=0};L instanceof Promise?L.then(G).catch(()=>R(k)):G(L)},f=()=>{try{if(l||Date.now()<i)return;let k=0;for(;u.length>0&&k<p&&!(Date.now()<i);){let L=u.shift();r.delete(L.id),!d.has(L.id)&&(k++,c(L))}}catch(k){}},w=Re(h,o);for(let k of w)r.has(k.id)||(r.add(k.id),u.push(k));w.length>0&&ce(w,o,h);let v=setInterval(f,t),D=()=>{document.visibilityState==="hidden"&&f()},V=()=>f();return document.addEventListener("visibilitychange",D),window.addEventListener("pagehide",V),{send(k){if(!l&&!(d.has(k.id)||r.has(k.id))){if(Date.now()<i){ce([k],o,h),r.add(k.id),u.push(k);return}c(k)}},flush:f,destroy(){clearInterval(v),document.removeEventListener("visibilitychange",D),window.removeEventListener("pagehide",V),f(),l=!0}}}var Yt=1800*1e3;function Ae(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Et(e=Yt,t){let o=new Map,p=`_snt_asgn${xe(t)}_`,h=(i,s)=>`${p}${encodeURIComponent(i)}:${encodeURIComponent(s)}`,u=i=>{let s=i.slice(p.length),l=s.indexOf(":");if(l<0)return null;try{return{componentId:decodeURIComponent(s.slice(0,l)),segment:decodeURIComponent(s.slice(l+1))}}catch(I){return null}},r=()=>{try{let i=[];for(let s=0;s<localStorage.length;s++){let l=localStorage.key(s);l!=null&&l.startsWith(p)&&i.push(l)}return i}catch(i){return[]}},d=i=>i.assignedAt+(i.ttlMs&&i.ttlMs>0?i.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let i of r())try{let s=localStorage.getItem(i);if(!s)continue;let l=JSON.parse(s);if(d(l)){localStorage.removeItem(i);continue}let I=u(i);if(!I)continue;o.set(Ae(I.componentId,I.segment),l)}catch(s){}})(),{get(i,s){let l=o.get(Ae(i,s));return l?d(l)?(o.delete(Ae(i,s)),null):l:null},set(i,s,l){let I=Ae(i,s);o.set(I,l);try{localStorage.setItem(h(i,s),JSON.stringify(l))}catch(R){}},clear(){o.clear();for(let i of r())try{localStorage.removeItem(i)}catch(s){}}}}var ye="_snt_snap:",Zt=["low","medium","high"];function ve(e){try{let t=localStorage.getItem(ye+e);if(!t)return null;let o=JSON.parse(t);if(!o||typeof o!="object"||o.v!==1||typeof o.persona!="string"||typeof o.band!="string"||!Zt.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)))return null;let p=o.vocabulary;return p!==void 0&&(typeof p!="object"||p===null||!Array.isArray(p.entries)||!Array.isArray(p.images))&&delete o.vocabulary,o}catch(t){return null}}function ke(e,t){try{localStorage.setItem(ye+e,JSON.stringify(t))}catch(o){}}function en(e){return"(function(){try{var r=localStorage.getItem("+JSON.stringify(ye+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 Ot}from"@sentientui/policy";import{confidenceBand as qe}from"@sentientui/policy";var Xe="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",_t="[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.",It=!1,Te=!1;function tn(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Ct(e){var i;let t=Ce({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),o=(i=t.getSessionId())!=null?i:"local",p=tn(),h=import("@sentientui/core/local").then(s=>{let l=s;return l.LOCAL_ENGINE_AVAILABLE?(It||(It=!0,console.info(_t)),l):(Te||(Te=!0,console.error(Xe)),null)}).catch(()=>(Te||(Te=!0,console.error(Xe)),null)),u=null,r={low:.15,medium:.5,high:.85},d=(()=>{var l;if(e.initialPersona)return T({},e.initialPersona);let s=ve(e.apiKey||"local");return s?{persona:s.persona,confidence:(l=r[s.band])!=null?l:.15}:null})();function g(s){let l=document.documentElement;l.dataset.sentientPersona===void 0&&(l.dataset.sentientPersona=s.persona,l.dataset.sentientConfidence=qe(s.confidence))}return{isLocal:!0,async decide(s){var R,c,f;let l=await h;if(!l)return null;let I=l.createLocalEngine({sessionId:o,forcedPersona:p}).decide(s);return u=pe(T({},I),{layoutOrder:(c=(R=I.layoutOrder)!=null?R:u==null?void 0:u.layoutOrder)!=null?c:null,slots:T(T({},(f=u==null?void 0:u.slots)!=null?f:{}),I.slots)}),ke(e.apiKey||"local",{v:1,persona:u.persona,band:qe(u.confidence),slots:u.slots,layoutOrder:u.layoutOrder,savedAt:Date.now()}),g(I),I},getSlotResult(s){var l,I,R;return(R=(I=u==null?void 0:u.slots[s])!=null?I:(l=e.initialSlots)==null?void 0:l[s])!=null?R:null},getSlotConfig(s){var l,I;return(I=(l=e.initialSlotConfig)==null?void 0:l[s])!=null?I:null},getSitePalette(){var s;return(s=e.initialPalette)!=null?s:null},reportSlots(){},getPersona(){let s=u!=null?u:d;return s?{persona:s.persona,confidence:s.confidence,band:qe(s.confidence)}:null},async assign(s,l){var c;let I=await h;return!I||!l||l.length===0?l!=null&&l[0]?{variantId:l[0],assignmentTtlMs:0}:null:{variantId:(c=I.createLocalEngine({sessionId:o,forcedPersona:p}).decide({components:[{id:s,variantIds:l}]}).assignments[s])!=null?c:l[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>t.destroy()}}var Rt=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function Ye(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function nn(e,t){if(e===void 0||!Rt.test(e))return!1;if(e==="*")return!0;let o=Ye(t);if(e.endsWith("/*")){let p=Ye(e.slice(0,-2));return o.startsWith(p==="/"?"/":`${p}/`)&&o!==p}return o===Ye(e)}var Mn=["none","sm","md","lg"],Nn=["start","center","end","stretch"],Kn=["start","center","end","between"],Gn=["sm","md","lg"],Fn=["normal","medium","bold"],$n=["default","muted","accent"],Un=["primary","secondary","ghost"],jn=["left","center","right"],Wn=["auto","square","landscape","wide"],Vn=["cover","contain"],zn=[2,3,4],Hn=[1,2,3,4],Jn=["default","raised"],Qn=["none","sm","md","lg"],qn=["measure"],Xn=["input","textarea","select"],Yn=["text","email","number","tel"],Zn=5,eo=8,to=64,no=5,oo=12,so=4,ro=500;function on(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(on):!1}var Ze="sentient-reveal",me="sentient-revealed",sn=240,Pe=!1;function rn(){var e;Pe=!1,typeof document!="undefined"&&((e=document.getElementById(Ze))==null||e.remove())}function an(e){if(Pe||e.getElementById(Ze)){Pe=!0;return}let t=e.createElement("style");t.id=Ze,t.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${me}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${me}{animation:${me} 240ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(t),Pe=!0}function ln(e,t={}){var h;let o=(h=t.doc)!=null?h: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;an(o),e.classList.remove(me),e.offsetWidth,e.classList.add(me);let p=()=>{e.classList.remove(me),e.removeEventListener("animationend",p)};return e.addEventListener("animationend",p),!0}function dn(e,t,o,p){let h=[];{let d=!1,g=[],i=()=>{if(d)return;let s=Date.now();for(g.push(s);g.length>0&&s-g[0]>500;)g.shift();g.length>=3&&(d=!0,e("rage_click"))};t.addEventListener("click",i),h.push(()=>t.removeEventListener("click",i))}{let u=!1,r=d=>{if(u||!(d.target instanceof Node)||!t.contains(d.target)&&t!==d.target)return;u=!0;let g=typeof window!="undefined"?window.getSelection():null,i=g?g.toString().length:0;e("text_copy",{selectionLength:i})};document.addEventListener("copy",r),h.push(()=>document.removeEventListener("copy",r))}{let u=!1,r=!1,d=null,g=()=>{d!==null&&(clearTimeout(d),d=null)},i=()=>{u||!r||(g(),d=setTimeout(()=>{!u&&r&&(u=!0,e("scroll_hesitation"))},3e3))},s=()=>{g(),i()},l=R=>{for(let c of R)r=c.intersectionRatio>.3,r?i():g()},I=new IntersectionObserver(l,{threshold:[.3]});I.observe(t),window.addEventListener("scroll",s,{passive:!0}),h.push(()=>{I.disconnect(),window.removeEventListener("scroll",s),g()})}if((p==null?void 0:p.tabLoss)!==!1){let u=!1,r=o!=null?o:Date.now(),d=()=>{if(u||document.visibilityState!=="hidden")return;let g=Date.now()-r;g<15e3&&(u=!0,e("tab_loss",{timeOnPage:g}))};document.addEventListener("visibilitychange",d),h.push(()=>document.removeEventListener("visibilitychange",d))}return()=>{for(let u of h)u()}}function cn(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var At="https://api.sentient-ui.com/v1/events",J=new Map,Tt=null;function Ao(e,t){let o=J.get(e);o&&o.upgrade&&(o.reinit=t)}function un(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var pn=3;function et(){return Ie()}function Be(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function gn(){let e=new WeakMap,t=new Map,o=!1,p=(d,g,i)=>{let s=d.get(g);return i===null?s?!0:(d.set(g,new Set),!1):s?s.has(i)?!0:(s.add(i),!1):(d.set(g,new Set([i])),!1)},h=typeof window!="undefined"&&"event"in window,u=()=>{if(!h)return;let d=window.event;return typeof Event=="function"&&d instanceof Event?d:void 0},r=()=>{if(h){Promise.resolve().then(()=>{o=!1,t.clear()});return}let d=!1,g=()=>{d||(d=!0,o=!1,t.clear())};if(setTimeout(g,0),typeof MessageChannel=="function"){let i=new MessageChannel;i.port1.onmessage=()=>{i.port1.close(),i.port2.close(),g()},i.port2.postMessage(0)}};return{firedBefore(d,g){let i=u();if(i){let l=e.get(i);return l||(l=new Map,e.set(i,l)),p(l,d,g)}let s=p(t,d,g);return!s&&!o&&(o=!0,r()),s}}}var Pt=new Set;function fn(e,t,o){let p=typeof window=="undefined"?null:window.history;if(!p)return()=>{};let h=!1,u,r=()=>{if(h)return;let i=Be();!i||i===u||(u=i,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),o(`${t}:${i}`))},d=[];for(let i of["pushState","replaceState"]){let s=p[i],l=function(...I){let R=s.apply(this,I);return r(),R};p[i]=l,d.push([i,s,l])}window.addEventListener("popstate",r);let g=Be();return g&&Pt.has(`${t}:${g}`)?u=g:r(),()=>{if(!h){h=!0,window.removeEventListener("popstate",r);for(let[i,s,l]of d)p[i]===l&&(p[i]=s)}}}var be={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}),flush:()=>{},dispose:()=>{},destroy:()=>{}};function yn(){try{return je(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function Bt(e){return e.replace(/\/events\/?$/,"")}function Dt(){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 To(e){var g;if(typeof window=="undefined")return;let t=e!=null?e:Tt;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let o=J.get(t);if(!o){console.warn("[sentient] grantConsent() called before init()");return}let{config:p,upgrade:h,reinit:u}=o;if(!h){o.upgradeBlockedReason&&console.warn(o.upgradeBlockedReason);return}if(p.respectDoNotTrack!==!1&&Dt())return;let r=(u!=null?u:Sn)(pe(T({},p),{consent:!0}));h(r);let d=(g=J.get(t))==null?void 0:g.dispose;J.set(t,{config:pe(T({},p),{consent:!0}),upgrade:null,dispose:d})}function mn(e){var R;let t=e.preConsentBehavior==="statistical_winner",o=Bt((R=e.ingestUrl)!=null?R:At),p={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},h=new Map,u=new Map,r={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(c,f,w){if(!t)return Promise.resolve(null);let v=h.get(c);return v?Promise.resolve(v):tt(u,c,async()=>{try{let D=new URLSearchParams({componentId:c});for(let M of f!=null?f:[])D.append("variantIds[]",M);let V=await fetch(`${o}/winner?${D.toString()}`,{headers:p});if(!V.ok)return f!=null&&f[0]?{variantId:f[0],assignmentTtlMs:0}:null;let K={variantId:(await V.json()).variantId,assignmentTtlMs:0};return h.set(c,K),K}catch(D){return f!=null&&f[0]?{variantId:f[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}},d=!1,g=new Set,i=[],s=[],l={track:c=>r.track(c),goal:((c,f,w,v)=>r.goal(c,f,w,v)),componentGoal:(c,f,w)=>r.componentGoal(c,f,w),identify:c=>r.identify(c),getAssignment:(c,f)=>r.getAssignment(c,f),assign:(c,f,w,v)=>r.assign(c,f,w,v),decide:c=>r.decide(c),getSlotResult:c=>r.getSlotResult(c),isSlotDecided:c=>{var f,w;return(w=(f=r.isSlotDecided)==null?void 0:f.call(r,c))!=null?w:!0},getSlotConfig:c=>r.getSlotConfig(c),getSitePalette:()=>r.getSitePalette(),getStyleVocabulary:()=>{var c,f;return(f=(c=r.getStyleVocabulary)==null?void 0:c.call(r))!=null?f:null},reportSlots:(c,f,w,v)=>r.reportSlots(c,f,w,v),reportSkeleton:(c,f)=>{var w;return(w=r.reportSkeleton)==null?void 0:w.call(r,c,f)},reportDrift:(c,f,w,v)=>{var D;return(D=r.reportDrift)==null?void 0:D.call(r,c,f,w,v)},requestSlots:(c,f,w)=>{var v;return d?(v=r.requestSlots)==null?void 0:v.call(r,c,f,w):i.push([c,f,w])},decideSlots:c=>{var f;return d?(f=r.decideSlots)==null?void 0:f.call(r,c):s.push(...c)},cancelSlots:c=>{var w;if(d)return(w=r.cancelSlots)==null?void 0:w.call(r,c);let f=new Set(c);for(let v of i)v[0]=v[0].filter(D=>!f.has(D));s=s.filter(v=>!f.has(v.id))},onSlotsChanged:c=>(g.add(c),()=>{g.delete(c)}),getPersona:()=>r.getPersona(),fetchWeights:()=>r.fetchWeights(),getGraph:()=>r.getGraph(),flush:()=>r.flush(),dispose:()=>r.dispose(),destroy:()=>r.destroy()};function I(c){var f,w,v;r=c,d=!0,(f=c.onSlotsChanged)==null||f.call(c,()=>g.forEach(D=>D()));for(let[D,V,P]of i.splice(0))D.length>0&&((w=c.requestSlots)==null||w.call(c,D,V,P));s.length>0&&((v=c.decideSlots)==null||v.call(c,s.splice(0)))}return{proxy:l,setInner:I}}function tt(e,t,o){let p=e.get(t);if(p)return p;let h=(async()=>{try{return await o()}finally{e.delete(t)}})();return e.set(t,h),h}function Sn(e){var at,lt,dt,ct,ut,pt,gt,ft,yt,mt;if(typeof window=="undefined")return be;Tt=e.apiKey||"local";let t=J.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(n){}let o=e.respectDoNotTrack!==!1&&Dt(),p=e.consent===!1||o,h=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!h&&e.localMode!==!1)return J.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?be:Ct(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."),J.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."}),be;let{proxy:n,setInner:a}=mn(e);return J.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."),be;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),be;let u=(at=e.ingestUrl)!=null?at:At,r=Date.now(),d=Ce({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),g=Et(void 0,e.apiKey),i=wt({ingestUrl:u,apiKey:e.apiKey}),s=Bt(u),l={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},I=new Set,R=xt({url:`${s}/goals`,apiKey:e.apiKey,headers:l,onDrop:(n,a)=>{if(!e.debug){if(I.has(a))return;I.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)}}),c=Fe((lt=navigator.userAgent)!=null?lt:""),f=window.location.origin,w=$e((dt=document.referrer)!=null?dt:"",f),v=(ct=e.sessionSegment)!=null?ct:`${c}:${w}`,D=new Map,V=new Map,P=new Map,K=new Set,M=new Map,k=null,L=null,G=null,ne=new Set,Y=new Set,oe=new Map,ge=new Map,b=new Set,A=new Set,se=new Set,ie=null,Q=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,Se=new Set,Z=new Set,ae=new Set,X=new Map,De=null,we=new Set,he=new Map,Le=null,Lt=2,nt=new Map,Me=!1,ot=(n,a,S)=>{var y;let E=new Set,_=1;for(let m of n){a.delete(m);let C=((y=nt.get(m))!=null?y:0)+1;nt.set(m,C),C<=Lt&&(E.add(m),C>_&&(_=C))}E.size>0&&setTimeout(()=>{Me||S(E)},re(_))},st=n=>{for(let a of n)P.has(a.id)||P.set(a.id,Ee(a))};if(e.initialSlots)for(let[n,a]of Object.entries(e.initialSlots))P.set(n,a),K.add(n);if(e.initialSlotConfig)for(let[n,a]of Object.entries(e.initialSlotConfig))M.set(n,a);e.initialPalette&&(k=e.initialPalette),e.initialVocabulary&&(L=e.initialVocabulary);let ee=ve(e.apiKey);if(ee){for(let[n,a]of Object.entries(ee.slots))P.has(n)||P.set(n,a);for(let[n,a]of Object.entries((ut=ee.slotConfig)!=null?ut:{}))M.has(n)||M.set(n,a);!k&&ee.palette&&(k=ee.palette),!L&&ee.vocabulary&&(L=ee.vocabulary)}let rt={low:.15,medium:.5,high:.85};if(e.initialPersona)G=T({},e.initialPersona);else{let n=document.documentElement.dataset;n.sentientPersona?G={persona:n.sentientPersona,confidence:(gt=rt[(pt=n.sentientConfidence)!=null?pt:"low"])!=null?gt:.15}:ee&&(G={persona:ee.persona,confidence:(ft=rt[ee.band])!=null?ft:.15})}if(e.initialAssignments)for(let[n,a]of Object.entries(e.initialAssignments))g.set(n,v,{variantId:a,assignedAt:Date.now(),segment:v,confidence:1});let le=Promise.resolve(),it=d.getSessionId();if(it){let n=Ue((yt=document.referrer)!=null?yt:""),{utmParams:a,clickIds:S}=yn(),E=T(T(T(T({sessionId:it,deviceClass:c,trafficSource:w,referrerDomain:n,utmParams:a,clickIds:S,timeOfDay:We(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:d.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Ge((mt=navigator.userAgent)!=null?mt:"")},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 m=await fetch(`${s}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(E),headers:l});if(m.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(m.ok||fe(m)==="dropped")return}catch(m){}if(y>=pn){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(m=>setTimeout(m,re(y+1)))}};try{le=_()}catch(y){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:i});let Mt=gn(),ue=null,Ne=!1,F={goal(n,a={},S=1,E=0){var j,$,H,q,z,x,W;let _=d.getSessionId();if(!_)return;let y=un(a)?a:{metadata:a},m=[n,(j=y.externalId)!=null?j:"",($=y.stepIndex)!=null?$:E,(H=y.weight)!=null?H:S].join("\0"),C=y.value!==void 0?`${y.value}\0${(q=y.currency)!=null?q:""}`:null;if(Mt.firedBefore(m,C)){e.debug&&console.log(`[sentient] goal("${n}") already recorded for this action \u2014 not sent twice`);return}let O=et(),B={sessionId:_,name:n,metadata:(z=y.metadata)!=null?z:{},weight:(x=y.weight)!=null?x:S,stepIndex:(W=y.stepIndex)!=null?W:E,goalId:O,value:y.value,currency:y.currency,externalId:y.externalId};e.debug&&console.log("[sentient] goal",B);let U={id:O,body:JSON.stringify(B)};le.then(()=>R.send(U))},componentGoal(n,a,S){var O,B,U;let E=d.getSessionId();if(!E)return;let _=g.get(n,v),y=_?null:(O=P.get(n))!=null?O: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(!_&&!K.has(n)){e.debug&&console.warn(`[sentient] componentGoal("${n}"): slot not decided this session \u2014 not attributed`);return}let m=_?_.variantId:ze(y),C={id:et(),sessionId:E,projectId:e.apiKey,componentId:n,variantId:m,eventType:"goal_achieved",goalType:a,payload:T({reward:(B=S==null?void 0:S.reward)!=null?B:1,goalValue:S==null?void 0:S.value,currency:S==null?void 0:S.currency},(U=S==null?void 0:S.metadata)!=null?U:{}),timestamp:Date.now(),timeInSession:Date.now()-r,path:Be()};e.debug&&console.log("[sentient] componentGoal",C),le.then(()=>i.push(C))},identify(n){let a=d.getSessionId();a&&le.then(()=>{fetch(`${s}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:a,userId:n,ephemeral:d.isEphemeral()}),headers:l}).catch(()=>{})})},track(n){let a=d.getSessionId();if(!a||n.eventType==="variant_assigned"&&P.get(n.componentId)!==void 0&&!K.has(n.componentId)&&!g.get(n.componentId,v))return;let S=pe(T({path:Be()},n),{id:et(),sessionId:a,timestamp:Date.now(),timeInSession:Date.now()-r});e.debug&&console.log("[sentient] track",S),le.then(()=>i.push(S))},getAssignment(n,a){return g.get(n,a)},async assign(n,a,S,E){let _=d.getSessionId();if(!_)return null;let y=g.get(n,v);if(y&&(a!=null&&a.length||y.content!==void 0)){let m=y.ttlMs&&y.ttlMs>0?Math.max(0,y.assignedAt+y.ttlMs-Date.now()):0;return{variantId:y.variantId,assignmentTtlMs:m,content:y.content}}return tt(D,n,async()=>{await le;try{let m={sessionId:_,componentId:n,variantIds:a};E!==void 0?m.agentDataByVariant=E:S!==void 0&&(m.agentData=S);let C=await fetch(`${s}/assign`,{method:"POST",body:JSON.stringify(m),headers:l});if(!C.ok)return null;let O=await C.json();return g.set(n,v,T({variantId:O.variantId,assignedAt:Date.now(),segment:v,confidence:1,content:O.content},O.assignmentTtlMs&&O.assignmentTtlMs>0?{ttlMs:O.assignmentTtlMs}:{})),O}catch(m){return null}})},async decide(n){var y,m;let a=d.getSessionId();if(!a)return null;let S=(y=n.slots)!=null?y:[],E={sessionId:a};n.sections&&n.sections.length>0&&(E.sections=n.sections.map(C=>({id:C}))),E.components=(m=n.components)!=null?m:[],S.length>0&&(E.slots=S.map(Ve)),n.slotsFrom==="registry"&&(E.slotsFrom="registry",n.registrySlotIds&&(E.registrySlotIds=n.registrySlotIds),n.bootstrap===!1&&(E.bootstrap=!1),n.render&&Object.keys(n.render).length>0&&(E.render=n.render)),n.v&&(E.v=n.v),typeof n.pp=="number"&&(E.pp=n.pp),e.persona&&(E.persona=e.persona);let _=JSON.stringify(E);return tt(V,_,async()=>{var C,O,B,U,j,$,H,q;await le;try{let z=await fetch(`${s}/decide`,{method:"POST",body:_,headers:l});if(!z.ok)return st(S),null;let x=await z.json(),W={};for(let N of S){let te=(C=x.slots)==null?void 0:C[N.id];if(te!==void 0){W[N.id]=te,P.set(N.id,te),K.add(N.id);continue}let St=P.get(N.id);if(St!==void 0)W[N.id]=St;else{let ht=Ee(N);W[N.id]=ht,P.set(N.id,ht)}}if(x.slots)for(let[N,te]of Object.entries(x.slots))N in W||(W[N]=te,P.set(N,te),K.add(N));let de=G!=null&&G.persona!=="unknown";x.persona&&!(x.persona==="unknown"&&de)?G={persona:x.persona,confidence:(O=x.confidence)!=null?O:0}:G||(G={persona:"unknown",confidence:0});for(let[N,te]of Object.entries((B=x.assignments)!=null?B:{}))g.set(N,v,{variantId:te,assignedAt:Date.now(),segment:v,confidence:1});if(x.slotConfig)for(let[N,te]of Object.entries(x.slotConfig))M.set(N,te);x.palette&&(k=x.palette),x.vocabulary&&(L=x.vocabulary);for(let N of(U=n.registrySlotIds)!=null?U:[])(j=x.slotConfig)!=null&&j[N]||(M.delete(N),P.delete(N),K.delete(N));return ke(e.apiKey,T(T(T({v:1,persona:G.persona,band:Ot(G.confidence),slots:Object.fromEntries(P),layoutOrder:($=x.layoutOrder)!=null?$:null,savedAt:Date.now()},M.size>0?{slotConfig:Object.fromEntries(M)}:{}),k?{palette:k}:{}),L?{vocabulary:L}:{})),T(T(T(T(T({layoutOrder:(H=x.layoutOrder)!=null?H:null,assignments:(q=x.assignments)!=null?q:{},slots:W,persona:G.persona,confidence:G.confidence},x.slotConfig?{slotConfig:x.slotConfig}:{}),x.goals?{goals:x.goals}:{}),x.sectionMap?{sectionMap:x.sectionMap}:{}),x.palette?{palette:x.palette}:{}),x.vocabulary?{vocabulary:x.vocabulary}:{})}catch(z){return st(S),null}})},getSlotResult(n){var a;return(a=P.get(n))!=null?a:null},isSlotDecided(n){return K.has(n)},getSlotConfig(n){var a;return(a=M.get(n))!=null?a:null},reportSlots(n,a,S,E){var y;let _={};for(let[m,C]of Object.entries(E!=null?E:{}))for(let O of C){let B=`${m}|${O.key}`;!Q.test(m)||se.has(B)||(se.add(B),((y=_[m])!=null?y:_[m]=[]).push(O))}Object.keys(_).length>0&&fetch(`${s}/slots/observed`,{method:"POST",headers:l,body:JSON.stringify({slotIds:Object.keys(_),authoredArms:_})}).catch(()=>{});for(let m of n)if(!(typeof m!="string"||m.length===0)){if(!Q.test(m)){cn()&&!Se.has(m)&&(Se.add(m),console.warn(`[sentient] reportSlots: slot id ${JSON.stringify(m)} 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(!ne.has(m)){ne.add(m),Y.add(m);let C=a==null?void 0:a[m];if(typeof C=="string"){let B=C.replace(/\s+/g," ").trim().slice(0,400);B!==""&&oe.set(m,B)}let O=S==null?void 0:S[m];O!==void 0&&ge.set(m,O)}}Y.size===0||ie!=null||(ie=setTimeout(()=>{ie=null;let m=[...Y];Y.clear();for(let C=0;C<m.length;C+=20){let O=m.slice(C,C+20),B={},U={};for(let j of O){let $=oe.get(j);$!==void 0&&(B[j]=$,oe.delete(j));let H=ge.get(j);H!==void 0&&(U[j]=H,ge.delete(j))}fetch(`${s}/slots/observed`,{method:"POST",headers:l,body:JSON.stringify(pe(T(T({slotIds:O},Object.keys(B).length>0?{baselineTexts:B}:{}),Object.keys(U).length>0?{baselineSkeletons:U}:{}),{pagePaths:Object.fromEntries(O.map(j=>[j,location.pathname]))}))}).catch(()=>{})}},1e3))},reportSkeleton(n,a){!Q.test(n)||b.has(n)||(b.add(n),fetch(`${s}/slots/observed`,{method:"POST",headers:l,body:JSON.stringify({slotIds:[n],baselineSkeletons:{[n]:a}})}).catch(()=>{}))},reportDrift(n,a,S,E){let _=`${n}|${a}`,y=d.getSessionId();!y||A.has(_)||(A.add(_),fetch(`${s}/slots/drift`,{method:"POST",headers:l,body:JSON.stringify({sessionId:y,reports:[{slotId:n,expectedFp:a,observedFp:S,reason:E}]})}).catch(()=>{}))},requestSlots(n,a,S){var E,_;for(let y of n)ae.has(y)||(ae.add(y),Q.test(y)?X.set(y,{text:a==null?void 0:a[y],render:(E=S==null?void 0:S.render)==null?void 0:E[y],skeleton:(_=S==null?void 0:S.skeletons)==null?void 0:_[y]}):F.reportSlots([y]));X.size===0||De!=null||(De=setTimeout(()=>{De=null;let y=[...X];X.clear();for(let m=0;m<y.length;m+=50){let C=y.slice(m,m+50),O={};for(let[B,U]of C)U.render&&(O[B]=U.render);F.decide({slotsFrom:"registry",registrySlotIds:C.map(([B])=>B),bootstrap:!1,render:O}).then(B=>{var U,j;if(B){let $={},H={},q=[];for(let[z,x]of C){let W=(U=B.slotConfig)==null?void 0:U[z];if(W){W.needsSkeleton&&x.skeleton&&((j=F.reportSkeleton)==null||j.call(F,z,x.skeleton));continue}q.push(z),x.text&&($[z]=x.text),x.skeleton&&(H[z]=x.skeleton)}q.length>0&&F.reportSlots(q,$,H)}else ot(C.map(([$])=>$),ae,$=>{var x;let H={},q={},z={};for(let[W,de]of C)$.has(W)&&(de.text&&(H[W]=de.text),de.render&&(q[W]=de.render),de.skeleton&&(z[W]=de.skeleton));(x=F.requestSlots)==null||x.call(F,[...$],H,{render:q,skeletons:z})});Z.forEach($=>$())})}},0))},decideSlots(n){for(let a of n)we.has(a.id)||(we.add(a.id),he.set(a.id,a));he.size===0||Le!=null||(Le=setTimeout(()=>{Le=null;let a=[...he.values()];he.clear();for(let S=0;S<a.length;S+=30){let E=a.slice(S,S+30);F.decide({slots:E}).then(_=>{_||ot(E.map(y=>y.id),we,y=>{var m;return(m=F.decideSlots)==null?void 0:m.call(F,E.filter(C=>y.has(C.id)))}),Z.forEach(y=>y())})}},0))},cancelSlots(n){for(let a of n)X.delete(a)&&ae.delete(a),he.delete(a)&&we.delete(a)},onSlotsChanged(n){return Z.add(n),()=>{Z.delete(n)}},getStyleVocabulary(){return L},getSitePalette(){return k},getPersona(){return G?{persona:G.persona,confidence:G.confidence,band:Ot(G.confidence)}:null},async fetchWeights(){var n;try{let a=await fetch(`${s}/weights`,{headers:l});return a.ok?(n=(await a.json()).components)!=null?n:[]:[]}catch(a){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},flush(){i.flush(),R.flush()},dispose(){var n;ue==null||ue(),Ne=!0,Me=!0,i.destroy(),R.destroy(),((n=J.get(e.apiKey))==null?void 0:n.dispose)===F.dispose&&J.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var n;ue==null||ue(),Ne=!0,Me=!0,i.destroy(),R.destroy(),d.destroy(),g.clear(),((n=J.get(e.apiKey))==null?void 0:n.dispose)===F.dispose&&J.delete(e.apiKey);try{localStorage.removeItem(ye+e.apiKey),localStorage.removeItem(Je(e.apiKey)),localStorage.removeItem(Qe(e.apiKey))}catch(a){}e.debug&&console.log("[sentient] destroyed")}};if(J.set(e.apiKey,{config:e,upgrade:null,dispose:F.dispose}),ue=fn(F,e.apiKey,n=>{le.then(()=>{Ne||Pt.add(n)})}),e.debug){let n=window;n.__sentient&&(n.__sentient.client=F)}return F}export{ye as a,ve as b,ke as c,en as d,Xe as e,_t as f,Rt as g,nn as h,Mn as i,Nn as j,Kn as k,Gn as l,Fn as m,$n as n,Un as o,jn as p,Wn as q,Vn as r,zn as s,Hn as t,Jn as u,Qn as v,qn as w,Xn as x,Yn as y,Zn as z,eo as A,to as B,no as C,oo as D,so as E,ro as F,on as G,sn as H,rn as I,ln as J,dn as K,Ao as L,Dt as M,To as N,Sn as O};
2
+ //# sourceMappingURL=chunk-DGRAS5VP.mjs.map