@helpai/elements 0.63.2 → 0.63.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,11 +4,11 @@ var gd=Object.defineProperty;var hd=(e,t,n)=>t in e?gd(e,t,{enumerable:!0,config
4
4
  `;var Gi=`.__P__-standalone-page{margin:0;height:100vh;background:var(--__P__-bg, #fff);display:grid;place-items:stretch}
5
5
  `;var Ki=`:host([data-mode="page"]){min-height:0}:host([data-mode="page"]) .__P__-page-shell{display:grid;grid-template-columns:280px 1fr;width:100%;height:100%;min-height:0;background:var(--__P__-bg);color:var(--__P__-fg);transition:grid-template-columns var(--__P__-dur-base) var(--__P__-ease-in-out)}:host([data-mode="page"]) .__P__-page-shell[data-sidebar-collapsed=true]{grid-template-columns:48px 1fr}:host([data-mode="page"]) .__P__-page-chat{display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden}:host([data-mode="page"]) .__P__-anchor{position:static;inset:auto;padding:0;align-items:stretch;width:100%;height:100%;min-width:0;min-height:0;flex:1 1 0}:host([data-mode="page"]) .__P__-panel{width:100%;height:100%;min-width:0;min-height:0;max-width:none;max-height:none;border-radius:0;border:0;box-shadow:none;animation:none}:host([data-mode="page"]) .__P__-sidebar{border-inline-end:1px solid var(--__P__-border);display:flex;flex-direction:column;overflow:hidden;background:var(--__P__-surface)}:host([data-mode="page"]) .__P__-sidebar-header{padding:var(--__P__-space-4) var(--__P__-space-5);border-bottom:1px solid var(--__P__-border);display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-2);min-height:56px;box-sizing:border-box}:host([data-mode="page"]) .__P__-sidebar[data-collapsed=true] .__P__-sidebar-header{padding:var(--__P__-space-4) var(--__P__-space-2);justify-content:center}:host([data-mode="page"]) .__P__-sidebar[data-collapsed=true] .__P__-sidebar-logo,:host([data-mode="page"]) .__P__-sidebar[data-collapsed=true] .__P__-sidebar-title{display:none}:host([data-mode="page"]) .__P__-sidebar-toggle{flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:1px solid var(--__P__-border);border-radius:6px;background:transparent;color:var(--__P__-fg);cursor:pointer;transition:background .12s,border-color .12s}:host([data-mode="page"]) .__P__-sidebar-toggle:hover{background:var(--__P__-hover);border-color:var(--__P__-accent)}:host([data-mode="page"]) .__P__-sidebar-toggle:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px}:host([data-mode="page"]) .__P__-sidebar-logo{height:32px;display:block}:host([data-mode="page"]) .__P__-sidebar-title{font-size:var(--__P__-text-md);font-weight:600}:host([data-mode="page"]) .__P__-sidebar-section{padding:var(--__P__-space-3) var(--__P__-space-4);border-bottom:1px solid var(--__P__-border)}:host([data-mode="page"]) .__P__-sidebar-nav{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}:host([data-mode="page"]) .__P__-sidebar-nav-item{display:flex;align-items:center;gap:10px;padding:var(--__P__-space-2) var(--__P__-space-3);border-radius:var(--__P__-radius-sm);color:var(--__P__-fg);text-decoration:none;font-size:calc(14px * var(--__P__-text-scale));transition:background var(--__P__-dur-quick) var(--__P__-ease-out)}:host([data-mode="page"]) .__P__-sidebar-nav-item:hover{background:var(--__P__-hover)}:host([data-mode="page"]) .__P__-sidebar-nav-item:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}:host([data-mode="page"]) .__P__-sidebar-cards{display:grid;grid-template-columns:1fr;gap:var(--__P__-space-2)}:host([data-mode="page"]) .__P__-sidebar-card{display:block;padding:10px 12px;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm);text-decoration:none;color:var(--__P__-fg);transition:border-color var(--__P__-dur-quick) var(--__P__-ease-out)}:host([data-mode="page"]) .__P__-sidebar-card:hover{border-color:var(--__P__-accent)}:host([data-mode="page"]) .__P__-sidebar-card:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}:host([data-mode="page"]) .__P__-sidebar-card-label{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}:host([data-mode="page"]) .__P__-sidebar-card-desc{font-size:var(--__P__-text-xs);color:var(--__P__-muted);margin-top:2px}:host([data-mode="page"]) .__P__-sidebar-conversations{flex:1 1 auto;overflow-y:auto;padding:var(--__P__-space-3) var(--__P__-space-4)}:host([data-mode="page"]) .__P__-page-chat{display:flex;flex-direction:column;overflow:hidden}@media(max-width:768px){:host([data-mode="page"]) .__P__-page-shell{grid-template-columns:1fr}:host([data-mode="page"]) .__P__-sidebar{display:none}}
6
6
  `;var __="helpai",u_="#5B5BD6",p_="#FFFFFF",m_="12px",f_="Inter, system-ui, -apple-system, 'Segoe UI', sans-serif",Vr=[qi,Vi,Wi,Gi,Ki].join(`
7
- `).replace(/__P__/g,__).replaceAll("__BRAND_ACCENT_TEXT__",p_).replaceAll("__BRAND_ACCENT__",u_).replaceAll("__BRAND_RADIUS__",m_).replaceAll("__BRAND_FONT__",f_);var g_=ee.scope("mount"),ji=new WeakMap,Xi={floating:"all: initial; position: fixed; z-index: 2147483600;",flow:"all: initial; display: block; position: relative; width: 100%; height: 100%; z-index: 1; contain: size;",viewport:"all: initial; display: block; position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1;"};function Yi(e,t){e.style.cssText=Xi[t]}function io(e){return e==="floating"||e==="modal"||e==="drawer"?"floating":e==="standalone"||e==="page"?"viewport":"flow"}function Ji(e={}){let t=e.position??"flow";g_.debug("createShadowMount",{position:t,hasTarget:!!e.target,hasHost:!!e.existingHost});let n=`${x.cssPrefix}-chat-host`;typeof customElements<"u"&&!customElements.get(n)&&customElements.define(n,class extends HTMLElement{});let o;e.existingHost?o=e.existingHost:(o=document.createElement(n),(e.target??document.body).appendChild(o)),o.setAttribute("data-brand",x.id),o.style.cssText=Xi[t];let a=o.shadowRoot??o.attachShadow({mode:"open"}),i=o.ownerDocument;if(!h_(a,i)){let s=i.createElement("style");s.textContent=Vr,a.appendChild(s)}let l=document.createElement("div");return l.className=`${x.cssPrefix}-app`,a.appendChild(l),{appRoot:l,destroy:()=>o.remove(),hostElement:o,shadowRoot:a}}function h_(e,t){if(!("adoptedStyleSheets"in e))return!1;let n=t.defaultView;if(!n||typeof n.CSSStyleSheet!="function")return!1;let o=ji.get(t);if(!o)try{o=new n.CSSStyleSheet,o.replaceSync(Vr),ji.set(t,o)}catch{return!1}try{return e.adoptedStyleSheets=[o],!0}catch{return!1}}function v_(e,t){let n=x.cssPrefix;t.accent&&e.style.setProperty(`--${n}-accent-user`,t.accent),t.accentText&&e.style.setProperty(`--${n}-accent-text-user`,t.accentText),t.radius&&e.style.setProperty(`--${n}-radius`,t.radius),t.fontFamily&&e.style.setProperty(`--${n}-font`,t.fontFamily),t.contentMaxWidth&&e.style.setProperty(`--${n}-conversation-max`,t.contentMaxWidth)}function b_(e,t){e.dataset.theme=t}function P_(e,t){let n=x.cssPrefix;t.width!==void 0&&e.style.setProperty(`--${n}-panel-w`,t.width),t.height!==void 0&&e.style.setProperty(`--${n}-panel-h`,t.height),t.expanded?.width!==void 0&&e.style.setProperty(`--${n}-expanded-w`,t.expanded.width),t.expanded?.height!==void 0&&e.style.setProperty(`--${n}-expanded-h`,t.expanded.height),t.inset!==void 0&&e.style.setProperty(`--${n}-panel-inset`,t.inset)}function y_(e,t){e.dataset.position=t}function so(e,t){e.dataset.mode=t}function Qi(e,t){b_(e,t.themeMode),v_(e,t.themeOverrides),y_(e,t.position),P_(e,t.size)}var qt,he,Wr,Zi,pn=0,ss=[],ye=te,es=ye.__b,ts=ye.__r,ns=ye.diffed,os=ye.__c,rs=ye.unmount,as=ye.__;function co(e,t){ye.__h&&ye.__h(he,e,pn||t),pn=0;var n=he.__H||(he.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function R(e){return pn=1,x_(ls,e)}function x_(e,t,n){var o=co(qt++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):ls(void 0,t),function(s){var c=o.__N?o.__N[0]:o.__[0],_=o.t(c,s);c!==_&&(o.__N=[_,o.__[1]],o.__c.setState({}))}],o.__c=he,!he.__f)){var a=function(s,c,_){if(!o.__c.__H)return!0;var p=!1,v=o.__c.props!==s;if(o.__c.__H.__.some(function(f){if(f.__N){p=!0;var m=f.__[0];f.__=f.__N,f.__N=void 0,m!==f.__[0]&&(v=!0)}}),i){var u=i.call(this,s,c,_);return p?u||v:u}return!p||v};he.__f=!0;var i=he.shouldComponentUpdate,l=he.componentWillUpdate;he.componentWillUpdate=function(s,c,_){if(this.__e){var p=i;i=void 0,a(s,c,_),i=p}l&&l.call(this,s,c,_)},he.shouldComponentUpdate=a}return o.__N||o.__}function T(e,t){var n=co(qt++,3);!ye.__s&&Kr(n.__H,t)&&(n.__=e,n.u=t,he.__H.__h.push(n))}function xt(e,t){var n=co(qt++,4);!ye.__s&&Kr(n.__H,t)&&(n.__=e,n.u=t,he.__h.push(n))}function N(e){return pn=5,De(function(){return{current:e}},[])}function De(e,t){var n=co(qt++,7);return Kr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function $(e,t){return pn=8,De(function(){return e},t)}function S_(){for(var e;e=ss.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(lo),t.__h.some(Gr),t.__h=[]}catch(n){t.__h=[],ye.__e(n,e.__v)}}}ye.__b=function(e){he=null,es&&es(e)},ye.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),as&&as(e,t)},ye.__r=function(e){ts&&ts(e),qt=0;var t=(he=e.__c).__H;t&&(Wr===he?(t.__h=[],he.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(lo),t.__h.some(Gr),t.__h=[],qt=0)),Wr=he},ye.diffed=function(e){ns&&ns(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ss.push(t)!==1&&Zi===ye.requestAnimationFrame||((Zi=ye.requestAnimationFrame)||k_)(S_)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Wr=he=null},ye.__c=function(e,t){t.some(function(n){try{n.__h.some(lo),n.__h=n.__h.filter(function(o){return!o.__||Gr(o)})}catch(o){t.some(function(a){a.__h&&(a.__h=[])}),t=[],ye.__e(o,n.__v)}}),os&&os(e,t)},ye.unmount=function(e){rs&&rs(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(o){try{lo(o)}catch(a){t=a}}),n.__H=void 0,t&&ye.__e(t,n.__v))};var is=typeof requestAnimationFrame=="function";function k_(e){var t,n=function(){clearTimeout(o),is&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);is&&(t=requestAnimationFrame(n))}function lo(e){var t=he,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),he=t}function Gr(e){var t=he;e.__c=e.__(),he=t}function Kr(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function ls(e,t){return typeof t=="function"?t(e):t}var w_=Symbol.for("preact-signals");function mo(){if(it>1)it--;else{var e,t=!1;for((function(){var a=uo;for(uo=void 0;a!==void 0;){var i=a.S;if(i.v===a.v)for(var l=i.t;l!==void 0;l=l.x)l.i===a.i&&(l.i=i.i);a=a.o}})();fn!==void 0;){var n=fn;for(fn=void 0,_o++;n!==void 0;){var o=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&ds(n))try{n.c()}catch(a){t||(e=a,t=!0)}n=o}}if(_o=0,it--,t)throw e}}function Vt(e){if(it>0)return e();jr=++C_,it++;try{return e()}finally{mo()}}var mn,ue=void 0;function gn(e){var t=ue,n=mn;ue=void 0,mn=void 0;try{return e()}finally{ue=t,mn=n}}var fn=void 0,it=0,_o=0,C_=0,jr=0,uo=void 0,po=0;function cs(e){if(ue!==void 0){var t=e.n;if(t===void 0||t.t!==ue)return t={i:0,S:e,p:ue.s,n:void 0,t:ue,e:void 0,x:void 0,r:t},ue.s!==void 0&&(ue.s.n=t),ue.s=t,e.n=t,32&ue.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=ue.s,t.n=void 0,ue.s.n=t,ue.s=t),t}}function ke(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}ke.prototype.brand=w_;ke.prototype.h=function(){return!0};ke.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:gn(function(){var o;(o=t.W)==null||o.call(t)}))};ke.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,o=e.x;n!==void 0&&(n.x=o,e.e=void 0),o!==void 0&&(o.e=n,e.x=void 0),e===this.t&&(this.t=o,o===void 0&&gn(function(){var a;(a=t.Z)==null||a.call(t)}))}};ke.prototype.subscribe=function(e){var t=this;return st(function(){var n=t.value;gn(function(){return e(n)})},{name:"sub"})};ke.prototype.valueOf=function(){return this.value};ke.prototype.toString=function(){return this.value+""};ke.prototype.toJSON=function(){return this.value};ke.prototype.peek=function(){var e=this;return gn(function(){return e.value})};Object.defineProperty(ke.prototype,"value",{get:function(){var e=cs(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(_o>100)throw new Error("Cycle detected");(function(n){it!==0&&_o===0&&n.l!==jr&&(n.l=jr,uo={S:n,v:n.v,i:n.i,o:uo})})(this),this.v=e,this.i++,po++,it++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{mo()}}}});function H(e,t){return new ke(e,t)}function ds(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function _s(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function us(e){for(var t=e.s,n=void 0;t!==void 0;){var o=t.p;t.i===-1?(t.S.U(t),o!==void 0&&(o.n=t.n),t.n!==void 0&&(t.n.p=o)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=o}e.s=n}function St(e,t){ke.call(this,void 0,t),this.x=e,this.s=void 0,this.g=po-1,this.f=4}St.prototype=new ke;St.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===po))return!0;if(this.g=po,this.f|=1,this.i>0&&!ds(this))return this.f&=-2,!0;var e=ue;try{_s(this),ue=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return ue=e,us(this),this.f&=-2,!0};St.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}ke.prototype.S.call(this,e)};St.prototype.U=function(e){if(this.t!==void 0&&(ke.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};St.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(St.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=cs(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function hn(e,t){return new St(e,t)}function ps(e){var t=e.m;if(e.m=void 0,typeof t=="function"){it++;var n=ue;ue=void 0;try{t()}catch(o){throw e.f&=-2,e.f|=8,Xr(e),o}finally{ue=n,mo()}}}function Xr(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ps(e)}function T_(e){if(ue!==this)throw new Error("Out-of-order effect");us(this),ue=e,this.f&=-2,8&this.f&&Xr(this),mo()}function Wt(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,mn&&mn.push(this)}Wt.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};Wt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ps(this),_s(this),it++;var e=ue;return ue=this,T_.bind(this,e)};Wt.prototype.N=function(){2&this.f||(this.f|=2,this.u=fn,fn=this)};Wt.prototype.d=function(){this.f|=8,1&this.f||Xr(this)};Wt.prototype.dispose=function(){this.d()};function st(e,t){var n=new Wt(e,t);try{n.c()}catch(a){throw n.d(),a}var o=n.d.bind(n);return o[Symbol.dispose]=o,o}var ms,ho,fo,E_=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var fs=[];st(function(){ms=this.N})();function Gt(e,t){te[e]=t.bind(null,te[e]||function(){})}function go(e){if(fo){var t=fo;fo=void 0,t()}fo=e&&e.S()}function gs(e){var t=this,n=e.data,o=pt(n);o.value=n;var a=De(function(){for(var s=t,c=t.__v;c=c.__;)if(c.__c){c.__c.__$f|=4;break}var _=hn(function(){var f=o.value.value;return f===0?0:f===!0?"":f||""}),p=hn(function(){return!Array.isArray(_.value)&&!Er(_.value)}),v=st(function(){if(this.N=hs,p.value){var f=_.value;s.__v&&s.__v.__e&&s.__v.__e.nodeType===3&&(s.__v.__e.data=f)}}),u=t.__$u.d;return t.__$u.d=function(){v(),u.call(this)},[p,_]},[]),i=a[0],l=a[1];return i.value?l.peek():l.value}gs.displayName="ReactiveTextNode";Object.defineProperties(ke.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:gs},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}});Gt("__b",function(e,t){if(typeof t.type=="string"){var n,o=t.props;for(var a in o)if(a!=="children"){var i=o[a];i instanceof ke&&(n||(t.__np=n={}),n[a]=i,o[a]=i.peek())}}e(t)});Gt("__r",function(e,t){if(e(t),t.type!==ae){go();var n,o=t.__c;o&&(o.__$f&=-2,(n=o.__$u)===void 0&&(o.__$u=n=(function(a,i){var l;return st(function(){l=this},{name:i}),l.c=a,l})(function(){var a;E_&&((a=n.y)==null||a.call(n)),o.__$f|=1,o.setState({})},typeof t.type=="function"?t.type.displayName||t.type.name:""))),ho=o,go(n)}});Gt("__e",function(e,t,n,o){go(),ho=void 0,e(t,n,o)});Gt("diffed",function(e,t){go(),ho=void 0;var n;if(typeof t.type=="string"&&(n=t.__e)){var o=t.__np,a=t.props,i=n.U;if(i)for(var l in i){var s=i[l];s===void 0||o&&l in o||(s.d(),i[l]=void 0)}if(o){i||(i={},n.U=i);for(var c in o){var _=i[c],p=o[c];_===void 0?(_=R_(n,c,p,a),i[c]=_):_.o(p,a)}}}e(t)});function R_(e,t,n,o){var a=t in e&&e.ownerSVGElement===void 0,i=H(n);return{o:function(l,s){i.value=l,o=s},d:st(function(){this.N=hs;var l=i.value.value;o[t]!==l&&(o[t]=l,a?e[t]=l:l!=null&&(l!==!1||t[4]==="-")?e.setAttribute(t,l):e.removeAttribute(t))})}}Gt("unmount",function(e,t){if(typeof t.type=="string"){var n=t.__e;if(n){var o=n.U;if(o){n.U=void 0;for(var a in o){var i=o[a];i&&i.d()}}}var l=t.__np;if(l){var s=t.props;for(var c in l)s[c]=l[c]}t.__np=void 0}else{var _=t.__c;if(_){var p=_.__$u;p&&(_.__$u=void 0,p.d())}}e(t)});Gt("__h",function(e,t,n,o){(o<3||o===9)&&(t.__$f|=2),e(t,n,o)});ut.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,o=n&&n.s!==void 0;for(var a in t)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var i=2&this.__$f;if(!(o||i||4&this.__$f)||1&this.__$f)return!0}else if(!(o||4&this.__$f)||3&this.__$f)return!0;for(var l in e)if(l!=="__source"&&e[l]!==this.props[l])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function pt(e,t){return De(function(){return H(e,t)},[])}function Q(e,t){var n=N(e);return n.current=e,ho.__$f|=4,De(function(){return hn(function(){return n.current()},t)},[])}var A_=function(e){queueMicrotask(function(){queueMicrotask(e)})};function I_(){Vt(function(){for(var e;e=fs.shift();)ms.call(e)})}function hs(){fs.push(this)===1&&(te.requestAnimationFrame||A_)(I_)}function vs(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function bs(e){return vs(e)}function Ps(e){return!(!vs(e)||e.navigation!==void 0&&!Array.isArray(e.navigation)||e.linkCards!==void 0&&!Array.isArray(e.linkCards))}function L_(e){return`${x.cssPrefix}:${e}`}function ys(e,t){let o=Object.entries(t).map(([a,i])=>{let l=L_(a),s=c=>i(c.detail);return e.addEventListener(l,s),[l,s]});return()=>{for(let[a,i]of o)e.removeEventListener(a,i)}}function vo(e,t,n){return e==="page"?"page":e==="standalone"?"standalone":e==="inline"?t==="fullscreen"?"fullscreen":"inline":e==="modal"||e==="drawer"?n?t==="fullscreen"?"fullscreen":e:"closed":n?t==="fullscreen"?"fullscreen":t==="expanded"?"expanded":"open":"closed"}var M_=900;function Yr(e,t,n){if(e==="standalone"||e==="page")return"fullscreen";let o=t.initialSize;if(o==="expanded"||o==="fullscreen"||o==="normal")return o;if(o==="auto"){let a=t.autoSizeBreakpoint??M_;return n>=a?"expanded":"normal"}return"normal"}function vn(e,t,n,o=null){let i=e.mode==="inline"||e.mode==="standalone"||e.mode==="page"||(n??!e.startMinimized),s=e.mode!=="standalone"&&e.mode!=="page"&&e.mode!=="inline"&&o?o:Yr(e.mode,e.size,t);return{panelOpen:i,panelSize:s}}function Kt(){return typeof window>"u"?0:window.innerWidth}var O_="x-public-key",N_="x-ai-agent-deployment-id";function xs(e){return{headers(){let t={};return e.aiAgentDeploymentId&&(t[N_]=e.aiAgentDeploymentId),e.publicKey&&(t[e.publicKeyHeader??O_]=e.publicKey),t}}}var bo="0.63.2";var Ke=class extends Error{constructor(n,o,a,i){super(n);j(this,"code",o);j(this,"status",a);j(this,"cause",i);this.name="StreamError"}};var Ss=ee.scope("parser");async function*Po(e,t){if(!e.ok){let n=await e.text().catch(()=>"");throw new Ke(`server responded ${e.status}: ${n.slice(0,200)}`,"server",e.status)}for await(let n of D_(e,t)){let o=$_(n);if(o==="done")return;o&&(yield o)}}async function*D_(e,t){if(!e.body)throw new Ke("response has no body","no-body");let n=e.body.pipeThrough(new TextDecoderStream).getReader(),o="";try{for(;;){if(t.aborted)throw new DOMException("aborted","AbortError");let{done:a,value:i}=await n.read();if(a){let s=o.trim();s&&(yield s);return}o+=i;let l;for(;(l=o.indexOf(`
7
+ `).replace(/__P__/g,__).replaceAll("__BRAND_ACCENT_TEXT__",p_).replaceAll("__BRAND_ACCENT__",u_).replaceAll("__BRAND_RADIUS__",m_).replaceAll("__BRAND_FONT__",f_);var g_=ee.scope("mount"),ji=new WeakMap,Xi={floating:"all: initial; position: fixed; z-index: 2147483600;",flow:"all: initial; display: block; position: relative; width: 100%; height: 100%; z-index: 1; contain: size;",viewport:"all: initial; display: block; position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1;"};function Yi(e,t){e.style.cssText=Xi[t]}function io(e){return e==="floating"||e==="modal"||e==="drawer"?"floating":e==="standalone"||e==="page"?"viewport":"flow"}function Ji(e={}){let t=e.position??"flow";g_.debug("createShadowMount",{position:t,hasTarget:!!e.target,hasHost:!!e.existingHost});let n=`${x.cssPrefix}-chat-host`;typeof customElements<"u"&&!customElements.get(n)&&customElements.define(n,class extends HTMLElement{});let o;e.existingHost?o=e.existingHost:(o=document.createElement(n),(e.target??document.body).appendChild(o)),o.setAttribute("data-brand",x.id),o.style.cssText=Xi[t];let a=o.shadowRoot??o.attachShadow({mode:"open"}),i=o.ownerDocument;if(!h_(a,i)){let s=i.createElement("style");s.textContent=Vr,a.appendChild(s)}let l=document.createElement("div");return l.className=`${x.cssPrefix}-app`,a.appendChild(l),{appRoot:l,destroy:()=>o.remove(),hostElement:o,shadowRoot:a}}function h_(e,t){if(!("adoptedStyleSheets"in e))return!1;let n=t.defaultView;if(!n||typeof n.CSSStyleSheet!="function")return!1;let o=ji.get(t);if(!o)try{o=new n.CSSStyleSheet,o.replaceSync(Vr),ji.set(t,o)}catch{return!1}try{return e.adoptedStyleSheets=[o],!0}catch{return!1}}function v_(e,t){let n=x.cssPrefix;t.accent&&e.style.setProperty(`--${n}-accent-user`,t.accent),t.accentText&&e.style.setProperty(`--${n}-accent-text-user`,t.accentText),t.radius&&e.style.setProperty(`--${n}-radius`,t.radius),t.fontFamily&&e.style.setProperty(`--${n}-font`,t.fontFamily),t.contentMaxWidth&&e.style.setProperty(`--${n}-conversation-max`,t.contentMaxWidth)}function b_(e,t){e.dataset.theme=t}function P_(e,t){let n=x.cssPrefix;t.width!==void 0&&e.style.setProperty(`--${n}-panel-w`,t.width),t.height!==void 0&&e.style.setProperty(`--${n}-panel-h`,t.height),t.expanded?.width!==void 0&&e.style.setProperty(`--${n}-expanded-w`,t.expanded.width),t.expanded?.height!==void 0&&e.style.setProperty(`--${n}-expanded-h`,t.expanded.height),t.inset!==void 0&&e.style.setProperty(`--${n}-panel-inset`,t.inset)}function y_(e,t){e.dataset.position=t}function so(e,t){e.dataset.mode=t}function Qi(e,t){b_(e,t.themeMode),v_(e,t.themeOverrides),y_(e,t.position),P_(e,t.size)}var qt,he,Wr,Zi,pn=0,ss=[],ye=te,es=ye.__b,ts=ye.__r,ns=ye.diffed,os=ye.__c,rs=ye.unmount,as=ye.__;function co(e,t){ye.__h&&ye.__h(he,e,pn||t),pn=0;var n=he.__H||(he.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function R(e){return pn=1,x_(ls,e)}function x_(e,t,n){var o=co(qt++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):ls(void 0,t),function(s){var c=o.__N?o.__N[0]:o.__[0],_=o.t(c,s);c!==_&&(o.__N=[_,o.__[1]],o.__c.setState({}))}],o.__c=he,!he.__f)){var a=function(s,c,_){if(!o.__c.__H)return!0;var p=!1,v=o.__c.props!==s;if(o.__c.__H.__.some(function(f){if(f.__N){p=!0;var m=f.__[0];f.__=f.__N,f.__N=void 0,m!==f.__[0]&&(v=!0)}}),i){var u=i.call(this,s,c,_);return p?u||v:u}return!p||v};he.__f=!0;var i=he.shouldComponentUpdate,l=he.componentWillUpdate;he.componentWillUpdate=function(s,c,_){if(this.__e){var p=i;i=void 0,a(s,c,_),i=p}l&&l.call(this,s,c,_)},he.shouldComponentUpdate=a}return o.__N||o.__}function T(e,t){var n=co(qt++,3);!ye.__s&&Kr(n.__H,t)&&(n.__=e,n.u=t,he.__H.__h.push(n))}function xt(e,t){var n=co(qt++,4);!ye.__s&&Kr(n.__H,t)&&(n.__=e,n.u=t,he.__h.push(n))}function N(e){return pn=5,De(function(){return{current:e}},[])}function De(e,t){var n=co(qt++,7);return Kr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function $(e,t){return pn=8,De(function(){return e},t)}function S_(){for(var e;e=ss.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(lo),t.__h.some(Gr),t.__h=[]}catch(n){t.__h=[],ye.__e(n,e.__v)}}}ye.__b=function(e){he=null,es&&es(e)},ye.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),as&&as(e,t)},ye.__r=function(e){ts&&ts(e),qt=0;var t=(he=e.__c).__H;t&&(Wr===he?(t.__h=[],he.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(lo),t.__h.some(Gr),t.__h=[],qt=0)),Wr=he},ye.diffed=function(e){ns&&ns(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ss.push(t)!==1&&Zi===ye.requestAnimationFrame||((Zi=ye.requestAnimationFrame)||k_)(S_)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Wr=he=null},ye.__c=function(e,t){t.some(function(n){try{n.__h.some(lo),n.__h=n.__h.filter(function(o){return!o.__||Gr(o)})}catch(o){t.some(function(a){a.__h&&(a.__h=[])}),t=[],ye.__e(o,n.__v)}}),os&&os(e,t)},ye.unmount=function(e){rs&&rs(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(o){try{lo(o)}catch(a){t=a}}),n.__H=void 0,t&&ye.__e(t,n.__v))};var is=typeof requestAnimationFrame=="function";function k_(e){var t,n=function(){clearTimeout(o),is&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);is&&(t=requestAnimationFrame(n))}function lo(e){var t=he,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),he=t}function Gr(e){var t=he;e.__c=e.__(),he=t}function Kr(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function ls(e,t){return typeof t=="function"?t(e):t}var w_=Symbol.for("preact-signals");function mo(){if(it>1)it--;else{var e,t=!1;for((function(){var a=uo;for(uo=void 0;a!==void 0;){var i=a.S;if(i.v===a.v)for(var l=i.t;l!==void 0;l=l.x)l.i===a.i&&(l.i=i.i);a=a.o}})();fn!==void 0;){var n=fn;for(fn=void 0,_o++;n!==void 0;){var o=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&ds(n))try{n.c()}catch(a){t||(e=a,t=!0)}n=o}}if(_o=0,it--,t)throw e}}function Vt(e){if(it>0)return e();jr=++C_,it++;try{return e()}finally{mo()}}var mn,ue=void 0;function gn(e){var t=ue,n=mn;ue=void 0,mn=void 0;try{return e()}finally{ue=t,mn=n}}var fn=void 0,it=0,_o=0,C_=0,jr=0,uo=void 0,po=0;function cs(e){if(ue!==void 0){var t=e.n;if(t===void 0||t.t!==ue)return t={i:0,S:e,p:ue.s,n:void 0,t:ue,e:void 0,x:void 0,r:t},ue.s!==void 0&&(ue.s.n=t),ue.s=t,e.n=t,32&ue.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=ue.s,t.n=void 0,ue.s.n=t,ue.s=t),t}}function ke(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}ke.prototype.brand=w_;ke.prototype.h=function(){return!0};ke.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:gn(function(){var o;(o=t.W)==null||o.call(t)}))};ke.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,o=e.x;n!==void 0&&(n.x=o,e.e=void 0),o!==void 0&&(o.e=n,e.x=void 0),e===this.t&&(this.t=o,o===void 0&&gn(function(){var a;(a=t.Z)==null||a.call(t)}))}};ke.prototype.subscribe=function(e){var t=this;return st(function(){var n=t.value;gn(function(){return e(n)})},{name:"sub"})};ke.prototype.valueOf=function(){return this.value};ke.prototype.toString=function(){return this.value+""};ke.prototype.toJSON=function(){return this.value};ke.prototype.peek=function(){var e=this;return gn(function(){return e.value})};Object.defineProperty(ke.prototype,"value",{get:function(){var e=cs(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(_o>100)throw new Error("Cycle detected");(function(n){it!==0&&_o===0&&n.l!==jr&&(n.l=jr,uo={S:n,v:n.v,i:n.i,o:uo})})(this),this.v=e,this.i++,po++,it++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{mo()}}}});function H(e,t){return new ke(e,t)}function ds(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function _s(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function us(e){for(var t=e.s,n=void 0;t!==void 0;){var o=t.p;t.i===-1?(t.S.U(t),o!==void 0&&(o.n=t.n),t.n!==void 0&&(t.n.p=o)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=o}e.s=n}function St(e,t){ke.call(this,void 0,t),this.x=e,this.s=void 0,this.g=po-1,this.f=4}St.prototype=new ke;St.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===po))return!0;if(this.g=po,this.f|=1,this.i>0&&!ds(this))return this.f&=-2,!0;var e=ue;try{_s(this),ue=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return ue=e,us(this),this.f&=-2,!0};St.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}ke.prototype.S.call(this,e)};St.prototype.U=function(e){if(this.t!==void 0&&(ke.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};St.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(St.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=cs(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function hn(e,t){return new St(e,t)}function ps(e){var t=e.m;if(e.m=void 0,typeof t=="function"){it++;var n=ue;ue=void 0;try{t()}catch(o){throw e.f&=-2,e.f|=8,Xr(e),o}finally{ue=n,mo()}}}function Xr(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ps(e)}function T_(e){if(ue!==this)throw new Error("Out-of-order effect");us(this),ue=e,this.f&=-2,8&this.f&&Xr(this),mo()}function Wt(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,mn&&mn.push(this)}Wt.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};Wt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ps(this),_s(this),it++;var e=ue;return ue=this,T_.bind(this,e)};Wt.prototype.N=function(){2&this.f||(this.f|=2,this.u=fn,fn=this)};Wt.prototype.d=function(){this.f|=8,1&this.f||Xr(this)};Wt.prototype.dispose=function(){this.d()};function st(e,t){var n=new Wt(e,t);try{n.c()}catch(a){throw n.d(),a}var o=n.d.bind(n);return o[Symbol.dispose]=o,o}var ms,ho,fo,E_=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var fs=[];st(function(){ms=this.N})();function Gt(e,t){te[e]=t.bind(null,te[e]||function(){})}function go(e){if(fo){var t=fo;fo=void 0,t()}fo=e&&e.S()}function gs(e){var t=this,n=e.data,o=pt(n);o.value=n;var a=De(function(){for(var s=t,c=t.__v;c=c.__;)if(c.__c){c.__c.__$f|=4;break}var _=hn(function(){var f=o.value.value;return f===0?0:f===!0?"":f||""}),p=hn(function(){return!Array.isArray(_.value)&&!Er(_.value)}),v=st(function(){if(this.N=hs,p.value){var f=_.value;s.__v&&s.__v.__e&&s.__v.__e.nodeType===3&&(s.__v.__e.data=f)}}),u=t.__$u.d;return t.__$u.d=function(){v(),u.call(this)},[p,_]},[]),i=a[0],l=a[1];return i.value?l.peek():l.value}gs.displayName="ReactiveTextNode";Object.defineProperties(ke.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:gs},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}});Gt("__b",function(e,t){if(typeof t.type=="string"){var n,o=t.props;for(var a in o)if(a!=="children"){var i=o[a];i instanceof ke&&(n||(t.__np=n={}),n[a]=i,o[a]=i.peek())}}e(t)});Gt("__r",function(e,t){if(e(t),t.type!==ae){go();var n,o=t.__c;o&&(o.__$f&=-2,(n=o.__$u)===void 0&&(o.__$u=n=(function(a,i){var l;return st(function(){l=this},{name:i}),l.c=a,l})(function(){var a;E_&&((a=n.y)==null||a.call(n)),o.__$f|=1,o.setState({})},typeof t.type=="function"?t.type.displayName||t.type.name:""))),ho=o,go(n)}});Gt("__e",function(e,t,n,o){go(),ho=void 0,e(t,n,o)});Gt("diffed",function(e,t){go(),ho=void 0;var n;if(typeof t.type=="string"&&(n=t.__e)){var o=t.__np,a=t.props,i=n.U;if(i)for(var l in i){var s=i[l];s===void 0||o&&l in o||(s.d(),i[l]=void 0)}if(o){i||(i={},n.U=i);for(var c in o){var _=i[c],p=o[c];_===void 0?(_=R_(n,c,p,a),i[c]=_):_.o(p,a)}}}e(t)});function R_(e,t,n,o){var a=t in e&&e.ownerSVGElement===void 0,i=H(n);return{o:function(l,s){i.value=l,o=s},d:st(function(){this.N=hs;var l=i.value.value;o[t]!==l&&(o[t]=l,a?e[t]=l:l!=null&&(l!==!1||t[4]==="-")?e.setAttribute(t,l):e.removeAttribute(t))})}}Gt("unmount",function(e,t){if(typeof t.type=="string"){var n=t.__e;if(n){var o=n.U;if(o){n.U=void 0;for(var a in o){var i=o[a];i&&i.d()}}}var l=t.__np;if(l){var s=t.props;for(var c in l)s[c]=l[c]}t.__np=void 0}else{var _=t.__c;if(_){var p=_.__$u;p&&(_.__$u=void 0,p.d())}}e(t)});Gt("__h",function(e,t,n,o){(o<3||o===9)&&(t.__$f|=2),e(t,n,o)});ut.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,o=n&&n.s!==void 0;for(var a in t)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var i=2&this.__$f;if(!(o||i||4&this.__$f)||1&this.__$f)return!0}else if(!(o||4&this.__$f)||3&this.__$f)return!0;for(var l in e)if(l!=="__source"&&e[l]!==this.props[l])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function pt(e,t){return De(function(){return H(e,t)},[])}function Q(e,t){var n=N(e);return n.current=e,ho.__$f|=4,De(function(){return hn(function(){return n.current()},t)},[])}var A_=function(e){queueMicrotask(function(){queueMicrotask(e)})};function I_(){Vt(function(){for(var e;e=fs.shift();)ms.call(e)})}function hs(){fs.push(this)===1&&(te.requestAnimationFrame||A_)(I_)}function vs(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function bs(e){return vs(e)}function Ps(e){return!(!vs(e)||e.navigation!==void 0&&!Array.isArray(e.navigation)||e.linkCards!==void 0&&!Array.isArray(e.linkCards))}function L_(e){return`${x.cssPrefix}:${e}`}function ys(e,t){let o=Object.entries(t).map(([a,i])=>{let l=L_(a),s=c=>i(c.detail);return e.addEventListener(l,s),[l,s]});return()=>{for(let[a,i]of o)e.removeEventListener(a,i)}}function vo(e,t,n){return e==="page"?"page":e==="standalone"?"standalone":e==="inline"?t==="fullscreen"?"fullscreen":"inline":e==="modal"||e==="drawer"?n?t==="fullscreen"?"fullscreen":e:"closed":n?t==="fullscreen"?"fullscreen":t==="expanded"?"expanded":"open":"closed"}var M_=900;function Yr(e,t,n){if(e==="standalone"||e==="page")return"fullscreen";let o=t.initialSize;if(o==="expanded"||o==="fullscreen"||o==="normal")return o;if(o==="auto"){let a=t.autoSizeBreakpoint??M_;return n>=a?"expanded":"normal"}return"normal"}function vn(e,t,n,o=null){let i=e.mode==="inline"||e.mode==="standalone"||e.mode==="page"||(n??!e.startMinimized),s=e.mode!=="standalone"&&e.mode!=="page"&&e.mode!=="inline"&&o?o:Yr(e.mode,e.size,t);return{panelOpen:i,panelSize:s}}function Kt(){return typeof window>"u"?0:window.innerWidth}var O_="x-public-key",N_="x-ai-agent-deployment-id";function xs(e){return{headers(){let t={};return e.aiAgentDeploymentId&&(t[N_]=e.aiAgentDeploymentId),e.publicKey&&(t[e.publicKeyHeader??O_]=e.publicKey),t}}}var bo="0.63.3";var Ke=class extends Error{constructor(n,o,a,i){super(n);j(this,"code",o);j(this,"status",a);j(this,"cause",i);this.name="StreamError"}};var Ss=ee.scope("parser");async function*Po(e,t){if(!e.ok){let n=await e.text().catch(()=>"");throw new Ke(`server responded ${e.status}: ${n.slice(0,200)}`,"server",e.status)}for await(let n of D_(e,t)){let o=$_(n);if(o==="done")return;o&&(yield o)}}async function*D_(e,t){if(!e.body)throw new Ke("response has no body","no-body");let n=e.body.pipeThrough(new TextDecoderStream).getReader(),o="";try{for(;;){if(t.aborted)throw new DOMException("aborted","AbortError");let{done:a,value:i}=await n.read();if(a){let s=o.trim();s&&(yield s);return}o+=i;let l;for(;(l=o.indexOf(`
8
8
 
9
9
  `))!==-1;){let s=o.slice(0,l);o=o.slice(l+2),yield s}}}finally{n.releaseLock()}}function $_(e){let t="",n;for(let o of e.split(`
10
10
  `))if(!(o===""||o.startsWith(":"))){if(o.startsWith("data:")){let a=o.slice(5).replace(/^ /,"");t=t?`${t}
11
- ${a}`:a;continue}o.startsWith("id:")&&(n=o.slice(3).trim())}if(t==="[DONE]")return"done";if(!t)return null;try{let o=JSON.parse(t);return Ss.trace("chunk",{type:o.type,eventId:n}),{chunk:o,eventId:n}}catch(o){return Ss.trace("frame parse failed",{err:o,payload:t.slice(0,200)}),null}}function F_(e){let t=new TextEncoder().encode(e),n="";for(let o of t)n+=String.fromCharCode(o);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var ks=e=>e&&Object.keys(e).length>0?e:void 0;function ws(e,t){let n=ks(e),o=ks(t);if(!n&&!o)return;let a={};return n&&(a.user=n),o&&(a.page=o),F_(JSON.stringify(a))}function yo(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function B_(e){return`tool-${e.startsWith("tool:")?e.slice(5):e}`}function Cs(e){return e.startsWith("tool-")?e.slice(5):e}var ze={handshake:"/pai/handshake",streamMessage:"/pai/stream-message",streamResume:"/pai/stream-resume",cancelStream:"/pai/cancel-stream",listConversations:"/pai/list-conversations",listMessages:"/pai/list-messages",updateSettings:"/pai/update-settings",markRead:"/pai/mark-read",messageFeedback:"/pai/message-feedback",requestOperator:"/pai/request-operator",bootstrap:"/pai/bootstrap",content:"/pai/content",submitForm:"/pai/submit-form"},Ts="context";function mt(e){let t=e??{},n=t.controlMode;return{controlMode:n==="awaiting_operator"||n==="operator"?n:"ai-agent",assignedOperatorInitials:typeof t.assignedOperatorInitials=="string"&&t.assignedOperatorInitials?t.assignedOperatorInitials:void 0,operatorAvailable:typeof t.operatorAvailable=="boolean"?t.operatorAvailable:void 0}}function xo(e){let t=e?.suggestions;if(!Array.isArray(t))return[];let n=[];for(let o of t){if(!o||typeof o!="object")continue;let{id:a,label:i,text:l}=o;typeof i!="string"||!i||n.push({id:typeof a=="string"&&a?a:`s${n.length}`,label:i,text:typeof l=="string"&&l?l:i})}return n}function Es(e){let t=e.messages.map(i=>({id:i.serverMessageId??i.id,parts:U_(i),role:i.role,createdAt:i.createdAt!==void 0?new Date(i.createdAt).toISOString():void 0})),n={messages:t,conversationId:e.conversationId,trigger:e.trigger??"submit-message"},o=t.at(-1)?.id;o&&(n.messageId=o),e.visitorId&&(n.visitorId=e.visitorId),e.userPrefs&&(n.userPrefs=e.userPrefs);let a=e.tools?.map(z_).filter(i=>i!==null);return a?.length&&(n.data={tools:a}),n}function H_(e){return e.state==="output-available"||e.state==="output-error"||e.state==="output-denied"||e.approval?.approved!==void 0}function z_(e){return typeof e=="string"?e?{code:e}:null:e?.code?e:null}function U_(e){let t=[];for(let n of e.parts)if(n.kind==="step-start"&&t.push({type:"step-start"}),n.kind==="reasoning"&&n.text&&t.push({type:"reasoning",text:n.text,state:n.done?"done":"streaming"}),n.kind==="text"&&n.text&&t.push({text:n.text,type:"text"}),n.kind==="file"&&n.url&&t.push({mediaType:n.mediaType,type:"file",url:n.url}),n.kind==="tool"&&H_(n)){let o={type:B_(n.toolName),toolCallId:n.toolCallId,state:n.state};n.input!==void 0&&(o.input=n.input),n.output!==void 0&&(o.output=n.output),n.error!==void 0&&(o.errorText=n.error),n.approval&&n.approval.approved!==void 0&&(o.approval=n.approval),t.push(o)}for(let n of e.attachments??[])n.url&&t.push({type:"file",url:n.url,mediaType:n.mediaType,filename:n.name,fileId:n.id,fileSize:n.size});return t}var Y=ee.scope("transport"),Rs=3,Ls=400,q_=250,V_=5e3,W_=6e4,G_=1e4,As=3,K_=new Set([408,425,429,500,502,503,504]);function Is(e){return Ls*2**e+Math.floor(Math.random()*250)}function j_(e){let t=e.get("retry-after");if(!t)return null;let n=Number(t),o=Number.isFinite(n)?n*1e3:Date.parse(t)-Date.now();return Number.isFinite(o)&&o>=0?Math.min(o,3e4):null}function So(e,t){return new Promise(n=>{if(t?.aborted)return n();let o=setTimeout(i,e),a=()=>i();t?.addEventListener("abort",a,{once:!0});function i(){clearTimeout(o),t?.removeEventListener("abort",a),n()}})}var ko=class{constructor(t){j(this,"ttlMs",t);j(this,"map",new Map)}getOrFetch(t,n){let o=this.map.get(t);if(o&&Date.now()-o.at<this.ttlMs)return o.result;let a={at:Date.now(),result:n().then(i=>(a.value=i,i)).catch(i=>{throw this.map.delete(t),i})};return this.map.set(t,a),a.result}peek(t){let n=this.map.get(t);if(n?.value!==void 0&&Date.now()-n.at<this.ttlMs)return n.value}clear(){this.map.clear()}},wo=class{constructor(t){j(this,"opts",t);j(this,"visitorId");j(this,"conversationId");j(this,"resumeStatus");j(this,"userContext");j(this,"pageContext");j(this,"locale");j(this,"conversationsCache",new ko(G_));j(this,"contentCache",new ko(W_))}setContext(t,n){this.userContext=t,this.pageContext=n}setLocale(t){this.locale=t}primeIdentity(t,n){t&&(this.visitorId=t),n&&(this.conversationId=n)}envelope(){let t={_ev:bo};this.visitorId&&(t.visitorId=this.visitorId),this.conversationId&&(t.conversationId=this.conversationId),this.locale&&(t.locale=this.locale);let n=ws(this.userContext,this.pageContext);return n&&(t[Ts]=n),t}withEnvelope(t){return{...this.envelope(),...t}}appendEnvelope(t){for(let[n,o]of Object.entries(this.envelope()))t.append(n,o);return t}withEnvelopeQuery(t){let n=new URL(this.url(t));for(let[o,a]of Object.entries(this.envelope()))n.searchParams.has(o)||n.searchParams.set(o,a);return n.toString()}async handshake(t){Y.debug("handshake \u2192",{visitorId:t.visitorId,conversationId:t.conversationId,locale:t.locale});let n=await this.postJson(ze.handshake,t,"handshake");return Y.debug("handshake \u2190",{visitorId:n.visitorId,conversationId:n.conversationId,hasWelcome:!!n.welcome,hasConfig:!!n.config,rebind:n.rebind}),Y_(n)||Y.warn("handshake response did not match expected shape; using raw response",{response:n}),this.visitorId=n.visitorId??t.visitorId,this.conversationId=n.conversationId,n}async uploadFile(t){Y.debug("uploadFile \u2192",{name:t.name,size:t.size,type:t.type});let n=new FormData;n.append("file",t,t.name);let o=await this.postForm(this.uploadPath,n,"upload");return Y.debug("uploadFile \u2190",{id:o.id,url:o.url}),o}async transcribe(t,n="audio/webm"){Y.debug("transcribe \u2192",{size:t.size,mimeType:n});let o=new FormData;o.append("audio",t,`voice.${X_(n)}`),o.append("mimeType",n);let a=await this.postForm(this.transcribePath,o,"transcribe");return Y.debug("transcribe \u2190",{textLen:a.text.length}),a}localeCacheKey(t){return`${this.locale??""}|${JSON.stringify(t,Object.keys(t).toSorted())}`}peekConversations(t={}){return this.conversationsCache.peek(this.localeCacheKey(t))}listConversations(t={}){return this.conversationsCache.getOrFetch(this.localeCacheKey(t),()=>this.fetchConversations(t))}async fetchConversations(t){let n=new URL(this.url(ze.listConversations));t.visitorId&&n.searchParams.set("visitorId",t.visitorId),t.limit&&n.searchParams.set("limit",String(t.limit)),t.cursor&&n.searchParams.set("cursor",t.cursor),Y.debug("listConversations \u2192",{visitorId:t.visitorId??this.visitorId,limit:t.limit,cursor:t.cursor});let o=await this.getJson(n.toString(),"listConversations"),a=o.conversations??[];return Y.debug("listConversations \u2190",{count:a.length,nextCursor:o.nextCursor}),{conversations:a,nextCursor:o.nextCursor}}async loadConversation(t){let n=new URL(this.url(ze.listMessages));n.searchParams.set("conversationId",t),Y.debug("loadConversation \u2192",{conversationId:t,visitorId:this.visitorId});let o=await this.getJson(n.toString(),"loadConversation"),a=o.messages??[];return Y.debug("loadConversation \u2190",{conversationId:o.conversationId,canContinue:o.canContinue,messageCount:a.length,hasSuggestions:!!o.suggestions}),{...o,messages:a,canContinue:o.canContinue??!0}}async markRead(t){if(!(!this.visitorId||!t)){this.conversationsCache.clear(),Y.debug("markRead \u2192",{conversationId:t,visitorId:this.visitorId});try{await this.postJson(ze.markRead,{conversationId:t},"markRead")}catch(n){Y.debug("markRead failed (non-fatal)",{err:n})}}}async requestOperator(){if(!(!this.visitorId||!this.conversationId)){Y.debug("requestOperator \u2192",{conversationId:this.conversationId,visitorId:this.visitorId});try{return(await this.postJson(ze.requestOperator,{},"requestOperator")).controlState}catch(t){Y.debug("requestOperator failed (non-fatal)",{err:t});return}}}listContent(t={}){return this.contentCache.getOrFetch(this.localeCacheKey(t),()=>this.fetchContent(t))}async fetchContent(t){let n=new URL(this.dataUrl(ze.content));for(let[i,l]of Object.entries(t))l!==void 0&&n.searchParams.set(i,Array.isArray(l)?l.join(","):String(l));Y.debug("listContent \u2192",t);let o=await this.getJson(n.toString(),"listContent"),a=(o.items??[]).map(i=>gi(i,this.locale));return Y.debug("listContent \u2190",{count:a.length,total:o.pagination?.total}),{...o,items:a}}async bootstrap(t){let n=new URL(this.dataUrl(ze.bootstrap));t&&n.searchParams.set("conversationId",t),Y.debug("bootstrap \u2192",{conversationId:t??this.conversationId});let o=await this.getJson(n.toString(),"bootstrap"),a=o.forms??[],i=o.formSubmissions??[];return Y.debug("bootstrap \u2190",{forms:a.length,formSubmissions:i.length}),{forms:a,formSubmissions:i}}async saveUserPrefs(t){Y.debug("saveUserPrefs \u2192",{visitorId:this.visitorId,conversationId:this.conversationId,settingsKeys:Object.keys(t)});let n=await this.postJson(ze.updateSettings,{userPrefs:t},"saveUserPrefs");return Y.debug("saveUserPrefs \u2190",{success:n.success}),n}get uploadPath(){return this.opts.endpoints?.upload??"/pai/upload-file"}get transcribePath(){return this.opts.endpoints?.transcribe??"/pai/transcribe-audio"}get submitFormPath(){return this.opts.endpoints?.submitForm??ze.submitForm}async submitForm(t){Y.debug("submitForm \u2192",{formId:t.formId,trigger:t.trigger,fields:Object.keys(t.values).length});try{await this.postJson(this.dataUrl(this.submitFormPath),t,"submitForm")}catch(n){Y.debug("submitForm failed (non-fatal)",{err:n})}}async submitFeedback(t){Y.debug("submitFeedback \u2192",{messageId:t.messageId,value:t.value});try{await this.postJson(ze.messageFeedback,{messageId:t.messageId,set:{feedback:t.value}},"submitFeedback")}catch(n){Y.debug("submitFeedback failed (non-fatal)",{err:n})}}sendMessage(t){this.conversationsCache.clear(),Y.debug("message \u2192",{conversationId:t.conversationId,visitorId:t.visitorId,messageId:t.messageId,messageCount:t.messages.length,trigger:t.trigger,tools:t.data?.tools?.map(l=>l.code)});let n=new AbortController,o=new Set;return{iter:this.runStream(t,n,o),cancel:()=>this.cancelStream(n,t.conversationId),detach:()=>n.abort()}}resumeStream(){let t=new AbortController,n=new Set;this.resumeStatus=void 0;let o=this.resumeStreamGen(t,n,!0),a=()=>t.abort();return{iter:o,cancel:a,detach:a}}resumeChannel(){let t=new AbortController;return{iter:this.resumeChannelGen(t),stop:()=>t.abort()}}async*resumeChannelGen(t){for(let n=1;!t.signal.aborted;n++){if(n>1&&(await So(Math.min(q_*(n-1),V_),t.signal),t.signal.aborted))return;let o;try{o=await this.fetchImpl(this.resumeUrl(0),{method:"GET",credentials:"omit",headers:{accept:"text/event-stream",...this.opts.auth.headers()},signal:t.signal})}catch(a){if(t.signal.aborted)return;Y.debug("resume-channel fetch failed \u2014 reconnecting",{attempt:n,err:a});continue}if(!o.ok||!o.body){Y.debug("resume-channel \u2192 endpoint unavailable",{status:o.status});return}if(!(o.headers.get("content-type")??"").includes("text/event-stream")){let a=await o.json().then(i=>i.status).catch(()=>{});if(a==="pending"){Y.debug("resume-channel \u2192 pending (still registering); reconnecting",{attempt:n});continue}Y.debug("resume-channel \u2192 no live operator-control stream (status); stopping",{status:a});return}try{for await(let a of Po(o,t.signal)){if(t.signal.aborted)return;n=1,yield a}}catch(a){if(t.signal.aborted)return;Y.debug("resume-channel segment dropped \u2014 reconnecting",{err:a})}}}async*runStream(t,n,o){(yield*this.drain(this.openMessageStream(t,n.signal),o,n))||(yield*this.resumeStreamGen(n,o,!1))}async*resumeStreamGen(t,n,o){for(let a=1;a<=Rs&&!t.signal.aborted;a++){if((!o||a>1)&&(await So(Ls*a,t.signal),t.signal.aborted))return;let i;try{i=await this.fetchImpl(this.resumeUrl(n.size),{method:"GET",credentials:"omit",headers:{accept:"text/event-stream",...this.opts.auth.headers()},signal:t.signal})}catch(c){if(t.signal.aborted)return;Y.debug("resume fetch failed \u2014 retrying",{attempt:a,err:c});continue}if(i.status===204||!i.ok){Y.debug("resume \u2192 no in-flight stream",{status:i.status});return}if(!(i.headers.get("content-type")??"").includes("text/event-stream")){let c=await i.json().then(_=>_.status).catch(()=>{});if(Y.debug("resume \u2192 no live stream (status response)",{status:c,attempt:a}),c==="pending"&&a<Rs)continue;this.resumeStatus=c==="needs-generation"?"needs-generation":"completed";return}this.resumeStatus="live";let s=n.size;if(yield*this.drain(Po(i,t.signal),n,t))return;if(n.size===s){Y.debug("resume \u2192 stream closed with no new events; nothing to resume");return}}if(!t.signal.aborted)throw new Ke("stream incomplete after resume attempts","server")}async*drain(t,n,o){let a=!1;try{for await(let i of t){if(o.signal.aborted)return!0;if(i.eventId){if(n.has(i.eventId))continue;n.add(i.eventId)}yield i,(i.chunk.type==="finish"||i.chunk.type==="error")&&(a=!0)}}catch(i){if(o.signal.aborted)return!0;if(i instanceof Ke&&i.status!==void 0)throw i;Y.debug("stream segment dropped",{err:i})}return a}cancelStream(t,n){t.signal.aborted||(Y.debug("cancel stream",{conversationId:n,visitorId:this.visitorId}),t.abort(),!(!this.visitorId||!n)&&this.fetchImpl(this.url(ze.cancelStream),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope({})),keepalive:!0}).catch(o=>Y.debug("cancel POST failed (non-fatal)",{err:o})))}async*openMessageStream(t,n){let o=await this.fetchImpl(this.url(ze.streamMessage),{method:"POST",credentials:"omit",headers:{accept:"text/event-stream","content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(t)),signal:n});yield*Po(o,n)}resumeUrl(t){let n=new URL(this.withEnvelopeQuery(ze.streamResume));return n.searchParams.set("resumeAt",String(t)),n.toString()}async postJson(t,n,o){let a=await this.fetchWithRetry(()=>[this.url(t),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(n))}],o);return this.assertOk(a,o)}async postForm(t,n,o){let a=await this.fetchImpl(this.url(t),{method:"POST",credentials:"omit",headers:this.opts.auth.headers(),body:this.appendEnvelope(n)});return this.assertOk(a,o)}async getJson(t,n){let o=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(t),{method:"GET",credentials:"omit",headers:{accept:"application/json",...this.opts.auth.headers()}}],n);return this.assertOk(o,n)}async fetchWithRetry(t,n){for(let o=0;;o++){let[a,i]=t(),l;try{l=await this.fetchImpl(a,i)}catch(c){if(o>=As)throw new Ke(`${n} failed: network error`,"network",void 0,c);Y.debug("request network error \u2014 retrying",{label:n,attempt:o}),await So(Is(o));continue}if(l.ok||!K_.has(l.status)||o>=As)return l;let s=j_(l.headers)??Is(o);Y.debug("request retryable status \u2014 retrying",{label:n,status:l.status,attempt:o,wait:s}),await So(s)}}async assertOk(t,n){if(!t.ok)throw new Ke(`${n} failed: ${t.status}`,"server",t.status);return await t.json()}url(t){return/^https?:\/\//i.test(t)?t:`${this.opts.agentApiBaseUrl}${t}`}dataUrl(t){return/^https?:\/\//i.test(t)?t:`${this.opts.dataApiBaseUrl}${t}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function X_(e){return e.includes("webm")?"webm":e.includes("ogg")?"ogg":e.includes("mp4")||e.includes("m4a")?"m4a":e.includes("mpeg")?"mp3":e.includes("wav")?"wav":"bin"}function Y_(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.visitorId=="string"&&typeof t.conversationId=="string"}function Ms(e,t){let n=e?[{kind:"text",id:"t0",textSig:H(e),doneSig:H(!0)}]:[];return{id:Ge(),role:"user",createdAt:Date.now(),status:"complete",attachments:t,partsSig:H(n)}}function bn(){return{id:Ge(),role:"assistant",createdAt:Date.now(),status:"streaming",partsSig:H([])}}function Os(e){let t=Ge();return J_({id:t,role:e.role,createdAt:Date.now(),status:"complete",ephemeral:!0,parts:[{kind:"text",id:`${t}-t0`,text:e.text,done:!0}]})}function J_(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,canceled:e.canceled,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,ephemeral:e.ephemeral,attachments:e.attachments,feedback:e.feedback,partsSig:H(e.parts.map(tu))}}function Qr(e){let t=e.parts.map((o,a)=>o.type==="text"?{kind:"text",id:`${e.id}-t${a}`,textSig:H(o.text),doneSig:H(!0)}:o.type==="reasoning"?{kind:"reasoning",id:`${e.id}-r${a}`,textSig:H(o.text),doneSig:H(o.state!=="streaming")}:o.type==="step-start"?{kind:"step-start",id:`${e.id}-ss${a}`}:o.type==="file"?{kind:"file",url:o.url,mediaType:o.mediaType}:o.type==="source-url"?{kind:"source",sourceId:o.sourceId,url:o.url,title:o.title}:o.type==="source-document"?{kind:"source",sourceId:o.sourceId,title:o.title,filename:o.filename,mediaType:o.mediaType}:o.type==="data-suggestions"?null:o.type.startsWith("tool-")?{kind:"tool",toolCallId:o.toolCallId,toolName:Cs(o.type),inputPartialSig:H(""),inputSig:H(o.input),outputSig:H(o.output),errorSig:H(o.errorText),stateSig:H(o.state),approvalSig:H(o.approval)}:null).filter(o=>o!==null),n=e.parts.find(o=>o.type==="data-suggestions");return{id:e.id,role:e.role,operatorInitials:e.operatorInitials,suggestions:n?.type==="data-suggestions"?xo(n.data):void 0,serverMessageId:e.id,createdAt:yo(e.createdAt)??Date.now(),status:e.status==="failed"?"error":"complete",canceled:e.status==="canceled",feedback:e.feedback??null,partsSig:H(t)}}function Ns(e,t){let n=e.findIndex(o=>o.id===t.id);return n>=0?{list:e.map((o,a)=>a===n?t:o),appended:!1}:{list:[...e,t],appended:!0}}var Q_=new Set(["completed","failed","canceled"]);function Z_(e){return!e.parts.some(t=>t.type==="text"&&t.text.trim()!==""||t.type.startsWith("tool-")||t.type==="file"||t.type==="source-url"||t.type==="source-document")}function eu(e){return e.role==="assistant"&&e.status!=null&&!Q_.has(e.status)&&Z_(e)}function Zr(e){return e.filter(t=>!eu(t)).map(Qr)}function Ds(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,canceled:e.canceled,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,ephemeral:e.ephemeral,attachments:e.attachments,parts:e.partsSig.value.map(nu)}}function kt(e){let t="";for(let n of e.partsSig.value)n.kind==="text"&&(t+=n.textSig.value);return t}function Co(e){return kt(e).trim()!==""?!1:!e.partsSig.value.some(t=>t.kind==="tool"||t.kind==="file"||t.kind==="source")}function lt(e){return e.role==="assistant"&&e.status!=="streaming"&&Co(e)}function $s(e){return e.canceled===!0&&lt(e)}function ea(e,t){return e.pausedTurn?lt(e)?"drop":"complete-paused":t||lt(e)?"error":"complete"}function tu(e){return e.kind==="text"||e.kind==="reasoning"?{kind:e.kind,id:e.id,textSig:H(e.text),doneSig:H(e.done)}:e.kind==="tool"?{kind:"tool",toolCallId:e.toolCallId,toolName:e.toolName,inputPartialSig:H(e.inputPartial),inputSig:H(e.input),outputSig:H(e.output),errorSig:H(e.error),stateSig:H(e.state),approvalSig:H(e.approval)}:e}function nu(e){return e.kind==="text"||e.kind==="reasoning"?{kind:e.kind,id:e.id,text:e.textSig.value,done:e.doneSig.value}:e.kind==="tool"?{kind:"tool",toolCallId:e.toolCallId,toolName:e.toolName,inputPartial:e.inputPartialSig.value,input:e.inputSig.value,output:e.outputSig.value,error:e.errorSig.value,state:e.stateSig.value,approval:e.approvalSig.value}:e}var Fs=ee.scope("reducer"),To=class{constructor(t){j(this,"messagesSig",t);j(this,"active",null);j(this,"openTextParts",new Map);j(this,"partSeq",0)}attach(t){this.active=t,this.openTextParts.clear()}detach(){this.active=null,this.openTextParts.clear()}ensureTextPart(t,n,o){let a=`${n}:${o}`,i=this.openTextParts.get(a);if(i)return i;let l={kind:n,id:`${o}#${this.partSeq++}`,textSig:H(""),doneSig:H(!1)};return this.openTextParts.set(a,l),Pn(t,l),l}apply(t){let n=this.active;if(n)switch(t.type){case"start":t.messageId&&(n.serverMessageId=t.messageId);return;case"finish-step":this.openTextParts.clear();return;case"start-step":Pn(n,{kind:"step-start",id:`ss-${this.partSeq++}`});return;case"finish":Fs.debug("finish",{reason:t.finishReason,canContinue:t.canContinue}),n.status="complete",t.finishReason&&(n.finishReason=t.finishReason),this.bumpDone(n);return;case"error":Fs.warn("stream error chunk",{errorText:t.errorText}),n.status="error",n.errorText=t.errorText,this.bumpDone(n);return;case"text-start":this.ensureTextPart(n,"text",t.id);return;case"text-delta":{let o=this.ensureTextPart(n,"text",t.id);o.textSig.value+=t.delta;return}case"text-end":this.ensureTextPart(n,"text",t.id).doneSig.value=!0;return;case"reasoning-start":this.ensureTextPart(n,"reasoning",t.id).doneSig.value=!1;return;case"reasoning-delta":{let o=this.ensureTextPart(n,"reasoning",t.id);o.textSig.value+=t.delta;return}case"reasoning-end":this.ensureTextPart(n,"reasoning",t.id).doneSig.value=!0;return;case"tool-input-start":case"tool-input-delta":case"tool-input-available":case"tool-output-available":case"tool-output-error":case"tool-output-denied":case"tool-approval-request":ou(n,t);return;case"file":Pn(n,{kind:"file",url:t.url,mediaType:t.mediaType});return;case"source-url":Bs(n,{kind:"source",sourceId:t.sourceId,url:t.url,title:t.title});return;case"source-document":Bs(n,{kind:"source",sourceId:t.sourceId,title:t.title,filename:t.filename,mediaType:t.mediaType});return;case"data-notification":return;case"data-conversation-rebind":return;case"data-suggestions":n.suggestions=xo(t.data);return;case"data-control-state":n.pausedTurn=!0;return;case"data-message":return;default:{let o=t}}}bumpDone(t){t.partsSig.value=[...t.partsSig.value],this.messagesSig.value=[...this.messagesSig.value]}};function wt(e,t,n){let o=e.partsSig.value.find(i=>i.kind==="tool"&&i.toolCallId===t);if(o)return o;let a={kind:"tool",toolCallId:t,toolName:n??"tool",inputPartialSig:H(""),inputSig:H(void 0),outputSig:H(void 0),errorSig:H(void 0),stateSig:H("input-streaming"),approvalSig:H(void 0)};return Pn(e,a),a}function Pn(e,t){e.partsSig.value=[...e.partsSig.value,t]}function Bs(e,t){e.partsSig.value.some(n=>n.kind==="source"&&n.sourceId===t.sourceId)||Pn(e,t)}function ou(e,t){switch(t.type){case"tool-input-start":wt(e,t.toolCallId,t.toolName);return;case"tool-input-delta":{let n=wt(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case"tool-input-available":{let n=wt(e,t.toolCallId,t.toolName);n.inputSig.value=t.input,n.stateSig.value="input-available";return}case"tool-approval-request":{let n=wt(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value="approval-requested";return}case"tool-output-available":{let n=wt(e,t.toolCallId);n.outputSig.value=t.output,n.stateSig.value="output-available";return}case"tool-output-error":{let n=wt(e,t.toolCallId);n.errorSig.value=t.errorText,n.stateSig.value="output-error";return}case"tool-output-denied":{let n=wt(e,t.toolCallId);n.stateSig.value="output-denied";return}default:return}}var Hs=ee.scope("feedback:audio"),Eo=class{constructor(){j(this,"ctx",null);j(this,"master",null);j(this,"buffers",new Map)}unlock(){if(this.ctx){this.ctx.state==="suspended"&&this.ctx.resume();return}let t=globalThis.AudioContext??globalThis.webkitAudioContext;if(t)try{this.ctx=new t,this.master=this.ctx.createGain(),this.master.gain.value=1,this.master.connect(this.ctx.destination)}catch(n){Hs.warn("AudioContext init failed",{err:n})}}setVolume(t){if(!this.master||!this.ctx)return;let n=Math.max(0,Math.min(1,t));this.master.gain.setTargetAtTime(n,this.ctx.currentTime,.01)}playTone(t){let n=this.ctx,o=this.master;if(!n||!o||n.state!=="running")return;let a=n.currentTime,i=t.noteMs/1e3;t.notes.forEach((l,s)=>{let c=n.createOscillator();c.type=t.type,c.frequency.value=l;let _=n.createGain(),p=a+s*i;_.gain.setValueAtTime(1e-4,p),_.gain.exponentialRampToValueAtTime(t.peakGain,p+.005),_.gain.exponentialRampToValueAtTime(1e-4,p+i),c.connect(_).connect(o),c.start(p),c.stop(p+i+.01)})}async playUrl(t){let n=this.ctx,o=this.master;if(!n||!o||n.state!=="running")return;let a=await this.getBuffer(t);if(!a)return;let i=n.createBufferSource();i.buffer=a,i.connect(o),i.start()}destroy(){this.ctx&&this.ctx.close().catch(()=>{}),this.ctx=null,this.master=null,this.buffers.clear()}async getBuffer(t){if(!this.ctx)return null;let n=this.buffers.get(t);if(n)return n instanceof Promise,n;let o=this.ctx,a=fetch(t).then(i=>i.ok?i.arrayBuffer():Promise.reject(new Error(`fetch ${i.status}`))).then(i=>o.decodeAudioData(i)).then(i=>(this.buffers.set(t,i),i)).catch(i=>(Hs.warn("audio fetch/decode failed",{url:t,err:i}),this.buffers.delete(t),null));return this.buffers.set(t,a),a}};var zs={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},Us={messageReceived:{notes:[880,1318.51],noteMs:90,type:"sine",peakGain:.45},messageSent:{notes:[1568],noteMs:60,type:"sine",peakGain:.25},error:{notes:[523.25,392],noteMs:120,type:"triangle",peakGain:.55},voiceStart:{notes:[1318.51],noteMs:50,type:"sine",peakGain:.3},voiceStop:{notes:[880],noteMs:50,type:"sine",peakGain:.3}};var ft=null,Ro=0;function ru(){return typeof navigator<"u"&&typeof navigator.vibrate=="function"}function au(){if(typeof document>"u")return null;let e=document.createElement("input");e.type="checkbox",e.setAttribute("switch",""),e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e.id=`__${x.cssPrefix}_haptic_${Math.random().toString(36).slice(2)}`;let t=document.createElement("label");t.htmlFor=e.id,t.setAttribute("aria-hidden","true");let n="position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;opacity:0!important;pointer-events:none!important;";return e.style.cssText=n,t.style.cssText=n,document.body.append(e,t),{input:e,label:t}}function qs(e){if(!(e===0||Array.isArray(e)&&e.every(t=>t===0))){if(ru())try{navigator.vibrate(e);return}catch{}if(ft||(ft=au()),!!ft)try{ft.label.click()}catch{}}}function Vs(){Ro++;let e=!1;return()=>{e||(e=!0,Ro=Math.max(0,Ro-1),Ro===0&&ft&&(ft.input.remove(),ft.label.remove(),ft=null))}}var iu=ee.scope("feedback"),su=100,Ao=class{constructor(t,n){j(this,"mutedSig",H(!1));j(this,"audio",new Eo);j(this,"releaseHaptics");j(this,"sound");j(this,"haptics");j(this,"lastPlayed",new Map);j(this,"reducedMotionMq",null);this.sound=t,this.haptics=n,this.releaseHaptics=Vs(),this.audio.setVolume(this.effectiveVolume()),typeof matchMedia<"u"&&(this.reducedMotionMq=matchMedia("(prefers-reduced-motion: reduce)"))}unlock(){this.audio.unlock(),this.audio.setVolume(this.effectiveVolume())}update(t,n){this.sound=t,this.haptics=n,this.audio.setVolume(this.effectiveVolume())}setMuted(t){this.mutedSig.value!==t&&(this.mutedSig.value=t)}toggleMuted(){this.mutedSig.value=!this.mutedSig.value}play(t){this.mutedSig.value||this.isDeduped(t)||(this.lastPlayed.set(t,performance.now()),this.sound.enabled&&this.playSound(t),this.haptics.enabled&&this.isTouchDevice()&&this.playHaptic(t))}destroy(){this.audio.destroy(),this.releaseHaptics()}isDeduped(t){let n=this.lastPlayed.get(t);return n===void 0?!1:performance.now()-n<su}playSound(t){let n=this.sound.events?.[t];if(n===!1)return;if(typeof n=="string"){this.audio.playUrl(n).catch(a=>iu.warn("audio play failed",{err:a,url:n}));return}let o=Us[t];o&&this.audio.playTone(o)}playHaptic(t){if(this.reducedMotionMq?.matches)return;let n=this.haptics.events?.[t];if(n===!1)return;let o=n===!0||n===void 0?zs[t]:n;qs(o)}effectiveVolume(){let t=this.sound.volume??.3;return this.reducedMotionMq?.matches?t*.5:t}isTouchDevice(){return typeof window>"u"?!1:matchMedia("(hover: none) and (pointer: coarse)").matches}};function Ct(e,t){return e instanceof Ke&&e.status===429?t.errorRateLimited:t.errorGeneric}var lu=0;function r(e,t,n,o,a,i){t||(t={});var l,s,c=t;if("ref"in c)for(s in c={},t)s=="ref"?l=t[s]:c[s]=t[s];var _={type:e,props:c,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--lu,__i:-1,__u:0,__source:a,__self:i};if(typeof e=="function"&&(l=e.defaultProps))for(s in l)c[s]===void 0&&(c[s]=l[s]);return te.vnode&&te.vnode(_),_}var F={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24"},yn=`${x.cssPrefix}-icon-dir`,ta=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z"})}),et=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M18 6 6 18M6 6l12 12"})}),Ws=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M12 5v14M5 12h14"})}),Gs=()=>r("svg",{...F,class:yn,"aria-hidden":"true",children:[r("path",{d:"m22 2-7 20-4-9-9-4Z"}),r("path",{d:"M22 2 11 13"})]}),Ks=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M12 19V5M5 12l7-7 7 7"})}),js=()=>r("svg",{...F,class:yn,"aria-hidden":"true",children:r("path",{d:"M3 20V4l18 8-18 8Z"})}),jt=()=>r("svg",{...F,class:yn,"aria-hidden":"true",children:r("path",{d:"m9 18 6-6-6-6"})}),Xs=()=>r("svg",{...F,"aria-hidden":"true",children:r("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}),Ys=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"m21 11-9 9a5.5 5.5 0 0 1-7.78-7.78l8.49-8.49a3.67 3.67 0 0 1 5.19 5.19l-8.49 8.49a1.83 1.83 0 0 1-2.6-2.6l7.78-7.78"})}),Js=()=>r("svg",{...F,"aria-hidden":"true",children:[r("rect",{x:"9",y:"2",width:"6",height:"12",rx:"3"}),r("path",{d:"M5 10a7 7 0 0 0 14 0M12 19v3"})]}),Qs=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5"})}),Zs=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5"})}),el=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z"})}),tl=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7"})}),nl=()=>r("svg",{...F,"aria-hidden":"true",viewBox:"0 0 10 10",children:r("path",{d:"M9 1L1 9M9 5L5 9M9 9H9",strokeWidth:"1.5"})}),ol=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),r("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),r("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]}),rl=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10"})}),al=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6"})}),il=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M3 18 8 6l5 12M4.7 14h6.6"}),r("path",{d:"M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2"})]}),sl=()=>r("svg",{...F,class:yn,"aria-hidden":"true",children:r("path",{d:"m5 6 6 6-6 6M13 6l6 6-6 6"})}),Tt=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M20 6 9 17l-5-5"})}),ll=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M3 3v6h6"}),r("path",{d:"M3.05 13A9 9 0 1 0 6 5.3L3 9"}),r("path",{d:"M12 7v5l3 2"})]}),cl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("path",{d:"M2 12h20"}),r("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),xn=()=>r("svg",{...F,class:yn,"aria-hidden":"true",children:r("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),dl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M12 20h9"}),r("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),Et=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"m6 9 6 6 6-6"})}),_l=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"}),r("path",{d:"M14 2v6h6"})]}),cu=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z"}),r("path",{d:"M19 15v4M17 17h4M5 3v2M4 4h2"})]}),na=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z"})}),Sn=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),r("path",{d:"M12 17h.01"})]}),du=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"m15 4 3 3-9 9-3-3z"}),r("path",{d:"M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2"})]}),_u=()=>r("svg",{...F,"aria-hidden":"true",children:[r("rect",{x:"4",y:"8",width:"16",height:"12",rx:"2"}),r("path",{d:"M12 8V4"}),r("circle",{cx:"12",cy:"3",r:"1"}),r("path",{d:"M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5"})]}),oa=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M4 14v-2a8 8 0 0 1 16 0v2"}),r("rect",{x:"2",y:"14",width:"4",height:"6",rx:"1.5"}),r("rect",{x:"18",y:"14",width:"4",height:"6",rx:"1.5"}),r("path",{d:"M20 20v1a3 3 0 0 1-3 3h-5"})]}),uu=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("circle",{cx:"12",cy:"12",r:"4"}),r("path",{d:"m4.93 4.93 4.24 4.24M14.83 14.83l4.24 4.24M14.83 9.17l4.24-4.24M4.93 19.07l4.24-4.24"})]}),ra=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"11",cy:"11",r:"7"}),r("path",{d:"m21 21-4.3-4.3"})]}),ul=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"m8.5 12 2.5 2.5 4.5-5"})]}),pl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M3 9.5 12 3l9 6.5"}),r("path",{d:"M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9"})]}),ml=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"m3 11 15-5v12L3 13z"}),r("path",{d:"M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z"}),r("path",{d:"M7 15v3a2 2 0 0 0 4 0v-2"}),r("path",{d:"M21 10a3 3 0 0 1 0 4"})]}),kn=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z"}),r("path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1"})]}),fl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"4"}),r("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}),gl=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),hl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"M12 3v18"}),r("path",{d:"M12 3a9 9 0 0 1 0 18z",fill:"currentColor",stroke:"none"})]}),pu=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"10.5",cy:"10.5",r:"6.5"}),r("path",{d:"M8 11a2.5 2.5 0 0 0 5 0"}),r("path",{d:"m20 20-4.4-4.4"})]}),mu=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M12 3.5 13.6 9 19 10.5 13.6 12 12 17.5 10.4 12 5 10.5 10.4 9z"}),r("path",{d:"M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5"})]}),fu=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M4 18h16"}),r("path",{d:"M5 18a7 7 0 0 1 14 0"}),r("path",{d:"M12 8V6"}),r("path",{d:"M10 6h4"})]}),gu=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M7 11V6.5a1.5 1.5 0 0 1 3 0V10"}),r("path",{d:"M10 10V5.5a1.5 1.5 0 0 1 3 0V10"}),r("path",{d:"M13 10V6.5a1.5 1.5 0 0 1 3 0V12"}),r("path",{d:"M16 9.5a1.5 1.5 0 0 1 3 0v2.5a7 7 0 0 1-7 7 7 7 0 0 1-6.4-4.2L4 12.5a1.5 1.5 0 0 1 2.6-1.5L7 11"})]}),vl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),r("path",{d:"M5 15a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2"})]}),bl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M7 10v11H4a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1z"}),r("path",{d:"M7 10l4-7a2.5 2.5 0 0 1 2.5 2.5V8h5a2 2 0 0 1 2 2.3l-1.2 8A2 2 0 0 1 17.3 20H7"})]}),Pl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M17 14V3h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1z"}),r("path",{d:"M17 14l-4 7a2.5 2.5 0 0 1-2.5-2.5V16h-5a2 2 0 0 1-2-2.3l1.2-8A2 2 0 0 1 6.7 4H17"})]}),yl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"3.5"}),r("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M19.1 4.9l-2.1 2.1M7 17l-2.1 2.1"})]}),xl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"M12 7v5l3 2"})]}),Io=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"m8.5 12 2.5 2.5 4.5-5"})]}),Lo=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"m15 9-6 6M9 9l6 6"})]}),Sl={chat:ta,message:na,bubbles:kn,spark:cu,wand:du,bot:_u,help:Sn,lifebuoy:uu,headset:oa,search:pu,sparkles:mu,concierge:fu,wave:gu};var I=x.cssPrefix,S={launcher:`${I}-launcher`,callout:`${I}-callout`,calloutDismiss:`${I}-callout-dismiss`,panel:`${I}-panel`,panelHeader:`${I}-panel-header`,resizeGrip:`${I}-resize-grip`,scrollToBottom:`${I}-scroll-to-bottom`,actionHistory:`${I}-action-history`,actionClose:`${I}-action-close`,langSegment:`${I}-lang-segment`,composer:`${I}-composer`,composerInput:`${I}-composer-input`,composerSend:`${I}-composer-send`,composerStop:`${I}-composer-stop`,composerAttach:`${I}-composer-attach`,composerFileInput:`${I}-composer-file-input`,composerVoice:`${I}-composer-voice`,attachmentChip:`${I}-attachment-chip`,attachmentRemove:`${I}-attachment-remove`,suggestion:`${I}-suggestion`,messageBubble:`${I}-message`,messageRetry:`${I}-message-retry`,messageFeedback:`${I}-message-feedback`,feedbackUp:`${I}-feedback-up`,feedbackDown:`${I}-feedback-down`,messageCopy:`${I}-message-copy`,historyPane:`${I}-history-pane`,historyBack:`${I}-history-back`,historyItem:`${I}-history-item`,sidebar:`${I}-sidebar`,sidebarToggle:`${I}-sidebar-toggle`,sidebarNewConversation:`${I}-sidebar-new-conversation`,sidebarItem:`${I}-sidebar-item`,messengerHome:`${I}-messenger-home`,modulesEmpty:`${I}-modules-empty`,tab:`${I}-tab`,tabBadge:`${I}-tab-badge`,homeView:`${I}-home-view`,homeGreeting:`${I}-home-greeting`,homeBrand:`${I}-home-brand`,backHeader:`${I}-back-header`,contentView:`${I}-content-view`,contentScroll:`${I}-content-scroll`,homeSearch:`${I}-home-search`,helpSearch:`${I}-help-search`,homeRecent:`${I}-home-recent`,homeContentRow:`${I}-home-content-row`,helpArticle:`${I}-help-article`,newsItem:`${I}-news-item`,formGate:`${I}-form-gate`,formDone:`${I}-form-done`,formDoneToggle:`${I}-form-done-toggle`,formAnswers:`${I}-form-answers`,formFill:`${I}-form-fill`,formSubmit:`${I}-form-submit`,formSkip:`${I}-form-skip`,formField:`${I}-form-field`,toolAskQuestions:`${I}-tool-ask-questions`,toolInputSubmit:`${I}-tool-input-submit`,toolInputSkip:`${I}-tool-input-skip`,toolApproval:`${I}-tool-approval`,toolApprove:`${I}-tool-approve`,toolReject:`${I}-tool-reject`,toolEdit:`${I}-tool-edit`,toolDecision:`${I}-tool-decision`,toolAskSummary:`${I}-ask-questions-summary`,toolAskOptions:`${I}-ask-questions-options-toggle`,toolCall:`${I}-tool-call`,source:`${I}-source`,operatorRequest:`${I}-operator-request`,operatorBanner:`${I}-operator-banner`};function we(e,t){return`${e}-${t}`}var Mo=x.cssPrefix;function kl({onToggle:e,launcher:t,strings:n,leaving:o,edgeTab:a}){let i=t.variant!=="circle"&&!!t.label;return r("button",{type:"button",class:`${Mo}-fab`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":a?"true":void 0,"data-leaving":o?"true":void 0,"data-testid":S.launcher,onClick:e,"aria-label":n.launcherOpen,children:[hu(t.icon),i?r("span",{class:`${Mo}-fab-label`,children:Ne(n,t.label??"")}):null]})}function hu(e){let t=Sl[e];return t?r(t,{}):r(vu,{source:e})}function vu({source:e}){return r("span",{ref:t=>{t&&bu(t,e)},"aria-hidden":"true"})}function bu(e,t){if(e.dataset.svgMounted!==t)try{let o=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;o&&o.tagName.toLowerCase()==="svg"&&(e.replaceChildren(document.importNode(o,!0)),e.dataset.svgMounted=t)}catch{}}function wl({callout:e,launcherPosition:t,strings:n,closeLabel:o,onDismiss:a}){let[i,l]=R(!1);return T(()=>{let s=setTimeout(()=>l(!0),e.delayMs);return()=>clearTimeout(s)},[e.delayMs]),T(()=>{if(!i||e.autoDismissMs<=0)return;let s=setTimeout(a,e.autoDismissMs);return()=>clearTimeout(s)},[i,e.autoDismissMs,a]),i?r("div",{class:`${Mo}-callout`,role:"status","data-shape":e.shape,"data-position":Pu(e.position,t),"data-animated":e.animated?"true":void 0,"data-testid":S.callout,children:[r("span",{children:Ne(n,e.text)}),r("button",{type:"button",class:`${Mo}-callout-close`,onClick:a,"aria-label":o,title:o,"data-testid":S.calloutDismiss,children:r(et,{})})]}):null}function Pu(e,t){let n=t.endsWith("-right"),o=t.startsWith("bottom-");return e==="vertical"?o?"top":"bottom":n?"left":"right"}function Oo({panelEl:e,resize:t,position:n,initialSize:o,onSizeChange:a,strings:i}){let l=x.cssPrefix,s=N(null);if(T(()=>{if(!e)return;let m=e.style;t.minWidth&&m.setProperty(`--${l}-resize-min-w`,t.minWidth),t.maxWidth&&m.setProperty(`--${l}-resize-max-w`,t.maxWidth),t.minHeight&&m.setProperty(`--${l}-resize-min-h`,t.minHeight),t.maxHeight&&m.setProperty(`--${l}-resize-max-h`,t.maxHeight),o&&(m.setProperty(`--${l}-widget-w`,`${o.width}px`),m.setProperty(`--${l}-widget-h`,`${o.height}px`))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,l,o]),!e)return null;let c=n.startsWith("top-"),_=n.endsWith("-right"),p=`${l}-resize-grip ${l}-resize-grip--${c?"bottom":"top"}-${_?"left":"right"}`,v=m=>{if(!e)return;let k=m.currentTarget,h=e.getBoundingClientRect();s.current={pointerId:m.pointerId,startX:m.clientX,startY:m.clientY,startW:h.width,startH:h.height,dirX:_?-1:1,dirY:c?1:-1},k.setPointerCapture(m.pointerId),e.setAttribute("data-resizing",""),m.preventDefault()},u=m=>{let k=s.current;if(!k||m.pointerId!==k.pointerId||!e)return;let h=(m.clientX-k.startX)*k.dirX,b=(m.clientY-k.startY)*k.dirY;e.style.setProperty(`--${l}-widget-w`,`${k.startW+h}px`),e.style.setProperty(`--${l}-widget-h`,`${k.startH+b}px`)},f=m=>{let k=s.current;if(!k||m.pointerId!==k.pointerId||!e)return;m.currentTarget.releasePointerCapture(m.pointerId),e.removeAttribute("data-resizing");let h=e.getBoundingClientRect();a({width:Math.round(h.width),height:Math.round(h.height)}),s.current=null};return r("div",{class:p,role:"separator","aria-orientation":"vertical","aria-label":i.resizeHandle,title:i.resizeHandle,onPointerDown:v,onPointerMove:u,onPointerUp:f,onPointerCancel:f,"data-testid":S.resizeGrip,children:r(nl,{})})}var Rt=x.cssPrefix,yu=`.${Rt}-header, .${Rt}-back-header, .${Rt}-home-hero`,xu='button, a, input, textarea, select, [role="tab"], [contenteditable]',Cl=56;function No(e,t){T(()=>{if(!t||!e)return;let n=c=>Number.parseFloat(c)||0,o=(c,_)=>Math.min(_,Math.max(-_,c)),a=null,i=c=>{let _=c.target;if(!(_ instanceof Element)||!_.closest(yu)||_.closest(xu))return;let p=e.getBoundingClientRect();a={id:c.pointerId,x:c.clientX,y:c.clientY,dx:n(e.style.getPropertyValue(`--${Rt}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${Rt}-modal-dy`)),maxX:(window.innerWidth+p.width)/2-Cl,maxY:(window.innerHeight+p.height)/2-Cl},e.dataset.dragging="true",c.preventDefault()},l=c=>{if(!a||c.pointerId!==a.id)return;let _=o(a.dx+c.clientX-a.x,a.maxX),p=o(a.dy+c.clientY-a.y,a.maxY);e.style.setProperty(`--${Rt}-modal-dx`,`${_}px`),e.style.setProperty(`--${Rt}-modal-dy`,`${p}px`)},s=c=>{!a||c.pointerId!==a.id||(a=null,delete e.dataset.dragging)};return e.addEventListener("pointerdown",i),window.addEventListener("pointermove",l),window.addEventListener("pointerup",s),window.addEventListener("pointercancel",s),()=>{e.removeEventListener("pointerdown",i),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",s),window.removeEventListener("pointercancel",s)}},[e,t])}function wn(e,t,n){switch(e){case"clear":case"sound":case"history":case"language":case"theme":case"textSize":return!0;case"expand":return t==="floating";case"fullscreen":return t!=="standalone";case"close":return t==="standalone"||t==="page"?!1:t==="inline"?n==="fullscreen":!0}}function Do(e,t,n){return wn("close",e,t)?n.includes("close"):!1}function Tl(e,t){return e==="inline"&&t==="fullscreen"?"exit-fullscreen":"close"}var Su='a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])';function $o(e){let t=n=>{if(n.key!=="Tab")return;let o=[...e.querySelectorAll(Su)].filter(s=>s.offsetParent!==null||s===document.activeElement);if(o.length===0){n.preventDefault();return}let a=o[0],i=o[o.length-1];if(!a||!i)return;let l=e.getRootNode().activeElement;n.shiftKey&&l===a?(n.preventDefault(),i.focus()):!n.shiftKey&&l===i&&(n.preventDefault(),a.focus())};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}function Fo(e){return e.trim().split(/\s+/).slice(0,2).map(t=>t.charAt(0).toUpperCase()).join("")}var aa=x.cssPrefix;function El({agent:e,strings:t}){let n=e.status??"online",o=Ne(t,e.name),a=e.title?Ne(t,e.title):null;return r("div",{class:`${aa}-agent`,children:[r("div",{class:`${aa}-agent-avatar`,"data-status":n,children:e.avatar?r("img",{src:e.avatar,alt:""}):r("span",{children:Fo(o)})}),r("div",{class:`${aa}-agent-meta`,children:[r("strong",{children:o}),a?r("span",{children:a}):null]})]})}var Rl=ee.scope("attachments");function Bo(e,t,n){let o=wu(e),a=[],i=[],l=Eu(n.accept),s=t.reduce((_,p)=>_+p.size,0),c=t.length;for(let _ of o){let p=ku(_,c,s,n,l);if(p){i.push({file:_,reason:p});continue}a.push(Tu(_)),s+=_.size,c+=1}return(a.length||i.length)&&Rl.debug("ingest",{accepted:a.length,rejected:i.map(_=>({name:_.file.name,reason:_.reason}))}),{accepted:a,rejected:i}}function ia(e){try{URL.revokeObjectURL(e.previewUrl)}catch(t){Rl.debug("revokeObjectURL failed",{error:t})}}function ku(e,t,n,o,a){return t>=o.maxCount?"count":n+e.size>o.maxBytes?"bytes":Ru(e,a)?null:"mime"}function wu(e){return e?Array.isArray(e)?e.filter(t=>t instanceof File):[...e].map(t=>t instanceof File?t:Cu(t)).filter(t=>t!==null):[]}function Cu(e){let t=e;return!t?.getAsFile||t.kind!=="file"?null:t.getAsFile()}function Tu(e){return{file:e,id:Ge(),mediaType:e.type||"application/octet-stream",name:e.name||"pasted-file",previewUrl:URL.createObjectURL(e),size:e.size}}function Eu(e){return e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean).map(t=>{if(t.startsWith("."))return{kind:"ext",ext:t};let[n="*",o="*"]=t.split("/");return{kind:"mime",type:n,subtype:o}})}function Ru(e,t){if(t.length===0)return!0;let[n="*",o="*"]=(e.type||"").toLowerCase().split("/"),a=(e.name||"").toLowerCase();return t.some(i=>i.kind==="ext"?a.endsWith(i.ext):(i.type==="*"||i.type===n)&&(i.subtype==="*"||i.subtype===o))}var Cn=x.cssPrefix;function Al({attachment:e,onRemove:t}){let n=e.mediaType.startsWith("image/");return r("span",{class:`${Cn}-attachment-chip`,title:e.name,"data-testid":we(S.attachmentChip,e.id),children:[n?r("img",{class:`${Cn}-attachment-thumb`,src:e.previewUrl,alt:""}):r("span",{class:`${Cn}-attachment-thumb`,"aria-hidden":"true",children:r(_l,{})}),r("span",{class:`${Cn}-attachment-name`,children:e.name}),r("button",{type:"button",class:`${Cn}-attachment-remove`,onClick:t,"aria-label":`Remove ${e.name}`,"data-testid":we(S.attachmentRemove,e.id),children:r(et,{})})]})}var sa={isSupported:!1,start:()=>{},stop:()=>{}};function la(e,t,n){return e==="disabled"?sa:e==="server"?Mu(n):Au(t)}function Au(e){let t=Iu();if(!t)return sa;let n=null;return{isSupported:!0,start(o,a){n=new t,n.continuous=!0,n.interimResults=!0,n.lang=e,n.addEventListener("result",l=>{let s=l,c="",_=!1;for(let p=s.resultIndex;p<s.results.length;p++){let v=s.results[p];v&&(c+=v[0].transcript,v.isFinal&&(_=!0))}o(c,_)});let i=()=>{n=null,a()};n.addEventListener("end",i),n.addEventListener("error",i),n.start()},stop(){n?.stop()}}}function Iu(){return window.SpeechRecognition??window.webkitSpeechRecognition}var Lu=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus","audio/mp4"];function Mu(e){if(typeof MediaRecorder>"u"||!navigator?.mediaDevices?.getUserMedia)return sa;let t=null,n=null,o=[],a=()=>{for(let i of n?.getTracks()??[])i.stop();n=null};return{isSupported:!0,async start(i,l){try{n=await navigator.mediaDevices.getUserMedia({audio:!0});let s=Ou();t=new MediaRecorder(n,s?{mimeType:s}:void 0),o=[],t.addEventListener("dataavailable",c=>{c.data.size>0&&o.push(c.data)}),t.addEventListener("stop",async()=>{let c=t?.mimeType??"audio/webm";a();let _=new Blob(o,{type:c});o=[];try{let{text:p}=await e(_,c);p&&i(p,!0)}catch{}finally{l()}}),t.start()}catch{a(),l()}},stop(){t?.stop()}}}function Ou(){for(let e of Lu)if(MediaRecorder.isTypeSupported(e))return e}var Ue=x.cssPrefix,At=ee.scope("composer");function Xt(e){return e.reduce((t,n)=>t+n.size,0)}var Nu={arrowUp:Ks,paperPlane:Gs,send:js,chevron:jt};function Il({options:e,transport:t,feedback:n,bus:o,isStreaming:a,operatorRequestEnabled:i,controlMode:l,onRequestOperator:s,onSend:c,onStop:_,attachApiRef:p}){let v=e.strings,[u,f]=R(""),[m,k]=R([]),[h,b]=R(!1),w=N(null),P=N(null),E=e.features.fileUpload,B=e.features.voice,[J,ie]=R(()=>la(B,e.locale,(L,z)=>t.transcribe(L,z)));T(()=>{h||B==="disabled"||ie(la(B,e.locale,(L,z)=>t.transcribe(L,z)))},[e.locale,B,t,h]),T(()=>{let L=w.current;if(!L)return;let z=L.getRootNode(),W="activeElement"in z?z.activeElement:null;W&&L.closest(`.${Ue}-panel`)?.contains(W)||L.focus({preventScroll:!0})},[]),T(()=>{let L=w.current;if(!L)return;if(u.length===0){L.style.height="";return}L.style.height="auto";let z=parseFloat(getComputedStyle(L).fontSize)*.7,W=Math.min(L.scrollHeight,160);L.style.height=`${W<40+z?40:W}px`},[u]);let ne=N(m);ne.current=m,T(()=>()=>ne.current.forEach(ia),[]),T(()=>{if(p)return p.current={attachFromDrop:L=>{let z=Bo(L,ne.current,e.attachments);z.accepted.length!==0&&(At.info("attach (drop)",{count:z.accepted.length,totalBytes:Xt(z.accepted)}),o.emit("attach",{count:z.accepted.length,totalBytes:Xt(z.accepted)}),k(W=>[...W,...z.accepted]))},fill:L=>{f(L);let z=w.current;z&&(z.focus({preventScroll:!0}),requestAnimationFrame(()=>z.setSelectionRange(z.value.length,z.value.length)))}},()=>{p.current&&(p.current=null)}},[p,e.attachments]),T(()=>{let L=w.current;if(!L)return;let z=L.closest(`.${Ue}-panel`);if(!z)return;let W=Se=>{let ot=Se.clipboardData;if(!ot)return;let $e=Se.target?.closest?.("input, textarea, [contenteditable]:not([contenteditable='false'])");if($e&&$e!==L)return;if(E){let Pe=Bo(ot.items,ne.current,e.attachments);if(Pe.accepted.length>0){Se.preventDefault(),At.info("attach (paste)",{count:Pe.accepted.length,totalBytes:Xt(Pe.accepted)}),o.emit("attach",{count:Pe.accepted.length,totalBytes:Xt(Pe.accepted)}),k(fe=>[...fe,...Pe.accepted]);return}}if($e===L)return;let be=ot.getData("text/plain");be&&(Se.preventDefault(),f(Pe=>Pe+be),L.focus())};return z.addEventListener("paste",W),()=>z.removeEventListener("paste",W)},[E,e.attachments,Ue]);let Z=()=>{let L=u.trim();!L&&m.length===0||a||(c(L,m),f(""),k([]))},O=L=>{L.key!=="Enter"||L.shiftKey||L.isComposing||(L.preventDefault(),a?_():Z())},D=L=>{let z=L.target,W=Bo(z.files,m,e.attachments);W.accepted.length>0&&(At.info("attach (file picker)",{count:W.accepted.length,totalBytes:Xt(W.accepted)}),o.emit("attach",{count:W.accepted.length,totalBytes:Xt(W.accepted)}),k(Se=>[...Se,...W.accepted])),z.value=""},K=L=>{At.info("removeAttachment",{id:L}),o.emit("removeAttachment",{id:L}),k(z=>{let W=z.find(Se=>Se.id===L);return W&&ia(W),z.filter(Se=>Se.id!==L)})},X=N(null),se=()=>{if(J.isSupported){if(h){let L=X.current?Date.now()-X.current:0;At.info("voiceStop",{durationMs:L}),o.emit("voiceStop",{durationMs:L}),J.stop(),b(!1),n.play("voiceStop"),X.current=null;return}X.current=Date.now(),At.info("voiceStart"),o.emit("voiceStart",void 0),b(!0),n.play("voiceStart"),J.start((L,z)=>f(W=>z?`${W}${L} `:W),()=>{if(b(!1),X.current){let L=Date.now()-X.current;At.debug("voiceStop (auto)",{durationMs:L}),o.emit("voiceStop",{durationMs:L}),X.current=null}})}},ce=Nu[e.composer.sendButton.icon];return r("div",{class:`${Ue}-composer`,"data-testid":S.composer,children:[m.length>0?r("div",{class:`${Ue}-attachments`,children:m.map(L=>r(Al,{attachment:L,onRemove:()=>K(L.id)},L.id))}):null,r("div",{class:`${Ue}-composer-row`,children:[r("div",{class:`${Ue}-composer-actions`,children:[E?r("button",{type:"button",class:`${Ue}-icon-btn`,onClick:()=>P.current?.click(),"aria-label":v.attach,"data-testid":S.composerAttach,children:r(Ys,{})}):null,J.isSupported?r("button",{type:"button",class:`${Ue}-icon-btn`,onClick:se,"aria-label":h?v.micStop:v.micStart,"aria-pressed":h,"data-recording":h?"true":void 0,"data-testid":S.composerVoice,children:r(Js,{})}):null,i&&l==="ai-agent"&&s?r("button",{type:"button",class:`${Ue}-icon-btn`,onClick:s,"aria-label":v.talkToOperator,title:v.talkToOperator,"data-testid":S.operatorRequest,children:r(oa,{})}):null]}),r("textarea",{ref:w,class:`${Ue}-textarea`,rows:1,value:u,placeholder:v.composerPlaceholder,onInput:L=>f(L.target.value),onKeyDown:O,"aria-label":v.composerPlaceholder,"data-testid":S.composerInput}),a?r("button",{type:"button",class:`${Ue}-send`,onClick:_,"aria-label":v.stop,"data-testid":S.composerStop,children:r(Xs,{})}):r("button",{type:"button",class:`${Ue}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:Z,disabled:!u.trim()&&m.length===0,"aria-label":v.send,"data-testid":S.composerSend,children:r(ce,{})})]}),r("input",{ref:P,type:"file",multiple:!0,accept:e.attachments.accept,onChange:D,class:`${Ue}-sr-only`,"data-testid":S.composerFileInput})]})}var Du=x.cssPrefix;function Ll({visible:e,strings:t}){return e?r("div",{class:`${Du}-dropzone`,role:"status","aria-live":"polite",children:t.dropZone}):null}function Ho({containerRef:e,onDrop:t}){let[n,o]=R(!1);return T(()=>{let a=e.current;if(!a)return;let i=0,l=p=>{i+=1,p.dataTransfer?.types.includes("Files")&&(p.preventDefault(),o(!0))},s=()=>{i-=1,!(i>0)&&(i=0,o(!1))},c=p=>{p.dataTransfer?.types.includes("Files")&&p.preventDefault()},_=p=>{i=0,o(!1),p.dataTransfer&&(p.preventDefault(),t(p.dataTransfer.items))};return a.addEventListener("dragenter",l),a.addEventListener("dragleave",s),a.addEventListener("dragover",c),a.addEventListener("drop",_),()=>{a.removeEventListener("dragenter",l),a.removeEventListener("dragleave",s),a.removeEventListener("dragover",c),a.removeEventListener("drop",_)}},[e,t]),{visible:n}}function Ml({itemCount:e,initialFocusIndex:t}){let[n,o]=R(!1),a=N(null),i=N(null),[l,s]=R(-1),c=$(()=>{o(!1),s(-1),a.current?.focus()},[]),_=$(()=>o(u=>!u),[]);T(()=>{if(!n)return;let u=f=>{let m=i.current,k=a.current;if(!m||!k)return;let h=f.composedPath();h.includes(m)||h.includes(k)||(o(!1),s(-1))};return document.addEventListener("click",u,!0),()=>document.removeEventListener("click",u,!0)},[n]),T(()=>{if(!n||e===0)return;let u=t?.()??0,f=u<0||u>=e?0:u;s(f)},[n,e,t]),T(()=>{if(!n||l<0)return;i.current?.querySelectorAll("[role='menuitem']")?.[l]?.focus()},[n,l]);let p=$(u=>{(u.key==="ArrowDown"||u.key==="Enter"||u.key===" ")&&(u.preventDefault(),o(!0))},[]),v=$(u=>{if(e!==0)switch(u.key){case"Escape":u.preventDefault(),c();return;case"ArrowDown":u.preventDefault(),s(f=>(f+1)%e);return;case"ArrowUp":u.preventDefault(),s(f=>(f-1+e)%e);return;case"Home":u.preventDefault(),s(0);return;case"End":u.preventDefault(),s(e-1)}},[e,c]);return{open:n,focusIndex:l,triggerRef:a,menuRef:i,toggle:_,close:c,onTriggerKey:p,onMenuKey:v}}function Ol({items:e,triggerLabel:t}){let n=x.cssPrefix,o=Ml({itemCount:e.length}),a=s=>{s.disabled||(s.onSelect?.(),s.keepOpen||o.close())},i=(s,c)=>s.onSelectValue?.(c),l=(s,c)=>{let _=c.segments;if(!_?.length)return;let p=Math.max(0,_.findIndex(u=>u.value===c.value)),v=-1;if(s.key==="ArrowRight"||s.key==="Enter"||s.key===" ")v=(p+1)%_.length;else if(s.key==="ArrowLeft")v=(p-1+_.length)%_.length;else return;s.preventDefault(),s.stopPropagation(),i(c,_[v].value)};return r("div",{class:`${n}-menu-wrap`,children:[r("button",{ref:o.triggerRef,type:"button",class:`${n}-icon-btn`,"aria-label":t,"aria-haspopup":"menu","aria-expanded":o.open,title:t,onClick:o.toggle,onKeyDown:o.onTriggerKey,children:r(ol,{})}),o.open?r("div",{ref:o.menuRef,class:`${n}-menu`,role:"menu","aria-label":t,onKeyDown:o.onMenuKey,tabIndex:-1,children:e.map(s=>s.segments?r("div",{role:"menuitem",class:`${n}-menu-item ${n}-menu-item-segmented`,"aria-label":s.label,tabIndex:-1,onKeyDown:c=>l(c,s),children:[s.icon?r("span",{class:`${n}-menu-icon`,children:s.icon}):null,r("span",{class:`${n}-menu-label`,children:s.label}),r("span",{class:`${n}-segmented`,role:"group","aria-label":s.label,children:s.segments.map(c=>{let _=c.value===s.value;return r("button",{type:"button",role:"menuitemradio","aria-checked":_,class:`${n}-segment`,"data-on":_?"true":void 0,lang:c.lang,title:c.value,tabIndex:-1,"data-testid":`${S.langSegment}-${c.value}`,onClick:()=>i(s,c.value),children:c.label},c.value)})})]},s.id):r("button",{type:"button",role:"menuitem",class:`${n}-menu-item`,"aria-pressed":s.type==="switch"?s.on:void 0,disabled:s.disabled,onClick:()=>a(s),children:[s.icon?r("span",{class:`${n}-menu-icon`,children:s.icon}):null,r("span",{class:`${n}-menu-label`,children:s.label}),s.type==="switch"&&s.on?r("span",{class:`${n}-menu-check`,"aria-hidden":"true",children:r(Tt,{})}):null]},s.id))}):null]})}var ca=x.cssPrefix;function $u(e){let t=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)").matches:!0;return e==="auto"?t?"light":"dark":t?e==="light"?"dark":"auto":e==="dark"?"light":"auto"}var Fu={normal:"large",large:"small",small:"normal"};function Bu(e){return e==="light"?r(fl,{}):e==="dark"?r(gl,{}):r(hl,{})}function Hu(e){return(e.split("-")[0]??e).toUpperCase()}function tt({panelProps:e,variant:t}){let{options:n,panelSize:o,feedback:a,onClose:i,onClear:l,onExpand:s,onFullscreen:c,onSoundToggle:_}=e,{onToggleHistory:p,onLocaleChange:v,onThemeChange:u,onTextSizeChange:f}=e,m=n.strings,k=n.mode,h=t==="chat",b=Q(()=>a.mutedSig.value).value,w=new Set(n.actions),P=X=>w.has(X),E=typeof matchMedia=="function"&&matchMedia("(max-width: 640px)").matches,B=X=>E?!1:wn(X,k,o),J=n.themeMode,ie={auto:m.themeAuto,light:m.themeLight,dark:m.themeDark},ne=n.textSize,Z={small:m.textSizeSmall,normal:m.textSizeNormal,large:m.textSizeLarge},O=[];if(h&&P("clear")&&O.push({id:"clear",icon:r(dl,{}),label:m.newConversation,onSelect:l}),P("expand")&&B("expand")){let X=o==="expanded";O.push({id:"expand",icon:X?r(Zs,{}):r(Qs,{}),label:X?m.collapse:m.expand,type:"switch",on:X,onSelect:s})}if(P("fullscreen")&&B("fullscreen")){let X=o==="fullscreen";O.push({id:"fullscreen",icon:X?r(tl,{}):r(el,{}),label:X?m.exitFullscreen:m.fullscreen,type:"switch",on:X,onSelect:c})}h&&P("sound")&&O.push({id:"sound",icon:b?r(al,{}):r(rl,{}),label:b?m.soundOff:m.soundOn,type:"switch",on:!b,onSelect:_}),P("theme")&&O.push({id:"theme",icon:Bu(J),label:`${m.theme}: ${ie[J]}`,onSelect:()=>u($u(J)),keepOpen:!0}),P("textSize")&&O.push({id:"textSize",icon:r(il,{}),label:`${m.textSize}: ${Z[ne]}`,onSelect:()=>f(Fu[ne]),keepOpen:!0}),P("language")&&n.availableLocales.length>1&&O.push({id:"language",icon:r(cl,{}),label:m.language,segments:n.availableLocales.map(X=>({value:X,label:Hu(X),lang:X})),value:n.locale,onSelectValue:v});let D=!!i&&Do(k,o,n.actions),K=h&&P("history");return r("div",{class:`${ca}-header-actions`,children:[K?r("button",{type:"button",class:`${ca}-icon-btn`,onClick:p,"aria-label":m.history,title:m.history,"data-testid":S.actionHistory,children:r(ll,{})}):null,O.length>0?r(Ol,{items:O,triggerLabel:m.moreActions}):null,D?r("button",{type:"button",class:`${ca}-icon-btn`,onClick:i,"aria-label":m.close,title:m.close,"data-testid":S.actionClose,children:r(et,{})}):null]})}var zu=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Uu=/^https?:\/\/[^\s.]+\.[^\s]+$/i,qu=/^[+]?[\d\s().-]{6,}$/;function Yt(e,t){return e.replace(/\{(\w+)\}/g,(n,o)=>String(t[o]??`{${o}}`))}function Vu(e){return Array.isArray(e)?e.length:e&&e.trim()?1:0}function Wu(e,t,n){let o=e.required??!0,a=e.validation;if(e.type==="multiselect"){let l=Vu(t);return o&&l===0?n.formRequired:l===0?void 0:a?.minSelections!=null&&l<a.minSelections?Yt(n.formChooseAtLeast,{min:a.minSelections}):a?.maxSelections!=null&&l>a.maxSelections?Yt(n.formChooseAtMost,{max:a.maxSelections}):void 0}let i=typeof t=="string"?t.trim():"";if(!i)return o?n.formRequired:void 0;switch(e.type){case"email":if(!zu.test(i))return n.formInvalidEmail;break;case"url":if(!Uu.test(i))return n.formInvalidUrl;break;case"tel":if(!qu.test(i))return n.formInvalidTel;break;case"number":{let l=Number(i);if(!Number.isFinite(l))return n.formInvalidNumber;if(a?.min!=null&&l<a.min)return Yt(n.formNumberTooSmall,{min:a.min});if(a?.max!=null&&l>a.max)return Yt(n.formNumberTooLarge,{max:a.max});break}default:break}if(a?.minLength!=null&&i.length<a.minLength)return Yt(n.formTooShort,{min:a.minLength});if(a?.maxLength!=null&&i.length>a.maxLength)return Yt(n.formTooLong,{max:a.maxLength});if(a?.pattern)try{if(!new RegExp(a.pattern).test(i))return n.formPatternMismatch}catch{}}function Nl(e,t,n){let o={};for(let a of e){let i=Wu(a,t[a.name],n);i&&(o[a.name]=i)}return o}function Dl(e){let t={};for(let[n,o]of Object.entries(e)){let a=Array.isArray(o)?o.join(", "):o;a&&a.trim()&&(t[n]=a.trim())}return t}var de=x.cssPrefix,zo="__other__";function Tn({fields:e,strings:t,submitLabel:n,onSubmit:o,skipLabel:a,onSkip:i,footerHint:l,submitOnEnter:s,disabled:c,initialValues:_,hideActions:p,fieldTypeLabels:v,rootTestId:u,submitTestId:f,skipTestId:m}){let[k,h]=R(()=>({...Xu(e),..._})),[b,w]=R({}),[P,E]=R({}),B=O=>{P[O]&&E(D=>({...D,[O]:""}))},J=(O,D)=>{h(K=>({...K,[O]:D})),B(O)},ie=(O,D)=>{w(K=>({...K,[O]:D})),B(O)},ne=O=>{if(O.preventDefault(),c)return;let D=Yu(e,k,b),K=Nl(e,D,t);if(Object.keys(K).length>0){E(K);return}o(Dl(D))},Z=O=>{!s||O.key!=="Enter"||O.shiftKey||O.isComposing||O.target?.tagName==="TEXTAREA"&&ne(O)};return r("form",{class:`${de}-form`,onSubmit:ne,onKeyDown:Z,"data-testid":u,noValidate:!0,children:[e.map(O=>r(Gu,{field:O,value:k[O.name],otherText:b[O.name]??"",error:P[O.name],disabled:c,typeLabel:v?.[O.name],strings:t,onChange:D=>J(O.name,D),onOtherChange:D=>ie(O.name,D)},O.name)),p?null:r("div",{class:`${de}-form-actions`,children:[l?r("span",{class:`${de}-form-hint`,children:l}):null,a&&i?r("button",{type:"button",class:`${de}-form-skip`,onClick:i,disabled:c,"data-testid":m,children:a}):null,r("button",{type:"submit",class:`${de}-form-submit`,disabled:c,"data-testid":f,children:n})]})]})}function Gu({field:e,value:t,otherText:n,error:o,disabled:a,typeLabel:i,strings:l,onChange:s,onOtherChange:c}){let _=we(S.formField,e.name),p=Ku({field:e,value:t,otherText:n,disabled:a,strings:l,onChange:s,onOtherChange:c,fieldTid:_});return r("label",{class:`${de}-field`,"data-field":e.name,"data-invalid":o?"true":void 0,children:[r("span",{class:`${de}-field-head`,children:[r("span",{class:`${de}-field-label`,children:[e.label,e.required??!0?r("span",{class:`${de}-field-req`,"aria-hidden":"true",children:" *"}):null]}),i?r("span",{class:`${de}-field-type`,children:i}):null]}),p,e.validationHint&&!o?r("span",{class:`${de}-field-hint`,children:e.validationHint}):null,o?r("span",{class:`${de}-field-error`,role:"alert",children:o}):null]})}function Ku(e){let{field:t,value:n,otherText:o,disabled:a,strings:i,onChange:l,onOtherChange:s,fieldTid:c}=e,_=typeof n=="string"?n:"";switch(t.type){case"textarea":return r("textarea",{class:`${de}-field-input`,rows:3,value:_,placeholder:t.placeholder,disabled:a,onInput:p=>l(p.target.value),"data-testid":c});case"select":return r("select",{class:`${de}-field-input`,value:_,disabled:a,onChange:p=>l(p.target.value),"data-testid":c,children:[r("option",{value:"",children:t.placeholder??"\u2014"}),(t.options??[]).map(p=>r("option",{value:p.value,children:p.label??p.value},p.value))]});case"radio":{let p=t.allowOther&&_===zo;return r("div",{class:`${de}-field-choices`,role:"radiogroup","data-testid":c,children:[(t.options??[]).map(v=>r("label",{class:`${de}-choice`,children:[r("input",{type:"radio",name:`${de}-${t.name}`,checked:_===v.value,disabled:a,onChange:()=>l(v.value)}),r("span",{children:v.label??v.value})]},v.value)),t.allowOther?r("label",{class:`${de}-choice`,children:[r("input",{type:"radio",name:`${de}-${t.name}`,checked:_===zo,disabled:a,onChange:()=>l(zo)}),r("span",{children:i.formOther})]}):null,p?r("input",{class:`${de}-field-input`,value:o,placeholder:t.placeholder??i.formOtherPlaceholder,disabled:a,onInput:v=>s(v.target.value)}):null]})}case"checkbox":return r("label",{class:`${de}-choice`,children:[r("input",{type:"checkbox",checked:_==="true",disabled:a,onChange:p=>l(p.target.checked?"true":""),"data-testid":c}),r("span",{children:t.placeholder??t.label})]});case"multiselect":{let p=Array.isArray(n)?n:[],v=(u,f)=>l(f?[...p,u]:p.filter(m=>m!==u));return r("div",{class:`${de}-field-choices`,"data-testid":c,children:[(t.options??[]).map(u=>r("label",{class:`${de}-choice`,children:[r("input",{type:"checkbox",checked:p.includes(u.value),disabled:a,onChange:f=>v(u.value,f.target.checked)}),r("span",{children:u.label??u.value})]},u.value)),t.allowOther||(t.options??[]).length===0?r("textarea",{class:`${de}-field-input`,rows:2,value:o,placeholder:t.placeholder??i.formOtherPlaceholder,disabled:a,onInput:u=>s(u.target.value)}):null]})}default:return r("input",{class:`${de}-field-input`,type:ju(t.type),value:_,placeholder:t.placeholder,disabled:a,onInput:p=>l(p.target.value),"data-testid":c})}}function ju(e){switch(e){case"number":case"email":case"tel":case"url":case"date":case"time":return e;default:return"text"}}function Xu(e){let t={};for(let n of e)n.defaultValue!=null&&(t[n.name]=n.type==="multiselect"?n.defaultValue.split(",").map(o=>o.trim()).filter(Boolean):n.defaultValue);return t}function Yu(e,t,n){let o={...t};for(let a of e){let i=n[a.name]?.trim();if(a.type==="radio"&&a.allowOther&&t[a.name]===zo)o[a.name]=i??"";else if(a.type==="multiselect"&&i){let l=i.split(/[,\n;]+/).map(c=>c.trim()).filter(Boolean),s=Array.isArray(t[a.name])?t[a.name]:[];o[a.name]=[...s,...l]}}return o}var nt=x.cssPrefix;function da({form:e,strings:t,onSubmit:n,onSkip:o}){return r("div",{class:`${nt}-form-gate`,"data-testid":S.formGate,children:[e.title?r("h3",{class:`${nt}-form-gate-title`,children:e.title}):null,e.description?r("p",{class:`${nt}-form-gate-desc`,children:e.description}):null,r(Tn,{fields:e.fields,strings:t,submitLabel:e.submitLabel??t.formSubmit,onSubmit:n,skipLabel:e.skippable?t.formSkip:void 0,onSkip:e.skippable?o:void 0,submitTestId:S.formSubmit,skipTestId:S.formSkip})]})}function $l({marker:e,strings:t,onFill:n}){let o=e.outcome==="skipped",a=o?t.formSkipped:t.formSubmitted,i=e.title?r(ae,{children:[r("span",{children:e.title}),r("span",{class:`${nt}-sr-only`,children:a})]}):r("span",{children:a}),l=e.form?.reviewable??!1,s=!o&&l&&e.values&&Object.keys(e.values).length>0?e.values:null;if(s){let c=_=>e.form?.fields.find(p=>p.name===_)?.label??_;return r("details",{class:`${nt}-form-done`,"data-outcome":e.outcome,"data-testid":S.formDone,children:[r("summary",{class:`${nt}-form-done-summary`,"data-testid":S.formDoneToggle,children:[r(Tt,{}),i,r(jt,{})]}),r("dl",{class:`${nt}-form-answers`,"data-testid":S.formAnswers,children:Object.entries(s).map(([_,p])=>r("div",{class:`${nt}-form-answer`,children:[r("dt",{children:c(_)}),r("dd",{children:p})]},_))})]})}return r("div",{class:`${nt}-form-done`,"data-outcome":e.outcome,"data-testid":S.formDone,role:"status",children:[o?r(sl,{}):r(Tt,{}),i,o&&e.form?.reopenable&&n?r("button",{type:"button",class:`${nt}-form-done-fill`,"data-testid":S.formFill,onClick:n,children:t.formFillOut}):null]})}function Fl(e){if(!e)return!1;let t=e.startsWith("tool:")?e.slice(5):e;return t==="ask-user-questions"||t==="ask_user_questions"}var pa=1,Hl=2,zl=4,Ul=8,ql=16;function Ju(e){switch(e){case pa:return"href";case Hl:return"src";case zl:return"class";case Ul:return"checked";case ql:return"start"}}var Qu=e=>{switch(e){case 1:return 3;case 2:return 4;case 3:return 5;case 4:return 6;case 5:return 7;default:return 8}},Zu=Qu;var Bl=24;function fa(e){let t=new Uint32Array(Bl);return t[0]=1,{renderer:e,text:"",pending:"",tokens:t,len:0,token:1,fence_end:0,blockquote_idx:0,hr_char:"",hr_chars:0,fence_start:0,spaces:new Uint8Array(Bl),indent:"",indent_len:0,table_state:0}}function Vl(e){e.pending.length>0&&Ie(e,`
11
+ ${a}`:a;continue}o.startsWith("id:")&&(n=o.slice(3).trim())}if(t==="[DONE]")return"done";if(!t)return null;try{let o=JSON.parse(t);return Ss.trace("chunk",{type:o.type,eventId:n}),{chunk:o,eventId:n}}catch(o){return Ss.trace("frame parse failed",{err:o,payload:t.slice(0,200)}),null}}function F_(e){let t=new TextEncoder().encode(e),n="";for(let o of t)n+=String.fromCharCode(o);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var ks=e=>e&&Object.keys(e).length>0?e:void 0;function ws(e,t){let n=ks(e),o=ks(t);if(!n&&!o)return;let a={};return n&&(a.user=n),o&&(a.page=o),F_(JSON.stringify(a))}function yo(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function B_(e){return`tool-${e.startsWith("tool:")?e.slice(5):e}`}function Cs(e){return e.startsWith("tool-")?e.slice(5):e}var ze={handshake:"/pai/handshake",streamMessage:"/pai/stream-message",streamResume:"/pai/stream-resume",cancelStream:"/pai/cancel-stream",listConversations:"/pai/list-conversations",listMessages:"/pai/list-messages",updateSettings:"/pai/update-settings",markRead:"/pai/mark-read",messageFeedback:"/pai/message-feedback",requestOperator:"/pai/request-operator",bootstrap:"/pai/bootstrap",content:"/pai/content",submitForm:"/pai/submit-form"},Ts="context";function mt(e){let t=e??{},n=t.controlMode;return{controlMode:n==="awaiting_operator"||n==="operator"?n:"ai-agent",assignedOperatorInitials:typeof t.assignedOperatorInitials=="string"&&t.assignedOperatorInitials?t.assignedOperatorInitials:void 0,operatorAvailable:typeof t.operatorAvailable=="boolean"?t.operatorAvailable:void 0}}function xo(e){let t=e?.suggestions;if(!Array.isArray(t))return[];let n=[];for(let o of t){if(!o||typeof o!="object")continue;let{id:a,label:i,text:l}=o;typeof i!="string"||!i||n.push({id:typeof a=="string"&&a?a:`s${n.length}`,label:i,text:typeof l=="string"&&l?l:i})}return n}function Es(e){let t=e.messages.map(i=>({id:i.serverMessageId??i.id,parts:U_(i),role:i.role,createdAt:i.createdAt!==void 0?new Date(i.createdAt).toISOString():void 0})),n={messages:t,conversationId:e.conversationId,trigger:e.trigger??"submit-message"},o=t.at(-1)?.id;o&&(n.messageId=o),e.visitorId&&(n.visitorId=e.visitorId),e.userPrefs&&(n.userPrefs=e.userPrefs);let a=e.tools?.map(z_).filter(i=>i!==null);return a?.length&&(n.data={tools:a}),n}function H_(e){return e.state==="output-available"||e.state==="output-error"||e.state==="output-denied"||e.approval?.approved!==void 0}function z_(e){return typeof e=="string"?e?{code:e}:null:e?.code?e:null}function U_(e){let t=[];for(let n of e.parts)if(n.kind==="step-start"&&t.push({type:"step-start"}),n.kind==="reasoning"&&n.text&&t.push({type:"reasoning",text:n.text,state:n.done?"done":"streaming"}),n.kind==="text"&&n.text&&t.push({text:n.text,type:"text"}),n.kind==="file"&&n.url&&t.push({mediaType:n.mediaType,type:"file",url:n.url}),n.kind==="tool"&&H_(n)){let o={type:B_(n.toolName),toolCallId:n.toolCallId,state:n.state};n.input!==void 0&&(o.input=n.input),n.output!==void 0&&(o.output=n.output),n.error!==void 0&&(o.errorText=n.error),n.approval&&n.approval.approved!==void 0&&(o.approval=n.approval),t.push(o)}for(let n of e.attachments??[])n.url&&t.push({type:"file",url:n.url,mediaType:n.mediaType,filename:n.name,fileId:n.id,fileSize:n.size});return t}var Y=ee.scope("transport"),Rs=3,Ls=400,q_=250,V_=5e3,W_=6e4,G_=1e4,As=3,K_=new Set([408,425,429,500,502,503,504]);function Is(e){return Ls*2**e+Math.floor(Math.random()*250)}function j_(e){let t=e.get("retry-after");if(!t)return null;let n=Number(t),o=Number.isFinite(n)?n*1e3:Date.parse(t)-Date.now();return Number.isFinite(o)&&o>=0?Math.min(o,3e4):null}function So(e,t){return new Promise(n=>{if(t?.aborted)return n();let o=setTimeout(i,e),a=()=>i();t?.addEventListener("abort",a,{once:!0});function i(){clearTimeout(o),t?.removeEventListener("abort",a),n()}})}var ko=class{constructor(t){j(this,"ttlMs",t);j(this,"map",new Map)}getOrFetch(t,n){let o=this.map.get(t);if(o&&Date.now()-o.at<this.ttlMs)return o.result;let a={at:Date.now(),result:n().then(i=>(a.value=i,i)).catch(i=>{throw this.map.delete(t),i})};return this.map.set(t,a),a.result}peek(t){let n=this.map.get(t);if(n?.value!==void 0&&Date.now()-n.at<this.ttlMs)return n.value}clear(){this.map.clear()}},wo=class{constructor(t){j(this,"opts",t);j(this,"visitorId");j(this,"conversationId");j(this,"resumeStatus");j(this,"userContext");j(this,"pageContext");j(this,"locale");j(this,"conversationsCache",new ko(G_));j(this,"contentCache",new ko(W_))}setContext(t,n){this.userContext=t,this.pageContext=n}setLocale(t){this.locale=t}primeIdentity(t,n){t&&(this.visitorId=t),n&&(this.conversationId=n)}envelope(){let t={_ev:bo};this.visitorId&&(t.visitorId=this.visitorId),this.conversationId&&(t.conversationId=this.conversationId),this.locale&&(t.locale=this.locale);let n=ws(this.userContext,this.pageContext);return n&&(t[Ts]=n),t}withEnvelope(t){return{...this.envelope(),...t}}appendEnvelope(t){for(let[n,o]of Object.entries(this.envelope()))t.append(n,o);return t}withEnvelopeQuery(t){let n=new URL(this.url(t));for(let[o,a]of Object.entries(this.envelope()))n.searchParams.has(o)||n.searchParams.set(o,a);return n.toString()}async handshake(t){Y.debug("handshake \u2192",{visitorId:t.visitorId,conversationId:t.conversationId,locale:t.locale});let n=await this.postJson(ze.handshake,t,"handshake");return Y.debug("handshake \u2190",{visitorId:n.visitorId,conversationId:n.conversationId,hasWelcome:!!n.welcome,hasConfig:!!n.config,rebind:n.rebind}),Y_(n)||Y.warn("handshake response did not match expected shape; using raw response",{response:n}),this.visitorId=n.visitorId??t.visitorId,this.conversationId=n.conversationId,n}async uploadFile(t){Y.debug("uploadFile \u2192",{name:t.name,size:t.size,type:t.type});let n=new FormData;n.append("file",t,t.name);let o=await this.postForm(this.uploadPath,n,"upload");return Y.debug("uploadFile \u2190",{id:o.id,url:o.url}),o}async transcribe(t,n="audio/webm"){Y.debug("transcribe \u2192",{size:t.size,mimeType:n});let o=new FormData;o.append("audio",t,`voice.${X_(n)}`),o.append("mimeType",n);let a=await this.postForm(this.transcribePath,o,"transcribe");return Y.debug("transcribe \u2190",{textLen:a.text.length}),a}localeCacheKey(t){return`${this.locale??""}|${JSON.stringify(t,Object.keys(t).toSorted())}`}peekConversations(t={}){return this.conversationsCache.peek(this.localeCacheKey(t))}listConversations(t={}){return this.conversationsCache.getOrFetch(this.localeCacheKey(t),()=>this.fetchConversations(t))}async fetchConversations(t){let n=new URL(this.url(ze.listConversations));t.visitorId&&n.searchParams.set("visitorId",t.visitorId),t.limit&&n.searchParams.set("limit",String(t.limit)),t.cursor&&n.searchParams.set("cursor",t.cursor),Y.debug("listConversations \u2192",{visitorId:t.visitorId??this.visitorId,limit:t.limit,cursor:t.cursor});let o=await this.getJson(n.toString(),"listConversations"),a=o.conversations??[];return Y.debug("listConversations \u2190",{count:a.length,nextCursor:o.nextCursor}),{conversations:a,nextCursor:o.nextCursor}}async loadConversation(t){let n=new URL(this.url(ze.listMessages));n.searchParams.set("conversationId",t),Y.debug("loadConversation \u2192",{conversationId:t,visitorId:this.visitorId});let o=await this.getJson(n.toString(),"loadConversation"),a=o.messages??[];return Y.debug("loadConversation \u2190",{conversationId:o.conversationId,canContinue:o.canContinue,messageCount:a.length,hasSuggestions:!!o.suggestions}),{...o,messages:a,canContinue:o.canContinue??!0}}async markRead(t){if(!(!this.visitorId||!t)){this.conversationsCache.clear(),Y.debug("markRead \u2192",{conversationId:t,visitorId:this.visitorId});try{await this.postJson(ze.markRead,{conversationId:t},"markRead")}catch(n){Y.debug("markRead failed (non-fatal)",{err:n})}}}async requestOperator(){if(!(!this.visitorId||!this.conversationId)){Y.debug("requestOperator \u2192",{conversationId:this.conversationId,visitorId:this.visitorId});try{return(await this.postJson(ze.requestOperator,{},"requestOperator")).controlState}catch(t){Y.debug("requestOperator failed (non-fatal)",{err:t});return}}}listContent(t={}){return this.contentCache.getOrFetch(this.localeCacheKey(t),()=>this.fetchContent(t))}async fetchContent(t){let n=new URL(this.dataUrl(ze.content));for(let[i,l]of Object.entries(t))l!==void 0&&n.searchParams.set(i,Array.isArray(l)?l.join(","):String(l));Y.debug("listContent \u2192",t);let o=await this.getJson(n.toString(),"listContent"),a=(o.items??[]).map(i=>gi(i,this.locale));return Y.debug("listContent \u2190",{count:a.length,total:o.pagination?.total}),{...o,items:a}}async bootstrap(t){let n=new URL(this.dataUrl(ze.bootstrap));t&&n.searchParams.set("conversationId",t),Y.debug("bootstrap \u2192",{conversationId:t??this.conversationId});let o=await this.getJson(n.toString(),"bootstrap"),a=o.forms??[],i=o.formSubmissions??[];return Y.debug("bootstrap \u2190",{forms:a.length,formSubmissions:i.length}),{forms:a,formSubmissions:i}}async saveUserPrefs(t){Y.debug("saveUserPrefs \u2192",{visitorId:this.visitorId,conversationId:this.conversationId,settingsKeys:Object.keys(t)});let n=await this.postJson(ze.updateSettings,{userPrefs:t},"saveUserPrefs");return Y.debug("saveUserPrefs \u2190",{success:n.success}),n}get uploadPath(){return this.opts.endpoints?.upload??"/pai/upload-file"}get transcribePath(){return this.opts.endpoints?.transcribe??"/pai/transcribe-audio"}get submitFormPath(){return this.opts.endpoints?.submitForm??ze.submitForm}async submitForm(t){Y.debug("submitForm \u2192",{formId:t.formId,trigger:t.trigger,fields:Object.keys(t.values).length});try{await this.postJson(this.dataUrl(this.submitFormPath),t,"submitForm")}catch(n){Y.debug("submitForm failed (non-fatal)",{err:n})}}async submitFeedback(t){Y.debug("submitFeedback \u2192",{messageId:t.messageId,value:t.value});try{await this.postJson(ze.messageFeedback,{messageId:t.messageId,set:{feedback:t.value}},"submitFeedback")}catch(n){Y.debug("submitFeedback failed (non-fatal)",{err:n})}}sendMessage(t){this.conversationsCache.clear(),Y.debug("message \u2192",{conversationId:t.conversationId,visitorId:t.visitorId,messageId:t.messageId,messageCount:t.messages.length,trigger:t.trigger,tools:t.data?.tools?.map(l=>l.code)});let n=new AbortController,o=new Set;return{iter:this.runStream(t,n,o),cancel:()=>this.cancelStream(n,t.conversationId),detach:()=>n.abort()}}resumeStream(){let t=new AbortController,n=new Set;this.resumeStatus=void 0;let o=this.resumeStreamGen(t,n,!0),a=()=>t.abort();return{iter:o,cancel:a,detach:a}}resumeChannel(){let t=new AbortController;return{iter:this.resumeChannelGen(t),stop:()=>t.abort()}}async*resumeChannelGen(t){for(let n=1;!t.signal.aborted;n++){if(n>1&&(await So(Math.min(q_*(n-1),V_),t.signal),t.signal.aborted))return;let o;try{o=await this.fetchImpl(this.resumeUrl(),{method:"GET",credentials:"omit",headers:{accept:"text/event-stream",...this.opts.auth.headers()},signal:t.signal})}catch(a){if(t.signal.aborted)return;Y.debug("resume-channel fetch failed \u2014 reconnecting",{attempt:n,err:a});continue}if(!o.ok||!o.body){Y.debug("resume-channel \u2192 endpoint unavailable",{status:o.status});return}if(!(o.headers.get("content-type")??"").includes("text/event-stream")){let a=await o.json().then(i=>i.status).catch(()=>{});if(a==="pending"){Y.debug("resume-channel \u2192 pending (still registering); reconnecting",{attempt:n});continue}Y.debug("resume-channel \u2192 no live operator-control stream (status); stopping",{status:a});return}try{for await(let a of Po(o,t.signal)){if(t.signal.aborted)return;n=1,yield a}}catch(a){if(t.signal.aborted)return;Y.debug("resume-channel segment dropped \u2014 reconnecting",{err:a})}}}async*runStream(t,n,o){(yield*this.drain(this.openMessageStream(t,n.signal),o,n))||(yield*this.resumeStreamGen(n,o,!1))}async*resumeStreamGen(t,n,o){for(let a=1;a<=Rs&&!t.signal.aborted;a++){if((!o||a>1)&&(await So(Ls*a,t.signal),t.signal.aborted))return;let i;try{i=await this.fetchImpl(this.resumeUrl(n.size),{method:"GET",credentials:"omit",headers:{accept:"text/event-stream",...this.opts.auth.headers()},signal:t.signal})}catch(c){if(t.signal.aborted)return;Y.debug("resume fetch failed \u2014 retrying",{attempt:a,err:c});continue}if(i.status===204||!i.ok){Y.debug("resume \u2192 no in-flight stream",{status:i.status});return}if(!(i.headers.get("content-type")??"").includes("text/event-stream")){let c=await i.json().then(_=>_.status).catch(()=>{});if(Y.debug("resume \u2192 no live stream (status response)",{status:c,attempt:a}),c==="pending"&&a<Rs)continue;this.resumeStatus=c==="needs-generation"?"needs-generation":"completed";return}this.resumeStatus="live";let s=n.size;if(yield*this.drain(Po(i,t.signal),n,t))return;if(n.size===s){Y.debug("resume \u2192 stream closed with no new events; nothing to resume");return}}if(!t.signal.aborted)throw new Ke("stream incomplete after resume attempts","server")}async*drain(t,n,o){let a=!1;try{for await(let i of t){if(o.signal.aborted)return!0;if(i.eventId){if(n.has(i.eventId))continue;n.add(i.eventId)}yield i,(i.chunk.type==="finish"||i.chunk.type==="error")&&(a=!0)}}catch(i){if(o.signal.aborted)return!0;if(i instanceof Ke&&i.status!==void 0)throw i;Y.debug("stream segment dropped",{err:i})}return a}cancelStream(t,n){t.signal.aborted||(Y.debug("cancel stream",{conversationId:n,visitorId:this.visitorId}),t.abort(),!(!this.visitorId||!n)&&this.fetchImpl(this.url(ze.cancelStream),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope({})),keepalive:!0}).catch(o=>Y.debug("cancel POST failed (non-fatal)",{err:o})))}async*openMessageStream(t,n){let o=await this.fetchImpl(this.url(ze.streamMessage),{method:"POST",credentials:"omit",headers:{accept:"text/event-stream","content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(t)),signal:n});yield*Po(o,n)}resumeUrl(t){let n=new URL(this.withEnvelopeQuery(ze.streamResume));return t!==void 0&&n.searchParams.set("resumeAt",String(t)),n.toString()}async postJson(t,n,o){let a=await this.fetchWithRetry(()=>[this.url(t),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(n))}],o);return this.assertOk(a,o)}async postForm(t,n,o){let a=await this.fetchImpl(this.url(t),{method:"POST",credentials:"omit",headers:this.opts.auth.headers(),body:this.appendEnvelope(n)});return this.assertOk(a,o)}async getJson(t,n){let o=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(t),{method:"GET",credentials:"omit",headers:{accept:"application/json",...this.opts.auth.headers()}}],n);return this.assertOk(o,n)}async fetchWithRetry(t,n){for(let o=0;;o++){let[a,i]=t(),l;try{l=await this.fetchImpl(a,i)}catch(c){if(o>=As)throw new Ke(`${n} failed: network error`,"network",void 0,c);Y.debug("request network error \u2014 retrying",{label:n,attempt:o}),await So(Is(o));continue}if(l.ok||!K_.has(l.status)||o>=As)return l;let s=j_(l.headers)??Is(o);Y.debug("request retryable status \u2014 retrying",{label:n,status:l.status,attempt:o,wait:s}),await So(s)}}async assertOk(t,n){if(!t.ok)throw new Ke(`${n} failed: ${t.status}`,"server",t.status);return await t.json()}url(t){return/^https?:\/\//i.test(t)?t:`${this.opts.agentApiBaseUrl}${t}`}dataUrl(t){return/^https?:\/\//i.test(t)?t:`${this.opts.dataApiBaseUrl}${t}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function X_(e){return e.includes("webm")?"webm":e.includes("ogg")?"ogg":e.includes("mp4")||e.includes("m4a")?"m4a":e.includes("mpeg")?"mp3":e.includes("wav")?"wav":"bin"}function Y_(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.visitorId=="string"&&typeof t.conversationId=="string"}function Ms(e,t){let n=e?[{kind:"text",id:"t0",textSig:H(e),doneSig:H(!0)}]:[];return{id:Ge(),role:"user",createdAt:Date.now(),status:"complete",attachments:t,partsSig:H(n)}}function bn(){return{id:Ge(),role:"assistant",createdAt:Date.now(),status:"streaming",partsSig:H([])}}function Os(e){let t=Ge();return J_({id:t,role:e.role,createdAt:Date.now(),status:"complete",ephemeral:!0,parts:[{kind:"text",id:`${t}-t0`,text:e.text,done:!0}]})}function J_(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,canceled:e.canceled,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,ephemeral:e.ephemeral,attachments:e.attachments,feedback:e.feedback,partsSig:H(e.parts.map(tu))}}function Qr(e){let t=e.parts.map((o,a)=>o.type==="text"?{kind:"text",id:`${e.id}-t${a}`,textSig:H(o.text),doneSig:H(!0)}:o.type==="reasoning"?{kind:"reasoning",id:`${e.id}-r${a}`,textSig:H(o.text),doneSig:H(o.state!=="streaming")}:o.type==="step-start"?{kind:"step-start",id:`${e.id}-ss${a}`}:o.type==="file"?{kind:"file",url:o.url,mediaType:o.mediaType}:o.type==="source-url"?{kind:"source",sourceId:o.sourceId,url:o.url,title:o.title}:o.type==="source-document"?{kind:"source",sourceId:o.sourceId,title:o.title,filename:o.filename,mediaType:o.mediaType}:o.type==="data-suggestions"?null:o.type.startsWith("tool-")?{kind:"tool",toolCallId:o.toolCallId,toolName:Cs(o.type),inputPartialSig:H(""),inputSig:H(o.input),outputSig:H(o.output),errorSig:H(o.errorText),stateSig:H(o.state),approvalSig:H(o.approval)}:null).filter(o=>o!==null),n=e.parts.find(o=>o.type==="data-suggestions");return{id:e.id,role:e.role,operatorInitials:e.operatorInitials,suggestions:n?.type==="data-suggestions"?xo(n.data):void 0,serverMessageId:e.id,createdAt:yo(e.createdAt)??Date.now(),status:e.status==="failed"?"error":"complete",canceled:e.status==="canceled",feedback:e.feedback??null,partsSig:H(t)}}function Ns(e,t){let n=e.findIndex(o=>o.id===t.id);return n>=0?{list:e.map((o,a)=>a===n?t:o),appended:!1}:{list:[...e,t],appended:!0}}var Q_=new Set(["completed","failed","canceled"]);function Z_(e){return!e.parts.some(t=>t.type==="text"&&t.text.trim()!==""||t.type.startsWith("tool-")||t.type==="file"||t.type==="source-url"||t.type==="source-document")}function eu(e){return e.role==="assistant"&&e.status!=null&&!Q_.has(e.status)&&Z_(e)}function Zr(e){return e.filter(t=>!eu(t)).map(Qr)}function Ds(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,canceled:e.canceled,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,ephemeral:e.ephemeral,attachments:e.attachments,parts:e.partsSig.value.map(nu)}}function kt(e){let t="";for(let n of e.partsSig.value)n.kind==="text"&&(t+=n.textSig.value);return t}function Co(e){return kt(e).trim()!==""?!1:!e.partsSig.value.some(t=>t.kind==="tool"||t.kind==="file"||t.kind==="source")}function lt(e){return e.role==="assistant"&&e.status!=="streaming"&&Co(e)}function $s(e){return e.canceled===!0&&lt(e)}function ea(e,t){return e.pausedTurn?lt(e)?"drop":"complete-paused":t||lt(e)?"error":"complete"}function tu(e){return e.kind==="text"||e.kind==="reasoning"?{kind:e.kind,id:e.id,textSig:H(e.text),doneSig:H(e.done)}:e.kind==="tool"?{kind:"tool",toolCallId:e.toolCallId,toolName:e.toolName,inputPartialSig:H(e.inputPartial),inputSig:H(e.input),outputSig:H(e.output),errorSig:H(e.error),stateSig:H(e.state),approvalSig:H(e.approval)}:e}function nu(e){return e.kind==="text"||e.kind==="reasoning"?{kind:e.kind,id:e.id,text:e.textSig.value,done:e.doneSig.value}:e.kind==="tool"?{kind:"tool",toolCallId:e.toolCallId,toolName:e.toolName,inputPartial:e.inputPartialSig.value,input:e.inputSig.value,output:e.outputSig.value,error:e.errorSig.value,state:e.stateSig.value,approval:e.approvalSig.value}:e}var Fs=ee.scope("reducer"),To=class{constructor(t){j(this,"messagesSig",t);j(this,"active",null);j(this,"openTextParts",new Map);j(this,"partSeq",0)}attach(t){this.active=t,this.openTextParts.clear()}detach(){this.active=null,this.openTextParts.clear()}ensureTextPart(t,n,o){let a=`${n}:${o}`,i=this.openTextParts.get(a);if(i)return i;let l={kind:n,id:`${o}#${this.partSeq++}`,textSig:H(""),doneSig:H(!1)};return this.openTextParts.set(a,l),Pn(t,l),l}apply(t){let n=this.active;if(n)switch(t.type){case"start":t.messageId&&(n.serverMessageId=t.messageId);return;case"finish-step":this.openTextParts.clear();return;case"start-step":Pn(n,{kind:"step-start",id:`ss-${this.partSeq++}`});return;case"finish":Fs.debug("finish",{reason:t.finishReason,canContinue:t.canContinue}),n.status="complete",t.finishReason&&(n.finishReason=t.finishReason),this.bumpDone(n);return;case"error":Fs.warn("stream error chunk",{errorText:t.errorText}),n.status="error",n.errorText=t.errorText,this.bumpDone(n);return;case"text-start":this.ensureTextPart(n,"text",t.id);return;case"text-delta":{let o=this.ensureTextPart(n,"text",t.id);o.textSig.value+=t.delta;return}case"text-end":this.ensureTextPart(n,"text",t.id).doneSig.value=!0;return;case"reasoning-start":this.ensureTextPart(n,"reasoning",t.id).doneSig.value=!1;return;case"reasoning-delta":{let o=this.ensureTextPart(n,"reasoning",t.id);o.textSig.value+=t.delta;return}case"reasoning-end":this.ensureTextPart(n,"reasoning",t.id).doneSig.value=!0;return;case"tool-input-start":case"tool-input-delta":case"tool-input-available":case"tool-output-available":case"tool-output-error":case"tool-output-denied":case"tool-approval-request":ou(n,t);return;case"file":Pn(n,{kind:"file",url:t.url,mediaType:t.mediaType});return;case"source-url":Bs(n,{kind:"source",sourceId:t.sourceId,url:t.url,title:t.title});return;case"source-document":Bs(n,{kind:"source",sourceId:t.sourceId,title:t.title,filename:t.filename,mediaType:t.mediaType});return;case"data-notification":return;case"data-conversation-rebind":return;case"data-suggestions":n.suggestions=xo(t.data);return;case"data-control-state":n.pausedTurn=!0;return;case"data-message":return;default:{let o=t}}}bumpDone(t){t.partsSig.value=[...t.partsSig.value],this.messagesSig.value=[...this.messagesSig.value]}};function wt(e,t,n){let o=e.partsSig.value.find(i=>i.kind==="tool"&&i.toolCallId===t);if(o)return o;let a={kind:"tool",toolCallId:t,toolName:n??"tool",inputPartialSig:H(""),inputSig:H(void 0),outputSig:H(void 0),errorSig:H(void 0),stateSig:H("input-streaming"),approvalSig:H(void 0)};return Pn(e,a),a}function Pn(e,t){e.partsSig.value=[...e.partsSig.value,t]}function Bs(e,t){e.partsSig.value.some(n=>n.kind==="source"&&n.sourceId===t.sourceId)||Pn(e,t)}function ou(e,t){switch(t.type){case"tool-input-start":wt(e,t.toolCallId,t.toolName);return;case"tool-input-delta":{let n=wt(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case"tool-input-available":{let n=wt(e,t.toolCallId,t.toolName);n.inputSig.value=t.input,n.stateSig.value="input-available";return}case"tool-approval-request":{let n=wt(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value="approval-requested";return}case"tool-output-available":{let n=wt(e,t.toolCallId);n.outputSig.value=t.output,n.stateSig.value="output-available";return}case"tool-output-error":{let n=wt(e,t.toolCallId);n.errorSig.value=t.errorText,n.stateSig.value="output-error";return}case"tool-output-denied":{let n=wt(e,t.toolCallId);n.stateSig.value="output-denied";return}default:return}}var Hs=ee.scope("feedback:audio"),Eo=class{constructor(){j(this,"ctx",null);j(this,"master",null);j(this,"buffers",new Map)}unlock(){if(this.ctx){this.ctx.state==="suspended"&&this.ctx.resume();return}let t=globalThis.AudioContext??globalThis.webkitAudioContext;if(t)try{this.ctx=new t,this.master=this.ctx.createGain(),this.master.gain.value=1,this.master.connect(this.ctx.destination)}catch(n){Hs.warn("AudioContext init failed",{err:n})}}setVolume(t){if(!this.master||!this.ctx)return;let n=Math.max(0,Math.min(1,t));this.master.gain.setTargetAtTime(n,this.ctx.currentTime,.01)}playTone(t){let n=this.ctx,o=this.master;if(!n||!o||n.state!=="running")return;let a=n.currentTime,i=t.noteMs/1e3;t.notes.forEach((l,s)=>{let c=n.createOscillator();c.type=t.type,c.frequency.value=l;let _=n.createGain(),p=a+s*i;_.gain.setValueAtTime(1e-4,p),_.gain.exponentialRampToValueAtTime(t.peakGain,p+.005),_.gain.exponentialRampToValueAtTime(1e-4,p+i),c.connect(_).connect(o),c.start(p),c.stop(p+i+.01)})}async playUrl(t){let n=this.ctx,o=this.master;if(!n||!o||n.state!=="running")return;let a=await this.getBuffer(t);if(!a)return;let i=n.createBufferSource();i.buffer=a,i.connect(o),i.start()}destroy(){this.ctx&&this.ctx.close().catch(()=>{}),this.ctx=null,this.master=null,this.buffers.clear()}async getBuffer(t){if(!this.ctx)return null;let n=this.buffers.get(t);if(n)return n instanceof Promise,n;let o=this.ctx,a=fetch(t).then(i=>i.ok?i.arrayBuffer():Promise.reject(new Error(`fetch ${i.status}`))).then(i=>o.decodeAudioData(i)).then(i=>(this.buffers.set(t,i),i)).catch(i=>(Hs.warn("audio fetch/decode failed",{url:t,err:i}),this.buffers.delete(t),null));return this.buffers.set(t,a),a}};var zs={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},Us={messageReceived:{notes:[880,1318.51],noteMs:90,type:"sine",peakGain:.45},messageSent:{notes:[1568],noteMs:60,type:"sine",peakGain:.25},error:{notes:[523.25,392],noteMs:120,type:"triangle",peakGain:.55},voiceStart:{notes:[1318.51],noteMs:50,type:"sine",peakGain:.3},voiceStop:{notes:[880],noteMs:50,type:"sine",peakGain:.3}};var ft=null,Ro=0;function ru(){return typeof navigator<"u"&&typeof navigator.vibrate=="function"}function au(){if(typeof document>"u")return null;let e=document.createElement("input");e.type="checkbox",e.setAttribute("switch",""),e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e.id=`__${x.cssPrefix}_haptic_${Math.random().toString(36).slice(2)}`;let t=document.createElement("label");t.htmlFor=e.id,t.setAttribute("aria-hidden","true");let n="position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;opacity:0!important;pointer-events:none!important;";return e.style.cssText=n,t.style.cssText=n,document.body.append(e,t),{input:e,label:t}}function qs(e){if(!(e===0||Array.isArray(e)&&e.every(t=>t===0))){if(ru())try{navigator.vibrate(e);return}catch{}if(ft||(ft=au()),!!ft)try{ft.label.click()}catch{}}}function Vs(){Ro++;let e=!1;return()=>{e||(e=!0,Ro=Math.max(0,Ro-1),Ro===0&&ft&&(ft.input.remove(),ft.label.remove(),ft=null))}}var iu=ee.scope("feedback"),su=100,Ao=class{constructor(t,n){j(this,"mutedSig",H(!1));j(this,"audio",new Eo);j(this,"releaseHaptics");j(this,"sound");j(this,"haptics");j(this,"lastPlayed",new Map);j(this,"reducedMotionMq",null);this.sound=t,this.haptics=n,this.releaseHaptics=Vs(),this.audio.setVolume(this.effectiveVolume()),typeof matchMedia<"u"&&(this.reducedMotionMq=matchMedia("(prefers-reduced-motion: reduce)"))}unlock(){this.audio.unlock(),this.audio.setVolume(this.effectiveVolume())}update(t,n){this.sound=t,this.haptics=n,this.audio.setVolume(this.effectiveVolume())}setMuted(t){this.mutedSig.value!==t&&(this.mutedSig.value=t)}toggleMuted(){this.mutedSig.value=!this.mutedSig.value}play(t){this.mutedSig.value||this.isDeduped(t)||(this.lastPlayed.set(t,performance.now()),this.sound.enabled&&this.playSound(t),this.haptics.enabled&&this.isTouchDevice()&&this.playHaptic(t))}destroy(){this.audio.destroy(),this.releaseHaptics()}isDeduped(t){let n=this.lastPlayed.get(t);return n===void 0?!1:performance.now()-n<su}playSound(t){let n=this.sound.events?.[t];if(n===!1)return;if(typeof n=="string"){this.audio.playUrl(n).catch(a=>iu.warn("audio play failed",{err:a,url:n}));return}let o=Us[t];o&&this.audio.playTone(o)}playHaptic(t){if(this.reducedMotionMq?.matches)return;let n=this.haptics.events?.[t];if(n===!1)return;let o=n===!0||n===void 0?zs[t]:n;qs(o)}effectiveVolume(){let t=this.sound.volume??.3;return this.reducedMotionMq?.matches?t*.5:t}isTouchDevice(){return typeof window>"u"?!1:matchMedia("(hover: none) and (pointer: coarse)").matches}};function Ct(e,t){return e instanceof Ke&&e.status===429?t.errorRateLimited:t.errorGeneric}var lu=0;function r(e,t,n,o,a,i){t||(t={});var l,s,c=t;if("ref"in c)for(s in c={},t)s=="ref"?l=t[s]:c[s]=t[s];var _={type:e,props:c,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--lu,__i:-1,__u:0,__source:a,__self:i};if(typeof e=="function"&&(l=e.defaultProps))for(s in l)c[s]===void 0&&(c[s]=l[s]);return te.vnode&&te.vnode(_),_}var F={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24"},yn=`${x.cssPrefix}-icon-dir`,ta=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z"})}),et=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M18 6 6 18M6 6l12 12"})}),Ws=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M12 5v14M5 12h14"})}),Gs=()=>r("svg",{...F,class:yn,"aria-hidden":"true",children:[r("path",{d:"m22 2-7 20-4-9-9-4Z"}),r("path",{d:"M22 2 11 13"})]}),Ks=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M12 19V5M5 12l7-7 7 7"})}),js=()=>r("svg",{...F,class:yn,"aria-hidden":"true",children:r("path",{d:"M3 20V4l18 8-18 8Z"})}),jt=()=>r("svg",{...F,class:yn,"aria-hidden":"true",children:r("path",{d:"m9 18 6-6-6-6"})}),Xs=()=>r("svg",{...F,"aria-hidden":"true",children:r("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}),Ys=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"m21 11-9 9a5.5 5.5 0 0 1-7.78-7.78l8.49-8.49a3.67 3.67 0 0 1 5.19 5.19l-8.49 8.49a1.83 1.83 0 0 1-2.6-2.6l7.78-7.78"})}),Js=()=>r("svg",{...F,"aria-hidden":"true",children:[r("rect",{x:"9",y:"2",width:"6",height:"12",rx:"3"}),r("path",{d:"M5 10a7 7 0 0 0 14 0M12 19v3"})]}),Qs=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5"})}),Zs=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5"})}),el=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z"})}),tl=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7"})}),nl=()=>r("svg",{...F,"aria-hidden":"true",viewBox:"0 0 10 10",children:r("path",{d:"M9 1L1 9M9 5L5 9M9 9H9",strokeWidth:"1.5"})}),ol=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),r("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),r("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]}),rl=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10"})}),al=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6"})}),il=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M3 18 8 6l5 12M4.7 14h6.6"}),r("path",{d:"M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2"})]}),sl=()=>r("svg",{...F,class:yn,"aria-hidden":"true",children:r("path",{d:"m5 6 6 6-6 6M13 6l6 6-6 6"})}),Tt=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M20 6 9 17l-5-5"})}),ll=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M3 3v6h6"}),r("path",{d:"M3.05 13A9 9 0 1 0 6 5.3L3 9"}),r("path",{d:"M12 7v5l3 2"})]}),cl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("path",{d:"M2 12h20"}),r("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),xn=()=>r("svg",{...F,class:yn,"aria-hidden":"true",children:r("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),dl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M12 20h9"}),r("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),Et=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"m6 9 6 6 6-6"})}),_l=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"}),r("path",{d:"M14 2v6h6"})]}),cu=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z"}),r("path",{d:"M19 15v4M17 17h4M5 3v2M4 4h2"})]}),na=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z"})}),Sn=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),r("path",{d:"M12 17h.01"})]}),du=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"m15 4 3 3-9 9-3-3z"}),r("path",{d:"M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2"})]}),_u=()=>r("svg",{...F,"aria-hidden":"true",children:[r("rect",{x:"4",y:"8",width:"16",height:"12",rx:"2"}),r("path",{d:"M12 8V4"}),r("circle",{cx:"12",cy:"3",r:"1"}),r("path",{d:"M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5"})]}),oa=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M4 14v-2a8 8 0 0 1 16 0v2"}),r("rect",{x:"2",y:"14",width:"4",height:"6",rx:"1.5"}),r("rect",{x:"18",y:"14",width:"4",height:"6",rx:"1.5"}),r("path",{d:"M20 20v1a3 3 0 0 1-3 3h-5"})]}),uu=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("circle",{cx:"12",cy:"12",r:"4"}),r("path",{d:"m4.93 4.93 4.24 4.24M14.83 14.83l4.24 4.24M14.83 9.17l4.24-4.24M4.93 19.07l4.24-4.24"})]}),ra=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"11",cy:"11",r:"7"}),r("path",{d:"m21 21-4.3-4.3"})]}),ul=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"m8.5 12 2.5 2.5 4.5-5"})]}),pl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M3 9.5 12 3l9 6.5"}),r("path",{d:"M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9"})]}),ml=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"m3 11 15-5v12L3 13z"}),r("path",{d:"M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z"}),r("path",{d:"M7 15v3a2 2 0 0 0 4 0v-2"}),r("path",{d:"M21 10a3 3 0 0 1 0 4"})]}),kn=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z"}),r("path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1"})]}),fl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"4"}),r("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}),gl=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),hl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"M12 3v18"}),r("path",{d:"M12 3a9 9 0 0 1 0 18z",fill:"currentColor",stroke:"none"})]}),pu=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"10.5",cy:"10.5",r:"6.5"}),r("path",{d:"M8 11a2.5 2.5 0 0 0 5 0"}),r("path",{d:"m20 20-4.4-4.4"})]}),mu=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M12 3.5 13.6 9 19 10.5 13.6 12 12 17.5 10.4 12 5 10.5 10.4 9z"}),r("path",{d:"M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5"})]}),fu=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M4 18h16"}),r("path",{d:"M5 18a7 7 0 0 1 14 0"}),r("path",{d:"M12 8V6"}),r("path",{d:"M10 6h4"})]}),gu=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M7 11V6.5a1.5 1.5 0 0 1 3 0V10"}),r("path",{d:"M10 10V5.5a1.5 1.5 0 0 1 3 0V10"}),r("path",{d:"M13 10V6.5a1.5 1.5 0 0 1 3 0V12"}),r("path",{d:"M16 9.5a1.5 1.5 0 0 1 3 0v2.5a7 7 0 0 1-7 7 7 7 0 0 1-6.4-4.2L4 12.5a1.5 1.5 0 0 1 2.6-1.5L7 11"})]}),vl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),r("path",{d:"M5 15a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2"})]}),bl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M7 10v11H4a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1z"}),r("path",{d:"M7 10l4-7a2.5 2.5 0 0 1 2.5 2.5V8h5a2 2 0 0 1 2 2.3l-1.2 8A2 2 0 0 1 17.3 20H7"})]}),Pl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("path",{d:"M17 14V3h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1z"}),r("path",{d:"M17 14l-4 7a2.5 2.5 0 0 1-2.5-2.5V16h-5a2 2 0 0 1-2-2.3l1.2-8A2 2 0 0 1 6.7 4H17"})]}),yl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"3.5"}),r("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M19.1 4.9l-2.1 2.1M7 17l-2.1 2.1"})]}),xl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"M12 7v5l3 2"})]}),Io=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"m8.5 12 2.5 2.5 4.5-5"})]}),Lo=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"m15 9-6 6M9 9l6 6"})]}),Sl={chat:ta,message:na,bubbles:kn,spark:cu,wand:du,bot:_u,help:Sn,lifebuoy:uu,headset:oa,search:pu,sparkles:mu,concierge:fu,wave:gu};var I=x.cssPrefix,S={launcher:`${I}-launcher`,callout:`${I}-callout`,calloutDismiss:`${I}-callout-dismiss`,panel:`${I}-panel`,panelHeader:`${I}-panel-header`,resizeGrip:`${I}-resize-grip`,scrollToBottom:`${I}-scroll-to-bottom`,actionHistory:`${I}-action-history`,actionClose:`${I}-action-close`,langSegment:`${I}-lang-segment`,composer:`${I}-composer`,composerInput:`${I}-composer-input`,composerSend:`${I}-composer-send`,composerStop:`${I}-composer-stop`,composerAttach:`${I}-composer-attach`,composerFileInput:`${I}-composer-file-input`,composerVoice:`${I}-composer-voice`,attachmentChip:`${I}-attachment-chip`,attachmentRemove:`${I}-attachment-remove`,suggestion:`${I}-suggestion`,messageBubble:`${I}-message`,messageRetry:`${I}-message-retry`,messageFeedback:`${I}-message-feedback`,feedbackUp:`${I}-feedback-up`,feedbackDown:`${I}-feedback-down`,messageCopy:`${I}-message-copy`,historyPane:`${I}-history-pane`,historyBack:`${I}-history-back`,historyItem:`${I}-history-item`,sidebar:`${I}-sidebar`,sidebarToggle:`${I}-sidebar-toggle`,sidebarNewConversation:`${I}-sidebar-new-conversation`,sidebarItem:`${I}-sidebar-item`,messengerHome:`${I}-messenger-home`,modulesEmpty:`${I}-modules-empty`,tab:`${I}-tab`,tabBadge:`${I}-tab-badge`,homeView:`${I}-home-view`,homeGreeting:`${I}-home-greeting`,homeBrand:`${I}-home-brand`,backHeader:`${I}-back-header`,contentView:`${I}-content-view`,contentScroll:`${I}-content-scroll`,homeSearch:`${I}-home-search`,helpSearch:`${I}-help-search`,homeRecent:`${I}-home-recent`,homeContentRow:`${I}-home-content-row`,helpArticle:`${I}-help-article`,newsItem:`${I}-news-item`,formGate:`${I}-form-gate`,formDone:`${I}-form-done`,formDoneToggle:`${I}-form-done-toggle`,formAnswers:`${I}-form-answers`,formFill:`${I}-form-fill`,formSubmit:`${I}-form-submit`,formSkip:`${I}-form-skip`,formField:`${I}-form-field`,toolAskQuestions:`${I}-tool-ask-questions`,toolInputSubmit:`${I}-tool-input-submit`,toolInputSkip:`${I}-tool-input-skip`,toolApproval:`${I}-tool-approval`,toolApprove:`${I}-tool-approve`,toolReject:`${I}-tool-reject`,toolEdit:`${I}-tool-edit`,toolDecision:`${I}-tool-decision`,toolAskSummary:`${I}-ask-questions-summary`,toolAskOptions:`${I}-ask-questions-options-toggle`,toolCall:`${I}-tool-call`,source:`${I}-source`,operatorRequest:`${I}-operator-request`,operatorBanner:`${I}-operator-banner`};function we(e,t){return`${e}-${t}`}var Mo=x.cssPrefix;function kl({onToggle:e,launcher:t,strings:n,leaving:o,edgeTab:a}){let i=t.variant!=="circle"&&!!t.label;return r("button",{type:"button",class:`${Mo}-fab`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":a?"true":void 0,"data-leaving":o?"true":void 0,"data-testid":S.launcher,onClick:e,"aria-label":n.launcherOpen,children:[hu(t.icon),i?r("span",{class:`${Mo}-fab-label`,children:Ne(n,t.label??"")}):null]})}function hu(e){let t=Sl[e];return t?r(t,{}):r(vu,{source:e})}function vu({source:e}){return r("span",{ref:t=>{t&&bu(t,e)},"aria-hidden":"true"})}function bu(e,t){if(e.dataset.svgMounted!==t)try{let o=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;o&&o.tagName.toLowerCase()==="svg"&&(e.replaceChildren(document.importNode(o,!0)),e.dataset.svgMounted=t)}catch{}}function wl({callout:e,launcherPosition:t,strings:n,closeLabel:o,onDismiss:a}){let[i,l]=R(!1);return T(()=>{let s=setTimeout(()=>l(!0),e.delayMs);return()=>clearTimeout(s)},[e.delayMs]),T(()=>{if(!i||e.autoDismissMs<=0)return;let s=setTimeout(a,e.autoDismissMs);return()=>clearTimeout(s)},[i,e.autoDismissMs,a]),i?r("div",{class:`${Mo}-callout`,role:"status","data-shape":e.shape,"data-position":Pu(e.position,t),"data-animated":e.animated?"true":void 0,"data-testid":S.callout,children:[r("span",{children:Ne(n,e.text)}),r("button",{type:"button",class:`${Mo}-callout-close`,onClick:a,"aria-label":o,title:o,"data-testid":S.calloutDismiss,children:r(et,{})})]}):null}function Pu(e,t){let n=t.endsWith("-right"),o=t.startsWith("bottom-");return e==="vertical"?o?"top":"bottom":n?"left":"right"}function Oo({panelEl:e,resize:t,position:n,initialSize:o,onSizeChange:a,strings:i}){let l=x.cssPrefix,s=N(null);if(T(()=>{if(!e)return;let m=e.style;t.minWidth&&m.setProperty(`--${l}-resize-min-w`,t.minWidth),t.maxWidth&&m.setProperty(`--${l}-resize-max-w`,t.maxWidth),t.minHeight&&m.setProperty(`--${l}-resize-min-h`,t.minHeight),t.maxHeight&&m.setProperty(`--${l}-resize-max-h`,t.maxHeight),o&&(m.setProperty(`--${l}-widget-w`,`${o.width}px`),m.setProperty(`--${l}-widget-h`,`${o.height}px`))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,l,o]),!e)return null;let c=n.startsWith("top-"),_=n.endsWith("-right"),p=`${l}-resize-grip ${l}-resize-grip--${c?"bottom":"top"}-${_?"left":"right"}`,v=m=>{if(!e)return;let k=m.currentTarget,h=e.getBoundingClientRect();s.current={pointerId:m.pointerId,startX:m.clientX,startY:m.clientY,startW:h.width,startH:h.height,dirX:_?-1:1,dirY:c?1:-1},k.setPointerCapture(m.pointerId),e.setAttribute("data-resizing",""),m.preventDefault()},u=m=>{let k=s.current;if(!k||m.pointerId!==k.pointerId||!e)return;let h=(m.clientX-k.startX)*k.dirX,b=(m.clientY-k.startY)*k.dirY;e.style.setProperty(`--${l}-widget-w`,`${k.startW+h}px`),e.style.setProperty(`--${l}-widget-h`,`${k.startH+b}px`)},f=m=>{let k=s.current;if(!k||m.pointerId!==k.pointerId||!e)return;m.currentTarget.releasePointerCapture(m.pointerId),e.removeAttribute("data-resizing");let h=e.getBoundingClientRect();a({width:Math.round(h.width),height:Math.round(h.height)}),s.current=null};return r("div",{class:p,role:"separator","aria-orientation":"vertical","aria-label":i.resizeHandle,title:i.resizeHandle,onPointerDown:v,onPointerMove:u,onPointerUp:f,onPointerCancel:f,"data-testid":S.resizeGrip,children:r(nl,{})})}var Rt=x.cssPrefix,yu=`.${Rt}-header, .${Rt}-back-header, .${Rt}-home-hero`,xu='button, a, input, textarea, select, [role="tab"], [contenteditable]',Cl=56;function No(e,t){T(()=>{if(!t||!e)return;let n=c=>Number.parseFloat(c)||0,o=(c,_)=>Math.min(_,Math.max(-_,c)),a=null,i=c=>{let _=c.target;if(!(_ instanceof Element)||!_.closest(yu)||_.closest(xu))return;let p=e.getBoundingClientRect();a={id:c.pointerId,x:c.clientX,y:c.clientY,dx:n(e.style.getPropertyValue(`--${Rt}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${Rt}-modal-dy`)),maxX:(window.innerWidth+p.width)/2-Cl,maxY:(window.innerHeight+p.height)/2-Cl},e.dataset.dragging="true",c.preventDefault()},l=c=>{if(!a||c.pointerId!==a.id)return;let _=o(a.dx+c.clientX-a.x,a.maxX),p=o(a.dy+c.clientY-a.y,a.maxY);e.style.setProperty(`--${Rt}-modal-dx`,`${_}px`),e.style.setProperty(`--${Rt}-modal-dy`,`${p}px`)},s=c=>{!a||c.pointerId!==a.id||(a=null,delete e.dataset.dragging)};return e.addEventListener("pointerdown",i),window.addEventListener("pointermove",l),window.addEventListener("pointerup",s),window.addEventListener("pointercancel",s),()=>{e.removeEventListener("pointerdown",i),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",s),window.removeEventListener("pointercancel",s)}},[e,t])}function wn(e,t,n){switch(e){case"clear":case"sound":case"history":case"language":case"theme":case"textSize":return!0;case"expand":return t==="floating";case"fullscreen":return t!=="standalone";case"close":return t==="standalone"||t==="page"?!1:t==="inline"?n==="fullscreen":!0}}function Do(e,t,n){return wn("close",e,t)?n.includes("close"):!1}function Tl(e,t){return e==="inline"&&t==="fullscreen"?"exit-fullscreen":"close"}var Su='a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])';function $o(e){let t=n=>{if(n.key!=="Tab")return;let o=[...e.querySelectorAll(Su)].filter(s=>s.offsetParent!==null||s===document.activeElement);if(o.length===0){n.preventDefault();return}let a=o[0],i=o[o.length-1];if(!a||!i)return;let l=e.getRootNode().activeElement;n.shiftKey&&l===a?(n.preventDefault(),i.focus()):!n.shiftKey&&l===i&&(n.preventDefault(),a.focus())};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}function Fo(e){return e.trim().split(/\s+/).slice(0,2).map(t=>t.charAt(0).toUpperCase()).join("")}var aa=x.cssPrefix;function El({agent:e,strings:t}){let n=e.status??"online",o=Ne(t,e.name),a=e.title?Ne(t,e.title):null;return r("div",{class:`${aa}-agent`,children:[r("div",{class:`${aa}-agent-avatar`,"data-status":n,children:e.avatar?r("img",{src:e.avatar,alt:""}):r("span",{children:Fo(o)})}),r("div",{class:`${aa}-agent-meta`,children:[r("strong",{children:o}),a?r("span",{children:a}):null]})]})}var Rl=ee.scope("attachments");function Bo(e,t,n){let o=wu(e),a=[],i=[],l=Eu(n.accept),s=t.reduce((_,p)=>_+p.size,0),c=t.length;for(let _ of o){let p=ku(_,c,s,n,l);if(p){i.push({file:_,reason:p});continue}a.push(Tu(_)),s+=_.size,c+=1}return(a.length||i.length)&&Rl.debug("ingest",{accepted:a.length,rejected:i.map(_=>({name:_.file.name,reason:_.reason}))}),{accepted:a,rejected:i}}function ia(e){try{URL.revokeObjectURL(e.previewUrl)}catch(t){Rl.debug("revokeObjectURL failed",{error:t})}}function ku(e,t,n,o,a){return t>=o.maxCount?"count":n+e.size>o.maxBytes?"bytes":Ru(e,a)?null:"mime"}function wu(e){return e?Array.isArray(e)?e.filter(t=>t instanceof File):[...e].map(t=>t instanceof File?t:Cu(t)).filter(t=>t!==null):[]}function Cu(e){let t=e;return!t?.getAsFile||t.kind!=="file"?null:t.getAsFile()}function Tu(e){return{file:e,id:Ge(),mediaType:e.type||"application/octet-stream",name:e.name||"pasted-file",previewUrl:URL.createObjectURL(e),size:e.size}}function Eu(e){return e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean).map(t=>{if(t.startsWith("."))return{kind:"ext",ext:t};let[n="*",o="*"]=t.split("/");return{kind:"mime",type:n,subtype:o}})}function Ru(e,t){if(t.length===0)return!0;let[n="*",o="*"]=(e.type||"").toLowerCase().split("/"),a=(e.name||"").toLowerCase();return t.some(i=>i.kind==="ext"?a.endsWith(i.ext):(i.type==="*"||i.type===n)&&(i.subtype==="*"||i.subtype===o))}var Cn=x.cssPrefix;function Al({attachment:e,onRemove:t}){let n=e.mediaType.startsWith("image/");return r("span",{class:`${Cn}-attachment-chip`,title:e.name,"data-testid":we(S.attachmentChip,e.id),children:[n?r("img",{class:`${Cn}-attachment-thumb`,src:e.previewUrl,alt:""}):r("span",{class:`${Cn}-attachment-thumb`,"aria-hidden":"true",children:r(_l,{})}),r("span",{class:`${Cn}-attachment-name`,children:e.name}),r("button",{type:"button",class:`${Cn}-attachment-remove`,onClick:t,"aria-label":`Remove ${e.name}`,"data-testid":we(S.attachmentRemove,e.id),children:r(et,{})})]})}var sa={isSupported:!1,start:()=>{},stop:()=>{}};function la(e,t,n){return e==="disabled"?sa:e==="server"?Mu(n):Au(t)}function Au(e){let t=Iu();if(!t)return sa;let n=null;return{isSupported:!0,start(o,a){n=new t,n.continuous=!0,n.interimResults=!0,n.lang=e,n.addEventListener("result",l=>{let s=l,c="",_=!1;for(let p=s.resultIndex;p<s.results.length;p++){let v=s.results[p];v&&(c+=v[0].transcript,v.isFinal&&(_=!0))}o(c,_)});let i=()=>{n=null,a()};n.addEventListener("end",i),n.addEventListener("error",i),n.start()},stop(){n?.stop()}}}function Iu(){return window.SpeechRecognition??window.webkitSpeechRecognition}var Lu=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus","audio/mp4"];function Mu(e){if(typeof MediaRecorder>"u"||!navigator?.mediaDevices?.getUserMedia)return sa;let t=null,n=null,o=[],a=()=>{for(let i of n?.getTracks()??[])i.stop();n=null};return{isSupported:!0,async start(i,l){try{n=await navigator.mediaDevices.getUserMedia({audio:!0});let s=Ou();t=new MediaRecorder(n,s?{mimeType:s}:void 0),o=[],t.addEventListener("dataavailable",c=>{c.data.size>0&&o.push(c.data)}),t.addEventListener("stop",async()=>{let c=t?.mimeType??"audio/webm";a();let _=new Blob(o,{type:c});o=[];try{let{text:p}=await e(_,c);p&&i(p,!0)}catch{}finally{l()}}),t.start()}catch{a(),l()}},stop(){t?.stop()}}}function Ou(){for(let e of Lu)if(MediaRecorder.isTypeSupported(e))return e}var Ue=x.cssPrefix,At=ee.scope("composer");function Xt(e){return e.reduce((t,n)=>t+n.size,0)}var Nu={arrowUp:Ks,paperPlane:Gs,send:js,chevron:jt};function Il({options:e,transport:t,feedback:n,bus:o,isStreaming:a,operatorRequestEnabled:i,controlMode:l,onRequestOperator:s,onSend:c,onStop:_,attachApiRef:p}){let v=e.strings,[u,f]=R(""),[m,k]=R([]),[h,b]=R(!1),w=N(null),P=N(null),E=e.features.fileUpload,B=e.features.voice,[J,ie]=R(()=>la(B,e.locale,(L,z)=>t.transcribe(L,z)));T(()=>{h||B==="disabled"||ie(la(B,e.locale,(L,z)=>t.transcribe(L,z)))},[e.locale,B,t,h]),T(()=>{let L=w.current;if(!L)return;let z=L.getRootNode(),W="activeElement"in z?z.activeElement:null;W&&L.closest(`.${Ue}-panel`)?.contains(W)||L.focus({preventScroll:!0})},[]),T(()=>{let L=w.current;if(!L)return;if(u.length===0){L.style.height="";return}L.style.height="auto";let z=parseFloat(getComputedStyle(L).fontSize)*.7,W=Math.min(L.scrollHeight,160);L.style.height=`${W<40+z?40:W}px`},[u]);let ne=N(m);ne.current=m,T(()=>()=>ne.current.forEach(ia),[]),T(()=>{if(p)return p.current={attachFromDrop:L=>{let z=Bo(L,ne.current,e.attachments);z.accepted.length!==0&&(At.info("attach (drop)",{count:z.accepted.length,totalBytes:Xt(z.accepted)}),o.emit("attach",{count:z.accepted.length,totalBytes:Xt(z.accepted)}),k(W=>[...W,...z.accepted]))},fill:L=>{f(L);let z=w.current;z&&(z.focus({preventScroll:!0}),requestAnimationFrame(()=>z.setSelectionRange(z.value.length,z.value.length)))}},()=>{p.current&&(p.current=null)}},[p,e.attachments]),T(()=>{let L=w.current;if(!L)return;let z=L.closest(`.${Ue}-panel`);if(!z)return;let W=Se=>{let ot=Se.clipboardData;if(!ot)return;let $e=Se.target?.closest?.("input, textarea, [contenteditable]:not([contenteditable='false'])");if($e&&$e!==L)return;if(E){let Pe=Bo(ot.items,ne.current,e.attachments);if(Pe.accepted.length>0){Se.preventDefault(),At.info("attach (paste)",{count:Pe.accepted.length,totalBytes:Xt(Pe.accepted)}),o.emit("attach",{count:Pe.accepted.length,totalBytes:Xt(Pe.accepted)}),k(fe=>[...fe,...Pe.accepted]);return}}if($e===L)return;let be=ot.getData("text/plain");be&&(Se.preventDefault(),f(Pe=>Pe+be),L.focus())};return z.addEventListener("paste",W),()=>z.removeEventListener("paste",W)},[E,e.attachments,Ue]);let Z=()=>{let L=u.trim();!L&&m.length===0||a||(c(L,m),f(""),k([]))},O=L=>{L.key!=="Enter"||L.shiftKey||L.isComposing||(L.preventDefault(),a?_():Z())},D=L=>{let z=L.target,W=Bo(z.files,m,e.attachments);W.accepted.length>0&&(At.info("attach (file picker)",{count:W.accepted.length,totalBytes:Xt(W.accepted)}),o.emit("attach",{count:W.accepted.length,totalBytes:Xt(W.accepted)}),k(Se=>[...Se,...W.accepted])),z.value=""},K=L=>{At.info("removeAttachment",{id:L}),o.emit("removeAttachment",{id:L}),k(z=>{let W=z.find(Se=>Se.id===L);return W&&ia(W),z.filter(Se=>Se.id!==L)})},X=N(null),se=()=>{if(J.isSupported){if(h){let L=X.current?Date.now()-X.current:0;At.info("voiceStop",{durationMs:L}),o.emit("voiceStop",{durationMs:L}),J.stop(),b(!1),n.play("voiceStop"),X.current=null;return}X.current=Date.now(),At.info("voiceStart"),o.emit("voiceStart",void 0),b(!0),n.play("voiceStart"),J.start((L,z)=>f(W=>z?`${W}${L} `:W),()=>{if(b(!1),X.current){let L=Date.now()-X.current;At.debug("voiceStop (auto)",{durationMs:L}),o.emit("voiceStop",{durationMs:L}),X.current=null}})}},ce=Nu[e.composer.sendButton.icon];return r("div",{class:`${Ue}-composer`,"data-testid":S.composer,children:[m.length>0?r("div",{class:`${Ue}-attachments`,children:m.map(L=>r(Al,{attachment:L,onRemove:()=>K(L.id)},L.id))}):null,r("div",{class:`${Ue}-composer-row`,children:[r("div",{class:`${Ue}-composer-actions`,children:[E?r("button",{type:"button",class:`${Ue}-icon-btn`,onClick:()=>P.current?.click(),"aria-label":v.attach,"data-testid":S.composerAttach,children:r(Ys,{})}):null,J.isSupported?r("button",{type:"button",class:`${Ue}-icon-btn`,onClick:se,"aria-label":h?v.micStop:v.micStart,"aria-pressed":h,"data-recording":h?"true":void 0,"data-testid":S.composerVoice,children:r(Js,{})}):null,i&&l==="ai-agent"&&s?r("button",{type:"button",class:`${Ue}-icon-btn`,onClick:s,"aria-label":v.talkToOperator,title:v.talkToOperator,"data-testid":S.operatorRequest,children:r(oa,{})}):null]}),r("textarea",{ref:w,class:`${Ue}-textarea`,rows:1,value:u,placeholder:v.composerPlaceholder,onInput:L=>f(L.target.value),onKeyDown:O,"aria-label":v.composerPlaceholder,"data-testid":S.composerInput}),a?r("button",{type:"button",class:`${Ue}-send`,onClick:_,"aria-label":v.stop,"data-testid":S.composerStop,children:r(Xs,{})}):r("button",{type:"button",class:`${Ue}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:Z,disabled:!u.trim()&&m.length===0,"aria-label":v.send,"data-testid":S.composerSend,children:r(ce,{})})]}),r("input",{ref:P,type:"file",multiple:!0,accept:e.attachments.accept,onChange:D,class:`${Ue}-sr-only`,"data-testid":S.composerFileInput})]})}var Du=x.cssPrefix;function Ll({visible:e,strings:t}){return e?r("div",{class:`${Du}-dropzone`,role:"status","aria-live":"polite",children:t.dropZone}):null}function Ho({containerRef:e,onDrop:t}){let[n,o]=R(!1);return T(()=>{let a=e.current;if(!a)return;let i=0,l=p=>{i+=1,p.dataTransfer?.types.includes("Files")&&(p.preventDefault(),o(!0))},s=()=>{i-=1,!(i>0)&&(i=0,o(!1))},c=p=>{p.dataTransfer?.types.includes("Files")&&p.preventDefault()},_=p=>{i=0,o(!1),p.dataTransfer&&(p.preventDefault(),t(p.dataTransfer.items))};return a.addEventListener("dragenter",l),a.addEventListener("dragleave",s),a.addEventListener("dragover",c),a.addEventListener("drop",_),()=>{a.removeEventListener("dragenter",l),a.removeEventListener("dragleave",s),a.removeEventListener("dragover",c),a.removeEventListener("drop",_)}},[e,t]),{visible:n}}function Ml({itemCount:e,initialFocusIndex:t}){let[n,o]=R(!1),a=N(null),i=N(null),[l,s]=R(-1),c=$(()=>{o(!1),s(-1),a.current?.focus()},[]),_=$(()=>o(u=>!u),[]);T(()=>{if(!n)return;let u=f=>{let m=i.current,k=a.current;if(!m||!k)return;let h=f.composedPath();h.includes(m)||h.includes(k)||(o(!1),s(-1))};return document.addEventListener("click",u,!0),()=>document.removeEventListener("click",u,!0)},[n]),T(()=>{if(!n||e===0)return;let u=t?.()??0,f=u<0||u>=e?0:u;s(f)},[n,e,t]),T(()=>{if(!n||l<0)return;i.current?.querySelectorAll("[role='menuitem']")?.[l]?.focus()},[n,l]);let p=$(u=>{(u.key==="ArrowDown"||u.key==="Enter"||u.key===" ")&&(u.preventDefault(),o(!0))},[]),v=$(u=>{if(e!==0)switch(u.key){case"Escape":u.preventDefault(),c();return;case"ArrowDown":u.preventDefault(),s(f=>(f+1)%e);return;case"ArrowUp":u.preventDefault(),s(f=>(f-1+e)%e);return;case"Home":u.preventDefault(),s(0);return;case"End":u.preventDefault(),s(e-1)}},[e,c]);return{open:n,focusIndex:l,triggerRef:a,menuRef:i,toggle:_,close:c,onTriggerKey:p,onMenuKey:v}}function Ol({items:e,triggerLabel:t}){let n=x.cssPrefix,o=Ml({itemCount:e.length}),a=s=>{s.disabled||(s.onSelect?.(),s.keepOpen||o.close())},i=(s,c)=>s.onSelectValue?.(c),l=(s,c)=>{let _=c.segments;if(!_?.length)return;let p=Math.max(0,_.findIndex(u=>u.value===c.value)),v=-1;if(s.key==="ArrowRight"||s.key==="Enter"||s.key===" ")v=(p+1)%_.length;else if(s.key==="ArrowLeft")v=(p-1+_.length)%_.length;else return;s.preventDefault(),s.stopPropagation(),i(c,_[v].value)};return r("div",{class:`${n}-menu-wrap`,children:[r("button",{ref:o.triggerRef,type:"button",class:`${n}-icon-btn`,"aria-label":t,"aria-haspopup":"menu","aria-expanded":o.open,title:t,onClick:o.toggle,onKeyDown:o.onTriggerKey,children:r(ol,{})}),o.open?r("div",{ref:o.menuRef,class:`${n}-menu`,role:"menu","aria-label":t,onKeyDown:o.onMenuKey,tabIndex:-1,children:e.map(s=>s.segments?r("div",{role:"menuitem",class:`${n}-menu-item ${n}-menu-item-segmented`,"aria-label":s.label,tabIndex:-1,onKeyDown:c=>l(c,s),children:[s.icon?r("span",{class:`${n}-menu-icon`,children:s.icon}):null,r("span",{class:`${n}-menu-label`,children:s.label}),r("span",{class:`${n}-segmented`,role:"group","aria-label":s.label,children:s.segments.map(c=>{let _=c.value===s.value;return r("button",{type:"button",role:"menuitemradio","aria-checked":_,class:`${n}-segment`,"data-on":_?"true":void 0,lang:c.lang,title:c.value,tabIndex:-1,"data-testid":`${S.langSegment}-${c.value}`,onClick:()=>i(s,c.value),children:c.label},c.value)})})]},s.id):r("button",{type:"button",role:"menuitem",class:`${n}-menu-item`,"aria-pressed":s.type==="switch"?s.on:void 0,disabled:s.disabled,onClick:()=>a(s),children:[s.icon?r("span",{class:`${n}-menu-icon`,children:s.icon}):null,r("span",{class:`${n}-menu-label`,children:s.label}),s.type==="switch"&&s.on?r("span",{class:`${n}-menu-check`,"aria-hidden":"true",children:r(Tt,{})}):null]},s.id))}):null]})}var ca=x.cssPrefix;function $u(e){let t=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)").matches:!0;return e==="auto"?t?"light":"dark":t?e==="light"?"dark":"auto":e==="dark"?"light":"auto"}var Fu={normal:"large",large:"small",small:"normal"};function Bu(e){return e==="light"?r(fl,{}):e==="dark"?r(gl,{}):r(hl,{})}function Hu(e){return(e.split("-")[0]??e).toUpperCase()}function tt({panelProps:e,variant:t}){let{options:n,panelSize:o,feedback:a,onClose:i,onClear:l,onExpand:s,onFullscreen:c,onSoundToggle:_}=e,{onToggleHistory:p,onLocaleChange:v,onThemeChange:u,onTextSizeChange:f}=e,m=n.strings,k=n.mode,h=t==="chat",b=Q(()=>a.mutedSig.value).value,w=new Set(n.actions),P=X=>w.has(X),E=typeof matchMedia=="function"&&matchMedia("(max-width: 640px)").matches,B=X=>E?!1:wn(X,k,o),J=n.themeMode,ie={auto:m.themeAuto,light:m.themeLight,dark:m.themeDark},ne=n.textSize,Z={small:m.textSizeSmall,normal:m.textSizeNormal,large:m.textSizeLarge},O=[];if(h&&P("clear")&&O.push({id:"clear",icon:r(dl,{}),label:m.newConversation,onSelect:l}),P("expand")&&B("expand")){let X=o==="expanded";O.push({id:"expand",icon:X?r(Zs,{}):r(Qs,{}),label:X?m.collapse:m.expand,type:"switch",on:X,onSelect:s})}if(P("fullscreen")&&B("fullscreen")){let X=o==="fullscreen";O.push({id:"fullscreen",icon:X?r(tl,{}):r(el,{}),label:X?m.exitFullscreen:m.fullscreen,type:"switch",on:X,onSelect:c})}h&&P("sound")&&O.push({id:"sound",icon:b?r(al,{}):r(rl,{}),label:b?m.soundOff:m.soundOn,type:"switch",on:!b,onSelect:_}),P("theme")&&O.push({id:"theme",icon:Bu(J),label:`${m.theme}: ${ie[J]}`,onSelect:()=>u($u(J)),keepOpen:!0}),P("textSize")&&O.push({id:"textSize",icon:r(il,{}),label:`${m.textSize}: ${Z[ne]}`,onSelect:()=>f(Fu[ne]),keepOpen:!0}),P("language")&&n.availableLocales.length>1&&O.push({id:"language",icon:r(cl,{}),label:m.language,segments:n.availableLocales.map(X=>({value:X,label:Hu(X),lang:X})),value:n.locale,onSelectValue:v});let D=!!i&&Do(k,o,n.actions),K=h&&P("history");return r("div",{class:`${ca}-header-actions`,children:[K?r("button",{type:"button",class:`${ca}-icon-btn`,onClick:p,"aria-label":m.history,title:m.history,"data-testid":S.actionHistory,children:r(ll,{})}):null,O.length>0?r(Ol,{items:O,triggerLabel:m.moreActions}):null,D?r("button",{type:"button",class:`${ca}-icon-btn`,onClick:i,"aria-label":m.close,title:m.close,"data-testid":S.actionClose,children:r(et,{})}):null]})}var zu=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Uu=/^https?:\/\/[^\s.]+\.[^\s]+$/i,qu=/^[+]?[\d\s().-]{6,}$/;function Yt(e,t){return e.replace(/\{(\w+)\}/g,(n,o)=>String(t[o]??`{${o}}`))}function Vu(e){return Array.isArray(e)?e.length:e&&e.trim()?1:0}function Wu(e,t,n){let o=e.required??!0,a=e.validation;if(e.type==="multiselect"){let l=Vu(t);return o&&l===0?n.formRequired:l===0?void 0:a?.minSelections!=null&&l<a.minSelections?Yt(n.formChooseAtLeast,{min:a.minSelections}):a?.maxSelections!=null&&l>a.maxSelections?Yt(n.formChooseAtMost,{max:a.maxSelections}):void 0}let i=typeof t=="string"?t.trim():"";if(!i)return o?n.formRequired:void 0;switch(e.type){case"email":if(!zu.test(i))return n.formInvalidEmail;break;case"url":if(!Uu.test(i))return n.formInvalidUrl;break;case"tel":if(!qu.test(i))return n.formInvalidTel;break;case"number":{let l=Number(i);if(!Number.isFinite(l))return n.formInvalidNumber;if(a?.min!=null&&l<a.min)return Yt(n.formNumberTooSmall,{min:a.min});if(a?.max!=null&&l>a.max)return Yt(n.formNumberTooLarge,{max:a.max});break}default:break}if(a?.minLength!=null&&i.length<a.minLength)return Yt(n.formTooShort,{min:a.minLength});if(a?.maxLength!=null&&i.length>a.maxLength)return Yt(n.formTooLong,{max:a.maxLength});if(a?.pattern)try{if(!new RegExp(a.pattern).test(i))return n.formPatternMismatch}catch{}}function Nl(e,t,n){let o={};for(let a of e){let i=Wu(a,t[a.name],n);i&&(o[a.name]=i)}return o}function Dl(e){let t={};for(let[n,o]of Object.entries(e)){let a=Array.isArray(o)?o.join(", "):o;a&&a.trim()&&(t[n]=a.trim())}return t}var de=x.cssPrefix,zo="__other__";function Tn({fields:e,strings:t,submitLabel:n,onSubmit:o,skipLabel:a,onSkip:i,footerHint:l,submitOnEnter:s,disabled:c,initialValues:_,hideActions:p,fieldTypeLabels:v,rootTestId:u,submitTestId:f,skipTestId:m}){let[k,h]=R(()=>({...Xu(e),..._})),[b,w]=R({}),[P,E]=R({}),B=O=>{P[O]&&E(D=>({...D,[O]:""}))},J=(O,D)=>{h(K=>({...K,[O]:D})),B(O)},ie=(O,D)=>{w(K=>({...K,[O]:D})),B(O)},ne=O=>{if(O.preventDefault(),c)return;let D=Yu(e,k,b),K=Nl(e,D,t);if(Object.keys(K).length>0){E(K);return}o(Dl(D))},Z=O=>{!s||O.key!=="Enter"||O.shiftKey||O.isComposing||O.target?.tagName==="TEXTAREA"&&ne(O)};return r("form",{class:`${de}-form`,onSubmit:ne,onKeyDown:Z,"data-testid":u,noValidate:!0,children:[e.map(O=>r(Gu,{field:O,value:k[O.name],otherText:b[O.name]??"",error:P[O.name],disabled:c,typeLabel:v?.[O.name],strings:t,onChange:D=>J(O.name,D),onOtherChange:D=>ie(O.name,D)},O.name)),p?null:r("div",{class:`${de}-form-actions`,children:[l?r("span",{class:`${de}-form-hint`,children:l}):null,a&&i?r("button",{type:"button",class:`${de}-form-skip`,onClick:i,disabled:c,"data-testid":m,children:a}):null,r("button",{type:"submit",class:`${de}-form-submit`,disabled:c,"data-testid":f,children:n})]})]})}function Gu({field:e,value:t,otherText:n,error:o,disabled:a,typeLabel:i,strings:l,onChange:s,onOtherChange:c}){let _=we(S.formField,e.name),p=Ku({field:e,value:t,otherText:n,disabled:a,strings:l,onChange:s,onOtherChange:c,fieldTid:_});return r("label",{class:`${de}-field`,"data-field":e.name,"data-invalid":o?"true":void 0,children:[r("span",{class:`${de}-field-head`,children:[r("span",{class:`${de}-field-label`,children:[e.label,e.required??!0?r("span",{class:`${de}-field-req`,"aria-hidden":"true",children:" *"}):null]}),i?r("span",{class:`${de}-field-type`,children:i}):null]}),p,e.validationHint&&!o?r("span",{class:`${de}-field-hint`,children:e.validationHint}):null,o?r("span",{class:`${de}-field-error`,role:"alert",children:o}):null]})}function Ku(e){let{field:t,value:n,otherText:o,disabled:a,strings:i,onChange:l,onOtherChange:s,fieldTid:c}=e,_=typeof n=="string"?n:"";switch(t.type){case"textarea":return r("textarea",{class:`${de}-field-input`,rows:3,value:_,placeholder:t.placeholder,disabled:a,onInput:p=>l(p.target.value),"data-testid":c});case"select":return r("select",{class:`${de}-field-input`,value:_,disabled:a,onChange:p=>l(p.target.value),"data-testid":c,children:[r("option",{value:"",children:t.placeholder??"\u2014"}),(t.options??[]).map(p=>r("option",{value:p.value,children:p.label??p.value},p.value))]});case"radio":{let p=t.allowOther&&_===zo;return r("div",{class:`${de}-field-choices`,role:"radiogroup","data-testid":c,children:[(t.options??[]).map(v=>r("label",{class:`${de}-choice`,children:[r("input",{type:"radio",name:`${de}-${t.name}`,checked:_===v.value,disabled:a,onChange:()=>l(v.value)}),r("span",{children:v.label??v.value})]},v.value)),t.allowOther?r("label",{class:`${de}-choice`,children:[r("input",{type:"radio",name:`${de}-${t.name}`,checked:_===zo,disabled:a,onChange:()=>l(zo)}),r("span",{children:i.formOther})]}):null,p?r("input",{class:`${de}-field-input`,value:o,placeholder:t.placeholder??i.formOtherPlaceholder,disabled:a,onInput:v=>s(v.target.value)}):null]})}case"checkbox":return r("label",{class:`${de}-choice`,children:[r("input",{type:"checkbox",checked:_==="true",disabled:a,onChange:p=>l(p.target.checked?"true":""),"data-testid":c}),r("span",{children:t.placeholder??t.label})]});case"multiselect":{let p=Array.isArray(n)?n:[],v=(u,f)=>l(f?[...p,u]:p.filter(m=>m!==u));return r("div",{class:`${de}-field-choices`,"data-testid":c,children:[(t.options??[]).map(u=>r("label",{class:`${de}-choice`,children:[r("input",{type:"checkbox",checked:p.includes(u.value),disabled:a,onChange:f=>v(u.value,f.target.checked)}),r("span",{children:u.label??u.value})]},u.value)),t.allowOther||(t.options??[]).length===0?r("textarea",{class:`${de}-field-input`,rows:2,value:o,placeholder:t.placeholder??i.formOtherPlaceholder,disabled:a,onInput:u=>s(u.target.value)}):null]})}default:return r("input",{class:`${de}-field-input`,type:ju(t.type),value:_,placeholder:t.placeholder,disabled:a,onInput:p=>l(p.target.value),"data-testid":c})}}function ju(e){switch(e){case"number":case"email":case"tel":case"url":case"date":case"time":return e;default:return"text"}}function Xu(e){let t={};for(let n of e)n.defaultValue!=null&&(t[n.name]=n.type==="multiselect"?n.defaultValue.split(",").map(o=>o.trim()).filter(Boolean):n.defaultValue);return t}function Yu(e,t,n){let o={...t};for(let a of e){let i=n[a.name]?.trim();if(a.type==="radio"&&a.allowOther&&t[a.name]===zo)o[a.name]=i??"";else if(a.type==="multiselect"&&i){let l=i.split(/[,\n;]+/).map(c=>c.trim()).filter(Boolean),s=Array.isArray(t[a.name])?t[a.name]:[];o[a.name]=[...s,...l]}}return o}var nt=x.cssPrefix;function da({form:e,strings:t,onSubmit:n,onSkip:o}){return r("div",{class:`${nt}-form-gate`,"data-testid":S.formGate,children:[e.title?r("h3",{class:`${nt}-form-gate-title`,children:e.title}):null,e.description?r("p",{class:`${nt}-form-gate-desc`,children:e.description}):null,r(Tn,{fields:e.fields,strings:t,submitLabel:e.submitLabel??t.formSubmit,onSubmit:n,skipLabel:e.skippable?t.formSkip:void 0,onSkip:e.skippable?o:void 0,submitTestId:S.formSubmit,skipTestId:S.formSkip})]})}function $l({marker:e,strings:t,onFill:n}){let o=e.outcome==="skipped",a=o?t.formSkipped:t.formSubmitted,i=e.title?r(ae,{children:[r("span",{children:e.title}),r("span",{class:`${nt}-sr-only`,children:a})]}):r("span",{children:a}),l=e.form?.reviewable??!1,s=!o&&l&&e.values&&Object.keys(e.values).length>0?e.values:null;if(s){let c=_=>e.form?.fields.find(p=>p.name===_)?.label??_;return r("details",{class:`${nt}-form-done`,"data-outcome":e.outcome,"data-testid":S.formDone,children:[r("summary",{class:`${nt}-form-done-summary`,"data-testid":S.formDoneToggle,children:[r(Tt,{}),i,r(jt,{})]}),r("dl",{class:`${nt}-form-answers`,"data-testid":S.formAnswers,children:Object.entries(s).map(([_,p])=>r("div",{class:`${nt}-form-answer`,children:[r("dt",{children:c(_)}),r("dd",{children:p})]},_))})]})}return r("div",{class:`${nt}-form-done`,"data-outcome":e.outcome,"data-testid":S.formDone,role:"status",children:[o?r(sl,{}):r(Tt,{}),i,o&&e.form?.reopenable&&n?r("button",{type:"button",class:`${nt}-form-done-fill`,"data-testid":S.formFill,onClick:n,children:t.formFillOut}):null]})}function Fl(e){if(!e)return!1;let t=e.startsWith("tool:")?e.slice(5):e;return t==="ask-user-questions"||t==="ask_user_questions"}var pa=1,Hl=2,zl=4,Ul=8,ql=16;function Ju(e){switch(e){case pa:return"href";case Hl:return"src";case zl:return"class";case Ul:return"checked";case ql:return"start"}}var Qu=e=>{switch(e){case 1:return 3;case 2:return 4;case 3:return 5;case 4:return 6;case 5:return 7;default:return 8}},Zu=Qu;var Bl=24;function fa(e){let t=new Uint32Array(Bl);return t[0]=1,{renderer:e,text:"",pending:"",tokens:t,len:0,token:1,fence_end:0,blockquote_idx:0,hr_char:"",hr_chars:0,fence_start:0,spaces:new Uint8Array(Bl),indent:"",indent_len:0,table_state:0}}function Vl(e){e.pending.length>0&&Ie(e,`
12
12
  `)}function oe(e){e.text.length!==0&&(console.assert(e.len>0,"Never adding text to root"),e.renderer.add_text(e.renderer.data,e.text),e.text="")}function ve(e){console.assert(e.len>0,"No nodes to end"),e.len-=1,e.token=e.tokens[e.len],e.renderer.end_token(e.renderer.data)}function re(e,t){(e.tokens[e.len]===24||e.tokens[e.len]===23)&&t!==25&&ve(e),e.len+=1,e.tokens[e.len]=t,e.token=t,e.renderer.add_token(e.renderer.data,t)}function ep(e,t,n){for(;n<=e.len;){if(e.tokens[n]===t)return n;n+=1}return-1}function It(e,t){for(e.fence_start=0;e.len>t;)ve(e)}function Uo(e,t){let n=0;for(let o=0;o<=e.len&&(t-=e.spaces[o],!(t<0));o+=1)switch(e.tokens[o]){case 9:case 10:case 20:case 25:n=o;break}for(;e.len>n;)ve(e);return t}function _a(e,t){let n=-1,o=-1;for(let a=e.blockquote_idx+1;a<=e.len;a+=1)if(e.tokens[a]===25){if(e.indent_len<e.spaces[a]){o=-1;break}o=a}else e.tokens[a]===t&&(n=a);return o===-1?n===-1?(It(e,e.blockquote_idx),re(e,t),!0):(It(e,n),!1):(It(e,o),re(e,t),!0)}function ua(e,t){re(e,25),e.spaces[e.len]=e.indent_len+t,ct(e),e.token=103}function ct(e){e.indent="",e.indent_len=0,e.pending=""}function ma(e){switch(e){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return!0;default:return!1}}function tp(e){switch(e){case 32:case 58:case 59:case 41:case 44:case 33:case 46:case 63:case 93:case 10:return!0;default:return!1}}function np(e){return ma(e)||tp(e)}function Ie(e,t){for(let n of t){if(e.token===101){switch(n){case" ":e.indent_len+=1;continue;case" ":e.indent_len+=4;continue}let a=Uo(e,e.indent_len);e.indent_len=0,e.token=e.tokens[e.len],a>0&&Ie(e," ".repeat(a))}let o=e.pending+n;switch(e.token){case 21:case 1:case 20:case 24:case 23:switch(console.assert(e.text.length===0,"Root should not have any text"),e.pending[0]){case void 0:e.pending=n;continue;case" ":console.assert(e.pending.length===1),e.pending=n,e.indent+=" ",e.indent_len+=1;continue;case" ":console.assert(e.pending.length===1),e.pending=n,e.indent+=" ",e.indent_len+=4;continue;case`
13
13
  `:if(console.assert(e.pending.length===1),e.tokens[e.len]===25&&e.token===21){ve(e),ct(e),e.pending=n;continue}It(e,e.blockquote_idx),ct(e),e.blockquote_idx=0,e.fence_start=0,e.pending=n;continue;case"#":switch(n){case"#":if(e.pending.length<6){e.pending=o;continue}break;case" ":Uo(e,e.indent_len),re(e,Zu(e.pending.length)),ct(e);continue}break;case">":{let i=ep(e,20,e.blockquote_idx+1);i===-1?(It(e,e.blockquote_idx),e.blockquote_idx+=1,e.fence_start=0,re(e,20)):e.blockquote_idx=i,ct(e),e.pending=n;continue}case"-":case"*":case"_":if(e.hr_chars===0&&(console.assert(e.pending.length===1,"Pending should be one character"),e.hr_chars=1,e.hr_char=e.pending),e.hr_chars>0){switch(n){case e.hr_char:e.hr_chars+=1,e.pending=o;continue;case" ":e.pending=o;continue;case`
14
14
  `:if(e.hr_chars<3)break;Uo(e,e.indent_len),e.renderer.add_token(e.renderer.data,22),e.renderer.end_token(e.renderer.data),ct(e),e.hr_chars=0;continue}e.hr_chars=0}if(e.pending[0]!=="_"&&e.pending[1]===" "){_a(e,23),ua(e,2),Ie(e,o.slice(2));continue}break;case"`":if(e.pending.length<3){if(n==="`"){e.pending=o,e.fence_start=o.length;continue}e.fence_start=0;break}switch(n){case"`":e.pending.length===e.fence_start?(e.pending=o,e.fence_start=o.length):(re(e,2),ct(e),e.fence_start=0,Ie(e,o));continue;case`