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