@sentientui/react 0.28.0 → 0.29.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 (44) hide show
  1. package/dist/devtools.js +1 -1
  2. package/dist/devtools.js.map +1 -1
  3. package/dist/devtools.mjs +1 -1
  4. package/dist/devtools.mjs.map +1 -1
  5. package/dist/index.d.cts +32 -2
  6. package/dist/index.d.ts +32 -2
  7. package/dist/index.js +2 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +2 -2
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/next/adaptive-root.d.ts +10 -1
  12. package/dist/next/adaptive-root.js +2 -2
  13. package/dist/next/adaptive-root.js.map +1 -1
  14. package/dist/server.d.cts +3 -0
  15. package/dist/server.d.ts +3 -0
  16. package/dist/server.js +1 -1
  17. package/dist/server.js.map +1 -1
  18. package/dist/server.mjs +1 -1
  19. package/dist/server.mjs.map +1 -1
  20. package/dist/testing/msw.d.cts +3 -0
  21. package/dist/testing/msw.d.ts +3 -0
  22. package/dist/testing/msw.js +1 -1
  23. package/dist/testing/msw.js.map +1 -1
  24. package/dist/testing/msw.mjs +1 -1
  25. package/dist/testing/msw.mjs.map +1 -1
  26. package/dist/testing/node.d.cts +3 -0
  27. package/dist/testing/node.d.ts +3 -0
  28. package/dist/testing/node.js +1 -1
  29. package/dist/testing/node.js.map +1 -1
  30. package/dist/testing/node.mjs +1 -1
  31. package/dist/testing/node.mjs.map +1 -1
  32. package/dist/testing/react.d.cts +3 -0
  33. package/dist/testing/react.d.ts +3 -0
  34. package/dist/testing/react.js +1 -1
  35. package/dist/testing/react.js.map +1 -1
  36. package/dist/testing/react.mjs +1 -1
  37. package/dist/testing/react.mjs.map +1 -1
  38. package/dist/testing.d.cts +3 -0
  39. package/dist/testing.d.ts +3 -0
  40. package/dist/testing.js +1 -1
  41. package/dist/testing.js.map +1 -1
  42. package/dist/testing.mjs +1 -1
  43. package/dist/testing.mjs.map +1 -1
  44. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- var pt=Object.defineProperty,vt=Object.defineProperties;var yt=Object.getOwnPropertyDescriptors;var X=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable;var Oe=(e,t,n)=>t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_=(e,t)=>{for(var n in t||(t={}))Ee.call(t,n)&&Oe(e,n,t[n]);if(X)for(var n of X(t))Ie.call(t,n)&&Oe(e,n,t[n]);return e},q=(e,t)=>vt(e,yt(t));var Le=(e,t)=>{var n={};for(var r in e)Ee.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&X)for(var r of X(e))t.indexOf(r)<0&&Ie.call(e,r)&&(n[r]=e[r]);return n};import{createContext as wt,useContext as L,useEffect as j,useMemo as ze,useRef as ye,useState as ee,useSyncExternalStore as At}from"react";import{deriveSessionSegment as xt,init as _t}from"@sentientui/core";var De=new Map,Q=new Map;function Te(e,t){let n=Q.get(e);return n||(n=new Set,Q.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Q.delete(e)}}function Pe(e,t){De.set(e,t);let n=Q.get(e);if(n)for(let r of n)try{r(t)}catch(o){}}function de(e){var t;return(t=De.get(e))!=null?t:null}var St={on:!1,listeners:new Set};function Fe(){if(typeof window=="undefined")return St;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function fe(){return Fe().on}function Me(e){let t=Fe().listeners;return t.add(e),()=>{t.delete(e)}}function Ke(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,o)=>e.assign(t,n,r,o),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Be="sentient:overrides-changed";function je(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function F(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(Be,e),()=>window.removeEventListener(Be,e))}function $e(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function G(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function E(e){return typeof e=="string"?{type:"click"}:e}function W(e){return typeof e=="string"?e:e.type}function D(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var ge=new Set,me=!1;function Ve(e){if(ge.has(e))return!0;if(ge.add(e),!me){me=!0;let t=()=>{me=!1,ge.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function ht(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function Ne(e,t,n){if(n){try{let o=e;for(;o&&o!==t;){if(o.matches(n))return!0;o=o.parentElement}}catch(o){}return!1}let r=e;for(;r&&r!==t;){if(ht(r))return!0;r=r.parentElement}return!1}function T(e,t,n,r){if(t.type==="weighted_composite"){let c=new Set,m=[];return t.steps.forEach(({goal:g,name:v,weight:k},w)=>{let A=(u=!1)=>{c.has(w)||u&&r!==void 0&&Ve(`step\0${v}\0${k}\0${w}`)||(c.add(w),n.fireStep(v,k,w))};if(g.type==="click"){let u=s=>{let a=s.target;a instanceof Element&&Ne(a,e,g.selector)&&A()};e.addEventListener("click",u),m.push(()=>e.removeEventListener("click",u));return}if(g.type==="form_submit"){let u=s=>{s.target instanceof HTMLFormElement&&e.contains(s.target)&&A()};e.addEventListener("submit",u),m.push(()=>e.removeEventListener("submit",u));return}if(g.type==="scroll_depth"){let u=Math.max(0,Math.min(1,g.threshold)),s=new IntersectionObserver(a=>{for(let p of a)if(p.intersectionRatio>=u){A(!0),s.disconnect();break}},{threshold:[u]});s.observe(e),m.push(()=>s.disconnect())}}),()=>{for(let g of m)g()}}let o=t.type==="composite"?t.all:[t],i=new Set(o.map((c,m)=>m)),f=()=>{r!==void 0&&Ve(r)||n.fireGoal()},l=(c,m=!1)=>{i.delete(c),i.size===0&&(m?f():n.fireGoal())},d=[];return o.forEach((c,m)=>{if(c.type==="click"){let g=v=>{let k=v.target;k instanceof Element&&Ne(k,e,c.selector)&&(t.type==="composite"?l(m):n.fireGoal())};e.addEventListener("click",g),d.push(()=>e.removeEventListener("click",g));return}if(c.type==="form_submit"){let g=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&(t.type==="composite"?l(m):n.fireGoal())};e.addEventListener("submit",g),d.push(()=>e.removeEventListener("submit",g));return}if(c.type==="scroll_depth"){let g=Math.max(0,Math.min(1,c.threshold)),v=new IntersectionObserver(k=>{for(let w of k)if(w.intersectionRatio>=g){t.type==="composite"?l(m,!0):f(),v.disconnect();break}},{threshold:[g]});v.observe(e),d.push(()=>v.disconnect());return}}),()=>{for(let c of d)c()}}var We=new Set,Ue=new Set;function K(e,t,n,r,o){let i=`${r}|${n}`;if(Ue.has(i))return;Ue.add(i);let f=o.type==="weighted_composite"&&!We.has(r);f&&We.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:f?{funnelId:r,steps:o.steps.map(l=>({goalId:l.name,weight:l.weight}))}:{funnelId:r}})}function B(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var bt={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function V(){if(typeof window=="undefined")return bt;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function J(){V().version+=1;for(let e of V().listeners)e()}var Je=()=>{};function Y(e){return G()?(V().components.set(e.id,e),J(),()=>{V().components.delete(e.id),J()}):Je}function Z(e){return G()?(V().slots.set(e.id,e),J(),()=>{V().slots.delete(e.id),J()}):Je}function pe(e){G()&&(V().sections=[...e],J())}var He="0.28.0",ve=He!=="0.0.0-dev"?{name:"react",version:He}:void 0;import{jsx as Et}from"react/jsx-runtime";function kt(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return xt({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Xe="https://api.sentient-ui.com/v1",I=wt({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialPersona:null,apiBaseUrl:Xe,debug:!1});function Ct(e){let[t,n]=ee(!1),r=ye(e);r.current=e;let{cookie:o,value:i,event:f}=e!=null?e:{},l=typeof(e==null?void 0:e.check)=="function";return j(()=>{let d=()=>{var v;let m=r.current;if(!m)return!1;if(m.check)return m.check()===!0;if(!m.cookie||typeof document=="undefined")return!1;let g=`${m.cookie}=${(v=m.value)!=null?v:"accepted"}`;return document.cookie.split("; ").some(k=>k.trim()===g)};if(n(d()),!f)return;let c=()=>{n(d())};return window.addEventListener(f,c),()=>window.removeEventListener(f,c)},[o,i,f,l]),t}function Gt(e){var w,A;let[t,n]=ee(null),[r]=ee(()=>{var u;return(u=e.sessionSegment)!=null?u:kt()}),[o,i]=ee(fe());j(()=>Me(()=>i(fe())),[]);let f=Ct(e.consentFrom),l=e.consentFrom?e.consent===!0||f:e.consent,d=ye(null);j(()=>{var x;if(l===!1&&!e.preConsentBehavior){(x=d.current)==null||x.destroy(),d.current=null,n(null);return}let u=_({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:l,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},ve?{sdk:ve}:{}),s=!1,a=null,p=null,h=C=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:S})=>{s||(p=S(C,{apiKey:e.apiKey,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:C})=>{s||(a=C(q(_({},u),{graph:!0,captureDomText:e.captureDomText===!0})),d.current=a,n(a),h(a))}):(a=_t(u),d.current=a,n(a),h(a)),()=>{s=!0,p==null||p(),a==null||a.dispose()}},[l]),j(()=>{if(!t)return;let u=!1,s=async()=>{if(u)return;let p;try{p=await t.fetchWeights()}catch(h){return}if(!u)for(let h of p){let x={componentId:h.componentId,updatedAt:h.updatedAt,variants:h.variants.map(C=>{var S;return{variantId:C.variantId,pulls:C.pulls,avgReward:(S=C.avgReward)!=null?S:0}})};Pe(h.componentId,x)}};s();let a=setInterval(()=>{s()},6e4);return()=>{u=!0,clearInterval(a)}},[t]);let c=(w=e.ssrFallback)!=null?w:"first",m=((A=e.apiBaseUrl)!=null?A:Xe).replace(/\/$/,""),g=ye(null);j(()=>{var a;if(typeof process!="undefined"&&((a=process.env)==null?void 0:a.NODE_ENV)==="production")return;let u={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:m},s=g.current;if(g.current=u,s!==null)for(let p of["apiKey","context","country","persona","apiBaseUrl"])Object.is(s[p],u[p])||console.warn(`[sentient] AdaptiveProvider: \`${p}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,m]),j(()=>{var u;typeof process!="undefined"&&((u=process.env)==null?void 0:u.NODE_ENV)==="production"||$e({apiKey:e.apiKey,apiBaseUrl:m,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,m]),j(()=>{let u=e.initialLayoutOrder;if(u&&u.length>0){pe(u);return}e.declaredSections&&e.declaredSections.length>0&&pe(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),j(()=>{if(!G())return;let u=e.declaredSections;if(!u||u.length===0||typeof document=="undefined")return;let s=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),p=>p.getAttribute("data-sentient-id"))),a=u.filter(p=>!s.has(p));a.length>0&&console.warn(`[SentientUI] Declared section${a.length>1?"s":""} ${a.map(p=>`"${p}"`).join(", ")} ${a.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" (plus optional data-sentient-type) to each section's element.`)},[e.declaredSections]);let v=ze(()=>t&&o?Ke(t):t,[t,o]),k=ze(()=>{var u,s,a,p,h;return{client:v,apiKey:e.apiKey,initialAssignments:(u=e.initialAssignments)!=null?u:{},sessionSegment:r,ssrFallback:c,onAssignment:e.onAssignment,initialLayoutOrder:(s=e.initialLayoutOrder)!=null?s:null,initialSlots:(a=e.initialSlots)!=null?a:{},initialPersona:(p=e.initialPersona)!=null?p:null,apiBaseUrl:m,debug:(h=e.debug)!=null?h:!1}},[v,e.apiKey,e.initialAssignments,r,c,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialPersona,m,e.debug]);return Et(I.Provider,{value:k,children:e.children})}function R(){return L(I).client}function P(){return L(I).apiKey}function Se(){return L(I).initialAssignments}function te(){return L(I).sessionSegment}function qe(){return L(I).ssrFallback}function ne(){return L(I).onAssignment}function Qe(){return L(I).debug}function Rt(){let e=L(I).initialLayoutOrder,t=At(F,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ye(){return L(I).initialSlots}function Ze(){return L(I).initialPersona}function Ot(){return L(I).apiBaseUrl}import{memo as Dt,useEffect as $,useMemo as tt,useRef as ie,useState as Tt}from"react";import{attachMicroSignalDetectors as Pt}from"@sentientui/core";import{useEffect as re,useRef as et,useState as It,useSyncExternalStore as Lt}from"react";import{pickFromWeights as he}from"@sentientui/policy";function U(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let o of r.getAll("sentient_variant")){let i=o.indexOf(":");if(i!==-1&&o.slice(0,i)===e)return o.slice(i+1)}}catch(r){}return null}function H(e,t,n,r){let o=Se(),i=qe(),f=R(),l=te(),d=ne(),c=Qe(),m=et(null),g=Lt(F,()=>U(e),()=>null),v=g&&t.includes(g)?g:null,k=et(null);re(()=>{c&&v&&k.current!==v&&(k.current=v,console.info(`[sentient] override active: ${e} -> ${v}`))},[c,v,e]);let[w,A]=It(()=>{var p,h;if(v)return{variantId:v,content:null,isLoading:!1,settled:!0};if(!f){let x=o[e];return x&&t.includes(x)?{variantId:x,content:null,isLoading:!1,settled:!0}:i==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let s=f.getAssignment(e,l);if(s&&(t.includes(s.variantId)||s.content))return{variantId:s.variantId,content:(p=s.content)!=null?p:null,isLoading:!1,settled:!0};let a=de(e);if(a){let x=he(a.variants,t);if(x)return{variantId:x,content:null,isLoading:!1,settled:!0}}return{variantId:(h=t[0])!=null?h:null,content:null,isLoading:!1,settled:!1}}),u=s=>{d&&m.current!==s&&(m.current=s,d(e,s))};return re(()=>{var p;if(v||!f)return;let s=f.getAssignment(e,l);if(s&&(t.includes(s.variantId)||s.content)){A({variantId:s.variantId,content:(p=s.content)!=null?p:null,isLoading:!1,settled:!0}),u(s.variantId);return}let a=de(e);if(a&&w.settled&&w.variantId&&w.variantId===he(a.variants,t)){u(w.variantId);return}A(h=>{var x;return h.variantId?h:{variantId:(x=t[0])!=null?x:null,content:null,isLoading:!1,settled:!1}})},[v,f,e,l]),re(()=>{if(v||!f)return;let s=f.getAssignment(e,l);if(s&&t.includes(s.variantId))return;let a=!1;return f.assign(e,t,n,r).then(p=>{var h;a||p&&(!t.includes(p.variantId)&&!p.content||(A({variantId:p.variantId,content:(h=p.content)!=null?h:null,isLoading:!1,settled:!0}),u(p.variantId)))}),()=>{a=!0}},[v,f,e,l]),re(()=>{if(!v&&f)return Te(e,s=>{var h;let a=f.getAssignment(e,l);if(a&&(t.includes(a.variantId)||a.content)){A({variantId:a.variantId,content:(h=a.content)!=null?h:null,isLoading:!1,settled:!0}),u(a.variantId);return}let p=he(s.variants,t);p&&(A({variantId:p,content:null,isLoading:!1,settled:!0}),u(p))})},[v,f,e,l]),v?{variantId:v,content:null,isLoading:!1,settled:!0,isOverride:!0}:w}import{jsx as Kt}from"react/jsx-runtime";function Ft(e){var h;let t=R(),n=P(),r=Object.keys(e.variants).join("\0"),o=tt(()=>Object.keys(e.variants),[r]),{variantId:i,content:f,isOverride:l,settled:d}=H(e.id,o,e.agentData,e.agentDataByVariant),c=ie(null),[m,g]=Tt(!1);$(()=>{g(!0)},[]);let v=ie(!1),k=ie(new Set),w=ie(null),A=typeof e.goal=="string"?e.goal:JSON.stringify(e.goal),u=tt(()=>E(e.goal),[A]),s=typeof e.goal=="string"?e.goal:u.type;if($(()=>Y({id:e.id,variantIds:o,goal:s}),[e.id,o,s]),$(()=>{l||d&&(!t||!i||!n||w.current!==i&&(w.current=i,B(t,n,e.id,i)))},[t,i,n,e.id,l,d]),$(()=>{v.current=!1,k.current=new Set},[i,u]),$(()=>{l||!d||!t||!e.funnel||K(t,n,e.id,e.funnel,u)},[t,n,e.id,e.funnel,u,l,d]),$(()=>{if(l||!d||!t||!i)return;let x=c.current;if(!x)return;let C=null,S=0,b=()=>{S=Date.now(),C=setTimeout(()=>{t.track({projectId:n,componentId:e.id,variantId:i,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-S}}),C=null},800)},y=()=>{C!==null&&(clearTimeout(C),C=null)};return x.addEventListener("mouseenter",b),x.addEventListener("mouseleave",y),()=>{x.removeEventListener("mouseenter",b),x.removeEventListener("mouseleave",y),C!==null&&clearTimeout(C)}},[t,i,n,e.id,l,d]),$(()=>{if(l||!d||!t||!i)return;let x=c.current;if(!x)return;let C=Date.now();return Pt((S,b={})=>{var Ce,Ge,Re;t.track({projectId:n,componentId:e.id,variantId:i,eventType:"micro_signal",payload:_({signalType:S},b)});let y=(Ce=e.microSignalGoals)==null?void 0:Ce[S];if(!y||k.current.has(S))return;k.current.add(S);let O=typeof y=="string"?y:y.name,M=typeof y=="string"?1:(Ge=y.weight)!=null?Ge:1,z=typeof y=="string"?0:(Re=y.stepIndex)!=null?Re:0;t.goal(O,{metadata:_({signalType:S},b),weight:M,stepIndex:z})},x,C)},[t,i,n,e.id,e.microSignalGoals,l,d]),$(()=>{if(l||!d||!t||!i)return;let x=c.current;if(!x)return;let C=D(u);return T(x,u,{fireGoal:()=>{v.current||(v.current=!0,t.track({projectId:n,componentId:e.id,variantId:i,eventType:"goal_achieved",goalType:s,payload:_({reward:1},C!==void 0?{goalValue:C}:{})}),t.goal(s,_({metadata:{componentId:e.id,variantId:i},weight:1,stepIndex:0},C!==void 0?{value:C}:{})))},fireStep:(S,b,y)=>{t.track({projectId:n,componentId:e.id,variantId:i,eventType:"goal_achieved",goalType:S,payload:{reward:b}}),t.goal(S,{metadata:{},weight:b,stepIndex:y})}},s)},[t,i,n,e.id,u,s,l,d]),e.clientOnly&&(!m||!t)||!i)return null;let a=(h=e.variants[i])!=null?h:null,p=a===null?f:null;return G()&&a===null&&p===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${i}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),Kt("div",{ref:c,"data-sentient-id":e.id,"data-sentient-variant":i,children:a!=null?a:p})}var Mt=Dt(Ft,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(o=>o in t.variants&&Object.is(e.variants[o],t.variants[o]))});import{useEffect as oe,useMemo as Bt,useRef as be,useState as nt,useSyncExternalStore as jt}from"react";import{jsx as Vt}from"react/jsx-runtime";function $t({id:e,default:t,component:n="span",className:r,goal:o}){var C;let i=R(),f=P(),l=ne(),d=te(),c=be(null),m=be(null),g=jt(F,()=>U(e),()=>null),[v,k]=nt(()=>{var S,b;return(b=(S=i==null?void 0:i.getAssignment(e,d))==null?void 0:S.content)!=null?b:null}),[w,A]=nt(()=>{var S,b;return(b=(S=i==null?void 0:i.getAssignment(e,d))==null?void 0:S.variantId)!=null?b:null});oe(()=>{if(g||!i)return;let S=i.getAssignment(e,d);if((S==null?void 0:S.content)!==void 0){A(S.variantId),k(S.content);return}let b=!1;return i.assign(e).then(y=>{if(!b){if(!y){G()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}A(y.variantId),y.content&&k(y.content)}}),()=>{b=!0}},[i,e,d,g]),oe(()=>{g||!i||!w||!f||c.current!==w&&(c.current=w,i.track({projectId:f,componentId:e,variantId:w,eventType:"variant_assigned",payload:{}}),l==null||l(e,w))},[i,w,f,e,l,g]);let u=o===void 0?"":typeof o=="string"?o:JSON.stringify(o),s=Bt(()=>o===void 0?null:E(o),[u]),a=o===void 0?null:typeof o=="string"?o:s.type,p=be(!1);oe(()=>{p.current=!1},[w,u]),oe(()=>{if(g||!i||!w||!f||!s||!a)return;let S=m.current;if(!S)return;let b=D(s);return T(S,s,{fireGoal:()=>{p.current||(p.current=!0,i.track({projectId:f,componentId:e,variantId:w,eventType:"goal_achieved",goalType:a,payload:_({reward:1},b!==void 0?{goalValue:b}:{})}),i.goal(a,_({metadata:{componentId:e,variantId:w},weight:1,stepIndex:0},b!==void 0?{value:b}:{})))},fireStep:(y,O,M)=>{i.track({projectId:f,componentId:e,variantId:w,eventType:"goal_achieved",goalType:y,payload:{reward:O}}),i.goal(y,{metadata:{},weight:O,stepIndex:M})}})},[i,w,f,e,s,a,g]);let h=v!=null?v:t;if(g){let S=i==null?void 0:i.getAssignment(e,d);h=S&&S.variantId===g&&(C=S.content)!=null?C:t}return Vt(n,{ref:S=>{m.current=S},className:r,children:h})}import{useCallback as Nt,useRef as Wt}from"react";function we(e){let t=R(),n=Wt(new Set);return Nt((r,o)=>{var i,f;if(!U(e)){if(o!=null&&o.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,o),t==null||t.goal(r,_(_(_({metadata:(i=o==null?void 0:o.metadata)!=null?i:{},weight:(f=o==null?void 0:o.reward)!=null?f:1,stepIndex:0},(o==null?void 0:o.value)!==void 0?{value:o.value}:{}),(o==null?void 0:o.currency)!==void 0?{currency:o.currency}:{}),(o==null?void 0:o.externalId)!==void 0?{externalId:o.externalId}:{}))}},[t,e])}import{useEffect as Ut,useRef as rt}from"react";function Jt(e,t={}){let d=t,{componentId:n}=d,r=Le(d,["componentId"]),o=R(),i=we(n!=null?n:""),f=rt(!1),l=rt(r);l.current=r,Ut(()=>{if(!o||f.current)return;f.current=!0;let{metadata:c,reward:m,value:g,currency:v,externalId:k}=l.current;if(n){i(e,l.current);return}o.goal(e,_(_(_({metadata:c!=null?c:{},weight:m!=null?m:1,stepIndex:0},g!==void 0?{value:g}:{}),v!==void 0?{currency:v}:{}),k!==void 0?{externalId:k}:{}))},[o,n,e,i])}import{renderPrePaintScript as Ht}from"@sentientui/core";import{confidenceBand as zt}from"@sentientui/policy";import{jsx as Qt}from"react/jsx-runtime";function it(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Xt(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+it(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+it(zt(e.persona.confidence))+");}catch(e){}})();":Ht(e.apiKey)}function qt(e){return Qt("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Xt(e)}})}import{useEffect as le,useMemo as xe,useRef as on}from"react";import{validateSlotDecl as sn}from"@sentientui/policy";import{useEffect as Ae,useReducer as Yt,useState as Zt,useSyncExternalStore as st}from"react";import{armOfResult as se,baselineResultFor as en}from"@sentientui/core";import{confidenceBand as tn}from"@sentientui/policy";var ot=new Set;function ae(e,t){let n=R(),r=Ye(),[,o]=Yt(m=>m+1,0),i=st(F,()=>{var m;return typeof window!="undefined"?(m=window.__sentient_slot_overrides)==null?void 0:m[e]:void 0},()=>{}),f=i===void 0?r[e]:void 0,l=i===void 0&&f===void 0&&n?n.getSlotResult(e):null,d=(n==null?void 0:n.isLocal)===!0&&i===void 0&&f===void 0&&l===null;Ae(()=>{if(!d||!n)return;let m=!1;return n.decide({slots:[t]}).then(g=>{!m&&g&&o()}),()=>{m=!0}},[n,e,d]);let c=(()=>{if(i!==void 0)return{result:i,arm:se(i),source:"override"};if(f!==void 0)return{result:f,arm:se(f),source:"preloaded"};if(l!==null)return{result:l,arm:se(l),source:"client"};let m=en(t);return{result:m,arm:se(m),source:"baseline"}})();return Ae(()=>{G()&&(!n||n.isLocal===!0||c.source==="baseline"&&(ot.has(e)||(ot.add(e),console.warn(`[sentient] slot "${e}" resolved to its baseline \u2014 no SSR-preloaded or decided result. Keyed clients decide slots server-side, so this slot serves baseline for the whole session and records no exposure. Preload it via loadAdaptiveDecision()/initialSlots so it can serve a decided arm and learn.`))))},[n,c.source,e]),c}function nn(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function rn(){let e=R(),t=Ze();st(F,je,()=>0);let[n,r]=Zt(!1);Ae(()=>r(!0),[]);let o=l=>({persona:l.persona,confidence:l.confidence,band:tn(l.confidence)});if(!n)return t?o(t):null;let i=nn();if(i)return o(i);if(t)return o(t);let f=e?e.getPersona():null;return f?o(f):null}var at=new Set;function an(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function ln(e,t,n){let r=R(),o=P(),i=JSON.stringify(t),f=xe(()=>({id:e,dims:t}),[e,i]),{result:l,arm:d,source:c}=ae(e,f),m=xe(()=>typeof l=="string"?{}:l,[d]);if(G()&&!at.has(e)){at.add(e);let A=sn({id:e,dims:Object.fromEntries(Object.entries(t).map(([s,a])=>[s,[...a]]))}),u=Object.values(t).reduce((s,a)=>s*a.length,1);A.ok?u>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${u} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${A.reason}. Serving baseline.`)}let g=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);le(()=>Z({id:e,dims:t}),[e]);let v=on(null);le(()=>{!r||c==="baseline"||c==="override"||v.current===d||(v.current=d,B(r,o,e,d))},[r,o,e,d,c]);let k=n==null?void 0:n.funnel;le(()=>{var A;!r||!k||c==="override"||K(r,o,e,k,E((A=n==null?void 0:n.goal)!=null?A:"click"))},[r,o,e,k,g,c]),le(()=>{if(!r||!(n!=null&&n.goal)||c==="override"||c==="baseline")return;let A=document.querySelector(`[data-sentient-slot="${an(e)}"]`);if(!A){G()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let u=W(n.goal),s=D(n.goal),a=!1;return T(A,E(n.goal),{fireGoal:()=>{a||(a=!0,s!==void 0?r.componentGoal(e,u,{value:s}):r.componentGoal(e,u),r.goal(u,_({metadata:{componentId:e,arm:d},weight:1,stepIndex:0},s!==void 0?{value:s}:{})))},fireStep:(p,h,x)=>{r.componentGoal(e,p,{reward:h}),r.goal(p,{metadata:{componentId:e,arm:d},weight:h,stepIndex:x})}},u)},[r,e,g,d,c]);let w=xe(()=>{let A={"data-sentient-slot":e};for(let[u,s]of Object.entries(m))A[`data-${u}`]=s;return A},[e,m]);return{tokens:m,props:w}}import{useCallback as lt,useEffect as N,useMemo as _e,useRef as ke,useState as un}from"react";import{attachMicroSignalDetectors as cn}from"@sentientui/core";var ut=new Set;function dn(e,t){var S;if(G()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let n=R(),r=P(),o=Object.keys(t.variants).join(" "),i=_e(()=>Object.keys(t.variants),[o]),{variantId:f,isOverride:l,settled:d}=H(e,i),c=(S=f!=null?f:i[0])!=null?S:"",m=t.variants[c],[g,v]=un(null),k=ke(null),w=lt(b=>{k.current=b,v(b)},[]),A=typeof t.goal=="string"?t.goal:JSON.stringify(t.goal),u=_e(()=>t.goal?E(t.goal):null,[A]),s=t.goal?W(t.goal):"";N(()=>Y({id:e,variantIds:i,goal:s}),[e,i,s]);let a=ke(null);N(()=>{l||d&&(!n||!c||!g||a.current!==c&&(a.current=c,B(n,r,e,c)))},[n,r,e,c,g,l,d]);let p=t.funnel;N(()=>{l||!d||!n||!p||!u||K(n,r,e,p,u)},[n,r,e,p,u,l,d]);let h=ke(!1);N(()=>{h.current=!1},[c,A]),N(()=>{if(l||!d||!n||!c||!g||!u)return;let b=D(u);return T(g,u,{fireGoal:()=>{h.current||(h.current=!0,n.track({projectId:r,componentId:e,variantId:c,eventType:"goal_achieved",goalType:s,payload:_({reward:1},b!==void 0?{goalValue:b}:{})}),n.goal(s,_({metadata:{componentId:e,variantId:c},weight:1,stepIndex:0},b!==void 0?{value:b}:{})))},fireStep:(y,O,M)=>{n.track({projectId:r,componentId:e,variantId:c,eventType:"goal_achieved",goalType:y,payload:{reward:O}}),n.goal(y,{metadata:{},weight:O,stepIndex:M})}},s)},[n,g,c,r,e,u,s,l,d]),N(()=>{if(l||!n||!c||!g)return;let b=Date.now();return cn((y,O={})=>{n.track({projectId:r,componentId:e,variantId:c,eventType:"micro_signal",payload:_({signalType:y},O)})},g,b)},[n,g,c,r,e,l]),N(()=>{if(!G()||!n)return;let b=setTimeout(()=>{!k.current&&!ut.has(e)&&(ut.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(b)},[n,e]);let x=lt((b,y)=>{var M,z;if(l)return;let O=b!=null?b:s;O&&(n==null||n.componentGoal(e,O,y),n==null||n.goal(O,_(_(_({metadata:(M=y==null?void 0:y.metadata)!=null?M:{},weight:(z=y==null?void 0:y.reward)!=null?z:1,stepIndex:0},(y==null?void 0:y.value)!==void 0?{value:y.value}:{}),(y==null?void 0:y.currency)!==void 0?{currency:y.currency}:{}),(y==null?void 0:y.externalId)!==void 0?{externalId:y.externalId}:{})))},[n,e,s,l]),C=_e(()=>({ref:w,"data-sentient-id":e,"data-sentient-variant":c}),[w,e,c]);return{variant:c,value:m,bind:C,fireGoal:x}}import{Children as fn,isValidElement as gn,useEffect as ue,useMemo as ct,useRef as dt}from"react";import{jsx as pn}from"react/jsx-runtime";var ce=new Set;function mn(e){var s;let t=R(),n=P(),r=dt(null),o=Object.keys(e.arrangements).join(" "),i=ct(()=>Object.keys(e.arrangements),[o]),f=ct(()=>_({id:e.id,arms:i},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,i,e.baseline]),{arm:l,source:d}=ae(e.id,f);G()&&e.baseline!==void 0&&e.baseline!==i[0]&&!ce.has(e.id+":baseline")&&(ce.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${i[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let c=fn.toArray(e.children).filter(gn),m=new Map;for(let a of c)m.set(String((s=a.key)!=null?s:"").replace(/^\.\$/,""),a);let g=e.arrangements[l],v=g!==void 0&&g.length===c.length&&g.every(a=>m.has(a));G()&&g!==void 0&&!v&&!ce.has(e.id+":keys")&&(ce.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${l}" [${g.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let k=v?g.map(a=>m.get(a)):c;ue(()=>Z({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let w=dt(null);ue(()=>{!t||d==="baseline"||d==="override"||w.current===l||(w.current=l,B(t,n,e.id,l))},[t,n,e.id,l,d]);let A=e.funnel;ue(()=>{var a;!t||!A||d==="override"||K(t,n,e.id,A,E((a=e.goal)!=null?a:"click"))},[t,n,e.id,A,d]);let u=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return ue(()=>{if(!t||e.goal===void 0||d==="override"||d==="baseline")return;let a=r.current;if(!a)return;let p=W(e.goal),h=D(e.goal),x=!1;return T(a,E(e.goal),{fireGoal:()=>{x||(x=!0,h!==void 0?t.componentGoal(e.id,p,{value:h}):t.componentGoal(e.id,p),t.goal(p,_({metadata:{componentId:e.id,arm:l},weight:1,stepIndex:0},h!==void 0?{value:h}:{})))},fireStep:(C,S,b)=>{t.componentGoal(e.id,C,{reward:S}),t.goal(C,{metadata:{componentId:e.id,arm:l},weight:S,stepIndex:b})}},p)},[t,e.id,u,l,d]),pn("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":l,children:k})}import{deriveSessionSegment as vn}from"@sentientui/core";var yn=["page","blocks","layoutOrder"],ft=new Map;function Sn(e,t){ft.set(e,t)}function gt(e){return ft.get(e)}function hn(e){var o,i;let t=(i=(o=e.content)!=null?o:gt(e.page))!=null?i:{},n={};for(let[f,l]of Object.entries(t))yn.includes(f)||(n[f]=l);let r=q(_({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function bn(e){return`<script type="application/ld+json">${mt(e)}</script>`}function mt(e){return JSON.stringify(_({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function wn(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
2
+ var Tt=Object.defineProperty,Ft=Object.defineProperties;var Bt=Object.getOwnPropertyDescriptors;var Q=Object.getOwnPropertySymbols;var Be=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable;var Fe=(e,t,n)=>t in e?Tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))Be.call(t,n)&&Fe(e,n,t[n]);if(Q)for(var n of Q(t))Me.call(t,n)&&Fe(e,n,t[n]);return e},K=(e,t)=>Ft(e,Bt(t));var Ke=(e,t)=>{var n={};for(var i in e)Be.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&Q)for(var i of Q(e))t.indexOf(i)<0&&Me.call(e,i)&&(n[i]=e[i]);return n};import{createContext as Nt,useContext as L,useEffect as V,useMemo as tt,useRef as xe,useState as te,useSyncExternalStore as $t}from"react";import{deriveSessionSegment as Vt,init as Wt}from"@sentientui/core";var je=new Map,Y=new Map;function Ne(e,t){let n=Y.get(e);return n||(n=new Set,Y.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Y.delete(e)}}function $e(e,t){je.set(e,t);let n=Y.get(e);if(n)for(let i of n)try{i(t)}catch(s){}}function ve(e){var t;return(t=je.get(e))!=null?t:null}var Mt={on:!1,listeners:new Set};function Ve(){if(typeof window=="undefined")return Mt;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function ye(){return Ve().on}function We(e){let t=Ve().listeners;return t.add(e),()=>{t.delete(e)}}function Ue(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,i,s)=>e.assign(t,n,i,s),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Je="sentient:overrides-changed";function He(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function D(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(Je,e),()=>window.removeEventListener(Je,e))}function Xe(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function _(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function P(e){return typeof e=="string"?{type:"click"}:e}function N(e){return typeof e=="string"?e:e.type}function T(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var Se=new Set,he=!1;function ze(e){if(Se.has(e))return!0;if(Se.add(e),!he){he=!0;let t=()=>{he=!1,Se.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function Kt(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function qe(e,t,n){if(n){try{let s=e;for(;s&&s!==t;){if(s.matches(n))return!0;s=s.parentElement}}catch(s){}return!1}let i=e;for(;i&&i!==t;){if(Kt(i))return!0;i=i.parentElement}return!1}function F(e,t,n,i){if(t.type==="weighted_composite"){let l=new Set,d=[];return t.steps.forEach(({goal:f,name:p,weight:h},b)=>{let y=(c=!1)=>{l.has(b)||c&&i!==void 0&&ze(`step\0${p}\0${h}\0${b}`)||(l.add(b),n.fireStep(p,h,b))};if(f.type==="click"){let c=u=>{let g=u.target;g instanceof Element&&qe(g,e,f.selector)&&y()};e.addEventListener("click",c),d.push(()=>e.removeEventListener("click",c));return}if(f.type==="form_submit"){let c=u=>{u.target instanceof HTMLFormElement&&e.contains(u.target)&&y()};e.addEventListener("submit",c),d.push(()=>e.removeEventListener("submit",c));return}if(f.type==="scroll_depth"){let c=Math.max(0,Math.min(1,f.threshold)),u=new IntersectionObserver(g=>{for(let v of g)if(v.intersectionRatio>=c){y(!0),u.disconnect();break}},{threshold:[c]});u.observe(e),d.push(()=>u.disconnect())}}),()=>{for(let f of d)f()}}let s=t.type==="composite"?t.all:[t],r=new Set(s.map((l,d)=>d)),m=()=>{i!==void 0&&ze(i)||n.fireGoal()},o=(l,d=!1)=>{r.delete(l),r.size===0&&(d?m():n.fireGoal())},a=[];return s.forEach((l,d)=>{if(l.type==="click"){let f=p=>{let h=p.target;h instanceof Element&&qe(h,e,l.selector)&&(t.type==="composite"?o(d):n.fireGoal())};e.addEventListener("click",f),a.push(()=>e.removeEventListener("click",f));return}if(l.type==="form_submit"){let f=p=>{p.target instanceof HTMLFormElement&&e.contains(p.target)&&(t.type==="composite"?o(d):n.fireGoal())};e.addEventListener("submit",f),a.push(()=>e.removeEventListener("submit",f));return}if(l.type==="scroll_depth"){let f=Math.max(0,Math.min(1,l.threshold)),p=new IntersectionObserver(h=>{for(let b of h)if(b.intersectionRatio>=f){t.type==="composite"?o(d,!0):m(),p.disconnect();break}},{threshold:[f]});p.observe(e),a.push(()=>p.disconnect());return}}),()=>{for(let l of a)l()}}var Ze=new Set,Qe=new Set;function $(e,t,n,i,s){let r=`${i}|${n}`;if(Qe.has(r))return;Qe.add(r);let m=s.type==="weighted_composite"&&!Ze.has(i);m&&Ze.add(i),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:m?{funnelId:i,steps:s.steps.map(o=>({goalId:o.name,weight:o.weight}))}:{funnelId:i}})}function j(e,t,n,i){e.track({projectId:t,componentId:n,variantId:i,eventType:"variant_assigned",payload:{}})}var jt={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function U(){if(typeof window=="undefined")return jt;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function q(){U().version+=1;for(let e of U().listeners)e()}var Ye=()=>{};function ee(e){return _()?(U().components.set(e.id,e),q(),()=>{U().components.delete(e.id),q()}):Ye}function X(e){return _()?(U().slots.set(e.id,e),q(),()=>{U().slots.delete(e.id),q()}):Ye}function be(e){_()&&(U().sections=[...e],q())}var et="0.29.0",we=et!=="0.0.0-dev"?{name:"react",version:et}:void 0;import{jsx as qt}from"react/jsx-runtime";function Ut(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return Vt({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var nt="https://api.sentient-ui.com/v1",I=Nt({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:nt,debug:!1});function Jt(e){let[t,n]=te(!1),i=xe(e);i.current=e;let{cookie:s,value:r,event:m}=e!=null?e:{},o=typeof(e==null?void 0:e.check)=="function";return V(()=>{let a=()=>{var p;let d=i.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let f=`${d.cookie}=${(p=d.value)!=null?p:"accepted"}`;return document.cookie.split("; ").some(h=>h.trim()===f)};if(n(a()),!m)return;let l=()=>{n(a())};return window.addEventListener(m,l),()=>window.removeEventListener(m,l)},[s,r,m,o]),t}function Ht(e){var b,y;let[t,n]=te(null),[i]=te(()=>{var c;return(c=e.sessionSegment)!=null?c:Ut()}),[s,r]=te(ye());V(()=>We(()=>r(ye())),[]);let m=Jt(e.consentFrom),o=e.consentFrom?e.consent===!0||m:e.consent,a=xe(null);V(()=>{var k;if(o===!1&&!e.preConsentBehavior){(k=a.current)==null||k.destroy(),a.current=null,n(null);return}let c=S({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:i,consent:o,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},we?{sdk:we}:{}),u=!1,g=null,v=null,C=R=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:x})=>{u||(v=x(R,{apiKey:e.apiKey,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:R})=>{u||(g=R(K(S({},c),{graph:!0,captureDomText:e.captureDomText===!0})),a.current=g,n(g),C(g))}):(g=Wt(c),a.current=g,n(g),C(g)),()=>{u=!0,v==null||v(),g==null||g.dispose()}},[o]),V(()=>{if(!t)return;let c=!1,u=async()=>{if(c)return;let v;try{v=await t.fetchWeights()}catch(C){return}if(!c)for(let C of v){let k={componentId:C.componentId,updatedAt:C.updatedAt,variants:C.variants.map(R=>{var x;return{variantId:R.variantId,pulls:R.pulls,avgReward:(x=R.avgReward)!=null?x:0}})};$e(C.componentId,k)}};u();let g=setInterval(()=>{u()},6e4);return()=>{c=!0,clearInterval(g)}},[t]);let l=(b=e.ssrFallback)!=null?b:"first",d=((y=e.apiBaseUrl)!=null?y:nt).replace(/\/$/,""),f=xe(null);V(()=>{var g;if(typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production")return;let c={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},u=f.current;if(f.current=c,u!==null)for(let v of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[v],c[v])||console.warn(`[sentient] AdaptiveProvider: \`${v}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,d]),V(()=>{var c;typeof process!="undefined"&&((c=process.env)==null?void 0:c.NODE_ENV)==="production"||Xe({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),V(()=>{let c=e.initialLayoutOrder;if(c&&c.length>0){be(c);return}e.declaredSections&&e.declaredSections.length>0&&be(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),V(()=>{if(!_())return;let c=e.declaredSections;if(!c||c.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),v=>v.getAttribute("data-sentient-id"))),g=c.filter(v=>!u.has(v));g.length>0&&console.warn(`[SentientUI] Declared section${g.length>1?"s":""} ${g.map(v=>`"${v}"`).join(", ")} ${g.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" (plus optional data-sentient-type) to each section's element.`)},[e.declaredSections]);let p=tt(()=>t&&s?Ue(t):t,[t,s]),h=tt(()=>{var c,u,g,v,C,k,R;return{client:p,apiKey:e.apiKey,initialAssignments:(c=e.initialAssignments)!=null?c:{},sessionSegment:i,ssrFallback:l,onAssignment:e.onAssignment,initialLayoutOrder:(u=e.initialLayoutOrder)!=null?u:null,initialSlots:(g=e.initialSlots)!=null?g:{},initialSlotConfig:(v=e.initialSlotConfig)!=null?v:{},initialPalette:(C=e.initialPalette)!=null?C:null,initialPersona:(k=e.initialPersona)!=null?k:null,apiBaseUrl:d,debug:(R=e.debug)!=null?R:!1}},[p,e.apiKey,e.initialAssignments,i,l,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return qt(I.Provider,{value:h,children:e.children})}function G(){return L(I).client}function B(){return L(I).apiKey}function Ae(){return L(I).initialAssignments}function ne(){return L(I).sessionSegment}function rt(){return L(I).ssrFallback}function re(){return L(I).onAssignment}function it(){return L(I).debug}function Xt(){let e=L(I).initialLayoutOrder,t=$t(D,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function ie(){return L(I).initialSlots}function ot(){return L(I).initialPersona}function st(){return L(I).initialSlotConfig}function at(){return L(I).initialPalette}function zt(){return L(I).apiBaseUrl}import{memo as Yt,useEffect as W,useMemo as ut,useRef as se,useState as en}from"react";import{attachMicroSignalDetectors as tn}from"@sentientui/core";import{useEffect as oe,useRef as lt,useState as Zt,useSyncExternalStore as Qt}from"react";import{pickFromWeights as Ce}from"@sentientui/policy";function z(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let i=new URLSearchParams(window.location.search);for(let s of i.getAll("sentient_variant")){let r=s.indexOf(":");if(r!==-1&&s.slice(0,r)===e)return s.slice(r+1)}}catch(i){}return null}function Z(e,t,n,i){let s=Ae(),r=rt(),m=G(),o=ne(),a=re(),l=it(),d=lt(null),f=Qt(D,()=>z(e),()=>null),p=f&&t.includes(f)?f:null,h=lt(null);oe(()=>{l&&p&&h.current!==p&&(h.current=p,console.info(`[sentient] override active: ${e} -> ${p}`))},[l,p,e]);let[b,y]=Zt(()=>{var v,C;if(p)return{variantId:p,content:null,isLoading:!1,settled:!0};if(!m){let k=s[e];return k&&t.includes(k)?{variantId:k,content:null,isLoading:!1,settled:!0}:r==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let u=m.getAssignment(e,o);if(u&&(t.includes(u.variantId)||u.content))return{variantId:u.variantId,content:(v=u.content)!=null?v:null,isLoading:!1,settled:!0};let g=ve(e);if(g){let k=Ce(g.variants,t);if(k)return{variantId:k,content:null,isLoading:!1,settled:!0}}return{variantId:(C=t[0])!=null?C:null,content:null,isLoading:!1,settled:!1}}),c=u=>{a&&d.current!==u&&(d.current=u,a(e,u))};return oe(()=>{var v;if(p||!m)return;let u=m.getAssignment(e,o);if(u&&(t.includes(u.variantId)||u.content)){y({variantId:u.variantId,content:(v=u.content)!=null?v:null,isLoading:!1,settled:!0}),c(u.variantId);return}let g=ve(e);if(g&&b.settled&&b.variantId&&b.variantId===Ce(g.variants,t)){c(b.variantId);return}y(C=>{var k;return C.variantId?C:{variantId:(k=t[0])!=null?k:null,content:null,isLoading:!1,settled:!1}})},[p,m,e,o]),oe(()=>{if(p||!m)return;let u=m.getAssignment(e,o);if(u&&t.includes(u.variantId))return;let g=!1;return m.assign(e,t,n,i).then(v=>{var C;g||v&&(!t.includes(v.variantId)&&!v.content||(y({variantId:v.variantId,content:(C=v.content)!=null?C:null,isLoading:!1,settled:!0}),c(v.variantId)))}),()=>{g=!0}},[p,m,e,o]),oe(()=>{if(!p&&m)return Ne(e,u=>{var C;let g=m.getAssignment(e,o);if(g&&(t.includes(g.variantId)||g.content)){y({variantId:g.variantId,content:(C=g.content)!=null?C:null,isLoading:!1,settled:!0}),c(g.variantId);return}let v=Ce(u.variants,t);v&&(y({variantId:v,content:null,isLoading:!1,settled:!0}),c(v))})},[p,m,e,o]),p?{variantId:p,content:null,isLoading:!1,settled:!0,isOverride:!0}:b}import{jsx as on}from"react/jsx-runtime";function nn(e){var C;let t=G(),n=B(),i=Object.keys(e.variants).join("\0"),s=ut(()=>Object.keys(e.variants),[i]),{variantId:r,content:m,isOverride:o,settled:a}=Z(e.id,s,e.agentData,e.agentDataByVariant),l=se(null),[d,f]=en(!1);W(()=>{f(!0)},[]);let p=se(!1),h=se(new Set),b=se(null),y=typeof e.goal=="string"?e.goal:JSON.stringify(e.goal),c=ut(()=>P(e.goal),[y]),u=typeof e.goal=="string"?e.goal:c.type;if(W(()=>ee({id:e.id,variantIds:s,goal:u}),[e.id,s,u]),W(()=>{o||a&&(!t||!r||!n||b.current!==r&&(b.current=r,j(t,n,e.id,r)))},[t,r,n,e.id,o,a]),W(()=>{p.current=!1,h.current=new Set},[r,c]),W(()=>{o||!a||!t||!e.funnel||$(t,n,e.id,e.funnel,c)},[t,n,e.id,e.funnel,c,o,a]),W(()=>{if(o||!a||!t||!r)return;let k=l.current;if(!k)return;let R=null,x=0,A=()=>{x=Date.now(),R=setTimeout(()=>{t.track({projectId:n,componentId:e.id,variantId:r,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-x}}),R=null},800)},w=()=>{R!==null&&(clearTimeout(R),R=null)};return k.addEventListener("mouseenter",A),k.addEventListener("mouseleave",w),()=>{k.removeEventListener("mouseenter",A),k.removeEventListener("mouseleave",w),R!==null&&clearTimeout(R)}},[t,r,n,e.id,o,a]),W(()=>{if(o||!a||!t||!r)return;let k=l.current;if(!k)return;let R=Date.now();return tn((x,A={})=>{var Le,De,Te;t.track({projectId:n,componentId:e.id,variantId:r,eventType:"micro_signal",payload:S({signalType:x},A)});let w=(Le=e.microSignalGoals)==null?void 0:Le[x];if(!w||h.current.has(x))return;h.current.add(x);let E=typeof w=="string"?w:w.name,M=typeof w=="string"?1:(De=w.weight)!=null?De:1,H=typeof w=="string"?0:(Te=w.stepIndex)!=null?Te:0;t.goal(E,{metadata:S({signalType:x},A),weight:M,stepIndex:H})},k,R)},[t,r,n,e.id,e.microSignalGoals,o,a]),W(()=>{if(o||!a||!t||!r)return;let k=l.current;if(!k)return;let R=T(c);return F(k,c,{fireGoal:()=>{p.current||(p.current=!0,t.track({projectId:n,componentId:e.id,variantId:r,eventType:"goal_achieved",goalType:u,payload:S({reward:1},R!==void 0?{goalValue:R}:{})}),t.goal(u,S({metadata:{componentId:e.id,variantId:r},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(x,A,w)=>{t.track({projectId:n,componentId:e.id,variantId:r,eventType:"goal_achieved",goalType:x,payload:{reward:A}}),t.goal(x,{metadata:{},weight:A,stepIndex:w})}},u)},[t,r,n,e.id,c,u,o,a]),e.clientOnly&&(!d||!t)||!r)return null;let g=(C=e.variants[r])!=null?C:null,v=g===null?m:null;return _()&&g===null&&v===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${r}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),on("div",{ref:l,"data-sentient-id":e.id,"data-sentient-variant":r,children:g!=null?g:v})}var rn=Yt(nn,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),i=Object.keys(t.variants);return n.length!==i.length?!1:n.every(s=>s in t.variants&&Object.is(e.variants[s],t.variants[s]))});import{useEffect as ae,useMemo as sn,useRef as ke,useState as ct,useSyncExternalStore as an}from"react";import{jsx as un}from"react/jsx-runtime";function ln({id:e,default:t,component:n="span",className:i,goal:s}){var R;let r=G(),m=B(),o=re(),a=ne(),l=ke(null),d=ke(null),f=an(D,()=>z(e),()=>null),[p,h]=ct(()=>{var x,A;return(A=(x=r==null?void 0:r.getAssignment(e,a))==null?void 0:x.content)!=null?A:null}),[b,y]=ct(()=>{var x,A;return(A=(x=r==null?void 0:r.getAssignment(e,a))==null?void 0:x.variantId)!=null?A:null});ae(()=>{if(f||!r)return;let x=r.getAssignment(e,a);if((x==null?void 0:x.content)!==void 0){y(x.variantId),h(x.content);return}let A=!1;return r.assign(e).then(w=>{if(!A){if(!w){_()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}y(w.variantId),w.content&&h(w.content)}}),()=>{A=!0}},[r,e,a,f]),ae(()=>{f||!r||!b||!m||l.current!==b&&(l.current=b,r.track({projectId:m,componentId:e,variantId:b,eventType:"variant_assigned",payload:{}}),o==null||o(e,b))},[r,b,m,e,o,f]);let c=s===void 0?"":typeof s=="string"?s:JSON.stringify(s),u=sn(()=>s===void 0?null:P(s),[c]),g=s===void 0?null:typeof s=="string"?s:u.type,v=ke(!1);ae(()=>{v.current=!1},[b,c]),ae(()=>{if(f||!r||!b||!m||!u||!g)return;let x=d.current;if(!x)return;let A=T(u);return F(x,u,{fireGoal:()=>{v.current||(v.current=!0,r.track({projectId:m,componentId:e,variantId:b,eventType:"goal_achieved",goalType:g,payload:S({reward:1},A!==void 0?{goalValue:A}:{})}),r.goal(g,S({metadata:{componentId:e,variantId:b},weight:1,stepIndex:0},A!==void 0?{value:A}:{})))},fireStep:(w,E,M)=>{r.track({projectId:m,componentId:e,variantId:b,eventType:"goal_achieved",goalType:w,payload:{reward:E}}),r.goal(w,{metadata:{},weight:E,stepIndex:M})}})},[r,b,m,e,u,g,f]);let C=p!=null?p:t;if(f){let x=r==null?void 0:r.getAssignment(e,a);C=x&&x.variantId===f&&(R=x.content)!=null?R:t}return un(n,{ref:x=>{d.current=x},className:i,children:C})}import{useCallback as cn,useRef as dn}from"react";function Re(e){let t=G(),n=dn(new Set);return cn((i,s)=>{var r,m;if(!z(e)){if(s!=null&&s.once){if(n.current.has(i))return;n.current.add(i)}t==null||t.componentGoal(e,i,s),t==null||t.goal(i,S(S(S({metadata:(r=s==null?void 0:s.metadata)!=null?r:{},weight:(m=s==null?void 0:s.reward)!=null?m:1,stepIndex:0},(s==null?void 0:s.value)!==void 0?{value:s.value}:{}),(s==null?void 0:s.currency)!==void 0?{currency:s.currency}:{}),(s==null?void 0:s.externalId)!==void 0?{externalId:s.externalId}:{}))}},[t,e])}import{useEffect as fn,useRef as dt}from"react";function gn(e,t={}){let a=t,{componentId:n}=a,i=Ke(a,["componentId"]),s=G(),r=Re(n!=null?n:""),m=dt(!1),o=dt(i);o.current=i,fn(()=>{if(!s||m.current)return;m.current=!0;let{metadata:l,reward:d,value:f,currency:p,externalId:h}=o.current;if(n){r(e,o.current);return}s.goal(e,S(S(S({metadata:l!=null?l:{},weight:d!=null?d:1,stepIndex:0},f!==void 0?{value:f}:{}),p!==void 0?{currency:p}:{}),h!==void 0?{externalId:h}:{}))},[s,n,e,r])}import{renderPrePaintScript as mn}from"@sentientui/core";import{confidenceBand as pn}from"@sentientui/policy";import{jsx as Sn}from"react/jsx-runtime";function ft(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function vn(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+ft(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+ft(pn(e.persona.confidence))+");}catch(e){}})();":mn(e.apiKey)}function yn(e){return Sn("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:vn(e)}})}import{useEffect as ce,useMemo as Ge,useRef as kn}from"react";import{validateSlotDecl as Rn}from"@sentientui/policy";import{useEffect as _e,useReducer as hn,useState as bn,useSyncExternalStore as mt}from"react";import{armOfResult as le,baselineResultFor as wn}from"@sentientui/core";import{confidenceBand as xn}from"@sentientui/policy";var gt=new Set;function ue(e,t){let n=G(),i=ie(),[,s]=hn(d=>d+1,0),r=mt(D,()=>{var d;return typeof window!="undefined"?(d=window.__sentient_slot_overrides)==null?void 0:d[e]:void 0},()=>{}),m=r===void 0?i[e]:void 0,o=r===void 0&&m===void 0&&n?n.getSlotResult(e):null,a=(n==null?void 0:n.isLocal)===!0&&r===void 0&&m===void 0&&o===null;_e(()=>{if(!a||!n)return;let d=!1;return n.decide({slots:[t]}).then(f=>{!d&&f&&s()}),()=>{d=!0}},[n,e,a]);let l=(()=>{if(r!==void 0)return{result:r,arm:le(r),source:"override"};if(m!==void 0)return{result:m,arm:le(m),source:"preloaded"};if(o!==null)return{result:o,arm:le(o),source:"client"};let d=wn(t);return{result:d,arm:le(d),source:"baseline"}})();return _e(()=>{_()&&(!n||n.isLocal===!0||l.source==="baseline"&&(gt.has(e)||(gt.add(e),console.warn(`[sentient] slot "${e}" resolved to its baseline \u2014 no SSR-preloaded or decided result. Keyed clients decide slots server-side, so this slot serves baseline for the whole session and records no exposure. Preload it via loadAdaptiveDecision()/initialSlots so it can serve a decided arm and learn.`))))},[n,l.source,e]),l}function An(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function Cn(){let e=G(),t=ot();mt(D,He,()=>0);let[n,i]=bn(!1);_e(()=>i(!0),[]);let s=o=>({persona:o.persona,confidence:o.confidence,band:xn(o.confidence)});if(!n)return t?s(t):null;let r=An();if(r)return s(r);if(t)return s(t);let m=e?e.getPersona():null;return m?s(m):null}var pt=new Set;function _n(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Gn(e,t,n){let i=G(),s=B(),r=JSON.stringify(t),m=Ge(()=>({id:e,dims:t}),[e,r]),{result:o,arm:a,source:l}=ue(e,m),d=Ge(()=>typeof o=="string"?{}:o,[a]);if(_()&&!pt.has(e)){pt.add(e);let y=Rn({id:e,dims:Object.fromEntries(Object.entries(t).map(([u,g])=>[u,[...g]]))}),c=Object.values(t).reduce((u,g)=>u*g.length,1);y.ok?c>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${c} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${y.reason}. Serving baseline.`)}let f=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);ce(()=>X({id:e,dims:t}),[e]);let p=kn(null);ce(()=>{!i||l==="baseline"||l==="override"||p.current===a||(p.current=a,j(i,s,e,a))},[i,s,e,a,l]);let h=n==null?void 0:n.funnel;ce(()=>{var y;!i||!h||l==="override"||$(i,s,e,h,P((y=n==null?void 0:n.goal)!=null?y:"click"))},[i,s,e,h,f,l]),ce(()=>{if(!i||!(n!=null&&n.goal)||l==="override"||l==="baseline")return;let y=document.querySelector(`[data-sentient-slot="${_n(e)}"]`);if(!y){_()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let c=N(n.goal),u=T(n.goal),g=!1;return F(y,P(n.goal),{fireGoal:()=>{g||(g=!0,u!==void 0?i.componentGoal(e,c,{value:u}):i.componentGoal(e,c),i.goal(c,S({metadata:{componentId:e,arm:a},weight:1,stepIndex:0},u!==void 0?{value:u}:{})))},fireStep:(v,C,k)=>{i.componentGoal(e,v,{reward:C}),i.goal(v,{metadata:{componentId:e,arm:a},weight:C,stepIndex:k})}},c)},[i,e,f,a,l]);let b=Ge(()=>{let y={"data-sentient-slot":e};for(let[c,u]of Object.entries(d))y[`data-${c}`]=u;return y},[e,d]);return{tokens:d,props:b}}import{useEffect as ge,useMemo as Tn,useRef as Rt}from"react";import{containsFormBlock as Fn}from"@sentientui/core";import{useEffect as Oe,useReducer as On,useSyncExternalStore as vt}from"react";import{armOfResult as En}from"@sentientui/core";var yt=new Set;function St(e){var b;let t=G(),n=ie(),i=st(),s=at(),[,r]=On(y=>y+1,0),m=vt(D,()=>{var y;return typeof window!="undefined"?(y=window.__sentient_slot_config_overrides)==null?void 0:y[e]:void 0},()=>{}),o=vt(D,()=>{var y;return typeof window!="undefined"?(y=window.__sentient_slot_overrides)==null?void 0:y[e]:void 0},()=>{}),a=m===void 0?i[e]:void 0,l=m===void 0&&a===void 0&&t?t.getSlotConfig(e):null,d=y=>y==null?"":En(y),f=(b=s!=null?s:t==null?void 0:t.getSitePalette())!=null?b:null,p=(t==null?void 0:t.isLocal)===!0&&m===void 0&&a===void 0&&l===null;Oe(()=>{if(!p||!t)return;let y=!1;return t.decide({slotsFrom:"registry"}).then(c=>{!y&&c&&r()}),()=>{y=!0}},[t,e,p]);let h=(()=>{var y,c;return m!==void 0?{config:m,arm:d(o),palette:f,source:"override"}:a!==void 0?{config:a,arm:d((y=n[e])!=null?y:t==null?void 0:t.getSlotResult(e)),palette:f,source:"preloaded"}:l!==null?{config:l,arm:d((c=t==null?void 0:t.getSlotResult(e))!=null?c:n[e]),palette:f,source:"client"}:{config:null,arm:"",palette:f,source:"none"}})();return Oe(()=>{!t||t.isLocal===!0||h.source!=="none"||t.reportSlots([e])},[t,h.source,e]),Oe(()=>{_()&&(!t||t.isLocal===!0||h.source==="none"&&(yt.has(e)||(yt.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" has no server config \u2014 rendering its baseline children. Preload it via loadAdaptiveDecision({ slotsFrom: 'registry' }) and pass initialSlotConfig/initialSlots to <AdaptiveProvider> so it can serve a decided arm and learn.`))))},[t,h.source,e]),h}import{Fragment as ht}from"react";import{jsx as O,jsxs as At}from"react/jsx-runtime";var de={none:"0",sm:"8px",md:"16px",lg:"24px"},Ee={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Ct={sm:"0.875em",md:"1em",lg:"1.25em"},Pn={sm:"1.25em",md:"1.5em",lg:"2em"},bt={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},wt={sm:"8px",md:"16px",lg:"32px"},In={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Ln={normal:"400",medium:"500",bold:"700"};function xt(e){return S(S({},e==="muted"?{opacity:.7}:{}),e==="accent"?{fontWeight:600}:{})}function kt(e,t,n){var i,s,r,m;return K(S({display:"inline-block",padding:(i=bt[n!=null?n:"md"])!=null?i:bt.md,borderRadius:(s=t==null?void 0:t.radius)!=null?s:"8px",font:"inherit"},n?{fontSize:Ct[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(r=t==null?void 0:t.primaryBg)!=null?r:"#111827":"transparent",color:e==="primary"?(m=t==null?void 0:t.primaryText)!=null?m:"#ffffff":"inherit",border:e==="secondary"?"1px solid currentColor":"none"})}function Dn({node:e,opts:t}){var s,r,m;let n=(s=e.emphasis)!=null?s:"primary",i={padding:"8px 10px",font:"inherit",border:"1px solid currentColor",borderRadius:(m=(r=t.palette)==null?void 0:r.radius)!=null?m:"8px"};return At("form",{onSubmit:o=>{var d,f,p;o.preventDefault();let a=new FormData(o.currentTarget),l={};for(let h of e.fields)l[h.name]=String((d=a.get(h.name))!=null?d:"");(f=t.onFormGoal)==null||f.call(t,e.submitGoal);try{(p=t.onFormSubmit)==null||p.call(t,l)}catch(h){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(o=>{var a,l;return At("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[o.label,o.kind==="textarea"?O("textarea",{name:o.name,required:o.required,placeholder:o.placeholder,rows:3,style:i}):o.kind==="select"?O("select",{name:o.name,required:o.required,style:i,children:((a=o.options)!=null?a:[]).map(d=>O("option",{value:d,children:d},d))}):O("input",{name:o.name,type:(l=o.inputType)!=null?l:"text",required:o.required,placeholder:o.placeholder,style:i})]},o.name)}),O("button",{type:"submit",style:kt(n,t.palette),children:e.submitLabel})]})}function fe(e,t){var n,i,s,r,m,o,a,l,d;try{switch(e.type){case"stack":{let f=(i=de[(n=e.gap)!=null?n:"md"])!=null?i:de.md;return O("div",{style:S(S(S({display:"flex",flexDirection:e.direction,gap:f},e.align?{alignItems:Ee[e.align]}:{}),e.justify?{justifyContent:Ee[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),children:((s=e.children)!=null?s:[]).map((p,h)=>{let b=fe(p,t);return b===null?null:O(ht,{children:b},h)})})}case"grid":{let f=(m=de[(r=e.gap)!=null?r:"md"])!=null?m:de.md;return O("div",{style:S({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${f}) / ${e.columns})), 1fr))`,gap:f},e.align?{alignItems:Ee[e.align]}:{}),children:((o=e.children)!=null?o:[]).map((p,h)=>{let b=fe(p,t);return b===null?null:O(ht,{children:b},h)})})}case"text":return O("p",{style:S(S(S(S({margin:0},e.size?{fontSize:Ct[e.size]}:{}),e.weight?{fontWeight:Ln[e.weight]}:{}),e.align?{textAlign:e.align}:{}),xt(e.tone)),children:e.value});case"heading":{let f=`h${e.level}`;return O(f,{style:S({margin:0,fontSize:Pn[(a=e.size)!=null?a:"md"]},e.align?{textAlign:e.align}:{}),children:e.value})}case"button":{let f=(l=e.emphasis)!=null?l:"primary";return O("a",K(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:kt(f,t.palette,e.size),children:e.label}))}case"link":return O("a",K(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:{color:"inherit",textDecoration:"underline"},children:e.label}));case"image":return O("img",{src:e.src,alt:e.alt,style:S(S({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:In[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})});case"badge":return O("span",{style:S({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:"1px solid currentColor"},xt(e.tone)),children:e.value});case"spacer":return O("div",{style:{height:(d=wt[e.size])!=null?d:wt.md}});case"form":return O(Dn,{node:e,opts:t});default:return null}}catch(f){return null}}import{jsx as Mn}from"react/jsx-runtime";var _t=new Set;function Bn({id:e,children:t,onFormSubmit:n,goal:i,className:s}){var C,k;let r=G(),m=B(),{config:o,arm:a,palette:l,source:d}=St(e),f=Rt(null),p=a!==""?(C=o==null?void 0:o.blocks)==null?void 0:C[a]:void 0,h=p!==void 0&&Fn(p)&&!n;ge(()=>{!h||!_()||_t.has(e)||(_t.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[h,e]);let b=R=>{!r||d==="override"||(r.componentGoal(e,R),r.goal(R,{metadata:{componentId:e,arm:a},weight:1,stepIndex:0}))},y=t;p!==void 0&&!h?y=(k=fe(p,{palette:l,onFormSubmit:n,onFormGoal:b}))!=null?k:t:(o==null?void 0:o.content)!==void 0&&d!=="none"&&(y=o.content);let c=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";ge(()=>X({id:e,arms:c===""?void 0:c.split("|")}),[e,c]);let u=Rt(null);ge(()=>{!r||d==="none"||d==="override"||a===""||u.current===a||(u.current=a,j(r,m,e,a))},[r,m,e,a,d]);let g=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);ge(()=>{if(!r||!i||d==="override"||d==="none")return;let R=f.current;if(!R)return;let x=N(i),A=T(i),w=!1;return F(R,P(i),{fireGoal:()=>{w||(w=!0,A!==void 0?r.componentGoal(e,x,{value:A}):r.componentGoal(e,x),r.goal(x,S({metadata:{componentId:e,arm:a},weight:1,stepIndex:0},A!==void 0?{value:A}:{})))},fireStep:(E,M,H)=>{r.componentGoal(e,E,{reward:M}),r.goal(E,{metadata:{componentId:e,arm:a},weight:M,stepIndex:H})}},x)},[r,e,g,a,d]);let v=Tn(()=>S({"data-sentient-slot":e},a!==""?{"data-sentient-arm":a}:{}),[e,a]);return Mn("div",K(S({ref:f,className:s},v),{children:y}))}import{useCallback as Gt,useEffect as J,useMemo as Pe,useRef as Ie,useState as Kn}from"react";import{attachMicroSignalDetectors as jn}from"@sentientui/core";var Ot=new Set;function Nn(e,t){var x;if(_()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let n=G(),i=B(),s=Object.keys(t.variants).join(" "),r=Pe(()=>Object.keys(t.variants),[s]),{variantId:m,isOverride:o,settled:a}=Z(e,r),l=(x=m!=null?m:r[0])!=null?x:"",d=t.variants[l],[f,p]=Kn(null),h=Ie(null),b=Gt(A=>{h.current=A,p(A)},[]),y=typeof t.goal=="string"?t.goal:JSON.stringify(t.goal),c=Pe(()=>t.goal?P(t.goal):null,[y]),u=t.goal?N(t.goal):"";J(()=>ee({id:e,variantIds:r,goal:u}),[e,r,u]);let g=Ie(null);J(()=>{o||a&&(!n||!l||!f||g.current!==l&&(g.current=l,j(n,i,e,l)))},[n,i,e,l,f,o,a]);let v=t.funnel;J(()=>{o||!a||!n||!v||!c||$(n,i,e,v,c)},[n,i,e,v,c,o,a]);let C=Ie(!1);J(()=>{C.current=!1},[l,y]),J(()=>{if(o||!a||!n||!l||!f||!c)return;let A=T(c);return F(f,c,{fireGoal:()=>{C.current||(C.current=!0,n.track({projectId:i,componentId:e,variantId:l,eventType:"goal_achieved",goalType:u,payload:S({reward:1},A!==void 0?{goalValue:A}:{})}),n.goal(u,S({metadata:{componentId:e,variantId:l},weight:1,stepIndex:0},A!==void 0?{value:A}:{})))},fireStep:(w,E,M)=>{n.track({projectId:i,componentId:e,variantId:l,eventType:"goal_achieved",goalType:w,payload:{reward:E}}),n.goal(w,{metadata:{},weight:E,stepIndex:M})}},u)},[n,f,l,i,e,c,u,o,a]),J(()=>{if(o||!n||!l||!f)return;let A=Date.now();return jn((w,E={})=>{n.track({projectId:i,componentId:e,variantId:l,eventType:"micro_signal",payload:S({signalType:w},E)})},f,A)},[n,f,l,i,e,o]),J(()=>{if(!_()||!n)return;let A=setTimeout(()=>{!h.current&&!Ot.has(e)&&(Ot.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(A)},[n,e]);let k=Gt((A,w)=>{var M,H;if(o)return;let E=A!=null?A:u;E&&(n==null||n.componentGoal(e,E,w),n==null||n.goal(E,S(S(S({metadata:(M=w==null?void 0:w.metadata)!=null?M:{},weight:(H=w==null?void 0:w.reward)!=null?H:1,stepIndex:0},(w==null?void 0:w.value)!==void 0?{value:w.value}:{}),(w==null?void 0:w.currency)!==void 0?{currency:w.currency}:{}),(w==null?void 0:w.externalId)!==void 0?{externalId:w.externalId}:{})))},[n,e,u,o]),R=Pe(()=>({ref:b,"data-sentient-id":e,"data-sentient-variant":l}),[b,e,l]);return{variant:l,value:d,bind:R,fireGoal:k}}import{Children as $n,isValidElement as Vn,useEffect as me,useMemo as Et,useRef as Pt}from"react";import{jsx as Un}from"react/jsx-runtime";var pe=new Set;function Wn(e){var u;let t=G(),n=B(),i=Pt(null),s=Object.keys(e.arrangements).join(" "),r=Et(()=>Object.keys(e.arrangements),[s]),m=Et(()=>S({id:e.id,arms:r},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,r,e.baseline]),{arm:o,source:a}=ue(e.id,m);_()&&e.baseline!==void 0&&e.baseline!==r[0]&&!pe.has(e.id+":baseline")&&(pe.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${r[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let l=$n.toArray(e.children).filter(Vn),d=new Map;for(let g of l)d.set(String((u=g.key)!=null?u:"").replace(/^\.\$/,""),g);let f=e.arrangements[o],p=f!==void 0&&f.length===l.length&&f.every(g=>d.has(g));_()&&f!==void 0&&!p&&!pe.has(e.id+":keys")&&(pe.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${o}" [${f.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let h=p?f.map(g=>d.get(g)):l;me(()=>X({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let b=Pt(null);me(()=>{!t||a==="baseline"||a==="override"||b.current===o||(b.current=o,j(t,n,e.id,o))},[t,n,e.id,o,a]);let y=e.funnel;me(()=>{var g;!t||!y||a==="override"||$(t,n,e.id,y,P((g=e.goal)!=null?g:"click"))},[t,n,e.id,y,a]);let c=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return me(()=>{if(!t||e.goal===void 0||a==="override"||a==="baseline")return;let g=i.current;if(!g)return;let v=N(e.goal),C=T(e.goal),k=!1;return F(g,P(e.goal),{fireGoal:()=>{k||(k=!0,C!==void 0?t.componentGoal(e.id,v,{value:C}):t.componentGoal(e.id,v),t.goal(v,S({metadata:{componentId:e.id,arm:o},weight:1,stepIndex:0},C!==void 0?{value:C}:{})))},fireStep:(R,x,A)=>{t.componentGoal(e.id,R,{reward:x}),t.goal(R,{metadata:{componentId:e.id,arm:o},weight:x,stepIndex:A})}},v)},[t,e.id,c,o,a]),Un("div",{ref:i,"data-sentient-id":e.id,"data-sentient-variant":o,children:h})}import{deriveSessionSegment as Jn}from"@sentientui/core";var Hn=["page","blocks","layoutOrder"],It=new Map;function Xn(e,t){It.set(e,t)}function Lt(e){return It.get(e)}function zn(e){var s,r;let t=(r=(s=e.content)!=null?s:Lt(e.page))!=null?r:{},n={};for(let[m,o]of Object.entries(t))Hn.includes(m)||(n[m]=o);let i=K(S({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(i.layoutOrder=e.layoutOrder),i}function qn(e){return`<script type="application/ld+json">${Dt(e)}</script>`}function Dt(e){return JSON.stringify(S({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function Zn(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,i]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(i,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
3
3
  `).trimEnd()+`
4
- `}import{grantConsent as _i}from"@sentientui/core";export{Mt as Adaptive,mn as AdaptiveGroup,Gt as AdaptiveProvider,$t as AdaptiveText,qt as SentientPersonaScript,hn as buildAgentFeed,Sn as defineAgentContent,vn as detectSegment,gt as getAgentContent,_i as grantConsent,bn as renderAgentJsonLd,mt as renderAgentJsonLdBody,wn as renderAgentMarkdown,dn as useAdaptive,Ot as useAdaptiveApiBaseUrl,we as useAdaptiveGoal,rn as useAdaptivePersona,ln as useAdaptiveTokens,H as useAssignment,Se as useInitialAssignments,Rt as useLayoutOrder,Jt as usePageGoal,R as useSentient};
4
+ `}import{grantConsent as xo}from"@sentientui/core";export{rn as Adaptive,Wn as AdaptiveGroup,Ht as AdaptiveProvider,Bn as AdaptiveSlot,ln as AdaptiveText,yn as SentientPersonaScript,zn as buildAgentFeed,Xn as defineAgentContent,Jn as detectSegment,Lt as getAgentContent,xo as grantConsent,qn as renderAgentJsonLd,Dt as renderAgentJsonLdBody,Zn as renderAgentMarkdown,Nn as useAdaptive,zt as useAdaptiveApiBaseUrl,Re as useAdaptiveGoal,Cn as useAdaptivePersona,Gn as useAdaptiveTokens,Z as useAssignment,Ae as useInitialAssignments,Xt as useLayoutOrder,gn as usePageGoal,G as useSentient};
5
5
  //# sourceMappingURL=index.mjs.map