@usereq/widget 1.0.0-experimental.1 → 1.0.0-experimental.2

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 CHANGED
@@ -19,17 +19,21 @@ Importing the module instead gives `render(snapshot, host, { apiUrl?, theme?, si
19
19
 
20
20
  ## What it does with a payload
21
21
 
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 |
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
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 |
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 |
30
30
 
31
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>`.
32
32
 
33
+ The bubble's panel is a FIXED box on a desktop (`CHAT_BUBBLE` in `@workspace/contracts/embed/presets`, 340 by 480, shrinking only when the viewport is shorter than that plus the launcher): the thread scrolls inside it and the composer stays put, the same size before the first message and after the fiftieth (2026-09-10 - before, the card was as tall as its messages and grew as replies landed). The inline box variant is the same fixed box in the page's flow.
34
+
35
+ The bubble's panel is a FIXED box on a desktop (`CHAT_BUBBLE` in `@workspace/contracts/embed/presets`, 340 by 480, shrinking only when the viewport is shorter than that plus the launcher): the thread scrolls inside it and the composer stays put, the same size before the first message and after the fiftieth (2026-09-10 - before, the card was as tall as its messages and grew as replies landed). The inline box variant is the same fixed box in the page's flow.
36
+
33
37
  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.
34
38
 
35
39
  ## Working on it
@@ -47,7 +51,7 @@ The dev host page takes `?id=…&kind=widget|group&bg=light|dark|photo&api=http:
47
51
 
48
52
  ## Publishing
49
53
 
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`.
54
+ From the repo root, `bun run release:embed` (`scripts/release-embed.ts`) bumps `version` in `package.json` to the next `1.0.0-experimental.N` (or the one you name), commits that file, and tags `embed-v<version>` on it - it refuses an uncommitted `packages/embed` or `packages/contracts`, since the runtime bakes the contracts in. Then `git push origin HEAD 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`.
51
55
 
52
56
  ## Not here yet
53
57
 
package/dist/embed.js CHANGED
@@ -1,5 +1,5 @@
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=`
1
+ var UserEQ=(function(Ie){Object.defineProperty(Ie,Symbol.toStringTag,{value:"Module"});async function rn(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 ee(e){"@babel/helpers - typeof";return ee=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},ee(e)}function on(e,t){if(ee(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(ee(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function sn(e){var t=on(e,"string");return ee(t)=="symbol"?t:t+""}function Te(e,t,n){return(t=sn(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),Te(this,"status",void 0),Te(this,"code",void 0),this.status=e,this.code=t}};async function te(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 Me=(e,t={})=>({method:"POST",headers:{"Content-Type":"application/json",...t},body:JSON.stringify(e)});async function an(e,t,n){const r=await fetch(`${e.base}/api/embed/${t}/${n}`);return r.ok?r.json():te(r)}async function ln(e,t){const n=await fetch(`${e.base}/api/embed/sessions`,Me(t));return n.ok?n.json():te(n)}var ze=e=>({Authorization:`Bearer ${e}`});async function cn(e,t){const n=await fetch(`${e.base}/api/embed/sessions/current`,{headers:ze(t)});return n.ok?n.json():te(n)}async function un(e,t){const n=await fetch(`${e.base}/api/embed/sessions/current/end`,{method:"POST",headers:ze(t)});return n.ok?n.json():te(n)}async function dn(e,t,n,r,o){const i=await fetch(`${e.base}/api/embed/chat`,{...Me({message:{id:n.id,role:"user",parts:[{type:"text",text:n.text}]},trigger:r},ze(t)),signal:o});return!i.ok||!i.body?te(i):rn(i.body)}async function fn(e,t){try{const n=await fetch(`${e.base}/api/embed/events`,{...Me(t),keepalive:!0});return n.ok?await n.json():null}catch{return null}}var K=e=>typeof e=="object"&&e!==null;function tt(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 pn(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)&&tt(t.widget))&&Array.isArray(e.rules)}function hn(e,t){return!K(e)||e.kind!==t?null:t==="widget"&&tt(e.payload)||t==="group"&&pn(e.payload)?e:null}var ue,I,nt,_n,O,rt,it,ot,Ae,de,ne,st,He,Re,Ee,gn,fe={},pe=[],mn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,he=Array.isArray;function W(e,t){for(var n in t)e[n]=t[n];return e}function Pe(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function bn(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?ue.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 _e(e,a,r,o,null)}function _e(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?++nt:o,__i:-1,__u:0};return o==null&&I.vnode!=null&&I.vnode(i),i}function N(e){return e.children}function ge(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 vn(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],o=[],i=W({},t);i.__v=t.__v+1,I.vnode&&I.vnode(i),je(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,ht(r,i,o),t.__e=t.__=null,i.__e!=n&&at(i)}}function at(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}),at(e)}function lt(e){(!e.__d&&(e.__d=!0)&&O.push(e)&&!me.__r++||rt!=I.debounceRendering)&&((rt=I.debounceRendering)||it)(me)}function me(){try{for(var e,t=1;O.length;)O.length>t&&O.sort(ot),e=O.shift(),t=O.length,vn(e)}finally{O.length=me.__r=0}}function ct(e,t,n,r,o,i,a,u,d,c,f){var h,l,p,m,x,v,_=r&&r.__k||pe,g=t.length;for(d=yn(n,t,_,d,g),h=0;h<g;h++)(p=n.__k[h])!=null&&(l=p.__i!=-1&&_[p.__i]||fe,p.__i=h,v=je(e,p,l,o,i,a,u,d,c,f),m=p.__e,p.ref&&l.ref!=p.ref&&(l.ref&&Fe(l.ref,null,p),f.push(p.ref,p.__c||m,p)),x==null&&m!=null&&(x=m),4&p.__u?(d=ut(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 yn(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]=_e(null,a,null,null,null):he(a)?a=e.__k[i]=_e(N,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[i]=_e(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=xn(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)),gt(u,u));return r}function ut(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=ut(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 xn(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 dt(e,t,n){t[0]=="-"?e.setProperty(t,n==null?"":n):e[t]=n==null?"":typeof n!="number"||mn.test(t)?n:n+"px"}function be(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||dt(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||dt(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")i=t!=(t=t.replace(st,"$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[ne]=r[ne]:(n[ne]=He,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 ft(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[de]==null)t[de]=He++;else if(t[de]<n[ne])return;return n(I.event?I.event(t):t)}}}function je(e,t,n,r,o,i,a,u,d,c){var f,h,l,p,m,x,v,_,g,y,$,q,z,S,C,w,T=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(d=!!(32&n.__u),i=[u=t.__e=n.__e]),(f=I.__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 ge(g,q),l.constructor=T,l.render=Sn),$&&$.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)}),pe.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,z=I.__r,S=0,y)l.state=l.__s,l.__d=!1,z&&z(t),f=l.render(l.props,l.state,l.context),pe.push.apply(l.__h,l._sb),l._sb=[];else do l.__d=!1,z&&z(t),f=l.render(l.props,l.state,l.context),l.state=l.__s;while(l.__d&&++S<25);l.state=l.__s,l.getChildContext!=null&&(r=W(W({},r),l.getChildContext())),y&&!p&&l.getSnapshotBeforeUpdate!=null&&(v=l.getSnapshotBeforeUpdate(m,x)),C=f!=null&&f.type===N&&f.key==null?_t(f.props.children):f,u=ct(e,he(C)?C:[C],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(w=i.length;w--;)Pe(i[w])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),M.then||pt(t),I.__e(M,t,n)}}else i==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):u=t.__e=wn(n.__e,t,n,r,o,i,a,d,c);return(f=I.diffed)&&f(t),128&t.__u?void 0:u}function pt(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(pt))}function ht(e,t,n){for(var r=0;r<n.length;r++)Fe(n[r],n[++r],n[++r]);I.__c&&I.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(i){i.call(o)})}catch(i){I.__e(i,o.__v)}})}function _t(e){return typeof e!="object"||e==null||e.__b>0?e:he(e)?e.map(_t):e.constructor!==void 0?null:W({},e)}function wn(e,t,n,r,o,i,a,u,d){var c,f,h,l,p,m,x,v=n.props||fe,_=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&&(I.__m&&I.__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&&ue.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 _||be(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||be(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=""),ct(t.type=="template"?e.content:e,he(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--;)Pe(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])&&be(e,c,m,v[c],o),c="checked",x!=null&&x!=e[c]&&be(e,c,x,v[c],o))}return e}function Fe(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){I.__e(o,n)}}function gt(e,t,n){var r,o;if(I.unmount&&I.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Fe(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(i){I.__e(i,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&gt(r[o],t,n||typeof e.type!="function");n||Pe(e.__e),e.__c=e.__=e.__e=void 0}function Sn(e,t,n){return this.constructor(e,n)}function mt(e,t,n){var r,o,i,a;t==document&&(t=document.documentElement),I.__&&I.__(e,t),o=(r=typeof n=="function")?null:n&&n.__k||t.__k,i=[],a=[],je(t,e=(!r&&n||t).__k=bn(N,null,[e]),o||fe,fe,t.namespaceURI,!r&&n?[n]:o?null:t.firstChild?ue.call(t.childNodes):null,i,!r&&n?n:o?o.__e:t.firstChild,r,a),ht(i,e,a),e.props.children=null}ue=pe.slice,I={__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}},nt=0,_n=function(e){return e!=null&&e.constructor===void 0},ge.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),lt(this))},ge.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),lt(this))},ge.prototype.render=N,O=[],it=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ot=function(e,t){return e.__v.__b-t.__v.__b},me.__r=0,Ae=Math.random().toString(8),de="__d"+Ae,ne="__a"+Ae,st=/(PointerCapture)$|Capture$/i,He=0,Re=ft(!1),Ee=ft(!0),gn=0;var re,A,Be,bt,ie=0,vt=[],R=I,yt=R.__b,xt=R.__r,wt=R.diffed,St=R.__c,kt=R.unmount,$t=R.__;function De(e,t){R.__h&&R.__h(A,e,ie||t),ie=0;var n=A.__H||(A.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function E(e){return ie=1,kn(It,e)}function kn(e,t,n){var r=De(re++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):It(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=A,!A.__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};A.__f=!0;var i=A.shouldComponentUpdate,a=A.componentWillUpdate;A.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)},A.shouldComponentUpdate=o}return r.__N||r.__}function P(e,t){var n=De(re++,3);!R.__s&&qt(n.__H,t)&&(n.__=e,n.u=t,A.__H.__h.push(n))}function B(e){return ie=5,ve(function(){return{current:e}},[])}function ve(e,t){var n=De(re++,7);return qt(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function U(e,t){return ie=8,ve(function(){return e},t)}function $n(){for(var e;e=vt.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ye),t.__h.some(We),t.__h=[]}catch(n){t.__h=[],R.__e(n,e.__v)}}}R.__b=function(e){A=null,yt&&yt(e)},R.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),$t&&$t(e,t)},R.__r=function(e){xt&&xt(e),re=0;var t=(A=e.__c).__H;t&&(Be===A?(t.__h=[],A.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(ye),t.__h.some(We),t.__h=[],re=0)),Be=A},R.diffed=function(e){wt&&wt(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(vt.push(t)!==1&&bt===R.requestAnimationFrame||((bt=R.requestAnimationFrame)||Cn)($n)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Be=A=null},R.__c=function(e,t){t.some(function(n){try{n.__h.some(ye),n.__h=n.__h.filter(function(r){return!r.__||We(r)})}catch(r){t.some(function(o){o.__h&&(o.__h=[])}),t=[],R.__e(r,n.__v)}}),St&&St(e,t)},R.unmount=function(e){kt&&kt(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{ye(r)}catch(o){t=o}}),n.__H=void 0,t&&R.__e(t,n.__v))};var Ct=typeof requestAnimationFrame=="function";function Cn(e){var t,n=function(){clearTimeout(r),Ct&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ct&&(t=requestAnimationFrame(n))}function ye(e){var t=A,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),A=t}function We(e){var t=A;e.__c=e.__(),A=t}function qt(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function It(e,t){return typeof t=="function"?t(e):t}var qn=`
3
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
4
  :host([hidden]){display:none}
5
5
  *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
@@ -31,8 +31,8 @@ img,video{display:block;max-width:100%}
31
31
  .uq-slide{animation:uq-slide .3s cubic-bezier(.32,.72,0,1) both}
32
32
  @keyframes uq-slide{from{transform:translateY(100%)}to{transform:none}}
33
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})({});
34
+ `;function oe(e,t){try{return window[e].getItem(t)}catch{return null}}function se(e,t,n){try{window[e].setItem(t,n)}catch{}}function Tt(e,t){try{window[e].removeItem(t)}catch{}}var In=2e3,Tn=20,Mn=100;function Le(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 Mt="usereq:visitor";function zt(){const e=oe("localStorage",Mt);if(e)return e;const t=Le();return se("localStorage",Mt,t),t}function zn(e,t){const n=[];let r=null;const o=zt(),i=()=>{for(r!==null&&(window.clearTimeout(r),r=null);n.length>0;){const u=n.splice(0,Mn);fn(e,{events:u})}},a=(u,d={})=>{n.push({id:Le(),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>=Tn?i():r===null&&(r=window.setTimeout(i,In))};return window.addEventListener("pagehide",i),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&i()}),{report:a,flush:i}}var At=e=>`usereq:once:${e}`;function Oe(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==="*"||Oe(e.op,t.path,e.value);case"utm":var n;return Oe(e.op,(n=t.utm[e.param])!==null&&n!==void 0?n:"",e.value);case"device":return t.device===e.value;case"referrer":return Oe(e.op,t.referrer,e.value)}}function Hn(e,t){for(const n of e)if(!(n.once&&oe("sessionStorage",At(n.id)))&&n.conditions.every(r=>An(r,t)))return n;return null}function Ht(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=Hn(e,t);return r?Ht(r.trigger,r.triggerParams,()=>{r.once&&se("sessionStorage",At(r.id),"1"),n(r)}):()=>{}}var Et=e=>`usereq:split:${e}`,Pt=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 xe(e){return[...e].sort((t,n)=>t.position-n.position)}function En(e){const t=xe(e.members);if(t.length===0)return null;const n=oe("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(`${zt()}:${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 se("localStorage",Et(e.id),a.widget.id),a}function jt(e){var t,n;const r=xe(e.members);if(r.length===0)return null;const o=Number((t=oe("sessionStorage",Pt(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 Pn(e,t,n){if(!t.advanceOn)return()=>{};const r=xe(e.members),o=r.findIndex(i=>i.widget.id===t.widget.id);return Ht(t.advanceOn.kind,t.advanceOn.params,()=>{var i;const a=o+1<r.length?o+1:null;if(a===null){n(null);return}se("sessionStorage",Pt(e.id),String(a)),n((i=r[a])!==null&&i!==void 0?i:null)})}function jn(e){switch(e.mode){case"split":{const t=En(e);return t?[t.widget]:[]}case"sequence":{const t=jt(e);return t?[t.widget]:[]}case"parallel":return xe(e.members).map(t=>t.widget)}}function Fn(e){var t,n,r,o;if(e)return e==="dark";const i=(t=Ft(getComputedStyle(document.body).backgroundColor))!==null&&t!==void 0?t:Ft(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 Ft(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 Bn(e=window.innerWidth){return e<640?"mobile":e<1024?"tablet":"desktop"}function Dn(){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:Bn()}}function Bt(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 Wn(e){const{r:t,g:n,b:r}=Bt(e);return(.299*t+.587*n+.114*r)/255>.62?"#15171e":"#ffffff"}var ae=e=>e?"245,245,241":"21,23,30";function Ln(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}=Bt(r);return`rgba(${o},${i},${a},${n.alpha/100})`})(),accentText:Wn(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:ae(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 On=0,Tr=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:--On,__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 I.vnode&&I.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 Dt=({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"})]}),Wt=({size:e})=>s(j,{size:e,children:[s("path",{d:"M5 12h14"}),s("path",{d:"m12 5 7 7-7 7"})]}),we=({size:e})=>s(j,{size:e,children:[s("path",{d:"M18 6 6 18"}),s("path",{d:"m6 6 12 12"})]}),Ne=({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"})]}),Nn=({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"})}),Un=({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"})]}),Yn=({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"})]}),Lt=({size:e})=>s(j,{size:e,children:s("path",{d:"m6 9 6 6 6-6"})}),Gn=({size:e})=>s(j,{size:e,children:s("path",{d:"M5 12h14"})}),Kn=({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"})]}),Vn=({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"})]}),Xn=({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 Jn({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(we,{size:14})})]})}var X={panelWidth:340,panelHeight:480,launcherSize:44,panelGap:10},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},Ue={holdMs:1260,gapMs:1520,jitterMs:100};function Qn(e,t=Math.random){const n=[];let r=0;for(let o=0;o<e;o++){if(o===0)r+=Ue.holdMs;else{const i=Math.round((t()*2-1)*Ue.jitterMs);r+=Math.max(0,Ue.gapMs+i)}n.push(r)}return n}var Se=e=>`usereq:session:${e}`;function Zn(e,t=Date.now()){const n=oe("localStorage",Se(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?(Tt("localStorage",Se(e)),null):{token:r.token,conversationId:r.conversationId,expiresAt:r.expiresAt}}catch{return null}}function er(e,t){se("localStorage",Se(e),JSON.stringify(t))}function tr(e){Tt("localStorage",Se(e))}function nr(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 rr(e,t,n,r){const[o,i]=E([]),[a,u]=E(!1),[d,c]=E(null),[f,h]=E(null),[l,p]=E(null),m=B(null),x=B(null),v=B([]),_=B(null),g=()=>{for(const S of v.current)window.clearTimeout(S);v.current=[]};P(()=>()=>g(),[]);const y=t.id,$=U(()=>{m.current=null,h(null),tr(y)},[y]);P(()=>{const S=Zn(y);if(!S)return;let C=!1;return m.current={token:S.token,conversationId:S.conversationId},h(S.conversationId),cn(e,S.token).then(w=>{if(!C){if(w.ended){$();return}i(w.messages.flatMap(T=>{const M=nr(T);return M?[M]:[]}))}}).catch(w=>{C||w instanceof G&&w.status<500&&$()}),()=>{C=!0}},[e,y,$]);const q=U(async()=>{if(m.current)return m.current;const S=await ln(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:S.token,conversationId:S.conversationId},er(y,{token:S.token,conversationId:S.conversationId,expiresAt:S.expiresAt}),h(S.conversationId),m.current},[e,n.kind,n.id,t.id,r,y]),z=U(async(S,C)=>{var w;(w=x.current)===null||w===void 0||w.abort();const T=new AbortController;x.current=T,g(),u(!0),c(null);try{const{token:M}=await q(),Q=await dn(e,M,S,C,T.signal);if(T.signal.aborted)return;const F=Q.parts.filter(L=>L.trim());if(F.length===0)throw new Error("The agent did not answer. Try again.");i(L=>[...L,{id:Q.id,role:"assistant",parts:F,shown:0}]),v.current=Qn(F.length).map((L,ce)=>window.setTimeout(()=>{i(Y=>Y.map(D=>D.id===Q.id?{...D,shown:ce+1}:D)),ce===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(S=>{const C=S.trim().slice(0,4e3);if(!C||a||l)return;const w={id:Le(),text:C};_.current=w,i(T=>[...T,{id:w.id,role:"user",parts:[C],shown:1}]),z(w,"submit-message")},[a,l,z]),retry:U(()=>{!_.current||a||l||z(_.current,"regenerate-message")},[a,l,z]),stop:U(()=>{var S;(S=x.current)===null||S===void 0||S.abort(),x.current=null,g(),i(C=>C.map(w=>w.role==="assistant"&&w.shown<w.parts.length?{...w,shown:w.parts.length}:w)),u(!1)},[]),askToStop:U(()=>{!m.current||a||p({busy:!1,error:null})},[a]),answerStop:U(async S=>{const C=m.current;if(!S||!C){p(null);return}p({busy:!0,error:null});try{await un(e,C.token)}catch(w){if(!(w instanceof G&&(w.status===401||w.status===409))){p({busy:!1,error:w instanceof G?w.message:"Could not stop the conversation. Try again."});return}}$(),_.current=null,i([]),c(null),p(null)},[e,$])}}function ir(){const e="(max-width: 639px)",[t,n]=E(()=>{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 or=.5,Ot=120,Ye=()=>document.documentElement.clientHeight;function Nt({look:e,pinned:t,onClose:n,children:r}){const[o,i]=E("half"),[a,u]=E(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(Ot,Math.min(Ye(),$)))},l=()=>{const _=c.current;if(!_)return;c.current=null;const g=Math.max(Ot,Math.min(Ye(),_.startHeight+(_.startY-_.lastY))),y=Ye();let $;if(_.velocity<-.5?$="full":_.velocity>or?$=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 sr=3600,Ge=e=>e.welcome||"Hi! Ask me anything before you buy.";function Ut(e,t="Type your message…"){const n=e.spotlights.filter(a=>a.trim()),[r,o]=E(0);P(()=>{if(n.length<2)return;const a=window.setInterval(()=>o(u=>u+1),sr);return()=>window.clearInterval(a)},[n.length]);const i=e.placeholder||t;return n.length?n[r%n.length]:i}function ke(e){const t=B(null);return P(()=>{const n=t.current;n&&(n.scrollTop=n.scrollHeight)},e),t}function Yt(e){const t=e?"dark":"light";return{surface:b.surface[t],bubble:b.bubble[t],muted:b.muted[t],border:b.border[t]}}var J=(e,t={})=>({width:e,height:e,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,...t});function Ke({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:J(t,{objectFit:"cover"})}):s("span",{style:J(t,{background:r.bubble,color:r.muted,fontSize:n,fontWeight:600,...o}),children:c?c.trim().charAt(0).toUpperCase():"A"})}function Ve({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(Ke,{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 ar({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 Gt({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=Yt(n.hostDark),{surface:x,bubble:v,muted:_,border:g}=m,y=Ut(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),z=ke([r.turns,r.busy,r.error,r.stopping]),[S,C]=E(""),w=B(null);P(()=>{var H;o>0&&((H=w.current)===null||H===void 0||H.focus())},[o]);const T=q&&!r.stopping,M=H=>{H.preventDefault(),T&&(r.send(S),C(""))},Q=!((p=t.cta)===null||p===void 0||(p=p.href)===null||p===void 0)&&p.trim()?t.cta:null,F=[{key:"welcome",text:Ge(t),mine:!1}];for(const H of r.turns)if(H.role==="user"){var L;F.push({key:H.id,text:(L=H.parts[0])!==null&&L!==void 0?L:"",mine:!0})}else H.parts.slice(0,H.shown).forEach((Z,Ze)=>{F.push({key:`${H.id}:${Ze}`,text:Z,mine:!1})});const ce=F[F.length-1],Y=(H,Z,Ze,et,nn)=>s("button",{type:"button",class:nn?k(t,nn):void 0,onClick:et,disabled:!et,"aria-label":Z,style:J(a?36:b.headerButton,{color:Ze,opacity:et?1:.6}),children:H}),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(Ke,{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(Lt,{size:16})})]}),Y(s(Nn,{size:D}),"Call (unavailable)",b.blue),Y(s(Un,{size:D}),"Video call (unavailable)",b.blue),Y(s(Yn,{size:D}),"Details (unavailable)",_),r.sessionId&&Y(s(Ne,{size:D}),"Stop conversation",_,r.busy||r.stopping?void 0:r.askToStop,"stopButton"),d&&Y(s(Gn,{size:D}),"Minimize chat",_,d),c&&Y(s(we,{size:D}),"Close chat",_,c,"close")]}),s("div",{ref:z,style:{flex:1,minHeight:0,padding:"6px 12px 12px",display:"flex",flexDirection:"column",overflowY:"auto",overscrollBehavior:"contain"},children:[F.map((H,Z)=>s(Ve,{text:H.text,mine:H.mine,runStart:Z===0||F[Z-1].mine!==H.mine,look:n,config:t,payload:e,palette:m},H.key)),r.stopping&&s(Ve,{mine:!1,runStart:ce.mine,look:n,config:t,payload:e,palette:m,children:s(ar,{chat:r,stopping:r.stopping})}),r.busy&&s(Ve,{mine:!1,runStart:ce.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"})]})]}),Q&&s("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 12px"},children:s("a",{class:"uq-cta",href:Q.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:[Q.label||"Learn more",s(Vn,{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:w,type:"text",value:S,onInput:H=>C(H.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:J(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||!S.trim(),"aria-label":"Send",style:J(b.sendSize,{color:b.blue,opacity:T&&S.trim()?1:.5}),children:s(Kn,{size:b.sendIcon})})]})]})}function lr({payload:e,config:t,look:n,chat:r,mobile:o,focus:i,open:a,setOpen:u,pinned:d,onCta:c}){const f=Yt(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(Nt,{look:m,pinned:d,onClose:()=>u(!1),children:s(Gt,{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(Gt,{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,...J(b.launcherSize,{boxShadow:b.launcherShadow}),...h},children:[s(Ke,{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(Lt,{size:28})}):s("span",{style:{position:"absolute",right:-4,bottom:-4,...J(b.badgeSize,{background:b.accent,color:"#fff",boxShadow:`0 0 0 2px ${f.surface}`})},children:s(Xn,{size:12,d:b.logo})})]})]})}function le({text:e,mine:t,onDark:n,look:r,config:o,children:i}){const a=ae(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 cr=e=>s(le,{mine:!1,...e,children:s("span",{class:"uq-dots","aria-label":"Typing",children:[s("span",{}),s("span",{}),s("span",{})]})});function ur({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(le,{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 Kt({config:e,look:t,onDark:n,chat:r,size:o}){if(!r.sessionId)return null;const i=ae(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(Ne,{size:o-9})})}function Vt({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 Xt({config:e,look:t,onDark:n,hint:r,chat:o,disabled:i,focus:a,withStop:u=!1}){const d=ae(n),{isGlass:c,accentFill:f,accentText:h,rad:l}=t,[p,m]=E(""),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(Kt,{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(Wt,{size:13})})]})}function Xe({welcome:e,chat:t,onDark:n,look:r,config:o}){const i=ae(n);return s(N,{children:[s(le,{text:e,mine:!1,onDark:n,look:r,config:o}),t.turns.map(a=>a.role==="user"?s(le,{text:a.parts[0],mine:!0,onDark:n,look:r,config:o},a.id):a.parts.slice(0,a.shown).map((u,d)=>s(le,{text:u,mine:!1,onDark:n,look:r,config:o},`${a.id}:${d}`))),s(ur,{chat:t,onDark:n,look:r,config:o}),t.busy&&s(cr,{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 Je({payload:e,config:t,look:n,chat:r,shadow:o,hint:i,focus:a,onCta:u,fill:d=!1,height:c=X.panelHeight,maxHeight:f,onClose:h}){var l,p,m;const{ink:x,surfaceBg:v,hostDark:_,accentFill:g,accentText:y,rad:$}=n,q=(l=(p=e.agent)===null||p===void 0?void 0:p.name)!==null&&l!==void 0?l:null,z=q?q.trim().charAt(0).toUpperCase():"A",S=Ge(t),C=ke([r.turns,r.busy,r.error,r.stopping]),w=!!(!((m=e.agent)===null||m===void 0)&&m.live);return s("div",{class:k(t,"panel"),style:{width:"100%",borderRadius:d?0:$,overflow:"hidden",border:d?void 0:`1px solid rgba(${x},.12)`,boxShadow:o?"0 18px 44px rgba(0,0,0,.16)":void 0,background:v,display:"flex",flexDirection:"column",...d?{flex:1,minHeight:0}:{height:c,maxHeight:f}},children:[s("div",{class:k(t,"header"),style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:g,color:y},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:y},children:z}),s("span",{style:{fontSize:12,fontWeight:500},children:q?q.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:h?0:-6,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",color:y,opacity:r.busy||r.stopping?.5:.9,flexShrink:0},children:s(Ne,{size:15})}),h&&s("button",{type:"button",class:k(t,"close"),onClick:h,"aria-label":"Close chat",style:{width:28,height:28,marginRight:-6,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",color:y,flexShrink:0},children:s(we,{size:16})})]}),s("div",{ref:C,style:{display:"flex",flexDirection:"column",gap:7,padding:12,background:v,flex:1,minHeight:0,overflowY:"auto",overscrollBehavior:"contain"},children:s(Xe,{welcome:S,chat:r,onDark:_,look:n,config:t})}),s("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"0 12px 12px",background:v},children:[s(Vt,{config:t,look:n,onClick:u}),s(Xt,{config:t,look:n,onDark:_,hint:i,chat:r,disabled:!w,focus:a})]})]})}function dr({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=rr(n,e,r,o),p=Ut(h),{accentFill:m,accentText:x,rad:v,side:_,offsetY:g}=t,y=ir(),$=!!(!((f=e.agent)===null||f===void 0)&&f.live),q=Ge(h),z=()=>{var C,w;return i.report("cta.clicked",{widgetId:e.id,sessionId:(C=l.sessionId)!==null&&C!==void 0?C:void 0,payload:{href:(w=h.cta)===null||w===void 0?void 0:w.href}})};if(t.isMessenger)return s(lr,{payload:e,config:h,look:t,chat:l,mobile:y,focus:c,open:a,setOpen:u,pinned:d,onCta:z});if(h.variant==="bubble"){const C=g+X.launcherSize+X.panelGap;return a&&y?s(Nt,{look:t,pinned:d,onClose:()=>u(!1),children:s(Je,{payload:e,config:h,look:t,chat:l,shadow:!1,hint:p,focus:c,onCta:z,fill:!0,onClose:d?void 0:()=>u(!1)})}):s(N,{children:[a&&s("div",{class:"uq-fixed uq-rise",style:{bottom:C,width:X.panelWidth,..._},children:s(Je,{payload:e,config:h,look:t,chat:l,shadow:!0,hint:p,focus:c,onCta:z,maxHeight:`calc(100vh - ${C+12}px)`})}),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:X.launcherSize,height:X.launcherSize,borderRadius:Math.min(X.launcherSize/2,v*2),background:m,color:x,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 10px 26px rgba(0,0,0,.24)",..._},children:s(Dt,{size:20})})]})}if(h.variant==="box")return s("div",{class:"uq-inline",children:s(Je,{payload:e,config:h,look:t,chat:l,shadow:!1,hint:p,focus:c,onCta:z})});const S={payload:e,config:h,look:t,chat:l,hint:p,mobile:y,focus:c,live:$,welcome:q,onCta:z};return h.variant==="chatbar"?s(fr,{...S}):s(pr,{...S})}function fr({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=ke([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(Xe,{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(Dt,{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(Kt,{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(Wt,{size:12})})]})]})]})}function pr({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=ke([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(Xe,{welcome:u,chat:n,onDark:l,look:t,config:e})}),s(Vt,{config:e,look:t,onClick:d}),s(Xt,{config:e,look:t,onDark:l,hint:r,chat:n,disabled:!a,focus:i,withStop:!0})]})}var hr=e=>/^https?:\/\//i.test(e);function _r({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||!hr(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 gr({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(we,{size:14})}),a.blocks.map((l,p)=>s(_r,{config:a,block:l,index:p,look:t,onCta:h},p))]})})}var mr=3600;function br({payload:e,look:t,open:n}){const r=e.config,{ink:o,accent:i,surfaceBg:a,rad:u}=t,d=r.quotes,[c,f]=E(0);if(P(()=>{if(d.length<2)return;const p=window.setInterval(()=>f(m=>m+1),mr);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 vr(e){switch(e.config.type){case"chat":case"exit-popup":return!1;case"banner":case"testimonial":return!0}}function yr(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 Jt({payload:e,api:t,embed:n,page:r,reporter:o,hostDark:i,kick:a=null}){const u=ve(()=>Ln(e.config,i),[e,i]),d=ve(()=>yr(e),[e]),[c,f]=E(d.length===0),[h,l]=E(()=>d.length===0&&vr(e)),[p,m]=E(!1),[x,v]=E(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:z})=>{f(!0),m(z),g(!0),q&&v(S=>S+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(dr,{...$});case"exit-popup":return s(gr,{...$});case"banner":return s(Jn,{...$});case"testimonial":return s(br,{...$})}}function xr(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 wr(e){return e.kind==="widget"?[e.payload]:e.payload.members.map(t=>t.widget)}var Sr={report:()=>{},flush:()=>{}};function kr({group:e,...t}){const[n,r]=E(e.rules.length===0),[o,i]=E(null),[a,u]=E(()=>jn(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=jt(e);if(d)return Pn(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(Jt,{payload:d,kick:o,...t})},d.id))}):null}function $r({snapshot:e,...t}){const n={kind:e.kind,id:e.payload.id};return e.kind==="group"?s(kr,{group:e.payload,embed:n,...t}):s("div",{"data-uq-widget":e.payload.id,style:"display:contents",children:s(Jt,{payload:e.payload,embed:n,...t})})}function Qt(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?Sr:zn(u,d),f=Fn((i=n.theme)!==null&&i!==void 0?i:null),h=Dn(),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=[qn,...wr(x).map(xr)].join(`
36
+ `),mt(s($r,{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:()=>{mt(null,p),c.flush(),l.remove(),p.remove()}}}function Zt(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Cr(e,t){Zt(e,t),t.add(e)}function en(e,t,n){Zt(e,t),t.set(e,n)}function $e(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 Ce(e,t){return e.get($e(e,t))}function qe(e,t,n){return e.set($e(e,t),n),n}var qr={widget:{element:"usereq-widget",attribute:"widget-id"},group:{element:"usereq-group",attribute:"group-id"}};function Qe(e){console.warn(`[usereq] ${e}`)}function tn(e){const{element:t,attribute:n}=qr[e];if(customElements.get(t))return;var r=new WeakMap,o=new WeakMap,i=new WeakSet;class a extends HTMLElement{constructor(...c){super(...c),Cr(this,i),en(this,r,null),en(this,o,0)}connectedCallback(){$e(i,this,u).call(this)}disconnectedCallback(){var c;(c=Ce(r,this))===null||c===void 0||c.unmount(),qe(r,this,null)}attributeChangedCallback(c,f,h){f!==h&&this.isConnected&&$e(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=qe(o,this,(c=Ce(o,this),++c));(f=Ce(r,this))===null||f===void 0||f.unmount(),qe(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 an({base:m},e,l);_=hn(g,e)}catch(g){g instanceof G?Qe(`${t} ${l}: ${g.message} (${g.code})`):Qe(`${t} ${l}: could not reach ${m}.`);return}if(!(p!==Ce(o,this)||!this.isConnected)){if(!_){Qe(`${t} ${l}: the response was not a ${e} snapshot.`);return}qe(r,this,Qt(_,this,{apiUrl:m,theme:v}))}}Te(a,"observedAttributes",[n,"api-url","theme"]),customElements.define(t,a)}function Ir(){tn("widget"),tn("group")}return Ir(),Ie.render=Qt,Ie})({});
37
37
 
38
38
  //# sourceMappingURL=embed.js.map