@sentientui/react 0.34.4 → 0.35.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 +23 -16
- package/dist/index.d.ts +23 -16
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/next/adaptive-root.d.ts +4 -1
- package/dist/testing/react.js +1 -1
- package/dist/testing/react.js.map +1 -1
- package/dist/testing/react.mjs +1 -1
- package/dist/testing/react.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode, JSX } from 'react';
|
|
2
|
-
import { SentientConfig, SlotResult, SlotConfigEntry, SitePalette, SentientClient, MicroSignalType, ComponentGoalOptions, BlockNode } from '@sentientui/core';
|
|
2
|
+
import { SentientConfig, 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';
|
|
@@ -139,6 +139,9 @@ type AdaptiveProviderProps = {
|
|
|
139
139
|
/** SSR-preloaded site palette (`palette` field of `loadAdaptiveDecision()`'s
|
|
140
140
|
* registry-mode result) for block rendering. */
|
|
141
141
|
initialPalette?: SitePalette;
|
|
142
|
+
/** SSR-preloaded site styles (`vocabulary` field of `loadAdaptiveDecision()`'s
|
|
143
|
+
* registry-mode result) that served Redesign arms borrow. */
|
|
144
|
+
initialVocabulary?: StyleVocabulary;
|
|
142
145
|
/**
|
|
143
146
|
* Persona decided during SSR (`persona` + `confidence` fields of
|
|
144
147
|
* `loadAdaptiveDecision()`'s result). Adopted by the core client;
|
|
@@ -269,6 +272,10 @@ type AdaptiveSlotProps = {
|
|
|
269
272
|
id: string;
|
|
270
273
|
/** Baseline JSX — holdout, unknown personas, empty cells, every error path. */
|
|
271
274
|
children: ReactNode;
|
|
275
|
+
/** Hand-written versions (a hybrid <Adaptive>): each key is an arm the
|
|
276
|
+
* server may draw alongside your original and the generated versions, in
|
|
277
|
+
* one experiment (spec 2026-09-23 §7). */
|
|
278
|
+
variants?: Record<string, ReactNode>;
|
|
272
279
|
/** Receives form values when a generated form arm submits. Without it, form
|
|
273
280
|
* arms fall back to children entirely. Values never reach Sentient. */
|
|
274
281
|
onFormSubmit?: (values: Record<string, string>) => void;
|
|
@@ -282,24 +289,17 @@ type AdaptiveSlotProps = {
|
|
|
282
289
|
* the text of THIS region is all that is ever read, never the page. */
|
|
283
290
|
reportBaselineText?: boolean;
|
|
284
291
|
};
|
|
285
|
-
|
|
286
|
-
* @deprecated Use `<Adaptive id="…">{children}</Adaptive>` — `<Adaptive>`
|
|
287
|
-
* without `variants` is this component. Kept exported because the package is
|
|
288
|
-
* published; it will not be removed in a minor release.
|
|
289
|
-
*
|
|
290
|
-
* A region whose content the server may replace with a named arm — a copy
|
|
291
|
-
* string or a validated Composition Block tree (registry slot config). The
|
|
292
|
-
* children are the founder's baseline: they render untouched for holdout
|
|
293
|
-
* traffic, unserved slots, and every error path, so the worst case is always
|
|
294
|
-
* "nothing changed" (spec 2026-09-08 empty-cell-generation §3).
|
|
295
|
-
*/
|
|
296
|
-
declare function AdaptiveSlot({ id, children, onFormSubmit, goal, className, reportBaselineText, }: AdaptiveSlotProps): JSX.Element;
|
|
292
|
+
declare function AdaptiveSlot({ id, children, variants, onFormSubmit, goal, className, reportBaselineText, }: AdaptiveSlotProps): JSX.Element;
|
|
297
293
|
|
|
298
294
|
/** `<Adaptive>` with variants written in code — each key an arm, first key the control. */
|
|
299
295
|
type AdaptiveVariantsProps = {
|
|
300
296
|
id: string;
|
|
301
297
|
variants: Record<string, ReactNode>;
|
|
302
|
-
children
|
|
298
|
+
/** Your original. With `variants` AND children the component is a hybrid:
|
|
299
|
+
* your hand-written versions, your original and dashboard-generated
|
|
300
|
+
* versions compete in one experiment (spec 2026-09-23 §7). Without
|
|
301
|
+
* children, `variants` keeps the variants-only experiment it always had. */
|
|
302
|
+
children?: ReactNode;
|
|
303
303
|
goal: string | GoalConfig;
|
|
304
304
|
/**
|
|
305
305
|
* Funnel this component serves (stable funnel id, e.g. "checkout" —
|
|
@@ -724,12 +724,19 @@ declare function renderAgentMarkdown(feed: AgentFeed): string;
|
|
|
724
724
|
|
|
725
725
|
type RenderBlocksOptions = {
|
|
726
726
|
palette: SitePalette | null;
|
|
727
|
+
/** The site styles a Redesign tree borrows (native generation phase 2). */
|
|
728
|
+
vocabulary?: StyleVocabulary | null;
|
|
727
729
|
/** Absent handler = form trees must not reach this function (AdaptiveSlot gates). */
|
|
728
730
|
onFormSubmit?: (values: Record<string, string>) => void;
|
|
729
731
|
/** Fired with the form's submitGoal when a rendered form submits. */
|
|
730
732
|
onFormGoal?: (goal: string) => void;
|
|
731
733
|
};
|
|
732
|
-
/** Render one validated block tree as JSX. Null for anything unrenderable — fail-safe. */
|
|
733
734
|
declare function renderBlocks(node: BlockNode, opts: RenderBlocksOptions): JSX.Element | null;
|
|
735
|
+
/**
|
|
736
|
+
* A Redesign (compose) arm: the tree, painted on a site section/card surface
|
|
737
|
+
* when its style resolves. Null when the tree's root can't render (a newer
|
|
738
|
+
* server's node type) — the caller treats that like a blocked blocks arm.
|
|
739
|
+
*/
|
|
740
|
+
declare function renderCompose(compose: ComposeArm, opts: RenderBlocksOptions): JSX.Element | null;
|
|
734
741
|
|
|
735
|
-
export { Adaptive, type AdaptiveGeneratedProps, AdaptiveGroup, type AdaptiveGroupProps, type AdaptivePersona, type AdaptiveProps, AdaptiveProvider, type AdaptiveProviderProps, AdaptiveSlot, type AdaptiveSlotProps, AdaptiveText, type AdaptiveTextProps, type AdaptiveVariantsProps, type AgentBlock, type AgentFeed, type AssignmentState, type ClickGoal, type ComponentWeights, type CompositeGoal, type FireGoal, type FormSubmitGoal, type GoalConfig, type MicroSignalGoalConfig, type MicroSignalGoals, type PageGoalOptions, type RenderBlocksOptions, type ScrollDepthGoal, SentientPersonaScript, type SentientPersonaScriptProps, type SsrFallback, type UseAdaptiveBind, type UseAdaptiveResult, type UseAdaptiveTokensOptions, type UseAdaptiveTokensResult, type VariantWeight, type WeightedCompositeGoal, type WeightedStep, buildAgentFeed, defineAgentContent, getAgentContent, renderAgentJsonLd, renderAgentJsonLdBody, renderAgentMarkdown, renderBlocks, useAdaptive, useAdaptiveApiBaseUrl, useAdaptiveGoal, useAdaptivePersona, useAdaptiveTokens, useAssignment, useInitialAssignments, useLayoutOrder, usePageGoal, useSentient };
|
|
742
|
+
export { Adaptive, type AdaptiveGeneratedProps, AdaptiveGroup, type AdaptiveGroupProps, type AdaptivePersona, type AdaptiveProps, AdaptiveProvider, type AdaptiveProviderProps, AdaptiveSlot, type AdaptiveSlotProps, AdaptiveText, type AdaptiveTextProps, type AdaptiveVariantsProps, type AgentBlock, type AgentFeed, type AssignmentState, type ClickGoal, type ComponentWeights, type CompositeGoal, type FireGoal, type FormSubmitGoal, type GoalConfig, type MicroSignalGoalConfig, type MicroSignalGoals, type PageGoalOptions, type RenderBlocksOptions, type ScrollDepthGoal, SentientPersonaScript, type SentientPersonaScriptProps, type SsrFallback, type UseAdaptiveBind, type UseAdaptiveResult, type UseAdaptiveTokensOptions, type UseAdaptiveTokensResult, type VariantWeight, type WeightedCompositeGoal, type WeightedStep, buildAgentFeed, defineAgentContent, getAgentContent, renderAgentJsonLd, renderAgentJsonLdBody, renderAgentMarkdown, renderBlocks, renderCompose, useAdaptive, useAdaptiveApiBaseUrl, useAdaptiveGoal, useAdaptivePersona, useAdaptiveTokens, useAssignment, useInitialAssignments, useLayoutOrder, usePageGoal, useSentient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode, JSX } from 'react';
|
|
2
|
-
import { SentientConfig, SlotResult, SlotConfigEntry, SitePalette, SentientClient, MicroSignalType, ComponentGoalOptions, BlockNode } from '@sentientui/core';
|
|
2
|
+
import { SentientConfig, 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';
|
|
@@ -139,6 +139,9 @@ type AdaptiveProviderProps = {
|
|
|
139
139
|
/** SSR-preloaded site palette (`palette` field of `loadAdaptiveDecision()`'s
|
|
140
140
|
* registry-mode result) for block rendering. */
|
|
141
141
|
initialPalette?: SitePalette;
|
|
142
|
+
/** SSR-preloaded site styles (`vocabulary` field of `loadAdaptiveDecision()`'s
|
|
143
|
+
* registry-mode result) that served Redesign arms borrow. */
|
|
144
|
+
initialVocabulary?: StyleVocabulary;
|
|
142
145
|
/**
|
|
143
146
|
* Persona decided during SSR (`persona` + `confidence` fields of
|
|
144
147
|
* `loadAdaptiveDecision()`'s result). Adopted by the core client;
|
|
@@ -269,6 +272,10 @@ type AdaptiveSlotProps = {
|
|
|
269
272
|
id: string;
|
|
270
273
|
/** Baseline JSX — holdout, unknown personas, empty cells, every error path. */
|
|
271
274
|
children: ReactNode;
|
|
275
|
+
/** Hand-written versions (a hybrid <Adaptive>): each key is an arm the
|
|
276
|
+
* server may draw alongside your original and the generated versions, in
|
|
277
|
+
* one experiment (spec 2026-09-23 §7). */
|
|
278
|
+
variants?: Record<string, ReactNode>;
|
|
272
279
|
/** Receives form values when a generated form arm submits. Without it, form
|
|
273
280
|
* arms fall back to children entirely. Values never reach Sentient. */
|
|
274
281
|
onFormSubmit?: (values: Record<string, string>) => void;
|
|
@@ -282,24 +289,17 @@ type AdaptiveSlotProps = {
|
|
|
282
289
|
* the text of THIS region is all that is ever read, never the page. */
|
|
283
290
|
reportBaselineText?: boolean;
|
|
284
291
|
};
|
|
285
|
-
|
|
286
|
-
* @deprecated Use `<Adaptive id="…">{children}</Adaptive>` — `<Adaptive>`
|
|
287
|
-
* without `variants` is this component. Kept exported because the package is
|
|
288
|
-
* published; it will not be removed in a minor release.
|
|
289
|
-
*
|
|
290
|
-
* A region whose content the server may replace with a named arm — a copy
|
|
291
|
-
* string or a validated Composition Block tree (registry slot config). The
|
|
292
|
-
* children are the founder's baseline: they render untouched for holdout
|
|
293
|
-
* traffic, unserved slots, and every error path, so the worst case is always
|
|
294
|
-
* "nothing changed" (spec 2026-09-08 empty-cell-generation §3).
|
|
295
|
-
*/
|
|
296
|
-
declare function AdaptiveSlot({ id, children, onFormSubmit, goal, className, reportBaselineText, }: AdaptiveSlotProps): JSX.Element;
|
|
292
|
+
declare function AdaptiveSlot({ id, children, variants, onFormSubmit, goal, className, reportBaselineText, }: AdaptiveSlotProps): JSX.Element;
|
|
297
293
|
|
|
298
294
|
/** `<Adaptive>` with variants written in code — each key an arm, first key the control. */
|
|
299
295
|
type AdaptiveVariantsProps = {
|
|
300
296
|
id: string;
|
|
301
297
|
variants: Record<string, ReactNode>;
|
|
302
|
-
children
|
|
298
|
+
/** Your original. With `variants` AND children the component is a hybrid:
|
|
299
|
+
* your hand-written versions, your original and dashboard-generated
|
|
300
|
+
* versions compete in one experiment (spec 2026-09-23 §7). Without
|
|
301
|
+
* children, `variants` keeps the variants-only experiment it always had. */
|
|
302
|
+
children?: ReactNode;
|
|
303
303
|
goal: string | GoalConfig;
|
|
304
304
|
/**
|
|
305
305
|
* Funnel this component serves (stable funnel id, e.g. "checkout" —
|
|
@@ -724,12 +724,19 @@ declare function renderAgentMarkdown(feed: AgentFeed): string;
|
|
|
724
724
|
|
|
725
725
|
type RenderBlocksOptions = {
|
|
726
726
|
palette: SitePalette | null;
|
|
727
|
+
/** The site styles a Redesign tree borrows (native generation phase 2). */
|
|
728
|
+
vocabulary?: StyleVocabulary | null;
|
|
727
729
|
/** Absent handler = form trees must not reach this function (AdaptiveSlot gates). */
|
|
728
730
|
onFormSubmit?: (values: Record<string, string>) => void;
|
|
729
731
|
/** Fired with the form's submitGoal when a rendered form submits. */
|
|
730
732
|
onFormGoal?: (goal: string) => void;
|
|
731
733
|
};
|
|
732
|
-
/** Render one validated block tree as JSX. Null for anything unrenderable — fail-safe. */
|
|
733
734
|
declare function renderBlocks(node: BlockNode, opts: RenderBlocksOptions): JSX.Element | null;
|
|
735
|
+
/**
|
|
736
|
+
* A Redesign (compose) arm: the tree, painted on a site section/card surface
|
|
737
|
+
* when its style resolves. Null when the tree's root can't render (a newer
|
|
738
|
+
* server's node type) — the caller treats that like a blocked blocks arm.
|
|
739
|
+
*/
|
|
740
|
+
declare function renderCompose(compose: ComposeArm, opts: RenderBlocksOptions): JSX.Element | null;
|
|
734
741
|
|
|
735
|
-
export { Adaptive, type AdaptiveGeneratedProps, AdaptiveGroup, type AdaptiveGroupProps, type AdaptivePersona, type AdaptiveProps, AdaptiveProvider, type AdaptiveProviderProps, AdaptiveSlot, type AdaptiveSlotProps, AdaptiveText, type AdaptiveTextProps, type AdaptiveVariantsProps, type AgentBlock, type AgentFeed, type AssignmentState, type ClickGoal, type ComponentWeights, type CompositeGoal, type FireGoal, type FormSubmitGoal, type GoalConfig, type MicroSignalGoalConfig, type MicroSignalGoals, type PageGoalOptions, type RenderBlocksOptions, type ScrollDepthGoal, SentientPersonaScript, type SentientPersonaScriptProps, type SsrFallback, type UseAdaptiveBind, type UseAdaptiveResult, type UseAdaptiveTokensOptions, type UseAdaptiveTokensResult, type VariantWeight, type WeightedCompositeGoal, type WeightedStep, buildAgentFeed, defineAgentContent, getAgentContent, renderAgentJsonLd, renderAgentJsonLdBody, renderAgentMarkdown, renderBlocks, useAdaptive, useAdaptiveApiBaseUrl, useAdaptiveGoal, useAdaptivePersona, useAdaptiveTokens, useAssignment, useInitialAssignments, useLayoutOrder, usePageGoal, useSentient };
|
|
742
|
+
export { Adaptive, type AdaptiveGeneratedProps, AdaptiveGroup, type AdaptiveGroupProps, type AdaptivePersona, type AdaptiveProps, AdaptiveProvider, type AdaptiveProviderProps, AdaptiveSlot, type AdaptiveSlotProps, AdaptiveText, type AdaptiveTextProps, type AdaptiveVariantsProps, type AgentBlock, type AgentFeed, type AssignmentState, type ClickGoal, type ComponentWeights, type CompositeGoal, type FireGoal, type FormSubmitGoal, type GoalConfig, type MicroSignalGoalConfig, type MicroSignalGoals, type PageGoalOptions, type RenderBlocksOptions, type ScrollDepthGoal, SentientPersonaScript, type SentientPersonaScriptProps, type SsrFallback, type UseAdaptiveBind, type UseAdaptiveResult, type UseAdaptiveTokensOptions, type UseAdaptiveTokensResult, type VariantWeight, type WeightedCompositeGoal, type WeightedStep, buildAgentFeed, defineAgentContent, getAgentContent, renderAgentJsonLd, renderAgentJsonLdBody, renderAgentMarkdown, renderBlocks, renderCompose, useAdaptive, useAdaptiveApiBaseUrl, useAdaptiveGoal, useAdaptivePersona, useAdaptiveTokens, useAssignment, useInitialAssignments, useLayoutOrder, usePageGoal, useSentient };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var gn=Object.create;var le=Object.defineProperty,mn=Object.defineProperties,pn=Object.getOwnPropertyDescriptor,vn=Object.getOwnPropertyDescriptors,yn=Object.getOwnPropertyNames,fe=Object.getOwnPropertySymbols,Sn=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty,Ye=Object.prototype.propertyIsEnumerable;var Ze=(e,t,n)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))Pe.call(t,n)&&Ze(e,n,t[n]);if(fe)for(var n of fe(t))Ye.call(t,n)&&Ze(e,n,t[n]);return e},W=(e,t)=>mn(e,vn(t));var Qe=(e,t)=>{var n={};for(var r in e)Pe.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&fe)for(var r of fe(e))t.indexOf(r)<0&&Ye.call(e,r)&&(n[r]=e[r]);return n};var hn=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},et=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of yn(t))!Pe.call(e,i)&&i!==n&&le(e,i,{get:()=>t[i],enumerable:!(r=pn(t,i))||r.enumerable});return e};var tt=(e,t,n)=>(n=e!=null?gn(Sn(e)):{},et(t||!e||!e.__esModule?le(n,"default",{value:e,enumerable:!0}):n,e)),bn=e=>et(le({},"__esModule",{value:!0}),e);var Mn={};hn(Mn,{Adaptive:()=>jt,AdaptiveGroup:()=>on,AdaptiveProvider:()=>wt,AdaptiveSlot:()=>Ae,AdaptiveText:()=>Kt,SentientPersonaScript:()=>zt,buildAgentFeed:()=>cn,defineAgentContent:()=>ln,detectSegment:()=>Ue.deriveSessionSegment,getAgentContent:()=>Je,grantConsent:()=>fn.grantConsent,renderAgentJsonLd:()=>un,renderAgentJsonLdBody:()=>Xe,renderAgentMarkdown:()=>dn,renderBlocks:()=>oe,useAdaptive:()=>rn,useAdaptiveApiBaseUrl:()=>Ot,useAdaptiveGoal:()=>ke,useAdaptivePersona:()=>Yt,useAdaptiveTokens:()=>tn,useAssignment:()=>xe,useInitialAssignments:()=>ve,useLayoutOrder:()=>_t,usePageGoal:()=>Ut,useSentient:()=>E});module.exports=bn(Mn);var C=require("react"),pe=require("@sentientui/core");var nt=new Map,ge=new Map;function rt(e,t){let n=ge.get(e);return n||(n=new Set,ge.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&ge.delete(e)}}function it(e,t){nt.set(e,t);let n=ge.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function Te(e){var t;return(t=nt.get(e))!=null?t:null}var xn={on:!1,listeners:new Set};function ot(){if(typeof window=="undefined")return xn;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function De(){return ot().on}function st(e){let t=ot().listeners;return t.add(e),()=>{t.delete(e)}}function at(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Le="sentient:overrides-changed";function lt(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function ct(){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(Le))}function $(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(Le,e),()=>window.removeEventListener(Le,e))}function ut(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function G(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function V(e){return typeof e=="string"?{type:"click"}:e}function q(e){return typeof e=="string"?e:e.type}function X(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var Ie=new Set,Fe=!1;function dt(e){if(Ie.has(e))return!0;if(Ie.add(e),!Fe){Fe=!0;let t=()=>{Fe=!1,Ie.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 wn(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function ft(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(wn(r))return!0;r=r.parentElement}return!1}function H(e,t,n,r){if(t.type==="weighted_composite"){let o=new Set,d=[];return t.steps.forEach(({goal:u,name:g,weight:b},h)=>{let v=(p=!1)=>{o.has(h)||p&&r!==void 0&&dt(`step\0${g}\0${b}\0${h}`)||(o.add(h),n.fireStep(g,b,h))};if(u.type==="click"){let p=a=>{let l=a.target;l instanceof Element&&ft(l,e,u.selector)&&v()};e.addEventListener("click",p),d.push(()=>e.removeEventListener("click",p));return}if(u.type==="form_submit"){let p=a=>{a.target instanceof HTMLFormElement&&e.contains(a.target)&&v()};e.addEventListener("submit",p),d.push(()=>e.removeEventListener("submit",p));return}if(u.type==="scroll_depth"){let p=Math.max(0,Math.min(1,u.threshold)),a=new IntersectionObserver(l=>{for(let y of l)if(y.intersectionRatio>=p){v(!0),a.disconnect();break}},{threshold:[p]});a.observe(e),d.push(()=>a.disconnect())}}),()=>{for(let u of d)u()}}let i=t.type==="composite"?t.all:[t],f=new Set(i.map((o,d)=>d)),c=()=>{r!==void 0&&dt(r)||n.fireGoal()},s=(o,d=!1)=>{f.delete(o),f.size===0&&(d?c():n.fireGoal())},m=[];return i.forEach((o,d)=>{if(o.type==="click"){let u=g=>{let b=g.target;b instanceof Element&&ft(b,e,o.selector)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("click",u),m.push(()=>e.removeEventListener("click",u));return}if(o.type==="form_submit"){let u=g=>{g.target instanceof HTMLFormElement&&e.contains(g.target)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("submit",u),m.push(()=>e.removeEventListener("submit",u));return}if(o.type==="scroll_depth"){let u=Math.max(0,Math.min(1,o.threshold)),g=new IntersectionObserver(b=>{for(let h of b)if(h.intersectionRatio>=u){t.type==="composite"?s(d,!0):c(),g.disconnect();break}},{threshold:[u]});g.observe(e),m.push(()=>g.disconnect());return}}),()=>{for(let o of m)o()}}var gt=new Set,mt=new Set;function ne(e,t,n,r,i){let f=`${r}|${n}`;if(mt.has(f))return;mt.add(f);let c=i.type==="weighted_composite"&&!gt.has(r);c&>.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:c?{funnelId:r,steps:i.steps.map(s=>({goalId:s.name,weight:s.weight}))}:{funnelId:r}})}function Z(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Cn={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function ee(){if(typeof window=="undefined")return Cn;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 ce(){ee().version+=1;for(let e of ee().listeners)e()}var pt=()=>{};function vt(e){return G()?(ee().components.set(e.id,e),ce(),()=>{ee().components.delete(e.id),ce()}):pt}function re(e){return G()?(ee().slots.set(e.id,e),ce(),()=>{ee().slots.delete(e.id),ce()}):pt}function Be(e){G()&&(ee().sections=[...e],ce())}var yt="0.34.4",Me=yt!=="0.0.0-dev"?{name:"react",version:yt}:void 0;function An(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function $e(e,t){An()[e]=t}function _n(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Ve(e,t){_n()[e]=t}var St="sentient_editor",ht="sentient_preview_cell",je="sentient-cell-preview-bar",Ne="__preview__";function bt(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(je))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(St),n=s.get(ht)}catch(s){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let i=n.slice(0,r),f=n.slice(r+1),c=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${c}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async s=>{if(!s.ok){me(s.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 m=await s.json();if(m.blocks!=null)$e(i,{kind:"arms",blocks:{[Ne]:m.blocks}}),Ve(i,Ne);else if(m.content!=null)$e(i,{kind:"arms",content:m.content}),Ve(i,Ne);else{me("Nothing to preview in that square yet.");return}ct(),me(`Previewing \u201C${m.slotName}\u201D for ${m.personaDisplay}${m.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var o;try{(o=document.querySelector(`[data-sentient-slot="${i}"]`))==null||o.scrollIntoView({block:"center"})}catch(d){}},300)}).catch(()=>me("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function me(e){var i;if(document.getElementById(je))return;let t=document.createElement("div");t.id=je,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 f=new URL(window.location.href);f.searchParams.delete(St),f.searchParams.delete(ht),window.location.assign(f.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var Et=require("react/jsx-runtime");function Rn(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,pe.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var xt="https://api.sentient-ui.com/v1",M=(0,C.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:xt,debug:!1});function kn(e){let[t,n]=(0,C.useState)(!1),r=(0,C.useRef)(e);r.current=e;let{cookie:i,value:f,event:c}=e!=null?e:{},s=typeof(e==null?void 0:e.check)=="function";return(0,C.useEffect)(()=>{let m=()=>{var g;let d=r.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let u=`${d.cookie}=${(g=d.value)!=null?g:"accepted"}`;return document.cookie.split("; ").some(b=>b.trim()===u)};if(n(m()),!c)return;let o=()=>{n(m())};return window.addEventListener(c,o),()=>window.removeEventListener(c,o)},[i,f,c,s]),t}function wt(e){var h,v;let[t,n]=(0,C.useState)(null),[r]=(0,C.useState)(()=>{var p;return(p=e.sessionSegment)!=null?p:Rn()}),[i,f]=(0,C.useState)(De());(0,C.useEffect)(()=>st(()=>f(De())),[]),(0,C.useEffect)(()=>{bt(e.apiBaseUrl)},[]);let c=kn(e.consentFrom),s=e.consentFrom?e.consent===!0||c:e.consent,m=(0,C.useRef)(null);(0,C.useEffect)(()=>{var _;if(s===!1&&!e.preConsentBehavior){(_=m.current)==null||_.destroy(),m.current=null,n(null);return}let p=S({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},Me?{sdk:Me}:{}),a=!1,l=null,y=null,x=k=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:A})=>{a||(y=A(k,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:k})=>{a||(l=k(W(S({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),m.current=l,n(l),x(l))}):(l=(0,pe.init)(p),m.current=l,n(l),x(l)),()=>{a=!0,y==null||y(),l==null||l.dispose()}},[s]),(0,C.useEffect)(()=>{if(!t)return;let p=!1,a=async()=>{if(p)return;let y;try{y=await t.fetchWeights()}catch(x){return}if(!p)for(let x of y){let _={componentId:x.componentId,updatedAt:x.updatedAt,variants:x.variants.map(k=>{var A;return{variantId:k.variantId,pulls:k.pulls,avgReward:(A=k.avgReward)!=null?A:0}})};it(x.componentId,_)}};a();let l=setInterval(()=>{a()},6e4);return()=>{p=!0,clearInterval(l)}},[t]);let o=(h=e.ssrFallback)!=null?h:"first",d=((v=e.apiBaseUrl)!=null?v:xt).replace(/\/$/,""),u=(0,C.useRef)(null);(0,C.useEffect)(()=>{var l;if(typeof process!="undefined"&&((l=process.env)==null?void 0:l.NODE_ENV)==="production")return;let p={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},a=u.current;if(u.current=p,a!==null)for(let y of["apiKey","context","country","persona","apiBaseUrl"])Object.is(a[y],p[y])||console.warn(`[sentient] AdaptiveProvider: \`${y}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,d]),(0,C.useEffect)(()=>{var p;typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production"||ut({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),(0,C.useEffect)(()=>{let p=e.initialLayoutOrder;if(p&&p.length>0){Be(p);return}e.declaredSections&&e.declaredSections.length>0&&Be(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,C.useEffect)(()=>{if(!G())return;let p=e.declaredSections;if(!p||p.length===0||typeof document=="undefined")return;let a=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),y=>y.getAttribute("data-sentient-id"))),l=p.filter(y=>!a.has(y));l.length>0&&console.warn(`[SentientUI] Declared section${l.length>1?"s":""} ${l.map(y=>`"${y}"`).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 g=(0,C.useMemo)(()=>t&&i?at(t):t,[t,i]),b=(0,C.useMemo)(()=>{var p,a,l,y,x,_,k;return{client:g,apiKey:e.apiKey,initialAssignments:(p=e.initialAssignments)!=null?p:{},sessionSegment:r,ssrFallback:o,onAssignment:e.onAssignment,initialLayoutOrder:(a=e.initialLayoutOrder)!=null?a:null,initialSlots:(l=e.initialSlots)!=null?l:{},initialSlotConfig:(y=e.initialSlotConfig)!=null?y:{},initialPalette:(x=e.initialPalette)!=null?x:null,initialPersona:(_=e.initialPersona)!=null?_:null,apiBaseUrl:d,debug:(k=e.debug)!=null?k:!1}},[g,e.apiKey,e.initialAssignments,r,o,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return(0,Et.jsx)(M.Provider,{value:b,children:e.children})}function E(){return(0,C.useContext)(M).client}function z(){return(0,C.useContext)(M).apiKey}function ve(){return(0,C.useContext)(M).initialAssignments}function ye(){return(0,C.useContext)(M).sessionSegment}function Ct(){return(0,C.useContext)(M).ssrFallback}function Se(){return(0,C.useContext)(M).onAssignment}function At(){return(0,C.useContext)(M).debug}function _t(){let e=(0,C.useContext)(M).initialLayoutOrder,t=(0,C.useSyncExternalStore)($,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function he(){return(0,C.useContext)(M).initialSlots}function Rt(){return(0,C.useContext)(M).initialPersona}function kt(){return(0,C.useContext)(M).initialSlotConfig}function Gt(){return(0,C.useContext)(M).initialPalette}function Ot(){return(0,C.useContext)(M).apiBaseUrl}var se=require("react");var D=require("react"),Pt=require("@sentientui/core");var N=require("react"),be=require("@sentientui/policy");function ie(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 f=i.indexOf(":");if(f!==-1&&i.slice(0,f)===e)return i.slice(f+1)}}catch(r){}return null}function xe(e,t,n,r){let i=ve(),f=Ct(),c=E(),s=ye(),m=Se(),o=At(),d=(0,N.useRef)(null),u=(0,N.useSyncExternalStore)($,()=>ie(e),()=>null),g=u&&t.includes(u)?u:null,b=(0,N.useRef)(null);(0,N.useEffect)(()=>{o&&g&&b.current!==g&&(b.current=g,console.info(`[sentient] override active: ${e} -> ${g}`))},[o,g,e]);let[h,v]=(0,N.useState)(()=>{var y,x;if(g)return{variantId:g,content:null,isLoading:!1,settled:!0};if(!c){let _=i[e];return _&&t.includes(_)?{variantId:_,content:null,isLoading:!1,settled:!0}:f==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content))return{variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0};let l=Te(e);if(l){let _=(0,be.pickFromWeights)(l.variants,t);if(_)return{variantId:_,content:null,isLoading:!1,settled:!0}}return{variantId:(x=t[0])!=null?x:null,content:null,isLoading:!1,settled:!1}}),p=a=>{m&&d.current!==a&&(d.current=a,m(e,a))};return(0,N.useEffect)(()=>{var y;if(g||!c)return;let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content)){v({variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0}),p(a.variantId);return}let l=Te(e);if(l&&h.settled&&h.variantId&&h.variantId===(0,be.pickFromWeights)(l.variants,t)){p(h.variantId);return}v(x=>{var _;return x.variantId?x:{variantId:(_=t[0])!=null?_:null,content:null,isLoading:!1,settled:!1}})},[g,c,e,s]),(0,N.useEffect)(()=>{if(g||!c)return;let a=c.getAssignment(e,s);if(a&&t.includes(a.variantId))return;let l=!1;return c.assign(e,t,n,r).then(y=>{var x;l||y&&(!t.includes(y.variantId)&&!y.content||(v({variantId:y.variantId,content:(x=y.content)!=null?x:null,isLoading:!1,settled:!0}),p(y.variantId)))}),()=>{l=!0}},[g,c,e,s]),(0,N.useEffect)(()=>{if(!g&&c)return rt(e,a=>{var x;let l=c.getAssignment(e,s);if(l&&(t.includes(l.variantId)||l.content)){v({variantId:l.variantId,content:(x=l.content)!=null?x:null,isLoading:!1,settled:!0}),p(l.variantId);return}let y=(0,be.pickFromWeights)(a.variants,t);y&&(v({variantId:y,content:null,isLoading:!1,settled:!0}),p(y))})},[g,c,e,s]),g?{variantId:g,content:null,isLoading:!1,settled:!0,isOverride:!0}:h}function we(e,t,n){let r=E(),i=z(),f=Object.keys(t).join("\0"),c=(0,D.useMemo)(()=>Object.keys(t),[f]),{variantId:s,content:m,isOverride:o=!1,settled:d}=xe(e,c,n.agentData,n.agentDataByVariant),[u,g]=(0,D.useState)(null),b=(0,D.useRef)(null),h=(0,D.useCallback)(w=>{b.current=w,g(w)},[]),v=n.goal,p=typeof v=="string"?v:JSON.stringify(v),a=(0,D.useMemo)(()=>v?V(v):null,[p]),l=v?q(v):"";(0,D.useEffect)(()=>vt({id:e,variantIds:c,goal:l}),[e,c,l]);let y=(0,D.useRef)(null);(0,D.useEffect)(()=>{o||d&&(!r||!s||!i||!u||y.current!==s&&(y.current=s,Z(r,i,e,s)))},[r,s,i,e,u,o,d]);let x=(0,D.useRef)(!1),_=(0,D.useRef)(new Set);(0,D.useEffect)(()=>{x.current=!1,_.current=new Set},[s,a]);let k=n.funnel;(0,D.useEffect)(()=>{o||!d||!r||!k||!a||ne(r,i,e,k,a)},[r,i,e,k,a,o,d]);let A=n.cursorSignal===!0;(0,D.useEffect)(()=>{if(!A||o||!d||!r||!s||!u)return;let w=null,R=0,L=()=>{R=Date.now(),w=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-R}}),w=null},800)},I=()=>{w!==null&&(clearTimeout(w),w=null)};return u.addEventListener("mouseenter",L),u.addEventListener("mouseleave",I),()=>{u.removeEventListener("mouseenter",L),u.removeEventListener("mouseleave",I),w!==null&&clearTimeout(w)}},[A,r,s,i,e,u,o,d]);let O=(0,D.useRef)(n.microSignalGoals);O.current=n.microSignalGoals;let P=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,D.useEffect)(()=>{if(o||!d||!r||!s||!u)return;let w=Date.now();return(0,Pt.attachMicroSignalDetectors)((R,L={})=>{var He,ze,qe;r.track({projectId:i,componentId:e,variantId:s,eventType:"micro_signal",payload:S({signalType:R},L)});let I=(He=O.current)==null?void 0:He[R];if(!I||_.current.has(R))return;_.current.add(R);let Q=typeof I=="string"?I:I.name,de=typeof I=="string"?1:(ze=I.weight)!=null?ze:1,Ee=typeof I=="string"?0:(qe=I.stepIndex)!=null?qe:0;r.goal(Q,{metadata:S({signalType:R},L),weight:de,stepIndex:Ee})},u,w)},[r,s,i,e,u,P,o,d]),(0,D.useEffect)(()=>{if(o||!d||!r||!s||!u||!a)return;let w=X(a);return H(u,a,{fireGoal:()=>{x.current||(x.current=!0,r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:l,payload:S({reward:1},w!==void 0?{goalValue:w}:{})}),r.goal(l,S({metadata:{componentId:e,variantId:s},weight:1,stepIndex:0},w!==void 0?{value:w}:{})))},fireStep:(R,L,I)=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:R,payload:{reward:L}}),r.goal(R,{metadata:{},weight:L,stepIndex:I})}},l)},[r,s,i,e,u,a,l,o,d]),{client:r,variantIds:c,variantId:s,content:m,settled:d,isOverride:o,goalLabel:l,ref:h,nodeRef:b}}var K=require("react"),Ce=require("@sentientui/core");var j=require("react"),Dt=require("@sentientui/core");var Tt=new Set;function Lt(e,t){var p;let n=E(),r=(0,j.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=he(),f=kt(),c=Gt(),s=(0,j.useSyncExternalStore)($,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_config_overrides)==null?void 0:a[e]:void 0},()=>{}),m=(0,j.useSyncExternalStore)($,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_overrides)==null?void 0:a[e]:void 0},()=>{}),o=a=>a==null?"":(0,Dt.armOfResult)(a),d=(0,j.useCallback)(a=>{var l,y;return(y=(l=n==null?void 0:n.onSlotsChanged)==null?void 0:l.call(n,a))!=null?y:(()=>{})},[n]);(0,j.useSyncExternalStore)(d,()=>{var a;return(a=n==null?void 0:n.getSlotConfig(e))!=null?a:null},()=>null),(0,j.useSyncExternalStore)(d,()=>o(n==null?void 0:n.getSlotResult(e)),()=>"");let u=s===void 0?f[e]:void 0,g=s===void 0&&u===void 0&&n?n.getSlotConfig(e):null,b=(p=c!=null?c:n==null?void 0:n.getSitePalette())!=null?p:null,h=(()=>{var a,l;if(s!==void 0)return{config:s,arm:o(m),palette:b,source:"override"};if(u!==void 0)return{config:u,arm:o((a=i[e])!=null?a:n==null?void 0:n.getSlotResult(e)),palette:b,source:"preloaded"};if(g!==null){let y=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:g,arm:o((l=n==null?void 0:n.getSlotResult(e))!=null?l:i[e]),palette:b,source:y?"client":"seeded"}}return{config:null,arm:"",palette:b,source:"none"}})(),v=h.source==="preloaded"||h.source==="override";return(0,j.useEffect)(()=>{var y,x;if(!n||n.isLocal===!0||v)return;let a=h.source==="none"&&(x=(y=r.current)==null?void 0:y.call(r))!=null?x:null,l=a!=null&&a!==""?[[e],{[e]:a}]:[[e]];return n.requestSlots?n.requestSlots(...l):h.source==="none"&&n.reportSlots(...l),()=>{var _;return(_=n.cancelSlots)==null?void 0:_.call(n,[e])}},[n,v,h.source,e]),(0,j.useEffect)(()=>{!G()||(n==null?void 0:n.isLocal)!==!0||h.source!=="none"||Tt.has(e)||(Tt.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,h.source,e]),h}var We=require("react");var T=require("react/jsx-runtime"),Y={none:"0",sm:"8px",md:"16px",lg:"24px"},Ke={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Mt={sm:"0.875em",md:"1em",lg:"1.25em"},Gn={sm:"1.25em",md:"1.5em",lg:"2em"},It={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Ft={sm:"8px",md:"16px",lg:"32px"},On={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},En={normal:"400",medium:"500",bold:"700"};function Bt(e,t){return S(S({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?S({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function $t(e,t,n){var i,f,c,s;let r=t==null?void 0:t.accent;return W(S({display:"inline-block",padding:(i=It[n!=null?n:"md"])!=null?i:It.md,borderRadius:(f=t==null?void 0:t.radius)!=null?f:"8px",font:"inherit"},n?{fontSize:Mt[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"?(s=t==null?void 0:t.primaryText)!=null?s:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function Pn({node:e,opts:t}){var i,f,c,s,m;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(c=(f=t.palette)==null?void 0:f.border)!=null?c:"currentColor"}`,borderRadius:(m=(s=t.palette)==null?void 0:s.radius)!=null?m:"8px"};return(0,T.jsxs)("form",{onSubmit:o=>{var g,b,h;o.preventDefault();let d=new FormData(o.currentTarget),u={};for(let v of e.fields)u[v.name]=String((g=d.get(v.name))!=null?g:"");(b=t.onFormGoal)==null||b.call(t,e.submitGoal);try{(h=t.onFormSubmit)==null||h.call(t,u)}catch(v){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(o=>{var d,u;return(0,T.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[o.label,o.kind==="textarea"?(0,T.jsx)("textarea",{name:o.name,required:o.required,placeholder:o.placeholder,rows:3,style:r}):o.kind==="select"?(0,T.jsx)("select",{name:o.name,required:o.required,style:r,children:((d=o.options)!=null?d:[]).map(g=>(0,T.jsx)("option",{value:g,children:g},g))}):(0,T.jsx)("input",{name:o.name,type:(u=o.inputType)!=null?u:"text",required:o.required,placeholder:o.placeholder,style:r})]},o.name)}),(0,T.jsx)("button",{type:"submit",style:$t(n,t.palette),children:e.submitLabel})]})}function oe(e,t){var n,r,i,f,c,s,m,o,d,u,g,b,h,v,p,a,l,y,x,_,k,A,O;try{switch(e.type){case"stack":{let P=(r=Y[(n=e.gap)!=null?n:"md"])!=null?r:Y.md,w=e.surface==="raised",R=(i=e.pad)!=null?i:w?"md":void 0;return(0,T.jsx)("div",{style:S(S(S(S(S({display:"flex",flexDirection:e.direction,gap:P},e.align?{alignItems:Ke[e.align]}:{}),e.justify?{justifyContent:Ke[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),R?{padding:(f=Y[R])!=null?f:Y.md}:{}),w?W(S(S({},(c=t.palette)!=null&&c.surface?{background:t.palette.surface}:{}),(s=t.palette)!=null&&s.surface&&((m=t.palette)!=null&&m.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(d=(o=t.palette)==null?void 0:o.border)!=null?d:"currentColor"}`,borderRadius:(g=(u=t.palette)==null?void 0:u.radius)!=null?g:"8px"}):{}),children:((b=e.children)!=null?b:[]).map((L,I)=>{let Q=oe(L,t);return Q===null?null:(0,T.jsx)(We.Fragment,{children:Q},I)})})}case"grid":{let P=(v=Y[(h=e.gap)!=null?h:"md"])!=null?v:Y.md;return(0,T.jsx)("div",{style:S(S({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${P}) / ${e.columns})), 1fr))`,gap:P},e.align?{alignItems:Ke[e.align]}:{}),e.pad?{padding:(p=Y[e.pad])!=null?p:Y.md}:{}),children:((a=e.children)!=null?a:[]).map((w,R)=>{let L=oe(w,t);return L===null?null:(0,T.jsx)(We.Fragment,{children:L},R)})})}case"text":return(0,T.jsx)("p",{style:S(S(S(S(S({margin:0},e.size?{fontSize:Mt[e.size]}:{}),e.weight?{fontWeight:En[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Bt(e.tone,t.palette)),children:e.value});case"heading":{let P=`h${e.level}`;return(0,T.jsx)(P,{style:S(S({margin:0,fontSize:Gn[(l=e.size)!=null?l:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let P=(y=e.emphasis)!=null?y:"primary";return(0,T.jsx)("a",W(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:$t(P,t.palette,e.size),children:e.label}))}case"link":return(0,T.jsx)("a",W(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:{color:"inherit",textDecoration:"underline"},children:e.label}));case"image":return(0,T.jsx)("img",{src:e.src,alt:e.alt,style:S(S({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:On[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})});case"badge":return(0,T.jsx)("span",{style:S({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(_=(x=t.palette)==null?void 0:x.border)!=null?_:"currentColor"}`},Bt(e.tone,t.palette)),children:e.value});case"spacer":return(0,T.jsx)("div",{style:{height:(k=Ft[e.size])!=null?k:Ft.md}});case"divider":return(0,T.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(O=(A=t.palette)==null?void 0:A.border)!=null?O:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,T.jsx)(Pn,{node:e,opts:t});default:return null}}catch(P){return null}}var Nt=require("react/jsx-runtime"),Vt=new Set;function Ae({id:e,children:t,onFormSubmit:n,goal:r,className:i,reportBaselineText:f=!0}){var P;let c=E(),s=z(),m=(0,K.useRef)(null),{config:o,arm:d,palette:u,source:g}=Lt(e,{baselineText:f?()=>{var w,R;return(R=(w=m.current)==null?void 0:w.textContent)!=null?R:null}:void 0}),b=d!==""?(P=o==null?void 0:o.blocks)==null?void 0:P[d]:void 0,h=b!==void 0&&(0,Ce.containsFormBlock)(b)&&!n;(0,K.useEffect)(()=>{!h||!G()||Vt.has(e)||(Vt.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[h,e]);let v=w=>{!c||g==="override"||(g!=="seeded"&&c.componentGoal(e,w),c.goal(w,{metadata:{componentId:e,arm:d},weight:1,stepIndex:0}))},p=t,a=!1;if(b!==void 0){let w=h?null:oe(b,{palette:u,onFormSubmit:n,onFormGoal:v});w===null?a=!0:p=w}else(o==null?void 0:o.content)!==void 0&&g!=="none"&&(p=o.content);let l=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";(0,K.useEffect)(()=>re({id:e,arms:l===""?void 0:l.split("|")}),[e,l]);let y=(0,K.useRef)(null);(0,K.useEffect)(()=>{!c||g==="none"||g==="seeded"||g==="override"||d===""||a||y.current!==d&&(y.current=d,Z(c,s,e,d))},[c,s,e,d,g,a]);let x=g!=="none"&&g!=="seeded"&&!a,_=x?d:"",k=r===void 0?null:typeof r=="string"?r:JSON.stringify(r);(0,K.useEffect)(()=>{if(!c||!r||g==="override")return;let w=m.current;if(!w)return;let R=q(r),L=X(r),I=!1;return H(w,V(r),{fireGoal:()=>{I||(I=!0,x&&(L!==void 0?c.componentGoal(e,R,{value:L}):c.componentGoal(e,R)),c.goal(R,S({metadata:{componentId:e,arm:_},weight:1,stepIndex:0},L!==void 0?{value:L}:{})))},fireStep:(Q,de,Ee)=>{x&&c.componentGoal(e,Q,{reward:de}),c.goal(Q,{metadata:{componentId:e,arm:_},weight:de,stepIndex:Ee})}},R)},[c,e,k,d,g,a,x,_]);let A=(0,K.useRef)(null);(0,K.useEffect)(()=>{let w=m.current;if(w){if(A.current===null){A.current=d;return}A.current!==d&&(A.current=d,(0,Ce.reveal)(w))}},[d]);let O=(0,K.useMemo)(()=>S({"data-sentient-slot":e},d!==""?{"data-sentient-arm":d}:{}),[e,d]);return(0,Nt.jsx)("div",W(S({ref:m,className:i},O),{children:p}))}var _e=require("react/jsx-runtime");function Tn(e){var o;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}),[f,c]=(0,se.useState)(!1);if((0,se.useEffect)(()=>{c(!0)},[]),e.clientOnly&&(!f||!t)||!n)return null;let s=(o=e.variants[n])!=null?o:null,m=s===null?r:null;return G()&&s===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,_e.jsx)("div",{ref:i,"data-sentient-id":e.id,"data-sentient-variant":n,children:s!=null?s:m})}var Dn=(0,se.memo)(Tn,(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 jt(e){return e.variants===void 0?(0,_e.jsx)(Ae,S({},e)):(G()&&e.children!=null&&console.warn(`[sentient] <Adaptive id="${e.id}"> got both variants and children \u2014 rendering variants; children are ignored.`),(0,_e.jsx)(Dn,S({},e)))}var F=require("react");var Wt=require("react/jsx-runtime");function Kt({id:e,default:t,component:n="span",className:r,goal:i}){var k;let f=E(),c=z(),s=Se(),m=ye(),o=(0,F.useRef)(null),d=(0,F.useRef)(null),u=(0,F.useSyncExternalStore)($,()=>ie(e),()=>null),[g,b]=(0,F.useState)(()=>{var A,O;return(O=(A=f==null?void 0:f.getAssignment(e,m))==null?void 0:A.content)!=null?O:null}),[h,v]=(0,F.useState)(()=>{var A,O;return(O=(A=f==null?void 0:f.getAssignment(e,m))==null?void 0:A.variantId)!=null?O:null});(0,F.useEffect)(()=>{if(u||!f)return;let A=f.getAssignment(e,m);if((A==null?void 0:A.content)!==void 0){v(A.variantId),b(A.content);return}let O=!1;return f.assign(e).then(P=>{if(!O){if(!P){G()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}v(P.variantId),P.content&&b(P.content)}}),()=>{O=!0}},[f,e,m,u]),(0,F.useEffect)(()=>{u||!f||!h||!c||o.current!==h&&(o.current=h,f.track({projectId:c,componentId:e,variantId:h,eventType:"variant_assigned",payload:{}}),s==null||s(e,h))},[f,h,c,e,s,u]);let p=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),a=(0,F.useMemo)(()=>i===void 0?null:V(i),[p]),l=i===void 0?null:typeof i=="string"?i:a.type,y=(0,F.useRef)(!1);(0,F.useEffect)(()=>{y.current=!1},[h,p]),(0,F.useEffect)(()=>{if(u||!f||!h||!c||!a||!l)return;let A=d.current;if(!A)return;let O=X(a);return H(A,a,{fireGoal:()=>{y.current||(y.current=!0,f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:l,payload:S({reward:1},O!==void 0?{goalValue:O}:{})}),f.goal(l,S({metadata:{componentId:e,variantId:h},weight:1,stepIndex:0},O!==void 0?{value:O}:{})))},fireStep:(P,w,R)=>{f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:P,payload:{reward:w}}),f.goal(P,{metadata:{},weight:w,stepIndex:R})}})},[f,h,c,e,a,l,u]);let x=g!=null?g:t;if(u){let A=f==null?void 0:f.getAssignment(e,m);x=A&&A.variantId===u&&(k=A.content)!=null?k:t}return(0,Wt.jsx)(n,{ref:A=>{d.current=A},className:r,children:x})}var Re=require("react");function ke(e){let t=E(),n=(0,Re.useRef)(new Set);return(0,Re.useCallback)((r,i)=>{var f,c;if(!ie(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,S(S(S({metadata:(f=i==null?void 0:i.metadata)!=null?f:{},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 ue=require("react");function Ut(e,t={}){let m=t,{componentId:n}=m,r=Qe(m,["componentId"]),i=E(),f=ke(n!=null?n:""),c=(0,ue.useRef)(!1),s=(0,ue.useRef)(r);s.current=r,(0,ue.useEffect)(()=>{if(!i||c.current)return;c.current=!0;let{metadata:o,reward:d,value:u,currency:g,externalId:b}=s.current;if(n){f(e,s.current);return}i.goal(e,S(S(S({metadata:o!=null?o:{},weight:d!=null?d:1,stepIndex:0},u!==void 0?{value:u}:{}),g!==void 0?{currency:g}:{}),b!==void 0?{externalId:b}:{}))},[i,n,e,f])}var Xt=require("@sentientui/core"),Ht=require("@sentientui/policy"),qt=require("react/jsx-runtime");function Jt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Ln(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Jt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Jt((0,Ht.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,Xt.renderPrePaintScript)(e.apiKey)}function zt(e){return(0,qt.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Ln(e)}})}var J=require("react"),en=require("@sentientui/policy");var U=require("react"),te=require("@sentientui/core"),Zt=require("@sentientui/policy");function Ge(e,t){let n=E(),r=he(),[,i]=(0,U.useReducer)(u=>u+1,0),f=(0,U.useSyncExternalStore)($,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),c=f===void 0?r[e]:void 0,s=f===void 0&&c===void 0&&n?n.getSlotResult(e):null,m=(n==null?void 0:n.isLocal)===!0&&f===void 0&&c===void 0&&s===null;(0,U.useEffect)(()=>{if(!m||!n)return;let u=!1;return n.decide({slots:[t]}).then(g=>{!u&&g&&i()}),()=>{u=!0}},[n,e,m]);let o=(()=>{if(f!==void 0)return{result:f,arm:(0,te.armOfResult)(f),source:"override"};if(c!==void 0)return{result:c,arm:(0,te.armOfResult)(c),source:"preloaded"};if(s!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:s,arm:(0,te.armOfResult)(s),source:g?"client":"seeded"}}let u=(0,te.baselineResultFor)(t);return{result:u,arm:(0,te.armOfResult)(u),source:"baseline"}})(),d=o.source==="preloaded"||o.source==="override";return(0,U.useEffect)(()=>{var g;if(!n||n.isLocal===!0||d||!n.decideSlots)return;let u=(g=n.onSlotsChanged)==null?void 0:g.call(n,i);return n.decideSlots([t]),()=>{var b;(b=n.cancelSlots)==null||b.call(n,[e]),u==null||u()}},[n,e,d]),o}function In(){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 Yt(){let e=E(),t=Rt();(0,U.useSyncExternalStore)($,lt,()=>0);let[n,r]=(0,U.useState)(!1);(0,U.useEffect)(()=>r(!0),[]);let i=s=>({persona:s.persona,confidence:s.confidence,band:(0,Zt.confidenceBand)(s.confidence)});if(!n)return t?i(t):null;let f=In();if(f)return i(f);if(t)return i(t);let c=e?e.getPersona():null;return c?i(c):null}var Qt=new Set;function Fn(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function tn(e,t,n){let r=E(),i=z(),f=JSON.stringify(t),c=(0,J.useMemo)(()=>({id:e,dims:t}),[e,f]),{result:s,arm:m,source:o}=Ge(e,c),d=(0,J.useMemo)(()=>typeof s=="string"?{}:s,[m]);if(G()&&!Qt.has(e)){Qt.add(e);let v=(0,en.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([a,l])=>[a,[...l]]))}),p=Object.values(t).reduce((a,l)=>a*l.length,1);v.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 ${v.reason}. Serving baseline.`)}let u=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,J.useEffect)(()=>re({id:e,dims:t}),[e]);let g=(0,J.useRef)(null);(0,J.useEffect)(()=>{!r||o==="baseline"||o==="seeded"||o==="override"||g.current===m||(g.current=m,Z(r,i,e,m))},[r,i,e,m,o]);let b=n==null?void 0:n.funnel;(0,J.useEffect)(()=>{var v;!r||!b||o==="override"||ne(r,i,e,b,V((v=n==null?void 0:n.goal)!=null?v:"click"))},[r,i,e,b,u,o]),(0,J.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||o==="override"||o==="baseline"||o==="seeded")return;let v=document.querySelector(`[data-sentient-slot="${Fn(e)}"]`);if(!v){G()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let p=q(n.goal),a=X(n.goal),l=!1;return H(v,V(n.goal),{fireGoal:()=>{l||(l=!0,a!==void 0?r.componentGoal(e,p,{value:a}):r.componentGoal(e,p),r.goal(p,S({metadata:{componentId:e,arm:m},weight:1,stepIndex:0},a!==void 0?{value:a}:{})))},fireStep:(y,x,_)=>{r.componentGoal(e,y,{reward:x}),r.goal(y,{metadata:{componentId:e,arm:m},weight:x,stepIndex:_})}},p)},[r,e,u,m,o]);let h=(0,J.useMemo)(()=>{let v={"data-sentient-slot":e};for(let[p,a]of Object.entries(d))v[`data-${p}`]=a;return v},[e,d]);return{tokens:d,props:h}}var ae=require("react");var nn=new Set;function rn(e,t){var b;if(G()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:f,goalLabel:c,ref:s,nodeRef:m}=we(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),o=(b=i!=null?i:r[0])!=null?b:"",d=t.variants[o];(0,ae.useEffect)(()=>{if(!G()||!n)return;let h=setTimeout(()=>{!m.current&&!nn.has(e)&&(nn.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(h)},[n,e]);let u=(0,ae.useCallback)((h,v)=>{var a,l;if(f)return;let p=h!=null?h:c;p&&(n==null||n.componentGoal(e,p,v),n==null||n.goal(p,S(S(S({metadata:(a=v==null?void 0:v.metadata)!=null?a:{},weight:(l=v==null?void 0:v.reward)!=null?l:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,c,f]),g=(0,ae.useMemo)(()=>({ref:s,"data-sentient-id":e,"data-sentient-variant":o}),[s,e,o]);return{variant:o,value:d,bind:g,fireGoal:u}}var B=require("react");var sn=require("react/jsx-runtime"),Oe=new Set;function on(e){var a;let t=E(),n=z(),r=(0,B.useRef)(null),i=Object.keys(e.arrangements).join(" "),f=(0,B.useMemo)(()=>Object.keys(e.arrangements),[i]),c=(0,B.useMemo)(()=>S({id:e.id,arms:f},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,f,e.baseline]),{arm:s,source:m}=Ge(e.id,c);G()&&e.baseline!==void 0&&e.baseline!==f[0]&&!Oe.has(e.id+":baseline")&&(Oe.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${f[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let o=B.Children.toArray(e.children).filter(B.isValidElement),d=new Map;for(let l of o)d.set(String((a=l.key)!=null?a:"").replace(/^\.\$/,""),l);let u=e.arrangements[s],g=u!==void 0&&u.length===o.length&&u.every(l=>d.has(l));G()&&u!==void 0&&!g&&!Oe.has(e.id+":keys")&&(Oe.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${s}" [${u.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let b=g?u.map(l=>d.get(l)):o;(0,B.useEffect)(()=>re({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let h=(0,B.useRef)(null);(0,B.useEffect)(()=>{!t||m==="baseline"||m==="seeded"||m==="override"||h.current===s||(h.current=s,Z(t,n,e.id,s))},[t,n,e.id,s,m]);let v=e.funnel;(0,B.useEffect)(()=>{var l;!t||!v||m==="override"||ne(t,n,e.id,v,V((l=e.goal)!=null?l:"click"))},[t,n,e.id,v,m]);let p=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,B.useEffect)(()=>{if(!t||e.goal===void 0||m==="override"||m==="baseline"||m==="seeded")return;let l=r.current;if(!l)return;let y=q(e.goal),x=X(e.goal),_=!1;return H(l,V(e.goal),{fireGoal:()=>{_||(_=!0,x!==void 0?t.componentGoal(e.id,y,{value:x}):t.componentGoal(e.id,y),t.goal(y,S({metadata:{componentId:e.id,arm:s},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(k,A,O)=>{t.componentGoal(e.id,k,{reward:A}),t.goal(k,{metadata:{componentId:e.id,arm:s},weight:A,stepIndex:O})}},y)},[t,e.id,p,s,m]),(0,sn.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":s,children:b})}var Ue=require("@sentientui/core");var Bn=["page","blocks","layoutOrder"],an=new Map;function ln(e,t){an.set(e,t)}function Je(e){return an.get(e)}function cn(e){var i,f;let t=(f=(i=e.content)!=null?i:Je(e.page))!=null?f:{},n={};for(let[c,s]of Object.entries(t))Bn.includes(c)||(n[c]=s);let r=W(S({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function un(e){return`<script type="application/ld+json">${Xe(e)}</script>`}function Xe(e){return JSON.stringify(S({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function dn(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 Qn=Object.create;var Ce=Object.defineProperty,er=Object.defineProperties,tr=Object.getOwnPropertyDescriptor,nr=Object.getOwnPropertyDescriptors,rr=Object.getOwnPropertyNames,Te=Object.getOwnPropertySymbols,ir=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty,Rt=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={}))Ze.call(t,n)&&wt(e,n,t[n]);if(Te)for(var n of Te(t))Rt.call(t,n)&&wt(e,n,t[n]);return e},M=(e,t)=>er(e,nr(t));var Le=(e,t)=>{var n={};for(var r in e)Ze.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Te)for(var r of Te(e))t.indexOf(r)<0&&Rt.call(e,r)&&(n[r]=e[r]);return n};var or=(e,t)=>{for(var n in t)Ce(e,n,{get:t[n],enumerable:!0})},kt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of rr(t))!Ze.call(e,i)&&i!==n&&Ce(e,i,{get:()=>t[i],enumerable:!(r=tr(t,i))||r.enumerable});return e};var Ye=(e,t,n)=>(n=e!=null?Qn(ir(e)):{},kt(t||!e||!e.__esModule?Ce(n,"default",{value:e,enumerable:!0}):n,e)),sr=e=>kt(Ce({},"__esModule",{value:!0}),e);var Pr={};or(Pr,{Adaptive:()=>_n,AdaptiveGroup:()=>Kn,AdaptiveProvider:()=>Zt,AdaptiveSlot:()=>Ee,AdaptiveText:()=>On,SentientPersonaScript:()=>Dn,buildAgentFeed:()=>Hn,defineAgentContent:()=>Un,detectSegment:()=>yt.deriveSessionSegment,getAgentContent:()=>vt,grantConsent:()=>qn.grantConsent,renderAgentJsonLd:()=>zn,renderAgentJsonLdBody:()=>St,renderAgentMarkdown:()=>Xn,renderBlocks:()=>fe,renderCompose:()=>Ke,useAdaptive:()=>jn,useAdaptiveApiBaseUrl:()=>sn,useAdaptiveGoal:()=>ze,useAdaptivePersona:()=>Vn,useAdaptiveTokens:()=>$n,useAssignment:()=>Be,useInitialAssignments:()=>Ne,useLayoutOrder:()=>en,usePageGoal:()=>Pn,useSentient:()=>I});module.exports=sr(Pr);var C=require("react"),Ie=require("@sentientui/core");var At=new Map,De=new Map;function Ct(e,t){let n=De.get(e);return n||(n=new Set,De.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&De.delete(e)}}function _t(e,t){At.set(e,t);let n=De.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function Qe(e){var t;return(t=At.get(e))!=null?t:null}var ar={on:!1,listeners:new Set};function Ot(){if(typeof window=="undefined")return ar;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function et(){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 tt="sentient:overrides-changed";function Gt(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function nt(){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(tt))}function J(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(tt,e),()=>window.removeEventListener(tt,e))}function Tt(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function G(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function 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 rt=new Set,it=!1;function Lt(e){if(rt.has(e))return!0;if(rt.add(e),!it){it=!0;let t=()=>{it=!1,rt.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 lr(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(lr(r))return!0;r=r.parentElement}return!1}function te(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,p=[];return t.steps.forEach(({goal:f,name:h,weight:k},c)=>{let u=(m=!1)=>{s.has(c)||m&&r!==void 0&&Lt(`step\0${h}\0${k}\0${c}`)||(s.add(c),n.fireStep(h,k,c))};if(f.type==="click"){let m=g=>{let a=g.target;a instanceof Element&&Dt(a,e,f.selector)&&u()};e.addEventListener("click",m),p.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),p.push(()=>e.removeEventListener("submit",m));return}if(f.type==="scroll_depth"){let m=Math.max(0,Math.min(1,f.threshold)),g=new IntersectionObserver(a=>{for(let S of a)if(S.intersectionRatio>=m){u(!0),g.disconnect();break}},{threshold:[m]});g.observe(e),p.push(()=>g.disconnect())}}),()=>{for(let f of p)f()}}let i=t.type==="composite"?t.all:[t],l=new Set(i.map((s,p)=>p)),d=()=>{r!==void 0&&Lt(r)||n.fireGoal()},o=(s,p=!1)=>{l.delete(s),l.size===0&&(p?d():n.fireGoal())},y=[];return i.forEach((s,p)=>{if(s.type==="click"){let f=h=>{let k=h.target;k instanceof Element&&Dt(k,e,s.selector)&&(t.type==="composite"?o(p):n.fireGoal())};e.addEventListener("click",f),y.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(p):n.fireGoal())};e.addEventListener("submit",f),y.push(()=>e.removeEventListener("submit",f));return}if(s.type==="scroll_depth"){let f=Math.max(0,Math.min(1,s.threshold)),h=new IntersectionObserver(k=>{for(let c of k)if(c.intersectionRatio>=f){t.type==="composite"?o(p,!0):d(),h.disconnect();break}},{threshold:[f]});h.observe(e),y.push(()=>h.disconnect());return}}),()=>{for(let s of y)s()}}var It=new Set,Nt=new Set;function pe(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 ur={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function ce(){if(typeof window=="undefined")return ur;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(){ce().version+=1;for(let e of ce().listeners)e()}var Vt=()=>{};function Ft(e){return G()?(ce().components.set(e.id,e),_e(),()=>{ce().components.delete(e.id),_e()}):Vt}function ye(e){return G()?(ce().slots.set(e.id,e),_e(),()=>{ce().slots.delete(e.id),_e()}):Vt}function ot(e){G()&&(ce().sections=[...e],_e())}var Mt="0.35.0",st=Mt!=="0.0.0-dev"?{name:"react",version:Mt}:void 0;function cr(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function ve(e,t){cr()[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 dr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Se(e,t){dr()[e]=t}var jt="sentient_editor",Kt="sentient_preview_cell",Wt="sentient_refresh_region",at="sentient-cell-preview-bar",de="__preview__",he=null;function Jt(e){if((he==null?void 0:he.slotId)!==e)return null;let t=he;return he=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=>be(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>be("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(at))return;let t,n,r;try{let y=new URLSearchParams(window.location.search);t=y.get(jt),n=y.get(Kt),r=y.get(Wt)}catch(y){return}if(t&&r){he={slotId:r,token:t,base:(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"")},ve(r,{kind:"arms"}),Se(r,de),nt();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 y=>{if(!y.ok){be(y.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 y.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&$t(s.vocabulary),s.compose!=null)ve(l,{kind:"arms",compose:{[de]:s.compose}}),Se(l,de);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))ve(l,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),Se(l,de);else if(s.blocks!=null)ve(l,{kind:"arms",blocks:{[de]:s.blocks}}),Se(l,de);else if(s.content!=null)ve(l,{kind:"arms",content:s.content}),Se(l,de);else{be("Nothing to preview in that square yet.");return}nt(),be(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${l}"]`))==null||p.scrollIntoView({block:"center"})}catch(f){}},300)}).catch(()=>be("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function be(e){var i;if(document.getElementById(at))return;let t=document.createElement("div");t.id=at,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 fr="sentient_editor",zt=!1;function Xt(e){if(zt||typeof window=="undefined")return;let t=null;try{t=new URLSearchParams(window.location.search).get(fr)}catch(i){return}if(!t)return;zt=!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 gr(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,Ie.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 mr(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 y=()=>{var h;let p=r.current;if(!p)return!1;if(p.check)return p.check()===!0;if(!p.cookie||typeof document=="undefined")return!1;let f=`${p.cookie}=${(h=p.value)!=null?h:"accepted"}`;return document.cookie.split("; ").some(k=>k.trim()===f)};if(n(y()),!d)return;let s=()=>{n(y())};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 m;return(m=e.sessionSegment)!=null?m:gr()}),[i,l]=(0,C.useState)(et());(0,C.useEffect)(()=>Et(()=>l(et())),[]),(0,C.useEffect)(()=>{Ht(e.apiBaseUrl),Xt(e.apiBaseUrl)},[]);let d=mr(e.consentFrom),o=e.consentFrom?e.consent===!0||d:e.consent,y=(0,C.useRef)(null);(0,C.useEffect)(()=>{var A;if(o===!1&&!e.preConsentBehavior){(A=y.current)==null||A.destroy(),y.current=null,n(null);return}let m=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},st?{sdk:st}:{}),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(M(v({},m),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),y.current=a,n(a),x(a))}):(a=(0,Ie.init)(m),y.current=a,n(a),x(a)),()=>{g=!0,S==null||S(),a==null||a.dispose()}},[o]),(0,C.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 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()=>{m=!0,clearInterval(a)}},[t]);let s=(c=e.ssrFallback)!=null?c:"first",p=((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 m={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:p},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,p]),(0,C.useEffect)(()=>{var m;typeof process!="undefined"&&((m=process.env)==null?void 0:m.NODE_ENV)==="production"||Tt({apiKey:e.apiKey,apiBaseUrl:p,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,p]),(0,C.useEffect)(()=>{let m=e.initialLayoutOrder;if(m&&m.length>0){ot(m);return}e.declaredSections&&e.declaredSections.length>0&&ot(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,C.useEffect)(()=>{if(!G())return;let m=e.declaredSections;if(!m||m.length===0||typeof document=="undefined")return;let g=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),S=>S.getAttribute("data-sentient-id"))),a=m.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]),k=(0,C.useMemo)(()=>{var m,g,a,S,x,A,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:(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:p,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,p,e.debug]);return(0,an.jsx)(B.Provider,{value:k,children:e.children})}function I(){return(0,C.useContext)(B).client}function ne(){return(0,C.useContext)(B).apiKey}function Ne(){return(0,C.useContext)(B).initialAssignments}function Ve(){return(0,C.useContext)(B).sessionSegment}function Yt(){return(0,C.useContext)(B).ssrFallback}function Fe(){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 Me(){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 we=require("react");var N=require("react"),ln=require("@sentientui/core");var H=require("react"),$e=require("@sentientui/policy");function xe(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 Be(e,t,n,r){let i=Ne(),l=Yt(),d=I(),o=Ve(),y=Fe(),s=Qt(),p=(0,H.useRef)(null),f=(0,H.useSyncExternalStore)(J,()=>xe(e),()=>null),h=f&&t.includes(f)?f:null,k=(0,H.useRef)(null);(0,H.useEffect)(()=>{s&&h&&k.current!==h&&(k.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=Qe(e);if(a){let A=(0,$e.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}}),m=g=>{y&&p.current!==g&&(p.current=g,y(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}),m(g.variantId);return}let a=Qe(e);if(a&&c.settled&&c.variantId&&c.variantId===(0,$e.pickFromWeights)(a.variants,t)){m(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}),m(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}),m(a.variantId);return}let S=(0,$e.pickFromWeights)(g.variants,t);S&&(u({variantId:S,content:null,isLoading:!1,settled:!0}),m(S))})},[h,d,e,o]),h?{variantId:h,content:null,isLoading:!1,settled:!0,isOverride:!0}:c}function je(e,t,n){let r=I(),i=ne(),l=Object.keys(t).join("\0"),d=(0,N.useMemo)(()=>Object.keys(t),[l]),{variantId:o,content:y,isOverride:s=!1,settled:p}=Be(e,d,n.agentData,n.agentDataByVariant),[f,h]=(0,N.useState)(null),k=(0,N.useRef)(null),c=(0,N.useCallback)(O=>{k.current=O,h(O)},[]),u=n.goal,m=typeof u=="string"?u:JSON.stringify(u),g=(0,N.useMemo)(()=>u?U(u):null,[m]),a=u?se(u):"";(0,N.useEffect)(()=>Ft({id:e,variantIds:d,goal:a}),[e,d,a]);let S=(0,N.useRef)(null);(0,N.useEffect)(()=>{s||p&&(!r||!o||!i||!f||S.current!==o&&(S.current=o,ae(r,i,e,o)))},[r,o,i,e,f,s,p]);let x=(0,N.useRef)(!1),A=(0,N.useRef)(new Set);(0,N.useEffect)(()=>{x.current=!1,A.current=new Set},[o,g]);let E=n.funnel;(0,N.useEffect)(()=>{s||!p||!r||!E||!g||pe(r,i,e,E,g)},[r,i,e,E,g,s,p]);let b=n.cursorSignal===!0;(0,N.useEffect)(()=>{if(!b||s||!p||!r||!o||!f)return;let O=null,P=0,F=()=>{P=Date.now(),O=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:o,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-P}}),O=null},800)},L=()=>{O!==null&&(clearTimeout(O),O=null)};return f.addEventListener("mouseenter",F),f.addEventListener("mouseleave",L),()=>{f.removeEventListener("mouseenter",F),f.removeEventListener("mouseleave",L),O!==null&&clearTimeout(O)}},[b,r,o,i,e,f,s,p]);let R=(0,N.useRef)(n.microSignalGoals);R.current=n.microSignalGoals;let w=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,N.useEffect)(()=>{if(s||!p||!r||!o||!f)return;let O=Date.now();return(0,ln.attachMicroSignalDetectors)((P,F={})=>{var oe,ue,Y;r.track({projectId:i,componentId:e,variantId:o,eventType:"micro_signal",payload:v({signalType:P},F)});let L=(oe=R.current)==null?void 0:oe[P];if(!L||A.current.has(P))return;A.current.add(P);let q=typeof L=="string"?L:L.name,Z=typeof L=="string"?1:(ue=L.weight)!=null?ue:1,ie=typeof L=="string"?0:(Y=L.stepIndex)!=null?Y:0;r.goal(q,{metadata:v({signalType:P},F),weight:Z,stepIndex:ie})},f,O)},[r,o,i,e,f,w,s,p]),(0,N.useEffect)(()=>{if(s||!p||!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,F,L)=>{r.track({projectId:i,componentId:e,variantId:o,eventType:"goal_achieved",goalType:P,payload:{reward:F}}),r.goal(P,{metadata:{},weight:F,stepIndex:L})}},a)},[r,o,i,e,f,g,a,s,p]),{client:r,variantIds:d,variantId:o,content:y,settled:p,isOverride:s,goalLabel:a,ref:c,nodeRef:k}}var V=require("react"),Oe=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=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 l=(0,K.useRef)(t==null?void 0:t.skeleton);l.current=t==null?void 0:t.skeleton;let d=Me(),o=nn(),y=rn(),s=on(),p=(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),k=(0,K.useCallback)(b=>{var R,w;return(w=(R=n==null?void 0:n.onSlotsChanged)==null?void 0:R.call(n,b))!=null?w:(()=>{})},[n]);(0,K.useSyncExternalStore)(k,()=>{var b;return(b=n==null?void 0:n.getSlotConfig(e))!=null?b:null},()=>null),(0,K.useSyncExternalStore)(k,()=>h(n==null?void 0:n.getSlotResult(e)),()=>"");let c=p===void 0?o[e]:void 0,u=p===void 0&&c===void 0&&n?n.getSlotConfig(e):null,m=(x=y!=null?y: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,R,w;if(p!==void 0)return{config:p,arm:h(f),palette:m,vocabulary:(b=Bt())!=null?b:g,source:"override"};if(c!==void 0)return{config:c,arm:h((R=d[e])!=null?R: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:d[e]),palette:m,vocabulary:g,source:O?"client":"seeded"}}return{config:null,arm:"",palette:m,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",R=b&&(Z=(q=r.current)==null?void 0:q.call(r))!=null?Z:null,w=R!=null&&R!==""?{[e]:R}: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,F=v(v({},O?{render:{[e]:O}}:{}),P?{skeletons:{[e]:P}}:{}),L=Object.keys(F).length>0;return n.requestSlots?L?n.requestSlots([e],w,F):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)(()=>{!G()||(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 ut=require("react");var T=require("react/jsx-runtime"),le={none:"0",sm:"8px",md:"16px",lg:"24px"},lt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},pn={sm:"0.875em",md:"1em",lg:"1.25em"},pr={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"},yr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},vr={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 M(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 Sr({node:e,opts:t}){var i,l,d,o,y;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:(y=(o=t.palette)==null?void 0:o.radius)!=null?y:"8px"};return(0,T.jsxs)("form",{onSubmit:s=>{var h,k,c;s.preventDefault();let p=new FormData(s.currentTarget),f={};for(let u of e.fields)f[u.name]=String((h=p.get(u.name))!=null?h:"");(k=t.onFormGoal)==null||k.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 p,f;return(0,T.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?(0,T.jsx)("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?(0,T.jsx)("select",{name:s.name,required:s.required,style:r,children:((p=s.options)!=null?p:[]).map(h=>(0,T.jsx)("option",{value:h,children:h},h))}):(0,T.jsx)("input",{name:s.name,type:(f=s.inputType)!=null?f:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),(0,T.jsx)("button",{type:"submit",style:yn(n,t.palette),children:e.submitLabel})]})}function hr(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 fe(e,t){var n,r,i,l,d,o,y,s,p,f,h,k,c,u,m,g,a,S,x,A,E,b,R;try{let w=hr(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,F=(i=e.pad)!=null?i:P?"md":void 0;return(0,T.jsx)("div",M(v({},w?{className:w}:{}),{style:v(v(v(v(v({display:"flex",flexDirection:e.direction,gap:O},e.align?{alignItems:lt[e.align]}:{}),e.justify?{justifyContent:lt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),F?{padding:(l=le[F])!=null?l:le.md}:{}),P?M(v(v({},(d=t.palette)!=null&&d.surface?{background:t.palette.surface}:{}),(o=t.palette)!=null&&o.surface&&((y=t.palette)!=null&&y.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(p=(s=t.palette)==null?void 0:s.border)!=null?p:"currentColor"}`,borderRadius:(h=(f=t.palette)==null?void 0:f.radius)!=null?h:"8px"}):{}),children:((k=e.children)!=null?k:[]).map((L,q)=>{let Z=fe(L,t);return Z===null?null:(0,T.jsx)(ut.Fragment,{children:Z},q)})}))}case"grid":{let O=(u=le[(c=e.gap)!=null?c:"md"])!=null?u:le.md;return(0,T.jsx)("div",M(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:lt[e.align]}:{}),e.pad?{padding:(m=le[e.pad])!=null?m:le.md}:{}),children:((g=e.children)!=null?g:[]).map((P,F)=>{let L=fe(P,t);return L===null?null:(0,T.jsx)(ut.Fragment,{children:L},F)})}))}case"text":return w?(0,T.jsx)("p",{className:w,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,T.jsx)("p",{style:v(v(v(v(v({margin:0},e.size?{fontSize:pn[e.size]}:{}),e.weight?{fontWeight:vr[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,T.jsx)(O,{className:w,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,T.jsx)(O,{style:v(v({margin:0,fontSize:pr[(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,T.jsx)("a",M(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,T.jsx)("a",M(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,T.jsx)("img",M(v({src:e.src,alt:e.alt},w?{className:w}:{}),{style:v(v({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:yr[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return w?(0,T.jsx)("span",{className:w,children:e.value}):(0,T.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,T.jsx)("div",{style:{height:(E=gn[e.size])!=null?E:gn.md}});case"divider":return(0,T.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(R=(b=t.palette)==null?void 0:b.border)!=null?R:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,T.jsx)(Sr,{node:e,opts:t});default:return null}}catch(w){return null}}function Ke(e,t){var i,l,d;let n=fe(e.tree,t);if(n===null)return null;let r=(i=e.surface)!=null&&i.like?(d=(l=t.vocabulary)==null?void 0:l.entries.find(o=>o.id===e.surface.like))==null?void 0:d.classes:void 0;return r?(0,T.jsx)("div",{className:r,children:n}):n}var re=require("react"),We=require("@sentientui/core/region");function Je(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function Ue(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ge(e){return Je(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ge(n),0):(0,re.isValidElement)(e)?ge(Ue(e)):0}function br(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(Je(e))return t;if(Array.isArray(e))return e.map(n=>ct(n,t));if((0,re.isValidElement)(e)){let n=Ue(e);return ge(n)===0?e:br(e,ct(n,t))}return e}function vn(e,t){return ge(e)===1?ct(e,t):null}var W=e=>e.join("/");function dt(e,t,n){if(Je(e)){n.leafPaths.push(t),n.texts.push((0,We.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(Ue(e),[...t,"c"],n))}function gt(e){let t={leafPaths:[],texts:[],elements:new Map};return dt(e,[],t),t}function xr(e){return gt(e).texts}function Sn(e){let t=xr(e);return t.length===0?null:(0,We.skeletonFingerprint)(t)}function wr(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function hn(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,y)=>o===i?[wr(e.leafPaths[y])]:[]);if(l.length===0){r.push(null);continue}let d=l[0];for(let o of l.slice(1)){let y=new Set(o.map(W));d=d.filter(s=>y.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=hn(n,e.leafToNode),i=e.nodes.map((l,d)=>{let o=r[d],y=o?n.elements.get(W(o)):void 0,s=!!y&&(typeof y.type=="string"||ft(y)!==void 0);return M(v({},l),{restylable:s})});return M(v({},e),{nodes:i})}function bn(e,t,n){var c;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 l=hn(r,n),d=new Map;n.forEach((u,m)=>{d.has(u)||d.set(u,m)});let o=new Map(r.leafPaths.map((u,m)=>[W(u),m])),y=new Set,s=new Map,p=!1;for(let[u,m]of Object.entries(t.nodes)){let g=Number(u),a=l[g];if(m.hidden&&(a?y.add(W(a)):p=!0),m.like!==void 0){let S=l[m.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?p=!0:s.set(W(a),A)}}let f=new Map(Object.entries((c=t.order)!=null?c:{})),h=(u,m)=>{var g;if(Je(u)){let a=o.get(W(m));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,[...m,x]));for(let[S,x]of f){let A=x.map(R=>{let w=l[R];return!w||w.length!==m.length+1||W(w.slice(0,-1))!==W(m)?-1:w[w.length-1]});if(A.some(R=>R<0))continue;let E=[...A].sort((R,w)=>R-w),b=[...a];E.forEach((R,w)=>{a[R]=b[A[w]]}),f.delete(S)}return a}if((0,re.isValidElement)(u)){let a=W(m);if(y.has(a))return null;let S=Ue(u);if(ge(S)===0)return u;let x=h(S,[...m,"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},k=h(e,[]);return p||f.size>0?null:k}var An=require("react/jsx-runtime"),xn=new Set,wn=new Set,Rn=new Set,kn="authored.";function Ee({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:l,reportBaselineText:d=!0}){var ht,bt;let o=I(),y=ne(),s=(0,V.useRef)(null),p=(0,V.useMemo)(()=>Sn(t),[t]),f=n?Object.keys(n).join("|"):"",h=(0,V.useMemo)(()=>v({fp:p!=null?p:"0000000000000000",forms:!!r,compose:!0,content:ge(t)===1},f!==""?{authored:f.split("|"),children:!0}:{}),[p,t,r,f]),k=()=>{var Q;let _=s.current;if(!_||!d)return null;let D=(0,pt.captureRegionSkeleton)(_);return D.skeleton?(Q=mt(D.skeleton,t))!=null?Q:{status:"unaddressable"}:{status:D.reason}},{config:c,arm:u,palette:m,vocabulary:g,source:a}=dn(e,{baselineText:d?()=>{var _,D;return(D=(_=s.current)==null?void 0:_.textContent)!=null?D:null}:void 0,render:()=>h,skeleton:k}),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,Oe.containsFormBlock)(S)||x!==void 0&&(0,Oe.containsFormBlock)(x.tree))&&!r;(0,V.useEffect)(()=>{!A||!G()||xn.has(e)||(xn.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,R=!1,w=u.startsWith(kn)?u.slice(kn.length):null;if((c==null?void 0:c.blocked)==="variant_history")R=!0;else if(w!==null)n&&Object.prototype.hasOwnProperty.call(n,w)?b=n[w]:R=!0;else if(x!==void 0){let _=A?null:Ke(x,{palette:m,vocabulary:g,onFormSubmit:r,onFormGoal:E});_===null?R=!0:b=_}else if(S!==void 0){let _=A?null:fe(S,{palette:m,vocabulary:g,onFormSubmit:r,onFormGoal:E});_===null?R=!0:b=_}else if((c==null?void 0:c.edits)!==void 0&&a!=="none"){let _=c.edits,D=_.fp===p?bn(t,_.edits,_.leafToNode):null;D===null?R=!0:b=D}else if((c==null?void 0:c.content)!==void 0&&a!=="none"){let _=vn(t,c.content);_===null?R=!0:b=_}let O=R&&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,V.useEffect)(()=>{(c==null?void 0:c.blocked)!=="variant_history"||!G()||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&&!R?w:null;(0,V.useEffect)(()=>{var Ae;if(!P||!d||!o)return;let _=s.current;if(!_)return;let D=(0,pt.captureRegionSkeleton)(_),Q=D.skeleton?mt(D.skeleton,n==null?void 0:n[P]):null,ke=(Ae=_.textContent)==null?void 0:Ae.trim();o.reportSlots([],void 0,void 0,{[e]:[v(v({key:P},ke?{text:ke}:{}),Q?{skeleton:Q}:{})]})},[P,o,e]);let F=R&&(c==null?void 0:c.edits)!==void 0&&(a==="preloaded"||a==="client");(0,V.useEffect)(()=>{var _;!F||!(c!=null&&c.edits)||(_=o==null?void 0:o.reportDrift)==null||_.call(o,e,c.edits.fp,p,c.edits.fp===p?"unaddressable":"fp_mismatch")},[F,e,p,o]);let L=b===t;(0,V.useEffect)(()=>{var D;if(!(c!=null&&c.needsSkeleton)||!L)return;let _=k();_&&((D=o==null?void 0:o.reportSkeleton)==null||D.call(o,e,_))},[c==null?void 0:c.needsSkeleton,L,e,o]),(0,V.useEffect)(()=>{if(!L)return;let _=Jt(e);if(!_)return;let D=k();Ut(_,D&&"status"in D?{status:D.status}:{skeleton:D})},[e,L]),(0,V.useEffect)(()=>{!O||!G()||wn.has(e)||(wn.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,V.useEffect)(()=>ye({id:e,arms:q===""?void 0:q.split("|")}),[e,q]);let Z=(0,V.useRef)(null);(0,V.useEffect)(()=>{!o||a==="none"||a==="seeded"||a==="override"||u===""||R||Z.current!==u&&(Z.current=u,ae(o,y,e,u))},[o,y,e,u,a,R]);let ie=a!=="none"&&a!=="seeded"&&!R,oe=ie?u:"",ue=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);(0,V.useEffect)(()=>{if(!o||!i||a==="override")return;let _=s.current;if(!_)return;let D=se(i),Q=ee(i),ke=!1;return te(_,U(i),{fireGoal:()=>{ke||(ke=!0,ie&&(Q!==void 0?o.componentGoal(e,D,{value:Q}):o.componentGoal(e,D)),o.goal(D,v({metadata:{componentId:e,arm:oe},weight:1,stepIndex:0},Q!==void 0?{value:Q}:{})))},fireStep:(Ae,xt,Yn)=>{ie&&o.componentGoal(e,Ae,{reward:xt}),o.goal(Ae,{metadata:{componentId:e,arm:oe},weight:xt,stepIndex:Yn})}},D)},[o,e,ue,u,a,R,ie,oe]);let Y=(0,V.useRef)(null);(0,V.useEffect)(()=>{let _=s.current;if(_){if(Y.current===null){Y.current=u;return}Y.current!==u&&(Y.current=u,(0,Oe.reveal)(_))}},[u]);let Zn=(0,V.useMemo)(()=>v({"data-sentient-slot":e},u!==""?{"data-sentient-arm":u}:{}),[e,u]);return(0,An.jsx)("div",M(v({ref:s,className:l},Zn),{children:b}))}var Pe=require("react/jsx-runtime");function Rr(e){var s;let{client:t,variantId:n,content:r,ref:i}=je(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[l,d]=(0,we.useState)(!1);if((0,we.useEffect)(()=>{d(!0)},[]),e.clientOnly&&(!l||!t)||!n)return null;let o=(s=e.variants[n])!=null?s:null,y=o===null?r:null;return G()&&o===null&&y===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,Pe.jsx)("div",{ref:i,"data-sentient-id":e.id,"data-sentient-variant":n,children:o!=null?o:y})}var kr=(0,we.memo)(Rr,(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 _n(e){if(e.variants===void 0)return(0,Pe.jsx)(Ee,v({},e));let t=e;if(t.children!=null){G()&&Ar(t);let n=t,{funnel:r,microSignalGoals:i,agentData:l,agentDataByVariant:d,clientOnly:o,variants:y}=n,s=Le(n,["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly","variants"]);return(0,Pe.jsx)(Ee,M(v({},s),{children:t.children,variants:y}))}return(0,Pe.jsx)(kr,v({},t))}var Cn=new Set;function Ar(e){let t=["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly"].filter(n=>e[n]!==void 0);t.length===0||Cn.has(e.id)||(Cn.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 En=require("react/jsx-runtime");function On({id:e,default:t,component:n="span",className:r,goal:i}){var E;let l=I(),d=ne(),o=Fe(),y=Ve(),s=(0,$.useRef)(null),p=(0,$.useRef)(null),f=(0,$.useSyncExternalStore)(J,()=>xe(e),()=>null),[h,k]=(0,$.useState)(()=>{var b,R;return(R=(b=l==null?void 0:l.getAssignment(e,y))==null?void 0:b.content)!=null?R:null}),[c,u]=(0,$.useState)(()=>{var b,R;return(R=(b=l==null?void 0:l.getAssignment(e,y))==null?void 0:b.variantId)!=null?R:null});(0,$.useEffect)(()=>{if(f||!l)return;let b=l.getAssignment(e,y);if((b==null?void 0:b.content)!==void 0){u(b.variantId),k(b.content);return}let R=!1;return l.assign(e).then(w=>{if(!R){if(!w){G()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}u(w.variantId),w.content&&k(w.content)}}),()=>{R=!0}},[l,e,y,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 m=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),g=(0,$.useMemo)(()=>i===void 0?null:U(i),[m]),a=i===void 0?null:typeof i=="string"?i:g.type,S=(0,$.useRef)(!1);(0,$.useEffect)(()=>{S.current=!1},[c,m]),(0,$.useEffect)(()=>{if(f||!l||!c||!d||!g||!a)return;let b=p.current;if(!b)return;let R=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},R!==void 0?{goalValue:R}:{})}),l.goal(a,v({metadata:{componentId:e,variantId:c},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},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,y);x=b&&b.variantId===f&&(E=b.content)!=null?E:t}return(0,En.jsx)(n,{ref:b=>{p.current=b},className:r,children:x})}var He=require("react");function ze(e){let t=I(),n=(0,He.useRef)(new Set);return(0,He.useCallback)((r,i)=>{var l,d;if(!xe(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 Ge=require("react");function Pn(e,t={}){let y=t,{componentId:n}=y,r=Le(y,["componentId"]),i=I(),l=ze(n!=null?n:""),d=(0,Ge.useRef)(!1),o=(0,Ge.useRef)(r);o.current=r,(0,Ge.useEffect)(()=>{if(!i||d.current)return;d.current=!0;let{metadata:s,reward:p,value:f,currency:h,externalId:k}=o.current;if(n){l(e,o.current);return}i.goal(e,v(v(v({metadata:s!=null?s:{},weight:p!=null?p:1,stepIndex:0},f!==void 0?{value:f}:{}),h!==void 0?{currency:h}:{}),k!==void 0?{externalId:k}:{}))},[i,n,e,l])}var Tn=require("@sentientui/core"),Ln=require("@sentientui/policy"),In=require("react/jsx-runtime");function Gn(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Cr(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Gn(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Gn((0,Ln.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,Tn.renderPrePaintScript)(e.apiKey)}function Dn(e){return(0,In.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Cr(e)}})}var X=require("react"),Mn=require("@sentientui/policy");var z=require("react"),me=require("@sentientui/core"),Nn=require("@sentientui/policy");function Xe(e,t){let n=I(),r=Me(),[,i]=(0,z.useReducer)(f=>f+1,0),l=(0,z.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,y=(n==null?void 0:n.isLocal)===!0&&l===void 0&&d===void 0&&o===null;(0,z.useEffect)(()=>{if(!y||!n)return;let f=!1;return n.decide({slots:[t]}).then(h=>{!f&&h&&i()}),()=>{f=!0}},[n,e,y]);let s=(()=>{if(l!==void 0)return{result:l,arm:(0,me.armOfResult)(l),source:"override"};if(d!==void 0)return{result:d,arm:(0,me.armOfResult)(d),source:"preloaded"};if(o!==null){let h=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:o,arm:(0,me.armOfResult)(o),source:h?"client":"seeded"}}let f=(0,me.baselineResultFor)(t);return{result:f,arm:(0,me.armOfResult)(f),source:"baseline"}})(),p=s.source==="preloaded"||s.source==="override";return(0,z.useEffect)(()=>{var h;if(!n||n.isLocal===!0||p||!n.decideSlots)return;let f=(h=n.onSlotsChanged)==null?void 0:h.call(n,i);return n.decideSlots([t]),()=>{var k;(k=n.cancelSlots)==null||k.call(n,[e]),f==null||f()}},[n,e,p]),s}function _r(){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 Vn(){let e=I(),t=tn();(0,z.useSyncExternalStore)(J,Gt,()=>0);let[n,r]=(0,z.useState)(!1);(0,z.useEffect)(()=>r(!0),[]);let i=o=>({persona:o.persona,confidence:o.confidence,band:(0,Nn.confidenceBand)(o.confidence)});if(!n)return t?i(t):null;let l=_r();if(l)return i(l);if(t)return i(t);let d=e?e.getPersona():null;return d?i(d):null}var Fn=new Set;function Or(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function $n(e,t,n){let r=I(),i=ne(),l=JSON.stringify(t),d=(0,X.useMemo)(()=>({id:e,dims:t}),[e,l]),{result:o,arm:y,source:s}=Xe(e,d),p=(0,X.useMemo)(()=>typeof o=="string"?{}:o,[y]);if(G()&&!Fn.has(e)){Fn.add(e);let u=(0,Mn.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([g,a])=>[g,[...a]]))}),m=Object.values(t).reduce((g,a)=>g*a.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,X.useEffect)(()=>ye({id:e,dims:t}),[e]);let h=(0,X.useRef)(null);(0,X.useEffect)(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||h.current===y||(h.current=y,ae(r,i,e,y))},[r,i,e,y,s]);let k=n==null?void 0:n.funnel;(0,X.useEffect)(()=>{var u;!r||!k||s==="override"||pe(r,i,e,k,U((u=n==null?void 0:n.goal)!=null?u:"click"))},[r,i,e,k,f,s]),(0,X.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let u=document.querySelector(`[data-sentient-slot="${Or(e)}"]`);if(!u){G()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let m=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,m,{value:g}):r.componentGoal(e,m),r.goal(m,v({metadata:{componentId:e,arm:y},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:y},weight:x,stepIndex:A})}},m)},[r,e,f,y,s]);let c=(0,X.useMemo)(()=>{let u={"data-sentient-slot":e};for(let[m,g]of Object.entries(p))u[`data-${m}`]=g;return u},[e,p]);return{tokens:p,props:c}}var Re=require("react");var Bn=new Set;function jn(e,t){var k;if(G()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:l,goalLabel:d,ref:o,nodeRef:y}=je(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(k=i!=null?i:r[0])!=null?k:"",p=t.variants[s];(0,Re.useEffect)(()=>{if(!G()||!n)return;let c=setTimeout(()=>{!y.current&&!Bn.has(e)&&(Bn.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 m=c!=null?c:d;m&&(n==null||n.componentGoal(e,m,u),n==null||n.goal(m,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:p,bind:h,fireGoal:f}}var j=require("react");var Wn=require("react/jsx-runtime"),qe=new Set;function Kn(e){var g;let t=I(),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:y}=Xe(e.id,d);G()&&e.baseline!==void 0&&e.baseline!==l[0]&&!qe.has(e.id+":baseline")&&(qe.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),p=new Map;for(let a of s)p.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=>p.has(a));G()&&f!==void 0&&!h&&!qe.has(e.id+":keys")&&(qe.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 k=h?f.map(a=>p.get(a)):s;(0,j.useEffect)(()=>ye({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let c=(0,j.useRef)(null);(0,j.useEffect)(()=>{!t||y==="baseline"||y==="seeded"||y==="override"||c.current===o||(c.current=o,ae(t,n,e.id,o))},[t,n,e.id,o,y]);let u=e.funnel;(0,j.useEffect)(()=>{var a;!t||!u||y==="override"||pe(t,n,e.id,u,U((a=e.goal)!=null?a:"click"))},[t,n,e.id,u,y]);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||y==="override"||y==="baseline"||y==="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,R)=>{t.componentGoal(e.id,E,{reward:b}),t.goal(E,{metadata:{componentId:e.id,arm:o},weight:b,stepIndex:R})}},S)},[t,e.id,m,o,y]),(0,Wn.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":o,children:k})}var yt=require("@sentientui/core");var Er=["page","blocks","layoutOrder"],Jn=new Map;function Un(e,t){Jn.set(e,t)}function vt(e){return Jn.get(e)}function Hn(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))Er.includes(d)||(n[d]=o);let r=M(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 Xn(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
|
-
`}var
|
|
4
|
+
`}var qn=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
|