@helpai/elements 1.12.7 → 1.12.9

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/react.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  'use client';
2
- import{useEffect as e,useMemo as t,useRef as n,useSyncExternalStore as r}from"react";function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const c={open:!1,ready:!1,unread:0};var l=class{constructor(){s(this,`handlers`,/* @__PURE__ */ new Map)}on(e,t){let n=this.handlers.get(e);return n||(n=/* @__PURE__ */ new Set,this.handlers.set(e,n)),n.add(t),()=>this.handlers.get(e)?.delete(t)}emit(e,t){let n=this.handlers.get(e);if(n)for(let e of n)try{e(t)}catch{}}clear(){this.handlers.clear()}};const u={id:`help-ai`,name:`@helpai/elements`,global:`HelpAI`,tagName:`web-ai-chat`,cssPrefix:`helpai`,defaultBaseUrl:`https://help.ai`,displayName:`Help AI`,domain:`help.ai`,siteUrl:`https://help.ai`},d=[`off`,`error`,`warn`,`info`,`debug`,`trace`],f=u.cssPrefix,p=`${f}.debug`,m=`__${u.global}_DEBUG__`,h=`${f}-debug`;let g=2,_=null;function v(){if(typeof window>`u`)return 2;try{let e=new URLSearchParams(window.location.search).get(h);if(e!==null){let t=y(e);if(t>=0)return t}}catch{}try{let e=window.localStorage?.getItem(p);if(e){let t=y(e);if(t>=0)return t}}catch{}return Reflect.get(window,m)?4:2}function y(e){if(e===!0||e===`1`||e===`true`)return 4;if(e===!1||e===`0`||e===`false`||e===`off`)return 0;if(typeof e==`number`)return Math.max(0,Math.min(5,Math.floor(e)));if(typeof e==`string`){let t=d.findIndex(t=>t===e);if(t>=0)return t}return-1}function b(e){let t=y(e);if(!(t<0)){g=t;try{window.localStorage?.setItem(p,d[t]??`off`)}catch{}}}function x(){return d[g]??`warn`}g=v();function S(e){let t=`[${f}:${e}]`;function n(n,r,i){return(a,o)=>{if(!(g<n)&&(o===void 0?console[r](t,a):console[r](t,a,o),_))try{_({level:i,scope:e,message:a,payload:o})}catch{}}}return{error:n(1,`error`,`error`),warn:n(2,`warn`,`warn`),info:n(3,`info`,`info`),debug:n(4,`debug`,`debug`),trace:n(5,`debug`,`trace`),scope:t=>S(`${e}:${t}`)}}const C=S(`core`);function w(e){_=e}const T=/* @__PURE__ */ new Set([`hidden`,`submit`,`button`,`reset`,`image`,`file`,`password`]);function E(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function D(e){return!E(e)||e.name===``||e.disabled?!1:!(e instanceof HTMLInputElement&&T.has(e.type))}function O(e){let t=e.labels?.[0]?.textContent?.trim();return e.getAttribute(`toolparamdescription`)??(t||e.getAttribute(`aria-description`))??void 0}function ee(e,t){let n=O(e),r=n?{description:n}:{};return e instanceof HTMLSelectElement?{...r,type:`string`,enum:[...e.options].map(e=>e.value)}:e instanceof HTMLTextAreaElement?{...r,type:`string`}:e.type===`checkbox`?{...r,type:`boolean`}:e.type===`radio`?{...r,type:`string`,enum:t}:e.type===`number`||e.type===`range`?{...r,type:`number`}:{...r,type:`string`}}function k(e,t){Object.getOwnPropertyDescriptor(Reflect.getPrototypeOf(e)??e,`value`)?.set?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}function te(e){return e==null?``:typeof e==`string`?e:JSON.stringify(e)}function ne(e,t){e instanceof HTMLInputElement&&e.type===`checkbox`?e.checked!==(t===!0||t===`true`)&&e.click():e instanceof HTMLInputElement&&e.type===`radio`?e.value===te(t)&&!e.checked&&e.click():k(e,te(t))}function A(e,t,n){let r=[...e.elements].filter(D),i={},a=/* @__PURE__ */ new Set;for(let e of r){var o;let t=r.flatMap(t=>t instanceof HTMLInputElement&&t.type===`radio`&&t.name===e.name?[t.value]:[]);i[o=e.name]??(i[o]=ee(e,t)),e.required&&a.add(e.name)}return{name:t,description:n,inputSchema:{type:`object`,properties:i,...a.size>0?{required:[...a]}:{}},execute(t){let n=typeof t==`object`&&t?Object.entries(t):[];for(let[e,t]of n)for(let n of r)n.name===e&&ne(n,t);if(!e.hasAttribute(`toolautosubmit`))return`Filled in the form. The visitor still needs to check it and press its submit button.`;let i=[...new Set([...e.elements].flatMap(e=>E(e)&&e.name&&!e.checkValidity()?[e.name]:[]))];return i.length>0?`Filled in the form, but it can't be submitted yet: ${i.join(`, `)} still needs the visitor. Ask them to complete it and press the submit button.`:(setTimeout(()=>e.requestSubmit(),0),`Filled in the form and submitted it.`)}}}function j(){return[...document.querySelectorAll(`form[toolname][tooldescription]`)].flatMap(e=>{let t=e.getAttribute(`toolname`)?.trim()??``,n=e.getAttribute(`tooldescription`)?.trim()??``;return t&&n?[A(e,t,n)]:[]})}const re=`${u.cssPrefix}.page-tools`;function ie(e){return typeof e==`object`&&!!e}function ae(e){return ie(e)&&(e.state===`running`||e.state===`stopped`||e.state===`finished`&&ie(e.outcome))}function oe(e){let t=e?JSON.parse(e):void 0;return ie(t)?{sent:Array.isArray(t.sent)?t.sent.filter(e=>typeof e==`string`):[],calls:Object.fromEntries(Object.entries(ie(t.calls)?t.calls:{}).filter(e=>ae(e[1])))}:{sent:[],calls:{}}}let se={sent:[],calls:{}};function ce(){try{se=oe(sessionStorage.getItem(re))}catch{}return se}function le(e){se=e;try{sessionStorage.setItem(re,JSON.stringify(e))}catch{}}const M={markSent(e){let t=ce();le({...t,sent:[...t.sent.filter(t=>t!==e),e].slice(-20)})},sentHere(e){return ce().sent.includes(e)},get(e){return ce().calls[e]},set(e,t){let n=ce(),r=Object.entries(n.calls).filter(([t])=>t!==e);le({...n,calls:Object.fromEntries([...r,[e,t]].slice(-50))})},clear(e){let t=ce();e.some(e=>e in t.calls)&&le({...t,calls:Object.fromEntries(Object.entries(t.calls).filter(([t])=>!e.includes(t)))})}};function ue(e,t){return new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(a,e);function i(){return a()}t?.addEventListener(`abort`,i,{once:!0});function a(){clearTimeout(r),t?.removeEventListener(`abort`,i),n()}})}const de=C.scope(`page-tools`),fe=3e4,pe=Symbol.for(`${u.cssPrefix}.page-tools`),me={state:`output-error`,errorText:`The page reloaded before this finished, so it may or may not have taken effect. Check with the visitor before trying it again.`},he=`The visitor stopped this before it finished.`;function N(e){return typeof e==`object`&&!!e}function ge(e){return N(e)&&Array.isArray(e.registered)&&e.runs instanceof Map}function _e(){let e=Reflect.get(globalThis,pe);if(ge(e))return e;let t={registered:[],runs:/* @__PURE__ */ new Map};return Reflect.set(globalThis,pe,t),t}function ve(e,t){let n=N(t)&&t.signal instanceof AbortSignal?t.signal:void 0;if(n?.aborted)return;let r=_e().registered;r.push(e);function i(){let t=r.indexOf(e);t>=0&&r.splice(t,1)}n?.addEventListener(`abort`,i,{once:!0})}function ye(e){return e.replace(/[^A-Za-z0-9_-]/g,`_`).slice(0,58)}function be(e){if(!N(e)||typeof e.name!=`string`||!ye(e.name))return;let t=[e.description,e.title].find(e=>typeof e==`string`&&e.trim()!==``)??e.name;return{name:ye(e.name),description:t.trim().slice(0,1024),inputSchema:{properties:{},...N(e.inputSchema)?e.inputSchema:{},type:`object`},consequential:N(e.annotations)&&e.annotations.consequentialHint===!0}}function xe(e){return e.flatMap(e=>{let t=be(e),n=N(e)?e.execute:void 0;return!t||typeof n!=`function`?(de.warn(`skipped a tool without a name or an execute function`,e),[]):[{...t,run:(t,r)=>Reflect.apply(n,e,[t,{signal:r}])}]})}async function Se(){let e=Reflect.get(document,`modelContext`)??Reflect.get(navigator,`modelContext`);if(!N(e)||typeof e.getTools!=`function`||typeof e.executeTool!=`function`)return[];let t=e.getTools,n=e.executeTool,r=await Promise.race([Promise.resolve().then(()=>Reflect.apply(t,e,[])),ue(1e3).then(()=>[])]).catch(()=>[]);return(Array.isArray(r)?r:[]).flatMap(t=>{let r=be(t);return r?[{...r,run:(r,i)=>Reflect.apply(n,e,[t,r,{signal:i}])}]:[]})}async function Ce(e=[]){let t=xe(j()),n=new Set(t.map(e=>e.name)),r=[...(await Se()).filter(e=>!n.has(e.name)),...t,...xe(e),...xe(_e().registered)];return new Map(r.map(e=>[e.name,e]))}function we(e){return[...e.values()].map(({name:e,description:t,inputSchema:n,consequential:r})=>r?{name:e,description:t,inputSchema:n,annotations:{consequentialHint:!0}}:{name:e,description:t,inputSchema:n})}function Te(e){return e?.execution===`client`}function Ee(e){return e.startsWith(`site__`)?e.slice(6):e}function De(e){if(e===void 0||typeof e==`function`||typeof e==`symbol`)return null;let t=/* @__PURE__ */ new WeakSet,n=JSON.stringify(e,(e,n)=>{if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`)return n instanceof Node?`[${n.nodeName.toLowerCase()}]`:N(n)?t.has(n)?`[circular]`:(t.add(n),n):n});return n.length>fe?{truncated:!0,preview:n.slice(0,fe)}:JSON.parse(n)}async function Oe(e){let t=Ee(e.toolName),n=(await Ce(e.optionTools)).get(t);return n?Promise.resolve().then(()=>n.run(e.input,e.signal)).then(e=>({state:`output-available`,output:De(e)})).catch(e=>(de.warn(`a page tool failed`,{name:t,error:e}),{state:`output-error`,errorText:(e instanceof Error?e.message:String(e)).slice(0,1e3)||`The page tool failed.`})):{state:`output-error`,errorText:`This page doesn't offer "${t}" right now; the visitor may have moved on. Tell them, or continue without it.`}}function ke(e){let{toolCallId:t}=e,n=M.get(t);if(n?.state===`finished`)return Promise.resolve(n.outcome);let{runs:r}=_e(),i=r.get(t);if(i)return i.outcome;if(n?.state===`running`)return M.set(t,{state:`finished`,outcome:me}),e.onSettled(`interrupted`,0),Promise.resolve(me);let a=new AbortController,o=performance.now();M.set(t,{state:`running`});let s=Oe({...e,signal:a.signal}).then(n=>(r.delete(t),M.get(t)?.state===`running`&&(M.set(t,{state:`finished`,outcome:n}),e.onSettled(n.state===`output-available`?`completed`:`failed`,Math.round(performance.now()-o))),n));return r.set(t,{outcome:s,controller:a}),s}function Ae(e){return e===me.errorText||e===he}function je(e){return M.set(e,{state:`stopped`}),_e().runs.get(e)?.controller.abort(),he}function Me(e){M.clear([e]),_e().runs.get(e)?.controller.abort()}var P,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,F=Symbol.for(`pv`),Ue={},We=[],Ge=/^m(i|n|o|s|text|space)$/,Ke=Array.isArray,qe=We.slice,Je=Object.assign;function Ye(e){e&&e.parentNode&&e.remove()}function Xe(e,t,n){var r,i,a,o={},s=arguments.length;for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return s>2&&(o.children=s>3?qe.call(arguments,2):n),Ze(e,o,r,i,null)}function Ze(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:F,__v:i||++Ne,__i:-1,__u:0};return!i&&P.vnode&&P.vnode(a),a}function I(e){return e.children}function Qe(e,t){this.props=e,this.context=t,this.__g=0}function $e(e,t){if(t==null)return e.__&&$e(e.__,e.__i+1);for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:$e(e)}function et(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),et(e)}function tt(e){(8&e.__g||(e.__g|=8,Fe.push(e),Le++))&&Ie==P.debounceRendering||((Ie=P.debounceRendering)||queueMicrotask)(nt)}function nt(){var e,t,n,r,i,a,o,s,c;try{for(t=1;Fe.length;)Fe.length>t&&Fe.sort(Re),e=Fe.shift(),t=Fe.length,8&e.__g&&(r=void 0,i=void 0,a=(i=(n=e).__v).__e,o=[],s=[],(c=n.__P)&&((r=Je({constructor:F},i)).__v=i.__v+1,P.vnode&&P.vnode(r),dt(c,r,i,n.__n,c.namespaceURI,32&i.__u?[a]:null,o,a||$e(i),32&i.__u,s),r.__v=i.__v,r.__.__k[r.__i]=r,mt(o,r,s),i.__=i.__e=null,r.__e!=a&&et(r)))}finally{(Le=Fe.length)&&(Ie||queueMicrotask)(nt)}}function rt(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r.__k||We,v=t.length;for(c=it(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=~p.__i&&_[p.__i]||Ue,p.__i=d,g=dt(e,p,f,i,a,o,s,c,l,u),m=p.__e,(f.ref!=p.ref||8&f.__u)&&(f.ref&&gt(f.ref,null,p,f),p.ref&&u.push(p.ref,p.__c||m,p)),h=h||m,4&p.__u?(c=at(p,c,e,!f.__v),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-21);return n.__e=h,c}function it(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,m=n.length,h=m,g=0,_=0,v=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor===String?o=v[a]=Ze(null,o):Ke(o)?o=v[a]=Ze(I,{children:o}):o.constructor===F&&o.__b?o=v[a]=Ze(o.type,o.props,o.key,o.ref,o.__v):v[a]=o,c=a+g,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=st(o,n,c,h))&&(h--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=16,l==c-1?g--:l==c+1?g++:l!=c&&(l>c?g--:g++,_=1)):(~l||(i>m?g--:i<m&&g++),typeof o.type!=`function`&&(o.__u|=4))):v[a]=null;if(_){for(u=[],d=[],a=0;a<i;a++)if((o=v[a])&&16&o.__u){for(g=0,f=u.length;g<f;)u[p=g+f>>1]<o.__i?g=p+1:f=p;u[g]=o.__i,d[a]=g+1}for(g=u.length;a--;)d[a]&&(d[a]==g?g--:v[a].__u|=4)}if(h)for(a=0;a<m;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=$e(s)),_t(s,s));return r}function at(e,t,n,r){var i,a,o,s;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=at(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=$e(e))&&!t.parentNode&&(t=null),o=e.__e,s=t;s&&s.nodeType==8;)s=s.nextSibling;for(o!=s&&(!r&&n.moveBefore&&o.parentNode?n.moveBefore(o,t):n.insertBefore(o,t||null)),t=o;(t=t&&t.nextSibling)&&t.nodeType==8&&!t.data.startsWith(`$s`););return t}function ot(e,t){return t=t||[],e!=null&&typeof e!=`boolean`&&(Ke(e)?e.some(function(e){ot(e,t)}):t.push(e)),t}function st(e,t,n,r){var i,a=e.key,o=e.type,s=t[n],c=s&&!(2&s.__u);if(s===null&&a==null||c&&a==s.key&&o==s.type)return n;if(r>+!!c){for(i=n-1;i>=0;i--)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i;for(i=n+1;i<t.length;i++)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i}return-1}function ct(e,t,n){n??(n=``),t[0]==`-`?e.setProperty(t,n):e[t]=n}function lt(e,t,n,r,i){var a,o;if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ct(e.style,t);if(n)for(t in n)r&&n[t]==r[t]||ct(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||(e.__e={}))[t]=n,n&&r||(o=He[t]||(He[t]=ut(t)),(e.__a||(e.__a={}))[t]=Ve,a=t!=(t=t.replace(Be,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,a));else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;return}catch{}if(typeof n==`function`)return;n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n)}}function ut(e){return function(t){var n=this.__e;if(n){if(n=n[e],t[ze]==null)t[ze]=Ve++;else if(t[ze]<this.__a[e])return;return n(P.event?P.event(t):t)}}}function dt(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O=t.type;if(t.constructor!==F)return null;128&n.__u&&(c=32&n.__u,u=n.__c.__z)&&(t.__u|=c,d=a=[],u.nodeType==8?s=ft(u,a):a.push(u),s=a[0]||s),(u=P.__b)&&u(t);n:if(typeof O==`function`){f=o.length;try{if(_=t.props,v=(u=O.prototype)&&u.render,y=(u=O.contextType)&&r[u.__c],b=u?y?y.props.value:u.__:r,(p=n.__c)?(t.__c=p,2&p.__g&&(p.__g|=1)):(v?t.__c=p=new O(_,b):(t.__c=p=new Qe(_,b),p.constructor=O,p.render=vt),y&&y.sub(p),p.state||(p.state={}),p.__n=r,p.__g|=8,p.__h=[],p.__k=[]),v&&(p.__s||(p.__s=p.state),O.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=Je({},p.__s)),Je(p.__s,O.getDerivedStateFromProps(_,p.__s)))),m=p.props,h=p.state,p.__v=t,n.__c){if(_!==m&&v&&!O.getDerivedStateFromProps&&p.componentWillReceiveProps&&p.componentWillReceiveProps(_,b),t.__v==n.__v&&!(8&p.__g)||!(4&p.__g)&&p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(_,p.__s,b)){t.__v!=n.__v&&(p.props=_,p.state=p.__s,p.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),We.push.apply(p.__h,p.__k),p.__k=[],p.__h.length&&o.push(p),s=$e(n);break n}p.componentWillUpdate&&p.componentWillUpdate(_,p.__s,b),v&&p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(m,h,g)})}else v&&!O.getDerivedStateFromProps&&p.componentWillMount&&p.componentWillMount(),v&&p.componentDidMount&&p.__h.push(p.componentDidMount);if(p.context=b,p.props=_,p.__P=e,p.__g&=-5,x=P.__r,S=0,v)p.state=p.__s,p.__g&=-9,x&&x(t),u=p.render(p.props,p.state,p.context),We.push.apply(p.__h,p.__k),p.__k=[];else do p.__g&=-9,x&&x(t),u=p.render(p.props,p.state,p.context),p.state=p.__s;while(8&p.__g&&++S<25);p.state=p.__s,p.getChildContext&&(r=Je({},r,p.getChildContext())),v&&n.__c&&p.getSnapshotBeforeUpdate&&(g=p.getSnapshotBeforeUpdate(m,h)),C=u&&u.type===I&&u.key==null?u.props.children:u,_.__P&&(u=s,i=(e=_.__P).namespaceURI,c=a=null,n.props&&n.props.__P!=e&&(n.__k.some(function(e){e&&_t(e,e)}),n.__k=null),s=n.__k?$e(n,0):null),s=rt(e,Ke(C)?C:[C],t,n,r,i,a,o,s,c,l),_.__P&&(t.__e=null,s=u),t.__u&=-161,d&&d.some(Ye),p.__h.length&&o.push(p),1&p.__g&&(p.__g&=-4)}catch(e){if(o.length=f,t.__v=null,c||a){if(e.then){if(w=0,t.__u|=128|c,a){for(~(E=a.indexOf(s||void 0))||(E=a.length);(D=a[E-1])&&D.nodeType==8;)E--;for(;E<a.length;E++)if(D=a[E]){if(a[E]=null,D.nodeType==8){if(D.data.startsWith(`$s`))w++||(T=D);else if(w&&D.data.startsWith(`/$s`)&&!--w)break}else if(!w)break}}if(!T){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;T=s}(u=ft(T=t.__c.__z||(t.__c.__z=T)))?(t.__e=T,s=u):t.__e=s,s=s&&s.nextSibling}else a&&a.some(Ye)}else t.__e=n.__e;t.__k||(t.__k=n.__k||[]),e.then||pt(t),P.__e(e,t,n)}}else s=t.__e=ht(n.__e,t,n,r,i,a,o,c,l,e);return(u=P.diffed)&&u(t),s}function ft(e,t){if(e&&e.nodeType==8&&e.data.startsWith(`$s`))for(var n=1;e=e.nextSibling;){if(e.nodeType==8){if(e.data.startsWith(`$s`))n++;else if(e.data.startsWith(`/$s`)&&!--n)return e}t&&t.push(e)}}function pt(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(pt))}function mt(e,t,n){for(var r=0;r<n.length;)gt(n[r++],n[r++],n[r++]);P.__c&&P.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){P.__e(e,t.__v)}})}function ht(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y=n.props||Ue,b=t.props,x=t.type;if(x==`svg`?i=`http://www.w3.org/2000/svg`:x==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||(i=`http://www.w3.org/1999/xhtml`),a){for(u=0;u<a.length;u++)if((m=a[u])&&(x?m.localName==x:m.nodeType==3)){e=m,a[u]=null;break}}if(!e){if(_=l.ownerDocument||document,!x)return _.createTextNode(b);e=_.createElementNS(i,x,b.is&&b),s&&(P.__m&&P.__m(t,a),s=!1),a=null}if(x){if(l=x==`template`?e.content:e,a=x==`textarea`&&b.defaultValue!=null?null:a&&qe.call(l.childNodes),!s&&a)for(y={},u=0;u<e.attributes.length;u++)y[(m=e.attributes[u]).name]=m.value;for(u in y)m=y[u],u==`dangerouslySetInnerHTML`?f=m:u==`children`||u in b||u==`value`&&`defaultValue`in b||u==`checked`&&`defaultChecked`in b||lt(e,u,null,m,i);for(u in v=1&n.__u,b)m=b[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||!(y[u]!==m||v&&m!=null)||lt(e,u,m,y[u],i);d?(s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[]):(f&&(e.textContent=``),(x==`foreignObject`||i==`http://www.w3.org/1998/Math/MathML`&&Ge.test(x))&&(i=`http://www.w3.org/1999/xhtml`),rt(l,Ke(p)?p:[p],t,n,r,i,a,o,a?a[0]:n.__k&&$e(n,0),s,c),a&&a.some(Ye)),s&&x!=`textarea`||(u=`value`,x==`progress`&&h==null?e.removeAttribute(u):h==null||h===e[u]&&(x!=`progress`||h)||lt(e,u,h,y[u],i),u=`checked`,g!=null&&g!=e[u]&&lt(e,u,g,y[u],i))}else y===b||s&&e.data==b||(e.data=b);return e}function gt(e,t,n,r){try{typeof e==`function`?t?t.__x=e(t)||1:r&&(r=r.__c||r.__e)&&(t=r.__x)&&(r.__x=null,typeof t==`function`?t():e(null)):e.current=t}catch(e){P.__e(e,n)}}function _t(e,t,n){var r,i,a,o;if(P.unmount&&P.unmount(e),!(r=e.ref)||r.current&&r.current!=e.__e||gt(r,null,t,e),r=e.__c){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){P.__e(e,t)}r.__P=r.__n=null}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&_t(r[o],t,typeof e.type!=`function`||n&&!e.props.__P);!n&&(r=e.__c)&&(r=r.__z)&&(i=ft(r,a=[]))&&(r==e.__e&&a.some(Ye),Ye(i),Ye(r)),(r=e.__e)&&(n||Ye(r),r.__e&&(r.__e=null)),e.__e=e.__c=e.__=null}function vt(e,t,n){return this.constructor(e,n)}function yt(e,t){var n,r,i,a;P.__&&P.__(e,t),t.nodeType==9&&(t=t.documentElement),r=(n=e&&32&e.__u)?null:t.__k,t.__k=Ze(I,{children:[e]}),i=[],a=[],dt(t,t.__k,r||Ue,Ue,t.namespaceURI,r?null:t.firstChild?qe.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a),mt(i,t.__k,a),t.__k.props.children=null}P={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((o=(a=i.constructor)&&a.getDerivedStateFromError)&&i.setState(a.getDerivedStateFromError(e)),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),o=1),o&&8&i.__g)return void(i.__g|=2)}catch(t){e=t}}throw Le=0,e}},Ne=0,Pe=function(e){return e!=null&&e.constructor===F},Qe.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=Je({},this.state)),typeof e==`function`&&(e=e(Je({},n),this.props)),e&&(Je(n,e),this.__v&&(t&&this.__k.push(t),tt(this)))},Qe.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),tt(this))},Qe.prototype.render=I,Fe=[],Le=0,Re=function(e,t){return e.__v.__b-t.__v.__b},ze=Symbol(),Be=/(PointerCapture)$|Capture$/i,Ve=0,He={};function bt(e,t){if(e?.length&&t)return e.find(e=>e.locale===t)}function xt(e,t){let{translations:n,defaultLocale:r,...i}=e,a=bt(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description,content:a.content??i.content}:i}function St(e,t){let{translations:n,defaultLocale:r,...i}=e,a=bt(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description}:i}function Ct(e,t){let{translations:n,defaultLocale:r,...i}=e,a=bt(n,t);if(!a)return i;let o=new Map((a.fields??[]).map(e=>[e.name,e])),s=i.fields.map(e=>{let t=o.get(e.name);if(!t)return e;let n=new Map((t.options??[]).map(e=>[e.value,e]));return{...e,label:t.label??e.label,placeholder:t.placeholder??e.placeholder,validationHint:t.validationHint??e.validationHint,options:e.options?.map(e=>{let t=n.get(e.value);return t?{...e,label:t.label??e.label,description:t.description??e.description}:e})}});return{...i,title:a.title??i.title,description:a.description??i.description,submitLabel:a.submitLabel??i.submitLabel,fields:s}}const wt={attach:`Attach files`,attachmentMimeRejected:`File type not supported`,attachmentTooLarge:`File is too large`,attachmentTooMany:`Attachment limit reached`,conversationClosed:`This chat is closed`,conversationLoading:`Loading chat…`,loadPreviousMessages:`Load previous messages`,close:`Close`,collapse:`Collapse`,collapseSidebar:`Collapse sidebar`,composerPlaceholder:`Type a message…`,dateLastWeek:`Last 7 days`,dateOlder:`Older`,dateToday:`Today`,dateYesterday:`Yesterday`,dropZone:`Drop files to attach`,errorGeneric:`Something went wrong`,errorRateLimited:`Too many requests — please try again in a moment.`,errorRetry:`Retry`,expand:`Expand`,expandSidebar:`Expand sidebar`,exitFullscreen:`Exit fullscreen`,fullscreen:`Fullscreen`,history:`History`,historyBack:`Back to chat`,historyEmpty:`No previous chats yet`,historyLoading:`Loading your chats…`,historyContinue:`Continue the chat`,historyTitle:`Chat history`,loadMoreConversations:`Load more conversations`,language:`Language`,launcherOpen:`Open chat`,launcherLabel:`Chat with us`,micStart:`Start voice input`,micStop:`Stop voice input`,micUnsupported:`Voice input is not supported in this browser`,moreActions:`More actions`,newConversation:`New chat`,panelTitle:`Chat`,popOut:`Open in new tab`,resizeHandle:`Drag to resize`,scrollToBottom:`Scroll to latest`,send:`Send`,queueMessage:`Queue message`,removeQueuedMessage:`Remove queued message`,compactingContext:`Optimizing conversation context…`,soundOff:`Sound off`,soundOn:`Sound on`,startNewConversation:`Start a new chat`,talkToOperator:`Talk to a person`,connectingOperator:`Connecting you to a person…`,noOperatorAvailable:`No one's available right now — leave your details and we'll follow up.`,chattingWithOperator:`You're chatting with {operator}`,cancelOperatorRequest:`Keep chatting with the AI`,stop:`Stop`,theme:`Theme`,themeAuto:`Auto`,themeDark:`Dark`,themeLight:`Light`,textSize:`Text size`,textSizeSmall:`Small`,textSizeNormal:`Normal`,textSizeLarge:`Large`,loading:`Loading…`,visualPreparing:`Preparing visual…`,visualError:`This visual could not be displayed.`,visualPartial:`Some parts of this visual could not be displayed.`,thinking:`Thinking…`,thoughts:`Thoughts`,toolResult:`Result`,sources:`Sources`,feedbackUp:`Good response`,feedbackDown:`Bad response`,feedbackThanks:`Thanks for your feedback`,copy:`Copy`,copied:`Copied`,tabHome:`Home`,tabConversations:`Chats`,tabHelp:`Help`,tabNews:`News`,modulesEmpty:`Nothing here yet`,moduleBack:`Back`,contentLoading:`Loading…`,contentHelpful:`Was this helpful?`,homeGreeting:`How can we help?`,homeGreetingNamed:`Hi {name} 👋`,homeGreetingLead:`How can we help?`,homeSearchPlaceholder:`Search for help`,homeAskPlaceholder:`Ask a question…`,homeWhatsNew:`What's new`,homeContentTitle:`Popular articles`,homeStatus:`Status`,helpTitle:`Help`,helpSearchPlaceholder:`Search for help`,helpEmpty:`No help articles yet`,helpLoading:`Loading help…`,helpSearchEmpty:`No results for “{query}”`,helpShowMore:`Show more`,newsTitle:`News`,newsEmpty:`No news yet`,newsLoading:`Loading news…`,newsBack:`Back to news`,newsPublishedAt:`Published {date}`,newsShowMore:`Show more`,newsUnseen:`New post`,formSubmit:`Submit`,formSkip:`Maybe later`,formSubmitted:`Completed`,formSkipped:`Maybe later`,formFillOut:`Fill out`,formRequired:`This field is required`,formInvalidEmail:`Enter a valid email address`,formInvalidTel:`Enter a valid phone number`,formInvalidUrl:`Enter a valid URL`,formInvalidNumber:`Enter a valid number`,formTooShort:`Too short (min {min} characters)`,formTooLong:`Too long (max {max} characters)`,formNumberTooSmall:`Must be at least {min}`,formNumberTooLarge:`Must be at most {max}`,formPatternMismatch:`Please match the requested format`,formChooseAtLeast:`Choose at least {min}`,formChooseAtMost:`Choose at most {max}`,formOther:`Other`,formOtherPlaceholder:`Type your answer…`,inputRequired:`Questions for you`,inputBadge:`Questions`,inputAnswered:`Answered`,inputSkipped:`Skipped`,showOptions:`Show options`,hideOptions:`Hide options`,qtypeText:`Your answer`,qtypeEmail:`Email address`,qtypePhone:`Phone number`,qtypeNumber:`Number`,qtypeDate:`Date`,qtypeChooseOne:`Pick one`,qtypeChooseAny:`Pick any`,qtypeBoolean:`Yes / No`,inputSubmit:`Submit answers`,inputSubmitHint:`Enter to send · Shift+Enter = new line`,inputSkip:`Skip`,confirmYes:`Yes`,confirmNo:`No`,approve:`Approve`,reject:`Reject`,approvalPrompt:`{tool} requires your approval to execute.`,approvalBody:`Review the tool input above and decide whether to allow this action.`,approvalYourResponse:`Your response: {decision}`,approvalEditHint:`You can edit this response until this step continues.`,approvalSubmitting:`Response submitted. Request in progress…`,edit:`Edit`,toolParameters:`Parameters`,statusAwaiting:`Awaiting Approval`,statusResponded:`Submitted`,statusRunning:`Running`,statusCompleted:`Completed`,statusDenied:`Denied`,statusError:`Error`,statusSuperseded:`Skipped`,statusIncomplete:`Not completed`},Tt={en:wt,fr:{attach:`Joindre des fichiers`,attachmentMimeRejected:`Type de fichier non pris en charge`,attachmentTooLarge:`Le fichier est trop volumineux`,attachmentTooMany:`Limite de pièces jointes atteinte`,conversationClosed:`Ce chat est fermé`,conversationLoading:`Chargement du chat…`,loadPreviousMessages:`Charger les messages précédents`,close:`Fermer`,collapse:`Réduire`,collapseSidebar:`Réduire la barre latérale`,composerPlaceholder:`Écrivez un message…`,dateLastWeek:`7 derniers jours`,dateOlder:`Plus ancien`,dateToday:`Aujourd'hui`,dateYesterday:`Hier`,dropZone:`Déposez les fichiers à joindre`,errorGeneric:`Une erreur s'est produite`,errorRateLimited:`Trop de requêtes — veuillez réessayer dans un instant.`,errorRetry:`Réessayer`,expand:`Agrandir`,expandSidebar:`Développer la barre latérale`,exitFullscreen:`Quitter le plein écran`,fullscreen:`Plein écran`,history:`Historique`,historyBack:`Retour au chat`,historyEmpty:`Aucun chat pour le moment`,historyContinue:`Poursuivre le chat`,historyLoading:`Chargement de vos chats…`,historyTitle:`Historique des chats`,loadMoreConversations:`Charger plus de conversations`,language:`Langue`,launcherOpen:`Ouvrir le chat`,launcherLabel:`Discuter avec nous`,micStart:`Démarrer la saisie vocale`,micStop:`Arrêter la saisie vocale`,micUnsupported:`La saisie vocale n'est pas prise en charge par ce navigateur`,moreActions:`Plus d'actions`,newConversation:`Nouveau chat`,panelTitle:`Chat`,popOut:`Ouvrir dans un nouvel onglet`,resizeHandle:`Glisser pour redimensionner`,scrollToBottom:`Aller au plus récent`,send:`Envoyer`,queueMessage:`Mettre le message en attente`,removeQueuedMessage:`Retirer le message en attente`,compactingContext:`Optimisation du contexte de la conversation…`,soundOff:`Son désactivé`,soundOn:`Son activé`,startNewConversation:`Démarrer un nouveau chat`,talkToOperator:`Parler à une personne`,connectingOperator:`Mise en relation avec une personne…`,noOperatorAvailable:`Personne n'est disponible pour le moment — laissez vos coordonnées et nous reviendrons vers vous.`,chattingWithOperator:`Vous discutez avec {operator}`,cancelOperatorRequest:`Continuer avec l'IA`,stop:`Arrêter`,theme:`Thème`,themeAuto:`Auto`,themeDark:`Sombre`,themeLight:`Clair`,textSize:`Taille du texte`,textSizeSmall:`Petite`,textSizeNormal:`Normale`,textSizeLarge:`Grande`,loading:`Chargement…`,visualPreparing:`Préparation du visuel…`,visualError:`Ce visuel n’a pas pu être affiché.`,visualPartial:`Certaines parties de ce visuel n’ont pas pu être affichées.`,thinking:`Réflexion…`,thoughts:`Réflexions`,toolResult:`Résultat`,sources:`Sources`,feedbackUp:`Bonne réponse`,feedbackDown:`Mauvaise réponse`,feedbackThanks:`Merci pour votre retour`,copy:`Copier`,copied:`Copié`,tabHome:`Accueil`,tabConversations:`Chats`,tabHelp:`Aide`,tabNews:`Actualités`,modulesEmpty:`Rien pour le moment`,moduleBack:`Retour`,contentLoading:`Chargement…`,contentHelpful:`Cela vous a-t-il aidé ?`,homeGreeting:`Comment pouvons-nous vous aider ?`,homeGreetingNamed:`Bonjour {name} 👋`,homeGreetingLead:`Comment pouvons-nous vous aider ?`,homeSearchPlaceholder:`Rechercher de l'aide`,homeAskPlaceholder:`Posez une question…`,homeWhatsNew:`Nouveautés`,homeContentTitle:`Articles populaires`,homeStatus:`Statut`,helpTitle:`Aide`,helpSearchPlaceholder:`Rechercher de l'aide`,helpEmpty:`Aucun article d'aide pour le moment`,helpLoading:`Chargement de l'aide…`,helpSearchEmpty:`Aucun résultat pour «\xA0{query}\xA0»`,helpShowMore:`Afficher plus`,newsTitle:`Actualités`,newsEmpty:`Aucune actualité pour le moment`,newsLoading:`Chargement des actualités…`,newsBack:`Retour aux actualités`,newsPublishedAt:`Publié le {date}`,newsShowMore:`Afficher plus`,newsUnseen:`Nouvelle publication`,formSubmit:`Envoyer`,formSkip:`Plus tard`,formSubmitted:`Terminé`,formSkipped:`Plus tard`,formFillOut:`Remplir`,formRequired:`Ce champ est obligatoire`,formInvalidEmail:`Saisissez une adresse e-mail valide`,formInvalidTel:`Saisissez un numéro de téléphone valide`,formInvalidUrl:`Saisissez une URL valide`,formInvalidNumber:`Saisissez un nombre valide`,formTooShort:`Trop court (min. {min} caractères)`,formTooLong:`Trop long (max. {max} caractères)`,formNumberTooSmall:`Doit être au moins {min}`,formNumberTooLarge:`Doit être au plus {max}`,formPatternMismatch:`Veuillez respecter le format demandé`,formChooseAtLeast:`Choisissez au moins {min}`,formChooseAtMost:`Choisissez au plus {max}`,formOther:`Autre`,formOtherPlaceholder:`Saisissez votre réponse…`,inputRequired:`Questions pour vous`,inputBadge:`Questions`,inputAnswered:`Répondu`,inputSkipped:`Ignoré`,showOptions:`Afficher les options`,hideOptions:`Masquer les options`,qtypeText:`Votre réponse`,qtypeEmail:`Adresse e-mail`,qtypePhone:`Numéro de téléphone`,qtypeNumber:`Nombre`,qtypeDate:`Date`,qtypeChooseOne:`Choisir une`,qtypeChooseAny:`Choisir plusieurs`,qtypeBoolean:`Oui / Non`,inputSubmit:`Envoyer les réponses`,inputSubmitHint:`Entrée pour envoyer · Maj+Entrée = saut de ligne`,inputSkip:`Ignorer`,confirmYes:`Oui`,confirmNo:`Non`,approve:`Approuver`,reject:`Refuser`,approvalPrompt:`{tool} nécessite votre approbation pour s'exécuter.`,approvalBody:`Vérifiez les paramètres ci-dessus et décidez d'autoriser ou non cette action.`,approvalYourResponse:`Votre réponse : {decision}`,approvalEditHint:`Vous pouvez modifier votre réponse jusqu'à la reprise de cette étape.`,approvalSubmitting:`Réponse envoyée. Traitement en cours…`,edit:`Modifier`,toolParameters:`Paramètres`,statusAwaiting:`En attente d'approbation`,statusResponded:`Envoyé`,statusRunning:`En cours`,statusCompleted:`Terminé`,statusDenied:`Refusé`,statusError:`Erreur`,statusSuperseded:`Ignoré`,statusIncomplete:`Non terminé`},ar:{attach:`إرفاق ملفات`,attachmentMimeRejected:`نوع الملف غير مدعوم`,attachmentTooLarge:`حجم الملف كبير جدًا`,attachmentTooMany:`تم بلوغ الحد الأقصى للمرفقات`,conversationClosed:`تم إغلاق هذه الدردشة`,conversationLoading:`جارٍ تحميل الدردشة…`,loadPreviousMessages:`تحميل الرسائل السابقة`,close:`إغلاق`,collapse:`طيّ`,collapseSidebar:`طيّ الشريط الجانبي`,composerPlaceholder:`اكتب رسالة…`,dateLastWeek:`آخر ٧ أيام`,dateOlder:`أقدم`,dateToday:`اليوم`,dateYesterday:`أمس`,dropZone:`أفلت الملفات لإرفاقها`,errorGeneric:`حدث خطأ ما`,errorRateLimited:`طلبات كثيرة جدًا — يرجى المحاولة بعد لحظة.`,errorRetry:`إعادة المحاولة`,expand:`توسيع`,expandSidebar:`توسيع الشريط الجانبي`,exitFullscreen:`إنهاء ملء الشاشة`,fullscreen:`ملء الشاشة`,history:`السجل`,historyBack:`العودة إلى الدردشة`,historyEmpty:`لا توجد دردشات سابقة بعد`,historyContinue:`متابعة الدردشة`,historyLoading:`جارٍ تحميل دردشاتك…`,historyTitle:`سجل الدردشات`,loadMoreConversations:`تحميل المزيد من المحادثات`,language:`اللغة`,launcherOpen:`فتح الدردشة`,launcherLabel:`تحدث معنا`,micStart:`بدء الإدخال الصوتي`,micStop:`إيقاف الإدخال الصوتي`,micUnsupported:`الإدخال الصوتي غير مدعوم في هذا المتصفح`,moreActions:`إجراءات إضافية`,newConversation:`دردشة جديدة`,panelTitle:`الدردشة`,popOut:`فتح في علامة تبويب جديدة`,resizeHandle:`اسحب لتغيير الحجم`,scrollToBottom:`الانتقال إلى الأحدث`,send:`إرسال`,queueMessage:`إضافة الرسالة إلى قائمة الانتظار`,removeQueuedMessage:`إزالة الرسالة من قائمة الانتظار`,compactingContext:`جارٍ تحسين سياق المحادثة…`,soundOff:`كتم الصوت`,soundOn:`تشغيل الصوت`,startNewConversation:`بدء دردشة جديدة`,talkToOperator:`التحدث إلى شخص`,connectingOperator:`جارٍ توصيلك بشخص…`,noOperatorAvailable:`لا يوجد موظفون متاحون الآن — اترك بياناتك وسنتواصل معك.`,chattingWithOperator:`أنت تتحدث مع {operator}`,cancelOperatorRequest:`متابعة المحادثة مع الذكاء الاصطناعي`,stop:`إيقاف`,theme:`المظهر`,themeAuto:`تلقائي`,themeDark:`داكن`,themeLight:`فاتح`,textSize:`حجم النص`,textSizeSmall:`صغير`,textSizeNormal:`عادي`,textSizeLarge:`كبير`,loading:`جارٍ التحميل…`,visualPreparing:`جارٍ إعداد المحتوى المرئي…`,visualError:`تعذر عرض هذا المحتوى المرئي.`,visualPartial:`تعذر عرض بعض أجزاء هذا المحتوى المرئي.`,thinking:`يفكّر…`,thoughts:`الأفكار`,toolResult:`النتيجة`,sources:`المصادر`,feedbackUp:`رد جيد`,feedbackDown:`رد سيئ`,feedbackThanks:`شكرًا على ملاحظاتك`,copy:`نسخ`,copied:`تم النسخ`,tabHome:`الرئيسية`,tabConversations:`الدردشات`,tabHelp:`المساعدة`,tabNews:`الأخبار`,modulesEmpty:`لا شيء هنا بعد`,moduleBack:`رجوع`,contentLoading:`جارٍ التحميل…`,contentHelpful:`هل كان هذا مفيدًا؟`,homeGreeting:`كيف يمكننا مساعدتك؟`,homeGreetingNamed:`مرحبًا {name} 👋`,homeGreetingLead:`كيف يمكننا مساعدتك؟`,homeSearchPlaceholder:`ابحث عن مساعدة`,homeAskPlaceholder:`اطرح سؤالاً…`,homeWhatsNew:`ما الجديد`,homeContentTitle:`مقالات شائعة`,homeStatus:`الحالة`,helpTitle:`المساعدة`,helpSearchPlaceholder:`ابحث عن مساعدة`,helpEmpty:`لا توجد مقالات مساعدة بعد`,helpLoading:`جارٍ تحميل المساعدة…`,helpSearchEmpty:`لا نتائج لـ «{query}»`,helpShowMore:`عرض المزيد`,newsTitle:`الأخبار`,newsEmpty:`لا توجد أخبار بعد`,newsLoading:`جارٍ تحميل الأخبار…`,newsBack:`العودة إلى الأخبار`,newsPublishedAt:`نُشر في {date}`,newsShowMore:`عرض المزيد`,newsUnseen:`منشور جديد`,formSubmit:`إرسال`,formSkip:`لاحقًا`,formSubmitted:`تم`,formSkipped:`لاحقًا`,formFillOut:`تعبئة`,formRequired:`هذا الحقل مطلوب`,formInvalidEmail:`أدخل بريدًا إلكترونيًا صحيحًا`,formInvalidTel:`أدخل رقم هاتف صحيحًا`,formInvalidUrl:`أدخل رابطًا صحيحًا`,formInvalidNumber:`أدخل رقمًا صحيحًا`,formTooShort:`قصير جدًا (الحد الأدنى {min} حرفًا)`,formTooLong:`طويل جدًا (الحد الأقصى {max} حرفًا)`,formNumberTooSmall:`يجب ألا يقل عن {min}`,formNumberTooLarge:`يجب ألا يزيد عن {max}`,formPatternMismatch:`يرجى مطابقة الصيغة المطلوبة`,formChooseAtLeast:`اختر {min} على الأقل`,formChooseAtMost:`اختر {max} على الأكثر`,formOther:`أخرى`,formOtherPlaceholder:`اكتب إجابتك…`,inputRequired:`أسئلة لك`,inputBadge:`أسئلة`,inputAnswered:`تمت الإجابة`,inputSkipped:`تم التخطي`,showOptions:`إظهار الخيارات`,hideOptions:`إخفاء الخيارات`,qtypeText:`إجابتك`,qtypeEmail:`عنوان البريد الإلكتروني`,qtypePhone:`رقم الهاتف`,qtypeNumber:`رقم`,qtypeDate:`تاريخ`,qtypeChooseOne:`اختر واحدًا`,qtypeChooseAny:`اختر أيًا`,qtypeBoolean:`نعم / لا`,inputSubmit:`إرسال الإجابات`,inputSubmitHint:`Enter للإرسال · Shift+Enter = سطر جديد`,inputSkip:`تخطٍّ`,confirmYes:`نعم`,confirmNo:`لا`,approve:`موافقة`,reject:`رفض`,approvalPrompt:`تتطلب {tool} موافقتك للتنفيذ.`,approvalBody:`راجع مُعطيات الأداة أعلاه وقرّر السماح بهذا الإجراء أو رفضه.`,approvalYourResponse:`ردّك: {decision}`,approvalEditHint:`يمكنك تعديل ردّك حتى تستأنف هذه الخطوة.`,approvalSubmitting:`تم إرسال الرد. جارٍ التنفيذ…`,edit:`تعديل`,toolParameters:`المعطيات`,statusAwaiting:`بانتظار الموافقة`,statusResponded:`تم الإرسال`,statusRunning:`قيد التنفيذ`,statusCompleted:`مكتمل`,statusDenied:`مرفوض`,statusError:`خطأ`,statusSuperseded:`تم التخطي`,statusIncomplete:`لم يكتمل`},es:{attach:`Adjuntar archivos`,attachmentMimeRejected:`Tipo de archivo no admitido`,attachmentTooLarge:`El archivo es demasiado grande`,attachmentTooMany:`Se alcanzó el límite de adjuntos`,conversationClosed:`Este chat está cerrado`,conversationLoading:`Cargando chat…`,loadPreviousMessages:`Cargar mensajes anteriores`,close:`Cerrar`,collapse:`Contraer`,collapseSidebar:`Contraer la barra lateral`,composerPlaceholder:`Escribe un mensaje…`,dateLastWeek:`Últimos 7 días`,dateOlder:`Anteriores`,dateToday:`Hoy`,dateYesterday:`Ayer`,dropZone:`Suelta los archivos para adjuntarlos`,errorGeneric:`Algo salió mal`,errorRateLimited:`Demasiadas solicitudes: inténtalo de nuevo en un momento.`,errorRetry:`Reintentar`,expand:`Ampliar`,expandSidebar:`Expandir la barra lateral`,exitFullscreen:`Salir de pantalla completa`,fullscreen:`Pantalla completa`,history:`Historial`,historyBack:`Volver al chat`,historyEmpty:`Aún no tienes chats`,historyContinue:`Continuar el chat`,historyLoading:`Cargando tus chats…`,historyTitle:`Historial de chats`,loadMoreConversations:`Cargar más conversaciones`,language:`Idioma`,launcherOpen:`Abrir el chat`,launcherLabel:`Chatea con nosotros`,micStart:`Iniciar entrada de voz`,micStop:`Detener entrada de voz`,micUnsupported:`Este navegador no admite la entrada de voz`,moreActions:`Más acciones`,newConversation:`Nuevo chat`,panelTitle:`Chat`,popOut:`Abrir en una pestaña nueva`,resizeHandle:`Arrastra para cambiar el tamaño`,scrollToBottom:`Ir a lo más reciente`,send:`Enviar`,queueMessage:`Poner mensaje en cola`,removeQueuedMessage:`Quitar mensaje de la cola`,compactingContext:`Optimizando el contexto de la conversación…`,soundOff:`Sonido desactivado`,soundOn:`Sonido activado`,startNewConversation:`Iniciar un chat nuevo`,talkToOperator:`Hablar con una persona`,connectingOperator:`Conectándote con una persona…`,noOperatorAvailable:`Nadie está disponible ahora — deja tus datos y te contactaremos.`,chattingWithOperator:`Estás chateando con {operator}`,cancelOperatorRequest:`Seguir con la IA`,stop:`Detener`,theme:`Tema`,themeAuto:`Automático`,themeDark:`Oscuro`,themeLight:`Claro`,textSize:`Tamaño del texto`,textSizeSmall:`Pequeño`,textSizeNormal:`Normal`,textSizeLarge:`Grande`,loading:`Cargando…`,visualPreparing:`Preparando visualización…`,visualError:`No se pudo mostrar esta visualización.`,visualPartial:`No se pudieron mostrar algunas partes de esta visualización.`,thinking:`Pensando…`,thoughts:`Razonamiento`,toolResult:`Resultado`,sources:`Fuentes`,feedbackUp:`Buena respuesta`,feedbackDown:`Mala respuesta`,feedbackThanks:`Gracias por tu opinión`,copy:`Copiar`,copied:`Copiado`,tabHome:`Inicio`,tabConversations:`Chats`,tabHelp:`Ayuda`,tabNews:`Novedades`,modulesEmpty:`Aún no hay nada aquí`,moduleBack:`Atrás`,contentLoading:`Cargando…`,contentHelpful:`¿Te resultó útil?`,homeGreeting:`¿Cómo podemos ayudarte?`,homeGreetingNamed:`Hola, {name} 👋`,homeGreetingLead:`¿Cómo podemos ayudarte?`,homeSearchPlaceholder:`Buscar ayuda`,homeAskPlaceholder:`Haz una pregunta…`,homeWhatsNew:`Lo nuevo`,homeContentTitle:`Artículos populares`,homeStatus:`Estado`,helpTitle:`Ayuda`,helpSearchPlaceholder:`Buscar ayuda`,helpEmpty:`Aún no hay artículos de ayuda`,helpLoading:`Cargando la ayuda…`,helpSearchEmpty:`Sin resultados para «{query}»`,helpShowMore:`Mostrar más`,newsTitle:`Novedades`,newsEmpty:`Aún no hay novedades`,newsLoading:`Cargando novedades…`,newsBack:`Volver a novedades`,newsPublishedAt:`Publicado el {date}`,newsShowMore:`Mostrar más`,newsUnseen:`Publicación nueva`,formSubmit:`Enviar`,formSkip:`Quizá más tarde`,formSubmitted:`Completado`,formSkipped:`Quizá más tarde`,formFillOut:`Completar`,formRequired:`Este campo es obligatorio`,formInvalidEmail:`Introduce un correo electrónico válido`,formInvalidTel:`Introduce un número de teléfono válido`,formInvalidUrl:`Introduce una URL válida`,formInvalidNumber:`Introduce un número válido`,formTooShort:`Demasiado corto (mín. {min} caracteres)`,formTooLong:`Demasiado largo (máx. {max} caracteres)`,formNumberTooSmall:`Debe ser al menos {min}`,formNumberTooLarge:`Debe ser como máximo {max}`,formPatternMismatch:`Respeta el formato solicitado`,formChooseAtLeast:`Elige al menos {min}`,formChooseAtMost:`Elige como máximo {max}`,formOther:`Otro`,formOtherPlaceholder:`Escribe tu respuesta…`,inputRequired:`Preguntas para ti`,inputBadge:`Preguntas`,inputAnswered:`Respondido`,inputSkipped:`Omitido`,showOptions:`Mostrar opciones`,hideOptions:`Ocultar opciones`,qtypeText:`Tu respuesta`,qtypeEmail:`Correo electrónico`,qtypePhone:`Número de teléfono`,qtypeNumber:`Número`,qtypeDate:`Fecha`,qtypeChooseOne:`Elige una`,qtypeChooseAny:`Elige varias`,qtypeBoolean:`Sí / No`,inputSubmit:`Enviar respuestas`,inputSubmitHint:`Enter para enviar · Mayús+Enter = nueva línea`,inputSkip:`Omitir`,confirmYes:`Sí`,confirmNo:`No`,approve:`Aprobar`,reject:`Rechazar`,approvalPrompt:`{tool} requiere tu aprobación para ejecutarse.`,approvalBody:`Revisa los parámetros de arriba y decide si permites esta acción.`,approvalYourResponse:`Tu respuesta: {decision}`,approvalEditHint:`Puedes cambiar tu respuesta hasta que este paso continúe.`,approvalSubmitting:`Respuesta enviada. Procesando…`,edit:`Editar`,toolParameters:`Parámetros`,statusAwaiting:`Esperando aprobación`,statusResponded:`Enviado`,statusRunning:`En curso`,statusCompleted:`Completado`,statusDenied:`Denegado`,statusError:`Error`,statusSuperseded:`Omitido`,statusIncomplete:`No completado`},he:{attach:`צירוף קבצים`,attachmentMimeRejected:`סוג הקובץ אינו נתמך`,attachmentTooLarge:`הקובץ גדול מדי`,attachmentTooMany:`הגעת למספר המרבי של קבצים מצורפים`,conversationClosed:`הצ׳אט הזה נסגר`,conversationLoading:`טוען צ׳אט…`,loadPreviousMessages:`טעינת הודעות קודמות`,close:`סגירה`,collapse:`כיווץ`,collapseSidebar:`כיווץ סרגל הצד`,composerPlaceholder:`כתוב הודעה…`,dateLastWeek:`7 הימים האחרונים`,dateOlder:`ישן יותר`,dateToday:`היום`,dateYesterday:`אתמול`,dropZone:`שחרר קבצים כדי לצרף`,errorGeneric:`משהו השתבש`,errorRateLimited:`יותר מדי בקשות — נסה שוב בעוד רגע.`,errorRetry:`נסה שוב`,expand:`הרחבה`,expandSidebar:`הרחבת סרגל הצד`,exitFullscreen:`יציאה ממסך מלא`,fullscreen:`מסך מלא`,history:`היסטוריה`,historyBack:`חזרה לצ׳אט`,historyEmpty:`אין עדיין צ׳אטים קודמים`,historyContinue:`המשך צ׳אט`,historyLoading:`טוען את הצ׳אטים שלך…`,historyTitle:`היסטוריית צ׳אטים`,loadMoreConversations:`טעינת שיחות נוספות`,language:`שפה`,launcherOpen:`פתיחת צ׳אט`,launcherLabel:`דברו איתנו`,micStart:`התחלת קלט קולי`,micStop:`עצירת קלט קולי`,micUnsupported:`קלט קולי אינו נתמך בדפדפן זה`,moreActions:`פעולות נוספות`,newConversation:`צ׳אט חדש`,panelTitle:`צ׳אט`,popOut:`פתיחה בכרטיסייה חדשה`,resizeHandle:`גרור לשינוי הגודל`,scrollToBottom:`מעבר לחדש ביותר`,send:`שליחה`,queueMessage:`הוספת ההודעה לתור`,removeQueuedMessage:`הסרת ההודעה מהתור`,compactingContext:`מבצע אופטימיזציה להקשר השיחה…`,soundOff:`השתקת הצליל`,soundOn:`הפעלת הצליל`,startNewConversation:`התחלת צ׳אט חדש`,talkToOperator:`דברו עם אדם`,connectingOperator:`מחברים אותך לאדם…`,noOperatorAvailable:`אין נציגים זמינים כעת — השאר את הפרטים שלך ונחזור אליך.`,chattingWithOperator:`אתה מצ׳וטט עם {operator}`,cancelOperatorRequest:`המשך לשוחח עם ה-AI`,stop:`עצירה`,theme:`ערכת נושא`,themeAuto:`אוטומטי`,themeDark:`כהה`,themeLight:`בהיר`,textSize:`גודל טקסט`,textSizeSmall:`קטן`,textSizeNormal:`רגיל`,textSizeLarge:`גדול`,loading:`טוען…`,visualPreparing:`מכין תצוגה…`,visualError:`לא ניתן היה להציג תצוגה זו.`,visualPartial:`לא ניתן היה להציג חלקים מתצוגה זו.`,thinking:`חושב…`,thoughts:`מחשבות`,toolResult:`תוצאה`,sources:`מקורות`,feedbackUp:`תשובה טובה`,feedbackDown:`תשובה גרועה`,feedbackThanks:`תודה על המשוב`,copy:`העתק`,copied:`הועתק`,tabHome:`בית`,tabConversations:`צ׳אטים`,tabHelp:`עזרה`,tabNews:`חדשות`,modulesEmpty:`אין כאן עדיין כלום`,moduleBack:`חזרה`,contentLoading:`טוען…`,contentHelpful:`האם זה עזר?`,homeGreeting:`כיצד נוכל לעזור?`,homeGreetingNamed:`שלום {name} 👋`,homeGreetingLead:`כיצד נוכל לעזור?`,homeSearchPlaceholder:`חיפוש עזרה`,homeAskPlaceholder:`שאלו שאלה…`,homeWhatsNew:`מה חדש`,homeContentTitle:`מאמרים פופולריים`,homeStatus:`סטטוס`,helpTitle:`עזרה`,helpSearchPlaceholder:`חיפוש עזרה`,helpEmpty:`אין עדיין מאמרי עזרה`,helpLoading:`טוען עזרה…`,helpSearchEmpty:`אין תוצאות עבור „{query}”`,helpShowMore:`הצגת עוד`,newsTitle:`חדשות`,newsEmpty:`אין עדיין חדשות`,newsLoading:`טוען חדשות…`,newsBack:`חזרה לחדשות`,newsPublishedAt:`פורסם ב-{date}`,newsShowMore:`הצגת עוד`,newsUnseen:`פוסט חדש`,formSubmit:`שליחה`,formSkip:`אחר כך`,formSubmitted:`נשלח`,formSkipped:`דולג`,formFillOut:`מילוי`,formRequired:`שדה חובה`,formInvalidEmail:`הזן כתובת אימייל תקינה`,formInvalidTel:`הזן מספר טלפון תקין`,formInvalidUrl:`הזן כתובת URL תקינה`,formInvalidNumber:`הזן מספר תקין`,formTooShort:`קצר מדי (לפחות {min} תווים)`,formTooLong:`ארוך מדי (לכל היותר {max} תווים)`,formNumberTooSmall:`חייב להיות לפחות {min}`,formNumberTooLarge:`חייב להיות לכל היותר {max}`,formPatternMismatch:`התאם לתבנית הנדרשת`,formChooseAtLeast:`בחר לפחות {min}`,formChooseAtMost:`בחר לכל היותר {max}`,formOther:`אחר`,formOtherPlaceholder:`כתוב את תשובתך…`,inputRequired:`שאלות עבורך`,inputBadge:`שאלות`,inputAnswered:`נענה`,inputSkipped:`דולג`,showOptions:`הצג אפשרויות`,hideOptions:`הסתר אפשרויות`,qtypeText:`התשובה שלך`,qtypeEmail:`כתובת אימייל`,qtypePhone:`מספר טלפון`,qtypeNumber:`מספר`,qtypeDate:`תאריך`,qtypeChooseOne:`בחר אחת`,qtypeChooseAny:`בחר כמה`,qtypeBoolean:`כן / לא`,inputSubmit:`שליחת תשובות`,inputSubmitHint:`Enter לשליחה · Shift+Enter = שורה חדשה`,inputSkip:`דילוג`,confirmYes:`כן`,confirmNo:`לא`,approve:`אישור`,reject:`דחייה`,approvalPrompt:`הכלי {tool} דורש את אישורך כדי לפעול.`,approvalBody:`בדוק את פרמטרי הכלי שלמעלה והחלט אם לאשר פעולה זו.`,approvalYourResponse:`התגובה שלך: {decision}`,approvalEditHint:`ניתן לערוך את תגובתך עד שהשלב הזה יתחדש.`,approvalSubmitting:`התגובה נשלחה. מבצע…`,edit:`עריכה`,toolParameters:`פרמטרים`,statusAwaiting:`ממתין לאישור`,statusResponded:`נשלח`,statusRunning:`פועל`,statusCompleted:`הושלם`,statusDenied:`נדחה`,statusError:`שגיאה`,statusSuperseded:`דולג`,statusIncomplete:`לא הושלם`}};function Et(e,t){let n=Dt(e),r=jt(t),i=n===`en`?{}:Tt[n]??{},a=r?t[n]??{}:t??{},o=r?t.en??{}:{};return{...wt,...i,...o,...a}}function Dt(e){return(e.split(`-`)[0]??`en`).toLowerCase()}const Ot=/* @__PURE__ */ new Set([`ar`,`he`,`iw`,`fa`,`ur`,`ps`,`sd`,`ug`,`yi`,`dv`,`ckb`,`ks`,`nqo`,`prs`,`syr`]);function kt(e){return Ot.has(Dt(e))}function At(e,t){return e[t]??t}function jt(e){if(!e)return!1;for(let t of Object.values(e))if(t&&typeof t==`object`)return!0;return!1}const Mt=new class{get(e){try{return localStorage.getItem(e)}catch{return null}}set(e,t){try{localStorage.setItem(e,t)}catch{}}remove(e){try{localStorage.removeItem(e)}catch{}}},Nt={maxBytes:10485760,maxCount:10,accept:`*/*`},Pt={voice:`local`},Ft={list:[],byTrigger:{}},It={enabled:!0,sampleRate:1},Lt={upload:`/pai/upload-file`,transcribe:`/pai/transcribe-audio`,submitForm:`/pai/submit-form`},Rt={variant:`circle`,size:`md`,label:void 0,icon:`chat`,hidden:!1},zt={floating:[`theme`,`textSize`,`history`,`close`,`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`language`],inline:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],standalone:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],page:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],modal:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],drawer:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`]},Bt={enabled:!0,volume:.3,events:void 0},Vt={enabled:!0,events:void 0},Ht=[{label:`tabConversations`,layout:`chat`}],Ut=C.scope(`context`),Wt=/* @__PURE__ */ new Set([`visitorId`,`conversationId`,`jwt`,`token`,`authorization`,`password`]),Gt=1024,Kt=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function qt(e){return Yt(e,`userContext`,!0)}function Jt(e){return Yt(e,`pageContext`,!1)}function Yt(e,t,n){if(e==null)return;if(typeof e!=`object`||Array.isArray(e)){Ut.warn(`ignored ${t} — expected an object`,{type:Array.isArray(e)?`array`:typeof e});return}let r={},i=0;for(let[n,a]of Object.entries(e)){if(Wt.has(n)){Ut.warn(`dropped reserved ${t} key "${n}" — managed by the widget, not host-settable`);continue}if(a==null)continue;if(i>=50){Ut.warn(`${t} truncated at 50 keys — dropped "${n}"`);continue}let e=Xt(t,n,a);e!==void 0&&(r[n]=e,i++)}return n&&typeof r.email==`string`&&!Kt.test(r.email)&&(Ut.warn(`dropped malformed context field`,{field:`${t}.email`,reason:`invalid format`}),delete r.email),Object.keys(r).length>0?r:void 0}function Xt(e,t,n){if(typeof n==`boolean`)return n;if(typeof n==`number`){if(!Number.isFinite(n)){Ut.warn(`dropped non-finite ${e}.${t}`);return}return n}if(typeof n==`string`){let r=n.trim();return r===``?void 0:r.length>Gt?(Ut.warn(`truncated ${e}.${t} to ${Gt} chars`),r.slice(0,Gt)):r}Ut.warn(`dropped ${e}.${t} — only string/number/boolean values are allowed`,{type:typeof n})}function Zt(e){let t=typeof e==`object`&&e?e:{},n=t.presentation??{},r=t.behavior??{},i=t.i18n??{},a=t.feedback??{},o=t.footer??{},s=t.header??{},c={enabled:t.history?.enabled??!0},{themeMode:l,themeOverrides:d}=Qt(t.theme),f=n.mode??`floating`,p=$t(i.defaultLocale),m=i.availableLocales??[i.locale??p],h=en(i.locale??p,m,p),g=(t.baseUrl??u.defaultBaseUrl).replace(/\/$/,``),_=(t.agentApiBaseUrl??`${g}/api/agent`).replace(/\/$/,``),v=(t.dataApiBaseUrl??`${g}/api/data`).replace(/\/$/,``);return{widgetId:t.widgetId??`default`,publicKey:t.publicKey,aiAgentDeploymentId:t.aiAgentDeploymentId,baseUrl:g,agentApiBaseUrl:_,dataApiBaseUrl:v,userContext:qt(t.userContext),pageContext:Jt(t.pageContext),position:n.position??`bottom-right`,themeMode:l,textSize:`normal`,themeOverrides:d,mode:f,iframe:n.iframe??!1,responseMode:r.responseMode??`streaming`,showReasoning:r.showReasoning??!1,showToolCalls:r.showToolCalls??!1,showSources:r.showSources??!1,enableMessageFeedback:!(r.disableMessageFeedback??!1),autoSendSuggestions:r.autoSendSuggestions??!1,popOutUrl:r.popOutUrl,features:{voice:t.features?.voice??Pt.voice,fileUpload:!(t.features?.disableFileUpload??!1),humanInLoop:!(t.features?.disableHumanInLoop??!1),operatorRequest:t.features?.enableOperatorRequest===!0},forms:ln(t.forms,h),endpoints:{upload:t.endpoints?.upload??Lt.upload,transcribe:t.endpoints?.transcribe??Lt.transcribe,submitForm:t.endpoints?.submitForm??Lt.submitForm},attachments:{accept:t.composer?.attachments?.accept??Nt.accept,maxBytes:t.composer?.attachments?.maxBytes??Nt.maxBytes,maxCount:t.composer?.attachments?.maxCount??Nt.maxCount},locale:h,defaultLocale:p,availableLocales:m,startMinimized:r.startMinimized??!0,actions:tn(f,s.actions,c.enabled),size:n.size??{},launcher:dn(t.launcher),sound:nn(a.sound),haptics:rn(a.haptics),strings:Et(h,i.strings),stringsOverride:i.strings,composerDisclaimer:o.composerDisclaimer??``,poweredBy:on(o.poweredBy),composer:sn(t.composer),modules:cn(t.modules,c.enabled),tracking:an(t.tracking,v),history:c,storage:t.storage??Mt,userToken:t.userToken,tools:t.tools,onMessage:t.onMessage,onOpen:t.onOpen,onClose:t.onClose,onError:t.onError}}function Qt(e){if(typeof e==`string`)return{themeMode:e,themeOverrides:{}};if(!e||typeof e!=`object`)return{themeMode:`auto`,themeOverrides:{}};let{mode:t,...n}=e;return{themeMode:t??`auto`,themeOverrides:n}}function $t(e){return e&&e!==`auto`?e:globalThis.navigator?.language||`en`}function en(e,t,n){return t.length<=1||t.includes(e)?e:t.includes(n)?n:t[0]??e}function tn(e,t,n){let r=t??zt[e];return n?r:r.filter(e=>e!==`history`)}function nn(e){return{enabled:e?.enabled??Bt.enabled,volume:e?.volume??Bt.volume,events:e?.events}}function rn(e){return{enabled:e?.enabled??Vt.enabled,events:e?.events}}function an(e,t){let n=e?.sampleRate??It.sampleRate;return{enabled:e?.enabled??It.enabled,endpoint:e?.endpoint??`${t}/pai/elements-px.gif`,sampleRate:Math.min(1,Math.max(0,Number.isFinite(n)?n:1)),token:e?.token}}function on(e){let t={text:`Powered by ${u.displayName}`,href:u.siteUrl,...e};return t.text||t.logoUrl?t:null}function sn(e){let t=e?.sendButton;return{sendButton:{shape:t?.shape??`circle`,icon:t?.icon??`arrowUp`,variant:t?.variant??`filled`}}}function cn(e,t){let n=e??Ht,r=/* @__PURE__ */ new Set,i=[];for(let e of n.slice(0,4)){if(!e?.label||!e?.layout)continue;let n=e.contentCollectionIds?.filter(Boolean),a=e.id??n?.[0]??e.layout;for(;r.has(a);)a=`${a}-${i.length}`;r.add(a);let o={id:a,label:e.label,layout:e.layout};n?.length&&(o.contentCollectionIds=n),e.layout===`home`&&(o.brandName=e.brandName,o.greetingText=e.greetingText,o.showGreeting=!(e.hideGreeting??!1),o.showSearchBar=!(e.hideSearchBar??!1),o.showRecentConversations=t&&!(e.hideRecentConversations??!1),e.userAvatars?.length&&(o.userAvatars=e.userAvatars),e.status&&(o.status=e.status),o.contentBlockTitle=e.contentBlockTitle),i.push(o)}return{list:i,byId:Object.fromEntries(i.map(e=>[e.id,e]))}}function ln(e,t){if(!e?.length)return Ft;let n=[],r=/* @__PURE__ */ new Set;for(let i of e){if(!i?.id||r.has(i.id))continue;let e=Ct(i,t),a=(e.fields??[]).filter(e=>!!(e?.name&&e.label&&e.type)),o=(Array.isArray(e.on)?e.on:[e.on]).map(un).filter(e=>e!==null);a.length!==0&&o.length!==0&&(r.add(e.id),n.push({id:e.id,triggers:o,when:e.when,fields:a,title:e.title,description:e.description,submitLabel:e.submitLabel,skippable:e.skippable??!1,frequency:e.frequency??`once`,mirrorToContext:e.mirrorToContext??!0,reopenable:e.reopenable??!0,reviewable:e.reviewable??!0}))}let i={};for(let e of n){var a;for(let t of e.triggers)(i[a=t.kind]??(i[a]=[])).push(e)}return{list:n,byTrigger:i}}function un(e){if(typeof e!=`string`)return null;if(e===`pre-chat`||e===`conversation-closed`||e===`panel-close`||e===`manual`)return{kind:e};let[t,n]=e.split(`:`,2);if(t===`after-messages`){let e=Number(n);return Number.isFinite(e)&&e>0?{kind:`after-messages`,param:e}:null}if(t===`idle`){let e=Number(n);return Number.isFinite(e)&&e>0?{kind:`idle`,param:e}:null}return t===`page-area`&&n?{kind:`page-area`,param:n}:null}function dn(e){let t=e?.callout?.text?{shape:`pill`,position:`auto`,delayMs:1200,autoDismissMs:0,animated:!0,persistent:!0,...e.callout}:null;return{variant:e?.variant??Rt.variant,size:e?.size??Rt.size,label:e?.label??Rt.label,icon:e?.icon??Rt.icon,hidden:e?.hidden??Rt.hidden,callout:t}}function fn(e,t,n,r){let i=en(t,e.availableLocales,e.defaultLocale);if(i===e.locale&&n===e.themeMode&&r===e.textSize)return e;let a={...e};return i!==e.locale&&(a.locale=i,a.strings=Et(i,e.stringsOverride)),n!==e.themeMode&&(a.themeMode=n),r!==e.textSize&&(a.textSize=r),a}const pn=[`presentation`,`behavior`,`theme`,`launcher`,`header`,`composer`,`feedback`,`i18n`,`footer`,`features`,`tracking`,`endpoints`,`history`];function mn(e,t){if(!t)return e;let n={...e};for(let r of pn){let i=t[r];if(i===void 0)continue;let a=e[r];r===`theme`?a===void 0?n[r]=i:typeof a==`string`&&typeof i==`object`&&i&&(n[r]={...i,mode:a}):r!==`i18n`&&(n[r]=hn(i,a))}t.modules!==void 0&&e.modules===void 0&&(n.modules=t.modules),t.dataApiBaseUrl!==void 0&&e.dataApiBaseUrl===void 0&&(n.dataApiBaseUrl=t.dataApiBaseUrl);let r=e.i18n,i=t.i18n;if(r||i){let e=hn(i??{},r);i?.availableLocales!==void 0&&(e.availableLocales=i.availableLocales),i?.defaultLocale!==void 0&&(e.defaultLocale=i.defaultLocale);let t=r?.strings,a=i?.strings;(t||a)&&(e.strings=gn(a,t)),n.i18n=e}return n}function hn(e,t){if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function gn(e,t){if(!e)return t;if(!t)return e;let n=jt(e),r=jt(t);if(!n&&!r)return{...e,...t};let i={},a=n?e:{en:e},o=r?t:{en:t};for(let[e,t]of Object.entries(a))i[e]={...t};for(let[e,t]of Object.entries(o))i[e]={...i[e],...t};return i}const _n=[`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`history`,`language`,`theme`,`textSize`,`close`];function vn(e){return e!==`false`}const yn=[[`public-key`,`publicKey`],[`ai-agent-deployment-id`,`aiAgentDeploymentId`],[`base-url`,`baseUrl`],[`agent-api-base-url`,`agentApiBaseUrl`],[`data-api-base-url`,`dataApiBaseUrl`],[`theme`,`theme`,e=>e]],bn=[[`mode`,`mode`,e=>e],[`position`,`position`,e=>e],[`iframe`,`iframe`,vn]],xn=[[`width`,`width`],[`height`,`height`]],Sn=[[`response-mode`,`responseMode`,e=>e],[`start-minimized`,`startMinimized`,vn],[`show-reasoning`,`showReasoning`,vn],[`show-tool-calls`,`showToolCalls`,vn],[`show-sources`,`showSources`,vn],[`disable-message-feedback`,`disableMessageFeedback`,vn],[`auto-send-suggestions`,`autoSendSuggestions`,vn],[`pop-out-url`,`popOutUrl`]],Cn=[[`locale`,`locale`]];new Set(_n);const wn=[[`launcher-variant`,`variant`,e=>e],[`launcher-size`,`size`,e=>e],[`launcher-icon`,`icon`],[`launcher-hidden`,`hidden`,vn]],Tn=[[`features-disable-file-upload`,`disableFileUpload`,vn],[`features-voice`,`voice`,e=>e]],En=[[`endpoint-upload`,`upload`],[`endpoint-transcribe`,`transcribe`]],Dn=[[`user-id`,`id`],[`user-email`,`email`],[`user-name`,`name`]],On=[[`page-area`,`area`],[`page-url`,`url`],[`page-path`,`path`],[`page-title`,`title`]],kn=[`launcher-label`,`callout-text`,`callout-delay`,`actions`,`user-context`,`page-context`],An=[yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On],jn=/* @__PURE__ */ new Set([`iframe`,`start-minimized`]);[...An.flatMap(e=>e.map(([e])=>e).filter(e=>!jn.has(e))),...kn];const Mn=C.scope(`track`);function Nn(e,t){let n=typeof e==`string`?e.trim():``;if(!n||n.length>64){Mn.warn(`track: ignored an event without a name of 1–64 characters`,{name:e});return}let r=Object.fromEntries(Object.entries(typeof t==`object`&&t?t:{}).filter(e=>typeof e[1]==`string`||typeof e[1]==`boolean`||Number.isFinite(e[1])));return JSON.stringify(r).length>256?(Mn.warn(`track: sent the event without its data, which is over 256 characters`,{name:n}),{name:n}):Object.keys(r).length>0?{name:n,data:r}:{name:n}}function Pn(e){let t=[];return e.on(`hostEvent`,e=>{t.push({...e,at:Date.now()}),t.length>10&&t.shift()}),t}function Fn(){let e=Date.now(),t=/* @__PURE__ */ new Uint8Array(16);t[0]=Math.floor(e/2**40)&255,t[1]=Math.floor(e/2**32)&255,t[2]=e>>>24&255,t[3]=e>>>16&255,t[4]=e>>>8&255,t[5]=e&255,In(t.subarray(6)),t[6]=t[6]&15|112,t[8]=t[8]&63|128;let n=Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function In(e){if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}const Ln=C.scope(`persistence`);function Rn(e,t=Mt,n){let r=n?`${e}.${n}`:e,i=`${u.cssPrefix}.storageVersion`,a=t.get(i)??void 0,o=a?`.v${a}`:``,s=`${u.cssPrefix}.${r}${o}`,c=`${u.cssPrefix}${o}.visitorId`,l=`${s}.conversationId`,d=`${s}.userPrefs`,f=`${s}.panelOpen`,p=`${s}.panelSize`,m=`${s}.calloutDismissed`,h=`${s}.sidebarCollapsed`,g=`${s}.activeModule`,_=`${s}.seenNewsId`,v=`${s}.historyCount`,y=`${s}.formsDone`,b={getVisitorId(){let e=t.get(c);if(e)return e;let n=Fn();return t.set(c,n),n},loadConversationId(){return t.get(l)??void 0},saveConversationId(e){Ln.trace(`saveConversationId`,{id:e,scope:r}),e?t.set(l,e):t.remove(l)},loadDraft(e){return t.get(`${s}.draft.${e}`)??``},saveDraft(e,n){let r=`${s}.draft.${e}`;n?t.set(r,n):t.remove(r)},loadMessageQueue(e){let n=t.get(`${s}.messageQueue.${e}`);if(!n)return[];try{let e=JSON.parse(n);return!Array.isArray(e)||!e.every(Bn)?[]:e}catch(e){return Ln.warn(`loadMessageQueue parse failed`,{error:e}),[]}},saveMessageQueue(e,n){let r=`${s}.messageQueue.${e}`;if(n.length===0)t.remove(r);else try{t.set(r,JSON.stringify(n))}catch(e){Ln.warn(`saveMessageQueue serialise failed`,{error:e})}},loadUserPrefs(){let e=t.get(d);if(!e)return{};try{return Vn(JSON.parse(e))}catch(e){return Ln.warn(`loadUserPrefs parse failed`,{error:e}),{}}},saveUserPrefs(e){try{t.set(d,JSON.stringify(e))}catch(e){Ln.warn(`saveUserPrefs serialise failed`,{error:e})}},patchUserPrefs(e){let t=b.loadUserPrefs();b.saveUserPrefs({...t,...e})},loadPanelOpen(){let e=t.get(f);return e===`1`||e!==`0`&&null},savePanelOpen(e){t.set(f,e?`1`:`0`)},loadPanelSize(){let e=t.get(p);return e===`normal`||e===`expanded`||e===`fullscreen`?e:null},savePanelSize(e){t.set(p,e)},loadCalloutDismissed(e){if(!e)return!1;let n=t.get(m);return!!n&&n===e},saveCalloutDismissed(e){e?t.set(m,e):t.remove(m)},loadSidebarCollapsed(){let e=t.get(h);return e===`1`||e!==`0`&&null},saveSidebarCollapsed(e){t.set(h,e?`1`:`0`)},loadActiveModule(){return t.get(g)||null},saveActiveModule(e){t.set(g,e)},loadSeenNewsId(){return t.get(_)||null},saveSeenNewsId(e){t.set(_,e)},loadHistoryCount(){let e=t.get(v);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:null},saveHistoryCount(e){t.set(v,String(e))},loadFormsDone(){let e=t.get(y);if(!e)return{};try{let t=JSON.parse(e);return zn(t)?Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]==`number`)):{}}catch(e){return Ln.warn(`loadFormsDone parse failed`,{error:e}),{}}},saveFormDone(e){try{let n=b.loadFormsDone();n[e]=Date.now(),t.set(y,JSON.stringify(n))}catch(e){Ln.warn(`saveFormDone serialise failed`,{error:e})}},rememberStorageVersion(e){e&&e!==t.get(i)&&(Ln.debug(`rememberStorageVersion (force-reset on next load)`,{version:e}),t.set(i,e))},clearConversation(){t.remove(l)},reset(){let e=t.get(l);e&&(t.remove(`${s}.draft.${e}`),t.remove(`${s}.messageQueue.${e}`));for(let e of[c,l,d,f,p,m,h,g,_,v,y])t.remove(e);Ln.info(`reset: forgot the visitor`,{scope:r})}};return b}function zn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Bn(e){return zn(e)&&typeof e.id==`string`&&e.id.length>0&&typeof e.text==`string`}function Vn(e){if(!zn(e))return{};let t={};return typeof e.locale==`string`&&(t.locale=e.locale),typeof e.soundMuted==`boolean`&&(t.soundMuted=e.soundMuted),(e.themeMode===`auto`||e.themeMode===`light`||e.themeMode===`dark`)&&(t.themeMode=e.themeMode),(e.textSize===`small`||e.textSize===`normal`||e.textSize===`large`)&&(t.textSize=e.textSize),zn(e.widgetSize)&&typeof e.widgetSize.width==`number`&&typeof e.widgetSize.height==`number`&&(t.widgetSize={width:e.widgetSize.width,height:e.widgetSize.height}),t}const Hn=`1.12.7`,Un={open:()=>void 0,close:()=>void 0,expand:e=>({on:e}),fullscreen:e=>({on:e}),send:e=>({attachments:e.attachmentCount}),message:e=>({role:e.role}),stop:()=>void 0,clear:()=>void 0,suggestion:()=>void 0,toggleHistory:e=>({view:e.view}),handshake:()=>void 0,formSubmit:e=>({formId:e.formId,skipped:e.skipped}),toolResult:()=>void 0,toolDecision:e=>({approved:e.approved}),hostEvent:e=>({name:e.name,data:e.data&&JSON.stringify(e.data)}),messageFeedback:e=>({value:e.value??`none`}),contentView:e=>({section:e.section,count:e.count}),contentOpen:e=>({contentId:e.contentId,contentCollectionId:e.contentCollectionId}),contentSearch:e=>({qlen:e.queryLength,hits:e.hitCount}),contentRead:e=>({contentId:e.contentId}),contentLinkClick:e=>({contentId:e.contentId}),attach:e=>({count:e.count,bytes:e.totalBytes}),voiceStart:()=>void 0,voiceStop:e=>({ms:e.durationMs}),voiceCancel:()=>void 0,localeChange:e=>({locale:e}),themeChange:e=>({theme:e}),textSizeChange:e=>({size:e}),soundToggle:e=>({muted:e.muted}),sidebarToggle:e=>({collapsed:e.collapsed}),calloutDismiss:()=>void 0,error:()=>void 0};function Wn(){let e=navigator;return e.globalPrivacyControl===!0||e.doNotTrack===`1`}function Gn(){return location.origin+location.pathname}function Kn(){try{return document.referrer?new URL(document.referrer).origin:``}catch{return``}}function qn(e,t){let n=Math.random(),r=0,i=0,a=/* @__PURE__ */ new Set;function o(e,o){let{tracking:s,publicKey:c,aiAgentDeploymentId:l,mode:u,themeMode:d}=t.getOptions();if(!s.enabled||Wn()||n>=s.sampleRate)return;let f=performance.now();if(f-r>6e4&&(r=f,i=0),++i>60)return;let p=new URLSearchParams;p.set(`v`,`1`),p.set(`_ev`,Hn),p.set(`e`,e),s.token&&p.set(`tk`,s.token),c&&p.set(`pk`,c),l&&p.set(`dep`,l),p.set(`vid`,t.getVisitorId());let m=t.getConversationId();m&&p.set(`cid`,m),p.set(`url`,Gn());let h=Kn();h&&p.set(`ref`,h),p.set(`sw`,String(screen.width)),p.set(`sh`,String(screen.height)),p.set(`vw`,String(innerWidth)),p.set(`vh`,String(innerHeight)),p.set(`dpr`,String(devicePixelRatio)),p.set(`lang`,navigator.language);try{p.set(`tz`,Intl.DateTimeFormat().resolvedOptions().timeZone)}catch{}if(p.set(`m`,u),p.set(`th`,d),o)for(let[e,t]of Object.entries(o))t!==void 0&&p.set(e,String(t));p.set(`ts`,String(Date.now()));let g=`${s.endpoint}?${p}`;if(g.length>2e3)return;let _=new Image(1,1);a.add(_);function v(){return a.delete(_)}_.addEventListener(`load`,v,{once:!0}),_.addEventListener(`error`,v,{once:!0}),_.src=g}let s=[];function c(e,t){if(s&&e!==`handshake`){s.length<60&&s.push([e,t]);return}let n=s??[];s=void 0;for(let[e,t]of n)o(e,t);o(e,t)}let l=Object.keys(Un).map(t=>e.on(t,e=>c(t,Un[t]?.(e))));return()=>{for(let e of l)e();a.clear()}}const Jn=`:host{--__P__-accent-user: __BRAND_ACCENT__;--__P__-accent: var(--__P__-accent-user);--__P__-accent-text-user: __BRAND_ACCENT_TEXT__;--__P__-accent-text: var(--__P__-accent-text-user);--__P__-accent-fg: var(--__P__-accent);--__P__-radius: __BRAND_RADIUS__;--__P__-radius-sm: 8px;--__P__-radius-md: 10px;--__P__-radius-lg: 16px;--__P__-font: __BRAND_FONT__;--__P__-font-display: var(--__P__-font);--__P__-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;--__P__-bg: oklch(1 0 0);--__P__-bg-elevated: oklch(.9789 .0029 278.3);--__P__-surface: var(--__P__-bg-elevated);--__P__-muted: var(--__P__-fg-muted);--__P__-hover: oklch(.1686 .011 278.3 / .06);--__P__-fg: oklch(.1686 .011 278.3);--__P__-fg-muted: oklch(.4932 .0301 278.3);--__P__-border: oklch(.9312 .0084 278.3);--__P__-border-strong: oklch(.8757 .0131 278.3);--__P__-bubble-user: var(--__P__-accent);--__P__-bubble-user-text: var(--__P__-accent-text);--__P__-bubble-assistant: oklch(.9638 .0058 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-on-accent: var(--__P__-accent-text);--__P__-success: oklch(.6456 .1654 151.53);--__P__-warning: oklch(.7135 .1494 74.05);--__P__-danger: oklch(.5966 .1818 24.51);--__P__-danger-text: oklch(.5054 .1905 27.52);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .1);--__P__-neutral: oklch(.7137 .0192 278.3);--__P__-pill-l-min: .3;--__P__-pill-l-max: .46;--__P__-focus: var(--__P__-accent);--__P__-shadow-panel: 0 8px 24px -8px rgba(13, 15, 20, .18), 0 24px 64px -24px rgba(13, 15, 20, .24);--__P__-shadow-card: 0 1px 2px rgba(13, 15, 20, .06), 0 4px 12px -6px rgba(13, 15, 20, .12);--__P__-backdrop: oklch(.1686 .011 278.3 / .55);--__P__-shadow-fab: 0 6px 16px -4px color-mix(in oklch, var(--__P__-accent) 45%, transparent), 0 12px 32px -12px rgba(13, 15, 20, .25);--__P__-z-fab: 2147483600;--__P__-z-panel: 2147483601;--__P__-panel-w: 380px;--__P__-panel-h: 600px;--__P__-fab-size: 56px;--__P__-conversation-max: 768px;--__P__-space-1: 4px;--__P__-space-2: 8px;--__P__-space-3: 12px;--__P__-space-4: 16px;--__P__-space-5: 20px;--__P__-space-6: 24px;--__P__-space-8: 32px;--__P__-text-scale: 1;--__P__-text-xs: calc(12px * var(--__P__-text-scale));--__P__-text-sm: calc(13px * var(--__P__-text-scale));--__P__-text-base: calc(15px * var(--__P__-text-scale));--__P__-text-md: calc(16px * var(--__P__-text-scale));--__P__-text-lg: calc(18px * var(--__P__-text-scale));--__P__-text-xl: calc(22px * var(--__P__-text-scale));--__P__-text-2xl: calc(30px * var(--__P__-text-scale))}:host([data-mode="modal"]),:host([data-mode="drawer"]){--__P__-conversation-max: 100%}:host([data-text-size="small"]){--__P__-text-scale: .9}:host([data-text-size="large"]){--__P__-text-scale: 1.15}:host{--__P__-ease: cubic-bezier(.2, .7, .2, 1);--__P__-ease-out: cubic-bezier(.2, .7, .2, 1);--__P__-ease-in: cubic-bezier(.4, 0, 1, 1);--__P__-ease-in-out: cubic-bezier(.65, 0, .35, 1);--__P__-dur-quick: .12s;--__P__-dur-base: .22s;--__P__-dur-slow: .32s;font-family:var(--__P__-font);color:var(--__P__-fg);color-scheme:light;--__P__-color-scheme: light}:host([data-theme="dark"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-danger-text: oklch(.8077 .1035 19.57);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .18);--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);--__P__-shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px -6px rgba(0, 0, 0, .5);--__P__-backdrop: rgba(0, 0, 0, .65);--__P__-pill-l-min: .75;--__P__-pill-l-max: .92;color-scheme:dark;--__P__-color-scheme: dark}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-pill-l-min: .75;--__P__-pill-l-max: .92;--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);color-scheme:dark;--__P__-color-scheme: dark}}@supports (color: oklch(from red l c h)){:host{--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.3, l, .62) c h);--__P__-accent-text: oklch(from var(--__P__-accent) clamp(0, (l / .623 - 1) * -infinity, 1) 0 h);--__P__-accent-fg: oklch(from var(--__P__-accent-user) clamp(.3, l, .46) c h)}:host([data-theme="dark"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}}}@media(prefers-reduced-motion:reduce){:host{--__P__-dur-quick: 1ms;--__P__-dur-base: 1ms;--__P__-dur-slow: 1ms}}
2
+ import{useEffect as e,useMemo as t,useRef as n,useSyncExternalStore as r}from"react";function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const c={open:!1,ready:!1,unread:0};var l=class{constructor(){s(this,`handlers`,/* @__PURE__ */ new Map)}on(e,t){let n=this.handlers.get(e);return n||(n=/* @__PURE__ */ new Set,this.handlers.set(e,n)),n.add(t),()=>this.handlers.get(e)?.delete(t)}emit(e,t){let n=this.handlers.get(e);if(n)for(let e of n)try{e(t)}catch{}}clear(){this.handlers.clear()}};const u={id:`help-ai`,name:`@helpai/elements`,global:`HelpAI`,tagName:`web-ai-chat`,cssPrefix:`helpai`,defaultBaseUrl:`https://help.ai`,displayName:`Help AI`,domain:`help.ai`,siteUrl:`https://help.ai`},d=[`off`,`error`,`warn`,`info`,`debug`,`trace`],f=u.cssPrefix,p=`${f}.debug`,m=`__${u.global}_DEBUG__`,h=`${f}-debug`;let g=2,_=null;function v(){if(typeof window>`u`)return 2;try{let e=new URLSearchParams(window.location.search).get(h);if(e!==null){let t=y(e);if(t>=0)return t}}catch{}try{let e=window.localStorage?.getItem(p);if(e){let t=y(e);if(t>=0)return t}}catch{}return Reflect.get(window,m)?4:2}function y(e){if(e===!0||e===`1`||e===`true`)return 4;if(e===!1||e===`0`||e===`false`||e===`off`)return 0;if(typeof e==`number`)return Math.max(0,Math.min(5,Math.floor(e)));if(typeof e==`string`){let t=d.findIndex(t=>t===e);if(t>=0)return t}return-1}function b(e){let t=y(e);if(!(t<0)){g=t;try{window.localStorage?.setItem(p,d[t]??`off`)}catch{}}}function x(){return d[g]??`warn`}g=v();function S(e){let t=`[${f}:${e}]`;function n(n,r,i){return(a,o)=>{if(!(g<n)&&(o===void 0?console[r](t,a):console[r](t,a,o),_))try{_({level:i,scope:e,message:a,payload:o})}catch{}}}return{error:n(1,`error`,`error`),warn:n(2,`warn`,`warn`),info:n(3,`info`,`info`),debug:n(4,`debug`,`debug`),trace:n(5,`debug`,`trace`),scope:t=>S(`${e}:${t}`)}}const C=S(`core`);function w(e){_=e}const T=/* @__PURE__ */ new Set([`hidden`,`submit`,`button`,`reset`,`image`,`file`,`password`]);function E(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function D(e){return!E(e)||e.name===``||e.disabled?!1:!(e instanceof HTMLInputElement&&T.has(e.type))}function O(e){let t=e.labels?.[0]?.textContent?.trim();return e.getAttribute(`toolparamdescription`)??(t||e.getAttribute(`aria-description`))??void 0}function ee(e,t){let n=O(e),r=n?{description:n}:{};return e instanceof HTMLSelectElement?{...r,type:`string`,enum:[...e.options].map(e=>e.value)}:e instanceof HTMLTextAreaElement?{...r,type:`string`}:e.type===`checkbox`?{...r,type:`boolean`}:e.type===`radio`?{...r,type:`string`,enum:t}:e.type===`number`||e.type===`range`?{...r,type:`number`}:{...r,type:`string`}}function k(e,t){Object.getOwnPropertyDescriptor(Reflect.getPrototypeOf(e)??e,`value`)?.set?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}function te(e){return e==null?``:typeof e==`string`?e:JSON.stringify(e)}function ne(e,t){e instanceof HTMLInputElement&&e.type===`checkbox`?e.checked!==(t===!0||t===`true`)&&e.click():e instanceof HTMLInputElement&&e.type===`radio`?e.value===te(t)&&!e.checked&&e.click():k(e,te(t))}function A(e,t,n){let r=[...e.elements].filter(D),i={},a=/* @__PURE__ */ new Set;for(let e of r){var o;let t=r.flatMap(t=>t instanceof HTMLInputElement&&t.type===`radio`&&t.name===e.name?[t.value]:[]);i[o=e.name]??(i[o]=ee(e,t)),e.required&&a.add(e.name)}return{name:t,description:n,inputSchema:{type:`object`,properties:i,...a.size>0?{required:[...a]}:{}},execute(t){let n=typeof t==`object`&&t?Object.entries(t):[];for(let[e,t]of n)for(let n of r)n.name===e&&ne(n,t);if(!e.hasAttribute(`toolautosubmit`))return`Filled in the form. The visitor still needs to check it and press its submit button.`;let i=[...new Set([...e.elements].flatMap(e=>E(e)&&e.name&&!e.checkValidity()?[e.name]:[]))];return i.length>0?`Filled in the form, but it can't be submitted yet: ${i.join(`, `)} still needs the visitor. Ask them to complete it and press the submit button.`:(setTimeout(()=>e.requestSubmit(),0),`Filled in the form and submitted it.`)}}}function j(){return[...document.querySelectorAll(`form[toolname][tooldescription]`)].flatMap(e=>{let t=e.getAttribute(`toolname`)?.trim()??``,n=e.getAttribute(`tooldescription`)?.trim()??``;return t&&n?[A(e,t,n)]:[]})}const re=`${u.cssPrefix}.page-tools`;function ie(e){return typeof e==`object`&&!!e}function ae(e){return ie(e)&&(e.state===`running`||e.state===`stopped`||e.state===`finished`&&ie(e.outcome))}function oe(e){let t=e?JSON.parse(e):void 0;return ie(t)?{sent:Array.isArray(t.sent)?t.sent.filter(e=>typeof e==`string`):[],calls:Object.fromEntries(Object.entries(ie(t.calls)?t.calls:{}).filter(e=>ae(e[1])))}:{sent:[],calls:{}}}let se={sent:[],calls:{}};function ce(){try{se=oe(sessionStorage.getItem(re))}catch{}return se}function le(e){se=e;try{sessionStorage.setItem(re,JSON.stringify(e))}catch{}}const M={markSent(e){let t=ce();le({...t,sent:[...t.sent.filter(t=>t!==e),e].slice(-20)})},sentHere(e){return ce().sent.includes(e)},get(e){return ce().calls[e]},set(e,t){let n=ce(),r=Object.entries(n.calls).filter(([t])=>t!==e);le({...n,calls:Object.fromEntries([...r,[e,t]].slice(-50))})},clear(e){let t=ce();e.some(e=>e in t.calls)&&le({...t,calls:Object.fromEntries(Object.entries(t.calls).filter(([t])=>!e.includes(t)))})}};function ue(e,t){return new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(a,e);function i(){return a()}t?.addEventListener(`abort`,i,{once:!0});function a(){clearTimeout(r),t?.removeEventListener(`abort`,i),n()}})}const de=C.scope(`page-tools`),fe=3e4,pe=Symbol.for(`${u.cssPrefix}.page-tools`),me={state:`output-error`,errorText:`The page reloaded before this finished, so it may or may not have taken effect. Check with the visitor before trying it again.`},he=`The visitor stopped this before it finished.`;function N(e){return typeof e==`object`&&!!e}function ge(e){return N(e)&&Array.isArray(e.registered)&&e.runs instanceof Map}function _e(){let e=Reflect.get(globalThis,pe);if(ge(e))return e;let t={registered:[],runs:/* @__PURE__ */ new Map};return Reflect.set(globalThis,pe,t),t}function ve(e,t){let n=N(t)&&t.signal instanceof AbortSignal?t.signal:void 0;if(n?.aborted)return;let r=_e().registered;r.push(e);function i(){let t=r.indexOf(e);t>=0&&r.splice(t,1)}n?.addEventListener(`abort`,i,{once:!0})}function ye(e){return e.replace(/[^A-Za-z0-9_-]/g,`_`).slice(0,58)}function be(e){if(!N(e)||typeof e.name!=`string`||!ye(e.name))return;let t=[e.description,e.title].find(e=>typeof e==`string`&&e.trim()!==``)??e.name;return{name:ye(e.name),description:t.trim().slice(0,1024),inputSchema:{properties:{},...N(e.inputSchema)?e.inputSchema:{},type:`object`},consequential:N(e.annotations)&&e.annotations.consequentialHint===!0}}function xe(e){return e.flatMap(e=>{let t=be(e),n=N(e)?e.execute:void 0;return!t||typeof n!=`function`?(de.warn(`skipped a tool without a name or an execute function`,e),[]):[{...t,run:(t,r)=>Reflect.apply(n,e,[t,{signal:r}])}]})}async function Se(){let e=Reflect.get(document,`modelContext`)??Reflect.get(navigator,`modelContext`);if(!N(e)||typeof e.getTools!=`function`||typeof e.executeTool!=`function`)return[];let t=e.getTools,n=e.executeTool,r=await Promise.race([Promise.resolve().then(()=>Reflect.apply(t,e,[])),ue(1e3).then(()=>[])]).catch(()=>[]);return(Array.isArray(r)?r:[]).flatMap(t=>{let r=be(t);return r?[{...r,run:(r,i)=>Reflect.apply(n,e,[t,r,{signal:i}])}]:[]})}async function Ce(e=[]){let t=xe(j()),n=new Set(t.map(e=>e.name)),r=[...(await Se()).filter(e=>!n.has(e.name)),...t,...xe(e),...xe(_e().registered)];return new Map(r.map(e=>[e.name,e]))}function we(e){return[...e.values()].map(({name:e,description:t,inputSchema:n,consequential:r})=>r?{name:e,description:t,inputSchema:n,annotations:{consequentialHint:!0}}:{name:e,description:t,inputSchema:n})}function Te(e){return e?.execution===`client`}function Ee(e){return e.startsWith(`site__`)?e.slice(6):e}function De(e){if(e===void 0||typeof e==`function`||typeof e==`symbol`)return null;let t=/* @__PURE__ */ new WeakSet,n=JSON.stringify(e,(e,n)=>{if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`)return n instanceof Node?`[${n.nodeName.toLowerCase()}]`:N(n)?t.has(n)?`[circular]`:(t.add(n),n):n});return n.length>fe?{truncated:!0,preview:n.slice(0,fe)}:JSON.parse(n)}async function Oe(e){let t=Ee(e.toolName),n=(await Ce(e.optionTools)).get(t);return n?Promise.resolve().then(()=>n.run(e.input,e.signal)).then(e=>({state:`output-available`,output:De(e)})).catch(e=>(de.warn(`a page tool failed`,{name:t,error:e}),{state:`output-error`,errorText:(e instanceof Error?e.message:String(e)).slice(0,1e3)||`The page tool failed.`})):{state:`output-error`,errorText:`This page doesn't offer "${t}" right now; the visitor may have moved on. Tell them, or continue without it.`}}function ke(e){let{toolCallId:t}=e,n=M.get(t);if(n?.state===`finished`)return Promise.resolve(n.outcome);let{runs:r}=_e(),i=r.get(t);if(i)return i.outcome;if(n?.state===`running`)return M.set(t,{state:`finished`,outcome:me}),e.onSettled(`interrupted`,0),Promise.resolve(me);let a=new AbortController,o=performance.now();M.set(t,{state:`running`});let s=Oe({...e,signal:a.signal}).then(n=>(r.delete(t),M.get(t)?.state===`running`&&(M.set(t,{state:`finished`,outcome:n}),e.onSettled(n.state===`output-available`?`completed`:`failed`,Math.round(performance.now()-o))),n));return r.set(t,{outcome:s,controller:a}),s}function Ae(e){return e===me.errorText||e===he}function je(e){return M.set(e,{state:`stopped`}),_e().runs.get(e)?.controller.abort(),he}function Me(e){M.clear([e]),_e().runs.get(e)?.controller.abort()}var P,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,F=Symbol.for(`pv`),Ue={},We=[],Ge=/^m(i|n|o|s|text|space)$/,Ke=Array.isArray,qe=We.slice,Je=Object.assign;function Ye(e){e&&e.parentNode&&e.remove()}function Xe(e,t,n){var r,i,a,o={},s=arguments.length;for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return s>2&&(o.children=s>3?qe.call(arguments,2):n),Ze(e,o,r,i,null)}function Ze(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:F,__v:i||++Ne,__i:-1,__u:0};return!i&&P.vnode&&P.vnode(a),a}function I(e){return e.children}function Qe(e,t){this.props=e,this.context=t,this.__g=0}function $e(e,t){if(t==null)return e.__&&$e(e.__,e.__i+1);for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:$e(e)}function et(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),et(e)}function tt(e){(8&e.__g||(e.__g|=8,Fe.push(e),Le++))&&Ie==P.debounceRendering||((Ie=P.debounceRendering)||queueMicrotask)(nt)}function nt(){var e,t,n,r,i,a,o,s,c;try{for(t=1;Fe.length;)Fe.length>t&&Fe.sort(Re),e=Fe.shift(),t=Fe.length,8&e.__g&&(r=void 0,i=void 0,a=(i=(n=e).__v).__e,o=[],s=[],(c=n.__P)&&((r=Je({constructor:F},i)).__v=i.__v+1,P.vnode&&P.vnode(r),dt(c,r,i,n.__n,c.namespaceURI,32&i.__u?[a]:null,o,a||$e(i),32&i.__u,s),r.__v=i.__v,r.__.__k[r.__i]=r,mt(o,r,s),i.__=i.__e=null,r.__e!=a&&et(r)))}finally{(Le=Fe.length)&&(Ie||queueMicrotask)(nt)}}function rt(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r.__k||We,v=t.length;for(c=it(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=~p.__i&&_[p.__i]||Ue,p.__i=d,g=dt(e,p,f,i,a,o,s,c,l,u),m=p.__e,(f.ref!=p.ref||8&f.__u)&&(f.ref&&gt(f.ref,null,p,f),p.ref&&u.push(p.ref,p.__c||m,p)),h=h||m,4&p.__u?(c=at(p,c,e,!f.__v),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-21);return n.__e=h,c}function it(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,m=n.length,h=m,g=0,_=0,v=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor===String?o=v[a]=Ze(null,o):Ke(o)?o=v[a]=Ze(I,{children:o}):o.constructor===F&&o.__b?o=v[a]=Ze(o.type,o.props,o.key,o.ref,o.__v):v[a]=o,c=a+g,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=st(o,n,c,h))&&(h--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=16,l==c-1?g--:l==c+1?g++:l!=c&&(l>c?g--:g++,_=1)):(~l||(i>m?g--:i<m&&g++),typeof o.type!=`function`&&(o.__u|=4))):v[a]=null;if(_){for(u=[],d=[],a=0;a<i;a++)if((o=v[a])&&16&o.__u){for(g=0,f=u.length;g<f;)u[p=g+f>>1]<o.__i?g=p+1:f=p;u[g]=o.__i,d[a]=g+1}for(g=u.length;a--;)d[a]&&(d[a]==g?g--:v[a].__u|=4)}if(h)for(a=0;a<m;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=$e(s)),_t(s,s));return r}function at(e,t,n,r){var i,a,o,s;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=at(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=$e(e))&&!t.parentNode&&(t=null),o=e.__e,s=t;s&&s.nodeType==8;)s=s.nextSibling;for(o!=s&&(!r&&n.moveBefore&&o.parentNode?n.moveBefore(o,t):n.insertBefore(o,t||null)),t=o;(t=t&&t.nextSibling)&&t.nodeType==8&&!t.data.startsWith(`$s`););return t}function ot(e,t){return t=t||[],e!=null&&typeof e!=`boolean`&&(Ke(e)?e.some(function(e){ot(e,t)}):t.push(e)),t}function st(e,t,n,r){var i,a=e.key,o=e.type,s=t[n],c=s&&!(2&s.__u);if(s===null&&a==null||c&&a==s.key&&o==s.type)return n;if(r>+!!c){for(i=n-1;i>=0;i--)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i;for(i=n+1;i<t.length;i++)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i}return-1}function ct(e,t,n){n??(n=``),t[0]==`-`?e.setProperty(t,n):e[t]=n}function lt(e,t,n,r,i){var a,o;if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ct(e.style,t);if(n)for(t in n)r&&n[t]==r[t]||ct(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||(e.__e={}))[t]=n,n&&r||(o=He[t]||(He[t]=ut(t)),(e.__a||(e.__a={}))[t]=Ve,a=t!=(t=t.replace(Be,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,a));else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;return}catch{}if(typeof n==`function`)return;n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n)}}function ut(e){return function(t){var n=this.__e;if(n){if(n=n[e],t[ze]==null)t[ze]=Ve++;else if(t[ze]<this.__a[e])return;return n(P.event?P.event(t):t)}}}function dt(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O=t.type;if(t.constructor!==F)return null;128&n.__u&&(c=32&n.__u,u=n.__c.__z)&&(t.__u|=c,d=a=[],u.nodeType==8?s=ft(u,a):a.push(u),s=a[0]||s),(u=P.__b)&&u(t);n:if(typeof O==`function`){f=o.length;try{if(_=t.props,v=(u=O.prototype)&&u.render,y=(u=O.contextType)&&r[u.__c],b=u?y?y.props.value:u.__:r,(p=n.__c)?(t.__c=p,2&p.__g&&(p.__g|=1)):(v?t.__c=p=new O(_,b):(t.__c=p=new Qe(_,b),p.constructor=O,p.render=vt),y&&y.sub(p),p.state||(p.state={}),p.__n=r,p.__g|=8,p.__h=[],p.__k=[]),v&&(p.__s||(p.__s=p.state),O.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=Je({},p.__s)),Je(p.__s,O.getDerivedStateFromProps(_,p.__s)))),m=p.props,h=p.state,p.__v=t,n.__c){if(_!==m&&v&&!O.getDerivedStateFromProps&&p.componentWillReceiveProps&&p.componentWillReceiveProps(_,b),t.__v==n.__v&&!(8&p.__g)||!(4&p.__g)&&p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(_,p.__s,b)){t.__v!=n.__v&&(p.props=_,p.state=p.__s,p.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),We.push.apply(p.__h,p.__k),p.__k=[],p.__h.length&&o.push(p),s=$e(n);break n}p.componentWillUpdate&&p.componentWillUpdate(_,p.__s,b),v&&p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(m,h,g)})}else v&&!O.getDerivedStateFromProps&&p.componentWillMount&&p.componentWillMount(),v&&p.componentDidMount&&p.__h.push(p.componentDidMount);if(p.context=b,p.props=_,p.__P=e,p.__g&=-5,x=P.__r,S=0,v)p.state=p.__s,p.__g&=-9,x&&x(t),u=p.render(p.props,p.state,p.context),We.push.apply(p.__h,p.__k),p.__k=[];else do p.__g&=-9,x&&x(t),u=p.render(p.props,p.state,p.context),p.state=p.__s;while(8&p.__g&&++S<25);p.state=p.__s,p.getChildContext&&(r=Je({},r,p.getChildContext())),v&&n.__c&&p.getSnapshotBeforeUpdate&&(g=p.getSnapshotBeforeUpdate(m,h)),C=u&&u.type===I&&u.key==null?u.props.children:u,_.__P&&(u=s,i=(e=_.__P).namespaceURI,c=a=null,n.props&&n.props.__P!=e&&(n.__k.some(function(e){e&&_t(e,e)}),n.__k=null),s=n.__k?$e(n,0):null),s=rt(e,Ke(C)?C:[C],t,n,r,i,a,o,s,c,l),_.__P&&(t.__e=null,s=u),t.__u&=-161,d&&d.some(Ye),p.__h.length&&o.push(p),1&p.__g&&(p.__g&=-4)}catch(e){if(o.length=f,t.__v=null,c||a){if(e.then){if(w=0,t.__u|=128|c,a){for(~(E=a.indexOf(s||void 0))||(E=a.length);(D=a[E-1])&&D.nodeType==8;)E--;for(;E<a.length;E++)if(D=a[E]){if(a[E]=null,D.nodeType==8){if(D.data.startsWith(`$s`))w++||(T=D);else if(w&&D.data.startsWith(`/$s`)&&!--w)break}else if(!w)break}}if(!T){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;T=s}(u=ft(T=t.__c.__z||(t.__c.__z=T)))?(t.__e=T,s=u):t.__e=s,s=s&&s.nextSibling}else a&&a.some(Ye)}else t.__e=n.__e;t.__k||(t.__k=n.__k||[]),e.then||pt(t),P.__e(e,t,n)}}else s=t.__e=ht(n.__e,t,n,r,i,a,o,c,l,e);return(u=P.diffed)&&u(t),s}function ft(e,t){if(e&&e.nodeType==8&&e.data.startsWith(`$s`))for(var n=1;e=e.nextSibling;){if(e.nodeType==8){if(e.data.startsWith(`$s`))n++;else if(e.data.startsWith(`/$s`)&&!--n)return e}t&&t.push(e)}}function pt(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(pt))}function mt(e,t,n){for(var r=0;r<n.length;)gt(n[r++],n[r++],n[r++]);P.__c&&P.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){P.__e(e,t.__v)}})}function ht(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y=n.props||Ue,b=t.props,x=t.type;if(x==`svg`?i=`http://www.w3.org/2000/svg`:x==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||(i=`http://www.w3.org/1999/xhtml`),a){for(u=0;u<a.length;u++)if((m=a[u])&&(x?m.localName==x:m.nodeType==3)){e=m,a[u]=null;break}}if(!e){if(_=l.ownerDocument||document,!x)return _.createTextNode(b);e=_.createElementNS(i,x,b.is&&b),s&&(P.__m&&P.__m(t,a),s=!1),a=null}if(x){if(l=x==`template`?e.content:e,a=x==`textarea`&&b.defaultValue!=null?null:a&&qe.call(l.childNodes),!s&&a)for(y={},u=0;u<e.attributes.length;u++)y[(m=e.attributes[u]).name]=m.value;for(u in y)m=y[u],u==`dangerouslySetInnerHTML`?f=m:u==`children`||u in b||u==`value`&&`defaultValue`in b||u==`checked`&&`defaultChecked`in b||lt(e,u,null,m,i);for(u in v=1&n.__u,b)m=b[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||!(y[u]!==m||v&&m!=null)||lt(e,u,m,y[u],i);d?(s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[]):(f&&(e.textContent=``),(x==`foreignObject`||i==`http://www.w3.org/1998/Math/MathML`&&Ge.test(x))&&(i=`http://www.w3.org/1999/xhtml`),rt(l,Ke(p)?p:[p],t,n,r,i,a,o,a?a[0]:n.__k&&$e(n,0),s,c),a&&a.some(Ye)),s&&x!=`textarea`||(u=`value`,x==`progress`&&h==null?e.removeAttribute(u):h==null||h===e[u]&&(x!=`progress`||h)||lt(e,u,h,y[u],i),u=`checked`,g!=null&&g!=e[u]&&lt(e,u,g,y[u],i))}else y===b||s&&e.data==b||(e.data=b);return e}function gt(e,t,n,r){try{typeof e==`function`?t?t.__x=e(t)||1:r&&(r=r.__c||r.__e)&&(t=r.__x)&&(r.__x=null,typeof t==`function`?t():e(null)):e.current=t}catch(e){P.__e(e,n)}}function _t(e,t,n){var r,i,a,o;if(P.unmount&&P.unmount(e),!(r=e.ref)||r.current&&r.current!=e.__e||gt(r,null,t,e),r=e.__c){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){P.__e(e,t)}r.__P=r.__n=null}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&_t(r[o],t,typeof e.type!=`function`||n&&!e.props.__P);!n&&(r=e.__c)&&(r=r.__z)&&(i=ft(r,a=[]))&&(r==e.__e&&a.some(Ye),Ye(i),Ye(r)),(r=e.__e)&&(n||Ye(r),r.__e&&(r.__e=null)),e.__e=e.__c=e.__=null}function vt(e,t,n){return this.constructor(e,n)}function yt(e,t){var n,r,i,a;P.__&&P.__(e,t),t.nodeType==9&&(t=t.documentElement),r=(n=e&&32&e.__u)?null:t.__k,t.__k=Ze(I,{children:[e]}),i=[],a=[],dt(t,t.__k,r||Ue,Ue,t.namespaceURI,r?null:t.firstChild?qe.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a),mt(i,t.__k,a),t.__k.props.children=null}P={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((o=(a=i.constructor)&&a.getDerivedStateFromError)&&i.setState(a.getDerivedStateFromError(e)),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),o=1),o&&8&i.__g)return void(i.__g|=2)}catch(t){e=t}}throw Le=0,e}},Ne=0,Pe=function(e){return e!=null&&e.constructor===F},Qe.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=Je({},this.state)),typeof e==`function`&&(e=e(Je({},n),this.props)),e&&(Je(n,e),this.__v&&(t&&this.__k.push(t),tt(this)))},Qe.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),tt(this))},Qe.prototype.render=I,Fe=[],Le=0,Re=function(e,t){return e.__v.__b-t.__v.__b},ze=Symbol(),Be=/(PointerCapture)$|Capture$/i,Ve=0,He={};function bt(e,t){if(e?.length&&t)return e.find(e=>e.locale===t)}function xt(e,t){let{translations:n,defaultLocale:r,...i}=e,a=bt(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description,content:a.content??i.content}:i}function St(e,t){let{translations:n,defaultLocale:r,...i}=e,a=bt(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description}:i}function Ct(e,t){let{translations:n,defaultLocale:r,...i}=e,a=bt(n,t);if(!a)return i;let o=new Map((a.fields??[]).map(e=>[e.name,e])),s=i.fields.map(e=>{let t=o.get(e.name);if(!t)return e;let n=new Map((t.options??[]).map(e=>[e.value,e]));return{...e,label:t.label??e.label,placeholder:t.placeholder??e.placeholder,validationHint:t.validationHint??e.validationHint,options:e.options?.map(e=>{let t=n.get(e.value);return t?{...e,label:t.label??e.label,description:t.description??e.description}:e})}});return{...i,title:a.title??i.title,description:a.description??i.description,submitLabel:a.submitLabel??i.submitLabel,fields:s}}const wt={attach:`Attach files`,file:`File`,attachmentMimeRejected:`File type not supported`,attachmentTooLarge:`File is too large`,attachmentTooMany:`Attachment limit reached`,conversationClosed:`This chat is closed`,conversationLoading:`Loading chat…`,loadPreviousMessages:`Load previous messages`,close:`Close`,collapse:`Collapse`,collapseSidebar:`Collapse sidebar`,composerPlaceholder:`Type a message…`,dateLastWeek:`Last 7 days`,dateOlder:`Older`,dateToday:`Today`,dateYesterday:`Yesterday`,dropZone:`Drop files to attach`,errorGeneric:`Something went wrong`,errorRateLimited:`Too many requests — please try again in a moment.`,errorRetry:`Retry`,expand:`Expand`,expandSidebar:`Expand sidebar`,exitFullscreen:`Exit fullscreen`,fullscreen:`Fullscreen`,history:`History`,historyBack:`Back to chat`,historyEmpty:`No previous chats yet`,historyLoading:`Loading your chats…`,historyContinue:`Continue the chat`,historyTitle:`Chat history`,loadMoreConversations:`Load more conversations`,language:`Language`,launcherOpen:`Open chat`,launcherLabel:`Chat with us`,micStart:`Start voice input`,micStop:`Stop voice input`,micUnsupported:`Voice input is not supported in this browser`,moreActions:`More actions`,newConversation:`New chat`,panelTitle:`Chat`,popOut:`Open in new tab`,resizeHandle:`Drag to resize`,scrollToBottom:`Scroll to latest`,send:`Send`,queueMessage:`Queue message`,removeQueuedMessage:`Remove queued message`,compactingContext:`Optimizing conversation context…`,soundOff:`Sound off`,soundOn:`Sound on`,startNewConversation:`Start a new chat`,talkToOperator:`Talk to a person`,connectingOperator:`Connecting you to a person…`,noOperatorAvailable:`No one's available right now — leave your details and we'll follow up.`,chattingWithOperator:`You're chatting with {operator}`,cancelOperatorRequest:`Keep chatting with the AI`,stop:`Stop`,theme:`Theme`,themeAuto:`Auto`,themeDark:`Dark`,themeLight:`Light`,textSize:`Text size`,textSizeSmall:`Small`,textSizeNormal:`Normal`,textSizeLarge:`Large`,loading:`Loading…`,visualPreparing:`Preparing visual…`,visualError:`This visual could not be displayed.`,visualPartial:`Some parts of this visual could not be displayed.`,thinking:`Thinking…`,thoughts:`Thoughts`,toolResult:`Result`,sources:`Sources`,feedbackUp:`Good response`,feedbackDown:`Bad response`,feedbackThanks:`Thanks for your feedback`,copy:`Copy`,copied:`Copied`,tabHome:`Home`,tabConversations:`Chats`,tabHelp:`Help`,tabNews:`News`,modulesEmpty:`Nothing here yet`,moduleBack:`Back`,contentLoading:`Loading…`,contentHelpful:`Was this helpful?`,homeGreeting:`How can we help?`,homeGreetingNamed:`Hi {name} 👋`,homeGreetingLead:`How can we help?`,homeSearchPlaceholder:`Search for help`,homeAskPlaceholder:`Ask a question…`,homeWhatsNew:`What's new`,homeContentTitle:`Popular articles`,homeStatus:`Status`,helpTitle:`Help`,helpSearchPlaceholder:`Search for help`,helpEmpty:`No help articles yet`,helpLoading:`Loading help…`,helpSearchEmpty:`No results for “{query}”`,helpShowMore:`Show more`,newsTitle:`News`,newsEmpty:`No news yet`,newsLoading:`Loading news…`,newsBack:`Back to news`,newsPublishedAt:`Published {date}`,newsShowMore:`Show more`,newsUnseen:`New post`,formSubmit:`Submit`,formSkip:`Maybe later`,formSubmitted:`Completed`,formSkipped:`Maybe later`,formFillOut:`Fill out`,formRequired:`This field is required`,formInvalidEmail:`Enter a valid email address`,formInvalidTel:`Enter a valid phone number`,formInvalidUrl:`Enter a valid URL`,formInvalidNumber:`Enter a valid number`,formTooShort:`Too short (min {min} characters)`,formTooLong:`Too long (max {max} characters)`,formNumberTooSmall:`Must be at least {min}`,formNumberTooLarge:`Must be at most {max}`,formPatternMismatch:`Please match the requested format`,formChooseAtLeast:`Choose at least {min}`,formChooseAtMost:`Choose at most {max}`,formOther:`Other`,formOtherPlaceholder:`Type your answer…`,inputRequired:`Questions for you`,inputBadge:`Questions`,inputAnswered:`Answered`,inputSkipped:`Skipped`,showOptions:`Show options`,hideOptions:`Hide options`,qtypeText:`Your answer`,qtypeEmail:`Email address`,qtypePhone:`Phone number`,qtypeNumber:`Number`,qtypeDate:`Date`,qtypeChooseOne:`Pick one`,qtypeChooseAny:`Pick any`,qtypeBoolean:`Yes / No`,inputSubmit:`Submit answers`,inputSubmitHint:`Enter to send · Shift+Enter = new line`,inputSkip:`Skip`,confirmYes:`Yes`,confirmNo:`No`,approve:`Approve`,reject:`Reject`,approvalPrompt:`{tool} requires your approval to execute.`,approvalBody:`Review the tool input above and decide whether to allow this action.`,approvalYourResponse:`Your response: {decision}`,approvalEditHint:`You can edit this response until this step continues.`,approvalSubmitting:`Response submitted. Request in progress…`,edit:`Edit`,toolParameters:`Parameters`,statusAwaiting:`Awaiting Approval`,statusResponded:`Submitted`,statusRunning:`Running`,statusCompleted:`Completed`,statusDenied:`Denied`,statusError:`Error`,statusSuperseded:`Skipped`,statusIncomplete:`Not completed`},Tt={en:wt,fr:{attach:`Joindre des fichiers`,file:`Fichier`,attachmentMimeRejected:`Type de fichier non pris en charge`,attachmentTooLarge:`Le fichier est trop volumineux`,attachmentTooMany:`Limite de pièces jointes atteinte`,conversationClosed:`Ce chat est fermé`,conversationLoading:`Chargement du chat…`,loadPreviousMessages:`Charger les messages précédents`,close:`Fermer`,collapse:`Réduire`,collapseSidebar:`Réduire la barre latérale`,composerPlaceholder:`Écrivez un message…`,dateLastWeek:`7 derniers jours`,dateOlder:`Plus ancien`,dateToday:`Aujourd'hui`,dateYesterday:`Hier`,dropZone:`Déposez les fichiers à joindre`,errorGeneric:`Une erreur s'est produite`,errorRateLimited:`Trop de requêtes — veuillez réessayer dans un instant.`,errorRetry:`Réessayer`,expand:`Agrandir`,expandSidebar:`Développer la barre latérale`,exitFullscreen:`Quitter le plein écran`,fullscreen:`Plein écran`,history:`Historique`,historyBack:`Retour au chat`,historyEmpty:`Aucun chat pour le moment`,historyContinue:`Poursuivre le chat`,historyLoading:`Chargement de vos chats…`,historyTitle:`Historique des chats`,loadMoreConversations:`Charger plus de conversations`,language:`Langue`,launcherOpen:`Ouvrir le chat`,launcherLabel:`Discuter avec nous`,micStart:`Démarrer la saisie vocale`,micStop:`Arrêter la saisie vocale`,micUnsupported:`La saisie vocale n'est pas prise en charge par ce navigateur`,moreActions:`Plus d'actions`,newConversation:`Nouveau chat`,panelTitle:`Chat`,popOut:`Ouvrir dans un nouvel onglet`,resizeHandle:`Glisser pour redimensionner`,scrollToBottom:`Aller au plus récent`,send:`Envoyer`,queueMessage:`Mettre le message en attente`,removeQueuedMessage:`Retirer le message en attente`,compactingContext:`Optimisation du contexte de la conversation…`,soundOff:`Son désactivé`,soundOn:`Son activé`,startNewConversation:`Démarrer un nouveau chat`,talkToOperator:`Parler à une personne`,connectingOperator:`Mise en relation avec une personne…`,noOperatorAvailable:`Personne n'est disponible pour le moment — laissez vos coordonnées et nous reviendrons vers vous.`,chattingWithOperator:`Vous discutez avec {operator}`,cancelOperatorRequest:`Continuer avec l'IA`,stop:`Arrêter`,theme:`Thème`,themeAuto:`Auto`,themeDark:`Sombre`,themeLight:`Clair`,textSize:`Taille du texte`,textSizeSmall:`Petite`,textSizeNormal:`Normale`,textSizeLarge:`Grande`,loading:`Chargement…`,visualPreparing:`Préparation du visuel…`,visualError:`Ce visuel n’a pas pu être affiché.`,visualPartial:`Certaines parties de ce visuel n’ont pas pu être affichées.`,thinking:`Réflexion…`,thoughts:`Réflexions`,toolResult:`Résultat`,sources:`Sources`,feedbackUp:`Bonne réponse`,feedbackDown:`Mauvaise réponse`,feedbackThanks:`Merci pour votre retour`,copy:`Copier`,copied:`Copié`,tabHome:`Accueil`,tabConversations:`Chats`,tabHelp:`Aide`,tabNews:`Actualités`,modulesEmpty:`Rien pour le moment`,moduleBack:`Retour`,contentLoading:`Chargement…`,contentHelpful:`Cela vous a-t-il aidé ?`,homeGreeting:`Comment pouvons-nous vous aider ?`,homeGreetingNamed:`Bonjour {name} 👋`,homeGreetingLead:`Comment pouvons-nous vous aider ?`,homeSearchPlaceholder:`Rechercher de l'aide`,homeAskPlaceholder:`Posez une question…`,homeWhatsNew:`Nouveautés`,homeContentTitle:`Articles populaires`,homeStatus:`Statut`,helpTitle:`Aide`,helpSearchPlaceholder:`Rechercher de l'aide`,helpEmpty:`Aucun article d'aide pour le moment`,helpLoading:`Chargement de l'aide…`,helpSearchEmpty:`Aucun résultat pour «\xA0{query}\xA0»`,helpShowMore:`Afficher plus`,newsTitle:`Actualités`,newsEmpty:`Aucune actualité pour le moment`,newsLoading:`Chargement des actualités…`,newsBack:`Retour aux actualités`,newsPublishedAt:`Publié le {date}`,newsShowMore:`Afficher plus`,newsUnseen:`Nouvelle publication`,formSubmit:`Envoyer`,formSkip:`Plus tard`,formSubmitted:`Terminé`,formSkipped:`Plus tard`,formFillOut:`Remplir`,formRequired:`Ce champ est obligatoire`,formInvalidEmail:`Saisissez une adresse e-mail valide`,formInvalidTel:`Saisissez un numéro de téléphone valide`,formInvalidUrl:`Saisissez une URL valide`,formInvalidNumber:`Saisissez un nombre valide`,formTooShort:`Trop court (min. {min} caractères)`,formTooLong:`Trop long (max. {max} caractères)`,formNumberTooSmall:`Doit être au moins {min}`,formNumberTooLarge:`Doit être au plus {max}`,formPatternMismatch:`Veuillez respecter le format demandé`,formChooseAtLeast:`Choisissez au moins {min}`,formChooseAtMost:`Choisissez au plus {max}`,formOther:`Autre`,formOtherPlaceholder:`Saisissez votre réponse…`,inputRequired:`Questions pour vous`,inputBadge:`Questions`,inputAnswered:`Répondu`,inputSkipped:`Ignoré`,showOptions:`Afficher les options`,hideOptions:`Masquer les options`,qtypeText:`Votre réponse`,qtypeEmail:`Adresse e-mail`,qtypePhone:`Numéro de téléphone`,qtypeNumber:`Nombre`,qtypeDate:`Date`,qtypeChooseOne:`Choisir une`,qtypeChooseAny:`Choisir plusieurs`,qtypeBoolean:`Oui / Non`,inputSubmit:`Envoyer les réponses`,inputSubmitHint:`Entrée pour envoyer · Maj+Entrée = saut de ligne`,inputSkip:`Ignorer`,confirmYes:`Oui`,confirmNo:`Non`,approve:`Approuver`,reject:`Refuser`,approvalPrompt:`{tool} nécessite votre approbation pour s'exécuter.`,approvalBody:`Vérifiez les paramètres ci-dessus et décidez d'autoriser ou non cette action.`,approvalYourResponse:`Votre réponse : {decision}`,approvalEditHint:`Vous pouvez modifier votre réponse jusqu'à la reprise de cette étape.`,approvalSubmitting:`Réponse envoyée. Traitement en cours…`,edit:`Modifier`,toolParameters:`Paramètres`,statusAwaiting:`En attente d'approbation`,statusResponded:`Envoyé`,statusRunning:`En cours`,statusCompleted:`Terminé`,statusDenied:`Refusé`,statusError:`Erreur`,statusSuperseded:`Ignoré`,statusIncomplete:`Non terminé`},ar:{attach:`إرفاق ملفات`,file:`ملف`,attachmentMimeRejected:`نوع الملف غير مدعوم`,attachmentTooLarge:`حجم الملف كبير جدًا`,attachmentTooMany:`تم بلوغ الحد الأقصى للمرفقات`,conversationClosed:`تم إغلاق هذه الدردشة`,conversationLoading:`جارٍ تحميل الدردشة…`,loadPreviousMessages:`تحميل الرسائل السابقة`,close:`إغلاق`,collapse:`طيّ`,collapseSidebar:`طيّ الشريط الجانبي`,composerPlaceholder:`اكتب رسالة…`,dateLastWeek:`آخر ٧ أيام`,dateOlder:`أقدم`,dateToday:`اليوم`,dateYesterday:`أمس`,dropZone:`أفلت الملفات لإرفاقها`,errorGeneric:`حدث خطأ ما`,errorRateLimited:`طلبات كثيرة جدًا — يرجى المحاولة بعد لحظة.`,errorRetry:`إعادة المحاولة`,expand:`توسيع`,expandSidebar:`توسيع الشريط الجانبي`,exitFullscreen:`إنهاء ملء الشاشة`,fullscreen:`ملء الشاشة`,history:`السجل`,historyBack:`العودة إلى الدردشة`,historyEmpty:`لا توجد دردشات سابقة بعد`,historyContinue:`متابعة الدردشة`,historyLoading:`جارٍ تحميل دردشاتك…`,historyTitle:`سجل الدردشات`,loadMoreConversations:`تحميل المزيد من المحادثات`,language:`اللغة`,launcherOpen:`فتح الدردشة`,launcherLabel:`تحدث معنا`,micStart:`بدء الإدخال الصوتي`,micStop:`إيقاف الإدخال الصوتي`,micUnsupported:`الإدخال الصوتي غير مدعوم في هذا المتصفح`,moreActions:`إجراءات إضافية`,newConversation:`دردشة جديدة`,panelTitle:`الدردشة`,popOut:`فتح في علامة تبويب جديدة`,resizeHandle:`اسحب لتغيير الحجم`,scrollToBottom:`الانتقال إلى الأحدث`,send:`إرسال`,queueMessage:`إضافة الرسالة إلى قائمة الانتظار`,removeQueuedMessage:`إزالة الرسالة من قائمة الانتظار`,compactingContext:`جارٍ تحسين سياق المحادثة…`,soundOff:`كتم الصوت`,soundOn:`تشغيل الصوت`,startNewConversation:`بدء دردشة جديدة`,talkToOperator:`التحدث إلى شخص`,connectingOperator:`جارٍ توصيلك بشخص…`,noOperatorAvailable:`لا يوجد موظفون متاحون الآن — اترك بياناتك وسنتواصل معك.`,chattingWithOperator:`أنت تتحدث مع {operator}`,cancelOperatorRequest:`متابعة المحادثة مع الذكاء الاصطناعي`,stop:`إيقاف`,theme:`المظهر`,themeAuto:`تلقائي`,themeDark:`داكن`,themeLight:`فاتح`,textSize:`حجم النص`,textSizeSmall:`صغير`,textSizeNormal:`عادي`,textSizeLarge:`كبير`,loading:`جارٍ التحميل…`,visualPreparing:`جارٍ إعداد المحتوى المرئي…`,visualError:`تعذر عرض هذا المحتوى المرئي.`,visualPartial:`تعذر عرض بعض أجزاء هذا المحتوى المرئي.`,thinking:`يفكّر…`,thoughts:`الأفكار`,toolResult:`النتيجة`,sources:`المصادر`,feedbackUp:`رد جيد`,feedbackDown:`رد سيئ`,feedbackThanks:`شكرًا على ملاحظاتك`,copy:`نسخ`,copied:`تم النسخ`,tabHome:`الرئيسية`,tabConversations:`الدردشات`,tabHelp:`المساعدة`,tabNews:`الأخبار`,modulesEmpty:`لا شيء هنا بعد`,moduleBack:`رجوع`,contentLoading:`جارٍ التحميل…`,contentHelpful:`هل كان هذا مفيدًا؟`,homeGreeting:`كيف يمكننا مساعدتك؟`,homeGreetingNamed:`مرحبًا {name} 👋`,homeGreetingLead:`كيف يمكننا مساعدتك؟`,homeSearchPlaceholder:`ابحث عن مساعدة`,homeAskPlaceholder:`اطرح سؤالاً…`,homeWhatsNew:`ما الجديد`,homeContentTitle:`مقالات شائعة`,homeStatus:`الحالة`,helpTitle:`المساعدة`,helpSearchPlaceholder:`ابحث عن مساعدة`,helpEmpty:`لا توجد مقالات مساعدة بعد`,helpLoading:`جارٍ تحميل المساعدة…`,helpSearchEmpty:`لا نتائج لـ «{query}»`,helpShowMore:`عرض المزيد`,newsTitle:`الأخبار`,newsEmpty:`لا توجد أخبار بعد`,newsLoading:`جارٍ تحميل الأخبار…`,newsBack:`العودة إلى الأخبار`,newsPublishedAt:`نُشر في {date}`,newsShowMore:`عرض المزيد`,newsUnseen:`منشور جديد`,formSubmit:`إرسال`,formSkip:`لاحقًا`,formSubmitted:`تم`,formSkipped:`لاحقًا`,formFillOut:`تعبئة`,formRequired:`هذا الحقل مطلوب`,formInvalidEmail:`أدخل بريدًا إلكترونيًا صحيحًا`,formInvalidTel:`أدخل رقم هاتف صحيحًا`,formInvalidUrl:`أدخل رابطًا صحيحًا`,formInvalidNumber:`أدخل رقمًا صحيحًا`,formTooShort:`قصير جدًا (الحد الأدنى {min} حرفًا)`,formTooLong:`طويل جدًا (الحد الأقصى {max} حرفًا)`,formNumberTooSmall:`يجب ألا يقل عن {min}`,formNumberTooLarge:`يجب ألا يزيد عن {max}`,formPatternMismatch:`يرجى مطابقة الصيغة المطلوبة`,formChooseAtLeast:`اختر {min} على الأقل`,formChooseAtMost:`اختر {max} على الأكثر`,formOther:`أخرى`,formOtherPlaceholder:`اكتب إجابتك…`,inputRequired:`أسئلة لك`,inputBadge:`أسئلة`,inputAnswered:`تمت الإجابة`,inputSkipped:`تم التخطي`,showOptions:`إظهار الخيارات`,hideOptions:`إخفاء الخيارات`,qtypeText:`إجابتك`,qtypeEmail:`عنوان البريد الإلكتروني`,qtypePhone:`رقم الهاتف`,qtypeNumber:`رقم`,qtypeDate:`تاريخ`,qtypeChooseOne:`اختر واحدًا`,qtypeChooseAny:`اختر أيًا`,qtypeBoolean:`نعم / لا`,inputSubmit:`إرسال الإجابات`,inputSubmitHint:`Enter للإرسال · Shift+Enter = سطر جديد`,inputSkip:`تخطٍّ`,confirmYes:`نعم`,confirmNo:`لا`,approve:`موافقة`,reject:`رفض`,approvalPrompt:`تتطلب {tool} موافقتك للتنفيذ.`,approvalBody:`راجع مُعطيات الأداة أعلاه وقرّر السماح بهذا الإجراء أو رفضه.`,approvalYourResponse:`ردّك: {decision}`,approvalEditHint:`يمكنك تعديل ردّك حتى تستأنف هذه الخطوة.`,approvalSubmitting:`تم إرسال الرد. جارٍ التنفيذ…`,edit:`تعديل`,toolParameters:`المعطيات`,statusAwaiting:`بانتظار الموافقة`,statusResponded:`تم الإرسال`,statusRunning:`قيد التنفيذ`,statusCompleted:`مكتمل`,statusDenied:`مرفوض`,statusError:`خطأ`,statusSuperseded:`تم التخطي`,statusIncomplete:`لم يكتمل`},es:{attach:`Adjuntar archivos`,file:`Archivo`,attachmentMimeRejected:`Tipo de archivo no admitido`,attachmentTooLarge:`El archivo es demasiado grande`,attachmentTooMany:`Se alcanzó el límite de adjuntos`,conversationClosed:`Este chat está cerrado`,conversationLoading:`Cargando chat…`,loadPreviousMessages:`Cargar mensajes anteriores`,close:`Cerrar`,collapse:`Contraer`,collapseSidebar:`Contraer la barra lateral`,composerPlaceholder:`Escribe un mensaje…`,dateLastWeek:`Últimos 7 días`,dateOlder:`Anteriores`,dateToday:`Hoy`,dateYesterday:`Ayer`,dropZone:`Suelta los archivos para adjuntarlos`,errorGeneric:`Algo salió mal`,errorRateLimited:`Demasiadas solicitudes: inténtalo de nuevo en un momento.`,errorRetry:`Reintentar`,expand:`Ampliar`,expandSidebar:`Expandir la barra lateral`,exitFullscreen:`Salir de pantalla completa`,fullscreen:`Pantalla completa`,history:`Historial`,historyBack:`Volver al chat`,historyEmpty:`Aún no tienes chats`,historyContinue:`Continuar el chat`,historyLoading:`Cargando tus chats…`,historyTitle:`Historial de chats`,loadMoreConversations:`Cargar más conversaciones`,language:`Idioma`,launcherOpen:`Abrir el chat`,launcherLabel:`Chatea con nosotros`,micStart:`Iniciar entrada de voz`,micStop:`Detener entrada de voz`,micUnsupported:`Este navegador no admite la entrada de voz`,moreActions:`Más acciones`,newConversation:`Nuevo chat`,panelTitle:`Chat`,popOut:`Abrir en una pestaña nueva`,resizeHandle:`Arrastra para cambiar el tamaño`,scrollToBottom:`Ir a lo más reciente`,send:`Enviar`,queueMessage:`Poner mensaje en cola`,removeQueuedMessage:`Quitar mensaje de la cola`,compactingContext:`Optimizando el contexto de la conversación…`,soundOff:`Sonido desactivado`,soundOn:`Sonido activado`,startNewConversation:`Iniciar un chat nuevo`,talkToOperator:`Hablar con una persona`,connectingOperator:`Conectándote con una persona…`,noOperatorAvailable:`Nadie está disponible ahora — deja tus datos y te contactaremos.`,chattingWithOperator:`Estás chateando con {operator}`,cancelOperatorRequest:`Seguir con la IA`,stop:`Detener`,theme:`Tema`,themeAuto:`Automático`,themeDark:`Oscuro`,themeLight:`Claro`,textSize:`Tamaño del texto`,textSizeSmall:`Pequeño`,textSizeNormal:`Normal`,textSizeLarge:`Grande`,loading:`Cargando…`,visualPreparing:`Preparando visualización…`,visualError:`No se pudo mostrar esta visualización.`,visualPartial:`No se pudieron mostrar algunas partes de esta visualización.`,thinking:`Pensando…`,thoughts:`Razonamiento`,toolResult:`Resultado`,sources:`Fuentes`,feedbackUp:`Buena respuesta`,feedbackDown:`Mala respuesta`,feedbackThanks:`Gracias por tu opinión`,copy:`Copiar`,copied:`Copiado`,tabHome:`Inicio`,tabConversations:`Chats`,tabHelp:`Ayuda`,tabNews:`Novedades`,modulesEmpty:`Aún no hay nada aquí`,moduleBack:`Atrás`,contentLoading:`Cargando…`,contentHelpful:`¿Te resultó útil?`,homeGreeting:`¿Cómo podemos ayudarte?`,homeGreetingNamed:`Hola, {name} 👋`,homeGreetingLead:`¿Cómo podemos ayudarte?`,homeSearchPlaceholder:`Buscar ayuda`,homeAskPlaceholder:`Haz una pregunta…`,homeWhatsNew:`Lo nuevo`,homeContentTitle:`Artículos populares`,homeStatus:`Estado`,helpTitle:`Ayuda`,helpSearchPlaceholder:`Buscar ayuda`,helpEmpty:`Aún no hay artículos de ayuda`,helpLoading:`Cargando la ayuda…`,helpSearchEmpty:`Sin resultados para «{query}»`,helpShowMore:`Mostrar más`,newsTitle:`Novedades`,newsEmpty:`Aún no hay novedades`,newsLoading:`Cargando novedades…`,newsBack:`Volver a novedades`,newsPublishedAt:`Publicado el {date}`,newsShowMore:`Mostrar más`,newsUnseen:`Publicación nueva`,formSubmit:`Enviar`,formSkip:`Quizá más tarde`,formSubmitted:`Completado`,formSkipped:`Quizá más tarde`,formFillOut:`Completar`,formRequired:`Este campo es obligatorio`,formInvalidEmail:`Introduce un correo electrónico válido`,formInvalidTel:`Introduce un número de teléfono válido`,formInvalidUrl:`Introduce una URL válida`,formInvalidNumber:`Introduce un número válido`,formTooShort:`Demasiado corto (mín. {min} caracteres)`,formTooLong:`Demasiado largo (máx. {max} caracteres)`,formNumberTooSmall:`Debe ser al menos {min}`,formNumberTooLarge:`Debe ser como máximo {max}`,formPatternMismatch:`Respeta el formato solicitado`,formChooseAtLeast:`Elige al menos {min}`,formChooseAtMost:`Elige como máximo {max}`,formOther:`Otro`,formOtherPlaceholder:`Escribe tu respuesta…`,inputRequired:`Preguntas para ti`,inputBadge:`Preguntas`,inputAnswered:`Respondido`,inputSkipped:`Omitido`,showOptions:`Mostrar opciones`,hideOptions:`Ocultar opciones`,qtypeText:`Tu respuesta`,qtypeEmail:`Correo electrónico`,qtypePhone:`Número de teléfono`,qtypeNumber:`Número`,qtypeDate:`Fecha`,qtypeChooseOne:`Elige una`,qtypeChooseAny:`Elige varias`,qtypeBoolean:`Sí / No`,inputSubmit:`Enviar respuestas`,inputSubmitHint:`Enter para enviar · Mayús+Enter = nueva línea`,inputSkip:`Omitir`,confirmYes:`Sí`,confirmNo:`No`,approve:`Aprobar`,reject:`Rechazar`,approvalPrompt:`{tool} requiere tu aprobación para ejecutarse.`,approvalBody:`Revisa los parámetros de arriba y decide si permites esta acción.`,approvalYourResponse:`Tu respuesta: {decision}`,approvalEditHint:`Puedes cambiar tu respuesta hasta que este paso continúe.`,approvalSubmitting:`Respuesta enviada. Procesando…`,edit:`Editar`,toolParameters:`Parámetros`,statusAwaiting:`Esperando aprobación`,statusResponded:`Enviado`,statusRunning:`En curso`,statusCompleted:`Completado`,statusDenied:`Denegado`,statusError:`Error`,statusSuperseded:`Omitido`,statusIncomplete:`No completado`},he:{attach:`צירוף קבצים`,file:`קובץ`,attachmentMimeRejected:`סוג הקובץ אינו נתמך`,attachmentTooLarge:`הקובץ גדול מדי`,attachmentTooMany:`הגעת למספר המרבי של קבצים מצורפים`,conversationClosed:`הצ׳אט הזה נסגר`,conversationLoading:`טוען צ׳אט…`,loadPreviousMessages:`טעינת הודעות קודמות`,close:`סגירה`,collapse:`כיווץ`,collapseSidebar:`כיווץ סרגל הצד`,composerPlaceholder:`כתוב הודעה…`,dateLastWeek:`7 הימים האחרונים`,dateOlder:`ישן יותר`,dateToday:`היום`,dateYesterday:`אתמול`,dropZone:`שחרר קבצים כדי לצרף`,errorGeneric:`משהו השתבש`,errorRateLimited:`יותר מדי בקשות — נסה שוב בעוד רגע.`,errorRetry:`נסה שוב`,expand:`הרחבה`,expandSidebar:`הרחבת סרגל הצד`,exitFullscreen:`יציאה ממסך מלא`,fullscreen:`מסך מלא`,history:`היסטוריה`,historyBack:`חזרה לצ׳אט`,historyEmpty:`אין עדיין צ׳אטים קודמים`,historyContinue:`המשך צ׳אט`,historyLoading:`טוען את הצ׳אטים שלך…`,historyTitle:`היסטוריית צ׳אטים`,loadMoreConversations:`טעינת שיחות נוספות`,language:`שפה`,launcherOpen:`פתיחת צ׳אט`,launcherLabel:`דברו איתנו`,micStart:`התחלת קלט קולי`,micStop:`עצירת קלט קולי`,micUnsupported:`קלט קולי אינו נתמך בדפדפן זה`,moreActions:`פעולות נוספות`,newConversation:`צ׳אט חדש`,panelTitle:`צ׳אט`,popOut:`פתיחה בכרטיסייה חדשה`,resizeHandle:`גרור לשינוי הגודל`,scrollToBottom:`מעבר לחדש ביותר`,send:`שליחה`,queueMessage:`הוספת ההודעה לתור`,removeQueuedMessage:`הסרת ההודעה מהתור`,compactingContext:`מבצע אופטימיזציה להקשר השיחה…`,soundOff:`השתקת הצליל`,soundOn:`הפעלת הצליל`,startNewConversation:`התחלת צ׳אט חדש`,talkToOperator:`דברו עם אדם`,connectingOperator:`מחברים אותך לאדם…`,noOperatorAvailable:`אין נציגים זמינים כעת — השאר את הפרטים שלך ונחזור אליך.`,chattingWithOperator:`אתה מצ׳וטט עם {operator}`,cancelOperatorRequest:`המשך לשוחח עם ה-AI`,stop:`עצירה`,theme:`ערכת נושא`,themeAuto:`אוטומטי`,themeDark:`כהה`,themeLight:`בהיר`,textSize:`גודל טקסט`,textSizeSmall:`קטן`,textSizeNormal:`רגיל`,textSizeLarge:`גדול`,loading:`טוען…`,visualPreparing:`מכין תצוגה…`,visualError:`לא ניתן היה להציג תצוגה זו.`,visualPartial:`לא ניתן היה להציג חלקים מתצוגה זו.`,thinking:`חושב…`,thoughts:`מחשבות`,toolResult:`תוצאה`,sources:`מקורות`,feedbackUp:`תשובה טובה`,feedbackDown:`תשובה גרועה`,feedbackThanks:`תודה על המשוב`,copy:`העתק`,copied:`הועתק`,tabHome:`בית`,tabConversations:`צ׳אטים`,tabHelp:`עזרה`,tabNews:`חדשות`,modulesEmpty:`אין כאן עדיין כלום`,moduleBack:`חזרה`,contentLoading:`טוען…`,contentHelpful:`האם זה עזר?`,homeGreeting:`כיצד נוכל לעזור?`,homeGreetingNamed:`שלום {name} 👋`,homeGreetingLead:`כיצד נוכל לעזור?`,homeSearchPlaceholder:`חיפוש עזרה`,homeAskPlaceholder:`שאלו שאלה…`,homeWhatsNew:`מה חדש`,homeContentTitle:`מאמרים פופולריים`,homeStatus:`סטטוס`,helpTitle:`עזרה`,helpSearchPlaceholder:`חיפוש עזרה`,helpEmpty:`אין עדיין מאמרי עזרה`,helpLoading:`טוען עזרה…`,helpSearchEmpty:`אין תוצאות עבור „{query}”`,helpShowMore:`הצגת עוד`,newsTitle:`חדשות`,newsEmpty:`אין עדיין חדשות`,newsLoading:`טוען חדשות…`,newsBack:`חזרה לחדשות`,newsPublishedAt:`פורסם ב-{date}`,newsShowMore:`הצגת עוד`,newsUnseen:`פוסט חדש`,formSubmit:`שליחה`,formSkip:`אחר כך`,formSubmitted:`נשלח`,formSkipped:`דולג`,formFillOut:`מילוי`,formRequired:`שדה חובה`,formInvalidEmail:`הזן כתובת אימייל תקינה`,formInvalidTel:`הזן מספר טלפון תקין`,formInvalidUrl:`הזן כתובת URL תקינה`,formInvalidNumber:`הזן מספר תקין`,formTooShort:`קצר מדי (לפחות {min} תווים)`,formTooLong:`ארוך מדי (לכל היותר {max} תווים)`,formNumberTooSmall:`חייב להיות לפחות {min}`,formNumberTooLarge:`חייב להיות לכל היותר {max}`,formPatternMismatch:`התאם לתבנית הנדרשת`,formChooseAtLeast:`בחר לפחות {min}`,formChooseAtMost:`בחר לכל היותר {max}`,formOther:`אחר`,formOtherPlaceholder:`כתוב את תשובתך…`,inputRequired:`שאלות עבורך`,inputBadge:`שאלות`,inputAnswered:`נענה`,inputSkipped:`דולג`,showOptions:`הצג אפשרויות`,hideOptions:`הסתר אפשרויות`,qtypeText:`התשובה שלך`,qtypeEmail:`כתובת אימייל`,qtypePhone:`מספר טלפון`,qtypeNumber:`מספר`,qtypeDate:`תאריך`,qtypeChooseOne:`בחר אחת`,qtypeChooseAny:`בחר כמה`,qtypeBoolean:`כן / לא`,inputSubmit:`שליחת תשובות`,inputSubmitHint:`Enter לשליחה · Shift+Enter = שורה חדשה`,inputSkip:`דילוג`,confirmYes:`כן`,confirmNo:`לא`,approve:`אישור`,reject:`דחייה`,approvalPrompt:`הכלי {tool} דורש את אישורך כדי לפעול.`,approvalBody:`בדוק את פרמטרי הכלי שלמעלה והחלט אם לאשר פעולה זו.`,approvalYourResponse:`התגובה שלך: {decision}`,approvalEditHint:`ניתן לערוך את תגובתך עד שהשלב הזה יתחדש.`,approvalSubmitting:`התגובה נשלחה. מבצע…`,edit:`עריכה`,toolParameters:`פרמטרים`,statusAwaiting:`ממתין לאישור`,statusResponded:`נשלח`,statusRunning:`פועל`,statusCompleted:`הושלם`,statusDenied:`נדחה`,statusError:`שגיאה`,statusSuperseded:`דולג`,statusIncomplete:`לא הושלם`}};function Et(e,t){let n=Dt(e),r=jt(t),i=n===`en`?{}:Tt[n]??{},a=r?t[n]??{}:t??{},o=r?t.en??{}:{};return{...wt,...i,...o,...a}}function Dt(e){return(e.split(`-`)[0]??`en`).toLowerCase()}const Ot=/* @__PURE__ */ new Set([`ar`,`he`,`iw`,`fa`,`ur`,`ps`,`sd`,`ug`,`yi`,`dv`,`ckb`,`ks`,`nqo`,`prs`,`syr`]);function kt(e){return Ot.has(Dt(e))}function At(e,t){return e[t]??t}function jt(e){if(!e)return!1;for(let t of Object.values(e))if(t&&typeof t==`object`)return!0;return!1}const Mt=new class{get(e){try{return localStorage.getItem(e)}catch{return null}}set(e,t){try{localStorage.setItem(e,t)}catch{}}remove(e){try{localStorage.removeItem(e)}catch{}}},Nt={maxBytes:10485760,maxCount:10,accept:`*/*`},Pt={voice:`local`},Ft={list:[],byTrigger:{}},It={enabled:!0,sampleRate:1},Lt={upload:`/pai/upload-file`,transcribe:`/pai/transcribe-audio`,submitForm:`/pai/submit-form`},Rt={variant:`circle`,size:`md`,label:void 0,icon:`chat`,hidden:!1},zt={floating:[`theme`,`textSize`,`history`,`close`,`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`language`],inline:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],standalone:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],page:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],modal:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],drawer:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`]},Bt={enabled:!0,volume:.3,events:void 0},Vt={enabled:!0,events:void 0},Ht=[{label:`tabConversations`,layout:`chat`}],Ut=C.scope(`context`),Wt=/* @__PURE__ */ new Set([`visitorId`,`conversationId`,`jwt`,`token`,`authorization`,`password`]),Gt=1024,Kt=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function qt(e){return Yt(e,`userContext`,!0)}function Jt(e){return Yt(e,`pageContext`,!1)}function Yt(e,t,n){if(e==null)return;if(typeof e!=`object`||Array.isArray(e)){Ut.warn(`ignored ${t} — expected an object`,{type:Array.isArray(e)?`array`:typeof e});return}let r={},i=0;for(let[n,a]of Object.entries(e)){if(Wt.has(n)){Ut.warn(`dropped reserved ${t} key "${n}" — managed by the widget, not host-settable`);continue}if(a==null)continue;if(i>=50){Ut.warn(`${t} truncated at 50 keys — dropped "${n}"`);continue}let e=Xt(t,n,a);e!==void 0&&(r[n]=e,i++)}return n&&typeof r.email==`string`&&!Kt.test(r.email)&&(Ut.warn(`dropped malformed context field`,{field:`${t}.email`,reason:`invalid format`}),delete r.email),Object.keys(r).length>0?r:void 0}function Xt(e,t,n){if(typeof n==`boolean`)return n;if(typeof n==`number`){if(!Number.isFinite(n)){Ut.warn(`dropped non-finite ${e}.${t}`);return}return n}if(typeof n==`string`){let r=n.trim();return r===``?void 0:r.length>Gt?(Ut.warn(`truncated ${e}.${t} to ${Gt} chars`),r.slice(0,Gt)):r}Ut.warn(`dropped ${e}.${t} — only string/number/boolean values are allowed`,{type:typeof n})}function Zt(e){let t=typeof e==`object`&&e?e:{},n=t.presentation??{},r=t.behavior??{},i=t.i18n??{},a=t.feedback??{},o=t.footer??{},s=t.header??{},c={enabled:t.history?.enabled??!0},{themeMode:l,themeOverrides:d}=Qt(t.theme),f=n.mode??`floating`,p=$t(i.defaultLocale),m=i.availableLocales??[i.locale??p],h=en(i.locale??p,m,p),g=(t.baseUrl??u.defaultBaseUrl).replace(/\/$/,``),_=(t.agentApiBaseUrl??`${g}/api/agent`).replace(/\/$/,``),v=(t.dataApiBaseUrl??`${g}/api/data`).replace(/\/$/,``);return{widgetId:t.widgetId??`default`,publicKey:t.publicKey,aiAgentDeploymentId:t.aiAgentDeploymentId,baseUrl:g,agentApiBaseUrl:_,dataApiBaseUrl:v,userContext:qt(t.userContext),pageContext:Jt(t.pageContext),position:n.position??`bottom-right`,themeMode:l,textSize:`normal`,themeOverrides:d,mode:f,iframe:n.iframe??!1,responseMode:r.responseMode??`streaming`,showReasoning:r.showReasoning??!1,showToolCalls:r.showToolCalls??!1,showSources:r.showSources??!1,enableMessageFeedback:!(r.disableMessageFeedback??!1),autoSendSuggestions:r.autoSendSuggestions??!1,popOutUrl:r.popOutUrl,features:{voice:t.features?.voice??Pt.voice,fileUpload:!(t.features?.disableFileUpload??!1),humanInLoop:!(t.features?.disableHumanInLoop??!1),operatorRequest:t.features?.enableOperatorRequest===!0},forms:ln(t.forms,h),endpoints:{upload:t.endpoints?.upload??Lt.upload,transcribe:t.endpoints?.transcribe??Lt.transcribe,submitForm:t.endpoints?.submitForm??Lt.submitForm},attachments:{accept:t.composer?.attachments?.accept??Nt.accept,maxBytes:t.composer?.attachments?.maxBytes??Nt.maxBytes,maxCount:t.composer?.attachments?.maxCount??Nt.maxCount},locale:h,defaultLocale:p,availableLocales:m,startMinimized:r.startMinimized??!0,actions:tn(f,s.actions,c.enabled),size:n.size??{},launcher:dn(t.launcher),sound:nn(a.sound),haptics:rn(a.haptics),strings:Et(h,i.strings),stringsOverride:i.strings,composerDisclaimer:o.composerDisclaimer??``,poweredBy:on(o.poweredBy),composer:sn(t.composer),modules:cn(t.modules,c.enabled),tracking:an(t.tracking,v),history:c,storage:t.storage??Mt,userToken:t.userToken,tools:t.tools,onMessage:t.onMessage,onOpen:t.onOpen,onClose:t.onClose,onError:t.onError}}function Qt(e){if(typeof e==`string`)return{themeMode:e,themeOverrides:{}};if(!e||typeof e!=`object`)return{themeMode:`auto`,themeOverrides:{}};let{mode:t,...n}=e;return{themeMode:t??`auto`,themeOverrides:n}}function $t(e){return e&&e!==`auto`?e:globalThis.navigator?.language||`en`}function en(e,t,n){return t.length<=1||t.includes(e)?e:t.includes(n)?n:t[0]??e}function tn(e,t,n){let r=t??zt[e];return n?r:r.filter(e=>e!==`history`)}function nn(e){return{enabled:e?.enabled??Bt.enabled,volume:e?.volume??Bt.volume,events:e?.events}}function rn(e){return{enabled:e?.enabled??Vt.enabled,events:e?.events}}function an(e,t){let n=e?.sampleRate??It.sampleRate;return{enabled:e?.enabled??It.enabled,endpoint:e?.endpoint??`${t}/pai/elements-px.gif`,sampleRate:Math.min(1,Math.max(0,Number.isFinite(n)?n:1)),token:e?.token}}function on(e){let t={text:`Powered by ${u.displayName}`,href:u.siteUrl,...e};return t.text||t.logoUrl?t:null}function sn(e){let t=e?.sendButton;return{sendButton:{shape:t?.shape??`circle`,icon:t?.icon??`arrowUp`,variant:t?.variant??`filled`}}}function cn(e,t){let n=e??Ht,r=/* @__PURE__ */ new Set,i=[];for(let e of n.slice(0,4)){if(!e?.label||!e?.layout)continue;let n=e.contentCollectionIds?.filter(Boolean),a=e.id??n?.[0]??e.layout;for(;r.has(a);)a=`${a}-${i.length}`;r.add(a);let o={id:a,label:e.label,layout:e.layout};n?.length&&(o.contentCollectionIds=n),e.layout===`home`&&(o.brandName=e.brandName,o.greetingText=e.greetingText,o.showGreeting=!(e.hideGreeting??!1),o.showSearchBar=!(e.hideSearchBar??!1),o.showRecentConversations=t&&!(e.hideRecentConversations??!1),e.userAvatars?.length&&(o.userAvatars=e.userAvatars),e.status&&(o.status=e.status),o.contentBlockTitle=e.contentBlockTitle),i.push(o)}return{list:i,byId:Object.fromEntries(i.map(e=>[e.id,e]))}}function ln(e,t){if(!e?.length)return Ft;let n=[],r=/* @__PURE__ */ new Set;for(let i of e){if(!i?.id||r.has(i.id))continue;let e=Ct(i,t),a=(e.fields??[]).filter(e=>!!(e?.name&&e.label&&e.type)),o=(Array.isArray(e.on)?e.on:[e.on]).map(un).filter(e=>e!==null);a.length!==0&&o.length!==0&&(r.add(e.id),n.push({id:e.id,triggers:o,when:e.when,fields:a,title:e.title,description:e.description,submitLabel:e.submitLabel,skippable:e.skippable??!1,blocking:e.blocking??!1,frequency:e.frequency??`once`,mirrorToContext:e.mirrorToContext??!0,reopenable:e.reopenable??!0,reviewable:e.reviewable??!0}))}let i={};for(let e of n){var a;for(let t of e.triggers)(i[a=t.kind]??(i[a]=[])).push(e)}return{list:n,byTrigger:i}}function un(e){if(typeof e!=`string`)return null;if(e===`pre-chat`||e===`conversation-closed`||e===`panel-close`||e===`manual`)return{kind:e};let[t,n]=e.split(`:`,2);if(t===`after-messages`){let e=Number(n);return Number.isFinite(e)&&e>0?{kind:`after-messages`,param:e}:null}if(t===`idle`){let e=Number(n);return Number.isFinite(e)&&e>0?{kind:`idle`,param:e}:null}return t===`page-area`&&n?{kind:`page-area`,param:n}:null}function dn(e){let t=e?.callout?.text?{shape:`pill`,position:`auto`,delayMs:1200,autoDismissMs:0,animated:!0,persistent:!0,...e.callout}:null;return{variant:e?.variant??Rt.variant,size:e?.size??Rt.size,label:e?.label??Rt.label,icon:e?.icon??Rt.icon,hidden:e?.hidden??Rt.hidden,callout:t}}function fn(e,t,n,r){let i=en(t,e.availableLocales,e.defaultLocale);if(i===e.locale&&n===e.themeMode&&r===e.textSize)return e;let a={...e};return i!==e.locale&&(a.locale=i,a.strings=Et(i,e.stringsOverride)),n!==e.themeMode&&(a.themeMode=n),r!==e.textSize&&(a.textSize=r),a}const pn=[`presentation`,`behavior`,`theme`,`launcher`,`header`,`composer`,`feedback`,`i18n`,`footer`,`features`,`tracking`,`endpoints`,`history`];function mn(e,t){if(!t)return e;let n={...e};for(let r of pn){let i=t[r];if(i===void 0)continue;let a=e[r];r===`theme`?a===void 0?n[r]=i:typeof a==`string`&&typeof i==`object`&&i&&(n[r]={...i,mode:a}):r!==`i18n`&&(n[r]=hn(i,a))}t.modules!==void 0&&e.modules===void 0&&(n.modules=t.modules),t.dataApiBaseUrl!==void 0&&e.dataApiBaseUrl===void 0&&(n.dataApiBaseUrl=t.dataApiBaseUrl);let r=e.i18n,i=t.i18n;if(r||i){let e=hn(i??{},r);i?.availableLocales!==void 0&&(e.availableLocales=i.availableLocales),i?.defaultLocale!==void 0&&(e.defaultLocale=i.defaultLocale);let t=r?.strings,a=i?.strings;(t||a)&&(e.strings=gn(a,t)),n.i18n=e}return n}function hn(e,t){if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function gn(e,t){if(!e)return t;if(!t)return e;let n=jt(e),r=jt(t);if(!n&&!r)return{...e,...t};let i={},a=n?e:{en:e},o=r?t:{en:t};for(let[e,t]of Object.entries(a))i[e]={...t};for(let[e,t]of Object.entries(o))i[e]={...i[e],...t};return i}const _n=[`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`history`,`language`,`theme`,`textSize`,`close`];function vn(e){return e!==`false`}const yn=[[`public-key`,`publicKey`],[`ai-agent-deployment-id`,`aiAgentDeploymentId`],[`base-url`,`baseUrl`],[`agent-api-base-url`,`agentApiBaseUrl`],[`data-api-base-url`,`dataApiBaseUrl`],[`theme`,`theme`,e=>e]],bn=[[`mode`,`mode`,e=>e],[`position`,`position`,e=>e],[`iframe`,`iframe`,vn]],xn=[[`width`,`width`],[`height`,`height`]],Sn=[[`response-mode`,`responseMode`,e=>e],[`start-minimized`,`startMinimized`,vn],[`show-reasoning`,`showReasoning`,vn],[`show-tool-calls`,`showToolCalls`,vn],[`show-sources`,`showSources`,vn],[`disable-message-feedback`,`disableMessageFeedback`,vn],[`auto-send-suggestions`,`autoSendSuggestions`,vn],[`pop-out-url`,`popOutUrl`]],Cn=[[`locale`,`locale`]];new Set(_n);const wn=[[`launcher-variant`,`variant`,e=>e],[`launcher-size`,`size`,e=>e],[`launcher-icon`,`icon`],[`launcher-hidden`,`hidden`,vn]],Tn=[[`features-disable-file-upload`,`disableFileUpload`,vn],[`features-voice`,`voice`,e=>e]],En=[[`endpoint-upload`,`upload`],[`endpoint-transcribe`,`transcribe`]],Dn=[[`user-id`,`id`],[`user-email`,`email`],[`user-name`,`name`]],On=[[`page-area`,`area`],[`page-url`,`url`],[`page-path`,`path`],[`page-title`,`title`]],kn=[`launcher-label`,`callout-text`,`callout-delay`,`actions`,`user-context`,`page-context`],An=[yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On],jn=/* @__PURE__ */ new Set([`iframe`,`start-minimized`]);[...An.flatMap(e=>e.map(([e])=>e).filter(e=>!jn.has(e))),...kn];const Mn=C.scope(`track`);function Nn(e,t){let n=typeof e==`string`?e.trim():``;if(!n||n.length>64){Mn.warn(`track: ignored an event without a name of 1–64 characters`,{name:e});return}let r=Object.fromEntries(Object.entries(typeof t==`object`&&t?t:{}).filter(e=>typeof e[1]==`string`||typeof e[1]==`boolean`||Number.isFinite(e[1])));return JSON.stringify(r).length>256?(Mn.warn(`track: sent the event without its data, which is over 256 characters`,{name:n}),{name:n}):Object.keys(r).length>0?{name:n,data:r}:{name:n}}function Pn(e){let t=[];return e.on(`hostEvent`,e=>{t.push({...e,at:Date.now()}),t.length>10&&t.shift()}),t}function Fn(){let e=Date.now(),t=/* @__PURE__ */ new Uint8Array(16);t[0]=Math.floor(e/2**40)&255,t[1]=Math.floor(e/2**32)&255,t[2]=e>>>24&255,t[3]=e>>>16&255,t[4]=e>>>8&255,t[5]=e&255,In(t.subarray(6)),t[6]=t[6]&15|112,t[8]=t[8]&63|128;let n=Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function In(e){if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}const Ln=C.scope(`persistence`);function Rn(e,t=Mt,n){let r=n?`${e}.${n}`:e,i=`${u.cssPrefix}.storageVersion`,a=t.get(i)??void 0,o=a?`.v${a}`:``,s=`${u.cssPrefix}.${r}${o}`,c=`${u.cssPrefix}${o}.visitorId`,l=`${s}.conversationId`,d=`${s}.userPrefs`,f=`${s}.panelOpen`,p=`${s}.panelSize`,m=`${s}.calloutDismissed`,h=`${s}.sidebarCollapsed`,g=`${s}.activeModule`,_=`${s}.seenNewsId`,v=`${s}.historyCount`,y=`${s}.formsDone`,b={getVisitorId(){let e=t.get(c);if(e)return e;let n=Fn();return t.set(c,n),n},loadConversationId(){return t.get(l)??void 0},saveConversationId(e){Ln.trace(`saveConversationId`,{id:e,scope:r}),e?t.set(l,e):t.remove(l)},loadDraft(e){return t.get(`${s}.draft.${e}`)??``},saveDraft(e,n){let r=`${s}.draft.${e}`;n?t.set(r,n):t.remove(r)},loadMessageQueue(e){let n=t.get(`${s}.messageQueue.${e}`);if(!n)return[];try{let e=JSON.parse(n);return!Array.isArray(e)||!e.every(Bn)?[]:e}catch(e){return Ln.warn(`loadMessageQueue parse failed`,{error:e}),[]}},saveMessageQueue(e,n){let r=`${s}.messageQueue.${e}`;if(n.length===0)t.remove(r);else try{t.set(r,JSON.stringify(n))}catch(e){Ln.warn(`saveMessageQueue serialise failed`,{error:e})}},loadUserPrefs(){let e=t.get(d);if(!e)return{};try{return Vn(JSON.parse(e))}catch(e){return Ln.warn(`loadUserPrefs parse failed`,{error:e}),{}}},saveUserPrefs(e){try{t.set(d,JSON.stringify(e))}catch(e){Ln.warn(`saveUserPrefs serialise failed`,{error:e})}},patchUserPrefs(e){let t=b.loadUserPrefs();b.saveUserPrefs({...t,...e})},loadPanelOpen(){let e=t.get(f);return e===`1`||e!==`0`&&null},savePanelOpen(e){t.set(f,e?`1`:`0`)},loadPanelSize(){let e=t.get(p);return e===`normal`||e===`expanded`||e===`fullscreen`?e:null},savePanelSize(e){t.set(p,e)},loadCalloutDismissed(e){if(!e)return!1;let n=t.get(m);return!!n&&n===e},saveCalloutDismissed(e){e?t.set(m,e):t.remove(m)},loadSidebarCollapsed(){let e=t.get(h);return e===`1`||e!==`0`&&null},saveSidebarCollapsed(e){t.set(h,e?`1`:`0`)},loadActiveModule(){return t.get(g)||null},saveActiveModule(e){t.set(g,e)},loadSeenNewsId(){return t.get(_)||null},saveSeenNewsId(e){t.set(_,e)},loadHistoryCount(){let e=t.get(v);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:null},saveHistoryCount(e){t.set(v,String(e))},loadFormsDone(){let e=t.get(y);if(!e)return{};try{let t=JSON.parse(e);return zn(t)?Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]==`number`)):{}}catch(e){return Ln.warn(`loadFormsDone parse failed`,{error:e}),{}}},saveFormDone(e){try{let n=b.loadFormsDone();n[e]=Date.now(),t.set(y,JSON.stringify(n))}catch(e){Ln.warn(`saveFormDone serialise failed`,{error:e})}},rememberStorageVersion(e){e&&e!==t.get(i)&&(Ln.debug(`rememberStorageVersion (force-reset on next load)`,{version:e}),t.set(i,e))},clearConversation(){t.remove(l)},reset(){let e=t.get(l);e&&(t.remove(`${s}.draft.${e}`),t.remove(`${s}.messageQueue.${e}`));for(let e of[c,l,d,f,p,m,h,g,_,v,y])t.remove(e);Ln.info(`reset: forgot the visitor`,{scope:r})}};return b}function zn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Bn(e){return zn(e)&&typeof e.id==`string`&&e.id.length>0&&typeof e.text==`string`}function Vn(e){if(!zn(e))return{};let t={};return typeof e.locale==`string`&&(t.locale=e.locale),typeof e.soundMuted==`boolean`&&(t.soundMuted=e.soundMuted),(e.themeMode===`auto`||e.themeMode===`light`||e.themeMode===`dark`)&&(t.themeMode=e.themeMode),(e.textSize===`small`||e.textSize===`normal`||e.textSize===`large`)&&(t.textSize=e.textSize),zn(e.widgetSize)&&typeof e.widgetSize.width==`number`&&typeof e.widgetSize.height==`number`&&(t.widgetSize={width:e.widgetSize.width,height:e.widgetSize.height}),t}const Hn=`1.12.9`,Un={open:()=>void 0,close:()=>void 0,expand:e=>({on:e}),fullscreen:e=>({on:e}),send:e=>({attachments:e.attachmentCount}),message:e=>({role:e.role}),stop:()=>void 0,clear:()=>void 0,suggestion:()=>void 0,toggleHistory:e=>({view:e.view}),handshake:()=>void 0,formSubmit:e=>({formId:e.formId,skipped:e.skipped}),toolResult:()=>void 0,toolDecision:e=>({approved:e.approved}),hostEvent:e=>({name:e.name,data:e.data&&JSON.stringify(e.data)}),messageFeedback:e=>({value:e.value??`none`}),contentView:e=>({section:e.section,count:e.count}),contentOpen:e=>({contentId:e.contentId,contentCollectionId:e.contentCollectionId}),contentSearch:e=>({qlen:e.queryLength,hits:e.hitCount}),contentRead:e=>({contentId:e.contentId}),contentLinkClick:e=>({contentId:e.contentId}),attach:e=>({count:e.count,bytes:e.totalBytes}),voiceStart:()=>void 0,voiceStop:e=>({ms:e.durationMs}),voiceCancel:()=>void 0,localeChange:e=>({locale:e}),themeChange:e=>({theme:e}),textSizeChange:e=>({size:e}),soundToggle:e=>({muted:e.muted}),sidebarToggle:e=>({collapsed:e.collapsed}),calloutDismiss:()=>void 0,error:()=>void 0};function Wn(){let e=navigator;return e.globalPrivacyControl===!0||e.doNotTrack===`1`}function Gn(){return location.origin+location.pathname}function Kn(){try{return document.referrer?new URL(document.referrer).origin:``}catch{return``}}function qn(e,t){let n=Math.random(),r=0,i=0,a=/* @__PURE__ */ new Set;function o(e,o){let{tracking:s,publicKey:c,aiAgentDeploymentId:l,mode:u,themeMode:d}=t.getOptions();if(!s.enabled||Wn()||n>=s.sampleRate)return;let f=performance.now();if(f-r>6e4&&(r=f,i=0),++i>60)return;let p=new URLSearchParams;p.set(`v`,`1`),p.set(`_ev`,Hn),p.set(`e`,e),s.token&&p.set(`tk`,s.token),c&&p.set(`pk`,c),l&&p.set(`dep`,l),p.set(`vid`,t.getVisitorId());let m=t.getConversationId();m&&p.set(`cid`,m),p.set(`url`,Gn());let h=Kn();h&&p.set(`ref`,h),p.set(`sw`,String(screen.width)),p.set(`sh`,String(screen.height)),p.set(`vw`,String(innerWidth)),p.set(`vh`,String(innerHeight)),p.set(`dpr`,String(devicePixelRatio)),p.set(`lang`,navigator.language);try{p.set(`tz`,Intl.DateTimeFormat().resolvedOptions().timeZone)}catch{}if(p.set(`m`,u),p.set(`th`,d),o)for(let[e,t]of Object.entries(o))t!==void 0&&p.set(e,String(t));p.set(`ts`,String(Date.now()));let g=`${s.endpoint}?${p}`;if(g.length>2e3)return;let _=new Image(1,1);a.add(_);function v(){return a.delete(_)}_.addEventListener(`load`,v,{once:!0}),_.addEventListener(`error`,v,{once:!0}),_.src=g}let s=[];function c(e,t){if(s&&e!==`handshake`){s.length<60&&s.push([e,t]);return}let n=s??[];s=void 0;for(let[e,t]of n)o(e,t);o(e,t)}let l=Object.keys(Un).map(t=>e.on(t,e=>c(t,Un[t]?.(e))));return()=>{for(let e of l)e();a.clear()}}const Jn=`:host{--__P__-accent-user: __BRAND_ACCENT__;--__P__-accent: var(--__P__-accent-user);--__P__-accent-text-user: __BRAND_ACCENT_TEXT__;--__P__-accent-text: var(--__P__-accent-text-user);--__P__-accent-fg: var(--__P__-accent);--__P__-radius: __BRAND_RADIUS__;--__P__-radius-sm: 8px;--__P__-radius-md: 10px;--__P__-radius-lg: 16px;--__P__-font: __BRAND_FONT__;--__P__-font-display: var(--__P__-font);--__P__-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;--__P__-bg: oklch(1 0 0);--__P__-bg-elevated: oklch(.9789 .0029 278.3);--__P__-surface: var(--__P__-bg-elevated);--__P__-muted: var(--__P__-fg-muted);--__P__-hover: oklch(.1686 .011 278.3 / .06);--__P__-fg: oklch(.1686 .011 278.3);--__P__-fg-muted: oklch(.4932 .0301 278.3);--__P__-border: oklch(.9312 .0084 278.3);--__P__-border-strong: oklch(.8757 .0131 278.3);--__P__-bubble-user: var(--__P__-accent);--__P__-bubble-user-text: var(--__P__-accent-text);--__P__-bubble-assistant: oklch(.9638 .0058 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-on-accent: var(--__P__-accent-text);--__P__-success: oklch(.6456 .1654 151.53);--__P__-warning: oklch(.7135 .1494 74.05);--__P__-danger: oklch(.5966 .1818 24.51);--__P__-danger-text: oklch(.5054 .1905 27.52);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .1);--__P__-neutral: oklch(.7137 .0192 278.3);--__P__-pill-l-min: .3;--__P__-pill-l-max: .46;--__P__-focus: var(--__P__-accent);--__P__-shadow-panel: 0 8px 24px -8px rgba(13, 15, 20, .18), 0 24px 64px -24px rgba(13, 15, 20, .24);--__P__-shadow-card: 0 1px 2px rgba(13, 15, 20, .06), 0 4px 12px -6px rgba(13, 15, 20, .12);--__P__-backdrop: oklch(.1686 .011 278.3 / .55);--__P__-shadow-fab: 0 6px 16px -4px color-mix(in oklch, var(--__P__-accent) 45%, transparent), 0 12px 32px -12px rgba(13, 15, 20, .25);--__P__-z-fab: 2147483600;--__P__-z-panel: 2147483601;--__P__-panel-w: 380px;--__P__-panel-h: 600px;--__P__-fab-size: 56px;--__P__-conversation-max: 768px;--__P__-space-1: 4px;--__P__-space-2: 8px;--__P__-space-3: 12px;--__P__-space-4: 16px;--__P__-space-5: 20px;--__P__-space-6: 24px;--__P__-space-8: 32px;--__P__-text-scale: 1;--__P__-text-xs: calc(12px * var(--__P__-text-scale));--__P__-text-sm: calc(13px * var(--__P__-text-scale));--__P__-text-base: calc(15px * var(--__P__-text-scale));--__P__-text-md: calc(16px * var(--__P__-text-scale));--__P__-text-lg: calc(18px * var(--__P__-text-scale));--__P__-text-xl: calc(22px * var(--__P__-text-scale));--__P__-text-2xl: calc(30px * var(--__P__-text-scale))}:host([data-mode="modal"]),:host([data-mode="drawer"]){--__P__-conversation-max: 100%}:host([data-text-size="small"]){--__P__-text-scale: .9}:host([data-text-size="large"]){--__P__-text-scale: 1.15}:host{--__P__-ease: cubic-bezier(.2, .7, .2, 1);--__P__-ease-out: cubic-bezier(.2, .7, .2, 1);--__P__-ease-in: cubic-bezier(.4, 0, 1, 1);--__P__-ease-in-out: cubic-bezier(.65, 0, .35, 1);--__P__-dur-quick: .12s;--__P__-dur-base: .22s;--__P__-dur-slow: .32s;font-family:var(--__P__-font);color:var(--__P__-fg);color-scheme:light;--__P__-color-scheme: light}:host([data-theme="dark"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-danger-text: oklch(.8077 .1035 19.57);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .18);--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);--__P__-shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px -6px rgba(0, 0, 0, .5);--__P__-backdrop: rgba(0, 0, 0, .65);--__P__-pill-l-min: .75;--__P__-pill-l-max: .92;color-scheme:dark;--__P__-color-scheme: dark}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-pill-l-min: .75;--__P__-pill-l-max: .92;--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);color-scheme:dark;--__P__-color-scheme: dark}}@supports (color: oklch(from red l c h)){:host{--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.3, l, .62) c h);--__P__-accent-text: oklch(from var(--__P__-accent) clamp(0, (l / .623 - 1) * -infinity, 1) 0 h);--__P__-accent-fg: oklch(from var(--__P__-accent-user) clamp(.3, l, .46) c h)}:host([data-theme="dark"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}}}@media(prefers-reduced-motion:reduce){:host{--__P__-dur-quick: 1ms;--__P__-dur-base: 1ms;--__P__-dur-slow: 1ms}}
3
3
 
4
4
  *,*:before,*:after{box-sizing:border-box;margin:0;padding:0;border:0}button{font:inherit;color:inherit;background:none;cursor:pointer;-webkit-appearance:none;appearance:none;line-height:1}button:focus-visible,[tabindex]:focus-visible,textarea:focus-visible,input:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px}textarea,input{font:inherit;color:inherit;background:none;border:0;outline:0;resize:none}a{color:var(--__P__-accent-fg);text-decoration:underline;text-underline-offset:2px}img,svg{display:block;max-width:100%}ul,ol{list-style:none}.__P__-app{display:block;width:100%;height:100%;font-family:var(--__P__-font);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-feature-settings:"cv11","ss01","ss03"}.__P__-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
5
5
 
6
- .__P__-anchor{color-scheme:var(--__P__-color-scheme, light);right:16px;bottom:16px}.__P__-surface{display:contents}.__P__-surface[hidden]{display:none}:host([data-position="bottom-left"]) .__P__-anchor,:host([data-position="top-left"]) .__P__-anchor{right:auto;left:16px}:host([data-position="top-right"]) .__P__-anchor,:host([data-position="top-left"]) .__P__-anchor{bottom:auto;top:16px}.__P__-anchor{position:fixed;display:flex;flex-direction:column;align-items:flex-end;gap:var(--__P__-space-3);pointer-events:none}.__P__-anchor{--__P__-fab-size: 56px}.__P__-anchor[data-launcher-size=sm]{--__P__-fab-size: 44px}.__P__-anchor[data-launcher-size=md]{--__P__-fab-size: 56px}.__P__-anchor[data-launcher-size=lg]{--__P__-fab-size: 68px}.__P__-anchor>*{pointer-events:auto}.__P__-fab[data-size=sm]{--__P__-fab-size: 44px;font-size:var(--__P__-text-sm)}.__P__-fab[data-size=md]{--__P__-fab-size: 56px;font-size:calc(14px * var(--__P__-text-scale))}.__P__-fab[data-size=lg]{--__P__-fab-size: 68px;font-size:var(--__P__-text-base)}.__P__-fab{display:inline-flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);color:var(--__P__-accent-text);background:var(--__P__-accent);box-shadow:var(--__P__-shadow-fab);font-weight:600;line-height:1;transform-origin:bottom right;animation:__P__-fab-in var(--__P__-dur-base) var(--__P__-ease) both;transition:transform var(--__P__-dur-base) var(--__P__-ease),opacity var(--__P__-dur-base) var(--__P__-ease),box-shadow var(--__P__-dur-base) var(--__P__-ease)}.__P__-fab:hover{transform:translateY(-2px)}.__P__-fab:active{transform:translateY(0)}.__P__-fab:focus-visible{outline:2px solid var(--__P__-on-accent);outline-offset:3px}.__P__-fab svg{width:24px;height:24px;flex-shrink:0}@keyframes __P__-fab-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:none}}.__P__-fab[data-leaving]{position:absolute;right:0;bottom:0;animation:__P__-fab-out var(--__P__-dur-quick) var(--__P__-ease) forwards;pointer-events:none}:host([data-position^="top-"]) .__P__-fab[data-leaving]{bottom:auto;top:0}:host([data-position$="-left"]) .__P__-fab[data-leaving]{right:auto;left:0}@keyframes __P__-fab-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.85)}}.__P__-fab[data-variant=circle]{width:var(--__P__-fab-size);height:var(--__P__-fab-size);border-radius:999px}.__P__-fab[data-variant=circle] .__P__-fab-label{display:none}.__P__-fab[data-variant=pill]{height:var(--__P__-fab-size);padding:0 18px 0 16px;border-radius:999px}.__P__-fab[data-variant=bar]{height:var(--__P__-fab-size);padding:0 22px;border-radius:var(--__P__-radius)}.__P__-fab[data-variant=minimal]{height:var(--__P__-fab-size);padding:0 var(--__P__-space-4);border-radius:999px;background:transparent;color:var(--__P__-accent-fg);box-shadow:none;border:1px solid currentColor}.__P__-fab[data-variant=minimal]:hover{background:color-mix(in srgb,var(--__P__-accent) 12%,transparent)}.__P__-callout{--__P__-callout-fab-h: var(--__P__-fab-size, 56px);--__P__-callout-gap: clamp(12px, calc(var(--__P__-callout-fab-h) * .25), 22px);--__P__-callout-nudge-direction: -1;position:absolute;display:inline-flex;align-items:center;gap:var(--__P__-space-2);padding:10px 14px;background:var(--__P__-fg);color:var(--__P__-bg);border-radius:999px;font-size:var(--__P__-text-sm);font-weight:600;line-height:1.2;box-shadow:0 10px 30px -8px #00000059;pointer-events:auto;animation:__P__-callout-in var(--__P__-dur-slow) var(--__P__-ease);z-index:1;max-width:240px;white-space:nowrap}.__P__-callout[data-position=left]{right:calc(100% + var(--__P__-callout-gap));bottom:calc(var(--__P__-callout-fab-h) / 2);transform:translateY(50%)}.__P__-callout[data-position=right]{left:calc(100% + var(--__P__-callout-gap));bottom:calc(var(--__P__-callout-fab-h) / 2);transform:translateY(50%);--__P__-callout-nudge-direction: 1}.__P__-callout[data-position=top]{bottom:calc(100% + var(--__P__-callout-gap));right:0;max-width:min(280px,calc(100vw - 32px))}.__P__-callout[data-position=bottom]{top:calc(100% + var(--__P__-callout-gap));right:0;max-width:min(280px,calc(100vw - 32px))}:host([data-position$="-left"]) .__P__-callout[data-position=top],:host([data-position$="-left"]) .__P__-callout[data-position=bottom]{right:auto;left:0}.__P__-callout[data-shape=bubble]{border-radius:var(--__P__-radius-md);white-space:normal;width:max-content;max-width:min(280px,calc(100vw - 32px))}.__P__-callout[data-shape=callout]{padding:12px 18px;font-size:calc(14px * var(--__P__-text-scale));background:var(--__P__-accent);color:var(--__P__-accent-text)}.__P__-callout:after{content:"";position:absolute;width:12px;height:12px;background:inherit;border-radius:2px;transform:rotate(45deg)}.__P__-callout[data-position=left]:after{right:-5px;top:50%;margin-top:-6px}.__P__-callout[data-position=right]:after{left:-5px;top:50%;margin-top:-6px}.__P__-callout[data-position=top]:after{bottom:-5px;right:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}.__P__-callout[data-position=bottom]:after{top:-5px;right:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}:host([data-position$="-left"]) .__P__-callout[data-position=top]:after,:host([data-position$="-left"]) .__P__-callout[data-position=bottom]:after{right:auto;left:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}.__P__-callout[data-animated]{animation:__P__-callout-in var(--__P__-dur-slow) var(--__P__-ease),__P__-callout-nudge 1.6s var(--__P__-ease-in-out) var(--__P__-dur-slow) infinite}@keyframes __P__-callout-in{0%{opacity:0}to{opacity:1}}@keyframes __P__-callout-nudge{0%,to{margin-left:0;margin-right:0}50%{margin-left:calc(6px * var(--__P__-callout-nudge-direction));margin-right:calc(-6px * var(--__P__-callout-nudge-direction))}}@media(prefers-reduced-motion:reduce){.__P__-callout[data-animated]{animation:__P__-callout-in 1ms var(--__P__-ease)}.__P__-icon-btn[data-recording=true],.__P__-typing span{animation:none}}.__P__-callout-close{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:999px;color:inherit;opacity:.7;cursor:pointer}.__P__-callout-close:hover{opacity:1;background:color-mix(in srgb,currentColor 15%,transparent)}.__P__-callout-close:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-callout-close svg{width:12px;height:12px}.__P__-panel{width:var(--__P__-panel-w);height:var(--__P__-panel-h);max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);background:var(--__P__-bg);color:var(--__P__-fg);border-radius:var(--__P__-radius-lg);box-shadow:var(--__P__-shadow-panel);display:flex;flex-direction:column;overflow:hidden;overscroll-behavior:none;transform-origin:bottom right;animation:__P__-panel-in var(--__P__-dur-slow) var(--__P__-ease);border:1px solid var(--__P__-border)}@media(prefers-reduced-motion:no-preference){.__P__-panel{transition:width var(--__P__-dur-base) var(--__P__-ease),height var(--__P__-dur-base) var(--__P__-ease),max-width var(--__P__-dur-base) var(--__P__-ease),max-height var(--__P__-dur-base) var(--__P__-ease)}.__P__-panel[data-resizing]{transition:none}}:host([data-mode="open"]) .__P__-panel{width:var(--__P__-widget-w, var(--__P__-panel-w));height:var(--__P__-widget-h, var(--__P__-panel-h));min-width:var(--__P__-resize-min-w, auto);min-height:var(--__P__-resize-min-h, auto);max-width:var(--__P__-resize-max-w, calc(100vw - 32px) );max-height:var(--__P__-resize-max-h, calc(100dvh - 32px) )}@keyframes __P__-panel-in{0%{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}:host([data-mode="expanded"]) .__P__-panel{width:var(--__P__-expanded-w, 640px);height:var(--__P__-expanded-h, 820px);max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px)}:host([data-mode="fullscreen"]){z-index:var(--__P__-z-panel)!important}:host([data-mode="fullscreen"]) .__P__-anchor{inset:var(--__P__-visual-viewport-top, 0px) 0 auto;height:var(--__P__-visual-viewport-height, 100dvh);padding:0;justify-content:flex-end;align-items:flex-end}:host([data-mode="fullscreen"][data-position*="top"]) .__P__-anchor{justify-content:flex-start}:host([data-mode="fullscreen"][data-position*="left"]) .__P__-anchor{align-items:flex-start}:host([data-mode="fullscreen"]) .__P__-panel{width:100vw;height:100%;max-width:none;max-height:none;border-radius:0;border:0}:host([data-mode="fullscreen"]) .__P__-fab{display:none}@media(max-width:640px){:host([data-mode="open"]) .__P__-anchor,:host([data-mode="expanded"]) .__P__-anchor{inset:var(--__P__-visual-viewport-top, 0px) 0 auto;align-items:stretch;height:var(--__P__-visual-viewport-height, 100dvh);padding:0}:host([data-mode="open"]) .__P__-panel,:host([data-mode="expanded"]) .__P__-panel{width:100vw;height:100%;max-width:none;max-height:none;border-radius:0;border:0}}:host([data-mode="inline"]) .__P__-anchor,:host([data-mode="standalone"]) .__P__-anchor{position:static;inset:auto;padding:0;align-items:stretch;width:100%;height:100%;min-height:0}:host([data-mode="inline"]) .__P__-panel,:host([data-mode="standalone"]) .__P__-panel{width:100%;height:100%;min-width:0;min-height:0;max-width:none;max-height:none;animation:none}:host([data-mode="inline"]) .__P__-fab,:host([data-mode="standalone"]) .__P__-fab{display:none}:host([data-mode="inline"]){min-height:320px}:host([data-mode="inline"]) .__P__-panel{border-radius:var(--__P__-radius)}:host([data-mode="standalone"]) .__P__-panel{border-radius:0;border:0;box-shadow:none}:host([data-mode="modal"]){position:fixed!important;inset:0!important;z-index:var(--__P__-z-panel)!important;display:block!important;width:100vw;height:100dvh;background:var(--__P__-modal-backdrop, var(--__P__-backdrop));animation:__P__-backdrop-in var(--__P__-dur-base) var(--__P__-ease) both;--__P__-panel-w: min(960px, 92vw);--__P__-panel-h: min(720px, 88dvh)}:host([data-mode="modal"]) .__P__-anchor{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:var(--__P__-space-6);pointer-events:none}:host([data-mode="modal"]) .__P__-panel{pointer-events:auto;width:var(--__P__-widget-w, var(--__P__-panel-w));height:var(--__P__-widget-h, var(--__P__-panel-h));max-width:calc(100vw - 48px);max-height:calc(100dvh - 48px);min-width:0;min-height:0;border-radius:var(--__P__-radius);box-shadow:var(--__P__-shadow-panel);animation:__P__-modal-in var(--__P__-dur-base) var(--__P__-ease);translate:var(--__P__-modal-dx, 0px) var(--__P__-modal-dy, 0px)}:host([data-mode="modal"]) .__P__-header,:host([data-mode="modal"]) .__P__-back-header,:host([data-mode="modal"]) .__P__-home-hero{cursor:grab;touch-action:none}:host([data-mode="modal"]) .__P__-panel[data-dragging]{cursor:grabbing;user-select:none}:host([data-mode="modal"]) .__P__-panel[data-dragging] *{cursor:grabbing}:host([data-mode="modal"]) .__P__-fab{display:none}@keyframes __P__-backdrop-in{0%{background:#0000}to{background:var(--__P__-modal-backdrop, var(--__P__-backdrop))}}@keyframes __P__-modal-in{0%{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}:host([data-mode="drawer"]){--__P__-panel-w: min(440px, calc(100vw - 32px) );--__P__-panel-h: 100dvh}:host([data-mode="drawer"]) .__P__-anchor{position:fixed;--__P__-inset-x: var(--__P__-panel-inset, 12px);--__P__-inset-y: var(--__P__-panel-inset, 3dvh);top:var(--__P__-inset-y);bottom:auto;right:var(--__P__-inset-x);left:auto;width:min(var(--__P__-widget-w, var(--__P__-panel-w)),calc(100vw - var(--__P__-inset-x) * 2));height:min(var(--__P__-widget-h, var(--__P__-panel-h)),calc(100dvh - var(--__P__-inset-y) * 2));padding:0;display:block;pointer-events:auto}:host([data-mode="drawer"][data-position$="-left"]) .__P__-anchor{right:auto;left:var(--__P__-inset-x)}:host([data-mode="drawer"][data-position^="bottom-"]) .__P__-anchor{top:auto;bottom:var(--__P__-inset-y)}:host([data-mode="drawer"]) .__P__-panel{width:100%;height:100%;max-width:none;max-height:none;min-width:0;min-height:0;border-radius:var(--__P__-radius, 12px);border:1px solid var(--__P__-border);box-shadow:-8px 16px 32px -12px #00000038;animation:__P__-drawer-in var(--__P__-dur-base) var(--__P__-ease)}:host([data-mode="drawer"][data-position$="-left"]) .__P__-panel{box-shadow:8px 16px 32px -12px #00000038;animation:__P__-drawer-in-left var(--__P__-dur-base) var(--__P__-ease)}.__P__-fab[data-edge-tab]{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--__P__-space-2);position:fixed;top:50%;height:140px;width:auto;min-width:0;padding:10px 8px;writing-mode:vertical-rl;text-orientation:mixed;transform:translateY(-50%);transform-origin:center;animation:__P__-edge-tab-in var(--__P__-dur-base) var(--__P__-ease) both}.__P__-fab[data-edge-tab] svg{writing-mode:horizontal-tb}.__P__-fab[data-edge-tab]:hover{transform:translateY(-50%) scale(1.03)}.__P__-fab[data-edge-tab]:active{transform:translateY(-50%) scale(.97)}:host([data-position$="-right"]) .__P__-fab[data-edge-tab]{right:0;left:auto;border-radius:12px 0 0 12px;box-shadow:-6px 0 18px -8px #0000004d}:host([data-position$="-left"]) .__P__-fab[data-edge-tab]{left:0;right:auto;border-radius:0 12px 12px 0;box-shadow:6px 0 18px -8px #0000004d}.__P__-fab[data-edge-tab][data-leaving]{position:fixed;top:50%;bottom:auto;animation:__P__-edge-tab-out var(--__P__-dur-quick) var(--__P__-ease) forwards}@keyframes __P__-edge-tab-in{0%{opacity:0;transform:translateY(-50%) scale(.9)}to{opacity:1;transform:translateY(-50%) scale(1)}}@keyframes __P__-edge-tab-out{0%{opacity:1;transform:translateY(-50%) scale(1)}to{opacity:0;transform:translateY(-50%) scale(.85)}}@keyframes __P__-drawer-in{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes __P__-drawer-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}@media(prefers-reduced-motion:reduce){:host([data-mode="drawer"]) .__P__-panel,.__P__-fab[data-edge-tab]{animation:none}}.__P__-header{display:flex;align-items:center;gap:var(--__P__-space-2);padding:10px 12px;border-bottom:1px solid var(--__P__-border);background:var(--__P__-bg)}.__P__-header h1{font-size:calc(14px * var(--__P__-text-scale));font-weight:600;flex:1;letter-spacing:-.01em}.__P__-header-actions{margin-inline-start:auto;display:flex;align-items:center;gap:var(--__P__-space-1);flex-shrink:0}.__P__-agent{flex:1;display:inline-flex;align-items:center;gap:10px;min-width:0}.__P__-agent-avatar{position:relative;width:32px;height:32px;border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated);color:var(--__P__-fg-muted);display:inline-flex;align-items:center;justify-content:center;font-weight:700;font-size:var(--__P__-text-xs);flex-shrink:0}.__P__-agent-avatar img{width:100%;height:100%;border-radius:inherit;object-fit:cover}.__P__-agent-avatar:after{content:"";position:absolute;right:-1px;bottom:-1px;width:10px;height:10px;border-radius:999px;border:2px solid var(--__P__-bg);background:var(--__P__-neutral)}.__P__-agent-avatar[data-status=online]:after{background:var(--__P__-success)}.__P__-agent-avatar[data-status=away]:after{background:var(--__P__-warning)}.__P__-agent-avatar[data-status=offline]:after{background:var(--__P__-neutral)}.__P__-agent-meta{display:flex;flex-direction:column;line-height:1.15;min-width:0}.__P__-agent-meta strong{font-size:calc(14px * var(--__P__-text-scale));font-weight:600;letter-spacing:-.01em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-agent-meta span{font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-suggestions{display:flex;flex-wrap:nowrap;gap:var(--__P__-space-2);padding:6px 14px 10px;overflow-x:auto;overflow-y:hidden;scroll-behavior:smooth;scroll-snap-type:x proximity;scrollbar-width:none;-ms-overflow-style:none;min-width:0}.__P__-suggestions::-webkit-scrollbar{display:none}.__P__-suggestions:before,.__P__-suggestions:after{content:"";flex:1 1 0;min-width:0}.__P__-suggestion{flex:0 0 auto;scroll-snap-align:center;padding:7px 14px;border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);color:var(--__P__-fg);font-size:var(--__P__-text-sm);font-weight:500;white-space:nowrap;transition:background var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease)}.__P__-suggestion:hover{border-color:var(--__P__-accent);color:var(--__P__-accent-fg);transform:translateY(-1px)}.__P__-suggestion:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px;border-color:var(--__P__-accent)}.__P__-suggestion:active{transform:translateY(0)}.__P__-icon-btn{width:32px;height:32px;border-radius:999px;position:relative;display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted);transition:background var(--__P__-dur-quick) var(--__P__-ease),color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-icon-btn:hover{background:var(--__P__-bg-elevated);color:var(--__P__-fg)}.__P__-icon-btn:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-icon-btn:active{background:var(--__P__-border)}.__P__-icon-btn:disabled{opacity:.45;cursor:not-allowed}.__P__-icon-btn:before{content:"";position:absolute;inset:-6px}.__P__-icon-btn svg{width:18px;height:18px}.__P__-icon-btn[data-recording=true]{color:var(--__P__-accent-fg);background:color-mix(in srgb,var(--__P__-accent) 12%,transparent);animation:__P__-pulse 1.2s var(--__P__-ease) infinite}@keyframes __P__-pulse{0%,to{box-shadow:0 0 color-mix(in srgb,var(--__P__-accent) 40%,transparent)}50%{box-shadow:0 0 0 6px color-mix(in srgb,var(--__P__-accent) 0%,transparent)}}.__P__-list,.__P__-history,.__P__-module-scroll,.__P__-home-scroll,.__P__-help-list,.__P__-toolui-code,.__P__-sidebar-conversations{scrollbar-width:thin;scrollbar-color:var(--__P__-border-strong) transparent;overscroll-behavior:contain;scrollbar-gutter:stable}.__P__-list::-webkit-scrollbar,.__P__-history::-webkit-scrollbar,.__P__-module-scroll::-webkit-scrollbar,.__P__-home-scroll::-webkit-scrollbar,.__P__-help-list::-webkit-scrollbar,.__P__-toolui-code::-webkit-scrollbar,.__P__-sidebar-conversations::-webkit-scrollbar{width:8px}.__P__-list::-webkit-scrollbar-thumb,.__P__-history::-webkit-scrollbar-thumb,.__P__-module-scroll::-webkit-scrollbar-thumb,.__P__-home-scroll::-webkit-scrollbar-thumb,.__P__-help-list::-webkit-scrollbar-thumb,.__P__-toolui-code::-webkit-scrollbar-thumb,.__P__-sidebar-conversations::-webkit-scrollbar-thumb{background:var(--__P__-border-strong);border-radius:8px}.__P__-list-wrap{position:relative;flex:1;min-height:0;display:flex;flex-direction:column}.__P__-jump{position:absolute;inset-inline-end:14px;bottom:14px;z-index:2;display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:999px;border:1px solid var(--__P__-border);background:var(--__P__-bg-elevated);color:var(--__P__-fg);box-shadow:var(--__P__-shadow-panel);cursor:pointer;opacity:.85;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease);animation:__P__-bubble-in var(--__P__-dur-base) var(--__P__-ease)}.__P__-jump:hover{opacity:1}.__P__-jump:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;opacity:1}.__P__-jump:active{transform:translateY(1px)}.__P__-jump svg{width:18px;height:18px}.__P__-list{flex:1;min-height:0;overflow-y:auto;padding:var(--__P__-space-4);padding-bottom:var(--__P__-space-8);display:flex;flex-direction:column;gap:14px}.__P__-list--fade{--__P__-fade-size: 20px;--__P__-fade-top: 0px;--__P__-fade-bottom: 0px;-webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 var(--__P__-fade-top),#000 calc(100% - var(--__P__-fade-bottom)),transparent 100%);mask-image:linear-gradient(to bottom,transparent 0,#000 var(--__P__-fade-top),#000 calc(100% - var(--__P__-fade-bottom)),transparent 100%)}.__P__-list--fade[data-fade-top=true]{--__P__-fade-top: var(--__P__-fade-size)}.__P__-list--fade[data-fade-bottom=true]{--__P__-fade-bottom: var(--__P__-fade-size)}.__P__-list>*{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-load-previous,.__P__-history-more{display:flex;justify-content:center}.__P__-load-previous button,.__P__-history-more button{border:0;padding:4px 8px;background:transparent;color:var(--__P__-accent);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;cursor:pointer}.__P__-load-previous button:hover,.__P__-history-more button:hover{text-decoration:underline}.__P__-load-previous button:focus-visible,.__P__-history-more button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-load-previous button:disabled,.__P__-history-more button:disabled{cursor:wait;opacity:.6}.__P__-date-divider{display:flex;justify-content:center;margin-block:var(--__P__-space-3)}.__P__-date-pill{padding:3px 10px;border-radius:999px;font-size:calc(11px * var(--__P__-text-scale));font-weight:600;color:var(--__P__-fg-muted);background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);box-shadow:var(--__P__-shadow-card)}.__P__-bubble-row{display:flex}.__P__-bubble-row[data-role=user]{justify-content:flex-end}.__P__-bubble-row[data-role=assistant]{justify-content:flex-start}.__P__-bubble{max-width:100%;min-width:0;padding:var(--__P__-space-3) var(--__P__-space-4);border-radius:var(--__P__-radius);line-height:1.6;font-size:calc(14px * var(--__P__-text-scale));word-wrap:break-word;overflow-wrap:break-word;box-shadow:0 1px 2px #0000000a,0 1px 8px -4px #0000000f;animation:__P__-bubble-in var(--__P__-dur-base) var(--__P__-ease)}.__P__-bubble ::selection{background:color-mix(in srgb,var(--__P__-accent) 30%,transparent)}.__P__-bubble-row[data-role=user] .__P__-bubble ::selection{background:#fff6;color:var(--__P__-bubble-user-text)}@keyframes __P__-bubble-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}.__P__-bubble-row[data-role=user] .__P__-bubble{background:var(--__P__-bubble-user);color:var(--__P__-bubble-user-text);border-end-end-radius:5px}.__P__-bubble-row[data-role=assistant] .__P__-bubble{background:var(--__P__-bubble-assistant);color:var(--__P__-bubble-assistant-text);border:1px solid var(--__P__-border);border-end-start-radius:5px}.__P__-bubble-row[data-role=operator] .__P__-bubble{display:flex;align-items:stretch;padding:0;overflow:hidden;background:var(--__P__-bubble-assistant);color:var(--__P__-bubble-assistant-text);border-end-start-radius:5px}.__P__-bubble-row[data-role=operator] .__P__-bubble-col{align-items:flex-start}.__P__-bubble-author{display:flex;flex:0 0 auto;align-items:center;padding:0 .875rem;border-inline-end:1px solid color-mix(in oklab,var(--__P__-accent),transparent 60%);color:var(--__P__-accent);font-size:calc(13px * var(--__P__-text-scale));font-weight:600;letter-spacing:.025em;user-select:none}.__P__-bubble-row[data-role=operator] .__P__-bubble-body{flex:1 1 auto;min-width:0;padding:var(--__P__-space-3) var(--__P__-space-4)}.__P__-bubble-col{display:flex;flex-direction:column;max-width:85%;min-width:0}.__P__-bubble-row[data-role=user] .__P__-bubble-col{align-items:flex-end}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col{align-items:flex-start}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui){width:100%}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui) .__P__-bubble{width:100%}@media(max-width:640px){.__P__-bubble-col{max-width:92%}.__P__-toolui:not(.__P__-toolui-collapsible){padding:var(--__P__-space-3);gap:var(--__P__-space-2)}details.__P__-toolui-collapsible>summary{padding:var(--__P__-space-2) var(--__P__-space-3)}details.__P__-toolui-collapsible>.__P__-toolui-section{margin:var(--__P__-space-3)}.__P__-toolui-section,.__P__-toolui-desc{padding:var(--__P__-space-2) var(--__P__-space-3)}}.__P__-bubble-meta{display:flex;align-items:center;gap:8px;margin-top:2px;padding:0 2px;min-height:24px}.__P__-bubble-actions{display:flex;align-items:center;gap:2px}.__P__-bubble-time{font-size:calc(11px * var(--__P__-text-scale));line-height:1;color:var(--__P__-fg-muted);user-select:none}.__P__-feedback{display:flex;align-items:center;gap:2px}.__P__-msg-action{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border:0;border-radius:var(--__P__-radius-sm);background:transparent;color:var(--__P__-fg-muted);cursor:pointer;opacity:.65;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),background var(--__P__-dur-quick) var(--__P__-ease),color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-msg-action:hover{opacity:1;background:var(--__P__-bg-elevated);color:var(--__P__-fg)}.__P__-msg-action:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;opacity:1}.__P__-msg-action[data-active=true]{opacity:1;color:var(--__P__-accent-fg)}.__P__-msg-action svg{width:15px;height:15px}.__P__-md>*:first-child{margin-top:0}.__P__-md>*:last-child{margin-bottom:0}.__P__-md p{margin:10px 0}.__P__-md h1,.__P__-md h2,.__P__-md h3,.__P__-md h4,.__P__-md h5,.__P__-md h6{margin:18px 0 8px;line-height:1.3;letter-spacing:-.01em;font-weight:700}.__P__-md h1{font-size:1.4em}.__P__-md h2{font-size:1.22em}.__P__-md h3{font-size:1.08em}.__P__-md h4,.__P__-md h5,.__P__-md h6{font-size:1em}.__P__-md>h1:first-child,.__P__-md>h2:first-child,.__P__-md>h3:first-child,.__P__-md>h4:first-child,.__P__-md>h5:first-child,.__P__-md>h6:first-child{margin-top:0}.__P__-md ul,.__P__-md ol{padding-inline-start:1.5em;margin:10px 0}.__P__-md ul{list-style:disc}.__P__-md ol{list-style:decimal}.__P__-md li{margin:6px 0;padding-inline-start:2px}.__P__-md li::marker{color:var(--__P__-fg-muted)}.__P__-md li>p{margin:6px 0}.__P__-md li>ul,.__P__-md li>ol{margin:6px 0}.__P__-md strong,.__P__-md b{font-weight:650;letter-spacing:-.005em}.__P__-md em,.__P__-md i{font-style:italic}.__P__-md code{font-family:var(--__P__-font-mono);font-size:.86em;padding:1px 6px;border-radius:5px;background:color-mix(in srgb,var(--__P__-accent) 10%,transparent);color:var(--__P__-fg);border:1px solid color-mix(in srgb,var(--__P__-accent) 16%,transparent)}.__P__-md pre{font-family:var(--__P__-font-mono);font-size:calc(12.5px * var(--__P__-text-scale));padding:12px 14px;border-radius:var(--__P__-radius-sm);background:#7f7f7f1f;overflow-x:auto;margin:var(--__P__-space-3) 0;line-height:1.5}.__P__-md pre code{padding:0;background:none}.__P__-md a{color:inherit;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px}.__P__-md a:hover{text-decoration-thickness:2px}.__P__-md blockquote{margin:14px 0;padding:6px 14px;border-inline-start:3px solid color-mix(in srgb,var(--__P__-accent) 50%,transparent);background:color-mix(in srgb,var(--__P__-accent) 5%,transparent);border-start-end-radius:var(--__P__-radius-sm);border-end-end-radius:var(--__P__-radius-sm);color:var(--__P__-fg-muted)}.__P__-md blockquote>:first-child{margin-top:0}.__P__-md blockquote>:last-child{margin-bottom:0}.__P__-md hr{border:0;height:1px;background:color-mix(in srgb,currentColor 18%,transparent);margin:var(--__P__-space-4) 0}.__P__-md table{border-collapse:collapse;margin:var(--__P__-space-3) 0;font-size:.95em;display:block;overflow-x:auto;max-width:100%;font-variant-numeric:tabular-nums}.__P__-md th,.__P__-md td{padding:6px 10px;border-bottom:1px solid color-mix(in srgb,currentColor 12%,transparent);text-align:start}.__P__-md th{font-weight:700;background:color-mix(in srgb,currentColor 6%,transparent)}.__P__-md h1+ul,.__P__-md h1+ol,.__P__-md h2+ul,.__P__-md h2+ol,.__P__-md h3+ul,.__P__-md h3+ol,.__P__-md h4+ul,.__P__-md h4+ol{margin-top:var(--__P__-space-1)}.__P__-loading{display:inline-flex;align-items:center;gap:var(--__P__-space-2);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-loading-spinner{width:14px;height:14px;border-radius:999px;border:2px solid currentColor;border-top-color:transparent;animation:__P__-spin .8s linear infinite}@keyframes __P__-spin{to{transform:rotate(1turn)}}.__P__-typing{display:inline-flex;gap:var(--__P__-space-1);padding:var(--__P__-space-1) 0}.__P__-typing span{width:5px;height:5px;border-radius:999px;background:currentColor;opacity:.4;animation:__P__-blink 1.2s var(--__P__-ease) infinite}.__P__-typing span:nth-child(2){animation-delay:.2s}.__P__-typing span:nth-child(3){animation-delay:.4s}@keyframes __P__-blink{0%,80%,to{opacity:.3;transform:translateY(0)}40%{opacity:1;transform:translateY(-2px)}}.__P__-reasoning{margin:var(--__P__-space-1) 0 var(--__P__-space-2);padding-inline-start:var(--__P__-space-3);border-inline-start:2px solid var(--__P__-border-strong)}.__P__-reasoning-summary{display:inline-flex;align-items:center;gap:var(--__P__-space-1);cursor:pointer;list-style:none;user-select:none;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-reasoning-summary:hover{color:var(--__P__-fg)}.__P__-reasoning-summary:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-reasoning-summary::-webkit-details-marker{display:none}.__P__-reasoning-summary:before{content:"";width:5px;height:5px;border-inline-end:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(-45deg);opacity:.7;transition:transform var(--__P__-dur-quick) var(--__P__-ease)}.__P__-reasoning[open] .__P__-reasoning-summary:before{transform:rotate(45deg)}.__P__-reasoning[data-active=true] .__P__-reasoning-label{animation:__P__-reasoning-pulse 1.4s var(--__P__-ease) infinite}@keyframes __P__-reasoning-pulse{0%,to{opacity:.5}50%{opacity:1}}@media(prefers-reduced-motion:reduce){.__P__-reasoning[data-active=true] .__P__-reasoning-label{animation:none}}.__P__-reasoning-body{margin-top:var(--__P__-space-1);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-reasoning-body>:first-child{margin-top:0}.__P__-reasoning-body>:last-child{margin-bottom:0}.__P__-source{display:inline-flex;align-items:center;gap:6px;max-width:100%;margin-top:6px;margin-inline-end:6px;padding:var(--__P__-space-1) var(--__P__-space-2);border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);text-decoration:none}a.__P__-source:hover{color:var(--__P__-fg);border-color:var(--__P__-accent)}.__P__-source-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-composer{border-top:1px solid var(--__P__-border);padding:10px 12px;background:var(--__P__-bg);display:flex;flex-direction:column;gap:var(--__P__-space-2)}.__P__-composer>*{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-compaction-status{width:100%;padding:10px 14px;justify-content:center;font-size:var(--__P__-text-xs)}.__P__-message-queue{display:flex;max-height:112px;flex-direction:column;gap:var(--__P__-space-1);overflow-y:auto}.__P__-attachment-chip.__P__-queued-message{width:100%;max-width:none}.__P__-queued-text{min-width:0;flex:1}.__P__-composer-row{display:flex;align-items:flex-end;gap:6px}.__P__-textarea{flex:1;--__P__-textarea-base-height: 40px;height:var(--__P__-textarea-base-height);max-height:160px;padding:10px 12px;border-radius:var(--__P__-radius);background:var(--__P__-bg-elevated);border:1px solid transparent;font-size:calc(14px * var(--__P__-text-scale));line-height:1.4;transition:height var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-textarea:focus-visible{outline:none;border-color:var(--__P__-focus)}@media(pointer:coarse){.__P__-textarea{--__P__-textarea-base-height: 44px}}.__P__-send{width:40px;height:40px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease),background var(--__P__-dur-quick) var(--__P__-ease)}.__P__-send[data-shape=circle]{border-radius:999px}.__P__-send[data-shape=square]{border-radius:var(--__P__-radius-sm)}.__P__-send[data-shape=pill]{width:auto;padding:0 18px;border-radius:999px}.__P__-send[data-variant=filled]{background:var(--__P__-accent);color:var(--__P__-accent-text)}.__P__-send[data-variant=outline]{background:transparent;color:var(--__P__-accent-fg);border-color:var(--__P__-accent)}.__P__-send[data-variant=outline]:not(:disabled):hover{background:color-mix(in srgb,var(--__P__-accent) 10%,transparent)}.__P__-send[data-variant=ghost]{background:transparent;color:var(--__P__-accent-fg)}.__P__-send[data-variant=ghost]:not(:disabled):hover{background:color-mix(in srgb,var(--__P__-accent) 8%,transparent)}.__P__-send:disabled{opacity:.4;cursor:not-allowed}.__P__-send:not(:disabled):hover{transform:translateY(-1px)}.__P__-send:not(:disabled):active{transform:translateY(0)}.__P__-send:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-send svg{width:18px;height:18px}.__P__-composer-actions{display:flex;gap:var(--__P__-space-1);flex-wrap:wrap}.__P__-attachments{display:flex;flex-wrap:wrap;gap:6px}.__P__-attachment-chip{display:inline-flex;align-items:center;gap:6px;padding:var(--__P__-space-1) var(--__P__-space-2) var(--__P__-space-1) var(--__P__-space-1);border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);font-size:var(--__P__-text-xs);max-width:200px}.__P__-attachment-thumb{width:24px;height:24px;border-radius:999px;object-fit:cover;background:var(--__P__-border)}.__P__-attachment-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-attachment-remove{width:18px;height:18px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted)}.__P__-attachment-remove:hover{background:var(--__P__-border);color:var(--__P__-fg)}.__P__-dropzone{position:absolute;inset:8px;border:2px dashed var(--__P__-accent);border-radius:var(--__P__-radius);background:color-mix(in srgb,var(--__P__-accent) 8%,transparent);display:flex;align-items:center;justify-content:center;font-weight:600;color:var(--__P__-accent-fg);pointer-events:none;z-index:10;animation:__P__-fade-in var(--__P__-dur-quick) var(--__P__-ease)}@keyframes __P__-fade-in{0%{opacity:0}to{opacity:1}}.__P__-error{margin-top:var(--__P__-space-1);padding:8px 12px;border-radius:var(--__P__-radius-sm);background:color-mix(in oklab,var(--__P__-danger) 8%,var(--__P__-bg-elevated));border:1px solid color-mix(in oklab,var(--__P__-danger) 20%,transparent);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);display:flex;align-items:center;gap:var(--__P__-space-2)}.__P__-error span{min-width:0}.__P__-error button{margin-inline-start:auto;flex-shrink:0;border:0;background:none;padding:0;color:var(--__P__-accent-fg);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;text-decoration:underline;white-space:nowrap;cursor:pointer}.__P__-history{flex:1;overflow-y:auto;padding:var(--__P__-space-2) var(--__P__-space-1) var(--__P__-space-3)}.__P__-history-footer{flex:none;padding:var(--__P__-space-2) var(--__P__-space-3) var(--__P__-space-3);border-top:1px solid var(--__P__-border);background:var(--__P__-surface)}.__P__-history-new{width:100%;display:flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);padding:var(--__P__-space-2) var(--__P__-space-3);border:none;border-radius:var(--__P__-radius-md);background:var(--__P__-accent);color:var(--__P__-on-accent);cursor:pointer;font-size:var(--__P__-text-sm);font-weight:600;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-history-new svg{width:16px;height:16px}.__P__-history-new:hover{filter:brightness(1.08)}.__P__-history-new:active{transform:translateY(1px)}.__P__-history-new:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-history-empty{flex:1;display:flex;align-items:center;justify-content:center;padding:40px 16px;color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale));text-align:center}.__P__-history-group{display:flex;flex-direction:column;padding:0 var(--__P__-space-3)}.__P__-history-heading{font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);padding:14px 4px 8px;text-transform:uppercase;letter-spacing:.04em}.__P__-history-card{display:flex;flex-direction:column;background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-lg, 14px);overflow:hidden}.__P__-history-card>[role=listitem]{display:flex;flex-direction:column}.__P__-history-item{all:unset;display:flex;align-items:center;gap:var(--__P__-space-3);padding:12px var(--__P__-space-3);cursor:pointer;transition:background var(--__P__-dur-base) var(--__P__-ease)}.__P__-history-card>*+*{border-top:1px solid var(--__P__-border)}.__P__-history-item:hover{background:var(--__P__-bg-elevated)}.__P__-history-item:focus-visible{background:var(--__P__-bg-elevated);outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-history-avatar{flex:none;display:grid;place-items:center;width:36px;height:36px;border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-accent) 12%,transparent);color:var(--__P__-accent-fg)}.__P__-history-avatar svg{width:18px;height:18px}.__P__-history-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.__P__-history-row{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-2)}.__P__-history-title{flex:1;min-width:0;font-size:calc(14px * var(--__P__-text-scale));font-weight:500;color:var(--__P__-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-history-time{flex:none;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-history-preview{flex:1;min-width:0;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-history-dot{flex:none;width:8px;height:8px;border-radius:50%;background:var(--__P__-accent)}.__P__-history-item[data-unread=true] .__P__-history-title{font-weight:600}.__P__-history-item[data-closed=true] .__P__-history-title{color:var(--__P__-fg-muted)}.__P__-history-item-skeleton{cursor:default;pointer-events:none}.__P__-skeleton{display:block;border-radius:4px;background:linear-gradient(90deg,color-mix(in oklab,var(--__P__-fg) 9%,transparent) 30%,color-mix(in oklab,var(--__P__-fg) 17%,transparent),color-mix(in oklab,var(--__P__-fg) 9%,transparent) 70%);background-size:200% 100%;animation:__P__-skeleton-shimmer 1.8s ease-in-out infinite}.__P__-history-avatar.__P__-skeleton{border-radius:var(--__P__-radius-md)}.__P__-skeleton-heading{width:52px;height:8px}.__P__-skeleton-title{width:55%;height:12px}.__P__-skeleton-time{width:34px;height:10px}.__P__-skeleton-preview{width:80%;height:10px}@keyframes __P__-skeleton-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){.__P__-skeleton{animation:none}}.__P__-list-loading{margin:auto;padding:var(--__P__-space-6) var(--__P__-space-4);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);text-align:center}.__P__-readonly-banner{display:flex;flex-direction:column;align-items:center;gap:10px;padding:14px 12px;margin:0 var(--__P__-space-3) var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated);color:var(--__P__-fg-muted);text-align:center;font-size:var(--__P__-text-sm)}.__P__-readonly-label{line-height:1.4}.__P__-readonly-cta{appearance:none;border:0;cursor:pointer;padding:var(--__P__-space-2) var(--__P__-space-4);border-radius:999px;background:var(--__P__-accent);color:var(--__P__-accent-text, #fff);font:inherit;font-weight:600;font-size:var(--__P__-text-sm);transition:filter var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-readonly-cta:hover,.__P__-readonly-cta:focus-visible{filter:brightness(1.1)}.__P__-operator-banner{display:flex;align-items:center;justify-content:center;gap:8px;margin:0 var(--__P__-space-3) var(--__P__-space-1);padding:8px 12px;border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-bg-elevated),var(--__P__-accent) 6%);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);line-height:1.3;text-align:center}.__P__-operator-pulse{flex:0 0 auto;width:8px;height:8px;border-radius:50%;background:var(--__P__-accent)}.__P__-operator-banner[data-mode=awaiting-operator] .__P__-operator-pulse{animation:__P__-operator-pulse 1.4s var(--__P__-ease-out) infinite}.__P__-cancel-operator-request{flex:0 0 auto;padding:0;border:0;background:none;color:var(--__P__-accent);font:inherit;font-weight:600;text-decoration:underline;text-underline-offset:2px;cursor:pointer}.__P__-cancel-operator-request:hover{opacity:.8}.__P__-cancel-operator-request:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px;border-radius:var(--__P__-radius-sm)}@keyframes __P__-operator-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(.7)}}.__P__-readonly-cta:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px}.__P__-composer-footer{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:10px 16px;margin:0 var(--__P__-space-3);border-top:1px solid var(--__P__-border);text-align:center;font-size:calc(11px * var(--__P__-text-scale));line-height:1.4;color:var(--__P__-fg-muted)}.__P__-disclaimer{max-width:320px;margin:0 auto;opacity:.9;letter-spacing:.01em}.__P__-poweredby{display:inline-flex;align-items:center;justify-content:center;gap:6px;color:inherit;text-decoration:none;opacity:.7;transition:opacity var(--__P__-dur-base) var(--__P__-ease);font-size:calc(11px * var(--__P__-text-scale));letter-spacing:.02em}.__P__-poweredby:hover{opacity:1}.__P__-poweredby-logo{height:12px;width:auto;display:inline-block;vertical-align:middle}.__P__-poweredby-bar{flex:none;display:flex;align-items:center;justify-content:center;padding:6px 16px;border-top:1px solid var(--__P__-border);background:var(--__P__-bg-elevated)}.__P__-menu-wrap{position:relative;display:inline-flex}.__P__-menu{position:absolute;top:100%;inset-inline-end:0;margin-top:6px;min-width:200px;padding:6px;background:var(--__P__-bg);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);box-shadow:var(--__P__-shadow-panel);z-index:10;display:flex;flex-direction:column;gap:2px;animation:__P__-menu-in var(--__P__-dur-base) var(--__P__-ease)}@media(prefers-reduced-motion:reduce){.__P__-menu{animation:none}}@keyframes __P__-menu-in{0%{opacity:0;transform:translateY(-4px) scale(.98);transform-origin:top right}to{opacity:1;transform:none}}.__P__-menu-item{all:unset;display:flex;align-items:center;gap:10px;padding:8px 10px;font-size:var(--__P__-text-sm);color:var(--__P__-fg);border-radius:var(--__P__-radius-sm);cursor:pointer;user-select:none}.__P__-menu-item:hover{background:var(--__P__-bg-elevated)}.__P__-menu-item:focus-visible{background:var(--__P__-bg-elevated);outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-menu-item[disabled]{opacity:.45;cursor:not-allowed}.__P__-menu-icon{display:inline-flex;width:16px;height:16px;color:var(--__P__-fg-muted)}.__P__-menu-icon svg{width:16px;height:16px}.__P__-menu-label{flex:1}.__P__-menu-check{display:inline-flex;color:var(--__P__-accent-fg)}.__P__-menu-check svg{width:14px;height:14px}.__P__-menu-item-segmented{cursor:default}.__P__-menu-item-segmented:hover{background:transparent}.__P__-segmented{display:inline-flex;gap:2px;padding:2px;background:var(--__P__-bg-elevated);border-radius:var(--__P__-radius-sm)}.__P__-segment{all:unset;min-width:26px;padding:3px 8px;font-size:var(--__P__-text-xs);font-weight:600;letter-spacing:.02em;text-align:center;color:var(--__P__-fg-muted);border-radius:calc(var(--__P__-radius-sm) - 2px);cursor:pointer;transition:color .12s ease,background .12s ease}.__P__-segment:hover{color:var(--__P__-fg)}.__P__-segment[data-on=true]{background:var(--__P__-bg);color:var(--__P__-accent-fg);box-shadow:var(--__P__-shadow-card)}.__P__-segment:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-resize-grip{position:absolute;width:18px;height:18px;display:flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted);opacity:.45;transition:opacity var(--__P__-dur-base) var(--__P__-ease);z-index:2;touch-action:none;user-select:none}.__P__-resize-grip:hover,.__P__-resize-grip:focus-visible{opacity:1}.__P__-resize-grip svg{width:10px;height:10px}.__P__-resize-grip--bottom-left{bottom:2px;left:2px;cursor:nesw-resize;transform:scaleX(-1)}.__P__-resize-grip--bottom-right{bottom:2px;right:2px;cursor:nwse-resize}.__P__-resize-grip--top-left{top:2px;left:2px;cursor:nwse-resize;transform:rotate(180deg)}.__P__-resize-grip--top-right{top:2px;right:2px;cursor:nesw-resize;transform:scaleY(-1)}:host(:not([data-mode="open"])) .__P__-resize-grip{display:none}.__P__-messenger{display:flex;flex-direction:column;overflow:hidden}.__P__-messenger-body,.__P__-messenger-pane{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.__P__-messenger-pane[hidden]{display:none}@keyframes __P__-view-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}.__P__-module{display:flex;flex-direction:column;height:100%;min-height:0}@media(prefers-reduced-motion:no-preference){.__P__-module,.__P__-history{animation:__P__-view-in .18s var(--__P__-ease-out)}}.__P__-module-scroll{flex:1;min-height:0;overflow-y:auto;padding:var(--__P__-space-3);display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-home{container-type:inline-size;background:radial-gradient(125% 65% at 88% 0%,color-mix(in srgb,#fff 16%,transparent),transparent 55%),linear-gradient(180deg,var(--__P__-accent) 0%,var(--__P__-accent) 22%,color-mix(in srgb,var(--__P__-accent) 28%,var(--__P__-surface)) 44%,var(--__P__-surface) 70%);border-radius:var(--__P__-radius-lg) var(--__P__-radius-lg) 0 0}.__P__-home-scroll{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;background:transparent}.__P__-home-cards{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:4px 14px 16px}.__P__-module-pad{padding:var(--__P__-space-3) var(--__P__-space-3) 0}.__P__-module-empty{display:flex;flex-direction:column;align-items:center;gap:var(--__P__-space-3);padding:var(--__P__-space-8) var(--__P__-space-4);text-align:center;color:var(--__P__-fg-muted);font-size:var(--__P__-text-base)}.__P__-module-retry{padding:var(--__P__-space-2) var(--__P__-space-4);border:1px solid var(--__P__-border-strong);border-radius:var(--__P__-radius-sm);color:var(--__P__-fg);font-weight:600;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out),border-color var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-module-retry:hover{background:var(--__P__-hover);border-color:var(--__P__-accent)}.__P__-module-retry:active{background:var(--__P__-border)}.__P__-module-retry:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-help-list{flex:1;min-height:0;overflow-y:auto;padding-bottom:var(--__P__-space-3)}.__P__-help-group{display:flex;flex-direction:column}.__P__-help-section-title{position:sticky;top:0;z-index:1;margin:0;padding:var(--__P__-space-3) var(--__P__-space-5) var(--__P__-space-2);font-size:var(--__P__-text-xs);font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--__P__-fg-muted);background:var(--__P__-bg)}.__P__-help-card{margin:0 var(--__P__-space-3) var(--__P__-space-3);background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden}.__P__-help-card .__P__-list-row{border-bottom:0;border-radius:0}.__P__-help-card .__P__-list-row+.__P__-list-row{border-top:1px solid var(--__P__-border)}.__P__-help-more{justify-content:center;color:var(--__P__-accent-fg);font-weight:600}.__P__-tabbar{display:flex;border-top:1px solid var(--__P__-border);background:var(--__P__-bg-elevated);flex-shrink:0}.__P__-tab{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--__P__-space-1);min-height:48px;padding:var(--__P__-space-2) var(--__P__-space-1);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600;transition:color var(--__P__-dur-quick) var(--__P__-ease-out)}@media(hover:hover){.__P__-tab:hover{background:var(--__P__-hover)}}.__P__-tab[aria-selected=true]{color:var(--__P__-accent-fg)}.__P__-tab:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-tab:active{background:var(--__P__-hover)}.__P__-tab-icon{position:relative;display:inline-flex}.__P__-tab-icon svg{width:22px;height:22px}.__P__-tab-badge{position:absolute;top:-2px;left:calc(50% + 6px);width:8px;height:8px;border-radius:50%;background:var(--__P__-accent);box-shadow:0 0 0 2px var(--__P__-bg-elevated)}.__P__-home-hero{flex-shrink:0;padding:var(--__P__-space-5) var(--__P__-space-5) var(--__P__-space-3);color:var(--__P__-on-accent);--__P__-focus: var(--__P__-on-accent)}.__P__-home-hero-top{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);min-height:32px}.__P__-home-brand{font-size:clamp(calc(12px * var(--__P__-text-scale)),calc(3.2cqi * var(--__P__-text-scale)),calc(14px * var(--__P__-text-scale)));font-weight:600;letter-spacing:.01em;color:color-mix(in srgb,#fff 82%,transparent);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.__P__-home-brand-spacer{flex:1}.__P__-home-hero-actions{display:flex;align-items:center;gap:var(--__P__-space-2);flex-shrink:0}.__P__-home-hero-actions .__P__-icon-btn{color:#fff}.__P__-home-hero-actions .__P__-icon-btn:hover{background:color-mix(in srgb,#fff 18%,transparent);color:#fff}.__P__-home-hero-actions .__P__-icon-btn:active{background:color-mix(in srgb,#fff 26%,transparent)}.__P__-home-greeting{margin:28px 0 0;font-family:var(--__P__-font-display);font-size:clamp(calc(19px * var(--__P__-text-scale)),calc(5.5cqi * var(--__P__-text-scale)),var(--__P__-text-2xl));font-weight:800;line-height:1.18;letter-spacing:-.01em;overflow-wrap:anywhere}.__P__-home-lead{margin:10px 0 0;font-family:var(--__P__-font-display);font-size:clamp(calc(15px * var(--__P__-text-scale)),calc(4.2cqi * var(--__P__-text-scale)),var(--__P__-text-xl));font-weight:600;line-height:1.25;letter-spacing:-.005em;color:color-mix(in srgb,var(--__P__-on-accent) 78%,transparent);overflow-wrap:anywhere}.__P__-home-avatars{display:flex}.__P__-home-avatar{width:30px;height:30px;border-radius:var(--__P__-radius-md);overflow:hidden;margin-inline-start:-10px;border:2px solid color-mix(in srgb,#fff 92%,transparent);box-shadow:0 1px 3px #0000002e;background:var(--__P__-surface);display:inline-flex;align-items:center;justify-content:center;font-size:var(--__P__-text-xs);font-weight:700;color:var(--__P__-fg)}.__P__-home-avatar:first-child{margin-inline-start:0}.__P__-home-avatar img{width:100%;height:100%;object-fit:cover}.__P__-home-content{background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);box-shadow:var(--__P__-shadow-card);overflow:hidden}.__P__-home-content-title{padding:var(--__P__-space-4) var(--__P__-space-4) var(--__P__-space-3);font-size:var(--__P__-text-sm);font-weight:700}.__P__-home-content-list{display:flex;flex-direction:column;padding:0 var(--__P__-space-2) var(--__P__-space-2)}.__P__-home-content-list .__P__-list-row+.__P__-list-row{border-top:1px solid var(--__P__-border)}.__P__-home-card{display:block;width:100%;text-align:start;background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);padding:var(--__P__-space-4);box-shadow:var(--__P__-shadow-card)}.__P__-home-card[data-interactive=true]{cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-home-card[data-interactive=true]:hover{background:var(--__P__-bg-elevated)}.__P__-home-card[data-interactive=true]:active{transform:translateY(1px)}.__P__-home-card[data-interactive=true]:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-recent-row{display:flex;align-items:center;gap:var(--__P__-space-3)}.__P__-home-recent-avatar{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;flex-shrink:0;border-radius:var(--__P__-radius-md);background:color-mix(in oklch,var(--__P__-accent) 14%,transparent);color:var(--__P__-accent-fg)}.__P__-home-recent-avatar svg{width:20px;height:20px}.__P__-home-recent-body{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1;line-height:1.45}.__P__-home-recent-title{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-recent-preview{color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-home-recent-dot{width:8px;height:8px;border-radius:999px;background:var(--__P__-accent);flex-shrink:0}.__P__-home-recent-row[data-unread=true] .__P__-home-recent-title{font-weight:700}.__P__-home-status{display:flex;align-items:center;gap:var(--__P__-space-3)}.__P__-home-status-icon svg{width:22px;height:22px;color:var(--__P__-success)}.__P__-home-status[data-level=degraded] .__P__-home-status-icon svg{color:var(--__P__-warning)}.__P__-home-status[data-level=down] .__P__-home-status-icon svg{color:var(--__P__-danger)}.__P__-home-status-text{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-search{display:flex;align-items:center;gap:var(--__P__-space-2);width:100%;padding:var(--__P__-space-3) var(--__P__-space-4);border-radius:var(--__P__-radius);border:1px solid var(--__P__-border);background:var(--__P__-surface);text-align:start}.__P__-home-search[data-input=true]{background:var(--__P__-bg-elevated)}.__P__-home-search:hover{border-color:var(--__P__-border-strong)}.__P__-home-search:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-search[data-input=true]:focus-within{outline:none;border-color:var(--__P__-focus)}.__P__-home-search-text{flex:1;color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-search-input{flex:1;border:0;background:transparent;font-size:calc(14px * var(--__P__-text-scale));color:var(--__P__-fg);outline:none}.__P__-home-search-input:focus-visible{outline:none}.__P__-home-search-icon svg{width:18px;height:18px;color:var(--__P__-accent-fg)}.__P__-home-ask{padding-block:6px;padding-inline-end:6px}.__P__-home-ask .__P__-send{width:32px;height:32px;flex-shrink:0}.__P__-home-ask .__P__-send[data-shape=pill]{width:auto;padding:0 14px}.__P__-home-ask .__P__-send svg{width:16px;height:16px}.__P__-list-row{display:flex;align-items:center;gap:var(--__P__-space-3);width:100%;min-height:44px;text-align:start;padding:var(--__P__-space-3) var(--__P__-space-2);border-radius:var(--__P__-radius-sm)}.__P__-list-row:hover{background:var(--__P__-hover)}.__P__-list-row:active{background:var(--__P__-border)}.__P__-list-row:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-list-row-body{display:flex;flex-direction:column;min-width:0;flex:1}.__P__-list-row-title{font-weight:600;font-size:var(--__P__-text-md);line-height:1.35}.__P__-list-row-sub{color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);margin-top:var(--__P__-space-1);line-height:1.45;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.__P__-list-row-chevron svg{width:18px;height:18px;color:var(--__P__-accent-fg);flex-shrink:0}.__P__-back-header{display:flex;align-items:center;gap:var(--__P__-space-2);padding:10px 12px;border-bottom:1px solid var(--__P__-border);flex-shrink:0}.__P__-back-title{flex:1;text-align:center;font-size:var(--__P__-text-md);font-weight:700;margin:0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-back-spacer{width:32px;height:1px}.__P__-history>*,.__P__-home-scroll>*,.__P__-module-scroll>*,.__P__-help-list>*,.__P__-history-footer>*,.__P__-module-pad{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-header,.__P__-back-header{padding-inline:max(12px,calc((100% - var(--__P__-conversation-max, 768px)) / 2))}.__P__-tabbar{padding-inline:max(0px,calc((100% - var(--__P__-conversation-max, 768px)) / 2))}.__P__-content{display:flex;flex-direction:column;gap:14px;width:100%;max-width:68ch;margin:0 auto}.__P__-content-hero{width:100%;border-radius:var(--__P__-radius)}.__P__-content-subtitle{color:var(--__P__-fg-muted);margin:0}.__P__-content-vote{display:flex;align-items:center;flex-wrap:wrap;gap:var(--__P__-space-2);padding-top:var(--__P__-space-3);border-top:1px solid var(--__P__-border)}.__P__-content-frame{flex:1;min-height:0;width:100%;border:0;background:#fff}.__P__-news-list{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-news-card{display:block;width:100%;text-align:start;line-height:1.45;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden;background:var(--__P__-surface);transition:background var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-news-card:hover{background:var(--__P__-bg-elevated)}.__P__-news-card:active{transform:translateY(1px)}.__P__-news-card:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-news-hero{width:100%;display:block}.__P__-news-body{display:flex;flex-direction:column;gap:6px;padding:14px 16px}.__P__-news-title{font-weight:700;font-size:var(--__P__-text-md)}.__P__-news-meta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-news-tag{padding:1px 8px;border-radius:6px;background:var(--__P__-hover);color:var(--__P__-fg);font-size:calc(12px * var(--__P__-text-scale));white-space:nowrap}.__P__-news-more{display:flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);width:100%;min-height:44px;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);background:var(--__P__-surface);color:var(--__P__-accent-fg);font-weight:600}.__P__-news-more:hover{background:var(--__P__-bg-elevated)}.__P__-news-more:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-news-summary{color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale));display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.__P__-modules-empty{display:flex;align-items:center;justify-content:center;position:relative}.__P__-modules-empty-close{position:absolute;top:12px;inset-inline-end:12px}.__P__-modules-empty-text{color:var(--__P__-fg-muted);font-size:var(--__P__-text-base)}.__P__-form{display:flex;flex-direction:column;gap:var(--__P__-space-4)}.__P__-field{display:flex;flex-direction:column;gap:6px}.__P__-field-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:var(--__P__-space-2)}.__P__-field-label{font-size:var(--__P__-text-sm);font-weight:600;color:var(--__P__-fg)}.__P__-field-req{color:var(--__P__-danger)}.__P__-field-type{flex-shrink:0;align-self:center;margin-inline-start:auto;border:1px solid var(--__P__-border);border-radius:5px;background:color-mix(in oklab,var(--__P__-fg-muted) 9%,transparent);padding:1px 7px;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);white-space:nowrap}.__P__-field-input{width:100%;min-width:0;max-width:100%;box-sizing:border-box;padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);color:var(--__P__-fg);font:inherit;font-size:var(--__P__-text-sm);resize:vertical;transition:border-color var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-field-input:focus-visible{outline:none;border-color:var(--__P__-accent)}.__P__-field[data-invalid=true] .__P__-field-input{border-color:var(--__P__-danger)}.__P__-field-input[type=date],.__P__-field-input[type=time]{appearance:none;-webkit-appearance:none}@media(pointer:coarse){.__P__-textarea,.__P__-home-search-input,.__P__-field-input{font-size:max(16px,calc(16px * var(--__P__-text-scale)))}}.__P__-field-hint{font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-field-error{font-size:var(--__P__-text-xs);color:var(--__P__-danger)}.__P__-field-choices{display:flex;flex-direction:column;gap:10px;padding-top:2px}.__P__-choice{display:flex;align-items:flex-start;gap:10px;font-size:var(--__P__-text-sm);color:var(--__P__-fg);cursor:pointer}.__P__-choice input{margin-top:2px;accent-color:var(--__P__-accent)}.__P__-form-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}.__P__-form-hint{flex:1 1 auto;min-width:6rem;margin-inline-end:auto;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-form-submit{padding:var(--__P__-space-2) var(--__P__-space-4);border:none;border-radius:var(--__P__-radius-md);background:var(--__P__-accent);color:var(--__P__-accent-text, #fff);font:inherit;font-weight:600;font-size:var(--__P__-text-sm);white-space:nowrap;flex-shrink:0;cursor:pointer;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-form-submit:hover:not(:disabled){filter:brightness(1.06)}.__P__-form-submit:disabled{opacity:.6;cursor:default}.__P__-form-skip{padding:var(--__P__-space-2) var(--__P__-space-4);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:transparent;color:var(--__P__-fg-muted);font:inherit;font-size:var(--__P__-text-sm);white-space:nowrap;flex-shrink:0;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-form-skip:hover:not(:disabled){background:var(--__P__-bg-elevated)}@media(max-width:640px){.__P__-form-hint{flex-basis:100%;margin-inline-end:0;font-size:var(--__P__-text-xs)}.__P__-form-submit,.__P__-form-skip{flex:1 1 0;text-align:center}}.__P__-form-gate{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated)}.__P__-form-gate-title{margin:0;font-size:var(--__P__-text-base);font-weight:700;color:var(--__P__-fg)}.__P__-form-gate-desc{margin:0 0 var(--__P__-space-1);font-size:var(--__P__-text-sm);color:var(--__P__-fg-muted)}.__P__-form-done{display:flex;align-items:center;justify-content:center;gap:6px;padding:6px 12px;border:1px dashed var(--__P__-border);border-radius:999px;align-self:center;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted)}.__P__-form-done svg{width:14px;height:14px;color:var(--__P__-success, #22c55e)}.__P__-form-done[data-outcome=skipped] svg{color:var(--__P__-fg-muted)}.__P__-form-done-fill{border:0;background:none;padding:0 2px;cursor:pointer;font:inherit;font-weight:600;color:var(--__P__-accent-fg)}.__P__-form-done-fill:hover{text-decoration:underline}details.__P__-form-done{display:block;padding:0;border-radius:var(--__P__-radius-md)}details[open].__P__-form-done{width:min(100%,420px);background:var(--__P__-surface)}.__P__-form-done-summary{display:flex;align-items:center;justify-content:center;gap:6px;padding:8px 12px;cursor:pointer;list-style:none}.__P__-form-done-summary::-webkit-details-marker{display:none}.__P__-form-done-summary>svg:last-child{color:var(--__P__-fg-muted);transition:transform .15s var(--__P__-ease)}details[open]>.__P__-form-done-summary>svg:last-child{transform:rotate(90deg)}.__P__-form-answers{margin:0;padding:var(--__P__-space-2) var(--__P__-space-3) var(--__P__-space-3);display:grid;gap:var(--__P__-space-3);text-align:start}.__P__-form-answer{display:grid;gap:6px}.__P__-form-answer dt{font-size:var(--__P__-text-sm);font-weight:600;color:var(--__P__-fg)}.__P__-form-answer dd{margin:0;padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);font-size:var(--__P__-text-sm);font-weight:400;color:var(--__P__-fg);overflow-wrap:anywhere}.__P__-toolui{margin-block:var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-lg, 14px);background:var(--__P__-bg-elevated);font-size:var(--__P__-text-sm)}.__P__-toolui:not(.__P__-toolui-collapsible){display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4)}.__P__-toolui-group{display:flex;flex-direction:column;gap:var(--__P__-space-3);margin-block:var(--__P__-space-3)}.__P__-toolui-group>.__P__-toolui{margin-block:0}.__P__-toolui-stale{opacity:.7}details.__P__-toolui-collapsible>summary{display:flex;align-items:center;gap:var(--__P__-space-2);padding:var(--__P__-space-3) var(--__P__-space-4);cursor:pointer;list-style:none;-webkit-tap-highlight-color:transparent;user-select:none}details.__P__-toolui-collapsible>summary::-webkit-details-marker{display:none}details.__P__-toolui-collapsible[open]>summary{border-bottom:1px solid var(--__P__-border)}details.__P__-toolui-collapsible>.__P__-toolui-section{margin:var(--__P__-space-4)}details.__P__-toolui-collapsible>.__P__-toolui-section~.__P__-toolui-section{margin-top:calc(-1 * var(--__P__-space-2))}.__P__-toolui-name-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-toolui-chevron{display:inline-flex;color:var(--__P__-fg-muted);transition:transform var(--__P__-dur-quick) var(--__P__-ease-out)}details.__P__-toolui-collapsible>summary .__P__-toolui-status{margin-inline-start:auto}.__P__-toolui-chevron svg{width:16px;height:16px}details.__P__-toolui-collapsible[open]>summary .__P__-toolui-chevron{transform:rotate(180deg)}.__P__-toolui-badge,.__P__-toolui-name-pill,.__P__-toolui-q-pill{--__P__-pill: var(--__P__-fg-muted);display:inline-flex;min-width:0;align-items:center;gap:5px;padding:3px 7px;border-radius:5px;border:1px solid var(--__P__-border);background:color-mix(in oklab,var(--__P__-fg-muted) 9%,transparent);color:var(--__P__-pill);font-size:var(--__P__-text-xs);font-weight:600;white-space:nowrap}.__P__-toolui-badge svg,.__P__-toolui-name-pill svg,.__P__-toolui-q-pill svg{flex-shrink:0;width:14px;height:14px}.__P__-toolui-status-icon{display:inline-flex}.__P__-toolui-name-pill{--__P__-pill: oklch(.68 .13 233)}.__P__-toolui-q-pill{--__P__-pill: oklch(.66 .12 195)}.__P__-toolui-status[data-status=completed]{--__P__-pill: var(--__P__-success, #16a34a)}.__P__-toolui-status[data-status=responded]{--__P__-pill: oklch(.62 .15 255)}.__P__-toolui-status[data-status=awaiting]{--__P__-pill: var(--__P__-warning, #f59e0b)}.__P__-toolui-status[data-status=denied]{--__P__-pill: oklch(.66 .16 45)}.__P__-toolui-status[data-status=error]{--__P__-pill: var(--__P__-danger, #dc2626)}.__P__-toolui-status[data-status=superseded],.__P__-toolui-status[data-status=incomplete]{--__P__-pill: var(--__P__-fg-muted)}@supports (color: oklch(from red l c h)){.__P__-toolui-badge,.__P__-toolui-name-pill,.__P__-toolui-q-pill{color:oklch(from var(--__P__-pill) clamp(var(--__P__-pill-l-min),l,var(--__P__-pill-l-max)) c h)}}.__P__-toolui-head{display:flex;align-items:center;flex-wrap:wrap;gap:var(--__P__-space-2)}.__P__-toolui-head-end{display:inline-flex;align-items:center;gap:var(--__P__-space-2);margin-inline-start:auto}.__P__-toolui-collapse-body{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4)}.__P__-toolui-summary{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-toolui-collapse-body>.__P__-form{gap:var(--__P__-space-3)}.__P__-toolui-collapse-body>.__P__-form>.__P__-field,.__P__-toolui-summary>.__P__-field{padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-bg) 80%,transparent);line-height:1.5}.__P__-toolui-collapse-body>.__P__-form>.__P__-field{gap:var(--__P__-space-2)}.__P__-toolui-summary>.__P__-field{gap:var(--__P__-space-1)}.__P__-toolui-summary .__P__-field-label{color:var(--__P__-fg-muted)}.__P__-toolui-answer{margin:0;font-size:var(--__P__-text-sm);color:var(--__P__-fg-muted);overflow-wrap:anywhere;white-space:pre-wrap}.__P__-toolui-footer{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);margin-inline:calc(-1 * var(--__P__-space-4));padding:var(--__P__-space-3) var(--__P__-space-4) 0;border-top:1px solid var(--__P__-border)}.__P__-toolui-options-toggle{display:inline-flex;align-items:center;gap:4px;border:0;background:transparent;padding:0;cursor:pointer;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);transition:color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-toolui-options-toggle:hover{color:var(--__P__-fg)}.__P__-toolui-options-chevron{display:inline-flex;transition:transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-toolui-options-chevron svg{width:14px;height:14px}.__P__-toolui-options-chevron.__P__-open{transform:rotate(180deg)}.__P__-toolui-desc{margin:0;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);border:1px solid var(--__P__-border);color:var(--__P__-fg-muted);line-height:1.5}.__P__-toolui-section{display:flex;flex-direction:column;gap:8px;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);border:1px solid var(--__P__-border)}.__P__-toolui:not(.__P__-toolui-collapsible) .__P__-toolui-section,.__P__-toolui:not(.__P__-toolui-collapsible) .__P__-toolui-desc{padding:0;background:none;border:0;border-radius:0}.__P__-toolui-label{font-size:var(--__P__-text-xs);font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--__P__-fg-muted)}.__P__-toolui-code{margin:0;max-height:240px;overflow:auto;color:var(--__P__-fg);font-family:var(--__P__-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);font-size:var(--__P__-text-xs);line-height:1.5;white-space:pre-wrap;word-break:break-word}.__P__-toolui-code[data-error=true]{color:var(--__P__-danger, #dc2626)}.__P__-toolui-body{gap:6px}.__P__-toolui-prompt{margin:0;font-weight:600;color:var(--__P__-fg);overflow-wrap:anywhere}.__P__-toolui-subtle{margin:0;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);line-height:1.5}.__P__-toolui-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}:host([dir="rtl"]) .__P__-icon-dir{transform:scaleX(-1)}:host([dir="rtl"]) .__P__-field-input[type=date],:host([dir="rtl"]) .__P__-field-input[type=time]{position:relative;text-align:right;padding-left:34px}:host([dir="rtl"]) .__P__-field-input[type=date]::-webkit-datetime-edit,:host([dir="rtl"]) .__P__-field-input[type=time]::-webkit-datetime-edit{text-align:right}:host([dir="rtl"]) .__P__-field-input[type=date]::-webkit-calendar-picker-indicator,:host([dir="rtl"]) .__P__-field-input[type=time]::-webkit-calendar-picker-indicator{position:absolute;left:var(--__P__-space-3);margin:0}
6
+ .__P__-anchor{color-scheme:var(--__P__-color-scheme, light);right:16px;bottom:16px}.__P__-surface{display:contents}.__P__-surface[hidden]{display:none}:host([data-position="bottom-left"]) .__P__-anchor,:host([data-position="top-left"]) .__P__-anchor{right:auto;left:16px}:host([data-position="top-right"]) .__P__-anchor,:host([data-position="top-left"]) .__P__-anchor{bottom:auto;top:16px}.__P__-anchor{position:fixed;display:flex;flex-direction:column;align-items:flex-end;gap:var(--__P__-space-3);pointer-events:none}.__P__-anchor{--__P__-fab-size: 56px}.__P__-anchor[data-launcher-size=sm]{--__P__-fab-size: 44px}.__P__-anchor[data-launcher-size=md]{--__P__-fab-size: 56px}.__P__-anchor[data-launcher-size=lg]{--__P__-fab-size: 68px}.__P__-anchor>*{pointer-events:auto}.__P__-fab[data-size=sm]{--__P__-fab-size: 44px;font-size:var(--__P__-text-sm)}.__P__-fab[data-size=md]{--__P__-fab-size: 56px;font-size:calc(14px * var(--__P__-text-scale))}.__P__-fab[data-size=lg]{--__P__-fab-size: 68px;font-size:var(--__P__-text-base)}.__P__-fab{display:inline-flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);color:var(--__P__-accent-text);background:var(--__P__-accent);box-shadow:var(--__P__-shadow-fab);font-weight:600;line-height:1;transform-origin:bottom right;animation:__P__-fab-in var(--__P__-dur-base) var(--__P__-ease) both;transition:transform var(--__P__-dur-base) var(--__P__-ease),opacity var(--__P__-dur-base) var(--__P__-ease),box-shadow var(--__P__-dur-base) var(--__P__-ease)}.__P__-fab:hover{transform:translateY(-2px)}.__P__-fab:active{transform:translateY(0)}.__P__-fab:focus-visible{outline:2px solid var(--__P__-on-accent);outline-offset:3px}.__P__-fab svg{width:24px;height:24px;flex-shrink:0}@keyframes __P__-fab-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:none}}.__P__-fab[data-leaving]{position:absolute;right:0;bottom:0;animation:__P__-fab-out var(--__P__-dur-quick) var(--__P__-ease) forwards;pointer-events:none}:host([data-position^="top-"]) .__P__-fab[data-leaving]{bottom:auto;top:0}:host([data-position$="-left"]) .__P__-fab[data-leaving]{right:auto;left:0}@keyframes __P__-fab-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.85)}}.__P__-fab[data-variant=circle]{width:var(--__P__-fab-size);height:var(--__P__-fab-size);border-radius:999px}.__P__-fab[data-variant=circle] .__P__-fab-label{display:none}.__P__-fab[data-variant=pill]{height:var(--__P__-fab-size);padding:0 18px 0 16px;border-radius:999px}.__P__-fab[data-variant=bar]{height:var(--__P__-fab-size);padding:0 22px;border-radius:var(--__P__-radius)}.__P__-fab[data-variant=minimal]{height:var(--__P__-fab-size);padding:0 var(--__P__-space-4);border-radius:999px;background:transparent;color:var(--__P__-accent-fg);box-shadow:none;border:1px solid currentColor}.__P__-fab[data-variant=minimal]:hover{background:color-mix(in srgb,var(--__P__-accent) 12%,transparent)}.__P__-callout{--__P__-callout-fab-h: var(--__P__-fab-size, 56px);--__P__-callout-gap: clamp(12px, calc(var(--__P__-callout-fab-h) * .25), 22px);--__P__-callout-nudge-direction: -1;position:absolute;display:inline-flex;align-items:center;gap:var(--__P__-space-2);padding:10px 14px;background:var(--__P__-fg);color:var(--__P__-bg);border-radius:999px;font-size:var(--__P__-text-sm);font-weight:600;line-height:1.2;box-shadow:0 10px 30px -8px #00000059;pointer-events:auto;animation:__P__-callout-in var(--__P__-dur-slow) var(--__P__-ease);z-index:1;max-width:240px;white-space:nowrap}.__P__-callout[data-position=left]{right:calc(100% + var(--__P__-callout-gap));bottom:calc(var(--__P__-callout-fab-h) / 2);transform:translateY(50%)}.__P__-callout[data-position=right]{left:calc(100% + var(--__P__-callout-gap));bottom:calc(var(--__P__-callout-fab-h) / 2);transform:translateY(50%);--__P__-callout-nudge-direction: 1}.__P__-callout[data-position=top]{bottom:calc(100% + var(--__P__-callout-gap));right:0;max-width:min(280px,calc(100vw - 32px))}.__P__-callout[data-position=bottom]{top:calc(100% + var(--__P__-callout-gap));right:0;max-width:min(280px,calc(100vw - 32px))}:host([data-position$="-left"]) .__P__-callout[data-position=top],:host([data-position$="-left"]) .__P__-callout[data-position=bottom]{right:auto;left:0}.__P__-callout[data-shape=bubble]{border-radius:var(--__P__-radius-md);white-space:normal;width:max-content;max-width:min(280px,calc(100vw - 32px))}.__P__-callout[data-shape=callout]{padding:12px 18px;font-size:calc(14px * var(--__P__-text-scale));background:var(--__P__-accent);color:var(--__P__-accent-text)}.__P__-callout:after{content:"";position:absolute;width:12px;height:12px;background:inherit;border-radius:2px;transform:rotate(45deg)}.__P__-callout[data-position=left]:after{right:-5px;top:50%;margin-top:-6px}.__P__-callout[data-position=right]:after{left:-5px;top:50%;margin-top:-6px}.__P__-callout[data-position=top]:after{bottom:-5px;right:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}.__P__-callout[data-position=bottom]:after{top:-5px;right:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}:host([data-position$="-left"]) .__P__-callout[data-position=top]:after,:host([data-position$="-left"]) .__P__-callout[data-position=bottom]:after{right:auto;left:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}.__P__-callout[data-animated]{animation:__P__-callout-in var(--__P__-dur-slow) var(--__P__-ease),__P__-callout-nudge 1.6s var(--__P__-ease-in-out) var(--__P__-dur-slow) infinite}@keyframes __P__-callout-in{0%{opacity:0}to{opacity:1}}@keyframes __P__-callout-nudge{0%,to{margin-left:0;margin-right:0}50%{margin-left:calc(6px * var(--__P__-callout-nudge-direction));margin-right:calc(-6px * var(--__P__-callout-nudge-direction))}}@media(prefers-reduced-motion:reduce){.__P__-callout[data-animated]{animation:__P__-callout-in 1ms var(--__P__-ease)}.__P__-icon-btn[data-recording=true],.__P__-typing span{animation:none}}.__P__-callout-close{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:999px;color:inherit;opacity:.7;cursor:pointer}.__P__-callout-close:hover{opacity:1;background:color-mix(in srgb,currentColor 15%,transparent)}.__P__-callout-close:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-callout-close svg{width:12px;height:12px}.__P__-panel{width:var(--__P__-panel-w);height:var(--__P__-panel-h);max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);background:var(--__P__-bg);color:var(--__P__-fg);border-radius:var(--__P__-radius-lg);box-shadow:var(--__P__-shadow-panel);display:flex;flex-direction:column;overflow:hidden;overscroll-behavior:none;transform-origin:bottom right;animation:__P__-panel-in var(--__P__-dur-slow) var(--__P__-ease);border:1px solid var(--__P__-border)}@media(prefers-reduced-motion:no-preference){.__P__-panel{transition:width var(--__P__-dur-base) var(--__P__-ease),height var(--__P__-dur-base) var(--__P__-ease),max-width var(--__P__-dur-base) var(--__P__-ease),max-height var(--__P__-dur-base) var(--__P__-ease)}.__P__-panel[data-resizing]{transition:none}}:host([data-mode="open"]) .__P__-panel{width:var(--__P__-widget-w, var(--__P__-panel-w));height:var(--__P__-widget-h, var(--__P__-panel-h));min-width:var(--__P__-resize-min-w, auto);min-height:var(--__P__-resize-min-h, auto);max-width:var(--__P__-resize-max-w, calc(100vw - 32px) );max-height:var(--__P__-resize-max-h, calc(100dvh - 32px) )}@keyframes __P__-panel-in{0%{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}:host([data-mode="expanded"]) .__P__-panel{width:var(--__P__-expanded-w, 640px);height:var(--__P__-expanded-h, 820px);max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px)}:host([data-mode="fullscreen"]){z-index:var(--__P__-z-panel)!important}:host([data-mode="fullscreen"]) .__P__-anchor{inset:var(--__P__-visual-viewport-top, 0px) 0 auto;height:var(--__P__-visual-viewport-height, 100dvh);padding:0;justify-content:flex-end;align-items:flex-end}:host([data-mode="fullscreen"][data-position*="top"]) .__P__-anchor{justify-content:flex-start}:host([data-mode="fullscreen"][data-position*="left"]) .__P__-anchor{align-items:flex-start}:host([data-mode="fullscreen"]) .__P__-panel{width:100vw;height:100%;max-width:none;max-height:none;border-radius:0;border:0}:host([data-mode="fullscreen"]) .__P__-fab{display:none}@media(max-width:640px){:host([data-mode="open"]) .__P__-anchor,:host([data-mode="expanded"]) .__P__-anchor{inset:var(--__P__-visual-viewport-top, 0px) 0 auto;align-items:stretch;height:var(--__P__-visual-viewport-height, 100dvh);padding:0}:host([data-mode="open"]) .__P__-panel,:host([data-mode="expanded"]) .__P__-panel{width:100vw;height:100%;max-width:none;max-height:none;border-radius:0;border:0}}:host([data-mode="inline"]) .__P__-anchor,:host([data-mode="standalone"]) .__P__-anchor{position:static;inset:auto;padding:0;align-items:stretch;width:100%;height:100%;min-height:0}:host([data-mode="inline"]) .__P__-panel,:host([data-mode="standalone"]) .__P__-panel{width:100%;height:100%;min-width:0;min-height:0;max-width:none;max-height:none;animation:none}:host([data-mode="inline"]) .__P__-fab,:host([data-mode="standalone"]) .__P__-fab{display:none}:host([data-mode="inline"]){min-height:320px}:host([data-mode="inline"]) .__P__-panel{border-radius:var(--__P__-radius)}:host([data-mode="standalone"]) .__P__-panel{border-radius:0;border:0;box-shadow:none}:host([data-mode="modal"]){position:fixed!important;inset:0!important;z-index:var(--__P__-z-panel)!important;display:block!important;width:100vw;height:100dvh;background:var(--__P__-modal-backdrop, var(--__P__-backdrop));animation:__P__-backdrop-in var(--__P__-dur-base) var(--__P__-ease) both;--__P__-panel-w: min(960px, 92vw);--__P__-panel-h: min(720px, 88dvh)}:host([data-mode="modal"]) .__P__-anchor{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:var(--__P__-space-6);pointer-events:none}:host([data-mode="modal"]) .__P__-panel{pointer-events:auto;width:var(--__P__-widget-w, var(--__P__-panel-w));height:var(--__P__-widget-h, var(--__P__-panel-h));max-width:calc(100vw - 48px);max-height:calc(100dvh - 48px);min-width:0;min-height:0;border-radius:var(--__P__-radius);box-shadow:var(--__P__-shadow-panel);animation:__P__-modal-in var(--__P__-dur-base) var(--__P__-ease);translate:var(--__P__-modal-dx, 0px) var(--__P__-modal-dy, 0px)}:host([data-mode="modal"]) .__P__-header,:host([data-mode="modal"]) .__P__-back-header,:host([data-mode="modal"]) .__P__-home-hero{cursor:grab;touch-action:none}:host([data-mode="modal"]) .__P__-panel[data-dragging]{cursor:grabbing;user-select:none}:host([data-mode="modal"]) .__P__-panel[data-dragging] *{cursor:grabbing}:host([data-mode="modal"]) .__P__-fab{display:none}@keyframes __P__-backdrop-in{0%{background:#0000}to{background:var(--__P__-modal-backdrop, var(--__P__-backdrop))}}@keyframes __P__-modal-in{0%{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}:host([data-mode="drawer"]){--__P__-panel-w: min(440px, calc(100vw - 32px) );--__P__-panel-h: 100dvh}:host([data-mode="drawer"]) .__P__-anchor{position:fixed;--__P__-inset-x: var(--__P__-panel-inset, 12px);--__P__-inset-y: var(--__P__-panel-inset, 3dvh);top:var(--__P__-inset-y);bottom:auto;right:var(--__P__-inset-x);left:auto;width:min(var(--__P__-widget-w, var(--__P__-panel-w)),calc(100vw - var(--__P__-inset-x) * 2));height:min(var(--__P__-widget-h, var(--__P__-panel-h)),calc(100dvh - var(--__P__-inset-y) * 2));padding:0;display:block;pointer-events:auto}:host([data-mode="drawer"][data-position$="-left"]) .__P__-anchor{right:auto;left:var(--__P__-inset-x)}:host([data-mode="drawer"][data-position^="bottom-"]) .__P__-anchor{top:auto;bottom:var(--__P__-inset-y)}:host([data-mode="drawer"]) .__P__-panel{width:100%;height:100%;max-width:none;max-height:none;min-width:0;min-height:0;border-radius:var(--__P__-radius, 12px);border:1px solid var(--__P__-border);box-shadow:-8px 16px 32px -12px #00000038;animation:__P__-drawer-in var(--__P__-dur-base) var(--__P__-ease)}:host([data-mode="drawer"][data-position$="-left"]) .__P__-panel{box-shadow:8px 16px 32px -12px #00000038;animation:__P__-drawer-in-left var(--__P__-dur-base) var(--__P__-ease)}.__P__-fab[data-edge-tab]{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--__P__-space-2);position:fixed;top:50%;height:140px;width:auto;min-width:0;padding:10px 8px;writing-mode:vertical-rl;text-orientation:mixed;transform:translateY(-50%);transform-origin:center;animation:__P__-edge-tab-in var(--__P__-dur-base) var(--__P__-ease) both}.__P__-fab[data-edge-tab] svg{writing-mode:horizontal-tb}.__P__-fab[data-edge-tab]:hover{transform:translateY(-50%) scale(1.03)}.__P__-fab[data-edge-tab]:active{transform:translateY(-50%) scale(.97)}:host([data-position$="-right"]) .__P__-fab[data-edge-tab]{right:0;left:auto;border-radius:12px 0 0 12px;box-shadow:-6px 0 18px -8px #0000004d}:host([data-position$="-left"]) .__P__-fab[data-edge-tab]{left:0;right:auto;border-radius:0 12px 12px 0;box-shadow:6px 0 18px -8px #0000004d}.__P__-fab[data-edge-tab][data-leaving]{position:fixed;top:50%;bottom:auto;animation:__P__-edge-tab-out var(--__P__-dur-quick) var(--__P__-ease) forwards}@keyframes __P__-edge-tab-in{0%{opacity:0;transform:translateY(-50%) scale(.9)}to{opacity:1;transform:translateY(-50%) scale(1)}}@keyframes __P__-edge-tab-out{0%{opacity:1;transform:translateY(-50%) scale(1)}to{opacity:0;transform:translateY(-50%) scale(.85)}}@keyframes __P__-drawer-in{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes __P__-drawer-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}@media(prefers-reduced-motion:reduce){:host([data-mode="drawer"]) .__P__-panel,.__P__-fab[data-edge-tab]{animation:none}}.__P__-header{display:flex;align-items:center;gap:var(--__P__-space-2);padding:10px 12px;border-bottom:1px solid var(--__P__-border);background:var(--__P__-bg)}.__P__-header h1{font-size:calc(14px * var(--__P__-text-scale));font-weight:600;flex:1;letter-spacing:-.01em}.__P__-header-actions{margin-inline-start:auto;display:flex;align-items:center;gap:var(--__P__-space-1);flex-shrink:0}.__P__-agent{flex:1;display:inline-flex;align-items:center;gap:10px;min-width:0}.__P__-agent-avatar{position:relative;width:32px;height:32px;border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated);color:var(--__P__-fg-muted);display:inline-flex;align-items:center;justify-content:center;font-weight:700;font-size:var(--__P__-text-xs);flex-shrink:0}.__P__-agent-avatar img{width:100%;height:100%;border-radius:inherit;object-fit:cover}.__P__-agent-avatar:after{content:"";position:absolute;right:-1px;bottom:-1px;width:10px;height:10px;border-radius:999px;border:2px solid var(--__P__-bg);background:var(--__P__-neutral)}.__P__-agent-avatar[data-status=online]:after{background:var(--__P__-success)}.__P__-agent-avatar[data-status=away]:after{background:var(--__P__-warning)}.__P__-agent-avatar[data-status=offline]:after{background:var(--__P__-neutral)}.__P__-agent-meta{display:flex;flex-direction:column;line-height:1.15;min-width:0}.__P__-agent-meta strong{font-size:calc(14px * var(--__P__-text-scale));font-weight:600;letter-spacing:-.01em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-agent-meta span{font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-suggestions{display:flex;flex-wrap:nowrap;gap:var(--__P__-space-2);padding:6px 14px 10px;overflow-x:auto;overflow-y:hidden;scroll-behavior:smooth;scroll-snap-type:x proximity;scrollbar-width:none;-ms-overflow-style:none;min-width:0}.__P__-suggestions::-webkit-scrollbar{display:none}.__P__-suggestions:before,.__P__-suggestions:after{content:"";flex:1 1 0;min-width:0}.__P__-suggestion{flex:0 0 auto;scroll-snap-align:center;padding:7px 14px;border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);color:var(--__P__-fg);font-size:var(--__P__-text-sm);font-weight:500;white-space:nowrap;transition:background var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease)}.__P__-suggestion:hover{border-color:var(--__P__-accent);color:var(--__P__-accent-fg);transform:translateY(-1px)}.__P__-suggestion:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px;border-color:var(--__P__-accent)}.__P__-suggestion:active{transform:translateY(0)}.__P__-icon-btn{width:32px;height:32px;border-radius:999px;position:relative;display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted);transition:background var(--__P__-dur-quick) var(--__P__-ease),color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-icon-btn:hover{background:var(--__P__-bg-elevated);color:var(--__P__-fg)}.__P__-icon-btn:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-icon-btn:active{background:var(--__P__-border)}.__P__-icon-btn:disabled{opacity:.45;cursor:not-allowed}.__P__-icon-btn:before{content:"";position:absolute;inset:-6px}.__P__-icon-btn svg{width:18px;height:18px}.__P__-icon-btn[data-recording=true]{color:var(--__P__-accent-fg);background:color-mix(in srgb,var(--__P__-accent) 12%,transparent);animation:__P__-pulse 1.2s var(--__P__-ease) infinite}@keyframes __P__-pulse{0%,to{box-shadow:0 0 color-mix(in srgb,var(--__P__-accent) 40%,transparent)}50%{box-shadow:0 0 0 6px color-mix(in srgb,var(--__P__-accent) 0%,transparent)}}.__P__-list,.__P__-history,.__P__-module-scroll,.__P__-home-scroll,.__P__-help-list,.__P__-toolui-code,.__P__-sidebar-conversations{scrollbar-width:thin;scrollbar-color:var(--__P__-border-strong) transparent;overscroll-behavior:contain;scrollbar-gutter:stable}.__P__-list::-webkit-scrollbar,.__P__-history::-webkit-scrollbar,.__P__-module-scroll::-webkit-scrollbar,.__P__-home-scroll::-webkit-scrollbar,.__P__-help-list::-webkit-scrollbar,.__P__-toolui-code::-webkit-scrollbar,.__P__-sidebar-conversations::-webkit-scrollbar{width:8px}.__P__-list::-webkit-scrollbar-thumb,.__P__-history::-webkit-scrollbar-thumb,.__P__-module-scroll::-webkit-scrollbar-thumb,.__P__-home-scroll::-webkit-scrollbar-thumb,.__P__-help-list::-webkit-scrollbar-thumb,.__P__-toolui-code::-webkit-scrollbar-thumb,.__P__-sidebar-conversations::-webkit-scrollbar-thumb{background:var(--__P__-border-strong);border-radius:8px}.__P__-list-wrap{position:relative;flex:1;min-height:0;display:flex;flex-direction:column}.__P__-jump{position:absolute;inset-inline-end:14px;bottom:14px;z-index:2;display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:999px;border:1px solid var(--__P__-border);background:var(--__P__-bg-elevated);color:var(--__P__-fg);box-shadow:var(--__P__-shadow-panel);cursor:pointer;opacity:.85;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease);animation:__P__-bubble-in var(--__P__-dur-base) var(--__P__-ease)}.__P__-jump:hover{opacity:1}.__P__-jump:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;opacity:1}.__P__-jump:active{transform:translateY(1px)}.__P__-jump svg{width:18px;height:18px}.__P__-list{flex:1;min-height:0;overflow-y:auto;padding:var(--__P__-space-4);padding-bottom:var(--__P__-space-8);display:flex;flex-direction:column;gap:14px}.__P__-list--fade{--__P__-fade-size: 20px;--__P__-fade-top: 0px;--__P__-fade-bottom: 0px;-webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 var(--__P__-fade-top),#000 calc(100% - var(--__P__-fade-bottom)),transparent 100%);mask-image:linear-gradient(to bottom,transparent 0,#000 var(--__P__-fade-top),#000 calc(100% - var(--__P__-fade-bottom)),transparent 100%)}.__P__-list--fade[data-fade-top=true]{--__P__-fade-top: var(--__P__-fade-size)}.__P__-list--fade[data-fade-bottom=true]{--__P__-fade-bottom: var(--__P__-fade-size)}.__P__-list>*{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-load-previous,.__P__-history-more{display:flex;justify-content:center}.__P__-load-previous button,.__P__-history-more button{border:0;padding:4px 8px;background:transparent;color:var(--__P__-accent);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;cursor:pointer}.__P__-load-previous button:hover,.__P__-history-more button:hover{text-decoration:underline}.__P__-load-previous button:focus-visible,.__P__-history-more button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-load-previous button:disabled,.__P__-history-more button:disabled{cursor:wait;opacity:.6}.__P__-date-divider{display:flex;justify-content:center;margin-block:var(--__P__-space-3)}.__P__-date-pill{padding:3px 10px;border-radius:999px;font-size:calc(11px * var(--__P__-text-scale));font-weight:600;color:var(--__P__-fg-muted);background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);box-shadow:var(--__P__-shadow-card)}.__P__-bubble-row{display:flex}.__P__-bubble-row[data-role=user]{justify-content:flex-end}.__P__-bubble-row[data-role=assistant]{justify-content:flex-start}.__P__-bubble{max-width:100%;min-width:0;padding:var(--__P__-space-3) var(--__P__-space-4);border-radius:var(--__P__-radius);line-height:1.6;font-size:calc(14px * var(--__P__-text-scale));word-wrap:break-word;overflow-wrap:break-word;box-shadow:0 1px 2px #0000000a,0 1px 8px -4px #0000000f;animation:__P__-bubble-in var(--__P__-dur-base) var(--__P__-ease)}.__P__-bubble ::selection{background:color-mix(in srgb,var(--__P__-accent) 30%,transparent)}.__P__-bubble-row[data-role=user] .__P__-bubble ::selection{background:#fff6;color:var(--__P__-bubble-user-text)}@keyframes __P__-bubble-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}.__P__-bubble-row[data-role=user] .__P__-bubble{background:var(--__P__-bubble-user);color:var(--__P__-bubble-user-text);border-end-end-radius:5px}.__P__-bubble-row[data-role=assistant] .__P__-bubble{background:var(--__P__-bubble-assistant);color:var(--__P__-bubble-assistant-text);border:1px solid var(--__P__-border);border-end-start-radius:5px}.__P__-bubble-row[data-role=operator] .__P__-bubble{display:flex;align-items:stretch;padding:0;overflow:hidden;background:var(--__P__-bubble-assistant);color:var(--__P__-bubble-assistant-text);border-end-start-radius:5px}.__P__-bubble-row[data-role=operator] .__P__-bubble-col{align-items:flex-start}.__P__-bubble-author{display:flex;flex:0 0 auto;align-items:center;padding:0 .875rem;border-inline-end:1px solid color-mix(in oklab,var(--__P__-accent),transparent 60%);color:var(--__P__-accent);font-size:calc(13px * var(--__P__-text-scale));font-weight:600;letter-spacing:.025em;user-select:none}.__P__-bubble-row[data-role=operator] .__P__-bubble-body{flex:1 1 auto;min-width:0;padding:var(--__P__-space-3) var(--__P__-space-4)}.__P__-bubble-col{display:flex;flex-direction:column;max-width:85%;min-width:0}.__P__-bubble-row[data-role=user] .__P__-bubble-col{align-items:flex-end}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col{align-items:flex-start}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui){width:100%}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui) .__P__-bubble{width:100%}@media(max-width:640px){.__P__-bubble-col{max-width:92%}.__P__-toolui:not(.__P__-toolui-collapsible){padding:var(--__P__-space-3);gap:var(--__P__-space-2)}details.__P__-toolui-collapsible>summary{padding:var(--__P__-space-2) var(--__P__-space-3)}details.__P__-toolui-collapsible>.__P__-toolui-section{margin:var(--__P__-space-3)}.__P__-toolui-section,.__P__-toolui-desc{padding:var(--__P__-space-2) var(--__P__-space-3)}}.__P__-bubble-meta{display:flex;align-items:center;gap:8px;margin-top:2px;padding:0 2px;min-height:24px}.__P__-bubble-actions{display:flex;align-items:center;gap:2px}.__P__-bubble-time{font-size:calc(11px * var(--__P__-text-scale));line-height:1;color:var(--__P__-fg-muted);user-select:none}.__P__-feedback{display:flex;align-items:center;gap:2px}.__P__-msg-action{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border:0;border-radius:var(--__P__-radius-sm);background:transparent;color:var(--__P__-fg-muted);cursor:pointer;opacity:.65;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),background var(--__P__-dur-quick) var(--__P__-ease),color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-msg-action:hover{opacity:1;background:var(--__P__-bg-elevated);color:var(--__P__-fg)}.__P__-msg-action:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;opacity:1}.__P__-msg-action[data-active=true]{opacity:1;color:var(--__P__-accent-fg)}.__P__-msg-action svg{width:15px;height:15px}.__P__-md>*:first-child{margin-top:0}.__P__-md>*:last-child{margin-bottom:0}.__P__-md p{margin:10px 0}.__P__-md h1,.__P__-md h2,.__P__-md h3,.__P__-md h4,.__P__-md h5,.__P__-md h6{margin:18px 0 8px;line-height:1.3;letter-spacing:-.01em;font-weight:700}.__P__-md h1{font-size:1.4em}.__P__-md h2{font-size:1.22em}.__P__-md h3{font-size:1.08em}.__P__-md h4,.__P__-md h5,.__P__-md h6{font-size:1em}.__P__-md>h1:first-child,.__P__-md>h2:first-child,.__P__-md>h3:first-child,.__P__-md>h4:first-child,.__P__-md>h5:first-child,.__P__-md>h6:first-child{margin-top:0}.__P__-md ul,.__P__-md ol{padding-inline-start:1.5em;margin:10px 0}.__P__-md ul{list-style:disc}.__P__-md ol{list-style:decimal}.__P__-md li{margin:6px 0;padding-inline-start:2px}.__P__-md li::marker{color:var(--__P__-fg-muted)}.__P__-md li>p{margin:6px 0}.__P__-md li>ul,.__P__-md li>ol{margin:6px 0}.__P__-md strong,.__P__-md b{font-weight:650;letter-spacing:-.005em}.__P__-md em,.__P__-md i{font-style:italic}.__P__-md code{font-family:var(--__P__-font-mono);font-size:.86em;padding:1px 6px;border-radius:5px;background:color-mix(in srgb,var(--__P__-accent) 10%,transparent);color:var(--__P__-fg);border:1px solid color-mix(in srgb,var(--__P__-accent) 16%,transparent)}.__P__-md pre{font-family:var(--__P__-font-mono);font-size:calc(12.5px * var(--__P__-text-scale));padding:12px 14px;border-radius:var(--__P__-radius-sm);background:#7f7f7f1f;overflow-x:auto;margin:var(--__P__-space-3) 0;line-height:1.5}.__P__-md pre code{padding:0;background:none}.__P__-file-image,.__P__-file-chip{margin-block:var(--__P__-space-1);border-radius:var(--__P__-radius-sm);color:inherit;text-decoration:none}.__P__-file-image{display:block;width:fit-content;max-width:min(100%,240px);overflow:hidden}.__P__-file-image img{max-height:240px;object-fit:cover}.__P__-file-chip{display:flex;align-items:center;gap:var(--__P__-space-2);max-width:min(100%,280px);padding:var(--__P__-space-2);border:1px solid color-mix(in srgb,currentColor 18%,transparent);background:color-mix(in srgb,currentColor 5%,transparent);transition:background var(--__P__-dur-base) var(--__P__-ease)}.__P__-file-chip:hover{background:color-mix(in srgb,currentColor 10%,transparent)}.__P__-file-image:focus-visible,.__P__-file-chip:focus-visible{outline:2px solid currentColor;outline-offset:2px}.__P__-file-chip-icon{flex:none;display:grid;place-items:center;width:32px;height:32px;border-radius:var(--__P__-radius-sm);background:color-mix(in srgb,currentColor 10%,transparent)}.__P__-file-chip-text{display:grid;min-width:0;line-height:1.35}.__P__-file-chip-name{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-file-chip-meta{font-size:var(--__P__-text-xs);opacity:.75}.__P__-md a{color:inherit;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px}.__P__-md a:hover{text-decoration-thickness:2px}.__P__-md blockquote{margin:14px 0;padding:6px 14px;border-inline-start:3px solid color-mix(in srgb,var(--__P__-accent) 50%,transparent);background:color-mix(in srgb,var(--__P__-accent) 5%,transparent);border-start-end-radius:var(--__P__-radius-sm);border-end-end-radius:var(--__P__-radius-sm);color:var(--__P__-fg-muted)}.__P__-md blockquote>:first-child{margin-top:0}.__P__-md blockquote>:last-child{margin-bottom:0}.__P__-md hr{border:0;height:1px;background:color-mix(in srgb,currentColor 18%,transparent);margin:var(--__P__-space-4) 0}.__P__-md table{border-collapse:collapse;margin:var(--__P__-space-3) 0;font-size:.95em;display:block;overflow-x:auto;max-width:100%;font-variant-numeric:tabular-nums}.__P__-md th,.__P__-md td{padding:6px 10px;border-bottom:1px solid color-mix(in srgb,currentColor 12%,transparent);text-align:start}.__P__-md th{font-weight:700;background:color-mix(in srgb,currentColor 6%,transparent)}.__P__-md h1+ul,.__P__-md h1+ol,.__P__-md h2+ul,.__P__-md h2+ol,.__P__-md h3+ul,.__P__-md h3+ol,.__P__-md h4+ul,.__P__-md h4+ol{margin-top:var(--__P__-space-1)}.__P__-loading{display:inline-flex;align-items:center;gap:var(--__P__-space-2);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-loading-spinner{width:14px;height:14px;border-radius:999px;border:2px solid currentColor;border-top-color:transparent;animation:__P__-spin .8s linear infinite}@keyframes __P__-spin{to{transform:rotate(1turn)}}.__P__-typing{display:inline-flex;gap:var(--__P__-space-1);padding:var(--__P__-space-1) 0}.__P__-typing span{width:5px;height:5px;border-radius:999px;background:currentColor;opacity:.4;animation:__P__-blink 1.2s var(--__P__-ease) infinite}.__P__-typing span:nth-child(2){animation-delay:.2s}.__P__-typing span:nth-child(3){animation-delay:.4s}@keyframes __P__-blink{0%,80%,to{opacity:.3;transform:translateY(0)}40%{opacity:1;transform:translateY(-2px)}}.__P__-reasoning{margin:var(--__P__-space-1) 0 var(--__P__-space-2);padding-inline-start:var(--__P__-space-3);border-inline-start:2px solid var(--__P__-border-strong)}.__P__-reasoning-summary{display:inline-flex;align-items:center;gap:var(--__P__-space-1);cursor:pointer;list-style:none;user-select:none;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-reasoning-summary:hover{color:var(--__P__-fg)}.__P__-reasoning-summary:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-reasoning-summary::-webkit-details-marker{display:none}.__P__-reasoning-summary:before{content:"";width:5px;height:5px;border-inline-end:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(-45deg);opacity:.7;transition:transform var(--__P__-dur-quick) var(--__P__-ease)}.__P__-reasoning[open] .__P__-reasoning-summary:before{transform:rotate(45deg)}.__P__-reasoning[data-active=true] .__P__-reasoning-label{animation:__P__-reasoning-pulse 1.4s var(--__P__-ease) infinite}@keyframes __P__-reasoning-pulse{0%,to{opacity:.5}50%{opacity:1}}@media(prefers-reduced-motion:reduce){.__P__-reasoning[data-active=true] .__P__-reasoning-label{animation:none}}.__P__-reasoning-body{margin-top:var(--__P__-space-1);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-reasoning-body>:first-child{margin-top:0}.__P__-reasoning-body>:last-child{margin-bottom:0}.__P__-source{display:inline-flex;align-items:center;gap:6px;max-width:100%;margin-top:6px;margin-inline-end:6px;padding:var(--__P__-space-1) var(--__P__-space-2);border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);text-decoration:none}a.__P__-source:hover{color:var(--__P__-fg);border-color:var(--__P__-accent)}.__P__-source-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-composer{border-top:1px solid var(--__P__-border);padding:10px 12px;background:var(--__P__-bg);display:flex;flex-direction:column;gap:var(--__P__-space-2)}.__P__-composer>*{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-compaction-status{width:100%;padding:10px 14px;justify-content:center;font-size:var(--__P__-text-xs)}.__P__-message-queue{display:flex;max-height:112px;flex-direction:column;gap:var(--__P__-space-1);overflow-y:auto}.__P__-attachment-chip.__P__-queued-message{width:100%;max-width:none}.__P__-queued-text{min-width:0;flex:1}.__P__-composer-row{display:flex;align-items:flex-end;gap:6px}.__P__-textarea{flex:1;--__P__-textarea-base-height: 40px;height:var(--__P__-textarea-base-height);max-height:160px;padding:10px 12px;border-radius:var(--__P__-radius);background:var(--__P__-bg-elevated);border:1px solid transparent;font-size:calc(14px * var(--__P__-text-scale));line-height:1.4;transition:height var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-textarea:focus-visible{outline:none;border-color:var(--__P__-focus)}@media(pointer:coarse){.__P__-textarea{--__P__-textarea-base-height: 44px}}.__P__-send{width:40px;height:40px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease),background var(--__P__-dur-quick) var(--__P__-ease)}.__P__-send[data-shape=circle]{border-radius:999px}.__P__-send[data-shape=square]{border-radius:var(--__P__-radius-sm)}.__P__-send[data-shape=pill]{width:auto;padding:0 18px;border-radius:999px}.__P__-send[data-variant=filled]{background:var(--__P__-accent);color:var(--__P__-accent-text)}.__P__-send[data-variant=outline]{background:transparent;color:var(--__P__-accent-fg);border-color:var(--__P__-accent)}.__P__-send[data-variant=outline]:not(:disabled):hover{background:color-mix(in srgb,var(--__P__-accent) 10%,transparent)}.__P__-send[data-variant=ghost]{background:transparent;color:var(--__P__-accent-fg)}.__P__-send[data-variant=ghost]:not(:disabled):hover{background:color-mix(in srgb,var(--__P__-accent) 8%,transparent)}.__P__-send:disabled{opacity:.4;cursor:not-allowed}.__P__-send:not(:disabled):hover{transform:translateY(-1px)}.__P__-send:not(:disabled):active{transform:translateY(0)}.__P__-send:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-send svg{width:18px;height:18px}.__P__-composer-actions{display:flex;gap:var(--__P__-space-1);flex-wrap:wrap}.__P__-attachments{display:flex;flex-wrap:wrap;gap:6px}.__P__-attachment-chip{display:inline-flex;align-items:center;gap:6px;padding:var(--__P__-space-1) var(--__P__-space-2) var(--__P__-space-1) var(--__P__-space-1);border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);font-size:var(--__P__-text-xs);max-width:200px}.__P__-attachment-thumb{width:24px;height:24px;border-radius:999px;object-fit:cover;background:var(--__P__-border)}.__P__-attachment-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-attachment-remove{width:18px;height:18px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted)}.__P__-attachment-remove:hover{background:var(--__P__-border);color:var(--__P__-fg)}.__P__-dropzone{position:absolute;inset:8px;border:2px dashed var(--__P__-accent);border-radius:var(--__P__-radius);background:color-mix(in srgb,var(--__P__-accent) 8%,transparent);display:flex;align-items:center;justify-content:center;font-weight:600;color:var(--__P__-accent-fg);pointer-events:none;z-index:10;animation:__P__-fade-in var(--__P__-dur-quick) var(--__P__-ease)}@keyframes __P__-fade-in{0%{opacity:0}to{opacity:1}}.__P__-error{margin-top:var(--__P__-space-1);padding:8px 12px;border-radius:var(--__P__-radius-sm);background:color-mix(in oklab,var(--__P__-danger) 8%,var(--__P__-bg-elevated));border:1px solid color-mix(in oklab,var(--__P__-danger) 20%,transparent);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);display:flex;align-items:center;gap:var(--__P__-space-2)}.__P__-error span{min-width:0}.__P__-error button{margin-inline-start:auto;flex-shrink:0;border:0;background:none;padding:0;color:var(--__P__-accent-fg);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;text-decoration:underline;white-space:nowrap;cursor:pointer}.__P__-history{flex:1;overflow-y:auto;padding:var(--__P__-space-2) var(--__P__-space-1) var(--__P__-space-3)}.__P__-history-footer{flex:none;padding:var(--__P__-space-2) var(--__P__-space-3) var(--__P__-space-3);border-top:1px solid var(--__P__-border);background:var(--__P__-surface)}.__P__-history-new{width:100%;display:flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);padding:var(--__P__-space-2) var(--__P__-space-3);border:none;border-radius:var(--__P__-radius-md);background:var(--__P__-accent);color:var(--__P__-on-accent);cursor:pointer;font-size:var(--__P__-text-sm);font-weight:600;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-history-new svg{width:16px;height:16px}.__P__-history-new:hover{filter:brightness(1.08)}.__P__-history-new:active{transform:translateY(1px)}.__P__-history-new:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-history-empty{flex:1;display:flex;align-items:center;justify-content:center;padding:40px 16px;color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale));text-align:center}.__P__-history-group{display:flex;flex-direction:column;padding:0 var(--__P__-space-3)}.__P__-history-heading{font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);padding:14px 4px 8px;text-transform:uppercase;letter-spacing:.04em}.__P__-history-card{display:flex;flex-direction:column;background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-lg, 14px);overflow:hidden}.__P__-history-card>[role=listitem]{display:flex;flex-direction:column}.__P__-history-item{all:unset;display:flex;align-items:center;gap:var(--__P__-space-3);padding:12px var(--__P__-space-3);cursor:pointer;transition:background var(--__P__-dur-base) var(--__P__-ease)}.__P__-history-card>*+*{border-top:1px solid var(--__P__-border)}.__P__-history-item:hover{background:var(--__P__-bg-elevated)}.__P__-history-item:focus-visible{background:var(--__P__-bg-elevated);outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-history-avatar{flex:none;display:grid;place-items:center;width:36px;height:36px;border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-accent) 12%,transparent);color:var(--__P__-accent-fg)}.__P__-history-avatar svg{width:18px;height:18px}.__P__-history-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.__P__-history-row{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-2)}.__P__-history-title{flex:1;min-width:0;font-size:calc(14px * var(--__P__-text-scale));font-weight:500;color:var(--__P__-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-history-time{flex:none;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-history-preview{flex:1;min-width:0;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-history-dot{flex:none;width:8px;height:8px;border-radius:50%;background:var(--__P__-accent)}.__P__-history-item[data-unread=true] .__P__-history-title{font-weight:600}.__P__-history-item[data-closed=true] .__P__-history-title{color:var(--__P__-fg-muted)}.__P__-history-item-skeleton{cursor:default;pointer-events:none}.__P__-skeleton{display:block;border-radius:4px;background:linear-gradient(90deg,color-mix(in oklab,var(--__P__-fg) 9%,transparent) 30%,color-mix(in oklab,var(--__P__-fg) 17%,transparent),color-mix(in oklab,var(--__P__-fg) 9%,transparent) 70%);background-size:200% 100%;animation:__P__-skeleton-shimmer 1.8s ease-in-out infinite}.__P__-history-avatar.__P__-skeleton{border-radius:var(--__P__-radius-md)}.__P__-skeleton-heading{width:52px;height:8px}.__P__-skeleton-title{width:55%;height:12px}.__P__-skeleton-time{width:34px;height:10px}.__P__-skeleton-preview{width:80%;height:10px}@keyframes __P__-skeleton-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){.__P__-skeleton{animation:none}}.__P__-list-loading{margin:auto;padding:var(--__P__-space-6) var(--__P__-space-4);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);text-align:center}.__P__-readonly-banner{display:flex;flex-direction:column;align-items:center;gap:10px;padding:14px 12px;margin:0 var(--__P__-space-3) var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated);color:var(--__P__-fg-muted);text-align:center;font-size:var(--__P__-text-sm)}.__P__-readonly-label{line-height:1.4}.__P__-readonly-cta{appearance:none;border:0;cursor:pointer;padding:var(--__P__-space-2) var(--__P__-space-4);border-radius:999px;background:var(--__P__-accent);color:var(--__P__-accent-text, #fff);font:inherit;font-weight:600;font-size:var(--__P__-text-sm);transition:filter var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-readonly-cta:hover,.__P__-readonly-cta:focus-visible{filter:brightness(1.1)}.__P__-operator-banner{display:flex;align-items:center;justify-content:center;gap:8px;margin:0 var(--__P__-space-3) var(--__P__-space-1);padding:8px 12px;border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-bg-elevated),var(--__P__-accent) 6%);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);line-height:1.3;text-align:center}.__P__-operator-pulse{flex:0 0 auto;width:8px;height:8px;border-radius:50%;background:var(--__P__-accent)}.__P__-operator-banner[data-mode=awaiting-operator] .__P__-operator-pulse{animation:__P__-operator-pulse 1.4s var(--__P__-ease-out) infinite}.__P__-cancel-operator-request{flex:0 0 auto;padding:0;border:0;background:none;color:var(--__P__-accent);font:inherit;font-weight:600;text-decoration:underline;text-underline-offset:2px;cursor:pointer}.__P__-cancel-operator-request:hover{opacity:.8}.__P__-cancel-operator-request:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px;border-radius:var(--__P__-radius-sm)}@keyframes __P__-operator-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(.7)}}.__P__-readonly-cta:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px}.__P__-composer-footer{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:10px 16px;margin:0 var(--__P__-space-3);border-top:1px solid var(--__P__-border);text-align:center;font-size:calc(11px * var(--__P__-text-scale));line-height:1.4;color:var(--__P__-fg-muted)}.__P__-disclaimer{max-width:320px;margin:0 auto;opacity:.9;letter-spacing:.01em}.__P__-poweredby{display:inline-flex;align-items:center;justify-content:center;gap:6px;color:inherit;text-decoration:none;opacity:.7;transition:opacity var(--__P__-dur-base) var(--__P__-ease);font-size:calc(11px * var(--__P__-text-scale));letter-spacing:.02em}.__P__-poweredby:hover{opacity:1}.__P__-poweredby-logo{height:12px;width:auto;display:inline-block;vertical-align:middle}.__P__-poweredby-bar{flex:none;display:flex;align-items:center;justify-content:center;padding:6px 16px;border-top:1px solid var(--__P__-border);background:var(--__P__-bg-elevated)}.__P__-menu-wrap{position:relative;display:inline-flex}.__P__-menu{position:absolute;top:100%;inset-inline-end:0;margin-top:6px;min-width:200px;padding:6px;background:var(--__P__-bg);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);box-shadow:var(--__P__-shadow-panel);z-index:10;display:flex;flex-direction:column;gap:2px;animation:__P__-menu-in var(--__P__-dur-base) var(--__P__-ease)}@media(prefers-reduced-motion:reduce){.__P__-menu{animation:none}}@keyframes __P__-menu-in{0%{opacity:0;transform:translateY(-4px) scale(.98);transform-origin:top right}to{opacity:1;transform:none}}.__P__-menu-item{all:unset;display:flex;align-items:center;gap:10px;padding:8px 10px;font-size:var(--__P__-text-sm);color:var(--__P__-fg);border-radius:var(--__P__-radius-sm);cursor:pointer;user-select:none}.__P__-menu-item:hover{background:var(--__P__-bg-elevated)}.__P__-menu-item:focus-visible{background:var(--__P__-bg-elevated);outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-menu-item[disabled]{opacity:.45;cursor:not-allowed}.__P__-menu-icon{display:inline-flex;width:16px;height:16px;color:var(--__P__-fg-muted)}.__P__-menu-icon svg{width:16px;height:16px}.__P__-menu-label{flex:1}.__P__-menu-check{display:inline-flex;color:var(--__P__-accent-fg)}.__P__-menu-check svg{width:14px;height:14px}.__P__-menu-item-segmented{cursor:default}.__P__-menu-item-segmented:hover{background:transparent}.__P__-segmented{display:inline-flex;gap:2px;padding:2px;background:var(--__P__-bg-elevated);border-radius:var(--__P__-radius-sm)}.__P__-segment{all:unset;min-width:26px;padding:3px 8px;font-size:var(--__P__-text-xs);font-weight:600;letter-spacing:.02em;text-align:center;color:var(--__P__-fg-muted);border-radius:calc(var(--__P__-radius-sm) - 2px);cursor:pointer;transition:color .12s ease,background .12s ease}.__P__-segment:hover{color:var(--__P__-fg)}.__P__-segment[data-on=true]{background:var(--__P__-bg);color:var(--__P__-accent-fg);box-shadow:var(--__P__-shadow-card)}.__P__-segment:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-resize-grip{position:absolute;width:18px;height:18px;display:flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted);opacity:.45;transition:opacity var(--__P__-dur-base) var(--__P__-ease);z-index:2;touch-action:none;user-select:none}.__P__-resize-grip:hover,.__P__-resize-grip:focus-visible{opacity:1}.__P__-resize-grip svg{width:10px;height:10px}.__P__-resize-grip--bottom-left{bottom:2px;left:2px;cursor:nesw-resize;transform:scaleX(-1)}.__P__-resize-grip--bottom-right{bottom:2px;right:2px;cursor:nwse-resize}.__P__-resize-grip--top-left{top:2px;left:2px;cursor:nwse-resize;transform:rotate(180deg)}.__P__-resize-grip--top-right{top:2px;right:2px;cursor:nesw-resize;transform:scaleY(-1)}:host(:not([data-mode="open"])) .__P__-resize-grip{display:none}.__P__-messenger{display:flex;flex-direction:column;overflow:hidden}.__P__-messenger-body,.__P__-messenger-pane{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.__P__-messenger-pane[hidden]{display:none}@keyframes __P__-view-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}.__P__-module{display:flex;flex-direction:column;height:100%;min-height:0}@media(prefers-reduced-motion:no-preference){.__P__-module,.__P__-history{animation:__P__-view-in .18s var(--__P__-ease-out)}}.__P__-module-scroll{flex:1;min-height:0;overflow-y:auto;padding:var(--__P__-space-3);display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-home{container-type:inline-size;background:radial-gradient(125% 65% at 88% 0%,color-mix(in srgb,#fff 16%,transparent),transparent 55%),linear-gradient(180deg,var(--__P__-accent) 0%,var(--__P__-accent) 22%,color-mix(in srgb,var(--__P__-accent) 28%,var(--__P__-surface)) 44%,var(--__P__-surface) 70%);border-radius:var(--__P__-radius-lg) var(--__P__-radius-lg) 0 0}.__P__-home-scroll{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;background:transparent}.__P__-home-cards{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:4px 14px 16px}.__P__-module-pad{padding:var(--__P__-space-3) var(--__P__-space-3) 0}.__P__-module-empty{display:flex;flex-direction:column;align-items:center;gap:var(--__P__-space-3);padding:var(--__P__-space-8) var(--__P__-space-4);text-align:center;color:var(--__P__-fg-muted);font-size:var(--__P__-text-base)}.__P__-module-retry{padding:var(--__P__-space-2) var(--__P__-space-4);border:1px solid var(--__P__-border-strong);border-radius:var(--__P__-radius-sm);color:var(--__P__-fg);font-weight:600;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out),border-color var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-module-retry:hover{background:var(--__P__-hover);border-color:var(--__P__-accent)}.__P__-module-retry:active{background:var(--__P__-border)}.__P__-module-retry:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-help-list{flex:1;min-height:0;overflow-y:auto;padding-bottom:var(--__P__-space-3)}.__P__-help-group{display:flex;flex-direction:column}.__P__-help-section-title{position:sticky;top:0;z-index:1;margin:0;padding:var(--__P__-space-3) var(--__P__-space-5) var(--__P__-space-2);font-size:var(--__P__-text-xs);font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--__P__-fg-muted);background:var(--__P__-bg)}.__P__-help-card{margin:0 var(--__P__-space-3) var(--__P__-space-3);background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden}.__P__-help-card .__P__-list-row{border-bottom:0;border-radius:0}.__P__-help-card .__P__-list-row+.__P__-list-row{border-top:1px solid var(--__P__-border)}.__P__-help-more{justify-content:center;color:var(--__P__-accent-fg);font-weight:600}.__P__-tabbar{display:flex;border-top:1px solid var(--__P__-border);background:var(--__P__-bg-elevated);flex-shrink:0}.__P__-tab{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--__P__-space-1);min-height:48px;padding:var(--__P__-space-2) var(--__P__-space-1);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600;transition:color var(--__P__-dur-quick) var(--__P__-ease-out)}@media(hover:hover){.__P__-tab:hover{background:var(--__P__-hover)}}.__P__-tab[aria-selected=true]{color:var(--__P__-accent-fg)}.__P__-tab:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-tab:active{background:var(--__P__-hover)}.__P__-tab-icon{position:relative;display:inline-flex}.__P__-tab-icon svg{width:22px;height:22px}.__P__-tab-badge{position:absolute;top:-2px;left:calc(50% + 6px);width:8px;height:8px;border-radius:50%;background:var(--__P__-accent);box-shadow:0 0 0 2px var(--__P__-bg-elevated)}.__P__-home-hero{flex-shrink:0;padding:var(--__P__-space-5) var(--__P__-space-5) var(--__P__-space-3);color:var(--__P__-on-accent);--__P__-focus: var(--__P__-on-accent)}.__P__-home-hero-top{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);min-height:32px}.__P__-home-brand{font-size:clamp(calc(12px * var(--__P__-text-scale)),calc(3.2cqi * var(--__P__-text-scale)),calc(14px * var(--__P__-text-scale)));font-weight:600;letter-spacing:.01em;color:color-mix(in srgb,#fff 82%,transparent);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.__P__-home-brand-spacer{flex:1}.__P__-home-hero-actions{display:flex;align-items:center;gap:var(--__P__-space-2);flex-shrink:0}.__P__-home-hero-actions .__P__-icon-btn{color:#fff}.__P__-home-hero-actions .__P__-icon-btn:hover{background:color-mix(in srgb,#fff 18%,transparent);color:#fff}.__P__-home-hero-actions .__P__-icon-btn:active{background:color-mix(in srgb,#fff 26%,transparent)}.__P__-home-greeting{margin:28px 0 0;font-family:var(--__P__-font-display);font-size:clamp(calc(19px * var(--__P__-text-scale)),calc(5.5cqi * var(--__P__-text-scale)),var(--__P__-text-2xl));font-weight:800;line-height:1.18;letter-spacing:-.01em;overflow-wrap:anywhere}.__P__-home-lead{margin:10px 0 0;font-family:var(--__P__-font-display);font-size:clamp(calc(15px * var(--__P__-text-scale)),calc(4.2cqi * var(--__P__-text-scale)),var(--__P__-text-xl));font-weight:600;line-height:1.25;letter-spacing:-.005em;color:color-mix(in srgb,var(--__P__-on-accent) 78%,transparent);overflow-wrap:anywhere}.__P__-home-avatars{display:flex}.__P__-home-avatar{width:30px;height:30px;border-radius:var(--__P__-radius-md);overflow:hidden;margin-inline-start:-10px;border:2px solid color-mix(in srgb,#fff 92%,transparent);box-shadow:0 1px 3px #0000002e;background:var(--__P__-surface);display:inline-flex;align-items:center;justify-content:center;font-size:var(--__P__-text-xs);font-weight:700;color:var(--__P__-fg)}.__P__-home-avatar:first-child{margin-inline-start:0}.__P__-home-avatar img{width:100%;height:100%;object-fit:cover}.__P__-home-content{background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);box-shadow:var(--__P__-shadow-card);overflow:hidden}.__P__-home-content-title{padding:var(--__P__-space-4) var(--__P__-space-4) var(--__P__-space-3);font-size:var(--__P__-text-sm);font-weight:700}.__P__-home-content-list{display:flex;flex-direction:column;padding:0 var(--__P__-space-2) var(--__P__-space-2)}.__P__-home-content-list .__P__-list-row+.__P__-list-row{border-top:1px solid var(--__P__-border)}.__P__-home-card{display:block;width:100%;text-align:start;background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);padding:var(--__P__-space-4);box-shadow:var(--__P__-shadow-card)}.__P__-home-card[data-interactive=true]{cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-home-card[data-interactive=true]:hover{background:var(--__P__-bg-elevated)}.__P__-home-card[data-interactive=true]:active{transform:translateY(1px)}.__P__-home-card[data-interactive=true]:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-recent-row{display:flex;align-items:center;gap:var(--__P__-space-3)}.__P__-home-recent-avatar{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;flex-shrink:0;border-radius:var(--__P__-radius-md);background:color-mix(in oklch,var(--__P__-accent) 14%,transparent);color:var(--__P__-accent-fg)}.__P__-home-recent-avatar svg{width:20px;height:20px}.__P__-home-recent-body{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1;line-height:1.45}.__P__-home-recent-title{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-recent-preview{color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-home-recent-dot{width:8px;height:8px;border-radius:999px;background:var(--__P__-accent);flex-shrink:0}.__P__-home-recent-row[data-unread=true] .__P__-home-recent-title{font-weight:700}.__P__-home-status{display:flex;align-items:center;gap:var(--__P__-space-3)}.__P__-home-status-icon svg{width:22px;height:22px;color:var(--__P__-success)}.__P__-home-status[data-level=degraded] .__P__-home-status-icon svg{color:var(--__P__-warning)}.__P__-home-status[data-level=down] .__P__-home-status-icon svg{color:var(--__P__-danger)}.__P__-home-status-text{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-search{display:flex;align-items:center;gap:var(--__P__-space-2);width:100%;padding:var(--__P__-space-3) var(--__P__-space-4);border-radius:var(--__P__-radius);border:1px solid var(--__P__-border);background:var(--__P__-surface);text-align:start}.__P__-home-search[data-input=true]{background:var(--__P__-bg-elevated)}.__P__-home-search:hover{border-color:var(--__P__-border-strong)}.__P__-home-search:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-search[data-input=true]:focus-within{outline:none;border-color:var(--__P__-focus)}.__P__-home-search-text{flex:1;color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-search-input{flex:1;border:0;background:transparent;font-size:calc(14px * var(--__P__-text-scale));color:var(--__P__-fg);outline:none}.__P__-home-search-input:focus-visible{outline:none}.__P__-home-search-icon svg{width:18px;height:18px;color:var(--__P__-accent-fg)}.__P__-home-ask{padding-block:6px;padding-inline-end:6px}.__P__-home-ask .__P__-send{width:32px;height:32px;flex-shrink:0}.__P__-home-ask .__P__-send[data-shape=pill]{width:auto;padding:0 14px}.__P__-home-ask .__P__-send svg{width:16px;height:16px}.__P__-list-row{display:flex;align-items:center;gap:var(--__P__-space-3);width:100%;min-height:44px;text-align:start;padding:var(--__P__-space-3) var(--__P__-space-2);border-radius:var(--__P__-radius-sm)}.__P__-list-row:hover{background:var(--__P__-hover)}.__P__-list-row:active{background:var(--__P__-border)}.__P__-list-row:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-list-row-body{display:flex;flex-direction:column;min-width:0;flex:1}.__P__-list-row-title{font-weight:600;font-size:var(--__P__-text-md);line-height:1.35}.__P__-list-row-sub{color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);margin-top:var(--__P__-space-1);line-height:1.45;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.__P__-list-row-chevron svg{width:18px;height:18px;color:var(--__P__-accent-fg);flex-shrink:0}.__P__-back-header{display:flex;align-items:center;gap:var(--__P__-space-2);padding:10px 12px;border-bottom:1px solid var(--__P__-border);flex-shrink:0}.__P__-back-title{flex:1;text-align:center;font-size:var(--__P__-text-md);font-weight:700;margin:0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-back-spacer{width:32px;height:1px}.__P__-history>*,.__P__-home-scroll>*,.__P__-module-scroll>*,.__P__-help-list>*,.__P__-history-footer>*,.__P__-module-pad{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-header,.__P__-back-header{padding-inline:max(12px,calc((100% - var(--__P__-conversation-max, 768px)) / 2))}.__P__-tabbar{padding-inline:max(0px,calc((100% - var(--__P__-conversation-max, 768px)) / 2))}.__P__-content{display:flex;flex-direction:column;gap:14px;width:100%;max-width:68ch;margin:0 auto}.__P__-content-hero{width:100%;border-radius:var(--__P__-radius)}.__P__-content-subtitle{color:var(--__P__-fg-muted);margin:0}.__P__-content-vote{display:flex;align-items:center;flex-wrap:wrap;gap:var(--__P__-space-2);padding-top:var(--__P__-space-3);border-top:1px solid var(--__P__-border)}.__P__-content-frame{flex:1;min-height:0;width:100%;border:0;background:#fff}.__P__-news-list{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-news-card{display:block;width:100%;text-align:start;line-height:1.45;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden;background:var(--__P__-surface);transition:background var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-news-card:hover{background:var(--__P__-bg-elevated)}.__P__-news-card:active{transform:translateY(1px)}.__P__-news-card:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-news-hero{width:100%;display:block}.__P__-news-body{display:flex;flex-direction:column;gap:6px;padding:14px 16px}.__P__-news-title{font-weight:700;font-size:var(--__P__-text-md)}.__P__-news-meta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-news-tag{padding:1px 8px;border-radius:6px;background:var(--__P__-hover);color:var(--__P__-fg);font-size:calc(12px * var(--__P__-text-scale));white-space:nowrap}.__P__-news-more{display:flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);width:100%;min-height:44px;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);background:var(--__P__-surface);color:var(--__P__-accent-fg);font-weight:600}.__P__-news-more:hover{background:var(--__P__-bg-elevated)}.__P__-news-more:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-news-summary{color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale));display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.__P__-modules-empty{display:flex;align-items:center;justify-content:center;position:relative}.__P__-modules-empty-close{position:absolute;top:12px;inset-inline-end:12px}.__P__-modules-empty-text{color:var(--__P__-fg-muted);font-size:var(--__P__-text-base)}.__P__-form{display:flex;flex-direction:column;gap:var(--__P__-space-4)}.__P__-field{display:flex;flex-direction:column;gap:6px}.__P__-field-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:var(--__P__-space-2)}.__P__-field-label{font-size:var(--__P__-text-sm);font-weight:600;color:var(--__P__-fg)}.__P__-field-req{color:var(--__P__-danger)}.__P__-field-type{flex-shrink:0;align-self:center;margin-inline-start:auto;border:1px solid var(--__P__-border);border-radius:5px;background:color-mix(in oklab,var(--__P__-fg-muted) 9%,transparent);padding:1px 7px;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);white-space:nowrap}.__P__-field-input{width:100%;min-width:0;max-width:100%;box-sizing:border-box;padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);color:var(--__P__-fg);font:inherit;font-size:var(--__P__-text-sm);resize:vertical;transition:border-color var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-field-input:focus-visible{outline:none;border-color:var(--__P__-accent)}.__P__-field[data-invalid=true] .__P__-field-input{border-color:var(--__P__-danger)}.__P__-field-input[type=date],.__P__-field-input[type=time]{appearance:none;-webkit-appearance:none}@media(pointer:coarse){.__P__-textarea,.__P__-home-search-input,.__P__-field-input{font-size:max(16px,calc(16px * var(--__P__-text-scale)))}}.__P__-field-hint{font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-field-error{font-size:var(--__P__-text-xs);color:var(--__P__-danger)}.__P__-field-choices{display:flex;flex-direction:column;gap:10px;padding-top:2px}.__P__-choice{display:flex;align-items:flex-start;gap:10px;font-size:var(--__P__-text-sm);color:var(--__P__-fg);cursor:pointer}.__P__-choice input{margin-top:2px;accent-color:var(--__P__-accent)}.__P__-form-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}.__P__-form-hint{flex:1 1 auto;min-width:6rem;margin-inline-end:auto;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-form-submit{padding:var(--__P__-space-2) var(--__P__-space-4);border:none;border-radius:var(--__P__-radius-md);background:var(--__P__-accent);color:var(--__P__-accent-text, #fff);font:inherit;font-weight:600;font-size:var(--__P__-text-sm);white-space:nowrap;flex-shrink:0;cursor:pointer;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-form-submit:hover:not(:disabled){filter:brightness(1.06)}.__P__-form-submit:disabled{opacity:.6;cursor:default}.__P__-form-skip{padding:var(--__P__-space-2) var(--__P__-space-4);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:transparent;color:var(--__P__-fg-muted);font:inherit;font-size:var(--__P__-text-sm);white-space:nowrap;flex-shrink:0;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-form-skip:hover:not(:disabled){background:var(--__P__-bg-elevated)}@media(max-width:640px){.__P__-form-hint{flex-basis:100%;margin-inline-end:0;font-size:var(--__P__-text-xs)}.__P__-form-submit,.__P__-form-skip{flex:1 1 0;text-align:center}}.__P__-form-gate{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated)}.__P__-form-gate-title{margin:0;font-size:var(--__P__-text-base);font-weight:700;color:var(--__P__-fg)}.__P__-form-gate-desc{margin:0 0 var(--__P__-space-1);font-size:var(--__P__-text-sm);color:var(--__P__-fg-muted)}.__P__-form-done{display:flex;align-items:center;justify-content:center;gap:6px;padding:6px 12px;border:1px dashed var(--__P__-border);border-radius:999px;align-self:center;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted)}.__P__-form-done svg{width:14px;height:14px;color:var(--__P__-success, #22c55e)}.__P__-form-done[data-outcome=skipped] svg{color:var(--__P__-fg-muted)}.__P__-form-done-fill{border:0;background:none;padding:0 2px;cursor:pointer;font:inherit;font-weight:600;color:var(--__P__-accent-fg)}.__P__-form-done-fill:hover{text-decoration:underline}details.__P__-form-done{display:block;padding:0;border-radius:var(--__P__-radius-md)}details[open].__P__-form-done{width:min(100%,420px);background:var(--__P__-surface)}.__P__-form-done-summary{display:flex;align-items:center;justify-content:center;gap:6px;padding:8px 12px;cursor:pointer;list-style:none}.__P__-form-done-summary::-webkit-details-marker{display:none}.__P__-form-done-summary>svg:last-child{color:var(--__P__-fg-muted);transition:transform .15s var(--__P__-ease)}details[open]>.__P__-form-done-summary>svg:last-child{transform:rotate(90deg)}.__P__-form-answers{margin:0;padding:var(--__P__-space-2) var(--__P__-space-3) var(--__P__-space-3);display:grid;gap:var(--__P__-space-3);text-align:start}.__P__-form-answer{display:grid;gap:6px}.__P__-form-answer dt{font-size:var(--__P__-text-sm);font-weight:600;color:var(--__P__-fg)}.__P__-form-answer dd{margin:0;padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);font-size:var(--__P__-text-sm);font-weight:400;color:var(--__P__-fg);overflow-wrap:anywhere}.__P__-toolui{margin-block:var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-lg, 14px);background:var(--__P__-bg-elevated);font-size:var(--__P__-text-sm)}.__P__-toolui:not(.__P__-toolui-collapsible){display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4)}.__P__-toolui-group{display:flex;flex-direction:column;gap:var(--__P__-space-3);margin-block:var(--__P__-space-3)}.__P__-toolui-group>.__P__-toolui{margin-block:0}.__P__-toolui-stale{opacity:.7}details.__P__-toolui-collapsible>summary{display:flex;align-items:center;gap:var(--__P__-space-2);padding:var(--__P__-space-3) var(--__P__-space-4);cursor:pointer;list-style:none;-webkit-tap-highlight-color:transparent;user-select:none}details.__P__-toolui-collapsible>summary::-webkit-details-marker{display:none}details.__P__-toolui-collapsible[open]>summary{border-bottom:1px solid var(--__P__-border)}details.__P__-toolui-collapsible>.__P__-toolui-section{margin:var(--__P__-space-4)}details.__P__-toolui-collapsible>.__P__-toolui-section~.__P__-toolui-section{margin-top:calc(-1 * var(--__P__-space-2))}.__P__-toolui-name-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-toolui-chevron{display:inline-flex;color:var(--__P__-fg-muted);transition:transform var(--__P__-dur-quick) var(--__P__-ease-out)}details.__P__-toolui-collapsible>summary .__P__-toolui-status{margin-inline-start:auto}.__P__-toolui-chevron svg{width:16px;height:16px}details.__P__-toolui-collapsible[open]>summary .__P__-toolui-chevron{transform:rotate(180deg)}.__P__-toolui-badge,.__P__-toolui-name-pill,.__P__-toolui-q-pill{--__P__-pill: var(--__P__-fg-muted);display:inline-flex;min-width:0;align-items:center;gap:5px;padding:3px 7px;border-radius:5px;border:1px solid var(--__P__-border);background:color-mix(in oklab,var(--__P__-fg-muted) 9%,transparent);color:var(--__P__-pill);font-size:var(--__P__-text-xs);font-weight:600;white-space:nowrap}.__P__-toolui-badge svg,.__P__-toolui-name-pill svg,.__P__-toolui-q-pill svg{flex-shrink:0;width:14px;height:14px}.__P__-toolui-status-icon{display:inline-flex}.__P__-toolui-name-pill{--__P__-pill: oklch(.68 .13 233)}.__P__-toolui-q-pill{--__P__-pill: oklch(.66 .12 195)}.__P__-toolui-status[data-status=completed]{--__P__-pill: var(--__P__-success, #16a34a)}.__P__-toolui-status[data-status=responded]{--__P__-pill: oklch(.62 .15 255)}.__P__-toolui-status[data-status=awaiting]{--__P__-pill: var(--__P__-warning, #f59e0b)}.__P__-toolui-status[data-status=denied]{--__P__-pill: oklch(.66 .16 45)}.__P__-toolui-status[data-status=error]{--__P__-pill: var(--__P__-danger, #dc2626)}.__P__-toolui-status[data-status=superseded],.__P__-toolui-status[data-status=incomplete]{--__P__-pill: var(--__P__-fg-muted)}@supports (color: oklch(from red l c h)){.__P__-toolui-badge,.__P__-toolui-name-pill,.__P__-toolui-q-pill{color:oklch(from var(--__P__-pill) clamp(var(--__P__-pill-l-min),l,var(--__P__-pill-l-max)) c h)}}.__P__-toolui-head{display:flex;align-items:center;flex-wrap:wrap;gap:var(--__P__-space-2)}.__P__-toolui-head-end{display:inline-flex;align-items:center;gap:var(--__P__-space-2);margin-inline-start:auto}.__P__-toolui-collapse-body{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4)}.__P__-toolui-summary{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-toolui-collapse-body>.__P__-form{gap:var(--__P__-space-3)}.__P__-toolui-collapse-body>.__P__-form>.__P__-field,.__P__-toolui-summary>.__P__-field{padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-bg) 80%,transparent);line-height:1.5}.__P__-toolui-collapse-body>.__P__-form>.__P__-field{gap:var(--__P__-space-2)}.__P__-toolui-summary>.__P__-field{gap:var(--__P__-space-1)}.__P__-toolui-summary .__P__-field-label{color:var(--__P__-fg-muted)}.__P__-toolui-answer{margin:0;font-size:var(--__P__-text-sm);color:var(--__P__-fg-muted);overflow-wrap:anywhere;white-space:pre-wrap}.__P__-toolui-footer{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);margin-inline:calc(-1 * var(--__P__-space-4));padding:var(--__P__-space-3) var(--__P__-space-4) 0;border-top:1px solid var(--__P__-border)}.__P__-toolui-options-toggle{display:inline-flex;align-items:center;gap:4px;border:0;background:transparent;padding:0;cursor:pointer;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);transition:color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-toolui-options-toggle:hover{color:var(--__P__-fg)}.__P__-toolui-options-chevron{display:inline-flex;transition:transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-toolui-options-chevron svg{width:14px;height:14px}.__P__-toolui-options-chevron.__P__-open{transform:rotate(180deg)}.__P__-toolui-desc{margin:0;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);border:1px solid var(--__P__-border);color:var(--__P__-fg-muted);line-height:1.5}.__P__-toolui-section{display:flex;flex-direction:column;gap:8px;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);border:1px solid var(--__P__-border)}.__P__-toolui:not(.__P__-toolui-collapsible) .__P__-toolui-section,.__P__-toolui:not(.__P__-toolui-collapsible) .__P__-toolui-desc{padding:0;background:none;border:0;border-radius:0}.__P__-toolui-label{font-size:var(--__P__-text-xs);font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--__P__-fg-muted)}.__P__-toolui-code{margin:0;max-height:240px;overflow:auto;color:var(--__P__-fg);font-family:var(--__P__-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);font-size:var(--__P__-text-xs);line-height:1.5;white-space:pre-wrap;word-break:break-word}.__P__-toolui-code[data-error=true]{color:var(--__P__-danger, #dc2626)}.__P__-toolui-body{gap:6px}.__P__-toolui-prompt{margin:0;font-weight:600;color:var(--__P__-fg);overflow-wrap:anywhere}.__P__-toolui-subtle{margin:0;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);line-height:1.5}.__P__-toolui-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}:host([dir="rtl"]) .__P__-icon-dir{transform:scaleX(-1)}:host([dir="rtl"]) .__P__-field-input[type=date],:host([dir="rtl"]) .__P__-field-input[type=time]{position:relative;text-align:right;padding-left:34px}:host([dir="rtl"]) .__P__-field-input[type=date]::-webkit-datetime-edit,:host([dir="rtl"]) .__P__-field-input[type=time]::-webkit-datetime-edit{text-align:right}:host([dir="rtl"]) .__P__-field-input[type=date]::-webkit-calendar-picker-indicator,:host([dir="rtl"]) .__P__-field-input[type=time]::-webkit-calendar-picker-indicator{position:absolute;left:var(--__P__-space-3);margin:0}
7
7
 
8
8
  .__P__-generative-ui{display:grid;gap:var(--__P__-space-3);overflow-wrap:anywhere;white-space:pre-wrap}.__P__-generative-ui p{margin:0}.__P__-generative-ui-grid-container{container:__P__-generative-ui-grid / inline-size;min-width:0}.__P__-generative-ui-grid{display:grid;grid-template-columns:minmax(0,1fr);align-items:start;gap:16px}.__P__-generative-ui-cell{display:grid;align-content:start;min-width:0;gap:16px}@container __P__-generative-ui-grid (min-width: 496px){.__P__-generative-ui-grid:is([data-columns="2"],[data-columns="3"],[data-columns="4"]){grid-template-columns:repeat(2,minmax(0,1fr))}.__P__-generative-ui-grid:is([data-columns="2"],[data-columns="3"],[data-columns="4"])>.__P__-generative-ui-cell:is([data-span="2"],[data-span="3"],[data-span="4"]){grid-column:span 2}}@container __P__-generative-ui-grid (min-width: 752px){.__P__-generative-ui-grid:is([data-columns="3"],[data-columns="4"]){grid-template-columns:repeat(3,minmax(0,1fr))}.__P__-generative-ui-grid:is([data-columns="3"],[data-columns="4"])>.__P__-generative-ui-cell:is([data-span="3"],[data-span="4"]){grid-column:span 3}}@container __P__-generative-ui-grid (min-width: 1008px){.__P__-generative-ui-grid[data-columns="4"]{grid-template-columns:repeat(4,minmax(0,1fr))}.__P__-generative-ui-grid[data-columns="4"]>.__P__-generative-ui-cell[data-span="4"]{grid-column:span 4}}.__P__-generative-ui section{display:grid;gap:var(--__P__-space-2);padding:var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);min-width:0}.__P__-generative-ui-metric{font-size:1.6em;font-weight:700}.__P__-generative-ui-table{overflow-x:auto}.__P__-generative-ui table{width:100%;border-collapse:collapse;white-space:normal}.__P__-generative-ui caption{text-align:start;font-weight:600;padding-bottom:var(--__P__-space-2)}.__P__-generative-ui th,.__P__-generative-ui td{text-align:start;padding:var(--__P__-space-2);border-bottom:1px solid var(--__P__-border)}.__P__-generative-ui-chart{display:block;width:100%;color:var(--__P__-accent)}.__P__-generative-ui-axis{stroke:var(--__P__-border)}.__P__-generative-ui-data{display:flex;flex-wrap:wrap;gap:var(--__P__-space-2);font-size:.85em}
9
9
 
@@ -53,11 +53,11 @@ import{useEffect as e,useMemo as t,useRef as n,useSyncExternalStore as r}from"re
53
53
  `)]}function Zo(e,{cssPrefix:t,strings:n}){let r=[],i;return{...fa(e),set_attr(e,a,o){if(a!==4||o!==`openui`||e.index!==1)return ga(e,a,o);let s=document.createElement(`div`);e.nodes[e.index]?.parentElement?.replaceWith(s),i={textSig:H(``),doneSig:H(!1)},r.push(s),yt(U(Qo,{cssPrefix:t,textSig:i.textSig,doneSig:i.doneSig,strings:n}),s)},add_text(e,t){i?i.textSig.value=i.textSig.peek()+t:ha(e,t)},end_token(e){i&&(i.doneSig.value=!0,i=void 0),ma(e)},finish(){i&&(i.doneSig.value=!0)},dispose(){for(let e of r)yt(null,e);r.length=0,i=void 0}}}function Qo({textSig:e,doneSig:t,cssPrefix:n,strings:r}){let i=B(()=>{let n=qo();return ri(()=>Jo(n.set(e.value,t.value),!t.value))},[e,t]);return i.value.error?U(`div`,{role:`alert`,children:r.visualError}):U(`div`,{class:`${n}-generative-ui`,"aria-busy":!t.value,children:[i.value.elements.map(e=>U($o,{element:e,cssPrefix:n},e.statementId)),i.value.partial&&U(`p`,{role:`status`,children:r.visualPartial}),i.value.elements.length===0&&!t.value?U(`span`,{role:`status`,children:r.visualPreparing}):null]})}function $o({element:e,cssPrefix:t}){if(e.typeName===`Grid`)return U(`div`,{class:`${t}-generative-ui-grid-container`,children:U(`div`,{class:`${t}-generative-ui-grid`,"data-columns":e.props.columns,children:e.props.children.map(e=>U(`div`,{class:`${t}-generative-ui-cell`,"data-span":e.typeName===`Cell`?e.props.span??1:1,children:e.typeName===`Cell`?e.props.children.map(e=>U($o,{element:e,cssPrefix:t},e.statementId)):U($o,{element:e,cssPrefix:t})},e.statementId))})});switch(e.typeName){case`Text`:return U(`p`,{children:e.props.text});case`Card`:return U(`section`,{children:[U(`strong`,{children:e.props.title}),U(`p`,{children:e.props.body})]});case`Metric`:return U(`section`,{children:[U(`strong`,{children:e.props.label}),U(`span`,{class:`${t}-generative-ui-metric`,children:e.props.value}),e.props.detail&&U(`p`,{children:e.props.detail})]});case`Table`:return U(`section`,{children:U(`div`,{class:`${t}-generative-ui-table`,children:U(`table`,{children:[U(`caption`,{children:e.props.title}),U(`thead`,{children:U(`tr`,{children:e.props.columns.map((e,t)=>U(`th`,{scope:`col`,children:e},t))})}),U(`tbody`,{children:e.props.rows.map((e,t)=>U(`tr`,{children:e.map((e,t)=>U(`td`,{children:e},t))},t))})]})})});case`Chart`:return U(es,{element:e,cssPrefix:t})}}function es({element:e,cssPrefix:t}){let n=Math.min(0,...e.props.data.map(e=>e.value)),r=Math.max(0,...e.props.data.map(e=>e.value))-n||1,i=148+n/r*136,a=e.props.data.map((t,i)=>({x:24+(i+.5)*272/e.props.data.length,y:148-(t.value-n)/r*136}));return U(`section`,{children:[U(`strong`,{children:e.props.title}),U(`svg`,{class:`${t}-generative-ui-chart`,viewBox:`0 0 320 168`,role:`img`,"aria-label":`${e.props.title}. ${e.props.data.map(e=>`${e.label}: ${e.value}`).join(`, `)}`,children:[U(`line`,{class:`${t}-generative-ui-axis`,x1:24,x2:296,y1:i,y2:i}),e.props.type===`line`&&U(`polyline`,{points:a.map(e=>`${e.x},${e.y}`).join(` `),fill:`none`,stroke:`currentColor`,"stroke-width":3}),a.map((t,n)=>e.props.type===`bar`?U(`rect`,{x:t.x-96/e.props.data.length,y:Math.min(t.y,i),width:192/e.props.data.length,height:Math.abs(t.y-i),fill:`currentColor`},n):U(`circle`,{cx:t.x,cy:t.y,r:3,fill:`currentColor`},n))]}),U(`div`,{class:`${t}-generative-ui-data`,children:e.props.data.map((e,t)=>U(`span`,{children:[e.label,`: `,e.value]},t))})]})}function ts(e){if(!e.includes("```openui"))return e;let t=``,n=0,r=0,i=0,a=0,o;function s(r){o?.language===`openui`&&(t+=e.slice(n,o.start)+Yo(o.source)+(e[r-1]===`
54
54
  `?`
55
55
  `:``),n=r),o=void 0}let c=$i({data:void 0,add_token(e,t){a+=1,t===10&&a===1&&(o={start:i,source:``,language:``})},set_attr(e,t,n){o&&t===4&&(o.language=n)},add_text(e,t){o&&(o.source+=t)},end_token(){o&&s(Math.min(r+1,e.length)),--a}});for(;r<e.length;r++)da(c,e.charAt(r)),e[r]===`
56
- `&&(i=r+1);return ea(c),o&&s(e.length),t+e.slice(n)}function ns(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function rs(e){return`tool-${e.startsWith(`tool:`)?e.slice(5):e}`}function is(e){return e.startsWith(`tool-`)?e.slice(5):e}const as={handshake:`/pai/handshake`,streamMessage:`/pai/stream-message`,streamResume:`/pai/stream-resume`,cancelStream:`/pai/cancel-stream`,listConversations:`/pai/list-conversations`,listMessages:`/pai/list-messages`,updateSettings:`/pai/update-settings`,markRead:`/pai/mark-read`,messageFeedback:`/pai/message-feedback`,requestOperator:`/pai/request-operator`,cancelOperatorRequest:`/pai/cancel-request-operator`,bootstrap:`/pai/bootstrap`,content:`/pai/content`,contentCollections:`/pai/content/collection/list`,contentVoteSet:`/pai/content/vote/set`,submitForm:`/pai/submit-form`},os=`context`;function ss(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cs(e){if(!ss(e))return;let t=e,n=t.controlMode,r=t.controlRevision;if(!(n!==`ai-agent`&&n!==`awaiting-operator`&&n!==`operator`||typeof r!=`number`||!Number.isSafeInteger(r)||r<0))return{controlMode:n,controlRevision:r,assignedOperatorInitials:typeof t.assignedOperatorInitials==`string`&&t.assignedOperatorInitials?t.assignedOperatorInitials:void 0,operatorAvailable:typeof t.operatorAvailable==`boolean`?t.operatorAvailable:void 0}}function ls(e){if(!ss(e))return;let t=e.status,n=e.postFinishSequence;if(!(t!==`compacting`&&t!==`ready`||typeof n!=`number`||!Number.isSafeInteger(n)||n<0))return{status:t,postFinishSequence:n}}function us(e){let t=ss(e)?e.suggestions:void 0;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!ss(e))continue;let{id:t,label:r,text:i}=e;typeof r==`string`&&r&&n.push({id:typeof t==`string`&&t?t:`s${n.length}`,label:r,text:typeof i==`string`&&i?i:r})}return n}function ds(e){let t={messages:e.messages.map(e=>({id:e.serverMessageId??e.id,parts:ps(e),role:e.role})),conversationId:e.conversationId,responseType:`ack`};return e.visitorId&&(t.visitorId=e.visitorId),e.userPrefs&&(t.userPrefs=e.userPrefs),e.clientTools?.length&&(t.clientTools=e.clientTools),t}function fs(e){return e.state===`output-available`||e.state===`output-error`||e.state===`output-denied`||e.approval?.approved!==void 0}function ps(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`&&fs(n)){let e=n.dynamic?{type:`dynamic-tool`,toolName:n.toolName,toolCallId:n.toolCallId,state:n.state}:{type:rs(n.toolName),toolCallId:n.toolCallId,state:n.state};n.input!==void 0&&(e.input=n.input),n.output!==void 0&&(e.output=n.output),n.error!==void 0&&(e.errorText=n.error),n.approval?.approved!==void 0&&(e.approval=n.approval),n.toolMetadata&&(e.toolMetadata=n.toolMetadata),t.push(e)}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}function ms(e,t,n=Fn()){let r=e?[{kind:`text`,id:`t0`,textSig:H(e),doneSig:H(!0)}]:[];return{id:n,role:`user`,createdAt:Date.now(),status:`complete`,attachments:t,partsSig:H(r)}}function hs(){return{id:Fn(),role:`assistant`,createdAt:Date.now(),status:`streaming`,partsSig:H([])}}function gs(e){let t=Fn();return _s({id:t,role:e.role,createdAt:Date.now(),status:`complete`,ephemeral:!0,parts:[{kind:`text`,id:`${t}-t0`,text:e.text,done:!0}]})}function _s(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($s))}}function vs(e){return e.status===`failed`?`error`:e.role===`assistant`&&e.status===`streaming`?`streaming`:`complete`}function ys(e){let t=/* @__PURE__ */ new Set,n=e.parts.map((t,n)=>t.type===`text`?{kind:`text`,id:`${e.id}-t${n}`,textSig:H(t.text),doneSig:H(!0)}:t.type===`reasoning`?{kind:`reasoning`,id:`${e.id}-r${n}`,textSig:H(t.text),doneSig:H(t.state!==`streaming`)}:t.type===`step-start`?{kind:`step-start`,id:`${e.id}-ss${n}`}:t.type===`file`?{kind:`file`,url:t.url,mediaType:t.mediaType}:t.type===`source-url`?{kind:`source`,sourceId:t.sourceId,url:t.url,title:t.title}:t.type===`source-document`?{kind:`source`,sourceId:t.sourceId,title:t.title,filename:t.filename,mediaType:t.mediaType}:t.type===`data-suggestions`?null:t.type===`dynamic-tool`||t.type.startsWith(`tool-`)?{kind:`tool`,toolCallId:t.toolCallId,toolName:t.type===`dynamic-tool`?t.toolName:is(t.type),dynamic:t.type===`dynamic-tool`||void 0,toolMetadata:t.toolMetadata,inputPartialSig:H(``),inputSig:H(t.input),outputSig:H(t.output),errorSig:H(t.errorText),stateSig:H(t.state),approvalSig:H(t.approval)}:null).filter(e=>e!==null).filter(e=>e.kind!==`source`||!t.has(e.sourceId)&&(t.add(e.sourceId),!0)),r=e.parts.find(e=>e.type===`data-suggestions`);return{id:e.id,role:e.role,operatorInitials:e.operatorInitials,suggestions:r?.type===`data-suggestions`?us(r.data):void 0,serverMessageId:e.id,createdAt:Date.parse(e.createdAt),status:vs(e),canceled:e.status===`canceled`,feedback:e.feedback??null,partsSig:H(n)}}function bs(e){return!e.parts.some(e=>e.type===`text`&&e.text.trim()!==``||e.type===`dynamic-tool`||e.type.startsWith(`tool-`)||e.type===`file`||e.type===`source-url`||e.type===`source-document`)}function xs(e){return e.role===`assistant`&&e.status===`streaming`&&bs(e)}function Ss(e){let t=e.length-1;return e.filter((e,n)=>n===t||!xs(e)).map(ys)}function Cs(e,t){let n=!t&&e.at(-1)?.role===`assistant`?-2:-1,r=e.at(n);return!r||r.ephemeral?[]:[r]}function ws(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(ec)}}function Ts(e){let t=``;for(let n of e.partsSig.value)n.kind===`text`&&(t+=n.textSig.value);return t}function Es(e,t,n,r,i,a=t.createdAt){let o=e.find(e=>e.role===`user`&&!e.ephemeral);function s(e,t){return(e.role===`assistant`?ts(Ts(e)):Ts(e)).replace(/\s+/g,` `).trim().slice(0,t)}let c=o?s(o,80):``,l=s(t,120);return{conversationId:n,title:c||r,lastMessageAt:new Date(a).toISOString(),preview:l||void 0,canContinue:i}}function Ds(e){return Ts(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`||e.kind===`source`)}function Os(e){return Ts(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`)}function ks(e){return e===`approval-responded`||e===`output-available`||e===`output-denied`||e===`output-error`}function As(e){return e.kind===`tool`}function js(e){return e.kind===`text`&&e.textSig.value.trim()!==``||e.kind===`file`}function Ms(e){let t=e.partsSig.value,n=t.findLastIndex(e=>e.kind===`tool`);return t.slice(n+1).some(js)}function Ns(e){if(e.role!==`assistant`)return!1;let t=e.partsSig.value.filter(As);return t.length>0&&t.every(e=>ks(e.stateSig.value))}function Ps(e){return e.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`)&&!Ms(e)}function Fs(e,t){return!e.partsSig.value.slice(t+1).some(e=>e.kind===`step-start`||js(e))}function Is(e){return e.partsSig.value.some(e=>As(e)&&!ks(e.stateSig.value))}function Ls(e,t){if(t.length===0)return e;let n=/* @__PURE__ */ new Set;for(let t of e)n.add(t.id),t.serverMessageId&&n.add(t.serverMessageId);let r=t.filter(e=>{let t=[e.id,e.serverMessageId].filter(e=>e!==void 0);return!t.some(e=>n.has(e))&&(t.forEach(e=>n.add(e)),!0)});if(r.length===0)return e;let i=e.findIndex(e=>!e.ephemeral),a=i<0?e.length:i;return[...e.slice(0,a),...r,...e.slice(a)]}function Rs(e,t){return t.id=e.id,e.canceled&&(t.canceled=!0),e.feedback!==void 0&&(t.feedback=e.feedback),t.suggestions??(t.suggestions=e.suggestions),t}function zs(e,t,n,r){if(!Bs(e))return;if(t.length===0){let t=Math.max(...r.values());return n.find(n=>n.role===`assistant`&&r.get(n.serverMessageId??n.id)===t&&Ts(n).length>=Ts(e).length)}let i=t.at(-1);if(i?.role!==`user`)return;let a=r.get(i.serverMessageId??i.id);if(a!==void 0)return n.find(t=>t.role===`assistant`&&r.get(t.serverMessageId??t.id)===a+1&&Ts(t).length>=Ts(e).length)}function Bs(e){return e?.role===`assistant`&&e.status===`streaming`&&e.serverMessageId===void 0}function Vs(e,t){let n=new Map(t.partsSig.value.filter(As).filter(e=>ks(e.stateSig.value)).map(e=>[e.toolCallId,e]));if(n.size===0)return;let r=!1,i=e.partsSig.value.map(e=>{if(!As(e))return e;let t=n.get(e.toolCallId);if(!t)return e;let i=e.approvalSig.value,a=t.approvalSig.value,o=i===void 0||i.approved===void 0&&a?.approved!==void 0?t.approvalSig:e.approvalSig,s=e.inputSig.value===void 0?t.inputSig:e.inputSig,c=e.toolName===`tool`?t.toolName:e.toolName,l=e.dynamic??t.dynamic;return o===e.approvalSig&&s===e.inputSig&&c===e.toolName&&l===e.dynamic?e:(r=!0,{...e,toolName:c,dynamic:l,inputSig:s,approvalSig:o})});r&&(e.partsSig.value=i)}function Hs(e,t){let n=t.filter(e=>!e.ephemeral&&(e.status===`streaming`||e.status===`pending`||e.status===`error`||e.retryAction!==void 0||(e.attachments?.length??0)>0||Ds(e))),r=/* @__PURE__ */ new Map;for(let e of n)r.set(e.id,e),e.serverMessageId!==void 0&&r.set(e.serverMessageId,e);let i=/* @__PURE__ */ new Set,a=[],o=e.map(e=>{let t=(e.serverMessageId===void 0?void 0:r.get(e.serverMessageId))??r.get(e.id);return t===void 0?(a.push(e),e):(i.add(t),t.role===e.role?t.role===`user`&&t.serverMessageId===void 0&&(t.status===`pending`||t.status===`error`)?Rs(t,e):t.status===`streaming`||Ts(t).length>=Ts(e).length?(Vs(t,e),t.suggestions??(t.suggestions=e.suggestions),t.feedback===void 0&&(t.feedback=e.feedback),e.canceled&&(t.canceled=!0),t):Rs(t,e):e)}),s=n.filter(e=>!i.has(e)),c=s.findLast(Bs),l=/* @__PURE__ */ new Map;e.forEach((e,t)=>{l.set(e.id,t),e.serverMessageId!==void 0&&l.set(e.serverMessageId,t)});let u=zs(c,c?n.slice(0,n.indexOf(c)):[],a,l);if(c&&u){let e=o.indexOf(u);e>=0&&(o[e]=Rs(c,u)),s=s.filter(e=>e!==c)}return[...o,...s]}function Us(e,t){let n=new Map(t.filter(e=>e.serverMessageId!==void 0).map(e=>[e.serverMessageId,e])),r=/* @__PURE__ */ new Map;t.forEach((e,t)=>{r.set(e.id,t),e.serverMessageId!==void 0&&r.set(e.serverMessageId,t)});let i=new Set(e.flatMap(e=>[e.serverMessageId,e.id].filter(e=>e!==void 0))),a=!1,o=e.map(e=>{let t=n.get(e.serverMessageId??e.id);if(t===void 0||t.role!==e.role)return e;if(e.role===`user`&&e.serverMessageId===void 0)return a=!0,Rs(e,t);if(e.serverMessageId===void 0)return e;let r=Ts(t),i=Ts(e),o=t.status!==`streaming`&&r.length>=i.length&&Js(e,t);if(r.length>i.length||r===i&&t.partsSig.value.length>e.partsSig.value.length||o)return a=!0,Rs(e,t);if(e.status===`streaming`&&t.status!==`streaming`&&Gs(e,t)){if(e.continuationStreaming&&Is(t))return e;if(!Js(t,e))return a=!0,Rs(e,t)}return e}),s=[...n.values()].filter(e=>!i.has(e.serverMessageId)),c=o.findLastIndex(Bs),l=o[c],u=zs(l,o.slice(0,c),s,r);if(l!==void 0&&u!==void 0&&Ts(u).length>=Ts(l).length&&(Rs(l,u),o[c]=u,s.splice(s.indexOf(u),1),a=!0),s.length===0)return{messages:a?o:e,changed:a};for(let e of s){let t=r.get(e.serverMessageId??e.id),n=!1,i=o.findIndex(e=>{let i=r.get(e.serverMessageId??e.id);return t===void 0?!1:i===void 0?n:i>t||(n=!0,!1)});i===-1?o.push(e):o.splice(i,0,e)}return{messages:o,changed:!0}}function Ws(e,t){if(e.role!==t.role)return!1;let n=Ts(t),r=Ts(e);return n.length>r.length||t.partsSig.value.length>e.partsSig.value.length||Js(e,t)}function Gs(e,t){let n=e.partsSig.value,r=t.partsSig.value;return n.length===r.length&&n.every((e,t)=>{let n=r[t];switch(e.kind){case`text`:return n?.kind===`text`&&n.textSig.value===e.textSig.value;case`reasoning`:return n?.kind===`reasoning`&&n.textSig.value===e.textSig.value;case`step-start`:return n?.kind===`step-start`;case`tool`:return n?.kind===`tool`&&n.toolCallId===e.toolCallId&&Ks(n.toolName,e.toolName);case`file`:return n?.kind===`file`&&n.url===e.url&&n.mediaType===e.mediaType;case`source`:return n?.kind===`source`&&n.sourceId===e.sourceId&&n.url===e.url&&n.title===e.title&&n.filename===e.filename&&n.mediaType===e.mediaType;default:return e}})}function Ks(e,t){return(e.startsWith(`tool:`)?e.slice(5):e)===(t.startsWith(`tool:`)?t.slice(5):t)}const qs={"input-streaming":0,"input-available":1,"approval-requested":2,"approval-responded":3,"output-available":4,"output-denied":4,"output-error":4};function Js(e,t){let n=new Map(e.partsSig.value.filter(As).map(e=>[e.toolCallId,e]));return t.partsSig.value.filter(As).some(e=>{let t=n.get(e.toolCallId);if(!t||qs[e.stateSig.value]>qs[t.stateSig.value])return!0;let r=e.approvalSig.value?.approved;return r!==void 0&&r!==t.approvalSig.value?.approved})}function Ys(e){return e.role===`assistant`&&e.status!==`streaming`&&!Ds(e)}function Xs(e,t){if(!e.includes(t)||t.retryAction===null)return;if(t.retryAction)return t.retryAction;if(t!==e.at(-1)||t.role!==`assistant`||t.serverMessageId===void 0||t.status!==`error`&&!Ys(t))return;let n=e.indexOf(t);for(let t=n-1;t>=0;t--){let n=e[t];if(n?.role===`user`&&!n.ephemeral)return{kind:`repeat-user`,messageId:n.id}}}function Zs(e){return e.canceled===!0&&e.role===`assistant`&&e.status!==`streaming`&&!Os(e)}function Qs(e,t){return e.operatorRoutedTurn?Ys(e)?`drop`:`complete-operator-routed`:t||Ys(e)?`error`:`complete`}function $s(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,dynamic:e.dynamic,toolMetadata:e.toolMetadata,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 ec(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,dynamic:e.dynamic,toolMetadata:e.toolMetadata,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}function tc(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function nc(e){return e&&Object.keys(e).length>0?e:void 0}function rc(e,t,n=[]){let r=nc(e),i=nc(t),a=Date.now();for(let e=n.length;;--e){let t=n.slice(n.length-e).map(({name:e,data:t,at:n})=>({name:e,data:t,secondsAgo:Math.round((a-n)/1e3)})),o=t.length>0?{...i,recentEvents:t}:i;if(!r&&!o)return;let s=tc(JSON.stringify({...r&&{user:r},...o&&{page:o}}));if(s.length<=8192||e===0)return s}}var ic=class extends Error{constructor(e,t,n,r){super(e),this.code=t,this.status=n,this.cause=r,this.name=`StreamError`}};const ac=C.scope(`parser`);async function*oc(e,t,n){if(!e.ok){let t=await e.text().catch(()=>``);throw new ic(`server responded ${e.status}: ${t.slice(0,200)}`,`server`,e.status)}for await(let r of sc(e,t)){let e=cc(r,n);if(e===`done`)return;e&&(yield e)}}async function*sc(e,t){if(!e.body)throw new ic(`response has no body`,`no-body`);let n=e.body.pipeThrough(new TextDecoderStream).getReader(),r=``;try{for(;;){if(t.aborted)throw new DOMException(`aborted`,`AbortError`);let{done:e,value:i}=await n.read();if(e){let e=r.trim();e&&(yield e);return}r+=i;let a;for(;(a=r.indexOf(`
56
+ `&&(i=r+1);return ea(c),o&&s(e.length),t+e.slice(n)}function ns(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function rs(e){return`tool-${e.startsWith(`tool:`)?e.slice(5):e}`}function is(e){return e.startsWith(`tool-`)?e.slice(5):e}const as={handshake:`/pai/handshake`,streamMessage:`/pai/stream-message`,streamResume:`/pai/stream-resume`,cancelStream:`/pai/cancel-stream`,listConversations:`/pai/list-conversations`,listMessages:`/pai/list-messages`,updateSettings:`/pai/update-settings`,markRead:`/pai/mark-read`,messageFeedback:`/pai/message-feedback`,requestOperator:`/pai/request-operator`,cancelOperatorRequest:`/pai/cancel-request-operator`,bootstrap:`/pai/bootstrap`,content:`/pai/content`,contentCollections:`/pai/content/collection/list`,contentVoteSet:`/pai/content/vote/set`,submitForm:`/pai/submit-form`},os=`context`;function ss(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cs(e){if(!ss(e))return;let t=e,n=t.controlMode,r=t.controlRevision;if(!(n!==`ai-agent`&&n!==`awaiting-operator`&&n!==`operator`||typeof r!=`number`||!Number.isSafeInteger(r)||r<0))return{controlMode:n,controlRevision:r,assignedOperatorInitials:typeof t.assignedOperatorInitials==`string`&&t.assignedOperatorInitials?t.assignedOperatorInitials:void 0,operatorAvailable:typeof t.operatorAvailable==`boolean`?t.operatorAvailable:void 0}}function ls(e){if(!ss(e))return;let t=e.status,n=e.postFinishSequence;if(!(t!==`compacting`&&t!==`ready`||typeof n!=`number`||!Number.isSafeInteger(n)||n<0))return{status:t,postFinishSequence:n}}function us(e){let t=ss(e)?e.suggestions:void 0;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!ss(e))continue;let{id:t,label:r,text:i}=e;typeof r==`string`&&r&&n.push({id:typeof t==`string`&&t?t:`s${n.length}`,label:r,text:typeof i==`string`&&i?i:r})}return n}function ds(e){let t={messages:e.messages.map(e=>({id:e.serverMessageId??e.id,parts:ps(e),role:e.role})),conversationId:e.conversationId,responseType:`ack`};return e.visitorId&&(t.visitorId=e.visitorId),e.userPrefs&&(t.userPrefs=e.userPrefs),e.clientTools?.length&&(t.clientTools=e.clientTools),t}function fs(e){return e.state===`output-available`||e.state===`output-error`||e.state===`output-denied`||e.approval?.approved!==void 0}function ps(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,filename:n.filename,fileId:n.fileId,fileSize:n.fileSize}),n.kind===`tool`&&fs(n)){let e=n.dynamic?{type:`dynamic-tool`,toolName:n.toolName,toolCallId:n.toolCallId,state:n.state}:{type:rs(n.toolName),toolCallId:n.toolCallId,state:n.state};n.input!==void 0&&(e.input=n.input),n.output!==void 0&&(e.output=n.output),n.error!==void 0&&(e.errorText=n.error),n.approval?.approved!==void 0&&(e.approval=n.approval),n.toolMetadata&&(e.toolMetadata=n.toolMetadata),t.push(e)}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}function ms(e,t,n=Fn()){let r=e?[{kind:`text`,id:`t0`,textSig:H(e),doneSig:H(!0)}]:[];return{id:n,role:`user`,createdAt:Date.now(),status:`complete`,attachments:t,partsSig:H(r)}}function hs(){return{id:Fn(),role:`assistant`,createdAt:Date.now(),status:`streaming`,partsSig:H([])}}function gs(e){let t=Fn();return _s({id:t,role:e.role,createdAt:Date.now(),status:`complete`,ephemeral:!0,parts:[{kind:`text`,id:`${t}-t0`,text:e.text,done:!0}]})}function _s(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($s))}}function vs(e){return e.status===`failed`?`error`:e.role===`assistant`&&e.status===`streaming`?`streaming`:`complete`}function ys(e){let t=/* @__PURE__ */ new Set,n=e.parts.map((t,n)=>t.type===`text`?{kind:`text`,id:`${e.id}-t${n}`,textSig:H(t.text),doneSig:H(!0)}:t.type===`reasoning`?{kind:`reasoning`,id:`${e.id}-r${n}`,textSig:H(t.text),doneSig:H(t.state!==`streaming`)}:t.type===`step-start`?{kind:`step-start`,id:`${e.id}-ss${n}`}:t.type===`file`?{kind:`file`,url:t.url,mediaType:t.mediaType,filename:t.filename,fileId:t.fileId,fileSize:t.fileSize}:t.type===`source-url`?{kind:`source`,sourceId:t.sourceId,url:t.url,title:t.title}:t.type===`source-document`?{kind:`source`,sourceId:t.sourceId,title:t.title,filename:t.filename,mediaType:t.mediaType}:t.type===`data-suggestions`?null:t.type===`dynamic-tool`||t.type.startsWith(`tool-`)?{kind:`tool`,toolCallId:t.toolCallId,toolName:t.type===`dynamic-tool`?t.toolName:is(t.type),dynamic:t.type===`dynamic-tool`||void 0,toolMetadata:t.toolMetadata,inputPartialSig:H(``),inputSig:H(t.input),outputSig:H(t.output),errorSig:H(t.errorText),stateSig:H(t.state),approvalSig:H(t.approval)}:null).filter(e=>e!==null).filter(e=>e.kind!==`source`||!t.has(e.sourceId)&&(t.add(e.sourceId),!0)),r=e.parts.find(e=>e.type===`data-suggestions`);return{id:e.id,role:e.role,operatorInitials:e.operatorInitials,suggestions:r?.type===`data-suggestions`?us(r.data):void 0,serverMessageId:e.id,createdAt:Date.parse(e.createdAt),status:vs(e),canceled:e.status===`canceled`,feedback:e.feedback??null,partsSig:H(n)}}function bs(e){return!e.parts.some(e=>e.type===`text`&&e.text.trim()!==``||e.type===`dynamic-tool`||e.type.startsWith(`tool-`)||e.type===`file`||e.type===`source-url`||e.type===`source-document`)}function xs(e){return e.role===`assistant`&&e.status===`streaming`&&bs(e)}function Ss(e){let t=e.length-1;return e.filter((e,n)=>n===t||!xs(e)).map(ys)}function Cs(e,t){let n=!t&&e.at(-1)?.role===`assistant`?-2:-1,r=e.at(n);return!r||r.ephemeral?[]:[r]}function ws(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(ec)}}function Ts(e){let t=``;for(let n of e.partsSig.value)n.kind===`text`&&(t+=n.textSig.value);return t}function Es(e,t,n,r,i,a=t.createdAt){let o=e.find(e=>e.role===`user`&&!e.ephemeral);function s(e,t){return(e.role===`assistant`?ts(Ts(e)):Ts(e)).replace(/\s+/g,` `).trim().slice(0,t)}let c=o?s(o,80):``,l=s(t,120);return{conversationId:n,title:c||r,lastMessageAt:new Date(a).toISOString(),preview:l||void 0,canContinue:i}}function Ds(e){return Ts(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`||e.kind===`source`)}function Os(e){return Ts(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`)}function ks(e){return e===`approval-responded`||e===`output-available`||e===`output-denied`||e===`output-error`}function As(e){return e.kind===`tool`}function js(e){return e.kind===`text`&&e.textSig.value.trim()!==``||e.kind===`file`}function Ms(e){let t=e.partsSig.value,n=t.findLastIndex(e=>e.kind===`tool`);return t.slice(n+1).some(js)}function Ns(e){if(e.role!==`assistant`)return!1;let t=e.partsSig.value.filter(As);return t.length>0&&t.every(e=>ks(e.stateSig.value))}function Ps(e){return e.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`)&&!Ms(e)}function Fs(e,t){return!e.partsSig.value.slice(t+1).some(e=>e.kind===`step-start`||js(e))}function Is(e){return e.partsSig.value.some(e=>As(e)&&!ks(e.stateSig.value))}function Ls(e,t){if(t.length===0)return e;let n=/* @__PURE__ */ new Set;for(let t of e)n.add(t.id),t.serverMessageId&&n.add(t.serverMessageId);let r=t.filter(e=>{let t=[e.id,e.serverMessageId].filter(e=>e!==void 0);return!t.some(e=>n.has(e))&&(t.forEach(e=>n.add(e)),!0)});if(r.length===0)return e;let i=e.findIndex(e=>!e.ephemeral),a=i<0?e.length:i;return[...e.slice(0,a),...r,...e.slice(a)]}function Rs(e,t){return t.id=e.id,e.canceled&&(t.canceled=!0),e.feedback!==void 0&&(t.feedback=e.feedback),t.suggestions??(t.suggestions=e.suggestions),t}function zs(e,t,n,r){if(!Bs(e))return;if(t.length===0){let t=Math.max(...r.values());return n.find(n=>n.role===`assistant`&&r.get(n.serverMessageId??n.id)===t&&Ts(n).length>=Ts(e).length)}let i=t.at(-1);if(i?.role!==`user`)return;let a=r.get(i.serverMessageId??i.id);if(a!==void 0)return n.find(t=>t.role===`assistant`&&r.get(t.serverMessageId??t.id)===a+1&&Ts(t).length>=Ts(e).length)}function Bs(e){return e?.role===`assistant`&&e.status===`streaming`&&e.serverMessageId===void 0}function Vs(e,t){let n=new Map(t.partsSig.value.filter(As).filter(e=>ks(e.stateSig.value)).map(e=>[e.toolCallId,e]));if(n.size===0)return;let r=!1,i=e.partsSig.value.map(e=>{if(!As(e))return e;let t=n.get(e.toolCallId);if(!t)return e;let i=e.approvalSig.value,a=t.approvalSig.value,o=i===void 0||i.approved===void 0&&a?.approved!==void 0?t.approvalSig:e.approvalSig,s=e.inputSig.value===void 0?t.inputSig:e.inputSig,c=e.toolName===`tool`?t.toolName:e.toolName,l=e.dynamic??t.dynamic;return o===e.approvalSig&&s===e.inputSig&&c===e.toolName&&l===e.dynamic?e:(r=!0,{...e,toolName:c,dynamic:l,inputSig:s,approvalSig:o})});r&&(e.partsSig.value=i)}function Hs(e,t){let n=t.filter(e=>!e.ephemeral&&(e.status===`streaming`||e.status===`pending`||e.status===`error`||e.retryAction!==void 0||(e.attachments?.length??0)>0||Ds(e))),r=/* @__PURE__ */ new Map;for(let e of n)r.set(e.id,e),e.serverMessageId!==void 0&&r.set(e.serverMessageId,e);let i=/* @__PURE__ */ new Set,a=[],o=e.map(e=>{let t=(e.serverMessageId===void 0?void 0:r.get(e.serverMessageId))??r.get(e.id);return t===void 0?(a.push(e),e):(i.add(t),t.role===e.role?t.role===`user`&&t.serverMessageId===void 0&&(t.status===`pending`||t.status===`error`)?Rs(t,e):t.status===`streaming`||Ts(t).length>=Ts(e).length?(Vs(t,e),t.suggestions??(t.suggestions=e.suggestions),t.feedback===void 0&&(t.feedback=e.feedback),e.canceled&&(t.canceled=!0),t):Rs(t,e):e)}),s=n.filter(e=>!i.has(e)),c=s.findLast(Bs),l=/* @__PURE__ */ new Map;e.forEach((e,t)=>{l.set(e.id,t),e.serverMessageId!==void 0&&l.set(e.serverMessageId,t)});let u=zs(c,c?n.slice(0,n.indexOf(c)):[],a,l);if(c&&u){let e=o.indexOf(u);e>=0&&(o[e]=Rs(c,u)),s=s.filter(e=>e!==c)}return[...o,...s]}function Us(e,t){let n=new Map(t.filter(e=>e.serverMessageId!==void 0).map(e=>[e.serverMessageId,e])),r=/* @__PURE__ */ new Map;t.forEach((e,t)=>{r.set(e.id,t),e.serverMessageId!==void 0&&r.set(e.serverMessageId,t)});let i=new Set(e.flatMap(e=>[e.serverMessageId,e.id].filter(e=>e!==void 0))),a=!1,o=e.map(e=>{let t=n.get(e.serverMessageId??e.id);if(t===void 0||t.role!==e.role)return e;if(e.role===`user`&&e.serverMessageId===void 0)return a=!0,Rs(e,t);if(e.serverMessageId===void 0)return e;let r=Ts(t),i=Ts(e),o=t.status!==`streaming`&&r.length>=i.length&&Js(e,t);if(r.length>i.length||r===i&&t.partsSig.value.length>e.partsSig.value.length||o)return a=!0,Rs(e,t);if(e.status===`streaming`&&t.status!==`streaming`&&Gs(e,t)){if(e.continuationStreaming&&Is(t))return e;if(!Js(t,e))return a=!0,Rs(e,t)}return e}),s=[...n.values()].filter(e=>!i.has(e.serverMessageId)),c=o.findLastIndex(Bs),l=o[c],u=zs(l,o.slice(0,c),s,r);if(l!==void 0&&u!==void 0&&Ts(u).length>=Ts(l).length&&(Rs(l,u),o[c]=u,s.splice(s.indexOf(u),1),a=!0),s.length===0)return{messages:a?o:e,changed:a};for(let e of s){let t=r.get(e.serverMessageId??e.id),n=!1,i=o.findIndex(e=>{let i=r.get(e.serverMessageId??e.id);return t===void 0?!1:i===void 0?n:i>t||(n=!0,!1)});i===-1?o.push(e):o.splice(i,0,e)}return{messages:o,changed:!0}}function Ws(e,t){if(e.role!==t.role)return!1;let n=Ts(t),r=Ts(e);return n.length>r.length||t.partsSig.value.length>e.partsSig.value.length||Js(e,t)}function Gs(e,t){let n=e.partsSig.value,r=t.partsSig.value;return n.length===r.length&&n.every((e,t)=>{let n=r[t];switch(e.kind){case`text`:return n?.kind===`text`&&n.textSig.value===e.textSig.value;case`reasoning`:return n?.kind===`reasoning`&&n.textSig.value===e.textSig.value;case`step-start`:return n?.kind===`step-start`;case`tool`:return n?.kind===`tool`&&n.toolCallId===e.toolCallId&&Ks(n.toolName,e.toolName);case`file`:return n?.kind===`file`&&n.url===e.url&&n.mediaType===e.mediaType;case`source`:return n?.kind===`source`&&n.sourceId===e.sourceId&&n.url===e.url&&n.title===e.title&&n.filename===e.filename&&n.mediaType===e.mediaType;default:return e}})}function Ks(e,t){return(e.startsWith(`tool:`)?e.slice(5):e)===(t.startsWith(`tool:`)?t.slice(5):t)}const qs={"input-streaming":0,"input-available":1,"approval-requested":2,"approval-responded":3,"output-available":4,"output-denied":4,"output-error":4};function Js(e,t){let n=new Map(e.partsSig.value.filter(As).map(e=>[e.toolCallId,e]));return t.partsSig.value.filter(As).some(e=>{let t=n.get(e.toolCallId);if(!t||qs[e.stateSig.value]>qs[t.stateSig.value])return!0;let r=e.approvalSig.value?.approved;return r!==void 0&&r!==t.approvalSig.value?.approved})}function Ys(e){return e.role===`assistant`&&e.status!==`streaming`&&!Ds(e)}function Xs(e,t){if(!e.includes(t)||t.retryAction===null)return;if(t.retryAction)return t.retryAction;if(t!==e.at(-1)||t.role!==`assistant`||t.serverMessageId===void 0||t.status!==`error`&&!Ys(t))return;let n=e.indexOf(t);for(let t=n-1;t>=0;t--){let n=e[t];if(n?.role===`user`&&!n.ephemeral)return{kind:`repeat-user`,messageId:n.id}}}function Zs(e){return e.canceled===!0&&e.role===`assistant`&&e.status!==`streaming`&&!Os(e)}function Qs(e,t){return e.operatorRoutedTurn?Ys(e)?`drop`:`complete-operator-routed`:t||Ys(e)?`error`:`complete`}function $s(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,dynamic:e.dynamic,toolMetadata:e.toolMetadata,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 ec(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,dynamic:e.dynamic,toolMetadata:e.toolMetadata,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}function tc(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function nc(e){return e&&Object.keys(e).length>0?e:void 0}function rc(e,t,n=[]){let r=nc(e),i=nc(t),a=Date.now();for(let e=n.length;;--e){let t=n.slice(n.length-e).map(({name:e,data:t,at:n})=>({name:e,data:t,secondsAgo:Math.round((a-n)/1e3)})),o=t.length>0?{...i,recentEvents:t}:i;if(!r&&!o)return;let s=tc(JSON.stringify({...r&&{user:r},...o&&{page:o}}));if(s.length<=8192||e===0)return s}}var ic=class extends Error{constructor(e,t,n,r){super(e),this.code=t,this.status=n,this.cause=r,this.name=`StreamError`}};const ac=C.scope(`parser`);async function*oc(e,t,n){if(!e.ok){let t=await e.text().catch(()=>``);throw new ic(`server responded ${e.status}: ${t.slice(0,200)}`,`server`,e.status)}for await(let r of sc(e,t)){let e=cc(r,n);if(e===`done`)return;e&&(yield e)}}async function*sc(e,t){if(!e.body)throw new ic(`response has no body`,`no-body`);let n=e.body.pipeThrough(new TextDecoderStream).getReader(),r=``;try{for(;;){if(t.aborted)throw new DOMException(`aborted`,`AbortError`);let{done:e,value:i}=await n.read();if(e){let e=r.trim();e&&(yield e);return}r+=i;let a;for(;(a=r.indexOf(`
57
57
 
58
58
  `))!==-1;){let e=r.slice(0,a);r=r.slice(a+2),yield e}}}finally{n.releaseLock()}}function cc(e,t){let n=``,r;for(let i of e.split(`
59
- `))if(i!==``){if(i.startsWith(`:`))t?.(i.slice(1).trim());else if(i.startsWith(`data:`)){let e=i.slice(5).replace(/^ /,``);n=n?`${n}\n${e}`:e}else i.startsWith(`id:`)&&(r=i.slice(3).trim())}if(n===`[DONE]`)return`done`;if(!n)return null;try{let e=JSON.parse(n);return ac.trace(`chunk`,{type:e.type,eventId:r}),{chunk:e,eventId:r}}catch(e){throw ac.trace(`frame parse failed`,{errorType:e instanceof Error?e.name:typeof e,payloadLength:n.length}),new ic(`invalid SSE frame`,`network`,void 0,e)}}const J=C.scope(`transport`),lc=6e4,uc=/* @__PURE__ */ new WeakMap;function dc(e){return uc.get(e)}function fc(e,t){return uc.set(e,t),e}function pc(e){return Math.max(e?.upsertRevision??0,e?.read?.revision??0)}function mc(e,t){return e.conversationId===t.conversationId&&e.title===t.title&&e.lastMessageAt===t.lastMessageAt&&e.preview===t.preview&&e.canContinue===t.canContinue&&e.hasUnread===t.hasUnread&&e.controlState===t.controlState}function hc(e,t,n=!0){switch(t.type){case`snapshot`:{let n=new Map(e.map(e=>[e.conversationId,e])),r=e.filter(e=>(dc(e)?.activityRevision??0)>t.requestedRevision).toSorted((e,t)=>dc(t).activityRevision-dc(e).activityRevision),i=new Set(r.map(e=>e.conversationId));return[...r,...t.result.conversations.filter(e=>!i.has(e.conversationId)).map(e=>{let r=n.get(e.conversationId);if(!r)return e;let i=dc(r);return(i?.upsertRevision??0)>t.requestedRevision?r:i?.read&&!r.hasUnread&&i.read.lastMessageAt===e.lastMessageAt?fc({...e,hasUnread:!1},{upsertRevision:0,read:i.read}):e})]}case`read`:{let n=e.findIndex(e=>e.conversationId===t.conversationId&&(t.lastMessageAt===void 0||e.lastMessageAt===t.lastMessageAt));if(n<0)return e;let r=e[n],i=dc(r);if(pc(i)>t.revision)return e;let a=t.lastMessageAt??r.lastMessageAt,o={upsertRevision:i?.upsertRevision??0,...i?.activityRevision===void 0?{}:{activityRevision:i.activityRevision},read:{revision:t.revision,...a?{lastMessageAt:a}:{}}};return r.hasUnread?e.map((e,t)=>t===n?fc({...e,hasUnread:!1},o):e):(fc(r,o),e)}case`upsert`:{let r=e.findIndex(e=>e.conversationId===t.conversation.conversationId);if(r<0&&!n)return e;let i=r<0?void 0:e[r],a=i?dc(i):void 0;if(pc(a)>t.revision)return e;let o=t.activity?t.revision:a?.activityRevision,s={upsertRevision:t.revision,...o===void 0?{}:{activityRevision:o},...!t.conversation.hasUnread&&a?.read?{read:a.read}:{}},c=i?{...i,...t.conversation,title:i.title}:{...t.conversation};return i&&mc(i,c)?(fc(i,s),e):(fc(c,s),t.activity?[c,...e.filter(e=>e.conversationId!==c.conversationId)]:i?e.map((e,t)=>t===r?c:e):[...e,c])}default:return t}}const gc=/* @__PURE__ */ new Set([408,425,429,500,502,503,504]);function _c(e){return 400*2**e+Math.floor(Math.random()*250)}function vc(e){return 6e4+Math.ceil(e/1048576)*15e3}function yc(e){let t=e.get(`retry-after`);if(!t)return null;let n=Number(t),r=Number.isFinite(n)?n*1e3:Date.parse(t)-Date.now();return Number.isFinite(r)&&r>=0?Math.min(r,3e4):null}var bc=class{constructor(e){this.ttlMs=e,s(this,`map`,/* @__PURE__ */ new Map)}getOrFetch(e,t){let n=this.map.get(e);if(n&&performance.now()-n.at<this.ttlMs)return n.result;let r={at:performance.now(),result:t().then(e=>(r.value=e,e)).catch(t=>{throw this.map.get(e)===r&&this.map.delete(e),t})};return this.map.set(e,r),r.result}peek(e){let t=this.map.get(e);if(t?.value!==void 0&&performance.now()-t.at<this.ttlMs)return t.value}update(e){for(let t of this.map.values())if(t.value!==void 0){let n=e(t.value);t.value=n,t.result=Promise.resolve(n)}else t.result=t.result.then(n=>{let r=e(n);return t.value=r,r})}delete(e){this.map.delete(e)}},xc=class{constructor(e){this.opts=e,s(this,`conversationListeners`,/* @__PURE__ */ new Set),s(this,`conversationRevision`,0),s(this,`visitorId`,void 0),s(this,`conversationId`,void 0),s(this,`userContext`,void 0),s(this,`pageContext`,void 0),s(this,`locale`,void 0),s(this,`userTokenSource`,void 0),s(this,`userToken`,void 0),s(this,`userTokenRequest`,void 0),s(this,`conversationsCache`,new bc(1e4)),s(this,`contentCache`,new bc(lc)),s(this,`contentCollectionsCache`,new bc(lc))}setUserToken(e){this.userTokenSource=e,this.userToken=typeof e==`string`&&e||void 0,this.userTokenRequest=typeof e==`function`?this.fetchUserToken():void 0}setContext(e,t){this.userContext=e,this.pageContext=t}setLocale(e){this.locale=e}primeIdentity(e,t){e&&(this.visitorId=e),t&&(this.conversationId=t)}envelope(){let e={_ev:Hn};this.visitorId&&(e.visitorId=this.visitorId),this.conversationId&&(e.conversationId=this.conversationId),this.locale&&(e.locale=this.locale);let t=rc(this.userContext,this.pageContext);return t&&(e[os]=t),e}withEnvelope(e){return{...this.envelope(),...e}}appendEnvelope(e){for(let[t,n]of Object.entries(this.envelope()))e.append(t,n);return e}withEnvelopeQuery(e){let t=new URL(this.url(e));for(let[e,n]of Object.entries(this.envelope()))t.searchParams.has(e)||t.searchParams.set(e,n);return t.toString()}async handshake(e){J.debug(`handshake →`,{visitorId:e.visitorId,conversationId:e.conversationId,locale:e.locale}),this.userTokenRequest&&await this.userTokenRequest;let t=await this.postJson(as.handshake,e,`handshake`);return J.debug(`handshake ←`,{visitorId:t.visitorId,conversationId:t.conversationId,hasWelcome:!!t.welcome,hasConfig:!!t.config,rebind:t.rebind}),this.visitorId=e.visitorId,this.conversationId=t.conversationId,t}async uploadFile(e,t){J.debug(`uploadFile →`,{name:e.name,size:e.size,type:e.type});let n=new FormData;n.append(`file`,e,e.name);let r=await this.postForm(this.uploadPath,n,`upload`,t,vc(e.size));return J.debug(`uploadFile ←`,{id:r.id,url:r.url}),r}async transcribe(e,t=`audio/webm`){J.debug(`transcribe →`,{size:e.size,mimeType:t});let n=new FormData;n.append(`audio`,e,`voice.${Sc(t)}`),n.append(`mimeType`,t);let r=await this.postForm(this.transcribePath,n,`transcribe`);return J.debug(`transcribe ←`,{textLen:r.text.length}),r}subscribeConversationChanges(e){return this.conversationListeners.add(e),()=>this.conversationListeners.delete(e)}publishConversation(e,t=!1){let n={type:`upsert`,conversation:e,revision:++this.conversationRevision,...t?{activity:!0}:{}};this.conversationsCache.update(r=>{let i=r.pagination.page===1,a=r.conversations.some(t=>t.conversationId===e.conversationId),o=hc(r.conversations,n,i&&t),s=i&&o.length>r.pagination.limit?o.slice(0,r.pagination.limit):o;if(!i||!t||a||r.pagination.hasNext)return s===r.conversations?r:{...r,conversations:s};let c=Math.max(r.pagination.total,r.conversations.length)+1,l=Math.ceil(c/r.pagination.limit);return{...r,conversations:s,pagination:{...r.pagination,total:c,totalPages:l,hasNext:r.pagination.page<l}}});for(let e of this.conversationListeners)e(n)}localeCacheKey(e){return`${this.locale??``}|${JSON.stringify(e,Object.keys(e).toSorted())}`}peekConversations(e={}){return this.conversationsCache.peek(this.localeCacheKey(e))}listConversations(e={},t=!1){if((e.page??1)>1)return this.fetchConversations(e);let n=this.localeCacheKey(e),r=this.conversationRevision;t&&this.conversationsCache.delete(n);let i=this.conversationsCache.getOrFetch(n,()=>this.fetchConversations(e));return t?i.then(e=>{let t={type:`snapshot`,result:e,requestedRevision:r};for(let e of this.conversationListeners)e(t);return e}):i}async fetchConversations(e){let t=new URL(this.url(as.listConversations));return e.visitorId&&t.searchParams.set(`visitorId`,e.visitorId),e.page&&t.searchParams.set(`page`,String(e.page)),e.limit&&t.searchParams.set(`limit`,String(e.limit)),e.ids?.length&&t.searchParams.set(`ids`,e.ids.join(`,`)),this.getJson(t.toString(),`listConversations`)}async loadConversation(e,{ids:t=[],beforeId:n,beforeCreatedAt:r}={}){let i=new URL(this.url(as.listMessages));i.searchParams.set(`conversationId`,e),i.searchParams.set(`limit`,`50`),t.length>0&&i.searchParams.set(`ids`,t.join(`,`)),n&&i.searchParams.set(`beforeId`,n),r&&i.searchParams.set(`beforeCreatedAt`,r);let a=await this.getJson(i.toString(),`loadConversation`);return{...a,messages:a.messages.toReversed()}}async markRead(e,t){if(!this.visitorId||!e)return;let n={type:`read`,conversationId:e,...t===void 0?{}:{lastMessageAt:t},revision:++this.conversationRevision};this.conversationsCache.update(e=>{let t=hc(e.conversations,n);return t===e.conversations?e:{...e,conversations:t}});for(let e of this.conversationListeners)e(n);try{await this.postJson(as.markRead,{conversationId:e},`markRead`,!0)}catch(e){J.debug(`markRead failed (non-fatal)`,{err:e})}}async requestOperator(){if(this.visitorId&&this.conversationId)try{return(await this.postJson(as.requestOperator,{},`requestOperator`)).controlState}catch(e){J.debug(`requestOperator failed (non-fatal)`,{err:e});return}}async cancelOperatorRequest(){if(this.visitorId&&this.conversationId)try{return(await this.postJson(as.cancelOperatorRequest,{},`cancelOperatorRequest`)).controlState}catch(e){J.debug(`cancelOperatorRequest failed (non-fatal)`,{err:e});return}}listContent(e={}){return this.contentCache.getOrFetch(this.localeCacheKey(e),()=>this.fetchContent(e))}async fetchContent(e){let t=new URL(this.dataUrl(as.content));for(let[n,r]of Object.entries(e))r!==void 0&&t.searchParams.set(n,Array.isArray(r)?r.join(`,`):String(r));let n=await this.getJson(t.toString(),`listContent`),r=n.items?.map(e=>xt(e,this.locale))??[];return{...n,items:r}}async setContentVote(e){try{await this.postJson(this.dataUrl(as.contentVoteSet),e,`setContentVote`)}catch{}}listContentCollections(e){return this.contentCollectionsCache.getOrFetch(this.localeCacheKey({ids:e}),()=>this.fetchContentCollections(e))}async fetchContentCollections(e){let t=new URL(this.dataUrl(as.contentCollections));return e.length&&t.searchParams.set(`ids`,e.join(`,`)),{items:(await this.getJson(t.toString(),`listContentCollections`)).items?.map(e=>St(e,this.locale))??[]}}async bootstrap(e){let t=new URL(this.dataUrl(as.bootstrap));e&&t.searchParams.set(`conversationId`,e);let n=await this.getJson(t.toString(),`bootstrap`);return{forms:n.forms??[],formSubmissions:n.formSubmissions??[]}}async saveUserPrefs(e){return this.postJson(as.updateSettings,{userPrefs:e},`saveUserPrefs`)}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??as.submitForm}async submitForm(e){J.debug(`submitForm →`,{formId:e.formId,trigger:e.trigger,fields:Object.keys(e.values).length});try{await this.postJson(this.dataUrl(this.submitFormPath),e,`submitForm`)}catch(e){J.debug(`submitForm failed (non-fatal)`,{err:e})}}async submitFeedback(e){J.debug(`submitFeedback →`,{messageId:e.messageId,value:e.value});try{await this.postJson(as.messageFeedback,{messageId:e.messageId,set:{feedback:e.value}},`submitFeedback`)}catch(e){J.debug(`submitFeedback failed (non-fatal)`,{err:e})}}async sendTurn(e,t={}){J.debug(`message →`,{conversationId:e.conversationId,visitorId:e.visitorId,messageCount:e.messages.length});let n=JSON.stringify({...this.withEnvelope(e),[os]:rc(this.userContext,this.pageContext,this.opts.recentHostEvents)}),r=t.keepalive===!0&&new Blob([n]).size<6e4;try{return await this.runWithAbort(async e=>{let t=await this.withFreshUserToken(()=>this.fetchImpl(this.url(as.streamMessage),{method:`POST`,credentials:`omit`,headers:{accept:`application/json`,"content-type":`application/json`,...this.headersFor(this.url(as.streamMessage))},body:n,keepalive:r,signal:e}));if(t.status!==202)throw new ic(`sendTurn failed: expected 202, received ${t.status}`,`server`,t.status);let i;try{i=await t.json()}catch(n){throw e?.aborted?n:new ic(`sendTurn failed: invalid acknowledgement`,`server`,t.status,n)}if(!Cc(i))throw new ic(`sendTurn failed: invalid acknowledgement`,`server`,t.status);return i},void 0,3e4)}catch(e){throw e instanceof ic?e:new ic(`sendTurn failed: network error`,`network`,void 0,e)}}cancelTurn(e,t){this.visitorId&&e&&t&&(J.debug(`cancel stream`,{conversationId:e,runId:t,visitorId:this.visitorId}),this.fetchImpl(this.url(as.cancelStream),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(as.cancelStream))},body:JSON.stringify(this.withEnvelope({conversationId:e,runId:t})),keepalive:!0}).catch(e=>J.debug(`cancel POST failed (non-fatal)`,{err:e})))}async connectResumeStream(e){let t=new AbortController;function n(){return t.abort(e.signal.reason)}e.signal.aborted?n():e.signal.addEventListener(`abort`,n,{once:!0});let r=setTimeout(()=>t.abort(),1e4);function i(){clearTimeout(r),e.signal.removeEventListener(`abort`,n)}let a;try{this.userTokenRequest&&await this.userTokenRequest,a=await this.fetchImpl(this.resumeUrl(),{method:`GET`,credentials:`omit`,headers:{accept:`text/event-stream`,...this.headersFor(this.resumeUrl())},signal:t.signal})}catch(t){return i(),e.signal.aborted||J.debug(`resume-stream fetch failed — reconnecting`,{err:t}),`held`}if(!a.ok)return i(),a.status===401&&typeof this.userTokenSource==`function`?(await this.fetchUserToken(),`held`):a.status===409||gc.has(a.status)?(J.debug(`resume-stream → transient response; reconnecting`,{status:a.status}),`held`):(J.debug(`resume-stream → endpoint unavailable`,{status:a.status}),`unavailable`);if(!a.body)return i(),J.debug(`resume-stream → bodyless response; stopping`,{status:a.status}),`unavailable`;if(!(a.headers.get(`content-type`)??``).includes(`text/event-stream`))return i(),J.debug(`resume-stream → non-SSE response; stopping`),`unavailable`;let o=!1;try{for await(let{chunk:n}of oc(a,t.signal,t=>{o||t!==`connected`||(o=!0,clearTimeout(r),e.onConnected())})){if(e.signal.aborted)return`held`;e.onChunk(n)}}catch(t){if(e.signal.aborted)return`held`;J.debug(`resume-stream segment dropped — reconnecting`,{err:t})}finally{i()}return`held`}resumeUrl(){return this.withEnvelopeQuery(as.streamResume)}async postJson(e,t,n,r=!1){let i=await this.fetchWithRetry(()=>[this.url(e),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(e))},body:JSON.stringify(this.withEnvelope(t)),...r?{keepalive:!0}:{}}],n);return this.assertOk(i,n)}async postForm(e,t,n,r,i){return this.runWithAbort(async r=>{let i=await this.withFreshUserToken(()=>this.fetchImpl(this.url(e),{method:`POST`,credentials:`omit`,headers:this.headersFor(this.url(e)),body:this.appendEnvelope(t),signal:r}));return this.assertOk(i,n)},r,i)}async runWithAbort(e,t,n){if(!t&&n===void 0)return e();let r=new AbortController;function i(){return r.abort(t?.reason)}t?.aborted?i():t?.addEventListener(`abort`,i,{once:!0});let a=n===void 0?void 0:setTimeout(()=>r.abort(),n);try{return await e(r.signal)}finally{a!==void 0&&clearTimeout(a),t?.removeEventListener(`abort`,i)}}async getJson(e,t){let n=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(e),{method:`GET`,credentials:`omit`,headers:{accept:`application/json`,...this.headersFor(this.url(e))}}],t);return this.assertOk(n,t)}async fetchWithRetry(e,t){for(let n=0;;n++){let r;try{r=await this.withFreshUserToken(()=>this.fetchImpl(...e()))}catch(e){if(n>=3)throw new ic(`${t} failed: network error`,`network`,void 0,e);J.debug(`request network error — retrying`,{label:t,attempt:n}),await ue(_c(n));continue}if(r.ok||!gc.has(r.status)||n>=3)return r;let i=yc(r.headers)??_c(n);J.debug(`request retryable status — retrying`,{label:t,status:r.status,attempt:n,wait:i}),await ue(i)}}async assertOk(e,t){if(!e.ok)throw new ic(`${t} failed: ${e.status}`,`server`,e.status);return await e.json()}fetchUserToken(){let e=this.userTokenSource;if(typeof e!=`function`)return Promise.resolve();let t=Promise.resolve().then(e).then(t=>{this.userTokenSource===e&&(this.userToken=t||void 0)},e=>{J.warn(`userToken function failed; continuing as an anonymous visitor`,{err:e})});return this.userTokenRequest=t,t}headersFor(e){let t=!/^https?:\/\//i.test(e)||e.startsWith(`${this.opts.agentApiBaseUrl}/`);return{...this.opts.auth.headers(),...t&&this.userToken?{"x-user-token":this.userToken}:{}}}async withFreshUserToken(e){let t=await e();return t.status!==401||!this.userTokenSource?t:typeof this.userTokenSource==`function`?(await this.fetchUserToken(),e()):(J.warn(`userToken rejected as invalid or expired; pass a function so the widget can fetch a fresh one`),t)}url(e){return/^https?:\/\//i.test(e)?e:`${this.opts.agentApiBaseUrl}${e}`}dataUrl(e){return/^https?:\/\//i.test(e)?e:`${this.opts.dataApiBaseUrl}${e}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function Sc(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 Cc(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`status`),n=Reflect.get(e,`conversationId`),r=Reflect.get(e,`runId`);return t===`accepted`&&typeof n==`string`&&n.length>0&&(r===void 0||typeof r==`string`&&r.length>0)}function wc(e,t,n){switch(e){case`clear`:case`sound`:case`history`:case`language`:case`theme`:case`textSize`:return!0;case`popOut`:return t!==`standalone`&&t!==`page`;case`expand`:return t===`floating`;case`fullscreen`:return t!==`standalone`;case`close`:return t===`standalone`||t===`page`?!1:t!==`inline`||n===`fullscreen`}}function Tc(e,t,n){return wc(`close`,e,t)?n.includes(`close`):!1}function Ec(e,t){return e===`inline`&&t===`fullscreen`?`exit-fullscreen`:`close`}function Dc(e,t,n,r){let i={role:n,text:r};e.emit(`message`,i),t.onMessage?.(i)}function Oc(e){let t=z(e);t.current=e;let n=z(null);return n.current??(n.current=kc(t)),n.current}function kc(e){let t=H(null),n=/* @__PURE__ */ new Set;function r(t){return`${e.current.conversationId()??``}:${t}`}function i(t){return t.frequency===`always`?!1:t.frequency===`conversation`?n.has(r(t.id)):t.id in e.current.persistence.loadFormsDone()}function a(n,r){if(t.value)return;let a=e.current;if(n===`manual`){let e=a.forms.list.find(e=>e.id===r);e&&(t.value={form:e,trigger:`manual`})}else for(let e of a.forms.byTrigger[n]??[]){let r=e.triggers.find(e=>e.kind===n);if(r&&Ac(r,a)&&!i(e)&&jc(e,a)){t.value={form:e,trigger:n};return}}}function o(i,a){let o=t.value;if(!o)return;t.value=null;let{form:s,trigger:c}=o;s.frequency===`conversation`?n.add(r(s.id)):s.frequency!==`always`&&e.current.persistence.saveFormDone(s.id),e.current.onComplete(s,c,i,a)}function s(){let n=t.value;if(!n)return;let r=e.current.forms.list.find(e=>e.id===n.form.id);r&&r!==n.form&&(t.value={form:r,trigger:n.trigger})}return{activeForm:t,fire:a,refresh:s,complete:e=>o(e,!1),skip:()=>o({},!0)}}function Ac(e,t){return e.kind===`after-messages`?t.messageCount()>=Number(e.param??0):e.kind!==`page-area`||t.pageArea()===e.param}function jc(e,t){let n=e.when;if(!n)return!0;if(n.missingContext?.length){let e=t.userContext()??{};if(n.missingContext.some(t=>e[t]!==void 0&&e[t]!==``))return!1}if(n.pageArea&&!(Array.isArray(n.pageArea)?n.pageArea:[n.pageArea]).includes(t.pageArea()??``))return!1;let r=t.messageCount();return!(n.minMessages!=null&&r<n.minMessages||n.maxMessages!=null&&r>n.maxMessages)}function Mc(e){return Object.fromEntries(e.map(e=>[e,[]]))}function Nc(e,t,n){return e.includes(t)?t:e.includes(n)?n:e[0]??``}function Pc(e,t,n){let r=[...new Set(t)],i=H({activeTab:Nc(r,e,``),stacks:Mc(r)});return{sig:i,reconcile(e,t){let a=[...new Set(e)],o=i.value,s=Nc(a,o.activeTab,t),c=Object.fromEntries(a.map(e=>[e,o.stacks[e]??[]])),l=s===o.activeTab&&a.length===Object.keys(o.stacks).length&&a.every(e=>o.stacks[e]===c[e]);r=a,!l&&(i.value={activeTab:s,stacks:c},s!==o.activeTab&&s&&n?.(s))},switchTab(e){e in i.value.stacks&&i.value.activeTab!==e&&(i.value={...i.value,activeTab:e},n?.(e))},open(e,t){let r=i.value;e in r.stacks&&(i.value={activeTab:e,stacks:{...r.stacks,[e]:t?[t]:[]}},r.activeTab!==e&&n?.(e))},push(e){let t=i.value,n=t.stacks[t.activeTab]??[];i.value={...t,stacks:{...t.stacks,[t.activeTab]:[...n,e]}}},pop(){let e=i.value,t=e.stacks[e.activeTab]??[];t.length!==0&&(i.value={...e,stacks:{...e.stacks,[e.activeTab]:t.slice(0,-1)}})},reset(e){i.value={activeTab:Nc(r,e,``),stacks:Mc(r)}}}}function Fc(e){return e.stacks[e.activeTab]??[]}function Ic(e){return Fc(e).at(-1)}function Lc(e){return Fc(e).length===0}function Rc(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`}function zc(e,t,n){if(e===`standalone`||e===`page`)return`fullscreen`;let r=t.initialSize;return r===`expanded`||r===`fullscreen`||r===`normal`?r:n>0&&n<640?`fullscreen`:n>=(t.autoSizeBreakpoint??900)?`expanded`:`normal`}function Bc(e,t,n,r=null){return{panelOpen:e.mode===`inline`||e.mode===`standalone`||e.mode===`page`||(n??!e.startMinimized),panelSize:e.mode!==`standalone`&&e.mode!==`page`&&e.mode!==`inline`&&r?r:zc(e.mode,e.size,t)}}function Vc(){return typeof window>`u`?0:window.innerWidth}const Y={fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`},Hc=`${u.cssPrefix}-icon-dir`;function Uc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z`})})}function Wc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M18 6 6 18M6 6l12 12`})})}function Gc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M12 5v14M5 12h14`})})}function Kc(){return/* @__PURE__ */ U(`svg`,{...Y,class:Hc,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m22 2-7 20-4-9-9-4Z`}),/* @__PURE__ */ U(`path`,{d:`M22 2 11 13`})]})}function qc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M12 19V5M5 12l7-7 7 7`})})}function Jc(){return/* @__PURE__ */ U(`svg`,{...Y,class:Hc,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 20V4l18 8-18 8Z`})})}function Yc(){return/* @__PURE__ */ U(`svg`,{...Y,class:Hc,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m9 18 6-6-6-6`})})}function Xc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}function Zc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`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`})})}function Qc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`rect`,{x:`9`,y:`2`,width:`6`,height:`12`,rx:`3`}),/* @__PURE__ */ U(`path`,{d:`M5 10a7 7 0 0 0 14 0M12 19v3`})]})}function $c(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5`})})}function el(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5`})})}function tl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z`})})}function nl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7`})})}function rl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M14 3h7v7M21 3l-9 9`}),/* @__PURE__ */ U(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`})]})}function il(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,viewBox:`0 0 10 10`,children:/* @__PURE__ */ U(`path`,{d:`M9 1L1 9M9 5L5 9M9 9H9`,strokeWidth:`1.5`})})}function al(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:`currentColor`,stroke:`none`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:`currentColor`,stroke:`none`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:`currentColor`,stroke:`none`})]})}function ol(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10`})})}function sl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6`})})}function cl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M3 18 8 6l5 12M4.7 14h6.6`}),/* @__PURE__ */ U(`path`,{d:`M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2`})]})}function ll(){return/* @__PURE__ */ U(`svg`,{...Y,class:Hc,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m5 6 6 6-6 6M13 6l6 6-6 6`})})}function ul(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M20 6 9 17l-5-5`})})}function dl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M3 3v6h6`}),/* @__PURE__ */ U(`path`,{d:`M3.05 13A9 9 0 1 0 6 5.3L3 9`}),/* @__PURE__ */ U(`path`,{d:`M12 7v5l3 2`})]})}function fl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ U(`path`,{d:`M2 12h20`}),/* @__PURE__ */ U(`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`})]})}function pl(){return/* @__PURE__ */ U(`svg`,{...Y,class:Hc,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})})}function ml(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M12 20h9`}),/* @__PURE__ */ U(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}function hl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m6 9 6 6 6-6`})})}function gl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z`}),/* @__PURE__ */ U(`path`,{d:`M14 2v6h6`})]})}function _l(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z`}),/* @__PURE__ */ U(`path`,{d:`M19 15v4M17 17h4M5 3v2M4 4h2`})]})}function vl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z`})})}function yl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ U(`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}),/* @__PURE__ */ U(`path`,{d:`M12 17h.01`})]})}function bl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m15 4 3 3-9 9-3-3z`}),/* @__PURE__ */ U(`path`,{d:`M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2`})]})}function xl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`rect`,{x:`4`,y:`8`,width:`16`,height:`12`,rx:`2`}),/* @__PURE__ */ U(`path`,{d:`M12 8V4`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`3`,r:`1`}),/* @__PURE__ */ U(`path`,{d:`M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5`})]})}function Sl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M4 14v-2a8 8 0 0 1 16 0v2`}),/* @__PURE__ */ U(`rect`,{x:`2`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),/* @__PURE__ */ U(`rect`,{x:`18`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),/* @__PURE__ */ U(`path`,{d:`M20 20v1a3 3 0 0 1-3 3h-5`})]})}function Cl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`4`}),/* @__PURE__ */ U(`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`})]})}function wl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`11`,cy:`11`,r:`7`}),/* @__PURE__ */ U(`path`,{d:`m21 21-4.3-4.3`})]})}function Tl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]})}function El(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M3 9.5 12 3l9 6.5`}),/* @__PURE__ */ U(`path`,{d:`M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9`})]})}function Dl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m3 11 15-5v12L3 13z`}),/* @__PURE__ */ U(`path`,{d:`M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z`}),/* @__PURE__ */ U(`path`,{d:`M7 15v3a2 2 0 0 0 4 0v-2`}),/* @__PURE__ */ U(`path`,{d:`M21 10a3 3 0 0 1 0 4`})]})}function Ol(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`}),/* @__PURE__ */ U(`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`})]})}function kl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`4`}),/* @__PURE__ */ U(`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`})]})}function Al(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`})})}function jl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`M12 3v18`}),/* @__PURE__ */ U(`path`,{d:`M12 3a9 9 0 0 1 0 18z`,fill:`currentColor`,stroke:`none`})]})}function Ml(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`10.5`,cy:`10.5`,r:`6.5`}),/* @__PURE__ */ U(`path`,{d:`M8 11a2.5 2.5 0 0 0 5 0`}),/* @__PURE__ */ U(`path`,{d:`m20 20-4.4-4.4`})]})}function Nl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`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`}),/* @__PURE__ */ U(`path`,{d:`M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5`})]})}function Pl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M4 18h16`}),/* @__PURE__ */ U(`path`,{d:`M5 18a7 7 0 0 1 14 0`}),/* @__PURE__ */ U(`path`,{d:`M12 8V6`}),/* @__PURE__ */ U(`path`,{d:`M10 6h4`})]})}function Fl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M7 11V6.5a1.5 1.5 0 0 1 3 0V10`}),/* @__PURE__ */ U(`path`,{d:`M10 10V5.5a1.5 1.5 0 0 1 3 0V10`}),/* @__PURE__ */ U(`path`,{d:`M13 10V6.5a1.5 1.5 0 0 1 3 0V12`}),/* @__PURE__ */ U(`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`})]})}function Il(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`rect`,{x:`9`,y:`9`,width:`11`,height:`11`,rx:`2`}),/* @__PURE__ */ U(`path`,{d:`M5 15a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2`})]})}function Ll(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M7 10v11H4a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1z`}),/* @__PURE__ */ U(`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`})]})}function Rl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M17 14V3h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1z`}),/* @__PURE__ */ U(`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`})]})}function zl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`3.5`}),/* @__PURE__ */ U(`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`})]})}function Bl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`M12 7v5l3 2`})]})}function Vl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]})}function Hl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`m15 9-6 6M9 9l6 6`})]})}const Ul={chat:Uc,message:vl,bubbles:Ol,spark:_l,wand:bl,bot:xl,help:yl,lifebuoy:Cl,headset:Sl,search:Ml,sparkles:Nl,concierge:Pl,wave:Fl},X=u.cssPrefix,Z={launcher:`${X}-launcher`,callout:`${X}-callout`,calloutDismiss:`${X}-callout-dismiss`,panel:`${X}-panel`,panelHeader:`${X}-panel-header`,resizeGrip:`${X}-resize-grip`,scrollToBottom:`${X}-scroll-to-bottom`,loadPreviousMessages:`${X}-load-previous-messages`,actionHistory:`${X}-action-history`,actionClose:`${X}-action-close`,langSegment:`${X}-lang-segment`,composer:`${X}-composer`,composerInput:`${X}-composer-input`,composerSend:`${X}-composer-send`,composerStop:`${X}-composer-stop`,compactionStatus:`${X}-compaction-status`,messageQueue:`${X}-message-queue`,queuedMessage:`${X}-queued-message`,queuedMessageRemove:`${X}-queued-message-remove`,composerAttach:`${X}-composer-attach`,composerFileInput:`${X}-composer-file-input`,composerVoice:`${X}-composer-voice`,attachmentChip:`${X}-attachment-chip`,attachmentRemove:`${X}-attachment-remove`,suggestion:`${X}-suggestion`,messageBubble:`${X}-message`,messageRetry:`${X}-message-retry`,messageFeedback:`${X}-message-feedback`,feedbackUp:`${X}-feedback-up`,feedbackDown:`${X}-feedback-down`,messageCopy:`${X}-message-copy`,historyPane:`${X}-history-pane`,historyBack:`${X}-history-back`,historyItem:`${X}-history-item`,historyLoadMore:`${X}-history-load-more`,sidebar:`${X}-sidebar`,sidebarToggle:`${X}-sidebar-toggle`,sidebarNewConversation:`${X}-sidebar-new-conversation`,sidebarItem:`${X}-sidebar-item`,messengerHome:`${X}-messenger-home`,modulesEmpty:`${X}-modules-empty`,tab:`${X}-tab`,tabBadge:`${X}-tab-badge`,homeView:`${X}-home-view`,homeGreeting:`${X}-home-greeting`,homeBrand:`${X}-home-brand`,backHeader:`${X}-back-header`,contentView:`${X}-content-view`,contentScroll:`${X}-content-scroll`,homeSearch:`${X}-home-search`,helpSearch:`${X}-help-search`,homeRecent:`${X}-home-recent`,homeAsk:`${X}-home-ask`,homeWhatsNew:`${X}-home-whats-new`,homeContentRow:`${X}-home-content-row`,helpArticle:`${X}-help-article`,newsItem:`${X}-news-item`,newsMore:`${X}-news-more`,formGate:`${X}-form-gate`,formDone:`${X}-form-done`,formDoneToggle:`${X}-form-done-toggle`,formAnswers:`${X}-form-answers`,formFill:`${X}-form-fill`,formSubmit:`${X}-form-submit`,formSkip:`${X}-form-skip`,formField:`${X}-form-field`,toolAskQuestions:`${X}-tool-ask-questions`,toolInputSubmit:`${X}-tool-input-submit`,toolInputSkip:`${X}-tool-input-skip`,toolApproval:`${X}-tool-approval`,toolApprove:`${X}-tool-approve`,toolReject:`${X}-tool-reject`,toolEdit:`${X}-tool-edit`,toolDecision:`${X}-tool-decision`,typingDots:`${X}-typing-dots`,reasoning:`${X}-reasoning`,toolAskSummary:`${X}-ask-questions-summary`,toolAskOptions:`${X}-ask-questions-options-toggle`,toolCall:`${X}-tool-call`,source:`${X}-source`,operatorRequest:`${X}-operator-request`,operatorBanner:`${X}-operator-banner`,cancelOperatorRequest:`${X}-cancel-operator-request`};function Wl(e,t){return`${e}-${t}`}const Gl=u.cssPrefix;function Kl({onToggle:e,launcher:t,strings:n,leaving:r,edgeTab:i}){let a=t.variant!==`circle`&&!!t.label;return/* @__PURE__ */ U(`button`,{type:`button`,class:`${Gl}-fab`,part:`launcher`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":i?`true`:void 0,"data-leaving":r?`true`:void 0,"data-testid":Z.launcher,onClick:e,"aria-label":n.launcherOpen,children:[ql(t.icon),a?/* @__PURE__ */ U(`span`,{class:`${Gl}-fab-label`,children:At(n,t.label??``)}):null]})}function ql(e){let t=Ul[e];return t?/* @__PURE__ */ U(t,{}):/* @__PURE__ */ U(Jl,{source:e})}function Jl({source:e}){return/* @__PURE__ */ U(`span`,{ref:t=>{t&&Yl(t,e)},"aria-hidden":`true`})}function Yl(e,t){if(e.dataset.svgMounted!==t)try{let n=new DOMParser().parseFromString(t,`image/svg+xml`).documentElement;n.tagName.toLowerCase()===`svg`&&(e.replaceChildren(document.importNode(n,!0)),e.dataset.svgMounted=t)}catch{}}function Xl({callout:e,launcherPosition:t,strings:n,closeLabel:r,onDismiss:i}){let[a,o]=L(!1);return R(()=>{let t=setTimeout(()=>o(!0),e.delayMs);return()=>clearTimeout(t)},[e.delayMs]),R(()=>{if(!a||e.autoDismissMs<=0)return;let t=setTimeout(i,e.autoDismissMs);return()=>clearTimeout(t)},[a,e.autoDismissMs,i]),a?/* @__PURE__ */ U(`div`,{class:`${Gl}-callout`,role:`status`,"data-shape":e.shape,"data-position":Zl(e.position,t),"data-animated":e.animated?`true`:void 0,"data-testid":Z.callout,children:[/* @__PURE__ */ U(`span`,{children:At(n,e.text)}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Gl}-callout-close`,onClick:i,"aria-label":r,title:r,"data-testid":Z.calloutDismiss,children:/* @__PURE__ */ U(Wc,{})})]}):null}function Zl(e,t){let n=t.endsWith(`-right`),r=t.startsWith(`bottom-`);return e===`vertical`?r?`top`:`bottom`:n?`left`:`right`}function Ql(e){function t(t){if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(`a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])`)].filter(e=>e.offsetParent!==null||e===document.activeElement);if(n.length===0){t.preventDefault();return}let r=n[0],i=n[n.length-1];if(!r||!i)return;let a=e.getRootNode().activeElement;t.shiftKey&&a===r?(t.preventDefault(),i.focus()):!t.shiftKey&&a===i&&(t.preventDefault(),r.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}const $l=u.cssPrefix;function eu({title:e,actions:t}){return/* @__PURE__ */ U(`header`,{class:`${$l}-back-header`,part:`header`,"data-variant":`title`,children:[/* @__PURE__ */ U(`span`,{class:`${$l}-back-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ U(`h1`,{class:`${$l}-back-title`,children:e}),t??/* @__PURE__ */ U(`span`,{class:`${$l}-back-spacer`,"aria-hidden":`true`})]})}function tu({title:e,backLabel:t,onBack:n,actions:r,testid:i}){return/* @__PURE__ */ U(`header`,{class:`${$l}-back-header`,part:`header`,"data-testid":i,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${$l}-icon-btn`,onClick:n,"aria-label":t,title:t,children:/* @__PURE__ */ U(pl,{})}),/* @__PURE__ */ U(`h1`,{class:`${$l}-back-title`,children:e}),r??/* @__PURE__ */ U(`span`,{class:`${$l}-back-spacer`,"aria-hidden":`true`})]})}function nu({textSig:e,doneSig:t,generativeUi:n=!1,strings:r=wt}){let i=z(null);return kr(()=>{let a=i.current;if(!a)return;a.classList.add(`${u.cssPrefix}-md`),a.replaceChildren();let o=n?Zo(a,{cssPrefix:u.cssPrefix,strings:r}):void 0,s=$i(o??fa(a)),c=0,l=ci(()=>{let i=e.value,l=t.value;i.length<c&&(o?.dispose(),a.replaceChildren(),o=n?Zo(a,{cssPrefix:u.cssPrefix,strings:r}):void 0,s=$i(o??fa(a)),c=0);let d=i.slice(c);d&&da(s,d),c=i.length,l&&(ea(s),o?.finish())}),d=new MutationObserver(()=>ou(a));d.observe(a,{childList:!0,subtree:!0}),ou(a);function f(e){let t=e.target?.closest?.(`a`);if(!t||!(t instanceof HTMLAnchorElement))return;let n=t.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))}return a.addEventListener(`click`,f),()=>{l(),o?.dispose(),d.disconnect(),a.removeEventListener(`click`,f)}},[e,t,n,r]),/* @__PURE__ */ U(`div`,{ref:i})}function ru({text:e}){return/* @__PURE__ */ U(nu,{textSig:B(()=>H(e),[e]),doneSig:B(()=>H(!0),[])})}const iu=/<(\/?)(?:(Note|Info|Tip|Warning|Danger|Check|Callout)|Tabs?|Steps?|AccordionGroup|Accordion|Expandable|Columns|CardGroup|Card|Frame|CodeGroup|Badge|Icon|Video|Embed|ParamField|ResponseField)\b((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>|(^|\n)([ \t]*)(```[^]*?(?:\n[ \t]*```|$))?/g;function au(e){let t=0,n=``;return e.replace(iu,(e,r,i,a,o,s,c,l)=>{if(r===void 0)return t?s+(l?.split(`\n${c}`).join(`
60
- `)??n):e;if(r)return t--,i&&(n=n.slice(2)),i?`\n${n}`:``;o||(t++,i&&(n+=`> `));let u={};a.replace(/(\w+)=(["'])(.*?)\2/g,(e,t,n,r)=>u[t]=r);let d=u.href??u.src,f=u.title??u.path??u.query??u.body??u.header??u.name??d;return(i?`> `:``)+(f?`**${d?`[${f}](${d})`:f}**${u.type?` \`${u.type}\``:``}\n${n}`:``)})}function ou(e){for(let t of e.querySelectorAll(`a`)){let e=t.getAttribute(`href`)??``;e&&!e.startsWith(`#`)&&(t.target=`_blank`,t.rel=`noopener noreferrer`)}}const su=/* @__PURE__ */ new Set([11,12,13,14,15,16,17,18,19,31]);function cu(e){let t=``,n=[],r=$i({data:void 0,add_token:(e,r)=>{n.push(r),su.has(r)||(t+=` `)},end_token:()=>{let e=n.pop();e!==void 0&&!su.has(e)&&(t+=` `)},add_text:(e,n)=>void(t+=n),set_attr:()=>void 0});return da(r,e),ea(r),t.replace(/\s+/g,` `).trim()}const lu=u.cssPrefix;function uu({tone:e=`info`,message:t,onRetry:n,strings:r}){return/* @__PURE__ */ U(`div`,{class:`${lu}-module-empty`,role:e===`error`?`alert`:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ U(`span`,{children:t}),n?/* @__PURE__ */ U(`button`,{type:`button`,class:`${lu}-module-retry`,onClick:n,children:r.errorRetry}):null]})}const du=u.cssPrefix,fu=C.scope(`content`);function pu({id:e,title:t,transport:n,strings:r,bus:i,onBack:a,actions:o}){let[s,c]=L(null),[l,u]=L(!1),[d,f]=L(!1),[p,m]=L(0),[h,g]=L(null),_=V(()=>{f(!1),c(null),m(e=>e+1)},[]);R(()=>{let t=!1,r=n.listContentCollections([]).catch(()=>void 0);return Promise.all([n.listContent({ids:[e],limit:1}),r]).then(([n,r])=>{if(t)return;let a=n.items[0];a?(c(a),u(r?.items.find(e=>e.id===a.contentCollectionId)?.settings?.voteAccess===`portal`),i.emit(`contentOpen`,{contentId:e,contentCollectionId:a.contentCollectionId})):f(!0)}).catch(e=>{t||(fu.warn(`listContent (reader) failed`,{err:e}),f(!0))}),()=>{t=!0}},[n,e,p,i]),R(()=>{if(!s)return;let t=setTimeout(()=>i.emit(`contentRead`,{contentId:e}),5e3);return()=>clearTimeout(t)},[s,e,i]);let v=V(t=>{let n=(t.target?.closest?.(`a`))?.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&i.emit(`contentLinkClick`,{contentId:e})},[i,e]);function y(t){g(e),n.setContentVote({contentId:e,value:t})}function b(){return d?/* @__PURE__ */ U(uu,{tone:`error`,message:r.errorGeneric,onRetry:_,strings:r}):s===null?/* @__PURE__ */ U(uu,{message:r.contentLoading,strings:r}):/* @__PURE__ */ U(`article`,{class:`${du}-content`,"data-testid":Z.contentView,onClick:v,children:[s.image?/* @__PURE__ */ U(`img`,{class:`${du}-content-hero`,src:s.image,alt:``,loading:`lazy`}):null,s.description?/* @__PURE__ */ U(`p`,{class:`${du}-content-subtitle`,children:s.description}):null,/* @__PURE__ */ U(ru,{text:au(s.content??``)}),l?/* @__PURE__ */ U(`div`,{class:`${du}-content-vote`,"aria-live":`polite`,children:h===e?r.feedbackThanks:/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`span`,{children:r.contentHelpful}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${du}-module-retry`,onClick:()=>y(1),children:r.confirmYes}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${du}-module-retry`,onClick:()=>y(0),children:r.confirmNo})]})}):null]})}return/* @__PURE__ */ U(`div`,{class:`${du}-module`,children:[/* @__PURE__ */ U(tu,{title:s?.title||t||r.moduleBack,backLabel:r.moduleBack,onBack:a,actions:o,testid:Z.backHeader}),/* @__PURE__ */ U(`div`,{class:`${du}-module-scroll`,"data-testid":Z.contentScroll,children:b()})]})}function mu({itemCount:e,initialFocusIndex:t}){let[n,r]=L(!1),i=z(null),a=z(null),[o,s]=L(-1),c=V(()=>{r(!1),s(-1),i.current?.focus()},[]),l=V(()=>r(e=>!e),[]);return R(()=>{if(!n)return;function e(e){let t=a.current,n=i.current;if(!t||!n)return;let o=e.composedPath();o.includes(t)||o.includes(n)||(r(!1),s(-1))}return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)},[n]),R(()=>{if(!n||e===0)return;let r=t?.()??0;s(r<0||r>=e?0:r)},[n,e,t]),R(()=>{!n||o<0||(a.current?.querySelectorAll(`[role='menuitem']`))?.[o]?.focus()},[n,o]),{open:n,focusIndex:o,triggerRef:i,menuRef:a,toggle:l,close:c,onTriggerKey:V(e=>{(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(!0))},[]),onMenuKey:V(t=>{if(e!==0)switch(t.key){case`Escape`:t.preventDefault(),c();return;case`ArrowDown`:t.preventDefault(),s(t=>(t+1)%e);return;case`ArrowUp`:t.preventDefault(),s(t=>(t-1+e)%e);return;case`Home`:t.preventDefault(),s(0);return;case`End`:t.preventDefault(),s(e-1)}},[e,c])}}function hu({items:e,triggerLabel:t}){let n=u.cssPrefix,r=mu({itemCount:e.length});function i(e){e.disabled||(e.onSelect?.(),e.keepOpen||r.close())}function a(e,t){return e.onSelectValue?.(t)}function o(e,t){let n=t.segments;if(!n?.length)return;let r=Math.max(0,n.findIndex(e=>e.value===t.value)),i=-1;if(e.key===`ArrowRight`||e.key===`Enter`||e.key===` `)i=(r+1)%n.length;else if(e.key===`ArrowLeft`)i=(r-1+n.length)%n.length;else return;e.preventDefault(),e.stopPropagation(),a(t,n[i].value)}return/* @__PURE__ */ U(`div`,{class:`${n}-menu-wrap`,children:[/* @__PURE__ */ U(`button`,{ref:r.triggerRef,type:`button`,class:`${n}-icon-btn`,"aria-label":t,"aria-haspopup":`menu`,"aria-expanded":r.open,title:t,onClick:r.toggle,onKeyDown:r.onTriggerKey,children:/* @__PURE__ */ U(al,{})}),r.open?/* @__PURE__ */ U(`div`,{ref:r.menuRef,class:`${n}-menu`,role:`menu`,"aria-label":t,onKeyDown:r.onMenuKey,tabIndex:-1,children:e.map(e=>e.segments?/* @__PURE__ */ U(`div`,{role:`menuitem`,class:`${n}-menu-item ${n}-menu-item-segmented`,"aria-label":e.label,tabIndex:-1,onKeyDown:t=>o(t,e),children:[e.icon?/* @__PURE__ */ U(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ U(`span`,{class:`${n}-menu-label`,children:e.label}),/* @__PURE__ */ U(`span`,{class:`${n}-segmented`,role:`group`,"aria-label":e.label,children:e.segments.map(t=>{let r=t.value===e.value;return/* @__PURE__ */ U(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,class:`${n}-segment`,"data-on":r?`true`:void 0,lang:t.lang,title:t.value,tabIndex:-1,"data-testid":`${Z.langSegment}-${t.value}`,onClick:()=>a(e,t.value),children:t.label},t.value)})})]},e.id):/* @__PURE__ */ U(`button`,{type:`button`,role:`menuitem`,class:`${n}-menu-item`,"aria-pressed":e.type===`switch`?e.on:void 0,disabled:e.disabled,onClick:()=>i(e),children:[e.icon?/* @__PURE__ */ U(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ U(`span`,{class:`${n}-menu-label`,children:e.label}),e.type===`switch`&&e.on?/* @__PURE__ */ U(`span`,{class:`${n}-menu-check`,"aria-hidden":`true`,children:/* @__PURE__ */ U(ul,{})}):null]},e.id))}):null]})}const gu=u.cssPrefix;function _u(e){let t=typeof matchMedia!=`function`||matchMedia(`(prefers-color-scheme: dark)`).matches;return e===`host`?Zn()===`dark`?`light`:`dark`:e===`auto`?t?`light`:`dark`:t?e===`light`?`dark`:`auto`:e===`dark`?`light`:`auto`}const vu={normal:`large`,large:`small`,small:`normal`};function yu(e){return U(e===`light`?kl:e===`dark`?Al:jl,{})}function bu(e){return(e.split(`-`)[0]??e).toUpperCase()}function xu(e,t){let n;try{n=new URL(e,window.location.href)}catch{return}if(n.protocol===`http:`||n.protocol===`https:`)return t.conversationId&&n.searchParams.set(`chat`,t.conversationId),n.searchParams.set(`widgetId`,t.widgetId),t.publicKey&&n.searchParams.set(`public_key`,t.publicKey),n.searchParams.set(`ai_agent_deployment_id`,t.aiAgentDeploymentId),n.href}function Su({panelProps:e,variant:t}){let{options:n,panelSize:r,feedback:i,onClose:a,onClear:o,onExpand:s,onFullscreen:c,onSoundToggle:l}=e,{onToggleHistory:u,onLocaleChange:d,onThemeChange:f,onTextSizeChange:p}=e,m=n.strings,h=n.mode,g=t===`chat`,_=yi(()=>i.mutedSig.value).value,v=new Set(n.actions);function y(e){return v.has(e)}let b=typeof matchMedia==`function`&&matchMedia(`(max-width: 640px)`).matches;function x(e){return!b&&wc(e,h,r)}let S=n.themeMode,C={auto:m.themeAuto,light:m.themeLight,dark:m.themeDark,host:m.themeAuto},w=n.textSize,T={small:m.textSizeSmall,normal:m.textSizeNormal,large:m.textSizeLarge},E=[];if(g&&y(`clear`)&&E.push({id:`clear`,icon:/* @__PURE__ */ U(ml,{}),label:m.newConversation,onSelect:o}),y(`expand`)&&x(`expand`)){let e=r===`expanded`;E.push({id:`expand`,icon:U(e?el:$c,{}),label:e?m.collapse:m.expand,type:`switch`,on:e,onSelect:s})}if(y(`fullscreen`)&&x(`fullscreen`)){let e=r===`fullscreen`;E.push({id:`fullscreen`,icon:U(e?nl:tl,{}),label:e?m.exitFullscreen:m.fullscreen,type:`switch`,on:e,onSelect:c})}let D=n.popOutUrl,O=n.aiAgentDeploymentId;y(`popOut`)&&D&&O&&wc(`popOut`,h,r)&&E.push({id:`popOut`,icon:/* @__PURE__ */ U(rl,{}),label:m.popOut,onSelect:()=>{let t=xu(D,{conversationId:e.conversationId,widgetId:n.widgetId,publicKey:n.publicKey,aiAgentDeploymentId:O});t&&window.open(t,`_blank`,`noopener,noreferrer`)}}),g&&y(`sound`)&&E.push({id:`sound`,icon:U(_?sl:ol,{}),label:_?m.soundOff:m.soundOn,type:`switch`,on:!_,onSelect:l}),y(`theme`)&&E.push({id:`theme`,icon:yu(S),label:`${m.theme}: ${C[S]}`,onSelect:()=>f(_u(S)),keepOpen:!0}),y(`textSize`)&&E.push({id:`textSize`,icon:/* @__PURE__ */ U(cl,{}),label:`${m.textSize}: ${T[w]}`,onSelect:()=>p(vu[w]),keepOpen:!0}),y(`language`)&&n.availableLocales.length>1&&E.push({id:`language`,icon:/* @__PURE__ */ U(fl,{}),label:m.language,segments:n.availableLocales.map(e=>({value:e,label:bu(e),lang:e})),value:n.locale,onSelectValue:d});let ee=!!a&&Tc(h,r,n.actions),k=g&&y(`history`);return/* @__PURE__ */ U(`div`,{class:`${gu}-header-actions`,children:[k?/* @__PURE__ */ U(`button`,{type:`button`,class:`${gu}-icon-btn`,onClick:u,"aria-label":m.history,title:m.history,"data-testid":Z.actionHistory,children:/* @__PURE__ */ U(dl,{})}):null,E.length>0?/* @__PURE__ */ U(hu,{items:E,triggerLabel:m.moreActions}):null,ee?/* @__PURE__ */ U(`button`,{type:`button`,class:`${gu}-icon-btn`,onClick:a,"aria-label":m.close,title:m.close,"data-testid":Z.actionClose,children:/* @__PURE__ */ U(Wc,{})}):null]})}const Cu={Icon:Ol};function wu(e,t){return e instanceof ic&&e.status===429?t.errorRateLimited:t.errorGeneric}const Tu=u.cssPrefix;function Eu({placeholder:e,onActivate:t}){return/* @__PURE__ */ U(`button`,{type:`button`,class:`${Tu}-home-search`,onClick:t,"data-testid":Z.homeSearch,children:[/* @__PURE__ */ U(`span`,{class:`${Tu}-home-search-text`,children:e}),/* @__PURE__ */ U(`span`,{class:`${Tu}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(wl,{})})]})}function Du({placeholder:e,value:t,onInput:n}){return/* @__PURE__ */ U(`div`,{class:`${Tu}-home-search`,"data-input":`true`,children:[/* @__PURE__ */ U(`input`,{type:`search`,class:`${Tu}-home-search-input`,placeholder:e,value:t,maxLength:200,onInput:e=>n(e.currentTarget.value),"data-testid":Z.helpSearch}),/* @__PURE__ */ U(`span`,{class:`${Tu}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(wl,{})})]})}const Ou=u.cssPrefix;function ku({title:e,subtitle:t,onClick:n,testid:r}){return/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ou}-list-row`,onClick:n,"data-testid":r,children:[/* @__PURE__ */ U(`span`,{class:`${Ou}-list-row-body`,children:[/* @__PURE__ */ U(`span`,{class:`${Ou}-list-row-title`,children:e}),t?/* @__PURE__ */ U(`span`,{class:`${Ou}-list-row-sub`,children:t}):null]}),/* @__PURE__ */ U(`span`,{class:`${Ou}-list-row-chevron`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Yc,{})})]})}const Au=u.cssPrefix,ju=C.scope(`help`);function Mu(e,t,n){let r=new Map(n.map(e=>[e.id,e.title]));return t.map(t=>({id:t,title:r.get(t),rows:e.filter(e=>e.contentCollectionId===t)})).filter(e=>e.rows.length>0)}function Nu({transport:e,strings:t,bus:n},r,i){let[a,o]=L(),s=z(void 0);function c(a){if(!r?.length)return;let c={};s.current=c,o(e=>({search:i,items:[],collections:[],...e,pagination:a>1?e?.pagination:void 0,loading:!0,error:void 0})),Promise.all([e.listContent({contentCollectionIds:r,sortBy:`order`,page:a,limit:20,search:i}),a>1?void 0:e.listContentCollections(r)]).then(([e,t])=>{s.current===c&&(o(n=>({search:i,items:[...a>1?n?.items??[]:[],...e.items],collections:t?.items??n?.collections??[],pagination:e.pagination,loading:!1})),!(a>1)&&(i?n.emit(`contentSearch`,{queryLength:i.length,hitCount:e.pagination.total}):n.emit(`contentView`,{section:`help`,count:e.items.length})))}).catch(e=>{s.current===c&&(ju.warn(`listContent (help) failed`,{err:e,page:a}),o(n=>n&&{...n,loading:!1,error:wu(e,t)}))})}return R(()=>{if(!r?.length)o(void 0);else return c(1),()=>{s.current=void 0}},[e,r,i]),[a,()=>!a?.loading&&c((a?.pagination?.page??0)+1)]}function Pu(e){let{strings:t,config:n,nav:r,panelProps:i}=e,a=n.contentCollectionIds,[o,s]=L(``),[c,l]=L(``),u=Nu(e,a),d=Nu(e,c?a:void 0,c),[f,p]=o.trim()?d:u;R(()=>{let e=setTimeout(()=>l(o.trim()),300);return()=>clearTimeout(e)},[o]);function m(){if(!a?.length)return/* @__PURE__ */ U(uu,{message:t.helpEmpty,strings:t});let e=f?.error?/* @__PURE__ */ U(uu,{tone:`error`,message:f.error,onRetry:p,strings:t}):null;return e&&!f?.pagination?e:!f||!f.pagination&&!f.items.length?/* @__PURE__ */ U(uu,{message:t.helpLoading,strings:t}):f.items.length?/* @__PURE__ */ U(I,{children:[Mu(f.items,a,f.collections).map(e=>/* @__PURE__ */ U(`section`,{class:`${Au}-help-group`,children:[e.title?/* @__PURE__ */ U(`h2`,{class:`${Au}-help-section-title`,children:e.title}):null,/* @__PURE__ */ U(`div`,{class:`${Au}-help-card`,children:e.rows.map(e=>/* @__PURE__ */ U(ku,{title:e.title,subtitle:e.description,onClick:()=>r.push(e.url?{kind:`iframe`,url:e.url,title:e.title}:{kind:`content`,id:e.id,title:e.title}),testid:Wl(Z.helpArticle,e.id)},e.id))})]},e.id)),e,f.pagination?.hasNext&&!e?/* @__PURE__ */ U(`div`,{children:/* @__PURE__ */ U(`div`,{class:`${Au}-help-card`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${Au}-list-row ${Au}-help-more`,onClick:p,"aria-busy":f.loading,children:[f.loading?/* @__PURE__ */ U(`span`,{class:`${Au}-loading-spinner`,"aria-hidden":`true`}):null,t.helpShowMore]})})}):null]}):/* @__PURE__ */ U(uu,{message:f.search?t.helpSearchEmpty.replace(`{query}`,f.search):t.helpEmpty,strings:t})}return/* @__PURE__ */ U(`div`,{class:`${Au}-module`,children:[/* @__PURE__ */ U(eu,{title:t.helpTitle,actions:/* @__PURE__ */ U(Su,{panelProps:i,variant:`plain`})}),/* @__PURE__ */ U(`div`,{class:`${Au}-module-pad`,children:/* @__PURE__ */ U(Du,{placeholder:t.helpSearchPlaceholder,value:o,onInput:s})}),/* @__PURE__ */ U(`div`,{class:`${Au}-help-list`,children:m()})]})}const Fu={Icon:yl,Root:e=>/* @__PURE__ */ U(Pu,{...e})},Iu=C.scope(`attachments`);function Lu(e,t,n){let r=Bu(e),i=[],a=[],o=Uu(n.accept),s=t.reduce((e,t)=>e+t.size,0),c=t.length;for(let e of r){let t=zu(e,c,s,n,o);t?a.push({file:e,reason:t}):(i.push(Hu(e)),s+=e.size,c+=1)}return(i.length||a.length)&&Iu.debug(`ingest`,{accepted:i.length,rejected:a.map(e=>({name:e.file.name,reason:e.reason}))}),{accepted:i,rejected:a}}function Ru(e){try{URL.revokeObjectURL(e.previewUrl)}catch(e){Iu.debug(`revokeObjectURL failed`,{error:e})}}function zu(e,t,n,r,i){return t>=r.maxCount?`count`:n+e.size>r.maxBytes?`bytes`:Wu(e,i)?null:`mime`}function Bu(e){return e?Array.isArray(e)?e.filter(e=>e instanceof File):[...e].map(e=>e instanceof File?e:Vu(e)).filter(e=>e!==null):[]}function Vu(e){let t=e;return!t?.getAsFile||t.kind!==`file`?null:t.getAsFile()}function Hu(e){return{file:e,id:Fn(),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(e=>e.trim().toLowerCase()).filter(Boolean).map(e=>{if(e.startsWith(`.`))return{kind:`ext`,ext:e};let[t=`*`,n=`*`]=e.split(`/`);return{kind:`mime`,type:t,subtype:n}})}function Wu(e,t){if(t.length===0)return!0;let[n=`*`,r=`*`]=(e.type||``).toLowerCase().split(`/`),i=(e.name||``).toLowerCase();return t.some(e=>e.kind===`ext`?i.endsWith(e.ext):e.type===`image`&&e.subtype===`*`&&/\.(heic|heif|avif|bmp|tif|tiff)$/.test(i)?!0:(e.type===`*`||e.type===n)&&(e.subtype===`*`||e.subtype===r))}const Gu=u.cssPrefix;function Ku({attachment:e,onRemove:t,disabled:n=!1}){let r=/^image\/(jpeg|png|gif|webp|avif|bmp|x-ms-bmp|svg\+xml)$/i.test(e.mediaType);return/* @__PURE__ */ U(`span`,{class:`${Gu}-attachment-chip`,title:e.name,"data-testid":Wl(Z.attachmentChip,e.id),children:[r?/* @__PURE__ */ U(`img`,{class:`${Gu}-attachment-thumb`,src:e.previewUrl,alt:``}):/* @__PURE__ */ U(`span`,{class:`${Gu}-attachment-thumb`,"aria-hidden":`true`,children:/* @__PURE__ */ U(gl,{})}),/* @__PURE__ */ U(`span`,{class:`${Gu}-attachment-name`,children:e.name}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Gu}-attachment-remove`,onClick:t,disabled:n,"aria-label":`Remove ${e.name}`,"data-testid":Wl(Z.attachmentRemove,e.id),children:/* @__PURE__ */ U(Wc,{})})]})}const qu={isSupported:!1,start:()=>void 0,stop:()=>void 0,cancel:()=>void 0};function Ju(e,t,n){return e===`disabled`?qu:e===`server`?Qu(n):Yu(t)}function Yu(e){let t=Xu();if(!t)return qu;let n=null,r=0;return{isSupported:!0,start(i,a){let o=n,s=++r;n=null,o?.abort();let c=new t;n=c,c.continuous=!0,c.interimResults=!0,c.lang=e;let l=!1;c.addEventListener(`result`,e=>{if(r!==s||n!==c)return;let t=e,a=``,o=!1;for(let e=t.resultIndex;e<t.results.length;e++){let n=t.results[e];n&&(a+=n[0].transcript,n.isFinal&&(o=!0))}i(a,o)});function u(){l||r!==s||n!==c||(l=!0,n=null,a())}c.addEventListener(`end`,u),c.addEventListener(`error`,u);try{c.start()}catch{u()}},stop(){n?.stop()},cancel(){r++;let e=n;n=null,e?.abort()}}}function Xu(){return window.SpeechRecognition??window.webkitSpeechRecognition}const Zu=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/mp4`];function Qu(e){if(typeof MediaRecorder>`u`||!navigator?.mediaDevices?.getUserMedia)return qu;let t=0,n=null;function r(e){for(let t of e.stream?.getTracks()??[])t.stop();e.stream=null}function i(){t++;let e=n;n=null,e&&(r(e),e.recorder?.state!==`inactive`&&e.recorder?.stop())}async function a(i){if(i.finishing)return;i.finishing=!0;let a=i.recorder?.mimeType??`audio/webm`;r(i);let o=new Blob(i.chunks,{type:a});i.chunks=[];try{let{text:r}=await e(o,a);n===i&&t===i.generation&&r&&i.onText(r,!0)}catch{}finally{n===i&&t===i.generation&&(n=null,i.onEnd())}}return{isSupported:!0,async start(e,o){i();let s={generation:t,recorder:null,stream:null,chunks:[],onText:e,onEnd:o,finishing:!1};n=s;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});if(n!==s||t!==s.generation){for(let t of e.getTracks())t.stop();return}s.stream=e;let r=$u(),i=new MediaRecorder(e,r?{mimeType:r}:void 0);s.recorder=i,i.addEventListener(`dataavailable`,e=>{n===s&&t===s.generation&&e.data.size>0&&s.chunks.push(e.data)}),i.addEventListener(`stop`,()=>{n===s&&t===s.generation&&a(s)}),i.start()}catch{r(s),n===s&&t===s.generation&&(n=null,o())}},stop(){let e=n;e&&(e.recorder?e.recorder.state!==`inactive`&&e.recorder.stop():i())},cancel(){i()}}}function $u(){for(let e of Zu)if(MediaRecorder.isTypeSupported(e))return e}const ed=u.cssPrefix,td=C.scope(`composer`);function nd(e){return e.reduce((e,t)=>e+t.size,0)}const rd={arrowUp:qc,paperPlane:Kc,send:Jc,chevron:Yc};function id(e){return`activeElement`in e}function ad(e){return`host`in e&&`activeElement`in e}function od({options:e,transport:t,feedback:n,bus:r,persistence:i,conversationId:a,isStreaming:o,pageToolRunning:s=!1,isMemoryCompacting:c=!1,canReleaseQueuedMessages:l=!0,queueManualMessages:u=!1,active:d=!0,isPreparing:f=!1,operatorRequestEnabled:p,canRequestOperator:m=!1,controlMode:h=`ai-agent`,onRequestOperator:g,onSend:_,onStop:v,apiRef:y}){let b=e.strings,[x,S]=L(()=>i.loadDraft(a)),[C,w]=L([]),[T,E]=L(()=>i.loadMessageQueue(a).map(e=>({id:e.id,text:e.text,attachments:[]}))),D=z(T),O=z(!1),[ee,k]=L(!1),[te,ne]=L(!1),A=z(!1),j=z(null),re=z(null),ie=z(null),ae=z(0),oe=z(a);oe.current=a;let se=z(d);se.current=d;let ce=z(f);ce.current=f;let le=te||f||!d,M=o&&h===`ai-agent`,ue=M||c&&h===`ai-agent`,de=h===`ai-agent`&&(ue||u||T.length>0),fe=V(e=>{E(t=>{let n=e(t);return i.saveMessageQueue(oe.current,n.filter(e=>e.attachments.length===0).map(({id:e,text:t})=>({id:e,text:t}))),D.current=n,n})},[i]),pe=V(e=>{fe(t=>(t.find(t=>t.id===e)?.attachments.forEach(Ru),t.filter(t=>t.id!==e)))},[fe]),me=V(e=>{S(t=>{let n=typeof e==`function`?e(t):e;return n===t?t:(i.saveDraft(oe.current,n),n)})},[i]),he=e.features.fileUpload,N=e.features.voice,[ge,_e]=L(()=>Ju(N,e.locale,(e,n)=>t.transcribe(e,n))),ve=z(ge);ve.current=ge;let ye=z({mode:N,locale:e.locale,transport:t});R(()=>{let n=ye.current;(n.mode!==N||n.locale!==e.locale||n.transport!==t)&&(ye.current={mode:N,locale:e.locale,transport:t},ae.current++,ve.current.cancel(),ie.current=null,k(!1),_e(Ju(N,e.locale,(e,n)=>t.transcribe(e,n))))},[e.locale,N,t]),kr(()=>()=>{ae.current++,ge.cancel()},[ge]);let be=V(e=>{let t=ie.current;if(t===null)return!1;let n=Math.round(performance.now()-t);return td[e](`voiceStop`,{durationMs:n}),r.emit(`voiceStop`,{durationMs:n}),ie.current=null,!0},[r]),xe=V(()=>{ie.current!==null&&(ge.stop(),k(!1),be(`info`)&&n.play(`voiceStop`))},[be,n,ge]),Se=V(()=>{ae.current++,ge.cancel(),k(!1),be(`info`)&&n.play(`voiceStop`)},[be,n,ge]);R(()=>{(f||!d)&&Se()},[d,Se,f]),R(()=>{let e=j.current;if(!e)return;let t=e.getRootNode(),n=id(t)?t.activeElement:null;n&&e.closest(`.${ed}-panel`)?.contains(n)||e.focus({preventScroll:!0})},[]),R(()=>{let e=j.current;if(!e)return;if(x.length===0){e.style.height=``;return}e.style.height=`auto`;let t=getComputedStyle(e),n=Number.parseFloat(t.getPropertyValue(`--${ed}-textarea-base-height`)),r=Number.parseFloat(t.borderTopWidth)+Number.parseFloat(t.borderBottomWidth),i=Math.min(e.scrollHeight+r,Number.parseFloat(t.maxHeight)),a=Number.parseFloat(t.fontSize)*.7;e.style.height=`${i<n+a?n:i}px`},[x]);let Ce=z(C);Ce.current=C,R(()=>()=>{Ce.current.forEach(Ru);for(let e of D.current)e.attachments.forEach(Ru)},[]),kr(()=>{if(y)return y.current={attachFromDrop:t=>{if(!he||!se.current||A.current||ce.current)return;let n=Lu(t,Ce.current,e.attachments);n.accepted.length!==0&&(td.info(`attach (drop)`,{count:n.accepted.length,totalBytes:nd(n.accepted)}),r.emit(`attach`,{count:n.accepted.length,totalBytes:nd(n.accepted)}),w(e=>[...e,...n.accepted]))},fill:e=>{if(!se.current||A.current||ce.current)return;me(e);let t=j.current;t&&(t.focus({preventScroll:!0}),requestAnimationFrame(()=>t.setSelectionRange(t.value.length,t.value.length)))},acceptQueuedMessage:pe},()=>{y.current&&(y.current=null)}},[y,he,f,e.attachments,pe,me]),R(()=>{let t=j.current;if(!t)return;let n=t.closest(`.${ed}-panel`);if(!n)return;let i=n=>{if(!se.current||A.current||ce.current)return;let i=n.clipboardData;if(!i)return;let a=n.target?.closest?.(`input, textarea, [contenteditable]:not([contenteditable='false'])`);if(a&&a!==t)return;if(he){let t=Lu(i.items,Ce.current,e.attachments);if(t.accepted.length>0){n.preventDefault(),td.info(`attach (paste)`,{count:t.accepted.length,totalBytes:nd(t.accepted)}),r.emit(`attach`,{count:t.accepted.length,totalBytes:nd(t.accepted)}),w(e=>[...e,...t.accepted]);return}}if(a===t)return;let o=i.getData(`text/plain`);o&&(n.preventDefault(),me(e=>e+o),t.focus())};return n.addEventListener(`paste`,i),()=>n.removeEventListener(`paste`,i)},[he,e.attachments,me]);async function we(){let e=x.trim();if(!e&&C.length===0||!d||M||A.current||f)return;Se(),A.current=!0,ne(!0);let t=x,n=C;try{await _(e,n)&&(me(e=>e===t?``:e),w(e=>e===n?(n.forEach(Ru),Ce.current=[],[]):e))}finally{A.current=!1,ne(!1),requestAnimationFrame(()=>{let e=j.current;if(!e||e.disabled||!se.current)return;let t=e.getRootNode(),n=id(t)?t.activeElement:null,r=n?.getAttribute(`data-testid`);if(!(n&&n!==e&&r!==Z.composerSend&&r!==Z.composerStop)){if(ad(t)){let e=t.host.ownerDocument;if(!e.hasFocus())return;let n=e.activeElement;if(n&&n!==t.host&&n!==e.body)return}e.focus({preventScroll:!0})}})}}function Te(){let e=x.trim();if(!e&&C.length===0||!d||!de||A.current||f)return;Se();let t=C;fe(n=>[...n,{id:Fn(),text:e,attachments:t}]),me(``),w(e=>e===t?(Ce.current=[],[]):e),j.current?.focus({preventScroll:!0})}R(()=>{ue&&(O.current=!1)},[ue]),R(()=>{let e=T[0];if(!e||!l||ue||O.current||te||f||!d)return;let t=setTimeout(()=>{O.current=!0,_(e.text,e.attachments,e.id).then(t=>{t?pe(e.id):O.current=!1})},300);return()=>clearTimeout(t)},[d,l,f,_,ue,T,pe,te]);function Ee(e){e.key!==`Enter`||e.shiftKey||e.isComposing||(e.preventDefault(),de&&(x.trim()||C.length>0)?Te():M?v():we())}function De(t){let n=t.target;if(!d||A.current||f){n.value=``;return}let i=Lu(n.files,C,e.attachments);i.accepted.length>0&&(td.info(`attach (file picker)`,{count:i.accepted.length,totalBytes:nd(i.accepted)}),r.emit(`attach`,{count:i.accepted.length,totalBytes:nd(i.accepted)}),w(e=>[...e,...i.accepted])),n.value=``}function Oe(e){!d||A.current||f||(td.info(`removeAttachment`,{id:e}),r.emit(`removeAttachment`,{id:e}),w(t=>{let n=t.find(t=>t.id===e);return n&&Ru(n),t.filter(t=>t.id!==e)}))}function ke(){if(ee){xe();return}if(!d||!ge.isSupported||A.current||f)return;let e=++ae.current;ie.current=performance.now(),td.info(`voiceStart`),r.emit(`voiceStart`,void 0),k(!0),n.play(`voiceStart`),ge.start((t,n)=>{ae.current===e&&se.current&&!ce.current&&!A.current&&n&&me(e=>`${e}${t} `)},()=>{ae.current===e&&se.current&&(k(!1),be(`debug`))})}let Ae=rd[e.composer.sendButton.icon],je=!!(x.trim()||C.length>0),Me=M||s&&!je;return/* @__PURE__ */ U(`div`,{class:`${ed}-composer`,part:`composer`,"data-testid":Z.composer,children:[T.length>0?/* @__PURE__ */ U(`div`,{class:`${ed}-message-queue`,"aria-label":b.queueMessage,"data-testid":Z.messageQueue,children:T.map(e=>/* @__PURE__ */ U(`div`,{class:`${ed}-attachment-chip ${ed}-queued-message`,"data-testid":`${Z.queuedMessage}-${e.id}`,children:[/* @__PURE__ */ U(`span`,{class:`${ed}-attachment-name ${ed}-queued-text`,children:e.text||e.attachments.map(e=>e.name).join(`, `)}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${ed}-attachment-remove`,onClick:()=>pe(e.id),"aria-label":b.removeQueuedMessage,title:b.removeQueuedMessage,"data-testid":`${Z.queuedMessageRemove}-${e.id}`,children:/* @__PURE__ */ U(Wc,{})})]},e.id))}):null,C.length>0?/* @__PURE__ */ U(`div`,{class:`${ed}-attachments`,children:C.map(e=>/* @__PURE__ */ U(Ku,{attachment:e,onRemove:()=>Oe(e.id),disabled:le},e.id))}):null,/* @__PURE__ */ U(`div`,{class:`${ed}-composer-row`,children:[/* @__PURE__ */ U(`div`,{class:`${ed}-composer-actions`,children:[he?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ed}-icon-btn`,onClick:()=>re.current?.click(),disabled:le,"aria-label":b.attach,"data-testid":Z.composerAttach,children:/* @__PURE__ */ U(Zc,{})}):null,ge.isSupported?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ed}-icon-btn`,onClick:ke,disabled:le,"aria-label":ee?b.micStop:b.micStart,"aria-pressed":ee,"data-recording":ee?`true`:void 0,"data-testid":Z.composerVoice,children:/* @__PURE__ */ U(Qc,{})}):null]}),/* @__PURE__ */ U(`textarea`,{ref:j,name:`message`,class:`${ed}-textarea`,rows:1,value:x,placeholder:b.composerPlaceholder,onInput:e=>me(e.currentTarget.value),onKeyDown:Ee,disabled:le,"aria-label":b.composerPlaceholder,"data-testid":Z.composerInput}),de&&je?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ed}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:Te,disabled:le,"aria-label":b.queueMessage,title:b.queueMessage,"data-testid":Z.composerSend,children:/* @__PURE__ */ U(Ae,{})}):null,Me?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ed}-send`,onClick:v,disabled:le,"aria-label":b.stop,"data-testid":Z.composerStop,children:/* @__PURE__ */ U(Xc,{})}):null,!Me&&(!de||!je)?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ed}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:()=>void we(),disabled:le||!x.trim()&&C.length===0,"aria-label":b.send,"data-testid":Z.composerSend,children:/* @__PURE__ */ U(Ae,{})}):null,p&&h===`ai-agent`&&g?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ed}-icon-btn`,onClick:g,disabled:le||!m,"aria-label":b.talkToOperator,title:b.talkToOperator,"data-testid":Z.operatorRequest,children:/* @__PURE__ */ U(Sl,{})}):null]}),/* @__PURE__ */ U(`input`,{ref:re,name:`attachments`,type:`file`,multiple:!0,accept:e.attachments.accept,onChange:De,disabled:le,class:`${ed}-sr-only`,"data-testid":Z.composerFileInput})]})}const sd=u.cssPrefix;function cd({onClick:e,children:t,testid:n}){return e?/* @__PURE__ */ U(`button`,{type:`button`,class:`${sd}-home-card`,"data-interactive":`true`,onClick:e,"data-testid":n,children:t}):/* @__PURE__ */ U(`div`,{class:`${sd}-home-card`,"data-testid":n,children:t})}function ld(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}const ud=u.cssPrefix,dd=C.scope(`news`);function fd(e,t){let n=e?new Date(e):void 0;if(n&&!Number.isNaN(n.getTime()))return new Intl.DateTimeFormat(t,{dateStyle:`medium`}).format(n)}function pd({options:e,transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}){let c=r.contentCollectionIds,[l,u]=L({items:[],loading:!0}),d=z(void 0);function f(e){if(!c?.length)return;let r={};d.current=r,u(e=>({...e,loading:!0,error:void 0})),t.listContent({contentCollectionIds:c,sortBy:`publishedAt`,sortOrder:`desc`,page:e,limit:10}).then(t=>{if(d.current!==r||(u(n=>({items:e>1?[...n.items,...t.items]:t.items,pagination:t.pagination,loading:!1})),e>1))return;a.emit(`contentView`,{section:`news`,count:t.items.length});let n=t.items[0];n&&s.markSeen(n.id)}).catch(t=>{d.current===r&&(dd.warn(`listContent (news) failed`,{err:t,page:e}),u(e=>({...e,loading:!1,error:wu(t,n)})))})}function p(){l.loading||f((l.pagination?.page??0)+1)}R(()=>(u({items:[],loading:!0}),f(1),()=>{d.current=void 0}),[t,c]);function m(t){let n=fd(t.publishedAt,e.locale);return/* @__PURE__ */ U(`button`,{type:`button`,class:`${ud}-news-card`,onClick:()=>i.push({kind:`content`,id:t.id,title:t.title}),"data-testid":Wl(Z.newsItem,t.id),children:[t.image?/* @__PURE__ */ U(`img`,{class:`${ud}-news-hero`,src:t.image,alt:``,loading:`lazy`}):null,/* @__PURE__ */ U(`span`,{class:`${ud}-news-body`,children:[/* @__PURE__ */ U(`span`,{class:`${ud}-news-title`,children:t.title}),n||t.tags?.length?/* @__PURE__ */ U(`span`,{class:`${ud}-news-meta`,children:[n?/* @__PURE__ */ U(`time`,{dateTime:t.publishedAt,children:n}):null,t.tags?.map(e=>/* @__PURE__ */ U(`span`,{class:`${ud}-news-tag`,children:e},e))]}):null,t.description?/* @__PURE__ */ U(`span`,{class:`${ud}-news-summary`,children:t.description}):null]})]},t.id)}function h(){if(!c?.length)return/* @__PURE__ */ U(uu,{message:n.newsEmpty,strings:n});let e=l.error?/* @__PURE__ */ U(uu,{tone:`error`,message:l.error,onRetry:p,strings:n}):null;return e&&!l.pagination?e:l.pagination?l.items.length?/* @__PURE__ */ U(`div`,{class:`${ud}-news-list`,children:[l.items.map(m),e,l.pagination.hasNext&&!e?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ud}-news-more`,onClick:p,"aria-busy":l.loading,"data-testid":Z.newsMore,children:[l.loading?/* @__PURE__ */ U(`span`,{class:`${ud}-loading-spinner`,"aria-hidden":`true`}):null,n.newsShowMore]}):null]}):/* @__PURE__ */ U(uu,{message:n.newsEmpty,strings:n}):/* @__PURE__ */ U(uu,{message:n.newsLoading,strings:n})}return/* @__PURE__ */ U(`div`,{class:`${ud}-module`,children:[/* @__PURE__ */ U(eu,{title:n.newsTitle,actions:/* @__PURE__ */ U(Su,{panelProps:o,variant:`plain`})}),/* @__PURE__ */ U(`div`,{class:`${ud}-module-scroll`,children:h()})]})}const md={Icon:Dl,Root:e=>/* @__PURE__ */ U(pd,{...e})},Q=u.cssPrefix,hd=C.scope(`home`);function gd(e){let t=e.options.userContext?.name,n=e.config.greetingText?At(e.strings,e.config.greetingText):void 0;if(n){let r=t?n.replace(`{name}`,t):n.replace(/\s*\{name\}\s*/,` `).trim(),i=e.strings.homeGreetingLead;return{title:r,subtitle:r.toLowerCase()===i.toLowerCase()?void 0:i}}return t?{title:e.strings.homeGreetingNamed.replace(`{name}`,t),subtitle:e.strings.homeGreetingLead}:{title:e.strings.homeGreeting}}function _d(e,t){return t.url?e.push({kind:`iframe`,url:t.url,title:t.title}):e.push({kind:`content`,id:t.id,title:t.title})}function vd({options:e,onAsk:t}){let[n,r]=L(``),{sendButton:i}=e.composer,a=rd[i.icon];function o(e){e.preventDefault();let i=n.trim();i&&(r(``),t(i))}return/* @__PURE__ */ U(`form`,{class:`${Q}-home-search ${Q}-home-ask`,"data-input":`true`,onSubmit:o,"data-testid":Z.homeAsk,children:[/* @__PURE__ */ U(`input`,{type:`text`,class:`${Q}-home-search-input`,placeholder:e.strings.homeAskPlaceholder,"aria-label":e.strings.homeAskPlaceholder,value:n,enterKeyHint:`send`,onInput:e=>r(e.currentTarget.value)}),/* @__PURE__ */ U(`button`,{type:`submit`,class:`${Q}-send`,"data-shape":i.shape,"data-variant":i.variant,disabled:!n.trim(),"aria-label":e.strings.send,children:/* @__PURE__ */ U(a,{})})]})}function yd(e,t){return hc(e,t,t.type!==`upsert`||t.activity===!0)}function bd(e){let{transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}=e,[c,l]=L(null),[u,d]=L([]),f=r.contentCollectionIds?.join(`,`),p=e.options.modules.list.some(e=>e.layout===`chat`);R(()=>{if(r.showRecentConversations===!1)return;let e=!1,n=!0,i=[],a=t.subscribeConversationChanges(e=>{n&&i.push(e),l(t=>yd(t?[t]:[],e)[0]??null)});return t.listConversations({limit:p?50:1}).then(t=>{if(e)return;let r=i.reduce(yd,t.conversations);i=[],n=!1,l(r[0]??null)}).catch(t=>{e||(i=[],n=!1,hd.warn(`listConversations (home) failed`,{err:t}))}),()=>{e=!0,a()}},[t,r.showRecentConversations,p]),R(()=>{if(!r.contentCollectionIds?.length)return;let e=!1;return t.listContent({contentCollectionIds:r.contentCollectionIds,pinned:!0,limit:6}).then(t=>{e||(d(t.items),a.emit(`contentView`,{section:`home`,count:t.items.length}))}).catch(t=>!e&&hd.warn(`listContent (home) failed`,{err:t})),()=>{e=!0}},[t,f,a]);let m=gd(e),h=r.userAvatars??[],g=r.status,_=g?.text?At(n,g.text):n.homeStatus,v=r.contentBlockTitle?At(n,r.contentBlockTitle):n.homeContentTitle,y=s.item,b=fd(y?.publishedAt,e.options.locale);return/* @__PURE__ */ U(`div`,{class:`${Q}-module ${Q}-home`,"data-testid":Z.homeView,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-scroll`,children:[/* @__PURE__ */ U(`div`,{class:`${Q}-home-hero`,children:[/* @__PURE__ */ U(`div`,{class:`${Q}-home-hero-top`,children:[r.brandName?/* @__PURE__ */ U(`span`,{class:`${Q}-home-brand`,"data-testid":Z.homeBrand,children:r.brandName}):/* @__PURE__ */ U(`span`,{class:`${Q}-home-brand-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ U(`div`,{class:`${Q}-home-hero-actions`,children:[h.length>0?/* @__PURE__ */ U(`div`,{class:`${Q}-home-avatars`,children:h.map(e=>/* @__PURE__ */ U(`span`,{class:`${Q}-home-avatar`,title:e.role?`${e.name} · ${e.role}`:e.name,children:e.avatar?/* @__PURE__ */ U(`img`,{src:e.avatar,alt:``,loading:`lazy`}):/* @__PURE__ */ U(`span`,{children:ld(e.name)})},e.name))}):null,/* @__PURE__ */ U(Su,{panelProps:o,variant:`plain`})]})]}),r.showGreeting===!1?null:/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`h1`,{class:`${Q}-home-greeting`,"data-testid":Z.homeGreeting,children:m.title}),m.subtitle?/* @__PURE__ */ U(`p`,{class:`${Q}-home-lead`,children:m.subtitle}):null]})]}),/* @__PURE__ */ U(`div`,{class:`${Q}-home-cards`,children:[p?/* @__PURE__ */ U(vd,{options:e.options,onAsk:e=>i.startNewConversation(e)}):null,r.showSearchBar===!1?null:/* @__PURE__ */ U(Eu,{placeholder:n.homeSearchPlaceholder,onActivate:()=>i.switchToLayout(`help`)}),y?/* @__PURE__ */ U(cd,{onClick:()=>{s.markSeen(y.id),i.push({kind:`content`,id:y.id,title:y.title})},testid:Z.homeWhatsNew,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-recent-row`,"data-unread":s.unseen?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Dl,{})}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-body`,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-title`,children:n.homeWhatsNew}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-preview`,children:b?`${y.title} · ${b}`:y.title})]}),s.unseen?/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-dot`,role:`img`,"aria-label":n.newsUnseen}):null]})}):null,c?/* @__PURE__ */ U(cd,{onClick:()=>i.selectConversation(c),testid:Z.homeRecent,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-recent-row`,"data-unread":c.hasUnread?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Ol,{})}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-body`,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-title`,children:c.title}),c.preview?/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-preview`,children:cu(c.preview)}):null]}),c.hasUnread?/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-dot`,"aria-label":`Unread`}):null]})}):null,g?/* @__PURE__ */ U(cd,{onClick:g.url?()=>i.push({kind:`iframe`,url:g.url,title:_}):void 0,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-status`,"data-level":g.level??`operational`,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-status-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Tl,{})}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-status-text`,children:_})]})}):null,u.length>0?/* @__PURE__ */ U(`section`,{class:`${Q}-home-content`,children:[/* @__PURE__ */ U(`div`,{class:`${Q}-home-content-title`,children:v}),/* @__PURE__ */ U(`div`,{class:`${Q}-home-content-list`,children:u.map(e=>/* @__PURE__ */ U(ku,{title:e.title,subtitle:e.description,onClick:()=>_d(i,e),testid:Wl(Z.homeContentRow,e.id)},e.id))})]}):null]})]})})}const xd={chat:Cu,home:{Icon:El,Root:e=>/* @__PURE__ */ U(bd,{...e})},help:Fu,news:md},Sd=u.cssPrefix;function Cd({modules:e,activeTab:t,strings:n,hasUnread:r,onSelect:i}){return/* @__PURE__ */ U(`nav`,{class:`${Sd}-tabbar`,role:`tablist`,"aria-label":n.panelTitle,children:e.map(e=>{let a=xd[e.layout].Icon,o=e.id===t,s=e.layout===`chat`&&r;return/* @__PURE__ */ U(`button`,{type:`button`,role:`tab`,"aria-selected":o,class:`${Sd}-tab`,onClick:()=>i(e.id),"data-testid":Wl(Z.tab,e.id),children:[/* @__PURE__ */ U(`span`,{class:`${Sd}-tab-icon`,"aria-hidden":`true`,children:[/* @__PURE__ */ U(a,{}),s?/* @__PURE__ */ U(`span`,{class:`${Sd}-tab-badge`,"data-testid":Z.tabBadge,"aria-label":`Unread`}):null]}),/* @__PURE__ */ U(`span`,{class:`${Sd}-tab-label`,children:At(n,e.label)})]},e.id)})})}const wd=u.cssPrefix;function Td({url:e,title:t,strings:n,onBack:r,actions:i}){return/* @__PURE__ */ U(`div`,{class:`${wd}-module`,children:[/* @__PURE__ */ U(tu,{title:t||n.moduleBack,backLabel:n.moduleBack,onBack:r,actions:i}),/* @__PURE__ */ U(`iframe`,{class:`${wd}-content-frame`,src:e,title:t||`content`,sandbox:`allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads`,referrerpolicy:`no-referrer`,loading:`lazy`,allow:`fullscreen`})]})}const Ed=u.cssPrefix;function Dd({agent:e,strings:t}){let n=e.status??`online`,r=At(t,e.name),i=e.title?At(t,e.title):null;return/* @__PURE__ */ U(`div`,{class:`${Ed}-agent`,children:[/* @__PURE__ */ U(`div`,{class:`${Ed}-agent-avatar`,"data-status":n,children:e.avatar?/* @__PURE__ */ U(`img`,{src:e.avatar,alt:``}):/* @__PURE__ */ U(`span`,{children:ld(r)})}),/* @__PURE__ */ U(`div`,{class:`${Ed}-agent-meta`,children:[/* @__PURE__ */ U(`strong`,{children:r}),i?/* @__PURE__ */ U(`span`,{children:i}):null]})]})}const Od=[`today`,`yesterday`,`lastWeek`,`older`];function kd(e,t){let n=Date.parse(t);if(!Number.isFinite(n))return`older`;let r=Math.floor((jd(e)-jd(n))/864e5);return r<=0?`today`:r===1?`yesterday`:r<7?`lastWeek`:`older`}function Ad(e,t){let n=/* @__PURE__ */ new Map;for(let r of t){let t=kd(e,r.lastMessageAt),i=n.get(t);i?i.push(r):n.set(t,[r])}return Od.filter(e=>n.has(e)).map(e=>({bucket:e,conversations:n.get(e)}))}function jd(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t.getTime()}const Md=C.scope(`history`),Nd={today:`dateToday`,yesterday:`dateYesterday`,lastWeek:`dateLastWeek`,older:`dateOlder`};function Pd(e,t){let n=t.type!==`upsert`||t.activity===!0;if(t.type===`snapshot`&&t.result.pagination.page===1&&e.pagination.page>1){let r=hc(e.conversations.slice(0,t.result.pagination.limit),t,n);if(t.result.conversations.length===0){if(r.length===0)return t.result;let e=Math.max(t.result.pagination.total,r.length);return{...t.result,conversations:r,pagination:{...t.result.pagination,total:e,totalPages:Math.ceil(e/t.result.pagination.limit)}}}let i=new Set(r.map(e=>e.conversationId)),a=e.conversations.slice(t.result.pagination.limit).filter(e=>!i.has(e.conversationId)),o=e.pagination.page,s={...t.result.pagination,page:o,hasPrev:o>1,hasNext:o<t.result.pagination.totalPages};return{conversations:[...r,...a],pagination:s}}let r=hc(e.conversations,t,n);return r===e.conversations?e:{...t.type===`snapshot`?t.result:e,conversations:r}}function Fd(e,t,n){let r=Date.parse(e);return Number.isFinite(r)?new Date(r).toDateString()===new Date(t).toDateString()?new Intl.DateTimeFormat(n,{hour:`numeric`,minute:`2-digit`}).format(r):t-r<6048e5?new Intl.DateTimeFormat(n,{weekday:`short`}).format(r):new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`}).format(r):``}function Id({transport:e,strings:t,locale:n,persistence:r,onSelect:i,onNewConversation:a}){let o=u.cssPrefix,s=e.peekConversations({limit:50}),[c,l]=L(s?`loaded`:`loading`),[d,f]=L(s),[p,m]=L(!1),h=z(void 0),g=d?.conversations??[],_=d?.pagination;R(()=>{let t=!1,n=!0,i=[],a=e.subscribeConversationChanges(e=>{n&&i.push(e),f(t=>t&&Pd(t,e))});h.current=void 0,m(!1);let o=e.peekConversations({limit:50});return f(o),l(o?`loaded`:`loading`),e.listConversations({limit:50}).then(e=>{if(t)return;let a=e;for(let e of i)a=Pd(a,e);i=[],n=!1,f(a),l(`loaded`),r.saveHistoryCount(a.conversations.length)}).catch(e=>{t||(i=[],n=!1,Md.warn(`listConversations failed`,{err:e}),l(`error`))}),()=>{t=!0,a(),h.current=void 0}},[e,r,n]);async function v(){if(h.current||!_?.hasNext)return;let t={};h.current=t,m(!0);try{let n=await e.listConversations({page:_.page+1,limit:_.limit});if(h.current!==t)return;f(e=>{if(!e)return e;let t=new Set(e.conversations.map(e=>e.conversationId)),i=n.conversations.filter(e=>!t.has(e.conversationId)&&(t.add(e.conversationId),!0)),a={conversations:[...e.conversations,...i],pagination:n.pagination};return r.saveHistoryCount(a.conversations.length),a})}catch(e){if(h.current!==t)return;Md.warn(`listConversations page failed`,{err:e,page:_.page+1})}finally{h.current===t&&(h.current=void 0,m(!1))}}let y=a?/* @__PURE__ */ U(`div`,{class:`${o}-history-footer`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${o}-history-new`,onClick:a,"data-testid":Z.sidebarNewConversation,children:[/* @__PURE__ */ U(Gc,{}),t.newConversation]})}):null;if(c===`loading`){let e=Math.min(r.loadHistoryCount()??3,6);return/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`div`,{class:`${o}-history`,"aria-busy":`true`,"aria-label":t.historyLoading,children:/* @__PURE__ */ U(`div`,{class:`${o}-history-group`,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`div`,{class:`${o}-history-heading`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-heading`})}),/* @__PURE__ */ U(`div`,{class:`${o}-history-card`,children:Array.from({length:Math.max(1,e)},(e,t)=>/* @__PURE__ */ U(`div`,{class:`${o}-history-item ${o}-history-item-skeleton`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-avatar ${o}-skeleton`}),/* @__PURE__ */ U(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-title`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-title`})}),/* @__PURE__ */ U(`span`,{class:`${o}-history-time`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-time`})})]}),/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:/* @__PURE__ */ U(`span`,{class:`${o}-history-preview`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-preview`})})})]})]},t))})]})}),y]})}if(c===`error`||g.length===0)return/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`div`,{class:`${o}-history-empty`,children:t.historyEmpty}),y]});let b=Date.now(),x=Ad(b,g);return/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`div`,{class:`${o}-history`,role:`list`,children:[x.map(e=>/* @__PURE__ */ U(`div`,{class:`${o}-history-group`,children:[/* @__PURE__ */ U(`div`,{class:`${o}-history-heading`,children:t[Nd[e.bucket]]}),/* @__PURE__ */ U(`div`,{class:`${o}-history-card`,children:e.conversations.map(e=>/* @__PURE__ */ U(`div`,{role:`listitem`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${o}-history-item`,onClick:()=>i(e),"data-closed":e.canContinue?void 0:`true`,"data-unread":e.hasUnread?`true`:void 0,"data-testid":Wl(Z.historyItem,e.conversationId),children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(vl,{})}),/* @__PURE__ */ U(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-title`,children:e.title}),/* @__PURE__ */ U(`span`,{class:`${o}-history-time`,children:Fd(e.lastMessageAt,b,n)})]}),/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-preview`,children:e.preview&&cu(e.preview)||(e.canContinue?t.historyContinue:t.conversationClosed)}),e.hasUnread?/* @__PURE__ */ U(`span`,{class:`${o}-history-dot`}):null]})]})]})},e.conversationId))})]},e.bucket)),_?.hasNext?/* @__PURE__ */ U(`div`,{class:`${o}-history-more`,children:/* @__PURE__ */ U(`button`,{type:`button`,onClick:v,disabled:p,"aria-busy":p,"data-testid":Z.historyLoadMore,children:t.loadMoreConversations})}):null]}),y]})}const Ld=u.cssPrefix;function Rd({visible:e,strings:t}){return e?/* @__PURE__ */ U(`div`,{class:`${Ld}-dropzone`,role:`status`,"aria-live":`polite`,children:t.dropZone}):null}const zd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Bd=/^https?:\/\/[^\s.]+\.[^\s]+$/i,Vd=/^[+]?[\d\s().-]{6,}$/;function Hd(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??`{${n}}`))}function Ud(e){return Array.isArray(e)?e.length:+!!e?.trim()}function Wd(e,t,n){let r=e.required??!0,i=e.validation;if(e.type===`multiselect`){let e=Ud(t);return r&&e===0?n.formRequired:e===0?void 0:i?.minSelections!=null&&e<i.minSelections?Hd(n.formChooseAtLeast,{min:i.minSelections}):i?.maxSelections!=null&&e>i.maxSelections?Hd(n.formChooseAtMost,{max:i.maxSelections}):void 0}let a=typeof t==`string`?t.trim():``;if(!a)return r?n.formRequired:void 0;switch(e.type){case`email`:if(!zd.test(a))return n.formInvalidEmail;break;case`url`:if(!Bd.test(a))return n.formInvalidUrl;break;case`tel`:if(!Vd.test(a))return n.formInvalidTel;break;case`number`:{let e=Number(a);if(!Number.isFinite(e))return n.formInvalidNumber;if(i?.min!=null&&e<i.min)return Hd(n.formNumberTooSmall,{min:i.min});if(i?.max!=null&&e>i.max)return Hd(n.formNumberTooLarge,{max:i.max});break}}if(i?.minLength!=null&&a.length<i.minLength)return Hd(n.formTooShort,{min:i.minLength});if(i?.maxLength!=null&&a.length>i.maxLength)return Hd(n.formTooLong,{max:i.maxLength});if(i?.pattern)try{if(!new RegExp(i.pattern).test(a))return n.formPatternMismatch}catch{}}function Gd(e,t,n){let r={};for(let i of e){let e=Wd(i,t[i.name],n);e&&(r[i.name]=e)}return r}function Kd(e){let t={};for(let[n,r]of Object.entries(e)){let e=Array.isArray(r)?r.join(`, `):r;e.trim()&&(t[n]=e.trim())}return t}const qd=u.cssPrefix,Jd=`__other__`;function Yd({fields:e,strings:t,submitLabel:n,onSubmit:r,skipLabel:i,onSkip:a,footerHint:o,submitOnEnter:s,disabled:c,initialValues:l,hideActions:u,fieldTypeLabels:d,rootTestId:f,submitTestId:p,skipTestId:m}){let[h,g]=L(()=>({...$d(e),...l})),[_,v]=L({}),[y,b]=L({});function x(e){y[e]&&b(t=>({...t,[e]:``}))}function S(e,t){g(n=>({...n,[e]:t})),x(e)}function C(e,t){v(n=>({...n,[e]:t})),x(e)}function w(n){if(n.preventDefault(),c)return;let i=ef(e,h,_),a=Gd(e,i,t);Object.keys(a).length>0?b(a):r(Kd(i))}function T(e){!s||e.key!==`Enter`||e.shiftKey||e.isComposing||e.target&&`tagName`in e.target&&e.target.tagName===`TEXTAREA`&&w(e)}return/* @__PURE__ */ U(`form`,{class:`${qd}-form`,onSubmit:w,onKeyDown:T,"data-testid":f,noValidate:!0,children:[e.map(e=>/* @__PURE__ */ U(Xd,{field:e,value:h[e.name],otherText:_[e.name]??``,error:y[e.name],disabled:c,typeLabel:d?.[e.name],strings:t,onChange:t=>S(e.name,t),onOtherChange:t=>C(e.name,t)},e.name)),u?null:/* @__PURE__ */ U(`div`,{class:`${qd}-form-actions`,children:[o?/* @__PURE__ */ U(`span`,{class:`${qd}-form-hint`,children:o}):null,i&&a?/* @__PURE__ */ U(`button`,{type:`button`,class:`${qd}-form-skip`,onClick:a,disabled:c,"data-testid":m,children:i}):null,/* @__PURE__ */ U(`button`,{type:`submit`,class:`${qd}-form-submit`,disabled:c,"data-testid":p,children:n})]})]})}function Xd({field:e,value:t,otherText:n,error:r,disabled:i,typeLabel:a,strings:o,onChange:s,onOtherChange:c}){let l=Zd({field:e,value:t,otherText:n,disabled:i,strings:o,onChange:s,onOtherChange:c,fieldTid:Wl(Z.formField,e.name)});return/* @__PURE__ */ U(`label`,{class:`${qd}-field`,"data-field":e.name,"data-invalid":r?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${qd}-field-head`,children:[/* @__PURE__ */ U(`span`,{class:`${qd}-field-label`,children:[e.label,e.required??!0?/* @__PURE__ */ U(`span`,{class:`${qd}-field-req`,"aria-hidden":`true`,children:` *`}):null]}),a?/* @__PURE__ */ U(`span`,{class:`${qd}-field-type`,children:a}):null]}),l,e.validationHint&&!r?/* @__PURE__ */ U(`span`,{class:`${qd}-field-hint`,children:e.validationHint}):null,r?/* @__PURE__ */ U(`span`,{class:`${qd}-field-error`,role:`alert`,children:r}):null]})}function Zd(e){let{field:t,value:n,otherText:r,disabled:i,strings:a,onChange:o,onOtherChange:s,fieldTid:c}=e,l=typeof n==`string`?n:``,u=t.type===`select`?a.formOtherPlaceholder:t.placeholder??a.formOtherPlaceholder,d=t.allowOther&&l===Jd?/* @__PURE__ */ U(`input`,{class:`${qd}-field-input`,value:r,placeholder:u,disabled:i,onInput:e=>s(e.currentTarget.value)}):null;switch(t.type){case`textarea`:return/* @__PURE__ */ U(`textarea`,{class:`${qd}-field-input`,rows:3,value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c});case`select`:return/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`select`,{class:`${qd}-field-input`,value:l,disabled:i,onChange:e=>o(e.currentTarget.value),"data-testid":c,children:[/* @__PURE__ */ U(`option`,{value:``,children:t.placeholder??`—`}),(t.options??[]).map(e=>/* @__PURE__ */ U(`option`,{value:e.value,children:e.label??e.value},e.value)),t.allowOther?/* @__PURE__ */ U(`option`,{value:Jd,children:a.formOther}):null]}),d]});case`radio`:return/* @__PURE__ */ U(`div`,{class:`${qd}-field-choices`,role:`radiogroup`,"data-testid":c,children:[(t.options??[]).map(e=>/* @__PURE__ */ U(`label`,{class:`${qd}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`radio`,name:`${qd}-${t.name}`,checked:l===e.value,disabled:i,onChange:()=>o(e.value)}),/* @__PURE__ */ U(`span`,{children:e.label??e.value})]},e.value)),t.allowOther?/* @__PURE__ */ U(`label`,{class:`${qd}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`radio`,name:`${qd}-${t.name}`,checked:l===Jd,disabled:i,onChange:()=>o(Jd)}),/* @__PURE__ */ U(`span`,{children:a.formOther})]}):null,d]});case`checkbox`:return/* @__PURE__ */ U(`label`,{class:`${qd}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`checkbox`,checked:l===`true`,disabled:i,onChange:e=>o(e.currentTarget.checked?`true`:``),"data-testid":c}),/* @__PURE__ */ U(`span`,{children:t.placeholder??t.label})]});case`multiselect`:{let e=Array.isArray(n)?n:[];function l(t,n){return o(n?[...e,t]:e.filter(e=>e!==t))}return/* @__PURE__ */ U(`div`,{class:`${qd}-field-choices`,"data-testid":c,children:[(t.options??[]).map(t=>/* @__PURE__ */ U(`label`,{class:`${qd}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`checkbox`,checked:e.includes(t.value),disabled:i,onChange:e=>l(t.value,e.currentTarget.checked)}),/* @__PURE__ */ U(`span`,{children:t.label??t.value})]},t.value)),t.allowOther||(t.options??[]).length===0?/* @__PURE__ */ U(`textarea`,{class:`${qd}-field-input`,rows:2,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.currentTarget.value)}):null]})}default:return/* @__PURE__ */ U(`input`,{...Qd(t.type),class:`${qd}-field-input`,value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c})}}function Qd(e){switch(e){case`number`:return{type:e};case`email`:return{type:e};case`tel`:return{type:e};case`url`:return{type:e};case`date`:case`time`:return{type:e};default:return{type:`text`}}}function $d(e){let t={};for(let n of e)n.defaultValue!=null&&(t[n.name]=n.type===`multiselect`?n.defaultValue.split(`,`).map(e=>e.trim()).filter(Boolean):n.defaultValue);return t}function ef(e,t,n){let r={...t};for(let i of e){let e=n[i.name]?.trim();if((i.type===`radio`||i.type===`select`)&&i.allowOther&&t[i.name]===Jd)r[i.name]=e??``;else if(i.type===`multiselect`&&e){let n=e.split(/[,\n;]+/).map(e=>e.trim()).filter(Boolean),a=t[i.name];r[i.name]=[...Array.isArray(a)?a:[],...n]}}return r}const tf=u.cssPrefix;function nf({form:e,strings:t,onSubmit:n,onSkip:r}){return/* @__PURE__ */ U(`div`,{class:`${tf}-form-gate`,"data-testid":Z.formGate,children:[e.title?/* @__PURE__ */ U(`h3`,{class:`${tf}-form-gate-title`,children:e.title}):null,e.description?/* @__PURE__ */ U(`p`,{class:`${tf}-form-gate-desc`,children:e.description}):null,/* @__PURE__ */ U(Yd,{fields:e.fields,strings:t,submitLabel:e.submitLabel??t.formSubmit,onSubmit:n,skipLabel:e.skippable?t.formSkip:void 0,onSkip:e.skippable?r:void 0,submitTestId:Z.formSubmit,skipTestId:Z.formSkip})]})}function rf({marker:e,strings:t,onFill:n}){let r=e.outcome===`skipped`,i=r?t.formSkipped:t.formSubmitted,a=e.title?/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`span`,{children:e.title}),/* @__PURE__ */ U(`span`,{class:`${tf}-sr-only`,children:i})]}):/* @__PURE__ */ U(`span`,{children:i}),o=e.form?.reviewable??!1,s=!r&&o&&e.values&&Object.keys(e.values).length>0?e.values:null;if(s){function t(t){return e.form?.fields.find(e=>e.name===t)?.label??t}return/* @__PURE__ */ U(`details`,{class:`${tf}-form-done`,"data-outcome":e.outcome,"data-testid":Z.formDone,children:[/* @__PURE__ */ U(`summary`,{class:`${tf}-form-done-summary`,"data-testid":Z.formDoneToggle,children:[/* @__PURE__ */ U(ul,{}),a,/* @__PURE__ */ U(Yc,{})]}),/* @__PURE__ */ U(`dl`,{class:`${tf}-form-answers`,"data-testid":Z.formAnswers,children:Object.entries(s).map(([e,n])=>/* @__PURE__ */ U(`div`,{class:`${tf}-form-answer`,children:[/* @__PURE__ */ U(`dt`,{children:t(e)}),/* @__PURE__ */ U(`dd`,{children:n})]},e))})]})}return/* @__PURE__ */ U(`div`,{class:`${tf}-form-done`,"data-outcome":e.outcome,"data-testid":Z.formDone,role:`status`,children:[U(r?ll:ul,{}),a,r&&e.form?.reopenable&&n?/* @__PURE__ */ U(`button`,{type:`button`,class:`${tf}-form-done-fill`,"data-testid":Z.formFill,onClick:n,children:t.formFillOut}):null]})}var af=Object.assign;function of(e,t){for(var n in e)if(n!=`__source`&&e[n]!==t[n])return!0;for(var r in t)if(r!=`__source`&&!(r in e))return!0;return!1}var sf=/^(-|f[lo].*[^se]$|g.{5,}[^ps]$|z|o[pr]|(W.{5})?[lL]i.*(t|mp)$|an|(bo|s).{4}Im|sca|m.{6}[ds]|ta|c.*[st]$|wido|ini|asp|fill|st)/;function cf(e,t){function n(e){var n=this.props.ref;return n!=e.ref&&n&&(typeof n==`function`?n(null):n.current=null),t?!t(this.props,e)||n!=e.ref:of(this.props,e)}function r(t){return this.shouldComponentUpdate=n,Xe(e,t)}return r.displayName=`Memo(`+(e.displayName||e.name)+`)`,r.prototype.isReactComponent=!0,r.type=e,r}var lf=Symbol.for(`react.element`),uf=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(?!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,df=/[A-Z0-9]/g,ff=typeof document<`u`,pf=function(e){return/fil|che|rad/.test(e)};Qe.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(Qe.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var mf=P.event;P.event=function(e){return mf&&(e=mf(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var hf={configurable:!0,get:function(){return this.class}},gf=P.vnode;P.vnode=function(e){if(typeof e.type==`string`)(function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a==`value`&&`defaultValue`in t&&o==null||ff&&a==`children`&&n==`noscript`||a==`class`||a==`className`)){if(a==`style`&&o&&o.constructor==Object){var s=void 0;for(var c in o)typeof o[c]!=`number`||sf.test(c)||(s||(s=o=af({},o)),o[c]+=`px`)}else if(a==`defaultValue`&&`value`in t&&t.value==null)a=`value`;else if(a==`download`&&!0===o)o=``;else if(a==`translate`&&o===`no`)o=!1;else if(a[0]==`o`&&a[1]==`n`){var l=a.toLowerCase();l==`ondoubleclick`?a=`ondblclick`:l!=`onchange`||n!=`input`&&n!=`textarea`||pf(t.type)?l==`onfocus`?a=`onfocusin`:l==`onblur`&&(a=`onfocusout`):l=a=`oninput`,l==`oninput`&&r[a=l]&&(a=`oninputCapture`)}else i&&uf.test(a)?a=a.replace(df,`-$&`).toLowerCase():o===null&&(o=void 0);r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=ot(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=ot(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",hf)):t.className&&(r.class=r.className=t.className),e.props=r})(e);else if(typeof e.type==`function`&&(`ref`in e.props&&`prototype`in e.type&&e.type.prototype.render&&(e.ref=e.props.ref,delete e.props.ref),e.type.defaultProps)){var t=af({},e.props);for(var n in e.type.defaultProps)t[n]===void 0&&(t[n]=e.type.defaultProps[n]);e.props=t}e.ref&&!(`ref`in e.props)&&Object.defineProperty(e.props,"ref",{value:e.ref,configurable:!0,writable:!0}),e.$$typeof=lf,gf&&gf(e)};function _f(e){return e?(e.startsWith(`tool:`)?e.slice(5):e)===`ask-user-questions`:!1}const vf=u.cssPrefix;function yf({messageId:e,initial:t,strings:n,onFeedback:r}){let[i,a]=L(t);R(()=>a(t),[e,t]);function o(t){let n=i===t?null:t;a(n),r(e,n)}return/* @__PURE__ */ U(`div`,{class:`${vf}-feedback`,role:`group`,"data-testid":Z.messageFeedback,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${vf}-msg-action`,"data-active":i===`up`?`true`:void 0,"aria-pressed":i===`up`,"aria-label":n.feedbackUp,title:n.feedbackUp,onClick:()=>o(`up`),"data-testid":Z.feedbackUp,children:/* @__PURE__ */ U(Ll,{})}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${vf}-msg-action`,"data-active":i===`down`?`true`:void 0,"aria-pressed":i===`down`,"aria-label":n.feedbackDown,title:n.feedbackDown,onClick:()=>o(`down`),"data-testid":Z.feedbackDown,children:/* @__PURE__ */ U(Rl,{})}),/* @__PURE__ */ U(`span`,{class:`${vf}-sr-only`,role:`status`,"aria-live":`polite`,children:i?n.feedbackThanks:``})]})}const bf=u.cssPrefix;function xf(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function Sf(e){if(e.startsWith(`tool:`)||e.startsWith(`tool-`))return e.slice(5);let t=e.indexOf(`__`),n=e.slice(t+2);return t>0&&n?`${xf(e.slice(0,t))} · ${xf(n)}`:e}function Cf(e,t){let n=e===`output-available`||e===`output-error`||e===`output-denied`,r=e===`approval-responded`||t?.approved!==void 0;return{terminal:n,responded:r,decided:n||r}}function wf({status:e,icon:t,label:n}){return/* @__PURE__ */ U(`span`,{class:`${bf}-toolui-badge ${bf}-toolui-status`,"data-status":e,children:[/* @__PURE__ */ U(`span`,{class:`${bf}-toolui-status-icon`,children:t}),n]})}function Tf(e,t){return e===`output-error`?`error`:e===`output-denied`||t?.approved===!1?`denied`:e===`output-available`?`completed`:e===`approval-responded`||t?.approved===!0?`responded`:e===`approval-requested`?`awaiting`:`running`}function Ef(e,t,n={}){return n.submitted?`responded`:n.incomplete?`incomplete`:kf(Tf(e,t),n.superseded,n.live??!0)}function Df({status:e}){return U(e===`denied`||e===`error`||e===`superseded`||e===`incomplete`?Hl:e===`completed`||e===`responded`?Vl:Bl,{})}function Of(e,t){switch(e){case`awaiting`:return t.statusAwaiting;case`responded`:return t.statusResponded;case`completed`:return t.statusCompleted;case`denied`:return t.statusDenied;case`error`:return t.statusError;case`superseded`:return t.statusSuperseded;case`incomplete`:return t.statusIncomplete;default:return t.statusRunning}}function kf(e,t,n){return t&&(e===`awaiting`||e===`running`)?`superseded`:!n&&e===`running`?`error`:e}function Af({state:e,approval:t,strings:n,superseded:r,live:i=!0,submitted:a=!1,incomplete:o=!1}){let s=Ef(e,t,{superseded:r,live:i,submitted:a,incomplete:o});return/* @__PURE__ */ U(wf,{status:s,icon:/* @__PURE__ */ U(Df,{status:s}),label:Of(s,n)})}function jf({name:e,state:t,approval:n,strings:r,superseded:i,live:a,submitted:o,incomplete:s}){return/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`span`,{class:`${bf}-toolui-name-pill`,children:[/* @__PURE__ */ U(zl,{}),/* @__PURE__ */ U(`span`,{class:`${bf}-toolui-name-text`,children:e})]}),/* @__PURE__ */ U(Af,{state:t,approval:n,strings:r,superseded:i,live:a,submitted:o,incomplete:s}),/* @__PURE__ */ U(`span`,{class:`${bf}-toolui-chevron`,children:/* @__PURE__ */ U(hl,{})})]})}function Mf({part:e,strings:t,testid:n,superseded:r,live:i,submitted:a,incomplete:o}){let s=B(()=>ri(()=>e.inputSig.value),[e]),c=B(()=>ri(()=>e.outputSig.value),[e]),l=B(()=>ri(()=>e.errorSig.value),[e]),u=B(()=>ri(()=>e.stateSig.value),[e]),d=B(()=>ri(()=>e.approvalSig.value),[e]),f=B(()=>ri(()=>Te(e.toolMetadata)&&Ae(e.errorSig.value)),[e]),p=o===!0||f.value;return/* @__PURE__ */ U(`details`,{class:`${bf}-toolui ${bf}-toolui-collapsible`,"data-testid":n,children:[/* @__PURE__ */ U(`summary`,{class:`${bf}-toolui-head`,children:/* @__PURE__ */ U(jf,{name:Sf(e.toolName),state:u.value,approval:d.value,strings:t,superseded:r,live:i,submitted:a,incomplete:p})}),/* @__PURE__ */ U(Nf,{label:t.toolParameters,value:s.value}),c.value===void 0?null:/* @__PURE__ */ U(Nf,{label:t.toolResult,value:c.value}),l.value&&!p?/* @__PURE__ */ U(Nf,{label:t.statusError,value:l.value,error:!0}):null]})}function Nf({label:e,value:t,error:n}){let r=n?typeof t==`string`?t:``:Ff(Pf(t));return r?/* @__PURE__ */ U(`div`,{class:`${bf}-toolui-section`,children:[/* @__PURE__ */ U(`span`,{class:`${bf}-toolui-label`,children:e}),/* @__PURE__ */ U(`pre`,{class:`${bf}-toolui-code`,"data-error":n?`true`:void 0,children:r})]}):null}function Pf(e){if(e&&typeof e==`object`){let t=e;if(t.storage===`tool-result-ref`&&`summary`in t)return t.summary}return e}function Ff(e){if(e==null)return``;try{let t=typeof e==`string`?e:JSON.stringify(e,null,2);return!t||t===`{}`||t===`[]`||t===`""`?``:t.length>800?`${t.slice(0,800)}…`:t}catch{return``}}function If(e){return e.partsSig.value.some(e=>e.kind===`text`&&e.textSig.value.length>0)}function Lf(e){return e.partsSig.value.some(e=>e.kind===`reasoning`)}function Rf(e){return e.streaming&&!e.bufferedHold&&!(e.reasoningVisible&&e.working)}function zf(e){let{streaming:t,reasoningVisible:n,emptyReply:r,hidden:i}=e,a=e.responseMode===`buffered`&&t,o=t&&!e.hasAnswerText;return{streaming:t,bufferedHold:a,reasoningVisible:n,working:o,showStreamDots:Rf({streaming:t,bufferedHold:a,reasoningVisible:n,working:o}),emptyReply:r,hidden:i}}function Bf(e,t){let n=e.stateSig.value,r=e.approvalSig.value,{terminal:i,responded:a,decided:o}=Cf(n,r),s=t.continuationStreaming===!0&&!o,c=t.superseded&&!o&&!s;return{pill:Ef(n,r,{superseded:c,live:t.live,submitted:s,incomplete:Te(e.toolMetadata)&&Ae(e.errorSig.value)}),state:n,terminal:i,decided:o||s,showApproveReject:!o&&!t.superseded&&!s,showAnswered:a&&!i&&!c,showSubmitted:s,showEdit:a&&t.active&&!i,skipped:c,answeredApproved:r?.approved}}const Vf=u.cssPrefix;function Hf({part:e,strings:t}){let n=e.title||e.filename||e.url||t.sources;return e.url?/* @__PURE__ */ U(`a`,{class:`${Vf}-source`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-testid":Z.source,children:[/* @__PURE__ */ U(`span`,{class:`${Vf}-source-icon`,"aria-hidden":`true`,children:`🔗`}),/* @__PURE__ */ U(`span`,{class:`${Vf}-source-label`,children:n})]}):/* @__PURE__ */ U(`span`,{class:`${Vf}-source`,"data-testid":Z.source,children:[/* @__PURE__ */ U(`span`,{class:`${Vf}-source-icon`,"aria-hidden":`true`,children:`📄`}),/* @__PURE__ */ U(`span`,{class:`${Vf}-source-label`,children:n})]})}const Uf=u.cssPrefix;function Wf({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:i=!1,onDecision:a,onEdit:o}){let s=B(()=>ri(()=>e.approvalSig.value),[e]),c=B(()=>ri(()=>Bf(e,{active:n,superseded:r,continuationStreaming:i})),[e,n,r,i]).value,{terminal:l,showApproveReject:u,showAnswered:d,showSubmitted:f,showEdit:p,skipped:m}=c,h=Sf(e.toolName),g=c.answeredApproved,_=e.toolCallId,v=/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`p`,{class:`${Uf}-toolui-prompt`,children:t.approvalPrompt.replace(`{tool}`,h)}),/* @__PURE__ */ U(`p`,{class:`${Uf}-toolui-subtle`,children:t.approvalBody})]});f?v=/* @__PURE__ */ U(`p`,{class:`${Uf}-toolui-subtle`,children:t.approvalSubmitting}):d&&g!==!1?v=/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`p`,{class:`${Uf}-toolui-prompt`,children:[t.approvalYourResponse.replace(`{decision}`,g?t.approve:t.reject),s.value?.reason?` — ${s.value.reason}`:``]}),p?/* @__PURE__ */ U(`p`,{class:`${Uf}-toolui-subtle`,children:t.approvalEditHint}):null,p?null:/* @__PURE__ */ U(`p`,{class:`${Uf}-toolui-subtle`,children:t.approvalSubmitting})]}):d&&(v=/* @__PURE__ */ U(I,{}));let y=u||f||p||d&&g!==!1;return/* @__PURE__ */ U(`div`,{class:`${Uf}-toolui-group`,"data-testid":c.decided?Z.toolDecision:Z.toolApproval,children:[/* @__PURE__ */ U(Mf,{part:e,strings:t,superseded:m,submitted:f}),m||l||!y?null:/* @__PURE__ */ U(`div`,{class:`${Uf}-toolui ${Uf}-toolui-body`,children:[v,u?/* @__PURE__ */ U(`div`,{class:`${Uf}-toolui-actions`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Uf}-form-skip`,disabled:!n,onClick:()=>a(_,!1),"data-testid":Z.toolReject,children:t.reject}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Uf}-form-submit`,disabled:!n,onClick:()=>a(_,!0),"data-testid":Z.toolApprove,children:t.approve})]}):null,p?/* @__PURE__ */ U(`div`,{class:`${Uf}-toolui-actions`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${Uf}-form-skip`,onClick:()=>o(_),"data-testid":Z.toolEdit,children:t.edit})}):null]})]})}const Gf=[`text`,`email`,`phone`,`number`,`date`,`single-select`,`multi-select`,`boolean`];function Kf(e){return typeof e==`object`&&!!e}function qf(e){let t=Kf(e)?e:{},n=(Array.isArray(t.questions)?t.questions:[]).map(Jf).filter(e=>e!==null);return{intro:Zf(t.intro),questions:n}}function Jf(e,t){if(!Kf(e))return null;let n=Gf.find(t=>t===e.type)??`text`;return{key:Zf(e.key)??`q${t+1}`,question:Zf(e.question)??`Please provide the missing information.`,type:n,options:Array.isArray(e.options)?e.options.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,required:typeof e.required==`boolean`?e.required:void 0,helpText:Zf(e.helpText)}}function Yf(e){switch(e){case`text`:return`textarea`;case`phone`:return`tel`;case`single-select`:case`boolean`:return`radio`;case`multi-select`:return`multiselect`;default:return e}}function Xf(e,t,n){return e.questions.map(e=>{let r=Yf(e.type),i=e.type===`boolean`?[{value:`yes`,label:t},{value:`no`,label:n}]:(e.options??[]).map(e=>({value:e,label:e}));return{name:e.key,label:e.question,type:r,required:e.required??!1,options:i.length>0?i:void 0,validationHint:e.helpText}})}function Zf(e){return typeof e==`string`&&e.trim()?e.trim():void 0}const Qf=u.cssPrefix;function $f({skipped:e,submitted:t,strings:n}){return e?{status:`superseded`,statusLabel:n.inputSkipped}:t?{status:`responded`,statusLabel:n.statusResponded}:{status:`completed`,statusLabel:n.inputAnswered}}const ep={text:`qtypeText`,email:`qtypeEmail`,phone:`qtypePhone`,number:`qtypeNumber`,date:`qtypeDate`,"single-select":`qtypeChooseOne`,"multi-select":`qtypeChooseAny`,boolean:`qtypeBoolean`};function tp(e,t){let n={};for(let r of e)n[r.key]=t[ep[r.type]];return n}function np({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:i=!1,onDecision:a,onEdit:o}){let s=B(()=>ri(()=>e.stateSig.value),[e]).value,c=B(()=>ri(()=>e.approvalSig.value),[e]).value,l=B(()=>ri(()=>qf(e.inputSig.value)),[e]).value,{terminal:u,decided:d}=Cf(s,c),f=d&&c?.approved===!0,p=i&&!d,m=!d&&!r&&!p,h=!m&&!f&&!p,g=f&&n&&!u,_=l.questions,[v,y]=L(null),b=v??(m||f||p),[x,S]=L(!1),C=_.length>1?Uc:yl,w=m?t.inputRequired:t.inputBadge,T=p?/* @__PURE__ */ U(`p`,{class:`${Qf}-toolui-subtle`,children:t.approvalSubmitting}):m?/* @__PURE__ */ U(rp,{req:l,strings:t,active:n,resolve:(t,n)=>a(e.toolCallId,n,t)}):x?/* @__PURE__ */ U(Yd,{fields:Xf(l,t.confirmYes,t.confirmNo),strings:t,submitLabel:t.inputSubmit,onSubmit:()=>{},disabled:!0,hideActions:!0,fieldTypeLabels:tp(_,t),initialValues:f?lp(_,c?.reason):void 0}):/* @__PURE__ */ U(ip,{questions:_,answers:f?cp(c?.reason):{},strings:t}),{status:E,statusLabel:D}=$f({skipped:h,submitted:p,strings:t});return/* @__PURE__ */ U(`details`,{class:`${Qf}-toolui ${Qf}-toolui-collapsible${r?` ${Qf}-toolui-stale`:``}`,open:b,onToggle:e=>{let t=e.currentTarget.open;t!==b&&y(t)},"data-testid":m?Z.toolAskQuestions:Z.toolDecision,children:[/* @__PURE__ */ U(`summary`,{class:`${Qf}-toolui-head`,children:[/* @__PURE__ */ U(`span`,{class:`${Qf}-toolui-q-pill`,children:[/* @__PURE__ */ U(C,{}),w]}),/* @__PURE__ */ U(`span`,{class:`${Qf}-toolui-head-end`,children:[m?null:/* @__PURE__ */ U(wf,{status:E,icon:U(h?Hl:Vl,{}),label:D}),/* @__PURE__ */ U(`span`,{class:`${Qf}-toolui-chevron`,children:/* @__PURE__ */ U(hl,{})})]})]}),/* @__PURE__ */ U(`div`,{class:`${Qf}-toolui-collapse-body`,children:[l.intro?/* @__PURE__ */ U(`div`,{class:`${Qf}-toolui-desc`,children:l.intro}):null,T,m||p?null:/* @__PURE__ */ U(`div`,{class:`${Qf}-toolui-footer`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Qf}-toolui-options-toggle`,onClick:()=>S(e=>!e),"data-testid":Z.toolAskOptions,children:[/* @__PURE__ */ U(`span`,{class:`${Qf}-toolui-options-chevron${x?` ${Qf}-open`:``}`,children:/* @__PURE__ */ U(hl,{})}),x?t.hideOptions:t.showOptions]}),g?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Qf}-form-skip`,onClick:()=>o(e.toolCallId),"data-testid":Z.toolEdit,children:t.edit}):null]})]})]})}function rp({req:e,strings:t,active:n,resolve:r}){let i=Xf(e,t.confirmYes,t.confirmNo),a=e.questions.length===1&&e.questions[0]?.type===`text`;return/* @__PURE__ */ U(Yd,{fields:i,strings:t,disabled:!n,submitLabel:t.inputSubmit,footerHint:a?t.inputSubmitHint:void 0,onSubmit:t=>r(op(e.questions,t),!0),skipLabel:t.inputSkip,onSkip:()=>r(void 0,!1),submitOnEnter:a,fieldTypeLabels:tp(e.questions,t),submitTestId:Z.toolInputSubmit,skipTestId:Z.toolInputSkip})}function ip({questions:e,answers:t,strings:n}){return/* @__PURE__ */ U(`div`,{class:`${Qf}-toolui-summary`,"data-testid":Z.toolAskSummary,children:e.map(e=>/* @__PURE__ */ U(`div`,{class:`${Qf}-field`,children:[/* @__PURE__ */ U(`span`,{class:`${Qf}-field-head`,children:/* @__PURE__ */ U(`span`,{class:`${Qf}-field-label`,children:[e.question,e.required?/* @__PURE__ */ U(`span`,{class:`${Qf}-field-req`,"aria-hidden":`true`,children:` *`}):null]})}),/* @__PURE__ */ U(`p`,{class:`${Qf}-toolui-answer`,children:ap(e,t[e.key],n)||`—`})]},e.key))})}function ap(e,t,n){return e.type===`boolean`?t===`yes`?n.confirmYes:t===`no`?n.confirmNo:t??``:t??``}function op(e,t){let n=e.flatMap(e=>{let n=t[e.key];if(n==null||n.trim()===``)return[];let r=e.type===`multi-select`?n.split(`,`).map(e=>e.trim()).filter(Boolean):n;return[{key:e.key,value:r}]});return JSON.stringify({answers:n})}function sp(e){if(!e)return{};let t=(()=>{try{return JSON.parse(e)}catch{return}})()?.answers;if(!Array.isArray(t))return{};let n={};for(let e of t)if(e&&typeof e==`object`&&`key`in e){let{key:t,value:r}=e;if(typeof t!=`string`)continue;typeof r==`string`?n[t]=r:Array.isArray(r)&&(n[t]=r.filter(e=>typeof e==`string`))}return n}function cp(e){let t=sp(e),n={};for(let[e,r]of Object.entries(t))n[e]=Array.isArray(r)?r.join(`, `):r;return n}function lp(e,t){let n=sp(t),r={};for(let t of e){let e=n[t.key];e!==void 0&&(t.type===`multi-select`?r[t.key]=Array.isArray(e)?e:[e]:r[t.key]=Array.isArray(e)?e[0]??``:e)}return r}function up({part:e,strings:t,live:n,superseded:r}){let i=B(()=>ri(()=>e.inputSig.value),[e]),a=B(()=>ri(()=>e.outputSig.value),[e]),o=B(()=>ri(()=>e.errorSig.value),[e]),s=Te(e.toolMetadata);if(!B(()=>ri(()=>!!Ff(i.value)||!!o.value||!!Ff(Pf(a.value))),[i,a,o]).value&&!s)return null;let c=a.value===void 0&&!o.value;return/* @__PURE__ */ U(Mf,{part:e,strings:t,testid:Z.toolCall,live:n||s&&!r,incomplete:s&&r&&c})}const dp=u.cssPrefix,fp=cf(pp);function pp({message:e,status:t,strings:n,responseMode:r,showReasoning:i,showToolCalls:a,showSources:o,interactive:s=!1,superseded:c=!1,tool:l,onRetry:u,enableMessageFeedback:d=!1,onFeedback:f}){let p=[...B(()=>ri(()=>e.partsSig.value),[e]).value];for(let t of e.attachments??[])t.url&&!p.some(e=>e.kind===`file`&&e.url===t.url)&&p.push({kind:`file`,url:t.url,mediaType:t.mediaType});let m=B(()=>ri(()=>Ys(e)),[e]),h=B(()=>ri(()=>Zs(e)),[e]),g=B(()=>ri(()=>If(e)),[e]),_=B(()=>ri(()=>i&&Lf(e)),[e,i]),v=t===`streaming`,y=e.role===`assistant`&&v,b=zf({streaming:y,responseMode:r,reasoningVisible:_.value,hasAnswerText:g.value,emptyReply:m.value,hidden:h.value}),{bufferedHold:x,working:S,showStreamDots:C}=b;if(b.hidden)return null;let w=hp(e.createdAt),T=e.role===`assistant`||e.role===`operator`,E=d&&!!f&&!!e.serverMessageId&&T&&!v&&t!==`error`&&!m.value,D=v?``:p.filter(e=>e.kind===`text`).map(t=>e.role===`assistant`?ts(t.textSig.peek()):t.textSig.peek()).join(`
59
+ `))if(i!==``){if(i.startsWith(`:`))t?.(i.slice(1).trim());else if(i.startsWith(`data:`)){let e=i.slice(5).replace(/^ /,``);n=n?`${n}\n${e}`:e}else i.startsWith(`id:`)&&(r=i.slice(3).trim())}if(n===`[DONE]`)return`done`;if(!n)return null;try{let e=JSON.parse(n);return ac.trace(`chunk`,{type:e.type,eventId:r}),{chunk:e,eventId:r}}catch(e){throw ac.trace(`frame parse failed`,{errorType:e instanceof Error?e.name:typeof e,payloadLength:n.length}),new ic(`invalid SSE frame`,`network`,void 0,e)}}const J=C.scope(`transport`),lc=6e4,uc=/* @__PURE__ */ new WeakMap;function dc(e){return uc.get(e)}function fc(e,t){return uc.set(e,t),e}function pc(e){return Math.max(e?.upsertRevision??0,e?.read?.revision??0)}function mc(e,t){return e.conversationId===t.conversationId&&e.title===t.title&&e.lastMessageAt===t.lastMessageAt&&e.preview===t.preview&&e.canContinue===t.canContinue&&e.hasUnread===t.hasUnread&&e.controlState===t.controlState}function hc(e,t,n=!0){switch(t.type){case`snapshot`:{let n=new Map(e.map(e=>[e.conversationId,e])),r=e.filter(e=>(dc(e)?.activityRevision??0)>t.requestedRevision).toSorted((e,t)=>dc(t).activityRevision-dc(e).activityRevision),i=new Set(r.map(e=>e.conversationId));return[...r,...t.result.conversations.filter(e=>!i.has(e.conversationId)).map(e=>{let r=n.get(e.conversationId);if(!r)return e;let i=dc(r);return(i?.upsertRevision??0)>t.requestedRevision?r:i?.read&&!r.hasUnread&&i.read.lastMessageAt===e.lastMessageAt?fc({...e,hasUnread:!1},{upsertRevision:0,read:i.read}):e})]}case`read`:{let n=e.findIndex(e=>e.conversationId===t.conversationId&&(t.lastMessageAt===void 0||e.lastMessageAt===t.lastMessageAt));if(n<0)return e;let r=e[n],i=dc(r);if(pc(i)>t.revision)return e;let a=t.lastMessageAt??r.lastMessageAt,o={upsertRevision:i?.upsertRevision??0,...i?.activityRevision===void 0?{}:{activityRevision:i.activityRevision},read:{revision:t.revision,...a?{lastMessageAt:a}:{}}};return r.hasUnread?e.map((e,t)=>t===n?fc({...e,hasUnread:!1},o):e):(fc(r,o),e)}case`upsert`:{let r=e.findIndex(e=>e.conversationId===t.conversation.conversationId);if(r<0&&!n)return e;let i=r<0?void 0:e[r],a=i?dc(i):void 0;if(pc(a)>t.revision)return e;let o=t.activity?t.revision:a?.activityRevision,s={upsertRevision:t.revision,...o===void 0?{}:{activityRevision:o},...!t.conversation.hasUnread&&a?.read?{read:a.read}:{}},c=i?{...i,...t.conversation,title:i.title}:{...t.conversation};return i&&mc(i,c)?(fc(i,s),e):(fc(c,s),t.activity?[c,...e.filter(e=>e.conversationId!==c.conversationId)]:i?e.map((e,t)=>t===r?c:e):[...e,c])}default:return t}}const gc=/* @__PURE__ */ new Set([408,425,429,500,502,503,504]);function _c(e){return 400*2**e+Math.floor(Math.random()*250)}function vc(e){return 6e4+Math.ceil(e/1048576)*15e3}function yc(e){let t=e.get(`retry-after`);if(!t)return null;let n=Number(t),r=Number.isFinite(n)?n*1e3:Date.parse(t)-Date.now();return Number.isFinite(r)&&r>=0?Math.min(r,3e4):null}var bc=class{constructor(e){this.ttlMs=e,s(this,`map`,/* @__PURE__ */ new Map)}getOrFetch(e,t){let n=this.map.get(e);if(n&&performance.now()-n.at<this.ttlMs)return n.result;let r={at:performance.now(),result:t().then(e=>(r.value=e,e)).catch(t=>{throw this.map.get(e)===r&&this.map.delete(e),t})};return this.map.set(e,r),r.result}peek(e){let t=this.map.get(e);if(t?.value!==void 0&&performance.now()-t.at<this.ttlMs)return t.value}update(e){for(let t of this.map.values())if(t.value!==void 0){let n=e(t.value);t.value=n,t.result=Promise.resolve(n)}else t.result=t.result.then(n=>{let r=e(n);return t.value=r,r})}delete(e){this.map.delete(e)}},xc=class{constructor(e){this.opts=e,s(this,`conversationListeners`,/* @__PURE__ */ new Set),s(this,`conversationRevision`,0),s(this,`visitorId`,void 0),s(this,`conversationId`,void 0),s(this,`userContext`,void 0),s(this,`pageContext`,void 0),s(this,`locale`,void 0),s(this,`userTokenSource`,void 0),s(this,`userToken`,void 0),s(this,`userTokenRequest`,void 0),s(this,`conversationsCache`,new bc(1e4)),s(this,`contentCache`,new bc(lc)),s(this,`contentCollectionsCache`,new bc(lc))}setUserToken(e){this.userTokenSource=e,this.userToken=typeof e==`string`&&e||void 0,this.userTokenRequest=typeof e==`function`?this.fetchUserToken():void 0}setContext(e,t){this.userContext=e,this.pageContext=t}setLocale(e){this.locale=e}primeIdentity(e,t){e&&(this.visitorId=e),t&&(this.conversationId=t)}envelope(){let e={_ev:Hn};this.visitorId&&(e.visitorId=this.visitorId),this.conversationId&&(e.conversationId=this.conversationId),this.locale&&(e.locale=this.locale);let t=rc(this.userContext,this.pageContext);return t&&(e[os]=t),e}withEnvelope(e){return{...this.envelope(),...e}}appendEnvelope(e){for(let[t,n]of Object.entries(this.envelope()))e.append(t,n);return e}withEnvelopeQuery(e){let t=new URL(this.url(e));for(let[e,n]of Object.entries(this.envelope()))t.searchParams.has(e)||t.searchParams.set(e,n);return t.toString()}async handshake(e){J.debug(`handshake →`,{visitorId:e.visitorId,conversationId:e.conversationId,locale:e.locale}),this.userTokenRequest&&await this.userTokenRequest;let t=await this.postJson(as.handshake,e,`handshake`);return J.debug(`handshake ←`,{visitorId:t.visitorId,conversationId:t.conversationId,hasWelcome:!!t.welcome,hasConfig:!!t.config,rebind:t.rebind}),this.visitorId=e.visitorId,this.conversationId=t.conversationId,t}async uploadFile(e,t){J.debug(`uploadFile →`,{name:e.name,size:e.size,type:e.type});let n=new FormData;n.append(`file`,e,e.name);let r=await this.postForm(this.uploadPath,n,`upload`,t,vc(e.size));return J.debug(`uploadFile ←`,{id:r.id,url:r.url}),r}async transcribe(e,t=`audio/webm`){J.debug(`transcribe →`,{size:e.size,mimeType:t});let n=new FormData;n.append(`audio`,e,`voice.${Sc(t)}`),n.append(`mimeType`,t);let r=await this.postForm(this.transcribePath,n,`transcribe`);return J.debug(`transcribe ←`,{textLen:r.text.length}),r}subscribeConversationChanges(e){return this.conversationListeners.add(e),()=>this.conversationListeners.delete(e)}publishConversation(e,t=!1){let n={type:`upsert`,conversation:e,revision:++this.conversationRevision,...t?{activity:!0}:{}};this.conversationsCache.update(r=>{let i=r.pagination.page===1,a=r.conversations.some(t=>t.conversationId===e.conversationId),o=hc(r.conversations,n,i&&t),s=i&&o.length>r.pagination.limit?o.slice(0,r.pagination.limit):o;if(!i||!t||a||r.pagination.hasNext)return s===r.conversations?r:{...r,conversations:s};let c=Math.max(r.pagination.total,r.conversations.length)+1,l=Math.ceil(c/r.pagination.limit);return{...r,conversations:s,pagination:{...r.pagination,total:c,totalPages:l,hasNext:r.pagination.page<l}}});for(let e of this.conversationListeners)e(n)}localeCacheKey(e){return`${this.locale??``}|${JSON.stringify(e,Object.keys(e).toSorted())}`}peekConversations(e={}){return this.conversationsCache.peek(this.localeCacheKey(e))}listConversations(e={},t=!1){if((e.page??1)>1)return this.fetchConversations(e);let n=this.localeCacheKey(e),r=this.conversationRevision;t&&this.conversationsCache.delete(n);let i=this.conversationsCache.getOrFetch(n,()=>this.fetchConversations(e));return t?i.then(e=>{let t={type:`snapshot`,result:e,requestedRevision:r};for(let e of this.conversationListeners)e(t);return e}):i}async fetchConversations(e){let t=new URL(this.url(as.listConversations));return e.visitorId&&t.searchParams.set(`visitorId`,e.visitorId),e.page&&t.searchParams.set(`page`,String(e.page)),e.limit&&t.searchParams.set(`limit`,String(e.limit)),e.ids?.length&&t.searchParams.set(`ids`,e.ids.join(`,`)),this.getJson(t.toString(),`listConversations`)}async loadConversation(e,{ids:t=[],beforeId:n,beforeCreatedAt:r}={}){let i=new URL(this.url(as.listMessages));i.searchParams.set(`conversationId`,e),i.searchParams.set(`limit`,`50`),t.length>0&&i.searchParams.set(`ids`,t.join(`,`)),n&&i.searchParams.set(`beforeId`,n),r&&i.searchParams.set(`beforeCreatedAt`,r);let a=await this.getJson(i.toString(),`loadConversation`);return{...a,messages:a.messages.toReversed()}}async markRead(e,t){if(!this.visitorId||!e)return;let n={type:`read`,conversationId:e,...t===void 0?{}:{lastMessageAt:t},revision:++this.conversationRevision};this.conversationsCache.update(e=>{let t=hc(e.conversations,n);return t===e.conversations?e:{...e,conversations:t}});for(let e of this.conversationListeners)e(n);try{await this.postJson(as.markRead,{conversationId:e},`markRead`,!0)}catch(e){J.debug(`markRead failed (non-fatal)`,{err:e})}}async requestOperator(){if(this.visitorId&&this.conversationId)try{return(await this.postJson(as.requestOperator,{},`requestOperator`)).controlState}catch(e){J.debug(`requestOperator failed (non-fatal)`,{err:e});return}}async cancelOperatorRequest(){if(this.visitorId&&this.conversationId)try{return(await this.postJson(as.cancelOperatorRequest,{},`cancelOperatorRequest`)).controlState}catch(e){J.debug(`cancelOperatorRequest failed (non-fatal)`,{err:e});return}}listContent(e={}){return this.contentCache.getOrFetch(this.localeCacheKey(e),()=>this.fetchContent(e))}async fetchContent(e){let t=new URL(this.dataUrl(as.content));for(let[n,r]of Object.entries(e))r!==void 0&&t.searchParams.set(n,Array.isArray(r)?r.join(`,`):String(r));let n=await this.getJson(t.toString(),`listContent`),r=n.items?.map(e=>xt(e,this.locale))??[];return{...n,items:r}}async setContentVote(e){try{await this.postJson(this.dataUrl(as.contentVoteSet),e,`setContentVote`)}catch{}}listContentCollections(e){return this.contentCollectionsCache.getOrFetch(this.localeCacheKey({ids:e}),()=>this.fetchContentCollections(e))}async fetchContentCollections(e){let t=new URL(this.dataUrl(as.contentCollections));return e.length&&t.searchParams.set(`ids`,e.join(`,`)),{items:(await this.getJson(t.toString(),`listContentCollections`)).items?.map(e=>St(e,this.locale))??[]}}async bootstrap(e){let t=new URL(this.dataUrl(as.bootstrap));e&&t.searchParams.set(`conversationId`,e);let n=await this.getJson(t.toString(),`bootstrap`);return{forms:n.forms??[],formSubmissions:n.formSubmissions??[]}}async saveUserPrefs(e){return this.postJson(as.updateSettings,{userPrefs:e},`saveUserPrefs`)}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??as.submitForm}async submitForm(e){J.debug(`submitForm →`,{formId:e.formId,trigger:e.trigger,fields:Object.keys(e.values).length});try{await this.postJson(this.dataUrl(this.submitFormPath),e,`submitForm`)}catch(e){J.debug(`submitForm failed (non-fatal)`,{err:e})}}async submitFeedback(e){J.debug(`submitFeedback →`,{messageId:e.messageId,value:e.value});try{await this.postJson(as.messageFeedback,{messageId:e.messageId,set:{feedback:e.value}},`submitFeedback`)}catch(e){J.debug(`submitFeedback failed (non-fatal)`,{err:e})}}async sendTurn(e,t={}){J.debug(`message →`,{conversationId:e.conversationId,visitorId:e.visitorId,messageCount:e.messages.length});let n=JSON.stringify({...this.withEnvelope(e),[os]:rc(this.userContext,this.pageContext,this.opts.recentHostEvents)}),r=t.keepalive===!0&&new Blob([n]).size<6e4;try{return await this.runWithAbort(async e=>{let t=await this.withFreshUserToken(()=>this.fetchImpl(this.url(as.streamMessage),{method:`POST`,credentials:`omit`,headers:{accept:`application/json`,"content-type":`application/json`,...this.headersFor(this.url(as.streamMessage))},body:n,keepalive:r,signal:e}));if(t.status!==202)throw new ic(`sendTurn failed: expected 202, received ${t.status}`,`server`,t.status);let i;try{i=await t.json()}catch(n){throw e?.aborted?n:new ic(`sendTurn failed: invalid acknowledgement`,`server`,t.status,n)}if(!Cc(i))throw new ic(`sendTurn failed: invalid acknowledgement`,`server`,t.status);return i},void 0,3e4)}catch(e){throw e instanceof ic?e:new ic(`sendTurn failed: network error`,`network`,void 0,e)}}cancelTurn(e,t){this.visitorId&&e&&t&&(J.debug(`cancel stream`,{conversationId:e,runId:t,visitorId:this.visitorId}),this.fetchImpl(this.url(as.cancelStream),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(as.cancelStream))},body:JSON.stringify(this.withEnvelope({conversationId:e,runId:t})),keepalive:!0}).catch(e=>J.debug(`cancel POST failed (non-fatal)`,{err:e})))}async connectResumeStream(e){let t=new AbortController;function n(){return t.abort(e.signal.reason)}e.signal.aborted?n():e.signal.addEventListener(`abort`,n,{once:!0});let r=setTimeout(()=>t.abort(),1e4);function i(){clearTimeout(r),e.signal.removeEventListener(`abort`,n)}let a;try{this.userTokenRequest&&await this.userTokenRequest,a=await this.fetchImpl(this.resumeUrl(),{method:`GET`,credentials:`omit`,headers:{accept:`text/event-stream`,...this.headersFor(this.resumeUrl())},signal:t.signal})}catch(t){return i(),e.signal.aborted||J.debug(`resume-stream fetch failed — reconnecting`,{err:t}),`held`}if(!a.ok)return i(),a.status===401&&typeof this.userTokenSource==`function`?(await this.fetchUserToken(),`held`):a.status===409||gc.has(a.status)?(J.debug(`resume-stream → transient response; reconnecting`,{status:a.status}),`held`):(J.debug(`resume-stream → endpoint unavailable`,{status:a.status}),`unavailable`);if(!a.body)return i(),J.debug(`resume-stream → bodyless response; stopping`,{status:a.status}),`unavailable`;if(!(a.headers.get(`content-type`)??``).includes(`text/event-stream`))return i(),J.debug(`resume-stream → non-SSE response; stopping`),`unavailable`;let o=!1;try{for await(let{chunk:n}of oc(a,t.signal,t=>{o||t!==`connected`||(o=!0,clearTimeout(r),e.onConnected())})){if(e.signal.aborted)return`held`;e.onChunk(n)}}catch(t){if(e.signal.aborted)return`held`;J.debug(`resume-stream segment dropped — reconnecting`,{err:t})}finally{i()}return`held`}resumeUrl(){return this.withEnvelopeQuery(as.streamResume)}async postJson(e,t,n,r=!1){let i=await this.fetchWithRetry(()=>[this.url(e),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(e))},body:JSON.stringify(this.withEnvelope(t)),...r?{keepalive:!0}:{}}],n);return this.assertOk(i,n)}async postForm(e,t,n,r,i){return this.runWithAbort(async r=>{let i=await this.withFreshUserToken(()=>this.fetchImpl(this.url(e),{method:`POST`,credentials:`omit`,headers:this.headersFor(this.url(e)),body:this.appendEnvelope(t),signal:r}));return this.assertOk(i,n)},r,i)}async runWithAbort(e,t,n){if(!t&&n===void 0)return e();let r=new AbortController;function i(){return r.abort(t?.reason)}t?.aborted?i():t?.addEventListener(`abort`,i,{once:!0});let a=n===void 0?void 0:setTimeout(()=>r.abort(),n);try{return await e(r.signal)}finally{a!==void 0&&clearTimeout(a),t?.removeEventListener(`abort`,i)}}async getJson(e,t){let n=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(e),{method:`GET`,credentials:`omit`,headers:{accept:`application/json`,...this.headersFor(this.url(e))}}],t);return this.assertOk(n,t)}async fetchWithRetry(e,t){for(let n=0;;n++){let r;try{r=await this.withFreshUserToken(()=>this.fetchImpl(...e()))}catch(e){if(n>=3)throw new ic(`${t} failed: network error`,`network`,void 0,e);J.debug(`request network error — retrying`,{label:t,attempt:n}),await ue(_c(n));continue}if(r.ok||!gc.has(r.status)||n>=3)return r;let i=yc(r.headers)??_c(n);J.debug(`request retryable status — retrying`,{label:t,status:r.status,attempt:n,wait:i}),await ue(i)}}async assertOk(e,t){if(!e.ok)throw new ic(`${t} failed: ${e.status}`,`server`,e.status);return await e.json()}fetchUserToken(){let e=this.userTokenSource;if(typeof e!=`function`)return Promise.resolve();let t=Promise.resolve().then(e).then(t=>{this.userTokenSource===e&&(this.userToken=t||void 0)},e=>{J.warn(`userToken function failed; continuing as an anonymous visitor`,{err:e})});return this.userTokenRequest=t,t}headersFor(e){let t=!/^https?:\/\//i.test(e)||e.startsWith(`${this.opts.agentApiBaseUrl}/`);return{...this.opts.auth.headers(),...t&&this.userToken?{"x-user-token":this.userToken}:{}}}async withFreshUserToken(e){let t=await e();return t.status!==401||!this.userTokenSource?t:typeof this.userTokenSource==`function`?(await this.fetchUserToken(),e()):(J.warn(`userToken rejected as invalid or expired; pass a function so the widget can fetch a fresh one`),t)}url(e){return/^https?:\/\//i.test(e)?e:`${this.opts.agentApiBaseUrl}${e}`}dataUrl(e){return/^https?:\/\//i.test(e)?e:`${this.opts.dataApiBaseUrl}${e}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function Sc(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 Cc(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`status`),n=Reflect.get(e,`conversationId`),r=Reflect.get(e,`runId`);return t===`accepted`&&typeof n==`string`&&n.length>0&&(r===void 0||typeof r==`string`&&r.length>0)}function wc(e,t,n){switch(e){case`clear`:case`sound`:case`history`:case`language`:case`theme`:case`textSize`:return!0;case`popOut`:return t!==`standalone`&&t!==`page`;case`expand`:return t===`floating`;case`fullscreen`:return t!==`standalone`;case`close`:return t===`standalone`||t===`page`?!1:t!==`inline`||n===`fullscreen`}}function Tc(e,t,n){return wc(`close`,e,t)?n.includes(`close`):!1}function Ec(e,t){return e===`inline`&&t===`fullscreen`?`exit-fullscreen`:`close`}function Dc(e,t,n,r){let i={role:n,text:r};e.emit(`message`,i),t.onMessage?.(i)}function Oc(e){let t=z(e);t.current=e;let n=z(null);return n.current??(n.current=kc(t)),n.current}function kc(e){let t=H(null),n=/* @__PURE__ */ new Set;function r(t){return`${e.current.conversationId()??``}:${t}`}function i(t){return t.frequency===`always`?!1:t.frequency===`conversation`?n.has(r(t.id)):t.id in e.current.persistence.loadFormsDone()}function a(n,r){if(t.value)return;let a=e.current;if(n===`manual`){let e=a.forms.list.find(e=>e.id===r);e&&(t.value={form:e,trigger:`manual`})}else for(let e of a.forms.byTrigger[n]??[]){let r=e.triggers.find(e=>e.kind===n);if(r&&Ac(r,a)&&!i(e)&&jc(e,a)){t.value={form:e,trigger:n};return}}}function o(i,a){let o=t.value;if(!o)return;t.value=null;let{form:s,trigger:c}=o;s.frequency===`conversation`?n.add(r(s.id)):s.frequency!==`always`&&e.current.persistence.saveFormDone(s.id),e.current.onComplete(s,c,i,a)}function s(){let n=t.value;if(!n)return;let r=e.current.forms.list.find(e=>e.id===n.form.id);r&&r!==n.form&&(t.value={form:r,trigger:n.trigger})}return{activeForm:t,fire:a,refresh:s,complete:e=>o(e,!1),skip:()=>o({},!0)}}function Ac(e,t){return e.kind===`after-messages`?t.messageCount()>=Number(e.param??0):e.kind!==`page-area`||t.pageArea()===e.param}function jc(e,t){let n=e.when;if(!n)return!0;if(n.missingContext?.length){let e=t.userContext()??{};if(n.missingContext.some(t=>e[t]!==void 0&&e[t]!==``))return!1}if(n.pageArea&&!(Array.isArray(n.pageArea)?n.pageArea:[n.pageArea]).includes(t.pageArea()??``))return!1;let r=t.messageCount();return!(n.minMessages!=null&&r<n.minMessages||n.maxMessages!=null&&r>n.maxMessages)}function Mc(e){return Object.fromEntries(e.map(e=>[e,[]]))}function Nc(e,t,n){return e.includes(t)?t:e.includes(n)?n:e[0]??``}function Pc(e,t,n){let r=[...new Set(t)],i=H({activeTab:Nc(r,e,``),stacks:Mc(r)});return{sig:i,reconcile(e,t){let a=[...new Set(e)],o=i.value,s=Nc(a,o.activeTab,t),c=Object.fromEntries(a.map(e=>[e,o.stacks[e]??[]])),l=s===o.activeTab&&a.length===Object.keys(o.stacks).length&&a.every(e=>o.stacks[e]===c[e]);r=a,!l&&(i.value={activeTab:s,stacks:c},s!==o.activeTab&&s&&n?.(s))},switchTab(e){e in i.value.stacks&&i.value.activeTab!==e&&(i.value={...i.value,activeTab:e},n?.(e))},open(e,t){let r=i.value;e in r.stacks&&(i.value={activeTab:e,stacks:{...r.stacks,[e]:t?[t]:[]}},r.activeTab!==e&&n?.(e))},push(e){let t=i.value,n=t.stacks[t.activeTab]??[];i.value={...t,stacks:{...t.stacks,[t.activeTab]:[...n,e]}}},pop(){let e=i.value,t=e.stacks[e.activeTab]??[];t.length!==0&&(i.value={...e,stacks:{...e.stacks,[e.activeTab]:t.slice(0,-1)}})},reset(e){i.value={activeTab:Nc(r,e,``),stacks:Mc(r)}}}}function Fc(e){return e.stacks[e.activeTab]??[]}function Ic(e){return Fc(e).at(-1)}function Lc(e){return Fc(e).length===0}function Rc(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`}function zc(e,t,n){if(e===`standalone`||e===`page`)return`fullscreen`;let r=t.initialSize;return r===`expanded`||r===`fullscreen`||r===`normal`?r:n>0&&n<640?`fullscreen`:n>=(t.autoSizeBreakpoint??900)?`expanded`:`normal`}function Bc(e,t,n,r=null){return{panelOpen:e.mode===`inline`||e.mode===`standalone`||e.mode===`page`||(n??!e.startMinimized),panelSize:e.mode!==`standalone`&&e.mode!==`page`&&e.mode!==`inline`&&r?r:zc(e.mode,e.size,t)}}function Vc(){return typeof window>`u`?0:window.innerWidth}const Y={fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`},Hc=`${u.cssPrefix}-icon-dir`;function Uc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z`})})}function Wc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M18 6 6 18M6 6l12 12`})})}function Gc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M12 5v14M5 12h14`})})}function Kc(){return/* @__PURE__ */ U(`svg`,{...Y,class:Hc,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m22 2-7 20-4-9-9-4Z`}),/* @__PURE__ */ U(`path`,{d:`M22 2 11 13`})]})}function qc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M12 19V5M5 12l7-7 7 7`})})}function Jc(){return/* @__PURE__ */ U(`svg`,{...Y,class:Hc,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 20V4l18 8-18 8Z`})})}function Yc(){return/* @__PURE__ */ U(`svg`,{...Y,class:Hc,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m9 18 6-6-6-6`})})}function Xc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}function Zc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`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`})})}function Qc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`rect`,{x:`9`,y:`2`,width:`6`,height:`12`,rx:`3`}),/* @__PURE__ */ U(`path`,{d:`M5 10a7 7 0 0 0 14 0M12 19v3`})]})}function $c(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5`})})}function el(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5`})})}function tl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z`})})}function nl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7`})})}function rl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M14 3h7v7M21 3l-9 9`}),/* @__PURE__ */ U(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`})]})}function il(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,viewBox:`0 0 10 10`,children:/* @__PURE__ */ U(`path`,{d:`M9 1L1 9M9 5L5 9M9 9H9`,strokeWidth:`1.5`})})}function al(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:`currentColor`,stroke:`none`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:`currentColor`,stroke:`none`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:`currentColor`,stroke:`none`})]})}function ol(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10`})})}function sl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6`})})}function cl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M3 18 8 6l5 12M4.7 14h6.6`}),/* @__PURE__ */ U(`path`,{d:`M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2`})]})}function ll(){return/* @__PURE__ */ U(`svg`,{...Y,class:Hc,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m5 6 6 6-6 6M13 6l6 6-6 6`})})}function ul(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M20 6 9 17l-5-5`})})}function dl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M3 3v6h6`}),/* @__PURE__ */ U(`path`,{d:`M3.05 13A9 9 0 1 0 6 5.3L3 9`}),/* @__PURE__ */ U(`path`,{d:`M12 7v5l3 2`})]})}function fl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ U(`path`,{d:`M2 12h20`}),/* @__PURE__ */ U(`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`})]})}function pl(){return/* @__PURE__ */ U(`svg`,{...Y,class:Hc,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})})}function ml(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M12 20h9`}),/* @__PURE__ */ U(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}function hl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m6 9 6 6 6-6`})})}function gl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z`}),/* @__PURE__ */ U(`path`,{d:`M14 2v6h6`})]})}function _l(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z`}),/* @__PURE__ */ U(`path`,{d:`M19 15v4M17 17h4M5 3v2M4 4h2`})]})}function vl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z`})})}function yl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ U(`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}),/* @__PURE__ */ U(`path`,{d:`M12 17h.01`})]})}function bl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m15 4 3 3-9 9-3-3z`}),/* @__PURE__ */ U(`path`,{d:`M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2`})]})}function xl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`rect`,{x:`4`,y:`8`,width:`16`,height:`12`,rx:`2`}),/* @__PURE__ */ U(`path`,{d:`M12 8V4`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`3`,r:`1`}),/* @__PURE__ */ U(`path`,{d:`M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5`})]})}function Sl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M4 14v-2a8 8 0 0 1 16 0v2`}),/* @__PURE__ */ U(`rect`,{x:`2`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),/* @__PURE__ */ U(`rect`,{x:`18`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),/* @__PURE__ */ U(`path`,{d:`M20 20v1a3 3 0 0 1-3 3h-5`})]})}function Cl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`4`}),/* @__PURE__ */ U(`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`})]})}function wl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`11`,cy:`11`,r:`7`}),/* @__PURE__ */ U(`path`,{d:`m21 21-4.3-4.3`})]})}function Tl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]})}function El(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M3 9.5 12 3l9 6.5`}),/* @__PURE__ */ U(`path`,{d:`M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9`})]})}function Dl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m3 11 15-5v12L3 13z`}),/* @__PURE__ */ U(`path`,{d:`M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z`}),/* @__PURE__ */ U(`path`,{d:`M7 15v3a2 2 0 0 0 4 0v-2`}),/* @__PURE__ */ U(`path`,{d:`M21 10a3 3 0 0 1 0 4`})]})}function Ol(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`}),/* @__PURE__ */ U(`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`})]})}function kl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`4`}),/* @__PURE__ */ U(`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`})]})}function Al(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`})})}function jl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`M12 3v18`}),/* @__PURE__ */ U(`path`,{d:`M12 3a9 9 0 0 1 0 18z`,fill:`currentColor`,stroke:`none`})]})}function Ml(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`10.5`,cy:`10.5`,r:`6.5`}),/* @__PURE__ */ U(`path`,{d:`M8 11a2.5 2.5 0 0 0 5 0`}),/* @__PURE__ */ U(`path`,{d:`m20 20-4.4-4.4`})]})}function Nl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`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`}),/* @__PURE__ */ U(`path`,{d:`M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5`})]})}function Pl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M4 18h16`}),/* @__PURE__ */ U(`path`,{d:`M5 18a7 7 0 0 1 14 0`}),/* @__PURE__ */ U(`path`,{d:`M12 8V6`}),/* @__PURE__ */ U(`path`,{d:`M10 6h4`})]})}function Fl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M7 11V6.5a1.5 1.5 0 0 1 3 0V10`}),/* @__PURE__ */ U(`path`,{d:`M10 10V5.5a1.5 1.5 0 0 1 3 0V10`}),/* @__PURE__ */ U(`path`,{d:`M13 10V6.5a1.5 1.5 0 0 1 3 0V12`}),/* @__PURE__ */ U(`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`})]})}function Il(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`rect`,{x:`9`,y:`9`,width:`11`,height:`11`,rx:`2`}),/* @__PURE__ */ U(`path`,{d:`M5 15a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2`})]})}function Ll(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M7 10v11H4a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1z`}),/* @__PURE__ */ U(`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`})]})}function Rl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M17 14V3h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1z`}),/* @__PURE__ */ U(`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`})]})}function zl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`3.5`}),/* @__PURE__ */ U(`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`})]})}function Bl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`M12 7v5l3 2`})]})}function Vl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]})}function Hl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`m15 9-6 6M9 9l6 6`})]})}const Ul={chat:Uc,message:vl,bubbles:Ol,spark:_l,wand:bl,bot:xl,help:yl,lifebuoy:Cl,headset:Sl,search:Ml,sparkles:Nl,concierge:Pl,wave:Fl},X=u.cssPrefix,Z={launcher:`${X}-launcher`,callout:`${X}-callout`,calloutDismiss:`${X}-callout-dismiss`,panel:`${X}-panel`,panelHeader:`${X}-panel-header`,resizeGrip:`${X}-resize-grip`,scrollToBottom:`${X}-scroll-to-bottom`,loadPreviousMessages:`${X}-load-previous-messages`,actionHistory:`${X}-action-history`,actionClose:`${X}-action-close`,langSegment:`${X}-lang-segment`,composer:`${X}-composer`,composerInput:`${X}-composer-input`,composerSend:`${X}-composer-send`,composerStop:`${X}-composer-stop`,compactionStatus:`${X}-compaction-status`,messageQueue:`${X}-message-queue`,queuedMessage:`${X}-queued-message`,queuedMessageRemove:`${X}-queued-message-remove`,composerAttach:`${X}-composer-attach`,composerFileInput:`${X}-composer-file-input`,composerVoice:`${X}-composer-voice`,attachmentChip:`${X}-attachment-chip`,attachmentRemove:`${X}-attachment-remove`,suggestion:`${X}-suggestion`,messageBubble:`${X}-message`,messageRetry:`${X}-message-retry`,messageFile:`${X}-message-file`,messageFeedback:`${X}-message-feedback`,feedbackUp:`${X}-feedback-up`,feedbackDown:`${X}-feedback-down`,messageCopy:`${X}-message-copy`,historyPane:`${X}-history-pane`,historyBack:`${X}-history-back`,historyItem:`${X}-history-item`,historyLoadMore:`${X}-history-load-more`,sidebar:`${X}-sidebar`,sidebarToggle:`${X}-sidebar-toggle`,sidebarNewConversation:`${X}-sidebar-new-conversation`,sidebarItem:`${X}-sidebar-item`,messengerHome:`${X}-messenger-home`,modulesEmpty:`${X}-modules-empty`,tab:`${X}-tab`,tabBadge:`${X}-tab-badge`,homeView:`${X}-home-view`,homeGreeting:`${X}-home-greeting`,homeBrand:`${X}-home-brand`,backHeader:`${X}-back-header`,contentView:`${X}-content-view`,contentScroll:`${X}-content-scroll`,homeSearch:`${X}-home-search`,helpSearch:`${X}-help-search`,homeRecent:`${X}-home-recent`,homeAsk:`${X}-home-ask`,homeWhatsNew:`${X}-home-whats-new`,homeContentRow:`${X}-home-content-row`,helpArticle:`${X}-help-article`,newsItem:`${X}-news-item`,newsMore:`${X}-news-more`,formGate:`${X}-form-gate`,formDone:`${X}-form-done`,formDoneToggle:`${X}-form-done-toggle`,formAnswers:`${X}-form-answers`,formFill:`${X}-form-fill`,formSubmit:`${X}-form-submit`,formSkip:`${X}-form-skip`,formField:`${X}-form-field`,toolAskQuestions:`${X}-tool-ask-questions`,toolInputSubmit:`${X}-tool-input-submit`,toolInputSkip:`${X}-tool-input-skip`,toolApproval:`${X}-tool-approval`,toolApprove:`${X}-tool-approve`,toolReject:`${X}-tool-reject`,toolEdit:`${X}-tool-edit`,toolDecision:`${X}-tool-decision`,typingDots:`${X}-typing-dots`,reasoning:`${X}-reasoning`,toolAskSummary:`${X}-ask-questions-summary`,toolAskOptions:`${X}-ask-questions-options-toggle`,toolCall:`${X}-tool-call`,source:`${X}-source`,operatorRequest:`${X}-operator-request`,operatorBanner:`${X}-operator-banner`,cancelOperatorRequest:`${X}-cancel-operator-request`};function Wl(e,t){return`${e}-${t}`}const Gl=u.cssPrefix;function Kl({onToggle:e,launcher:t,strings:n,leaving:r,edgeTab:i}){let a=t.variant!==`circle`&&!!t.label;return/* @__PURE__ */ U(`button`,{type:`button`,class:`${Gl}-fab`,part:`launcher`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":i?`true`:void 0,"data-leaving":r?`true`:void 0,"data-testid":Z.launcher,onClick:e,"aria-label":n.launcherOpen,children:[ql(t.icon),a?/* @__PURE__ */ U(`span`,{class:`${Gl}-fab-label`,children:At(n,t.label??``)}):null]})}function ql(e){let t=Ul[e];return t?/* @__PURE__ */ U(t,{}):/* @__PURE__ */ U(Jl,{source:e})}function Jl({source:e}){return/* @__PURE__ */ U(`span`,{ref:t=>{t&&Yl(t,e)},"aria-hidden":`true`})}function Yl(e,t){if(e.dataset.svgMounted!==t)try{let n=new DOMParser().parseFromString(t,`image/svg+xml`).documentElement;n.tagName.toLowerCase()===`svg`&&(e.replaceChildren(document.importNode(n,!0)),e.dataset.svgMounted=t)}catch{}}function Xl({callout:e,launcherPosition:t,strings:n,closeLabel:r,onDismiss:i}){let[a,o]=L(!1);return R(()=>{let t=setTimeout(()=>o(!0),e.delayMs);return()=>clearTimeout(t)},[e.delayMs]),R(()=>{if(!a||e.autoDismissMs<=0)return;let t=setTimeout(i,e.autoDismissMs);return()=>clearTimeout(t)},[a,e.autoDismissMs,i]),a?/* @__PURE__ */ U(`div`,{class:`${Gl}-callout`,role:`status`,"data-shape":e.shape,"data-position":Zl(e.position,t),"data-animated":e.animated?`true`:void 0,"data-testid":Z.callout,children:[/* @__PURE__ */ U(`span`,{children:At(n,e.text)}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Gl}-callout-close`,onClick:i,"aria-label":r,title:r,"data-testid":Z.calloutDismiss,children:/* @__PURE__ */ U(Wc,{})})]}):null}function Zl(e,t){let n=t.endsWith(`-right`),r=t.startsWith(`bottom-`);return e===`vertical`?r?`top`:`bottom`:n?`left`:`right`}function Ql(e){function t(t){if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(`a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])`)].filter(e=>e.offsetParent!==null||e===document.activeElement);if(n.length===0){t.preventDefault();return}let r=n[0],i=n[n.length-1];if(!r||!i)return;let a=e.getRootNode().activeElement;t.shiftKey&&a===r?(t.preventDefault(),i.focus()):!t.shiftKey&&a===i&&(t.preventDefault(),r.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}const $l=u.cssPrefix;function eu({title:e,actions:t}){return/* @__PURE__ */ U(`header`,{class:`${$l}-back-header`,part:`header`,"data-variant":`title`,children:[/* @__PURE__ */ U(`span`,{class:`${$l}-back-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ U(`h1`,{class:`${$l}-back-title`,children:e}),t??/* @__PURE__ */ U(`span`,{class:`${$l}-back-spacer`,"aria-hidden":`true`})]})}function tu({title:e,backLabel:t,onBack:n,actions:r,testid:i}){return/* @__PURE__ */ U(`header`,{class:`${$l}-back-header`,part:`header`,"data-testid":i,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${$l}-icon-btn`,onClick:n,"aria-label":t,title:t,children:/* @__PURE__ */ U(pl,{})}),/* @__PURE__ */ U(`h1`,{class:`${$l}-back-title`,children:e}),r??/* @__PURE__ */ U(`span`,{class:`${$l}-back-spacer`,"aria-hidden":`true`})]})}function nu({textSig:e,doneSig:t,generativeUi:n=!1,strings:r=wt}){let i=z(null);return kr(()=>{let a=i.current;if(!a)return;a.classList.add(`${u.cssPrefix}-md`),a.replaceChildren();let o=n?Zo(a,{cssPrefix:u.cssPrefix,strings:r}):void 0,s=$i(o??fa(a)),c=0,l=ci(()=>{let i=e.value,l=t.value;i.length<c&&(o?.dispose(),a.replaceChildren(),o=n?Zo(a,{cssPrefix:u.cssPrefix,strings:r}):void 0,s=$i(o??fa(a)),c=0);let d=i.slice(c);d&&da(s,d),c=i.length,l&&(ea(s),o?.finish())}),d=new MutationObserver(()=>ou(a));d.observe(a,{childList:!0,subtree:!0}),ou(a);function f(e){let t=e.target?.closest?.(`a`);if(!t||!(t instanceof HTMLAnchorElement))return;let n=t.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))}return a.addEventListener(`click`,f),()=>{l(),o?.dispose(),d.disconnect(),a.removeEventListener(`click`,f)}},[e,t,n,r]),/* @__PURE__ */ U(`div`,{ref:i})}function ru({text:e}){return/* @__PURE__ */ U(nu,{textSig:B(()=>H(e),[e]),doneSig:B(()=>H(!0),[])})}const iu=/<(\/?)(?:(Note|Info|Tip|Warning|Danger|Check|Callout)|Tabs?|Steps?|AccordionGroup|Accordion|Expandable|Columns|CardGroup|Card|Frame|CodeGroup|Badge|Icon|Video|Embed|ParamField|ResponseField)\b((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>|(^|\n)([ \t]*)(```[^]*?(?:\n[ \t]*```|$))?/g;function au(e){let t=0,n=``;return e.replace(iu,(e,r,i,a,o,s,c,l)=>{if(r===void 0)return t?s+(l?.split(`\n${c}`).join(`
60
+ `)??n):e;if(r)return t--,i&&(n=n.slice(2)),i?`\n${n}`:``;o||(t++,i&&(n+=`> `));let u={};a.replace(/(\w+)=(["'])(.*?)\2/g,(e,t,n,r)=>u[t]=r);let d=u.href??u.src,f=u.title??u.path??u.query??u.body??u.header??u.name??d;return(i?`> `:``)+(f?`**${d?`[${f}](${d})`:f}**${u.type?` \`${u.type}\``:``}\n${n}`:``)})}function ou(e){for(let t of e.querySelectorAll(`a`)){let e=t.getAttribute(`href`)??``;e&&!e.startsWith(`#`)&&(t.target=`_blank`,t.rel=`noopener noreferrer`)}}const su=/* @__PURE__ */ new Set([11,12,13,14,15,16,17,18,19,31]);function cu(e){let t=``,n=[],r=$i({data:void 0,add_token:(e,r)=>{n.push(r),su.has(r)||(t+=` `)},end_token:()=>{let e=n.pop();e!==void 0&&!su.has(e)&&(t+=` `)},add_text:(e,n)=>void(t+=n),set_attr:()=>void 0});return da(r,e),ea(r),t.replace(/\s+/g,` `).trim()}const lu=u.cssPrefix;function uu({tone:e=`info`,message:t,onRetry:n,strings:r}){return/* @__PURE__ */ U(`div`,{class:`${lu}-module-empty`,role:e===`error`?`alert`:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ U(`span`,{children:t}),n?/* @__PURE__ */ U(`button`,{type:`button`,class:`${lu}-module-retry`,onClick:n,children:r.errorRetry}):null]})}const du=u.cssPrefix,fu=C.scope(`content`);function pu({id:e,title:t,transport:n,strings:r,bus:i,onBack:a,actions:o}){let[s,c]=L(null),[l,u]=L(!1),[d,f]=L(!1),[p,m]=L(0),[h,g]=L(null),_=V(()=>{f(!1),c(null),m(e=>e+1)},[]);R(()=>{let t=!1,r=n.listContentCollections([]).catch(()=>void 0);return Promise.all([n.listContent({ids:[e],limit:1}),r]).then(([n,r])=>{if(t)return;let a=n.items[0];a?(c(a),u(r?.items.find(e=>e.id===a.contentCollectionId)?.settings?.voteAccess===`portal`),i.emit(`contentOpen`,{contentId:e,contentCollectionId:a.contentCollectionId})):f(!0)}).catch(e=>{t||(fu.warn(`listContent (reader) failed`,{err:e}),f(!0))}),()=>{t=!0}},[n,e,p,i]),R(()=>{if(!s)return;let t=setTimeout(()=>i.emit(`contentRead`,{contentId:e}),5e3);return()=>clearTimeout(t)},[s,e,i]);let v=V(t=>{let n=(t.target?.closest?.(`a`))?.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&i.emit(`contentLinkClick`,{contentId:e})},[i,e]);function y(t){g(e),n.setContentVote({contentId:e,value:t})}function b(){return d?/* @__PURE__ */ U(uu,{tone:`error`,message:r.errorGeneric,onRetry:_,strings:r}):s===null?/* @__PURE__ */ U(uu,{message:r.contentLoading,strings:r}):/* @__PURE__ */ U(`article`,{class:`${du}-content`,"data-testid":Z.contentView,onClick:v,children:[s.image?/* @__PURE__ */ U(`img`,{class:`${du}-content-hero`,src:s.image,alt:``,loading:`lazy`}):null,s.description?/* @__PURE__ */ U(`p`,{class:`${du}-content-subtitle`,children:s.description}):null,/* @__PURE__ */ U(ru,{text:au(s.content??``)}),l?/* @__PURE__ */ U(`div`,{class:`${du}-content-vote`,"aria-live":`polite`,children:h===e?r.feedbackThanks:/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`span`,{children:r.contentHelpful}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${du}-module-retry`,onClick:()=>y(1),children:r.confirmYes}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${du}-module-retry`,onClick:()=>y(0),children:r.confirmNo})]})}):null]})}return/* @__PURE__ */ U(`div`,{class:`${du}-module`,children:[/* @__PURE__ */ U(tu,{title:s?.title||t||r.moduleBack,backLabel:r.moduleBack,onBack:a,actions:o,testid:Z.backHeader}),/* @__PURE__ */ U(`div`,{class:`${du}-module-scroll`,"data-testid":Z.contentScroll,children:b()})]})}function mu({itemCount:e,initialFocusIndex:t}){let[n,r]=L(!1),i=z(null),a=z(null),[o,s]=L(-1),c=V(()=>{r(!1),s(-1),i.current?.focus()},[]),l=V(()=>r(e=>!e),[]);return R(()=>{if(!n)return;function e(e){let t=a.current,n=i.current;if(!t||!n)return;let o=e.composedPath();o.includes(t)||o.includes(n)||(r(!1),s(-1))}return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)},[n]),R(()=>{if(!n||e===0)return;let r=t?.()??0;s(r<0||r>=e?0:r)},[n,e,t]),R(()=>{!n||o<0||(a.current?.querySelectorAll(`[role='menuitem']`))?.[o]?.focus()},[n,o]),{open:n,focusIndex:o,triggerRef:i,menuRef:a,toggle:l,close:c,onTriggerKey:V(e=>{(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(!0))},[]),onMenuKey:V(t=>{if(e!==0)switch(t.key){case`Escape`:t.preventDefault(),c();return;case`ArrowDown`:t.preventDefault(),s(t=>(t+1)%e);return;case`ArrowUp`:t.preventDefault(),s(t=>(t-1+e)%e);return;case`Home`:t.preventDefault(),s(0);return;case`End`:t.preventDefault(),s(e-1)}},[e,c])}}function hu({items:e,triggerLabel:t}){let n=u.cssPrefix,r=mu({itemCount:e.length});function i(e){e.disabled||(e.onSelect?.(),e.keepOpen||r.close())}function a(e,t){return e.onSelectValue?.(t)}function o(e,t){let n=t.segments;if(!n?.length)return;let r=Math.max(0,n.findIndex(e=>e.value===t.value)),i=-1;if(e.key===`ArrowRight`||e.key===`Enter`||e.key===` `)i=(r+1)%n.length;else if(e.key===`ArrowLeft`)i=(r-1+n.length)%n.length;else return;e.preventDefault(),e.stopPropagation(),a(t,n[i].value)}return/* @__PURE__ */ U(`div`,{class:`${n}-menu-wrap`,children:[/* @__PURE__ */ U(`button`,{ref:r.triggerRef,type:`button`,class:`${n}-icon-btn`,"aria-label":t,"aria-haspopup":`menu`,"aria-expanded":r.open,title:t,onClick:r.toggle,onKeyDown:r.onTriggerKey,children:/* @__PURE__ */ U(al,{})}),r.open?/* @__PURE__ */ U(`div`,{ref:r.menuRef,class:`${n}-menu`,role:`menu`,"aria-label":t,onKeyDown:r.onMenuKey,tabIndex:-1,children:e.map(e=>e.segments?/* @__PURE__ */ U(`div`,{role:`menuitem`,class:`${n}-menu-item ${n}-menu-item-segmented`,"aria-label":e.label,tabIndex:-1,onKeyDown:t=>o(t,e),children:[e.icon?/* @__PURE__ */ U(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ U(`span`,{class:`${n}-menu-label`,children:e.label}),/* @__PURE__ */ U(`span`,{class:`${n}-segmented`,role:`group`,"aria-label":e.label,children:e.segments.map(t=>{let r=t.value===e.value;return/* @__PURE__ */ U(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,class:`${n}-segment`,"data-on":r?`true`:void 0,lang:t.lang,title:t.value,tabIndex:-1,"data-testid":`${Z.langSegment}-${t.value}`,onClick:()=>a(e,t.value),children:t.label},t.value)})})]},e.id):/* @__PURE__ */ U(`button`,{type:`button`,role:`menuitem`,class:`${n}-menu-item`,"aria-pressed":e.type===`switch`?e.on:void 0,disabled:e.disabled,onClick:()=>i(e),children:[e.icon?/* @__PURE__ */ U(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ U(`span`,{class:`${n}-menu-label`,children:e.label}),e.type===`switch`&&e.on?/* @__PURE__ */ U(`span`,{class:`${n}-menu-check`,"aria-hidden":`true`,children:/* @__PURE__ */ U(ul,{})}):null]},e.id))}):null]})}const gu=u.cssPrefix;function _u(e){let t=typeof matchMedia!=`function`||matchMedia(`(prefers-color-scheme: dark)`).matches;return e===`host`?Zn()===`dark`?`light`:`dark`:e===`auto`?t?`light`:`dark`:t?e===`light`?`dark`:`auto`:e===`dark`?`light`:`auto`}const vu={normal:`large`,large:`small`,small:`normal`};function yu(e){return U(e===`light`?kl:e===`dark`?Al:jl,{})}function bu(e){return(e.split(`-`)[0]??e).toUpperCase()}function xu(e,t){let n;try{n=new URL(e,window.location.href)}catch{return}if(n.protocol===`http:`||n.protocol===`https:`)return t.conversationId&&n.searchParams.set(`chat`,t.conversationId),n.searchParams.set(`widgetId`,t.widgetId),t.publicKey&&n.searchParams.set(`public_key`,t.publicKey),n.searchParams.set(`ai_agent_deployment_id`,t.aiAgentDeploymentId),n.href}function Su({panelProps:e,variant:t}){let{options:n,panelSize:r,feedback:i,onClose:a,onClear:o,onExpand:s,onFullscreen:c,onSoundToggle:l}=e,{onToggleHistory:u,onLocaleChange:d,onThemeChange:f,onTextSizeChange:p}=e,m=n.strings,h=n.mode,g=t===`chat`,_=yi(()=>i.mutedSig.value).value,v=new Set(n.actions);function y(e){return v.has(e)}let b=typeof matchMedia==`function`&&matchMedia(`(max-width: 640px)`).matches;function x(e){return!b&&wc(e,h,r)}let S=n.themeMode,C={auto:m.themeAuto,light:m.themeLight,dark:m.themeDark,host:m.themeAuto},w=n.textSize,T={small:m.textSizeSmall,normal:m.textSizeNormal,large:m.textSizeLarge},E=[];if(g&&y(`clear`)&&E.push({id:`clear`,icon:/* @__PURE__ */ U(ml,{}),label:m.newConversation,onSelect:o}),y(`expand`)&&x(`expand`)){let e=r===`expanded`;E.push({id:`expand`,icon:U(e?el:$c,{}),label:e?m.collapse:m.expand,type:`switch`,on:e,onSelect:s})}if(y(`fullscreen`)&&x(`fullscreen`)){let e=r===`fullscreen`;E.push({id:`fullscreen`,icon:U(e?nl:tl,{}),label:e?m.exitFullscreen:m.fullscreen,type:`switch`,on:e,onSelect:c})}let D=n.popOutUrl,O=n.aiAgentDeploymentId;y(`popOut`)&&D&&O&&wc(`popOut`,h,r)&&E.push({id:`popOut`,icon:/* @__PURE__ */ U(rl,{}),label:m.popOut,onSelect:()=>{let t=xu(D,{conversationId:e.conversationId,widgetId:n.widgetId,publicKey:n.publicKey,aiAgentDeploymentId:O});t&&window.open(t,`_blank`,`noopener,noreferrer`)}}),g&&y(`sound`)&&E.push({id:`sound`,icon:U(_?sl:ol,{}),label:_?m.soundOff:m.soundOn,type:`switch`,on:!_,onSelect:l}),y(`theme`)&&E.push({id:`theme`,icon:yu(S),label:`${m.theme}: ${C[S]}`,onSelect:()=>f(_u(S)),keepOpen:!0}),y(`textSize`)&&E.push({id:`textSize`,icon:/* @__PURE__ */ U(cl,{}),label:`${m.textSize}: ${T[w]}`,onSelect:()=>p(vu[w]),keepOpen:!0}),y(`language`)&&n.availableLocales.length>1&&E.push({id:`language`,icon:/* @__PURE__ */ U(fl,{}),label:m.language,segments:n.availableLocales.map(e=>({value:e,label:bu(e),lang:e})),value:n.locale,onSelectValue:d});let ee=!!a&&Tc(h,r,n.actions),k=g&&y(`history`);return/* @__PURE__ */ U(`div`,{class:`${gu}-header-actions`,children:[k?/* @__PURE__ */ U(`button`,{type:`button`,class:`${gu}-icon-btn`,onClick:u,"aria-label":m.history,title:m.history,"data-testid":Z.actionHistory,children:/* @__PURE__ */ U(dl,{})}):null,E.length>0?/* @__PURE__ */ U(hu,{items:E,triggerLabel:m.moreActions}):null,ee?/* @__PURE__ */ U(`button`,{type:`button`,class:`${gu}-icon-btn`,onClick:a,"aria-label":m.close,title:m.close,"data-testid":Z.actionClose,children:/* @__PURE__ */ U(Wc,{})}):null]})}const Cu={Icon:Ol};function wu(e,t){return e instanceof ic&&e.status===429?t.errorRateLimited:t.errorGeneric}const Tu=u.cssPrefix;function Eu({placeholder:e,onActivate:t}){return/* @__PURE__ */ U(`button`,{type:`button`,class:`${Tu}-home-search`,onClick:t,"data-testid":Z.homeSearch,children:[/* @__PURE__ */ U(`span`,{class:`${Tu}-home-search-text`,children:e}),/* @__PURE__ */ U(`span`,{class:`${Tu}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(wl,{})})]})}function Du({placeholder:e,value:t,onInput:n}){return/* @__PURE__ */ U(`div`,{class:`${Tu}-home-search`,"data-input":`true`,children:[/* @__PURE__ */ U(`input`,{type:`search`,class:`${Tu}-home-search-input`,placeholder:e,value:t,maxLength:200,onInput:e=>n(e.currentTarget.value),"data-testid":Z.helpSearch}),/* @__PURE__ */ U(`span`,{class:`${Tu}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(wl,{})})]})}const Ou=u.cssPrefix;function ku({title:e,subtitle:t,onClick:n,testid:r}){return/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ou}-list-row`,onClick:n,"data-testid":r,children:[/* @__PURE__ */ U(`span`,{class:`${Ou}-list-row-body`,children:[/* @__PURE__ */ U(`span`,{class:`${Ou}-list-row-title`,children:e}),t?/* @__PURE__ */ U(`span`,{class:`${Ou}-list-row-sub`,children:t}):null]}),/* @__PURE__ */ U(`span`,{class:`${Ou}-list-row-chevron`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Yc,{})})]})}const Au=u.cssPrefix,ju=C.scope(`help`);function Mu(e,t,n){let r=new Map(n.map(e=>[e.id,e.title]));return t.map(t=>({id:t,title:r.get(t),rows:e.filter(e=>e.contentCollectionId===t)})).filter(e=>e.rows.length>0)}function Nu({transport:e,strings:t,bus:n},r,i){let[a,o]=L(),s=z(void 0);function c(a){if(!r?.length)return;let c={};s.current=c,o(e=>({search:i,items:[],collections:[],...e,pagination:a>1?e?.pagination:void 0,loading:!0,error:void 0})),Promise.all([e.listContent({contentCollectionIds:r,sortBy:`order`,page:a,limit:20,search:i}),a>1?void 0:e.listContentCollections(r)]).then(([e,t])=>{s.current===c&&(o(n=>({search:i,items:[...a>1?n?.items??[]:[],...e.items],collections:t?.items??n?.collections??[],pagination:e.pagination,loading:!1})),!(a>1)&&(i?n.emit(`contentSearch`,{queryLength:i.length,hitCount:e.pagination.total}):n.emit(`contentView`,{section:`help`,count:e.items.length})))}).catch(e=>{s.current===c&&(ju.warn(`listContent (help) failed`,{err:e,page:a}),o(n=>n&&{...n,loading:!1,error:wu(e,t)}))})}return R(()=>{if(!r?.length)o(void 0);else return c(1),()=>{s.current=void 0}},[e,r,i]),[a,()=>!a?.loading&&c((a?.pagination?.page??0)+1)]}function Pu(e){let{strings:t,config:n,nav:r,panelProps:i}=e,a=n.contentCollectionIds,[o,s]=L(``),[c,l]=L(``),u=Nu(e,a),d=Nu(e,c?a:void 0,c),[f,p]=o.trim()?d:u;R(()=>{let e=setTimeout(()=>l(o.trim()),300);return()=>clearTimeout(e)},[o]);function m(){if(!a?.length)return/* @__PURE__ */ U(uu,{message:t.helpEmpty,strings:t});let e=f?.error?/* @__PURE__ */ U(uu,{tone:`error`,message:f.error,onRetry:p,strings:t}):null;return e&&!f?.pagination?e:!f||!f.pagination&&!f.items.length?/* @__PURE__ */ U(uu,{message:t.helpLoading,strings:t}):f.items.length?/* @__PURE__ */ U(I,{children:[Mu(f.items,a,f.collections).map(e=>/* @__PURE__ */ U(`section`,{class:`${Au}-help-group`,children:[e.title?/* @__PURE__ */ U(`h2`,{class:`${Au}-help-section-title`,children:e.title}):null,/* @__PURE__ */ U(`div`,{class:`${Au}-help-card`,children:e.rows.map(e=>/* @__PURE__ */ U(ku,{title:e.title,subtitle:e.description,onClick:()=>r.push(e.url?{kind:`iframe`,url:e.url,title:e.title}:{kind:`content`,id:e.id,title:e.title}),testid:Wl(Z.helpArticle,e.id)},e.id))})]},e.id)),e,f.pagination?.hasNext&&!e?/* @__PURE__ */ U(`div`,{children:/* @__PURE__ */ U(`div`,{class:`${Au}-help-card`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${Au}-list-row ${Au}-help-more`,onClick:p,"aria-busy":f.loading,children:[f.loading?/* @__PURE__ */ U(`span`,{class:`${Au}-loading-spinner`,"aria-hidden":`true`}):null,t.helpShowMore]})})}):null]}):/* @__PURE__ */ U(uu,{message:f.search?t.helpSearchEmpty.replace(`{query}`,f.search):t.helpEmpty,strings:t})}return/* @__PURE__ */ U(`div`,{class:`${Au}-module`,children:[/* @__PURE__ */ U(eu,{title:t.helpTitle,actions:/* @__PURE__ */ U(Su,{panelProps:i,variant:`plain`})}),/* @__PURE__ */ U(`div`,{class:`${Au}-module-pad`,children:/* @__PURE__ */ U(Du,{placeholder:t.helpSearchPlaceholder,value:o,onInput:s})}),/* @__PURE__ */ U(`div`,{class:`${Au}-help-list`,children:m()})]})}const Fu={Icon:yl,Root:e=>/* @__PURE__ */ U(Pu,{...e})},Iu=C.scope(`attachments`);function Lu(e,t,n){let r=Bu(e),i=[],a=[],o=Uu(n.accept),s=t.reduce((e,t)=>e+t.size,0),c=t.length;for(let e of r){let t=zu(e,c,s,n,o);t?a.push({file:e,reason:t}):(i.push(Hu(e)),s+=e.size,c+=1)}return(i.length||a.length)&&Iu.debug(`ingest`,{accepted:i.length,rejected:a.map(e=>({name:e.file.name,reason:e.reason}))}),{accepted:i,rejected:a}}function Ru(e){try{URL.revokeObjectURL(e.previewUrl)}catch(e){Iu.debug(`revokeObjectURL failed`,{error:e})}}function zu(e,t,n,r,i){return t>=r.maxCount?`count`:n+e.size>r.maxBytes?`bytes`:Wu(e,i)?null:`mime`}function Bu(e){return e?Array.isArray(e)?e.filter(e=>e instanceof File):[...e].map(e=>e instanceof File?e:Vu(e)).filter(e=>e!==null):[]}function Vu(e){let t=e;return!t?.getAsFile||t.kind!==`file`?null:t.getAsFile()}function Hu(e){return{file:e,id:Fn(),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(e=>e.trim().toLowerCase()).filter(Boolean).map(e=>{if(e.startsWith(`.`))return{kind:`ext`,ext:e};let[t=`*`,n=`*`]=e.split(`/`);return{kind:`mime`,type:t,subtype:n}})}function Wu(e,t){if(t.length===0)return!0;let[n=`*`,r=`*`]=(e.type||``).toLowerCase().split(`/`),i=(e.name||``).toLowerCase();return t.some(e=>e.kind===`ext`?i.endsWith(e.ext):e.type===`image`&&e.subtype===`*`&&/\.(heic|heif|avif|bmp|tif|tiff)$/.test(i)?!0:(e.type===`*`||e.type===n)&&(e.subtype===`*`||e.subtype===r))}const Gu=u.cssPrefix;function Ku({attachment:e,onRemove:t,disabled:n=!1}){let r=/^image\/(jpeg|png|gif|webp|avif|bmp|x-ms-bmp|svg\+xml)$/i.test(e.mediaType);return/* @__PURE__ */ U(`span`,{class:`${Gu}-attachment-chip`,title:e.name,"data-testid":Wl(Z.attachmentChip,e.id),children:[r?/* @__PURE__ */ U(`img`,{class:`${Gu}-attachment-thumb`,src:e.previewUrl,alt:``}):/* @__PURE__ */ U(`span`,{class:`${Gu}-attachment-thumb`,"aria-hidden":`true`,children:/* @__PURE__ */ U(gl,{})}),/* @__PURE__ */ U(`span`,{class:`${Gu}-attachment-name`,children:e.name}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Gu}-attachment-remove`,onClick:t,disabled:n,"aria-label":`Remove ${e.name}`,"data-testid":Wl(Z.attachmentRemove,e.id),children:/* @__PURE__ */ U(Wc,{})})]})}const qu={isSupported:!1,start:()=>void 0,stop:()=>void 0,cancel:()=>void 0};function Ju(e,t,n){return e===`disabled`?qu:e===`server`?Qu(n):Yu(t)}function Yu(e){let t=Xu();if(!t)return qu;let n=null,r=0;return{isSupported:!0,start(i,a){let o=n,s=++r;n=null,o?.abort();let c=new t;n=c,c.continuous=!0,c.interimResults=!0,c.lang=e;let l=!1;c.addEventListener(`result`,e=>{if(r!==s||n!==c)return;let t=e,a=``,o=!1;for(let e=t.resultIndex;e<t.results.length;e++){let n=t.results[e];n&&(a+=n[0].transcript,n.isFinal&&(o=!0))}i(a,o)});function u(){l||r!==s||n!==c||(l=!0,n=null,a())}c.addEventListener(`end`,u),c.addEventListener(`error`,u);try{c.start()}catch{u()}},stop(){n?.stop()},cancel(){r++;let e=n;n=null,e?.abort()}}}function Xu(){return window.SpeechRecognition??window.webkitSpeechRecognition}const Zu=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/mp4`];function Qu(e){if(typeof MediaRecorder>`u`||!navigator?.mediaDevices?.getUserMedia)return qu;let t=0,n=null;function r(e){for(let t of e.stream?.getTracks()??[])t.stop();e.stream=null}function i(){t++;let e=n;n=null,e&&(r(e),e.recorder?.state!==`inactive`&&e.recorder?.stop())}async function a(i){if(i.finishing)return;i.finishing=!0;let a=i.recorder?.mimeType??`audio/webm`;r(i);let o=new Blob(i.chunks,{type:a});i.chunks=[];try{let{text:r}=await e(o,a);n===i&&t===i.generation&&r&&i.onText(r,!0)}catch{}finally{n===i&&t===i.generation&&(n=null,i.onEnd())}}return{isSupported:!0,async start(e,o){i();let s={generation:t,recorder:null,stream:null,chunks:[],onText:e,onEnd:o,finishing:!1};n=s;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});if(n!==s||t!==s.generation){for(let t of e.getTracks())t.stop();return}s.stream=e;let r=$u(),i=new MediaRecorder(e,r?{mimeType:r}:void 0);s.recorder=i,i.addEventListener(`dataavailable`,e=>{n===s&&t===s.generation&&e.data.size>0&&s.chunks.push(e.data)}),i.addEventListener(`stop`,()=>{n===s&&t===s.generation&&a(s)}),i.start()}catch{r(s),n===s&&t===s.generation&&(n=null,o())}},stop(){let e=n;e&&(e.recorder?e.recorder.state!==`inactive`&&e.recorder.stop():i())},cancel(){i()}}}function $u(){for(let e of Zu)if(MediaRecorder.isTypeSupported(e))return e}const ed=u.cssPrefix,td=C.scope(`composer`);function nd(e){return e.reduce((e,t)=>e+t.size,0)}const rd={arrowUp:qc,paperPlane:Kc,send:Jc,chevron:Yc};function id(e){return`activeElement`in e}function ad(e){return`host`in e&&`activeElement`in e}function od({options:e,transport:t,feedback:n,bus:r,persistence:i,conversationId:a,isStreaming:o,pageToolRunning:s=!1,isMemoryCompacting:c=!1,canReleaseQueuedMessages:l=!0,queueManualMessages:u=!1,active:d=!0,isPreparing:f=!1,operatorRequestEnabled:p,canRequestOperator:m=!1,controlMode:h=`ai-agent`,onRequestOperator:g,onSend:_,onStop:v,apiRef:y}){let b=e.strings,[x,S]=L(()=>i.loadDraft(a)),[C,w]=L([]),[T,E]=L(()=>i.loadMessageQueue(a).map(e=>({id:e.id,text:e.text,attachments:[]}))),D=z(T),O=z(!1),[ee,k]=L(!1),[te,ne]=L(!1),A=z(!1),j=z(null),re=z(null),ie=z(null),ae=z(0),oe=z(a);oe.current=a;let se=z(d);se.current=d;let ce=z(f);ce.current=f;let le=te||f||!d,M=o&&h===`ai-agent`,ue=M||c&&h===`ai-agent`,de=h===`ai-agent`&&(ue||u||T.length>0),fe=V(e=>{E(t=>{let n=e(t);return i.saveMessageQueue(oe.current,n.filter(e=>e.attachments.length===0).map(({id:e,text:t})=>({id:e,text:t}))),D.current=n,n})},[i]),pe=V(e=>{fe(t=>(t.find(t=>t.id===e)?.attachments.forEach(Ru),t.filter(t=>t.id!==e)))},[fe]),me=V(e=>{S(t=>{let n=typeof e==`function`?e(t):e;return n===t?t:(i.saveDraft(oe.current,n),n)})},[i]),he=e.features.fileUpload,N=e.features.voice,[ge,_e]=L(()=>Ju(N,e.locale,(e,n)=>t.transcribe(e,n))),ve=z(ge);ve.current=ge;let ye=z({mode:N,locale:e.locale,transport:t});R(()=>{let n=ye.current;(n.mode!==N||n.locale!==e.locale||n.transport!==t)&&(ye.current={mode:N,locale:e.locale,transport:t},ae.current++,ve.current.cancel(),ie.current=null,k(!1),_e(Ju(N,e.locale,(e,n)=>t.transcribe(e,n))))},[e.locale,N,t]),kr(()=>()=>{ae.current++,ge.cancel()},[ge]);let be=V(e=>{let t=ie.current;if(t===null)return!1;let n=Math.round(performance.now()-t);return td[e](`voiceStop`,{durationMs:n}),r.emit(`voiceStop`,{durationMs:n}),ie.current=null,!0},[r]),xe=V(()=>{ie.current!==null&&(ge.stop(),k(!1),be(`info`)&&n.play(`voiceStop`))},[be,n,ge]),Se=V(()=>{ae.current++,ge.cancel(),k(!1),be(`info`)&&n.play(`voiceStop`)},[be,n,ge]);R(()=>{(f||!d)&&Se()},[d,Se,f]),R(()=>{let e=j.current;if(!e)return;let t=e.getRootNode(),n=id(t)?t.activeElement:null;n&&e.closest(`.${ed}-panel`)?.contains(n)||e.focus({preventScroll:!0})},[]),R(()=>{let e=j.current;if(!e)return;if(x.length===0){e.style.height=``;return}e.style.height=`auto`;let t=getComputedStyle(e),n=Number.parseFloat(t.getPropertyValue(`--${ed}-textarea-base-height`)),r=Number.parseFloat(t.borderTopWidth)+Number.parseFloat(t.borderBottomWidth),i=Math.min(e.scrollHeight+r,Number.parseFloat(t.maxHeight)),a=Number.parseFloat(t.fontSize)*.7;e.style.height=`${i<n+a?n:i}px`},[x]);let Ce=z(C);Ce.current=C,R(()=>()=>{Ce.current.forEach(Ru);for(let e of D.current)e.attachments.forEach(Ru)},[]),kr(()=>{if(y)return y.current={attachFromDrop:t=>{if(!he||!se.current||A.current||ce.current)return;let n=Lu(t,Ce.current,e.attachments);n.accepted.length!==0&&(td.info(`attach (drop)`,{count:n.accepted.length,totalBytes:nd(n.accepted)}),r.emit(`attach`,{count:n.accepted.length,totalBytes:nd(n.accepted)}),w(e=>[...e,...n.accepted]))},fill:e=>{if(!se.current||A.current||ce.current)return;me(e);let t=j.current;t&&(t.focus({preventScroll:!0}),requestAnimationFrame(()=>t.setSelectionRange(t.value.length,t.value.length)))},acceptQueuedMessage:pe},()=>{y.current&&(y.current=null)}},[y,he,f,e.attachments,pe,me]),R(()=>{let t=j.current;if(!t)return;let n=t.closest(`.${ed}-panel`);if(!n)return;let i=n=>{if(!se.current||A.current||ce.current)return;let i=n.clipboardData;if(!i)return;let a=n.target?.closest?.(`input, textarea, [contenteditable]:not([contenteditable='false'])`);if(a&&a!==t)return;if(he){let t=Lu(i.items,Ce.current,e.attachments);if(t.accepted.length>0){n.preventDefault(),td.info(`attach (paste)`,{count:t.accepted.length,totalBytes:nd(t.accepted)}),r.emit(`attach`,{count:t.accepted.length,totalBytes:nd(t.accepted)}),w(e=>[...e,...t.accepted]);return}}if(a===t)return;let o=i.getData(`text/plain`);o&&(n.preventDefault(),me(e=>e+o),t.focus())};return n.addEventListener(`paste`,i),()=>n.removeEventListener(`paste`,i)},[he,e.attachments,me]);async function we(){let e=x.trim();if(!e&&C.length===0||!d||M||A.current||f)return;Se(),A.current=!0,ne(!0);let t=x,n=C;try{await _(e,n)&&(me(e=>e===t?``:e),w(e=>e===n?(n.forEach(Ru),Ce.current=[],[]):e))}finally{A.current=!1,ne(!1),requestAnimationFrame(()=>{let e=j.current;if(!e||e.disabled||!se.current)return;let t=e.getRootNode(),n=id(t)?t.activeElement:null,r=n?.getAttribute(`data-testid`);if(!(n&&n!==e&&r!==Z.composerSend&&r!==Z.composerStop)){if(ad(t)){let e=t.host.ownerDocument;if(!e.hasFocus())return;let n=e.activeElement;if(n&&n!==t.host&&n!==e.body)return}e.focus({preventScroll:!0})}})}}function Te(){let e=x.trim();if(!e&&C.length===0||!d||!de||A.current||f)return;Se();let t=C;fe(n=>[...n,{id:Fn(),text:e,attachments:t}]),me(``),w(e=>e===t?(Ce.current=[],[]):e),j.current?.focus({preventScroll:!0})}R(()=>{ue&&(O.current=!1)},[ue]),R(()=>{let e=T[0];if(!e||!l||ue||O.current||te||f||!d)return;let t=setTimeout(()=>{O.current=!0,_(e.text,e.attachments,e.id).then(t=>{t?pe(e.id):O.current=!1})},300);return()=>clearTimeout(t)},[d,l,f,_,ue,T,pe,te]);function Ee(e){e.key!==`Enter`||e.shiftKey||e.isComposing||(e.preventDefault(),de&&(x.trim()||C.length>0)?Te():M?v():we())}function De(t){let n=t.target;if(!d||A.current||f){n.value=``;return}let i=Lu(n.files,C,e.attachments);i.accepted.length>0&&(td.info(`attach (file picker)`,{count:i.accepted.length,totalBytes:nd(i.accepted)}),r.emit(`attach`,{count:i.accepted.length,totalBytes:nd(i.accepted)}),w(e=>[...e,...i.accepted])),n.value=``}function Oe(e){!d||A.current||f||(td.info(`removeAttachment`,{id:e}),r.emit(`removeAttachment`,{id:e}),w(t=>{let n=t.find(t=>t.id===e);return n&&Ru(n),t.filter(t=>t.id!==e)}))}function ke(){if(ee){xe();return}if(!d||!ge.isSupported||A.current||f)return;let e=++ae.current;ie.current=performance.now(),td.info(`voiceStart`),r.emit(`voiceStart`,void 0),k(!0),n.play(`voiceStart`),ge.start((t,n)=>{ae.current===e&&se.current&&!ce.current&&!A.current&&n&&me(e=>`${e}${t} `)},()=>{ae.current===e&&se.current&&(k(!1),be(`debug`))})}let Ae=rd[e.composer.sendButton.icon],je=!!(x.trim()||C.length>0),Me=M||s&&!je;return/* @__PURE__ */ U(`div`,{class:`${ed}-composer`,part:`composer`,"data-testid":Z.composer,children:[T.length>0?/* @__PURE__ */ U(`div`,{class:`${ed}-message-queue`,"aria-label":b.queueMessage,"data-testid":Z.messageQueue,children:T.map(e=>/* @__PURE__ */ U(`div`,{class:`${ed}-attachment-chip ${ed}-queued-message`,"data-testid":`${Z.queuedMessage}-${e.id}`,children:[/* @__PURE__ */ U(`span`,{class:`${ed}-attachment-name ${ed}-queued-text`,children:e.text||e.attachments.map(e=>e.name).join(`, `)}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${ed}-attachment-remove`,onClick:()=>pe(e.id),"aria-label":b.removeQueuedMessage,title:b.removeQueuedMessage,"data-testid":`${Z.queuedMessageRemove}-${e.id}`,children:/* @__PURE__ */ U(Wc,{})})]},e.id))}):null,C.length>0?/* @__PURE__ */ U(`div`,{class:`${ed}-attachments`,children:C.map(e=>/* @__PURE__ */ U(Ku,{attachment:e,onRemove:()=>Oe(e.id),disabled:le},e.id))}):null,/* @__PURE__ */ U(`div`,{class:`${ed}-composer-row`,children:[/* @__PURE__ */ U(`div`,{class:`${ed}-composer-actions`,children:[he?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ed}-icon-btn`,onClick:()=>re.current?.click(),disabled:le,"aria-label":b.attach,"data-testid":Z.composerAttach,children:/* @__PURE__ */ U(Zc,{})}):null,ge.isSupported?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ed}-icon-btn`,onClick:ke,disabled:le,"aria-label":ee?b.micStop:b.micStart,"aria-pressed":ee,"data-recording":ee?`true`:void 0,"data-testid":Z.composerVoice,children:/* @__PURE__ */ U(Qc,{})}):null]}),/* @__PURE__ */ U(`textarea`,{ref:j,name:`message`,class:`${ed}-textarea`,rows:1,value:x,placeholder:b.composerPlaceholder,onInput:e=>me(e.currentTarget.value),onKeyDown:Ee,disabled:le,"aria-label":b.composerPlaceholder,"data-testid":Z.composerInput}),de&&je?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ed}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:Te,disabled:le,"aria-label":b.queueMessage,title:b.queueMessage,"data-testid":Z.composerSend,children:/* @__PURE__ */ U(Ae,{})}):null,Me?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ed}-send`,onClick:v,disabled:le,"aria-label":b.stop,"data-testid":Z.composerStop,children:/* @__PURE__ */ U(Xc,{})}):null,!Me&&(!de||!je)?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ed}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:()=>void we(),disabled:le||!x.trim()&&C.length===0,"aria-label":b.send,"data-testid":Z.composerSend,children:/* @__PURE__ */ U(Ae,{})}):null,p&&h===`ai-agent`&&g?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ed}-icon-btn`,onClick:g,disabled:le||!m,"aria-label":b.talkToOperator,title:b.talkToOperator,"data-testid":Z.operatorRequest,children:/* @__PURE__ */ U(Sl,{})}):null]}),/* @__PURE__ */ U(`input`,{ref:re,name:`attachments`,type:`file`,multiple:!0,accept:e.attachments.accept,onChange:De,disabled:le,class:`${ed}-sr-only`,"data-testid":Z.composerFileInput})]})}const sd=u.cssPrefix;function cd({onClick:e,children:t,testid:n}){return e?/* @__PURE__ */ U(`button`,{type:`button`,class:`${sd}-home-card`,"data-interactive":`true`,onClick:e,"data-testid":n,children:t}):/* @__PURE__ */ U(`div`,{class:`${sd}-home-card`,"data-testid":n,children:t})}function ld(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}const ud=u.cssPrefix,dd=C.scope(`news`);function fd(e,t){let n=e?new Date(e):void 0;if(n&&!Number.isNaN(n.getTime()))return new Intl.DateTimeFormat(t,{dateStyle:`medium`}).format(n)}function pd({options:e,transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}){let c=r.contentCollectionIds,[l,u]=L({items:[],loading:!0}),d=z(void 0);function f(e){if(!c?.length)return;let r={};d.current=r,u(e=>({...e,loading:!0,error:void 0})),t.listContent({contentCollectionIds:c,sortBy:`publishedAt`,sortOrder:`desc`,page:e,limit:10}).then(t=>{if(d.current!==r||(u(n=>({items:e>1?[...n.items,...t.items]:t.items,pagination:t.pagination,loading:!1})),e>1))return;a.emit(`contentView`,{section:`news`,count:t.items.length});let n=t.items[0];n&&s.markSeen(n.id)}).catch(t=>{d.current===r&&(dd.warn(`listContent (news) failed`,{err:t,page:e}),u(e=>({...e,loading:!1,error:wu(t,n)})))})}function p(){l.loading||f((l.pagination?.page??0)+1)}R(()=>(u({items:[],loading:!0}),f(1),()=>{d.current=void 0}),[t,c]);function m(t){let n=fd(t.publishedAt,e.locale);return/* @__PURE__ */ U(`button`,{type:`button`,class:`${ud}-news-card`,onClick:()=>i.push({kind:`content`,id:t.id,title:t.title}),"data-testid":Wl(Z.newsItem,t.id),children:[t.image?/* @__PURE__ */ U(`img`,{class:`${ud}-news-hero`,src:t.image,alt:``,loading:`lazy`}):null,/* @__PURE__ */ U(`span`,{class:`${ud}-news-body`,children:[/* @__PURE__ */ U(`span`,{class:`${ud}-news-title`,children:t.title}),n||t.tags?.length?/* @__PURE__ */ U(`span`,{class:`${ud}-news-meta`,children:[n?/* @__PURE__ */ U(`time`,{dateTime:t.publishedAt,children:n}):null,t.tags?.map(e=>/* @__PURE__ */ U(`span`,{class:`${ud}-news-tag`,children:e},e))]}):null,t.description?/* @__PURE__ */ U(`span`,{class:`${ud}-news-summary`,children:t.description}):null]})]},t.id)}function h(){if(!c?.length)return/* @__PURE__ */ U(uu,{message:n.newsEmpty,strings:n});let e=l.error?/* @__PURE__ */ U(uu,{tone:`error`,message:l.error,onRetry:p,strings:n}):null;return e&&!l.pagination?e:l.pagination?l.items.length?/* @__PURE__ */ U(`div`,{class:`${ud}-news-list`,children:[l.items.map(m),e,l.pagination.hasNext&&!e?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ud}-news-more`,onClick:p,"aria-busy":l.loading,"data-testid":Z.newsMore,children:[l.loading?/* @__PURE__ */ U(`span`,{class:`${ud}-loading-spinner`,"aria-hidden":`true`}):null,n.newsShowMore]}):null]}):/* @__PURE__ */ U(uu,{message:n.newsEmpty,strings:n}):/* @__PURE__ */ U(uu,{message:n.newsLoading,strings:n})}return/* @__PURE__ */ U(`div`,{class:`${ud}-module`,children:[/* @__PURE__ */ U(eu,{title:n.newsTitle,actions:/* @__PURE__ */ U(Su,{panelProps:o,variant:`plain`})}),/* @__PURE__ */ U(`div`,{class:`${ud}-module-scroll`,children:h()})]})}const md={Icon:Dl,Root:e=>/* @__PURE__ */ U(pd,{...e})},Q=u.cssPrefix,hd=C.scope(`home`);function gd(e){let t=e.options.userContext?.name,n=e.config.greetingText?At(e.strings,e.config.greetingText):void 0;if(n){let r=t?n.replace(`{name}`,t):n.replace(/\s*\{name\}\s*/,` `).trim(),i=e.strings.homeGreetingLead;return{title:r,subtitle:r.toLowerCase()===i.toLowerCase()?void 0:i}}return t?{title:e.strings.homeGreetingNamed.replace(`{name}`,t),subtitle:e.strings.homeGreetingLead}:{title:e.strings.homeGreeting}}function _d(e,t){return t.url?e.push({kind:`iframe`,url:t.url,title:t.title}):e.push({kind:`content`,id:t.id,title:t.title})}function vd({options:e,onAsk:t}){let[n,r]=L(``),{sendButton:i}=e.composer,a=rd[i.icon];function o(e){e.preventDefault();let i=n.trim();i&&(r(``),t(i))}return/* @__PURE__ */ U(`form`,{class:`${Q}-home-search ${Q}-home-ask`,"data-input":`true`,onSubmit:o,"data-testid":Z.homeAsk,children:[/* @__PURE__ */ U(`input`,{type:`text`,class:`${Q}-home-search-input`,placeholder:e.strings.homeAskPlaceholder,"aria-label":e.strings.homeAskPlaceholder,value:n,enterKeyHint:`send`,onInput:e=>r(e.currentTarget.value)}),/* @__PURE__ */ U(`button`,{type:`submit`,class:`${Q}-send`,"data-shape":i.shape,"data-variant":i.variant,disabled:!n.trim(),"aria-label":e.strings.send,children:/* @__PURE__ */ U(a,{})})]})}function yd(e,t){return hc(e,t,t.type!==`upsert`||t.activity===!0)}function bd(e){let{transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}=e,[c,l]=L(null),[u,d]=L([]),f=r.contentCollectionIds?.join(`,`),p=e.options.modules.list.some(e=>e.layout===`chat`);R(()=>{if(r.showRecentConversations===!1)return;let e=!1,n=!0,i=[],a=t.subscribeConversationChanges(e=>{n&&i.push(e),l(t=>yd(t?[t]:[],e)[0]??null)});return t.listConversations({limit:p?50:1}).then(t=>{if(e)return;let r=i.reduce(yd,t.conversations);i=[],n=!1,l(r[0]??null)}).catch(t=>{e||(i=[],n=!1,hd.warn(`listConversations (home) failed`,{err:t}))}),()=>{e=!0,a()}},[t,r.showRecentConversations,p]),R(()=>{if(!r.contentCollectionIds?.length)return;let e=!1;return t.listContent({contentCollectionIds:r.contentCollectionIds,pinned:!0,limit:6}).then(t=>{e||(d(t.items),a.emit(`contentView`,{section:`home`,count:t.items.length}))}).catch(t=>!e&&hd.warn(`listContent (home) failed`,{err:t})),()=>{e=!0}},[t,f,a]);let m=gd(e),h=r.userAvatars??[],g=r.status,_=g?.text?At(n,g.text):n.homeStatus,v=r.contentBlockTitle?At(n,r.contentBlockTitle):n.homeContentTitle,y=s.item,b=fd(y?.publishedAt,e.options.locale);return/* @__PURE__ */ U(`div`,{class:`${Q}-module ${Q}-home`,"data-testid":Z.homeView,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-scroll`,children:[/* @__PURE__ */ U(`div`,{class:`${Q}-home-hero`,children:[/* @__PURE__ */ U(`div`,{class:`${Q}-home-hero-top`,children:[r.brandName?/* @__PURE__ */ U(`span`,{class:`${Q}-home-brand`,"data-testid":Z.homeBrand,children:r.brandName}):/* @__PURE__ */ U(`span`,{class:`${Q}-home-brand-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ U(`div`,{class:`${Q}-home-hero-actions`,children:[h.length>0?/* @__PURE__ */ U(`div`,{class:`${Q}-home-avatars`,children:h.map(e=>/* @__PURE__ */ U(`span`,{class:`${Q}-home-avatar`,title:e.role?`${e.name} · ${e.role}`:e.name,children:e.avatar?/* @__PURE__ */ U(`img`,{src:e.avatar,alt:``,loading:`lazy`}):/* @__PURE__ */ U(`span`,{children:ld(e.name)})},e.name))}):null,/* @__PURE__ */ U(Su,{panelProps:o,variant:`plain`})]})]}),r.showGreeting===!1?null:/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`h1`,{class:`${Q}-home-greeting`,"data-testid":Z.homeGreeting,children:m.title}),m.subtitle?/* @__PURE__ */ U(`p`,{class:`${Q}-home-lead`,children:m.subtitle}):null]})]}),/* @__PURE__ */ U(`div`,{class:`${Q}-home-cards`,children:[p?/* @__PURE__ */ U(vd,{options:e.options,onAsk:e=>i.startNewConversation(e)}):null,r.showSearchBar===!1?null:/* @__PURE__ */ U(Eu,{placeholder:n.homeSearchPlaceholder,onActivate:()=>i.switchToLayout(`help`)}),y?/* @__PURE__ */ U(cd,{onClick:()=>{s.markSeen(y.id),i.push({kind:`content`,id:y.id,title:y.title})},testid:Z.homeWhatsNew,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-recent-row`,"data-unread":s.unseen?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Dl,{})}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-body`,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-title`,children:n.homeWhatsNew}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-preview`,children:b?`${y.title} · ${b}`:y.title})]}),s.unseen?/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-dot`,role:`img`,"aria-label":n.newsUnseen}):null]})}):null,c?/* @__PURE__ */ U(cd,{onClick:()=>i.selectConversation(c),testid:Z.homeRecent,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-recent-row`,"data-unread":c.hasUnread?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Ol,{})}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-body`,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-title`,children:c.title}),c.preview?/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-preview`,children:cu(c.preview)}):null]}),c.hasUnread?/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-dot`,"aria-label":`Unread`}):null]})}):null,g?/* @__PURE__ */ U(cd,{onClick:g.url?()=>i.push({kind:`iframe`,url:g.url,title:_}):void 0,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-status`,"data-level":g.level??`operational`,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-status-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Tl,{})}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-status-text`,children:_})]})}):null,u.length>0?/* @__PURE__ */ U(`section`,{class:`${Q}-home-content`,children:[/* @__PURE__ */ U(`div`,{class:`${Q}-home-content-title`,children:v}),/* @__PURE__ */ U(`div`,{class:`${Q}-home-content-list`,children:u.map(e=>/* @__PURE__ */ U(ku,{title:e.title,subtitle:e.description,onClick:()=>_d(i,e),testid:Wl(Z.homeContentRow,e.id)},e.id))})]}):null]})]})})}const xd={chat:Cu,home:{Icon:El,Root:e=>/* @__PURE__ */ U(bd,{...e})},help:Fu,news:md},Sd=u.cssPrefix;function Cd({modules:e,activeTab:t,strings:n,hasUnread:r,onSelect:i}){return/* @__PURE__ */ U(`nav`,{class:`${Sd}-tabbar`,role:`tablist`,"aria-label":n.panelTitle,children:e.map(e=>{let a=xd[e.layout].Icon,o=e.id===t,s=e.layout===`chat`&&r;return/* @__PURE__ */ U(`button`,{type:`button`,role:`tab`,"aria-selected":o,class:`${Sd}-tab`,onClick:()=>i(e.id),"data-testid":Wl(Z.tab,e.id),children:[/* @__PURE__ */ U(`span`,{class:`${Sd}-tab-icon`,"aria-hidden":`true`,children:[/* @__PURE__ */ U(a,{}),s?/* @__PURE__ */ U(`span`,{class:`${Sd}-tab-badge`,"data-testid":Z.tabBadge,"aria-label":`Unread`}):null]}),/* @__PURE__ */ U(`span`,{class:`${Sd}-tab-label`,children:At(n,e.label)})]},e.id)})})}const wd=u.cssPrefix;function Td({url:e,title:t,strings:n,onBack:r,actions:i}){return/* @__PURE__ */ U(`div`,{class:`${wd}-module`,children:[/* @__PURE__ */ U(tu,{title:t||n.moduleBack,backLabel:n.moduleBack,onBack:r,actions:i}),/* @__PURE__ */ U(`iframe`,{class:`${wd}-content-frame`,src:e,title:t||`content`,sandbox:`allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads`,referrerpolicy:`no-referrer`,loading:`lazy`,allow:`fullscreen`})]})}const Ed=u.cssPrefix;function Dd({agent:e,strings:t}){let n=e.status??`online`,r=At(t,e.name),i=e.title?At(t,e.title):null;return/* @__PURE__ */ U(`div`,{class:`${Ed}-agent`,children:[/* @__PURE__ */ U(`div`,{class:`${Ed}-agent-avatar`,"data-status":n,children:e.avatar?/* @__PURE__ */ U(`img`,{src:e.avatar,alt:``}):/* @__PURE__ */ U(`span`,{children:ld(r)})}),/* @__PURE__ */ U(`div`,{class:`${Ed}-agent-meta`,children:[/* @__PURE__ */ U(`strong`,{children:r}),i?/* @__PURE__ */ U(`span`,{children:i}):null]})]})}const Od=[`today`,`yesterday`,`lastWeek`,`older`];function kd(e,t){let n=Date.parse(t);if(!Number.isFinite(n))return`older`;let r=Math.floor((jd(e)-jd(n))/864e5);return r<=0?`today`:r===1?`yesterday`:r<7?`lastWeek`:`older`}function Ad(e,t){let n=/* @__PURE__ */ new Map;for(let r of t){let t=kd(e,r.lastMessageAt),i=n.get(t);i?i.push(r):n.set(t,[r])}return Od.filter(e=>n.has(e)).map(e=>({bucket:e,conversations:n.get(e)}))}function jd(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t.getTime()}const Md=C.scope(`history`),Nd={today:`dateToday`,yesterday:`dateYesterday`,lastWeek:`dateLastWeek`,older:`dateOlder`};function Pd(e,t){let n=t.type!==`upsert`||t.activity===!0;if(t.type===`snapshot`&&t.result.pagination.page===1&&e.pagination.page>1){let r=hc(e.conversations.slice(0,t.result.pagination.limit),t,n);if(t.result.conversations.length===0){if(r.length===0)return t.result;let e=Math.max(t.result.pagination.total,r.length);return{...t.result,conversations:r,pagination:{...t.result.pagination,total:e,totalPages:Math.ceil(e/t.result.pagination.limit)}}}let i=new Set(r.map(e=>e.conversationId)),a=e.conversations.slice(t.result.pagination.limit).filter(e=>!i.has(e.conversationId)),o=e.pagination.page,s={...t.result.pagination,page:o,hasPrev:o>1,hasNext:o<t.result.pagination.totalPages};return{conversations:[...r,...a],pagination:s}}let r=hc(e.conversations,t,n);return r===e.conversations?e:{...t.type===`snapshot`?t.result:e,conversations:r}}function Fd(e,t,n){let r=Date.parse(e);return Number.isFinite(r)?new Date(r).toDateString()===new Date(t).toDateString()?new Intl.DateTimeFormat(n,{hour:`numeric`,minute:`2-digit`}).format(r):t-r<6048e5?new Intl.DateTimeFormat(n,{weekday:`short`}).format(r):new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`}).format(r):``}function Id({transport:e,strings:t,locale:n,persistence:r,onSelect:i,onNewConversation:a}){let o=u.cssPrefix,s=e.peekConversations({limit:50}),[c,l]=L(s?`loaded`:`loading`),[d,f]=L(s),[p,m]=L(!1),h=z(void 0),g=d?.conversations??[],_=d?.pagination;R(()=>{let t=!1,n=!0,i=[],a=e.subscribeConversationChanges(e=>{n&&i.push(e),f(t=>t&&Pd(t,e))});h.current=void 0,m(!1);let o=e.peekConversations({limit:50});return f(o),l(o?`loaded`:`loading`),e.listConversations({limit:50}).then(e=>{if(t)return;let a=e;for(let e of i)a=Pd(a,e);i=[],n=!1,f(a),l(`loaded`),r.saveHistoryCount(a.conversations.length)}).catch(e=>{t||(i=[],n=!1,Md.warn(`listConversations failed`,{err:e}),l(`error`))}),()=>{t=!0,a(),h.current=void 0}},[e,r,n]);async function v(){if(h.current||!_?.hasNext)return;let t={};h.current=t,m(!0);try{let n=await e.listConversations({page:_.page+1,limit:_.limit});if(h.current!==t)return;f(e=>{if(!e)return e;let t=new Set(e.conversations.map(e=>e.conversationId)),i=n.conversations.filter(e=>!t.has(e.conversationId)&&(t.add(e.conversationId),!0)),a={conversations:[...e.conversations,...i],pagination:n.pagination};return r.saveHistoryCount(a.conversations.length),a})}catch(e){if(h.current!==t)return;Md.warn(`listConversations page failed`,{err:e,page:_.page+1})}finally{h.current===t&&(h.current=void 0,m(!1))}}let y=a?/* @__PURE__ */ U(`div`,{class:`${o}-history-footer`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${o}-history-new`,onClick:a,"data-testid":Z.sidebarNewConversation,children:[/* @__PURE__ */ U(Gc,{}),t.newConversation]})}):null;if(c===`loading`){let e=Math.min(r.loadHistoryCount()??3,6);return/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`div`,{class:`${o}-history`,"aria-busy":`true`,"aria-label":t.historyLoading,children:/* @__PURE__ */ U(`div`,{class:`${o}-history-group`,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`div`,{class:`${o}-history-heading`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-heading`})}),/* @__PURE__ */ U(`div`,{class:`${o}-history-card`,children:Array.from({length:Math.max(1,e)},(e,t)=>/* @__PURE__ */ U(`div`,{class:`${o}-history-item ${o}-history-item-skeleton`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-avatar ${o}-skeleton`}),/* @__PURE__ */ U(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-title`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-title`})}),/* @__PURE__ */ U(`span`,{class:`${o}-history-time`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-time`})})]}),/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:/* @__PURE__ */ U(`span`,{class:`${o}-history-preview`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-preview`})})})]})]},t))})]})}),y]})}if(c===`error`||g.length===0)return/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`div`,{class:`${o}-history-empty`,children:t.historyEmpty}),y]});let b=Date.now(),x=Ad(b,g);return/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`div`,{class:`${o}-history`,role:`list`,children:[x.map(e=>/* @__PURE__ */ U(`div`,{class:`${o}-history-group`,children:[/* @__PURE__ */ U(`div`,{class:`${o}-history-heading`,children:t[Nd[e.bucket]]}),/* @__PURE__ */ U(`div`,{class:`${o}-history-card`,children:e.conversations.map(e=>/* @__PURE__ */ U(`div`,{role:`listitem`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${o}-history-item`,onClick:()=>i(e),"data-closed":e.canContinue?void 0:`true`,"data-unread":e.hasUnread?`true`:void 0,"data-testid":Wl(Z.historyItem,e.conversationId),children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(vl,{})}),/* @__PURE__ */ U(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-title`,children:e.title}),/* @__PURE__ */ U(`span`,{class:`${o}-history-time`,children:Fd(e.lastMessageAt,b,n)})]}),/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-preview`,children:e.preview&&cu(e.preview)||(e.canContinue?t.historyContinue:t.conversationClosed)}),e.hasUnread?/* @__PURE__ */ U(`span`,{class:`${o}-history-dot`}):null]})]})]})},e.conversationId))})]},e.bucket)),_?.hasNext?/* @__PURE__ */ U(`div`,{class:`${o}-history-more`,children:/* @__PURE__ */ U(`button`,{type:`button`,onClick:v,disabled:p,"aria-busy":p,"data-testid":Z.historyLoadMore,children:t.loadMoreConversations})}):null]}),y]})}const Ld=u.cssPrefix;function Rd({visible:e,strings:t}){return e?/* @__PURE__ */ U(`div`,{class:`${Ld}-dropzone`,role:`status`,"aria-live":`polite`,children:t.dropZone}):null}const zd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Bd=/^https?:\/\/[^\s.]+\.[^\s]+$/i,Vd=/^[+]?[\d\s().-]{6,}$/;function Hd(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??`{${n}}`))}function Ud(e){return Array.isArray(e)?e.length:+!!e?.trim()}function Wd(e,t,n){let r=e.required??!0,i=e.validation;if(e.type===`multiselect`){let e=Ud(t);return r&&e===0?n.formRequired:e===0?void 0:i?.minSelections!=null&&e<i.minSelections?Hd(n.formChooseAtLeast,{min:i.minSelections}):i?.maxSelections!=null&&e>i.maxSelections?Hd(n.formChooseAtMost,{max:i.maxSelections}):void 0}let a=typeof t==`string`?t.trim():``;if(!a)return r?n.formRequired:void 0;switch(e.type){case`email`:if(!zd.test(a))return n.formInvalidEmail;break;case`url`:if(!Bd.test(a))return n.formInvalidUrl;break;case`tel`:if(!Vd.test(a))return n.formInvalidTel;break;case`number`:{let e=Number(a);if(!Number.isFinite(e))return n.formInvalidNumber;if(i?.min!=null&&e<i.min)return Hd(n.formNumberTooSmall,{min:i.min});if(i?.max!=null&&e>i.max)return Hd(n.formNumberTooLarge,{max:i.max});break}}if(i?.minLength!=null&&a.length<i.minLength)return Hd(n.formTooShort,{min:i.minLength});if(i?.maxLength!=null&&a.length>i.maxLength)return Hd(n.formTooLong,{max:i.maxLength});if(i?.pattern)try{if(!new RegExp(i.pattern).test(a))return n.formPatternMismatch}catch{}}function Gd(e,t,n){let r={};for(let i of e){let e=Wd(i,t[i.name],n);e&&(r[i.name]=e)}return r}function Kd(e){let t={};for(let[n,r]of Object.entries(e)){let e=Array.isArray(r)?r.join(`, `):r;e.trim()&&(t[n]=e.trim())}return t}const qd=u.cssPrefix,Jd=`__other__`;function Yd({fields:e,strings:t,submitLabel:n,onSubmit:r,skipLabel:i,onSkip:a,footerHint:o,submitOnEnter:s,disabled:c,initialValues:l,hideActions:u,fieldTypeLabels:d,rootTestId:f,submitTestId:p,skipTestId:m}){let[h,g]=L(()=>({...$d(e),...l})),[_,v]=L({}),[y,b]=L({});function x(e){y[e]&&b(t=>({...t,[e]:``}))}function S(e,t){g(n=>({...n,[e]:t})),x(e)}function C(e,t){v(n=>({...n,[e]:t})),x(e)}function w(n){if(n.preventDefault(),c)return;let i=ef(e,h,_),a=Gd(e,i,t);Object.keys(a).length>0?b(a):r(Kd(i))}function T(e){!s||e.key!==`Enter`||e.shiftKey||e.isComposing||e.target&&`tagName`in e.target&&e.target.tagName===`TEXTAREA`&&w(e)}return/* @__PURE__ */ U(`form`,{class:`${qd}-form`,onSubmit:w,onKeyDown:T,"data-testid":f,noValidate:!0,children:[e.map(e=>/* @__PURE__ */ U(Xd,{field:e,value:h[e.name],otherText:_[e.name]??``,error:y[e.name],disabled:c,typeLabel:d?.[e.name],strings:t,onChange:t=>S(e.name,t),onOtherChange:t=>C(e.name,t)},e.name)),u?null:/* @__PURE__ */ U(`div`,{class:`${qd}-form-actions`,children:[o?/* @__PURE__ */ U(`span`,{class:`${qd}-form-hint`,children:o}):null,i&&a?/* @__PURE__ */ U(`button`,{type:`button`,class:`${qd}-form-skip`,onClick:a,disabled:c,"data-testid":m,children:i}):null,/* @__PURE__ */ U(`button`,{type:`submit`,class:`${qd}-form-submit`,disabled:c,"data-testid":p,children:n})]})]})}function Xd({field:e,value:t,otherText:n,error:r,disabled:i,typeLabel:a,strings:o,onChange:s,onOtherChange:c}){let l=Zd({field:e,value:t,otherText:n,disabled:i,strings:o,onChange:s,onOtherChange:c,fieldTid:Wl(Z.formField,e.name)});return/* @__PURE__ */ U(`label`,{class:`${qd}-field`,"data-field":e.name,"data-invalid":r?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${qd}-field-head`,children:[/* @__PURE__ */ U(`span`,{class:`${qd}-field-label`,children:[e.label,e.required??!0?/* @__PURE__ */ U(`span`,{class:`${qd}-field-req`,"aria-hidden":`true`,children:` *`}):null]}),a?/* @__PURE__ */ U(`span`,{class:`${qd}-field-type`,children:a}):null]}),l,e.validationHint&&!r?/* @__PURE__ */ U(`span`,{class:`${qd}-field-hint`,children:e.validationHint}):null,r?/* @__PURE__ */ U(`span`,{class:`${qd}-field-error`,role:`alert`,children:r}):null]})}function Zd(e){let{field:t,value:n,otherText:r,disabled:i,strings:a,onChange:o,onOtherChange:s,fieldTid:c}=e,l=typeof n==`string`?n:``,u=t.type===`select`?a.formOtherPlaceholder:t.placeholder??a.formOtherPlaceholder,d=t.allowOther&&l===Jd?/* @__PURE__ */ U(`input`,{class:`${qd}-field-input`,value:r,placeholder:u,disabled:i,onInput:e=>s(e.currentTarget.value)}):null;switch(t.type){case`textarea`:return/* @__PURE__ */ U(`textarea`,{class:`${qd}-field-input`,rows:3,value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c});case`select`:return/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`select`,{class:`${qd}-field-input`,value:l,disabled:i,onChange:e=>o(e.currentTarget.value),"data-testid":c,children:[/* @__PURE__ */ U(`option`,{value:``,children:t.placeholder??`—`}),(t.options??[]).map(e=>/* @__PURE__ */ U(`option`,{value:e.value,children:e.label??e.value},e.value)),t.allowOther?/* @__PURE__ */ U(`option`,{value:Jd,children:a.formOther}):null]}),d]});case`radio`:return/* @__PURE__ */ U(`div`,{class:`${qd}-field-choices`,role:`radiogroup`,"data-testid":c,children:[(t.options??[]).map(e=>/* @__PURE__ */ U(`label`,{class:`${qd}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`radio`,name:`${qd}-${t.name}`,checked:l===e.value,disabled:i,onChange:()=>o(e.value)}),/* @__PURE__ */ U(`span`,{children:e.label??e.value})]},e.value)),t.allowOther?/* @__PURE__ */ U(`label`,{class:`${qd}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`radio`,name:`${qd}-${t.name}`,checked:l===Jd,disabled:i,onChange:()=>o(Jd)}),/* @__PURE__ */ U(`span`,{children:a.formOther})]}):null,d]});case`checkbox`:return/* @__PURE__ */ U(`label`,{class:`${qd}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`checkbox`,checked:l===`true`,disabled:i,onChange:e=>o(e.currentTarget.checked?`true`:``),"data-testid":c}),/* @__PURE__ */ U(`span`,{children:t.placeholder??t.label})]});case`multiselect`:{let e=Array.isArray(n)?n:[];function l(t,n){return o(n?[...e,t]:e.filter(e=>e!==t))}return/* @__PURE__ */ U(`div`,{class:`${qd}-field-choices`,"data-testid":c,children:[(t.options??[]).map(t=>/* @__PURE__ */ U(`label`,{class:`${qd}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`checkbox`,checked:e.includes(t.value),disabled:i,onChange:e=>l(t.value,e.currentTarget.checked)}),/* @__PURE__ */ U(`span`,{children:t.label??t.value})]},t.value)),t.allowOther||(t.options??[]).length===0?/* @__PURE__ */ U(`textarea`,{class:`${qd}-field-input`,rows:2,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.currentTarget.value)}):null]})}default:return/* @__PURE__ */ U(`input`,{...Qd(t.type),class:`${qd}-field-input`,value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c})}}function Qd(e){switch(e){case`number`:return{type:e};case`email`:return{type:e};case`tel`:return{type:e};case`url`:return{type:e};case`date`:case`time`:return{type:e};default:return{type:`text`}}}function $d(e){let t={};for(let n of e)n.defaultValue!=null&&(t[n.name]=n.type===`multiselect`?n.defaultValue.split(`,`).map(e=>e.trim()).filter(Boolean):n.defaultValue);return t}function ef(e,t,n){let r={...t};for(let i of e){let e=n[i.name]?.trim();if((i.type===`radio`||i.type===`select`)&&i.allowOther&&t[i.name]===Jd)r[i.name]=e??``;else if(i.type===`multiselect`&&e){let n=e.split(/[,\n;]+/).map(e=>e.trim()).filter(Boolean),a=t[i.name];r[i.name]=[...Array.isArray(a)?a:[],...n]}}return r}const tf=u.cssPrefix;function nf({form:e,strings:t,onSubmit:n,onSkip:r}){return/* @__PURE__ */ U(`div`,{class:`${tf}-form-gate`,"data-testid":Z.formGate,children:[e.title?/* @__PURE__ */ U(`h3`,{class:`${tf}-form-gate-title`,children:e.title}):null,e.description?/* @__PURE__ */ U(`p`,{class:`${tf}-form-gate-desc`,children:e.description}):null,/* @__PURE__ */ U(Yd,{fields:e.fields,strings:t,submitLabel:e.submitLabel??t.formSubmit,onSubmit:n,skipLabel:e.skippable?t.formSkip:void 0,onSkip:e.skippable?r:void 0,submitTestId:Z.formSubmit,skipTestId:Z.formSkip})]})}function rf({marker:e,strings:t,onFill:n}){let r=e.outcome===`skipped`,i=r?t.formSkipped:t.formSubmitted,a=e.title?/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`span`,{children:e.title}),/* @__PURE__ */ U(`span`,{class:`${tf}-sr-only`,children:i})]}):/* @__PURE__ */ U(`span`,{children:i}),o=e.form?.reviewable??!1,s=!r&&o&&e.values&&Object.keys(e.values).length>0?e.values:null;if(s){function t(t){return e.form?.fields.find(e=>e.name===t)?.label??t}return/* @__PURE__ */ U(`details`,{class:`${tf}-form-done`,"data-outcome":e.outcome,"data-testid":Z.formDone,children:[/* @__PURE__ */ U(`summary`,{class:`${tf}-form-done-summary`,"data-testid":Z.formDoneToggle,children:[/* @__PURE__ */ U(ul,{}),a,/* @__PURE__ */ U(Yc,{})]}),/* @__PURE__ */ U(`dl`,{class:`${tf}-form-answers`,"data-testid":Z.formAnswers,children:Object.entries(s).map(([e,n])=>/* @__PURE__ */ U(`div`,{class:`${tf}-form-answer`,children:[/* @__PURE__ */ U(`dt`,{children:t(e)}),/* @__PURE__ */ U(`dd`,{children:n})]},e))})]})}return/* @__PURE__ */ U(`div`,{class:`${tf}-form-done`,"data-outcome":e.outcome,"data-testid":Z.formDone,role:`status`,children:[U(r?ll:ul,{}),a,r&&e.form?.reopenable&&n?/* @__PURE__ */ U(`button`,{type:`button`,class:`${tf}-form-done-fill`,"data-testid":Z.formFill,onClick:n,children:t.formFillOut}):null]})}var af=Object.assign;function of(e,t){for(var n in e)if(n!=`__source`&&e[n]!==t[n])return!0;for(var r in t)if(r!=`__source`&&!(r in e))return!0;return!1}var sf=/^(-|f[lo].*[^se]$|g.{5,}[^ps]$|z|o[pr]|(W.{5})?[lL]i.*(t|mp)$|an|(bo|s).{4}Im|sca|m.{6}[ds]|ta|c.*[st]$|wido|ini|asp|fill|st)/;function cf(e,t){function n(e){var n=this.props.ref;return n!=e.ref&&n&&(typeof n==`function`?n(null):n.current=null),t?!t(this.props,e)||n!=e.ref:of(this.props,e)}function r(t){return this.shouldComponentUpdate=n,Xe(e,t)}return r.displayName=`Memo(`+(e.displayName||e.name)+`)`,r.prototype.isReactComponent=!0,r.type=e,r}var lf=Symbol.for(`react.element`),uf=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(?!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,df=/[A-Z0-9]/g,ff=typeof document<`u`,pf=function(e){return/fil|che|rad/.test(e)};Qe.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(Qe.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var mf=P.event;P.event=function(e){return mf&&(e=mf(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var hf={configurable:!0,get:function(){return this.class}},gf=P.vnode;P.vnode=function(e){if(typeof e.type==`string`)(function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a==`value`&&`defaultValue`in t&&o==null||ff&&a==`children`&&n==`noscript`||a==`class`||a==`className`)){if(a==`style`&&o&&o.constructor==Object){var s=void 0;for(var c in o)typeof o[c]!=`number`||sf.test(c)||(s||(s=o=af({},o)),o[c]+=`px`)}else if(a==`defaultValue`&&`value`in t&&t.value==null)a=`value`;else if(a==`download`&&!0===o)o=``;else if(a==`translate`&&o===`no`)o=!1;else if(a[0]==`o`&&a[1]==`n`){var l=a.toLowerCase();l==`ondoubleclick`?a=`ondblclick`:l!=`onchange`||n!=`input`&&n!=`textarea`||pf(t.type)?l==`onfocus`?a=`onfocusin`:l==`onblur`&&(a=`onfocusout`):l=a=`oninput`,l==`oninput`&&r[a=l]&&(a=`oninputCapture`)}else i&&uf.test(a)?a=a.replace(df,`-$&`).toLowerCase():o===null&&(o=void 0);r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=ot(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=ot(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",hf)):t.className&&(r.class=r.className=t.className),e.props=r})(e);else if(typeof e.type==`function`&&(`ref`in e.props&&`prototype`in e.type&&e.type.prototype.render&&(e.ref=e.props.ref,delete e.props.ref),e.type.defaultProps)){var t=af({},e.props);for(var n in e.type.defaultProps)t[n]===void 0&&(t[n]=e.type.defaultProps[n]);e.props=t}e.ref&&!(`ref`in e.props)&&Object.defineProperty(e.props,"ref",{value:e.ref,configurable:!0,writable:!0}),e.$$typeof=lf,gf&&gf(e)};function _f(e){return e?(e.startsWith(`tool:`)?e.slice(5):e)===`ask-user-questions`:!1}const vf=u.cssPrefix;function yf({messageId:e,initial:t,strings:n,onFeedback:r}){let[i,a]=L(t);R(()=>a(t),[e,t]);function o(t){let n=i===t?null:t;a(n),r(e,n)}return/* @__PURE__ */ U(`div`,{class:`${vf}-feedback`,role:`group`,"data-testid":Z.messageFeedback,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${vf}-msg-action`,"data-active":i===`up`?`true`:void 0,"aria-pressed":i===`up`,"aria-label":n.feedbackUp,title:n.feedbackUp,onClick:()=>o(`up`),"data-testid":Z.feedbackUp,children:/* @__PURE__ */ U(Ll,{})}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${vf}-msg-action`,"data-active":i===`down`?`true`:void 0,"aria-pressed":i===`down`,"aria-label":n.feedbackDown,title:n.feedbackDown,onClick:()=>o(`down`),"data-testid":Z.feedbackDown,children:/* @__PURE__ */ U(Rl,{})}),/* @__PURE__ */ U(`span`,{class:`${vf}-sr-only`,role:`status`,"aria-live":`polite`,children:i?n.feedbackThanks:``})]})}const bf=u.cssPrefix;function xf(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function Sf(e){if(e.startsWith(`tool:`)||e.startsWith(`tool-`))return e.slice(5);let t=e.indexOf(`__`),n=e.slice(t+2);return t>0&&n?`${xf(e.slice(0,t))} · ${xf(n)}`:e}function Cf(e,t){let n=e===`output-available`||e===`output-error`||e===`output-denied`,r=e===`approval-responded`||t?.approved!==void 0;return{terminal:n,responded:r,decided:n||r}}function wf({status:e,icon:t,label:n}){return/* @__PURE__ */ U(`span`,{class:`${bf}-toolui-badge ${bf}-toolui-status`,"data-status":e,children:[/* @__PURE__ */ U(`span`,{class:`${bf}-toolui-status-icon`,children:t}),n]})}function Tf(e,t){return e===`output-error`?`error`:e===`output-denied`||t?.approved===!1?`denied`:e===`output-available`?`completed`:e===`approval-responded`||t?.approved===!0?`responded`:e===`approval-requested`?`awaiting`:`running`}function Ef(e,t,n={}){return n.submitted?`responded`:n.incomplete?`incomplete`:kf(Tf(e,t),n.superseded,n.live??!0)}function Df({status:e}){return U(e===`denied`||e===`error`||e===`superseded`||e===`incomplete`?Hl:e===`completed`||e===`responded`?Vl:Bl,{})}function Of(e,t){switch(e){case`awaiting`:return t.statusAwaiting;case`responded`:return t.statusResponded;case`completed`:return t.statusCompleted;case`denied`:return t.statusDenied;case`error`:return t.statusError;case`superseded`:return t.statusSuperseded;case`incomplete`:return t.statusIncomplete;default:return t.statusRunning}}function kf(e,t,n){return t&&(e===`awaiting`||e===`running`)?`superseded`:!n&&e===`running`?`error`:e}function Af({state:e,approval:t,strings:n,superseded:r,live:i=!0,submitted:a=!1,incomplete:o=!1}){let s=Ef(e,t,{superseded:r,live:i,submitted:a,incomplete:o});return/* @__PURE__ */ U(wf,{status:s,icon:/* @__PURE__ */ U(Df,{status:s}),label:Of(s,n)})}function jf({name:e,state:t,approval:n,strings:r,superseded:i,live:a,submitted:o,incomplete:s}){return/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`span`,{class:`${bf}-toolui-name-pill`,children:[/* @__PURE__ */ U(zl,{}),/* @__PURE__ */ U(`span`,{class:`${bf}-toolui-name-text`,children:e})]}),/* @__PURE__ */ U(Af,{state:t,approval:n,strings:r,superseded:i,live:a,submitted:o,incomplete:s}),/* @__PURE__ */ U(`span`,{class:`${bf}-toolui-chevron`,children:/* @__PURE__ */ U(hl,{})})]})}function Mf({part:e,strings:t,testid:n,superseded:r,live:i,submitted:a,incomplete:o}){let s=B(()=>ri(()=>e.inputSig.value),[e]),c=B(()=>ri(()=>e.outputSig.value),[e]),l=B(()=>ri(()=>e.errorSig.value),[e]),u=B(()=>ri(()=>e.stateSig.value),[e]),d=B(()=>ri(()=>e.approvalSig.value),[e]),f=B(()=>ri(()=>Te(e.toolMetadata)&&Ae(e.errorSig.value)),[e]),p=o===!0||f.value;return/* @__PURE__ */ U(`details`,{class:`${bf}-toolui ${bf}-toolui-collapsible`,"data-testid":n,children:[/* @__PURE__ */ U(`summary`,{class:`${bf}-toolui-head`,children:/* @__PURE__ */ U(jf,{name:Sf(e.toolName),state:u.value,approval:d.value,strings:t,superseded:r,live:i,submitted:a,incomplete:p})}),/* @__PURE__ */ U(Nf,{label:t.toolParameters,value:s.value}),c.value===void 0?null:/* @__PURE__ */ U(Nf,{label:t.toolResult,value:c.value}),l.value&&!p?/* @__PURE__ */ U(Nf,{label:t.statusError,value:l.value,error:!0}):null]})}function Nf({label:e,value:t,error:n}){let r=n?typeof t==`string`?t:``:Ff(Pf(t));return r?/* @__PURE__ */ U(`div`,{class:`${bf}-toolui-section`,children:[/* @__PURE__ */ U(`span`,{class:`${bf}-toolui-label`,children:e}),/* @__PURE__ */ U(`pre`,{class:`${bf}-toolui-code`,"data-error":n?`true`:void 0,children:r})]}):null}function Pf(e){if(e&&typeof e==`object`){let t=e;if(t.storage===`tool-result-ref`&&`summary`in t)return t.summary}return e}function Ff(e){if(e==null)return``;try{let t=typeof e==`string`?e:JSON.stringify(e,null,2);return!t||t===`{}`||t===`[]`||t===`""`?``:t.length>800?`${t.slice(0,800)}…`:t}catch{return``}}function If(e){return e.partsSig.value.some(e=>e.kind===`text`&&e.textSig.value.length>0)}function Lf(e){return e.partsSig.value.some(e=>e.kind===`reasoning`)}function Rf(e){return e.streaming&&!e.bufferedHold&&!(e.reasoningVisible&&e.working)}function zf(e){let{streaming:t,reasoningVisible:n,emptyReply:r,hidden:i}=e,a=e.responseMode===`buffered`&&t,o=t&&!e.hasAnswerText;return{streaming:t,bufferedHold:a,reasoningVisible:n,working:o,showStreamDots:Rf({streaming:t,bufferedHold:a,reasoningVisible:n,working:o}),emptyReply:r,hidden:i}}function Bf(e,t){let n=e.stateSig.value,r=e.approvalSig.value,{terminal:i,responded:a,decided:o}=Cf(n,r),s=t.continuationStreaming===!0&&!o,c=t.superseded&&!o&&!s;return{pill:Ef(n,r,{superseded:c,live:t.live,submitted:s,incomplete:Te(e.toolMetadata)&&Ae(e.errorSig.value)}),state:n,terminal:i,decided:o||s,showApproveReject:!o&&!t.superseded&&!s,showAnswered:a&&!i&&!c,showSubmitted:s,showEdit:a&&t.active&&!i,skipped:c,answeredApproved:r?.approved}}const Vf=u.cssPrefix;function Hf({part:e,strings:t}){let n=e.title||e.filename||e.url||t.sources;return e.url?/* @__PURE__ */ U(`a`,{class:`${Vf}-source`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-testid":Z.source,children:[/* @__PURE__ */ U(`span`,{class:`${Vf}-source-icon`,"aria-hidden":`true`,children:`🔗`}),/* @__PURE__ */ U(`span`,{class:`${Vf}-source-label`,children:n})]}):/* @__PURE__ */ U(`span`,{class:`${Vf}-source`,"data-testid":Z.source,children:[/* @__PURE__ */ U(`span`,{class:`${Vf}-source-icon`,"aria-hidden":`true`,children:`📄`}),/* @__PURE__ */ U(`span`,{class:`${Vf}-source-label`,children:n})]})}const Uf=u.cssPrefix;function Wf({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:i=!1,onDecision:a,onEdit:o}){let s=B(()=>ri(()=>e.approvalSig.value),[e]),c=B(()=>ri(()=>Bf(e,{active:n,superseded:r,continuationStreaming:i})),[e,n,r,i]).value,{terminal:l,showApproveReject:u,showAnswered:d,showSubmitted:f,showEdit:p,skipped:m}=c,h=Sf(e.toolName),g=c.answeredApproved,_=e.toolCallId,v=/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`p`,{class:`${Uf}-toolui-prompt`,children:t.approvalPrompt.replace(`{tool}`,h)}),/* @__PURE__ */ U(`p`,{class:`${Uf}-toolui-subtle`,children:t.approvalBody})]});f?v=/* @__PURE__ */ U(`p`,{class:`${Uf}-toolui-subtle`,children:t.approvalSubmitting}):d&&g!==!1?v=/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(`p`,{class:`${Uf}-toolui-prompt`,children:[t.approvalYourResponse.replace(`{decision}`,g?t.approve:t.reject),s.value?.reason?` — ${s.value.reason}`:``]}),p?/* @__PURE__ */ U(`p`,{class:`${Uf}-toolui-subtle`,children:t.approvalEditHint}):null,p?null:/* @__PURE__ */ U(`p`,{class:`${Uf}-toolui-subtle`,children:t.approvalSubmitting})]}):d&&(v=/* @__PURE__ */ U(I,{}));let y=u||f||p||d&&g!==!1;return/* @__PURE__ */ U(`div`,{class:`${Uf}-toolui-group`,"data-testid":c.decided?Z.toolDecision:Z.toolApproval,children:[/* @__PURE__ */ U(Mf,{part:e,strings:t,superseded:m,submitted:f}),m||l||!y?null:/* @__PURE__ */ U(`div`,{class:`${Uf}-toolui ${Uf}-toolui-body`,children:[v,u?/* @__PURE__ */ U(`div`,{class:`${Uf}-toolui-actions`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Uf}-form-skip`,disabled:!n,onClick:()=>a(_,!1),"data-testid":Z.toolReject,children:t.reject}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Uf}-form-submit`,disabled:!n,onClick:()=>a(_,!0),"data-testid":Z.toolApprove,children:t.approve})]}):null,p?/* @__PURE__ */ U(`div`,{class:`${Uf}-toolui-actions`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${Uf}-form-skip`,onClick:()=>o(_),"data-testid":Z.toolEdit,children:t.edit})}):null]})]})}const Gf=[`text`,`email`,`phone`,`number`,`date`,`single-select`,`multi-select`,`boolean`];function Kf(e){return typeof e==`object`&&!!e}function qf(e){let t=Kf(e)?e:{},n=(Array.isArray(t.questions)?t.questions:[]).map(Jf).filter(e=>e!==null);return{intro:Zf(t.intro),questions:n}}function Jf(e,t){if(!Kf(e))return null;let n=Gf.find(t=>t===e.type)??`text`;return{key:Zf(e.key)??`q${t+1}`,question:Zf(e.question)??`Please provide the missing information.`,type:n,options:Array.isArray(e.options)?e.options.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,required:typeof e.required==`boolean`?e.required:void 0,helpText:Zf(e.helpText)}}function Yf(e){switch(e){case`text`:return`textarea`;case`phone`:return`tel`;case`single-select`:case`boolean`:return`radio`;case`multi-select`:return`multiselect`;default:return e}}function Xf(e,t,n){return e.questions.map(e=>{let r=Yf(e.type),i=e.type===`boolean`?[{value:`yes`,label:t},{value:`no`,label:n}]:(e.options??[]).map(e=>({value:e,label:e}));return{name:e.key,label:e.question,type:r,required:e.required??!1,options:i.length>0?i:void 0,validationHint:e.helpText}})}function Zf(e){return typeof e==`string`&&e.trim()?e.trim():void 0}const Qf=u.cssPrefix;function $f({skipped:e,submitted:t,strings:n}){return e?{status:`superseded`,statusLabel:n.inputSkipped}:t?{status:`responded`,statusLabel:n.statusResponded}:{status:`completed`,statusLabel:n.inputAnswered}}const ep={text:`qtypeText`,email:`qtypeEmail`,phone:`qtypePhone`,number:`qtypeNumber`,date:`qtypeDate`,"single-select":`qtypeChooseOne`,"multi-select":`qtypeChooseAny`,boolean:`qtypeBoolean`};function tp(e,t){let n={};for(let r of e)n[r.key]=t[ep[r.type]];return n}function np({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:i=!1,onDecision:a,onEdit:o}){let s=B(()=>ri(()=>e.stateSig.value),[e]).value,c=B(()=>ri(()=>e.approvalSig.value),[e]).value,l=B(()=>ri(()=>qf(e.inputSig.value)),[e]).value,{terminal:u,decided:d}=Cf(s,c),f=d&&c?.approved===!0,p=i&&!d,m=!d&&!r&&!p,h=!m&&!f&&!p,g=f&&n&&!u,_=l.questions,[v,y]=L(null),b=v??(m||f||p),[x,S]=L(!1),C=_.length>1?Uc:yl,w=m?t.inputRequired:t.inputBadge,T=p?/* @__PURE__ */ U(`p`,{class:`${Qf}-toolui-subtle`,children:t.approvalSubmitting}):m?/* @__PURE__ */ U(rp,{req:l,strings:t,active:n,resolve:(t,n)=>a(e.toolCallId,n,t)}):x?/* @__PURE__ */ U(Yd,{fields:Xf(l,t.confirmYes,t.confirmNo),strings:t,submitLabel:t.inputSubmit,onSubmit:()=>{},disabled:!0,hideActions:!0,fieldTypeLabels:tp(_,t),initialValues:f?lp(_,c?.reason):void 0}):/* @__PURE__ */ U(ip,{questions:_,answers:f?cp(c?.reason):{},strings:t}),{status:E,statusLabel:D}=$f({skipped:h,submitted:p,strings:t});return/* @__PURE__ */ U(`details`,{class:`${Qf}-toolui ${Qf}-toolui-collapsible${r?` ${Qf}-toolui-stale`:``}`,open:b,onToggle:e=>{let t=e.currentTarget.open;t!==b&&y(t)},"data-testid":m?Z.toolAskQuestions:Z.toolDecision,children:[/* @__PURE__ */ U(`summary`,{class:`${Qf}-toolui-head`,children:[/* @__PURE__ */ U(`span`,{class:`${Qf}-toolui-q-pill`,children:[/* @__PURE__ */ U(C,{}),w]}),/* @__PURE__ */ U(`span`,{class:`${Qf}-toolui-head-end`,children:[m?null:/* @__PURE__ */ U(wf,{status:E,icon:U(h?Hl:Vl,{}),label:D}),/* @__PURE__ */ U(`span`,{class:`${Qf}-toolui-chevron`,children:/* @__PURE__ */ U(hl,{})})]})]}),/* @__PURE__ */ U(`div`,{class:`${Qf}-toolui-collapse-body`,children:[l.intro?/* @__PURE__ */ U(`div`,{class:`${Qf}-toolui-desc`,children:l.intro}):null,T,m||p?null:/* @__PURE__ */ U(`div`,{class:`${Qf}-toolui-footer`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Qf}-toolui-options-toggle`,onClick:()=>S(e=>!e),"data-testid":Z.toolAskOptions,children:[/* @__PURE__ */ U(`span`,{class:`${Qf}-toolui-options-chevron${x?` ${Qf}-open`:``}`,children:/* @__PURE__ */ U(hl,{})}),x?t.hideOptions:t.showOptions]}),g?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Qf}-form-skip`,onClick:()=>o(e.toolCallId),"data-testid":Z.toolEdit,children:t.edit}):null]})]})]})}function rp({req:e,strings:t,active:n,resolve:r}){let i=Xf(e,t.confirmYes,t.confirmNo),a=e.questions.length===1&&e.questions[0]?.type===`text`;return/* @__PURE__ */ U(Yd,{fields:i,strings:t,disabled:!n,submitLabel:t.inputSubmit,footerHint:a?t.inputSubmitHint:void 0,onSubmit:t=>r(op(e.questions,t),!0),skipLabel:t.inputSkip,onSkip:()=>r(void 0,!1),submitOnEnter:a,fieldTypeLabels:tp(e.questions,t),submitTestId:Z.toolInputSubmit,skipTestId:Z.toolInputSkip})}function ip({questions:e,answers:t,strings:n}){return/* @__PURE__ */ U(`div`,{class:`${Qf}-toolui-summary`,"data-testid":Z.toolAskSummary,children:e.map(e=>/* @__PURE__ */ U(`div`,{class:`${Qf}-field`,children:[/* @__PURE__ */ U(`span`,{class:`${Qf}-field-head`,children:/* @__PURE__ */ U(`span`,{class:`${Qf}-field-label`,children:[e.question,e.required?/* @__PURE__ */ U(`span`,{class:`${Qf}-field-req`,"aria-hidden":`true`,children:` *`}):null]})}),/* @__PURE__ */ U(`p`,{class:`${Qf}-toolui-answer`,children:ap(e,t[e.key],n)||`—`})]},e.key))})}function ap(e,t,n){return e.type===`boolean`?t===`yes`?n.confirmYes:t===`no`?n.confirmNo:t??``:t??``}function op(e,t){let n=e.flatMap(e=>{let n=t[e.key];if(n==null||n.trim()===``)return[];let r=e.type===`multi-select`?n.split(`,`).map(e=>e.trim()).filter(Boolean):n;return[{key:e.key,value:r}]});return JSON.stringify({answers:n})}function sp(e){if(!e)return{};let t=(()=>{try{return JSON.parse(e)}catch{return}})()?.answers;if(!Array.isArray(t))return{};let n={};for(let e of t)if(e&&typeof e==`object`&&`key`in e){let{key:t,value:r}=e;if(typeof t!=`string`)continue;typeof r==`string`?n[t]=r:Array.isArray(r)&&(n[t]=r.filter(e=>typeof e==`string`))}return n}function cp(e){let t=sp(e),n={};for(let[e,r]of Object.entries(t))n[e]=Array.isArray(r)?r.join(`, `):r;return n}function lp(e,t){let n=sp(t),r={};for(let t of e){let e=n[t.key];e!==void 0&&(t.type===`multi-select`?r[t.key]=Array.isArray(e)?e:[e]:r[t.key]=Array.isArray(e)?e[0]??``:e)}return r}function up({part:e,strings:t,live:n,superseded:r}){let i=B(()=>ri(()=>e.inputSig.value),[e]),a=B(()=>ri(()=>e.outputSig.value),[e]),o=B(()=>ri(()=>e.errorSig.value),[e]),s=Te(e.toolMetadata);if(!B(()=>ri(()=>!!Ff(i.value)||!!o.value||!!Ff(Pf(a.value))),[i,a,o]).value&&!s)return null;let c=a.value===void 0&&!o.value;return/* @__PURE__ */ U(Mf,{part:e,strings:t,testid:Z.toolCall,live:n||s&&!r,incomplete:s&&r&&c})}const dp=u.cssPrefix,fp=cf(pp);function pp({message:e,status:t,strings:n,responseMode:r,showReasoning:i,showToolCalls:a,showSources:o,interactive:s=!1,superseded:c=!1,tool:l,onRetry:u,enableMessageFeedback:d=!1,onFeedback:f}){let p=[...B(()=>ri(()=>e.partsSig.value),[e]).value];for(let t of e.attachments??[])t.url&&!p.some(e=>e.kind===`file`&&e.url===t.url)&&p.push({kind:`file`,url:t.url,mediaType:t.mediaType,filename:t.name,fileId:t.id,fileSize:t.size});let m=B(()=>ri(()=>Ys(e)),[e]),h=B(()=>ri(()=>Zs(e)),[e]),g=B(()=>ri(()=>If(e)),[e]),_=B(()=>ri(()=>i&&Lf(e)),[e,i]),v=t===`streaming`,y=e.role===`assistant`&&v,b=zf({streaming:y,responseMode:r,reasoningVisible:_.value,hasAnswerText:g.value,emptyReply:m.value,hidden:h.value}),{bufferedHold:x,working:S,showStreamDots:C}=b;if(b.hidden)return null;let w=hp(e.createdAt),T=e.role===`assistant`||e.role===`operator`,E=d&&!!f&&!!e.serverMessageId&&T&&!v&&t!==`error`&&!m.value,D=v?``:p.filter(e=>e.kind===`text`).map(t=>e.role===`assistant`?ts(t.textSig.peek()):t.textSig.peek()).join(`
61
61
 
62
- `).trim(),O=!v&&t!==`error`&&!m.value&&D.length>0,ee=E||O;return/* @__PURE__ */ U(`div`,{class:`${dp}-bubble-row`,"data-role":e.role,"data-testid":Wl(Z.messageBubble,e.serverMessageId??e.id),children:/* @__PURE__ */ U(`div`,{class:`${dp}-bubble-col`,children:[/* @__PURE__ */ U(`div`,{class:`${dp}-bubble`,children:[e.role===`operator`&&e.operatorInitials?/* @__PURE__ */ U(`span`,{class:`${dp}-bubble-author`,children:e.operatorInitials}):null,/* @__PURE__ */ U(`div`,{class:`${dp}-bubble-body`,children:[x?/* @__PURE__ */ U(xp,{label:n.loading}):p.map((r,u)=>/* @__PURE__ */ U(gp,{part:r,generativeUi:e.role===`assistant`,active:S,live:y,strings:n,showReasoning:i,showToolCalls:a,showSources:o,interactive:s&&t===`complete`&&(r.kind!==`tool`||Fs(e,u)),superseded:c,continuationStreaming:e.continuationStreaming===!0,tool:l},`${yp(r)}#${u}`)),C&&/* @__PURE__ */ U(bp,{}),t===`error`||m.value?/* @__PURE__ */ U(`div`,{class:`${dp}-error`,role:`alert`,children:[/* @__PURE__ */ U(`span`,{children:e.errorText??n.errorGeneric}),u?/* @__PURE__ */ U(`button`,{type:`button`,class:`${dp}-error-retry`,onClick:()=>u(e),"data-testid":Z.messageRetry,children:n.errorRetry}):null]}):null]})]}),w||ee?/* @__PURE__ */ U(`div`,{class:`${dp}-bubble-meta`,children:[w?/* @__PURE__ */ U(`time`,{class:`${dp}-bubble-time`,dateTime:w.iso,title:w.full,children:w.short}):null,ee?/* @__PURE__ */ U(`div`,{class:`${dp}-bubble-actions`,children:[E&&e.serverMessageId?/* @__PURE__ */ U(yf,{messageId:e.serverMessageId,initial:e.feedback??null,strings:n,onFeedback:f}):null,O?/* @__PURE__ */ U(mp,{text:D,strings:n}):null]}):null]}):null]})})}function mp({text:e,strings:t}){let[n,r]=L(!1);function i(){navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})}let a=n?t.copied:t.copy;return/* @__PURE__ */ U(`button`,{type:`button`,class:`${dp}-msg-action`,"data-active":n?`true`:void 0,"aria-label":a,title:a,onClick:i,"data-testid":Z.messageCopy,children:U(n?ul:Il,{})})}function hp(e){if(typeof e!=`number`||!Number.isFinite(e))return null;try{let t=new Date(e);return{short:t.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`}),full:t.toLocaleString(void 0,{dateStyle:`full`,timeStyle:`short`}),iso:t.toISOString()}}catch{return null}}function gp({part:e,generativeUi:t,active:n,live:r,strings:i,showReasoning:a,showToolCalls:o,showSources:s,interactive:c,superseded:l,continuationStreaming:u,tool:d}){switch(e.kind){case`step-start`:return null;case`text`:return/* @__PURE__ */ U(nu,{textSig:e.textSig,doneSig:e.doneSig,generativeUi:t,strings:i});case`reasoning`:return a?/* @__PURE__ */ U(vp,{part:e,active:n,strings:i}):null;case`tool`:return/* @__PURE__ */ U(_p,{part:e,strings:i,showToolCalls:o,interactive:c,superseded:l,continuationStreaming:u,live:r,tool:d});case`file`:return e.mediaType.startsWith(`image/`)?/* @__PURE__ */ U(`img`,{src:e.url,alt:``,loading:`lazy`}):/* @__PURE__ */ U(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,children:e.url});case`source`:return s?/* @__PURE__ */ U(Hf,{part:e,strings:i}):null}}function _p({part:e,strings:t,showToolCalls:n,interactive:r,superseded:i,continuationStreaming:a,live:o,tool:s}){let c=B(()=>ri(()=>e.approvalSig.value!==void 0),[e]);return s?.humanInLoop&&c.value?_f(e.toolName)?/* @__PURE__ */ U(np,{part:e,strings:t,active:r,superseded:i,continuationStreaming:a,onDecision:s.onDecision,onEdit:s.onEdit}):/* @__PURE__ */ U(Wf,{part:e,strings:t,active:r,superseded:i,continuationStreaming:a,onDecision:s.onDecision,onEdit:s.onEdit}):n?/* @__PURE__ */ U(up,{part:e,strings:t,live:o,superseded:i}):null}function vp({part:e,active:t,strings:n}){return/* @__PURE__ */ U(`details`,{class:`${dp}-reasoning`,"data-testid":Z.reasoning,open:t,"data-active":t?`true`:void 0,children:[/* @__PURE__ */ U(`summary`,{class:`${dp}-reasoning-summary`,children:/* @__PURE__ */ U(`span`,{class:`${dp}-reasoning-label`,children:t?n.thinking:n.thoughts})}),/* @__PURE__ */ U(`div`,{class:`${dp}-reasoning-body`,children:/* @__PURE__ */ U(nu,{textSig:e.textSig,doneSig:e.doneSig})})]})}function yp(e){switch(e.kind){case`text`:case`reasoning`:case`step-start`:return`${e.kind}:${e.id}`;case`tool`:return`tool:${e.toolCallId}`;case`file`:return`file:${e.url}`;case`source`:return`source:${e.sourceId}`}}function bp(){return/* @__PURE__ */ U(`span`,{class:`${dp}-typing`,"data-testid":Z.typingDots,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`span`,{}),/* @__PURE__ */ U(`span`,{}),/* @__PURE__ */ U(`span`,{})]})}function xp({label:e}){return/* @__PURE__ */ U(`span`,{class:`${dp}-loading`,role:`status`,children:[/* @__PURE__ */ U(`span`,{class:`${dp}-loading-spinner`,"aria-hidden":`true`}),/* @__PURE__ */ U(`span`,{class:`${dp}-loading-label`,children:e})]})}const Sp=u.cssPrefix;function Cp({messagesSig:e,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,enableMessageFeedback:o,onFeedback:s,loading:c,onLoadPreviousMessages:l,idle:u,controlMode:d=`ai-agent`,tool:f,onRetry:p,form:m,formMarkers:h,onFillForm:g}){let _=z(null),v=yi(()=>e.value),[y,b]=L(!1),[x,S]=L(!1),C=z(!1),w=z(!1),[T,E]=L(),D=z(!1),O=z(!1),ee=z(!1),k=z(0);function te(){return ee.current||performance.now()-k.current<350}let ne=z(0);function A(e){let t=e.scrollHeight-e.clientHeight>1;e.dataset.fadeTop=t&&e.scrollTop>1?`true`:`false`,e.dataset.fadeBottom=t&&e.scrollHeight-e.scrollTop-e.clientHeight>1?`true`:`false`}function j(e){return b(e.scrollHeight-e.scrollTop-e.clientHeight>240)}function re(e){ne.current=performance.now(),e.scrollTop=e.scrollHeight,A(e)}function ie(e,t){re(e);let n=t,r=0;function i(){O.current||te()||(re(e),--n>0&&(r=requestAnimationFrame(i)))}return t>0&&(r=requestAnimationFrame(i)),()=>cancelAnimationFrame(r)}function ae(e,t){let n,r,i,a=-1;function o(){n.disconnect(),r.disconnect(),clearTimeout(i)}function s(){if(O.current||te()||a>=0&&e.scrollTop<a-4)return o();re(e),a=e.scrollTop}return n=new ResizeObserver(s),r=new MutationObserver(s),s(),n.observe(e),r.observe(e,{childList:!0,subtree:!0,characterData:!0}),i=setTimeout(o,t),o}let oe=v.value[0]?.id;kr(()=>{let e=_.current;if(e&&v.value.length!==0&&!w.current&&(D.current=!0,v.value.some(e=>e.role===`user`)))return ae(e,300)},[oe]);let se=z(0);R(()=>{let e=_.current,t=v.value,n=se.current;if(se.current=t.length,e&&D.current&&!w.current){if(t.slice(n).some(e=>e.role===`user`))return O.current=!1,ie(e,3);t.some(e=>e.role===`user`)&&(O.current||te()||e.scrollHeight-e.scrollTop-e.clientHeight<120&&re(e))}},[v.value.length]);let ce=z(null);R(()=>{let e=_.current,t=v.value.at(-1),n=ce.current;if(ce.current=t?{id:t.id,streaming:t.status===`streaming`}:null,e&&D.current&&t&&t.id===n?.id&&!n.streaming&&t.status===`streaming`)return O.current=!1,ie(e,3)},[v.value]),R(()=>{let e=_.current;if(!e)return;let t=v.value.at(-1);if(!t||t.status!==`streaming`&&!v.value.some(e=>e.role===`user`))return;let n=()=>{O.current||te()||e.scrollHeight-e.scrollTop-e.clientHeight<240&&re(e)};if(t.status!==`streaming`)return ae(e,300);n();let r=new MutationObserver(n);return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[v.value]);let le=m?.form.id,M=!!m&&(h??[]).some(e=>e.formId===m.form.id);kr(()=>{let e=_.current;e&&le&&!O.current&&v.value.some(e=>e.role===`user`)&&(M?e.querySelector(`[data-testid="${Z.formGate}"]`)?.scrollIntoView({block:`nearest`}):re(e))},[le,M]),R(()=>{let e=_.current;if(!e)return;let t=()=>{j(e),A(e),performance.now()-ne.current>150&&(O.current=e.scrollHeight-e.scrollTop-e.clientHeight>8)};function n(){O.current=!0}function r(e){e.deltaY<0&&n()}let i=0;function a(e){i=e.touches[0]?.clientY??0,ee.current=!0}function o(e){(e.touches[0]?.clientY??0)>i+4&&n()}function s(){ee.current=!1,k.current=performance.now()}function c(){ee.current=!0}return e.addEventListener(`scroll`,t,{passive:!0}),e.addEventListener(`wheel`,r,{passive:!0}),e.addEventListener(`touchstart`,a,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`touchend`,s,{passive:!0}),e.addEventListener(`touchcancel`,s,{passive:!0}),e.addEventListener(`pointerdown`,c,{passive:!0}),window.addEventListener(`pointerup`,s,{passive:!0}),window.addEventListener(`pointercancel`,s,{passive:!0}),j(e),()=>{e.removeEventListener(`scroll`,t),e.removeEventListener(`wheel`,r),e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s),e.removeEventListener(`touchcancel`,s),e.removeEventListener(`pointerdown`,c),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[]);function ue(){let e=_.current;e&&(O.current=!1,re(e))}let de=v.value.filter(e=>!e.ephemeral),fe=de[0],pe=fe?.serverMessageId??fe?.id,me=!!(l&&de.length>=50&&pe!==T);async function he(){if(!l||C.current)return;let e=_.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;C.current=!0,w.current=!0,S(!0);try{let r=await l();r===!1&&pe&&E(pe),r&&e&&(await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e()))),e.scrollTop=n+e.scrollHeight-t,A(e),j(e))}finally{w.current=!1,C.current=!1,S(!1)}}let N=[],ge=``,_e=v.value.at(-1)?.id,ve=[...h??[]].toSorted((e,t)=>(e.createdAt??1/0)-(t.createdAt??1/0));function ye(e){return m&&e.formId===m.form.id?/* @__PURE__ */ U(nf,{form:m.form,strings:t,onSubmit:m.onSubmit,onSkip:m.onSkip},`gate:${e.formId}`):/* @__PURE__ */ U(rf,{marker:e,strings:t,onFill:!m&&g?()=>g(e.formId):void 0},e.key)}function be(e){for(let t=ve[0];t?.createdAt!==void 0&&!(e!==void 0&&t.createdAt>e);t=ve[0])ve.shift(),N.push(ye(t))}for(let e of v.value){if(e.role===`assistant`&&e.id!==_e&&Ys(e))continue;be(e.createdAt);let c=wp(e.createdAt);c&&c!==ge&&(N.push(/* @__PURE__ */ U(`div`,{class:`${Sp}-date-divider`,children:/* @__PURE__ */ U(`span`,{class:`${Sp}-date-pill`,title:Tp(e.createdAt),children:Ep(e.createdAt,t)})},`day:${c}`)),ge=c);let l=e.retryAction!==void 0||e.role===`assistant`&&e.id===_e?Xs(v.value,e):void 0,m=l!==void 0&&(l.kind!==`continue-assistant`||d===`ai-agent`);N.push(/* @__PURE__ */ U(fp,{message:e,status:e.status,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,interactive:!!u&&d===`ai-agent`&&e.id===_e,superseded:e.id!==_e,tool:f,onRetry:u&&m&&(e.role===`user`||e.id===_e)?p:void 0,enableMessageFeedback:o,onFeedback:s},e.id))}for(let e of ve)N.push(ye(e));return/* @__PURE__ */ U(`div`,{class:`${Sp}-list-wrap`,children:[/* @__PURE__ */ U(`div`,{ref:_,class:`${Sp}-list ${Sp}-list--fade`,part:`messages`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,children:[c&&v.value.length===0?/* @__PURE__ */ U(`div`,{class:`${Sp}-list-loading`,role:`status`,children:t.conversationLoading}):null,me?/* @__PURE__ */ U(`div`,{class:`${Sp}-load-previous`,children:/* @__PURE__ */ U(`button`,{type:`button`,onClick:he,disabled:x,"aria-busy":x,"data-testid":Z.loadPreviousMessages,children:t.loadPreviousMessages})}):null,N,m&&!M?/* @__PURE__ */ U(nf,{form:m.form,strings:t,onSubmit:m.onSubmit,onSkip:m.onSkip}):null]}),y?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Sp}-jump`,onClick:ue,"aria-label":t.scrollToBottom,title:t.scrollToBottom,"data-testid":Z.scrollToBottom,children:/* @__PURE__ */ U(hl,{})}):null]})}function wp(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function Tp(e){if(typeof e!=`number`||!Number.isFinite(e))return``;try{return new Date(e).toLocaleDateString(void 0,{dateStyle:`full`})}catch{return``}}function Ep(e,t){let n=new Date(e);function r(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}let i=Math.round((r(/* @__PURE__ */ new Date)-r(n))/864e5);return i<=0?t.dateToday:i===1?t.dateYesterday:i<7?n.toLocaleDateString(void 0,{weekday:`long`}):n.toLocaleDateString(void 0,{month:`long`,day:`numeric`,year:`numeric`})}function Dp({panelEl:e,resize:t,position:n,initialSize:r,onSizeChange:i,strings:a}){let o=u.cssPrefix,s=z(null);if(R(()=>{if(!e)return;let n=e.style;t.minWidth&&n.setProperty(`--${o}-resize-min-w`,t.minWidth),t.maxWidth&&n.setProperty(`--${o}-resize-max-w`,t.maxWidth),t.minHeight&&n.setProperty(`--${o}-resize-min-h`,t.minHeight),t.maxHeight&&n.setProperty(`--${o}-resize-max-h`,t.maxHeight),r&&(n.setProperty(`--${o}-widget-w`,`${r.width}px`),n.setProperty(`--${o}-widget-h`,`${r.height}px`))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,o,r]),!e)return null;let c=n.startsWith(`top-`),l=n.endsWith(`-right`),d=`${o}-resize-grip ${o}-resize-grip--${c?`bottom`:`top`}-${l?`left`:`right`}`;function f(t){if(!e)return;let n=t.currentTarget,r=e.getBoundingClientRect();s.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startW:r.width,startH:r.height,dirX:l?-1:1,dirY:c?1:-1},n.setPointerCapture(t.pointerId),e.setAttribute(`data-resizing`,``),t.preventDefault()}function p(t){let n=s.current;if(!n||t.pointerId!==n.pointerId||!e)return;let r=(t.clientX-n.startX)*n.dirX,i=(t.clientY-n.startY)*n.dirY;e.style.setProperty(`--${o}-widget-w`,`${n.startW+r}px`),e.style.setProperty(`--${o}-widget-h`,`${n.startH+i}px`)}function m(t){let n=s.current;if(!n||t.pointerId!==n.pointerId||!e)return;t.currentTarget.releasePointerCapture(t.pointerId),e.removeAttribute(`data-resizing`);let r=e.getBoundingClientRect();i({width:Math.round(r.width),height:Math.round(r.height)}),s.current=null}return/* @__PURE__ */ U(`div`,{class:d,role:`separator`,"aria-orientation":`vertical`,"aria-label":a.resizeHandle,title:a.resizeHandle,onPointerDown:f,onPointerMove:p,onPointerUp:m,onPointerCancel:m,"data-testid":Z.resizeGrip,children:/* @__PURE__ */ U(il,{})})}const Op=u.cssPrefix;function kp({suggestions:e,onPick:t,disabled:n=!1}){return e.length===0?null:/* @__PURE__ */ U(`div`,{class:`${Op}-suggestions`,role:`group`,"aria-label":`Suggested replies`,children:e.map((e,r)=>/* @__PURE__ */ U(`button`,{type:`button`,class:`${Op}-suggestion`,onClick:()=>t(e),disabled:n,"data-testid":Wl(Z.suggestion,r),children:e.label},e.id))})}const Ap=u.cssPrefix,jp=`.${Ap}-header, .${Ap}-back-header, .${Ap}-home-hero`;function Mp(e,t){R(()=>{if(!t||!e)return;function n(e){return Number.parseFloat(e)||0}function r(e,t){return Math.min(t,Math.max(-t,e))}let i=null,a=t=>{let r=t.target;if(!(r instanceof Element)||!r.closest(jp)||r.closest(`button, a, input, textarea, select, [role="tab"], [contenteditable]`))return;let a=e.getBoundingClientRect();i={id:t.pointerId,x:t.clientX,y:t.clientY,dx:n(e.style.getPropertyValue(`--${Ap}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${Ap}-modal-dy`)),maxX:(window.innerWidth+a.width)/2-56,maxY:(window.innerHeight+a.height)/2-56},e.dataset.dragging=`true`,t.preventDefault()},o=t=>{if(!i||t.pointerId!==i.id)return;let n=r(i.dx+t.clientX-i.x,i.maxX),a=r(i.dy+t.clientY-i.y,i.maxY);e.style.setProperty(`--${Ap}-modal-dx`,`${n}px`),e.style.setProperty(`--${Ap}-modal-dy`,`${a}px`)},s=t=>{i&&t.pointerId===i.id&&(i=null,delete e.dataset.dragging)};return e.addEventListener(`pointerdown`,a),window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s),()=>{e.removeEventListener(`pointerdown`,a),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[e,t])}function Np({containerRef:e,onDrop:t,disabled:n=!1}){let[r,i]=L(!1);return R(()=>{if(n){i(!1);return}let r=e.current;if(!r)return;let a=0;function o(e){a+=1,e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),i(!0))}function s(){--a,!(a>0)&&(a=0,i(!1))}function c(e){e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()}function l(e){a=0,i(!1),e.dataTransfer&&(e.preventDefault(),t(e.dataTransfer.items))}return r.addEventListener(`dragenter`,o),r.addEventListener(`dragleave`,s),r.addEventListener(`dragover`,c),r.addEventListener(`drop`,l),()=>{r.removeEventListener(`dragenter`,o),r.removeEventListener(`dragleave`,s),r.removeEventListener(`dragover`,c),r.removeEventListener(`drop`,l)}},[e,n,t]),{visible:!n&&r}}const Pp=u.cssPrefix;function Fp(e){let{options:t,onClose:n}=e,r=t.strings,i=z(null);R(()=>{let e=i.current;if(!e)return;let t=Ql(e);function r(e){e.key===`Escape`&&n?.()}return e.addEventListener(`keydown`,r),()=>{t(),e.removeEventListener(`keydown`,r)}},[n]);let a=e.composerApiRef,o=e.composerActive&&e.view===`chat`&&e.canSend&&!e.activeForm&&!e.sendPreparing&&e.options.features.fileUpload,{visible:s}=Np({containerRef:i,onDrop:V(e=>{o&&a.current?.attachFromDrop(e)},[a,o]),disabled:!o});return Mp(i.current,t.mode===`modal`),/* @__PURE__ */ U(`div`,{ref:i,class:`${Pp}-panel`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":r.panelTitle,style:{position:`relative`},"data-testid":Z.panel,children:[/* @__PURE__ */ U(Ip,{...e,containerEl:i.current,dragOver:s}),/* @__PURE__ */ U(Hp,{poweredBy:e.options.poweredBy})]})}function Ip(e){let{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,composerKey:s,panelSize:c,view:l,canSend:u,isStreaming:d,isMemoryCompacting:f,canReleaseQueuedMessages:p,queueManualMessages:m,sendPreparing:h,controlMode:g,assignedOperatorInitials:_,operatorAvailable:v,operatorRequestEnabled:y,onRequestOperator:b,onCancelOperatorRequest:x,loadingMessages:S,onLoadPreviousMessages:C,messagesSig:w,agent:T,suggestions:E,initialWidgetSize:D,onClose:O,onBack:ee,onClear:k,onToggleHistory:te,onSelectHistoryConversation:ne,onNewConversation:A,onWidgetSizeChange:j,onSend:re,onStop:ie,onSuggestion:ae,activeForm:oe,formMarkers:se,onFormSubmit:ce,onFormSkip:le,onFormFill:M,tool:ue,onRetry:de,onMessageFeedback:fe,containerEl:pe,dragOver:me,composerApiRef:he}=e,N=t.strings,ge=yi(()=>w.value.some(e=>!e.ephemeral&&e.role!==`system`)).value,_e;return _e=oe?null:u?/* @__PURE__ */ U(I,{children:[g&&g!==`ai-agent`?/* @__PURE__ */ U(zp,{controlMode:g,operatorInitials:_,operatorAvailable:v,onCancelOperatorRequest:x,strings:N}):null,f&&g===`ai-agent`?/* @__PURE__ */ U(`div`,{class:`${Pp}-loading ${Pp}-compaction-status`,role:`status`,"data-testid":Z.compactionStatus,children:[/* @__PURE__ */ U(`span`,{class:`${Pp}-loading-spinner`,"aria-hidden":`true`}),N.compactingContext]}):null,!d&&!f&&g===`ai-agent`&&/* @__PURE__ */ U(kp,{suggestions:E,onPick:ae,disabled:h}),/* @__PURE__ */ U(od,{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,isStreaming:d,pageToolRunning:e.pageToolRunning,isMemoryCompacting:f,canReleaseQueuedMessages:p,queueManualMessages:m,active:e.composerActive&&l===`chat`,isPreparing:h,operatorRequestEnabled:y,canRequestOperator:ge,controlMode:g,onRequestOperator:b,onSend:re,onStop:ie,apiRef:he},s)]}):/* @__PURE__ */ U(Rp,{label:N.conversationClosed,ctaLabel:N.startNewConversation,onNewConversation:k}),/* @__PURE__ */ U(I,{children:[l===`history`?/* @__PURE__ */ U(Lp,{strings:N,onBack:te,onClose:O,showClose:Tc(t.mode,c,t.actions)}):/* @__PURE__ */ U(`header`,{class:`${Pp}-header`,part:`header`,"data-testid":Z.panelHeader,children:[ee?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Pp}-icon-btn`,onClick:ee,"aria-label":N.moduleBack,title:N.moduleBack,children:/* @__PURE__ */ U(pl,{})}):null,T?/* @__PURE__ */ U(Dd,{agent:T,strings:N}):/* @__PURE__ */ U(`h1`,{children:N.panelTitle}),/* @__PURE__ */ U(Su,{panelProps:e,variant:`chat`})]}),l===`history`?/* @__PURE__ */ U(Id,{transport:n,strings:N,locale:t.locale,persistence:a,onSelect:ne,onNewConversation:A}):/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(Rd,{visible:me,strings:N}),/* @__PURE__ */ U(Cp,{messagesSig:w,strings:N,responseMode:t.responseMode,showReasoning:t.showReasoning,showToolCalls:t.showToolCalls,showSources:t.showSources,enableMessageFeedback:t.enableMessageFeedback,onFeedback:fe,loading:S,onLoadPreviousMessages:C,idle:!d&&!h&&u&&!oe,controlMode:g,tool:ue,onRetry:de,form:oe?{form:oe,onSubmit:ce,onSkip:le}:null,formMarkers:se,onFillForm:M}),_e,/* @__PURE__ */ U(Vp,{disclaimer:t.composerDisclaimer})]}),t.size.resize?.enabled?/* @__PURE__ */ U(Dp,{panelEl:pe,resize:t.size.resize,position:t.position,initialSize:D,onSizeChange:j,strings:N}):null]})}function Lp({strings:e,onBack:t,onClose:n,showClose:r}){return/* @__PURE__ */ U(`header`,{class:`${Pp}-header`,part:`header`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Pp}-icon-btn`,onClick:t,"aria-label":e.historyBack,title:e.historyBack,children:/* @__PURE__ */ U(pl,{})}),/* @__PURE__ */ U(`h1`,{children:e.historyTitle}),r?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Pp}-icon-btn`,onClick:n,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ U(Wc,{})}):null]})}function Rp({label:e,ctaLabel:t,onNewConversation:n}){return/* @__PURE__ */ U(`div`,{class:`${Pp}-readonly-banner`,role:`note`,children:[/* @__PURE__ */ U(`span`,{class:`${Pp}-readonly-label`,children:e}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Pp}-readonly-cta`,onClick:n,children:t})]})}function zp({controlMode:e,operatorInitials:t,operatorAvailable:n,onCancelOperatorRequest:r,strings:i}){let a=Bp(e,t,n,i);return/* @__PURE__ */ U(`div`,{class:`${Pp}-operator-banner`,role:`status`,"data-mode":e,"data-testid":Z.operatorBanner,children:[/* @__PURE__ */ U(`span`,{class:`${Pp}-operator-pulse`,"aria-hidden":`true`}),/* @__PURE__ */ U(`span`,{class:`${Pp}-operator-label`,children:a}),e===`awaiting-operator`&&r?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Pp}-cancel-operator-request`,"data-testid":Z.cancelOperatorRequest,onClick:r,children:i.cancelOperatorRequest}):null]})}function Bp(e,t,n,r){return e===`operator`?r.chattingWithOperator.replace(`{operator}`,t??``):n===!1?r.noOperatorAvailable:r.connectingOperator}function Vp({disclaimer:e}){return e?/* @__PURE__ */ U(`div`,{class:`${Pp}-composer-footer`,children:/* @__PURE__ */ U(`div`,{class:`${Pp}-disclaimer`,children:e})}):null}function Hp({poweredBy:e}){return e?/* @__PURE__ */ U(`div`,{class:`${Pp}-poweredby-bar`,children:/* @__PURE__ */ U(Up,{logoUrl:e.logoUrl,text:e.text,href:e.href})}):null}function Up({logoUrl:e,text:t,href:n}){let r=/* @__PURE__ */ U(I,{children:[e?/* @__PURE__ */ U(`img`,{class:`${Pp}-poweredby-logo`,src:e,alt:``,loading:`lazy`}):null,t?/* @__PURE__ */ U(`span`,{children:t}):null]});return n?/* @__PURE__ */ U(`a`,{class:`${Pp}-poweredby`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:r}):/* @__PURE__ */ U(`span`,{class:`${Pp}-poweredby`,children:r})}const Wp=u.cssPrefix;function Gp({panelProps:e,enabledModules:t,nav:n,bus:r,hasUnread:i,latestNews:a,onSelectConversation:o,onStartNewConversation:s,onSetPanelSize:c}){let l=e.options,u=l.strings,d=z(null),f=z(/* @__PURE__ */ new Set);R(()=>{let t=d.current;if(!t)return;let n=Ql(t);function r(t){t.key===`Escape`&&e.onClose?.()}return t.addEventListener(`keydown`,r),()=>{n(),t.removeEventListener(`keydown`,r)}},[e.onClose]);let p=yi(()=>n.sig.value).value,m=Ic(p),h=l.modules.byId[p.activeTab],g=e.composerActive&&h?.layout===`chat`&&m===void 0,_=e.composerApiRef,v=g&&e.view===`chat`&&e.canSend&&!e.activeForm&&!e.sendPreparing&&e.options.features.fileUpload,{visible:y}=Np({containerRef:d,onDrop:V(e=>{v&&_.current?.attachFromDrop(e)},[_,v]),disabled:!v});Mp(d.current,l.mode===`modal`);let b=m?.kind===`iframe`||m?.kind===`content`,x=t.length>1&&(Lc(p)||!b),S=z(null);R(()=>{if(b&&S.current===null)S.current=e.panelSize,e.panelSize===`normal`&&c(`expanded`);else if(!b&&S.current!==null){let e=S.current;S.current=null,c(e)}},[b]);let C={push:e=>n.push(e),pop:()=>n.pop(),switchTab:e=>n.switchTab(e),switchToLayout:e=>{let r=t.find(t=>t.layout===e);r&&n.switchTab(r.id)},selectConversation:o,startNewConversation:s};function w(t){return{options:l,transport:e.transport,strings:u,config:t,nav:C,bus:r,panelProps:e,latestNews:a}}let T=/* @__PURE__ */ U(Su,{panelProps:e,variant:`plain`});h&&f.current.add(h.id);let E=t.filter(e=>f.current.has(e.id));function D(t){if(t.layout===`chat`)return/* @__PURE__ */ U(Ip,{...e,composerActive:g,containerEl:d.current,dragOver:y});let n=xd[t.layout].Root;return n?/* @__PURE__ */ U(n,{...w(t)}):null}function O(){return m?.kind===`iframe`?/* @__PURE__ */ U(Td,{url:m.url,title:m.title,strings:u,onBack:()=>n.pop(),actions:T}):m?.kind===`content`?/* @__PURE__ */ U(pu,{id:m.id,title:m.title,transport:e.transport,strings:u,bus:r,onBack:()=>n.pop(),actions:T}):null}return/* @__PURE__ */ U(`div`,{ref:d,class:`${Wp}-panel ${Wp}-messenger`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":u.panelTitle,style:{position:`relative`},"data-testid":Z.messengerHome,children:[/* @__PURE__ */ U(`div`,{class:`${Wp}-messenger-body`,children:[E.map(e=>/* @__PURE__ */ U(`div`,{class:`${Wp}-messenger-pane`,hidden:b||e.id!==h?.id,children:D(e)},e.id)),O()]}),x?/* @__PURE__ */ U(Cd,{modules:t,activeTab:p.activeTab,strings:u,hasUnread:i,onSelect:e=>n.switchTab(e)}):null,/* @__PURE__ */ U(Hp,{poweredBy:l.poweredBy}),l.size.resize?.enabled&&(h?.layout!==`chat`||m)?/* @__PURE__ */ U(Dp,{panelEl:d.current,resize:l.size.resize,position:l.position,initialSize:e.initialWidgetSize,onSizeChange:e.onWidgetSizeChange,strings:u}):null]})}const Kp=u.cssPrefix;function qp({strings:e,onClose:t}){return/* @__PURE__ */ U(`div`,{class:`${Kp}-panel ${Kp}-modules-empty`,part:`panel`,role:`dialog`,"aria-label":e.panelTitle,"data-testid":Z.modulesEmpty,children:[t?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Kp}-icon-btn ${Kp}-modules-empty-close`,onClick:t,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ U(Wc,{})}):null,/* @__PURE__ */ U(`p`,{class:`${Kp}-modules-empty-text`,children:e.modulesEmpty})]})}function Jp(e){let t=u.cssPrefix,{site:n,blocks:r,strings:i,collapsed:a}=e,o=r?.navigation??[],s=r?.linkCards??[],c=a?i.expandSidebar:i.collapseSidebar;return/* @__PURE__ */ U(`aside`,{class:`${t}-sidebar`,"data-collapsed":a?`true`:`false`,"data-testid":Z.sidebar,children:[/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-header`,children:[/* @__PURE__ */ U(Yp,{site:n}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${t}-sidebar-toggle`,"aria-label":c,"aria-expanded":a?`false`:`true`,title:c,onClick:e.onToggleCollapsed,"data-testid":Z.sidebarToggle,children:/* @__PURE__ */ U(Xp,{collapsed:a})})]}),a?null:/* @__PURE__ */ U(I,{children:[o.length>0?/* @__PURE__ */ U(`nav`,{class:`${t}-sidebar-section`,"data-section":`navigation`,children:/* @__PURE__ */ U(Zp,{items:o})}):null,s.length>0?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-section`,"data-section":`link-cards`,children:/* @__PURE__ */ U(Qp,{items:s})}):null,e.showConversations?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-conversations`,children:/* @__PURE__ */ U(Id,{transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,onSelect:e.onSelectConversation,onNewConversation:e.onNewConversation})}):null]})]})}function Yp({site:e}){let t=u.cssPrefix;if(e?.logo?.url){let n=e.logo.alt??e.title??`Logo`;return/* @__PURE__ */ U(`picture`,{children:[e.logoDark?.url?/* @__PURE__ */ U(`source`,{srcset:e.logoDark.url,media:`(prefers-color-scheme: dark)`}):null,/* @__PURE__ */ U(`img`,{class:`${t}-sidebar-logo`,src:e.logo.url,alt:n})]})}return/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-title`,children:e?.title??u.name})}function Xp({collapsed:e}){return/* @__PURE__ */ U(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`,children:e?/* @__PURE__ */ U(`polyline`,{points:`9 6 15 12 9 18`}):/* @__PURE__ */ U(`polyline`,{points:`15 6 9 12 15 18`})})}function Zp({items:e}){let t=u.cssPrefix;return/* @__PURE__ */ U(`ul`,{class:`${t}-sidebar-nav`,children:e.map(e=>/* @__PURE__ */ U(`li`,{children:/* @__PURE__ */ U(`a`,{class:`${t}-sidebar-nav-item`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[e.icon?/* @__PURE__ */ U(`span`,{class:`${t}-sidebar-nav-icon`,"data-icon":e.icon}):null,/* @__PURE__ */ U(`span`,{class:`${t}-sidebar-nav-label`,children:e.label})]})},e.id??e.label))})}function Qp({items:e}){let t=u.cssPrefix;return/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-cards`,children:e.map(e=>/* @__PURE__ */ U(`a`,{class:`${t}-sidebar-card`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-card-label`,children:e.label}),e.description?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-card-desc`,children:e.description}):null]},e.id??e.label))})}const $p=u.cssPrefix;function em(e){return/* @__PURE__ */ U(`main`,{class:`${$p}-page-shell`,"data-sidebar-collapsed":e.sidebarCollapsed?`true`:`false`,children:[/* @__PURE__ */ U(Jp,{site:e.site,blocks:e.blocks,transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,showConversations:e.showConversations,onSelectConversation:e.onSelectConversation,onNewConversation:e.onNewConversation,collapsed:e.sidebarCollapsed,onToggleCollapsed:e.onToggleSidebarCollapsed}),/* @__PURE__ */ U(`section`,{class:`${$p}-page-chat`,"aria-label":e.strings.panelTitle,children:e.children})]})}const tm=C.scope(`hitl`);function nm(e){return e.kind===`tool`&&Te(e.toolMetadata)&&(e.stateSig.value===`input-available`||e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved===!0)}function rm(e,t){t.errorSig.value=je(t.toolCallId),t.stateSig.value=`output-error`,e.partsSig.value=[...e.partsSig.value]}function im(e,t){let n=e.slice(0,e.indexOf(t)).findLast(e=>e.role===`user`);return n!==void 0&&M.sentHere(n.id)}function am(e){let{streaming:t,controlModeSig:n,messagesSig:r,sendAiTurn:i,bus:a,humanInLoop:o,tools:s}=e,c=z(t);c.current=t;let l=z(s);l.current=s;let u=z(/* @__PURE__ */ new Map),[d,f]=L(!1),p=V((e,t,a)=>{if(c.current||n.value!==`ai-agent`)return!1;let o=r.value.at(-1),s=o?.partsSig.value.findIndex(t=>t.kind===`tool`&&t.toolCallId===e)??-1,l=o?.partsSig.value[s];if(!o||l?.kind!==`tool`)return tm.warn(`decideTool: tool part not found`,{toolCallId:e}),!1;if(o.status!==`complete`||!Fs(o,s)||!t(l))return!1;if(a(l),o.partsSig.value=[...o.partsSig.value],!Ns(o)||o.partsSig.value.some(nm))return!0;o.status=`streaming`,o.retryAction={kind:`continue-assistant`,messageId:o.serverMessageId??o.id},o.awaitingContinuation=!0,r.value=[...r.value];let u=o.partsSig.value.flatMap(e=>e.kind===`tool`?[e.toolCallId]:[]);return i({continueExisting:!0}).then(e=>e&&M.clear(u)),!0},[n,r,i]),m=V((e,t)=>{let{toolCallId:n,toolName:r}=t;u.current.has(n)||(u.current.set(n,e),f(!0),ke({toolCallId:n,toolName:r,input:t.inputSig.value,optionTools:l.current??[],onSettled:(e,t)=>{tm.info(`toolResult`,{toolCallId:n,status:e}),a.emit(`toolResult`,{toolCallId:n,name:Ee(r),status:e,durationMs:t})}}).then(e=>{u.current.delete(n)&&(f(u.current.size>0),p(n,nm,t=>{e.state===`output-available`?t.outputSig.value=e.output:t.errorSig.value=e.errorText,t.stateSig.value=e.state}))}))},[a,p]),h=V(()=>{let e=r.value;for(let[t,n]of u.current){let r=e.findIndex(e=>e.id===n);r<0||r===e.length-1||(u.current.delete(t),Me(t),f(u.current.size>0))}let t=e.at(-1);if(c.current||t?.role!==`assistant`||t.status!==`complete`)return;let n=t.partsSig.value.filter(e=>nm(e)&&e.stateSig.value===`input-available`);if(n.length!==0&&im(e,t))for(let e of n)M.get(e.toolCallId)?.state===`stopped`?rm(t,e):m(t.id,e)},[r,m]);R(()=>h(),[t,h]),R(()=>r.subscribe(()=>h()),[r,h]);let g=V((e,t,n)=>{let i=!1,o;if(!p(e,e=>e.stateSig.value===`approval-requested`,r=>{Te(r.toolMetadata)&&(o=r),i=_f(r.toolName);let a=r.approvalSig.value?.id??e;r.approvalSig.value={id:a,approved:t,reason:n},r.stateSig.value=`approval-responded`}))return;let s=r.value.at(-1);o&&t&&s&&m(s.id,o),o&&!t&&a.emit(`toolResult`,{toolCallId:e,name:Ee(o.toolName),status:`declined`,durationMs:0}),i?(tm.info(`toolResult`,{toolCallId:e}),a.emit(`toolResult`,{toolCallId:e})):(tm.info(`toolDecision`,{toolCallId:e,approved:t}),a.emit(`toolDecision`,{toolCallId:e,approved:t}))},[a,p,r,m]),_=V(e=>{p(e,e=>e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved!==void 0&&!nm(e),t=>{let n=t.approvalSig.value?.id??e;t.approvalSig.value={id:n},t.stateSig.value=`approval-requested`})},[p]);return{toolInteraction:B(()=>({humanInLoop:o,onDecision:g,onEdit:_}),[o,g,_]),pageToolsRunning:d,stopPageTools:V(()=>{let e=r.value.at(-1);for(let t of u.current.keys()){let n=e?.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);e&&n?rm(e,n):je(t),tm.info(`toolResult`,{toolCallId:t,status:`stopped`}),a.emit(`toolResult`,{toolCallId:t,name:n?Ee(n.toolName):void 0,status:`stopped`,durationMs:0})}u.current.clear(),f(!1)},[a,r])}}const om=C.scope(`latest-news`);function sm({transport:e,options:t,persistence:n,enabled:r}){let i=t.modules.list.find(e=>e.layout===`news`)?.contentCollectionIds,a=i?.join(`,`),[o,s]=L(),[c,l]=L(()=>n.loadSeenNewsId());R(()=>{if(!r||!i?.length)return;let t=!1;return e.listContent({contentCollectionIds:i,sortBy:`publishedAt`,sortOrder:`desc`,limit:1}).then(e=>{t||s(e.items[0])}).catch(e=>om.debug(`listContent (latest news) failed (non-fatal)`,{err:e})),()=>{t=!0}},[e,r,a]);let u=V(e=>{n.saveSeenNewsId(e),l(e)},[n]);return{item:o,unseen:o!==void 0&&o.id!==c,markSeen:u}}function cm({callout:e,persistence:t}){let n=e?.text??``,r=e?.persistent??!0,[i,a]=L(()=>!r&&t.loadCalloutDismissed(n));return R(()=>{a(!r&&t.loadCalloutDismissed(n))},[n,r,t]),{dismissed:i,dismissCallout:V(()=>{a(!0),r||t.saveCalloutDismissed(n)},[t,n,r])}}function lm(e){let{transport:t,conversationIdSig:n}=e,r=vi(`ai-agent`),i=vi(void 0),a=vi(void 0),o=z(void 0),s=V(e=>{let t=e.controlRevision,s=o.current;s&&s.conversationId===n.value&&t<s.revision||(o.current={conversationId:n.value,revision:t},r.value=e.controlMode,i.value=e.assignedOperatorInitials,e.controlMode===`awaiting-operator`?e.operatorAvailable!==void 0&&(a.value=e.operatorAvailable):a.value=void 0)},[n,r,i,a]);return{controlModeSig:r,assignedOperatorInitialsSig:i,operatorAvailableSig:a,applyControlState:s,adoptControlStateChunk:V(e=>{if(e.type!==`data-control-state`)return;let t=cs(e.data);t&&s(t)},[s]),requestOperator:V(async()=>{let e=n.value,r=await t.requestOperator();r&&n.value===e&&s(r)},[t,n,s]),cancelOperatorRequest:V(async()=>{let e=n.value,r=await t.cancelOperatorRequest();r&&n.value===e&&s(r)},[t,n,s])}}const um=u.cssPrefix,dm=`--${um}-visual-viewport-height`,fm=`--${um}-visual-viewport-top`;function pm(e){let{hostElement:t,mode:n,panelSize:r,isOpen:i,surfaceReady:a,setIsOpen:o}=e;kr(()=>{ur(t,Rc(n,r,i))},[t,i,r,n]),kr(()=>{if(!i||!a)return;let e=t.ownerDocument.defaultView,n=e?.visualViewport,r=t.shadowRoot?.querySelector(`.${um}-anchor`);if(!e||!n||!r)return;let o=()=>{r.style.setProperty(dm,`${n.height}px`),r.style.setProperty(fm,`${n.offsetTop}px`)},s=0,c=()=>{e.cancelAnimationFrame(s),s=e.requestAnimationFrame(()=>{s=e.requestAnimationFrame(o)})};return o(),n.addEventListener(`resize`,c),n.addEventListener(`scroll`,c),()=>{e.cancelAnimationFrame(s),n.removeEventListener(`resize`,c),n.removeEventListener(`scroll`,c),r.style.removeProperty(dm),r.style.removeProperty(fm)}},[t,i,a]),R(()=>{if(n!==`modal`||!i)return;function e(e){e.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains(`${um}-panel`))||o(!1)}return t.addEventListener(`click`,e),()=>t.removeEventListener(`click`,e)},[t,i,n,o]),R(()=>{if(n!==`drawer`||!i)return;function e(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,n,o])}const mm=C.scope(`reducer`);var hm=class{constructor(e,t){this.messagesSig=e,this.onReconcileNeeded=t,s(this,`active`,null),s(this,`openTextParts`,/* @__PURE__ */ new Map),s(this,`partSeq`,0),s(this,`replay`,null)}attach(e){this.active=e,this.openTextParts.clear()}detach(){this.active=null,this.replay=null,this.openTextParts.clear()}beginReplay(e,t){let n=hs();n.id=e.id;let r=_m(e)||Ps(e)&&(e.status!==`streaming`||Ns(e)),i=e.status===`streaming`&&Ns(e)&&Ms(e);this.replay={baseline:e,shadow:n,chunks:[t],probeContinuation:r,continuationTailReplay:i,liveCatchUp:e.status===`streaming`&&!r},this.attach(n),this.apply(t)}refreshReplayBaseline(){let e=this.replay;if(!e)return null;let t=e.shadow.serverMessageId??e.baseline.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e.baseline||r?.id===e.baseline.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e.baseline)??n.find(n=>n.id===e.baseline.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e.baseline)return e;let a=e.baseline;return e.baseline=i,vm(a,i),e.liveCatchUp&&_m(e.shadow)&&(i.status===`streaming`||Ps(i))?(e.probeContinuation=!1,e.continuationTailReplay=!1,e):(e.probeContinuation=_m(i)||Ps(i)&&(i.status!==`streaming`||Ns(i)),e.continuationTailReplay=i.status===`streaming`&&Ns(i)&&Ms(i),e.liveCatchUp=i.status===`streaming`&&!e.probeContinuation,e)}refreshActive(){let e=this.active;if(!e)return null;let t=e.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e||r?.id===e.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e)??n.find(n=>n.id===e.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e)return e;vm(e,i);let a=_m(e)&&Ps(i);return i.status!==`streaming`&&!a?(this.detach(),null):(this.replay={baseline:i,shadow:e,chunks:[],probeContinuation:!1,continuationTailReplay:!1,liveCatchUp:!0},e)}promoteReplay(){let{baseline:e,shadow:t}=this.replay;return Br(()=>{e.role=t.role,e.serverMessageId=t.serverMessageId,e.operatorInitials=t.operatorInitials,e.status=t.status,t.canceled&&(e.canceled=!0),e.finishReason=t.finishReason,e.errorText=t.errorText,e.suggestions=t.suggestions??e.suggestions,e.partsSig.value=t.partsSig.value,this.messagesSig.value=[...this.messagesSig.value]}),this.replay=null,this.active=e,e}promoteContinuation(e=!1){let{baseline:t,chunks:n}=this.replay,r=Is(t);return this.replay=null,Br(()=>{if(e){let e=t.partsSig.value.findLastIndex(e=>e.kind===`tool`);t.partsSig.value=t.partsSig.value.slice(0,e+1)}t.awaitingContinuation=!1,t.status=`streaming`,t.finishReason=void 0,t.errorText=void 0,t.suggestions=void 0,this.attach(t);for(let e of n)this.apply(e);t.continuationStreaming=r||void 0,this.messagesSig.value=[...this.messagesSig.value]}),t}settleOwnedContinuation(e){let{baseline:t}=this.replay,n=Is(t);return this.replay=null,Br(()=>{t.awaitingContinuation=!1,t.status=`streaming`,t.finishReason=void 0,t.errorText=void 0,t.suggestions=void 0,this.attach(t),this.apply(e),t.continuationStreaming=n||void 0,this.messagesSig.value=[...this.messagesSig.value]}),t}applyResume(e){if(e.type===`start`){let t=(this.replay?.baseline??this.active)?.serverMessageId;t!==void 0&&e.messageId!==void 0&&t!==e.messageId&&this.onReconcileNeeded?.({messageId:t}),this.detach();let n=e.messageId,r=n===void 0?void 0:this.messagesSig.value.find(e=>e.serverMessageId===n||e.id===n);if(r!==void 0)return e.messageMetadata?.senderRole===`visitor`&&r.role===`user`&&(r.status===`pending`||r.status===`error`)&&(r.serverMessageId=n,r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,this.messagesSig.value=[...this.messagesSig.value]),this.beginReplay(r,e),null;let i=e.messageMetadata?.senderRole,a=this.messagesSig.value.at(-1);if(i===void 0&&a?.role===`assistant`&&a.status===`streaming`&&a.serverMessageId===void 0&&!Ds(a))return this.attach(a),this.apply(e),null;let o=hs();return this.attach(o),this.messagesSig.value=[...this.messagesSig.value,o],this.apply(e),null}if(this.replay){let t=this.refreshReplayBaseline();if(!t)return null;t.chunks.push(e),e.type===`data-control-state`&&(t.baseline.operatorRoutedTurn=e.data.controlMode!==`ai-agent`),this.apply(e);let{baseline:n,shadow:r,probeContinuation:i,continuationTailReplay:a,liveCatchUp:o}=t,s=e.type===`finish`||e.type===`error`||e.type===`abort`;if(i){if(!Sm(n,r,e))return s&&(Em(n,r)&&(n.continuationStreaming=!0,this.messagesSig.value=[...this.messagesSig.value],this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id})),this.detach()),null;let t=_m(n)&&s?this.settleOwnedContinuation(e):this.promoteContinuation();return s?(t.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:t.serverMessageId??t.id}):t.continuationStreaming=!1),this.detach(),t):null}if(a&&bm(n,r)){let e=this.promoteContinuation(!0);return s?(this.detach(),e):null}if(!o)return s&&this.detach(),null;if(s&&!Ds(n)&&Ds(r)){let e=this.promoteReplay();return this.detach(),e}if(!ym(n,r))return s&&(this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}),this.detach()),null;let c=this.promoteReplay();return s?(this.detach(),c):null}let t=this.refreshActive();if(!t)return null;if(this.replay)return this.applyResume(e);if(this.apply(e),e.type===`finish`||e.type===`error`||e.type===`abort`){let n=t;return n.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}):n.continuationStreaming=!1),this.detach(),n}return null}ensureTextPart(e,t,n){let r=`${t}:${n}`,i=this.openTextParts.get(r);if(i)return i;let a={kind:t,id:`${n}#${this.partSeq++}`,textSig:H(``),doneSig:H(!1)};return this.openTextParts.set(r,a),Om(e,a),a}apply(e){let t=this.active;if(t)switch(e.type){case`start`:{e.messageId&&(t.serverMessageId=e.messageId);let n=e.messageMetadata;n?.senderRole===`operator`?(t.role=`operator`,n.operatorInitials&&(t.operatorInitials=n.operatorInitials)):n?.senderRole===`visitor`&&(t.role=`user`);return}case`finish-step`:this.openTextParts.clear();return;case`start-step`:Om(t,{kind:`step-start`,id:`ss-${this.partSeq++}`});return;case`finish`:mm.debug(`finish`,{reason:e.finishReason,canContinue:e.canContinue}),t.status=`complete`,t.retryAction=void 0,e.finishReason&&(t.finishReason=e.finishReason),this.bumpDone(t);return;case`error`:mm.warn(`stream error chunk`,{errorText:e.errorText}),t.status=`error`,t.errorText=e.errorText,this.bumpDone(t);return;case`abort`:mm.debug(`stream abort chunk (canceled)`),t.status=`complete`,t.canceled=!0,t.retryAction=void 0,this.bumpDone(t);return;case`text-start`:this.ensureTextPart(t,`text`,e.id);return;case`text-delta`:{let n=this.ensureTextPart(t,`text`,e.id);n.textSig.value+=e.delta;return}case`text-end`:this.ensureTextPart(t,`text`,e.id).doneSig.value=!0;return;case`reasoning-start`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!1;return;case`reasoning-delta`:{let n=this.ensureTextPart(t,`reasoning`,e.id);n.textSig.value+=e.delta;return}case`reasoning-end`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!0;return;case`tool-input-start`:case`tool-input-delta`:case`tool-input-available`:case`tool-input-error`:case`tool-output-available`:case`tool-output-error`:case`tool-output-denied`:case`tool-approval-request`:Am(t,e);return;case`file`:Om(t,{kind:`file`,url:e.url,mediaType:e.mediaType});return;case`source-url`:km(t,{kind:`source`,sourceId:e.sourceId,url:e.url,title:e.title});return;case`source-document`:km(t,{kind:`source`,sourceId:e.sourceId,title:e.title,filename:e.filename,mediaType:e.mediaType});return;case`data-suggestions`:t.suggestions=us(e.data);return;case`data-control-state`:t.operatorRoutedTurn=e.data.controlMode!==`ai-agent`;return;case`data-memory-compaction-state`:return}}bumpDone(e){Br(()=>{e.partsSig.value=[...e.partsSig.value],this.messagesSig.value.includes(e)&&(this.messagesSig.value=[...this.messagesSig.value])})}};const gm={"input-streaming":0,"input-available":1,"approval-requested":2,"approval-responded":3,"output-available":4,"output-denied":4,"output-error":4};function _m(e){return e.awaitingContinuation===!0||e.continuationStreaming===!0||e.retryAction?.kind===`continue-assistant`}function vm(e,t){e.canceled&&(t.canceled=!0),_m(e)&&(t.status===`streaming`||Ps(t))&&(t.awaitingContinuation??(t.awaitingContinuation=e.awaitingContinuation),t.continuationStreaming??(t.continuationStreaming=e.continuationStreaming),t.retryAction===void 0&&(t.retryAction=e.retryAction))}function ym(e,t){let n=e.partsSig.value,r=t.partsSig.value;return e.role!==t.role||r.length<n.length?!1:n.every((e,t)=>xm(e,r[t]))}function bm(e,t){let n=e.partsSig.value,r=n.findLastIndex(e=>e.kind===`tool`),i=new Set(n.slice(0,r+1).flatMap(e=>e.kind===`tool`?[e.toolCallId]:[])),a=t.partsSig.value.filter(e=>e.kind!==`tool`||!i.has(e.toolCallId)),o=n.slice(r+1);return a.length<o.length?!1:o.every((e,t)=>xm(e,a[t]))}function xm(e,t){switch(e.kind){case`text`:case`reasoning`:return t?.kind===e.kind&&t.textSig.value.startsWith(e.textSig.value);case`step-start`:return t?.kind===`step-start`;case`tool`:{if(t?.kind!==`tool`||t.toolCallId!==e.toolCallId||!Ks(t.toolName,e.toolName)||gm[t.stateSig.value]<gm[e.stateSig.value])return!1;let n=e.approvalSig.value?.approved;return n===void 0||t.approvalSig.value?.approved===n}case`file`:return t?.kind===`file`&&t.url===e.url&&t.mediaType===e.mediaType;case`source`:return t?.kind===`source`&&t.sourceId===e.sourceId&&t.url===e.url&&t.title===e.title&&t.filename===e.filename&&t.mediaType===e.mediaType;default:return e}}function Sm(e,t,n){return Cm(e,n)||!wm(e,t)?!0:n.type!==`finish`&&n.type!==`error`&&n.type!==`abort`?!1:Ms(t)||e.awaitingContinuation===!0&&n.type!==`finish`?!0:e.awaitingContinuation===!0&&t.partsSig.value.every(e=>e.kind===`step-start`)}function Cm(e,t){if(t.type!==`tool-output-available`&&t.type!==`tool-output-error`&&t.type!==`tool-output-denied`)return!1;let n=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t.toolCallId);return n!==void 0&&gm[n.stateSig.value]<4}function wm(e,t){let n=t.partsSig.value;if(n.length===0)return!0;let r=e.partsSig.value;return r.some((e,t)=>n.every((e,n)=>Tm(r[t+n],e)))}function Tm(e,t){switch(t.kind){case`text`:case`reasoning`:return e?.kind===t.kind&&e.textSig.value.startsWith(t.textSig.value);case`step-start`:return e?.kind===`step-start`;case`tool`:return e?.kind===`tool`&&e.toolCallId===t.toolCallId&&(t.toolName===`tool`||Ks(e.toolName,t.toolName));case`file`:return e?.kind===`file`&&e.url===t.url&&e.mediaType===t.mediaType;case`source`:return e?.kind===`source`&&e.sourceId===t.sourceId&&e.url===t.url&&e.title===t.title&&e.filename===t.filename&&e.mediaType===t.mediaType;default:return t}}function Em(e,t){if(_m(e)||!Ps(e))return!1;let n=new Set(e.partsSig.value.filter(e=>e.kind===`tool`).map(e=>e.toolCallId));return!t.partsSig.value.some(e=>e.kind===`tool`&&n.has(e.toolCallId))}function Dm(e,t,n,r,i){let a=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);if(a)return r&&(a.dynamic=!0),a.toolMetadata??(a.toolMetadata=i),a;let o={kind:`tool`,toolCallId:t,toolName:n??`tool`,dynamic:r?!0:void 0,toolMetadata:i,inputPartialSig:H(``),inputSig:H(void 0),outputSig:H(void 0),errorSig:H(void 0),stateSig:H(`input-streaming`),approvalSig:H(void 0)};return Om(e,o),o}function Om(e,t){e.partsSig.value=[...e.partsSig.value,t]}function km(e,t){e.partsSig.value.some(e=>e.kind===`source`&&e.sourceId===t.sourceId)||Om(e,t)}function Am(e,t){switch(t.type){case`tool-input-start`:Dm(e,t.toolCallId,t.toolName,t.dynamic,t.toolMetadata);return;case`tool-input-delta`:{let n=Dm(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case`tool-input-available`:{let n=Dm(e,t.toolCallId,t.toolName,t.dynamic,t.toolMetadata);n.inputSig.value=t.input,n.stateSig.value=`input-available`;return}case`tool-input-error`:{let n=Dm(e,t.toolCallId,t.toolName,t.dynamic);n.inputSig.value=t.input,n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-approval-request`:{let n=Dm(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value=`approval-requested`;return}case`tool-output-available`:{let n=Dm(e,t.toolCallId,void 0,t.dynamic);n.outputSig.value=t.output,n.stateSig.value=`output-available`;return}case`tool-output-error`:{let n=Dm(e,t.toolCallId,void 0,t.dynamic);n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-output-denied`:{let n=Dm(e,t.toolCallId);n.stateSig.value=`output-denied`;return}default:return}}const jm=1e3;async function Mm(e){let t=jm,n=!1,r=!1,i=!1;function a(){i||e.signal.aborted||(i=!0,e.onInitialBoundaryReady())}for(;!e.signal.aborted;){let o,s=`held`;try{s=await e.connect(()=>{if(e.signal.aborted)return;o=e.now();let t=n||r;n=!0,r=!1,i?t&&e.backfill():a()})}catch{}if(e.signal.aborted||(!n&&o===void 0&&(r=!0,a()),s===`unavailable`))return;o!==void 0&&e.now()-o>=1e3&&(t=jm),await e.sleep(t),t=Math.min(t*2,15e3)}}function Nm(e){let{activated:t,conversationReady:n,conversationIdSig:r,messagesSig:i,optionsRef:a,transport:o,visitorId:s,adoptControlStateChunk:c,adoptMemoryCompactionStateChunk:l,settleSuggestions:u,recordConversationReply:d,transcriptRecoverySig:f,beginConversationTranscript:p,commitConversationTranscript:m,onReplyLanded:h,runCancellation:g,canContinueRef:_,setCanSend:v,feedback:y,bus:b,loadInitialThread:x,shouldReconcileOnConnect:S}=e,C=z(0);R(()=>{if(!t||!n||!r.value)return;let e=r.value,w=new AbortController,T=e=>{},E=new hm(i,e=>T(e));o.primeIdentity(s,e);let D=!1,O=!1,ee,k=!1,te,ne=0,A=_.current,j,re,ie=Date.now(),ae,oe=!1,se=!1;function ce(t,n,r){if(!Ds(t))return;let o=i.value.findLast(e=>!e.ephemeral),s=t.serverMessageId??t.id;if(!(o&&(o.serverMessageId??o.id)!==s))return Es(i.value,t,e,a.current.strings.newConversation,n,r)}function le(e,t,n,r){let i=ce(e,t,r);if(!i)return;let a=`${e.serverMessageId??e.id}:${n}:${i.preview??``}`;a!==re&&(re=a,o.publishConversation({...i,hasUnread:!0},!0))}let M;function de(){M&&(clearTimeout(M.timer),M=void 0)}function fe(){let e=M;if(!e)return;clearTimeout(e.timer),M=void 0;let t=i.value.find(t=>(t.serverMessageId??t.id)===e.replyId);(t?.role===`assistant`||t?.role===`operator`)&&le(t,e.canContinue,e.generation,e.activityAt)}function pe(e,t,n,r){de(),M={replyId:e.serverMessageId??e.id,canContinue:t,generation:n,activityAt:r,timer:setTimeout(fe,120)}}function me(e,t,n,r=Date.now(),i=!0){de();let a=ce(e,t,r);if(!a)return;let o=`${e.serverMessageId??e.id}:${n}`;o!==j&&(j=o,d(a),i&&ae&&(oe=!0))}function he(e,t){(e||!g.localSendRef.current)&&g.settle(t),e&&h()}function N(e,t=[],n=!1,r,o=A,s=ne,c=Date.now(),l=!0){let d=a.current;if(e.canceled){me(e,o,s,c,l),he(n,r);return}let f=!0,p=e.status===`error`;switch(Qs(e,p)){case`drop`:i.value=i.value.filter(t=>t!==e),f=!1;break;case`complete-operator-routed`:e.status=`complete`,n&&(y.play(`messageReceived`),Dc(b,d,`assistant`,Ts(e)));break;case`error`:if(e.status=`error`,e.errorText=d.strings.errorGeneric,n){y.play(`error`);let e=/* @__PURE__ */ Error(p?`stream error chunk`:`empty reply`);b.emit(`error`,e),d.onError?.(e)}break;case`complete`:e.status=`complete`,n&&(y.play(`messageReceived`),Dc(b,d,`assistant`,Ts(e))),u(e,t)}f&&me(e,o,s,c,l),he(n,r)}function ge(t){if(w.signal.aborted||r.value!==e)return;if(c(t),l?.(t),t.type===`start`){fe();let n=t.messageId===void 0?void 0:i.value.find(e=>e.serverMessageId===t.messageId||e.id===t.messageId);k=n!==void 0&&n.status!==`streaming`;let r=te?.senderRole===`visitor`?te.messageId:void 0;if(te={messageId:t.messageId,senderRole:t.messageMetadata?.senderRole},ne+=1,ie=Date.now(),re=void 0,D=t.messageMetadata?.senderRole===void 0,O=!1,ee=D?t.messageMetadata?.runId:void 0,D){let n=t.messageId!==void 0&&i.value.some(e=>e.serverMessageId===t.messageId||e.id===t.messageId),a=i.value.at(-1),o=t.messageId!==void 0&&(a?.serverMessageId===t.messageId||a?.id===t.messageId),s=g.localSendRef.current&&(!n||o)&&a?.role===`assistant`&&a.status===`streaming`&&(o||a.serverMessageId===void 0&&a.partsSig.value.length===0);O=g.captureStart(e,t,s,r)}}let n=D&&(t.type===`finish`||t.type===`error`||t.type===`abort`),o=n?ee:void 0,s=n&&(O||g.ownsLocalRun(o)),u=ne,d=k;t.type===`finish`&&t.canContinue!==void 0&&(A=t.canContinue);let f=A;n&&(D=!1,O=!1,ee=void 0);let p=E.applyResume(t),m=te?.messageId,h=m===void 0?void 0:i.value.find(e=>e.serverMessageId===m||e.id===m);k&&te?.senderRole!==`visitor`&&(p!==null||h?.status===`streaming`)&&(k=!1,d=!1);let _=!k&&(h?.role===`assistant`||h?.role===`operator`);t.type===`text-delta`&&_&&pe(h,A,ne,ie),t.type===`text-end`&&(de(),_&&le(h,A,ne,ie)),t.type===`finish`&&t.canContinue===!1&&v(!1),p?p.role===`operator`?(d||(y.play(`messageReceived`),Dc(b,a.current,`operator`,Ts(p))),me(p,f,u,ie),k=!1,n&&(s||!g.localSendRef.current)&&g.settle(o)):p.role===`assistant`&&(N(p,[],s,o,f,u,ie),k=!1):n&&(s||!g.localSendRef.current)&&g.settle(o)}async function _e(t){let n=ne,a=await o.loadConversation(e,t?{ids:[t]}:void 0).catch(()=>null);if(w.signal.aborted||r.value!==e||!a)return!1;a.controlState&&c({type:`data-control-state`,data:a.controlState});let s=i.value.at(-1),l=n===ne&&(t===void 0||s!==void 0&&(s.serverMessageId===t||s.id===t));if(a.messages.length===0)return!0;l&&(A=a.canContinue,v(A));let d=i.value,f=t===void 0?d.at(-1):d.find(e=>e.serverMessageId===t||e.id===t),{messages:p,changed:m}=Us(d,Ss(a.messages));if(!m)return!0;i.value=p;let h=t===void 0?p.at(-1):p.find(e=>e.serverMessageId===t||e.id===t),_=f!==void 0&&h!==void 0&&(f.id===h.id||f.serverMessageId!==void 0&&f.serverMessageId===h.serverMessageId),y=h!==void 0&&h.status!==`streaming`&&(!_||f?.status===`streaming`),b=_&&f?.status===`streaming`?Date.now():h?.createdAt;return l&&y&&h.role===`assistant`?N(h,h.suggestions??[],g.localSendRef.current,void 0,a.canContinue,n,b,!1):l&&y&&h.role===`operator`?me(h,a.canContinue,n,b,!1):l&&h?.role===`assistant`&&h.status!==`streaming`&&u(h,h.suggestions??[]),!0}let ve=/* @__PURE__ */ new Set;T=({messageId:e})=>{if(ve.has(e)||!i.value.some(t=>t.serverMessageId===e||t.id===e))return;ve.add(e);function t(){return ve.delete(e)}_e(e).then(t,t)};function ye(t=!1){if(w.signal.aborted||r.value!==e){oe=!1;return}if(ae){oe=!0;return}let n=t?x(e)??(S()?_e():void 0):_e();if(!n)return;p(e),ae=n;function i(t=!1){ae===n&&(ae=void 0,oe?(oe=!1,ye()):t&&m(e))}n.then(i,()=>i(!1))}let be=f.subscribe(e=>{e<=C.current||(C.current=e,se&&ye())});return Mm({signal:w.signal,now:()=>performance.now(),sleep:e=>ue(e,w.signal),connect:e=>o.connectResumeStream({signal:w.signal,onChunk:ge,onConnected:e}),onInitialBoundaryReady:()=>{se=!0,ye(!0)},backfill:()=>ye()}),()=>{w.abort(),de(),be(),E.detach()}},[t,n,r,r.value,s,o,c,l,u,d,f,p,m,h,g,_,v,i,b,y,x,S])}function Pm(e){let{transport:t,setStreaming:n}=e,r=z(void 0),i=z(void 0),a=z(!1),o=z(void 0),s=z(!1),c=z(/* @__PURE__ */ new Map),l=z(/* @__PURE__ */ new Set),u=V((e,n)=>{let r=`${e}:${n}`;o.current!==r&&(o.current=r,t.cancelTurn(e,n))},[t]),d=V(e=>{r.current=void 0,i.current=e,a.current=!1,o.current=void 0,s.current=!0,n(!0)},[n]),f=V((e,t)=>{c.current.set(e,{messageId:t})},[]),p=V(e=>{e!==void 0&&(l.current.add(e),l.current.size>32&&l.current.delete(l.current.values().next().value)),(e===void 0||r.current?.runId===e)&&(r.current=void 0,i.current=void 0,a.current=!1,s.current=!1,n(!1))},[n]),m=V((e,t)=>i.current===e?(i.current=void 0,t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},n(!0),a.current&&u(t.conversationId,t.runId),!0):(p(),!0)):t.runId&&r.current?.runId===t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&u(t.conversationId,t.runId),!0):!1,[u,n,p]),h=V((e,t)=>{let d=c.current.get(e);return d?(c.current.delete(e),!t.runId||l.current.has(t.runId)?!0:d.runId===void 0?(s.current||i.current||(r.current={conversationId:t.conversationId,runId:t.runId},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0)),!0):(d.runId===t.runId&&r.current?.runId===t.runId&&(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&u(t.conversationId,t.runId)),!0)):!1},[u,n]),g=V(e=>i.current===e&&(p(),!0),[p]),_=V(e=>{let t=c.current.get(e);return t?(c.current.delete(e),t.runId===void 0):!1},[]),v=V((e,t,d,f)=>{let p=t.messageMetadata?.runId;if(t.messageMetadata?.senderRole!==void 0||typeof p!=`string`||!p||l.current.has(p))return!1;if(r.current?.runId===p)return s.current;if(s.current)return r.current||!d?!1:(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&u(e,p),!0);let m=[...c.current.values()].filter(e=>e.runId===void 0).find(e=>e.messageId===f);return m?(m.runId=p,r.current={conversationId:e,runId:p},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0),!0):(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&u(e,p),s.current)},[u,n]),y=V(e=>typeof e==`string`&&r.current?.runId===e&&s.current,[]),b=V(()=>{let e=r.current;if(e)return a.current=!0,u(e.conversationId,e.runId),!0;let t=i.current;return t?(a.current=!0,t.then(e=>{e.runId&&u(e.conversationId,e.runId)}).catch(()=>void 0),!0):!1},[u]);return B(()=>({localSendRef:s,begin:d,beginRouted:f,acceptAck:m,acceptRoutedAck:h,reject:g,rejectRouted:_,captureStart:v,ownsLocalRun:y,settle:p,stop:b}),[m,h,d,f,v,y,g,_,p,b])}const Fm=C.scope(`send`);function Im(e,t,n,r,i,a=!0){e.publishConversation({...Es(t,n,r,i,a),hasUnread:!1},!0)}function Lm(e,t){return e.id===t.id||(e.serverMessageId??e.id)===(t.serverMessageId??t.id)}function Rm(e){return e.findLast(e=>!e.ephemeral&&e.role!==`system`&&(e.role===`user`||e.status!==`streaming`||Ds(e)))}function zm(e,t,n,r,i){let a=Rm(t);a?.role===`user`&&Lm(a,n)&&Im(e,t,a,r,i)}function Bm(e){return!(e instanceof ic)||e.code===`network`||e.status===void 0||e.status===202||e.status===408||e.status===425||e.status===429||e.status>=500&&e.status<600}function Vm(e){let{transport:t,messagesSig:n,conversationIdSig:r,options:i,bus:a,feedback:o,persistence:s,visitorId:c,adoptConversationId:l,applyControlState:u,setCanSend:d,settleSuggestions:f,runCancellation:p}=e,m=V(()=>{let e=r.value??Fn();return r.value||(r.value=e,s.saveConversationId(e)),e},[r,s]);return{sendAiTurn:V(async({continueExisting:e,turn:h})=>{let g=m(),_=n.value.at(-1),v=h?[h]:Cs(n.value,e),y=v[0];y?.role===`user`&&M.markSent(y.id);let b=v.map(ws),x=s.loadUserPrefs(),S=Ce(i.tools).then(n=>t.sendTurn(ds({messages:b,conversationId:g,visitorId:c,userPrefs:x,clientTools:we(n)}),{keepalive:e}));p.begin(S);try{let a=await S;if(r.value!==g||!p.acceptAck(S,a))return!1;if(l(a.conversationId),a.runId&&y?.role===`user`&&zm(t,n.value,y,a.conversationId,i.strings.newConversation),!a.runId){let o=await t.loadConversation(a.conversationId).catch(()=>null);if(r.value!==a.conversationId)return!0;if(o){o.controlState&&u(o.controlState),d(o.canContinue);let r=Ss(o.messages),{messages:s,changed:c}=Us(n.value,r);c&&(n.value=s);let l=r.findLast(e=>!e.ephemeral&&e.role!==`system`),p=Rm(n.value);p&&l&&Lm(p,l)&&Im(t,n.value,p,a.conversationId,i.strings.newConversation,o.canContinue);let m=_?n.value.find(e=>e.id===_.id&&e.role===`assistant`&&e.status!==`streaming`):void 0;m&&f(m,m.suggestions??[]),!e&&_?.role===`assistant`&&n.value.includes(_)&&_.serverMessageId===void 0&&!Ds(_)&&(n.value=n.value.filter(e=>e!==_))}else _?.role===`assistant`&&n.value.includes(_)&&(_.status=`error`,_.errorText=i.strings.errorGeneric,_.retryAction=e?{kind:`continue-assistant`,messageId:_.serverMessageId??_.id}:y?.role===`user`?{kind:`resend-user`,messageId:y.id}:null,n.value=[...n.value])}return!0}catch(s){if(r.value!==g)return!1;if(!p.reject(S))return y?.role===`user`&&zm(t,n.value,y,g,i.strings.newConversation),!0;let c=wu(s,i.strings),l=Bm(s),m=h?.role===`assistant`?h:n.value.at(-1);if(e&&m?.role===`assistant`&&s instanceof ic&&s.status===409){let e=m.serverMessageId??m.id,i=await t.loadConversation(g,{ids:[e]}).catch(()=>null);if(r.value!==g)return!1;if(i){i.controlState&&u(i.controlState),d(i.canContinue);let t=Ss(i.messages),r=t.find(t=>(t.serverMessageId??t.id)===e);if(r&&Ws(m,r)){let{messages:r,changed:i}=Us(n.value,t),a=r.find(t=>(t.serverMessageId??t.id)===e);if(i&&a&&a!==m)return a.awaitingContinuation=!1,a.continuationStreaming=void 0,a.retryAction=null,n.value=r,a.status!==`streaming`&&f(a,a.suggestions??[]),!0}}if(!n.value.includes(m)||m.status!==`streaming`)return!1;m.continuationStreaming=!0}if(e&&m?.role===`assistant`)m.status=`error`,m.errorText=c,m.retryAction=l?{kind:`continue-assistant`,messageId:m.serverMessageId??m.id}:null,n.value=[...n.value];else if(_?.role===`assistant`&&n.value.includes(_)){_.status=`error`,_.errorText=c;let e=v[0];_.retryAction=l&&e?.role===`user`?{kind:`resend-user`,messageId:e.id}:null,n.value=[...n.value]}else{let e=hs();e.status=`error`,e.errorText=c;let t=v[0];e.retryAction=l&&t?.role===`user`?{kind:`resend-user`,messageId:t.id}:null,n.value=[...n.value,e]}return o.play(`error`),a.emit(`error`,s),i.onError?.(s),!1}},[t,n,i,a,o,s,c,l,u,d,f,m,p]),sendRoutedTurn:V(async e=>{let u=m();e.status=`pending`,e.errorText=void 0,e.retryAction=void 0,n.value.includes(e)&&(n.value=[...n.value]),M.markSent(e.id);let d=[ws(e)],f=s.loadUserPrefs(),h=Ce(i.tools).then(e=>t.sendTurn(ds({messages:d,conversationId:u,visitorId:c,userPrefs:f,clientTools:we(e)})));p.beginRouted(h,e.id);try{let a=await h;return r.value===u?p.acceptRoutedAck(h,a)?(l(a.conversationId),zm(t,n.value,e,a.conversationId,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0):!1:(p.rejectRouted(h),!1)}catch(s){let c=p.rejectRouted(h);if(r.value!==u)return!1;if(!c)return zm(t,n.value,e,u,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0;if(e.status!==`pending`)return zm(t,n.value,e,u,i.strings.newConversation),!0;Fm.debug(`operator-routed send failed`,{error:s});let l=s instanceof Error?s:Error(String(s));return e.status=`error`,e.errorText=wu(s,i.strings),e.retryAction=Bm(s)?{kind:`resend-user`,messageId:e.id}:null,n.value.includes(e)&&(n.value=[...n.value]),o.play(`error`),a.emit(`error`,l),i.onError?.(l),!1}},[t,n,i,a,o,s,c,l,m,p])}}const Hm=C.scope(`unread`);function Um(e){let{transport:t,options:n,conversationIdSig:r,isConversationVisibleRef:i,activated:a,conversationReady:o}=e,s=vi(!1),c=vi(0),l=vi(0),u=z([]),d=z(void 0),f=z(!1),p=V(()=>{let e=r.value,t=i.current()&&d.current===e?e:void 0,n=u.current.filter(e=>e.hasUnread&&e.conversationId!==t).length;c.value=n,s.value=n>0},[r,s,c,i]),m=V(e=>{let t=r.value,n=u.current.find(e=>e.conversationId===t),i=hc(u.current,e),a=i.find(e=>e.conversationId===t),o=e.type===`snapshot`&&t!==void 0&&a?.hasUnread===!0&&d.current===t&&n!==void 0&&n.lastMessageAt!==a.lastMessageAt;o&&(d.current=void 0),u.current=i,p(),o&&(l.value+=1)},[r,p,l]),h=V(()=>{if(p(),!i.current())return;let e=r.value;if(!e||d.current!==e)return;let n=u.current.find(t=>t.conversationId===e);n?.hasUnread&&t.markRead(e,n.lastMessageAt)},[r,i,p,t]),g=V(e=>{r.value===e&&(d.current=void 0,p())},[r,p]),_=V(e=>{r.value===e&&(d.current=e,h())},[r,h]),v=V(e=>d.current===e,[]),y=V((e=!1)=>{n.history.enabled&&n.modules.list.some(e=>e.layout===`chat`)&&(f.current||(f.current=!0,t.listConversations({limit:50},e).then(t=>{e||m({type:`snapshot`,result:t,requestedRevision:0}),h()}).catch(e=>Hm.debug(`refreshUnread failed (non-fatal)`,{err:e})).finally(()=>{f.current=!1})))},[m,h,n.history.enabled,n.modules,t]),b=V(e=>{let n=e.conversationId,a=i.current()&&r.value===n&&d.current===n,o=u.current.find(e=>e.conversationId===n),s=a&&(o?.lastMessageAt!==e.lastMessageAt||o.hasUnread);t.publishConversation({...e,hasUnread:!a},!0),s&&t.markRead(n,e.lastMessageAt)},[r,i,t]);R(()=>t.subscribeConversationChanges(m),[m,t]);let x=z(!1);return R(()=>{a&&o&&!x.current&&(x.current=!0,y())},[a,o,y]),R(()=>{if(!a)return;function e(){document.visibilityState===`visible`&&(h(),y(!0))}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[a,h,y]),{hasUnreadSig:s,unreadCountSig:c,transcriptRecoverySig:l,markVisibleConversationRead:h,beginConversationTranscript:g,commitConversationTranscript:_,isConversationTranscriptCommitted:v,recordConversationReply:b}}const Wm=C.scope(`settings`);function Gm(e){let{options:t,persistence:n,transport:r,feedback:i,hostElement:a,bus:o}=e,s=n.loadUserPrefs(),[c,l]=L(()=>s.locale??t.locale),[u,d]=L(s.themeMode),f=u??t.themeMode,[p,m]=L(()=>s.textSize??t.textSize),h=V(e=>{n.patchUserPrefs(e),r.saveUserPrefs(n.loadUserPrefs()).catch(e=>Wm.warn(`saveUserPrefs failed`,{err:e}))},[n,r]);R(()=>{s.soundMuted!==void 0&&i.setMuted(s.soundMuted)},[]),R(()=>{if(f!==`host`)a.dataset.theme=f;else return Qn(e=>{a.dataset.theme=e})},[a,f,t]),R(()=>{a.dataset.textSize=p},[a,p,t]),R(()=>{let e=!0;return i.mutedSig.subscribe(t=>{e?e=!1:h({soundMuted:t})})},[i,h]);let g=en(c,t.availableLocales,t.defaultLocale);return R(()=>{r.setLocale(g)},[r,g]),R(()=>{a.dir=kt(g)?`rtl`:`ltr`},[a,g]),R(()=>{g!==c&&l(g)},[g,c]),{activeLocale:c,activeThemeMode:f,activeTextSize:p,effectiveLocale:g,setActiveLocale:l,setActiveThemeMode:d,setActiveTextSize:m,patchAndSync:h,handleLocaleChange:V(e=>{Wm.info(`localeChange`,{locale:e}),l(e),h({locale:e}),o.emit(`localeChange`,e)},[h,o]),handleThemeChange:V(e=>{Wm.info(`themeChange`,{mode:e}),d(e),a.dataset.theme=e,h({themeMode:e}),o.emit(`themeChange`,e)},[a,h,o]),handleTextSizeChange:V(e=>{Wm.info(`textSizeChange`,{size:e}),m(e),a.dataset.textSize=e,h({textSize:e}),o.emit(`textSizeChange`,e)},[a,h,o]),handleSoundToggle:V(()=>{i.toggleMuted();let e=i.mutedSig.value;Wm.info(`soundToggle`,{muted:e}),o.emit(`soundToggle`,{muted:e})},[i,o])}}const $=C.scope(`app`),Km=u.cssPrefix,qm={home:`home`,chats:`chat`,help:`help`,news:`news`};function Jm(e,t){return gs({...e,text:At(t,e.text)})}function Ym({options:e,hostElement:t,bus:n,recentHostEvents:r}){let i=e.aiAgentDeploymentId;if(!i)throw Error(`aiAgentDeploymentId is required`);let[a]=L(()=>Rn(e.widgetId,e.storage,e.aiAgentDeploymentId)),[o]=L(()=>a.getVisitorId()),s=a.loadUserPrefs(),l=vi(a.loadConversationId()),d=z(l.value!==void 0),f=vi(l.value??``),p=vi([]),[m,h]=L(!1),g=z(void 0),[_,v]=L([]);function y(){let t=e.modules.list,n=new Set(t.map(e=>e.id)),r=a.loadActiveModule();return r&&n.has(r)?r:t[0]?.id??``}function b(){return e.modules.list.find(e=>e.layout===`chat`)?.id}function x(){let t=b();return t?e.modules.list.length===1||C.sig.value.activeTab===t:!1}let S=z(void 0);if(!S.current){let t=e.modules.list.map(e=>e.id),n=a.loadActiveModule()??t[0]??``;S.current=Pc(n,n?[...t,n]:t,e=>a.saveActiveModule(e))}let C=S.current,w=yi(()=>C.sig.value.activeTab).value,T=yi(()=>l.value).value,[E,D]=L(!1),[O,ee]=L(null),[k,te]=L(!1),ne=e.mode===`standalone`||e.mode===`inline`,A=z(Bc(e,Vc(),a.loadPanelOpen(),a.loadPanelSize())),[j,re]=L(A.current.panelOpen),[ie,ae]=L(A.current.panelOpen),oe=z(void 0),se=z(void 0),ce=z(!1),le=z(void 0);R(()=>{j&&ae(!0)},[j]);let M=z(!1),[ue,de]=L(!1),{dismissed:fe,dismissCallout:pe}=cm({callout:e.launcher.callout,persistence:a}),me=e.launcher.callout?.persistent??!0,he=V(()=>{$.info(`calloutDismiss`),n.emit(`calloutDismiss`,void 0),pe()},[n,pe]),[N,ge]=L(A.current.panelSize),_e=z(!1),[ve,ye]=L(`chat`),be=z(()=>!1);be.current=()=>j&&ve===`chat`&&!document.hidden&&x();let[xe,Se]=L(!0),Ce=z(xe);Ce.current=xe;let[we,Te]=L(!1),Ee=z(we);Ee.current=we;let De=z(null),[Oe,ke]=L(!1),[Ae,je]=L(null),[Me,P]=L([]),Ne=z(e.strings),Pe=z(e);Pe.current=e;let[Fe,Ie]=L(void 0),[Le,Re]=L(void 0),[ze,Be]=L(()=>a.loadSidebarCollapsed()??!1),[Ve,He]=L({}),[F]=L(()=>new xc({agentApiBaseUrl:e.agentApiBaseUrl,dataApiBaseUrl:e.dataApiBaseUrl,auth:Ci({publicKey:e.publicKey,aiAgentDeploymentId:i,publicKeyHeader:`x-public-key`}),endpoints:e.endpoints,recentHostEvents:r})),[Ue]=L(()=>new Gi(e.sound,e.haptics)),We=Pm({transport:F,setStreaming:Te}),{activeLocale:Ge,activeThemeMode:Ke,activeTextSize:qe,effectiveLocale:Je,setActiveLocale:Ye,setActiveThemeMode:Xe,setActiveTextSize:Ze,patchAndSync:I,handleLocaleChange:Qe,handleThemeChange:$e,handleTextSizeChange:et,handleSoundToggle:tt}=Gm({options:e,persistence:a,transport:F,feedback:Ue,hostElement:t,bus:n}),{controlModeSig:nt,assignedOperatorInitialsSig:rt,operatorAvailableSig:it,applyControlState:at,adoptControlStateChunk:ot,requestOperator:st,cancelOperatorRequest:ct}=lm({transport:F,conversationIdSig:l}),lt=vi(/* @__PURE__ */ new Map),ut=V(e=>{if(e.type!==`data-memory-compaction-state`)return;let t=l.value;if(!t)return;let n=ls(e.data);if(!n)return;let r=lt.value.get(t);if(r&&(n.postFinishSequence<r.postFinishSequence||n.postFinishSequence===r.postFinishSequence&&(r.status===`ready`||r.status===n.status)))return;let i=new Map(lt.value);i.set(t,n),lt.value=i},[l,lt]),{hasUnreadSig:dt,unreadCountSig:ft,transcriptRecoverySig:pt,markVisibleConversationRead:mt,beginConversationTranscript:ht,commitConversationTranscript:gt,isConversationTranscriptCommitted:_t,recordConversationReply:vt}=Um({transport:F,options:e,conversationIdSig:l,isConversationVisibleRef:be,activated:ie,conversationReady:E}),yt=j&&e.modules.byId[w]?.layout===`home`,bt=sm({transport:F,options:e,persistence:a,enabled:E&&yt});R(()=>{mt()},[w,j,ve,T,mt]),R(()=>{Ue.update(e.sound,e.haptics)},[Ue,e.sound,e.haptics]),R(()=>()=>Ue.destroy(),[Ue]),R(()=>{!_e.current&&e.size.initialSize&&(_e.current=!0,!a.loadPanelSize()&&ge(zc(e.mode,e.size,Vc())))},[e.mode,e.size,a]),R(()=>{if(!E||M.current)return;M.current=!0;let t=Bc(e,Vc(),a.loadPanelOpen(),a.loadPanelSize());re(t.panelOpen),ge(t.panelSize)},[E,e,a]);let xt=z(null);R(()=>{E&&C.reconcile(e.modules.list.map(e=>e.id),y())},[E,e.modules.list,C]);let St=V(e=>{e&&e.length!==0&&(p.value=e.map(e=>Jm(e,Ne.current)))},[p]),Ct=z(null),wt=V(async e=>{try{let{formSubmissions:t}=await(e?F.bootstrap(e):Ct.current??F.bootstrap()),n=/* @__PURE__ */ new Map;return t.forEach((e,t)=>n.set(e.formId,t)),t.filter((e,t)=>!e.skipped||n.get(e.formId)===t).map((e,t)=>({key:`wire:${e.formId}:${e.createdAt??t}`,formId:e.formId,outcome:e.skipped?`skipped`:`submitted`,createdAt:ns(e.createdAt),values:e.values}))}catch(e){return $.debug(`bootstrap failed — no form markers (non-fatal)`,{err:e}),[]}},[F]),Tt=z(0),Et=z(0),Dt=V(e=>{if(e===l.value)return;let t=l.value;Et.current++,h(!1),t&&(a.saveDraft(e,a.loadDraft(t)),a.saveDraft(t,``),a.saveMessageQueue(e,a.loadMessageQueue(t)),a.saveMessageQueue(t,[])),l.value=e,a.saveConversationId(e),F.primeIdentity(void 0,e),$.info(`conversation rebound`,{previous:t,current:e}),t&&n.emit(`conversationRebound`,{previous:t,current:e})},[n,l,a,F]),Ot=V((e,t)=>{let n=[...e.map(e=>e.createdAt),...t.map(e=>e.createdAt)].filter(e=>e!==void 0),r=(n.length?Math.min(...n):Date.now())-1;return[...(le.current?.messages??[]).map(e=>{let t=Jm(e,Ne.current);return t.createdAt=r,t}),...e]},[]),kt=V(async e=>{let t=Et.current;function r(){return t!==Et.current||l.value!==e}se.current===e&&(se.current=void 0),h(!0);try{let[t,n]=await Promise.all([F.loadConversation(e),wt()]);if(r())return!1;let i=Ss(t.messages);v(n);let a=Ot(Hs(i,p.value),n);if(p.value=a,se.current=a.some(e=>e.role===`user`)?void 0:e,i.length>0||t.controlState!==void 0){Se(t.canContinue),t.controlState&&at(t.controlState);let e=i.findLast(e=>e.role===`assistant`&&!e.ephemeral);P(e?.suggestions??[])}return!0}catch(t){return r()||($.warn(`loadThread failed; keeping conversation active`,{err:t,conversationId:e}),n.emit(`error`,t),Pe.current.onError?.(t)),!1}finally{r()||h(!1)}},[F,wt,p,l,Ot,n]),jt=V(e=>{if(oe.current===e)return oe.current=void 0,kt(e)},[kt]),Mt=V(()=>{if(g.current)return Promise.resolve(void 0);let t=l.value,r=p.value.find(e=>e.serverMessageId!==void 0),i=r?.serverMessageId,a=r?new Date(r.createdAt).toISOString():void 0;if(!t||!i||!a)return Promise.resolve(void 0);let o=Et.current,s={};return g.current=s,(async()=>{try{let e=await F.loadConversation(t,{beforeId:i,beforeCreatedAt:a});if(g.current!==s||Et.current!==o||l.value!==t)return;if(e.messages.length===0)return!1;let n=e.messages.map(ys),r=p.value,c=Ls(r,n);if(c!==r){let e=Math.min(...n.map(e=>e.createdAt??1/0),..._.map(e=>e.createdAt??1/0));if(Number.isFinite(e))for(let t of r){if(!t.ephemeral)break;(t.createdAt??1/0)>=e&&(t.createdAt=e-1)}p.value=c}return!0}catch(r){if(g.current!==s||Et.current!==o||l.value!==t)return;$.warn(`load previous messages failed`,{err:r,conversationId:t,beforeId:i}),n.emit(`error`,r),e.onError?.(r);return}finally{g.current===s&&(g.current=void 0)}})()},[n,l,_,p,e,F]),Nt=V(async({newConversation:t})=>{let r=++Tt.current;function i(){return r!==Tt.current}let s=l.value,c=t||!s?Fn():s;c!==s&&(Et.current++,h(!1),Br(()=>{l.value=c,f.value=c}),a.saveConversationId(c)),F.primeIdentity(o,c);let u;try{u=await F.handshake({visitorId:o,conversationId:c,userPrefs:a.loadUserPrefs(),locale:Ge})}catch(r){if(i())return;n.emit(`error`,r),e.onError?.(r),t||D(!0);return}if(i())return;u.conversationId!==c&&Dt(u.conversationId),je(u.agent),u.site&&qi(u.site)?Ie(u.site):u.site&&$.warn(`invalid site config, using fallback`,{site:u.site}),u.blocks&&Ji(u.blocks)?Re(u.blocks):u.blocks&&$.warn(`invalid blocks config, using fallback`,{blocks:u.blocks});let p=Vn(u.userPrefs);if(Object.keys(p).length>0&&!t&&(a.saveUserPrefs(p),p.locale&&Ye(p.locale),p.soundMuted!==void 0&&Ue.setMuted(p.soundMuted),p.themeMode&&Xe(p.themeMode),p.textSize&&Ze(p.textSize)),le.current=u.welcome,t||n.emit(`handshake`,u),u.welcome?.suggestions){let e=Ne.current;P(u.welcome.suggestions.map(t=>({...t,label:At(e,t.label),...t.text===void 0?{}:{text:At(e,t.text)}})))}let m=!t&&s&&u.conversationId===s;d.current=!!m,m?ce.current||(oe.current=u.conversationId):(se.current=u.conversationId,St(u.welcome?.messages),gt(u.conversationId)),t||D(!0)},[F,o,a,e,n,l,f,Ue,St,Ge,Dt,gt]),Pt=JSON.stringify(e.userContext??null);R(()=>{let t=Object.keys(Ve).length?{...Ve,...e.userContext}:e.userContext;F.setContext(t,Xm(e.pageContext))},[F,Pt,JSON.stringify(e.pageContext??null),JSON.stringify(Ve)]),R(()=>F.setUserToken(e.userToken),[F,e.userToken]);let Ft=V((e,t=[])=>P(e.suggestions??t),[]);R(()=>(F.primeIdentity(o,l.value),Nt({newConversation:!1}),()=>{Tt.current++,Et.current++}),[]),R(()=>{ie&&E&&!ce.current&&(ce.current=!0,Ct.current=F.bootstrap(),(async()=>{try{let e=await Ct.current;ee(ln((e??{forms:[]}).forms,Je))}catch(e){$.debug(`bootstrap failed — treating as no forms`,{err:e})}finally{te(!0)}})(),oe.current===l.value&&h(!0))},[ie,E]);let It=z(null);R(()=>{if(!ie||!E||(It.current??(It.current=Je),It.current===Je))return;It.current=Je;let e=!1;return F.bootstrap().then(t=>{e||ee(ln((t??{forms:[]}).forms,Je))}).catch(e=>$.debug(`forms re-localize failed — keeping current copy`,{err:e})),()=>{e=!0}},[ie,E,Je,F]);let Lt=z(Pt);R(()=>{E&&Lt.current!==Pt&&(Lt.current=Pt,Nt({newConversation:!1}))},[Pt,E,Nt]),pm({hostElement:t,mode:e.mode,panelSize:N,isOpen:j,surfaceReady:E,setIsOpen:re});let{sendAiTurn:Rt,sendRoutedTurn:zt}=Vm({transport:F,messagesSig:p,conversationIdSig:l,options:e,bus:n,feedback:Ue,persistence:a,visitorId:o,adoptConversationId:Dt,applyControlState:at,setCanSend:Se,settleSuggestions:Ft,runCancellation:We}),{toolInteraction:Bt,pageToolsRunning:Vt,stopPageTools:Ht}=am({streaming:we,controlModeSig:nt,messagesSig:p,sendAiTurn:Rt,bus:n,humanInLoop:e.features.humanInLoop,tools:e.tools}),Ut=V((e,t)=>{let r=p.value.find(t=>t.serverMessageId===e);r&&(r.feedback=t),$.info(`messageFeedback`,{messageId:e,value:t}),n.emit(`messageFeedback`,{messageId:e,value:t}),F.submitFeedback({messageId:e,value:t})},[n,p,F]);function Wt(){return p.value.reduce((e,t)=>e+ +(t.role===`user`),0)}let Gt=e.forms.list.length>0?e.forms:O??e.forms,Kt=Oc({forms:Gt,persistence:a,userContext:()=>e.userContext,messageCount:Wt,pageArea:()=>e.pageContext?.area?String(e.pageContext.area):void 0,conversationId:()=>l.value,onComplete:(e,t,r,i)=>{$.info(`formSubmit`,{formId:e.id,trigger:t,skipped:i}),n.emit(`formSubmit`,{formId:e.id,values:r,skipped:i}),v(t=>{let n=t.find(t=>t.formId===e.id&&t.outcome===`skipped`)?.createdAt??Date.now();return[...t.filter(t=>t.formId!==e.id||t.outcome!==`skipped`),{key:`local:${e.id}:${n}`,formId:e.id,outcome:i?`skipped`:`submitted`,createdAt:n,...i?{}:{values:r}}]});let o=l.value??Fn();l.value||(l.value=o,a.saveConversationId(o),F.primeIdentity(void 0,o)),!i&&e.mirrorToContext&&He(e=>({...e,...r})),F.submitForm({formId:e.id,conversationId:o,trigger:t,values:r,skipped:i})}}),qt=yi(()=>Kt.activeForm.value);Nm({activated:ie,conversationReady:E,conversationIdSig:l,messagesSig:p,optionsRef:Pe,transport:F,visitorId:o,adoptControlStateChunk:ot,adoptMemoryCompactionStateChunk:ut,settleSuggestions:Ft,recordConversationReply:vt,transcriptRecoverySig:pt,beginConversationTranscript:ht,commitConversationTranscript:gt,onReplyLanded:V(()=>Kt.fire(`after-messages`),[Kt]),runCancellation:We,canContinueRef:Ce,setCanSend:Se,feedback:Ue,bus:n,loadInitialThread:jt,shouldReconcileOnConnect:V(()=>d.current||p.value.some(e=>!e.ephemeral&&e.role===`user`),[p])}),R(()=>{Kt.refresh()},[Gt,Kt]);let Jt=e.pageContext?.area?String(e.pageContext.area):void 0,Yt=yi(()=>p.value.length),Xt=z(null);R(()=>{k&&Xt.current&&(Kt.fire(`manual`,Xt.current),Xt.current=null)},[k,Kt]),R(()=>{E&&k&&Kt.fire(`pre-chat`)},[E,k,Kt]),R(()=>{k&&!xe&&Kt.fire(`conversation-closed`)},[k,xe,Kt]),R(()=>{E&&k&&Jt&&Kt.fire(`page-area`)},[E,k,Jt,Kt]);let Zt=B(()=>{let e=Gt.list.flatMap(e=>e.triggers).filter(e=>e.kind===`idle`).map(e=>Number(e.param));return e.length?Math.min(...e)*1e3:0},[Gt]);R(()=>{if(!Zt||!j)return;let e=setTimeout(()=>Kt.fire(`idle`),Zt);return()=>clearTimeout(e)},[Zt,j,Kt,Yt.value]);let Qt=V(async(t,r,i)=>{if(De.current)return!1;let a=l.value,o=a?lt.value.get(a):void 0,s=nt.value!==`ai-agent`;if(!s&&o?.status===`compacting`||($.info(`send`,{textLen:t.length,attachments:r.length,streaming:Ee.current,routedToOperator:s}),Ee.current&&!s))return!1;let c=new AbortController,u={conversationId:a,controller:c};De.current=u,ke(!0);try{Ue.unlock();let o=await Qm(F,r,c.signal,t=>{c.signal.aborted||($.warn(`upload failed`,{err:t}),n.emit(`error`,t),e.onError?.(t))});if(c.signal.aborted||l.value!==a||!Ce.current||Kt.activeForm.value)return!1;let s=a?lt.value.get(a):void 0,u=nt.value!==`ai-agent`;if(!u&&s?.status===`compacting`||Ee.current&&!u||!t&&o.length===0)return!1;n.emit(`send`,{text:t,attachmentCount:r.length}),Me.length>0&&P([]),Ue.play(`messageSent`);let d=ms(t,o,i);return Dc(n,e,`user`,t),u?(p.value=[...p.value,d],i?await zt(d):(zt(d),!0)):(p.value=[...p.value,d,hs()],i?await Rt({continueExisting:!1}):(Rt({continueExisting:!1}),!0))}finally{De.current===u&&(De.current=null,ke(!1))}},[F,n,e,Me.length,p,l,lt,Rt,zt,nt]),$t=z(Qt);$t.current=Qt;let en=l.value,tn=(en?lt.value.get(en):void 0)?.status===`compacting`,nn=nt.value===`ai-agent`,rn=yi(()=>{let e=p.value.at(-1);return e?.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`&&e.stateSig.value===`approval-requested`)}),an=yi(()=>p.value.some(e=>e.retryAction?.kind===`resend-user`||e.retryAction?.kind===`continue-assistant`));kr(()=>{let e=l.value;return()=>{let t=De.current;t&&t.conversationId===e&&(De.current=null,ke(!1),t.controller.abort())}},[l.value]),R(()=>{(!xe||qt.value)&&De.current?.controller.abort()},[qt.value,xe]);let on=V(()=>{if(Vt){$.info(`stop page tools`),n.emit(`stop`,void 0),Ht();return}if(!We.stop())return;$.info(`stop`),n.emit(`stop`,void 0);let e=p.value.at(-1);e&&e.role!==`user`&&e.status===`streaming`&&(e.canceled=!0,p.value=[...p.value])},[We,n,p,Vt,Ht]),sn=V(e=>{if(we)return;let t=p.value,n=Xs(t,e);if(n)switch($.info(`retry`,{kind:n.kind,messageId:n.messageId}),n.kind){case`continue-assistant`:if(nt.value!==`ai-agent`||e.role!==`assistant`||(e.serverMessageId??e.id)!==n.messageId)return;e.status=`streaming`,e.errorText=void 0,e.retryAction=void 0,e.awaitingContinuation=!0,p.value=[...t],Rt({continueExisting:!0,turn:e});return;case`resend-user`:{let r=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!r)return;let i=e=>{e&&xt.current?.acceptQueuedMessage(n.messageId)};if(r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,nt.value!==`ai-agent`){p.value=e.role===`assistant`?t.filter(t=>t!==e):[...t],zt(r).then(i);return}let a=hs();p.value=e.role===`assistant`?t.map(t=>t===e?a:t):[...t,a],Rt({continueExisting:!1,turn:r}).then(i);return}case`repeat-user`:{let e=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!e)return;let r=ms(Ts(e),e.attachments?.map(e=>({...e}))??[]),i=new Set(r.attachments?.flatMap(e=>e.url?[e.url]:[])??[]),a=e.partsSig.value.flatMap(e=>e.kind===`file`&&!i.has(e.url)?[{...e}]:[]);if(a.length>0&&(r.partsSig.value=[...r.partsSig.value,...a]),nt.value!==`ai-agent`){p.value=[...t,r],zt(r);return}p.value=[...t,r,hs()],Rt({continueExisting:!1,turn:r});return}default:return n}},[we,p,nt,Rt,zt]),cn=V(()=>{Ec(e.mode,N)===`exit-fullscreen`?($.info(`close → exit-fullscreen`,{mode:e.mode}),ge(`normal`),n.emit(`fullscreen`,!1)):($.info(`close → panel closed`,{mode:e.mode}),Kt.fire(`panel-close`),re(!1),a.savePanelOpen(!1),n.emit(`close`,void 0),e.onClose?.())},[n,e,a,N,Kt]),un=V(()=>{$.info(`open`,{mode:e.mode}),Ue.unlock(),de(!0),re(!0),a.savePanelOpen(!0),!fe&&!me&&he(),setTimeout(()=>de(!1),Zm),n.emit(`open`,void 0),e.onOpen?.()},[n,e,Ue,a,fe,me,he]),dn=V(()=>{let e=p.value.some(e=>e.role===`user`);if(se.current===l.value&&!e&&xe&&l.value)$.info(`clear → reusing empty conversation`,{conversationId:l.value}),p.value.length===0&&St(le.current?.messages);else return $.info(`clear → new conversation`,{wasStreaming:we}),n.emit(`clear`,void 0),We.settle(),d.current=!1,oe.current=void 0,se.current=void 0,Br(()=>{p.value=[],l.value=void 0,at({controlMode:`ai-agent`,controlRevision:0})}),a.clearConversation(),Se(!0),v([]),P([]),Nt({newConversation:!0})},[we,p,l,a,Nt,n,xe,St,We,at]),pn=V(()=>{let t=dn();ye(`chat`);let n=e.modules.list.find(e=>e.layout===`chat`)?.id;return n&&C.switchTab(n),t},[dn,C,e]),mn=V(async e=>{await pn(),await $t.current(e,[])||xt.current?.fill(e)},[pn]),hn=V(()=>{let e=N===`expanded`?`normal`:`expanded`;$.info(`expand`,{from:N,expanded:e===`expanded`}),ge(e),a.savePanelSize(e),n.emit(`expand`,e===`expanded`)},[n,N,a]),gn=V(()=>{let e=N===`fullscreen`?`normal`:`fullscreen`;$.info(`fullscreen`,{from:N,fullscreen:e===`fullscreen`}),ge(e),a.savePanelSize(e),n.emit(`fullscreen`,e===`fullscreen`)},[n,N,a]),_n=V(()=>{ye(e=>{let t=e===`history`?`chat`:`history`;return $.info(`toggleHistory`,{view:t}),n.emit(`toggleHistory`,{view:t}),t})},[n]),vn=V(()=>{Be(e=>{let t=!e;return $.info(`sidebarToggle`,{collapsed:t}),a.saveSidebarCollapsed(t),n.emit(`sidebarToggle`,{collapsed:t}),t})},[a,n]),yn=V(e=>{$.info(`resize`,e),I({widgetSize:e}),n.emit(`resize`,e)},[I,n]),bn=V(async t=>{let r=t.conversationId;if(r===l.value&&_t(r)){$.info(`selectConversation`,{conversationId:r,cached:!0}),n.emit(`selectConversation`,{conversationId:r}),F.publishConversation(t),ye(`chat`);let e=b();e&&C.switchTab(e),gt(r);return}let i=++Tt.current;Et.current++,h(!1);function s(){return i!==Tt.current}$.info(`selectConversation`,{conversationId:r,wasStreaming:we}),n.emit(`selectConversation`,{conversationId:r}),F.publishConversation(t);try{let[e,t]=await Promise.all([F.loadConversation(r),wt(r)]);if(s())return;We.settle(),d.current=!0,oe.current=void 0;let n=Ss(e.messages),i=e.conversationId!==l.value,c=i?n:Hs(n,p.value);se.current=c.some(e=>e.role===`user`)?void 0:e.conversationId,Br(()=>{p.value=Ot(c,t),i&&(f.value=e.conversationId),l.value=e.conversationId}),v(t),a.saveConversationId(e.conversationId),F.primeIdentity(o,e.conversationId),Se(e.canContinue),e.controlState&&at(e.controlState);let u=c.findLast(e=>e.role===`assistant`&&!e.ephemeral);P(u?.suggestions??[]),i?ht(e.conversationId):gt(e.conversationId),ye(`chat`);let m=b();m&&C.switchTab(m)}catch(t){if(s())return;n.emit(`error`,t),e.onError?.(t)}},[F,p,l,f,n,e,a,wt,Ot,we,o,We,ht,gt,_t,C]),xn=V(e=>{if(typeof e!=`string`)return;j||un(),ye(`chat`);let t=b();t&&C.switchTab(t),k?Kt.fire(`manual`,e):Xt.current=e},[j,un,e.modules,C,k,Kt]),Sn=z(void 0),Cn=V(t=>{let n=e.modules.list.find(e=>e.layout===qm[t.to]);if(!n){$.warn(`open: the widget has no such tab`,{to:t.to});return}let r=t.id&&(n.layout===`help`||n.layout===`news`)?{kind:`content`,id:t.id,title:``}:void 0;C.open(n.id,r)},[e.modules,C]),wn=V(e=>{j||un(),e!==void 0&&(Ti(e)?E?Cn(e):Sn.current=e:$.warn(`open: unknown target`,{detail:e}))},[j,un,E,Cn]);R(()=>{E&&Sn.current&&(Cn(Sn.current),Sn.current=void 0)},[E,Cn]);let Tn=E&&!m&&!qt.value&&(!nn||!rn.value&&!an.value),[En,Dn]=L(),On=V(e=>{let t=Oi(e);t?(j||un(),Dn(t)):$.warn(`ask: expected { text, send? } with non-empty text`,{detail:e})},[j,un]),kn=j&&k&&xe&&E&&!m&&!qt.value,An=kn&&Tn&&!Oe&&!(nn&&(we||tn));R(()=>{if(En===void 0||!(En.send?An:kn))return;let e=b();e?ve!==`chat`||!x()?(ye(`chat`),C.switchTab(e)):(Dn(void 0),En.send?Qt(En.text,[]).then(e=>{e||xt.current?.fill(En.text)}):xt.current?.fill(En.text)):($.warn(`ask: the widget has no chat`),Dn(void 0))},[En,kn,An,ve,w,e.modules,C,Qt]),R(()=>{if(e.widgetId!=="default")return;let n=`data-${u.cssPrefix}-`,r=[`ask`,`open`,`close`,`form`].map(e=>n+e);function i(e){let i=e.composedPath().find(e=>e instanceof Element&&r.some(t=>e.hasAttribute(t)));if(!(i instanceof Element))return;e.preventDefault();let a=i.getAttribute(`${n}ask`),o=i.getAttribute(`${n}open`),s=i.getAttribute(`${n}form`);a===null?o===null?s===null?Ai(t,`close`):Ai(t,`openForm`,s):Ai(t,`open`,Ei(o)):Ai(t,`ask`,Di(a||(i.textContent??``),{send:i.hasAttribute(`${n}send`)}))}return document.addEventListener(`click`,i),()=>document.removeEventListener(`click`,i)},[e.widgetId,t]),R(()=>{if(e.widgetId!=="default")return;let n=Ni(location.href);n&&(history.replaceState(history.state,``,n.url),n.ask?Ai(t,`ask`,Di(n.ask)):Ai(t,`open`,n.target))},[e.widgetId,t]);let jn=z(c),Mn=e.mode===`page`||e.mode===`inline`||e.mode===`standalone`;R(()=>ci(()=>{let e=l.value,t={open:Mn||j,ready:E,unread:ft.value,...e?{conversationId:e}:{}},r=jn.current;(t.open!==r.open||t.ready!==r.ready||t.unread!==r.unread||t.conversationId!==r.conversationId)&&(jn.current=t,n.emit(`state`,t),t.unread!==r.unread&&n.emit(`unread`,t.unread))}),[n,Mn,j,E,ft,l]);let Nn=z({handleOpenCommand:wn,handleClose:cn,handleExpand:hn,handleFullscreen:gn,openForm:xn,handleAskCommand:On});Nn.current={handleOpenCommand:wn,handleClose:cn,handleExpand:hn,handleFullscreen:gn,openForm:xn,handleAskCommand:On},kr(()=>ji(t,{open:e=>Nn.current.handleOpenCommand(e),close:()=>Nn.current.handleClose(),expand:()=>Nn.current.handleExpand(),fullscreen:()=>Nn.current.handleFullscreen(),openForm:e=>Nn.current.openForm(e),ask:e=>Nn.current.handleAskCommand(e)}),[t]);let Pn=B(()=>fn(e,Ge,Ke,qe),[e,Ge,Ke,qe]);Ne.current=Pn.strings;let In=B(()=>_.map(e=>{let t=Gt.list.find(t=>t.id===e.formId);return{...e,title:t?.title,form:t}}),[_,Gt]);function Ln(e){bn(e)}let zn={options:Pn,transport:F,feedback:Ue,bus:n,persistence:a,conversationId:l.value??``,composerKey:f.value,composerApiRef:xt,view:ve,canSend:xe,isStreaming:we,pageToolRunning:Vt,isMemoryCompacting:tn,canReleaseQueuedMessages:Tn,queueManualMessages:nn&&(rn.value||an.value),sendPreparing:Oe,composerActive:Pn.mode===`page`||Pn.mode===`inline`||Pn.mode===`standalone`||j,controlMode:nt.value,assignedOperatorInitials:rt.value,operatorAvailable:it.value,operatorRequestEnabled:e.features.operatorRequest,onRequestOperator:st,onCancelOperatorRequest:ct,loadingMessages:m,onLoadPreviousMessages:Mt,messagesSig:p,agent:Ae,suggestions:Me,initialWidgetSize:s.widgetSize??null,onClose:cn,onClear:dn,onExpand:hn,onFullscreen:gn,onSoundToggle:tt,onToggleHistory:_n,onSelectHistoryConversation:Ln,onNewConversation:pn,onLocaleChange:Qe,onThemeChange:$e,onTextSizeChange:et,onWidgetSizeChange:yn,onSend:Qt,onStop:on,onSuggestion:t=>{if(De.current)return;let r=t.text??t.label;$.info(`suggestion`,{text:r,autoSend:e.autoSendSuggestions}),n.emit(`suggestion`,{text:r}),e.autoSendSuggestions?Qt(r,[]):xt.current?.fill(r)},activeForm:qt.value?.form??null,formMarkers:In,onFormSubmit:Kt.complete,onFormSkip:Kt.skip,onFormFill:e=>Kt.fire(`manual`,e),tool:Bt,onRetry:sn,onMessageFeedback:Ut};if(!E)return null;let Bn=Pn.modules.list;function Hn(e){let t=wc(`close`,Pn.mode,e);return Bn.length===0?/* @__PURE__ */ U(qp,{strings:Pn.strings,onClose:t?cn:void 0}):Bn.length===1&&Bn[0]?.layout===`chat`?/* @__PURE__ */ U(Fp,{...zn,panelSize:e}):/* @__PURE__ */ U(Gp,{panelProps:{...zn,panelSize:e,onClose:t?cn:void 0},enabledModules:Bn,nav:C,bus:n,hasUnread:dt.value,latestNews:bt,onSelectConversation:Ln,onStartNewConversation:mn,onSetPanelSize:ge})}if(e.mode===`page`){let t=e.history.enabled&&Bn.some(e=>e.layout===`chat`);return/* @__PURE__ */ U(`div`,{class:`${Km}-anchor`,children:/* @__PURE__ */ U(em,{site:Fe,blocks:Le,transport:F,strings:Pn.strings,locale:Pn.locale,persistence:a,showConversations:t,onSelectConversation:Ln,onNewConversation:pn,sidebarCollapsed:ze,onToggleSidebarCollapsed:vn,children:Hn(`fullscreen`)})})}if(ne){let t=e.mode===`standalone`?`fullscreen`:N;return/* @__PURE__ */ U(`div`,{class:`${Km}-anchor`,children:Hn(t)})}let Un=e.mode===`drawer`,Wn=e.mode!==`modal`&&!e.launcher.hidden&&(!j||ue),Gn=Wn&&!ue&&!fe&&!Un?Pn.launcher.callout:null;return/* @__PURE__ */ U(`div`,{class:`${Km}-anchor`,"data-launcher-size":Pn.launcher.size,children:[j||ie?/* @__PURE__ */ U(`div`,{class:`${Km}-surface`,hidden:!j,children:Hn(N)}):null,Wn?/* @__PURE__ */ U(Kl,{onToggle:un,launcher:Pn.launcher,strings:Pn.strings,leaving:ue,edgeTab:Un}):null,Gn?/* @__PURE__ */ U(Xl,{callout:Gn,launcherPosition:Pn.position,strings:Pn.strings,closeLabel:Pn.strings.close,onDismiss:he}):null]})}function Xm(e){let t=e?.url??(typeof location<`u`?location.href:void 0);if(e||t)return{...e,...t?{url:t}:{}}}const Zm=120;async function Qm(e,t,n,r){return(await Promise.all(t.map(async t=>{try{let{id:r,url:i,originalName:a,mimeType:o,fileSize:s}=await e.uploadFile(t.file,n);return{id:r,name:a,mediaType:o,size:s,url:i}}catch(e){r(e);return}}))).filter(e=>e!==void 0)}const $m=C.scope(`error-boundary`);var eh=class extends Qe{constructor(...e){super(...e),s(this,`state`,{crashed:!1})}componentDidCatch(e,t){$m.error(`widget render crashed`,{error:e,componentStack:t?.componentStack}),this.setState({crashed:!0}),this.props.onError(e,t?.componentStack)}render(){return this.state.crashed?this.props.fallback:this.props.children}};function th(e){let{bus:t,host:n,appRoot:r,persistence:i,reportError:a}=e,o=e.initialRaw,s,c=Zt(o),l=!0,u=0,d=Pn(t);function f(){c=Zt(s?mn(o,s):o)}function p(){nr(n,rr(c.mode));let e=i.loadUserPrefs().themeMode;dr(n,e?{...c,themeMode:e}:c),l&&(ur(n,nh(c)),l=!1)}function m(){p(),yt(Xe(eh,{onError:a},Xe(Ym,{key:u,bus:t,hostElement:n,options:c,recentHostEvents:d})),r)}t.on(`handshake`,e=>{e.config&&(e.config.storageVersion&&i.rememberStorageVersion(e.config.storageVersion),s=e.config,f(),m())});let h=qn(t,{getOptions:()=>c,getVisitorId:()=>i.getVisitorId(),getConversationId:()=>i.loadConversationId()});function g(e={}){i.reset(),o={...o,userContext:void 0,userToken:void 0,...e},d.length=0,u+=1,l=!0,f(),m()}return{getOptions:()=>c,getUserOptions:()=>o,render:m,setUserOptions:e=>{o=e,f(),m()},patchUserOptions:e=>{let t=`userToken`in e&&e.userToken!==o.userToken;t&&o.userToken?g(e):(t&&(u+=1),o={...o,...e},f(),m())},reset:()=>g(),destroy:()=>h()}}function nh(e){if(e.mode===`standalone`)return`standalone`;if(e.mode===`inline`)return`inline`;let t=Rn(e.widgetId,e.storage,e.aiAgentDeploymentId),{panelOpen:n,panelSize:r}=Bc(e,Vc(),t.loadPanelOpen(),t.loadPanelSize());return Rc(e.mode,r,n)}const rh=C.scope(`hooks`),ih=`*`,ah=/* @__PURE__ */ new Set;function oh(e,t,n){let r={widgetId:e,event:t,listener:n};return ah.add(r),()=>{ah.delete(r)}}function sh(e,t,n){let r=[...ah];for(let i of r)if(lh(i.widgetId,e.widgetId)&&(i.event===`*`||i.event===t))try{i.listener(e,t,n)}catch(e){rh.warn(`hook listener threw`,{event:t,error:e})}}function ch(e,t){let n=[];for(let r of uh)n.push(t.on(r,t=>{sh(e,r,t)}));return()=>{for(let e of n)e()}}function lh(e,t){return e===`*`||e===t}const uh=/* @__PURE__ */ `open.close.expand.fullscreen.resize.message.send.stop.clear.selectConversation.suggestion.toggleHistory.formSubmit.toolResult.toolDecision.hostEvent.messageFeedback.contentView.contentOpen.contentSearch.contentRead.contentLinkClick.attach.removeAttachment.voiceStart.voiceStop.voiceCancel.localeChange.themeChange.textSizeChange.soundToggle.sidebarToggle.calloutDismiss.error.handshake.conversationRebound.state.unread`.split(`.`),dh=C.scope(`iframe`);function fh(e,t,n=`closed`,r=`floating`,i=null){dh.debug(`createIframeMount`,{position:t,initialMode:n,layoutMode:r,hasTarget:!!i});let a=document.createElement(`iframe`);a.title=`${u.name} chat`,a.setAttribute(`allow`,`microphone; clipboard-write`),hh(a,t,n,r),(r===`inline`&&i?i:document.body).appendChild(a);let o=a.contentDocument;if(!o)throw Error(`iframe contentDocument unavailable (cross-origin?)`);o.open(),o.write(`<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;background:transparent;overflow:hidden}</style></head><body></body></html>`),o.close();let s=ir({...e,target:o.body}),c=new MutationObserver(()=>{hh(a,t,s.hostElement.dataset.mode??`closed`,r)});return c.observe(s.hostElement,{attributes:!0,attributeFilter:[`data-mode`]}),{...s,iframeElement:a,destroy(){c.disconnect(),s.destroy(),a.remove()}}}const ph=`border:0;background:transparent;z-index:2147483647;pointer-events:auto;`,mh={closed:{w:`88px`,h:`88px`},expanded:{w:`min(calc(100vw - 32px), 680px)`,h:`min(calc(100vh - 32px), 860px)`},open:{w:`min(calc(100vw - 32px), 440px)`,h:`min(calc(100vh - 32px), 700px)`}};function hh(e,t,n,r){if(n===`fullscreen`||r===`standalone`){e.style.cssText=`${ph}position:fixed;inset:0;width:100vw;height:100vh;`;return}if(r===`inline`){e.style.cssText=`${ph}position:static;display:block;width:100%;height:100%;`;return}if(typeof matchMedia==`function`&&matchMedia(`(max-width: 640px)`).matches&&(n===`open`||n===`expanded`)){e.style.cssText=`${ph}position:fixed;inset:0;width:100vw;height:100vh;`;return}let i=t.startsWith(`top-`)?`top`:`bottom`,a=t.endsWith(`-left`)?`left`:`right`,{w:o,h:s}=mh[n]??mh.open;e.style.cssText=`${ph}position:fixed;${i}:16px;${a}:16px;width:${o};height:${s};`}const gh=/* @__PURE__ */ new Map;function _h(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);e.debug!==void 0&&b(e.debug);let t=C.scope(`mount`);t.info(`mount`,{widgetId:e.widgetId,publicKey:e.publicKey,mode:e.presentation?.mode});let n=Zt(e),r=n.widgetId,i=gh.get(r);i&&(t.debug(`destroy existing instance at slot`,{widgetId:r}),i.destroy());let a=nh(n),o=n.iframe?fh({position:rr(n.mode)},n.position,a,n.mode,e.target??null):ir({position:rr(n.mode),target:e.target??null});o.hostElement.dataset.widgetId=r;let s=new l,u=Rn(r,n.storage,n.aiAgentDeploymentId);function d(e){s.emit(`error`,e),f.getOptions().onError?.(e)}let f=th({bus:s,host:o.hostElement,appRoot:o.appRoot,persistence:u,initialRaw:e,reportError:d}),p=c,m=()=>{},h=new Promise(e=>{m=e});s.on(`state`,e=>{p=e,e.ready&&m()}),f.render();let g=o.hostElement,_=null;function v(e){e.debug!==void 0&&b(e.debug),f.patchUserOptions(e)}let y={widgetId:r,open:e=>Ai(g,`open`,e),close:()=>Ai(g,`close`),expand:()=>Ai(g,`expand`),openForm:e=>Ai(g,`openForm`,e),ask:(e,t)=>Ai(g,`ask`,Di(e,t)),on:(e,t)=>s.on(e,t),update:e=>{t.debug(`update`,{patch:e}),v(e)},setUserContext:e=>{t.debug(`setUserContext`,{keys:Object.keys(e)}),v({userContext:{...f.getUserOptions().userContext,...e}})},clearUserContext:()=>{t.debug(`clearUserContext`),v({userContext:void 0})},setPageContext:e=>{t.debug(`setPageContext`,{keys:Object.keys(e)}),v({pageContext:{...f.getUserOptions().pageContext,...e}})},clearPageContext:()=>{t.debug(`clearPageContext`),v({pageContext:void 0})},get state(){return p},ready:h,reset:()=>{t.info(`reset`,{widgetId:r}),f.reset()},login:e=>{t.info(`login`,{widgetId:r}),v({userToken:e})},track:(e,t)=>{let n=Nn(e,t);n&&s.emit(`hostEvent`,n)},registerTool:ve,setDebug:e=>{b(e),t.info(`debug level set`,{level:x()})},debugLevel:()=>x(),onLog:e=>w(e),destroy:()=>{t.info(`destroy`,{widgetId:r}),s.emit(`state`,c),_?.(),f.destroy(),s.clear(),yt(null,o.appRoot),o.destroy(),gh.get(r)===y&&gh.delete(r)}};return _=ch(y,s),gh.set(r,y),y}function vh(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);let t=e.widgetId??`default`,n=gh.get(t);return n?(n.update(e),n):_h(e)}function yh(e){if(e!==void 0){gh.get(e)?.destroy();return}let t=[...gh.values()];for(let e of t)e.destroy()}function bh(e=`default`){return gh.get(e)??null}function xh(){return[...gh.values()]}function Sh(e,t,n){return oh(e,t,n)}const Ch=Hn,wh=u,Th=/* @__PURE__ */ new WeakMap;let Eh=0;function Dh(e){if(typeof e!=`function`)return e;let t=Th.get(e)??++Eh;return Th.set(e,t),`function#${t}`}function Oh(t){let r=n(t);r.current=t;let i=t.widgetId??`default`,a=JSON.stringify({...t,userToken:Dh(t.userToken)});return e(()=>()=>yh(i),[i]),e(()=>{vh({...r.current,userToken:r.current.userToken,onMessage:e=>r.current.onMessage?.(e),onOpen:()=>r.current.onOpen?.(),onClose:()=>r.current.onClose?.(),onError:e=>r.current.onError?.(e),tools:r.current.tools?.map(e=>Object.assign({},e,{execute:(t,n)=>(r.current.tools?.find(t=>t.name===e.name)??e).execute(t,n)}))})},[a]),null}function kh(e=`default`){return{state:r(t=>Sh(e,`state`,t),()=>bh(e)?.state??c,()=>c),...t(()=>({ask:(t,n)=>bh(e)?.ask(t,n),open:t=>bh(e)?.open(t),close:()=>bh(e)?.close(),reset:()=>bh(e)?.reset(),track:(t,n)=>bh(e)?.track(t,n)}),[e])}}function Ah(t){let r=n(t);r.current=t;let i=JSON.stringify(t);e(()=>{let e=new AbortController;return ve({...r.current,execute:(e,t)=>r.current.execute(e,t)},{signal:e.signal}),()=>e.abort()},[i])}export{ih as HOOK_WILDCARD,Oh as HelpAI,wh as brand,yh as destroy,xh as getAllInstances,bh as getInstance,Sh as hook,vh as init,_h as mount,nh as resolveInitialHostMode,kh as useHelpAI,Ah as useHelpAITool,Ch as version};
62
+ `).trim(),O=!v&&t!==`error`&&!m.value&&D.length>0,ee=E||O;return/* @__PURE__ */ U(`div`,{class:`${dp}-bubble-row`,"data-role":e.role,"data-testid":Wl(Z.messageBubble,e.serverMessageId??e.id),children:/* @__PURE__ */ U(`div`,{class:`${dp}-bubble-col`,children:[/* @__PURE__ */ U(`div`,{class:`${dp}-bubble`,children:[e.role===`operator`&&e.operatorInitials?/* @__PURE__ */ U(`span`,{class:`${dp}-bubble-author`,children:e.operatorInitials}):null,/* @__PURE__ */ U(`div`,{class:`${dp}-bubble-body`,children:[x?/* @__PURE__ */ U(Cp,{label:n.loading}):p.map((r,u)=>/* @__PURE__ */ U(gp,{part:r,generativeUi:e.role===`assistant`,active:S,live:y,strings:n,showReasoning:i,showToolCalls:a,showSources:o,interactive:s&&t===`complete`&&(r.kind!==`tool`||Fs(e,u)),superseded:c,continuationStreaming:e.continuationStreaming===!0,tool:l},`${xp(r)}#${u}`)),C&&/* @__PURE__ */ U(Sp,{}),t===`error`||m.value?/* @__PURE__ */ U(`div`,{class:`${dp}-error`,role:`alert`,children:[/* @__PURE__ */ U(`span`,{children:e.errorText??n.errorGeneric}),u?/* @__PURE__ */ U(`button`,{type:`button`,class:`${dp}-error-retry`,onClick:()=>u(e),"data-testid":Z.messageRetry,children:n.errorRetry}):null]}):null]})]}),w||ee?/* @__PURE__ */ U(`div`,{class:`${dp}-bubble-meta`,children:[w?/* @__PURE__ */ U(`time`,{class:`${dp}-bubble-time`,dateTime:w.iso,title:w.full,children:w.short}):null,ee?/* @__PURE__ */ U(`div`,{class:`${dp}-bubble-actions`,children:[E&&e.serverMessageId?/* @__PURE__ */ U(yf,{messageId:e.serverMessageId,initial:e.feedback??null,strings:n,onFeedback:f}):null,O?/* @__PURE__ */ U(mp,{text:D,strings:n}):null]}):null]}):null]})})}function mp({text:e,strings:t}){let[n,r]=L(!1);function i(){navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})}let a=n?t.copied:t.copy;return/* @__PURE__ */ U(`button`,{type:`button`,class:`${dp}-msg-action`,"data-active":n?`true`:void 0,"aria-label":a,title:a,onClick:i,"data-testid":Z.messageCopy,children:U(n?ul:Il,{})})}function hp(e){if(typeof e!=`number`||!Number.isFinite(e))return null;try{let t=new Date(e);return{short:t.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`}),full:t.toLocaleString(void 0,{dateStyle:`full`,timeStyle:`short`}),iso:t.toISOString()}}catch{return null}}function gp({part:e,generativeUi:t,active:n,live:r,strings:i,showReasoning:a,showToolCalls:o,showSources:s,interactive:c,superseded:l,continuationStreaming:u,tool:d}){switch(e.kind){case`step-start`:return null;case`text`:return/* @__PURE__ */ U(nu,{textSig:e.textSig,doneSig:e.doneSig,generativeUi:t,strings:i});case`reasoning`:return a?/* @__PURE__ */ U(bp,{part:e,active:n,strings:i}):null;case`tool`:return/* @__PURE__ */ U(yp,{part:e,strings:i,showToolCalls:o,interactive:c,superseded:l,continuationStreaming:u,live:r,tool:d});case`file`:return/* @__PURE__ */ U(_p,{part:e,strings:i});case`source`:return s?/* @__PURE__ */ U(Hf,{part:e,strings:i}):null}}function _p({part:e,strings:t}){let n=e.filename??t.file;if(e.mediaType.startsWith(`image/`))return/* @__PURE__ */ U(`a`,{class:`${dp}-file-image`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:n,"data-testid":Z.messageFile,children:/* @__PURE__ */ U(`img`,{src:e.url,alt:n,loading:`lazy`})});let r=(n.includes(`.`)?n.split(`.`).pop():e.mediaType.split(`/`).pop())?.toUpperCase(),i=e.fileSize===void 0?void 0:vp(e.fileSize);return/* @__PURE__ */ U(`a`,{class:`${dp}-file-chip`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:n,"data-testid":Z.messageFile,children:[/* @__PURE__ */ U(`span`,{class:`${dp}-file-chip-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(gl,{})}),/* @__PURE__ */ U(`span`,{class:`${dp}-file-chip-text`,children:[/* @__PURE__ */ U(`span`,{class:`${dp}-file-chip-name`,children:n}),/* @__PURE__ */ U(`span`,{class:`${dp}-file-chip-meta`,children:[r,i].filter(Boolean).join(` · `)})]})]})}function vp(e){let t=Math.min(Math.floor(Math.log10(Math.max(e,1))/3),2);return new Intl.NumberFormat(void 0,{style:`unit`,unit:[`byte`,`kilobyte`,`megabyte`][t],unitDisplay:`narrow`,maximumFractionDigits:1}).format(e/1e3**t)}function yp({part:e,strings:t,showToolCalls:n,interactive:r,superseded:i,continuationStreaming:a,live:o,tool:s}){let c=B(()=>ri(()=>e.approvalSig.value!==void 0),[e]);return s?.humanInLoop&&c.value?_f(e.toolName)?/* @__PURE__ */ U(np,{part:e,strings:t,active:r,superseded:i,continuationStreaming:a,onDecision:s.onDecision,onEdit:s.onEdit}):/* @__PURE__ */ U(Wf,{part:e,strings:t,active:r,superseded:i,continuationStreaming:a,onDecision:s.onDecision,onEdit:s.onEdit}):n?/* @__PURE__ */ U(up,{part:e,strings:t,live:o,superseded:i}):null}function bp({part:e,active:t,strings:n}){return/* @__PURE__ */ U(`details`,{class:`${dp}-reasoning`,"data-testid":Z.reasoning,open:t,"data-active":t?`true`:void 0,children:[/* @__PURE__ */ U(`summary`,{class:`${dp}-reasoning-summary`,children:/* @__PURE__ */ U(`span`,{class:`${dp}-reasoning-label`,children:t?n.thinking:n.thoughts})}),/* @__PURE__ */ U(`div`,{class:`${dp}-reasoning-body`,children:/* @__PURE__ */ U(nu,{textSig:e.textSig,doneSig:e.doneSig})})]})}function xp(e){switch(e.kind){case`text`:case`reasoning`:case`step-start`:return`${e.kind}:${e.id}`;case`tool`:return`tool:${e.toolCallId}`;case`file`:return`file:${e.url}`;case`source`:return`source:${e.sourceId}`}}function Sp(){return/* @__PURE__ */ U(`span`,{class:`${dp}-typing`,"data-testid":Z.typingDots,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`span`,{}),/* @__PURE__ */ U(`span`,{}),/* @__PURE__ */ U(`span`,{})]})}function Cp({label:e}){return/* @__PURE__ */ U(`span`,{class:`${dp}-loading`,role:`status`,children:[/* @__PURE__ */ U(`span`,{class:`${dp}-loading-spinner`,"aria-hidden":`true`}),/* @__PURE__ */ U(`span`,{class:`${dp}-loading-label`,children:e})]})}const wp=u.cssPrefix;function Tp({messagesSig:e,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,enableMessageFeedback:o,onFeedback:s,loading:c,onLoadPreviousMessages:l,idle:u,controlMode:d=`ai-agent`,tool:f,onRetry:p,form:m,formMarkers:h,onFillForm:g}){let _=z(null),v=yi(()=>e.value),[y,b]=L(!1),[x,S]=L(!1),C=z(!1),w=z(!1),[T,E]=L(),D=z(!1),O=z(!1),ee=z(!1),k=z(0);function te(){return ee.current||performance.now()-k.current<350}let ne=z(0);function A(e){let t=e.scrollHeight-e.clientHeight>1;e.dataset.fadeTop=t&&e.scrollTop>1?`true`:`false`,e.dataset.fadeBottom=t&&e.scrollHeight-e.scrollTop-e.clientHeight>1?`true`:`false`}function j(e){return b(e.scrollHeight-e.scrollTop-e.clientHeight>240)}function re(e){ne.current=performance.now(),e.scrollTop=e.scrollHeight,A(e)}function ie(e,t){re(e);let n=t,r=0;function i(){O.current||te()||(re(e),--n>0&&(r=requestAnimationFrame(i)))}return t>0&&(r=requestAnimationFrame(i)),()=>cancelAnimationFrame(r)}function ae(e,t){let n,r,i,a=-1;function o(){n.disconnect(),r.disconnect(),clearTimeout(i)}function s(){if(O.current||te()||a>=0&&e.scrollTop<a-4)return o();re(e),a=e.scrollTop}return n=new ResizeObserver(s),r=new MutationObserver(s),s(),n.observe(e),r.observe(e,{childList:!0,subtree:!0,characterData:!0}),i=setTimeout(o,t),o}let oe=v.value[0]?.id;kr(()=>{let e=_.current;if(e&&v.value.length!==0&&!w.current&&(D.current=!0,v.value.some(e=>e.role===`user`)))return ae(e,300)},[oe]);let se=z(0);R(()=>{let e=_.current,t=v.value,n=se.current;if(se.current=t.length,e&&D.current&&!w.current){if(t.slice(n).some(e=>e.role===`user`))return O.current=!1,ie(e,3);t.some(e=>e.role===`user`)&&(O.current||te()||e.scrollHeight-e.scrollTop-e.clientHeight<120&&re(e))}},[v.value.length]);let ce=z(null);R(()=>{let e=_.current,t=v.value.at(-1),n=ce.current;if(ce.current=t?{id:t.id,streaming:t.status===`streaming`}:null,e&&D.current&&t&&t.id===n?.id&&!n.streaming&&t.status===`streaming`)return O.current=!1,ie(e,3)},[v.value]),R(()=>{let e=_.current;if(!e)return;let t=v.value.at(-1);if(!t||t.status!==`streaming`&&!v.value.some(e=>e.role===`user`))return;let n=()=>{O.current||te()||e.scrollHeight-e.scrollTop-e.clientHeight<240&&re(e)};if(t.status!==`streaming`)return ae(e,300);n();let r=new MutationObserver(n);return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[v.value]);let le=m?.form.id,M=!!m&&(h??[]).some(e=>e.formId===m.form.id);kr(()=>{let e=_.current;e&&le&&!O.current&&v.value.some(e=>e.role===`user`)&&(M?e.querySelector(`[data-testid="${Z.formGate}"]`)?.scrollIntoView({block:`nearest`}):re(e))},[le,M]),R(()=>{let e=_.current;if(!e)return;let t=()=>{j(e),A(e),performance.now()-ne.current>150&&(O.current=e.scrollHeight-e.scrollTop-e.clientHeight>8)};function n(){O.current=!0}function r(e){e.deltaY<0&&n()}let i=0;function a(e){i=e.touches[0]?.clientY??0,ee.current=!0}function o(e){(e.touches[0]?.clientY??0)>i+4&&n()}function s(){ee.current=!1,k.current=performance.now()}function c(){ee.current=!0}return e.addEventListener(`scroll`,t,{passive:!0}),e.addEventListener(`wheel`,r,{passive:!0}),e.addEventListener(`touchstart`,a,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`touchend`,s,{passive:!0}),e.addEventListener(`touchcancel`,s,{passive:!0}),e.addEventListener(`pointerdown`,c,{passive:!0}),window.addEventListener(`pointerup`,s,{passive:!0}),window.addEventListener(`pointercancel`,s,{passive:!0}),j(e),()=>{e.removeEventListener(`scroll`,t),e.removeEventListener(`wheel`,r),e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s),e.removeEventListener(`touchcancel`,s),e.removeEventListener(`pointerdown`,c),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[]);function ue(){let e=_.current;e&&(O.current=!1,re(e))}let de=v.value.filter(e=>!e.ephemeral),fe=de[0],pe=fe?.serverMessageId??fe?.id,me=!!(l&&de.length>=50&&pe!==T);async function he(){if(!l||C.current)return;let e=_.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;C.current=!0,w.current=!0,S(!0);try{let r=await l();r===!1&&pe&&E(pe),r&&e&&(await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e()))),e.scrollTop=n+e.scrollHeight-t,A(e),j(e))}finally{w.current=!1,C.current=!1,S(!1)}}let N=[],ge=``,_e=v.value.at(-1)?.id,ve=[...h??[]].toSorted((e,t)=>(e.createdAt??1/0)-(t.createdAt??1/0));function ye(e){return m&&e.formId===m.form.id?/* @__PURE__ */ U(nf,{form:m.form,strings:t,onSubmit:m.onSubmit,onSkip:m.onSkip},`gate:${e.formId}`):/* @__PURE__ */ U(rf,{marker:e,strings:t,onFill:!m&&g?()=>g(e.formId):void 0},e.key)}function be(e){for(let t=ve[0];t?.createdAt!==void 0&&!(e!==void 0&&t.createdAt>e);t=ve[0])ve.shift(),N.push(ye(t))}for(let e of v.value){if(e.role===`assistant`&&e.id!==_e&&Ys(e))continue;be(e.createdAt);let c=Ep(e.createdAt);c&&c!==ge&&(N.push(/* @__PURE__ */ U(`div`,{class:`${wp}-date-divider`,children:/* @__PURE__ */ U(`span`,{class:`${wp}-date-pill`,title:Dp(e.createdAt),children:Op(e.createdAt,t)})},`day:${c}`)),ge=c);let l=e.retryAction!==void 0||e.role===`assistant`&&e.id===_e?Xs(v.value,e):void 0,m=l!==void 0&&(l.kind!==`continue-assistant`||d===`ai-agent`);N.push(/* @__PURE__ */ U(fp,{message:e,status:e.status,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,interactive:!!u&&d===`ai-agent`&&e.id===_e,superseded:e.id!==_e,tool:f,onRetry:u&&m&&(e.role===`user`||e.id===_e)?p:void 0,enableMessageFeedback:o,onFeedback:s},e.id))}for(let e of ve)N.push(ye(e));return/* @__PURE__ */ U(`div`,{class:`${wp}-list-wrap`,children:[/* @__PURE__ */ U(`div`,{ref:_,class:`${wp}-list ${wp}-list--fade`,part:`messages`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,children:[c&&v.value.length===0?/* @__PURE__ */ U(`div`,{class:`${wp}-list-loading`,role:`status`,children:t.conversationLoading}):null,me?/* @__PURE__ */ U(`div`,{class:`${wp}-load-previous`,children:/* @__PURE__ */ U(`button`,{type:`button`,onClick:he,disabled:x,"aria-busy":x,"data-testid":Z.loadPreviousMessages,children:t.loadPreviousMessages})}):null,N,m&&!M?/* @__PURE__ */ U(nf,{form:m.form,strings:t,onSubmit:m.onSubmit,onSkip:m.onSkip}):null]}),y?/* @__PURE__ */ U(`button`,{type:`button`,class:`${wp}-jump`,onClick:ue,"aria-label":t.scrollToBottom,title:t.scrollToBottom,"data-testid":Z.scrollToBottom,children:/* @__PURE__ */ U(hl,{})}):null]})}function Ep(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function Dp(e){if(typeof e!=`number`||!Number.isFinite(e))return``;try{return new Date(e).toLocaleDateString(void 0,{dateStyle:`full`})}catch{return``}}function Op(e,t){let n=new Date(e);function r(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}let i=Math.round((r(/* @__PURE__ */ new Date)-r(n))/864e5);return i<=0?t.dateToday:i===1?t.dateYesterday:i<7?n.toLocaleDateString(void 0,{weekday:`long`}):n.toLocaleDateString(void 0,{month:`long`,day:`numeric`,year:`numeric`})}function kp({panelEl:e,resize:t,position:n,initialSize:r,onSizeChange:i,strings:a}){let o=u.cssPrefix,s=z(null);if(R(()=>{if(!e)return;let n=e.style;t.minWidth&&n.setProperty(`--${o}-resize-min-w`,t.minWidth),t.maxWidth&&n.setProperty(`--${o}-resize-max-w`,t.maxWidth),t.minHeight&&n.setProperty(`--${o}-resize-min-h`,t.minHeight),t.maxHeight&&n.setProperty(`--${o}-resize-max-h`,t.maxHeight),r&&(n.setProperty(`--${o}-widget-w`,`${r.width}px`),n.setProperty(`--${o}-widget-h`,`${r.height}px`))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,o,r]),!e)return null;let c=n.startsWith(`top-`),l=n.endsWith(`-right`),d=`${o}-resize-grip ${o}-resize-grip--${c?`bottom`:`top`}-${l?`left`:`right`}`;function f(t){if(!e)return;let n=t.currentTarget,r=e.getBoundingClientRect();s.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startW:r.width,startH:r.height,dirX:l?-1:1,dirY:c?1:-1},n.setPointerCapture(t.pointerId),e.setAttribute(`data-resizing`,``),t.preventDefault()}function p(t){let n=s.current;if(!n||t.pointerId!==n.pointerId||!e)return;let r=(t.clientX-n.startX)*n.dirX,i=(t.clientY-n.startY)*n.dirY;e.style.setProperty(`--${o}-widget-w`,`${n.startW+r}px`),e.style.setProperty(`--${o}-widget-h`,`${n.startH+i}px`)}function m(t){let n=s.current;if(!n||t.pointerId!==n.pointerId||!e)return;t.currentTarget.releasePointerCapture(t.pointerId),e.removeAttribute(`data-resizing`);let r=e.getBoundingClientRect();i({width:Math.round(r.width),height:Math.round(r.height)}),s.current=null}return/* @__PURE__ */ U(`div`,{class:d,role:`separator`,"aria-orientation":`vertical`,"aria-label":a.resizeHandle,title:a.resizeHandle,onPointerDown:f,onPointerMove:p,onPointerUp:m,onPointerCancel:m,"data-testid":Z.resizeGrip,children:/* @__PURE__ */ U(il,{})})}const Ap=u.cssPrefix;function jp({suggestions:e,onPick:t,disabled:n=!1}){return e.length===0?null:/* @__PURE__ */ U(`div`,{class:`${Ap}-suggestions`,role:`group`,"aria-label":`Suggested replies`,children:e.map((e,r)=>/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ap}-suggestion`,onClick:()=>t(e),disabled:n,"data-testid":Wl(Z.suggestion,r),children:e.label},e.id))})}const Mp=u.cssPrefix,Np=`.${Mp}-header, .${Mp}-back-header, .${Mp}-home-hero`;function Pp(e,t){R(()=>{if(!t||!e)return;function n(e){return Number.parseFloat(e)||0}function r(e,t){return Math.min(t,Math.max(-t,e))}let i=null,a=t=>{let r=t.target;if(!(r instanceof Element)||!r.closest(Np)||r.closest(`button, a, input, textarea, select, [role="tab"], [contenteditable]`))return;let a=e.getBoundingClientRect();i={id:t.pointerId,x:t.clientX,y:t.clientY,dx:n(e.style.getPropertyValue(`--${Mp}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${Mp}-modal-dy`)),maxX:(window.innerWidth+a.width)/2-56,maxY:(window.innerHeight+a.height)/2-56},e.dataset.dragging=`true`,t.preventDefault()},o=t=>{if(!i||t.pointerId!==i.id)return;let n=r(i.dx+t.clientX-i.x,i.maxX),a=r(i.dy+t.clientY-i.y,i.maxY);e.style.setProperty(`--${Mp}-modal-dx`,`${n}px`),e.style.setProperty(`--${Mp}-modal-dy`,`${a}px`)},s=t=>{i&&t.pointerId===i.id&&(i=null,delete e.dataset.dragging)};return e.addEventListener(`pointerdown`,a),window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s),()=>{e.removeEventListener(`pointerdown`,a),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[e,t])}function Fp({containerRef:e,onDrop:t,disabled:n=!1}){let[r,i]=L(!1);return R(()=>{if(n){i(!1);return}let r=e.current;if(!r)return;let a=0;function o(e){a+=1,e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),i(!0))}function s(){--a,!(a>0)&&(a=0,i(!1))}function c(e){e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()}function l(e){a=0,i(!1),e.dataTransfer&&(e.preventDefault(),t(e.dataTransfer.items))}return r.addEventListener(`dragenter`,o),r.addEventListener(`dragleave`,s),r.addEventListener(`dragover`,c),r.addEventListener(`drop`,l),()=>{r.removeEventListener(`dragenter`,o),r.removeEventListener(`dragleave`,s),r.removeEventListener(`dragover`,c),r.removeEventListener(`drop`,l)}},[e,n,t]),{visible:!n&&r}}const Ip=u.cssPrefix;function Lp(e){let{options:t,onClose:n}=e,r=t.strings,i=z(null);R(()=>{let e=i.current;if(!e)return;let t=Ql(e);function r(e){e.key===`Escape`&&n?.()}return e.addEventListener(`keydown`,r),()=>{t(),e.removeEventListener(`keydown`,r)}},[n]);let a=e.composerApiRef,o=e.composerActive&&e.view===`chat`&&e.canSend&&!e.activeForm?.blocking&&!e.sendPreparing&&e.options.features.fileUpload,{visible:s}=Fp({containerRef:i,onDrop:V(e=>{o&&a.current?.attachFromDrop(e)},[a,o]),disabled:!o});return Pp(i.current,t.mode===`modal`),/* @__PURE__ */ U(`div`,{ref:i,class:`${Ip}-panel`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":r.panelTitle,style:{position:`relative`},"data-testid":Z.panel,children:[/* @__PURE__ */ U(Rp,{...e,containerEl:i.current,dragOver:s}),/* @__PURE__ */ U(Wp,{poweredBy:e.options.poweredBy})]})}function Rp(e){let{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,composerKey:s,panelSize:c,view:l,canSend:u,isStreaming:d,isMemoryCompacting:f,canReleaseQueuedMessages:p,queueManualMessages:m,sendPreparing:h,controlMode:g,assignedOperatorInitials:_,operatorAvailable:v,operatorRequestEnabled:y,onRequestOperator:b,onCancelOperatorRequest:x,loadingMessages:S,onLoadPreviousMessages:C,messagesSig:w,agent:T,suggestions:E,initialWidgetSize:D,onClose:O,onBack:ee,onClear:k,onToggleHistory:te,onSelectHistoryConversation:ne,onNewConversation:A,onWidgetSizeChange:j,onSend:re,onStop:ie,onSuggestion:ae,activeForm:oe,formMarkers:se,onFormSubmit:ce,onFormSkip:le,onFormFill:M,tool:ue,onRetry:de,onMessageFeedback:fe,containerEl:pe,dragOver:me,composerApiRef:he}=e,N=t.strings,ge=yi(()=>w.value.some(e=>!e.ephemeral&&e.role!==`system`)).value,_e;return _e=oe?.blocking?null:u?/* @__PURE__ */ U(I,{children:[g&&g!==`ai-agent`?/* @__PURE__ */ U(Vp,{controlMode:g,operatorInitials:_,operatorAvailable:v,onCancelOperatorRequest:x,strings:N}):null,f&&g===`ai-agent`?/* @__PURE__ */ U(`div`,{class:`${Ip}-loading ${Ip}-compaction-status`,role:`status`,"data-testid":Z.compactionStatus,children:[/* @__PURE__ */ U(`span`,{class:`${Ip}-loading-spinner`,"aria-hidden":`true`}),N.compactingContext]}):null,!d&&!f&&g===`ai-agent`&&/* @__PURE__ */ U(jp,{suggestions:E,onPick:ae,disabled:h}),/* @__PURE__ */ U(od,{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,isStreaming:d,pageToolRunning:e.pageToolRunning,isMemoryCompacting:f,canReleaseQueuedMessages:p,queueManualMessages:m,active:e.composerActive&&l===`chat`,isPreparing:h,operatorRequestEnabled:y,canRequestOperator:ge,controlMode:g,onRequestOperator:b,onSend:re,onStop:ie,apiRef:he},s)]}):/* @__PURE__ */ U(Bp,{label:N.conversationClosed,ctaLabel:N.startNewConversation,onNewConversation:k}),/* @__PURE__ */ U(I,{children:[l===`history`?/* @__PURE__ */ U(zp,{strings:N,onBack:te,onClose:O,showClose:Tc(t.mode,c,t.actions)}):/* @__PURE__ */ U(`header`,{class:`${Ip}-header`,part:`header`,"data-testid":Z.panelHeader,children:[ee?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ip}-icon-btn`,onClick:ee,"aria-label":N.moduleBack,title:N.moduleBack,children:/* @__PURE__ */ U(pl,{})}):null,T?/* @__PURE__ */ U(Dd,{agent:T,strings:N}):/* @__PURE__ */ U(`h1`,{children:N.panelTitle}),/* @__PURE__ */ U(Su,{panelProps:e,variant:`chat`})]}),l===`history`?/* @__PURE__ */ U(Id,{transport:n,strings:N,locale:t.locale,persistence:a,onSelect:ne,onNewConversation:A}):/* @__PURE__ */ U(I,{children:[/* @__PURE__ */ U(Rd,{visible:me,strings:N}),/* @__PURE__ */ U(Tp,{messagesSig:w,strings:N,responseMode:t.responseMode,showReasoning:t.showReasoning,showToolCalls:t.showToolCalls,showSources:t.showSources,enableMessageFeedback:t.enableMessageFeedback,onFeedback:fe,loading:S,onLoadPreviousMessages:C,idle:!d&&!h&&u&&!oe?.blocking,controlMode:g,tool:ue,onRetry:de,form:oe?{form:oe,onSubmit:ce,onSkip:le}:null,formMarkers:se,onFillForm:M}),_e,/* @__PURE__ */ U(Up,{disclaimer:t.composerDisclaimer})]}),t.size.resize?.enabled?/* @__PURE__ */ U(kp,{panelEl:pe,resize:t.size.resize,position:t.position,initialSize:D,onSizeChange:j,strings:N}):null]})}function zp({strings:e,onBack:t,onClose:n,showClose:r}){return/* @__PURE__ */ U(`header`,{class:`${Ip}-header`,part:`header`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ip}-icon-btn`,onClick:t,"aria-label":e.historyBack,title:e.historyBack,children:/* @__PURE__ */ U(pl,{})}),/* @__PURE__ */ U(`h1`,{children:e.historyTitle}),r?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ip}-icon-btn`,onClick:n,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ U(Wc,{})}):null]})}function Bp({label:e,ctaLabel:t,onNewConversation:n}){return/* @__PURE__ */ U(`div`,{class:`${Ip}-readonly-banner`,role:`note`,children:[/* @__PURE__ */ U(`span`,{class:`${Ip}-readonly-label`,children:e}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ip}-readonly-cta`,onClick:n,children:t})]})}function Vp({controlMode:e,operatorInitials:t,operatorAvailable:n,onCancelOperatorRequest:r,strings:i}){let a=Hp(e,t,n,i);return/* @__PURE__ */ U(`div`,{class:`${Ip}-operator-banner`,role:`status`,"data-mode":e,"data-testid":Z.operatorBanner,children:[/* @__PURE__ */ U(`span`,{class:`${Ip}-operator-pulse`,"aria-hidden":`true`}),/* @__PURE__ */ U(`span`,{class:`${Ip}-operator-label`,children:a}),e===`awaiting-operator`&&r?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ip}-cancel-operator-request`,"data-testid":Z.cancelOperatorRequest,onClick:r,children:i.cancelOperatorRequest}):null]})}function Hp(e,t,n,r){return e===`operator`?r.chattingWithOperator.replace(`{operator}`,t??``):n===!1?r.noOperatorAvailable:r.connectingOperator}function Up({disclaimer:e}){return e?/* @__PURE__ */ U(`div`,{class:`${Ip}-composer-footer`,children:/* @__PURE__ */ U(`div`,{class:`${Ip}-disclaimer`,children:e})}):null}function Wp({poweredBy:e}){return e?/* @__PURE__ */ U(`div`,{class:`${Ip}-poweredby-bar`,children:/* @__PURE__ */ U(Gp,{logoUrl:e.logoUrl,text:e.text,href:e.href})}):null}function Gp({logoUrl:e,text:t,href:n}){let r=/* @__PURE__ */ U(I,{children:[e?/* @__PURE__ */ U(`img`,{class:`${Ip}-poweredby-logo`,src:e,alt:``,loading:`lazy`}):null,t?/* @__PURE__ */ U(`span`,{children:t}):null]});return n?/* @__PURE__ */ U(`a`,{class:`${Ip}-poweredby`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:r}):/* @__PURE__ */ U(`span`,{class:`${Ip}-poweredby`,children:r})}const Kp=u.cssPrefix;function qp({panelProps:e,enabledModules:t,nav:n,bus:r,hasUnread:i,latestNews:a,onSelectConversation:o,onStartNewConversation:s,onSetPanelSize:c}){let l=e.options,u=l.strings,d=z(null),f=z(/* @__PURE__ */ new Set);R(()=>{let t=d.current;if(!t)return;let n=Ql(t);function r(t){t.key===`Escape`&&e.onClose?.()}return t.addEventListener(`keydown`,r),()=>{n(),t.removeEventListener(`keydown`,r)}},[e.onClose]);let p=yi(()=>n.sig.value).value,m=Ic(p),h=l.modules.byId[p.activeTab],g=e.composerActive&&h?.layout===`chat`&&m===void 0,_=e.composerApiRef,v=g&&e.view===`chat`&&e.canSend&&!e.activeForm?.blocking&&!e.sendPreparing&&e.options.features.fileUpload,{visible:y}=Fp({containerRef:d,onDrop:V(e=>{v&&_.current?.attachFromDrop(e)},[_,v]),disabled:!v});Pp(d.current,l.mode===`modal`);let b=m?.kind===`iframe`||m?.kind===`content`,x=t.length>1&&(Lc(p)||!b),S=z(null);R(()=>{if(b&&S.current===null)S.current=e.panelSize,e.panelSize===`normal`&&c(`expanded`);else if(!b&&S.current!==null){let e=S.current;S.current=null,c(e)}},[b]);let C={push:e=>n.push(e),pop:()=>n.pop(),switchTab:e=>n.switchTab(e),switchToLayout:e=>{let r=t.find(t=>t.layout===e);r&&n.switchTab(r.id)},selectConversation:o,startNewConversation:s};function w(t){return{options:l,transport:e.transport,strings:u,config:t,nav:C,bus:r,panelProps:e,latestNews:a}}let T=/* @__PURE__ */ U(Su,{panelProps:e,variant:`plain`});h&&f.current.add(h.id);let E=t.filter(e=>f.current.has(e.id));function D(t){if(t.layout===`chat`)return/* @__PURE__ */ U(Rp,{...e,composerActive:g,containerEl:d.current,dragOver:y});let n=xd[t.layout].Root;return n?/* @__PURE__ */ U(n,{...w(t)}):null}function O(){return m?.kind===`iframe`?/* @__PURE__ */ U(Td,{url:m.url,title:m.title,strings:u,onBack:()=>n.pop(),actions:T}):m?.kind===`content`?/* @__PURE__ */ U(pu,{id:m.id,title:m.title,transport:e.transport,strings:u,bus:r,onBack:()=>n.pop(),actions:T}):null}return/* @__PURE__ */ U(`div`,{ref:d,class:`${Kp}-panel ${Kp}-messenger`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":u.panelTitle,style:{position:`relative`},"data-testid":Z.messengerHome,children:[/* @__PURE__ */ U(`div`,{class:`${Kp}-messenger-body`,children:[E.map(e=>/* @__PURE__ */ U(`div`,{class:`${Kp}-messenger-pane`,hidden:b||e.id!==h?.id,children:D(e)},e.id)),O()]}),x?/* @__PURE__ */ U(Cd,{modules:t,activeTab:p.activeTab,strings:u,hasUnread:i,onSelect:e=>n.switchTab(e)}):null,/* @__PURE__ */ U(Wp,{poweredBy:l.poweredBy}),l.size.resize?.enabled&&(h?.layout!==`chat`||m)?/* @__PURE__ */ U(kp,{panelEl:d.current,resize:l.size.resize,position:l.position,initialSize:e.initialWidgetSize,onSizeChange:e.onWidgetSizeChange,strings:u}):null]})}const Jp=u.cssPrefix;function Yp({strings:e,onClose:t}){return/* @__PURE__ */ U(`div`,{class:`${Jp}-panel ${Jp}-modules-empty`,part:`panel`,role:`dialog`,"aria-label":e.panelTitle,"data-testid":Z.modulesEmpty,children:[t?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Jp}-icon-btn ${Jp}-modules-empty-close`,onClick:t,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ U(Wc,{})}):null,/* @__PURE__ */ U(`p`,{class:`${Jp}-modules-empty-text`,children:e.modulesEmpty})]})}function Xp(e){let t=u.cssPrefix,{site:n,blocks:r,strings:i,collapsed:a}=e,o=r?.navigation??[],s=r?.linkCards??[],c=a?i.expandSidebar:i.collapseSidebar;return/* @__PURE__ */ U(`aside`,{class:`${t}-sidebar`,"data-collapsed":a?`true`:`false`,"data-testid":Z.sidebar,children:[/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-header`,children:[/* @__PURE__ */ U(Zp,{site:n}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${t}-sidebar-toggle`,"aria-label":c,"aria-expanded":a?`false`:`true`,title:c,onClick:e.onToggleCollapsed,"data-testid":Z.sidebarToggle,children:/* @__PURE__ */ U(Qp,{collapsed:a})})]}),a?null:/* @__PURE__ */ U(I,{children:[o.length>0?/* @__PURE__ */ U(`nav`,{class:`${t}-sidebar-section`,"data-section":`navigation`,children:/* @__PURE__ */ U($p,{items:o})}):null,s.length>0?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-section`,"data-section":`link-cards`,children:/* @__PURE__ */ U(em,{items:s})}):null,e.showConversations?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-conversations`,children:/* @__PURE__ */ U(Id,{transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,onSelect:e.onSelectConversation,onNewConversation:e.onNewConversation})}):null]})]})}function Zp({site:e}){let t=u.cssPrefix;if(e?.logo?.url){let n=e.logo.alt??e.title??`Logo`;return/* @__PURE__ */ U(`picture`,{children:[e.logoDark?.url?/* @__PURE__ */ U(`source`,{srcset:e.logoDark.url,media:`(prefers-color-scheme: dark)`}):null,/* @__PURE__ */ U(`img`,{class:`${t}-sidebar-logo`,src:e.logo.url,alt:n})]})}return/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-title`,children:e?.title??u.name})}function Qp({collapsed:e}){return/* @__PURE__ */ U(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`,children:e?/* @__PURE__ */ U(`polyline`,{points:`9 6 15 12 9 18`}):/* @__PURE__ */ U(`polyline`,{points:`15 6 9 12 15 18`})})}function $p({items:e}){let t=u.cssPrefix;return/* @__PURE__ */ U(`ul`,{class:`${t}-sidebar-nav`,children:e.map(e=>/* @__PURE__ */ U(`li`,{children:/* @__PURE__ */ U(`a`,{class:`${t}-sidebar-nav-item`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[e.icon?/* @__PURE__ */ U(`span`,{class:`${t}-sidebar-nav-icon`,"data-icon":e.icon}):null,/* @__PURE__ */ U(`span`,{class:`${t}-sidebar-nav-label`,children:e.label})]})},e.id??e.label))})}function em({items:e}){let t=u.cssPrefix;return/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-cards`,children:e.map(e=>/* @__PURE__ */ U(`a`,{class:`${t}-sidebar-card`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-card-label`,children:e.label}),e.description?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-card-desc`,children:e.description}):null]},e.id??e.label))})}const tm=u.cssPrefix;function nm(e){return/* @__PURE__ */ U(`main`,{class:`${tm}-page-shell`,"data-sidebar-collapsed":e.sidebarCollapsed?`true`:`false`,children:[/* @__PURE__ */ U(Xp,{site:e.site,blocks:e.blocks,transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,showConversations:e.showConversations,onSelectConversation:e.onSelectConversation,onNewConversation:e.onNewConversation,collapsed:e.sidebarCollapsed,onToggleCollapsed:e.onToggleSidebarCollapsed}),/* @__PURE__ */ U(`section`,{class:`${tm}-page-chat`,"aria-label":e.strings.panelTitle,children:e.children})]})}const rm=C.scope(`hitl`);function im(e){return e.kind===`tool`&&Te(e.toolMetadata)&&(e.stateSig.value===`input-available`||e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved===!0)}function am(e,t){t.errorSig.value=je(t.toolCallId),t.stateSig.value=`output-error`,e.partsSig.value=[...e.partsSig.value]}function om(e,t){let n=e.slice(0,e.indexOf(t)).findLast(e=>e.role===`user`);return n!==void 0&&M.sentHere(n.id)}function sm(e){let{streaming:t,controlModeSig:n,messagesSig:r,sendAiTurn:i,bus:a,humanInLoop:o,tools:s}=e,c=z(t);c.current=t;let l=z(s);l.current=s;let u=z(/* @__PURE__ */ new Map),[d,f]=L(!1),p=V((e,t,a)=>{if(c.current||n.value!==`ai-agent`)return!1;let o=r.value.at(-1),s=o?.partsSig.value.findIndex(t=>t.kind===`tool`&&t.toolCallId===e)??-1,l=o?.partsSig.value[s];if(!o||l?.kind!==`tool`)return rm.warn(`decideTool: tool part not found`,{toolCallId:e}),!1;if(o.status!==`complete`||!Fs(o,s)||!t(l))return!1;if(a(l),o.partsSig.value=[...o.partsSig.value],!Ns(o)||o.partsSig.value.some(im))return!0;o.status=`streaming`,o.retryAction={kind:`continue-assistant`,messageId:o.serverMessageId??o.id},o.awaitingContinuation=!0,r.value=[...r.value];let u=o.partsSig.value.flatMap(e=>e.kind===`tool`?[e.toolCallId]:[]);return i({continueExisting:!0}).then(e=>e&&M.clear(u)),!0},[n,r,i]),m=V((e,t)=>{let{toolCallId:n,toolName:r}=t;u.current.has(n)||(u.current.set(n,e),f(!0),ke({toolCallId:n,toolName:r,input:t.inputSig.value,optionTools:l.current??[],onSettled:(e,t)=>{rm.info(`toolResult`,{toolCallId:n,status:e}),a.emit(`toolResult`,{toolCallId:n,name:Ee(r),status:e,durationMs:t})}}).then(e=>{u.current.delete(n)&&(f(u.current.size>0),p(n,im,t=>{e.state===`output-available`?t.outputSig.value=e.output:t.errorSig.value=e.errorText,t.stateSig.value=e.state}))}))},[a,p]),h=V(()=>{let e=r.value;for(let[t,n]of u.current){let r=e.findIndex(e=>e.id===n);r<0||r===e.length-1||(u.current.delete(t),Me(t),f(u.current.size>0))}let t=e.at(-1);if(c.current||t?.role!==`assistant`||t.status!==`complete`)return;let n=t.partsSig.value.filter(e=>im(e)&&e.stateSig.value===`input-available`);if(n.length!==0&&om(e,t))for(let e of n)M.get(e.toolCallId)?.state===`stopped`?am(t,e):m(t.id,e)},[r,m]);R(()=>h(),[t,h]),R(()=>r.subscribe(()=>h()),[r,h]);let g=V((e,t,n)=>{let i=!1,o;if(!p(e,e=>e.stateSig.value===`approval-requested`,r=>{Te(r.toolMetadata)&&(o=r),i=_f(r.toolName);let a=r.approvalSig.value?.id??e;r.approvalSig.value={id:a,approved:t,reason:n},r.stateSig.value=`approval-responded`}))return;let s=r.value.at(-1);o&&t&&s&&m(s.id,o),o&&!t&&a.emit(`toolResult`,{toolCallId:e,name:Ee(o.toolName),status:`declined`,durationMs:0}),i?(rm.info(`toolResult`,{toolCallId:e}),a.emit(`toolResult`,{toolCallId:e})):(rm.info(`toolDecision`,{toolCallId:e,approved:t}),a.emit(`toolDecision`,{toolCallId:e,approved:t}))},[a,p,r,m]),_=V(e=>{p(e,e=>e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved!==void 0&&!im(e),t=>{let n=t.approvalSig.value?.id??e;t.approvalSig.value={id:n},t.stateSig.value=`approval-requested`})},[p]);return{toolInteraction:B(()=>({humanInLoop:o,onDecision:g,onEdit:_}),[o,g,_]),pageToolsRunning:d,stopPageTools:V(()=>{let e=r.value.at(-1);for(let t of u.current.keys()){let n=e?.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);e&&n?am(e,n):je(t),rm.info(`toolResult`,{toolCallId:t,status:`stopped`}),a.emit(`toolResult`,{toolCallId:t,name:n?Ee(n.toolName):void 0,status:`stopped`,durationMs:0})}u.current.clear(),f(!1)},[a,r])}}const cm=C.scope(`latest-news`);function lm({transport:e,options:t,persistence:n,enabled:r}){let i=t.modules.list.find(e=>e.layout===`news`)?.contentCollectionIds,a=i?.join(`,`),[o,s]=L(),[c,l]=L(()=>n.loadSeenNewsId());R(()=>{if(!r||!i?.length)return;let t=!1;return e.listContent({contentCollectionIds:i,sortBy:`publishedAt`,sortOrder:`desc`,limit:1}).then(e=>{t||s(e.items[0])}).catch(e=>cm.debug(`listContent (latest news) failed (non-fatal)`,{err:e})),()=>{t=!0}},[e,r,a]);let u=V(e=>{n.saveSeenNewsId(e),l(e)},[n]);return{item:o,unseen:o!==void 0&&o.id!==c,markSeen:u}}function um({callout:e,persistence:t}){let n=e?.text??``,r=e?.persistent??!0,[i,a]=L(()=>!r&&t.loadCalloutDismissed(n));return R(()=>{a(!r&&t.loadCalloutDismissed(n))},[n,r,t]),{dismissed:i,dismissCallout:V(()=>{a(!0),r||t.saveCalloutDismissed(n)},[t,n,r])}}function dm(e){let{transport:t,conversationIdSig:n}=e,r=vi(`ai-agent`),i=vi(void 0),a=vi(void 0),o=z(void 0),s=V(e=>{let t=e.controlRevision,s=o.current;s&&s.conversationId===n.value&&t<s.revision||(o.current={conversationId:n.value,revision:t},r.value=e.controlMode,i.value=e.assignedOperatorInitials,e.controlMode===`awaiting-operator`?e.operatorAvailable!==void 0&&(a.value=e.operatorAvailable):a.value=void 0)},[n,r,i,a]);return{controlModeSig:r,assignedOperatorInitialsSig:i,operatorAvailableSig:a,applyControlState:s,adoptControlStateChunk:V(e=>{if(e.type!==`data-control-state`)return;let t=cs(e.data);t&&s(t)},[s]),requestOperator:V(async()=>{let e=n.value,r=await t.requestOperator();r&&n.value===e&&s(r)},[t,n,s]),cancelOperatorRequest:V(async()=>{let e=n.value,r=await t.cancelOperatorRequest();r&&n.value===e&&s(r)},[t,n,s])}}const fm=u.cssPrefix,pm=`--${fm}-visual-viewport-height`,mm=`--${fm}-visual-viewport-top`;function hm(e){let{hostElement:t,mode:n,panelSize:r,isOpen:i,surfaceReady:a,setIsOpen:o}=e;kr(()=>{ur(t,Rc(n,r,i))},[t,i,r,n]),kr(()=>{if(!i||!a)return;let e=t.ownerDocument.defaultView,n=e?.visualViewport,r=t.shadowRoot?.querySelector(`.${fm}-anchor`);if(!e||!n||!r)return;let o=()=>{r.style.setProperty(pm,`${n.height}px`),r.style.setProperty(mm,`${n.offsetTop}px`)},s=0,c=()=>{e.cancelAnimationFrame(s),s=e.requestAnimationFrame(()=>{s=e.requestAnimationFrame(o)})};return o(),n.addEventListener(`resize`,c),n.addEventListener(`scroll`,c),()=>{e.cancelAnimationFrame(s),n.removeEventListener(`resize`,c),n.removeEventListener(`scroll`,c),r.style.removeProperty(pm),r.style.removeProperty(mm)}},[t,i,a]),R(()=>{if(n!==`modal`||!i)return;function e(e){e.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains(`${fm}-panel`))||o(!1)}return t.addEventListener(`click`,e),()=>t.removeEventListener(`click`,e)},[t,i,n,o]),R(()=>{if(n!==`drawer`||!i)return;function e(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,n,o])}const gm=C.scope(`reducer`);var _m=class{constructor(e,t){this.messagesSig=e,this.onReconcileNeeded=t,s(this,`active`,null),s(this,`openTextParts`,/* @__PURE__ */ new Map),s(this,`partSeq`,0),s(this,`replay`,null)}attach(e){this.active=e,this.openTextParts.clear()}detach(){this.active=null,this.replay=null,this.openTextParts.clear()}beginReplay(e,t){let n=hs();n.id=e.id;let r=ym(e)||Ps(e)&&(e.status!==`streaming`||Ns(e)),i=e.status===`streaming`&&Ns(e)&&Ms(e);this.replay={baseline:e,shadow:n,chunks:[t],probeContinuation:r,continuationTailReplay:i,liveCatchUp:e.status===`streaming`&&!r},this.attach(n),this.apply(t)}refreshReplayBaseline(){let e=this.replay;if(!e)return null;let t=e.shadow.serverMessageId??e.baseline.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e.baseline||r?.id===e.baseline.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e.baseline)??n.find(n=>n.id===e.baseline.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e.baseline)return e;let a=e.baseline;return e.baseline=i,bm(a,i),e.liveCatchUp&&ym(e.shadow)&&(i.status===`streaming`||Ps(i))?(e.probeContinuation=!1,e.continuationTailReplay=!1,e):(e.probeContinuation=ym(i)||Ps(i)&&(i.status!==`streaming`||Ns(i)),e.continuationTailReplay=i.status===`streaming`&&Ns(i)&&Ms(i),e.liveCatchUp=i.status===`streaming`&&!e.probeContinuation,e)}refreshActive(){let e=this.active;if(!e)return null;let t=e.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e||r?.id===e.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e)??n.find(n=>n.id===e.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e)return e;bm(e,i);let a=ym(e)&&Ps(i);return i.status!==`streaming`&&!a?(this.detach(),null):(this.replay={baseline:i,shadow:e,chunks:[],probeContinuation:!1,continuationTailReplay:!1,liveCatchUp:!0},e)}promoteReplay(){let{baseline:e,shadow:t}=this.replay;return Br(()=>{e.role=t.role,e.serverMessageId=t.serverMessageId,e.operatorInitials=t.operatorInitials,e.status=t.status,t.canceled&&(e.canceled=!0),e.finishReason=t.finishReason,e.errorText=t.errorText,e.suggestions=t.suggestions??e.suggestions,e.partsSig.value=t.partsSig.value,this.messagesSig.value=[...this.messagesSig.value]}),this.replay=null,this.active=e,e}promoteContinuation(e=!1){let{baseline:t,chunks:n}=this.replay,r=Is(t);return this.replay=null,Br(()=>{if(e){let e=t.partsSig.value.findLastIndex(e=>e.kind===`tool`);t.partsSig.value=t.partsSig.value.slice(0,e+1)}t.awaitingContinuation=!1,t.status=`streaming`,t.finishReason=void 0,t.errorText=void 0,t.suggestions=void 0,this.attach(t);for(let e of n)this.apply(e);t.continuationStreaming=r||void 0,this.messagesSig.value=[...this.messagesSig.value]}),t}settleOwnedContinuation(e){let{baseline:t}=this.replay,n=Is(t);return this.replay=null,Br(()=>{t.awaitingContinuation=!1,t.status=`streaming`,t.finishReason=void 0,t.errorText=void 0,t.suggestions=void 0,this.attach(t),this.apply(e),t.continuationStreaming=n||void 0,this.messagesSig.value=[...this.messagesSig.value]}),t}applyResume(e){if(e.type===`start`){let t=(this.replay?.baseline??this.active)?.serverMessageId;t!==void 0&&e.messageId!==void 0&&t!==e.messageId&&this.onReconcileNeeded?.({messageId:t}),this.detach();let n=e.messageId,r=n===void 0?void 0:this.messagesSig.value.find(e=>e.serverMessageId===n||e.id===n);if(r!==void 0)return e.messageMetadata?.senderRole===`visitor`&&r.role===`user`&&(r.status===`pending`||r.status===`error`)&&(r.serverMessageId=n,r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,this.messagesSig.value=[...this.messagesSig.value]),this.beginReplay(r,e),null;let i=e.messageMetadata?.senderRole,a=this.messagesSig.value.at(-1);if(i===void 0&&a?.role===`assistant`&&a.status===`streaming`&&a.serverMessageId===void 0&&!Ds(a))return this.attach(a),this.apply(e),null;let o=hs();return this.attach(o),this.messagesSig.value=[...this.messagesSig.value,o],this.apply(e),null}if(this.replay){let t=this.refreshReplayBaseline();if(!t)return null;t.chunks.push(e),e.type===`data-control-state`&&(t.baseline.operatorRoutedTurn=e.data.controlMode!==`ai-agent`),this.apply(e);let{baseline:n,shadow:r,probeContinuation:i,continuationTailReplay:a,liveCatchUp:o}=t,s=e.type===`finish`||e.type===`error`||e.type===`abort`;if(i){if(!wm(n,r,e))return s&&(Om(n,r)&&(n.continuationStreaming=!0,this.messagesSig.value=[...this.messagesSig.value],this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id})),this.detach()),null;let t=ym(n)&&s?this.settleOwnedContinuation(e):this.promoteContinuation();return s?(t.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:t.serverMessageId??t.id}):t.continuationStreaming=!1),this.detach(),t):null}if(a&&Sm(n,r)){let e=this.promoteContinuation(!0);return s?(this.detach(),e):null}if(!o)return s&&this.detach(),null;if(s&&!Ds(n)&&Ds(r)){let e=this.promoteReplay();return this.detach(),e}if(!xm(n,r))return s&&(this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}),this.detach()),null;let c=this.promoteReplay();return s?(this.detach(),c):null}let t=this.refreshActive();if(!t)return null;if(this.replay)return this.applyResume(e);if(this.apply(e),e.type===`finish`||e.type===`error`||e.type===`abort`){let n=t;return n.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}):n.continuationStreaming=!1),this.detach(),n}return null}ensureTextPart(e,t,n){let r=`${t}:${n}`,i=this.openTextParts.get(r);if(i)return i;let a={kind:t,id:`${n}#${this.partSeq++}`,textSig:H(``),doneSig:H(!1)};return this.openTextParts.set(r,a),Am(e,a),a}apply(e){let t=this.active;if(t)switch(e.type){case`start`:{e.messageId&&(t.serverMessageId=e.messageId);let n=e.messageMetadata;n?.senderRole===`operator`?(t.role=`operator`,n.operatorInitials&&(t.operatorInitials=n.operatorInitials)):n?.senderRole===`visitor`&&(t.role=`user`);return}case`finish-step`:this.openTextParts.clear();return;case`start-step`:Am(t,{kind:`step-start`,id:`ss-${this.partSeq++}`});return;case`finish`:gm.debug(`finish`,{reason:e.finishReason,canContinue:e.canContinue}),t.status=`complete`,t.retryAction=void 0,e.finishReason&&(t.finishReason=e.finishReason),this.bumpDone(t);return;case`error`:gm.warn(`stream error chunk`,{errorText:e.errorText}),t.status=`error`,t.errorText=e.errorText,this.bumpDone(t);return;case`abort`:gm.debug(`stream abort chunk (canceled)`),t.status=`complete`,t.canceled=!0,t.retryAction=void 0,this.bumpDone(t);return;case`text-start`:this.ensureTextPart(t,`text`,e.id);return;case`text-delta`:{let n=this.ensureTextPart(t,`text`,e.id);n.textSig.value+=e.delta;return}case`text-end`:this.ensureTextPart(t,`text`,e.id).doneSig.value=!0;return;case`reasoning-start`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!1;return;case`reasoning-delta`:{let n=this.ensureTextPart(t,`reasoning`,e.id);n.textSig.value+=e.delta;return}case`reasoning-end`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!0;return;case`tool-input-start`:case`tool-input-delta`:case`tool-input-available`:case`tool-input-error`:case`tool-output-available`:case`tool-output-error`:case`tool-output-denied`:case`tool-approval-request`:Mm(t,e);return;case`file`:Am(t,{kind:`file`,url:e.url,mediaType:e.mediaType});return;case`source-url`:jm(t,{kind:`source`,sourceId:e.sourceId,url:e.url,title:e.title});return;case`source-document`:jm(t,{kind:`source`,sourceId:e.sourceId,title:e.title,filename:e.filename,mediaType:e.mediaType});return;case`data-suggestions`:t.suggestions=us(e.data);return;case`data-control-state`:t.operatorRoutedTurn=e.data.controlMode!==`ai-agent`;return;case`data-memory-compaction-state`:return}}bumpDone(e){Br(()=>{e.partsSig.value=[...e.partsSig.value],this.messagesSig.value.includes(e)&&(this.messagesSig.value=[...this.messagesSig.value])})}};const vm={"input-streaming":0,"input-available":1,"approval-requested":2,"approval-responded":3,"output-available":4,"output-denied":4,"output-error":4};function ym(e){return e.awaitingContinuation===!0||e.continuationStreaming===!0||e.retryAction?.kind===`continue-assistant`}function bm(e,t){e.canceled&&(t.canceled=!0),ym(e)&&(t.status===`streaming`||Ps(t))&&(t.awaitingContinuation??(t.awaitingContinuation=e.awaitingContinuation),t.continuationStreaming??(t.continuationStreaming=e.continuationStreaming),t.retryAction===void 0&&(t.retryAction=e.retryAction))}function xm(e,t){let n=e.partsSig.value,r=t.partsSig.value;return e.role!==t.role||r.length<n.length?!1:n.every((e,t)=>Cm(e,r[t]))}function Sm(e,t){let n=e.partsSig.value,r=n.findLastIndex(e=>e.kind===`tool`),i=new Set(n.slice(0,r+1).flatMap(e=>e.kind===`tool`?[e.toolCallId]:[])),a=t.partsSig.value.filter(e=>e.kind!==`tool`||!i.has(e.toolCallId)),o=n.slice(r+1);return a.length<o.length?!1:o.every((e,t)=>Cm(e,a[t]))}function Cm(e,t){switch(e.kind){case`text`:case`reasoning`:return t?.kind===e.kind&&t.textSig.value.startsWith(e.textSig.value);case`step-start`:return t?.kind===`step-start`;case`tool`:{if(t?.kind!==`tool`||t.toolCallId!==e.toolCallId||!Ks(t.toolName,e.toolName)||vm[t.stateSig.value]<vm[e.stateSig.value])return!1;let n=e.approvalSig.value?.approved;return n===void 0||t.approvalSig.value?.approved===n}case`file`:return t?.kind===`file`&&t.url===e.url&&t.mediaType===e.mediaType;case`source`:return t?.kind===`source`&&t.sourceId===e.sourceId&&t.url===e.url&&t.title===e.title&&t.filename===e.filename&&t.mediaType===e.mediaType;default:return e}}function wm(e,t,n){return Tm(e,n)||!Em(e,t)?!0:n.type!==`finish`&&n.type!==`error`&&n.type!==`abort`?!1:Ms(t)||e.awaitingContinuation===!0&&n.type!==`finish`?!0:e.awaitingContinuation===!0&&t.partsSig.value.every(e=>e.kind===`step-start`)}function Tm(e,t){if(t.type!==`tool-output-available`&&t.type!==`tool-output-error`&&t.type!==`tool-output-denied`)return!1;let n=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t.toolCallId);return n!==void 0&&vm[n.stateSig.value]<4}function Em(e,t){let n=t.partsSig.value;if(n.length===0)return!0;let r=e.partsSig.value;return r.some((e,t)=>n.every((e,n)=>Dm(r[t+n],e)))}function Dm(e,t){switch(t.kind){case`text`:case`reasoning`:return e?.kind===t.kind&&e.textSig.value.startsWith(t.textSig.value);case`step-start`:return e?.kind===`step-start`;case`tool`:return e?.kind===`tool`&&e.toolCallId===t.toolCallId&&(t.toolName===`tool`||Ks(e.toolName,t.toolName));case`file`:return e?.kind===`file`&&e.url===t.url&&e.mediaType===t.mediaType;case`source`:return e?.kind===`source`&&e.sourceId===t.sourceId&&e.url===t.url&&e.title===t.title&&e.filename===t.filename&&e.mediaType===t.mediaType;default:return t}}function Om(e,t){if(ym(e)||!Ps(e))return!1;let n=new Set(e.partsSig.value.filter(e=>e.kind===`tool`).map(e=>e.toolCallId));return!t.partsSig.value.some(e=>e.kind===`tool`&&n.has(e.toolCallId))}function km(e,t,n,r,i){let a=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);if(a)return r&&(a.dynamic=!0),a.toolMetadata??(a.toolMetadata=i),a;let o={kind:`tool`,toolCallId:t,toolName:n??`tool`,dynamic:r?!0:void 0,toolMetadata:i,inputPartialSig:H(``),inputSig:H(void 0),outputSig:H(void 0),errorSig:H(void 0),stateSig:H(`input-streaming`),approvalSig:H(void 0)};return Am(e,o),o}function Am(e,t){e.partsSig.value=[...e.partsSig.value,t]}function jm(e,t){e.partsSig.value.some(e=>e.kind===`source`&&e.sourceId===t.sourceId)||Am(e,t)}function Mm(e,t){switch(t.type){case`tool-input-start`:km(e,t.toolCallId,t.toolName,t.dynamic,t.toolMetadata);return;case`tool-input-delta`:{let n=km(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case`tool-input-available`:{let n=km(e,t.toolCallId,t.toolName,t.dynamic,t.toolMetadata);n.inputSig.value=t.input,n.stateSig.value=`input-available`;return}case`tool-input-error`:{let n=km(e,t.toolCallId,t.toolName,t.dynamic);n.inputSig.value=t.input,n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-approval-request`:{let n=km(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value=`approval-requested`;return}case`tool-output-available`:{let n=km(e,t.toolCallId,void 0,t.dynamic);n.outputSig.value=t.output,n.stateSig.value=`output-available`;return}case`tool-output-error`:{let n=km(e,t.toolCallId,void 0,t.dynamic);n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-output-denied`:{let n=km(e,t.toolCallId);n.stateSig.value=`output-denied`;return}default:return}}const Nm=1e3;async function Pm(e){let t=Nm,n=!1,r=!1,i=!1;function a(){i||e.signal.aborted||(i=!0,e.onInitialBoundaryReady())}for(;!e.signal.aborted;){let o,s=`held`;try{s=await e.connect(()=>{if(e.signal.aborted)return;o=e.now();let t=n||r;n=!0,r=!1,i?t&&e.backfill():a()})}catch{}if(e.signal.aborted||(!n&&o===void 0&&(r=!0,a()),s===`unavailable`))return;o!==void 0&&e.now()-o>=1e3&&(t=Nm),await e.sleep(t),t=Math.min(t*2,15e3)}}function Fm(e){let{activated:t,conversationReady:n,conversationIdSig:r,messagesSig:i,optionsRef:a,transport:o,visitorId:s,adoptControlStateChunk:c,adoptMemoryCompactionStateChunk:l,settleSuggestions:u,recordConversationReply:d,transcriptRecoverySig:f,beginConversationTranscript:p,commitConversationTranscript:m,onReplyLanded:h,runCancellation:g,canContinueRef:_,setCanSend:v,feedback:y,bus:b,loadInitialThread:x,shouldReconcileOnConnect:S}=e,C=z(0);R(()=>{if(!t||!n||!r.value)return;let e=r.value,w=new AbortController,T=e=>{},E=new _m(i,e=>T(e));o.primeIdentity(s,e);let D=!1,O=!1,ee,k=!1,te,ne=0,A=_.current,j,re,ie=Date.now(),ae,oe=!1,se=!1;function ce(t,n,r){if(!Ds(t))return;let o=i.value.findLast(e=>!e.ephemeral),s=t.serverMessageId??t.id;if(!(o&&(o.serverMessageId??o.id)!==s))return Es(i.value,t,e,a.current.strings.newConversation,n,r)}function le(e,t,n,r){let i=ce(e,t,r);if(!i)return;let a=`${e.serverMessageId??e.id}:${n}:${i.preview??``}`;a!==re&&(re=a,o.publishConversation({...i,hasUnread:!0},!0))}let M;function de(){M&&(clearTimeout(M.timer),M=void 0)}function fe(){let e=M;if(!e)return;clearTimeout(e.timer),M=void 0;let t=i.value.find(t=>(t.serverMessageId??t.id)===e.replyId);(t?.role===`assistant`||t?.role===`operator`)&&le(t,e.canContinue,e.generation,e.activityAt)}function pe(e,t,n,r){de(),M={replyId:e.serverMessageId??e.id,canContinue:t,generation:n,activityAt:r,timer:setTimeout(fe,120)}}function me(e,t,n,r=Date.now(),i=!0){de();let a=ce(e,t,r);if(!a)return;let o=`${e.serverMessageId??e.id}:${n}`;o!==j&&(j=o,d(a),i&&ae&&(oe=!0))}function he(e,t){(e||!g.localSendRef.current)&&g.settle(t),e&&h()}function N(e,t=[],n=!1,r,o=A,s=ne,c=Date.now(),l=!0){let d=a.current;if(e.canceled){me(e,o,s,c,l),he(n,r);return}let f=!0,p=e.status===`error`;switch(Qs(e,p)){case`drop`:i.value=i.value.filter(t=>t!==e),f=!1;break;case`complete-operator-routed`:e.status=`complete`,n&&(y.play(`messageReceived`),Dc(b,d,`assistant`,Ts(e)));break;case`error`:if(e.status=`error`,e.errorText=d.strings.errorGeneric,n){y.play(`error`);let e=/* @__PURE__ */ Error(p?`stream error chunk`:`empty reply`);b.emit(`error`,e),d.onError?.(e)}break;case`complete`:e.status=`complete`,n&&(y.play(`messageReceived`),Dc(b,d,`assistant`,Ts(e))),u(e,t)}f&&me(e,o,s,c,l),he(n,r)}function ge(t){if(w.signal.aborted||r.value!==e)return;if(c(t),l?.(t),t.type===`start`){fe();let n=t.messageId===void 0?void 0:i.value.find(e=>e.serverMessageId===t.messageId||e.id===t.messageId);k=n!==void 0&&n.status!==`streaming`;let r=te?.senderRole===`visitor`?te.messageId:void 0;if(te={messageId:t.messageId,senderRole:t.messageMetadata?.senderRole},ne+=1,ie=Date.now(),re=void 0,D=t.messageMetadata?.senderRole===void 0,O=!1,ee=D?t.messageMetadata?.runId:void 0,D){let n=t.messageId!==void 0&&i.value.some(e=>e.serverMessageId===t.messageId||e.id===t.messageId),a=i.value.at(-1),o=t.messageId!==void 0&&(a?.serverMessageId===t.messageId||a?.id===t.messageId),s=g.localSendRef.current&&(!n||o)&&a?.role===`assistant`&&a.status===`streaming`&&(o||a.serverMessageId===void 0&&a.partsSig.value.length===0);O=g.captureStart(e,t,s,r)}}let n=D&&(t.type===`finish`||t.type===`error`||t.type===`abort`),o=n?ee:void 0,s=n&&(O||g.ownsLocalRun(o)),u=ne,d=k;t.type===`finish`&&t.canContinue!==void 0&&(A=t.canContinue);let f=A;n&&(D=!1,O=!1,ee=void 0);let p=E.applyResume(t),m=te?.messageId,h=m===void 0?void 0:i.value.find(e=>e.serverMessageId===m||e.id===m);k&&te?.senderRole!==`visitor`&&(p!==null||h?.status===`streaming`)&&(k=!1,d=!1);let _=!k&&(h?.role===`assistant`||h?.role===`operator`);t.type===`text-delta`&&_&&pe(h,A,ne,ie),t.type===`text-end`&&(de(),_&&le(h,A,ne,ie)),t.type===`finish`&&t.canContinue===!1&&v(!1),p?p.role===`operator`?(d||(y.play(`messageReceived`),Dc(b,a.current,`operator`,Ts(p))),me(p,f,u,ie),k=!1,n&&(s||!g.localSendRef.current)&&g.settle(o)):p.role===`assistant`&&(N(p,[],s,o,f,u,ie),k=!1):n&&(s||!g.localSendRef.current)&&g.settle(o)}async function _e(t){let n=ne,a=await o.loadConversation(e,t?{ids:[t]}:void 0).catch(()=>null);if(w.signal.aborted||r.value!==e||!a)return!1;a.controlState&&c({type:`data-control-state`,data:a.controlState});let s=i.value.at(-1),l=n===ne&&(t===void 0||s!==void 0&&(s.serverMessageId===t||s.id===t));if(a.messages.length===0)return!0;l&&(A=a.canContinue,v(A));let d=i.value,f=t===void 0?d.at(-1):d.find(e=>e.serverMessageId===t||e.id===t),{messages:p,changed:m}=Us(d,Ss(a.messages));if(!m)return!0;i.value=p;let h=t===void 0?p.at(-1):p.find(e=>e.serverMessageId===t||e.id===t),_=f!==void 0&&h!==void 0&&(f.id===h.id||f.serverMessageId!==void 0&&f.serverMessageId===h.serverMessageId),y=h!==void 0&&h.status!==`streaming`&&(!_||f?.status===`streaming`),b=_&&f?.status===`streaming`?Date.now():h?.createdAt;return l&&y&&h.role===`assistant`?N(h,h.suggestions??[],g.localSendRef.current,void 0,a.canContinue,n,b,!1):l&&y&&h.role===`operator`?me(h,a.canContinue,n,b,!1):l&&h?.role===`assistant`&&h.status!==`streaming`&&u(h,h.suggestions??[]),!0}let ve=/* @__PURE__ */ new Set;T=({messageId:e})=>{if(ve.has(e)||!i.value.some(t=>t.serverMessageId===e||t.id===e))return;ve.add(e);function t(){return ve.delete(e)}_e(e).then(t,t)};function ye(t=!1){if(w.signal.aborted||r.value!==e){oe=!1;return}if(ae){oe=!0;return}let n=t?x(e)??(S()?_e():void 0):_e();if(!n)return;p(e),ae=n;function i(t=!1){ae===n&&(ae=void 0,oe?(oe=!1,ye()):t&&m(e))}n.then(i,()=>i(!1))}let be=f.subscribe(e=>{e<=C.current||(C.current=e,se&&ye())});return Pm({signal:w.signal,now:()=>performance.now(),sleep:e=>ue(e,w.signal),connect:e=>o.connectResumeStream({signal:w.signal,onChunk:ge,onConnected:e}),onInitialBoundaryReady:()=>{se=!0,ye(!0)},backfill:()=>ye()}),()=>{w.abort(),de(),be(),E.detach()}},[t,n,r,r.value,s,o,c,l,u,d,f,p,m,h,g,_,v,i,b,y,x,S])}function Im(e){let{transport:t,setStreaming:n}=e,r=z(void 0),i=z(void 0),a=z(!1),o=z(void 0),s=z(!1),c=z(/* @__PURE__ */ new Map),l=z(/* @__PURE__ */ new Set),u=V((e,n)=>{let r=`${e}:${n}`;o.current!==r&&(o.current=r,t.cancelTurn(e,n))},[t]),d=V(e=>{r.current=void 0,i.current=e,a.current=!1,o.current=void 0,s.current=!0,n(!0)},[n]),f=V((e,t)=>{c.current.set(e,{messageId:t})},[]),p=V(e=>{e!==void 0&&(l.current.add(e),l.current.size>32&&l.current.delete(l.current.values().next().value)),(e===void 0||r.current?.runId===e)&&(r.current=void 0,i.current=void 0,a.current=!1,s.current=!1,n(!1))},[n]),m=V((e,t)=>i.current===e?(i.current=void 0,t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},n(!0),a.current&&u(t.conversationId,t.runId),!0):(p(),!0)):t.runId&&r.current?.runId===t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&u(t.conversationId,t.runId),!0):!1,[u,n,p]),h=V((e,t)=>{let d=c.current.get(e);return d?(c.current.delete(e),!t.runId||l.current.has(t.runId)?!0:d.runId===void 0?(s.current||i.current||(r.current={conversationId:t.conversationId,runId:t.runId},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0)),!0):(d.runId===t.runId&&r.current?.runId===t.runId&&(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&u(t.conversationId,t.runId)),!0)):!1},[u,n]),g=V(e=>i.current===e&&(p(),!0),[p]),_=V(e=>{let t=c.current.get(e);return t?(c.current.delete(e),t.runId===void 0):!1},[]),v=V((e,t,d,f)=>{let p=t.messageMetadata?.runId;if(t.messageMetadata?.senderRole!==void 0||typeof p!=`string`||!p||l.current.has(p))return!1;if(r.current?.runId===p)return s.current;if(s.current)return r.current||!d?!1:(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&u(e,p),!0);let m=[...c.current.values()].filter(e=>e.runId===void 0).find(e=>e.messageId===f);return m?(m.runId=p,r.current={conversationId:e,runId:p},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0),!0):(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&u(e,p),s.current)},[u,n]),y=V(e=>typeof e==`string`&&r.current?.runId===e&&s.current,[]),b=V(()=>{let e=r.current;if(e)return a.current=!0,u(e.conversationId,e.runId),!0;let t=i.current;return t?(a.current=!0,t.then(e=>{e.runId&&u(e.conversationId,e.runId)}).catch(()=>void 0),!0):!1},[u]);return B(()=>({localSendRef:s,begin:d,beginRouted:f,acceptAck:m,acceptRoutedAck:h,reject:g,rejectRouted:_,captureStart:v,ownsLocalRun:y,settle:p,stop:b}),[m,h,d,f,v,y,g,_,p,b])}const Lm=C.scope(`send`);function Rm(e,t,n,r,i,a=!0){e.publishConversation({...Es(t,n,r,i,a),hasUnread:!1},!0)}function zm(e,t){return e.id===t.id||(e.serverMessageId??e.id)===(t.serverMessageId??t.id)}function Bm(e){return e.findLast(e=>!e.ephemeral&&e.role!==`system`&&(e.role===`user`||e.status!==`streaming`||Ds(e)))}function Vm(e,t,n,r,i){let a=Bm(t);a?.role===`user`&&zm(a,n)&&Rm(e,t,a,r,i)}function Hm(e){return!(e instanceof ic)||e.code===`network`||e.status===void 0||e.status===202||e.status===408||e.status===425||e.status===429||e.status>=500&&e.status<600}function Um(e){let{transport:t,messagesSig:n,conversationIdSig:r,options:i,bus:a,feedback:o,persistence:s,visitorId:c,adoptConversationId:l,applyControlState:u,setCanSend:d,settleSuggestions:f,runCancellation:p}=e,m=V(()=>{let e=r.value??Fn();return r.value||(r.value=e,s.saveConversationId(e)),e},[r,s]);return{sendAiTurn:V(async({continueExisting:e,turn:h})=>{let g=m(),_=n.value.at(-1),v=h?[h]:Cs(n.value,e),y=v[0];y?.role===`user`&&M.markSent(y.id);let b=v.map(ws),x=s.loadUserPrefs(),S=Ce(i.tools).then(n=>t.sendTurn(ds({messages:b,conversationId:g,visitorId:c,userPrefs:x,clientTools:we(n)}),{keepalive:e}));p.begin(S);try{let a=await S;if(r.value!==g||!p.acceptAck(S,a))return!1;if(l(a.conversationId),a.runId&&y?.role===`user`&&Vm(t,n.value,y,a.conversationId,i.strings.newConversation),!a.runId){let o=await t.loadConversation(a.conversationId).catch(()=>null);if(r.value!==a.conversationId)return!0;if(o){o.controlState&&u(o.controlState),d(o.canContinue);let r=Ss(o.messages),{messages:s,changed:c}=Us(n.value,r);c&&(n.value=s);let l=r.findLast(e=>!e.ephemeral&&e.role!==`system`),p=Bm(n.value);p&&l&&zm(p,l)&&Rm(t,n.value,p,a.conversationId,i.strings.newConversation,o.canContinue);let m=_?n.value.find(e=>e.id===_.id&&e.role===`assistant`&&e.status!==`streaming`):void 0;m&&f(m,m.suggestions??[]),!e&&_?.role===`assistant`&&n.value.includes(_)&&_.serverMessageId===void 0&&!Ds(_)&&(n.value=n.value.filter(e=>e!==_))}else _?.role===`assistant`&&n.value.includes(_)&&(_.status=`error`,_.errorText=i.strings.errorGeneric,_.retryAction=e?{kind:`continue-assistant`,messageId:_.serverMessageId??_.id}:y?.role===`user`?{kind:`resend-user`,messageId:y.id}:null,n.value=[...n.value])}return!0}catch(s){if(r.value!==g)return!1;if(!p.reject(S))return y?.role===`user`&&Vm(t,n.value,y,g,i.strings.newConversation),!0;let c=wu(s,i.strings),l=Hm(s),m=h?.role===`assistant`?h:n.value.at(-1);if(e&&m?.role===`assistant`&&s instanceof ic&&s.status===409){let e=m.serverMessageId??m.id,i=await t.loadConversation(g,{ids:[e]}).catch(()=>null);if(r.value!==g)return!1;if(i){i.controlState&&u(i.controlState),d(i.canContinue);let t=Ss(i.messages),r=t.find(t=>(t.serverMessageId??t.id)===e);if(r&&Ws(m,r)){let{messages:r,changed:i}=Us(n.value,t),a=r.find(t=>(t.serverMessageId??t.id)===e);if(i&&a&&a!==m)return a.awaitingContinuation=!1,a.continuationStreaming=void 0,a.retryAction=null,n.value=r,a.status!==`streaming`&&f(a,a.suggestions??[]),!0}}if(!n.value.includes(m)||m.status!==`streaming`)return!1;m.continuationStreaming=!0}if(e&&m?.role===`assistant`)m.status=`error`,m.errorText=c,m.retryAction=l?{kind:`continue-assistant`,messageId:m.serverMessageId??m.id}:null,n.value=[...n.value];else if(_?.role===`assistant`&&n.value.includes(_)){_.status=`error`,_.errorText=c;let e=v[0];_.retryAction=l&&e?.role===`user`?{kind:`resend-user`,messageId:e.id}:null,n.value=[...n.value]}else{let e=hs();e.status=`error`,e.errorText=c;let t=v[0];e.retryAction=l&&t?.role===`user`?{kind:`resend-user`,messageId:t.id}:null,n.value=[...n.value,e]}return o.play(`error`),a.emit(`error`,s),i.onError?.(s),!1}},[t,n,i,a,o,s,c,l,u,d,f,m,p]),sendRoutedTurn:V(async e=>{let u=m();e.status=`pending`,e.errorText=void 0,e.retryAction=void 0,n.value.includes(e)&&(n.value=[...n.value]),M.markSent(e.id);let d=[ws(e)],f=s.loadUserPrefs(),h=Ce(i.tools).then(e=>t.sendTurn(ds({messages:d,conversationId:u,visitorId:c,userPrefs:f,clientTools:we(e)})));p.beginRouted(h,e.id);try{let a=await h;return r.value===u?p.acceptRoutedAck(h,a)?(l(a.conversationId),Vm(t,n.value,e,a.conversationId,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0):!1:(p.rejectRouted(h),!1)}catch(s){let c=p.rejectRouted(h);if(r.value!==u)return!1;if(!c)return Vm(t,n.value,e,u,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0;if(e.status!==`pending`)return Vm(t,n.value,e,u,i.strings.newConversation),!0;Lm.debug(`operator-routed send failed`,{error:s});let l=s instanceof Error?s:Error(String(s));return e.status=`error`,e.errorText=wu(s,i.strings),e.retryAction=Hm(s)?{kind:`resend-user`,messageId:e.id}:null,n.value.includes(e)&&(n.value=[...n.value]),o.play(`error`),a.emit(`error`,l),i.onError?.(l),!1}},[t,n,i,a,o,s,c,l,m,p])}}const Wm=C.scope(`unread`);function Gm(e){let{transport:t,options:n,conversationIdSig:r,isConversationVisibleRef:i,activated:a,conversationReady:o}=e,s=vi(!1),c=vi(0),l=vi(0),u=z([]),d=z(void 0),f=z(!1),p=V(()=>{let e=r.value,t=i.current()&&d.current===e?e:void 0,n=u.current.filter(e=>e.hasUnread&&e.conversationId!==t).length;c.value=n,s.value=n>0},[r,s,c,i]),m=V(e=>{let t=r.value,n=u.current.find(e=>e.conversationId===t),i=hc(u.current,e),a=i.find(e=>e.conversationId===t),o=e.type===`snapshot`&&t!==void 0&&a?.hasUnread===!0&&d.current===t&&n!==void 0&&n.lastMessageAt!==a.lastMessageAt;o&&(d.current=void 0),u.current=i,p(),o&&(l.value+=1)},[r,p,l]),h=V(()=>{if(p(),!i.current())return;let e=r.value;if(!e||d.current!==e)return;let n=u.current.find(t=>t.conversationId===e);n?.hasUnread&&t.markRead(e,n.lastMessageAt)},[r,i,p,t]),g=V(e=>{r.value===e&&(d.current=void 0,p())},[r,p]),_=V(e=>{r.value===e&&(d.current=e,h())},[r,h]),v=V(e=>d.current===e,[]),y=V((e=!1)=>{n.history.enabled&&n.modules.list.some(e=>e.layout===`chat`)&&(f.current||(f.current=!0,t.listConversations({limit:50},e).then(t=>{e||m({type:`snapshot`,result:t,requestedRevision:0}),h()}).catch(e=>Wm.debug(`refreshUnread failed (non-fatal)`,{err:e})).finally(()=>{f.current=!1})))},[m,h,n.history.enabled,n.modules,t]),b=V(e=>{let n=e.conversationId,a=i.current()&&r.value===n&&d.current===n,o=u.current.find(e=>e.conversationId===n),s=a&&(o?.lastMessageAt!==e.lastMessageAt||o.hasUnread);t.publishConversation({...e,hasUnread:!a},!0),s&&t.markRead(n,e.lastMessageAt)},[r,i,t]);R(()=>t.subscribeConversationChanges(m),[m,t]);let x=z(!1);return R(()=>{a&&o&&!x.current&&(x.current=!0,y())},[a,o,y]),R(()=>{if(!a)return;function e(){document.visibilityState===`visible`&&(h(),y(!0))}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[a,h,y]),{hasUnreadSig:s,unreadCountSig:c,transcriptRecoverySig:l,markVisibleConversationRead:h,beginConversationTranscript:g,commitConversationTranscript:_,isConversationTranscriptCommitted:v,recordConversationReply:b}}const Km=C.scope(`settings`);function qm(e){let{options:t,persistence:n,transport:r,feedback:i,hostElement:a,bus:o}=e,s=n.loadUserPrefs(),[c,l]=L(()=>s.locale??t.locale),[u,d]=L(s.themeMode),f=u??t.themeMode,[p,m]=L(()=>s.textSize??t.textSize),h=V(e=>{n.patchUserPrefs(e),r.saveUserPrefs(n.loadUserPrefs()).catch(e=>Km.warn(`saveUserPrefs failed`,{err:e}))},[n,r]);R(()=>{s.soundMuted!==void 0&&i.setMuted(s.soundMuted)},[]),R(()=>{if(f!==`host`)a.dataset.theme=f;else return Qn(e=>{a.dataset.theme=e})},[a,f,t]),R(()=>{a.dataset.textSize=p},[a,p,t]),R(()=>{let e=!0;return i.mutedSig.subscribe(t=>{e?e=!1:h({soundMuted:t})})},[i,h]);let g=en(c,t.availableLocales,t.defaultLocale);return R(()=>{r.setLocale(g)},[r,g]),R(()=>{a.dir=kt(g)?`rtl`:`ltr`},[a,g]),R(()=>{g!==c&&l(g)},[g,c]),{activeLocale:c,activeThemeMode:f,activeTextSize:p,effectiveLocale:g,setActiveLocale:l,setActiveThemeMode:d,setActiveTextSize:m,patchAndSync:h,handleLocaleChange:V(e=>{Km.info(`localeChange`,{locale:e}),l(e),h({locale:e}),o.emit(`localeChange`,e)},[h,o]),handleThemeChange:V(e=>{Km.info(`themeChange`,{mode:e}),d(e),a.dataset.theme=e,h({themeMode:e}),o.emit(`themeChange`,e)},[a,h,o]),handleTextSizeChange:V(e=>{Km.info(`textSizeChange`,{size:e}),m(e),a.dataset.textSize=e,h({textSize:e}),o.emit(`textSizeChange`,e)},[a,h,o]),handleSoundToggle:V(()=>{i.toggleMuted();let e=i.mutedSig.value;Km.info(`soundToggle`,{muted:e}),o.emit(`soundToggle`,{muted:e})},[i,o])}}const $=C.scope(`app`),Jm=u.cssPrefix,Ym={home:`home`,chats:`chat`,help:`help`,news:`news`};function Xm(e,t){return gs({...e,text:At(t,e.text)})}function Zm({options:e,hostElement:t,bus:n,recentHostEvents:r}){let i=e.aiAgentDeploymentId;if(!i)throw Error(`aiAgentDeploymentId is required`);let[a]=L(()=>Rn(e.widgetId,e.storage,e.aiAgentDeploymentId)),[o]=L(()=>a.getVisitorId()),s=a.loadUserPrefs(),l=vi(a.loadConversationId()),d=z(l.value!==void 0),f=vi(l.value??``),p=vi([]),[m,h]=L(!1),g=z(void 0),[_,v]=L([]);function y(){let t=e.modules.list,n=new Set(t.map(e=>e.id)),r=a.loadActiveModule();return r&&n.has(r)?r:t[0]?.id??``}function b(){return e.modules.list.find(e=>e.layout===`chat`)?.id}function x(){let t=b();return t?e.modules.list.length===1||C.sig.value.activeTab===t:!1}let S=z(void 0);if(!S.current){let t=e.modules.list.map(e=>e.id),n=a.loadActiveModule()??t[0]??``;S.current=Pc(n,n?[...t,n]:t,e=>a.saveActiveModule(e))}let C=S.current,w=yi(()=>C.sig.value.activeTab).value,T=yi(()=>l.value).value,[E,D]=L(!1),[O,ee]=L(null),[k,te]=L(!1),ne=e.mode===`standalone`||e.mode===`inline`,A=z(Bc(e,Vc(),a.loadPanelOpen(),a.loadPanelSize())),[j,re]=L(A.current.panelOpen),[ie,ae]=L(A.current.panelOpen),oe=z(void 0),se=z(void 0),ce=z(!1),le=z(void 0);R(()=>{j&&ae(!0)},[j]);let M=z(!1),[ue,de]=L(!1),{dismissed:fe,dismissCallout:pe}=um({callout:e.launcher.callout,persistence:a}),me=e.launcher.callout?.persistent??!0,he=V(()=>{$.info(`calloutDismiss`),n.emit(`calloutDismiss`,void 0),pe()},[n,pe]),[N,ge]=L(A.current.panelSize),_e=z(!1),[ve,ye]=L(`chat`),be=z(()=>!1);be.current=()=>j&&ve===`chat`&&!document.hidden&&x();let[xe,Se]=L(!0),Ce=z(xe);Ce.current=xe;let[we,Te]=L(!1),Ee=z(we);Ee.current=we;let De=z(null),[Oe,ke]=L(!1),[Ae,je]=L(null),[Me,P]=L([]),Ne=z(e.strings),Pe=z(e);Pe.current=e;let[Fe,Ie]=L(void 0),[Le,Re]=L(void 0),[ze,Be]=L(()=>a.loadSidebarCollapsed()??!1),[Ve,He]=L({}),[F]=L(()=>new xc({agentApiBaseUrl:e.agentApiBaseUrl,dataApiBaseUrl:e.dataApiBaseUrl,auth:Ci({publicKey:e.publicKey,aiAgentDeploymentId:i,publicKeyHeader:`x-public-key`}),endpoints:e.endpoints,recentHostEvents:r})),[Ue]=L(()=>new Gi(e.sound,e.haptics)),We=Im({transport:F,setStreaming:Te}),{activeLocale:Ge,activeThemeMode:Ke,activeTextSize:qe,effectiveLocale:Je,setActiveLocale:Ye,setActiveThemeMode:Xe,setActiveTextSize:Ze,patchAndSync:I,handleLocaleChange:Qe,handleThemeChange:$e,handleTextSizeChange:et,handleSoundToggle:tt}=qm({options:e,persistence:a,transport:F,feedback:Ue,hostElement:t,bus:n}),{controlModeSig:nt,assignedOperatorInitialsSig:rt,operatorAvailableSig:it,applyControlState:at,adoptControlStateChunk:ot,requestOperator:st,cancelOperatorRequest:ct}=dm({transport:F,conversationIdSig:l}),lt=vi(/* @__PURE__ */ new Map),ut=V(e=>{if(e.type!==`data-memory-compaction-state`)return;let t=l.value;if(!t)return;let n=ls(e.data);if(!n)return;let r=lt.value.get(t);if(r&&(n.postFinishSequence<r.postFinishSequence||n.postFinishSequence===r.postFinishSequence&&(r.status===`ready`||r.status===n.status)))return;let i=new Map(lt.value);i.set(t,n),lt.value=i},[l,lt]),{hasUnreadSig:dt,unreadCountSig:ft,transcriptRecoverySig:pt,markVisibleConversationRead:mt,beginConversationTranscript:ht,commitConversationTranscript:gt,isConversationTranscriptCommitted:_t,recordConversationReply:vt}=Gm({transport:F,options:e,conversationIdSig:l,isConversationVisibleRef:be,activated:ie,conversationReady:E}),yt=j&&e.modules.byId[w]?.layout===`home`,bt=lm({transport:F,options:e,persistence:a,enabled:E&&yt});R(()=>{mt()},[w,j,ve,T,mt]),R(()=>{Ue.update(e.sound,e.haptics)},[Ue,e.sound,e.haptics]),R(()=>()=>Ue.destroy(),[Ue]),R(()=>{!_e.current&&e.size.initialSize&&(_e.current=!0,!a.loadPanelSize()&&ge(zc(e.mode,e.size,Vc())))},[e.mode,e.size,a]),R(()=>{if(!E||M.current)return;M.current=!0;let t=Bc(e,Vc(),a.loadPanelOpen(),a.loadPanelSize());re(t.panelOpen),ge(t.panelSize)},[E,e,a]);let xt=z(null);R(()=>{E&&C.reconcile(e.modules.list.map(e=>e.id),y())},[E,e.modules.list,C]);let St=V(e=>{e&&e.length!==0&&(p.value=e.map(e=>Xm(e,Ne.current)))},[p]),Ct=z(null),wt=V(async e=>{try{let{formSubmissions:t}=await(e?F.bootstrap(e):Ct.current??F.bootstrap()),n=/* @__PURE__ */ new Map;return t.forEach((e,t)=>n.set(e.formId,t)),t.filter((e,t)=>!e.skipped||n.get(e.formId)===t).map((e,t)=>({key:`wire:${e.formId}:${e.createdAt??t}`,formId:e.formId,outcome:e.skipped?`skipped`:`submitted`,createdAt:ns(e.createdAt),values:e.values}))}catch(e){return $.debug(`bootstrap failed — no form markers (non-fatal)`,{err:e}),[]}},[F]),Tt=z(0),Et=z(0),Dt=V(e=>{if(e===l.value)return;let t=l.value;Et.current++,h(!1),t&&(a.saveDraft(e,a.loadDraft(t)),a.saveDraft(t,``),a.saveMessageQueue(e,a.loadMessageQueue(t)),a.saveMessageQueue(t,[])),l.value=e,a.saveConversationId(e),F.primeIdentity(void 0,e),$.info(`conversation rebound`,{previous:t,current:e}),t&&n.emit(`conversationRebound`,{previous:t,current:e})},[n,l,a,F]),Ot=V((e,t)=>{let n=[...e.map(e=>e.createdAt),...t.map(e=>e.createdAt)].filter(e=>e!==void 0),r=(n.length?Math.min(...n):Date.now())-1;return[...(le.current?.messages??[]).map(e=>{let t=Xm(e,Ne.current);return t.createdAt=r,t}),...e]},[]),kt=V(async e=>{let t=Et.current;function r(){return t!==Et.current||l.value!==e}se.current===e&&(se.current=void 0),h(!0);try{let[t,n]=await Promise.all([F.loadConversation(e),wt()]);if(r())return!1;let i=Ss(t.messages);v(n);let a=Ot(Hs(i,p.value),n);if(p.value=a,se.current=a.some(e=>e.role===`user`)?void 0:e,i.length>0||t.controlState!==void 0){Se(t.canContinue),t.controlState&&at(t.controlState);let e=i.findLast(e=>e.role===`assistant`&&!e.ephemeral);P(e?.suggestions??[])}return!0}catch(t){return r()||($.warn(`loadThread failed; keeping conversation active`,{err:t,conversationId:e}),n.emit(`error`,t),Pe.current.onError?.(t)),!1}finally{r()||h(!1)}},[F,wt,p,l,Ot,n]),jt=V(e=>{if(oe.current===e)return oe.current=void 0,kt(e)},[kt]),Mt=V(()=>{if(g.current)return Promise.resolve(void 0);let t=l.value,r=p.value.find(e=>e.serverMessageId!==void 0),i=r?.serverMessageId,a=r?new Date(r.createdAt).toISOString():void 0;if(!t||!i||!a)return Promise.resolve(void 0);let o=Et.current,s={};return g.current=s,(async()=>{try{let e=await F.loadConversation(t,{beforeId:i,beforeCreatedAt:a});if(g.current!==s||Et.current!==o||l.value!==t)return;if(e.messages.length===0)return!1;let n=e.messages.map(ys),r=p.value,c=Ls(r,n);if(c!==r){let e=Math.min(...n.map(e=>e.createdAt??1/0),..._.map(e=>e.createdAt??1/0));if(Number.isFinite(e))for(let t of r){if(!t.ephemeral)break;(t.createdAt??1/0)>=e&&(t.createdAt=e-1)}p.value=c}return!0}catch(r){if(g.current!==s||Et.current!==o||l.value!==t)return;$.warn(`load previous messages failed`,{err:r,conversationId:t,beforeId:i}),n.emit(`error`,r),e.onError?.(r);return}finally{g.current===s&&(g.current=void 0)}})()},[n,l,_,p,e,F]),Nt=V(async({newConversation:t})=>{let r=++Tt.current;function i(){return r!==Tt.current}let s=l.value,c=t||!s?Fn():s;c!==s&&(Et.current++,h(!1),Br(()=>{l.value=c,f.value=c}),a.saveConversationId(c)),F.primeIdentity(o,c);let u;try{u=await F.handshake({visitorId:o,conversationId:c,userPrefs:a.loadUserPrefs(),locale:Ge})}catch(r){if(i())return;n.emit(`error`,r),e.onError?.(r),t||D(!0);return}if(i())return;u.conversationId!==c&&Dt(u.conversationId),je(u.agent),u.site&&qi(u.site)?Ie(u.site):u.site&&$.warn(`invalid site config, using fallback`,{site:u.site}),u.blocks&&Ji(u.blocks)?Re(u.blocks):u.blocks&&$.warn(`invalid blocks config, using fallback`,{blocks:u.blocks});let p=Vn(u.userPrefs);if(Object.keys(p).length>0&&!t&&(a.saveUserPrefs(p),p.locale&&Ye(p.locale),p.soundMuted!==void 0&&Ue.setMuted(p.soundMuted),p.themeMode&&Xe(p.themeMode),p.textSize&&Ze(p.textSize)),le.current=u.welcome,t||n.emit(`handshake`,u),u.welcome?.suggestions){let e=Ne.current;P(u.welcome.suggestions.map(t=>({...t,label:At(e,t.label),...t.text===void 0?{}:{text:At(e,t.text)}})))}let m=!t&&s&&u.conversationId===s;d.current=!!m,m?ce.current||(oe.current=u.conversationId):(se.current=u.conversationId,St(u.welcome?.messages),gt(u.conversationId)),t||D(!0)},[F,o,a,e,n,l,f,Ue,St,Ge,Dt,gt]),Pt=JSON.stringify(e.userContext??null);R(()=>{let t=Object.keys(Ve).length?{...Ve,...e.userContext}:e.userContext;F.setContext(t,Qm(e.pageContext))},[F,Pt,JSON.stringify(e.pageContext??null),JSON.stringify(Ve)]),R(()=>F.setUserToken(e.userToken),[F,e.userToken]);let Ft=V((e,t=[])=>P(e.suggestions??t),[]);R(()=>(F.primeIdentity(o,l.value),Nt({newConversation:!1}),()=>{Tt.current++,Et.current++}),[]),R(()=>{ie&&E&&!ce.current&&(ce.current=!0,Ct.current=F.bootstrap(),(async()=>{try{let e=await Ct.current;ee(ln((e??{forms:[]}).forms,Je))}catch(e){$.debug(`bootstrap failed — treating as no forms`,{err:e})}finally{te(!0)}})(),oe.current===l.value&&h(!0))},[ie,E]);let It=z(null);R(()=>{if(!ie||!E||(It.current??(It.current=Je),It.current===Je))return;It.current=Je;let e=!1;return F.bootstrap().then(t=>{e||ee(ln((t??{forms:[]}).forms,Je))}).catch(e=>$.debug(`forms re-localize failed — keeping current copy`,{err:e})),()=>{e=!0}},[ie,E,Je,F]);let Lt=z(Pt);R(()=>{E&&Lt.current!==Pt&&(Lt.current=Pt,Nt({newConversation:!1}))},[Pt,E,Nt]),hm({hostElement:t,mode:e.mode,panelSize:N,isOpen:j,surfaceReady:E,setIsOpen:re});let{sendAiTurn:Rt,sendRoutedTurn:zt}=Um({transport:F,messagesSig:p,conversationIdSig:l,options:e,bus:n,feedback:Ue,persistence:a,visitorId:o,adoptConversationId:Dt,applyControlState:at,setCanSend:Se,settleSuggestions:Ft,runCancellation:We}),{toolInteraction:Bt,pageToolsRunning:Vt,stopPageTools:Ht}=sm({streaming:we,controlModeSig:nt,messagesSig:p,sendAiTurn:Rt,bus:n,humanInLoop:e.features.humanInLoop,tools:e.tools}),Ut=V((e,t)=>{let r=p.value.find(t=>t.serverMessageId===e);r&&(r.feedback=t),$.info(`messageFeedback`,{messageId:e,value:t}),n.emit(`messageFeedback`,{messageId:e,value:t}),F.submitFeedback({messageId:e,value:t})},[n,p,F]);function Wt(){return p.value.reduce((e,t)=>e+ +(t.role===`user`),0)}let Gt=e.forms.list.length>0?e.forms:O??e.forms,Kt=Oc({forms:Gt,persistence:a,userContext:()=>e.userContext,messageCount:Wt,pageArea:()=>e.pageContext?.area?String(e.pageContext.area):void 0,conversationId:()=>l.value,onComplete:(e,t,r,i)=>{$.info(`formSubmit`,{formId:e.id,trigger:t,skipped:i}),n.emit(`formSubmit`,{formId:e.id,values:r,skipped:i}),v(t=>{let n=t.find(t=>t.formId===e.id&&t.outcome===`skipped`)?.createdAt??Date.now();return[...t.filter(t=>t.formId!==e.id||t.outcome!==`skipped`),{key:`local:${e.id}:${n}`,formId:e.id,outcome:i?`skipped`:`submitted`,createdAt:n,...i?{}:{values:r}}]});let o=l.value??Fn();l.value||(l.value=o,a.saveConversationId(o),F.primeIdentity(void 0,o)),!i&&e.mirrorToContext&&He(e=>({...e,...r})),F.submitForm({formId:e.id,conversationId:o,trigger:t,values:r,skipped:i})}}),qt=yi(()=>Kt.activeForm.value),Jt=qt.value?.form.blocking??!1;Fm({activated:ie,conversationReady:E,conversationIdSig:l,messagesSig:p,optionsRef:Pe,transport:F,visitorId:o,adoptControlStateChunk:ot,adoptMemoryCompactionStateChunk:ut,settleSuggestions:Ft,recordConversationReply:vt,transcriptRecoverySig:pt,beginConversationTranscript:ht,commitConversationTranscript:gt,onReplyLanded:V(()=>Kt.fire(`after-messages`),[Kt]),runCancellation:We,canContinueRef:Ce,setCanSend:Se,feedback:Ue,bus:n,loadInitialThread:jt,shouldReconcileOnConnect:V(()=>d.current||p.value.some(e=>!e.ephemeral&&e.role===`user`),[p])}),R(()=>{Kt.refresh()},[Gt,Kt]);let Yt=e.pageContext?.area?String(e.pageContext.area):void 0,Xt=yi(()=>p.value.length),Zt=z(null);R(()=>{k&&Zt.current&&(Kt.fire(`manual`,Zt.current),Zt.current=null)},[k,Kt]),R(()=>{E&&k&&Kt.fire(`pre-chat`)},[E,k,Kt]),R(()=>{k&&!xe&&Kt.fire(`conversation-closed`)},[k,xe,Kt]),R(()=>{E&&k&&Yt&&Kt.fire(`page-area`)},[E,k,Yt,Kt]);let Qt=B(()=>{let e=Gt.list.flatMap(e=>e.triggers).filter(e=>e.kind===`idle`).map(e=>Number(e.param));return e.length?Math.min(...e)*1e3:0},[Gt]);R(()=>{if(!Qt||!j)return;let e=setTimeout(()=>Kt.fire(`idle`),Qt);return()=>clearTimeout(e)},[Qt,j,Kt,Xt.value]);let $t=V(async(t,r,i)=>{if(De.current)return!1;let a=l.value,o=a?lt.value.get(a):void 0,s=nt.value!==`ai-agent`;if(!s&&o?.status===`compacting`||($.info(`send`,{textLen:t.length,attachments:r.length,streaming:Ee.current,routedToOperator:s}),Ee.current&&!s))return!1;let c=new AbortController,u={conversationId:a,controller:c};De.current=u,ke(!0);try{Ue.unlock();let o=await eh(F,r,c.signal,t=>{c.signal.aborted||($.warn(`upload failed`,{err:t}),n.emit(`error`,t),e.onError?.(t))});if(c.signal.aborted||l.value!==a||!Ce.current||Kt.activeForm.value?.form.blocking)return!1;let s=a?lt.value.get(a):void 0,u=nt.value!==`ai-agent`;if(!u&&s?.status===`compacting`||Ee.current&&!u||!t&&o.length===0)return!1;n.emit(`send`,{text:t,attachmentCount:r.length}),Me.length>0&&P([]),Ue.play(`messageSent`);let d=ms(t,o,i);return Dc(n,e,`user`,t),u?(p.value=[...p.value,d],i?await zt(d):(zt(d),!0)):(p.value=[...p.value,d,hs()],i?await Rt({continueExisting:!1}):(Rt({continueExisting:!1}),!0))}finally{De.current===u&&(De.current=null,ke(!1))}},[F,n,e,Me.length,p,l,lt,Rt,zt,nt]),en=z($t);en.current=$t;let tn=l.value,nn=(tn?lt.value.get(tn):void 0)?.status===`compacting`,rn=nt.value===`ai-agent`,an=yi(()=>{let e=p.value.at(-1);return e?.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`&&e.stateSig.value===`approval-requested`)}),on=yi(()=>p.value.some(e=>e.retryAction?.kind===`resend-user`||e.retryAction?.kind===`continue-assistant`));kr(()=>{let e=l.value;return()=>{let t=De.current;t&&t.conversationId===e&&(De.current=null,ke(!1),t.controller.abort())}},[l.value]),R(()=>{(!xe||Jt)&&De.current?.controller.abort()},[Jt,xe]);let sn=V(()=>{if(Vt){$.info(`stop page tools`),n.emit(`stop`,void 0),Ht();return}if(!We.stop())return;$.info(`stop`),n.emit(`stop`,void 0);let e=p.value.at(-1);e&&e.role!==`user`&&e.status===`streaming`&&(e.canceled=!0,p.value=[...p.value])},[We,n,p,Vt,Ht]),cn=V(e=>{if(we)return;let t=p.value,n=Xs(t,e);if(n)switch($.info(`retry`,{kind:n.kind,messageId:n.messageId}),n.kind){case`continue-assistant`:if(nt.value!==`ai-agent`||e.role!==`assistant`||(e.serverMessageId??e.id)!==n.messageId)return;e.status=`streaming`,e.errorText=void 0,e.retryAction=void 0,e.awaitingContinuation=!0,p.value=[...t],Rt({continueExisting:!0,turn:e});return;case`resend-user`:{let r=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!r)return;let i=e=>{e&&xt.current?.acceptQueuedMessage(n.messageId)};if(r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,nt.value!==`ai-agent`){p.value=e.role===`assistant`?t.filter(t=>t!==e):[...t],zt(r).then(i);return}let a=hs();p.value=e.role===`assistant`?t.map(t=>t===e?a:t):[...t,a],Rt({continueExisting:!1,turn:r}).then(i);return}case`repeat-user`:{let e=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!e)return;let r=ms(Ts(e),e.attachments?.map(e=>({...e}))??[]),i=new Set(r.attachments?.flatMap(e=>e.url?[e.url]:[])??[]),a=e.partsSig.value.flatMap(e=>e.kind===`file`&&!i.has(e.url)?[{...e}]:[]);if(a.length>0&&(r.partsSig.value=[...r.partsSig.value,...a]),nt.value!==`ai-agent`){p.value=[...t,r],zt(r);return}p.value=[...t,r,hs()],Rt({continueExisting:!1,turn:r});return}default:return n}},[we,p,nt,Rt,zt]),un=V(()=>{Ec(e.mode,N)===`exit-fullscreen`?($.info(`close → exit-fullscreen`,{mode:e.mode}),ge(`normal`),n.emit(`fullscreen`,!1)):($.info(`close → panel closed`,{mode:e.mode}),Kt.fire(`panel-close`),re(!1),a.savePanelOpen(!1),n.emit(`close`,void 0),e.onClose?.())},[n,e,a,N,Kt]),dn=V(()=>{$.info(`open`,{mode:e.mode}),Ue.unlock(),de(!0),re(!0),a.savePanelOpen(!0),!fe&&!me&&he(),setTimeout(()=>de(!1),$m),n.emit(`open`,void 0),e.onOpen?.()},[n,e,Ue,a,fe,me,he]),pn=V(()=>{let e=p.value.some(e=>e.role===`user`);if(se.current===l.value&&!e&&xe&&l.value)$.info(`clear → reusing empty conversation`,{conversationId:l.value}),p.value.length===0&&St(le.current?.messages);else return $.info(`clear → new conversation`,{wasStreaming:we}),n.emit(`clear`,void 0),We.settle(),d.current=!1,oe.current=void 0,se.current=void 0,Br(()=>{p.value=[],l.value=void 0,at({controlMode:`ai-agent`,controlRevision:0})}),a.clearConversation(),Se(!0),v([]),P([]),Nt({newConversation:!0})},[we,p,l,a,Nt,n,xe,St,We,at]),mn=V(()=>{let t=pn();ye(`chat`);let n=e.modules.list.find(e=>e.layout===`chat`)?.id;return n&&C.switchTab(n),t},[pn,C,e]),hn=V(async e=>{await mn(),await en.current(e,[])||xt.current?.fill(e)},[mn]),gn=V(()=>{let e=N===`expanded`?`normal`:`expanded`;$.info(`expand`,{from:N,expanded:e===`expanded`}),ge(e),a.savePanelSize(e),n.emit(`expand`,e===`expanded`)},[n,N,a]),_n=V(()=>{let e=N===`fullscreen`?`normal`:`fullscreen`;$.info(`fullscreen`,{from:N,fullscreen:e===`fullscreen`}),ge(e),a.savePanelSize(e),n.emit(`fullscreen`,e===`fullscreen`)},[n,N,a]),vn=V(()=>{ye(e=>{let t=e===`history`?`chat`:`history`;return $.info(`toggleHistory`,{view:t}),n.emit(`toggleHistory`,{view:t}),t})},[n]),yn=V(()=>{Be(e=>{let t=!e;return $.info(`sidebarToggle`,{collapsed:t}),a.saveSidebarCollapsed(t),n.emit(`sidebarToggle`,{collapsed:t}),t})},[a,n]),bn=V(e=>{$.info(`resize`,e),I({widgetSize:e}),n.emit(`resize`,e)},[I,n]),xn=V(async t=>{let r=t.conversationId;if(r===l.value&&_t(r)){$.info(`selectConversation`,{conversationId:r,cached:!0}),n.emit(`selectConversation`,{conversationId:r}),F.publishConversation(t),ye(`chat`);let e=b();e&&C.switchTab(e),gt(r);return}let i=++Tt.current;Et.current++,h(!1);function s(){return i!==Tt.current}$.info(`selectConversation`,{conversationId:r,wasStreaming:we}),n.emit(`selectConversation`,{conversationId:r}),F.publishConversation(t);try{let[e,t]=await Promise.all([F.loadConversation(r),wt(r)]);if(s())return;We.settle(),d.current=!0,oe.current=void 0;let n=Ss(e.messages),i=e.conversationId!==l.value,c=i?n:Hs(n,p.value);se.current=c.some(e=>e.role===`user`)?void 0:e.conversationId,Br(()=>{p.value=Ot(c,t),i&&(f.value=e.conversationId),l.value=e.conversationId}),v(t),a.saveConversationId(e.conversationId),F.primeIdentity(o,e.conversationId),Se(e.canContinue),e.controlState&&at(e.controlState);let u=c.findLast(e=>e.role===`assistant`&&!e.ephemeral);P(u?.suggestions??[]),i?ht(e.conversationId):gt(e.conversationId),ye(`chat`);let m=b();m&&C.switchTab(m)}catch(t){if(s())return;n.emit(`error`,t),e.onError?.(t)}},[F,p,l,f,n,e,a,wt,Ot,we,o,We,ht,gt,_t,C]),Sn=V(e=>{if(typeof e!=`string`)return;j||dn(),ye(`chat`);let t=b();t&&C.switchTab(t),k?Kt.fire(`manual`,e):Zt.current=e},[j,dn,e.modules,C,k,Kt]),Cn=z(void 0),wn=V(t=>{let n=e.modules.list.find(e=>e.layout===Ym[t.to]);if(!n){$.warn(`open: the widget has no such tab`,{to:t.to});return}let r=t.id&&(n.layout===`help`||n.layout===`news`)?{kind:`content`,id:t.id,title:``}:void 0;C.open(n.id,r)},[e.modules,C]),Tn=V(e=>{j||dn(),e!==void 0&&(Ti(e)?E?wn(e):Cn.current=e:$.warn(`open: unknown target`,{detail:e}))},[j,dn,E,wn]);R(()=>{E&&Cn.current&&(wn(Cn.current),Cn.current=void 0)},[E,wn]);let En=E&&!m&&!Jt&&(!rn||!an.value&&!on.value),[Dn,On]=L(),kn=V(e=>{let t=Oi(e);t?(j||dn(),On(t)):$.warn(`ask: expected { text, send? } with non-empty text`,{detail:e})},[j,dn]),An=j&&k&&xe&&E&&!m&&!Jt,jn=An&&En&&!Oe&&!(rn&&(we||nn));R(()=>{if(Dn===void 0||!(Dn.send?jn:An))return;let e=b();e?ve!==`chat`||!x()?(ye(`chat`),C.switchTab(e)):(On(void 0),Dn.send?$t(Dn.text,[]).then(e=>{e||xt.current?.fill(Dn.text)}):xt.current?.fill(Dn.text)):($.warn(`ask: the widget has no chat`),On(void 0))},[Dn,An,jn,ve,w,e.modules,C,$t]),R(()=>{if(e.widgetId!=="default")return;let n=`data-${u.cssPrefix}-`,r=[`ask`,`open`,`close`,`form`].map(e=>n+e);function i(e){let i=e.composedPath().find(e=>e instanceof Element&&r.some(t=>e.hasAttribute(t)));if(!(i instanceof Element))return;e.preventDefault();let a=i.getAttribute(`${n}ask`),o=i.getAttribute(`${n}open`),s=i.getAttribute(`${n}form`);a===null?o===null?s===null?Ai(t,`close`):Ai(t,`openForm`,s):Ai(t,`open`,Ei(o)):Ai(t,`ask`,Di(a||(i.textContent??``),{send:i.hasAttribute(`${n}send`)}))}return document.addEventListener(`click`,i),()=>document.removeEventListener(`click`,i)},[e.widgetId,t]),R(()=>{if(e.widgetId!=="default")return;let n=Ni(location.href);n&&(history.replaceState(history.state,``,n.url),n.ask?Ai(t,`ask`,Di(n.ask)):Ai(t,`open`,n.target))},[e.widgetId,t]);let Mn=z(c),Nn=e.mode===`page`||e.mode===`inline`||e.mode===`standalone`;R(()=>ci(()=>{let e=l.value,t={open:Nn||j,ready:E,unread:ft.value,...e?{conversationId:e}:{}},r=Mn.current;(t.open!==r.open||t.ready!==r.ready||t.unread!==r.unread||t.conversationId!==r.conversationId)&&(Mn.current=t,n.emit(`state`,t),t.unread!==r.unread&&n.emit(`unread`,t.unread))}),[n,Nn,j,E,ft,l]);let Pn=z({handleOpenCommand:Tn,handleClose:un,handleExpand:gn,handleFullscreen:_n,openForm:Sn,handleAskCommand:kn});Pn.current={handleOpenCommand:Tn,handleClose:un,handleExpand:gn,handleFullscreen:_n,openForm:Sn,handleAskCommand:kn},kr(()=>ji(t,{open:e=>Pn.current.handleOpenCommand(e),close:()=>Pn.current.handleClose(),expand:()=>Pn.current.handleExpand(),fullscreen:()=>Pn.current.handleFullscreen(),openForm:e=>Pn.current.openForm(e),ask:e=>Pn.current.handleAskCommand(e)}),[t]);let In=B(()=>fn(e,Ge,Ke,qe),[e,Ge,Ke,qe]);Ne.current=In.strings;let Ln=B(()=>_.map(e=>{let t=Gt.list.find(t=>t.id===e.formId);return{...e,title:t?.title,form:t}}),[_,Gt]);function zn(e){xn(e)}let Bn={options:In,transport:F,feedback:Ue,bus:n,persistence:a,conversationId:l.value??``,composerKey:f.value,composerApiRef:xt,view:ve,canSend:xe,isStreaming:we,pageToolRunning:Vt,isMemoryCompacting:nn,canReleaseQueuedMessages:En,queueManualMessages:rn&&(an.value||on.value),sendPreparing:Oe,composerActive:In.mode===`page`||In.mode===`inline`||In.mode===`standalone`||j,controlMode:nt.value,assignedOperatorInitials:rt.value,operatorAvailable:it.value,operatorRequestEnabled:e.features.operatorRequest,onRequestOperator:st,onCancelOperatorRequest:ct,loadingMessages:m,onLoadPreviousMessages:Mt,messagesSig:p,agent:Ae,suggestions:Me,initialWidgetSize:s.widgetSize??null,onClose:un,onClear:pn,onExpand:gn,onFullscreen:_n,onSoundToggle:tt,onToggleHistory:vn,onSelectHistoryConversation:zn,onNewConversation:mn,onLocaleChange:Qe,onThemeChange:$e,onTextSizeChange:et,onWidgetSizeChange:bn,onSend:$t,onStop:sn,onSuggestion:t=>{if(De.current)return;let r=t.text??t.label;$.info(`suggestion`,{text:r,autoSend:e.autoSendSuggestions}),n.emit(`suggestion`,{text:r}),e.autoSendSuggestions?$t(r,[]):xt.current?.fill(r)},activeForm:qt.value?.form??null,formMarkers:Ln,onFormSubmit:Kt.complete,onFormSkip:Kt.skip,onFormFill:e=>Kt.fire(`manual`,e),tool:Bt,onRetry:cn,onMessageFeedback:Ut};if(!E)return null;let Hn=In.modules.list;function Un(e){let t=wc(`close`,In.mode,e);return Hn.length===0?/* @__PURE__ */ U(Yp,{strings:In.strings,onClose:t?un:void 0}):Hn.length===1&&Hn[0]?.layout===`chat`?/* @__PURE__ */ U(Lp,{...Bn,panelSize:e}):/* @__PURE__ */ U(qp,{panelProps:{...Bn,panelSize:e,onClose:t?un:void 0},enabledModules:Hn,nav:C,bus:n,hasUnread:dt.value,latestNews:bt,onSelectConversation:zn,onStartNewConversation:hn,onSetPanelSize:ge})}if(e.mode===`page`){let t=e.history.enabled&&Hn.some(e=>e.layout===`chat`);return/* @__PURE__ */ U(`div`,{class:`${Jm}-anchor`,children:/* @__PURE__ */ U(nm,{site:Fe,blocks:Le,transport:F,strings:In.strings,locale:In.locale,persistence:a,showConversations:t,onSelectConversation:zn,onNewConversation:mn,sidebarCollapsed:ze,onToggleSidebarCollapsed:yn,children:Un(`fullscreen`)})})}if(ne){let t=e.mode===`standalone`?`fullscreen`:N;return/* @__PURE__ */ U(`div`,{class:`${Jm}-anchor`,children:Un(t)})}let Wn=e.mode===`drawer`,Gn=e.mode!==`modal`&&!e.launcher.hidden&&(!j||ue),Kn=Gn&&!ue&&!fe&&!Wn?In.launcher.callout:null;return/* @__PURE__ */ U(`div`,{class:`${Jm}-anchor`,"data-launcher-size":In.launcher.size,children:[j||ie?/* @__PURE__ */ U(`div`,{class:`${Jm}-surface`,hidden:!j,children:Un(N)}):null,Gn?/* @__PURE__ */ U(Kl,{onToggle:dn,launcher:In.launcher,strings:In.strings,leaving:ue,edgeTab:Wn}):null,Kn?/* @__PURE__ */ U(Xl,{callout:Kn,launcherPosition:In.position,strings:In.strings,closeLabel:In.strings.close,onDismiss:he}):null]})}function Qm(e){let t=e?.url??(typeof location<`u`?location.href:void 0);if(e||t)return{...e,...t?{url:t}:{}}}const $m=120;async function eh(e,t,n,r){return(await Promise.all(t.map(async t=>{try{let{id:r,url:i,originalName:a,mimeType:o,fileSize:s}=await e.uploadFile(t.file,n);return{id:r,name:a,mediaType:o,size:s,url:i}}catch(e){r(e);return}}))).filter(e=>e!==void 0)}const th=C.scope(`error-boundary`);var nh=class extends Qe{constructor(...e){super(...e),s(this,`state`,{crashed:!1})}componentDidCatch(e,t){th.error(`widget render crashed`,{error:e,componentStack:t?.componentStack}),this.setState({crashed:!0}),this.props.onError(e,t?.componentStack)}render(){return this.state.crashed?this.props.fallback:this.props.children}};function rh(e){let{bus:t,host:n,appRoot:r,persistence:i,reportError:a}=e,o=e.initialRaw,s,c=Zt(o),l=!0,u=0,d=Pn(t);function f(){c=Zt(s?mn(o,s):o)}function p(){nr(n,rr(c.mode));let e=i.loadUserPrefs().themeMode;dr(n,e?{...c,themeMode:e}:c),l&&(ur(n,ih(c)),l=!1)}function m(){p(),yt(Xe(nh,{onError:a},Xe(Zm,{key:u,bus:t,hostElement:n,options:c,recentHostEvents:d})),r)}t.on(`handshake`,e=>{e.config&&(e.config.storageVersion&&i.rememberStorageVersion(e.config.storageVersion),s=e.config,f(),m())});let h=qn(t,{getOptions:()=>c,getVisitorId:()=>i.getVisitorId(),getConversationId:()=>i.loadConversationId()});function g(e={}){i.reset(),o={...o,userContext:void 0,userToken:void 0,...e},d.length=0,u+=1,l=!0,f(),m()}return{getOptions:()=>c,getUserOptions:()=>o,render:m,setUserOptions:e=>{o=e,f(),m()},patchUserOptions:e=>{let t=`userToken`in e&&e.userToken!==o.userToken;t&&o.userToken?g(e):(t&&(u+=1),o={...o,...e},f(),m())},reset:()=>g(),destroy:()=>h()}}function ih(e){if(e.mode===`standalone`)return`standalone`;if(e.mode===`inline`)return`inline`;let t=Rn(e.widgetId,e.storage,e.aiAgentDeploymentId),{panelOpen:n,panelSize:r}=Bc(e,Vc(),t.loadPanelOpen(),t.loadPanelSize());return Rc(e.mode,r,n)}const ah=C.scope(`hooks`),oh=`*`,sh=/* @__PURE__ */ new Set;function ch(e,t,n){let r={widgetId:e,event:t,listener:n};return sh.add(r),()=>{sh.delete(r)}}function lh(e,t,n){let r=[...sh];for(let i of r)if(dh(i.widgetId,e.widgetId)&&(i.event===`*`||i.event===t))try{i.listener(e,t,n)}catch(e){ah.warn(`hook listener threw`,{event:t,error:e})}}function uh(e,t){let n=[];for(let r of fh)n.push(t.on(r,t=>{lh(e,r,t)}));return()=>{for(let e of n)e()}}function dh(e,t){return e===`*`||e===t}const fh=/* @__PURE__ */ `open.close.expand.fullscreen.resize.message.send.stop.clear.selectConversation.suggestion.toggleHistory.formSubmit.toolResult.toolDecision.hostEvent.messageFeedback.contentView.contentOpen.contentSearch.contentRead.contentLinkClick.attach.removeAttachment.voiceStart.voiceStop.voiceCancel.localeChange.themeChange.textSizeChange.soundToggle.sidebarToggle.calloutDismiss.error.handshake.conversationRebound.state.unread`.split(`.`),ph=C.scope(`iframe`);function mh(e,t,n=`closed`,r=`floating`,i=null){ph.debug(`createIframeMount`,{position:t,initialMode:n,layoutMode:r,hasTarget:!!i});let a=document.createElement(`iframe`);a.title=`${u.name} chat`,a.setAttribute(`allow`,`microphone; clipboard-write`),_h(a,t,n,r),(r===`inline`&&i?i:document.body).appendChild(a);let o=a.contentDocument;if(!o)throw Error(`iframe contentDocument unavailable (cross-origin?)`);o.open(),o.write(`<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;background:transparent;overflow:hidden}</style></head><body></body></html>`),o.close();let s=ir({...e,target:o.body}),c=new MutationObserver(()=>{_h(a,t,s.hostElement.dataset.mode??`closed`,r)});return c.observe(s.hostElement,{attributes:!0,attributeFilter:[`data-mode`]}),{...s,iframeElement:a,destroy(){c.disconnect(),s.destroy(),a.remove()}}}const hh=`border:0;background:transparent;z-index:2147483647;pointer-events:auto;`,gh={closed:{w:`88px`,h:`88px`},expanded:{w:`min(calc(100vw - 32px), 680px)`,h:`min(calc(100vh - 32px), 860px)`},open:{w:`min(calc(100vw - 32px), 440px)`,h:`min(calc(100vh - 32px), 700px)`}};function _h(e,t,n,r){if(n===`fullscreen`||r===`standalone`){e.style.cssText=`${hh}position:fixed;inset:0;width:100vw;height:100vh;`;return}if(r===`inline`){e.style.cssText=`${hh}position:static;display:block;width:100%;height:100%;`;return}if(typeof matchMedia==`function`&&matchMedia(`(max-width: 640px)`).matches&&(n===`open`||n===`expanded`)){e.style.cssText=`${hh}position:fixed;inset:0;width:100vw;height:100vh;`;return}let i=t.startsWith(`top-`)?`top`:`bottom`,a=t.endsWith(`-left`)?`left`:`right`,{w:o,h:s}=gh[n]??gh.open;e.style.cssText=`${hh}position:fixed;${i}:16px;${a}:16px;width:${o};height:${s};`}const vh=/* @__PURE__ */ new Map;function yh(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);e.debug!==void 0&&b(e.debug);let t=C.scope(`mount`);t.info(`mount`,{widgetId:e.widgetId,publicKey:e.publicKey,mode:e.presentation?.mode});let n=Zt(e),r=n.widgetId,i=vh.get(r);i&&(t.debug(`destroy existing instance at slot`,{widgetId:r}),i.destroy());let a=ih(n),o=n.iframe?mh({position:rr(n.mode)},n.position,a,n.mode,e.target??null):ir({position:rr(n.mode),target:e.target??null});o.hostElement.dataset.widgetId=r;let s=new l,u=Rn(r,n.storage,n.aiAgentDeploymentId);function d(e){s.emit(`error`,e),f.getOptions().onError?.(e)}let f=rh({bus:s,host:o.hostElement,appRoot:o.appRoot,persistence:u,initialRaw:e,reportError:d}),p=c,m=()=>{},h=new Promise(e=>{m=e});s.on(`state`,e=>{p=e,e.ready&&m()}),f.render();let g=o.hostElement,_=null;function v(e){e.debug!==void 0&&b(e.debug),f.patchUserOptions(e)}let y={widgetId:r,open:e=>Ai(g,`open`,e),close:()=>Ai(g,`close`),expand:()=>Ai(g,`expand`),openForm:e=>Ai(g,`openForm`,e),ask:(e,t)=>Ai(g,`ask`,Di(e,t)),on:(e,t)=>s.on(e,t),update:e=>{t.debug(`update`,{patch:e}),v(e)},setUserContext:e=>{t.debug(`setUserContext`,{keys:Object.keys(e)}),v({userContext:{...f.getUserOptions().userContext,...e}})},clearUserContext:()=>{t.debug(`clearUserContext`),v({userContext:void 0})},setPageContext:e=>{t.debug(`setPageContext`,{keys:Object.keys(e)}),v({pageContext:{...f.getUserOptions().pageContext,...e}})},clearPageContext:()=>{t.debug(`clearPageContext`),v({pageContext:void 0})},get state(){return p},ready:h,reset:()=>{t.info(`reset`,{widgetId:r}),f.reset()},login:e=>{t.info(`login`,{widgetId:r}),v({userToken:e})},track:(e,t)=>{let n=Nn(e,t);n&&s.emit(`hostEvent`,n)},registerTool:ve,setDebug:e=>{b(e),t.info(`debug level set`,{level:x()})},debugLevel:()=>x(),onLog:e=>w(e),destroy:()=>{t.info(`destroy`,{widgetId:r}),s.emit(`state`,c),_?.(),f.destroy(),s.clear(),yt(null,o.appRoot),o.destroy(),vh.get(r)===y&&vh.delete(r)}};return _=uh(y,s),vh.set(r,y),y}function bh(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);let t=e.widgetId??`default`,n=vh.get(t);return n?(n.update(e),n):yh(e)}function xh(e){if(e!==void 0){vh.get(e)?.destroy();return}let t=[...vh.values()];for(let e of t)e.destroy()}function Sh(e=`default`){return vh.get(e)??null}function Ch(){return[...vh.values()]}function wh(e,t,n){return ch(e,t,n)}const Th=Hn,Eh=u,Dh=/* @__PURE__ */ new WeakMap;let Oh=0;function kh(e){if(typeof e!=`function`)return e;let t=Dh.get(e)??++Oh;return Dh.set(e,t),`function#${t}`}function Ah(t){let r=n(t);r.current=t;let i=t.widgetId??`default`,a=JSON.stringify({...t,userToken:kh(t.userToken)});return e(()=>()=>xh(i),[i]),e(()=>{bh({...r.current,userToken:r.current.userToken,onMessage:e=>r.current.onMessage?.(e),onOpen:()=>r.current.onOpen?.(),onClose:()=>r.current.onClose?.(),onError:e=>r.current.onError?.(e),tools:r.current.tools?.map(e=>Object.assign({},e,{execute:(t,n)=>(r.current.tools?.find(t=>t.name===e.name)??e).execute(t,n)}))})},[a]),null}function jh(e=`default`){return{state:r(t=>wh(e,`state`,t),()=>Sh(e)?.state??c,()=>c),...t(()=>({ask:(t,n)=>Sh(e)?.ask(t,n),open:t=>Sh(e)?.open(t),close:()=>Sh(e)?.close(),reset:()=>Sh(e)?.reset(),track:(t,n)=>Sh(e)?.track(t,n)}),[e])}}function Mh(t){let r=n(t);r.current=t;let i=JSON.stringify(t);e(()=>{let e=new AbortController;return ve({...r.current,execute:(e,t)=>r.current.execute(e,t)},{signal:e.signal}),()=>e.abort()},[i])}export{oh as HOOK_WILDCARD,Ah as HelpAI,Eh as brand,xh as destroy,Ch as getAllInstances,Sh as getInstance,wh as hook,bh as init,yh as mount,ih as resolveInitialHostMode,jh as useHelpAI,Mh as useHelpAITool,Th as version};
63
63
  //# sourceMappingURL=react.mjs.map