@squadico/chatbot 1.2.0 → 1.3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.tsx"],"names":[],"mappings":"AAkBA,eAAO,MAAM,QAAQ,qBAAqB,CAAA;AA6W1C;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,GAAE,MAAiB,GAAG,IAAI,CAM1D"}
1
+ {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.tsx"],"names":[],"mappings":"AAkBA,eAAO,MAAM,QAAQ,qBAAqB,CAAA;AA+W1C;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,GAAE,MAAiB,GAAG,IAAI,CAM1D"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./src-CcILETWB.cjs");exports.API_URL=e.r,exports.ChatHttpError=e.i,exports.DEFAULT_LANGUAGE=e.s,exports.MAX_MESSAGE_LENGTH=e.a,exports.SUPPORTED_LANGUAGES=e.c,exports.TAG_NAME=e.t,exports.defineChatbot=e.n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./src-DcJyi601.cjs");exports.API_URL=e.r,exports.ChatHttpError=e.i,exports.DEFAULT_LANGUAGE=e.s,exports.MAX_MESSAGE_LENGTH=e.a,exports.SUPPORTED_LANGUAGES=e.c,exports.TAG_NAME=e.t,exports.defineChatbot=e.n;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, i as n, n as r, r as i, s as a, t as o } from "./src-2GKPJcbZ.js";
1
+ import { a as e, c as t, i as n, n as r, r as i, s as a, t as o } from "./src-Nh5rZvti.js";
2
2
  export { i as API_URL, n as ChatHttpError, a as DEFAULT_LANGUAGE, e as MAX_MESSAGE_LENGTH, t as SUPPORTED_LANGUAGES, o as TAG_NAME, r as defineChatbot };
package/dist/jsx.d.ts CHANGED
@@ -39,6 +39,8 @@ export interface SquadicoChatbotAttributes {
39
39
  open?: string | boolean;
40
40
  /** `persist-open="false"`: the panel starts from `open` on every mount. */
41
41
  'persist-open'?: string | boolean;
42
+ /** `show-context="false"`: the context chips under the header are hidden. */
43
+ 'show-context'?: string | boolean;
42
44
  locale?: string;
43
45
  class?: string;
44
46
  id?: string;
package/dist/jsx.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC;;kEAEkE;AAClE,MAAM,WAAW,yBAAyB;IACxC;iEAC6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,uFAAuF;IACvF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;sDACkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;IACjC,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,CAAA;IACzC,4EAA4E;IAC5E,MAAM,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;IAC/B,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,2EAA2E;IAC3E,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;IACvC,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;mCAE+B;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AAED,OAAO,QAAQ,OAAO,CAAC;IAErB,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAiB;YACzB,kBAAkB,EAAE,yBAAyB,CAAA;SAC9C;KACF;CACF"}
1
+ {"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC;;kEAEkE;AAClE,MAAM,WAAW,yBAAyB;IACxC;iEAC6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,uFAAuF;IACvF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;sDACkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;IACjC,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,CAAA;IACzC,4EAA4E;IAC5E,MAAM,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;IAC/B,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,2EAA2E;IAC3E,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACjC,6EAA6E;IAC7E,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;IACvC,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;mCAE+B;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AAED,OAAO,QAAQ,OAAO,CAAC;IAErB,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAiB;YACzB,kBAAkB,EAAE,yBAAyB,CAAA;SAC9C;KACF;CACF"}
package/dist/react.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./src-CcILETWB.cjs");let t=require("react");var n={embedKey:`embed-key`,agent:`agent`,heading:`heading`,subheading:`subheading`,assistantName:`assistant-name`,placeholder:`placeholder`,greeting:`greeting`,width:`width`,accent:`accent`,theme:`theme`,position:`position`,layout:`layout`,locale:`locale`};function r(e,t){typeof e==`function`?e(t):e&&(e.current=t)}var i=(0,t.forwardRef)(function(i,a){let o=(0,t.useRef)(null),s=(0,t.useRef)(!1);(0,t.useEffect)(()=>{let t=o.current;if(t){e.n(),customElements.upgrade(t);for(let[e,r]of Object.entries(n)){let n=i[e];typeof n==`string`&&n?t.setAttribute(r,n):t.removeAttribute(r)}i.suggestions?.length?t.setAttribute(`suggestions`,JSON.stringify(i.suggestions)):t.removeAttribute(`suggestions`),i.persistOpen===!1?t.setAttribute(`persist-open`,`false`):t.removeAttribute(`persist-open`),t.context=i.context,t.user=i.user,t.getSubjectToken=i.getSubjectToken,s.current||(s.current=!0,e.o(i.defaultOpen,i.persistOpen)&&t.openChat())}});let{onOpen:c,onClose:l,onMessage:u,onError:d,onReset:f}=i;return(0,t.useEffect)(()=>{let e=o.current;if(!e)return;let t=Object.entries({"chatbot-open":c,"chatbot-close":l,"chatbot-message":u,"chatbot-error":d,"chatbot-reset":f}).filter(([,e])=>typeof e==`function`).map(([t,n])=>{let r=e=>{n?.(e.detail)};return e.addEventListener(t,r),()=>e.removeEventListener(t,r)});return()=>t.forEach(e=>e())},[c,l,u,d,f]),(0,t.createElement)(e.t,{ref:e=>{o.current=e,r(a,e)},class:i.className,style:i.style,id:i.id},i.launcherIcon==null?null:(0,t.createElement)(`span`,{slot:`launcher-icon`},i.launcherIcon))});exports.SquadicoChatbot=i,exports.TAG_NAME=e.t,exports.defineChatbot=e.n;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./src-DcJyi601.cjs");let t=require("react");var n={embedKey:`embed-key`,agent:`agent`,heading:`heading`,subheading:`subheading`,assistantName:`assistant-name`,placeholder:`placeholder`,greeting:`greeting`,width:`width`,accent:`accent`,theme:`theme`,position:`position`,layout:`layout`,locale:`locale`};function r(e,t){typeof e==`function`?e(t):e&&(e.current=t)}var i=(0,t.forwardRef)(function(i,a){let o=(0,t.useRef)(null),s=(0,t.useRef)(!1);(0,t.useEffect)(()=>{let t=o.current;if(t){e.n(),customElements.upgrade(t);for(let[e,r]of Object.entries(n)){let n=i[e];typeof n==`string`&&n?t.setAttribute(r,n):t.removeAttribute(r)}i.suggestions?.length?t.setAttribute(`suggestions`,JSON.stringify(i.suggestions)):t.removeAttribute(`suggestions`),i.persistOpen===!1?t.setAttribute(`persist-open`,`false`):t.removeAttribute(`persist-open`),i.showContext===!1?t.setAttribute(`show-context`,`false`):t.removeAttribute(`show-context`),t.context=i.context,t.user=i.user,t.getSubjectToken=i.getSubjectToken,s.current||(s.current=!0,e.o(i.defaultOpen,i.persistOpen)&&t.openChat())}});let{onOpen:c,onClose:l,onMessage:u,onError:d,onReset:f}=i;return(0,t.useEffect)(()=>{let e=o.current;if(!e)return;let t=Object.entries({"chatbot-open":c,"chatbot-close":l,"chatbot-message":u,"chatbot-error":d,"chatbot-reset":f}).filter(([,e])=>typeof e==`function`).map(([t,n])=>{let r=e=>{n?.(e.detail)};return e.addEventListener(t,r),()=>e.removeEventListener(t,r)});return()=>t.forEach(e=>e())},[c,l,u,d,f]),(0,t.createElement)(e.t,{ref:e=>{o.current=e,r(a,e)},class:i.className,style:i.style,id:i.id},i.launcherIcon==null?null:(0,t.createElement)(`span`,{slot:`launcher-icon`},i.launcherIcon))});exports.SquadicoChatbot=i,exports.TAG_NAME=e.t,exports.defineChatbot=e.n;
2
2
  //# sourceMappingURL=react.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"react.cjs","names":[],"sources":["../src/react.tsx"],"sourcesContent":["/**\n * React wrapper around `<squadico-chatbot>`.\n *\n * import { SquadicoChatbot } from '@squadico/chatbot/react'\n * <SquadicoChatbot context={{ order: { id: 'ORD-1', name: 'Order #1042' } }} onMessage={…} />\n *\n * This is not a second widget: it is a thin adapter (it renders nothing of its\n * own) around the custom element. It gives typed props, React callbacks instead\n * of `addEventListener`, and a `ref` on the imperative API.\n *\n * `react` is an **optional** peer dependency: this subpath is the only one\n * importing it, so a Vue or HTML host never has to install it.\n */\n'use client'\n\nimport { createElement, forwardRef, useEffect, useRef } from 'react'\nimport type { CSSProperties, ReactNode, Ref } from 'react'\nimport { defineChatbot, TAG_NAME } from './index'\nimport { initialOpen } from './lib/openState'\nimport type { ChatbotEventMap, ChatbotOptions, SquadicoChatbotElement } from './types'\n\nexport interface SquadicoChatbotProps extends ChatbotOptions {\n /**\n * Icon of the floating button, in place of the default spark — any React node\n * (`<BotIcon />`, an `<img>`, a font ligature).\n *\n * It is the only option that does not go through an attribute: the panel\n * renders inside a shadow root, where React cannot mount anything. The node is\n * therefore rendered as a child of the custom element, in the host's own tree\n * (where its CSS applies normally), then projected into the button by\n * `slot=\"launcher-icon\"`. It inherits the button's colour, so a\n * `stroke=\"currentColor\"` is enough; the frame is 26 px, and an icon sizing\n * itself in `1em` or `100%` fits it.\n */\n launcherIcon?: ReactNode\n onOpen?: (detail: ChatbotEventMap['chatbot-open']) => void\n onClose?: (detail: ChatbotEventMap['chatbot-close']) => void\n onMessage?: (detail: ChatbotEventMap['chatbot-message']) => void\n onError?: (detail: ChatbotEventMap['chatbot-error']) => void\n onReset?: (detail: ChatbotEventMap['chatbot-reset']) => void\n /** Set on the custom element — useful to override the `--sqc-*` variables. */\n className?: string\n style?: CSSProperties\n id?: string\n}\n\n/** Options driven by a plain string attribute. */\nconst STRING_ATTRS = {\n embedKey: 'embed-key',\n agent: 'agent',\n heading: 'heading',\n subheading: 'subheading',\n assistantName: 'assistant-name',\n placeholder: 'placeholder',\n greeting: 'greeting',\n width: 'width',\n accent: 'accent',\n theme: 'theme',\n position: 'position',\n layout: 'layout',\n locale: 'locale',\n} as const satisfies Partial<Record<keyof ChatbotOptions, string>>\n\nfunction assignRef(\n target: Ref<SquadicoChatbotElement | null> | undefined,\n node: SquadicoChatbotElement | null,\n): void {\n if (typeof target === 'function') target(node)\n else if (target) (target as { current: SquadicoChatbotElement | null }).current = node\n}\n\nexport const SquadicoChatbot = forwardRef<\n SquadicoChatbotElement | null,\n SquadicoChatbotProps\n>(function SquadicoChatbot(props, forwarded) {\n const host = useRef<SquadicoChatbotElement | null>(null)\n const mounted = useRef(false)\n\n /*\n * Nothing is passed to `createElement` besides `ref` / `class` / `style`:\n * depending on the React version, an unknown prop on a custom element is set\n * either as an attribute or as a property. Everything is therefore written\n * here, for identical behaviour from React 17 to 19.\n */\n useEffect(() => {\n const element = host.current\n if (!element) return\n\n // `defineChatbot()` already ran when `./index` was imported, but it is\n // called again for safety (it is idempotent), then the upgrade is forced: an\n // element created during hydration may not be upgraded yet, and a property\n // assignment would then shadow the class accessor.\n defineChatbot()\n customElements.upgrade(element)\n\n for (const [prop, attribute] of Object.entries(STRING_ATTRS)) {\n const value = props[prop as keyof typeof STRING_ATTRS]\n if (typeof value === 'string' && value) element.setAttribute(attribute, value)\n else element.removeAttribute(attribute)\n }\n\n if (props.suggestions?.length) {\n element.setAttribute('suggestions', JSON.stringify(props.suggestions))\n } else {\n element.removeAttribute('suggestions')\n }\n\n if (props.persistOpen === false) element.setAttribute('persist-open', 'false')\n else element.removeAttribute('persist-open')\n\n // Objects have no attribute representation: properties.\n element.context = props.context\n element.user = props.user\n element.getSubjectToken = props.getSubjectToken\n\n // `defaultOpen` is only honoured at mount: afterwards opening is driven\n // through the `ref` (`openChat()` / `closeChat()`), not by a render. It goes\n // through the same arbitration as the custom element — the element has\n // already restored the remembered panel when this effect runs, and an\n // `openChat()` on top would reopen what the user had just closed.\n if (!mounted.current) {\n mounted.current = true\n if (initialOpen(props.defaultOpen, props.persistOpen)) element.openChat()\n }\n })\n\n const { onOpen, onClose, onMessage, onError, onReset } = props\n useEffect(() => {\n const element = host.current\n if (!element) return\n\n const handlers: Partial<Record<keyof ChatbotEventMap, (detail: unknown) => void>> = {\n 'chatbot-open': onOpen as ((detail: unknown) => void) | undefined,\n 'chatbot-close': onClose as ((detail: unknown) => void) | undefined,\n 'chatbot-message': onMessage as ((detail: unknown) => void) | undefined,\n 'chatbot-error': onError as ((detail: unknown) => void) | undefined,\n 'chatbot-reset': onReset as ((detail: unknown) => void) | undefined,\n }\n\n const detachers = Object.entries(handlers)\n .filter(([, handler]) => typeof handler === 'function')\n .map(([name, handler]) => {\n const listener = (event: Event): void => {\n handler?.((event as CustomEvent<unknown>).detail)\n }\n element.addEventListener(name, listener)\n return () => element.removeEventListener(name, listener)\n })\n\n return () => detachers.forEach((detach) => detach())\n }, [onOpen, onClose, onMessage, onError, onReset])\n\n return createElement(\n TAG_NAME,\n {\n ref: (node: SquadicoChatbotElement | null) => {\n host.current = node\n assignRef(forwarded, node)\n },\n class: props.className,\n style: props.style,\n id: props.id,\n },\n // Wrapped rather than cloned with a `slot`: an icon component that does not\n // forward unknown props to its root element would never be projected, and a\n // child assigned to no slot is not rendered at all — the icon would vanish\n // without a word.\n props.launcherIcon == null\n ? null\n : createElement('span', { slot: 'launcher-icon' }, props.launcherIcon),\n )\n})\n\nexport { defineChatbot, TAG_NAME } from './index'\nexport type {\n AgentHandle,\n ApprovalDecision,\n ChatbotContext,\n ChatbotEvent,\n ChatbotEventMap,\n ChatbotEventName,\n ChatbotLayout,\n ChatbotOptions,\n ChatbotTheme,\n ChatMessage,\n ChatRole,\n ContextObject,\n ContextValue,\n HostUser,\n LauncherPosition,\n PendingApproval,\n SquadicoChatbotElement,\n} from './types'\n"],"mappings":"6IA+CA,IAAM,EAAe,CACnB,SAAU,YACV,MAAO,QACP,QAAS,UACT,WAAY,aACZ,cAAe,iBACf,YAAa,cACb,SAAU,WACV,MAAO,QACP,OAAQ,SACR,MAAO,QACP,SAAU,WACV,OAAQ,SACR,OAAQ,QACV,EAEA,SAAS,EACP,EACA,EACM,CACF,OAAO,GAAW,WAAY,EAAO,CAAI,EACpC,IAAQ,EAAuD,QAAU,EACpF,CAEA,IAAa,GAAA,EAAkB,EAAA,WAAA,CAG7B,SAAyB,EAAO,EAAW,CAC3C,IAAM,GAAA,EAAO,EAAA,OAAA,CAAsC,IAAI,EACjD,GAAA,EAAU,EAAA,OAAA,CAAO,EAAK,GAQ5B,EAAA,EAAA,UAAA,KAAgB,CACd,IAAM,EAAU,EAAK,QAChB,KAOL,CADA,EAAA,EAAc,EACd,eAAe,QAAQ,CAAO,EAE9B,IAAK,GAAM,CAAC,EAAM,KAAc,OAAO,QAAQ,CAAY,EAAG,CAC5D,IAAM,EAAQ,EAAM,GAChB,OAAO,GAAU,UAAY,EAAO,EAAQ,aAAa,EAAW,CAAK,EACxE,EAAQ,gBAAgB,CAAS,CACxC,CAEI,EAAM,aAAa,OACrB,EAAQ,aAAa,cAAe,KAAK,UAAU,EAAM,WAAW,CAAC,EAErE,EAAQ,gBAAgB,aAAa,EAGnC,EAAM,cAAgB,GAAO,EAAQ,aAAa,eAAgB,OAAO,EACxE,EAAQ,gBAAgB,cAAc,EAG3C,EAAQ,QAAU,EAAM,QACxB,EAAQ,KAAO,EAAM,KACrB,EAAQ,gBAAkB,EAAM,gBAO3B,EAAQ,UACX,EAAQ,QAAU,GACd,EAAA,EAAY,EAAM,YAAa,EAAM,WAAW,GAAG,EAAQ,SAAS,EA7B5C,CA+BhC,CAAC,EAED,GAAM,CAAE,SAAQ,UAAS,YAAW,UAAS,WAAY,EA0BzD,OAzBA,EAAA,EAAA,UAAA,KAAgB,CACd,IAAM,EAAU,EAAK,QACrB,GAAI,CAAC,EAAS,OAUd,IAAM,EAAY,OAAO,QAAQ,CAP/B,eAAgB,EAChB,gBAAiB,EACjB,kBAAmB,EACnB,gBAAiB,EACjB,gBAAiB,CAGc,CAAQ,CAAC,CACvC,QAAQ,EAAG,KAAa,OAAO,GAAY,UAAU,CAAC,CACtD,KAAK,CAAC,EAAM,KAAa,CACxB,IAAM,EAAY,GAAuB,CACvC,IAAW,EAA+B,MAAM,CAClD,EAEA,OADA,EAAQ,iBAAiB,EAAM,CAAQ,MAC1B,EAAQ,oBAAoB,EAAM,CAAQ,CACzD,CAAC,EAEH,UAAa,EAAU,QAAS,GAAW,EAAO,CAAC,CACrD,EAAG,CAAC,EAAQ,EAAS,EAAW,EAAS,CAAO,CAAC,GAEjD,EAAO,EAAA,cAAA,CACL,EAAA,EACA,CACE,IAAM,GAAwC,CAC5C,EAAK,QAAU,EACf,EAAU,EAAW,CAAI,CAC3B,EACA,MAAO,EAAM,UACb,MAAO,EAAM,MACb,GAAI,EAAM,EACZ,EAKA,EAAM,cAAgB,KAClB,MAAA,EACA,EAAA,cAAA,CAAc,OAAQ,CAAE,KAAM,eAAgB,EAAG,EAAM,YAAY,CACzE,CACF,CAAC"}
1
+ {"version":3,"file":"react.cjs","names":[],"sources":["../src/react.tsx"],"sourcesContent":["/**\n * React wrapper around `<squadico-chatbot>`.\n *\n * import { SquadicoChatbot } from '@squadico/chatbot/react'\n * <SquadicoChatbot context={{ order: { id: 'ORD-1', name: 'Order #1042' } }} onMessage={…} />\n *\n * This is not a second widget: it is a thin adapter (it renders nothing of its\n * own) around the custom element. It gives typed props, React callbacks instead\n * of `addEventListener`, and a `ref` on the imperative API.\n *\n * `react` is an **optional** peer dependency: this subpath is the only one\n * importing it, so a Vue or HTML host never has to install it.\n */\n'use client'\n\nimport { createElement, forwardRef, useEffect, useRef } from 'react'\nimport type { CSSProperties, ReactNode, Ref } from 'react'\nimport { defineChatbot, TAG_NAME } from './index'\nimport { initialOpen } from './lib/openState'\nimport type { ChatbotEventMap, ChatbotOptions, SquadicoChatbotElement } from './types'\n\nexport interface SquadicoChatbotProps extends ChatbotOptions {\n /**\n * Icon of the floating button, in place of the default spark — any React node\n * (`<BotIcon />`, an `<img>`, a font ligature).\n *\n * It is the only option that does not go through an attribute: the panel\n * renders inside a shadow root, where React cannot mount anything. The node is\n * therefore rendered as a child of the custom element, in the host's own tree\n * (where its CSS applies normally), then projected into the button by\n * `slot=\"launcher-icon\"`. It inherits the button's colour, so a\n * `stroke=\"currentColor\"` is enough; the frame is 26 px, and an icon sizing\n * itself in `1em` or `100%` fits it.\n */\n launcherIcon?: ReactNode\n onOpen?: (detail: ChatbotEventMap['chatbot-open']) => void\n onClose?: (detail: ChatbotEventMap['chatbot-close']) => void\n onMessage?: (detail: ChatbotEventMap['chatbot-message']) => void\n onError?: (detail: ChatbotEventMap['chatbot-error']) => void\n onReset?: (detail: ChatbotEventMap['chatbot-reset']) => void\n /** Set on the custom element — useful to override the `--sqc-*` variables. */\n className?: string\n style?: CSSProperties\n id?: string\n}\n\n/** Options driven by a plain string attribute. */\nconst STRING_ATTRS = {\n embedKey: 'embed-key',\n agent: 'agent',\n heading: 'heading',\n subheading: 'subheading',\n assistantName: 'assistant-name',\n placeholder: 'placeholder',\n greeting: 'greeting',\n width: 'width',\n accent: 'accent',\n theme: 'theme',\n position: 'position',\n layout: 'layout',\n locale: 'locale',\n} as const satisfies Partial<Record<keyof ChatbotOptions, string>>\n\nfunction assignRef(\n target: Ref<SquadicoChatbotElement | null> | undefined,\n node: SquadicoChatbotElement | null,\n): void {\n if (typeof target === 'function') target(node)\n else if (target) (target as { current: SquadicoChatbotElement | null }).current = node\n}\n\nexport const SquadicoChatbot = forwardRef<\n SquadicoChatbotElement | null,\n SquadicoChatbotProps\n>(function SquadicoChatbot(props, forwarded) {\n const host = useRef<SquadicoChatbotElement | null>(null)\n const mounted = useRef(false)\n\n /*\n * Nothing is passed to `createElement` besides `ref` / `class` / `style`:\n * depending on the React version, an unknown prop on a custom element is set\n * either as an attribute or as a property. Everything is therefore written\n * here, for identical behaviour from React 17 to 19.\n */\n useEffect(() => {\n const element = host.current\n if (!element) return\n\n // `defineChatbot()` already ran when `./index` was imported, but it is\n // called again for safety (it is idempotent), then the upgrade is forced: an\n // element created during hydration may not be upgraded yet, and a property\n // assignment would then shadow the class accessor.\n defineChatbot()\n customElements.upgrade(element)\n\n for (const [prop, attribute] of Object.entries(STRING_ATTRS)) {\n const value = props[prop as keyof typeof STRING_ATTRS]\n if (typeof value === 'string' && value) element.setAttribute(attribute, value)\n else element.removeAttribute(attribute)\n }\n\n if (props.suggestions?.length) {\n element.setAttribute('suggestions', JSON.stringify(props.suggestions))\n } else {\n element.removeAttribute('suggestions')\n }\n\n if (props.persistOpen === false) element.setAttribute('persist-open', 'false')\n else element.removeAttribute('persist-open')\n\n if (props.showContext === false) element.setAttribute('show-context', 'false')\n else element.removeAttribute('show-context')\n\n // Objects have no attribute representation: properties.\n element.context = props.context\n element.user = props.user\n element.getSubjectToken = props.getSubjectToken\n\n // `defaultOpen` is only honoured at mount: afterwards opening is driven\n // through the `ref` (`openChat()` / `closeChat()`), not by a render. It goes\n // through the same arbitration as the custom element — the element has\n // already restored the remembered panel when this effect runs, and an\n // `openChat()` on top would reopen what the user had just closed.\n if (!mounted.current) {\n mounted.current = true\n if (initialOpen(props.defaultOpen, props.persistOpen)) element.openChat()\n }\n })\n\n const { onOpen, onClose, onMessage, onError, onReset } = props\n useEffect(() => {\n const element = host.current\n if (!element) return\n\n const handlers: Partial<Record<keyof ChatbotEventMap, (detail: unknown) => void>> = {\n 'chatbot-open': onOpen as ((detail: unknown) => void) | undefined,\n 'chatbot-close': onClose as ((detail: unknown) => void) | undefined,\n 'chatbot-message': onMessage as ((detail: unknown) => void) | undefined,\n 'chatbot-error': onError as ((detail: unknown) => void) | undefined,\n 'chatbot-reset': onReset as ((detail: unknown) => void) | undefined,\n }\n\n const detachers = Object.entries(handlers)\n .filter(([, handler]) => typeof handler === 'function')\n .map(([name, handler]) => {\n const listener = (event: Event): void => {\n handler?.((event as CustomEvent<unknown>).detail)\n }\n element.addEventListener(name, listener)\n return () => element.removeEventListener(name, listener)\n })\n\n return () => detachers.forEach((detach) => detach())\n }, [onOpen, onClose, onMessage, onError, onReset])\n\n return createElement(\n TAG_NAME,\n {\n ref: (node: SquadicoChatbotElement | null) => {\n host.current = node\n assignRef(forwarded, node)\n },\n class: props.className,\n style: props.style,\n id: props.id,\n },\n // Wrapped rather than cloned with a `slot`: an icon component that does not\n // forward unknown props to its root element would never be projected, and a\n // child assigned to no slot is not rendered at all — the icon would vanish\n // without a word.\n props.launcherIcon == null\n ? null\n : createElement('span', { slot: 'launcher-icon' }, props.launcherIcon),\n )\n})\n\nexport { defineChatbot, TAG_NAME } from './index'\nexport type {\n AgentHandle,\n ApprovalDecision,\n ChatbotContext,\n ChatbotEvent,\n ChatbotEventMap,\n ChatbotEventName,\n ChatbotLayout,\n ChatbotOptions,\n ChatbotTheme,\n ChatMessage,\n ChatRole,\n ContextObject,\n ContextValue,\n HostUser,\n LauncherPosition,\n PendingApproval,\n SquadicoChatbotElement,\n} from './types'\n"],"mappings":"6IA+CA,IAAM,EAAe,CACnB,SAAU,YACV,MAAO,QACP,QAAS,UACT,WAAY,aACZ,cAAe,iBACf,YAAa,cACb,SAAU,WACV,MAAO,QACP,OAAQ,SACR,MAAO,QACP,SAAU,WACV,OAAQ,SACR,OAAQ,QACV,EAEA,SAAS,EACP,EACA,EACM,CACF,OAAO,GAAW,WAAY,EAAO,CAAI,EACpC,IAAQ,EAAuD,QAAU,EACpF,CAEA,IAAa,GAAA,EAAkB,EAAA,WAAA,CAG7B,SAAyB,EAAO,EAAW,CAC3C,IAAM,GAAA,EAAO,EAAA,OAAA,CAAsC,IAAI,EACjD,GAAA,EAAU,EAAA,OAAA,CAAO,EAAK,GAQ5B,EAAA,EAAA,UAAA,KAAgB,CACd,IAAM,EAAU,EAAK,QAChB,KAOL,CADA,EAAA,EAAc,EACd,eAAe,QAAQ,CAAO,EAE9B,IAAK,GAAM,CAAC,EAAM,KAAc,OAAO,QAAQ,CAAY,EAAG,CAC5D,IAAM,EAAQ,EAAM,GAChB,OAAO,GAAU,UAAY,EAAO,EAAQ,aAAa,EAAW,CAAK,EACxE,EAAQ,gBAAgB,CAAS,CACxC,CAEI,EAAM,aAAa,OACrB,EAAQ,aAAa,cAAe,KAAK,UAAU,EAAM,WAAW,CAAC,EAErE,EAAQ,gBAAgB,aAAa,EAGnC,EAAM,cAAgB,GAAO,EAAQ,aAAa,eAAgB,OAAO,EACxE,EAAQ,gBAAgB,cAAc,EAEvC,EAAM,cAAgB,GAAO,EAAQ,aAAa,eAAgB,OAAO,EACxE,EAAQ,gBAAgB,cAAc,EAG3C,EAAQ,QAAU,EAAM,QACxB,EAAQ,KAAO,EAAM,KACrB,EAAQ,gBAAkB,EAAM,gBAO3B,EAAQ,UACX,EAAQ,QAAU,GACd,EAAA,EAAY,EAAM,YAAa,EAAM,WAAW,GAAG,EAAQ,SAAS,EAhC5C,CAkChC,CAAC,EAED,GAAM,CAAE,SAAQ,UAAS,YAAW,UAAS,WAAY,EA0BzD,OAzBA,EAAA,EAAA,UAAA,KAAgB,CACd,IAAM,EAAU,EAAK,QACrB,GAAI,CAAC,EAAS,OAUd,IAAM,EAAY,OAAO,QAAQ,CAP/B,eAAgB,EAChB,gBAAiB,EACjB,kBAAmB,EACnB,gBAAiB,EACjB,gBAAiB,CAGc,CAAQ,CAAC,CACvC,QAAQ,EAAG,KAAa,OAAO,GAAY,UAAU,CAAC,CACtD,KAAK,CAAC,EAAM,KAAa,CACxB,IAAM,EAAY,GAAuB,CACvC,IAAW,EAA+B,MAAM,CAClD,EAEA,OADA,EAAQ,iBAAiB,EAAM,CAAQ,MAC1B,EAAQ,oBAAoB,EAAM,CAAQ,CACzD,CAAC,EAEH,UAAa,EAAU,QAAS,GAAW,EAAO,CAAC,CACrD,EAAG,CAAC,EAAQ,EAAS,EAAW,EAAS,CAAO,CAAC,GAEjD,EAAO,EAAA,cAAA,CACL,EAAA,EACA,CACE,IAAM,GAAwC,CAC5C,EAAK,QAAU,EACf,EAAU,EAAW,CAAI,CAC3B,EACA,MAAO,EAAM,UACb,MAAO,EAAM,MACb,GAAI,EAAM,EACZ,EAKA,EAAM,cAAgB,KAClB,MAAA,EACA,EAAA,cAAA,CAAc,OAAQ,CAAE,KAAM,eAAgB,EAAG,EAAM,YAAY,CACzE,CACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAO,MAAM,OAAO,CAAA;AAG1D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAEtF,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,cAAc,CAAC,KAAK,IAAI,CAAA;IAC1D,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,eAAe,CAAC,KAAK,IAAI,CAAA;IAC5D,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAA;IAChE,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,eAAe,CAAC,KAAK,IAAI,CAAA;IAC5D,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,eAAe,CAAC,KAAK,IAAI,CAAA;IAC5D,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ;AA2BD,eAAO,MAAM,eAAe,gIAoG1B,CAAA;AAEF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACjD,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,sBAAsB,GACvB,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAO,MAAM,OAAO,CAAA;AAG1D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAEtF,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,cAAc,CAAC,KAAK,IAAI,CAAA;IAC1D,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,eAAe,CAAC,KAAK,IAAI,CAAA;IAC5D,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAA;IAChE,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,eAAe,CAAC,KAAK,IAAI,CAAA;IAC5D,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,eAAe,CAAC,KAAK,IAAI,CAAA;IAC5D,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ;AA2BD,eAAO,MAAM,eAAe,gIAuG1B,CAAA;AAEF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACjD,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,sBAAsB,GACvB,MAAM,SAAS,CAAA"}
package/dist/react.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { n as e, o as t, t as n } from "./src-2GKPJcbZ.js";
2
+ import { n as e, o as t, t as n } from "./src-Nh5rZvti.js";
3
3
  import { createElement as r, forwardRef as i, useEffect as a, useRef as o } from "react";
4
4
  //#region src/react.tsx
5
5
  var s = {
@@ -30,7 +30,7 @@ var l = i(function(i, l) {
30
30
  let r = i[e];
31
31
  typeof r == "string" && r ? n.setAttribute(t, r) : n.removeAttribute(t);
32
32
  }
33
- i.suggestions?.length ? n.setAttribute("suggestions", JSON.stringify(i.suggestions)) : n.removeAttribute("suggestions"), i.persistOpen === !1 ? n.setAttribute("persist-open", "false") : n.removeAttribute("persist-open"), n.context = i.context, n.user = i.user, n.getSubjectToken = i.getSubjectToken, d.current || (d.current = !0, t(i.defaultOpen, i.persistOpen) && n.openChat());
33
+ i.suggestions?.length ? n.setAttribute("suggestions", JSON.stringify(i.suggestions)) : n.removeAttribute("suggestions"), i.persistOpen === !1 ? n.setAttribute("persist-open", "false") : n.removeAttribute("persist-open"), i.showContext === !1 ? n.setAttribute("show-context", "false") : n.removeAttribute("show-context"), n.context = i.context, n.user = i.user, n.getSubjectToken = i.getSubjectToken, d.current || (d.current = !0, t(i.defaultOpen, i.persistOpen) && n.openChat());
34
34
  }
35
35
  });
36
36
  let { onOpen: f, onClose: p, onMessage: m, onError: h, onReset: g } = i;
package/dist/react.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"react.js","names":[],"sources":["../src/react.tsx"],"sourcesContent":["/**\n * React wrapper around `<squadico-chatbot>`.\n *\n * import { SquadicoChatbot } from '@squadico/chatbot/react'\n * <SquadicoChatbot context={{ order: { id: 'ORD-1', name: 'Order #1042' } }} onMessage={…} />\n *\n * This is not a second widget: it is a thin adapter (it renders nothing of its\n * own) around the custom element. It gives typed props, React callbacks instead\n * of `addEventListener`, and a `ref` on the imperative API.\n *\n * `react` is an **optional** peer dependency: this subpath is the only one\n * importing it, so a Vue or HTML host never has to install it.\n */\n'use client'\n\nimport { createElement, forwardRef, useEffect, useRef } from 'react'\nimport type { CSSProperties, ReactNode, Ref } from 'react'\nimport { defineChatbot, TAG_NAME } from './index'\nimport { initialOpen } from './lib/openState'\nimport type { ChatbotEventMap, ChatbotOptions, SquadicoChatbotElement } from './types'\n\nexport interface SquadicoChatbotProps extends ChatbotOptions {\n /**\n * Icon of the floating button, in place of the default spark — any React node\n * (`<BotIcon />`, an `<img>`, a font ligature).\n *\n * It is the only option that does not go through an attribute: the panel\n * renders inside a shadow root, where React cannot mount anything. The node is\n * therefore rendered as a child of the custom element, in the host's own tree\n * (where its CSS applies normally), then projected into the button by\n * `slot=\"launcher-icon\"`. It inherits the button's colour, so a\n * `stroke=\"currentColor\"` is enough; the frame is 26 px, and an icon sizing\n * itself in `1em` or `100%` fits it.\n */\n launcherIcon?: ReactNode\n onOpen?: (detail: ChatbotEventMap['chatbot-open']) => void\n onClose?: (detail: ChatbotEventMap['chatbot-close']) => void\n onMessage?: (detail: ChatbotEventMap['chatbot-message']) => void\n onError?: (detail: ChatbotEventMap['chatbot-error']) => void\n onReset?: (detail: ChatbotEventMap['chatbot-reset']) => void\n /** Set on the custom element — useful to override the `--sqc-*` variables. */\n className?: string\n style?: CSSProperties\n id?: string\n}\n\n/** Options driven by a plain string attribute. */\nconst STRING_ATTRS = {\n embedKey: 'embed-key',\n agent: 'agent',\n heading: 'heading',\n subheading: 'subheading',\n assistantName: 'assistant-name',\n placeholder: 'placeholder',\n greeting: 'greeting',\n width: 'width',\n accent: 'accent',\n theme: 'theme',\n position: 'position',\n layout: 'layout',\n locale: 'locale',\n} as const satisfies Partial<Record<keyof ChatbotOptions, string>>\n\nfunction assignRef(\n target: Ref<SquadicoChatbotElement | null> | undefined,\n node: SquadicoChatbotElement | null,\n): void {\n if (typeof target === 'function') target(node)\n else if (target) (target as { current: SquadicoChatbotElement | null }).current = node\n}\n\nexport const SquadicoChatbot = forwardRef<\n SquadicoChatbotElement | null,\n SquadicoChatbotProps\n>(function SquadicoChatbot(props, forwarded) {\n const host = useRef<SquadicoChatbotElement | null>(null)\n const mounted = useRef(false)\n\n /*\n * Nothing is passed to `createElement` besides `ref` / `class` / `style`:\n * depending on the React version, an unknown prop on a custom element is set\n * either as an attribute or as a property. Everything is therefore written\n * here, for identical behaviour from React 17 to 19.\n */\n useEffect(() => {\n const element = host.current\n if (!element) return\n\n // `defineChatbot()` already ran when `./index` was imported, but it is\n // called again for safety (it is idempotent), then the upgrade is forced: an\n // element created during hydration may not be upgraded yet, and a property\n // assignment would then shadow the class accessor.\n defineChatbot()\n customElements.upgrade(element)\n\n for (const [prop, attribute] of Object.entries(STRING_ATTRS)) {\n const value = props[prop as keyof typeof STRING_ATTRS]\n if (typeof value === 'string' && value) element.setAttribute(attribute, value)\n else element.removeAttribute(attribute)\n }\n\n if (props.suggestions?.length) {\n element.setAttribute('suggestions', JSON.stringify(props.suggestions))\n } else {\n element.removeAttribute('suggestions')\n }\n\n if (props.persistOpen === false) element.setAttribute('persist-open', 'false')\n else element.removeAttribute('persist-open')\n\n // Objects have no attribute representation: properties.\n element.context = props.context\n element.user = props.user\n element.getSubjectToken = props.getSubjectToken\n\n // `defaultOpen` is only honoured at mount: afterwards opening is driven\n // through the `ref` (`openChat()` / `closeChat()`), not by a render. It goes\n // through the same arbitration as the custom element — the element has\n // already restored the remembered panel when this effect runs, and an\n // `openChat()` on top would reopen what the user had just closed.\n if (!mounted.current) {\n mounted.current = true\n if (initialOpen(props.defaultOpen, props.persistOpen)) element.openChat()\n }\n })\n\n const { onOpen, onClose, onMessage, onError, onReset } = props\n useEffect(() => {\n const element = host.current\n if (!element) return\n\n const handlers: Partial<Record<keyof ChatbotEventMap, (detail: unknown) => void>> = {\n 'chatbot-open': onOpen as ((detail: unknown) => void) | undefined,\n 'chatbot-close': onClose as ((detail: unknown) => void) | undefined,\n 'chatbot-message': onMessage as ((detail: unknown) => void) | undefined,\n 'chatbot-error': onError as ((detail: unknown) => void) | undefined,\n 'chatbot-reset': onReset as ((detail: unknown) => void) | undefined,\n }\n\n const detachers = Object.entries(handlers)\n .filter(([, handler]) => typeof handler === 'function')\n .map(([name, handler]) => {\n const listener = (event: Event): void => {\n handler?.((event as CustomEvent<unknown>).detail)\n }\n element.addEventListener(name, listener)\n return () => element.removeEventListener(name, listener)\n })\n\n return () => detachers.forEach((detach) => detach())\n }, [onOpen, onClose, onMessage, onError, onReset])\n\n return createElement(\n TAG_NAME,\n {\n ref: (node: SquadicoChatbotElement | null) => {\n host.current = node\n assignRef(forwarded, node)\n },\n class: props.className,\n style: props.style,\n id: props.id,\n },\n // Wrapped rather than cloned with a `slot`: an icon component that does not\n // forward unknown props to its root element would never be projected, and a\n // child assigned to no slot is not rendered at all — the icon would vanish\n // without a word.\n props.launcherIcon == null\n ? null\n : createElement('span', { slot: 'launcher-icon' }, props.launcherIcon),\n )\n})\n\nexport { defineChatbot, TAG_NAME } from './index'\nexport type {\n AgentHandle,\n ApprovalDecision,\n ChatbotContext,\n ChatbotEvent,\n ChatbotEventMap,\n ChatbotEventName,\n ChatbotLayout,\n ChatbotOptions,\n ChatbotTheme,\n ChatMessage,\n ChatRole,\n ContextObject,\n ContextValue,\n HostUser,\n LauncherPosition,\n PendingApproval,\n SquadicoChatbotElement,\n} from './types'\n"],"mappings":";;;;AA+CA,IAAM,IAAe;CACnB,UAAU;CACV,OAAO;CACP,SAAS;CACT,YAAY;CACZ,eAAe;CACf,aAAa;CACb,UAAU;CACV,OAAO;CACP,QAAQ;CACR,OAAO;CACP,UAAU;CACV,QAAQ;CACR,QAAQ;AACV;AAEA,SAAS,EACP,GACA,GACM;CACN,AAAI,OAAO,KAAW,aAAY,EAAO,CAAI,IACpC,MAAQ,EAAuD,UAAU;AACpF;AAEA,IAAa,IAAkB,EAG7B,SAAyB,GAAO,GAAW;CAC3C,IAAM,IAAO,EAAsC,IAAI,GACjD,IAAU,EAAO,EAAK;CAQ5B,QAAgB;EACd,IAAM,IAAU,EAAK;EAChB,OAOL;GADA,EAAc,GACd,eAAe,QAAQ,CAAO;GAE9B,KAAK,IAAM,CAAC,GAAM,MAAc,OAAO,QAAQ,CAAY,GAAG;IAC5D,IAAM,IAAQ,EAAM;IACpB,AAAI,OAAO,KAAU,YAAY,IAAO,EAAQ,aAAa,GAAW,CAAK,IACxE,EAAQ,gBAAgB,CAAS;GACxC;GAqBA,AAnBI,EAAM,aAAa,SACrB,EAAQ,aAAa,eAAe,KAAK,UAAU,EAAM,WAAW,CAAC,IAErE,EAAQ,gBAAgB,aAAa,GAGnC,EAAM,gBAAgB,KAAO,EAAQ,aAAa,gBAAgB,OAAO,IACxE,EAAQ,gBAAgB,cAAc,GAG3C,EAAQ,UAAU,EAAM,SACxB,EAAQ,OAAO,EAAM,MACrB,EAAQ,kBAAkB,EAAM,iBAO3B,EAAQ,YACX,EAAQ,UAAU,IACd,EAAY,EAAM,aAAa,EAAM,WAAW,KAAG,EAAQ,SAAS;EA7B5C;CA+BhC,CAAC;CAED,IAAM,EAAE,WAAQ,YAAS,cAAW,YAAS,eAAY;CA0BzD,OAzBA,QAAgB;EACd,IAAM,IAAU,EAAK;EACrB,IAAI,CAAC,GAAS;EAUd,IAAM,IAAY,OAAO,QAAQ;GAP/B,gBAAgB;GAChB,iBAAiB;GACjB,mBAAmB;GACnB,iBAAiB;GACjB,iBAAiB;EAGc,CAAQ,CAAC,CACvC,QAAQ,GAAG,OAAa,OAAO,KAAY,UAAU,CAAC,CACtD,KAAK,CAAC,GAAM,OAAa;GACxB,IAAM,KAAY,MAAuB;IACvC,IAAW,EAA+B,MAAM;GAClD;GAEA,OADA,EAAQ,iBAAiB,GAAM,CAAQ,SAC1B,EAAQ,oBAAoB,GAAM,CAAQ;EACzD,CAAC;EAEH,aAAa,EAAU,SAAS,MAAW,EAAO,CAAC;CACrD,GAAG;EAAC;EAAQ;EAAS;EAAW;EAAS;CAAO,CAAC,GAE1C,EACL,GACA;EACE,MAAM,MAAwC;GAE5C,AADA,EAAK,UAAU,GACf,EAAU,GAAW,CAAI;EAC3B;EACA,OAAO,EAAM;EACb,OAAO,EAAM;EACb,IAAI,EAAM;CACZ,GAKA,EAAM,gBAAgB,OAClB,OACA,EAAc,QAAQ,EAAE,MAAM,gBAAgB,GAAG,EAAM,YAAY,CACzE;AACF,CAAC"}
1
+ {"version":3,"file":"react.js","names":[],"sources":["../src/react.tsx"],"sourcesContent":["/**\n * React wrapper around `<squadico-chatbot>`.\n *\n * import { SquadicoChatbot } from '@squadico/chatbot/react'\n * <SquadicoChatbot context={{ order: { id: 'ORD-1', name: 'Order #1042' } }} onMessage={…} />\n *\n * This is not a second widget: it is a thin adapter (it renders nothing of its\n * own) around the custom element. It gives typed props, React callbacks instead\n * of `addEventListener`, and a `ref` on the imperative API.\n *\n * `react` is an **optional** peer dependency: this subpath is the only one\n * importing it, so a Vue or HTML host never has to install it.\n */\n'use client'\n\nimport { createElement, forwardRef, useEffect, useRef } from 'react'\nimport type { CSSProperties, ReactNode, Ref } from 'react'\nimport { defineChatbot, TAG_NAME } from './index'\nimport { initialOpen } from './lib/openState'\nimport type { ChatbotEventMap, ChatbotOptions, SquadicoChatbotElement } from './types'\n\nexport interface SquadicoChatbotProps extends ChatbotOptions {\n /**\n * Icon of the floating button, in place of the default spark — any React node\n * (`<BotIcon />`, an `<img>`, a font ligature).\n *\n * It is the only option that does not go through an attribute: the panel\n * renders inside a shadow root, where React cannot mount anything. The node is\n * therefore rendered as a child of the custom element, in the host's own tree\n * (where its CSS applies normally), then projected into the button by\n * `slot=\"launcher-icon\"`. It inherits the button's colour, so a\n * `stroke=\"currentColor\"` is enough; the frame is 26 px, and an icon sizing\n * itself in `1em` or `100%` fits it.\n */\n launcherIcon?: ReactNode\n onOpen?: (detail: ChatbotEventMap['chatbot-open']) => void\n onClose?: (detail: ChatbotEventMap['chatbot-close']) => void\n onMessage?: (detail: ChatbotEventMap['chatbot-message']) => void\n onError?: (detail: ChatbotEventMap['chatbot-error']) => void\n onReset?: (detail: ChatbotEventMap['chatbot-reset']) => void\n /** Set on the custom element — useful to override the `--sqc-*` variables. */\n className?: string\n style?: CSSProperties\n id?: string\n}\n\n/** Options driven by a plain string attribute. */\nconst STRING_ATTRS = {\n embedKey: 'embed-key',\n agent: 'agent',\n heading: 'heading',\n subheading: 'subheading',\n assistantName: 'assistant-name',\n placeholder: 'placeholder',\n greeting: 'greeting',\n width: 'width',\n accent: 'accent',\n theme: 'theme',\n position: 'position',\n layout: 'layout',\n locale: 'locale',\n} as const satisfies Partial<Record<keyof ChatbotOptions, string>>\n\nfunction assignRef(\n target: Ref<SquadicoChatbotElement | null> | undefined,\n node: SquadicoChatbotElement | null,\n): void {\n if (typeof target === 'function') target(node)\n else if (target) (target as { current: SquadicoChatbotElement | null }).current = node\n}\n\nexport const SquadicoChatbot = forwardRef<\n SquadicoChatbotElement | null,\n SquadicoChatbotProps\n>(function SquadicoChatbot(props, forwarded) {\n const host = useRef<SquadicoChatbotElement | null>(null)\n const mounted = useRef(false)\n\n /*\n * Nothing is passed to `createElement` besides `ref` / `class` / `style`:\n * depending on the React version, an unknown prop on a custom element is set\n * either as an attribute or as a property. Everything is therefore written\n * here, for identical behaviour from React 17 to 19.\n */\n useEffect(() => {\n const element = host.current\n if (!element) return\n\n // `defineChatbot()` already ran when `./index` was imported, but it is\n // called again for safety (it is idempotent), then the upgrade is forced: an\n // element created during hydration may not be upgraded yet, and a property\n // assignment would then shadow the class accessor.\n defineChatbot()\n customElements.upgrade(element)\n\n for (const [prop, attribute] of Object.entries(STRING_ATTRS)) {\n const value = props[prop as keyof typeof STRING_ATTRS]\n if (typeof value === 'string' && value) element.setAttribute(attribute, value)\n else element.removeAttribute(attribute)\n }\n\n if (props.suggestions?.length) {\n element.setAttribute('suggestions', JSON.stringify(props.suggestions))\n } else {\n element.removeAttribute('suggestions')\n }\n\n if (props.persistOpen === false) element.setAttribute('persist-open', 'false')\n else element.removeAttribute('persist-open')\n\n if (props.showContext === false) element.setAttribute('show-context', 'false')\n else element.removeAttribute('show-context')\n\n // Objects have no attribute representation: properties.\n element.context = props.context\n element.user = props.user\n element.getSubjectToken = props.getSubjectToken\n\n // `defaultOpen` is only honoured at mount: afterwards opening is driven\n // through the `ref` (`openChat()` / `closeChat()`), not by a render. It goes\n // through the same arbitration as the custom element — the element has\n // already restored the remembered panel when this effect runs, and an\n // `openChat()` on top would reopen what the user had just closed.\n if (!mounted.current) {\n mounted.current = true\n if (initialOpen(props.defaultOpen, props.persistOpen)) element.openChat()\n }\n })\n\n const { onOpen, onClose, onMessage, onError, onReset } = props\n useEffect(() => {\n const element = host.current\n if (!element) return\n\n const handlers: Partial<Record<keyof ChatbotEventMap, (detail: unknown) => void>> = {\n 'chatbot-open': onOpen as ((detail: unknown) => void) | undefined,\n 'chatbot-close': onClose as ((detail: unknown) => void) | undefined,\n 'chatbot-message': onMessage as ((detail: unknown) => void) | undefined,\n 'chatbot-error': onError as ((detail: unknown) => void) | undefined,\n 'chatbot-reset': onReset as ((detail: unknown) => void) | undefined,\n }\n\n const detachers = Object.entries(handlers)\n .filter(([, handler]) => typeof handler === 'function')\n .map(([name, handler]) => {\n const listener = (event: Event): void => {\n handler?.((event as CustomEvent<unknown>).detail)\n }\n element.addEventListener(name, listener)\n return () => element.removeEventListener(name, listener)\n })\n\n return () => detachers.forEach((detach) => detach())\n }, [onOpen, onClose, onMessage, onError, onReset])\n\n return createElement(\n TAG_NAME,\n {\n ref: (node: SquadicoChatbotElement | null) => {\n host.current = node\n assignRef(forwarded, node)\n },\n class: props.className,\n style: props.style,\n id: props.id,\n },\n // Wrapped rather than cloned with a `slot`: an icon component that does not\n // forward unknown props to its root element would never be projected, and a\n // child assigned to no slot is not rendered at all — the icon would vanish\n // without a word.\n props.launcherIcon == null\n ? null\n : createElement('span', { slot: 'launcher-icon' }, props.launcherIcon),\n )\n})\n\nexport { defineChatbot, TAG_NAME } from './index'\nexport type {\n AgentHandle,\n ApprovalDecision,\n ChatbotContext,\n ChatbotEvent,\n ChatbotEventMap,\n ChatbotEventName,\n ChatbotLayout,\n ChatbotOptions,\n ChatbotTheme,\n ChatMessage,\n ChatRole,\n ContextObject,\n ContextValue,\n HostUser,\n LauncherPosition,\n PendingApproval,\n SquadicoChatbotElement,\n} from './types'\n"],"mappings":";;;;AA+CA,IAAM,IAAe;CACnB,UAAU;CACV,OAAO;CACP,SAAS;CACT,YAAY;CACZ,eAAe;CACf,aAAa;CACb,UAAU;CACV,OAAO;CACP,QAAQ;CACR,OAAO;CACP,UAAU;CACV,QAAQ;CACR,QAAQ;AACV;AAEA,SAAS,EACP,GACA,GACM;CACN,AAAI,OAAO,KAAW,aAAY,EAAO,CAAI,IACpC,MAAQ,EAAuD,UAAU;AACpF;AAEA,IAAa,IAAkB,EAG7B,SAAyB,GAAO,GAAW;CAC3C,IAAM,IAAO,EAAsC,IAAI,GACjD,IAAU,EAAO,EAAK;CAQ5B,QAAgB;EACd,IAAM,IAAU,EAAK;EAChB,OAOL;GADA,EAAc,GACd,eAAe,QAAQ,CAAO;GAE9B,KAAK,IAAM,CAAC,GAAM,MAAc,OAAO,QAAQ,CAAY,GAAG;IAC5D,IAAM,IAAQ,EAAM;IACpB,AAAI,OAAO,KAAU,YAAY,IAAO,EAAQ,aAAa,GAAW,CAAK,IACxE,EAAQ,gBAAgB,CAAS;GACxC;GAwBA,AAtBI,EAAM,aAAa,SACrB,EAAQ,aAAa,eAAe,KAAK,UAAU,EAAM,WAAW,CAAC,IAErE,EAAQ,gBAAgB,aAAa,GAGnC,EAAM,gBAAgB,KAAO,EAAQ,aAAa,gBAAgB,OAAO,IACxE,EAAQ,gBAAgB,cAAc,GAEvC,EAAM,gBAAgB,KAAO,EAAQ,aAAa,gBAAgB,OAAO,IACxE,EAAQ,gBAAgB,cAAc,GAG3C,EAAQ,UAAU,EAAM,SACxB,EAAQ,OAAO,EAAM,MACrB,EAAQ,kBAAkB,EAAM,iBAO3B,EAAQ,YACX,EAAQ,UAAU,IACd,EAAY,EAAM,aAAa,EAAM,WAAW,KAAG,EAAQ,SAAS;EAhC5C;CAkChC,CAAC;CAED,IAAM,EAAE,WAAQ,YAAS,cAAW,YAAS,eAAY;CA0BzD,OAzBA,QAAgB;EACd,IAAM,IAAU,EAAK;EACrB,IAAI,CAAC,GAAS;EAUd,IAAM,IAAY,OAAO,QAAQ;GAP/B,gBAAgB;GAChB,iBAAiB;GACjB,mBAAmB;GACnB,iBAAiB;GACjB,iBAAiB;EAGc,CAAQ,CAAC,CACvC,QAAQ,GAAG,OAAa,OAAO,KAAY,UAAU,CAAC,CACtD,KAAK,CAAC,GAAM,OAAa;GACxB,IAAM,KAAY,MAAuB;IACvC,IAAW,EAA+B,MAAM;GAClD;GAEA,OADA,EAAQ,iBAAiB,GAAM,CAAQ,SAC1B,EAAQ,oBAAoB,GAAM,CAAQ;EACzD,CAAC;EAEH,aAAa,EAAU,SAAS,MAAW,EAAO,CAAC;CACrD,GAAG;EAAC;EAAQ;EAAS;EAAW;EAAS;CAAO,CAAC,GAE1C,EACL,GACA;EACE,MAAM,MAAwC;GAE5C,AADA,EAAK,UAAU,GACf,EAAU,GAAW,CAAI;EAC3B;EACA,OAAO,EAAM;EACb,OAAO,EAAM;EACb,IAAI,EAAM;CACZ,GAKA,EAAM,gBAAgB,OAClB,OACA,EAAc,QAAQ,EAAE,MAAM,gBAAgB,GAAG,EAAM,YAAY,CACzE;AACF,CAAC"}
@@ -4,5 +4,5 @@ var e,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|m
4
4
  `),i=[],a=[],o=[],s=[],c=()=>{if(!a.length)return;let e=`p${i.length}`;i.push(Y(`p`,{children:$t(a.join(`
5
5
  `),e)},e)),a=[]},l=()=>{if(!o.length)return;let e=0;for(;e<o.length;){let t=`l${i.length}`,[n,r]=fn(o,e,o[e].depth,t);i.push(n),e=r}o=[]},u=()=>{if(!s.length)return;let e=`q${i.length}`;i.push(Y(`blockquote`,{children:$t(s.join(`
6
6
  `),e)},e)),s=[]},d=()=>{c(),l(),u()};for(let e=0;e<r.length;e+=1){let f=r[e];if(un.test(f)){d();let t=[];for(e+=1;e<r.length&&!un.test(r[e]);)t.push(r[e]),e+=1;let n=`c${i.length}`;i.push(Y(`pre`,{children:Y(`code`,{children:t.join(`
7
- `)})},n));continue}if(cn.test(f)&&e+1<r.length&&ln.test(r[e+1])){d();let t=dn(f),n=[];for(e+=2;e<r.length&&cn.test(r[e]);)n.push(dn(r[e])),e+=1;--e;let a=`t${i.length}`;i.push(Y(`div`,{class:`sqc-table`,children:Y(`table`,{children:[Y(`thead`,{children:Y(`tr`,{children:t.map((e,t)=>Y(`th`,{children:$t(e,`${a}-h${t}`)},`${a}-h${t}`))})}),Y(`tbody`,{children:n.map((e,n)=>Y(`tr`,{children:t.map((t,r)=>Y(`td`,{children:$t(e[r]??``,`${a}-r${n}c${r}`)},`${a}-r${n}c${r}`))},`${a}-r${n}`))})]})},a));continue}if(!f.trim()){d();continue}if(en.test(f)){d();let a=[];for(;e<r.length;){let t=en.exec(r[e]);if(!t)break;let n=t[2].trim(),o=`o${i.length}-${a.length}`;a.push({label:tn(n),checked:t[1].toLowerCase()===`x`,content:$t(n,o)}),e+=1}--e,i.push(Y(Jt,{items:a,locale:t,onPick:n},`o${i.length}`));continue}let p=an.exec(f);if(p){d();let e=p[1].length,t=e<=2?`h3`:e===3?`h4`:`h5`,n=`h${i.length}`;i.push(Y(t,{children:$t(p[2],n)},n));continue}if(on.test(f)){d(),i.push(Y(`hr`,{},`r${i.length}`));continue}let m=sn.exec(f);if(m){c(),l(),s.push(m[1]);continue}let h=nn.exec(f),g=h?null:rn.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(),Y(S,{children:i})}var mn=80;function hn({at:e,locale:t}){let n=new Date(e);return Y(`time`,{class:`sqc-msg__time`,dateTime:n.toISOString(),children:n.toLocaleTimeString(t.tag,{hour:`2-digit`,minute:`2-digit`})})}function gn({file:e,load:t}){let[n,r]=W(null);return G(()=>{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?Y(`img`,{class:`sqc-attachment__image`,src:n,alt:e.filename}):Y(`span`,{class:`sqc-chip sqc-chip--waiting`,children:e.filename})}function _n({files:e,load:t}){return e.length===0||!t?null:Y(`div`,{class:`sqc-attachments sqc-attachments--sent`,children:e.map(e=>e.kind===`image`?Y(gn,{file:e,load:t},e.id):Y(`span`,{class:`sqc-chip`,"data-kind":`document`,children:Y(`span`,{class:`sqc-chip__name`,children:e.filename})},e.id))})}function vn({message:e,locale:t,assistantName:n,onChoice:r,onDecide:i,onLoadAttachment:a}){let o=e.streaming&&!e.content,s=!!e.approval;return Y(`div`,{class:`sqc-msg sqc-msg--${e.role}${e.error?` sqc-msg--error`:``}`,children:[e.role===`assistant`&&Y(`div`,{class:`sqc-msg__who`,children:[e.agent?Y(kt,{name:e.agent.name,color:e.agent.color,url:e.agent.avatarUrl}):Y(bn,{}),e.authorName??e.agent?.name??n]}),Y(`div`,{class:`sqc-msg__bubble`,children:[o?Y(`span`,{class:`sqc-typing`,"aria-label":t.t.typing,children:[Y(`i`,{}),Y(`i`,{}),Y(`i`,{})]}):Y(`div`,{class:`sqc-msg__body`,children:[Y(pn,{text:e.content,locale:t,onChoice:r}),e.streaming&&Y(`span`,{class:`sqc-caret`,"aria-hidden":`true`}),s&&Y(Gt,{locale:t,call:e.content.trim()===``?e.approval:void 0,onDecide:i}),e.role===`assistant`&&!s&&!e.streaming&&!e.error&&Vt(e.content,t.code)&&Y(Kt,{locale:t,onPick:r}),e.unknownHandle&&!e.streaming&&Y(yn,{message:e,locale:t}),Y(_n,{files:e.attachments??[],load:a})]}),!o&&Y(hn,{at:e.createdAt,locale:t})]})]})}function yn({message:e,locale:t}){let n=e.offered??[];return Y(`p`,{class:`sqc-msg__unaddressed`,children:[Y(`span`,{children:t.t.handles.unknown}),` `,Y(`code`,{children:[`@`,e.unknownHandle]}),n.length>0&&Y(S,{children:[` `,Y(`span`,{children:t.t.handles.instead}),` `,n.map(e=>Y(`code`,{children:[`@`,e.handle]},e.handle))]})]})}function bn(){return Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:Y(`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 xn({messages:e,locale:t,assistantName:n,suggestions:r,showSuggestions:i,busy:a,withHuman:o,onSuggestion:s,onChoice:c,onDecide:l,onLoadAttachment:u}){let d=K(null),f=K(!0);return ge(()=>{let e=d.current;e&&f.current&&(e.scrollTop=e.scrollHeight)},[e]),G(()=>{let e=d.current;if(!e)return;let t=()=>{f.current=e.scrollHeight-e.scrollTop-e.clientHeight<mn};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),Y(`div`,{class:`sqc-messages`,ref:d,role:`log`,"aria-live":`polite`,"aria-atomic":`false`,children:[e.map((r,i)=>Y(vn,{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&&Y(`p`,{class:`sqc-with-human`,role:`status`,children:t.t.withHuman}),i&&r&&r.length>0&&Y(`div`,{class:`sqc-suggestions`,children:r.map(e=>Y(`button`,{type:`button`,class:`sqc-suggestion`,onClick:()=>s(e),children:e},e))})]})}var Sn={width:`min(392px, 100vw)`},Cn=new Set([`sessionId`]);function wn(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 Tn(e){if(!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if(Cn.has(n)||typeof r!=`string`&&!Oe(r))continue;let e=De(r);e&&t.push({label:wn(n),value:e})}return t}function En(e,t){return e?.trim()?e:t}function Dn(e){let[t,n]=W(!1);return G(()=>{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 On(e){let t=e.persistOpen??!0,[n,r]=W(()=>Be(e.defaultOpen,t)),[i,a]=W(!1),[o,s]=W(!1),c=K(null),l=K(null),u=Dn(e.theme??`light`),d=_e(()=>Ie(e.locale),[e.locale]),f=d.t,p=En(e.heading,f.heading),m=En(e.assistantName,f.assistant),h=En(e.greeting,f.greeting),g=e.onEvent,{send:_,reset:v,decide:y,stop:b,start:x,busy:S,messages:C,withHuman:w,branding:T,sessionId:E,handles:D,addressee:O,agentHandle:k,attachments:A,uploading:j,attachmentError:M,attach:N,detach:P,loadAttachment:F}=Dt({embedKey:e.embedKey,user:e.user,getSubjectToken:e.getSubjectToken,agent:e.agent,context:e.context,greeting:h,locale:d,onEvent:g});G(()=>{!n&&C.some(e=>e.role===`assistant`&&e.id!==`greeting`)&&s(!0)},[C,n]);let I=K(n);I.current=n;let ee=q(()=>{s(!1),!I.current&&(I.current=!0,r(!0),t&&ze(!0),g?.({type:`chatbot-open`,sessionId:E}))},[g,t,E]),L=q(()=>{I.current&&(I.current=!1,r(!1),t&&ze(!1),g?.({type:`chatbot-close`,sessionId:E}),l.current?.focus())},[g,t,E]);G(()=>{n&&x()},[n,x]);let te=D.length>=2,R=Ve(C,k||void 0),[ne,re]=W(void 0),ie=K(void 0),ae=q(e=>{ie.current=e,re(e)},[]);G(()=>{ie.current=void 0,re(void 0)},[R]);let z=q(e=>{a(!0),_(te?He(e,ie.current,R):e)},[_,te,R]),B=q(()=>{a(!1),s(!1),v()},[v]),V=K({openPanel:ee,closePanel:L,send:z,reset:B,sessionId:E});V.current={openPanel:ee,closePanel:L,send:z,reset:B,sessionId:E};let oe=K({open:()=>V.current.openPanel(),close:()=>V.current.closePanel(),toggle:()=>I.current?V.current.closePanel():V.current.openPanel(),reset:()=>V.current.reset(),send:e=>{V.current.openPanel(),V.current.send(e)},isOpen:()=>I.current,sessionId:()=>V.current.sessionId}),H=e.bind;ge(()=>(H?.(oe.current),()=>H?.(null)),[H]),G(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),L())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[L,n]);let se=_e(()=>C.some(e=>e.id!==`greeting`),[C]),U=_e(()=>Tn(e.context),[e.context]),ce={...e.accent?{"--sqc-accent":e.accent}:{},"--sqc-width":e.width??Sn.width};return Y(`div`,{class:`sqc`,"data-theme":u,"data-position":e.position??`bottom-right`,"data-layout":e.layout??`sidebar`,"data-open":n?`true`:`false`,style:ce,children:[Y(`button`,{ref:l,type:`button`,class:`sqc-launcher`,"aria-label":p,"aria-expanded":n,"aria-haspopup":`dialog`,onClick:ee,children:[Y(`span`,{class:`sqc-launcher__icon`,children:Y(`slot`,{name:`launcher-icon`,class:`sqc-slot-icon`,children:Y(bn,{})})}),o&&Y(`span`,{class:`sqc-launcher__badge`,"aria-hidden":`true`})]}),Y(`aside`,{ref:c,class:`sqc-panel`,role:`dialog`,"aria-modal":`false`,"aria-label":p,...n?{}:{inert:!0},children:[Y(`header`,{class:`sqc-header`,children:[Y(`span`,{class:`sqc-header__icon`,"aria-hidden":`true`,children:Y(bn,{})}),Y(`div`,{class:`sqc-header__titles`,children:[Y(`p`,{class:`sqc-header__heading`,children:p}),Y(`p`,{class:`sqc-header__sub`,children:En(e.subheading,f.subheading)})]}),Y(`button`,{type:`button`,class:`sqc-icon-btn`,onClick:B,"aria-label":f.newConversation,"data-tip":f.newConversation,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,children:Y(`path`,{d:`M20 12a8 8 0 1 1-2.6-5.9M20 4v4h-4`,"stroke-linecap":`round`})})}),Y(`button`,{type:`button`,class:`sqc-icon-btn`,onClick:L,"aria-label":f.close,"data-tip":f.closeTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,children:Y(`path`,{d:`M6 6l12 12M18 6L6 18`,"stroke-linecap":`round`})})})]}),Y(`div`,{class:`sqc-panel__body`,children:[te&&Y(jt,{handles:D,active:ne??R,disabled:w,onPick:ae,label:f.handles.rail}),Y(`div`,{class:`sqc-panel__main`,children:[U.length>0&&Y(`div`,{class:`sqc-context`,"aria-label":f.context.region,children:U.map(e=>Y(`span`,{class:`sqc-chip`,title:`${e.label}: ${e.value}`,children:[Y(`b`,{children:e.label}),e.value]},e.label))}),Y(xn,{messages:C,locale:d,assistantName:m,suggestions:e.suggestions,showSuggestions:!i&&!se,busy:S,withHuman:w,onSuggestion:z,onChoice:z,onDecide:y,onLoadAttachment:F}),Y(Lt,{placeholder:En(e.placeholder,f.placeholder),locale:d,busy:S,autoFocus:n,handles:D,addressee:O,attachments:A,uploading:j,attachmentError:M?f.attachments[M]:void 0,onAttach:N,onDetach:P,onSend:z,onStop:b}),Y(`p`,{class:`sqc-hint`,children:f.hint}),T&&Y(`p`,{class:`sqc-powered`,children:Y(`a`,{href:`https://squadico.com`,target:`_blank`,rel:`noopener noreferrer`,children:f.poweredBy})})]})]})]})]})}var kn=`: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-panel__body{flex:1;min-height:0;display:flex}.sqc-panel__main{flex-direction:column;flex:1;min-width:0;min-height:0;display:flex}.sqc-rail{border-right:1px solid var(--sqc-border);background:color-mix(in oklab, var(--sqc-accent-color) 7%, var(--sqc-bg));flex-direction:column;flex-shrink:0;align-items:stretch;gap:6px;width:72px;padding:12px 0;display:flex;overflow:visible}.sqc-rail__item{color:var(--sqc-text-muted);font:inherit;cursor:pointer;background:0 0;border:0;flex-direction:column;align-items:center;gap:4px;padding:4px 0;display:flex;position:relative}.sqc-rail__label{white-space:nowrap;text-overflow:ellipsis;max-width:64px;font-size:10.5px;font-weight:500;line-height:1.2;overflow:hidden}.sqc-rail__item:hover,.sqc-rail__item[aria-pressed=true]{color:var(--sqc-text)}.sqc-rail__item[aria-pressed=true] .sqc-rail__label{font-weight:600}.sqc-rail__item .sqc-avatar{transition:box-shadow .15s}.sqc-rail__item[aria-pressed=true] .sqc-avatar{box-shadow:0 0 0 2px var(--sqc-bg), 0 0 0 4px var(--sqc-accent-color)}.sqc-rail__item:before{content:"";background:var(--sqc-text);border-radius:0 4px 4px 0;width:4px;height:0;transition:height .15s;position:absolute;top:24px;left:0;transform:translateY(-50%)}.sqc-rail__item:hover:before{height:12px}.sqc-rail__item[aria-pressed=true]:before{height:32px}.sqc-rail__item:focus-visible{outline:2px solid var(--sqc-accent-color);outline-offset:-2px;border-radius:8px}.sqc-rail__item:disabled{cursor:not-allowed;opacity:.5}.sqc-rail__item[data-tip]:after{content:attr(data-tip);z-index:2;background:var(--sqc-text);color:var(--sqc-bg);white-space:nowrap;pointer-events:none;opacity:0;border-radius:6px;padding:4px 8px;font-size:12px;font-weight:500;transition:opacity .12s;position:absolute;top:24px;left:calc(100% + 6px);transform:translateY(-50%)}.sqc-rail__item[data-tip]:hover:after{opacity:1}.sqc-rail__item[data-tip]:focus-visible:after{opacity:1}.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-avatar{background:var(--sqc-accent-color);color:var(--sqc-on-accent);-webkit-user-select:none;user-select:none;flex-shrink:0;justify-content:center;align-items:center;font-weight:600;line-height:1;display:inline-flex;overflow:hidden}.sqc-avatar img{object-fit:cover;width:100%;height:100%}.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}.sqc-powered{padding:0 16px max(9px, env(safe-area-inset-bottom));text-align:center;flex-shrink:0;margin:0;font-size:10.5px;line-height:1.35}.sqc-powered a{color:var(--sqc-text-muted);text-decoration:none}.sqc-powered a:hover{text-decoration:underline}@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,.sqc-rail__item:before,.sqc-rail__item[data-tip]:after,.sqc-rail__item .sqc-avatar{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 An(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function jn(e,t){An(e,t),t.add(e)}function X(e,t,n){An(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 Mn=`squadico-chatbot`,Nn=[`embed-key`,`context`,`user`,`agent`,`heading`,`subheading`,`assistant-name`,`placeholder`,`greeting`,`suggestions`,`width`,`accent`,`theme`,`position`,`layout`,`open`,`persist-open`,`locale`],Pn;function Fn(){if(Pn!==void 0)return Pn;try{let e=new CSSStyleSheet;e.replaceSync(kn),Pn=e}catch{Pn=null}return Pn}function In(e,t){typeof console<`u`&&console.warn(`[${Mn}] ${e}`,t??``)}function Ln(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}}In(`the "user" attribute needs an object with an id`,e)}catch(e){In(`the "user" attribute is not valid JSON`,e)}}function Rn(e){if(!(!e||!e.trim()))try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t;In("the `context` attribute must be a JSON object",e)}catch(e){In("the `context` attribute is not valid JSON",e)}}function zn(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){In("the `suggestions` attribute is not valid JSON",e);return}return e.split(`|`).map(e=>e.trim()).filter(Boolean)}}function Bn(e){if(e!==null)return e!==`false`&&e!==`0`}function Vn(e){return e===`dark`||e===`light`||e===`auto`?e:void 0}function Hn(e){return e===`bottom-left`||e===`bottom-right`?e:void 0}function Un(e){return e===`floating`||e===`sidebar`?e:void 0}var Wn=[`context`,`embedKey`,`user`,`getSubjectToken`,`agent`];function Gn(){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(),jn(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=Fn();if(m)e.adoptedStyleSheets=[m];else{let t=document.createElement(`style`);t.textContent=kn,e.append(t)}Q(t,this,document.createElement(`div`)),e.append($(t,this));for(let e of Wn){if(!Object.hasOwn(this,e))continue;let t=this[e];delete this[e],this[e]=t}}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)){Bn(r)?$(n,this).open():$(n,this).close();return}Z(d,this,m).call(this)}}get context(){return $(o,this)??Rn(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)??Ln(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()??Bn(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)){In(`sendMessage() called before the component was mounted — ignored`);return}$(n,this).send(e)}},qe(e,`observedAttributes`,Nn),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(Y(On,{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:zn(this.getAttribute(`suggestions`)),width:e(`width`),accent:e(`accent`),theme:Vn(this.getAttribute(`theme`)),position:Hn(this.getAttribute(`position`)),layout:Un(this.getAttribute(`layout`)),defaultOpen:Bn(this.getAttribute(`open`))??!1,persistOpen:Bn(this.getAttribute(`persist-open`))??!0,locale:e(`locale`),onEvent:$(f,this),bind:$(p,this)}),$(t,this))}}var Kn;function qn(e=Mn){typeof window>`u`||typeof HTMLElement>`u`||(Kn??(Kn=Gn()),window.customElements.get(e)||window.customElements.define(e,Kn))}qn(),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return qn}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Mn}});
8
- //# sourceMappingURL=src-CcILETWB.cjs.map
7
+ `)})},n));continue}if(cn.test(f)&&e+1<r.length&&ln.test(r[e+1])){d();let t=dn(f),n=[];for(e+=2;e<r.length&&cn.test(r[e]);)n.push(dn(r[e])),e+=1;--e;let a=`t${i.length}`;i.push(Y(`div`,{class:`sqc-table`,children:Y(`table`,{children:[Y(`thead`,{children:Y(`tr`,{children:t.map((e,t)=>Y(`th`,{children:$t(e,`${a}-h${t}`)},`${a}-h${t}`))})}),Y(`tbody`,{children:n.map((e,n)=>Y(`tr`,{children:t.map((t,r)=>Y(`td`,{children:$t(e[r]??``,`${a}-r${n}c${r}`)},`${a}-r${n}c${r}`))},`${a}-r${n}`))})]})},a));continue}if(!f.trim()){d();continue}if(en.test(f)){d();let a=[];for(;e<r.length;){let t=en.exec(r[e]);if(!t)break;let n=t[2].trim(),o=`o${i.length}-${a.length}`;a.push({label:tn(n),checked:t[1].toLowerCase()===`x`,content:$t(n,o)}),e+=1}--e,i.push(Y(Jt,{items:a,locale:t,onPick:n},`o${i.length}`));continue}let p=an.exec(f);if(p){d();let e=p[1].length,t=e<=2?`h3`:e===3?`h4`:`h5`,n=`h${i.length}`;i.push(Y(t,{children:$t(p[2],n)},n));continue}if(on.test(f)){d(),i.push(Y(`hr`,{},`r${i.length}`));continue}let m=sn.exec(f);if(m){c(),l(),s.push(m[1]);continue}let h=nn.exec(f),g=h?null:rn.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(),Y(S,{children:i})}var mn=80;function hn({at:e,locale:t}){let n=new Date(e);return Y(`time`,{class:`sqc-msg__time`,dateTime:n.toISOString(),children:n.toLocaleTimeString(t.tag,{hour:`2-digit`,minute:`2-digit`})})}function gn({file:e,load:t}){let[n,r]=W(null);return G(()=>{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?Y(`img`,{class:`sqc-attachment__image`,src:n,alt:e.filename}):Y(`span`,{class:`sqc-chip sqc-chip--waiting`,children:e.filename})}function _n({files:e,load:t}){return e.length===0||!t?null:Y(`div`,{class:`sqc-attachments sqc-attachments--sent`,children:e.map(e=>e.kind===`image`?Y(gn,{file:e,load:t},e.id):Y(`span`,{class:`sqc-chip`,"data-kind":`document`,children:Y(`span`,{class:`sqc-chip__name`,children:e.filename})},e.id))})}function vn({message:e,locale:t,assistantName:n,onChoice:r,onDecide:i,onLoadAttachment:a}){let o=e.streaming&&!e.content,s=!!e.approval;return Y(`div`,{class:`sqc-msg sqc-msg--${e.role}${e.error?` sqc-msg--error`:``}`,children:[e.role===`assistant`&&Y(`div`,{class:`sqc-msg__who`,children:[e.agent?Y(kt,{name:e.agent.name,color:e.agent.color,url:e.agent.avatarUrl}):Y(bn,{}),e.authorName??e.agent?.name??n]}),Y(`div`,{class:`sqc-msg__bubble`,children:[o?Y(`span`,{class:`sqc-typing`,"aria-label":t.t.typing,children:[Y(`i`,{}),Y(`i`,{}),Y(`i`,{})]}):Y(`div`,{class:`sqc-msg__body`,children:[Y(pn,{text:e.content,locale:t,onChoice:r}),e.streaming&&Y(`span`,{class:`sqc-caret`,"aria-hidden":`true`}),s&&Y(Gt,{locale:t,call:e.content.trim()===``?e.approval:void 0,onDecide:i}),e.role===`assistant`&&!s&&!e.streaming&&!e.error&&Vt(e.content,t.code)&&Y(Kt,{locale:t,onPick:r}),e.unknownHandle&&!e.streaming&&Y(yn,{message:e,locale:t}),Y(_n,{files:e.attachments??[],load:a})]}),!o&&Y(hn,{at:e.createdAt,locale:t})]})]})}function yn({message:e,locale:t}){let n=e.offered??[];return Y(`p`,{class:`sqc-msg__unaddressed`,children:[Y(`span`,{children:t.t.handles.unknown}),` `,Y(`code`,{children:[`@`,e.unknownHandle]}),n.length>0&&Y(S,{children:[` `,Y(`span`,{children:t.t.handles.instead}),` `,n.map(e=>Y(`code`,{children:[`@`,e.handle]},e.handle))]})]})}function bn(){return Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:Y(`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 xn({messages:e,locale:t,assistantName:n,suggestions:r,showSuggestions:i,busy:a,withHuman:o,onSuggestion:s,onChoice:c,onDecide:l,onLoadAttachment:u}){let d=K(null),f=K(!0);return ge(()=>{let e=d.current;e&&f.current&&(e.scrollTop=e.scrollHeight)},[e]),G(()=>{let e=d.current;if(!e)return;let t=()=>{f.current=e.scrollHeight-e.scrollTop-e.clientHeight<mn};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),Y(`div`,{class:`sqc-messages`,ref:d,role:`log`,"aria-live":`polite`,"aria-atomic":`false`,children:[e.map((r,i)=>Y(vn,{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&&Y(`p`,{class:`sqc-with-human`,role:`status`,children:t.t.withHuman}),i&&r&&r.length>0&&Y(`div`,{class:`sqc-suggestions`,children:r.map(e=>Y(`button`,{type:`button`,class:`sqc-suggestion`,onClick:()=>s(e),children:e},e))})]})}var Sn={width:`min(392px, 100vw)`},Cn=new Set([`sessionId`]);function wn(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 Tn(e){if(!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if(Cn.has(n)||typeof r!=`string`&&!Oe(r))continue;let e=De(r);e&&t.push({label:wn(n),value:e})}return t}function En(e,t){return e?.trim()?e:t}function Dn(e){let[t,n]=W(!1);return G(()=>{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 On(e){let t=e.persistOpen??!0,[n,r]=W(()=>Be(e.defaultOpen,t)),[i,a]=W(!1),[o,s]=W(!1),c=K(null),l=K(null),u=Dn(e.theme??`light`),d=_e(()=>Ie(e.locale),[e.locale]),f=d.t,p=En(e.heading,f.heading),m=En(e.assistantName,f.assistant),h=En(e.greeting,f.greeting),g=e.onEvent,{send:_,reset:v,decide:y,stop:b,start:x,busy:S,messages:C,withHuman:w,branding:T,sessionId:E,handles:D,addressee:O,agentHandle:k,attachments:A,uploading:j,attachmentError:M,attach:N,detach:P,loadAttachment:F}=Dt({embedKey:e.embedKey,user:e.user,getSubjectToken:e.getSubjectToken,agent:e.agent,context:e.context,greeting:h,locale:d,onEvent:g});G(()=>{!n&&C.some(e=>e.role===`assistant`&&e.id!==`greeting`)&&s(!0)},[C,n]);let I=K(n);I.current=n;let ee=q(()=>{s(!1),!I.current&&(I.current=!0,r(!0),t&&ze(!0),g?.({type:`chatbot-open`,sessionId:E}))},[g,t,E]),L=q(()=>{I.current&&(I.current=!1,r(!1),t&&ze(!1),g?.({type:`chatbot-close`,sessionId:E}),l.current?.focus())},[g,t,E]);G(()=>{n&&x()},[n,x]);let te=D.length>=2,R=Ve(C,k||void 0),[ne,re]=W(void 0),ie=K(void 0),ae=q(e=>{ie.current=e,re(e)},[]);G(()=>{ie.current=void 0,re(void 0)},[R]);let z=q(e=>{a(!0),_(te?He(e,ie.current,R):e)},[_,te,R]),B=q(()=>{a(!1),s(!1),v()},[v]),V=K({openPanel:ee,closePanel:L,send:z,reset:B,sessionId:E});V.current={openPanel:ee,closePanel:L,send:z,reset:B,sessionId:E};let oe=K({open:()=>V.current.openPanel(),close:()=>V.current.closePanel(),toggle:()=>I.current?V.current.closePanel():V.current.openPanel(),reset:()=>V.current.reset(),send:e=>{V.current.openPanel(),V.current.send(e)},isOpen:()=>I.current,sessionId:()=>V.current.sessionId}),H=e.bind;ge(()=>(H?.(oe.current),()=>H?.(null)),[H]),G(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),L())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[L,n]);let se=_e(()=>C.some(e=>e.id!==`greeting`),[C]),U=_e(()=>Tn(e.context),[e.context]),ce={...e.accent?{"--sqc-accent":e.accent}:{},"--sqc-width":e.width??Sn.width};return Y(`div`,{class:`sqc`,"data-theme":u,"data-position":e.position??`bottom-right`,"data-layout":e.layout??`sidebar`,"data-open":n?`true`:`false`,style:ce,children:[Y(`button`,{ref:l,type:`button`,class:`sqc-launcher`,"aria-label":p,"aria-expanded":n,"aria-haspopup":`dialog`,onClick:ee,children:[Y(`span`,{class:`sqc-launcher__icon`,children:Y(`slot`,{name:`launcher-icon`,class:`sqc-slot-icon`,children:Y(bn,{})})}),o&&Y(`span`,{class:`sqc-launcher__badge`,"aria-hidden":`true`})]}),Y(`aside`,{ref:c,class:`sqc-panel`,role:`dialog`,"aria-modal":`false`,"aria-label":p,...n?{}:{inert:!0},children:[Y(`header`,{class:`sqc-header`,children:[Y(`span`,{class:`sqc-header__icon`,"aria-hidden":`true`,children:Y(bn,{})}),Y(`div`,{class:`sqc-header__titles`,children:[Y(`p`,{class:`sqc-header__heading`,children:p}),Y(`p`,{class:`sqc-header__sub`,children:En(e.subheading,f.subheading)})]}),Y(`button`,{type:`button`,class:`sqc-icon-btn`,onClick:B,"aria-label":f.newConversation,"data-tip":f.newConversation,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,children:Y(`path`,{d:`M20 12a8 8 0 1 1-2.6-5.9M20 4v4h-4`,"stroke-linecap":`round`})})}),Y(`button`,{type:`button`,class:`sqc-icon-btn`,onClick:L,"aria-label":f.close,"data-tip":f.closeTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,children:Y(`path`,{d:`M6 6l12 12M18 6L6 18`,"stroke-linecap":`round`})})})]}),Y(`div`,{class:`sqc-panel__body`,children:[te&&Y(jt,{handles:D,active:ne??R,disabled:w,onPick:ae,label:f.handles.rail}),Y(`div`,{class:`sqc-panel__main`,children:[(e.showContext??!0)&&U.length>0&&Y(`div`,{class:`sqc-context`,"aria-label":f.context.region,children:U.map(e=>Y(`span`,{class:`sqc-chip`,title:`${e.label}: ${e.value}`,children:[Y(`b`,{children:e.label}),e.value]},e.label))}),Y(xn,{messages:C,locale:d,assistantName:m,suggestions:e.suggestions,showSuggestions:!i&&!se,busy:S,withHuman:w,onSuggestion:z,onChoice:z,onDecide:y,onLoadAttachment:F}),Y(Lt,{placeholder:En(e.placeholder,f.placeholder),locale:d,busy:S,autoFocus:n,handles:D,addressee:O,attachments:A,uploading:j,attachmentError:M?f.attachments[M]:void 0,onAttach:N,onDetach:P,onSend:z,onStop:b}),Y(`p`,{class:`sqc-hint`,children:f.hint}),T&&Y(`p`,{class:`sqc-powered`,children:Y(`a`,{href:`https://squadico.com`,target:`_blank`,rel:`noopener noreferrer`,children:f.poweredBy})})]})]})]})]})}var kn=`: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-panel__body{flex:1;min-height:0;display:flex}.sqc-panel__main{flex-direction:column;flex:1;min-width:0;min-height:0;display:flex}.sqc-rail{border-right:1px solid var(--sqc-border);background:color-mix(in oklab, var(--sqc-accent-color) 7%, var(--sqc-bg));flex-direction:column;flex-shrink:0;align-items:stretch;gap:6px;width:72px;padding:12px 0;display:flex;overflow:visible}.sqc-rail__item{color:var(--sqc-text-muted);font:inherit;cursor:pointer;background:0 0;border:0;flex-direction:column;align-items:center;gap:4px;padding:4px 0;display:flex;position:relative}.sqc-rail__label{white-space:nowrap;text-overflow:ellipsis;max-width:64px;font-size:10.5px;font-weight:500;line-height:1.2;overflow:hidden}.sqc-rail__item:hover,.sqc-rail__item[aria-pressed=true]{color:var(--sqc-text)}.sqc-rail__item[aria-pressed=true] .sqc-rail__label{font-weight:600}.sqc-rail__item .sqc-avatar{transition:box-shadow .15s}.sqc-rail__item[aria-pressed=true] .sqc-avatar{box-shadow:0 0 0 2px var(--sqc-bg), 0 0 0 4px var(--sqc-accent-color)}.sqc-rail__item:before{content:"";background:var(--sqc-text);border-radius:0 4px 4px 0;width:4px;height:0;transition:height .15s;position:absolute;top:24px;left:0;transform:translateY(-50%)}.sqc-rail__item:hover:before{height:12px}.sqc-rail__item[aria-pressed=true]:before{height:32px}.sqc-rail__item:focus-visible{outline:2px solid var(--sqc-accent-color);outline-offset:-2px;border-radius:8px}.sqc-rail__item:disabled{cursor:not-allowed;opacity:.5}.sqc-rail__item[data-tip]:after{content:attr(data-tip);z-index:2;background:var(--sqc-text);color:var(--sqc-bg);white-space:nowrap;pointer-events:none;opacity:0;border-radius:6px;padding:4px 8px;font-size:12px;font-weight:500;transition:opacity .12s;position:absolute;top:24px;left:calc(100% + 6px);transform:translateY(-50%)}.sqc-rail__item[data-tip]:hover:after{opacity:1}.sqc-rail__item[data-tip]:focus-visible:after{opacity:1}.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-avatar{background:var(--sqc-accent-color);color:var(--sqc-on-accent);-webkit-user-select:none;user-select:none;flex-shrink:0;justify-content:center;align-items:center;font-weight:600;line-height:1;display:inline-flex;overflow:hidden}.sqc-avatar img{object-fit:cover;width:100%;height:100%}.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}.sqc-powered{padding:0 16px max(9px, env(safe-area-inset-bottom));text-align:center;flex-shrink:0;margin:0;font-size:10.5px;line-height:1.35}.sqc-powered a{color:var(--sqc-text-muted);text-decoration:none}.sqc-powered a:hover{text-decoration:underline}@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,.sqc-rail__item:before,.sqc-rail__item[data-tip]:after,.sqc-rail__item .sqc-avatar{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 An(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function jn(e,t){An(e,t),t.add(e)}function X(e,t,n){An(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 Mn=`squadico-chatbot`,Nn=[`embed-key`,`context`,`user`,`agent`,`heading`,`subheading`,`assistant-name`,`placeholder`,`greeting`,`suggestions`,`width`,`accent`,`theme`,`position`,`layout`,`open`,`persist-open`,`show-context`,`locale`],Pn;function Fn(){if(Pn!==void 0)return Pn;try{let e=new CSSStyleSheet;e.replaceSync(kn),Pn=e}catch{Pn=null}return Pn}function In(e,t){typeof console<`u`&&console.warn(`[${Mn}] ${e}`,t??``)}function Ln(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}}In(`the "user" attribute needs an object with an id`,e)}catch(e){In(`the "user" attribute is not valid JSON`,e)}}function Rn(e){if(!(!e||!e.trim()))try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t;In("the `context` attribute must be a JSON object",e)}catch(e){In("the `context` attribute is not valid JSON",e)}}function zn(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){In("the `suggestions` attribute is not valid JSON",e);return}return e.split(`|`).map(e=>e.trim()).filter(Boolean)}}function Bn(e){if(e!==null)return e!==`false`&&e!==`0`}function Vn(e){return e===`dark`||e===`light`||e===`auto`?e:void 0}function Hn(e){return e===`bottom-left`||e===`bottom-right`?e:void 0}function Un(e){return e===`floating`||e===`sidebar`?e:void 0}var Wn=[`context`,`embedKey`,`user`,`getSubjectToken`,`agent`];function Gn(){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(),jn(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=Fn();if(m)e.adoptedStyleSheets=[m];else{let t=document.createElement(`style`);t.textContent=kn,e.append(t)}Q(t,this,document.createElement(`div`)),e.append($(t,this));for(let e of Wn){if(!Object.hasOwn(this,e))continue;let t=this[e];delete this[e],this[e]=t}}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)){Bn(r)?$(n,this).open():$(n,this).close();return}Z(d,this,m).call(this)}}get context(){return $(o,this)??Rn(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)??Ln(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()??Bn(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)){In(`sendMessage() called before the component was mounted — ignored`);return}$(n,this).send(e)}},qe(e,`observedAttributes`,Nn),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(Y(On,{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:zn(this.getAttribute(`suggestions`)),width:e(`width`),accent:e(`accent`),theme:Vn(this.getAttribute(`theme`)),position:Hn(this.getAttribute(`position`)),layout:Un(this.getAttribute(`layout`)),defaultOpen:Bn(this.getAttribute(`open`))??!1,persistOpen:Bn(this.getAttribute(`persist-open`))??!0,showContext:Bn(this.getAttribute(`show-context`))??!0,locale:e(`locale`),onEvent:$(f,this),bind:$(p,this)}),$(t,this))}}var Kn;function qn(e=Mn){typeof window>`u`||typeof HTMLElement>`u`||(Kn??(Kn=Gn()),window.customElements.get(e)||window.customElements.define(e,Kn))}qn(),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return qn}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Mn}});
8
+ //# sourceMappingURL=src-DcJyi601.cjs.map