@usereq/widget 0.2.25 → 1.0.0-experimental.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -145
- package/dist/embed.js +38 -0
- package/dist/embed.js.map +1 -0
- package/dist/embed.mjs +3185 -0
- package/dist/embed.mjs.map +1 -0
- package/package.json +35 -81
- package/dist/widget.js +0 -255
- package/src/chat-widget/chat-widget-appearance.ts +0 -134
- package/src/chat-widget/message-reveal.ts +0 -52
- package/src/chat-widget/stop-confirmation.ts +0 -288
- package/src/custom-element/agent-widget-element.tsx +0 -682
- package/src/embed.ts +0 -8
- package/src/index.ts +0 -9
- package/src/register.ts +0 -15
- package/src/renderer/index.ts +0 -6
- package/src/renderer/widget-runtime.tsx +0 -395
- package/src/runtime/api-origin.ts +0 -29
- package/src/runtime/api.ts +0 -123
- package/src/runtime/bootstrap.ts +0 -366
- package/src/runtime/debug.ts +0 -104
- package/src/runtime/messages.ts +0 -12
- package/src/runtime/session-storage.ts +0 -32
- package/src/runtime/trigger-rule.ts +0 -182
- package/src/shared/shadow-css.ts +0 -15
- package/src/shared/shadow-theme.ts +0 -115
- package/src/shared/stop-confirmation.ts +0 -20
- package/src/shared/widget-config.ts +0 -171
- package/src/styles/widget.css.ts +0 -83
- package/src/types.ts +0 -98
- package/src/vite-env.d.ts +0 -4
package/README.md
CHANGED
|
@@ -1,166 +1,56 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@usereq/widget` (the `experimental` line)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The script a customer's page loads. It renders a published surface - a chat (bubble, chatbar, box, stream), a banner, a testimonial card, an exit popup - or a group of them, and talks to the surface's agent through `apps/api`. Published to npm as `@usereq/widget` - the previous platform's package name, reused for its scope and publish lane - under the **`experimental` dist-tag** (`1.0.0-experimental.N`); `latest` (0.2.x) stays the old `<usereq-agent-widget>` script, which the pages pasted before this runtime load unpinned. The dashboard's install snippet points at `https://unpkg.com/@usereq/widget@experimental` (`NEXT_PUBLIC_EMBED_SCRIPT_URL`), pinned to the tag so a publish never requires a merchant to re-paste and never reaches those older pages.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Plan: `docs/embed-ui-runtime-plan.md`. The rule for every pixel: **the surface renders the way the dashboard preview promised it** (`apps/app/feats/widgets/components/widget-preview.tsx`) - the styles are lifted number for number, and a change to one is a change to both.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- Embed browser IIFE bundle generated at root `dist/widget.js`.
|
|
7
|
+
## On a page
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- `src` (core, shared, runtime, custom-element, embed entry)
|
|
15
|
-
- `dist` (built embed artifact; created by `bun run build`)
|
|
16
|
-
- `tsconfig.json` (global TS config)
|
|
17
|
-
- `.env.example` (optional local env template; not loaded automatically—copy to `.env` / `.env.production` as needed)
|
|
18
|
-
|
|
19
|
-
## Prerequisites
|
|
20
|
-
|
|
21
|
-
- [Bun](https://bun.sh/) 1.2+ (matches `packageManager` in `package.json`)
|
|
22
|
-
- npm CLI for publishing (`npm whoami`, `npm publish`)
|
|
23
|
-
- npm account with publish permission to the `@usereq` scope (or change the package `name` before publishing elsewhere)
|
|
24
|
-
|
|
25
|
-
## Environment variables
|
|
26
|
-
|
|
27
|
-
These matter when you run **`bun run build`** (specifically the Vite embed step). Vite reads them from the repo root via `.env`, `.env.local`, `.env.production`, `.env.production.local`, and so on (see [Vite env files](https://vitejs.dev/guide/env-and-mode.html#env-files)). `vite build` uses mode **`production`**, so `.env.production` is the usual place for release API URLs.
|
|
28
|
-
|
|
29
|
-
| Variable | When set | Effect |
|
|
30
|
-
| ---------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
31
|
-
| `USEREQ_WIDGET_DEV_API_BASE` | Embed build | Highest-priority API origin (useful for dev-tag releases). If set, it overrides `USEREQ_WIDGET_API_BASE`. |
|
|
32
|
-
| `USEREQ_WIDGET_API_BASE` | Embed build | Preferred API origin string inlined into `dist/widget.js` (no trailing slash normalization at build time; the runtime trims and strips trailing slashes). |
|
|
33
|
-
| `NEXT_PUBLIC_API_URL` | Embed build | Used only if `USEREQ_WIDGET_API_BASE` is empty—handy if you already define this in a Next.js monorepo. |
|
|
34
|
-
| _(neither set)_ | Embed build | Falls back to `http://localhost:3000` in the Vite config. |
|
|
35
|
-
|
|
36
|
-
**Runtime `globalThis` (advanced):** `getWidgetApiBase()` (see `src/runtime/api-origin.ts`) prefers the compile-time `__USEREQ_WIDGET_API_BASE__` value when it is non-empty after trimming. The Vite embed build always defines that symbol to a non-empty string (see defaults above), so **changing the API URL for the published `dist/widget.js` requires a rebuild with a different `USEREQ_WIDGET_API_BASE`**. The `globalThis.__USEREQ_WIDGET_API_BASE__` path mainly applies when consuming source from this package without inlining a base URL (for example your own bundler without that `define`). If nothing resolves, the function falls back to `http://localhost:4000`.
|
|
37
|
-
|
|
38
|
-
Example for a production embed build:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
USEREQ_WIDGET_API_BASE=https://api.example.com bun run build
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Or create `.env.production` in the repo root (gitignored by default; copy from `.env.example`).
|
|
45
|
-
|
|
46
|
-
## Install
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
bun install
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Development
|
|
53
|
-
|
|
54
|
-
Typecheck:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
bun run typecheck
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Build core + embed:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
bun run build
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Build individual targets:
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
bun run build:core
|
|
70
|
-
bun run build:embed
|
|
9
|
+
```html
|
|
10
|
+
<usereq-widget widget-id="01a0…"></usereq-widget>
|
|
11
|
+
<script src="https://unpkg.com/@usereq/widget@experimental" async></script>
|
|
71
12
|
```
|
|
72
13
|
|
|
73
|
-
|
|
14
|
+
`<usereq-group group-id="…">` for a group. Every surface but one floats over the page, so the tag can go anywhere (the snippet says before `</body>`); a chat **box** renders in the flow at the tag's spot, as wide as whatever holds it - the tag is its placement, there is no selector. Optional attributes: `api-url` (a staging API; the dev host page uses it) and `theme="light|dark"` when sampling the page's background would lie about the ground the surface sits on.
|
|
74
15
|
|
|
75
|
-
|
|
76
|
-
- Embed bundle is emitted at root `dist/widget.js` (plus css artifact if emitted).
|
|
16
|
+
The element fetches `GET /api/embed/{kind}/{id}` on connect, checks the envelope (`guard.ts`, a hand-written shape check - no zod on a merchant page), and mounts into its own open shadow root. Nothing throws onto the page: no live snapshot, a page off the org's verified domains, a network that is down - each is one `console.warn("[usereq] …")` and an empty element.
|
|
77
17
|
|
|
78
|
-
|
|
18
|
+
Importing the module instead gives `render(snapshot, host, { apiUrl?, theme?, silent? })` for a page that has the payload in hand (the dashboard's preview, once it swaps to the runtime - plan E3). `silent` keeps events off the wire.
|
|
79
19
|
|
|
80
|
-
|
|
20
|
+
## What it does with a payload
|
|
81
21
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
For CDN/script usage, use:
|
|
92
|
-
|
|
93
|
-
- unpkg: `https://unpkg.com/@usereq/widget/dist/widget.js`
|
|
94
|
-
- jsDelivr: `https://cdn.jsdelivr.net/npm/@usereq/widget/dist/widget.js`
|
|
95
|
-
|
|
96
|
-
The embed entry automatically registers `<usereq-agent-widget>`.
|
|
97
|
-
|
|
98
|
-
## Publish guide
|
|
99
|
-
|
|
100
|
-
Publish once from this repo root. The package is **scoped** (`@usereq/widget`); `publishConfig.access` is already `public`.
|
|
101
|
-
|
|
102
|
-
### 1) Login and verify permissions
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
npm whoami
|
|
106
|
-
# If needed:
|
|
107
|
-
npm login
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Ensure you are logged in as a user or CI token that is allowed to publish under the `@usereq` scope on npm.
|
|
22
|
+
| Piece | Where | Does |
|
|
23
|
+
| ------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
24
|
+
| Look | `appearance.ts` | accent, alpha → fill, readable text colour, radius, glass skin, position - the preview's arithmetic, pure; `isMessenger` when a bubble carries `preset: "facebook-messenger"`, and `surfaces/chat-messenger.tsx` draws it from `@workspace/contracts/embed/presets` instead (the accent, alpha and radius go unused; placement, the content and the parts still apply) |
|
|
25
|
+
| Rules | `rules.ts`, `surface.tsx` | the payload's ENABLED rules in priority order; the first whose conditions fit the page (path, utm, device, referrer) arms its trigger (`page_load`, `time_on_page`, `scroll_depth`, `element_click`, `element_visible`, `exit_intent`); when it fires the surface **shows** - the dashboard's sentence is "When …, show <surface>", so a firing is the show, `autoStart` puts the visitor in the composer, `pinned` takes the close away. `once` is remembered per visit in `sessionStorage`. No rules: the surface rests - a bubble's launcher alone, a banner or a testimonial straight away, a popup on exit intent |
|
|
26
|
+
| Groups | `group.ts`, `mount.tsx` | the group's rules say when it plays; `split` picks a member by weight and remembers the bucket (`localStorage`), `sequence` walks the lineup on each member's `advanceOn` and remembers the step |
|
|
27
|
+
| Chat | `chat/use-conversation.ts`, `chat/session-store.ts`, `stream.ts`, `api.ts` | `POST /api/embed/sessions` on the first send, then `POST /api/embed/chat` - the AI SDK UI-message stream read by hand (`stream.ts`), one bubble per paragraph on the preview's reveal clock (`@workspace/contracts/embed/reveal`); Stop aborts, Retry regenerates. The session is kept per surface in `localStorage` (the token is bound to the origin that minted it, and `localStorage` is per origin - so a kept token is only ever presented from the site it belongs to) and a surface that mounts with one reads the thread back (`GET /api/embed/sessions/current`), so a reload or the next page of the site carries the conversation on; a refused session (401/409, expired) is forgotten and minted anew on the next send. The visitor ends it with the `MessageCircleX` control (the panel header, or beside the send where there is no header): the agent asks "Stop the conversation?" in the thread, "Stop conversation" ends it on the server (`POST /api/embed/sessions/current/end` - the dashboard shows it ended) and clears the page for a fresh start; "Keep chatting" takes the card away. Chat only - the other surfaces have no agent |
|
|
28
|
+
| Events | `events.ts` | `embed.loaded`, `surface.opened/closed`, `rule.fired`, `cta.clicked`, … batched to `POST /api/embed/events` with client-minted uuidv7 ids (the server's dedupe key) and a per-browser visitor key |
|
|
29
|
+
| Styling hooks | `base.css.ts`, `appearance.ts` | a static base sheet in the shadow root, then the customer's: `appearance.parts` adds their class beside the runtime's `uq-<part>` on each named part, `appearance.customCss` is appended as-is, a block's `css` is scoped to that block's element |
|
|
111
30
|
|
|
112
|
-
|
|
31
|
+
Storage keys, all optional conveniences that degrade to "forgotten" (`storage.ts` never throws): `usereq:visitor` (localStorage), `usereq:session:<widgetId>` (localStorage - the chat session, for the token's 24 h), `usereq:once:<ruleId>` (sessionStorage), `usereq:split:<groupId>`, `usereq:seq:<groupId>`.
|
|
113
32
|
|
|
114
|
-
|
|
33
|
+
On a phone (`max-width: 639px`, live through `matchMedia`, `drawer.tsx`): the bubble's panel is a bottom sheet at half the screen instead of a card beside the launcher. The grab bar drags it to full height or, past the bottom, away; a flick decides on its own; the header gains a close button; the launcher hides while the sheet is up. A pinned surface never closes - the drag down settles at half. Heights are percentages of the viewport as it is (under a collapsing address bar or a keyboard), not `vh`. The chatbar is already a bottom strip and the stream keeps floating; the exit popup's card scrolls inside itself on a short screen.
|
|
115
34
|
|
|
116
|
-
|
|
35
|
+
## Working on it
|
|
117
36
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
bun run typecheck
|
|
126
|
-
bun run build
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
Confirm `dist/widget.js` exists (the `files` field includes `dist` and `src`).
|
|
130
|
-
|
|
131
|
-
### 5) Sanity check contents (optional)
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
npm pack --dry-run
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### 6) Publish
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
npm publish
|
|
37
|
+
```sh
|
|
38
|
+
bun run dev # vite on :5173, opens /dev/ - a host page that mounts a surface by id against a local API
|
|
39
|
+
bun test # rules, the stream reader, the look
|
|
40
|
+
bun run build # dist/embed.js (IIFE, the snippet) + dist/embed.mjs (ESM) + sourcemaps
|
|
41
|
+
bun run size # the gzip gate - fails the build over 25 kB
|
|
141
42
|
```
|
|
142
43
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
### 7) Verify
|
|
44
|
+
The dev host page takes `?id=…&kind=widget|group&bg=light|dark|photo&api=http://localhost:4000`, plus `variant=bubble|chatbar|box|stream` and `preset=default|facebook-messenger` to render a chat surface as another variant or under a preset (the real snapshot with `config.variant` / `config.preset` swapped, through `render`) - every look from one published surface. The origin gate is open for an org with no verified domain; with one, run `apps/api` with `DASHBOARD_ORIGIN=http://localhost:5173` or add `localhost` to the list.
|
|
146
45
|
|
|
147
|
-
|
|
148
|
-
npm view @usereq/widget version
|
|
149
|
-
```
|
|
46
|
+
`USEREQ_EMBED_API_URL` at build time bakes the default API origin (the contracts' `EMBED_API_URL`, `https://api.usereq.com`, otherwise); `api-url` on the element overrides it per mount. The dashboard writes that attribute into the snippet only when its own `NEXT_PUBLIC_API_URL` is not the production API - a dev or staging deployment - so a production snippet stays two lines with nothing to override.
|
|
150
47
|
|
|
151
|
-
|
|
48
|
+
## Publishing
|
|
152
49
|
|
|
153
|
-
-
|
|
154
|
-
- **Publish** (`.github/workflows/publish.yml`): runs when you push tags matching:
|
|
155
|
-
- `v*` (for example `v0.2.0`) → publishes to npm default `latest` tag.
|
|
156
|
-
- `dev-v*` (for example `dev-v0.2.0-dev.1`) → publishes to npm `dev` dist-tag.
|
|
157
|
-
Configure repository secrets:
|
|
158
|
-
- **`NPM_TOKEN`** (required): npm automation token able to publish `@usereq/widget`.
|
|
159
|
-
- **`USEREQ_WIDGET_API_BASE`** (optional): production API base for normal `v*` releases.
|
|
160
|
-
- **`USEREQ_WIDGET_DEV_API_BASE`** (optional): dev API base used by `dev-v*` releases.
|
|
161
|
-
- For `dev-v*` publishes, keep `package.json` `version` unique (for example prerelease versions like `0.2.0-dev.1`), because npm does not allow publishing the same version twice even with different dist-tags.
|
|
50
|
+
Bump `version` in `package.json` (`1.0.0-experimental.N`, the next N), push a tag `embed-v<version>`; `.github/workflows/publish-embed.yml` checks the tag against the version, refuses a version that is not an experimental prerelease, runs the typecheck, the tests, the build and the size gate, then `npm publish --access public --tag experimental` (`files: ["dist"]`; no provenance - npm only attests public source repositories and this one is private). Authentication is npm trusted publishing: `@usereq/widget` on npmjs.com names `UserEQ/usereq-app` and `publish-embed.yml` as a trusted publisher, and the run's OIDC token is exchanged for a publish token, so no secret is stored or expires - the workflow carries no `NPM_TOKEN` at all. Taking `latest` - `1.0.0`, the snippet on `@1` - is the day the old element is retired: a product decision, not a release step. The dashboard's snippet follows `NEXT_PUBLIC_EMBED_SCRIPT_URL`.
|
|
162
51
|
|
|
163
|
-
##
|
|
52
|
+
## Not here yet
|
|
164
53
|
|
|
165
|
-
-
|
|
166
|
-
-
|
|
54
|
+
- The editor's preview still renders the React mock; swapping it for `render()` is plan E3.
|
|
55
|
+
- The escalation exit (`payload.escalation`) is carried, not rendered.
|
|
56
|
+
- A media block's `src` is an upload KEY; the runtime shows it only when it is already an `http(s)` URL. The API has to hand back a URL before uploads appear on a page.
|
package/dist/embed.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var UserEQ=(function(qe){Object.defineProperty(qe,Symbol.toStringTag,{value:"Module"});async function nn(e){const t=e.getReader(),n=new TextDecoder;let r="",o="";const i=[],a=new Map,u=d=>{if(!d.startsWith("data:"))return;const c=d.slice(5).trim();if(!c||c==="[DONE]")return;let f;try{f=JSON.parse(c)}catch{return}switch(f.type){case"start":"messageId"in f&&f.messageId&&(o=f.messageId);break;case"text-start":"id"in f&&(i.push(f.id),a.set(f.id,""));break;case"text-delta":if("id"in f&&"delta"in f){var h;a.set(f.id,((h=a.get(f.id))!==null&&h!==void 0?h:"")+f.delta)}break;case"error":throw new Error("errorText"in f?f.errorText:"The reply failed.");case"abort":throw new Error("The reply was cut short.")}};for(;;){const{done:d,value:c}=await t.read();if(d)break;r+=n.decode(c,{stream:!0});let f;for(;(f=r.indexOf(`
|
|
2
|
+
`))!==-1;)u(r.slice(0,f).replace(/\r$/,"")),r=r.slice(f+1)}return r&&u(r),{id:o||`reply-${Date.now()}`,parts:i.map(d=>{var c;return(c=a.get(d))!==null&&c!==void 0?c:""})}}function Z(e){"@babel/helpers - typeof";return Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(e)}function rn(e,t){if(Z(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Z(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function on(e){var t=rn(e,"string");return Z(t)=="symbol"?t:t+""}function Ie(e,t,n){return(t=on(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var G=class extends Error{constructor(e,t,n){super(n),Ie(this,"status",void 0),Ie(this,"code",void 0),this.status=e,this.code=t}};async function ee(e){let t="request_failed",n=`The request failed (${e.status}).`;try{var r,o;const i=await e.json();!((r=i.error)===null||r===void 0)&&r.code&&(t=i.error.code),!((o=i.error)===null||o===void 0)&&o.message&&(n=i.error.message)}catch{}throw new G(e.status,t,n)}var Te=(e,t={})=>({method:"POST",headers:{"Content-Type":"application/json",...t},body:JSON.stringify(e)});async function sn(e,t,n){const r=await fetch(`${e.base}/api/embed/${t}/${n}`);return r.ok?r.json():ee(r)}async function an(e,t){const n=await fetch(`${e.base}/api/embed/sessions`,Te(t));return n.ok?n.json():ee(n)}var Me=e=>({Authorization:`Bearer ${e}`});async function ln(e,t){const n=await fetch(`${e.base}/api/embed/sessions/current`,{headers:Me(t)});return n.ok?n.json():ee(n)}async function cn(e,t){const n=await fetch(`${e.base}/api/embed/sessions/current/end`,{method:"POST",headers:Me(t)});return n.ok?n.json():ee(n)}async function un(e,t,n,r,o){const i=await fetch(`${e.base}/api/embed/chat`,{...Te({message:{id:n.id,role:"user",parts:[{type:"text",text:n.text}]},trigger:r},Me(t)),signal:o});return!i.ok||!i.body?ee(i):nn(i.body)}async function dn(e,t){try{const n=await fetch(`${e.base}/api/embed/events`,{...Te(t),keepalive:!0});return n.ok?await n.json():null}catch{return null}}var K=e=>typeof e=="object"&&e!==null;function et(e){return K(e)&&typeof e.id=="string"&&K(e.config)&&typeof e.config.type=="string"&&K(e.config.appearance)&&Array.isArray(e.rules)}function fn(e){return K(e)&&typeof e.id=="string"&&typeof e.mode=="string"&&K(e.config)&&Array.isArray(e.members)&&e.members.every(t=>K(t)&&et(t.widget))&&Array.isArray(e.rules)}function pn(e,t){return!K(e)||e.kind!==t?null:t==="widget"&&et(e.payload)||t==="group"&&fn(e.payload)?e:null}var ce,C,tt,hn,O,nt,rt,it,Ae,ue,te,ot,ze,Re,Ee,_n,de={},fe=[],gn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,pe=Array.isArray;function W(e,t){for(var n in t)e[n]=t[n];return e}function He(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function mn(e,t,n){var r,o,i,a={};for(i in t)i=="key"?r=t[i]:i=="ref"?o=t[i]:a[i]=t[i];if(arguments.length>2&&(a.children=arguments.length>3?ce.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(i in e.defaultProps)a[i]===void 0&&(a[i]=e.defaultProps[i]);return he(e,a,r,o,null)}function he(e,t,n,r,o){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o==null?++tt:o,__i:-1,__u:0};return o==null&&C.vnode!=null&&C.vnode(i),i}function N(e){return e.children}function _e(e,t){this.props=e,this.context=t}function V(e,t){if(t==null)return e.__?V(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?V(e):null}function bn(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],o=[],i=W({},t);i.__v=t.__v+1,C.vnode&&C.vnode(i),Pe(e.__P,i,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n==null?V(t):n,!!(32&t.__u),o),i.__v=t.__v,i.__.__k[i.__i]=i,pt(r,i,o),t.__e=t.__=null,i.__e!=n&&st(i)}}function st(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),st(e)}function at(e){(!e.__d&&(e.__d=!0)&&O.push(e)&&!ge.__r++||nt!=C.debounceRendering)&&((nt=C.debounceRendering)||rt)(ge)}function ge(){try{for(var e,t=1;O.length;)O.length>t&&O.sort(it),e=O.shift(),t=O.length,bn(e)}finally{O.length=ge.__r=0}}function lt(e,t,n,r,o,i,a,u,d,c,f){var h,l,p,m,x,v,_=r&&r.__k||fe,g=t.length;for(d=vn(n,t,_,d,g),h=0;h<g;h++)(p=n.__k[h])!=null&&(l=p.__i!=-1&&_[p.__i]||de,p.__i=h,v=Pe(e,p,l,o,i,a,u,d,c,f),m=p.__e,p.ref&&l.ref!=p.ref&&(l.ref&&je(l.ref,null,p),f.push(p.ref,p.__c||m,p)),x==null&&m!=null&&(x=m),4&p.__u?(d=ct(p,d,e),l.__e&&(l.__e=null)):typeof p.type=="function"&&v!==void 0?d=v:m&&(d=m.nextSibling),p.__u&=-7);return n.__e=x,d}function vn(e,t,n,r,o){var i,a,u,d,c,f=n.length,h=f,l=0;for(e.__k=new Array(o),i=0;i<o;i++)(a=t[i])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=e.__k[i]=he(null,a,null,null,null):pe(a)?a=e.__k[i]=he(N,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[i]=he(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[i]=a,d=i+l,a.__=e,a.__b=e.__b+1,u=null,(c=a.__i=yn(a,n,d,h))!=-1&&(h--,(u=n[c])&&(u.__u|=2)),u==null||u.__v==null?(c==-1&&(o>f?l--:o<f&&l++),typeof a.type!="function"&&(a.__u|=4)):c!=d&&(c==d-1?l--:c==d+1?l++:(c>d?l--:l++,a.__u|=4))):e.__k[i]=null;if(h)for(i=0;i<f;i++)(u=n[i])!=null&&(2&u.__u)==0&&(u.__e==r&&(r=V(u)),_t(u,u));return r}function ct(e,t,n){var r,o;if(typeof e.type=="function"){for(r=e.__k,o=0;r&&o<r.length;o++)r[o]&&(r[o].__=e,t=ct(r[o],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=V(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function yn(e,t,n,r){var o,i,a,u=e.key,d=e.type,c=t[n],f=c!=null&&(2&c.__u)==0;if(c===null&&u==null||f&&u==c.key&&d==c.type)return n;if(r>(f?1:0)){for(o=n-1,i=n+1;o>=0||i<t.length;)if((c=t[a=o>=0?o--:i++])!=null&&(2&c.__u)==0&&u==c.key&&d==c.type)return a}return-1}function ut(e,t,n){t[0]=="-"?e.setProperty(t,n==null?"":n):e[t]=n==null?"":typeof n!="number"||gn.test(t)?n:n+"px"}function me(e,t,n,r,o){var i,a;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||ut(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||ut(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")i=t!=(t=t.replace(ot,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=n,n?r?n[te]=r[te]:(n[te]=ze,e.addEventListener(t,i?Ee:Re,i)):e.removeEventListener(t,i?Ee:Re,i);else{if(o=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n==null?"":n;break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function dt(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[ue]==null)t[ue]=ze++;else if(t[ue]<n[te])return;return n(C.event?C.event(t):t)}}}function Pe(e,t,n,r,o,i,a,u,d,c){var f,h,l,p,m,x,v,_,g,y,$,q,A,w,I,S,T=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(d=!!(32&n.__u),i=[u=t.__e=n.__e]),(f=C.__b)&&f(t);e:if(typeof T=="function"){h=a.length;try{if(g=t.props,y=T.prototype&&T.prototype.render,$=(f=T.contextType)&&r[f.__c],q=f?$?$.props.value:f.__:r,n.__c?_=(l=t.__c=n.__c).__=l.__E:(y?t.__c=l=new T(g,q):(t.__c=l=new _e(g,q),l.constructor=T,l.render=wn),$&&$.sub(l),l.state||(l.state={}),l.__n=r,p=l.__d=!0,l.__h=[],l._sb=[]),y&&l.__s==null&&(l.__s=l.state),y&&T.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=W({},l.__s)),W(l.__s,T.getDerivedStateFromProps(g,l.__s))),m=l.props,x=l.state,l.__v=t,p)y&&T.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),y&&l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(y&&T.getDerivedStateFromProps==null&&g!==m&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(g,q),t.__v==n.__v||!l.__e&&l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(g,l.__s,q)===!1){t.__v!=n.__v&&(l.props=g,l.state=l.__s,l.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(M){M&&(M.__=t)}),fe.push.apply(l.__h,l._sb),l._sb=[],l.__h.length&&a.push(l),u=V(n);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(g,l.__s,q),y&&l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(m,x,v)})}if(l.context=q,l.props=g,l.__P=e,l.__e=!1,A=C.__r,w=0,y)l.state=l.__s,l.__d=!1,A&&A(t),f=l.render(l.props,l.state,l.context),fe.push.apply(l.__h,l._sb),l._sb=[];else do l.__d=!1,A&&A(t),f=l.render(l.props,l.state,l.context),l.state=l.__s;while(l.__d&&++w<25);l.state=l.__s,l.getChildContext!=null&&(r=W(W({},r),l.getChildContext())),y&&!p&&l.getSnapshotBeforeUpdate!=null&&(v=l.getSnapshotBeforeUpdate(m,x)),I=f!=null&&f.type===N&&f.key==null?ht(f.props.children):f,u=lt(e,pe(I)?I:[I],t,n,r,o,i,a,u,d,c),l.base=t.__e,t.__u&=-161,l.__h.length&&a.push(l),_&&(l.__E=l.__=null)}catch(M){if(a.length=h,t.__v=null,d||i!=null){if(M.then){for(t.__u|=d?160:128;u&&u.nodeType==8&&u.nextSibling;)u=u.nextSibling;i!=null&&(i[i.indexOf(u)]=null),t.__e=u}else if(i!=null)for(S=i.length;S--;)He(i[S])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),M.then||ft(t),C.__e(M,t,n)}}else i==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):u=t.__e=xn(n.__e,t,n,r,o,i,a,d,c);return(f=C.diffed)&&f(t),128&t.__u?void 0:u}function ft(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ft))}function pt(e,t,n){for(var r=0;r<n.length;r++)je(n[r],n[++r],n[++r]);C.__c&&C.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(i){i.call(o)})}catch(i){C.__e(i,o.__v)}})}function ht(e){return typeof e!="object"||e==null||e.__b>0?e:pe(e)?e.map(ht):e.constructor!==void 0?null:W({},e)}function xn(e,t,n,r,o,i,a,u,d){var c,f,h,l,p,m,x,v=n.props||de,_=t.props,g=t.type;if(g=="svg"?o="http://www.w3.org/2000/svg":g=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),i!=null){for(c=0;c<i.length;c++)if((p=i[c])&&"setAttribute"in p==!!g&&(g?p.localName==g:p.nodeType==3)){e=p,i[c]=null;break}}if(e==null){if(g==null)return document.createTextNode(_);e=document.createElementNS(o,g,_.is&&_),u&&(C.__m&&C.__m(t,i),u=!1),i=null}if(g==null)v===_||u&&e.data==_||(e.data=_);else{if(i=g=="textarea"&&_.defaultValue!=null?null:i&&ce.call(e.childNodes),!u&&i!=null)for(v={},c=0;c<e.attributes.length;c++)v[(p=e.attributes[c]).name]=p.value;for(c in v)p=v[c],c=="dangerouslySetInnerHTML"?h=p:c=="children"||c in _||c=="value"&&"defaultValue"in _||c=="checked"&&"defaultChecked"in _||me(e,c,null,p,o);for(c in _)p=_[c],c=="children"?l=p:c=="dangerouslySetInnerHTML"?f=p:c=="value"?m=p:c=="checked"?x=p:u&&typeof p!="function"||v[c]===p||me(e,c,p,v[c],o);if(f)u||h&&(f.__html==h.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(h&&(e.innerHTML=""),lt(t.type=="template"?e.content:e,pe(l)?l:[l],t,n,r,g=="foreignObject"?"http://www.w3.org/1999/xhtml":o,i,a,i?i[0]:n.__k&&V(n,0),u,d),i!=null)for(c=i.length;c--;)He(i[c]);u&&g!="textarea"||(c="value",g=="progress"&&m==null?e.removeAttribute("value"):m!=null&&(m!==e[c]||g=="progress"&&!m||g=="option"&&m!=v[c])&&me(e,c,m,v[c],o),c="checked",x!=null&&x!=e[c]&&me(e,c,x,v[c],o))}return e}function je(e,t,n){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(o){C.__e(o,n)}}function _t(e,t,n){var r,o;if(C.unmount&&C.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||je(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(i){C.__e(i,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&_t(r[o],t,n||typeof e.type!="function");n||He(e.__e),e.__c=e.__=e.__e=void 0}function wn(e,t,n){return this.constructor(e,n)}function gt(e,t,n){var r,o,i,a;t==document&&(t=document.documentElement),C.__&&C.__(e,t),o=(r=typeof n=="function")?null:n&&n.__k||t.__k,i=[],a=[],Pe(t,e=(!r&&n||t).__k=mn(N,null,[e]),o||de,de,t.namespaceURI,!r&&n?[n]:o?null:t.firstChild?ce.call(t.childNodes):null,i,!r&&n?n:o?o.__e:t.firstChild,r,a),pt(i,e,a),e.props.children=null}ce=fe.slice,C={__e:function(e,t,n,r){for(var o,i,a;t=t.__;)if((o=t.__c)&&!o.__)try{if((i=o.constructor)&&i.getDerivedStateFromError!=null&&(o.setState(i.getDerivedStateFromError(e)),a=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(e,r||{}),a=o.__d),a)return o.__E=o}catch(u){e=u}throw e}},tt=0,hn=function(e){return e!=null&&e.constructor===void 0},_e.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=W({},this.state);typeof e=="function"&&(e=e(W({},n),this.props)),e&&W(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),at(this))},_e.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),at(this))},_e.prototype.render=N,O=[],rt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,it=function(e,t){return e.__v.__b-t.__v.__b},ge.__r=0,Ae=Math.random().toString(8),ue="__d"+Ae,te="__a"+Ae,ot=/(PointerCapture)$|Capture$/i,ze=0,Re=dt(!1),Ee=dt(!0),_n=0;var ne,z,Fe,mt,re=0,bt=[],E=C,vt=E.__b,yt=E.__r,xt=E.diffed,wt=E.__c,St=E.unmount,kt=E.__;function Be(e,t){E.__h&&E.__h(z,e,re||t),re=0;var n=z.__H||(z.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function H(e){return re=1,Sn(qt,e)}function Sn(e,t,n){var r=Be(ne++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):qt(void 0,t),function(u){var d=r.__N?r.__N[0]:r.__[0],c=r.t(d,u);d!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=z,!z.__f)){var o=function(u,d,c){if(!r.__c.__H)return!0;var f=!1,h=r.__c.props!==u;if(r.__c.__H.__.some(function(p){if(p.__N){f=!0;var m=p.__[0];p.__=p.__N,p.__N=void 0,m!==p.__[0]&&(h=!0)}}),i){var l=i.call(this,u,d,c);return f?l||h:l}return!f||h};z.__f=!0;var i=z.shouldComponentUpdate,a=z.componentWillUpdate;z.componentWillUpdate=function(u,d,c){if(this.__e){var f=i;i=void 0,o(u,d,c),i=f}a&&a.call(this,u,d,c)},z.shouldComponentUpdate=o}return r.__N||r.__}function P(e,t){var n=Be(ne++,3);!E.__s&&Ct(n.__H,t)&&(n.__=e,n.u=t,z.__H.__h.push(n))}function B(e){return re=5,be(function(){return{current:e}},[])}function be(e,t){var n=Be(ne++,7);return Ct(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function U(e,t){return re=8,be(function(){return e},t)}function kn(){for(var e;e=bt.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ve),t.__h.some(De),t.__h=[]}catch(n){t.__h=[],E.__e(n,e.__v)}}}E.__b=function(e){z=null,vt&&vt(e)},E.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),kt&&kt(e,t)},E.__r=function(e){yt&&yt(e),ne=0;var t=(z=e.__c).__H;t&&(Fe===z?(t.__h=[],z.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(ve),t.__h.some(De),t.__h=[],ne=0)),Fe=z},E.diffed=function(e){xt&&xt(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(bt.push(t)!==1&&mt===E.requestAnimationFrame||((mt=E.requestAnimationFrame)||$n)(kn)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Fe=z=null},E.__c=function(e,t){t.some(function(n){try{n.__h.some(ve),n.__h=n.__h.filter(function(r){return!r.__||De(r)})}catch(r){t.some(function(o){o.__h&&(o.__h=[])}),t=[],E.__e(r,n.__v)}}),wt&&wt(e,t)},E.unmount=function(e){St&&St(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{ve(r)}catch(o){t=o}}),n.__H=void 0,t&&E.__e(t,n.__v))};var $t=typeof requestAnimationFrame=="function";function $n(e){var t,n=function(){clearTimeout(r),$t&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);$t&&(t=requestAnimationFrame(n))}function ve(e){var t=z,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),z=t}function De(e){var t=z;e.__c=e.__(),z=t}function Ct(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function qt(e,t){return typeof t=="function"?t(e):t}var Cn=`
|
|
3
|
+
:host{all:initial;display:contents;font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:14px;line-height:1.4;-webkit-font-smoothing:antialiased;color:#15171e}
|
|
4
|
+
:host([hidden]){display:none}
|
|
5
|
+
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
|
|
6
|
+
button{font:inherit;color:inherit;background:none;border:0;cursor:pointer;-webkit-tap-highlight-color:transparent}
|
|
7
|
+
input{font:inherit;color:inherit;background:none;border:0;outline:0;min-width:0}
|
|
8
|
+
input::placeholder{color:var(--uq-placeholder,inherit);opacity:1}
|
|
9
|
+
input:disabled{cursor:not-allowed}
|
|
10
|
+
button:disabled{cursor:default}
|
|
11
|
+
a{color:inherit;text-decoration:none}
|
|
12
|
+
img,video{display:block;max-width:100%}
|
|
13
|
+
.uq-fixed{position:fixed;z-index:2147483000}
|
|
14
|
+
.uq-inline{display:block}
|
|
15
|
+
.uq-dots{display:inline-flex;gap:3px;align-items:center;height:10px}
|
|
16
|
+
.uq-dots span{width:5px;height:5px;border-radius:50%;background:currentColor;opacity:.35;animation:uq-dot 1.2s infinite ease-in-out}
|
|
17
|
+
.uq-dots span:nth-child(2){animation-delay:.15s}
|
|
18
|
+
.uq-dots span:nth-child(3){animation-delay:.3s}
|
|
19
|
+
@keyframes uq-dot{0%,80%,100%{opacity:.25;transform:translateY(0)}40%{opacity:.9;transform:translateY(-2px)}}
|
|
20
|
+
.uq-rise{animation:uq-rise .22s ease-out both}
|
|
21
|
+
@keyframes uq-rise{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
|
|
22
|
+
.uq-fade{animation:uq-fade .18s ease-out both}
|
|
23
|
+
@keyframes uq-fade{from{opacity:0}to{opacity:1}}
|
|
24
|
+
.uq-drawer{left:0;right:0;bottom:0;display:flex;flex-direction:column;overflow:hidden;padding-bottom:env(safe-area-inset-bottom);transition:height .28s cubic-bezier(.32,.72,0,1),border-radius .28s ease}
|
|
25
|
+
.uq-drawer-half{height:50%}
|
|
26
|
+
.uq-drawer-full{height:100%}
|
|
27
|
+
.uq-drawer-held{transition:none}
|
|
28
|
+
.uq-grab{flex-shrink:0;height:22px;display:flex;align-items:center;justify-content:center;cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none}
|
|
29
|
+
.uq-grab:active{cursor:grabbing}
|
|
30
|
+
.uq-grab span{width:36px;height:4px;border-radius:2px}
|
|
31
|
+
.uq-slide{animation:uq-slide .3s cubic-bezier(.32,.72,0,1) both}
|
|
32
|
+
@keyframes uq-slide{from{transform:translateY(100%)}to{transform:none}}
|
|
33
|
+
@media (prefers-reduced-motion:reduce){.uq-rise,.uq-fade,.uq-slide,.uq-dots span{animation:none}.uq-drawer{transition:none}}
|
|
34
|
+
`;function ie(e,t){try{return window[e].getItem(t)}catch{return null}}function oe(e,t,n){try{window[e].setItem(t,n)}catch{}}function It(e,t){try{window[e].removeItem(t)}catch{}}var qn=2e3,In=20,Tn=100;function We(e=Date.now()){const t=new Uint8Array(16);crypto.getRandomValues(t),t[0]=e/1099511627776&255,t[1]=e/4294967296&255,t[2]=e/16777216&255,t[3]=e/65536&255,t[4]=e/256&255,t[5]=e&255,t[6]=t[6]&15|112,t[8]=t[8]&63|128;const n=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}var Tt="usereq:visitor";function Mt(){const e=ie("localStorage",Tt);if(e)return e;const t=We();return oe("localStorage",Tt,t),t}function Mn(e,t){const n=[];let r=null;const o=Mt(),i=()=>{for(r!==null&&(window.clearTimeout(r),r=null);n.length>0;){const u=n.splice(0,Tn);dn(e,{events:u})}},a=(u,d={})=>{n.push({id:We(),type:u,embedKind:t.kind,embedId:t.id,widgetId:d.widgetId,sessionId:d.sessionId,clientKey:o,url:window.location.href.slice(0,2e3),occurredAt:new Date().toISOString(),payload:d.payload}),n.length>=In?i():r===null&&(r=window.setTimeout(i,qn))};return window.addEventListener("pagehide",i),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&i()}),{report:a,flush:i}}var At=e=>`usereq:once:${e}`;function Le(e,t,n){switch(e){case"is":return t===n;case"starts_with":return t.startsWith(n);case"contains":return t.includes(n);case"matches":try{return new RegExp(n).test(t)}catch{return!1}}}function An(e,t){switch(e.kind){case"path":return e.value==="*"||Le(e.op,t.path,e.value);case"utm":var n;return Le(e.op,(n=t.utm[e.param])!==null&&n!==void 0?n:"",e.value);case"device":return t.device===e.value;case"referrer":return Le(e.op,t.referrer,e.value)}}function zn(e,t){for(const n of e)if(!(n.once&&ie("sessionStorage",At(n.id)))&&n.conditions.every(r=>An(r,t)))return n;return null}function zt(e,t,n){let r=!1,o=()=>{};const i=()=>{r||(r=!0,o(),n())};switch(e){case"page_load":{const d=window.setTimeout(i,0);o=()=>window.clearTimeout(d);break}case"time_on_page":{const d=Number(t.seconds)||0,c=window.setTimeout(i,d*1e3);o=()=>window.clearTimeout(c);break}case"scroll_depth":{const d=Number(t.percent)||0,c=()=>{const f=document.documentElement.scrollHeight-window.innerHeight;(f<=0?100:window.scrollY/f*100)>=d&&i()};window.addEventListener("scroll",c,{passive:!0}),o=()=>window.removeEventListener("scroll",c),c();break}case"element_click":{var a;const d=String((a=t.selector)!==null&&a!==void 0?a:""),c=f=>{const h=f.target;if(!(!(h instanceof Element)||!d))try{h.closest(d)&&i()}catch{}};document.addEventListener("click",c,!0),o=()=>document.removeEventListener("click",c,!0);break}case"element_visible":{var u;const d=String((u=t.selector)!==null&&u!==void 0?u:"");let c=null;const f=()=>{let h=null;try{h=d?document.querySelector(d):null}catch{h=null}return h?(c=new IntersectionObserver(l=>{l.some(p=>p.isIntersecting)&&i()}),c.observe(h),!0):!1};!f()&&document.readyState==="loading"&&document.addEventListener("DOMContentLoaded",()=>void f(),{once:!0}),o=()=>c==null?void 0:c.disconnect();break}case"exit_intent":{const d=c=>{c.relatedTarget===null&&c.clientY<=0&&i()};document.addEventListener("mouseout",d),o=()=>document.removeEventListener("mouseout",d);break}}return()=>{r=!0,o()}}function Rt(e,t,n){const r=zn(e,t);return r?zt(r.trigger,r.triggerParams,()=>{r.once&&oe("sessionStorage",At(r.id),"1"),n(r)}):()=>{}}var Et=e=>`usereq:split:${e}`,Ht=e=>`usereq:seq:${e}`;function Rn(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function ye(e){return[...e].sort((t,n)=>t.position-n.position)}function En(e){const t=ye(e.members);if(t.length===0)return null;const n=ie("localStorage",Et(e.id)),r=n?t.find(u=>u.widget.id===n):void 0;if(r)return r;const o=t.reduce((u,d)=>u+d.weight,0);let i=Rn(`${Mt()}:${e.config.salt}`)%o,a=t[t.length-1];for(const u of t){if(i<u.weight){a=u;break}i-=u.weight}return oe("localStorage",Et(e.id),a.widget.id),a}function Pt(e){var t,n;const r=ye(e.members);if(r.length===0)return null;const o=Number((t=ie("sessionStorage",Ht(e.id)))!==null&&t!==void 0?t:0);return(n=r[Number.isFinite(o)?Math.min(o,r.length-1):0])!==null&&n!==void 0?n:null}function Hn(e,t,n){if(!t.advanceOn)return()=>{};const r=ye(e.members),o=r.findIndex(i=>i.widget.id===t.widget.id);return zt(t.advanceOn.kind,t.advanceOn.params,()=>{var i;const a=o+1<r.length?o+1:null;if(a===null){n(null);return}oe("sessionStorage",Ht(e.id),String(a)),n((i=r[a])!==null&&i!==void 0?i:null)})}function Pn(e){switch(e.mode){case"split":{const t=En(e);return t?[t.widget]:[]}case"sequence":{const t=Pt(e);return t?[t.widget]:[]}case"parallel":return ye(e.members).map(t=>t.widget)}}function jn(e){var t,n,r,o;if(e)return e==="dark";const i=(t=jt(getComputedStyle(document.body).backgroundColor))!==null&&t!==void 0?t:jt(getComputedStyle(document.documentElement).backgroundColor);return i!==null?i<.5:(n=(r=(o=window).matchMedia)===null||r===void 0?void 0:r.call(o,"(prefers-color-scheme: dark)").matches)!==null&&n!==void 0?n:!1}function jt(e){const t=/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)(?:[,\s/]+([\d.]+))?/.exec(e);if(!t||(t[4]===void 0?1:Number(t[4]))<.5)return null;const[n,r,o]=[Number(t[1]),Number(t[2]),Number(t[3])];return(.299*n+.587*r+.114*o)/255}function Fn(e=window.innerWidth){return e<640?"mobile":e<1024?"tablet":"desktop"}function Bn(){const e=new URL(window.location.href),t={};for(const n of["source","medium","campaign","term","content"]){const r=e.searchParams.get(`utm_${n}`);r&&(t[n]=r)}return{href:e.href.slice(0,2e3),path:e.pathname,referrer:document.referrer.slice(0,2e3),utm:t,device:Fn()}}function Ft(e){const t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function Dn(e){const{r:t,g:n,b:r}=Ft(e);return(.299*t+.587*n+.114*r)/255>.62?"#15171e":"#ffffff"}var se=e=>e?"245,245,241":"21,23,30";function Wn(e,t){const n=e.appearance,r=n.accent;return{accent:r,accentFill:(()=>{if(n.alpha>=100)return r;const{r:o,g:i,b:a}=Ft(r);return`rgba(${o},${i},${a},${n.alpha/100})`})(),accentText:Dn(r),rad:n.radius,isGlass:e.type==="chat"&&e.variant==="stream"&&n.skin==="glass",isMessenger:e.type==="chat"&&e.variant==="bubble"&&e.preset==="facebook-messenger",hostDark:t,ink:se(t),surfaceBg:t?"#181b22":"#ffffff",side:n.position==="bottom-right"?{right:n.offsetX}:{left:n.offsetX},offsetY:n.offsetY}}function k(e,t,n){const r=e.appearance.parts[t],o=[`uq-${t}`];return n&&o.push(n),r&&o.push(r.trim()),o.join(" ")}var Ln=0,Ir=Array.isArray;function s(e,t,n,r,o,i){t||(t={});var a,u,d=t;if("ref"in d)for(u in d={},t)u=="ref"?a=t[u]:d[u]=t[u];var c={type:e,props:d,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ln,__i:-1,__u:0,__source:o,__self:i};if(typeof e=="function"&&(a=e.defaultProps))for(u in a)d[u]===void 0&&(d[u]=a[u]);return C.vnode&&C.vnode(c),c}function j({size:e,children:t}){return s("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:t})}var Bt=({size:e})=>s(j,{size:e,children:[s("path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"}),s("path",{d:"M20 2v4"}),s("path",{d:"M22 4h-4"}),s("circle",{cx:"4",cy:"20",r:"2"})]}),Dt=({size:e})=>s(j,{size:e,children:[s("path",{d:"M5 12h14"}),s("path",{d:"m12 5 7 7-7 7"})]}),xe=({size:e})=>s(j,{size:e,children:[s("path",{d:"M18 6 6 18"}),s("path",{d:"m6 6 12 12"})]}),Oe=({size:e})=>s(j,{size:e,children:[s("path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"}),s("path",{d:"m15 9-6 6"}),s("path",{d:"m9 9 6 6"})]}),On=({size:e})=>s(j,{size:e,children:s("path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384"})}),Nn=({size:e})=>s(j,{size:e,children:[s("path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}),s("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"})]}),Un=({size:e})=>s(j,{size:e,children:[s("circle",{cx:"12",cy:"12",r:"10"}),s("path",{d:"M12 16v-4"}),s("path",{d:"M12 8h.01"})]}),Wt=({size:e})=>s(j,{size:e,children:s("path",{d:"m6 9 6 6 6-6"})}),Yn=({size:e})=>s(j,{size:e,children:s("path",{d:"M5 12h14"})}),Gn=({size:e})=>s(j,{size:e,children:[s("path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"}),s("path",{d:"m21.854 2.147-10.94 10.939"})]}),Kn=({size:e})=>s(j,{size:e,children:[s("path",{d:"M15 3h6v6"}),s("path",{d:"M10 14 21 3"}),s("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]}),Vn=({size:e,d:t})=>s("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s("path",{d:t})});function Xn({payload:e,look:t,reporter:n,open:r,setOpen:o,pinned:i}){var a;const u=e.config,{accentFill:d,accentText:c,rad:f}=t;if(!r)return null;const h=!((a=u.cta)===null||a===void 0)&&a.label.trim()?u.cta:null,l=(h==null?void 0:h.href.trim())||"",p=u.position==="bottom"?{bottom:0}:{top:0};return s("div",{class:k(u,"strip","uq-fixed uq-fade"),role:"region","aria-label":"Announcement",style:{left:0,right:0,...p,display:"flex",alignItems:"center",justifyContent:"center",gap:14,padding:"11px 14px",background:d,color:c},children:[s("span",{class:k(u,"text"),style:{fontSize:12.5,fontWeight:500},children:u.text}),h&&s("a",{class:k(u,"cta"),href:l||"#",target:l?"_blank":void 0,rel:l?"noopener noreferrer":void 0,onClick:()=>n.report("cta.clicked",{widgetId:e.id,payload:{href:l}}),style:{fontSize:11.5,padding:"5px 10px",borderRadius:f,border:`1px solid ${c}`,whiteSpace:"nowrap"},children:h.label}),!i&&s("button",{type:"button",class:k(u,"close"),onClick:()=>o(!1),"aria-label":"Close",style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",opacity:.7},children:s(xe,{size:14})})]})}var Ne={holdMs:1260,gapMs:1520,jitterMs:100};function Jn(e,t=Math.random){const n=[];let r=0;for(let o=0;o<e;o++){if(o===0)r+=Ne.holdMs;else{const i=Math.round((t()*2-1)*Ne.jitterMs);r+=Math.max(0,Ne.gapMs+i)}n.push(r)}return n}var we=e=>`usereq:session:${e}`;function Qn(e,t=Date.now()){const n=ie("localStorage",we(e));if(!n)return null;try{const r=JSON.parse(n);if(typeof r!="object"||r===null||!("token"in r)||typeof r.token!="string"||!("conversationId"in r)||typeof r.conversationId!="string"||!("expiresAt"in r)||typeof r.expiresAt!="string")return null;const o=Date.parse(r.expiresAt);return!Number.isFinite(o)||o<=t?(It("localStorage",we(e)),null):{token:r.token,conversationId:r.conversationId,expiresAt:r.expiresAt}}catch{return null}}function Zn(e,t){oe("localStorage",we(e),JSON.stringify(t))}function er(e){It("localStorage",we(e))}function tr(e){const t=e.parts.map(n=>n.text).filter(n=>n.trim());return t.length===0?null:{id:e.id,role:e.role,parts:t,shown:t.length}}function nr(e,t,n,r){const[o,i]=H([]),[a,u]=H(!1),[d,c]=H(null),[f,h]=H(null),[l,p]=H(null),m=B(null),x=B(null),v=B([]),_=B(null),g=()=>{for(const w of v.current)window.clearTimeout(w);v.current=[]};P(()=>()=>g(),[]);const y=t.id,$=U(()=>{m.current=null,h(null),er(y)},[y]);P(()=>{const w=Qn(y);if(!w)return;let I=!1;return m.current={token:w.token,conversationId:w.conversationId},h(w.conversationId),ln(e,w.token).then(S=>{if(!I){if(S.ended){$();return}i(S.messages.flatMap(T=>{const M=tr(T);return M?[M]:[]}))}}).catch(S=>{I||S instanceof G&&S.status<500&&$()}),()=>{I=!0}},[e,y,$]);const q=U(async()=>{if(m.current)return m.current;const w=await an(e,{kind:n.kind,id:n.id,widgetId:n.kind==="group"?t.id:void 0,landingUrl:r.href,referrer:r.referrer||void 0,utm:Object.keys(r.utm).length?r.utm:void 0});return m.current={token:w.token,conversationId:w.conversationId},Zn(y,{token:w.token,conversationId:w.conversationId,expiresAt:w.expiresAt}),h(w.conversationId),m.current},[e,n.kind,n.id,t.id,r,y]),A=U(async(w,I)=>{var S;(S=x.current)===null||S===void 0||S.abort();const T=new AbortController;x.current=T,g(),u(!0),c(null);try{const{token:M}=await q(),J=await un(e,M,w,I,T.signal);if(T.signal.aborted)return;const F=J.parts.filter(L=>L.trim());if(F.length===0)throw new Error("The agent did not answer. Try again.");i(L=>[...L,{id:J.id,role:"assistant",parts:F,shown:0}]),v.current=Jn(F.length).map((L,le)=>window.setTimeout(()=>{i(Y=>Y.map(D=>D.id===J.id?{...D,shown:le+1}:D)),le===F.length-1&&u(!1)},L))}catch(M){if(T.signal.aborted)return;M instanceof G&&(M.status===401||M.status===409)&&$(),u(!1),c(M instanceof G?M.message:M instanceof TypeError?"Could not reach the agent. Try again.":M instanceof Error&&M.message?M.message:"Something went wrong. Try again.")}},[e,q,$]);return{turns:o,busy:a,error:d,sessionId:f,stopping:l,send:U(w=>{const I=w.trim().slice(0,4e3);if(!I||a||l)return;const S={id:We(),text:I};_.current=S,i(T=>[...T,{id:S.id,role:"user",parts:[I],shown:1}]),A(S,"submit-message")},[a,l,A]),retry:U(()=>{!_.current||a||l||A(_.current,"regenerate-message")},[a,l,A]),stop:U(()=>{var w;(w=x.current)===null||w===void 0||w.abort(),x.current=null,g(),i(I=>I.map(S=>S.role==="assistant"&&S.shown<S.parts.length?{...S,shown:S.parts.length}:S)),u(!1)},[]),askToStop:U(()=>{!m.current||a||p({busy:!1,error:null})},[a]),answerStop:U(async w=>{const I=m.current;if(!w||!I){p(null);return}p({busy:!0,error:null});try{await cn(e,I.token)}catch(S){if(!(S instanceof G&&(S.status===401||S.status===409))){p({busy:!1,error:S instanceof G?S.message:"Could not stop the conversation. Try again."});return}}$(),_.current=null,i([]),c(null),p(null)},[e,$])}}function rr(){const e="(max-width: 639px)",[t,n]=H(()=>{var r,o,i;return(r=(o=(i=window).matchMedia)===null||o===void 0?void 0:o.call(i,e).matches)!==null&&r!==void 0?r:!1});return P(()=>{var r,o;const i=(r=(o=window).matchMedia)===null||r===void 0?void 0:r.call(o,e);if(!i)return;const a=()=>n(i.matches);return i.addEventListener("change",a),()=>i.removeEventListener("change",a)},[]),t}var ir=.5,Lt=120,Ue=()=>document.documentElement.clientHeight;function Ot({look:e,pinned:t,onClose:n,children:r}){const[o,i]=H("half"),[a,u]=H(null),d=B(null),c=B(null),f=_=>{const g=d.current;g&&(_.currentTarget.setPointerCapture(_.pointerId),c.current={startY:_.clientY,startHeight:g.getBoundingClientRect().height,lastY:_.clientY,lastAt:_.timeStamp,velocity:0},u(c.current.startHeight))},h=_=>{const g=c.current;if(!g)return;const y=_.timeStamp-g.lastAt;y>0&&(g.velocity=(_.clientY-g.lastY)/y),g.lastY=_.clientY,g.lastAt=_.timeStamp;const $=g.startHeight+(g.startY-_.clientY);u(Math.max(Lt,Math.min(Ue(),$)))},l=()=>{const _=c.current;if(!_)return;c.current=null;const g=Math.max(Lt,Math.min(Ue(),_.startHeight+(_.startY-_.lastY))),y=Ue();let $;if(_.velocity<-.5?$="full":_.velocity>ir?$=o==="full"?"half":"closed":g>y*.75?$="full":g<y*.3?$="closed":$="half",u(null),$==="closed"){t?i("half"):n();return}i($)},{ink:p,surfaceBg:m,rad:x}=e,v=o==="full"&&a===null;return s("div",{ref:d,class:["uq-fixed uq-drawer uq-slide",v?"uq-drawer-full":"uq-drawer-half",a!==null&&"uq-drawer-held"].filter(Boolean).join(" "),role:"dialog","aria-modal":"false",style:{height:a!==null?a:void 0,borderRadius:v?0:`${x}px ${x}px 0 0`,borderTop:`1px solid rgba(${p},.12)`,background:m,boxShadow:"0 -12px 40px rgba(0,0,0,.18)"},children:[s("div",{class:"uq-grab",onPointerDown:f,onPointerMove:h,onPointerUp:l,onPointerCancel:l,"aria-label":v?"Drag down to shrink or close":"Drag up to expand",style:{background:m},children:s("span",{style:{background:`rgba(${p},.25)`}})}),r]})}var b={accent:"#7B5BFF",gradient:"linear-gradient(135deg,#00B2FF 0%,#006AFF 38%,#8E5BFF 100%)",blue:"#0084FF",surface:{light:"#ffffff",dark:"#242526"},bubble:{light:"#f5f5f5",dark:"#404040"},muted:{light:"#8e8e8e",dark:"#a8a8a8"},border:{light:"rgba(0,0,0,.1)",dark:"rgba(255,255,255,.12)"},panelWidth:372,panelHeight:520,panelRadius:24,panelGap:14,panelShadow:"0 8px 32px rgba(0,0,0,.16)",launcherSize:60,launcherShadow:"0 6px 20px rgba(123,91,255,.4)",badgeSize:20,logo:"M12 2C6.48 2 2 6.18 2 11.32c0 2.93 1.45 5.55 3.7 7.27v3.4l3.39-1.86a10.5 10.5 0 0 0 2.91.41c5.52 0 10-4.18 10-9.22S17.52 2 12 2Zm1.06 12.42-2.55-2.72-4.97 2.72 5.46-5.8 2.61 2.72 4.91-2.72-5.46 5.8Z",headerAvatar:40,headerButton:28,headerIcon:18,nameFont:15,avatarSize:28,bubbleRadius:18,bubbleFont:14,bubblePadding:"6px 12px",bubbleMaxWidth:"78%",ctaShadow:"0 4px 12px rgba(123,91,255,.32)",composerPlaceholder:"Aa",composerRadius:24,composerHeight:36,sendSize:36,sendIcon:20},or=3600,Ye=e=>e.welcome||"Hi! Ask me anything before you buy.";function Nt(e,t="Type your message…"){const n=e.spotlights.filter(a=>a.trim()),[r,o]=H(0);P(()=>{if(n.length<2)return;const a=window.setInterval(()=>o(u=>u+1),or);return()=>window.clearInterval(a)},[n.length]);const i=e.placeholder||t;return n.length?n[r%n.length]:i}function Se(e){const t=B(null);return P(()=>{const n=t.current;n&&(n.scrollTop=n.scrollHeight)},e),t}function Ut(e){const t=e?"dark":"light";return{surface:b.surface[t],bubble:b.bubble[t],muted:b.muted[t],border:b.border[t]}}var X=(e,t={})=>({width:e,height:e,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,...t});function Ge({payload:e,size:t,font:n,palette:r,fallback:o}){var i,a,u,d;const c=(i=(a=e.agent)===null||a===void 0?void 0:a.name)!==null&&i!==void 0?i:null,f=(u=(d=e.agent)===null||d===void 0?void 0:d.avatarUrl)!==null&&u!==void 0?u:null;return f?s("img",{src:f,alt:"",width:t,height:t,style:X(t,{objectFit:"cover"})}):s("span",{style:X(t,{background:r.bubble,color:r.muted,fontSize:n,fontWeight:600,...o}),children:c?c.trim().charAt(0).toUpperCase():"A"})}function Ke({text:e,mine:t,runStart:n,look:r,config:o,payload:i,palette:a,children:u}){return s("div",{class:"uq-rise",style:{display:"flex",alignItems:"flex-end",gap:6,justifyContent:t?"flex-end":"flex-start",marginTop:n?6:2},children:[!t&&(n?s(Ge,{payload:i,size:b.avatarSize,font:12,palette:a}):s("span",{style:{width:b.avatarSize,flexShrink:0}})),s("div",{class:k(o,t?"userMessage":"botMessage"),style:{maxWidth:b.bubbleMaxWidth,padding:u?"8px 12px":b.bubblePadding,borderRadius:b.bubbleRadius,background:t?b.gradient:a.bubble,color:t?"#fff":`rgb(${r.ink})`,fontSize:b.bubbleFont,lineHeight:1.375,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:u!=null?u:e})]})}function sr({chat:e,stopping:t}){const n={padding:"6px 12px",borderRadius:999,fontSize:13,fontWeight:600,lineHeight:1.3,opacity:t.busy?.6:1};return s("div",{class:"uq-stop",style:{display:"flex",flexDirection:"column",gap:8},children:[s("span",{style:{fontWeight:600},children:"Stop the conversation?"}),s("span",{children:"Do you want to stop this conversation?"}),s("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[s("button",{type:"button",onClick:()=>e.answerStop(!1),disabled:t.busy,style:{...n,border:`1px solid ${b.blue}`,color:b.blue},children:"Keep chatting"}),s("button",{type:"button",onClick:()=>e.answerStop(!0),disabled:t.busy,style:{...n,background:b.gradient,color:"#fff"},children:t.busy?"Stopping…":"Stop conversation"})]}),t.error&&s("span",{class:"uq-fade",style:{opacity:.7},children:t.error})]})}function Yt({payload:e,config:t,look:n,chat:r,focus:o,onCta:i,mobile:a,fill:u=!1,onMinimize:d,onClose:c}){var f,h,l,p;const m=Ut(n.hostDark),{surface:x,bubble:v,muted:_,border:g}=m,y=Nt(t,b.composerPlaceholder),$=(f=(h=e.agent)===null||h===void 0?void 0:h.name)!==null&&f!==void 0?f:null,q=!!(!((l=e.agent)===null||l===void 0)&&l.live),A=Se([r.turns,r.busy,r.error,r.stopping]),[w,I]=H(""),S=B(null);P(()=>{var R;o>0&&((R=S.current)===null||R===void 0||R.focus())},[o]);const T=q&&!r.stopping,M=R=>{R.preventDefault(),T&&(r.send(w),I(""))},J=!((p=t.cta)===null||p===void 0||(p=p.href)===null||p===void 0)&&p.trim()?t.cta:null,F=[{key:"welcome",text:Ye(t),mine:!1}];for(const R of r.turns)if(R.role==="user"){var L;F.push({key:R.id,text:(L=R.parts[0])!==null&&L!==void 0?L:"",mine:!0})}else R.parts.slice(0,R.shown).forEach((Q,Qe)=>{F.push({key:`${R.id}:${Qe}`,text:Q,mine:!1})});const le=F[F.length-1],Y=(R,Q,Qe,Ze,tn)=>s("button",{type:"button",class:tn?k(t,tn):void 0,onClick:Ze,disabled:!Ze,"aria-label":Q,style:X(a?36:b.headerButton,{color:Qe,opacity:Ze?1:.6}),children:R}),D=b.headerIcon;return s("div",{class:k(t,"panel"),style:{display:"flex",flexDirection:"column",borderRadius:u?0:b.panelRadius,overflow:"hidden",border:u?void 0:`1px solid ${g}`,boxShadow:u?void 0:b.panelShadow,background:x,color:`rgb(${n.ink})`,...u?{flex:1,minHeight:0}:{height:b.panelHeight,maxHeight:`calc(100vh - ${n.offsetY+b.launcherSize+b.panelGap+12}px)`}},children:[s("div",{class:k(t,"header"),style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",borderBottom:`1px solid ${g}`},children:[s(Ge,{payload:e,size:b.headerAvatar,font:14,palette:m}),s("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:2},children:[s("span",{style:{fontSize:b.nameFont,fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$?$.split("—")[0].trim():"Chat"}),s("span",{style:{color:_,opacity:.7,display:"flex"},children:s(Wt,{size:16})})]}),Y(s(On,{size:D}),"Call (unavailable)",b.blue),Y(s(Nn,{size:D}),"Video call (unavailable)",b.blue),Y(s(Un,{size:D}),"Details (unavailable)",_),r.sessionId&&Y(s(Oe,{size:D}),"Stop conversation",_,r.busy||r.stopping?void 0:r.askToStop,"stopButton"),d&&Y(s(Yn,{size:D}),"Minimize chat",_,d),c&&Y(s(xe,{size:D}),"Close chat",_,c,"close")]}),s("div",{ref:A,style:{flex:1,minHeight:0,padding:"6px 12px 12px",display:"flex",flexDirection:"column",overflowY:"auto",overscrollBehavior:"contain"},children:[F.map((R,Q)=>s(Ke,{text:R.text,mine:R.mine,runStart:Q===0||F[Q-1].mine!==R.mine,look:n,config:t,payload:e,palette:m},R.key)),r.stopping&&s(Ke,{mine:!1,runStart:le.mine,look:n,config:t,payload:e,palette:m,children:s(sr,{chat:r,stopping:r.stopping})}),r.busy&&s(Ke,{mine:!1,runStart:le.mine,look:n,config:t,payload:e,palette:m,children:s("span",{class:"uq-dots","aria-label":"Typing",style:{gap:4},children:[s("span",{style:{width:6,height:6}}),s("span",{style:{width:6,height:6}}),s("span",{style:{width:6,height:6}})]})}),r.error&&s("div",{class:"uq-error uq-fade",style:{display:"flex",gap:8,marginTop:6,paddingLeft:b.avatarSize+6,fontSize:12,color:_},children:[s("span",{children:r.error}),s("button",{type:"button",onClick:r.retry,style:{color:b.blue,fontWeight:500,textDecoration:"underline"},children:"Retry"})]})]}),J&&s("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 12px"},children:s("a",{class:"uq-cta",href:J.href,target:"_blank",rel:"noopener noreferrer",onClick:i,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"8px 16px",borderRadius:999,background:b.gradient,color:"#fff",fontSize:14,fontWeight:600,boxShadow:b.ctaShadow},children:[J.label||"Learn more",s(Kn,{size:16})]})}),s("form",{class:k(t,"composer"),onSubmit:M,style:{display:"flex",alignItems:"center",gap:4,padding:8,borderTop:`1px solid ${g}`},children:[s("input",{ref:S,type:"text",value:w,onInput:R=>I(R.target.value),placeholder:y,disabled:!T,maxLength:4e3,"aria-label":"Message",autoComplete:"off",style:{flex:1,minHeight:b.composerHeight,padding:"0 12px",borderRadius:b.composerRadius,background:v,color:`rgb(${n.ink})`,fontSize:a?16:14,"--uq-placeholder":_}}),r.busy?s("button",{type:"button",class:k(t,"sendButton"),onClick:r.stop,"aria-label":"Stop",style:X(b.sendSize,{color:b.blue}),children:s("span",{style:{width:10,height:10,background:"currentColor",borderRadius:2}})}):s("button",{type:"submit",class:k(t,"sendButton"),disabled:!T||!w.trim(),"aria-label":"Send",style:X(b.sendSize,{color:b.blue,opacity:T&&w.trim()?1:.5}),children:s(Gn,{size:b.sendIcon})})]})]})}function ar({payload:e,config:t,look:n,chat:r,mobile:o,focus:i,open:a,setOpen:u,pinned:d,onCta:c}){const f=Ut(n.hostDark),{side:h,offsetY:l}=n,p=d?void 0:()=>u(!1);if(a&&o){const m={...n,surfaceBg:f.surface,rad:b.panelRadius};return s(Ot,{look:m,pinned:d,onClose:()=>u(!1),children:s(Yt,{payload:e,config:t,look:n,chat:r,focus:i,onCta:c,mobile:!0,fill:!0,onClose:p})})}return s(N,{children:[a&&s("div",{class:"uq-fixed uq-rise",style:{bottom:l+b.launcherSize+b.panelGap,width:b.panelWidth,...h},children:s(Yt,{payload:e,config:t,look:n,chat:r,focus:i,onCta:c,mobile:!1,onMinimize:p,onClose:p})}),s("button",{type:"button",class:k(t,"launcher","uq-fixed"),"aria-label":a?"Close chat":"Open chat","aria-expanded":a,onClick:()=>{a&&d||u(!a)},style:{bottom:l,...X(b.launcherSize,{boxShadow:b.launcherShadow}),...h},children:[s(Ge,{payload:e,size:b.launcherSize,font:16,palette:f,fallback:{background:b.gradient,color:"#fff"}}),a?s("span",{style:{position:"absolute",inset:0,borderRadius:"50%",background:"rgba(0,0,0,.45)",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff"},children:s(Wt,{size:28})}):s("span",{style:{position:"absolute",right:-4,bottom:-4,...X(b.badgeSize,{background:b.accent,color:"#fff",boxShadow:`0 0 0 2px ${f.surface}`})},children:s(Vn,{size:12,d:b.logo})})]})]})}function ae({text:e,mine:t,onDark:n,look:r,config:o,children:i}){const a=se(n),{isGlass:u,accentFill:d,accentText:c,rad:f}=r;return s("div",{class:k(o,t?"userMessage":"botMessage","uq-rise"),style:{alignSelf:t?"flex-end":"flex-start",maxWidth:t?"78%":"84%",padding:"8px 10px",borderRadius:f,background:t?d:u?"rgba(10,12,18,.42)":`rgba(${a},${n?.1:.06})`,color:t?c:u?"#fff":`rgb(${a})`,backdropFilter:!t&&u?"blur(6px)":void 0,fontSize:12,lineHeight:1.45,textShadow:!t&&u?"0 1px 2px rgba(0,0,0,.5)":void 0,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:i!=null?i:e})}var lr=e=>s(ae,{mine:!1,...e,children:s("span",{class:"uq-dots","aria-label":"Typing",children:[s("span",{}),s("span",{}),s("span",{})]})});function cr({chat:e,onDark:t,look:n,config:r}){const o=e.stopping;if(!o)return null;const{isGlass:i,accent:a,accentFill:u,accentText:d,rad:c}=n,f=i?"#fff":a,h={padding:"5px 10px",borderRadius:c,fontSize:11.5,fontWeight:500,lineHeight:1.3,opacity:o.busy?.6:1};return s(ae,{mine:!1,onDark:t,look:n,config:r,children:s("div",{class:"uq-stop",style:{display:"flex",flexDirection:"column",gap:8},children:[s("span",{style:{fontWeight:600},children:"Stop the conversation?"}),s("span",{children:"Do you want to stop this conversation?"}),s("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[s("button",{type:"button",onClick:()=>e.answerStop(!1),disabled:o.busy,style:{...h,border:`1px solid ${f}`,color:f},children:"Keep chatting"}),s("button",{type:"button",onClick:()=>e.answerStop(!0),disabled:o.busy,style:{...h,background:u,color:d},children:o.busy?"Stopping…":"Stop conversation"})]}),o.error&&s("span",{class:"uq-fade",style:{opacity:.7},children:o.error})]})})}function Gt({config:e,look:t,onDark:n,chat:r,size:o}){if(!r.sessionId)return null;const i=se(n),a=!r.busy&&!r.stopping;return s("button",{type:"button",class:k(e,"stopButton"),onClick:r.askToStop,disabled:!a,"aria-label":"Stop conversation",style:{width:o,height:o,borderRadius:t.rad,color:t.isGlass?"#fff":`rgb(${i})`,opacity:a?.55:.3,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:s(Oe,{size:o-9})})}function Kt({config:e,look:t,onClick:n}){var r;const o=!((r=e.cta)===null||r===void 0||(r=r.href)===null||r===void 0)&&r.trim()?e.cta:null;return o?s("a",{class:"uq-cta",href:o.href,target:"_blank",rel:"noopener noreferrer",onClick:n,style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"9px 12px",borderRadius:t.rad,background:t.accentFill,color:t.accentText,fontSize:12,fontWeight:500},children:o.label||"Learn more"}):null}function Vt({config:e,look:t,onDark:n,hint:r,chat:o,disabled:i,focus:a,withStop:u=!1}){const d=se(n),{isGlass:c,accentFill:f,accentText:h,rad:l}=t,[p,m]=H(""),x=B(null);P(()=>{var y;a>0&&((y=x.current)===null||y===void 0||y.focus())},[a]);const v=i||!!o.stopping,_=y=>{y.preventDefault(),!v&&(o.send(p),m(""))},g=c?"rgba(255,255,255,.75)":`rgba(${d},${n?.6:.45})`;return s("form",{class:k(e,"composer"),onSubmit:_,style:{display:"flex",alignItems:"center",gap:8,padding:"7px 8px 7px 11px",borderRadius:l,border:c?"1px solid rgba(255,255,255,.35)":`1px solid rgba(${d},${n?.28:.12})`,background:c?"rgba(10,12,18,.3)":`rgba(${d},${n?.08:.02})`,backdropFilter:c||n?"blur(6px)":void 0},children:[s("input",{ref:x,type:"text",value:p,onInput:y=>m(y.target.value),placeholder:r||"Message…",disabled:v,maxLength:4e3,"aria-label":"Message",autoComplete:"off",style:{flex:1,fontSize:11.5,color:c?"#fff":`rgb(${d})`,"--uq-placeholder":g}}),u&&s(Gt,{config:e,look:t,onDark:n,chat:o,size:24}),o.busy?s("button",{type:"button",class:k(e,"sendButton"),onClick:o.stop,"aria-label":"Stop",style:{width:24,height:24,borderRadius:l,background:f,color:h,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:s("span",{style:{width:8,height:8,background:"currentColor",borderRadius:1}})}):s("button",{type:"submit",class:k(e,"sendButton"),disabled:v,"aria-label":"Send",style:{width:24,height:24,borderRadius:l,background:f,color:h,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,opacity:v?.5:1},children:s(Dt,{size:13})})]})}function Ve({welcome:e,chat:t,onDark:n,look:r,config:o}){const i=se(n);return s(N,{children:[s(ae,{text:e,mine:!1,onDark:n,look:r,config:o}),t.turns.map(a=>a.role==="user"?s(ae,{text:a.parts[0],mine:!0,onDark:n,look:r,config:o},a.id):a.parts.slice(0,a.shown).map((u,d)=>s(ae,{text:u,mine:!1,onDark:n,look:r,config:o},`${a.id}:${d}`))),s(cr,{chat:t,onDark:n,look:r,config:o}),t.busy&&s(lr,{onDark:n,look:r,config:o}),t.error&&s("div",{class:"uq-error uq-fade",style:{alignSelf:"flex-start",display:"flex",gap:8,fontSize:11.5,color:r.isGlass?"rgba(255,255,255,.8)":`rgba(${i},.6)`,textShadow:r.isGlass?"0 1px 2px rgba(0,0,0,.5)":void 0},children:[s("span",{children:t.error}),s("button",{type:"button",onClick:t.retry,style:{color:r.isGlass?"#fff":r.accent,fontWeight:500,textDecoration:"underline"},children:"Retry"})]})]})}function Xe({payload:e,config:t,look:n,chat:r,shadow:o,hint:i,focus:a,onCta:u,fill:d=!1,onClose:c}){var f,h,l;const{ink:p,surfaceBg:m,hostDark:x,accentFill:v,accentText:_,rad:g}=n,y=(f=(h=e.agent)===null||h===void 0?void 0:h.name)!==null&&f!==void 0?f:null,$=y?y.trim().charAt(0).toUpperCase():"A",q=Ye(t),A=Se([r.turns,r.busy,r.error,r.stopping]),w=!!(!((l=e.agent)===null||l===void 0)&&l.live);return s("div",{class:k(t,"panel"),style:{width:"100%",borderRadius:d?0:g,overflow:"hidden",border:d?void 0:`1px solid rgba(${p},.12)`,boxShadow:o?"0 18px 44px rgba(0,0,0,.16)":void 0,background:m,...d?{flex:1,minHeight:0,display:"flex",flexDirection:"column"}:{}},children:[s("div",{class:k(t,"header"),style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:v,color:_},children:[s("span",{style:{width:20,height:20,borderRadius:"50%",background:"rgba(255,255,255,.25)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:600,color:_},children:$}),s("span",{style:{fontSize:12,fontWeight:500},children:y?y.split("—")[0].trim():"Chat"}),s("span",{style:{marginLeft:"auto",fontSize:10,opacity:.8},children:w?"online":"offline"}),r.sessionId&&s("button",{type:"button",class:k(t,"stopButton"),onClick:r.askToStop,disabled:r.busy||!!r.stopping,"aria-label":"Stop conversation",style:{width:28,height:28,marginRight:c?0:-6,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",color:_,opacity:r.busy||r.stopping?.5:.9,flexShrink:0},children:s(Oe,{size:15})}),c&&s("button",{type:"button",class:k(t,"close"),onClick:c,"aria-label":"Close chat",style:{width:28,height:28,marginRight:-6,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",color:_,flexShrink:0},children:s(xe,{size:16})})]}),s("div",{ref:A,style:{display:"flex",flexDirection:"column",gap:7,padding:12,background:m,maxHeight:d?void 0:"min(58vh, 380px)",flex:d?1:void 0,minHeight:d?0:void 0,overflowY:"auto",overscrollBehavior:"contain"},children:s(Ve,{welcome:q,chat:r,onDark:x,look:n,config:t})}),s("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"0 12px 12px",background:m},children:[s(Kt,{config:t,look:n,onClick:u}),s(Vt,{config:t,look:n,onDark:x,hint:i,chat:r,disabled:!w,focus:a})]})]})}function ur({payload:e,look:t,api:n,embed:r,page:o,reporter:i,open:a,setOpen:u,pinned:d,focus:c}){var f;const h=e.config,l=nr(n,e,r,o),p=Nt(h),{accentFill:m,accentText:x,rad:v,side:_,offsetY:g}=t,y=rr(),$=!!(!((f=e.agent)===null||f===void 0)&&f.live),q=Ye(h),A=()=>{var I,S;return i.report("cta.clicked",{widgetId:e.id,sessionId:(I=l.sessionId)!==null&&I!==void 0?I:void 0,payload:{href:(S=h.cta)===null||S===void 0?void 0:S.href}})};if(t.isMessenger)return s(ar,{payload:e,config:h,look:t,chat:l,mobile:y,focus:c,open:a,setOpen:u,pinned:d,onCta:A});if(h.variant==="bubble")return a&&y?s(Ot,{look:t,pinned:d,onClose:()=>u(!1),children:s(Xe,{payload:e,config:h,look:t,chat:l,shadow:!1,hint:p,focus:c,onCta:A,fill:!0,onClose:d?void 0:()=>u(!1)})}):s(N,{children:[a&&s("div",{class:"uq-fixed uq-rise",style:{bottom:g+54,width:296,..._},children:s(Xe,{payload:e,config:h,look:t,chat:l,shadow:!0,hint:p,focus:c,onCta:A})}),s("button",{type:"button",class:k(h,"launcher","uq-fixed"),"aria-label":a?"Close chat":"Open chat","aria-expanded":a,onClick:()=>{a&&d||u(!a)},style:{bottom:g,width:44,height:44,borderRadius:Math.min(22,v*2),background:m,color:x,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 10px 26px rgba(0,0,0,.24)",..._},children:s(Bt,{size:20})})]});if(h.variant==="box")return s("div",{class:"uq-inline",children:s(Xe,{payload:e,config:h,look:t,chat:l,shadow:!1,hint:p,focus:c,onCta:A})});const w={payload:e,config:h,look:t,chat:l,hint:p,mobile:y,focus:c,live:$,welcome:q,onCta:A};return h.variant==="chatbar"?s(dr,{...w}):s(fr,{...w})}function dr({config:e,look:t,chat:n,hint:r,mobile:o,focus:i,live:a,welcome:u}){const{ink:d,hostDark:c,accentFill:f,accentText:h,rad:l}=t,p=Se([n.turns,n.busy,n.error,n.stopping]),m=n.turns.length>0||n.stopping!==null,x=!a||n.stopping!==null;return s("div",{class:k(e,"panel","uq-fixed"),style:{left:0,right:0,bottom:0,padding:"10px 12px",background:c?"rgba(24,27,34,.97)":"rgba(255,255,255,.97)",borderTop:`1px solid rgba(${d},.12)`,display:"flex",flexDirection:"column",gap:10,boxShadow:"0 -10px 30px rgba(0,0,0,.12)"},children:[m&&s("div",{ref:p,style:{display:"flex",flexDirection:"column",gap:7,maxHeight:"min(50vh, 320px)",overflowY:"auto"},children:s(Ve,{welcome:u,chat:n,onDark:c,look:t,config:e})}),s("div",{style:{display:"flex",alignItems:"center",gap:10},children:[s("span",{class:k(e,"launcher"),style:{width:26,height:26,borderRadius:l,background:f,color:h,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:s(Bt,{size:14})}),s("span",{class:k(e,"botMessage"),style:{flex:1,minWidth:0,fontSize:12,color:`rgb(${d})`,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:u}),s("form",{class:k(e,"composer"),onSubmit:v=>{v.preventDefault();const _=v.currentTarget.elements.namedItem("message");!_||x||(n.send(_.value),_.value="")},style:{display:"flex",alignItems:"center",gap:8,flexShrink:0,padding:"6px 8px 6px 11px",borderRadius:l,border:`1px solid rgba(${d},.14)`,minWidth:o?0:220},children:[s("input",{name:"message",type:"text",placeholder:r,disabled:x,maxLength:4e3,"aria-label":"Message",autoComplete:"off",ref:v=>{v&&i>0&&v.focus()},style:{flex:1,fontSize:11.5,color:`rgb(${d})`,"--uq-placeholder":`rgba(${d},.45)`}}),s(Gt,{config:e,look:t,onDark:c,chat:n,size:22}),s("button",{type:n.busy?"button":"submit",class:k(e,"sendButton"),onClick:n.busy?n.stop:void 0,disabled:x,"aria-label":n.busy?"Stop":"Send",style:{width:22,height:22,borderRadius:l,background:f,color:h,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:n.busy?s("span",{style:{width:7,height:7,background:"currentColor",borderRadius:1}}):s(Dt,{size:12})})]})]})]})}function fr({config:e,look:t,chat:n,hint:r,mobile:o,focus:i,live:a,welcome:u,onCta:d}){const{hostDark:c,side:f,offsetY:h}=t,l=c,p=Se([n.turns,n.busy,n.error,n.stopping]);return s("div",{class:k(e,"panel","uq-fixed"),style:{bottom:h,width:o?`calc(100% - ${e.appearance.offsetX*2}px)`:320,display:"flex",flexDirection:"column",gap:7,...f},children:[s("div",{ref:p,style:{display:"flex",flexDirection:"column",gap:7,maxHeight:"min(60vh, 420px)",overflowY:"auto"},children:s(Ve,{welcome:u,chat:n,onDark:l,look:t,config:e})}),s(Kt,{config:e,look:t,onClick:d}),s(Vt,{config:e,look:t,onDark:l,hint:r,chat:n,disabled:!a,focus:i,withStop:!0})]})}var pr=e=>/^https?:\/\//i.test(e);function hr({config:e,block:t,index:n,look:r,onCta:o}){const{ink:i,accent:a,accentFill:u,accentText:d,rad:c}=r,f=["uq-block",`uq-block-${t.kind}`,t.cssClass.trim()].filter(Boolean).join(" "),h="align"in t?t.align:"center",l={class:f,"data-uq-block":n};switch(t.kind){case"headline":return s("div",{...l,style:{fontFamily:"var(--font-display, inherit)",fontSize:t.size==="lg"?21:t.size==="sm"?15:18,fontWeight:600,letterSpacing:"-0.02em",textAlign:h,color:t.color||`rgb(${i})`},children:t.text});case"text":return s("div",{...l,style:{fontSize:12.5,lineHeight:1.5,textAlign:h,color:t.color||`rgba(${i},.65)`,whiteSpace:"pre-wrap"},children:t.text});case"media":return!t.src||!pr(t.src)?null:t.mediaType==="video"?s("video",{...l,src:t.src,muted:!0,loop:!0,autoPlay:!0,playsInline:!0,style:{width:"100%",maxHeight:200,objectFit:"cover",borderRadius:c,background:"#000"}}):s("img",{...l,src:t.src,alt:t.alt||"",style:{width:"100%",maxHeight:200,objectFit:"cover",borderRadius:c}});case"quote":return s("div",{...l,style:{textAlign:"center"},children:[s("div",{style:{fontSize:13,fontStyle:"italic",color:`rgb(${i})`},children:["“",t.text,"”"]}),s("div",{style:{fontSize:11,color:`rgba(${i},.55)`,marginTop:4},children:t.author})]});case"cta":return s("a",{...l,class:`${k(e,"cta")} ${f}`,href:t.href||"#",target:t.newTab?"_blank":void 0,rel:t.newTab?"noopener noreferrer":void 0,onClick:()=>o(t.href),style:{display:"block",marginTop:4,padding:"10px 14px",borderRadius:c,background:t.style==="outline"?"transparent":u,border:t.style==="outline"?`1px solid ${a}`:void 0,color:t.style==="outline"?a:d,fontSize:13,fontWeight:500,textAlign:"center"},children:t.label})}}function _r({payload:e,look:t,reporter:n,open:r,setOpen:o,pinned:i}){const a=e.config,{ink:u,surfaceBg:d,rad:c}=t;if(!r)return null;const f=()=>{i||o(!1)},h=l=>n.report("cta.clicked",{widgetId:e.id,payload:{href:l}});return s("div",{class:k(a,"scrim","uq-fixed uq-fade"),onClick:f,style:{inset:0,background:"rgba(8,10,16,.5)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:s("div",{class:k(a,"card","uq-rise"),role:"dialog","aria-modal":"true",onClick:l=>l.stopPropagation(),style:{position:"relative",width:"100%",maxWidth:340,maxHeight:"calc(100vh - 48px)",overflowY:"auto",background:d,borderRadius:c,padding:"22px 20px",boxShadow:"0 24px 60px rgba(0,0,0,.3)",display:"flex",flexDirection:"column",gap:10,textAlign:"center",color:`rgb(${u})`},children:[!i&&s("button",{type:"button",class:k(a,"close"),onClick:f,"aria-label":"Close",style:{position:"absolute",top:8,right:8,width:24,height:24,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",color:`rgba(${u},.55)`},children:s(xe,{size:14})}),a.blocks.map((l,p)=>s(hr,{config:a,block:l,index:p,look:t,onCta:h},p))]})})}var gr=3600;function mr({payload:e,look:t,open:n}){const r=e.config,{ink:o,accent:i,surfaceBg:a,rad:u}=t,d=r.quotes,[c,f]=H(0);if(P(()=>{if(d.length<2)return;const p=window.setInterval(()=>f(m=>m+1),gr);return()=>window.clearInterval(p)},[d.length]),!n||d.length===0)return null;const h=c%d.length,l=d[h];return s("div",{class:"uq-fixed uq-fade",style:{left:0,right:0,bottom:0,display:"flex",justifyContent:"center",padding:24,pointerEvents:"none"},children:s("figure",{class:k(r,"frame"),style:{width:"100%",maxWidth:440,background:a,border:`1px solid rgba(${o},.12)`,borderLeft:`3px solid ${i}`,borderRadius:u,padding:"16px 18px",display:"flex",flexDirection:"column",gap:9,boxShadow:"0 14px 34px rgba(0,0,0,.12)",pointerEvents:"auto"},children:[s("blockquote",{class:k(r,"quote","uq-fade"),style:{fontSize:13.5,lineHeight:1.55,color:`rgb(${o})`},children:["“",l.text||"…","”"]},h),s("figcaption",{style:{display:"flex",alignItems:"center",gap:10},children:[s("span",{class:k(r,"author"),style:{fontFamily:"monospace",fontSize:11,color:`rgba(${o},.55)`},children:l.author||"—"}),s("span",{class:k(r,"dots"),style:{marginLeft:"auto",display:"flex",gap:4},children:d.map((p,m)=>s("span",{style:{width:5,height:5,borderRadius:"50%",background:m===h?i:`rgba(${o},.18)`}},m))})]})]})})}function br(e){switch(e.config.type){case"chat":case"exit-popup":return!1;case"banner":case"testimonial":return!0}}function vr(e){return e.rules.length>0||e.config.type!=="exit-popup"?e.rules:[{id:`default:${e.id}`,trigger:"exit_intent",triggerParams:{},conditions:[],once:!0,actionConfig:{open:!1,autoStart:!1,pinned:!1}}]}function Xt({payload:e,api:t,embed:n,page:r,reporter:o,hostDark:i,kick:a=null}){const u=be(()=>Wn(e.config,i),[e,i]),d=be(()=>vr(e),[e]),[c,f]=H(d.length===0),[h,l]=H(()=>d.length===0&&br(e)),[p,m]=H(!1),[x,v]=H(0),_=B(h),g=q=>{l(q),q!==_.current&&(_.current=q,o.report(q?"surface.opened":"surface.closed",{widgetId:e.id}))},y=({autoStart:q,pinned:A})=>{f(!0),m(A),g(!0),q&&v(w=>w+1)};if(P(()=>Rt(d,r,q=>{o.report("rule.fired",{widgetId:e.id,payload:{ruleId:q.id,trigger:q.trigger}}),y(q.actionConfig)}),[e.id]),P(()=>{a&&y(a.action)},[a]),!c)return null;const $={payload:e,look:u,api:t,embed:n,page:r,reporter:o,open:h,setOpen:g,pinned:p,focus:x};switch(e.config.type){case"chat":return s(ur,{...$});case"exit-popup":return s(_r,{...$});case"banner":return s(Xn,{...$});case"testimonial":return s(mr,{...$})}}function yr(e){const t=[],n=e.config.appearance.customCss.trim();return n&&t.push(n),e.config.type==="exit-popup"&&e.config.blocks.forEach((r,o)=>{const i=r.css.trim();i&&t.push(`[data-uq-widget="${e.id}"] [data-uq-block="${o}"]{${i}}`)}),t.join(`
|
|
35
|
+
`)}function xr(e){return e.kind==="widget"?[e.payload]:e.payload.members.map(t=>t.widget)}var wr={report:()=>{},flush:()=>{}};function Sr({group:e,...t}){const[n,r]=H(e.rules.length===0),[o,i]=H(null),[a,u]=H(()=>Pn(e));return P(()=>Rt(e.rules,t.page,d=>{t.reporter.report("rule.fired",{payload:{ruleId:d.id,trigger:d.trigger}}),r(!0),i(c=>{var f;return{action:d.actionConfig,n:((f=c==null?void 0:c.n)!==null&&f!==void 0?f:0)+1}})}),[e.id]),P(()=>{if(e.mode!=="sequence"||!n)return;const d=Pt(e);if(d)return Hn(e,d,c=>u(c?[c.widget]:[]))},[e.id,e.mode,n,a]),n?s(N,{children:a.map(d=>s("div",{"data-uq-widget":d.id,style:"display:contents",children:s(Xt,{payload:d,kick:o,...t})},d.id))}):null}function kr({snapshot:e,...t}){const n={kind:e.kind,id:e.payload.id};return e.kind==="group"?s(Sr,{group:e.payload,embed:n,...t}):s("div",{"data-uq-widget":e.payload.id,style:"display:contents",children:s(Xt,{payload:e.payload,embed:n,...t})})}function Jt(e,t,n={}){var r,o,i;const a=(r=t.shadowRoot)!==null&&r!==void 0?r:t.attachShadow({mode:"open"}),u={base:((o=n.apiUrl)!==null&&o!==void 0?o:"https://api.usereq.com").replace(/\/+$/,"")},d={kind:e.kind,id:e.payload.id},c=n.silent?wr:Mn(u,d),f=jn((i=n.theme)!==null&&i!==void 0?i:null),h=Bn(),l=document.createElement("style");a.appendChild(l);const p=document.createElement("div");p.setAttribute("data-uq-root",""),p.style.display="contents",a.appendChild(p);const m=x=>{l.textContent=[Cn,...xr(x).map(yr)].join(`
|
|
36
|
+
`),gt(s(kr,{snapshot:x,api:u,page:h,reporter:c,hostDark:f}),p)};return m(e),c.report("embed.loaded",{payload:{version:e.payload.version}}),{update:m,unmount:()=>{gt(null,p),c.flush(),l.remove(),p.remove()}}}function Qt(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function $r(e,t){Qt(e,t),t.add(e)}function Zt(e,t,n){Qt(e,t),t.set(e,n)}function ke(e,t,n){if(typeof e=="function"?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function $e(e,t){return e.get(ke(e,t))}function Ce(e,t,n){return e.set(ke(e,t),n),n}var Cr={widget:{element:"usereq-widget",attribute:"widget-id"},group:{element:"usereq-group",attribute:"group-id"}};function Je(e){console.warn(`[usereq] ${e}`)}function en(e){const{element:t,attribute:n}=Cr[e];if(customElements.get(t))return;var r=new WeakMap,o=new WeakMap,i=new WeakSet;class a extends HTMLElement{constructor(...c){super(...c),$r(this,i),Zt(this,r,null),Zt(this,o,0)}connectedCallback(){ke(i,this,u).call(this)}disconnectedCallback(){var c;(c=$e(r,this))===null||c===void 0||c.unmount(),Ce(r,this,null)}attributeChangedCallback(c,f,h){f!==h&&this.isConnected&&ke(i,this,u).call(this)}}async function u(){var d,c,f,h;const l=(d=this.getAttribute(n))===null||d===void 0?void 0:d.trim();if(!l)return;const p=Ce(o,this,(c=$e(o,this),++c));(f=$e(r,this))===null||f===void 0||f.unmount(),Ce(r,this,null);const m=((h=this.getAttribute("api-url"))!==null&&h!==void 0?h:"https://api.usereq.com").replace(/\/+$/,""),x=this.getAttribute("theme"),v=x==="light"||x==="dark"?x:null;let _;try{const g=await sn({base:m},e,l);_=pn(g,e)}catch(g){g instanceof G?Je(`${t} ${l}: ${g.message} (${g.code})`):Je(`${t} ${l}: could not reach ${m}.`);return}if(!(p!==$e(o,this)||!this.isConnected)){if(!_){Je(`${t} ${l}: the response was not a ${e} snapshot.`);return}Ce(r,this,Jt(_,this,{apiUrl:m,theme:v}))}}Ie(a,"observedAttributes",[n,"api-url","theme"]),customElements.define(t,a)}function qr(){en("widget"),en("group")}return qr(),qe.render=Jt,qe})({});
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=embed.js.map
|