@sentientui/react 0.35.3 → 0.36.1
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/index.d.cts +10 -19
- package/dist/index.d.ts +10 -19
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/next/adaptive-root.d.ts +21 -20
- package/dist/next/adaptive-root.js +2 -2
- package/dist/next/adaptive-root.js.map +1 -1
- package/dist/testing/react.js +1 -1
- package/dist/testing/react.js.map +1 -1
- package/dist/testing/react.mjs +1 -1
- package/dist/testing/react.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/server.d.cts +0 -103
- package/dist/server.d.ts +0 -103
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
var Vn=Object.defineProperty,Fn=Object.defineProperties;var Mn=Object.getOwnPropertyDescriptors;var he=Object.getOwnPropertySymbols;var St=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var vt=(e,t,n)=>t in e?Vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))St.call(t,n)&&vt(e,n,t[n]);if(he)for(var n of he(t))ht.call(t,n)&&vt(e,n,t[n]);return e},L=(e,t)=>Fn(e,Mn(t));var be=(e,t)=>{var n={};for(var r in e)St.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&he)for(var r of he(e))t.indexOf(r)<0&&ht.call(e,r)&&(n[r]=e[r]);return n};import{createContext as Un,useContext as F,useEffect as Y,useMemo as Jt,useRef as qe,useState as we,useSyncExternalStore as Hn}from"react";import{deriveSessionSegment as Xn,init as zn}from"@sentientui/core";var bt=new Map,xe=new Map;function xt(e,t){let n=xe.get(e);return n||(n=new Set,xe.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&xe.delete(e)}}function wt(e,t){bt.set(e,t);let n=xe.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function Be(e){var t;return(t=bt.get(e))!=null?t:null}var $n={on:!1,listeners:new Set};function kt(){if(typeof window=="undefined")return $n;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function je(){return kt().on}function Rt(e){let t=kt().listeners;return t.add(e),()=>{t.delete(e)}}function At(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),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(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Ke="sentient:overrides-changed";function Ct(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function We(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(Ke))}function $(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(Ke,e),()=>window.removeEventListener(Ke,e))}function _t(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 B(e){return typeof e=="string"?{type:"click"}:e}function Q(e){return typeof e=="string"?e:e.type}function H(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var Je=new Set,Ue=!1;function Ot(e){if(Je.has(e))return!0;if(Je.add(e),!Ue){Ue=!0;let t=()=>{Ue=!1,Je.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 Bn(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function Et(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(Bn(r))return!0;r=r.parentElement}return!1}function X(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,y=[];return t.steps.forEach(({goal:f,name:h,weight:R},c)=>{let u=(p=!1)=>{s.has(c)||p&&r!==void 0&&Ot(`step\0${h}\0${R}\0${c}`)||(s.add(c),n.fireStep(h,R,c))};if(f.type==="click"){let p=g=>{let a=g.target;a instanceof Element&&Et(a,e,f.selector)&&u()};e.addEventListener("click",p),y.push(()=>e.removeEventListener("click",p));return}if(f.type==="form_submit"){let p=g=>{g.target instanceof HTMLFormElement&&e.contains(g.target)&&u()};e.addEventListener("submit",p),y.push(()=>e.removeEventListener("submit",p));return}if(f.type==="scroll_depth"){let p=Math.max(0,Math.min(1,f.threshold)),g=new IntersectionObserver(a=>{for(let S of a)if(S.intersectionRatio>=p){u(!0),g.disconnect();break}},{threshold:[p]});g.observe(e),y.push(()=>g.disconnect())}}),()=>{for(let f of y)f()}}let i=t.type==="composite"?t.all:[t],l=new Set(i.map((s,y)=>y)),d=()=>{r!==void 0&&Ot(r)||n.fireGoal()},o=(s,y=!1)=>{l.delete(s),l.size===0&&(y?d():n.fireGoal())},m=[];return i.forEach((s,y)=>{if(s.type==="click"){let f=h=>{let R=h.target;R instanceof Element&&Et(R,e,s.selector)&&(t.type==="composite"?o(y):n.fireGoal())};e.addEventListener("click",f),m.push(()=>e.removeEventListener("click",f));return}if(s.type==="form_submit"){let f=h=>{h.target instanceof HTMLFormElement&&e.contains(h.target)&&(t.type==="composite"?o(y):n.fireGoal())};e.addEventListener("submit",f),m.push(()=>e.removeEventListener("submit",f));return}if(s.type==="scroll_depth"){let f=Math.max(0,Math.min(1,s.threshold)),h=new IntersectionObserver(R=>{for(let c of R)if(c.intersectionRatio>=f){t.type==="composite"?o(y,!0):d(),h.disconnect();break}},{threshold:[f]});h.observe(e),m.push(()=>h.disconnect());return}}),()=>{for(let s of m)s()}}var Pt=new Set,Gt=new Set;function le(e,t,n,r,i){let l=`${r}|${n}`;if(Gt.has(l))return;Gt.add(l);let d=i.type==="weighted_composite"&&!Pt.has(r);d&&Pt.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:d?{funnelId:r,steps:i.steps.map(o=>({goalId:o.name,weight:o.weight}))}:{funnelId:r}})}function ee(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var jn={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function ie(){if(typeof window=="undefined")return jn;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 ve(){ie().version+=1;for(let e of ie().listeners)e()}var Tt=()=>{};function Lt(e){return G()?(ie().components.set(e.id,e),ve(),()=>{ie().components.delete(e.id),ve()}):Tt}function ue(e){return G()?(ie().slots.set(e.id,e),ve(),()=>{ie().slots.delete(e.id),ve()}):Tt}function He(e){G()&&(ie().sections=[...e],ve())}var Dt="0.35.3",Xe=Dt!=="0.0.0-dev"?{name:"react",version:Dt}:void 0;function Kn(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function ce(e,t){Kn()[e]=t}function It(e){window.__sentient_vocabulary_override=e}function Nt(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Wn(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function de(e,t){Wn()[e]=t}var Vt="sentient_editor",Ft="sentient_preview_cell",Mt="sentient_refresh_region",ze="sentient-cell-preview-bar",oe="__preview__",fe=null;function $t(e){if((fe==null?void 0:fe.slotId)!==e)return null;let t=fe;return fe=null,t}function Bt(e,t){fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(v({slotId:e.slotId},t))}).then(n=>ge(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>ge("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function jt(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(ze))return;let t,n,r;try{let m=new URLSearchParams(window.location.search);t=m.get(Vt),n=m.get(Ft),r=m.get(Mt)}catch(m){return}if(t&&r){fe={slotId:r,token:t,base:(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"")},ce(r,{kind:"arms"}),de(r,oe),We();return}if(!t||!n)return;let i=n.lastIndexOf("~");if(i<=0)return;let l=n.slice(0,i),d=n.slice(i+1),o=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${o}/editor/cell-preview?slotId=${encodeURIComponent(l)}&persona=${encodeURIComponent(d)}`,{headers:{authorization:`Bearer ${t}`}}).then(async m=>{if(!m.ok){ge(m.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await m.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&It(s.vocabulary),s.compose!=null)ce(l,{kind:"arms",compose:{[oe]:s.compose}}),de(l,oe);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))ce(l,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),de(l,oe);else if(s.blocks!=null)ce(l,{kind:"arms",blocks:{[oe]:s.blocks}}),de(l,oe);else if(s.content!=null)ce(l,{kind:"arms",content:s.content}),de(l,oe);else{ge("Nothing to preview in that square yet.");return}We(),ge(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${l}"]`))==null||y.scrollIntoView({block:"center"})}catch(f){}},300)}).catch(()=>ge("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function ge(e){var i;if(document.getElementById(ze))return;let t=document.createElement("div");t.id=ze,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{let l=new URL(window.location.href);l.searchParams.delete(Vt),l.searchParams.delete(Ft),l.searchParams.delete(Mt),window.location.assign(l.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var Jn="sentient_editor",Kt=!1;function Wt(e){if(Kt||typeof window=="undefined")return;let t=null;try{t=new URLSearchParams(window.location.search).get(Jn)}catch(i){return}if(!t)return;Kt=!0;let n=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),r=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:i})=>fetch(`${n}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(i(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?r():window.addEventListener("load",r,{once:!0})}import{jsx as tr}from"react/jsx-runtime";function qn(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return Xn({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Ut="https://api.sentient-ui.com/v1",V=Un({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Ut,debug:!1});function Zn(e){let[t,n]=we(!1),r=qe(e);r.current=e;let{cookie:i,value:l,event:d}=e!=null?e:{},o=typeof(e==null?void 0:e.check)=="function";return Y(()=>{let m=()=>{var h;let y=r.current;if(!y)return!1;if(y.check)return y.check()===!0;if(!y.cookie||typeof document=="undefined")return!1;let f=`${y.cookie}=${(h=y.value)!=null?h:"accepted"}`;return document.cookie.split("; ").some(R=>R.trim()===f)};if(n(m()),!d)return;let s=()=>{n(m())};return window.addEventListener(d,s),()=>window.removeEventListener(d,s)},[i,l,d,o]),t}function Yn(e){var c,u;let[t,n]=we(null),[r]=we(()=>{var p;return(p=e.sessionSegment)!=null?p:qn()}),[i,l]=we(je());Y(()=>Rt(()=>l(je())),[]),Y(()=>{jt(e.apiBaseUrl),Wt(e.apiBaseUrl)},[]);let d=Zn(e.consentFrom),o=e.consentFrom?e.consent===!0||d:e.consent,m=qe(null);Y(()=>{var A;if(o===!1&&!e.preConsentBehavior){(A=m.current)==null||A.destroy(),m.current=null,n(null);return}let p=v({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,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,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},Xe?{sdk:Xe}:{}),g=!1,a=null,S=null,x=O=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:b})=>{g||(S=b(O,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:O})=>{g||(a=O(L(v({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),m.current=a,n(a),x(a))}):(a=zn(p),m.current=a,n(a),x(a)),()=>{g=!0,S==null||S(),a==null||a.dispose()}},[o]),Y(()=>{if(!t)return;let p=!1,g=async()=>{if(p)return;let S;try{S=await t.fetchWeights()}catch(x){return}if(!p)for(let x of S){let A={componentId:x.componentId,updatedAt:x.updatedAt,variants:x.variants.map(O=>{var b;return{variantId:O.variantId,pulls:O.pulls,avgReward:(b=O.avgReward)!=null?b:0}})};wt(x.componentId,A)}};g();let a=setInterval(()=>{g()},6e4);return()=>{p=!0,clearInterval(a)}},[t]);let s=(c=e.ssrFallback)!=null?c:"first",y=((u=e.apiBaseUrl)!=null?u:Ut).replace(/\/$/,""),f=qe(null);Y(()=>{var a;if(typeof process!="undefined"&&((a=process.env)==null?void 0:a.NODE_ENV)==="production")return;let p={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:y},g=f.current;if(f.current=p,g!==null)for(let S of["apiKey","context","country","persona","apiBaseUrl"])Object.is(g[S],p[S])||console.warn(`[sentient] AdaptiveProvider: \`${S}\` 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,y]),Y(()=>{var p;typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production"||_t({apiKey:e.apiKey,apiBaseUrl:y,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,y]),Y(()=>{let p=e.initialLayoutOrder;if(p&&p.length>0){He(p);return}e.declaredSections&&e.declaredSections.length>0&&He(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),Y(()=>{if(!G())return;let p=e.declaredSections;if(!p||p.length===0||typeof document=="undefined")return;let g=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),S=>S.getAttribute("data-sentient-id"))),a=p.filter(S=>!g.has(S));a.length>0&&console.warn(`[SentientUI] Declared section${a.length>1?"s":""} ${a.map(S=>`"${S}"`).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>" to each section's element.`)},[e.declaredSections]);let h=Jt(()=>t&&i?At(t):t,[t,i]),R=Jt(()=>{var p,g,a,S,x,A,O,b;return{client:h,apiKey:e.apiKey,initialAssignments:(p=e.initialAssignments)!=null?p:{},sessionSegment:r,ssrFallback:s,onAssignment:e.onAssignment,initialLayoutOrder:(g=e.initialLayoutOrder)!=null?g:null,initialSlots:(a=e.initialSlots)!=null?a:{},initialSlotConfig:(S=e.initialSlotConfig)!=null?S:{},initialPalette:(x=e.initialPalette)!=null?x:null,initialVocabulary:(A=e.initialVocabulary)!=null?A:null,initialPersona:(O=e.initialPersona)!=null?O:null,apiBaseUrl:y,debug:(b=e.debug)!=null?b:!1}},[h,e.apiKey,e.initialAssignments,r,s,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,y,e.debug]);return tr(V.Provider,{value:R,children:e.children})}function D(){return F(V).client}function z(){return F(V).apiKey}function Ze(){return F(V).initialAssignments}function ke(){return F(V).sessionSegment}function Ht(){return F(V).ssrFallback}function Re(){return F(V).onAssignment}function Xt(){return F(V).debug}function Qn(){let e=F(V).initialLayoutOrder,t=Hn($,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ae(){return F(V).initialSlots}function zt(){return F(V).initialPersona}function qt(){return F(V).initialSlotConfig}function Zt(){return F(V).initialPalette}function Yt(){return F(V).initialVocabulary}function er(){return F(V).apiBaseUrl}import{memo as kr,useEffect as Rr,useState as Ar}from"react";import{useCallback as ir,useEffect as se,useMemo as en,useRef as Se,useState as or}from"react";import{attachMicroSignalDetectors as sr}from"@sentientui/core";import{useEffect as Ce,useRef as Qt,useState as nr,useSyncExternalStore as rr}from"react";import{pickFromWeights as Ye}from"@sentientui/policy";function me(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 i of r.getAll("sentient_variant")){let l=i.indexOf(":");if(l!==-1&&i.slice(0,l)===e)return i.slice(l+1)}}catch(r){}return null}function Qe(e,t,n,r){let i=Ze(),l=Ht(),d=D(),o=ke(),m=Re(),s=Xt(),y=Qt(null),f=rr($,()=>me(e),()=>null),h=f&&t.includes(f)?f:null,R=Qt(null);Ce(()=>{s&&h&&R.current!==h&&(R.current=h,console.info(`[sentient] override active: ${e} -> ${h}`))},[s,h,e]);let[c,u]=nr(()=>{var S,x;if(h)return{variantId:h,content:null,isLoading:!1,settled:!0};if(!d){let A=i[e];return A&&t.includes(A)?{variantId:A,content:null,isLoading:!1,settled:!0}:l==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let g=d.getAssignment(e,o);if(g&&(t.includes(g.variantId)||g.content))return{variantId:g.variantId,content:(S=g.content)!=null?S:null,isLoading:!1,settled:!0};let a=Be(e);if(a){let A=Ye(a.variants,t);if(A)return{variantId:A,content:null,isLoading:!1,settled:!0}}return{variantId:(x=t[0])!=null?x:null,content:null,isLoading:!1,settled:!1}}),p=g=>{m&&y.current!==g&&(y.current=g,m(e,g))};return Ce(()=>{var S;if(h||!d)return;let g=d.getAssignment(e,o);if(g&&(t.includes(g.variantId)||g.content)){u({variantId:g.variantId,content:(S=g.content)!=null?S:null,isLoading:!1,settled:!0}),p(g.variantId);return}let a=Be(e);if(a&&c.settled&&c.variantId&&c.variantId===Ye(a.variants,t)){p(c.variantId);return}u(x=>{var A;return x.variantId?x:{variantId:(A=t[0])!=null?A:null,content:null,isLoading:!1,settled:!1}})},[h,d,e,o]),Ce(()=>{if(h||!d)return;let g=d.getAssignment(e,o);if(g&&t.includes(g.variantId))return;let a=!1;return d.assign(e,t,n,r).then(S=>{var x;a||S&&(!t.includes(S.variantId)&&!S.content||(u({variantId:S.variantId,content:(x=S.content)!=null?x:null,isLoading:!1,settled:!0}),p(S.variantId)))}),()=>{a=!0}},[h,d,e,o]),Ce(()=>{if(!h&&d)return xt(e,g=>{var x;let a=d.getAssignment(e,o);if(a&&(t.includes(a.variantId)||a.content)){u({variantId:a.variantId,content:(x=a.content)!=null?x:null,isLoading:!1,settled:!0}),p(a.variantId);return}let S=Ye(g.variants,t);S&&(u({variantId:S,content:null,isLoading:!1,settled:!0}),p(S))})},[h,d,e,o]),h?{variantId:h,content:null,isLoading:!1,settled:!0,isOverride:!0}:c}function _e(e,t,n){let r=D(),i=z(),l=Object.keys(t).join("\0"),d=en(()=>Object.keys(t),[l]),{variantId:o,content:m,isOverride:s=!1,settled:y}=Qe(e,d,n.agentData,n.agentDataByVariant),[f,h]=or(null),R=Se(null),c=ir(_=>{R.current=_,h(_)},[]),u=n.goal,p=typeof u=="string"?u:JSON.stringify(u),g=en(()=>u?B(u):null,[p]),a=u?Q(u):"";se(()=>Lt({id:e,variantIds:d,goal:a}),[e,d,a]);let S=Se(null);se(()=>{s||y&&(!r||!o||!i||!f||S.current!==o&&(S.current=o,ee(r,i,e,o)))},[r,o,i,e,f,s,y]);let x=Se(!1),A=Se(new Set);se(()=>{x.current=!1,A.current=new Set},[o,g]);let O=n.funnel;se(()=>{s||!y||!r||!O||!g||le(r,i,e,O,g)},[r,i,e,O,g,s,y]);let b=n.cursorSignal===!0;se(()=>{if(!b||s||!y||!r||!o||!f)return;let _=null,E=0,N=()=>{E=Date.now(),_=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:o,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-E}}),_=null},800)},T=()=>{_!==null&&(clearTimeout(_),_=null)};return f.addEventListener("mouseenter",N),f.addEventListener("mouseleave",T),()=>{f.removeEventListener("mouseenter",N),f.removeEventListener("mouseleave",T),_!==null&&clearTimeout(_)}},[b,r,o,i,e,f,s,y]);let k=Se(n.microSignalGoals);k.current=n.microSignalGoals;let w=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return se(()=>{if(s||!y||!r||!o||!f)return;let _=Date.now();return sr((E,N={})=>{var Z,ne,J;r.track({projectId:i,componentId:e,variantId:o,eventType:"micro_signal",payload:v({signalType:E},N)});let T=(Z=k.current)==null?void 0:Z[E];if(!T||A.current.has(E))return;A.current.add(E);let K=typeof T=="string"?T:T.name,W=typeof T=="string"?1:(ne=T.weight)!=null?ne:1,q=typeof T=="string"?0:(J=T.stepIndex)!=null?J:0;r.goal(K,{metadata:v({signalType:E},N),weight:W,stepIndex:q})},f,_)},[r,o,i,e,f,w,s,y]),se(()=>{if(s||!y||!r||!o||!f||!g)return;let _=H(g);return X(f,g,{fireGoal:()=>{x.current||(x.current=!0,r.track({projectId:i,componentId:e,variantId:o,eventType:"goal_achieved",goalType:a,payload:v({reward:1},_!==void 0?{goalValue:_}:{})}),r.goal(a,v({metadata:{componentId:e,variantId:o},weight:1,stepIndex:0},_!==void 0?{value:_}:{})))},fireStep:(E,N,T)=>{r.track({projectId:i,componentId:e,variantId:o,eventType:"goal_achieved",goalType:E,payload:{reward:N}}),r.goal(E,{metadata:{},weight:N,stepIndex:T})}},a)},[r,o,i,e,f,g,a,s,y]),{client:r,variantIds:d,variantId:o,content:m,settled:y,isOverride:s,goalLabel:a,ref:c,nodeRef:R}}import{useEffect as j,useMemo as lt,useRef as ut}from"react";import{containsFormBlock as vn,reveal as xr}from"@sentientui/core";import{captureRegionSkeleton as Sn}from"@sentientui/core/region";import{useCallback as ar,useEffect as tn,useRef as et,useSyncExternalStore as Oe}from"react";import{armOfResult as lr}from"@sentientui/core";var nn=new Set;function rn(e,t){var x,A,O;let n=D(),r=et(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=et(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let l=et(t==null?void 0:t.skeleton);l.current=t==null?void 0:t.skeleton;let d=Ae(),o=qt(),m=Zt(),s=Yt(),y=Oe($,()=>{var b;return typeof window!="undefined"?(b=window.__sentient_slot_config_overrides)==null?void 0:b[e]:void 0},()=>{}),f=Oe($,()=>{var b;return typeof window!="undefined"?(b=window.__sentient_slot_overrides)==null?void 0:b[e]:void 0},()=>{}),h=b=>b==null?"":lr(b),R=ar(b=>{var k,w;return(w=(k=n==null?void 0:n.onSlotsChanged)==null?void 0:k.call(n,b))!=null?w:(()=>{})},[n]);Oe(R,()=>{var b;return(b=n==null?void 0:n.getSlotConfig(e))!=null?b:null},()=>null),Oe(R,()=>h(n==null?void 0:n.getSlotResult(e)),()=>"");let c=y===void 0?o[e]:void 0,u=y===void 0&&c===void 0&&n?n.getSlotConfig(e):null,p=(x=m!=null?m:n==null?void 0:n.getSitePalette())!=null?x:null,g=(O=s!=null?s:(A=n==null?void 0:n.getStyleVocabulary)==null?void 0:A.call(n))!=null?O:null,a=(()=>{var b,k,w;if(y!==void 0)return{config:y,arm:h(f),palette:p,vocabulary:(b=Nt())!=null?b:g,source:"override"};if(c!==void 0)return{config:c,arm:h((k=d[e])!=null?k:n==null?void 0:n.getSlotResult(e)),palette:p,vocabulary:g,source:"preloaded"};if(u!==null){let _=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:u,arm:h((w=n==null?void 0:n.getSlotResult(e))!=null?w:d[e]),palette:p,vocabulary:g,source:_?"client":"seeded"}}return{config:null,arm:"",palette:p,vocabulary:g,source:"none"}})(),S=a.source==="preloaded"||a.source==="override";return tn(()=>{var K,W,q,Z,ne;if(!n||n.isLocal===!0||S)return;let b=a.source==="none",k=b&&(W=(K=r.current)==null?void 0:K.call(r))!=null?W:null,w=k!=null&&k!==""?{[e]:k}:void 0,_=(q=i.current)==null?void 0:q.call(i),E=b&&(ne=(Z=l.current)==null?void 0:Z.call(l))!=null?ne:null,N=v(v({},_?{render:{[e]:_}}:{}),E?{skeletons:{[e]:E}}:{}),T=Object.keys(N).length>0;return n.requestSlots?T?n.requestSlots([e],w,N):w?n.requestSlots([e],w):n.requestSlots([e]):b&&(E?n.reportSlots([e],w!=null?w:{},{[e]:E}):w?n.reportSlots([e],w):n.reportSlots([e])),()=>{var J;return(J=n.cancelSlots)==null?void 0:J.call(n,[e])}},[n,S,a.source,e]),tn(()=>{!G()||(n==null?void 0:n.isLocal)!==!0||a.source!=="none"||nn.has(e)||(nn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,a.source,e]),a}import{cloneElement as ur,Fragment as on}from"react";import{jsx as I,jsxs as un}from"react/jsx-runtime";var te={none:"0",sm:"8px",md:"16px",lg:"24px"},tt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},cn={sm:"0.875em",md:"1em",lg:"1.25em"},cr={sm:"1.25em",md:"1.5em",lg:"2em"},sn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},an={sm:"8px",md:"16px",lg:"32px"},dr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},fr={normal:"400",medium:"500",bold:"700"};function ln(e,t){return v(v({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?v({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function dn(e,t,n){var i,l,d,o;let r=t==null?void 0:t.accent;return L(v({display:"inline-block",padding:(i=sn[n!=null?n:"md"])!=null?i:sn.md,borderRadius:(l=t==null?void 0:t.radius)!=null?l:"8px",font:"inherit"},n?{fontSize:cn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(d=t==null?void 0:t.primaryBg)!=null?d:"#111827":"transparent",color:e==="primary"?(o=t==null?void 0:t.primaryText)!=null?o:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function gr({node:e,opts:t}){var i,l,d,o,m;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(d=(l=t.palette)==null?void 0:l.border)!=null?d:"currentColor"}`,borderRadius:(m=(o=t.palette)==null?void 0:o.radius)!=null?m:"8px"};return un("form",{onSubmit:s=>{var h,R,c;s.preventDefault();let y=new FormData(s.currentTarget),f={};for(let u of e.fields)f[u.name]=String((h=y.get(u.name))!=null?h:"");(R=t.onFormGoal)==null||R.call(t,e.submitGoal);try{(c=t.onFormSubmit)==null||c.call(t,f)}catch(u){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var y,f;return un("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?I("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?I("select",{name:s.name,required:s.required,style:r,children:((y=s.options)!=null?y:[]).map(h=>I("option",{value:h,children:h},h))}):I("input",{name:s.name,type:(f=s.inputType)!=null?f:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),I("button",{type:"submit",style:dn(n,t.palette),children:e.submitLabel})]})}function mr(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(l=>l.id===n))==null?void 0:i.classes:void 0}function fn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function pe(e,t){var i;let n=pr(e,t),r=fn(e.like,t);return n&&r?ur(n,{style:L(v({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function pr(e,t){var n,r,i,l,d,o,m,s,y,f,h,R,c,u,p,g,a,S,x,A,O,b,k;try{let w=mr(e,t);switch(e.type){case"stack":{let _=(r=te[(n=e.gap)!=null?n:"md"])!=null?r:te.md,E=e.surface==="raised"&&!w,N=(i=e.pad)!=null?i:E?"md":void 0;return I("div",L(v({},w?{className:w}:{}),{style:v(v(v(v(v({display:"flex",flexDirection:e.direction,gap:_},e.align?{alignItems:tt[e.align]}:{}),e.justify?{justifyContent:tt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),N?{padding:(l=te[N])!=null?l:te.md}:{}),E?L(v(v({},(d=t.palette)!=null&&d.surface?{background:t.palette.surface}:{}),(o=t.palette)!=null&&o.surface&&((m=t.palette)!=null&&m.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(y=(s=t.palette)==null?void 0:s.border)!=null?y:"currentColor"}`,borderRadius:(h=(f=t.palette)==null?void 0:f.radius)!=null?h:"8px"}):{}),children:((R=e.children)!=null?R:[]).map((T,K)=>{let W=pe(T,t);return W===null?null:I(on,{children:W},K)})}))}case"grid":{let _=(u=te[(c=e.gap)!=null?c:"md"])!=null?u:te.md;return I("div",L(v({},w?{className:w}:{}),{style:v(v({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${_}) / ${e.columns})), 1fr))`,gap:_},e.align?{alignItems:tt[e.align]}:{}),e.pad?{padding:(p=te[e.pad])!=null?p:te.md}:{}),children:((g=e.children)!=null?g:[]).map((E,N)=>{let T=pe(E,t);return T===null?null:I(on,{children:T},N)})}))}case"text":return w?I("p",{className:w,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):I("p",{style:v(v(v(v(v({margin:0},e.size?{fontSize:cn[e.size]}:{}),e.weight?{fontWeight:fr[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),ln(e.tone,t.palette)),children:e.value});case"heading":{let _=`h${e.level}`;return w?I(_,{className:w,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):I(_,{style:v(v({margin:0,fontSize:cr[(a=e.size)!=null?a:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let _=(S=e.emphasis)!=null?S:"primary";return I("a",L(v(v({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),w?{className:w}:{style:dn(_,t.palette,e.size)}),{children:e.label}))}case"link":return I("a",L(v(v({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),w?{className:w}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return I("img",L(v({src:e.src,alt:e.alt},w?{className:w}:{}),{style:v(v({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:dr[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return w?I("span",{className:w,children:e.value}):I("span",{style:v({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(A=(x=t.palette)==null?void 0:x.border)!=null?A:"currentColor"}`},ln(e.tone,t.palette)),children:e.value});case"spacer":return I("div",{style:{height:(O=an[e.size])!=null?O:an.md}});case"divider":return I("hr",{style:{border:"none",borderTop:`1px solid ${(k=(b=t.palette)==null?void 0:b.border)!=null?k:"currentColor"}`,margin:0,width:"100%"}});case"form":return I(gr,{node:e,opts:t});default:return null}}catch(w){return null}}function nt(e,t){var l,d,o,m;let n=pe(e.tree,t);if(n===null)return null;let r=(l=e.surface)!=null&&l.like?(o=(d=t.vocabulary)==null?void 0:d.entries.find(s=>s.id===e.surface.like))==null?void 0:o.classes:void 0,i=fn((m=e.surface)==null?void 0:m.like,t);return r?I("div",L(v({className:r},i?{style:{color:i}}:{}),{children:n})):n}import{cloneElement as Ee,isValidElement as Pe}from"react";import{normalizeLeafText as yr,skeletonFingerprint as vr}from"@sentientui/core/region";function Ge(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function Te(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ae(e){return Ge(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ae(n),0):Pe(e)?ae(Te(e)):0}function Sr(e,t){return Array.isArray(t)?Ee(e,void 0,...t):Ee(e,void 0,t)}function rt(e,t){if(Ge(e))return t;if(Array.isArray(e))return e.map(n=>rt(n,t));if(Pe(e)){let n=Te(e);return ae(n)===0?e:Sr(e,rt(n,t))}return e}function gn(e,t){return ae(e)===1?rt(e,t):null}var M=e=>e.join("/");function it(e,t,n){if(Ge(e)){n.leafPaths.push(t),n.texts.push(yr(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>it(r,[...t,i],n));return}Pe(e)&&(n.elements.set(M(t),e),it(Te(e),[...t,"c"],n))}function st(e){let t={leafPaths:[],texts:[],elements:new Map};return it(e,[],t),t}function hr(e){return st(e).texts}function mn(e){let t=hr(e);return t.length===0?null:vr(t)}function br(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function pn(e,t){let n=t.reduce((i,l)=>Math.max(i,l+1),0),r=[];for(let i=0;i<n;i++){let l=t.flatMap((o,m)=>o===i?[br(e.leafPaths[m])]:[]);if(l.length===0){r.push(null);continue}let d=l[0];for(let o of l.slice(1)){let m=new Set(o.map(M));d=d.filter(s=>m.has(M(s)))}r.push(d.length>0?d[d.length-1]:null)}return r}function ot(e){var n;let t=(n=e==null?void 0:e.props)==null?void 0:n.className;return typeof t=="string"?t:void 0}function at(e,t){let n=st(t);if(n.texts.length!==e.leaves.length||n.texts.some((l,d)=>l!==e.leaves[d]))return null;let r=pn(n,e.leafToNode),i=e.nodes.map((l,d)=>{let o=r[d],m=o?n.elements.get(M(o)):void 0,s=!!m&&(typeof m.type=="string"||ot(m)!==void 0);return L(v({},l),{restylable:s})});return L(v({},e),{nodes:i})}function yn(e,t,n){var c;let r=st(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((u,p)=>Math.max(u,p+1),0);for(let u of Object.keys(t.nodes))if(!/^\d+$/.test(u)||Number(u)>=i)return null;let l=pn(r,n),d=new Map;n.forEach((u,p)=>{d.has(u)||d.set(u,p)});let o=new Map(r.leafPaths.map((u,p)=>[M(u),p])),m=new Set,s=new Map,y=!1;for(let[u,p]of Object.entries(t.nodes)){let g=Number(u),a=l[g];if(p.hidden&&(a?m.add(M(a)):y=!0),p.like!==void 0){let S=l[p.like],x=a?r.elements.get(M(a)):void 0,A=S?ot(r.elements.get(M(S))):void 0;!a||A===void 0||ot(x)===void 0?y=!0:s.set(M(a),A)}}let f=new Map(Object.entries((c=t.order)!=null?c:{})),h=(u,p)=>{var g;if(Ge(u)){let a=o.get(M(p));if(a===void 0)return u;let S=n[a],x=(g=t.nodes[String(S)])==null?void 0:g.text;return x===void 0?u:d.get(S)===a?x:""}if(Array.isArray(u)){let a=u.map((S,x)=>h(S,[...p,x]));for(let[S,x]of f){let A=x.map(k=>{let w=l[k];return!w||w.length!==p.length+1||M(w.slice(0,-1))!==M(p)?-1:w[w.length-1]});if(A.some(k=>k<0))continue;let O=[...A].sort((k,w)=>k-w),b=[...a];O.forEach((k,w)=>{a[k]=b[A[w]]}),f.delete(S)}return a}if(Pe(u)){let a=M(p);if(m.has(a))return null;let S=Te(u);if(ae(S)===0)return u;let x=h(S,[...p,"c"]),A=s.get(a),O=A!==void 0?{className:A}:void 0;return Array.isArray(x)?Ee(u,O,...x):Ee(u,O,x)}return u},R=h(e,[]);return y||f.size>0?null:R}import{jsx as wr}from"react/jsx-runtime";var hn=new Set,bn=new Set,xn=new Set,wn="authored.";function Le({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:l,reportBaselineText:d=!0}){var mt,pt;let o=D(),m=z(),s=ut(null),y=lt(()=>mn(t),[t]),f=n?Object.keys(n).join("|"):"",h=lt(()=>v({fp:y!=null?y:"0000000000000000",forms:!!r,compose:!0,content:ae(t)===1},f!==""?{authored:f.split("|"),children:!0}:{}),[y,t,r,f]),R=()=>{var U;let C=s.current;if(!C||!d)return null;let P=Sn(C);return P.skeleton?(U=at(P.skeleton,t))!=null?U:L(v({},P.skeleton),{editable:!1,nodes:P.skeleton.nodes.map(re=>L(v({},re),{restylable:!1}))}):{status:P.reason}},{config:c,arm:u,palette:p,vocabulary:g,source:a}=rn(e,{baselineText:d?()=>{var C,P;return(P=(C=s.current)==null?void 0:C.textContent)!=null?P:null}:void 0,render:()=>h,skeleton:R}),S=u!==""?(mt=c==null?void 0:c.blocks)==null?void 0:mt[u]:void 0,x=u!==""?(pt=c==null?void 0:c.compose)==null?void 0:pt[u]:void 0,A=(S!==void 0&&vn(S)||x!==void 0&&vn(x.tree))&&!r;j(()=>{!A||!G()||hn.has(e)||(hn.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.`))},[A,e]);let O=C=>{!o||a==="override"||(a!=="seeded"&&o.componentGoal(e,C),o.goal(C,{metadata:{componentId:e,arm:u},weight:1,stepIndex:0}))},b=t,k=!1,w=u.startsWith(wn)?u.slice(wn.length):null;if((c==null?void 0:c.blocked)==="variant_history")k=!0;else if(w!==null)n&&Object.prototype.hasOwnProperty.call(n,w)?b=n[w]:k=!0;else if(x!==void 0){let C=A?null:nt(x,{palette:p,vocabulary:g,onFormSubmit:r,onFormGoal:O});C===null?k=!0:b=C}else if(S!==void 0){let C=A?null:pe(S,{palette:p,vocabulary:g,onFormSubmit:r,onFormGoal:O});C===null?k=!0:b=C}else if((c==null?void 0:c.edits)!==void 0&&a!=="none"){let C=c.edits,P=C.fp===y?yn(t,C.edits,C.leafToNode):null;P===null?k=!0:b=P}else if((c==null?void 0:c.content)!==void 0&&a!=="none"){let C=gn(t,c.content);C===null?k=!0:b=C}let _=k&&S===void 0&&x===void 0&&(c==null?void 0:c.edits)===void 0&&w===null&&(c==null?void 0:c.blocked)===void 0;j(()=>{(c==null?void 0:c.blocked)!=="variant_history"||!G()||xn.has(e)||(xn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[c==null?void 0:c.blocked,e]);let E=w!==null&&!k?w:null;j(()=>{var ye;if(!E||!d||!o)return;let C=s.current;if(!C)return;let P=Sn(C),U=P.skeleton?at(P.skeleton,n==null?void 0:n[E]):null,re=(ye=C.textContent)==null?void 0:ye.trim();o.reportSlots([],void 0,void 0,{[e]:[v(v({key:E},re?{text:re}:{}),U?{skeleton:U}:{})]})},[E,o,e]);let N=k&&(c==null?void 0:c.edits)!==void 0&&(a==="preloaded"||a==="client");j(()=>{var C;!N||!(c!=null&&c.edits)||(C=o==null?void 0:o.reportDrift)==null||C.call(o,e,c.edits.fp,y,c.edits.fp===y?"unaddressable":"fp_mismatch")},[N,e,y,o]);let T=b===t;j(()=>{var P;if(!(c!=null&&c.needsSkeleton)||!T)return;let C=R();C&&((P=o==null?void 0:o.reportSkeleton)==null||P.call(o,e,C))},[c==null?void 0:c.needsSkeleton,T,e,o]),j(()=>{if(!T)return;let C=$t(e);if(!C)return;let P=R();Bt(C,P&&"status"in P?{status:P.status}:{skeleton:P})},[e,T]),j(()=>{!_||!G()||bn.has(e)||(bn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[_,e]);let K=c!=null&&c.blocks?Object.keys(c.blocks).sort().join("|"):"";j(()=>ue({id:e,arms:K===""?void 0:K.split("|")}),[e,K]);let W=ut(null);j(()=>{!o||a==="none"||a==="seeded"||a==="override"||u===""||k||W.current!==u&&(W.current=u,ee(o,m,e,u))},[o,m,e,u,a,k]);let q=a!=="none"&&a!=="seeded"&&!k,Z=q?u:"",ne=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);j(()=>{if(!o||!i||a==="override")return;let C=s.current;if(!C)return;let P=Q(i),U=H(i),re=!1;return X(C,B(i),{fireGoal:()=>{re||(re=!0,q&&(U!==void 0?o.componentGoal(e,P,{value:U}):o.componentGoal(e,P)),o.goal(P,v({metadata:{componentId:e,arm:Z},weight:1,stepIndex:0},U!==void 0?{value:U}:{})))},fireStep:(ye,yt,Nn)=>{q&&o.componentGoal(e,ye,{reward:yt}),o.goal(ye,{metadata:{componentId:e,arm:Z},weight:yt,stepIndex:Nn})}},P)},[o,e,ne,u,a,k,q,Z]);let J=ut(null);j(()=>{let C=s.current;if(C){if(J.current===null){J.current=u;return}J.current!==u&&(J.current=u,xr(C))}},[u]);let In=lt(()=>v({"data-sentient-slot":e},u!==""?{"data-sentient-arm":u}:{}),[e,u]);return wr("div",L(v({ref:s,className:l},In),{children:b}))}import{jsx as De}from"react/jsx-runtime";function Cr(e){var s;let{client:t,variantId:n,content:r,ref:i}=_e(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[l,d]=Ar(!1);if(Rr(()=>{d(!0)},[]),e.clientOnly&&(!l||!t)||!n)return null;let o=(s=e.variants[n])!=null?s:null,m=o===null?r:null;return G()&&o===null&&m===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),De("div",{ref:i,"data-sentient-id":e.id,"data-sentient-variant":n,children:o!=null?o:m})}var _r=kr(Cr,(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(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function Or(e){if(e.variants===void 0)return De(Le,v({},e));let t=e;if(t.children!=null){G()&&Er(t);let n=t,{funnel:r,microSignalGoals:i,agentData:l,agentDataByVariant:d,clientOnly:o,variants:m}=n,s=be(n,["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly","variants"]);return De(Le,L(v({},s),{children:t.children,variants:m}))}return De(_r,v({},t))}var kn=new Set;function Er(e){let t=["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly"].filter(n=>e[n]!==void 0);t.length===0||kn.has(e.id)||(kn.add(e.id),console.warn(`[sentient] <Adaptive id="${e.id}"> has both variants and children, so it runs as one experiment with your original and generated versions. These props only apply to a variants-only component and are ignored here: ${t.join(", ")}.`))}import{useEffect as Ie,useMemo as Pr,useRef as ct,useState as Rn,useSyncExternalStore as Gr}from"react";import{jsx as Lr}from"react/jsx-runtime";function Tr({id:e,default:t,component:n="span",className:r,goal:i}){var O;let l=D(),d=z(),o=Re(),m=ke(),s=ct(null),y=ct(null),f=Gr($,()=>me(e),()=>null),[h,R]=Rn(()=>{var b,k;return(k=(b=l==null?void 0:l.getAssignment(e,m))==null?void 0:b.content)!=null?k:null}),[c,u]=Rn(()=>{var b,k;return(k=(b=l==null?void 0:l.getAssignment(e,m))==null?void 0:b.variantId)!=null?k:null});Ie(()=>{if(f||!l)return;let b=l.getAssignment(e,m);if((b==null?void 0:b.content)!==void 0){u(b.variantId),R(b.content);return}let k=!1;return l.assign(e).then(w=>{if(!k){if(!w){G()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}u(w.variantId),w.content&&R(w.content)}}),()=>{k=!0}},[l,e,m,f]),Ie(()=>{f||!l||!c||!d||s.current!==c&&(s.current=c,l.track({projectId:d,componentId:e,variantId:c,eventType:"variant_assigned",payload:{}}),o==null||o(e,c))},[l,c,d,e,o,f]);let p=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),g=Pr(()=>i===void 0?null:B(i),[p]),a=i===void 0?null:typeof i=="string"?i:g.type,S=ct(!1);Ie(()=>{S.current=!1},[c,p]),Ie(()=>{if(f||!l||!c||!d||!g||!a)return;let b=y.current;if(!b)return;let k=H(g);return X(b,g,{fireGoal:()=>{S.current||(S.current=!0,l.track({projectId:d,componentId:e,variantId:c,eventType:"goal_achieved",goalType:a,payload:v({reward:1},k!==void 0?{goalValue:k}:{})}),l.goal(a,v({metadata:{componentId:e,variantId:c},weight:1,stepIndex:0},k!==void 0?{value:k}:{})))},fireStep:(w,_,E)=>{l.track({projectId:d,componentId:e,variantId:c,eventType:"goal_achieved",goalType:w,payload:{reward:_}}),l.goal(w,{metadata:{},weight:_,stepIndex:E})}})},[l,c,d,e,g,a,f]);let x=h!=null?h:t;if(f){let b=l==null?void 0:l.getAssignment(e,m);x=b&&b.variantId===f&&(O=b.content)!=null?O:t}return Lr(n,{ref:b=>{y.current=b},className:r,children:x})}import{useCallback as Dr,useRef as Ir}from"react";function dt(e){let t=D(),n=Ir(new Set);return Dr((r,i)=>{var l,d;if(!me(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,v(v(v({metadata:(l=i==null?void 0:i.metadata)!=null?l:{},weight:(d=i==null?void 0:i.reward)!=null?d:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}import{useEffect as Nr,useRef as An}from"react";function Vr(e,t={}){let m=t,{componentId:n}=m,r=be(m,["componentId"]),i=D(),l=dt(n!=null?n:""),d=An(!1),o=An(r);o.current=r,Nr(()=>{if(!i||d.current)return;d.current=!0;let{metadata:s,reward:y,value:f,currency:h,externalId:R}=o.current;if(n){l(e,o.current);return}i.goal(e,v(v(v({metadata:s!=null?s:{},weight:y!=null?y:1,stepIndex:0},f!==void 0?{value:f}:{}),h!==void 0?{currency:h}:{}),R!==void 0?{externalId:R}:{}))},[i,n,e,l])}import{renderPrePaintScript as Fr}from"@sentientui/core";import{confidenceBand as Mr}from"@sentientui/policy";import{jsx as jr}from"react/jsx-runtime";function Cn(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function $r(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Cn(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Cn(Mr(e.persona.confidence))+");}catch(e){}})();":Fr(e.apiKey)}function Br(e){return jr("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:$r(e)}})}import{useEffect as Fe,useMemo as gt,useRef as zr}from"react";import{validateSlotDecl as qr}from"@sentientui/policy";import{useEffect as ft,useReducer as Kr,useState as Wr,useSyncExternalStore as _n}from"react";import{armOfResult as Ne,baselineResultFor as Jr}from"@sentientui/core";import{confidenceBand as Ur}from"@sentientui/policy";function Ve(e,t){let n=D(),r=Ae(),[,i]=Kr(f=>f+1,0),l=_n($,()=>{var f;return typeof window!="undefined"?(f=window.__sentient_slot_overrides)==null?void 0:f[e]:void 0},()=>{}),d=l===void 0?r[e]:void 0,o=l===void 0&&d===void 0&&n?n.getSlotResult(e):null,m=(n==null?void 0:n.isLocal)===!0&&l===void 0&&d===void 0&&o===null;ft(()=>{if(!m||!n)return;let f=!1;return n.decide({slots:[t]}).then(h=>{!f&&h&&i()}),()=>{f=!0}},[n,e,m]);let s=(()=>{if(l!==void 0)return{result:l,arm:Ne(l),source:"override"};if(d!==void 0)return{result:d,arm:Ne(d),source:"preloaded"};if(o!==null){let h=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:o,arm:Ne(o),source:h?"client":"seeded"}}let f=Jr(t);return{result:f,arm:Ne(f),source:"baseline"}})(),y=s.source==="preloaded"||s.source==="override";return ft(()=>{var h;if(!n||n.isLocal===!0||y||!n.decideSlots)return;let f=(h=n.onSlotsChanged)==null?void 0:h.call(n,i);return n.decideSlots([t]),()=>{var R;(R=n.cancelSlots)==null||R.call(n,[e]),f==null||f()}},[n,e,y]),s}function Hr(){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 Xr(){let e=D(),t=zt();_n($,Ct,()=>0);let[n,r]=Wr(!1);ft(()=>r(!0),[]);let i=o=>({persona:o.persona,confidence:o.confidence,band:Ur(o.confidence)});if(!n)return t?i(t):null;let l=Hr();if(l)return i(l);if(t)return i(t);let d=e?e.getPersona():null;return d?i(d):null}var On=new Set;function Zr(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Yr(e,t,n){let r=D(),i=z(),l=JSON.stringify(t),d=gt(()=>({id:e,dims:t}),[e,l]),{result:o,arm:m,source:s}=Ve(e,d),y=gt(()=>typeof o=="string"?{}:o,[m]);if(G()&&!On.has(e)){On.add(e);let u=qr({id:e,dims:Object.fromEntries(Object.entries(t).map(([g,a])=>[g,[...a]]))}),p=Object.values(t).reduce((g,a)=>g*a.length,1);u.ok?p>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${p} 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 ${u.reason}. Serving baseline.`)}let f=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);Fe(()=>ue({id:e,dims:t}),[e]);let h=zr(null);Fe(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||h.current===m||(h.current=m,ee(r,i,e,m))},[r,i,e,m,s]);let R=n==null?void 0:n.funnel;Fe(()=>{var u;!r||!R||s==="override"||le(r,i,e,R,B((u=n==null?void 0:n.goal)!=null?u:"click"))},[r,i,e,R,f,s]),Fe(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let u=document.querySelector(`[data-sentient-slot="${Zr(e)}"]`);if(!u){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 p=Q(n.goal),g=H(n.goal),a=!1;return X(u,B(n.goal),{fireGoal:()=>{a||(a=!0,g!==void 0?r.componentGoal(e,p,{value:g}):r.componentGoal(e,p),r.goal(p,v({metadata:{componentId:e,arm:m},weight:1,stepIndex:0},g!==void 0?{value:g}:{})))},fireStep:(S,x,A)=>{r.componentGoal(e,S,{reward:x}),r.goal(S,{metadata:{componentId:e,arm:m},weight:x,stepIndex:A})}},p)},[r,e,f,m,s]);let c=gt(()=>{let u={"data-sentient-slot":e};for(let[p,g]of Object.entries(y))u[`data-${p}`]=g;return u},[e,y]);return{tokens:y,props:c}}import{useCallback as Qr,useEffect as ei,useMemo as ti}from"react";var En=new Set;function ni(e,t){var R;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{client:n,variantIds:r,variantId:i,isOverride:l,goalLabel:d,ref:o,nodeRef:m}=_e(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(R=i!=null?i:r[0])!=null?R:"",y=t.variants[s];ei(()=>{if(!G()||!n)return;let c=setTimeout(()=>{!m.current&&!En.has(e)&&(En.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(c)},[n,e]);let f=Qr((c,u)=>{var g,a;if(l)return;let p=c!=null?c:d;p&&(n==null||n.componentGoal(e,p,u),n==null||n.goal(p,v(v(v({metadata:(g=u==null?void 0:u.metadata)!=null?g:{},weight:(a=u==null?void 0:u.reward)!=null?a:1,stepIndex:0},(u==null?void 0:u.value)!==void 0?{value:u.value}:{}),(u==null?void 0:u.currency)!==void 0?{currency:u.currency}:{}),(u==null?void 0:u.externalId)!==void 0?{externalId:u.externalId}:{})))},[n,e,d,l]),h=ti(()=>({ref:o,"data-sentient-id":e,"data-sentient-variant":s}),[o,e,s]);return{variant:s,value:y,bind:h,fireGoal:f}}import{Children as ri,isValidElement as ii,useEffect as Me,useMemo as Pn,useRef as Gn}from"react";import{jsx as si}from"react/jsx-runtime";var $e=new Set;function oi(e){var g;let t=D(),n=z(),r=Gn(null),i=Object.keys(e.arrangements).join(" "),l=Pn(()=>Object.keys(e.arrangements),[i]),d=Pn(()=>v({id:e.id,arms:l},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,l,e.baseline]),{arm:o,source:m}=Ve(e.id,d);G()&&e.baseline!==void 0&&e.baseline!==l[0]&&!$e.has(e.id+":baseline")&&($e.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${l[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=ri.toArray(e.children).filter(ii),y=new Map;for(let a of s)y.set(String((g=a.key)!=null?g:"").replace(/^\.\$/,""),a);let f=e.arrangements[o],h=f!==void 0&&f.length===s.length&&f.every(a=>y.has(a));G()&&f!==void 0&&!h&&!$e.has(e.id+":keys")&&($e.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 R=h?f.map(a=>y.get(a)):s;Me(()=>ue({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let c=Gn(null);Me(()=>{!t||m==="baseline"||m==="seeded"||m==="override"||c.current===o||(c.current=o,ee(t,n,e.id,o))},[t,n,e.id,o,m]);let u=e.funnel;Me(()=>{var a;!t||!u||m==="override"||le(t,n,e.id,u,B((a=e.goal)!=null?a:"click"))},[t,n,e.id,u,m]);let p=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return Me(()=>{if(!t||e.goal===void 0||m==="override"||m==="baseline"||m==="seeded")return;let a=r.current;if(!a)return;let S=Q(e.goal),x=H(e.goal),A=!1;return X(a,B(e.goal),{fireGoal:()=>{A||(A=!0,x!==void 0?t.componentGoal(e.id,S,{value:x}):t.componentGoal(e.id,S),t.goal(S,v({metadata:{componentId:e.id,arm:o},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(O,b,k)=>{t.componentGoal(e.id,O,{reward:b}),t.goal(O,{metadata:{componentId:e.id,arm:o},weight:b,stepIndex:k})}},S)},[t,e.id,p,o,m]),si("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":o,children:R})}import{deriveSessionSegment as ai}from"@sentientui/core";var li=["page","blocks","layoutOrder"],Tn=new Map;function ui(e,t){Tn.set(e,t)}function Ln(e){return Tn.get(e)}function ci(e){var i,l;let t=(l=(i=e.content)!=null?i:Ln(e.page))!=null?l:{},n={};for(let[d,o]of Object.entries(t))li.includes(d)||(n[d]=o);let r=L(v({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function di(e){return`<script type="application/ld+json">${Dn(e)}</script>`}function Dn(e){return JSON.stringify(v({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function fi(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 Vn=Object.defineProperty,Fn=Object.defineProperties;var Mn=Object.getOwnPropertyDescriptors;var he=Object.getOwnPropertySymbols;var St=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var vt=(e,t,n)=>t in e?Vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))St.call(t,n)&&vt(e,n,t[n]);if(he)for(var n of he(t))ht.call(t,n)&&vt(e,n,t[n]);return e},L=(e,t)=>Fn(e,Mn(t));var be=(e,t)=>{var n={};for(var r in e)St.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&he)for(var r of he(e))t.indexOf(r)<0&&ht.call(e,r)&&(n[r]=e[r]);return n};import{createContext as Un,useContext as F,useEffect as Y,useMemo as Jt,useRef as qe,useState as we,useSyncExternalStore as Hn}from"react";import{deriveSessionSegment as Xn,init as zn}from"@sentientui/core";var bt=new Map,xe=new Map;function xt(e,t){let n=xe.get(e);return n||(n=new Set,xe.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&xe.delete(e)}}function wt(e,t){bt.set(e,t);let n=xe.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function Be(e){var t;return(t=bt.get(e))!=null?t:null}var $n={on:!1,listeners:new Set};function kt(){if(typeof window=="undefined")return $n;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function je(){return kt().on}function Rt(e){let t=kt().listeners;return t.add(e),()=>{t.delete(e)}}function Ct(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),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(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var We="sentient:overrides-changed";function At(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function Ke(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(We))}function $(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(We,e),()=>window.removeEventListener(We,e))}function _t(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 B(e){return typeof e=="string"?{type:"click"}:e}function Q(e){return typeof e=="string"?e:e.type}function H(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var Je=new Set,Ue=!1;function Ot(e){if(Je.has(e))return!0;if(Je.add(e),!Ue){Ue=!0;let t=()=>{Ue=!1,Je.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 Bn(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function Et(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(Bn(r))return!0;r=r.parentElement}return!1}function X(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,v=[];return t.steps.forEach(({goal:f,name:h,weight:R},d)=>{let u=(m=!1)=>{s.has(d)||m&&r!==void 0&&Ot(`step\0${h}\0${R}\0${d}`)||(s.add(d),n.fireStep(h,R,d))};if(f.type==="click"){let m=g=>{let l=g.target;l instanceof Element&&Et(l,e,f.selector)&&u()};e.addEventListener("click",m),v.push(()=>e.removeEventListener("click",m));return}if(f.type==="form_submit"){let m=g=>{g.target instanceof HTMLFormElement&&e.contains(g.target)&&u()};e.addEventListener("submit",m),v.push(()=>e.removeEventListener("submit",m));return}if(f.type==="scroll_depth"){let m=Math.max(0,Math.min(1,f.threshold)),g=new IntersectionObserver(l=>{for(let S of l)if(S.intersectionRatio>=m){u(!0),g.disconnect();break}},{threshold:[m]});g.observe(e),v.push(()=>g.disconnect())}}),()=>{for(let f of v)f()}}let i=t.type==="composite"?t.all:[t],a=new Set(i.map((s,v)=>v)),c=()=>{r!==void 0&&Ot(r)||n.fireGoal()},o=(s,v=!1)=>{a.delete(s),a.size===0&&(v?c():n.fireGoal())},p=[];return i.forEach((s,v)=>{if(s.type==="click"){let f=h=>{let R=h.target;R instanceof Element&&Et(R,e,s.selector)&&(t.type==="composite"?o(v):n.fireGoal())};e.addEventListener("click",f),p.push(()=>e.removeEventListener("click",f));return}if(s.type==="form_submit"){let f=h=>{h.target instanceof HTMLFormElement&&e.contains(h.target)&&(t.type==="composite"?o(v):n.fireGoal())};e.addEventListener("submit",f),p.push(()=>e.removeEventListener("submit",f));return}if(s.type==="scroll_depth"){let f=Math.max(0,Math.min(1,s.threshold)),h=new IntersectionObserver(R=>{for(let d of R)if(d.intersectionRatio>=f){t.type==="composite"?o(v,!0):c(),h.disconnect();break}},{threshold:[f]});h.observe(e),p.push(()=>h.disconnect());return}}),()=>{for(let s of p)s()}}var Pt=new Set,Gt=new Set;function le(e,t,n,r,i){let a=`${r}|${n}`;if(Gt.has(a))return;Gt.add(a);let c=i.type==="weighted_composite"&&!Pt.has(r);c&&Pt.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:c?{funnelId:r,steps:i.steps.map(o=>({goalId:o.name,weight:o.weight}))}:{funnelId:r}})}function ee(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var jn={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function ie(){if(typeof window=="undefined")return jn;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 ve(){ie().version+=1;for(let e of ie().listeners)e()}var Tt=()=>{};function Lt(e){return G()?(ie().components.set(e.id,e),ve(),()=>{ie().components.delete(e.id),ve()}):Tt}function ue(e){return G()?(ie().slots.set(e.id,e),ve(),()=>{ie().slots.delete(e.id),ve()}):Tt}function He(e){G()&&(ie().sections=[...e],ve())}var Dt="0.36.1",Xe=Dt!=="0.0.0-dev"?{name:"react",version:Dt}:void 0;function Wn(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function ce(e,t){Wn()[e]=t}function Nt(e){window.__sentient_vocabulary_override=e}function It(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Kn(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function de(e,t){Kn()[e]=t}var Vt="sentient_editor",Ft="sentient_preview_cell",Mt="sentient_refresh_region",ze="sentient-cell-preview-bar",oe="__preview__",fe=null;function $t(e){if((fe==null?void 0:fe.slotId)!==e)return null;let t=fe;return fe=null,t}function Bt(e,t){fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(y({slotId:e.slotId},t))}).then(n=>ge(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>ge("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function jt(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(ze))return;let t,n,r;try{let p=new URLSearchParams(window.location.search);t=p.get(Vt),n=p.get(Ft),r=p.get(Mt)}catch(p){return}if(t&&r){fe={slotId:r,token:t,base:(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"")},ce(r,{kind:"arms"}),de(r,oe),Ke();return}if(!t||!n)return;let i=n.lastIndexOf("~");if(i<=0)return;let a=n.slice(0,i),c=n.slice(i+1),o=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${o}/editor/cell-preview?slotId=${encodeURIComponent(a)}&persona=${encodeURIComponent(c)}`,{headers:{authorization:`Bearer ${t}`}}).then(async p=>{if(!p.ok){ge(p.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await p.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&Nt(s.vocabulary),s.compose!=null)ce(a,{kind:"arms",compose:{[oe]:s.compose}}),de(a,oe);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))ce(a,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),de(a,oe);else if(s.blocks!=null)ce(a,{kind:"arms",blocks:{[oe]:s.blocks}}),de(a,oe);else if(s.content!=null)ce(a,{kind:"arms",content:s.content}),de(a,oe);else{ge("Nothing to preview in that square yet.");return}Ke(),ge(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var v;try{(v=document.querySelector(`[data-sentient-slot="${a}"]`))==null||v.scrollIntoView({block:"center"})}catch(f){}},300)}).catch(()=>ge("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function ge(e){var i;if(document.getElementById(ze))return;let t=document.createElement("div");t.id=ze,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{let a=new URL(window.location.href);a.searchParams.delete(Vt),a.searchParams.delete(Ft),a.searchParams.delete(Mt),window.location.assign(a.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var Jn="sentient_editor",Wt=!1;function Kt(e){if(Wt||typeof window=="undefined")return;let t=null;try{t=new URLSearchParams(window.location.search).get(Jn)}catch(i){return}if(!t)return;Wt=!0;let n=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),r=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:i})=>fetch(`${n}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(i(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?r():window.addEventListener("load",r,{once:!0})}import{jsx as tr}from"react/jsx-runtime";function qn(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return Xn({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Ut="https://api.sentient-ui.com/v1",V=Un({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Ut,debug:!1});function Zn(e){let[t,n]=we(null),r=qe(e);r.current=e;let i=e===void 0?"":typeof e=="string"?e:JSON.stringify(L(y({},e),{check:typeof e.check}));return Y(()=>{let a=r.current;if(a===void 0||typeof window=="undefined")return;let c,o=!1;return import("@sentientui/core/consent").then(({consentWatcher:p})=>{if(o)return;let s=p(typeof a=="object"&&a.cmp===void 0&&a.check?L(y({},a),{check:()=>r.current.check()}):a);n(s.read()),c=s.subscribe(()=>n(s.read()))}),()=>{o=!0,c==null||c()}},[i]),t}function Yn(e){var d,u;let[t,n]=we(null),[r]=we(()=>{var m;return(m=e.sessionSegment)!=null?m:qn()}),[i,a]=we(je());Y(()=>Rt(()=>a(je())),[]),Y(()=>{jt(e.apiBaseUrl),Kt(e.apiBaseUrl)},[]);let c=Zn(e.consentFrom),o=e.consentFrom?c!=null?c:e.consent===!0:e.consent,p=qe(null);Y(()=>{var C;if(o===!1&&!e.preConsentBehavior){(C=p.current)==null||C.destroy(),p.current=null,n(null);return}let m=y({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,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,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},Xe?{sdk:Xe}:{}),g=!1,l=null,S=null,x=O=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:b})=>{g||(S=b(O,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:O})=>{g||(l=O(L(y({},m),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),p.current=l,n(l),x(l))}):(l=zn(m),p.current=l,n(l),x(l)),()=>{g=!0,S==null||S(),l==null||l.dispose()}},[o]),Y(()=>{if(!t)return;let m=!1,g=async()=>{if(m)return;let S;try{S=await t.fetchWeights()}catch(x){return}if(!m)for(let x of S){let C={componentId:x.componentId,updatedAt:x.updatedAt,variants:x.variants.map(O=>{var b;return{variantId:O.variantId,pulls:O.pulls,avgReward:(b=O.avgReward)!=null?b:0}})};wt(x.componentId,C)}};g();let l=setInterval(()=>{g()},6e4);return()=>{m=!0,clearInterval(l)}},[t]);let s=(d=e.ssrFallback)!=null?d:"first",v=((u=e.apiBaseUrl)!=null?u:Ut).replace(/\/$/,""),f=qe(null);Y(()=>{var l;if(typeof process!="undefined"&&((l=process.env)==null?void 0:l.NODE_ENV)==="production")return;let m={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:v},g=f.current;if(f.current=m,g!==null)for(let S of["apiKey","context","country","persona","apiBaseUrl"])Object.is(g[S],m[S])||console.warn(`[sentient] AdaptiveProvider: \`${S}\` 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,v]),Y(()=>{var m;typeof process!="undefined"&&((m=process.env)==null?void 0:m.NODE_ENV)==="production"||_t({apiKey:e.apiKey,apiBaseUrl:v,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,v]),Y(()=>{let m=e.initialLayoutOrder;if(m&&m.length>0){He(m);return}e.declaredSections&&e.declaredSections.length>0&&He(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),Y(()=>{if(!G())return;let m=e.declaredSections;if(!m||m.length===0||typeof document=="undefined")return;let g=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),S=>S.getAttribute("data-sentient-id"))),l=m.filter(S=>!g.has(S));l.length>0&&console.warn(`[SentientUI] Declared section${l.length>1?"s":""} ${l.map(S=>`"${S}"`).join(", ")} ${l.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>" to each section's element.`)},[e.declaredSections]);let h=Jt(()=>t&&i?Ct(t):t,[t,i]),R=Jt(()=>{var m,g,l,S,x,C,O,b;return{client:h,apiKey:e.apiKey,initialAssignments:(m=e.initialAssignments)!=null?m:{},sessionSegment:r,ssrFallback:s,onAssignment:e.onAssignment,initialLayoutOrder:(g=e.initialLayoutOrder)!=null?g:null,initialSlots:(l=e.initialSlots)!=null?l:{},initialSlotConfig:(S=e.initialSlotConfig)!=null?S:{},initialPalette:(x=e.initialPalette)!=null?x:null,initialVocabulary:(C=e.initialVocabulary)!=null?C:null,initialPersona:(O=e.initialPersona)!=null?O:null,apiBaseUrl:v,debug:(b=e.debug)!=null?b:!1}},[h,e.apiKey,e.initialAssignments,r,s,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,v,e.debug]);return tr(V.Provider,{value:R,children:e.children})}function D(){return F(V).client}function z(){return F(V).apiKey}function Ze(){return F(V).initialAssignments}function ke(){return F(V).sessionSegment}function Ht(){return F(V).ssrFallback}function Re(){return F(V).onAssignment}function Xt(){return F(V).debug}function Qn(){let e=F(V).initialLayoutOrder,t=Hn($,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ce(){return F(V).initialSlots}function zt(){return F(V).initialPersona}function qt(){return F(V).initialSlotConfig}function Zt(){return F(V).initialPalette}function Yt(){return F(V).initialVocabulary}function er(){return F(V).apiBaseUrl}import{memo as kr,useEffect as Rr,useState as Cr}from"react";import{useCallback as ir,useEffect as se,useMemo as en,useRef as Se,useState as or}from"react";import{attachMicroSignalDetectors as sr}from"@sentientui/core";import{useEffect as Ae,useRef as Qt,useState as nr,useSyncExternalStore as rr}from"react";import{pickFromWeights as Ye}from"@sentientui/policy";function me(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 i of r.getAll("sentient_variant")){let a=i.indexOf(":");if(a!==-1&&i.slice(0,a)===e)return i.slice(a+1)}}catch(r){}return null}function Qe(e,t,n,r){let i=Ze(),a=Ht(),c=D(),o=ke(),p=Re(),s=Xt(),v=Qt(null),f=rr($,()=>me(e),()=>null),h=f&&t.includes(f)?f:null,R=Qt(null);Ae(()=>{s&&h&&R.current!==h&&(R.current=h,console.info(`[sentient] override active: ${e} -> ${h}`))},[s,h,e]);let[d,u]=nr(()=>{var S,x;if(h)return{variantId:h,content:null,isLoading:!1,settled:!0};if(!c){let C=i[e];return C&&t.includes(C)?{variantId:C,content:null,isLoading:!1,settled:!0}:a==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let g=c.getAssignment(e,o);if(g&&(t.includes(g.variantId)||g.content))return{variantId:g.variantId,content:(S=g.content)!=null?S:null,isLoading:!1,settled:!0};let l=Be(e);if(l){let C=Ye(l.variants,t);if(C)return{variantId:C,content:null,isLoading:!1,settled:!0}}return{variantId:(x=t[0])!=null?x:null,content:null,isLoading:!1,settled:!1}}),m=g=>{p&&v.current!==g&&(v.current=g,p(e,g))};return Ae(()=>{var S;if(h||!c)return;let g=c.getAssignment(e,o);if(g&&(t.includes(g.variantId)||g.content)){u({variantId:g.variantId,content:(S=g.content)!=null?S:null,isLoading:!1,settled:!0}),m(g.variantId);return}let l=Be(e);if(l&&d.settled&&d.variantId&&d.variantId===Ye(l.variants,t)){m(d.variantId);return}u(x=>{var C;return x.variantId?x:{variantId:(C=t[0])!=null?C:null,content:null,isLoading:!1,settled:!1}})},[h,c,e,o]),Ae(()=>{if(h||!c)return;let g=c.getAssignment(e,o);if(g&&t.includes(g.variantId))return;let l=!1;return c.assign(e,t,n,r).then(S=>{var x;l||S&&(!t.includes(S.variantId)&&!S.content||(u({variantId:S.variantId,content:(x=S.content)!=null?x:null,isLoading:!1,settled:!0}),m(S.variantId)))}),()=>{l=!0}},[h,c,e,o]),Ae(()=>{if(!h&&c)return xt(e,g=>{var x;let l=c.getAssignment(e,o);if(l&&(t.includes(l.variantId)||l.content)){u({variantId:l.variantId,content:(x=l.content)!=null?x:null,isLoading:!1,settled:!0}),m(l.variantId);return}let S=Ye(g.variants,t);S&&(u({variantId:S,content:null,isLoading:!1,settled:!0}),m(S))})},[h,c,e,o]),h?{variantId:h,content:null,isLoading:!1,settled:!0,isOverride:!0}:d}function _e(e,t,n){let r=D(),i=z(),a=Object.keys(t).join("\0"),c=en(()=>Object.keys(t),[a]),{variantId:o,content:p,isOverride:s=!1,settled:v}=Qe(e,c,n.agentData,n.agentDataByVariant),[f,h]=or(null),R=Se(null),d=ir(_=>{R.current=_,h(_)},[]),u=n.goal,m=typeof u=="string"?u:JSON.stringify(u),g=en(()=>u?B(u):null,[m]),l=u?Q(u):"";se(()=>Lt({id:e,variantIds:c,goal:l}),[e,c,l]);let S=Se(null);se(()=>{s||v&&(!r||!o||!i||!f||S.current!==o&&(S.current=o,ee(r,i,e,o)))},[r,o,i,e,f,s,v]);let x=Se(!1),C=Se(new Set);se(()=>{x.current=!1,C.current=new Set},[o,g]);let O=n.funnel;se(()=>{s||!v||!r||!O||!g||le(r,i,e,O,g)},[r,i,e,O,g,s,v]);let b=n.cursorSignal===!0;se(()=>{if(!b||s||!v||!r||!o||!f)return;let _=null,E=0,I=()=>{E=Date.now(),_=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:o,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-E}}),_=null},800)},T=()=>{_!==null&&(clearTimeout(_),_=null)};return f.addEventListener("mouseenter",I),f.addEventListener("mouseleave",T),()=>{f.removeEventListener("mouseenter",I),f.removeEventListener("mouseleave",T),_!==null&&clearTimeout(_)}},[b,r,o,i,e,f,s,v]);let k=Se(n.microSignalGoals);k.current=n.microSignalGoals;let w=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return se(()=>{if(s||!v||!r||!o||!f)return;let _=Date.now();return sr((E,I={})=>{var Z,ne,J;r.track({projectId:i,componentId:e,variantId:o,eventType:"micro_signal",payload:y({signalType:E},I)});let T=(Z=k.current)==null?void 0:Z[E];if(!T||C.current.has(E))return;C.current.add(E);let W=typeof T=="string"?T:T.name,K=typeof T=="string"?1:(ne=T.weight)!=null?ne:1,q=typeof T=="string"?0:(J=T.stepIndex)!=null?J:0;r.goal(W,{metadata:y({signalType:E},I),weight:K,stepIndex:q})},f,_)},[r,o,i,e,f,w,s,v]),se(()=>{if(s||!v||!r||!o||!f||!g)return;let _=H(g);return X(f,g,{fireGoal:()=>{x.current||(x.current=!0,r.track({projectId:i,componentId:e,variantId:o,eventType:"goal_achieved",goalType:l,payload:y({reward:1},_!==void 0?{goalValue:_}:{})}),r.goal(l,y({metadata:{componentId:e,variantId:o},weight:1,stepIndex:0},_!==void 0?{value:_}:{})))},fireStep:(E,I,T)=>{r.track({projectId:i,componentId:e,variantId:o,eventType:"goal_achieved",goalType:E,payload:{reward:I}}),r.goal(E,{metadata:{},weight:I,stepIndex:T})}},l)},[r,o,i,e,f,g,l,s,v]),{client:r,variantIds:c,variantId:o,content:p,settled:v,isOverride:s,goalLabel:l,ref:d,nodeRef:R}}import{useEffect as j,useMemo as lt,useRef as ut}from"react";import{containsFormBlock as vn,reveal as xr}from"@sentientui/core";import{captureRegionSkeleton as Sn}from"@sentientui/core/region";import{useCallback as ar,useEffect as tn,useRef as et,useSyncExternalStore as Oe}from"react";import{armOfResult as lr}from"@sentientui/core";var nn=new Set;function rn(e,t){var x,C,O;let n=D(),r=et(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=et(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let a=et(t==null?void 0:t.skeleton);a.current=t==null?void 0:t.skeleton;let c=Ce(),o=qt(),p=Zt(),s=Yt(),v=Oe($,()=>{var b;return typeof window!="undefined"?(b=window.__sentient_slot_config_overrides)==null?void 0:b[e]:void 0},()=>{}),f=Oe($,()=>{var b;return typeof window!="undefined"?(b=window.__sentient_slot_overrides)==null?void 0:b[e]:void 0},()=>{}),h=b=>b==null?"":lr(b),R=ar(b=>{var k,w;return(w=(k=n==null?void 0:n.onSlotsChanged)==null?void 0:k.call(n,b))!=null?w:(()=>{})},[n]);Oe(R,()=>{var b;return(b=n==null?void 0:n.getSlotConfig(e))!=null?b:null},()=>null),Oe(R,()=>h(n==null?void 0:n.getSlotResult(e)),()=>"");let d=v===void 0?o[e]:void 0,u=v===void 0&&d===void 0&&n?n.getSlotConfig(e):null,m=(x=p!=null?p:n==null?void 0:n.getSitePalette())!=null?x:null,g=(O=s!=null?s:(C=n==null?void 0:n.getStyleVocabulary)==null?void 0:C.call(n))!=null?O:null,l=(()=>{var b,k,w;if(v!==void 0)return{config:v,arm:h(f),palette:m,vocabulary:(b=It())!=null?b:g,source:"override"};if(d!==void 0)return{config:d,arm:h((k=c[e])!=null?k:n==null?void 0:n.getSlotResult(e)),palette:m,vocabulary:g,source:"preloaded"};if(u!==null){let _=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:u,arm:h((w=n==null?void 0:n.getSlotResult(e))!=null?w:c[e]),palette:m,vocabulary:g,source:_?"client":"seeded"}}return{config:null,arm:"",palette:m,vocabulary:g,source:"none"}})(),S=l.source==="preloaded"||l.source==="override";return tn(()=>{var W,K,q,Z,ne;if(!n||n.isLocal===!0||S)return;let b=l.source==="none",k=b&&(K=(W=r.current)==null?void 0:W.call(r))!=null?K:null,w=k!=null&&k!==""?{[e]:k}:void 0,_=(q=i.current)==null?void 0:q.call(i),E=b&&(ne=(Z=a.current)==null?void 0:Z.call(a))!=null?ne:null,I=y(y({},_?{render:{[e]:_}}:{}),E?{skeletons:{[e]:E}}:{}),T=Object.keys(I).length>0;return n.requestSlots?T?n.requestSlots([e],w,I):w?n.requestSlots([e],w):n.requestSlots([e]):b&&(E?n.reportSlots([e],w!=null?w:{},{[e]:E}):w?n.reportSlots([e],w):n.reportSlots([e])),()=>{var J;return(J=n.cancelSlots)==null?void 0:J.call(n,[e])}},[n,S,l.source,e]),tn(()=>{!G()||(n==null?void 0:n.isLocal)!==!0||l.source!=="none"||nn.has(e)||(nn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,l.source,e]),l}import{cloneElement as ur,Fragment as on}from"react";import{jsx as N,jsxs as un}from"react/jsx-runtime";var te={none:"0",sm:"8px",md:"16px",lg:"24px"},tt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},cn={sm:"0.875em",md:"1em",lg:"1.25em"},cr={sm:"1.25em",md:"1.5em",lg:"2em"},sn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},an={sm:"8px",md:"16px",lg:"32px"},dr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},fr={normal:"400",medium:"500",bold:"700"};function ln(e,t){return y(y({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?y({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function dn(e,t,n){var i,a,c,o;let r=t==null?void 0:t.accent;return L(y({display:"inline-block",padding:(i=sn[n!=null?n:"md"])!=null?i:sn.md,borderRadius:(a=t==null?void 0:t.radius)!=null?a:"8px",font:"inherit"},n?{fontSize:cn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(c=t==null?void 0:t.primaryBg)!=null?c:"#111827":"transparent",color:e==="primary"?(o=t==null?void 0:t.primaryText)!=null?o:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function gr({node:e,opts:t}){var i,a,c,o,p;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(c=(a=t.palette)==null?void 0:a.border)!=null?c:"currentColor"}`,borderRadius:(p=(o=t.palette)==null?void 0:o.radius)!=null?p:"8px"};return un("form",{onSubmit:s=>{var h,R,d;s.preventDefault();let v=new FormData(s.currentTarget),f={};for(let u of e.fields)f[u.name]=String((h=v.get(u.name))!=null?h:"");(R=t.onFormGoal)==null||R.call(t,e.submitGoal);try{(d=t.onFormSubmit)==null||d.call(t,f)}catch(u){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var v,f;return un("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?N("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?N("select",{name:s.name,required:s.required,style:r,children:((v=s.options)!=null?v:[]).map(h=>N("option",{value:h,children:h},h))}):N("input",{name:s.name,type:(f=s.inputType)!=null?f:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),N("button",{type:"submit",style:dn(n,t.palette),children:e.submitLabel})]})}function mr(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(a=>a.id===n))==null?void 0:i.classes:void 0}function fn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function pe(e,t){var i;let n=pr(e,t),r=fn(e.like,t);return n&&r?ur(n,{style:L(y({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function pr(e,t){var n,r,i,a,c,o,p,s,v,f,h,R,d,u,m,g,l,S,x,C,O,b,k;try{let w=mr(e,t);switch(e.type){case"stack":{let _=(r=te[(n=e.gap)!=null?n:"md"])!=null?r:te.md,E=e.surface==="raised"&&!w,I=(i=e.pad)!=null?i:E?"md":void 0;return N("div",L(y({},w?{className:w}:{}),{style:y(y(y(y(y({display:"flex",flexDirection:e.direction,gap:_},e.align?{alignItems:tt[e.align]}:{}),e.justify?{justifyContent:tt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),I?{padding:(a=te[I])!=null?a:te.md}:{}),E?L(y(y({},(c=t.palette)!=null&&c.surface?{background:t.palette.surface}:{}),(o=t.palette)!=null&&o.surface&&((p=t.palette)!=null&&p.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(v=(s=t.palette)==null?void 0:s.border)!=null?v:"currentColor"}`,borderRadius:(h=(f=t.palette)==null?void 0:f.radius)!=null?h:"8px"}):{}),children:((R=e.children)!=null?R:[]).map((T,W)=>{let K=pe(T,t);return K===null?null:N(on,{children:K},W)})}))}case"grid":{let _=(u=te[(d=e.gap)!=null?d:"md"])!=null?u:te.md;return N("div",L(y({},w?{className:w}:{}),{style:y(y({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${_}) / ${e.columns})), 1fr))`,gap:_},e.align?{alignItems:tt[e.align]}:{}),e.pad?{padding:(m=te[e.pad])!=null?m:te.md}:{}),children:((g=e.children)!=null?g:[]).map((E,I)=>{let T=pe(E,t);return T===null?null:N(on,{children:T},I)})}))}case"text":return w?N("p",{className:w,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):N("p",{style:y(y(y(y(y({margin:0},e.size?{fontSize:cn[e.size]}:{}),e.weight?{fontWeight:fr[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),ln(e.tone,t.palette)),children:e.value});case"heading":{let _=`h${e.level}`;return w?N(_,{className:w,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):N(_,{style:y(y({margin:0,fontSize:cr[(l=e.size)!=null?l:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let _=(S=e.emphasis)!=null?S:"primary";return N("a",L(y(y({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),w?{className:w}:{style:dn(_,t.palette,e.size)}),{children:e.label}))}case"link":return N("a",L(y(y({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),w?{className:w}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return N("img",L(y({src:e.src,alt:e.alt},w?{className:w}:{}),{style:y(y({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:dr[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return w?N("span",{className:w,children:e.value}):N("span",{style:y({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(C=(x=t.palette)==null?void 0:x.border)!=null?C:"currentColor"}`},ln(e.tone,t.palette)),children:e.value});case"spacer":return N("div",{style:{height:(O=an[e.size])!=null?O:an.md}});case"divider":return N("hr",{style:{border:"none",borderTop:`1px solid ${(k=(b=t.palette)==null?void 0:b.border)!=null?k:"currentColor"}`,margin:0,width:"100%"}});case"form":return N(gr,{node:e,opts:t});default:return null}}catch(w){return null}}function nt(e,t){var a,c,o,p;let n=pe(e.tree,t);if(n===null)return null;let r=(a=e.surface)!=null&&a.like?(o=(c=t.vocabulary)==null?void 0:c.entries.find(s=>s.id===e.surface.like))==null?void 0:o.classes:void 0,i=fn((p=e.surface)==null?void 0:p.like,t);return r?N("div",L(y({className:r},i?{style:{color:i}}:{}),{children:n})):n}import{cloneElement as Ee,isValidElement as Pe}from"react";import{normalizeLeafText as yr,skeletonFingerprint as vr}from"@sentientui/core/region";function Ge(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function Te(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ae(e){return Ge(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ae(n),0):Pe(e)?ae(Te(e)):0}function Sr(e,t){return Array.isArray(t)?Ee(e,void 0,...t):Ee(e,void 0,t)}function rt(e,t){if(Ge(e))return t;if(Array.isArray(e))return e.map(n=>rt(n,t));if(Pe(e)){let n=Te(e);return ae(n)===0?e:Sr(e,rt(n,t))}return e}function gn(e,t){return ae(e)===1?rt(e,t):null}var M=e=>e.join("/");function it(e,t,n){if(Ge(e)){n.leafPaths.push(t),n.texts.push(yr(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>it(r,[...t,i],n));return}Pe(e)&&(n.elements.set(M(t),e),it(Te(e),[...t,"c"],n))}function st(e){let t={leafPaths:[],texts:[],elements:new Map};return it(e,[],t),t}function hr(e){return st(e).texts}function mn(e){let t=hr(e);return t.length===0?null:vr(t)}function br(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function pn(e,t){let n=t.reduce((i,a)=>Math.max(i,a+1),0),r=[];for(let i=0;i<n;i++){let a=t.flatMap((o,p)=>o===i?[br(e.leafPaths[p])]:[]);if(a.length===0){r.push(null);continue}let c=a[0];for(let o of a.slice(1)){let p=new Set(o.map(M));c=c.filter(s=>p.has(M(s)))}r.push(c.length>0?c[c.length-1]:null)}return r}function ot(e){var n;let t=(n=e==null?void 0:e.props)==null?void 0:n.className;return typeof t=="string"?t:void 0}function at(e,t){let n=st(t);if(n.texts.length!==e.leaves.length||n.texts.some((a,c)=>a!==e.leaves[c]))return null;let r=pn(n,e.leafToNode),i=e.nodes.map((a,c)=>{let o=r[c],p=o?n.elements.get(M(o)):void 0,s=!!p&&(typeof p.type=="string"||ot(p)!==void 0);return L(y({},a),{restylable:s})});return L(y({},e),{nodes:i})}function yn(e,t,n){var d;let r=st(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((u,m)=>Math.max(u,m+1),0);for(let u of Object.keys(t.nodes))if(!/^\d+$/.test(u)||Number(u)>=i)return null;let a=pn(r,n),c=new Map;n.forEach((u,m)=>{c.has(u)||c.set(u,m)});let o=new Map(r.leafPaths.map((u,m)=>[M(u),m])),p=new Set,s=new Map,v=!1;for(let[u,m]of Object.entries(t.nodes)){let g=Number(u),l=a[g];if(m.hidden&&(l?p.add(M(l)):v=!0),m.like!==void 0){let S=a[m.like],x=l?r.elements.get(M(l)):void 0,C=S?ot(r.elements.get(M(S))):void 0;!l||C===void 0||ot(x)===void 0?v=!0:s.set(M(l),C)}}let f=new Map(Object.entries((d=t.order)!=null?d:{})),h=(u,m)=>{var g;if(Ge(u)){let l=o.get(M(m));if(l===void 0)return u;let S=n[l],x=(g=t.nodes[String(S)])==null?void 0:g.text;return x===void 0?u:c.get(S)===l?x:""}if(Array.isArray(u)){let l=u.map((S,x)=>h(S,[...m,x]));for(let[S,x]of f){let C=x.map(k=>{let w=a[k];return!w||w.length!==m.length+1||M(w.slice(0,-1))!==M(m)?-1:w[w.length-1]});if(C.some(k=>k<0))continue;let O=[...C].sort((k,w)=>k-w),b=[...l];O.forEach((k,w)=>{l[k]=b[C[w]]}),f.delete(S)}return l}if(Pe(u)){let l=M(m);if(p.has(l))return null;let S=Te(u);if(ae(S)===0)return u;let x=h(S,[...m,"c"]),C=s.get(l),O=C!==void 0?{className:C}:void 0;return Array.isArray(x)?Ee(u,O,...x):Ee(u,O,x)}return u},R=h(e,[]);return v||f.size>0?null:R}import{jsx as wr}from"react/jsx-runtime";var hn=new Set,bn=new Set,xn=new Set,wn="authored.";function Le({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:a,reportBaselineText:c=!0}){var mt,pt;let o=D(),p=z(),s=ut(null),v=lt(()=>mn(t),[t]),f=n?Object.keys(n).join("|"):"",h=lt(()=>y({fp:v!=null?v:"0000000000000000",forms:!!r,compose:!0,content:ae(t)===1},f!==""?{authored:f.split("|"),children:!0}:{}),[v,t,r,f]),R=()=>{var U;let A=s.current;if(!A||!c)return null;let P=Sn(A);return P.skeleton?(U=at(P.skeleton,t))!=null?U:L(y({},P.skeleton),{editable:!1,nodes:P.skeleton.nodes.map(re=>L(y({},re),{restylable:!1}))}):{status:P.reason}},{config:d,arm:u,palette:m,vocabulary:g,source:l}=rn(e,{baselineText:c?()=>{var A,P;return(P=(A=s.current)==null?void 0:A.textContent)!=null?P:null}:void 0,render:()=>h,skeleton:R}),S=u!==""?(mt=d==null?void 0:d.blocks)==null?void 0:mt[u]:void 0,x=u!==""?(pt=d==null?void 0:d.compose)==null?void 0:pt[u]:void 0,C=(S!==void 0&&vn(S)||x!==void 0&&vn(x.tree))&&!r;j(()=>{!C||!G()||hn.has(e)||(hn.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.`))},[C,e]);let O=A=>{!o||l==="override"||(l!=="seeded"&&o.componentGoal(e,A),o.goal(A,{metadata:{componentId:e,arm:u},weight:1,stepIndex:0}))},b=t,k=!1,w=u.startsWith(wn)?u.slice(wn.length):null;if((d==null?void 0:d.blocked)==="variant_history")k=!0;else if(w!==null)n&&Object.prototype.hasOwnProperty.call(n,w)?b=n[w]:k=!0;else if(x!==void 0){let A=C?null:nt(x,{palette:m,vocabulary:g,onFormSubmit:r,onFormGoal:O});A===null?k=!0:b=A}else if(S!==void 0){let A=C?null:pe(S,{palette:m,vocabulary:g,onFormSubmit:r,onFormGoal:O});A===null?k=!0:b=A}else if((d==null?void 0:d.edits)!==void 0&&l!=="none"){let A=d.edits,P=A.fp===v?yn(t,A.edits,A.leafToNode):null;P===null?k=!0:b=P}else if((d==null?void 0:d.content)!==void 0&&l!=="none"){let A=gn(t,d.content);A===null?k=!0:b=A}let _=k&&S===void 0&&x===void 0&&(d==null?void 0:d.edits)===void 0&&w===null&&(d==null?void 0:d.blocked)===void 0;j(()=>{(d==null?void 0:d.blocked)!=="variant_history"||!G()||xn.has(e)||(xn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[d==null?void 0:d.blocked,e]);let E=w!==null&&!k?w:null;j(()=>{var ye;if(!E||!c||!o)return;let A=s.current;if(!A)return;let P=Sn(A),U=P.skeleton?at(P.skeleton,n==null?void 0:n[E]):null,re=(ye=A.textContent)==null?void 0:ye.trim();o.reportSlots([],void 0,void 0,{[e]:[y(y({key:E},re?{text:re}:{}),U?{skeleton:U}:{})]})},[E,o,e]);let I=k&&(d==null?void 0:d.edits)!==void 0&&(l==="preloaded"||l==="client");j(()=>{var A;!I||!(d!=null&&d.edits)||(A=o==null?void 0:o.reportDrift)==null||A.call(o,e,d.edits.fp,v,d.edits.fp===v?"unaddressable":"fp_mismatch")},[I,e,v,o]);let T=b===t;j(()=>{var P;if(!(d!=null&&d.needsSkeleton)||!T)return;let A=R();A&&((P=o==null?void 0:o.reportSkeleton)==null||P.call(o,e,A))},[d==null?void 0:d.needsSkeleton,T,e,o]),j(()=>{if(!T)return;let A=$t(e);if(!A)return;let P=R();Bt(A,P&&"status"in P?{status:P.status}:{skeleton:P})},[e,T]),j(()=>{!_||!G()||bn.has(e)||(bn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[_,e]);let W=d!=null&&d.blocks?Object.keys(d.blocks).sort().join("|"):"";j(()=>ue({id:e,arms:W===""?void 0:W.split("|")}),[e,W]);let K=ut(null);j(()=>{!o||l==="none"||l==="seeded"||l==="override"||u===""||k||K.current!==u&&(K.current=u,ee(o,p,e,u))},[o,p,e,u,l,k]);let q=l!=="none"&&l!=="seeded"&&!k,Z=q?u:"",ne=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);j(()=>{if(!o||!i||l==="override")return;let A=s.current;if(!A)return;let P=Q(i),U=H(i),re=!1;return X(A,B(i),{fireGoal:()=>{re||(re=!0,q&&(U!==void 0?o.componentGoal(e,P,{value:U}):o.componentGoal(e,P)),o.goal(P,y({metadata:{componentId:e,arm:Z},weight:1,stepIndex:0},U!==void 0?{value:U}:{})))},fireStep:(ye,yt,In)=>{q&&o.componentGoal(e,ye,{reward:yt}),o.goal(ye,{metadata:{componentId:e,arm:Z},weight:yt,stepIndex:In})}},P)},[o,e,ne,u,l,k,q,Z]);let J=ut(null);j(()=>{let A=s.current;if(A){if(J.current===null){J.current=u;return}J.current!==u&&(J.current=u,xr(A))}},[u]);let Nn=lt(()=>y({"data-sentient-slot":e},u!==""?{"data-sentient-arm":u}:{}),[e,u]);return wr("div",L(y({ref:s,className:a},Nn),{children:b}))}import{jsx as De}from"react/jsx-runtime";function Ar(e){var s;let{client:t,variantId:n,content:r,ref:i}=_e(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[a,c]=Cr(!1);if(Rr(()=>{c(!0)},[]),e.clientOnly&&(!a||!t)||!n)return null;let o=(s=e.variants[n])!=null?s:null,p=o===null?r:null;return G()&&o===null&&p===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),De("div",{ref:i,"data-sentient-id":e.id,"data-sentient-variant":n,children:o!=null?o:p})}var _r=kr(Ar,(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(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function Or(e){if(e.variants===void 0)return De(Le,y({},e));let t=e;if(t.children!=null){G()&&Er(t);let n=t,{funnel:r,microSignalGoals:i,agentData:a,agentDataByVariant:c,clientOnly:o,variants:p}=n,s=be(n,["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly","variants"]);return De(Le,L(y({},s),{children:t.children,variants:p}))}return De(_r,y({},t))}var kn=new Set;function Er(e){let t=["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly"].filter(n=>e[n]!==void 0);t.length===0||kn.has(e.id)||(kn.add(e.id),console.warn(`[sentient] <Adaptive id="${e.id}"> has both variants and children, so it runs as one experiment with your original and generated versions. These props only apply to a variants-only component and are ignored here: ${t.join(", ")}.`))}import{useEffect as Ne,useMemo as Pr,useRef as ct,useState as Rn,useSyncExternalStore as Gr}from"react";import{jsx as Lr}from"react/jsx-runtime";function Tr({id:e,default:t,component:n="span",className:r,goal:i}){var O;let a=D(),c=z(),o=Re(),p=ke(),s=ct(null),v=ct(null),f=Gr($,()=>me(e),()=>null),[h,R]=Rn(()=>{var b,k;return(k=(b=a==null?void 0:a.getAssignment(e,p))==null?void 0:b.content)!=null?k:null}),[d,u]=Rn(()=>{var b,k;return(k=(b=a==null?void 0:a.getAssignment(e,p))==null?void 0:b.variantId)!=null?k:null});Ne(()=>{if(f||!a)return;let b=a.getAssignment(e,p);if((b==null?void 0:b.content)!==void 0){u(b.variantId),R(b.content);return}let k=!1;return a.assign(e).then(w=>{if(!k){if(!w){G()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}u(w.variantId),w.content&&R(w.content)}}),()=>{k=!0}},[a,e,p,f]),Ne(()=>{f||!a||!d||!c||s.current!==d&&(s.current=d,a.track({projectId:c,componentId:e,variantId:d,eventType:"variant_assigned",payload:{}}),o==null||o(e,d))},[a,d,c,e,o,f]);let m=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),g=Pr(()=>i===void 0?null:B(i),[m]),l=i===void 0?null:typeof i=="string"?i:g.type,S=ct(!1);Ne(()=>{S.current=!1},[d,m]),Ne(()=>{if(f||!a||!d||!c||!g||!l)return;let b=v.current;if(!b)return;let k=H(g);return X(b,g,{fireGoal:()=>{S.current||(S.current=!0,a.track({projectId:c,componentId:e,variantId:d,eventType:"goal_achieved",goalType:l,payload:y({reward:1},k!==void 0?{goalValue:k}:{})}),a.goal(l,y({metadata:{componentId:e,variantId:d},weight:1,stepIndex:0},k!==void 0?{value:k}:{})))},fireStep:(w,_,E)=>{a.track({projectId:c,componentId:e,variantId:d,eventType:"goal_achieved",goalType:w,payload:{reward:_}}),a.goal(w,{metadata:{},weight:_,stepIndex:E})}})},[a,d,c,e,g,l,f]);let x=h!=null?h:t;if(f){let b=a==null?void 0:a.getAssignment(e,p);x=b&&b.variantId===f&&(O=b.content)!=null?O:t}return Lr(n,{ref:b=>{v.current=b},className:r,children:x})}import{useCallback as Dr,useRef as Nr}from"react";function dt(e){let t=D(),n=Nr(new Set);return Dr((r,i)=>{var a,c;if(!me(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,y(y(y({metadata:(a=i==null?void 0:i.metadata)!=null?a:{},weight:(c=i==null?void 0:i.reward)!=null?c:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}import{useEffect as Ir,useRef as Cn}from"react";function Vr(e,t={}){let p=t,{componentId:n}=p,r=be(p,["componentId"]),i=D(),a=dt(n!=null?n:""),c=Cn(!1),o=Cn(r);o.current=r,Ir(()=>{if(!i||c.current)return;c.current=!0;let{metadata:s,reward:v,value:f,currency:h,externalId:R}=o.current;if(n){a(e,o.current);return}i.goal(e,y(y(y({metadata:s!=null?s:{},weight:v!=null?v:1,stepIndex:0},f!==void 0?{value:f}:{}),h!==void 0?{currency:h}:{}),R!==void 0?{externalId:R}:{}))},[i,n,e,a])}import{renderPrePaintScript as Fr}from"@sentientui/core";import{confidenceBand as Mr}from"@sentientui/policy";import{jsx as jr}from"react/jsx-runtime";function An(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function $r(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+An(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+An(Mr(e.persona.confidence))+");}catch(e){}})();":Fr(e.apiKey)}function Br(e){return jr("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:$r(e)}})}import{useEffect as Fe,useMemo as gt,useRef as zr}from"react";import{validateSlotDecl as qr}from"@sentientui/policy";import{useEffect as ft,useReducer as Wr,useState as Kr,useSyncExternalStore as _n}from"react";import{armOfResult as Ie,baselineResultFor as Jr}from"@sentientui/core";import{confidenceBand as Ur}from"@sentientui/policy";function Ve(e,t){let n=D(),r=Ce(),[,i]=Wr(f=>f+1,0),a=_n($,()=>{var f;return typeof window!="undefined"?(f=window.__sentient_slot_overrides)==null?void 0:f[e]:void 0},()=>{}),c=a===void 0?r[e]:void 0,o=a===void 0&&c===void 0&&n?n.getSlotResult(e):null,p=(n==null?void 0:n.isLocal)===!0&&a===void 0&&c===void 0&&o===null;ft(()=>{if(!p||!n)return;let f=!1;return n.decide({slots:[t]}).then(h=>{!f&&h&&i()}),()=>{f=!0}},[n,e,p]);let s=(()=>{if(a!==void 0)return{result:a,arm:Ie(a),source:"override"};if(c!==void 0)return{result:c,arm:Ie(c),source:"preloaded"};if(o!==null){let h=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:o,arm:Ie(o),source:h?"client":"seeded"}}let f=Jr(t);return{result:f,arm:Ie(f),source:"baseline"}})(),v=s.source==="preloaded"||s.source==="override";return ft(()=>{var h;if(!n||n.isLocal===!0||v||!n.decideSlots)return;let f=(h=n.onSlotsChanged)==null?void 0:h.call(n,i);return n.decideSlots([t]),()=>{var R;(R=n.cancelSlots)==null||R.call(n,[e]),f==null||f()}},[n,e,v]),s}function Hr(){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 Xr(){let e=D(),t=zt();_n($,At,()=>0);let[n,r]=Kr(!1);ft(()=>r(!0),[]);let i=o=>({persona:o.persona,confidence:o.confidence,band:Ur(o.confidence)});if(!n)return t?i(t):null;let a=Hr();if(a)return i(a);if(t)return i(t);let c=e?e.getPersona():null;return c?i(c):null}var On=new Set;function Zr(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Yr(e,t,n){let r=D(),i=z(),a=JSON.stringify(t),c=gt(()=>({id:e,dims:t}),[e,a]),{result:o,arm:p,source:s}=Ve(e,c),v=gt(()=>typeof o=="string"?{}:o,[p]);if(G()&&!On.has(e)){On.add(e);let u=qr({id:e,dims:Object.fromEntries(Object.entries(t).map(([g,l])=>[g,[...l]]))}),m=Object.values(t).reduce((g,l)=>g*l.length,1);u.ok?m>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${m} 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 ${u.reason}. Serving baseline.`)}let f=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);Fe(()=>ue({id:e,dims:t}),[e]);let h=zr(null);Fe(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||h.current===p||(h.current=p,ee(r,i,e,p))},[r,i,e,p,s]);let R=n==null?void 0:n.funnel;Fe(()=>{var u;!r||!R||s==="override"||le(r,i,e,R,B((u=n==null?void 0:n.goal)!=null?u:"click"))},[r,i,e,R,f,s]),Fe(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let u=document.querySelector(`[data-sentient-slot="${Zr(e)}"]`);if(!u){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 m=Q(n.goal),g=H(n.goal),l=!1;return X(u,B(n.goal),{fireGoal:()=>{l||(l=!0,g!==void 0?r.componentGoal(e,m,{value:g}):r.componentGoal(e,m),r.goal(m,y({metadata:{componentId:e,arm:p},weight:1,stepIndex:0},g!==void 0?{value:g}:{})))},fireStep:(S,x,C)=>{r.componentGoal(e,S,{reward:x}),r.goal(S,{metadata:{componentId:e,arm:p},weight:x,stepIndex:C})}},m)},[r,e,f,p,s]);let d=gt(()=>{let u={"data-sentient-slot":e};for(let[m,g]of Object.entries(v))u[`data-${m}`]=g;return u},[e,v]);return{tokens:v,props:d}}import{useCallback as Qr,useEffect as ei,useMemo as ti}from"react";var En=new Set;function ni(e,t){var R;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{client:n,variantIds:r,variantId:i,isOverride:a,goalLabel:c,ref:o,nodeRef:p}=_e(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(R=i!=null?i:r[0])!=null?R:"",v=t.variants[s];ei(()=>{if(!G()||!n)return;let d=setTimeout(()=>{!p.current&&!En.has(e)&&(En.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(d)},[n,e]);let f=Qr((d,u)=>{var g,l;if(a)return;let m=d!=null?d:c;m&&(n==null||n.componentGoal(e,m,u),n==null||n.goal(m,y(y(y({metadata:(g=u==null?void 0:u.metadata)!=null?g:{},weight:(l=u==null?void 0:u.reward)!=null?l:1,stepIndex:0},(u==null?void 0:u.value)!==void 0?{value:u.value}:{}),(u==null?void 0:u.currency)!==void 0?{currency:u.currency}:{}),(u==null?void 0:u.externalId)!==void 0?{externalId:u.externalId}:{})))},[n,e,c,a]),h=ti(()=>({ref:o,"data-sentient-id":e,"data-sentient-variant":s}),[o,e,s]);return{variant:s,value:v,bind:h,fireGoal:f}}import{Children as ri,isValidElement as ii,useEffect as Me,useMemo as Pn,useRef as Gn}from"react";import{jsx as si}from"react/jsx-runtime";var $e=new Set;function oi(e){var g;let t=D(),n=z(),r=Gn(null),i=Object.keys(e.arrangements).join(" "),a=Pn(()=>Object.keys(e.arrangements),[i]),c=Pn(()=>y({id:e.id,arms:a},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,a,e.baseline]),{arm:o,source:p}=Ve(e.id,c);G()&&e.baseline!==void 0&&e.baseline!==a[0]&&!$e.has(e.id+":baseline")&&($e.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${a[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=ri.toArray(e.children).filter(ii),v=new Map;for(let l of s)v.set(String((g=l.key)!=null?g:"").replace(/^\.\$/,""),l);let f=e.arrangements[o],h=f!==void 0&&f.length===s.length&&f.every(l=>v.has(l));G()&&f!==void 0&&!h&&!$e.has(e.id+":keys")&&($e.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 R=h?f.map(l=>v.get(l)):s;Me(()=>ue({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let d=Gn(null);Me(()=>{!t||p==="baseline"||p==="seeded"||p==="override"||d.current===o||(d.current=o,ee(t,n,e.id,o))},[t,n,e.id,o,p]);let u=e.funnel;Me(()=>{var l;!t||!u||p==="override"||le(t,n,e.id,u,B((l=e.goal)!=null?l:"click"))},[t,n,e.id,u,p]);let m=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return Me(()=>{if(!t||e.goal===void 0||p==="override"||p==="baseline"||p==="seeded")return;let l=r.current;if(!l)return;let S=Q(e.goal),x=H(e.goal),C=!1;return X(l,B(e.goal),{fireGoal:()=>{C||(C=!0,x!==void 0?t.componentGoal(e.id,S,{value:x}):t.componentGoal(e.id,S),t.goal(S,y({metadata:{componentId:e.id,arm:o},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(O,b,k)=>{t.componentGoal(e.id,O,{reward:b}),t.goal(O,{metadata:{componentId:e.id,arm:o},weight:b,stepIndex:k})}},S)},[t,e.id,m,o,p]),si("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":o,children:R})}import{deriveSessionSegment as ai}from"@sentientui/core";var li=["page","blocks","layoutOrder"],Tn=new Map;function ui(e,t){Tn.set(e,t)}function Ln(e){return Tn.get(e)}function ci(e){var i,a;let t=(a=(i=e.content)!=null?i:Ln(e.page))!=null?a:{},n={};for(let[c,o]of Object.entries(t))li.includes(c)||(n[c]=o);let r=L(y({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function di(e){return`<script type="application/ld+json">${Dn(e)}</script>`}function Dn(e){return JSON.stringify(y({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function fi(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(`
|
|
3
3
|
`).trimEnd()+`
|
|
4
|
-
`}import{grantConsent as sa}from"@sentientui/core";export{Or as Adaptive,oi as AdaptiveGroup,Yn as AdaptiveProvider,Le as AdaptiveSlot,Tr as AdaptiveText,Br as SentientPersonaScript,ci as buildAgentFeed,ui as defineAgentContent,ai as detectSegment,Ln as getAgentContent,sa as grantConsent,di as renderAgentJsonLd,Dn as renderAgentJsonLdBody,fi as renderAgentMarkdown,pe as renderBlocks,nt as renderCompose,ni as useAdaptive,er as useAdaptiveApiBaseUrl,dt as useAdaptiveGoal,Xr as useAdaptivePersona,Yr as useAdaptiveTokens,Qe as useAssignment,Ze as useInitialAssignments,Qn as useLayoutOrder,Vr as usePageGoal,D as useSentient};
|
|
4
|
+
`}import{grantConsent as sa}from"@sentientui/core";import{consentWatcher as ua}from"@sentientui/core/consent";export{Or as Adaptive,oi as AdaptiveGroup,Yn as AdaptiveProvider,Le as AdaptiveSlot,Tr as AdaptiveText,Br as SentientPersonaScript,ci as buildAgentFeed,ua as consentWatcher,ui as defineAgentContent,ai as detectSegment,Ln as getAgentContent,sa as grantConsent,di as renderAgentJsonLd,Dn as renderAgentJsonLdBody,fi as renderAgentMarkdown,pe as renderBlocks,nt as renderCompose,ni as useAdaptive,er as useAdaptiveApiBaseUrl,dt as useAdaptiveGoal,Xr as useAdaptivePersona,Yr as useAdaptiveTokens,Qe as useAssignment,Ze as useInitialAssignments,Qn as useLayoutOrder,Vr as usePageGoal,D as useSentient};
|
|
5
5
|
//# sourceMappingURL=index.mjs.map
|