/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/@anam-ai/agent-widget@0.2.0/dist/index.umd.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
(function(se,te){typeof exports=="object"&&typeof module<"u"?te(exports):typeof define=="function"&&define.amd?define(["exports"],te):(se=typeof globalThis<"u"?globalThis:se||self,te(se.AnamAgentWidget={}))})(this,(function(se){"use strict";var te,x,At,Tt,me,Rt,Nt,xt,Ot,et,tt,it,Ne={},kt=[],Bi=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Pe=Array.isArray;function Q(t,e){for(var n in e)t[n]=e[n];return t}function nt(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function ve(t,e,n){var o,l,s,u={};for(s in e)s=="key"?o=e[s]:s=="ref"?l=e[s]:u[s]=e[s];if(arguments.length>2&&(u.children=arguments.length>3?te.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)u[s]===void 0&&(u[s]=t.defaultProps[s]);return xe(t,u,o,l,null)}function xe(t,e,n,o,l){var s={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:l??++At,__i:-1,__u:0};return l==null&&x.vnode!=null&&x.vnode(s),s}function ae(t){return t.children}function ye(t,e){this.props=t,this.context=e}function Se(t,e){if(e==null)return t.__?Se(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?Se(t):null}function Dt(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Dt(t)}}function Mt(t){(!t.__d&&(t.__d=!0)&&me.push(t)&&!Fe.__r++||Rt!=x.debounceRendering)&&((Rt=x.debounceRendering)||Nt)(Fe)}function Fe(){for(var t,e,n,o,l,s,u,c=1;me.length;)me.length>c&&me.sort(xt),t=me.shift(),c=me.length,t.__d&&(n=void 0,o=void 0,l=(o=(e=t).__v).__e,s=[],u=[],e.__P&&((n=Q({},o)).__v=o.__v+1,x.vnode&&x.vnode(n),rt(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[l]:null,s,l??Se(o),!!(32&o.__u),u),n.__v=o.__v,n.__.__k[n.__i]=n,Ft(s,n,u),o.__e=o.__=null,n.__e!=l&&Dt(n)));Fe.__r=0}function Ut(t,e,n,o,l,s,u,c,E,p,_){var d,S,g,y,C,A,I,b=o&&o.__k||kt,N=e.length;for(E=Pi(n,e,b,E,N),d=0;d<N;d++)(g=n.__k[d])!=null&&(S=g.__i==-1?Ne:b[g.__i]||Ne,g.__i=d,A=rt(t,g,S,l,s,u,c,E,p,_),y=g.__e,g.ref&&S.ref!=g.ref&&(S.ref&&st(S.ref,null,g),_.push(g.ref,g.__c||y,g)),C==null&&y!=null&&(C=y),(I=!!(4&g.__u))||S.__k===g.__k?E=Lt(g,E,t,I):typeof g.type=="function"&&A!==void 0?E=A:y&&(E=y.nextSibling),g.__u&=-7);return n.__e=C,E}function Pi(t,e,n,o,l){var s,u,c,E,p,_=n.length,d=_,S=0;for(t.__k=new Array(l),s=0;s<l;s++)(u=e[s])!=null&&typeof u!="boolean"&&typeof u!="function"?(typeof u=="string"||typeof u=="number"||typeof u=="bigint"||u.constructor==String?u=t.__k[s]=xe(null,u,null,null,null):Pe(u)?u=t.__k[s]=xe(ae,{children:u},null,null,null):u.constructor===void 0&&u.__b>0?u=t.__k[s]=xe(u.type,u.props,u.key,u.ref?u.ref:null,u.__v):t.__k[s]=u,E=s+S,u.__=t,u.__b=t.__b+1,c=null,(p=u.__i=Fi(u,n,E,d))!=-1&&(d--,(c=n[p])&&(c.__u|=2)),c==null||c.__v==null?(p==-1&&(l>_?S--:l<_&&S++),typeof u.type!="function"&&(u.__u|=4)):p!=E&&(p==E-1?S--:p==E+1?S++:(p>E?S--:S++,u.__u|=4))):t.__k[s]=null;if(d)for(s=0;s<_;s++)(c=n[s])!=null&&(2&c.__u)==0&&(c.__e==o&&(o=Se(c)),Vt(c,c));return o}function Lt(t,e,n,o){var l,s;if(typeof t.type=="function"){for(l=t.__k,s=0;l&&s<l.length;s++)l[s]&&(l[s].__=t,e=Lt(l[s],e,n,o));return e}t.__e!=e&&(o&&(e&&t.type&&!e.parentNode&&(e=Se(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function Fi(t,e,n,o){var l,s,u,c=t.key,E=t.type,p=e[n],_=p!=null&&(2&p.__u)==0;if(p===null&&c==null||_&&c==p.key&&E==p.type)return n;if(o>(_?1:0)){for(l=n-1,s=n+1;l>=0||s<e.length;)if((p=e[u=l>=0?l--:s++])!=null&&(2&p.__u)==0&&c==p.key&&E==p.type)return u}return-1}function Bt(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Bi.test(e)?n:n+"px"}function $e(t,e,n,o,l){var s,u;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||Bt(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||Bt(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(Ot,"$1")),u=e.toLowerCase(),e=u in t||e=="onFocusOut"||e=="onFocusIn"?u.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=n,n?o?n.u=o.u:(n.u=et,t.addEventListener(e,s?it:tt,s)):t.removeEventListener(e,s?it:tt,s);else{if(l=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function Pt(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=et++;else if(e.t<n.u)return;return n(x.event?x.event(e):e)}}}function rt(t,e,n,o,l,s,u,c,E,p){var _,d,S,g,y,C,A,I,b,N,M,k,Y,ne,V,re,oe,Z=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(E=!!(32&n.__u),s=[c=e.__e=n.__e]),(_=x.__b)&&_(e);e:if(typeof Z=="function")try{if(I=e.props,b="prototype"in Z&&Z.prototype.render,N=(_=Z.contextType)&&o[_.__c],M=_?N?N.props.value:_.__:o,n.__c?A=(d=e.__c=n.__c).__=d.__E:(b?e.__c=d=new Z(I,M):(e.__c=d=new ye(I,M),d.constructor=Z,d.render=Vi),N&&N.sub(d),d.state||(d.state={}),d.__n=o,S=d.__d=!0,d.__h=[],d._sb=[]),b&&d.__s==null&&(d.__s=d.state),b&&Z.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=Q({},d.__s)),Q(d.__s,Z.getDerivedStateFromProps(I,d.__s))),g=d.props,y=d.state,d.__v=e,S)b&&Z.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),b&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(b&&Z.getDerivedStateFromProps==null&&I!==g&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(I,M),e.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(I,d.__s,M)===!1){for(e.__v!=n.__v&&(d.props=I,d.state=d.__s,d.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(pe){pe&&(pe.__=e)}),k=0;k<d._sb.length;k++)d.__h.push(d._sb[k]);d._sb=[],d.__h.length&&u.push(d);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(I,d.__s,M),b&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(g,y,C)})}if(d.context=M,d.props=I,d.__P=t,d.__e=!1,Y=x.__r,ne=0,b){for(d.state=d.__s,d.__d=!1,Y&&Y(e),_=d.render(d.props,d.state,d.context),V=0;V<d._sb.length;V++)d.__h.push(d._sb[V]);d._sb=[]}else do d.__d=!1,Y&&Y(e),_=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++ne<25);d.state=d.__s,d.getChildContext!=null&&(o=Q(Q({},o),d.getChildContext())),b&&!S&&d.getSnapshotBeforeUpdate!=null&&(C=d.getSnapshotBeforeUpdate(g,y)),re=_,_!=null&&_.type===ae&&_.key==null&&(re=$t(_.props.children)),c=Ut(t,Pe(re)?re:[re],e,n,o,l,s,u,c,E,p),d.base=e.__e,e.__u&=-161,d.__h.length&&u.push(d),A&&(d.__E=d.__=null)}catch(pe){if(e.__v=null,E||s!=null)if(pe.then){for(e.__u|=E?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;s[s.indexOf(c)]=null,e.__e=c}else{for(oe=s.length;oe--;)nt(s[oe]);ot(e)}else e.__e=n.__e,e.__k=n.__k,pe.then||ot(e);x.__e(pe,e,n)}else s==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):c=e.__e=$i(n.__e,e,n,o,l,s,u,E,p);return(_=x.diffed)&&_(e),128&e.__u?void 0:c}function ot(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(ot)}function Ft(t,e,n){for(var o=0;o<n.length;o++)st(n[o],n[++o],n[++o]);x.__c&&x.__c(e,t),t.some(function(l){try{t=l.__h,l.__h=[],t.some(function(s){s.call(l)})}catch(s){x.__e(s,l.__v)}})}function $t(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:Pe(t)?t.map($t):Q({},t)}function $i(t,e,n,o,l,s,u,c,E){var p,_,d,S,g,y,C,A=n.props||Ne,I=e.props,b=e.type;if(b=="svg"?l="http://www.w3.org/2000/svg":b=="math"?l="http://www.w3.org/1998/Math/MathML":l||(l="http://www.w3.org/1999/xhtml"),s!=null){for(p=0;p<s.length;p++)if((g=s[p])&&"setAttribute"in g==!!b&&(b?g.localName==b:g.nodeType==3)){t=g,s[p]=null;break}}if(t==null){if(b==null)return document.createTextNode(I);t=document.createElementNS(l,b,I.is&&I),c&&(x.__m&&x.__m(e,s),c=!1),s=null}if(b==null)A===I||c&&t.data==I||(t.data=I);else{if(s=s&&te.call(t.childNodes),!c&&s!=null)for(A={},p=0;p<t.attributes.length;p++)A[(g=t.attributes[p]).name]=g.value;for(p in A)if(g=A[p],p!="children"){if(p=="dangerouslySetInnerHTML")d=g;else if(!(p in I)){if(p=="value"&&"defaultValue"in I||p=="checked"&&"defaultChecked"in I)continue;$e(t,p,null,g,l)}}for(p in I)g=I[p],p=="children"?S=g:p=="dangerouslySetInnerHTML"?_=g:p=="value"?y=g:p=="checked"?C=g:c&&typeof g!="function"||A[p]===g||$e(t,p,g,A[p],l);if(_)c||d&&(_.__html==d.__html||_.__html==t.innerHTML)||(t.innerHTML=_.__html),e.__k=[];else if(d&&(t.innerHTML=""),Ut(e.type=="template"?t.content:t,Pe(S)?S:[S],e,n,o,b=="foreignObject"?"http://www.w3.org/1999/xhtml":l,s,u,s?s[0]:n.__k&&Se(n,0),c,E),s!=null)for(p=s.length;p--;)nt(s[p]);c||(p="value",b=="progress"&&y==null?t.removeAttribute("value"):y!=null&&(y!==t[p]||b=="progress"&&!y||b=="option"&&y!=A[p])&&$e(t,p,y,A[p],l),p="checked",C!=null&&C!=t[p]&&$e(t,p,C,A[p],l))}return t}function st(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(l){x.__e(l,n)}}function Vt(t,e,n){var o,l;if(x.unmount&&x.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||st(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){x.__e(s,e)}o.base=o.__P=null}if(o=t.__k)for(l=0;l<o.length;l++)o[l]&&Vt(o[l],e,n||typeof t.type!="function");n||nt(t.__e),t.__c=t.__=t.__e=void 0}function Vi(t,e,n){return this.constructor(t,n)}function Ve(t,e,n){var o,l,s,u;e==document&&(e=document.documentElement),x.__&&x.__(t,e),l=(o=typeof n=="function")?null:n&&n.__k||e.__k,s=[],u=[],rt(e,t=(!o&&n||e).__k=ve(ae,null,[t]),l||Ne,Ne,e.namespaceURI,!o&&n?[n]:l?null:e.firstChild?te.call(e.childNodes):null,s,!o&&n?n:l?l.__e:e.firstChild,o,u),Ft(s,t,u)}function Gt(t,e){Ve(t,e,Gt)}function jt(t,e,n){var o,l,s,u,c=Q({},t.props);for(s in t.type&&t.type.defaultProps&&(u=t.type.defaultProps),e)s=="key"?o=e[s]:s=="ref"?l=e[s]:c[s]=e[s]===void 0&&u!=null?u[s]:e[s];return arguments.length>2&&(c.children=arguments.length>3?te.call(arguments,2):n),xe(t.type,c,o||t.key,l||t.ref,null)}te=kt.slice,x={__e:function(t,e,n,o){for(var l,s,u;e=e.__;)if((l=e.__c)&&!l.__)try{if((s=l.constructor)&&s.getDerivedStateFromError!=null&&(l.setState(s.getDerivedStateFromError(t)),u=l.__d),l.componentDidCatch!=null&&(l.componentDidCatch(t,o||{}),u=l.__d),u)return l.__E=l}catch(c){t=c}throw t}},At=0,Tt=function(t){return t!=null&&t.constructor===void 0},ye.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Q({},this.state),typeof t=="function"&&(t=t(Q({},n),this.props)),t&&Q(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),Mt(this))},ye.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Mt(this))},ye.prototype.render=ae,me=[],Nt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,xt=function(t,e){return t.__v.__b-e.__v.__b},Fe.__r=0,Ot=/(PointerCapture)$|Capture$/i,et=0,tt=Pt(!1),it=Pt(!0);function Ge(){return Ge=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},Ge.apply(this,arguments)}function Wt(t,e){if(t==null)return{};var n,o,l={},s=Object.keys(t);for(o=0;o<s.length;o++)e.indexOf(n=s[o])>=0||(l[n]=t[n]);return l}var Gi=["context","children"],ji=["useFragment"];function Wi(t,e,n,o){function l(){var s,u=Reflect.construct(HTMLElement,[],l);return u._vdomComponent=t,o&&o.shadow?(u._root=u.attachShadow({mode:o.mode||"open",serializable:(s=o.serializable)!=null&&s}),o.adoptedStyleSheets&&(u._root.adoptedStyleSheets=o.adoptedStyleSheets)):u._root=u,u}return(l.prototype=Object.create(HTMLElement.prototype)).constructor=l,l.prototype.connectedCallback=function(){zi.call(this,o)},l.prototype.attributeChangedCallback=qi,l.prototype.disconnectedCallback=Yi,n=n||t.observedAttributes||Object.keys(t.propTypes||{}),l.observedAttributes=n,t.formAssociated&&(l.formAssociated=!0),n.forEach(function(s){Object.defineProperty(l.prototype,s,{get:function(){return this._vdom?this._vdom.props[s]:this._props[s]},set:function(u){this._vdom?this.attributeChangedCallback(s,null,u):(this._props||(this._props={}),this._props[s]=u);var c=typeof u;u!=null&&c!=="string"&&c!=="boolean"&&c!=="number"||this.setAttribute(s,u)}})}),customElements.define(e||t.tagName||t.displayName||t.name,l),l}function Hi(t){this.getChildContext=function(){return t.context};var e=t.children,n=Wt(t,Gi);return jt(e,n)}function zi(t){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=ve(Hi,Ge({},this._props,{context:e.detail.context}),qt(this,this._vdomComponent,t)),(this.hasAttribute("hydrate")?Gt:Ve)(this._vdom,this._root)}function Ht(t){return t.replace(/-(\w)/g,function(e,n){return n?n.toUpperCase():""})}function qi(t,e,n){if(this._vdom){var o={};o[t]=n=n??void 0,o[Ht(t)]=n,this._vdom=jt(this._vdom,o),Ve(this._vdom,this._root)}}function Yi(){Ve(this._vdom=null,this._root)}function zt(t,e){var n=this,o=t.useFragment,l=Wt(t,ji);return ve(o?ae:"slot",Ge({},l,{ref:function(s){s?(n.ref=s,n._listener||(n._listener=function(u){u.stopPropagation(),u.detail.context=e},s.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function qt(t,e,n){if(t.nodeType===3)return t.data;if(t.nodeType!==1)return null;var o=[],l={},s=0,u=t.attributes,c=t.childNodes;for(s=u.length;s--;)u[s].name!=="slot"&&(l[u[s].name]=u[s].value,l[Ht(u[s].name)]=u[s].value);for(s=c.length;s--;){var E=qt(c[s],null,n),p=c[s].slot;p?l[p]=ve(zt,{name:p},E):o[s]=E}var _=!(!n||!n.shadow),d=e?ve(zt,{useFragment:!_},o):o;return!_&&e&&(t.innerHTML=""),ve(e||t.nodeName.toLowerCase(),l,d)}var Ki=0;function w(t,e,n,o,l,s){e||(e={});var u,c,E=e;if("ref"in E)for(c in E={},e)c=="ref"?u=e[c]:E[c]=e[c];var p={type:t,props:E,key:n,ref:u,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ki,__i:-1,__u:0,__source:l,__self:s};if(typeof t=="function"&&(u=t.defaultProps))for(c in u)E[c]===void 0&&(E[c]=u[c]);return x.vnode&&x.vnode(p),p}var Oe,P,at,Yt,ke=0,Kt=[],F=x,Jt=F.__b,Xt=F.__r,Zt=F.diffed,Qt=F.__c,ei=F.unmount,ti=F.__;function lt(t,e){F.__h&&F.__h(P,t,ke||e),ke=0;var n=P.__H||(P.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function je(t){return ke=1,Ji(ri,t)}function Ji(t,e,n){var o=lt(Oe++,2);if(o.t=t,!o.__c&&(o.__=[ri(void 0,e),function(c){var E=o.__N?o.__N[0]:o.__[0],p=o.t(E,c);E!==p&&(o.__N=[p,o.__[1]],o.__c.setState({}))}],o.__c=P,!P.__f)){var l=function(c,E,p){if(!o.__c.__H)return!0;var _=o.__c.__H.__.filter(function(S){return!!S.__c});if(_.every(function(S){return!S.__N}))return!s||s.call(this,c,E,p);var d=o.__c.props!==c;return _.forEach(function(S){if(S.__N){var g=S.__[0];S.__=S.__N,S.__N=void 0,g!==S.__[0]&&(d=!0)}}),s&&s.call(this,c,E,p)||d};P.__f=!0;var s=P.shouldComponentUpdate,u=P.componentWillUpdate;P.componentWillUpdate=function(c,E,p){if(this.__e){var _=s;s=void 0,l(c,E,p),s=_}u&&u.call(this,c,E,p)},P.shouldComponentUpdate=l}return o.__N||o.__}function We(t,e){var n=lt(Oe++,3);!F.__s&&ni(n.__H,e)&&(n.__=t,n.u=e,P.__H.__h.push(n))}function He(t){return ke=5,we(function(){return{current:t}},[])}function we(t,e){var n=lt(Oe++,7);return ni(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function ct(t,e){return ke=8,we(function(){return t},e)}function Xi(){for(var t;t=Kt.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ze),t.__H.__h.forEach(ut),t.__H.__h=[]}catch(e){t.__H.__h=[],F.__e(e,t.__v)}}F.__b=function(t){P=null,Jt&&Jt(t)},F.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),ti&&ti(t,e)},F.__r=function(t){Xt&&Xt(t),Oe=0;var e=(P=t.__c).__H;e&&(at===P?(e.__h=[],P.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(ze),e.__h.forEach(ut),e.__h=[],Oe=0)),at=P},F.diffed=function(t){Zt&&Zt(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Kt.push(e)!==1&&Yt===F.requestAnimationFrame||((Yt=F.requestAnimationFrame)||Zi)(Xi)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),at=P=null},F.__c=function(t,e){e.some(function(n){try{n.__h.forEach(ze),n.__h=n.__h.filter(function(o){return!o.__||ut(o)})}catch(o){e.some(function(l){l.__h&&(l.__h=[])}),e=[],F.__e(o,n.__v)}}),Qt&&Qt(t,e)},F.unmount=function(t){ei&&ei(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{ze(o)}catch(l){e=l}}),n.__H=void 0,e&&F.__e(e,n.__v))};var ii=typeof requestAnimationFrame=="function";function Zi(t){var e,n=function(){clearTimeout(o),ii&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,35);ii&&(e=requestAnimationFrame(n))}function ze(t){var e=P,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),P=e}function ut(t){var e=P;t.__c=t.__(),P=e}function ni(t,e){return!t||t.length!==e.length||e.some(function(n,o){return n!==t[o]})}function ri(t,e){return typeof e=="function"?e(t):e}var Qi=Symbol.for("preact-signals");function qe(){if(le>1)le--;else{for(var t,e=!1;De!==void 0;){var n=De;for(De=void 0,dt++;n!==void 0;){var o=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&ai(n))try{n.c()}catch(l){e||(t=l,e=!0)}n=o}}if(dt=0,le--,e)throw t}}function en(t){if(le>0)return t();le++;try{return t()}finally{qe()}}var O=void 0;function oi(t){var e=O;O=void 0;try{return t()}finally{O=e}}var De=void 0,le=0,dt=0,Ye=0;function si(t){if(O!==void 0){var e=t.n;if(e===void 0||e.t!==O)return e={i:0,S:t,p:O.s,n:void 0,t:O,e:void 0,x:void 0,r:e},O.s!==void 0&&(O.s.n=e),O.s=e,t.n=e,32&O.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=O.s,e.n=void 0,O.s.n=e,O.s=e),e}}function j(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}j.prototype.brand=Qi,j.prototype.h=function(){return!0},j.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:oi(function(){var o;(o=e.W)==null||o.call(e)}))},j.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,o=t.x;n!==void 0&&(n.x=o,t.e=void 0),o!==void 0&&(o.e=n,t.x=void 0),t===this.t&&(this.t=o,o===void 0&&oi(function(){var l;(l=e.Z)==null||l.call(e)}))}},j.prototype.subscribe=function(t){var e=this;return Me(function(){var n=e.value,o=O;O=void 0;try{t(n)}finally{O=o}},{name:"sub"})},j.prototype.valueOf=function(){return this.value},j.prototype.toString=function(){return this.value+""},j.prototype.toJSON=function(){return this.value},j.prototype.peek=function(){var t=O;O=void 0;try{return this.value}finally{O=t}},Object.defineProperty(j.prototype,"value",{get:function(){var t=si(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(dt>100)throw new Error("Cycle detected");this.v=t,this.i++,Ye++,le++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{qe()}}}});function z(t,e){return new j(t,e)}function ai(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function li(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function ci(t){for(var e=t.s,n=void 0;e!==void 0;){var o=e.p;e.i===-1?(e.S.U(e),o!==void 0&&(o.n=e.n),e.n!==void 0&&(e.n.p=o)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=o}t.s=n}function Ee(t,e){j.call(this,void 0),this.x=t,this.s=void 0,this.g=Ye-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}Ee.prototype=new j,Ee.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Ye))return!0;if(this.g=Ye,this.f|=1,this.i>0&&!ai(this))return this.f&=-2,!0;var t=O;try{li(this),O=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return O=t,ci(this),this.f&=-2,!0},Ee.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}j.prototype.S.call(this,t)},Ee.prototype.U=function(t){if(this.t!==void 0&&(j.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}},Ee.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}},Object.defineProperty(Ee.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=si(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function ui(t,e){return new Ee(t,e)}function di(t){var e=t.u;if(t.u=void 0,typeof e=="function"){le++;var n=O;O=void 0;try{e()}catch(o){throw t.f&=-2,t.f|=8,ht(t),o}finally{O=n,qe()}}}function ht(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,di(t)}function tn(t){if(O!==this)throw new Error("Out-of-order effect");ci(this),O=t,this.f&=-2,8&this.f&&ht(this),qe()}function Ce(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}Ce.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}},Ce.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,di(this),li(this),le++;var t=O;return O=this,tn.bind(this,t)},Ce.prototype.N=function(){2&this.f||(this.f|=2,this.o=De,De=this)},Ce.prototype.d=function(){this.f|=8,1&this.f||ht(this)},Ce.prototype.dispose=function(){this.d()};function Me(t,e){var n=new Ce(t,e);try{n.c()}catch(l){throw n.d(),l}var o=n.d.bind(n);return o[Symbol.dispose]=o,o}var hi,ft,nn=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,fi=[];Me(function(){hi=this.N})();function Ie(t,e){x[t]=e.bind(null,x[t]||function(){})}function Ke(t){ft&&ft(),ft=t&&t.S()}function pi(t){var e=this,n=t.data,o=_i(n);o.value=n;var l=we(function(){for(var c=e,E=e.__v;E=E.__;)if(E.__c){E.__c.__$f|=4;break}var p=ui(function(){var g=o.value.value;return g===0?0:g===!0?"":g||""}),_=ui(function(){return!Array.isArray(p.value)&&!Tt(p.value)}),d=Me(function(){if(this.N=mi,_.value){var g=p.value;c.__v&&c.__v.__e&&c.__v.__e.nodeType===3&&(c.__v.__e.data=g)}}),S=e.__$u.d;return e.__$u.d=function(){d(),S.call(this)},[_,p]},[]),s=l[0],u=l[1];return s.value?u.peek():u.value}pi.displayName="ReactiveTextNode",Object.defineProperties(j.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:pi},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Ie("__b",function(t,e){if(typeof e.type=="string"){var n,o=e.props;for(var l in o)if(l!=="children"){var s=o[l];s instanceof j&&(n||(e.__np=n={}),n[l]=s,o[l]=s.peek())}}t(e)}),Ie("__r",function(t,e){if(e.type!==ae){Ke();var n,o=e.__c;o&&(o.__$f&=-2,(n=o.__$u)===void 0&&(o.__$u=n=(function(l,s){var u;return Me(function(){u=this},{name:s}),u.c=l,u})(function(){var l;nn&&((l=n.y)==null||l.call(n)),o.__$f|=1,o.setState({})},typeof e.type=="function"?e.type.displayName||e.type.name:""))),Ke(n)}t(e)}),Ie("__e",function(t,e,n,o){Ke(),t(e,n,o)}),Ie("diffed",function(t,e){Ke();var n;if(typeof e.type=="string"&&(n=e.__e)){var o=e.__np,l=e.props;if(o){var s=n.U;if(s)for(var u in s){var c=s[u];c!==void 0&&!(u in o)&&(c.d(),s[u]=void 0)}else s={},n.U=s;for(var E in o){var p=s[E],_=o[E];p===void 0?(p=rn(n,E,_,l),s[E]=p):p.o(_,l)}}}t(e)});function rn(t,e,n,o){var l=e in t&&t.ownerSVGElement===void 0,s=z(n);return{o:function(u,c){s.value=u,o=c},d:Me(function(){this.N=mi;var u=s.value.value;o[e]!==u&&(o[e]=u,l?t[e]=u:u!=null&&(u!==!1||e[4]==="-")?t.setAttribute(e,u):t.removeAttribute(e))})}}Ie("unmount",function(t,e){if(typeof e.type=="string"){var n=e.__e;if(n){var o=n.U;if(o){n.U=void 0;for(var l in o){var s=o[l];s&&s.d()}}}}else{var u=e.__c;if(u){var c=u.__$u;c&&(u.__$u=void 0,c.d())}}t(e)}),Ie("__h",function(t,e,n,o){(o<3||o===9)&&(e.__$f|=2),t(e,n,o)}),ye.prototype.shouldComponentUpdate=function(t,e){if(this.__R)return!0;var n=this.__$u,o=n&&n.s!==void 0;for(var l in e)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var s=2&this.__$f;if(!(o||s||4&this.__$f)||1&this.__$f)return!0}else if(!(o||4&this.__$f)||3&this.__$f)return!0;for(var u in t)if(u!=="__source"&&t[u]!==this.props[u])return!0;for(var c in this.props)if(!(c in t))return!0;return!1};function _i(t,e){return je(function(){return z(t,e)})[0]}var on=function(t){queueMicrotask(function(){queueMicrotask(t)})};function sn(){en(function(){for(var t;t=fi.shift();)hi.call(t)})}function mi(){fi.push(this)===1&&(x.requestAnimationFrame||on)(sn)}const pt={layout:"floating",initialState:"expanded",position:"bottom-right",showCaptions:!1,showTextInput:!0,showMuteButton:!0,removeWatermark:!1,callToAction:"Talk to our assistant"},Je={"bottom-right":{bottom:"24px",right:"24px"},"bottom-left":{bottom:"24px",left:"24px"},"top-right":{top:"24px",right:"24px"},"top-left":{top:"24px",left:"24px"}},an=new Set(["top","right","bottom","left","margin","margin-top","margin-right","margin-bottom","margin-left"]);function ln(t){if(Je[t])return Je[t];const e=t.match(/^\[(.+)\]$/);if(!e)return Je["bottom-right"];const n={};for(const o of e[1].split(",")){const l=o.trim(),s=l.lastIndexOf("-");if(s<=0)continue;const u=l.slice(0,s);if(!an.has(u))continue;const c=l.slice(s+1);/^[\w.%-]+$/.test(c)&&(n[u]=/^\d+$/.test(c)?`${c}px`:c)}return Object.keys(n).length>0?n:Je["bottom-right"]}var _t={},Ue={},Ei;function cn(){if(Ei)return Ue;Ei=1,Ue.byteLength=c,Ue.toByteArray=p,Ue.fromByteArray=S;for(var t=[],e=[],n=typeof Uint8Array<"u"?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,s=o.length;l<s;++l)t[l]=o[l],e[o.charCodeAt(l)]=l;e[45]=62,e[95]=63;function u(g){var y=g.length;if(y%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var C=g.indexOf("=");C===-1&&(C=y);var A=C===y?0:4-C%4;return[C,A]}function c(g){var y=u(g),C=y[0],A=y[1];return(C+A)*3/4-A}function E(g,y,C){return(y+C)*3/4-C}function p(g){var y,C=u(g),A=C[0],I=C[1],b=new n(E(g,A,I)),N=0,M=I>0?A-4:A,k;for(k=0;k<M;k+=4)y=e[g.charCodeAt(k)]<<18|e[g.charCodeAt(k+1)]<<12|e[g.charCodeAt(k+2)]<<6|e[g.charCodeAt(k+3)],b[N++]=y>>16&255,b[N++]=y>>8&255,b[N++]=y&255;return I===2&&(y=e[g.charCodeAt(k)]<<2|e[g.charCodeAt(k+1)]>>4,b[N++]=y&255),I===1&&(y=e[g.charCodeAt(k)]<<10|e[g.charCodeAt(k+1)]<<4|e[g.charCodeAt(k+2)]>>2,b[N++]=y>>8&255,b[N++]=y&255),b}function _(g){return t[g>>18&63]+t[g>>12&63]+t[g>>6&63]+t[g&63]}function d(g,y,C){for(var A,I=[],b=y;b<C;b+=3)A=(g[b]<<16&16711680)+(g[b+1]<<8&65280)+(g[b+2]&255),I.push(_(A));return I.join("")}function S(g){for(var y,C=g.length,A=C%3,I=[],b=16383,N=0,M=C-A;N<M;N+=b)I.push(d(g,N,N+b>M?M:N+b));return A===1?(y=g[C-1],I.push(t[y>>2]+t[y<<4&63]+"==")):A===2&&(y=(g[C-2]<<8)+g[C-1],I.push(t[y>>10]+t[y>>4&63]+t[y<<2&63]+"=")),I.join("")}return Ue}var Xe={};var gi;function un(){return gi||(gi=1,Xe.read=function(t,e,n,o,l){var s,u,c=l*8-o-1,E=(1<<c)-1,p=E>>1,_=-7,d=n?l-1:0,S=n?-1:1,g=t[e+d];for(d+=S,s=g&(1<<-_)-1,g>>=-_,_+=c;_>0;s=s*256+t[e+d],d+=S,_-=8);for(u=s&(1<<-_)-1,s>>=-_,_+=o;_>0;u=u*256+t[e+d],d+=S,_-=8);if(s===0)s=1-p;else{if(s===E)return u?NaN:(g?-1:1)*(1/0);u=u+Math.pow(2,o),s=s-p}return(g?-1:1)*u*Math.pow(2,s-o)},Xe.write=function(t,e,n,o,l,s){var u,c,E,p=s*8-l-1,_=(1<<p)-1,d=_>>1,S=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=o?0:s-1,y=o?1:-1,C=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,u=_):(u=Math.floor(Math.log(e)/Math.LN2),e*(E=Math.pow(2,-u))<1&&(u--,E*=2),u+d>=1?e+=S/E:e+=S*Math.pow(2,1-d),e*E>=2&&(u++,E/=2),u+d>=_?(c=0,u=_):u+d>=1?(c=(e*E-1)*Math.pow(2,l),u=u+d):(c=e*Math.pow(2,d-1)*Math.pow(2,l),u=0));l>=8;t[n+g]=c&255,g+=y,c/=256,l-=8);for(u=u<<l|c,p+=l;p>0;t[n+g]=u&255,g+=y,u/=256,p-=8);t[n+g-y]|=C*128}),Xe}var vi;function dn(){return vi||(vi=1,(function(t){const e=cn(),n=un(),o=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=c,t.SlowBuffer=b,t.INSPECT_MAX_BYTES=50;const l=2147483647;t.kMaxLength=l,c.TYPED_ARRAY_SUPPORT=s(),!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function s(){try{const a=new Uint8Array(1),i={foo:function(){return 42}};return Object.setPrototypeOf(i,Uint8Array.prototype),Object.setPrototypeOf(a,i),a.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function u(a){if(a>l)throw new RangeError('The value "'+a+'" is invalid for option "size"');const i=new Uint8Array(a);return Object.setPrototypeOf(i,c.prototype),i}function c(a,i,r){if(typeof a=="number"){if(typeof i=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(a)}return E(a,i,r)}c.poolSize=8192;function E(a,i,r){if(typeof a=="string")return S(a,i);if(ArrayBuffer.isView(a))return y(a);if(a==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a);if(ee(a,ArrayBuffer)||a&&ee(a.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ee(a,SharedArrayBuffer)||a&&ee(a.buffer,SharedArrayBuffer)))return C(a,i,r);if(typeof a=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const h=a.valueOf&&a.valueOf();if(h!=null&&h!==a)return c.from(h,i,r);const f=A(a);if(f)return f;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof a[Symbol.toPrimitive]=="function")return c.from(a[Symbol.toPrimitive]("string"),i,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a)}c.from=function(a,i,r){return E(a,i,r)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array);function p(a){if(typeof a!="number")throw new TypeError('"size" argument must be of type number');if(a<0)throw new RangeError('The value "'+a+'" is invalid for option "size"')}function _(a,i,r){return p(a),a<=0?u(a):i!==void 0?typeof r=="string"?u(a).fill(i,r):u(a).fill(i):u(a)}c.alloc=function(a,i,r){return _(a,i,r)};function d(a){return p(a),u(a<0?0:I(a)|0)}c.allocUnsafe=function(a){return d(a)},c.allocUnsafeSlow=function(a){return d(a)};function S(a,i){if((typeof i!="string"||i==="")&&(i="utf8"),!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i);const r=N(a,i)|0;let h=u(r);const f=h.write(a,i);return f!==r&&(h=h.slice(0,f)),h}function g(a){const i=a.length<0?0:I(a.length)|0,r=u(i);for(let h=0;h<i;h+=1)r[h]=a[h]&255;return r}function y(a){if(ee(a,Uint8Array)){const i=new Uint8Array(a);return C(i.buffer,i.byteOffset,i.byteLength)}return g(a)}function C(a,i,r){if(i<0||a.byteLength<i)throw new RangeError('"offset" is outside of buffer bounds');if(a.byteLength<i+(r||0))throw new RangeError('"length" is outside of buffer bounds');let h;return i===void 0&&r===void 0?h=new Uint8Array(a):r===void 0?h=new Uint8Array(a,i):h=new Uint8Array(a,i,r),Object.setPrototypeOf(h,c.prototype),h}function A(a){if(c.isBuffer(a)){const i=I(a.length)|0,r=u(i);return r.length===0||a.copy(r,0,0,i),r}if(a.length!==void 0)return typeof a.length!="number"||bt(a.length)?u(0):g(a);if(a.type==="Buffer"&&Array.isArray(a.data))return g(a.data)}function I(a){if(a>=l)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+l.toString(16)+" bytes");return a|0}function b(a){return+a!=a&&(a=0),c.alloc(+a)}c.isBuffer=function(i){return i!=null&&i._isBuffer===!0&&i!==c.prototype},c.compare=function(i,r){if(ee(i,Uint8Array)&&(i=c.from(i,i.offset,i.byteLength)),ee(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),!c.isBuffer(i)||!c.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(i===r)return 0;let h=i.length,f=r.length;for(let m=0,v=Math.min(h,f);m<v;++m)if(i[m]!==r[m]){h=i[m],f=r[m];break}return h<f?-1:f<h?1:0},c.isEncoding=function(i){switch(String(i).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(i,r){if(!Array.isArray(i))throw new TypeError('"list" argument must be an Array of Buffers');if(i.length===0)return c.alloc(0);let h;if(r===void 0)for(r=0,h=0;h<i.length;++h)r+=i[h].length;const f=c.allocUnsafe(r);let m=0;for(h=0;h<i.length;++h){let v=i[h];if(ee(v,Uint8Array))m+v.length>f.length?(c.isBuffer(v)||(v=c.from(v)),v.copy(f,m)):Uint8Array.prototype.set.call(f,v,m);else if(c.isBuffer(v))v.copy(f,m);else throw new TypeError('"list" argument must be an Array of Buffers');m+=v.length}return f};function N(a,i){if(c.isBuffer(a))return a.length;if(ArrayBuffer.isView(a)||ee(a,ArrayBuffer))return a.byteLength;if(typeof a!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof a);const r=a.length,h=arguments.length>2&&arguments[2]===!0;if(!h&&r===0)return 0;let f=!1;for(;;)switch(i){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return It(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Li(a).length;default:if(f)return h?-1:It(a).length;i=(""+i).toLowerCase(),f=!0}}c.byteLength=N;function M(a,i,r){let h=!1;if((i===void 0||i<0)&&(i=0),i>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,i>>>=0,r<=i))return"";for(a||(a="utf8");;)switch(a){case"hex":return _r(this,i,r);case"utf8":case"utf-8":return Ti(this,i,r);case"ascii":return fr(this,i,r);case"latin1":case"binary":return pr(this,i,r);case"base64":return dr(this,i,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mr(this,i,r);default:if(h)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),h=!0}}c.prototype._isBuffer=!0;function k(a,i,r){const h=a[i];a[i]=a[r],a[r]=h}c.prototype.swap16=function(){const i=this.length;if(i%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<i;r+=2)k(this,r,r+1);return this},c.prototype.swap32=function(){const i=this.length;if(i%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<i;r+=4)k(this,r,r+3),k(this,r+1,r+2);return this},c.prototype.swap64=function(){const i=this.length;if(i%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<i;r+=8)k(this,r,r+7),k(this,r+1,r+6),k(this,r+2,r+5),k(this,r+3,r+4);return this},c.prototype.toString=function(){const i=this.length;return i===0?"":arguments.length===0?Ti(this,0,i):M.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(i){if(!c.isBuffer(i))throw new TypeError("Argument must be a Buffer");return this===i?!0:c.compare(this,i)===0},c.prototype.inspect=function(){let i="";const r=t.INSPECT_MAX_BYTES;return i=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(i+=" ... "),"<Buffer "+i+">"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(i,r,h,f,m){if(ee(i,Uint8Array)&&(i=c.from(i,i.offset,i.byteLength)),!c.isBuffer(i))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof i);if(r===void 0&&(r=0),h===void 0&&(h=i?i.length:0),f===void 0&&(f=0),m===void 0&&(m=this.length),r<0||h>i.length||f<0||m>this.length)throw new RangeError("out of range index");if(f>=m&&r>=h)return 0;if(f>=m)return-1;if(r>=h)return 1;if(r>>>=0,h>>>=0,f>>>=0,m>>>=0,this===i)return 0;let v=m-f,T=h-r;const L=Math.min(v,T),U=this.slice(f,m),B=i.slice(r,h);for(let D=0;D<L;++D)if(U[D]!==B[D]){v=U[D],T=B[D];break}return v<T?-1:T<v?1:0};function Y(a,i,r,h,f){if(a.length===0)return-1;if(typeof r=="string"?(h=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,bt(r)&&(r=f?0:a.length-1),r<0&&(r=a.length+r),r>=a.length){if(f)return-1;r=a.length-1}else if(r<0)if(f)r=0;else return-1;if(typeof i=="string"&&(i=c.from(i,h)),c.isBuffer(i))return i.length===0?-1:ne(a,i,r,h,f);if(typeof i=="number")return i=i&255,typeof Uint8Array.prototype.indexOf=="function"?f?Uint8Array.prototype.indexOf.call(a,i,r):Uint8Array.prototype.lastIndexOf.call(a,i,r):ne(a,[i],r,h,f);throw new TypeError("val must be string, number or Buffer")}function ne(a,i,r,h,f){let m=1,v=a.length,T=i.length;if(h!==void 0&&(h=String(h).toLowerCase(),h==="ucs2"||h==="ucs-2"||h==="utf16le"||h==="utf-16le")){if(a.length<2||i.length<2)return-1;m=2,v/=2,T/=2,r/=2}function L(B,D){return m===1?B[D]:B.readUInt16BE(D*m)}let U;if(f){let B=-1;for(U=r;U<v;U++)if(L(a,U)===L(i,B===-1?0:U-B)){if(B===-1&&(B=U),U-B+1===T)return B*m}else B!==-1&&(U-=U-B),B=-1}else for(r+T>v&&(r=v-T),U=r;U>=0;U--){let B=!0;for(let D=0;D<T;D++)if(L(a,U+D)!==L(i,D)){B=!1;break}if(B)return U}return-1}c.prototype.includes=function(i,r,h){return this.indexOf(i,r,h)!==-1},c.prototype.indexOf=function(i,r,h){return Y(this,i,r,h,!0)},c.prototype.lastIndexOf=function(i,r,h){return Y(this,i,r,h,!1)};function V(a,i,r,h){r=Number(r)||0;const f=a.length-r;h?(h=Number(h),h>f&&(h=f)):h=f;const m=i.length;h>m/2&&(h=m/2);let v;for(v=0;v<h;++v){const T=parseInt(i.substr(v*2,2),16);if(bt(T))return v;a[r+v]=T}return v}function re(a,i,r,h){return Qe(It(i,a.length-r),a,r,h)}function oe(a,i,r,h){return Qe(yr(i),a,r,h)}function Z(a,i,r,h){return Qe(Li(i),a,r,h)}function pe(a,i,r,h){return Qe(Sr(i,a.length-r),a,r,h)}c.prototype.write=function(i,r,h,f){if(r===void 0)f="utf8",h=this.length,r=0;else if(h===void 0&&typeof r=="string")f=r,h=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(h)?(h=h>>>0,f===void 0&&(f="utf8")):(f=h,h=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const m=this.length-r;if((h===void 0||h>m)&&(h=m),i.length>0&&(h<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");f||(f="utf8");let v=!1;for(;;)switch(f){case"hex":return V(this,i,r,h);case"utf8":case"utf-8":return re(this,i,r,h);case"ascii":case"latin1":case"binary":return oe(this,i,r,h);case"base64":return Z(this,i,r,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,i,r,h);default:if(v)throw new TypeError("Unknown encoding: "+f);f=(""+f).toLowerCase(),v=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function dr(a,i,r){return i===0&&r===a.length?e.fromByteArray(a):e.fromByteArray(a.slice(i,r))}function Ti(a,i,r){r=Math.min(a.length,r);const h=[];let f=i;for(;f<r;){const m=a[f];let v=null,T=m>239?4:m>223?3:m>191?2:1;if(f+T<=r){let L,U,B,D;switch(T){case 1:m<128&&(v=m);break;case 2:L=a[f+1],(L&192)===128&&(D=(m&31)<<6|L&63,D>127&&(v=D));break;case 3:L=a[f+1],U=a[f+2],(L&192)===128&&(U&192)===128&&(D=(m&15)<<12|(L&63)<<6|U&63,D>2047&&(D<55296||D>57343)&&(v=D));break;case 4:L=a[f+1],U=a[f+2],B=a[f+3],(L&192)===128&&(U&192)===128&&(B&192)===128&&(D=(m&15)<<18|(L&63)<<12|(U&63)<<6|B&63,D>65535&&D<1114112&&(v=D))}}v===null?(v=65533,T=1):v>65535&&(v-=65536,h.push(v>>>10&1023|55296),v=56320|v&1023),h.push(v),f+=T}return hr(h)}const Ri=4096;function hr(a){const i=a.length;if(i<=Ri)return String.fromCharCode.apply(String,a);let r="",h=0;for(;h<i;)r+=String.fromCharCode.apply(String,a.slice(h,h+=Ri));return r}function fr(a,i,r){let h="";r=Math.min(a.length,r);for(let f=i;f<r;++f)h+=String.fromCharCode(a[f]&127);return h}function pr(a,i,r){let h="";r=Math.min(a.length,r);for(let f=i;f<r;++f)h+=String.fromCharCode(a[f]);return h}function _r(a,i,r){const h=a.length;(!i||i<0)&&(i=0),(!r||r<0||r>h)&&(r=h);let f="";for(let m=i;m<r;++m)f+=wr[a[m]];return f}function mr(a,i,r){const h=a.slice(i,r);let f="";for(let m=0;m<h.length-1;m+=2)f+=String.fromCharCode(h[m]+h[m+1]*256);return f}c.prototype.slice=function(i,r){const h=this.length;i=~~i,r=r===void 0?h:~~r,i<0?(i+=h,i<0&&(i=0)):i>h&&(i=h),r<0?(r+=h,r<0&&(r=0)):r>h&&(r=h),r<i&&(r=i);const f=this.subarray(i,r);return Object.setPrototypeOf(f,c.prototype),f};function G(a,i,r){if(a%1!==0||a<0)throw new RangeError("offset is not uint");if(a+i>r)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(i,r,h){i=i>>>0,r=r>>>0,h||G(i,r,this.length);let f=this[i],m=1,v=0;for(;++v<r&&(m*=256);)f+=this[i+v]*m;return f},c.prototype.readUintBE=c.prototype.readUIntBE=function(i,r,h){i=i>>>0,r=r>>>0,h||G(i,r,this.length);let f=this[i+--r],m=1;for(;r>0&&(m*=256);)f+=this[i+--r]*m;return f},c.prototype.readUint8=c.prototype.readUInt8=function(i,r){return i=i>>>0,r||G(i,1,this.length),this[i]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(i,r){return i=i>>>0,r||G(i,2,this.length),this[i]|this[i+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(i,r){return i=i>>>0,r||G(i,2,this.length),this[i]<<8|this[i+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(i,r){return i=i>>>0,r||G(i,4,this.length),(this[i]|this[i+1]<<8|this[i+2]<<16)+this[i+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(i,r){return i=i>>>0,r||G(i,4,this.length),this[i]*16777216+(this[i+1]<<16|this[i+2]<<8|this[i+3])},c.prototype.readBigUInt64LE=_e(function(i){i=i>>>0,Re(i,"offset");const r=this[i],h=this[i+7];(r===void 0||h===void 0)&&Be(i,this.length-8);const f=r+this[++i]*2**8+this[++i]*2**16+this[++i]*2**24,m=this[++i]+this[++i]*2**8+this[++i]*2**16+h*2**24;return BigInt(f)+(BigInt(m)<<BigInt(32))}),c.prototype.readBigUInt64BE=_e(function(i){i=i>>>0,Re(i,"offset");const r=this[i],h=this[i+7];(r===void 0||h===void 0)&&Be(i,this.length-8);const f=r*2**24+this[++i]*2**16+this[++i]*2**8+this[++i],m=this[++i]*2**24+this[++i]*2**16+this[++i]*2**8+h;return(BigInt(f)<<BigInt(32))+BigInt(m)}),c.prototype.readIntLE=function(i,r,h){i=i>>>0,r=r>>>0,h||G(i,r,this.length);let f=this[i],m=1,v=0;for(;++v<r&&(m*=256);)f+=this[i+v]*m;return m*=128,f>=m&&(f-=Math.pow(2,8*r)),f},c.prototype.readIntBE=function(i,r,h){i=i>>>0,r=r>>>0,h||G(i,r,this.length);let f=r,m=1,v=this[i+--f];for(;f>0&&(m*=256);)v+=this[i+--f]*m;return m*=128,v>=m&&(v-=Math.pow(2,8*r)),v},c.prototype.readInt8=function(i,r){return i=i>>>0,r||G(i,1,this.length),this[i]&128?(255-this[i]+1)*-1:this[i]},c.prototype.readInt16LE=function(i,r){i=i>>>0,r||G(i,2,this.length);const h=this[i]|this[i+1]<<8;return h&32768?h|4294901760:h},c.prototype.readInt16BE=function(i,r){i=i>>>0,r||G(i,2,this.length);const h=this[i+1]|this[i]<<8;return h&32768?h|4294901760:h},c.prototype.readInt32LE=function(i,r){return i=i>>>0,r||G(i,4,this.length),this[i]|this[i+1]<<8|this[i+2]<<16|this[i+3]<<24},c.prototype.readInt32BE=function(i,r){return i=i>>>0,r||G(i,4,this.length),this[i]<<24|this[i+1]<<16|this[i+2]<<8|this[i+3]},c.prototype.readBigInt64LE=_e(function(i){i=i>>>0,Re(i,"offset");const r=this[i],h=this[i+7];(r===void 0||h===void 0)&&Be(i,this.length-8);const f=this[i+4]+this[i+5]*2**8+this[i+6]*2**16+(h<<24);return(BigInt(f)<<BigInt(32))+BigInt(r+this[++i]*2**8+this[++i]*2**16+this[++i]*2**24)}),c.prototype.readBigInt64BE=_e(function(i){i=i>>>0,Re(i,"offset");const r=this[i],h=this[i+7];(r===void 0||h===void 0)&&Be(i,this.length-8);const f=(r<<24)+this[++i]*2**16+this[++i]*2**8+this[++i];return(BigInt(f)<<BigInt(32))+BigInt(this[++i]*2**24+this[++i]*2**16+this[++i]*2**8+h)}),c.prototype.readFloatLE=function(i,r){return i=i>>>0,r||G(i,4,this.length),n.read(this,i,!0,23,4)},c.prototype.readFloatBE=function(i,r){return i=i>>>0,r||G(i,4,this.length),n.read(this,i,!1,23,4)},c.prototype.readDoubleLE=function(i,r){return i=i>>>0,r||G(i,8,this.length),n.read(this,i,!0,52,8)},c.prototype.readDoubleBE=function(i,r){return i=i>>>0,r||G(i,8,this.length),n.read(this,i,!1,52,8)};function K(a,i,r,h,f,m){if(!c.isBuffer(a))throw new TypeError('"buffer" argument must be a Buffer instance');if(i>f||i<m)throw new RangeError('"value" argument is out of bounds');if(r+h>a.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(i,r,h,f){if(i=+i,r=r>>>0,h=h>>>0,!f){const T=Math.pow(2,8*h)-1;K(this,i,r,h,T,0)}let m=1,v=0;for(this[r]=i&255;++v<h&&(m*=256);)this[r+v]=i/m&255;return r+h},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(i,r,h,f){if(i=+i,r=r>>>0,h=h>>>0,!f){const T=Math.pow(2,8*h)-1;K(this,i,r,h,T,0)}let m=h-1,v=1;for(this[r+m]=i&255;--m>=0&&(v*=256);)this[r+m]=i/v&255;return r+h},c.prototype.writeUint8=c.prototype.writeUInt8=function(i,r,h){return i=+i,r=r>>>0,h||K(this,i,r,1,255,0),this[r]=i&255,r+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(i,r,h){return i=+i,r=r>>>0,h||K(this,i,r,2,65535,0),this[r]=i&255,this[r+1]=i>>>8,r+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(i,r,h){return i=+i,r=r>>>0,h||K(this,i,r,2,65535,0),this[r]=i>>>8,this[r+1]=i&255,r+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(i,r,h){return i=+i,r=r>>>0,h||K(this,i,r,4,4294967295,0),this[r+3]=i>>>24,this[r+2]=i>>>16,this[r+1]=i>>>8,this[r]=i&255,r+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(i,r,h){return i=+i,r=r>>>0,h||K(this,i,r,4,4294967295,0),this[r]=i>>>24,this[r+1]=i>>>16,this[r+2]=i>>>8,this[r+3]=i&255,r+4};function Ni(a,i,r,h,f){Ui(i,h,f,a,r,7);let m=Number(i&BigInt(4294967295));a[r++]=m,m=m>>8,a[r++]=m,m=m>>8,a[r++]=m,m=m>>8,a[r++]=m;let v=Number(i>>BigInt(32)&BigInt(4294967295));return a[r++]=v,v=v>>8,a[r++]=v,v=v>>8,a[r++]=v,v=v>>8,a[r++]=v,r}function xi(a,i,r,h,f){Ui(i,h,f,a,r,7);let m=Number(i&BigInt(4294967295));a[r+7]=m,m=m>>8,a[r+6]=m,m=m>>8,a[r+5]=m,m=m>>8,a[r+4]=m;let v=Number(i>>BigInt(32)&BigInt(4294967295));return a[r+3]=v,v=v>>8,a[r+2]=v,v=v>>8,a[r+1]=v,v=v>>8,a[r]=v,r+8}c.prototype.writeBigUInt64LE=_e(function(i,r=0){return Ni(this,i,r,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=_e(function(i,r=0){return xi(this,i,r,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(i,r,h,f){if(i=+i,r=r>>>0,!f){const L=Math.pow(2,8*h-1);K(this,i,r,h,L-1,-L)}let m=0,v=1,T=0;for(this[r]=i&255;++m<h&&(v*=256);)i<0&&T===0&&this[r+m-1]!==0&&(T=1),this[r+m]=(i/v>>0)-T&255;return r+h},c.prototype.writeIntBE=function(i,r,h,f){if(i=+i,r=r>>>0,!f){const L=Math.pow(2,8*h-1);K(this,i,r,h,L-1,-L)}let m=h-1,v=1,T=0;for(this[r+m]=i&255;--m>=0&&(v*=256);)i<0&&T===0&&this[r+m+1]!==0&&(T=1),this[r+m]=(i/v>>0)-T&255;return r+h},c.prototype.writeInt8=function(i,r,h){return i=+i,r=r>>>0,h||K(this,i,r,1,127,-128),i<0&&(i=255+i+1),this[r]=i&255,r+1},c.prototype.writeInt16LE=function(i,r,h){return i=+i,r=r>>>0,h||K(this,i,r,2,32767,-32768),this[r]=i&255,this[r+1]=i>>>8,r+2},c.prototype.writeInt16BE=function(i,r,h){return i=+i,r=r>>>0,h||K(this,i,r,2,32767,-32768),this[r]=i>>>8,this[r+1]=i&255,r+2},c.prototype.writeInt32LE=function(i,r,h){return i=+i,r=r>>>0,h||K(this,i,r,4,2147483647,-2147483648),this[r]=i&255,this[r+1]=i>>>8,this[r+2]=i>>>16,this[r+3]=i>>>24,r+4},c.prototype.writeInt32BE=function(i,r,h){return i=+i,r=r>>>0,h||K(this,i,r,4,2147483647,-2147483648),i<0&&(i=4294967295+i+1),this[r]=i>>>24,this[r+1]=i>>>16,this[r+2]=i>>>8,this[r+3]=i&255,r+4},c.prototype.writeBigInt64LE=_e(function(i,r=0){return Ni(this,i,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=_e(function(i,r=0){return xi(this,i,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Oi(a,i,r,h,f,m){if(r+h>a.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ki(a,i,r,h,f){return i=+i,r=r>>>0,f||Oi(a,i,r,4),n.write(a,i,r,h,23,4),r+4}c.prototype.writeFloatLE=function(i,r,h){return ki(this,i,r,!0,h)},c.prototype.writeFloatBE=function(i,r,h){return ki(this,i,r,!1,h)};function Di(a,i,r,h,f){return i=+i,r=r>>>0,f||Oi(a,i,r,8),n.write(a,i,r,h,52,8),r+8}c.prototype.writeDoubleLE=function(i,r,h){return Di(this,i,r,!0,h)},c.prototype.writeDoubleBE=function(i,r,h){return Di(this,i,r,!1,h)},c.prototype.copy=function(i,r,h,f){if(!c.isBuffer(i))throw new TypeError("argument should be a Buffer");if(h||(h=0),!f&&f!==0&&(f=this.length),r>=i.length&&(r=i.length),r||(r=0),f>0&&f<h&&(f=h),f===h||i.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(h<0||h>=this.length)throw new RangeError("Index out of range");if(f<0)throw new RangeError("sourceEnd out of bounds");f>this.length&&(f=this.length),i.length-r<f-h&&(f=i.length-r+h);const m=f-h;return this===i&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,h,f):Uint8Array.prototype.set.call(i,this.subarray(h,f),r),m},c.prototype.fill=function(i,r,h,f){if(typeof i=="string"){if(typeof r=="string"?(f=r,r=0,h=this.length):typeof h=="string"&&(f=h,h=this.length),f!==void 0&&typeof f!="string")throw new TypeError("encoding must be a string");if(typeof f=="string"&&!c.isEncoding(f))throw new TypeError("Unknown encoding: "+f);if(i.length===1){const v=i.charCodeAt(0);(f==="utf8"&&v<128||f==="latin1")&&(i=v)}}else typeof i=="number"?i=i&255:typeof i=="boolean"&&(i=Number(i));if(r<0||this.length<r||this.length<h)throw new RangeError("Out of range index");if(h<=r)return this;r=r>>>0,h=h===void 0?this.length:h>>>0,i||(i=0);let m;if(typeof i=="number")for(m=r;m<h;++m)this[m]=i;else{const v=c.isBuffer(i)?i:c.from(i,f),T=v.length;if(T===0)throw new TypeError('The value "'+i+'" is invalid for argument "value"');for(m=0;m<h-r;++m)this[m+r]=v[m%T]}return this};const Te={};function Ct(a,i,r){Te[a]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:i.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${a}]`,this.stack,delete this.name}get code(){return a}set code(f){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:f,writable:!0})}toString(){return`${this.name} [${a}]: ${this.message}`}}}Ct("ERR_BUFFER_OUT_OF_BOUNDS",function(a){return a?`${a} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ct("ERR_INVALID_ARG_TYPE",function(a,i){return`The "${a}" argument must be of type number. Received type ${typeof i}`},TypeError),Ct("ERR_OUT_OF_RANGE",function(a,i,r){let h=`The value of "${a}" is out of range.`,f=r;return Number.isInteger(r)&&Math.abs(r)>2**32?f=Mi(String(r)):typeof r=="bigint"&&(f=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(f=Mi(f)),f+="n"),h+=` It must be ${i}. Received ${f}`,h},RangeError);function Mi(a){let i="",r=a.length;const h=a[0]==="-"?1:0;for(;r>=h+4;r-=3)i=`_${a.slice(r-3,r)}${i}`;return`${a.slice(0,r)}${i}`}function Er(a,i,r){Re(i,"offset"),(a[i]===void 0||a[i+r]===void 0)&&Be(i,a.length-(r+1))}function Ui(a,i,r,h,f,m){if(a>r||a<i){const v=typeof i=="bigint"?"n":"";let T;throw i===0||i===BigInt(0)?T=`>= 0${v} and < 2${v} ** ${(m+1)*8}${v}`:T=`>= -(2${v} ** ${(m+1)*8-1}${v}) and < 2 ** ${(m+1)*8-1}${v}`,new Te.ERR_OUT_OF_RANGE("value",T,a)}Er(h,f,m)}function Re(a,i){if(typeof a!="number")throw new Te.ERR_INVALID_ARG_TYPE(i,"number",a)}function Be(a,i,r){throw Math.floor(a)!==a?(Re(a,r),new Te.ERR_OUT_OF_RANGE("offset","an integer",a)):i<0?new Te.ERR_BUFFER_OUT_OF_BOUNDS:new Te.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${i}`,a)}const gr=/[^+/0-9A-Za-z-_]/g;function vr(a){if(a=a.split("=")[0],a=a.trim().replace(gr,""),a.length<2)return"";for(;a.length%4!==0;)a=a+"=";return a}function It(a,i){i=i||1/0;let r;const h=a.length;let f=null;const m=[];for(let v=0;v<h;++v){if(r=a.charCodeAt(v),r>55295&&r<57344){if(!f){if(r>56319){(i-=3)>-1&&m.push(239,191,189);continue}else if(v+1===h){(i-=3)>-1&&m.push(239,191,189);continue}f=r;continue}if(r<56320){(i-=3)>-1&&m.push(239,191,189),f=r;continue}r=(f-55296<<10|r-56320)+65536}else f&&(i-=3)>-1&&m.push(239,191,189);if(f=null,r<128){if((i-=1)<0)break;m.push(r)}else if(r<2048){if((i-=2)<0)break;m.push(r>>6|192,r&63|128)}else if(r<65536){if((i-=3)<0)break;m.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((i-=4)<0)break;m.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return m}function yr(a){const i=[];for(let r=0;r<a.length;++r)i.push(a.charCodeAt(r)&255);return i}function Sr(a,i){let r,h,f;const m=[];for(let v=0;v<a.length&&!((i-=2)<0);++v)r=a.charCodeAt(v),h=r>>8,f=r%256,m.push(f),m.push(h);return m}function Li(a){return e.toByteArray(vr(a))}function Qe(a,i,r,h){let f;for(f=0;f<h&&!(f+r>=i.length||f>=a.length);++f)i[f+r]=a[f];return f}function ee(a,i){return a instanceof i||a!=null&&a.constructor!=null&&a.constructor.name!=null&&a.constructor.name===i.name}function bt(a){return a!==a}const wr=(function(){const a="0123456789abcdef",i=new Array(256);for(let r=0;r<16;++r){const h=r*16;for(let f=0;f<16;++f)i[h+f]=a[r]+a[f]}return i})();function _e(a){return typeof BigInt>"u"?Cr:a}function Cr(){throw new Error("BigInt not supported")}})(_t)),_t}var hn=dn();const fn="https://api.anam.ai",pn="/v1",yi={client:"js-sdk",version:"4.8.0"};var _n=function(t,e,n,o){function l(s){return s instanceof n?s:new n(function(u){u(s)})}return new(n||(n=Promise))(function(s,u){function c(_){try{p(o.next(_))}catch(d){u(d)}}function E(_){try{p(o.throw(_))}catch(d){u(d)}}function p(_){_.done?s(_.value):l(_.value).then(c,E)}p((o=o.apply(t,e||[])).next())})};const Si="https://api.anam.ai",mt="/v1";var ie;(function(t){t.CLIENT_METRIC_MEASUREMENT_ERROR="client_error",t.CLIENT_METRIC_MEASUREMENT_CONNECTION_CLOSED="client_connection_closed",t.CLIENT_METRIC_MEASUREMENT_CONNECTION_ESTABLISHED="client_connection_established",t.CLIENT_METRIC_MEASUREMENT_SESSION_ATTEMPT="client_session_attempt",t.CLIENT_METRIC_MEASUREMENT_SESSION_SUCCESS="client_session_success"})(ie||(ie={}));let Et=Si,wi=mt,ce,Ci=!1;const mn=(t,e=mt)=>{Et=t,wi=e},En=t=>{ce=t},gn=t=>{Ci=t};let ue={sessionId:null,organizationId:null,attemptCorrelationId:null};const be=t=>{ue=Object.assign(Object.assign({},ue),t)},ge=(t,e,n)=>_n(void 0,void 0,void 0,function*(){if(!Ci)try{const o=Object.assign(Object.assign({},yi),n);ue.sessionId&&(o.sessionId=ue.sessionId),ue.organizationId&&(o.organizationId=ue.organizationId),ue.attemptCorrelationId&&(o.attemptCorrelationId=ue.attemptCorrelationId);const l=`${wi}/metrics/client`;let s,u={"Content-Type":"application/json"};ce?.enabled&&ce?.baseUrl?(s=`${ce.baseUrl}${l}`,u["X-Anam-Target-Url"]=`${Et}${l}`):s=`${Et}${l}`,yield fetch(s,{method:"POST",headers:u,body:JSON.stringify({name:t,value:e,tags:o})})}catch(o){console.error("Failed to send error metric:",o)}}),vn=(t,e="console")=>{var n,o,l;const s={};t.forEach(d=>{s[d.type]||(s[d.type]=[]),s[d.type].push(d)});const u={issues:[]},c=((n=s["inbound-rtp"])===null||n===void 0?void 0:n.filter(d=>d.kind==="video"))||[];c.length>0&&(u.personaVideoStream=[],c.forEach(d=>{var S,g,y,C,A;const I={framesReceived:(S=d.framesReceived)!==null&&S!==void 0?S:"unknown",framesDropped:(g=d.framesDropped)!==null&&g!==void 0?g:"unknown",framesPerSecond:(y=d.framesPerSecond)!==null&&y!==void 0?y:"unknown",packetsReceived:(C=d.packetsReceived)!==null&&C!==void 0?C:"unknown",packetsLost:(A=d.packetsLost)!==null&&A!==void 0?A:"unknown",resolution:d.frameWidth&&d.frameHeight?`${d.frameWidth}x${d.frameHeight}`:void 0,jitter:d.jitter!==void 0?d.jitter:void 0};u.personaVideoStream.push(I)}));const E=((o=s["inbound-rtp"])===null||o===void 0?void 0:o.filter(d=>d.kind==="audio"))||[];E.length>0&&(u.personaAudioStream=[],E.forEach(d=>{var S,g,y;const C={packetsReceived:(S=d.packetsReceived)!==null&&S!==void 0?S:"unknown",packetsLost:(g=d.packetsLost)!==null&&g!==void 0?g:"unknown",audioLevel:(y=d.audioLevel)!==null&&y!==void 0?y:"unknown",jitter:d.jitter!==void 0?d.jitter:void 0,totalAudioEnergy:d.totalAudioEnergy!==void 0?d.totalAudioEnergy:void 0};u.personaAudioStream.push(C)}));const p=((l=s["outbound-rtp"])===null||l===void 0?void 0:l.filter(d=>d.kind==="audio"))||[];p.length>0&&(u.userAudioInput=[],p.forEach(d=>{var S,g;const y={packetsSent:(S=d.packetsSent)!==null&&S!==void 0?S:"unknown",retransmittedPackets:(g=d.retransmittedPacketsSent)!==null&&g!==void 0?g:void 0,avgPacketSendDelay:d.totalPacketSendDelay!==void 0?d.totalPacketSendDelay/(d.packetsSent||1)*1e3:void 0};u.userAudioInput.push(y)})),s.codec&&(u.codecs=[],s.codec.forEach(d=>{const S={status:d.payloadType?"Active":"Available",mimeType:d.mimeType||"Unknown",payloadType:d.payloadType||"N/A",clockRate:d.clockRate||void 0,channels:d.channels||void 0};u.codecs.push(S)})),s.transport&&(u.transportLayer=[],s.transport.forEach(d=>{const S={dtlsState:d.dtlsState||"unknown",iceState:d.iceState||"unknown",bytesSent:d.bytesSent||void 0,bytesReceived:d.bytesReceived||void 0};u.transportLayer.push(S)}));const _=[];if(c.forEach(d=>{typeof d.framesDropped=="number"&&d.framesDropped>0&&_.push(`Video: ${d.framesDropped} frames dropped`),typeof d.packetsLost=="number"&&d.packetsLost>0&&_.push(`Video: ${d.packetsLost} packets lost`),typeof d.framesPerSecond=="number"&&d.framesPerSecond<23&&_.push(`Video: Low frame rate (${d.framesPerSecond} fps)`)}),E.forEach(d=>{typeof d.packetsLost=="number"&&d.packetsLost>0&&_.push(`Audio: ${d.packetsLost} packets lost`),typeof d.jitter=="number"&&d.jitter>.1&&_.push(`Audio: High jitter (${(d.jitter*1e3).toFixed(1)}ms)`)}),u.issues=_,e==="json")return u;console.group("📊 WebRTC Session Statistics Report"),u.personaVideoStream&&u.personaVideoStream.length>0&&(console.group("📹 Persona Video Stream (Inbound)"),u.personaVideoStream.forEach(d=>{console.log(`Frames Received: ${d.framesReceived}`),console.log(`Frames Dropped: ${d.framesDropped}`),console.log(`Frames Per Second: ${d.framesPerSecond}`),console.log(`Packets Received: ${typeof d.packetsReceived=="number"?d.packetsReceived.toLocaleString():d.packetsReceived}`),console.log(`Packets Lost: ${d.packetsLost}`),d.resolution&&console.log(`Resolution: ${d.resolution}`),d.jitter!==void 0&&console.log(`Jitter: ${d.jitter.toFixed(5)}ms`)}),console.groupEnd()),u.personaAudioStream&&u.personaAudioStream.length>0&&(console.group("🔊 Persona Audio Stream (Inbound)"),u.personaAudioStream.forEach(d=>{console.log(`Packets Received: ${typeof d.packetsReceived=="number"?d.packetsReceived.toLocaleString():d.packetsReceived}`),console.log(`Packets Lost: ${d.packetsLost}`),console.log(`Audio Level: ${d.audioLevel}`),d.jitter!==void 0&&console.log(`Jitter: ${d.jitter.toFixed(5)}ms`),d.totalAudioEnergy!==void 0&&console.log(`Total Audio Energy: ${d.totalAudioEnergy.toFixed(6)}`)}),console.groupEnd()),u.userAudioInput&&u.userAudioInput.length>0&&(console.group("🎤 User Audio Input (Outbound)"),u.userAudioInput.forEach(d=>{console.log(`Packets Sent: ${typeof d.packetsSent=="number"?d.packetsSent.toLocaleString():d.packetsSent}`),d.retransmittedPackets&&console.log(`Retransmitted Packets: ${d.retransmittedPackets}`),d.avgPacketSendDelay!==void 0&&console.log(`Avg Packet Send Delay: ${d.avgPacketSendDelay.toFixed(5)}ms`)}),console.groupEnd()),u.codecs&&u.codecs.length>0&&(console.group("🔧 Codecs Used"),u.codecs.forEach(d=>{console.log(`${d.status} ${d.mimeType} - Payload Type: ${d.payloadType}`),d.clockRate&&console.log(`  Clock Rate: ${d.clockRate}Hz`),d.channels&&console.log(`  Channels: ${d.channels}`)}),console.groupEnd()),u.transportLayer&&u.transportLayer.length>0&&(console.group("🚚 Transport Layer"),u.transportLayer.forEach(d=>{console.log(`DTLS State: ${d.dtlsState}`),console.log(`ICE State: ${d.iceState}`),(d.bytesReceived||d.bytesSent)&&console.log(`Data Transfer (bytes) - Sent: ${(d.bytesSent||0).toLocaleString()}, Received: ${(d.bytesReceived||0).toLocaleString()}`)}),console.groupEnd()),u.issues.length>0?(console.group("⚠️ Potential Issues Detected"),u.issues.forEach(d=>console.warn(d)),console.groupEnd()):console.log("✅ No significant issues detected"),console.groupEnd()};var W;(function(t){t.CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED="CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED",t.CLIENT_ERROR_CODE_SPEND_CAP_REACHED="CLIENT_ERROR_CODE_SPEND_CAP_REACHED",t.CLIENT_ERROR_CODE_VALIDATION_ERROR="CLIENT_ERROR_CODE_VALIDATION_ERROR",t.CLIENT_ERROR_CODE_AUTHENTICATION_ERROR="CLIENT_ERROR_CODE_AUTHENTICATION_ERROR",t.CLIENT_ERROR_CODE_SERVER_ERROR="CLIENT_ERROR_CODE_SERVER_ERROR",t.CLIENT_ERROR_CODE_MAX_CONCURRENT_SESSIONS_REACHED="CLIENT_ERROR_CODE_MAX_CONCURRENT_SESSIONS_REACHED",t.CLIENT_ERROR_CODE_SERVICE_BUSY="CLIENT_ERROR_CODE_SERVICE_BUSY",t.CLIENT_ERROR_CODE_NO_PLAN_FOUND="CLIENT_ERROR_CODE_NO_PLAN_FOUND",t.CLIENT_ERROR_CODE_UNKNOWN_ERROR="CLIENT_ERROR_CODE_UNKNOWN_ERROR",t.CLIENT_ERROR_CODE_CONFIGURATION_ERROR="CLIENT_ERROR_CODE_CONFIGURATION_ERROR"})(W||(W={}));class $ extends Error{constructor(e,n,o=500,l){super(e),this.name="ClientError",this.code=n,this.statusCode=o,this.details=l,Object.setPrototypeOf(this,$.prototype),ge(ie.CLIENT_METRIC_MEASUREMENT_ERROR,n,{details:l,statusCode:o})}}function Ii(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Date.now().toString(36)+Math.random().toString(36).substr(2,9)}function yn(t){if(!(!t||!t.enabled)){if(!t.baseUrl)return"API Gateway baseUrl is required when enabled";try{const e=new URL(t.baseUrl);if(!["http:","https:","ws:","wss:"].includes(e.protocol))return`Invalid API Gateway baseUrl protocol: ${e.protocol}. Must be http:, https:, ws:, or wss:`}catch{return`Invalid API Gateway baseUrl: ${t.baseUrl}`}if(t.wsPath&&!t.wsPath.startsWith("/"))return"API Gateway wsPath must start with /"}}var H;(function(t){t.OFFER="offer",t.ANSWER="answer",t.ICE_CANDIDATE="icecandidate",t.END_SESSION="endsession",t.HEARTBEAT="heartbeat",t.WARNING="warning",t.TALK_STREAM_INTERRUPTED="talkinputstreaminterrupted",t.TALK_STREAM_INPUT="talkstream",t.SESSION_READY="sessionready",t.AGENT_AUDIO_INPUT="agentaudioinput",t.AGENT_AUDIO_INPUT_END="agentaudioinputend"})(H||(H={}));var Le;(function(t){t.SPEECH_TEXT="speechText",t.CLIENT_TOOL_EVENT="clientToolEvent",t.REASONING_TEXT="reasoningText"})(Le||(Le={}));var de;(function(t){t.PENDING="pending",t.GRANTED="granted",t.DENIED="denied",t.NOT_REQUESTED="not_requested"})(de||(de={}));var Ze;(function(t){t.USER="user",t.PERSONA="persona"})(Ze||(Ze={}));var R;(function(t){t.MESSAGE_HISTORY_UPDATED="MESSAGE_HISTORY_UPDATED",t.MESSAGE_STREAM_EVENT_RECEIVED="MESSAGE_STREAM_EVENT_RECEIVED",t.CONNECTION_ESTABLISHED="CONNECTION_ESTABLISHED",t.CONNECTION_CLOSED="CONNECTION_CLOSED",t.INPUT_AUDIO_STREAM_STARTED="INPUT_AUDIO_STREAM_STARTED",t.VIDEO_STREAM_STARTED="VIDEO_STREAM_STARTED",t.VIDEO_PLAY_STARTED="VIDEO_PLAY_STARTED",t.AUDIO_STREAM_STARTED="AUDIO_STREAM_STARTED",t.TALK_STREAM_INTERRUPTED="TALK_STREAM_INTERRUPTED",t.SESSION_READY="SESSION_READY",t.SERVER_WARNING="SERVER_WARNING",t.MIC_PERMISSION_PENDING="MIC_PERMISSION_PENDING",t.MIC_PERMISSION_GRANTED="MIC_PERMISSION_GRANTED",t.MIC_PERMISSION_DENIED="MIC_PERMISSION_DENIED",t.INPUT_AUDIO_DEVICE_CHANGED="INPUT_AUDIO_DEVICE_CHANGED",t.CLIENT_TOOL_EVENT_RECEIVED="CLIENT_TOOL_EVENT_RECEIVED",t.REASONING_HISTORY_UPDATED="REASONING_HISTORY_UPDATED",t.REASONING_STREAM_EVENT_RECEIVED="REASONING_STREAM_EVENT_RECEIVED"})(R||(R={}));var J;(function(t){t.WEB_SOCKET_OPEN="WEB_SOCKET_OPEN",t.SIGNAL_MESSAGE_RECEIVED="SIGNAL_MESSAGE_RECEIVED",t.WEBRTC_CHAT_MESSAGE_RECEIVED="WEBRTC_CHAT_MESSAGE_RECEIVED",t.WEBRTC_CLIENT_TOOL_EVENT_RECEIVED="WEBRTC_CLIENT_TOOL_EVENT_RECEIVED",t.WEBRTC_REASONING_TEXT_MESSAGE_RECEIVED="WEBRTC_REASONING_TEXT_MESSAGE_RECEIVED"})(J||(J={}));var he;(function(t){t.NORMAL="CONNECTION_CLOSED_CODE_NORMAL",t.MICROPHONE_PERMISSION_DENIED="CONNECTION_CLOSED_CODE_MICROPHONE_PERMISSION_DENIED",t.SIGNALLING_CLIENT_CONNECTION_FAILURE="CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE",t.WEBRTC_FAILURE="CONNECTION_CLOSED_CODE_WEBRTC_FAILURE",t.SERVER_CLOSED_CONNECTION="CONNECTION_CLOSED_CODE_SERVER_CLOSED_CONNECTION"})(he||(he={}));class Sn{constructor(e,n){this.sequenceNumber=0,this.config=e,this.signallingClient=n}sendAudioChunk(e){const o={audioData:typeof e=="string"?e:this.arrayBufferToBase64(e),encoding:this.config.encoding,sampleRate:this.config.sampleRate,channels:this.config.channels,sequenceNumber:this.sequenceNumber++};this.signallingClient.sendAgentAudioInput(o)}endSequence(){this.signallingClient.sendAgentAudioInputEnd(),this.sequenceNumber=0}getSequenceNumber(){return this.sequenceNumber}getConfig(){return this.config}arrayBufferToBase64(e){const n=e instanceof Uint8Array?e:new Uint8Array(e),o=Array.from(n,l=>String.fromCharCode(l)).join("");return btoa(o)}}var Ae=function(t,e,n,o){function l(s){return s instanceof n?s:new n(function(u){u(s)})}return new(n||(n=Promise))(function(s,u){function c(_){try{p(o.next(_))}catch(d){u(d)}}function E(_){try{p(o.throw(_))}catch(d){u(d)}}function p(_){_.done?s(_.value):l(_.value).then(c,E)}p((o=o.apply(t,e||[])).next())})};const wn=5,Cn=5;class In{constructor(e,n,o,l,s){var u,c,E,p,_;if(this.stopSignal=!1,this.sendingBuffer=[],this.wsConnectionAttempts=0,this.socket=null,this.heartBeatIntervalRef=null,this.publicEventEmitter=o,this.internalEventEmitter=l,this.apiGatewayConfig=s,!e)throw new Error("Signalling Client: sessionId is required");this.sessionId=e;const{heartbeatIntervalSeconds:d,maxWsReconnectionAttempts:S,url:g}=n;if(this.heartbeatIntervalSeconds=d||wn,this.maxWsReconnectionAttempts=S||Cn,!g.baseUrl)throw new Error("Signalling Client: baseUrl is required");if(!((u=this.apiGatewayConfig)===null||u===void 0)&&u.enabled&&(!((c=this.apiGatewayConfig)===null||c===void 0)&&c.baseUrl)){const y=new URL(this.apiGatewayConfig.baseUrl),C=(E=this.apiGatewayConfig.wsPath)!==null&&E!==void 0?E:"/ws";y.protocol=y.protocol.replace("http","ws"),y.pathname=C,this.url=y;const A=g.protocol||"https",I=A==="http"?"ws":"wss",b=`${A}://${g.baseUrl}`,N=(p=g.signallingPath)!==null&&p!==void 0?p:"/ws",M=new URL(b);M.protocol=I==="ws"?"ws:":"wss:",g.port&&(M.port=g.port),M.pathname=N,M.searchParams.append("session_id",e),this.url.searchParams.append("target_url",M.href)}else{const C=`${g.protocol||"https"}://${g.baseUrl}`;this.url=new URL(C),this.url.protocol=g.protocol==="http"?"ws:":"wss:",g.port&&(this.url.port=g.port),this.url.pathname=(_=g.signallingPath)!==null&&_!==void 0?_:"/ws",this.url.searchParams.append("session_id",e)}}stop(){this.stopSignal=!0,this.closeSocket()}connect(){return this.socket=new WebSocket(this.url.href),this.socket.onopen=this.onOpen.bind(this),this.socket.onclose=this.onClose.bind(this),this.socket.onerror=this.onError.bind(this),this.socket}sendOffer(e){return Ae(this,void 0,void 0,function*(){const n={connectionDescription:e,userUid:this.sessionId},o={actionType:H.OFFER,sessionId:this.sessionId,payload:n};this.sendSignalMessage(o)})}sendIceCandidate(e){return Ae(this,void 0,void 0,function*(){const n={actionType:H.ICE_CANDIDATE,sessionId:this.sessionId,payload:e.toJSON()};this.sendSignalMessage(n)})}sendSignalMessage(e){var n;if(((n=this.socket)===null||n===void 0?void 0:n.readyState)===WebSocket.OPEN)try{this.socket.send(JSON.stringify(e))}catch(o){console.error("SignallingClient - sendSignalMessage: error sending message",o)}else this.sendingBuffer.push(e)}sendTalkMessage(e){return Ae(this,void 0,void 0,function*(){const n={actionType:H.TALK_STREAM_INPUT,sessionId:this.sessionId,payload:e};this.sendSignalMessage(n)})}sendAgentAudioInput(e){const n={actionType:H.AGENT_AUDIO_INPUT,sessionId:this.sessionId,payload:e};this.sendSignalMessage(n)}sendAgentAudioInputEnd(){const e={actionType:H.AGENT_AUDIO_INPUT_END,sessionId:this.sessionId,payload:{}};this.sendSignalMessage(e)}closeSocket(){this.socket&&(this.socket.close(),this.socket=null),this.heartBeatIntervalRef&&(clearInterval(this.heartBeatIntervalRef),this.heartBeatIntervalRef=null)}onOpen(){return Ae(this,void 0,void 0,function*(){if(!this.socket)throw new Error("SignallingClient - onOpen: socket is null");try{this.wsConnectionAttempts=0,this.flushSendingBuffer(),this.socket.onmessage=this.onMessage.bind(this),this.startSendingHeartBeats(),this.internalEventEmitter.emit(J.WEB_SOCKET_OPEN)}catch(e){console.error("SignallingClient - onOpen: error in onOpen",e),this.publicEventEmitter.emit(R.CONNECTION_CLOSED,he.SIGNALLING_CLIENT_CONNECTION_FAILURE)}})}onClose(){return Ae(this,void 0,void 0,function*(){this.wsConnectionAttempts+=1,!this.stopSignal&&(this.wsConnectionAttempts<=this.maxWsReconnectionAttempts?(this.socket=null,setTimeout(()=>{this.connect()},100*this.wsConnectionAttempts)):(this.heartBeatIntervalRef&&(clearInterval(this.heartBeatIntervalRef),this.heartBeatIntervalRef=null),this.publicEventEmitter.emit(R.CONNECTION_CLOSED,he.SIGNALLING_CLIENT_CONNECTION_FAILURE)))})}onError(e){this.stopSignal||console.error("SignallingClient - onError: ",e)}flushSendingBuffer(){const e=[];this.sendingBuffer.length>0&&this.sendingBuffer.forEach(n=>{var o;((o=this.socket)===null||o===void 0?void 0:o.readyState)===WebSocket.OPEN?this.socket.send(JSON.stringify(n)):e.push(n)}),this.sendingBuffer=e}onMessage(e){return Ae(this,void 0,void 0,function*(){const n=JSON.parse(e.data);this.internalEventEmitter.emit(J.SIGNAL_MESSAGE_RECEIVED,n)})}startSendingHeartBeats(){if(!this.socket)throw new Error("SignallingClient - startSendingHeartBeats: socket is null");this.heartBeatIntervalRef&&console.warn("SignallingClient - startSendingHeartBeats: heartbeat interval already set");const e=this.heartbeatIntervalSeconds*1e3,n={actionType:H.HEARTBEAT,sessionId:this.sessionId,payload:""},o=JSON.stringify(n);this.heartBeatIntervalRef=setInterval(()=>{var l;this.stopSignal||((l=this.socket)===null||l===void 0?void 0:l.readyState)===WebSocket.OPEN&&this.socket.send(o)},e)}}function bn(t){return"brainType"in t||"llmId"in t}var bi=function(t,e,n,o){function l(s){return s instanceof n?s:new n(function(u){u(s)})}return new(n||(n=Promise))(function(s,u){function c(_){try{p(o.next(_))}catch(d){u(d)}}function E(_){try{p(o.throw(_))}catch(d){u(d)}}function p(_){_.done?s(_.value):l(_.value).then(c,E)}p((o=o.apply(t,e||[])).next())})};class An{constructor(e,n,o){if(!e&&!n)throw new Error("Either sessionToken or apiKey must be provided");this.sessionToken=e||null,this.apiKey=n||null,this.baseUrl=o?.baseUrl||fn,this.apiVersion=o?.apiVersion||pn,this.apiGatewayConfig=o?.apiGateway||void 0}buildGatewayUrlAndHeaders(e,n){var o,l;if(!((o=this.apiGatewayConfig)===null||o===void 0)&&o.enabled&&(!((l=this.apiGatewayConfig)===null||l===void 0)&&l.baseUrl)){const s=`${this.apiGatewayConfig.baseUrl}${e}`,u=new URL(`${this.baseUrl}${e}`),c=Object.assign(Object.assign({},n),{"X-Anam-Target-Url":u.href});return{url:s,headers:c}}else return{url:`${this.baseUrl}${e}`,headers:n}}startSession(e,n){return bi(this,void 0,void 0,function*(){if(!this.sessionToken){if(!e)throw new $("Persona configuration must be provided when using apiKey",W.CLIENT_ERROR_CODE_VALIDATION_ERROR,400);this.sessionToken=yield this.unsafe_getSessionToken(e)}e&&"brainType"in e&&console.warn("Warning: brainType is deprecated and will be removed in a future version. Please use llmId instead.");try{const o=`${this.apiVersion}/engine/session`,{url:l,headers:s}=this.buildGatewayUrlAndHeaders(o,{"Content-Type":"application/json",Authorization:`Bearer ${this.sessionToken}`}),u=yield fetch(l,{method:"POST",headers:s,body:JSON.stringify({personaConfig:e,sessionOptions:n,clientMetadata:yi})}),c=yield u.json(),E=c.error;switch(u.status){case 200:case 201:return c;case 400:throw new $("Invalid request to start session",W.CLIENT_ERROR_CODE_VALIDATION_ERROR,400,{cause:c.message});case 401:throw new $("Authentication failed when starting session",W.CLIENT_ERROR_CODE_AUTHENTICATION_ERROR,401,{cause:c.message});case 402:throw new $("Please sign up for a plan to start a session",W.CLIENT_ERROR_CODE_NO_PLAN_FOUND,402,{cause:c.message});case 403:throw new $("Authentication failed when starting session",W.CLIENT_ERROR_CODE_AUTHENTICATION_ERROR,403,{cause:c.message});case 429:throw E==="Concurrent session limit reached"?new $("Concurrency limit reached, please upgrade your plan",W.CLIENT_ERROR_CODE_MAX_CONCURRENT_SESSIONS_REACHED,429,{cause:c.message}):E==="Spend cap reached"?new $("Spend cap reached, please upgrade your plan",W.CLIENT_ERROR_CODE_SPEND_CAP_REACHED,429,{cause:c.message}):new $("Usage limit reached, please upgrade your plan",W.CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED,429,{cause:c.message});case 503:throw new $("There are no available personas, please try again later",W.CLIENT_ERROR_CODE_SERVICE_BUSY,503,{cause:c.message});default:throw new $("Unknown error when starting session",W.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:c.message})}}catch(o){throw o instanceof $?o:new $("Failed to start session",W.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:o instanceof Error?o.message:String(o)})}})}unsafe_getSessionToken(e){return bi(this,void 0,void 0,function*(){if(console.warn("Using unsecure method. This method should not be used in production."),!this.apiKey)throw new Error("No apiKey provided");e&&"brainType"in e&&console.warn("Warning: brainType is deprecated and will be removed in a future version. Please use llmId instead.");let n={clientLabel:"js-sdk-api-key"};bn(e)&&(n=Object.assign(Object.assign({},n),{personaConfig:e}));try{const o=`${this.apiVersion}/auth/session-token`,{url:l,headers:s}=this.buildGatewayUrlAndHeaders(o,{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`});return(yield(yield fetch(l,{method:"POST",headers:s,body:JSON.stringify(n)})).json()).sessionToken}catch{throw new Error("Failed to get session token")}})}getApiUrl(){return`${this.baseUrl}${this.apiVersion}`}}var Tn=function(t,e,n,o){function l(s){return s instanceof n?s:new n(function(u){u(s)})}return new(n||(n=Promise))(function(s,u){function c(_){try{p(o.next(_))}catch(d){u(d)}}function E(_){try{p(o.throw(_))}catch(d){u(d)}}function p(_){_.done?s(_.value):l(_.value).then(c,E)}p((o=o.apply(t,e||[])).next())})};class Rn{constructor(e,n,o){this.baseUrl=e,this.sessionId=n,this.apiGatewayConfig=o}sendTalkCommand(e){return Tn(this,void 0,void 0,function*(){var n,o;try{let l,s={"Content-Type":"application/json"};const u="/talk",c=`?session_id=${this.sessionId}`;if(!((n=this.apiGatewayConfig)===null||n===void 0)&&n.enabled&&(!((o=this.apiGatewayConfig)===null||o===void 0)&&o.baseUrl)){l=`${this.apiGatewayConfig.baseUrl}${u}${c}`;const p=new URL(`${this.baseUrl}${u}${c}`);s["X-Anam-Target-Url"]=p.href}else l=`${this.baseUrl}${u}${c}`;const E=yield fetch(l,{method:"POST",headers:s,body:JSON.stringify({content:e})});if(!E.ok)throw new Error(`Failed to send talk command: ${E.status} ${E.statusText}`)}catch(l){throw console.error(l),new Error("EngineApiRestClient - sendTalkCommand: Failed to send talk command")}})}}class Nn{constructor(){this.listeners={}}addListener(e,n){this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(n)}removeListener(e,n){this.listeners[e]&&this.listeners[e].delete(n)}emit(e,...n){this.listeners[e]&&this.listeners[e].forEach(o=>{o(...n)})}}class xn{constructor(e,n){this.messages=[],this.publicEventEmitter=e,this.internalEventEmitter=n,this.internalEventEmitter.addListener(J.WEBRTC_CHAT_MESSAGE_RECEIVED,this.processWebRtcTextMessageEvent.bind(this))}webRtcTextMessageEventToMessageStreamEvent(e){return{id:`${e.role}::${e.message_id}`,content:e.content,role:e.role,endOfSpeech:e.end_of_speech,interrupted:e.interrupted}}processUserMessage(e){const n={id:e.id,content:e.content,role:e.role};this.messages.push(n)}processPersonaMessage(e){const n={id:e.id,content:e.content,role:e.role,interrupted:e.interrupted},o=this.messages.findIndex(l=>l.id===n.id);if(o!==-1){const l=this.messages[o];this.messages[o]=Object.assign(Object.assign({},l),{content:l.content+n.content,interrupted:l.interrupted||n.interrupted})}else this.messages.push(n)}processWebRtcTextMessageEvent(e){const n=this.webRtcTextMessageEventToMessageStreamEvent(e);switch(this.publicEventEmitter.emit(R.MESSAGE_STREAM_EVENT_RECEIVED,n),n.role){case Ze.USER:this.processUserMessage(n);break;case Ze.PERSONA:this.processPersonaMessage(n);break}n.endOfSpeech&&this.publicEventEmitter.emit(R.MESSAGE_HISTORY_UPDATED,this.messages)}}class On{constructor(){this.listeners={}}addListener(e,n){this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(n)}removeListener(e,n){this.listeners[e]&&this.listeners[e].delete(n)}emit(e,...n){if(e===R.CONNECTION_ESTABLISHED&&ge(ie.CLIENT_METRIC_MEASUREMENT_CONNECTION_ESTABLISHED,"1"),e===R.CONNECTION_CLOSED){const[o,l]=n;ge(ie.CLIENT_METRIC_MEASUREMENT_CONNECTION_CLOSED,o,l?{details:l}:void 0)}this.listeners[e]&&this.listeners[e].forEach(o=>{o(...n)})}}var q;(function(t){t[t.UNSTARTED=0]="UNSTARTED",t[t.STREAMING=1]="STREAMING",t[t.INTERRUPTED=2]="INTERRUPTED",t[t.ENDED=3]="ENDED"})(q||(q={}));var gt=function(t,e,n,o){function l(s){return s instanceof n?s:new n(function(u){u(s)})}return new(n||(n=Promise))(function(s,u){function c(_){try{p(o.next(_))}catch(d){u(d)}}function E(_){try{p(o.throw(_))}catch(d){u(d)}}function p(_){_.done?s(_.value):l(_.value).then(c,E)}p((o=o.apply(t,e||[])).next())})};class kn{constructor(e,n,o){this.state=q.UNSTARTED,this.correlationId=e,this.internalEventEmitter=n,this.signallingClient=o,this.internalEventEmitter.addListener(J.SIGNAL_MESSAGE_RECEIVED,this.onSignalMessage.bind(this))}onDeactivate(){this.internalEventEmitter.removeListener(J.SIGNAL_MESSAGE_RECEIVED,this.onSignalMessage.bind(this))}onSignalMessage(e){return gt(this,void 0,void 0,function*(){e.actionType===H.TALK_STREAM_INTERRUPTED&&e.payload.correlationId===this.correlationId&&(this.state=q.INTERRUPTED,this.onDeactivate())})}endMessage(){return gt(this,void 0,void 0,function*(){if(this.state===q.ENDED){console.warn("Talk stream is already ended via end of speech. No need to call endMessage.");return}if(this.state!==q.STREAMING){console.warn("Talk stream is not active state: "+this.state);return}const e={content:"",startOfSpeech:!1,endOfSpeech:!0,correlationId:this.correlationId};yield this.signallingClient.sendTalkMessage(e),this.state=q.ENDED,this.onDeactivate()})}streamMessageChunk(e,n){return gt(this,void 0,void 0,function*(){if(this.state!==q.STREAMING&&this.state!==q.UNSTARTED)throw new Error("Talk stream is not in an active state: "+this.state);const o={content:e,startOfSpeech:this.state===q.UNSTARTED,endOfSpeech:n,correlationId:this.correlationId};this.state=n?q.ENDED:q.STREAMING,this.state===q.ENDED&&this.onDeactivate(),yield this.signallingClient.sendTalkMessage(o)})}getCorrelationId(){return this.correlationId}isActive(){return this.state===q.STREAMING||this.state===q.UNSTARTED}getState(){return this.state}}var X=function(t,e,n,o){function l(s){return s instanceof n?s:new n(function(u){u(s)})}return new(n||(n=Promise))(function(s,u){function c(_){try{p(o.next(_))}catch(d){u(d)}}function E(_){try{p(o.throw(_))}catch(d){u(d)}}function p(_){_.done?s(_.value):l(_.value).then(c,E)}p((o=o.apply(t,e||[])).next())})};const Dn=15e3,Mn=5e3,Un=2;class Ln{constructor(e,n,o,l){var s,u,c,E;this.peerConnection=null,this.connectionReceivedAnswer=!1,this.remoteIceCandidateBuffer=[],this.inputAudioStream=null,this.dataChannel=null,this.videoElement=null,this.videoStream=null,this.audioStream=null,this.inputAudioState={isMuted:!1,permissionState:de.NOT_REQUESTED},this.successMetricPoller=null,this.successMetricFired=!1,this.showPeerConnectionStatsReport=!1,this.peerConnectionStatsReportOutputFormat="console",this.statsCollectionInterval=null,this.agentAudioInputStream=null,this.publicEventEmitter=o,this.internalEventEmitter=l,this.apiGatewayConfig=n.apiGateway;const{inputAudio:p}=n;this.inputAudioState=p.inputAudioState,n.inputAudio.userProvidedMediaStream&&(this.inputAudioStream=n.inputAudio.userProvidedMediaStream),this.disableInputAudio=n.inputAudio.disableInputAudio===!0,this.internalEventEmitter.addListener(J.WEB_SOCKET_OPEN,this.onSignallingClientConnected.bind(this)),this.internalEventEmitter.addListener(J.SIGNAL_MESSAGE_RECEIVED,this.onSignalMessage.bind(this)),this.iceServers=n.iceServers,this.signallingClient=new In(e,n.signalling,this.publicEventEmitter,this.internalEventEmitter,this.apiGatewayConfig),this.engineApiRestClient=new Rn(n.engine.baseUrl,e,this.apiGatewayConfig),this.audioDeviceId=n.inputAudio.audioDeviceId,this.showPeerConnectionStatsReport=(u=(s=n.metrics)===null||s===void 0?void 0:s.showPeerConnectionStatsReport)!==null&&u!==void 0?u:!1,this.peerConnectionStatsReportOutputFormat=(E=(c=n.metrics)===null||c===void 0?void 0:c.peerConnectionStatsReportOutputFormat)!==null&&E!==void 0?E:"console"}onInputAudioStateChange(e,n){e.isMuted!==n.isMuted&&(n.isMuted?this.muteAllAudioTracks():this.unmuteAllAudioTracks())}muteAllAudioTracks(){var e;(e=this.inputAudioStream)===null||e===void 0||e.getAudioTracks().forEach(n=>{n.enabled=!1})}unmuteAllAudioTracks(){var e;(e=this.inputAudioStream)===null||e===void 0||e.getAudioTracks().forEach(n=>{n.enabled=!0})}startStatsCollection(){this.statsCollectionInterval||(this.statsCollectionInterval=setInterval(()=>X(this,void 0,void 0,function*(){if(!(!this.peerConnection||!this.dataChannel||this.dataChannel.readyState!=="open"))try{const e=yield this.peerConnection.getStats();this.sendClientSideMetrics(e)}catch(e){console.error("Failed to collect and send stats:",e)}}),Mn))}sendClientSideMetrics(e){e.forEach(n=>{if(n.type==="inbound-rtp"){const o={message_type:"remote_rtp_stats",data:n};this.dataChannel&&this.dataChannel.readyState==="open"&&this.dataChannel.send(JSON.stringify(o))}})}startSuccessMetricPolling(){if(this.successMetricPoller||this.successMetricFired)return;const e=setTimeout(()=>{this.successMetricPoller&&(console.warn("No video frames received, there is a problem with the connection."),clearInterval(this.successMetricPoller),this.successMetricPoller=null)},Dn);this.successMetricPoller=setInterval(()=>X(this,void 0,void 0,function*(){if(!this.peerConnection||this.successMetricFired){this.successMetricPoller&&clearInterval(this.successMetricPoller),clearTimeout(e);return}try{const n=yield this.peerConnection.getStats();let o=!1,l=null;n.forEach(s=>{s.type==="inbound-rtp"&&s.kind==="video"&&(s.framesDecoded!==void 0&&s.framesDecoded>0?(o=!0,l="framesDecoded"):s.framesReceived!==void 0&&s.framesReceived>0?(o=!0,l="framesReceived"):s.bytesReceived>0&&s.packetsReceived>0&&s.bytesReceived>1e5&&(o=!0,l="bytesReceived"))}),o&&!this.successMetricFired&&(this.successMetricFired=!0,ge(ie.CLIENT_METRIC_MEASUREMENT_SESSION_SUCCESS,"1",l?{detectionMethod:l}:void 0),this.successMetricPoller&&clearInterval(this.successMetricPoller),clearTimeout(e),this.successMetricPoller=null)}catch{}}),500)}muteInputAudio(){const e=this.inputAudioState,n=Object.assign(Object.assign({},this.inputAudioState),{isMuted:!0});return this.inputAudioState=n,this.onInputAudioStateChange(e,n),this.inputAudioState}unmuteInputAudio(){const e=this.inputAudioState,n=Object.assign(Object.assign({},this.inputAudioState),{isMuted:!1});return this.inputAudioState=n,this.onInputAudioStateChange(e,n),this.inputAudioState}getInputAudioState(){return this.inputAudioState}getPeerConnection(){return this.peerConnection}changeAudioInputDevice(e){return X(this,void 0,void 0,function*(){if(!this.peerConnection)throw new Error("StreamingClient - changeAudioInputDevice: peer connection is not initialized. Start streaming first.");if(e==null)throw new Error("StreamingClient - changeAudioInputDevice: deviceId is required");const n=this.inputAudioState.isMuted;try{this.inputAudioStream&&this.inputAudioStream.getAudioTracks().forEach(l=>{l.stop()});const o={echoCancellation:!0,deviceId:{exact:e}};this.inputAudioStream=yield navigator.mediaDevices.getUserMedia({audio:o}),this.audioDeviceId=e,yield this.setupAudioTrack(),n&&this.muteAllAudioTracks(),this.publicEventEmitter.emit(R.INPUT_AUDIO_DEVICE_CHANGED,e)}catch(o){throw console.error("Failed to change audio input device:",o),new Error(`StreamingClient - changeAudioInputDevice: ${o instanceof Error?o.message:String(o)}`)}})}getInputAudioStream(){return this.inputAudioStream}getVideoStream(){return this.videoStream}getAudioStream(){return this.audioStream}sendDataMessage(e){this.dataChannel&&this.dataChannel.readyState==="open"&&this.dataChannel.send(e)}setMediaStreamTargetById(e){if(e){const n=document.getElementById(e);if(!n)throw new Error(`StreamingClient: video element with id ${e} not found`);this.videoElement=n}}startConnection(){try{if(this.peerConnection){console.error("StreamingClient - startConnection: peer connection already exists");return}this.signallingClient.connect()}catch(e){console.error("StreamingClient - startConnection: error",e),this.handleWebrtcFailure(e)}}stopConnection(){return X(this,void 0,void 0,function*(){yield this.shutdown()})}sendTalkCommand(e){return X(this,void 0,void 0,function*(){if(!this.peerConnection)throw new Error("StreamingClient - sendTalkCommand: peer connection is null");yield this.engineApiRestClient.sendTalkCommand(e)})}startTalkMessageStream(e){return e||(e=Math.random().toString(36).substring(2,15)),new kn(e,this.internalEventEmitter,this.signallingClient)}createAgentAudioInputStream(e){return this.agentAudioInputStream=new Sn(e,this.signallingClient),this.agentAudioInputStream}getAgentAudioInputStream(){return this.agentAudioInputStream}initPeerConnection(){return X(this,void 0,void 0,function*(){this.peerConnection=new RTCPeerConnection({iceServers:this.iceServers,iceCandidatePoolSize:Un}),this.peerConnection.onicecandidate=this.onIceCandidate.bind(this),this.peerConnection.oniceconnectionstatechange=this.onIceConnectionStateChange.bind(this),this.peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this),this.peerConnection.addEventListener("track",this.onTrackEventHandler.bind(this)),yield this.setupDataChannels(),this.peerConnection.addTransceiver("video",{direction:"recvonly"}),this.disableInputAudio?this.peerConnection.addTransceiver("audio",{direction:"recvonly"}):(this.peerConnection.addTransceiver("audio",{direction:"sendrecv"}),this.inputAudioStream?yield this.setupAudioTrack():this.requestMicrophonePermissionAsync().catch(e=>{console.error("Async microphone permission request failed:",e)}))})}onSignalMessage(e){return X(this,void 0,void 0,function*(){if(!this.peerConnection){console.error("StreamingClient - onSignalMessage: peerConnection is not initialized");return}switch(e.actionType){case H.ANSWER:const n=e.payload;yield this.peerConnection.setRemoteDescription(n),this.connectionReceivedAnswer=!0,this.flushRemoteIceCandidateBuffer();break;case H.ICE_CANDIDATE:const o=e.payload,l=new RTCIceCandidate(o);this.connectionReceivedAnswer?yield this.peerConnection.addIceCandidate(l):this.remoteIceCandidateBuffer.push(l);break;case H.END_SESSION:const s=e.payload;this.publicEventEmitter.emit(R.CONNECTION_CLOSED,he.SERVER_CLOSED_CONNECTION,s),this.shutdown();break;case H.WARNING:const u=e.payload;console.warn("Warning received from server: "+u),this.publicEventEmitter.emit(R.SERVER_WARNING,u);break;case H.TALK_STREAM_INTERRUPTED:const c=e.payload;this.publicEventEmitter.emit(R.TALK_STREAM_INTERRUPTED,c.correlationId);break;case H.SESSION_READY:const E=e.sessionId;this.publicEventEmitter.emit(R.SESSION_READY,E);break;case H.HEARTBEAT:break;default:console.warn("StreamingClient - onSignalMessage: unknown signal message action type. Is your anam-sdk version up to date?",e)}})}onSignallingClientConnected(){return X(this,void 0,void 0,function*(){if(!this.peerConnection)try{yield this.initPeerConnectionAndSendOffer()}catch(e){console.error("StreamingClient - onSignallingClientConnected: Error initializing peer connection",e),this.handleWebrtcFailure(e)}})}flushRemoteIceCandidateBuffer(){this.remoteIceCandidateBuffer.forEach(e=>{var n;(n=this.peerConnection)===null||n===void 0||n.addIceCandidate(e)}),this.remoteIceCandidateBuffer=[]}onIceCandidate(e){e.candidate&&this.signallingClient.sendIceCandidate(e.candidate)}onIceConnectionStateChange(){var e,n;(((e=this.peerConnection)===null||e===void 0?void 0:e.iceConnectionState)==="connected"||((n=this.peerConnection)===null||n===void 0?void 0:n.iceConnectionState)==="completed")&&(this.publicEventEmitter.emit(R.CONNECTION_ESTABLISHED),this.startStatsCollection())}onConnectionStateChange(){var e;((e=this.peerConnection)===null||e===void 0?void 0:e.connectionState)==="closed"&&(console.error("StreamingClient - onConnectionStateChange: Connection closed"),this.handleWebrtcFailure("The connection to our servers was lost. Please try again."))}handleWebrtcFailure(e){console.error({message:"StreamingClient - handleWebrtcFailure: ",err:e}),e.name==="NotAllowedError"&&e.message==="Permission denied"?this.publicEventEmitter.emit(R.CONNECTION_CLOSED,he.MICROPHONE_PERMISSION_DENIED):this.publicEventEmitter.emit(R.CONNECTION_CLOSED,he.WEBRTC_FAILURE);try{this.stopConnection()}catch(n){console.error("StreamingClient - handleWebrtcFailure: error stopping connection",n)}}onTrackEventHandler(e){if(e.track.kind==="video"){if(this.startSuccessMetricPolling(),this.videoStream=e.streams[0],this.publicEventEmitter.emit(R.VIDEO_STREAM_STARTED,this.videoStream),this.videoElement){this.videoElement.srcObject=this.videoStream;const n=this.videoElement.requestVideoFrameCallback(()=>{var o;(o=this.videoElement)===null||o===void 0||o.cancelVideoFrameCallback(n),this.publicEventEmitter.emit(R.VIDEO_PLAY_STARTED),this.successMetricFired||(this.successMetricFired=!0,ge(ie.CLIENT_METRIC_MEASUREMENT_SESSION_SUCCESS,"1",{detectionMethod:"videoElement"}))})}}else e.track.kind==="audio"&&(this.audioStream=e.streams[0],this.publicEventEmitter.emit(R.AUDIO_STREAM_STARTED,this.audioStream))}setupDataChannels(){return X(this,void 0,void 0,function*(){if(!this.peerConnection){console.error("StreamingClient - setupDataChannels: peer connection is not initialized");return}if(!this.disableInputAudio&&this.inputAudioStream&&!this.inputAudioStream.getAudioTracks().length)throw new Error("StreamingClient - setupDataChannels: user provided stream does not have audio tracks");const e=this.peerConnection.createDataChannel("session",{ordered:!0});e.onopen=()=>{this.dataChannel=e??null},e.onclose=()=>{},e.onmessage=n=>{try{const o=JSON.parse(n.data);switch(o.messageType){case Le.SPEECH_TEXT:this.internalEventEmitter.emit(J.WEBRTC_CHAT_MESSAGE_RECEIVED,o.data);break;case Le.CLIENT_TOOL_EVENT:const l=o.data;this.internalEventEmitter.emit(J.WEBRTC_CLIENT_TOOL_EVENT_RECEIVED,l);const s=Bn.WebRTCClientToolEventToClientToolEvent(l);this.publicEventEmitter.emit(R.CLIENT_TOOL_EVENT_RECEIVED,s);break;case Le.REASONING_TEXT:this.internalEventEmitter.emit(J.WEBRTC_REASONING_TEXT_MESSAGE_RECEIVED,o.data);break;default:break}}catch(o){console.error("Failed to parse data channel message:",o)}}})}requestMicrophonePermissionAsync(){return X(this,void 0,void 0,function*(){if(this.inputAudioState.permissionState!==de.PENDING){this.inputAudioState=Object.assign(Object.assign({},this.inputAudioState),{permissionState:de.PENDING}),this.publicEventEmitter.emit(R.MIC_PERMISSION_PENDING);try{const e={echoCancellation:!0};this.audioDeviceId&&(e.deviceId={exact:this.audioDeviceId}),this.inputAudioStream=yield navigator.mediaDevices.getUserMedia({audio:e}),this.inputAudioState=Object.assign(Object.assign({},this.inputAudioState),{permissionState:de.GRANTED}),this.publicEventEmitter.emit(R.MIC_PERMISSION_GRANTED),yield this.setupAudioTrack()}catch(e){console.error("Failed to get microphone permission:",e),this.inputAudioState=Object.assign(Object.assign({},this.inputAudioState),{permissionState:de.DENIED});const n=e instanceof Error?e.message:String(e);this.publicEventEmitter.emit(R.MIC_PERMISSION_DENIED,n)}}})}setupAudioTrack(){return X(this,void 0,void 0,function*(){if(!this.peerConnection||!this.inputAudioStream)return;if(!this.inputAudioStream.getAudioTracks().length){console.error("StreamingClient - setupAudioTrack: stream does not have audio tracks");return}this.inputAudioState.isMuted&&this.muteAllAudioTracks();const e=this.inputAudioStream.getAudioTracks()[0],o=this.peerConnection.getSenders().find(l=>{var s;return((s=l.track)===null||s===void 0?void 0:s.kind)==="audio"||l.track===null&&l.dtmf!==null});if(o)try{yield o.replaceTrack(e)}catch(l){console.error("Failed to replace audio track:",l),this.peerConnection.addTrack(e,this.inputAudioStream)}else this.peerConnection.addTrack(e,this.inputAudioStream);this.publicEventEmitter.emit(R.INPUT_AUDIO_STREAM_STARTED,this.inputAudioStream)})}initPeerConnectionAndSendOffer(){return X(this,void 0,void 0,function*(){if(yield this.initPeerConnection(),!this.peerConnection){console.error("StreamingClient - initPeerConnectionAndSendOffer: peer connection is not initialized");return}try{const e=yield this.peerConnection.createOffer();yield this.peerConnection.setLocalDescription(e)}catch(e){console.error("StreamingClient - initPeerConnectionAndSendOffer: error creating offer",e)}if(!this.peerConnection.localDescription)throw new Error("StreamingClient - initPeerConnectionAndSendOffer: local description is null");yield this.signallingClient.sendOffer(this.peerConnection.localDescription)})}shutdown(){return X(this,void 0,void 0,function*(){var e;if(this.showPeerConnectionStatsReport){const n=yield(e=this.peerConnection)===null||e===void 0?void 0:e.getStats();if(n){const o=vn(n,this.peerConnectionStatsReportOutputFormat);o&&console.log(o,void 0,2)}}this.statsCollectionInterval&&(clearInterval(this.statsCollectionInterval),this.statsCollectionInterval=null),this.successMetricPoller&&(clearInterval(this.successMetricPoller),this.successMetricPoller=null),this.successMetricFired=!1;try{this.inputAudioStream&&this.inputAudioStream.getTracks().forEach(n=>{n.stop()}),this.inputAudioStream=null}catch(n){console.error("StreamingClient - shutdown: error stopping input audio stream",n)}try{this.signallingClient.stop()}catch(n){console.error("StreamingClient - shutdown: error stopping signallilng",n)}try{this.peerConnection&&this.peerConnection.connectionState!=="closed"&&(this.peerConnection.onconnectionstatechange=null,this.peerConnection.close(),this.peerConnection=null)}catch(n){console.error("StreamingClient - shutdown: error closing peer connection",n)}})}}class Bn{static WebRTCClientToolEventToClientToolEvent(e){return{eventUid:e.event_uid,sessionId:e.session_id,eventName:e.event_name,eventData:e.event_data,timestamp:e.timestamp,timestampUserAction:e.timestamp_user_action,userActionCorrelationId:e.user_action_correlation_id}}}class Pn{constructor(e,n){this.reasoning_messages=[],this.publicEventEmitter=e,this.internalEventEmitter=n,this.internalEventEmitter.addListener(J.WEBRTC_REASONING_TEXT_MESSAGE_RECEIVED,this.processWebRtcReasoningTextMessageEvent.bind(this))}webRtcTextMessageEventToReasoningStreamEvent(e){return{id:`${e.role}::${e.message_id}`,content:e.content,endOfThought:e.end_of_thought,role:e.role}}processWebRtcReasoningTextMessageEvent(e){const n=this.webRtcTextMessageEventToReasoningStreamEvent(e);this.publicEventEmitter.emit(R.REASONING_STREAM_EVENT_RECEIVED,n);const o={id:n.id,content:n.content,role:n.role},l=this.reasoning_messages.findIndex(s=>s.id===o.id);if(l!==-1){const s=this.reasoning_messages[l];s.content+=o.content,this.reasoning_messages[l]=s}else this.reasoning_messages.push(o);n.endOfThought&&this.publicEventEmitter.emit(R.REASONING_HISTORY_UPDATED,this.reasoning_messages)}}var fe=function(t,e,n,o){function l(s){return s instanceof n?s:new n(function(u){u(s)})}return new(n||(n=Promise))(function(s,u){function c(_){try{p(o.next(_))}catch(d){u(d)}}function E(_){try{p(o.throw(_))}catch(d){u(d)}}function p(_){_.done?s(_.value):l(_.value).then(c,E)}p((o=o.apply(t,e||[])).next())})};class Fn{constructor(e,n,o){var l,s,u,c,E;this.inputAudioState={isMuted:!1,permissionState:de.NOT_REQUESTED},this.sessionId=null,this.organizationId=null,this.streamingClient=null,this._isStreaming=!1;const p=this.validateClientConfig(e,n,o);if(p)throw new $(p,W.CLIENT_ERROR_CODE_CONFIGURATION_ERROR,400);this.personaConfig=n,this.clientOptions=o,(!((l=o?.api)===null||l===void 0)&&l.baseUrl||!((s=o?.api)===null||s===void 0)&&s.apiVersion)&&mn(o.api.baseUrl||Si,o.api.apiVersion||mt),!((c=(u=o?.api)===null||u===void 0?void 0:u.apiGateway)===null||c===void 0)&&c.enabled&&En(o.api.apiGateway),!((E=o?.metrics)===null||E===void 0)&&E.disableClientMetrics&&gn(!0),this.publicEventEmitter=new On,this.internalEventEmitter=new Nn,this.apiClient=new An(e,o?.apiKey,o?.api),this.messageHistoryClient=new xn(this.publicEventEmitter,this.internalEventEmitter),this.reasoningHistoryClient=new Pn(this.publicEventEmitter,this.internalEventEmitter)}decodeJwt(e){try{const n=e.split(".")[1],o=hn.Buffer.from(n,"base64").toString("utf8");return JSON.parse(o)}catch{throw new Error("Invalid session token format")}}validateClientConfig(e,n,o){var l,s;if(!e&&!o?.apiKey)return"Either sessionToken or apiKey must be provided";if(o?.apiKey&&e)return"Only one of sessionToken or apiKey should be used";const u=yn((l=o?.api)===null||l===void 0?void 0:l.apiGateway);if(u)return u;if(e){const c=this.decodeJwt(e);this.organizationId=c.accountId,be({organizationId:this.organizationId});const E=(s=c.type)===null||s===void 0?void 0:s.toLowerCase();if(E==="legacy")return"Legacy session tokens are no longer supported. Please define your persona when creating your session token. See https://docs.anam.ai/resources/migrating-legacy for more information.";if((E==="ephemeral"||E==="stateful")&&n)return"This session token already contains a persona configuration. Please remove the personaConfig parameter."}else if(!n)return"Missing persona config. Persona configuration must be provided when using apiKey";if(o?.voiceDetection){if(o.disableInputAudio)return"Voice detection is disabled because input audio is disabled. Please set disableInputAudio to false to enable voice detection.";if(o.voiceDetection.endOfSpeechSensitivity!==void 0){if(typeof o.voiceDetection.endOfSpeechSensitivity!="number")return"End of speech sensitivity must be a number";if(o.voiceDetection.endOfSpeechSensitivity<0||o.voiceDetection.endOfSpeechSensitivity>1)return"End of speech sensitivity must be between 0 and 1"}}}buildStartSessionOptionsForClient(){var e;const n={};if(!((e=this.clientOptions)===null||e===void 0)&&e.voiceDetection&&(n.voiceDetection=this.clientOptions.voiceDetection),Object.keys(n).length!==0)return n}startSession(e){return fe(this,void 0,void 0,function*(){var n,o,l,s,u,c,E,p,_,d,S,g;const y=this.personaConfig,C=this.buildStartSessionOptionsForClient(),A=yield this.apiClient.startSession(y,C),{sessionId:I,clientConfig:b,engineHost:N,engineProtocol:M,signallingEndpoint:k}=A,{heartbeatIntervalSeconds:Y,maxWsReconnectionAttempts:ne,iceServers:V}=b;this.sessionId=I,be({sessionId:this.sessionId});const re=!((n=this.clientOptions)===null||n===void 0)&&n.iceServers?this.clientOptions.iceServers:V;try{this.streamingClient=new Ln(I,{engine:{baseUrl:`${M}://${N}`},signalling:{heartbeatIntervalSeconds:Y,maxWsReconnectionAttempts:ne,url:{baseUrl:N,protocol:M,signallingPath:k}},iceServers:re,inputAudio:{inputAudioState:this.inputAudioState,userProvidedMediaStream:!((o=this.clientOptions)===null||o===void 0)&&o.disableInputAudio?void 0:e,audioDeviceId:(l=this.clientOptions)===null||l===void 0?void 0:l.audioDeviceId,disableInputAudio:(s=this.clientOptions)===null||s===void 0?void 0:s.disableInputAudio},apiGateway:(c=(u=this.clientOptions)===null||u===void 0?void 0:u.api)===null||c===void 0?void 0:c.apiGateway,metrics:{showPeerConnectionStatsReport:(_=(p=(E=this.clientOptions)===null||E===void 0?void 0:E.metrics)===null||p===void 0?void 0:p.showPeerConnectionStatsReport)!==null&&_!==void 0?_:!1,peerConnectionStatsReportOutputFormat:(g=(S=(d=this.clientOptions)===null||d===void 0?void 0:d.metrics)===null||S===void 0?void 0:S.peerConnectionStatsReportOutputFormat)!==null&&g!==void 0?g:"console"}},this.publicEventEmitter,this.internalEventEmitter)}catch(oe){throw be({sessionId:null}),new $("Failed to initialize streaming client",W.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:oe instanceof Error?oe.message:String(oe),sessionId:I})}return I})}startSessionIfNeeded(e){return fe(this,void 0,void 0,function*(){if((!this.sessionId||!this.streamingClient)&&(yield this.startSession(e),!this.sessionId||!this.streamingClient))throw new $("Session ID or streaming client is not available after starting session",W.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:"Failed to initialize session properly"})})}stream(e){return fe(this,void 0,void 0,function*(){var n;if(this._isStreaming)throw new Error("Already streaming");const o=Ii();return be({attemptCorrelationId:o,sessionId:null}),ge(ie.CLIENT_METRIC_MEASUREMENT_SESSION_ATTEMPT,"1"),!((n=this.clientOptions)===null||n===void 0)&&n.disableInputAudio&&e&&console.warn("AnamClient:Input audio is disabled. User provided audio stream will be ignored."),yield this.startSessionIfNeeded(e),this._isStreaming=!0,new Promise(l=>{var s;const u=[];let c=!1,E=!1;this.publicEventEmitter.addListener(R.VIDEO_STREAM_STARTED,p=>{u.push(p),c=!0,E&&l(u)}),this.publicEventEmitter.addListener(R.AUDIO_STREAM_STARTED,p=>{u.push(p),E=!0,c&&l(u)}),(s=this.streamingClient)===null||s===void 0||s.startConnection()})})}streamToVideoAndAudioElements(e,n,o){return fe(this,void 0,void 0,function*(){console.warn("AnamClient: streamToVideoAndAudioElements is deprecated. To avoid possible audio issues, please use streamToVideoElement instead."),yield this.streamToVideoElement(e,o)})}streamToVideoElement(e,n){return fe(this,void 0,void 0,function*(){var o;const l=Ii();be({attemptCorrelationId:l,sessionId:null}),ge(ie.CLIENT_METRIC_MEASUREMENT_SESSION_ATTEMPT,"1"),!((o=this.clientOptions)===null||o===void 0)&&o.disableInputAudio&&n&&console.warn("AnamClient:Input audio is disabled. User provided audio stream will be ignored.");try{yield this.startSessionIfNeeded(n)}catch(s){throw s instanceof $?s:new $("Failed to start session",W.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:s instanceof Error?s.message:String(s),sessionId:this.sessionId})}if(this._isStreaming)throw new Error("Already streaming");if(this._isStreaming=!0,!this.streamingClient)throw new Error("Failed to stream: streaming client is not available");this.streamingClient.setMediaStreamTargetById(e),this.streamingClient.startConnection()})}talk(e){return fe(this,void 0,void 0,function*(){if(!this.streamingClient)throw new Error("Failed to send talk command: session is not started. Have you called startSession?");if(!this._isStreaming)throw new Error("Failed to send talk command: not currently streaming. Have you called stream?");yield this.streamingClient.sendTalkCommand(e)})}sendDataMessage(e){if(this.streamingClient)this.streamingClient.sendDataMessage(e);else throw new Error("Failed to send message: session is not started.")}sendUserMessage(e){if(!this._isStreaming)throw console.warn("AnamClient: Not currently streaming. User message will not be sent."),new Error("Failed to send user message: not currently streaming");const n=this.getActiveSessionId();if(!n)throw new Error("Failed to send user message: no active session");const o=new Date().toISOString().replace("Z",""),l=JSON.stringify({content:e,timestamp:o,session_id:n,message_type:"speech"});this.sendDataMessage(l)}interruptPersona(){if(!this._isStreaming)throw new Error("Failed to send interrupt command: not currently streaming");const e=this.getActiveSessionId();if(!e)throw new Error("Failed to send interrupt command: no active session");const n=JSON.stringify({message_type:"interrupt",session_id:e,timestamp:new Date().toISOString()});this.sendDataMessage(n)}stopStreaming(){return fe(this,void 0,void 0,function*(){this.streamingClient&&(this.publicEventEmitter.emit(R.CONNECTION_CLOSED,he.NORMAL),yield this.streamingClient.stopConnection(),this.streamingClient=null,this.sessionId=null,be({attemptCorrelationId:null,sessionId:null,organizationId:this.organizationId}),this._isStreaming=!1)})}isStreaming(){return this._isStreaming}setPersonaConfig(e){this.personaConfig=e}getPersonaConfig(){return this.personaConfig}getInputAudioState(){var e;return!((e=this.clientOptions)===null||e===void 0)&&e.disableInputAudio&&console.warn("AnamClient: Audio state will not be used because input audio is disabled."),this.streamingClient&&(this.inputAudioState=this.streamingClient.getInputAudioState()),this.inputAudioState}muteInputAudio(){var e,n;return!((e=this.clientOptions)===null||e===void 0)&&e.disableInputAudio&&console.warn("AnamClient: Input audio is disabled. Muting input audio will have no effect."),this.streamingClient&&!(!((n=this.clientOptions)===null||n===void 0)&&n.disableInputAudio)?this.inputAudioState=this.streamingClient.muteInputAudio():this.inputAudioState=Object.assign(Object.assign({},this.inputAudioState),{isMuted:!0}),this.inputAudioState}unmuteInputAudio(){var e,n;return!((e=this.clientOptions)===null||e===void 0)&&e.disableInputAudio&&console.warn("AnamClient: Input audio is disabled. Unmuting input audio will have no effect."),this.streamingClient&&!(!((n=this.clientOptions)===null||n===void 0)&&n.disableInputAudio)?this.inputAudioState=this.streamingClient.unmuteInputAudio():this.inputAudioState=Object.assign(Object.assign({},this.inputAudioState),{isMuted:!1}),this.inputAudioState}changeAudioInputDevice(e){return fe(this,void 0,void 0,function*(){var n;if(!((n=this.clientOptions)===null||n===void 0)&&n.disableInputAudio)throw new Error("AnamClient: Cannot change audio input device because input audio is disabled.");if(!this._isStreaming)throw new Error("AnamClient: Cannot change audio input device while not streaming. Start streaming first.");if(!this.streamingClient)throw new Error("AnamClient: Cannot change audio input device because streaming client is not available. Start streaming first.");yield this.streamingClient.changeAudioInputDevice(e)})}createTalkMessageStream(e){if(!this.streamingClient)throw new Error("Failed to start talk message stream: session is not started.");if(e&&e.trim()==="")throw new Error("Failed to start talk message stream: correlationId is empty");return this.streamingClient.startTalkMessageStream(e)}createAgentAudioInputStream(e){if(!this.streamingClient)throw new Error("Failed to create agent audio input stream: session is not started.");return this.streamingClient.createAgentAudioInputStream(e)}addListener(e,n){this.publicEventEmitter.addListener(e,n)}removeListener(e,n){this.publicEventEmitter.removeListener(e,n)}getActiveSessionId(){return this.sessionId}}const $n=(t,e)=>new Fn(t,void 0,e),Vn="https://api.anam.ai";function Ai(t){return/^[a-zA-Z0-9_-]{1,128}$/.test(t)}function Gn(t){try{const e=t.split(".")[1];return JSON.parse(atob(e))}catch{return{}}}function jn(t,e){return e===401||e===403?"This agent is not authorized. Check your agent ID.":e===404?"Agent not found. Check your agent ID.":e===429?"Too many requests. Please wait a moment.":e&&e>=500?"Server error. Please try again later.":t instanceof TypeError&&t.message==="Failed to fetch"?"Unable to connect. Check your network connection.":t instanceof Error&&t.message.length<80?t.message:"Something went wrong. Please try again."}function Wn(){return{client:z(null),connectionStatus:z("idle"),isStreaming:z(!1),isMuted:z(!1),messages:z([]),error:z(null),sessionId:z(null),avatarThumbnailUrl:z(null),avatarVideoUrl:z(null),personaName:z(null),serverConfig:z(null),isConfigured:z(!1),isReady:z(!1),generation:0}}async function Hn(t,e,n){if(t.isReady.value=!1,!Ai(e)){console.error("[AnamWidget] Invalid agent ID format:",e);return}try{const o=await fetch(`${n}/v1/personas/${e}/widget`);if(!o.ok){const s=o.status===404?"Agent not found. Check your agent ID.":o.status===401||o.status===403?"Not authorized. Check your agent ID.":"Server error. Please try again later.";console.error(`[AnamWidget] Failed to load widget config: ${s}`);return}const l=await o.json();t.avatarThumbnailUrl.value=l.persona?.avatarImageUrl||null,t.avatarVideoUrl.value=l.persona?.avatarVideoUrl||null,t.personaName.value=l.persona?.name||null,t.serverConfig.value=l.widgetConfig||null,t.isReady.value=!0}catch(o){console.error("[AnamWidget] Failed to load widget config:",o)}}async function zn(t,e,n,o,l){if(t.connectionStatus.value==="connecting"||t.connectionStatus.value==="connected")return;const s=++t.generation;t.connectionStatus.value="connecting",t.error.value=null;let u;try{let c;if(l)console.log("[AnamWidget] Using pre-created session token"),c=l;else{if(!Ai(e))throw new Error("Invalid agent ID format");console.log("[AnamWidget] Fetching session for agent:",e);const _=await fetch(`${n}/v1/auth/widget`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:e})});if(s!==t.generation)return;if(u=_.status,!_.ok){const S=await _.json().catch(()=>({}));throw new Error(S.error||`HTTP ${_.status}`)}const d=await _.json();console.log("[AnamWidget] Got session from agent-id:",{hasToken:!!d.sessionToken}),c=d.sessionToken}if(s!==t.generation)return;const E=$n(c,{api:n?{baseUrl:n}:void 0,metrics:{disableClientMetrics:!0}});E.addListener(R.CONNECTION_ESTABLISHED,()=>{s===t.generation&&(console.log("[AnamWidget] Connection established"),t.connectionStatus.value="connected")}),E.addListener(R.VIDEO_STREAM_STARTED,()=>{s===t.generation&&(console.log("[AnamWidget] Video stream started"),t.isStreaming.value=!0)}),E.addListener(R.AUDIO_STREAM_STARTED,()=>{console.log("[AnamWidget] Audio stream started")}),E.addListener(R.MESSAGE_HISTORY_UPDATED,_=>{s===t.generation&&(t.messages.value=[..._])}),E.addListener(R.CONNECTION_CLOSED,(_,d)=>{s===t.generation&&(console.log("[AnamWidget] Connection closed:",_,d),t.connectionStatus.value="idle",t.isStreaming.value=!1,t.sessionId.value=null)}),E.addListener(R.SESSION_READY,_=>{s===t.generation&&(console.log("[AnamWidget] Session ready:",_),t.sessionId.value=_)});const p=await E.stream();if(s!==t.generation){try{await E.stopStreaming()}catch{}return}if(t.client.value=E,o&&p.length>0){const _=p.find(d=>d.getVideoTracks().length>0);_&&(o.srcObject=_)}}catch(c){if(s!==t.generation)return;console.error("[AnamWidget] Failed to start session:",c),t.error.value=jn(c,u),t.connectionStatus.value="error",t.client.value=null}}async function qn(t){if(t.generation++,t.client.value)try{await t.client.value.stopStreaming()}catch(e){console.error("[AnamWidget] Failed to stop session:",e)}t.client.value=null,t.connectionStatus.value="idle",t.isStreaming.value=!1,t.isMuted.value=!1,t.messages.value=[]}function Yn(t,e){!t.client.value||t.connectionStatus.value!=="connected"||t.client.value.sendUserMessage(e)}function Kn(t){t.client.value&&(t.isMuted.value?(t.client.value.unmuteInputAudio(),t.isMuted.value=!1):(t.client.value.muteInputAudio(),t.isMuted.value=!0))}function Jn(t){t.generation++,t.client.value?.isStreaming()&&t.client.value.stopStreaming(),t.client.value=null,t.connectionStatus.value="idle",t.isStreaming.value=!1,t.isMuted.value=!1,t.messages.value=[],t.error.value=null,t.sessionId.value=null,t.avatarThumbnailUrl.value=null,t.avatarVideoUrl.value=null,t.personaName.value=null,t.serverConfig.value=null}function Xn(t,e,n){const o=He();o.current||(o.current=Wn());const l=o.current,s=t||(n?Gn(n).personaId:void 0),u=!!s||!!n;l.isConfigured.value!==u&&(l.isConfigured.value=u);const c=e||Vn;return{connectionStatus:l.connectionStatus,isStreaming:l.isStreaming,isMuted:l.isMuted,messages:l.messages,error:l.error,sessionId:l.sessionId,isConfigured:l.isConfigured,isReady:l.isReady,avatarThumbnailUrl:l.avatarThumbnailUrl,avatarVideoUrl:l.avatarVideoUrl,personaName:l.personaName,serverConfig:l.serverConfig,fetchWidgetConfig:()=>{if(!s){l.isReady.value=!0;return}Hn(l,s,c)},startSession:E=>!s&&!n?(l.error.value="No agent ID or session token configured",Promise.resolve()):zn(l,s||"",c,E,n),stopSession:()=>qn(l),sendMessage:E=>Yn(l,E),toggleMute:()=>Kn(l),cleanup:()=>Jn(l)}}const Zn='@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-outline-style:solid}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.visible{visibility:visible}.block{display:block}.flex{display:flex}.inline{display:inline}.flex-shrink{flex-shrink:1}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.border{border-style:var(--tw-border-style);border-width:1px}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}}:host{--anam-trigger-size:80px;--anam-sheet-width:400px;--anam-sheet-height:640px;all:initial;color:#18181b;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:DM Sans,system-ui,-apple-system,sans-serif;font-size:15px;line-height:1.5}@media(max-width:640px){:host{--anam-trigger-size:72px;--anam-sheet-width: calc(100vw - 24px) ;--anam-sheet-height: calc(100dvh - 100px) }}.anam-widget{z-index:9999;font-family:inherit}.anam-widget[data-layout=floating]{position:fixed}.anam-widget[data-layout=inline]{position:relative}.anam-trigger{width:var(--anam-trigger-size);height:var(--anam-trigger-size);cursor:pointer;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;transition:all .25s cubic-bezier(.4,0,.2,1);display:flex;overflow:hidden;box-shadow:0 2px 8px #00000014,0 8px 24px -4px #0000002e}.anam-trigger:hover{transform:scale(1.06);box-shadow:0 4px 12px #0000001a,0 12px 32px -4px #00000040}.anam-trigger:active{transform:scale(.97)}.anam-trigger img{object-fit:cover;width:100%;height:100%;display:block}.anam-sheet{width:var(--anam-sheet-width);aspect-ratio:16/10;max-height:var(--anam-sheet-height);border-radius:8px;animation:.25s cubic-bezier(.16,1,.3,1) sheetIn;position:relative;overflow:hidden;box-shadow:0 32px 64px -16px #00000040,0 0 0 1px #00000014}.anam-widget[data-layout=inline] .anam-sheet{aspect-ratio:3/2;border-radius:8px;width:100%;max-height:none;animation:none}@keyframes sheetIn{0%{opacity:0;transform:translateY(8px)scale(.97)}to{opacity:1;transform:translateY(0)scale(1)}}.anam-video{object-fit:cover;background:#000;width:100%;height:100%;display:block;position:absolute;inset:0}.anam-video[data-hidden=true]{visibility:hidden}.anam-overlay-idle{z-index:2;position:absolute;inset:0}.anam-overlay-idle img{object-fit:cover;width:100%;height:100%;display:block}.anam-preview-video{object-fit:cover;z-index:1;width:100%;height:100%;display:block;position:absolute;inset:0}.anam-preview-fallback{z-index:0;position:absolute;inset:0}.anam-cta-pill{z-index:2;-webkit-backdrop-filter:blur(12px);color:#2a2220;letter-spacing:-.01em;cursor:pointer;white-space:nowrap;background:#ffffff8c;border:none;border-radius:999px;justify-content:center;align-items:center;gap:10px;padding:14px 28px;font-family:inherit;font-size:18px;font-weight:600;transition:all .2s;display:flex;position:absolute;bottom:20px;left:50%;transform:translate(-50%)}.anam-cta-pill:hover{background:#ffffffb3;transform:translate(-50%)scale(1.03)}.anam-cta-pill:active{transform:translate(-50%)scale(.98)}.anam-cta-pill svg{flex-shrink:0;transform:translateY(-1px)}.anam-overlay-unconfigured{z-index:2;background:#111;flex-direction:column;justify-content:center;align-items:center;gap:16px;display:flex;position:absolute;inset:0}.anam-overlay-unconfigured span{color:#ffffff59;letter-spacing:-.01em;font-size:14px;font-weight:400}.anam-overlay-loading{z-index:3;background:#000;flex-direction:column;justify-content:center;align-items:center;gap:20px;display:flex;position:absolute;inset:0}.anam-overlay-loading span{color:#fffc;letter-spacing:-.01em;font-size:15px;font-weight:400}.anam-overlay-error{z-index:3;background:#000;flex-direction:column;justify-content:center;align-items:center;gap:16px;display:flex;position:absolute;inset:0}.anam-overlay-error-text{color:#fff9;text-align:center;max-width:260px;font-size:14px;line-height:1.5}.anam-overlay-error .anam-retry-btn{-webkit-backdrop-filter:blur(8px);color:#fff;cursor:pointer;background:#ffffff1f;border:1px solid #ffffff1a;border-radius:999px;padding:10px 24px;font-family:inherit;font-size:14px;font-weight:500;transition:background .15s}.anam-overlay-error .anam-retry-btn:hover{background:#fff3}.anam-spinner{border:2.5px solid #ffffff1f;border-top-color:#fff;border-radius:50%;width:32px;height:32px;animation:.75s linear infinite spin}@keyframes spin{to{transform:rotate(360deg)}}.anam-close-btn{z-index:10;-webkit-backdrop-filter:blur(12px);color:#2a2220;cursor:pointer;background:#ffffff8c;border:none;border-radius:50%;justify-content:center;align-items:center;width:28px;height:28px;padding:0;transition:background .15s;display:flex;position:absolute;top:12px;right:12px}.anam-close-btn:hover{background:#ffffffb3}.anam-toast{z-index:10;-webkit-backdrop-filter:blur(16px);color:#18181b;letter-spacing:-.01em;white-space:nowrap;text-overflow:ellipsis;pointer-events:none;background:#ffffffeb;border:1px solid #00000014;border-radius:999px;max-width:85%;padding:10px 22px;font-size:14px;font-weight:400;animation:.25s cubic-bezier(.16,1,.3,1) toastIn;position:absolute;bottom:80px;left:50%;overflow:hidden;transform:translate(-50%)}.anam-toast-out{animation:.4s forwards toastOut}@keyframes toastIn{0%{opacity:0;transform:translate(-50%)translateY(6px)}to{opacity:1;transform:translate(-50%)translateY(0)}}@keyframes toastOut{0%{opacity:1}to{opacity:0}}.anam-control-bar{z-index:10;background:0 0;justify-content:center;align-items:center;gap:8px;padding:0;display:flex;position:absolute;bottom:12px;left:12px;right:12px}.anam-ctl-btn{-webkit-backdrop-filter:blur(12px);color:#2a2220;cursor:pointer;background:#ffffff8c;border:none;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:44px;height:44px;padding:0;transition:background .15s;display:flex}.anam-ctl-btn:hover{background:#ffffffb3}.anam-ctl-btn:disabled{opacity:.35;cursor:not-allowed}.anam-ctl-input-wrap{flex:1;align-items:center;min-width:0;display:flex;position:relative}.anam-ctl-input{-webkit-backdrop-filter:blur(12px);color:#2a2220;background:#ffffff8c;border:none;border-radius:999px;outline:none;width:100%;padding:11px 44px 11px 18px;font-family:inherit;font-size:14px;transition:background .15s}.anam-ctl-input::placeholder{color:#2a222080}.anam-ctl-input:focus{background:#ffffffb3}.anam-ctl-input:disabled{opacity:.35;cursor:not-allowed}.anam-ctl-send{color:#2a222080;cursor:pointer;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;width:32px;height:32px;padding:0;transition:color .15s;display:flex;position:absolute;right:6px}.anam-ctl-send:hover{color:#2a2220}.anam-ctl-send:disabled{opacity:.35;cursor:not-allowed}.anam-watermark{z-index:11;opacity:.5;line-height:0;text-decoration:none;transition:opacity .15s;position:absolute;top:16px;left:16px}.anam-watermark:hover{opacity:.8}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}';class Qn extends ye{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("[AnamWidget] Render error:",e)}render(){return this.state.hasError?w("div",{class:"anam-overlay-error",children:w("div",{class:"anam-overlay-error-text",children:"Widget failed to load"})}):this.props.children}}function vt(t,e){const n={...t};for(const o of Object.keys(e)){const l=e[o];l!==void 0&&(l!==null&&typeof l=="object"&&!Array.isArray(l)&&typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])?n[o]=vt(n[o],l):n[o]=l)}return n}function yt(t){if(t!==void 0)return t==="true"}function er(t){const e={};t.layout&&(e.layout=t.layout),t["initial-state"]&&(e.initialState=t["initial-state"]),t.position&&(e.position=t.position);const n=yt(t["ui-mute-button"]);n!==void 0&&(e.showMuteButton=n);const o=yt(t["ui-text-input"]);o!==void 0&&(e.showTextInput=o);const l=yt(t["ui-captions"]);return l!==void 0&&(e.showCaptions=l),t["call-to-action"]&&(e.callToAction=t["call-to-action"]),e}const tr=()=>w("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round",children:w("path",{d:"M18 6L6 18M6 6l12 12"})}),ir=()=>w("svg",{width:"24",height:"24",viewBox:"0 0 640 640",fill:"currentColor",children:w("path",{d:"M187.2 100.9C174.8 94.1 159.8 94.4 147.6 101.6C135.4 108.8 128 121.9 128 136L128 504C128 518.1 135.5 531.2 147.6 538.4C159.7 545.6 174.8 545.9 187.2 539.1L523.2 355.1C536 348.1 544 334.6 544 320C544 305.4 536 291.9 523.2 284.9L187.2 100.9z"})}),nr=()=>w("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round",children:[w("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"}),w("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),w("line",{x1:"12",y1:"19",x2:"12",y2:"22"})]}),rr=()=>w("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round",children:[w("line",{x1:"1",y1:"1",x2:"23",y2:"23"}),w("path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12M15 9.34V5a3 3 0 0 0-5.94-.6"}),w("path",{d:"M17 16.95A7 7 0 0 1 5 12v-2m14 0v2c0 .87-.16 1.71-.46 2.49"}),w("line",{x1:"12",y1:"19",x2:"12",y2:"22"})]}),or=()=>w("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round",children:[w("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),w("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}),St=()=>w("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",style:{opacity:.3},children:[w("circle",{cx:"24",cy:"18",r:"8",stroke:"white","stroke-width":"2",fill:"none"}),w("path",{d:"M8 42c0-8.837 7.163-16 16-16s16 7.163 16 16",stroke:"white","stroke-width":"2",fill:"none"})]});function sr({config:t,session:e,videoRef:n,avatarSrc:o,avatarVideoSrc:l,displayCta:s,onCollapse:u,onStop:c}){const E=He(null),[p,_]=je(""),[d,S]=je(null),[g,y]=je(!1),C=He(null),A=e.connectionStatus.value==="connected",I=e.connectionStatus.value==="connecting",b=e.connectionStatus.value==="error",N=e.isStreaming.value,M=!I&&!A&&!b,k=ct(async()=>{n.current&&await e.startSession(n.current)},[e.startSession]),Y=ct(()=>{if(!p.trim())return;const V=p.trim();e.sendMessage(V),_(""),E.current?.focus(),C.current&&clearTimeout(C.current),y(!1),S(V),C.current=window.setTimeout(()=>{y(!0),C.current=window.setTimeout(()=>{S(null),y(!1)},400)},2600)},[p]),ne=ct(V=>{V.key==="Enter"&&!V.shiftKey&&(V.preventDefault(),Y())},[Y]);return We(()=>()=>{C.current&&clearTimeout(C.current)},[]),w("div",{class:"anam-sheet",children:[w("video",{ref:n,class:"anam-video",autoplay:!0,playsinline:!0,"data-hidden":N?void 0:"true"}),M&&(e.isConfigured.value?w("div",{class:"anam-overlay-idle",children:[l?w("video",{src:l,autoplay:!0,loop:!0,muted:!0,playsinline:!0,class:"anam-preview-video",onError:V=>{V.target.style.display="none"}}):null,o?w("img",{src:o,alt:"Avatar",class:l?"anam-preview-fallback":void 0}):w(St,{}),w("button",{class:"anam-cta-pill",onClick:k,children:[w(ir,{}),s]})]}):w("div",{class:"anam-overlay-unconfigured",children:[w(St,{}),w("span",{children:"Agent not configured"})]})),I&&w("div",{class:"anam-overlay-loading",children:[w("span",{class:"anam-spinner"}),w("span",{children:"Starting your conversation..."})]}),b&&w("div",{class:"anam-overlay-error",children:[w("div",{class:"anam-overlay-error-text",children:e.error.value||"Something went wrong"}),w("button",{class:"anam-retry-btn",onClick:k,children:"Try Again"})]}),(u||c&&(A||I||N))&&w("button",{class:"anam-close-btn",onClick:u||c,"aria-label":u?"Close":"End call",children:w(tr,{})}),(A||N)&&w(ae,{children:[d&&w("div",{class:`anam-toast ${g?"anam-toast-out":""}`,children:d}),w("div",{class:"anam-control-bar",children:[t.showMuteButton&&w("button",{class:`anam-ctl-btn ${e.isMuted.value?"anam-ctl-btn-muted":""}`,onClick:()=>e.toggleMute(),"aria-label":e.isMuted.value?"Unmute":"Mute",children:e.isMuted.value?w(rr,{}):w(nr,{})}),t.showTextInput&&w("div",{class:"anam-ctl-input-wrap",children:[w("input",{ref:E,type:"text",class:"anam-ctl-input",placeholder:"Type a message...",value:p,onInput:V=>_(V.target.value),onKeyDown:ne,disabled:!A}),w("button",{class:"anam-ctl-send",onClick:Y,disabled:!A||!p.trim(),"aria-label":"Send message",children:w(or,{})})]})]})]}),!t.removeWatermark&&w("a",{class:"anam-watermark",href:"https://anam.ai",target:"_blank",rel:"noopener noreferrer",children:w("svg",{width:"48",height:"16",viewBox:"0 0 86 29",fill:"white",xmlns:"http://www.w3.org/2000/svg",children:[w("path",{d:"M18.1491 28.1986L16.2127 21.63L6.3408 21.63L4.40439 28.1986H0L9.03659 -1.79687L13.4789 -1.79687L22.5535 28.1986H18.1491ZM7.47986 17.8331L15.0736 17.8331L11.2767 4.96161L7.47986 17.8331Z"}),w("path",{d:"M24.7666 28.1984L24.7666 7.69518L39.5745 7.69518V28.1984L35.3979 28.1984V11.4921L28.9432 11.4921L28.9432 28.1984H24.7666Z"}),w("path",{d:"M61.0239 28.1984V7.69518L85.7037 7.69518V28.1984H81.5271V11.4921L75.4521 11.4921V28.1984L71.2755 28.1984V11.4921L65.2005 11.4921V28.1984H61.0239Z"}),w("path",{d:"M42.8948 7.69518L57.7026 7.69518V28.1984L53.5261 28.1984V27.1353C52.4629 28.0466 51.0201 28.5781 49.3495 28.5781C45.4007 28.5781 42.8948 25.7305 42.8948 21.2501C42.8948 16.8457 45.4007 14.074 49.3495 14.074C51.0201 14.074 52.4629 14.5676 53.5261 15.4788V11.3022L42.8948 11.3022V7.69518ZM50.4885 24.7812C52.6148 24.7812 53.9437 23.4143 53.9057 21.2501C53.8678 19.0859 52.5389 17.681 50.4885 17.681C48.4003 17.681 47.0713 19.0859 47.0713 21.2501C47.0713 23.4143 48.4003 24.7812 50.4885 24.7812Z"})]})})]})}function ar(t){return w(ae,{children:[w("style",{children:Zn}),w(Qn,{children:w(lr,{...t})})]})}function lr(t){const e=He(null);t["agent-id"]&&t["session-token"]&&console.warn("[AnamWidget] Both agent-id and session-token are set. Use one or the other. Ignoring agent-id.");const n=t["session-token"]?void 0:t["agent-id"],o=Xn(n,t["api-base-url"],t["session-token"]);We(()=>()=>{o.cleanup()},[]);const l=we(()=>er(t),[t.layout,t["initial-state"],t.position,t["ui-mute-button"],t["ui-text-input"],t["ui-captions"],t["call-to-action"]]),s=we(()=>{const I=o.serverConfig.value;return vt(vt({...pt},I??{}),l)},[o.serverConfig.value,l]),u=_i(s.layout==="floating"?s.initialState:"expanded");We(()=>{s.layout==="inline"?u.value="expanded":u.value=s.initialState},[s.layout,s.initialState]),We(()=>{o.fetchWidgetConfig()},[n,t["api-base-url"],t["session-token"]]);const c=t["avatar-url"]||o.avatarThumbnailUrl.value||null,E=t["avatar-video-url"]||o.avatarVideoUrl.value||null,_=t["agent-name"]||o.personaName.value,d=s.callToAction===pt.callToAction&&_?`Talk to ${_}`:s.callToAction,S=we(()=>{if(s.layout==="inline")return"";const I=ln(s.position);return Object.entries(I).map(([b,N])=>`${b}: ${N}`).join("; ")},[s.layout,s.position]),g=s.layout==="floating",y=()=>{u.value="expanded"},C=async()=>{o.connectionStatus.value!=="idle"&&await o.stopSession(),u.value="minimized"},A=g?u.value==="expanded":!0;return o.isReady.value?w("div",{class:"anam-widget","data-layout":s.layout,"data-state":u.value,style:S,children:[g&&u.value==="minimized"&&w("button",{class:"anam-trigger",onClick:y,"aria-label":d,children:c?w("img",{src:c,alt:"Avatar"}):w(St,{})}),A&&w(sr,{config:s,session:o,videoRef:e,avatarSrc:c,avatarVideoSrc:E,displayCta:d,onCollapse:g?C:null,onStop:g?null:()=>o.stopSession()})]}):null}const cr=["agent-id","api-base-url","session-token","layout","initial-state","position","ui-mute-button","ui-text-input","ui-captions","call-to-action","avatar-url","avatar-video-url","agent-name"],ur={SESSION_STARTED:"anam-agent:session-started",SESSION_ENDED:"anam-agent:session-ended",MESSAGE_RECEIVED:"anam-agent:message-received",MESSAGE_SENT:"anam-agent:message-sent",EXPANDED:"anam-agent:expanded",COLLAPSED:"anam-agent:collapsed",ERROR:"anam-agent:error",MIC_MUTED:"anam-agent:mic-muted",MIC_UNMUTED:"anam-agent:mic-unmuted"};function wt(t="anam-agent"){Wi(ar,t,[...cr],{shadow:!0})}typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>wt()):wt()),se.DefaultConfig=pt,se.WidgetEventNames=ur,se.registerWidget=wt,Object.defineProperty(se,Symbol.toStringTag,{value:"Module"})}));
