@mono-agent/web 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +132 -14
  2. package/dist/contracts.d.ts +12 -0
  3. package/dist/contracts.d.ts.map +1 -1
  4. package/dist/contracts.js +1 -0
  5. package/dist/contracts.js.map +1 -1
  6. package/dist/index.d.ts +3 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/notification-client.d.ts +19 -0
  11. package/dist/notification-client.d.ts.map +1 -0
  12. package/dist/notification-client.js +136 -0
  13. package/dist/notification-client.js.map +1 -0
  14. package/dist/notification-ingress.d.ts +17 -0
  15. package/dist/notification-ingress.d.ts.map +1 -0
  16. package/dist/notification-ingress.js +170 -0
  17. package/dist/notification-ingress.js.map +1 -0
  18. package/dist/operator-client.d.ts +6 -1
  19. package/dist/operator-client.d.ts.map +1 -1
  20. package/dist/operator-client.js +30 -0
  21. package/dist/operator-client.js.map +1 -1
  22. package/dist/server.d.ts.map +1 -1
  23. package/dist/server.js +40 -2
  24. package/dist/server.js.map +1 -1
  25. package/dist/service.d.ts +17 -1
  26. package/dist/service.d.ts.map +1 -1
  27. package/dist/service.js +78 -5
  28. package/dist/service.js.map +1 -1
  29. package/dist/state-paths.d.ts +1 -0
  30. package/dist/state-paths.d.ts.map +1 -1
  31. package/dist/state-paths.js +12 -0
  32. package/dist/state-paths.js.map +1 -1
  33. package/dist/store.d.ts +20 -1
  34. package/dist/store.d.ts.map +1 -1
  35. package/dist/store.js +186 -10
  36. package/dist/store.js.map +1 -1
  37. package/package.json +4 -4
  38. package/webapp/dist/assets/assistant-ui-DTnHvSvW.js +70 -0
  39. package/webapp/dist/assets/index-BpHUwRCC.css +1 -0
  40. package/webapp/dist/assets/index-DpEe0YWc.js +47 -0
  41. package/webapp/dist/assets/{markdown-qFW9VWmB.js → markdown-DxoHTsvM.js} +1 -1
  42. package/webapp/dist/index.html +4 -4
  43. package/webapp/dist/notification-sw.js +16 -0
  44. package/webapp/dist/sw.js +1 -1
  45. package/webapp/dist/assets/assistant-ui-CU4gqU0g.js +0 -70
  46. package/webapp/dist/assets/index-Ck3BY0Ti.js +0 -47
  47. package/webapp/dist/assets/index-CoB6Xwh-.css +0 -1
@@ -1,70 +0,0 @@
1
- function Tl(t,e){for(var s=0;s<e.length;s++){const n=e[s];if(typeof n!="string"&&!Array.isArray(n)){for(const r in n)if(r!=="default"&&!(r in t)){const o=Object.getOwnPropertyDescriptor(n,r);o&&Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>n[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}function Go(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ls={exports:{}},Ct={};/**
2
- * @license React
3
- * react-jsx-runtime.production.js
4
- *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var mr;function El(){if(mr)return Ct;mr=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function s(n,r,o){var i=null;if(o!==void 0&&(i=""+o),r.key!==void 0&&(i=""+r.key),"key"in r){o={};for(var a in r)a!=="key"&&(o[a]=r[a])}else o=r;return r=o.ref,{$$typeof:t,type:n,key:i,ref:r!==void 0?r:null,props:o}}return Ct.Fragment=e,Ct.jsx=s,Ct.jsxs=s,Ct}var pr;function Il(){return pr||(pr=1,Ls.exports=El()),Ls.exports}var v=Il(),js={exports:{}},z={};/**
10
- * @license React
11
- * react.production.js
12
- *
13
- * Copyright (c) Meta Platforms, Inc. and affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var gr;function Rl(){if(gr)return z;gr=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),i=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),l=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),d=Symbol.iterator;function f(w){return w===null||typeof w!="object"?null:(w=d&&w[d]||w["@@iterator"],typeof w=="function"?w:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,p={};function g(w,A,N){this.props=w,this.context=A,this.refs=p,this.updater=N||h}g.prototype.isReactComponent={},g.prototype.setState=function(w,A){if(typeof w!="object"&&typeof w!="function"&&w!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,w,A,"setState")},g.prototype.forceUpdate=function(w){this.updater.enqueueForceUpdate(this,w,"forceUpdate")};function _(){}_.prototype=g.prototype;function C(w,A,N){this.props=w,this.context=A,this.refs=p,this.updater=N||h}var S=C.prototype=new _;S.constructor=C,m(S,g.prototype),S.isPureReactComponent=!0;var y=Array.isArray,x={H:null,A:null,T:null,S:null,V:null},E=Object.prototype.hasOwnProperty;function I(w,A,N,L,F,J){return N=J.ref,{$$typeof:t,type:w,key:A,ref:N!==void 0?N:null,props:J}}function R(w,A){return I(w.type,A,void 0,void 0,void 0,w.props)}function P(w){return typeof w=="object"&&w!==null&&w.$$typeof===t}function k(w){var A={"=":"=0",":":"=2"};return"$"+w.replace(/[=:]/g,function(N){return A[N]})}var O=/\/+/g;function $(w,A){return typeof w=="object"&&w!==null&&w.key!=null?k(""+w.key):A.toString(36)}function M(){}function B(w){switch(w.status){case"fulfilled":return w.value;case"rejected":throw w.reason;default:switch(typeof w.status=="string"?w.then(M,M):(w.status="pending",w.then(function(A){w.status==="pending"&&(w.status="fulfilled",w.value=A)},function(A){w.status==="pending"&&(w.status="rejected",w.reason=A)})),w.status){case"fulfilled":return w.value;case"rejected":throw w.reason}}throw w}function U(w,A,N,L,F){var J=typeof w;(J==="undefined"||J==="boolean")&&(w=null);var G=!1;if(w===null)G=!0;else switch(J){case"bigint":case"string":case"number":G=!0;break;case"object":switch(w.$$typeof){case t:case e:G=!0;break;case u:return G=w._init,U(G(w._payload),A,N,L,F)}}if(G)return F=F(w),G=L===""?"."+$(w,0):L,y(F)?(N="",G!=null&&(N=G.replace(O,"$&/")+"/"),U(F,A,N,"",function(Cl){return Cl})):F!=null&&(P(F)&&(F=R(F,N+(F.key==null||w&&w.key===F.key?"":(""+F.key).replace(O,"$&/")+"/")+G)),A.push(F)),1;G=0;var $e=L===""?".":L+":";if(y(w))for(var se=0;se<w.length;se++)L=w[se],J=$e+$(L,se),G+=U(L,A,N,J,F);else if(se=f(w),typeof se=="function")for(w=se.call(w),se=0;!(L=w.next()).done;)L=L.value,J=$e+$(L,se++),G+=U(L,A,N,J,F);else if(J==="object"){if(typeof w.then=="function")return U(B(w),A,N,L,F);throw A=String(w),Error("Objects are not valid as a React child (found: "+(A==="[object Object]"?"object with keys {"+Object.keys(w).join(", ")+"}":A)+"). If you meant to render a collection of children, use an array instead.")}return G}function V(w,A,N){if(w==null)return w;var L=[],F=0;return U(w,L,"","",function(J){return A.call(N,J,F++)}),L}function Q(w){if(w._status===-1){var A=w._result;A=A(),A.then(function(N){(w._status===0||w._status===-1)&&(w._status=1,w._result=N)},function(N){(w._status===0||w._status===-1)&&(w._status=2,w._result=N)}),w._status===-1&&(w._status=0,w._result=A)}if(w._status===1)return w._result.default;throw w._result}var j=typeof reportError=="function"?reportError:function(w){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var A=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof w=="object"&&w!==null&&typeof w.message=="string"?String(w.message):String(w),error:w});if(!window.dispatchEvent(A))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",w);return}console.error(w)};function Z(){}return z.Children={map:V,forEach:function(w,A,N){V(w,function(){A.apply(this,arguments)},N)},count:function(w){var A=0;return V(w,function(){A++}),A},toArray:function(w){return V(w,function(A){return A})||[]},only:function(w){if(!P(w))throw Error("React.Children.only expected to receive a single React element child.");return w}},z.Component=g,z.Fragment=s,z.Profiler=r,z.PureComponent=C,z.StrictMode=n,z.Suspense=c,z.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=x,z.__COMPILER_RUNTIME={__proto__:null,c:function(w){return x.H.useMemoCache(w)}},z.cache=function(w){return function(){return w.apply(null,arguments)}},z.cloneElement=function(w,A,N){if(w==null)throw Error("The argument must be a React element, but you passed "+w+".");var L=m({},w.props),F=w.key,J=void 0;if(A!=null)for(G in A.ref!==void 0&&(J=void 0),A.key!==void 0&&(F=""+A.key),A)!E.call(A,G)||G==="key"||G==="__self"||G==="__source"||G==="ref"&&A.ref===void 0||(L[G]=A[G]);var G=arguments.length-2;if(G===1)L.children=N;else if(1<G){for(var $e=Array(G),se=0;se<G;se++)$e[se]=arguments[se+2];L.children=$e}return I(w.type,F,void 0,void 0,J,L)},z.createContext=function(w){return w={$$typeof:i,_currentValue:w,_currentValue2:w,_threadCount:0,Provider:null,Consumer:null},w.Provider=w,w.Consumer={$$typeof:o,_context:w},w},z.createElement=function(w,A,N){var L,F={},J=null;if(A!=null)for(L in A.key!==void 0&&(J=""+A.key),A)E.call(A,L)&&L!=="key"&&L!=="__self"&&L!=="__source"&&(F[L]=A[L]);var G=arguments.length-2;if(G===1)F.children=N;else if(1<G){for(var $e=Array(G),se=0;se<G;se++)$e[se]=arguments[se+2];F.children=$e}if(w&&w.defaultProps)for(L in G=w.defaultProps,G)F[L]===void 0&&(F[L]=G[L]);return I(w,J,void 0,void 0,null,F)},z.createRef=function(){return{current:null}},z.forwardRef=function(w){return{$$typeof:a,render:w}},z.isValidElement=P,z.lazy=function(w){return{$$typeof:u,_payload:{_status:-1,_result:w},_init:Q}},z.memo=function(w,A){return{$$typeof:l,type:w,compare:A===void 0?null:A}},z.startTransition=function(w){var A=x.T,N={};x.T=N;try{var L=w(),F=x.S;F!==null&&F(N,L),typeof L=="object"&&L!==null&&typeof L.then=="function"&&L.then(Z,j)}catch(J){j(J)}finally{x.T=A}},z.unstable_useCacheRefresh=function(){return x.H.useCacheRefresh()},z.use=function(w){return x.H.use(w)},z.useActionState=function(w,A,N){return x.H.useActionState(w,A,N)},z.useCallback=function(w,A){return x.H.useCallback(w,A)},z.useContext=function(w){return x.H.useContext(w)},z.useDebugValue=function(){},z.useDeferredValue=function(w,A){return x.H.useDeferredValue(w,A)},z.useEffect=function(w,A,N){var L=x.H;if(typeof N=="function")throw Error("useEffect CRUD overload is not enabled in this build of React.");return L.useEffect(w,A)},z.useId=function(){return x.H.useId()},z.useImperativeHandle=function(w,A,N){return x.H.useImperativeHandle(w,A,N)},z.useInsertionEffect=function(w,A){return x.H.useInsertionEffect(w,A)},z.useLayoutEffect=function(w,A){return x.H.useLayoutEffect(w,A)},z.useMemo=function(w,A){return x.H.useMemo(w,A)},z.useOptimistic=function(w,A){return x.H.useOptimistic(w,A)},z.useReducer=function(w,A,N){return x.H.useReducer(w,A,N)},z.useRef=function(w){return x.H.useRef(w)},z.useState=function(w){return x.H.useState(w)},z.useSyncExternalStore=function(w,A,N){return x.H.useSyncExternalStore(w,A,N)},z.useTransition=function(){return x.H.useTransition()},z.version="19.1.0",z}var vr;function Ko(){return vr||(vr=1,js.exports=Rl()),js.exports}var b=Ko();const ne=Go(b),Tn=Tl({__proto__:null,default:ne},[b]);var Bs={exports:{}},re={};/**
18
- * @license React
19
- * react-dom.production.js
20
- *
21
- * Copyright (c) Meta Platforms, Inc. and affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */var br;function Al(){if(br)return re;br=1;var t=Ko();function e(c){var l="https://react.dev/errors/"+c;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)l+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+c+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var n={d:{f:s,r:function(){throw Error(e(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},r=Symbol.for("react.portal");function o(c,l,u){var d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:r,key:d==null?null:""+d,children:c,containerInfo:l,implementation:u}}var i=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function a(c,l){if(c==="font")return"";if(typeof l=="string")return l==="use-credentials"?l:""}return re.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=n,re.createPortal=function(c,l){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)throw Error(e(299));return o(c,l,null,u)},re.flushSync=function(c){var l=i.T,u=n.p;try{if(i.T=null,n.p=2,c)return c()}finally{i.T=l,n.p=u,n.d.f()}},re.preconnect=function(c,l){typeof c=="string"&&(l?(l=l.crossOrigin,l=typeof l=="string"?l==="use-credentials"?l:"":void 0):l=null,n.d.C(c,l))},re.prefetchDNS=function(c){typeof c=="string"&&n.d.D(c)},re.preinit=function(c,l){if(typeof c=="string"&&l&&typeof l.as=="string"){var u=l.as,d=a(u,l.crossOrigin),f=typeof l.integrity=="string"?l.integrity:void 0,h=typeof l.fetchPriority=="string"?l.fetchPriority:void 0;u==="style"?n.d.S(c,typeof l.precedence=="string"?l.precedence:void 0,{crossOrigin:d,integrity:f,fetchPriority:h}):u==="script"&&n.d.X(c,{crossOrigin:d,integrity:f,fetchPriority:h,nonce:typeof l.nonce=="string"?l.nonce:void 0})}},re.preinitModule=function(c,l){if(typeof c=="string")if(typeof l=="object"&&l!==null){if(l.as==null||l.as==="script"){var u=a(l.as,l.crossOrigin);n.d.M(c,{crossOrigin:u,integrity:typeof l.integrity=="string"?l.integrity:void 0,nonce:typeof l.nonce=="string"?l.nonce:void 0})}}else l==null&&n.d.M(c)},re.preload=function(c,l){if(typeof c=="string"&&typeof l=="object"&&l!==null&&typeof l.as=="string"){var u=l.as,d=a(u,l.crossOrigin);n.d.L(c,u,{crossOrigin:d,integrity:typeof l.integrity=="string"?l.integrity:void 0,nonce:typeof l.nonce=="string"?l.nonce:void 0,type:typeof l.type=="string"?l.type:void 0,fetchPriority:typeof l.fetchPriority=="string"?l.fetchPriority:void 0,referrerPolicy:typeof l.referrerPolicy=="string"?l.referrerPolicy:void 0,imageSrcSet:typeof l.imageSrcSet=="string"?l.imageSrcSet:void 0,imageSizes:typeof l.imageSizes=="string"?l.imageSizes:void 0,media:typeof l.media=="string"?l.media:void 0})}},re.preloadModule=function(c,l){if(typeof c=="string")if(l){var u=a(l.as,l.crossOrigin);n.d.m(c,{as:typeof l.as=="string"&&l.as!=="script"?l.as:void 0,crossOrigin:u,integrity:typeof l.integrity=="string"?l.integrity:void 0})}else n.d.m(c)},re.requestFormReset=function(c){n.d.r(c)},re.unstable_batchedUpdates=function(c,l){return c(l)},re.useFormState=function(c,l,u){return i.H.useFormState(c,l,u)},re.useFormStatus=function(){return i.H.useHostTransitionStatus()},re.version="19.1.0",re}var yr;function Pl(){if(yr)return Bs.exports;yr=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Bs.exports=Al(),Bs.exports}let lt=null;function Ml(t,e){t.currentIndex=0,t.wipContextDeps=null,t.wipCommitCallbacks=[];const s=lt;lt=t;try{if(e(),t.isFirstRender=!1,t.cells.length!==t.currentIndex)throw new Error(`Rendered ${t.currentIndex} hooks but expected ${t.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{lt=s}}function Fe(){if(!lt)throw new Error("No resource fiber available");return lt}function yt(){return lt}const En=Symbol("tap.Context.defaultValue"),Dl=t=>t;let we=new Map;const Ge=new Set,Yo=()=>new Map(we),_r=(t,e)=>{const s=we;we=t;try{return e()}finally{we=s}},Qo=(t,e)=>{t[En]=e},Jo=t=>typeof t=="object"&&t!==null&&En in t,Xo=t=>typeof t=="object"&&t!==null&&"$$typeof"in t&&t.$$typeof===Symbol.for("react.context"),In=t=>Jo(t)||Xo(t),Zo=t=>{if(!Jo(t)){if(Xo(t)){Qo(t,t._currentValue??t._currentValue2);return}throw new Error("A tap resource's `use()` only accepts a tap context.")}},ei=(t,e,s)=>{if(typeof t!="object"||t===null)throw new Error("useContextProvider only accepts a React context.");Zo(t);const n=t,r=Fe(),o=W(void 0),i=o.current===void 0||!Object.is(o.current.value,e);q(()=>{o.current={value:e}},[e]);const a=we.get(n),c=a!==void 0||we.has(n);we.set(n,{value:e,source:r});try{return Ol(n,i,s)}finally{c?we.set(n,a):we.delete(n)}},Ol=(t,e,s)=>{const n=Ge.has(t);e?Ge.add(t):Ge.delete(t);try{return s()}finally{n?Ge.add(t):Ge.delete(t)}},kl=t=>{Zo(t);const e=t,s=$l(e,t),n=Fe();return(n.wipContextDeps??=new Map).set(e,s.source),s.value},$l=(t,e)=>we.get(t)??{value:Dl(e)[En],source:null},Nl=(t,e,s,n)=>{if(!n)return s;let r=s;for(const[o,i]of n)i===e||i===t||(r??=new Map).set(o,i);return r},ti=(t,e=t.wipContextDeps)=>{const s=yt();!s||!e||(s.wipContextDeps=Nl(s,t,s.wipContextDeps,e))},si=()=>Ge.size>0,Rn=t=>{if(!t.contextDeps||!si())return!1;for(const e of Ge.keys())if(t.contextDeps.has(e))return!0;return!1},Ll=[0,1,2,3];function jl(t){const e=[];for(const s of Ll){const n=t[s];if(n!==void 0)for(let r=0;r<n.length;r++)try{n[r]()}catch(o){e.push(o)}}if(e.length>0){if(e.length===1)throw e[0];for(const s of e)console.error(s);throw new AggregateError(e,"Errors during commit")}}function Bl(t){const e=[];for(const s of t.cells)if(s?.type==="effect"&&(s.deps=null,s.cleanup))try{s.cleanup?.()}catch(n){e.push(n)}finally{s.cleanup=void 0}if(e.length>0){if(e.length===1)throw e[0];for(const s of e)console.error(s);throw new AggregateError(e,"Errors during cleanup")}}const ni=t=>({version:0,committedVersion:0,context:Yo(),dispatchUpdate:t,changelog:[],rollbackCallbacks:[]}),rs=t=>{t.committedVersion=t.version,t.changelog.length=0,t.rollbackCallbacks.length=0},Et=(t,e)=>{const s=t.version>e;if(t.version=e,s){for(let n=0;n<t.rollbackCallbacks.length;n++)t.rollbackCallbacks[n]();if(t.rollbackCallbacks.length=0,e===t.committedVersion)t.changelog.length=0;else{if(t.committedVersion>e)throw new Error("Version is less than committed version");for(;t.committedVersion+t.changelog.length>e;)t.changelog.pop();for(let n=0;n<t.changelog.length;n++)ri(t.changelog[n]);rs(t)}}},ri=t=>{ii(t.fiber,t.cell),t.queued||(t.queued=!0,(t.cell.queue??=[]).push(t))},Pt=(t,e,s)=>{const n=t.wipCommitCallbacks;(n[e]??=[]).push(s)},oi=(t,e)=>{t.rollbackCallbacks.push(e)},ii=(t,e)=>{e.isDirty||(e.isDirty=!0,t.markDirty?.(),oi(t.root,()=>{if(e.queue!==null){for(const s of e.queue)s.queued=!1;e.queue=null}e.workInProgress=e.current,e.isDirty=!1}))},An=()=>{throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.")},Pn=()=>{throw new Error("Hook order changed between renders")},Fl=(t,e,s)=>{if(t.isNeverMounted)throw new Error("Resource updated before mount");let n=!1,r=!0;t.root.dispatchUpdate(()=>(n||(n=!0,s&&t.root.changelog.length===0&&!e.cell.isDirty&&!e.hasEagerState&&(e.eagerState=s(e.cell.workInProgress,e.action),e.hasEagerState=!0,r=!Object.is(e.cell.current,e.eagerState))),r),()=>(n=!0,r=!0,ri(e),t.root.changelog.push(e),!0))},Ul=(t,e,s,n,r)=>{const o=n?n(s):s,i={type:"reducer",workInProgress:o,current:o,isDirty:!1,queue:null,renderQueue:null,reducer:e,dispatch:a=>{const c=yt();if(c!==null){if(c!==t)throw new Error("Cannot update a resource while rendering a different resource.");(t.renderPendingCells??=new Set).add(i),(i.renderQueue??=[]).push(a)}else Fl(t,{fiber:t,cell:i,action:a,hasEagerState:!1,eagerState:void 0,queued:!1},r?e:void 0)}};return i};function ai(t,e,s,n){const r=Fe(),o=r.currentIndex++,i=r.cells[o],a=(()=>{if(i!==void 0)return i.type==="reducer"?i:Pn();!r.isFirstRender&&o>=r.cells.length&&An();const l=Ul(r,t,e,s,n);return r.cells[o]=l,l})(),c=a.queue;if(c!==null){const l=t===a.reducer;for(let u=0;u<c.length;u++){const d=c[u];(!d.hasEagerState||!l)&&(d.eagerState=t(a.workInProgress,d.action),d.hasEagerState=!0),d.queued=!1,a.workInProgress=d.eagerState}a.queue=null}if(a.reducer=t,a.renderQueue!==null){let l=a.workInProgress;for(const u of a.renderQueue)l=t(l,u);a.renderQueue=null,r.renderPendingCells?.delete(a),Object.is(l,a.workInProgress)||(ii(r,a),a.workInProgress=l)}return a.isDirty&&Pt(r,0,()=>{a.current=a.workInProgress,a.isDirty=!1}),[a.workInProgress,a.dispatch]}function ci(t,e,s){return ai(t,e,s,!1)}const Vl=(t,e)=>typeof e=="function"?e(t):e,Hl=t=>t===void 0?void 0:typeof t=="function"?t():t;function Mn(t){return ai(Vl,t,Hl,!0)}const Ss=(t,e)=>{for(let s=0;s<t.length&&s<e.length;s++)if(!Object.is(t[s],e[s]))return!1;return!0},Sr=(t,e)=>{Pt(t,0,()=>{e.current=e.wip,e.currentDeps=e.wipDeps,e.isDirty=!1})},xs=(t,e)=>{const s=Fe(),n=s.currentIndex++;let r=s.cells[n];if(r===void 0){!s.isFirstRender&&n>=s.cells.length&&An();const a=t();return r={type:"memo",current:a,currentDeps:e,wip:a,wipDeps:e,isDirty:!1},s.cells[n]=r,a}r.type!=="memo"&&Pn();const o=r;if(Ss(o.wipDeps,e))return o.isDirty&&Sr(s,o),o.wip;const i=t();return o.wip=i,o.wipDeps=e,o.isDirty||(o.isDirty=!0,oi(s.root,()=>{o.wip=o.current,o.wipDeps=o.currentDeps,o.isDirty=!1})),Sr(s,o),i};function ws(t){return xs(()=>({current:t}),[])}const Dn=(t,e)=>xs(()=>t,e),ql=()=>({type:"effect",cleanup:void 0,deps:null});function ut(t,e){const s=Fe(),n=s.currentIndex++,r=s.cells[n],o=r===void 0?ql():r.type==="effect"?r:Pn();if(r===void 0&&(!s.isFirstRender&&n>=s.cells.length&&An(),s.cells[n]=o),!(e&&o.deps&&Ss(o.deps,e))){if(o.deps!==null&&!!e!=!!o.deps)throw new Error("useEffect called with and without dependencies across re-renders");Pt(s,2,()=>{try{o.cleanup?.()}finally{o.cleanup=void 0}}),Pt(s,3,()=>{try{const i=t();if(i!==void 0&&typeof i!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof i}`);o.cleanup=i}finally{o.deps=e}})}}function On(t){const e=Fe(),s=ws(t);return s.current!==t&&Pt(e,1,()=>{s.current=t}),Dn(((...n)=>s.current(...n)),[])}const os=t=>{if(!In(t))throw new Error("A tap resource's `use()` only accepts a tap context.");return kl(t)},li=(t,e,s=e)=>{const n=ws(!0),r=n.current?s():e();n.current=!1;const[,o]=Mn(0),i=On(()=>{Object.is(r,e())||o(a=>a+1)});return ut(()=>(i(),t(i)),[t]),r},ui=(t,e)=>{},zl=ne;function Wl(t){const e=b.useRef(t);return b.useInsertionEffect(()=>{e.current=t}),b.useCallback(((...s)=>e.current(...s)),[])}const Gl=zl.useEffectEvent??Wl,ge=()=>yt()!==null,ve=ne,ee=t=>ge()?Mn(t):ve.useState(t),Kl=(t,e,s)=>ge()?ci(t,e,s):ve.useReducer(t,e,s),W=t=>ge()?ws(t):ve.useRef(t),te=(t,e)=>ge()?xs(t,e):ve.useMemo(t,e),It=(t,e)=>ge()?Dn(t,e):ve.useCallback(t,e),q=(t,e)=>ge()?ut(t,e):ve.useEffect(t,e),is=(t,e)=>ge()?ut(t,e):ve.useLayoutEffect(t,e),ye=t=>ge()?On(t):Gl(t),_t=(t,e,s)=>ge()?li(t,e,s):ve.useSyncExternalStore(t,e,s),Yl=(t,e)=>ge()?ui():ve.useDebugValue(t,e),fe=t=>{const e=ve.createContext(t);return Qo(e,t),e},di=t=>ge()&&In(t)?os(t):ve.use(t),me=t=>ge()&&In(t)?os(t):ve.useContext(t),fi=ne,hi=Symbol.for("react.memo_cache_sentinel"),mi=t=>new Array(t).fill(hi),Ql=t=>fi.useMemo(()=>{const e=mi(t);return e[hi]=!0,e},[]),T=t=>{const e=yt();if(e===null)return(fi.__COMPILER_RUNTIME?.c??Ql)(t);const s=e.memoCache;let n=s.workInProgress;if(n===null){const i=s.current;n=i===null?[]:i.map(a=>a.slice()),s.workInProgress=n}const r=s.index++;let o=n[r];return o===void 0&&(o=mi(t),n[r]=o),o};function Y(t){return(...e)=>({hook:t,args:e})}function _e(t,e,s){return s?{...e,key:t,deps:s}:{...e,key:t}}const Jl=50;let Te={schedulers:new Set([]),isScheduled:!1};var Xl=class{_task;_isDirty=!1;constructor(t){this._task=t}get isDirty(){return this._isDirty}markDirty(){this._isDirty=!0,Te.schedulers.add(this),Zl()}runTask(){this._isDirty=!1,this._task()}};const Zl=()=>{Te.isScheduled||(Te.isScheduled=!0,eu())},on=()=>{try{const t=[];let e=0;for(const s of Te.schedulers)if(Te.schedulers.delete(s),!!s.isDirty){if(e++,e>Jl)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.");try{s.runTask()}catch(n){t.push(n)}}if(t.length>0){if(t.length===1)throw t[0];for(const s of t)console.error(s);throw new AggregateError(t,"Errors occurred during flushSync")}}finally{Te.schedulers.clear(),Te.isScheduled=!1}},eu=(()=>{if(typeof MessageChannel<"u"){const t=new MessageChannel;return t.port1.onmessage=on,()=>t.port2.postMessage(null)}return()=>setTimeout(on,0)})(),xr=t=>{const e=Te;Te={schedulers:new Set([]),isScheduled:!0};try{const s=t();return on(),s}finally{Te=e}},tu={useState:Mn,useReducer:ci,useRef:ws,useMemo:xs,useCallback:Dn,useEffect:ut,useLayoutEffect:ut,useInsertionEffect:ut,useEffectEvent:On,useContext:os,use:os,useSyncExternalStore:li,useDebugValue:ui},wr=ne,He=wr.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??wr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Bt=He==null?null:"H"in He?{get current(){return He.H},set current(t){He.H=t}}:"ReactCurrentDispatcher"in He?{get current(){return He.ReactCurrentDispatcher.current},set current(t){He.ReactCurrentDispatcher.current=t}}:null;function su(t){if(!Bt)return t();const e=Bt.current;Bt.current=tu;try{return t()}finally{Bt.current=e}}function pi(t,e,s=void 0,n){return{hook:t,root:e,markDirty:s,devStrictMode:n,cells:[],contextDeps:null,wipContextDeps:null,commitCallbacks:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function dt(t){if(!t.isMounted)throw new Error("Tried to unmount a fiber that is already unmounted");t.isMounted=!1,Bl(t)}function Ke(t,e){if(t.memoCache.workInProgress=null,t.renderPendingCells!==null){for(const r of t.renderPendingCells)r.renderQueue=null;t.renderPendingCells.clear()}let s=0,n;do{if(++s>25)throw new Error("Too many re-renders. tap limits the number of renders to prevent an infinite loop.");t.memoCache.index=0,Ml(t,()=>{n=su(()=>t.hook(...e))})}while((t.renderPendingCells?.size??0)>0);return ti(t),n}function Mt(t){const e=t.wipCommitCallbacks??t.commitCallbacks??[];t.wipCommitCallbacks=null,t.commitCallbacks=e,t.isMounted=!0,t.contextDeps=t.wipContextDeps,rs(t.root),t.memoCache.workInProgress!==null&&(t.memoCache.current=t.memoCache.workInProgress,t.memoCache.workInProgress=null),t.isNeverMounted=!1,jl(e)}const nu=()=>{const t=Fe();return t.devStrictMode?t.isFirstRender?"child":"root":null},ru=()=>null,ou=()=>ru,gi=()=>yt()?nu:ou(),iu=t=>t(),au=t=>{const[e]=ee(()=>new Xl(()=>h())),[s]=ee(()=>[]),n=gi(),[r]=ee(()=>{const m=ni((p,g)=>{if(!e.isDirty){if(!p())return;g()}Et(m,m.committedVersion+m.changelog.length),s.push(g),e.markDirty()});return pi(iu,m,void 0,n())}),o=Yo(),i=r.root.version-r.root.committedVersion,a=_r(o,()=>Ke(r,[t])),c=W(!1),l=W([t]),u=W(a),[d]=ee(()=>new Set),f=m=>{e.isDirty||u.current===m||(u.current=m,d.forEach(p=>p()))},h=ye(()=>{Et(r.root,r.root.committedVersion),s.forEach(p=>{p()}),Et(r.root,r.root.committedVersion+r.root.changelog.length);const m=_r(r.root.context,()=>Ke(r,l.current));if(e.isDirty)throw new Error("Scheduler is dirty, this should never happen");rs(r.root),s.length=0,c.current&&Mt(r),f(m)});return q(()=>(c.current=!0,()=>{c.current=!1,dt(r)}),[r]),q(()=>{l.current=[t],rs(r.root),s.splice(0,i),r.root.context=o,Mt(r),f(a)}),te(()=>({getValue:()=>u.current,subscribe:m=>(d.add(m),()=>d.delete(m))}),[d])},cu=()=>{const t=W(0),e=t.current,s=Fe();return{version:e,markDirty:te(()=>()=>{t.current++,s?.markDirty?.()},[s]),root:s.root}},lu=()=>{const[t]=ee(()=>ni((r,o)=>{let i=!1;n(a=>(i=!r(),i?a:a+1)),i||s(o)})),[e,s]=Kl((r,o)=>(Et(t,r),r+(o()?1:0)),0),[,n]=ee(0);return Et(t,e),{root:t,version:e,markDirty:void 0}},kn=()=>{const t=gi(),{root:e,version:s,markDirty:n}=yt()?cu():lu();return{version:s,createFiber:It((r,o,i)=>pi(r,e,i?()=>{i(),n?.()}:n,t()),[])}},vi=(t,e,s)=>{const n=W(null),r=n.current??(n.current={wipDeps:null,wip:null,currentDeps:null,current:null});return r.wipDeps=r.currentDeps,r.wip=r.current,q(()=>{r.currentDeps=r.wipDeps,r.current=r.wip}),!s&&r.currentDeps&&Ss(r.currentDeps,e)?r.current:(r.wipDeps=e,r.wip=t(),r.wip)};function ue(t){const{version:e,createFiber:s}=kn(),n=te(()=>s(t.hook,t.key),[t.hook,t.key,s]),r=vi(()=>({value:Ke(n,t.args)}),[n,e,t.args],Rn(n));return q(()=>()=>dt(n),[n]),q(()=>{Mt(n)},[n,r]),r.value}const Cr=(t,e)=>{const s=t.get(e);s&&(s.isDirty=!0)},uu=(t,e)=>!t.isDirty&&!Rn(t.fiber)&&e!==void 0&&t.committedDeps!==void 0&&Ss(t.committedDeps,e),du=t=>{if(!si())return!1;for(const{fiber:e}of t.values())if(Rn(e))return!0;return!1};function Cs(t){const[e]=ee(()=>new Map),{version:s,createFiber:n}=kn(),r=du(e),o=vi(()=>{const i=new Set,a=[];let c=0;for(let l=0;l<t.length;l++){const u=t[l],d=u.key;if(d===void 0)throw new Error(`useResources did not provide a key for array at index ${l}`);if(i.has(d))throw new Error(`Duplicate key ${d} in useResources`);i.add(d);let f=e.get(d);if(f)if(f.fiber.hook!==u.hook){const h=n(u.hook,u.key,()=>Cr(e,d)),m=Ke(h,u.args);f.next={value:m,deps:u.deps,remount:h}}else if(uu(f,u.deps))f.fiber.contextDeps&&ti(f.fiber,f.fiber.contextDeps),f.next="skip";else{const h=Ke(f.fiber,u.args);f.next={value:h,deps:u.deps}}else{const h=n(u.hook,u.key,()=>Cr(e,d));f={fiber:h,next:{value:Ke(h,u.args),deps:u.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},c++,e.set(d,f)}a.push(typeof f.next=="object"?f.next.value:f.committedValue)}if(e.size>a.length-c)for(const l of e.keys())i.has(l)||(e.get(l).next="delete");return a},[t,e,n,s],r);return q(()=>()=>{for(const i of e.keys()){const a=e.get(i).fiber;dt(a)}},[e]),q(()=>{for(const[i,a]of e.entries()){const c=a.next;c==="delete"?(a.fiber.isMounted&&dt(a.fiber),e.delete(i)):c==="skip"||(c.remount&&(dt(a.fiber),a.fiber=c.remount),Mt(a.fiber),a.committedDeps=c.deps,a.committedValue=c.value,a.isDirty=!1)}},[o,e]),o}const fu=t=>t(),hu=t=>{const{createFiber:e}=kn(),s=te(()=>e(fu,void 0),[e]),n=Ke(s,[t]);q(()=>()=>{dt(s)},[s]);let r=!1;const o=()=>{r&&s.isMounted||(r=!0,Mt(s))};return q(o),{value:n,effects:o}},mu=()=>{const t=T(4),[e,s]=ee(gu);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=(c,l)=>(s(u=>({...u,renderers:{...u.renderers,[c]:[...u.renderers[c]??[],l]}})),()=>{s(u=>({...u,renderers:{...u.renderers,[c]:u.renderers[c]?.filter(d=>d!==l)??[]}}))}),t[0]=n):n=t[0];const r=n;let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o=c=>(s(l=>({...l,fallbacks:[...l.fallbacks,c]})),()=>{s(l=>({...l,fallbacks:l.fallbacks.filter(u=>u!==c)}))}),t[1]=o):o=t[1];const i=o;let a;return t[2]!==e?(a={getState:()=>e,setDataUI:r,setFallbackDataUI:i},t[2]=e,t[3]=a):a=t[3],a},pu=Y(mu);function gu(){return{renderers:{},fallbacks:[]}}const vu=t=>{const e=Array.from(t).map(n=>n.getModelContext()).sort((n,r)=>(r.priority??0)-(n.priority??0)),s={};return e.reduce((n,r)=>{const o=r.priority??0;if(r.system&&(n.system?n.system+=`
26
-
27
- ${r.system}`:n.system=r.system),r.tools)for(const[i,a]of Object.entries(r.tools)){const c=n.tools?.[i];if(c&&c!==a){const l=s[i];if(l===o)throw new Error(`You tried to define a tool with the name ${i}, but it already exists.`);const u=l>o?c:a,d=l>o?a:c;n.tools[i]={...d,...u},s[i]=Math.max(l,o);continue}n.tools||(n.tools={}),n.tools[i]=a,s[i]??=o}return r.config&&(n.config={...n.config,...r.config}),r.callSettings&&(n.callSettings={...n.callSettings,...r.callSettings}),r.unstable_composerMetadata&&(n.unstable_composerMetadata={...n.unstable_composerMetadata,...r.unstable_composerMetadata}),n},{})};var $n=class{_providers=new Set;getModelContext(){return vu(this._providers)}registerModelContextProvider(t){this._providers.add(t);const e=t.subscribe?.(()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(t),e?.(),this.notifySubscribers()}}_subscribers=new Set;notifySubscribers(){for(const t of this._subscribers)t()}subscribe(t){return this._subscribers.add(t),()=>{this._subscribers.delete(t)}}};const an=[],bu={modelName:void 0,toolNames:an},yu=(t,e)=>t===e||t.length===e.length&&t.every((s,n)=>s===e[n]),Ft=(t,e)=>{const s=t.getModelContext(),n=s.config?.modelName,r=s.tools?Object.keys(s.tools).sort():an,o=r.length?r:an;return n===e.modelName&&yu(o,e.toolNames)?e:{modelName:n,toolNames:o}},_u=()=>{const t=T(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=new $n,t[0]=e):e=t[0];const s=e;let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=()=>Ft(s,bu),t[1]=n):n=t[1];const[r,o]=ee(n);let i,a;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=()=>(o(h=>Ft(s,h)),s.subscribe(()=>{o(h=>Ft(s,h))})),a=[s],t[2]=i,t[3]=a):(i=t[2],a=t[3]),q(i,a);let c;t[4]!==r?(c=()=>Ft(s,r),t[4]=r,t[5]=c):c=t[5];let l,u,d;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=()=>s.getModelContext(),u=h=>s.subscribe(h),d=h=>s.registerModelContextProvider(h),t[6]=l,t[7]=u,t[8]=d):(l=t[6],u=t[7],d=t[8]);let f;return t[9]!==c?(f={getState:c,getModelContext:l,subscribe:u,register:d},t[9]=c,t[10]=f):f=t[10],f},bi=Y(_u),Su=t=>t.display!==void 0?t.display==="standalone":t.type==="human",xu=(t,e)=>{if(!(e.status?.type==="running"||e.status?.type==="requires-action")){const n=t.complete;return typeof n!="function"?n??null:n({args:e.args,result:e.result})}const s=t.running;return typeof s!="function"?s??null:s({args:e.args})},wu=t=>function(s){return xu(t,s)},cn=Symbol("assistant-ui.store.clientIndex"),Cu=t=>t[cn],yi=fe([]),Nn=()=>di(yi),Tu=(t,e)=>{const s=T(3),n=Nn();let r;return s[0]!==t||s[1]!==n?(r=[...n,t],s[0]=t,s[1]=n,s[2]=r):r=s[2],ei(yi,r,e)},Eu=new Set(["$$typeof","nodeType","then"]),Ts=(t,e)=>{if(t===Symbol.toStringTag)return e;if(typeof t!="symbol"){if(t==="toJSON")return()=>e;if(!Eu.has(t))return!1}};var Ln=class{getOwnPropertyDescriptor(t,e){const s=this.get(t,e);if(s!==void 0)return{value:s,writable:!1,enumerable:!0,configurable:!1}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}};const as=Symbol("assistant-ui.store.getValue"),Iu=t=>{const e=t[as];if(!e)throw new Error("Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.");return e.getState?.()},Tr=new Map;function Ru(t){let e=Tr.get(t);return e||(e=function(...s){if(!this||typeof this!="object")throw new Error(`Method "${String(t)}" called without proper context. This may indicate the function was called incorrectly.`);const n=this[as];if(!n)throw new Error(`Method "${String(t)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);const r=n[t];if(!r)throw new Error(`Method "${String(t)}" is not implemented.`);if(typeof r!="function")throw new Error(`"${String(t)}" is not a function.`);return r(...s)},Tr.set(t,e)),e}var Au=class extends Ln{outputRef;index;boundFns;cachedReceiver;constructor(t,e){super(),this.outputRef=t,this.index=e}get(t,e,s){if(e===as)return this.outputRef.current;if(e===cn)return this.index;const n=Ts(e,"ClientProxy");if(n!==!1)return n;const r=this.outputRef.current[e];if(typeof r=="function"){this.cachedReceiver!==s&&(this.boundFns=new Map,this.cachedReceiver=s);let o=this.boundFns.get(e);return o||(o=Ru(e).bind(s),this.boundFns.set(e,o)),o}return r}ownKeys(){return Object.keys(this.outputRef.current)}has(t,e){return e===as||e===cn?!0:e in this.outputRef.current}};const Lt=t=>{const e=W(null),s=Nn().length,n=te(()=>new Proxy({},new Au(e,s)),[s]),r=Tu(n,function(){return ue(t)});return e.current||(e.current=r),q(()=>{e.current=r}),{methods:n,state:r.getState?.(),key:t.key}},Pu=Y(Lt),Rt=Symbol("assistant-ui.store.proxiedAssistantState"),Fs=t=>t==="on"||t==="subscribe"||typeof t=="symbol",_i=t=>{class e extends Ln{get(n,r){const o=Ts(r,"AssistantState");if(o!==!1)return o;const i=r;if(!Fs(i))return Iu(t[i]())}ownKeys(){return Object.keys(t).filter(n=>!Fs(n))}has(n,r){return!Fs(r)&&r in t}}return new Proxy({},new e)},Mu=t=>t[Rt],Er=()=>()=>{},Si=t=>{const e=(()=>{throw new Error(t)});return e.source=null,e.query=null,e};var Du=class extends Ln{get(t,e){if(e==="subscribe"||e==="on")return Er;if(e===Rt)return Ou;const s=Ts(e,"DefaultAssistantClient");return s!==!1?s:Si("You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.")}ownKeys(){return["subscribe","on",Rt]}has(t,e){return e==="subscribe"||e==="on"||e===Rt}};const Es=new Proxy({},new Du),Ou=_i(Es),ku=()=>new Proxy({},{get(t,e){const s=Ts(e,"AssistantClient");return s!==!1?s:Si(`The current scope does not have a "${String(e)}" property.`)}}),xi=fe(Es),wi=Symbol("assistant-ui.store.useEffects"),$u=()=>{},Nu=t=>t[wi]??$u,Lu=()=>{"use no memo";return q(Nu(Ci())),null},Ci=()=>me(xi),pe=({value:t,children:e})=>{"use no memo";return v.jsxs(xi.Provider,{value:t,children:[v.jsx(Lu,{}),e]})},ln=t=>null,he=Y(ln),un=Symbol("assistant-ui.transform-scopes");function Ti(t,e){const s=t;if(s[un])throw new Error("transformScopes is already attached to this resource");s[un]=e}function ju(t){return t[un]}const Ei=t=>typeof t=="string"?{scope:t.split(".")[0],event:t}:{scope:t.scope,event:t.event},Ii=fe(null),Bu=(t,e)=>ei(Ii,t,e),Ri=()=>{const t=di(Ii);if(!t)throw new Error("AssistantTapContext is not available");return t},Ai=()=>Ri().clientRef,jn=()=>{const t=T(3),{emit:e}=Ri(),s=Nn();let n;return t[0]!==s||t[1]!==e?(n=(r,o)=>{e(r,o,s)},t[0]=s,t[1]=e,t[2]=n):n=t[2],ye(n)};function Fu(t,e){const s={...t},n=new Set;let r=!0;for(;r;){r=!1;for(const a of Object.values(s)){if(a.hook===ln||n.has(a.hook))continue;n.add(a.hook);const c=ju(a.hook);if(c){c(s,e),r=!0;break}}}const o={},i={};for(const[a,c]of Object.entries(s))c.hook===ln?i[a]=c:o[a]=c;return{rootClients:o,derivedClients:i}}const Ir=t=>te(()=>t,[...Object.entries(t).flat()]),Uu=(t,e)=>{const s=T(6);let n;s[0]!==e||s[1]!==t?(n=Fu(t,e),s[0]=e,s[1]=t,s[2]=n):n=s[2];const{rootClients:r,derivedClients:o}=n,i=Ir(r),a=Ir(o);let c;return s[3]!==i||s[4]!==a?(c={rootClients:i,derivedClients:a},s[3]=i,s[4]=a,s[5]=c):c=s[5],c},Vu=()=>{const t=T(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=new Map,t[0]=e):e=t[0];const s=e;let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=new Set,t[1]=n):n=t[1];const r=n;let o;if(t[2]===Symbol.for("react.memo_cache_sentinel")){const i=new Set;o={on(a,c){const l=c;if(a==="*")return r.add(l),()=>r.delete(l);let u=s.get(a);return u||(u=new Set,s.set(a,u)),u.add(l),()=>{u.delete(l),u.size===0&&s.delete(a)}},emit(a,c,l){const u=s.get(a);!u&&r.size===0||queueMicrotask(()=>{const d=[];if(u)for(const f of u)try{f(c,l)}catch(h){const m=h;d.push(m)}if(r.size>0){const f={event:a,payload:c};for(const h of r)try{h(f,l)}catch(m){const p=m;d.push(p)}}if(d.length>0){if(d.length===1)throw d[0];for(const f of d)console.error(f);throw new AggregateError(d,"Errors occurred during event emission")}})},subscribe(a){return i.add(a),()=>i.delete(a)},notifySubscribers(){for(const a of i)try{a()}catch(c){console.error("NotificationManager: subscriber callback error",c)}}},t[2]=o}else o=t[2];return o},Hu=Y(Vu),Pi=t=>te(()=>t,t),qu=({element:t,emit:e,clientRef:s})=>{const{methods:n,state:r}=Bu({clientRef:s,emit:e},function(){return Lt(t)});return te(()=>({state:r,methods:n}),[n,r])},zu=({element:t,notifications:e,clientRef:s,name:n})=>{const r=au(function(){return qu({element:t,emit:e.emit,clientRef:s})});return q(()=>r.subscribe(e.notifySubscribers),[r,e]),te(()=>{const o=()=>r.getValue().methods;return Object.defineProperties(o,{source:{value:"root",writable:!1},query:{value:{},writable:!1},name:{value:n,configurable:!0}}),o},[r,n])},Wu=Y(zu),Gu=()=>{const t=T(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s={clients:e,subscribe:void 0,on:void 0},t[1]=s):s=t[1],s},Ku=Y(Gu),Yu=t=>{const e=T(14),{clients:s,clientRef:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=Hu(),e[0]=r):r=e[0];const o=ue(r);let i;e[1]!==n.parent||e[2]!==o.notifySubscribers?(i=()=>n.parent.subscribe(o.notifySubscribers),e[1]=n.parent,e[2]=o.notifySubscribers,e[3]=i):i=e[3];let a;e[4]!==n||e[5]!==o?(a=[n,o],e[4]=n,e[5]=o,e[6]=a):a=e[6],q(i,a);let c;e[7]!==n||e[8]!==s||e[9]!==o?(c=Object.keys(s).map(d=>_e(d,Wu({element:s[d],notifications:o,clientRef:n,name:d}))),e[7]=n,e[8]=s,e[9]=o,e[10]=c):c=e[10];const l=Pi(Cs(c));let u;return e[11]!==o||e[12]!==l?(u={notifications:o,results:l},e[11]=o,e[12]=l,e[13]=u):u=e[13],u},Qu=t=>{const{clientRef:e}=t,{notifications:s,results:n}=Yu(t);return te(()=>({clients:n,subscribe:s.subscribe,on:function(r,o){if(!this)throw new Error("const { on } = useAui() is not supported. Use aui.on() instead.");const{scope:i,event:a}=Ei(r);if(i!=="*"&&this[i].source===null)throw new Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);const c=s.on(a,(u,d)=>{if(i==="*"){o(u);return}const f=this[i]();f===d[Cu(f)]&&o(u)});if(i!=="*"&&e.parent[i].source===null)return c;const l=e.parent.on(r,o);return()=>{c(),l()}}}),[n,s,e])},Ju=Y(Qu);function dn(t){return t.args?t.args[0]:t.props}const Xu=({element:t,clientRef:e,name:s})=>{const n=W(dn(t));return n.current=dn(t),te(()=>{const r=()=>n.current.get(e.current);return Object.defineProperties(r,{source:{value:n.current.source},query:{value:n.current.query},name:{value:s,configurable:!0}}),r},[e,s])},Zu=Y(Xu),ed=(t,e)=>{let s;try{const n={};for(const r of Object.keys(e.query).sort())n[r]=e.query[r];s=JSON.stringify(n)}catch{s=String(e.query)}return`${t}::${e.source}::${s}`},td=t=>{const e=T(3),{clients:s,clientRef:n}=t;let r;return e[0]!==n||e[1]!==s?(r=Object.keys(s).map(o=>{const i=o,a=s[i];return _e(ed(i,dn(a)),Zu({element:a,clientRef:n,name:i}))}),e[0]=n,e[1]=s,e[2]=r):r=e[2],Pi(Cs(r))},sd=t=>{const e=T(3),{rootClients:s,clientRef:n}=t;let r;return e[0]!==n||e[1]!==s?(r=Object.keys(s).length>0?Ju({clients:s,clientRef:n}):Ku(),e[0]=n,e[1]=s,e[2]=r):r=e[2],ue(r)},nd=({parent:t,clients:e})=>{const{rootClients:s,derivedClients:n}=Uu(e,t),r=W({parent:t,current:null}).current;q(()=>{r.current=a});const o=sd({rootClients:s,clientRef:r}),i=td({clients:n,clientRef:r}),a=te(()=>{const c=t===Es?ku():t,l=Object.create(c);Object.assign(l,{subscribe:o.subscribe??t.subscribe,on:o.on??t.on,[Rt]:_i(l)});for(const u of o.clients)l[u.name]=u;for(const u of i)l[u.name]=u;return l},[t,o,i]);return r.current===null&&(r.current=a),a},rd=t=>{const{value:e,effects:s}=hu(function(){return nd(t)});return e[wi]=s,e};function H(t,{parent:e}={parent:Ci()}){if(t)return rd({parent:e??Es,clients:t});if(e===null)throw new Error("received null parent, this usage is not allowed");return e}const D=t=>{const e=T(6),s=H();let n;e[0]!==s?(n=Mu(s),e[0]=s,e[1]=n):n=e[1];const r=n;let o,i;e[2]!==r||e[3]!==t?(o=()=>t(r),i=()=>t(r),e[2]=r,e[3]=t,e[4]=o,e[5]=i):(o=e[4],i=e[5]);const a=_t(s.subscribe,o,i);if(a===r)throw new Error("You tried to return the entire AssistantState. This is not supported due to technical limitations.");return Yl(a),a},od=t=>{const e=H(),s=W(!1),n=s.current?null:t(e);return D(()=>s.current?t(e):n),()=>(s.current=!0,t(e))},id=Object.freeze({});function et(t){const e=T(3),{getItemState:s,children:n}=t,r=od(s);let o;return e[0]!==n||e[1]!==r?(o=n(r),e[0]=n,e[1]=r,e[2]=o):o=e[2],ad(o)}const ad=t=>{const e=typeof t=="object"&&t!=null&&"type"in t?t:null,s=e?.type,n=e?.key;return te(()=>e,[s,n,typeof e?.props=="object"&&e.props!=null&&Object.entries(e.props).length===0?id:e?.props])??t},cd=ne.createContext(!0);function Rr(){throw new Error("A function wrapped in useEffectEvent can't be called during rendering.")}const ld="use"in ne?()=>{try{return ne.use(cd)}catch{return!1}}:()=>!1;function ud(t){const e=ne.useRef(Rr);return ne.useInsertionEffect(()=>{e.current=t},[t]),(...s)=>{ld()&&Rr();const n=e.current;return n(...s)}}const cs=(t,e)=>{const s=T(11),n=H(),r=ud(e);let o;s[0]!==t?(o=Ei(t),s[0]=t,s[1]=o):o=s[1];const{scope:i,event:a}=o;let c;s[2]!==n||s[3]!==r||s[4]!==a||s[5]!==i?(c=()=>n.on({scope:i,event:a},r),s[2]=n,s[3]=r,s[4]=a,s[5]=i,s[6]=c):c=s[6];let l;s[7]!==n||s[8]!==a||s[9]!==i?(l=[n,i,a],s[7]=n,s[8]=a,s[9]=i,s[10]=l):l=s[10],q(c,l)},dd=t=>{if(t.key===void 0)throw new Error("useClientLookup: Element has no key");return t.key};function Ye(t){const e=T(15);let s;e[0]!==t?(s=t.map(md),e[0]=t,e[1]=s):s=e[1];const n=Cs(s);let r;e[2]!==n?(r=Object.keys(n),e[2]=n,e[3]=r):r=e[3];const o=r;let i;e[4]!==n?(i=n.reduce(hd,{}),e[4]=n,e[5]=i):i=e[5];const a=i;let c;e[6]!==n?(c=n.map(fd),e[6]=n,e[7]=c):c=e[7];const l=c;let u;e[8]!==a||e[9]!==o||e[10]!==n?(u=f=>{if("index"in f){if(f.index<0||f.index>=o.length)throw new Error(`useClientLookup: Index ${f.index} out of bounds (length: ${o.length})`);return n[f.index].methods}const h=a[f.key];if(h===void 0)throw new Error(`useClientLookup: Key "${f.key}" not found`);return n[h].methods},e[8]=a,e[9]=o,e[10]=n,e[11]=u):u=e[11];let d;return e[12]!==l||e[13]!==u?(d={state:l,get:u},e[12]=l,e[13]=u,e[14]=d):d=e[14],d}function fd(t){return t.state}function hd(t,e,s){return t[e.key]=s,t}function md(t){return _e(dd(t),Pu(t),t.deps)}const Mi=t=>{const e=T(15),{toolkit:s,mcpApp:n}=t;let r;e[0]!==n?(r=n?[_e("mcpApp",n)]:[],e[0]=n,e[1]=r):r=e[1];const o=Cs(r)[0],[i,a]=ee(gd);let c;e[2]!==i?(c=Object.fromEntries(Object.entries(i).map(bd)),e[2]=i,e[3]=c):c=e[3];let l;e[4]!==o||e[5]!==c||e[6]!==i?(l={toolUIs:i,mcpApp:o,tools:c},e[4]=o,e[5]=c,e[6]=i,e[7]=l):l=e[7];const u=l,d=Ai();let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=(_,C,S)=>{const y={render:C,standalone:S?.standalone??!1};return a(x=>({...x,[_]:[...x[_]??[],y]})),()=>{a(x=>{const E=x[_]?.filter(R=>R!==y)??[];if(E.length>0)return{...x,[_]:E};const I={...x};return delete I[_],I})}},e[8]=f):f=e[8];const h=f;let m,p;e[9]!==d||e[10]!==s?(m=()=>{if(!s)return;const _=[];for(const[S,y]of Object.entries(s)){const x="render"in y?y.render:void 0,E="renderText"in y?y.renderText:void 0,I=x??(E?wu(E):void 0);I&&_.push(h(S,I,{standalone:Su(y)}))}const C=Object.entries(s).reduce(yd,{});return _.push(d.current.modelContext().register({getModelContext:()=>({tools:C})})),()=>{_.forEach(_d)}},p=[s,h,d],e[9]=d,e[10]=s,e[11]=m,e[12]=p):(m=e[11],p=e[12]),q(m,p);let g;return e[13]!==u?(g={getState:()=>u,setToolUI:h},e[13]=u,e[14]=g):g=e[14],g},pd=Y(Mi);Ti(Mi,(t,e)=>{!t.modelContext&&e.modelContext.source===null&&(t.modelContext=bi())});function gd(){return{}}function vd(t){return t.render}function bd(t){const[e,s]=t;return[e,s.map(vd)]}function yd(t,e){const[s,n]=e;if(n.type==="mcp")return t;const{display:r,render:o,renderText:i,...a}=n;return t[s]=a,t}function _d(t){return t()}const tt=t=>_t(t.subscribe,t.getState),Sd=t=>{const e=T(8),{runtime:s}=t,n=tt(s);let r;e[0]!==n?(r=()=>n,e[0]=n,e[1]=r):r=e[1];let o;e[2]!==s?(o=()=>s,e[2]=s,e[3]=o):o=e[3];let i;return e[4]!==s.remove||e[5]!==r||e[6]!==o?(i={getState:r,remove:s.remove,__internal_getRuntime:o},e[4]=s.remove,e[5]=r,e[6]=o,e[7]=i):i=e[7],i},Di=Y(Sd),xd=t=>{const e=T(5),{runtime:s,index:n}=t;let r;e[0]!==n||e[1]!==s?(r=s.getAttachmentByIndex(n),e[0]=n,e[1]=s,e[2]=r):r=e[2];const o=r;let i;return e[3]!==o?(i=Di({runtime:o}),e[3]=o,e[4]=i):i=e[4],ue(i)},wd=Y(xd),Cd=({item:t,onSteer:e,onRemove:s})=>({getState:()=>t,steer:e,remove:s}),Td=Y(Cd),Ed=t=>{const e=T(55),{threadIdRef:s,messageIdRef:n,runtime:r}=t,o=tt(r),i=jn();let a,c;e[0]!==i||e[1]!==n||e[2]!==r||e[3]!==s?(a=()=>{const I=[];for(const R of["send","attachmentAdd"]){const P=r.unstable_on(R,()=>{i(`composer.${R}`,{threadId:s.current,...n&&{messageId:n.current}})});I.push(P)}return I.push(r.unstable_on("attachmentAddError",R=>{i("composer.attachmentAddError",{threadId:s.current,...n&&{messageId:n.current},...R.attachmentId&&{attachmentId:R.attachmentId},reason:R.reason,message:R.message})})),()=>{for(const R of I)R()}},c=[r,i,s,n],e[0]=i,e[1]=n,e[2]=r,e[3]=s,e[4]=a,e[5]=c):(a=e[4],c=e[5]),q(a,c);let l;if(e[6]!==r||e[7]!==o.attachments){let I;e[9]!==r?(I=(R,P)=>_e(R.id,wd({runtime:r,index:P}),[r,P]),e[9]=r,e[10]=I):I=e[10],l=o.attachments.map(I),e[6]=r,e[7]=o.attachments,e[8]=l}else l=e[8];const u=Ye(l),d=o.queue;let f;if(e[11]!==d||e[12]!==r){let I;e[14]!==r?(I=R=>_e(R.id,Td({item:R,onSteer:()=>r.steerQueueItem(R.id),onRemove:()=>r.removeQueueItem(R.id)})),e[14]=r,e[15]=I):I=e[15],f=d.map(I),e[11]=d,e[12]=r,e[13]=f}else f=e[13];const h=Ye(f),m=o.type??"thread";let p;e[16]!==u.state||e[17]!==d||e[18]!==o.attachmentAccept||e[19]!==o.canCancel||e[20]!==o.canSend||e[21]!==o.dictation||e[22]!==o.isEditing||e[23]!==o.isEmpty||e[24]!==o.quote||e[25]!==o.role||e[26]!==o.runConfig||e[27]!==o.text||e[28]!==m?(p={text:o.text,role:o.role,attachments:u.state,runConfig:o.runConfig,isEditing:o.isEditing,canCancel:o.canCancel,canSend:o.canSend,attachmentAccept:o.attachmentAccept,isEmpty:o.isEmpty,type:m,dictation:o.dictation,quote:o.quote,queue:d},e[16]=u.state,e[17]=d,e[18]=o.attachmentAccept,e[19]=o.canCancel,e[20]=o.canSend,e[21]=o.dictation,e[22]=o.isEditing,e[23]=o.isEmpty,e[24]=o.quote,e[25]=o.role,e[26]=o.runConfig,e[27]=o.text,e[28]=m,e[29]=p):p=e[29];const g=p;let _;e[30]!==g?(_=()=>g,e[30]=g,e[31]=_):_=e[31];const C=r.beginEdit??Id;let S;e[32]!==u?(S=I=>"id"in I?u.get({key:I.id}):u.get(I),e[32]=u,e[33]=S):S=e[33];let y;e[34]!==h?(y=I=>h.get(I),e[34]=h,e[35]=y):y=e[35];let x;e[36]!==r?(x=()=>r,e[36]=r,e[37]=x):x=e[37];let E;return e[38]!==r.addAttachment||e[39]!==r.cancel||e[40]!==r.clearAttachments||e[41]!==r.reset||e[42]!==r.send||e[43]!==r.setQuote||e[44]!==r.setRole||e[45]!==r.setRunConfig||e[46]!==r.setText||e[47]!==r.startDictation||e[48]!==r.stopDictation||e[49]!==y||e[50]!==x||e[51]!==_||e[52]!==C||e[53]!==S?(E={getState:_,setText:r.setText,setRole:r.setRole,setRunConfig:r.setRunConfig,addAttachment:r.addAttachment,reset:r.reset,clearAttachments:r.clearAttachments,send:r.send,cancel:r.cancel,beginEdit:C,startDictation:r.startDictation,stopDictation:r.stopDictation,setQuote:r.setQuote,attachment:S,queueItem:y,__internal_getRuntime:x},e[38]=r.addAttachment,e[39]=r.cancel,e[40]=r.clearAttachments,e[41]=r.reset,e[42]=r.send,e[43]=r.setQuote,e[44]=r.setRole,e[45]=r.setRunConfig,e[46]=r.setText,e[47]=r.startDictation,e[48]=r.stopDictation,e[49]=y,e[50]=x,e[51]=_,e[52]=C,e[53]=S,e[54]=E):E=e[54],E},Oi=Y(Ed);function Id(){throw new Error("beginEdit is not supported in this runtime")}const ki=t=>({get current(){return t()}}),Rd=t=>{const e=T(13),{runtime:s}=t,n=tt(s);let r;e[0]!==n?(r=()=>n,e[0]=n,e[1]=r):r=e[1];let o,i,a,c;e[2]!==s?(o=u=>s.addToolResult(u),i=u=>s.resumeToolCall(u),a=u=>s.respondToToolApproval(u),c=()=>s,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=c):(o=e[3],i=e[4],a=e[5],c=e[6]);let l;return e[7]!==r||e[8]!==o||e[9]!==i||e[10]!==a||e[11]!==c?(l={getState:r,addToolResult:o,resumeToolCall:i,respondToToolApproval:a,__internal_getRuntime:c},e[7]=r,e[8]=o,e[9]=i,e[10]=a,e[11]=c,e[12]=l):l=e[12],l},Ad=Y(Rd),Pd=t=>{const e=T(5),{runtime:s,index:n}=t;let r;e[0]!==n||e[1]!==s?(r=s.getAttachmentByIndex(n),e[0]=n,e[1]=s,e[2]=r):r=e[2];const o=r;let i;return e[3]!==o?(i=Di({runtime:o}),e[3]=o,e[4]=i):i=e[4],ue(i)},Md=Y(Pd),Dd=t=>{const e=T(5),{runtime:s,index:n}=t;let r;e[0]!==n||e[1]!==s?(r=s.getMessagePartByIndex(n),e[0]=n,e[1]=s,e[2]=r):r=e[2];const o=r;let i;return e[3]!==o?(i=Ad({runtime:o}),e[3]=o,e[4]=i):i=e[4],ue(i)},Od=Y(Dd),kd=t=>{const e=T(55),{runtime:s,threadIdRef:n}=t,r=tt(s),[o,i]=ee(!1),[a,c]=ee(!1);let l;e[0]!==s?(l=ki(()=>s.getState().id),e[0]=s,e[1]=l):l=e[1];const u=l;let d;e[2]!==u||e[3]!==s.composer||e[4]!==n?(d=Oi({runtime:s.composer,threadIdRef:n,messageIdRef:u}),e[2]=u,e[3]=s.composer,e[4]=n,e[5]=d):d=e[5];const f=Lt(d);let h;if(e[6]!==s||e[7]!==r.content){let j;e[9]!==s?(j=(Z,w)=>_e("toolCallId"in Z&&Z.toolCallId!=null?`toolCallId-${Z.toolCallId}`:`index-${w}`,Od({runtime:s,index:w}),[s,w]),e[9]=s,e[10]=j):j=e[10],h=r.content.map(j),e[6]=s,e[7]=r.content,e[8]=h}else h=e[8];const m=Ye(h);let p;e[11]!==r.attachments?(p=r.attachments??[],e[11]=r.attachments,e[12]=p):p=e[12];let g;if(e[13]!==s||e[14]!==p){let j;e[16]!==s?(j=(Z,w)=>_e(Z.id,Md({runtime:s,index:w}),[s,w]),e[16]=s,e[17]=j):j=e[17],g=p.map(j),e[13]=s,e[14]=p,e[15]=g}else g=e[15];const _=Ye(g),C=r;let S;e[18]!==f.state||e[19]!==o||e[20]!==a||e[21]!==m.state||e[22]!==C?(S={...C,parts:m.state,composer:f.state,isCopied:o,isHovering:a},e[18]=f.state,e[19]=o,e[20]=a,e[21]=m.state,e[22]=C,e[23]=S):S=e[23];const y=S;let x;e[24]!==y?(x=()=>y,e[24]=y,e[25]=x):x=e[25];let E;e[26]!==f.methods?(E=()=>f.methods,e[26]=f.methods,e[27]=E):E=e[27];let I,R,P,k,O,$,M;e[28]!==s?(I=()=>s.delete(),R=j=>s.reload(j),P=()=>s.speak(),k=()=>s.stopSpeaking(),O=j=>s.submitFeedback(j),$=j=>s.switchToBranch(j),M=()=>s.unstable_getCopyText(),e[28]=s,e[29]=I,e[30]=R,e[31]=P,e[32]=k,e[33]=O,e[34]=$,e[35]=M):(I=e[29],R=e[30],P=e[31],k=e[32],O=e[33],$=e[34],M=e[35]);let B;e[36]!==m?(B=j=>"index"in j?m.get({index:j.index}):m.get({key:`toolCallId-${j.toolCallId}`}),e[36]=m,e[37]=B):B=e[37];let U;e[38]!==_?(U=j=>"id"in j?_.get({key:j.id}):_.get(j),e[38]=_,e[39]=U):U=e[39];let V;e[40]!==s?(V=()=>s,e[40]=s,e[41]=V):V=e[41];let Q;return e[42]!==I||e[43]!==R||e[44]!==P||e[45]!==k||e[46]!==O||e[47]!==$||e[48]!==M||e[49]!==B||e[50]!==U||e[51]!==V||e[52]!==x||e[53]!==E?(Q={getState:x,composer:E,delete:I,reload:R,speak:P,stopSpeaking:k,submitFeedback:O,switchToBranch:$,getCopyText:M,part:B,attachment:U,setIsCopied:i,setIsHovering:c,__internal_getRuntime:V},e[42]=I,e[43]=R,e[44]=P,e[45]=k,e[46]=O,e[47]=$,e[48]=M,e[49]=B,e[50]=U,e[51]=V,e[52]=x,e[53]=E,e[54]=Q):Q=e[54],Q},$d=Y(kd),Nd=t=>{const e=T(6),{runtime:s,id:n,threadIdRef:r}=t;let o;e[0]!==n||e[1]!==s?(o=s.getMessageById(n),e[0]=n,e[1]=s,e[2]=o):o=e[2];const i=o;let a;return e[3]!==i||e[4]!==r?(a=$d({runtime:i,threadIdRef:r}),e[3]=i,e[4]=r,e[5]=a):a=e[5],ue(a)},Ld=Y(Nd),jd=t=>{const e=T(58),{runtime:s}=t,n=tt(s),r=jn();let o,i;e[0]!==r||e[1]!==s?(o=()=>{const x=[];for(const E of["runStart","runEnd","initialize","modelContextUpdate"]){const I=s.unstable_on(E,()=>{const R=s.getState()?.threadId||"unknown";r(`thread.${E}`,{threadId:R})});x.push(I)}return()=>{for(const E of x)E()}},i=[s,r],e[0]=r,e[1]=s,e[2]=o,e[3]=i):(o=e[2],i=e[3]),q(o,i);let a;e[4]!==s?(a=ki(()=>s.getState().threadId),e[4]=s,e[5]=a):a=e[5];const c=a;let l;e[6]!==s.composer||e[7]!==c?(l=Oi({runtime:s.composer,threadIdRef:c}),e[6]=s.composer,e[7]=c,e[8]=l):l=e[8];const u=Lt(l);let d;if(e[9]!==s||e[10]!==n.messages||e[11]!==c){let x;e[13]!==s||e[14]!==c?(x=E=>_e(E.id,Ld({runtime:s,id:E.id,threadIdRef:c}),[s,E.id,c]),e[13]=s,e[14]=c,e[15]=x):x=e[15],d=n.messages.map(x),e[9]=s,e[10]=n.messages,e[11]=c,e[12]=d}else d=e[12];const f=Ye(d),h=f.state.length===0&&!n.isLoading;let m;e[16]!==u.state||e[17]!==f.state||e[18]!==n.capabilities||e[19]!==n.extras||e[20]!==n.isDisabled||e[21]!==n.isLoading||e[22]!==n.isRunning||e[23]!==n.speech||e[24]!==n.state||e[25]!==n.suggestions||e[26]!==n.voice||e[27]!==h?(m={isEmpty:h,isDisabled:n.isDisabled,isLoading:n.isLoading,isRunning:n.isRunning,capabilities:n.capabilities,state:n.state,suggestions:n.suggestions,extras:n.extras,speech:n.speech,voice:n.voice,composer:u.state,messages:f.state},e[16]=u.state,e[17]=f.state,e[18]=n.capabilities,e[19]=n.extras,e[20]=n.isDisabled,e[21]=n.isLoading,e[22]=n.isRunning,e[23]=n.speech,e[24]=n.state,e[25]=n.suggestions,e[26]=n.voice,e[27]=h,e[28]=m):m=e[28];const p=m;let g;e[29]!==p?(g=()=>p,e[29]=p,e[30]=g):g=e[30];let _;e[31]!==u.methods?(_=()=>u.methods,e[31]=u.methods,e[32]=_):_=e[32];let C;e[33]!==f?(C=x=>"id"in x?f.get({key:x.id}):f.get(x),e[33]=f,e[34]=C):C=e[34];let S;e[35]!==s?(S=()=>s,e[35]=s,e[36]=S):S=e[36];let y;return e[37]!==s.append||e[38]!==s.cancelRun||e[39]!==s.connectVoice||e[40]!==s.deleteMessage||e[41]!==s.disconnectVoice||e[42]!==s.export||e[43]!==s.getModelContext||e[44]!==s.getVoiceVolume||e[45]!==s.import||e[46]!==s.muteVoice||e[47]!==s.reset||e[48]!==s.resumeRun||e[49]!==s.startRun||e[50]!==s.stopSpeaking||e[51]!==s.subscribeVoiceVolume||e[52]!==s.unmuteVoice||e[53]!==C||e[54]!==S||e[55]!==g||e[56]!==_?(y={getState:g,composer:_,append:s.append,deleteMessage:s.deleteMessage,startRun:s.startRun,resumeRun:s.resumeRun,cancelRun:s.cancelRun,getModelContext:s.getModelContext,export:s.export,import:s.import,reset:s.reset,stopSpeaking:s.stopSpeaking,connectVoice:s.connectVoice,disconnectVoice:s.disconnectVoice,getVoiceVolume:s.getVoiceVolume,subscribeVoiceVolume:s.subscribeVoiceVolume,muteVoice:s.muteVoice,unmuteVoice:s.unmuteVoice,message:C,__internal_getRuntime:S},e[37]=s.append,e[38]=s.cancelRun,e[39]=s.connectVoice,e[40]=s.deleteMessage,e[41]=s.disconnectVoice,e[42]=s.export,e[43]=s.getModelContext,e[44]=s.getVoiceVolume,e[45]=s.import,e[46]=s.muteVoice,e[47]=s.reset,e[48]=s.resumeRun,e[49]=s.startRun,e[50]=s.stopSpeaking,e[51]=s.subscribeVoiceVolume,e[52]=s.unmuteVoice,e[53]=C,e[54]=S,e[55]=g,e[56]=_,e[57]=y):y=e[57],y},Bd=Y(jd),Fd=t=>{const e=T(20),{runtime:s}=t,n=tt(s),r=jn();let o,i;e[0]!==r||e[1]!==s?(o=()=>{const u=[];for(const d of["switchedTo","switchedAway"]){const f=s.unstable_on(d,()=>{r(`threadListItem.${d}`,{threadId:s.getState().id})});u.push(f)}return()=>{for(const d of u)d()}},i=[s,r],e[0]=r,e[1]=s,e[2]=o,e[3]=i):(o=e[2],i=e[3]),q(o,i);let a;e[4]!==n?(a=()=>n,e[4]=n,e[5]=a):a=e[5];let c;e[6]!==s?(c=()=>s,e[6]=s,e[7]=c):c=e[7];let l;return e[8]!==s.archive||e[9]!==s.delete||e[10]!==s.detach||e[11]!==s.generateTitle||e[12]!==s.initialize||e[13]!==s.rename||e[14]!==s.switchTo||e[15]!==s.unarchive||e[16]!==s.updateCustom||e[17]!==a||e[18]!==c?(l={getState:a,switchTo:s.switchTo,rename:s.rename,updateCustom:s.updateCustom,archive:s.archive,unarchive:s.unarchive,delete:s.delete,generateTitle:s.generateTitle,initialize:s.initialize,detach:s.detach,__internal_getRuntime:c},e[8]=s.archive,e[9]=s.delete,e[10]=s.detach,e[11]=s.generateTitle,e[12]=s.initialize,e[13]=s.rename,e[14]=s.switchTo,e[15]=s.unarchive,e[16]=s.updateCustom,e[17]=a,e[18]=c,e[19]=l):l=e[19],l},Ud=Y(Fd),Vd=t=>{const e=T(5),{runtime:s,id:n}=t;let r;e[0]!==n||e[1]!==s?(r=s.getItemById(n),e[0]=n,e[1]=s,e[2]=r):r=e[2];const o=r;let i;return e[3]!==o?(i=Ud({runtime:o}),e[3]=o,e[4]=i):i=e[4],ue(i)},Hd=Y(Vd),qd=t=>{const e=T(40),{runtime:s,__internal_assistantRuntime:n}=t,r=tt(s);let o;e[0]!==s.main?(o=Bd({runtime:s.main}),e[0]=s.main,e[1]=o):o=e[1];const i=Lt(o);let a;e[2]!==s||e[3]!==r.threadItems?(a=Object.keys(r.threadItems).map(E=>_e(E,Hd({runtime:s,id:E}),[s,E])),e[2]=s,e[3]=r.threadItems,e[4]=a):a=e[4];const c=Ye(a),l=r.newThreadId??null;let u;e[5]!==i.state||e[6]!==r.archivedThreadIds||e[7]!==r.hasMore||e[8]!==r.isLoading||e[9]!==r.isLoadingMore||e[10]!==r.mainThreadId||e[11]!==r.threadIds||e[12]!==l||e[13]!==c.state?(u={mainThreadId:r.mainThreadId,newThreadId:l,isLoading:r.isLoading,isLoadingMore:r.isLoadingMore,hasMore:r.hasMore,threadIds:r.threadIds,archivedThreadIds:r.archivedThreadIds,threadItems:c.state,main:i.state},e[5]=i.state,e[6]=r.archivedThreadIds,e[7]=r.hasMore,e[8]=r.isLoading,e[9]=r.isLoadingMore,e[10]=r.mainThreadId,e[11]=r.threadIds,e[12]=l,e[13]=c.state,e[14]=u):u=e[14];const d=u;let f;e[15]!==d?(f=()=>d,e[15]=d,e[16]=f):f=e[16];let h;e[17]!==i.methods?(h=()=>i.methods,e[17]=i.methods,e[18]=h):h=e[18];let m;e[19]!==d||e[20]!==c?(m=E=>{if(E==="main")return c.get({key:d.mainThreadId});if("id"in E)return c.get({key:E.id});const{index:I,archived:R}=E,P=R!==void 0&&R?d.archivedThreadIds[I]:d.threadIds[I];return c.get({key:P})},e[19]=d,e[20]=c,e[21]=m):m=e[21];let p,g,_,C,S;e[22]!==s?(C=async(E,I)=>{await s.switchToThread(E,I)},S=async()=>{await s.switchToNewThread()},p=()=>s.getLoadThreadsPromise(),g=()=>s.reload(),_=()=>s.loadMore(),e[22]=s,e[23]=p,e[24]=g,e[25]=_,e[26]=C,e[27]=S):(p=e[23],g=e[24],_=e[25],C=e[26],S=e[27]);let y;e[28]!==n?(y=()=>n,e[28]=n,e[29]=y):y=e[29];let x;return e[30]!==p||e[31]!==g||e[32]!==_||e[33]!==y||e[34]!==f||e[35]!==h||e[36]!==m||e[37]!==C||e[38]!==S?(x={getState:f,thread:h,item:m,switchToThread:C,switchToNewThread:S,getLoadThreadsPromise:p,reload:g,loadMore:_,__internal_getAssistantRuntime:y},e[30]=p,e[31]=g,e[32]=_,e[33]=y,e[34]=f,e[35]=h,e[36]=m,e[37]=C,e[38]=S,e[39]=x):x=e[39],x},zd=Y(qd),Wd=t=>({getState:()=>t}),Gd=Y(Wd),Kd=t=>{const e=T(11);let s;e[0]!==t?(s=()=>({suggestions:(t??[]).map(Qd)}),e[0]=t,e[1]=s):s=e[1];const[n]=ee(s);let r;e[2]!==n.suggestions?(r=n.suggestions.map(Jd),e[2]=n.suggestions,e[3]=r):r=e[3];const o=Ye(r);let i;e[4]!==n?(i=()=>n,e[4]=n,e[5]=i):i=e[5];let a;e[6]!==o?(a=l=>{const{index:u}=l;return o.get({index:u})},e[6]=o,e[7]=a):a=e[7];let c;return e[8]!==i||e[9]!==a?(c={getState:i,suggestion:a},e[8]=i,e[9]=a,e[10]=c):c=e[10],c},Yd=Y(Kd);function Qd(t){return typeof t=="string"?{title:t,label:"",prompt:t}:{title:t.title,label:t.label,prompt:t.prompt}}function Jd(t,e){return _e(e,Gd(t),[t])}const Xd=(t,e)=>{t.thread??=he({source:"threads",query:{type:"main"},get:s=>s.threads().thread("main")}),t.threadListItem??=he({source:"threads",query:{type:"main"},get:s=>s.threads().item("main")}),t.composer??=he({source:"thread",query:{},get:s=>s.threads().thread("main").composer()}),!t.modelContext&&e.modelContext.source===null&&(t.modelContext=bi()),!t.suggestions&&e.suggestions.source===null&&(t.suggestions=Yd())},$i=t=>{const e=T(6),s=Ai();let n,r;e[0]!==s||e[1]!==t?(n=()=>t.registerModelContextProvider(s.current.modelContext()),r=[t,s],e[0]=s,e[1]=t,e[2]=n,e[3]=r):(n=e[2],r=e[3]),q(n,r);let o;return e[4]!==t?(o=zd({runtime:t.threads,__internal_assistantRuntime:t}),e[4]=t,e[5]=o):o=e[5],ue(o)},Zd=Y($i);Ti($i,(t,e)=>{Xd(t,e),!t.tools&&e.tools.source===null&&(t.tools=pd({})),!t.dataRenderers&&e.dataRenderers.source===null&&(t.dataRenderers=pu())});const ef=t=>t._core?.RenderComponent,tf=b.memo(({runtime:t,aui:e=null,children:s})=>{"use no memo";const n=H({threads:Zd(t)},{parent:e}),r=ef(t),o=v.jsxs(pe,{value:n,children:[r&&v.jsx(r,{}),s]});return e?v.jsx(pe,{value:e,children:o}):o}),Ar=t=>{let e;const s=new Set,n=(l,u)=>{const d=typeof l=="function"?l(e):l;if(!Object.is(d,e)){const f=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),s.forEach(h=>h(e,f))}},r=()=>e,a={setState:n,getState:r,getInitialState:()=>c,subscribe:l=>(s.add(l),()=>s.delete(l))},c=e=t(n,r,a);return a},sf=(t=>t?Ar(t):Ar),nf=t=>t;function rf(t,e=nf){const s=ne.useSyncExternalStore(t.subscribe,ne.useCallback(()=>e(t.getState()),[t,e]),ne.useCallback(()=>e(t.getInitialState()),[t,e]));return ne.useDebugValue(s),s}const Pr=t=>{const e=sf(t),s=n=>rf(e,n);return Object.assign(s,e),s},Ni=(t=>t?Pr(t):Pr);function ie(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}function ls(t,e=0){return e>100?!1:t===null||typeof t=="string"||typeof t=="boolean"?!0:typeof t=="number"?!Number.isNaN(t)&&Number.isFinite(t):Array.isArray(t)?t.every(s=>ls(s,e+1)):ie(t)?Object.entries(t).every(([s,n])=>typeof s=="string"&&ls(n,e+1)):!1}const of=100,fn=(t,e,s)=>{if(t===e)return!0;if(s>of||t==null||e==null)return!1;if(Array.isArray(t))return!Array.isArray(e)||t.length!==e.length?!1:t.every((o,i)=>fn(o,e[i],s+1));if(Array.isArray(e)||!ie(t)||!ie(e))return!1;const n=Object.keys(t),r=Object.keys(e);return n.length!==r.length?!1:n.every(o=>Object.hasOwn(e,o)&&fn(t[o],e[o],s+1))},Bn=(t,e)=>!ls(t)||!ls(e)?!1:fn(t,e,0);function af(t){const e=t.metadata;if(!e||typeof e!="object")return;const s=e.custom;if(!s||typeof s!="object")return;const n=s.interactables;return Array.isArray(n)?n:void 0}function cf(t){return`update_${t.replace(/[^a-zA-Z0-9_-]/g,"_")}`}const Mr=t=>{if(!ie(t))return;const e=t.id;return typeof e=="string"||typeof e=="number"?e:void 0};function lf(t,e,s){let n=Array.isArray(e.set)?[...e.set]:[...t];if(e.clear===!0&&(n=[]),Array.isArray(e.remove)&&e.remove.length>0){const o=new Set(e.remove);n=n.filter(i=>{const a=Mr(i);return a!==void 0?!o.has(a):!o.has(i)})}const r=e.update;if(Array.isArray(r)&&r.length>0&&(n=n.map(o=>{const i=Mr(o);if(i===void 0||!ie(o))return o;const a=r.find(c=>ie(c)&&c.id===i);return a?{...o,...a}:o})),Array.isArray(e.add)&&e.add.length>0){const o=s?e.add.map(i=>{if(!ie(i)||i.id!==void 0)return i;const a=s();return a===void 0?i:{...i,id:a}}):e.add;n=[...n,...o]}return n}function Us(t,e,s){if(!ie(t)||!ie(e))return e;const n=ie(s?.arrayBaseline)?s.arrayBaseline:t,r={...t};for(const[o,i]of Object.entries(e)){const a=n[o];Array.isArray(a)&&ie(i)?r[o]=lf(a,i,s?.idFactory&&(s.idKeyedFields===void 0||s.idKeyedFields.has(o))?()=>s.idFactory?.(o):void 0):r[o]=i}return r}function uf(t,e){if(!ie(t)||!ie(e))return;for(const r of Object.keys(t))if(!(r in e))return;const s={};for(const[r,o]of Object.entries(e))(!(r in t)||!Bn(t[r],o))&&(s[r]=o);const n=Object.keys(s).length;if(!(n===0||n===Object.keys(e).length))return s}const df=t=>{if(!t||typeof t!="object")return;const e=t;return e.type==="tool-call"?e:void 0},ff=(t,e)=>{if(!t.args||typeof t.args!="object")return!1;const s=ie(t.result)?t.result:void 0;if(s?.success===!1)return!1;if(typeof s?.id=="string")return s.id===e;const n=t.args.id;return n===e||n===void 0},hf=t=>{const e=ie(t)?t.addedItemIds:void 0;if(!ie(e))return;const s=new Map;for(const[n,r]of Object.entries(e)){if(!Array.isArray(r))continue;const o=r.filter(i=>typeof i=="string");o.length>0&&s.set(n,o)}if(s.size!==0)return n=>s.get(n)?.shift()},Dr=new WeakMap;function mf(t,e,s){let n=Dr.get(t);n||(n=new Map,Dr.set(t,n));let r=n.get(s);r||(r=new Map,n.set(s,r));const o=r.get(e);if(o)return o;const i=cf(s),a=[],c=()=>a[a.length-1];for(const l of t){if(l.role==="user"){const u=af(l)?.find(d=>d.id===e);if(!u)continue;if(u.partial){const d=c();d&&a.push({state:Us(d.state,u.state),origin:"user-edit"})}else a.push({state:u.state,origin:"user-edit"});continue}if(l.role==="assistant")for(const u of l.content??[]){const d=df(u);if(d){if(d.toolCallId===e&&d.toolName===s)d.args&&typeof d.args=="object"&&a.push({state:d.args,origin:"create",toolCallId:e});else if(d.toolName===i&&ff(d,e)){const f=c();if(f){const{id:h,...m}=d.args,p=hf(d.result);a.push({state:p?Us(f.state,m,{idFactory:p}):Us(f.state,m),origin:"update",toolCallId:d.toolCallId})}}}}}return r.set(e,a),a}function pf(t,e,s){const n=mf(t,e,s),r=n[n.length-1];return r?{state:r.state}:void 0}function Li(t,e){if(!t)return;const{interactables:s,...n}=t,r={...n};if(Array.isArray(s)){const o=[];for(const i of s){const a=pf(e,i.id,i.name);if(!a){o.push({id:i.id,name:i.name,state:i.state});continue}if(Bn(i.state,a.state))continue;const c=uf(a.state,i.state);o.push(c?{id:i.id,name:i.name,state:c,partial:!0}:{id:i.id,name:i.name,state:i.state})}o.length&&(r.interactables=o)}return Object.keys(r).length?r:void 0}const Fn=()=>{let t,e;const s=new Promise((n,r)=>{t=n,e=r});if(!t||!e)throw new Error("Failed to create promise");return{promise:s,resolve:t,reject:e}},gf=()=>{const t=[];let e=!1,s,n;const r=o=>{o.promise||(o.promise=o.reader.read().then(({done:i,value:a})=>{o.promise=void 0,i?(t.splice(t.indexOf(o),1),e&&t.length===0&&s.close()):s.enqueue(a),n?.resolve(),n=void 0}).catch(i=>{console.error(i),t.forEach(a=>{a.reader.cancel()}),t.length=0,s.error(i),n?.reject(i),n=void 0}))};return{readable:new ReadableStream({start(o){s=o},pull(){return n=Fn(),t.forEach(o=>{r(o)}),n.promise},cancel(){t.forEach(o=>{o.reader.cancel()}),t.length=0}}),isSealed(){return e},seal(){e=!0,t.length===0&&s.close()},addStream(o){if(e)throw new Error("Cannot add streams after the run callback has settled.");const i={reader:o.getReader()};t.push(i),r(i)},enqueue(o){this.addStream(new ReadableStream({start(i){i.enqueue(o),i.close()}}))}}};var Or=class{_controller;_isClosed=!1;constructor(t){this._controller=t}append(t){return this._controller.enqueue({type:"text-delta",path:[],textDelta:t}),this}close(){this._isClosed||(this._isClosed=!0,this._controller.enqueue({type:"part-finish",path:[]}),this._controller.close())}};const ji=t=>new ReadableStream({start(e){return t.start?.(new Or(e))},pull(e){return t.pull?.(new Or(e))},cancel(e){return t.cancel?.(e)}}),kr=()=>{let t;return[ji({start(e){t=e}}),t]};var $r=class{_controller;_isClosed=!1;_mergeTask;constructor(t){this._controller=t;const e=ji({start:n=>{this._argsTextController=n}});let s=!1;this._mergeTask=e.pipeTo(new WritableStream({write:n=>{switch(n.type){case"text-delta":s=!0,this._controller.enqueue(n);break;case"part-finish":s||this._controller.enqueue({type:"text-delta",textDelta:"{}",path:[]}),this._controller.enqueue({type:"tool-call-args-text-finish",path:[]});break;default:throw new Error(`Unexpected chunk type: ${n.type}`)}}}))}get argsText(){return this._argsTextController}_argsTextController;async setResponse(t){this._argsTextController.close(),await Promise.resolve(),this._controller.enqueue({type:"result",path:[],...t.artifact!==void 0?{artifact:t.artifact}:{},result:t.result,isError:t.isError??!1,...t.modelContent!==void 0?{modelContent:t.modelContent}:{},...t.messages!==void 0?{messages:t.messages}:{}})}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,this._controller.enqueue({type:"part-finish",path:[]}),this._controller.close())}};const vf=t=>new ReadableStream({start(e){return t.start?.(new $r(e))},pull(e){return t.pull?.(new $r(e))},cancel(e){return t.cancel?.(e)}}),bf=()=>{let t;return[vf({start(e){t=e}}),t]};var Bi=class{value=-1;up(){return++this.value}},yf=class extends TransformStream{constructor(t){super({transform(e,s){s.enqueue({...e,path:[t,...e.path]})}})}};(class extends TransformStream{constructor(t){super({transform(e,s){const{path:[n,...r]}=e;if(t!==n)throw new Error(`Path mismatch: expected ${t}, got ${n}`);s.enqueue({...e,path:r})}})}});var _f=class extends TransformStream{constructor(t){const e=new Bi,s=new Map;super({transform(n,r){n.type==="part-start"&&n.path.length===0&&s.set(e.up(),t.up());const[o,...i]=n.path;if(o===void 0){r.enqueue(n);return}const a=s.get(o);if(a===void 0)throw new Error("Path not found");r.enqueue({...n,path:[a,...i]})}})}},Sf=class extends TransformStream{constructor(t){super();const e=t(super.readable);Object.defineProperty(this,"readable",{value:e,writable:!1})}},Fi=class extends TransformStream{constructor(){const t=[];super({transform(e,s){if(e.type==="part-start"){if(e.path.length!==0){s.error(new Error("Nested parts are not supported"));return}t.push(e.part),s.enqueue(e);return}if(e.type==="text-delta"||e.type==="result"||e.type==="part-finish"||e.type==="tool-call-args-text-finish"){if(e.path.length!==1){s.error(new Error(`${e.type} chunks must have a path of length 1`));return}const n=e.path[0];if(n<0||n>=t.length){s.error(new Error(`Invalid path index: ${n}`));return}const r=t[n];s.enqueue({...e,meta:r});return}s.enqueue(e)}})}};let Ui=(t,e=21)=>(s=e)=>{let n="",r=s|0;for(;r-- >0;)n+=t[Math.random()*t.length|0];return n};const xf=Ui("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7);var wf=class Vi{_state;_parentId;constructor(e){this._state=e||{merger:gf(),contentCounter:new Bi}}get __internal_isClosed(){return this._state.merger.isSealed()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addPart(e,s){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:"part-start",part:e,path:[]}),this._state.merger.addStream(s.pipeThrough(new yf(this._state.contentCounter.value)))}merge(e){this._state.merger.addStream(e.pipeThrough(new _f(this._state.contentCounter)))}appendText(e){(this._state.append?.kind!=="text"||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:"text",parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(e)}appendReasoning(e){(this._state.append?.kind!=="reasoning"||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:"reasoning",parentId:this._parentId,controller:this.addReasoningPart()}),this._state.append.controller.append(e)}addTextPart(){const[e,s]=kr();return this._addPart(this._withParentIdOption({type:"text"}),e),s}addReasoningPart(){const[e,s]=kr();return this._addPart(this._withParentIdOption({type:"reasoning"}),e),s}addToolCallPart(e){const s=typeof e=="string"?{toolName:e}:e,n=s.toolName,r=s.toolCallId??xf(),[o,i]=bf();return this._addPart({type:"tool-call",toolName:n,toolCallId:r,...this._parentId&&{parentId:this._parentId}},o),s.argsText!==void 0&&(i.argsText.append(s.argsText),i.argsText.close()),s.args!==void 0&&(i.argsText.append(JSON.stringify(s.args)),i.argsText.close()),s.response!==void 0&&i.setResponse(s.response),i}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:"part-finish",path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}enqueue(e){this._state.merger.enqueue(e),e.type==="part-start"&&e.path.length===0&&this._state.contentCounter.up()}withParentId(e){const s=new Vi(this._state);return s._parentId=e,s}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function Cf(t){const e=new wf;return(async()=>{try{await t(e)}catch(n){throw e.__internal_isClosed||e.enqueue({type:"error",path:[],error:String(n)}),n}finally{e.__internal_isClosed||e.close()}})(),e.__internal_getReadable()}function Tf(){const{resolve:t,promise:e}=Fn();let s;return[Cf(n=>(s=n,s.__internal_subscribeToClose(t),e)),s]}function Ef(t){const e=["ROOT"];let s=-1,n=null;const r=[];let o;function i(){o!==void 0&&(r.push(JSON.parse(`"${o}"`)),o=void 0)}function a(d,f,h){switch(d){case'"':s=f,e.pop(),e.push(h),e.push("INSIDE_STRING"),i();break;case"f":case"t":case"n":s=f,n=f,e.pop(),e.push(h),e.push("INSIDE_LITERAL");break;case"-":e.pop(),e.push(h),e.push("INSIDE_NUMBER"),i();break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":s=f,e.pop(),e.push(h),e.push("INSIDE_NUMBER"),i();break;case"{":s=f,e.pop(),e.push(h),e.push("INSIDE_OBJECT_START"),i();break;case"[":s=f,e.pop(),e.push(h),e.push("INSIDE_ARRAY_START"),i();break}}function c(d,f){switch(d){case",":e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break;case"}":s=f,e.pop(),o=r.pop();break}}function l(d,f){switch(d){case",":e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA"),o=(Number(o)+1).toString();break;case"]":s=f,e.pop(),o=r.pop();break}}for(let d=0;d<t.length;d++){const f=t[d];switch(e[e.length-1]){case"ROOT":a(f,d,"FINISH");break;case"INSIDE_OBJECT_START":switch(f){case'"':e.pop(),e.push("INSIDE_OBJECT_KEY"),o="";break;case"}":s=d,e.pop(),o=r.pop();break}break;case"INSIDE_OBJECT_AFTER_COMMA":switch(f){case'"':e.pop(),e.push("INSIDE_OBJECT_KEY"),o="";break}break;case"INSIDE_OBJECT_KEY":switch(f){case'"':e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY");break;case"\\":e.push("INSIDE_STRING_ESCAPE"),o+=f;break;default:o+=f;break}break;case"INSIDE_OBJECT_AFTER_KEY":switch(f){case":":e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE");break}break;case"INSIDE_OBJECT_BEFORE_VALUE":a(f,d,"INSIDE_OBJECT_AFTER_VALUE");break;case"INSIDE_OBJECT_AFTER_VALUE":c(f,d);break;case"INSIDE_STRING":switch(f){case'"':e.pop(),s=d,o=r.pop();break;case"\\":e.push("INSIDE_STRING_ESCAPE");break;default:s=d}break;case"INSIDE_ARRAY_START":switch(f){case"]":s=d,e.pop(),o=r.pop();break;default:s=d,o="0",a(f,d,"INSIDE_ARRAY_AFTER_VALUE");break}break;case"INSIDE_ARRAY_AFTER_VALUE":switch(f){case",":e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA"),o=(Number(o)+1).toString();break;case"]":s=d,e.pop(),o=r.pop();break;default:s=d;break}break;case"INSIDE_ARRAY_AFTER_COMMA":a(f,d,"INSIDE_ARRAY_AFTER_VALUE");break;case"INSIDE_STRING_ESCAPE":e.pop(),e[e.length-1]==="INSIDE_STRING"?s=d:e[e.length-1]==="INSIDE_OBJECT_KEY"&&(o+=f);break;case"INSIDE_NUMBER":switch(f){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":s=d;break;case"e":case"E":case"-":case".":break;case",":e.pop(),o=r.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&l(f,d),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&c(f,d);break;case"}":e.pop(),o=r.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&c(f,d);break;case"]":e.pop(),o=r.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&l(f,d);break;default:e.pop(),o=r.pop();break}break;case"INSIDE_LITERAL":{const h=t.substring(n,d+1);!"false".startsWith(h)&&!"true".startsWith(h)&&!"null".startsWith(h)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?c(f,d):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&l(f,d)):s=d;break}}}let u=t.slice(0,s+1);for(let d=e.length-1;d>=0;d--)switch(e[d]){case"INSIDE_STRING":u+='"';break;case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":u+="}";break;case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":u+="]";break;case"INSIDE_LITERAL":{const f=t.substring(n,t.length);"true".startsWith(f)?u+="true".slice(f.length):"false".startsWith(f)?u+="false".slice(f.length):"null".startsWith(f)&&(u+="null".slice(f.length))}}return[u,r]}var qe={exports:{}},Nr;function If(){if(Nr)return qe.exports;Nr=1;const t=typeof Buffer<"u",e=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,s=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function n(a,c,l){l==null&&c!==null&&typeof c=="object"&&(l=c,c=void 0),t&&Buffer.isBuffer(a)&&(a=a.toString()),a&&a.charCodeAt(0)===65279&&(a=a.slice(1));const u=JSON.parse(a,c);if(u===null||typeof u!="object")return u;const d=l&&l.protoAction||"error",f=l&&l.constructorAction||"error";if(d==="ignore"&&f==="ignore")return u;if(d!=="ignore"&&f!=="ignore"){if(e.test(a)===!1&&s.test(a)===!1)return u}else if(d!=="ignore"&&f==="ignore"){if(e.test(a)===!1)return u}else if(s.test(a)===!1)return u;return r(u,{protoAction:d,constructorAction:f,safe:l&&l.safe})}function r(a,{protoAction:c="error",constructorAction:l="error",safe:u}={}){let d=[a];for(;d.length;){const f=d;d=[];for(const h of f){if(c!=="ignore"&&Object.prototype.hasOwnProperty.call(h,"__proto__")){if(u===!0)return null;if(c==="error")throw new SyntaxError("Object contains forbidden prototype property");delete h.__proto__}if(l!=="ignore"&&Object.prototype.hasOwnProperty.call(h,"constructor")&&h.constructor!==null&&typeof h.constructor=="object"&&Object.prototype.hasOwnProperty.call(h.constructor,"prototype")){if(u===!0)return null;if(l==="error")throw new SyntaxError("Object contains forbidden prototype property");delete h.constructor}for(const m in h){const p=h[m];p&&typeof p=="object"&&d.push(p)}}}return a}function o(a,c,l){const{stackTraceLimit:u}=Error;Error.stackTraceLimit=0;try{return n(a,c,l)}finally{Error.stackTraceLimit=u}}function i(a,c){const{stackTraceLimit:l}=Error;Error.stackTraceLimit=0;try{return n(a,c,{safe:!0})}catch{return}finally{Error.stackTraceLimit=l}}return qe.exports=o,qe.exports.default=o,qe.exports.parse=o,qe.exports.safeParse=i,qe.exports.scan=r,qe.exports}var Rf=If();const hn=Go(Rf),Zt=Symbol("aui.parse-partial-json-object.meta"),Af=t=>t?.[Zt],mn=t=>{if(t.length===0)return{[Zt]:{state:"partial",partialPath:[]}};try{const e=hn.parse(t);if(typeof e!="object"||e===null)throw new Error("argsText is expected to be an object");return e[Zt]={state:"complete",partialPath:[]},e}catch{try{const[e,s]=Ef(t),n=hn.parse(e);if(typeof n!="object"||n===null)throw new Error("argsText is expected to be an object");return n[Zt]={state:"partial",partialPath:s},n}catch{return}}},Hi=(t,e,s)=>{if(typeof t!="object"||t===null)return e.state;if(e.state==="complete")return"complete";if(s.length===0)return e.state;const[n,...r]=s;if(!Object.hasOwn(t,n))return"partial";const[o,...i]=e.partialPath;if(n!==o)return"complete";const a=t[n];return Hi(a,{state:"partial",partialPath:i},r)},pt=(t,e)=>{const s=Af(t);if(!s)throw new Error("unable to determine object state");return Hi(t,s,e.map(String))};async function*Pf(){const t=this.getReader();try{for(;;){const{done:e,value:s}=await t.read();if(e)break;yield s}}finally{t.releaseLock()}}function Vs(t){return t[Symbol.asyncIterator]??=Pf,t}const Lr=Symbol.for("aui.tool-response");var Pe=class pn{get[Lr](){return!0}artifact;result;isError;modelContent;messages;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact),this.result=e.result,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}static[Symbol.hasInstance](e){return typeof e=="object"&&e!==null&&Lr in e}static toResponse(e){return e instanceof pn?e:new pn({result:e===void 0?"<no result>":e})}};function Mf(t,e,s){try{const n=t();if(typeof n=="object"&&n!==null&&"then"in n)return n.then(e,s);e(n)}catch(n){s(n)}}function gt(t,e){let s=t;for(const n of e){if(s==null)return;s=s[n]}return s}var Df=class{resolve;reject;disposed=!1;fieldPath;constructor(t,e,s){this.resolve=t,this.reject=e,this.fieldPath=s}update(t){if(!this.disposed)try{if(pt(t,this.fieldPath)==="complete"){const e=gt(t,this.fieldPath);e!==void 0&&(this.resolve(e),this.dispose())}}catch(e){this.reject(e),this.dispose()}}end(t){if(!this.disposed)try{const e=gt(t,this.fieldPath);this.resolve(e)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},Of=class{controller;disposed=!1;fieldPath;constructor(t,e){this.controller=t,this.fieldPath=e}update(t){if(!this.disposed)try{const e=gt(t,this.fieldPath);e!==void 0&&this.controller.enqueue(e),pt(t,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},kf=class{controller;disposed=!1;fieldPath;lastValue=void 0;constructor(t,e){this.controller=t,this.fieldPath=e}update(t){if(!this.disposed)try{const e=gt(t,this.fieldPath);if(e!==void 0&&typeof e=="string"){const s=e.substring(this.lastValue?.length||0);this.lastValue=e,this.controller.enqueue(s)}pt(t,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},$f=class{controller;disposed=!1;fieldPath;processedIndexes=new Set;constructor(t,e){this.controller=t,this.fieldPath=e}update(t){if(!this.disposed)try{const e=gt(t,this.fieldPath);if(!Array.isArray(e))return;for(let s=0;s<e.length;s++)this.processedIndexes.has(s)||pt(t,[...this.fieldPath,s])==="complete"&&(this.controller.enqueue(e[s]),this.processedIndexes.add(s));pt(t,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},Nf=class{argTextDeltas;handles=new Set;args=mn("");finished=!1;constructor(t){this.argTextDeltas=t,this.processStream()}async processStream(){try{let t="";const e=this.argTextDeltas.getReader();for(;;){const{value:s,done:n}=await e.read();if(n)break;t+=s;const r=mn(t);if(r!==void 0){this.args=r;for(const o of this.handles)o.update(r)}}}catch(t){console.error("Error processing argument stream:",t)}finally{this.finished=!0;for(const t of this.handles)t.end(this.args);this.handles.clear()}}get(...t){return new Promise((e,s)=>{const n=new Df(e,s,t);if(this.args&&pt(this.args,t)==="complete"){const r=gt(this.args,t);if(r!==void 0){e(r);return}}if(this.finished){n.end(this.args);return}this.handles.add(n),n.update(this.args)})}streamValues(...t){const e=t;let s;return Vs(new ReadableStream({start:n=>{s=new Of(n,e),this.finished||this.handles.add(s),s.update(this.args),this.finished&&s.end()},cancel:()=>{s&&(s.dispose(),this.handles.delete(s))}}))}streamText(...t){const e=t;let s;return Vs(new ReadableStream({start:n=>{s=new kf(n,e),this.finished||this.handles.add(s),s.update(this.args),this.finished&&s.end()},cancel:()=>{s&&(s.dispose(),this.handles.delete(s))}}))}forEach(...t){const e=t;let s;return Vs(new ReadableStream({start:n=>{s=new $f(n,e),this.finished||this.handles.add(s),s.update(this.args),this.finished&&s.end()},cancel:()=>{s&&(s.dispose(),this.handles.delete(s))}}))}},Lf=class{promise;constructor(t){this.promise=t}get(){return this.promise}},jf=class{args;response;writable;resolve;argsText="";constructor(){const t=new TransformStream;this.writable=t.writable,this.args=new Nf(t.readable);const{promise:e,resolve:s}=Fn();this.resolve=s,this.response=new Lf(e)}async appendArgsTextDelta(t){const e=this.writable.getWriter();try{await e.write(t)}catch(s){console.warn(s)}finally{e.releaseLock()}this.argsText+=t}async finishArgsText(){const t=this.writable.getWriter();try{await t.close()}catch(e){console.warn(e)}finally{t.releaseLock()}}setResponse(t){this.resolve(t)}result={get:async()=>(await this.response.get()).result}},Bf=class extends Sf{constructor(t){const e=new Map,s=new Map;super(n=>{const r=new TransformStream({async transform(o,i){switch((o.type!=="part-finish"||o.meta.type!=="tool-call")&&i.enqueue(o),o.type){case"part-start":if(o.part.type==="tool-call"){const a=new jf;s.set(o.part.toolCallId,a),t.streamCall({reader:a,toolCallId:o.part.toolCallId,toolName:o.part.toolName})}break;case"text-delta":if(o.meta.type==="tool-call"){const a=o.meta.toolCallId,c=s.get(a);if(!c)throw new Error("No controller found for tool call");await c.appendArgsTextDelta(o.textDelta)}break;case"result":{if(o.meta.type!=="tool-call")break;const{toolCallId:a}=o.meta,c=s.get(a);if(!c)throw new Error("No controller found for tool call");c.setResponse(new Pe({result:o.result,artifact:o.artifact,isError:o.isError,modelContent:o.modelContent}));break}case"tool-call-args-text-finish":{if(o.meta.type!=="tool-call")break;const{toolCallId:a,toolName:c}=o.meta,l=s.get(a);if(!l)throw new Error("No controller found for tool call");await l.finishArgsText();let u=!1;const d=Mf(()=>{let f;try{f=hn.parse(l.argsText)}catch(m){throw new Error(`Function parameter parsing failed. ${JSON.stringify(m.message)}`)}const h=t.execute({toolCallId:a,toolName:c,args:f});return h!==void 0&&(u=!0,t.onExecutionStart?.(a,c)),h},f=>{if(u&&t.onExecutionEnd?.(a,c),f===void 0)return;const h=new Pe({artifact:f.artifact,result:f.result,isError:f.isError,messages:f.messages,modelContent:f.modelContent});l.setResponse(h),i.enqueue({type:"result",path:o.path,...h})},f=>{u&&t.onExecutionEnd?.(a,c);const h=new Pe({result:String(f),isError:!0});l.setResponse(h),i.enqueue({type:"result",path:o.path,...h})});d&&e.set(a,d);break}case"part-finish":{if(o.meta.type!=="tool-call")break;const{toolCallId:a}=o.meta,c=e.get(a);c?c.then(()=>{e.delete(a),s.delete(a),i.enqueue(o)}):i.enqueue(o)}}},async flush(){await Promise.all(e.values())}});return n.pipeThrough(new Fi).pipeThrough(r)})}};const Ff=t=>typeof t=="object"&&t!==null&&"~standard"in t&&t["~standard"].version===1;function Uf(t,e,s,n){const r=t?.[s.toolName];return r?.execute?(async i=>{if(e.aborted)return new Pe({result:"Tool execution was cancelled.",isError:!0});let a=i;if(Ff(r.parameters)){let u=r.parameters["~standard"].validate(s.args);u instanceof Promise&&(u=await u),u.issues&&(a=r.experimental_onSchemaValidationError??(()=>{throw new Error(`Function parameter validation failed. ${JSON.stringify(u.issues)}`)}))}const c=new Promise(u=>{const d=()=>{queueMicrotask(()=>{queueMicrotask(()=>{u(new Pe({result:"Tool execution was cancelled.",isError:!0}))})})};e.aborted?d():e.addEventListener("abort",d,{once:!0})}),l=(async()=>{const u=await a(s.args,{toolCallId:s.toolCallId,abortSignal:e,human:f=>n(s.toolCallId,f)}),d=Pe.toResponse(u);if(r.toModelOutput&&!d.isError&&d.modelContent===void 0)try{const f=await r.toModelOutput({toolCallId:s.toolCallId,input:s.args,output:d.result});return new Pe({result:d.result,artifact:d.artifact,isError:d.isError,messages:d.messages,modelContent:f})}catch(f){console.warn(`[assistant-stream] tool "${s.toolName}" toModelOutput threw; falling back to default projection.`,f)}return d})();return Promise.race([l,c])})(r.execute):void 0}function Vf(t,e,s,n,r){t?.[n.toolName]?.streamCall?.(s,{toolCallId:n.toolCallId,abortSignal:e,human:o=>r(n.toolCallId,o)})}function Hf(t,e,s,n){const r=typeof t=="function"?t:()=>t,o=typeof e=="function"?e:()=>e;return new Bf({execute:i=>Uf(r(),o(),i,s),streamCall:({reader:i,...a})=>Vf(r(),o(),i,a,s),onExecutionStart:n?.onExecutionStart,onExecutionEnd:n?.onExecutionEnd})}const Qe=Ui("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),qi=t=>{const e=T(7),{index:s,children:n}=t;let r;e[0]!==s?(r=he({source:"message",query:{type:"index",index:s},get:c=>c.message().attachment({index:s})}),e[0]=s,e[1]=r):r=e[1];let o;e[2]!==r?(o={attachment:r},e[2]=r,e[3]=o):o=e[3];const i=H(o);let a;return e[4]!==i||e[5]!==n?(a=v.jsx(pe,{value:i,children:n}),e[4]=i,e[5]=n,e[6]=a):a=e[6],a},zi=t=>{const e=T(7),{index:s,children:n}=t;let r;e[0]!==s?(r=he({source:"composer",query:{type:"index",index:s},get:c=>c.composer().attachment({index:s})}),e[0]=s,e[1]=r):r=e[1];let o;e[2]!==r?(o={attachment:r},e[2]=r,e[3]=o):o=e[3];const i=H(o);let a;return e[4]!==i||e[5]!==n?(a=v.jsx(pe,{value:i,children:n}),e[4]=i,e[5]=n,e[6]=a):a=e[6],a},Wi=t=>{const e=T(10),{index:s,children:n}=t;let r;e[0]!==s?(r=he({source:"thread",query:{type:"index",index:s},get:l=>l.thread().message({index:s})}),e[0]=s,e[1]=r):r=e[1];let o;e[2]!==s?(o=he({source:"message",query:{},get:l=>l.thread().message({index:s}).composer()}),e[2]=s,e[3]=o):o=e[3];let i;e[4]!==r||e[5]!==o?(i={message:r,composer:o},e[4]=r,e[5]=o,e[6]=i):i=e[6];const a=H(i);let c;return e[7]!==a||e[8]!==n?(c=v.jsx(pe,{value:a,children:n}),e[7]=a,e[8]=n,e[9]=c):c=e[9],c},Un=t=>{const e=T(7),{index:s,children:n}=t;let r;e[0]!==s?(r=he({source:"message",query:{type:"index",index:s},get:c=>c.message().part({index:s})}),e[0]=s,e[1]=r):r=e[1];let o;e[2]!==r?(o={part:r},e[2]=r,e[3]=o):o=e[3];const i=H(o);let a;return e[4]!==i||e[5]!==n?(a=v.jsx(pe,{value:i,children:n}),e[4]=i,e[5]=n,e[6]=a):a=e[6],a},qf=t=>{const e=T(7),{text:s,isRunning:n}=t;let r;e[0]!==n?(r=n?{type:"running"}:{type:"complete"},e[0]=n,e[1]=r):r=e[1];let o;e[2]!==r||e[3]!==s?(o={type:"text",text:s,status:r},e[2]=r,e[3]=s,e[4]=o):o=e[4];const i=o;let a;return e[5]!==i?(a={getState:()=>i,addToolResult:Wf,resumeToolCall:Gf,respondToToolApproval:Kf},e[5]=i,e[6]=a):a=e[6],a},zf=Y(qf),Vn=t=>{const e=T(8),{text:s,isRunning:n,children:r}=t,o=n===void 0?!1:n;let i;e[0]!==o||e[1]!==s?(i=zf({text:s,isRunning:o}),e[0]=o,e[1]=s,e[2]=i):i=e[2];let a;e[3]!==i?(a={part:i},e[3]=i,e[4]=a):a=e[4];const c=H(a);let l;return e[5]!==c||e[6]!==r?(l=v.jsx(pe,{value:c,children:r}),e[5]=c,e[6]=r,e[7]=l):l=e[7],l};function Wf(){throw new Error("Not supported")}function Gf(){throw new Error("Not supported")}function Kf(){throw new Error("Not supported")}const Yf=Object.freeze({type:"complete"}),Qf=t=>{const e=T(9),{parts:s,getMessagePart:n}=t,[r,o]=ee(!0),i=s[s.length-1]?.status??Yf;let a;e[0]!==r||e[1]!==s||e[2]!==i?(a={parts:s,collapsed:r,status:i},e[0]=r,e[1]=s,e[2]=i,e[3]=a):a=e[3];const c=a;let l;e[4]!==c?(l=()=>c,e[4]=c,e[5]=l):l=e[5];let u;return e[6]!==n||e[7]!==l?(u={getState:l,setCollapsed:o,part:n},e[6]=n,e[7]=l,e[8]=u):u=e[8],u},Jf=Y(Qf),Xf=t=>{const e=T(5),{startIndex:s,endIndex:n,children:r}=t,o=D(Zf).slice(s,n+1),i=H(),a=Jf({parts:o,getMessagePart:d=>{const{index:f}=d;if(f<0||f>=o.length)throw new Error(`ChainOfThought part index ${f} is out of bounds (0..${o.length-1})`);return i.message().part({index:s+f})}});let c;e[0]!==a?(c={chainOfThought:a},e[0]=a,e[1]=c):c=e[1];const l=H(c);let u;return e[2]!==l||e[3]!==r?(u=v.jsx(pe,{value:l,children:r}),e[2]=l,e[3]=r,e[4]=u):u=e[4],u};function Zf(t){return t.message.parts}const Gi=t=>{const e=T(8),{index:s,archived:n,children:r}=t;let o;e[0]!==n||e[1]!==s?(o=he({source:"threads",query:{type:"index",index:s,archived:n},get:l=>l.threads().item({index:s,archived:n})}),e[0]=n,e[1]=s,e[2]=o):o=e[2];let i;e[3]!==o?(i={threadListItem:o},e[3]=o,e[4]=i):i=e[4];const a=H(i);let c;return e[5]!==a||e[6]!==r?(c=v.jsx(pe,{value:a,children:r}),e[5]=a,e[6]=r,e[7]=c):c=e[7],c},Ki=t=>{const e=T(7),{index:s,children:n}=t;let r;e[0]!==s?(r=he({source:"suggestions",query:{index:s},get:c=>c.suggestions().suggestion({index:s})}),e[0]=s,e[1]=r):r=e[1];let o;e[2]!==r?(o={suggestion:r},e[2]=r,e[3]=o):o=e[3];const i=H(o);let a;return e[4]!==i||e[5]!==n?(a=v.jsx(pe,{value:i,children:n}),e[4]=i,e[5]=n,e[6]=a):a=e[6],a},eh=t=>{const e=T(7),{index:s,children:n}=t;let r;e[0]!==s?(r=he({source:"composer",query:{index:s},get:c=>c.composer().queueItem({index:s})}),e[0]=s,e[1]=r):r=e[1];let o;e[2]!==r?(o={queueItem:r},e[2]=r,e[3]=o):o=e[3];const i=H(o);let a;return e[4]!==i||e[5]!==n?(a=v.jsx(pe,{value:i,children:n}),e[4]=i,e[5]=n,e[6]=a):a=e[6],a},Je=Symbol("innerMessage"),Hs=Symbol("innerMessages"),th=[],sh=(t,e)=>{Je in t||(t[Je]=e)},nh=t=>{const e="messages"in t?t.messages:t,s=e[Hs]||e[Je];return s?Array.isArray(s)?s:(e[Hs]=[s],e[Hs]):th},Se=Symbol("skip-update");function rh(t,e){if(t===void 0&&e===void 0)return!0;if(t===void 0||e===void 0)return!1;for(const s of Object.keys(t)){const n=t[s],r=e[s];if(!Object.is(n,r))return!1}return!0}var oh=class{_subscribers=new Set;subscribe(t){return this._subscribers.add(t),()=>this._subscribers.delete(t)}waitForUpdate(){return new Promise(t=>{const e=this.subscribe(()=>{e(),t()})})}_notifySubscribers(){const t=[];for(const e of this._subscribers)try{e()}catch(s){t.push(s)}if(t.length>0){if(t.length===1)throw t[0];for(const e of t)console.error(e);throw new AggregateError(t)}}},Is=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(t){for(const e of this._subscriptions)e(t)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else this._connection?.(),this._connection=void 0}subscribe(t){return this._subscriptions.add(t),this._updateConnection(),()=>{this._subscriptions.delete(t),this._updateConnection()}}},be=class extends Is{binding;get path(){return this.binding.path}constructor(t){super(),this.binding=t;const e=t.getState();if(e===Se)throw new Error("Entry not available in the store");this._previousState=e}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){const t=this.binding.getState();return t===Se||rh(t,this._previousState)?!1:(this._previousState=t,!0)}_connect(){const t=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(t)}},Hn=class extends Is{binding;get path(){return this.binding.path}constructor(t){super(),this.binding=t}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){const t=this.binding.getState();t!==Se&&(this._previousState=t),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState};_connect(){const t=()=>{this._previousStateDirty=!0,this.notifySubscribers()};return this.binding.subscribe(t)}},us=class extends Is{binding;get path(){return this.binding.path}constructor(t){super(),this.binding=t}getState(){return this.binding.getState()}outerSubscribe(t){return this.binding.subscribe(t)}_connect(){const t=()=>{this.notifySubscribers()};let e=this.binding.getState(),s=e?.subscribe(t);const n=()=>{const o=this.binding.getState();o!==e&&(e=o,s?.(),s=o?.subscribe(t),t())},r=this.outerSubscribe(n);return()=>{r?.(),s?.()}}},Yi=class extends Is{config;constructor(t){super(),this.config=t}getState(){return this.config.binding.getState()}outerSubscribe(t){return this.config.binding.subscribe(t)}_connect(){const t=o=>{this.notifySubscribers(o)};let e=this.config.binding.getState(),s=e?.unstable_on(this.config.event,t);const n=()=>{const o=this.config.binding.getState();o!==e&&(e=o,s?.(),s=o?.unstable_on(this.config.event,t))},r=this.outerSubscribe(n);return()=>{r?.(),s?.()}}},Qi=class{_core;get path(){return this._core.path}constructor(t){this._core=t,this.__internal_bindMethods()}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(t){return this._core.subscribe(t)}},Ji=class extends Qi{_composerApi;constructor(t,e){super(t),this._composerApi=e}remove(){const t=this._composerApi.getState();if(!t)throw new Error("Composer is not available");return t.removeAttachment(this.getState().id)}},ih=class extends Ji{get source(){return"thread-composer"}},ah=class extends Ji{get source(){return"edit-composer"}},ch=class extends Qi{get source(){return"message"}remove(){throw new Error("Message attachments cannot be removed")}};const ds=Object.freeze([]),Xi=Object.freeze({}),lh=t=>Object.freeze({type:"thread",isEditing:t?.isEditing??!1,canCancel:t?.canCancel??!1,canSend:t?.canSend??!1,isEmpty:t?.isEmpty??!0,attachments:t?.attachments??ds,text:t?.text??"",role:t?.role??"user",runConfig:t?.runConfig??Xi,attachmentAccept:t?.attachmentAccept??"",dictation:t?.dictation,quote:t?.quote,queue:t?.queue??ds,value:t?.text??""}),uh=t=>Object.freeze({type:"edit",isEditing:t?.isEditing??!1,canCancel:t?.canCancel??!1,canSend:t?.canSend??!1,isEmpty:t?.isEmpty??!0,text:t?.text??"",role:t?.role??"user",attachments:t?.attachments??ds,runConfig:t?.runConfig??Xi,attachmentAccept:t?.attachmentAccept??"",dictation:t?.dictation,quote:t?.quote,queue:t?.queue??ds,parentId:t?.parentId??null,sourceId:t?.sourceId??null,value:t?.text??""});var Zi=class{_core;get path(){return this._core.path}constructor(t){this._core=t}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.steerQueueItem=this.steerQueueItem.bind(this),this.removeQueueItem=this.removeQueueItem.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setText(t)}setRunConfig(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setRunConfig(t)}addAttachment(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");return e.addAttachment(t)}reset(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.reset()}clearAttachments(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.clearAttachments()}send(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.send(t)}cancel(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.cancel()}steerQueueItem(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.steerQueueItem(t)}removeQueueItem(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.removeQueueItem(t)}setRole(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setRole(t)}startDictation(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.startDictation()}stopDictation(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.stopDictation()}setQuote(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setQuote(t)}subscribe(t){return this._core.subscribe(t)}_eventSubscriptionSubjects=new Map;unstable_on(t,e){let s=this._eventSubscriptionSubjects.get(t);return s||(s=new Yi({event:t,binding:this._core}),this._eventSubscriptionSubjects.set(t,s)),s.subscribe(e)}},dh=class extends Zi{get path(){return this._core.path}get type(){return"thread"}_getState;constructor(t){const e=new Hn({path:t.path,getState:()=>lh(t.getState()),subscribe:s=>t.subscribe(s)});super({path:t.path,getState:()=>t.getState(),subscribe:s=>e.subscribe(s)}),this._getState=e.getState.bind(e),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(t){return new ih(new be({path:{...this.path,attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:t},ref:`${this.path.ref}.attachments[${t}]`},getState:()=>{const e=this.getState().attachments[t];return e?{...e,source:"thread-composer"}:Se},subscribe:e=>this._core.subscribe(e)}),this._core)}},fh=class extends Zi{_beginEdit;get path(){return this._core.path}get type(){return"edit"}_getState;constructor(t,e){const s=new Hn({path:t.path,getState:()=>uh(t.getState()),subscribe:n=>t.subscribe(n)});super({path:t.path,getState:()=>t.getState(),subscribe:n=>s.subscribe(n)}),this._beginEdit=e,this._getState=s.getState.bind(s),this.__internal_bindMethods()}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(t){return new ah(new be({path:{...this.path,attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:t},ref:`${this.path.ref}.attachments[${t}]`},getState:()=>{const e=this.getState().attachments[t];return e?{...e,source:"edit-composer"}:Se},subscribe:e=>this._core.subscribe(e)}),this._core)}};const Dt=t=>t.content.filter(e=>e.type==="text").map(e=>e.text).join(`
28
-
29
- `),jr={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},hh=(t,e)=>{let s,n;if("optionId"in e){const r=t.options?.find(o=>o.id===e.optionId);if(!r)throw new Error(`Tool approval has no option with id "${e.optionId}"`);if("approved"in e)s=e.approved;else{if(!Object.hasOwn(jr,r.kind))throw new Error(`Tool approval option "${r.id}" has a custom kind "${r.kind}"; respond with an explicit approved value instead`);s=jr[r.kind]}n=r.id}else s=e.approved;return{approvalId:t.id,approved:s,...n!==void 0&&{optionId:n},...e.reason!=null&&{reason:e.reason}}};var Br=class{contentBinding;messageApi;threadApi;get path(){return this.contentBinding.path}constructor(t,e,s){this.contentBinding=t,this.messageApi=e,this.threadApi=s,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(t){const e=this.contentBinding.getState();if(!e)throw new Error("Message part is not available");if(e.type!=="tool-call")throw new Error("Tried to add tool result to non-tool message part");if(!this.messageApi)throw new Error("Message API is not available. This is likely a bug in assistant-ui.");if(!this.threadApi)throw new Error("Thread API is not available");const s=this.messageApi.getState();if(!s)throw new Error("Message is not available");const n=e.toolName,r=e.toolCallId,o=Pe.toResponse(t);this.threadApi.getState().addToolResult({messageId:s.id,toolName:n,toolCallId:r,result:o.result,artifact:o.artifact,isError:o.isError})}resumeToolCall(t){const e=this.contentBinding.getState();if(!e)throw new Error("Message part is not available");if(e.type!=="tool-call")throw new Error("Tried to resume tool call on non-tool message part");if(!this.threadApi)throw new Error("Thread API is not available");const s=e.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:s,payload:t})}respondToToolApproval(t){const e=this.contentBinding.getState();if(!e)throw new Error("Message part is not available");if(e.type!=="tool-call")throw new Error("Tried to respond to tool approval on non-tool message part");if(!e.approval||e.approval.approved!==void 0||e.approval.resolution!==void 0)throw new Error("Tool call has no pending approval");if(!this.threadApi)throw new Error("Thread API is not available");this.threadApi.getState().respondToToolApproval(hh(e.approval,t))}subscribe(t){return this.contentBinding.subscribe(t)}};const Ut=Object.freeze({type:"complete"}),mh=(t,e,s)=>{if(t.role!=="assistant")return Ut;if(s.type==="tool-call")return s.result?Ut:t.status;const n=e===Math.max(0,t.content.length-1);return t.status.type==="requires-action"?Ut:n?t.status:Ut},Fr=(t,e)=>{const s=t.content[e];if(!s)return Se;const n=mh(t,e,s);return Object.freeze({...s,[Je]:s[Je],status:n})};var ph=class{_core;_threadBinding;get path(){return this._core.path}constructor(t,e){this._core=t,this._threadBinding=e,this.composer=new fh(new us({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:"edit"},getState:this._getEditComposerRuntimeCore,subscribe:s=>this._threadBinding.subscribe(s)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}__internal_bindMethods(){this.reload=this.reload.bind(this),this.delete=this.delete.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}delete(){const t=this._core.getState();return this._threadBinding.getState().deleteMessage(t.id)}reload(t={}){const e=this._getEditComposerRuntimeCore(),s=e??this._threadBinding.getState().composer,n=e??s,{runConfig:r=n.runConfig}=t,o=this._core.getState();if(o.role!=="assistant")throw new Error("Can only reload assistant messages");this._threadBinding.getState().startRun({parentId:o.parentId,sourceId:o.id,runConfig:r})}speak(){const t=this._core.getState();return this._threadBinding.getState().speak(t.id)}stopSpeaking(){const t=this._core.getState();if(this._threadBinding.getState().speech?.messageId===t.id)this._threadBinding.getState().stopSpeaking();else throw new Error("Message is not being spoken")}submitFeedback({type:t}){const e=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:e.id,type:t})}switchToBranch({position:t,branchId:e}){const s=this._core.getState();if(e&&t)throw new Error("May not specify both branchId and position");if(!e&&!t)throw new Error("Must specify either branchId or position");const n=this._threadBinding.getState().getBranches(s.id);let r=e;if(t==="previous"?r=n[s.branchNumber-2]:t==="next"&&(r=n[s.branchNumber]),!r)throw new Error("Branch not found");this._threadBinding.getState().switchToBranch(r)}unstable_getCopyText(){return Dt(this.getState())}subscribe(t){return this._core.subscribe(t)}getMessagePartByIndex(t){if(t<0)throw new Error("Message part index must be >= 0");return new Br(new be({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.content[${t}]`,messagePartSelector:{type:"index",index:t}},getState:()=>Fr(this.getState(),t),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(t){return new Br(new be({path:{...this.path,ref:this.path.ref+`${this.path.ref}.content[toolCallId=${JSON.stringify(t)}]`,messagePartSelector:{type:"toolCallId",toolCallId:t}},getState:()=>{const e=this._core.getState(),s=e.content.findIndex(n=>n.type==="tool-call"&&n.toolCallId===t);return s===-1?Se:Fr(e,s)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(t){return new ch(new be({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.attachments[${t}]`,attachmentSource:"message",attachmentSelector:{type:"index",index:t}},getState:()=>{const e=this.getState().attachments?.[t];return e?{...e,source:"message"}:Se},subscribe:e=>this._core.subscribe(e)}))}};const gh=t=>({parentId:t.parentId??null,sourceId:t.sourceId??null,runConfig:t.runConfig??{},...t.stream?{stream:t.stream}:{}}),vh=t=>({parentId:t.parentId??null,sourceId:t.sourceId??null,runConfig:t.runConfig??{}}),bh=(t,e)=>typeof e=="string"?{createdAt:new Date,parentId:t.at(-1)?.id??null,sourceId:null,runConfig:{},role:"user",content:[{type:"text",text:e}],attachments:[],metadata:{custom:{}}}:{createdAt:e.createdAt??new Date,parentId:e.parentId??t.at(-1)?.id??null,sourceId:e.sourceId??null,role:e.role??"user",content:e.content,attachments:e.attachments??[],metadata:e.metadata??{custom:{}},runConfig:e.runConfig??{},startRun:e.startRun},yh=(t,e)=>{const s=t.messages.at(-1);return Object.freeze({threadId:e.id,metadata:e,capabilities:t.capabilities,isDisabled:t.isDisabled,isLoading:t.isLoading,isRunning:t.isRunning??(s?.role!=="assistant"?!1:s.status.type==="running"),messages:t.messages,state:t.state,suggestions:t.suggestions,extras:t.extras,speech:t.speech,voice:t.voice})};var ea=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;constructor(t,e){const s=new be({path:t.path,getState:()=>yh(t.getState(),e.getState()),subscribe:n=>{const r=t.subscribe(n),o=e.subscribe(n);return()=>{r(),o()}}});this._threadBinding={path:t.path,getState:()=>t.getState(),getStateState:()=>s.getState(),outerSubscribe:n=>t.outerSubscribe(n),subscribe:n=>t.subscribe(n)},this.composer=new dh(new us({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:"thread"},getState:()=>this._threadBinding.getState().composer,subscribe:n=>this._threadBinding.subscribe(n)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.deleteMessage=this.deleteMessage.bind(this),this.resumeRun=this.resumeRun.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getState=this.getState.bind(this)}composer;getState(){return this._threadBinding.getStateState()}append(t){this._threadBinding.getState().append(bh(this._threadBinding.getState().messages,t))}deleteMessage(t){return this._threadBinding.getState().deleteMessage(t)}subscribe(t){return this._threadBinding.subscribe(t)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(t){return this._threadBinding.getState().startRun(vh(t))}resumeRun(t){return this._threadBinding.getState().resumeRun(gh(t))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(t){this._threadBinding.getState().importExternalState(t)}cancelRun(){this._threadBinding.getState().cancelRun()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(t){return this._threadBinding.getState().subscribeVoiceVolume(t)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(t){this._threadBinding.getState().import(t)}reset(t){this._threadBinding.getState().reset(t)}getMessageByIndex(t){if(t<0)throw new Error("Message index must be >= 0");return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${t}]`,messageSelector:{type:"index",index:t}},()=>{const e=this._threadBinding.getState().messages,s=e[t];if(s)return{message:s,parentId:e[t-1]?.id??null,index:t}})}getMessageById(t){return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[messageId=${JSON.stringify(t)}]`,messageSelector:{type:"messageId",messageId:t}},()=>this._threadBinding.getState().getMessageById(t))}_getMessageRuntime(t,e){return new ph(new be({path:t,getState:()=>{const{message:s,parentId:n,index:r}=e()??{},{messages:o,speech:i}=this._threadBinding.getState();if(!s||n===void 0||r===void 0)return Se;const a=this._threadBinding.getState().getBranches(s.id);return{...s,[Je]:s[Je],index:r,isLast:o.at(-1)?.id===s.id,parentId:n,branchNumber:a.indexOf(s.id)+1,branchCount:a.length,speech:i?.messageId===s.id?i:void 0}},subscribe:s=>this._threadBinding.subscribe(s)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(t,e){let s=this._eventSubscriptionSubjects.get(t);return s||(s=new Yi({event:t,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(t,s)),s.subscribe(e)}};const _h=fe(null),Sh=()=>me(_h);var Vt=class{_core;_threadListBinding;get path(){return this._core.path}constructor(t,e){this._core=t,this._threadListBinding=e,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.updateCustom=this.updateCustom.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(t){const e=this._core.getState();return this._threadListBinding.switchToThread(e.id,t)}rename(t){const e=this._core.getState();return this._threadListBinding.rename(e.id,t)}updateCustom(t){const e=this._core.getState();if(!this._threadListBinding.updateCustom)throw new Error("Thread list runtime does not support updating custom metadata");return this._threadListBinding.updateCustom(e.id,t)}archive(){const t=this._core.getState();return this._threadListBinding.archive(t.id)}unarchive(){const t=this._core.getState();return this._threadListBinding.unarchive(t.id)}delete(){const t=this._core.getState();return this._threadListBinding.delete(t.id)}initialize(){const t=this._core.getState();return this._threadListBinding.initialize(t.id)}generateTitle(){const t=this._core.getState();return this._threadListBinding.generateTitle(t.id)}unstable_on(t,e){let s=this._core.getState().isMain,n=this._core.getState().id;return this.subscribe(()=>{const r=this._core.getState(),o=r.isMain,i=r.id;s===o&&n===i||(s=o,n=i,!(t==="switchedTo"&&!o)&&(t==="switchedAway"&&o||e({})))})}subscribe(t){return this._core.subscribe(t)}detach(){const t=this._core.getState();this._threadListBinding.detach(t.id)}__internal_getRuntime(){return this}};const Ur=Promise.resolve(),xh=t=>({mainThreadId:t.mainThreadId,newThreadId:t.newThreadId,threadIds:t.threadIds,archivedThreadIds:t.archivedThreadIds,isLoading:t.isLoading,isLoadingMore:t.isLoadingMore??!1,hasMore:t.hasMore??!1,threadItems:t.threadItems}),Ht=(t,e)=>{if(e===void 0)return Se;const s=t.getItemById(e);return s?{id:s.id,remoteId:s.remoteId,externalId:s.externalId,title:s.title,status:s.status,lastMessageAt:s.lastMessageAt,custom:s.custom,isMain:s.id===t.mainThreadId}:Se};var wh=class{_core;_runtimeFactory;_getState;constructor(t,e=ea){this._core=t,this._runtimeFactory=e;const s=new Hn({path:{},getState:()=>xh(t),subscribe:n=>t.subscribe(n)});this._getState=s.getState.bind(s),this._mainThreadListItemRuntime=new Vt(new be({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>Ht(this._core,this._core.mainThreadId),subscribe:n=>this._core.subscribe(n)}),this._core),this.main=new e(new us({path:{ref:"threads.main",threadSelector:{type:"main"}},getState:()=>t.getMainThreadRuntimeCore(),subscribe:n=>t.subscribe(n)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.loadMore=this.loadMore.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(t,e){return this._core.switchToThread(t,e)}switchToNewThread(){return this._core.switchToNewThread()}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??Ur}loadMore(){return this._core.loadMore?.()??Ur}getState(){return this._getState()}subscribe(t){return this._core.subscribe(t)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}getById(t){return new this._runtimeFactory(new us({path:{ref:`threads[threadId=${JSON.stringify(t)}]`,threadSelector:{type:"threadId",threadId:t}},getState:()=>this._core.getThreadRuntimeCore(t),subscribe:e=>this._core.subscribe(e)}),this.mainItem)}getItemByIndex(t){return new Vt(new be({path:{ref:`threadItems[${t}]`,threadSelector:{type:"index",index:t}},getState:()=>Ht(this._core,this._core.threadIds[t]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(t){return new Vt(new be({path:{ref:`archivedThreadItems[${t}]`,threadSelector:{type:"archiveIndex",index:t}},getState:()=>Ht(this._core,this._core.archivedThreadIds[t]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(t){return new Vt(new be({path:{ref:`threadItems[threadId=${t}]`,threadSelector:{type:"threadId",threadId:t}},getState:()=>Ht(this._core,t),subscribe:e=>this._core.subscribe(e)}),this._core)}},ta=class{_core;threads;_thread;constructor(t){this._core=t,this.threads=new wh(t.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(t){return this._core.registerModelContextProvider(t)}},sa=class{_contextProvider=new $n;registerModelContextProvider(t){return this._contextProvider.registerModelContextProvider(t)}getModelContextProvider(){return this._contextProvider}};const ze=Object.freeze([]),ft="DEFAULT_THREAD_ID",Ch=Object.freeze([ft]),Th=Object.freeze({id:ft,remoteId:void 0,externalId:void 0,status:"regular"}),Eh=Promise.resolve(),Vr=Object.freeze({[ft]:Th});var Ih=class{threadFactory;_mainThreadId=ft;_threads=Ch;_archivedThreads=ze;_threadData=Vr;adapter={};get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadItems(){return this._threadData}getLoadThreadsPromise(){return Eh}_mainThread;get mainThreadId(){return this._mainThreadId}constructor(t={},e){this.threadFactory=e,this.__internal_setAdapter(t,!0)}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw new Error("Method not implemented.")}getItemById(t){return this._threadData[t]}__internal_setAdapter(t,e=!1){const s=this.adapter;this.adapter=t;const n=t.threadId??ft,r=t.threads??ze,o=t.archivedThreads??ze,i=s.threadId??ft,a=s.threads??ze,c=s.archivedThreads??ze;!e&&i===n&&a===r&&c===o||((a!==r||c!==o||i!==n)&&(this._threadData={...Vr,...Object.fromEntries(t.threads?.map(l=>[l.id,{...l,remoteId:l.remoteId,externalId:l.externalId,status:"regular"}])??[]),...Object.fromEntries(t.archivedThreads?.map(l=>[l.id,{...l,remoteId:l.remoteId,externalId:l.externalId,status:"archived"}])??[])}),a!==r&&(this._threads=this.adapter.threads?.map(l=>l.id)??ze),c!==o&&(this._archivedThreads=this.adapter.archivedThreads?.map(l=>l.id)??ze),(e||i!==n)&&(this._mainThreadId=n,this._mainThread=this.threadFactory()),this._threadData[this._mainThreadId]||(this._threadData={...this._threadData,[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:"regular"}}),this._notifySubscribers())}async switchToThread(t,e){if(this._mainThreadId===t)return;const s=this.adapter.onSwitchToThread;if(!s)throw new Error("External store adapter does not support switching to thread");await s(t)}async switchToNewThread(){const t=this.adapter.onSwitchToNewThread;if(!t)throw new Error("External store adapter does not support switching to new thread");await t()}async rename(t,e){const s=this.adapter.onRename;if(!s)throw new Error("External store adapter does not support renaming");await s(t,e)}async updateCustom(t,e){const s=this.adapter.onUpdateCustom;if(!s)throw new Error("External store adapter does not support updating custom metadata");await s(t,e)}async detach(){}async archive(t){const e=this.adapter.onArchive;if(!e)throw new Error("External store adapter does not support archiving");await e(t)}async unarchive(t){const e=this.adapter.onUnarchive;if(!e)throw new Error("External store adapter does not support unarchiving");await e(t)}async delete(t){const e=this.adapter.onDelete;if(!e)throw new Error("External store adapter does not support deleting");await e(t)}initialize(t){return Promise.resolve({remoteId:t,externalId:void 0})}generateTitle(){throw new Error("Method not implemented.")}_subscriptions=new Set;subscribe(t){return this._subscriptions.add(t),()=>this._subscriptions.delete(t)}_notifySubscribers(){for(const t of this._subscriptions)t()}};const qs=(t,e)=>{if(t.startsWith("data-"))return{type:"data",name:t.substring(5),data:e}},fs=(t,e,s)=>{const{role:n,id:r,createdAt:o,attachments:i,status:a,metadata:c}=t,l={id:r??e,createdAt:o??new Date},u=typeof t.content=="string"?[{type:"text",text:t.content}]:t.content,d=({image:f,...h})=>typeof f!="string"?null:f.match(/^data:image\/(png|jpeg|jpg|gif|webp|svg\+xml);base64,(.*)$/)?{...h,image:f}:/^(https:\/\/|blob:)/.test(f)?{...h,image:f}:(console.warn("Invalid image data format detected"),null);if(n!=="user"&&i?.length)throw new Error("attachments are only supported for user messages");if(n!=="assistant"&&a)throw new Error("status is only supported for assistant messages");if(n!=="assistant"&&c?.steps)throw new Error("metadata.steps is only supported for assistant messages");switch(n){case"assistant":return{...l,role:n,content:u.map(f=>{const h=f.type;switch(h){case"text":case"reasoning":return f.text?.trim()?f:null;case"file":case"source":return f;case"image":return d(f);case"data":return f;case"generative-ui":return f;case"tool-call":{const{parentId:m,messages:p,...g}=f,_={...g,toolCallId:f.toolCallId??`tool-${Qe()}`,...m!==void 0&&{parentId:m},...p!==void 0&&{messages:p}};return f.args?{..._,args:f.args,argsText:f.argsText??JSON.stringify(f.args)}:{..._,args:mn(f.argsText??"")??{},argsText:f.argsText??""}}default:{const m=qs(h,f.data);if(m)return m;throw new Error(`Unsupported assistant message part type: ${h}`)}}}).filter(f=>!!f),status:a??s,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[],...c?.timing&&{timing:c.timing},...c?.submittedFeedback&&{submittedFeedback:c.submittedFeedback},...c?.isOptimistic&&{isOptimistic:!0}}};case"user":return{...l,role:n,content:u.map(f=>{const h=f.type;switch(h){case"text":case"image":case"audio":case"file":case"data":return f;default:{const m=qs(h,f.data);if(m)return m;throw new Error(`Unsupported user message part type: ${h}`)}}}),attachments:(i??[]).map(f=>({...f,content:f.content.map(h=>qs(h.type,h.data)??h)})),metadata:{custom:c?.custom??{}}};case"system":if(u.length!==1||u[0].type!=="text")throw new Error("System messages must have exactly one text message part.");return{...l,role:n,content:u,metadata:{custom:c?.custom??{}}};default:throw new Error(`Unknown message role: ${n}`)}},St=Symbol("autoStatus"),Rh=Object.freeze(Object.assign({type:"running"},{[St]:!0})),Ah=Object.freeze(Object.assign({type:"complete",reason:"unknown"},{[St]:!0})),Ph=Object.freeze(Object.assign({type:"requires-action",reason:"tool-calls"},{[St]:!0})),Mh=Object.freeze(Object.assign({type:"requires-action",reason:"interrupt"},{[St]:!0})),Dh=t=>t[St]===!0,hs=(t,e,s,n,r)=>t&&r?Object.assign({type:"incomplete",reason:"error",error:r},{[St]:!0}):t&&e?Rh:s?Mh:n?Ph:Ah,na={fromArray:t=>{const e=t.map(s=>fs(s,Qe(),hs(!1,!1,!1,!1,void 0)));return{messages:e.map((s,n)=>({parentId:n>0?e[n-1].id:null,message:s}))}},fromBranchableArray:(t,e)=>{const s=hs(!1,!1,!1,!1,void 0);return{...e?.headId!==void 0?{headId:e.headId}:void 0,messages:t.map(({message:n,parentId:r})=>{if(!n.id)throw new Error("ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.");return{parentId:r,message:fs(n,n.id,s)}})}}},es=t=>t.next?es(t.next):"current"in t?t:null;var Oh=class{func;_value=null;constructor(t){this.func=t}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},qn=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(t,e){t.level=e;for(const s of t.children){const n=this.messages.get(s);n&&this.updateLevels(n,e+1)}}performOp(t,e,s){const n=e.prev??this.root,r=t??this.root;if(!(s==="relink"&&n===r)){if(s!=="link"&&(n.children=n.children.filter(o=>o!==e.current.id),n.next===e)){const o=n.children.at(-1),i=o?this.messages.get(o):null;if(i===void 0)throw new Error("MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.");n.next=i}if(s!=="cut"){for(let i=t;i;i=i.prev)if(i.current.id===e.current.id)throw new Error("MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.");r.children=[...r.children,e.current.id],(es(e)===this.head||r.next===null)&&(r.next=e),e.prev=t;const o=t?t.level+1:0;this.updateLevels(e,o)}}}_messages=new Oh(()=>{const t=new Array((this.head?.level??-1)+1);for(let e=this.head;e;e=e.prev)t[e.level]=e.current;return t});get headId(){return this.head?.current.id??null}get canonicalHeadId(){let t=this.head;for(;t?.current.metadata?.isOptimistic;)t=t.prev;return t?.current.id??null}getMessages(t){if(t===void 0||t===this.head?.current.id)return this._messages.value;const e=this.messages.get(t);if(!e)throw new Error("MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.");const s=new Array(e.level+1);for(let n=e;n;n=n.prev)s[n.level]=n.current;return s}addOrUpdateMessage(t,e){const s=this.messages.get(e.id),n=t?this.messages.get(t):null;if(n===void 0)throw new Error("MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.");if(s){s.current=e,this.performOp(n,s,"relink"),this._messages.dirty();return}const r={prev:n,current:e,next:null,children:[],level:n?n.level+1:0};this.messages.set(e.id,r),this.performOp(n,r,"link"),this.head===n&&(this.head=r),this._messages.dirty()}getMessage(t){const e=this.messages.get(t);if(!e)throw new Error("MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.");return{parentId:e.prev?.current.id??null,message:e.current,index:e.level}}deleteMessage(t,e){const s=this.messages.get(t);if(!s)throw new Error("MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.");const n=e===void 0?s.prev:e===null?null:this.messages.get(e);if(n===void 0)throw new Error("MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.");for(const r of s.children){const o=this.messages.get(r);if(!o)throw new Error("MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.");this.performOp(n,o,"relink")}this.performOp(null,s,"cut"),this.messages.delete(t),this.head===s&&(this.head=es(n??this.root)),this._messages.dirty()}getBranches(t){const e=this.messages.get(t);if(!e)throw new Error("MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.");const{children:s}=e.prev??this.root;return s}evictOffBranchOptimisticMessages(t,e){if(!t)return;const s=new Set;for(let r=e;r;r=r.prev)s.add(r.current.id);const n=[];for(let r=t;r&&!s.has(r.current.id);r=r.prev)r.current.metadata?.isOptimistic&&n.push(r.current.id);for(const r of n)this.messages.has(r)&&this.deleteMessage(r)}switchToBranch(t){const e=this.messages.get(t);if(!e)throw new Error("MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.");const s=this.head,n=e.prev??this.root;n.next=e,this.head=es(e),this.evictOffBranchOptimisticMessages(s,this.head),this._messages.dirty()}resetHead(t){if(t===null){this.clear();return}const e=this.messages.get(t);if(!e)throw new Error("MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.");const s=this.head;if(e.children.length>0){const n=r=>{for(const o of r.children){const i=this.messages.get(o);i&&(n(i),this.messages.delete(o))}};n(e),e.children=[],e.next=null}this.head=e;for(let n=e;n;n=n.prev)n.prev?n.prev.next=n:this.root.next=n;this.evictOffBranchOptimisticMessages(s,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){const t=[];for(const[,e]of this.messages){if(e.current.metadata?.isOptimistic)continue;let s=e.prev;for(;s&&s.current.metadata?.isOptimistic;)s=s.prev;t.push({message:e.current,parentId:s?.current.id??null})}return{headId:this.canonicalHeadId,messages:t}}import({headId:t,messages:e}){for(const{message:s,parentId:n}of e)this.addOrUpdateMessage(n,s);this.resetHead(t??e.at(-1)?.message.id??null)}};const zn=Object.freeze([]);function Hr(t,e){if(e==="*")return!0;const s=e.split(",").map(o=>o.trim().toLowerCase()),n=`.${t.name.split(".").pop().toLowerCase()}`,r=t.type.split(";",1)[0].trim().toLowerCase();for(const o of s){if(o.startsWith(".")&&o===n||o.includes("/")&&o===r)return!0;if(o.endsWith("/*")){const i=o.split("/")[0];if(r.startsWith(`${i}/`))return!0}}return!1}function kh(t,e){return t.length!==e.length?!1:t.every((s,n)=>s.id===e[n].id)}function $h(t){const e=Qe();return t.type==="image"?{id:e,type:"image",name:t.filename??"image",content:[t],status:{type:"complete"}}:t.type==="file"?{id:e,type:"document",name:t.filename??"document",contentType:t.mimeType,content:[t],status:{type:"complete"}}:t.type==="audio"?{id:e,type:"audio",name:`audio.${t.audio.format}`,contentType:`audio/${t.audio.format}`,content:[t],status:{type:"complete"}}:{id:e,type:"data",name:t.name,content:[t],status:{type:"complete"}}}function Nh(t){const e=[];for(const s of t)s.type!=="text"&&e.push($h(s));return e}const zs=t=>t.status.type==="complete";var ra=class extends oh{isEditing=!0;enrichWithComposerMetadata(t,e){return e?{...t,metadata:{...t.metadata,custom:{...t.metadata?.custom,...e}}}:t}get attachmentAccept(){return this.getAttachmentAdapter()?.accept??"*"}_attachments=[];get attachments(){return this._attachments}setAttachments(t){this._attachments=t,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text="";get text(){return this._text}_role="user";get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}_quote=void 0;get quote(){return this._quote}setQuote(t){this._quote!==t&&(this._quote=t,this._notifySubscribers())}setText(t){if(this._text!==t){if(this._text=t,this._dictation){this._dictationBaseText=t,this._currentInterimText="";const{status:e,inputDisabled:s}=this._dictation;this._dictation=s?{status:e,inputDisabled:s}:{status:e}}this._notifySubscribers()}}setRole(t){this._role!==t&&(this._role=t,this._notifySubscribers())}setRunConfig(t){this._runConfig!==t&&(this._runConfig=t,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text="",this._notifySubscribers()}async _onClearAttachments(){const t=this.getAttachmentAdapter();if(t){const e=this._attachments.filter(s=>!zs(s));await Promise.all(e.map(s=>t.remove(s)))}}async reset(){if(this._attachments.length===0&&this._text===""&&this._role==="user"&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role="user",this._runConfig={},this._quote=void 0;const t=this._onClearAttachments();this._emptyTextAndAttachments(),await t}async clearAttachments(){const t=this._onClearAttachments();this.setAttachments([]),await t}async send(t){if(!this.canSend)return;this._dictationSession&&(this._dictationSession.cancel(),this._cleanupDictation());const e=this.getAttachmentAdapter(),s=this.attachments.length>0?Promise.all(this.attachments.map(async c=>{if(zs(c))return c;if(!e)throw new Error("Attachments are not supported");return await e.send(c)})):[],n=this.attachments,r=this.text,o=this._quote;this._quote=void 0,this._emptyTextAndAttachments();let i;try{i=await s}catch(c){throw this.isEmpty&&this._quote===void 0&&(this._attachments=n,this._text=r,this._quote=o,this._notifySubscribers()),c}const a={createdAt:new Date,role:this.role,content:r?[{type:"text",text:r}]:[],attachments:i,runConfig:this.runConfig,metadata:{custom:{...o?{quote:o}:{}}}};this.handleSend(a,t),this._notifyEventSubscribers("send",{})}cancel(){this.handleCancel()}get queue(){return zn}steerQueueItem(t){}removeQueueItem(t){}async addAttachment(t){if(!(t instanceof File)){const r=this.getAttachmentAdapter();if(r&&!Hr({name:t.name,type:t.contentType??""},r.accept)){const i=`File type ${t.contentType||"unknown"} is not accepted. Accepted types: ${r.accept}`,a=new Error(i);throw this._safeEmitAttachmentAddError("not-accepted",i,void 0,a),a}const o={id:t.id??Qe(),type:t.type??"document",name:t.name,contentType:t.contentType,content:t.content,status:{type:"complete"}};this._attachments=[...this._attachments,o],this._notifySubscribers(),this._notifyEventSubscribers("attachmentAdd",{});return}const e=r=>{const o=this._attachments.findIndex(i=>i.id===r.id);o!==-1?this._attachments=[...this._attachments.slice(0,o),r,...this._attachments.slice(o+1)]:this._attachments=[...this._attachments,r],this._notifySubscribers()},s=this.getAttachmentAdapter();if(!s){const r="Attachments are not supported",o=new Error(r);throw this._safeEmitAttachmentAddError("no-adapter",r,void 0,o),o}if(!Hr({name:t.name,type:t.type},s.accept)){const r=`File type ${t.type||"unknown"} is not accepted. Accepted types: ${s.accept}`,o=new Error(r);throw this._safeEmitAttachmentAddError("not-accepted",r,void 0,o),o}let n;try{const r=s.add({file:t});if(Symbol.asyncIterator in r)for await(const o of r)n=o,e(o);else n=await r,e(n)}catch(r){throw n&&e({...n,status:{type:"incomplete",reason:"error",message:r instanceof Error?r.message:String(r)}}),this._safeEmitAttachmentAddError("adapter-error",r instanceof Error?r.message:String(r),n?.id,r instanceof Error?r:void 0),r}n?.status.type==="incomplete"&&n.status.reason==="error"?this._safeEmitAttachmentAddError("adapter-error",n.status.message??"Attachment upload did not complete successfully.",n.id):this._notifyEventSubscribers("attachmentAdd",{})}_safeEmitAttachmentAddError(t,e,s,n){try{this._notifyEventSubscribers("attachmentAddError",{reason:t,message:e,...s!==void 0&&{attachmentId:s},...n!==void 0&&{error:n}})}catch(r){console.error("[assistant-ui] attachmentAddError subscriber threw:",r)}}async removeAttachment(t){const e=this._attachments.findIndex(n=>n.id===t);if(e===-1)throw new Error("Attachment not found");const s=this._attachments[e];if(!zs(s)){const n=this.getAttachmentAdapter();if(!n)throw new Error("Attachments are not supported");await n.remove(s)}this._attachments=this._attachments.filter(n=>n.id!==t),this._notifySubscribers()}_dictation;_dictationSession;_dictationUnsubscribes=[];_dictationBaseText="";_currentInterimText="";_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(t,e){return this._activeDictationSessionId===t&&this._dictationSession===e}startDictation(){const t=this.getDictationAdapter();if(!t)throw new Error("Dictation adapter not configured");if(this._dictationSession){for(const c of this._dictationUnsubscribes)c();this._dictationUnsubscribes=[],this._dictationSession.stop().catch(()=>{}),this._dictationSession=void 0}const e=t.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText="";const s=t.listen();this._dictationSession=s;const n=++this._dictationSessionIdCounter;this._activeDictationSessionId=n,this._dictation={status:s.status,inputDisabled:e},this._notifySubscribers();const r=s.onSpeech(c=>{if(!this._isActiveSession(n,s))return;const l=c.isFinal!==!1,u=this._dictationBaseText&&!this._dictationBaseText.endsWith(" ")&&c.transcript?" ":"";if(l){if(this._dictationBaseText=this._dictationBaseText+u+c.transcript,this._currentInterimText="",this._text=this._dictationBaseText,this._dictation){const{transcript:d,...f}=this._dictation;this._dictation=f}this._notifySubscribers()}else this._currentInterimText=u+c.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&(this._dictation={...this._dictation,transcript:c.transcript}),this._notifySubscribers()});this._dictationUnsubscribes.push(r);const o=s.onSpeechStart(()=>{this._isActiveSession(n,s)&&(this._dictation={status:{type:"running"},inputDisabled:e,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(o);const i=s.onSpeechEnd(()=>{this._cleanupDictation({sessionId:n})});this._dictationUnsubscribes.push(i);const a=setInterval(()=>{this._isActiveSession(n,s)&&s.status.type==="ended"&&this._cleanupDictation({sessionId:n})},100);this._dictationUnsubscribes.push(()=>clearInterval(a))}stopDictation(){if(!this._dictationSession)return;const t=this._dictationSession,e=this._activeDictationSessionId;t.stop().finally(()=>{this._cleanupDictation({sessionId:e})})}_cleanupDictation(t){if(!(t?.sessionId!==void 0&&t.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)){this._isCleaningDictation=!0;try{for(const e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText="",this._currentInterimText="",this._notifySubscribers()}finally{this._isCleaningDictation=!1}}}_eventSubscribers=new Map;_notifyEventSubscribers(t,e){const s=this._eventSubscribers.get(t);if(s)for(const n of s)n(e)}unstable_on(t,e){const s=e;let n=this._eventSubscribers.get(t);return n||(n=new Set,this._eventSubscribers.set(t,n)),n.add(s),()=>{this._eventSubscribers.get(t)?.delete(s)}}},oa=class extends ra{runtime;_canCancel=!1;get canCancel(){return this._canCancel}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled}get queue(){return this.runtime.getQueueItems?.()??zn}steerQueueItem(t){this.runtime.steerQueueItem?.(t)}removeQueueItem(t){this.runtime.removeQueueItem?.(t)}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}constructor(t){super(),this.runtime=t,this.connect()}connect(){let t=this.runtime.isSendDisabled,e=this.queue;return this.runtime.subscribe(()=>{let s=!1;this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,s=!0),t!==this.runtime.isSendDisabled&&(t=this.runtime.isSendDisabled,s=!0),e!==this.queue&&(e=this.queue,s=!0),s&&this._notifySubscribers()})}async handleSend(t,e){const s=Li(this.runtime.getModelContext().unstable_composerMetadata,this.runtime.messages),n=this.enrichWithComposerMetadata(t,s);this.runtime.append({...n,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:e?.startRun,steer:e?.steer})}async handleCancel(){this.runtime.cancelRun()}},Lh=class extends ra{runtime;endEditCallback;get canCancel(){return!0}get canSend(){return!this.isEmpty}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_previousText;_previousAttachments;_nonTextPassthrough;_parentId;_sourceId;constructor(t,e,{parentId:s,message:n}){super(),this.runtime=t,this.endEditCallback=e,this._parentId=s,this._sourceId=n.id,this._previousText=Dt(n),this.setText(this._previousText),this.setRole(n.role),n.role==="user"?(this._previousAttachments=[...n.attachments??[],...Nh(n.content)],this._nonTextPassthrough=[]):(this._previousAttachments=n.attachments??[],this._nonTextPassthrough=n.content.filter(r=>r.type!=="text")),this.setAttachments(this._previousAttachments),this.setRunConfig({...t.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(t,e){const s=Dt(t),n=!kh(t.attachments??[],this._previousAttachments);if(s!==this._previousText||n||e?.startRun){const r=this._nonTextPassthrough.length>0?[...t.content,...this._nonTextPassthrough]:t.content,o=this.runtime.messages,i=this._parentId===null?-1:o.findIndex(l=>l.id===this._parentId),a=Li(this.runtime.getModelContext().unstable_composerMetadata,o.slice(0,i+1)),c=this.enrichWithComposerMetadata(t,a);this.runtime.append({...c,content:r,parentId:this._parentId,sourceId:this._sourceId,startRun:e?.startRun})}this.handleCancel()}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},jh=class{_contextProvider;_subscriptions=new Set;_isInitialized=!1;repository=new qn;_voiceMessages=[];_voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();const t=this._getBaseMessages();return(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==t)&&(this._cachedMergedMessages=[...t,...this._voiceMessages],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=t),this._cachedMergedMessages}get state(){let t;for(const e of this.messages)e.role==="assistant"&&(t=e);return t?.metadata.unstable_state??null}composer=new oa(this);constructor(t){this._contextProvider=t}getModelContext(){return this._contextProvider.getModelContext()}_editComposers=new Map;getEditComposer(t){return this._editComposers.get(t)}beginEdit(t){if(this._editComposers.has(t))throw new Error("Edit already in progress");this._editComposers.set(t,new Lh(this,()=>this._editComposers.delete(t),this.repository.getMessage(t))),this._notifySubscribers()}getMessageById(t){try{return this.repository.getMessage(t)}catch{const e=this.repository.getMessages(),s=this._voiceMessages.findIndex(n=>n.id===t);return s!==-1?{parentId:s>0?this._voiceMessages[s-1].id:e.at(-1)?.id??null,message:this._voiceMessages[s],index:e.length+s}:void 0}}getBranches(t){return this._voiceMessages.some(e=>e.id===t)?[]:this.repository.getBranches(t)}switchToBranch(t){this.repository.switchToBranch(t),this._notifySubscribers()}_notifySubscribers(){for(const t of this._subscriptions)t()}_notifyEventSubscribers(t,e){const s=this._eventSubscribers.get(t);if(s)for(const n of s)n(e)}subscribe(t){return this._subscriptions.add(t),()=>this._subscriptions.delete(t)}submitFeedback({messageId:t,type:e}){const s=this.adapters?.feedback;if(!s)throw new Error("Feedback adapter not configured");const{message:n,parentId:r}=this.repository.getMessage(t);if(s.submit({message:n,type:e}),n.role==="assistant"){const o={...n,metadata:{...n.metadata,submittedFeedback:{type:e}}};this.repository.addOrUpdateMessage(r,o)}this._notifySubscribers()}_stopSpeaking;speech;speak(t){const e=this.adapters?.speech;if(!e)throw new Error("Speech adapter not configured");const{message:s}=this.repository.getMessage(t);this._stopSpeaking?.();const n=e.speak(Dt(s)),r=n.subscribe(()=>{n.status.type==="ended"?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:t,status:n.status},this._notifySubscribers()});this.speech={messageId:t,status:n.status},this._notifySubscribers(),this._stopSpeaking=()=>{n.cancel(),r(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw new Error("No message is being spoken");this._stopSpeaking(),this._notifySubscribers()}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=t=>(this._voiceVolumeSubscribers.add(t),()=>this._voiceVolumeSubscribers.delete(t));connectVoice(){const t=this.adapters?.voice;if(!t)throw new Error("Voice adapter not configured");this.disconnectVoice();const e=t.connect({});this._voiceSession=e;const s=[];let n="listening";this.voice={status:e.status,isMuted:e.isMuted,mode:n},this._voiceVolume=0,this._notifySubscribers(),s.push(e.onStatusChange(r=>{r.type==="ended"?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0):this.voice={status:r,isMuted:e.isMuted,mode:n},this._notifySubscribers()})),s.push(e.onModeChange(r=>{n=r,this.voice&&(this.voice={...this.voice,mode:r},this._notifySubscribers())})),s.push(e.onVolumeChange(r=>{this._voiceVolume=r;for(const o of this._voiceVolumeSubscribers)o()})),s.push(e.onTranscript(r=>{this._handleVoiceTranscript(r)})),this._voiceUnsubs=s}_currentAssistantMsg=null;_handleVoiceTranscript(t){if(this.ensureInitialized(),t.role==="user")this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,t.isFinal&&(this._voiceMessages.push({id:Qe(),role:"user",content:[{type:"text",text:t.text}],metadata:{custom:{}},createdAt:new Date,status:{type:"complete",reason:"unknown"},attachments:[]}),this._markVoiceMessagesDirty(),this._notifySubscribers());else{if(!this._currentAssistantMsg)this._currentAssistantMsg={id:Qe(),role:"assistant",content:[{type:"text",text:t.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},status:{type:"running"},createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{const e=this._voiceMessages.indexOf(this._currentAssistantMsg);if(e===-1)return;const s={...this._currentAssistantMsg,content:[{type:"text",text:t.text}],...t.isFinal?{status:{type:"complete",reason:"stop"}}:{}};this._voiceMessages[e]=s,this._currentAssistantMsg=s}t.isFinal&&(this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(){const t=this._voiceMessages.at(-1);if(t?.role==="assistant"&&t.status.type==="running"){const e=this._voiceMessages.length-1;this._voiceMessages[e]={...t,status:{type:"complete",reason:"stop"}},this._markVoiceMessagesDirty(),this._notifySubscribers()}}disconnectVoice(){this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null;for(const t of this._voiceUnsubs)t();this._voiceUnsubs=[],this._voiceSession?.disconnect(),this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;for(const t of this._voiceVolumeSubscribers)t();this._voiceMessages=[],this._markVoiceMessagesDirty(),this._notifySubscribers()}muteVoice(){if(!this._voiceSession)throw new Error("No active voice session");this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw new Error("No active voice session");this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers("initialize",{}))}export(){return this.repository.export()}import(t){this.ensureInitialized(),this.repository.clear(),this.repository.import(t),this._notifySubscribers()}reset(t){this.import(na.fromArray(t??[]))}_eventSubscribers=new Map;unstable_on(t,e){const s=e;if(t==="modelContextUpdate")return this._contextProvider.subscribe?.(()=>s({}))??(()=>{});let n=this._eventSubscribers.get(t);return n||(n=new Set,this._eventSubscribers.set(t,n)),n.add(s),t==="initialize"&&this._isInitialized&&queueMicrotask(()=>{n.has(s)&&s({})}),()=>{this._eventSubscribers.get(t)?.delete(s)}}},qr=class{cache=new WeakMap;convertMessages(t,e){return t.map((s,n)=>{const r=e(this.cache.get(s),s,n);return this.cache.set(s,r),r})}};const qt=t=>{try{return JSON.parse(t),!0}catch{return!1}},zr=t=>{try{return JSON.parse(t)}catch{return}},Wr=(t,e)=>{const s=zr(t),n=zr(e);return s===void 0||n===void 0?!1:Bn(s,n)};var Bh=class{_getTools;_callbacks;_entries=new Map;_skipExecuteStreamIds=new Set;_humanInput=new Map;_executing=new Set;_settledResolvers=[];_statuses=new Map;_ac=new AbortController;_pendingRestore=!0;_lastSnapshot=null;_isRunning=!1;_controller;_pipelineDead=!1;_pipelineRestartUsed=!1;constructor(t,e){this._getTools=t,this._callbacks=e,this._initPipeline()}_initPipeline(){const[t,e]=Tf();this._controller=e;const s=Hf(()=>this._getWrappedTools(),()=>this._ac.signal,(n,r)=>this._onHumanInput(n,r),{onExecutionStart:n=>this._onExecutionStart(n),onExecutionEnd:n=>this._onExecutionEnd(n)});t.pipeThrough(s).pipeThrough(new Fi).pipeTo(new WritableStream({write:n=>{try{if(n.type!=="result")return;this._handleResultChunk(n)}catch(r){console.error("[ToolInvocationTracker] result chunk handling failed",r)}}})).catch(n=>{console.error("[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState",n),this._pipelineDead=!0})}setState(t){try{if(this._pipelineDead){if(this._pipelineRestartUsed)return;this._pipelineRestartUsed=!0,this._pipelineDead=!1,this._demoteEntriesToRestored(),this._executing.clear(),this._ac=new AbortController,this._initPipeline()}if(this._lastSnapshot&&this._lastSnapshot.messages===t.messages&&this._lastSnapshot.isRunning===t.isRunning&&this._lastSnapshot.isLoading===t.isLoading)return;t.isLoading===!0&&(this._pendingRestore=!0);const e=this._isRunning;this._isRunning=t.isRunning;try{this._processMessages(t.messages)}catch(s){throw this._isRunning=e,s}this._lastSnapshot=t,this._pendingRestore=!1}catch(e){console.error("[ToolInvocationTracker] setState failed; snapshot dropped",e)}}reset(){try{this._pendingRestore=!0,this._entries.clear(),this._lastSnapshot=null,this.abort().finally(()=>{this._executing.clear()})}catch(t){console.error("[ToolInvocationTracker] reset failed",t)}}abort(){try{return this._humanInput.forEach(({reject:t})=>{try{t(new Error("Tool execution aborted"))}catch{}}),this._humanInput.clear(),this._ac.abort(),this._ac=new AbortController,this._executing.size===0?Promise.resolve():new Promise(t=>{this._settledResolvers.push(t)})}catch(t){return console.error("[ToolInvocationTracker] abort failed",t),Promise.resolve()}}resume(t,e){try{const s=this._humanInput.get(t);return s?(this._humanInput.delete(t),this._setStatus(t,{type:"executing"}),s.resolve(e),!0):!1}catch(s){return console.error("[ToolInvocationTracker] resume failed",s),!1}}getStatuses(){return this._statuses}_getWrappedTools(){const t=this._getTools();if(t)return Object.fromEntries(Object.entries(t).map(([e,s])=>{const n=s.execute;return n===void 0?[e,s]:[e,{...s,execute:(...[r,o])=>this._skipExecuteStreamIds.has(o.toolCallId)?new Promise(()=>{}):n(r,o)}]}))}_onHumanInput(t,e){return new Promise((s,n)=>{const r=this._humanInput.get(t);if(r)try{r.reject(new Error("Human input request was superseded by a new request"))}catch{}this._humanInput.set(t,{resolve:s,reject:n}),this._setStatus(t,{type:"interrupt",payload:{type:"human",payload:e}})})}_onExecutionStart(t){this._skipExecuteStreamIds.has(t)||(this._executing.add(t),this._setStatus(t,{type:"executing"}))}_onExecutionEnd(t){this._executing.delete(t)&&(this._deleteStatus(t),this._executing.size===0&&this._settledResolvers.splice(0).forEach(e=>{try{e()}catch{}}))}_handleResultChunk(t){const e=t.meta.toolCallId,s=this._entries.get(e);!s&&this._skipExecuteStreamIds.has(e)||s?.hasResult||this._invokeOnResult({type:"add-tool-result",toolCallId:e,toolName:t.meta.toolName,result:t.result,isError:t.isError,...t.artifact!==void 0&&{artifact:t.artifact},...t.modelContent!==void 0&&{modelContent:t.modelContent}})}_invokeOnResult(t){try{this._callbacks.onResult(t)}catch(e){console.error("[ToolInvocationTracker] onResult callback threw; result dropped",e)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(t){console.error("[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated",t)}}_setStatus(t,e){const s=new Map(this._statuses);s.set(t,e),this._statuses=s,this._invokeOnStatusesChange()}_deleteStatus(t){if(!this._statuses.has(t))return;const e=new Map(this._statuses);e.delete(t),this._statuses=e,this._invokeOnStatusesChange()}_hasExecutableTool(t){const e=this._getTools()?.[t];return e?.execute!==void 0||e?.streamCall!==void 0}_shouldCloseArgsStream({toolName:t,argsText:e,hasResult:s}){return s?!0:(this._hasExecutableTool(t)||!this._isRunning)&&qt(e)}_startActiveEntry(t,e,s){const n=this._controller.addToolCallPart({toolName:e,toolCallId:t});s&&this._skipExecuteStreamIds.add(t);const r={toolName:e,controller:n,argsText:"",hasResult:!1,argsComplete:!1};return this._entries.set(t,r),r}_demoteEntriesToRestored(){for(const[t,e]of this._entries)e.controller&&this._entries.set(t,{toolName:e.toolName,argsText:e.argsText,hasResult:e.hasResult})}_processArgsText(t,e){if(!t.controller)return;const s=e.result!==void 0;if(e.argsText!==t.argsText){let n=!0;if(t.argsComplete)Wr(t.argsText,e.argsText)&&(t.argsText=e.argsText),n=!1;else if(!e.argsText.startsWith(t.argsText))if(qt(t.argsText)&&qt(e.argsText)&&Wr(t.argsText,e.argsText)){const r=this._shouldCloseArgsStream({toolName:e.toolName,argsText:e.argsText,hasResult:s});r&&t.controller.argsText.close(),t.argsText=e.argsText,t.argsComplete=r,n=!1}else n=!1;if(n&&t.controller){const r=e.argsText.slice(t.argsText.length);t.controller.argsText.append(r);const o=this._shouldCloseArgsStream({toolName:e.toolName,argsText:e.argsText,hasResult:s});o&&t.controller.argsText.close(),t.argsText=e.argsText,t.argsComplete=o}}!t.argsComplete&&t.controller&&this._shouldCloseArgsStream({toolName:e.toolName,argsText:e.argsText,hasResult:s})&&(t.controller.argsText.close(),t.argsText=e.argsText,t.argsComplete=!0)}_processMessages(t){const e=this._pendingRestore;for(const s of t)if(!(!s||!Array.isArray(s.content)))for(const n of s.content){if(!n||n.type!=="tool-call")continue;const r=this._entries.get(n.toolCallId);if(e){r?.controller||this._entries.set(n.toolCallId,{toolName:n.toolName,argsText:n.argsText,hasResult:n.result!==void 0}),n.messages&&this._processMessages(n.messages);continue}let o=r;if(o&&!o.controller){if(!(n.argsText!==o.argsText||n.result!==void 0!==o.hasResult)){n.messages&&this._processMessages(n.messages);continue}this._entries.delete(n.toolCallId),o=void 0}if(o||(o=this._startActiveEntry(n.toolCallId,n.toolName,n.result!==void 0)),this._processArgsText(o,n),n.result!==void 0&&!o.hasResult){const{controller:i}=o;if(!i)continue;o.hasResult=!0,o.argsComplete=!0,i.setResponse(new Pe({result:n.result,artifact:n.artifact,isError:n.isError,...n.modelContent!==void 0?{modelContent:n.modelContent}:{}})),i.close()}n.messages&&this._processMessages(n.messages)}}};const Fh=Object.freeze([]),Gr=(t,e)=>{const s=Object.keys(t);if(s.length!==Object.keys(e).length)return!1;for(const n of s)if(t[n]!==e[n])return!1;return!0},Uh=(t,e)=>t&&e[e.length-1]?.role!=="assistant";var Vh=class extends jh{_capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};get capabilities(){return this._capabilities}_messages;isDisabled;isSendDisabled;get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}suggestions=[];extras=void 0;_converter=new qr;_store;_toolInvocations=null;beginEdit(t){if(!this._store.onEdit)throw new Error("Runtime does not support editing.");super.beginEdit(t)}constructor(t,e){super(t),this.__internal_setAdapter(e)}__internal_setAdapter(t){if(this._store===t)return;const e=t.isRunning??!1;this.isDisabled=t.isDisabled??!1,this.isSendDisabled=t.isSendDisabled??!1;const s=this._store;this._store=t,this.extras!==t.extras&&(this.extras=t.extras);const n=t.suggestions??Fh;Gr(this.suggestions,n)||(this.suggestions=n);const r={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,delete:this._store.onDelete!==void 0||this._store.setMessages!==void 0,reload:this._store.onReload!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:this._store.queue!==void 0};Gr(this._capabilities,r)||(this._capabilities=r);let o;if(t.messageRepository){if(s&&s.isRunning===t.isRunning&&s.messageRepository===t.messageRepository){this._notifySubscribers();return}const a=t.messageRepository.messages,c=t.messageRepository.headId??a.at(-1)?.message.id??null;if(s&&s.messageRepository===t.messageRepository)this.repository.resetHead(c),o=this.repository.getMessages();else{const l=new Set(a.map(({message:u})=>u.id));for(const{message:u,parentId:d}of a)this.repository.addOrUpdateMessage(d,u);for(const{message:u}of this.repository.export().messages)l.has(u.id)||this.repository.deleteMessage(u.id);this.repository.resetHead(c),o=this.repository.getMessages()}}else if(t.messages){if(s){if(s.convertMessage!==t.convertMessage)this._converter=new qr;else if(s.isRunning===t.isRunning&&s.messages===t.messages){this._notifySubscribers();return}}o=t.convertMessage?this._converter.convertMessages(t.messages,(a,c,l)=>{if(!t.convertMessage)return c;const u=hs(l===(t.messages?.length??0)-1,e,!1,!1,void 0);if(a&&(a.role!=="assistant"||!Dh(a.status)||a.status===u))return a;const d=fs(t.convertMessage(c,l),l.toString(),u);return sh(d,c),d}):t.messages;for(let a=0;a<o.length;a++){const c=o[a],l=o[a-1];this.repository.addOrUpdateMessage(l?.id??null,c)}}else throw new Error("ExternalStoreAdapter must provide either 'messages' or 'messageRepository'");o.length>0&&this.ensureInitialized(),(s?.isRunning??!1)!==(t.isRunning??!1)&&(t.isRunning?this._notifyEventSubscribers("runStart",{}):this._notifyEventSubscribers("runEnd",{}));let i=null;Uh(e,o)&&(i=Qe(),this.repository.addOrUpdateMessage(o.at(-1)?.id??null,fs({role:"assistant",content:[],metadata:{isOptimistic:!0}},i,{type:"running"}))),this.repository.resetHead(i??o.at(-1)?.id??null),this._messages=this.repository.getMessages(),this._driveToolInvocations(),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._store.setToolStatuses?.({}));return}this._toolInvocations||(this._toolInvocations=new Bh(()=>this.getModelContext().tools,{onResult:t=>{try{const e=this._findMessageIdForToolCall(t.toolCallId);if(e===void 0)return;this._store.onAddToolResult?.({messageId:e,toolCallId:t.toolCallId,toolName:t.toolName,result:t.result,isError:t.isError,...t.artifact!==void 0&&{artifact:t.artifact},...t.modelContent!==void 0&&{modelContent:t.modelContent}})}catch(e){console.error("[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed",e)}},onStatusesChange:t=>{this._store.setToolStatuses?.(Object.fromEntries(t))}})),this._toolInvocations.setState({messages:this._messages,isRunning:this._store.isRunning??!1,...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_toolCallToMessageId=new Map;_messagesForToolCallIndex=null;_findMessageIdForToolCall(t){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();const e=s=>{for(const n of s)if(Array.isArray(n.content))for(const r of n.content)!r||r.type!=="tool-call"||(this._toolCallToMessageId.set(r.toolCallId,n.id),r.messages&&e(r.messages))};e(this._messages),this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(t)}switchToBranch(t){if(!this._store.setMessages)throw new Error("Runtime does not support switching branches.");if(this._store.isRunning)return;const e=this._store.unstable_onBranchChange,s=e?this.repository.canonicalHeadId:null;this.repository.switchToBranch(t),this.updateMessages(this.repository.getMessages()),e&&this._notifyBranchChange(s,e)}_notifyBranchChange(t,e){const s=this.repository.canonicalHeadId;s!==t&&e({headId:s,visibleMessageIds:this.repository.getMessages().map(n=>n.id)})}async append(t){const e=t.parentId!==(this.messages.at(-1)?.id??null);if(!e&&this._store.queue){this._store.queue.enqueue(t,{steer:t.steer??!1});return}if((t.startRun??t.role==="user")&&await this._toolInvocations?.abort(),e){if(!this._store.onEdit)throw new Error("Runtime does not support editing messages.");this._store.queue?.clear("edit"),await this._store.onEdit(t)}else await this._store.onNew(t)}async deleteMessage(t){if(this._store.onDelete){await this._store.onDelete(t);return}if(!this._store.setMessages)throw new Error("Runtime does not support deleting messages.");this._store.isRunning&&await this._toolInvocations?.abort();const e=this.repository.getMessages();if(e.findIndex(s=>s.id===t)===-1)throw new Error("Message not found.");this.updateMessages(e.filter(s=>s.id!==t))}getQueueItems(){return this._store?.queue?.items??zn}steerQueueItem(t){this._store?.queue?.steer(t)}removeQueueItem(t){this._store?.queue?.remove(t)}async startRun(t){if(!this._store.onReload)throw new Error("Runtime does not support reloading messages.");this._store.queue?.clear("reload"),await this._toolInvocations?.abort(),await this._store.onReload(t.parentId,t)}async resumeRun(t){if(!this._store.onResume)throw new Error("Runtime does not support resuming runs.");await this._store.onResume(t)}exportExternalState(){if(!this._store.onExportExternalState)throw new Error("Runtime does not support exporting external states.");return this._store.onExportExternalState()}importExternalState(t){if(!this._store.onLoadExternalState)throw new Error("Runtime does not support importing external states.");this._toolInvocations&&(this._toolInvocations.reset(),this._store.setToolStatuses?.({})),this._store.onLoadExternalState(t)}cancelRun(){if(!this._store.onCancel)throw new Error("Runtime does not support cancelling runs.");this._store.queue?.clear("cancel-run"),this._toolInvocations?.abort(),this._store.onCancel();const t=this.repository.getMessages().at(-1);t&&t.metadata.isOptimistic&&t.content.length===0&&this.repository.deleteMessage(t.id);let e=this.repository.getMessages();const s=e[e.length-1];s?.role==="user"&&s.id===e.at(-1)?.id?(this.repository.deleteMessage(s.id),this.composer.text.trim()||this.composer.setText(Dt(s)),e=this.repository.getMessages()):this._notifySubscribers(),setTimeout(()=>{this.updateMessages(e)},0)}addToolResult(t){if(!this._store.onAddToolResult)throw new Error("Runtime does not support tool results.");this._store.onAddToolResult?.(t)}resumeToolCall(t){if(!(this._toolInvocations?.resume(t.toolCallId,t.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(t);return}throw new Error(`Tool call ${t.toolCallId} is not waiting for resume.`)}}respondToToolApproval(t){if(!this._store.onRespondToToolApproval)throw new Error("Runtime does not support tool approvals.");this._store.onRespondToToolApproval(t)}reset(t){const e=new qn;e.import(na.fromArray(t??[])),this.updateMessages(e.getMessages())}import(t){super.import(t),this._store.onImport&&this._store.onImport(this.repository.getMessages())}updateMessages=t=>{this._store.convertMessage!==void 0?this._store.setMessages?.(t.flatMap(nh)):this._store.setMessages?.(t)}};const Kr=t=>t.adapters?.threadList??{};var Hh=class extends sa{threads;constructor(t){super(),this.threads=new Ih(Kr(t),()=>new Vh(this._contextProvider,t))}setAdapter(t){this.threads.__internal_setAdapter(Kr(t)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(t)}};const F1=t=>{const e=T(11);let s;e[0]!==t?(s=()=>new Hh(t),e[0]=t,e[1]=s):s=e[1];const[n]=ee(s);let r;e[2]!==n||e[3]!==t?(r=()=>{n.setAdapter(t)},e[2]=n,e[3]=t,e[4]=r):r=e[4],q(r);const{modelContext:o}=Sh()??{};let i,a;e[5]!==o||e[6]!==n?(i=()=>{if(o)return n.registerModelContextProvider(o)},a=[o,n],e[5]=o,e[6]=n,e[7]=i,e[8]=a):(i=e[7],a=e[8]),q(i,a);let c;return e[9]!==n?(c=new ta(n),e[9]=n,e[10]=c):c=e[10],c},qh=t=>{const e=T(10),{id:s,children:n}=t;let r;e[0]!==s?(r=he({source:"thread",query:{type:"id",id:s},get:l=>l.thread().message({id:s})}),e[0]=s,e[1]=r):r=e[1];let o;e[2]!==s?(o=he({source:"message",query:{},get:l=>l.thread().message({id:s}).composer()}),e[2]=s,e[3]=o):o=e[3];let i;e[4]!==r||e[5]!==o?(i={message:r,composer:o},e[4]=r,e[5]=o,e[6]=i):i=e[6];const a=H(i);let c;return e[7]!==a||e[8]!==n?(c=v.jsx(pe,{value:a,children:n}),e[7]=a,e[8]=n,e[9]=c):c=e[9],c},Wn=(t,e)=>t.Message===e.Message&&t.EditComposer===e.EditComposer&&t.UserEditComposer===e.UserEditComposer&&t.AssistantEditComposer===e.AssistantEditComposer&&t.SystemEditComposer===e.SystemEditComposer&&t.UserMessage===e.UserMessage&&t.AssistantMessage===e.AssistantMessage&&t.SystemMessage===e.SystemMessage,zh=()=>null,Yr=new WeakMap,Wh=(t,e)=>{let s=Yr.get(t);return s||(s=new Set(t.map(n=>n.id)),Yr.set(t,s)),s.has(e)},Gh=(t,e,s)=>{switch(e){case"user":return s?t.UserEditComposer??t.EditComposer??t.UserMessage??t.Message:t.UserMessage??t.Message;case"assistant":return s?t.AssistantEditComposer??t.EditComposer??t.AssistantMessage??t.Message:t.AssistantMessage??t.Message;case"system":return s?t.SystemEditComposer??t.EditComposer??t.SystemMessage??t.Message:t.SystemMessage??t.Message??zh;default:throw new Error(`Unknown message role: ${e}`)}},Gn=t=>{const e=T(6),{components:s}=t,n=D(Yh),r=D(Qh);let o;e[0]!==s||e[1]!==r||e[2]!==n?(o=Gh(s,n,r),e[0]=s,e[1]=r,e[2]=n,e[3]=o):o=e[3];const i=o;let a;return e[4]!==i?(a=v.jsx(i,{}),e[4]=i,e[5]=a):a=e[5],a},ia=b.memo(t=>{const e=T(5),{index:s,components:n}=t;let r;e[0]!==n?(r=v.jsx(Gn,{components:n}),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=v.jsx(Wi,{index:s,children:r}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o},(t,e)=>t.index===e.index&&Wn(t.components,e.components));ia.displayName="ThreadPrimitive.MessageByIndex";const aa=b.memo(t=>{const e=T(7),{messageId:s,components:n}=t;let r;if(e[0]!==s?(r=a=>Wh(a.thread.messages,s),e[0]=s,e[1]=r):r=e[1],!D(r))return null;let o;e[2]!==n?(o=v.jsx(Gn,{components:n}),e[2]=n,e[3]=o):o=e[3];let i;return e[4]!==s||e[5]!==o?(i=v.jsx(qh,{id:s,children:o}),e[4]=s,e[5]=o,e[6]=i):i=e[6],i},(t,e)=>t.messageId===e.messageId&&Wn(t.components,e.components));aa.displayName="ThreadPrimitive.Unstable_MessageById";const Qr=({children:t})=>{const e=D(s=>s.thread.messages.length);return te(()=>e===0?null:Array.from({length:e},(s,n)=>v.jsx(Wi,{index:n,children:v.jsx(et,{getItemState:r=>r.thread().message({index:n}).getState(),children:r=>t({get message(){return r()}})})},n)),[e,t])},ca=t=>{const e=T(4),{components:s,children:n}=t;if(s){let o;return e[0]!==s?(o=v.jsx(Qr,{children:()=>v.jsx(Gn,{components:s})}),e[0]=s,e[1]=o):o=e[1],o}let r;return e[2]!==n?(r=v.jsx(Qr,{children:n}),e[2]=n,e[3]=r):r=e[3],r};ca.displayName="ThreadPrimitive.Messages";const Kh=b.memo(ca,(t,e)=>t.children||e.children?t.children===e.children:Wn(t.components,e.components));function Yh(t){return t.message.role}function Qh(t){return t.message.composer.isEditing}const la=t=>{const e=t.message.metadata;if(!(!e||typeof e!="object"))return e.custom?.quote};var Jh=class extends Error{componentName;constructor(t,e=`Component "${t}" is not in the generative-ui allowlist.`){super(e),this.name="GenerativeUIRenderError",this.componentName=t}};const Xh=t=>typeof t=="object"&&t!==null,ua=(t,e,s,n)=>{if(t==null)return null;if(typeof t=="string")return t;if(!Xh(t)||!("component"in t)||typeof t.component!="string")return null;const{component:r,props:o,children:i,key:a}=t,c=e[r];if(!c){if(s)return v.jsx(s,{component:r,props:o},a??n);throw new Jh(r)}const l=i?.length?i.map((u,d)=>ua(u,e,s,`${n}/${d}`)):void 0;return b.createElement(c,{...o??{},key:a??n},...l??[])},Zh=t=>{if(!t||t.root===void 0||t.root===null)return[];const e=t.root;return Array.isArray(e)?e:[e]},Kn=t=>{const e=T(11),{spec:s,components:n,Fallback:r}=t;let o;e[0]!==s?(o=Zh(s),e[0]=s,e[1]=o):o=e[1];const i=o;let a;if(e[2]!==r||e[3]!==n||e[4]!==i){let l;e[6]!==r||e[7]!==n?(l=(u,d)=>ua(u,n,r,`${d}`),e[6]=r,e[7]=n,e[8]=l):l=e[8],a=i.map(l),e[2]=r,e[3]=n,e[4]=i,e[5]=a}else a=e[5];let c;return e[9]!==a?(c=v.jsx(v.Fragment,{children:a}),e[9]=a,e[10]=c):c=e[10],c};Kn.displayName="GenerativeUIRender";const da=t=>{const e=T(4),{components:s,spec:n,Fallback:r}=t,o=D(em),i=n??o;if(!i)return null;let a;return e[0]!==r||e[1]!==s||e[2]!==i?(a=v.jsx(Kn,{spec:i,components:s,Fallback:r}),e[0]=r,e[1]=s,e[2]=i,e[3]=a):a=e[3],a};da.displayName="MessagePrimitive.GenerativeUI";function em(t){const e=t.part;return e?.type==="generative-ui"?e.spec:void 0}const tm="ui://",fa=t=>!!t?.startsWith(tm),Jr=t=>Symbol.iterator in t,Xr=t=>"entries"in t,Zr=(t,e)=>{const s=t instanceof Map?t:new Map(t.entries()),n=e instanceof Map?e:new Map(e.entries());if(s.size!==n.size)return!1;for(const[r,o]of s)if(!n.has(r)||!Object.is(o,n.get(r)))return!1;return!0},sm=(t,e)=>{const s=t[Symbol.iterator](),n=e[Symbol.iterator]();let r=s.next(),o=n.next();for(;!r.done&&!o.done;){if(!Object.is(r.value,o.value))return!1;r=s.next(),o=n.next()}return!!r.done&&!!o.done};function nm(t,e){return Object.is(t,e)?!0:typeof t!="object"||t===null||typeof e!="object"||e===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e)?!1:Jr(t)&&Jr(e)?Xr(t)&&Xr(e)?Zr(t,e):sm(t,e):Zr({entries:()=>Object.entries(t)},{entries:()=>Object.entries(e)})}function gn(t){const e=ne.useRef(void 0);return s=>{const n=t(s);return nm(e.current,n)?e.current:e.current=n}}const Ws=t=>{let e=-1;return{startGroup:s=>{e===-1&&(e=s)},endGroup:(s,n)=>{e!==-1&&(n.push({type:t,startIndex:e,endIndex:s}),e=-1)},finalize:(s,n)=>{e!==-1&&n.push({type:t,startIndex:e,endIndex:s})}}},rm=(t,e,s)=>{const n=[];if(e){const r=Ws("chainOfThoughtGroup");for(let o=0;o<t.length;o++){const i=t[o];i==="tool-call"||i==="reasoning"?r.startGroup(o):(r.endGroup(o-1,n),n.push({type:"single",index:o}))}r.finalize(t.length-1,n)}else{const r=Ws("toolGroup"),o=Ws("reasoningGroup");for(let i=0;i<t.length;i++){const a=t[i];a==="tool-call"?(o.endGroup(i-1,n),r.startGroup(i)):a==="reasoning"?(r.endGroup(i-1,n),o.startGroup(i)):(r.endGroup(i-1,n),o.endGroup(i-1,n),n.push({type:"single",index:i}))}r.finalize(t.length-1,n),o.finalize(t.length-1,n)}if(s){const r=new Set;for(const o of n){if(o.type==="single")continue;const i=s[o.startIndex];i!==void 0&&!r.has(i)&&(r.add(i),o.idKey=`id:${i}`)}}return n},om=t=>{const e=T(10),s=D(gn(xm)),n=D(gn(Cm));let r;e:{if(s.length===0){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=[],e[0]=a):a=e[0];let c;e[1]!==n?(c={ranges:a,partIds:n},e[1]=n,e[2]=c):c=e[2],r=c;break e}let o;e[3]!==s||e[4]!==n||e[5]!==t?(o=rm(s,t,n),e[3]=s,e[4]=n,e[5]=t,e[6]=o):o=e[6];let i;e[7]!==n||e[8]!==o?(i={ranges:o,partIds:n},e[7]=n,e[8]=o,e[9]=i):i=e[9],r=i}return r},im=t=>{const e=T(9);let s,n;e[0]!==t?({Fallback:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let r;e[3]!==s||e[4]!==n.toolName?(r=a=>a.tools.toolUIs[n.toolName]?.[0]?.render??s,e[3]=s,e[4]=n.toolName,e[5]=r):r=e[5];const o=D(r);if(!o)return null;let i;return e[6]!==o||e[7]!==n?(i=v.jsx(o,{...n}),e[6]=o,e[7]=n,e[8]=i):i=e[8],i},Yn=(t,e,s)=>{const n=t.renderers[e]?.[0];return n||(t.fallbacks[0]??s)},am=t=>{const e=T(9);let s,n;e[0]!==t?({Fallback:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let r;e[3]!==s||e[4]!==n.name?(r=a=>Yn(a.dataRenderers,n.name,s),e[3]=s,e[4]=n.name,e[5]=r):r=e[5];const o=D(r);if(!o)return null;let i;return e[6]!==o||e[7]!==n?(i=v.jsx(o,{...n}),e[6]=o,e[7]=n,e[8]=i):i=e[8],i},oe={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:t})=>t,ReasoningGroup:({children:t})=>t},cm=t=>{const e=T(47),{components:s}=t;let n;e[0]!==s?(n=s===void 0?{}:s,e[0]=s,e[1]=n):n=e[1];const{Text:r,Reasoning:o,Image:i,Source:a,File:c,Unstable_Audio:l,tools:u,data:d,generativeUI:f}=n,h=r===void 0?oe.Text:r,m=o===void 0?oe.Reasoning:o,p=i===void 0?oe.Image:i,g=a===void 0?oe.Source:a,_=c===void 0?oe.File:c,C=l===void 0?oe.Unstable_Audio:l;let S;e[2]!==u?(S=u===void 0?{}:u,e[2]=u,e[3]=S):S=e[3];const y=S,x=H(),E=D(Tm),I=E.type;if(I==="tool-call"){let R;e[4]!==x?(R=x.part(),e[4]=x,e[5]=R):R=e[5];const P=R.addToolResult;let k;e[6]!==x?(k=x.part(),e[6]=x,e[7]=k):k=e[7];const O=k.resumeToolCall;let $;e[8]!==x?($=x.part(),e[8]=x,e[9]=$):$=e[9];const M=$.respondToToolApproval;if("Override"in y){let V;return e[10]!==P||e[11]!==E||e[12]!==M||e[13]!==O||e[14]!==y.Override?(V=v.jsx(y.Override,{...E,addResult:P,resume:O,respondToApproval:M}),e[10]=P,e[11]=E,e[12]=M,e[13]=O,e[14]=y.Override,e[15]=V):V=e[15],V}const B=y.by_name?.[E.toolName]??y.Fallback;let U;return e[16]!==B||e[17]!==P||e[18]!==E||e[19]!==M||e[20]!==O?(U=v.jsx(im,{...E,Fallback:B,addResult:P,resume:O,respondToApproval:M}),e[16]=B,e[17]=P,e[18]=E,e[19]=M,e[20]=O,e[21]=U):U=e[21],U}if(E.status?.type==="requires-action")throw new Error("Encountered unexpected requires-action status");switch(I){case"text":{let R;return e[22]!==h||e[23]!==E?(R=v.jsx(h,{...E}),e[22]=h,e[23]=E,e[24]=R):R=e[24],R}case"reasoning":{let R;return e[25]!==m||e[26]!==E?(R=v.jsx(m,{...E}),e[25]=m,e[26]=E,e[27]=R):R=e[27],R}case"source":{let R;return e[28]!==g||e[29]!==E?(R=v.jsx(g,{...E}),e[28]=g,e[29]=E,e[30]=R):R=e[30],R}case"image":{let R;return e[31]!==p||e[32]!==E?(R=v.jsx(p,{...E}),e[31]=p,e[32]=E,e[33]=R):R=e[33],R}case"file":{let R;return e[34]!==_||e[35]!==E?(R=v.jsx(_,{...E}),e[34]=_,e[35]=E,e[36]=R):R=e[36],R}case"audio":{let R;return e[37]!==C||e[38]!==E?(R=v.jsx(C,{...E}),e[37]=C,e[38]=E,e[39]=R):R=e[39],R}case"data":{const R=d?.by_name?.[E.name]??d?.Fallback;let P;return e[40]!==R||e[41]!==E?(P=v.jsx(am,{...E,Fallback:R}),e[40]=R,e[41]=E,e[42]=P):P=e[42],P}case"generative-ui":{if(!f?.components)return null;const R=E;let P;return e[43]!==f.Fallback||e[44]!==f.components||e[45]!==R.spec?(P=v.jsx(Kn,{spec:R.spec,components:f.components,Fallback:f.Fallback}),e[43]=f.Fallback,e[44]=f.components,e[45]=R.spec,e[46]=P):P=e[46],P}default:return console.warn(`Unknown message part type: ${I}`),null}},At=b.memo(t=>{const e=T(5),{index:s,components:n}=t;let r;e[0]!==n?(r=v.jsx(cm,{components:n}),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=v.jsx(Un,{index:s,children:r}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o},(t,e)=>t.index===e.index&&t.components?.Text===e.components?.Text&&t.components?.Reasoning===e.components?.Reasoning&&t.components?.Source===e.components?.Source&&t.components?.Image===e.components?.Image&&t.components?.File===e.components?.File&&t.components?.Unstable_Audio===e.components?.Unstable_Audio&&t.components?.tools===e.components?.tools&&t.components?.data===e.components?.data&&t.components?.generativeUI===e.components?.generativeUI&&t.components?.ToolGroup===e.components?.ToolGroup&&t.components?.ReasoningGroup===e.components?.ReasoningGroup);At.displayName="MessagePrimitive.PartByIndex";const lm=t=>{const e=T(6),{status:s,component:n}=t,r=s.type==="running";let o;e[0]!==n||e[1]!==s?(o=v.jsx(n,{type:"text",text:"",status:s}),e[0]=n,e[1]=s,e[2]=o):o=e[2];let i;return e[3]!==r||e[4]!==o?(i=v.jsx(Vn,{text:"",isRunning:r,children:o}),e[3]=r,e[4]=o,e[5]=i):i=e[5],i},um=Object.freeze({type:"complete"}),dm=Object.freeze({type:"running"}),fm=t=>{const e=T(6),{components:s}=t,n=D(Em);if(s?.Empty){let i;return e[0]!==s.Empty||e[1]!==n?(i=v.jsx(s.Empty,{status:n}),e[0]=s.Empty,e[1]=n,e[2]=i):i=e[2],i}if(n.type!=="running")return null;const r=s?.Text??oe.Text;let o;return e[3]!==n||e[4]!==r?(o=v.jsx(lm,{status:n,component:r}),e[3]=n,e[4]=r,e[5]=o):o=e[5],o},ha=b.memo(fm,(t,e)=>t.components?.Empty===e.components?.Empty&&t.components?.Text===e.components?.Text),hm=t=>{const e=T(4),{components:s,enabled:n}=t;let r;if(e[0]!==n?(r=i=>{if(!n||i.message.parts.length===0)return!1;const a=i.message.parts[i.message.parts.length-1];return a?.type!=="text"&&a?.type!=="reasoning"},e[0]=n,e[1]=r):r=e[1],!D(r))return null;let o;return e[2]!==s?(o=v.jsx(ha,{components:s}),e[2]=s,e[3]=o):o=e[3],o},mm=b.memo(hm,(t,e)=>t.enabled===e.enabled&&t.components?.Empty===e.components?.Empty&&t.components?.Text===e.components?.Text),pm=t=>{const e=T(4),{Quote:s}=t,n=D(la);if(!n)return null;let r;return e[0]!==s||e[1]!==n.messageId||e[2]!==n.text?(r=v.jsx(s,{text:n.text,messageId:n.messageId}),e[0]=s,e[1]=n.messageId,e[2]=n.text,e[3]=r):r=e[3],r},gm=b.memo(pm);function ma(t,e){const s=t.toolUIs[e.toolName]?.[0]?.render??null;return s||(fa(e.mcp?.app?.resourceUri)&&t.mcpApp?t.mcpApp.render:null)}const pa=()=>{const t=T(12),e=H(),s=D(Im),n=D(Rm);if(!n||s.type!=="tool-call")return null;let r;t[0]!==e?(r=e.part(),t[0]=e,t[1]=r):r=t[1];const o=r.addToolResult;let i;t[2]!==e?(i=e.part(),t[2]=e,t[3]=i):i=t[3];const a=i.resumeToolCall;let c;t[4]!==e?(c=e.part(),t[4]=e,t[5]=c):c=t[5];let l;return t[6]!==n||t[7]!==s||t[8]!==r.addToolResult||t[9]!==i.resumeToolCall||t[10]!==c.respondToToolApproval?(l=v.jsx(n,{...s,addResult:o,resume:a,respondToApproval:c.respondToToolApproval}),t[6]=n,t[7]=s,t[8]=r.addToolResult,t[9]=i.resumeToolCall,t[10]=c.respondToToolApproval,t[11]=l):l=t[11],l},ga=()=>{const t=T(3),e=D(Am),s=D(Pm);if(!s||e.type!=="data")return null;const n=e;let r;return t[0]!==s||t[1]!==n?(r=v.jsx(s,{...n}),t[0]=s,t[1]=n,t[2]=r):r=t[2],r},vm=()=>{const t=T(2),e=D(Mm);if(e==="tool-call"){let s;return t[0]===Symbol.for("react.memo_cache_sentinel")?(s=v.jsx(pa,{}),t[0]=s):s=t[0],s}if(e==="data"){let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=v.jsx(ga,{}),t[1]=s):s=t[1],s}return null},bm=Object.freeze({type:"text",text:"",status:dm}),va=({index:t,children:e})=>{const s=H(),n=D(r=>r.dataRenderers);return v.jsx(Un,{index:t,children:v.jsx(et,{getItemState:r=>r.message().part({index:t}).getState(),children:r=>e({get part(){const o=r();if(o.type==="tool-call"){const i=ma(s.tools().getState(),o)!==null,a=s.message().part({index:t});return{...o,toolUI:i?v.jsx(pa,{}):null,addResult:a.addToolResult,resume:a.resumeToolCall,respondToApproval:a.respondToToolApproval}}if(o.type==="data"){const i=Yn(n,o.name,void 0)!==void 0;return{...o,dataRendererUI:i?v.jsx(ga,{}):null}}return o}})})})},ym=t=>{const e=T(9),{children:s}=t,n=D(Dm),r=D(Om),o=n===0&&r;if(n===0){if(!o)return null;let a;e[0]!==s?(a=s({part:bm}),e[0]=s,e[1]=a):a=e[1];let c;return e[2]!==a?(c=v.jsx(Vn,{text:"",isRunning:!0,children:a}),e[2]=a,e[3]=c):c=e[3],c}let i;if(e[4]!==s||e[5]!==n){let a;e[7]!==s?(a=(c,l)=>v.jsx(va,{index:l,children:u=>s(u)??v.jsx(vm,{})},l),e[7]=s,e[8]=a):a=e[8],i=v.jsx(v.Fragment,{children:Array.from({length:n},a)}),e[4]=s,e[5]=n,e[6]=i}else i=e[6];return i},vn=t=>{const e=T(5),{components:s,unstable_showEmptyOnNonTextEnd:n,children:r}=t,o=n===void 0?!0:n;if(r){let a;return e[0]!==r?(a=v.jsx(ym,{children:r}),e[0]=r,e[1]=a):a=e[1],a}let i;return e[2]!==s||e[3]!==o?(i=v.jsx(_m,{components:s,unstable_showEmptyOnNonTextEnd:o}),e[2]=s,e[3]=o,e[4]=i):i=e[4],i};vn.displayName="MessagePrimitive.Parts";const _m=t=>{const e=T(15),{components:s,unstable_showEmptyOnNonTextEnd:n}=t,r=D(km),o=!!s?.ChainOfThought,{ranges:i,partIds:a}=om(o);let c;e:{if(r===0){let m;e[0]!==s?(m=v.jsx(ha,{components:s}),e[0]=s,e[1]=m):m=e[1],c=m;break e}let h;if(e[2]!==s||e[3]!==i||e[4]!==a){const m=new Set,p=g=>{const _=a[g];return _!==void 0&&!m.has(_)?(m.add(_),`part-id:${_}`):`part-${g}`};h=i.map(g=>{if(g.type==="single")return v.jsx(At,{index:g.index,components:s},g.index);if(g.type==="chainOfThoughtGroup"){const _=s?.ChainOfThought;return _?v.jsx(Xf,{startIndex:g.startIndex,endIndex:g.endIndex,children:v.jsx(_,{})},`chainOfThought-${g.idKey??g.startIndex}`):null}else return g.type==="toolGroup"?v.jsx(s?.ToolGroup??oe.ToolGroup,{startIndex:g.startIndex,endIndex:g.endIndex,children:Array.from({length:g.endIndex-g.startIndex+1},(_,C)=>{const S=g.startIndex+C;return v.jsx(At,{index:S,components:s},p(S))})},`tool-${g.idKey??g.startIndex}`):v.jsx(s?.ReasoningGroup??oe.ReasoningGroup,{startIndex:g.startIndex,endIndex:g.endIndex,children:Array.from({length:g.endIndex-g.startIndex+1},(_,C)=>{const S=g.startIndex+C;return v.jsx(At,{index:S,components:s},`part-${S}`)})},`reasoning-${g.startIndex}`)}),e[2]=s,e[3]=i,e[4]=a,e[5]=h}else h=e[5];c=h}const l=c;let u;e[6]!==s?(u=s?.Quote&&v.jsx(gm,{Quote:s.Quote}),e[6]=s,e[7]=u):u=e[7];let d;e[8]!==s||e[9]!==n?(d=v.jsx(mm,{components:s,enabled:n}),e[8]=s,e[9]=n,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==u||e[13]!==d?(f=v.jsxs(v.Fragment,{children:[u,l,d]}),e[11]=l,e[12]=u,e[13]=d,e[14]=f):f=e[14],f};function Sm(t){return t.type}function xm(t){return t.message.parts.map(Sm)}function wm(t){return t.type==="tool-call"?t.toolCallId:void 0}function Cm(t){return t.message.parts.map(wm)}function Tm(t){return t.part}function Em(t){return t.message.status??um}function Im(t){return t.part}function Rm(t){return t.part.type==="tool-call"?ma(t.tools,t.part):null}function Am(t){return t.part}function Pm(t){return t.part.type==="data"?Yn(t.dataRenderers,t.part.name,void 0)??null:null}function Mm(t){return t.part.type}function Dm(t){return t.message.parts.length}function Om(t){return(t.message.status?.type??"complete")==="running"}function km(t){return t.message.parts.length}const ba=Symbol.for("@assistant-ui/groupBy.memoKey"),U1=t=>{const e=t,s=((r,o)=>{if(r.type==="tool-call"){const i=fa(r.mcp?.app?.resourceUri);if((i||(o?.toolUIs?.[r.toolName]?.[0]?.standalone??!1))&&e["standalone-tool-call"]!==void 0)return e["standalone-tool-call"];if(i&&e["mcp-app"]!==void 0)return e["mcp-app"]}return e[r.type]??[]}),n=Object.keys(t).sort().map(r=>[r,t[r]]);return s[ba]=`groupPartByType:${JSON.stringify(n)}`,s},eo=t=>{const e=t.nextChildIdx++;return t.nodeKey===""?String(e):`${t.nodeKey}.${e}`},to=(t,e)=>{if(!(e===void 0||t.claimed.has(e)))return t.claimed.add(e),`id:${e}`},$m=(t,e)=>{const s={key:"",nodeKey:"",indices:[],children:[],nextChildIdx:0,claimed:new Set},n=[s],r=()=>{const o=n.pop(),i=n[n.length-1];i.children.push({type:"group",key:o.key,nodeKey:o.nodeKey,idKey:to(i,e?.[o.indices[0]]),indices:o.indices,children:o.children})};for(let o=0;o<t.length;o++){const i=t[o];let a=0;for(;a<n.length-1&&a<i.length&&n[a+1].key===i[a];)a++;for(;n.length-1>a;)r();for(;n.length-1<i.length;){const l=n[n.length-1];n.push({key:i[n.length-1],nodeKey:eo(l),indices:[],children:[],nextChildIdx:0,claimed:new Set})}const c=n[n.length-1];c.children.push({type:"part",index:o,nodeKey:eo(c),idKey:to(c,e?.[o])});for(let l=1;l<n.length;l++)n[l].indices.push(o)}for(;n.length>1;)r();return s.children},Nm=Object.freeze({type:"complete"}),Lm=(t,e,s)=>{if(!s)return!1;switch(t){case"never":return!1;case"always":return!0;case"empty":return e.length===0;case"no-text":{const n=e[e.length-1];return n===void 0||n.type!=="text"&&n.type!=="reasoning"}}},ya=()=>{throw new Error("MessagePrimitive.GroupedParts: rendered `children` under a leaf part. `children` is only meaningful for `group-…` cases — add a matching case for the part type or return `null` to skip it.")},_a=(t,e,s)=>{if(t.type==="part")return v.jsx(va,{index:t.index,children:({part:r})=>s({part:r,children:v.jsx(ya,{})})},t.idKey?`part-${t.idKey}`:`part-${t.index}`);const n=e[t.indices.at(-1)]?.status??Nm;return v.jsx(b.Fragment,{children:s({part:{type:t.key,status:n,indices:t.indices},children:v.jsx(v.Fragment,{children:t.children.map(r=>_a(r,e,s))})})},t.idKey??t.nodeKey)},Sa=({groupBy:t,indicator:e="no-text",children:s})=>{const n=D(gn(i=>i.message.parts)),r=D(i=>i.tools.toolUIs),o=D(i=>e==="never"?!1:i.message.status?.type==="running");return v.jsxs(v.Fragment,{children:[te(()=>{const i={toolUIs:r};return $m(n.map(a=>t(a,i)??[]),n.map(a=>a.type==="tool-call"?a.toolCallId:void 0))},[n,t[ba]??t,r]).map(i=>_a(i,n,s)),Lm(e,n,o)&&s({part:{type:"indicator"},children:v.jsx(ya,{})})]})};Sa.displayName="MessagePrimitive.GroupedParts";const jm=t=>{const e=T(5),{children:s}=t,n=D(la);if(!n)return null;let r;e[0]!==s||e[1]!==n?(r=s(n),e[0]=s,e[1]=n,e[2]=r):r=e[2];let o;return e[3]!==r?(o=v.jsx(v.Fragment,{children:r}),e[3]=r,e[4]=o):o=e[4],o},xa=b.memo(jm);xa.displayName="MessagePrimitive.Quote";const wa=(t,e)=>{switch(e.type){case"image":return t?.Image??t?.Attachment;case"document":return t?.Document??t?.Attachment;case"file":return t?.File??t?.Attachment;default:return t?.Attachment}},Bm=t=>{const e=T(5),{components:s}=t,n=D(Fm);if(!n)return null;const r=n;let o;e[0]!==s||e[1]!==r?(o=wa(s,r),e[0]=s,e[1]=r,e[2]=o):o=e[2];const i=o;if(!i)return null;let a;return e[3]!==i?(a=v.jsx(i,{}),e[3]=i,e[4]=a):a=e[4],a},Ca=b.memo(t=>{const e=T(5),{index:s,components:n}=t;let r;e[0]!==n?(r=v.jsx(Bm,{components:n}),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=v.jsx(qi,{index:s,children:r}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o},(t,e)=>t.index===e.index&&t.components?.Image===e.components?.Image&&t.components?.Document===e.components?.Document&&t.components?.File===e.components?.File&&t.components?.Attachment===e.components?.Attachment);Ca.displayName="MessagePrimitive.AttachmentByIndex";const so=({children:t})=>{const e=D(s=>s.message.role!=="user"?0:(s.message.attachments??[]).length);return te(()=>Array.from({length:e},(s,n)=>v.jsx(qi,{index:n,children:v.jsx(et,{getItemState:r=>r.message().attachment({index:n}).getState(),children:r=>t({get attachment(){return r()}})})},n)),[e,t])},Ta=t=>{const e=T(4),{components:s,children:n}=t;if(s){let o;return e[0]!==s?(o=v.jsx(so,{children:i=>{const{attachment:a}=i,c=wa(s,a);return c?v.jsx(c,{}):null}}),e[0]=s,e[1]=o):o=e[1],o}let r;return e[2]!==n?(r=v.jsx(so,{children:n}),e[2]=n,e[3]=r):r=e[3],r};Ta.displayName="MessagePrimitive.Attachments";function Fm(t){return t.attachment}const Ea=(t,e)=>{switch(e.type){case"image":return t?.Image??t?.Attachment;case"document":return t?.Document??t?.Attachment;case"file":return t?.File??t?.Attachment;default:return t?.Attachment}},Um=t=>{const e=T(5),{components:s}=t,n=D(Vm);if(!n)return null;let r;e[0]!==n||e[1]!==s?(r=Ea(s,n),e[0]=n,e[1]=s,e[2]=r):r=e[2];const o=r;if(!o)return null;let i;return e[3]!==o?(i=v.jsx(o,{}),e[3]=o,e[4]=i):i=e[4],i},Ia=b.memo(t=>{const e=T(5),{index:s,components:n}=t;let r;e[0]!==n?(r=v.jsx(Um,{components:n}),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=v.jsx(zi,{index:s,children:r}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o},(t,e)=>t.index===e.index&&t.components?.Image===e.components?.Image&&t.components?.Document===e.components?.Document&&t.components?.File===e.components?.File&&t.components?.Attachment===e.components?.Attachment);Ia.displayName="ComposerPrimitive.AttachmentByIndex";const no=({children:t})=>{const e=D(s=>s.composer.attachments.length);return te(()=>Array.from({length:e},(s,n)=>v.jsx(zi,{index:n,children:v.jsx(et,{getItemState:r=>r.composer().attachment({index:n}).getState(),children:r=>t({get attachment(){return r()}})})},n)),[e,t])},Ra=t=>{const e=T(4),{components:s,children:n}=t;if(s){let o;return e[0]!==s?(o=v.jsx(no,{children:i=>{const{attachment:a}=i,c=Ea(s,a);return c?v.jsx(c,{}):null}}),e[0]=s,e[1]=o):o=e[1],o}let r;return e[2]!==n?(r=v.jsx(no,{children:n}),e[2]=n,e[3]=r):r=e[3],r};Ra.displayName="ComposerPrimitive.Attachments";function Vm(t){return t.attachment}const Hm=({children:t})=>{const e=D(s=>s.composer.queue.length);return te(()=>Array.from({length:e},(s,n)=>v.jsx(eh,{index:n,children:v.jsx(et,{getItemState:r=>r.composer().queueItem({index:n}).getState(),children:r=>t({get queueItem(){return r()}})})},n)),[e,t])},Aa=b.memo(Hm);Aa.displayName="ComposerPrimitive.Queue";const Pa=b.memo(t=>{const e=T(6),{index:s,archived:n,components:r}=t,o=n===void 0?!1:n,i=r.ThreadListItem;let a;e[0]!==i?(a=v.jsx(i,{}),e[0]=i,e[1]=a):a=e[1];let c;return e[2]!==o||e[3]!==s||e[4]!==a?(c=v.jsx(Gi,{index:s,archived:o,children:a}),e[2]=o,e[3]=s,e[4]=a,e[5]=c):c=e[5],c},(t,e)=>t.index===e.index&&t.archived===e.archived&&t.components.ThreadListItem===e.components.ThreadListItem);Pa.displayName="ThreadListPrimitive.ItemByIndex";const ro=({archived:t,children:e})=>{const s=D(n=>t?n.threads.archivedThreadIds.length:n.threads.threadIds.length);return te(()=>Array.from({length:s},(n,r)=>v.jsx(Gi,{index:r,archived:t,children:v.jsx(et,{getItemState:o=>o.threads().item({index:r,archived:t}).getState(),children:o=>e({get threadListItem(){return o()}})})},r)),[s,t,e])},Ma=t=>{const e=T(8),{archived:s,components:n,children:r}=t,o=s===void 0?!1:s;if(n){const a=n.ThreadListItem;let c;e[0]!==a?(c=()=>v.jsx(a,{}),e[0]=a,e[1]=c):c=e[1];let l;return e[2]!==o||e[3]!==c?(l=v.jsx(ro,{archived:o,children:c}),e[2]=o,e[3]=c,e[4]=l):l=e[4],l}let i;return e[5]!==o||e[6]!==r?(i=v.jsx(ro,{archived:o,children:r}),e[5]=o,e[6]=r,e[7]=i):i=e[7],i};Ma.displayName="ThreadListPrimitive.Items";const Qn=t=>{const{children:e}=t;return D(qm)?e:null};Qn.displayName="MessagePartPrimitive.InProgress";function qm(t){return t.part.status.type==="running"}const Da=t=>{const e=T(2),{fallback:s}=t,n=D(zm)||s;let r;return e[0]!==n?(r=v.jsx(v.Fragment,{children:n}),e[0]=n,e[1]=r):r=e[1],r};Da.displayName="ThreadListItemPrimitive.Title";function zm(t){return t.threadListItem.title}const Oa=t=>{const e=T(2),{components:s}=t,n=s.Suggestion;let r;return e[0]!==n?(r=v.jsx(n,{}),e[0]=n,e[1]=r):r=e[1],r},ka=b.memo(t=>{const e=T(5),{index:s,components:n}=t;let r;e[0]!==n?(r=v.jsx(Oa,{components:n}),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=v.jsx(Ki,{index:s,children:r}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o},(t,e)=>t.index===e.index&&t.components.Suggestion===e.components.Suggestion);ka.displayName="ThreadPrimitive.SuggestionByIndex";const oo=({children:t})=>{const e=D(s=>s.suggestions.suggestions.length);return te(()=>e===0?null:Array.from({length:e},(s,n)=>v.jsx(Ki,{index:n,children:v.jsx(et,{getItemState:r=>r.suggestions().suggestion({index:n}).getState(),children:r=>t({get suggestion(){return r()}})})},n)),[e,t])},$a=t=>{const e=T(4),{components:s,children:n}=t;if(s){let o;return e[0]!==s?(o=v.jsx(oo,{children:()=>v.jsx(Oa,{components:s})}),e[0]=s,e[1]=o):o=e[1],o}let r;return e[2]!==n?(r=v.jsx(oo,{children:n}),e[2]=n,e[3]=r):r=e[3],r};$a.displayName="ThreadPrimitive.Suggestions";const Wm=b.memo($a,(t,e)=>t.children||e.children?t.children===e.children:t.components.Suggestion===e.components.Suggestion),Gm=t=>{const e=T(3);let s;return e[0]!==t.dictation||e[1]!==t.editing?(s=n=>{if(t.editing===!0&&!n.composer.isEditing||t.editing===!1&&n.composer.isEditing)return!1;const r=n.composer.dictation!=null;return!(t.dictation===!0&&!r||t.dictation===!1&&r)},e[0]=t.dictation,e[1]=t.editing,e[2]=s):s=e[2],D(s)},Na=t=>{const e=T(3);let s,n;return e[0]!==t?({children:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]),Gm(n)?s:null};Na.displayName="ComposerPrimitive.If";const Km=()=>{const t=T(5),e=H(),s=D(Ym);let n;t[0]!==e?(n=i=>{e.composer().send(i)},t[0]=e,t[1]=n):n=t[1];const r=n;let o;return t[2]!==s||t[3]!==r?(o={send:r,disabled:s},t[2]=s,t[3]=r,t[4]=o):o=t[4],o};function Ym(t){return!t.composer.canSend||t.thread.isRunning&&!t.thread.capabilities.queue}const Qm=()=>{const t=T(5),e=H(),s=D(Jm);let n;t[0]!==e?(n=()=>{e.composer().cancel()},t[0]=e,t[1]=n):n=t[1];const r=n;let o;return t[2]!==r||t[3]!==s?(o={cancel:r,disabled:s},t[2]=r,t[3]=s,t[4]=o):o=t[4],o};function Jm(t){return!t.composer.canCancel}const Xm=()=>{const t=T(5),e=H(),s=D(Zm);let n;t[0]!==e?(n=()=>{e.composer().startDictation()},t[0]=e,t[1]=n):n=t[1];const r=n;let o;return t[2]!==s||t[3]!==r?(o={startDictation:r,disabled:s},t[2]=s,t[3]=r,t[4]=o):o=t[4],o};function Zm(t){return t.composer.dictation!=null||!t.thread.capabilities.dictation||!t.composer.isEditing}const ep=()=>{const t=T(5),e=H(),s=D(tp);let n;t[0]!==e?(n=i=>e.composer().addAttachment(i),t[0]=e,t[1]=n):n=t[1];const r=n;let o;return t[2]!==r||t[3]!==s?(o={addAttachment:r,disabled:s},t[2]=r,t[3]=s,t[4]=o):o=t[4],o};function tp(t){return!t.composer.isEditing}const sp=t=>{const e=T(12);let s;e[0]!==t?(s=t===void 0?{}:t,e[0]=t,e[1]=s):s=e[1];const{copiedDuration:n,copyToClipboard:r}=s,o=n===void 0?3e3:n,i=H(),a=D(rp),c=D(op),l=D(ip),u=D(ap);let d;e[2]!==i||e[3]!==u||e[4]!==o||e[5]!==r||e[6]!==l?(d=()=>{const m=l?u:i.message().getCopyText();if(!m)return;const p=r??cp;Promise.resolve(p(m)).then(()=>{i.message().setIsCopied(!0),setTimeout(()=>i.message().setIsCopied(!1),o)},lp)},e[2]=i,e[3]=u,e[4]=o,e[5]=r,e[6]=l,e[7]=d):d=e[7];const f=d;let h;return e[8]!==f||e[9]!==a||e[10]!==c?(h={copy:f,disabled:a,isCopied:c},e[8]=f,e[9]=a,e[10]=c,e[11]=h):h=e[11],h};function np(t){return t.type==="text"&&t.text.length>0}function rp(t){return!((t.message.role!=="assistant"||t.message.status?.type!=="running")&&t.message.parts.some(np))}function op(t){return t.message.isCopied}function ip(t){return t.composer.isEditing}function ap(t){return t.composer.text}function cp(){}function lp(){}const up=()=>{const t=T(5),e=H(),s=D(dp);let n;t[0]!==e?(n=()=>{e.composer().beginEdit()},t[0]=e,t[1]=n):n=t[1];const r=n;let o;return t[2]!==s||t[3]!==r?(o={edit:r,disabled:s},t[2]=s,t[3]=r,t[4]=o):o=t[4],o};function dp(t){return t.composer.isEditing}const fp=()=>{const t=T(5),e=H(),s=D(hp);let n;t[0]!==e?(n=()=>{e.message().reload()},t[0]=e,t[1]=n):n=t[1];const r=n;let o;return t[2]!==s||t[3]!==r?(o={reload:r,disabled:s},t[2]=s,t[3]=r,t[4]=o):o=t[4],o};function hp(t){return t.thread.isRunning||t.thread.isDisabled||t.message.role!=="assistant"}const mp=()=>{const t=T(5),e=H(),s=D(gp);let n;t[0]!==e?(n=()=>{e.message().submitFeedback({type:"positive"})},t[0]=e,t[1]=n):n=t[1];const r=n;let o;return t[2]!==s||t[3]!==r?(o={submit:r,isSubmitted:s},t[2]=s,t[3]=r,t[4]=o):o=t[4],o},pp=()=>{const t=T(5),e=H(),s=D(vp);let n;t[0]!==e?(n=()=>{e.message().submitFeedback({type:"negative"})},t[0]=e,t[1]=n):n=t[1];const r=n;let o;return t[2]!==s||t[3]!==r?(o={submit:r,isSubmitted:s},t[2]=s,t[3]=r,t[4]=o):o=t[4],o};function gp(t){return t.message.metadata.submittedFeedback?.type==="positive"}function vp(t){return t.message.metadata.submittedFeedback?.type==="negative"}const bp=()=>{const t=T(5),e=H(),s=D(_p);let n;t[0]!==e?(n=async()=>{e.message().speak()},t[0]=e,t[1]=n):n=t[1];const r=n;let o;return t[2]!==s||t[3]!==r?(o={speak:r,disabled:s},t[2]=s,t[3]=r,t[4]=o):o=t[4],o};function yp(t){return t.type==="text"&&t.text.length>0}function _p(t){return!((t.message.role!=="assistant"||t.message.status?.type!=="running")&&t.message.parts.some(yp))}const Sp=()=>{const t=T(5),e=H(),s=D(xp);let n;t[0]!==e?(n=()=>{e.message().stopSpeaking()},t[0]=e,t[1]=n):n=t[1];const r=n;let o;return t[2]!==s||t[3]!==r?(o={stopSpeaking:r,disabled:s},t[2]=s,t[3]=r,t[4]=o):o=t[4],o};function xp(t){return t.message.speech==null}const wp=t=>{const e=T(8),{prompt:s,send:n,clearComposer:r}=t,o=r===void 0?!0:r,i=H(),a=D(Cp),c=n??!1;let l;e[0]!==i||e[1]!==o||e[2]!==s||e[3]!==c?(l=()=>{const f=i.thread().getState().isRunning;if(c&&!f)i.thread().append({content:[{type:"text",text:s}],runConfig:i.composer().getState().runConfig}),o&&i.composer().setText("");else if(o)i.composer().setText(s);else{const h=i.composer().getState().text;i.composer().setText(h.trim()?`${h} ${s}`:s)}},e[0]=i,e[1]=o,e[2]=s,e[3]=c,e[4]=l):l=e[4];const u=l;let d;return e[5]!==a||e[6]!==u?(d={trigger:u,disabled:a},e[5]=a,e[6]=u,e[7]=d):d=e[7],d};function Cp(t){return t.thread.isDisabled}const Tp=()=>{const t=T(4),e=H();let s;t[0]!==e?(s=()=>{e.threadListItem().archive()},t[0]=e,t[1]=s):s=t[1];const n=s;let r;return t[2]!==n?(r={archive:n},t[2]=n,t[3]=r):r=t[3],r},Ep=()=>{const t=T(4),e=H();let s;t[0]!==e?(s=()=>{e.threadListItem().delete()},t[0]=e,t[1]=s):s=t[1];const n=s;let r;return t[2]!==n?(r={delete:n},t[2]=n,t[3]=r):r=t[3],r},Ip=()=>{const t=T(4),e=H();let s;t[0]!==e?(s=()=>{e.threadListItem().unarchive()},t[0]=e,t[1]=s):s=t[1];const n=s;let r;return t[2]!==n?(r={unarchive:n},t[2]=n,t[3]=r):r=t[3],r},Rp=()=>{const t=T(4),e=H();let s;t[0]!==e?(s=()=>{e.threadListItem().switchTo()},t[0]=e,t[1]=s):s=t[1];const n=s;let r;return t[2]!==n?(r={switchTo:n},t[2]=n,t[3]=r):r=t[3],r},Ap=()=>{const t=T(4),e=H();let s;t[0]!==e?(s=()=>{e.threads().switchToNewThread()},t[0]=e,t[1]=s):s=t[1];const n=s;let r;return t[2]!==n?(r={switchToNewThread:n},t[2]=n,t[3]=r):r=t[3],r},Pp=()=>{const t=T(5),e=H(),s=D(Mp);let n;t[0]!==e?(n=()=>{e.threads().loadMore()},t[0]=e,t[1]=n):n=t[1];const r=n;let o;return t[2]!==s||t[3]!==r?(o={loadMore:r,disabled:s},t[2]=s,t[3]=r,t[4]=o):o=t[4],o};function Mp(t){return!t.threads.hasMore||t.threads.isLoading||t.threads.isLoadingMore}const Dp=()=>D(Op);function Op(t){if(t.message.status?.type!=="incomplete"||t.message.status.reason!=="error")return;const e=t.message.status.error;return typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:e??"An error occurred"}const kp=t=>{const{cloud:e,initialMessages:s,maxSteps:n,adapters:r,unstable_humanToolNames:o,unstable_enableMessageQueue:i,...a}=t;return{localRuntimeOptions:{cloud:e,initialMessages:s,maxSteps:n,adapters:r,unstable_humanToolNames:o,unstable_enableMessageQueue:i},otherOptions:a}},$p=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,La={serialize(t){const e=t.id!==t.label?`{name=${t.id}}`:"";return`:${t.type}[${t.label}]${e}`},parse(t){const e=[];let s=0;for(const n of t.matchAll($p)){n.index>s&&e.push({kind:"text",text:t.slice(s,n.index)});const r=n[2];e.push({kind:"mention",type:n[1],label:r,id:n[3]??r}),s=n.index+n[0].length}return s<t.length&&e.push({kind:"text",text:t.slice(s)}),e}};function Np(t,e){function s(n){const r=me(t);if(!n?.optional&&!r)throw new Error(`This component must be used within ${e}.`);return r}return s}function ja(t,e){function s(r){const o=t(r);return o?o[e]:null}function n(r){let o=!1,i;typeof r=="function"?i=r:r&&typeof r=="object"&&(o=!!r.optional,i=r.selector);const a=s({optional:o});return a?i?a(i):a():null}return{[e]:n,[`${e}Store`]:s}}const Ba=fe(null),{useThreadViewport:st,useThreadViewportStore:nt}=ja(Np(Ba,"ThreadPrimitive.Viewport"),"useThreadViewport"),io=t=>{const e=new Map,s=()=>{let n=0;for(const r of e.values())n+=r;t(n)};return{register:()=>{const n=Symbol();return e.set(n,0),{setHeight:r=>{e.get(n)!==r&&(e.set(n,r),s())},unregister:()=>{e.delete(n),s()}}}}},Lp=(t={})=>{const e=new Set,s=io(i=>{o.setState({height:{...o.getState().height,viewport:i}})}),n=io(i=>{o.setState({height:{...o.getState().height,inset:i}})}),r=(i,a)=>(o.setState({element:{...o.getState().element,[i]:a}}),()=>{o.getState().element[i]===a&&o.setState({element:{...o.getState().element,[i]:null}})}),o=Ni(()=>({isAtBottom:!0,scrollToBottom:({behavior:i="auto"}={})=>{for(const a of e)a({behavior:i})},onScrollToBottom:i=>(e.add(i),()=>{e.delete(i)}),turnAnchor:t.turnAnchor??"bottom",topAnchorMessageClamp:{tallerThan:t.topAnchorMessageClamp?.tallerThan??"10em",visibleHeight:t.topAnchorMessageClamp?.visibleHeight??"6em"},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:s.register,registerContentInset:n.register,registerViewportElement:i=>r("viewport",i),registerAnchorElement:i=>r("anchor",i),registerAnchorTargetElement:(i,a)=>(o.setState({element:{...o.getState().element,target:i},targetConfig:i&&a?a:null}),()=>{o.getState().element.target===i&&o.setState({element:{...o.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:i=>{o.setState({topAnchorTurn:i})}}));return o},ms=t=>t,jp=t=>{const e=T(11);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={optional:!0},e[0]=s):s=e[0];const n=nt(s);let r;e[1]!==t?(r=()=>Lp(t),e[1]=t,e[2]=r):r=e[2];const[o]=ee(r);let i,a;e[3]!==n||e[4]!==o?(i=()=>n?.getState().onScrollToBottom(()=>{o.getState().scrollToBottom()}),a=[n,o],e[3]=n,e[4]=o,e[5]=i,e[6]=a):(i=e[5],a=e[6]),q(i,a);let c,l;return e[7]!==n||e[8]!==o?(c=()=>{if(n)return o.subscribe(u=>{n.getState().isAtBottom!==u.isAtBottom&&ms(n).setState({isAtBottom:u.isAtBottom})})},l=[o,n],e[7]=n,e[8]=o,e[9]=c,e[10]=l):(c=e[9],l=e[10]),q(c,l),o},Jn=t=>{const e=T(7),{children:s,options:n}=t;let r;e[0]!==n?(r=n===void 0?{}:n,e[0]=n,e[1]=r):r=e[1];const o=jp(r);let i;e[2]!==o?(i=()=>({useThreadViewport:o}),e[2]=o,e[3]=i):i=e[3];const[a]=ee(i);let c;return e[4]!==s||e[5]!==a?(c=v.jsx(Ba.Provider,{value:a,children:s}),e[4]=s,e[5]=a,e[6]=c):c=e[6],c},Bp=()=>{const t=T(3),e=H();let s,n;return t[0]!==e?(s=()=>{},n=[e],t[0]=e,t[1]=s,t[2]=n):(s=t[1],n=t[2]),q(s,n),null},Fp=t=>{const e=T(7),{children:s,aui:n,runtime:r}=t,o=n??null;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=v.jsx(Bp,{}),e[0]=i):i=e[0];let a;e[1]!==s?(a=v.jsx(Jn,{children:s}),e[1]=s,e[2]=a):a=e[2];let c;return e[3]!==r||e[4]!==o||e[5]!==a?(c=v.jsxs(tf,{runtime:r,aui:o,children:[i,a]}),e[3]=r,e[4]=o,e[5]=a,e[6]=c):c=e[6],c},V1=b.memo(Fp);function ao(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Up(...t){return e=>{let s=!1;const n=t.map(r=>{const o=ao(r,e);return!s&&typeof o=="function"&&(s=!0),o});if(s)return()=>{for(let r=0;r<n.length;r++){const o=n[r];typeof o=="function"?o():ao(t[r],null)}}}}function ae(...t){return b.useCallback(Up(...t),t)}var co=Object.defineProperty,Ue=(t,e)=>{let s={};for(var n in t)co(s,n,{get:t[n],enumerable:!0});return co(s,Symbol.toStringTag,{value:"Module"}),s},Xn=Pl();function Ot(t){const e=b.forwardRef((s,n)=>{let{children:r,...o}=s,i=null,a=!1;const c=[];lo(r)&&typeof zt=="function"&&(r=zt(r._payload)),b.Children.forEach(r,f=>{if(Wp(f)){a=!0;const h=f;let m="child"in h.props?h.props.child:h.props.children;lo(m)&&typeof zt=="function"&&(m=zt(m._payload)),i=Hp(h,m),c.push(i?.props?.children)}else c.push(f)}),i?i=b.cloneElement(i,void 0,c):!a&&b.Children.count(r)===1&&b.isValidElement(r)&&(i=r);const l=i?zp(i):void 0,u=ae(n,l);if(!i){if(r||r===0)throw new Error(a?Qp(t):Yp(t));return r}const d=qp(o,i.props??{});return i.type!==b.Fragment&&(d.ref=n?u:l),b.cloneElement(i,d)});return e.displayName=`${t}.Slot`,e}var ps=Ot("Slot"),Vp=Symbol.for("radix.slottable"),Hp=(t,e)=>{if("child"in t.props){const s=t.props.child;return b.isValidElement(s)?b.cloneElement(s,void 0,t.props.children(s.props.children)):null}return b.isValidElement(e)?e:null};function qp(t,e){const s={...e};for(const n in e){const r=t[n],o=e[n];/^on[A-Z]/.test(n)?r&&o?s[n]=(...a)=>{const c=o(...a);return r(...a),c}:r&&(s[n]=r):n==="style"?s[n]={...r,...o}:n==="className"&&(s[n]=[r,o].filter(Boolean).join(" "))}return{...t,...s}}function zp(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}function Wp(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Vp}var Gp=Symbol.for("react.lazy");function lo(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===Gp&&"_payload"in t&&Kp(t._payload)}function Kp(t){return typeof t=="object"&&t!==null&&"then"in t}var Yp=t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,Qp=t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,zt=Tn[" use ".trim().toString()],Jp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ae=Jp.reduce((t,e)=>{const s=Ot(`Primitive.${e}`),n=b.forwardRef((r,o)=>{const{asChild:i,...a}=r,c=i?s:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),v.jsx(c,{...a,ref:o})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function Xp(t,e){t&&Xn.flushSync(()=>t.dispatchEvent(e))}const Zp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"];function eg(t){const e=b.forwardRef((s,n)=>{const r=T(17);let o,i,a,c;r[0]!==s?({render:a,asChild:o,children:i,...c}=s,r[0]=s,r[1]=o,r[2]=i,r[3]=a,r[4]=c):(o=r[1],i=r[2],a=r[3],c=r[4]);const l=t;if(a&&b.isValidElement(a)){const f=i!==void 0?i:a.props.children,h=c;let m;r[5]!==a||r[6]!==f?(m=b.cloneElement(a,void 0,f),r[5]=a,r[6]=f,r[7]=m):m=r[7];let p;return r[8]!==n||r[9]!==h||r[10]!==m?(p=v.jsx(l,{...h,asChild:!0,ref:n,children:m}),r[8]=n,r[9]=h,r[10]=m,r[11]=p):p=r[11],p}const u=c;let d;return r[12]!==o||r[13]!==i||r[14]!==n||r[15]!==u?(d=v.jsx(l,{...u,asChild:o,ref:n,children:i}),r[12]=o,r[13]=i,r[14]=n,r[15]=u,r[16]=d):d=r[16],d});return e.displayName=typeof t=="string"?t:t.displayName??t.name??"Component",e}function tg(t){const e=Ae[t],s=eg(e);return s.displayName=`Primitive.${t}`,s}const X=Zp.reduce((t,e)=>(t[e]=tg(e),t),{}),sg=t=>{const e=T(5),{hideWhenRunning:s,autohide:n,autohideFloat:r,forceVisible:o}=t;let i;return e[0]!==n||e[1]!==r||e[2]!==o||e[3]!==s?(i=a=>{if(s&&a.thread.isRunning)return"hidden";const c=n==="always"||n==="not-last"&&!a.message.isLast,l=o||a.message.isHovering;return c?l?r==="always"||r==="single-branch"&&a.message.branchCount<=1?"floating":"normal":"hidden":"normal"},e[0]=n,e[1]=r,e[2]=o,e[3]=s,e[4]=i):i=e[4],D(i)},ng=fe(null),Fa=b.forwardRef((t,e)=>{const s=T(18);let n,r,o,i;s[0]!==t?({hideWhenRunning:o,autohide:n,autohideFloat:r,...i}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o,s[4]=i):(n=s[1],r=s[2],o=s[3],i=s[4]);const[a,c]=ee(0);let l;s[5]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{let C=!1;return c(rg),()=>{C||(C=!0,c(og))}},s[5]=l):l=s[5];const u=l;let d;s[6]===Symbol.for("react.memo_cache_sentinel")?(d={acquireInteractionLock:u},s[6]=d):d=s[6];const f=d,h=a>0;let m;s[7]!==n||s[8]!==r||s[9]!==o||s[10]!==h?(m={hideWhenRunning:o,autohide:n,autohideFloat:r,forceVisible:h},s[7]=n,s[8]=r,s[9]=o,s[10]=h,s[11]=m):m=s[11];const p=sg(m);if(p==="hidden")return null;let g;s[12]!==p?(g=p==="floating"?{"data-floating":"true"}:null,s[12]=p,s[13]=g):g=s[13];let _;return s[14]!==e||s[15]!==i||s[16]!==g?(_=v.jsx(ng.Provider,{value:f,children:v.jsx(X.div,{...g,...i,ref:e})}),s[14]=e,s[15]=i,s[16]=g,s[17]=_):_=s[17],_});Fa.displayName="ActionBarPrimitive.Root";function rg(t){return t+1}function og(t){return Math.max(0,t-1)}function K(t,e,{checkForDefaultPrevented:s=!0}={}){return function(r){if(t?.(r),s===!1||!r||!r.defaultPrevented)return e?.(r)}}const ig=t=>{const e=T(4);let s;e[0]!==t?(s=t===void 0?{}:t,e[0]=t,e[1]=s):s=e[1];const{copiedDuration:n}=s,r=n===void 0?3e3:n;let o;e[2]!==r?(o={copiedDuration:r,copyToClipboard:ag},e[2]=r,e[3]=o):o=e[3];const{copy:i,disabled:a}=sp(o);return a?null:i},Ua=b.forwardRef((t,e)=>{const s=T(20);let n,r,o,i;s[0]!==t?({copiedDuration:n,onClick:o,disabled:r,...i}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o,s[4]=i):(n=s[1],r=s[2],o=s[3],i=s[4]);const a=D(cg);let c;s[5]!==n?(c={copiedDuration:n},s[5]=n,s[6]=c):c=s[6];const l=ig(c);let u;s[7]!==a?(u=a?{"data-copied":"true"}:{},s[7]=a,s[8]=u):u=s[8];const d=r||!l;let f;s[9]!==l?(f=()=>{l?.()},s[9]=l,s[10]=f):f=s[10];let h;s[11]!==o||s[12]!==f?(h=K(o,f),s[11]=o,s[12]=f,s[13]=h):h=s[13];let m;return s[14]!==e||s[15]!==i||s[16]!==u||s[17]!==d||s[18]!==h?(m=v.jsx(X.button,{type:"button",...u,...i,ref:e,disabled:d,onClick:h}),s[14]=e,s[15]=i,s[16]=u,s[17]=d,s[18]=h,s[19]=m):m=s[19],m});Ua.displayName="ActionBarPrimitive.Copy";function ag(t){return typeof navigator>"u"||!navigator.clipboard?Promise.reject(new Error("Clipboard API is unavailable")):navigator.clipboard.writeText(t)}function cg(t){return t.message.isCopied}const ce=(t,e,s=[])=>{const n=b.forwardRef((r,o)=>{const i=T(6),a={},c={};Object.keys(r).forEach(p=>{s.includes(p)?a[p]=r[p]:c[p]=r[p]});const l=e(a)??void 0,u=X,d="button",f=c.disabled||!l,h=K(c.onClick,l);let m;return i[0]!==o||i[1]!==c||i[2]!==u.button||i[3]!==f||i[4]!==h?(m=v.jsx(u.button,{...c,type:d,ref:o,disabled:f,onClick:h}),i[0]=o,i[1]=c,i[2]=u.button,i[3]=f,i[4]=h,i[5]=m):m=i[5],m});return n.displayName=t,n},lg=()=>{const{disabled:t,reload:e}=fp();return t?null:e},ug=ce("ActionBarPrimitive.Reload",lg),dg=()=>{const{disabled:t,edit:e}=up();return t?null:e},fg=ce("ActionBarPrimitive.Edit",dg),hg=()=>{const{disabled:t,speak:e}=bp();return t?null:e},mg=ce("ActionBarPrimitive.Speak",hg);function Oe(t){const e=b.useRef(t);return b.useEffect(()=>{e.current=t}),b.useMemo(()=>((...s)=>e.current?.(...s)),[])}function Va(t,e=globalThis?.document){const s=Oe(t);b.useEffect(()=>{const n=r=>{r.key==="Escape"&&s(r)};return e.addEventListener("keydown",n,{capture:!0}),()=>e.removeEventListener("keydown",n,{capture:!0})},[s,e])}const pg=()=>{const{disabled:t,stopSpeaking:e}=Sp();return t?null:e},Ha=b.forwardRef((t,e)=>{const s=T(12),n=pg();let r;s[0]!==n?(r=l=>{n&&(l.preventDefault(),n())},s[0]=n,s[1]=r):r=s[1],Va(r);const o=!n;let i;s[2]!==n?(i=()=>{n?.()},s[2]=n,s[3]=i):i=s[3];let a;s[4]!==t.onClick||s[5]!==i?(a=K(t.onClick,i),s[4]=t.onClick,s[5]=i,s[6]=a):a=s[6];let c;return s[7]!==t||s[8]!==e||s[9]!==o||s[10]!==a?(c=v.jsx(X.button,{type:"button",disabled:o,...t,ref:e,onClick:a}),s[7]=t,s[8]=e,s[9]=o,s[10]=a,s[11]=c):c=s[11],c});Ha.displayName="ActionBarPrimitive.StopSpeaking";const gg=()=>{const{submit:t}=mp();return t},qa=b.forwardRef((t,e)=>{const s=T(17);let n,r,o;s[0]!==t?({onClick:r,disabled:n,...o}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o):(n=s[1],r=s[2],o=s[3]);const i=D(vg),a=gg();let c;s[4]!==i?(c=i?{"data-submitted":"true"}:{},s[4]=i,s[5]=c):c=s[5];const l=n||!a;let u;s[6]!==a?(u=()=>{a?.()},s[6]=a,s[7]=u):u=s[7];let d;s[8]!==r||s[9]!==u?(d=K(r,u),s[8]=r,s[9]=u,s[10]=d):d=s[10];let f;return s[11]!==e||s[12]!==o||s[13]!==c||s[14]!==l||s[15]!==d?(f=v.jsx(X.button,{type:"button",...c,...o,ref:e,disabled:l,onClick:d}),s[11]=e,s[12]=o,s[13]=c,s[14]=l,s[15]=d,s[16]=f):f=s[16],f});qa.displayName="ActionBarPrimitive.FeedbackPositive";function vg(t){return t.message.metadata.submittedFeedback?.type==="positive"}const bg=()=>{const{submit:t}=pp();return t},za=b.forwardRef((t,e)=>{const s=T(17);let n,r,o;s[0]!==t?({onClick:r,disabled:n,...o}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o):(n=s[1],r=s[2],o=s[3]);const i=D(yg),a=bg();let c;s[4]!==i?(c=i?{"data-submitted":"true"}:{},s[4]=i,s[5]=c):c=s[5];const l=n||!a;let u;s[6]!==a?(u=()=>{a?.()},s[6]=a,s[7]=u):u=s[7];let d;s[8]!==r||s[9]!==u?(d=K(r,u),s[8]=r,s[9]=u,s[10]=d):d=s[10];let f;return s[11]!==e||s[12]!==o||s[13]!==c||s[14]!==l||s[15]!==d?(f=v.jsx(X.button,{type:"button",...c,...o,ref:e,disabled:l,onClick:d}),s[11]=e,s[12]=o,s[13]=c,s[14]=l,s[15]=d,s[16]=f):f=s[16],f});za.displayName="ActionBarPrimitive.FeedbackNegative";function yg(t){return t.message.metadata.submittedFeedback?.type==="negative"}const _g=t=>{const e=T(6);let s;e[0]!==t?(s=t===void 0?{}:t,e[0]=t,e[1]=s):s=e[1];const{filename:n,onExport:r}=s,o=H(),i=D(xg);let a;e[2]!==o||e[3]!==n||e[4]!==r?(a=async()=>{const l=o.message().getCopyText();if(!l)return;if(r){await r(l);return}const u=new Blob([l],{type:"text/markdown"}),d=URL.createObjectURL(u),f=document.createElement("a");f.href=d,f.download=n??`message-${Date.now()}.md`,f.click(),URL.revokeObjectURL(d)},e[2]=o,e[3]=n,e[4]=r,e[5]=a):a=e[5];const c=a;return i?c:null},Wa=b.forwardRef((t,e)=>{const s=T(19);let n,r,o,i,a;s[0]!==t?({filename:r,onExport:i,onClick:o,disabled:n,...a}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o,s[4]=i,s[5]=a):(n=s[1],r=s[2],o=s[3],i=s[4],a=s[5]);let c;s[6]!==r||s[7]!==i?(c={filename:r,onExport:i},s[6]=r,s[7]=i,s[8]=c):c=s[8];const l=_g(c),u=n||!l;let d;s[9]!==l?(d=()=>{l?.()},s[9]=l,s[10]=d):d=s[10];let f;s[11]!==o||s[12]!==d?(f=K(o,d),s[11]=o,s[12]=d,s[13]=f):f=s[13];let h;return s[14]!==e||s[15]!==a||s[16]!==u||s[17]!==f?(h=v.jsx(X.button,{type:"button",...a,ref:e,disabled:u,onClick:f}),s[14]=e,s[15]=a,s[16]=u,s[17]=f,s[18]=h):h=s[18],h});Wa.displayName="ActionBarPrimitive.ExportMarkdown";function Sg(t){return t.type==="text"&&t.text.length>0}function xg(t){return(t.message.role!=="assistant"||t.message.status?.type!=="running")&&t.message.parts.some(Sg)}var H1=Ue({Copy:()=>Ua,Edit:()=>fg,ExportMarkdown:()=>Wa,FeedbackNegative:()=>za,FeedbackPositive:()=>qa,Reload:()=>ug,Root:()=>Fa,Speak:()=>mg,StopSpeaking:()=>Ha});function Ga(t,e=[]){let s=[];function n(o,i){const a=b.createContext(i);a.displayName=o+"Context";const c=s.length;s=[...s,i];const l=d=>{const{scope:f,children:h,...m}=d,p=f?.[t]?.[c]||a,g=b.useMemo(()=>m,Object.values(m));return v.jsx(p.Provider,{value:g,children:h})};l.displayName=o+"Provider";function u(d,f,h={}){const{optional:m=!1}=h,p=f?.[t]?.[c]||a,g=b.useContext(p);if(g)return g;if(i!==void 0)return i;if(!m)throw new Error(`\`${d}\` must be used within \`${o}\``)}return[l,u]}const r=()=>{const o=s.map(i=>b.createContext(i));return function(a){const c=a?.[t]||o;return b.useMemo(()=>({[`__scope${t}`]:{...a,[t]:c}}),[a,c])}};return r.scopeName=t,[n,wg(r,...e)]}function wg(...t){const e=t[0];if(t.length===1)return e;const s=()=>{const n=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(o){const i=n.reduce((a,{useScope:c,scopeName:l})=>{const d=c(o)[`__scope${l}`];return{...a,...d}},{});return b.useMemo(()=>({[`__scope${e.scopeName}`]:i}),[i])}};return s.scopeName=e.scopeName,s}function Cg(t){const e=t+"CollectionProvider",[s,n]=Ga(e),[r,o]=s(e,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:g,children:_}=p,C=b.useRef(null),S=b.useRef(new Map).current;return v.jsx(r,{scope:g,itemMap:S,collectionRef:C,children:_})};i.displayName=e;const a=t+"CollectionSlot",c=Ot(a),l=b.forwardRef((p,g)=>{const{scope:_,children:C}=p,S=o(a,_),y=ae(g,S.collectionRef);return v.jsx(c,{ref:y,children:C})});l.displayName=a;const u=t+"CollectionItemSlot",d="data-radix-collection-item",f=Ot(u),h=b.forwardRef((p,g)=>{const{scope:_,children:C,...S}=p,y=b.useRef(null),x=ae(g,y),E=o(u,_);return b.useEffect(()=>(E.itemMap.set(y,{ref:y,...S}),()=>void E.itemMap.delete(y))),v.jsx(f,{[d]:"",ref:x,children:C})});h.displayName=u;function m(p){const g=o(t+"CollectionConsumer",p);return b.useCallback(()=>{const C=g.collectionRef.current;if(!C)return[];const S=Array.from(C.querySelectorAll(`[${d}]`));return Array.from(g.itemMap.values()).sort((E,I)=>S.indexOf(E.ref.current)-S.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:l,ItemSlot:h},m,n]}var kt=globalThis?.document?b.useLayoutEffect:()=>{},Tg=Tn[" useInsertionEffect ".trim().toString()]||kt;function Eg({prop:t,defaultProp:e,onChange:s=()=>{},caller:n}){const[r,o,i]=Ig({defaultProp:e,onChange:s}),a=t!==void 0,c=a?t:r;{const u=b.useRef(t!==void 0);b.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${n} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,n])}const l=b.useCallback(u=>{if(a){const d=Rg(u)?u(t):u;d!==t&&i.current?.(d)}else o(u)},[a,t,o,i]);return[c,l]}function Ig({defaultProp:t,onChange:e}){const[s,n]=b.useState(t),r=b.useRef(s),o=b.useRef(e);return Tg(()=>{o.current=e},[e]),b.useEffect(()=>{r.current!==s&&(o.current?.(s),r.current=s)},[s,r]),[s,n,o]}function Rg(t){return typeof t=="function"}function Ag(t,e){return b.useReducer((s,n)=>e[s][n]??s,t)}var Rs=t=>{const{present:e,children:s}=t,n=Pg(e),r=typeof s=="function"?s({present:n.isPresent}):b.Children.only(s),o=Mg(n.ref,Dg(r));return typeof s=="function"||n.isPresent?b.cloneElement(r,{ref:o}):null};Rs.displayName="Presence";function Pg(t){const[e,s]=b.useState(),n=b.useRef(null),r=b.useRef(t),o=b.useRef("none"),i=b.useRef(void 0),a=t?"mounted":"unmounted",[c,l]=Ag(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{c==="mounted"?(o.current=i.current??Tt(n.current),i.current=void 0):o.current="none"},[c]),kt(()=>{const u=n.current,d=r.current;if(d!==t){const h=o.current,m=Tt(u);t?(i.current=m,l("MOUNT")):m==="none"||u?.display==="none"?l("UNMOUNT"):l(d&&h!==m?"ANIMATION_OUT":"UNMOUNT"),r.current=t}},[t,l]),kt(()=>{if(e){let u;const d=e.ownerDocument.defaultView??window,f=m=>{const g=Tt(n.current).includes(CSS.escape(m.animationName));if(m.target===e&&g&&(l("ANIMATION_END"),!r.current)){const _=e.style.animationFillMode;e.style.animationFillMode="forwards",u=d.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=_)})}},h=m=>{m.target===e&&(o.current=Tt(n.current))};return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",f),e.addEventListener("animationend",f),()=>{d.clearTimeout(u),e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",f),e.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:b.useCallback(u=>{if(u){const d=getComputedStyle(u);n.current=d,i.current=Tt(d)}else n.current=null;s(u)},[])}}function uo(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Mg(...t){const e=b.useRef(t);return e.current=t,b.useCallback(s=>{const n=e.current;let r=!1;const o=n.map(i=>{const a=uo(i,s);return!r&&typeof a=="function"&&(r=!0),a});if(r)return()=>{for(let i=0;i<o.length;i++){const a=o[i];typeof a=="function"?a():uo(n[i],null)}}},[])}function Tt(t){return t?.animationName||"none"}function Dg(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}var Og=Tn[" useId ".trim().toString()]||(()=>{}),kg=0;function Gs(t){const[e,s]=b.useState(Og());return kt(()=>{s(n=>n??String(kg++))},[t]),e?`radix-${e}`:""}var $g=b.createContext(void 0);function Ng(t){return b.useContext($g)||"ltr"}var Lg="DismissableLayer",bn="dismissableLayer.update",jg="dismissableLayer.pointerDownOutside",Bg="dismissableLayer.focusOutside",fo,Zn=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ka=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:s=!1,deferPointerDownOutside:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:a,onDismiss:c,...l}=t,u=b.useContext(Zn),[d,f]=b.useState(null),h=d?.ownerDocument??globalThis?.document,[,m]=b.useState({}),p=ae(e,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),C=_?g.indexOf(_):-1,S=d?g.indexOf(d):-1,y=u.layersWithOutsidePointerEventsDisabled.size>0,x=S>=C,E=b.useRef(!1),I=qg(O=>{o?.(O),a?.(O),O.defaultPrevented||c?.()},{ownerDocument:h,deferPointerDownOutside:n,isDeferredPointerDownOutsideRef:E,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:b.useCallback(O=>{if(!(O instanceof Node))return!1;const $=[...u.branches].some(M=>M.contains(O));return x&&!$},[u.branches,x])}),R=zg(O=>{if(n&&E.current)return;const $=O.target;[...u.branches].some(B=>B.contains($))||(i?.(O),a?.(O),O.defaultPrevented||c?.())},h),P=d?S===g.length-1:!1,k=Oe(O=>{O.key==="Escape"&&(r?.(O),!O.defaultPrevented&&c&&(O.preventDefault(),c()))});return b.useEffect(()=>{if(P)return h.addEventListener("keydown",k,{capture:!0}),()=>h.removeEventListener("keydown",k,{capture:!0})},[h,P,k]),b.useEffect(()=>{if(d)return s&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(fo=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),ho(),()=>{s&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=fo))}},[d,h,s,u]),b.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),ho())},[d,u]),b.useEffect(()=>{const O=()=>m({});return document.addEventListener(bn,O),()=>document.removeEventListener(bn,O)},[]),v.jsx(Ae.div,{...l,ref:p,style:{pointerEvents:y?x?"auto":"none":void 0,...t.style},onFocusCapture:K(t.onFocusCapture,R.onFocusCapture),onBlurCapture:K(t.onBlurCapture,R.onBlurCapture),onPointerDownCapture:K(t.onPointerDownCapture,I.onPointerDownCapture)})});Ka.displayName=Lg;var Fg="DismissableLayerBranch",Ug=b.forwardRef((t,e)=>{const s=b.useContext(Zn),n=b.useRef(null),r=ae(e,n);return b.useEffect(()=>{const o=n.current;if(o)return s.branches.add(o),()=>{s.branches.delete(o)}},[s.branches]),v.jsx(Ae.div,{...t,ref:r})});Ug.displayName=Fg;function Vg(){const t=b.useContext(Zn),[e,s]=b.useState(null);return b.useEffect(()=>{if(e)return t.dismissableSurfaces.add(e),()=>{t.dismissableSurfaces.delete(e)}},[e,t.dismissableSurfaces]),s}var Hg=()=>!0;function qg(t,e){const{ownerDocument:s=globalThis?.document,deferPointerDownOutside:n=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:o,shouldHandlePointerDownOutside:i=Hg}=e,a=Oe(t),c=b.useRef(!1),l=b.useRef(!1),u=b.useRef(new Map),d=b.useRef(()=>{});return b.useEffect(()=>{function f(){l.current=!1,r.current=!1,u.current.clear()}function h(){return Array.from(u.current.values()).some(Boolean)}function m(S){if(!l.current)return;const y=S.target;y instanceof Node&&[...o].some(E=>E.contains(y))||u.current.set(S.type,!0),S.type==="click"&&window.setTimeout(()=>{l.current&&d.current()},0)}function p(S){l.current&&u.current.set(S.type,!1)}const g=S=>{if(S.target&&!c.current){let y=function(){s.removeEventListener("click",d.current);const E=h();f(),E||Ya(jg,a,x,{discrete:!0})};if(!i(S.target)){s.removeEventListener("click",d.current),f(),c.current=!1;return}const x={originalEvent:S};l.current=!0,r.current=n&&S.button===0,u.current.clear(),!n||S.button!==0?y():(s.removeEventListener("click",d.current),d.current=y,s.addEventListener("click",d.current,{once:!0}))}else s.removeEventListener("click",d.current),f();c.current=!1},_=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const S of _)s.addEventListener(S,m,!0),s.addEventListener(S,p);const C=window.setTimeout(()=>{s.addEventListener("pointerdown",g)},0);return()=>{window.clearTimeout(C),s.removeEventListener("pointerdown",g),s.removeEventListener("click",d.current);for(const S of _)s.removeEventListener(S,m,!0),s.removeEventListener(S,p)}},[s,a,n,r,o,i]),{onPointerDownCapture:()=>c.current=!0}}function zg(t,e=globalThis?.document){const s=Oe(t),n=b.useRef(!1);return b.useEffect(()=>{const r=o=>{o.target&&!n.current&&Ya(Bg,s,{originalEvent:o},{discrete:!1})};return e.addEventListener("focusin",r),()=>e.removeEventListener("focusin",r)},[e,s]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function ho(){const t=new CustomEvent(bn);document.dispatchEvent(t)}function Ya(t,e,s,{discrete:n}){const r=s.originalEvent.target,o=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:s});e&&r.addEventListener(t,e,{once:!0}),n?Xp(r,o):r.dispatchEvent(o)}var Ks="focusScope.autoFocusOnMount",Ys="focusScope.autoFocusOnUnmount",mo={bubbles:!1,cancelable:!0},Wg="FocusScope",Qa=b.forwardRef((t,e)=>{const{loop:s=!1,trapped:n=!1,onMountAutoFocus:r,onUnmountAutoFocus:o,...i}=t,[a,c]=b.useState(null),l=Oe(r),u=Oe(o),d=b.useRef(null),f=ae(e,c),h=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(n){let p=function(S){if(h.paused||!a)return;const y=S.target;a.contains(y)?d.current=y:Ne(d.current,{select:!0})},g=function(S){if(h.paused||!a)return;const y=S.relatedTarget;y!==null&&(a.contains(y)||Ne(d.current,{select:!0}))},_=function(S){if(document.activeElement===document.body)for(const x of S)x.removedNodes.length>0&&Ne(a)};document.addEventListener("focusin",p),document.addEventListener("focusout",g);const C=new MutationObserver(_);return a&&C.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",g),C.disconnect()}}},[n,a,h.paused]),b.useEffect(()=>{if(a){go.add(h);const p=document.activeElement;if(!a.contains(p)){const _=new CustomEvent(Ks,mo);a.addEventListener(Ks,l),a.dispatchEvent(_),_.defaultPrevented||(Gg(Xg(Ja(a)),{select:!0}),document.activeElement===p&&Ne(a))}return()=>{a.removeEventListener(Ks,l),setTimeout(()=>{const _=new CustomEvent(Ys,mo);a.addEventListener(Ys,u),a.dispatchEvent(_),_.defaultPrevented||Ne(p??document.body,{select:!0}),a.removeEventListener(Ys,u),go.remove(h)},0)}}},[a,l,u,h]);const m=b.useCallback(p=>{if(!s&&!n||h.paused)return;const g=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,_=document.activeElement;if(g&&_){const C=p.currentTarget,[S,y]=Kg(C);S&&y?!p.shiftKey&&_===y?(p.preventDefault(),s&&Ne(S,{select:!0})):p.shiftKey&&_===S&&(p.preventDefault(),s&&Ne(y,{select:!0})):_===C&&p.preventDefault()}},[s,n,h.paused]);return v.jsx(Ae.div,{tabIndex:-1,...i,ref:f,onKeyDown:m})});Qa.displayName=Wg;function Gg(t,{select:e=!1}={}){const s=document.activeElement;for(const n of t)if(Ne(n,{select:e}),document.activeElement!==s)return}function Kg(t){const e=Ja(t),s=po(e,t),n=po(e.reverse(),t);return[s,n]}function Ja(t){const e=[],s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const r=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||r?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)e.push(s.currentNode);return e}function po(t,e){const s=typeof e.checkVisibility=="function"&&e.checkVisibility({checkVisibilityCSS:!0});for(const n of t)if(!(s?!n.checkVisibility({checkVisibilityCSS:!0}):Yg(n,{upTo:e})))return n}function Yg(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function Qg(t){return t instanceof HTMLInputElement&&"select"in t}function Ne(t,{select:e=!1}={}){if(t&&t.focus){const s=document.activeElement;t.focus({preventScroll:!0}),t!==s&&Qg(t)&&e&&t.select()}}var go=Jg();function Jg(){let t=[];return{add(e){const s=t[0];e!==s&&s?.pause(),t=vo(t,e),t.unshift(e)},remove(e){t=vo(t,e),t[0]?.resume()}}}function vo(t,e){const s=[...t],n=s.indexOf(e);return n!==-1&&s.splice(n,1),s}function Xg(t){return t.filter(e=>e.tagName!=="A")}var Zg="Portal",Xa=b.forwardRef((t,e)=>{const{container:s,...n}=t,[r,o]=b.useState(!1);kt(()=>o(!0),[]);const i=s||r&&globalThis?.document?.body;return i?Xn.createPortal(v.jsx(Ae.div,{...n,ref:e}),i):null});Xa.displayName=Zg;var Wt=0,ot=null;function ev(){b.useEffect(()=>{ot||(ot={start:bo(),end:bo()});const{start:t,end:e}=ot;return document.body.firstElementChild!==t&&document.body.insertAdjacentElement("afterbegin",t),document.body.lastElementChild!==e&&document.body.insertAdjacentElement("beforeend",e),Wt++,()=>{Wt===1&&(ot?.start.remove(),ot?.end.remove(),ot=null),Wt=Math.max(0,Wt-1)}},[])}function bo(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Ce=function(){return Ce=Object.assign||function(e){for(var s,n=1,r=arguments.length;n<r;n++){s=arguments[n];for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(e[o]=s[o])}return e},Ce.apply(this,arguments)};function Za(t,e){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(s[n[r]]=t[n[r]]);return s}function tv(t,e,s){if(s||arguments.length===2)for(var n=0,r=e.length,o;n<r;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))}var ts="right-scroll-bar-position",ss="width-before-scroll-bar",sv="with-scroll-bars-hidden",nv="--removed-body-scroll-bar-size";function Qs(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function rv(t,e){var s=b.useState(function(){return{value:t,callback:e,facade:{get current(){return s.value},set current(n){var r=s.value;r!==n&&(s.value=n,s.callback(n,r))}}}})[0];return s.callback=e,s.facade}var ov=typeof window<"u"?b.useLayoutEffect:b.useEffect,yo=new WeakMap;function iv(t,e){var s=rv(null,function(n){return t.forEach(function(r){return Qs(r,n)})});return ov(function(){var n=yo.get(s);if(n){var r=new Set(n),o=new Set(t),i=s.current;r.forEach(function(a){o.has(a)||Qs(a,null)}),o.forEach(function(a){r.has(a)||Qs(a,i)})}yo.set(s,t)},[t]),s}function av(t){return t}function cv(t,e){e===void 0&&(e=av);var s=[],n=!1,r={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:t},useMedium:function(o){var i=e(o,n);return s.push(i),function(){s=s.filter(function(a){return a!==i})}},assignSyncMedium:function(o){for(n=!0;s.length;){var i=s;s=[],i.forEach(o)}s={push:function(a){return o(a)},filter:function(){return s}}},assignMedium:function(o){n=!0;var i=[];if(s.length){var a=s;s=[],a.forEach(o),i=s}var c=function(){var u=i;i=[],u.forEach(o)},l=function(){return Promise.resolve().then(c)};l(),s={push:function(u){i.push(u),l()},filter:function(u){return i=i.filter(u),s}}}};return r}function lv(t){t===void 0&&(t={});var e=cv(null);return e.options=Ce({async:!0,ssr:!1},t),e}var ec=function(t){var e=t.sideCar,s=Za(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=e.read();if(!n)throw new Error("Sidecar medium not found");return b.createElement(n,Ce({},s))};ec.isSideCarExport=!0;function uv(t,e){return t.useMedium(e),ec}var tc=lv(),Js=function(){},As=b.forwardRef(function(t,e){var s=b.useRef(null),n=b.useState({onScrollCapture:Js,onWheelCapture:Js,onTouchMoveCapture:Js}),r=n[0],o=n[1],i=t.forwardProps,a=t.children,c=t.className,l=t.removeScrollBar,u=t.enabled,d=t.shards,f=t.sideCar,h=t.noRelative,m=t.noIsolation,p=t.inert,g=t.allowPinchZoom,_=t.as,C=_===void 0?"div":_,S=t.gapMode,y=Za(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),x=f,E=iv([s,e]),I=Ce(Ce({},y),r);return b.createElement(b.Fragment,null,u&&b.createElement(x,{sideCar:tc,removeScrollBar:l,shards:d,noRelative:h,noIsolation:m,inert:p,setCallbacks:o,allowPinchZoom:!!g,lockRef:s,gapMode:S}),i?b.cloneElement(b.Children.only(a),Ce(Ce({},I),{ref:E})):b.createElement(C,Ce({},I,{className:c,ref:E}),a))});As.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};As.classNames={fullWidth:ss,zeroRight:ts};var dv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function fv(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=dv();return e&&t.setAttribute("nonce",e),t}function hv(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function mv(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var pv=function(){var t=0,e=null;return{add:function(s){t==0&&(e=fv())&&(hv(e,s),mv(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},gv=function(){var t=pv();return function(e,s){b.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&s])}},sc=function(){var t=gv(),e=function(s){var n=s.styles,r=s.dynamic;return t(n,r),null};return e},vv={left:0,top:0,right:0,gap:0},Xs=function(t){return parseInt(t||"",10)||0},bv=function(t){var e=window.getComputedStyle(document.body),s=e[t==="padding"?"paddingLeft":"marginLeft"],n=e[t==="padding"?"paddingTop":"marginTop"],r=e[t==="padding"?"paddingRight":"marginRight"];return[Xs(s),Xs(n),Xs(r)]},yv=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return vv;var e=bv(t),s=document.documentElement.clientWidth,n=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,n-s+e[2]-e[0])}},_v=sc(),ht="data-scroll-locked",Sv=function(t,e,s,n){var r=t.left,o=t.top,i=t.right,a=t.gap;return s===void 0&&(s="margin"),`
30
- .`.concat(sv,` {
31
- overflow: hidden `).concat(n,`;
32
- padding-right: `).concat(a,"px ").concat(n,`;
33
- }
34
- body[`).concat(ht,`] {
35
- overflow: hidden `).concat(n,`;
36
- overscroll-behavior: contain;
37
- `).concat([e&&"position: relative ".concat(n,";"),s==="margin"&&`
38
- padding-left: `.concat(r,`px;
39
- padding-top: `).concat(o,`px;
40
- padding-right: `).concat(i,`px;
41
- margin-left:0;
42
- margin-top:0;
43
- margin-right: `).concat(a,"px ").concat(n,`;
44
- `),s==="padding"&&"padding-right: ".concat(a,"px ").concat(n,";")].filter(Boolean).join(""),`
45
- }
46
-
47
- .`).concat(ts,` {
48
- right: `).concat(a,"px ").concat(n,`;
49
- }
50
-
51
- .`).concat(ss,` {
52
- margin-right: `).concat(a,"px ").concat(n,`;
53
- }
54
-
55
- .`).concat(ts," .").concat(ts,` {
56
- right: 0 `).concat(n,`;
57
- }
58
-
59
- .`).concat(ss," .").concat(ss,` {
60
- margin-right: 0 `).concat(n,`;
61
- }
62
-
63
- body[`).concat(ht,`] {
64
- `).concat(nv,": ").concat(a,`px;
65
- }
66
- `)},_o=function(){var t=parseInt(document.body.getAttribute(ht)||"0",10);return isFinite(t)?t:0},xv=function(){b.useEffect(function(){return document.body.setAttribute(ht,(_o()+1).toString()),function(){var t=_o()-1;t<=0?document.body.removeAttribute(ht):document.body.setAttribute(ht,t.toString())}},[])},wv=function(t){var e=t.noRelative,s=t.noImportant,n=t.gapMode,r=n===void 0?"margin":n;xv();var o=b.useMemo(function(){return yv(r)},[r]);return b.createElement(_v,{styles:Sv(o,!e,r,s?"":"!important")})},yn=!1;if(typeof window<"u")try{var Gt=Object.defineProperty({},"passive",{get:function(){return yn=!0,!0}});window.addEventListener("test",Gt,Gt),window.removeEventListener("test",Gt,Gt)}catch{yn=!1}var it=yn?{passive:!1}:!1,Cv=function(t){return t.tagName==="TEXTAREA"},nc=function(t,e){if(!(t instanceof Element))return!1;var s=window.getComputedStyle(t);return s[e]!=="hidden"&&!(s.overflowY===s.overflowX&&!Cv(t)&&s[e]==="visible")},Tv=function(t){return nc(t,"overflowY")},Ev=function(t){return nc(t,"overflowX")},So=function(t,e){var s=e.ownerDocument,n=e;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var r=rc(t,n);if(r){var o=oc(t,n),i=o[1],a=o[2];if(i>a)return!0}n=n.parentNode}while(n&&n!==s.body);return!1},Iv=function(t){var e=t.scrollTop,s=t.scrollHeight,n=t.clientHeight;return[e,s,n]},Rv=function(t){var e=t.scrollLeft,s=t.scrollWidth,n=t.clientWidth;return[e,s,n]},rc=function(t,e){return t==="v"?Tv(e):Ev(e)},oc=function(t,e){return t==="v"?Iv(e):Rv(e)},Av=function(t,e){return t==="h"&&e==="rtl"?-1:1},Pv=function(t,e,s,n,r){var o=Av(t,window.getComputedStyle(e).direction),i=o*n,a=s.target,c=e.contains(a),l=!1,u=i>0,d=0,f=0;do{if(!a)break;var h=oc(t,a),m=h[0],p=h[1],g=h[2],_=p-g-o*m;(m||_)&&rc(t,a)&&(d+=_,f+=m);var C=a.parentNode;a=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!c&&a!==document.body||c&&(e.contains(a)||e===a));return(u&&Math.abs(d)<1||!u&&Math.abs(f)<1)&&(l=!0),l},Kt=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},xo=function(t){return[t.deltaX,t.deltaY]},wo=function(t){return t&&"current"in t?t.current:t},Mv=function(t,e){return t[0]===e[0]&&t[1]===e[1]},Dv=function(t){return`
67
- .block-interactivity-`.concat(t,` {pointer-events: none;}
68
- .allow-interactivity-`).concat(t,` {pointer-events: all;}
69
- `)},Ov=0,at=[];function kv(t){var e=b.useRef([]),s=b.useRef([0,0]),n=b.useRef(),r=b.useState(Ov++)[0],o=b.useState(sc)[0],i=b.useRef(t);b.useEffect(function(){i.current=t},[t]),b.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(r));var p=tv([t.lockRef.current],(t.shards||[]).map(wo),!0).filter(Boolean);return p.forEach(function(g){return g.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),p.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(r))})}}},[t.inert,t.lockRef.current,t.shards]);var a=b.useCallback(function(p,g){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!i.current.allowPinchZoom;var _=Kt(p),C=s.current,S="deltaX"in p?p.deltaX:C[0]-_[0],y="deltaY"in p?p.deltaY:C[1]-_[1],x,E=p.target,I=Math.abs(S)>Math.abs(y)?"h":"v";if("touches"in p&&I==="h"&&E.type==="range")return!1;var R=window.getSelection(),P=R&&R.anchorNode,k=P?P===E||P.contains(E):!1;if(k)return!1;var O=So(I,E);if(!O)return!0;if(O?x=I:(x=I==="v"?"h":"v",O=So(I,E)),!O)return!1;if(!n.current&&"changedTouches"in p&&(S||y)&&(n.current=x),!x)return!0;var $=n.current||x;return Pv($,g,p,$==="h"?S:y)},[]),c=b.useCallback(function(p){var g=p;if(!(!at.length||at[at.length-1]!==o)){var _="deltaY"in g?xo(g):Kt(g),C=e.current.filter(function(x){return x.name===g.type&&(x.target===g.target||g.target===x.shadowParent)&&Mv(x.delta,_)})[0];if(C&&C.should){g.cancelable&&g.preventDefault();return}if(!C){var S=(i.current.shards||[]).map(wo).filter(Boolean).filter(function(x){return x.contains(g.target)}),y=S.length>0?a(g,S[0]):!i.current.noIsolation;y&&g.cancelable&&g.preventDefault()}}},[]),l=b.useCallback(function(p,g,_,C){var S={name:p,delta:g,target:_,should:C,shadowParent:$v(_)};e.current.push(S),setTimeout(function(){e.current=e.current.filter(function(y){return y!==S})},1)},[]),u=b.useCallback(function(p){s.current=Kt(p),n.current=void 0},[]),d=b.useCallback(function(p){l(p.type,xo(p),p.target,a(p,t.lockRef.current))},[]),f=b.useCallback(function(p){l(p.type,Kt(p),p.target,a(p,t.lockRef.current))},[]);b.useEffect(function(){return at.push(o),t.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",c,it),document.addEventListener("touchmove",c,it),document.addEventListener("touchstart",u,it),function(){at=at.filter(function(p){return p!==o}),document.removeEventListener("wheel",c,it),document.removeEventListener("touchmove",c,it),document.removeEventListener("touchstart",u,it)}},[]);var h=t.removeScrollBar,m=t.inert;return b.createElement(b.Fragment,null,m?b.createElement(o,{styles:Dv(r)}):null,h?b.createElement(wv,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function $v(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const Nv=uv(tc,kv);var ic=b.forwardRef(function(t,e){return b.createElement(As,Ce({},t,{ref:e,sideCar:Nv}))});ic.classNames=As.classNames;var Lv=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},ct=new WeakMap,Yt=new WeakMap,Qt={},Zs=0,ac=function(t){return t&&(t.host||ac(t.parentNode))},jv=function(t,e){return e.map(function(s){if(t.contains(s))return s;var n=ac(s);return n&&t.contains(n)?n:(console.error("aria-hidden",s,"in not contained inside",t,". Doing nothing"),null)}).filter(function(s){return!!s})},Bv=function(t,e,s,n){var r=jv(e,Array.isArray(t)?t:[t]);Qt[s]||(Qt[s]=new WeakMap);var o=Qt[s],i=[],a=new Set,c=new Set(r),l=function(d){!d||a.has(d)||(a.add(d),l(d.parentNode))};r.forEach(l);var u=function(d){!d||c.has(d)||Array.prototype.forEach.call(d.children,function(f){if(a.has(f))u(f);else try{var h=f.getAttribute(n),m=h!==null&&h!=="false",p=(ct.get(f)||0)+1,g=(o.get(f)||0)+1;ct.set(f,p),o.set(f,g),i.push(f),p===1&&m&&Yt.set(f,!0),g===1&&f.setAttribute(s,"true"),m||f.setAttribute(n,"true")}catch(_){console.error("aria-hidden: cannot operate on ",f,_)}})};return u(e),a.clear(),Zs++,function(){i.forEach(function(d){var f=ct.get(d)-1,h=o.get(d)-1;ct.set(d,f),o.set(d,h),f||(Yt.has(d)||d.removeAttribute(n),Yt.delete(d)),h||d.removeAttribute(s)}),Zs--,Zs||(ct=new WeakMap,ct=new WeakMap,Yt=new WeakMap,Qt={})}},Fv=function(t,e,s){s===void 0&&(s="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),r=Lv(t);return r?(n.push.apply(n,Array.from(r.querySelectorAll("[aria-live], script"))),Bv(n,r,s,"aria-hidden")):function(){return null}},Ps="Dialog",[cc]=Ga(Ps),[Uv,xe]=cc(Ps),Vv=t=>{const{__scopeDialog:e,children:s,open:n,defaultOpen:r,onOpenChange:o,modal:i=!0}=t,a=b.useRef(null),c=b.useRef(null),[l,u]=Eg({prop:n,defaultProp:r??!1,onChange:o,caller:Ps});return v.jsx(Uv,{scope:e,triggerRef:a,contentRef:c,contentId:Gs(),titleId:Gs(),descriptionId:Gs(),open:l,onOpenChange:u,onOpenToggle:b.useCallback(()=>u(d=>!d),[u]),modal:i,children:s})};Vv.displayName=Ps;var lc="DialogTrigger",Hv=b.forwardRef((t,e)=>{const{__scopeDialog:s,...n}=t,r=xe(lc,s),o=ae(e,r.triggerRef);return v.jsx(Ae.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":tr(r.open),...n,ref:o,onClick:K(t.onClick,r.onOpenToggle)})});Hv.displayName=lc;var er="DialogPortal",[qv,uc]=cc(er,{forceMount:void 0}),zv=t=>{const{__scopeDialog:e,forceMount:s,children:n,container:r}=t,o=xe(er,e);return v.jsx(qv,{scope:e,forceMount:s,children:b.Children.map(n,i=>v.jsx(Rs,{present:s||o.open,children:v.jsx(Xa,{asChild:!0,container:r,children:i})}))})};zv.displayName=er;var gs="DialogOverlay",Wv=b.forwardRef((t,e)=>{const s=uc(gs,t.__scopeDialog),{forceMount:n=s.forceMount,...r}=t,o=xe(gs,t.__scopeDialog);return o.modal?v.jsx(Rs,{present:n||o.open,children:v.jsx(Kv,{...r,ref:e})}):null});Wv.displayName=gs;var Gv=Ot("DialogOverlay.RemoveScroll"),Kv=b.forwardRef((t,e)=>{const{__scopeDialog:s,...n}=t,r=xe(gs,s),o=Vg(),i=ae(e,o);return v.jsx(ic,{as:Gv,allowPinchZoom:!0,shards:[r.contentRef],children:v.jsx(Ae.div,{"data-state":tr(r.open),...n,ref:i,style:{pointerEvents:"auto",...n.style}})})}),vt="DialogContent",Yv=b.forwardRef((t,e)=>{const s=uc(vt,t.__scopeDialog),{forceMount:n=s.forceMount,...r}=t,o=xe(vt,t.__scopeDialog);return v.jsx(Rs,{present:n||o.open,children:o.modal?v.jsx(Qv,{...r,ref:e}):v.jsx(Jv,{...r,ref:e})})});Yv.displayName=vt;var Qv=b.forwardRef((t,e)=>{const s=xe(vt,t.__scopeDialog),n=b.useRef(null),r=ae(e,s.contentRef,n);return b.useEffect(()=>{const o=n.current;if(o)return Fv(o)},[]),v.jsx(dc,{...t,ref:r,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:K(t.onCloseAutoFocus,o=>{o.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:K(t.onPointerDownOutside,o=>{const i=o.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&o.preventDefault()}),onFocusOutside:K(t.onFocusOutside,o=>o.preventDefault())})}),Jv=b.forwardRef((t,e)=>{const s=xe(vt,t.__scopeDialog),n=b.useRef(!1),r=b.useRef(!1);return v.jsx(dc,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(n.current||s.triggerRef.current?.focus(),o.preventDefault()),n.current=!1,r.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const i=o.target;s.triggerRef.current?.contains(i)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&r.current&&o.preventDefault()}})}),dc=b.forwardRef((t,e)=>{const{__scopeDialog:s,trapFocus:n,onOpenAutoFocus:r,onCloseAutoFocus:o,...i}=t,a=xe(vt,s);return ev(),v.jsx(v.Fragment,{children:v.jsx(Qa,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:r,onUnmountAutoFocus:o,children:v.jsx(Ka,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":tr(a.open),...i,ref:e,deferPointerDownOutside:!0,onDismiss:()=>a.onOpenChange(!1)})})})}),fc="DialogTitle",Xv=b.forwardRef((t,e)=>{const{__scopeDialog:s,...n}=t,r=xe(fc,s);return v.jsx(Ae.h2,{id:r.titleId,...n,ref:e})});Xv.displayName=fc;var hc="DialogDescription",Zv=b.forwardRef((t,e)=>{const{__scopeDialog:s,...n}=t,r=xe(hc,s);return v.jsx(Ae.p,{id:r.descriptionId,...n,ref:e})});Zv.displayName=hc;var mc="DialogClose",eb=b.forwardRef((t,e)=>{const{__scopeDialog:s,...n}=t,r=xe(mc,s);return v.jsx(Ae.button,{type:"button",...n,ref:e,onClick:K(t.onClick,()=>r.onOpenChange(!1))})});eb.displayName=mc;function tr(t){return t?"open":"closed"}const tb=["top","right","bottom","left"],bt=Math.min,Me=Math.max,vs=Math.round,Jt=Math.floor,De=t=>({x:t,y:t}),sb={left:"right",right:"left",bottom:"top",top:"bottom"};function nb(t,e,s){return Me(t,bt(e,s))}function je(t,e){return typeof t=="function"?t(e):t}function Be(t){return t.split("-")[0]}function jt(t){return t.split("-")[1]}function sr(t){return t==="x"?"y":"x"}function pc(t){return t==="y"?"height":"width"}function Ee(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function gc(t){return sr(Ee(t))}function rb(t,e,s){s===void 0&&(s=!1);const n=jt(t),r=gc(t),o=pc(r);let i=r==="x"?n===(s?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(i=bs(i)),[i,bs(i)]}function ob(t){const e=bs(t);return[_n(t),e,_n(e)]}function _n(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const Co=["left","right"],To=["right","left"],ib=["top","bottom"],ab=["bottom","top"];function cb(t,e,s){switch(t){case"top":case"bottom":return s?e?To:Co:e?Co:To;case"left":case"right":return e?ib:ab;default:return[]}}function lb(t,e,s,n){const r=jt(t);let o=cb(Be(t),s==="start",n);return r&&(o=o.map(i=>i+"-"+r),e&&(o=o.concat(o.map(_n)))),o}function bs(t){const e=Be(t);return sb[e]+t.slice(e.length)}function ub(t){var e,s,n,r;return{top:(e=t.top)!=null?e:0,right:(s=t.right)!=null?s:0,bottom:(n=t.bottom)!=null?n:0,left:(r=t.left)!=null?r:0}}function db(t){return typeof t!="number"?ub(t):{top:t,right:t,bottom:t,left:t}}function ys(t){const{x:e,y:s,width:n,height:r}=t;return{width:n,height:r,top:s,left:e,right:e+n,bottom:s+r,x:e,y:s}}function Eo(t,e,s){let{reference:n,floating:r}=t;const o=Ee(e),i=gc(e),a=pc(i),c=Be(e),l=o==="y",u=n.x+n.width/2-r.width/2,d=n.y+n.height/2-r.height/2,f=n[a]/2-r[a]/2;let h;switch(c){case"top":h={x:u,y:n.y-r.height};break;case"bottom":h={x:u,y:n.y+n.height};break;case"right":h={x:n.x+n.width,y:d};break;case"left":h={x:n.x-r.width,y:d};break;default:h={x:n.x,y:n.y}}const m=jt(e);return m&&(h[i]+=f*(m==="end"?1:-1)*(s&&l?-1:1)),h}async function fb(t,e){var s;e===void 0&&(e={});const{x:n,y:r,platform:o,rects:i,elements:a,strategy:c}=t,{boundary:l="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=je(e,t),m=db(h),g=a[f?d==="floating"?"reference":"floating":d],_=ys(await o.getClippingRect({element:(s=await(o.isElement==null?void 0:o.isElement(g)))==null||s?g:g.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:l,rootBoundary:u,strategy:c})),C=d==="floating"?{x:n,y:r,width:i.floating.width,height:i.floating.height}:i.reference,S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),y=await(o.isElement==null?void 0:o.isElement(S))&&await(o.getScale==null?void 0:o.getScale(S))||{x:1,y:1},x=ys(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:C,offsetParent:S,strategy:c}):C);return{top:(_.top-x.top+m.top)/y.y,bottom:(x.bottom-_.bottom+m.bottom)/y.y,left:(_.left-x.left+m.left)/y.x,right:(x.right-_.right+m.right)/y.x}}const hb=50,mb=async(t,e,s)=>{const{placement:n="bottom",strategy:r="absolute",middleware:o=[],platform:i}=s,a=i.detectOverflow?i:{...i,detectOverflow:fb},c=await(i.isRTL==null?void 0:i.isRTL(e));let l=await i.getElementRects({reference:t,floating:e,strategy:r}),{x:u,y:d}=Eo(l,n,c),f=n,h=0;const m={};for(let p=0;p<o.length;p++){const g=o[p];if(!g)continue;const{name:_,fn:C}=g,{x:S,y,data:x,reset:E}=await C({x:u,y:d,initialPlacement:n,placement:f,strategy:r,middlewareData:m,rects:l,platform:a,elements:{reference:t,floating:e}});u=S??u,d=y??d,m[_]={...m[_],...x},E&&h<hb&&(h++,typeof E=="object"&&(E.placement&&(f=E.placement),E.rects&&(l=E.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:r}):E.rects),{x:u,y:d}=Eo(l,f,c)),p=-1)}return{x:u,y:d,placement:f,strategy:r,middlewareData:m}},pb=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var s,n;const{placement:r,middlewareData:o,rects:i,initialPlacement:a,platform:c,elements:l}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:p=!0,...g}=je(t,e);if((s=o.arrow)!=null&&s.alignmentOffset)return{};const _=Be(r),C=Ee(a),S=Be(a)===a,y=await(c.isRTL==null?void 0:c.isRTL(l.floating)),x=f||(S||!p?[bs(a)]:ob(a)),E=m!=="none";!f&&E&&x.push(...lb(a,p,m,y));const I=[a,...x],R=await c.detectOverflow(e,g),P=[];let k=((n=o.flip)==null?void 0:n.overflows)||[];if(u&&P.push(R[_]),d){const B=rb(r,i,y);P.push(R[B[0]],R[B[1]])}if(k=[...k,{placement:r,overflows:P}],!P.every(B=>B<=0)){var O,$;const B=(((O=o.flip)==null?void 0:O.index)||0)+1,U=I[B];if(U&&(!(d==="alignment"?C!==Ee(U):!1)||k.every(j=>Ee(j.placement)===C?j.overflows[0]>0:!0)))return{data:{index:B,overflows:k},reset:{placement:U}};let V=($=k.filter(Q=>Q.overflows[0]<=0).sort((Q,j)=>Q.overflows[1]-j.overflows[1])[0])==null?void 0:$.placement;if(!V)switch(h){case"bestFit":{var M;const Q=(M=k.filter(j=>{if(E){const Z=Ee(j.placement);return Z===C||Z==="y"}return!0}).map(j=>[j.placement,j.overflows.filter(Z=>Z>0).reduce((Z,w)=>Z+w,0)]).sort((j,Z)=>j[1]-Z[1])[0])==null?void 0:M[0];Q&&(V=Q);break}case"initialPlacement":V=a;break}if(r!==V)return{reset:{placement:V}}}return{}}}};function Io(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Ro(t){return tb.some(e=>t[e]>=0)}const gb=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:s,platform:n}=e,{strategy:r="referenceHidden",...o}=je(t,e);switch(r){case"referenceHidden":{const i=await n.detectOverflow(e,{...o,elementContext:"reference"}),a=Io(i,s.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Ro(a)}}}case"escaped":{const i=await n.detectOverflow(e,{...o,altBoundary:!0}),a=Io(i,s.floating);return{data:{escapedOffsets:a,escaped:Ro(a)}}}default:return{}}}}},vc=new Set(["left","top"]);async function vb(t,e){const{placement:s,platform:n,elements:r}=t,o=await(n.isRTL==null?void 0:n.isRTL(r.floating)),i=Be(s),a=jt(s),c=Ee(s)==="y",l=vc.has(i)?-1:1,u=o&&c?-1:1,d=je(e,t);let{mainAxis:f,crossAxis:h,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof m=="number"&&(h=a==="end"?m*-1:m),c?{x:h*u,y:f*l}:{x:f*l,y:h*u}}const bb=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var s,n;const{x:r,y:o,placement:i,middlewareData:a}=e,c=await vb(e,t);return i===((s=a.offset)==null?void 0:s.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:r+c.x,y:o+c.y,data:{...c,placement:i}}}}},yb=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:s,y:n,placement:r,platform:o}=e,{mainAxis:i=!0,crossAxis:a=!1,limiter:c={fn:C=>{let{x:S,y}=C;return{x:S,y}}},...l}=je(t,e),u={x:s,y:n},d=await o.detectOverflow(e,l),f=Ee(r),h=sr(f);let m=u[h],p=u[f];const g=(C,S)=>nb(S+d[C==="y"?"top":"left"],S,S-d[C==="y"?"bottom":"right"]);i&&(m=g(h,m)),a&&(p=g(f,p));const _=c.fn({...e,[h]:m,[f]:p});return{..._,data:{x:_.x-s,y:_.y-n,enabled:{[h]:i,[f]:a}}}}}},_b=function(t){return t===void 0&&(t={}),{options:t,fn(e){var s,n;const{x:r,y:o,placement:i,rects:a,middlewareData:c}=e,{offset:l=0,mainAxis:u=!0,crossAxis:d=!0}=je(t,e),f={x:r,y:o},h=Ee(i),m=sr(h);let p=f[m],g=f[h];const _=je(l,e),C=typeof _=="number"?{mainAxis:_,crossAxis:0}:{mainAxis:(s=_.mainAxis)!=null?s:0,crossAxis:(n=_.crossAxis)!=null?n:0};if(u){const x=m==="y"?"height":"width",E=a.reference[m]-a.floating[x]+C.mainAxis,I=a.reference[m]+a.reference[x]-C.mainAxis;p<E?p=E:p>I&&(p=I)}if(d){var S,y;const x=m==="y"?"width":"height",E=vc.has(Be(i)),I=a.reference[h]-a.floating[x]+(E&&((S=c.offset)==null?void 0:S[h])||0)+(E?0:C.crossAxis),R=a.reference[h]+a.reference[x]+(E?0:((y=c.offset)==null?void 0:y[h])||0)-(E?C.crossAxis:0);g<I?g=I:g>R&&(g=R)}return{[m]:p,[h]:g}}}},Sb=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){const{placement:s,rects:n,platform:r,elements:o}=e,{apply:i=()=>{},...a}=je(t,e),c=await r.detectOverflow(e,a),l=Be(s),u=jt(s),d=Ee(s)==="y",{width:f,height:h}=n.floating;let m,p;l==="top"||l==="bottom"?(m=l,p=u===(await(r.isRTL==null?void 0:r.isRTL(o.floating))?"start":"end")?"left":"right"):(p=l,m=u==="end"?"top":"bottom");const g=h-c.top-c.bottom,_=f-c.left-c.right,C=bt(h-c[m],g),S=bt(f-c[p],_),y=e.middlewareData.shift,x=!y;let E=C,I=S;y!=null&&y.enabled.x&&(I=_),y!=null&&y.enabled.y&&(E=g),x&&!u&&(d?I=f-2*Me(c.left,c.right):E=h-2*Me(c.top,c.bottom)),await i({...e,availableWidth:I,availableHeight:E});const R=await r.getDimensions(o.floating);return f!==R.width||h!==R.height?{reset:{rects:!0}}:{}}}};function Ms(){return typeof window<"u"}function xt(t){return bc(t)?(t.nodeName||"").toLowerCase():"#document"}function de(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ke(t){var e;return(e=(bc(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function bc(t){return Ms()?t instanceof Node||t instanceof de(t).Node:!1}function Ie(t){return Ms()?t instanceof Element||t instanceof de(t).Element:!1}function Ve(t){return Ms()?t instanceof HTMLElement||t instanceof de(t).HTMLElement:!1}function Ao(t){return!Ms()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof de(t).ShadowRoot}function Ds(t){const{overflow:e,overflowX:s,overflowY:n,display:r}=Re(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+s)&&r!=="inline"&&r!=="contents"}function xb(t){return/^(table|td|th)$/.test(xt(t))}function Os(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const wb=/transform|translate|scale|rotate|perspective|filter/,Cb=/paint|layout|strict|content/,We=t=>!!t&&t!=="none";let en;function nr(t){const e=Ie(t)?Re(t):t;return We(e.transform)||We(e.translate)||We(e.scale)||We(e.rotate)||We(e.perspective)||!rr()&&(We(e.backdropFilter)||We(e.filter))||wb.test(e.willChange||"")||Cb.test(e.contain||"")}function Tb(t){let e=Xe(t);for(;Ve(e)&&!$t(e);){if(nr(e))return e;if(Os(e))return null;e=Xe(e)}return null}function rr(){return en==null&&(en=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),en}function $t(t){return/^(html|body|#document)$/.test(xt(t))}function Re(t){return de(t).getComputedStyle(t)}function ks(t){return Ie(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Xe(t){if(xt(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Ao(t)&&t.host||ke(t);return Ao(e)?e.host:e}function yc(t){const e=Xe(t);return $t(e)?(t.ownerDocument||t).body:Ve(e)&&Ds(e)?e:yc(e)}function Nt(t,e,s){var n;e===void 0&&(e=[]),s===void 0&&(s=!0);const r=yc(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),i=de(r);if(o){const a=Sn(i);return e.concat(i,i.visualViewport||[],Ds(r)?r:[],a&&s?Nt(a):[])}else return e.concat(r,Nt(r,[],s))}function Sn(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function _c(t){const e=Re(t);let s=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const r=Ve(t),o=r?t.offsetWidth:s,i=r?t.offsetHeight:n,a=vs(s)!==o||vs(n)!==i;return a&&(s=o,n=i),{width:s,height:n,$:a}}function or(t){return Ie(t)?t:t.contextElement}function mt(t){const e=or(t);if(!Ve(e))return De(1);const s=e.getBoundingClientRect(),{width:n,height:r,$:o}=_c(e);let i=(o?vs(s.width):s.width)/n,a=(o?vs(s.height):s.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Eb=De(0);function Sc(t){const e=de(t);return!rr()||!e.visualViewport?Eb:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Ib(t,e,s){return e===void 0&&(e=!1),!!s&&e&&s===de(t)}function Ze(t,e,s,n){e===void 0&&(e=!1),s===void 0&&(s=!1);const r=t.getBoundingClientRect(),o=or(t);let i=De(1);e&&(n?Ie(n)&&(i=mt(n)):i=mt(t));const a=Ib(o,s,n)?Sc(o):De(0);let c=(r.left+a.x)/i.x,l=(r.top+a.y)/i.y,u=r.width/i.x,d=r.height/i.y;if(o&&n){const f=de(o),h=Ie(n)?de(n):n;let m=f,p=Sn(m);for(;p&&h!==m;){const g=mt(p),_=p.getBoundingClientRect(),C=Re(p),S=_.left+(p.clientLeft+parseFloat(C.paddingLeft))*g.x,y=_.top+(p.clientTop+parseFloat(C.paddingTop))*g.y;c*=g.x,l*=g.y,u*=g.x,d*=g.y,c+=S,l+=y,m=de(p),p=Sn(m)}}return ys({width:u,height:d,x:c,y:l})}function $s(t,e){const s=ks(t).scrollLeft;return e?e.left+s:Ze(ke(t)).left+s}function xc(t,e){const s=t.getBoundingClientRect(),n=s.left+e.scrollLeft-$s(t,s),r=s.top+e.scrollTop;return{x:n,y:r}}function Rb(t){let{elements:e,rect:s,offsetParent:n,strategy:r}=t;const o=r==="fixed",i=ke(n),a=e?Os(e.floating):!1;if(n===i||a&&o)return s;let c={scrollLeft:0,scrollTop:0},l=De(1);const u=De(0),d=Ve(n);if((d||!o)&&((xt(n)!=="body"||Ds(i))&&(c=ks(n)),d)){const h=Ze(n);l=mt(n),u.x=h.x+n.clientLeft,u.y=h.y+n.clientTop}const f=i&&!d&&!o?xc(i,c):De(0);return{width:s.width*l.x,height:s.height*l.y,x:s.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:s.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Ab(t){return t.getClientRects?Array.from(t.getClientRects()):[]}function Pb(t){const e=ks(t),s=t.ownerDocument.body,n=Me(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),r=Me(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let o=-e.scrollLeft+$s(t);const i=-e.scrollTop;return Re(s).direction==="rtl"&&(o+=Me(t.clientWidth,s.clientWidth)-n),{width:n,height:r,x:o,y:i}}const Mb=25;function Db(t,e,s){s===void 0&&(s="viewport");const n=s==="layoutViewport",r=de(t),o=ke(t),i=r.visualViewport;let a=o.clientWidth,c=o.clientHeight,l=0,u=0;if(i){const f=!rr()||e==="fixed";n?f||(l=-i.offsetLeft,u=-i.offsetTop):(a=i.width,c=i.height,f&&(l=i.offsetLeft,u=i.offsetTop))}if($s(o)<=0){const f=o.ownerDocument,h=f.body,m=getComputedStyle(h),p=f.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(o.clientWidth-h.clientWidth-p),_=getComputedStyle(o).scrollbarGutter==="stable both-edges"?g/2:g;_<=Mb&&(a-=_)}return{width:a,height:c,x:l,y:u}}function Ob(t,e){const s=Ze(t,!0,e==="fixed"),n=s.top+t.clientTop,r=s.left+t.clientLeft,o=mt(t),i=t.clientWidth*o.x,a=t.clientHeight*o.y,c=r*o.x,l=n*o.y;return{width:i,height:a,x:c,y:l}}function Po(t,e,s){let n;if(e==="viewport"||e==="layoutViewport")n=Db(t,s,e);else if(e==="document")n=Pb(ke(t));else if(Ie(e))n=Ob(e,s);else{const r=Sc(t);n={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return ys(n)}function kb(t,e){const s=e.get(t);if(s)return s;let n=Nt(t,[],!1).filter(a=>Ie(a)&&xt(a)!=="body"),r=null;const o=Re(t).position==="fixed";let i=o?Xe(t):t;for(;Ie(i)&&!$t(i);){const a=Re(i),c=nr(i),l=r?r.position:o?"fixed":"";!c&&(l==="fixed"||l==="absolute"&&a.position==="static")?n=n.filter(d=>d!==i):r=a,i=Xe(i)}return e.set(t,n),n}function $b(t){let{element:e,boundary:s,rootBoundary:n,strategy:r}=t;const i=[...s==="clippingAncestors"?Os(e)?[]:kb(e,this._c):[].concat(s),n],a=Po(e,i[0],r);let c=a.top,l=a.right,u=a.bottom,d=a.left;for(let f=1;f<i.length;f++){const h=Po(e,i[f],r);c=Me(h.top,c),l=bt(h.right,l),u=bt(h.bottom,u),d=Me(h.left,d)}return{width:l-d,height:u-c,x:d,y:c}}function Nb(t){const{width:e,height:s}=_c(t);return{width:e,height:s}}function Lb(t,e,s){const n=Ve(e),r=ke(e),o=s==="fixed",i=Ze(t,!0,o,e);let a={scrollLeft:0,scrollTop:0};const c=De(0);if((n||!o)&&((xt(e)!=="body"||Ds(r))&&(a=ks(e)),n)){const f=Ze(e,!0,o,e);c.x=f.x+e.clientLeft,c.y=f.y+e.clientTop}!n&&r&&(c.x=$s(r));const l=r&&!n&&!o?xc(r,a):De(0),u=i.left+a.scrollLeft-c.x-l.x,d=i.top+a.scrollTop-c.y-l.y;return{x:u,y:d,width:i.width,height:i.height}}function tn(t){return Re(t).position==="static"}function Mo(t,e){if(!Ve(t)||Re(t).position==="fixed")return null;if(e)return e(t);let s=t.offsetParent;return ke(t)===s&&(s=s.ownerDocument.body),s}function wc(t,e){const s=de(t);if(Os(t))return s;if(!Ve(t)){let r=Xe(t);for(;r&&!$t(r);){if(Ie(r)&&!tn(r))return r;r=Xe(r)}return s}let n=Mo(t,e);for(;n&&xb(n)&&tn(n);)n=Mo(n,e);return n&&$t(n)&&tn(n)&&!nr(n)?s:n||Tb(t)||s}const jb=async function(t){const e=this.getOffsetParent||wc,s=this.getDimensions,n=await s(t.floating);return{reference:Lb(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Bb(t){return Re(t).direction==="rtl"}const Fb={convertOffsetParentRelativeRectToViewportRelativeRect:Rb,getDocumentElement:ke,getClippingRect:$b,getOffsetParent:wc,getElementRects:jb,getClientRects:Ab,getDimensions:Nb,getScale:mt,isElement:Ie,isRTL:Bb};function Cc(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Ub(t,e,s){let n=null,r;const o=ke(t);function i(){var u;clearTimeout(r),(u=n)==null||u.disconnect(),n=null}function a(u,d){u===void 0&&(u=!1),d===void 0&&(d=1),i();const f=t.getBoundingClientRect(),{left:h,top:m,width:p,height:g}=f;if(u||e(),!p||!g)return;const _=Jt(m),C=Jt(o.clientWidth-(h+p)),S=Jt(o.clientHeight-(m+g)),y=Jt(h),E={rootMargin:-_+"px "+-C+"px "+-S+"px "+-y+"px",threshold:Me(0,bt(1,d))||1};let I=!0;function R(P){const k=P[0].intersectionRatio;if(!Cc(f,t.getBoundingClientRect()))return a();if(k!==d){if(!I)return a();k?a(!1,k):r=setTimeout(()=>{a(!1,1e-7)},1e3)}I=!1}try{n=new IntersectionObserver(R,{...E,root:o.ownerDocument})}catch{n=new IntersectionObserver(R,E)}n.observe(t)}const c=de(t),l=()=>a(s);return c.addEventListener("resize",l),a(!0),()=>{c.removeEventListener("resize",l),i()}}function q1(t,e,s,n){n===void 0&&(n={});const{ancestorScroll:r=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,l=or(t),u=r||o?[...l?Nt(l):[],...e?Nt(e):[]]:[];u.forEach(_=>{r&&_.addEventListener("scroll",s),o&&_.addEventListener("resize",s)});const d=l&&a?Ub(l,s,o):null;let f=-1,h=null;i&&(h=new ResizeObserver(_=>{let[C]=_;C&&C.target===l&&h&&e&&(h.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var S;(S=h)==null||S.observe(e)})),s()}),l&&!c&&h.observe(l),e&&h.observe(e));let m,p=c?Ze(t):null;c&&g();function g(){const _=Ze(t);p&&!Cc(p,_)&&s(),p=_,m=requestAnimationFrame(g)}return s(),()=>{var _;u.forEach(C=>{r&&C.removeEventListener("scroll",s),o&&C.removeEventListener("resize",s)}),d?.(),(_=h)==null||_.disconnect(),h=null,c&&cancelAnimationFrame(m)}}const Vb=bb,Hb=yb,qb=pb,zb=Sb,Wb=gb,Gb=_b,Kb=(t,e,s)=>{const n=new Map,r=s??{},o={...Fb,...r.platform,_c:n};return mb(t,e,{...r,platform:o})};var Yb=typeof document<"u",Qb=function(){},ns=Yb?b.useLayoutEffect:Qb;function _s(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let s,n,r;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(s=t.length,s!==e.length)return!1;for(n=s;n--!==0;)if(!_s(t[n],e[n]))return!1;return!0}if(r=Object.keys(t),s=r.length,s!==Object.keys(e).length)return!1;for(n=s;n--!==0;)if(!{}.hasOwnProperty.call(e,r[n]))return!1;for(n=s;n--!==0;){const o=r[n];if(!(o==="_owner"&&t.$$typeof)&&!_s(t[o],e[o]))return!1}return!0}return t!==t&&e!==e}function Tc(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Do(t,e){const s=Tc(t);return Math.round(e*s)/s}function sn(t){const e=b.useRef(t);return ns(()=>{e.current=t}),e}function z1(t){t===void 0&&(t={});const{placement:e="bottom",strategy:s="absolute",middleware:n=[],platform:r,elements:{reference:o,floating:i}={},transform:a=!0,whileElementsMounted:c,open:l}=t,[u,d]=b.useState({x:0,y:0,strategy:s,placement:e,middlewareData:{},isPositioned:!1}),[f,h]=b.useState(n);_s(f,n)||h(n);const[m,p]=b.useState(null),[g,_]=b.useState(null),C=b.useCallback(j=>{j!==E.current&&(E.current=j,p(j))},[]),S=b.useCallback(j=>{j!==I.current&&(I.current=j,_(j))},[]),y=o||m,x=i||g,E=b.useRef(null),I=b.useRef(null),R=b.useRef(u),P=c!=null,k=sn(c),O=sn(r),$=sn(l),M=b.useCallback(()=>{if(!E.current||!I.current)return;const j={placement:e,strategy:s,middleware:f};O.current&&(j.platform=O.current),Kb(E.current,I.current,j).then(Z=>{const w={...Z,isPositioned:$.current!==!1};B.current&&!_s(R.current,w)&&(R.current=w,Xn.flushSync(()=>{d(w)}))})},[f,e,s,O,$]);ns(()=>{l===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,d(j=>({...j,isPositioned:!1})))},[l]);const B=b.useRef(!1);ns(()=>(B.current=!0,()=>{B.current=!1}),[]),ns(()=>{if(y&&(E.current=y),x&&(I.current=x),y&&x){if(k.current)return k.current(y,x,M);M()}},[y,x,M,k,P]);const U=b.useMemo(()=>({reference:E,floating:I,setReference:C,setFloating:S}),[C,S]),V=b.useMemo(()=>({reference:y,floating:x}),[y,x]),Q=b.useMemo(()=>{const j={position:s,left:0,top:0};if(!V.floating)return j;const Z=Do(V.floating,u.x),w=Do(V.floating,u.y);return a?{...j,transform:"translate("+Z+"px, "+w+"px)",...Tc(V.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:Z,top:w}},[s,a,V.floating,u.x,u.y]);return b.useMemo(()=>({...u,update:M,refs:U,elements:V,floatingStyles:Q}),[u,M,U,V,Q])}const W1=(t,e)=>{const s=Vb(t);return{name:s.name,fn:s.fn,options:[t,e]}},G1=(t,e)=>{const s=Hb(t);return{name:s.name,fn:s.fn,options:[t,e]}},K1=(t,e)=>({fn:Gb(t).fn,options:[t,e]}),Y1=(t,e)=>{const s=qb(t);return{name:s.name,fn:s.fn,options:[t,e]}},Q1=(t,e)=>{const s=zb(t);return{name:s.name,fn:s.fn,options:[t,e]}},J1=(t,e)=>{const s=Wb(t);return{name:s.name,fn:s.fn,options:[t,e]}},Ec=b.forwardRef((t,e)=>{const s=T(3);let n;return s[0]!==t||s[1]!==e?(n=v.jsx(X.div,{...t,ref:e}),s[0]=t,s[1]=e,s[2]=n):n=s[2],n});Ec.displayName="AttachmentPrimitive.Root";const Ic=b.forwardRef((t,e)=>{const s=T(4),n=D(Jb);let r;return s[0]!==n||s[1]!==t||s[2]!==e?(r=v.jsxs(X.div,{...t,ref:e,children:[".",n]}),s[0]=n,s[1]=t,s[2]=e,s[3]=r):r=s[3],r});Ic.displayName="AttachmentPrimitive.unstable_Thumb";function Jb(t){const e=t.attachment.name.split(".");return e.length>1?e.pop():""}const Rc=()=>{const t=T(2),e=D(Xb);let s;return t[0]!==e?(s=v.jsx(v.Fragment,{children:e}),t[0]=e,t[1]=s):s=t[1],s};Rc.displayName="AttachmentPrimitive.Name";function Xb(t){return t.attachment.name}const Zb=()=>{const t=T(2),e=H();let s;return t[0]!==e?(s=()=>{e.attachment().remove()},t[0]=e,t[1]=s):s=t[1],s},ey=ce("AttachmentPrimitive.Remove",Zb);var X1=Ue({Name:()=>Rc,Remove:()=>ey,Root:()=>Ec,unstable_Thumb:()=>Ic});const ty=t=>{const e=T(12);let s;return e[0]!==t.assistant||e[1]!==t.copied||e[2]!==t.hasAttachments||e[3]!==t.hasBranches||e[4]!==t.hasContent||e[5]!==t.last||e[6]!==t.lastOrHover||e[7]!==t.speaking||e[8]!==t.submittedFeedback||e[9]!==t.system||e[10]!==t.user?(s=n=>{const{role:r,attachments:o,parts:i,branchCount:a,isLast:c,speech:l,isCopied:u,isHovering:d}=n.message;return!(t.hasBranches===!0&&a<2||t.user&&r!=="user"||t.assistant&&r!=="assistant"||t.system&&r!=="system"||t.lastOrHover===!0&&!d&&!c||t.last!==void 0&&t.last!==c||t.copied===!0&&!u||t.copied===!1&&u||t.speaking===!0&&l==null||t.speaking===!1&&l!=null||t.hasAttachments===!0&&(r!=="user"||!o?.length)||t.hasAttachments===!1&&r==="user"&&o?.length||t.hasContent===!0&&i.length===0||t.hasContent===!1&&i.length>0||t.submittedFeedback!==void 0&&(n.message.metadata.submittedFeedback?.type??null)!==t.submittedFeedback)},e[0]=t.assistant,e[1]=t.copied,e[2]=t.hasAttachments,e[3]=t.hasBranches,e[4]=t.hasContent,e[5]=t.last,e[6]=t.lastOrHover,e[7]=t.speaking,e[8]=t.submittedFeedback,e[9]=t.system,e[10]=t.user,e[11]=s):s=e[11],D(s)},Ac=t=>{const e=T(3);let s,n;return e[0]!==t?({children:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]),ty(n)?s:null};Ac.displayName="MessagePrimitive.If";const Pc=fe(null),Ns=()=>me(Pc),sy=t=>{const e=T(8),{children:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=new Map,e[0]=n):n=e[0];const r=W(n);let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[1]=o):o=e[1];const i=W(o);let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const g=Array.from(r.current.entries());g.sort(ny),i.current=g.map(ry)},e[2]=a):a=e[2];const c=a;let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=(g,_)=>{const C=_?.priority??0;return r.current.set(g,C),c(),()=>{r.current.delete(g),c()}},e[3]=l):l=e[3];const u=l;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=()=>i.current,e[4]=d):d=e[4];const f=d;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h={register:u,getPlugins:f},e[5]=h):h=e[5];const m=h;let p;return e[6]!==s?(p=v.jsx(Pc.Provider,{value:m,children:s}),e[6]=s,e[7]=p):p=e[7],p};function ny(t,e){return e[1]-t[1]}function ry(t){const[e]=t;return e}const ir=fe(null),Mc=fe(null),ar=()=>{const t=me(ir);if(!t)throw new Error("useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot");return t},cr=()=>me(ir),oy=()=>{const t=me(Mc);if(!t)throw new Error("useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot");return t},iy=()=>{const t=ar();return _t(t.subscribe,t.getTriggers,t.getTriggers)},ay=new Map,Dc=()=>()=>{},Oo=()=>ay,cy=()=>{const t=cr();return _t(t?t.subscribe:Dc,t?t.getTriggers:Oo,t?t.getTriggers:Oo)},ko=()=>null,ly=()=>{const t=cr();return _t(t?t.subscribeAria:Dc,t?t.getActiveAria:ko,t?t.getActiveAria:ko)};function $o(){const t=T(4);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=new Set,t[0]=e):e=t[0];const s=W(e);let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=()=>{for(const c of s.current)c()},t[1]=n):n=t[1];const r=n;let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=c=>(s.current.add(c),()=>{s.current.delete(c)}),t[2]=o):o=t[2];const i=o;let a;return t[3]===Symbol.for("react.memo_cache_sentinel")?(a={notify:r,subscribe:i},t[3]=a):a=t[3],a}const No=t=>{const e=T(21),{children:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=new Map,e[0]=n):n=e[0];const r=W(n);let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,e[1]=o):o=e[1];const i=W(o),{notify:a,subscribe:c}=$o();let l;e[2]!==a?(l=M=>{const{char:B}=M;if(r.current.has(B))return uy;const U=new Map(r.current);U.set(B,M),r.current=U,a();for(const V of i.current)V.added(M);return()=>{const V=new Map(r.current);V.delete(B),r.current=V,a();for(const Q of i.current)Q.removed(B)}},e[2]=a,e[3]=l):l=e[3];const u=l;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=()=>r.current,e[4]=d):d=e[4];const f=d;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=M=>(i.current.add(M),()=>{i.current.delete(M)}),e[5]=h):h=e[5];const m=h,p=W(null),g=W(null),{notify:_,subscribe:C}=$o();let S;e[6]!==_?(S=(M,B)=>{if(B===null){if(g.current!==M)return;p.current=null,g.current=null,_();return}const U=p.current;g.current===M&&U!==null&&U.popoverId===B.popoverId&&U.highlightedItemId===B.highlightedItemId||(p.current=B,g.current=M,_())},e[6]=_,e[7]=S):S=e[7];const y=S;let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=()=>p.current,e[8]=x):x=e[8];const E=x;let I;e[9]!==u||e[10]!==c||e[11]!==C?(I={register:u,getTriggers:f,subscribe:c,subscribeLifecycle:m,getActiveAria:E,subscribeAria:C},e[9]=u,e[10]=c,e[11]=C,e[12]=I):I=e[12];const R=I;let P;e[13]!==y?(P={setActiveAria:y},e[13]=y,e[14]=P):P=e[14];const k=P;let O;e[15]!==k||e[16]!==s?(O=v.jsx(Mc.Provider,{value:k,children:s}),e[15]=k,e[16]=s,e[17]=O):O=e[17];let $;return e[18]!==O||e[19]!==R?($=v.jsx(ir.Provider,{value:R,children:O}),e[18]=O,e[19]=R,e[20]=$):$=e[20],$},Oc=t=>{const e=T(4),{children:s}=t;if(Ns()){let r;return e[0]!==s?(r=v.jsx(No,{children:s}),e[0]=s,e[1]=r):r=e[1],r}let n;return e[2]!==s?(n=v.jsx(sy,{children:v.jsx(No,{children:s})}),e[2]=s,e[3]=n):n=e[3],n};Oc.displayName="ComposerPrimitive.TriggerPopoverRoot";function uy(){}const Lo=/\s/u;function dy(t,e,s){const n=t.slice(0,s);for(let r=n.length-1;r>=0;r--){const o=n[r];if(Lo.test(o))return null;if(n.startsWith(e,r)){if(r>0&&!Lo.test(n[r-1]))continue;return{query:n.slice(r+e.length),offset:r}}}return null}const fy=t=>{const e=T(7),{text:s,triggerChar:n}=t,[r,o]=ee(s.length),i=Math.min(r,s.length);let a;e[0]!==i||e[1]!==s||e[2]!==n?(a=dy(s,n,i),e[0]=i,e[1]=s,e[2]=n,e[3]=a):a=e[3];const c=a,l=c?.query??"";let u;return e[4]!==l||e[5]!==c?(u={trigger:c,query:l,setCursorPosition:o},e[4]=l,e[5]=c,e[6]=u):u=e[6],u},hy=Y(fy);function my(t){return"type"in t}const py=t=>{const e=T(25),{navigableList:s,isSearchMode:n,activeCategoryId:r,query:o,popoverId:i,open:a,selectItem:c,selectCategory:l,goBack:u,close:d}=t,[f,h]=ee(0);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{h(0)},e[0]=m):m=e[0];let p;e[1]!==s?(p=[s],e[1]=s,e[2]=p):p=e[2],q(m,p);let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{h(0)},e[3]=g):g=e[3];let _;e[4]!==r||e[5]!==n?(_=[n,r],e[4]=r,e[5]=n,e[6]=_):_=e[6],q(g,_);let C;e[7]!==f||e[8]!==s.length?(C=P=>{P<0||P>=s.length||P!==f&&h(P)},e[7]=f,e[8]=s.length,e[9]=C):C=e[9];const S=ye(C);let y;e[10]!==r||e[11]!==d||e[12]!==u||e[13]!==f||e[14]!==s||e[15]!==a||e[16]!==o||e[17]!==l||e[18]!==c?(y=P=>{if(!a)return!1;switch(P.key){case"ArrowDown":return P.preventDefault(),h(k=>{const O=s.length;return O===0?0:k<O-1?k+1:0}),!0;case"ArrowUp":return P.preventDefault(),h(k=>{const O=s.length;return O===0?0:k>0?k-1:O-1}),!0;case"Enter":case"Tab":{if(P.shiftKey)return!1;P.preventDefault();const k=s[f];return k&&(my(k)?c(k):l(k.id)),!0}case"Escape":return P.preventDefault(),d(),!0;case"Backspace":return r&&o===""?(P.preventDefault(),u(),!0):!1;default:return!1}},e[10]=r,e[11]=d,e[12]=u,e[13]=f,e[14]=s,e[15]=a,e[16]=o,e[17]=l,e[18]=c,e[19]=y):y=e[19];const x=ye(y),E=s[f],I=a&&E?`${i}-option-${E.id}`:void 0;let R;return e[20]!==x||e[21]!==S||e[22]!==f||e[23]!==I?(R={highlightedIndex:f,highlightedItemId:I,highlightIndex:S,handleKeyDown:x},e[20]=x,e[21]=S,e[22]=f,e[23]=I,e[24]=R):R=e[24],R},gy=Y(py);function jo(t,e){return t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e)||(t.description?.toLowerCase().includes(e)??!1)}const vy=t=>{const e=T(38),{adapter:s,query:n,open:r}=t,[o,i]=ee(null);let a,c;e[0]!==r?(a=()=>{r||i(null)},c=[r],e[0]=r,e[1]=a,e[2]=c):(a=e[1],c=e[2]),q(a,c);let l;e:{if(!r||!s){let M;e[3]===Symbol.for("react.memo_cache_sentinel")?(M=[],e[3]=M):M=e[3],l=M;break e}let $;e[4]!==s?($=s.categories(),e[4]=s,e[5]=$):$=e[5],l=$}const u=l,d=r?o:null;let f;e:{if(!d||!s){let M;e[6]===Symbol.for("react.memo_cache_sentinel")?(M=[],e[6]=M):M=e[6],f=M;break e}let $;e[7]!==s||e[8]!==d?($=s.categoryItems(d),e[7]=s,e[8]=d,e[9]=$):$=e[9],f=$}const h=f;let m;e:{if(!r||!s||d){m=null;break e}if(!n&&u.length>0){m=null;break e}if(s.search){let M;e[10]!==s||e[11]!==n?(M=s.search(n),e[10]=s,e[11]=n,e[12]=M):M=e[12],m=M;break e}let $;if(e[13]!==s||e[14]!==u||e[15]!==n){$=[];const M=n.toLowerCase();for(const B of u)for(const U of s.categoryItems(B.id))jo(U,M)&&$.push(U);e[13]=s,e[14]=u,e[15]=n,e[16]=$}else $=e[16];m=$}const p=m,g=p!==null;let _;e:{if(g){let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M=[],e[17]=M):M=e[17],_=M;break e}if(!n){_=u;break e}let $;if(e[18]!==u||e[19]!==n){const M=n.toLowerCase();$=u.filter(B=>B.label.toLowerCase().includes(M)),e[18]=u,e[19]=n,e[20]=$}else $=e[20];_=$}const C=_;let S;e:{if(g){let M;e[21]!==p?(M=p??[],e[21]=p,e[22]=M):M=e[22],S=M;break e}if(!n){S=h;break e}let $;if(e[23]!==h||e[24]!==n){const M=n.toLowerCase();$=h.filter(B=>jo(B,M)),e[23]=h,e[24]=n,e[25]=$}else $=e[25];S=$}const y=S;let x;e:{if(g){let $;e[26]!==p?($=p??[],e[26]=p,e[27]=$):$=e[27],x=$;break e}if(d){x=y;break e}x=C}const E=x;let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=$=>{i($)},e[28]=I):I=e[28];const R=ye(I);let P;e[29]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{i(null)},e[29]=P):P=e[29];const k=ye(P);let O;return e[30]!==d||e[31]!==C||e[32]!==y||e[33]!==k||e[34]!==g||e[35]!==E||e[36]!==R?(O={categories:C,items:y,isSearchMode:g,activeCategoryId:d,navigableList:E,selectCategory:R,goBack:k},e[30]=d,e[31]=C,e[32]=y,e[33]=k,e[34]=g,e[35]=E,e[36]=R,e[37]=O):O=e[37],O},by=Y(vy),yy=t=>{const e=T(15),{behavior:s,trigger:n,aui:r,triggerChar:o,setCursorPosition:i,onSelected:a}=t,c=W(null);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=g=>(c.current=g,()=>{c.current===g&&(c.current=null)}),e[0]=l):l=e[0];const u=ye(l);let d;e[1]!==r||e[2]!==s||e[3]!==a||e[4]!==n||e[5]!==o?(d=g=>{if(!n||!s)return;if(c.current?.(g)){a();return}const _=r.composer().getState().text,C=_.slice(0,n.offset),S=_.slice(n.offset+o.length+n.query.length),y=()=>{const x=s.formatter.serialize(g);r.composer().setText(C+x+(S.startsWith(" ")?S:` ${S}`))};s.kind==="directive"?(y(),s.onInserted?.(g)):(s.removeOnExecute?r.composer().setText(C+(S.startsWith(" ")?S.slice(1):S)):y(),s.onExecute(g)),a()},e[1]=r,e[2]=s,e[3]=a,e[4]=n,e[5]=o,e[6]=d):d=e[6];const f=ye(d);let h;e[7]!==a||e[8]!==i||e[9]!==n?(h=()=>{a(),n&&i(n.offset)},e[7]=a,e[8]=i,e[9]=n,e[10]=h):h=e[10];const m=ye(h);let p;return e[11]!==m||e[12]!==u||e[13]!==f?(p={selectItem:f,close:m,registerSelectItemOverride:u},e[11]=m,e[12]=u,e[13]=f,e[14]=p):p=e[14],p},_y=Y(yy),Sy=t=>{const e=T(46),{adapter:s,text:n,triggerChar:r,behavior:o,aui:i,popoverId:a,isLoading:c}=t;let l;e[0]!==n||e[1]!==r?(l=hy({text:n,triggerChar:r}),e[0]=n,e[1]=r,e[2]=l):l=e[2];const u=ue(l),d=u.trigger!==null&&s!==void 0&&o!==void 0;let f;e[3]!==s||e[4]!==u.query||e[5]!==d?(f=by({adapter:s,query:u.query,open:d}),e[3]=s,e[4]=u.query,e[5]=d,e[6]=f):f=e[6];const h=ue(f);let m;e[7]!==h?(m=()=>{h.goBack()},e[7]=h,e[8]=m):m=e[8];const p=ye(m);let g;e[9]!==i||e[10]!==o||e[11]!==u.setCursorPosition||e[12]!==u.trigger||e[13]!==p||e[14]!==r?(g=_y({behavior:o,trigger:u.trigger,aui:i,triggerChar:r,setCursorPosition:u.setCursorPosition,onSelected:p}),e[9]=i,e[10]=o,e[11]=u.setCursorPosition,e[12]=u.trigger,e[13]=p,e[14]=r,e[15]=g):g=e[15];const _=ue(g);let C;e[16]!==u.query||e[17]!==h.activeCategoryId||e[18]!==h.goBack||e[19]!==h.isSearchMode||e[20]!==h.navigableList||e[21]!==h.selectCategory||e[22]!==d||e[23]!==a||e[24]!==_.close||e[25]!==_.selectItem?(C=gy({navigableList:h.navigableList,isSearchMode:h.isSearchMode,activeCategoryId:h.activeCategoryId,query:u.query,popoverId:a,open:d,selectItem:_.selectItem,selectCategory:h.selectCategory,goBack:h.goBack,close:_.close}),e[16]=u.query,e[17]=h.activeCategoryId,e[18]=h.goBack,e[19]=h.isSearchMode,e[20]=h.navigableList,e[21]=h.selectCategory,e[22]=d,e[23]=a,e[24]=_.close,e[25]=_.selectItem,e[26]=C):C=e[26];const S=ue(C);let y;return e[27]!==u.query||e[28]!==u.setCursorPosition||e[29]!==c||e[30]!==S.handleKeyDown||e[31]!==S.highlightIndex||e[32]!==S.highlightedIndex||e[33]!==S.highlightedItemId||e[34]!==h.activeCategoryId||e[35]!==h.categories||e[36]!==h.goBack||e[37]!==h.isSearchMode||e[38]!==h.items||e[39]!==h.selectCategory||e[40]!==d||e[41]!==a||e[42]!==_.close||e[43]!==_.registerSelectItemOverride||e[44]!==_.selectItem?(y={open:d,query:u.query,activeCategoryId:h.activeCategoryId,categories:h.categories,items:h.items,highlightedIndex:S.highlightedIndex,isSearchMode:h.isSearchMode,isLoading:c,popoverId:a,highlightedItemId:S.highlightedItemId,selectCategory:h.selectCategory,goBack:h.goBack,selectItem:_.selectItem,close:_.close,highlightIndex:S.highlightIndex,handleKeyDown:S.handleKeyDown,setCursorPosition:u.setCursorPosition,registerSelectItemOverride:_.registerSelectItemOverride},e[27]=u.query,e[28]=u.setCursorPosition,e[29]=c,e[30]=S.handleKeyDown,e[31]=S.highlightIndex,e[32]=S.highlightedIndex,e[33]=S.highlightedItemId,e[34]=h.activeCategoryId,e[35]=h.categories,e[36]=h.goBack,e[37]=h.isSearchMode,e[38]=h.items,e[39]=h.selectCategory,e[40]=d,e[41]=a,e[42]=_.close,e[43]=_.registerSelectItemOverride,e[44]=_.selectItem,e[45]=y):y=e[45],y},xy=Y(Sy),lr=fe(null),wt=()=>{const t=me(lr);if(!t)throw new Error("useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover");return t},wy=()=>me(lr),kc=fe(null),$c=()=>{const t=me(kc);if(!t)throw new Error("TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover");return t},Nc=b.forwardRef((t,e)=>{const s=T(61);let n,r,o,i,a,c;s[0]!==t?({char:o,adapter:n,isLoading:c,"aria-label":r,children:i,...a}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o,s[4]=i,s[5]=a,s[6]=c):(n=s[1],r=s[2],o=s[3],i=s[4],a=s[5],c=s[6]);const l=c===void 0?!1:c,u=H(),d=D(Cy),f=b.useId(),h=W(null),[m,p]=ee(null),g=W(0);let _;s[7]!==o?(_=J=>(g.current=g.current+1,h.current=J,p(J),()=>{g.current=Math.max(0,g.current-1),h.current===J&&(h.current=null,p(null))}),s[7]=o,s[8]=_):_=s[8];const C=_;let S;s[9]!==C?(S={register:C},s[9]=C,s[10]=S):S=s[10];const y=S,x=m??void 0;let E;s[11]!==n||s[12]!==u||s[13]!==o||s[14]!==l||s[15]!==f||s[16]!==x||s[17]!==d?(E=xy({adapter:n,text:d,triggerChar:o,behavior:x,aui:u,popoverId:f,isLoading:l}),s[11]=n,s[12]=u,s[13]=o,s[14]=l,s[15]=f,s[16]=x,s[17]=d,s[18]=E):E=s[18];const I=ue(E);let R;s[19]!==I?(R=()=>I,s[19]=I,s[20]=R):R=s[20];const P=ye(R),k=ar();let O;s[21]!==m||s[22]!==o||s[23]!==P||s[24]!==k?(O=()=>k.register({char:o,...m?{behavior:m}:{},resource:P()}),s[21]=m,s[22]=o,s[23]=P,s[24]=k,s[25]=O):O=s[25];let $;s[26]!==m||s[27]!==o||s[28]!==k?($=[k,o,m],s[26]=m,s[27]=o,s[28]=k,s[29]=$):$=s[29],q(O,$);const M=Ns();let B;s[30]!==P||s[31]!==M?(B=()=>{if(M)return M.register(P())},s[30]=P,s[31]=M,s[32]=B):B=s[32];let U;s[33]!==M?(U=[M],s[33]=M,s[34]=U):U=s[34],q(B,U);const V=m!==null&&I.open,Q=oy();let j,Z;s[35]!==Q||s[36]!==o||s[37]!==V?(j=()=>{if(V)return()=>{Q.setActiveAria(o,null)}},Z=[Q,o,V],s[35]=Q,s[36]=o,s[37]=V,s[38]=j,s[39]=Z):(j=s[38],Z=s[39]),q(j,Z);let w,A;s[40]!==Q||s[41]!==o||s[42]!==V||s[43]!==f||s[44]!==I.highlightedItemId?(w=()=>{V&&Q.setActiveAria(o,{popoverId:f,highlightedItemId:I.highlightedItemId})},A=[Q,o,f,V,I.highlightedItemId],s[40]=Q,s[41]=o,s[42]=V,s[43]=f,s[44]=I.highlightedItemId,s[45]=w,s[46]=A):(w=s[45],A=s[46]),q(w,A);let N;s[47]!==r||s[48]!==i||s[49]!==e||s[50]!==V||s[51]!==f||s[52]!==a||s[53]!==I.highlightedItemId?(N=V?v.jsx(X.div,{role:"listbox",id:f,"aria-label":r??"Suggestions","aria-activedescendant":I.highlightedItemId,"data-state":"open",...a,ref:e,children:i}):i,s[47]=r,s[48]=i,s[49]=e,s[50]=V,s[51]=f,s[52]=a,s[53]=I.highlightedItemId,s[54]=N):N=s[54];let L;s[55]!==I||s[56]!==N?(L=v.jsx(lr.Provider,{value:I,children:N}),s[55]=I,s[56]=N,s[57]=L):L=s[57];let F;return s[58]!==y||s[59]!==L?(F=v.jsx(kc.Provider,{value:y,children:L}),s[58]=y,s[59]=L,s[60]=F):F=s[60],F});Nc.displayName="ComposerPrimitive.TriggerPopover";function Cy(t){return t.composer.text}const Lc=()=>{const t=T(2),{disabled:e,send:s}=Km();let n;t[0]!==s?(n=()=>s(),t[0]=s,t[1]=n):n=t[1];const r=n;return e?null:r},Ty=ce("ComposerPrimitive.Send",Lc),jc=fe(null),Ey=()=>me(jc),Bc=b.forwardRef((t,e)=>{const s=T(20);let n,r,o;s[0]!==t?({onSubmit:r,compact:n,...o}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o):(n=s[1],r=s[2],o=s[3]);const i=Lc(),[a,c]=ee(!1);let l;s[4]===Symbol.for("react.memo_cache_sentinel")?(l={setMultiline:c},s[4]=l):l=s[4];const u=l;let d;s[5]!==n?(d=y=>n?y.composer.attachments.length===0&&y.composer.quote==null&&y.composer.queue.length===0&&y.composer.dictation==null&&!y.composer.text.includes(`
70
- `):!1,s[5]=n,s[6]=d):d=s[6];const f=D(d)&&!a;let h;s[7]!==i?(h=y=>{y.preventDefault(),i&&i()},s[7]=i,s[8]=h):h=s[8];const m=h,p=n?u:null,g=f?"":void 0;let _;s[9]!==m||s[10]!==r?(_=K(r,m),s[9]=m,s[10]=r,s[11]=_):_=s[11];let C;s[12]!==e||s[13]!==o||s[14]!==g||s[15]!==_?(C=v.jsx(X.form,{...o,"data-compact":g,ref:e,onSubmit:_}),s[12]=e,s[13]=o,s[14]=g,s[15]=_,s[16]=C):C=s[16];let S;return s[17]!==p||s[18]!==C?(S=v.jsx(jc.Provider,{value:p,children:C}),s[17]=p,s[18]=C,s[19]=S):S=s[19],S});Bc.displayName="ComposerPrimitive.Root";const Fc=t=>{const e=T(4),s=Oe(t),n=st(Iy);let r,o;e[0]!==s||e[1]!==n?(r=()=>n(s),o=[n,s],e[0]=s,e[1]=n,e[2]=r,e[3]=o):(r=e[2],o=e[3]),q(r,o)};function Iy(t){return t.onScrollToBottom}const Ry=()=>!1,Ay=()=>{},Uc=t=>{const e=T(4);let s;e[0]!==t?(s=o=>{if(typeof window>"u"||t===null||!window.matchMedia)return Ay;const i=window.matchMedia(t);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},e[0]=t,e[1]=s):s=e[1];const n=s;let r;return e[2]!==t?(r=()=>typeof window>"u"||t===null||!window.matchMedia?!1:window.matchMedia(t).matches,e[2]=t,e[3]=r):r=e[3],_t(n,r,Ry)};function Py(){return D(My)}function My(t){return t.composer.isEditing?t.composer.text:""}function Dy(t){return!!D(Oy)||!!t}function Oy(t){return t.thread.isDisabled||t.composer.dictation?.inputDisabled}function ky(){const t=T(4),e=ly();if(!e){let n;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n={},t[0]=n):n=t[0],n}let s;return t[1]!==e.highlightedItemId||t[2]!==e.popoverId?(s={"aria-controls":e.popoverId,"aria-expanded":!0,"aria-haspopup":"listbox","aria-activedescendant":e.highlightedItemId},t[1]=e.highlightedItemId,t[2]=e.popoverId,t[3]=s):s=t[3],s}function xn(){return xn=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var n in s)({}).hasOwnProperty.call(s,n)&&(t[n]=s[n])}return t},xn.apply(null,arguments)}function $y(t,e){if(t==null)return{};var s={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.indexOf(n)!==-1)continue;s[n]=t[n]}return s}var Ny=b.useLayoutEffect,Ly=function(e){var s=ne.useRef(e);return Ny(function(){s.current=e}),s},Bo=function(e,s){if(typeof e=="function"){e(s);return}e.current=s},jy=function(e,s){var n=ne.useRef();return ne.useCallback(function(r){e.current=r,n.current&&Bo(n.current,null),n.current=s,s&&Bo(s,r)},[s])},Fo={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},By=function(e){Object.keys(Fo).forEach(function(s){e.style.setProperty(s,Fo[s],"important")})},Uo=By,le=null,Vo=function(e,s){var n=e.scrollHeight;return s.sizingStyle.boxSizing==="border-box"?n+s.borderSize:n-s.paddingSize};function Fy(t,e,s,n){s===void 0&&(s=1),n===void 0&&(n=1/0),le||(le=document.createElement("textarea"),le.setAttribute("tabindex","-1"),le.setAttribute("aria-hidden","true"),Uo(le)),le.parentNode===null&&document.body.appendChild(le);var r=t.paddingSize,o=t.borderSize,i=t.sizingStyle,a=i.boxSizing;Object.keys(i).forEach(function(f){var h=f;le.style[h]=i[h]}),Uo(le),le.value=e;var c=Vo(le,t);le.value=e,c=Vo(le,t),le.value="x";var l=le.scrollHeight-r,u=l*s;a==="border-box"&&(u=u+r+o),c=Math.max(u,c);var d=l*n;return a==="border-box"&&(d=d+r+o),c=Math.min(d,c),[c,l]}var Ho=function(){},Uy=function(e,s){return e.reduce(function(n,r){return n[r]=s[r],n},{})},Vy=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],Hy=!!document.documentElement.currentStyle,qy=function(e){var s=window.getComputedStyle(e);if(s===null)return null;var n=Uy(Vy,s),r=n.boxSizing;if(r==="")return null;Hy&&r==="border-box"&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+"px");var o=parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),i=parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth);return{sizingStyle:n,paddingSize:o,borderSize:i}},zy=qy;function ur(t,e,s){var n=Ly(s);b.useLayoutEffect(function(){var r=function(i){return n.current(i)};if(t)return t.addEventListener(e,r),function(){return t.removeEventListener(e,r)}},[])}var Wy=function(e,s){ur(document.body,"reset",function(n){e.current.form===n.target&&s(n)})},Gy=function(e){ur(window,"resize",e)},Ky=function(e){ur(document.fonts,"loadingdone",e)},Yy=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],Qy=function(e,s){var n=e.cacheMeasurements,r=e.maxRows,o=e.minRows,i=e.onChange,a=i===void 0?Ho:i,c=e.onHeightChange,l=c===void 0?Ho:c,u=$y(e,Yy),d=u.value!==void 0,f=b.useRef(null),h=jy(f,s),m=b.useRef(0),p=b.useRef(),g=function(){var S=f.current,y=n&&p.current?p.current:zy(S);if(y){p.current=y;var x=Fy(y,S.value||S.placeholder||"x",o,r),E=x[0],I=x[1];m.current!==E&&(m.current=E,S.style.setProperty("height",E+"px","important"),l(E,{rowHeight:I}))}},_=function(S){d||g(),a(S)};return b.useLayoutEffect(g),Wy(f,function(){if(!d){var C=f.current.value;requestAnimationFrame(function(){var S=f.current;S&&C!==S.value&&g()})}}),Gy(g),Ky(g),b.createElement("textarea",xn({},u,{onChange:_,ref:h}))},Jy=b.forwardRef(Qy);const Xy="(pointer: coarse) and (not (any-pointer: fine))",Vc=b.forwardRef(({autoFocus:t=!1,asChild:e,render:s,disabled:n,onChange:r,onKeyDown:o,onPaste:i,onSelect:a,submitOnEnter:c,submitMode:l,cancelOnEscape:u=!0,unstable_focusOnRunStart:d=!0,unstable_focusOnScrollToBottom:f=!0,unstable_focusOnThreadSwitched:h=!0,unstable_insertNewlineOnTouchEnter:m=!1,addAttachmentOnPaste:p=!0,onHeightChange:g,..._},C)=>{const S=H(),y=Ns(),x=Ey(),E=l??(c===!1?"none":"enter"),I=Uc(m?Xy:null),R=m&&I&&E==="enter"?"none":E,P=Py(),k=Dy(n),O=W(null),$=ae(C,O),M=W(!1);Va(A=>{if(!O.current?.contains(A.target))return;if(y){for(const L of y.getPlugins())if(L.handleKeyDown(A))return}if(!u)return;const N=S.composer();N.getState().canCancel&&(N.cancel(),A.preventDefault())});const B=A=>{if(!k&&!A.nativeEvent.isComposing){if(y){for(const N of y.getPlugins())if(N.handleKeyDown(A))return}if(A.key==="Enter"){const N=S.thread().getState(),L=N.capabilities.queue;if(A.shiftKey&&(A.ctrlKey||A.metaKey)&&L&&E!=="none"&&S.composer().getState().canSend){A.preventDefault(),S.composer().send({steer:!0});return}if(A.shiftKey||N.isRunning&&!L)return;let F=!1;R==="ctrlEnter"?F=A.ctrlKey||A.metaKey:R==="enter"&&(F=!0),F&&(A.preventDefault(),O.current?.closest("form")?.requestSubmit())}}},U=async A=>{if(!p)return;const N=S.thread().getState().capabilities,L=Array.from(A.clipboardData?.files||[]);if(N.attachments&&L.length>0)try{A.preventDefault(),await Promise.all(L.map(F=>S.composer().addAttachment(F)))}catch(F){console.error("Error adding attachment:",F)}},V=(A,N)=>{if(g?.(A,N),!x)return;const L=O.current;if(!L||L.value==="")return;const F=getComputedStyle(L),J=F.boxSizing==="border-box"?A-parseFloat(F.paddingTop)-parseFloat(F.paddingBottom)-parseFloat(F.borderTopWidth)-parseFloat(F.borderBottomWidth):A;Math.round(J/N.rowHeight)>1&&x.setMultiline(!0)},Q=t&&!k,j=It(()=>{const A=O.current;!A||!Q||(A.focus({preventScroll:!0}),A.setSelectionRange(A.value.length,A.value.length))},[Q]);q(()=>j(),[j]),Fc(()=>{S.composer().getState().type==="thread"&&f&&j()}),q(()=>{if(!(S.composer().getState().type!=="thread"||!d))return S.on("thread.runStart",j)},[d,j,S]),q(()=>{if(!(S.composer().getState().type!=="thread"||!h))return S.on("threadListItem.switchedTo",j)},[h,j,S]),q(()=>{P===""&&x?.setMultiline(!1)},[P,x]);const Z=ky(),w={name:"input",value:P,..._,...Z,ref:$,disabled:k,onChange:K(r,A=>{if(!S.composer().getState().isEditing)return;const N=A.nativeEvent.isComposing===!0;M.current&&!N&&(M.current=!1);const L=N||M.current;if(xr(()=>{S.composer().setText(A.target.value)}),L)return;const F=A.target.selectionStart??A.target.value.length;if(y)for(const J of y.getPlugins())J.setCursorPosition(F)}),onKeyDown:K(o,B),onCompositionStart:K(_.onCompositionStart,()=>{M.current=!0}),onCompositionEnd:K(_.onCompositionEnd,A=>{if(M.current=!1,!S.composer().getState().isEditing)return;const N=A.target;xr(()=>{S.composer().setText(N.value)});const L=N.selectionStart??N.value.length;if(y)for(const F of y.getPlugins())F.setCursorPosition(L)}),onSelect:K(a,A=>{if(M.current)return;const N=A.target,L=N.selectionStart??N.value.length;if(y)for(const F of y.getPlugins())F.setCursorPosition(L)}),onPaste:K(i,U),...x?{onHeightChange:V}:g!==void 0?{onHeightChange:g}:{}};if(s&&b.isValidElement(s)){const A=_.children!==void 0?_.children:s.props.children;return v.jsx(ps,{...w,children:b.cloneElement(s,void 0,A)})}return v.jsx(e?ps:Jy,{...w})});Vc.displayName="ComposerPrimitive.Input";const Zy=()=>{const{disabled:t,cancel:e}=Qm();return t?null:e},e_=ce("ComposerPrimitive.Cancel",Zy),t_=t=>{const e=T(6);let s;e[0]!==t?(s=t===void 0?{}:t,e[0]=t,e[1]=s):s=e[1];const{multiple:n}=s,r=n===void 0?!0:n,{disabled:o,addAttachment:i}=ep(),a=H();let c;e[2]!==i||e[3]!==a||e[4]!==r?(c=()=>{const u=document.createElement("input");u.type="file",u.multiple=r,u.hidden=!0;const d=a.composer().getState().attachmentAccept;d!=="*"&&(u.accept=d),document.body.appendChild(u),u.onchange=f=>{const h=f.target.files;if(h){for(const m of h)i(m);document.body.removeChild(u)}},u.oncancel=()=>{(!u.files||u.files.length===0)&&document.body.removeChild(u)},u.click()},e[2]=i,e[3]=a,e[4]=r,e[5]=c):c=e[5];const l=c;return o?null:l},s_=ce("ComposerPrimitive.AddAttachment",t_,["multiple"]),Hc=b.forwardRef((t,e)=>{const s=T(30),{disabled:n,asChild:r,render:o,children:i,...a}=t,c=r===void 0?!1:r,[l,u]=ee(!1),d=H();let f;s[0]!==n?(f=M=>{n||(M.preventDefault(),u(!0))},s[0]=n,s[1]=f):f=s[1];const h=f;let m;s[2]!==n||s[3]!==l?(m=M=>{n||(M.preventDefault(),l||u(!0))},s[2]=n,s[3]=l,s[4]=m):m=s[4];const p=m;let g;s[5]!==n?(g=M=>{if(n)return;M.preventDefault();const B=M.relatedTarget;B&&M.currentTarget.contains(B)||u(!1)},s[5]=n,s[6]=g):g=s[6];const _=g;let C;s[7]!==d||s[8]!==n?(C=async M=>{if(n)return;M.preventDefault(),u(!1);const B=Array.from(M.dataTransfer.files);await Promise.all(B.map(async U=>{try{await d.composer().addAttachment(U)}catch(V){console.error("Failed to add attachment:",V)}}))},s[7]=d,s[8]=n,s[9]=C):C=s[9];const S=C;let y;s[10]!==l?(y=l?{"data-dragging":"true"}:null,s[10]=l,s[11]=y):y=s[11];const x=K(a.onDragEnterCapture,h),E=K(a.onDragOverCapture,p),I=K(a.onDragLeaveCapture,_),R=K(a.onDropCapture,S);let P;s[12]!==e||s[13]!==a||s[14]!==R||s[15]!==y||s[16]!==x||s[17]!==E||s[18]!==I?(P={...y,...a,onDragEnterCapture:x,onDragOverCapture:E,onDragLeaveCapture:I,onDropCapture:R,ref:e},s[12]=e,s[13]=a,s[14]=R,s[15]=y,s[16]=x,s[17]=E,s[18]=I,s[19]=P):P=s[19];const k=P;if(o&&b.isValidElement(o)){const M=i!==void 0?i:o.props.children;let B;s[20]!==o||s[21]!==M?(B=b.cloneElement(o,void 0,M),s[20]=o,s[21]=M,s[22]=B):B=s[22];let U;return s[23]!==k||s[24]!==B?(U=v.jsx(ps,{...k,children:B}),s[23]=k,s[24]=B,s[25]=U):U=s[25],U}const O=c?ps:"div";let $;return s[26]!==O||s[27]!==i||s[28]!==k?($=v.jsx(O,{...k,children:i}),s[26]=O,s[27]=i,s[28]=k,s[29]=$):$=s[29],$});Hc.displayName="ComposerPrimitive.AttachmentDropzone";const n_=()=>{const{disabled:t,startDictation:e}=Xm();return t?null:e},r_=ce("ComposerPrimitive.Dictate",n_),o_=()=>{const t=T(2),e=H(),s=D(a_);let n;t[0]!==e?(n=()=>{e.composer().stopDictation()},t[0]=e,t[1]=n):n=t[1];const r=n;return s?r:null},i_=ce("ComposerPrimitive.StopDictation",o_);function a_(t){return t.composer.dictation!=null}const qc=b.forwardRef((t,e)=>{const s=T(7);let n,r;s[0]!==t?({children:n,...r}=t,s[0]=t,s[1]=n,s[2]=r):(n=s[1],r=s[2]);const o=D(c_);if(!o)return null;const i=n??o;let a;return s[3]!==e||s[4]!==r||s[5]!==i?(a=v.jsx(X.span,{...r,ref:e,children:i}),s[3]=e,s[4]=r,s[5]=i,s[6]=a):a=s[6],a});qc.displayName="ComposerPrimitive.DictationTranscript";function c_(t){return t.composer.dictation?.transcript}const zc=b.forwardRef((t,e)=>{const s=T(3);if(!D(l_))return null;let n;return s[0]!==e||s[1]!==t?(n=v.jsx(X.div,{...t,ref:e}),s[0]=e,s[1]=t,s[2]=n):n=s[2],n});zc.displayName="ComposerPrimitive.Quote";const Wc=b.forwardRef((t,e)=>{const s=T(7);let n,r;s[0]!==t?({children:n,...r}=t,s[0]=t,s[1]=n,s[2]=r):(n=s[1],r=s[2]);const o=D(u_);if(!o)return null;const i=n??o;let a;return s[3]!==e||s[4]!==r||s[5]!==i?(a=v.jsx(X.span,{...r,ref:e,children:i}),s[3]=e,s[4]=r,s[5]=i,s[6]=a):a=s[6],a});Wc.displayName="ComposerPrimitive.QuoteText";const Gc=b.forwardRef((t,e)=>{const s=T(12);let n,r;s[0]!==t?({onClick:n,...r}=t,s[0]=t,s[1]=n,s[2]=r):(n=s[1],r=s[2]);const o=H();let i;s[3]!==o?(i=()=>{o.composer().setQuote(void 0)},s[3]=o,s[4]=i):i=s[4];const a=i;let c;s[5]!==a||s[6]!==n?(c=K(n,a),s[5]=a,s[6]=n,s[7]=c):c=s[7];let l;return s[8]!==e||s[9]!==r||s[10]!==c?(l=v.jsx(X.button,{type:"button",...r,ref:e,onClick:c}),s[8]=e,s[9]=r,s[10]=c,s[11]=l):l=s[11],l});Gc.displayName="ComposerPrimitive.QuoteDismiss";function l_(t){return t.composer.quote}function u_(t){return t.composer.quote?.text}const Kc=b.forwardRef((t,e)=>{const s=T(12);let n,r,o;s[0]!==t?({children:r,"aria-label":n,...o}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o):(n=s[1],r=s[2],o=s[3]);const{categories:i,activeCategoryId:a,isSearchMode:c,open:l}=wt();if(!l||a||c)return null;const u=n??"Categories";let d;s[4]!==i||s[5]!==r?(d=r(i),s[4]=i,s[5]=r,s[6]=d):d=s[6];let f;return s[7]!==e||s[8]!==o||s[9]!==u||s[10]!==d?(f=v.jsx(X.div,{role:"group","aria-label":u,...o,ref:e,children:d}),s[7]=e,s[8]=o,s[9]=u,s[10]=d,s[11]=f):f=s[11],f});Kc.displayName="ComposerPrimitive.TriggerPopoverCategories";const Yc=b.forwardRef((t,e)=>{const s=T(30);let n,r,o,i;s[0]!==t?({categoryId:n,onClick:r,onMouseMove:o,...i}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o,s[4]=i):(n=s[1],r=s[2],o=s[3],i=s[4]);const{selectCategory:a,highlightIndex:c,categories:l,highlightedIndex:u,activeCategoryId:d,isSearchMode:f,popoverId:h}=wt();let m;s[5]!==n||s[6]!==a?(m=()=>{a(n)},s[5]=n,s[6]=a,s[7]=m):m=s[7];const p=m;let g;if(s[8]!==l||s[9]!==n){let k;s[11]!==n?(k=O=>O.id===n,s[11]=n,s[12]=k):k=s[12],g=l.findIndex(k),s[8]=l,s[9]=n,s[10]=g}else g=s[10];const _=g,C=!d&&!f&&_===u;let S;s[13]!==_||s[14]!==c?(S=()=>{c(_)},s[13]=_,s[14]=c,s[15]=S):S=s[15];const y=S,x=`${h}-option-${n}`,E=C?"":void 0;let I;s[16]!==p||s[17]!==r?(I=K(r,p),s[16]=p,s[17]=r,s[18]=I):I=s[18];let R;s[19]!==y||s[20]!==o?(R=K(o,y),s[19]=y,s[20]=o,s[21]=R):R=s[21];let P;return s[22]!==e||s[23]!==C||s[24]!==i||s[25]!==x||s[26]!==E||s[27]!==I||s[28]!==R?(P=v.jsx(X.button,{type:"button",role:"option",id:x,"aria-selected":C,"data-highlighted":E,...i,ref:e,onClick:I,onMouseMove:R}),s[22]=e,s[23]=C,s[24]=i,s[25]=x,s[26]=E,s[27]=I,s[28]=R,s[29]=P):P=s[29],P});Yc.displayName="ComposerPrimitive.TriggerPopoverCategoryItem";const Qc=b.forwardRef((t,e)=>{const s=T(12);let n,r,o;s[0]!==t?({children:r,"aria-label":n,...o}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o):(n=s[1],r=s[2],o=s[3]);const{items:i,activeCategoryId:a,isSearchMode:c,open:l}=wt();if(!l||!a&&!c)return null;const u=n??"Items";let d;s[4]!==r||s[5]!==i?(d=r(i),s[4]=r,s[5]=i,s[6]=d):d=s[6];let f;return s[7]!==e||s[8]!==o||s[9]!==u||s[10]!==d?(f=v.jsx(X.div,{role:"group","aria-label":u,...o,ref:e,children:d}),s[7]=e,s[8]=o,s[9]=u,s[10]=d,s[11]=f):f=s[11],f});Qc.displayName="ComposerPrimitive.TriggerPopoverItems";const Jc=b.forwardRef((t,e)=>{const s=T(30);let n,r,o,i,a;s[0]!==t?({item:r,index:n,onClick:o,onMouseMove:i,...a}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o,s[4]=i,s[5]=a):(n=s[1],r=s[2],o=s[3],i=s[4],a=s[5]);const{selectItem:c,highlightIndex:l,items:u,highlightedIndex:d,activeCategoryId:f,isSearchMode:h,popoverId:m}=wt();let p;s[6]!==r||s[7]!==c?(p=()=>{c(r)},s[6]=r,s[7]=c,s[8]=p):p=s[8];const g=p;let _;s[9]!==n||s[10]!==r.id||s[11]!==u?(_=n??u.findIndex(O=>O.id===r.id),s[9]=n,s[10]=r.id,s[11]=u,s[12]=_):_=s[12];const C=_,S=(h||f!==null)&&C===d;let y;s[13]!==l||s[14]!==C?(y=()=>{l(C)},s[13]=l,s[14]=C,s[15]=y):y=s[15];const x=y,E=`${m}-option-${r.id}`,I=S?"":void 0;let R;s[16]!==g||s[17]!==o?(R=K(o,g),s[16]=g,s[17]=o,s[18]=R):R=s[18];let P;s[19]!==x||s[20]!==i?(P=K(i,x),s[19]=x,s[20]=i,s[21]=P):P=s[21];let k;return s[22]!==e||s[23]!==S||s[24]!==a||s[25]!==E||s[26]!==I||s[27]!==R||s[28]!==P?(k=v.jsx(X.button,{type:"button",role:"option",id:E,"aria-selected":S,"data-highlighted":I,...a,ref:e,onClick:R,onMouseMove:P}),s[22]=e,s[23]=S,s[24]=a,s[25]=E,s[26]=I,s[27]=R,s[28]=P,s[29]=k):k=s[29],k});Jc.displayName="ComposerPrimitive.TriggerPopoverItem";const Xc=b.forwardRef((t,e)=>{const s=T(10);let n,r;s[0]!==t?({onClick:n,...r}=t,s[0]=t,s[1]=n,s[2]=r):(n=s[1],r=s[2]);const{activeCategoryId:o,isSearchMode:i,goBack:a,open:c}=wt();if(!c||!o||i)return null;let l;s[3]!==a||s[4]!==n?(l=K(n,a),s[3]=a,s[4]=n,s[5]=l):l=s[5];let u;return s[6]!==e||s[7]!==r||s[8]!==l?(u=v.jsx(X.button,{type:"button",...r,ref:e,onClick:l}),s[6]=e,s[7]=r,s[8]=l,s[9]=u):u=s[9],u});Xc.displayName="ComposerPrimitive.TriggerPopoverBack";const Zc=({formatter:t,onExecute:e,removeOnExecute:s})=>{const{register:n}=$c(),r=W(e);return r.current=e,q(()=>{const o={kind:"action",formatter:t??La,onExecute:i=>r.current(i),...s!==void 0?{removeOnExecute:s}:{}};return n(o)},[n,t,s]),null};Zc.displayName="ComposerPrimitive.TriggerPopoverAction";const el=({formatter:t,onInserted:e})=>{const{register:s}=$c(),n=W(e);return n.current=e,q(()=>s({kind:"directive",formatter:t??La,onInserted:r=>n.current?.(r)}),[s,t]),null};el.displayName="ComposerPrimitive.TriggerPopoverDirective";const d_=Object.assign(Nc,{Directive:el,Action:Zc});var Z1=Ue({AddAttachment:()=>s_,AttachmentByIndex:()=>Ia,AttachmentDropzone:()=>Hc,Attachments:()=>Ra,Cancel:()=>e_,Dictate:()=>r_,DictationTranscript:()=>qc,If:()=>Na,Input:()=>Vc,Queue:()=>Aa,Quote:()=>zc,QuoteDismiss:()=>Gc,QuoteText:()=>Wc,Root:()=>Bc,Send:()=>Ty,StopDictation:()=>i_,Unstable_TriggerPopover:()=>d_,Unstable_TriggerPopoverBack:()=>Xc,Unstable_TriggerPopoverCategories:()=>Kc,Unstable_TriggerPopoverCategoryItem:()=>Yc,Unstable_TriggerPopoverItem:()=>Jc,Unstable_TriggerPopoverItems:()=>Qc,Unstable_TriggerPopoverRoot:()=>Oc,unstable_useTriggerPopoverRootContext:()=>ar,unstable_useTriggerPopoverRootContextOptional:()=>cr,unstable_useTriggerPopoverScopeContext:()=>wt,unstable_useTriggerPopoverScopeContextOptional:()=>wy,unstable_useTriggerPopoverTriggers:()=>iy,unstable_useTriggerPopoverTriggersOptional:()=>cy});const f_=()=>D(h_);function h_(t){if(t.part.type!=="text"&&t.part.type!=="reasoning")throw new Error("MessagePartText can only be used inside text or reasoning message parts.");return t.part}const tl=fe(null),m_=t=>({useSmoothStatus:Ni(()=>t)}),p_=t=>{const e=T(6),{children:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={optional:!0},e[0]=n):n=e[0];const r=sl(n),o=H();let i;e[1]!==o?(i=()=>m_(o.part().getState().status),e[1]=o,e[2]=i):i=e[2];const[a]=ee(i);if(r)return s;let c;return e[3]!==s||e[4]!==a?(c=v.jsx(tl.Provider,{value:a,children:s}),e[3]=s,e[4]=a,e[5]=c):c=e[5],c},g_=t=>{const e=b.forwardRef((s,n)=>{const r=T(3),o=s;let i;return r[0]!==n||r[1]!==o?(i=v.jsx(p_,{children:v.jsx(t,{...o,ref:n})}),r[0]=n,r[1]=o,r[2]=i):i=r[2],i});return e.displayName=t.displayName,e};function sl(t){const e=me(tl);if(!t?.optional&&!e)throw new Error("This component must be used within a SmoothContextProvider.");return e}const{useSmoothStatus:v_,useSmoothStatusStore:b_}=ja(sl,"useSmoothStatus"),nl=250,rl=5;var y_=class{currentText;setText;animationFrameId=null;lastUpdateTime=Date.now();lastCommitTime=0;targetText="";drainMs=nl;maxCharIntervalMs=rl;maxCharsPerFrame=1/0;minCommitMs=0;constructor(t,e){this.currentText=t,this.setText=e}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate=()=>{const t=Date.now();let e=t-this.lastUpdateTime;const s=this.targetText.length-this.currentText.length,n=Math.min(this.maxCharIntervalMs,this.drainMs/s),r=Math.min(s,this.maxCharsPerFrame);let o=0;for(;e>=n&&o<r;)o++,e-=n;o===r&&r===this.maxCharsPerFrame&&(e=0),o!==s?this.animationFrameId=requestAnimationFrame(this.animate):this.animationFrameId=null,o!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+o),this.lastUpdateTime=t-e,(o===s||t-this.lastCommitTime>=this.minCommitMs)&&(this.lastCommitTime=t,this.setText(this.currentText)))}};const nn=Object.freeze({type:"running"}),Xt=(t,e)=>t!==void 0&&t>0?t:e,ol=(t,e=!1)=>{const{text:s}=t,n=Uc("(prefers-reduced-motion: reduce)"),r=typeof e=="object"&&e!==null?e:void 0,o=e!==!1&&e!==null&&!n,i=Xt(r?.drainMs,nl),a=Xt(r?.maxCharIntervalMs,rl),c=Xt(r?.maxCharsPerFrame,1/0),l=Xt(r?.minCommitMs,0),[u,d]=ee(t.status.type==="running"?"":s),f=H(),h=D(()=>f.part()),[m,p]=ee(h);(h!==m||!s.startsWith(u))&&(p(h),d(t.status.type==="running"?"":s));const g=b_({optional:!0}),_=Oe(y=>{if(d(y),g){const x=u!==y||t.status.type==="running"?nn:t.status;ms(g).setState(x,!0)}});q(()=>{if(g){const y=o&&(u!==s||t.status.type==="running")?nn:t.status;ms(g).setState(y,!0)}},[g,o,s,u,t.status]);const[C]=ee(new y_(u,_));q(()=>{C.drainMs=i,C.maxCharIntervalMs=a,C.maxCharsPerFrame=c,C.minCommitMs=l},[C,i,a,c,l]);const S=W(h);return q(()=>{if(!o){C.stop();return}const y=S.current!==h;if(S.current=h,y||!s.startsWith(C.targetText)){t.status.type==="running"?(C.currentText="",C.targetText=s,C.lastCommitTime=0,C.start()):(C.currentText=s,C.targetText=s,C.stop());return}C.targetText=s,C.start()},[C,o,s,t.status.type,h]),q(()=>()=>{C.stop()},[C]),te(()=>o?{...t,text:u,status:s===u?t.status:nn}:t,[o,u,t,s])},__=()=>D(S_);function S_(t){if(t.part.type!=="image")throw new Error("MessagePartImage can only be used inside image message parts.");return t.part}const dr=b.forwardRef((t,e)=>{const s=T(10);let n,r,o;s[0]!==t?({smooth:r,component:o,...n}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o):(n=s[1],r=s[2],o=s[3]);const i=r===void 0?!0:r,a=o===void 0?"span":o,{text:c,status:l}=ol(f_(),i);let u;return s[4]!==a||s[5]!==e||s[6]!==n||s[7]!==l.type||s[8]!==c?(u=v.jsx(a,{"data-status":l.type,...n,ref:e,children:c}),s[4]=a,s[5]=e,s[6]=n,s[7]=l.type,s[8]=c,s[9]=u):u=s[9],u});dr.displayName="MessagePartPrimitive.Text";const fr=b.forwardRef((t,e)=>{const s=T(4),{image:n}=__();let r;return s[0]!==e||s[1]!==n||s[2]!==t?(r=v.jsx(X.img,{src:n,...t,ref:e}),s[0]=e,s[1]=n,s[2]=t,s[3]=r):r=s[3],r});fr.displayName="MessagePartPrimitive.Image";const rt=t=>{const e=T(2),s=W(void 0);let n;return e[0]!==t?(n=r=>{s.current&&(s.current(),s.current=void 0),r&&(s.current=t(r))},e[0]=t,e[1]=n):n=e[1],n},qo=(t,e)=>{const s=t.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(em|px|rem)$/);if(!s)return Number.POSITIVE_INFINITY;const n=Number(s[1]),r=s[2];return r==="px"?n:r==="em"?n*(parseFloat(getComputedStyle(e).fontSize)||16):r==="rem"?n*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):Number.POSITIVE_INFINITY},x_=t=>t.dataset.messageId,w_=()=>{const t=document.createElement("div");return t.dataset.auiTopAnchorReserve="",t.style.height="0px",t.style.flexShrink="0",t.style.pointerEvents="none",t.setAttribute("aria-hidden","true"),t},zo=(t,e)=>{const s=`${e}px`;return t.style.height!==s?(t.style.height=s,!0):!1},C_=t=>{const e=window.devicePixelRatio||1;return Math.round(t*e)/e},il=()=>{const t=T(4),e=H();let s;t[0]!==e?(s=()=>e.message(),t[0]=e,t[1]=s):s=t[1];const n=D(s);let r;return t[2]!==n?(r=o=>{const i=()=>{n.setIsHovering(!0)},a=()=>{n.setIsHovering(!1)};return o.addEventListener("mouseenter",i),o.addEventListener("mouseleave",a),o.matches(":hover")&&queueMicrotask(()=>n.setIsHovering(!0)),()=>{o.removeEventListener("mouseenter",i),o.removeEventListener("mouseleave",a),n.setIsHovering(!1)}},t[2]=n,t[3]=r):r=t[3],rt(r)},T_=()=>{const t=T(2),e=st(M_);let s;return t[0]!==e?(s=n=>n.message.role==="user"&&n.message.index>0&&n.message.index===n.thread.messages.length-2&&n.thread.messages.at(-1)?.role==="assistant"&&(n.message.id===e||n.thread.isRunning),t[0]=e,t[1]=s):s=t[1],D(s)},E_=()=>{const t=T(2),e=st(D_);let s;return t[0]!==e?(s=n=>n.message.isLast&&n.message.role==="assistant"&&n.message.index>=1&&n.thread.messages.at(n.message.index-1)?.role==="user"&&(n.message.id===e||n.thread.isRunning),t[0]=e,t[1]=s):s=t[1],D(s)},I_=(t,e)=>{const s=T(3);let n;return s[0]!==t||s[1]!==e?(n=r=>{if(t)return e.getState().registerAnchorElement(r)},s[0]=t,s[1]=e,s[2]=n):n=s[2],rt(n)},R_=t=>{const e=T(3),{active:s,threadViewportStore:n}=t;let r;return e[0]!==s||e[1]!==n?(r=o=>{if(!s)return;const i=n.getState(),a=i.topAnchorMessageClamp;return i.registerAnchorTargetElement(o,{tallerThan:qo(a.tallerThan,o),visibleHeight:qo(a.visibleHeight,o)})},e[0]=s,e[1]=n,e[2]=r):r=e[2],rt(r)},A_=t=>{const e=T(7);let s,n;e[0]!==t?({forwardedRef:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);const r=il(),o=ae(s,r),i=D(O_);let a;return e[3]!==i||e[4]!==n||e[5]!==o?(a=v.jsx(X.div,{...n,ref:o,"data-message-id":i}),e[3]=i,e[4]=n,e[5]=o,e[6]=a):a=e[6],a},P_=t=>{const e=T(13);let s,n,r;e[0]!==t?({forwardedRef:s,threadViewportStore:r,...n}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=r):(s=e[1],n=e[2],r=e[3]);const o=il(),i=T_(),a=E_(),c=I_(i,r);let l;e[4]!==a||e[5]!==r?(l={active:a,threadViewportStore:r},e[4]=a,e[5]=r,e[6]=l):l=e[6];const u=R_(l),d=ae(s,o,c,u),f=D(k_),h=i?"":void 0,m=a?"":void 0;let p;return e[7]!==f||e[8]!==n||e[9]!==d||e[10]!==h||e[11]!==m?(p=v.jsx(X.div,{...n,ref:d,"data-message-id":f,"data-aui-top-anchor-user":h,"data-aui-top-anchor-target":m}),e[7]=f,e[8]=n,e[9]=d,e[10]=h,e[11]=m,e[12]=p):p=e[12],p},al=b.forwardRef((t,e)=>{const s=T(7),n=nt();if(n.getState().turnAnchor==="top"){let o;return s[0]!==e||s[1]!==t||s[2]!==n?(o=v.jsx(P_,{...t,forwardedRef:e,threadViewportStore:n}),s[0]=e,s[1]=t,s[2]=n,s[3]=o):o=s[3],o}let r;return s[4]!==e||s[5]!==t?(r=v.jsx(A_,{...t,forwardedRef:e}),s[4]=e,s[5]=t,s[6]=r):r=s[6],r});al.displayName="MessagePrimitive.Root";function M_(t){return t.topAnchorTurn?.anchorId}function D_(t){return t.topAnchorTurn?.targetId}function O_(t){return t.message.id}function k_(t){return t.message.id}const rn={...oe,Text:()=>v.jsxs("p",{style:{whiteSpace:"pre-line"},children:[v.jsx(dr,{}),v.jsx(Qn,{children:v.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Image:()=>v.jsx(fr,{})},wn=t=>{const e=T(10);if("children"in t){let a;return e[0]!==t.children?(a=v.jsx(vn,{children:t.children}),e[0]=t.children,e[1]=a):a=e[1],a}let s,n;e[2]!==t?({components:s,...n}=t,e[2]=t,e[3]=s,e[4]=n):(s=e[3],n=e[4]);let r;e[5]!==s?(r=s?{Text:s.Text??rn.Text,Image:s.Image??rn.Image,Reasoning:s.Reasoning??oe.Reasoning,Source:s.Source??oe.Source,File:s.File??oe.File,Unstable_Audio:s.Unstable_Audio??oe.Unstable_Audio,..."ChainOfThought"in s?{ChainOfThought:s.ChainOfThought}:{tools:s.tools,data:s.data,ToolGroup:s.ToolGroup??oe.ToolGroup,ReasoningGroup:s.ReasoningGroup??oe.ReasoningGroup},Empty:s.Empty,Quote:s.Quote,generativeUI:s.generativeUI}:rn,e[5]=s,e[6]=r):r=e[6];const o=r;let i;return e[7]!==n||e[8]!==o?(i=v.jsx(vn,{components:o,...n}),e[7]=n,e[8]=o,e[9]=i):i=e[9],i};wn.displayName="MessagePrimitive.Parts";const cl=t=>{const{children:e}=t;return Dp()!==void 0?e:null};cl.displayName="MessagePrimitive.Error";const $_=t=>{const e=new Map;for(let n=0;n<t.length;n++){const r=t[n]?.parentId??`__ungrouped_${n}`,o=e.get(r)??[];o.push(n),e.set(r,o)}const s=[];for(const[n,r]of e){const o=n.startsWith("__ungrouped_")?void 0:n;s.push({groupKey:o,indices:r})}return s},N_=t=>{const e=T(4),s=D(W_);let n;e:{if(s.length===0){let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0],n=o;break e}let r;e[1]!==t||e[2]!==s?(r=t(s),e[1]=t,e[2]=s,e[3]=r):r=e[3],n=r}return n},L_=t=>{const e=T(9);let s,n;e[0]!==t?({Fallback:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let r;e[3]!==s||e[4]!==n.toolName?(r=a=>{const c=a.tools.tools[n.toolName]??s;return Array.isArray(c)?c[0]??s:c},e[3]=s,e[4]=n.toolName,e[5]=r):r=e[5];const o=D(r);if(!o)return null;let i;return e[6]!==o||e[7]!==n?(i=v.jsx(o,{...n}),e[6]=o,e[7]=n,e[8]=i):i=e[8],i},j_=t=>{const e=T(9);let s,n;e[0]!==t?({Fallback:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let r;e[3]!==s||e[4]!==n.name?(r=a=>{const c=a.dataRenderers.renderers[n.name]??s;return Array.isArray(c)?c[0]??s:c},e[3]=s,e[4]=n.name,e[5]=r):r=e[5];const o=D(r);if(!o)return null;let i;return e[6]!==o||e[7]!==n?(i=v.jsx(o,{...n}),e[6]=o,e[7]=n,e[8]=i):i=e[8],i},Le={Text:()=>v.jsxs("p",{style:{whiteSpace:"pre-line"},children:[v.jsx(dr,{}),v.jsx(Qn,{children:v.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>v.jsx(fr,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:t})=>t},B_=t=>{const e=T(43),{components:s}=t;let n;e[0]!==s?(n=s===void 0?{}:s,e[0]=s,e[1]=n):n=e[1];const{Text:r,Reasoning:o,Image:i,Source:a,File:c,Unstable_Audio:l,tools:u,data:d}=n,f=r===void 0?Le.Text:r,h=o===void 0?Le.Reasoning:o,m=i===void 0?Le.Image:i,p=a===void 0?Le.Source:a,g=c===void 0?Le.File:c,_=l===void 0?Le.Unstable_Audio:l;let C;e[2]!==u?(C=u===void 0?{}:u,e[2]=u,e[3]=C):C=e[3];const S=C,y=H(),x=D(G_),E=x.type;if(E==="tool-call"){let I;e[4]!==y?(I=y.part(),e[4]=y,e[5]=I):I=e[5];const R=I.addToolResult;let P;e[6]!==y?(P=y.part(),e[6]=y,e[7]=P):P=e[7];const k=P.resumeToolCall;let O;e[8]!==y?(O=y.part(),e[8]=y,e[9]=O):O=e[9];const $=O.respondToToolApproval;if("Override"in S){let U;return e[10]!==R||e[11]!==x||e[12]!==$||e[13]!==k||e[14]!==S.Override?(U=v.jsx(S.Override,{...x,addResult:R,resume:k,respondToApproval:$}),e[10]=R,e[11]=x,e[12]=$,e[13]=k,e[14]=S.Override,e[15]=U):U=e[15],U}const M=S.by_name?.[x.toolName]??S.Fallback;let B;return e[16]!==M||e[17]!==R||e[18]!==x||e[19]!==$||e[20]!==k?(B=v.jsx(L_,{...x,Fallback:M,addResult:R,resume:k,respondToApproval:$}),e[16]=M,e[17]=R,e[18]=x,e[19]=$,e[20]=k,e[21]=B):B=e[21],B}if(x.status?.type==="requires-action")throw new Error("Encountered unexpected requires-action status");switch(E){case"text":{let I;return e[22]!==f||e[23]!==x?(I=v.jsx(f,{...x}),e[22]=f,e[23]=x,e[24]=I):I=e[24],I}case"reasoning":{let I;return e[25]!==h||e[26]!==x?(I=v.jsx(h,{...x}),e[25]=h,e[26]=x,e[27]=I):I=e[27],I}case"source":{let I;return e[28]!==p||e[29]!==x?(I=v.jsx(p,{...x}),e[28]=p,e[29]=x,e[30]=I):I=e[30],I}case"image":{let I;return e[31]!==m||e[32]!==x?(I=v.jsx(m,{...x}),e[31]=m,e[32]=x,e[33]=I):I=e[33],I}case"file":{let I;return e[34]!==g||e[35]!==x?(I=v.jsx(g,{...x}),e[34]=g,e[35]=x,e[36]=I):I=e[36],I}case"audio":{let I;return e[37]!==_||e[38]!==x?(I=v.jsx(_,{...x}),e[37]=_,e[38]=x,e[39]=I):I=e[39],I}case"data":{const I=d?.by_name?.[x.name]??d?.Fallback;let R;return e[40]!==I||e[41]!==x?(R=v.jsx(j_,{...x,Fallback:I}),e[40]=I,e[41]=x,e[42]=R):R=e[42],R}default:return console.warn(`Unknown message part type: ${E}`),null}},F_=t=>{const e=T(5),{partIndex:s,components:n}=t;let r;e[0]!==n?(r=v.jsx(B_,{components:n}),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=v.jsx(Un,{index:s,children:r}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o},U_=b.memo(F_,(t,e)=>t.partIndex===e.partIndex&&t.components?.Text===e.components?.Text&&t.components?.Reasoning===e.components?.Reasoning&&t.components?.Source===e.components?.Source&&t.components?.Image===e.components?.Image&&t.components?.File===e.components?.File&&t.components?.Unstable_Audio===e.components?.Unstable_Audio&&t.components?.tools===e.components?.tools&&t.components?.data===e.components?.data&&t.components?.Group===e.components?.Group),V_=t=>{const e=T(6),{status:s,component:n}=t,r=s.type==="running";let o;e[0]!==n||e[1]!==s?(o=v.jsx(n,{type:"text",text:"",status:s}),e[0]=n,e[1]=s,e[2]=o):o=e[2];let i;return e[3]!==r||e[4]!==o?(i=v.jsx(Vn,{text:"",isRunning:r,children:o}),e[3]=r,e[4]=o,e[5]=i):i=e[5],i},H_=Object.freeze({type:"complete"}),q_=t=>{const e=T(6),{components:s}=t,n=D(K_);if(s?.Empty){let i;return e[0]!==s.Empty||e[1]!==n?(i=v.jsx(s.Empty,{status:n}),e[0]=s.Empty,e[1]=n,e[2]=i):i=e[2],i}const r=s?.Text??Le.Text;let o;return e[3]!==n||e[4]!==r?(o=v.jsx(V_,{status:n,component:r}),e[3]=n,e[4]=r,e[5]=o):o=e[5],o},z_=b.memo(q_,(t,e)=>t.components?.Empty===e.components?.Empty&&t.components?.Text===e.components?.Text),hr=t=>{const e=T(9),{groupingFunction:s,components:n}=t,r=D(Y_),o=N_(s);let i;e:{if(r===0){let u;e[0]!==n?(u=v.jsx(z_,{components:n}),e[0]=n,e[1]=u):u=e[1],i=u;break e}let l;if(e[2]!==n||e[3]!==o){let u;e[5]!==n?(u=(d,f)=>v.jsx(n?.Group??Le.Group,{groupKey:d.groupKey,indices:d.indices,children:d.indices.map(h=>v.jsx(U_,{partIndex:h,components:n},h))},`group-${f}-${d.groupKey??"ungrouped"}`),e[5]=n,e[6]=u):u=e[6],l=o.map(u),e[2]=n,e[3]=o,e[4]=l}else l=e[4];i=l}const a=i;let c;return e[7]!==a?(c=v.jsx(v.Fragment,{children:a}),e[7]=a,e[8]=c):c=e[8],c};hr.displayName="MessagePrimitive.Unstable_PartsGrouped";const ll=t=>{const e=T(6);let s,n;e[0]!==t?({components:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let r;return e[3]!==s||e[4]!==n?(r=v.jsx(hr,{...n,components:s,groupingFunction:$_}),e[3]=s,e[4]=n,e[5]=r):r=e[5],r};ll.displayName="MessagePrimitive.Unstable_PartsGroupedByParentId";function W_(t){return t.message.parts}function G_(t){return t.part}function K_(t){return t.message.status??H_}function Y_(t){return t.message.parts.length}var eS=Ue({AttachmentByIndex:()=>Ca,Attachments:()=>Ta,Content:()=>wn,Error:()=>cl,GenerativeUI:()=>da,GroupedParts:()=>Sa,If:()=>Ac,PartByIndex:()=>At,Parts:()=>wn,Quote:()=>xa,Root:()=>al,Unstable_PartsGrouped:()=>hr,Unstable_PartsGroupedByParentId:()=>ll});const Q_=t=>{const e=T(2),s=Oe(t);let n;return e[0]!==s?(n=r=>{const o=new ResizeObserver(()=>{s()}),i=new MutationObserver(a=>{a.some(J_)&&s()});return o.observe(r),i.observe(r,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{o.disconnect(),i.disconnect()}},e[0]=s,e[1]=n):n=e[1],rt(n)};function J_(t){return t.type!=="attributes"||t.attributeName!=="style"}const X_=({autoScroll:t,scrollToBottomOnRunStart:e=!0,scrollToBottomOnInitialize:s=!0,scrollToBottomOnThreadSwitch:n=!0})=>{const r=W(null),o=D(y=>y.thread.messages.length>0),i=W(!1),a=W(null),c=nt();t===void 0&&(t=c.getState().turnAnchor!=="top");const l=W(0),u=W(0),d=W(0),f=W(0),h=W(null),m=It(y=>{const x=r.current;x&&(h.current=y,x.scrollTo({top:x.scrollHeight,behavior:y}))},[]),p=It(y=>{h.current=y,a.current!==null&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{a.current=null,m(y)})},[m]);is(()=>()=>{a.current!==null&&cancelAnimationFrame(a.current)},[]);const g=It(()=>{const y=c.getState();return y.turnAnchor==="top"&&y.element.viewport===r.current&&y.element.anchor!==null},[c]),_=()=>{const y=r.current;if(!y)return;const x=c.getState().isAtBottom,E=Math.abs(y.scrollHeight-y.scrollTop-y.clientHeight)<=1||y.scrollHeight<=y.clientHeight;!E&&l.current<y.scrollTop||(E?y.scrollHeight>y.clientHeight+1&&(h.current=null):l.current>y.scrollTop&&u.current===y.scrollHeight&&(h.current=null),(E||h.current===null)&&E!==x&&ms(c).setState({isAtBottom:E})),l.current=y.scrollTop,u.current=y.scrollHeight},C=Q_(()=>{const y=r.current;if(!y)return;const{scrollHeight:x,clientHeight:E}=y;if(x===d.current&&E===f.current)return;d.current=x,f.current=E;const I=h.current;I&&g()?h.current=null:I?m(I):t&&c.getState().isAtBottom&&m("instant"),_()}),S=rt(y=>{const x=()=>{h.current=null};return y.addEventListener("scroll",_),y.addEventListener("pointerdown",x),()=>{y.removeEventListener("scroll",_),y.removeEventListener("pointerdown",x)}});return is(()=>{if(s){if(!o){i.current=!1;return}i.current||(i.current=!0,h.current===null&&p("instant"))}},[o,p,s]),Fc(({behavior:y})=>{m(y)}),cs("thread.runStart",()=>{e&&c.getState().turnAnchor!=="top"&&p("auto")}),cs("threadListItem.switchedTo",()=>{n&&p("instant")}),ae(C,S,r)},ul=b.forwardRef((t,e)=>{const s=T(3);let n;return s[0]!==t||s[1]!==e?(n=v.jsx(X.div,{...t,ref:e}),s[0]=t,s[1]=e,s[2]=n):n=s[2],n});ul.displayName="ThreadPrimitive.Root";const dl=t=>{const{children:e}=t;return D(Z_)?e:null};dl.displayName="ThreadPrimitive.Empty";function Z_(t){return t.thread.isEmpty}const e1=t=>{const e=T(4);let s;return e[0]!==t.disabled||e[1]!==t.empty||e[2]!==t.running?(s=n=>!(t.empty===!0&&!n.thread.isEmpty||t.empty===!1&&n.thread.isEmpty||t.running===!0&&!n.thread.isRunning||t.running===!1&&n.thread.isRunning||t.disabled===!0&&!n.thread.isDisabled||t.disabled===!1&&n.thread.isDisabled),e[0]=t.disabled,e[1]=t.empty,e[2]=t.running,e[3]=s):s=e[3],D(s)},fl=t=>{const e=T(3);let s,n;return e[0]!==t?({children:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]),e1(n)?s:null};fl.displayName="ThreadPrimitive.If";const hl=(t,e)=>{const s=T(3);let n;return s[0]!==e||s[1]!==t?(n=r=>{if(!t)return;const o=t(),i=()=>{const c=e?e(r):r.offsetHeight;o.setHeight(c)},a=new ResizeObserver(i);return a.observe(r),i(),()=>{a.disconnect(),o.unregister()}},s[0]=e,s[1]=t,s[2]=n):n=s[2],rt(n)},Wo=t=>{let e=0,s=t;for(;s;)e+=s.offsetTop,s=s.offsetParent;return e},t1=(t,e)=>{let s=0,n=t;for(;n&&n!==e;)s+=n.offsetTop,n=n.offsetParent;return n===e?s:Wo(t)-Wo(e)},ml=({viewport:t,anchor:e,tallerThan:s,visibleHeight:n})=>{const r=t1(e,t),o=e.offsetHeight;return r+Math.max(0,o-(o<=s?o:n))},s1=({scrollHeight:t,...e})=>{const{viewport:s}=e,n=ml(e)+s.clientHeight;return Math.max(0,n-t)},n1=({viewport:t,reserve:e,...s})=>s1({viewport:t,...s,scrollHeight:t.scrollHeight-e.offsetHeight}),r1=t=>{const e=new ResizeObserver(t),s=new MutationObserver(t);let n=null,r=null,o=null;const i=()=>{e.disconnect(),s.disconnect(),n=null,r=null,o=null};return{target:(a,c,l)=>{n===a&&r===c&&o===l||(i(),e.observe(a),e.observe(c),e.observe(l),s.observe(l,{childList:!0,subtree:!0,characterData:!0}),n=a,r=c,o=l)},disconnect:i}},o1=t=>{let e=null;return{schedule:()=>{e===null&&(e=requestAnimationFrame(()=>{e=null,t()}))},cancel:()=>{e!==null&&(cancelAnimationFrame(e),e=null)}}},i1=t=>{let e=null,s;function n(){const a=t.getState(),{viewport:c,anchor:l,target:u}=a.element,d=a.targetConfig;if(a.turnAnchor!=="top"||!c||!l||!u||!d){o.disconnect(),e&&(zo(e,0),e.remove());return}if(e??=w_(),(e.parentElement!==u.parentElement||e.previousElementSibling!==u)&&u.after(e),o.target(c,l,u),zo(e,n1({viewport:c,anchor:l,reserve:e,...d}))){r.schedule();return}const f=x_(l);if(f!==void 0&&s===f)return;const h=C_(ml({viewport:c,anchor:l,...d}));Math.abs(c.scrollTop-h)>1&&c.scrollTo({top:h,behavior:"smooth"}),f!==void 0&&(s=f)}const r=o1(n),o=r1(r.schedule);r.schedule();const i=t.subscribe(r.schedule);return()=>{r.cancel(),i(),o.disconnect(),e?.remove()}},a1=t=>{const e=T(4),s=nt();let n,r;e[0]!==t||e[1]!==s?(n=()=>{if(t)return i1(s)},r=[t,s],e[0]=t,e[1]=s,e[2]=n,e[3]=r):(n=e[2],r=e[3]),is(n,r)},pl=({isRunning:t,messages:e})=>{if(!t)return null;const s=e.at(-1),n=e.at(-2);return n?.role!=="user"||s?.role!=="assistant"?null:{anchorId:n.id,targetId:s.id}},c1=t=>pl(t)?.anchorId,l1=t=>pl(t)?.targetId,u1=()=>hl(st(h1),m1),d1=()=>rt(st(p1)),f1=t=>{const e=T(13),s=nt();let n;e[0]!==t?(n=h=>{if(t)return c1(h.thread)},e[0]=t,e[1]=n):n=e[1];const r=D(n);let o;e[2]!==t?(o=h=>{if(t)return l1(h.thread)},e[2]=t,e[3]=o):o=e[3];const i=D(o);let a;e:{if(!r||!i){a=null;break e}let h;e[4]!==r||e[5]!==i?(h={anchorId:r,targetId:i},e[4]=r,e[5]=i,e[6]=h):h=e[6],a=h}const c=a;let l,u;e[7]!==c||e[8]!==s?(l=()=>{if(!c)return;const h=s.getState(),m=h.topAnchorTurn;m?.anchorId===c.anchorId&&m.targetId===c.targetId||h.setTopAnchorTurn(c)},u=[c,s],e[7]=c,e[8]=s,e[9]=l,e[10]=u):(l=e[9],u=e[10]),is(l,u);let d;e[11]!==s?(d=()=>{s.getState().setTopAnchorTurn(null)},e[11]=s,e[12]=d):d=e[12];const f=d;cs("thread.initialize",f),cs("threadListItem.switchedTo",f)},gl=b.forwardRef((t,e)=>{const s=T(18);let n,r,o,i,a,c;s[0]!==t?({autoScroll:n,scrollToBottomOnRunStart:a,scrollToBottomOnInitialize:i,scrollToBottomOnThreadSwitch:c,children:r,...o}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o,s[4]=i,s[5]=a,s[6]=c):(n=s[1],r=s[2],o=s[3],i=s[4],a=s[5],c=s[6]);let l;s[7]!==n||s[8]!==i||s[9]!==a||s[10]!==c?(l={autoScroll:n,scrollToBottomOnRunStart:a,scrollToBottomOnInitialize:i,scrollToBottomOnThreadSwitch:c},s[7]=n,s[8]=i,s[9]=a,s[10]=c,s[11]=l):l=s[11];const u=X_(l),d=u1(),f=d1(),h=nt();let m;s[12]!==h?(m=h.getState(),s[12]=h,s[13]=m):m=s[13];const p=m.turnAnchor==="top";f1(p),a1(p);const g=ae(e,u,d,f);let _;return s[14]!==r||s[15]!==g||s[16]!==o?(_=v.jsx(X.div,{...o,ref:g,children:r}),s[14]=r,s[15]=g,s[16]=o,s[17]=_):_=s[17],_});gl.displayName="ThreadPrimitive.ViewportScrollable";const vl=b.forwardRef((t,e)=>{const s=T(13);let n,r,o;s[0]!==t?({turnAnchor:o,topAnchorMessageClamp:r,...n}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o):(n=s[1],r=s[2],o=s[3]);let i;s[4]!==r||s[5]!==o?(i={turnAnchor:o,topAnchorMessageClamp:r},s[4]=r,s[5]=o,s[6]=i):i=s[6];let a;s[7]!==n||s[8]!==e?(a=v.jsx(gl,{...n,ref:e}),s[7]=n,s[8]=e,s[9]=a):a=s[9];let c;return s[10]!==i||s[11]!==a?(c=v.jsx(Jn,{options:i,children:a}),s[10]=i,s[11]=a,s[12]=c):c=s[12],c});vl.displayName="ThreadPrimitive.Viewport";function h1(t){return t.registerViewport}function m1(t){return t.clientHeight}function p1(t){return t.registerViewportElement}const bl=b.forwardRef((t,e)=>{const s=T(3),n=ae(e,hl(st(g1),v1));let r;return s[0]!==t||s[1]!==n?(r=v.jsx(X.div,{...t,ref:n}),s[0]=t,s[1]=n,s[2]=r):r=s[2],r});bl.displayName="ThreadPrimitive.ViewportFooter";function g1(t){return t.registerContentInset}function v1(t){const e=parseFloat(getComputedStyle(t).marginTop)||0;return t.offsetHeight+e}const b1=t=>{const e=T(5);let s;e[0]!==t?(s=t===void 0?{}:t,e[0]=t,e[1]=s):s=e[1];const{behavior:n}=s,r=st(_1),o=nt();let i;e[2]!==n||e[3]!==o?(i=()=>{o.getState().scrollToBottom({behavior:n})},e[2]=n,e[3]=o,e[4]=i):i=e[4];const a=i;return r?null:a},y1=ce("ThreadPrimitive.ScrollToBottom",b1,["behavior"]);function _1(t){return t.isAtBottom}const S1=t=>{const e=T(4),{prompt:s,send:n,clearComposer:r,autoSend:o}=t,i=n??o??!1;let a;e[0]!==r||e[1]!==s||e[2]!==i?(a={prompt:s,send:i,clearComposer:r},e[0]=r,e[1]=s,e[2]=i,e[3]=a):a=e[3];const{disabled:c,trigger:l}=wp(a);return c?null:l},x1=ce("ThreadPrimitive.Suggestion",S1,["prompt","send","clearComposer","autoSend","method"]);var tS=Ue({Empty:()=>dl,If:()=>fl,MessageByIndex:()=>ia,Messages:()=>Kh,Root:()=>ul,ScrollToBottom:()=>y1,Suggestion:()=>x1,SuggestionByIndex:()=>ka,Suggestions:()=>Wm,Unstable_MessageById:()=>aa,Viewport:()=>vl,ViewportFooter:()=>bl,ViewportProvider:()=>Jn});const yl=b.forwardRef((t,e)=>{const s=T(15);let n,r,o;s[0]!==t?({onClick:r,disabled:n,...o}=t,s[0]=t,s[1]=n,s[2]=r,s[3]=o):(n=s[1],r=s[2],o=s[3]);const i=D(w1),{switchToNewThread:a}=Ap();let c;s[4]!==i?(c=i?{"data-active":"true","aria-current":"true"}:null,s[4]=i,s[5]=c):c=s[5];let l;s[6]!==r||s[7]!==a?(l=K(r,a),s[6]=r,s[7]=a,s[8]=l):l=s[8];let u;return s[9]!==n||s[10]!==e||s[11]!==o||s[12]!==c||s[13]!==l?(u=v.jsx(X.button,{type:"button",...c,...o,ref:e,disabled:n,onClick:l}),s[9]=n,s[10]=e,s[11]=o,s[12]=c,s[13]=l,s[14]=u):u=s[14],u});yl.displayName="ThreadListPrimitive.New";function w1(t){return t.threads.newThreadId===t.threads.mainThreadId}const C1=()=>{const{loadMore:t,disabled:e}=Pp();return e?null:t},T1=ce("ThreadListPrimitive.LoadMore",C1),[E1,I1]=Cg("ThreadList"),Cn=E1,_l=fe(null),R1=_l.Provider,A1=()=>me(_l),Sl=b.forwardRef((t,e)=>{const s=T(3);let n;return s[0]!==t||s[1]!==e?(n=v.jsx(Cn.Provider,{scope:void 0,children:v.jsx(Cn.Slot,{scope:void 0,children:v.jsx(X.div,{...t,ref:e})})}),s[0]=t,s[1]=e,s[2]=n):n=s[2],n});Sl.displayName="ThreadListPrimitive.Root";var sS=Ue({ItemByIndex:()=>Pa,Items:()=>Ma,LoadMore:()=>T1,New:()=>yl,Root:()=>Sl});const xl=b.forwardRef((t,e)=>{const s=D(l=>l.threads.mainThreadId===l.threadListItem.id),n=W(null),r=W(null),o=te(()=>({triggerRef:n,moreRef:r}),[]),i=I1(void 0),a=Ng(),c=l=>{const u=a==="rtl"?"ArrowLeft":"ArrowRight",d=a==="rtl"?"ArrowRight":"ArrowLeft",f=n.current,h=r.current;if(f&&l.target===f)if(l.key==="ArrowDown"||l.key==="ArrowUp"){const m=i().map(g=>g.ref.current).filter(g=>g!==null),p=m[m.indexOf(f)+(l.key==="ArrowDown"?1:-1)];p&&(p.focus(),l.preventDefault())}else l.key===u&&h&&(h.focus(),l.preventDefault());else h&&l.target===h&&l.key===d&&(f?.focus(),l.preventDefault())};return v.jsx(R1,{value:o,children:v.jsx(X.div,{...s?{"data-active":"true","aria-current":"true"}:null,...t,onKeyDown:K(t.onKeyDown,c),ref:e})})});xl.displayName="ThreadListItemPrimitive.Root";const P1=()=>{const{archive:t}=Tp();return t},M1=ce("ThreadListItemPrimitive.Archive",P1),D1=()=>{const{unarchive:t}=Ip();return t},O1=ce("ThreadListItemPrimitive.Unarchive",D1),k1=()=>{const{delete:t}=Ep();return t},$1=ce("ThreadListItemPrimitive.Delete",k1),N1=()=>{const{switchTo:t}=Rp();return t},L1=ce("ThreadListItemPrimitive.Trigger",N1),wl=b.forwardRef((t,e)=>{const s=T(3),n=ae(e,A1()?.triggerRef);let r;return s[0]!==t||s[1]!==n?(r=v.jsx(Cn.ItemSlot,{scope:void 0,children:v.jsx(L1,{...t,ref:n})}),s[0]=t,s[1]=n,s[2]=r):r=s[2],r});wl.displayName="ThreadListItemPrimitive.Trigger";var nS=Ue({Archive:()=>M1,Delete:()=>$1,Root:()=>xl,Title:()=>Da,Trigger:()=>wl,Unarchive:()=>O1});const rS=(t,e)=>{const s=T(5),n=W(null),r=W(null);let o,i;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>()=>{r.current?.()},i=[],s[0]=o,s[1]=i):(o=s[0],i=s[1]),q(o,i);let a;return s[2]!==t||s[3]!==e?(a=()=>{r.current?.(),(function(){if(n.current||!t.current)return;let S=t.current;for(;S;){const{overflowY:y}=getComputedStyle(S);if(y==="scroll"||y==="auto"){n.current=S;break}S=S.parentElement}})();const c=n.current;if(!c)return;const l=c.scrollTop,u=c.style.scrollbarWidth,d=getComputedStyle(c),f=d.direction==="rtl"?"paddingLeft":"paddingRight",h=c.style[f],m=c.offsetWidth-c.clientWidth-parseFloat(d.borderLeftWidth)-parseFloat(d.borderRightWidth);c.style.scrollbarWidth="none",m>0&&(c.style[f]=`${parseFloat(d[f])+m}px`);const p=()=>{c.style.scrollbarWidth=u,c.style[f]=h},g=()=>c.scrollTop=l;c.addEventListener("scroll",g);const _=setTimeout(()=>{c.removeEventListener("scroll",g),p(),r.current=null},e);r.current=()=>{clearTimeout(_),c.removeEventListener("scroll",g),p()}},s[2]=t,s[3]=e,s[4]=a):a=s[4],a};var oS=Ue({AssistantRuntimeImpl:()=>ta,BaseAssistantRuntimeCore:()=>sa,CompositeContextProvider:()=>$n,DefaultThreadComposerRuntimeCore:()=>oa,MessageRepository:()=>qn,ThreadRuntimeImpl:()=>ea,getAutoStatus:()=>hs,splitLocalRuntimeOptions:()=>kp,useComposerInputPluginRegistryOptional:()=>Ns,useSmooth:()=>ol,useSmoothStatus:()=>v_,withSmoothContextProvider:()=>g_});function iS(t){const{commands:e,removeOnExecute:s}=t,n=W(e);return n.current=e,te(()=>({adapter:{categories:()=>[],categoryItems:()=>[],search:r=>{const o=r.toLowerCase();return n.current.filter(i=>B1(i,o)).map(j1)}},action:{onExecute:r=>{n.current.find(o=>o.id===r.id)?.execute()},...s!==void 0?{removeOnExecute:s}:{}},...t.iconMap?{iconMap:t.iconMap}:{},...t.fallbackIcon?{fallbackIcon:t.fallbackIcon}:{}}),[s,t.iconMap,t.fallbackIcon])}function j1(t){return{id:t.id,type:"command",label:t.label??`/${t.id}`,...t.description!==void 0?{description:t.description}:{},...t.icon!==void 0?{metadata:{icon:t.icon}}:{}}}function B1(t,e){return!!(!e||t.id.toLowerCase().includes(e)||t.label?.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))}export{tS as $,Be as A,Y1 as B,Q1 as C,Ee as D,q1 as E,W1 as F,G1 as G,K1 as H,Ds as I,Gs as J,Vv as K,zv as L,Wv as M,Yv as N,Up as O,Ae as P,eS as Q,Tn as R,cs as S,Z1 as T,H as U,D as V,X1 as W,U1 as X,rS as Y,H1 as Z,iS as _,f_ as a,sS as a0,nS as a1,F1 as a2,V1 as a3,Ko as b,Pl as c,Ao as d,Ve as e,Ie as f,Go as g,Re as h,oS as i,v as j,xt as k,Xn as l,bc as m,de as n,$t as o,Xe as p,z1 as q,b as r,je as s,db as t,Oe as u,gc as v,jt as w,pc as x,nb as y,J1 as z};