@helpai/elements 0.61.0 → 0.61.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/elements-web-component.esm.js +2 -2
- package/elements-web-component.esm.js.map +3 -3
- package/elements.cjs.js +2 -2
- package/elements.cjs.js.map +3 -3
- package/elements.esm.js +2 -2
- package/elements.esm.js.map +3 -3
- package/elements.js +2 -2
- package/elements.js.map +3 -3
- package/index.mjs +8 -6
- package/package.json +1 -1
- package/web-component.mjs +8 -6
|
@@ -4,11 +4,11 @@ var nd=Object.defineProperty;var od=(e,t,n)=>t in e?nd(e,t,{enumerable:!0,config
|
|
|
4
4
|
`;var Ai=`.__P__-standalone-page{margin:0;height:100vh;background:var(--__P__-bg, #fff);display:grid;place-items:stretch}
|
|
5
5
|
`;var Ii=`: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 Jd="helpai",Qd="#5B5BD6",Zd="#FFFFFF",e_="12px",t_="Inter, system-ui, -apple-system, 'Segoe UI', sans-serif",Ar=[Ti,Ei,Ri,Ai,Ii].join(`
|
|
7
|
-
`).replace(/__P__/g,Jd).replaceAll("__BRAND_ACCENT_TEXT__",Zd).replaceAll("__BRAND_ACCENT__",Qd).replaceAll("__BRAND_RADIUS__",e_).replaceAll("__BRAND_FONT__",t_);var n_=Q.scope("mount"),Li=new WeakMap,Mi={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 Ni(e,t){e.style.cssText=Mi[t]}function Zn(e){return e==="floating"||e==="modal"||e==="drawer"?"floating":e==="standalone"||e==="page"?"viewport":"flow"}function Di(e={}){let t=e.position??"flow";n_.debug("createShadowMount",{position:t,hasTarget:!!e.target,hasHost:!!e.existingHost});let n=`${y.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",y.id),o.style.cssText=Mi[t];let a=o.shadowRoot??o.attachShadow({mode:"open"}),i=o.ownerDocument;if(!o_(a,i)){let s=i.createElement("style");s.textContent=Ar,a.appendChild(s)}let l=document.createElement("div");return l.className=`${y.cssPrefix}-app`,a.appendChild(l),{appRoot:l,destroy:()=>o.remove(),hostElement:o,shadowRoot:a}}function o_(e,t){if(!("adoptedStyleSheets"in e))return!1;let n=t.defaultView;if(!n||typeof n.CSSStyleSheet!="function")return!1;let o=Li.get(t);if(!o)try{o=new n.CSSStyleSheet,o.replaceSync(Ar),Li.set(t,o)}catch{return!1}try{return e.adoptedStyleSheets=[o],!0}catch{return!1}}function r_(e,t){let n=y.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 a_(e,t){e.dataset.theme=t}function i_(e,t){let n=y.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 s_(e,t){e.dataset.position=t}function eo(e,t){e.dataset.mode=t}function Oi(e,t){a_(e,t.themeMode),r_(e,t.themeOverrides),s_(e,t.position),i_(e,t.size)}var Ot,pe,Ir,$i,an=0,Gi=[],fe=Z,Fi=fe.__b,Bi=fe.__r,Hi=fe.diffed,zi=fe.__c,Ui=fe.unmount,qi=fe.__;function to(e,t){fe.__h&&fe.__h(pe,e,an||t),an=0;var n=pe.__H||(pe.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function I(e){return an=1,l_(ji,e)}function l_(e,t,n){var o=to(Ot++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):ji(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=pe,!pe.__f)){var a=function(s,c,_){if(!o.__c.__H)return!0;var p=!1,g=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]&&(g=!0)}}),i){var d=i.call(this,s,c,_);return p?d||g:d}return!p||g};pe.__f=!0;var i=pe.shouldComponentUpdate,l=pe.componentWillUpdate;pe.componentWillUpdate=function(s,c,_){if(this.__e){var p=i;i=void 0,a(s,c,_),i=p}l&&l.call(this,s,c,_)},pe.shouldComponentUpdate=a}return o.__N||o.__}function A(e,t){var n=to(Ot++,3);!fe.__s&&Mr(n.__H,t)&&(n.__=e,n.u=t,pe.__H.__h.push(n))}function ht(e,t){var n=to(Ot++,4);!fe.__s&&Mr(n.__H,t)&&(n.__=e,n.u=t,pe.__h.push(n))}function D(e){return an=5,Le(function(){return{current:e}},[])}function Le(e,t){var n=to(Ot++,7);return Mr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function $(e,t){return an=8,Le(function(){return e},t)}function Vi(){for(var e;e=Gi.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Lr),t.__h.some(Ki),t.__h=[]}catch(n){t.__h=[],fe.__e(n,e.__v)}}}fe.__b=function(e){pe=null,Fi&&Fi(e)},fe.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),qi&&qi(e,t)},fe.__r=function(e){Bi&&Bi(e),Ot=0;var t=(pe=e.__c).__H;t&&(Ir===pe?(t.__h=[],pe.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.length&&Vi(),Ot=0)),Ir=pe},fe.diffed=function(e){Hi&&Hi(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Gi.push(t)!==1&&$i===fe.requestAnimationFrame||(($i=fe.requestAnimationFrame)||c_)(Vi)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Ir=pe=null},fe.__c=function(e,t){t.some(function(n){try{n.__h.some(Lr),n.__h=n.__h.filter(function(o){return!o.__||Ki(o)})}catch(o){t.some(function(a){a.__h&&(a.__h=[])}),t=[],fe.__e(o,n.__v)}}),zi&&zi(e,t)},fe.unmount=function(e){Ui&&Ui(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(o){try{Lr(o)}catch(a){t=a}}),n.__H=void 0,t&&fe.__e(t,n.__v))};var Wi=typeof requestAnimationFrame=="function";function c_(e){var t,n=function(){clearTimeout(o),Wi&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);Wi&&(t=requestAnimationFrame(n))}function Lr(e){var t=pe,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),pe=t}function Ki(e){var t=pe;e.__c=e.__(),pe=t}function Mr(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function ji(e,t){return typeof t=="function"?t(e):t}var d_=Symbol.for("preact-signals");function ao(){if(nt>1)nt--;else{var e,t=!1;for((function(){var a=oo;for(oo=void 0;a!==void 0;)a.S.v===a.v&&(a.S.i=a.i),a=a.o})();sn!==void 0;){var n=sn;for(sn=void 0,no++;n!==void 0;){var o=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ji(n))try{n.c()}catch(a){t||(e=a,t=!0)}n=o}}if(no=0,nt--,t)throw e}}function $t(e){if(nt>0)return e();Nr=++__,nt++;try{return e()}finally{ao()}}var de=void 0;function ln(e){var t=de;de=void 0;try{return e()}finally{de=t}}var Xi,sn=void 0,nt=0,no=0,__=0,Nr=0,oo=void 0,ro=0;function Yi(e){if(de!==void 0){var t=e.n;if(t===void 0||t.t!==de)return t={i:0,S:e,p:de.s,n:void 0,t:de,e:void 0,x:void 0,r:t},de.s!==void 0&&(de.s.n=t),de.s=t,e.n=t,32&de.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=de.s,t.n=void 0,de.s.n=t,de.s=t),t}}function ye(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}ye.prototype.brand=d_;ye.prototype.h=function(){return!0};ye.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:ln(function(){var o;(o=t.W)==null||o.call(t)}))};ye.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&&ln(function(){var a;(a=t.Z)==null||a.call(t)}))}};ye.prototype.subscribe=function(e){var t=this;return ot(function(){var n=t.value;ln(function(){return e(n)})},{name:"sub"})};ye.prototype.valueOf=function(){return this.value};ye.prototype.toString=function(){return this.value+""};ye.prototype.toJSON=function(){return this.value};ye.prototype.peek=function(){var e=this;return ln(function(){return e.value})};Object.defineProperty(ye.prototype,"value",{get:function(){var e=Yi(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(no>100)throw new Error("Cycle detected");(function(n){nt!==0&&no===0&&n.l!==Nr&&(n.l=Nr,oo={S:n,v:n.v,i:n.i,o:oo})})(this),this.v=e,this.i++,ro++,nt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{ao()}}}});function H(e,t){return new ye(e,t)}function Ji(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 Qi(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 Zi(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 vt(e,t){ye.call(this,void 0,t),this.x=e,this.s=void 0,this.g=ro-1,this.f=4}vt.prototype=new ye;vt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ro))return!0;if(this.g=ro,this.f|=1,this.i>0&&!Ji(this))return this.f&=-2,!0;var e=de;try{Qi(this),de=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 de=e,Zi(this),this.f&=-2,!0};vt.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)}ye.prototype.S.call(this,e)};vt.prototype.U=function(e){if(this.t!==void 0&&(ye.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)}};vt.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(vt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Yi(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function cn(e,t){return new vt(e,t)}function es(e){var t=e.m;if(e.m=void 0,typeof t=="function"){nt++;var n=de;de=void 0;try{t()}catch(o){throw e.f&=-2,e.f|=8,Dr(e),o}finally{de=n,ao()}}}function Dr(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,es(e)}function u_(e){if(de!==this)throw new Error("Out-of-order effect");Zi(this),de=e,this.f&=-2,8&this.f&&Dr(this),ao()}function Ft(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Xi&&Xi.push(this)}Ft.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()}};Ft.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,es(this),Qi(this),nt++;var e=de;return de=this,u_.bind(this,e)};Ft.prototype.N=function(){2&this.f||(this.f|=2,this.u=sn,sn=this)};Ft.prototype.d=function(){this.f|=8,1&this.f||Dr(this)};Ft.prototype.dispose=function(){this.d()};function ot(e,t){var n=new Ft(e,t);try{n.c()}catch(a){throw n.d(),a}var o=n.d.bind(n);return o[Symbol.dispose]=o,o}var ts,lo,io,p_=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var ns=[];ot(function(){ts=this.N})();function Bt(e,t){Z[e]=t.bind(null,Z[e]||function(){})}function so(e){if(io){var t=io;io=void 0,t()}io=e&&e.S()}function os(e){var t=this,n=e.data,o=dn(n);o.value=n;var a=Le(function(){for(var s=t,c=t.__v;c=c.__;)if(c.__c){c.__c.__$f|=4;break}var _=cn(function(){var f=o.value.value;return f===0?0:f===!0?"":f||""}),p=cn(function(){return!Array.isArray(_.value)&&!mr(_.value)}),g=ot(function(){if(this.N=rs,p.value){var f=_.value;s.__v&&s.__v.__e&&s.__v.__e.nodeType===3&&(s.__v.__e.data=f)}}),d=t.__$u.d;return t.__$u.d=function(){g(),d.call(this)},[p,_]},[]),i=a[0],l=a[1];return i.value?l.peek():l.value}os.displayName="ReactiveTextNode";Object.defineProperties(ye.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:os},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}});Bt("__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 ye&&(n||(t.__np=n={}),n[a]=i,o[a]=i.peek())}}e(t)});Bt("__r",function(e,t){if(e(t),t.type!==ie){so();var n,o=t.__c;o&&(o.__$f&=-2,(n=o.__$u)===void 0&&(o.__$u=n=(function(a,i){var l;return ot(function(){l=this},{name:i}),l.c=a,l})(function(){var a;p_&&((a=n.y)==null||a.call(n)),o.__$f|=1,o.setState({})},typeof t.type=="function"?t.type.displayName||t.type.name:""))),lo=o,so(n)}});Bt("__e",function(e,t,n,o){so(),lo=void 0,e(t,n,o)});Bt("diffed",function(e,t){so(),lo=void 0;var n;if(typeof t.type=="string"&&(n=t.__e)){var o=t.__np,a=t.props;if(o){var i=n.U;if(i)for(var l in i){var s=i[l];s!==void 0&&!(l in o)&&(s.d(),i[l]=void 0)}else i={},n.U=i;for(var c in o){var _=i[c],p=o[c];_===void 0?(_=m_(n,c,p,a),i[c]=_):_.o(p,a)}}}e(t)});function m_(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:ot(function(){this.N=rs;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))})}}Bt("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)});Bt("__h",function(e,t,n,o){(o<3||o===9)&&(t.__$f|=2),e(t,n,o)});lt.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 dn(e,t){return Le(function(){return H(e,t)},[])}function j(e,t){var n=D(e);return n.current=e,lo.__$f|=4,Le(function(){return cn(function(){return n.current()},t)},[])}var f_=function(e){queueMicrotask(function(){queueMicrotask(e)})};function g_(){$t(function(){for(var e;e=ns.shift();)ts.call(e)})}function rs(){ns.push(this)===1&&(Z.requestAnimationFrame||f_)(g_)}function as(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function is(e){return as(e)}function ss(e){return!(!as(e)||e.navigation!==void 0&&!Array.isArray(e.navigation)||e.linkCards!==void 0&&!Array.isArray(e.linkCards))}function h_(e){return`${y.cssPrefix}:${e}`}function ls(e,t){let o=Object.entries(t).map(([a,i])=>{let l=h_(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 co(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 v_=900;function Or(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??v_;return n>=a?"expanded":"normal"}return"normal"}function _n(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:Or(e.mode,e.size,t);return{panelOpen:i,panelSize:s}}function Ht(){return typeof window>"u"?0:window.innerWidth}var b_="x-public-key",P_="x-ai-agent-deployment-id";function cs(e){return{headers(){let t={};return e.aiAgentDeploymentId&&(t[P_]=e.aiAgentDeploymentId),e.publicKey&&(t[e.publicKeyHeader??b_]=e.publicKey),t}}}var _o="0.61.0";var We=class extends Error{constructor(n,o,a,i){super(n);K(this,"code",o);K(this,"status",a);K(this,"cause",i);this.name="StreamError"}};var ds=Q.scope("parser");async function*$r(e,t){if(!e.ok){let a=await e.text().catch(()=>"");throw new We(`server responded ${e.status}: ${a.slice(0,200)}`,"server",e.status)}if(!e.body)throw new We("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();if(s){let c=_s(s);c&&(yield c)}return}o+=i;let l;for(;(l=o.indexOf(`
|
|
7
|
+
`).replace(/__P__/g,Jd).replaceAll("__BRAND_ACCENT_TEXT__",Zd).replaceAll("__BRAND_ACCENT__",Qd).replaceAll("__BRAND_RADIUS__",e_).replaceAll("__BRAND_FONT__",t_);var n_=Q.scope("mount"),Li=new WeakMap,Mi={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 Ni(e,t){e.style.cssText=Mi[t]}function Zn(e){return e==="floating"||e==="modal"||e==="drawer"?"floating":e==="standalone"||e==="page"?"viewport":"flow"}function Di(e={}){let t=e.position??"flow";n_.debug("createShadowMount",{position:t,hasTarget:!!e.target,hasHost:!!e.existingHost});let n=`${y.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",y.id),o.style.cssText=Mi[t];let a=o.shadowRoot??o.attachShadow({mode:"open"}),i=o.ownerDocument;if(!o_(a,i)){let s=i.createElement("style");s.textContent=Ar,a.appendChild(s)}let l=document.createElement("div");return l.className=`${y.cssPrefix}-app`,a.appendChild(l),{appRoot:l,destroy:()=>o.remove(),hostElement:o,shadowRoot:a}}function o_(e,t){if(!("adoptedStyleSheets"in e))return!1;let n=t.defaultView;if(!n||typeof n.CSSStyleSheet!="function")return!1;let o=Li.get(t);if(!o)try{o=new n.CSSStyleSheet,o.replaceSync(Ar),Li.set(t,o)}catch{return!1}try{return e.adoptedStyleSheets=[o],!0}catch{return!1}}function r_(e,t){let n=y.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 a_(e,t){e.dataset.theme=t}function i_(e,t){let n=y.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 s_(e,t){e.dataset.position=t}function eo(e,t){e.dataset.mode=t}function Oi(e,t){a_(e,t.themeMode),r_(e,t.themeOverrides),s_(e,t.position),i_(e,t.size)}var Ot,pe,Ir,$i,an=0,Gi=[],fe=Z,Fi=fe.__b,Bi=fe.__r,Hi=fe.diffed,zi=fe.__c,Ui=fe.unmount,qi=fe.__;function to(e,t){fe.__h&&fe.__h(pe,e,an||t),an=0;var n=pe.__H||(pe.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function I(e){return an=1,l_(ji,e)}function l_(e,t,n){var o=to(Ot++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):ji(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=pe,!pe.__f)){var a=function(s,c,_){if(!o.__c.__H)return!0;var p=!1,g=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]&&(g=!0)}}),i){var d=i.call(this,s,c,_);return p?d||g:d}return!p||g};pe.__f=!0;var i=pe.shouldComponentUpdate,l=pe.componentWillUpdate;pe.componentWillUpdate=function(s,c,_){if(this.__e){var p=i;i=void 0,a(s,c,_),i=p}l&&l.call(this,s,c,_)},pe.shouldComponentUpdate=a}return o.__N||o.__}function A(e,t){var n=to(Ot++,3);!fe.__s&&Mr(n.__H,t)&&(n.__=e,n.u=t,pe.__H.__h.push(n))}function ht(e,t){var n=to(Ot++,4);!fe.__s&&Mr(n.__H,t)&&(n.__=e,n.u=t,pe.__h.push(n))}function D(e){return an=5,Le(function(){return{current:e}},[])}function Le(e,t){var n=to(Ot++,7);return Mr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function $(e,t){return an=8,Le(function(){return e},t)}function Vi(){for(var e;e=Gi.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Lr),t.__h.some(Ki),t.__h=[]}catch(n){t.__h=[],fe.__e(n,e.__v)}}}fe.__b=function(e){pe=null,Fi&&Fi(e)},fe.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),qi&&qi(e,t)},fe.__r=function(e){Bi&&Bi(e),Ot=0;var t=(pe=e.__c).__H;t&&(Ir===pe?(t.__h=[],pe.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.length&&Vi(),Ot=0)),Ir=pe},fe.diffed=function(e){Hi&&Hi(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Gi.push(t)!==1&&$i===fe.requestAnimationFrame||(($i=fe.requestAnimationFrame)||c_)(Vi)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Ir=pe=null},fe.__c=function(e,t){t.some(function(n){try{n.__h.some(Lr),n.__h=n.__h.filter(function(o){return!o.__||Ki(o)})}catch(o){t.some(function(a){a.__h&&(a.__h=[])}),t=[],fe.__e(o,n.__v)}}),zi&&zi(e,t)},fe.unmount=function(e){Ui&&Ui(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(o){try{Lr(o)}catch(a){t=a}}),n.__H=void 0,t&&fe.__e(t,n.__v))};var Wi=typeof requestAnimationFrame=="function";function c_(e){var t,n=function(){clearTimeout(o),Wi&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);Wi&&(t=requestAnimationFrame(n))}function Lr(e){var t=pe,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),pe=t}function Ki(e){var t=pe;e.__c=e.__(),pe=t}function Mr(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function ji(e,t){return typeof t=="function"?t(e):t}var d_=Symbol.for("preact-signals");function ao(){if(nt>1)nt--;else{var e,t=!1;for((function(){var a=oo;for(oo=void 0;a!==void 0;)a.S.v===a.v&&(a.S.i=a.i),a=a.o})();sn!==void 0;){var n=sn;for(sn=void 0,no++;n!==void 0;){var o=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ji(n))try{n.c()}catch(a){t||(e=a,t=!0)}n=o}}if(no=0,nt--,t)throw e}}function $t(e){if(nt>0)return e();Nr=++__,nt++;try{return e()}finally{ao()}}var de=void 0;function ln(e){var t=de;de=void 0;try{return e()}finally{de=t}}var Xi,sn=void 0,nt=0,no=0,__=0,Nr=0,oo=void 0,ro=0;function Yi(e){if(de!==void 0){var t=e.n;if(t===void 0||t.t!==de)return t={i:0,S:e,p:de.s,n:void 0,t:de,e:void 0,x:void 0,r:t},de.s!==void 0&&(de.s.n=t),de.s=t,e.n=t,32&de.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=de.s,t.n=void 0,de.s.n=t,de.s=t),t}}function ye(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}ye.prototype.brand=d_;ye.prototype.h=function(){return!0};ye.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:ln(function(){var o;(o=t.W)==null||o.call(t)}))};ye.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&&ln(function(){var a;(a=t.Z)==null||a.call(t)}))}};ye.prototype.subscribe=function(e){var t=this;return ot(function(){var n=t.value;ln(function(){return e(n)})},{name:"sub"})};ye.prototype.valueOf=function(){return this.value};ye.prototype.toString=function(){return this.value+""};ye.prototype.toJSON=function(){return this.value};ye.prototype.peek=function(){var e=this;return ln(function(){return e.value})};Object.defineProperty(ye.prototype,"value",{get:function(){var e=Yi(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(no>100)throw new Error("Cycle detected");(function(n){nt!==0&&no===0&&n.l!==Nr&&(n.l=Nr,oo={S:n,v:n.v,i:n.i,o:oo})})(this),this.v=e,this.i++,ro++,nt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{ao()}}}});function H(e,t){return new ye(e,t)}function Ji(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 Qi(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 Zi(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 vt(e,t){ye.call(this,void 0,t),this.x=e,this.s=void 0,this.g=ro-1,this.f=4}vt.prototype=new ye;vt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ro))return!0;if(this.g=ro,this.f|=1,this.i>0&&!Ji(this))return this.f&=-2,!0;var e=de;try{Qi(this),de=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 de=e,Zi(this),this.f&=-2,!0};vt.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)}ye.prototype.S.call(this,e)};vt.prototype.U=function(e){if(this.t!==void 0&&(ye.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)}};vt.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(vt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Yi(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function cn(e,t){return new vt(e,t)}function es(e){var t=e.m;if(e.m=void 0,typeof t=="function"){nt++;var n=de;de=void 0;try{t()}catch(o){throw e.f&=-2,e.f|=8,Dr(e),o}finally{de=n,ao()}}}function Dr(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,es(e)}function u_(e){if(de!==this)throw new Error("Out-of-order effect");Zi(this),de=e,this.f&=-2,8&this.f&&Dr(this),ao()}function Ft(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Xi&&Xi.push(this)}Ft.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()}};Ft.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,es(this),Qi(this),nt++;var e=de;return de=this,u_.bind(this,e)};Ft.prototype.N=function(){2&this.f||(this.f|=2,this.u=sn,sn=this)};Ft.prototype.d=function(){this.f|=8,1&this.f||Dr(this)};Ft.prototype.dispose=function(){this.d()};function ot(e,t){var n=new Ft(e,t);try{n.c()}catch(a){throw n.d(),a}var o=n.d.bind(n);return o[Symbol.dispose]=o,o}var ts,lo,io,p_=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var ns=[];ot(function(){ts=this.N})();function Bt(e,t){Z[e]=t.bind(null,Z[e]||function(){})}function so(e){if(io){var t=io;io=void 0,t()}io=e&&e.S()}function os(e){var t=this,n=e.data,o=dn(n);o.value=n;var a=Le(function(){for(var s=t,c=t.__v;c=c.__;)if(c.__c){c.__c.__$f|=4;break}var _=cn(function(){var f=o.value.value;return f===0?0:f===!0?"":f||""}),p=cn(function(){return!Array.isArray(_.value)&&!mr(_.value)}),g=ot(function(){if(this.N=rs,p.value){var f=_.value;s.__v&&s.__v.__e&&s.__v.__e.nodeType===3&&(s.__v.__e.data=f)}}),d=t.__$u.d;return t.__$u.d=function(){g(),d.call(this)},[p,_]},[]),i=a[0],l=a[1];return i.value?l.peek():l.value}os.displayName="ReactiveTextNode";Object.defineProperties(ye.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:os},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}});Bt("__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 ye&&(n||(t.__np=n={}),n[a]=i,o[a]=i.peek())}}e(t)});Bt("__r",function(e,t){if(e(t),t.type!==ie){so();var n,o=t.__c;o&&(o.__$f&=-2,(n=o.__$u)===void 0&&(o.__$u=n=(function(a,i){var l;return ot(function(){l=this},{name:i}),l.c=a,l})(function(){var a;p_&&((a=n.y)==null||a.call(n)),o.__$f|=1,o.setState({})},typeof t.type=="function"?t.type.displayName||t.type.name:""))),lo=o,so(n)}});Bt("__e",function(e,t,n,o){so(),lo=void 0,e(t,n,o)});Bt("diffed",function(e,t){so(),lo=void 0;var n;if(typeof t.type=="string"&&(n=t.__e)){var o=t.__np,a=t.props;if(o){var i=n.U;if(i)for(var l in i){var s=i[l];s!==void 0&&!(l in o)&&(s.d(),i[l]=void 0)}else i={},n.U=i;for(var c in o){var _=i[c],p=o[c];_===void 0?(_=m_(n,c,p,a),i[c]=_):_.o(p,a)}}}e(t)});function m_(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:ot(function(){this.N=rs;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))})}}Bt("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)});Bt("__h",function(e,t,n,o){(o<3||o===9)&&(t.__$f|=2),e(t,n,o)});lt.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 dn(e,t){return Le(function(){return H(e,t)},[])}function j(e,t){var n=D(e);return n.current=e,lo.__$f|=4,Le(function(){return cn(function(){return n.current()},t)},[])}var f_=function(e){queueMicrotask(function(){queueMicrotask(e)})};function g_(){$t(function(){for(var e;e=ns.shift();)ts.call(e)})}function rs(){ns.push(this)===1&&(Z.requestAnimationFrame||f_)(g_)}function as(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function is(e){return as(e)}function ss(e){return!(!as(e)||e.navigation!==void 0&&!Array.isArray(e.navigation)||e.linkCards!==void 0&&!Array.isArray(e.linkCards))}function h_(e){return`${y.cssPrefix}:${e}`}function ls(e,t){let o=Object.entries(t).map(([a,i])=>{let l=h_(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 co(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 v_=900;function Or(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??v_;return n>=a?"expanded":"normal"}return"normal"}function _n(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:Or(e.mode,e.size,t);return{panelOpen:i,panelSize:s}}function Ht(){return typeof window>"u"?0:window.innerWidth}var b_="x-public-key",P_="x-ai-agent-deployment-id";function cs(e){return{headers(){let t={};return e.aiAgentDeploymentId&&(t[P_]=e.aiAgentDeploymentId),e.publicKey&&(t[e.publicKeyHeader??b_]=e.publicKey),t}}}var _o="0.61.1";var We=class extends Error{constructor(n,o,a,i){super(n);K(this,"code",o);K(this,"status",a);K(this,"cause",i);this.name="StreamError"}};var ds=Q.scope("parser");async function*$r(e,t){if(!e.ok){let a=await e.text().catch(()=>"");throw new We(`server responded ${e.status}: ${a.slice(0,200)}`,"server",e.status)}if(!e.body)throw new We("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();if(s){let c=_s(s);c&&(yield c)}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);let c=_s(s);c&&(yield c)}}}finally{n.releaseLock()}}function _s(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||t==="[DONE]")return null;try{let o=JSON.parse(t);return ds.trace("chunk",{type:o.type,eventId:n}),{chunk:o,eventId:n}}catch(o){return ds.trace("frame parse failed",{err:o,payload:t.slice(0,200)}),null}}function y_(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 us=e=>e&&Object.keys(e).length>0?e:void 0;function ps(e,t){let n=us(e),o=us(t);if(!n&&!o)return;let a={};return n&&(a.user=n),o&&(a.page=o),y_(JSON.stringify(a))}function uo(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function x_(e){return`tool-${e.startsWith("tool:")?e.slice(5):e}`}function ms(e){return e.startsWith("tool-")?e.slice(5):e}var $e={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",bootstrap:"/pai/bootstrap",content:"/pai/content",submitForm:"/pai/submit-form"},fs="context";function po(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 gs(e){let t=e.messages.map(i=>({id:i.serverMessageId??i.id,parts:w_(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(k_).filter(i=>i!==null);return a?.length&&(n.data={tools:a}),n}function S_(e){return e.state==="output-available"||e.state==="output-error"||e.state==="output-denied"||e.approval?.approved!==void 0}function k_(e){return typeof e=="string"?e?{code:e}:null:e?.code?e:null}function w_(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"&&S_(n)){let o={type:x_(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 X=Q.scope("transport"),hs=3,ys=400,C_=5e3,T_=6e4,vs=1e4,bs=3,E_=new Set([408,425,429,500,502,503,504]);function Ps(e){return ys*2**e+Math.floor(Math.random()*250)}function R_(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 A_(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!n||n.role!=="assistant")continue;let o=n.parts.find(a=>a.type==="data-suggestions");return o?.type==="data-suggestions"?po(o.data):void 0}}function Fr(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 mo=class{constructor(t){K(this,"opts",t);K(this,"visitorId");K(this,"conversationId");K(this,"resumeStatus");K(this,"userContext");K(this,"pageContext");K(this,"locale");K(this,"conversationsCache",new Map);K(this,"contentCache",new Map)}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:_o};this.visitorId&&(t.visitorId=this.visitorId),this.conversationId&&(t.conversationId=this.conversationId),this.locale&&(t.locale=this.locale);let n=ps(this.userContext,this.pageContext);return n&&(t[fs]=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){X.debug("handshake \u2192",{visitorId:t.visitorId,conversationId:t.conversationId,locale:t.locale});let n=await this.postJson($e.handshake,t,"handshake");return X.debug("handshake \u2190",{visitorId:n.visitorId,conversationId:n.conversationId,hasWelcome:!!n.welcome,hasConfig:!!n.config,rebind:n.rebind}),L_(n)||X.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){X.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 X.debug("uploadFile \u2190",{id:o.id,url:o.url}),o}async transcribe(t,n="audio/webm"){X.debug("transcribe \u2192",{size:t.size,mimeType:n});let o=new FormData;o.append("audio",t,`voice.${I_(n)}`),o.append("mimeType",n);let a=await this.postForm(this.transcribePath,o,"transcribe");return X.debug("transcribe \u2190",{textLen:a.text.length}),a}conversationsKey(t){return`${this.locale??""}|${JSON.stringify(t,Object.keys(t).toSorted())}`}peekConversations(t={}){let n=this.conversationsCache.get(this.conversationsKey(t));if(n?.value&&Date.now()-n.at<vs)return n.value}listConversations(t={}){let n=this.conversationsKey(t),o=this.conversationsCache.get(n);if(o&&Date.now()-o.at<vs)return X.debug("listConversations \u2192 cache",t),o.result;let a={at:Date.now(),result:this.fetchConversations(t).then(i=>(a.value=i,i)).catch(i=>{throw this.conversationsCache.delete(n),i})};return this.conversationsCache.set(n,a),a.result}async fetchConversations(t){let n=new URL(this.url($e.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),X.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 X.debug("listConversations \u2190",{count:a.length,nextCursor:o.nextCursor}),{conversations:a.map(i=>({conversationId:i.conversationId,title:i.title,lastMessageAt:i.lastMessageAt,preview:i.preview,canContinue:i.canContinue,hasUnread:i.hasUnread})),nextCursor:o.nextCursor}}async loadConversation(t){let n=new URL(this.url($e.listMessages));n.searchParams.set("conversationId",t),X.debug("loadConversation \u2192",{conversationId:t,visitorId:this.visitorId});let o=await this.getJson(n.toString(),"loadConversation"),a=o.messages??[];return X.debug("loadConversation \u2190",{conversationId:o.conversationId,canContinue:o.canContinue,messageCount:a.length,hasSuggestions:!!o.suggestions}),{conversationId:o.conversationId,canContinue:o.canContinue??!0,messages:a,agent:o.agent,suggestions:A_(a)??o.suggestions}}async markRead(t){if(!(!this.visitorId||!t)){this.conversationsCache.clear(),X.debug("markRead \u2192",{conversationId:t,visitorId:this.visitorId});try{await this.postJson($e.markRead,{conversationId:t},"markRead")}catch(n){X.debug("markRead failed (non-fatal)",{err:n})}}}listContent(t={}){let n=`${this.locale??""}|${JSON.stringify(t,Object.keys(t).toSorted())}`,o=this.contentCache.get(n);if(o&&Date.now()-o.at<T_)return X.debug("listContent \u2192 cache",t),o.result;let a=this.fetchContent(t).catch(i=>{throw this.contentCache.delete(n),i});return this.contentCache.set(n,{at:Date.now(),result:a}),a}async fetchContent(t){let n=new URL(this.dataUrl($e.content));for(let[i,l]of Object.entries(t))l!==void 0&&n.searchParams.set(i,Array.isArray(l)?l.join(","):String(l));X.debug("listContent \u2192",t);let o=await this.getJson(n.toString(),"listContent"),a=(o.items??[]).map(i=>ei(i,this.locale));return X.debug("listContent \u2190",{count:a.length,total:o.pagination?.total}),{...o,items:a}}async bootstrap(t){let n=new URL(this.dataUrl($e.bootstrap));t&&n.searchParams.set("conversationId",t),X.debug("bootstrap \u2192",{conversationId:t??this.conversationId});let o=await this.getJson(n.toString(),"bootstrap"),a=o.forms??[],i=o.formSubmissions??[];return X.debug("bootstrap \u2190",{forms:a.length,formSubmissions:i.length}),{forms:a,formSubmissions:i}}async saveUserPrefs(t){X.debug("saveUserPrefs \u2192",{visitorId:this.visitorId,conversationId:this.conversationId,settingsKeys:Object.keys(t)});let n=await this.postJson($e.updateSettings,{userPrefs:t},"saveUserPrefs");return X.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??$e.submitForm}async submitForm(t){X.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){X.debug("submitForm failed (non-fatal)",{err:n})}}async submitFeedback(t){X.debug("submitFeedback \u2192",{messageId:t.messageId,value:t.value});try{await this.postJson($e.messageFeedback,{messageId:t.messageId,set:{feedback:t.value}},"submitFeedback")}catch(n){X.debug("submitFeedback failed (non-fatal)",{err:n})}}sendMessage(t){this.conversationsCache.clear(),X.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}}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<=hs&&!t.signal.aborted;a++){if((!o||a>1)&&(await Fr(ys*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;X.debug("resume fetch failed \u2014 retrying",{attempt:a,err:c});continue}if(i.status===204||!i.ok){X.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(X.debug("resume \u2192 no live stream (status response)",{status:c,attempt:a}),c==="pending"&&a<hs)continue;this.resumeStatus=c==="needs-generation"?"needs-generation":"completed";return}this.resumeStatus="live";let s=n.size;if(yield*this.drain($r(i,t.signal),n,t))return;if(n.size===s){X.debug("resume \u2192 stream closed with no new events; nothing to resume");return}}if(!t.signal.aborted)throw new We("stream incomplete after resume attempts","server")}async*drain(t,n,o){let a=!1,i;try{for await(let l of t){if(o.signal.aborted)return!0;if(l.eventId){if(n.has(l.eventId))continue;n.add(l.eventId)}yield l,(l.chunk.type==="finish"||l.chunk.type==="error")&&(a=!0,i??(i=setTimeout(()=>o.abort(),C_)))}}catch(l){if(o.signal.aborted)return!0;if(l instanceof We&&l.status!==void 0)throw l;X.debug("stream segment dropped",{err:l})}finally{i&&clearTimeout(i)}return a}cancelStream(t,n){t.signal.aborted||(X.debug("cancel stream",{conversationId:n,visitorId:this.visitorId}),t.abort(),!(!this.visitorId||!n)&&this.fetchImpl(this.url($e.cancelStream),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope({})),keepalive:!0}).catch(o=>X.debug("cancel POST failed (non-fatal)",{err:o})))}async*openMessageStream(t,n){let o=await this.fetchImpl(this.url($e.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*$r(o,n)}resumeUrl(t){let n=new URL(this.withEnvelopeQuery($e.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>=bs)throw new We(`${n} failed: network error`,"network",void 0,c);X.debug("request network error \u2014 retrying",{label:n,attempt:o}),await Fr(Ps(o));continue}if(l.ok||!E_.has(l.status)||o>=bs)return l;let s=R_(l.headers)??Ps(o);X.debug("request retryable status \u2014 retrying",{label:n,status:l.status,attempt:o,wait:s}),await Fr(s)}}async assertOk(t,n){if(!t.ok)throw new We(`${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 I_(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 L_(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.visitorId=="string"&&typeof t.conversationId=="string"}function xs(e,t){let n=e?[{kind:"text",id:"t0",textSig:H(e),doneSig:H(!0)}]:[];return{id:Ve(),role:"user",createdAt:Date.now(),status:"complete",attachments:t,partsSig:H(n)}}function un(){return{id:Ve(),role:"assistant",createdAt:Date.now(),status:"streaming",partsSig:H([])}}function Ss(e){let t=Ve();return M_({id:t,role:e.role,createdAt:Date.now(),status:"complete",ephemeral:!0,parts:[{kind:"text",id:`${t}-t0`,text:e.text,done:!0}]})}function M_(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(F_))}}function N_(e){let t=e.parts.map((n,o)=>n.type==="text"?{kind:"text",id:`${e.id}-t${o}`,textSig:H(n.text),doneSig:H(!0)}:n.type==="reasoning"?{kind:"reasoning",id:`${e.id}-r${o}`,textSig:H(n.text),doneSig:H(n.state!=="streaming")}:n.type==="step-start"?{kind:"step-start",id:`${e.id}-ss${o}`}:n.type==="file"?{kind:"file",url:n.url,mediaType:n.mediaType}:n.type==="source-url"?{kind:"source",sourceId:n.sourceId,url:n.url,title:n.title}:n.type==="source-document"?{kind:"source",sourceId:n.sourceId,title:n.title,filename:n.filename,mediaType:n.mediaType}:n.type==="data-suggestions"?null:n.type.startsWith("tool-")?{kind:"tool",toolCallId:n.toolCallId,toolName:ms(n.type),inputPartialSig:H(""),inputSig:H(n.input),outputSig:H(n.output),errorSig:H(n.errorText),stateSig:H(n.state),approvalSig:H(n.approval)}:null).filter(n=>n!==null);return{id:e.id,role:e.role,serverMessageId:e.id,createdAt:uo(e.createdAt)??Date.now(),status:e.status==="failed"?"error":"complete",canceled:e.status==="canceled",feedback:e.feedback??null,partsSig:H(t)}}var D_=new Set(["completed","failed","canceled"]);function O_(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 $_(e){return e.role==="assistant"&&e.status!=null&&!D_.has(e.status)&&O_(e)}function Hr(e){return e.filter(t=>!$_(t)).map(N_)}function ks(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(B_)}}function fo(e){let t="";for(let n of e.partsSig.value)n.kind==="text"&&(t+=n.textSig.value);return t}function go(e){return fo(e).trim()!==""?!1:!e.partsSig.value.some(t=>t.kind==="tool"||t.kind==="file"||t.kind==="source")}function rt(e){return e.role==="assistant"&&e.status!=="streaming"&&go(e)}function ws(e){return e.canceled===!0&&rt(e)}function F_(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 B_(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 Cs=Q.scope("reducer"),ho=class{constructor(t){K(this,"messagesSig",t);K(this,"active",null);K(this,"openTextParts",new Map);K(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":Cs.debug("finish",{reason:t.finishReason,canContinue:t.canContinue}),n.status="complete",t.finishReason&&(n.finishReason=t.finishReason),this.bumpDone(n);return;case"error":Cs.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":H_(n,t);return;case"file":pn(n,{kind:"file",url:t.url,mediaType:t.mediaType});return;case"source-url":Ts(n,{kind:"source",sourceId:t.sourceId,url:t.url,title:t.title});return;case"source-document":Ts(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":return;default:{let o=t}}}bumpDone(t){t.partsSig.value=[...t.partsSig.value],this.messagesSig.value=[...this.messagesSig.value]}};function bt(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 Ts(e,t){e.partsSig.value.some(n=>n.kind==="source"&&n.sourceId===t.sourceId)||pn(e,t)}function H_(e,t){switch(t.type){case"tool-input-start":bt(e,t.toolCallId,t.toolName);return;case"tool-input-delta":{let n=bt(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case"tool-input-available":{let n=bt(e,t.toolCallId,t.toolName);n.inputSig.value=t.input,n.stateSig.value="input-available";return}case"tool-approval-request":{let n=bt(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value="approval-requested";return}case"tool-output-available":{let n=bt(e,t.toolCallId);n.outputSig.value=t.output,n.stateSig.value="output-available";return}case"tool-output-error":{let n=bt(e,t.toolCallId);n.errorSig.value=t.errorText,n.stateSig.value="output-error";return}case"tool-output-denied":{let n=bt(e,t.toolCallId);n.stateSig.value="output-denied";return}default:return}}var Es=Q.scope("feedback:audio"),vo=class{constructor(){K(this,"ctx",null);K(this,"master",null);K(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){Es.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=>(Es.warn("audio fetch/decode failed",{url:t,err:i}),this.buffers.delete(t),null));return this.buffers.set(t,a),a}};var Rs={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},As={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 dt=null,bo=0;function z_(){return typeof navigator<"u"&&typeof navigator.vibrate=="function"}function U_(){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=`__${y.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 Is(e){if(!(e===0||Array.isArray(e)&&e.every(t=>t===0))){if(z_())try{navigator.vibrate(e);return}catch{}if(dt||(dt=U_()),!!dt)try{dt.label.click()}catch{}}}function Ls(){bo++;let e=!1;return()=>{e||(e=!0,bo=Math.max(0,bo-1),bo===0&&dt&&(dt.input.remove(),dt.label.remove(),dt=null))}}var q_=Q.scope("feedback"),V_=100,Po=class{constructor(t,n){K(this,"mutedSig",H(!1));K(this,"audio",new vo);K(this,"releaseHaptics");K(this,"sound");K(this,"haptics");K(this,"lastPlayed",new Map);K(this,"reducedMotionMq",null);this.sound=t,this.haptics=n,this.releaseHaptics=Ls(),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<V_}playSound(t){let n=this.sound.events?.[t];if(n===!1)return;if(typeof n=="string"){this.audio.playUrl(n).catch(a=>q_.warn("audio play failed",{err:a,url:n}));return}let o=As[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?Rs[t]:n;Is(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 Pt(e,t){return e instanceof We&&e.status===429?t.errorRateLimited:t.errorGeneric}var W_=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:--W_,__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 Z.vnode&&Z.vnode(_),_}var F={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24"},mn=`${y.cssPrefix}-icon-dir`,zr=()=>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"})}),Qe=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M18 6 6 18M6 6l12 12"})}),Ms=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M12 5v14M5 12h14"})}),Ns=()=>r("svg",{...F,class:mn,"aria-hidden":"true",children:[r("path",{d:"m22 2-7 20-4-9-9-4Z"}),r("path",{d:"M22 2 11 13"})]}),Ds=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M12 19V5M5 12l7-7 7 7"})}),Os=()=>r("svg",{...F,class:mn,"aria-hidden":"true",children:r("path",{d:"M3 20V4l18 8-18 8Z"})}),zt=()=>r("svg",{...F,class:mn,"aria-hidden":"true",children:r("path",{d:"m9 18 6-6-6-6"})}),$s=()=>r("svg",{...F,"aria-hidden":"true",children:r("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}),Fs=()=>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"})}),Bs=()=>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"})]}),Hs=()=>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"})}),Us=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z"})}),qs=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7"})}),Vs=()=>r("svg",{...F,"aria-hidden":"true",viewBox:"0 0 10 10",children:r("path",{d:"M9 1L1 9M9 5L5 9M9 9H9",strokeWidth:"1.5"})}),Ws=()=>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"})]}),Gs=()=>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"})}),Ks=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6"})}),js=()=>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"})]}),Xs=()=>r("svg",{...F,class:mn,"aria-hidden":"true",children:r("path",{d:"m5 6 6 6-6 6M13 6l6 6-6 6"})}),yt=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M20 6 9 17l-5-5"})}),Ys=()=>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"})]}),Js=()=>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"})]}),fn=()=>r("svg",{...F,class:mn,"aria-hidden":"true",children:r("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),Qs=()=>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"})]}),xt=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"m6 9 6 6 6-6"})}),Zs=()=>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"})]}),G_=()=>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"})]}),Ur=()=>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"})}),gn=()=>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"})]}),K_=()=>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"})]}),j_=()=>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"})]}),X_=()=>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"})]}),Y_=()=>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"})]}),qr=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"11",cy:"11",r:"7"}),r("path",{d:"m21 21-4.3-4.3"})]}),el=()=>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"})]}),tl=()=>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"})]}),nl=()=>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"})]}),hn=()=>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"})]}),ol=()=>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"})]}),rl=()=>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"})}),al=()=>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"})]}),J_=()=>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"})]}),Q_=()=>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"})]}),Z_=()=>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"})]}),eu=()=>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"})]}),il=()=>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"})]}),sl=()=>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"})]}),ll=()=>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"})]}),cl=()=>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"})]}),dl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"M12 7v5l3 2"})]}),yo=()=>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"})]}),xo=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"m15 9-6 6M9 9l6 6"})]}),_l={chat:zr,message:Ur,bubbles:hn,spark:G_,wand:K_,bot:j_,help:gn,lifebuoy:Y_,headset:X_,search:J_,sparkles:Q_,concierge:Z_,wave:eu};var M=y.cssPrefix,S={launcher:`${M}-launcher`,callout:`${M}-callout`,calloutDismiss:`${M}-callout-dismiss`,panel:`${M}-panel`,panelHeader:`${M}-panel-header`,resizeGrip:`${M}-resize-grip`,scrollToBottom:`${M}-scroll-to-bottom`,actionHistory:`${M}-action-history`,actionClose:`${M}-action-close`,langSegment:`${M}-lang-segment`,composer:`${M}-composer`,composerInput:`${M}-composer-input`,composerSend:`${M}-composer-send`,composerStop:`${M}-composer-stop`,composerAttach:`${M}-composer-attach`,composerFileInput:`${M}-composer-file-input`,composerVoice:`${M}-composer-voice`,attachmentChip:`${M}-attachment-chip`,attachmentRemove:`${M}-attachment-remove`,suggestion:`${M}-suggestion`,messageBubble:`${M}-message`,messageRetry:`${M}-message-retry`,messageFeedback:`${M}-message-feedback`,feedbackUp:`${M}-feedback-up`,feedbackDown:`${M}-feedback-down`,messageCopy:`${M}-message-copy`,historyPane:`${M}-history-pane`,historyBack:`${M}-history-back`,historyItem:`${M}-history-item`,sidebar:`${M}-sidebar`,sidebarToggle:`${M}-sidebar-toggle`,sidebarNewConversation:`${M}-sidebar-new-conversation`,sidebarItem:`${M}-sidebar-item`,messengerHome:`${M}-messenger-home`,modulesEmpty:`${M}-modules-empty`,tab:`${M}-tab`,tabBadge:`${M}-tab-badge`,homeView:`${M}-home-view`,homeGreeting:`${M}-home-greeting`,homeBrand:`${M}-home-brand`,backHeader:`${M}-back-header`,contentView:`${M}-content-view`,contentScroll:`${M}-content-scroll`,homeSearch:`${M}-home-search`,helpSearch:`${M}-help-search`,homeRecent:`${M}-home-recent`,homeContentRow:`${M}-home-content-row`,helpArticle:`${M}-help-article`,newsItem:`${M}-news-item`,formGate:`${M}-form-gate`,formDone:`${M}-form-done`,formDoneToggle:`${M}-form-done-toggle`,formAnswers:`${M}-form-answers`,formFill:`${M}-form-fill`,formSubmit:`${M}-form-submit`,formSkip:`${M}-form-skip`,formField:`${M}-form-field`,toolAskQuestions:`${M}-tool-ask-questions`,toolInputSubmit:`${M}-tool-input-submit`,toolInputSkip:`${M}-tool-input-skip`,toolApproval:`${M}-tool-approval`,toolApprove:`${M}-tool-approve`,toolReject:`${M}-tool-reject`,toolEdit:`${M}-tool-edit`,toolDecision:`${M}-tool-decision`,toolAskSummary:`${M}-ask-questions-summary`,toolAskOptions:`${M}-ask-questions-options-toggle`,toolCall:`${M}-tool-call`,source:`${M}-source`};function xe(e,t){return`${e}-${t}`}var So=y.cssPrefix;function ul({onToggle:e,launcher:t,strings:n,leaving:o,edgeTab:a}){let i=t.variant!=="circle"&&!!t.label;return r("button",{type:"button",class:`${So}-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:[tu(t.icon),i?r("span",{class:`${So}-fab-label`,children:Ie(n,t.label??"")}):null]})}function tu(e){let t=_l[e];return t?r(t,{}):r(nu,{source:e})}function nu({source:e}){return r("span",{ref:t=>{t&&ou(t,e)},"aria-hidden":"true"})}function ou(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 pl({callout:e,launcherPosition:t,strings:n,closeLabel:o,onDismiss:a}){let[i,l]=I(!1);return A(()=>{let s=setTimeout(()=>l(!0),e.delayMs);return()=>clearTimeout(s)},[e.delayMs]),A(()=>{if(!i||e.autoDismissMs<=0)return;let s=setTimeout(a,e.autoDismissMs);return()=>clearTimeout(s)},[i,e.autoDismissMs,a]),i?r("div",{class:`${So}-callout`,role:"status","data-shape":e.shape,"data-position":ru(e.position,t),"data-animated":e.animated?"true":void 0,"data-testid":S.callout,children:[r("span",{children:Ie(n,e.text)}),r("button",{type:"button",class:`${So}-callout-close`,onClick:a,"aria-label":o,title:o,"data-testid":S.calloutDismiss,children:r(Qe,{})})]}):null}function ru(e,t){let n=t.endsWith("-right"),o=t.startsWith("bottom-");return e==="vertical"?o?"top":"bottom":n?"left":"right"}function ko({panelEl:e,resize:t,position:n,initialSize:o,onSizeChange:a,strings:i}){let l=y.cssPrefix,s=D(null);if(A(()=>{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"}`,g=m=>{if(!e)return;let k=m.currentTarget,v=e.getBoundingClientRect();s.current={pointerId:m.pointerId,startX:m.clientX,startY:m.clientY,startW:v.width,startH:v.height,dirX:_?-1:1,dirY:c?1:-1},k.setPointerCapture(m.pointerId),e.setAttribute("data-resizing",""),m.preventDefault()},d=m=>{let k=s.current;if(!k||m.pointerId!==k.pointerId||!e)return;let v=(m.clientX-k.startX)*k.dirX,P=(m.clientY-k.startY)*k.dirY;e.style.setProperty(`--${l}-widget-w`,`${k.startW+v}px`),e.style.setProperty(`--${l}-widget-h`,`${k.startH+P}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 v=e.getBoundingClientRect();a({width:Math.round(v.width),height:Math.round(v.height)}),s.current=null};return r("div",{class:p,role:"separator","aria-orientation":"vertical","aria-label":i.resizeHandle,title:i.resizeHandle,onPointerDown:g,onPointerMove:d,onPointerUp:f,onPointerCancel:f,"data-testid":S.resizeGrip,children:r(Vs,{})})}var St=y.cssPrefix,au=`.${St}-header, .${St}-back-header, .${St}-home-hero`,iu='button, a, input, textarea, select, [role="tab"], [contenteditable]',ml=56;function wo(e,t){A(()=>{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(au)||_.closest(iu))return;let p=e.getBoundingClientRect();a={id:c.pointerId,x:c.clientX,y:c.clientY,dx:n(e.style.getPropertyValue(`--${St}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${St}-modal-dy`)),maxX:(window.innerWidth+p.width)/2-ml,maxY:(window.innerHeight+p.height)/2-ml},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(`--${St}-modal-dx`,`${_}px`),e.style.setProperty(`--${St}-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 vn(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 Co(e,t,n){return vn("close",e,t)?n.includes("close"):!1}function fl(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 To(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 Eo(e){return e.trim().split(/\s+/).slice(0,2).map(t=>t.charAt(0).toUpperCase()).join("")}var Vr=y.cssPrefix;function gl({agent:e,strings:t}){let n=e.status??"online",o=Ie(t,e.name),a=e.title?Ie(t,e.title):null;return r("div",{class:`${Vr}-agent`,children:[r("div",{class:`${Vr}-agent-avatar`,"data-status":n,children:e.avatar?r("img",{src:e.avatar,alt:""}):r("span",{children:Eo(o)})}),r("div",{class:`${Vr}-agent-meta`,children:[r("strong",{children:o}),a?r("span",{children:a}):null]})]})}var hl=Q.scope("attachments");function Ro(e,t,n){let o=cu(e),a=[],i=[],l=uu(n.accept),s=t.reduce((_,p)=>_+p.size,0),c=t.length;for(let _ of o){let p=lu(_,c,s,n,l);if(p){i.push({file:_,reason:p});continue}a.push(_u(_)),s+=_.size,c+=1}return(a.length||i.length)&&hl.debug("ingest",{accepted:a.length,rejected:i.map(_=>({name:_.file.name,reason:_.reason}))}),{accepted:a,rejected:i}}function Wr(e){try{URL.revokeObjectURL(e.previewUrl)}catch(t){hl.debug("revokeObjectURL failed",{error:t})}}function lu(e,t,n,o,a){return t>=o.maxCount?"count":n+e.size>o.maxBytes?"bytes":pu(e,a)?null:"mime"}function cu(e){return e?Array.isArray(e)?e.filter(t=>t instanceof File):[...e].map(t=>t instanceof File?t:du(t)).filter(t=>t!==null):[]}function du(e){let t=e;return!t?.getAsFile||t.kind!=="file"?null:t.getAsFile()}function _u(e){return{file:e,id:Ve(),mediaType:e.type||"application/octet-stream",name:e.name||"pasted-file",previewUrl:URL.createObjectURL(e),size:e.size}}function uu(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 pu(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 bn=y.cssPrefix;function vl({attachment:e,onRemove:t}){let n=e.mediaType.startsWith("image/");return r("span",{class:`${bn}-attachment-chip`,title:e.name,"data-testid":xe(S.attachmentChip,e.id),children:[n?r("img",{class:`${bn}-attachment-thumb`,src:e.previewUrl,alt:""}):r("span",{class:`${bn}-attachment-thumb`,"aria-hidden":"true",children:r(Zs,{})}),r("span",{class:`${bn}-attachment-name`,children:e.name}),r("button",{type:"button",class:`${bn}-attachment-remove`,onClick:t,"aria-label":`Remove ${e.name}`,"data-testid":xe(S.attachmentRemove,e.id),children:r(Qe,{})})]})}var Gr={isSupported:!1,start:()=>{},stop:()=>{}};function Kr(e,t,n){return e==="disabled"?Gr:e==="server"?hu(n):mu(t)}function mu(e){let t=fu();if(!t)return Gr;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 g=s.results[p];g&&(c+=g[0].transcript,g.isFinal&&(_=!0))}o(c,_)});let i=()=>{n=null,a()};n.addEventListener("end",i),n.addEventListener("error",i),n.start()},stop(){n?.stop()}}}function fu(){let e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition}var gu=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus","audio/mp4"];function hu(e){if(typeof MediaRecorder>"u"||!navigator?.mediaDevices?.getUserMedia)return Gr;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=vu();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 vu(){for(let e of gu)if(MediaRecorder.isTypeSupported(e))return e}var Fe=y.cssPrefix,kt=Q.scope("composer");function Ut(e){return e.reduce((t,n)=>t+n.size,0)}var bu={arrowUp:Ds,paperPlane:Ns,send:Os,chevron:zt};function bl({options:e,transport:t,feedback:n,bus:o,isStreaming:a,onSend:i,onStop:l,attachApiRef:s}){let c=e.strings,[_,p]=I(""),[g,d]=I([]),[f,m]=I(!1),k=D(null),v=D(null),P=e.features.fileUpload,w=e.features.voice,[b,E]=I(()=>Kr(w,e.locale,(C,B)=>t.transcribe(C,B)));A(()=>{f||w==="disabled"||E(Kr(w,e.locale,(C,B)=>t.transcribe(C,B)))},[e.locale,w,t,f]),A(()=>{let C=k.current;if(!C)return;let B=C.getRootNode(),J="activeElement"in B?B.activeElement:null;J&&C.closest(`.${Fe}-panel`)?.contains(J)||C.focus({preventScroll:!0})},[]),A(()=>{let C=k.current;if(!C)return;if(_.length===0){C.style.height="";return}C.style.height="auto";let B=parseFloat(getComputedStyle(C).fontSize)*.7,J=Math.min(C.scrollHeight,160);C.style.height=`${J<40+B?40:J}px`},[_]);let z=D(g);z.current=g,A(()=>()=>z.current.forEach(Wr),[]),A(()=>{if(s)return s.current={attachFromDrop:C=>{let B=Ro(C,z.current,e.attachments);B.accepted.length!==0&&(kt.info("attach (drop)",{count:B.accepted.length,totalBytes:Ut(B.accepted)}),o.emit("attach",{count:B.accepted.length,totalBytes:Ut(B.accepted)}),d(J=>[...J,...B.accepted]))}},()=>{s.current&&(s.current=null)}},[s,e.attachments]),A(()=>{let C=k.current;if(!C)return;let B=C.closest(`.${Fe}-panel`);if(!B)return;let J=Se=>{let He=Se.clipboardData;if(!He)return;let _e=Se.target?.closest?.("input, textarea, [contenteditable]:not([contenteditable='false'])");if(_e&&_e!==C)return;if(P){let ae=Ro(He.items,z.current,e.attachments);if(ae.accepted.length>0){Se.preventDefault(),kt.info("attach (paste)",{count:ae.accepted.length,totalBytes:Ut(ae.accepted)}),o.emit("attach",{count:ae.accepted.length,totalBytes:Ut(ae.accepted)}),d(ke=>[...ke,...ae.accepted]);return}}if(_e===C)return;let ze=He.getData("text/plain");ze&&(Se.preventDefault(),p(ae=>ae+ze),C.focus())};return B.addEventListener("paste",J),()=>B.removeEventListener("paste",J)},[P,e.attachments,Fe]);let te=()=>{let C=_.trim();!C&&g.length===0||a||(i(C,g),p(""),d([]))},ee=C=>{C.key!=="Enter"||C.shiftKey||C.isComposing||(C.preventDefault(),a?l():te())},Y=C=>{let B=C.target,J=Ro(B.files,g,e.attachments);J.accepted.length>0&&(kt.info("attach (file picker)",{count:J.accepted.length,totalBytes:Ut(J.accepted)}),o.emit("attach",{count:J.accepted.length,totalBytes:Ut(J.accepted)}),d(Se=>[...Se,...J.accepted])),B.value=""},oe=C=>{kt.info("removeAttachment",{id:C}),o.emit("removeAttachment",{id:C}),d(B=>{let J=B.find(Se=>Se.id===C);return J&&Wr(J),B.filter(Se=>Se.id!==C)})},T=D(null),N=()=>{if(b.isSupported){if(f){let C=T.current?Date.now()-T.current:0;kt.info("voiceStop",{durationMs:C}),o.emit("voiceStop",{durationMs:C}),b.stop(),m(!1),n.play("voiceStop"),T.current=null;return}T.current=Date.now(),kt.info("voiceStart"),o.emit("voiceStart",void 0),m(!0),n.play("voiceStart"),b.start((C,B)=>p(J=>B?`${J}${C} `:J),()=>{if(m(!1),T.current){let C=Date.now()-T.current;kt.debug("voiceStop (auto)",{durationMs:C}),o.emit("voiceStop",{durationMs:C}),T.current=null}})}},q=bu[e.composer.sendButton.icon];return r("div",{class:`${Fe}-composer`,"data-testid":S.composer,children:[g.length>0?r("div",{class:`${Fe}-attachments`,children:g.map(C=>r(vl,{attachment:C,onRemove:()=>oe(C.id)},C.id))}):null,r("div",{class:`${Fe}-composer-row`,children:[r("div",{class:`${Fe}-composer-actions`,children:[P?r("button",{type:"button",class:`${Fe}-icon-btn`,onClick:()=>v.current?.click(),"aria-label":c.attach,"data-testid":S.composerAttach,children:r(Fs,{})}):null,b.isSupported?r("button",{type:"button",class:`${Fe}-icon-btn`,onClick:N,"aria-label":f?c.micStop:c.micStart,"aria-pressed":f,"data-recording":f?"true":void 0,"data-testid":S.composerVoice,children:r(Bs,{})}):null]}),r("textarea",{ref:k,class:`${Fe}-textarea`,rows:1,value:_,placeholder:c.composerPlaceholder,onInput:C=>p(C.target.value),onKeyDown:ee,"aria-label":c.composerPlaceholder,"data-testid":S.composerInput}),a?r("button",{type:"button",class:`${Fe}-send`,onClick:l,"aria-label":c.stop,"data-testid":S.composerStop,children:r($s,{})}):r("button",{type:"button",class:`${Fe}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:te,disabled:!_.trim()&&g.length===0,"aria-label":c.send,"data-testid":S.composerSend,children:r(q,{})})]}),r("input",{ref:v,type:"file",multiple:!0,accept:e.attachments.accept,onChange:Y,class:`${Fe}-sr-only`,"data-testid":S.composerFileInput})]})}var Pu=y.cssPrefix;function Pl({visible:e,strings:t}){return e?r("div",{class:`${Pu}-dropzone`,role:"status","aria-live":"polite",children:t.dropZone}):null}function Ao({containerRef:e,onDrop:t}){let[n,o]=I(!1);return A(()=>{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 yl({itemCount:e,initialFocusIndex:t}){let[n,o]=I(!1),a=D(null),i=D(null),[l,s]=I(-1),c=$(()=>{o(!1),s(-1),a.current?.focus()},[]),_=$(()=>o(d=>!d),[]);A(()=>{if(!n)return;let d=f=>{let m=i.current,k=a.current;if(!m||!k)return;let v=f.composedPath();v.includes(m)||v.includes(k)||(o(!1),s(-1))};return document.addEventListener("click",d,!0),()=>document.removeEventListener("click",d,!0)},[n]),A(()=>{if(!n||e===0)return;let d=t?.()??0,f=d<0||d>=e?0:d;s(f)},[n,e,t]),A(()=>{if(!n||l<0)return;i.current?.querySelectorAll("[role='menuitem']")?.[l]?.focus()},[n,l]);let p=$(d=>{(d.key==="ArrowDown"||d.key==="Enter"||d.key===" ")&&(d.preventDefault(),o(!0))},[]),g=$(d=>{if(e!==0)switch(d.key){case"Escape":d.preventDefault(),c();return;case"ArrowDown":d.preventDefault(),s(f=>(f+1)%e);return;case"ArrowUp":d.preventDefault(),s(f=>(f-1+e)%e);return;case"Home":d.preventDefault(),s(0);return;case"End":d.preventDefault(),s(e-1)}},[e,c]);return{open:n,focusIndex:l,triggerRef:a,menuRef:i,toggle:_,close:c,onTriggerKey:p,onMenuKey:g}}function xl({items:e,triggerLabel:t}){let n=y.cssPrefix,o=yl({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(d=>d.value===c.value)),g=-1;if(s.key==="ArrowRight"||s.key==="Enter"||s.key===" ")g=(p+1)%_.length;else if(s.key==="ArrowLeft")g=(p-1+_.length)%_.length;else return;s.preventDefault(),s.stopPropagation(),i(c,_[g].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(Ws,{})}),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(yt,{})}):null]},s.id))}):null]})}var jr=y.cssPrefix;function yu(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 xu={normal:"large",large:"small",small:"normal"};function Su(e){return e==="light"?r(ol,{}):e==="dark"?r(rl,{}):r(al,{})}function ku(e){return(e.split("-")[0]??e).toUpperCase()}function Ze({panelProps:e,variant:t}){let{options:n,panelSize:o,feedback:a,onClose:i,onClear:l,onExpand:s,onFullscreen:c,onSoundToggle:_}=e,{onToggleHistory:p,onLocaleChange:g,onThemeChange:d,onTextSizeChange:f}=e,m=n.strings,k=n.mode,v=t==="chat",P=j(()=>a.mutedSig.value).value,w=new Set(n.actions),b=C=>w.has(C),E=typeof matchMedia=="function"&&matchMedia("(max-width: 640px)").matches,z=C=>E?!1:vn(C,k,o),te=n.themeMode,ee={auto:m.themeAuto,light:m.themeLight,dark:m.themeDark},Y=n.textSize,oe={small:m.textSizeSmall,normal:m.textSizeNormal,large:m.textSizeLarge},T=[];if(v&&b("clear")&&T.push({id:"clear",icon:r(Qs,{}),label:m.newConversation,onSelect:l}),b("expand")&&z("expand")){let C=o==="expanded";T.push({id:"expand",icon:C?r(zs,{}):r(Hs,{}),label:C?m.collapse:m.expand,type:"switch",on:C,onSelect:s})}if(b("fullscreen")&&z("fullscreen")){let C=o==="fullscreen";T.push({id:"fullscreen",icon:C?r(qs,{}):r(Us,{}),label:C?m.exitFullscreen:m.fullscreen,type:"switch",on:C,onSelect:c})}v&&b("sound")&&T.push({id:"sound",icon:P?r(Ks,{}):r(Gs,{}),label:P?m.soundOff:m.soundOn,type:"switch",on:!P,onSelect:_}),b("theme")&&T.push({id:"theme",icon:Su(te),label:`${m.theme}: ${ee[te]}`,onSelect:()=>d(yu(te)),keepOpen:!0}),b("textSize")&&T.push({id:"textSize",icon:r(js,{}),label:`${m.textSize}: ${oe[Y]}`,onSelect:()=>f(xu[Y]),keepOpen:!0}),b("language")&&n.availableLocales.length>1&&T.push({id:"language",icon:r(Js,{}),label:m.language,segments:n.availableLocales.map(C=>({value:C,label:ku(C),lang:C})),value:n.locale,onSelectValue:g});let N=!!i&&Co(k,o,n.actions),q=v&&b("history");return r("div",{class:`${jr}-header-actions`,children:[q?r("button",{type:"button",class:`${jr}-icon-btn`,onClick:p,"aria-label":m.history,title:m.history,"data-testid":S.actionHistory,children:r(Ys,{})}):null,T.length>0?r(xl,{items:T,triggerLabel:m.moreActions}):null,N?r("button",{type:"button",class:`${jr}-icon-btn`,onClick:i,"aria-label":m.close,title:m.close,"data-testid":S.actionClose,children:r(Qe,{})}):null]})}var wu=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Cu=/^https?:\/\/[^\s.]+\.[^\s]+$/i,Tu=/^[+]?[\d\s().-]{6,}$/;function qt(e,t){return e.replace(/\{(\w+)\}/g,(n,o)=>String(t[o]??`{${o}}`))}function Eu(e){return Array.isArray(e)?e.length:e&&e.trim()?1:0}function Ru(e,t,n){let o=e.required??!0,a=e.validation;if(e.type==="multiselect"){let l=Eu(t);return o&&l===0?n.formRequired:l===0?void 0:a?.minSelections!=null&&l<a.minSelections?qt(n.formChooseAtLeast,{min:a.minSelections}):a?.maxSelections!=null&&l>a.maxSelections?qt(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(!wu.test(i))return n.formInvalidEmail;break;case"url":if(!Cu.test(i))return n.formInvalidUrl;break;case"tel":if(!Tu.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 qt(n.formNumberTooSmall,{min:a.min});if(a?.max!=null&&l>a.max)return qt(n.formNumberTooLarge,{max:a.max});break}default:break}if(a?.minLength!=null&&i.length<a.minLength)return qt(n.formTooShort,{min:a.minLength});if(a?.maxLength!=null&&i.length>a.maxLength)return qt(n.formTooLong,{max:a.maxLength});if(a?.pattern)try{if(!new RegExp(a.pattern).test(i))return n.formPatternMismatch}catch{}}function Sl(e,t,n){let o={};for(let a of e){let i=Ru(a,t[a.name],n);i&&(o[a.name]=i)}return o}function kl(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 le=y.cssPrefix,Io="__other__";function Pn({fields:e,strings:t,submitLabel:n,onSubmit:o,skipLabel:a,onSkip:i,footerHint:l,submitOnEnter:s,disabled:c,initialValues:_,hideActions:p,fieldTypeLabels:g,rootTestId:d,submitTestId:f,skipTestId:m}){let[k,v]=I(()=>({...Mu(e),..._})),[P,w]=I({}),[b,E]=I({}),z=T=>{b[T]&&E(N=>({...N,[T]:""}))},te=(T,N)=>{v(q=>({...q,[T]:N})),z(T)},ee=(T,N)=>{w(q=>({...q,[T]:N})),z(T)},Y=T=>{if(T.preventDefault(),c)return;let N=Nu(e,k,P),q=Sl(e,N,t);if(Object.keys(q).length>0){E(q);return}o(kl(N))},oe=T=>{!s||T.key!=="Enter"||T.shiftKey||T.isComposing||T.target?.tagName==="TEXTAREA"&&Y(T)};return r("form",{class:`${le}-form`,onSubmit:Y,onKeyDown:oe,"data-testid":d,noValidate:!0,children:[e.map(T=>r(Au,{field:T,value:k[T.name],otherText:P[T.name]??"",error:b[T.name],disabled:c,typeLabel:g?.[T.name],strings:t,onChange:N=>te(T.name,N),onOtherChange:N=>ee(T.name,N)},T.name)),p?null:r("div",{class:`${le}-form-actions`,children:[l?r("span",{class:`${le}-form-hint`,children:l}):null,a&&i?r("button",{type:"button",class:`${le}-form-skip`,onClick:i,disabled:c,"data-testid":m,children:a}):null,r("button",{type:"submit",class:`${le}-form-submit`,disabled:c,"data-testid":f,children:n})]})]})}function Au({field:e,value:t,otherText:n,error:o,disabled:a,typeLabel:i,strings:l,onChange:s,onOtherChange:c}){let _=xe(S.formField,e.name),p=Iu({field:e,value:t,otherText:n,disabled:a,strings:l,onChange:s,onOtherChange:c,fieldTid:_});return r("label",{class:`${le}-field`,"data-field":e.name,"data-invalid":o?"true":void 0,children:[r("span",{class:`${le}-field-head`,children:[r("span",{class:`${le}-field-label`,children:[e.label,e.required??!0?r("span",{class:`${le}-field-req`,"aria-hidden":"true",children:" *"}):null]}),i?r("span",{class:`${le}-field-type`,children:i}):null]}),p,e.validationHint&&!o?r("span",{class:`${le}-field-hint`,children:e.validationHint}):null,o?r("span",{class:`${le}-field-error`,role:"alert",children:o}):null]})}function Iu(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:`${le}-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:`${le}-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&&_===Io;return r("div",{class:`${le}-field-choices`,role:"radiogroup","data-testid":c,children:[(t.options??[]).map(g=>r("label",{class:`${le}-choice`,children:[r("input",{type:"radio",name:`${le}-${t.name}`,checked:_===g.value,disabled:a,onChange:()=>l(g.value)}),r("span",{children:g.label??g.value})]},g.value)),t.allowOther?r("label",{class:`${le}-choice`,children:[r("input",{type:"radio",name:`${le}-${t.name}`,checked:_===Io,disabled:a,onChange:()=>l(Io)}),r("span",{children:i.formOther})]}):null,p?r("input",{class:`${le}-field-input`,value:o,placeholder:t.placeholder??i.formOtherPlaceholder,disabled:a,onInput:g=>s(g.target.value)}):null]})}case"checkbox":return r("label",{class:`${le}-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:[],g=(d,f)=>l(f?[...p,d]:p.filter(m=>m!==d));return r("div",{class:`${le}-field-choices`,"data-testid":c,children:[(t.options??[]).map(d=>r("label",{class:`${le}-choice`,children:[r("input",{type:"checkbox",checked:p.includes(d.value),disabled:a,onChange:f=>g(d.value,f.target.checked)}),r("span",{children:d.label??d.value})]},d.value)),t.allowOther||(t.options??[]).length===0?r("textarea",{class:`${le}-field-input`,rows:2,value:o,placeholder:t.placeholder??i.formOtherPlaceholder,disabled:a,onInput:d=>s(d.target.value)}):null]})}default:return r("input",{class:`${le}-field-input`,type:Lu(t.type),value:_,placeholder:t.placeholder,disabled:a,onInput:p=>l(p.target.value),"data-testid":c})}}function Lu(e){switch(e){case"number":case"email":case"tel":case"url":case"date":case"time":return e;default:return"text"}}function Mu(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 Nu(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]===Io)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 et=y.cssPrefix;function Xr({form:e,strings:t,onSubmit:n,onSkip:o}){return r("div",{class:`${et}-form-gate`,"data-testid":S.formGate,children:[e.title?r("h3",{class:`${et}-form-gate-title`,children:e.title}):null,e.description?r("p",{class:`${et}-form-gate-desc`,children:e.description}):null,r(Pn,{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 wl({marker:e,strings:t,onFill:n}){let o=e.outcome==="skipped",a=o?t.formSkipped:t.formSubmitted,i=e.title?r(ie,{children:[r("span",{children:e.title}),r("span",{class:`${et}-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:`${et}-form-done`,"data-outcome":e.outcome,"data-testid":S.formDone,children:[r("summary",{class:`${et}-form-done-summary`,"data-testid":S.formDoneToggle,children:[r(yt,{}),i,r(zt,{})]}),r("dl",{class:`${et}-form-answers`,"data-testid":S.formAnswers,children:Object.entries(s).map(([_,p])=>r("div",{class:`${et}-form-answer`,children:[r("dt",{children:c(_)}),r("dd",{children:p})]},_))})]})}return r("div",{class:`${et}-form-done`,"data-outcome":e.outcome,"data-testid":S.formDone,role:"status",children:[o?r(Xs,{}):r(yt,{}),i,o&&e.form?.reopenable&&n?r("button",{type:"button",class:`${et}-form-done-fill`,"data-testid":S.formFill,onClick:n,children:t.formFillOut}):null]})}function Cl(e){if(!e)return!1;let t=e.startsWith("tool:")?e.slice(5):e;return t==="ask-user-questions"||t==="ask_user_questions"}var Qr=1,El=2,Rl=4,Al=8,Il=16;function Du(e){switch(e){case Qr:return"href";case El:return"src";case Rl:return"class";case Al:return"checked";case Il:return"start"}}var Ou=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}},$u=Ou;var Tl=24;function ea(e){let t=new Uint32Array(Tl);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(Tl),indent:"",indent_len:0,table_state:0}}function Ll(e){e.pending.length>0&&Te(e,`
|
|
11
|
+
${a}`:a;continue}o.startsWith("id:")&&(n=o.slice(3).trim())}if(!t||t==="[DONE]")return null;try{let o=JSON.parse(t);return ds.trace("chunk",{type:o.type,eventId:n}),{chunk:o,eventId:n}}catch(o){return ds.trace("frame parse failed",{err:o,payload:t.slice(0,200)}),null}}function y_(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 us=e=>e&&Object.keys(e).length>0?e:void 0;function ps(e,t){let n=us(e),o=us(t);if(!n&&!o)return;let a={};return n&&(a.user=n),o&&(a.page=o),y_(JSON.stringify(a))}function uo(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function x_(e){return`tool-${e.startsWith("tool:")?e.slice(5):e}`}function ms(e){return e.startsWith("tool-")?e.slice(5):e}var $e={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",bootstrap:"/pai/bootstrap",content:"/pai/content",submitForm:"/pai/submit-form"},fs="context";function po(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 gs(e){let t=e.messages.map(i=>({id:i.serverMessageId??i.id,parts:w_(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(k_).filter(i=>i!==null);return a?.length&&(n.data={tools:a}),n}function S_(e){return e.state==="output-available"||e.state==="output-error"||e.state==="output-denied"||e.approval?.approved!==void 0}function k_(e){return typeof e=="string"?e?{code:e}:null:e?.code?e:null}function w_(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"&&S_(n)){let o={type:x_(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 X=Q.scope("transport"),hs=3,ys=400,C_=2e4,T_=6e4,vs=1e4,bs=3,E_=new Set([408,425,429,500,502,503,504]);function Ps(e){return ys*2**e+Math.floor(Math.random()*250)}function R_(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 A_(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!n||n.role!=="assistant")continue;let o=n.parts.find(a=>a.type==="data-suggestions");return o?.type==="data-suggestions"?po(o.data):void 0}}function Fr(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 mo=class{constructor(t){K(this,"opts",t);K(this,"visitorId");K(this,"conversationId");K(this,"resumeStatus");K(this,"userContext");K(this,"pageContext");K(this,"locale");K(this,"conversationsCache",new Map);K(this,"contentCache",new Map)}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:_o};this.visitorId&&(t.visitorId=this.visitorId),this.conversationId&&(t.conversationId=this.conversationId),this.locale&&(t.locale=this.locale);let n=ps(this.userContext,this.pageContext);return n&&(t[fs]=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){X.debug("handshake \u2192",{visitorId:t.visitorId,conversationId:t.conversationId,locale:t.locale});let n=await this.postJson($e.handshake,t,"handshake");return X.debug("handshake \u2190",{visitorId:n.visitorId,conversationId:n.conversationId,hasWelcome:!!n.welcome,hasConfig:!!n.config,rebind:n.rebind}),L_(n)||X.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){X.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 X.debug("uploadFile \u2190",{id:o.id,url:o.url}),o}async transcribe(t,n="audio/webm"){X.debug("transcribe \u2192",{size:t.size,mimeType:n});let o=new FormData;o.append("audio",t,`voice.${I_(n)}`),o.append("mimeType",n);let a=await this.postForm(this.transcribePath,o,"transcribe");return X.debug("transcribe \u2190",{textLen:a.text.length}),a}conversationsKey(t){return`${this.locale??""}|${JSON.stringify(t,Object.keys(t).toSorted())}`}peekConversations(t={}){let n=this.conversationsCache.get(this.conversationsKey(t));if(n?.value&&Date.now()-n.at<vs)return n.value}listConversations(t={}){let n=this.conversationsKey(t),o=this.conversationsCache.get(n);if(o&&Date.now()-o.at<vs)return X.debug("listConversations \u2192 cache",t),o.result;let a={at:Date.now(),result:this.fetchConversations(t).then(i=>(a.value=i,i)).catch(i=>{throw this.conversationsCache.delete(n),i})};return this.conversationsCache.set(n,a),a.result}async fetchConversations(t){let n=new URL(this.url($e.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),X.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 X.debug("listConversations \u2190",{count:a.length,nextCursor:o.nextCursor}),{conversations:a.map(i=>({conversationId:i.conversationId,title:i.title,lastMessageAt:i.lastMessageAt,preview:i.preview,canContinue:i.canContinue,hasUnread:i.hasUnread})),nextCursor:o.nextCursor}}async loadConversation(t){let n=new URL(this.url($e.listMessages));n.searchParams.set("conversationId",t),X.debug("loadConversation \u2192",{conversationId:t,visitorId:this.visitorId});let o=await this.getJson(n.toString(),"loadConversation"),a=o.messages??[];return X.debug("loadConversation \u2190",{conversationId:o.conversationId,canContinue:o.canContinue,messageCount:a.length,hasSuggestions:!!o.suggestions}),{conversationId:o.conversationId,canContinue:o.canContinue??!0,messages:a,agent:o.agent,suggestions:A_(a)??o.suggestions}}async markRead(t){if(!(!this.visitorId||!t)){this.conversationsCache.clear(),X.debug("markRead \u2192",{conversationId:t,visitorId:this.visitorId});try{await this.postJson($e.markRead,{conversationId:t},"markRead")}catch(n){X.debug("markRead failed (non-fatal)",{err:n})}}}listContent(t={}){let n=`${this.locale??""}|${JSON.stringify(t,Object.keys(t).toSorted())}`,o=this.contentCache.get(n);if(o&&Date.now()-o.at<T_)return X.debug("listContent \u2192 cache",t),o.result;let a=this.fetchContent(t).catch(i=>{throw this.contentCache.delete(n),i});return this.contentCache.set(n,{at:Date.now(),result:a}),a}async fetchContent(t){let n=new URL(this.dataUrl($e.content));for(let[i,l]of Object.entries(t))l!==void 0&&n.searchParams.set(i,Array.isArray(l)?l.join(","):String(l));X.debug("listContent \u2192",t);let o=await this.getJson(n.toString(),"listContent"),a=(o.items??[]).map(i=>ei(i,this.locale));return X.debug("listContent \u2190",{count:a.length,total:o.pagination?.total}),{...o,items:a}}async bootstrap(t){let n=new URL(this.dataUrl($e.bootstrap));t&&n.searchParams.set("conversationId",t),X.debug("bootstrap \u2192",{conversationId:t??this.conversationId});let o=await this.getJson(n.toString(),"bootstrap"),a=o.forms??[],i=o.formSubmissions??[];return X.debug("bootstrap \u2190",{forms:a.length,formSubmissions:i.length}),{forms:a,formSubmissions:i}}async saveUserPrefs(t){X.debug("saveUserPrefs \u2192",{visitorId:this.visitorId,conversationId:this.conversationId,settingsKeys:Object.keys(t)});let n=await this.postJson($e.updateSettings,{userPrefs:t},"saveUserPrefs");return X.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??$e.submitForm}async submitForm(t){X.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){X.debug("submitForm failed (non-fatal)",{err:n})}}async submitFeedback(t){X.debug("submitFeedback \u2192",{messageId:t.messageId,value:t.value});try{await this.postJson($e.messageFeedback,{messageId:t.messageId,set:{feedback:t.value}},"submitFeedback")}catch(n){X.debug("submitFeedback failed (non-fatal)",{err:n})}}sendMessage(t){this.conversationsCache.clear(),X.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}}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<=hs&&!t.signal.aborted;a++){if((!o||a>1)&&(await Fr(ys*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;X.debug("resume fetch failed \u2014 retrying",{attempt:a,err:c});continue}if(i.status===204||!i.ok){X.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(X.debug("resume \u2192 no live stream (status response)",{status:c,attempt:a}),c==="pending"&&a<hs)continue;this.resumeStatus=c==="needs-generation"?"needs-generation":"completed";return}this.resumeStatus="live";let s=n.size;if(yield*this.drain($r(i,t.signal),n,t))return;if(n.size===s){X.debug("resume \u2192 stream closed with no new events; nothing to resume");return}}if(!t.signal.aborted)throw new We("stream incomplete after resume attempts","server")}async*drain(t,n,o){let a=!1,i,l=()=>{i&&clearTimeout(i),i=setTimeout(()=>o.abort(),C_)};try{for await(let s of t){if(o.signal.aborted)return!0;if(s.eventId){if(n.has(s.eventId))continue;n.add(s.eventId)}yield s,(s.chunk.type==="finish"||s.chunk.type==="error")&&(a=!0),a&&l()}}catch(s){if(o.signal.aborted)return!0;if(s instanceof We&&s.status!==void 0)throw s;X.debug("stream segment dropped",{err:s})}finally{i&&clearTimeout(i)}return a}cancelStream(t,n){t.signal.aborted||(X.debug("cancel stream",{conversationId:n,visitorId:this.visitorId}),t.abort(),!(!this.visitorId||!n)&&this.fetchImpl(this.url($e.cancelStream),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope({})),keepalive:!0}).catch(o=>X.debug("cancel POST failed (non-fatal)",{err:o})))}async*openMessageStream(t,n){let o=await this.fetchImpl(this.url($e.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*$r(o,n)}resumeUrl(t){let n=new URL(this.withEnvelopeQuery($e.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>=bs)throw new We(`${n} failed: network error`,"network",void 0,c);X.debug("request network error \u2014 retrying",{label:n,attempt:o}),await Fr(Ps(o));continue}if(l.ok||!E_.has(l.status)||o>=bs)return l;let s=R_(l.headers)??Ps(o);X.debug("request retryable status \u2014 retrying",{label:n,status:l.status,attempt:o,wait:s}),await Fr(s)}}async assertOk(t,n){if(!t.ok)throw new We(`${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 I_(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 L_(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.visitorId=="string"&&typeof t.conversationId=="string"}function xs(e,t){let n=e?[{kind:"text",id:"t0",textSig:H(e),doneSig:H(!0)}]:[];return{id:Ve(),role:"user",createdAt:Date.now(),status:"complete",attachments:t,partsSig:H(n)}}function un(){return{id:Ve(),role:"assistant",createdAt:Date.now(),status:"streaming",partsSig:H([])}}function Ss(e){let t=Ve();return M_({id:t,role:e.role,createdAt:Date.now(),status:"complete",ephemeral:!0,parts:[{kind:"text",id:`${t}-t0`,text:e.text,done:!0}]})}function M_(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(F_))}}function N_(e){let t=e.parts.map((n,o)=>n.type==="text"?{kind:"text",id:`${e.id}-t${o}`,textSig:H(n.text),doneSig:H(!0)}:n.type==="reasoning"?{kind:"reasoning",id:`${e.id}-r${o}`,textSig:H(n.text),doneSig:H(n.state!=="streaming")}:n.type==="step-start"?{kind:"step-start",id:`${e.id}-ss${o}`}:n.type==="file"?{kind:"file",url:n.url,mediaType:n.mediaType}:n.type==="source-url"?{kind:"source",sourceId:n.sourceId,url:n.url,title:n.title}:n.type==="source-document"?{kind:"source",sourceId:n.sourceId,title:n.title,filename:n.filename,mediaType:n.mediaType}:n.type==="data-suggestions"?null:n.type.startsWith("tool-")?{kind:"tool",toolCallId:n.toolCallId,toolName:ms(n.type),inputPartialSig:H(""),inputSig:H(n.input),outputSig:H(n.output),errorSig:H(n.errorText),stateSig:H(n.state),approvalSig:H(n.approval)}:null).filter(n=>n!==null);return{id:e.id,role:e.role,serverMessageId:e.id,createdAt:uo(e.createdAt)??Date.now(),status:e.status==="failed"?"error":"complete",canceled:e.status==="canceled",feedback:e.feedback??null,partsSig:H(t)}}var D_=new Set(["completed","failed","canceled"]);function O_(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 $_(e){return e.role==="assistant"&&e.status!=null&&!D_.has(e.status)&&O_(e)}function Hr(e){return e.filter(t=>!$_(t)).map(N_)}function ks(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(B_)}}function fo(e){let t="";for(let n of e.partsSig.value)n.kind==="text"&&(t+=n.textSig.value);return t}function go(e){return fo(e).trim()!==""?!1:!e.partsSig.value.some(t=>t.kind==="tool"||t.kind==="file"||t.kind==="source")}function rt(e){return e.role==="assistant"&&e.status!=="streaming"&&go(e)}function ws(e){return e.canceled===!0&&rt(e)}function F_(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 B_(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 Cs=Q.scope("reducer"),ho=class{constructor(t){K(this,"messagesSig",t);K(this,"active",null);K(this,"openTextParts",new Map);K(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":Cs.debug("finish",{reason:t.finishReason,canContinue:t.canContinue}),n.status="complete",t.finishReason&&(n.finishReason=t.finishReason),this.bumpDone(n);return;case"error":Cs.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":H_(n,t);return;case"file":pn(n,{kind:"file",url:t.url,mediaType:t.mediaType});return;case"source-url":Ts(n,{kind:"source",sourceId:t.sourceId,url:t.url,title:t.title});return;case"source-document":Ts(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":return;default:{let o=t}}}bumpDone(t){t.partsSig.value=[...t.partsSig.value],this.messagesSig.value=[...this.messagesSig.value]}};function bt(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 Ts(e,t){e.partsSig.value.some(n=>n.kind==="source"&&n.sourceId===t.sourceId)||pn(e,t)}function H_(e,t){switch(t.type){case"tool-input-start":bt(e,t.toolCallId,t.toolName);return;case"tool-input-delta":{let n=bt(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case"tool-input-available":{let n=bt(e,t.toolCallId,t.toolName);n.inputSig.value=t.input,n.stateSig.value="input-available";return}case"tool-approval-request":{let n=bt(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value="approval-requested";return}case"tool-output-available":{let n=bt(e,t.toolCallId);n.outputSig.value=t.output,n.stateSig.value="output-available";return}case"tool-output-error":{let n=bt(e,t.toolCallId);n.errorSig.value=t.errorText,n.stateSig.value="output-error";return}case"tool-output-denied":{let n=bt(e,t.toolCallId);n.stateSig.value="output-denied";return}default:return}}var Es=Q.scope("feedback:audio"),vo=class{constructor(){K(this,"ctx",null);K(this,"master",null);K(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){Es.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=>(Es.warn("audio fetch/decode failed",{url:t,err:i}),this.buffers.delete(t),null));return this.buffers.set(t,a),a}};var Rs={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},As={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 dt=null,bo=0;function z_(){return typeof navigator<"u"&&typeof navigator.vibrate=="function"}function U_(){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=`__${y.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 Is(e){if(!(e===0||Array.isArray(e)&&e.every(t=>t===0))){if(z_())try{navigator.vibrate(e);return}catch{}if(dt||(dt=U_()),!!dt)try{dt.label.click()}catch{}}}function Ls(){bo++;let e=!1;return()=>{e||(e=!0,bo=Math.max(0,bo-1),bo===0&&dt&&(dt.input.remove(),dt.label.remove(),dt=null))}}var q_=Q.scope("feedback"),V_=100,Po=class{constructor(t,n){K(this,"mutedSig",H(!1));K(this,"audio",new vo);K(this,"releaseHaptics");K(this,"sound");K(this,"haptics");K(this,"lastPlayed",new Map);K(this,"reducedMotionMq",null);this.sound=t,this.haptics=n,this.releaseHaptics=Ls(),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<V_}playSound(t){let n=this.sound.events?.[t];if(n===!1)return;if(typeof n=="string"){this.audio.playUrl(n).catch(a=>q_.warn("audio play failed",{err:a,url:n}));return}let o=As[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?Rs[t]:n;Is(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 Pt(e,t){return e instanceof We&&e.status===429?t.errorRateLimited:t.errorGeneric}var W_=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:--W_,__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 Z.vnode&&Z.vnode(_),_}var F={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24"},mn=`${y.cssPrefix}-icon-dir`,zr=()=>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"})}),Qe=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M18 6 6 18M6 6l12 12"})}),Ms=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M12 5v14M5 12h14"})}),Ns=()=>r("svg",{...F,class:mn,"aria-hidden":"true",children:[r("path",{d:"m22 2-7 20-4-9-9-4Z"}),r("path",{d:"M22 2 11 13"})]}),Ds=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M12 19V5M5 12l7-7 7 7"})}),Os=()=>r("svg",{...F,class:mn,"aria-hidden":"true",children:r("path",{d:"M3 20V4l18 8-18 8Z"})}),zt=()=>r("svg",{...F,class:mn,"aria-hidden":"true",children:r("path",{d:"m9 18 6-6-6-6"})}),$s=()=>r("svg",{...F,"aria-hidden":"true",children:r("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}),Fs=()=>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"})}),Bs=()=>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"})]}),Hs=()=>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"})}),Us=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z"})}),qs=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7"})}),Vs=()=>r("svg",{...F,"aria-hidden":"true",viewBox:"0 0 10 10",children:r("path",{d:"M9 1L1 9M9 5L5 9M9 9H9",strokeWidth:"1.5"})}),Ws=()=>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"})]}),Gs=()=>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"})}),Ks=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6"})}),js=()=>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"})]}),Xs=()=>r("svg",{...F,class:mn,"aria-hidden":"true",children:r("path",{d:"m5 6 6 6-6 6M13 6l6 6-6 6"})}),yt=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"M20 6 9 17l-5-5"})}),Ys=()=>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"})]}),Js=()=>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"})]}),fn=()=>r("svg",{...F,class:mn,"aria-hidden":"true",children:r("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),Qs=()=>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"})]}),xt=()=>r("svg",{...F,"aria-hidden":"true",children:r("path",{d:"m6 9 6 6 6-6"})}),Zs=()=>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"})]}),G_=()=>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"})]}),Ur=()=>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"})}),gn=()=>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"})]}),K_=()=>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"})]}),j_=()=>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"})]}),X_=()=>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"})]}),Y_=()=>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"})]}),qr=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"11",cy:"11",r:"7"}),r("path",{d:"m21 21-4.3-4.3"})]}),el=()=>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"})]}),tl=()=>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"})]}),nl=()=>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"})]}),hn=()=>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"})]}),ol=()=>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"})]}),rl=()=>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"})}),al=()=>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"})]}),J_=()=>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"})]}),Q_=()=>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"})]}),Z_=()=>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"})]}),eu=()=>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"})]}),il=()=>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"})]}),sl=()=>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"})]}),ll=()=>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"})]}),cl=()=>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"})]}),dl=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"M12 7v5l3 2"})]}),yo=()=>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"})]}),xo=()=>r("svg",{...F,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"m15 9-6 6M9 9l6 6"})]}),_l={chat:zr,message:Ur,bubbles:hn,spark:G_,wand:K_,bot:j_,help:gn,lifebuoy:Y_,headset:X_,search:J_,sparkles:Q_,concierge:Z_,wave:eu};var M=y.cssPrefix,S={launcher:`${M}-launcher`,callout:`${M}-callout`,calloutDismiss:`${M}-callout-dismiss`,panel:`${M}-panel`,panelHeader:`${M}-panel-header`,resizeGrip:`${M}-resize-grip`,scrollToBottom:`${M}-scroll-to-bottom`,actionHistory:`${M}-action-history`,actionClose:`${M}-action-close`,langSegment:`${M}-lang-segment`,composer:`${M}-composer`,composerInput:`${M}-composer-input`,composerSend:`${M}-composer-send`,composerStop:`${M}-composer-stop`,composerAttach:`${M}-composer-attach`,composerFileInput:`${M}-composer-file-input`,composerVoice:`${M}-composer-voice`,attachmentChip:`${M}-attachment-chip`,attachmentRemove:`${M}-attachment-remove`,suggestion:`${M}-suggestion`,messageBubble:`${M}-message`,messageRetry:`${M}-message-retry`,messageFeedback:`${M}-message-feedback`,feedbackUp:`${M}-feedback-up`,feedbackDown:`${M}-feedback-down`,messageCopy:`${M}-message-copy`,historyPane:`${M}-history-pane`,historyBack:`${M}-history-back`,historyItem:`${M}-history-item`,sidebar:`${M}-sidebar`,sidebarToggle:`${M}-sidebar-toggle`,sidebarNewConversation:`${M}-sidebar-new-conversation`,sidebarItem:`${M}-sidebar-item`,messengerHome:`${M}-messenger-home`,modulesEmpty:`${M}-modules-empty`,tab:`${M}-tab`,tabBadge:`${M}-tab-badge`,homeView:`${M}-home-view`,homeGreeting:`${M}-home-greeting`,homeBrand:`${M}-home-brand`,backHeader:`${M}-back-header`,contentView:`${M}-content-view`,contentScroll:`${M}-content-scroll`,homeSearch:`${M}-home-search`,helpSearch:`${M}-help-search`,homeRecent:`${M}-home-recent`,homeContentRow:`${M}-home-content-row`,helpArticle:`${M}-help-article`,newsItem:`${M}-news-item`,formGate:`${M}-form-gate`,formDone:`${M}-form-done`,formDoneToggle:`${M}-form-done-toggle`,formAnswers:`${M}-form-answers`,formFill:`${M}-form-fill`,formSubmit:`${M}-form-submit`,formSkip:`${M}-form-skip`,formField:`${M}-form-field`,toolAskQuestions:`${M}-tool-ask-questions`,toolInputSubmit:`${M}-tool-input-submit`,toolInputSkip:`${M}-tool-input-skip`,toolApproval:`${M}-tool-approval`,toolApprove:`${M}-tool-approve`,toolReject:`${M}-tool-reject`,toolEdit:`${M}-tool-edit`,toolDecision:`${M}-tool-decision`,toolAskSummary:`${M}-ask-questions-summary`,toolAskOptions:`${M}-ask-questions-options-toggle`,toolCall:`${M}-tool-call`,source:`${M}-source`};function xe(e,t){return`${e}-${t}`}var So=y.cssPrefix;function ul({onToggle:e,launcher:t,strings:n,leaving:o,edgeTab:a}){let i=t.variant!=="circle"&&!!t.label;return r("button",{type:"button",class:`${So}-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:[tu(t.icon),i?r("span",{class:`${So}-fab-label`,children:Ie(n,t.label??"")}):null]})}function tu(e){let t=_l[e];return t?r(t,{}):r(nu,{source:e})}function nu({source:e}){return r("span",{ref:t=>{t&&ou(t,e)},"aria-hidden":"true"})}function ou(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 pl({callout:e,launcherPosition:t,strings:n,closeLabel:o,onDismiss:a}){let[i,l]=I(!1);return A(()=>{let s=setTimeout(()=>l(!0),e.delayMs);return()=>clearTimeout(s)},[e.delayMs]),A(()=>{if(!i||e.autoDismissMs<=0)return;let s=setTimeout(a,e.autoDismissMs);return()=>clearTimeout(s)},[i,e.autoDismissMs,a]),i?r("div",{class:`${So}-callout`,role:"status","data-shape":e.shape,"data-position":ru(e.position,t),"data-animated":e.animated?"true":void 0,"data-testid":S.callout,children:[r("span",{children:Ie(n,e.text)}),r("button",{type:"button",class:`${So}-callout-close`,onClick:a,"aria-label":o,title:o,"data-testid":S.calloutDismiss,children:r(Qe,{})})]}):null}function ru(e,t){let n=t.endsWith("-right"),o=t.startsWith("bottom-");return e==="vertical"?o?"top":"bottom":n?"left":"right"}function ko({panelEl:e,resize:t,position:n,initialSize:o,onSizeChange:a,strings:i}){let l=y.cssPrefix,s=D(null);if(A(()=>{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"}`,g=m=>{if(!e)return;let k=m.currentTarget,v=e.getBoundingClientRect();s.current={pointerId:m.pointerId,startX:m.clientX,startY:m.clientY,startW:v.width,startH:v.height,dirX:_?-1:1,dirY:c?1:-1},k.setPointerCapture(m.pointerId),e.setAttribute("data-resizing",""),m.preventDefault()},d=m=>{let k=s.current;if(!k||m.pointerId!==k.pointerId||!e)return;let v=(m.clientX-k.startX)*k.dirX,P=(m.clientY-k.startY)*k.dirY;e.style.setProperty(`--${l}-widget-w`,`${k.startW+v}px`),e.style.setProperty(`--${l}-widget-h`,`${k.startH+P}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 v=e.getBoundingClientRect();a({width:Math.round(v.width),height:Math.round(v.height)}),s.current=null};return r("div",{class:p,role:"separator","aria-orientation":"vertical","aria-label":i.resizeHandle,title:i.resizeHandle,onPointerDown:g,onPointerMove:d,onPointerUp:f,onPointerCancel:f,"data-testid":S.resizeGrip,children:r(Vs,{})})}var St=y.cssPrefix,au=`.${St}-header, .${St}-back-header, .${St}-home-hero`,iu='button, a, input, textarea, select, [role="tab"], [contenteditable]',ml=56;function wo(e,t){A(()=>{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(au)||_.closest(iu))return;let p=e.getBoundingClientRect();a={id:c.pointerId,x:c.clientX,y:c.clientY,dx:n(e.style.getPropertyValue(`--${St}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${St}-modal-dy`)),maxX:(window.innerWidth+p.width)/2-ml,maxY:(window.innerHeight+p.height)/2-ml},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(`--${St}-modal-dx`,`${_}px`),e.style.setProperty(`--${St}-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 vn(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 Co(e,t,n){return vn("close",e,t)?n.includes("close"):!1}function fl(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 To(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 Eo(e){return e.trim().split(/\s+/).slice(0,2).map(t=>t.charAt(0).toUpperCase()).join("")}var Vr=y.cssPrefix;function gl({agent:e,strings:t}){let n=e.status??"online",o=Ie(t,e.name),a=e.title?Ie(t,e.title):null;return r("div",{class:`${Vr}-agent`,children:[r("div",{class:`${Vr}-agent-avatar`,"data-status":n,children:e.avatar?r("img",{src:e.avatar,alt:""}):r("span",{children:Eo(o)})}),r("div",{class:`${Vr}-agent-meta`,children:[r("strong",{children:o}),a?r("span",{children:a}):null]})]})}var hl=Q.scope("attachments");function Ro(e,t,n){let o=cu(e),a=[],i=[],l=uu(n.accept),s=t.reduce((_,p)=>_+p.size,0),c=t.length;for(let _ of o){let p=lu(_,c,s,n,l);if(p){i.push({file:_,reason:p});continue}a.push(_u(_)),s+=_.size,c+=1}return(a.length||i.length)&&hl.debug("ingest",{accepted:a.length,rejected:i.map(_=>({name:_.file.name,reason:_.reason}))}),{accepted:a,rejected:i}}function Wr(e){try{URL.revokeObjectURL(e.previewUrl)}catch(t){hl.debug("revokeObjectURL failed",{error:t})}}function lu(e,t,n,o,a){return t>=o.maxCount?"count":n+e.size>o.maxBytes?"bytes":pu(e,a)?null:"mime"}function cu(e){return e?Array.isArray(e)?e.filter(t=>t instanceof File):[...e].map(t=>t instanceof File?t:du(t)).filter(t=>t!==null):[]}function du(e){let t=e;return!t?.getAsFile||t.kind!=="file"?null:t.getAsFile()}function _u(e){return{file:e,id:Ve(),mediaType:e.type||"application/octet-stream",name:e.name||"pasted-file",previewUrl:URL.createObjectURL(e),size:e.size}}function uu(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 pu(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 bn=y.cssPrefix;function vl({attachment:e,onRemove:t}){let n=e.mediaType.startsWith("image/");return r("span",{class:`${bn}-attachment-chip`,title:e.name,"data-testid":xe(S.attachmentChip,e.id),children:[n?r("img",{class:`${bn}-attachment-thumb`,src:e.previewUrl,alt:""}):r("span",{class:`${bn}-attachment-thumb`,"aria-hidden":"true",children:r(Zs,{})}),r("span",{class:`${bn}-attachment-name`,children:e.name}),r("button",{type:"button",class:`${bn}-attachment-remove`,onClick:t,"aria-label":`Remove ${e.name}`,"data-testid":xe(S.attachmentRemove,e.id),children:r(Qe,{})})]})}var Gr={isSupported:!1,start:()=>{},stop:()=>{}};function Kr(e,t,n){return e==="disabled"?Gr:e==="server"?hu(n):mu(t)}function mu(e){let t=fu();if(!t)return Gr;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 g=s.results[p];g&&(c+=g[0].transcript,g.isFinal&&(_=!0))}o(c,_)});let i=()=>{n=null,a()};n.addEventListener("end",i),n.addEventListener("error",i),n.start()},stop(){n?.stop()}}}function fu(){let e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition}var gu=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus","audio/mp4"];function hu(e){if(typeof MediaRecorder>"u"||!navigator?.mediaDevices?.getUserMedia)return Gr;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=vu();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 vu(){for(let e of gu)if(MediaRecorder.isTypeSupported(e))return e}var Fe=y.cssPrefix,kt=Q.scope("composer");function Ut(e){return e.reduce((t,n)=>t+n.size,0)}var bu={arrowUp:Ds,paperPlane:Ns,send:Os,chevron:zt};function bl({options:e,transport:t,feedback:n,bus:o,isStreaming:a,onSend:i,onStop:l,attachApiRef:s}){let c=e.strings,[_,p]=I(""),[g,d]=I([]),[f,m]=I(!1),k=D(null),v=D(null),P=e.features.fileUpload,w=e.features.voice,[b,E]=I(()=>Kr(w,e.locale,(C,B)=>t.transcribe(C,B)));A(()=>{f||w==="disabled"||E(Kr(w,e.locale,(C,B)=>t.transcribe(C,B)))},[e.locale,w,t,f]),A(()=>{let C=k.current;if(!C)return;let B=C.getRootNode(),J="activeElement"in B?B.activeElement:null;J&&C.closest(`.${Fe}-panel`)?.contains(J)||C.focus({preventScroll:!0})},[]),A(()=>{let C=k.current;if(!C)return;if(_.length===0){C.style.height="";return}C.style.height="auto";let B=parseFloat(getComputedStyle(C).fontSize)*.7,J=Math.min(C.scrollHeight,160);C.style.height=`${J<40+B?40:J}px`},[_]);let z=D(g);z.current=g,A(()=>()=>z.current.forEach(Wr),[]),A(()=>{if(s)return s.current={attachFromDrop:C=>{let B=Ro(C,z.current,e.attachments);B.accepted.length!==0&&(kt.info("attach (drop)",{count:B.accepted.length,totalBytes:Ut(B.accepted)}),o.emit("attach",{count:B.accepted.length,totalBytes:Ut(B.accepted)}),d(J=>[...J,...B.accepted]))}},()=>{s.current&&(s.current=null)}},[s,e.attachments]),A(()=>{let C=k.current;if(!C)return;let B=C.closest(`.${Fe}-panel`);if(!B)return;let J=Se=>{let He=Se.clipboardData;if(!He)return;let _e=Se.target?.closest?.("input, textarea, [contenteditable]:not([contenteditable='false'])");if(_e&&_e!==C)return;if(P){let ae=Ro(He.items,z.current,e.attachments);if(ae.accepted.length>0){Se.preventDefault(),kt.info("attach (paste)",{count:ae.accepted.length,totalBytes:Ut(ae.accepted)}),o.emit("attach",{count:ae.accepted.length,totalBytes:Ut(ae.accepted)}),d(ke=>[...ke,...ae.accepted]);return}}if(_e===C)return;let ze=He.getData("text/plain");ze&&(Se.preventDefault(),p(ae=>ae+ze),C.focus())};return B.addEventListener("paste",J),()=>B.removeEventListener("paste",J)},[P,e.attachments,Fe]);let te=()=>{let C=_.trim();!C&&g.length===0||a||(i(C,g),p(""),d([]))},ee=C=>{C.key!=="Enter"||C.shiftKey||C.isComposing||(C.preventDefault(),a?l():te())},Y=C=>{let B=C.target,J=Ro(B.files,g,e.attachments);J.accepted.length>0&&(kt.info("attach (file picker)",{count:J.accepted.length,totalBytes:Ut(J.accepted)}),o.emit("attach",{count:J.accepted.length,totalBytes:Ut(J.accepted)}),d(Se=>[...Se,...J.accepted])),B.value=""},oe=C=>{kt.info("removeAttachment",{id:C}),o.emit("removeAttachment",{id:C}),d(B=>{let J=B.find(Se=>Se.id===C);return J&&Wr(J),B.filter(Se=>Se.id!==C)})},T=D(null),N=()=>{if(b.isSupported){if(f){let C=T.current?Date.now()-T.current:0;kt.info("voiceStop",{durationMs:C}),o.emit("voiceStop",{durationMs:C}),b.stop(),m(!1),n.play("voiceStop"),T.current=null;return}T.current=Date.now(),kt.info("voiceStart"),o.emit("voiceStart",void 0),m(!0),n.play("voiceStart"),b.start((C,B)=>p(J=>B?`${J}${C} `:J),()=>{if(m(!1),T.current){let C=Date.now()-T.current;kt.debug("voiceStop (auto)",{durationMs:C}),o.emit("voiceStop",{durationMs:C}),T.current=null}})}},q=bu[e.composer.sendButton.icon];return r("div",{class:`${Fe}-composer`,"data-testid":S.composer,children:[g.length>0?r("div",{class:`${Fe}-attachments`,children:g.map(C=>r(vl,{attachment:C,onRemove:()=>oe(C.id)},C.id))}):null,r("div",{class:`${Fe}-composer-row`,children:[r("div",{class:`${Fe}-composer-actions`,children:[P?r("button",{type:"button",class:`${Fe}-icon-btn`,onClick:()=>v.current?.click(),"aria-label":c.attach,"data-testid":S.composerAttach,children:r(Fs,{})}):null,b.isSupported?r("button",{type:"button",class:`${Fe}-icon-btn`,onClick:N,"aria-label":f?c.micStop:c.micStart,"aria-pressed":f,"data-recording":f?"true":void 0,"data-testid":S.composerVoice,children:r(Bs,{})}):null]}),r("textarea",{ref:k,class:`${Fe}-textarea`,rows:1,value:_,placeholder:c.composerPlaceholder,onInput:C=>p(C.target.value),onKeyDown:ee,"aria-label":c.composerPlaceholder,"data-testid":S.composerInput}),a?r("button",{type:"button",class:`${Fe}-send`,onClick:l,"aria-label":c.stop,"data-testid":S.composerStop,children:r($s,{})}):r("button",{type:"button",class:`${Fe}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:te,disabled:!_.trim()&&g.length===0,"aria-label":c.send,"data-testid":S.composerSend,children:r(q,{})})]}),r("input",{ref:v,type:"file",multiple:!0,accept:e.attachments.accept,onChange:Y,class:`${Fe}-sr-only`,"data-testid":S.composerFileInput})]})}var Pu=y.cssPrefix;function Pl({visible:e,strings:t}){return e?r("div",{class:`${Pu}-dropzone`,role:"status","aria-live":"polite",children:t.dropZone}):null}function Ao({containerRef:e,onDrop:t}){let[n,o]=I(!1);return A(()=>{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 yl({itemCount:e,initialFocusIndex:t}){let[n,o]=I(!1),a=D(null),i=D(null),[l,s]=I(-1),c=$(()=>{o(!1),s(-1),a.current?.focus()},[]),_=$(()=>o(d=>!d),[]);A(()=>{if(!n)return;let d=f=>{let m=i.current,k=a.current;if(!m||!k)return;let v=f.composedPath();v.includes(m)||v.includes(k)||(o(!1),s(-1))};return document.addEventListener("click",d,!0),()=>document.removeEventListener("click",d,!0)},[n]),A(()=>{if(!n||e===0)return;let d=t?.()??0,f=d<0||d>=e?0:d;s(f)},[n,e,t]),A(()=>{if(!n||l<0)return;i.current?.querySelectorAll("[role='menuitem']")?.[l]?.focus()},[n,l]);let p=$(d=>{(d.key==="ArrowDown"||d.key==="Enter"||d.key===" ")&&(d.preventDefault(),o(!0))},[]),g=$(d=>{if(e!==0)switch(d.key){case"Escape":d.preventDefault(),c();return;case"ArrowDown":d.preventDefault(),s(f=>(f+1)%e);return;case"ArrowUp":d.preventDefault(),s(f=>(f-1+e)%e);return;case"Home":d.preventDefault(),s(0);return;case"End":d.preventDefault(),s(e-1)}},[e,c]);return{open:n,focusIndex:l,triggerRef:a,menuRef:i,toggle:_,close:c,onTriggerKey:p,onMenuKey:g}}function xl({items:e,triggerLabel:t}){let n=y.cssPrefix,o=yl({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(d=>d.value===c.value)),g=-1;if(s.key==="ArrowRight"||s.key==="Enter"||s.key===" ")g=(p+1)%_.length;else if(s.key==="ArrowLeft")g=(p-1+_.length)%_.length;else return;s.preventDefault(),s.stopPropagation(),i(c,_[g].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(Ws,{})}),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(yt,{})}):null]},s.id))}):null]})}var jr=y.cssPrefix;function yu(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 xu={normal:"large",large:"small",small:"normal"};function Su(e){return e==="light"?r(ol,{}):e==="dark"?r(rl,{}):r(al,{})}function ku(e){return(e.split("-")[0]??e).toUpperCase()}function Ze({panelProps:e,variant:t}){let{options:n,panelSize:o,feedback:a,onClose:i,onClear:l,onExpand:s,onFullscreen:c,onSoundToggle:_}=e,{onToggleHistory:p,onLocaleChange:g,onThemeChange:d,onTextSizeChange:f}=e,m=n.strings,k=n.mode,v=t==="chat",P=j(()=>a.mutedSig.value).value,w=new Set(n.actions),b=C=>w.has(C),E=typeof matchMedia=="function"&&matchMedia("(max-width: 640px)").matches,z=C=>E?!1:vn(C,k,o),te=n.themeMode,ee={auto:m.themeAuto,light:m.themeLight,dark:m.themeDark},Y=n.textSize,oe={small:m.textSizeSmall,normal:m.textSizeNormal,large:m.textSizeLarge},T=[];if(v&&b("clear")&&T.push({id:"clear",icon:r(Qs,{}),label:m.newConversation,onSelect:l}),b("expand")&&z("expand")){let C=o==="expanded";T.push({id:"expand",icon:C?r(zs,{}):r(Hs,{}),label:C?m.collapse:m.expand,type:"switch",on:C,onSelect:s})}if(b("fullscreen")&&z("fullscreen")){let C=o==="fullscreen";T.push({id:"fullscreen",icon:C?r(qs,{}):r(Us,{}),label:C?m.exitFullscreen:m.fullscreen,type:"switch",on:C,onSelect:c})}v&&b("sound")&&T.push({id:"sound",icon:P?r(Ks,{}):r(Gs,{}),label:P?m.soundOff:m.soundOn,type:"switch",on:!P,onSelect:_}),b("theme")&&T.push({id:"theme",icon:Su(te),label:`${m.theme}: ${ee[te]}`,onSelect:()=>d(yu(te)),keepOpen:!0}),b("textSize")&&T.push({id:"textSize",icon:r(js,{}),label:`${m.textSize}: ${oe[Y]}`,onSelect:()=>f(xu[Y]),keepOpen:!0}),b("language")&&n.availableLocales.length>1&&T.push({id:"language",icon:r(Js,{}),label:m.language,segments:n.availableLocales.map(C=>({value:C,label:ku(C),lang:C})),value:n.locale,onSelectValue:g});let N=!!i&&Co(k,o,n.actions),q=v&&b("history");return r("div",{class:`${jr}-header-actions`,children:[q?r("button",{type:"button",class:`${jr}-icon-btn`,onClick:p,"aria-label":m.history,title:m.history,"data-testid":S.actionHistory,children:r(Ys,{})}):null,T.length>0?r(xl,{items:T,triggerLabel:m.moreActions}):null,N?r("button",{type:"button",class:`${jr}-icon-btn`,onClick:i,"aria-label":m.close,title:m.close,"data-testid":S.actionClose,children:r(Qe,{})}):null]})}var wu=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Cu=/^https?:\/\/[^\s.]+\.[^\s]+$/i,Tu=/^[+]?[\d\s().-]{6,}$/;function qt(e,t){return e.replace(/\{(\w+)\}/g,(n,o)=>String(t[o]??`{${o}}`))}function Eu(e){return Array.isArray(e)?e.length:e&&e.trim()?1:0}function Ru(e,t,n){let o=e.required??!0,a=e.validation;if(e.type==="multiselect"){let l=Eu(t);return o&&l===0?n.formRequired:l===0?void 0:a?.minSelections!=null&&l<a.minSelections?qt(n.formChooseAtLeast,{min:a.minSelections}):a?.maxSelections!=null&&l>a.maxSelections?qt(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(!wu.test(i))return n.formInvalidEmail;break;case"url":if(!Cu.test(i))return n.formInvalidUrl;break;case"tel":if(!Tu.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 qt(n.formNumberTooSmall,{min:a.min});if(a?.max!=null&&l>a.max)return qt(n.formNumberTooLarge,{max:a.max});break}default:break}if(a?.minLength!=null&&i.length<a.minLength)return qt(n.formTooShort,{min:a.minLength});if(a?.maxLength!=null&&i.length>a.maxLength)return qt(n.formTooLong,{max:a.maxLength});if(a?.pattern)try{if(!new RegExp(a.pattern).test(i))return n.formPatternMismatch}catch{}}function Sl(e,t,n){let o={};for(let a of e){let i=Ru(a,t[a.name],n);i&&(o[a.name]=i)}return o}function kl(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 le=y.cssPrefix,Io="__other__";function Pn({fields:e,strings:t,submitLabel:n,onSubmit:o,skipLabel:a,onSkip:i,footerHint:l,submitOnEnter:s,disabled:c,initialValues:_,hideActions:p,fieldTypeLabels:g,rootTestId:d,submitTestId:f,skipTestId:m}){let[k,v]=I(()=>({...Mu(e),..._})),[P,w]=I({}),[b,E]=I({}),z=T=>{b[T]&&E(N=>({...N,[T]:""}))},te=(T,N)=>{v(q=>({...q,[T]:N})),z(T)},ee=(T,N)=>{w(q=>({...q,[T]:N})),z(T)},Y=T=>{if(T.preventDefault(),c)return;let N=Nu(e,k,P),q=Sl(e,N,t);if(Object.keys(q).length>0){E(q);return}o(kl(N))},oe=T=>{!s||T.key!=="Enter"||T.shiftKey||T.isComposing||T.target?.tagName==="TEXTAREA"&&Y(T)};return r("form",{class:`${le}-form`,onSubmit:Y,onKeyDown:oe,"data-testid":d,noValidate:!0,children:[e.map(T=>r(Au,{field:T,value:k[T.name],otherText:P[T.name]??"",error:b[T.name],disabled:c,typeLabel:g?.[T.name],strings:t,onChange:N=>te(T.name,N),onOtherChange:N=>ee(T.name,N)},T.name)),p?null:r("div",{class:`${le}-form-actions`,children:[l?r("span",{class:`${le}-form-hint`,children:l}):null,a&&i?r("button",{type:"button",class:`${le}-form-skip`,onClick:i,disabled:c,"data-testid":m,children:a}):null,r("button",{type:"submit",class:`${le}-form-submit`,disabled:c,"data-testid":f,children:n})]})]})}function Au({field:e,value:t,otherText:n,error:o,disabled:a,typeLabel:i,strings:l,onChange:s,onOtherChange:c}){let _=xe(S.formField,e.name),p=Iu({field:e,value:t,otherText:n,disabled:a,strings:l,onChange:s,onOtherChange:c,fieldTid:_});return r("label",{class:`${le}-field`,"data-field":e.name,"data-invalid":o?"true":void 0,children:[r("span",{class:`${le}-field-head`,children:[r("span",{class:`${le}-field-label`,children:[e.label,e.required??!0?r("span",{class:`${le}-field-req`,"aria-hidden":"true",children:" *"}):null]}),i?r("span",{class:`${le}-field-type`,children:i}):null]}),p,e.validationHint&&!o?r("span",{class:`${le}-field-hint`,children:e.validationHint}):null,o?r("span",{class:`${le}-field-error`,role:"alert",children:o}):null]})}function Iu(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:`${le}-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:`${le}-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&&_===Io;return r("div",{class:`${le}-field-choices`,role:"radiogroup","data-testid":c,children:[(t.options??[]).map(g=>r("label",{class:`${le}-choice`,children:[r("input",{type:"radio",name:`${le}-${t.name}`,checked:_===g.value,disabled:a,onChange:()=>l(g.value)}),r("span",{children:g.label??g.value})]},g.value)),t.allowOther?r("label",{class:`${le}-choice`,children:[r("input",{type:"radio",name:`${le}-${t.name}`,checked:_===Io,disabled:a,onChange:()=>l(Io)}),r("span",{children:i.formOther})]}):null,p?r("input",{class:`${le}-field-input`,value:o,placeholder:t.placeholder??i.formOtherPlaceholder,disabled:a,onInput:g=>s(g.target.value)}):null]})}case"checkbox":return r("label",{class:`${le}-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:[],g=(d,f)=>l(f?[...p,d]:p.filter(m=>m!==d));return r("div",{class:`${le}-field-choices`,"data-testid":c,children:[(t.options??[]).map(d=>r("label",{class:`${le}-choice`,children:[r("input",{type:"checkbox",checked:p.includes(d.value),disabled:a,onChange:f=>g(d.value,f.target.checked)}),r("span",{children:d.label??d.value})]},d.value)),t.allowOther||(t.options??[]).length===0?r("textarea",{class:`${le}-field-input`,rows:2,value:o,placeholder:t.placeholder??i.formOtherPlaceholder,disabled:a,onInput:d=>s(d.target.value)}):null]})}default:return r("input",{class:`${le}-field-input`,type:Lu(t.type),value:_,placeholder:t.placeholder,disabled:a,onInput:p=>l(p.target.value),"data-testid":c})}}function Lu(e){switch(e){case"number":case"email":case"tel":case"url":case"date":case"time":return e;default:return"text"}}function Mu(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 Nu(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]===Io)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 et=y.cssPrefix;function Xr({form:e,strings:t,onSubmit:n,onSkip:o}){return r("div",{class:`${et}-form-gate`,"data-testid":S.formGate,children:[e.title?r("h3",{class:`${et}-form-gate-title`,children:e.title}):null,e.description?r("p",{class:`${et}-form-gate-desc`,children:e.description}):null,r(Pn,{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 wl({marker:e,strings:t,onFill:n}){let o=e.outcome==="skipped",a=o?t.formSkipped:t.formSubmitted,i=e.title?r(ie,{children:[r("span",{children:e.title}),r("span",{class:`${et}-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:`${et}-form-done`,"data-outcome":e.outcome,"data-testid":S.formDone,children:[r("summary",{class:`${et}-form-done-summary`,"data-testid":S.formDoneToggle,children:[r(yt,{}),i,r(zt,{})]}),r("dl",{class:`${et}-form-answers`,"data-testid":S.formAnswers,children:Object.entries(s).map(([_,p])=>r("div",{class:`${et}-form-answer`,children:[r("dt",{children:c(_)}),r("dd",{children:p})]},_))})]})}return r("div",{class:`${et}-form-done`,"data-outcome":e.outcome,"data-testid":S.formDone,role:"status",children:[o?r(Xs,{}):r(yt,{}),i,o&&e.form?.reopenable&&n?r("button",{type:"button",class:`${et}-form-done-fill`,"data-testid":S.formFill,onClick:n,children:t.formFillOut}):null]})}function Cl(e){if(!e)return!1;let t=e.startsWith("tool:")?e.slice(5):e;return t==="ask-user-questions"||t==="ask_user_questions"}var Qr=1,El=2,Rl=4,Al=8,Il=16;function Du(e){switch(e){case Qr:return"href";case El:return"src";case Rl:return"class";case Al:return"checked";case Il:return"start"}}var Ou=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}},$u=Ou;var Tl=24;function ea(e){let t=new Uint32Array(Tl);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(Tl),indent:"",indent_len:0,table_state:0}}function Ll(e){e.pending.length>0&&Te(e,`
|
|
12
12
|
`)}function ne(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 me(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&&me(e),e.len+=1,e.tokens[e.len]=t,e.token=t,e.renderer.add_token(e.renderer.data,t)}function Fu(e,t,n){for(;n<=e.len;){if(e.tokens[n]===t)return n;n+=1}return-1}function wt(e,t){for(e.fence_start=0;e.len>t;)me(e)}function Lo(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;)me(e);return t}function Yr(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?(wt(e,e.blockquote_idx),re(e,t),!0):(wt(e,n),!1):(wt(e,o),re(e,t),!0)}function Jr(e,t){re(e,25),e.spaces[e.len]=e.indent_len+t,at(e),e.token=103}function at(e){e.indent="",e.indent_len=0,e.pending=""}function Zr(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 Bu(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 Hu(e){return Zr(e)||Bu(e)}function Te(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=Lo(e,e.indent_len);e.indent_len=0,e.token=e.tokens[e.len],a>0&&Te(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){me(e),at(e),e.pending=n;continue}wt(e,e.blockquote_idx),at(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" ":Lo(e,e.indent_len),re(e,$u(e.pending.length)),at(e);continue}break;case">":{let i=Fu(e,20,e.blockquote_idx+1);i===-1?(wt(e,e.blockquote_idx),e.blockquote_idx+=1,e.fence_start=0,re(e,20)):e.blockquote_idx=i,at(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;Lo(e,e.indent_len),e.renderer.add_token(e.renderer.data,22),e.renderer.end_token(e.renderer.data),at(e),e.hr_chars=0;continue}e.hr_chars=0}if(e.pending[0]!=="_"&&e.pending[1]===" "){Yr(e,23),Jr(e,2),Te(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),at(e),e.fence_start=0,Te(e,o));continue;case`
|