@sentientui/react 0.42.4 → 0.44.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/README.md +100 -21
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/next/adaptive-root.d.ts +13 -1
- package/dist/next/adaptive-root.js +2 -2
- package/dist/next/adaptive-root.js.map +1 -1
- package/dist/server.d.cts +7 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +1 -1
- package/dist/server.mjs.map +1 -1
- package/dist/testing/react.js +1 -1
- package/dist/testing/react.js.map +1 -1
- package/dist/testing/react.mjs +1 -1
- package/dist/testing/react.mjs.map +1 -1
- package/dist/version-preview.d.cts +19 -0
- package/dist/version-preview.d.ts +19 -0
- package/dist/version-preview.js +3 -0
- package/dist/version-preview.js.map +1 -0
- package/dist/version-preview.mjs +3 -0
- package/dist/version-preview.mjs.map +1 -0
- package/llms.txt +5 -0
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -14,8 +14,8 @@ npm install @sentientui/react # or: npx @sentientui/cli init (installs + wri
|
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
npx @sentientui/cli init
|
|
17
|
-
# then follow its printed instructions: wrap your app with <
|
|
18
|
-
#
|
|
17
|
+
# then follow its printed instructions: wrap your app with <AdaptiveProvider>
|
|
18
|
+
# and mount the generated components/adaptive-example.tsx
|
|
19
19
|
npm run dev
|
|
20
20
|
# open http://localhost:3000?sentient_persona=a, then ?sentient_persona=b — <html data-sentient-persona> follows it
|
|
21
21
|
```
|
|
@@ -36,33 +36,68 @@ NEXT_PUBLIC_SENTIENT_API_KEY=pk_your_key
|
|
|
36
36
|
|
|
37
37
|
## Setup
|
|
38
38
|
|
|
39
|
-
Wrap your root layout (Next App Router
|
|
39
|
+
Wrap your root layout (Next App Router):
|
|
40
40
|
|
|
41
41
|
```tsx
|
|
42
42
|
// app/layout.tsx
|
|
43
|
-
import {
|
|
43
|
+
import { AdaptiveProvider } from '@sentientui/react';
|
|
44
44
|
|
|
45
45
|
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
46
46
|
return (
|
|
47
|
-
<html lang="en"
|
|
47
|
+
<html lang="en">
|
|
48
48
|
<body>
|
|
49
|
-
<
|
|
50
|
-
apiKey={process.env.NEXT_PUBLIC_SENTIENT_API_KEY!}
|
|
51
|
-
appOrigin={process.env.NEXT_PUBLIC_APP_URL!}
|
|
52
|
-
>
|
|
49
|
+
<AdaptiveProvider apiKey={process.env.NEXT_PUBLIC_SENTIENT_API_KEY!}>
|
|
53
50
|
{children}
|
|
54
|
-
</
|
|
51
|
+
</AdaptiveProvider>
|
|
55
52
|
</body>
|
|
56
53
|
</html>
|
|
57
54
|
);
|
|
58
55
|
}
|
|
59
56
|
```
|
|
60
57
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
That is the whole setup, and **your pages stay static and cached**: the provider reads nothing
|
|
59
|
+
from the request, so Next.js keeps prerendering every route under it. Decisions happen in the
|
|
60
|
+
browser — a first visit shows the original, then the chosen version after one round trip; a
|
|
61
|
+
return visit starts from the last version served, with no network wait. It can be rendered
|
|
62
|
+
straight from a Server Component, as above. To pass it a function (`onAssignment`, a
|
|
63
|
+
`consentFrom` with `check()`), put it in a small `'use client'` file of your own instead.
|
|
64
|
+
|
|
65
|
+
**Want the chosen version in the first HTML, with no swap?** Use `<AdaptiveRoot>` from
|
|
66
|
+
`@sentientui/react/next` — but only around the pages that adapt, never as the default in the
|
|
67
|
+
root layout:
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
// app/pricing/page.tsx — only this route pays for it
|
|
71
|
+
import { AdaptiveRoot } from '@sentientui/react/next';
|
|
72
|
+
|
|
73
|
+
export default function PricingPage() {
|
|
74
|
+
return (
|
|
75
|
+
<AdaptiveRoot
|
|
76
|
+
apiKey={process.env.NEXT_PUBLIC_SENTIENT_API_KEY!}
|
|
77
|
+
appOrigin={process.env.NEXT_PUBLIC_APP_URL!}
|
|
78
|
+
registrySlotIds={['pricing-plans']}
|
|
79
|
+
timeoutMs={300}
|
|
80
|
+
>
|
|
81
|
+
<Pricing />
|
|
82
|
+
</AdaptiveRoot>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`<AdaptiveRoot>` decides on the server, so it reads the request (`headers()`, `cookies()`), and
|
|
88
|
+
**every route under it renders on demand — none of them can be statically generated or cached at
|
|
89
|
+
the edge** — and waits for one API round trip before sending HTML. In the root layout that is
|
|
90
|
+
your whole site: a marketing site that was served from the edge cache becomes an uncached server
|
|
91
|
+
render on every page, for the benefit of the one page that adapts. Keep it to those pages (a
|
|
92
|
+
route group's `layout.tsx` works for several), and do not nest it inside the root layout's
|
|
93
|
+
`<AdaptiveProvider>` — a page under `<AdaptiveRoot>` belongs in a route group whose layout does
|
|
94
|
+
not render the provider. See [What `<AdaptiveRoot>` costs your rendering](#what-adaptiveroot-costs-your-rendering).
|
|
95
|
+
|
|
96
|
+
With `<AdaptiveRoot>`, `suppressHydrationWarning` on `<html>` is required: an inline script
|
|
97
|
+
(rendered by `AdaptiveRoot` as its first child) sets the persona attributes before first paint,
|
|
98
|
+
exactly like the `next-themes` pattern. `<AdaptiveProvider>` apps (the setup above, Vite, CRA,
|
|
99
|
+
Remix, Pages Router) take the same props — **plus `<SentientPersonaScript />` rendered in your
|
|
100
|
+
document `<head>`** (with `suppressHydrationWarning` on `<html>`) if you want the Rung-1a persona
|
|
66
101
|
attributes: only that inline script (which `AdaptiveRoot` includes for you) writes
|
|
67
102
|
`data-sentient-persona` / `data-sentient-confidence` in hosted mode. Without it, an
|
|
68
103
|
`AdaptiveProvider` app gets everything except the persona CSS hooks. (Keyless local mode writes
|
|
@@ -171,6 +206,13 @@ children:
|
|
|
171
206
|
/>
|
|
172
207
|
```
|
|
173
208
|
|
|
209
|
+
**Variant keys are versions, not audiences.** Naming a version `developer` does not show it to
|
|
210
|
+
developers — the optimizer may show any version to any visitor. To show `developer` to your
|
|
211
|
+
Developers: declare the persona on your site (`persona` on `<AdaptiveProvider>`, `init({ persona })`
|
|
212
|
+
or `window.sentient.persona`), then pin the version to that audience — Migrate the component in
|
|
213
|
+
Components and accept "Show each version to the audience it's named after?", or pin it
|
|
214
|
+
later from the banner there. Pinned visitors always see that version and don't teach the optimizer.
|
|
215
|
+
|
|
174
216
|
Use one or the other on a given `<Adaptive>`, not both. `useAdaptive` is the hook form of code
|
|
175
217
|
variants:
|
|
176
218
|
|
|
@@ -235,7 +277,8 @@ Imported from `@sentientui/react/next`.
|
|
|
235
277
|
| `searchParams` | page `searchParams` *(optional)* | Pass the page's `searchParams` on landing pages that get ad traffic: a Server Component can't read the request URL, so without it the SSR session carries no `utm_*` or click IDs. |
|
|
236
278
|
| `pathname` | `string` *(optional)* | The page's path, e.g. `/products/trail-shoe`. Pass it with `searchParams` on landing pages that get ad or email traffic, so a paid click to a product page or a `/discount/` link is recognised on the server render. |
|
|
237
279
|
| `context` | `'landing' \| 'ecommerce' \| 'saas' \| 'marketplace'` *(optional, deprecated)* | Unused — the project's type is set in the dashboard. Safe to omit. |
|
|
238
|
-
| `persona` | `string` *(optional)* | Declared persona — the role your app already knows for this visitor (e.g. from your auth context). Must be a key in the project's persona vocabulary (dashboard →
|
|
280
|
+
| `persona` | `string` *(optional)* | Declared persona — the role your app already knows for this visitor (e.g. from your auth context). Must be a key in the project's persona vocabulary (dashboard → Audiences); unrecognized values are ignored server-side. Served at full confidence, overriding the inferred persona; forwarded through both SSR paths. Stable for the session — remount to apply a new value. Never a user id or email. |
|
|
281
|
+
| `internal` | `boolean` *(optional)* | Your own team or a test site: served versions as usual, left out of reports and learning. Forwarded through both SSR paths, along with the request's `sentient_internal` browser-link cookie. See [Excluding your team and test sites](#excluding-your-team-and-test-sites). |
|
|
239
282
|
| `consent` | `boolean` *(default `true`)* | Set `false` to skip SDK init (no cookies, no events). Flip to `true` after the visitor accepts. |
|
|
240
283
|
| `respectDoNotTrack` | `boolean` *(default `true`)* | Honor the browser's Do Not Track signal. When on and DNT is enabled, the SDK sets no cookies and sends no tracking data (overriding `consent: true`), and `grantConsent()` won't re-enable it. Set `false` to make your own consent gate authoritative. |
|
|
241
284
|
| `consentFrom` | preset or `{ cookie, value, event }` *(optional)* | Your consent platform — see [Consent management](#consent-management-gdpr). Cookie-based sources are also read on the server, so a consented visitor gets personalized HTML and a non-consented one gets none. |
|
|
@@ -253,17 +296,24 @@ Imported from `@sentientui/react/next`.
|
|
|
253
296
|
(default 1000 ms). On timeout the page renders the originals and decides in the browser instead.
|
|
254
297
|
- **It skips the round trip entirely** for visitors it must not track (DNT/GPC, consent refused or not yet given).
|
|
255
298
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
visitor's last decision is restored from the SDK's local snapshot as
|
|
259
|
-
wait), and a first-time visitor's arrives after one round trip.
|
|
299
|
+
So it belongs around the pages that adapt, not in the root layout. Everywhere else use
|
|
300
|
+
`<AdaptiveProvider>` ([Setup](#setup)): decisions then happen in the browser after hydration — the server
|
|
301
|
+
HTML shows the originals, a returning visitor's last decision is restored from the SDK's local snapshot as
|
|
302
|
+
soon as the client starts (no network wait), and a first-time visitor's arrives after one round trip.
|
|
303
|
+
|
|
304
|
+
Two things only `<AdaptiveRoot>` does, because only a server render sees the request: logging AI-agent
|
|
305
|
+
fetches (`captureAgents`) and the crawler-readable `agentFeed` block. A static page has neither.
|
|
306
|
+
|
|
307
|
+
It also makes a visit for every server render, automated ones included — a crawler that never runs your
|
|
308
|
+
JavaScript still reaches your server. Under `<AdaptiveProvider>` a visit starts when a browser runs the
|
|
309
|
+
page.
|
|
260
310
|
|
|
261
311
|
`@sentientui/react/next` is ESM-only (the App Router always loads it as ESM). The package root and
|
|
262
312
|
`/server` ship both ESM and CommonJS.
|
|
263
313
|
|
|
264
314
|
### `<AdaptiveProvider>` (any React app)
|
|
265
315
|
|
|
266
|
-
Accepts the same `apiKey`, `persona`, `consent`, `debug` props as `<AdaptiveRoot>`, plus `onAssignment` (not available on `<AdaptiveRoot>` — function props can't cross the RSC boundary) and:
|
|
316
|
+
Accepts the same `apiKey`, `persona`, `internal`, `consent`, `debug` props as `<AdaptiveRoot>`, plus `onAssignment` (not available on `<AdaptiveRoot>` — function props can't cross the RSC boundary) and:
|
|
267
317
|
|
|
268
318
|
| Prop | Type | Description |
|
|
269
319
|
|------|------|-------------|
|
|
@@ -693,6 +743,35 @@ await trackServerGoal({
|
|
|
693
743
|
|
|
694
744
|
`trackServerGoal` resolves `'recorded'`, `'skipped_no_visitor'` (no id, so nothing is sent) or `'failed'`. It never throws. Sending the same `name` and `dedupeKey` for the same visitor again, for example when a webhook is redelivered, counts once. The id is scoped to the visitor's session, so another site using the same order number never collides with yours. It refuses to run in a browser and never sends the secret key there.
|
|
695
745
|
|
|
746
|
+
## Excluding your team and test sites
|
|
747
|
+
|
|
748
|
+
Visits from your own team, staging and local development can be left out of every number and out of learning. They are still served versions as usual, so you can keep testing on any site. You can also list internal sites and team emails in the dashboard (Settings).
|
|
749
|
+
|
|
750
|
+
**1. A flag in your code.** You already know who is signed in:
|
|
751
|
+
|
|
752
|
+
```tsx
|
|
753
|
+
<AdaptiveRoot apiKey="pk_…" internal={user.email.endsWith('@example.com')}>
|
|
754
|
+
{children}
|
|
755
|
+
</AdaptiveRoot>
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
`<AdaptiveProvider internal>` works the same way. The check runs in your code, so the email never leaves your site: only `internal: true` is sent. Once a visit is marked it stays marked, and `false` later on does not unmark it. The value is read once, when the client starts. If your user loads after the provider mounts, the later `true` is ignored (a development warning says so). Work it out on the server, as `<AdaptiveRoot>` lets you, or remount the provider.
|
|
759
|
+
|
|
760
|
+
**2. `identify(userId, { email })`.** For the team-email rules you set in the dashboard (`name@example.com` or `@example.com`):
|
|
761
|
+
|
|
762
|
+
```tsx
|
|
763
|
+
<AdaptiveProvider apiKey="pk_…" identity={{ userId: user.id, email: user.email }}>
|
|
764
|
+
// or: useSentient()?.identify(user.id, { email: user.email })
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
The SDK trims and lowercases the email, then sends its SHA-256 hash and its domain (for example `example.com`). The address itself is never sent, logged or stored. On a page served over plain `http:` the browser has no hashing API, so only the domain is sent there.
|
|
768
|
+
|
|
769
|
+
**3. A browser link.** Settings gives your project a link like `https://your-site.com/?sentient_internal=<token>`. Opening it once in a browser stores a first-party `sentient_internal` cookie (one year, on the same domain as the visitor cookie) and removes the parameter from the address bar. From then on every visit from that browser is marked, including server-rendered requests (`<AdaptiveRoot>`, `loadAdaptiveDecision` and `loadAdaptiveAssignments` read the cookie). `?sentient_internal=off` removes it. Rotating the link in Settings unmarks every browser at once.
|
|
770
|
+
|
|
771
|
+
A visit marked internal before it is scored never trains your versions. One marked later (a late `identify`, a rule added afterwards) drops out of reports on the next read, but anything it already taught a version stays.
|
|
772
|
+
|
|
773
|
+
These props need a SentientUI API that knows internal traffic. Older APIs ignore them, so adding them early is harmless. Visitors who have not consented are not tracked, so nothing is sent or stored for them.
|
|
774
|
+
|
|
696
775
|
## Graph scanning & engagement capture (on by default)
|
|
697
776
|
|
|
698
777
|
DOM graph scanning and behavioral engagement capture are **on by default** — no props needed. The SDK:
|
package/dist/index.d.cts
CHANGED
|
@@ -180,7 +180,19 @@ type AdaptiveProviderProps = {
|
|
|
180
180
|
identity?: {
|
|
181
181
|
userId: string;
|
|
182
182
|
userHash?: string;
|
|
183
|
+
email?: string;
|
|
183
184
|
};
|
|
185
|
+
/**
|
|
186
|
+
* Your own team or a test site: the visit is served versions as usual (QA
|
|
187
|
+
* keeps working) but left out of every report and out of learning. Compute
|
|
188
|
+
* it in your code — `internal={user.email.endsWith('@example.com')}` — and
|
|
189
|
+
* only `internal: true` is sent, never the email. Read once when the client
|
|
190
|
+
* starts (like `persona`): a value that arrives later (auth still loading)
|
|
191
|
+
* is ignored, so decide it before the provider mounts or remount it.
|
|
192
|
+
* Sticky server-side. Needs a SentientUI API that knows internal traffic;
|
|
193
|
+
* older ones ignore it.
|
|
194
|
+
*/
|
|
195
|
+
internal?: boolean;
|
|
184
196
|
/**
|
|
185
197
|
* ISO 3166-1 alpha-2 country code. Pass the value of the `CF-IPCountry`
|
|
186
198
|
* header from your Next.js server component to populate country on landing
|
|
@@ -190,7 +202,7 @@ type AdaptiveProviderProps = {
|
|
|
190
202
|
/**
|
|
191
203
|
* Declared persona — the role your app already knows for this visitor
|
|
192
204
|
* (e.g. 'admin', 'evaluator'). Must be a key in the project's persona
|
|
193
|
-
* vocabulary (dashboard →
|
|
205
|
+
* vocabulary (dashboard → Audiences); unrecognized values are
|
|
194
206
|
* ignored server-side and surfaced in the dashboard. Served at full
|
|
195
207
|
* confidence, overriding the inferred persona. Stable for the session —
|
|
196
208
|
* like `country`, changing it after init is ignored (decisions are locked
|
package/dist/index.d.ts
CHANGED
|
@@ -180,7 +180,19 @@ type AdaptiveProviderProps = {
|
|
|
180
180
|
identity?: {
|
|
181
181
|
userId: string;
|
|
182
182
|
userHash?: string;
|
|
183
|
+
email?: string;
|
|
183
184
|
};
|
|
185
|
+
/**
|
|
186
|
+
* Your own team or a test site: the visit is served versions as usual (QA
|
|
187
|
+
* keeps working) but left out of every report and out of learning. Compute
|
|
188
|
+
* it in your code — `internal={user.email.endsWith('@example.com')}` — and
|
|
189
|
+
* only `internal: true` is sent, never the email. Read once when the client
|
|
190
|
+
* starts (like `persona`): a value that arrives later (auth still loading)
|
|
191
|
+
* is ignored, so decide it before the provider mounts or remount it.
|
|
192
|
+
* Sticky server-side. Needs a SentientUI API that knows internal traffic;
|
|
193
|
+
* older ones ignore it.
|
|
194
|
+
*/
|
|
195
|
+
internal?: boolean;
|
|
184
196
|
/**
|
|
185
197
|
* ISO 3166-1 alpha-2 country code. Pass the value of the `CF-IPCountry`
|
|
186
198
|
* header from your Next.js server component to populate country on landing
|
|
@@ -190,7 +202,7 @@ type AdaptiveProviderProps = {
|
|
|
190
202
|
/**
|
|
191
203
|
* Declared persona — the role your app already knows for this visitor
|
|
192
204
|
* (e.g. 'admin', 'evaluator'). Must be a key in the project's persona
|
|
193
|
-
* vocabulary (dashboard →
|
|
205
|
+
* vocabulary (dashboard → Audiences); unrecognized values are
|
|
194
206
|
* ignored server-side and surfaced in the dashboard. Served at full
|
|
195
207
|
* confidence, overriding the inferred persona. Stable for the session —
|
|
196
208
|
* like `country`, changing it after init is ignored (decisions are locked
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var Vr=Object.create;var Ve=Object.defineProperty,Mr=Object.defineProperties,jr=Object.getOwnPropertyDescriptor,$r=Object.getOwnPropertyDescriptors,Br=Object.getOwnPropertyNames,He=Object.getOwnPropertySymbols,Ur=Object.getPrototypeOf,ht=Object.prototype.hasOwnProperty,rn=Object.prototype.propertyIsEnumerable;var nn=(e,t,n)=>t in e?Ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))ht.call(t,n)&&nn(e,n,t[n]);if(He)for(var n of He(t))rn.call(t,n)&&nn(e,n,t[n]);return e},V=(e,t)=>Mr(e,$r(t));var Me=(e,t)=>{var n={};for(var r in e)ht.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&He)for(var r of He(e))t.indexOf(r)<0&&rn.call(e,r)&&(n[r]=e[r]);return n};var Wr=(e,t)=>{for(var n in t)Ve(e,n,{get:t[n],enumerable:!0})},on=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Br(t))!ht.call(e,i)&&i!==n&&Ve(e,i,{get:()=>t[i],enumerable:!(r=jr(t,i))||r.enumerable});return e};var Xe=(e,t,n)=>(n=e!=null?Vr(Ur(e)):{},on(t||!e||!e.__esModule?Ve(n,"default",{value:e,enumerable:!0}):n,e)),Kr=e=>on(Ve({},"__esModule",{value:!0}),e);var ki={};Wr(ki,{Adaptive:()=>lr,AdaptiveGroup:()=>_r,AdaptiveProvider:()=>In,AdaptiveSlot:()=>Ie,AdaptiveText:()=>ur,SentientPersonaScript:()=>vr,buildAgentFeed:()=>Pr,consentWatcher:()=>Dr.consentWatcher,defineAgentContent:()=>Er,detectSegment:()=>$t.deriveSessionSegment,getAgentContent:()=>Bt,grantConsent:()=>Ir.grantConsent,renderAgentJsonLd:()=>Nr,renderAgentJsonLdBody:()=>Ut,renderAgentMarkdown:()=>Tr,renderBlocks:()=>xe,renderCompose:()=>st,useAdaptive:()=>Cr,useAdaptiveApiBaseUrl:()=>Bn,useAdaptiveGoal:()=>De,useAdaptivePersona:()=>br,useAdaptiveTokens:()=>kr,useAssignment:()=>it,useGoal:()=>mr,useInitialAssignments:()=>Qe,useLayoutOrder:()=>Fn,usePageGoal:()=>dr,useSentient:()=>M,useSessionSegment:()=>Te});module.exports=Kr(ki);var C=require("react"),Ze=require("@sentientui/core");var sn=new Map,ze=new Map;function an(e,t){let n=ze.get(e);return n||(n=new Set,ze.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&ze.delete(e)}}function ln(e,t){sn.set(e,t);let n=ze.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function bt(e){var t;return(t=sn.get(e))!=null?t:null}var Jr={on:!1,listeners:new Set};function un(){if(typeof window=="undefined")return Jr;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function wt(){return un().on}function cn(e){let t=un().listeners;return t.add(e),()=>{t.delete(e)}}function dn(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,o)=>e.assign(t,n,r,i,o),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var xt="sentient:overrides-changed";function fn(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function kt(){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(xt))}function Q(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(xt,e),()=>window.removeEventListener(xt,e))}function gn(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function F(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function te(e){return typeof e=="string"?{type:"click"}:e}function pe(e){return typeof e=="string"?e:e.type}function ue(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var Rt=new Set,At=!1;function mn(e){if(Rt.has(e))return!0;if(Rt.add(e),!At){At=!0;let t=()=>{At=!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 Hr(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function pn(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(Hr(r))return!0;r=r.parentElement}return!1}function ce(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,S=[];return t.steps.forEach(({goal:c,name:w,weight:x},m)=>{let y=(h=!1)=>{s.has(m)||h&&r!==void 0&&mn(`step\0${w}\0${x}\0${m}`)||(s.add(m),n.fireStep(w,x,m))};if(c.type==="click"){let h=v=>{let f=v.target;f instanceof Element&&pn(f,e,c.selector)&&y()};e.addEventListener("click",h),S.push(()=>e.removeEventListener("click",h));return}if(c.type==="form_submit"){let h=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&y()};e.addEventListener("submit",h),S.push(()=>e.removeEventListener("submit",h));return}if(c.type==="scroll_depth"){let h=Math.max(0,Math.min(1,c.threshold)),v=new IntersectionObserver(f=>{for(let b of f)if(b.intersectionRatio>=h){y(!0),v.disconnect();break}},{threshold:[h]});v.observe(e),S.push(()=>v.disconnect())}}),()=>{for(let c of S)c()}}let i=t.type==="composite"?t.all:[t],o=new Set(i.map((s,S)=>S)),l=()=>{r!==void 0&&mn(r)||n.fireGoal()},a=(s,S=!1)=>{o.delete(s),o.size===0&&(S?l():n.fireGoal())},u=[];return i.forEach((s,S)=>{if(s.type==="click"){let c=w=>{let x=w.target;x instanceof Element&&pn(x,e,s.selector)&&(t.type==="composite"?a(S):n.fireGoal())};e.addEventListener("click",c),u.push(()=>e.removeEventListener("click",c));return}if(s.type==="form_submit"){let c=w=>{w.target instanceof HTMLFormElement&&e.contains(w.target)&&(t.type==="composite"?a(S):n.fireGoal())};e.addEventListener("submit",c),u.push(()=>e.removeEventListener("submit",c));return}if(s.type==="scroll_depth"){let c=Math.max(0,Math.min(1,s.threshold)),w=new IntersectionObserver(x=>{for(let m of x)if(m.intersectionRatio>=c){t.type==="composite"?a(S,!0):l(),w.disconnect();break}},{threshold:[c]});w.observe(e),u.push(()=>w.disconnect());return}}),()=>{for(let s of u)s()}}var yn=new Set,vn=new Set;function Xr(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,100);if(t&&t===e)return`${t}-steps`;let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n+e.charCodeAt(r)>>>0;return`${t||"component"}-${n.toString(36)}-steps`}var zr=12;function qr(e,t){let n=new Set,r=[];for(let o of t.steps){let l=o.name;!l||l.length>128||l.startsWith("funnel:")||n.has(l)||r.length===zr||(n.add(l),r.push({goalId:l,weight:Math.min(1,Math.max(0,o.weight||0))}))}let i=[...r].sort((o,l)=>o.weight-l.weight);return(r.length<t.steps.length||i.some((o,l)=>o!==r[l]))&&F()&&console.warn(`[SentientUI] "${e}": weighted_composite steps adjusted for its funnel (skipped invalid/repeated/over-12 steps, or ordered by weight)`),i}function de(e,t,n,r,i){let o=(i==null?void 0:i.type)==="weighted_composite"?i:null,l=r!=null?r:o?Xr(n):void 0;if(!l)return;let a=`${l}|${n}`;if(vn.has(a))return;vn.add(a);let u=o&&!yn.has(l)?qr(n,o):null,s=u!==null&&u.length>=2;s&&yn.add(l),!(!s&&r===void 0)&&e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:s?{funnelId:l,steps:u}:{funnelId:l}})}function ye(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Yr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function he(){if(typeof window=="undefined")return Yr;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 je(){he().version+=1;for(let e of he().listeners)e()}var Sn=()=>{};function qe(e){return F()?(he().components.set(e.id,e),je(),()=>{he().components.delete(e.id),je()}):Sn}function Oe(e){return F()?(he().slots.set(e.id,e),je(),()=>{he().slots.delete(e.id),je()}):Sn}function Ct(e){F()&&(he().sections=[...e],je())}var hn="0.42.4",_t=hn!=="0.0.0-dev"?{name:"react",version:hn}:void 0;function Zr(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function Ge(e,t){Zr()[e]=t}function bn(e){window.__sentient_vocabulary_override=e}function wn(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Qr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Ee(e,t){Qr()[e]=t}function xn(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let o=n.slice(0,r.index)+i;history.replaceState(history.state,"",o?"#"+o:location.pathname+location.search)}}catch(n){}return t}var Gt="__snt_editor_token",Pe=null,Ot=!1;function kn(){return Ot}function ei(){try{return sessionStorage.getItem(Gt)}catch(e){return null}}function Ye(e){if(Pe)return Pe;let t=typeof window=="undefined"?null:xn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:ei();return Ot=!!n,Pe=Promise.resolve(n?{token:n,fresh:!1}:null),Pe}return Ot=!0,Pe=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(Gt,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),Pe}function Rn(){try{sessionStorage.removeItem(Gt)}catch(e){}}var An="sentient_preview_cell",Cn="sentient_refresh_region",Et="sentient-cell-preview-bar",be="__preview__",Ne=null;function _n(e){if((Ne==null?void 0:Ne.slotId)!==e)return null;let t=Ne;return Ne=null,t}function On(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(p({slotId:e.slotId},t))})}).then(n=>we(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>we("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function Gn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Et))return;let t,n;try{let u=new URLSearchParams(window.location.search);t=u.get(An),n=u.get(Cn)}catch(u){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=Ye(r);if(!kn())return;if(n){Ne={slotId:n,session:i,base:r},Ge(n,{kind:"arms"}),Ee(n,be),kt();return}if(!t)return;let o=t.lastIndexOf("~");if(o<=0)return;let l=t.slice(0,o),a=t.slice(o+1);i.then(u=>u?"token"in u?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(l)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${u.token}`}}):(we(u.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async u=>{if(!u)return;if(!u.ok){we(u.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await u.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&bn(s.vocabulary),s.compose!=null)Ge(l,{kind:"arms",compose:{[be]:s.compose}}),Ee(l,be);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))Ge(l,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),Ee(l,be);else if(s.blocks!=null)Ge(l,{kind:"arms",blocks:{[be]:s.blocks}}),Ee(l,be);else if(s.content!=null)Ge(l,{kind:"arms",content:s.content}),Ee(l,be);else{we("Nothing to preview in that square yet.");return}kt(),we(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var S;try{(S=document.querySelector(`[data-sentient-slot="${l}"]`))==null||S.scrollIntoView({block:"center"})}catch(c){}},300)}).catch(()=>we("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function we(e){var i;if(document.getElementById(Et))return;let t=document.createElement("div");t.id=Et,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=()=>{Rn();let o=new URL(window.location.href);o.searchParams.delete(An),o.searchParams.delete(Cn),window.location.assign(o.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var En=!1;function Pn(e){if(En||typeof window=="undefined")return;En=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");Ye(t).then(n=>{!n||!("token"in n)||!n.fresh||ti(t,n.token)})}function ti(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var Un=require("react/jsx-runtime");function ni(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,Ze.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Tn="https://api.sentient-ui.com/v1",Y=(0,C.createContext)({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Tn,debug:!1}),Nn=!1,Pt=new Set;function ri(e,t,n){let r=(0,C.useRef)(n);r.current=n;let[i,o]=(0,C.useState)(null),[l,a]=(0,C.useState)(!1),u=(0,C.useRef)(e);u.current=e;let s=e===void 0?"":typeof e=="string"?e:JSON.stringify(V(p({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,C.useEffect)(()=>{let S=u.current;if(S===void 0||typeof window=="undefined")return;let c,w=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:m})=>{if(w)return;let y=x(typeof S=="object"&&S.cmp===void 0&&S.check?p(V(p({},S),{check:()=>u.current.check()}),S.refused?{refused:()=>{var f,b;return((b=(f=u.current).refused)==null?void 0:b.call(f))===!0}}:{}):S),h=!1,v=()=>{let f=y.refused()&&y.read()!==!0;f&&!h&&(m(t),r.current()),h=f,a(f);let b=y.read();b!==null&&Pt.add(t),o(b!=null?b:Pt.has(t)?!1:null)};v(),c=y.subscribe(v)}),()=>{w=!0,c==null||c()}},[s,t]),{granted:i,refused:l}}function In(e){var N,E,R,A,d;let[t,n]=(0,C.useState)(null),[r]=(0,C.useState)(()=>{var g;return(g=e.sessionSegment)!=null?g:ni()}),[i,o]=(0,C.useState)(wt());(0,C.useEffect)(()=>cn(()=>o(wt())),[]),(0,C.useEffect)(()=>{Gn(e.apiBaseUrl),Pn(e.apiBaseUrl)},[]);let l=(0,C.useRef)(()=>{}),a=ri(e.consentFrom,e.apiKey,()=>l.current()),u=e.consentFrom?(N=a.granted)!=null?N:Pt.has(e.apiKey)?!1:e.consent===!0:e.consent,s=e.consentFrom?a.refused:!0,S=(0,C.useRef)(s);S.current=s;let c=(0,C.useRef)(null),w=(0,C.useRef)(!1),x=(0,C.useRef)([]),m=(0,C.useRef)(!1);l.current=()=>{var I;x.current=[],m.current=!0;let g=c.current;g!=null&&g.gated?g.dispose():(I=g==null?void 0:g.takeHeld)==null||I.call(g)},(0,C.useEffect)(()=>{var K,J;if(S.current&&u===!1&&(x.current=[]),u===!1&&w.current&&(S.current&&((K=c.current)==null||K.destroy()),c.current=null,w.current=!1),u===!1&&!e.preConsentBehavior){S.current&&((J=c.current)==null||J.destroy()),c.current=null,n(null);return}let g=u!==!1;g&&(m.current=!1);let I=$=>{!g&&m.current&&$.gated&&$.dispose()},T=p({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:u,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},_t?{sdk:_t}:{}),_=!1,P=null,U=null,W=$=>{for(let ae of x.current.splice(0))setTimeout(()=>{if(c.current!==$){m.current||x.current.push(ae);return}try{ae($)}catch(Fe){}},0)},X=$=>{e.engagement===!1||!g||import("@sentientui/core/engagement").then(({startEngagementCapture:ae})=>{_||(U=ae($,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:$})=>{_||(P=$(V(p({},T),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),I(P),c.current=P,w.current=g,W(P),n(P),X(P))}):(P=(0,Ze.init)(T),I(P),c.current=P,w.current=g,W(P),n(P),X(P)),()=>{var $,ae;_=!0,U==null||U(),x.current=x.current.concat((ae=($=P==null?void 0:P.takeHeld)==null?void 0:$.call(P))!=null?ae:[]),P==null||P.dispose()}},[u]),(0,C.useEffect)(()=>{if(!t)return;let g=!1,I=async()=>{if(g)return;let _;try{_=await t.fetchWeights()}catch(P){return}if(!g)for(let P of _){let U={componentId:P.componentId,updatedAt:P.updatedAt,variants:P.variants.map(W=>{var X;return{variantId:W.variantId,pulls:W.pulls,avgReward:(X=W.avgReward)!=null?X:0}})};ln(P.componentId,U)}};I();let T=setInterval(()=>{I()},6e4);return()=>{g=!0,clearInterval(T)}},[t]);let y=(E=e.ssrFallback)!=null?E:"first",h=((R=e.apiBaseUrl)!=null?R:Tn).replace(/\/$/,""),v=(0,C.useRef)(null);(0,C.useEffect)(()=>{var T;if(typeof process!="undefined"&&((T=process.env)==null?void 0:T.NODE_ENV)==="production")return;let g={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:h},I=v.current;if(v.current=g,I!==null)for(let _ of["apiKey","context","country","persona","apiBaseUrl"])Object.is(I[_],g[_])||console.warn(`[sentient] AdaptiveProvider: \`${_}\` 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,h]),(0,C.useEffect)(()=>{var g;typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production"||gn({apiKey:e.apiKey,apiBaseUrl:h,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,h]);let f=(A=e.identity)==null?void 0:A.userId,b=(d=e.identity)==null?void 0:d.userHash;(0,C.useEffect)(()=>{t&&f&&t.identify(f,{userHash:b})},[t,f,b]),(0,C.useEffect)(()=>{let g=e.initialLayoutOrder;if(g&&g.length>0){Ct(g);return}e.declaredSections&&e.declaredSections.length>0&&Ct(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,C.useEffect)(()=>{!F()||e.consent!==void 0||e.consentFrom!==void 0||Nn||(Nn=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,C.useEffect)(()=>{if(!F())return;let g=e.declaredSections;if(!g||g.length===0||typeof document=="undefined")return;let I=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),_=>_.getAttribute("data-sentient-id"))),T=g.filter(_=>!I.has(_));T.length>0&&console.warn(`[SentientUI] Declared section${T.length>1?"s":""} ${T.map(_=>`"${_}"`).join(", ")} ${T.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 k=(0,C.useMemo)(()=>t&&i?dn(t):t,[t,i]),G=(0,C.useMemo)(()=>{var g,I,T,_,P,U,W,X,K;return{client:k,apiKey:e.apiKey,initialAssignments:(g=e.initialAssignments)!=null?g:{},initialUnified:(I=e.initialUnified)!=null?I:ii,sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(T=e.initialLayoutOrder)!=null?T:null,initialSlots:(_=e.initialSlots)!=null?_:{},initialSlotConfig:(P=e.initialSlotConfig)!=null?P:{},initialPalette:(U=e.initialPalette)!=null?U:null,initialVocabulary:(W=e.initialVocabulary)!=null?W:null,initialPersona:(X=e.initialPersona)!=null?X:null,apiBaseUrl:h,debug:(K=e.debug)!=null?K:!1}},[k,e.apiKey,e.initialAssignments,e.initialUnified,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,h,e.debug]);return(0,Un.jsx)(Y.Provider,{value:G,children:e.children})}function M(){return(0,C.useContext)(Y).client}function re(){return(0,C.useContext)(Y).apiKey}function Qe(){return(0,C.useContext)(Y).initialAssignments}var ii=[];function et(){return(0,C.useContext)(Y).initialUnified}function Te(){return(0,C.useContext)(Y).sessionSegment}function Dn(){return(0,C.useContext)(Y).ssrFallback}function tt(){return(0,C.useContext)(Y).onAssignment}function Ln(){return(0,C.useContext)(Y).debug}function Fn(){let e=(0,C.useContext)(Y).initialLayoutOrder,t=(0,C.useSyncExternalStore)(Q,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function nt(){return(0,C.useContext)(Y).initialSlots}function Vn(){return(0,C.useContext)(Y).initialPersona}function Mn(){return(0,C.useContext)(Y).initialSlotConfig}function jn(){return(0,C.useContext)(Y).initialPalette}function $n(){return(0,C.useContext)(Y).initialVocabulary}function Bn(){return(0,C.useContext)(Y).apiBaseUrl}var ge=require("react");var B=require("react"),Wn=require("@sentientui/core");var ie=require("react"),rt=require("@sentientui/policy");function ve(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let o=i.indexOf(":");if(o!==-1&&i.slice(0,o)===e)return i.slice(o+1)}}catch(r){}return null}function it(e,t,n,r,i){let o=Qe(),l=Dn(),a=M(),u=Te(),s=tt(),S=Ln(),c=(0,ie.useRef)(null),w=(0,ie.useSyncExternalStore)(Q,()=>ve(e),()=>null),x=w&&t.includes(w)?w:null,m=(0,ie.useRef)(null);(0,ie.useEffect)(()=>{S&&x&&m.current!==x&&(m.current=x,console.info(`[sentient] override active: ${e} -> ${x}`))},[S,x,e]);let[y,h]=(0,ie.useState)(()=>{var k,G;if(x)return{variantId:x,content:null,isLoading:!1,settled:!0};if(!a){let N=o[e];return N&&t.includes(N)?{variantId:N,content:null,isLoading:!1,settled:!0}:l==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content))return{variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0};let b=bt(e);if(b){let N=(0,rt.pickFromWeights)(b.variants,t);if(N)return{variantId:N,content:null,isLoading:!1,settled:!0}}return{variantId:(G=t[0])!=null?G:null,content:null,isLoading:!1,settled:!1}}),v=f=>{s&&c.current!==f&&(c.current=f,s(e,f))};return(0,ie.useEffect)(()=>{var k;if(x||!a)return;let f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content)){h({variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0}),v(f.variantId);return}let b=bt(e);if(b&&y.settled&&y.variantId&&y.variantId===(0,rt.pickFromWeights)(b.variants,t)){v(y.variantId);return}h(G=>{var N;return G.variantId?G:{variantId:(N=t[0])!=null?N:null,content:null,isLoading:!1,settled:!1}})},[x,a,e,u]),(0,ie.useEffect)(()=>{if(x||!a)return;let f=a.getAssignment(e,u);if(f&&t.includes(f.variantId))return;let b=!1,k=i==null?void 0:i.onUnified;return(k?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(N=>{var E;if(!b&&N){if(N.unified===!0){k==null||k();return}!t.includes(N.variantId)&&!N.content||(h({variantId:N.variantId,content:(E=N.content)!=null?E:null,isLoading:!1,settled:!0}),v(N.variantId))}}),()=>{b=!0}},[x,a,e,u]),(0,ie.useEffect)(()=>{if(!x&&a)return an(e,f=>{var G;let b=a.getAssignment(e,u);if(b&&(t.includes(b.variantId)||b.content)){h({variantId:b.variantId,content:(G=b.content)!=null?G:null,isLoading:!1,settled:!0}),v(b.variantId);return}let k=(0,rt.pickFromWeights)(f.variants,t);k&&(h({variantId:k,content:null,isLoading:!1,settled:!0}),v(k))})},[x,a,e,u]),x?{variantId:x,content:null,isLoading:!1,settled:!0,isOverride:!0}:y}function ot(e,t,n){let r=M(),i=re(),o=Object.keys(t).join("\0"),l=(0,B.useMemo)(()=>Object.keys(t),[o]),{variantId:a,content:u,isOverride:s=!1,settled:S}=it(e,l,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[c,w]=(0,B.useState)(null),x=(0,B.useRef)(null),m=(0,B.useCallback)(d=>{x.current=d,w(d)},[]),y=n.goal,h=typeof y=="string"?y:JSON.stringify(y),v=(0,B.useMemo)(()=>y?te(y):null,[h]),f=y?pe(y):"";(0,B.useEffect)(()=>qe({id:e,variantIds:l,goal:f}),[e,l,f]);let b=(0,B.useRef)(null);(0,B.useEffect)(()=>{s||S&&(!r||!a||!i||!c||b.current!==a&&(b.current=a,ye(r,i,e,a)))},[r,a,i,e,c,s,S]);let k=(0,B.useRef)(!1),G=(0,B.useRef)(new Set);(0,B.useEffect)(()=>{k.current=!1,G.current=new Set},[a,v]);let N=n.funnel;(0,B.useEffect)(()=>{s||!S||!r||!v||de(r,i,e,N,v)},[r,i,e,N,v,s,S]);let E=n.cursorSignal===!0;(0,B.useEffect)(()=>{if(!E||s||!S||!r||!a||!c)return;let d=null,g=0,I=()=>{g=Date.now(),d=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-g}}),d=null},800)},T=()=>{d!==null&&(clearTimeout(d),d=null)};return c.addEventListener("mouseenter",I),c.addEventListener("mouseleave",T),()=>{c.removeEventListener("mouseenter",I),c.removeEventListener("mouseleave",T),d!==null&&clearTimeout(d)}},[E,r,a,i,e,c,s,S]);let R=(0,B.useRef)(n.microSignalGoals);R.current=n.microSignalGoals;let A=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,B.useEffect)(()=>{if(s||!S||!r||!a||!c)return;let d=Date.now();return(0,Wn.attachMicroSignalDetectors)((g,I={})=>{var W,X,K;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:p({signalType:g},I)});let T=(W=R.current)==null?void 0:W[g];if(!T||G.current.has(g))return;G.current.add(g);let _=typeof T=="string"?T:T.name,P=typeof T=="string"?1:(X=T.weight)!=null?X:1,U=typeof T=="string"?0:(K=T.stepIndex)!=null?K:0;r.goal(_,{metadata:p({signalType:g},I),weight:P,stepIndex:U})},c,d)},[r,a,i,e,c,A,s,S]),(0,B.useEffect)(()=>{if(s||!S||!r||!a||!c||!v)return;let d=ue(v);return ce(c,v,{fireGoal:()=>{k.current||(k.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:f,payload:p({reward:1},d!==void 0?{goalValue:d}:{})}),r.goal(f,p({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},d!==void 0?{value:d}:{})))},fireStep:(g,I,T)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:g,payload:{reward:I}}),r.goal(g,{metadata:{},weight:I,stepIndex:T})}},f)},[r,a,i,e,c,v,f,s,S]),{client:r,variantIds:l,variantId:a,content:u,settled:S,isOverride:s,goalLabel:f,ref:m,nodeRef:x}}var L=require("react"),Re=require("@sentientui/core"),Mt=require("@sentientui/core/region");var ee=require("react"),Jn=require("@sentientui/core");var Kn=new Set,oi={kind:"arms"};function Hn(e,t){var G,N,E;let n=M(),r=(0,ee.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=(0,ee.useRef)(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let o=(0,ee.useRef)(t==null?void 0:t.skeleton);o.current=t==null?void 0:t.skeleton;let l=nt(),a=Mn(),u=jn(),s=$n(),S=(0,ee.useSyncExternalStore)(Q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_config_overrides)==null?void 0:R[e]:void 0},()=>{}),c=(0,ee.useSyncExternalStore)(Q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_overrides)==null?void 0:R[e]:void 0},()=>{}),w=R=>R==null?"":(0,Jn.armOfResult)(R),x=(0,ee.useCallback)(R=>{var A,d;return(d=(A=n==null?void 0:n.onSlotsChanged)==null?void 0:A.call(n,R))!=null?d:(()=>{})},[n]);(0,ee.useSyncExternalStore)(x,()=>{var R;return(R=n==null?void 0:n.getSlotConfig(e))!=null?R:null},()=>null),(0,ee.useSyncExternalStore)(x,()=>w(n==null?void 0:n.getSlotResult(e)),()=>"");let m=S===void 0?a[e]:void 0,y=S===void 0&&m===void 0&&n?n.getSlotConfig(e):null,h=(G=u!=null?u:n==null?void 0:n.getSitePalette())!=null?G:null,v=(E=s!=null?s:(N=n==null?void 0:n.getStyleVocabulary)==null?void 0:N.call(n))!=null?E:null,f=(()=>{var R,A,d;if(S!==void 0)return{config:S,arm:w(c),palette:h,vocabulary:(R=wn())!=null?R:v,source:"override"};if(t!=null&&t.forcedArm)return{config:oi,arm:t.forcedArm,palette:h,vocabulary:v,source:"override"};if(m!==void 0)return{config:m,arm:w((A=l[e])!=null?A:n==null?void 0:n.getSlotResult(e)),palette:h,vocabulary:v,source:"preloaded"};if(y!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:y,arm:w((d=n==null?void 0:n.getSlotResult(e))!=null?d:l[e]),palette:h,vocabulary:v,source:g?"client":"seeded"}}return{config:null,arm:"",palette:h,vocabulary:v,source:"none"}})(),b=(t==null?void 0:t.defer)===!0,k=f.source==="preloaded"||f.source==="override";return(0,ee.useEffect)(()=>{var P,U,W,X,K;if(!n||n.isLocal===!0||k||b)return;let R=f.source==="none",A=R&&(U=(P=r.current)==null?void 0:P.call(r))!=null?U:null,d=A!=null&&A!==""?{[e]:A}:void 0,g=(W=i.current)==null?void 0:W.call(i),I=R&&(K=(X=o.current)==null?void 0:X.call(o))!=null?K:null,T=p(p({},g?{render:{[e]:g}}:{}),I?{skeletons:{[e]:I}}:{}),_=Object.keys(T).length>0;return n.requestSlots?_?n.requestSlots([e],d,T):d?n.requestSlots([e],d):n.requestSlots([e]):R&&(I?n.reportSlots([e],d!=null?d:{},{[e]:I}):d?n.reportSlots([e],d):n.reportSlots([e])),()=>{var J;return(J=n.cancelSlots)==null?void 0:J.call(n,[e])}},[n,k,f.source,e,b]),(0,ee.useEffect)(()=>{!F()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||Kn.has(e)||(Kn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,f.source,e]),f}var $e=require("react");var j=require("react/jsx-runtime");function Nt(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var Se={none:"0",sm:"8px",md:"16px",lg:"24px"},Tt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Yn={sm:"0.875em",md:"1em",lg:"1.25em"},si={sm:"1.25em",md:"1.5em",lg:"2em"},Xn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},zn={sm:"8px",md:"16px",lg:"32px"},ai={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},li={normal:"400",medium:"500",bold:"700"};function qn(e,t){return p(p({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?p({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Zn(e,t,n){var i,o,l,a;let r=t==null?void 0:t.accent;return V(p({display:"inline-block",padding:(i=Xn[n!=null?n:"md"])!=null?i:Xn.md,borderRadius:(o=t==null?void 0:t.radius)!=null?o:"8px",font:"inherit"},n?{fontSize:Yn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(l=t==null?void 0:t.primaryBg)!=null?l:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function ui({node:e,opts:t}){var i,o,l,a,u;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(l=(o=t.palette)==null?void 0:o.border)!=null?l:"currentColor"}`,borderRadius:(u=(a=t.palette)==null?void 0:a.radius)!=null?u:"8px"};return(0,j.jsxs)("form",{onSubmit:s=>{var w,x,m;s.preventDefault();let S=new FormData(s.currentTarget),c={};for(let y of e.fields)c[y.name]=String((w=S.get(y.name))!=null?w:"");(x=t.onFormGoal)==null||x.call(t,e.submitGoal);try{(m=t.onFormSubmit)==null||m.call(t,c)}catch(y){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var S,c;return(0,j.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?(0,j.jsx)("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?(0,j.jsx)("select",{name:s.name,required:s.required,style:r,children:((S=s.options)!=null?S:[]).map(w=>(0,j.jsx)("option",{value:w,children:w},w))}):(0,j.jsx)("input",{name:s.name,type:(c=s.inputType)!=null?c:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),(0,j.jsx)("button",{type:"submit",style:Zn(n,t.palette),children:e.submitLabel})]})}function ci(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(o=>o.id===n))==null?void 0:i.classes:void 0}function Qn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function xe(e,t){var i;let n=di(e,t),r=Qn(e.like,t);return n&&r?(0,$e.cloneElement)(n,{style:V(p({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function di(e,t){var n,r,i,o,l,a,u,s,S,c,w,x,m,y,h,v,f,b,k,G,N,E,R;try{let A=ci(e,t);switch(e.type){case"stack":{let d=(r=Se[(n=e.gap)!=null?n:"md"])!=null?r:Se.md,g=e.surface==="raised"&&!A,I=(i=e.pad)!=null?i:g?"md":void 0;return(0,j.jsx)("div",V(p({},A?{className:A}:{}),{style:p(p(p(p(p({display:"flex",flexDirection:e.direction,gap:d},e.align?{alignItems:Tt[e.align]}:{}),e.justify?{justifyContent:Tt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),I?{padding:(o=Se[I])!=null?o:Se.md}:{}),g?V(p(p({},(l=t.palette)!=null&&l.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((u=t.palette)!=null&&u.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(S=(s=t.palette)==null?void 0:s.border)!=null?S:"currentColor"}`,borderRadius:(w=(c=t.palette)==null?void 0:c.radius)!=null?w:"8px"}):{}),children:((x=e.children)!=null?x:[]).map((T,_)=>{let P=xe(T,t);return P===null?null:(0,j.jsx)($e.Fragment,{children:P},_)})}))}case"grid":{let d=(y=Se[(m=e.gap)!=null?m:"md"])!=null?y:Se.md;return(0,j.jsx)("div",V(p({},A?{className:A}:{}),{style:p(p({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${d}) / ${e.columns})), 1fr))`,gap:d},e.align?{alignItems:Tt[e.align]}:{}),e.pad?{padding:(h=Se[e.pad])!=null?h:Se.md}:{}),children:((v=e.children)!=null?v:[]).map((g,I)=>{let T=xe(g,t);return T===null?null:(0,j.jsx)($e.Fragment,{children:T},I)})}))}case"text":return A?(0,j.jsx)("p",{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,j.jsx)("p",{style:p(p(p(p(p({margin:0},e.size?{fontSize:Yn[e.size]}:{}),e.weight?{fontWeight:li[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),qn(e.tone,t.palette)),children:e.value});case"heading":{let d=`h${e.level}`;return A?(0,j.jsx)(d,{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,j.jsx)(d,{style:p(p({margin:0,fontSize:si[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let d=(b=e.emphasis)!=null?b:"primary";return(0,j.jsx)("a",V(p(p({href:Nt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:Zn(d,t.palette,e.size)}),{children:e.label}))}case"link":return(0,j.jsx)("a",V(p(p({href:Nt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return(0,j.jsx)("img",V(p({src:Nt(e.src),alt:e.alt},A?{className:A}:{}),{style:p(p({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:ai[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return A?(0,j.jsx)("span",{className:A,children:e.value}):(0,j.jsx)("span",{style:p({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(G=(k=t.palette)==null?void 0:k.border)!=null?G:"currentColor"}`},qn(e.tone,t.palette)),children:e.value});case"spacer":return(0,j.jsx)("div",{style:{height:(N=zn[e.size])!=null?N:zn.md}});case"divider":return(0,j.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(R=(E=t.palette)==null?void 0:E.border)!=null?R:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,j.jsx)(ui,{node:e,opts:t});default:return null}}catch(A){return null}}function st(e,t){var o,l,a,u;let n=xe(e.tree,t);if(n===null)return null;let r=(o=e.surface)!=null&&o.like?(a=(l=t.vocabulary)==null?void 0:l.entries.find(s=>s.id===e.surface.like))==null?void 0:a.classes:void 0,i=Qn((u=e.surface)==null?void 0:u.like,t);return r?(0,j.jsx)("div",V(p({className:r},i?{style:{color:i}}:{}),{children:n})):n}var fe=require("react"),at=require("@sentientui/core/region");function lt(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function ut(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ke(e){return lt(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ke(n),0):(0,fe.isValidElement)(e)?ke(ut(e)):0}function fi(e,t){return Array.isArray(t)?(0,fe.cloneElement)(e,void 0,...t):(0,fe.cloneElement)(e,void 0,t)}function It(e,t){if(lt(e))return t;if(Array.isArray(e))return e.map(n=>It(n,t));if((0,fe.isValidElement)(e)){let n=ut(e);return ke(n)===0?e:fi(e,It(n,t))}return e}function er(e,t){return ke(e)===1?It(e,t):null}var ne=e=>e.join("/");function Dt(e,t,n){if(lt(e)){n.leafPaths.push(t),n.texts.push((0,at.normalizeLeafText)(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>Dt(r,[...t,i],n));return}(0,fe.isValidElement)(e)&&(n.elements.set(ne(t),e),Dt(ut(e),[...t,"c"],n))}function Ft(e){let t={leafPaths:[],texts:[],elements:new Map};return Dt(e,[],t),t}function gi(e){return Ft(e).texts}function tr(e){let t=gi(e);return t.length===0?null:(0,at.skeletonFingerprint)(t)}function mi(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function nr(e,t){let n=t.reduce((i,o)=>Math.max(i,o+1),0),r=[];for(let i=0;i<n;i++){let o=t.flatMap((a,u)=>a===i?[mi(e.leafPaths[u])]:[]);if(o.length===0){r.push(null);continue}let l=o[0];for(let a of o.slice(1)){let u=new Set(a.map(ne));l=l.filter(s=>u.has(ne(s)))}r.push(l.length>0?l[l.length-1]:null)}return r}function Lt(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 Vt(e,t){let n=Ft(t);if(n.texts.length!==e.leaves.length||n.texts.some((o,l)=>o!==e.leaves[l]))return null;let r=nr(n,e.leafToNode),i=e.nodes.map((o,l)=>{let a=r[l],u=a?n.elements.get(ne(a)):void 0,s=!!u&&(typeof u.type=="string"||Lt(u)!==void 0);return V(p({},o),{restylable:s})});return V(p({},e),{nodes:i})}function rr(e,t,n){var m;let r=Ft(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((y,h)=>Math.max(y,h+1),0);for(let y of Object.keys(t.nodes))if(!/^\d+$/.test(y)||Number(y)>=i)return null;let o=nr(r,n),l=new Map;n.forEach((y,h)=>{l.has(y)||l.set(y,h)});let a=new Map(r.leafPaths.map((y,h)=>[ne(y),h])),u=new Set,s=new Map,S=!1;for(let[y,h]of Object.entries(t.nodes)){let v=Number(y),f=o[v];if(h.hidden&&(f?u.add(ne(f)):S=!0),h.like!==void 0){let b=o[h.like],k=f?r.elements.get(ne(f)):void 0,G=b?Lt(r.elements.get(ne(b))):void 0;!f||G===void 0||Lt(k)===void 0?S=!0:s.set(ne(f),G)}}let c=new Map(Object.entries((m=t.order)!=null?m:{})),w=(y,h)=>{var v;if(lt(y)){let f=a.get(ne(h));if(f===void 0)return y;let b=n[f],k=(v=t.nodes[String(b)])==null?void 0:v.text;return k===void 0?y:l.get(b)===f?k:""}if(Array.isArray(y)){let f=y.map((b,k)=>w(b,[...h,k]));for(let[b,k]of c){let G=k.map(R=>{let A=o[R];return!A||A.length!==h.length+1||ne(A.slice(0,-1))!==ne(h)?-1:A[A.length-1]});if(G.some(R=>R<0))continue;let N=[...G].sort((R,A)=>R-A),E=[...f];N.forEach((R,A)=>{f[R]=E[G[A]]}),c.delete(b)}return f}if((0,fe.isValidElement)(y)){let f=ne(h);if(u.has(f))return null;let b=ut(y);if(ke(b)===0)return y;let k=w(b,[...h,"c"]),G=s.get(f),N=G!==void 0?{className:G}:void 0;return Array.isArray(k)?(0,fe.cloneElement)(y,N,...k):(0,fe.cloneElement)(y,N,k)}return y},x=w(e,[]);return S||c.size>0?null:x}var ar=require("react/jsx-runtime"),ir=new Set,or=new Set,sr=new Set,ct="authored.";function Ie({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:o,as:l="div",reportBaselineText:a=!0,funnel:u,microSignalGoals:s,clientOnly:S,agentDataByVariant:c,agentData:w,variantsOnly:x=!1}){var Yt,Zt;let m=M(),y=re(),h=(0,L.useRef)(null),[v,f]=(0,L.useState)(!1);(0,L.useEffect)(()=>{f(!0)},[]);let b=S===!0&&(!v||!m),k=(0,L.useMemo)(()=>tr(t),[t]),G=n?Object.keys(n).join("|"):"",N=(0,L.useMemo)(()=>p({fp:k!=null?k:"0000000000000000",forms:!!r,compose:!0,content:ke(t)===1,ops:!1},G!==""?{authored:G.split("|"),children:!x}:{}),[k,t,r,G,x]),E=()=>{var q;let O=h.current;if(!O||!a)return null;let D=(0,Mt.captureRegionSkeleton)(O);return D.skeleton?(q=Vt(D.skeleton,t))!=null?q:V(p({},D.skeleton),{editable:!1,nodes:D.skeleton.nodes.map(H=>V(p({},H),{restylable:!1}))}):{status:D.reason}},R=(0,L.useSyncExternalStore)(Q,()=>n?ve(e):null,()=>null),A=R===null||!n?null:Object.prototype.hasOwnProperty.call(n,R)?`${ct}${R}`:x?`${ct}${Object.keys(n)[0]}`:"baseline",{config:d,arm:g,palette:I,vocabulary:T,source:_}=Hn(e,{forcedArm:A,baselineText:a?()=>{var O,D;return(D=(O=h.current)==null?void 0:O.textContent)!=null?D:null}:void 0,render:()=>N,skeleton:E,defer:b}),P=g!==""?(Yt=d==null?void 0:d.blocks)==null?void 0:Yt[g]:void 0,U=g!==""?(Zt=d==null?void 0:d.compose)==null?void 0:Zt[g]:void 0,W=(P!==void 0&&(0,Re.containsFormBlock)(P)||U!==void 0&&(0,Re.containsFormBlock)(U.tree))&&!r;(0,L.useEffect)(()=>{!W||!F()||ir.has(e)||(ir.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[W,e]);let X=O=>{!m||_==="override"||(_!=="seeded"&&m.componentGoal(e,O),m.goal(O,{metadata:{componentId:e,arm:g},weight:1,stepIndex:0}))},K=t,J=!1,$=g.startsWith(ct)?g.slice(ct.length):null;if((d==null?void 0:d.blocked)==="variant_history")J=!0;else if($!==null)n&&Object.prototype.hasOwnProperty.call(n,$)?K=n[$]:J=!0;else if(U!==void 0){let O=W?null:st(U,{palette:I,vocabulary:T,onFormSubmit:r,onFormGoal:X});O===null?J=!0:K=O}else if(P!==void 0){let O=W?null:xe(P,{palette:I,vocabulary:T,onFormSubmit:r,onFormGoal:X});O===null?J=!0:K=O}else if((d==null?void 0:d.edits)!==void 0&&_!=="none"){let O=d.edits,D=O.fp===k?rr(t,O.edits,O.leafToNode):null;D===null?J=!0:K=D}else if((d==null?void 0:d.content)!==void 0&&_!=="none"){let O=er(t,d.content);O===null?J=!0:K=O}let ae=J&&P===void 0&&U===void 0&&(d==null?void 0:d.edits)===void 0&&$===null&&(d==null?void 0:d.blocked)===void 0;(0,L.useEffect)(()=>{(d==null?void 0:d.blocked)!=="variant_history"||!F()||sr.has(e)||(sr.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Matrix \u2192 Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[d==null?void 0:d.blocked,e]);let Fe=$!==null&&!J?$:null;(0,L.useEffect)(()=>{var le;if(!Fe||!a||!m)return;let O=h.current;if(!O)return;let D=(0,Mt.captureRegionSkeleton)(O),q=D.skeleton?Vt(D.skeleton,n==null?void 0:n[Fe]):null,H=(le=O.textContent)==null?void 0:le.trim();m.reportSlots([],void 0,void 0,{[e]:[p(p({key:Fe},H?{text:H}:{}),q?{skeleton:q}:{})]})},[Fe,m,e,b]);let Wt=J&&(d==null?void 0:d.edits)!==void 0&&(_==="preloaded"||_==="client");(0,L.useEffect)(()=>{var O;!Wt||!(d!=null&&d.edits)||(O=m==null?void 0:m.reportDrift)==null||O.call(m,e,d.edits.fp,k,d.edits.fp===k?"unaddressable":"fp_mismatch")},[Wt,e,k,m]);let We=K===t;(0,L.useEffect)(()=>{var D;if(!(d!=null&&d.needsSkeleton)||!We)return;let O=E();O&&((D=m==null?void 0:m.reportSkeleton)==null||D.call(m,e,O))},[d==null?void 0:d.needsSkeleton,We,e,m,b]),(0,L.useEffect)(()=>{if(!We)return;let O=_n(e);if(!O)return;let D=E();On(O,D&&"status"in D?{status:D.status}:{skeleton:D})},[e,We,b]),(0,L.useEffect)(()=>{!ae||!F()||or.has(e)||(or.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[ae,e]);let mt=d!=null&&d.blocks?Object.keys(d.blocks).sort().join("|"):"",pt=n?[...x?[]:["baseline"],...G.split("|")].join("|"):"";(0,L.useEffect)(()=>pt!==""?qe({id:e,variantIds:pt.split("|")}):Oe({id:e,arms:mt===""?void 0:mt.split("|")}),[e,mt,pt]);let Kt=(0,L.useRef)(null);(0,L.useEffect)(()=>{!m||_==="none"||_==="seeded"||_==="override"||g===""||J||Kt.current!==g&&(Kt.current=g,ye(m,y,e,g))},[m,y,e,g,_,J]);let me=_!=="none"&&_!=="seeded"&&!J,yt=me?g:"",Jt=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);(0,L.useEffect)(()=>{if(!m||!i||_==="override")return;let O=h.current;if(!O)return;let D=pe(i),q=ue(i),H=!1;return ce(O,te(i),{fireGoal:()=>{H||(H=!0,me&&(q!==void 0?m.componentGoal(e,D,{value:q}):m.componentGoal(e,D)),m.goal(D,p({metadata:{componentId:e,arm:yt},weight:1,stepIndex:0},q!==void 0?{value:q}:{})))},fireStep:(le,Je,St)=>{me&&m.componentGoal(e,le,{reward:Je}),m.goal(le,{metadata:{componentId:e,arm:yt},weight:Je,stepIndex:St})}},D)},[m,e,Jt,g,_,J,me,yt,b]);let vt=(0,L.useMemo)(()=>i?te(i):null,[Jt]);(0,L.useEffect)(()=>{_==="override"||!m||!vt||de(m,y,e,u,vt)},[m,y,e,u,vt,_]);let Ht=(0,L.useRef)(s);Ht.current=s;let Xt=(0,L.useRef)(new Set),Lr=s?JSON.stringify(s):"";(0,L.useEffect)(()=>{if(!m||_==="override"||!me||g==="")return;let O=h.current;if(O)return(0,Re.attachMicroSignalDetectors)((D,q={})=>{var Qt,en,tn;m.track({projectId:y,componentId:e,variantId:g,eventType:"micro_signal",payload:p({signalType:D},q)});let H=(Qt=Ht.current)==null?void 0:Qt[D];if(!H||Xt.current.has(D))return;Xt.current.add(D);let le=typeof H=="string"?H:H.name,Je=typeof H=="string"?1:(en=H.weight)!=null?en:1,St=typeof H=="string"?0:(tn=H.stepIndex)!=null?tn:0;m.goal(le,{metadata:p({componentId:e,arm:g,signalType:D},q),weight:Je,stepIndex:St})},O,Date.now())},[m,y,e,g,_,me,Lr,b]);let zt=(0,L.useRef)({agentData:w,agentDataByVariant:c});zt.current={agentData:w,agentDataByVariant:c};let qt=(0,L.useRef)(null);(0,L.useEffect)(()=>{var le;if(!m||_==="override"||!me||g===""||qt.current===g)return;let{agentData:O,agentDataByVariant:D}=zt.current,q=$!=null?$:g,H=D!==void 0?Object.prototype.hasOwnProperty.call(D,q)?D[q]:void 0:O;H!==void 0&&(qt.current=g,(le=m.reportAgentData)==null||le.call(m,e,g,H))},[m,e,g,me,$,_]);let Ke=(0,L.useRef)(null);(0,L.useEffect)(()=>{let O=h.current;if(O){if(Ke.current===null){Ke.current=g;return}Ke.current!==g&&(Ke.current=g,(0,Re.reveal)(O))}},[g,b]);let Fr=(0,L.useMemo)(()=>p({"data-sentient-slot":e},g!==""?{"data-sentient-arm":g}:{}),[e,g]);return b?null:(0,ar.jsx)(l,V(p({ref:h,className:o},Fr),{children:K}))}var Ae=require("react/jsx-runtime");function pi(e){var S,c;let{client:t,variantId:n,content:r,ref:i}=ot(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[o,l]=(0,ge.useState)(!1);(0,ge.useEffect)(()=>{l(!0)},[]);let a=(S=e.as)!=null?S:"div";if(e.clientOnly&&(!o||!t)||!n)return null;let u=(c=e.variants[n])!=null?c:null,s=u===null?r:null;return F()&&u===null&&s===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),(0,Ae.jsx)(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:u!=null?u:s})}var yi=(0,ge.memo)(pi,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function lr(e){if(e.variants===void 0)return(0,Ae.jsx)(Ie,p({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=Me(n,["variants"]);return(0,Ae.jsx)(Ie,V(p({},i),{children:t.children,variants:r}))}return(0,Ae.jsx)(vi,p({},t))}function vi(e){var c;let[t,n]=(0,ge.useState)(null),{id:r}=e,i=(0,ge.useCallback)(()=>n(r),[r]),o=M(),l=et().includes(r)||((c=o==null?void 0:o.isUnified)==null?void 0:c.call(o,r))===!0;if(t!==r&&!l)return(0,Ae.jsx)(yi,V(p({},e),{onUnified:i}));let w=e,{variants:a,children:u}=w,s=Me(w,["variants","children"]),S=Object.keys(a)[0];return(0,Ae.jsx)(Ie,V(p({},s),{variants:a,variantsOnly:!0,children:S!==void 0?a[S]:null}))}var z=require("react");var cr=require("react/jsx-runtime");function ur({id:e,default:t,component:n="span",className:r,goal:i}){var N;let o=M(),l=re(),a=tt(),u=Te(),s=(0,z.useRef)(null),S=(0,z.useRef)(null),c=(0,z.useSyncExternalStore)(Q,()=>ve(e),()=>null),[w,x]=(0,z.useState)(()=>{var E,R;return(R=(E=o==null?void 0:o.getAssignment(e,u))==null?void 0:E.content)!=null?R:null}),[m,y]=(0,z.useState)(()=>{var E,R;return(R=(E=o==null?void 0:o.getAssignment(e,u))==null?void 0:E.variantId)!=null?R:null});(0,z.useEffect)(()=>{if(c||!o)return;let E=o.getAssignment(e,u);if((E==null?void 0:E.content)!==void 0){y(E.variantId),x(E.content);return}let R=!1;return o.assign(e).then(A=>{if(!R){if(!A){F()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}y(A.variantId),A.content&&x(A.content)}}),()=>{R=!0}},[o,e,u,c]),(0,z.useEffect)(()=>{c||!o||!m||!l||s.current!==m&&(s.current=m,o.track({projectId:l,componentId:e,variantId:m,eventType:"variant_assigned",payload:{}}),a==null||a(e,m))},[o,m,l,e,a,c]);let h=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=(0,z.useMemo)(()=>i===void 0?null:te(i),[h]),f=i===void 0?null:typeof i=="string"?i:v.type,b=(0,z.useRef)(!1);(0,z.useEffect)(()=>{b.current=!1},[m,h]),(0,z.useEffect)(()=>{c||!o||!l||de(o,l,e,void 0,v)},[o,l,e,v,c]),(0,z.useEffect)(()=>{if(c||!o||!m||!l||!v||!f)return;let E=S.current;if(!E)return;let R=ue(v);return ce(E,v,{fireGoal:()=>{b.current||(b.current=!0,o.track({projectId:l,componentId:e,variantId:m,eventType:"goal_achieved",goalType:f,payload:p({reward:1},R!==void 0?{goalValue:R}:{})}),o.goal(f,p({metadata:{componentId:e,variantId:m},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(A,d,g)=>{o.track({projectId:l,componentId:e,variantId:m,eventType:"goal_achieved",goalType:A,payload:{reward:d}}),o.goal(A,{metadata:{},weight:d,stepIndex:g})}})},[o,m,l,e,v,f,c]);let k=w!=null?w:t;if(c){let E=o==null?void 0:o.getAssignment(e,u);k=E&&E.variantId===c&&(N=E.content)!=null?N:t}return(0,cr.jsx)(n,{ref:E=>{S.current=E},className:r,children:k})}var dt=require("react");function Be(e){var t,n;return p(p(p({metadata:(t=e==null?void 0:e.metadata)!=null?t:{},weight:(n=e==null?void 0:e.reward)!=null?n:1,stepIndex:0},(e==null?void 0:e.value)!==void 0?{value:e.value}:{}),(e==null?void 0:e.currency)!==void 0?{currency:e.currency}:{}),(e==null?void 0:e.externalId)!==void 0?{externalId:e.externalId}:{})}function De(e){let t=M(),n=(0,dt.useRef)(new Set);return(0,dt.useCallback)((r,i)=>{if(!ve(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,Be(i))}},[t,e])}var Ue=require("react");function dr(e,t={}){let u=t,{componentId:n}=u,r=Me(u,["componentId"]),i=M(),o=De(n!=null?n:""),l=(0,Ue.useRef)(!1),a=(0,Ue.useRef)(r);a.current=r,(0,Ue.useEffect)(()=>{if(!(!i||l.current||i.gated)){if(l.current=!0,n){o(e,a.current);return}i.goal(e,Be(a.current))}},[i,n,e,o])}var Le=require("react");var fr=new Set,gr=new Map;function Si(e,t,n,r){let i=r;if(r){let l=gr.get(t);l&&l!==n?(F()&&console.warn(`[SentientUI] useGoal('${n}'): '${l}' is already primary on this page`),i=!1):gr.set(t,n)}let o=`${t}|${n}|${i?"primary":""}`;fr.has(o)||(fr.add(o),e.track({projectId:t,componentId:"__session__",eventType:"goal_declared",payload:i?{goalId:n,primary:!0}:{goalId:n}}))}function mr(e,t={}){let{primary:n=!1,componentId:r}=t,i=M(),o=re(),l=De(r!=null?r:""),a=(0,Le.useRef)(!1);return(0,Le.useEffect)(()=>{!i||i.gated||!o||Si(i,o,e,n)},[i,o,e,n]),(0,Le.useCallback)(u=>{if(u!=null&&u.once){if(a.current)return;a.current=!0}if(r){l(e,u);return}i==null||i.goal(e,Be(u))},[i,r,l,e])}var pr=require("@sentientui/core"),yr=require("@sentientui/policy"),Sr=require("react/jsx-runtime");function jt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function hi(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+jt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+jt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+jt((0,yr.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,pr.renderPrePaintScript)(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function vr(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:(0,Sr.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:hi(e)}})}var se=require("react"),xr=require("@sentientui/policy");var oe=require("react"),Ce=require("@sentientui/core"),hr=require("@sentientui/policy");function ft(e,t){let n=M(),r=nt(),[,i]=(0,oe.useReducer)(c=>c+1,0),o=(0,oe.useSyncExternalStore)(Q,()=>{var c;return typeof window!="undefined"?(c=window.__sentient_slot_overrides)==null?void 0:c[e]:void 0},()=>{}),l=o===void 0?r[e]:void 0,a=o===void 0&&l===void 0&&n?n.getSlotResult(e):null,u=(n==null?void 0:n.isLocal)===!0&&o===void 0&&l===void 0&&a===null;(0,oe.useEffect)(()=>{if(!u||!n)return;let c=!1;return n.decide({slots:[t]}).then(w=>{!c&&w&&i()}),()=>{c=!0}},[n,e,u]);let s=(()=>{if(o!==void 0)return{result:o,arm:(0,Ce.armOfResult)(o),source:"override"};if(l!==void 0)return{result:l,arm:(0,Ce.armOfResult)(l),source:"preloaded"};if(a!==null){let w=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:(0,Ce.armOfResult)(a),source:w?"client":"seeded"}}let c=(0,Ce.baselineResultFor)(t);return{result:c,arm:(0,Ce.armOfResult)(c),source:"baseline"}})(),S=s.source==="preloaded"||s.source==="override";return(0,oe.useEffect)(()=>{var w;if(!n||n.isLocal===!0||S||!n.decideSlots)return;let c=(w=n.onSlotsChanged)==null?void 0:w.call(n,i);return n.decideSlots([t]),()=>{var x;(x=n.cancelSlots)==null||x.call(n,[e]),c==null||c()}},[n,e,S]),s}function bi(){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 br(){let e=M(),t=Vn();(0,oe.useSyncExternalStore)(Q,fn,()=>0);let[n,r]=(0,oe.useState)(!1);(0,oe.useEffect)(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:(0,hr.confidenceBand)(a.confidence)});if(!n)return t?i(t):null;let o=bi();if(o)return i(o);if(t)return i(t);let l=e?e.getPersona():null;return l?i(l):null}var wr=new Set;function wi(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function kr(e,t,n){let r=M(),i=re(),o=JSON.stringify(t),l=(0,se.useMemo)(()=>({id:e,dims:t}),[e,o]),{result:a,arm:u,source:s}=ft(e,l),S=(0,se.useMemo)(()=>typeof a=="string"?{}:a,[u]);if(F()&&!wr.has(e)){wr.add(e);let y=(0,xr.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,f])=>[v,[...f]]))}),h=Object.values(t).reduce((v,f)=>v*f.length,1);y.ok?h>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${h} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${y.reason}. Serving baseline.`)}let c=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,se.useEffect)(()=>Oe({id:e,dims:t}),[e]);let w=(0,se.useRef)(null);(0,se.useEffect)(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||w.current===u||(w.current=u,ye(r,i,e,u))},[r,i,e,u,s]);let x=n==null?void 0:n.funnel;(0,se.useEffect)(()=>{var y;!r||s==="override"||de(r,i,e,x,te((y=n==null?void 0:n.goal)!=null?y:"click"))},[r,i,e,x,c,s]),(0,se.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let y=document.querySelector(`[data-sentient-slot="${wi(e)}"]`);if(!y){F()&&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 h=pe(n.goal),v=ue(n.goal),f=!1;return ce(y,te(n.goal),{fireGoal:()=>{f||(f=!0,v!==void 0?r.componentGoal(e,h,{value:v}):r.componentGoal(e,h),r.goal(h,p({metadata:{componentId:e,arm:u},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(b,k,G)=>{r.componentGoal(e,b,{reward:k}),r.goal(b,{metadata:{componentId:e,arm:u},weight:k,stepIndex:G})}},h)},[r,e,c,u,s]);let m=(0,se.useMemo)(()=>{let y={"data-sentient-slot":e};for(let[h,v]of Object.entries(S))y[`data-${h}`]=v;return y},[e,S]);return{tokens:S,props:m}}var _e=require("react");var Rr=new Set,Ar=new Set;function Cr(e,t){var m,y;if(F()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:o,goalLabel:l,ref:a,nodeRef:u}=ot(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(m=i!=null?i:r[0])!=null?m:"",S=t.variants[s],c=et().includes(e)||((y=n==null?void 0:n.isUnified)==null?void 0:y.call(n,e))===!0;(0,_e.useEffect)(()=>{!c||!F()||Ar.has(e)||(Ar.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[c,e]),(0,_e.useEffect)(()=>{if(!F()||!n)return;let h=setTimeout(()=>{!u.current&&!Rr.has(e)&&(Rr.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 w=(0,_e.useCallback)((h,v)=>{var b,k;if(o)return;let f=h!=null?h:l;f&&(n==null||n.componentGoal(e,f,v),n==null||n.goal(f,p(p(p({metadata:(b=v==null?void 0:v.metadata)!=null?b:{},weight:(k=v==null?void 0:v.reward)!=null?k:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,l,o]),x=(0,_e.useMemo)(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":s}),[a,e,s]);return{variant:s,value:S,bind:x,fireGoal:w}}var Z=require("react");var Or=require("react/jsx-runtime"),gt=new Set;function _r(e){var f;let t=M(),n=re(),r=(0,Z.useRef)(null),i=Object.keys(e.arrangements).join(" "),o=(0,Z.useMemo)(()=>Object.keys(e.arrangements),[i]),l=(0,Z.useMemo)(()=>p({id:e.id,arms:o},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,o,e.baseline]),{arm:a,source:u}=ft(e.id,l);F()&&e.baseline!==void 0&&e.baseline!==o[0]&&!gt.has(e.id+":baseline")&&(gt.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${o[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=Z.Children.toArray(e.children).filter(Z.isValidElement),S=new Map;for(let b of s)S.set(String((f=b.key)!=null?f:"").replace(/^\.\$/,""),b);let c=e.arrangements[a],w=c!==void 0&&c.length===s.length&&c.every(b=>S.has(b));F()&&c!==void 0&&!w&&!gt.has(e.id+":keys")&&(gt.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${c.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let x=w?c.map(b=>S.get(b)):s;(0,Z.useEffect)(()=>Oe({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let m=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{!t||u==="baseline"||u==="seeded"||u==="override"||m.current===a||(m.current=a,ye(t,n,e.id,a))},[t,n,e.id,a,u]);let y=e.funnel,h=e.goal===void 0||typeof e.goal=="string"?"":JSON.stringify(e.goal);(0,Z.useEffect)(()=>{var b;!t||u==="override"||de(t,n,e.id,y,te((b=e.goal)!=null?b:"click"))},[t,n,e.id,y,h,u]);let v=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,Z.useEffect)(()=>{if(!t||e.goal===void 0||u==="override"||u==="baseline"||u==="seeded")return;let b=r.current;if(!b)return;let k=pe(e.goal),G=ue(e.goal),N=!1;return ce(b,te(e.goal),{fireGoal:()=>{N||(N=!0,G!==void 0?t.componentGoal(e.id,k,{value:G}):t.componentGoal(e.id,k),t.goal(k,p({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},G!==void 0?{value:G}:{})))},fireStep:(E,R,A)=>{t.componentGoal(e.id,E,{reward:R}),t.goal(E,{metadata:{componentId:e.id,arm:a},weight:R,stepIndex:A})}},k)},[t,e.id,v,a,u]),(0,Or.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:x})}var $t=require("@sentientui/core");var xi=["page","blocks","layoutOrder"],Gr=new Map;function Er(e,t){Gr.set(e,t)}function Bt(e){return Gr.get(e)}function Pr(e){var i,o;let t=(o=(i=e.content)!=null?i:Bt(e.page))!=null?o:{},n={};for(let[l,a]of Object.entries(t))xi.includes(l)||(n[l]=a);let r=V(p({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function Nr(e){return`<script type="application/ld+json">${Ut(e)}</script>`}function Ut(e){return JSON.stringify(p({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function Tr(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 Mr=Object.create;var je=Object.defineProperty,jr=Object.defineProperties,$r=Object.getOwnPropertyDescriptor,Br=Object.getOwnPropertyDescriptors,Ur=Object.getOwnPropertyNames,ze=Object.getOwnPropertySymbols,Kr=Object.getPrototypeOf,bt=Object.prototype.hasOwnProperty,on=Object.prototype.propertyIsEnumerable;var rn=(e,t,n)=>t in e?je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))bt.call(t,n)&&rn(e,n,t[n]);if(ze)for(var n of ze(t))on.call(t,n)&&rn(e,n,t[n]);return e},M=(e,t)=>jr(e,Br(t));var $e=(e,t)=>{var n={};for(var r in e)bt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ze)for(var r of ze(e))t.indexOf(r)<0&&on.call(e,r)&&(n[r]=e[r]);return n};var Wr=(e,t)=>{for(var n in t)je(e,n,{get:t[n],enumerable:!0})},sn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ur(t))!bt.call(e,i)&&i!==n&&je(e,i,{get:()=>t[i],enumerable:!(r=$r(t,i))||r.enumerable});return e};var Be=(e,t,n)=>(n=e!=null?Mr(Kr(e)):{},sn(t||!e||!e.__esModule?je(n,"default",{value:e,enumerable:!0}):n,e)),Jr=e=>sn(je({},"__esModule",{value:!0}),e);var Ri={};Wr(Ri,{Adaptive:()=>ur,AdaptiveGroup:()=>Or,AdaptiveProvider:()=>Dn,AdaptiveSlot:()=>De,AdaptiveText:()=>cr,SentientPersonaScript:()=>Sr,buildAgentFeed:()=>Nr,consentWatcher:()=>Lr.consentWatcher,defineAgentContent:()=>Pr,detectSegment:()=>Ut.deriveSessionSegment,getAgentContent:()=>Kt,grantConsent:()=>Dr.grantConsent,renderAgentJsonLd:()=>Tr,renderAgentJsonLdBody:()=>Wt,renderAgentMarkdown:()=>Ir,renderBlocks:()=>ke,renderCompose:()=>at,useAdaptive:()=>_r,useAdaptiveApiBaseUrl:()=>Un,useAdaptiveGoal:()=>Le,useAdaptivePersona:()=>wr,useAdaptiveTokens:()=>Rr,useAssignment:()=>ot,useGoal:()=>pr,useInitialAssignments:()=>et,useLayoutOrder:()=>Vn,usePageGoal:()=>fr,useSentient:()=>j,useSessionSegment:()=>Ie});module.exports=Jr(Ri);var _=require("react"),Qe=require("@sentientui/core");var an=new Map,qe=new Map;function ln(e,t){let n=qe.get(e);return n||(n=new Set,qe.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&qe.delete(e)}}function un(e,t){an.set(e,t);let n=qe.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function wt(e){var t;return(t=an.get(e))!=null?t:null}var Hr={on:!1,listeners:new Set};function xt(){if(typeof window=="undefined")return Hr;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function cn(e){let t=xt();if(t.on!==e){t.on=e;for(let n of t.listeners)n()}}function kt(){return xt().on}function dn(e){let t=xt().listeners;return t.add(e),()=>{t.delete(e)}}function fn(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,o)=>e.assign(t,n,r,i,o),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Rt="sentient:overrides-changed";function gn(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function At(){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(Rt))}function ee(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(Rt,e),()=>window.removeEventListener(Rt,e))}function mn(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function F(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function ne(e){return typeof e=="string"?{type:"click"}:e}function ye(e){return typeof e=="string"?e:e.type}function ce(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var Ct=new Set,_t=!1;function pn(e){if(Ct.has(e))return!0;if(Ct.add(e),!_t){_t=!0;let t=()=>{_t=!1,Ct.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 Xr(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function yn(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(Xr(r))return!0;r=r.parentElement}return!1}function de(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,v=[];return t.steps.forEach(({goal:c,name:b,weight:x},g)=>{let p=(S=!1)=>{s.has(g)||S&&r!==void 0&&pn(`step\0${b}\0${x}\0${g}`)||(s.add(g),n.fireStep(b,x,g))};if(c.type==="click"){let S=y=>{let f=y.target;f instanceof Element&&yn(f,e,c.selector)&&p()};e.addEventListener("click",S),v.push(()=>e.removeEventListener("click",S));return}if(c.type==="form_submit"){let S=y=>{y.target instanceof HTMLFormElement&&e.contains(y.target)&&p()};e.addEventListener("submit",S),v.push(()=>e.removeEventListener("submit",S));return}if(c.type==="scroll_depth"){let S=Math.max(0,Math.min(1,c.threshold)),y=new IntersectionObserver(f=>{for(let h of f)if(h.intersectionRatio>=S){p(!0),y.disconnect();break}},{threshold:[S]});y.observe(e),v.push(()=>y.disconnect())}}),()=>{for(let c of v)c()}}let i=t.type==="composite"?t.all:[t],o=new Set(i.map((s,v)=>v)),l=()=>{r!==void 0&&pn(r)||n.fireGoal()},a=(s,v=!1)=>{o.delete(s),o.size===0&&(v?l():n.fireGoal())},u=[];return i.forEach((s,v)=>{if(s.type==="click"){let c=b=>{let x=b.target;x instanceof Element&&yn(x,e,s.selector)&&(t.type==="composite"?a(v):n.fireGoal())};e.addEventListener("click",c),u.push(()=>e.removeEventListener("click",c));return}if(s.type==="form_submit"){let c=b=>{b.target instanceof HTMLFormElement&&e.contains(b.target)&&(t.type==="composite"?a(v):n.fireGoal())};e.addEventListener("submit",c),u.push(()=>e.removeEventListener("submit",c));return}if(s.type==="scroll_depth"){let c=Math.max(0,Math.min(1,s.threshold)),b=new IntersectionObserver(x=>{for(let g of x)if(g.intersectionRatio>=c){t.type==="composite"?a(v,!0):l(),b.disconnect();break}},{threshold:[c]});b.observe(e),u.push(()=>b.disconnect());return}}),()=>{for(let s of u)s()}}var vn=new Set,Sn=new Set;function zr(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,100);if(t&&t===e)return`${t}-steps`;let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n+e.charCodeAt(r)>>>0;return`${t||"component"}-${n.toString(36)}-steps`}var qr=12;function Yr(e,t){let n=new Set,r=[];for(let o of t.steps){let l=o.name;!l||l.length>128||l.startsWith("funnel:")||n.has(l)||r.length===qr||(n.add(l),r.push({goalId:l,weight:Math.min(1,Math.max(0,o.weight||0))}))}let i=[...r].sort((o,l)=>o.weight-l.weight);return(r.length<t.steps.length||i.some((o,l)=>o!==r[l]))&&F()&&console.warn(`[SentientUI] "${e}": weighted_composite steps adjusted for its funnel (skipped invalid/repeated/over-12 steps, or ordered by weight)`),i}function fe(e,t,n,r,i){let o=(i==null?void 0:i.type)==="weighted_composite"?i:null,l=r!=null?r:o?zr(n):void 0;if(!l)return;let a=`${l}|${n}`;if(Sn.has(a))return;Sn.add(a);let u=o&&!vn.has(l)?Yr(n,o):null,s=u!==null&&u.length>=2;s&&vn.add(l),!(!s&&r===void 0)&&e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:s?{funnelId:l,steps:u}:{funnelId:l}})}function ve(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Zr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function be(){if(typeof window=="undefined")return Zr;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 Ue(){be().version+=1;for(let e of be().listeners)e()}var hn=()=>{};function Ye(e){return F()?(be().components.set(e.id,e),Ue(),()=>{be().components.delete(e.id),Ue()}):hn}function Ge(e){return F()?(be().slots.set(e.id,e),Ue(),()=>{be().slots.delete(e.id),Ue()}):hn}function Ot(e){F()&&(be().sections=[...e],Ue())}var bn="0.44.0",Gt=bn!=="0.0.0-dev"?{name:"react",version:bn}:void 0;function Qr(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function Ee(e,t){Qr()[e]=t}function wn(e){window.__sentient_vocabulary_override=e}function xn(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function ei(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Pe(e,t){ei()[e]=t}function kn(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let o=n.slice(0,r.index)+i;history.replaceState(history.state,"",o?"#"+o:location.pathname+location.search)}}catch(n){}return t}var Pt="__snt_editor_token",Ne=null,Et=!1;function Rn(){return Et}function ti(){try{return sessionStorage.getItem(Pt)}catch(e){return null}}function Ze(e){if(Ne)return Ne;let t=typeof window=="undefined"?null:kn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:ti();return Et=!!n,Ne=Promise.resolve(n?{token:n,fresh:!1}:null),Ne}return Et=!0,Ne=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(Pt,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),Ne}function An(){try{sessionStorage.removeItem(Pt)}catch(e){}}var Cn="sentient_preview_cell",_n="sentient_refresh_region",Nt="sentient-cell-preview-bar",we="__preview__",Te=null;function On(e){if((Te==null?void 0:Te.slotId)!==e)return null;let t=Te;return Te=null,t}function Gn(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(m({slotId:e.slotId},t))})}).then(n=>xe(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>xe("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function En(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Nt))return;let t,n;try{let u=new URLSearchParams(window.location.search);t=u.get(Cn),n=u.get(_n)}catch(u){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=Ze(r);if(!Rn())return;if(n){Te={slotId:n,session:i,base:r},Ee(n,{kind:"arms"}),Pe(n,we),At();return}if(!t)return;let o=t.lastIndexOf("~");if(o<=0)return;let l=t.slice(0,o),a=t.slice(o+1);i.then(u=>u?"token"in u?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(l)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${u.token}`}}):(xe(u.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async u=>{if(!u)return;if(!u.ok){xe(u.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await u.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&wn(s.vocabulary),s.compose!=null)Ee(l,{kind:"arms",compose:{[we]:s.compose}}),Pe(l,we);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))Ee(l,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),Pe(l,we);else if(s.blocks!=null)Ee(l,{kind:"arms",blocks:{[we]:s.blocks}}),Pe(l,we);else if(s.content!=null)Ee(l,{kind:"arms",content:s.content}),Pe(l,we);else{xe("Nothing to preview in that square yet.");return}At(),xe(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var v;try{(v=document.querySelector(`[data-sentient-slot="${l}"]`))==null||v.scrollIntoView({block:"center"})}catch(c){}},300)}).catch(()=>xe("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function xe(e){var i;if(document.getElementById(Nt))return;let t=document.createElement("div");t.id=Nt,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=()=>{An();let o=new URL(window.location.href);o.searchParams.delete(Cn),o.searchParams.delete(_n),window.location.assign(o.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var Pn=!1;function Nn(e){if(Pn||typeof window=="undefined")return;Pn=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");Ze(t).then(n=>{!n||!("token"in n)||!n.fresh||ni(t,n.token)})}function ni(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var Kn=require("react/jsx-runtime");function ri(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,Qe.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var In="https://api.sentient-ui.com/v1",Z=(0,_.createContext)({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:In,debug:!1}),Tn=!1,Tt=new Set;function ii(e,t,n){let r=(0,_.useRef)(n);r.current=n;let[i,o]=(0,_.useState)(null),[l,a]=(0,_.useState)(!1),u=(0,_.useRef)(e);u.current=e;let s=e===void 0?"":typeof e=="string"?e:JSON.stringify(M(m({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,_.useEffect)(()=>{let v=u.current;if(v===void 0||typeof window=="undefined")return;let c,b=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:g})=>{if(b)return;let p=x(typeof v=="object"&&v.cmp===void 0&&v.check?m(M(m({},v),{check:()=>u.current.check()}),v.refused?{refused:()=>{var f,h;return((h=(f=u.current).refused)==null?void 0:h.call(f))===!0}}:{}):v),S=!1,y=()=>{let f=p.refused()&&p.read()!==!0;f&&!S&&(g(t),r.current()),S=f,a(f);let h=p.read();h!==null&&Tt.add(t),o(h!=null?h:Tt.has(t)?!1:null)};y(),c=p.subscribe(y)}),()=>{b=!0,c==null||c()}},[s,t]),{granted:i,refused:l}}function Dn(e){var E,R,C,d,A,U;let[t,n]=(0,_.useState)(null),[r]=(0,_.useState)(()=>{var w;return(w=e.sessionSegment)!=null?w:ri()}),[i,o]=(0,_.useState)(kt());(0,_.useEffect)(()=>dn(()=>o(kt())),[]),(0,_.useEffect)(()=>{En(e.apiBaseUrl),typeof window!="undefined"&&/[?&]sentient_preview=[^&]*(:|%3A)/i.test(window.location.search)&&(cn(!0),import("@sentientui/react/version-preview").then(w=>w.maybeStartVersionPreview(e.apiKey,e.apiBaseUrl)).catch(()=>{})),Nn(e.apiBaseUrl)},[]);let l=(0,_.useRef)(()=>{}),a=ii(e.consentFrom,e.apiKey,()=>l.current()),u=e.consentFrom?(E=a.granted)!=null?E:Tt.has(e.apiKey)?!1:e.consent===!0:e.consent,s=e.consentFrom?a.refused:!0,v=(0,_.useRef)(s);v.current=s;let c=(0,_.useRef)(null),b=(0,_.useRef)(!1),x=(0,_.useRef)([]),g=(0,_.useRef)(!1);l.current=()=>{var P;x.current=[],g.current=!0;let w=c.current;w!=null&&w.gated?w.dispose():(P=w==null?void 0:w.takeHeld)==null||P.call(w)},(0,_.useEffect)(()=>{var q,Ve;if(v.current&&u===!1&&(x.current=[]),u===!1&&b.current&&(v.current&&((q=c.current)==null||q.destroy()),c.current=null,b.current=!1),u===!1&&!e.preConsentBehavior){v.current&&((Ve=c.current)==null||Ve.destroy()),c.current=null,n(null);return}let w=u!==!1;w&&(g.current=!1);let P=X=>{!w&&g.current&&X.gated&&X.dispose()},V=m({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:u,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,internal:e.internal,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},Gt?{sdk:Gt}:{}),L=!1,T=null,H=null,K=X=>{for(let le of x.current.splice(0))setTimeout(()=>{if(c.current!==X){g.current||x.current.push(le);return}try{le(X)}catch(Me){}},0)},B=X=>{e.engagement===!1||!w||import("@sentientui/core/engagement").then(({startEngagementCapture:le})=>{L||(H=le(X,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:X})=>{L||(T=X(M(m({},V),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),P(T),c.current=T,b.current=w,K(T),n(T),B(T))}):(T=(0,Qe.init)(V),P(T),c.current=T,b.current=w,K(T),n(T),B(T)),()=>{var X,le;L=!0,H==null||H(),x.current=x.current.concat((le=(X=T==null?void 0:T.takeHeld)==null?void 0:X.call(T))!=null?le:[]),T==null||T.dispose()}},[u]),(0,_.useEffect)(()=>{if(!t)return;let w=!1,P=async()=>{if(w)return;let L;try{L=await t.fetchWeights()}catch(T){return}if(!w)for(let T of L){let H={componentId:T.componentId,updatedAt:T.updatedAt,variants:T.variants.map(K=>{var B;return{variantId:K.variantId,pulls:K.pulls,avgReward:(B=K.avgReward)!=null?B:0}})};un(T.componentId,H)}};P();let V=setInterval(()=>{P()},6e4);return()=>{w=!0,clearInterval(V)}},[t]);let p=(R=e.ssrFallback)!=null?R:"first",S=((C=e.apiBaseUrl)!=null?C:In).replace(/\/$/,""),y=(0,_.useRef)(null);(0,_.useEffect)(()=>{var V;if(typeof process!="undefined"&&((V=process.env)==null?void 0:V.NODE_ENV)==="production")return;let w={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,internal:e.internal,apiBaseUrl:S},P=y.current;if(y.current=w,P!==null)for(let L of["apiKey","context","country","persona","internal","apiBaseUrl"])Object.is(P[L],w[L])||console.warn(`[sentient] AdaptiveProvider: \`${L}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,e.internal,S]),(0,_.useEffect)(()=>{var w;typeof process!="undefined"&&((w=process.env)==null?void 0:w.NODE_ENV)==="production"||mn({apiKey:e.apiKey,apiBaseUrl:S,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,S]);let f=(d=e.identity)==null?void 0:d.userId,h=(A=e.identity)==null?void 0:A.userHash,k=(U=e.identity)==null?void 0:U.email;(0,_.useEffect)(()=>{t&&f&&t.identify(f,{userHash:h,email:k})},[t,f,h,k]),(0,_.useEffect)(()=>{let w=e.initialLayoutOrder;if(w&&w.length>0){Ot(w);return}e.declaredSections&&e.declaredSections.length>0&&Ot(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,_.useEffect)(()=>{!F()||e.consent!==void 0||e.consentFrom!==void 0||Tn||(Tn=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,_.useEffect)(()=>{if(!F())return;let w=e.declaredSections;if(!w||w.length===0||typeof document=="undefined")return;let P=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),L=>L.getAttribute("data-sentient-id"))),V=w.filter(L=>!P.has(L));V.length>0&&console.warn(`[SentientUI] Declared section${V.length>1?"s":""} ${V.map(L=>`"${L}"`).join(", ")} ${V.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 O=(0,_.useMemo)(()=>t&&i?fn(t):t,[t,i]),N=(0,_.useMemo)(()=>{var w,P,V,L,T,H,K,B,q;return{client:O,apiKey:e.apiKey,initialAssignments:(w=e.initialAssignments)!=null?w:{},initialUnified:(P=e.initialUnified)!=null?P:oi,sessionSegment:r,ssrFallback:p,onAssignment:e.onAssignment,initialLayoutOrder:(V=e.initialLayoutOrder)!=null?V:null,initialSlots:(L=e.initialSlots)!=null?L:{},initialSlotConfig:(T=e.initialSlotConfig)!=null?T:{},initialPalette:(H=e.initialPalette)!=null?H:null,initialVocabulary:(K=e.initialVocabulary)!=null?K:null,initialPersona:(B=e.initialPersona)!=null?B:null,apiBaseUrl:S,debug:(q=e.debug)!=null?q:!1}},[O,e.apiKey,e.initialAssignments,e.initialUnified,r,p,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,S,e.debug]);return(0,Kn.jsx)(Z.Provider,{value:N,children:e.children})}function j(){return(0,_.useContext)(Z).client}function ie(){return(0,_.useContext)(Z).apiKey}function et(){return(0,_.useContext)(Z).initialAssignments}var oi=[];function tt(){return(0,_.useContext)(Z).initialUnified}function Ie(){return(0,_.useContext)(Z).sessionSegment}function Ln(){return(0,_.useContext)(Z).ssrFallback}function nt(){return(0,_.useContext)(Z).onAssignment}function Fn(){return(0,_.useContext)(Z).debug}function Vn(){let e=(0,_.useContext)(Z).initialLayoutOrder,t=(0,_.useSyncExternalStore)(ee,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function rt(){return(0,_.useContext)(Z).initialSlots}function Mn(){return(0,_.useContext)(Z).initialPersona}function jn(){return(0,_.useContext)(Z).initialSlotConfig}function $n(){return(0,_.useContext)(Z).initialPalette}function Bn(){return(0,_.useContext)(Z).initialVocabulary}function Un(){return(0,_.useContext)(Z).apiBaseUrl}var me=require("react");var W=require("react"),Wn=require("@sentientui/core");var oe=require("react"),it=require("@sentientui/policy");function Se(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let o=i.indexOf(":");if(o!==-1&&i.slice(0,o)===e)return i.slice(o+1)}}catch(r){}return null}function ot(e,t,n,r,i){let o=et(),l=Ln(),a=j(),u=Ie(),s=nt(),v=Fn(),c=(0,oe.useRef)(null),b=(0,oe.useSyncExternalStore)(ee,()=>Se(e),()=>null),x=b&&t.includes(b)?b:null,g=(0,oe.useRef)(null);(0,oe.useEffect)(()=>{v&&x&&g.current!==x&&(g.current=x,console.info(`[sentient] override active: ${e} -> ${x}`))},[v,x,e]);let[p,S]=(0,oe.useState)(()=>{var k,O;if(x)return{variantId:x,content:null,isLoading:!1,settled:!0};if(!a){let N=o[e];return N&&t.includes(N)?{variantId:N,content:null,isLoading:!1,settled:!0}:l==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content))return{variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0};let h=wt(e);if(h){let N=(0,it.pickFromWeights)(h.variants,t);if(N)return{variantId:N,content:null,isLoading:!1,settled:!0}}return{variantId:(O=t[0])!=null?O:null,content:null,isLoading:!1,settled:!1}}),y=f=>{s&&c.current!==f&&(c.current=f,s(e,f))};return(0,oe.useEffect)(()=>{var k;if(x||!a)return;let f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content)){S({variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0}),y(f.variantId);return}let h=wt(e);if(h&&p.settled&&p.variantId&&p.variantId===(0,it.pickFromWeights)(h.variants,t)){y(p.variantId);return}S(O=>{var N;return O.variantId?O:{variantId:(N=t[0])!=null?N:null,content:null,isLoading:!1,settled:!1}})},[x,a,e,u]),(0,oe.useEffect)(()=>{if(x||!a)return;let f=a.getAssignment(e,u);if(f&&t.includes(f.variantId))return;let h=!1,k=i==null?void 0:i.onUnified;return(k?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(N=>{var E;if(!h&&N){if(N.unified===!0){k==null||k();return}!t.includes(N.variantId)&&!N.content||(S({variantId:N.variantId,content:(E=N.content)!=null?E:null,isLoading:!1,settled:!0}),y(N.variantId))}}),()=>{h=!0}},[x,a,e,u]),(0,oe.useEffect)(()=>{if(!x&&a)return ln(e,f=>{var O;let h=a.getAssignment(e,u);if(h&&(t.includes(h.variantId)||h.content)){S({variantId:h.variantId,content:(O=h.content)!=null?O:null,isLoading:!1,settled:!0}),y(h.variantId);return}let k=(0,it.pickFromWeights)(f.variants,t);k&&(S({variantId:k,content:null,isLoading:!1,settled:!0}),y(k))})},[x,a,e,u]),x?{variantId:x,content:null,isLoading:!1,settled:!0,isOverride:!0}:p}function st(e,t,n){let r=j(),i=ie(),o=Object.keys(t).join("\0"),l=(0,W.useMemo)(()=>Object.keys(t),[o]),{variantId:a,content:u,isOverride:s=!1,settled:v}=ot(e,l,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[c,b]=(0,W.useState)(null),x=(0,W.useRef)(null),g=(0,W.useCallback)(d=>{x.current=d,b(d)},[]),p=n.goal,S=typeof p=="string"?p:JSON.stringify(p),y=(0,W.useMemo)(()=>p?ne(p):null,[S]),f=p?ye(p):"";(0,W.useEffect)(()=>Ye({id:e,variantIds:l,goal:f}),[e,l,f]);let h=(0,W.useRef)(null);(0,W.useEffect)(()=>{s||v&&(!r||!a||!i||!c||h.current!==a&&(h.current=a,ve(r,i,e,a)))},[r,a,i,e,c,s,v]);let k=(0,W.useRef)(!1),O=(0,W.useRef)(new Set);(0,W.useEffect)(()=>{k.current=!1,O.current=new Set},[a,y]);let N=n.funnel;(0,W.useEffect)(()=>{s||!v||!r||!y||fe(r,i,e,N,y)},[r,i,e,N,y,s,v]);let E=n.cursorSignal===!0;(0,W.useEffect)(()=>{if(!E||s||!v||!r||!a||!c)return;let d=null,A=0,U=()=>{A=Date.now(),d=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-A}}),d=null},800)},w=()=>{d!==null&&(clearTimeout(d),d=null)};return c.addEventListener("mouseenter",U),c.addEventListener("mouseleave",w),()=>{c.removeEventListener("mouseenter",U),c.removeEventListener("mouseleave",w),d!==null&&clearTimeout(d)}},[E,r,a,i,e,c,s,v]);let R=(0,W.useRef)(n.microSignalGoals);R.current=n.microSignalGoals;let C=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,W.useEffect)(()=>{if(s||!v||!r||!a||!c)return;let d=Date.now();return(0,Wn.attachMicroSignalDetectors)((A,U={})=>{var T,H,K;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:m({signalType:A},U)});let w=(T=R.current)==null?void 0:T[A];if(!w||O.current.has(A))return;O.current.add(A);let P=typeof w=="string"?w:w.name,V=typeof w=="string"?1:(H=w.weight)!=null?H:1,L=typeof w=="string"?0:(K=w.stepIndex)!=null?K:0;r.goal(P,{metadata:m({signalType:A},U),weight:V,stepIndex:L})},c,d)},[r,a,i,e,c,C,s,v]),(0,W.useEffect)(()=>{if(s||!v||!r||!a||!c||!y)return;let d=ce(y);return de(c,y,{fireGoal:()=>{k.current||(k.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:f,payload:m({reward:1},d!==void 0?{goalValue:d}:{})}),r.goal(f,m({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},d!==void 0?{value:d}:{})))},fireStep:(A,U,w)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:A,payload:{reward:U}}),r.goal(A,{metadata:{},weight:U,stepIndex:w})}},f)},[r,a,i,e,c,y,f,s,v]),{client:r,variantIds:l,variantId:a,content:u,settled:v,isOverride:s,goalLabel:f,ref:g,nodeRef:x}}var D=require("react"),Ae=require("@sentientui/core"),$t=require("@sentientui/core/region");var te=require("react"),Hn=require("@sentientui/core");var Jn=new Set,si={kind:"arms"};function Xn(e,t){var O,N,E;let n=j(),r=(0,te.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=(0,te.useRef)(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let o=(0,te.useRef)(t==null?void 0:t.skeleton);o.current=t==null?void 0:t.skeleton;let l=rt(),a=jn(),u=$n(),s=Bn(),v=(0,te.useSyncExternalStore)(ee,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_config_overrides)==null?void 0:R[e]:void 0},()=>{}),c=(0,te.useSyncExternalStore)(ee,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_overrides)==null?void 0:R[e]:void 0},()=>{}),b=R=>R==null?"":(0,Hn.armOfResult)(R),x=(0,te.useCallback)(R=>{var C,d;return(d=(C=n==null?void 0:n.onSlotsChanged)==null?void 0:C.call(n,R))!=null?d:(()=>{})},[n]);(0,te.useSyncExternalStore)(x,()=>{var R;return(R=n==null?void 0:n.getSlotConfig(e))!=null?R:null},()=>null),(0,te.useSyncExternalStore)(x,()=>b(n==null?void 0:n.getSlotResult(e)),()=>"");let g=v===void 0?a[e]:void 0,p=v===void 0&&g===void 0&&n?n.getSlotConfig(e):null,S=(O=u!=null?u:n==null?void 0:n.getSitePalette())!=null?O:null,y=(E=s!=null?s:(N=n==null?void 0:n.getStyleVocabulary)==null?void 0:N.call(n))!=null?E:null,f=(()=>{var R,C,d;if(v!==void 0)return{config:v,arm:b(c),palette:S,vocabulary:(R=xn())!=null?R:y,source:"override"};if(t!=null&&t.forcedArm)return{config:si,arm:t.forcedArm,palette:S,vocabulary:y,source:"override"};if(g!==void 0)return{config:g,arm:b((C=l[e])!=null?C:n==null?void 0:n.getSlotResult(e)),palette:S,vocabulary:y,source:"preloaded"};if(p!==null){let A=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:p,arm:b((d=n==null?void 0:n.getSlotResult(e))!=null?d:l[e]),palette:S,vocabulary:y,source:A?"client":"seeded"}}return{config:null,arm:"",palette:S,vocabulary:y,source:"none"}})(),h=(t==null?void 0:t.defer)===!0,k=f.source==="preloaded"||f.source==="override";return(0,te.useEffect)(()=>{var V,L,T,H,K;if(!n||n.isLocal===!0||k||h)return;let R=f.source==="none",C=R&&(L=(V=r.current)==null?void 0:V.call(r))!=null?L:null,d=C!=null&&C!==""?{[e]:C}:void 0,A=(T=i.current)==null?void 0:T.call(i),U=R&&(K=(H=o.current)==null?void 0:H.call(o))!=null?K:null,w=m(m({},A?{render:{[e]:A}}:{}),U?{skeletons:{[e]:U}}:{}),P=Object.keys(w).length>0;return n.requestSlots?P?n.requestSlots([e],d,w):d?n.requestSlots([e],d):n.requestSlots([e]):R&&(U?n.reportSlots([e],d!=null?d:{},{[e]:U}):d?n.reportSlots([e],d):n.reportSlots([e])),()=>{var B;return(B=n.cancelSlots)==null?void 0:B.call(n,[e])}},[n,k,f.source,e,h]),(0,te.useEffect)(()=>{!F()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||Jn.has(e)||(Jn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,f.source,e]),f}var Ke=require("react");var $=require("react/jsx-runtime");function It(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var he={none:"0",sm:"8px",md:"16px",lg:"24px"},Dt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Zn={sm:"0.875em",md:"1em",lg:"1.25em"},ai={sm:"1.25em",md:"1.5em",lg:"2em"},zn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},qn={sm:"8px",md:"16px",lg:"32px"},li={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},ui={normal:"400",medium:"500",bold:"700"};function Yn(e,t){return m(m({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?m({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Qn(e,t,n){var i,o,l,a;let r=t==null?void 0:t.accent;return M(m({display:"inline-block",padding:(i=zn[n!=null?n:"md"])!=null?i:zn.md,borderRadius:(o=t==null?void 0:t.radius)!=null?o:"8px",font:"inherit"},n?{fontSize:Zn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(l=t==null?void 0:t.primaryBg)!=null?l:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function ci({node:e,opts:t}){var i,o,l,a,u;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(l=(o=t.palette)==null?void 0:o.border)!=null?l:"currentColor"}`,borderRadius:(u=(a=t.palette)==null?void 0:a.radius)!=null?u:"8px"};return(0,$.jsxs)("form",{onSubmit:s=>{var b,x,g;s.preventDefault();let v=new FormData(s.currentTarget),c={};for(let p of e.fields)c[p.name]=String((b=v.get(p.name))!=null?b:"");(x=t.onFormGoal)==null||x.call(t,e.submitGoal);try{(g=t.onFormSubmit)==null||g.call(t,c)}catch(p){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var v,c;return(0,$.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?(0,$.jsx)("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?(0,$.jsx)("select",{name:s.name,required:s.required,style:r,children:((v=s.options)!=null?v:[]).map(b=>(0,$.jsx)("option",{value:b,children:b},b))}):(0,$.jsx)("input",{name:s.name,type:(c=s.inputType)!=null?c:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),(0,$.jsx)("button",{type:"submit",style:Qn(n,t.palette),children:e.submitLabel})]})}function di(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(o=>o.id===n))==null?void 0:i.classes:void 0}function er(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function ke(e,t){var i;let n=fi(e,t),r=er(e.like,t);return n&&r?(0,Ke.cloneElement)(n,{style:M(m({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function fi(e,t){var n,r,i,o,l,a,u,s,v,c,b,x,g,p,S,y,f,h,k,O,N,E,R;try{let C=di(e,t);switch(e.type){case"stack":{let d=(r=he[(n=e.gap)!=null?n:"md"])!=null?r:he.md,A=e.surface==="raised"&&!C,U=(i=e.pad)!=null?i:A?"md":void 0;return(0,$.jsx)("div",M(m({},C?{className:C}:{}),{style:m(m(m(m(m({display:"flex",flexDirection:e.direction,gap:d},e.align?{alignItems:Dt[e.align]}:{}),e.justify?{justifyContent:Dt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),U?{padding:(o=he[U])!=null?o:he.md}:{}),A?M(m(m({},(l=t.palette)!=null&&l.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((u=t.palette)!=null&&u.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(v=(s=t.palette)==null?void 0:s.border)!=null?v:"currentColor"}`,borderRadius:(b=(c=t.palette)==null?void 0:c.radius)!=null?b:"8px"}):{}),children:((x=e.children)!=null?x:[]).map((w,P)=>{let V=ke(w,t);return V===null?null:(0,$.jsx)(Ke.Fragment,{children:V},P)})}))}case"grid":{let d=(p=he[(g=e.gap)!=null?g:"md"])!=null?p:he.md;return(0,$.jsx)("div",M(m({},C?{className:C}:{}),{style:m(m({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${d}) / ${e.columns})), 1fr))`,gap:d},e.align?{alignItems:Dt[e.align]}:{}),e.pad?{padding:(S=he[e.pad])!=null?S:he.md}:{}),children:((y=e.children)!=null?y:[]).map((A,U)=>{let w=ke(A,t);return w===null?null:(0,$.jsx)(Ke.Fragment,{children:w},U)})}))}case"text":return C?(0,$.jsx)("p",{className:C,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,$.jsx)("p",{style:m(m(m(m(m({margin:0},e.size?{fontSize:Zn[e.size]}:{}),e.weight?{fontWeight:ui[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Yn(e.tone,t.palette)),children:e.value});case"heading":{let d=`h${e.level}`;return C?(0,$.jsx)(d,{className:C,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,$.jsx)(d,{style:m(m({margin:0,fontSize:ai[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let d=(h=e.emphasis)!=null?h:"primary";return(0,$.jsx)("a",M(m(m({href:It(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),C?{className:C}:{style:Qn(d,t.palette,e.size)}),{children:e.label}))}case"link":return(0,$.jsx)("a",M(m(m({href:It(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),C?{className:C}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return(0,$.jsx)("img",M(m({src:It(e.src),alt:e.alt},C?{className:C}:{}),{style:m(m({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:li[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return C?(0,$.jsx)("span",{className:C,children:e.value}):(0,$.jsx)("span",{style:m({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(O=(k=t.palette)==null?void 0:k.border)!=null?O:"currentColor"}`},Yn(e.tone,t.palette)),children:e.value});case"spacer":return(0,$.jsx)("div",{style:{height:(N=qn[e.size])!=null?N:qn.md}});case"divider":return(0,$.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(R=(E=t.palette)==null?void 0:E.border)!=null?R:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,$.jsx)(ci,{node:e,opts:t});default:return null}}catch(C){return null}}function at(e,t){var o,l,a,u;let n=ke(e.tree,t);if(n===null)return null;let r=(o=e.surface)!=null&&o.like?(a=(l=t.vocabulary)==null?void 0:l.entries.find(s=>s.id===e.surface.like))==null?void 0:a.classes:void 0,i=er((u=e.surface)==null?void 0:u.like,t);return r?(0,$.jsx)("div",M(m({className:r},i?{style:{color:i}}:{}),{children:n})):n}var ge=require("react"),lt=require("@sentientui/core/region");function ut(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function ct(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function Re(e){return ut(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+Re(n),0):(0,ge.isValidElement)(e)?Re(ct(e)):0}function gi(e,t){return Array.isArray(t)?(0,ge.cloneElement)(e,void 0,...t):(0,ge.cloneElement)(e,void 0,t)}function Lt(e,t){if(ut(e))return t;if(Array.isArray(e))return e.map(n=>Lt(n,t));if((0,ge.isValidElement)(e)){let n=ct(e);return Re(n)===0?e:gi(e,Lt(n,t))}return e}function tr(e,t){return Re(e)===1?Lt(e,t):null}var re=e=>e.join("/");function Ft(e,t,n){if(ut(e)){n.leafPaths.push(t),n.texts.push((0,lt.normalizeLeafText)(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>Ft(r,[...t,i],n));return}(0,ge.isValidElement)(e)&&(n.elements.set(re(t),e),Ft(ct(e),[...t,"c"],n))}function Mt(e){let t={leafPaths:[],texts:[],elements:new Map};return Ft(e,[],t),t}function mi(e){return Mt(e).texts}function nr(e){let t=mi(e);return t.length===0?null:(0,lt.skeletonFingerprint)(t)}function pi(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function rr(e,t){let n=t.reduce((i,o)=>Math.max(i,o+1),0),r=[];for(let i=0;i<n;i++){let o=t.flatMap((a,u)=>a===i?[pi(e.leafPaths[u])]:[]);if(o.length===0){r.push(null);continue}let l=o[0];for(let a of o.slice(1)){let u=new Set(a.map(re));l=l.filter(s=>u.has(re(s)))}r.push(l.length>0?l[l.length-1]:null)}return r}function Vt(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 jt(e,t){let n=Mt(t);if(n.texts.length!==e.leaves.length||n.texts.some((o,l)=>o!==e.leaves[l]))return null;let r=rr(n,e.leafToNode),i=e.nodes.map((o,l)=>{let a=r[l],u=a?n.elements.get(re(a)):void 0,s=!!u&&(typeof u.type=="string"||Vt(u)!==void 0);return M(m({},o),{restylable:s})});return M(m({},e),{nodes:i})}function ir(e,t,n){var g;let r=Mt(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((p,S)=>Math.max(p,S+1),0);for(let p of Object.keys(t.nodes))if(!/^\d+$/.test(p)||Number(p)>=i)return null;let o=rr(r,n),l=new Map;n.forEach((p,S)=>{l.has(p)||l.set(p,S)});let a=new Map(r.leafPaths.map((p,S)=>[re(p),S])),u=new Set,s=new Map,v=!1;for(let[p,S]of Object.entries(t.nodes)){let y=Number(p),f=o[y];if(S.hidden&&(f?u.add(re(f)):v=!0),S.like!==void 0){let h=o[S.like],k=f?r.elements.get(re(f)):void 0,O=h?Vt(r.elements.get(re(h))):void 0;!f||O===void 0||Vt(k)===void 0?v=!0:s.set(re(f),O)}}let c=new Map(Object.entries((g=t.order)!=null?g:{})),b=(p,S)=>{var y;if(ut(p)){let f=a.get(re(S));if(f===void 0)return p;let h=n[f],k=(y=t.nodes[String(h)])==null?void 0:y.text;return k===void 0?p:l.get(h)===f?k:""}if(Array.isArray(p)){let f=p.map((h,k)=>b(h,[...S,k]));for(let[h,k]of c){let O=k.map(R=>{let C=o[R];return!C||C.length!==S.length+1||re(C.slice(0,-1))!==re(S)?-1:C[C.length-1]});if(O.some(R=>R<0))continue;let N=[...O].sort((R,C)=>R-C),E=[...f];N.forEach((R,C)=>{f[R]=E[O[C]]}),c.delete(h)}return f}if((0,ge.isValidElement)(p)){let f=re(S);if(u.has(f))return null;let h=ct(p);if(Re(h)===0)return p;let k=b(h,[...S,"c"]),O=s.get(f),N=O!==void 0?{className:O}:void 0;return Array.isArray(k)?(0,ge.cloneElement)(p,N,...k):(0,ge.cloneElement)(p,N,k)}return p},x=b(e,[]);return v||c.size>0?null:x}var lr=require("react/jsx-runtime"),or=new Set,sr=new Set,ar=new Set,dt="authored.";function De({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:o,as:l="div",reportBaselineText:a=!0,funnel:u,microSignalGoals:s,clientOnly:v,agentDataByVariant:c,agentData:b,variantsOnly:x=!1}){var Zt,Qt;let g=j(),p=ie(),S=(0,D.useRef)(null),[y,f]=(0,D.useState)(!1);(0,D.useEffect)(()=>{f(!0)},[]);let h=v===!0&&(!y||!g),k=(0,D.useMemo)(()=>nr(t),[t]),O=n?Object.keys(n).join("|"):"",N=(0,D.useMemo)(()=>m({fp:k!=null?k:"0000000000000000",forms:!!r,compose:!0,content:Re(t)===1,ops:!1},O!==""?{authored:O.split("|"),children:!x}:{}),[k,t,r,O,x]),E=()=>{var Y;let G=S.current;if(!G||!a)return null;let I=(0,$t.captureRegionSkeleton)(G);return I.skeleton?(Y=jt(I.skeleton,t))!=null?Y:M(m({},I.skeleton),{editable:!1,nodes:I.skeleton.nodes.map(J=>M(m({},J),{restylable:!1}))}):{status:I.reason}},R=(0,D.useSyncExternalStore)(ee,()=>n?Se(e):null,()=>null),C=R===null||!n?null:Object.prototype.hasOwnProperty.call(n,R)?`${dt}${R}`:x?`${dt}${Object.keys(n)[0]}`:"baseline",{config:d,arm:A,palette:U,vocabulary:w,source:P}=Xn(e,{forcedArm:C,baselineText:a?()=>{var G,I;return(I=(G=S.current)==null?void 0:G.textContent)!=null?I:null}:void 0,render:()=>N,skeleton:E,defer:h}),V=A!==""?(Zt=d==null?void 0:d.blocks)==null?void 0:Zt[A]:void 0,L=A!==""?(Qt=d==null?void 0:d.compose)==null?void 0:Qt[A]:void 0,T=(V!==void 0&&(0,Ae.containsFormBlock)(V)||L!==void 0&&(0,Ae.containsFormBlock)(L.tree))&&!r;(0,D.useEffect)(()=>{!T||!F()||or.has(e)||(or.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.`))},[T,e]);let H=G=>{!g||P==="override"||(P!=="seeded"&&g.componentGoal(e,G),g.goal(G,{metadata:{componentId:e,arm:A},weight:1,stepIndex:0}))},K=t,B=!1,q=A.startsWith(dt)?A.slice(dt.length):null;if((d==null?void 0:d.blocked)==="variant_history")B=!0;else if(q!==null)n&&Object.prototype.hasOwnProperty.call(n,q)?K=n[q]:B=!0;else if(L!==void 0){let G=T?null:at(L,{palette:U,vocabulary:w,onFormSubmit:r,onFormGoal:H});G===null?B=!0:K=G}else if(V!==void 0){let G=T?null:ke(V,{palette:U,vocabulary:w,onFormSubmit:r,onFormGoal:H});G===null?B=!0:K=G}else if((d==null?void 0:d.edits)!==void 0&&P!=="none"){let G=d.edits,I=G.fp===k?ir(t,G.edits,G.leafToNode):null;I===null?B=!0:K=I}else if((d==null?void 0:d.content)!==void 0&&P!=="none"){let G=tr(t,d.content);G===null?B=!0:K=G}let Ve=B&&V===void 0&&L===void 0&&(d==null?void 0:d.edits)===void 0&&q===null&&(d==null?void 0:d.blocked)===void 0;(0,D.useEffect)(()=>{(d==null?void 0:d.blocked)!=="variant_history"||!F()||ar.has(e)||(ar.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[d==null?void 0:d.blocked,e]);let X=q!==null&&!B?q:null;(0,D.useEffect)(()=>{var ue;if(!X||!a||!g)return;let G=S.current;if(!G)return;let I=(0,$t.captureRegionSkeleton)(G),Y=I.skeleton?jt(I.skeleton,n==null?void 0:n[X]):null,J=(ue=G.textContent)==null?void 0:ue.trim();g.reportSlots([],void 0,void 0,{[e]:[m(m({key:X},J?{text:J}:{}),Y?{skeleton:Y}:{})]})},[X,g,e,h]);let le=B&&(d==null?void 0:d.edits)!==void 0&&(P==="preloaded"||P==="client");(0,D.useEffect)(()=>{var G;!le||!(d!=null&&d.edits)||(G=g==null?void 0:g.reportDrift)==null||G.call(g,e,d.edits.fp,k,d.edits.fp===k?"unaddressable":"fp_mismatch")},[le,e,k,g]);let Me=K===t;(0,D.useEffect)(()=>{var I;if(!(d!=null&&d.needsSkeleton)||!Me)return;let G=E();G&&((I=g==null?void 0:g.reportSkeleton)==null||I.call(g,e,G))},[d==null?void 0:d.needsSkeleton,Me,e,g,h]),(0,D.useEffect)(()=>{if(!Me)return;let G=On(e);if(!G)return;let I=E();Gn(G,I&&"status"in I?{status:I.status}:{skeleton:I})},[e,Me,h]),(0,D.useEffect)(()=>{!Ve||!F()||sr.has(e)||(sr.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.`))},[Ve,e]);let pt=d!=null&&d.blocks?Object.keys(d.blocks).sort().join("|"):"",yt=n?[...x?[]:["baseline"],...O.split("|")].join("|"):"";(0,D.useEffect)(()=>yt!==""?Ye({id:e,variantIds:yt.split("|")}):Ge({id:e,arms:pt===""?void 0:pt.split("|")}),[e,pt,yt]);let Jt=(0,D.useRef)(null);(0,D.useEffect)(()=>{!g||P==="none"||P==="seeded"||P==="override"||A===""||B||Jt.current!==A&&(Jt.current=A,ve(g,p,e,A))},[g,p,e,A,P,B]);let pe=P!=="none"&&P!=="seeded"&&!B,vt=pe?A:"",Ht=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);(0,D.useEffect)(()=>{if(!g||!i||P==="override")return;let G=S.current;if(!G)return;let I=ye(i),Y=ce(i),J=!1;return de(G,ne(i),{fireGoal:()=>{J||(J=!0,pe&&(Y!==void 0?g.componentGoal(e,I,{value:Y}):g.componentGoal(e,I)),g.goal(I,m({metadata:{componentId:e,arm:vt},weight:1,stepIndex:0},Y!==void 0?{value:Y}:{})))},fireStep:(ue,Xe,ht)=>{pe&&g.componentGoal(e,ue,{reward:Xe}),g.goal(ue,{metadata:{componentId:e,arm:vt},weight:Xe,stepIndex:ht})}},I)},[g,e,Ht,A,P,B,pe,vt,h]);let St=(0,D.useMemo)(()=>i?ne(i):null,[Ht]);(0,D.useEffect)(()=>{P==="override"||!g||!St||fe(g,p,e,u,St)},[g,p,e,u,St,P]);let Xt=(0,D.useRef)(s);Xt.current=s;let zt=(0,D.useRef)(new Set),Fr=s?JSON.stringify(s):"";(0,D.useEffect)(()=>{if(!g||P==="override"||!pe||A==="")return;let G=S.current;if(G)return(0,Ae.attachMicroSignalDetectors)((I,Y={})=>{var en,tn,nn;g.track({projectId:p,componentId:e,variantId:A,eventType:"micro_signal",payload:m({signalType:I},Y)});let J=(en=Xt.current)==null?void 0:en[I];if(!J||zt.current.has(I))return;zt.current.add(I);let ue=typeof J=="string"?J:J.name,Xe=typeof J=="string"?1:(tn=J.weight)!=null?tn:1,ht=typeof J=="string"?0:(nn=J.stepIndex)!=null?nn:0;g.goal(ue,{metadata:m({componentId:e,arm:A,signalType:I},Y),weight:Xe,stepIndex:ht})},G,Date.now())},[g,p,e,A,P,pe,Fr,h]);let qt=(0,D.useRef)({agentData:b,agentDataByVariant:c});qt.current={agentData:b,agentDataByVariant:c};let Yt=(0,D.useRef)(null);(0,D.useEffect)(()=>{var ue;if(!g||P==="override"||!pe||A===""||Yt.current===A)return;let{agentData:G,agentDataByVariant:I}=qt.current,Y=q!=null?q:A,J=I!==void 0?Object.prototype.hasOwnProperty.call(I,Y)?I[Y]:void 0:G;J!==void 0&&(Yt.current=A,(ue=g.reportAgentData)==null||ue.call(g,e,A,J))},[g,e,A,pe,q,P]);let He=(0,D.useRef)(null);(0,D.useEffect)(()=>{let G=S.current;if(G){if(He.current===null){He.current=A;return}He.current!==A&&(He.current=A,(0,Ae.reveal)(G))}},[A,h]);let Vr=(0,D.useMemo)(()=>m({"data-sentient-slot":e},A!==""?{"data-sentient-arm":A}:{}),[e,A]);return h?null:(0,lr.jsx)(l,M(m({ref:S,className:o},Vr),{children:K}))}var Ce=require("react/jsx-runtime");function yi(e){var v,c;let{client:t,variantId:n,content:r,ref:i}=st(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[o,l]=(0,me.useState)(!1);(0,me.useEffect)(()=>{l(!0)},[]);let a=(v=e.as)!=null?v:"div";if(e.clientOnly&&(!o||!t)||!n)return null;let u=(c=e.variants[n])!=null?c:null,s=u===null?r:null;return F()&&u===null&&s===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),(0,Ce.jsx)(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:u!=null?u:s})}var vi=(0,me.memo)(yi,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function ur(e){if(e.variants===void 0)return(0,Ce.jsx)(De,m({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=$e(n,["variants"]);return(0,Ce.jsx)(De,M(m({},i),{children:t.children,variants:r}))}return(0,Ce.jsx)(Si,m({},t))}function Si(e){var c;let[t,n]=(0,me.useState)(null),{id:r}=e,i=(0,me.useCallback)(()=>n(r),[r]),o=j(),l=tt().includes(r)||((c=o==null?void 0:o.isUnified)==null?void 0:c.call(o,r))===!0;if(t!==r&&!l)return(0,Ce.jsx)(vi,M(m({},e),{onUnified:i}));let b=e,{variants:a,children:u}=b,s=$e(b,["variants","children"]),v=Object.keys(a)[0];return(0,Ce.jsx)(De,M(m({},s),{variants:a,variantsOnly:!0,children:v!==void 0?a[v]:null}))}var z=require("react");var dr=require("react/jsx-runtime");function cr({id:e,default:t,component:n="span",className:r,goal:i}){var N;let o=j(),l=ie(),a=nt(),u=Ie(),s=(0,z.useRef)(null),v=(0,z.useRef)(null),c=(0,z.useSyncExternalStore)(ee,()=>Se(e),()=>null),[b,x]=(0,z.useState)(()=>{var E,R;return(R=(E=o==null?void 0:o.getAssignment(e,u))==null?void 0:E.content)!=null?R:null}),[g,p]=(0,z.useState)(()=>{var E,R;return(R=(E=o==null?void 0:o.getAssignment(e,u))==null?void 0:E.variantId)!=null?R:null});(0,z.useEffect)(()=>{if(c||!o)return;let E=o.getAssignment(e,u);if((E==null?void 0:E.content)!==void 0){p(E.variantId),x(E.content);return}let R=!1;return o.assign(e).then(C=>{if(!R){if(!C){F()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}p(C.variantId),C.content&&x(C.content)}}),()=>{R=!0}},[o,e,u,c]),(0,z.useEffect)(()=>{c||!o||!g||!l||s.current!==g&&(s.current=g,o.track({projectId:l,componentId:e,variantId:g,eventType:"variant_assigned",payload:{}}),a==null||a(e,g))},[o,g,l,e,a,c]);let S=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),y=(0,z.useMemo)(()=>i===void 0?null:ne(i),[S]),f=i===void 0?null:typeof i=="string"?i:y.type,h=(0,z.useRef)(!1);(0,z.useEffect)(()=>{h.current=!1},[g,S]),(0,z.useEffect)(()=>{c||!o||!l||fe(o,l,e,void 0,y)},[o,l,e,y,c]),(0,z.useEffect)(()=>{if(c||!o||!g||!l||!y||!f)return;let E=v.current;if(!E)return;let R=ce(y);return de(E,y,{fireGoal:()=>{h.current||(h.current=!0,o.track({projectId:l,componentId:e,variantId:g,eventType:"goal_achieved",goalType:f,payload:m({reward:1},R!==void 0?{goalValue:R}:{})}),o.goal(f,m({metadata:{componentId:e,variantId:g},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(C,d,A)=>{o.track({projectId:l,componentId:e,variantId:g,eventType:"goal_achieved",goalType:C,payload:{reward:d}}),o.goal(C,{metadata:{},weight:d,stepIndex:A})}})},[o,g,l,e,y,f,c]);let k=b!=null?b:t;if(c){let E=o==null?void 0:o.getAssignment(e,u);k=E&&E.variantId===c&&(N=E.content)!=null?N:t}return(0,dr.jsx)(n,{ref:E=>{v.current=E},className:r,children:k})}var ft=require("react");function We(e){var t,n;return m(m(m({metadata:(t=e==null?void 0:e.metadata)!=null?t:{},weight:(n=e==null?void 0:e.reward)!=null?n:1,stepIndex:0},(e==null?void 0:e.value)!==void 0?{value:e.value}:{}),(e==null?void 0:e.currency)!==void 0?{currency:e.currency}:{}),(e==null?void 0:e.externalId)!==void 0?{externalId:e.externalId}:{})}function Le(e){let t=j(),n=(0,ft.useRef)(new Set);return(0,ft.useCallback)((r,i)=>{if(!Se(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,We(i))}},[t,e])}var Je=require("react");function fr(e,t={}){let u=t,{componentId:n}=u,r=$e(u,["componentId"]),i=j(),o=Le(n!=null?n:""),l=(0,Je.useRef)(!1),a=(0,Je.useRef)(r);a.current=r,(0,Je.useEffect)(()=>{if(!(!i||l.current||i.gated)){if(l.current=!0,n){o(e,a.current);return}i.goal(e,We(a.current))}},[i,n,e,o])}var Fe=require("react");var gr=new Set,mr=new Map;function hi(e,t,n,r){let i=r;if(r){let l=mr.get(t);l&&l!==n?(F()&&console.warn(`[SentientUI] useGoal('${n}'): '${l}' is already primary on this page`),i=!1):mr.set(t,n)}let o=`${t}|${n}|${i?"primary":""}`;gr.has(o)||(gr.add(o),e.track({projectId:t,componentId:"__session__",eventType:"goal_declared",payload:i?{goalId:n,primary:!0}:{goalId:n}}))}function pr(e,t={}){let{primary:n=!1,componentId:r}=t,i=j(),o=ie(),l=Le(r!=null?r:""),a=(0,Fe.useRef)(!1);return(0,Fe.useEffect)(()=>{!i||i.gated||!o||hi(i,o,e,n)},[i,o,e,n]),(0,Fe.useCallback)(u=>{if(u!=null&&u.once){if(a.current)return;a.current=!0}if(r){l(e,u);return}i==null||i.goal(e,We(u))},[i,r,l,e])}var yr=require("@sentientui/core"),vr=require("@sentientui/policy"),hr=require("react/jsx-runtime");function Bt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function bi(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Bt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Bt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Bt((0,vr.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,yr.renderPrePaintScript)(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function Sr(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:(0,hr.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:bi(e)}})}var ae=require("react"),kr=require("@sentientui/policy");var se=require("react"),_e=require("@sentientui/core"),br=require("@sentientui/policy");function gt(e,t){let n=j(),r=rt(),[,i]=(0,se.useReducer)(c=>c+1,0),o=(0,se.useSyncExternalStore)(ee,()=>{var c;return typeof window!="undefined"?(c=window.__sentient_slot_overrides)==null?void 0:c[e]:void 0},()=>{}),l=o===void 0?r[e]:void 0,a=o===void 0&&l===void 0&&n?n.getSlotResult(e):null,u=(n==null?void 0:n.isLocal)===!0&&o===void 0&&l===void 0&&a===null;(0,se.useEffect)(()=>{if(!u||!n)return;let c=!1;return n.decide({slots:[t]}).then(b=>{!c&&b&&i()}),()=>{c=!0}},[n,e,u]);let s=(()=>{if(o!==void 0)return{result:o,arm:(0,_e.armOfResult)(o),source:"override"};if(l!==void 0)return{result:l,arm:(0,_e.armOfResult)(l),source:"preloaded"};if(a!==null){let b=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:(0,_e.armOfResult)(a),source:b?"client":"seeded"}}let c=(0,_e.baselineResultFor)(t);return{result:c,arm:(0,_e.armOfResult)(c),source:"baseline"}})(),v=s.source==="preloaded"||s.source==="override";return(0,se.useEffect)(()=>{var b;if(!n||n.isLocal===!0||v||!n.decideSlots)return;let c=(b=n.onSlotsChanged)==null?void 0:b.call(n,i);return n.decideSlots([t]),()=>{var x;(x=n.cancelSlots)==null||x.call(n,[e]),c==null||c()}},[n,e,v]),s}function wi(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function wr(){let e=j(),t=Mn();(0,se.useSyncExternalStore)(ee,gn,()=>0);let[n,r]=(0,se.useState)(!1);(0,se.useEffect)(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:(0,br.confidenceBand)(a.confidence)});if(!n)return t?i(t):null;let o=wi();if(o)return i(o);if(t)return i(t);let l=e?e.getPersona():null;return l?i(l):null}var xr=new Set;function xi(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Rr(e,t,n){let r=j(),i=ie(),o=JSON.stringify(t),l=(0,ae.useMemo)(()=>({id:e,dims:t}),[e,o]),{result:a,arm:u,source:s}=gt(e,l),v=(0,ae.useMemo)(()=>typeof a=="string"?{}:a,[u]);if(F()&&!xr.has(e)){xr.add(e);let p=(0,kr.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([y,f])=>[y,[...f]]))}),S=Object.values(t).reduce((y,f)=>y*f.length,1);p.ok?S>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${S} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${p.reason}. Serving baseline.`)}let c=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,ae.useEffect)(()=>Ge({id:e,dims:t}),[e]);let b=(0,ae.useRef)(null);(0,ae.useEffect)(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||b.current===u||(b.current=u,ve(r,i,e,u))},[r,i,e,u,s]);let x=n==null?void 0:n.funnel;(0,ae.useEffect)(()=>{var p;!r||s==="override"||fe(r,i,e,x,ne((p=n==null?void 0:n.goal)!=null?p:"click"))},[r,i,e,x,c,s]),(0,ae.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let p=document.querySelector(`[data-sentient-slot="${xi(e)}"]`);if(!p){F()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let S=ye(n.goal),y=ce(n.goal),f=!1;return de(p,ne(n.goal),{fireGoal:()=>{f||(f=!0,y!==void 0?r.componentGoal(e,S,{value:y}):r.componentGoal(e,S),r.goal(S,m({metadata:{componentId:e,arm:u},weight:1,stepIndex:0},y!==void 0?{value:y}:{})))},fireStep:(h,k,O)=>{r.componentGoal(e,h,{reward:k}),r.goal(h,{metadata:{componentId:e,arm:u},weight:k,stepIndex:O})}},S)},[r,e,c,u,s]);let g=(0,ae.useMemo)(()=>{let p={"data-sentient-slot":e};for(let[S,y]of Object.entries(v))p[`data-${S}`]=y;return p},[e,v]);return{tokens:v,props:g}}var Oe=require("react");var Ar=new Set,Cr=new Set;function _r(e,t){var g,p;if(F()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:o,goalLabel:l,ref:a,nodeRef:u}=st(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(g=i!=null?i:r[0])!=null?g:"",v=t.variants[s],c=tt().includes(e)||((p=n==null?void 0:n.isUnified)==null?void 0:p.call(n,e))===!0;(0,Oe.useEffect)(()=>{!c||!F()||Cr.has(e)||(Cr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[c,e]),(0,Oe.useEffect)(()=>{if(!F()||!n)return;let S=setTimeout(()=>{!u.current&&!Ar.has(e)&&(Ar.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(S)},[n,e]);let b=(0,Oe.useCallback)((S,y)=>{var h,k;if(o)return;let f=S!=null?S:l;f&&(n==null||n.componentGoal(e,f,y),n==null||n.goal(f,m(m(m({metadata:(h=y==null?void 0:y.metadata)!=null?h:{},weight:(k=y==null?void 0:y.reward)!=null?k:1,stepIndex:0},(y==null?void 0:y.value)!==void 0?{value:y.value}:{}),(y==null?void 0:y.currency)!==void 0?{currency:y.currency}:{}),(y==null?void 0:y.externalId)!==void 0?{externalId:y.externalId}:{})))},[n,e,l,o]),x=(0,Oe.useMemo)(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":s}),[a,e,s]);return{variant:s,value:v,bind:x,fireGoal:b}}var Q=require("react");var Gr=require("react/jsx-runtime"),mt=new Set;function Or(e){var f;let t=j(),n=ie(),r=(0,Q.useRef)(null),i=Object.keys(e.arrangements).join(" "),o=(0,Q.useMemo)(()=>Object.keys(e.arrangements),[i]),l=(0,Q.useMemo)(()=>m({id:e.id,arms:o},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,o,e.baseline]),{arm:a,source:u}=gt(e.id,l);F()&&e.baseline!==void 0&&e.baseline!==o[0]&&!mt.has(e.id+":baseline")&&(mt.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${o[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=Q.Children.toArray(e.children).filter(Q.isValidElement),v=new Map;for(let h of s)v.set(String((f=h.key)!=null?f:"").replace(/^\.\$/,""),h);let c=e.arrangements[a],b=c!==void 0&&c.length===s.length&&c.every(h=>v.has(h));F()&&c!==void 0&&!b&&!mt.has(e.id+":keys")&&(mt.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${c.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let x=b?c.map(h=>v.get(h)):s;(0,Q.useEffect)(()=>Ge({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let g=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{!t||u==="baseline"||u==="seeded"||u==="override"||g.current===a||(g.current=a,ve(t,n,e.id,a))},[t,n,e.id,a,u]);let p=e.funnel,S=e.goal===void 0||typeof e.goal=="string"?"":JSON.stringify(e.goal);(0,Q.useEffect)(()=>{var h;!t||u==="override"||fe(t,n,e.id,p,ne((h=e.goal)!=null?h:"click"))},[t,n,e.id,p,S,u]);let y=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,Q.useEffect)(()=>{if(!t||e.goal===void 0||u==="override"||u==="baseline"||u==="seeded")return;let h=r.current;if(!h)return;let k=ye(e.goal),O=ce(e.goal),N=!1;return de(h,ne(e.goal),{fireGoal:()=>{N||(N=!0,O!==void 0?t.componentGoal(e.id,k,{value:O}):t.componentGoal(e.id,k),t.goal(k,m({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},O!==void 0?{value:O}:{})))},fireStep:(E,R,C)=>{t.componentGoal(e.id,E,{reward:R}),t.goal(E,{metadata:{componentId:e.id,arm:a},weight:R,stepIndex:C})}},k)},[t,e.id,y,a,u]),(0,Gr.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:x})}var Ut=require("@sentientui/core");var ki=["page","blocks","layoutOrder"],Er=new Map;function Pr(e,t){Er.set(e,t)}function Kt(e){return Er.get(e)}function Nr(e){var i,o;let t=(o=(i=e.content)!=null?i:Kt(e.page))!=null?o:{},n={};for(let[l,a]of Object.entries(t))ki.includes(l)||(n[l]=a);let r=M(m({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function Tr(e){return`<script type="application/ld+json">${Wt(e)}</script>`}function Wt(e){return JSON.stringify(m({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function Ir(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 Dr=require("@sentientui/core"),Lr=require("@sentientui/core/consent");0&&(module.exports={Adaptive,AdaptiveGroup,AdaptiveProvider,AdaptiveSlot,AdaptiveText,SentientPersonaScript,buildAgentFeed,consentWatcher,defineAgentContent,detectSegment,getAgentContent,grantConsent,renderAgentJsonLd,renderAgentJsonLdBody,renderAgentMarkdown,renderBlocks,renderCompose,useAdaptive,useAdaptiveApiBaseUrl,useAdaptiveGoal,useAdaptivePersona,useAdaptiveTokens,useAssignment,useGoal,useInitialAssignments,useLayoutOrder,usePageGoal,useSentient,useSessionSegment});
|
|
5
5
|
//# sourceMappingURL=index.js.map
|