@sentientui/react 0.44.0 → 0.44.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/README.md +1 -1
- 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/testing/react.js +1 -1
- package/dist/testing/react.mjs +1 -1
- package/package.json +3 -3
- package/dist/server.d.cts +0 -123
- package/dist/server.d.ts +0 -123
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
var wr=Object.defineProperty,xr=Object.defineProperties;var kr=Object.getOwnPropertyDescriptors;var Me=Object.getOwnPropertySymbols;var Zt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable;var Yt=(e,t,n)=>t in e?wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))Zt.call(t,n)&&Yt(e,n,t[n]);if(Me)for(var n of Me(t))Qt.call(t,n)&&Yt(e,n,t[n]);return e},F=(e,t)=>xr(e,kr(t));var Oe=(e,t)=>{var n={};for(var r in e)Zt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Me)for(var r of Me(e))t.indexOf(r)<0&&Qt.call(e,r)&&(n[r]=e[r]);return n};import{createContext as Ir,useContext as z,useEffect as te,useMemo as _n,useRef as ae,useState as Ee,useSyncExternalStore as Dr}from"react";import{deriveSessionSegment as Lr,init as Fr}from"@sentientui/core";var en=new Map,je=new Map;function tn(e,t){let n=je.get(e);return n||(n=new Set,je.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&je.delete(e)}}function nn(e,t){en.set(e,t);let n=je.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function dt(e){var t;return(t=en.get(e))!=null?t:null}var Rr={on:!1,listeners:new Set};function ft(){if(typeof window=="undefined")return Rr;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function rn(e){let t=ft();if(t.on!==e){t.on=e;for(let n of t.listeners)n()}}function gt(){return ft().on}function on(e){let t=ft().listeners;return t.add(e),()=>{t.delete(e)}}function sn(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,o)=>e.assign(t,n,r,i,o),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 mt="sentient:overrides-changed";function an(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function pt(){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(mt))}function Y(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(mt,e),()=>window.removeEventListener(mt,e))}function ln(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function D(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function Z(e){return typeof e=="string"?{type:"click"}:e}function ue(e){return typeof e=="string"?e:e.type}function ie(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var yt=new Set,vt=!1;function un(e){if(yt.has(e))return!0;if(yt.add(e),!vt){vt=!0;let t=()=>{vt=!1,yt.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 Ar(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function cn(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(Ar(r))return!0;r=r.parentElement}return!1}function oe(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,v=[];return t.steps.forEach(({goal:c,name:b,weight:x},g)=>{let p=(S=!1)=>{s.has(g)||S&&r!==void 0&&un(`step\0${b}\0${x}\0${g}`)||(s.add(g),n.fireStep(b,x,g))};if(c.type==="click"){let S=y=>{let f=y.target;f instanceof Element&&cn(f,e,c.selector)&&p()};e.addEventListener("click",S),v.push(()=>e.removeEventListener("click",S));return}if(c.type==="form_submit"){let S=y=>{y.target instanceof HTMLFormElement&&e.contains(y.target)&&p()};e.addEventListener("submit",S),v.push(()=>e.removeEventListener("submit",S));return}if(c.type==="scroll_depth"){let S=Math.max(0,Math.min(1,c.threshold)),y=new IntersectionObserver(f=>{for(let h of f)if(h.intersectionRatio>=S){p(!0),y.disconnect();break}},{threshold:[S]});y.observe(e),v.push(()=>y.disconnect())}}),()=>{for(let c of v)c()}}let i=t.type==="composite"?t.all:[t],o=new Set(i.map((s,v)=>v)),l=()=>{r!==void 0&&un(r)||n.fireGoal()},a=(s,v=!1)=>{o.delete(s),o.size===0&&(v?l():n.fireGoal())},u=[];return i.forEach((s,v)=>{if(s.type==="click"){let c=b=>{let x=b.target;x instanceof Element&&cn(x,e,s.selector)&&(t.type==="composite"?a(v):n.fireGoal())};e.addEventListener("click",c),u.push(()=>e.removeEventListener("click",c));return}if(s.type==="form_submit"){let c=b=>{b.target instanceof HTMLFormElement&&e.contains(b.target)&&(t.type==="composite"?a(v):n.fireGoal())};e.addEventListener("submit",c),u.push(()=>e.removeEventListener("submit",c));return}if(s.type==="scroll_depth"){let c=Math.max(0,Math.min(1,s.threshold)),b=new IntersectionObserver(x=>{for(let g of x)if(g.intersectionRatio>=c){t.type==="composite"?a(v,!0):l(),b.disconnect();break}},{threshold:[c]});b.observe(e),u.push(()=>b.disconnect());return}}),()=>{for(let s of u)s()}}var dn=new Set,fn=new Set;function Cr(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,100);if(t&&t===e)return`${t}-steps`;let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n+e.charCodeAt(r)>>>0;return`${t||"component"}-${n.toString(36)}-steps`}var _r=12;function Or(e,t){let n=new Set,r=[];for(let o of t.steps){let l=o.name;!l||l.length>128||l.startsWith("funnel:")||n.has(l)||r.length===_r||(n.add(l),r.push({goalId:l,weight:Math.min(1,Math.max(0,o.weight||0))}))}let i=[...r].sort((o,l)=>o.weight-l.weight);return(r.length<t.steps.length||i.some((o,l)=>o!==r[l]))&&D()&&console.warn(`[SentientUI] "${e}": weighted_composite steps adjusted for its funnel (skipped invalid/repeated/over-12 steps, or ordered by weight)`),i}function se(e,t,n,r,i){let o=(i==null?void 0:i.type)==="weighted_composite"?i:null,l=r!=null?r:o?Cr(n):void 0;if(!l)return;let a=`${l}|${n}`;if(fn.has(a))return;fn.add(a);let u=o&&!dn.has(l)?Or(n,o):null,s=u!==null&&u.length>=2;s&&dn.add(l),!(!s&&r===void 0)&&e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:s?{funnelId:l,steps:u}:{funnelId:l}})}function ce(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Gr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function ge(){if(typeof window=="undefined")return Gr;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 Ge(){ge().version+=1;for(let e of ge().listeners)e()}var gn=()=>{};function $e(e){return D()?(ge().components.set(e.id,e),Ge(),()=>{ge().components.delete(e.id),Ge()}):gn}function he(e){return D()?(ge().slots.set(e.id,e),Ge(),()=>{ge().slots.delete(e.id),Ge()}):gn}function St(e){D()&&(ge().sections=[...e],Ge())}var mn="0.44.0",ht=mn!=="0.0.0-dev"?{name:"react",version:mn}:void 0;function Er(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function be(e,t){Er()[e]=t}function pn(e){window.__sentient_vocabulary_override=e}function yn(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Pr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function we(e,t){Pr()[e]=t}function vn(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let o=n.slice(0,r.index)+i;history.replaceState(history.state,"",o?"#"+o:location.pathname+location.search)}}catch(n){}return t}var wt="__snt_editor_token",xe=null,bt=!1;function Sn(){return bt}function Nr(){try{return sessionStorage.getItem(wt)}catch(e){return null}}function Be(e){if(xe)return xe;let t=typeof window=="undefined"?null:vn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Nr();return bt=!!n,xe=Promise.resolve(n?{token:n,fresh:!1}:null),xe}return bt=!0,xe=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(wt,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),xe}function hn(){try{sessionStorage.removeItem(wt)}catch(e){}}var bn="sentient_preview_cell",wn="sentient_refresh_region",xt="sentient-cell-preview-bar",me="__preview__",ke=null;function xn(e){if((ke==null?void 0:ke.slotId)!==e)return null;let t=ke;return ke=null,t}function kn(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(m({slotId:e.slotId},t))})}).then(n=>pe(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>pe("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function Rn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(xt))return;let t,n;try{let u=new URLSearchParams(window.location.search);t=u.get(bn),n=u.get(wn)}catch(u){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=Be(r);if(!Sn())return;if(n){ke={slotId:n,session:i,base:r},be(n,{kind:"arms"}),we(n,me),pt();return}if(!t)return;let o=t.lastIndexOf("~");if(o<=0)return;let l=t.slice(0,o),a=t.slice(o+1);i.then(u=>u?"token"in u?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(l)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${u.token}`}}):(pe(u.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async u=>{if(!u)return;if(!u.ok){pe(u.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 u.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&pn(s.vocabulary),s.compose!=null)be(l,{kind:"arms",compose:{[me]:s.compose}}),we(l,me);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))be(l,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),we(l,me);else if(s.blocks!=null)be(l,{kind:"arms",blocks:{[me]:s.blocks}}),we(l,me);else if(s.content!=null)be(l,{kind:"arms",content:s.content}),we(l,me);else{pe("Nothing to preview in that square yet.");return}pt(),pe(`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="${l}"]`))==null||v.scrollIntoView({block:"center"})}catch(c){}},300)}).catch(()=>pe("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function pe(e){var i;if(document.getElementById(xt))return;let t=document.createElement("div");t.id=xt,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=()=>{hn();let o=new URL(window.location.href);o.searchParams.delete(bn),o.searchParams.delete(wn),window.location.assign(o.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var An=!1;function Cn(e){if(An||typeof window=="undefined")return;An=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");Be(t).then(n=>{!n||!("token"in n)||!n.fresh||Tr(t,n.token)})}function Tr(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}import{jsx as Kr}from"react/jsx-runtime";function Vr(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return Lr({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Gn="https://api.sentient-ui.com/v1",X=Ir({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Gn,debug:!1}),On=!1,kt=new Set;function Mr(e,t,n){let r=ae(n);r.current=n;let[i,o]=Ee(null),[l,a]=Ee(!1),u=ae(e);u.current=e;let s=e===void 0?"":typeof e=="string"?e:JSON.stringify(F(m({},e),{check:typeof e.check,refused:typeof e.refused}));return te(()=>{let v=u.current;if(v===void 0||typeof window=="undefined")return;let c,b=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:g})=>{if(b)return;let p=x(typeof v=="object"&&v.cmp===void 0&&v.check?m(F(m({},v),{check:()=>u.current.check()}),v.refused?{refused:()=>{var f,h;return((h=(f=u.current).refused)==null?void 0:h.call(f))===!0}}:{}):v),S=!1,y=()=>{let f=p.refused()&&p.read()!==!0;f&&!S&&(g(t),r.current()),S=f,a(f);let h=p.read();h!==null&&kt.add(t),o(h!=null?h:kt.has(t)?!1:null)};y(),c=p.subscribe(y)}),()=>{b=!0,c==null||c()}},[s,t]),{granted:i,refused:l}}function jr(e){var G,R,C,d,A,j;let[t,n]=Ee(null),[r]=Ee(()=>{var w;return(w=e.sessionSegment)!=null?w:Vr()}),[i,o]=Ee(gt());te(()=>on(()=>o(gt())),[]),te(()=>{Rn(e.apiBaseUrl),typeof window!="undefined"&&/[?&]sentient_preview=[^&]*(:|%3A)/i.test(window.location.search)&&(rn(!0),import("@sentientui/react/version-preview").then(w=>w.maybeStartVersionPreview(e.apiKey,e.apiBaseUrl)).catch(()=>{})),Cn(e.apiBaseUrl)},[]);let l=ae(()=>{}),a=Mr(e.consentFrom,e.apiKey,()=>l.current()),u=e.consentFrom?(G=a.granted)!=null?G:kt.has(e.apiKey)?!1:e.consent===!0:e.consent,s=e.consentFrom?a.refused:!0,v=ae(s);v.current=s;let c=ae(null),b=ae(!1),x=ae([]),g=ae(!1);l.current=()=>{var E;x.current=[],g.current=!0;let w=c.current;w!=null&&w.gated?w.dispose():(E=w==null?void 0:w.takeHeld)==null||E.call(w)},te(()=>{var J,Ce;if(v.current&&u===!1&&(x.current=[]),u===!1&&b.current&&(v.current&&((J=c.current)==null||J.destroy()),c.current=null,b.current=!1),u===!1&&!e.preConsentBehavior){v.current&&((Ce=c.current)==null||Ce.destroy()),c.current=null,n(null);return}let w=u!==!1;w&&(g.current=!1);let E=W=>{!w&&g.current&&W.gated&&W.dispose()},L=m({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:u,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,internal:e.internal,stageAttributes:e.stageAttributes,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,nonce:e.nonce},ht?{sdk:ht}:{}),I=!1,N=null,K=null,$=W=>{for(let ne of x.current.splice(0))setTimeout(()=>{if(c.current!==W){g.current||x.current.push(ne);return}try{ne(W)}catch(_e){}},0)},M=W=>{e.engagement===!1||!w||import("@sentientui/core/engagement").then(({startEngagementCapture:ne})=>{I||(K=ne(W,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:W})=>{I||(N=W(F(m({},L),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),E(N),c.current=N,b.current=w,$(N),n(N),M(N))}):(N=Fr(L),E(N),c.current=N,b.current=w,$(N),n(N),M(N)),()=>{var W,ne;I=!0,K==null||K(),x.current=x.current.concat((ne=(W=N==null?void 0:N.takeHeld)==null?void 0:W.call(N))!=null?ne:[]),N==null||N.dispose()}},[u]),te(()=>{if(!t)return;let w=!1,E=async()=>{if(w)return;let I;try{I=await t.fetchWeights()}catch(N){return}if(!w)for(let N of I){let K={componentId:N.componentId,updatedAt:N.updatedAt,variants:N.variants.map($=>{var M;return{variantId:$.variantId,pulls:$.pulls,avgReward:(M=$.avgReward)!=null?M:0}})};nn(N.componentId,K)}};E();let L=setInterval(()=>{E()},6e4);return()=>{w=!0,clearInterval(L)}},[t]);let p=(R=e.ssrFallback)!=null?R:"first",S=((C=e.apiBaseUrl)!=null?C:Gn).replace(/\/$/,""),y=ae(null);te(()=>{var L;if(typeof process!="undefined"&&((L=process.env)==null?void 0:L.NODE_ENV)==="production")return;let w={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,internal:e.internal,apiBaseUrl:S},E=y.current;if(y.current=w,E!==null)for(let I of["apiKey","context","country","persona","internal","apiBaseUrl"])Object.is(E[I],w[I])||console.warn(`[sentient] AdaptiveProvider: \`${I}\` 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,e.internal,S]),te(()=>{var w;typeof process!="undefined"&&((w=process.env)==null?void 0:w.NODE_ENV)==="production"||ln({apiKey:e.apiKey,apiBaseUrl:S,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,S]);let f=(d=e.identity)==null?void 0:d.userId,h=(A=e.identity)==null?void 0:A.userHash,k=(j=e.identity)==null?void 0:j.email;te(()=>{t&&f&&t.identify(f,{userHash:h,email:k})},[t,f,h,k]),te(()=>{let w=e.initialLayoutOrder;if(w&&w.length>0){St(w);return}e.declaredSections&&e.declaredSections.length>0&&St(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),te(()=>{!D()||e.consent!==void 0||e.consentFrom!==void 0||On||(On=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),te(()=>{if(!D())return;let w=e.declaredSections;if(!w||w.length===0||typeof document=="undefined")return;let E=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),I=>I.getAttribute("data-sentient-id"))),L=w.filter(I=>!E.has(I));L.length>0&&console.warn(`[SentientUI] Declared section${L.length>1?"s":""} ${L.map(I=>`"${I}"`).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 _=_n(()=>t&&i?sn(t):t,[t,i]),P=_n(()=>{var w,E,L,I,N,K,$,M,J;return{client:_,apiKey:e.apiKey,initialAssignments:(w=e.initialAssignments)!=null?w:{},initialUnified:(E=e.initialUnified)!=null?E:$r,sessionSegment:r,ssrFallback:p,onAssignment:e.onAssignment,initialLayoutOrder:(L=e.initialLayoutOrder)!=null?L:null,initialSlots:(I=e.initialSlots)!=null?I:{},initialSlotConfig:(N=e.initialSlotConfig)!=null?N:{},initialPalette:(K=e.initialPalette)!=null?K:null,initialVocabulary:($=e.initialVocabulary)!=null?$:null,initialPersona:(M=e.initialPersona)!=null?M:null,apiBaseUrl:S,debug:(J=e.debug)!=null?J:!1}},[_,e.apiKey,e.initialAssignments,e.initialUnified,r,p,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,S,e.debug]);return Kr(X.Provider,{value:P,children:e.children})}function V(){return z(X).client}function ee(){return z(X).apiKey}function Rt(){return z(X).initialAssignments}var $r=[];function Ue(){return z(X).initialUnified}function Pe(){return z(X).sessionSegment}function En(){return z(X).ssrFallback}function Ke(){return z(X).onAssignment}function Pn(){return z(X).debug}function Br(){let e=z(X).initialLayoutOrder,t=Dr(Y,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function We(){return z(X).initialSlots}function Nn(){return z(X).initialPersona}function Tn(){return z(X).initialSlotConfig}function In(){return z(X).initialPalette}function Dn(){return z(X).initialVocabulary}function Ur(){return z(X).apiBaseUrl}import{memo as yi,useCallback as vi,useEffect as Si,useState as ir}from"react";import{useCallback as Hr,useEffect as ye,useMemo as Fn,useRef as Ne,useState as Xr}from"react";import{attachMicroSignalDetectors as zr}from"@sentientui/core";import{useEffect as Je,useRef as Ln,useState as Wr,useSyncExternalStore as Jr}from"react";import{pickFromWeights as At}from"@sentientui/policy";function de(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 o=i.indexOf(":");if(o!==-1&&i.slice(0,o)===e)return i.slice(o+1)}}catch(r){}return null}function Ct(e,t,n,r,i){let o=Rt(),l=En(),a=V(),u=Pe(),s=Ke(),v=Pn(),c=Ln(null),b=Jr(Y,()=>de(e),()=>null),x=b&&t.includes(b)?b:null,g=Ln(null);Je(()=>{v&&x&&g.current!==x&&(g.current=x,console.info(`[sentient] override active: ${e} -> ${x}`))},[v,x,e]);let[p,S]=Wr(()=>{var k,_;if(x)return{variantId:x,content:null,isLoading:!1,settled:!0};if(!a){let P=o[e];return P&&t.includes(P)?{variantId:P,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 f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content))return{variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0};let h=dt(e);if(h){let P=At(h.variants,t);if(P)return{variantId:P,content:null,isLoading:!1,settled:!0}}return{variantId:(_=t[0])!=null?_:null,content:null,isLoading:!1,settled:!1}}),y=f=>{s&&c.current!==f&&(c.current=f,s(e,f))};return Je(()=>{var k;if(x||!a)return;let f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content)){S({variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0}),y(f.variantId);return}let h=dt(e);if(h&&p.settled&&p.variantId&&p.variantId===At(h.variants,t)){y(p.variantId);return}S(_=>{var P;return _.variantId?_:{variantId:(P=t[0])!=null?P:null,content:null,isLoading:!1,settled:!1}})},[x,a,e,u]),Je(()=>{if(x||!a)return;let f=a.getAssignment(e,u);if(f&&t.includes(f.variantId))return;let h=!1,k=i==null?void 0:i.onUnified;return(k?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(P=>{var G;if(!h&&P){if(P.unified===!0){k==null||k();return}!t.includes(P.variantId)&&!P.content||(S({variantId:P.variantId,content:(G=P.content)!=null?G:null,isLoading:!1,settled:!0}),y(P.variantId))}}),()=>{h=!0}},[x,a,e,u]),Je(()=>{if(!x&&a)return tn(e,f=>{var _;let h=a.getAssignment(e,u);if(h&&(t.includes(h.variantId)||h.content)){S({variantId:h.variantId,content:(_=h.content)!=null?_:null,isLoading:!1,settled:!0}),y(h.variantId);return}let k=At(f.variants,t);k&&(S({variantId:k,content:null,isLoading:!1,settled:!0}),y(k))})},[x,a,e,u]),x?{variantId:x,content:null,isLoading:!1,settled:!0,isOverride:!0}:p}function He(e,t,n){let r=V(),i=ee(),o=Object.keys(t).join("\0"),l=Fn(()=>Object.keys(t),[o]),{variantId:a,content:u,isOverride:s=!1,settled:v}=Ct(e,l,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[c,b]=Xr(null),x=Ne(null),g=Hr(d=>{x.current=d,b(d)},[]),p=n.goal,S=typeof p=="string"?p:JSON.stringify(p),y=Fn(()=>p?Z(p):null,[S]),f=p?ue(p):"";ye(()=>$e({id:e,variantIds:l,goal:f}),[e,l,f]);let h=Ne(null);ye(()=>{s||v&&(!r||!a||!i||!c||h.current!==a&&(h.current=a,ce(r,i,e,a)))},[r,a,i,e,c,s,v]);let k=Ne(!1),_=Ne(new Set);ye(()=>{k.current=!1,_.current=new Set},[a,y]);let P=n.funnel;ye(()=>{s||!v||!r||!y||se(r,i,e,P,y)},[r,i,e,P,y,s,v]);let G=n.cursorSignal===!0;ye(()=>{if(!G||s||!v||!r||!a||!c)return;let d=null,A=0,j=()=>{A=Date.now(),d=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-A}}),d=null},800)},w=()=>{d!==null&&(clearTimeout(d),d=null)};return c.addEventListener("mouseenter",j),c.addEventListener("mouseleave",w),()=>{c.removeEventListener("mouseenter",j),c.removeEventListener("mouseleave",w),d!==null&&clearTimeout(d)}},[G,r,a,i,e,c,s,v]);let R=Ne(n.microSignalGoals);R.current=n.microSignalGoals;let C=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return ye(()=>{if(s||!v||!r||!a||!c)return;let d=Date.now();return zr((A,j={})=>{var N,K,$;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:m({signalType:A},j)});let w=(N=R.current)==null?void 0:N[A];if(!w||_.current.has(A))return;_.current.add(A);let E=typeof w=="string"?w:w.name,L=typeof w=="string"?1:(K=w.weight)!=null?K:1,I=typeof w=="string"?0:($=w.stepIndex)!=null?$:0;r.goal(E,{metadata:m({signalType:A},j),weight:L,stepIndex:I})},c,d)},[r,a,i,e,c,C,s,v]),ye(()=>{if(s||!v||!r||!a||!c||!y)return;let d=ie(y);return oe(c,y,{fireGoal:()=>{k.current||(k.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:f,payload:m({reward:1},d!==void 0?{goalValue:d}:{})}),r.goal(f,m({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},d!==void 0?{value:d}:{})))},fireStep:(A,j,w)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:A,payload:{reward:j}}),r.goal(A,{metadata:{},weight:j,stepIndex:w})}},f)},[r,a,i,e,c,y,f,s,v]),{client:r,variantIds:l,variantId:a,content:u,settled:v,isOverride:s,goalLabel:f,ref:g,nodeRef:x}}import{useEffect as q,useMemo as Qe,useRef as Se,useState as di,useSyncExternalStore as fi}from"react";import{attachMicroSignalDetectors as gi,containsFormBlock as Qn,reveal as mi}from"@sentientui/core";import{captureRegionSkeleton as er}from"@sentientui/core/region";import{useCallback as qr,useEffect as Vn,useRef as _t,useSyncExternalStore as Xe}from"react";import{armOfResult as Yr}from"@sentientui/core";var Mn=new Set,Zr={kind:"arms"};function jn(e,t){var _,P,G;let n=V(),r=_t(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=_t(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let o=_t(t==null?void 0:t.skeleton);o.current=t==null?void 0:t.skeleton;let l=We(),a=Tn(),u=In(),s=Dn(),v=Xe(Y,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_config_overrides)==null?void 0:R[e]:void 0},()=>{}),c=Xe(Y,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_overrides)==null?void 0:R[e]:void 0},()=>{}),b=R=>R==null?"":Yr(R),x=qr(R=>{var C,d;return(d=(C=n==null?void 0:n.onSlotsChanged)==null?void 0:C.call(n,R))!=null?d:(()=>{})},[n]);Xe(x,()=>{var R;return(R=n==null?void 0:n.getSlotConfig(e))!=null?R:null},()=>null),Xe(x,()=>b(n==null?void 0:n.getSlotResult(e)),()=>"");let g=v===void 0?a[e]:void 0,p=v===void 0&&g===void 0&&n?n.getSlotConfig(e):null,S=(_=u!=null?u:n==null?void 0:n.getSitePalette())!=null?_:null,y=(G=s!=null?s:(P=n==null?void 0:n.getStyleVocabulary)==null?void 0:P.call(n))!=null?G:null,f=(()=>{var R,C,d;if(v!==void 0)return{config:v,arm:b(c),palette:S,vocabulary:(R=yn())!=null?R:y,source:"override"};if(t!=null&&t.forcedArm)return{config:Zr,arm:t.forcedArm,palette:S,vocabulary:y,source:"override"};if(g!==void 0)return{config:g,arm:b((C=l[e])!=null?C:n==null?void 0:n.getSlotResult(e)),palette:S,vocabulary:y,source:"preloaded"};if(p!==null){let A=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:p,arm:b((d=n==null?void 0:n.getSlotResult(e))!=null?d:l[e]),palette:S,vocabulary:y,source:A?"client":"seeded"}}return{config:null,arm:"",palette:S,vocabulary:y,source:"none"}})(),h=(t==null?void 0:t.defer)===!0,k=f.source==="preloaded"||f.source==="override";return Vn(()=>{var L,I,N,K,$;if(!n||n.isLocal===!0||k||h)return;let R=f.source==="none",C=R&&(I=(L=r.current)==null?void 0:L.call(r))!=null?I:null,d=C!=null&&C!==""?{[e]:C}:void 0,A=(N=i.current)==null?void 0:N.call(i),j=R&&($=(K=o.current)==null?void 0:K.call(o))!=null?$:null,w=m(m({},A?{render:{[e]:A}}:{}),j?{skeletons:{[e]:j}}:{}),E=Object.keys(w).length>0;return n.requestSlots?E?n.requestSlots([e],d,w):d?n.requestSlots([e],d):n.requestSlots([e]):R&&(j?n.reportSlots([e],d!=null?d:{},{[e]:j}):d?n.reportSlots([e],d):n.reportSlots([e])),()=>{var M;return(M=n.cancelSlots)==null?void 0:M.call(n,[e])}},[n,k,f.source,e,h]),Vn(()=>{!D()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||Mn.has(e)||(Mn.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,f.source,e]),f}import{cloneElement as Qr,Fragment as $n}from"react";import{jsx as B,jsxs as Wn}from"react/jsx-runtime";function Ot(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var fe={none:"0",sm:"8px",md:"16px",lg:"24px"},Gt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Jn={sm:"0.875em",md:"1em",lg:"1.25em"},ei={sm:"1.25em",md:"1.5em",lg:"2em"},Bn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Un={sm:"8px",md:"16px",lg:"32px"},ti={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},ni={normal:"400",medium:"500",bold:"700"};function Kn(e,t){return m(m({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?m({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Hn(e,t,n){var i,o,l,a;let r=t==null?void 0:t.accent;return F(m({display:"inline-block",padding:(i=Bn[n!=null?n:"md"])!=null?i:Bn.md,borderRadius:(o=t==null?void 0:t.radius)!=null?o:"8px",font:"inherit"},n?{fontSize:Jn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(l=t==null?void 0:t.primaryBg)!=null?l:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function ri({node:e,opts:t}){var i,o,l,a,u;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(l=(o=t.palette)==null?void 0:o.border)!=null?l:"currentColor"}`,borderRadius:(u=(a=t.palette)==null?void 0:a.radius)!=null?u:"8px"};return Wn("form",{onSubmit:s=>{var b,x,g;s.preventDefault();let v=new FormData(s.currentTarget),c={};for(let p of e.fields)c[p.name]=String((b=v.get(p.name))!=null?b:"");(x=t.onFormGoal)==null||x.call(t,e.submitGoal);try{(g=t.onFormSubmit)==null||g.call(t,c)}catch(p){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var v,c;return Wn("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?B("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?B("select",{name:s.name,required:s.required,style:r,children:((v=s.options)!=null?v:[]).map(b=>B("option",{value:b,children:b},b))}):B("input",{name:s.name,type:(c=s.inputType)!=null?c:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),B("button",{type:"submit",style:Hn(n,t.palette),children:e.submitLabel})]})}function ii(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(o=>o.id===n))==null?void 0:i.classes:void 0}function Xn(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 Re(e,t){var i;let n=oi(e,t),r=Xn(e.like,t);return n&&r?Qr(n,{style:F(m({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function oi(e,t){var n,r,i,o,l,a,u,s,v,c,b,x,g,p,S,y,f,h,k,_,P,G,R;try{let C=ii(e,t);switch(e.type){case"stack":{let d=(r=fe[(n=e.gap)!=null?n:"md"])!=null?r:fe.md,A=e.surface==="raised"&&!C,j=(i=e.pad)!=null?i:A?"md":void 0;return B("div",F(m({},C?{className:C}:{}),{style:m(m(m(m(m({display:"flex",flexDirection:e.direction,gap:d},e.align?{alignItems:Gt[e.align]}:{}),e.justify?{justifyContent:Gt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),j?{padding:(o=fe[j])!=null?o:fe.md}:{}),A?F(m(m({},(l=t.palette)!=null&&l.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((u=t.palette)!=null&&u.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(v=(s=t.palette)==null?void 0:s.border)!=null?v:"currentColor"}`,borderRadius:(b=(c=t.palette)==null?void 0:c.radius)!=null?b:"8px"}):{}),children:((x=e.children)!=null?x:[]).map((w,E)=>{let L=Re(w,t);return L===null?null:B($n,{children:L},E)})}))}case"grid":{let d=(p=fe[(g=e.gap)!=null?g:"md"])!=null?p:fe.md;return B("div",F(m({},C?{className:C}:{}),{style:m(m({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${d}) / ${e.columns})), 1fr))`,gap:d},e.align?{alignItems:Gt[e.align]}:{}),e.pad?{padding:(S=fe[e.pad])!=null?S:fe.md}:{}),children:((y=e.children)!=null?y:[]).map((A,j)=>{let w=Re(A,t);return w===null?null:B($n,{children:w},j)})}))}case"text":return C?B("p",{className:C,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):B("p",{style:m(m(m(m(m({margin:0},e.size?{fontSize:Jn[e.size]}:{}),e.weight?{fontWeight:ni[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Kn(e.tone,t.palette)),children:e.value});case"heading":{let d=`h${e.level}`;return C?B(d,{className:C,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):B(d,{style:m(m({margin:0,fontSize:ei[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let d=(h=e.emphasis)!=null?h:"primary";return B("a",F(m(m({href:Ot(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),C?{className:C}:{style:Hn(d,t.palette,e.size)}),{children:e.label}))}case"link":return B("a",F(m(m({href:Ot(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),C?{className:C}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return B("img",F(m({src:Ot(e.src),alt:e.alt},C?{className:C}:{}),{style:m(m({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:ti[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return C?B("span",{className:C,children:e.value}):B("span",{style:m({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(_=(k=t.palette)==null?void 0:k.border)!=null?_:"currentColor"}`},Kn(e.tone,t.palette)),children:e.value});case"spacer":return B("div",{style:{height:(P=Un[e.size])!=null?P:Un.md}});case"divider":return B("hr",{style:{border:"none",borderTop:`1px solid ${(R=(G=t.palette)==null?void 0:G.border)!=null?R:"currentColor"}`,margin:0,width:"100%"}});case"form":return B(ri,{node:e,opts:t});default:return null}}catch(C){return null}}function Et(e,t){var o,l,a,u;let n=Re(e.tree,t);if(n===null)return null;let r=(o=e.surface)!=null&&o.like?(a=(l=t.vocabulary)==null?void 0:l.entries.find(s=>s.id===e.surface.like))==null?void 0:a.classes:void 0,i=Xn((u=e.surface)==null?void 0:u.like,t);return r?B("div",F(m({className:r},i?{style:{color:i}}:{}),{children:n})):n}import{cloneElement as ze,isValidElement as qe}from"react";import{normalizeLeafText as si,skeletonFingerprint as ai}from"@sentientui/core/region";function Ye(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function Ze(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ve(e){return Ye(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ve(n),0):qe(e)?ve(Ze(e)):0}function li(e,t){return Array.isArray(t)?ze(e,void 0,...t):ze(e,void 0,t)}function Pt(e,t){if(Ye(e))return t;if(Array.isArray(e))return e.map(n=>Pt(n,t));if(qe(e)){let n=Ze(e);return ve(n)===0?e:li(e,Pt(n,t))}return e}function zn(e,t){return ve(e)===1?Pt(e,t):null}var Q=e=>e.join("/");function Nt(e,t,n){if(Ye(e)){n.leafPaths.push(t),n.texts.push(si(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>Nt(r,[...t,i],n));return}qe(e)&&(n.elements.set(Q(t),e),Nt(Ze(e),[...t,"c"],n))}function It(e){let t={leafPaths:[],texts:[],elements:new Map};return Nt(e,[],t),t}function ui(e){return It(e).texts}function qn(e){let t=ui(e);return t.length===0?null:ai(t)}function ci(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function Yn(e,t){let n=t.reduce((i,o)=>Math.max(i,o+1),0),r=[];for(let i=0;i<n;i++){let o=t.flatMap((a,u)=>a===i?[ci(e.leafPaths[u])]:[]);if(o.length===0){r.push(null);continue}let l=o[0];for(let a of o.slice(1)){let u=new Set(a.map(Q));l=l.filter(s=>u.has(Q(s)))}r.push(l.length>0?l[l.length-1]:null)}return r}function Tt(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 Dt(e,t){let n=It(t);if(n.texts.length!==e.leaves.length||n.texts.some((o,l)=>o!==e.leaves[l]))return null;let r=Yn(n,e.leafToNode),i=e.nodes.map((o,l)=>{let a=r[l],u=a?n.elements.get(Q(a)):void 0,s=!!u&&(typeof u.type=="string"||Tt(u)!==void 0);return F(m({},o),{restylable:s})});return F(m({},e),{nodes:i})}function Zn(e,t,n){var g;let r=It(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((p,S)=>Math.max(p,S+1),0);for(let p of Object.keys(t.nodes))if(!/^\d+$/.test(p)||Number(p)>=i)return null;let o=Yn(r,n),l=new Map;n.forEach((p,S)=>{l.has(p)||l.set(p,S)});let a=new Map(r.leafPaths.map((p,S)=>[Q(p),S])),u=new Set,s=new Map,v=!1;for(let[p,S]of Object.entries(t.nodes)){let y=Number(p),f=o[y];if(S.hidden&&(f?u.add(Q(f)):v=!0),S.like!==void 0){let h=o[S.like],k=f?r.elements.get(Q(f)):void 0,_=h?Tt(r.elements.get(Q(h))):void 0;!f||_===void 0||Tt(k)===void 0?v=!0:s.set(Q(f),_)}}let c=new Map(Object.entries((g=t.order)!=null?g:{})),b=(p,S)=>{var y;if(Ye(p)){let f=a.get(Q(S));if(f===void 0)return p;let h=n[f],k=(y=t.nodes[String(h)])==null?void 0:y.text;return k===void 0?p:l.get(h)===f?k:""}if(Array.isArray(p)){let f=p.map((h,k)=>b(h,[...S,k]));for(let[h,k]of c){let _=k.map(R=>{let C=o[R];return!C||C.length!==S.length+1||Q(C.slice(0,-1))!==Q(S)?-1:C[C.length-1]});if(_.some(R=>R<0))continue;let P=[..._].sort((R,C)=>R-C),G=[...f];P.forEach((R,C)=>{f[R]=G[_[C]]}),c.delete(h)}return f}if(qe(p)){let f=Q(S);if(u.has(f))return null;let h=Ze(p);if(ve(h)===0)return p;let k=b(h,[...S,"c"]),_=s.get(f),P=_!==void 0?{className:_}:void 0;return Array.isArray(k)?ze(p,P,...k):ze(p,P,k)}return p},x=b(e,[]);return v||c.size>0?null:x}import{jsx as pi}from"react/jsx-runtime";var tr=new Set,nr=new Set,rr=new Set,et="authored.";function Te({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:o,as:l="div",reportBaselineText:a=!0,funnel:u,microSignalGoals:s,clientOnly:v,agentDataByVariant:c,agentData:b,variantsOnly:x=!1}){var Jt,Ht;let g=V(),p=ee(),S=Se(null),[y,f]=di(!1);q(()=>{f(!0)},[]);let h=v===!0&&(!y||!g),k=Qe(()=>qn(t),[t]),_=n?Object.keys(n).join("|"):"",P=Qe(()=>m({fp:k!=null?k:"0000000000000000",forms:!!r,compose:!0,content:ve(t)===1,ops:!1},_!==""?{authored:_.split("|"),children:!x}:{}),[k,t,r,_,x]),G=()=>{var H;let O=S.current;if(!O||!a)return null;let T=er(O);return T.skeleton?(H=Dt(T.skeleton,t))!=null?H:F(m({},T.skeleton),{editable:!1,nodes:T.skeleton.nodes.map(U=>F(m({},U),{restylable:!1}))}):{status:T.reason}},R=fi(Y,()=>n?de(e):null,()=>null),C=R===null||!n?null:Object.prototype.hasOwnProperty.call(n,R)?`${et}${R}`:x?`${et}${Object.keys(n)[0]}`:"baseline",{config:d,arm:A,palette:j,vocabulary:w,source:E}=jn(e,{forcedArm:C,baselineText:a?()=>{var O,T;return(T=(O=S.current)==null?void 0:O.textContent)!=null?T:null}:void 0,render:()=>P,skeleton:G,defer:h}),L=A!==""?(Jt=d==null?void 0:d.blocks)==null?void 0:Jt[A]:void 0,I=A!==""?(Ht=d==null?void 0:d.compose)==null?void 0:Ht[A]:void 0,N=(L!==void 0&&Qn(L)||I!==void 0&&Qn(I.tree))&&!r;q(()=>{!N||!D()||tr.has(e)||(tr.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.`))},[N,e]);let K=O=>{!g||E==="override"||(E!=="seeded"&&g.componentGoal(e,O),g.goal(O,{metadata:{componentId:e,arm:A},weight:1,stepIndex:0}))},$=t,M=!1,J=A.startsWith(et)?A.slice(et.length):null;if((d==null?void 0:d.blocked)==="variant_history")M=!0;else if(J!==null)n&&Object.prototype.hasOwnProperty.call(n,J)?$=n[J]:M=!0;else if(I!==void 0){let O=N?null:Et(I,{palette:j,vocabulary:w,onFormSubmit:r,onFormGoal:K});O===null?M=!0:$=O}else if(L!==void 0){let O=N?null:Re(L,{palette:j,vocabulary:w,onFormSubmit:r,onFormGoal:K});O===null?M=!0:$=O}else if((d==null?void 0:d.edits)!==void 0&&E!=="none"){let O=d.edits,T=O.fp===k?Zn(t,O.edits,O.leafToNode):null;T===null?M=!0:$=T}else if((d==null?void 0:d.content)!==void 0&&E!=="none"){let O=zn(t,d.content);O===null?M=!0:$=O}let Ce=M&&L===void 0&&I===void 0&&(d==null?void 0:d.edits)===void 0&&J===null&&(d==null?void 0:d.blocked)===void 0;q(()=>{(d==null?void 0:d.blocked)!=="variant_history"||!D()||rr.has(e)||(rr.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 W=J!==null&&!M?J:null;q(()=>{var re;if(!W||!a||!g)return;let O=S.current;if(!O)return;let T=er(O),H=T.skeleton?Dt(T.skeleton,n==null?void 0:n[W]):null,U=(re=O.textContent)==null?void 0:re.trim();g.reportSlots([],void 0,void 0,{[e]:[m(m({key:W},U?{text:U}:{}),H?{skeleton:H}:{})]})},[W,g,e,h]);let ne=M&&(d==null?void 0:d.edits)!==void 0&&(E==="preloaded"||E==="client");q(()=>{var O;!ne||!(d!=null&&d.edits)||(O=g==null?void 0:g.reportDrift)==null||O.call(g,e,d.edits.fp,k,d.edits.fp===k?"unaddressable":"fp_mismatch")},[ne,e,k,g]);let _e=$===t;q(()=>{var T;if(!(d!=null&&d.needsSkeleton)||!_e)return;let O=G();O&&((T=g==null?void 0:g.reportSkeleton)==null||T.call(g,e,O))},[d==null?void 0:d.needsSkeleton,_e,e,g,h]),q(()=>{if(!_e)return;let O=xn(e);if(!O)return;let T=G();kn(O,T&&"status"in T?{status:T.status}:{skeleton:T})},[e,_e,h]),q(()=>{!Ce||!D()||nr.has(e)||(nr.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.`))},[Ce,e]);let st=d!=null&&d.blocks?Object.keys(d.blocks).sort().join("|"):"",at=n?[...x?[]:["baseline"],..._.split("|")].join("|"):"";q(()=>at!==""?$e({id:e,variantIds:at.split("|")}):he({id:e,arms:st===""?void 0:st.split("|")}),[e,st,at]);let jt=Se(null);q(()=>{!g||E==="none"||E==="seeded"||E==="override"||A===""||M||jt.current!==A&&(jt.current=A,ce(g,p,e,A))},[g,p,e,A,E,M]);let le=E!=="none"&&E!=="seeded"&&!M,lt=le?A:"",$t=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);q(()=>{if(!g||!i||E==="override")return;let O=S.current;if(!O)return;let T=ue(i),H=ie(i),U=!1;return oe(O,Z(i),{fireGoal:()=>{U||(U=!0,le&&(H!==void 0?g.componentGoal(e,T,{value:H}):g.componentGoal(e,T)),g.goal(T,m({metadata:{componentId:e,arm:lt},weight:1,stepIndex:0},H!==void 0?{value:H}:{})))},fireStep:(re,Ve,ct)=>{le&&g.componentGoal(e,re,{reward:Ve}),g.goal(re,{metadata:{componentId:e,arm:lt},weight:Ve,stepIndex:ct})}},T)},[g,e,$t,A,E,M,le,lt,h]);let ut=Qe(()=>i?Z(i):null,[$t]);q(()=>{E==="override"||!g||!ut||se(g,p,e,u,ut)},[g,p,e,u,ut,E]);let Bt=Se(s);Bt.current=s;let Ut=Se(new Set),hr=s?JSON.stringify(s):"";q(()=>{if(!g||E==="override"||!le||A==="")return;let O=S.current;if(O)return gi((T,H={})=>{var Xt,zt,qt;g.track({projectId:p,componentId:e,variantId:A,eventType:"micro_signal",payload:m({signalType:T},H)});let U=(Xt=Bt.current)==null?void 0:Xt[T];if(!U||Ut.current.has(T))return;Ut.current.add(T);let re=typeof U=="string"?U:U.name,Ve=typeof U=="string"?1:(zt=U.weight)!=null?zt:1,ct=typeof U=="string"?0:(qt=U.stepIndex)!=null?qt:0;g.goal(re,{metadata:m({componentId:e,arm:A,signalType:T},H),weight:Ve,stepIndex:ct})},O,Date.now())},[g,p,e,A,E,le,hr,h]);let Kt=Se({agentData:b,agentDataByVariant:c});Kt.current={agentData:b,agentDataByVariant:c};let Wt=Se(null);q(()=>{var re;if(!g||E==="override"||!le||A===""||Wt.current===A)return;let{agentData:O,agentDataByVariant:T}=Kt.current,H=J!=null?J:A,U=T!==void 0?Object.prototype.hasOwnProperty.call(T,H)?T[H]:void 0:O;U!==void 0&&(Wt.current=A,(re=g.reportAgentData)==null||re.call(g,e,A,U))},[g,e,A,le,J,E]);let Fe=Se(null);q(()=>{let O=S.current;if(O){if(Fe.current===null){Fe.current=A;return}Fe.current!==A&&(Fe.current=A,mi(O))}},[A,h]);let br=Qe(()=>m({"data-sentient-slot":e},A!==""?{"data-sentient-arm":A}:{}),[e,A]);return h?null:pi(l,F(m({ref:S,className:o},br),{children:$}))}import{jsx as Ae}from"react/jsx-runtime";function hi(e){var v,c;let{client:t,variantId:n,content:r,ref:i}=He(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[o,l]=ir(!1);Si(()=>{l(!0)},[]);let a=(v=e.as)!=null?v:"div";if(e.clientOnly&&(!o||!t)||!n)return null;let u=(c=e.variants[n])!=null?c:null,s=u===null?r:null;return D()&&u===null&&s===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.`),Ae(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:u!=null?u:s})}var bi=yi(hi,(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.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)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 wi(e){if(e.variants===void 0)return Ae(Te,m({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=Oe(n,["variants"]);return Ae(Te,F(m({},i),{children:t.children,variants:r}))}return Ae(xi,m({},t))}function xi(e){var c;let[t,n]=ir(null),{id:r}=e,i=vi(()=>n(r),[r]),o=V(),l=Ue().includes(r)||((c=o==null?void 0:o.isUnified)==null?void 0:c.call(o,r))===!0;if(t!==r&&!l)return Ae(bi,F(m({},e),{onUnified:i}));let b=e,{variants:a,children:u}=b,s=Oe(b,["variants","children"]),v=Object.keys(a)[0];return Ae(Te,F(m({},s),{variants:a,variantsOnly:!0,children:v!==void 0?a[v]:null}))}import{useEffect as Ie,useMemo as ki,useRef as Lt,useState as or,useSyncExternalStore as Ri}from"react";import{jsx as Ci}from"react/jsx-runtime";function Ai({id:e,default:t,component:n="span",className:r,goal:i}){var P;let o=V(),l=ee(),a=Ke(),u=Pe(),s=Lt(null),v=Lt(null),c=Ri(Y,()=>de(e),()=>null),[b,x]=or(()=>{var G,R;return(R=(G=o==null?void 0:o.getAssignment(e,u))==null?void 0:G.content)!=null?R:null}),[g,p]=or(()=>{var G,R;return(R=(G=o==null?void 0:o.getAssignment(e,u))==null?void 0:G.variantId)!=null?R:null});Ie(()=>{if(c||!o)return;let G=o.getAssignment(e,u);if((G==null?void 0:G.content)!==void 0){p(G.variantId),x(G.content);return}let R=!1;return o.assign(e).then(C=>{if(!R){if(!C){D()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}p(C.variantId),C.content&&x(C.content)}}),()=>{R=!0}},[o,e,u,c]),Ie(()=>{c||!o||!g||!l||s.current!==g&&(s.current=g,o.track({projectId:l,componentId:e,variantId:g,eventType:"variant_assigned",payload:{}}),a==null||a(e,g))},[o,g,l,e,a,c]);let S=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),y=ki(()=>i===void 0?null:Z(i),[S]),f=i===void 0?null:typeof i=="string"?i:y.type,h=Lt(!1);Ie(()=>{h.current=!1},[g,S]),Ie(()=>{c||!o||!l||se(o,l,e,void 0,y)},[o,l,e,y,c]),Ie(()=>{if(c||!o||!g||!l||!y||!f)return;let G=v.current;if(!G)return;let R=ie(y);return oe(G,y,{fireGoal:()=>{h.current||(h.current=!0,o.track({projectId:l,componentId:e,variantId:g,eventType:"goal_achieved",goalType:f,payload:m({reward:1},R!==void 0?{goalValue:R}:{})}),o.goal(f,m({metadata:{componentId:e,variantId:g},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(C,d,A)=>{o.track({projectId:l,componentId:e,variantId:g,eventType:"goal_achieved",goalType:C,payload:{reward:d}}),o.goal(C,{metadata:{},weight:d,stepIndex:A})}})},[o,g,l,e,y,f,c]);let k=b!=null?b:t;if(c){let G=o==null?void 0:o.getAssignment(e,u);k=G&&G.variantId===c&&(P=G.content)!=null?P:t}return Ci(n,{ref:G=>{v.current=G},className:r,children:k})}import{useCallback as _i,useRef as Oi}from"react";function De(e){var t,n;return m(m(m({metadata:(t=e==null?void 0:e.metadata)!=null?t:{},weight:(n=e==null?void 0:e.reward)!=null?n:1,stepIndex:0},(e==null?void 0:e.value)!==void 0?{value:e.value}:{}),(e==null?void 0:e.currency)!==void 0?{currency:e.currency}:{}),(e==null?void 0:e.externalId)!==void 0?{externalId:e.externalId}:{})}function Le(e){let t=V(),n=Oi(new Set);return _i((r,i)=>{if(!de(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,De(i))}},[t,e])}import{useEffect as Gi,useRef as sr}from"react";function Ei(e,t={}){let u=t,{componentId:n}=u,r=Oe(u,["componentId"]),i=V(),o=Le(n!=null?n:""),l=sr(!1),a=sr(r);a.current=r,Gi(()=>{if(!(!i||l.current||i.gated)){if(l.current=!0,n){o(e,a.current);return}i.goal(e,De(a.current))}},[i,n,e,o])}import{useCallback as Pi,useEffect as Ni,useRef as Ti}from"react";var ar=new Set,lr=new Map;function Ii(e,t,n,r){let i=r;if(r){let l=lr.get(t);l&&l!==n?(D()&&console.warn(`[SentientUI] useGoal('${n}'): '${l}' is already primary on this page`),i=!1):lr.set(t,n)}let o=`${t}|${n}|${i?"primary":""}`;ar.has(o)||(ar.add(o),e.track({projectId:t,componentId:"__session__",eventType:"goal_declared",payload:i?{goalId:n,primary:!0}:{goalId:n}}))}function Di(e,t={}){let{primary:n=!1,componentId:r}=t,i=V(),o=ee(),l=Le(r!=null?r:""),a=Ti(!1);return Ni(()=>{!i||i.gated||!o||Ii(i,o,e,n)},[i,o,e,n]),Pi(u=>{if(u!=null&&u.once){if(a.current)return;a.current=!0}if(r){l(e,u);return}i==null||i.goal(e,De(u))},[i,r,l,e])}import{renderPrePaintScript as Li}from"@sentientui/core";import{confidenceBand as Fi}from"@sentientui/policy";import{jsx as ji}from"react/jsx-runtime";function Ft(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Vi(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Ft(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Ft(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Ft(Fi(e.persona.confidence))+");}catch(e){}})();":Li(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function Mi(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:ji("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Vi(e)}})}import{useEffect as rt,useMemo as Mt,useRef as Hi}from"react";import{validateSlotDecl as Xi}from"@sentientui/policy";import{useEffect as Vt,useReducer as $i,useState as Bi,useSyncExternalStore as ur}from"react";import{armOfResult as tt,baselineResultFor as Ui}from"@sentientui/core";import{confidenceBand as Ki}from"@sentientui/policy";function nt(e,t){let n=V(),r=We(),[,i]=$i(c=>c+1,0),o=ur(Y,()=>{var c;return typeof window!="undefined"?(c=window.__sentient_slot_overrides)==null?void 0:c[e]:void 0},()=>{}),l=o===void 0?r[e]:void 0,a=o===void 0&&l===void 0&&n?n.getSlotResult(e):null,u=(n==null?void 0:n.isLocal)===!0&&o===void 0&&l===void 0&&a===null;Vt(()=>{if(!u||!n)return;let c=!1;return n.decide({slots:[t]}).then(b=>{!c&&b&&i()}),()=>{c=!0}},[n,e,u]);let s=(()=>{if(o!==void 0)return{result:o,arm:tt(o),source:"override"};if(l!==void 0)return{result:l,arm:tt(l),source:"preloaded"};if(a!==null){let b=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:tt(a),source:b?"client":"seeded"}}let c=Ui(t);return{result:c,arm:tt(c),source:"baseline"}})(),v=s.source==="preloaded"||s.source==="override";return Vt(()=>{var b;if(!n||n.isLocal===!0||v||!n.decideSlots)return;let c=(b=n.onSlotsChanged)==null?void 0:b.call(n,i);return n.decideSlots([t]),()=>{var x;(x=n.cancelSlots)==null||x.call(n,[e]),c==null||c()}},[n,e,v]),s}function Wi(){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 Ji(){let e=V(),t=Nn();ur(Y,an,()=>0);let[n,r]=Bi(!1);Vt(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:Ki(a.confidence)});if(!n)return t?i(t):null;let o=Wi();if(o)return i(o);if(t)return i(t);let l=e?e.getPersona():null;return l?i(l):null}var cr=new Set;function zi(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function qi(e,t,n){let r=V(),i=ee(),o=JSON.stringify(t),l=Mt(()=>({id:e,dims:t}),[e,o]),{result:a,arm:u,source:s}=nt(e,l),v=Mt(()=>typeof a=="string"?{}:a,[u]);if(D()&&!cr.has(e)){cr.add(e);let p=Xi({id:e,dims:Object.fromEntries(Object.entries(t).map(([y,f])=>[y,[...f]]))}),S=Object.values(t).reduce((y,f)=>y*f.length,1);p.ok?S>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${S} 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 ${p.reason}. Serving baseline.`)}let c=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);rt(()=>he({id:e,dims:t}),[e]);let b=Hi(null);rt(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||b.current===u||(b.current=u,ce(r,i,e,u))},[r,i,e,u,s]);let x=n==null?void 0:n.funnel;rt(()=>{var p;!r||s==="override"||se(r,i,e,x,Z((p=n==null?void 0:n.goal)!=null?p:"click"))},[r,i,e,x,c,s]),rt(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let p=document.querySelector(`[data-sentient-slot="${zi(e)}"]`);if(!p){D()&&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 S=ue(n.goal),y=ie(n.goal),f=!1;return oe(p,Z(n.goal),{fireGoal:()=>{f||(f=!0,y!==void 0?r.componentGoal(e,S,{value:y}):r.componentGoal(e,S),r.goal(S,m({metadata:{componentId:e,arm:u},weight:1,stepIndex:0},y!==void 0?{value:y}:{})))},fireStep:(h,k,_)=>{r.componentGoal(e,h,{reward:k}),r.goal(h,{metadata:{componentId:e,arm:u},weight:k,stepIndex:_})}},S)},[r,e,c,u,s]);let g=Mt(()=>{let p={"data-sentient-slot":e};for(let[S,y]of Object.entries(v))p[`data-${S}`]=y;return p},[e,v]);return{tokens:v,props:g}}import{useCallback as Yi,useEffect as dr,useMemo as Zi}from"react";var fr=new Set,gr=new Set;function Qi(e,t){var g,p;if(D()&&!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:o,goalLabel:l,ref:a,nodeRef:u}=He(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(g=i!=null?i:r[0])!=null?g:"",v=t.variants[s],c=Ue().includes(e)||((p=n==null?void 0:n.isUnified)==null?void 0:p.call(n,e))===!0;dr(()=>{!c||!D()||gr.has(e)||(gr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[c,e]),dr(()=>{if(!D()||!n)return;let S=setTimeout(()=>{!u.current&&!fr.has(e)&&(fr.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(S)},[n,e]);let b=Yi((S,y)=>{var h,k;if(o)return;let f=S!=null?S:l;f&&(n==null||n.componentGoal(e,f,y),n==null||n.goal(f,m(m(m({metadata:(h=y==null?void 0:y.metadata)!=null?h:{},weight:(k=y==null?void 0:y.reward)!=null?k:1,stepIndex:0},(y==null?void 0:y.value)!==void 0?{value:y.value}:{}),(y==null?void 0:y.currency)!==void 0?{currency:y.currency}:{}),(y==null?void 0:y.externalId)!==void 0?{externalId:y.externalId}:{})))},[n,e,l,o]),x=Zi(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":s}),[a,e,s]);return{variant:s,value:v,bind:x,fireGoal:b}}import{Children as eo,isValidElement as to,useEffect as it,useMemo as mr,useRef as pr}from"react";import{jsx as ro}from"react/jsx-runtime";var ot=new Set;function no(e){var f;let t=V(),n=ee(),r=pr(null),i=Object.keys(e.arrangements).join(" "),o=mr(()=>Object.keys(e.arrangements),[i]),l=mr(()=>m({id:e.id,arms:o},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,o,e.baseline]),{arm:a,source:u}=nt(e.id,l);D()&&e.baseline!==void 0&&e.baseline!==o[0]&&!ot.has(e.id+":baseline")&&(ot.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${o[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=eo.toArray(e.children).filter(to),v=new Map;for(let h of s)v.set(String((f=h.key)!=null?f:"").replace(/^\.\$/,""),h);let c=e.arrangements[a],b=c!==void 0&&c.length===s.length&&c.every(h=>v.has(h));D()&&c!==void 0&&!b&&!ot.has(e.id+":keys")&&(ot.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${c.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let x=b?c.map(h=>v.get(h)):s;it(()=>he({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let g=pr(null);it(()=>{!t||u==="baseline"||u==="seeded"||u==="override"||g.current===a||(g.current=a,ce(t,n,e.id,a))},[t,n,e.id,a,u]);let p=e.funnel,S=e.goal===void 0||typeof e.goal=="string"?"":JSON.stringify(e.goal);it(()=>{var h;!t||u==="override"||se(t,n,e.id,p,Z((h=e.goal)!=null?h:"click"))},[t,n,e.id,p,S,u]);let y=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return it(()=>{if(!t||e.goal===void 0||u==="override"||u==="baseline"||u==="seeded")return;let h=r.current;if(!h)return;let k=ue(e.goal),_=ie(e.goal),P=!1;return oe(h,Z(e.goal),{fireGoal:()=>{P||(P=!0,_!==void 0?t.componentGoal(e.id,k,{value:_}):t.componentGoal(e.id,k),t.goal(k,m({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},_!==void 0?{value:_}:{})))},fireStep:(G,R,C)=>{t.componentGoal(e.id,G,{reward:R}),t.goal(G,{metadata:{componentId:e.id,arm:a},weight:R,stepIndex:C})}},k)},[t,e.id,y,a,u]),ro("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:x})}import{deriveSessionSegment as io}from"@sentientui/core";var oo=["page","blocks","layoutOrder"],yr=new Map;function so(e,t){yr.set(e,t)}function vr(e){return yr.get(e)}function ao(e){var i,o;let t=(o=(i=e.content)!=null?i:vr(e.page))!=null?o:{},n={};for(let[l,a]of Object.entries(t))oo.includes(l)||(n[l]=a);let r=F(m({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function lo(e){return`<script type="application/ld+json">${Sr(e)}</script>`}function Sr(e){return JSON.stringify(m({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function uo(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 xr=Object.defineProperty,kr=Object.defineProperties;var Rr=Object.getOwnPropertyDescriptors;var Me=Object.getOwnPropertySymbols;var Qt=Object.prototype.hasOwnProperty,en=Object.prototype.propertyIsEnumerable;var Zt=(e,t,n)=>t in e?xr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))Qt.call(t,n)&&Zt(e,n,t[n]);if(Me)for(var n of Me(t))en.call(t,n)&&Zt(e,n,t[n]);return e},F=(e,t)=>kr(e,Rr(t));var Oe=(e,t)=>{var n={};for(var r in e)Qt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Me)for(var r of Me(e))t.indexOf(r)<0&&en.call(e,r)&&(n[r]=e[r]);return n};import{createContext as Dr,useContext as z,useEffect as te,useMemo as On,useRef as ae,useState as Ee,useSyncExternalStore as Lr}from"react";import{deriveSessionSegment as Fr,init as Vr}from"@sentientui/core";var tn=new Map,je=new Map;function nn(e,t){let n=je.get(e);return n||(n=new Set,je.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&je.delete(e)}}function rn(e,t){tn.set(e,t);let n=je.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function ft(e){var t;return(t=tn.get(e))!=null?t:null}var Ar={on:!1,listeners:new Set};function gt(){if(typeof window=="undefined")return Ar;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function on(e){let t=gt();if(t.on!==e){t.on=e;for(let n of t.listeners)n()}}function mt(){return gt().on}function sn(e){let t=gt().listeners;return t.add(e),()=>{t.delete(e)}}function an(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,o)=>e.assign(t,n,r,i,o),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 pt="sentient:overrides-changed";function ln(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function yt(){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(pt))}function Y(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(pt,e),()=>window.removeEventListener(pt,e))}function un(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function D(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function Z(e){return typeof e=="string"?{type:"click"}:e}function ue(e){return typeof e=="string"?e:e.type}function ie(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var vt=new Set,St=!1;function cn(e){if(vt.has(e))return!0;if(vt.add(e),!St){St=!0;let t=()=>{St=!1,vt.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 Cr(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function dn(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(Cr(r))return!0;r=r.parentElement}return!1}function oe(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,y=[];return t.steps.forEach(({goal:c,name:b,weight:x},g)=>{let m=(S=!1)=>{s.has(g)||S&&r!==void 0&&cn(`step\0${b}\0${x}\0${g}`)||(s.add(g),n.fireStep(b,x,g))};if(c.type==="click"){let S=v=>{let f=v.target;f instanceof Element&&dn(f,e,c.selector)&&m()};e.addEventListener("click",S),y.push(()=>e.removeEventListener("click",S));return}if(c.type==="form_submit"){let S=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&m()};e.addEventListener("submit",S),y.push(()=>e.removeEventListener("submit",S));return}if(c.type==="scroll_depth"){let S=Math.max(0,Math.min(1,c.threshold)),v=new IntersectionObserver(f=>{for(let h of f)if(h.intersectionRatio>=S){m(!0),v.disconnect();break}},{threshold:[S]});v.observe(e),y.push(()=>v.disconnect())}}),()=>{for(let c of y)c()}}let i=t.type==="composite"?t.all:[t],o=new Set(i.map((s,y)=>y)),l=()=>{r!==void 0&&cn(r)||n.fireGoal()},a=(s,y=!1)=>{o.delete(s),o.size===0&&(y?l():n.fireGoal())},u=[];return i.forEach((s,y)=>{if(s.type==="click"){let c=b=>{let x=b.target;x instanceof Element&&dn(x,e,s.selector)&&(t.type==="composite"?a(y):n.fireGoal())};e.addEventListener("click",c),u.push(()=>e.removeEventListener("click",c));return}if(s.type==="form_submit"){let c=b=>{b.target instanceof HTMLFormElement&&e.contains(b.target)&&(t.type==="composite"?a(y):n.fireGoal())};e.addEventListener("submit",c),u.push(()=>e.removeEventListener("submit",c));return}if(s.type==="scroll_depth"){let c=Math.max(0,Math.min(1,s.threshold)),b=new IntersectionObserver(x=>{for(let g of x)if(g.intersectionRatio>=c){t.type==="composite"?a(y,!0):l(),b.disconnect();break}},{threshold:[c]});b.observe(e),u.push(()=>b.disconnect());return}}),()=>{for(let s of u)s()}}var fn=new Set,gn=new Set;function _r(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,100);if(t&&t===e)return`${t}-steps`;let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n+e.charCodeAt(r)>>>0;return`${t||"component"}-${n.toString(36)}-steps`}var Or=12;function Gr(e,t){let n=new Set,r=[];for(let o of t.steps){let l=o.name;!l||l.length>128||l.startsWith("funnel:")||n.has(l)||r.length===Or||(n.add(l),r.push({goalId:l,weight:Math.min(1,Math.max(0,o.weight||0))}))}let i=[...r].sort((o,l)=>o.weight-l.weight);return(r.length<t.steps.length||i.some((o,l)=>o!==r[l]))&&D()&&console.warn(`[SentientUI] "${e}": weighted_composite steps adjusted for its funnel (skipped invalid/repeated/over-12 steps, or ordered by weight)`),i}function se(e,t,n,r,i){let o=(i==null?void 0:i.type)==="weighted_composite"?i:null,l=r!=null?r:o?_r(n):void 0;if(!l)return;let a=`${l}|${n}`;if(gn.has(a))return;gn.add(a);let u=o&&!fn.has(l)?Gr(n,o):null,s=u!==null&&u.length>=2;s&&fn.add(l),!(!s&&r===void 0)&&e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:s?{funnelId:l,steps:u}:{funnelId:l}})}function ce(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Er={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function me(){if(typeof window=="undefined")return Er;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 Ge(){me().version+=1;for(let e of me().listeners)e()}var mn=()=>{};function $e(e){return D()?(me().components.set(e.id,e),Ge(),()=>{me().components.delete(e.id),Ge()}):mn}function he(e){return D()?(me().slots.set(e.id,e),Ge(),()=>{me().slots.delete(e.id),Ge()}):mn}function ht(e){D()&&(me().sections=[...e],Ge())}var pn="0.44.1",bt=pn!=="0.0.0-dev"?{name:"react",version:pn}:void 0;function Pr(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function be(e,t){Pr()[e]=t}function yn(e){window.__sentient_vocabulary_override=e}function vn(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Nr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function we(e,t){Nr()[e]=t}function Sn(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let o=n.slice(0,r.index)+i;history.replaceState(history.state,"",o?"#"+o:location.pathname+location.search)}}catch(n){}return t}var xt="__snt_editor_token",xe=null,wt=!1;function hn(){return wt}function Tr(){try{return sessionStorage.getItem(xt)}catch(e){return null}}function Be(e){if(xe)return xe;let t=typeof window=="undefined"?null:Sn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Tr();return wt=!!n,xe=Promise.resolve(n?{token:n,fresh:!1}:null),xe}return wt=!0,xe=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(xt,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),xe}function bn(){try{sessionStorage.removeItem(xt)}catch(e){}}var wn="sentient_preview_cell",xn="sentient_refresh_region",kt="sentient-cell-preview-bar",pe="__preview__",ke=null;function kn(e){if((ke==null?void 0:ke.slotId)!==e)return null;let t=ke;return ke=null,t}function Rn(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(p({slotId:e.slotId},t))})}).then(n=>ye(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>ye("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function An(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(kt))return;let t,n;try{let u=new URLSearchParams(window.location.search);t=u.get(wn),n=u.get(xn)}catch(u){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=Be(r);if(!hn())return;if(n){ke={slotId:n,session:i,base:r},be(n,{kind:"arms"}),we(n,pe),yt();return}if(!t)return;let o=t.lastIndexOf("~");if(o<=0)return;let l=t.slice(0,o),a=t.slice(o+1);i.then(u=>u?"token"in u?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(l)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${u.token}`}}):(ye(u.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async u=>{if(!u)return;if(!u.ok){ye(u.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 u.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&yn(s.vocabulary),s.compose!=null)be(l,{kind:"arms",compose:{[pe]:s.compose}}),we(l,pe);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))be(l,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),we(l,pe);else if(s.blocks!=null)be(l,{kind:"arms",blocks:{[pe]:s.blocks}}),we(l,pe);else if(s.content!=null)be(l,{kind:"arms",content:s.content}),we(l,pe);else{ye("Nothing to preview in that square yet.");return}yt(),ye(`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(c){}},300)}).catch(()=>ye("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function ye(e){var i;if(document.getElementById(kt))return;let t=document.createElement("div");t.id=kt,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=()=>{bn();let o=new URL(window.location.href);o.searchParams.delete(wn),o.searchParams.delete(xn),window.location.assign(o.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var Cn=!1;function _n(e){if(Cn||typeof window=="undefined")return;Cn=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");Be(t).then(n=>{!n||!("token"in n)||!n.fresh||Ir(t,n.token)})}function Ir(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}import{jsx as Wr}from"react/jsx-runtime";function Mr(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return Fr({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var En="https://api.sentient-ui.com/v1",X=Dr({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:En,debug:!1}),Gn=!1,Rt=new Set;function jr(e,t,n){let r=ae(n);r.current=n;let[i,o]=Ee(null),[l,a]=Ee(!1),u=ae(e);u.current=e;let s=e===void 0?"":typeof e=="string"?e:JSON.stringify(F(p({},e),{check:typeof e.check,refused:typeof e.refused}));return te(()=>{let y=u.current;if(y===void 0||typeof window=="undefined")return;let c,b=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:g})=>{if(b)return;let m=x(typeof y=="object"&&y.cmp===void 0&&y.check?p(F(p({},y),{check:()=>u.current.check()}),y.refused?{refused:()=>{var f,h;return((h=(f=u.current).refused)==null?void 0:h.call(f))===!0}}:{}):y),S=!1,v=()=>{let f=m.refused()&&m.read()!==!0;f&&!S&&(g(t),r.current()),S=f,a(f);let h=m.read();h!==null&&Rt.add(t),o(h!=null?h:Rt.has(t)?!1:null)};v(),c=m.subscribe(v)}),()=>{b=!0,c==null||c()}},[s,t]),{granted:i,refused:l}}function $r(e){var G,R,C,d,A,j;let[t,n]=Ee(null),[r]=Ee(()=>{var w;return(w=e.sessionSegment)!=null?w:Mr()}),[i,o]=Ee(mt());te(()=>sn(()=>o(mt())),[]),te(()=>{An(e.apiBaseUrl),typeof window!="undefined"&&/[?&]sentient_preview=[^&]*(:|%3A)/i.test(window.location.search)&&(on(!0),import("@sentientui/react/version-preview").then(w=>w.maybeStartVersionPreview(e.apiKey,e.apiBaseUrl)).catch(()=>{})),_n(e.apiBaseUrl)},[]);let l=ae(()=>{}),a=jr(e.consentFrom,e.apiKey,()=>l.current()),u=e.consentFrom?(G=a.granted)!=null?G:Rt.has(e.apiKey)?!1:e.consent===!0:e.consent,s=e.consentFrom?a.refused:!0,y=ae(s);y.current=s;let c=ae(null),b=ae(!1),x=ae([]),g=ae(!1);l.current=()=>{var E;x.current=[],g.current=!0;let w=c.current;w!=null&&w.gated?w.dispose():(E=w==null?void 0:w.takeHeld)==null||E.call(w)},te(()=>{var J,Ce;if(y.current&&u===!1&&(x.current=[]),u===!1&&b.current&&(y.current&&((J=c.current)==null||J.destroy()),c.current=null,b.current=!1),u===!1&&!e.preConsentBehavior){y.current&&((Ce=c.current)==null||Ce.destroy()),c.current=null,n(null);return}let w=u!==!1;w&&(g.current=!1);let E=W=>{!w&&g.current&&W.gated&&W.dispose()},L=p({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:u,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,internal:e.internal,stageAttributes:e.stageAttributes,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,nonce:e.nonce},bt?{sdk:bt}:{}),I=!1,N=null,K=null,$=W=>{for(let ne of x.current.splice(0))setTimeout(()=>{if(c.current!==W){g.current||x.current.push(ne);return}try{ne(W)}catch(_e){}},0)},M=W=>{e.engagement===!1||!w||import("@sentientui/core/engagement").then(({startEngagementCapture:ne})=>{I||(K=ne(W,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:W})=>{I||(N=W(F(p({},L),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),E(N),c.current=N,b.current=w,$(N),n(N),M(N))}):(N=Vr(L),E(N),c.current=N,b.current=w,$(N),n(N),M(N)),()=>{var W,ne;I=!0,K==null||K(),x.current=x.current.concat((ne=(W=N==null?void 0:N.takeHeld)==null?void 0:W.call(N))!=null?ne:[]),N==null||N.dispose()}},[u]),te(()=>{if(!t)return;let w=!1,E=async()=>{if(w)return;let I;try{I=await t.fetchWeights()}catch(N){return}if(!w)for(let N of I){let K={componentId:N.componentId,updatedAt:N.updatedAt,variants:N.variants.map($=>{var M;return{variantId:$.variantId,pulls:$.pulls,avgReward:(M=$.avgReward)!=null?M:0}})};rn(N.componentId,K)}};E();let L=setInterval(()=>{E()},6e4);return()=>{w=!0,clearInterval(L)}},[t]);let m=(R=e.ssrFallback)!=null?R:"first",S=((C=e.apiBaseUrl)!=null?C:En).replace(/\/$/,""),v=ae(null);te(()=>{var L;if(typeof process!="undefined"&&((L=process.env)==null?void 0:L.NODE_ENV)==="production")return;let w={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,internal:e.internal,apiBaseUrl:S},E=v.current;if(v.current=w,E!==null)for(let I of["apiKey","context","country","persona","internal","apiBaseUrl"])Object.is(E[I],w[I])||console.warn(`[sentient] AdaptiveProvider: \`${I}\` 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,e.internal,S]),te(()=>{var w;typeof process!="undefined"&&((w=process.env)==null?void 0:w.NODE_ENV)==="production"||un({apiKey:e.apiKey,apiBaseUrl:S,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,S]);let f=(d=e.identity)==null?void 0:d.userId,h=(A=e.identity)==null?void 0:A.userHash,k=(j=e.identity)==null?void 0:j.email;te(()=>{t&&f&&t.identify(f,{userHash:h,email:k})},[t,f,h,k]),te(()=>{let w=e.initialLayoutOrder;if(w&&w.length>0){ht(w);return}e.declaredSections&&e.declaredSections.length>0&&ht(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),te(()=>{!D()||e.consent!==void 0||e.consentFrom!==void 0||Gn||(Gn=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),te(()=>{if(!D())return;let w=e.declaredSections;if(!w||w.length===0||typeof document=="undefined")return;let E=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),I=>I.getAttribute("data-sentient-id"))),L=w.filter(I=>!E.has(I));L.length>0&&console.warn(`[SentientUI] Declared section${L.length>1?"s":""} ${L.map(I=>`"${I}"`).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 _=On(()=>t&&i?an(t):t,[t,i]),P=On(()=>{var w,E,L,I,N,K,$,M,J;return{client:_,apiKey:e.apiKey,initialAssignments:(w=e.initialAssignments)!=null?w:{},initialUnified:(E=e.initialUnified)!=null?E:Br,sessionSegment:r,ssrFallback:m,onAssignment:e.onAssignment,initialLayoutOrder:(L=e.initialLayoutOrder)!=null?L:null,initialSlots:(I=e.initialSlots)!=null?I:{},initialSlotConfig:(N=e.initialSlotConfig)!=null?N:{},initialPalette:(K=e.initialPalette)!=null?K:null,initialVocabulary:($=e.initialVocabulary)!=null?$:null,initialPersona:(M=e.initialPersona)!=null?M:null,apiBaseUrl:S,debug:(J=e.debug)!=null?J:!1}},[_,e.apiKey,e.initialAssignments,e.initialUnified,r,m,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,S,e.debug]);return Wr(X.Provider,{value:P,children:e.children})}function V(){return z(X).client}function ee(){return z(X).apiKey}function At(){return z(X).initialAssignments}var Br=[];function Ue(){return z(X).initialUnified}function Pe(){return z(X).sessionSegment}function Pn(){return z(X).ssrFallback}function Ke(){return z(X).onAssignment}function Nn(){return z(X).debug}function Ur(){let e=z(X).initialLayoutOrder,t=Lr(Y,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function We(){return z(X).initialSlots}function Tn(){return z(X).initialPersona}function In(){return z(X).initialSlotConfig}function Dn(){return z(X).initialPalette}function Ln(){return z(X).initialVocabulary}function Kr(){return z(X).apiBaseUrl}import{memo as vi,useCallback as Si,useEffect as hi,useState as ar}from"react";import{useCallback as Xr,useEffect as fe,useMemo as jn,useRef as Ne,useState as zr}from"react";import{attachMicroSignalDetectors as qr}from"@sentientui/core";import{useEffect as Je,useRef as Fn,useState as Jr,useSyncExternalStore as Hr}from"react";import{pickFromWeights as Ct}from"@sentientui/policy";function de(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 o=i.indexOf(":");if(o!==-1&&i.slice(0,o)===e)return i.slice(o+1)}}catch(r){}return null}function _t(e,t,n,r,i){let o=At(),l=Pn(),a=V(),u=Pe(),s=Ke(),y=Nn(),c=Fn(null),b=Hr(Y,()=>de(e),()=>null),x=b&&t.includes(b)?b:null,g=Fn(null);Je(()=>{y&&x&&g.current!==x&&(g.current=x,console.info(`[sentient] override active: ${e} -> ${x}`))},[y,x,e]);let[m,S]=Jr(()=>{var k,_;if(x)return{variantId:x,content:null,isLoading:!1,settled:!0};if(!a){let P=o[e];return P&&t.includes(P)?{variantId:P,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 f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content))return{variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0};let h=ft(e);if(h){let P=Ct(h.variants,t);if(P)return{variantId:P,content:null,isLoading:!1,settled:!0}}return{variantId:(_=t[0])!=null?_:null,content:null,isLoading:!1,settled:!1}}),v=f=>{s&&c.current!==f&&(c.current=f,s(e,f))};return Je(()=>{var k;if(x||!a)return;let f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content)){S({variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0}),v(f.variantId);return}let h=ft(e);if(h&&m.settled&&m.variantId&&m.variantId===Ct(h.variants,t)){v(m.variantId);return}S(_=>{var P;return _.variantId?_:{variantId:(P=t[0])!=null?P:null,content:null,isLoading:!1,settled:!1}})},[x,a,e,u]),Je(()=>{if(x||!a)return;let f=a.getAssignment(e,u);if(f&&t.includes(f.variantId))return;let h=!1,k=i==null?void 0:i.onUnified;return(k?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(P=>{var G;if(!h&&P){if(P.unified===!0){k==null||k();return}!t.includes(P.variantId)&&!P.content||(S({variantId:P.variantId,content:(G=P.content)!=null?G:null,isLoading:!1,settled:!0}),v(P.variantId))}}),()=>{h=!0}},[x,a,e,u]),Je(()=>{if(!x&&a)return nn(e,f=>{var _;let h=a.getAssignment(e,u);if(h&&(t.includes(h.variantId)||h.content)){S({variantId:h.variantId,content:(_=h.content)!=null?_:null,isLoading:!1,settled:!0}),v(h.variantId);return}let k=Ct(f.variants,t);k&&(S({variantId:k,content:null,isLoading:!1,settled:!0}),v(k))})},[x,a,e,u]),x?{variantId:x,content:null,isLoading:!1,settled:!0,isOverride:!0}:m}var Vn=new Set,Mn=new Map;function He(e,t,n,r){let i=r;if(r){let l=Mn.get(t);l&&l!==n?(D()&&console.warn(`[SentientUI] useGoal('${n}'): '${l}' is already primary on this page`),i=!1):Mn.set(t,n)}let o=`${t}|${n}|${i?"primary":""}`;Vn.has(o)||(Vn.add(o),e.track({projectId:t,componentId:"__session__",eventType:"goal_declared",payload:i?{goalId:n,primary:!0}:{goalId:n}}))}function Xe(e,t,n){let r=V(),i=ee(),o=Object.keys(t).join("\0"),l=jn(()=>Object.keys(t),[o]),{variantId:a,content:u,isOverride:s=!1,settled:y}=_t(e,l,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[c,b]=zr(null),x=Ne(null),g=Xr(d=>{x.current=d,b(d)},[]),m=n.goal,S=typeof m=="string"?m:JSON.stringify(m),v=jn(()=>m?Z(m):null,[S]),f=m?ue(m):"";fe(()=>$e({id:e,variantIds:l,goal:f}),[e,l,f]);let h=Ne(null);fe(()=>{s||y&&(!r||!a||!i||!c||h.current!==a&&(h.current=a,ce(r,i,e,a)))},[r,a,i,e,c,s,y]);let k=Ne(!1),_=Ne(new Set);fe(()=>{k.current=!1,_.current=new Set},[a,v]);let P=n.funnel;fe(()=>{s||!y||!r||!v||se(r,i,e,P,v)},[r,i,e,P,v,s,y]),fe(()=>{s||!y||!r||r.gated||!i||typeof m!="string"||!m||He(r,i,m,!1)},[r,i,m,s,y]);let G=n.cursorSignal===!0;fe(()=>{if(!G||s||!y||!r||!a||!c)return;let d=null,A=0,j=()=>{A=Date.now(),d=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-A}}),d=null},800)},w=()=>{d!==null&&(clearTimeout(d),d=null)};return c.addEventListener("mouseenter",j),c.addEventListener("mouseleave",w),()=>{c.removeEventListener("mouseenter",j),c.removeEventListener("mouseleave",w),d!==null&&clearTimeout(d)}},[G,r,a,i,e,c,s,y]);let R=Ne(n.microSignalGoals);R.current=n.microSignalGoals;let C=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return fe(()=>{if(s||!y||!r||!a||!c)return;let d=Date.now();return qr((A,j={})=>{var N,K,$;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:p({signalType:A},j)});let w=(N=R.current)==null?void 0:N[A];if(!w||_.current.has(A))return;_.current.add(A);let E=typeof w=="string"?w:w.name,L=typeof w=="string"?1:(K=w.weight)!=null?K:1,I=typeof w=="string"?0:($=w.stepIndex)!=null?$:0;r.goal(E,{metadata:p({signalType:A},j),weight:L,stepIndex:I})},c,d)},[r,a,i,e,c,C,s,y]),fe(()=>{if(s||!y||!r||!a||!c||!v)return;let d=ie(v);return oe(c,v,{fireGoal:()=>{k.current||(k.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:f,payload:p({reward:1},d!==void 0?{goalValue:d}:{})}),r.goal(f,p({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},d!==void 0?{value:d}:{})))},fireStep:(A,j,w)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:A,payload:{reward:j}}),r.goal(A,{metadata:{},weight:j,stepIndex:w})}},f)},[r,a,i,e,c,v,f,s,y]),{client:r,variantIds:l,variantId:a,content:u,settled:y,isOverride:s,goalLabel:f,ref:g,nodeRef:x}}import{useEffect as q,useMemo as et,useRef as Se,useState as fi,useSyncExternalStore as gi}from"react";import{attachMicroSignalDetectors as mi,containsFormBlock as nr,reveal as pi}from"@sentientui/core";import{captureRegionSkeleton as rr}from"@sentientui/core/region";import{useCallback as Yr,useEffect as $n,useRef as Ot,useSyncExternalStore as ze}from"react";import{armOfResult as Zr}from"@sentientui/core";var Bn=new Set,Qr={kind:"arms"};function Un(e,t){var _,P,G;let n=V(),r=Ot(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=Ot(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let o=Ot(t==null?void 0:t.skeleton);o.current=t==null?void 0:t.skeleton;let l=We(),a=In(),u=Dn(),s=Ln(),y=ze(Y,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_config_overrides)==null?void 0:R[e]:void 0},()=>{}),c=ze(Y,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_overrides)==null?void 0:R[e]:void 0},()=>{}),b=R=>R==null?"":Zr(R),x=Yr(R=>{var C,d;return(d=(C=n==null?void 0:n.onSlotsChanged)==null?void 0:C.call(n,R))!=null?d:(()=>{})},[n]);ze(x,()=>{var R;return(R=n==null?void 0:n.getSlotConfig(e))!=null?R:null},()=>null),ze(x,()=>b(n==null?void 0:n.getSlotResult(e)),()=>"");let g=y===void 0?a[e]:void 0,m=y===void 0&&g===void 0&&n?n.getSlotConfig(e):null,S=(_=u!=null?u:n==null?void 0:n.getSitePalette())!=null?_:null,v=(G=s!=null?s:(P=n==null?void 0:n.getStyleVocabulary)==null?void 0:P.call(n))!=null?G:null,f=(()=>{var R,C,d;if(y!==void 0)return{config:y,arm:b(c),palette:S,vocabulary:(R=vn())!=null?R:v,source:"override"};if(t!=null&&t.forcedArm)return{config:Qr,arm:t.forcedArm,palette:S,vocabulary:v,source:"override"};if(g!==void 0)return{config:g,arm:b((C=l[e])!=null?C:n==null?void 0:n.getSlotResult(e)),palette:S,vocabulary:v,source:"preloaded"};if(m!==null){let A=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:m,arm:b((d=n==null?void 0:n.getSlotResult(e))!=null?d:l[e]),palette:S,vocabulary:v,source:A?"client":"seeded"}}return{config:null,arm:"",palette:S,vocabulary:v,source:"none"}})(),h=(t==null?void 0:t.defer)===!0,k=f.source==="preloaded"||f.source==="override";return $n(()=>{var L,I,N,K,$;if(!n||n.isLocal===!0||k||h)return;let R=f.source==="none",C=R&&(I=(L=r.current)==null?void 0:L.call(r))!=null?I:null,d=C!=null&&C!==""?{[e]:C}:void 0,A=(N=i.current)==null?void 0:N.call(i),j=R&&($=(K=o.current)==null?void 0:K.call(o))!=null?$:null,w=p(p({},A?{render:{[e]:A}}:{}),j?{skeletons:{[e]:j}}:{}),E=Object.keys(w).length>0;return n.requestSlots?E?n.requestSlots([e],d,w):d?n.requestSlots([e],d):n.requestSlots([e]):R&&(j?n.reportSlots([e],d!=null?d:{},{[e]:j}):d?n.reportSlots([e],d):n.reportSlots([e])),()=>{var M;return(M=n.cancelSlots)==null?void 0:M.call(n,[e])}},[n,k,f.source,e,h]),$n(()=>{!D()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||Bn.has(e)||(Bn.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,f.source,e]),f}import{cloneElement as ei,Fragment as Kn}from"react";import{jsx as B,jsxs as Xn}from"react/jsx-runtime";function Gt(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var ge={none:"0",sm:"8px",md:"16px",lg:"24px"},Et={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},zn={sm:"0.875em",md:"1em",lg:"1.25em"},ti={sm:"1.25em",md:"1.5em",lg:"2em"},Wn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Jn={sm:"8px",md:"16px",lg:"32px"},ni={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},ri={normal:"400",medium:"500",bold:"700"};function Hn(e,t){return p(p({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?p({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function qn(e,t,n){var i,o,l,a;let r=t==null?void 0:t.accent;return F(p({display:"inline-block",padding:(i=Wn[n!=null?n:"md"])!=null?i:Wn.md,borderRadius:(o=t==null?void 0:t.radius)!=null?o:"8px",font:"inherit"},n?{fontSize:zn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(l=t==null?void 0:t.primaryBg)!=null?l:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function ii({node:e,opts:t}){var i,o,l,a,u;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(l=(o=t.palette)==null?void 0:o.border)!=null?l:"currentColor"}`,borderRadius:(u=(a=t.palette)==null?void 0:a.radius)!=null?u:"8px"};return Xn("form",{onSubmit:s=>{var b,x,g;s.preventDefault();let y=new FormData(s.currentTarget),c={};for(let m of e.fields)c[m.name]=String((b=y.get(m.name))!=null?b:"");(x=t.onFormGoal)==null||x.call(t,e.submitGoal);try{(g=t.onFormSubmit)==null||g.call(t,c)}catch(m){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var y,c;return Xn("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?B("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?B("select",{name:s.name,required:s.required,style:r,children:((y=s.options)!=null?y:[]).map(b=>B("option",{value:b,children:b},b))}):B("input",{name:s.name,type:(c=s.inputType)!=null?c:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),B("button",{type:"submit",style:qn(n,t.palette),children:e.submitLabel})]})}function oi(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(o=>o.id===n))==null?void 0:i.classes:void 0}function Yn(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 Re(e,t){var i;let n=si(e,t),r=Yn(e.like,t);return n&&r?ei(n,{style:F(p({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function si(e,t){var n,r,i,o,l,a,u,s,y,c,b,x,g,m,S,v,f,h,k,_,P,G,R;try{let C=oi(e,t);switch(e.type){case"stack":{let d=(r=ge[(n=e.gap)!=null?n:"md"])!=null?r:ge.md,A=e.surface==="raised"&&!C,j=(i=e.pad)!=null?i:A?"md":void 0;return B("div",F(p({},C?{className:C}:{}),{style:p(p(p(p(p({display:"flex",flexDirection:e.direction,gap:d},e.align?{alignItems:Et[e.align]}:{}),e.justify?{justifyContent:Et[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),j?{padding:(o=ge[j])!=null?o:ge.md}:{}),A?F(p(p({},(l=t.palette)!=null&&l.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((u=t.palette)!=null&&u.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(y=(s=t.palette)==null?void 0:s.border)!=null?y:"currentColor"}`,borderRadius:(b=(c=t.palette)==null?void 0:c.radius)!=null?b:"8px"}):{}),children:((x=e.children)!=null?x:[]).map((w,E)=>{let L=Re(w,t);return L===null?null:B(Kn,{children:L},E)})}))}case"grid":{let d=(m=ge[(g=e.gap)!=null?g:"md"])!=null?m:ge.md;return B("div",F(p({},C?{className:C}:{}),{style:p(p({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${d}) / ${e.columns})), 1fr))`,gap:d},e.align?{alignItems:Et[e.align]}:{}),e.pad?{padding:(S=ge[e.pad])!=null?S:ge.md}:{}),children:((v=e.children)!=null?v:[]).map((A,j)=>{let w=Re(A,t);return w===null?null:B(Kn,{children:w},j)})}))}case"text":return C?B("p",{className:C,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):B("p",{style:p(p(p(p(p({margin:0},e.size?{fontSize:zn[e.size]}:{}),e.weight?{fontWeight:ri[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Hn(e.tone,t.palette)),children:e.value});case"heading":{let d=`h${e.level}`;return C?B(d,{className:C,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):B(d,{style:p(p({margin:0,fontSize:ti[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let d=(h=e.emphasis)!=null?h:"primary";return B("a",F(p(p({href:Gt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),C?{className:C}:{style:qn(d,t.palette,e.size)}),{children:e.label}))}case"link":return B("a",F(p(p({href:Gt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),C?{className:C}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return B("img",F(p({src:Gt(e.src),alt:e.alt},C?{className:C}:{}),{style:p(p({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:ni[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return C?B("span",{className:C,children:e.value}):B("span",{style:p({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(_=(k=t.palette)==null?void 0:k.border)!=null?_:"currentColor"}`},Hn(e.tone,t.palette)),children:e.value});case"spacer":return B("div",{style:{height:(P=Jn[e.size])!=null?P:Jn.md}});case"divider":return B("hr",{style:{border:"none",borderTop:`1px solid ${(R=(G=t.palette)==null?void 0:G.border)!=null?R:"currentColor"}`,margin:0,width:"100%"}});case"form":return B(ii,{node:e,opts:t});default:return null}}catch(C){return null}}function Pt(e,t){var o,l,a,u;let n=Re(e.tree,t);if(n===null)return null;let r=(o=e.surface)!=null&&o.like?(a=(l=t.vocabulary)==null?void 0:l.entries.find(s=>s.id===e.surface.like))==null?void 0:a.classes:void 0,i=Yn((u=e.surface)==null?void 0:u.like,t);return r?B("div",F(p({className:r},i?{style:{color:i}}:{}),{children:n})):n}import{cloneElement as qe,isValidElement as Ye}from"react";import{normalizeLeafText as ai,skeletonFingerprint as li}from"@sentientui/core/region";function Ze(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function Qe(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ve(e){return Ze(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ve(n),0):Ye(e)?ve(Qe(e)):0}function ui(e,t){return Array.isArray(t)?qe(e,void 0,...t):qe(e,void 0,t)}function Nt(e,t){if(Ze(e))return t;if(Array.isArray(e))return e.map(n=>Nt(n,t));if(Ye(e)){let n=Qe(e);return ve(n)===0?e:ui(e,Nt(n,t))}return e}function Zn(e,t){return ve(e)===1?Nt(e,t):null}var Q=e=>e.join("/");function Tt(e,t,n){if(Ze(e)){n.leafPaths.push(t),n.texts.push(ai(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>Tt(r,[...t,i],n));return}Ye(e)&&(n.elements.set(Q(t),e),Tt(Qe(e),[...t,"c"],n))}function Dt(e){let t={leafPaths:[],texts:[],elements:new Map};return Tt(e,[],t),t}function ci(e){return Dt(e).texts}function Qn(e){let t=ci(e);return t.length===0?null:li(t)}function di(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function er(e,t){let n=t.reduce((i,o)=>Math.max(i,o+1),0),r=[];for(let i=0;i<n;i++){let o=t.flatMap((a,u)=>a===i?[di(e.leafPaths[u])]:[]);if(o.length===0){r.push(null);continue}let l=o[0];for(let a of o.slice(1)){let u=new Set(a.map(Q));l=l.filter(s=>u.has(Q(s)))}r.push(l.length>0?l[l.length-1]:null)}return r}function It(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 Lt(e,t){let n=Dt(t);if(n.texts.length!==e.leaves.length||n.texts.some((o,l)=>o!==e.leaves[l]))return null;let r=er(n,e.leafToNode),i=e.nodes.map((o,l)=>{let a=r[l],u=a?n.elements.get(Q(a)):void 0,s=!!u&&(typeof u.type=="string"||It(u)!==void 0);return F(p({},o),{restylable:s})});return F(p({},e),{nodes:i})}function tr(e,t,n){var g;let r=Dt(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((m,S)=>Math.max(m,S+1),0);for(let m of Object.keys(t.nodes))if(!/^\d+$/.test(m)||Number(m)>=i)return null;let o=er(r,n),l=new Map;n.forEach((m,S)=>{l.has(m)||l.set(m,S)});let a=new Map(r.leafPaths.map((m,S)=>[Q(m),S])),u=new Set,s=new Map,y=!1;for(let[m,S]of Object.entries(t.nodes)){let v=Number(m),f=o[v];if(S.hidden&&(f?u.add(Q(f)):y=!0),S.like!==void 0){let h=o[S.like],k=f?r.elements.get(Q(f)):void 0,_=h?It(r.elements.get(Q(h))):void 0;!f||_===void 0||It(k)===void 0?y=!0:s.set(Q(f),_)}}let c=new Map(Object.entries((g=t.order)!=null?g:{})),b=(m,S)=>{var v;if(Ze(m)){let f=a.get(Q(S));if(f===void 0)return m;let h=n[f],k=(v=t.nodes[String(h)])==null?void 0:v.text;return k===void 0?m:l.get(h)===f?k:""}if(Array.isArray(m)){let f=m.map((h,k)=>b(h,[...S,k]));for(let[h,k]of c){let _=k.map(R=>{let C=o[R];return!C||C.length!==S.length+1||Q(C.slice(0,-1))!==Q(S)?-1:C[C.length-1]});if(_.some(R=>R<0))continue;let P=[..._].sort((R,C)=>R-C),G=[...f];P.forEach((R,C)=>{f[R]=G[_[C]]}),c.delete(h)}return f}if(Ye(m)){let f=Q(S);if(u.has(f))return null;let h=Qe(m);if(ve(h)===0)return m;let k=b(h,[...S,"c"]),_=s.get(f),P=_!==void 0?{className:_}:void 0;return Array.isArray(k)?qe(m,P,...k):qe(m,P,k)}return m},x=b(e,[]);return y||c.size>0?null:x}import{jsx as yi}from"react/jsx-runtime";var ir=new Set,or=new Set,sr=new Set,tt="authored.";function Te({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:o,as:l="div",reportBaselineText:a=!0,funnel:u,microSignalGoals:s,clientOnly:y,agentDataByVariant:c,agentData:b,variantsOnly:x=!1}){var Ht,Xt;let g=V(),m=ee(),S=Se(null),[v,f]=fi(!1);q(()=>{f(!0)},[]);let h=y===!0&&(!v||!g),k=et(()=>Qn(t),[t]),_=n?Object.keys(n).join("|"):"",P=et(()=>p({fp:k!=null?k:"0000000000000000",forms:!!r,compose:!0,content:ve(t)===1,ops:!1},_!==""?{authored:_.split("|"),children:!x}:{}),[k,t,r,_,x]),G=()=>{var H;let O=S.current;if(!O||!a)return null;let T=rr(O);return T.skeleton?(H=Lt(T.skeleton,t))!=null?H:F(p({},T.skeleton),{editable:!1,nodes:T.skeleton.nodes.map(U=>F(p({},U),{restylable:!1}))}):{status:T.reason}},R=gi(Y,()=>n?de(e):null,()=>null),C=R===null||!n?null:Object.prototype.hasOwnProperty.call(n,R)?`${tt}${R}`:x?`${tt}${Object.keys(n)[0]}`:"baseline",{config:d,arm:A,palette:j,vocabulary:w,source:E}=Un(e,{forcedArm:C,baselineText:a?()=>{var O,T;return(T=(O=S.current)==null?void 0:O.textContent)!=null?T:null}:void 0,render:()=>P,skeleton:G,defer:h}),L=A!==""?(Ht=d==null?void 0:d.blocks)==null?void 0:Ht[A]:void 0,I=A!==""?(Xt=d==null?void 0:d.compose)==null?void 0:Xt[A]:void 0,N=(L!==void 0&&nr(L)||I!==void 0&&nr(I.tree))&&!r;q(()=>{!N||!D()||ir.has(e)||(ir.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.`))},[N,e]);let K=O=>{!g||E==="override"||(E!=="seeded"&&g.componentGoal(e,O),g.goal(O,{metadata:{componentId:e,arm:A},weight:1,stepIndex:0}))},$=t,M=!1,J=A.startsWith(tt)?A.slice(tt.length):null;if((d==null?void 0:d.blocked)==="variant_history")M=!0;else if(J!==null)n&&Object.prototype.hasOwnProperty.call(n,J)?$=n[J]:M=!0;else if(I!==void 0){let O=N?null:Pt(I,{palette:j,vocabulary:w,onFormSubmit:r,onFormGoal:K});O===null?M=!0:$=O}else if(L!==void 0){let O=N?null:Re(L,{palette:j,vocabulary:w,onFormSubmit:r,onFormGoal:K});O===null?M=!0:$=O}else if((d==null?void 0:d.edits)!==void 0&&E!=="none"){let O=d.edits,T=O.fp===k?tr(t,O.edits,O.leafToNode):null;T===null?M=!0:$=T}else if((d==null?void 0:d.content)!==void 0&&E!=="none"){let O=Zn(t,d.content);O===null?M=!0:$=O}let Ce=M&&L===void 0&&I===void 0&&(d==null?void 0:d.edits)===void 0&&J===null&&(d==null?void 0:d.blocked)===void 0;q(()=>{(d==null?void 0:d.blocked)!=="variant_history"||!D()||sr.has(e)||(sr.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 W=J!==null&&!M?J:null;q(()=>{var re;if(!W||!a||!g)return;let O=S.current;if(!O)return;let T=rr(O),H=T.skeleton?Lt(T.skeleton,n==null?void 0:n[W]):null,U=(re=O.textContent)==null?void 0:re.trim();g.reportSlots([],void 0,void 0,{[e]:[p(p({key:W},U?{text:U}:{}),H?{skeleton:H}:{})]})},[W,g,e,h]);let ne=M&&(d==null?void 0:d.edits)!==void 0&&(E==="preloaded"||E==="client");q(()=>{var O;!ne||!(d!=null&&d.edits)||(O=g==null?void 0:g.reportDrift)==null||O.call(g,e,d.edits.fp,k,d.edits.fp===k?"unaddressable":"fp_mismatch")},[ne,e,k,g]);let _e=$===t;q(()=>{var T;if(!(d!=null&&d.needsSkeleton)||!_e)return;let O=G();O&&((T=g==null?void 0:g.reportSkeleton)==null||T.call(g,e,O))},[d==null?void 0:d.needsSkeleton,_e,e,g,h]),q(()=>{if(!_e)return;let O=kn(e);if(!O)return;let T=G();Rn(O,T&&"status"in T?{status:T.status}:{skeleton:T})},[e,_e,h]),q(()=>{!Ce||!D()||or.has(e)||(or.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.`))},[Ce,e]);let at=d!=null&&d.blocks?Object.keys(d.blocks).sort().join("|"):"",lt=n?[...x?[]:["baseline"],..._.split("|")].join("|"):"";q(()=>lt!==""?$e({id:e,variantIds:lt.split("|")}):he({id:e,arms:at===""?void 0:at.split("|")}),[e,at,lt]);let $t=Se(null);q(()=>{!g||E==="none"||E==="seeded"||E==="override"||A===""||M||$t.current!==A&&($t.current=A,ce(g,m,e,A))},[g,m,e,A,E,M]);let le=E!=="none"&&E!=="seeded"&&!M,ut=le?A:"",Bt=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);q(()=>{if(!g||!i||E==="override")return;let O=S.current;if(!O)return;let T=ue(i),H=ie(i),U=!1;return oe(O,Z(i),{fireGoal:()=>{U||(U=!0,le&&(H!==void 0?g.componentGoal(e,T,{value:H}):g.componentGoal(e,T)),g.goal(T,p({metadata:{componentId:e,arm:ut},weight:1,stepIndex:0},H!==void 0?{value:H}:{})))},fireStep:(re,Ve,dt)=>{le&&g.componentGoal(e,re,{reward:Ve}),g.goal(re,{metadata:{componentId:e,arm:ut},weight:Ve,stepIndex:dt})}},T)},[g,e,Bt,A,E,M,le,ut,h]);let ct=et(()=>i?Z(i):null,[Bt]);q(()=>{E==="override"||!g||!ct||se(g,m,e,u,ct)},[g,m,e,u,ct,E]);let Ut=Se(s);Ut.current=s;let Kt=Se(new Set),br=s?JSON.stringify(s):"";q(()=>{if(!g||E==="override"||!le||A==="")return;let O=S.current;if(O)return mi((T,H={})=>{var zt,qt,Yt;g.track({projectId:m,componentId:e,variantId:A,eventType:"micro_signal",payload:p({signalType:T},H)});let U=(zt=Ut.current)==null?void 0:zt[T];if(!U||Kt.current.has(T))return;Kt.current.add(T);let re=typeof U=="string"?U:U.name,Ve=typeof U=="string"?1:(qt=U.weight)!=null?qt:1,dt=typeof U=="string"?0:(Yt=U.stepIndex)!=null?Yt:0;g.goal(re,{metadata:p({componentId:e,arm:A,signalType:T},H),weight:Ve,stepIndex:dt})},O,Date.now())},[g,m,e,A,E,le,br,h]);let Wt=Se({agentData:b,agentDataByVariant:c});Wt.current={agentData:b,agentDataByVariant:c};let Jt=Se(null);q(()=>{var re;if(!g||E==="override"||!le||A===""||Jt.current===A)return;let{agentData:O,agentDataByVariant:T}=Wt.current,H=J!=null?J:A,U=T!==void 0?Object.prototype.hasOwnProperty.call(T,H)?T[H]:void 0:O;U!==void 0&&(Jt.current=A,(re=g.reportAgentData)==null||re.call(g,e,A,U))},[g,e,A,le,J,E]);let Fe=Se(null);q(()=>{let O=S.current;if(O){if(Fe.current===null){Fe.current=A;return}Fe.current!==A&&(Fe.current=A,pi(O))}},[A,h]);let wr=et(()=>p({"data-sentient-slot":e},A!==""?{"data-sentient-arm":A}:{}),[e,A]);return h?null:yi(l,F(p({ref:S,className:o},wr),{children:$}))}import{jsx as Ae}from"react/jsx-runtime";function bi(e){var y,c;let{client:t,variantId:n,content:r,ref:i}=Xe(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[o,l]=ar(!1);hi(()=>{l(!0)},[]);let a=(y=e.as)!=null?y:"div";if(e.clientOnly&&(!o||!t)||!n)return null;let u=(c=e.variants[n])!=null?c:null,s=u===null?r:null;return D()&&u===null&&s===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.`),Ae(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:u!=null?u:s})}var wi=vi(bi,(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.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)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 xi(e){if(e.variants===void 0)return Ae(Te,p({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=Oe(n,["variants"]);return Ae(Te,F(p({},i),{children:t.children,variants:r}))}return Ae(ki,p({},t))}function ki(e){var c;let[t,n]=ar(null),{id:r}=e,i=Si(()=>n(r),[r]),o=V(),l=Ue().includes(r)||((c=o==null?void 0:o.isUnified)==null?void 0:c.call(o,r))===!0;if(t!==r&&!l)return Ae(wi,F(p({},e),{onUnified:i}));let b=e,{variants:a,children:u}=b,s=Oe(b,["variants","children"]),y=Object.keys(a)[0];return Ae(Te,F(p({},s),{variants:a,variantsOnly:!0,children:y!==void 0?a[y]:null}))}import{useEffect as Ie,useMemo as Ri,useRef as Ft,useState as lr,useSyncExternalStore as Ai}from"react";import{jsx as _i}from"react/jsx-runtime";function Ci({id:e,default:t,component:n="span",className:r,goal:i}){var P;let o=V(),l=ee(),a=Ke(),u=Pe(),s=Ft(null),y=Ft(null),c=Ai(Y,()=>de(e),()=>null),[b,x]=lr(()=>{var G,R;return(R=(G=o==null?void 0:o.getAssignment(e,u))==null?void 0:G.content)!=null?R:null}),[g,m]=lr(()=>{var G,R;return(R=(G=o==null?void 0:o.getAssignment(e,u))==null?void 0:G.variantId)!=null?R:null});Ie(()=>{if(c||!o)return;let G=o.getAssignment(e,u);if((G==null?void 0:G.content)!==void 0){m(G.variantId),x(G.content);return}let R=!1;return o.assign(e).then(C=>{if(!R){if(!C){D()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}m(C.variantId),C.content&&x(C.content)}}),()=>{R=!0}},[o,e,u,c]),Ie(()=>{c||!o||!g||!l||s.current!==g&&(s.current=g,o.track({projectId:l,componentId:e,variantId:g,eventType:"variant_assigned",payload:{}}),a==null||a(e,g))},[o,g,l,e,a,c]);let S=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=Ri(()=>i===void 0?null:Z(i),[S]),f=i===void 0?null:typeof i=="string"?i:v.type,h=Ft(!1);Ie(()=>{h.current=!1},[g,S]),Ie(()=>{c||!o||!l||se(o,l,e,void 0,v)},[o,l,e,v,c]),Ie(()=>{if(c||!o||!g||!l||!v||!f)return;let G=y.current;if(!G)return;let R=ie(v);return oe(G,v,{fireGoal:()=>{h.current||(h.current=!0,o.track({projectId:l,componentId:e,variantId:g,eventType:"goal_achieved",goalType:f,payload:p({reward:1},R!==void 0?{goalValue:R}:{})}),o.goal(f,p({metadata:{componentId:e,variantId:g},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(C,d,A)=>{o.track({projectId:l,componentId:e,variantId:g,eventType:"goal_achieved",goalType:C,payload:{reward:d}}),o.goal(C,{metadata:{},weight:d,stepIndex:A})}})},[o,g,l,e,v,f,c]);let k=b!=null?b:t;if(c){let G=o==null?void 0:o.getAssignment(e,u);k=G&&G.variantId===c&&(P=G.content)!=null?P:t}return _i(n,{ref:G=>{y.current=G},className:r,children:k})}import{useCallback as Oi,useRef as Gi}from"react";function De(e){var t,n;return p(p(p({metadata:(t=e==null?void 0:e.metadata)!=null?t:{},weight:(n=e==null?void 0:e.reward)!=null?n:1,stepIndex:0},(e==null?void 0:e.value)!==void 0?{value:e.value}:{}),(e==null?void 0:e.currency)!==void 0?{currency:e.currency}:{}),(e==null?void 0:e.externalId)!==void 0?{externalId:e.externalId}:{})}function Le(e){let t=V(),n=Gi(new Set);return Oi((r,i)=>{if(!de(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,De(i))}},[t,e])}import{useEffect as Ei,useRef as ur}from"react";function Pi(e,t={}){let u=t,{componentId:n}=u,r=Oe(u,["componentId"]),i=V(),o=Le(n!=null?n:""),l=ur(!1),a=ur(r);a.current=r,Ei(()=>{if(!(!i||l.current||i.gated)){if(l.current=!0,n){o(e,a.current);return}i.goal(e,De(a.current))}},[i,n,e,o])}import{useCallback as Ni,useEffect as Ti,useRef as Ii}from"react";function Di(e,t={}){let{primary:n=!1,componentId:r}=t,i=V(),o=ee(),l=Le(r!=null?r:""),a=Ii(!1);return Ti(()=>{!i||i.gated||!o||He(i,o,e,n)},[i,o,e,n]),Ni(u=>{if(u!=null&&u.once){if(a.current)return;a.current=!0}if(r){l(e,u);return}i==null||i.goal(e,De(u))},[i,r,l,e])}import{renderPrePaintScript as Li}from"@sentientui/core";import{confidenceBand as Fi}from"@sentientui/policy";import{jsx as ji}from"react/jsx-runtime";function Vt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Vi(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Vt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Vt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Vt(Fi(e.persona.confidence))+");}catch(e){}})();":Li(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function Mi(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:ji("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Vi(e)}})}import{useEffect as it,useMemo as jt,useRef as Hi}from"react";import{validateSlotDecl as Xi}from"@sentientui/policy";import{useEffect as Mt,useReducer as $i,useState as Bi,useSyncExternalStore as cr}from"react";import{armOfResult as nt,baselineResultFor as Ui}from"@sentientui/core";import{confidenceBand as Ki}from"@sentientui/policy";function rt(e,t){let n=V(),r=We(),[,i]=$i(c=>c+1,0),o=cr(Y,()=>{var c;return typeof window!="undefined"?(c=window.__sentient_slot_overrides)==null?void 0:c[e]:void 0},()=>{}),l=o===void 0?r[e]:void 0,a=o===void 0&&l===void 0&&n?n.getSlotResult(e):null,u=(n==null?void 0:n.isLocal)===!0&&o===void 0&&l===void 0&&a===null;Mt(()=>{if(!u||!n)return;let c=!1;return n.decide({slots:[t]}).then(b=>{!c&&b&&i()}),()=>{c=!0}},[n,e,u]);let s=(()=>{if(o!==void 0)return{result:o,arm:nt(o),source:"override"};if(l!==void 0)return{result:l,arm:nt(l),source:"preloaded"};if(a!==null){let b=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:nt(a),source:b?"client":"seeded"}}let c=Ui(t);return{result:c,arm:nt(c),source:"baseline"}})(),y=s.source==="preloaded"||s.source==="override";return Mt(()=>{var b;if(!n||n.isLocal===!0||y||!n.decideSlots)return;let c=(b=n.onSlotsChanged)==null?void 0:b.call(n,i);return n.decideSlots([t]),()=>{var x;(x=n.cancelSlots)==null||x.call(n,[e]),c==null||c()}},[n,e,y]),s}function Wi(){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 Ji(){let e=V(),t=Tn();cr(Y,ln,()=>0);let[n,r]=Bi(!1);Mt(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:Ki(a.confidence)});if(!n)return t?i(t):null;let o=Wi();if(o)return i(o);if(t)return i(t);let l=e?e.getPersona():null;return l?i(l):null}var dr=new Set;function zi(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function qi(e,t,n){let r=V(),i=ee(),o=JSON.stringify(t),l=jt(()=>({id:e,dims:t}),[e,o]),{result:a,arm:u,source:s}=rt(e,l),y=jt(()=>typeof a=="string"?{}:a,[u]);if(D()&&!dr.has(e)){dr.add(e);let m=Xi({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,f])=>[v,[...f]]))}),S=Object.values(t).reduce((v,f)=>v*f.length,1);m.ok?S>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${S} 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 ${m.reason}. Serving baseline.`)}let c=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);it(()=>he({id:e,dims:t}),[e]);let b=Hi(null);it(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||b.current===u||(b.current=u,ce(r,i,e,u))},[r,i,e,u,s]);let x=n==null?void 0:n.funnel;it(()=>{var m;!r||s==="override"||se(r,i,e,x,Z((m=n==null?void 0:n.goal)!=null?m:"click"))},[r,i,e,x,c,s]),it(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let m=document.querySelector(`[data-sentient-slot="${zi(e)}"]`);if(!m){D()&&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 S=ue(n.goal),v=ie(n.goal),f=!1;return oe(m,Z(n.goal),{fireGoal:()=>{f||(f=!0,v!==void 0?r.componentGoal(e,S,{value:v}):r.componentGoal(e,S),r.goal(S,p({metadata:{componentId:e,arm:u},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(h,k,_)=>{r.componentGoal(e,h,{reward:k}),r.goal(h,{metadata:{componentId:e,arm:u},weight:k,stepIndex:_})}},S)},[r,e,c,u,s]);let g=jt(()=>{let m={"data-sentient-slot":e};for(let[S,v]of Object.entries(y))m[`data-${S}`]=v;return m},[e,y]);return{tokens:y,props:g}}import{useCallback as Yi,useEffect as fr,useMemo as Zi}from"react";var gr=new Set,mr=new Set;function Qi(e,t){var g,m;if(D()&&!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:o,goalLabel:l,ref:a,nodeRef:u}=Xe(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(g=i!=null?i:r[0])!=null?g:"",y=t.variants[s],c=Ue().includes(e)||((m=n==null?void 0:n.isUnified)==null?void 0:m.call(n,e))===!0;fr(()=>{!c||!D()||mr.has(e)||(mr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[c,e]),fr(()=>{if(!D()||!n)return;let S=setTimeout(()=>{!u.current&&!gr.has(e)&&(gr.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(S)},[n,e]);let b=Yi((S,v)=>{var h,k;if(o)return;let f=S!=null?S:l;f&&(n==null||n.componentGoal(e,f,v),n==null||n.goal(f,p(p(p({metadata:(h=v==null?void 0:v.metadata)!=null?h:{},weight:(k=v==null?void 0:v.reward)!=null?k:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,l,o]),x=Zi(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":s}),[a,e,s]);return{variant:s,value:y,bind:x,fireGoal:b}}import{Children as eo,isValidElement as to,useEffect as ot,useMemo as pr,useRef as yr}from"react";import{jsx as ro}from"react/jsx-runtime";var st=new Set;function no(e){var f;let t=V(),n=ee(),r=yr(null),i=Object.keys(e.arrangements).join(" "),o=pr(()=>Object.keys(e.arrangements),[i]),l=pr(()=>p({id:e.id,arms:o},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,o,e.baseline]),{arm:a,source:u}=rt(e.id,l);D()&&e.baseline!==void 0&&e.baseline!==o[0]&&!st.has(e.id+":baseline")&&(st.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${o[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=eo.toArray(e.children).filter(to),y=new Map;for(let h of s)y.set(String((f=h.key)!=null?f:"").replace(/^\.\$/,""),h);let c=e.arrangements[a],b=c!==void 0&&c.length===s.length&&c.every(h=>y.has(h));D()&&c!==void 0&&!b&&!st.has(e.id+":keys")&&(st.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${c.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let x=b?c.map(h=>y.get(h)):s;ot(()=>he({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let g=yr(null);ot(()=>{!t||u==="baseline"||u==="seeded"||u==="override"||g.current===a||(g.current=a,ce(t,n,e.id,a))},[t,n,e.id,a,u]);let m=e.funnel,S=e.goal===void 0||typeof e.goal=="string"?"":JSON.stringify(e.goal);ot(()=>{var h;!t||u==="override"||se(t,n,e.id,m,Z((h=e.goal)!=null?h:"click"))},[t,n,e.id,m,S,u]);let v=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return ot(()=>{if(!t||e.goal===void 0||u==="override"||u==="baseline"||u==="seeded")return;let h=r.current;if(!h)return;let k=ue(e.goal),_=ie(e.goal),P=!1;return oe(h,Z(e.goal),{fireGoal:()=>{P||(P=!0,_!==void 0?t.componentGoal(e.id,k,{value:_}):t.componentGoal(e.id,k),t.goal(k,p({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},_!==void 0?{value:_}:{})))},fireStep:(G,R,C)=>{t.componentGoal(e.id,G,{reward:R}),t.goal(G,{metadata:{componentId:e.id,arm:a},weight:R,stepIndex:C})}},k)},[t,e.id,v,a,u]),ro("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:x})}import{deriveSessionSegment as io}from"@sentientui/core";var oo=["page","blocks","layoutOrder"],vr=new Map;function so(e,t){vr.set(e,t)}function Sr(e){return vr.get(e)}function ao(e){var i,o;let t=(o=(i=e.content)!=null?i:Sr(e.page))!=null?o:{},n={};for(let[l,a]of Object.entries(t))oo.includes(l)||(n[l]=a);let r=F(p({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function lo(e){return`<script type="application/ld+json">${hr(e)}</script>`}function hr(e){return JSON.stringify(p({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function uo(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
|
|
4
|
+
`}import{grantConsent as xl}from"@sentientui/core";import{consentWatcher as Al}from"@sentientui/core/consent";export{xi as Adaptive,no as AdaptiveGroup,$r as AdaptiveProvider,Te as AdaptiveSlot,Ci as AdaptiveText,Mi as SentientPersonaScript,ao as buildAgentFeed,Al as consentWatcher,so as defineAgentContent,io as detectSegment,Sr as getAgentContent,xl as grantConsent,lo as renderAgentJsonLd,hr as renderAgentJsonLdBody,uo as renderAgentMarkdown,Re as renderBlocks,Pt as renderCompose,Qi as useAdaptive,Kr as useAdaptiveApiBaseUrl,Le as useAdaptiveGoal,Ji as useAdaptivePersona,qi as useAdaptiveTokens,_t as useAssignment,Di as useGoal,At as useInitialAssignments,Ur as useLayoutOrder,Pi as usePageGoal,V as useSentient,Pe as useSessionSegment};
|
|
5
5
|
//# sourceMappingURL=index.mjs.map
|