@squadico/chatbot 1.3.0 → 1.5.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.
Files changed (113) hide show
  1. package/README.md +110 -20
  2. package/dist/answer-CDGrP8YE.js +1193 -0
  3. package/dist/answer-CDGrP8YE.js.map +1 -0
  4. package/dist/answer-DRaV2dVt.cjs +8 -0
  5. package/dist/answer-DRaV2dVt.cjs.map +1 -0
  6. package/dist/chatbot-widgets.global.js +4 -0
  7. package/dist/chatbot-widgets.global.js.map +1 -0
  8. package/dist/chatbot.global.js +12 -7
  9. package/dist/chatbot.global.js.map +1 -1
  10. package/dist/components/ChatbotWidget.d.ts.map +1 -1
  11. package/dist/components/MessageList.d.ts +4 -1
  12. package/dist/components/MessageList.d.ts.map +1 -1
  13. package/dist/components/RichText.d.ts +6 -4
  14. package/dist/components/RichText.d.ts.map +1 -1
  15. package/dist/element.d.ts.map +1 -1
  16. package/dist/extras-ClIRRLqo.js +604 -0
  17. package/dist/extras-ClIRRLqo.js.map +1 -0
  18. package/dist/extras-lsCe4xgN.cjs +4 -0
  19. package/dist/extras-lsCe4xgN.cjs.map +1 -0
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +3 -2
  24. package/dist/jsx.d.ts +41 -0
  25. package/dist/jsx.d.ts.map +1 -1
  26. package/dist/lib/client.d.ts +8 -4
  27. package/dist/lib/client.d.ts.map +1 -1
  28. package/dist/lib/conversation.d.ts +5 -1
  29. package/dist/lib/conversation.d.ts.map +1 -1
  30. package/dist/lib/i18n.d.ts +20 -0
  31. package/dist/lib/i18n.d.ts.map +1 -1
  32. package/dist/lib/useChat.d.ts +6 -0
  33. package/dist/lib/useChat.d.ts.map +1 -1
  34. package/dist/react.cjs +1 -1
  35. package/dist/react.cjs.map +1 -1
  36. package/dist/react.d.ts.map +1 -1
  37. package/dist/react.js +2 -2
  38. package/dist/react.js.map +1 -1
  39. package/dist/src-BWDC0W4O.js +2005 -0
  40. package/dist/src-BWDC0W4O.js.map +1 -0
  41. package/dist/src-DvrmRR89.cjs +7 -0
  42. package/dist/src-DvrmRR89.cjs.map +1 -0
  43. package/dist/types.d.ts +16 -2
  44. package/dist/types.d.ts.map +1 -1
  45. package/dist/widgets/approval/SqcApproval.d.ts +17 -0
  46. package/dist/widgets/approval/SqcApproval.d.ts.map +1 -0
  47. package/dist/widgets/approval/name.d.ts +3 -0
  48. package/dist/widgets/approval/name.d.ts.map +1 -0
  49. package/dist/widgets/chart/SqcChart.d.ts +19 -0
  50. package/dist/widgets/chart/SqcChart.d.ts.map +1 -0
  51. package/dist/widgets/chart/draw.d.ts +31 -0
  52. package/dist/widgets/chart/draw.d.ts.map +1 -0
  53. package/dist/widgets/chart/png.d.ts +10 -0
  54. package/dist/widgets/chart/png.d.ts.map +1 -0
  55. package/dist/widgets/chart/read.d.ts +11 -0
  56. package/dist/widgets/chart/read.d.ts.map +1 -0
  57. package/dist/widgets/chart/strings.d.ts +32 -0
  58. package/dist/widgets/chart/strings.d.ts.map +1 -0
  59. package/dist/widgets/choices/SqcChoices.d.ts +17 -0
  60. package/dist/widgets/choices/SqcChoices.d.ts.map +1 -0
  61. package/dist/widgets/confirm/SqcConfirm.d.ts +12 -0
  62. package/dist/widgets/confirm/SqcConfirm.d.ts.map +1 -0
  63. package/dist/widgets/define.d.ts +8 -0
  64. package/dist/widgets/define.d.ts.map +1 -0
  65. package/dist/widgets/element.d.ts +26 -0
  66. package/dist/widgets/element.d.ts.map +1 -0
  67. package/dist/widgets/extras-loader.d.ts +21 -0
  68. package/dist/widgets/extras-loader.d.ts.map +1 -0
  69. package/dist/widgets/extras.d.ts +3 -0
  70. package/dist/widgets/extras.d.ts.map +1 -0
  71. package/dist/widgets/extras.global.d.ts +2 -0
  72. package/dist/widgets/extras.global.d.ts.map +1 -0
  73. package/dist/widgets/form/SqcForm.d.ts +14 -0
  74. package/dist/widgets/form/SqcForm.d.ts.map +1 -0
  75. package/dist/widgets/form/reply.d.ts +7 -0
  76. package/dist/widgets/form/reply.d.ts.map +1 -0
  77. package/dist/widgets/i18n.d.ts +4 -0
  78. package/dist/widgets/i18n.d.ts.map +1 -0
  79. package/dist/widgets/index.d.ts +10 -0
  80. package/dist/widgets/index.d.ts.map +1 -0
  81. package/dist/widgets/inline.d.ts +11 -0
  82. package/dist/widgets/inline.d.ts.map +1 -0
  83. package/dist/widgets/live.d.ts +12 -0
  84. package/dist/widgets/live.d.ts.map +1 -0
  85. package/dist/widgets/names.d.ts +10 -0
  86. package/dist/widgets/names.d.ts.map +1 -0
  87. package/dist/widgets/parse/answer.d.ts +11 -0
  88. package/dist/widgets/parse/answer.d.ts.map +1 -0
  89. package/dist/widgets/parse/confirm.d.ts +19 -0
  90. package/dist/widgets/parse/confirm.d.ts.map +1 -0
  91. package/dist/widgets/parse/form.d.ts +6 -0
  92. package/dist/widgets/parse/form.d.ts.map +1 -0
  93. package/dist/widgets/styles.d.ts +3 -0
  94. package/dist/widgets/styles.d.ts.map +1 -0
  95. package/dist/widgets/table/SqcTable.d.ts +16 -0
  96. package/dist/widgets/table/SqcTable.d.ts.map +1 -0
  97. package/dist/widgets/types.d.ts +68 -0
  98. package/dist/widgets/types.d.ts.map +1 -0
  99. package/dist/widgets.cjs +1 -0
  100. package/dist/widgets.js +3 -0
  101. package/package.json +7 -2
  102. package/dist/components/Approval.d.ts +0 -37
  103. package/dist/components/Approval.d.ts.map +0 -1
  104. package/dist/components/Choices.d.ts +0 -27
  105. package/dist/components/Choices.d.ts.map +0 -1
  106. package/dist/components/Confirm.d.ts +0 -16
  107. package/dist/components/Confirm.d.ts.map +0 -1
  108. package/dist/lib/confirm.d.ts +0 -17
  109. package/dist/lib/confirm.d.ts.map +0 -1
  110. package/dist/src-DcJyi601.cjs +0 -8
  111. package/dist/src-DcJyi601.cjs.map +0 -1
  112. package/dist/src-Nh5rZvti.js +0 -2710
  113. package/dist/src-Nh5rZvti.js.map +0 -1
@@ -1,8 +1,13 @@
1
- var Chatbot=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h={},g=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,t){for(var n in t)e[n]=t[n];return e}function b(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function x(e,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?t.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return S(e,s,i,a,null)}function S(e,t,i,a,o){var s={type:e,props:t,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++r,__i:-1,__u:0};return o==null&&n.vnode!=null&&n.vnode(s),s}function C(e){return e.children}function w(e,t){this.props=e,this.context=t}function T(e,t){if(t==null)return e.__?T(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?T(e):null}function E(e){if(e.__P&&e.__d){var t=e.__v,r=t.__e,i=[],a=[],o=y({},t);o.__v=t.__v+1,n.vnode&&n.vnode(o),L(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[r]:null,i,r??T(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,z(i,o,a),t.__e=t.__=null,o.__e!=r&&D(o)}}function D(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),D(e)}function O(e){(!e.__d&&(e.__d=!0)&&i.push(e)&&!k.__r++||a!=n.debounceRendering)&&((a=n.debounceRendering)||o)(k)}function k(){try{for(var e,t=1;i.length;)i.length>t&&i.sort(s),e=i.shift(),t=i.length,E(e)}finally{i.length=k.__r=0}}function A(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,_,v,y=r&&r.__k||g,b=t.length;for(c=j(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||h,p.__i=d,v=L(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&te(f.ref,null,p),u.push(p.ref,p.__c||m,p)),_==null&&m!=null&&(_=m),4&p.__u?(c=M(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=_,c}function j(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=S(null,o,null,null,null):v(o)?o=e.__k[a]=S(C,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=S(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=N(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=T(s)),ne(s,s));return r}function M(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=M(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=T(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function N(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function P(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||_.test(t)?n:n+`px`}function F(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||P(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||P(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(d,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n[u]=r[u]:(n[u]=f,e.addEventListener(t,a?m:p,a)):e.removeEventListener(t,a?m:p,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function I(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t[l]==null)t[l]=f++;else if(t[l]<r[u])return;return r(n.event?n.event(t):t)}}}function L(e,t,r,i,a,o,s,c,l,u){var d,f,p,m,h,_,x,S,E,D,O,k,j,M,N,P,F=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(l=!!(32&r.__u),o=[c=t.__e=r.__e]),(d=n.__b)&&d(t);n:if(typeof F==`function`){f=s.length;try{if(E=t.props,D=F.prototype&&F.prototype.render,O=(d=F.contextType)&&i[d.__c],k=d?O?O.props.value:d.__:i,r.__c?S=(p=t.__c=r.__c).__=p.__E:(D?t.__c=p=new F(E,k):(t.__c=p=new w(E,k),p.constructor=F,p.render=re),O&&O.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),D&&p.__s==null&&(p.__s=p.state),D&&F.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=y({},p.__s)),y(p.__s,F.getDerivedStateFromProps(E,p.__s))),h=p.props,_=p.state,p.__v=t,m)D&&F.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),D&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(D&&F.getDerivedStateFromProps==null&&E!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(E,k),t.__v==r.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(E,p.__s,k)){t.__v!=r.__v&&(p.props=E,p.state=p.__s,p.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(e){e&&(e.__=t)}),g.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=T(r);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(E,p.__s,k),D&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,_,x)})}if(p.context=k,p.props=E,p.__P=e,p.__e=!1,j=n.__r,M=0,D)p.state=p.__s,p.__d=!1,j&&j(t),d=p.render(p.props,p.state,p.context),g.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,j&&j(t),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++M<25);p.state=p.__s,p.getChildContext!=null&&(i=y(y({},i),p.getChildContext())),D&&!m&&p.getSnapshotBeforeUpdate!=null&&(x=p.getSnapshotBeforeUpdate(h,_)),N=d!=null&&d.type===C&&d.key==null?B(d.props.children):d,c=A(e,v(N)?N:[N],t,r,i,a,o,s,c,l,u),p.base=t.__e,t.__u&=-161,p.__h.length&&s.push(p),S&&(p.__E=p.__=null)}catch(e){if(s.length=f,t.__v=null,l||o!=null){if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),t.__e=c}else if(o!=null)for(P=o.length;P--;)b(o[P])}else t.__e=r.__e;t.__k??(t.__k=r.__k||[]),e.then||R(t),n.__e(e,t,r)}}else o==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):c=t.__e=ee(r.__e,t,r,i,a,o,s,l,u);return(d=n.diffed)&&d(t),128&t.__u?void 0:c}function R(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(R))}function z(e,t,r){for(var i=0;i<r.length;i++)te(r[i],r[++i],r[++i]);n.__c&&n.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){n.__e(e,t.__v)}})}function B(e){return typeof e!=`object`||!e||e.__b>0?e:v(e)?e.map(B):e.constructor===void 0?y({},e):null}function ee(e,r,i,a,o,s,c,l,u){var d,f,p,m,g,_,y,x=i.props||h,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||(o=`http://www.w3.org/1999/xhtml`),s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){e=g,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&(n.__m&&n.__m(r,s),l=!1),s=null}if(C==null)x===S||l&&e.data==S||(e.data=S);else{if(s=C==`textarea`&&S.defaultValue!=null?null:s&&t.call(e.childNodes),!l&&s!=null)for(x={},d=0;d<e.attributes.length;d++)x[(g=e.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||F(e,d,null,g,o);for(d in S)g=S[d],d==`children`?m=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?_=g:d==`checked`?y=g:l&&typeof g!=`function`||x[d]===g||F(e,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),r.__k=[];else if(p&&(e.innerHTML=``),A(r.type==`template`?e.content:e,v(m)?m:[m],r,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&T(i,0),l,u),s!=null)for(d=s.length;d--;)b(s[d]);l&&C!=`textarea`||(d=`value`,C==`progress`&&_==null?e.removeAttribute(`value`):_!=null&&(_!==e[d]||C==`progress`&&!_||C==`option`&&_!=x[d])&&F(e,d,_,x[d],o),d=`checked`,y!=null&&y!=e[d]&&F(e,d,y,x[d],o))}return e}function te(e,t,r){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){n.__e(e,r)}}function ne(e,t,r){var i,a;if(n.unmount&&n.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||te(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){n.__e(e,t)}i.base=i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&ne(i[a],t,r||typeof e.type!=`function`);r||b(e.__e),e.__c=e.__=e.__e=void 0}function re(e,t,n){return this.constructor(e,n)}function ie(e,r,i){var a,o,s,c;r==document&&(r=document.documentElement),n.__&&n.__(e,r),o=(a=typeof i==`function`)?null:i&&i.__k||r.__k,s=[],c=[],L(r,e=(!a&&i||r).__k=x(C,null,[e]),o||h,h,r.namespaceURI,!a&&i?[i]:o?null:r.firstChild?t.call(r.childNodes):null,s,!a&&i?i:o?o.__e:r.firstChild,a,c),z(s,e,c),e.props.children=null}t=g.slice,n={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},r=0,w.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=y({},this.state);typeof e==`function`&&(e=e(y({},n),this.props)),e&&y(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),O(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),O(this))},w.prototype.render=C,i=[],o=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,s=function(e,t){return e.__v.__b-t.__v.__b},k.__r=0,c=Math.random().toString(8),l=`__d`+c,u=`__a`+c,d=/(PointerCapture)$|Capture$/i,f=0,p=I(!1),m=I(!0);var V,H,ae,oe,se=0,ce=[],U=n,le=U.__b,ue=U.__r,de=U.diffed,fe=U.__c,pe=U.unmount,me=U.__;function he(e,t){U.__h&&U.__h(H,e,se||t),se=0;var n=H.__H||(H.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function W(e){return se=1,ge(Te,e)}function ge(e,t,n){var r=he(V++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Te(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=H,!H.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};H.__f=!0;var a=H.shouldComponentUpdate,o=H.componentWillUpdate;H.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},H.shouldComponentUpdate=i}return r.__N||r.__}function G(e,t){var n=he(V++,3);!U.__s&&we(n.__H,t)&&(n.__=e,n.u=t,H.__H.__h.push(n))}function _e(e,t){var n=he(V++,4);!U.__s&&we(n.__H,t)&&(n.__=e,n.u=t,H.__h.push(n))}function K(e){return se=5,ve(function(){return{current:e}},[])}function ve(e,t){var n=he(V++,7);return we(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function q(e,t){return se=8,ve(function(){return e},t)}function ye(){for(var e;e=ce.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Se),t.__h.some(Ce),t.__h=[]}catch(n){t.__h=[],U.__e(n,e.__v)}}}U.__b=function(e){H=null,le&&le(e)},U.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),me&&me(e,t)},U.__r=function(e){ue&&ue(e),V=0;var t=(H=e.__c).__H;t&&(ae===H?(t.__h=[],H.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Se),t.__h.some(Ce),t.__h=[],V=0)),ae=H},U.diffed=function(e){de&&de(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ce.push(t)!==1&&oe===U.requestAnimationFrame||((oe=U.requestAnimationFrame)||xe)(ye)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),ae=H=null},U.__c=function(e,t){t.some(function(e){try{e.__h.some(Se),e.__h=e.__h.filter(function(e){return!e.__||Ce(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],U.__e(n,e.__v)}}),fe&&fe(e,t)},U.unmount=function(e){pe&&pe(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Se(e)}catch(e){t=e}}),n.__H=void 0,t&&U.__e(t,n.__v))};var be=typeof requestAnimationFrame==`function`;function xe(e){var t,n=function(){clearTimeout(r),be&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);be&&(t=requestAnimationFrame(n))}function Se(e){var t=H,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),H=t}function Ce(e){var t=H;e.__c=e.__(),H=t}function we(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Te(e,t){return typeof t==`function`?t(e):t}var Ee=new Set([`sessionId`]);function De(e){if(typeof e==`string`)return e.length>0?{id:e}:void 0;if(!e||typeof e!=`object`||Array.isArray(e))return;let{id:t,name:n}=e;if(typeof t==`string`&&t.length!==0)return typeof n==`string`&&n.length>0?{id:t,name:n}:{id:t}}function Oe(e){let t=De(e);if(t)return t.name??t.id}function ke(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Ae(e){let t={};for(let[n,r]of Object.entries(e)){if(Ee.has(n)||!ke(r)){t[n]=r;continue}let e=De(r);e&&(t[`${n}Id`]=e.id,e.name&&(t[`${n}Name`]=e.name))}return t}var je=`en`,Me=[`en`,`fr`,`es`],Ne={en:{heading:`Assistant`,subheading:`Squadico`,placeholder:`Ask your question…`,greeting:`Hello! I am your assistant. What would you like to do?`,hint:`The assistant proposes an action; nothing is applied without your confirmation.`,assistant:`Assistant`,typing:`The assistant is writing its answer`,newConversation:`New conversation`,close:`Close the assistant`,closeTitle:`Close`,history:{open:`Conversation history`,menu:`Previous conversations`,loading:`Loading…`,empty:`No previous conversation.`,untitled:`Conversation`},context:{region:`Context sent to the assistant`},approval:{group:`Write confirmation`,approve:`Yes, apply`,reject:`No, cancel`,request:`The agent wants to use {tool}.`,arguments:`With`,edit:`Change…`,correction:`What to change — e.g. “the due date is next Monday”`,correctionLabel:`Correction to make before approving`,send:`Send`},confirm:{group:`Confirmation`,yes:`Yes`,no:`No`,yesValue:`yes`,noValue:`no`},choices:`Suggested options`,poweredBy:`Powered by Squadico`,handles:{picker:`Agents you can address`,unknown:`Nobody answers to that name here:`,instead:`You can address:`,rail:`Agents`},selection:{group:`Suggested choice`,single:`Pick one option.`,multiple:`Pick one or more options, then validate.`,validate:`Validate`},composer:{label:`Your message`,send:`Send the message`,sendTitle:`Send`,stop:`Stop the answer`,stopTitle:`Stop`,attach:`Attach a file`,attachTitle:`Attach`,remove:`Remove {name}`},attachments:{unsupported:`This kind of file cannot be attached to a message.`,tooLarge:`This file is too large.`,tooMany:`This message already carries as many files as it may.`,unreadable:`This file could not be read.`,failed:`This file could not be attached.`},error:`Something went wrong, the assistant could not answer. Try again in a moment.`,withHuman:`A member of the team will reply to you here.`},fr:{heading:`Assistant`,subheading:`Squadico`,placeholder:`Posez votre question…`,greeting:`Bonjour ! Je suis votre assistant. Que souhaitez-vous faire ?`,hint:`L'assistant propose une action ; rien n'est appliqué sans votre confirmation.`,assistant:`Assistant`,typing:`L'assistant rédige sa réponse`,newConversation:`Nouvelle conversation`,close:`Fermer l'assistant`,closeTitle:`Fermer`,history:{open:`Historique des conversations`,menu:`Conversations précédentes`,loading:`Chargement…`,empty:`Aucune conversation précédente.`,untitled:`Conversation`},context:{region:`Contexte transmis à l'assistant`},approval:{group:`Validation de l'écriture`,approve:`Oui, appliquer`,reject:`Non, annuler`,request:`L'agent souhaite utiliser {tool}.`,arguments:`Avec`,edit:`Modifier…`,correction:`Ce qu'il faut changer — ex. « l'échéance est lundi prochain »`,correctionLabel:`Correction à apporter avant validation`,send:`Envoyer`},confirm:{group:`Confirmation`,yes:`Oui`,no:`Non`,yesValue:`oui`,noValue:`non`},choices:`Options proposées`,poweredBy:`Propulsé par Squadico`,handles:{picker:`Agents que vous pouvez adresser`,unknown:`Personne ne répond à ce nom ici :`,instead:`Vous pouvez adresser :`,rail:`Agents`},selection:{group:`Choix proposé`,single:`Sélectionnez une option.`,multiple:`Sélectionnez une ou plusieurs options, puis validez.`,validate:`Valider`},composer:{label:`Votre message`,send:`Envoyer le message`,sendTitle:`Envoyer`,stop:`Interrompre la réponse`,stopTitle:`Interrompre`,attach:`Joindre un fichier`,attachTitle:`Joindre`,remove:`Retirer {name}`},attachments:{unsupported:`Ce format de fichier ne peut pas être joint à un message.`,tooLarge:`Ce fichier est trop volumineux.`,tooMany:`Ce message porte déjà autant de fichiers qu'il le peut.`,unreadable:`Ce fichier n'a pas pu être lu.`,failed:`Impossible de joindre ce fichier.`},error:`Une erreur est survenue, l'assistant n'a pas pu répondre. Réessayez dans un instant.`,withHuman:`Un membre de l'équipe va vous répondre ici.`},es:{heading:`Asistente`,subheading:`Squadico`,placeholder:`Haga su pregunta…`,greeting:`¡Hola! Soy su asistente. ¿Qué desea hacer?`,hint:`El asistente propone una acción; no se aplica nada sin su confirmación.`,assistant:`Asistente`,typing:`El asistente está redactando su respuesta`,newConversation:`Nueva conversación`,close:`Cerrar el asistente`,closeTitle:`Cerrar`,history:{open:`Historial de conversaciones`,menu:`Conversaciones anteriores`,loading:`Cargando…`,empty:`Ninguna conversación anterior.`,untitled:`Conversación`},context:{region:`Contexto enviado al asistente`},approval:{group:`Validación de la escritura`,approve:`Sí, aplicar`,reject:`No, cancelar`,request:`El agente quiere usar {tool}.`,arguments:`Con`,edit:`Modificar…`,correction:`Lo que hay que cambiar — p. ej. «el vencimiento es el lunes»`,correctionLabel:`Corrección antes de validar`,send:`Enviar`},confirm:{group:`Confirmación`,yes:`Sí`,no:`No`,yesValue:`sí`,noValue:`no`},choices:`Opciones propuestas`,poweredBy:`Con la tecnología de Squadico`,handles:{picker:`Agentes a los que puedes dirigirte`,unknown:`Nadie responde a ese nombre aquí:`,instead:`Puedes dirigirte a:`,rail:`Agentes`},selection:{group:`Opción propuesta`,single:`Seleccione una opción.`,multiple:`Seleccione una o varias opciones y valide.`,validate:`Validar`},composer:{label:`Su mensaje`,send:`Enviar el mensaje`,sendTitle:`Enviar`,stop:`Interrumpir la respuesta`,stopTitle:`Interrumpir`,attach:`Adjuntar un archivo`,attachTitle:`Adjuntar`,remove:`Quitar {name}`},attachments:{unsupported:`Este tipo de archivo no se puede adjuntar a un mensaje.`,tooLarge:`Este archivo es demasiado grande.`,tooMany:`Este mensaje ya lleva todos los archivos que puede llevar.`,unreadable:`No se ha podido leer este archivo.`,failed:`No se ha podido adjuntar este archivo.`},error:`Se ha producido un error, el asistente no ha podido responder. Inténtelo de nuevo.`,withHuman:`Un miembro del equipo le responderá aquí.`}},Pe={en:`en-GB`,fr:`fr-FR`,es:`es-ES`};function Fe(e){let t=e?.trim().toLowerCase().split(/[-_]/)[0];return t&&t in Ne?t:void 0}function Ie(){return typeof navigator>`u`?[]:navigator.languages?.length?navigator.languages:[navigator.language]}function Le(e){let t=e?.trim(),n=(t?[t]:Ie()).find(Fe),r=Fe(n)??`en`;return{code:r,tag:n?.includes(`-`)?n:Pe[r],t:Ne[r]}}var Re=`squadico-chatbot:open`;function ze(){try{if(typeof sessionStorage>`u`)return;let e=sessionStorage.getItem(Re);return e===`1`||e!==`0`&&void 0}catch{return}}function Be(e){try{if(typeof sessionStorage>`u`)return;sessionStorage.setItem(Re,e?`1`:`0`)}catch{}}function Ve(e,t){return t===!1?e??!1:ze()??e??!1}function He(e,t){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role===`assistant`&&n.agent)return n.agent.handle}return t}function Ue(e,t,n){return!t||t===n||e.trimStart().startsWith(`@`)?e:`@${t} ${e}`}function We(){let e=globalThis.crypto;if(e&&typeof e.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);if(e&&typeof e.getRandomValues==`function`)e.getRandomValues(t);else for(let e=0;e<16;e++)t[e]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=[];for(let e=0;e<16;e++)n.push(t[e].toString(16).padStart(2,`0`));return n.slice(0,4).join(``)+`-`+n.slice(4,6).join(``)+`-`+n.slice(6,8).join(``)+`-`+n.slice(8,10).join(``)+`-`+n.slice(10,16).join(``)}function Ge(e){"@babel/helpers - typeof";return Ge=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Ge(e)}function Ke(e,t){if(Ge(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Ge(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function qe(e){var t=Ke(e,`string`);return Ge(t)==`symbol`?t:t+``}function Je(e,t,n){return(t=qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ye=`https://api.squadico.com`,Xe=2e4,J=class extends Error{constructor(e,t,n){super(e),Je(this,`status`,void 0),Je(this,`code`,void 0),this.name=`ChatHttpError`,this.status=t,this.code=n}};function Ze(e,t){return`${e.replace(/\/+$/,``)}${t}`}function Qe(e,t){return{"Content-Type":`application/json`,Accept:`text/event-stream, application/json`,...e?{"X-Visitor-Token":e}:{},...t?{"X-Subject-Token":t}:{}}}function $e(e){if(!e||typeof e!=`object`)return;let{loc:t,msg:n}=e;if(typeof n!=`string`||!n)return;let r=(Array.isArray(t)?t.filter(e=>typeof e==`string`):[]).at(-1);return r&&r!==`body`?`${r}: ${n}`:n}async function et(e){let t=``,n;try{let r=await e.text();if(r)try{let e=JSON.parse(r),i=e.detail??e.message;if(Array.isArray(i)){let e=i.map(e=>$e(e)??(typeof e==`string`?e:void 0)).filter(e=>e!==void 0);t=e.length>0?e.join(`, `):r}else t=typeof i==`string`?i:r;n=typeof e.code==`string`?e.code:void 0}catch{t=r}}catch{}return new J(t||`The API answered ${e.status}`,e.status,n)}function tt(e,t){if(!e||typeof e!=`object`)return;let n=e;if(!(typeof n.handle!=`string`||!n.handle))return{handle:n.handle,name:typeof n.name==`string`?n.name:n.handle,avatarUrl:typeof n.avatar_url==`string`&&n.avatar_url?Ze(t,n.avatar_url):void 0,color:typeof n.color==`string`?n.color:void 0}}function nt(e,t){return(Array.isArray(e)?e:[]).map(e=>tt(e,t)).filter(e=>e!==void 0)}function rt(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.tool_call_id!=`string`||!t.tool_call_id))return{toolCallId:t.tool_call_id,tool:typeof t.tool==`string`?t.tool:``,arguments:t.arguments&&typeof t.arguments==`object`?t.arguments:{}}}var it=new Set([`user`,`assistant`]);function at(e,t){if(typeof e.role!=`string`||!it.has(e.role)||typeof e.content!=`string`||!e.content)return null;let n=typeof e.created_at==`string`?Date.parse(e.created_at):NaN;return{id:typeof e.id==`string`&&e.id?e.id:We(),role:e.role,content:e.content,createdAt:Number.isNaN(n)?Date.now():n,agent:tt(e.agent,t),attachments:ot(e.attachments),authorName:e.kind===`human`&&typeof e.author_name==`string`&&e.author_name?e.author_name:void 0}}function ot(e){if(!Array.isArray(e))return;let t=e.map(e=>st(e)).filter(e=>e!==null);return t.length>0?t:void 0}function st(e){if(!e||typeof e!=`object`)return null;let{id:t,kind:n,filename:r,content_type:i}=e;return typeof t!=`string`||!t||typeof r!=`string`||!r?null:{id:t,kind:n===`image`?`image`:`document`,filename:r,contentType:typeof i==`string`?i:`application/octet-stream`}}async function ct(e){let t=e.agent?`?agent=${encodeURIComponent(e.agent)}`:``,n=await fetch(Ze(e.apiUrl,`/public/applications/${encodeURIComponent(e.embedKey)}${t}`),{method:`GET`,headers:Qe(),signal:e.signal});if(!n.ok)throw await et(n);let r=await n.json();return{welcomeMessage:typeof r.welcome_message==`string`&&r.welcome_message?r.welcome_message:void 0,agent:tt(r.agent,e.apiUrl),handles:nt(r.handles,e.apiUrl),agentHandle:typeof r.agent_handle==`string`&&r.agent_handle?r.agent_handle:void 0,branding:r.branding===!0}}async function lt(e){let t=await fetch(Ze(e.apiUrl,`/public/applications/${encodeURIComponent(e.embedKey)}/conversations`),{method:`POST`,headers:Qe(),body:JSON.stringify({...e.user?{user:e.user}:{},...e.agent?{agent:e.agent}:{}}),signal:e.signal});if(!t.ok)throw await et(t);let n=await t.json();if(typeof n.id!=`string`||typeof n.visitor_token!=`string`)throw new J(`The API opened a conversation without an id or a token`);let r=(Array.isArray(n.messages)?n.messages:[]).map(t=>at(t,e.apiUrl)).filter(e=>e!==null);return{conversationId:n.id,visitorToken:n.visitor_token,agentName:typeof n.agent_name==`string`?n.agent_name:``,agentSlug:typeof n.agent_slug==`string`?n.agent_slug:``,welcomeMessage:typeof n.welcome_message==`string`&&n.welcome_message?n.welcome_message:void 0,messages:r,handles:nt(n.handles,e.apiUrl),agentHandle:typeof n.agent_handle==`string`&&n.agent_handle?n.agent_handle:void 0,withHuman:typeof n.handling==`string`&&n.handling!==`agents`,branding:n.branding===!0}}async function ut(e){let t=await fetch(Ze(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}`),{method:`GET`,headers:Qe(e.visitorToken),signal:e.signal});if(!t.ok)throw await et(t);let n=await t.json();if(typeof n.id!=`string`)throw new J(`The API replayed a conversation without an id`);return{conversationId:n.id,visitorToken:e.visitorToken,agentName:typeof n.agent_name==`string`?n.agent_name:``,agentSlug:typeof n.agent_slug==`string`?n.agent_slug:``,welcomeMessage:typeof n.welcome_message==`string`&&n.welcome_message?n.welcome_message:void 0,messages:(Array.isArray(n.messages)?n.messages:[]).map(t=>at(t,e.apiUrl)).filter(e=>e!==null),handles:nt(n.handles,e.apiUrl),agentHandle:typeof n.agent_handle==`string`&&n.agent_handle?n.agent_handle:void 0,withHuman:typeof n.handling==`string`&&n.handling!==`agents`,branding:n.branding===!0}}async function dt(e){let t=new FormData;t.append(`file`,e.file);let n=await fetch(mt(e),{method:`POST`,headers:{"X-Visitor-Token":e.visitorToken},body:t,signal:e.signal});if(!n.ok)throw await et(n);let r=st(await n.json());if(!r)throw new J(`The upload could not be read`,n.status);return r}async function ft(e){let t=await fetch(`${mt(e)}/${encodeURIComponent(e.attachmentId)}`,{method:`DELETE`,headers:{"X-Visitor-Token":e.visitorToken},signal:e.signal});if(!t.ok)throw await et(t)}async function pt(e){let t=await fetch(`${mt(e)}/${encodeURIComponent(e.attachmentId)}/content`,{headers:{"X-Visitor-Token":e.visitorToken},signal:e.signal});if(!t.ok)throw await et(t);return t.blob()}function mt(e){return Ze(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/attachments`)}async function ht(e){return _t(Ze(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/messages`),{content:e.message,attachment_ids:e.attachmentIds??[],...e.context&&Object.keys(e.context).length>0?{context:e.context}:{}},e)}async function gt(e){return _t(Ze(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/approvals`),{tool_call_id:e.toolCallId,approved:e.approved},e)}async function _t(e,t,n){let r=await fetch(e,{method:`POST`,headers:Qe(n.visitorToken,n.subjectToken),body:JSON.stringify(t),signal:n.signal});if(!r.ok)throw await et(r);if(!r.body)throw new J(`Answer with no stream body`);let i=r.body.getReader(),a=new TextDecoder,o=``,s=``,c=``,l,u,d={answer:``};try{for(;;){let{value:e,done:t}=await i.read();if(t)break;o+=a.decode(e,{stream:!0});let r=o.split(`
2
- `);o=r.pop()??``;for(let e of r){let t=e.trim();if(!t){s=``;continue}if(t.startsWith(`event:`)){s=t.slice(6).trim();continue}if(!t.startsWith(`data:`))continue;let r=t.slice(5).trim();if(!r)continue;let i;try{i=JSON.parse(r)}catch{continue}s===`token`&&typeof i.text==`string`?(c+=i.text,n.onToken(i.text)):s===`done`?(d.answer=typeof i.content==`string`?i.content:c,d.agent=tt(i.agent,n.apiUrl),typeof i.unknown_handle==`string`&&i.unknown_handle&&(d.unknownHandle=i.unknown_handle,d.offered=nt(i.handles,n.apiUrl))):s===`handoff`?(typeof i.to_agent_name==`string`&&(u=i.to_agent_name),c=``):s===`escalated`?d.withHuman=!0:s===`held`?(d.held=!0,d.withHuman=!0):s===`approval_required`?d.approval=rt(i):s===`error`&&(l=typeof i.detail==`string`?i.detail:`The turn failed`)}if(l)break}}finally{i.cancel().catch(()=>void 0)}if(l)throw new J(l);return!d.answer&&!d.approval&&(d.answer=c),u&&!d.agent&&(d.authorName=u),d}var vt=`squadico-chatbot:conversation`;function yt(){try{if(typeof sessionStorage>`u`)return;let e=sessionStorage.getItem(vt);if(!e)return;let t=JSON.parse(e);return!t.sessionId||!t.visitorToken||!t.embedKey?void 0:{sessionId:t.sessionId,visitorToken:t.visitorToken,embedKey:t.embedKey,user:typeof t.user==`string`?t.user:void 0}}catch{return}}function bt(e){try{if(typeof sessionStorage>`u`)return;sessionStorage.setItem(vt,JSON.stringify(e))}catch{}}function xt(){try{if(typeof sessionStorage>`u`)return;sessionStorage.removeItem(vt)}catch{}}function St(e,{embedKey:t,user:n}){return e.embedKey===t&&e.user===n}async function Ct(e){if(e)try{return await e()||void 0}catch{return}}var wt=`preview-welcome`;function Tt(e){let t=e instanceof J?e.status:void 0;return t===415?`unsupported`:t===413?`tooLarge`:t===409?`tooMany`:t===422?`unreadable`:`failed`}var Et=5e3;function Dt(e){return e instanceof J&&e.code===`conversation_retired`}function Ot(e){let[t,n]=W([]),[r,i]=W(!1),[a,o]=W(``),[s,c]=W([]),[l,u]=W(``),[d,f]=W(``),[p,m]=W(null),[h,g]=W(!1),[_,v]=W(!1),[y,b]=W([]),[x,S]=W([]),[C,w]=W(null),T=K(null),E=K(e);E.current=e;let D=K(null),O=K(null),k=K(null),A=K(null),j=K(void 0),M=e.greeting,N=ve(()=>M?{id:`greeting`,role:`assistant`,content:M,createdAt:Date.now()}:null,[M]),P=q(e=>{E.current.onEvent?.(e)},[]),F=q((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,...t}:n))},[]),I=q((e,t)=>{let n=e instanceof J?e.status:void 0,r=e instanceof Error?e.message:String(e),i=(E.current.locale??Le(void 0)).t.error;t&&F(t,{content:i,streaming:!1,error:!0}),P({type:`chatbot-error`,message:r,status:n,sessionId:O.current?.sessionId??``}),typeof console<`u`&&console.error(`[squadico-chatbot]`,r)},[P,F]),L=q(()=>{let e=E.current;if(!e.embedKey)throw new J(`No embed key: nothing says which application to open`);return{opts:e,apiUrl:e.apiUrl??`https://api.squadico.com`,embedKey:e.embedKey,claim:e.user}},[]),R=q((e,t)=>{let r={sessionId:t.conversationId,visitorToken:t.visitorToken};return O.current=r,j.current=e.claim?.id,bt({...r,embedKey:e.embedKey,user:e.claim?.id}),o(t.conversationId),c(t.handles),u(e.opts.agent&&t.agentHandle?t.agentHandle:``),f(t.agentHandle??``),g(!!t.withHuman),v(t.branding),n(e=>[...t.messages,...e.filter(e=>e.id!==wt)]),r},[]),z=q(e=>{if(k.current)return k.current;let t=yt();if(!t||!St(t,{embedKey:e.embedKey,user:e.claim?.id}))return Promise.resolve(null);let n=ut({apiUrl:e.apiUrl,conversationId:t.sessionId,visitorToken:t.visitorToken}).then(t=>R(e,t)).catch(()=>(xt(),null)).finally(()=>{k.current=null});return k.current=n,n},[R]),B=q(async()=>{if(O.current)return O.current;if(D.current)return D.current;let e=L(),t=z(e).then(t=>t??lt({apiUrl:e.apiUrl,embedKey:e.embedKey,user:e.claim,agent:e.opts.agent}).then(t=>R(e,t)));D.current=t;try{return await t}finally{D.current=null}},[R,z,L]),ee=q(()=>{if(O.current||D.current||A.current)return;let e;try{e=L()}catch(e){I(e);return}let t=z(e).then(async t=>{if(t||O.current||D.current)return;let r=await ct({apiUrl:e.apiUrl,embedKey:e.embedKey,agent:e.opts.agent});if(O.current||D.current)return;c(r.handles),u(e.opts.agent&&r.agentHandle?r.agentHandle:``),f(r.agentHandle??``),v(r.branding);let i=r.welcomeMessage;i&&n(e=>e.length>0?e:[{id:wt,role:`assistant`,content:i,createdAt:Date.now(),agent:r.agent}])});A.current=t,t.catch(e=>{A.current=null,I(e)})},[I,z,L]),te=q((e,t,{retry:r=!1,carried:a=[]}={})=>{if(T.current)return;let o=new AbortController;T.current=o,i(!0),m(null);let s=We();n(t=>[...t,{id:We(),role:`user`,content:e,createdAt:Date.now(),attachments:a.length>0?a:void 0},{id:s,role:`assistant`,content:``,createdAt:Date.now(),streaming:!0}]),(async()=>{let i=await B();P({type:`chatbot-message`,role:`user`,content:e,sessionId:i.sessionId});let a=``,c=e=>{a+=e,F(s,{content:a})},l;try{l=await t(i,c,o.signal)}catch(e){if(!Dt(e)||(xt(),O.current=null,D.current=null,!r))throw e;i=await B(),a=``,F(s,{content:``}),l=await t(i,c,o.signal)}if(l.withHuman&&g(!0),l.held){n(e=>e.filter(e=>e.id!==s));return}F(s,{content:l.answer,streaming:!1,agent:l.agent,authorName:l.authorName,approval:l.approval,unknownHandle:l.unknownHandle,offered:l.offered}),m(l.approval??null),P({type:`chatbot-message`,role:`assistant`,content:l.answer,sessionId:i.sessionId,agent:l.agent?.handle})})().catch(e=>{if(o.signal.aborted){F(s,{streaming:!1});return}I(e,s)}).finally(()=>{T.current=null,i(!1)})},[B,P,I,F]),ne=q(e=>{let t=e.trim();if(!t&&y.length===0)return;let n=y;b([]),w(null),te(t,async(e,r,i)=>ht({subjectToken:await Ct(E.current.getSubjectToken),apiUrl:E.current.apiUrl??`https://api.squadico.com`,conversationId:e.sessionId,visitorToken:e.visitorToken,message:t,attachmentIds:n.map(e=>e.id),context:E.current.context?Ae(E.current.context):void 0,onToken:r,signal:i}),{retry:!0,carried:n})},[y,te]),re=q(e=>{w(null),S(t=>[...t,e.name]),B().then(t=>dt({apiUrl:E.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,file:e})).then(e=>b(t=>[...t,e])).catch(e=>w(Tt(e))).finally(()=>S(t=>{let n=t.indexOf(e.name);return n<0?t:[...t.slice(0,n),...t.slice(n+1)]}))},[B]),ie=q(e=>{b(t=>t.filter(t=>t.id!==e));let t=O.current;t&&ft({apiUrl:E.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,attachmentId:e}).catch(()=>{})},[]),V=q(async e=>{let t=O.current;if(!t)throw new J(`No conversation to read that file from`);return pt({apiUrl:E.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,attachmentId:e})},[]),H=q((e,t)=>{let n=p;n&&te(t,async(t,r,i)=>gt({subjectToken:await Ct(E.current.getSubjectToken),apiUrl:E.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,toolCallId:n.toolCallId,approved:e,onToken:r,signal:i}))},[p,te]),ae=q(()=>{T.current?.abort(),T.current=null,i(!1)},[]),oe=q(()=>{T.current?.abort(),T.current=null,O.current=null,D.current=null,k.current=null,A.current=null,j.current=void 0,xt(),i(!1),m(null),g(!1),o(``),u(``),f(``),n([]),P({type:`chatbot-reset`,sessionId:``})},[P]),se=e.humanPollMs??Et;G(()=>{if(!h||!a)return;let e=setInterval(()=>{let e=O.current;!e||T.current||ut({apiUrl:E.current.apiUrl??`https://api.squadico.com`,conversationId:e.sessionId,visitorToken:e.visitorToken}).then(e=>{n(e.messages),g(!!e.withHuman)}).catch(()=>{})},se);return()=>clearInterval(e)},[h,a,se]);let ce=e.user?.id;return G(()=>{O.current&&j.current!==ce&&oe()},[ce,oe]),{messages:ve(()=>t.length===0&&N?[N]:t,[N,t]),busy:r,sessionId:a,handles:s,addressee:l,agentHandle:d,approval:p,withHuman:h,branding:_,start:ee,send:ne,attachments:y,uploading:x,attachmentError:C,attach:re,detach:ie,loadAttachment:V,decide:H,stop:ae,reset:oe}}var kt=0;Array.isArray;function Y(e,t,r,i,a,o){t||(t={});var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--kt,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return n.vnode&&n.vnode(u),u}function At({name:e,color:t,url:n,size:r=16}){let[i,a]=W(void 0),o=!!n&&i!==n;return Y(`span`,{class:`sqc-avatar`,"aria-hidden":`true`,style:{width:`${r}px`,height:`${r}px`,fontSize:`${Math.round(r*.45)}px`,borderRadius:`${Math.round(r*.25)}px`,...o||!t?{}:{backgroundColor:t}},children:o?Y(`img`,{src:n,alt:``,onError:()=>a(n)}):jt(e)})}function jt(e){let t=Array.from(e.trim())[0];return t?t.toLocaleUpperCase():`?`}function Mt({handles:e,active:t,disabled:n,onPick:r,label:i}){return Y(`nav`,{class:`sqc-rail`,"aria-label":i,children:e.map(e=>Y(`button`,{type:`button`,class:`sqc-rail__item`,"aria-label":e.name,"aria-pressed":e.handle===t,"data-tip":e.name,disabled:n,onClick:()=>r(e.handle),children:[Y(At,{name:e.name,color:e.color,url:e.avatarUrl,size:40}),Y(`span`,{class:`sqc-rail__label`,"aria-hidden":`true`,children:Nt(e.handle)})]},e.handle))})}function Nt(e){let t=e.split(/[-_]/)[0]??e;return t.charAt(0).toUpperCase()+t.slice(1)}var Pt=132,Ft=`image/png,image/jpeg,image/gif,image/webp,application/pdf,.docx,.txt,.md,.csv,.json`,It=/^[a-zA-Z0-9_-]*$/;function Lt(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`@`);if(r<0||r>0&&!/\s/.test(n[r-1]??``))return null;let i=n.slice(r+1);return It.test(i)?{start:r,query:i}:null}function Rt({placeholder:e,locale:t,busy:n,autoFocus:r,handles:i,addressee:a,attachments:o=[],uploading:s=[],attachmentError:c,onAttach:l,onDetach:u,onSend:d,onStop:f}){let[p,m]=W(``),[h,g]=W(null),[_,v]=W(0),[y,b]=W(!1),x=K(null),S=K(null),w=!!l,T=s.length>0,E=ve(()=>{if(!h||!i||i.length===0)return[];let e=h.query.toLowerCase();return i.filter(t=>t.handle.startsWith(e))},[i,h]),D=E.length>0,O=q(()=>{let e=x.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight>Pt;e.style.height=`${Math.min(e.scrollHeight,Pt)}px`,e.style.overflowY=t?`auto`:`hidden`},[]);G(()=>{r&&x.current?.focus(),O()},[r,O]),G(()=>{a&&(m(e=>e||`@${a} `),requestAnimationFrame(O))},[a,O]);let k=q(e=>{g(Lt(e.value,e.selectionStart??e.value.length)),v(0)},[]),A=q(e=>{let t=x.current;if(!t||!h)return;let n=t.selectionStart??t.value.length,r=`${p.slice(0,h.start)}@${e} ${p.slice(n)}`,i=h.start+e.length+2;m(r),g(null),requestAnimationFrame(()=>{t.focus(),t.setSelectionRange(i,i),O()})},[O,h,p]),j=q(e=>{if(!(!l||!e))for(let t of Array.from(e))l(t)},[l]),M=q(()=>{let e=p.trim();!e&&o.length===0||n||T||(d(e),m(``),g(null),requestAnimationFrame(O))},[o.length,n,O,d,p,T]),N=q(e=>{if(D&&!e.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:E.length-1;v(e=>(e+t)%E.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),A((E[_]??E[0]).handle);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),g(null);return}}e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),M())},[_,E,A,D,M]),P=Xe-p.length;return Y(`form`,{class:`sqc-composer${y?` sqc-composer--dropping`:``}`,onSubmit:e=>{e.preventDefault(),M()},onDragOver:e=>{w&&(e.preventDefault(),b(!0))},onDragLeave:()=>b(!1),onDrop:e=>{w&&(e.preventDefault(),b(!1),j(e.dataTransfer?.files??null))},children:[(o.length>0||T||c)&&Y(`div`,{class:`sqc-attachments`,children:[o.map(e=>Y(`span`,{class:`sqc-chip`,"data-kind":e.kind,children:[Y(`span`,{class:`sqc-chip__name`,children:e.filename}),Y(`button`,{type:`button`,class:`sqc-chip__remove`,"aria-label":t.t.composer.remove.replace(`{name}`,e.filename),onClick:()=>u?.(e.id),children:`×`})]},e.id)),s.map(e=>Y(`span`,{class:`sqc-chip sqc-chip--waiting`,children:Y(`span`,{class:`sqc-chip__name`,children:e})},e)),c&&Y(`p`,{class:`sqc-attachments__error`,role:`status`,children:c})]}),Y(`div`,{class:`sqc-composer__field`,children:[D&&Y(`ul`,{class:`sqc-mentions`,role:`listbox`,"aria-label":t.t.handles.picker,children:E.map((e,t)=>Y(`li`,{role:`option`,"aria-selected":t===_,class:`sqc-mention${t===_?` sqc-mention--active`:``}`,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>v(t),onClick:()=>A(e.handle),children:[Y(`span`,{class:`sqc-mention__icon`,children:Y(At,{name:e.name,color:e.color,url:e.avatarUrl,size:18})}),Y(`span`,{class:`sqc-mention__handle`,children:[`@`,e.handle]}),Y(`span`,{class:`sqc-mention__name`,children:e.name})]},e.handle))}),Y(`textarea`,{ref:x,class:`sqc-composer__input`,rows:1,value:p,placeholder:e,maxLength:Xe,"aria-label":t.t.composer.label,onInput:e=>{m(e.currentTarget.value),k(e.currentTarget),O()},onKeyDown:N,onClick:e=>k(e.currentTarget),onPaste:e=>{let t=e.clipboardData?.files;!w||!t||t.length===0||(e.preventDefault(),j(t))}}),P<=200&&Y(`span`,{class:`sqc-composer__count`,"aria-live":`polite`,children:P})]}),w&&Y(C,{children:[Y(`input`,{ref:S,type:`file`,multiple:!0,accept:Ft,class:`sqc-file-input`,onChange:e=>{j(e.currentTarget.files),e.currentTarget.value=``}}),Y(`button`,{type:`button`,class:`sqc-btn sqc-btn--attach`,onClick:()=>S.current?.click(),"aria-label":t.t.composer.attach,title:t.t.composer.attachTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.9`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:Y(`path`,{d:`M21 11.5l-8.8 8.8a5 5 0 01-7.1-7.1l9-9a3.3 3.3 0 014.7 4.7l-9 9a1.6 1.6 0 01-2.3-2.3l8.3-8.3`})})})]}),n?Y(`button`,{type:`button`,class:`sqc-btn sqc-btn--stop`,onClick:f,"aria-label":t.t.composer.stop,title:t.t.composer.stopTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:Y(`rect`,{x:`7`,y:`7`,width:`10`,height:`10`,rx:`2`,fill:`currentColor`})})}):Y(`button`,{type:`submit`,class:`sqc-btn sqc-btn--send`,disabled:!p.trim()&&o.length===0||T,"aria-label":t.t.composer.send,title:t.t.composer.sendTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.9`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:Y(`path`,{d:`M5 12l14-7-5 14-2.5-5.5L5 12z`})})})]})}var zt={fr:/\br[ée]ponde?z? +«?\s*oui\b/i,en:/\b(?:reply|answer|respond) +[“"']?\s*yes\b/i,es:/\bresponda?e?d? +«?\s*s[íi]\b/i},Bt={fr:[/\b(?:confirmes?[- ]tu|confirmez[- ]vous)\b/i,/\b(?:valides?[- ]tu|validez[- ]vous)\b/i,/\b(?:es[- ]tu s[ûu]re?|[êe]tes[- ]vous s[ûu]re?s?)\b/i,/\b(?:dois[- ]je|puis[- ]je)\b/i,/\b(?:je continue|on continue|on y va|je lance)\b/i,zt.fr],en:[/\bdo you confirm\b/i,/\bdo you (?:want|wish) me to\b/i,/\b(?:shall|should) I\b/i,/\bare you sure\b/i,/\b(?:shall we|should I) (?:proceed|continue|go ahead)\b/i,zt.en],es:[/\b(?:confirmas|confirma|confirm[áa]is)\b/i,/\b(?:validas|valida|valid[áa]is)\b/i,/\best[áa]s? seguro\b/i,/\b(?:contin[úu]o|procedo|lo lanzo|lo hago)\b/i,/\bquieres? que\b/i,zt.es]},Vt=/^\s*(?:[-*•]\s+)?\[[ xX]\]\s+/m;function Ht(e,t=`en`){if(Vt.test(e))return!1;let n=e.split(`
3
- `).map(e=>e.trim()).filter(Boolean),r=n[n.length-1];return!r||!r.includes(`?`)&&!zt[t].test(r)?!1:Bt[t].some(e=>e.test(r))}var Ut=/^(?:mcp|custom|a2a)_[0-9a-f]{8}_/;function Wt(e){let t=e.replace(Ut,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):e}function Gt(e,t){return e===!0?t.t.confirm.yes:e===!1?t.t.confirm.no:typeof e==`string`?e:JSON.stringify(e)??String(e)}function Kt({locale:e,call:t,onDecide:n}){let{approval:r,confirm:i}=e.t,[a,o]=W(null),s=!!n&&a===null,c=(e,t)=>{o(t),n?.(e,t)},l=t?Object.entries(t.arguments):[];return Y(`div`,{class:`sqc-approval`,role:`group`,"aria-label":r.group,children:[t&&Y(`p`,{class:`sqc-approval__request`,"data-testid":`sqc-approval-tool`,children:r.request.replace(`{tool}`,Wt(t.tool))}),l.length>0&&Y(`dl`,{class:`sqc-approval__args`,"data-testid":`sqc-approval-arguments`,children:l.map(([t,n])=>Y(`div`,{class:`sqc-approval__arg`,children:[Y(`dt`,{class:`sqc-approval__arg-name`,children:Wt(t)}),Y(`dd`,{class:`sqc-approval__arg-value`,children:Gt(n,e)})]},t))}),Y(`div`,{class:`sqc-approval__actions`,children:[Y(`button`,{type:`button`,class:`sqc-approval__btn sqc-approval__btn--yes`,"aria-pressed":a===i.yes,disabled:!s,onClick:()=>c(!0,i.yes),children:r.approve}),Y(`button`,{type:`button`,class:`sqc-approval__btn sqc-approval__btn--no`,"aria-pressed":a===i.no,disabled:!s,onClick:()=>c(!1,i.no),children:r.reject})]})]})}function qt({locale:e,onPick:t}){let[n,r]=W(null),i=!!t&&n===null,{confirm:a}=e.t,o=[{value:a.yesValue,label:a.yes,kind:`yes`},{value:a.noValue,label:a.no,kind:`no`}];return Y(`div`,{class:`sqc-confirm`,role:`group`,"aria-label":a.group,children:o.map(e=>Y(`button`,{type:`button`,class:`sqc-confirm__btn sqc-confirm__btn--${e.kind}`,"aria-pressed":n===e.value,disabled:!i,onClick:()=>{r(e.value),t?.(e.value)},children:e.label},e.value))})}function Jt(){return Y(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.2`,"aria-hidden":`true`,children:Y(`path`,{d:`M3.5 8.5l3 3 6-7`,"stroke-linecap":`round`,"stroke-linejoin":`round`})})}function Yt({items:e,locale:t,onPick:n}){let[r,i]=W(null),a=!!n&&r===null;return Y(`div`,{class:`sqc-choices`,role:`group`,"aria-label":t.t.choices,children:e.map((e,t)=>{let o=r===null?e.checked:r===e.label;return Y(`button`,{type:`button`,class:`sqc-choice`,"aria-pressed":o,disabled:!a,onClick:()=>{i(e.label),n?.(e.label)},children:[Y(`span`,{class:`sqc-choice__box${o?` sqc-choice__box--on`:``}`,"aria-hidden":`true`,children:o&&Y(Jt,{})}),Y(`span`,{class:`sqc-choice__label`,children:e.content})]},`${t}-${e.label}`)})})}var Xt=/(\*\*[^*\n]+\*\*|`[^`\n]+`|~~[^~\n]+~~|\[[^\]\n]+\]\([^)\s]+\)|\*[^*\n]+\*|https?:\/\/[^\s<>()]+)/g,Zt=/^\[([^\]\n]+)\]\(([^)\s]+)\)$/,Qt=/^(https?:|mailto:)/i;function $t(e,t,n){return Qt.test(e)?Y(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t},n):t}function en(e,t){let n=e.split(Xt),r=[];return n.forEach((e,n)=>{if(!e)return;let i=`${t}-${n}`,a=Zt.exec(e);e.startsWith(`**`)&&e.endsWith(`**`)&&e.length>4?r.push(Y(`strong`,{children:e.slice(2,-2)},i)):e.startsWith("`")&&e.endsWith("`")&&e.length>2?r.push(Y(`code`,{children:e.slice(1,-1)},i)):e.startsWith(`~~`)&&e.endsWith(`~~`)&&e.length>4?r.push(Y(`del`,{children:e.slice(2,-2)},i)):a?r.push($t(a[2],a[1],i)):e.startsWith(`*`)&&e.endsWith(`*`)&&e.length>2?r.push(Y(`em`,{children:e.slice(1,-1)},i)):/^https?:\/\//.test(e)?r.push($t(e,e,i)):r.push(e)}),r}var tn=/^\s*(?:[-*•]\s+)?\[([ xX])\]\s+(.+)$/;function nn(e){return e.replace(/\[([^\]\n]+)\]\([^)\s]+\)/g,`$1`).replace(/\*\*|~~|`|\*/g,``).trim()}var rn=/^(\s*)[-*•]\s+/,an=/^(\s*)\d+[.)]\s+/,on=/^\s{0,3}(#{1,6})\s+(.+?)#*\s*$/,sn=/^\s*([-*_])(?:\s*\1){2,}\s*$/,cn=/^\s*>\s?(.*)$/,ln=/^\s*\|.*\|\s*$/,un=/^\s*\|(?:\s*:?-{1,}:?\s*\|)+\s*$/,dn=/^\s*```/;function fn(e){return e.replace(/^\s*\|/,``).replace(/\|\s*$/,``).split(`|`).map(e=>e.trim())}function pn(e,t,n,r){let i=e[t].ordered,a=[],o=t;for(;o<e.length&&e[o].depth>=n;){let t=e[o];if(t.depth===n&&t.ordered!==i)break;if(t.depth>n){let[n,i]=pn(e,o,t.depth,`${r}-${o}`),s=a[a.length-1];s?s.nested.push(n):a.push({key:`${r}-${o}`,text:null,nested:[n]}),o=i;continue}a.push({key:`${r}-${o}`,text:t.text,nested:[]}),o+=1}let s=a.map(e=>Y(`li`,{children:[e.text===null?null:en(e.text,e.key),e.nested]},e.key));return[Y(i?`ol`:`ul`,{children:s},r),o]}function mn({text:e,locale:t,onChoice:n}){let r=e.split(`
4
- `),i=[],a=[],o=[],s=[],c=()=>{if(!a.length)return;let e=`p${i.length}`;i.push(Y(`p`,{children:en(a.join(`
5
- `),e)},e)),a=[]},l=()=>{if(!o.length)return;let e=0;for(;e<o.length;){let t=`l${i.length}`,[n,r]=pn(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:en(s.join(`
6
- `),e)},e)),s=[]},d=()=>{c(),l(),u()};for(let e=0;e<r.length;e+=1){let f=r[e];if(dn.test(f)){d();let t=[];for(e+=1;e<r.length&&!dn.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(ln.test(f)&&e+1<r.length&&un.test(r[e+1])){d();let t=fn(f),n=[];for(e+=2;e<r.length&&ln.test(r[e]);)n.push(fn(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:en(e,`${a}-h${t}`)},`${a}-h${t}`))})}),Y(`tbody`,{children:n.map((e,n)=>Y(`tr`,{children:t.map((t,r)=>Y(`td`,{children:en(e[r]??``,`${a}-r${n}c${r}`)},`${a}-r${n}c${r}`))},`${a}-r${n}`))})]})},a));continue}if(!f.trim()){d();continue}if(tn.test(f)){d();let a=[];for(;e<r.length;){let t=tn.exec(r[e]);if(!t)break;let n=t[2].trim(),o=`o${i.length}-${a.length}`;a.push({label:nn(n),checked:t[1].toLowerCase()===`x`,content:en(n,o)}),e+=1}--e,i.push(Y(Yt,{items:a,locale:t,onPick:n},`o${i.length}`));continue}let p=on.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:en(p[2],n)},n));continue}if(sn.test(f)){d(),i.push(Y(`hr`,{},`r${i.length}`));continue}let m=cn.exec(f);if(m){c(),l(),s.push(m[1]);continue}let h=rn.exec(f),g=h?null:an.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(C,{children:i})}var hn=80;function gn({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 _n({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 vn({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(_n,{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 yn({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(At,{name:e.agent.name,color:e.agent.color,url:e.agent.avatarUrl}):Y(xn,{}),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(mn,{text:e.content,locale:t,onChoice:r}),e.streaming&&Y(`span`,{class:`sqc-caret`,"aria-hidden":`true`}),s&&Y(Kt,{locale:t,call:e.content.trim()===``?e.approval:void 0,onDecide:i}),e.role===`assistant`&&!s&&!e.streaming&&!e.error&&Ht(e.content,t.code)&&Y(qt,{locale:t,onPick:r}),e.unknownHandle&&!e.streaming&&Y(bn,{message:e,locale:t}),Y(vn,{files:e.attachments??[],load:a})]}),!o&&Y(gn,{at:e.createdAt,locale:t})]})]})}function bn({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(C,{children:[` `,Y(`span`,{children:t.t.handles.instead}),` `,n.map(e=>Y(`code`,{children:[`@`,e.handle]},e.handle))]})]})}function xn(){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 Sn({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 _e(()=>{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<hn};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(yn,{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 Cn={width:`min(392px, 100vw)`},wn=new Set([`sessionId`]);function Tn(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 En(e){if(!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if(wn.has(n)||typeof r!=`string`&&!ke(r))continue;let e=Oe(r);e&&t.push({label:Tn(n),value:e})}return t}function Dn(e,t){return e?.trim()?e:t}function On(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 kn(e){let t=e.persistOpen??!0,[n,r]=W(()=>Ve(e.defaultOpen,t)),[i,a]=W(!1),[o,s]=W(!1),c=K(null),l=K(null),u=On(e.theme??`light`),d=ve(()=>Le(e.locale),[e.locale]),f=d.t,p=Dn(e.heading,f.heading),m=Dn(e.assistantName,f.assistant),h=Dn(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}=Ot({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 L=q(()=>{s(!1),!I.current&&(I.current=!0,r(!0),t&&Be(!0),g?.({type:`chatbot-open`,sessionId:E}))},[g,t,E]),R=q(()=>{I.current&&(I.current=!1,r(!1),t&&Be(!1),g?.({type:`chatbot-close`,sessionId:E}),l.current?.focus())},[g,t,E]);G(()=>{n&&x()},[n,x]);let z=D.length>=2,B=He(C,k||void 0),[ee,te]=W(void 0),ne=K(void 0),re=q(e=>{ne.current=e,te(e)},[]);G(()=>{ne.current=void 0,te(void 0)},[B]);let ie=q(e=>{a(!0),_(z?Ue(e,ne.current,B):e)},[_,z,B]),V=q(()=>{a(!1),s(!1),v()},[v]),H=K({openPanel:L,closePanel:R,send:ie,reset:V,sessionId:E});H.current={openPanel:L,closePanel:R,send:ie,reset:V,sessionId:E};let ae=K({open:()=>H.current.openPanel(),close:()=>H.current.closePanel(),toggle:()=>I.current?H.current.closePanel():H.current.openPanel(),reset:()=>H.current.reset(),send:e=>{H.current.openPanel(),H.current.send(e)},isOpen:()=>I.current,sessionId:()=>H.current.sessionId}),oe=e.bind;_e(()=>(oe?.(ae.current),()=>oe?.(null)),[oe]),G(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),R())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[R,n]);let se=ve(()=>C.some(e=>e.id!==`greeting`),[C]),ce=ve(()=>En(e.context),[e.context]),U={...e.accent?{"--sqc-accent":e.accent}:{},"--sqc-width":e.width??Cn.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:U,children:[Y(`button`,{ref:l,type:`button`,class:`sqc-launcher`,"aria-label":p,"aria-expanded":n,"aria-haspopup":`dialog`,onClick:L,children:[Y(`span`,{class:`sqc-launcher__icon`,children:Y(`slot`,{name:`launcher-icon`,class:`sqc-slot-icon`,children:Y(xn,{})})}),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(xn,{})}),Y(`div`,{class:`sqc-header__titles`,children:[Y(`p`,{class:`sqc-header__heading`,children:p}),Y(`p`,{class:`sqc-header__sub`,children:Dn(e.subheading,f.subheading)})]}),Y(`button`,{type:`button`,class:`sqc-icon-btn`,onClick:V,"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:R,"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:[z&&Y(Mt,{handles:D,active:ee??B,disabled:w,onPick:re,label:f.handles.rail}),Y(`div`,{class:`sqc-panel__main`,children:[(e.showContext??!0)&&ce.length>0&&Y(`div`,{class:`sqc-context`,"aria-label":f.context.region,children:ce.map(e=>Y(`span`,{class:`sqc-chip`,title:`${e.label}: ${e.value}`,children:[Y(`b`,{children:e.label}),e.value]},e.label))}),Y(Sn,{messages:C,locale:d,assistantName:m,suggestions:e.suggestions,showSuggestions:!i&&!se,busy:S,withHuman:w,onSuggestion:ie,onChoice:ie,onDecide:y,onLoadAttachment:F}),Y(Rt,{placeholder:Dn(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:ie,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 An=`: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 jn(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function Mn(e,t){jn(e,t),t.add(e)}function X(e,t,n){jn(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 Nn=`squadico-chatbot`,Pn=[`embed-key`,`context`,`user`,`agent`,`heading`,`subheading`,`assistant-name`,`placeholder`,`greeting`,`suggestions`,`width`,`accent`,`theme`,`position`,`layout`,`open`,`persist-open`,`show-context`,`locale`],Fn;function In(){if(Fn!==void 0)return Fn;try{let e=new CSSStyleSheet;e.replaceSync(An),Fn=e}catch{Fn=null}return Fn}function Ln(e,t){typeof console<`u`&&console.warn(`[${Nn}] ${e}`,t??``)}function Rn(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}}Ln(`the "user" attribute needs an object with an id`,e)}catch(e){Ln(`the "user" attribute is not valid JSON`,e)}}function zn(e){if(!(!e||!e.trim()))try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t;Ln("the `context` attribute must be a JSON object",e)}catch(e){Ln("the `context` attribute is not valid JSON",e)}}function Bn(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){Ln("the `suggestions` attribute is not valid JSON",e);return}return e.split(`|`).map(e=>e.trim()).filter(Boolean)}}function Vn(e){if(e!==null)return e!==`false`&&e!==`0`}function Hn(e){return e===`dark`||e===`light`||e===`auto`?e:void 0}function Un(e){return e===`bottom-left`||e===`bottom-right`?e:void 0}function Wn(e){return e===`floating`||e===`sidebar`?e:void 0}var Gn=[`context`,`embedKey`,`user`,`getSubjectToken`,`agent`];function Kn(){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(),Mn(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=In();if(m)e.adoptedStyleSheets=[m];else{let t=document.createElement(`style`);t.textContent=An,e.append(t)}Q(t,this,document.createElement(`div`)),e.append($(t,this));for(let e of Gn){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),ie(null,$(t,this)),Q(n,this,null)}attributeChangedCallback(e,t,r){if(t!==r){if(e===`open`&&$(n,this)){Vn(r)?$(n,this).open():$(n,this).close();return}Z(d,this,m).call(this)}}get context(){return $(o,this)??zn(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)??Rn(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()??Vn(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)){Ln(`sendMessage() called before the component was mounted — ignored`);return}$(n,this).send(e)}},Je(e,`observedAttributes`,Pn),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;ie(Y(kn,{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:Bn(this.getAttribute(`suggestions`)),width:e(`width`),accent:e(`accent`),theme:Hn(this.getAttribute(`theme`)),position:Un(this.getAttribute(`position`)),layout:Wn(this.getAttribute(`layout`)),defaultOpen:Vn(this.getAttribute(`open`))??!1,persistOpen:Vn(this.getAttribute(`persist-open`))??!0,showContext:Vn(this.getAttribute(`show-context`))??!0,locale:e(`locale`),onEvent:$(f,this),bind:$(p,this)}),$(t,this))}}var qn;function Jn(e=Nn){typeof window>`u`||typeof HTMLElement>`u`||(qn??(qn=Kn()),window.customElements.get(e)||window.customElements.define(e,qn))}return Jn(),e.API_URL=Ye,e.ChatHttpError=J,e.DEFAULT_LANGUAGE=je,e.MAX_MESSAGE_LENGTH=Xe,e.SUPPORTED_LANGUAGES=Me,e.TAG_NAME=Nn,e.defineChatbot=Jn,e})({});
1
+ var Chatbot=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h={},g=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,t){for(var n in t)e[n]=t[n];return e}function b(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function x(e,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?t.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return S(e,s,i,a,null)}function S(e,t,i,a,o){var s={type:e,props:t,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++r,__i:-1,__u:0};return o==null&&n.vnode!=null&&n.vnode(s),s}function C(e){return e.children}function w(e,t){this.props=e,this.context=t}function T(e,t){if(t==null)return e.__?T(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?T(e):null}function E(e){if(e.__P&&e.__d){var t=e.__v,r=t.__e,i=[],a=[],o=y({},t);o.__v=t.__v+1,n.vnode&&n.vnode(o),L(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[r]:null,i,r??T(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,R(i,o,a),t.__e=t.__=null,o.__e!=r&&D(o)}}function D(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),D(e)}function O(e){(!e.__d&&(e.__d=!0)&&i.push(e)&&!k.__r++||a!=n.debounceRendering)&&((a=n.debounceRendering)||o)(k)}function k(){try{for(var e,t=1;i.length;)i.length>t&&i.sort(s),e=i.shift(),t=i.length,E(e)}finally{i.length=k.__r=0}}function A(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,_,v,y=r&&r.__k||g,b=t.length;for(c=j(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||h,p.__i=d,v=L(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&re(f.ref,null,p),u.push(p.ref,p.__c||m,p)),_==null&&m!=null&&(_=m),4&p.__u?(c=M(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=_,c}function j(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=S(null,o,null,null,null):v(o)?o=e.__k[a]=S(C,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=S(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=N(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=T(s)),ie(s,s));return r}function M(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=M(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=T(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function N(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function P(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||_.test(t)?n:n+`px`}function F(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||P(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||P(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(d,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n[u]=r[u]:(n[u]=f,e.addEventListener(t,a?m:p,a)):e.removeEventListener(t,a?m:p,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function I(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t[l]==null)t[l]=f++;else if(t[l]<r[u])return;return r(n.event?n.event(t):t)}}}function L(e,t,r,i,a,o,s,c,l,u){var d,f,p,m,h,_,x,S,E,D,O,k,j,M,N,P,F=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(l=!!(32&r.__u),o=[c=t.__e=r.__e]),(d=n.__b)&&d(t);n:if(typeof F==`function`){f=s.length;try{if(E=t.props,D=F.prototype&&F.prototype.render,O=(d=F.contextType)&&i[d.__c],k=d?O?O.props.value:d.__:i,r.__c?S=(p=t.__c=r.__c).__=p.__E:(D?t.__c=p=new F(E,k):(t.__c=p=new w(E,k),p.constructor=F,p.render=ae),O&&O.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),D&&p.__s==null&&(p.__s=p.state),D&&F.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=y({},p.__s)),y(p.__s,F.getDerivedStateFromProps(E,p.__s))),h=p.props,_=p.state,p.__v=t,m)D&&F.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),D&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(D&&F.getDerivedStateFromProps==null&&E!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(E,k),t.__v==r.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(E,p.__s,k)){t.__v!=r.__v&&(p.props=E,p.state=p.__s,p.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(e){e&&(e.__=t)}),g.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=T(r);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(E,p.__s,k),D&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,_,x)})}if(p.context=k,p.props=E,p.__P=e,p.__e=!1,j=n.__r,M=0,D)p.state=p.__s,p.__d=!1,j&&j(t),d=p.render(p.props,p.state,p.context),g.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,j&&j(t),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++M<25);p.state=p.__s,p.getChildContext!=null&&(i=y(y({},i),p.getChildContext())),D&&!m&&p.getSnapshotBeforeUpdate!=null&&(x=p.getSnapshotBeforeUpdate(h,_)),N=d!=null&&d.type===C&&d.key==null?te(d.props.children):d,c=A(e,v(N)?N:[N],t,r,i,a,o,s,c,l,u),p.base=t.__e,t.__u&=-161,p.__h.length&&s.push(p),S&&(p.__E=p.__=null)}catch(e){if(s.length=f,t.__v=null,l||o!=null){if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),t.__e=c}else if(o!=null)for(P=o.length;P--;)b(o[P])}else t.__e=r.__e;t.__k??(t.__k=r.__k||[]),e.then||ee(t),n.__e(e,t,r)}}else o==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):c=t.__e=ne(r.__e,t,r,i,a,o,s,l,u);return(d=n.diffed)&&d(t),128&t.__u?void 0:c}function ee(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ee))}function R(e,t,r){for(var i=0;i<r.length;i++)re(r[i],r[++i],r[++i]);n.__c&&n.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){n.__e(e,t.__v)}})}function te(e){return typeof e!=`object`||!e||e.__b>0?e:v(e)?e.map(te):e.constructor===void 0?y({},e):null}function ne(e,r,i,a,o,s,c,l,u){var d,f,p,m,g,_,y,x=i.props||h,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||(o=`http://www.w3.org/1999/xhtml`),s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){e=g,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&(n.__m&&n.__m(r,s),l=!1),s=null}if(C==null)x===S||l&&e.data==S||(e.data=S);else{if(s=C==`textarea`&&S.defaultValue!=null?null:s&&t.call(e.childNodes),!l&&s!=null)for(x={},d=0;d<e.attributes.length;d++)x[(g=e.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||F(e,d,null,g,o);for(d in S)g=S[d],d==`children`?m=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?_=g:d==`checked`?y=g:l&&typeof g!=`function`||x[d]===g||F(e,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),r.__k=[];else if(p&&(e.innerHTML=``),A(r.type==`template`?e.content:e,v(m)?m:[m],r,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&T(i,0),l,u),s!=null)for(d=s.length;d--;)b(s[d]);l&&C!=`textarea`||(d=`value`,C==`progress`&&_==null?e.removeAttribute(`value`):_!=null&&(_!==e[d]||C==`progress`&&!_||C==`option`&&_!=x[d])&&F(e,d,_,x[d],o),d=`checked`,y!=null&&y!=e[d]&&F(e,d,y,x[d],o))}return e}function re(e,t,r){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){n.__e(e,r)}}function ie(e,t,r){var i,a;if(n.unmount&&n.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||re(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){n.__e(e,t)}i.base=i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&ie(i[a],t,r||typeof e.type!=`function`);r||b(e.__e),e.__c=e.__=e.__e=void 0}function ae(e,t,n){return this.constructor(e,n)}function oe(e,r,i){var a,o,s,c;r==document&&(r=document.documentElement),n.__&&n.__(e,r),o=(a=typeof i==`function`)?null:i&&i.__k||r.__k,s=[],c=[],L(r,e=(!a&&i||r).__k=x(C,null,[e]),o||h,h,r.namespaceURI,!a&&i?[i]:o?null:r.firstChild?t.call(r.childNodes):null,s,!a&&i?i:o?o.__e:r.firstChild,a,c),R(s,e,c),e.props.children=null}t=g.slice,n={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},r=0,w.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=y({},this.state);typeof e==`function`&&(e=e(y({},n),this.props)),e&&y(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),O(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),O(this))},w.prototype.render=C,i=[],o=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,s=function(e,t){return e.__v.__b-t.__v.__b},k.__r=0,c=Math.random().toString(8),l=`__d`+c,u=`__a`+c,d=/(PointerCapture)$|Capture$/i,f=0,p=I(!1),m=I(!0);var z,B,V,se,ce=0,le=[],H=n,ue=H.__b,de=H.__r,fe=H.diffed,pe=H.__c,me=H.unmount,he=H.__;function ge(e,t){H.__h&&H.__h(B,e,ce||t),ce=0;var n=B.__H||(B.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function U(e){return ce=1,_e(Te,e)}function _e(e,t,n){var r=ge(z++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Te(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=B,!B.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};B.__f=!0;var a=B.shouldComponentUpdate,o=B.componentWillUpdate;B.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},B.shouldComponentUpdate=i}return r.__N||r.__}function W(e,t){var n=ge(z++,3);!H.__s&&we(n.__H,t)&&(n.__=e,n.u=t,B.__H.__h.push(n))}function ve(e,t){var n=ge(z++,4);!H.__s&&we(n.__H,t)&&(n.__=e,n.u=t,B.__h.push(n))}function G(e){return ce=5,K(function(){return{current:e}},[])}function K(e,t){var n=ge(z++,7);return we(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function q(e,t){return ce=8,K(function(){return e},t)}function ye(){for(var e;e=le.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Se),t.__h.some(Ce),t.__h=[]}catch(n){t.__h=[],H.__e(n,e.__v)}}}H.__b=function(e){B=null,ue&&ue(e)},H.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),he&&he(e,t)},H.__r=function(e){de&&de(e),z=0;var t=(B=e.__c).__H;t&&(V===B?(t.__h=[],B.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Se),t.__h.some(Ce),t.__h=[],z=0)),V=B},H.diffed=function(e){fe&&fe(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(le.push(t)!==1&&se===H.requestAnimationFrame||((se=H.requestAnimationFrame)||xe)(ye)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),V=B=null},H.__c=function(e,t){t.some(function(e){try{e.__h.some(Se),e.__h=e.__h.filter(function(e){return!e.__||Ce(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],H.__e(n,e.__v)}}),pe&&pe(e,t)},H.unmount=function(e){me&&me(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Se(e)}catch(e){t=e}}),n.__H=void 0,t&&H.__e(t,n.__v))};var be=typeof requestAnimationFrame==`function`;function xe(e){var t,n=function(){clearTimeout(r),be&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);be&&(t=requestAnimationFrame(n))}function Se(e){var t=B,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),B=t}function Ce(e){var t=B;e.__c=e.__(),B=t}function we(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Te(e,t){return typeof t==`function`?t(e):t}var Ee=new Set([`sessionId`]);function De(e){if(typeof e==`string`)return e.length>0?{id:e}:void 0;if(!e||typeof e!=`object`||Array.isArray(e))return;let{id:t,name:n}=e;if(typeof t==`string`&&t.length!==0)return typeof n==`string`&&n.length>0?{id:t,name:n}:{id:t}}function Oe(e){let t=De(e);if(t)return t.name??t.id}function ke(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Ae(e){let t={};for(let[n,r]of Object.entries(e)){if(Ee.has(n)||!ke(r)){t[n]=r;continue}let e=De(r);e&&(t[`${n}Id`]=e.id,e.name&&(t[`${n}Name`]=e.name))}return t}var je=`en`,Me=[`en`,`fr`,`es`],Ne={en:{heading:`Assistant`,subheading:`Squadico`,placeholder:`Ask your question…`,greeting:`Hello! I am your assistant. What would you like to do?`,hint:`The assistant proposes an action; nothing is applied without your confirmation.`,assistant:`Assistant`,typing:`The assistant is writing its answer`,activity:{knowledge:`Searching the knowledge base…`,skill:`Following a procedure…`,delegation:`Asking a colleague…`,tool:`Looking it up…`},newConversation:`New conversation`,close:`Close the assistant`,closeTitle:`Close`,history:{open:`Conversation history`,menu:`Previous conversations`,loading:`Loading…`,empty:`No previous conversation.`,untitled:`Conversation`},context:{region:`Context sent to the assistant`},approval:{group:`Write confirmation`,approve:`Yes, apply`,reject:`No, cancel`,request:`The agent wants to use {tool}.`,arguments:`With`,edit:`Change…`,correction:`What to change — e.g. “the due date is next Monday”`,correctionLabel:`Correction to make before approving`,send:`Send`},confirm:{group:`Confirmation`,yes:`Yes`,no:`No`,yesValue:`yes`,noValue:`no`,other:`Propose something else`},choices:`Suggested options`,table:{copy:`Copy`,copied:`Copied`,more:`{count} more rows`},form:{submit:`Send`,required:`Required`,email:`Enter a valid email address`,number:`Enter a number`},poweredBy:`Powered by Squadico`,handles:{picker:`Agents you can address`,unknown:`Nobody answers to that name here:`,instead:`You can address:`,rail:`Agents`},selection:{group:`Suggested choice`,single:`Pick one option.`,multiple:`Pick one or more options, then validate.`,validate:`Validate`},composer:{label:`Your message`,send:`Send the message`,sendTitle:`Send`,stop:`Stop the answer`,stopTitle:`Stop`,attach:`Attach a file`,attachTitle:`Attach`,remove:`Remove {name}`},attachments:{unsupported:`This kind of file cannot be attached to a message.`,tooLarge:`This file is too large.`,tooMany:`This message already carries as many files as it may.`,unreadable:`This file could not be read.`,failed:`This file could not be attached.`},error:`Something went wrong, the assistant could not answer. Try again in a moment.`,withHuman:`A member of the team will reply to you here.`},fr:{heading:`Assistant`,subheading:`Squadico`,placeholder:`Posez votre question…`,greeting:`Bonjour ! Je suis votre assistant. Que souhaitez-vous faire ?`,hint:`L'assistant propose une action ; rien n'est appliqué sans votre confirmation.`,assistant:`Assistant`,typing:`L'assistant rédige sa réponse`,activity:{knowledge:`Recherche dans la base de connaissances…`,skill:`Application d'une procédure…`,delegation:`Consultation d'un collègue…`,tool:`Recherche en cours…`},newConversation:`Nouvelle conversation`,close:`Fermer l'assistant`,closeTitle:`Fermer`,history:{open:`Historique des conversations`,menu:`Conversations précédentes`,loading:`Chargement…`,empty:`Aucune conversation précédente.`,untitled:`Conversation`},context:{region:`Contexte transmis à l'assistant`},approval:{group:`Validation de l'écriture`,approve:`Oui, appliquer`,reject:`Non, annuler`,request:`L'agent souhaite utiliser {tool}.`,arguments:`Avec`,edit:`Modifier…`,correction:`Ce qu'il faut changer — ex. « l'échéance est lundi prochain »`,correctionLabel:`Correction à apporter avant validation`,send:`Envoyer`},confirm:{group:`Confirmation`,yes:`Oui`,no:`Non`,yesValue:`oui`,noValue:`non`,other:`Proposer autre chose`},choices:`Options proposées`,table:{copy:`Copier`,copied:`Copié`,more:`{count} lignes de plus`},form:{submit:`Envoyer`,required:`Obligatoire`,email:`Saisissez une adresse e-mail valide`,number:`Saisissez un nombre`},poweredBy:`Propulsé par Squadico`,handles:{picker:`Agents que vous pouvez adresser`,unknown:`Personne ne répond à ce nom ici :`,instead:`Vous pouvez adresser :`,rail:`Agents`},selection:{group:`Choix proposé`,single:`Sélectionnez une option.`,multiple:`Sélectionnez une ou plusieurs options, puis validez.`,validate:`Valider`},composer:{label:`Votre message`,send:`Envoyer le message`,sendTitle:`Envoyer`,stop:`Interrompre la réponse`,stopTitle:`Interrompre`,attach:`Joindre un fichier`,attachTitle:`Joindre`,remove:`Retirer {name}`},attachments:{unsupported:`Ce format de fichier ne peut pas être joint à un message.`,tooLarge:`Ce fichier est trop volumineux.`,tooMany:`Ce message porte déjà autant de fichiers qu'il le peut.`,unreadable:`Ce fichier n'a pas pu être lu.`,failed:`Impossible de joindre ce fichier.`},error:`Une erreur est survenue, l'assistant n'a pas pu répondre. Réessayez dans un instant.`,withHuman:`Un membre de l'équipe va vous répondre ici.`},es:{heading:`Asistente`,subheading:`Squadico`,placeholder:`Haga su pregunta…`,greeting:`¡Hola! Soy su asistente. ¿Qué desea hacer?`,hint:`El asistente propone una acción; no se aplica nada sin su confirmación.`,assistant:`Asistente`,typing:`El asistente está redactando su respuesta`,activity:{knowledge:`Buscando en la base de conocimientos…`,skill:`Siguiendo un procedimiento…`,delegation:`Consultando a un compañero…`,tool:`Consultando…`},newConversation:`Nueva conversación`,close:`Cerrar el asistente`,closeTitle:`Cerrar`,history:{open:`Historial de conversaciones`,menu:`Conversaciones anteriores`,loading:`Cargando…`,empty:`Ninguna conversación anterior.`,untitled:`Conversación`},context:{region:`Contexto enviado al asistente`},approval:{group:`Validación de la escritura`,approve:`Sí, aplicar`,reject:`No, cancelar`,request:`El agente quiere usar {tool}.`,arguments:`Con`,edit:`Modificar…`,correction:`Lo que hay que cambiar — p. ej. «el vencimiento es el lunes»`,correctionLabel:`Corrección antes de validar`,send:`Enviar`},confirm:{group:`Confirmación`,yes:`Sí`,no:`No`,yesValue:`sí`,noValue:`no`,other:`Proponer otra cosa`},choices:`Opciones propuestas`,table:{copy:`Copiar`,copied:`Copiado`,more:`{count} filas más`},form:{submit:`Enviar`,required:`Obligatorio`,email:`Introduzca un correo electrónico válido`,number:`Introduzca un número`},poweredBy:`Con la tecnología de Squadico`,handles:{picker:`Agentes a los que puedes dirigirte`,unknown:`Nadie responde a ese nombre aquí:`,instead:`Puedes dirigirte a:`,rail:`Agentes`},selection:{group:`Opción propuesta`,single:`Seleccione una opción.`,multiple:`Seleccione una o varias opciones y valide.`,validate:`Validar`},composer:{label:`Su mensaje`,send:`Enviar el mensaje`,sendTitle:`Enviar`,stop:`Interrumpir la respuesta`,stopTitle:`Interrumpir`,attach:`Adjuntar un archivo`,attachTitle:`Adjuntar`,remove:`Quitar {name}`},attachments:{unsupported:`Este tipo de archivo no se puede adjuntar a un mensaje.`,tooLarge:`Este archivo es demasiado grande.`,tooMany:`Este mensaje ya lleva todos los archivos que puede llevar.`,unreadable:`No se ha podido leer este archivo.`,failed:`No se ha podido adjuntar este archivo.`},error:`Se ha producido un error, el asistente no ha podido responder. Inténtelo de nuevo.`,withHuman:`Un miembro del equipo le responderá aquí.`}},Pe={en:`en-GB`,fr:`fr-FR`,es:`es-ES`};function Fe(e){let t=e?.trim().toLowerCase().split(/[-_]/)[0];return t&&t in Ne?t:void 0}function Ie(){return typeof navigator>`u`?[]:navigator.languages?.length?navigator.languages:[navigator.language]}function Le(e){let t=e?.trim(),n=(t?[t]:Ie()).find(Fe),r=Fe(n)??`en`;return{code:r,tag:n?.includes(`-`)?n:Pe[r],t:Ne[r]}}var Re=`squadico-chatbot:open`;function ze(){try{if(typeof sessionStorage>`u`)return;let e=sessionStorage.getItem(Re);return e===`1`||e!==`0`&&void 0}catch{return}}function Be(e){try{if(typeof sessionStorage>`u`)return;sessionStorage.setItem(Re,e?`1`:`0`)}catch{}}function Ve(e,t){return t===!1?e??!1:ze()??e??!1}function He(e,t){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role===`assistant`&&n.agent)return n.agent.handle}return t}function Ue(e,t,n){return!t||t===n||e.trimStart().startsWith(`@`)?e:`@${t} ${e}`}function We(){let e=globalThis.crypto;if(e&&typeof e.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);if(e&&typeof e.getRandomValues==`function`)e.getRandomValues(t);else for(let e=0;e<16;e++)t[e]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=[];for(let e=0;e<16;e++)n.push(t[e].toString(16).padStart(2,`0`));return n.slice(0,4).join(``)+`-`+n.slice(4,6).join(``)+`-`+n.slice(6,8).join(``)+`-`+n.slice(8,10).join(``)+`-`+n.slice(10,16).join(``)}function Ge(e){"@babel/helpers - typeof";return Ge=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Ge(e)}function Ke(e,t){if(Ge(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Ge(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function qe(e){var t=Ke(e,`string`);return Ge(t)==`symbol`?t:t+``}function Je(e,t,n){return(t=qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ye=`https://api.squadico.com`,Xe=2e4,J=class extends Error{constructor(e,t,n){super(e),Je(this,`status`,void 0),Je(this,`code`,void 0),this.name=`ChatHttpError`,this.status=t,this.code=n}};function Ze(e,t){return`${e.replace(/\/+$/,``)}${t}`}function Qe(e,t){return{"Content-Type":`application/json`,Accept:`text/event-stream, application/json`,...e?{"X-Visitor-Token":e}:{},...t?{"X-Subject-Token":t}:{}}}function $e(e){if(!e||typeof e!=`object`)return;let{loc:t,msg:n}=e;if(typeof n!=`string`||!n)return;let r=(Array.isArray(t)?t.filter(e=>typeof e==`string`):[]).at(-1);return r&&r!==`body`?`${r}: ${n}`:n}async function et(e){let t=``,n;try{let r=await e.text();if(r)try{let e=JSON.parse(r),i=e.detail??e.message;if(Array.isArray(i)){let e=i.map(e=>$e(e)??(typeof e==`string`?e:void 0)).filter(e=>e!==void 0);t=e.length>0?e.join(`, `):r}else t=typeof i==`string`?i:r;n=typeof e.code==`string`?e.code:void 0}catch{t=r}}catch{}return new J(t||`The API answered ${e.status}`,e.status,n)}function tt(e,t){if(!e||typeof e!=`object`)return;let n=e;if(!(typeof n.handle!=`string`||!n.handle))return{handle:n.handle,name:typeof n.name==`string`?n.name:n.handle,avatarUrl:typeof n.avatar_url==`string`&&n.avatar_url?Ze(t,n.avatar_url):void 0,color:typeof n.color==`string`?n.color:void 0}}function nt(e,t){return(Array.isArray(e)?e:[]).map(e=>tt(e,t)).filter(e=>e!==void 0)}var rt=[`knowledge`,`skill`,`delegation`,`tool`];function it(e){return rt.find(t=>t===e)??`tool`}function at(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.tool_call_id!=`string`||!t.tool_call_id))return{toolCallId:t.tool_call_id,tool:typeof t.tool==`string`?t.tool:``,arguments:t.arguments&&typeof t.arguments==`object`?t.arguments:{}}}var ot=new Set([`user`,`assistant`]);function st(e,t){if(typeof e.role!=`string`||!ot.has(e.role)||typeof e.content!=`string`||!e.content)return null;let n=typeof e.created_at==`string`?Date.parse(e.created_at):NaN;return{id:typeof e.id==`string`&&e.id?e.id:We(),role:e.role,content:e.content,createdAt:Number.isNaN(n)?Date.now():n,agent:tt(e.agent,t),attachments:ct(e.attachments),authorName:e.kind===`human`&&typeof e.author_name==`string`&&e.author_name?e.author_name:void 0}}function ct(e){if(!Array.isArray(e))return;let t=e.map(e=>lt(e)).filter(e=>e!==null);return t.length>0?t:void 0}function lt(e){if(!e||typeof e!=`object`)return null;let{id:t,kind:n,filename:r,content_type:i}=e;return typeof t!=`string`||!t||typeof r!=`string`||!r?null:{id:t,kind:n===`image`||n===`chart`?n:`document`,filename:r,contentType:typeof i==`string`?i:`application/octet-stream`}}async function ut(e){let t=e.agent?`?agent=${encodeURIComponent(e.agent)}`:``,n=await fetch(Ze(e.apiUrl,`/public/applications/${encodeURIComponent(e.embedKey)}${t}`),{method:`GET`,headers:Qe(),signal:e.signal});if(!n.ok)throw await et(n);let r=await n.json();return{welcomeMessage:typeof r.welcome_message==`string`&&r.welcome_message?r.welcome_message:void 0,agent:tt(r.agent,e.apiUrl),handles:nt(r.handles,e.apiUrl),agentHandle:typeof r.agent_handle==`string`&&r.agent_handle?r.agent_handle:void 0,branding:r.branding===!0}}async function dt(e){let t=await fetch(Ze(e.apiUrl,`/public/applications/${encodeURIComponent(e.embedKey)}/conversations`),{method:`POST`,headers:Qe(),body:JSON.stringify({...e.user?{user:e.user}:{},...e.agent?{agent:e.agent}:{}}),signal:e.signal});if(!t.ok)throw await et(t);let n=await t.json();if(typeof n.id!=`string`||typeof n.visitor_token!=`string`)throw new J(`The API opened a conversation without an id or a token`);let r=(Array.isArray(n.messages)?n.messages:[]).map(t=>st(t,e.apiUrl)).filter(e=>e!==null);return{conversationId:n.id,visitorToken:n.visitor_token,agentName:typeof n.agent_name==`string`?n.agent_name:``,agentSlug:typeof n.agent_slug==`string`?n.agent_slug:``,welcomeMessage:typeof n.welcome_message==`string`&&n.welcome_message?n.welcome_message:void 0,messages:r,handles:nt(n.handles,e.apiUrl),agentHandle:typeof n.agent_handle==`string`&&n.agent_handle?n.agent_handle:void 0,withHuman:typeof n.handling==`string`&&n.handling!==`agents`,branding:n.branding===!0}}async function ft(e){let t=await fetch(Ze(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}`),{method:`GET`,headers:Qe(e.visitorToken),signal:e.signal});if(!t.ok)throw await et(t);let n=await t.json();if(typeof n.id!=`string`)throw new J(`The API replayed a conversation without an id`);return{conversationId:n.id,visitorToken:e.visitorToken,agentName:typeof n.agent_name==`string`?n.agent_name:``,agentSlug:typeof n.agent_slug==`string`?n.agent_slug:``,welcomeMessage:typeof n.welcome_message==`string`&&n.welcome_message?n.welcome_message:void 0,messages:(Array.isArray(n.messages)?n.messages:[]).map(t=>st(t,e.apiUrl)).filter(e=>e!==null),handles:nt(n.handles,e.apiUrl),agentHandle:typeof n.agent_handle==`string`&&n.agent_handle?n.agent_handle:void 0,withHuman:typeof n.handling==`string`&&n.handling!==`agents`,branding:n.branding===!0}}async function pt(e){let t=new FormData;t.append(`file`,e.file);let n=await fetch(gt(e),{method:`POST`,headers:{"X-Visitor-Token":e.visitorToken},body:t,signal:e.signal});if(!n.ok)throw await et(n);let r=lt(await n.json());if(!r)throw new J(`The upload could not be read`,n.status);return r}async function mt(e){let t=await fetch(`${gt(e)}/${encodeURIComponent(e.attachmentId)}`,{method:`DELETE`,headers:{"X-Visitor-Token":e.visitorToken},signal:e.signal});if(!t.ok)throw await et(t)}async function ht(e){let t=await fetch(`${gt(e)}/${encodeURIComponent(e.attachmentId)}/content`,{headers:{"X-Visitor-Token":e.visitorToken},signal:e.signal});if(!t.ok)throw await et(t);return t.blob()}function gt(e){return Ze(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/attachments`)}async function _t(e){return yt(Ze(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/messages`),{content:e.message,attachment_ids:e.attachmentIds??[],...e.context&&Object.keys(e.context).length>0?{context:e.context}:{}},e)}async function vt(e){return yt(Ze(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/approvals`),{tool_call_id:e.toolCallId,approved:e.approved},e)}async function yt(e,t,n){let r=await fetch(e,{method:`POST`,headers:Qe(n.visitorToken,n.subjectToken),body:JSON.stringify({...t,widgets:1}),signal:n.signal});if(!r.ok)throw await et(r);if(!r.body)throw new J(`Answer with no stream body`);let i=r.body.getReader(),a=new TextDecoder,o=``,s=``,c=``,l,u,d={answer:``};try{for(;;){let{value:e,done:t}=await i.read();if(t)break;o+=a.decode(e,{stream:!0});let r=o.split(`
2
+ `);o=r.pop()??``;for(let e of r){let t=e.trim();if(!t){s=``;continue}if(t.startsWith(`event:`)){s=t.slice(6).trim();continue}if(!t.startsWith(`data:`))continue;let r=t.slice(5).trim();if(!r)continue;let i;try{i=JSON.parse(r)}catch{continue}s===`token`&&typeof i.text==`string`?(c+=i.text,n.onToken(i.text)):s===`progress`?n.onProgress?.(it(i.activity)):s===`done`?(d.answer=typeof i.content==`string`?i.content:c,d.agent=tt(i.agent,n.apiUrl),typeof i.unknown_handle==`string`&&i.unknown_handle&&(d.unknownHandle=i.unknown_handle,d.offered=nt(i.handles,n.apiUrl))):s===`handoff`?(typeof i.to_agent_name==`string`&&(u=i.to_agent_name),c=``):s===`escalated`?d.withHuman=!0:s===`held`?(d.held=!0,d.withHuman=!0):s===`approval_required`?d.approval=at(i):s===`error`&&(l=typeof i.detail==`string`?i.detail:`The turn failed`)}if(l)break}}finally{i.cancel().catch(()=>void 0)}if(l)throw new J(l);return!d.answer&&!d.approval&&(d.answer=c),u&&!d.agent&&(d.authorName=u),d}var bt=`squadico-chatbot:conversation`;function xt(){try{if(typeof sessionStorage>`u`)return;let e=sessionStorage.getItem(bt);if(!e)return;let t=JSON.parse(e);return!t.sessionId||!t.visitorToken||!t.embedKey?void 0:{sessionId:t.sessionId,visitorToken:t.visitorToken,embedKey:t.embedKey,user:typeof t.user==`string`?t.user:void 0,scope:typeof t.scope==`string`?t.scope:void 0}}catch{return}}function St(e){try{if(typeof sessionStorage>`u`)return;sessionStorage.setItem(bt,JSON.stringify(e))}catch{}}function Ct(){try{if(typeof sessionStorage>`u`)return;sessionStorage.removeItem(bt)}catch{}}function wt(e,{embedKey:t,user:n,scope:r}){return e.embedKey===t&&e.user===n&&e.scope===r}async function Tt(e){if(e)try{return await e()||void 0}catch{return}}var Et=`preview-welcome`;function Dt(e,t){return e===void 0&&t===void 0?void 0:JSON.stringify([e,t])}function Ot(e){let t=e instanceof J?e.status:void 0;return t===415?`unsupported`:t===413?`tooLarge`:t===409?`tooMany`:t===422?`unreadable`:`failed`}var kt=5e3;function At(e){return e instanceof J&&e.code===`conversation_retired`}function jt(e){let[t,n]=U([]),[r,i]=U(!1),[a,o]=U(``),[s,c]=U(0),[l,u]=U([]),[d,f]=U(``),[p,m]=U(``),[h,g]=U(null),[_,v]=U(!1),[y,b]=U(!1),[x,S]=U([]),[C,w]=U([]),[T,E]=U(null),D=G(null),O=G(e);O.current=e;let k=G(null),A=G(null),j=G(null),M=G(null),N=G(void 0),P=e.greeting,F=K(()=>P?{id:`greeting`,role:`assistant`,content:P,createdAt:Date.now()}:null,[P]),I=q(e=>{O.current.onEvent?.(e)},[]),L=q((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,...t}:n))},[]),ee=q((e,t)=>{let n=e instanceof J?e.status:void 0,r=e instanceof Error?e.message:String(e),i=(O.current.locale??Le(void 0)).t.error;t&&L(t,{content:i,streaming:!1,error:!0,activity:void 0}),I({type:`chatbot-error`,message:r,status:n,sessionId:A.current?.sessionId??``}),typeof console<`u`&&console.error(`[squadico-chatbot]`,r)},[I,L]),R=q(()=>{let e=O.current;if(!e.embedKey)throw new J(`No embed key: nothing says which application to open`);return{opts:e,apiUrl:e.apiUrl??`https://api.squadico.com`,embedKey:e.embedKey,claim:e.user,scope:e.scope}},[]),te=q((e,t)=>{let r={sessionId:t.conversationId,visitorToken:t.visitorToken};return A.current=r,N.current=Dt(e.claim?.id,e.scope),St({...r,embedKey:e.embedKey,user:e.claim?.id,scope:e.scope}),o(t.conversationId),u(t.handles),f(e.opts.agent&&t.agentHandle?t.agentHandle:``),m(t.agentHandle??``),v(!!t.withHuman),b(t.branding),n(e=>[...t.messages,...e.filter(e=>e.id!==Et)]),r},[]),ne=q(e=>{if(j.current)return j.current;let t=xt();if(!t||!wt(t,{embedKey:e.embedKey,user:e.claim?.id,scope:e.scope}))return Promise.resolve(null);let n=ft({apiUrl:e.apiUrl,conversationId:t.sessionId,visitorToken:t.visitorToken}).then(t=>te(e,t)).catch(()=>(Ct(),null)).finally(()=>{j.current=null});return j.current=n,n},[te]),re=q(async()=>{if(A.current)return A.current;if(k.current)return k.current;let e=R(),t=ne(e).then(t=>t??dt({apiUrl:e.apiUrl,embedKey:e.embedKey,user:e.claim,agent:e.opts.agent}).then(t=>te(e,t)));k.current=t;try{return await t}finally{k.current=null}},[te,ne,R]),ie=q(()=>{if(A.current||k.current||M.current)return;let e;try{e=R()}catch(e){ee(e);return}let t=ne(e).then(async t=>{if(t||A.current||k.current)return;let r=await ut({apiUrl:e.apiUrl,embedKey:e.embedKey,agent:e.opts.agent});if(A.current||k.current)return;u(r.handles),f(e.opts.agent&&r.agentHandle?r.agentHandle:``),m(r.agentHandle??``),b(r.branding);let i=r.welcomeMessage;i&&n(e=>e.length>0?e:[{id:Et,role:`assistant`,content:i,createdAt:Date.now(),agent:r.agent}])});M.current=t,t.catch(e=>{M.current=null,ee(e)})},[ee,ne,R]),ae=q((e,t,{retry:r=!1,carried:a=[]}={})=>{if(D.current)return;let o=new AbortController;D.current=o,i(!0),g(null);let s=We();n(t=>[...t,{id:We(),role:`user`,content:e,createdAt:Date.now(),attachments:a.length>0?a:void 0},{id:s,role:`assistant`,content:``,createdAt:Date.now(),streaming:!0}]),(async()=>{let i=await re();I({type:`chatbot-message`,role:`user`,content:e,sessionId:i.sessionId});let a=``,c=e=>{a+=e,L(s,{content:a,activity:void 0})},l=e=>{a||L(s,{activity:e})},u;try{u=await t(i,c,o.signal,l)}catch(e){if(!At(e)||(Ct(),A.current=null,k.current=null,!r))throw e;i=await re(),a=``,L(s,{content:``,activity:void 0}),u=await t(i,c,o.signal,l)}if(u.withHuman&&v(!0),u.held){n(e=>e.filter(e=>e.id!==s));return}L(s,{content:u.answer,streaming:!1,activity:void 0,agent:u.agent,authorName:u.authorName,approval:u.approval,unknownHandle:u.unknownHandle,offered:u.offered}),g(u.approval??null),I({type:`chatbot-message`,role:`assistant`,content:u.answer,sessionId:i.sessionId,agent:u.agent?.handle})})().catch(e=>{if(o.signal.aborted){L(s,{streaming:!1,activity:void 0});return}ee(e,s)}).finally(()=>{D.current=null,i(!1)})},[re,I,ee,L]),oe=q(e=>{let t=e.trim();if(!t&&x.length===0)return;let n=x;S([]),E(null),ae(t,async(e,r,i,a)=>_t({subjectToken:await Tt(O.current.getSubjectToken),apiUrl:O.current.apiUrl??`https://api.squadico.com`,conversationId:e.sessionId,visitorToken:e.visitorToken,message:t,attachmentIds:n.map(e=>e.id),context:O.current.context?Ae(O.current.context):void 0,onToken:r,onProgress:a,signal:i}),{retry:!0,carried:n})},[x,ae]),z=q(e=>{E(null),w(t=>[...t,e.name]),re().then(t=>pt({apiUrl:O.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,file:e})).then(e=>S(t=>[...t,e])).catch(e=>E(Ot(e))).finally(()=>w(t=>{let n=t.indexOf(e.name);return n<0?t:[...t.slice(0,n),...t.slice(n+1)]}))},[re]),B=q(e=>{S(t=>t.filter(t=>t.id!==e));let t=A.current;t&&mt({apiUrl:O.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,attachmentId:e}).catch(()=>{})},[]),V=q(async e=>{let t=A.current;if(!t)throw new J(`No conversation to read that file from`);return ht({apiUrl:O.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,attachmentId:e})},[]),se=q((e,t)=>{let n=h;n&&ae(t,async(t,r,i,a)=>vt({subjectToken:await Tt(O.current.getSubjectToken),apiUrl:O.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,toolCallId:n.toolCallId,approved:e,onToken:r,onProgress:a,signal:i}))},[h,ae]),ce=q(()=>{D.current?.abort(),D.current=null,i(!1)},[]),le=q(()=>{D.current?.abort(),D.current=null,A.current=null,k.current=null,j.current=null,M.current=null,N.current=void 0,Ct(),i(!1),g(null),v(!1),o(``),c(e=>e+1),f(``),m(``),n([]),I({type:`chatbot-reset`,sessionId:``})},[I]),H=e.humanPollMs??kt;W(()=>{if(!_||!a)return;let e=setInterval(()=>{let e=A.current;!e||D.current||ft({apiUrl:O.current.apiUrl??`https://api.squadico.com`,conversationId:e.sessionId,visitorToken:e.visitorToken}).then(e=>{n(e.messages),v(!!e.withHuman)}).catch(()=>{})},H);return()=>clearInterval(e)},[_,a,H]);let ue=Dt(e.user?.id,e.scope);return W(()=>{A.current&&N.current!==ue&&le()},[ue,le]),{messages:K(()=>t.length===0&&F?[F]:t,[F,t]),busy:r,sessionId:a,resets:s,handles:l,addressee:d,agentHandle:p,approval:h,withHuman:_,branding:y,start:ie,send:oe,attachments:x,uploading:C,attachmentError:T,attach:z,detach:B,loadAttachment:V,decide:se,stop:ce,reset:le}}var Mt=0;Array.isArray;function Y(e,t,r,i,a,o){t||(t={});var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Mt,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return n.vnode&&n.vnode(u),u}function Nt({name:e,color:t,url:n,size:r=16}){let[i,a]=U(void 0),o=!!n&&i!==n;return Y(`span`,{class:`sqc-avatar`,"aria-hidden":`true`,style:{width:`${r}px`,height:`${r}px`,fontSize:`${Math.round(r*.45)}px`,borderRadius:`${Math.round(r*.25)}px`,...o||!t?{}:{backgroundColor:t}},children:o?Y(`img`,{src:n,alt:``,onError:()=>a(n)}):Pt(e)})}function Pt(e){let t=Array.from(e.trim())[0];return t?t.toLocaleUpperCase():`?`}function Ft({handles:e,active:t,disabled:n,onPick:r,label:i}){return Y(`nav`,{class:`sqc-rail`,"aria-label":i,children:e.map(e=>Y(`button`,{type:`button`,class:`sqc-rail__item`,"aria-label":e.name,"aria-pressed":e.handle===t,"data-tip":e.name,disabled:n,onClick:()=>r(e.handle),children:[Y(Nt,{name:e.name,color:e.color,url:e.avatarUrl,size:40}),Y(`span`,{class:`sqc-rail__label`,"aria-hidden":`true`,children:It(e.handle)})]},e.handle))})}function It(e){let t=e.split(/[-_]/)[0]??e;return t.charAt(0).toUpperCase()+t.slice(1)}var Lt=132,Rt=`image/png,image/jpeg,image/gif,image/webp,application/pdf,.docx,.txt,.md,.csv,.json`,zt=/^[a-zA-Z0-9_-]*$/;function Bt(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`@`);if(r<0||r>0&&!/\s/.test(n[r-1]??``))return null;let i=n.slice(r+1);return zt.test(i)?{start:r,query:i}:null}function Vt({placeholder:e,locale:t,busy:n,autoFocus:r,handles:i,addressee:a,attachments:o=[],uploading:s=[],attachmentError:c,onAttach:l,onDetach:u,onSend:d,onStop:f}){let[p,m]=U(``),[h,g]=U(null),[_,v]=U(0),[y,b]=U(!1),x=G(null),S=G(null),w=!!l,T=s.length>0,E=K(()=>{if(!h||!i||i.length===0)return[];let e=h.query.toLowerCase();return i.filter(t=>t.handle.startsWith(e))},[i,h]),D=E.length>0,O=q(()=>{let e=x.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight>Lt;e.style.height=`${Math.min(e.scrollHeight,Lt)}px`,e.style.overflowY=t?`auto`:`hidden`},[]);W(()=>{r&&x.current?.focus(),O()},[r,O]),W(()=>{a&&(m(e=>e||`@${a} `),requestAnimationFrame(O))},[a,O]);let k=q(e=>{g(Bt(e.value,e.selectionStart??e.value.length)),v(0)},[]),A=q(e=>{let t=x.current;if(!t||!h)return;let n=t.selectionStart??t.value.length,r=`${p.slice(0,h.start)}@${e} ${p.slice(n)}`,i=h.start+e.length+2;m(r),g(null),requestAnimationFrame(()=>{t.focus(),t.setSelectionRange(i,i),O()})},[O,h,p]),j=q(e=>{if(!(!l||!e))for(let t of Array.from(e))l(t)},[l]),M=q(()=>{let e=p.trim();!e&&o.length===0||n||T||(d(e),m(``),g(null),requestAnimationFrame(O))},[o.length,n,O,d,p,T]),N=q(e=>{if(D&&!e.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:E.length-1;v(e=>(e+t)%E.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),A((E[_]??E[0]).handle);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),g(null);return}}e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),M())},[_,E,A,D,M]),P=Xe-p.length;return Y(`form`,{class:`sqc-composer${y?` sqc-composer--dropping`:``}`,onSubmit:e=>{e.preventDefault(),M()},onDragOver:e=>{w&&(e.preventDefault(),b(!0))},onDragLeave:()=>b(!1),onDrop:e=>{w&&(e.preventDefault(),b(!1),j(e.dataTransfer?.files??null))},children:[(o.length>0||T||c)&&Y(`div`,{class:`sqc-attachments`,children:[o.map(e=>Y(`span`,{class:`sqc-chip`,"data-kind":e.kind,children:[Y(`span`,{class:`sqc-chip__name`,children:e.filename}),Y(`button`,{type:`button`,class:`sqc-chip__remove`,"aria-label":t.t.composer.remove.replace(`{name}`,e.filename),onClick:()=>u?.(e.id),children:`×`})]},e.id)),s.map(e=>Y(`span`,{class:`sqc-chip sqc-chip--waiting`,children:Y(`span`,{class:`sqc-chip__name`,children:e})},e)),c&&Y(`p`,{class:`sqc-attachments__error`,role:`status`,children:c})]}),Y(`div`,{class:`sqc-composer__field`,children:[D&&Y(`ul`,{class:`sqc-mentions`,role:`listbox`,"aria-label":t.t.handles.picker,children:E.map((e,t)=>Y(`li`,{role:`option`,"aria-selected":t===_,class:`sqc-mention${t===_?` sqc-mention--active`:``}`,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>v(t),onClick:()=>A(e.handle),children:[Y(`span`,{class:`sqc-mention__icon`,children:Y(Nt,{name:e.name,color:e.color,url:e.avatarUrl,size:18})}),Y(`span`,{class:`sqc-mention__handle`,children:[`@`,e.handle]}),Y(`span`,{class:`sqc-mention__name`,children:e.name})]},e.handle))}),Y(`textarea`,{ref:x,class:`sqc-composer__input`,rows:1,value:p,placeholder:e,maxLength:Xe,"aria-label":t.t.composer.label,onInput:e=>{m(e.currentTarget.value),k(e.currentTarget),O()},onKeyDown:N,onClick:e=>k(e.currentTarget),onPaste:e=>{let t=e.clipboardData?.files;!w||!t||t.length===0||(e.preventDefault(),j(t))}}),P<=200&&Y(`span`,{class:`sqc-composer__count`,"aria-live":`polite`,children:P})]}),w&&Y(C,{children:[Y(`input`,{ref:S,type:`file`,multiple:!0,accept:Rt,class:`sqc-file-input`,onChange:e=>{j(e.currentTarget.files),e.currentTarget.value=``}}),Y(`button`,{type:`button`,class:`sqc-btn sqc-btn--attach`,onClick:()=>S.current?.click(),"aria-label":t.t.composer.attach,title:t.t.composer.attachTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.9`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:Y(`path`,{d:`M21 11.5l-8.8 8.8a5 5 0 01-7.1-7.1l9-9a3.3 3.3 0 014.7 4.7l-9 9a1.6 1.6 0 01-2.3-2.3l8.3-8.3`})})})]}),n?Y(`button`,{type:`button`,class:`sqc-btn sqc-btn--stop`,onClick:f,"aria-label":t.t.composer.stop,title:t.t.composer.stopTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:Y(`rect`,{x:`7`,y:`7`,width:`10`,height:`10`,rx:`2`,fill:`currentColor`})})}):Y(`button`,{type:`submit`,class:`sqc-btn sqc-btn--send`,disabled:!p.trim()&&o.length===0||T,"aria-label":t.t.composer.send,title:t.t.composer.sendTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.9`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:Y(`path`,{d:`M5 12l14-7-5 14-2.5-5.5L5 12z`})})})]})}function Ht(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function Ut(e,t){Ht(e,t),t.add(e)}function X(e,t,n){Ht(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){return e.get(Z(e,t))}function $(e,t,n){return e.set(Z(e,t),n),n}var Wt=new Map;function Gt(e){if(Wt.has(e))return Wt.get(e)??null;let t;try{t=new CSSStyleSheet,t.replaceSync(e)}catch{t=null}return Wt.set(e,t),t}function Kt(e,t,n){let r=[...t,`locked`,`language`];var i=new WeakMap,a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakSet;class l extends HTMLElement{constructor(){super(),Ut(this,c),X(this,i,{locked:!1,language:`en`}),X(this,a,void 0),X(this,o,!1),X(this,s,e=>{Q(i,this).locked||(this.set(`locked`,!0),this.dispatchEvent(new CustomEvent(`sqc-reply`,{detail:{text:e},bubbles:!0,composed:!0})))});let e=this.attachShadow({mode:`open`}),t=Gt(n);if(t)e.adoptedStyleSheets=[t];else{let t=document.createElement(`style`);t.textContent=n,e.append(t)}$(a,this,document.createElement(`div`)),e.append(Q(a,this));for(let e of r){if(!Object.hasOwn(this,e))continue;let t=this[e];delete this[e],this[e]=t}}connectedCallback(){$(o,this,!0),Z(c,this,u).call(this)}disconnectedCallback(){$(o,this,!1),oe(null,Q(a,this))}set(e,t){Q(i,this)[e]=t,Z(c,this,u).call(this)}get(e){return Q(i,this)[e]}}function u(){Q(o,this)&&oe(x(e,{...Q(i,this),reply:Q(s,this)}),Q(a,this))}for(let e of r)Object.defineProperty(l.prototype,e,{get(){return this.get(e)},set(t){this.set(e,t)},configurable:!0});return l}var qt={table:`sqc-table`,choices:`sqc-choices`,confirm:`sqc-confirm`,form:`sqc-form`,chart:`sqc-chart`,approval:`sqc-approval`};function Jt(e){return Le(e).t}var Yt=/(\*\*[^*\n]+\*\*|`[^`\n]+`|~~[^~\n]+~~|\[[^\]\n]+\]\([^)\s]+\)|\*[^*\n]+\*|https?:\/\/[^\s<>()]+)/g,Xt=/^\[([^\]\n]+)\]\(([^)\s]+)\)$/,Zt=/^(https?:|mailto:)/i;function Qt(e,t,n){return Zt.test(e)?Y(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t},n):t}function $t(e,t){let n=e.split(Yt),r=[];return n.forEach((e,n)=>{if(!e)return;let i=`${t}-${n}`,a=Xt.exec(e);e.startsWith(`**`)&&e.endsWith(`**`)&&e.length>4?r.push(Y(`strong`,{children:e.slice(2,-2)},i)):e.startsWith("`")&&e.endsWith("`")&&e.length>2?r.push(Y(`code`,{children:e.slice(1,-1)},i)):e.startsWith(`~~`)&&e.endsWith(`~~`)&&e.length>4?r.push(Y(`del`,{children:e.slice(2,-2)},i)):a?r.push(Qt(a[2],a[1],i)):e.startsWith(`*`)&&e.endsWith(`*`)&&e.length>2?r.push(Y(`em`,{children:e.slice(1,-1)},i)):/^https?:\/\//.test(e)?r.push(Qt(e,e,i)):r.push(e)}),r}function en(e){return e.replace(/\[([^\]\n]+)\]\([^)\s]+\)/g,`$1`).replace(/\*\*|~~|`|\*/g,``).trim()}function tn(){return Y(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.2`,"aria-hidden":`true`,children:Y(`path`,{d:`M3.5 8.5l3 3 6-7`,"stroke-linecap":`round`,"stroke-linejoin":`round`})})}function nn({options:e=[],multiple:t,checked:n,locked:r,language:i,reply:a}){let o=Jt(i),s=e.map(en),[c,l]=U(null),u=e.flatMap((e,t)=>n?.includes(e)?[t]:[]),d=c??(t?u:u.slice(0,1)),f=e=>{if(!r){if(!t){l([e]),a(s[e]);return}l(d.includes(e)?d.filter(t=>t!==e):[...d,e])}};return Y(`div`,{class:`choices`,role:`group`,"aria-label":o.choices,children:[e.map((e,t)=>Y(`button`,{type:`button`,class:`choice`,"aria-pressed":d.includes(t),disabled:r,onClick:()=>f(t),children:[Y(`span`,{class:`box${d.includes(t)?` on`:``}`,"aria-hidden":`true`,children:d.includes(t)&&Y(tn,{})}),Y(`span`,{class:`label`,children:$t(e,`o${t}`)})]},`${t}-${s[t]}`)),t&&Y(`button`,{type:`button`,class:`send`,disabled:r||d.length===0,onClick:()=>{l(d),a([...d].sort((e,t)=>e-t).map(e=>s[e]).join(`, `))},children:o.selection.validate})]})}function rn({locked:e,language:t,reply:n}){let[r,i]=U(null),{confirm:a}=Jt(t),o=[{value:a.yesValue,label:a.yes,kind:`yes`},{value:a.noValue,label:a.no,kind:`no`}];return Y(`div`,{class:`confirm`,role:`group`,"aria-label":a.group,children:[o.map(t=>Y(`button`,{type:`button`,class:t.kind,"aria-pressed":r===t.value,disabled:e,onClick:()=>{i(t.value),n(t.value)},children:t.label},t.kind)),Y(`button`,{type:`button`,class:`other`,disabled:e,onClick:e=>e.currentTarget.dispatchEvent(new CustomEvent(`sqc-compose`,{bubbles:!0,composed:!0})),children:a.other})]})}var an=200,on=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`}),sn=e=>en(e??``).replace(/[\t\r\n]+/g,` `);function cn({table:e,language:t}){let n=Jt(t),{header:r=[],rows:i=[]}=e??{},[a,o]=U(null),[s,c]=U(!1),l=K(()=>{if(!a)return i;let e=a.descending?-1:1;return[...i].sort((t,n)=>e*on.compare(sn(t[a.column]),sn(n[a.column])))},[i,a]),u=()=>{let e=[r,...l].map(e=>r.map((t,n)=>sn(e[n])).join(` `));navigator.clipboard?.writeText(e.join(`
3
+ `)).then(()=>{c(!0),setTimeout(()=>c(!1),2e3)},()=>void 0)},d=l.length-an;return Y(`div`,{children:[Y(`div`,{class:`table`,children:Y(`table`,{children:[Y(`thead`,{children:Y(`tr`,{children:r.map((e,t)=>Y(`th`,{"aria-sort":a?.column===t?a.descending?`descending`:`ascending`:`none`,children:Y(`button`,{type:`button`,onClick:()=>o({column:t,descending:a?.column===t&&!a.descending}),children:$t(e,`h${t}`)})},t))})}),Y(`tbody`,{children:l.slice(0,an).map((e,t)=>Y(`tr`,{children:r.map((n,r)=>Y(`td`,{children:$t(e[r]??``,`r${t}c${r}`)},r))},t))})]})}),Y(`div`,{class:`foot`,children:[d>0&&Y(`span`,{children:n.table.more.replace(`{count}`,String(d))}),Y(`button`,{type:`button`,class:`copy`,onClick:u,children:s?n.table.copied:n.table.copy})]})]})}var ln=[`:host{--w-bg:var(--sqc-bg,#fff);--w-surface:var(--sqc-surface,#f8fafc);--w-selected:var(--sqc-selected,#f1f5f9);--w-border:var(--sqc-border,#e2e8f0);--w-border-strong:var(--sqc-border-strong,#cbd5e1);--w-text:var(--sqc-text,#0f172a);--w-muted:var(--sqc-text-muted,#64748b);--w-accent:var(--sqc-accent-color,var(--sqc-accent,#000));--w-on-accent:var(--sqc-on-accent,#fff);--w-accent-hover:var(--sqc-accent-hover,color-mix(in oklab, var(--w-accent) 84%, var(--w-on-accent)));--w-focus:var(--sqc-focus,0 0 0 2px #fff, 0 0 0 4px #0f172a4d);--w-font:var(--sqc-font-family,system-ui, sans-serif);font-family:var(--w-font);display:block}:host([hidden]){display:none}button{color:inherit;font-family:inherit}button:focus-visible{box-shadow:var(--w-focus);outline:none}`,`.table{scrollbar-width:thin;margin:0 0 8px;overflow-x:auto}table{border-collapse:collapse;white-space:nowrap;min-width:100%;font-size:12.5px}th,td{text-align:left;vertical-align:top;border-bottom:1px solid color-mix(in srgb, currentColor 18%, transparent);padding:6px 10px 6px 0}thead th{text-transform:uppercase;letter-spacing:.05em;font-size:10.5px;font-weight:600}thead button{font:inherit;text-transform:inherit;letter-spacing:inherit;opacity:.7;cursor:pointer;background:0 0;border:0;padding:0}thead button:hover{opacity:1}tbody tr:last-child td{border-bottom:0}.foot{opacity:.8;align-items:center;gap:10px;font-size:11.5px;display:flex}.copy{border:1px solid var(--w-border);cursor:pointer;background:0 0;border-radius:8px;padding:2px 8px;font-size:11.5px}`,`.choices{flex-direction:column;gap:7px;margin:10px 0 2px;display:flex}.choice{text-align:left;width:100%;color:var(--w-text);background:var(--w-bg);border:1px solid var(--w-border);cursor:pointer;border-radius:12px;align-items:center;gap:8px;padding:8px 11px;font-size:12.5px;display:flex}.choice:hover:not(:disabled){border-color:var(--w-border-strong);background:var(--w-surface)}.choice:disabled{cursor:default}.choice:disabled[aria-pressed=false]{opacity:.55}.choice[aria-pressed=true]{border-color:var(--w-border-strong);background:var(--w-selected)}.box{border:1.5px solid var(--w-border-strong);border-radius:4px;flex:none;justify-content:center;align-items:center;width:15px;height:15px;display:inline-flex}.choices:not(:has(.send)) .box{border-radius:50%}.box.on{color:var(--w-on-accent);background:var(--w-accent);border-color:var(--w-accent)}.box svg{width:11px;height:11px}.label{overflow-wrap:anywhere}.send{background:var(--w-accent);height:32px;color:var(--w-on-accent);cursor:pointer;border:0;border-radius:12px;align-self:flex-end;padding:0 14px;font-size:13px;font-weight:600}.send:disabled{opacity:.4;cursor:default}`,`.confirm{flex-wrap:wrap;gap:8px;margin:11px 0 2px;display:flex}.confirm button{border:1px solid var(--w-border);background:var(--w-bg);height:32px;color:var(--w-text);cursor:pointer;border-radius:12px;flex:1 1 0;padding:0 12px;font-size:13px;font-weight:500}.confirm .other{flex-basis:100%}.confirm .yes:not(:disabled){background:var(--w-accent);color:var(--w-on-accent);border-color:#0000;font-weight:600}.confirm button:hover:not(:disabled){border-color:var(--w-border-strong);background:var(--w-surface)}.confirm .yes:hover:not(:disabled){background:var(--w-accent-hover);border-color:#0000}.confirm button:disabled{cursor:default}.confirm button:disabled:not([aria-pressed=true]){opacity:.45}.confirm button[aria-pressed=true]{border-color:var(--w-border-strong);background:var(--w-selected);color:var(--w-text);font-weight:600}`].join(`
4
+ `);function un(){if(typeof customElements>`u`)return;let e=[[qt.table,()=>Kt(cn,[`table`],ln)],[qt.choices,()=>Kt(nn,[`options`,`multiple`,`checked`],ln)],[qt.confirm,()=>Kt(rn,[],ln)]];for(let[t,n]of e)customElements.get(t)||customElements.define(t,n())}var dn=/^(?:mcp|custom|a2a)_[0-9a-f]{8}_/;function fn(e){let t=e.replace(dn,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):e}var pn=`chatbot-widgets.global.js`;function mn(){let e=document.currentScript;return{src:e?.src??``,nonce:e?.nonce??``}}var hn=typeof document<`u`?mn():{src:``,nonce:``};function gn(e){let t=new URL(e);return t.pathname.endsWith(`.js`)?new URL(pn,t).href:new URL(`dist/${pn}`,t.href.replace(/\/?$/,`/`)).href}function _n(e,t=``){return new Promise((n,r)=>{if(!e){r(Error(`Squadico chatbot: cannot locate its own script to load the widget extras.`));return}let i=document.createElement(`script`);i.src=gn(e),t&&(i.nonce=t),i.async=!0,i.onload=()=>n(),i.onerror=()=>{i.remove(),r(Error(`Squadico chatbot: failed to load ${i.src}.`))},document.head.append(i)})}function vn(e){let t;return()=>t??(t=e().catch(e=>{t=void 0,console.warn(e instanceof Error?e.message:e)}))}var yn=vn(()=>_n(hn.src,hn.nonce));function bn(e,t){let n=t[e];return e===t.length-1&&n?.role===`assistant`&&!n.streaming}var xn={fr:/\br[ée]ponde?z? +«?\s*oui\b/i,en:/\b(?:reply|answer|respond) +[“"']?\s*yes\b/i,es:/\bresponda?e?d? +«?\s*s[íi](?!\p{L})/iu},Sn={fr:[/\b(?:confirmes?[- ]tu|confirmez[- ]vous)\b/i,/\b(?:valides?[- ]tu|validez[- ]vous)\b/i,/(?<!\p{L})(?:es[- ]tu s[ûu]re?|[êe]tes[- ]vous s[ûu]re?s?)(?!\p{L})/iu,/\b(?:dois[- ]je|puis[- ]je)\b/i,/\b(?:je continue|on continue|on y va|je lance)\b/i,xn.fr],en:[/\bdo you confirm\b/i,/\bdo you (?:want|wish) me to\b/i,/\b(?:shall|should) I\b/i,/\bare you sure\b/i,/\b(?:shall we|should I) (?:proceed|continue|go ahead)\b/i,xn.en],es:[/\b(?:confirmas|confirma|confirm[áa]is)\b/i,/\b(?:validas|valida|valid[áa]is)\b/i,/\best[áa]s? seguro\b/i,/\b(?:contin[úu]o|procedo|lo lanzo|lo hago)\b/i,/\bquieres? que\b/i,xn.es]},Cn=/^\s*(?:[-*•]\s+)?(?:\[[ xX]\]|\([ xX]\))\s+/m,wn=/[ \t]*\(\s*(?:yes|oui|s[íi])\s*\/\s*non?\s*\)\s*$/i;function Tn(e){return e.replace(wn,``)}function En(e,t=`en`){if(Cn.test(e))return!1;let n=e.split(`
5
+ `).map(e=>e.trim()).filter(Boolean),r=n[n.length-1];return r?wn.test(r)?!0:!r.includes(`?`)&&!xn[t].test(r)?!1:Sn[t].some(e=>e.test(r)):!1}var Dn=[`text`,`number`,`date`,`email`,`select`];function On(e){try{return JSON.parse(e)}catch{return null}}function kn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function An(e){return!Array.isArray(e)||e.length===0||e.length>20||!e.every(e=>typeof e==`string`&&e.trim())?null:e}function jn(e){if(!kn(e))return null;let{name:t,label:n,type:r}=e;if(typeof t!=`string`||!t.trim()||typeof n!=`string`||!n.trim()||typeof r!=`string`||!Dn.includes(r))return null;let i={name:t,label:n,type:r,required:e.required===!0};if(r===`select`){let t=An(e.options);if(!t)return null;i.options=t}return i}function Mn(e){let t=On(e);if(!kn(t)||!Array.isArray(t.fields)||t.fields.length===0||t.fields.length>12)return null;let n=[];for(let e of t.fields){let t=jn(e);if(!t||n.some(e=>e.name===t.name))return null;n.push(t)}let r={fields:n};return typeof t.title==`string`&&(r.title=t.title),typeof t.submit==`string`&&(r.submit=t.submit),r}var Nn=/^\s*(?:[-*•]\s+)?(?:\[([ xX])\]|\(([ xX])\))\s+(.+)$/,Pn=/^\s*\|.*\|\s*$/,Fn=/^\s*\|(?:\s*:?-{1,}:?\s*\|)+\s*$/,In=/^\s*```/;function Ln(e){return e.replace(/^\s*\|/,``).replace(/\|\s*$/,``).split(`|`).map(e=>e.trim())}function Rn(e,t,n=!0){let r=n&&En(e,t),i=(r?Tn(e):e).split(`
6
+ `),a=[],o=[],s=()=>{let e=o.join(`
7
+ `).replace(/^\n+|\n+$/g,``);e.trim()&&a.push({kind:`markdown`,text:e}),o=[]};for(let e=0;e<i.length;e+=1){let t=i[e];if(In.test(t)){let n=e+1;for(;n<i.length&&!In.test(i[n]);)n+=1;let r=n<i.length,c=t.replace(/^\s*```/,``).trim().toLowerCase(),l=i.slice(e+1,n).join(`
8
+ `),u=null;if(r&&c===`form`){let e=Mn(l);e&&(u={kind:`form`,form:e})}u?(s(),a.push(u)):o.push(...i.slice(e,r?n+1:n)),e=r?n:n-1;continue}if(Pn.test(t)&&e+1<i.length&&Fn.test(i[e+1])){s();let n=Ln(t),r=[];for(e+=2;e<i.length&&Pn.test(i[e]);)r.push(Ln(i[e])),e+=1;--e,a.push({kind:`table`,header:n,rows:r});continue}let n=Nn.exec(t);if(n){let t=n[1]!==void 0,r=[],c=[],l=e,u=n;for(;u&&u[1]!==void 0===t;){let e=u[3].trim();r.push(e),(u[1]??u[2])!==` `&&(t||!c.length)&&c.push(e),l+=1,u=l<i.length?Nn.exec(i[l]):null}if(r.length>20)o.push(...i.slice(e,l));else{s();let e={kind:`choices`,options:r,multiple:t};c.length&&(e.checked=c),a.push(e)}e=l-1;continue}o.push(t)}return s(),{blocks:a,confirm:r}}var zn=/^(\s*)[-*•]\s+/,Bn=/^(\s*)\d+[.)]\s+/,Vn=/^\s{0,3}(#{1,6})\s+(.+?)#*\s*$/,Hn=/^\s*([-*_])(?:\s*\1){2,}\s*$/,Un=/^\s*>\s?(.*)$/,Wn=/^\s*```/;function Gn(e,t,n,r){let i=e[t].ordered,a=[],o=t;for(;o<e.length&&e[o].depth>=n;){let t=e[o];if(t.depth===n&&t.ordered!==i)break;if(t.depth>n){let[n,i]=Gn(e,o,t.depth,`${r}-${o}`),s=a[a.length-1];s?s.nested.push(n):a.push({key:`${r}-${o}`,text:null,nested:[n]}),o=i;continue}a.push({key:`${r}-${o}`,text:t.text,nested:[]}),o+=1}let s=a.map(e=>Y(`li`,{children:[e.text===null?null:$t(e.text,e.key),e.nested]},e.key));return[Y(i?`ol`:`ul`,{children:s},r),o]}function Kn(e){let t=e.split(`
9
+ `),n=[],r=[],i=[],a=[],o=()=>{if(!r.length)return;let e=`p${n.length}`;n.push(Y(`p`,{children:$t(r.join(`
10
+ `),e)},e)),r=[]},s=()=>{if(!i.length)return;let e=0;for(;e<i.length;){let t=`l${n.length}`,[r,a]=Gn(i,e,i[e].depth,t);n.push(r),e=a}i=[]},c=()=>{if(!a.length)return;let e=`q${n.length}`;n.push(Y(`blockquote`,{children:$t(a.join(`
11
+ `),e)},e)),a=[]},l=()=>{o(),s(),c()};for(let e=0;e<t.length;e+=1){let u=t[e];if(Wn.test(u)){l();let r=[];for(e+=1;e<t.length&&!Wn.test(t[e]);)r.push(t[e]),e+=1;let i=`c${n.length}`;n.push(Y(`pre`,{children:Y(`code`,{children:r.join(`
12
+ `)})},i));continue}if(!u.trim()){l();continue}let d=Vn.exec(u);if(d){l();let e=d[1].length,t=e<=2?`h3`:e===3?`h4`:`h5`,r=`h${n.length}`;n.push(Y(t,{children:$t(d[2],r)},r));continue}if(Hn.test(u)){l(),n.push(Y(`hr`,{},`r${n.length}`));continue}let f=Un.exec(u);if(f){o(),s(),a.push(f[1]);continue}let p=zn.exec(u),m=p?null:Bn.exec(u),h=p??m;if(h){o(),c(),i.push({depth:h[1].replace(/\t/g,` `).length,ordered:!!m,text:u.slice(h[0].length)});continue}s(),c(),r.push(u)}return l(),n}function qn(e){let t=G(null),{form:n,locked:r,language:i}=e;return ve(()=>{yn()},[]),ve(()=>{t.current&&Object.assign(t.current,{form:n,locked:r,language:i})},[n,r,i]),Y(`sqc-form`,{ref:t,children:n.fields.map(e=>Y(`p`,{children:e.label},e.name))})}function Jn(e,t,n){switch(e.kind){case`markdown`:return Y(C,{children:Kn(e.text)});case`table`:return Y(`sqc-table`,{table:{header:e.header,rows:e.rows},locked:n,language:t.code});case`choices`:return Y(`sqc-choices`,{options:e.options,multiple:e.multiple,checked:e.checked,locked:n,language:t.code});case`form`:return Y(qn,{form:e.form,locked:n,language:t.code})}}function Yn({text:e,locale:t,live:n,confirmable:r}){let{blocks:i,confirm:a}=Rn(e,t.code,r===!0),o=!n;return Y(C,{children:[i.map((e,n)=>Y(C,{children:Jn(e,t,o)},`b${n}`)),a&&Y(`sqc-confirm`,{locked:o,language:t.code})]})}var Xn=80;function Zn({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 Qn(e){let{call:t,locked:n,locale:r}=e,i=r.code,a=G(null);ve(()=>{yn()},[t,n]),ve(()=>{a.current&&Object.assign(a.current,{call:t,locked:n,language:i})},[t,n,i]);let o=e=>t=>t.currentTarget?.dispatchEvent(new CustomEvent(`sqc-decision`,{detail:{approved:e},bubbles:!0,composed:!0})),{yes:s,no:c}=r.t.confirm;return Y(`sqc-approval`,{ref:a,children:[t&&Y(`p`,{children:fn(t.tool)}),Y(`button`,{type:`button`,disabled:n,onClick:o(!0),children:s}),Y(`button`,{type:`button`,disabled:n,onClick:o(!1),children:c})]})}function $n({file:e,load:t}){let[n,r]=U(null);return W(()=>{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 er(e){let{file:t,load:n,language:r}=e,i=G(null),a=K(()=>n(t.id).then(e=>e.text()).catch(()=>``),[t.id,n]);return ve(()=>{yn()},[]),ve(()=>{i.current&&Object.assign(i.current,{body:a,filename:t.filename,language:r})},[a,t.filename,r]),Y(`sqc-chart`,{class:`sqc-attachment__chart`,ref:i,children:t.filename})}function tr({files:e,load:t,language:n}){return e.length===0||!t?null:Y(`div`,{class:`sqc-attachments sqc-attachments--sent`,children:e.map(e=>e.kind===`image`?Y($n,{file:e,load:t},e.id):e.kind===`chart`?Y(er,{file:e,load:t,language:n},e.id):Y(`span`,{class:`sqc-chip`,"data-kind":`document`,children:Y(`span`,{class:`sqc-chip__name`,children:e.filename})},e.id))})}function nr({message:e,locale:t,assistantName:n,live: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(Nt,{name:e.agent.name,color:e.agent.color,url:e.agent.avatarUrl}):Y(ir,{}),e.authorName??e.agent?.name??n]}),Y(`div`,{class:`sqc-msg__bubble`,children:[o?Y(`span`,{class:`sqc-waiting`,children:[Y(`span`,{class:`sqc-typing`,"aria-label":t.t.typing,children:[Y(`i`,{}),Y(`i`,{}),Y(`i`,{})]}),e.activity&&Y(`span`,{class:`sqc-activity`,role:`status`,children:t.t.activity[e.activity]})]}):Y(`div`,{class:`sqc-msg__body`,children:[Y(Yn,{text:e.content,locale:t,live:r,confirmable:e.role===`assistant`&&!s&&!e.streaming&&!e.error}),e.streaming&&Y(`span`,{class:`sqc-caret`,"aria-hidden":`true`}),s&&Y(Qn,{locale:t,call:e.content.trim()===``?e.approval:void 0,locked:!i}),e.unknownHandle&&!e.streaming&&Y(rr,{message:e,locale:t}),Y(tr,{files:e.attachments??[],load:a,language:t.code})]}),!o&&Y(Zn,{at:e.createdAt,locale:t})]})]})}function rr({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(C,{children:[` `,Y(`span`,{children:t.t.handles.instead}),` `,n.map(e=>Y(`code`,{children:[`@`,e.handle]},e.handle))]})]})}function ir(){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 ar({messages:e,locale:t,assistantName:n,suggestions:r,showSuggestions:i,busy:a,withHuman:o,onSuggestion:s,onChoice:c,onDecide:l,onCompose:u,onLoadAttachment:d}){let f=G(null),p=G(!0);ve(()=>{let e=f.current;e&&p.current&&(e.scrollTop=e.scrollHeight)},[e]);let m=G({onChoice:c,onCompose:u});m.current={onChoice:c,onCompose:u},W(()=>{let e=f.current;if(!e)return;let t=e=>{e.stopPropagation();let t=e.detail?.text;typeof t==`string`&&m.current.onChoice(t)},n=e=>{e.stopPropagation(),m.current.onCompose?.()};return e.addEventListener(`sqc-reply`,t),e.addEventListener(`sqc-compose`,n),()=>{e.removeEventListener(`sqc-reply`,t),e.removeEventListener(`sqc-compose`,n)}},[]);let h=e[e.length-1],g=!a&&h?.role===`assistant`&&!!h.approval,_=G({onDecide:l,decidable:g,locale:t});return _.current={onDecide:l,decidable:g,locale:t},W(()=>{let e=f.current;if(!e)return;let t=e=>{e.stopPropagation();let t=e.detail?.approved,n=_.current;if(typeof t!=`boolean`||!n.decidable)return;let{yes:r,no:i}=n.locale.t.confirm;n.onDecide(t,t?r:i)};return e.addEventListener(`sqc-decision`,t),()=>e.removeEventListener(`sqc-decision`,t)},[]),W(()=>{let e=f.current;if(!e)return;let t=()=>{p.current=e.scrollHeight-e.scrollTop-e.clientHeight<Xn};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),Y(`div`,{class:`sqc-messages`,ref:f,role:`log`,"aria-live":`polite`,"aria-atomic":`false`,children:[e.map((r,i)=>Y(nr,{message:r,locale:t,assistantName:n,live:!a&&bn(i,e),onDecide:!a&&r.role===`assistant`&&i===e.length-1?l:void 0,onLoadAttachment:d},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 or={width:`min(392px, 100vw)`},sr=new Set([`sessionId`]);function cr(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 lr(e){if(!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if(sr.has(n)||typeof r!=`string`&&!ke(r))continue;let e=Oe(r);e&&t.push({label:cr(n),value:e})}return t}function ur(e,t){return e?.trim()?e:t}function dr(e){let[t,n]=U(!1);return W(()=>{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 fr(e){un();let t=e.persistOpen??!0,[n,r]=U(()=>Ve(e.defaultOpen,t)),[i,a]=U(!1),[o,s]=U(!1),c=G(null),l=G(null),u=dr(e.theme??`light`),d=K(()=>Le(e.locale),[e.locale]),f=d.t,p=ur(e.heading,f.heading),m=ur(e.assistantName,f.assistant),h=ur(e.greeting,f.greeting),g=e.onEvent,{send:_,reset:v,decide:y,stop:b,start:x,resets:S,busy:C,messages:w,withHuman:T,branding:E,sessionId:D,handles:O,addressee:k,agentHandle:A,attachments:j,uploading:M,attachmentError:N,attach:P,detach:F,loadAttachment:I}=jt({embedKey:e.embedKey,user:e.user,scope:e.scope,getSubjectToken:e.getSubjectToken,agent:e.agent,context:e.context,greeting:h,locale:d,onEvent:g});W(()=>{!n&&w.some(e=>e.role===`assistant`&&e.id!==`greeting`)&&s(!0)},[w,n]);let L=G(n);L.current=n;let ee=q(()=>{s(!1),!L.current&&(L.current=!0,r(!0),t&&Be(!0),g?.({type:`chatbot-open`,sessionId:D}))},[g,t,D]),R=q(()=>{L.current&&(L.current=!1,r(!1),t&&Be(!1),g?.({type:`chatbot-close`,sessionId:D}),l.current?.focus())},[g,t,D]);W(()=>{n&&x()},[n,S,x]);let te=O.length>=2,ne=He(w,A||void 0),[re,ie]=U(void 0),ae=G(void 0),oe=q(e=>{ae.current=e,ie(e)},[]);W(()=>{ae.current=void 0,ie(void 0)},[ne]);let z=q(e=>{a(!0),_(te?Ue(e,ae.current,ne):e)},[_,te,ne]),B=q(()=>{a(!1),s(!1),v()},[v]),V=G({openPanel:ee,closePanel:R,send:z,reset:B,sessionId:D});V.current={openPanel:ee,closePanel:R,send:z,reset:B,sessionId:D};let se=G({open:()=>V.current.openPanel(),close:()=>V.current.closePanel(),toggle:()=>L.current?V.current.closePanel():V.current.openPanel(),reset:()=>V.current.reset(),send:e=>{V.current.openPanel(),V.current.send(e)},isOpen:()=>L.current,sessionId:()=>V.current.sessionId}),ce=e.bind;ve(()=>(ce?.(se.current),()=>ce?.(null)),[ce]),W(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),R())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[R,n]);let le=K(()=>w.some(e=>e.id!==`greeting`),[w]),H=K(()=>lr(e.context),[e.context]),ue={...e.accent?{"--sqc-accent":e.accent}:{},"--sqc-width":e.width??or.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:ue,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(ir,{})})}),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(ir,{})}),Y(`div`,{class:`sqc-header__titles`,children:[Y(`p`,{class:`sqc-header__heading`,children:p}),Y(`p`,{class:`sqc-header__sub`,children:ur(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:R,"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(Ft,{handles:O,active:re??ne,disabled:T,onPick:oe,label:f.handles.rail}),Y(`div`,{class:`sqc-panel__main`,children:[(e.showContext??!0)&&H.length>0&&Y(`div`,{class:`sqc-context`,"aria-label":f.context.region,children:H.map(e=>Y(`span`,{class:`sqc-chip`,title:`${e.label}: ${e.value}`,children:[Y(`b`,{children:e.label}),e.value]},e.label))}),Y(ar,{messages:w,locale:d,assistantName:m,suggestions:e.suggestions,showSuggestions:!i&&!le,busy:C,withHuman:T,onSuggestion:z,onChoice:z,onDecide:y,onCompose:()=>c.current?.querySelector(`.sqc-composer__input`)?.focus(),onLoadAttachment:I}),Y(Vt,{placeholder:ur(e.placeholder,f.placeholder),locale:d,busy:C,autoFocus:n,handles:O,addressee:k,attachments:j,uploading:M,attachmentError:N?f.attachments[N]:void 0,onAttach:P,onDetach:F,onSend:z,onStop:b}),Y(`p`,{class:`sqc-hint`,children:f.hint}),E&&Y(`p`,{class:`sqc-powered`,children:Y(`a`,{href:`https://squadico.com`,target:`_blank`,rel:`noopener noreferrer`,children:f.poweredBy})})]})]})]})]})}var pr=`: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:stretch}.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-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-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}.sqc-waiting{align-items:center;gap:8px;display:inline-flex}.sqc-activity{color:var(--sqc-text-muted);font-size:12px}@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-attachment__chart{flex-basis:100%;min-width:0}.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}`,mr=`squadico-chatbot`,hr=[`embed-key`,`context`,`user`,`agent`,`heading`,`subheading`,`assistant-name`,`placeholder`,`greeting`,`suggestions`,`width`,`accent`,`theme`,`position`,`layout`,`open`,`persist-open`,`show-context`,`locale`],gr;function _r(){if(gr!==void 0)return gr;try{let e=new CSSStyleSheet;e.replaceSync(pr),gr=e}catch{gr=null}return gr}function vr(e,t){typeof console<`u`&&console.warn(`[${mr}] ${e}`,t??``)}function yr(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}}vr(`the "user" attribute needs an object with an id`,e)}catch(e){vr(`the "user" attribute is not valid JSON`,e)}}function br(e){if(!(!e||!e.trim()))try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t;vr("the `context` attribute must be a JSON object",e)}catch(e){vr("the `context` attribute is not valid JSON",e)}}function xr(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){vr("the `suggestions` attribute is not valid JSON",e);return}return e.split(`|`).map(e=>e.trim()).filter(Boolean)}}function Sr(e){if(e!==null)return e!==`false`&&e!==`0`}function Cr(e){return e===`dark`||e===`light`||e===`auto`?e:void 0}function wr(e){return e===`bottom-left`||e===`bottom-right`?e:void 0}function Tr(e){return e===`floating`||e===`sidebar`?e:void 0}var Er=[`context`,`embedKey`,`user`,`scope`,`getSubjectToken`,`agent`];function Dr(){var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m;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 WeakMap,f=new WeakSet,p=new WeakMap,m=new WeakMap,e=class extends HTMLElement{constructor(){super(),Ut(this,f),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,d,void 0),X(this,p,e=>{let{type:t,...n}=e;$(a,this,n.sessionId),this.dispatchEvent(new CustomEvent(t,{detail:n,bubbles:!0,composed:!0}))}),X(this,m,e=>{$(n,this,e),e&&$(a,this,e.sessionId())});let e=this.attachShadow({mode:`open`}),h=_r();if(h)e.adoptedStyleSheets=[h];else{let t=document.createElement(`style`);t.textContent=pr,e.append(t)}$(t,this,document.createElement(`div`)),e.append(Q(t,this));for(let e of Er){if(!Object.hasOwn(this,e))continue;let t=this[e];delete this[e],this[e]=t}}connectedCallback(){$(i,this,!0),Z(f,this,g).call(this)}disconnectedCallback(){$(i,this,!1),oe(null,Q(t,this)),$(n,this,null)}attributeChangedCallback(e,t,r){if(t!==r){if(e===`open`&&Q(n,this)){Sr(r)?Q(n,this).open():Q(n,this).close();return}Z(f,this,h).call(this)}}get context(){return Q(o,this)??br(this.getAttribute(`context`))}set context(e){$(o,this,e),Z(f,this,h).call(this)}get embedKey(){return Q(d,this)??this.getAttribute(`embed-key`)??void 0}set embedKey(e){$(d,this,e),Z(f,this,h).call(this)}get scope(){return Q(c,this)}set scope(e){$(c,this,e),Z(f,this,h).call(this)}get user(){return Q(s,this)??yr(this.getAttribute(`user`))}set user(e){$(s,this,e),Z(f,this,h).call(this)}get getSubjectToken(){return Q(l,this)}set getSubjectToken(e){$(l,this,e),Z(f,this,h).call(this)}get agent(){return Q(u,this)??this.getAttribute(`agent`)??void 0}set agent(e){$(u,this,e),Z(f,this,h).call(this)}get open(){return Q(n,this)?.isOpen()??Sr(this.getAttribute(`open`))??!1}set open(e){e?this.openChat():this.closeChat()}get sessionId(){return Q(n,this)?.sessionId()??Q(a,this)}openChat(){Q(n,this)?.open()}closeChat(){Q(n,this)?.close()}toggleChat(){Q(n,this)?.toggle()}reset(){Q(n,this)?.reset()}sendMessage(e){if(!Q(n,this)){vr(`sendMessage() called before the component was mounted — ignored`);return}Q(n,this).send(e)}},Je(e,`observedAttributes`,hr),e;function h(){Q(r,this)||!Q(i,this)||($(r,this,!0),queueMicrotask(()=>{$(r,this,!1),Q(i,this)&&Z(f,this,g).call(this)}))}function g(){let e=e=>this.getAttribute(e)??void 0;oe(Y(fr,{embedKey:this.embedKey,context:this.context,user:this.user,scope:this.scope,getSubjectToken:this.getSubjectToken,agent:this.agent,heading:e(`heading`),subheading:e(`subheading`),assistantName:e(`assistant-name`),placeholder:e(`placeholder`),greeting:e(`greeting`),suggestions:xr(this.getAttribute(`suggestions`)),width:e(`width`),accent:e(`accent`),theme:Cr(this.getAttribute(`theme`)),position:wr(this.getAttribute(`position`)),layout:Tr(this.getAttribute(`layout`)),defaultOpen:Sr(this.getAttribute(`open`))??!1,persistOpen:Sr(this.getAttribute(`persist-open`))??!0,showContext:Sr(this.getAttribute(`show-context`))??!0,locale:e(`locale`),onEvent:Q(p,this),bind:Q(m,this)}),Q(t,this))}}var Or;function kr(e=mr){typeof window>`u`||typeof HTMLElement>`u`||(Or??(Or=Dr()),window.customElements.get(e)||window.customElements.define(e,Or))}return kr(),e.API_URL=Ye,e.ChatHttpError=J,e.DEFAULT_LANGUAGE=je,e.MAX_MESSAGE_LENGTH=Xe,e.SUPPORTED_LANGUAGES=Me,e.TAG_NAME=mr,e.defineChatbot=kr,e})({});
8
13
  //# sourceMappingURL=chatbot.global.js.map