@sentientui/core 0.21.3 → 0.23.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/dist/chunk-2RH7I6AP.mjs +2 -0
  2. package/dist/chunk-2RH7I6AP.mjs.map +1 -0
  3. package/dist/chunk-EWP6FTHE.mjs +2 -0
  4. package/dist/chunk-EWP6FTHE.mjs.map +1 -0
  5. package/dist/chunk-KIP52DUJ.mjs +2 -0
  6. package/dist/chunk-KIP52DUJ.mjs.map +1 -0
  7. package/dist/classify-DYlSjkFP.d.cts +47 -0
  8. package/dist/classify-DYlSjkFP.d.ts +47 -0
  9. package/dist/{index-BcRtGYVH.d.ts → index-BbrtAtrY.d.ts} +11 -4
  10. package/dist/{index-D3_vlZ3z.d.cts → index-CXxvWxCB.d.cts} +11 -4
  11. package/dist/index-engagement.d.cts +3 -28
  12. package/dist/index-engagement.d.ts +3 -28
  13. package/dist/index-engagement.js +1 -1
  14. package/dist/index-engagement.js.map +1 -1
  15. package/dist/index-engagement.mjs +1 -1
  16. package/dist/index-engagement.mjs.map +1 -1
  17. package/dist/index-graph.d.cts +15 -5
  18. package/dist/index-graph.d.ts +15 -5
  19. package/dist/index-graph.js +1 -1
  20. package/dist/index-graph.js.map +1 -1
  21. package/dist/index-graph.mjs +1 -1
  22. package/dist/index-graph.mjs.map +1 -1
  23. package/dist/index-local.d.cts +1 -1
  24. package/dist/index-local.d.ts +1 -1
  25. package/dist/index-topics.d.cts +21 -0
  26. package/dist/index-topics.d.ts +21 -0
  27. package/dist/index-topics.js +2 -0
  28. package/dist/index-topics.js.map +1 -0
  29. package/dist/index-topics.mjs +2 -0
  30. package/dist/index-topics.mjs.map +1 -0
  31. package/dist/index.d.cts +1 -1
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +1 -1
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +1 -1
  36. package/package.json +7 -2
  37. package/dist/chunk-CD2A55US.mjs +0 -2
  38. package/dist/chunk-CD2A55US.mjs.map +0 -1
  39. package/dist/chunk-Q252FDO2.mjs +0 -2
  40. package/dist/chunk-Q252FDO2.mjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var mt=Object.create;var pe=Object.defineProperty,yt=Object.defineProperties,ht=Object.getOwnPropertyDescriptor,St=Object.getOwnPropertyDescriptors,vt=Object.getOwnPropertyNames,ze=Object.getOwnPropertySymbols,wt=Object.getPrototypeOf,Je=Object.prototype.hasOwnProperty,xt=Object.prototype.propertyIsEnumerable;var Qe=(e,t,n)=>t in e?pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,k=(e,t)=>{for(var n in t||(t={}))Je.call(t,n)&&Qe(e,n,t[n]);if(ze)for(var n of ze(t))xt.call(t,n)&&Qe(e,n,t[n]);return e},oe=(e,t)=>yt(e,St(t));var bt=(e,t)=>{for(var n in t)pe(e,n,{get:t[n],enumerable:!0})},Ve=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of vt(t))!Je.call(e,u)&&u!==n&&pe(e,u,{get:()=>t[u],enumerable:!(c=ht(t,u))||c.enumerable});return e};var kt=(e,t,n)=>(n=e!=null?mt(wt(e)):{},Ve(t||!e||!e.__esModule?pe(n,"default",{value:e,enumerable:!0}):n,e)),Et=e=>Ve(pe({},"__esModule",{value:!0}),e);var yn={};bt(yn,{AGENT_INTENTS:()=>Oe,BLOCK_ALIGNS:()=>zt,BLOCK_EMPHASES:()=>Yt,BLOCK_FITS:()=>en,BLOCK_GAPS:()=>Ht,BLOCK_GRID_COLUMNS:()=>tn,BLOCK_HEADING_LEVELS:()=>nn,BLOCK_JUSTIFIES:()=>Qt,BLOCK_RATIOS:()=>Zt,BLOCK_SIZES:()=>Jt,BLOCK_TEXT_ALIGNS:()=>qt,BLOCK_TONES:()=>Xt,BLOCK_WEIGHTS:()=>Vt,LEGACY_SESSION_COOKIE_NAME:()=>Me,LOCAL_MODE_BANNER:()=>$e,MAX_BLOCK_ARMS:()=>an,MAX_BLOCK_CHILDREN:()=>sn,MAX_BLOCK_DEPTH:()=>rn,MAX_BLOCK_NODES:()=>on,MAX_BLOCK_TEXT_LEN:()=>ln,PROD_KEYLESS_ERROR:()=>De,SNAPSHOT_STORAGE_KEY_PREFIX:()=>te,agentIntent:()=>nt,agentUaList:()=>fe,armOfResult:()=>Te,attachMicroSignalDetectors:()=>ct,baselineResultFor:()=>ie,baselineSlots:()=>st,classifiedAgents:()=>ot,deriveSessionSegment:()=>rt,detectDeviceClass:()=>ye,detectTimeOfDay:()=>ve,detectTrafficSource:()=>he,grantConsent:()=>fn,init:()=>ft,isDoNotTrackEnabled:()=>je,matchedAgentToken:()=>Ue,readSnapshot:()=>Re,referrerDomainFromReferer:()=>Se,renderPrePaintScript:()=>it,sessionCookieName:()=>Ee,toWireSlot:()=>we,uaTokenMatch:()=>me,writeSnapshot:()=>ae});module.exports=Et(yn);function ke(){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 n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===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)})}function ge(e){return e?`_${e.slice(0,12)}`:""}var Me="_snt_uid";function Ee(e){return`${Me}${ge(e)}`}var It="_snt_uid",Ct=365,Ne="_snt_uid";function _t(){return ke()}function Xe(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function At(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(c){}}function Ye(e){try{return localStorage.getItem(e)}catch(t){return null}}function Ot(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function qe(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function Tt(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Rt(e){try{sessionStorage.removeItem(e)}catch(t){}}function Bt(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 Lt(e){try{localStorage.removeItem(e)}catch(t){}}function Dt(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Pt={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function Ie(e){var b,D,C,_,O,K,A;if(typeof window=="undefined")return Pt;let t=ge(e==null?void 0:e.apiKey),n=(b=e==null?void 0:e.cookieName)!=null?b:Ee(e==null?void 0:e.apiKey),c=`${Ne}${t}`,i=((D=e==null?void 0:e.cookieTTLDays)!=null?D:Ct)*24*60*60,p=S=>S&&S.length>0?S:null,a=()=>{var S,R;return t&&!(e!=null&&e.cookieName)?(R=(S=p(Xe(It)))!=null?S:p(Ye(Ne)))!=null?R:p(qe(Ne)):null},r=(A=(K=(O=(_=(C=p(Xe(n)))!=null?C:p(Ye(c)))!=null?_:p(qe(c)))!=null?O:a())!=null?K:p(e==null?void 0:e.ssrSessionId))!=null?A:_t();At(n,r,i);let o=Ot(c,r),s=Bt(n),l=o?!1:Tt(c,r),y=!o&&!s&&!l;return{getSessionId:()=>r,isEphemeral:()=>y,destroy:()=>{r=null,Dt(n),Lt(c),Rt(c)}}}function q(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function re(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 Ce(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let c=JSON.parse(n);return Array.isArray(c)?(localStorage.removeItem(e),c.slice(-t)):[]}catch(n){return[]}}function Z(e,t,n){try{let c=(()=>{try{let i=localStorage.getItem(n);if(!i)return[];let p=JSON.parse(i);return Array.isArray(p)?p:[]}catch(i){return[]}})(),u=new Map;for(let i of c)u.set(i.id,i);for(let i of e)u.set(i.id,i);localStorage.setItem(n,JSON.stringify([...u.values()].slice(-t)))}catch(c){}}function _e(e,t){try{let n=localStorage.getItem(t);if(!n)return;let c=JSON.parse(n);if(!Array.isArray(c))return;let u=new Set(e),i=c.filter(p=>!u.has(p.id));if(i.length===c.length)return;i.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(i))}catch(n){}}var Mt=500,Nt=56*1024;function Ke(e){return`_snt_retry_${e.slice(0,12)}`}var Kt={push:()=>{},flush:()=>{},destroy:()=>{}};function Ze(e){var J,M,j;if(typeof window=="undefined")return Kt;let t=(J=e.flushIntervalMs)!=null?J:5e3,n=(M=e.maxBatchSize)!=null?M:20,c=(j=e.maxRetrySize)!=null?j:100,u=e.ingestUrl,i=e.apiKey,p=Ke(i),a=[],r=new Set,o=[],s=f=>{for(let w of f)l.delete(w),!r.has(w)&&(r.add(w),o.push(w));for(;o.length>Mt;){let w=o.shift();w&&r.delete(w)}_e(f,p)},l=new Set,y=f=>{r.has(f.id)||l.has(f.id)||(l.add(f.id),a.push(f))},b=f=>{for(let w of f)r.has(w.id)||(l.add(w.id),a.push(w))},D=Ce(p,c);for(let f of D)y(f);let C=0,_=0,O=(f,w=!0)=>{if(f.length===0)return;let H=JSON.stringify(f),ee=f.map(V=>V.id),F;try{F=fetch(u,{method:"POST",keepalive:!0,body:H,headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`}})}catch(V){Z(f,c,p),b(f),_++,C=Date.now()+q(_);return}let le=V=>{if(re(V)!=="retry"){if(!V.ok&&w){let ne=f.filter(X=>X.eventType!=="pageview");if(ne.length>0&&ne.length<f.length){s(f.filter(X=>X.eventType==="pageview").map(X=>X.id)),O(ne,!1);return}}s(ee),_=0,C=0;return}Z(f,c,p),b(f),_++,C=Date.now()+q(_)};F instanceof Promise?F.then(le).catch(()=>{Z(f,c,p),b(f),_++,C=Date.now()+q(_)}):le(F)},K=typeof TextEncoder!="undefined"?new TextEncoder:null,A=f=>K?K.encode(f).length:f.length,S=f=>{let w=[],H=2;for(let ee of f){let F=A(JSON.stringify(ee))+1;if(w.length>0&&H+F>Nt||w.length>=n)break;w.push(ee),H+=F}return w},R=()=>{try{if(Date.now()<C)return;for(;a.length>0&&!(Date.now()<C);){let f=a.filter(H=>!r.has(H.id));if(a.length=0,f.length===0)break;let w=S(f);if(w.length===0)break;w.length<f.length&&a.push(...f.slice(w.length)),O(w)}}catch(f){}},G=!0,m=null;m=setInterval(()=>{G&&R()},t);let E=()=>{document.visibilityState==="hidden"&&R()},Q=()=>{R()};return document.addEventListener("visibilitychange",E),window.addEventListener("pagehide",Q),{push(f){y(f),a.length>=n&&R()},flush:R,destroy(){G=!1,m!==null&&(clearInterval(m),m=null),document.removeEventListener("visibilitychange",E),window.removeEventListener("pagehide",Q),R()}}}var Gt=200;function Ge(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Ut={send:()=>{},flush:()=>{},destroy:()=>{}};function et(e){var S,R,G;if(typeof window=="undefined")return Ut;let t=(S=e.flushIntervalMs)!=null?S:5e3,n=(R=e.maxRetrySize)!=null?R:100,c=(G=e.maxPerFlush)!=null?G:5,u=Ge(e.apiKey),i=[],p=new Set,a=new Set,r=[],o=0,s=0,l=!1,y=m=>{for(p.delete(m.id),a.has(m.id)||(a.add(m.id),r.push(m.id));r.length>Gt;){let E=r.shift();E&&a.delete(E)}_e([m.id],u)},b=m=>{Z([m],n,u),!a.has(m.id)&&!p.has(m.id)&&(p.add(m.id),i.push(m)),Date.now()>=o&&(s++,o=Date.now()+q(s))},D=m=>{let E;try{E=fetch(e.url,{method:"POST",keepalive:!0,body:m.body,headers:e.headers})}catch(J){b(m);return}let Q=J=>{var j;let M=re(J);if(M==="retry"){b(m);return}M==="dropped"&&((j=e.onDrop)==null||j.call(e,m,J.status)),y(m),s=0,o=0};E instanceof Promise?E.then(Q).catch(()=>b(m)):Q(E)},C=()=>{try{if(l||Date.now()<o)return;let m=0;for(;i.length>0&&m<c&&!(Date.now()<o);){let E=i.shift();p.delete(E.id),!a.has(E.id)&&(m++,D(E))}}catch(m){}},_=Ce(u,n);for(let m of _)p.has(m.id)||(p.add(m.id),i.push(m));_.length>0&&Z(_,n,u);let O=setInterval(C,t),K=()=>{document.visibilityState==="hidden"&&C()},A=()=>C();return document.addEventListener("visibilitychange",K),window.addEventListener("pagehide",A),{send(m){if(!l&&!(a.has(m.id)||p.has(m.id))){if(Date.now()<o){Z([m],n,u),p.add(m.id),i.push(m);return}D(m)}},flush:C,destroy(){clearInterval(O),document.removeEventListener("visibilitychange",K),window.removeEventListener("pagehide",A),C(),l=!0}}}var $t=1800*1e3;function Ae(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function tt(e=$t,t){let n=new Map,c=`_snt_asgn${ge(t)}_`,u=(o,s)=>`${c}${encodeURIComponent(o)}:${encodeURIComponent(s)}`,i=o=>{let s=o.slice(c.length),l=s.indexOf(":");if(l<0)return null;try{return{componentId:decodeURIComponent(s.slice(0,l)),segment:decodeURIComponent(s.slice(l+1))}}catch(y){return null}},p=()=>{try{let o=[];for(let s=0;s<localStorage.length;s++){let l=localStorage.key(s);l!=null&&l.startsWith(c)&&o.push(l)}return o}catch(o){return[]}},a=o=>o.assignedAt+(o.ttlMs&&o.ttlMs>0?o.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let o of p())try{let s=localStorage.getItem(o);if(!s)continue;let l=JSON.parse(s);if(a(l)){localStorage.removeItem(o);continue}let y=i(o);if(!y)continue;n.set(Ae(y.componentId,y.segment),l)}catch(s){}})(),{get(o,s){let l=n.get(Ae(o,s));return l?a(l)?(n.delete(Ae(o,s)),null):l:null},set(o,s,l){let y=Ae(o,s);n.set(y,l);try{localStorage.setItem(u(o,s),JSON.stringify(l))}catch(b){}},invalidate(o){let s=`${encodeURIComponent(o)}:`;for(let l of[...n.keys()])l.startsWith(s)&&n.delete(l);for(let l of p()){let y=i(l);if((y==null?void 0:y.componentId)===o)try{localStorage.removeItem(l)}catch(b){}}},clear(){n.clear();for(let o of p())try{localStorage.removeItem(o)}catch(s){}}}}var fe=["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 me(e){return Ue(e)!==null}function Ue(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=fe.find(c=>t.includes(c.toLowerCase())))!=null?n:null}var Oe={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 nt(e){if(!e)return"other";let t=fe.find(n=>n.toLowerCase()===e.toLowerCase());return t&&Oe[t]||"other"}function ot(){var t;let e={user:[],search:[],training:[],other:[]};for(let n of fe)e[(t=Oe[n])!=null?t:"other"].push(n);return e}function ye(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 he(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(u){}let c=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(c)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(c)?"social":"referral"}catch(n){return"direct"}}function Se(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function ve(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function rt(e){let t=Ft("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function Ft(e,t){var i,p,a,r,o,s,l;let n=(p=(i=t==null?void 0:t.userAgent)==null?void 0:i.trim())!=null?p:"",c=(r=(a=t==null?void 0:t.referer)==null?void 0:a.trim())!=null?r:"",u=(o=t==null?void 0:t.now)!=null?o:new Date;return{sessionId:e,ephemeral:!1,utmParams:(s=t==null?void 0:t.utmParams)!=null?s:{},deviceClass:n?ye(n):"desktop",trafficSource:c?he(c,t==null?void 0:t.appOrigin):"direct",referrerDomain:Se(c),timeOfDay:ve(u),dayOfWeek:(l=["sun","mon","tue","wed","thu","fri","sat"][u.getDay()])!=null?l:"sun",automation:(t==null?void 0:t.webdriver)===!0||me(n)}}var se=require("@sentientui/policy");function we(e){return k(k(k({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function ie(e){let t=we(e);return(0,se.slotResultFor)(t,(0,se.slotBaselineArm)(t))}function st(e){let t={};for(let n of e)t[n.id]=ie(n);return t}function Te(e){return typeof e=="string"?e:(0,se.canonicalArm)(e)}var te="_snt_snap:",Wt=["low","medium","high"];function Re(e){try{let t=localStorage.getItem(te+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!Wt.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function ae(e,t){try{localStorage.setItem(te+e,JSON.stringify(t))}catch(n){}}function it(e){return"(function(){try{var r=localStorage.getItem("+JSON.stringify(te+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){}})();'}var We=require("@sentientui/policy");var Le=require("@sentientui/policy");var De="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",$e="[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.",at=!1,Be=!1;function jt(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function lt(e){var a;let t=Ie({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(a=t.getSessionId())!=null?a:"local",c=jt(),u=import("@sentientui/core/local").then(r=>{let o=r;return o.LOCAL_ENGINE_AVAILABLE?(at||(at=!0,console.info($e)),o):(Be||(Be=!0,console.error(De)),null)}).catch(()=>(Be||(Be=!0,console.error(De)),null)),i=null;function p(r){let o=document.documentElement;o.dataset.sentientPersona===void 0&&(o.dataset.sentientPersona=r.persona,o.dataset.sentientConfidence=(0,Le.confidenceBand)(r.confidence))}return{isLocal:!0,async decide(r){var l,y,b;let o=await u;if(!o)return null;let s=o.createLocalEngine({sessionId:n,forcedPersona:c}).decide(r);return i=oe(k({},s),{layoutOrder:(y=(l=s.layoutOrder)!=null?l:i==null?void 0:i.layoutOrder)!=null?y:null,slots:k(k({},(b=i==null?void 0:i.slots)!=null?b:{}),s.slots)}),ae(e.apiKey||"local",{v:1,persona:i.persona,band:(0,Le.confidenceBand)(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),p(s),s},getSlotResult(r){var o,s,l;return(l=(s=i==null?void 0:i.slots[r])!=null?s:(o=e.initialSlots)==null?void 0:o[r])!=null?l:null},getPersona(){return i?{persona:i.persona,confidence:i.confidence,band:(0,Le.confidenceBand)(i.confidence)}:null},async assign(r,o){var y;let s=await u;return!s||!o||o.length===0?o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null:{variantId:(y=s.createLocalEngine({sessionId:n,forcedPersona:c}).decide({components:[{id:r,variantIds:o}]}).assignments[r])!=null?y:o[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}var Ht=["none","sm","md","lg"],zt=["start","center","end","stretch"],Qt=["start","center","end","between"],Jt=["sm","md","lg"],Vt=["normal","medium","bold"],Xt=["default","muted","accent"],Yt=["primary","secondary","ghost"],qt=["left","center","right"],Zt=["auto","square","landscape","wide"],en=["cover","contain"],tn=[2,3,4],nn=[2,3,4],on=64,rn=5,sn=12,an=4,ln=500;function ct(e,t,n,c){let u=[];{let a=!1,r=[],o=()=>{if(a)return;let s=Date.now();for(r.push(s);r.length>0&&s-r[0]>500;)r.shift();r.length>=3&&(a=!0,e("rage_click"))};t.addEventListener("click",o),u.push(()=>t.removeEventListener("click",o))}{let i=!1,p=a=>{if(i||!(a.target instanceof Node)||!t.contains(a.target)&&t!==a.target)return;i=!0;let r=typeof window!="undefined"?window.getSelection():null,o=r?r.toString().length:0;e("text_copy",{selectionLength:o})};document.addEventListener("copy",p),u.push(()=>document.removeEventListener("copy",p))}{let i=!1,p=!1,a=null,r=()=>{a!==null&&(clearTimeout(a),a=null)},o=()=>{i||!p||(r(),a=setTimeout(()=>{!i&&p&&(i=!0,e("scroll_hesitation"))},3e3))},s=()=>{r(),o()},l=b=>{for(let D of b)p=D.intersectionRatio>.3,p?o():r()},y=new IntersectionObserver(l,{threshold:[.3]});y.observe(t),window.addEventListener("scroll",s,{passive:!0}),u.push(()=>{y.disconnect(),window.removeEventListener("scroll",s),r()})}if((c==null?void 0:c.tabLoss)!==!1){let i=!1,p=n!=null?n:Date.now(),a=()=>{if(i||document.visibilityState!=="hidden")return;let r=Date.now()-p;r<15e3&&(i=!0,e("tab_loss",{timeOnPage:r}))};document.addEventListener("visibilitychange",a),u.push(()=>document.removeEventListener("visibilitychange",a))}return()=>{for(let i of u)i()}}var dt="https://api.sentient-ui.com/v1/events",N=new Map,ut=null;function cn(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var dn=3;function Fe(){return ke()}function Pe(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function un(){let e=new WeakMap,t=new Map,n=!1,c=(a,r,o)=>{let s=a.get(r);return o===null?s?!0:(a.set(r,new Set),!1):s?s.has(o)?!0:(s.add(o),!1):(a.set(r,new Set([o])),!1)},u=typeof window!="undefined"&&"event"in window,i=()=>{if(!u)return;let a=window.event;return typeof Event=="function"&&a instanceof Event?a:void 0},p=()=>{if(u){Promise.resolve().then(()=>{n=!1,t.clear()});return}let a=!1,r=()=>{a||(a=!0,n=!1,t.clear())};if(setTimeout(r,0),typeof MessageChannel=="function"){let o=new MessageChannel;o.port1.onmessage=()=>{o.port1.close(),o.port2.close(),r()},o.port2.postMessage(0)}};return{firedBefore(a,r){let o=i();if(o){let l=e.get(o);return l||(l=new Map,e.set(o,l)),c(l,a,r)}let s=c(t,a,r);return!s&&!n&&(n=!0,p()),s}}}var pt=new Set;function pn(e,t,n){let c=typeof window=="undefined"?null:window.history;if(!c)return()=>{};let u=!1,i,p=()=>{if(u)return;let o=Pe();!o||o===i||(i=o,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${o}`))},a=[];for(let o of["pushState","replaceState"]){let s=c[o],l=function(...y){let b=s.apply(this,y);return p(),b};c[o]=l,a.push([o,s,l])}window.addEventListener("popstate",p);let r=Pe();return r&&pt.has(`${t}:${r}`)?i=r:p(),()=>{if(!u){u=!0,window.removeEventListener("popstate",p);for(let[o,s,l]of a)c[o]===l&&(c[o]=s)}}}var xe={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function gn(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,c]of t)n.startsWith("utm_")&&(e[n]=c);return e}catch(e){return{}}}function gt(e){return e.replace(/\/events\/?$/,"")}function je(){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 fn(e){var a;if(typeof window=="undefined")return;let t=e!=null?e:ut;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=N.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:c,upgrade:u}=n;if(!u||c.respectDoNotTrack!==!1&&je())return;let i=ft(oe(k({},c),{consent:!0}));u(i);let p=(a=N.get(t))==null?void 0:a.dispose;N.set(t,{config:oe(k({},c),{consent:!0}),upgrade:null,dispose:p})}function mn(e){var a;let t=e.preConsentBehavior==="statistical_winner",n=gt((a=e.ingestUrl)!=null?a:dt),c={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},u={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(r,o,s){if(!t)return null;try{let l=new URLSearchParams({componentId:r});for(let D of o!=null?o:[])l.append("variantIds[]",D);let y=await fetch(`${n}/winner?${l.toString()}`,{headers:c});return y.ok?{variantId:(await y.json()).variantId,assignmentTtlMs:0}:o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null}catch(l){return o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},i={track:r=>u.track(r),goal:((r,o,s,l)=>u.goal(r,o,s,l)),componentGoal:(r,o,s)=>u.componentGoal(r,o,s),identify:r=>u.identify(r),getAssignment:(r,o)=>u.getAssignment(r,o),assign:(r,o,s,l)=>u.assign(r,o,s,l),decide:r=>u.decide(r),getSlotResult:r=>u.getSlotResult(r),getPersona:()=>u.getPersona(),fetchWeights:()=>u.fetchWeights(),getGraph:()=>u.getGraph(),dispose:()=>u.dispose(),destroy:()=>u.destroy()};function p(r){u=r}return{proxy:i,setInner:p}}function ft(e){var w,H,ee,F,le,V,ne,X,He;if(typeof window=="undefined")return xe;ut=e.apiKey;let t=N.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(d){}let n=e.respectDoNotTrack!==!1&&je(),c=e.consent===!1||n,u=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!u&&e.localMode!==!1)return c?(N.set(e.apiKey||"local",{config:e,upgrade:null}),xe):(N.set(e.apiKey||"local",{config:e,upgrade:null}),lt(e));if(c){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."),N.set(e.apiKey,{config:e,upgrade:null}),xe;let{proxy:d,setInner:g}=mn(e);return N.set(e.apiKey,{config:e,upgrade:n?null:g}),d}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."),xe;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),xe;let i=(w=e.ingestUrl)!=null?w:dt,p=Date.now(),a=Ie({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=tt(void 0,e.apiKey),o=Ze({ingestUrl:i,apiKey:e.apiKey}),s=gt(i),l={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},y=new Set,b=et({url:`${s}/goals`,apiKey:e.apiKey,headers:l,onDrop:(d,g)=>{if(!e.debug){if(y.has(g))return;y.add(g)}console.warn(`[sentient] goal dropped (HTTP ${g}) \u2014 this will not be retried. `+(g===400?"The session was not found: call init() and let the session upsert complete before firing goals.":g===401||g===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),d)}}),D=ye((H=navigator.userAgent)!=null?H:""),C=typeof window!="undefined"?window.location.origin:void 0,_=he((ee=document.referrer)!=null?ee:"",C),O=(F=e.sessionSegment)!=null?F:`${D}:${_}`,K=new Map,A=new Map,S=null,R=d=>{for(let g of d)A.has(g.id)||A.set(g.id,ie(g))};if(e.initialSlots)for(let[d,g]of Object.entries(e.initialSlots))A.set(d,g);let G=Re(e.apiKey);if(G)for(let[d,g]of Object.entries(G.slots))A.has(d)||A.set(d,g);let m={low:.15,medium:.5,high:.85};if(e.initialPersona)S=k({},e.initialPersona);else{let d=document.documentElement.dataset;d.sentientPersona?S={persona:d.sentientPersona,confidence:(V=m[(le=d.sentientConfidence)!=null?le:"low"])!=null?V:.15}:G&&(S={persona:G.persona,confidence:(ne=m[G.band])!=null?ne:.15})}if(e.initialAssignments)for(let[d,g]of Object.entries(e.initialAssignments))r.set(d,O,{variantId:g,assignedAt:Date.now(),segment:O,confidence:1});let E=Promise.resolve(),Q=a.getSessionId();if(Q){let d=Se((X=document.referrer)!=null?X:""),g=k(k(k({sessionId:Q,deviceClass:D,trafficSource:_,referrerDomain:d,utmParams:gn(),timeOfDay:ve(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:a.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||me((He=navigator.userAgent)!=null?He:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),h=async()=>{for(let T=0;;T++){try{let I=await fetch(`${s}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(g),headers:l});if(I.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(I.ok||re(I)==="dropped")return}catch(I){}if(T>=dn){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(I=>setTimeout(I,q(T+1)))}};try{E=h()}catch(T){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:o});let J=un(),M=null,j=!1,f={goal(d,g={},h=1,T=0){var ce,$,de,x,Y,be,L;let I=a.getSessionId();if(!I)return;let v=cn(g)?g:{metadata:g},z=[d,(ce=v.externalId)!=null?ce:"",($=v.stepIndex)!=null?$:T,(de=v.weight)!=null?de:h].join("\0"),W=v.value!==void 0?`${v.value}\0${(x=v.currency)!=null?x:""}`:null;if(J.firedBefore(z,W)){e.debug&&console.log(`[sentient] goal("${d}") already recorded for this action \u2014 not sent twice`);return}let B=Fe(),U={sessionId:I,name:d,metadata:(Y=v.metadata)!=null?Y:{},weight:(be=v.weight)!=null?be:h,stepIndex:(L=v.stepIndex)!=null?L:T,goalId:B,value:v.value,currency:v.currency,externalId:v.externalId};e.debug&&console.log("[sentient] goal",U);let P={id:B,body:JSON.stringify(U)};E.then(()=>b.send(P))},componentGoal(d,g,h){var B,U,P;let T=a.getSessionId();if(!T)return;let I=r.get(d,O),v=I?null:(B=A.get(d))!=null?B:null;if(!I&&v===null){e.debug&&console.warn(`[sentient] componentGoal("${d}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let z=I?I.variantId:Te(v),W={id:Fe(),sessionId:T,projectId:e.apiKey,componentId:d,variantId:z,eventType:"goal_achieved",goalType:g,payload:k({reward:(U=h==null?void 0:h.reward)!=null?U:1,goalValue:h==null?void 0:h.value,currency:h==null?void 0:h.currency},(P=h==null?void 0:h.metadata)!=null?P:{}),timestamp:Date.now(),timeInSession:Date.now()-p,path:Pe()};e.debug&&console.log("[sentient] componentGoal",W),E.then(()=>o.push(W))},identify(d){let g=a.getSessionId();g&&E.then(()=>{fetch(`${s}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:g,userId:d,ephemeral:a.isEphemeral()}),headers:l}).catch(()=>{})})},track(d){let g=a.getSessionId();if(!g)return;let h=oe(k({path:Pe()},d),{id:Fe(),sessionId:g,timestamp:Date.now(),timeInSession:Date.now()-p});e.debug&&console.log("[sentient] track",h),E.then(()=>o.push(h))},getAssignment(d,g){return r.get(d,g)},async assign(d,g,h,T){let I=a.getSessionId();if(!I)return null;let v=r.get(d,O);if(v&&(g!=null&&g.length||v.content!==void 0)){let B=v.ttlMs&&v.ttlMs>0?Math.max(0,v.assignedAt+v.ttlMs-Date.now()):0;return{variantId:v.variantId,assignmentTtlMs:B,content:v.content}}let z=K.get(d);if(z)return z;let W=(async()=>{await E;try{let B={sessionId:I,componentId:d,variantIds:g};T!==void 0?B.agentDataByVariant=T:h!==void 0&&(B.agentData=h);let U=await fetch(`${s}/assign`,{method:"POST",body:JSON.stringify(B),headers:l});if(!U.ok)return null;let P=await U.json();return r.set(d,O,k({variantId:P.variantId,assignedAt:Date.now(),segment:O,confidence:1,content:P.content},P.assignmentTtlMs&&P.assignmentTtlMs>0?{ttlMs:P.assignmentTtlMs}:{})),P}catch(B){return null}finally{K.delete(d)}})();return K.set(d,W),W},async decide(d){var T,I,v,z,W,B,U,P,ce;let g=a.getSessionId();if(!g)return null;let h=(T=d.slots)!=null?T:[];await E;try{let $={sessionId:g};d.sections&&d.sections.length>0&&($.sections=d.sections.map(L=>({id:L}))),$.components=(I=d.components)!=null?I:[],h.length>0&&($.slots=h.map(we)),d.slotsFrom==="registry"&&($.slotsFrom="registry"),d.v&&($.v=d.v),e.persona&&($.persona=e.persona);let de=await fetch(`${s}/decide`,{method:"POST",body:JSON.stringify($),headers:l});if(!de.ok)return R(h),null;let x=await de.json(),Y={};for(let L of h)Y[L.id]=(z=(v=x.slots)==null?void 0:v[L.id])!=null?z:ie(L);if(x.slots)for(let[L,ue]of Object.entries(x.slots))L in Y||(Y[L]=ue);for(let[L,ue]of Object.entries(Y))A.set(L,ue);let be=S!=null&&S.persona!=="unknown";x.persona&&!(x.persona==="unknown"&&be)?S={persona:x.persona,confidence:(W=x.confidence)!=null?W:0}:S||(S={persona:"unknown",confidence:0});for(let[L,ue]of Object.entries((B=x.assignments)!=null?B:{}))r.set(L,O,{variantId:ue,assignedAt:Date.now(),segment:O,confidence:1});return ae(e.apiKey,k(k({v:1,persona:S.persona,band:(0,We.confidenceBand)(S.confidence),slots:Object.fromEntries(A),layoutOrder:(U=x.layoutOrder)!=null?U:null,savedAt:Date.now()},x.slotConfig?{slotConfig:x.slotConfig}:{}),x.palette?{palette:x.palette}:{})),k(k(k(k({layoutOrder:(P=x.layoutOrder)!=null?P:null,assignments:(ce=x.assignments)!=null?ce:{},slots:Y,persona:S.persona,confidence:S.confidence},x.slotConfig?{slotConfig:x.slotConfig}:{}),x.goals?{goals:x.goals}:{}),x.sectionMap?{sectionMap:x.sectionMap}:{}),x.palette?{palette:x.palette}:{})}catch($){return R(h),null}},getSlotResult(d){var g;return(g=A.get(d))!=null?g:null},getPersona(){return S?{persona:S.persona,confidence:S.confidence,band:(0,We.confidenceBand)(S.confidence)}:null},async fetchWeights(){var d;try{let g=await fetch(`${s}/weights`,{headers:l});return g.ok?(d=(await g.json()).components)!=null?d:[]:[]}catch(g){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var d;M==null||M(),j=!0,o.destroy(),b.destroy(),((d=N.get(e.apiKey))==null?void 0:d.dispose)===f.dispose&&N.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var d;M==null||M(),j=!0,o.destroy(),b.destroy(),a.destroy(),((d=N.get(e.apiKey))==null?void 0:d.dispose)===f.dispose&&N.delete(e.apiKey);try{localStorage.removeItem(te+e.apiKey),localStorage.removeItem(Ke(e.apiKey)),localStorage.removeItem(Ge(e.apiKey))}catch(g){}e.debug&&console.log("[sentient] destroyed")}};if(N.set(e.apiKey,{config:e,upgrade:null,dispose:f.dispose}),M=pn(f,e.apiKey,d=>{E.then(()=>{j||pt.add(d)})}),e.debug){let d=window;d.__sentient&&(d.__sentient.client=f)}return f}0&&(module.exports={AGENT_INTENTS,BLOCK_ALIGNS,BLOCK_EMPHASES,BLOCK_FITS,BLOCK_GAPS,BLOCK_GRID_COLUMNS,BLOCK_HEADING_LEVELS,BLOCK_JUSTIFIES,BLOCK_RATIOS,BLOCK_SIZES,BLOCK_TEXT_ALIGNS,BLOCK_TONES,BLOCK_WEIGHTS,LEGACY_SESSION_COOKIE_NAME,LOCAL_MODE_BANNER,MAX_BLOCK_ARMS,MAX_BLOCK_CHILDREN,MAX_BLOCK_DEPTH,MAX_BLOCK_NODES,MAX_BLOCK_TEXT_LEN,PROD_KEYLESS_ERROR,SNAPSHOT_STORAGE_KEY_PREFIX,agentIntent,agentUaList,armOfResult,attachMicroSignalDetectors,baselineResultFor,baselineSlots,classifiedAgents,deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,grantConsent,init,isDoNotTrackEnabled,matchedAgentToken,readSnapshot,referrerDomainFromReferer,renderPrePaintScript,sessionCookieName,toWireSlot,uaTokenMatch,writeSnapshot});
1
+ "use strict";var wt=Object.create;var fe=Object.defineProperty,xt=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,kt=Object.getOwnPropertyDescriptors,Et=Object.getOwnPropertyNames,Ye=Object.getOwnPropertySymbols,Ct=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable;var qe=(e,t,n)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,k=(e,t)=>{for(var n in t||(t={}))Ze.call(t,n)&&qe(e,n,t[n]);if(Ye)for(var n of Ye(t))It.call(t,n)&&qe(e,n,t[n]);return e},se=(e,t)=>xt(e,kt(t));var _t=(e,t)=>{for(var n in t)fe(e,n,{get:t[n],enumerable:!0})},et=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of Et(t))!Ze.call(e,p)&&p!==n&&fe(e,p,{get:()=>t[p],enumerable:!(l=bt(t,p))||l.enumerable});return e};var At=(e,t,n)=>(n=e!=null?wt(Ct(e)):{},et(t||!e||!e.__esModule?fe(n,"default",{value:e,enumerable:!0}):n,e)),Ot=e=>et(fe({},"__esModule",{value:!0}),e);var xn={};_t(xn,{AGENT_INTENTS:()=>Be,BLOCK_ALIGNS:()=>Xt,BLOCK_EMPHASES:()=>tn,BLOCK_FITS:()=>rn,BLOCK_GAPS:()=>Vt,BLOCK_GRID_COLUMNS:()=>sn,BLOCK_HEADING_LEVELS:()=>an,BLOCK_JUSTIFIES:()=>Yt,BLOCK_RATIOS:()=>on,BLOCK_SIZES:()=>qt,BLOCK_TEXT_ALIGNS:()=>nn,BLOCK_TONES:()=>en,BLOCK_WEIGHTS:()=>Zt,LEGACY_SESSION_COOKIE_NAME:()=>Ke,LOCAL_MODE_BANNER:()=>We,MAX_BLOCK_ARMS:()=>un,MAX_BLOCK_CHILDREN:()=>dn,MAX_BLOCK_DEPTH:()=>cn,MAX_BLOCK_NODES:()=>ln,MAX_BLOCK_TEXT_LEN:()=>pn,PROD_KEYLESS_ERROR:()=>Me,SNAPSHOT_STORAGE_KEY_PREFIX:()=>te,_registerConsentUpgradeInit:()=>gn,agentIntent:()=>at,agentUaList:()=>ye,armOfResult:()=>De,attachMicroSignalDetectors:()=>ft,baselineResultFor:()=>le,baselineSlots:()=>dt,classifiedAgents:()=>lt,deriveSessionSegment:()=>ct,detectDeviceClass:()=>Se,detectTimeOfDay:()=>xe,detectTrafficSource:()=>ve,grantConsent:()=>vn,init:()=>vt,isDoNotTrackEnabled:()=>Qe,matchedAgentToken:()=>Fe,readSnapshot:()=>ce,referrerDomainFromReferer:()=>we,renderPrePaintScript:()=>ut,sessionCookieName:()=>Ie,toWireSlot:()=>be,uaTokenMatch:()=>he,writeSnapshot:()=>de});module.exports=Ot(xn);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 t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===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)})}function me(e){return e?`_${e.slice(0,12)}`:""}var Ke="_snt_uid";function Ie(e){return`${Ke}${me(e)}`}var Rt="_snt_uid",Tt=365,_e="_snt_uid";function Bt(){return Ce()}function tt(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Dt(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(l){}}function Ge(e){try{return localStorage.getItem(e)}catch(t){return null}}function nt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function ot(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function Lt(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Pt(e){try{sessionStorage.removeItem(e)}catch(t){}}function Mt(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 Nt(e){try{localStorage.removeItem(e)}catch(t){}}function Kt(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Gt={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function Ae(e){var E,R,T,C,G,$,_;if(typeof window=="undefined")return Gt;let t=me(e==null?void 0:e.apiKey),n=(E=e==null?void 0:e.cookieName)!=null?E:Ie(e==null?void 0:e.apiKey),l=`${_e}${t}`,p=`${_e}_tomb${t}`,c=((R=e==null?void 0:e.cookieTTLDays)!=null?R:Tt)*24*60*60,i=v=>v&&v.length>0?v:null,u=()=>{var v,D;return t&&!(e!=null&&e.cookieName)&&Ge(p)===null?(D=(v=i(tt(Rt)))!=null?v:i(Ge(_e)))!=null?D:i(ot(_e)):null},s=(_=($=(G=(C=(T=i(tt(n)))!=null?T:i(Ge(l)))!=null?C:i(ot(l)))!=null?G:u())!=null?$:i(e==null?void 0:e.ssrSessionId))!=null?_:Bt();Dt(n,s,c);let o=nt(l,s),r=Mt(n),y=o?!1:Lt(l,s),h=!o&&!r&&!y;return{getSessionId:()=>s,isEphemeral:()=>h,destroy:()=>{s=null,Kt(n),Nt(l),Pt(l),t&&!(e!=null&&e.cookieName)&&nt(p,"1")}}}function X(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function ie(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 Oe(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let l=JSON.parse(n);return Array.isArray(l)?(localStorage.removeItem(e),l.slice(-t)):[]}catch(n){return[]}}function Y(e,t,n){try{let l=(()=>{try{let a=localStorage.getItem(n);if(!a)return[];let c=JSON.parse(a);return Array.isArray(c)?c:[]}catch(a){return[]}})(),p=new Map;for(let a of l)p.set(a.id,a);for(let a of e)p.set(a.id,a);localStorage.setItem(n,JSON.stringify([...p.values()].slice(-t)))}catch(l){}}function Re(e,t){try{let n=localStorage.getItem(t);if(!n)return;let l=JSON.parse(n);if(!Array.isArray(l))return;let p=new Set(e),a=l.filter(c=>!p.has(c.id));if(a.length===l.length)return;a.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(a))}catch(n){}}var Ut=500,$t=56*1024;function Ue(e){return`_snt_retry_${e.slice(0,12)}`}var Ft={push:()=>{},flush:()=>{},destroy:()=>{}};function rt(e){var q,M,ne;if(typeof window=="undefined")return Ft;let t=(q=e.flushIntervalMs)!=null?q:5e3,n=(M=e.maxBatchSize)!=null?M:20,l=(ne=e.maxRetrySize)!=null?ne:100,p=e.ingestUrl,a=e.apiKey,c=Ue(a),i=[],u=new Set,s=[],o=f=>{for(let x of f)r.delete(x),!u.has(x)&&(u.add(x),s.push(x));for(;s.length>Ut;){let x=s.shift();x&&u.delete(x)}Re(f,c)},r=new Set,y=()=>{for(;i.length>l;){let f=i.shift();f&&r.delete(f.id)}},h=f=>{u.has(f.id)||r.has(f.id)||(r.add(f.id),i.push(f),y())},E=f=>{for(let x of f)u.has(x.id)||(r.add(x.id),i.push(x));y()},R=Oe(c,l);for(let f of R)h(f);let T=0,C=0,G=(f,x=!0)=>{if(f.length===0)return;let j=JSON.stringify(f),Z=f.map(z=>z.id),F;try{F=fetch(p,{method:"POST",keepalive:!0,body:j,headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})}catch(z){Y(f,l,c),E(f),C++,T=Date.now()+X(C);return}let ue=z=>{if(ie(z)!=="retry"){if(!z.ok&&x){let oe=f.filter(Q=>Q.eventType!=="pageview");if(oe.length>0&&oe.length<f.length){o(f.filter(Q=>Q.eventType==="pageview").map(Q=>Q.id)),G(oe,!1);return}}o(Z),C=0,T=0;return}Y(f,l,c),E(f),C++,T=Date.now()+X(C)};F instanceof Promise?F.then(ue).catch(()=>{Y(f,l,c),E(f),C++,T=Date.now()+X(C)}):ue(F)},$=typeof TextEncoder!="undefined"?new TextEncoder:null,_=f=>$?$.encode(f).length:f.length,v=f=>{let x=[],j=2;for(let Z of f){let F=_(JSON.stringify(Z))+1;if(x.length>0&&j+F>$t||x.length>=n)break;x.push(Z),j+=F}return x},D=()=>{try{if(Date.now()<T)return;for(;i.length>0&&!(Date.now()<T);){let f=i.filter(j=>!u.has(j.id));if(i.length=0,f.length===0)break;let x=v(f);if(x.length===0)break;x.length<f.length&&i.push(...f.slice(x.length)),G(x)}}catch(f){}},m=!0,O=null;O=setInterval(()=>{m&&D()},t);let P=()=>{document.visibilityState==="hidden"&&D()},W=()=>{D()};return document.addEventListener("visibilitychange",P),window.addEventListener("pagehide",W),{push(f){h(f),i.length>=n&&D()},flush:D,destroy(){m=!1,O!==null&&(clearInterval(O),O=null),document.removeEventListener("visibilitychange",P),window.removeEventListener("pagehide",W),D()}}}var Wt=200;function $e(e){return`_snt_goal_retry_${e.slice(0,12)}`}var jt={send:()=>{},flush:()=>{},destroy:()=>{}};function st(e){var _,v,D;if(typeof window=="undefined")return jt;let t=(_=e.flushIntervalMs)!=null?_:5e3,n=(v=e.maxRetrySize)!=null?v:100,l=(D=e.maxPerFlush)!=null?D:5,p=$e(e.apiKey),a=[],c=new Set,i=new Set,u=[],s=0,o=0,r=!1,y=m=>{for(c.delete(m.id),i.has(m.id)||(i.add(m.id),u.push(m.id));u.length>Wt;){let O=u.shift();O&&i.delete(O)}Re([m.id],p)},h=m=>{Y([m],n,p),!i.has(m.id)&&!c.has(m.id)&&(c.add(m.id),a.push(m)),Date.now()>=s&&(o++,s=Date.now()+X(o))},E=m=>{let O;try{O=fetch(e.url,{method:"POST",keepalive:!0,body:m.body,headers:e.headers})}catch(W){h(m);return}let P=W=>{var M;let q=ie(W);if(q==="retry"){h(m);return}q==="dropped"&&((M=e.onDrop)==null||M.call(e,m,W.status)),y(m),o=0,s=0};O instanceof Promise?O.then(P).catch(()=>h(m)):P(O)},R=()=>{try{if(r||Date.now()<s)return;let m=0;for(;a.length>0&&m<l&&!(Date.now()<s);){let O=a.shift();c.delete(O.id),!i.has(O.id)&&(m++,E(O))}}catch(m){}},T=Oe(p,n);for(let m of T)c.has(m.id)||(c.add(m.id),a.push(m));T.length>0&&Y(T,n,p);let C=setInterval(R,t),G=()=>{document.visibilityState==="hidden"&&R()},$=()=>R();return document.addEventListener("visibilitychange",G),window.addEventListener("pagehide",$),{send(m){if(!r&&!(i.has(m.id)||c.has(m.id))){if(Date.now()<s){Y([m],n,p),c.add(m.id),a.push(m);return}E(m)}},flush:R,destroy(){clearInterval(C),document.removeEventListener("visibilitychange",G),window.removeEventListener("pagehide",$),R(),r=!0}}}var Ht=1800*1e3;function Te(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function it(e=Ht,t){let n=new Map,l=`_snt_asgn${me(t)}_`,p=(s,o)=>`${l}${encodeURIComponent(s)}:${encodeURIComponent(o)}`,a=s=>{let o=s.slice(l.length),r=o.indexOf(":");if(r<0)return null;try{return{componentId:decodeURIComponent(o.slice(0,r)),segment:decodeURIComponent(o.slice(r+1))}}catch(y){return null}},c=()=>{try{let s=[];for(let o=0;o<localStorage.length;o++){let r=localStorage.key(o);r!=null&&r.startsWith(l)&&s.push(r)}return s}catch(s){return[]}},i=s=>s.assignedAt+(s.ttlMs&&s.ttlMs>0?s.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let s of c())try{let o=localStorage.getItem(s);if(!o)continue;let r=JSON.parse(o);if(i(r)){localStorage.removeItem(s);continue}let y=a(s);if(!y)continue;n.set(Te(y.componentId,y.segment),r)}catch(o){}})(),{get(s,o){let r=n.get(Te(s,o));return r?i(r)?(n.delete(Te(s,o)),null):r:null},set(s,o,r){let y=Te(s,o);n.set(y,r);try{localStorage.setItem(p(s,o),JSON.stringify(r))}catch(h){}},clear(){n.clear();for(let s of c())try{localStorage.removeItem(s)}catch(o){}}}}var ye=["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 he(e){return Fe(e)!==null}function Fe(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=ye.find(l=>t.includes(l.toLowerCase())))!=null?n:null}var Be={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 at(e){if(!e)return"other";let t=ye.find(n=>n.toLowerCase()===e.toLowerCase());return t&&Be[t]||"other"}function lt(){var t;let e={user:[],search:[],training:[],other:[]};for(let n of ye)e[(t=Be[n])!=null?t:"other"].push(n);return e}function Se(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 ve(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(p){}let l=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(l)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(l)?"social":"referral"}catch(n){return"direct"}}function we(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function xe(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function ct(e){let t=zt("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function zt(e,t){var a,c,i,u,s,o,r;let n=(c=(a=t==null?void 0:t.userAgent)==null?void 0:a.trim())!=null?c:"",l=(u=(i=t==null?void 0:t.referer)==null?void 0:i.trim())!=null?u:"",p=(s=t==null?void 0:t.now)!=null?s:new Date;return{sessionId:e,ephemeral:!1,utmParams:(o=t==null?void 0:t.utmParams)!=null?o:{},deviceClass:n?Se(n):"desktop",trafficSource:l?ve(l,t==null?void 0:t.appOrigin):"direct",referrerDomain:we(l),timeOfDay:xe(p),dayOfWeek:(r=["sun","mon","tue","wed","thu","fri","sat"][p.getDay()])!=null?r:"sun",automation:(t==null?void 0:t.webdriver)===!0||he(n)}}var ae=require("@sentientui/policy");function be(e){return k(k(k({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function le(e){let t=be(e);return(0,ae.slotResultFor)(t,(0,ae.slotBaselineArm)(t))}function dt(e){let t={};for(let n of e)t[n.id]=le(n);return t}function De(e){return typeof e=="string"?e:(0,ae.canonicalArm)(e)}var te="_snt_snap:",Qt=["low","medium","high"];function ce(e){try{let t=localStorage.getItem(te+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!Qt.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function de(e,t){try{localStorage.setItem(te+e,JSON.stringify(t))}catch(n){}}function ut(e){return"(function(){try{var r=localStorage.getItem("+JSON.stringify(te+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){}})();'}var He=require("@sentientui/policy");var Pe=require("@sentientui/policy");var Me="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",We="[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.",pt=!1,Le=!1;function Jt(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function gt(e){var s;let t=Ae({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(s=t.getSessionId())!=null?s:"local",l=Jt(),p=import("@sentientui/core/local").then(o=>{let r=o;return r.LOCAL_ENGINE_AVAILABLE?(pt||(pt=!0,console.info(We)),r):(Le||(Le=!0,console.error(Me)),null)}).catch(()=>(Le||(Le=!0,console.error(Me)),null)),a=null,c={low:.15,medium:.5,high:.85},i=(()=>{var r;if(e.initialPersona)return k({},e.initialPersona);let o=ce(e.apiKey||"local");return o?{persona:o.persona,confidence:(r=c[o.band])!=null?r:.15}:null})();function u(o){let r=document.documentElement;r.dataset.sentientPersona===void 0&&(r.dataset.sentientPersona=o.persona,r.dataset.sentientConfidence=(0,Pe.confidenceBand)(o.confidence))}return{isLocal:!0,async decide(o){var h,E,R;let r=await p;if(!r)return null;let y=r.createLocalEngine({sessionId:n,forcedPersona:l}).decide(o);return a=se(k({},y),{layoutOrder:(E=(h=y.layoutOrder)!=null?h:a==null?void 0:a.layoutOrder)!=null?E:null,slots:k(k({},(R=a==null?void 0:a.slots)!=null?R:{}),y.slots)}),de(e.apiKey||"local",{v:1,persona:a.persona,band:(0,Pe.confidenceBand)(a.confidence),slots:a.slots,layoutOrder:a.layoutOrder,savedAt:Date.now()}),u(y),y},getSlotResult(o){var r,y,h;return(h=(y=a==null?void 0:a.slots[o])!=null?y:(r=e.initialSlots)==null?void 0:r[o])!=null?h:null},getPersona(){let o=a!=null?a:i;return o?{persona:o.persona,confidence:o.confidence,band:(0,Pe.confidenceBand)(o.confidence)}:null},async assign(o,r){var E;let y=await p;return!y||!r||r.length===0?r!=null&&r[0]?{variantId:r[0],assignmentTtlMs:0}:null:{variantId:(E=y.createLocalEngine({sessionId:n,forcedPersona:l}).decide({components:[{id:o,variantIds:r}]}).assignments[o])!=null?E:r[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}var Vt=["none","sm","md","lg"],Xt=["start","center","end","stretch"],Yt=["start","center","end","between"],qt=["sm","md","lg"],Zt=["normal","medium","bold"],en=["default","muted","accent"],tn=["primary","secondary","ghost"],nn=["left","center","right"],on=["auto","square","landscape","wide"],rn=["cover","contain"],sn=[2,3,4],an=[2,3,4],ln=64,cn=5,dn=12,un=4,pn=500;function ft(e,t,n,l){let p=[];{let i=!1,u=[],s=()=>{if(i)return;let o=Date.now();for(u.push(o);u.length>0&&o-u[0]>500;)u.shift();u.length>=3&&(i=!0,e("rage_click"))};t.addEventListener("click",s),p.push(()=>t.removeEventListener("click",s))}{let a=!1,c=i=>{if(a||!(i.target instanceof Node)||!t.contains(i.target)&&t!==i.target)return;a=!0;let u=typeof window!="undefined"?window.getSelection():null,s=u?u.toString().length:0;e("text_copy",{selectionLength:s})};document.addEventListener("copy",c),p.push(()=>document.removeEventListener("copy",c))}{let a=!1,c=!1,i=null,u=()=>{i!==null&&(clearTimeout(i),i=null)},s=()=>{a||!c||(u(),i=setTimeout(()=>{!a&&c&&(a=!0,e("scroll_hesitation"))},3e3))},o=()=>{u(),s()},r=h=>{for(let E of h)c=E.intersectionRatio>.3,c?s():u()},y=new IntersectionObserver(r,{threshold:[.3]});y.observe(t),window.addEventListener("scroll",o,{passive:!0}),p.push(()=>{y.disconnect(),window.removeEventListener("scroll",o),u()})}if((l==null?void 0:l.tabLoss)!==!1){let a=!1,c=n!=null?n:Date.now(),i=()=>{if(a||document.visibilityState!=="hidden")return;let u=Date.now()-c;u<15e3&&(a=!0,e("tab_loss",{timeOnPage:u}))};document.addEventListener("visibilitychange",i),p.push(()=>document.removeEventListener("visibilitychange",i))}return()=>{for(let a of p)a()}}var mt="https://api.sentient-ui.com/v1/events",K=new Map,yt=null;function gn(e,t){let n=K.get(e);n&&n.upgrade&&(n.reinit=t)}function fn(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var mn=3;function je(){return Ce()}function Ne(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function yn(){let e=new WeakMap,t=new Map,n=!1,l=(i,u,s)=>{let o=i.get(u);return s===null?o?!0:(i.set(u,new Set),!1):o?o.has(s)?!0:(o.add(s),!1):(i.set(u,new Set([s])),!1)},p=typeof window!="undefined"&&"event"in window,a=()=>{if(!p)return;let i=window.event;return typeof Event=="function"&&i instanceof Event?i:void 0},c=()=>{if(p){Promise.resolve().then(()=>{n=!1,t.clear()});return}let i=!1,u=()=>{i||(i=!0,n=!1,t.clear())};if(setTimeout(u,0),typeof MessageChannel=="function"){let s=new MessageChannel;s.port1.onmessage=()=>{s.port1.close(),s.port2.close(),u()},s.port2.postMessage(0)}};return{firedBefore(i,u){let s=a();if(s){let r=e.get(s);return r||(r=new Map,e.set(s,r)),l(r,i,u)}let o=l(t,i,u);return!o&&!n&&(n=!0,c()),o}}}var ht=new Set;function hn(e,t,n){let l=typeof window=="undefined"?null:window.history;if(!l)return()=>{};let p=!1,a,c=()=>{if(p)return;let s=Ne();!s||s===a||(a=s,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${s}`))},i=[];for(let s of["pushState","replaceState"]){let o=l[s],r=function(...y){let h=o.apply(this,y);return c(),h};l[s]=r,i.push([s,o,r])}window.addEventListener("popstate",c);let u=Ne();return u&&ht.has(`${t}:${u}`)?a=u:c(),()=>{if(!p){p=!0,window.removeEventListener("popstate",c);for(let[s,o,r]of i)l[s]===r&&(l[s]=o)}}}var ke={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function Sn(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,l]of t)n.startsWith("utm_")&&(e[n]=l);return e}catch(e){return{}}}function St(e){return e.replace(/\/events\/?$/,"")}function Qe(){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 vn(e){var u;if(typeof window=="undefined")return;let t=e!=null?e:yt;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=K.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:l,upgrade:p,reinit:a}=n;if(!p){n.upgradeBlockedReason&&console.warn(n.upgradeBlockedReason);return}if(l.respectDoNotTrack!==!1&&Qe())return;let c=(a!=null?a:vt)(se(k({},l),{consent:!0}));p(c);let i=(u=K.get(t))==null?void 0:u.dispose;K.set(t,{config:se(k({},l),{consent:!0}),upgrade:null,dispose:i})}function wn(e){var s;let t=e.preConsentBehavior==="statistical_winner",n=St((s=e.ingestUrl)!=null?s:mt),l={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},p=new Map,a=new Map,c={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(o,r,y){if(!t)return Promise.resolve(null);let h=p.get(o);return h?Promise.resolve(h):ze(a,o,async()=>{try{let E=new URLSearchParams({componentId:o});for(let G of r!=null?r:[])E.append("variantIds[]",G);let R=await fetch(`${n}/winner?${E.toString()}`,{headers:l});if(!R.ok)return r!=null&&r[0]?{variantId:r[0],assignmentTtlMs:0}:null;let C={variantId:(await R.json()).variantId,assignmentTtlMs:0};return p.set(o,C),C}catch(E){return r!=null&&r[0]?{variantId:r[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},i={track:o=>c.track(o),goal:((o,r,y,h)=>c.goal(o,r,y,h)),componentGoal:(o,r,y)=>c.componentGoal(o,r,y),identify:o=>c.identify(o),getAssignment:(o,r)=>c.getAssignment(o,r),assign:(o,r,y,h)=>c.assign(o,r,y,h),decide:o=>c.decide(o),getSlotResult:o=>c.getSlotResult(o),getPersona:()=>c.getPersona(),fetchWeights:()=>c.fetchWeights(),getGraph:()=>c.getGraph(),dispose:()=>c.dispose(),destroy:()=>c.destroy()};function u(o){c=o}return{proxy:i,setInner:u}}function ze(e,t,n){let l=e.get(t);if(l)return l;let p=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,p),p}function vt(e){var x,j,Z,F,ue,z,oe,Q,Je;if(typeof window=="undefined")return ke;yt=e.apiKey||"local";let t=K.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(d){}let n=e.respectDoNotTrack!==!1&&Qe(),l=e.consent===!1||n,p=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!p&&e.localMode!==!1)return K.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."}),l?ke:gt(e);if(l){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."),K.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."}),ke;let{proxy:d,setInner:g}=wn(e);return K.set(e.apiKey,{config:e,upgrade:n?null:g}),d}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."),ke;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),ke;let a=(x=e.ingestUrl)!=null?x:mt,c=Date.now(),i=Ae({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),u=it(void 0,e.apiKey),s=rt({ingestUrl:a,apiKey:e.apiKey}),o=St(a),r={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},y=new Set,h=st({url:`${o}/goals`,apiKey:e.apiKey,headers:r,onDrop:(d,g)=>{if(!e.debug){if(y.has(g))return;y.add(g)}console.warn(`[sentient] goal dropped (HTTP ${g}) \u2014 this will not be retried. `+(g===400?"The session was not found: call init() and let the session upsert complete before firing goals.":g===401||g===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),d)}}),E=Se((j=navigator.userAgent)!=null?j:""),R=window.location.origin,T=ve((Z=document.referrer)!=null?Z:"",R),C=(F=e.sessionSegment)!=null?F:`${E}:${T}`,G=new Map,$=new Map,_=new Map,v=null,D=d=>{for(let g of d)_.has(g.id)||_.set(g.id,le(g))};if(e.initialSlots)for(let[d,g]of Object.entries(e.initialSlots))_.set(d,g);let m=ce(e.apiKey);if(m)for(let[d,g]of Object.entries(m.slots))_.has(d)||_.set(d,g);let O={low:.15,medium:.5,high:.85};if(e.initialPersona)v=k({},e.initialPersona);else{let d=document.documentElement.dataset;d.sentientPersona?v={persona:d.sentientPersona,confidence:(z=O[(ue=d.sentientConfidence)!=null?ue:"low"])!=null?z:.15}:m&&(v={persona:m.persona,confidence:(oe=O[m.band])!=null?oe:.15})}if(e.initialAssignments)for(let[d,g]of Object.entries(e.initialAssignments))u.set(d,C,{variantId:g,assignedAt:Date.now(),segment:C,confidence:1});let P=Promise.resolve(),W=i.getSessionId();if(W){let d=we((Q=document.referrer)!=null?Q:""),g=k(k(k({sessionId:W,deviceClass:E,trafficSource:T,referrerDomain:d,utmParams:Sn(),timeOfDay:xe(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:i.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||he((Je=navigator.userAgent)!=null?Je:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),S=async()=>{for(let I=0;;I++){try{let A=await fetch(`${o}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(g),headers:r});if(A.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(A.ok||ie(A)==="dropped")return}catch(A){}if(I>=mn){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(A=>setTimeout(A,X(I+1)))}};try{P=S()}catch(I){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:s});let q=yn(),M=null,ne=!1,f={goal(d,g={},S=1,I=0){var pe,ge,re,b,H,Ee,B;let A=i.getSessionId();if(!A)return;let w=fn(g)?g:{metadata:g},N=[d,(pe=w.externalId)!=null?pe:"",(ge=w.stepIndex)!=null?ge:I,(re=w.weight)!=null?re:S].join("\0"),U=w.value!==void 0?`${w.value}\0${(b=w.currency)!=null?b:""}`:null;if(q.firedBefore(N,U)){e.debug&&console.log(`[sentient] goal("${d}") already recorded for this action \u2014 not sent twice`);return}let L=je(),J={sessionId:A,name:d,metadata:(H=w.metadata)!=null?H:{},weight:(Ee=w.weight)!=null?Ee:S,stepIndex:(B=w.stepIndex)!=null?B:I,goalId:L,value:w.value,currency:w.currency,externalId:w.externalId};e.debug&&console.log("[sentient] goal",J);let ee={id:L,body:JSON.stringify(J)};P.then(()=>h.send(ee))},componentGoal(d,g,S){var L,J,ee;let I=i.getSessionId();if(!I)return;let A=u.get(d,C),w=A?null:(L=_.get(d))!=null?L:null;if(!A&&w===null){e.debug&&console.warn(`[sentient] componentGoal("${d}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let N=A?A.variantId:De(w),U={id:je(),sessionId:I,projectId:e.apiKey,componentId:d,variantId:N,eventType:"goal_achieved",goalType:g,payload:k({reward:(J=S==null?void 0:S.reward)!=null?J:1,goalValue:S==null?void 0:S.value,currency:S==null?void 0:S.currency},(ee=S==null?void 0:S.metadata)!=null?ee:{}),timestamp:Date.now(),timeInSession:Date.now()-c,path:Ne()};e.debug&&console.log("[sentient] componentGoal",U),P.then(()=>s.push(U))},identify(d){let g=i.getSessionId();g&&P.then(()=>{fetch(`${o}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:g,userId:d,ephemeral:i.isEphemeral()}),headers:r}).catch(()=>{})})},track(d){let g=i.getSessionId();if(!g)return;let S=se(k({path:Ne()},d),{id:je(),sessionId:g,timestamp:Date.now(),timeInSession:Date.now()-c});e.debug&&console.log("[sentient] track",S),P.then(()=>s.push(S))},getAssignment(d,g){return u.get(d,g)},async assign(d,g,S,I){let A=i.getSessionId();if(!A)return null;let w=u.get(d,C);if(w&&(g!=null&&g.length||w.content!==void 0)){let N=w.ttlMs&&w.ttlMs>0?Math.max(0,w.assignedAt+w.ttlMs-Date.now()):0;return{variantId:w.variantId,assignmentTtlMs:N,content:w.content}}return ze(G,d,async()=>{await P;try{let N={sessionId:A,componentId:d,variantIds:g};I!==void 0?N.agentDataByVariant=I:S!==void 0&&(N.agentData=S);let U=await fetch(`${o}/assign`,{method:"POST",body:JSON.stringify(N),headers:r});if(!U.ok)return null;let L=await U.json();return u.set(d,C,k({variantId:L.variantId,assignedAt:Date.now(),segment:C,confidence:1,content:L.content},L.assignmentTtlMs&&L.assignmentTtlMs>0?{ttlMs:L.assignmentTtlMs}:{})),L}catch(N){return null}})},async decide(d){var w,N;let g=i.getSessionId();if(!g)return null;let S=(w=d.slots)!=null?w:[],I={sessionId:g};d.sections&&d.sections.length>0&&(I.sections=d.sections.map(U=>({id:U}))),I.components=(N=d.components)!=null?N:[],S.length>0&&(I.slots=S.map(be)),d.slotsFrom==="registry"&&(I.slotsFrom="registry"),d.v&&(I.v=d.v),e.persona&&(I.persona=e.persona);let A=JSON.stringify(I);return ze($,A,async()=>{var U,L,J,ee,pe,ge;await P;try{let re=await fetch(`${o}/decide`,{method:"POST",body:A,headers:r});if(!re.ok)return D(S),null;let b=await re.json(),H={};for(let B of S){let V=(U=b.slots)==null?void 0:U[B.id];if(V!==void 0){H[B.id]=V,_.set(B.id,V);continue}let Ve=_.get(B.id);if(Ve!==void 0)H[B.id]=Ve;else{let Xe=le(B);H[B.id]=Xe,_.set(B.id,Xe)}}if(b.slots)for(let[B,V]of Object.entries(b.slots))B in H||(H[B]=V,_.set(B,V));let Ee=v!=null&&v.persona!=="unknown";b.persona&&!(b.persona==="unknown"&&Ee)?v={persona:b.persona,confidence:(L=b.confidence)!=null?L:0}:v||(v={persona:"unknown",confidence:0});for(let[B,V]of Object.entries((J=b.assignments)!=null?J:{}))u.set(B,C,{variantId:V,assignedAt:Date.now(),segment:C,confidence:1});return de(e.apiKey,k(k({v:1,persona:v.persona,band:(0,He.confidenceBand)(v.confidence),slots:Object.fromEntries(_),layoutOrder:(ee=b.layoutOrder)!=null?ee:null,savedAt:Date.now()},b.slotConfig?{slotConfig:b.slotConfig}:{}),b.palette?{palette:b.palette}:{})),k(k(k(k({layoutOrder:(pe=b.layoutOrder)!=null?pe:null,assignments:(ge=b.assignments)!=null?ge:{},slots:H,persona:v.persona,confidence:v.confidence},b.slotConfig?{slotConfig:b.slotConfig}:{}),b.goals?{goals:b.goals}:{}),b.sectionMap?{sectionMap:b.sectionMap}:{}),b.palette?{palette:b.palette}:{})}catch(re){return D(S),null}})},getSlotResult(d){var g;return(g=_.get(d))!=null?g:null},getPersona(){return v?{persona:v.persona,confidence:v.confidence,band:(0,He.confidenceBand)(v.confidence)}:null},async fetchWeights(){var d;try{let g=await fetch(`${o}/weights`,{headers:r});return g.ok?(d=(await g.json()).components)!=null?d:[]:[]}catch(g){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var d;M==null||M(),ne=!0,s.destroy(),h.destroy(),((d=K.get(e.apiKey))==null?void 0:d.dispose)===f.dispose&&K.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var d;M==null||M(),ne=!0,s.destroy(),h.destroy(),i.destroy(),u.clear(),((d=K.get(e.apiKey))==null?void 0:d.dispose)===f.dispose&&K.delete(e.apiKey);try{localStorage.removeItem(te+e.apiKey),localStorage.removeItem(Ue(e.apiKey)),localStorage.removeItem($e(e.apiKey))}catch(g){}e.debug&&console.log("[sentient] destroyed")}};if(K.set(e.apiKey,{config:e,upgrade:null,dispose:f.dispose}),M=hn(f,e.apiKey,d=>{P.then(()=>{ne||ht.add(d)})}),e.debug){let d=window;d.__sentient&&(d.__sentient.client=f)}return f}0&&(module.exports={AGENT_INTENTS,BLOCK_ALIGNS,BLOCK_EMPHASES,BLOCK_FITS,BLOCK_GAPS,BLOCK_GRID_COLUMNS,BLOCK_HEADING_LEVELS,BLOCK_JUSTIFIES,BLOCK_RATIOS,BLOCK_SIZES,BLOCK_TEXT_ALIGNS,BLOCK_TONES,BLOCK_WEIGHTS,LEGACY_SESSION_COOKIE_NAME,LOCAL_MODE_BANNER,MAX_BLOCK_ARMS,MAX_BLOCK_CHILDREN,MAX_BLOCK_DEPTH,MAX_BLOCK_NODES,MAX_BLOCK_TEXT_LEN,PROD_KEYLESS_ERROR,SNAPSHOT_STORAGE_KEY_PREFIX,_registerConsentUpgradeInit,agentIntent,agentUaList,armOfResult,attachMicroSignalDetectors,baselineResultFor,baselineSlots,classifiedAgents,deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,grantConsent,init,isDoNotTrackEnabled,matchedAgentToken,readSnapshot,referrerDomainFromReferer,renderPrePaintScript,sessionCookieName,toWireSlot,uaTokenMatch,writeSnapshot});
2
2
  //# sourceMappingURL=index.js.map