@squadico/chatbot 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -5
- package/dist/chatbot.global.js +6 -6
- package/dist/chatbot.global.js.map +1 -1
- package/dist/components/ChatbotWidget.d.ts.map +1 -1
- package/dist/element.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/jsx.d.ts +2 -0
- package/dist/jsx.d.ts.map +1 -1
- package/dist/lib/client.d.ts +4 -0
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/useChat.d.ts +4 -1
- package/dist/lib/useChat.d.ts.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +3 -2
- package/dist/react.js.map +1 -1
- package/dist/{src-CN1vDssu.js → src-D4ZbNlbK.js} +193 -169
- package/dist/src-D4ZbNlbK.js.map +1 -0
- package/dist/src-wGegp_8B.cjs +8 -0
- package/dist/src-wGegp_8B.cjs.map +1 -0
- package/dist/types.d.ts +27 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/src-CN1vDssu.js.map +0 -1
- package/dist/src-DvRdkFTu.cjs +0 -8
- package/dist/src-DvRdkFTu.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -120,10 +120,11 @@ All optional. An attribute is a string; object or function values are set as
|
|
|
120
120
|
| `greeting` | translated greeting | First message from the assistant |
|
|
121
121
|
| `placeholder` | translated | Input placeholder |
|
|
122
122
|
| `suggestions` | — | `'["a","b"]'` or `a\|b` |
|
|
123
|
-
| `width` | `min(392px, 100vw)` |
|
|
123
|
+
| `width` | `min(392px, 100vw)` | Panel width |
|
|
124
124
|
| `accent` | black (white in `dark`) | Accent colour: the launcher, the visitor's bubbles and the main buttons. Text on it turns white or dark by itself |
|
|
125
125
|
| `theme` | `light` | `light` \| `dark` \| `auto` |
|
|
126
|
-
| `position` | `bottom-right` | Anchor of the floating button (the sidebar stays on the right)
|
|
126
|
+
| `position` | `bottom-right` | Anchor of the floating button — and of the window with `layout="floating"` (the sidebar stays on the right) |
|
|
127
|
+
| `layout` | `sidebar` | `sidebar` \| `floating`. The sidebar takes the full height of the right edge; `floating` opens a rounded window in the launcher's corner, `width` wide and `--sqc-height` tall (`640px`, never more than the screen allows). Full screen on a phone either way |
|
|
127
128
|
| `open` | absent | Presence = open at mount, for a first visit — a panel the user opened or closed themselves wins |
|
|
128
129
|
| `persist-open` | `true` | The panel stays open (or closed) across a refresh or a page change, for the lifetime of the tab. `persist-open="false"` → the state starts from `open` on every mount |
|
|
129
130
|
| `locale` | browser languages, then `en` | Interface language and date locale, in BCP-47. When absent, `navigator.languages` is read in the user's order of preference. Three languages ship — `en`, `fr`, `es`; anything else falls back to English. The region is only read by `Intl`: `fr-CA` = French copy, Canadian dates |
|
|
@@ -193,7 +194,8 @@ The variables are set on the host element, from the page:
|
|
|
193
194
|
squadico-chatbot {
|
|
194
195
|
--sqc-accent: #2563eb; /* default: black, white in the dark theme */
|
|
195
196
|
--sqc-width: 480px;
|
|
196
|
-
--sqc-
|
|
197
|
+
--sqc-height: 560px; /* floating window only; default 640px */
|
|
198
|
+
--sqc-radius: 12px; /* message bubbles and floating window; default 16px */
|
|
197
199
|
--sqc-z: 9999;
|
|
198
200
|
--sqc-font-family: 'Inter', sans-serif; /* default: Plus Jakarta Sans */
|
|
199
201
|
--sqc-font-heading: 'Inter', sans-serif; /* header, Markdown headings; default: the body family */
|
|
@@ -214,14 +216,41 @@ benefits; otherwise the system fallbacks apply.
|
|
|
214
216
|
|
|
215
217
|
### HTML / CDN
|
|
216
218
|
|
|
219
|
+
The standalone bundle is served from npm by [jsDelivr](https://www.jsdelivr.com)
|
|
220
|
+
and [unpkg](https://unpkg.com) as soon as a version is published — there is
|
|
221
|
+
nothing else to deploy. Add the script, then the tag, anywhere in the page:
|
|
222
|
+
|
|
217
223
|
```html
|
|
218
|
-
<script src="
|
|
224
|
+
<script src="https://cdn.jsdelivr.net/npm/@squadico/chatbot@1.1.0/dist/chatbot.global.js"></script>
|
|
219
225
|
<squadico-chatbot
|
|
220
226
|
embed-key="sq_pub_paste_yours_here"
|
|
221
227
|
context='{"workspaceId":"WS-1"}'
|
|
222
228
|
></squadico-chatbot>
|
|
223
229
|
```
|
|
224
230
|
|
|
231
|
+
unpkg works the same way:
|
|
232
|
+
`https://unpkg.com/@squadico/chatbot@1.1.0/dist/chatbot.global.js`.
|
|
233
|
+
|
|
234
|
+
**Pin the version.** `@1.1.0` never changes, so a release cannot alter a
|
|
235
|
+
customer page. Leaving it out (`@squadico/chatbot/dist/…`) serves the latest
|
|
236
|
+
version, cached by jsDelivr for up to 12 hours; a range such as `@1` follows the
|
|
237
|
+
newest `1.x.y`. Prefer a pinned version in production.
|
|
238
|
+
|
|
239
|
+
Before the page goes live:
|
|
240
|
+
|
|
241
|
+
1. **Embed key** — create the application in Squadico and paste its
|
|
242
|
+
`sq_pub_…` key into `embed-key`.
|
|
243
|
+
2. **Origin** — the page's origin (`https://www.example.com`, no path) has to be
|
|
244
|
+
on the application's allowlist, or the API answers `origin_not_allowed`. It
|
|
245
|
+
also has to be in the API's `CORS_ORIGINS`.
|
|
246
|
+
3. **Content Security Policy** — a site that sets one needs
|
|
247
|
+
`script-src https://cdn.jsdelivr.net` (or `https://unpkg.com`) and
|
|
248
|
+
`connect-src https://api.squadico.com`. The widget loads no font and no
|
|
249
|
+
other asset.
|
|
250
|
+
4. **Check** — the browser console should show no error, and the floating
|
|
251
|
+
button appears at the bottom right. Properties and events are the same as in
|
|
252
|
+
the other integrations (see *Properties and imperative API* and *Events*).
|
|
253
|
+
|
|
225
254
|
### Next.js
|
|
226
255
|
|
|
227
256
|
From a client component (the wrapper already carries `'use client'`):
|
|
@@ -402,11 +431,13 @@ codes a page reacts to rather than just logging:
|
|
|
402
431
|
| `conversation_retired` | The embed key was rotated after this conversation opened | Open a new conversation (the widget does this by itself, and asks the question again) |
|
|
403
432
|
| `identity_not_verified` | The application verifies visitors and the claim had no valid `digest` | Fix the digest on your server (see *Verified visitors*) |
|
|
404
433
|
| `public_rate_limited` | A budget is spent — 429, with a `Retry-After` header | Wait what the header says |
|
|
434
|
+
| `subject_token_needs_verified_identity` | `getSubjectToken` returned a token on a conversation whose `user` was not verified | Send a `digest` with `user` (see *Acting as your signed-in user*) |
|
|
405
435
|
|
|
406
436
|
Three things to watch:
|
|
407
437
|
|
|
408
438
|
- **Auth**: there is none to arrange. The `embed-key` is public and the visitor
|
|
409
|
-
token is handed out by the API
|
|
439
|
+
token is handed out by the API. The one bearer a page may hand over is its own
|
|
440
|
+
user's, for connectors acting as them — see *Acting as your signed-in user*.
|
|
410
441
|
- **Origins**: the page's origin has to be listed on the application in Squadico
|
|
411
442
|
— the panel is a custom element rendered *inline*, so the browser sends the
|
|
412
443
|
host page's own origin. Moving it into an iframe would break that check, and
|
|
@@ -451,6 +482,64 @@ rendered. Nothing else changes: an anonymous visitor still opens a conversation
|
|
|
451
482
|
a verifying application, because requiring *proof* of an identity is not the same
|
|
452
483
|
as requiring one.
|
|
453
484
|
|
|
485
|
+
### Acting as your signed-in user
|
|
486
|
+
|
|
487
|
+
A connector (MCP server) can be set, in the Squadico back office, to act as **the
|
|
488
|
+
user signed in on your site**: the API behind it then sees that user (`sub`), with
|
|
489
|
+
their own rights and context, as if they had made the calls themselves. Your user
|
|
490
|
+
never visits Squadico.
|
|
491
|
+
|
|
492
|
+
How it works — standard OAuth, no vendor assumed:
|
|
493
|
+
|
|
494
|
+
1. Before each message, the panel calls `getSubjectToken()` and sends the token
|
|
495
|
+
your site holds for the user (header `X-Subject-Token`).
|
|
496
|
+
2. Squadico exchanges it at your authorization server for a token naming the same
|
|
497
|
+
user and meant for the connector alone — OAuth 2.0 Token Exchange (RFC 8693), or
|
|
498
|
+
the JWT bearer "on-behalf-of" grant (RFC 7523) for Microsoft Entra ID.
|
|
499
|
+
3. The connector is called with that token. Your token itself is never sent to the
|
|
500
|
+
connector, and never stored.
|
|
501
|
+
|
|
502
|
+
```js
|
|
503
|
+
const chatbot = document.querySelector('squadico-chatbot')
|
|
504
|
+
// Called before every message: return the *current* token, refreshing it first
|
|
505
|
+
// if your auth library needs to. Return null when nobody is signed in.
|
|
506
|
+
chatbot.getSubjectToken = () => auth.getAccessToken()
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
```tsx
|
|
510
|
+
// React
|
|
511
|
+
<SquadicoChatbot embedKey="sq_pub_…" user={user} getSubjectToken={() => auth.getAccessToken()} />
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
Requirements:
|
|
515
|
+
|
|
516
|
+
- **A verified `user`.** The token is only accepted with a `digest` from your server
|
|
517
|
+
(see *Verified visitors*); otherwise the message is refused with
|
|
518
|
+
`subject_token_needs_verified_identity`.
|
|
519
|
+
- **An authorization server that can exchange tokens**, and on it a confidential
|
|
520
|
+
client for Squadico allowed to do so. Its id and secret go in the connector's
|
|
521
|
+
OAuth settings in Squadico; how it exchanges is set beside them — grant,
|
|
522
|
+
`audience`, `scope`, whether the connector's URL is sent as `resource` (RFC 8707),
|
|
523
|
+
HTTP Basic or in-body client authentication. The defaults are plain RFC 8693 with
|
|
524
|
+
HTTP Basic, which most servers accept as they are.
|
|
525
|
+
- **Optionally, the audience your token must carry.** Set it in the connector's
|
|
526
|
+
settings and Squadico refuses, before asking, any token whose `aud` does not name
|
|
527
|
+
it — for authorization servers that exchange any token they issued.
|
|
528
|
+
- **On the connector**, accept tokens addressed to it, and reach the API behind it
|
|
529
|
+
with its own exchange rather than by forwarding the token as is.
|
|
530
|
+
|
|
531
|
+
Step-by-step setup for each identity provider: <https://squadico.com/docs/token-exchange>.
|
|
532
|
+
|
|
533
|
+
Where the usual servers differ:
|
|
534
|
+
|
|
535
|
+
| Authorization server | Grant | Typically set |
|
|
536
|
+
|---|---|---|
|
|
537
|
+
| Keycloak 26.2+ | RFC 8693 | *Standard token exchange* on the Squadico client; an *audience* mapper adding the Squadico client to your site's tokens; `audience` = the connector's client id |
|
|
538
|
+
| Keycloak 23–26.1 | RFC 8693 (preview V1) | start with `--features=token-exchange,admin-fine-grained-authz`; *token-exchange* permission for the Squadico client on the connector's client; `audience` required; required token audience = the Squadico client id (V1 does not check it) |
|
|
539
|
+
| Okta | RFC 8693 | `scope` required; `audience` = the authorization server's audience |
|
|
540
|
+
| Microsoft Entra ID | On-behalf-of (RFC 7523) | `scope` = `api://<connector app>/.default`; untick `resource` |
|
|
541
|
+
| Auth0, Ping, Curity, ForgeRock, Zitadel… | RFC 8693 | per the server's documentation; usually `audience` |
|
|
542
|
+
|
|
454
543
|
### Context: named object or bare id
|
|
455
544
|
|
|
456
545
|
A host object can be named in two ways:
|
|
@@ -497,6 +586,25 @@ registry (and a tag that does not match `package.json`), and checks the bundle
|
|
|
497
586
|
talks to the production API before publishing. It needs an `NPM_TOKEN` secret: an npm automation token allowed to
|
|
498
587
|
publish `@squadico/chatbot`.
|
|
499
588
|
|
|
589
|
+
From a developer machine, `make publish-chatbot` runs the same checks and
|
|
590
|
+
publishes with your own `npm login` (the account needs two-factor authentication
|
|
591
|
+
for writes). `make publish-chatbot DRY_RUN=true` stops before the publish — the
|
|
592
|
+
variable is spelled with an underscore; with a dash, `make` ignores it and
|
|
593
|
+
publishes for real. `make publish-chatbot-ci` runs the workflow instead.
|
|
594
|
+
|
|
595
|
+
### CDN
|
|
596
|
+
|
|
597
|
+
There is no separate CDN deployment: publishing to npm is what makes
|
|
598
|
+
`dist/chatbot.global.js` available on jsDelivr and unpkg, through the `jsdelivr`
|
|
599
|
+
and `unpkg` fields of `package.json`. Once a version is out, check it:
|
|
600
|
+
|
|
601
|
+
```bash
|
|
602
|
+
curl -I https://cdn.jsdelivr.net/npm/@squadico/chatbot@<version>/dist/chatbot.global.js
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
A new version can take a few minutes to show up. A published version is
|
|
606
|
+
immutable on npm, so a mistake is fixed by publishing the next one.
|
|
607
|
+
|
|
500
608
|
The suite runs on vitest + jsdom against the real frame shapes: the HTTP client,
|
|
501
609
|
the conversation's state machine, the composer's picker. `type-check`, `lint` and
|
|
502
610
|
the size budget are guardrails beside it, not instead of it.
|
package/dist/chatbot.global.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var Chatbot=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h={},g=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,t){for(var n in t)e[n]=t[n];return e}function b(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function x(e,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?t.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return S(e,s,i,a,null)}function S(e,t,i,a,o){var s={type:e,props:t,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++r,__i:-1,__u:0};return o==null&&n.vnode!=null&&n.vnode(s),s}function C(e){return e.children}function w(e,t){this.props=e,this.context=t}function T(e,t){if(t==null)return e.__?T(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`?T(e):null}function E(e){if(e.__P&&e.__d){var t=e.__v,r=t.__e,i=[],a=[],o=y({},t);o.__v=t.__v+1,n.vnode&&n.vnode(o),L(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[r]:null,i,r??T(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,R(i,o,a),t.__e=t.__=null,o.__e!=r&&D(o)}}function D(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}),D(e)}function O(e){(!e.__d&&(e.__d=!0)&&i.push(e)&&!k.__r++||a!=n.debounceRendering)&&((a=n.debounceRendering)||o)(k)}function k(){try{for(var e,t=1;i.length;)i.length>t&&i.sort(s),e=i.shift(),t=i.length,E(e)}finally{i.length=k.__r=0}}function A(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,_,v,y=r&&r.__k||g,b=t.length;for(c=j(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||h,p.__i=d,v=L(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&re(f.ref,null,p),u.push(p.ref,p.__c||m,p)),_==null&&m!=null&&(_=m),4&p.__u?(c=M(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=_,c}function j(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=S(null,o,null,null,null):v(o)?o=e.__k[a]=S(C,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=S(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=N(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=T(s)),ie(s,s));return r}function M(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=M(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=T(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function N(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function P(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||_.test(t)?n:n+`px`}function F(e,t,n,r,i){var a,o;n: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||P(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||P(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(d,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n[u]=r[u]:(n[u]=f,e.addEventListener(t,a?m:p,a)):e.removeEventListener(t,a?m:p,a);else{if(i==`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??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function I(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t[l]==null)t[l]=f++;else if(t[l]<r[u])return;return r(n.event?n.event(t):t)}}}function L(e,t,r,i,a,o,s,c,l,u){var d,f,p,m,h,_,x,S,E,D,O,k,j,M,N,P,F=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(l=!!(32&r.__u),o=[c=t.__e=r.__e]),(d=n.__b)&&d(t);n:if(typeof F==`function`){f=s.length;try{if(E=t.props,D=F.prototype&&F.prototype.render,O=(d=F.contextType)&&i[d.__c],k=d?O?O.props.value:d.__:i,r.__c?S=(p=t.__c=r.__c).__=p.__E:(D?t.__c=p=new F(E,k):(t.__c=p=new w(E,k),p.constructor=F,p.render=ae),O&&O.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),D&&p.__s==null&&(p.__s=p.state),D&&F.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=y({},p.__s)),y(p.__s,F.getDerivedStateFromProps(E,p.__s))),h=p.props,_=p.state,p.__v=t,m)D&&F.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),D&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(D&&F.getDerivedStateFromProps==null&&E!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(E,k),t.__v==r.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(E,p.__s,k)){t.__v!=r.__v&&(p.props=E,p.state=p.__s,p.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(e){e&&(e.__=t)}),g.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=T(r);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(E,p.__s,k),D&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,_,x)})}if(p.context=k,p.props=E,p.__P=e,p.__e=!1,j=n.__r,M=0,D)p.state=p.__s,p.__d=!1,j&&j(t),d=p.render(p.props,p.state,p.context),g.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,j&&j(t),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++M<25);p.state=p.__s,p.getChildContext!=null&&(i=y(y({},i),p.getChildContext())),D&&!m&&p.getSnapshotBeforeUpdate!=null&&(x=p.getSnapshotBeforeUpdate(h,_)),N=d!=null&&d.type===C&&d.key==null?te(d.props.children):d,c=A(e,v(N)?N:[N],t,r,i,a,o,s,c,l,u),p.base=t.__e,t.__u&=-161,p.__h.length&&s.push(p),S&&(p.__E=p.__=null)}catch(e){if(s.length=f,t.__v=null,l||o!=null){if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),t.__e=c}else if(o!=null)for(P=o.length;P--;)b(o[P])}else t.__e=r.__e;t.__k??(t.__k=r.__k||[]),e.then||ee(t),n.__e(e,t,r)}}else o==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):c=t.__e=ne(r.__e,t,r,i,a,o,s,l,u);return(d=n.diffed)&&d(t),128&t.__u?void 0:c}function ee(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ee))}function R(e,t,r){for(var i=0;i<r.length;i++)re(r[i],r[++i],r[++i]);n.__c&&n.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){n.__e(e,t.__v)}})}function te(e){return typeof e!=`object`||!e||e.__b>0?e:v(e)?e.map(te):e.constructor===void 0?y({},e):null}function ne(e,r,i,a,o,s,c,l,u){var d,f,p,m,g,_,y,x=i.props||h,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||(o=`http://www.w3.org/1999/xhtml`),s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){e=g,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&(n.__m&&n.__m(r,s),l=!1),s=null}if(C==null)x===S||l&&e.data==S||(e.data=S);else{if(s=C==`textarea`&&S.defaultValue!=null?null:s&&t.call(e.childNodes),!l&&s!=null)for(x={},d=0;d<e.attributes.length;d++)x[(g=e.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||F(e,d,null,g,o);for(d in S)g=S[d],d==`children`?m=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?_=g:d==`checked`?y=g:l&&typeof g!=`function`||x[d]===g||F(e,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),r.__k=[];else if(p&&(e.innerHTML=``),A(r.type==`template`?e.content:e,v(m)?m:[m],r,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&T(i,0),l,u),s!=null)for(d=s.length;d--;)b(s[d]);l&&C!=`textarea`||(d=`value`,C==`progress`&&_==null?e.removeAttribute(`value`):_!=null&&(_!==e[d]||C==`progress`&&!_||C==`option`&&_!=x[d])&&F(e,d,_,x[d],o),d=`checked`,y!=null&&y!=e[d]&&F(e,d,y,x[d],o))}return e}function re(e,t,r){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){n.__e(e,r)}}function ie(e,t,r){var i,a;if(n.unmount&&n.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||re(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){n.__e(e,t)}i.base=i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&ie(i[a],t,r||typeof e.type!=`function`);r||b(e.__e),e.__c=e.__=e.__e=void 0}function ae(e,t,n){return this.constructor(e,n)}function oe(e,r,i){var a,o,s,c;r==document&&(r=document.documentElement),n.__&&n.__(e,r),o=(a=typeof i==`function`)?null:i&&i.__k||r.__k,s=[],c=[],L(r,e=(!a&&i||r).__k=x(C,null,[e]),o||h,h,r.namespaceURI,!a&&i?[i]:o?null:r.firstChild?t.call(r.childNodes):null,s,!a&&i?i:o?o.__e:r.firstChild,a,c),R(s,e,c),e.props.children=null}t=g.slice,n={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},r=0,w.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=y({},this.state);typeof e==`function`&&(e=e(y({},n),this.props)),e&&y(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),O(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),O(this))},w.prototype.render=C,i=[],o=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,s=function(e,t){return e.__v.__b-t.__v.__b},k.__r=0,c=Math.random().toString(8),l=`__d`+c,u=`__a`+c,d=/(PointerCapture)$|Capture$/i,f=0,p=I(!1),m=I(!0);var z,B,se,ce,le=0,ue=[],V=n,de=V.__b,fe=V.__r,pe=V.diffed,me=V.__c,he=V.unmount,ge=V.__;function _e(e,t){V.__h&&V.__h(B,e,le||t),le=0;var n=B.__H||(B.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function H(e){return le=1,ve(Ee,e)}function ve(e,t,n){var r=_e(z++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ee(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=B,!B.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};B.__f=!0;var a=B.shouldComponentUpdate,o=B.componentWillUpdate;B.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},B.shouldComponentUpdate=i}return r.__N||r.__}function U(e,t){var n=_e(z++,3);!V.__s&&Te(n.__H,t)&&(n.__=e,n.u=t,B.__H.__h.push(n))}function ye(e,t){var n=_e(z++,4);!V.__s&&Te(n.__H,t)&&(n.__=e,n.u=t,B.__h.push(n))}function W(e){return le=5,G(function(){return{current:e}},[])}function G(e,t){var n=_e(z++,7);return Te(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function K(e,t){return le=8,G(function(){return e},t)}function be(){for(var e;e=ue.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ce),t.__h.some(we),t.__h=[]}catch(n){t.__h=[],V.__e(n,e.__v)}}}V.__b=function(e){B=null,de&&de(e)},V.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ge&&ge(e,t)},V.__r=function(e){fe&&fe(e),z=0;var t=(B=e.__c).__H;t&&(se===B?(t.__h=[],B.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Ce),t.__h.some(we),t.__h=[],z=0)),se=B},V.diffed=function(e){pe&&pe(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ue.push(t)!==1&&ce===V.requestAnimationFrame||((ce=V.requestAnimationFrame)||Se)(be)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),se=B=null},V.__c=function(e,t){t.some(function(e){try{e.__h.some(Ce),e.__h=e.__h.filter(function(e){return!e.__||we(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],V.__e(n,e.__v)}}),me&&me(e,t)},V.unmount=function(e){he&&he(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Ce(e)}catch(e){t=e}}),n.__H=void 0,t&&V.__e(t,n.__v))};var xe=typeof requestAnimationFrame==`function`;function Se(e){var t,n=function(){clearTimeout(r),xe&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);xe&&(t=requestAnimationFrame(n))}function Ce(e){var t=B,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),B=t}function we(e){var t=B;e.__c=e.__(),B=t}function Te(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ee(e,t){return typeof t==`function`?t(e):t}var De=new Set([`sessionId`]);function Oe(e){if(typeof e==`string`)return e.length>0?{id:e}:void 0;if(!e||typeof e!=`object`||Array.isArray(e))return;let{id:t,name:n}=e;if(typeof t==`string`&&t.length!==0)return typeof n==`string`&&n.length>0?{id:t,name:n}:{id:t}}function ke(e){let t=Oe(e);if(t)return t.name??t.id}function Ae(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function je(e){let t={};for(let[n,r]of Object.entries(e)){if(De.has(n)||!Ae(r)){t[n]=r;continue}let e=Oe(r);e&&(t[`${n}Id`]=e.id,e.name&&(t[`${n}Name`]=e.name))}return t}var Me=`en`,Ne=[`en`,`fr`,`es`],Pe={en:{heading:`Assistant`,subheading:`Squadico`,placeholder:`Ask your question…`,greeting:`Hello! I am your assistant. What would you like to do?`,hint:`The assistant proposes an action; nothing is applied without your confirmation.`,assistant:`Assistant`,typing:`The assistant is writing its answer`,newConversation:`New conversation`,close:`Close the assistant`,closeTitle:`Close`,history:{open:`Conversation history`,menu:`Previous conversations`,loading:`Loading…`,empty:`No previous conversation.`,untitled:`Conversation`},context:{region:`Context sent to the assistant`},approval:{group:`Write confirmation`,approve:`Yes, apply`,reject:`No, cancel`,request:`The agent wants to use {tool}.`,arguments:`With`,edit:`Change…`,correction:`What to change — e.g. “the due date is next Monday”`,correctionLabel:`Correction to make before approving`,send:`Send`},confirm:{group:`Confirmation`,yes:`Yes`,no:`No`,yesValue:`yes`,noValue:`no`},choices:`Suggested options`,handles:{picker:`Agents you can address`,unknown:`Nobody answers to that name here:`,instead:`You can address:`},selection:{group:`Suggested choice`,single:`Pick one option.`,multiple:`Pick one or more options, then validate.`,validate:`Validate`},composer:{label:`Your message`,send:`Send the message`,sendTitle:`Send`,stop:`Stop the answer`,stopTitle:`Stop`,attach:`Attach a file`,attachTitle:`Attach`,remove:`Remove {name}`},attachments:{unsupported:`This kind of file cannot be attached to a message.`,tooLarge:`This file is too large.`,tooMany:`This message already carries as many files as it may.`,unreadable:`This file could not be read.`,failed:`This file could not be attached.`},error:`Something went wrong, the assistant could not answer. Try again in a moment.`,withHuman:`A member of the team will reply to you here.`},fr:{heading:`Assistant`,subheading:`Squadico`,placeholder:`Posez votre question…`,greeting:`Bonjour ! Je suis votre assistant. Que souhaitez-vous faire ?`,hint:`L'assistant propose une action ; rien n'est appliqué sans votre confirmation.`,assistant:`Assistant`,typing:`L'assistant rédige sa réponse`,newConversation:`Nouvelle conversation`,close:`Fermer l'assistant`,closeTitle:`Fermer`,history:{open:`Historique des conversations`,menu:`Conversations précédentes`,loading:`Chargement…`,empty:`Aucune conversation précédente.`,untitled:`Conversation`},context:{region:`Contexte transmis à l'assistant`},approval:{group:`Validation de l'écriture`,approve:`Oui, appliquer`,reject:`Non, annuler`,request:`L'agent souhaite utiliser {tool}.`,arguments:`Avec`,edit:`Modifier…`,correction:`Ce qu'il faut changer — ex. « l'échéance est lundi prochain »`,correctionLabel:`Correction à apporter avant validation`,send:`Envoyer`},confirm:{group:`Confirmation`,yes:`Oui`,no:`Non`,yesValue:`oui`,noValue:`non`},choices:`Options proposées`,handles:{picker:`Agents que vous pouvez adresser`,unknown:`Personne ne répond à ce nom ici :`,instead:`Vous pouvez adresser :`},selection:{group:`Choix proposé`,single:`Sélectionnez une option.`,multiple:`Sélectionnez une ou plusieurs options, puis validez.`,validate:`Valider`},composer:{label:`Votre message`,send:`Envoyer le message`,sendTitle:`Envoyer`,stop:`Interrompre la réponse`,stopTitle:`Interrompre`,attach:`Joindre un fichier`,attachTitle:`Joindre`,remove:`Retirer {name}`},attachments:{unsupported:`Ce format de fichier ne peut pas être joint à un message.`,tooLarge:`Ce fichier est trop volumineux.`,tooMany:`Ce message porte déjà autant de fichiers qu'il le peut.`,unreadable:`Ce fichier n'a pas pu être lu.`,failed:`Impossible de joindre ce fichier.`},error:`Une erreur est survenue, l'assistant n'a pas pu répondre. Réessayez dans un instant.`,withHuman:`Un membre de l'équipe va vous répondre ici.`},es:{heading:`Asistente`,subheading:`Squadico`,placeholder:`Haga su pregunta…`,greeting:`¡Hola! Soy su asistente. ¿Qué desea hacer?`,hint:`El asistente propone una acción; no se aplica nada sin su confirmación.`,assistant:`Asistente`,typing:`El asistente está redactando su respuesta`,newConversation:`Nueva conversación`,close:`Cerrar el asistente`,closeTitle:`Cerrar`,history:{open:`Historial de conversaciones`,menu:`Conversaciones anteriores`,loading:`Cargando…`,empty:`Ninguna conversación anterior.`,untitled:`Conversación`},context:{region:`Contexto enviado al asistente`},approval:{group:`Validación de la escritura`,approve:`Sí, aplicar`,reject:`No, cancelar`,request:`El agente quiere usar {tool}.`,arguments:`Con`,edit:`Modificar…`,correction:`Lo que hay que cambiar — p. ej. «el vencimiento es el lunes»`,correctionLabel:`Corrección antes de validar`,send:`Enviar`},confirm:{group:`Confirmación`,yes:`Sí`,no:`No`,yesValue:`sí`,noValue:`no`},choices:`Opciones propuestas`,handles:{picker:`Agentes a los que puedes dirigirte`,unknown:`Nadie responde a ese nombre aquí:`,instead:`Puedes dirigirte a:`},selection:{group:`Opción propuesta`,single:`Seleccione una opción.`,multiple:`Seleccione una o varias opciones y valide.`,validate:`Validar`},composer:{label:`Su mensaje`,send:`Enviar el mensaje`,sendTitle:`Enviar`,stop:`Interrumpir la respuesta`,stopTitle:`Interrumpir`,attach:`Adjuntar un archivo`,attachTitle:`Adjuntar`,remove:`Quitar {name}`},attachments:{unsupported:`Este tipo de archivo no se puede adjuntar a un mensaje.`,tooLarge:`Este archivo es demasiado grande.`,tooMany:`Este mensaje ya lleva todos los archivos que puede llevar.`,unreadable:`No se ha podido leer este archivo.`,failed:`No se ha podido adjuntar este archivo.`},error:`Se ha producido un error, el asistente no ha podido responder. Inténtelo de nuevo.`,withHuman:`Un miembro del equipo le responderá aquí.`}},Fe={en:`en-GB`,fr:`fr-FR`,es:`es-ES`};function Ie(e){let t=e?.trim().toLowerCase().split(/[-_]/)[0];return t&&t in Pe?t:void 0}function Le(){return typeof navigator>`u`?[]:navigator.languages?.length?navigator.languages:[navigator.language]}function Re(e){let t=e?.trim(),n=(t?[t]:Le()).find(Ie),r=Ie(n)??`en`;return{code:r,tag:n?.includes(`-`)?n:Fe[r],t:Pe[r]}}var ze=`squadico-chatbot:open`;function Be(){try{if(typeof sessionStorage>`u`)return;let e=sessionStorage.getItem(ze);return e===`1`||e!==`0`&&void 0}catch{return}}function Ve(e){try{if(typeof sessionStorage>`u`)return;sessionStorage.setItem(ze,e?`1`:`0`)}catch{}}function He(e,t){return t===!1?e??!1:Be()??e??!1}function Ue(){let e=globalThis.crypto;if(e&&typeof e.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);if(e&&typeof e.getRandomValues==`function`)e.getRandomValues(t);else for(let e=0;e<16;e++)t[e]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=[];for(let e=0;e<16;e++)n.push(t[e].toString(16).padStart(2,`0`));return n.slice(0,4).join(``)+`-`+n.slice(4,6).join(``)+`-`+n.slice(6,8).join(``)+`-`+n.slice(8,10).join(``)+`-`+n.slice(10,16).join(``)}function We(e){"@babel/helpers - typeof";return We=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},We(e)}function Ge(e,t){if(We(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(We(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ke(e){var t=Ge(e,`string`);return We(t)==`symbol`?t:t+``}function qe(e,t,n){return(t=Ke(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Je=`https://api.squadico.com`,Ye=2e4,q=class extends Error{constructor(e,t,n){super(e),qe(this,`status`,void 0),qe(this,`code`,void 0),this.name=`ChatHttpError`,this.status=t,this.code=n}};function Xe(e,t){return`${e.replace(/\/+$/,``)}${t}`}function Ze(e){return{"Content-Type":`application/json`,Accept:`text/event-stream, application/json`,...e?{"X-Visitor-Token":e}:{}}}function Qe(e){if(!e||typeof e!=`object`)return;let{loc:t,msg:n}=e;if(typeof n!=`string`||!n)return;let r=(Array.isArray(t)?t.filter(e=>typeof e==`string`):[]).at(-1);return r&&r!==`body`?`${r}: ${n}`:n}async function $e(e){let t=``,n;try{let r=await e.text();if(r)try{let e=JSON.parse(r),i=e.detail??e.message;if(Array.isArray(i)){let e=i.map(e=>Qe(e)??(typeof e==`string`?e:void 0)).filter(e=>e!==void 0);t=e.length>0?e.join(`, `):r}else t=typeof i==`string`?i:r;n=typeof e.code==`string`?e.code:void 0}catch{t=r}}catch{}return new q(t||`The API answered ${e.status}`,e.status,n)}function et(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.handle!=`string`||!t.handle))return{handle:t.handle,name:typeof t.name==`string`?t.name:t.handle,avatarEmoji:typeof t.avatar_emoji==`string`?t.avatar_emoji:void 0,color:typeof t.color==`string`?t.color:void 0}}function tt(e){return(Array.isArray(e)?e:[]).map(et).filter(e=>e!==void 0)}function nt(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.tool_call_id!=`string`||!t.tool_call_id))return{toolCallId:t.tool_call_id,tool:typeof t.tool==`string`?t.tool:``,arguments:t.arguments&&typeof t.arguments==`object`?t.arguments:{}}}var rt=new Set([`user`,`assistant`]);function it(e){if(typeof e.role!=`string`||!rt.has(e.role)||typeof e.content!=`string`||!e.content)return null;let t=typeof e.created_at==`string`?Date.parse(e.created_at):NaN;return{id:typeof e.id==`string`&&e.id?e.id:Ue(),role:e.role,content:e.content,createdAt:Number.isNaN(t)?Date.now():t,agent:et(e.agent),attachments:at(e.attachments),authorName:e.kind===`human`&&typeof e.author_name==`string`&&e.author_name?e.author_name:void 0}}function at(e){if(!Array.isArray(e))return;let t=e.map(e=>ot(e)).filter(e=>e!==null);return t.length>0?t:void 0}function ot(e){if(!e||typeof e!=`object`)return null;let{id:t,kind:n,filename:r,content_type:i}=e;return typeof t!=`string`||!t||typeof r!=`string`||!r?null:{id:t,kind:n===`image`?`image`:`document`,filename:r,contentType:typeof i==`string`?i:`application/octet-stream`}}async function st(e){let t=await fetch(Xe(e.apiUrl,`/public/applications/${encodeURIComponent(e.embedKey)}/conversations`),{method:`POST`,headers:Ze(),body:JSON.stringify({...e.user?{user:e.user}:{},...e.agent?{agent:e.agent}:{}}),signal:e.signal});if(!t.ok)throw await $e(t);let n=await t.json();if(typeof n.id!=`string`||typeof n.visitor_token!=`string`)throw new q(`The API opened a conversation without an id or a token`);let r=(Array.isArray(n.messages)?n.messages:[]).map(it).filter(e=>e!==null);return{conversationId:n.id,visitorToken:n.visitor_token,agentName:typeof n.agent_name==`string`?n.agent_name:``,agentSlug:typeof n.agent_slug==`string`?n.agent_slug:``,welcomeMessage:typeof n.welcome_message==`string`&&n.welcome_message?n.welcome_message:void 0,messages:r,handles:tt(n.handles),agentHandle:typeof n.agent_handle==`string`&&n.agent_handle?n.agent_handle:void 0,withHuman:typeof n.handling==`string`&&n.handling!==`agents`}}async function ct(e){let t=await fetch(Xe(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}`),{method:`GET`,headers:Ze(e.visitorToken),signal:e.signal});if(!t.ok)throw await $e(t);let n=await t.json();if(typeof n.id!=`string`)throw new q(`The API replayed a conversation without an id`);return{conversationId:n.id,visitorToken:e.visitorToken,agentName:typeof n.agent_name==`string`?n.agent_name:``,agentSlug:typeof n.agent_slug==`string`?n.agent_slug:``,welcomeMessage:typeof n.welcome_message==`string`&&n.welcome_message?n.welcome_message:void 0,messages:(Array.isArray(n.messages)?n.messages:[]).map(it).filter(e=>e!==null),handles:tt(n.handles),agentHandle:typeof n.agent_handle==`string`&&n.agent_handle?n.agent_handle:void 0,withHuman:typeof n.handling==`string`&&n.handling!==`agents`}}async function lt(e){let t=new FormData;t.append(`file`,e.file);let n=await fetch(ft(e),{method:`POST`,headers:{"X-Visitor-Token":e.visitorToken},body:t,signal:e.signal});if(!n.ok)throw await $e(n);let r=ot(await n.json());if(!r)throw new q(`The upload could not be read`,n.status);return r}async function ut(e){let t=await fetch(`${ft(e)}/${encodeURIComponent(e.attachmentId)}`,{method:`DELETE`,headers:{"X-Visitor-Token":e.visitorToken},signal:e.signal});if(!t.ok)throw await $e(t)}async function dt(e){let t=await fetch(`${ft(e)}/${encodeURIComponent(e.attachmentId)}/content`,{headers:{"X-Visitor-Token":e.visitorToken},signal:e.signal});if(!t.ok)throw await $e(t);return t.blob()}function ft(e){return Xe(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/attachments`)}async function pt(e){return ht(Xe(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/messages`),{content:e.message,attachment_ids:e.attachmentIds??[],...e.context&&Object.keys(e.context).length>0?{context:e.context}:{}},e)}async function mt(e){return ht(Xe(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/approvals`),{tool_call_id:e.toolCallId,approved:e.approved},e)}async function ht(e,t,n){let r=await fetch(e,{method:`POST`,headers:Ze(n.visitorToken),body:JSON.stringify(t),signal:n.signal});if(!r.ok)throw await $e(r);if(!r.body)throw new q(`Answer with no stream body`);let i=r.body.getReader(),a=new TextDecoder,o=``,s=``,c=``,l,u,d={answer:``};try{for(;;){let{value:e,done:t}=await i.read();if(t)break;o+=a.decode(e,{stream:!0});let r=o.split(`
|
|
2
|
-
`);o=r.pop()??``;for(let e of r){let t=e.trim();if(!t){s=``;continue}if(t.startsWith(`event:`)){s=t.slice(6).trim();continue}if(!t.startsWith(`data:`))continue;let r=t.slice(5).trim();if(!r)continue;let i;try{i=JSON.parse(r)}catch{continue}s===`token`&&typeof i.text==`string`?(c+=i.text,n.onToken(i.text)):s===`done`?(d.answer=typeof i.content==`string`?i.content:c,d.agent=et(i.agent),typeof i.unknown_handle==`string`&&i.unknown_handle&&(d.unknownHandle=i.unknown_handle,d.offered=tt(i.handles))):s===`handoff`?(typeof i.to_agent_name==`string`&&(u=i.to_agent_name),c=``):s===`escalated`?d.withHuman=!0:s===`held`?(d.held=!0,d.withHuman=!0):s===`approval_required`?d.approval=nt(i):s===`error`&&(l=typeof i.detail==`string`?i.detail:`The turn failed`)}if(l)break}}finally{i.cancel().catch(()=>void 0)}if(l)throw new q(l);return!d.answer&&!d.approval&&(d.answer=c),u&&!d.agent&&(d.authorName=u),d}var gt=`squadico-chatbot:conversation`;function _t(){try{if(typeof sessionStorage>`u`)return;let e=sessionStorage.getItem(gt);if(!e)return;let t=JSON.parse(e);return!t.sessionId||!t.visitorToken||!t.embedKey?void 0:{sessionId:t.sessionId,visitorToken:t.visitorToken,embedKey:t.embedKey,user:typeof t.user==`string`?t.user:void 0}}catch{return}}function vt(e){try{if(typeof sessionStorage>`u`)return;sessionStorage.setItem(gt,JSON.stringify(e))}catch{}}function yt(){try{if(typeof sessionStorage>`u`)return;sessionStorage.removeItem(gt)}catch{}}function bt(e,{embedKey:t,user:n}){return e.embedKey===t&&e.user===n}function xt(e){let t=e instanceof q?e.status:void 0;return t===415?`unsupported`:t===413?`tooLarge`:t===409?`tooMany`:t===422?`unreadable`:`failed`}var St=5e3;function Ct(e){return e instanceof q&&e.code===`conversation_retired`}function wt(e){let[t,n]=H([]),[r,i]=H(!1),[a,o]=H(``),[s,c]=H([]),[l,u]=H(``),[d,f]=H(null),[p,m]=H(!1),[h,g]=H([]),[_,v]=H([]),[y,b]=H(null),x=W(null),S=W(e);S.current=e;let C=W(null),w=W(null),T=W(void 0),E=e.greeting,D=G(()=>E?{id:`greeting`,role:`assistant`,content:E,createdAt:Date.now()}:null,[E]),O=K(e=>{S.current.onEvent?.(e)},[]),k=K((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,...t}:n))},[]),A=K((e,t)=>{let n=e instanceof q?e.status:void 0,r=e instanceof Error?e.message:String(e),i=(S.current.locale??Re(void 0)).t.error;t&&k(t,{content:i,streaming:!1,error:!0}),O({type:`chatbot-error`,message:r,status:n,sessionId:w.current?.sessionId??``}),typeof console<`u`&&console.error(`[squadico-chatbot]`,r)},[O,k]),j=K(async()=>{if(w.current)return w.current;if(C.current)return C.current;let e=S.current;if(!e.embedKey)throw new q(`No embed key: nothing says which application to open`);let t=e.user,r=e.apiUrl??`https://api.squadico.com`,i=e.embedKey,a=r=>{let a={sessionId:r.conversationId,visitorToken:r.visitorToken};return w.current=a,T.current=t?.id,vt({...a,embedKey:i,user:t?.id}),o(r.conversationId),c(r.handles),u(e.agent&&r.agentHandle?r.agentHandle:``),m(!!r.withHuman),r.messages.length>0&&n(e=>[...r.messages,...e]),a},s=()=>st({apiUrl:r,embedKey:i,user:t,agent:e.agent}).then(a),l=_t(),d=l&&bt(l,{embedKey:i,user:t?.id})?ct({apiUrl:r,conversationId:l.sessionId,visitorToken:l.visitorToken}).then(a).catch(()=>(yt(),s())):s();C.current=d;try{return await d}finally{C.current=null}},[]),M=K(()=>{w.current||C.current||j().catch(e=>A(e))},[j,A]),N=K((e,t,{retry:r=!1,carried:a=[]}={})=>{if(x.current)return;let o=new AbortController;x.current=o,i(!0),f(null);let s=Ue();n(t=>[...t,{id:Ue(),role:`user`,content:e,createdAt:Date.now(),attachments:a.length>0?a:void 0},{id:s,role:`assistant`,content:``,createdAt:Date.now(),streaming:!0}]),(async()=>{let i=await j();O({type:`chatbot-message`,role:`user`,content:e,sessionId:i.sessionId});let a=``,c=e=>{a+=e,k(s,{content:a})},l;try{l=await t(i,c,o.signal)}catch(e){if(!Ct(e)||(yt(),w.current=null,C.current=null,!r))throw e;i=await j(),a=``,k(s,{content:``}),l=await t(i,c,o.signal)}if(l.withHuman&&m(!0),l.held){n(e=>e.filter(e=>e.id!==s));return}k(s,{content:l.answer,streaming:!1,agent:l.agent,authorName:l.authorName,approval:l.approval,unknownHandle:l.unknownHandle,offered:l.offered}),f(l.approval??null),O({type:`chatbot-message`,role:`assistant`,content:l.answer,sessionId:i.sessionId,agent:l.agent?.handle})})().catch(e=>{if(o.signal.aborted){k(s,{streaming:!1});return}A(e,s)}).finally(()=>{x.current=null,i(!1)})},[j,O,A,k]),P=K(e=>{let t=e.trim();if(!t&&h.length===0)return;let n=h;g([]),b(null),N(t,(e,r,i)=>pt({apiUrl:S.current.apiUrl??`https://api.squadico.com`,conversationId:e.sessionId,visitorToken:e.visitorToken,message:t,attachmentIds:n.map(e=>e.id),context:S.current.context?je(S.current.context):void 0,onToken:r,signal:i}),{retry:!0,carried:n})},[h,N]),F=K(e=>{b(null),v(t=>[...t,e.name]),j().then(t=>lt({apiUrl:S.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,file:e})).then(e=>g(t=>[...t,e])).catch(e=>b(xt(e))).finally(()=>v(t=>{let n=t.indexOf(e.name);return n<0?t:[...t.slice(0,n),...t.slice(n+1)]}))},[j]),I=K(e=>{g(t=>t.filter(t=>t.id!==e));let t=w.current;t&&ut({apiUrl:S.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,attachmentId:e}).catch(()=>{})},[]),L=K(async e=>{let t=w.current;if(!t)throw new q(`No conversation to read that file from`);return dt({apiUrl:S.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,attachmentId:e})},[]),ee=K((e,t)=>{let n=d;n&&N(t,(t,r,i)=>mt({apiUrl:S.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,toolCallId:n.toolCallId,approved:e,onToken:r,signal:i}))},[d,N]),R=K(()=>{x.current?.abort(),x.current=null,i(!1)},[]),te=K(()=>{x.current?.abort(),x.current=null,w.current=null,C.current=null,T.current=void 0,yt(),i(!1),f(null),m(!1),o(``),u(``),n([]),O({type:`chatbot-reset`,sessionId:``})},[O]),ne=e.humanPollMs??St;U(()=>{if(!p||!a)return;let e=setInterval(()=>{let e=w.current;!e||x.current||ct({apiUrl:S.current.apiUrl??`https://api.squadico.com`,conversationId:e.sessionId,visitorToken:e.visitorToken}).then(e=>{n(e.messages),m(!!e.withHuman)}).catch(()=>{})},ne);return()=>clearInterval(e)},[p,a,ne]);let re=e.user?.id;return U(()=>{w.current&&T.current!==re&&te()},[re,te]),{messages:G(()=>t.length===0&&D?[D]:t,[D,t]),busy:r,sessionId:a,handles:s,addressee:l,approval:d,withHuman:p,start:M,send:P,attachments:h,uploading:_,attachmentError:y,attach:F,detach:I,loadAttachment:L,decide:ee,stop:R,reset:te}}var Tt=0;Array.isArray;function J(e,t,r,i,a,o){t||(t={});var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Tt,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return n.vnode&&n.vnode(u),u}var Et=132,Dt=`image/png,image/jpeg,image/gif,image/webp,application/pdf,.docx,.txt,.md,.csv,.json`,Ot=/^[a-zA-Z0-9_-]*$/;function kt(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`@`);if(r<0||r>0&&!/\s/.test(n[r-1]??``))return null;let i=n.slice(r+1);return Ot.test(i)?{start:r,query:i}:null}function At({placeholder:e,locale:t,busy:n,autoFocus:r,handles:i,addressee:a,attachments:o=[],uploading:s=[],attachmentError:c,onAttach:l,onDetach:u,onSend:d,onStop:f}){let[p,m]=H(``),[h,g]=H(null),[_,v]=H(0),[y,b]=H(!1),x=W(null),S=W(null),w=!!l,T=s.length>0,E=G(()=>{if(!h||!i||i.length===0)return[];let e=h.query.toLowerCase();return i.filter(t=>t.handle.startsWith(e))},[i,h]),D=E.length>0,O=K(()=>{let e=x.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight>Et;e.style.height=`${Math.min(e.scrollHeight,Et)}px`,e.style.overflowY=t?`auto`:`hidden`},[]);U(()=>{r&&x.current?.focus(),O()},[r,O]),U(()=>{a&&(m(e=>e||`@${a} `),requestAnimationFrame(O))},[a,O]);let k=K(e=>{g(kt(e.value,e.selectionStart??e.value.length)),v(0)},[]),A=K(e=>{let t=x.current;if(!t||!h)return;let n=t.selectionStart??t.value.length,r=`${p.slice(0,h.start)}@${e} ${p.slice(n)}`,i=h.start+e.length+2;m(r),g(null),requestAnimationFrame(()=>{t.focus(),t.setSelectionRange(i,i),O()})},[O,h,p]),j=K(e=>{if(!(!l||!e))for(let t of Array.from(e))l(t)},[l]),M=K(()=>{let e=p.trim();!e&&o.length===0||n||T||(d(e),m(``),g(null),requestAnimationFrame(O))},[o.length,n,O,d,p,T]),N=K(e=>{if(D&&!e.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:E.length-1;v(e=>(e+t)%E.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),A((E[_]??E[0]).handle);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),g(null);return}}e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),M())},[_,E,A,D,M]),P=Ye-p.length;return J(`form`,{class:`sqc-composer${y?` sqc-composer--dropping`:``}`,onSubmit:e=>{e.preventDefault(),M()},onDragOver:e=>{w&&(e.preventDefault(),b(!0))},onDragLeave:()=>b(!1),onDrop:e=>{w&&(e.preventDefault(),b(!1),j(e.dataTransfer?.files??null))},children:[(o.length>0||T||c)&&J(`div`,{class:`sqc-attachments`,children:[o.map(e=>J(`span`,{class:`sqc-chip`,"data-kind":e.kind,children:[J(`span`,{class:`sqc-chip__name`,children:e.filename}),J(`button`,{type:`button`,class:`sqc-chip__remove`,"aria-label":t.t.composer.remove.replace(`{name}`,e.filename),onClick:()=>u?.(e.id),children:`×`})]},e.id)),s.map(e=>J(`span`,{class:`sqc-chip sqc-chip--waiting`,children:J(`span`,{class:`sqc-chip__name`,children:e})},e)),c&&J(`p`,{class:`sqc-attachments__error`,role:`status`,children:c})]}),J(`div`,{class:`sqc-composer__field`,children:[D&&J(`ul`,{class:`sqc-mentions`,role:`listbox`,"aria-label":t.t.handles.picker,children:E.map((e,t)=>J(`li`,{role:`option`,"aria-selected":t===_,class:`sqc-mention${t===_?` sqc-mention--active`:``}`,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>v(t),onClick:()=>A(e.handle),children:[J(`span`,{class:`sqc-mention__icon`,"aria-hidden":`true`,children:e.avatarEmoji??`@`}),J(`span`,{class:`sqc-mention__handle`,children:[`@`,e.handle]}),J(`span`,{class:`sqc-mention__name`,children:e.name})]},e.handle))}),J(`textarea`,{ref:x,class:`sqc-composer__input`,rows:1,value:p,placeholder:e,maxLength:Ye,"aria-label":t.t.composer.label,onInput:e=>{m(e.currentTarget.value),k(e.currentTarget),O()},onKeyDown:N,onClick:e=>k(e.currentTarget),onPaste:e=>{let t=e.clipboardData?.files;!w||!t||t.length===0||(e.preventDefault(),j(t))}}),P<=200&&J(`span`,{class:`sqc-composer__count`,"aria-live":`polite`,children:P})]}),w&&J(C,{children:[J(`input`,{ref:S,type:`file`,multiple:!0,accept:Dt,class:`sqc-file-input`,onChange:e=>{j(e.currentTarget.files),e.currentTarget.value=``}}),J(`button`,{type:`button`,class:`sqc-btn sqc-btn--attach`,onClick:()=>S.current?.click(),"aria-label":t.t.composer.attach,title:t.t.composer.attachTitle,children:J(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.9`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:J(`path`,{d:`M21 11.5l-8.8 8.8a5 5 0 01-7.1-7.1l9-9a3.3 3.3 0 014.7 4.7l-9 9a1.6 1.6 0 01-2.3-2.3l8.3-8.3`})})})]}),n?J(`button`,{type:`button`,class:`sqc-btn sqc-btn--stop`,onClick:f,"aria-label":t.t.composer.stop,title:t.t.composer.stopTitle,children:J(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:J(`rect`,{x:`7`,y:`7`,width:`10`,height:`10`,rx:`2`,fill:`currentColor`})})}):J(`button`,{type:`submit`,class:`sqc-btn sqc-btn--send`,disabled:!p.trim()&&o.length===0||T,"aria-label":t.t.composer.send,title:t.t.composer.sendTitle,children:J(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.9`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:J(`path`,{d:`M5 12l14-7-5 14-2.5-5.5L5 12z`})})})]})}var jt={fr:/\br[ée]ponde?z? +«?\s*oui\b/i,en:/\b(?:reply|answer|respond) +[“"']?\s*yes\b/i,es:/\bresponda?e?d? +«?\s*s[íi]\b/i},Mt={fr:[/\b(?:confirmes?[- ]tu|confirmez[- ]vous)\b/i,/\b(?:valides?[- ]tu|validez[- ]vous)\b/i,/\b(?:es[- ]tu s[ûu]re?|[êe]tes[- ]vous s[ûu]re?s?)\b/i,/\b(?:dois[- ]je|puis[- ]je)\b/i,/\b(?:je continue|on continue|on y va|je lance)\b/i,jt.fr],en:[/\bdo you confirm\b/i,/\bdo you (?:want|wish) me to\b/i,/\b(?:shall|should) I\b/i,/\bare you sure\b/i,/\b(?:shall we|should I) (?:proceed|continue|go ahead)\b/i,jt.en],es:[/\b(?:confirmas|confirma|confirm[áa]is)\b/i,/\b(?:validas|valida|valid[áa]is)\b/i,/\best[áa]s? seguro\b/i,/\b(?:contin[úu]o|procedo|lo lanzo|lo hago)\b/i,/\bquieres? que\b/i,jt.es]},Nt=/^\s*(?:[-*•]\s+)?\[[ xX]\]\s+/m;function Pt(e,t=`en`){if(Nt.test(e))return!1;let n=e.split(`
|
|
3
|
-
`).map(e=>e.trim()).filter(Boolean),r=n[n.length-1];return!r||!r.includes(`?`)&&!
|
|
1
|
+
var Chatbot=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h={},g=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,t){for(var n in t)e[n]=t[n];return e}function b(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function x(e,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?t.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return S(e,s,i,a,null)}function S(e,t,i,a,o){var s={type:e,props:t,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++r,__i:-1,__u:0};return o==null&&n.vnode!=null&&n.vnode(s),s}function C(e){return e.children}function w(e,t){this.props=e,this.context=t}function T(e,t){if(t==null)return e.__?T(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`?T(e):null}function E(e){if(e.__P&&e.__d){var t=e.__v,r=t.__e,i=[],a=[],o=y({},t);o.__v=t.__v+1,n.vnode&&n.vnode(o),L(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[r]:null,i,r??T(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,z(i,o,a),t.__e=t.__=null,o.__e!=r&&D(o)}}function D(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}),D(e)}function O(e){(!e.__d&&(e.__d=!0)&&i.push(e)&&!k.__r++||a!=n.debounceRendering)&&((a=n.debounceRendering)||o)(k)}function k(){try{for(var e,t=1;i.length;)i.length>t&&i.sort(s),e=i.shift(),t=i.length,E(e)}finally{i.length=k.__r=0}}function A(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,_,v,y=r&&r.__k||g,b=t.length;for(c=j(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||h,p.__i=d,v=L(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&ne(f.ref,null,p),u.push(p.ref,p.__c||m,p)),_==null&&m!=null&&(_=m),4&p.__u?(c=M(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=_,c}function j(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=S(null,o,null,null,null):v(o)?o=e.__k[a]=S(C,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=S(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=N(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=T(s)),re(s,s));return r}function M(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=M(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=T(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function N(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function P(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||_.test(t)?n:n+`px`}function F(e,t,n,r,i){var a,o;n: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||P(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||P(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(d,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n[u]=r[u]:(n[u]=f,e.addEventListener(t,a?m:p,a)):e.removeEventListener(t,a?m:p,a);else{if(i==`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??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function I(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t[l]==null)t[l]=f++;else if(t[l]<r[u])return;return r(n.event?n.event(t):t)}}}function L(e,t,r,i,a,o,s,c,l,u){var d,f,p,m,h,_,x,S,E,D,O,k,j,M,N,P,F=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(l=!!(32&r.__u),o=[c=t.__e=r.__e]),(d=n.__b)&&d(t);n:if(typeof F==`function`){f=s.length;try{if(E=t.props,D=F.prototype&&F.prototype.render,O=(d=F.contextType)&&i[d.__c],k=d?O?O.props.value:d.__:i,r.__c?S=(p=t.__c=r.__c).__=p.__E:(D?t.__c=p=new F(E,k):(t.__c=p=new w(E,k),p.constructor=F,p.render=ie),O&&O.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),D&&p.__s==null&&(p.__s=p.state),D&&F.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=y({},p.__s)),y(p.__s,F.getDerivedStateFromProps(E,p.__s))),h=p.props,_=p.state,p.__v=t,m)D&&F.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),D&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(D&&F.getDerivedStateFromProps==null&&E!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(E,k),t.__v==r.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(E,p.__s,k)){t.__v!=r.__v&&(p.props=E,p.state=p.__s,p.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(e){e&&(e.__=t)}),g.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=T(r);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(E,p.__s,k),D&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,_,x)})}if(p.context=k,p.props=E,p.__P=e,p.__e=!1,j=n.__r,M=0,D)p.state=p.__s,p.__d=!1,j&&j(t),d=p.render(p.props,p.state,p.context),g.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,j&&j(t),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++M<25);p.state=p.__s,p.getChildContext!=null&&(i=y(y({},i),p.getChildContext())),D&&!m&&p.getSnapshotBeforeUpdate!=null&&(x=p.getSnapshotBeforeUpdate(h,_)),N=d!=null&&d.type===C&&d.key==null?ee(d.props.children):d,c=A(e,v(N)?N:[N],t,r,i,a,o,s,c,l,u),p.base=t.__e,t.__u&=-161,p.__h.length&&s.push(p),S&&(p.__E=p.__=null)}catch(e){if(s.length=f,t.__v=null,l||o!=null){if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),t.__e=c}else if(o!=null)for(P=o.length;P--;)b(o[P])}else t.__e=r.__e;t.__k??(t.__k=r.__k||[]),e.then||R(t),n.__e(e,t,r)}}else o==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):c=t.__e=te(r.__e,t,r,i,a,o,s,l,u);return(d=n.diffed)&&d(t),128&t.__u?void 0:c}function R(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(R))}function z(e,t,r){for(var i=0;i<r.length;i++)ne(r[i],r[++i],r[++i]);n.__c&&n.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){n.__e(e,t.__v)}})}function ee(e){return typeof e!=`object`||!e||e.__b>0?e:v(e)?e.map(ee):e.constructor===void 0?y({},e):null}function te(e,r,i,a,o,s,c,l,u){var d,f,p,m,g,_,y,x=i.props||h,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||(o=`http://www.w3.org/1999/xhtml`),s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){e=g,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&(n.__m&&n.__m(r,s),l=!1),s=null}if(C==null)x===S||l&&e.data==S||(e.data=S);else{if(s=C==`textarea`&&S.defaultValue!=null?null:s&&t.call(e.childNodes),!l&&s!=null)for(x={},d=0;d<e.attributes.length;d++)x[(g=e.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||F(e,d,null,g,o);for(d in S)g=S[d],d==`children`?m=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?_=g:d==`checked`?y=g:l&&typeof g!=`function`||x[d]===g||F(e,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),r.__k=[];else if(p&&(e.innerHTML=``),A(r.type==`template`?e.content:e,v(m)?m:[m],r,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&T(i,0),l,u),s!=null)for(d=s.length;d--;)b(s[d]);l&&C!=`textarea`||(d=`value`,C==`progress`&&_==null?e.removeAttribute(`value`):_!=null&&(_!==e[d]||C==`progress`&&!_||C==`option`&&_!=x[d])&&F(e,d,_,x[d],o),d=`checked`,y!=null&&y!=e[d]&&F(e,d,y,x[d],o))}return e}function ne(e,t,r){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){n.__e(e,r)}}function re(e,t,r){var i,a;if(n.unmount&&n.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||ne(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){n.__e(e,t)}i.base=i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&re(i[a],t,r||typeof e.type!=`function`);r||b(e.__e),e.__c=e.__=e.__e=void 0}function ie(e,t,n){return this.constructor(e,n)}function ae(e,r,i){var a,o,s,c;r==document&&(r=document.documentElement),n.__&&n.__(e,r),o=(a=typeof i==`function`)?null:i&&i.__k||r.__k,s=[],c=[],L(r,e=(!a&&i||r).__k=x(C,null,[e]),o||h,h,r.namespaceURI,!a&&i?[i]:o?null:r.firstChild?t.call(r.childNodes):null,s,!a&&i?i:o?o.__e:r.firstChild,a,c),z(s,e,c),e.props.children=null}t=g.slice,n={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},r=0,w.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=y({},this.state);typeof e==`function`&&(e=e(y({},n),this.props)),e&&y(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),O(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),O(this))},w.prototype.render=C,i=[],o=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,s=function(e,t){return e.__v.__b-t.__v.__b},k.__r=0,c=Math.random().toString(8),l=`__d`+c,u=`__a`+c,d=/(PointerCapture)$|Capture$/i,f=0,p=I(!1),m=I(!0);var oe,B,se,ce,le=0,ue=[],V=n,de=V.__b,fe=V.__r,pe=V.diffed,me=V.__c,he=V.unmount,ge=V.__;function _e(e,t){V.__h&&V.__h(B,e,le||t),le=0;var n=B.__H||(B.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function H(e){return le=1,ve(Ee,e)}function ve(e,t,n){var r=_e(oe++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ee(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=B,!B.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};B.__f=!0;var a=B.shouldComponentUpdate,o=B.componentWillUpdate;B.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},B.shouldComponentUpdate=i}return r.__N||r.__}function U(e,t){var n=_e(oe++,3);!V.__s&&Te(n.__H,t)&&(n.__=e,n.u=t,B.__H.__h.push(n))}function ye(e,t){var n=_e(oe++,4);!V.__s&&Te(n.__H,t)&&(n.__=e,n.u=t,B.__h.push(n))}function W(e){return le=5,G(function(){return{current:e}},[])}function G(e,t){var n=_e(oe++,7);return Te(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function K(e,t){return le=8,G(function(){return e},t)}function be(){for(var e;e=ue.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ce),t.__h.some(we),t.__h=[]}catch(n){t.__h=[],V.__e(n,e.__v)}}}V.__b=function(e){B=null,de&&de(e)},V.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ge&&ge(e,t)},V.__r=function(e){fe&&fe(e),oe=0;var t=(B=e.__c).__H;t&&(se===B?(t.__h=[],B.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Ce),t.__h.some(we),t.__h=[],oe=0)),se=B},V.diffed=function(e){pe&&pe(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ue.push(t)!==1&&ce===V.requestAnimationFrame||((ce=V.requestAnimationFrame)||Se)(be)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),se=B=null},V.__c=function(e,t){t.some(function(e){try{e.__h.some(Ce),e.__h=e.__h.filter(function(e){return!e.__||we(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],V.__e(n,e.__v)}}),me&&me(e,t)},V.unmount=function(e){he&&he(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Ce(e)}catch(e){t=e}}),n.__H=void 0,t&&V.__e(t,n.__v))};var xe=typeof requestAnimationFrame==`function`;function Se(e){var t,n=function(){clearTimeout(r),xe&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);xe&&(t=requestAnimationFrame(n))}function Ce(e){var t=B,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),B=t}function we(e){var t=B;e.__c=e.__(),B=t}function Te(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ee(e,t){return typeof t==`function`?t(e):t}var De=new Set([`sessionId`]);function Oe(e){if(typeof e==`string`)return e.length>0?{id:e}:void 0;if(!e||typeof e!=`object`||Array.isArray(e))return;let{id:t,name:n}=e;if(typeof t==`string`&&t.length!==0)return typeof n==`string`&&n.length>0?{id:t,name:n}:{id:t}}function ke(e){let t=Oe(e);if(t)return t.name??t.id}function Ae(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function je(e){let t={};for(let[n,r]of Object.entries(e)){if(De.has(n)||!Ae(r)){t[n]=r;continue}let e=Oe(r);e&&(t[`${n}Id`]=e.id,e.name&&(t[`${n}Name`]=e.name))}return t}var Me=`en`,Ne=[`en`,`fr`,`es`],Pe={en:{heading:`Assistant`,subheading:`Squadico`,placeholder:`Ask your question…`,greeting:`Hello! I am your assistant. What would you like to do?`,hint:`The assistant proposes an action; nothing is applied without your confirmation.`,assistant:`Assistant`,typing:`The assistant is writing its answer`,newConversation:`New conversation`,close:`Close the assistant`,closeTitle:`Close`,history:{open:`Conversation history`,menu:`Previous conversations`,loading:`Loading…`,empty:`No previous conversation.`,untitled:`Conversation`},context:{region:`Context sent to the assistant`},approval:{group:`Write confirmation`,approve:`Yes, apply`,reject:`No, cancel`,request:`The agent wants to use {tool}.`,arguments:`With`,edit:`Change…`,correction:`What to change — e.g. “the due date is next Monday”`,correctionLabel:`Correction to make before approving`,send:`Send`},confirm:{group:`Confirmation`,yes:`Yes`,no:`No`,yesValue:`yes`,noValue:`no`},choices:`Suggested options`,handles:{picker:`Agents you can address`,unknown:`Nobody answers to that name here:`,instead:`You can address:`},selection:{group:`Suggested choice`,single:`Pick one option.`,multiple:`Pick one or more options, then validate.`,validate:`Validate`},composer:{label:`Your message`,send:`Send the message`,sendTitle:`Send`,stop:`Stop the answer`,stopTitle:`Stop`,attach:`Attach a file`,attachTitle:`Attach`,remove:`Remove {name}`},attachments:{unsupported:`This kind of file cannot be attached to a message.`,tooLarge:`This file is too large.`,tooMany:`This message already carries as many files as it may.`,unreadable:`This file could not be read.`,failed:`This file could not be attached.`},error:`Something went wrong, the assistant could not answer. Try again in a moment.`,withHuman:`A member of the team will reply to you here.`},fr:{heading:`Assistant`,subheading:`Squadico`,placeholder:`Posez votre question…`,greeting:`Bonjour ! Je suis votre assistant. Que souhaitez-vous faire ?`,hint:`L'assistant propose une action ; rien n'est appliqué sans votre confirmation.`,assistant:`Assistant`,typing:`L'assistant rédige sa réponse`,newConversation:`Nouvelle conversation`,close:`Fermer l'assistant`,closeTitle:`Fermer`,history:{open:`Historique des conversations`,menu:`Conversations précédentes`,loading:`Chargement…`,empty:`Aucune conversation précédente.`,untitled:`Conversation`},context:{region:`Contexte transmis à l'assistant`},approval:{group:`Validation de l'écriture`,approve:`Oui, appliquer`,reject:`Non, annuler`,request:`L'agent souhaite utiliser {tool}.`,arguments:`Avec`,edit:`Modifier…`,correction:`Ce qu'il faut changer — ex. « l'échéance est lundi prochain »`,correctionLabel:`Correction à apporter avant validation`,send:`Envoyer`},confirm:{group:`Confirmation`,yes:`Oui`,no:`Non`,yesValue:`oui`,noValue:`non`},choices:`Options proposées`,handles:{picker:`Agents que vous pouvez adresser`,unknown:`Personne ne répond à ce nom ici :`,instead:`Vous pouvez adresser :`},selection:{group:`Choix proposé`,single:`Sélectionnez une option.`,multiple:`Sélectionnez une ou plusieurs options, puis validez.`,validate:`Valider`},composer:{label:`Votre message`,send:`Envoyer le message`,sendTitle:`Envoyer`,stop:`Interrompre la réponse`,stopTitle:`Interrompre`,attach:`Joindre un fichier`,attachTitle:`Joindre`,remove:`Retirer {name}`},attachments:{unsupported:`Ce format de fichier ne peut pas être joint à un message.`,tooLarge:`Ce fichier est trop volumineux.`,tooMany:`Ce message porte déjà autant de fichiers qu'il le peut.`,unreadable:`Ce fichier n'a pas pu être lu.`,failed:`Impossible de joindre ce fichier.`},error:`Une erreur est survenue, l'assistant n'a pas pu répondre. Réessayez dans un instant.`,withHuman:`Un membre de l'équipe va vous répondre ici.`},es:{heading:`Asistente`,subheading:`Squadico`,placeholder:`Haga su pregunta…`,greeting:`¡Hola! Soy su asistente. ¿Qué desea hacer?`,hint:`El asistente propone una acción; no se aplica nada sin su confirmación.`,assistant:`Asistente`,typing:`El asistente está redactando su respuesta`,newConversation:`Nueva conversación`,close:`Cerrar el asistente`,closeTitle:`Cerrar`,history:{open:`Historial de conversaciones`,menu:`Conversaciones anteriores`,loading:`Cargando…`,empty:`Ninguna conversación anterior.`,untitled:`Conversación`},context:{region:`Contexto enviado al asistente`},approval:{group:`Validación de la escritura`,approve:`Sí, aplicar`,reject:`No, cancelar`,request:`El agente quiere usar {tool}.`,arguments:`Con`,edit:`Modificar…`,correction:`Lo que hay que cambiar — p. ej. «el vencimiento es el lunes»`,correctionLabel:`Corrección antes de validar`,send:`Enviar`},confirm:{group:`Confirmación`,yes:`Sí`,no:`No`,yesValue:`sí`,noValue:`no`},choices:`Opciones propuestas`,handles:{picker:`Agentes a los que puedes dirigirte`,unknown:`Nadie responde a ese nombre aquí:`,instead:`Puedes dirigirte a:`},selection:{group:`Opción propuesta`,single:`Seleccione una opción.`,multiple:`Seleccione una o varias opciones y valide.`,validate:`Validar`},composer:{label:`Su mensaje`,send:`Enviar el mensaje`,sendTitle:`Enviar`,stop:`Interrumpir la respuesta`,stopTitle:`Interrumpir`,attach:`Adjuntar un archivo`,attachTitle:`Adjuntar`,remove:`Quitar {name}`},attachments:{unsupported:`Este tipo de archivo no se puede adjuntar a un mensaje.`,tooLarge:`Este archivo es demasiado grande.`,tooMany:`Este mensaje ya lleva todos los archivos que puede llevar.`,unreadable:`No se ha podido leer este archivo.`,failed:`No se ha podido adjuntar este archivo.`},error:`Se ha producido un error, el asistente no ha podido responder. Inténtelo de nuevo.`,withHuman:`Un miembro del equipo le responderá aquí.`}},Fe={en:`en-GB`,fr:`fr-FR`,es:`es-ES`};function Ie(e){let t=e?.trim().toLowerCase().split(/[-_]/)[0];return t&&t in Pe?t:void 0}function Le(){return typeof navigator>`u`?[]:navigator.languages?.length?navigator.languages:[navigator.language]}function Re(e){let t=e?.trim(),n=(t?[t]:Le()).find(Ie),r=Ie(n)??`en`;return{code:r,tag:n?.includes(`-`)?n:Fe[r],t:Pe[r]}}var ze=`squadico-chatbot:open`;function Be(){try{if(typeof sessionStorage>`u`)return;let e=sessionStorage.getItem(ze);return e===`1`||e!==`0`&&void 0}catch{return}}function Ve(e){try{if(typeof sessionStorage>`u`)return;sessionStorage.setItem(ze,e?`1`:`0`)}catch{}}function He(e,t){return t===!1?e??!1:Be()??e??!1}function Ue(){let e=globalThis.crypto;if(e&&typeof e.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);if(e&&typeof e.getRandomValues==`function`)e.getRandomValues(t);else for(let e=0;e<16;e++)t[e]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=[];for(let e=0;e<16;e++)n.push(t[e].toString(16).padStart(2,`0`));return n.slice(0,4).join(``)+`-`+n.slice(4,6).join(``)+`-`+n.slice(6,8).join(``)+`-`+n.slice(8,10).join(``)+`-`+n.slice(10,16).join(``)}function We(e){"@babel/helpers - typeof";return We=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},We(e)}function Ge(e,t){if(We(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(We(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ke(e){var t=Ge(e,`string`);return We(t)==`symbol`?t:t+``}function qe(e,t,n){return(t=Ke(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Je=`https://api.squadico.com`,Ye=2e4,q=class extends Error{constructor(e,t,n){super(e),qe(this,`status`,void 0),qe(this,`code`,void 0),this.name=`ChatHttpError`,this.status=t,this.code=n}};function Xe(e,t){return`${e.replace(/\/+$/,``)}${t}`}function Ze(e,t){return{"Content-Type":`application/json`,Accept:`text/event-stream, application/json`,...e?{"X-Visitor-Token":e}:{},...t?{"X-Subject-Token":t}:{}}}function Qe(e){if(!e||typeof e!=`object`)return;let{loc:t,msg:n}=e;if(typeof n!=`string`||!n)return;let r=(Array.isArray(t)?t.filter(e=>typeof e==`string`):[]).at(-1);return r&&r!==`body`?`${r}: ${n}`:n}async function $e(e){let t=``,n;try{let r=await e.text();if(r)try{let e=JSON.parse(r),i=e.detail??e.message;if(Array.isArray(i)){let e=i.map(e=>Qe(e)??(typeof e==`string`?e:void 0)).filter(e=>e!==void 0);t=e.length>0?e.join(`, `):r}else t=typeof i==`string`?i:r;n=typeof e.code==`string`?e.code:void 0}catch{t=r}}catch{}return new q(t||`The API answered ${e.status}`,e.status,n)}function et(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.handle!=`string`||!t.handle))return{handle:t.handle,name:typeof t.name==`string`?t.name:t.handle,avatarEmoji:typeof t.avatar_emoji==`string`?t.avatar_emoji:void 0,color:typeof t.color==`string`?t.color:void 0}}function tt(e){return(Array.isArray(e)?e:[]).map(et).filter(e=>e!==void 0)}function nt(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.tool_call_id!=`string`||!t.tool_call_id))return{toolCallId:t.tool_call_id,tool:typeof t.tool==`string`?t.tool:``,arguments:t.arguments&&typeof t.arguments==`object`?t.arguments:{}}}var rt=new Set([`user`,`assistant`]);function it(e){if(typeof e.role!=`string`||!rt.has(e.role)||typeof e.content!=`string`||!e.content)return null;let t=typeof e.created_at==`string`?Date.parse(e.created_at):NaN;return{id:typeof e.id==`string`&&e.id?e.id:Ue(),role:e.role,content:e.content,createdAt:Number.isNaN(t)?Date.now():t,agent:et(e.agent),attachments:at(e.attachments),authorName:e.kind===`human`&&typeof e.author_name==`string`&&e.author_name?e.author_name:void 0}}function at(e){if(!Array.isArray(e))return;let t=e.map(e=>ot(e)).filter(e=>e!==null);return t.length>0?t:void 0}function ot(e){if(!e||typeof e!=`object`)return null;let{id:t,kind:n,filename:r,content_type:i}=e;return typeof t!=`string`||!t||typeof r!=`string`||!r?null:{id:t,kind:n===`image`?`image`:`document`,filename:r,contentType:typeof i==`string`?i:`application/octet-stream`}}async function st(e){let t=await fetch(Xe(e.apiUrl,`/public/applications/${encodeURIComponent(e.embedKey)}/conversations`),{method:`POST`,headers:Ze(),body:JSON.stringify({...e.user?{user:e.user}:{},...e.agent?{agent:e.agent}:{}}),signal:e.signal});if(!t.ok)throw await $e(t);let n=await t.json();if(typeof n.id!=`string`||typeof n.visitor_token!=`string`)throw new q(`The API opened a conversation without an id or a token`);let r=(Array.isArray(n.messages)?n.messages:[]).map(it).filter(e=>e!==null);return{conversationId:n.id,visitorToken:n.visitor_token,agentName:typeof n.agent_name==`string`?n.agent_name:``,agentSlug:typeof n.agent_slug==`string`?n.agent_slug:``,welcomeMessage:typeof n.welcome_message==`string`&&n.welcome_message?n.welcome_message:void 0,messages:r,handles:tt(n.handles),agentHandle:typeof n.agent_handle==`string`&&n.agent_handle?n.agent_handle:void 0,withHuman:typeof n.handling==`string`&&n.handling!==`agents`}}async function ct(e){let t=await fetch(Xe(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}`),{method:`GET`,headers:Ze(e.visitorToken),signal:e.signal});if(!t.ok)throw await $e(t);let n=await t.json();if(typeof n.id!=`string`)throw new q(`The API replayed a conversation without an id`);return{conversationId:n.id,visitorToken:e.visitorToken,agentName:typeof n.agent_name==`string`?n.agent_name:``,agentSlug:typeof n.agent_slug==`string`?n.agent_slug:``,welcomeMessage:typeof n.welcome_message==`string`&&n.welcome_message?n.welcome_message:void 0,messages:(Array.isArray(n.messages)?n.messages:[]).map(it).filter(e=>e!==null),handles:tt(n.handles),agentHandle:typeof n.agent_handle==`string`&&n.agent_handle?n.agent_handle:void 0,withHuman:typeof n.handling==`string`&&n.handling!==`agents`}}async function lt(e){let t=new FormData;t.append(`file`,e.file);let n=await fetch(ft(e),{method:`POST`,headers:{"X-Visitor-Token":e.visitorToken},body:t,signal:e.signal});if(!n.ok)throw await $e(n);let r=ot(await n.json());if(!r)throw new q(`The upload could not be read`,n.status);return r}async function ut(e){let t=await fetch(`${ft(e)}/${encodeURIComponent(e.attachmentId)}`,{method:`DELETE`,headers:{"X-Visitor-Token":e.visitorToken},signal:e.signal});if(!t.ok)throw await $e(t)}async function dt(e){let t=await fetch(`${ft(e)}/${encodeURIComponent(e.attachmentId)}/content`,{headers:{"X-Visitor-Token":e.visitorToken},signal:e.signal});if(!t.ok)throw await $e(t);return t.blob()}function ft(e){return Xe(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/attachments`)}async function pt(e){return ht(Xe(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/messages`),{content:e.message,attachment_ids:e.attachmentIds??[],...e.context&&Object.keys(e.context).length>0?{context:e.context}:{}},e)}async function mt(e){return ht(Xe(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/approvals`),{tool_call_id:e.toolCallId,approved:e.approved},e)}async function ht(e,t,n){let r=await fetch(e,{method:`POST`,headers:Ze(n.visitorToken,n.subjectToken),body:JSON.stringify(t),signal:n.signal});if(!r.ok)throw await $e(r);if(!r.body)throw new q(`Answer with no stream body`);let i=r.body.getReader(),a=new TextDecoder,o=``,s=``,c=``,l,u,d={answer:``};try{for(;;){let{value:e,done:t}=await i.read();if(t)break;o+=a.decode(e,{stream:!0});let r=o.split(`
|
|
2
|
+
`);o=r.pop()??``;for(let e of r){let t=e.trim();if(!t){s=``;continue}if(t.startsWith(`event:`)){s=t.slice(6).trim();continue}if(!t.startsWith(`data:`))continue;let r=t.slice(5).trim();if(!r)continue;let i;try{i=JSON.parse(r)}catch{continue}s===`token`&&typeof i.text==`string`?(c+=i.text,n.onToken(i.text)):s===`done`?(d.answer=typeof i.content==`string`?i.content:c,d.agent=et(i.agent),typeof i.unknown_handle==`string`&&i.unknown_handle&&(d.unknownHandle=i.unknown_handle,d.offered=tt(i.handles))):s===`handoff`?(typeof i.to_agent_name==`string`&&(u=i.to_agent_name),c=``):s===`escalated`?d.withHuman=!0:s===`held`?(d.held=!0,d.withHuman=!0):s===`approval_required`?d.approval=nt(i):s===`error`&&(l=typeof i.detail==`string`?i.detail:`The turn failed`)}if(l)break}}finally{i.cancel().catch(()=>void 0)}if(l)throw new q(l);return!d.answer&&!d.approval&&(d.answer=c),u&&!d.agent&&(d.authorName=u),d}var gt=`squadico-chatbot:conversation`;function _t(){try{if(typeof sessionStorage>`u`)return;let e=sessionStorage.getItem(gt);if(!e)return;let t=JSON.parse(e);return!t.sessionId||!t.visitorToken||!t.embedKey?void 0:{sessionId:t.sessionId,visitorToken:t.visitorToken,embedKey:t.embedKey,user:typeof t.user==`string`?t.user:void 0}}catch{return}}function vt(e){try{if(typeof sessionStorage>`u`)return;sessionStorage.setItem(gt,JSON.stringify(e))}catch{}}function yt(){try{if(typeof sessionStorage>`u`)return;sessionStorage.removeItem(gt)}catch{}}function bt(e,{embedKey:t,user:n}){return e.embedKey===t&&e.user===n}async function xt(e){if(e)try{return await e()||void 0}catch{return}}function St(e){let t=e instanceof q?e.status:void 0;return t===415?`unsupported`:t===413?`tooLarge`:t===409?`tooMany`:t===422?`unreadable`:`failed`}var Ct=5e3;function wt(e){return e instanceof q&&e.code===`conversation_retired`}function Tt(e){let[t,n]=H([]),[r,i]=H(!1),[a,o]=H(``),[s,c]=H([]),[l,u]=H(``),[d,f]=H(null),[p,m]=H(!1),[h,g]=H([]),[_,v]=H([]),[y,b]=H(null),x=W(null),S=W(e);S.current=e;let C=W(null),w=W(null),T=W(void 0),E=e.greeting,D=G(()=>E?{id:`greeting`,role:`assistant`,content:E,createdAt:Date.now()}:null,[E]),O=K(e=>{S.current.onEvent?.(e)},[]),k=K((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,...t}:n))},[]),A=K((e,t)=>{let n=e instanceof q?e.status:void 0,r=e instanceof Error?e.message:String(e),i=(S.current.locale??Re(void 0)).t.error;t&&k(t,{content:i,streaming:!1,error:!0}),O({type:`chatbot-error`,message:r,status:n,sessionId:w.current?.sessionId??``}),typeof console<`u`&&console.error(`[squadico-chatbot]`,r)},[O,k]),j=K(async()=>{if(w.current)return w.current;if(C.current)return C.current;let e=S.current;if(!e.embedKey)throw new q(`No embed key: nothing says which application to open`);let t=e.user,r=e.apiUrl??`https://api.squadico.com`,i=e.embedKey,a=r=>{let a={sessionId:r.conversationId,visitorToken:r.visitorToken};return w.current=a,T.current=t?.id,vt({...a,embedKey:i,user:t?.id}),o(r.conversationId),c(r.handles),u(e.agent&&r.agentHandle?r.agentHandle:``),m(!!r.withHuman),r.messages.length>0&&n(e=>[...r.messages,...e]),a},s=()=>st({apiUrl:r,embedKey:i,user:t,agent:e.agent}).then(a),l=_t(),d=l&&bt(l,{embedKey:i,user:t?.id})?ct({apiUrl:r,conversationId:l.sessionId,visitorToken:l.visitorToken}).then(a).catch(()=>(yt(),s())):s();C.current=d;try{return await d}finally{C.current=null}},[]),M=K(()=>{w.current||C.current||j().catch(e=>A(e))},[j,A]),N=K((e,t,{retry:r=!1,carried:a=[]}={})=>{if(x.current)return;let o=new AbortController;x.current=o,i(!0),f(null);let s=Ue();n(t=>[...t,{id:Ue(),role:`user`,content:e,createdAt:Date.now(),attachments:a.length>0?a:void 0},{id:s,role:`assistant`,content:``,createdAt:Date.now(),streaming:!0}]),(async()=>{let i=await j();O({type:`chatbot-message`,role:`user`,content:e,sessionId:i.sessionId});let a=``,c=e=>{a+=e,k(s,{content:a})},l;try{l=await t(i,c,o.signal)}catch(e){if(!wt(e)||(yt(),w.current=null,C.current=null,!r))throw e;i=await j(),a=``,k(s,{content:``}),l=await t(i,c,o.signal)}if(l.withHuman&&m(!0),l.held){n(e=>e.filter(e=>e.id!==s));return}k(s,{content:l.answer,streaming:!1,agent:l.agent,authorName:l.authorName,approval:l.approval,unknownHandle:l.unknownHandle,offered:l.offered}),f(l.approval??null),O({type:`chatbot-message`,role:`assistant`,content:l.answer,sessionId:i.sessionId,agent:l.agent?.handle})})().catch(e=>{if(o.signal.aborted){k(s,{streaming:!1});return}A(e,s)}).finally(()=>{x.current=null,i(!1)})},[j,O,A,k]),P=K(e=>{let t=e.trim();if(!t&&h.length===0)return;let n=h;g([]),b(null),N(t,async(e,r,i)=>pt({subjectToken:await xt(S.current.getSubjectToken),apiUrl:S.current.apiUrl??`https://api.squadico.com`,conversationId:e.sessionId,visitorToken:e.visitorToken,message:t,attachmentIds:n.map(e=>e.id),context:S.current.context?je(S.current.context):void 0,onToken:r,signal:i}),{retry:!0,carried:n})},[h,N]),F=K(e=>{b(null),v(t=>[...t,e.name]),j().then(t=>lt({apiUrl:S.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,file:e})).then(e=>g(t=>[...t,e])).catch(e=>b(St(e))).finally(()=>v(t=>{let n=t.indexOf(e.name);return n<0?t:[...t.slice(0,n),...t.slice(n+1)]}))},[j]),I=K(e=>{g(t=>t.filter(t=>t.id!==e));let t=w.current;t&&ut({apiUrl:S.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,attachmentId:e}).catch(()=>{})},[]),L=K(async e=>{let t=w.current;if(!t)throw new q(`No conversation to read that file from`);return dt({apiUrl:S.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,attachmentId:e})},[]),R=K((e,t)=>{let n=d;n&&N(t,async(t,r,i)=>mt({subjectToken:await xt(S.current.getSubjectToken),apiUrl:S.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,toolCallId:n.toolCallId,approved:e,onToken:r,signal:i}))},[d,N]),z=K(()=>{x.current?.abort(),x.current=null,i(!1)},[]),ee=K(()=>{x.current?.abort(),x.current=null,w.current=null,C.current=null,T.current=void 0,yt(),i(!1),f(null),m(!1),o(``),u(``),n([]),O({type:`chatbot-reset`,sessionId:``})},[O]),te=e.humanPollMs??Ct;U(()=>{if(!p||!a)return;let e=setInterval(()=>{let e=w.current;!e||x.current||ct({apiUrl:S.current.apiUrl??`https://api.squadico.com`,conversationId:e.sessionId,visitorToken:e.visitorToken}).then(e=>{n(e.messages),m(!!e.withHuman)}).catch(()=>{})},te);return()=>clearInterval(e)},[p,a,te]);let ne=e.user?.id;return U(()=>{w.current&&T.current!==ne&&ee()},[ne,ee]),{messages:G(()=>t.length===0&&D?[D]:t,[D,t]),busy:r,sessionId:a,handles:s,addressee:l,approval:d,withHuman:p,start:M,send:P,attachments:h,uploading:_,attachmentError:y,attach:F,detach:I,loadAttachment:L,decide:R,stop:z,reset:ee}}var Et=0;Array.isArray;function J(e,t,r,i,a,o){t||(t={});var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Et,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return n.vnode&&n.vnode(u),u}var Dt=132,Ot=`image/png,image/jpeg,image/gif,image/webp,application/pdf,.docx,.txt,.md,.csv,.json`,kt=/^[a-zA-Z0-9_-]*$/;function At(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`@`);if(r<0||r>0&&!/\s/.test(n[r-1]??``))return null;let i=n.slice(r+1);return kt.test(i)?{start:r,query:i}:null}function jt({placeholder:e,locale:t,busy:n,autoFocus:r,handles:i,addressee:a,attachments:o=[],uploading:s=[],attachmentError:c,onAttach:l,onDetach:u,onSend:d,onStop:f}){let[p,m]=H(``),[h,g]=H(null),[_,v]=H(0),[y,b]=H(!1),x=W(null),S=W(null),w=!!l,T=s.length>0,E=G(()=>{if(!h||!i||i.length===0)return[];let e=h.query.toLowerCase();return i.filter(t=>t.handle.startsWith(e))},[i,h]),D=E.length>0,O=K(()=>{let e=x.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight>Dt;e.style.height=`${Math.min(e.scrollHeight,Dt)}px`,e.style.overflowY=t?`auto`:`hidden`},[]);U(()=>{r&&x.current?.focus(),O()},[r,O]),U(()=>{a&&(m(e=>e||`@${a} `),requestAnimationFrame(O))},[a,O]);let k=K(e=>{g(At(e.value,e.selectionStart??e.value.length)),v(0)},[]),A=K(e=>{let t=x.current;if(!t||!h)return;let n=t.selectionStart??t.value.length,r=`${p.slice(0,h.start)}@${e} ${p.slice(n)}`,i=h.start+e.length+2;m(r),g(null),requestAnimationFrame(()=>{t.focus(),t.setSelectionRange(i,i),O()})},[O,h,p]),j=K(e=>{if(!(!l||!e))for(let t of Array.from(e))l(t)},[l]),M=K(()=>{let e=p.trim();!e&&o.length===0||n||T||(d(e),m(``),g(null),requestAnimationFrame(O))},[o.length,n,O,d,p,T]),N=K(e=>{if(D&&!e.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:E.length-1;v(e=>(e+t)%E.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),A((E[_]??E[0]).handle);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),g(null);return}}e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),M())},[_,E,A,D,M]),P=Ye-p.length;return J(`form`,{class:`sqc-composer${y?` sqc-composer--dropping`:``}`,onSubmit:e=>{e.preventDefault(),M()},onDragOver:e=>{w&&(e.preventDefault(),b(!0))},onDragLeave:()=>b(!1),onDrop:e=>{w&&(e.preventDefault(),b(!1),j(e.dataTransfer?.files??null))},children:[(o.length>0||T||c)&&J(`div`,{class:`sqc-attachments`,children:[o.map(e=>J(`span`,{class:`sqc-chip`,"data-kind":e.kind,children:[J(`span`,{class:`sqc-chip__name`,children:e.filename}),J(`button`,{type:`button`,class:`sqc-chip__remove`,"aria-label":t.t.composer.remove.replace(`{name}`,e.filename),onClick:()=>u?.(e.id),children:`×`})]},e.id)),s.map(e=>J(`span`,{class:`sqc-chip sqc-chip--waiting`,children:J(`span`,{class:`sqc-chip__name`,children:e})},e)),c&&J(`p`,{class:`sqc-attachments__error`,role:`status`,children:c})]}),J(`div`,{class:`sqc-composer__field`,children:[D&&J(`ul`,{class:`sqc-mentions`,role:`listbox`,"aria-label":t.t.handles.picker,children:E.map((e,t)=>J(`li`,{role:`option`,"aria-selected":t===_,class:`sqc-mention${t===_?` sqc-mention--active`:``}`,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>v(t),onClick:()=>A(e.handle),children:[J(`span`,{class:`sqc-mention__icon`,"aria-hidden":`true`,children:e.avatarEmoji??`@`}),J(`span`,{class:`sqc-mention__handle`,children:[`@`,e.handle]}),J(`span`,{class:`sqc-mention__name`,children:e.name})]},e.handle))}),J(`textarea`,{ref:x,class:`sqc-composer__input`,rows:1,value:p,placeholder:e,maxLength:Ye,"aria-label":t.t.composer.label,onInput:e=>{m(e.currentTarget.value),k(e.currentTarget),O()},onKeyDown:N,onClick:e=>k(e.currentTarget),onPaste:e=>{let t=e.clipboardData?.files;!w||!t||t.length===0||(e.preventDefault(),j(t))}}),P<=200&&J(`span`,{class:`sqc-composer__count`,"aria-live":`polite`,children:P})]}),w&&J(C,{children:[J(`input`,{ref:S,type:`file`,multiple:!0,accept:Ot,class:`sqc-file-input`,onChange:e=>{j(e.currentTarget.files),e.currentTarget.value=``}}),J(`button`,{type:`button`,class:`sqc-btn sqc-btn--attach`,onClick:()=>S.current?.click(),"aria-label":t.t.composer.attach,title:t.t.composer.attachTitle,children:J(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.9`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:J(`path`,{d:`M21 11.5l-8.8 8.8a5 5 0 01-7.1-7.1l9-9a3.3 3.3 0 014.7 4.7l-9 9a1.6 1.6 0 01-2.3-2.3l8.3-8.3`})})})]}),n?J(`button`,{type:`button`,class:`sqc-btn sqc-btn--stop`,onClick:f,"aria-label":t.t.composer.stop,title:t.t.composer.stopTitle,children:J(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:J(`rect`,{x:`7`,y:`7`,width:`10`,height:`10`,rx:`2`,fill:`currentColor`})})}):J(`button`,{type:`submit`,class:`sqc-btn sqc-btn--send`,disabled:!p.trim()&&o.length===0||T,"aria-label":t.t.composer.send,title:t.t.composer.sendTitle,children:J(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.9`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:J(`path`,{d:`M5 12l14-7-5 14-2.5-5.5L5 12z`})})})]})}var Mt={fr:/\br[ée]ponde?z? +«?\s*oui\b/i,en:/\b(?:reply|answer|respond) +[“"']?\s*yes\b/i,es:/\bresponda?e?d? +«?\s*s[íi]\b/i},Nt={fr:[/\b(?:confirmes?[- ]tu|confirmez[- ]vous)\b/i,/\b(?:valides?[- ]tu|validez[- ]vous)\b/i,/\b(?:es[- ]tu s[ûu]re?|[êe]tes[- ]vous s[ûu]re?s?)\b/i,/\b(?:dois[- ]je|puis[- ]je)\b/i,/\b(?:je continue|on continue|on y va|je lance)\b/i,Mt.fr],en:[/\bdo you confirm\b/i,/\bdo you (?:want|wish) me to\b/i,/\b(?:shall|should) I\b/i,/\bare you sure\b/i,/\b(?:shall we|should I) (?:proceed|continue|go ahead)\b/i,Mt.en],es:[/\b(?:confirmas|confirma|confirm[áa]is)\b/i,/\b(?:validas|valida|valid[áa]is)\b/i,/\best[áa]s? seguro\b/i,/\b(?:contin[úu]o|procedo|lo lanzo|lo hago)\b/i,/\bquieres? que\b/i,Mt.es]},Pt=/^\s*(?:[-*•]\s+)?\[[ xX]\]\s+/m;function Ft(e,t=`en`){if(Pt.test(e))return!1;let n=e.split(`
|
|
3
|
+
`).map(e=>e.trim()).filter(Boolean),r=n[n.length-1];return!r||!r.includes(`?`)&&!Mt[t].test(r)?!1:Nt[t].some(e=>e.test(r))}var It=/^mcp_[0-9a-f]{8}_/;function Lt(e){let t=e.replace(It,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):e}function Rt(e){return typeof e==`string`?e:JSON.stringify(e)??String(e)}function zt({locale:e,call:t,onDecide:n}){let{approval:r,confirm:i}=e.t,[a,o]=H(null),s=!!n&&a===null,c=(e,t)=>{o(t),n?.(e,t)},l=t?Object.entries(t.arguments):[];return J(`div`,{class:`sqc-approval`,role:`group`,"aria-label":r.group,children:[t&&J(`p`,{class:`sqc-approval__request`,"data-testid":`sqc-approval-tool`,children:r.request.replace(`{tool}`,Lt(t.tool))}),l.length>0&&J(`dl`,{class:`sqc-approval__args`,"data-testid":`sqc-approval-arguments`,children:l.map(([e,t])=>J(`div`,{class:`sqc-approval__arg`,children:[J(`dt`,{class:`sqc-approval__arg-name`,children:Lt(e)}),J(`dd`,{class:`sqc-approval__arg-value`,children:Rt(t)})]},e))}),J(`div`,{class:`sqc-approval__actions`,children:[J(`button`,{type:`button`,class:`sqc-approval__btn sqc-approval__btn--yes`,"aria-pressed":a===i.yes,disabled:!s,onClick:()=>c(!0,i.yes),children:r.approve}),J(`button`,{type:`button`,class:`sqc-approval__btn sqc-approval__btn--no`,"aria-pressed":a===i.no,disabled:!s,onClick:()=>c(!1,i.no),children:r.reject})]})]})}function Bt({locale:e,onPick:t}){let[n,r]=H(null),i=!!t&&n===null,{confirm:a}=e.t,o=[{value:a.yesValue,label:a.yes,kind:`yes`},{value:a.noValue,label:a.no,kind:`no`}];return J(`div`,{class:`sqc-confirm`,role:`group`,"aria-label":a.group,children:o.map(e=>J(`button`,{type:`button`,class:`sqc-confirm__btn sqc-confirm__btn--${e.kind}`,"aria-pressed":n===e.value,disabled:!i,onClick:()=>{r(e.value),t?.(e.value)},children:e.label},e.value))})}function Vt(){return J(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.2`,"aria-hidden":`true`,children:J(`path`,{d:`M3.5 8.5l3 3 6-7`,"stroke-linecap":`round`,"stroke-linejoin":`round`})})}function Ht({items:e,locale:t,onPick:n}){let[r,i]=H(null),a=!!n&&r===null;return J(`div`,{class:`sqc-choices`,role:`group`,"aria-label":t.t.choices,children:e.map((e,t)=>{let o=r===null?e.checked:r===e.label;return J(`button`,{type:`button`,class:`sqc-choice`,"aria-pressed":o,disabled:!a,onClick:()=>{i(e.label),n?.(e.label)},children:[J(`span`,{class:`sqc-choice__box${o?` sqc-choice__box--on`:``}`,"aria-hidden":`true`,children:o&&J(Vt,{})}),J(`span`,{class:`sqc-choice__label`,children:e.content})]},`${t}-${e.label}`)})})}var Ut=/(\*\*[^*\n]+\*\*|`[^`\n]+`|~~[^~\n]+~~|\[[^\]\n]+\]\([^)\s]+\)|\*[^*\n]+\*|https?:\/\/[^\s<>()]+)/g,Wt=/^\[([^\]\n]+)\]\(([^)\s]+)\)$/,Gt=/^(https?:|mailto:)/i;function Kt(e,t,n){return Gt.test(e)?J(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t},n):t}function Y(e,t){let n=e.split(Ut),r=[];return n.forEach((e,n)=>{if(!e)return;let i=`${t}-${n}`,a=Wt.exec(e);e.startsWith(`**`)&&e.endsWith(`**`)&&e.length>4?r.push(J(`strong`,{children:e.slice(2,-2)},i)):e.startsWith("`")&&e.endsWith("`")&&e.length>2?r.push(J(`code`,{children:e.slice(1,-1)},i)):e.startsWith(`~~`)&&e.endsWith(`~~`)&&e.length>4?r.push(J(`del`,{children:e.slice(2,-2)},i)):a?r.push(Kt(a[2],a[1],i)):e.startsWith(`*`)&&e.endsWith(`*`)&&e.length>2?r.push(J(`em`,{children:e.slice(1,-1)},i)):/^https?:\/\//.test(e)?r.push(Kt(e,e,i)):r.push(e)}),r}var qt=/^\s*(?:[-*•]\s+)?\[([ xX])\]\s+(.+)$/;function Jt(e){return e.replace(/\[([^\]\n]+)\]\([^)\s]+\)/g,`$1`).replace(/\*\*|~~|`|\*/g,``).trim()}var Yt=/^(\s*)[-*•]\s+/,Xt=/^(\s*)\d+[.)]\s+/,Zt=/^\s{0,3}(#{1,6})\s+(.+?)#*\s*$/,Qt=/^\s*([-*_])(?:\s*\1){2,}\s*$/,$t=/^\s*>\s?(.*)$/,en=/^\s*\|.*\|\s*$/,tn=/^\s*\|(?:\s*:?-{1,}:?\s*\|)+\s*$/,nn=/^\s*```/;function rn(e){return e.replace(/^\s*\|/,``).replace(/\|\s*$/,``).split(`|`).map(e=>e.trim())}function an(e,t,n,r){let i=e[t].ordered,a=[],o=t;for(;o<e.length&&e[o].depth>=n;){let t=e[o];if(t.depth===n&&t.ordered!==i)break;if(t.depth>n){let[n,i]=an(e,o,t.depth,`${r}-${o}`),s=a[a.length-1];s?s.nested.push(n):a.push({key:`${r}-${o}`,text:null,nested:[n]}),o=i;continue}a.push({key:`${r}-${o}`,text:t.text,nested:[]}),o+=1}let s=a.map(e=>J(`li`,{children:[e.text===null?null:Y(e.text,e.key),e.nested]},e.key));return[J(i?`ol`:`ul`,{children:s},r),o]}function on({text:e,locale:t,onChoice:n}){let r=e.split(`
|
|
4
4
|
`),i=[],a=[],o=[],s=[],c=()=>{if(!a.length)return;let e=`p${i.length}`;i.push(J(`p`,{children:Y(a.join(`
|
|
5
|
-
`),e)},e)),a=[]},l=()=>{if(!o.length)return;let e=0;for(;e<o.length;){let t=`l${i.length}`,[n,r]=
|
|
6
|
-
`),e)},e)),s=[]},d=()=>{c(),l(),u()};for(let e=0;e<r.length;e+=1){let f=r[e];if(
|
|
7
|
-
`)})},n));continue}if($t.test(f)&&e+1<r.length&&en.test(r[e+1])){d();let t=nn(f),n=[];for(e+=2;e<r.length&&$t.test(r[e]);)n.push(nn(r[e])),e+=1;--e;let a=`t${i.length}`;i.push(J(`div`,{class:`sqc-table`,children:J(`table`,{children:[J(`thead`,{children:J(`tr`,{children:t.map((e,t)=>J(`th`,{children:Y(e,`${a}-h${t}`)},`${a}-h${t}`))})}),J(`tbody`,{children:n.map((e,n)=>J(`tr`,{children:t.map((t,r)=>J(`td`,{children:Y(e[r]??``,`${a}-r${n}c${r}`)},`${a}-r${n}c${r}`))},`${a}-r${n}`))})]})},a));continue}if(!f.trim()){d();continue}if(Kt.test(f)){d();let a=[];for(;e<r.length;){let t=Kt.exec(r[e]);if(!t)break;let n=t[2].trim(),o=`o${i.length}-${a.length}`;a.push({label:qt(n),checked:t[1].toLowerCase()===`x`,content:Y(n,o)}),e+=1}--e,i.push(J(Vt,{items:a,locale:t,onPick:n},`o${i.length}`));continue}let p=Xt.exec(f);if(p){d();let e=p[1].length,t=e<=2?`h3`:e===3?`h4`:`h5`,n=`h${i.length}`;i.push(J(t,{children:Y(p[2],n)},n));continue}if(Zt.test(f)){d(),i.push(J(`hr`,{},`r${i.length}`));continue}let m=Qt.exec(f);if(m){c(),l(),s.push(m[1]);continue}let h=Jt.exec(f),g=h?null:Yt.exec(f),_=h??g;if(_){c(),u(),o.push({depth:_[1].replace(/\t/g,` `).length,ordered:!!g,text:f.slice(_[0].length)});continue}l(),u(),a.push(f)}return d(),J(C,{children:i})}var on=80;function sn({at:e,locale:t}){let n=new Date(e);return J(`time`,{class:`sqc-msg__time`,dateTime:n.toISOString(),children:n.toLocaleTimeString(t.tag,{hour:`2-digit`,minute:`2-digit`})})}function cn({file:e,load:t}){let[n,r]=H(null);return U(()=>{let n=null,i=!0;return t(e.id).then(e=>{i&&(n=URL.createObjectURL(e),r(n))}).catch(()=>{}),()=>{i=!1,n&&URL.revokeObjectURL(n)}},[e.id,t]),n?J(`img`,{class:`sqc-attachment__image`,src:n,alt:e.filename}):J(`span`,{class:`sqc-chip sqc-chip--waiting`,children:e.filename})}function ln({files:e,load:t}){return e.length===0||!t?null:J(`div`,{class:`sqc-attachments sqc-attachments--sent`,children:e.map(e=>e.kind===`image`?J(cn,{file:e,load:t},e.id):J(`span`,{class:`sqc-chip`,"data-kind":`document`,children:J(`span`,{class:`sqc-chip__name`,children:e.filename})},e.id))})}function un({message:e,locale:t,assistantName:n,onChoice:r,onDecide:i,onLoadAttachment:a}){let o=e.streaming&&!e.content,s=!!e.approval;return J(`div`,{class:`sqc-msg sqc-msg--${e.role}${e.error?` sqc-msg--error`:``}`,children:[e.role===`assistant`&&J(`div`,{class:`sqc-msg__who`,children:[e.agent?.avatarEmoji?J(`span`,{class:`sqc-msg__emoji`,"aria-hidden":`true`,children:e.agent.avatarEmoji}):J(fn,{}),e.authorName??e.agent?.name??n]}),J(`div`,{class:`sqc-msg__bubble`,children:[o?J(`span`,{class:`sqc-typing`,"aria-label":t.t.typing,children:[J(`i`,{}),J(`i`,{}),J(`i`,{})]}):J(`div`,{class:`sqc-msg__body`,children:[J(an,{text:e.content,locale:t,onChoice:r}),e.streaming&&J(`span`,{class:`sqc-caret`,"aria-hidden":`true`}),s&&J(Rt,{locale:t,call:e.content.trim()===``?e.approval:void 0,onDecide:i}),!s&&!e.streaming&&!e.error&&Pt(e.content,t.code)&&J(zt,{locale:t,onPick:r}),e.unknownHandle&&!e.streaming&&J(dn,{message:e,locale:t}),J(ln,{files:e.attachments??[],load:a})]}),!o&&J(sn,{at:e.createdAt,locale:t})]})]})}function dn({message:e,locale:t}){let n=e.offered??[];return J(`p`,{class:`sqc-msg__unaddressed`,children:[J(`span`,{children:t.t.handles.unknown}),` `,J(`code`,{children:[`@`,e.unknownHandle]}),n.length>0&&J(C,{children:[` `,J(`span`,{children:t.t.handles.instead}),` `,n.map(e=>J(`code`,{children:[`@`,e.handle]},e.handle))]})]})}function fn(){return J(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:J(`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`})})}function pn({messages:e,locale:t,assistantName:n,suggestions:r,showSuggestions:i,busy:a,withHuman:o,onSuggestion:s,onChoice:c,onDecide:l,onLoadAttachment:u}){let d=W(null),f=W(!0);return ye(()=>{let e=d.current;e&&f.current&&(e.scrollTop=e.scrollHeight)},[e]),U(()=>{let e=d.current;if(!e)return;let t=()=>{f.current=e.scrollHeight-e.scrollTop-e.clientHeight<on};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),J(`div`,{class:`sqc-messages`,ref:d,role:`log`,"aria-live":`polite`,"aria-atomic":`false`,children:[e.map((r,i)=>J(un,{message:r,locale:t,assistantName:n,onChoice:!a&&r.role===`assistant`&&i===e.length-1?c:void 0,onDecide:!a&&r.role===`assistant`&&i===e.length-1?l:void 0,onLoadAttachment:u},r.id)),o&&J(`p`,{class:`sqc-with-human`,role:`status`,children:t.t.withHuman}),i&&r&&r.length>0&&J(`div`,{class:`sqc-suggestions`,children:r.map(e=>J(`button`,{type:`button`,class:`sqc-suggestion`,onClick:()=>s(e),children:e},e))})]})}var mn={width:`min(392px, 100vw)`},hn=new Set([`sessionId`]);function gn(e){let t=e.replace(/Id$|Ref$/,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):e}function _n(e){if(!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if(hn.has(n)||typeof r!=`string`&&!Ae(r))continue;let e=ke(r);e&&t.push({label:gn(n),value:e})}return t}function vn(e,t){return e?.trim()?e:t}function yn(e){let[t,n]=H(!1);return U(()=>{if(e!==`auto`||typeof matchMedia!=`function`)return;let t=matchMedia(`(prefers-color-scheme: dark)`);n(t.matches);let r=e=>n(e.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),e===`dark`?`dark`:e===`light`?`light`:t?`dark`:`light`}function bn(e){let t=e.persistOpen??!0,[n,r]=H(()=>He(e.defaultOpen,t)),[i,a]=H(!1),[o,s]=H(!1),c=W(null),l=W(null),u=yn(e.theme??`light`),d=G(()=>Re(e.locale),[e.locale]),f=d.t,p=vn(e.heading,f.heading),m=vn(e.assistantName,f.assistant),h=vn(e.greeting,f.greeting),g=e.onEvent,{send:_,reset:v,decide:y,stop:b,start:x,busy:S,messages:C,withHuman:w,sessionId:T,handles:E,addressee:D,attachments:O,uploading:k,attachmentError:A,attach:j,detach:M,loadAttachment:N}=wt({embedKey:e.embedKey,user:e.user,agent:e.agent,context:e.context,greeting:h,locale:d,onEvent:g});U(()=>{!n&&C.some(e=>e.role===`assistant`&&e.id!==`greeting`)&&s(!0)},[C,n]);let P=W(n);P.current=n;let F=K(()=>{s(!1),!P.current&&(P.current=!0,r(!0),t&&Ve(!0),g?.({type:`chatbot-open`,sessionId:T}))},[g,t,T]),I=K(()=>{P.current&&(P.current=!1,r(!1),t&&Ve(!1),g?.({type:`chatbot-close`,sessionId:T}),l.current?.focus())},[g,t,T]);U(()=>{n&&x()},[n,x]);let L=K(e=>{a(!0),_(e)},[_]),ee=K(()=>{a(!1),s(!1),v()},[v]),R=W({openPanel:F,closePanel:I,send:L,reset:ee,sessionId:T});R.current={openPanel:F,closePanel:I,send:L,reset:ee,sessionId:T};let te=W({open:()=>R.current.openPanel(),close:()=>R.current.closePanel(),toggle:()=>P.current?R.current.closePanel():R.current.openPanel(),reset:()=>R.current.reset(),send:e=>{R.current.openPanel(),R.current.send(e)},isOpen:()=>P.current,sessionId:()=>R.current.sessionId}),ne=e.bind;ye(()=>(ne?.(te.current),()=>ne?.(null)),[ne]),U(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),I())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[I,n]);let re=G(()=>C.some(e=>e.id!==`greeting`),[C]),ie=G(()=>_n(e.context),[e.context]),ae={...e.accent?{"--sqc-accent":e.accent}:{},"--sqc-width":e.width??mn.width};return J(`div`,{class:`sqc`,"data-theme":u,"data-position":e.position??`bottom-right`,"data-open":n?`true`:`false`,style:ae,children:[J(`button`,{ref:l,type:`button`,class:`sqc-launcher`,"aria-label":p,"aria-expanded":n,"aria-haspopup":`dialog`,onClick:F,children:[J(`span`,{class:`sqc-launcher__icon`,children:J(`slot`,{name:`launcher-icon`,class:`sqc-slot-icon`,children:J(fn,{})})}),o&&J(`span`,{class:`sqc-launcher__badge`,"aria-hidden":`true`})]}),J(`aside`,{ref:c,class:`sqc-panel`,role:`dialog`,"aria-modal":`false`,"aria-label":p,...n?{}:{inert:!0},children:[J(`header`,{class:`sqc-header`,children:[J(`span`,{class:`sqc-header__icon`,"aria-hidden":`true`,children:J(fn,{})}),J(`div`,{class:`sqc-header__titles`,children:[J(`p`,{class:`sqc-header__heading`,children:p}),J(`p`,{class:`sqc-header__sub`,children:vn(e.subheading,f.subheading)})]}),J(`button`,{type:`button`,class:`sqc-icon-btn`,onClick:ee,"aria-label":f.newConversation,"data-tip":f.newConversation,children:J(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,children:J(`path`,{d:`M20 12a8 8 0 1 1-2.6-5.9M20 4v4h-4`,"stroke-linecap":`round`})})}),J(`button`,{type:`button`,class:`sqc-icon-btn`,onClick:I,"aria-label":f.close,"data-tip":f.closeTitle,children:J(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,children:J(`path`,{d:`M6 6l12 12M18 6L6 18`,"stroke-linecap":`round`})})})]}),ie.length>0&&J(`div`,{class:`sqc-context`,"aria-label":f.context.region,children:ie.map(e=>J(`span`,{class:`sqc-chip`,title:`${e.label}: ${e.value}`,children:[J(`b`,{children:e.label}),e.value]},e.label))}),J(pn,{messages:C,locale:d,assistantName:m,suggestions:e.suggestions,showSuggestions:!i&&!re,busy:S,withHuman:w,onSuggestion:L,onChoice:L,onDecide:y,onLoadAttachment:N}),J(At,{placeholder:vn(e.placeholder,f.placeholder),locale:d,busy:S,autoFocus:n,handles:E,addressee:D,attachments:O,uploading:k,attachmentError:A?f.attachments[A]:void 0,onAttach:j,onDetach:M,onSend:L,onStop:b}),J(`p`,{class:`sqc-hint`,children:f.hint})]})]})}var xn=`:host{--sqc-width:min(392px, 100vw);--sqc-z:2147480000;--sqc-radius:16px;--sqc-font-family:"Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;--sqc-font-heading:var(--sqc-font-family);z-index:var(--sqc-z);pointer-events:none;font-family:var(--sqc-font-family);-webkit-font-smoothing:antialiased;text-align:left;font-size:14px;line-height:1.5;display:block;position:fixed;top:0;bottom:0;left:0;right:0;margin:0!important}:host([hidden]){display:none}.sqc{--sqc-neutral-50:#f8fafc;--sqc-neutral-100:#f1f5f9;--sqc-neutral-200:#e2e8f0;--sqc-neutral-300:#cbd5e1;--sqc-neutral-400:#94a3b8;--sqc-neutral-500:#64748b;--sqc-neutral-600:#475569;--sqc-neutral-900:#0f172a;--sqc-error-50:#fff1f2;--sqc-error-100:#ffe4e6;--sqc-error-600:#e11d48;--sqc-accent-default:#000;--sqc-accent-color:var(--sqc-accent,var(--sqc-accent-default));--sqc-on-accent:#fff;--sqc-accent-hover:color-mix(in oklab, var(--sqc-accent-color) 84%, var(--sqc-on-accent));--sqc-accent-fg:var(--sqc-accent,var(--sqc-text));--sqc-bg:#fff;--sqc-surface:var(--sqc-neutral-50);--sqc-selected:var(--sqc-neutral-100);--sqc-border:var(--sqc-neutral-200);--sqc-border-strong:var(--sqc-neutral-300);--sqc-text:var(--sqc-neutral-900);--sqc-text-muted:var(--sqc-neutral-500);--sqc-link:#2563eb;--sqc-bubble-user:var(--sqc-accent-color);--sqc-bubble-user-text:var(--sqc-on-accent);--sqc-code-bg:var(--sqc-neutral-100);--sqc-disabled:var(--sqc-neutral-300);--sqc-shadow:0 10px 15px -3px #0f172a1a, 0 4px 6px -4px #0f172a1a;--sqc-shadow-bottom:0 6px 8px -6px #0f172a2e;--sqc-focus:0 0 0 2px var(--sqc-bg), 0 0 0 4px #0f172a4d;--sqc-focus-input:0 0 0 3px #0f172a1a;--sqc-danger:var(--sqc-error-600);color:var(--sqc-text);position:absolute;top:0;bottom:0;left:0;right:0}.sqc[data-theme=dark]{--sqc-neutral-50:#172033;--sqc-neutral-100:#1e293b;--sqc-neutral-200:#334155;--sqc-neutral-300:#475569;--sqc-neutral-400:#64748b;--sqc-neutral-500:#94a3b8;--sqc-neutral-600:#cbd5e1;--sqc-neutral-900:#f8fafc;--sqc-error-50:#2a0a12;--sqc-error-100:#4c0519;--sqc-error-600:#fb7185;--sqc-accent-default:#fff;--sqc-on-accent:#0f172a;--sqc-bg:#0f172a;--sqc-link:#60a5fa;--sqc-code-bg:#020617;--sqc-shadow:0 10px 24px -4px #0000008c;--sqc-shadow-bottom:0 6px 8px -6px #0000008c;--sqc-focus:0 0 0 2px var(--sqc-bg), 0 0 0 4px #f8fafc59;--sqc-focus-input:0 0 0 3px #f8fafc1f}@supports (color:oklch(from red l c h)){.sqc{--sqc-on-accent:oklch(from var(--sqc-accent-color) clamp(.208, (.62 - l) * 1000, 1) 0 0)}}.sqc *,.sqc :before,.sqc :after{box-sizing:border-box}.sqc-launcher{background:var(--sqc-accent-color);width:56px;height:56px;color:var(--sqc-on-accent);cursor:pointer;pointer-events:auto;box-shadow:var(--sqc-shadow);border:none;border-radius:50%;place-items:center;padding:0;transition:transform .18s,opacity .18s,background .18s,box-shadow .18s;display:grid;position:absolute;bottom:24px;right:24px}.sqc[data-position=bottom-left] .sqc-launcher{left:24px;right:auto}.sqc-launcher:hover{background:var(--sqc-accent-hover);transform:scale(1.06)}.sqc-launcher:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc[data-open=true] .sqc-launcher{opacity:0;pointer-events:none;transform:scale(.5)}.sqc-launcher__icon svg{width:26px;height:26px;display:block}.sqc-slot-icon::slotted(*){justify-content:center;align-items:center;width:26px;height:26px;display:inline-flex}.sqc-launcher__badge{background:var(--sqc-error-600);border:2px solid var(--sqc-bg);border-radius:50%;width:12px;height:12px;position:absolute;top:6px;right:6px}.sqc-panel{width:var(--sqc-width);background:var(--sqc-bg);border-left:1px solid var(--sqc-border);box-shadow:var(--sqc-shadow);pointer-events:auto;visibility:hidden;flex-direction:column;transition:transform .26s cubic-bezier(.22,1,.36,1),visibility 0s linear .26s;display:flex;position:absolute;top:0;bottom:0;right:0;transform:translate(100%)}.sqc[data-open=true] .sqc-panel{visibility:visible;transition:transform .26s cubic-bezier(.22,1,.36,1),visibility;transform:translate(0)}.sqc-header{background:var(--sqc-bg);color:var(--sqc-text);border-bottom:1px solid var(--sqc-border);flex-shrink:0;align-items:center;gap:8px;padding:13px 12px 13px 16px;display:flex}.sqc-header__icon{color:var(--sqc-accent-fg);flex-shrink:0;place-items:center;display:grid}.sqc-header__icon svg{width:17px;height:17px;display:block}.sqc-header__titles{flex:1;min-width:0}.sqc-header__heading,.sqc-header__sub{text-overflow:ellipsis;white-space:nowrap;margin:0;overflow:hidden}.sqc-header__heading{font-family:var(--sqc-font-heading);letter-spacing:-.2px;font-size:15px;font-weight:700}.sqc-header__sub{color:var(--sqc-text-muted);font-size:12px}.sqc-icon-btn{width:26px;height:26px;color:var(--sqc-text-muted);cursor:pointer;background:0 0;border:none;border-radius:8px;flex-shrink:0;place-items:center;transition:background .15s;display:grid}.sqc-icon-btn:hover{background:var(--sqc-surface);color:var(--sqc-text)}.sqc-icon-btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-icon-btn svg{width:16px;height:16px}.sqc-icon-btn[data-tip]{position:relative}.sqc-icon-btn[data-tip]:after{content:attr(data-tip);z-index:6;background:var(--sqc-text);color:var(--sqc-bg);font-family:var(--sqc-font-family);white-space:nowrap;pointer-events:none;opacity:0;border-radius:8px;padding:4px 8px;font-size:11px;font-weight:500;line-height:1.3;transition:opacity .12s .15s;position:absolute;top:calc(100% + 6px);right:0}.sqc-icon-btn[data-tip]:hover:after{opacity:1}.sqc-icon-btn[data-tip]:focus-visible:after{opacity:1}.sqc-history-pop{z-index:5;position:absolute;top:54px;left:0;right:0}.sqc-history{background:var(--sqc-bg);max-height:320px;box-shadow:var(--sqc-shadow-bottom);flex-direction:column;display:flex;overflow-y:auto}.sqc-history__empty{color:var(--sqc-text-muted);text-align:center;margin:0;padding:14px 16px;font-size:12px}.sqc-history__item{border:none;border-bottom:1px solid var(--sqc-border);width:100%;color:var(--sqc-text);text-align:left;cursor:pointer;background:0 0;flex-direction:column;gap:2px;padding:10px 16px;transition:background .15s;display:flex}.sqc-history__item:last-child{border-bottom:none}.sqc-history__item:hover{background:var(--sqc-surface)}.sqc-history__item:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-history__item[aria-current=true]{background:var(--sqc-selected)}.sqc-history__item[aria-current=true] .sqc-history__title{color:var(--sqc-text);font-weight:600}.sqc-history__title{text-overflow:ellipsis;white-space:nowrap;font-size:13px;overflow:hidden}.sqc-history__date{color:var(--sqc-text-muted);font-size:11px}.sqc-context{background:var(--sqc-selected);border:1px solid var(--sqc-border);color:var(--sqc-text);border-radius:12px;flex-wrap:wrap;flex-shrink:0;align-items:center;gap:8px;margin:12px 16px 4px;padding:8px 11px;font-size:12px;display:flex}.sqc-chip{text-overflow:ellipsis;white-space:nowrap;align-items:baseline;gap:4px;max-width:100%;display:inline-flex;overflow:hidden}.sqc-chip b{font-weight:600}.sqc-chip:not(:last-child):after{content:"·";opacity:.5;margin-left:4px}.sqc-messages{overscroll-behavior:contain;background:var(--sqc-bg);scrollbar-width:thin;scrollbar-color:var(--sqc-neutral-300) transparent;flex-direction:column;flex:1;gap:13px;min-height:0;padding:12px 16px;display:flex;overflow-y:auto}.sqc-messages::-webkit-scrollbar{width:6px}.sqc-messages::-webkit-scrollbar-thumb{background:var(--sqc-neutral-300);border-radius:99px}.sqc-msg{flex-direction:column;max-width:93%;font-size:13.5px;display:flex}.sqc-msg--assistant{align-self:flex-start}.sqc-msg--user{align-self:flex-end}.sqc-msg__who{color:var(--sqc-text-muted);align-items:center;gap:6px;margin-bottom:4px;font-size:11px;font-weight:500;display:flex}.sqc-msg__who svg{width:12px;height:12px;color:var(--sqc-accent-fg);flex-shrink:0}.sqc-msg__unaddressed{color:var(--sqc-text-muted);margin:8px 0 0;font-size:11.5px;line-height:1.5}.sqc-msg__unaddressed code{background:var(--sqc-code-bg);color:var(--sqc-text);border-radius:4px;margin-right:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11px}.sqc-msg--user .sqc-msg__bubble{background:var(--sqc-bubble-user);color:var(--sqc-bubble-user-text);border-radius:var(--sqc-radius) var(--sqc-radius) 4px var(--sqc-radius);padding:9px 13px}.sqc-msg--error .sqc-msg__bubble{background:var(--sqc-error-50);color:var(--sqc-error-600);border:1px solid var(--sqc-error-100);border-radius:12px;padding:11px}.sqc-msg__body{overflow-wrap:anywhere}.sqc-msg--assistant .sqc-msg__body{font-size:14px;line-height:1.6}.sqc-msg__body>:first-child{margin-top:0}.sqc-msg__body>:last-child{margin-bottom:0}.sqc-msg__body p{white-space:pre-wrap;margin:0 0 8px}.sqc-msg__body ul,.sqc-msg__body ol{margin:0 0 8px;padding-left:20px}.sqc-msg__body li{margin-bottom:3px}.sqc-msg__body code{background:var(--sqc-code-bg);border-radius:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.85em}.sqc-msg--user .sqc-msg__body code{background:#ffffff38}.sqc-msg__body pre{background:var(--sqc-code-bg);border-radius:8px;margin:0 0 8px;padding:9px 11px;overflow-x:auto}.sqc-msg__body pre code{background:0 0;padding:0}.sqc-msg__body a{color:inherit;text-underline-offset:2px;text-decoration:underline}.sqc-msg--assistant .sqc-msg__body a{color:var(--sqc-link);text-decoration:none}.sqc-msg--assistant .sqc-msg__body a:hover{text-decoration:underline}.sqc-msg__body h3,.sqc-msg__body h4,.sqc-msg__body h5,.sqc-msg__body h6{font-family:var(--sqc-font-heading);letter-spacing:-.2px;margin:12px 0 6px;font-weight:700;line-height:1.3}.sqc-msg__body h3{font-size:1.05em}.sqc-msg__body h4{font-size:1em}.sqc-msg__body h5,.sqc-msg__body h6{font-size:.94em}.sqc-msg__body ul ul,.sqc-msg__body ul ol,.sqc-msg__body ol ul,.sqc-msg__body ol ol{margin:3px 0 0}.sqc-msg__body blockquote{border-left:2px solid var(--sqc-border-strong);color:var(--sqc-text-muted);white-space:pre-wrap;margin:0 0 8px;padding:2px 0 2px 10px}.sqc-msg--user .sqc-msg__body blockquote{color:inherit;opacity:.85;border-left-color:#ffffff73}.sqc-msg__body hr{border:0;border-top:1px solid var(--sqc-border);margin:10px 0}.sqc-msg--user .sqc-msg__body hr{border-top-color:#ffffff4d}.sqc-msg__body del{opacity:.7}.sqc-approval{flex-direction:column;gap:8px;margin:11px 0 2px;display:flex}.sqc-approval__actions{flex-wrap:wrap;gap:8px;display:flex}.sqc-approval__request{color:var(--sqc-text);margin:0;font-size:13px}.sqc-approval__args{border:1px solid var(--sqc-border);background:var(--sqc-surface);border-radius:12px;flex-direction:column;gap:4px;margin:0;padding:8px 10px;font-size:12px;display:flex}.sqc-approval__arg{gap:8px;display:flex}.sqc-approval__arg-name{color:var(--sqc-text-muted);flex:none;font-weight:500}.sqc-approval__arg-value{overflow-wrap:anywhere;min-width:0;color:var(--sqc-text);margin:0}.sqc-approval__btn{height:32px;font-family:var(--sqc-font-family);border:1px solid var(--sqc-border);background:var(--sqc-bg);color:var(--sqc-text);cursor:pointer;border-radius:12px;flex:auto;justify-content:center;align-items:center;padding:0 12px;font-size:13px;font-weight:500;transition:border-color .12s,background .12s;display:inline-flex}.sqc-approval__btn--yes:not(:disabled),.sqc-approval__btn--send:not(:disabled){background:var(--sqc-accent-color);color:var(--sqc-on-accent);border-color:#0000;font-weight:600}.sqc-approval__btn:hover:not(:disabled){border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-approval__btn--yes:hover:not(:disabled),.sqc-approval__btn--send:hover:not(:disabled){background:var(--sqc-accent-hover);border-color:#0000}.sqc-approval__btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-approval__btn:disabled{cursor:default}.sqc-approval__btn:disabled[aria-pressed=false]{opacity:.45}.sqc-approval__btn[aria-pressed=true]{border-color:var(--sqc-border-strong);background:var(--sqc-selected);color:var(--sqc-text);font-weight:600}.sqc-approval__edit{flex-direction:column;gap:8px;display:flex}.sqc-approval__input{width:100%;font-family:var(--sqc-font-family);color:var(--sqc-text);background:var(--sqc-bg);border:1px solid var(--sqc-border-strong);resize:vertical;border-radius:12px;padding:8px 10px;font-size:13px;line-height:1.4}.sqc-approval__input:focus-visible{border-color:var(--sqc-text);box-shadow:var(--sqc-focus-input);outline:none}.sqc-approval__btn--send{flex:none;align-self:flex-end}.sqc-confirm{gap:8px;margin:11px 0 2px;display:flex}.sqc-confirm__btn{height:32px;font-family:var(--sqc-font-family);border:1px solid var(--sqc-border);background:var(--sqc-bg);color:var(--sqc-text);cursor:pointer;border-radius:12px;flex:1 1 0;justify-content:center;align-items:center;padding:0 12px;font-size:13px;font-weight:500;transition:border-color .12s,background .12s;display:inline-flex}.sqc-confirm__btn--yes:not(:disabled){background:var(--sqc-accent-color);color:var(--sqc-on-accent);border-color:#0000;font-weight:600}.sqc-confirm__btn:hover:not(:disabled){border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-confirm__btn--yes:hover:not(:disabled){background:var(--sqc-accent-hover);border-color:#0000}.sqc-confirm__btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-confirm__btn:disabled{cursor:default}.sqc-confirm__btn:disabled[aria-pressed=false]{opacity:.45}.sqc-confirm__btn[aria-pressed=true]{border-color:var(--sqc-border-strong);background:var(--sqc-selected);color:var(--sqc-text);font-weight:600}.sqc-choices{flex-direction:column;gap:7px;margin:10px 0 2px;display:flex}.sqc-choice{width:100%;font-family:var(--sqc-font-family);text-align:left;color:var(--sqc-text);background:var(--sqc-bg);border:1px solid var(--sqc-border);cursor:pointer;border-radius:12px;align-items:center;gap:8px;padding:8px 11px;font-size:12.5px;transition:border-color .12s,background .12s;display:flex}.sqc-choice:hover:not(:disabled){border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-choice:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-choice:disabled{cursor:default}.sqc-choice:disabled[aria-pressed=false]{opacity:.55}.sqc-choice[aria-pressed=true]{border-color:var(--sqc-border-strong);background:var(--sqc-selected)}.sqc-choice__box{border:1.5px solid var(--sqc-border-strong);border-radius:4px;flex:none;justify-content:center;align-items:center;width:15px;height:15px;display:inline-flex}.sqc-choice__box--on{color:var(--sqc-on-accent);background:var(--sqc-accent-color);border-color:var(--sqc-accent-color)}.sqc-choice__box svg{width:11px;height:11px}.sqc-choice__label{overflow-wrap:anywhere}.sqc-choice__detail{color:var(--sqc-text-muted);margin-top:1px;font-size:11.5px;display:block}.sqc-selection{flex-direction:column;gap:10px;margin:2px 0;display:flex}.sqc-selection__question{flex-direction:column;gap:2px;display:flex}.sqc-selection__ask{font-family:var(--sqc-font-family);color:var(--sqc-text);margin:0;font-size:13px;font-weight:600}.sqc-selection__actions{display:flex}.sqc-selection__validate{height:32px;font-family:var(--sqc-font-family);color:var(--sqc-on-accent);background:var(--sqc-accent-color);cursor:pointer;border:1px solid #0000;border-radius:12px;flex:auto;justify-content:center;align-items:center;padding:0 12px;font-size:13px;font-weight:600;transition:filter .12s,background .12s;display:inline-flex}.sqc-selection__validate:hover:not(:disabled){background:var(--sqc-accent-hover)}.sqc-selection__validate:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-selection__validate:disabled{cursor:not-allowed;color:#fff;background:var(--sqc-disabled)}.sqc-selection__hint{font-family:var(--sqc-font-family);color:var(--sqc-text-muted);margin:0;font-size:11.5px}.sqc-table{scrollbar-width:thin;margin:0 0 8px;overflow-x:auto}.sqc-table table{border-collapse:collapse;min-width:100%;font-family:var(--sqc-font-family);white-space:nowrap;font-size:12.5px}.sqc-table th,.sqc-table td{text-align:left;vertical-align:top;border-bottom:1px solid var(--sqc-border);padding:6px 10px 6px 0}.sqc-table thead th{text-transform:uppercase;letter-spacing:.05em;color:var(--sqc-text-muted);font-size:10.5px;font-weight:600}.sqc-table tbody th{font-weight:500}.sqc-msg--user .sqc-table th,.sqc-msg--user .sqc-table td{border-bottom-color:#ffffff40}.sqc-msg--user .sqc-table thead th{color:#fffc}.sqc-table tbody tr:last-child th,.sqc-table tbody tr:last-child td{border-bottom:0}.sqc-msg__time{color:var(--sqc-text-muted);font-variant-numeric:tabular-nums;margin-top:3px;font-size:10px;display:block}.sqc-msg--user .sqc-msg__time{color:#ffffffb3;text-align:right}.sqc-caret{vertical-align:text-bottom;background:currentColor;width:2px;height:1em;margin-left:2px;animation:1s step-end infinite sqc-blink;display:inline-block}@keyframes sqc-blink{0%,to{opacity:1}50%{opacity:0}}.sqc-typing{gap:3px;padding:2px 0;display:inline-flex}.sqc-typing i{background:var(--sqc-neutral-400);border-radius:50%;width:5px;height:5px;animation:1.2s infinite sqc-pulse}.sqc-typing i:nth-child(2){animation-delay:.2s}.sqc-typing i:nth-child(3){animation-delay:.4s}@keyframes sqc-pulse{0%,60%,to{opacity:.25}30%{opacity:1}}.sqc-suggestions{flex-direction:column;gap:7px;display:flex}.sqc-suggestion{border:1px solid var(--sqc-border);background:var(--sqc-bg);width:100%;color:var(--sqc-text);font-family:var(--sqc-font-family);cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:8px;padding:8px 11px;font-size:12.5px;transition:background .15s,border-color .15s;display:flex}.sqc-suggestion:before{content:"";background:var(--sqc-accent-fg);border-radius:50%;flex:none;width:5px;height:5px}.sqc-suggestion:hover{background:var(--sqc-surface);border-color:var(--sqc-border-strong)}.sqc-suggestion:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-composer{border-top:1px solid var(--sqc-border);background:var(--sqc-bg);flex-wrap:wrap;flex-shrink:0;align-items:flex-end;gap:8px;padding:12px 14px;display:flex}.sqc-composer--dropping{outline:2px dashed var(--sqc-accent-color);outline-offset:-4px}.sqc-attachments{flex-wrap:wrap;flex-basis:100%;gap:6px;display:flex}.sqc-attachments--sent{margin-top:8px}.sqc-chip{border:1px solid var(--sqc-border);background:var(--sqc-selected);max-width:100%;color:var(--sqc-text);border-radius:999px;align-items:center;gap:4px;padding:3px 4px 3px 10px;font-size:12px;display:inline-flex}.sqc-chip--waiting{opacity:.6;padding-right:10px}.sqc-chip__name{text-overflow:ellipsis;white-space:nowrap;max-width:180px;overflow:hidden}.sqc-chip__remove{width:18px;height:18px;color:var(--sqc-text-muted);cursor:pointer;background:0 0;border:0;border-radius:999px;justify-content:center;align-items:center;padding:0;font-size:14px;line-height:1;display:inline-flex}.sqc-chip__remove:hover{background:var(--sqc-selected);color:var(--sqc-text)}.sqc-attachments__error{color:var(--sqc-error-600);flex-basis:100%;margin:0;font-size:12px}.sqc-attachment__image{border-radius:12px;max-width:100%;max-height:180px;display:block}.sqc-file-input{display:none}.sqc-btn--attach{color:var(--sqc-text-muted);background:0 0}.sqc-btn--attach:hover{background:var(--sqc-selected);color:var(--sqc-text)}.sqc-composer__field{flex:1;min-width:0;position:relative}.sqc-composer__input{border:1px solid var(--sqc-border-strong);background:var(--sqc-bg);width:100%;min-height:38px;max-height:132px;color:var(--sqc-text);font-family:var(--sqc-font-family);resize:none;border-radius:12px;outline:none;padding:9px 12px;font-size:13.5px;line-height:1.4;transition:border-color .15s,box-shadow .15s;display:block;overflow-y:hidden}.sqc-composer__input::placeholder{color:var(--sqc-neutral-400)}.sqc-composer__input:focus{border-color:var(--sqc-text);box-shadow:var(--sqc-focus-input)}.sqc-mentions{z-index:2;border:1px solid var(--sqc-border);background:var(--sqc-bg);max-height:184px;box-shadow:var(--sqc-shadow);scrollbar-width:thin;border-radius:12px;margin:0;padding:4px;list-style:none;position:absolute;bottom:calc(100% + 6px);left:0;right:0;overflow-y:auto}.sqc-mention{cursor:pointer;color:var(--sqc-text);border-radius:8px;align-items:baseline;gap:6px;padding:6px 8px;font-size:12.5px;display:flex}.sqc-mention--active{background:var(--sqc-neutral-100)}.sqc-mention__icon{flex-shrink:0}.sqc-mention__handle{font-weight:600}.sqc-mention__name{text-overflow:ellipsis;white-space:nowrap;color:var(--sqc-text-muted);overflow:hidden}.sqc-composer__count{color:var(--sqc-text-muted);pointer-events:none;font-variant-numeric:tabular-nums;font-size:10px;position:absolute;bottom:4px;right:8px}.sqc-btn{cursor:pointer;border:none;border-radius:12px;flex-shrink:0;place-items:center;width:38px;height:38px;transition:background .15s,opacity .15s;display:grid}.sqc-btn svg{width:17px;height:17px}.sqc-btn--send{background:var(--sqc-accent-color);color:var(--sqc-on-accent)}.sqc-btn--send:hover:not(:disabled){background:var(--sqc-accent-hover)}.sqc-btn--send:disabled{background:var(--sqc-disabled);color:#fff;cursor:not-allowed}.sqc-btn--stop{background:var(--sqc-bg);color:var(--sqc-text);border:1px solid var(--sqc-border)}.sqc-btn--stop:hover{border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-hint{padding:0 16px max(9px, env(safe-area-inset-bottom));color:var(--sqc-text-muted);text-align:center;flex-shrink:0;margin:0;font-size:10.5px;line-height:1.35}@media (max-width:520px){.sqc{--sqc-width:100vw}.sqc-panel{border-left:none}.sqc-launcher{bottom:16px;right:16px}.sqc[data-position=bottom-left] .sqc-launcher{left:16px}}@media (prefers-reduced-motion:reduce){.sqc-launcher,.sqc-panel,.sqc-btn,.sqc-suggestion,.sqc-choice,.sqc-confirm__btn,.sqc-icon-btn,.sqc-icon-btn[data-tip]:after{transition:none}.sqc-typing i,.sqc-caret{animation:none}}.sqc-with-human{border:1px solid var(--sqc-border);background:var(--sqc-selected);color:var(--sqc-neutral-600);border-radius:12px;margin:8px 0 0;padding:8px 12px;font-size:13px}`;function Sn(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function Cn(e,t){Sn(e,t),t.add(e)}function X(e,t,n){Sn(e,t),t.set(e,n)}function Z(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function Q(e,t,n){return e.set(Z(e,t),n),n}function $(e,t){return e.get(Z(e,t))}var wn=`squadico-chatbot`,Tn=[`embed-key`,`context`,`user`,`agent`,`heading`,`subheading`,`assistant-name`,`placeholder`,`greeting`,`suggestions`,`width`,`accent`,`theme`,`position`,`open`,`persist-open`,`locale`],En;function Dn(){if(En!==void 0)return En;try{let e=new CSSStyleSheet;e.replaceSync(xn),En=e}catch{En=null}return En}function On(e,t){typeof console<`u`&&console.warn(`[${wn}] ${e}`,t??``)}function kn(e){if(!(!e||!e.trim()))try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t;if(typeof e.id==`string`&&e.id)return{id:e.id,name:typeof e.name==`string`&&e.name?e.name:void 0,digest:typeof e.digest==`string`&&e.digest?e.digest:void 0}}On(`the "user" attribute needs an object with an id`,e)}catch(e){On(`the "user" attribute is not valid JSON`,e)}}function An(e){if(!(!e||!e.trim()))try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t;On("the `context` attribute must be a JSON object",e)}catch(e){On("the `context` attribute is not valid JSON",e)}}function jn(e){if(!(!e||!e.trim())){if(e.trim().startsWith(`[`))try{let t=JSON.parse(e);if(Array.isArray(t))return t.map(String)}catch(e){On("the `suggestions` attribute is not valid JSON",e);return}return e.split(`|`).map(e=>e.trim()).filter(Boolean)}}function Mn(e){if(e!==null)return e!==`false`&&e!==`0`}function Nn(e){return e===`dark`||e===`light`||e===`auto`?e:void 0}function Pn(e){return e===`bottom-left`||e===`bottom-right`?e:void 0}function Fn(){var e,t,n,r,i,a,o,s,c,l,u,d,f;return t=new WeakMap,n=new WeakMap,r=new WeakMap,i=new WeakMap,a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakSet,d=new WeakMap,f=new WeakMap,e=class extends HTMLElement{constructor(){super(),Cn(this,u),X(this,t,void 0),X(this,n,null),X(this,r,!1),X(this,i,!1),X(this,a,``),X(this,o,void 0),X(this,s,void 0),X(this,c,void 0),X(this,l,void 0),X(this,d,e=>{let{type:t,...n}=e;Q(a,this,n.sessionId),this.dispatchEvent(new CustomEvent(t,{detail:n,bubbles:!0,composed:!0}))}),X(this,f,e=>{Q(n,this,e),e&&Q(a,this,e.sessionId())});let e=this.attachShadow({mode:`open`}),p=Dn();if(p)e.adoptedStyleSheets=[p];else{let t=document.createElement(`style`);t.textContent=xn,e.append(t)}Q(t,this,document.createElement(`div`)),e.append($(t,this))}connectedCallback(){Q(i,this,!0),Z(u,this,m).call(this)}disconnectedCallback(){Q(i,this,!1),oe(null,$(t,this)),Q(n,this,null)}attributeChangedCallback(e,t,r){if(t!==r){if(e===`open`&&$(n,this)){Mn(r)?$(n,this).open():$(n,this).close();return}Z(u,this,p).call(this)}}get context(){return $(o,this)??An(this.getAttribute(`context`))}set context(e){Q(o,this,e),Z(u,this,p).call(this)}get embedKey(){return $(l,this)??this.getAttribute(`embed-key`)??void 0}set embedKey(e){Q(l,this,e),Z(u,this,p).call(this)}get user(){return $(s,this)??kn(this.getAttribute(`user`))}set user(e){Q(s,this,e),Z(u,this,p).call(this)}get agent(){return $(c,this)??this.getAttribute(`agent`)??void 0}set agent(e){Q(c,this,e),Z(u,this,p).call(this)}get open(){return $(n,this)?.isOpen()??Mn(this.getAttribute(`open`))??!1}set open(e){e?this.openChat():this.closeChat()}get sessionId(){return $(n,this)?.sessionId()??$(a,this)}openChat(){$(n,this)?.open()}closeChat(){$(n,this)?.close()}toggleChat(){$(n,this)?.toggle()}reset(){$(n,this)?.reset()}sendMessage(e){if(!$(n,this)){On(`sendMessage() called before the component was mounted — ignored`);return}$(n,this).send(e)}},qe(e,`observedAttributes`,Tn),e;function p(){$(r,this)||!$(i,this)||(Q(r,this,!0),queueMicrotask(()=>{Q(r,this,!1),$(i,this)&&Z(u,this,m).call(this)}))}function m(){let e=e=>this.getAttribute(e)??void 0;oe(J(bn,{embedKey:this.embedKey,context:this.context,user:this.user,agent:this.agent,heading:e(`heading`),subheading:e(`subheading`),assistantName:e(`assistant-name`),placeholder:e(`placeholder`),greeting:e(`greeting`),suggestions:jn(this.getAttribute(`suggestions`)),width:e(`width`),accent:e(`accent`),theme:Nn(this.getAttribute(`theme`)),position:Pn(this.getAttribute(`position`)),defaultOpen:Mn(this.getAttribute(`open`))??!1,persistOpen:Mn(this.getAttribute(`persist-open`))??!0,locale:e(`locale`),onEvent:$(d,this),bind:$(f,this)}),$(t,this))}}var In;function Ln(e=wn){typeof window>`u`||typeof HTMLElement>`u`||(In??(In=Fn()),window.customElements.get(e)||window.customElements.define(e,In))}return Ln(),e.API_URL=Je,e.ChatHttpError=q,e.DEFAULT_LANGUAGE=Me,e.MAX_MESSAGE_LENGTH=Ye,e.SUPPORTED_LANGUAGES=Ne,e.TAG_NAME=wn,e.defineChatbot=Ln,e})({});
|
|
5
|
+
`),e)},e)),a=[]},l=()=>{if(!o.length)return;let e=0;for(;e<o.length;){let t=`l${i.length}`,[n,r]=an(o,e,o[e].depth,t);i.push(n),e=r}o=[]},u=()=>{if(!s.length)return;let e=`q${i.length}`;i.push(J(`blockquote`,{children:Y(s.join(`
|
|
6
|
+
`),e)},e)),s=[]},d=()=>{c(),l(),u()};for(let e=0;e<r.length;e+=1){let f=r[e];if(nn.test(f)){d();let t=[];for(e+=1;e<r.length&&!nn.test(r[e]);)t.push(r[e]),e+=1;let n=`c${i.length}`;i.push(J(`pre`,{children:J(`code`,{children:t.join(`
|
|
7
|
+
`)})},n));continue}if(en.test(f)&&e+1<r.length&&tn.test(r[e+1])){d();let t=rn(f),n=[];for(e+=2;e<r.length&&en.test(r[e]);)n.push(rn(r[e])),e+=1;--e;let a=`t${i.length}`;i.push(J(`div`,{class:`sqc-table`,children:J(`table`,{children:[J(`thead`,{children:J(`tr`,{children:t.map((e,t)=>J(`th`,{children:Y(e,`${a}-h${t}`)},`${a}-h${t}`))})}),J(`tbody`,{children:n.map((e,n)=>J(`tr`,{children:t.map((t,r)=>J(`td`,{children:Y(e[r]??``,`${a}-r${n}c${r}`)},`${a}-r${n}c${r}`))},`${a}-r${n}`))})]})},a));continue}if(!f.trim()){d();continue}if(qt.test(f)){d();let a=[];for(;e<r.length;){let t=qt.exec(r[e]);if(!t)break;let n=t[2].trim(),o=`o${i.length}-${a.length}`;a.push({label:Jt(n),checked:t[1].toLowerCase()===`x`,content:Y(n,o)}),e+=1}--e,i.push(J(Ht,{items:a,locale:t,onPick:n},`o${i.length}`));continue}let p=Zt.exec(f);if(p){d();let e=p[1].length,t=e<=2?`h3`:e===3?`h4`:`h5`,n=`h${i.length}`;i.push(J(t,{children:Y(p[2],n)},n));continue}if(Qt.test(f)){d(),i.push(J(`hr`,{},`r${i.length}`));continue}let m=$t.exec(f);if(m){c(),l(),s.push(m[1]);continue}let h=Yt.exec(f),g=h?null:Xt.exec(f),_=h??g;if(_){c(),u(),o.push({depth:_[1].replace(/\t/g,` `).length,ordered:!!g,text:f.slice(_[0].length)});continue}l(),u(),a.push(f)}return d(),J(C,{children:i})}var sn=80;function cn({at:e,locale:t}){let n=new Date(e);return J(`time`,{class:`sqc-msg__time`,dateTime:n.toISOString(),children:n.toLocaleTimeString(t.tag,{hour:`2-digit`,minute:`2-digit`})})}function ln({file:e,load:t}){let[n,r]=H(null);return U(()=>{let n=null,i=!0;return t(e.id).then(e=>{i&&(n=URL.createObjectURL(e),r(n))}).catch(()=>{}),()=>{i=!1,n&&URL.revokeObjectURL(n)}},[e.id,t]),n?J(`img`,{class:`sqc-attachment__image`,src:n,alt:e.filename}):J(`span`,{class:`sqc-chip sqc-chip--waiting`,children:e.filename})}function un({files:e,load:t}){return e.length===0||!t?null:J(`div`,{class:`sqc-attachments sqc-attachments--sent`,children:e.map(e=>e.kind===`image`?J(ln,{file:e,load:t},e.id):J(`span`,{class:`sqc-chip`,"data-kind":`document`,children:J(`span`,{class:`sqc-chip__name`,children:e.filename})},e.id))})}function dn({message:e,locale:t,assistantName:n,onChoice:r,onDecide:i,onLoadAttachment:a}){let o=e.streaming&&!e.content,s=!!e.approval;return J(`div`,{class:`sqc-msg sqc-msg--${e.role}${e.error?` sqc-msg--error`:``}`,children:[e.role===`assistant`&&J(`div`,{class:`sqc-msg__who`,children:[e.agent?.avatarEmoji?J(`span`,{class:`sqc-msg__emoji`,"aria-hidden":`true`,children:e.agent.avatarEmoji}):J(pn,{}),e.authorName??e.agent?.name??n]}),J(`div`,{class:`sqc-msg__bubble`,children:[o?J(`span`,{class:`sqc-typing`,"aria-label":t.t.typing,children:[J(`i`,{}),J(`i`,{}),J(`i`,{})]}):J(`div`,{class:`sqc-msg__body`,children:[J(on,{text:e.content,locale:t,onChoice:r}),e.streaming&&J(`span`,{class:`sqc-caret`,"aria-hidden":`true`}),s&&J(zt,{locale:t,call:e.content.trim()===``?e.approval:void 0,onDecide:i}),!s&&!e.streaming&&!e.error&&Ft(e.content,t.code)&&J(Bt,{locale:t,onPick:r}),e.unknownHandle&&!e.streaming&&J(fn,{message:e,locale:t}),J(un,{files:e.attachments??[],load:a})]}),!o&&J(cn,{at:e.createdAt,locale:t})]})]})}function fn({message:e,locale:t}){let n=e.offered??[];return J(`p`,{class:`sqc-msg__unaddressed`,children:[J(`span`,{children:t.t.handles.unknown}),` `,J(`code`,{children:[`@`,e.unknownHandle]}),n.length>0&&J(C,{children:[` `,J(`span`,{children:t.t.handles.instead}),` `,n.map(e=>J(`code`,{children:[`@`,e.handle]},e.handle))]})]})}function pn(){return J(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:J(`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`})})}function mn({messages:e,locale:t,assistantName:n,suggestions:r,showSuggestions:i,busy:a,withHuman:o,onSuggestion:s,onChoice:c,onDecide:l,onLoadAttachment:u}){let d=W(null),f=W(!0);return ye(()=>{let e=d.current;e&&f.current&&(e.scrollTop=e.scrollHeight)},[e]),U(()=>{let e=d.current;if(!e)return;let t=()=>{f.current=e.scrollHeight-e.scrollTop-e.clientHeight<sn};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),J(`div`,{class:`sqc-messages`,ref:d,role:`log`,"aria-live":`polite`,"aria-atomic":`false`,children:[e.map((r,i)=>J(dn,{message:r,locale:t,assistantName:n,onChoice:!a&&r.role===`assistant`&&i===e.length-1?c:void 0,onDecide:!a&&r.role===`assistant`&&i===e.length-1?l:void 0,onLoadAttachment:u},r.id)),o&&J(`p`,{class:`sqc-with-human`,role:`status`,children:t.t.withHuman}),i&&r&&r.length>0&&J(`div`,{class:`sqc-suggestions`,children:r.map(e=>J(`button`,{type:`button`,class:`sqc-suggestion`,onClick:()=>s(e),children:e},e))})]})}var hn={width:`min(392px, 100vw)`},gn=new Set([`sessionId`]);function _n(e){let t=e.replace(/Id$|Ref$/,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):e}function vn(e){if(!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if(gn.has(n)||typeof r!=`string`&&!Ae(r))continue;let e=ke(r);e&&t.push({label:_n(n),value:e})}return t}function yn(e,t){return e?.trim()?e:t}function bn(e){let[t,n]=H(!1);return U(()=>{if(e!==`auto`||typeof matchMedia!=`function`)return;let t=matchMedia(`(prefers-color-scheme: dark)`);n(t.matches);let r=e=>n(e.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),e===`dark`?`dark`:e===`light`?`light`:t?`dark`:`light`}function xn(e){let t=e.persistOpen??!0,[n,r]=H(()=>He(e.defaultOpen,t)),[i,a]=H(!1),[o,s]=H(!1),c=W(null),l=W(null),u=bn(e.theme??`light`),d=G(()=>Re(e.locale),[e.locale]),f=d.t,p=yn(e.heading,f.heading),m=yn(e.assistantName,f.assistant),h=yn(e.greeting,f.greeting),g=e.onEvent,{send:_,reset:v,decide:y,stop:b,start:x,busy:S,messages:C,withHuman:w,sessionId:T,handles:E,addressee:D,attachments:O,uploading:k,attachmentError:A,attach:j,detach:M,loadAttachment:N}=Tt({embedKey:e.embedKey,user:e.user,getSubjectToken:e.getSubjectToken,agent:e.agent,context:e.context,greeting:h,locale:d,onEvent:g});U(()=>{!n&&C.some(e=>e.role===`assistant`&&e.id!==`greeting`)&&s(!0)},[C,n]);let P=W(n);P.current=n;let F=K(()=>{s(!1),!P.current&&(P.current=!0,r(!0),t&&Ve(!0),g?.({type:`chatbot-open`,sessionId:T}))},[g,t,T]),I=K(()=>{P.current&&(P.current=!1,r(!1),t&&Ve(!1),g?.({type:`chatbot-close`,sessionId:T}),l.current?.focus())},[g,t,T]);U(()=>{n&&x()},[n,x]);let L=K(e=>{a(!0),_(e)},[_]),R=K(()=>{a(!1),s(!1),v()},[v]),z=W({openPanel:F,closePanel:I,send:L,reset:R,sessionId:T});z.current={openPanel:F,closePanel:I,send:L,reset:R,sessionId:T};let ee=W({open:()=>z.current.openPanel(),close:()=>z.current.closePanel(),toggle:()=>P.current?z.current.closePanel():z.current.openPanel(),reset:()=>z.current.reset(),send:e=>{z.current.openPanel(),z.current.send(e)},isOpen:()=>P.current,sessionId:()=>z.current.sessionId}),te=e.bind;ye(()=>(te?.(ee.current),()=>te?.(null)),[te]),U(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),I())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[I,n]);let ne=G(()=>C.some(e=>e.id!==`greeting`),[C]),re=G(()=>vn(e.context),[e.context]),ie={...e.accent?{"--sqc-accent":e.accent}:{},"--sqc-width":e.width??hn.width};return J(`div`,{class:`sqc`,"data-theme":u,"data-position":e.position??`bottom-right`,"data-layout":e.layout??`sidebar`,"data-open":n?`true`:`false`,style:ie,children:[J(`button`,{ref:l,type:`button`,class:`sqc-launcher`,"aria-label":p,"aria-expanded":n,"aria-haspopup":`dialog`,onClick:F,children:[J(`span`,{class:`sqc-launcher__icon`,children:J(`slot`,{name:`launcher-icon`,class:`sqc-slot-icon`,children:J(pn,{})})}),o&&J(`span`,{class:`sqc-launcher__badge`,"aria-hidden":`true`})]}),J(`aside`,{ref:c,class:`sqc-panel`,role:`dialog`,"aria-modal":`false`,"aria-label":p,...n?{}:{inert:!0},children:[J(`header`,{class:`sqc-header`,children:[J(`span`,{class:`sqc-header__icon`,"aria-hidden":`true`,children:J(pn,{})}),J(`div`,{class:`sqc-header__titles`,children:[J(`p`,{class:`sqc-header__heading`,children:p}),J(`p`,{class:`sqc-header__sub`,children:yn(e.subheading,f.subheading)})]}),J(`button`,{type:`button`,class:`sqc-icon-btn`,onClick:R,"aria-label":f.newConversation,"data-tip":f.newConversation,children:J(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,children:J(`path`,{d:`M20 12a8 8 0 1 1-2.6-5.9M20 4v4h-4`,"stroke-linecap":`round`})})}),J(`button`,{type:`button`,class:`sqc-icon-btn`,onClick:I,"aria-label":f.close,"data-tip":f.closeTitle,children:J(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,children:J(`path`,{d:`M6 6l12 12M18 6L6 18`,"stroke-linecap":`round`})})})]}),re.length>0&&J(`div`,{class:`sqc-context`,"aria-label":f.context.region,children:re.map(e=>J(`span`,{class:`sqc-chip`,title:`${e.label}: ${e.value}`,children:[J(`b`,{children:e.label}),e.value]},e.label))}),J(mn,{messages:C,locale:d,assistantName:m,suggestions:e.suggestions,showSuggestions:!i&&!ne,busy:S,withHuman:w,onSuggestion:L,onChoice:L,onDecide:y,onLoadAttachment:N}),J(jt,{placeholder:yn(e.placeholder,f.placeholder),locale:d,busy:S,autoFocus:n,handles:E,addressee:D,attachments:O,uploading:k,attachmentError:A?f.attachments[A]:void 0,onAttach:j,onDetach:M,onSend:L,onStop:b}),J(`p`,{class:`sqc-hint`,children:f.hint})]})]})}var Sn=`:host{--sqc-width:min(392px, 100vw);--sqc-height:640px;--sqc-z:2147480000;--sqc-radius:16px;--sqc-font-family:"Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;--sqc-font-heading:var(--sqc-font-family);z-index:var(--sqc-z);pointer-events:none;font-family:var(--sqc-font-family);-webkit-font-smoothing:antialiased;text-align:left;font-size:14px;line-height:1.5;display:block;position:fixed;top:0;bottom:0;left:0;right:0;margin:0!important}:host([hidden]){display:none}.sqc{--sqc-neutral-50:#f8fafc;--sqc-neutral-100:#f1f5f9;--sqc-neutral-200:#e2e8f0;--sqc-neutral-300:#cbd5e1;--sqc-neutral-400:#94a3b8;--sqc-neutral-500:#64748b;--sqc-neutral-600:#475569;--sqc-neutral-900:#0f172a;--sqc-error-50:#fff1f2;--sqc-error-100:#ffe4e6;--sqc-error-600:#e11d48;--sqc-accent-default:#000;--sqc-accent-color:var(--sqc-accent,var(--sqc-accent-default));--sqc-on-accent:#fff;--sqc-accent-hover:color-mix(in oklab, var(--sqc-accent-color) 84%, var(--sqc-on-accent));--sqc-accent-fg:var(--sqc-accent,var(--sqc-text));--sqc-bg:#fff;--sqc-surface:var(--sqc-neutral-50);--sqc-selected:var(--sqc-neutral-100);--sqc-border:var(--sqc-neutral-200);--sqc-border-strong:var(--sqc-neutral-300);--sqc-text:var(--sqc-neutral-900);--sqc-text-muted:var(--sqc-neutral-500);--sqc-link:#2563eb;--sqc-bubble-user:var(--sqc-accent-color);--sqc-bubble-user-text:var(--sqc-on-accent);--sqc-code-bg:var(--sqc-neutral-100);--sqc-disabled:var(--sqc-neutral-300);--sqc-shadow:0 10px 15px -3px #0f172a1a, 0 4px 6px -4px #0f172a1a;--sqc-shadow-bottom:0 6px 8px -6px #0f172a2e;--sqc-focus:0 0 0 2px var(--sqc-bg), 0 0 0 4px #0f172a4d;--sqc-focus-input:0 0 0 3px #0f172a1a;--sqc-danger:var(--sqc-error-600);color:var(--sqc-text);position:absolute;top:0;bottom:0;left:0;right:0}.sqc[data-theme=dark]{--sqc-neutral-50:#172033;--sqc-neutral-100:#1e293b;--sqc-neutral-200:#334155;--sqc-neutral-300:#475569;--sqc-neutral-400:#64748b;--sqc-neutral-500:#94a3b8;--sqc-neutral-600:#cbd5e1;--sqc-neutral-900:#f8fafc;--sqc-error-50:#2a0a12;--sqc-error-100:#4c0519;--sqc-error-600:#fb7185;--sqc-accent-default:#fff;--sqc-on-accent:#0f172a;--sqc-bg:#0f172a;--sqc-link:#60a5fa;--sqc-code-bg:#020617;--sqc-shadow:0 10px 24px -4px #0000008c;--sqc-shadow-bottom:0 6px 8px -6px #0000008c;--sqc-focus:0 0 0 2px var(--sqc-bg), 0 0 0 4px #f8fafc59;--sqc-focus-input:0 0 0 3px #f8fafc1f}@supports (color:oklch(from red l c h)){.sqc{--sqc-on-accent:oklch(from var(--sqc-accent-color) clamp(.208, (.62 - l) * 1000, 1) 0 0)}}.sqc *,.sqc :before,.sqc :after{box-sizing:border-box}.sqc-launcher{background:var(--sqc-accent-color);width:56px;height:56px;color:var(--sqc-on-accent);cursor:pointer;pointer-events:auto;box-shadow:var(--sqc-shadow);border:none;border-radius:50%;place-items:center;padding:0;transition:transform .18s,opacity .18s,background .18s,box-shadow .18s;display:grid;position:absolute;bottom:24px;right:24px}.sqc[data-position=bottom-left] .sqc-launcher{left:24px;right:auto}.sqc-launcher:hover{background:var(--sqc-accent-hover);transform:scale(1.06)}.sqc-launcher:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc[data-open=true] .sqc-launcher{opacity:0;pointer-events:none;transform:scale(.5)}.sqc-launcher__icon svg{width:26px;height:26px;display:block}.sqc-slot-icon::slotted(*){justify-content:center;align-items:center;width:26px;height:26px;display:inline-flex}.sqc-launcher__badge{background:var(--sqc-error-600);border:2px solid var(--sqc-bg);border-radius:50%;width:12px;height:12px;position:absolute;top:6px;right:6px}.sqc-panel{width:var(--sqc-width);background:var(--sqc-bg);border-left:1px solid var(--sqc-border);box-shadow:var(--sqc-shadow);pointer-events:auto;visibility:hidden;flex-direction:column;transition:transform .26s cubic-bezier(.22,1,.36,1),visibility 0s linear .26s;display:flex;position:absolute;top:0;bottom:0;right:0;transform:translate(100%)}.sqc[data-open=true] .sqc-panel{visibility:visible;transition:transform .26s cubic-bezier(.22,1,.36,1),visibility;transform:translate(0)}.sqc[data-layout=floating] .sqc-panel{max-width:calc(100% - 48px);height:var(--sqc-height);border:1px solid var(--sqc-border);border-radius:var(--sqc-radius);opacity:0;transform-origin:100% 100%;max-height:calc(100% - 48px);transition:transform .22s cubic-bezier(.22,1,.36,1),opacity .22s,visibility 0s linear .22s;top:auto;bottom:24px;right:24px;overflow:hidden;transform:translateY(16px)scale(.96)}.sqc[data-layout=floating][data-position=bottom-left] .sqc-panel{transform-origin:0 100%;left:24px;right:auto}.sqc[data-layout=floating][data-open=true] .sqc-panel{opacity:1;transition:transform .22s cubic-bezier(.22,1,.36,1),opacity .22s,visibility;transform:none}.sqc-header{background:var(--sqc-bg);color:var(--sqc-text);border-bottom:1px solid var(--sqc-border);flex-shrink:0;align-items:center;gap:8px;padding:13px 12px 13px 16px;display:flex}.sqc-header__icon{color:var(--sqc-accent-fg);flex-shrink:0;place-items:center;display:grid}.sqc-header__icon svg{width:17px;height:17px;display:block}.sqc-header__titles{flex:1;min-width:0}.sqc-header__heading,.sqc-header__sub{text-overflow:ellipsis;white-space:nowrap;margin:0;overflow:hidden}.sqc-header__heading{font-family:var(--sqc-font-heading);letter-spacing:-.2px;font-size:15px;font-weight:700}.sqc-header__sub{color:var(--sqc-text-muted);font-size:12px}.sqc-icon-btn{width:26px;height:26px;color:var(--sqc-text-muted);cursor:pointer;background:0 0;border:none;border-radius:8px;flex-shrink:0;place-items:center;transition:background .15s;display:grid}.sqc-icon-btn:hover{background:var(--sqc-surface);color:var(--sqc-text)}.sqc-icon-btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-icon-btn svg{width:16px;height:16px}.sqc-icon-btn[data-tip]{position:relative}.sqc-icon-btn[data-tip]:after{content:attr(data-tip);z-index:6;background:var(--sqc-text);color:var(--sqc-bg);font-family:var(--sqc-font-family);white-space:nowrap;pointer-events:none;opacity:0;border-radius:8px;padding:4px 8px;font-size:11px;font-weight:500;line-height:1.3;transition:opacity .12s .15s;position:absolute;top:calc(100% + 6px);right:0}.sqc-icon-btn[data-tip]:hover:after{opacity:1}.sqc-icon-btn[data-tip]:focus-visible:after{opacity:1}.sqc-history-pop{z-index:5;position:absolute;top:54px;left:0;right:0}.sqc-history{background:var(--sqc-bg);max-height:320px;box-shadow:var(--sqc-shadow-bottom);flex-direction:column;display:flex;overflow-y:auto}.sqc-history__empty{color:var(--sqc-text-muted);text-align:center;margin:0;padding:14px 16px;font-size:12px}.sqc-history__item{border:none;border-bottom:1px solid var(--sqc-border);width:100%;color:var(--sqc-text);text-align:left;cursor:pointer;background:0 0;flex-direction:column;gap:2px;padding:10px 16px;transition:background .15s;display:flex}.sqc-history__item:last-child{border-bottom:none}.sqc-history__item:hover{background:var(--sqc-surface)}.sqc-history__item:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-history__item[aria-current=true]{background:var(--sqc-selected)}.sqc-history__item[aria-current=true] .sqc-history__title{color:var(--sqc-text);font-weight:600}.sqc-history__title{text-overflow:ellipsis;white-space:nowrap;font-size:13px;overflow:hidden}.sqc-history__date{color:var(--sqc-text-muted);font-size:11px}.sqc-context{background:var(--sqc-selected);border:1px solid var(--sqc-border);color:var(--sqc-text);border-radius:12px;flex-wrap:wrap;flex-shrink:0;align-items:center;gap:8px;margin:12px 16px 4px;padding:8px 11px;font-size:12px;display:flex}.sqc-chip{text-overflow:ellipsis;white-space:nowrap;align-items:baseline;gap:4px;max-width:100%;display:inline-flex;overflow:hidden}.sqc-chip b{font-weight:600}.sqc-chip:not(:last-child):after{content:"·";opacity:.5;margin-left:4px}.sqc-messages{overscroll-behavior:contain;background:var(--sqc-bg);scrollbar-width:thin;scrollbar-color:var(--sqc-neutral-300) transparent;flex-direction:column;flex:1;gap:13px;min-height:0;padding:12px 16px;display:flex;overflow-y:auto}.sqc-messages::-webkit-scrollbar{width:6px}.sqc-messages::-webkit-scrollbar-thumb{background:var(--sqc-neutral-300);border-radius:99px}.sqc-msg{flex-direction:column;max-width:93%;font-size:13.5px;display:flex}.sqc-msg--assistant{align-self:flex-start}.sqc-msg--user{align-self:flex-end}.sqc-msg__who{color:var(--sqc-text-muted);align-items:center;gap:6px;margin-bottom:4px;font-size:11px;font-weight:500;display:flex}.sqc-msg__who svg{width:12px;height:12px;color:var(--sqc-accent-fg);flex-shrink:0}.sqc-msg__unaddressed{color:var(--sqc-text-muted);margin:8px 0 0;font-size:11.5px;line-height:1.5}.sqc-msg__unaddressed code{background:var(--sqc-code-bg);color:var(--sqc-text);border-radius:4px;margin-right:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11px}.sqc-msg--user .sqc-msg__bubble{background:var(--sqc-bubble-user);color:var(--sqc-bubble-user-text);border-radius:var(--sqc-radius) var(--sqc-radius) 4px var(--sqc-radius);padding:9px 13px}.sqc-msg--error .sqc-msg__bubble{background:var(--sqc-error-50);color:var(--sqc-error-600);border:1px solid var(--sqc-error-100);border-radius:12px;padding:11px}.sqc-msg__body{overflow-wrap:anywhere}.sqc-msg--assistant .sqc-msg__body{font-size:14px;line-height:1.6}.sqc-msg__body>:first-child{margin-top:0}.sqc-msg__body>:last-child{margin-bottom:0}.sqc-msg__body p{white-space:pre-wrap;margin:0 0 8px}.sqc-msg__body ul,.sqc-msg__body ol{margin:0 0 8px;padding-left:20px}.sqc-msg__body li{margin-bottom:3px}.sqc-msg__body code{background:var(--sqc-code-bg);border-radius:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.85em}.sqc-msg--user .sqc-msg__body code{background:#ffffff38}.sqc-msg__body pre{background:var(--sqc-code-bg);border-radius:8px;margin:0 0 8px;padding:9px 11px;overflow-x:auto}.sqc-msg__body pre code{background:0 0;padding:0}.sqc-msg__body a{color:inherit;text-underline-offset:2px;text-decoration:underline}.sqc-msg--assistant .sqc-msg__body a{color:var(--sqc-link);text-decoration:none}.sqc-msg--assistant .sqc-msg__body a:hover{text-decoration:underline}.sqc-msg__body h3,.sqc-msg__body h4,.sqc-msg__body h5,.sqc-msg__body h6{font-family:var(--sqc-font-heading);letter-spacing:-.2px;margin:12px 0 6px;font-weight:700;line-height:1.3}.sqc-msg__body h3{font-size:1.05em}.sqc-msg__body h4{font-size:1em}.sqc-msg__body h5,.sqc-msg__body h6{font-size:.94em}.sqc-msg__body ul ul,.sqc-msg__body ul ol,.sqc-msg__body ol ul,.sqc-msg__body ol ol{margin:3px 0 0}.sqc-msg__body blockquote{border-left:2px solid var(--sqc-border-strong);color:var(--sqc-text-muted);white-space:pre-wrap;margin:0 0 8px;padding:2px 0 2px 10px}.sqc-msg--user .sqc-msg__body blockquote{color:inherit;opacity:.85;border-left-color:#ffffff73}.sqc-msg__body hr{border:0;border-top:1px solid var(--sqc-border);margin:10px 0}.sqc-msg--user .sqc-msg__body hr{border-top-color:#ffffff4d}.sqc-msg__body del{opacity:.7}.sqc-approval{flex-direction:column;gap:8px;margin:11px 0 2px;display:flex}.sqc-approval__actions{flex-wrap:wrap;gap:8px;display:flex}.sqc-approval__request{color:var(--sqc-text);margin:0;font-size:13px}.sqc-approval__args{border:1px solid var(--sqc-border);background:var(--sqc-surface);border-radius:12px;flex-direction:column;gap:4px;margin:0;padding:8px 10px;font-size:12px;display:flex}.sqc-approval__arg{gap:8px;display:flex}.sqc-approval__arg-name{color:var(--sqc-text-muted);flex:none;font-weight:500}.sqc-approval__arg-value{overflow-wrap:anywhere;min-width:0;color:var(--sqc-text);margin:0}.sqc-approval__btn{height:32px;font-family:var(--sqc-font-family);border:1px solid var(--sqc-border);background:var(--sqc-bg);color:var(--sqc-text);cursor:pointer;border-radius:12px;flex:auto;justify-content:center;align-items:center;padding:0 12px;font-size:13px;font-weight:500;transition:border-color .12s,background .12s;display:inline-flex}.sqc-approval__btn--yes:not(:disabled),.sqc-approval__btn--send:not(:disabled){background:var(--sqc-accent-color);color:var(--sqc-on-accent);border-color:#0000;font-weight:600}.sqc-approval__btn:hover:not(:disabled){border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-approval__btn--yes:hover:not(:disabled),.sqc-approval__btn--send:hover:not(:disabled){background:var(--sqc-accent-hover);border-color:#0000}.sqc-approval__btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-approval__btn:disabled{cursor:default}.sqc-approval__btn:disabled[aria-pressed=false]{opacity:.45}.sqc-approval__btn[aria-pressed=true]{border-color:var(--sqc-border-strong);background:var(--sqc-selected);color:var(--sqc-text);font-weight:600}.sqc-approval__edit{flex-direction:column;gap:8px;display:flex}.sqc-approval__input{width:100%;font-family:var(--sqc-font-family);color:var(--sqc-text);background:var(--sqc-bg);border:1px solid var(--sqc-border-strong);resize:vertical;border-radius:12px;padding:8px 10px;font-size:13px;line-height:1.4}.sqc-approval__input:focus-visible{border-color:var(--sqc-text);box-shadow:var(--sqc-focus-input);outline:none}.sqc-approval__btn--send{flex:none;align-self:flex-end}.sqc-confirm{gap:8px;margin:11px 0 2px;display:flex}.sqc-confirm__btn{height:32px;font-family:var(--sqc-font-family);border:1px solid var(--sqc-border);background:var(--sqc-bg);color:var(--sqc-text);cursor:pointer;border-radius:12px;flex:1 1 0;justify-content:center;align-items:center;padding:0 12px;font-size:13px;font-weight:500;transition:border-color .12s,background .12s;display:inline-flex}.sqc-confirm__btn--yes:not(:disabled){background:var(--sqc-accent-color);color:var(--sqc-on-accent);border-color:#0000;font-weight:600}.sqc-confirm__btn:hover:not(:disabled){border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-confirm__btn--yes:hover:not(:disabled){background:var(--sqc-accent-hover);border-color:#0000}.sqc-confirm__btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-confirm__btn:disabled{cursor:default}.sqc-confirm__btn:disabled[aria-pressed=false]{opacity:.45}.sqc-confirm__btn[aria-pressed=true]{border-color:var(--sqc-border-strong);background:var(--sqc-selected);color:var(--sqc-text);font-weight:600}.sqc-choices{flex-direction:column;gap:7px;margin:10px 0 2px;display:flex}.sqc-choice{width:100%;font-family:var(--sqc-font-family);text-align:left;color:var(--sqc-text);background:var(--sqc-bg);border:1px solid var(--sqc-border);cursor:pointer;border-radius:12px;align-items:center;gap:8px;padding:8px 11px;font-size:12.5px;transition:border-color .12s,background .12s;display:flex}.sqc-choice:hover:not(:disabled){border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-choice:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-choice:disabled{cursor:default}.sqc-choice:disabled[aria-pressed=false]{opacity:.55}.sqc-choice[aria-pressed=true]{border-color:var(--sqc-border-strong);background:var(--sqc-selected)}.sqc-choice__box{border:1.5px solid var(--sqc-border-strong);border-radius:4px;flex:none;justify-content:center;align-items:center;width:15px;height:15px;display:inline-flex}.sqc-choice__box--on{color:var(--sqc-on-accent);background:var(--sqc-accent-color);border-color:var(--sqc-accent-color)}.sqc-choice__box svg{width:11px;height:11px}.sqc-choice__label{overflow-wrap:anywhere}.sqc-choice__detail{color:var(--sqc-text-muted);margin-top:1px;font-size:11.5px;display:block}.sqc-selection{flex-direction:column;gap:10px;margin:2px 0;display:flex}.sqc-selection__question{flex-direction:column;gap:2px;display:flex}.sqc-selection__ask{font-family:var(--sqc-font-family);color:var(--sqc-text);margin:0;font-size:13px;font-weight:600}.sqc-selection__actions{display:flex}.sqc-selection__validate{height:32px;font-family:var(--sqc-font-family);color:var(--sqc-on-accent);background:var(--sqc-accent-color);cursor:pointer;border:1px solid #0000;border-radius:12px;flex:auto;justify-content:center;align-items:center;padding:0 12px;font-size:13px;font-weight:600;transition:filter .12s,background .12s;display:inline-flex}.sqc-selection__validate:hover:not(:disabled){background:var(--sqc-accent-hover)}.sqc-selection__validate:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-selection__validate:disabled{cursor:not-allowed;color:#fff;background:var(--sqc-disabled)}.sqc-selection__hint{font-family:var(--sqc-font-family);color:var(--sqc-text-muted);margin:0;font-size:11.5px}.sqc-table{scrollbar-width:thin;margin:0 0 8px;overflow-x:auto}.sqc-table table{border-collapse:collapse;min-width:100%;font-family:var(--sqc-font-family);white-space:nowrap;font-size:12.5px}.sqc-table th,.sqc-table td{text-align:left;vertical-align:top;border-bottom:1px solid var(--sqc-border);padding:6px 10px 6px 0}.sqc-table thead th{text-transform:uppercase;letter-spacing:.05em;color:var(--sqc-text-muted);font-size:10.5px;font-weight:600}.sqc-table tbody th{font-weight:500}.sqc-msg--user .sqc-table th,.sqc-msg--user .sqc-table td{border-bottom-color:#ffffff40}.sqc-msg--user .sqc-table thead th{color:#fffc}.sqc-table tbody tr:last-child th,.sqc-table tbody tr:last-child td{border-bottom:0}.sqc-msg__time{color:var(--sqc-text-muted);font-variant-numeric:tabular-nums;margin-top:3px;font-size:10px;display:block}.sqc-msg--user .sqc-msg__time{color:#ffffffb3;text-align:right}.sqc-caret{vertical-align:text-bottom;background:currentColor;width:2px;height:1em;margin-left:2px;animation:1s step-end infinite sqc-blink;display:inline-block}@keyframes sqc-blink{0%,to{opacity:1}50%{opacity:0}}.sqc-typing{gap:3px;padding:2px 0;display:inline-flex}.sqc-typing i{background:var(--sqc-neutral-400);border-radius:50%;width:5px;height:5px;animation:1.2s infinite sqc-pulse}.sqc-typing i:nth-child(2){animation-delay:.2s}.sqc-typing i:nth-child(3){animation-delay:.4s}@keyframes sqc-pulse{0%,60%,to{opacity:.25}30%{opacity:1}}.sqc-suggestions{flex-direction:column;gap:7px;display:flex}.sqc-suggestion{border:1px solid var(--sqc-border);background:var(--sqc-bg);width:100%;color:var(--sqc-text);font-family:var(--sqc-font-family);cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:8px;padding:8px 11px;font-size:12.5px;transition:background .15s,border-color .15s;display:flex}.sqc-suggestion:before{content:"";background:var(--sqc-accent-fg);border-radius:50%;flex:none;width:5px;height:5px}.sqc-suggestion:hover{background:var(--sqc-surface);border-color:var(--sqc-border-strong)}.sqc-suggestion:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-composer{border-top:1px solid var(--sqc-border);background:var(--sqc-bg);flex-wrap:wrap;flex-shrink:0;align-items:flex-end;gap:8px;padding:12px 14px;display:flex}.sqc-composer--dropping{outline:2px dashed var(--sqc-accent-color);outline-offset:-4px}.sqc-attachments{flex-wrap:wrap;flex-basis:100%;gap:6px;display:flex}.sqc-attachments--sent{margin-top:8px}.sqc-chip{border:1px solid var(--sqc-border);background:var(--sqc-selected);max-width:100%;color:var(--sqc-text);border-radius:999px;align-items:center;gap:4px;padding:3px 4px 3px 10px;font-size:12px;display:inline-flex}.sqc-chip--waiting{opacity:.6;padding-right:10px}.sqc-chip__name{text-overflow:ellipsis;white-space:nowrap;max-width:180px;overflow:hidden}.sqc-chip__remove{width:18px;height:18px;color:var(--sqc-text-muted);cursor:pointer;background:0 0;border:0;border-radius:999px;justify-content:center;align-items:center;padding:0;font-size:14px;line-height:1;display:inline-flex}.sqc-chip__remove:hover{background:var(--sqc-selected);color:var(--sqc-text)}.sqc-attachments__error{color:var(--sqc-error-600);flex-basis:100%;margin:0;font-size:12px}.sqc-attachment__image{border-radius:12px;max-width:100%;max-height:180px;display:block}.sqc-file-input{display:none}.sqc-btn--attach{color:var(--sqc-text-muted);background:0 0}.sqc-btn--attach:hover{background:var(--sqc-selected);color:var(--sqc-text)}.sqc-composer__field{flex:1;min-width:0;position:relative}.sqc-composer__input{border:1px solid var(--sqc-border-strong);background:var(--sqc-bg);width:100%;min-height:38px;max-height:132px;color:var(--sqc-text);font-family:var(--sqc-font-family);resize:none;border-radius:12px;outline:none;padding:9px 12px;font-size:13.5px;line-height:1.4;transition:border-color .15s,box-shadow .15s;display:block;overflow-y:hidden}.sqc-composer__input::placeholder{color:var(--sqc-neutral-400)}.sqc-composer__input:focus{border-color:var(--sqc-text);box-shadow:var(--sqc-focus-input)}.sqc-mentions{z-index:2;border:1px solid var(--sqc-border);background:var(--sqc-bg);max-height:184px;box-shadow:var(--sqc-shadow);scrollbar-width:thin;border-radius:12px;margin:0;padding:4px;list-style:none;position:absolute;bottom:calc(100% + 6px);left:0;right:0;overflow-y:auto}.sqc-mention{cursor:pointer;color:var(--sqc-text);border-radius:8px;align-items:baseline;gap:6px;padding:6px 8px;font-size:12.5px;display:flex}.sqc-mention--active{background:var(--sqc-neutral-100)}.sqc-mention__icon{flex-shrink:0}.sqc-mention__handle{font-weight:600}.sqc-mention__name{text-overflow:ellipsis;white-space:nowrap;color:var(--sqc-text-muted);overflow:hidden}.sqc-composer__count{color:var(--sqc-text-muted);pointer-events:none;font-variant-numeric:tabular-nums;font-size:10px;position:absolute;bottom:4px;right:8px}.sqc-btn{cursor:pointer;border:none;border-radius:12px;flex-shrink:0;place-items:center;width:38px;height:38px;transition:background .15s,opacity .15s;display:grid}.sqc-btn svg{width:17px;height:17px}.sqc-btn--send{background:var(--sqc-accent-color);color:var(--sqc-on-accent)}.sqc-btn--send:hover:not(:disabled){background:var(--sqc-accent-hover)}.sqc-btn--send:disabled{background:var(--sqc-disabled);color:#fff;cursor:not-allowed}.sqc-btn--stop{background:var(--sqc-bg);color:var(--sqc-text);border:1px solid var(--sqc-border)}.sqc-btn--stop:hover{border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-hint{padding:0 16px max(9px, env(safe-area-inset-bottom));color:var(--sqc-text-muted);text-align:center;flex-shrink:0;margin:0;font-size:10.5px;line-height:1.35}@media (max-width:520px){.sqc{--sqc-width:100vw}.sqc-panel{border-left:none}.sqc-launcher{bottom:16px;right:16px}.sqc[data-position=bottom-left] .sqc-launcher{left:16px}.sqc[data-layout=floating] .sqc-panel,.sqc[data-layout=floating][data-position=bottom-left] .sqc-panel{border:none;border-radius:0;max-width:none;height:auto;max-height:none;top:0;bottom:0;left:0;right:0}}@media (prefers-reduced-motion:reduce){.sqc-launcher,.sqc-panel,.sqc-btn,.sqc-suggestion,.sqc-choice,.sqc-confirm__btn,.sqc-icon-btn,.sqc-icon-btn[data-tip]:after{transition:none}.sqc-typing i,.sqc-caret{animation:none}}.sqc-with-human{border:1px solid var(--sqc-border);background:var(--sqc-selected);color:var(--sqc-neutral-600);border-radius:12px;margin:8px 0 0;padding:8px 12px;font-size:13px}`;function Cn(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function wn(e,t){Cn(e,t),t.add(e)}function X(e,t,n){Cn(e,t),t.set(e,n)}function Z(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function Q(e,t,n){return e.set(Z(e,t),n),n}function $(e,t){return e.get(Z(e,t))}var Tn=`squadico-chatbot`,En=[`embed-key`,`context`,`user`,`agent`,`heading`,`subheading`,`assistant-name`,`placeholder`,`greeting`,`suggestions`,`width`,`accent`,`theme`,`position`,`layout`,`open`,`persist-open`,`locale`],Dn;function On(){if(Dn!==void 0)return Dn;try{let e=new CSSStyleSheet;e.replaceSync(Sn),Dn=e}catch{Dn=null}return Dn}function kn(e,t){typeof console<`u`&&console.warn(`[${Tn}] ${e}`,t??``)}function An(e){if(!(!e||!e.trim()))try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t;if(typeof e.id==`string`&&e.id)return{id:e.id,name:typeof e.name==`string`&&e.name?e.name:void 0,digest:typeof e.digest==`string`&&e.digest?e.digest:void 0}}kn(`the "user" attribute needs an object with an id`,e)}catch(e){kn(`the "user" attribute is not valid JSON`,e)}}function jn(e){if(!(!e||!e.trim()))try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t;kn("the `context` attribute must be a JSON object",e)}catch(e){kn("the `context` attribute is not valid JSON",e)}}function Mn(e){if(!(!e||!e.trim())){if(e.trim().startsWith(`[`))try{let t=JSON.parse(e);if(Array.isArray(t))return t.map(String)}catch(e){kn("the `suggestions` attribute is not valid JSON",e);return}return e.split(`|`).map(e=>e.trim()).filter(Boolean)}}function Nn(e){if(e!==null)return e!==`false`&&e!==`0`}function Pn(e){return e===`dark`||e===`light`||e===`auto`?e:void 0}function Fn(e){return e===`bottom-left`||e===`bottom-right`?e:void 0}function In(e){return e===`floating`||e===`sidebar`?e:void 0}function Ln(){var e,t,n,r,i,a,o,s,c,l,u,d,f,p;return t=new WeakMap,n=new WeakMap,r=new WeakMap,i=new WeakMap,a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,d=new WeakSet,f=new WeakMap,p=new WeakMap,e=class extends HTMLElement{constructor(){super(),wn(this,d),X(this,t,void 0),X(this,n,null),X(this,r,!1),X(this,i,!1),X(this,a,``),X(this,o,void 0),X(this,s,void 0),X(this,c,void 0),X(this,l,void 0),X(this,u,void 0),X(this,f,e=>{let{type:t,...n}=e;Q(a,this,n.sessionId),this.dispatchEvent(new CustomEvent(t,{detail:n,bubbles:!0,composed:!0}))}),X(this,p,e=>{Q(n,this,e),e&&Q(a,this,e.sessionId())});let e=this.attachShadow({mode:`open`}),m=On();if(m)e.adoptedStyleSheets=[m];else{let t=document.createElement(`style`);t.textContent=Sn,e.append(t)}Q(t,this,document.createElement(`div`)),e.append($(t,this))}connectedCallback(){Q(i,this,!0),Z(d,this,h).call(this)}disconnectedCallback(){Q(i,this,!1),ae(null,$(t,this)),Q(n,this,null)}attributeChangedCallback(e,t,r){if(t!==r){if(e===`open`&&$(n,this)){Nn(r)?$(n,this).open():$(n,this).close();return}Z(d,this,m).call(this)}}get context(){return $(o,this)??jn(this.getAttribute(`context`))}set context(e){Q(o,this,e),Z(d,this,m).call(this)}get embedKey(){return $(u,this)??this.getAttribute(`embed-key`)??void 0}set embedKey(e){Q(u,this,e),Z(d,this,m).call(this)}get user(){return $(s,this)??An(this.getAttribute(`user`))}set user(e){Q(s,this,e),Z(d,this,m).call(this)}get getSubjectToken(){return $(c,this)}set getSubjectToken(e){Q(c,this,e),Z(d,this,m).call(this)}get agent(){return $(l,this)??this.getAttribute(`agent`)??void 0}set agent(e){Q(l,this,e),Z(d,this,m).call(this)}get open(){return $(n,this)?.isOpen()??Nn(this.getAttribute(`open`))??!1}set open(e){e?this.openChat():this.closeChat()}get sessionId(){return $(n,this)?.sessionId()??$(a,this)}openChat(){$(n,this)?.open()}closeChat(){$(n,this)?.close()}toggleChat(){$(n,this)?.toggle()}reset(){$(n,this)?.reset()}sendMessage(e){if(!$(n,this)){kn(`sendMessage() called before the component was mounted — ignored`);return}$(n,this).send(e)}},qe(e,`observedAttributes`,En),e;function m(){$(r,this)||!$(i,this)||(Q(r,this,!0),queueMicrotask(()=>{Q(r,this,!1),$(i,this)&&Z(d,this,h).call(this)}))}function h(){let e=e=>this.getAttribute(e)??void 0;ae(J(xn,{embedKey:this.embedKey,context:this.context,user:this.user,getSubjectToken:this.getSubjectToken,agent:this.agent,heading:e(`heading`),subheading:e(`subheading`),assistantName:e(`assistant-name`),placeholder:e(`placeholder`),greeting:e(`greeting`),suggestions:Mn(this.getAttribute(`suggestions`)),width:e(`width`),accent:e(`accent`),theme:Pn(this.getAttribute(`theme`)),position:Fn(this.getAttribute(`position`)),layout:In(this.getAttribute(`layout`)),defaultOpen:Nn(this.getAttribute(`open`))??!1,persistOpen:Nn(this.getAttribute(`persist-open`))??!0,locale:e(`locale`),onEvent:$(f,this),bind:$(p,this)}),$(t,this))}}var Rn;function zn(e=Tn){typeof window>`u`||typeof HTMLElement>`u`||(Rn??(Rn=Ln()),window.customElements.get(e)||window.customElements.define(e,Rn))}return zn(),e.API_URL=Je,e.ChatHttpError=q,e.DEFAULT_LANGUAGE=Me,e.MAX_MESSAGE_LENGTH=Ye,e.SUPPORTED_LANGUAGES=Ne,e.TAG_NAME=Tn,e.defineChatbot=zn,e})({});
|
|
8
8
|
//# sourceMappingURL=chatbot.global.js.map
|