@sentientui/react 0.35.3 → 0.36.0

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