aitable-workflow-cli 0.1.28-beta.1789632452666 → 0.1.28

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.
@@ -0,0 +1,79 @@
1
+ var xb=Object.defineProperty;var dp=t=>{throw TypeError(t)};var Sb=(t,e,n)=>e in t?xb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var w=(t,e,n)=>Sb(t,typeof e!="symbol"?e+"":e,n),hp=(t,e,n)=>e.has(t)||dp("Cannot "+n);var Pt=(t,e,n)=>(hp(t,e,"read from private field"),n?n.call(t):e.get(t)),cn=(t,e,n)=>e.has(t)?dp("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),dn=(t,e,n,r)=>(hp(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n);function bb(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in t)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var ka=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var iv={exports:{}},ml={},ov={exports:{}},ie={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its 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 yo=Symbol.for("react.element"),Tb=Symbol.for("react.portal"),kb=Symbol.for("react.fragment"),Cb=Symbol.for("react.strict_mode"),Ib=Symbol.for("react.profiler"),Eb=Symbol.for("react.provider"),Rb=Symbol.for("react.context"),Ab=Symbol.for("react.forward_ref"),Pb=Symbol.for("react.suspense"),Mb=Symbol.for("react.memo"),Db=Symbol.for("react.lazy"),fp=Symbol.iterator;function Ob(t){return t===null||typeof t!="object"?null:(t=fp&&t[fp]||t["@@iterator"],typeof t=="function"?t:null)}var av={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},lv=Object.assign,uv={};function Ls(t,e,n){this.props=t,this.context=e,this.refs=uv,this.updater=n||av}Ls.prototype.isReactComponent={};Ls.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Ls.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function cv(){}cv.prototype=Ls.prototype;function Ud(t,e,n){this.props=t,this.context=e,this.refs=uv,this.updater=n||av}var Vd=Ud.prototype=new cv;Vd.constructor=Ud;lv(Vd,Ls.prototype);Vd.isPureReactComponent=!0;var pp=Array.isArray,dv=Object.prototype.hasOwnProperty,Hd={current:null},hv={key:!0,ref:!0,__self:!0,__source:!0};function fv(t,e,n){var r,s={},i=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(i=""+e.key),e)dv.call(e,r)&&!hv.hasOwnProperty(r)&&(s[r]=e[r]);var a=arguments.length-2;if(a===1)s.children=n;else if(1<a){for(var l=Array(a),u=0;u<a;u++)l[u]=arguments[u+2];s.children=l}if(t&&t.defaultProps)for(r in a=t.defaultProps,a)s[r]===void 0&&(s[r]=a[r]);return{$$typeof:yo,type:t,key:i,ref:o,props:s,_owner:Hd.current}}function Nb(t,e){return{$$typeof:yo,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function qd(t){return typeof t=="object"&&t!==null&&t.$$typeof===yo}function Lb(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(n){return e[n]})}var mp=/\/+/g;function Jl(t,e){return typeof t=="object"&&t!==null&&t.key!=null?Lb(""+t.key):e.toString(36)}function aa(t,e,n,r,s){var i=typeof t;(i==="undefined"||i==="boolean")&&(t=null);var o=!1;if(t===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(t.$$typeof){case yo:case Tb:o=!0}}if(o)return o=t,s=s(o),t=r===""?"."+Jl(o,0):r,pp(s)?(n="",t!=null&&(n=t.replace(mp,"$&/")+"/"),aa(s,e,n,"",function(u){return u})):s!=null&&(qd(s)&&(s=Nb(s,n+(!s.key||o&&o.key===s.key?"":(""+s.key).replace(mp,"$&/")+"/")+t)),e.push(s)),1;if(o=0,r=r===""?".":r+":",pp(t))for(var a=0;a<t.length;a++){i=t[a];var l=r+Jl(i,a);o+=aa(i,e,n,l,s)}else if(l=Ob(t),typeof l=="function")for(t=l.call(t),a=0;!(i=t.next()).done;)i=i.value,l=r+Jl(i,a++),o+=aa(i,e,n,l,s);else if(i==="object")throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.");return o}function Ro(t,e,n){if(t==null)return t;var r=[],s=0;return aa(t,r,"","",function(i){return e.call(n,i,s++)}),r}function jb(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(n){(t._status===0||t._status===-1)&&(t._status=1,t._result=n)},function(n){(t._status===0||t._status===-1)&&(t._status=2,t._result=n)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var rt={current:null},la={transition:null},$b={ReactCurrentDispatcher:rt,ReactCurrentBatchConfig:la,ReactCurrentOwner:Hd};function pv(){throw Error("act(...) is not supported in production builds of React.")}ie.Children={map:Ro,forEach:function(t,e,n){Ro(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return Ro(t,function(){e++}),e},toArray:function(t){return Ro(t,function(e){return e})||[]},only:function(t){if(!qd(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};ie.Component=Ls;ie.Fragment=kb;ie.Profiler=Ib;ie.PureComponent=Ud;ie.StrictMode=Cb;ie.Suspense=Pb;ie.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=$b;ie.act=pv;ie.cloneElement=function(t,e,n){if(t==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var r=lv({},t.props),s=t.key,i=t.ref,o=t._owner;if(e!=null){if(e.ref!==void 0&&(i=e.ref,o=Hd.current),e.key!==void 0&&(s=""+e.key),t.type&&t.type.defaultProps)var a=t.type.defaultProps;for(l in e)dv.call(e,l)&&!hv.hasOwnProperty(l)&&(r[l]=e[l]===void 0&&a!==void 0?a[l]:e[l])}var l=arguments.length-2;if(l===1)r.children=n;else if(1<l){a=Array(l);for(var u=0;u<l;u++)a[u]=arguments[u+2];r.children=a}return{$$typeof:yo,type:t.type,key:s,ref:i,props:r,_owner:o}};ie.createContext=function(t){return t={$$typeof:Rb,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},t.Provider={$$typeof:Eb,_context:t},t.Consumer=t};ie.createElement=fv;ie.createFactory=function(t){var e=fv.bind(null,t);return e.type=t,e};ie.createRef=function(){return{current:null}};ie.forwardRef=function(t){return{$$typeof:Ab,render:t}};ie.isValidElement=qd;ie.lazy=function(t){return{$$typeof:Db,_payload:{_status:-1,_result:t},_init:jb}};ie.memo=function(t,e){return{$$typeof:Mb,type:t,compare:e===void 0?null:e}};ie.startTransition=function(t){var e=la.transition;la.transition={};try{t()}finally{la.transition=e}};ie.unstable_act=pv;ie.useCallback=function(t,e){return rt.current.useCallback(t,e)};ie.useContext=function(t){return rt.current.useContext(t)};ie.useDebugValue=function(){};ie.useDeferredValue=function(t){return rt.current.useDeferredValue(t)};ie.useEffect=function(t,e){return rt.current.useEffect(t,e)};ie.useId=function(){return rt.current.useId()};ie.useImperativeHandle=function(t,e,n){return rt.current.useImperativeHandle(t,e,n)};ie.useInsertionEffect=function(t,e){return rt.current.useInsertionEffect(t,e)};ie.useLayoutEffect=function(t,e){return rt.current.useLayoutEffect(t,e)};ie.useMemo=function(t,e){return rt.current.useMemo(t,e)};ie.useReducer=function(t,e,n){return rt.current.useReducer(t,e,n)};ie.useRef=function(t){return rt.current.useRef(t)};ie.useState=function(t){return rt.current.useState(t)};ie.useSyncExternalStore=function(t,e,n){return rt.current.useSyncExternalStore(t,e,n)};ie.useTransition=function(){return rt.current.useTransition()};ie.version="18.3.1";ov.exports=ie;var ee=ov.exports;const Nt=pl(ee),zb=bb({__proto__:null,default:Nt},[ee]);/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its 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 Fb=ee,Bb=Symbol.for("react.element"),Ub=Symbol.for("react.fragment"),Vb=Object.prototype.hasOwnProperty,Hb=Fb.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,qb={key:!0,ref:!0,__self:!0,__source:!0};function mv(t,e,n){var r,s={},i=null,o=null;n!==void 0&&(i=""+n),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)Vb.call(e,r)&&!qb.hasOwnProperty(r)&&(s[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)s[r]===void 0&&(s[r]=e[r]);return{$$typeof:Bb,type:t,key:i,ref:o,props:s,_owner:Hb.current}}ml.Fragment=Ub;ml.jsx=mv;ml.jsxs=mv;iv.exports=ml;var T=iv.exports,gv={exports:{}},It={},yv={exports:{}},vv={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its 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
+ */(function(t){function e($,U){var C=$.length;$.push(U);e:for(;0<C;){var Y=C-1>>>1,j=$[Y];if(0<s(j,U))$[Y]=U,$[C]=j,C=Y;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var U=$[0],C=$.pop();if(C!==U){$[0]=C;e:for(var Y=0,j=$.length,E=j>>>1;Y<E;){var q=2*(Y+1)-1,X=$[q],V=q+1,he=$[V];if(0>s(X,C))V<j&&0>s(he,X)?($[Y]=he,$[V]=C,Y=V):($[Y]=X,$[q]=C,Y=q);else if(V<j&&0>s(he,C))$[Y]=he,$[V]=C,Y=V;else break e}}return U}function s($,U){var C=$.sortIndex-U.sortIndex;return C!==0?C:$.id-U.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,a=o.now();t.unstable_now=function(){return o.now()-a}}var l=[],u=[],c=1,d=null,h=3,f=!1,p=!1,g=!1,_=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v($){for(var U=n(u);U!==null;){if(U.callback===null)r(u);else if(U.startTime<=$)r(u),U.sortIndex=U.expirationTime,e(l,U);else break;U=n(u)}}function S($){if(g=!1,v($),!p)if(n(l)!==null)p=!0,W(I);else{var U=n(u);U!==null&&K(S,U.startTime-$)}}function I($,U){p=!1,g&&(g=!1,m(A),A=-1),f=!0;var C=h;try{for(v(U),d=n(l);d!==null&&(!(d.expirationTime>U)||$&&!k());){var Y=d.callback;if(typeof Y=="function"){d.callback=null,h=d.priorityLevel;var j=Y(d.expirationTime<=U);U=t.unstable_now(),typeof j=="function"?d.callback=j:d===n(l)&&r(l),v(U)}else r(l);d=n(l)}if(d!==null)var E=!0;else{var q=n(u);q!==null&&K(S,q.startTime-U),E=!1}return E}finally{d=null,h=C,f=!1}}var b=!1,P=null,A=-1,D=5,x=-1;function k(){return!(t.unstable_now()-x<D)}function R(){if(P!==null){var $=t.unstable_now();x=$;var U=!0;try{U=P(!0,$)}finally{U?M():(b=!1,P=null)}}else b=!1}var M;if(typeof y=="function")M=function(){y(R)};else if(typeof MessageChannel<"u"){var L=new MessageChannel,z=L.port2;L.port1.onmessage=R,M=function(){z.postMessage(null)}}else M=function(){_(R,0)};function W($){P=$,b||(b=!0,M())}function K($,U){A=_(function(){$(t.unstable_now())},U)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function($){$.callback=null},t.unstable_continueExecution=function(){p||f||(p=!0,W(I))},t.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<$?Math.floor(1e3/$):5},t.unstable_getCurrentPriorityLevel=function(){return h},t.unstable_getFirstCallbackNode=function(){return n(l)},t.unstable_next=function($){switch(h){case 1:case 2:case 3:var U=3;break;default:U=h}var C=h;h=U;try{return $()}finally{h=C}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function($,U){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var C=h;h=$;try{return U()}finally{h=C}},t.unstable_scheduleCallback=function($,U,C){var Y=t.unstable_now();switch(typeof C=="object"&&C!==null?(C=C.delay,C=typeof C=="number"&&0<C?Y+C:Y):C=Y,$){case 1:var j=-1;break;case 2:j=250;break;case 5:j=1073741823;break;case 4:j=1e4;break;default:j=5e3}return j=C+j,$={id:c++,callback:U,priorityLevel:$,startTime:C,expirationTime:j,sortIndex:-1},C>Y?($.sortIndex=C,e(u,$),n(l)===null&&$===n(u)&&(g?(m(A),A=-1):g=!0,K(S,C-Y))):($.sortIndex=j,e(l,$),p||f||(p=!0,W(I))),$},t.unstable_shouldYield=k,t.unstable_wrapCallback=function($){var U=h;return function(){var C=h;h=U;try{return $.apply(this,arguments)}finally{h=C}}}})(vv);yv.exports=vv;var Gb=yv.exports;/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var Wb=ee,Tt=Gb;function F(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n<arguments.length;n++)e+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+t+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var _v=new Set,Di={};function qr(t,e){Is(t,e),Is(t+"Capture",e)}function Is(t,e){for(Di[t]=e,t=0;t<e.length;t++)_v.add(e[t])}var Mn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),dc=Object.prototype.hasOwnProperty,Qb=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,gp={},yp={};function Kb(t){return dc.call(yp,t)?!0:dc.call(gp,t)?!1:Qb.test(t)?yp[t]=!0:(gp[t]=!0,!1)}function Yb(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function Jb(t,e,n,r){if(e===null||typeof e>"u"||Yb(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function st(t,e,n,r,s,i,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=i,this.removeEmptyString=o}var qe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){qe[t]=new st(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];qe[e]=new st(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){qe[t]=new st(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){qe[t]=new st(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){qe[t]=new st(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){qe[t]=new st(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){qe[t]=new st(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){qe[t]=new st(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){qe[t]=new st(t,5,!1,t.toLowerCase(),null,!1,!1)});var Gd=/[\-:]([a-z])/g;function Wd(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Gd,Wd);qe[e]=new st(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Gd,Wd);qe[e]=new st(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Gd,Wd);qe[e]=new st(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){qe[t]=new st(t,1,!1,t.toLowerCase(),null,!1,!1)});qe.xlinkHref=new st("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){qe[t]=new st(t,1,!1,t.toLowerCase(),null,!0,!0)});function Qd(t,e,n,r){var s=qe.hasOwnProperty(e)?qe[e]:null;(s!==null?s.type!==0:r||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(Jb(e,n,s,r)&&(n=null),r||s===null?Kb(e)&&(n===null?t.removeAttribute(e):t.setAttribute(e,""+n)):s.mustUseProperty?t[s.propertyName]=n===null?s.type===3?!1:"":n:(e=s.attributeName,r=s.attributeNamespace,n===null?t.removeAttribute(e):(s=s.type,n=s===3||s===4&&n===!0?"":""+n,r?t.setAttributeNS(r,e,n):t.setAttribute(e,n))))}var jn=Wb.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Ao=Symbol.for("react.element"),os=Symbol.for("react.portal"),as=Symbol.for("react.fragment"),Kd=Symbol.for("react.strict_mode"),hc=Symbol.for("react.profiler"),wv=Symbol.for("react.provider"),xv=Symbol.for("react.context"),Yd=Symbol.for("react.forward_ref"),fc=Symbol.for("react.suspense"),pc=Symbol.for("react.suspense_list"),Jd=Symbol.for("react.memo"),Vn=Symbol.for("react.lazy"),Sv=Symbol.for("react.offscreen"),vp=Symbol.iterator;function Js(t){return t===null||typeof t!="object"?null:(t=vp&&t[vp]||t["@@iterator"],typeof t=="function"?t:null)}var Ie=Object.assign,Xl;function ci(t){if(Xl===void 0)try{throw Error()}catch(n){var e=n.stack.trim().match(/\n( *(at )?)/);Xl=e&&e[1]||""}return`
34
+ `+Xl+t}var Zl=!1;function eu(t,e){if(!t||Zl)return"";Zl=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(e)if(e=function(){throw Error()},Object.defineProperty(e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(e,[])}catch(u){var r=u}Reflect.construct(t,[],e)}else{try{e.call()}catch(u){r=u}t.call(e.prototype)}else{try{throw Error()}catch(u){r=u}t()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var s=u.stack.split(`
35
+ `),i=r.stack.split(`
36
+ `),o=s.length-1,a=i.length-1;1<=o&&0<=a&&s[o]!==i[a];)a--;for(;1<=o&&0<=a;o--,a--)if(s[o]!==i[a]){if(o!==1||a!==1)do if(o--,a--,0>a||s[o]!==i[a]){var l=`
37
+ `+s[o].replace(" at new "," at ");return t.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",t.displayName)),l}while(1<=o&&0<=a);break}}}finally{Zl=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?ci(t):""}function Xb(t){switch(t.tag){case 5:return ci(t.type);case 16:return ci("Lazy");case 13:return ci("Suspense");case 19:return ci("SuspenseList");case 0:case 2:case 15:return t=eu(t.type,!1),t;case 11:return t=eu(t.type.render,!1),t;case 1:return t=eu(t.type,!0),t;default:return""}}function mc(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case as:return"Fragment";case os:return"Portal";case hc:return"Profiler";case Kd:return"StrictMode";case fc:return"Suspense";case pc:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case xv:return(t.displayName||"Context")+".Consumer";case wv:return(t._context.displayName||"Context")+".Provider";case Yd:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Jd:return e=t.displayName||null,e!==null?e:mc(t.type)||"Memo";case Vn:e=t._payload,t=t._init;try{return mc(t(e))}catch{}}return null}function Zb(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return mc(e);case 8:return e===Kd?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function ir(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function bv(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function eT(t){var e=bv(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return s.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Po(t){t._valueTracker||(t._valueTracker=eT(t))}function Tv(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=bv(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function Ca(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function gc(t,e){var n=e.checked;return Ie({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function _p(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=ir(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function kv(t,e){e=e.checked,e!=null&&Qd(t,"checked",e,!1)}function yc(t,e){kv(t,e);var n=ir(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?vc(t,e.type,n):e.hasOwnProperty("defaultValue")&&vc(t,e.type,ir(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function wp(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function vc(t,e,n){(e!=="number"||Ca(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var di=Array.isArray;function vs(t,e,n,r){if(t=t.options,e){e={};for(var s=0;s<n.length;s++)e["$"+n[s]]=!0;for(n=0;n<t.length;n++)s=e.hasOwnProperty("$"+t[n].value),t[n].selected!==s&&(t[n].selected=s),s&&r&&(t[n].defaultSelected=!0)}else{for(n=""+ir(n),e=null,s=0;s<t.length;s++){if(t[s].value===n){t[s].selected=!0,r&&(t[s].defaultSelected=!0);return}e!==null||t[s].disabled||(e=t[s])}e!==null&&(e.selected=!0)}}function _c(t,e){if(e.dangerouslySetInnerHTML!=null)throw Error(F(91));return Ie({},e,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function xp(t,e){var n=e.value;if(n==null){if(n=e.children,e=e.defaultValue,n!=null){if(e!=null)throw Error(F(92));if(di(n)){if(1<n.length)throw Error(F(93));n=n[0]}e=n}e==null&&(e=""),n=e}t._wrapperState={initialValue:ir(n)}}function Cv(t,e){var n=ir(e.value),r=ir(e.defaultValue);n!=null&&(n=""+n,n!==t.value&&(t.value=n),e.defaultValue==null&&t.defaultValue!==n&&(t.defaultValue=n)),r!=null&&(t.defaultValue=""+r)}function Sp(t){var e=t.textContent;e===t._wrapperState.initialValue&&e!==""&&e!==null&&(t.value=e)}function Iv(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function wc(t,e){return t==null||t==="http://www.w3.org/1999/xhtml"?Iv(e):t==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var Mo,Ev=function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,n,r,s){MSApp.execUnsafeLocalFunction(function(){return t(e,n,r,s)})}:t}(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(Mo=Mo||document.createElement("div"),Mo.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=Mo.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Oi(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var gi={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},tT=["Webkit","ms","Moz","O"];Object.keys(gi).forEach(function(t){tT.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),gi[e]=gi[t]})});function Rv(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||gi.hasOwnProperty(t)&&gi[t]?(""+e).trim():e+"px"}function Av(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=Rv(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,s):t[n]=s}}var nT=Ie({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function xc(t,e){if(e){if(nT[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(F(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(F(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(F(61))}if(e.style!=null&&typeof e.style!="object")throw Error(F(62))}}function Sc(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var bc=null;function Xd(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Tc=null,_s=null,ws=null;function bp(t){if(t=wo(t)){if(typeof Tc!="function")throw Error(F(280));var e=t.stateNode;e&&(e=wl(e),Tc(t.stateNode,t.type,e))}}function Pv(t){_s?ws?ws.push(t):ws=[t]:_s=t}function Mv(){if(_s){var t=_s,e=ws;if(ws=_s=null,bp(t),e)for(t=0;t<e.length;t++)bp(e[t])}}function Dv(t,e){return t(e)}function Ov(){}var tu=!1;function Nv(t,e,n){if(tu)return t(e,n);tu=!0;try{return Dv(t,e,n)}finally{tu=!1,(_s!==null||ws!==null)&&(Ov(),Mv())}}function Ni(t,e){var n=t.stateNode;if(n===null)return null;var r=wl(n);if(r===null)return null;n=r[e];e:switch(e){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(t=t.type,r=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!r;break e;default:t=!1}if(t)return null;if(n&&typeof n!="function")throw Error(F(231,e,typeof n));return n}var kc=!1;if(Mn)try{var Xs={};Object.defineProperty(Xs,"passive",{get:function(){kc=!0}}),window.addEventListener("test",Xs,Xs),window.removeEventListener("test",Xs,Xs)}catch{kc=!1}function rT(t,e,n,r,s,i,o,a,l){var u=Array.prototype.slice.call(arguments,3);try{e.apply(n,u)}catch(c){this.onError(c)}}var yi=!1,Ia=null,Ea=!1,Cc=null,sT={onError:function(t){yi=!0,Ia=t}};function iT(t,e,n,r,s,i,o,a,l){yi=!1,Ia=null,rT.apply(sT,arguments)}function oT(t,e,n,r,s,i,o,a,l){if(iT.apply(this,arguments),yi){if(yi){var u=Ia;yi=!1,Ia=null}else throw Error(F(198));Ea||(Ea=!0,Cc=u)}}function Gr(t){var e=t,n=t;if(t.alternate)for(;e.return;)e=e.return;else{t=e;do e=t,e.flags&4098&&(n=e.return),t=e.return;while(t)}return e.tag===3?n:null}function Lv(t){if(t.tag===13){var e=t.memoizedState;if(e===null&&(t=t.alternate,t!==null&&(e=t.memoizedState)),e!==null)return e.dehydrated}return null}function Tp(t){if(Gr(t)!==t)throw Error(F(188))}function aT(t){var e=t.alternate;if(!e){if(e=Gr(t),e===null)throw Error(F(188));return e!==t?null:t}for(var n=t,r=e;;){var s=n.return;if(s===null)break;var i=s.alternate;if(i===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===i.child){for(i=s.child;i;){if(i===n)return Tp(s),t;if(i===r)return Tp(s),e;i=i.sibling}throw Error(F(188))}if(n.return!==r.return)n=s,r=i;else{for(var o=!1,a=s.child;a;){if(a===n){o=!0,n=s,r=i;break}if(a===r){o=!0,r=s,n=i;break}a=a.sibling}if(!o){for(a=i.child;a;){if(a===n){o=!0,n=i,r=s;break}if(a===r){o=!0,r=i,n=s;break}a=a.sibling}if(!o)throw Error(F(189))}}if(n.alternate!==r)throw Error(F(190))}if(n.tag!==3)throw Error(F(188));return n.stateNode.current===n?t:e}function jv(t){return t=aT(t),t!==null?$v(t):null}function $v(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var e=$v(t);if(e!==null)return e;t=t.sibling}return null}var zv=Tt.unstable_scheduleCallback,kp=Tt.unstable_cancelCallback,lT=Tt.unstable_shouldYield,uT=Tt.unstable_requestPaint,Me=Tt.unstable_now,cT=Tt.unstable_getCurrentPriorityLevel,Zd=Tt.unstable_ImmediatePriority,Fv=Tt.unstable_UserBlockingPriority,Ra=Tt.unstable_NormalPriority,dT=Tt.unstable_LowPriority,Bv=Tt.unstable_IdlePriority,gl=null,vn=null;function hT(t){if(vn&&typeof vn.onCommitFiberRoot=="function")try{vn.onCommitFiberRoot(gl,t,void 0,(t.current.flags&128)===128)}catch{}}var en=Math.clz32?Math.clz32:mT,fT=Math.log,pT=Math.LN2;function mT(t){return t>>>=0,t===0?32:31-(fT(t)/pT|0)|0}var Do=64,Oo=4194304;function hi(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Aa(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,s=t.suspendedLanes,i=t.pingedLanes,o=n&268435455;if(o!==0){var a=o&~s;a!==0?r=hi(a):(i&=o,i!==0&&(r=hi(i)))}else o=n&~s,o!==0?r=hi(o):i!==0&&(r=hi(i));if(r===0)return 0;if(e!==0&&e!==r&&!(e&s)&&(s=r&-r,i=e&-e,s>=i||s===16&&(i&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0<e;)n=31-en(e),s=1<<n,r|=t[n],e&=~s;return r}function gT(t,e){switch(t){case 1:case 2:case 4:return e+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function yT(t,e){for(var n=t.suspendedLanes,r=t.pingedLanes,s=t.expirationTimes,i=t.pendingLanes;0<i;){var o=31-en(i),a=1<<o,l=s[o];l===-1?(!(a&n)||a&r)&&(s[o]=gT(a,e)):l<=e&&(t.expiredLanes|=a),i&=~a}}function Ic(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function Uv(){var t=Do;return Do<<=1,!(Do&4194240)&&(Do=64),t}function nu(t){for(var e=[],n=0;31>n;n++)e.push(t);return e}function vo(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-en(e),t[e]=n}function vT(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0<n;){var s=31-en(n),i=1<<s;e[s]=0,r[s]=-1,t[s]=-1,n&=~i}}function eh(t,e){var n=t.entangledLanes|=e;for(t=t.entanglements;n;){var r=31-en(n),s=1<<r;s&e|t[r]&e&&(t[r]|=e),n&=~s}}var fe=0;function Vv(t){return t&=-t,1<t?4<t?t&268435455?16:536870912:4:1}var Hv,th,qv,Gv,Wv,Ec=!1,No=[],Yn=null,Jn=null,Xn=null,Li=new Map,ji=new Map,Gn=[],_T="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Cp(t,e){switch(t){case"focusin":case"focusout":Yn=null;break;case"dragenter":case"dragleave":Jn=null;break;case"mouseover":case"mouseout":Xn=null;break;case"pointerover":case"pointerout":Li.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":ji.delete(e.pointerId)}}function Zs(t,e,n,r,s,i){return t===null||t.nativeEvent!==i?(t={blockedOn:e,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[s]},e!==null&&(e=wo(e),e!==null&&th(e)),t):(t.eventSystemFlags|=r,e=t.targetContainers,s!==null&&e.indexOf(s)===-1&&e.push(s),t)}function wT(t,e,n,r,s){switch(e){case"focusin":return Yn=Zs(Yn,t,e,n,r,s),!0;case"dragenter":return Jn=Zs(Jn,t,e,n,r,s),!0;case"mouseover":return Xn=Zs(Xn,t,e,n,r,s),!0;case"pointerover":var i=s.pointerId;return Li.set(i,Zs(Li.get(i)||null,t,e,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,ji.set(i,Zs(ji.get(i)||null,t,e,n,r,s)),!0}return!1}function Qv(t){var e=kr(t.target);if(e!==null){var n=Gr(e);if(n!==null){if(e=n.tag,e===13){if(e=Lv(n),e!==null){t.blockedOn=e,Wv(t.priority,function(){qv(n)});return}}else if(e===3&&n.stateNode.current.memoizedState.isDehydrated){t.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}t.blockedOn=null}function ua(t){if(t.blockedOn!==null)return!1;for(var e=t.targetContainers;0<e.length;){var n=Rc(t.domEventName,t.eventSystemFlags,e[0],t.nativeEvent);if(n===null){n=t.nativeEvent;var r=new n.constructor(n.type,n);bc=r,n.target.dispatchEvent(r),bc=null}else return e=wo(n),e!==null&&th(e),t.blockedOn=n,!1;e.shift()}return!0}function Ip(t,e,n){ua(t)&&n.delete(e)}function xT(){Ec=!1,Yn!==null&&ua(Yn)&&(Yn=null),Jn!==null&&ua(Jn)&&(Jn=null),Xn!==null&&ua(Xn)&&(Xn=null),Li.forEach(Ip),ji.forEach(Ip)}function ei(t,e){t.blockedOn===e&&(t.blockedOn=null,Ec||(Ec=!0,Tt.unstable_scheduleCallback(Tt.unstable_NormalPriority,xT)))}function $i(t){function e(s){return ei(s,t)}if(0<No.length){ei(No[0],t);for(var n=1;n<No.length;n++){var r=No[n];r.blockedOn===t&&(r.blockedOn=null)}}for(Yn!==null&&ei(Yn,t),Jn!==null&&ei(Jn,t),Xn!==null&&ei(Xn,t),Li.forEach(e),ji.forEach(e),n=0;n<Gn.length;n++)r=Gn[n],r.blockedOn===t&&(r.blockedOn=null);for(;0<Gn.length&&(n=Gn[0],n.blockedOn===null);)Qv(n),n.blockedOn===null&&Gn.shift()}var xs=jn.ReactCurrentBatchConfig,Pa=!0;function ST(t,e,n,r){var s=fe,i=xs.transition;xs.transition=null;try{fe=1,nh(t,e,n,r)}finally{fe=s,xs.transition=i}}function bT(t,e,n,r){var s=fe,i=xs.transition;xs.transition=null;try{fe=4,nh(t,e,n,r)}finally{fe=s,xs.transition=i}}function nh(t,e,n,r){if(Pa){var s=Rc(t,e,n,r);if(s===null)hu(t,e,r,Ma,n),Cp(t,r);else if(wT(s,t,e,n,r))r.stopPropagation();else if(Cp(t,r),e&4&&-1<_T.indexOf(t)){for(;s!==null;){var i=wo(s);if(i!==null&&Hv(i),i=Rc(t,e,n,r),i===null&&hu(t,e,r,Ma,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else hu(t,e,r,null,n)}}var Ma=null;function Rc(t,e,n,r){if(Ma=null,t=Xd(r),t=kr(t),t!==null)if(e=Gr(t),e===null)t=null;else if(n=e.tag,n===13){if(t=Lv(e),t!==null)return t;t=null}else if(n===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;t=null}else e!==t&&(t=null);return Ma=t,null}function Kv(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(cT()){case Zd:return 1;case Fv:return 4;case Ra:case dT:return 16;case Bv:return 536870912;default:return 16}default:return 16}}var Qn=null,rh=null,ca=null;function Yv(){if(ca)return ca;var t,e=rh,n=e.length,r,s="value"in Qn?Qn.value:Qn.textContent,i=s.length;for(t=0;t<n&&e[t]===s[t];t++);var o=n-t;for(r=1;r<=o&&e[n-r]===s[i-r];r++);return ca=s.slice(t,1<r?1-r:void 0)}function da(t){var e=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&e===13&&(t=13)):t=e,t===10&&(t=13),32<=t||t===13?t:0}function Lo(){return!0}function Ep(){return!1}function Et(t){function e(n,r,s,i,o){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var a in t)t.hasOwnProperty(a)&&(n=t[a],this[a]=n?n(i):i[a]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Lo:Ep,this.isPropagationStopped=Ep,this}return Ie(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Lo)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Lo)},persist:function(){},isPersistent:Lo}),e}var js={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},sh=Et(js),_o=Ie({},js,{view:0,detail:0}),TT=Et(_o),ru,su,ti,yl=Ie({},_o,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ih,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==ti&&(ti&&t.type==="mousemove"?(ru=t.screenX-ti.screenX,su=t.screenY-ti.screenY):su=ru=0,ti=t),ru)},movementY:function(t){return"movementY"in t?t.movementY:su}}),Rp=Et(yl),kT=Ie({},yl,{dataTransfer:0}),CT=Et(kT),IT=Ie({},_o,{relatedTarget:0}),iu=Et(IT),ET=Ie({},js,{animationName:0,elapsedTime:0,pseudoElement:0}),RT=Et(ET),AT=Ie({},js,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),PT=Et(AT),MT=Ie({},js,{data:0}),Ap=Et(MT),DT={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},OT={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},NT={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function LT(t){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(t):(t=NT[t])?!!e[t]:!1}function ih(){return LT}var jT=Ie({},_o,{key:function(t){if(t.key){var e=DT[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=da(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?OT[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ih,charCode:function(t){return t.type==="keypress"?da(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?da(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),$T=Et(jT),zT=Ie({},yl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Pp=Et(zT),FT=Ie({},_o,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ih}),BT=Et(FT),UT=Ie({},js,{propertyName:0,elapsedTime:0,pseudoElement:0}),VT=Et(UT),HT=Ie({},yl,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),qT=Et(HT),GT=[9,13,27,32],oh=Mn&&"CompositionEvent"in window,vi=null;Mn&&"documentMode"in document&&(vi=document.documentMode);var WT=Mn&&"TextEvent"in window&&!vi,Jv=Mn&&(!oh||vi&&8<vi&&11>=vi),Mp=" ",Dp=!1;function Xv(t,e){switch(t){case"keyup":return GT.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Zv(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ls=!1;function QT(t,e){switch(t){case"compositionend":return Zv(e);case"keypress":return e.which!==32?null:(Dp=!0,Mp);case"textInput":return t=e.data,t===Mp&&Dp?null:t;default:return null}}function KT(t,e){if(ls)return t==="compositionend"||!oh&&Xv(t,e)?(t=Yv(),ca=rh=Qn=null,ls=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1<e.char.length)return e.char;if(e.which)return String.fromCharCode(e.which)}return null;case"compositionend":return Jv&&e.locale!=="ko"?null:e.data;default:return null}}var YT={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Op(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e==="input"?!!YT[t.type]:e==="textarea"}function e_(t,e,n,r){Pv(r),e=Da(e,"onChange"),0<e.length&&(n=new sh("onChange","change",null,n,r),t.push({event:n,listeners:e}))}var _i=null,zi=null;function JT(t){d_(t,0)}function vl(t){var e=ds(t);if(Tv(e))return t}function XT(t,e){if(t==="change")return e}var t_=!1;if(Mn){var ou;if(Mn){var au="oninput"in document;if(!au){var Np=document.createElement("div");Np.setAttribute("oninput","return;"),au=typeof Np.oninput=="function"}ou=au}else ou=!1;t_=ou&&(!document.documentMode||9<document.documentMode)}function Lp(){_i&&(_i.detachEvent("onpropertychange",n_),zi=_i=null)}function n_(t){if(t.propertyName==="value"&&vl(zi)){var e=[];e_(e,zi,t,Xd(t)),Nv(JT,e)}}function ZT(t,e,n){t==="focusin"?(Lp(),_i=e,zi=n,_i.attachEvent("onpropertychange",n_)):t==="focusout"&&Lp()}function ek(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return vl(zi)}function tk(t,e){if(t==="click")return vl(e)}function nk(t,e){if(t==="input"||t==="change")return vl(e)}function rk(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var on=typeof Object.is=="function"?Object.is:rk;function Fi(t,e){if(on(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var s=n[r];if(!dc.call(e,s)||!on(t[s],e[s]))return!1}return!0}function jp(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function $p(t,e){var n=jp(t);t=0;for(var r;n;){if(n.nodeType===3){if(r=t+n.textContent.length,t<=e&&r>=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=jp(n)}}function r_(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?r_(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function s_(){for(var t=window,e=Ca();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=Ca(t.document)}return e}function ah(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function sk(t){var e=s_(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&r_(n.ownerDocument.documentElement,n)){if(r!==null&&ah(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!t.extend&&i>r&&(s=r,r=i,i=s),s=$p(n,i);var o=$p(n,r);s&&o&&(t.rangeCount!==1||t.anchorNode!==s.node||t.anchorOffset!==s.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(s.node,s.offset),t.removeAllRanges(),i>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<e.length;n++)t=e[n],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var ik=Mn&&"documentMode"in document&&11>=document.documentMode,us=null,Ac=null,wi=null,Pc=!1;function zp(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Pc||us==null||us!==Ca(r)||(r=us,"selectionStart"in r&&ah(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),wi&&Fi(wi,r)||(wi=r,r=Da(Ac,"onSelect"),0<r.length&&(e=new sh("onSelect","select",null,e,n),t.push({event:e,listeners:r}),e.target=us)))}function jo(t,e){var n={};return n[t.toLowerCase()]=e.toLowerCase(),n["Webkit"+t]="webkit"+e,n["Moz"+t]="moz"+e,n}var cs={animationend:jo("Animation","AnimationEnd"),animationiteration:jo("Animation","AnimationIteration"),animationstart:jo("Animation","AnimationStart"),transitionend:jo("Transition","TransitionEnd")},lu={},i_={};Mn&&(i_=document.createElement("div").style,"AnimationEvent"in window||(delete cs.animationend.animation,delete cs.animationiteration.animation,delete cs.animationstart.animation),"TransitionEvent"in window||delete cs.transitionend.transition);function _l(t){if(lu[t])return lu[t];if(!cs[t])return t;var e=cs[t],n;for(n in e)if(e.hasOwnProperty(n)&&n in i_)return lu[t]=e[n];return t}var o_=_l("animationend"),a_=_l("animationiteration"),l_=_l("animationstart"),u_=_l("transitionend"),c_=new Map,Fp="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function ur(t,e){c_.set(t,e),qr(e,[t])}for(var uu=0;uu<Fp.length;uu++){var cu=Fp[uu],ok=cu.toLowerCase(),ak=cu[0].toUpperCase()+cu.slice(1);ur(ok,"on"+ak)}ur(o_,"onAnimationEnd");ur(a_,"onAnimationIteration");ur(l_,"onAnimationStart");ur("dblclick","onDoubleClick");ur("focusin","onFocus");ur("focusout","onBlur");ur(u_,"onTransitionEnd");Is("onMouseEnter",["mouseout","mouseover"]);Is("onMouseLeave",["mouseout","mouseover"]);Is("onPointerEnter",["pointerout","pointerover"]);Is("onPointerLeave",["pointerout","pointerover"]);qr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));qr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));qr("onBeforeInput",["compositionend","keypress","textInput","paste"]);qr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));qr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));qr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var fi="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),lk=new Set("cancel close invalid load scroll toggle".split(" ").concat(fi));function Bp(t,e,n){var r=t.type||"unknown-event";t.currentTarget=n,oT(r,e,void 0,t),t.currentTarget=null}function d_(t,e){e=(e&4)!==0;for(var n=0;n<t.length;n++){var r=t[n],s=r.event;r=r.listeners;e:{var i=void 0;if(e)for(var o=r.length-1;0<=o;o--){var a=r[o],l=a.instance,u=a.currentTarget;if(a=a.listener,l!==i&&s.isPropagationStopped())break e;Bp(s,a,u),i=l}else for(o=0;o<r.length;o++){if(a=r[o],l=a.instance,u=a.currentTarget,a=a.listener,l!==i&&s.isPropagationStopped())break e;Bp(s,a,u),i=l}}}if(Ea)throw t=Cc,Ea=!1,Cc=null,t}function we(t,e){var n=e[Lc];n===void 0&&(n=e[Lc]=new Set);var r=t+"__bubble";n.has(r)||(h_(e,t,2,!1),n.add(r))}function du(t,e,n){var r=0;e&&(r|=4),h_(n,t,r,e)}var $o="_reactListening"+Math.random().toString(36).slice(2);function Bi(t){if(!t[$o]){t[$o]=!0,_v.forEach(function(n){n!=="selectionchange"&&(lk.has(n)||du(n,!1,t),du(n,!0,t))});var e=t.nodeType===9?t:t.ownerDocument;e===null||e[$o]||(e[$o]=!0,du("selectionchange",!1,e))}}function h_(t,e,n,r){switch(Kv(e)){case 1:var s=ST;break;case 4:s=bT;break;default:s=nh}n=s.bind(null,e,n,t),s=void 0,!kc||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(s=!0),r?s!==void 0?t.addEventListener(e,n,{capture:!0,passive:s}):t.addEventListener(e,n,!0):s!==void 0?t.addEventListener(e,n,{passive:s}):t.addEventListener(e,n,!1)}function hu(t,e,n,r,s){var i=r;if(!(e&1)&&!(e&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var a=r.stateNode.containerInfo;if(a===s||a.nodeType===8&&a.parentNode===s)break;if(o===4)for(o=r.return;o!==null;){var l=o.tag;if((l===3||l===4)&&(l=o.stateNode.containerInfo,l===s||l.nodeType===8&&l.parentNode===s))return;o=o.return}for(;a!==null;){if(o=kr(a),o===null)return;if(l=o.tag,l===5||l===6){r=i=o;continue e}a=a.parentNode}}r=r.return}Nv(function(){var u=i,c=Xd(n),d=[];e:{var h=c_.get(t);if(h!==void 0){var f=sh,p=t;switch(t){case"keypress":if(da(n)===0)break e;case"keydown":case"keyup":f=$T;break;case"focusin":p="focus",f=iu;break;case"focusout":p="blur",f=iu;break;case"beforeblur":case"afterblur":f=iu;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":f=Rp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":f=CT;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":f=BT;break;case o_:case a_:case l_:f=RT;break;case u_:f=VT;break;case"scroll":f=TT;break;case"wheel":f=qT;break;case"copy":case"cut":case"paste":f=PT;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":f=Pp}var g=(e&4)!==0,_=!g&&t==="scroll",m=g?h!==null?h+"Capture":null:h;g=[];for(var y=u,v;y!==null;){v=y;var S=v.stateNode;if(v.tag===5&&S!==null&&(v=S,m!==null&&(S=Ni(y,m),S!=null&&g.push(Ui(y,S,v)))),_)break;y=y.return}0<g.length&&(h=new f(h,p,null,n,c),d.push({event:h,listeners:g}))}}if(!(e&7)){e:{if(h=t==="mouseover"||t==="pointerover",f=t==="mouseout"||t==="pointerout",h&&n!==bc&&(p=n.relatedTarget||n.fromElement)&&(kr(p)||p[Dn]))break e;if((f||h)&&(h=c.window===c?c:(h=c.ownerDocument)?h.defaultView||h.parentWindow:window,f?(p=n.relatedTarget||n.toElement,f=u,p=p?kr(p):null,p!==null&&(_=Gr(p),p!==_||p.tag!==5&&p.tag!==6)&&(p=null)):(f=null,p=u),f!==p)){if(g=Rp,S="onMouseLeave",m="onMouseEnter",y="mouse",(t==="pointerout"||t==="pointerover")&&(g=Pp,S="onPointerLeave",m="onPointerEnter",y="pointer"),_=f==null?h:ds(f),v=p==null?h:ds(p),h=new g(S,y+"leave",f,n,c),h.target=_,h.relatedTarget=v,S=null,kr(c)===u&&(g=new g(m,y+"enter",p,n,c),g.target=v,g.relatedTarget=_,S=g),_=S,f&&p)t:{for(g=f,m=p,y=0,v=g;v;v=ts(v))y++;for(v=0,S=m;S;S=ts(S))v++;for(;0<y-v;)g=ts(g),y--;for(;0<v-y;)m=ts(m),v--;for(;y--;){if(g===m||m!==null&&g===m.alternate)break t;g=ts(g),m=ts(m)}g=null}else g=null;f!==null&&Up(d,h,f,g,!1),p!==null&&_!==null&&Up(d,_,p,g,!0)}}e:{if(h=u?ds(u):window,f=h.nodeName&&h.nodeName.toLowerCase(),f==="select"||f==="input"&&h.type==="file")var I=XT;else if(Op(h))if(t_)I=nk;else{I=ek;var b=ZT}else(f=h.nodeName)&&f.toLowerCase()==="input"&&(h.type==="checkbox"||h.type==="radio")&&(I=tk);if(I&&(I=I(t,u))){e_(d,I,n,c);break e}b&&b(t,h,u),t==="focusout"&&(b=h._wrapperState)&&b.controlled&&h.type==="number"&&vc(h,"number",h.value)}switch(b=u?ds(u):window,t){case"focusin":(Op(b)||b.contentEditable==="true")&&(us=b,Ac=u,wi=null);break;case"focusout":wi=Ac=us=null;break;case"mousedown":Pc=!0;break;case"contextmenu":case"mouseup":case"dragend":Pc=!1,zp(d,n,c);break;case"selectionchange":if(ik)break;case"keydown":case"keyup":zp(d,n,c)}var P;if(oh)e:{switch(t){case"compositionstart":var A="onCompositionStart";break e;case"compositionend":A="onCompositionEnd";break e;case"compositionupdate":A="onCompositionUpdate";break e}A=void 0}else ls?Xv(t,n)&&(A="onCompositionEnd"):t==="keydown"&&n.keyCode===229&&(A="onCompositionStart");A&&(Jv&&n.locale!=="ko"&&(ls||A!=="onCompositionStart"?A==="onCompositionEnd"&&ls&&(P=Yv()):(Qn=c,rh="value"in Qn?Qn.value:Qn.textContent,ls=!0)),b=Da(u,A),0<b.length&&(A=new Ap(A,t,null,n,c),d.push({event:A,listeners:b}),P?A.data=P:(P=Zv(n),P!==null&&(A.data=P)))),(P=WT?QT(t,n):KT(t,n))&&(u=Da(u,"onBeforeInput"),0<u.length&&(c=new Ap("onBeforeInput","beforeinput",null,n,c),d.push({event:c,listeners:u}),c.data=P))}d_(d,e)})}function Ui(t,e,n){return{instance:t,listener:e,currentTarget:n}}function Da(t,e){for(var n=e+"Capture",r=[];t!==null;){var s=t,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=Ni(t,n),i!=null&&r.unshift(Ui(t,i,s)),i=Ni(t,e),i!=null&&r.push(Ui(t,i,s))),t=t.return}return r}function ts(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function Up(t,e,n,r,s){for(var i=e._reactName,o=[];n!==null&&n!==r;){var a=n,l=a.alternate,u=a.stateNode;if(l!==null&&l===r)break;a.tag===5&&u!==null&&(a=u,s?(l=Ni(n,i),l!=null&&o.unshift(Ui(n,l,a))):s||(l=Ni(n,i),l!=null&&o.push(Ui(n,l,a)))),n=n.return}o.length!==0&&t.push({event:e,listeners:o})}var uk=/\r\n?/g,ck=/\u0000|\uFFFD/g;function Vp(t){return(typeof t=="string"?t:""+t).replace(uk,`
38
+ `).replace(ck,"")}function zo(t,e,n){if(e=Vp(e),Vp(t)!==e&&n)throw Error(F(425))}function Oa(){}var Mc=null,Dc=null;function Oc(t,e){return t==="textarea"||t==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var Nc=typeof setTimeout=="function"?setTimeout:void 0,dk=typeof clearTimeout=="function"?clearTimeout:void 0,Hp=typeof Promise=="function"?Promise:void 0,hk=typeof queueMicrotask=="function"?queueMicrotask:typeof Hp<"u"?function(t){return Hp.resolve(null).then(t).catch(fk)}:Nc;function fk(t){setTimeout(function(){throw t})}function fu(t,e){var n=e,r=0;do{var s=n.nextSibling;if(t.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(r===0){t.removeChild(s),$i(e);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);$i(e)}function Zn(t){for(;t!=null;t=t.nextSibling){var e=t.nodeType;if(e===1||e===3)break;if(e===8){if(e=t.data,e==="$"||e==="$!"||e==="$?")break;if(e==="/$")return null}}return t}function qp(t){t=t.previousSibling;for(var e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="$"||n==="$!"||n==="$?"){if(e===0)return t;e--}else n==="/$"&&e++}t=t.previousSibling}return null}var $s=Math.random().toString(36).slice(2),yn="__reactFiber$"+$s,Vi="__reactProps$"+$s,Dn="__reactContainer$"+$s,Lc="__reactEvents$"+$s,pk="__reactListeners$"+$s,mk="__reactHandles$"+$s;function kr(t){var e=t[yn];if(e)return e;for(var n=t.parentNode;n;){if(e=n[Dn]||n[yn]){if(n=e.alternate,e.child!==null||n!==null&&n.child!==null)for(t=qp(t);t!==null;){if(n=t[yn])return n;t=qp(t)}return e}t=n,n=t.parentNode}return null}function wo(t){return t=t[yn]||t[Dn],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function ds(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(F(33))}function wl(t){return t[Vi]||null}var jc=[],hs=-1;function cr(t){return{current:t}}function xe(t){0>hs||(t.current=jc[hs],jc[hs]=null,hs--)}function ve(t,e){hs++,jc[hs]=t.current,t.current=e}var or={},Ye=cr(or),ut=cr(!1),Or=or;function Es(t,e){var n=t.type.contextTypes;if(!n)return or;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=e[i];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=s),s}function ct(t){return t=t.childContextTypes,t!=null}function Na(){xe(ut),xe(Ye)}function Gp(t,e,n){if(Ye.current!==or)throw Error(F(168));ve(Ye,e),ve(ut,n)}function f_(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in e))throw Error(F(108,Zb(t)||"Unknown",s));return Ie({},n,r)}function La(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||or,Or=Ye.current,ve(Ye,t),ve(ut,ut.current),!0}function Wp(t,e,n){var r=t.stateNode;if(!r)throw Error(F(169));n?(t=f_(t,e,Or),r.__reactInternalMemoizedMergedChildContext=t,xe(ut),xe(Ye),ve(Ye,t)):xe(ut),ve(ut,n)}var Cn=null,xl=!1,pu=!1;function p_(t){Cn===null?Cn=[t]:Cn.push(t)}function gk(t){xl=!0,p_(t)}function dr(){if(!pu&&Cn!==null){pu=!0;var t=0,e=fe;try{var n=Cn;for(fe=1;t<n.length;t++){var r=n[t];do r=r(!0);while(r!==null)}Cn=null,xl=!1}catch(s){throw Cn!==null&&(Cn=Cn.slice(t+1)),zv(Zd,dr),s}finally{fe=e,pu=!1}}return null}var fs=[],ps=0,ja=null,$a=0,Mt=[],Dt=0,Nr=null,En=1,Rn="";function _r(t,e){fs[ps++]=$a,fs[ps++]=ja,ja=t,$a=e}function m_(t,e,n){Mt[Dt++]=En,Mt[Dt++]=Rn,Mt[Dt++]=Nr,Nr=t;var r=En;t=Rn;var s=32-en(r)-1;r&=~(1<<s),n+=1;var i=32-en(e)+s;if(30<i){var o=s-s%5;i=(r&(1<<o)-1).toString(32),r>>=o,s-=o,En=1<<32-en(e)+s|n<<s|r,Rn=i+t}else En=1<<i|n<<s|r,Rn=t}function lh(t){t.return!==null&&(_r(t,1),m_(t,1,0))}function uh(t){for(;t===ja;)ja=fs[--ps],fs[ps]=null,$a=fs[--ps],fs[ps]=null;for(;t===Nr;)Nr=Mt[--Dt],Mt[Dt]=null,Rn=Mt[--Dt],Mt[Dt]=null,En=Mt[--Dt],Mt[Dt]=null}var St=null,vt=null,be=!1,Qt=null;function g_(t,e){var n=Lt(5,null,null,0);n.elementType="DELETED",n.stateNode=e,n.return=t,e=t.deletions,e===null?(t.deletions=[n],t.flags|=16):e.push(n)}function Qp(t,e){switch(t.tag){case 5:var n=t.type;return e=e.nodeType!==1||n.toLowerCase()!==e.nodeName.toLowerCase()?null:e,e!==null?(t.stateNode=e,St=t,vt=Zn(e.firstChild),!0):!1;case 6:return e=t.pendingProps===""||e.nodeType!==3?null:e,e!==null?(t.stateNode=e,St=t,vt=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(n=Nr!==null?{id:En,overflow:Rn}:null,t.memoizedState={dehydrated:e,treeContext:n,retryLane:1073741824},n=Lt(18,null,null,0),n.stateNode=e,n.return=t,t.child=n,St=t,vt=null,!0):!1;default:return!1}}function $c(t){return(t.mode&1)!==0&&(t.flags&128)===0}function zc(t){if(be){var e=vt;if(e){var n=e;if(!Qp(t,e)){if($c(t))throw Error(F(418));e=Zn(n.nextSibling);var r=St;e&&Qp(t,e)?g_(r,n):(t.flags=t.flags&-4097|2,be=!1,St=t)}}else{if($c(t))throw Error(F(418));t.flags=t.flags&-4097|2,be=!1,St=t}}}function Kp(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;St=t}function Fo(t){if(t!==St)return!1;if(!be)return Kp(t),be=!0,!1;var e;if((e=t.tag!==3)&&!(e=t.tag!==5)&&(e=t.type,e=e!=="head"&&e!=="body"&&!Oc(t.type,t.memoizedProps)),e&&(e=vt)){if($c(t))throw y_(),Error(F(418));for(;e;)g_(t,e),e=Zn(e.nextSibling)}if(Kp(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(F(317));e:{for(t=t.nextSibling,e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="/$"){if(e===0){vt=Zn(t.nextSibling);break e}e--}else n!=="$"&&n!=="$!"&&n!=="$?"||e++}t=t.nextSibling}vt=null}}else vt=St?Zn(t.stateNode.nextSibling):null;return!0}function y_(){for(var t=vt;t;)t=Zn(t.nextSibling)}function Rs(){vt=St=null,be=!1}function ch(t){Qt===null?Qt=[t]:Qt.push(t)}var yk=jn.ReactCurrentBatchConfig;function ni(t,e,n){if(t=n.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(F(309));var r=n.stateNode}if(!r)throw Error(F(147,t));var s=r,i=""+t;return e!==null&&e.ref!==null&&typeof e.ref=="function"&&e.ref._stringRef===i?e.ref:(e=function(o){var a=s.refs;o===null?delete a[i]:a[i]=o},e._stringRef=i,e)}if(typeof t!="string")throw Error(F(284));if(!n._owner)throw Error(F(290,t))}return t}function Bo(t,e){throw t=Object.prototype.toString.call(e),Error(F(31,t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t))}function Yp(t){var e=t._init;return e(t._payload)}function v_(t){function e(m,y){if(t){var v=m.deletions;v===null?(m.deletions=[y],m.flags|=16):v.push(y)}}function n(m,y){if(!t)return null;for(;y!==null;)e(m,y),y=y.sibling;return null}function r(m,y){for(m=new Map;y!==null;)y.key!==null?m.set(y.key,y):m.set(y.index,y),y=y.sibling;return m}function s(m,y){return m=rr(m,y),m.index=0,m.sibling=null,m}function i(m,y,v){return m.index=v,t?(v=m.alternate,v!==null?(v=v.index,v<y?(m.flags|=2,y):v):(m.flags|=2,y)):(m.flags|=1048576,y)}function o(m){return t&&m.alternate===null&&(m.flags|=2),m}function a(m,y,v,S){return y===null||y.tag!==6?(y=xu(v,m.mode,S),y.return=m,y):(y=s(y,v),y.return=m,y)}function l(m,y,v,S){var I=v.type;return I===as?c(m,y,v.props.children,S,v.key):y!==null&&(y.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===Vn&&Yp(I)===y.type)?(S=s(y,v.props),S.ref=ni(m,y,v),S.return=m,S):(S=va(v.type,v.key,v.props,null,m.mode,S),S.ref=ni(m,y,v),S.return=m,S)}function u(m,y,v,S){return y===null||y.tag!==4||y.stateNode.containerInfo!==v.containerInfo||y.stateNode.implementation!==v.implementation?(y=Su(v,m.mode,S),y.return=m,y):(y=s(y,v.children||[]),y.return=m,y)}function c(m,y,v,S,I){return y===null||y.tag!==7?(y=Pr(v,m.mode,S,I),y.return=m,y):(y=s(y,v),y.return=m,y)}function d(m,y,v){if(typeof y=="string"&&y!==""||typeof y=="number")return y=xu(""+y,m.mode,v),y.return=m,y;if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Ao:return v=va(y.type,y.key,y.props,null,m.mode,v),v.ref=ni(m,null,y),v.return=m,v;case os:return y=Su(y,m.mode,v),y.return=m,y;case Vn:var S=y._init;return d(m,S(y._payload),v)}if(di(y)||Js(y))return y=Pr(y,m.mode,v,null),y.return=m,y;Bo(m,y)}return null}function h(m,y,v,S){var I=y!==null?y.key:null;if(typeof v=="string"&&v!==""||typeof v=="number")return I!==null?null:a(m,y,""+v,S);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case Ao:return v.key===I?l(m,y,v,S):null;case os:return v.key===I?u(m,y,v,S):null;case Vn:return I=v._init,h(m,y,I(v._payload),S)}if(di(v)||Js(v))return I!==null?null:c(m,y,v,S,null);Bo(m,v)}return null}function f(m,y,v,S,I){if(typeof S=="string"&&S!==""||typeof S=="number")return m=m.get(v)||null,a(y,m,""+S,I);if(typeof S=="object"&&S!==null){switch(S.$$typeof){case Ao:return m=m.get(S.key===null?v:S.key)||null,l(y,m,S,I);case os:return m=m.get(S.key===null?v:S.key)||null,u(y,m,S,I);case Vn:var b=S._init;return f(m,y,v,b(S._payload),I)}if(di(S)||Js(S))return m=m.get(v)||null,c(y,m,S,I,null);Bo(y,S)}return null}function p(m,y,v,S){for(var I=null,b=null,P=y,A=y=0,D=null;P!==null&&A<v.length;A++){P.index>A?(D=P,P=null):D=P.sibling;var x=h(m,P,v[A],S);if(x===null){P===null&&(P=D);break}t&&P&&x.alternate===null&&e(m,P),y=i(x,y,A),b===null?I=x:b.sibling=x,b=x,P=D}if(A===v.length)return n(m,P),be&&_r(m,A),I;if(P===null){for(;A<v.length;A++)P=d(m,v[A],S),P!==null&&(y=i(P,y,A),b===null?I=P:b.sibling=P,b=P);return be&&_r(m,A),I}for(P=r(m,P);A<v.length;A++)D=f(P,m,A,v[A],S),D!==null&&(t&&D.alternate!==null&&P.delete(D.key===null?A:D.key),y=i(D,y,A),b===null?I=D:b.sibling=D,b=D);return t&&P.forEach(function(k){return e(m,k)}),be&&_r(m,A),I}function g(m,y,v,S){var I=Js(v);if(typeof I!="function")throw Error(F(150));if(v=I.call(v),v==null)throw Error(F(151));for(var b=I=null,P=y,A=y=0,D=null,x=v.next();P!==null&&!x.done;A++,x=v.next()){P.index>A?(D=P,P=null):D=P.sibling;var k=h(m,P,x.value,S);if(k===null){P===null&&(P=D);break}t&&P&&k.alternate===null&&e(m,P),y=i(k,y,A),b===null?I=k:b.sibling=k,b=k,P=D}if(x.done)return n(m,P),be&&_r(m,A),I;if(P===null){for(;!x.done;A++,x=v.next())x=d(m,x.value,S),x!==null&&(y=i(x,y,A),b===null?I=x:b.sibling=x,b=x);return be&&_r(m,A),I}for(P=r(m,P);!x.done;A++,x=v.next())x=f(P,m,A,x.value,S),x!==null&&(t&&x.alternate!==null&&P.delete(x.key===null?A:x.key),y=i(x,y,A),b===null?I=x:b.sibling=x,b=x);return t&&P.forEach(function(R){return e(m,R)}),be&&_r(m,A),I}function _(m,y,v,S){if(typeof v=="object"&&v!==null&&v.type===as&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case Ao:e:{for(var I=v.key,b=y;b!==null;){if(b.key===I){if(I=v.type,I===as){if(b.tag===7){n(m,b.sibling),y=s(b,v.props.children),y.return=m,m=y;break e}}else if(b.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===Vn&&Yp(I)===b.type){n(m,b.sibling),y=s(b,v.props),y.ref=ni(m,b,v),y.return=m,m=y;break e}n(m,b);break}else e(m,b);b=b.sibling}v.type===as?(y=Pr(v.props.children,m.mode,S,v.key),y.return=m,m=y):(S=va(v.type,v.key,v.props,null,m.mode,S),S.ref=ni(m,y,v),S.return=m,m=S)}return o(m);case os:e:{for(b=v.key;y!==null;){if(y.key===b)if(y.tag===4&&y.stateNode.containerInfo===v.containerInfo&&y.stateNode.implementation===v.implementation){n(m,y.sibling),y=s(y,v.children||[]),y.return=m,m=y;break e}else{n(m,y);break}else e(m,y);y=y.sibling}y=Su(v,m.mode,S),y.return=m,m=y}return o(m);case Vn:return b=v._init,_(m,y,b(v._payload),S)}if(di(v))return p(m,y,v,S);if(Js(v))return g(m,y,v,S);Bo(m,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,y!==null&&y.tag===6?(n(m,y.sibling),y=s(y,v),y.return=m,m=y):(n(m,y),y=xu(v,m.mode,S),y.return=m,m=y),o(m)):n(m,y)}return _}var As=v_(!0),__=v_(!1),za=cr(null),Fa=null,ms=null,dh=null;function hh(){dh=ms=Fa=null}function fh(t){var e=za.current;xe(za),t._currentValue=e}function Fc(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function Ss(t,e){Fa=t,dh=ms=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(lt=!0),t.firstContext=null)}function zt(t){var e=t._currentValue;if(dh!==t)if(t={context:t,memoizedValue:e,next:null},ms===null){if(Fa===null)throw Error(F(308));ms=t,Fa.dependencies={lanes:0,firstContext:t}}else ms=ms.next=t;return e}var Cr=null;function ph(t){Cr===null?Cr=[t]:Cr.push(t)}function w_(t,e,n,r){var s=e.interleaved;return s===null?(n.next=n,ph(e)):(n.next=s.next,s.next=n),e.interleaved=n,On(t,r)}function On(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var Hn=!1;function mh(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function x_(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Pn(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function er(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,ue&2){var s=r.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),r.pending=e,On(t,n)}return s=r.interleaved,s===null?(e.next=e,ph(r)):(e.next=s.next,s.next=e),r.interleaved=e,On(t,n)}function ha(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,eh(t,n)}}function Jp(t,e){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=o:i=i.next=o,n=n.next}while(n!==null);i===null?s=i=e:i=i.next=e}else s=i=e;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function Ba(t,e,n,r){var s=t.updateQueue;Hn=!1;var i=s.firstBaseUpdate,o=s.lastBaseUpdate,a=s.shared.pending;if(a!==null){s.shared.pending=null;var l=a,u=l.next;l.next=null,o===null?i=u:o.next=u,o=l;var c=t.alternate;c!==null&&(c=c.updateQueue,a=c.lastBaseUpdate,a!==o&&(a===null?c.firstBaseUpdate=u:a.next=u,c.lastBaseUpdate=l))}if(i!==null){var d=s.baseState;o=0,c=u=l=null,a=i;do{var h=a.lane,f=a.eventTime;if((r&h)===h){c!==null&&(c=c.next={eventTime:f,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var p=t,g=a;switch(h=e,f=n,g.tag){case 1:if(p=g.payload,typeof p=="function"){d=p.call(f,d,h);break e}d=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=g.payload,h=typeof p=="function"?p.call(f,d,h):p,h==null)break e;d=Ie({},d,h);break e;case 2:Hn=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,h=s.effects,h===null?s.effects=[a]:h.push(a))}else f={eventTime:f,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},c===null?(u=c=f,l=d):c=c.next=f,o|=h;if(a=a.next,a===null){if(a=s.shared.pending,a===null)break;h=a,a=h.next,h.next=null,s.lastBaseUpdate=h,s.shared.pending=null}}while(!0);if(c===null&&(l=d),s.baseState=l,s.firstBaseUpdate=u,s.lastBaseUpdate=c,e=s.shared.interleaved,e!==null){s=e;do o|=s.lane,s=s.next;while(s!==e)}else i===null&&(s.shared.lanes=0);jr|=o,t.lanes=o,t.memoizedState=d}}function Xp(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;e<t.length;e++){var r=t[e],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error(F(191,s));s.call(r)}}}var xo={},_n=cr(xo),Hi=cr(xo),qi=cr(xo);function Ir(t){if(t===xo)throw Error(F(174));return t}function gh(t,e){switch(ve(qi,e),ve(Hi,t),ve(_n,xo),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:wc(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=wc(e,t)}xe(_n),ve(_n,e)}function Ps(){xe(_n),xe(Hi),xe(qi)}function S_(t){Ir(qi.current);var e=Ir(_n.current),n=wc(e,t.type);e!==n&&(ve(Hi,t),ve(_n,n))}function yh(t){Hi.current===t&&(xe(_n),xe(Hi))}var ke=cr(0);function Ua(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var mu=[];function vh(){for(var t=0;t<mu.length;t++)mu[t]._workInProgressVersionPrimary=null;mu.length=0}var fa=jn.ReactCurrentDispatcher,gu=jn.ReactCurrentBatchConfig,Lr=0,Ce=null,je=null,Fe=null,Va=!1,xi=!1,Gi=0,vk=0;function Ge(){throw Error(F(321))}function _h(t,e){if(e===null)return!1;for(var n=0;n<e.length&&n<t.length;n++)if(!on(t[n],e[n]))return!1;return!0}function wh(t,e,n,r,s,i){if(Lr=i,Ce=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,fa.current=t===null||t.memoizedState===null?Sk:bk,t=n(r,s),xi){i=0;do{if(xi=!1,Gi=0,25<=i)throw Error(F(301));i+=1,Fe=je=null,e.updateQueue=null,fa.current=Tk,t=n(r,s)}while(xi)}if(fa.current=Ha,e=je!==null&&je.next!==null,Lr=0,Fe=je=Ce=null,Va=!1,e)throw Error(F(300));return t}function xh(){var t=Gi!==0;return Gi=0,t}function pn(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Fe===null?Ce.memoizedState=Fe=t:Fe=Fe.next=t,Fe}function Ft(){if(je===null){var t=Ce.alternate;t=t!==null?t.memoizedState:null}else t=je.next;var e=Fe===null?Ce.memoizedState:Fe.next;if(e!==null)Fe=e,je=t;else{if(t===null)throw Error(F(310));je=t,t={memoizedState:je.memoizedState,baseState:je.baseState,baseQueue:je.baseQueue,queue:je.queue,next:null},Fe===null?Ce.memoizedState=Fe=t:Fe=Fe.next=t}return Fe}function Wi(t,e){return typeof e=="function"?e(t):e}function yu(t){var e=Ft(),n=e.queue;if(n===null)throw Error(F(311));n.lastRenderedReducer=t;var r=je,s=r.baseQueue,i=n.pending;if(i!==null){if(s!==null){var o=s.next;s.next=i.next,i.next=o}r.baseQueue=s=i,n.pending=null}if(s!==null){i=s.next,r=r.baseState;var a=o=null,l=null,u=i;do{var c=u.lane;if((Lr&c)===c)l!==null&&(l=l.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:t(r,u.action);else{var d={lane:c,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};l===null?(a=l=d,o=r):l=l.next=d,Ce.lanes|=c,jr|=c}u=u.next}while(u!==null&&u!==i);l===null?o=r:l.next=a,on(r,e.memoizedState)||(lt=!0),e.memoizedState=r,e.baseState=o,e.baseQueue=l,n.lastRenderedState=r}if(t=n.interleaved,t!==null){s=t;do i=s.lane,Ce.lanes|=i,jr|=i,s=s.next;while(s!==t)}else s===null&&(n.lanes=0);return[e.memoizedState,n.dispatch]}function vu(t){var e=Ft(),n=e.queue;if(n===null)throw Error(F(311));n.lastRenderedReducer=t;var r=n.dispatch,s=n.pending,i=e.memoizedState;if(s!==null){n.pending=null;var o=s=s.next;do i=t(i,o.action),o=o.next;while(o!==s);on(i,e.memoizedState)||(lt=!0),e.memoizedState=i,e.baseQueue===null&&(e.baseState=i),n.lastRenderedState=i}return[i,r]}function b_(){}function T_(t,e){var n=Ce,r=Ft(),s=e(),i=!on(r.memoizedState,s);if(i&&(r.memoizedState=s,lt=!0),r=r.queue,Sh(I_.bind(null,n,r,t),[t]),r.getSnapshot!==e||i||Fe!==null&&Fe.memoizedState.tag&1){if(n.flags|=2048,Qi(9,C_.bind(null,n,r,s,e),void 0,null),Be===null)throw Error(F(349));Lr&30||k_(n,e,s)}return s}function k_(t,e,n){t.flags|=16384,t={getSnapshot:e,value:n},e=Ce.updateQueue,e===null?(e={lastEffect:null,stores:null},Ce.updateQueue=e,e.stores=[t]):(n=e.stores,n===null?e.stores=[t]:n.push(t))}function C_(t,e,n,r){e.value=n,e.getSnapshot=r,E_(e)&&R_(t)}function I_(t,e,n){return n(function(){E_(e)&&R_(t)})}function E_(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!on(t,n)}catch{return!0}}function R_(t){var e=On(t,1);e!==null&&tn(e,t,1,-1)}function Zp(t){var e=pn();return typeof t=="function"&&(t=t()),e.memoizedState=e.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Wi,lastRenderedState:t},e.queue=t,t=t.dispatch=xk.bind(null,Ce,t),[e.memoizedState,t]}function Qi(t,e,n,r){return t={tag:t,create:e,destroy:n,deps:r,next:null},e=Ce.updateQueue,e===null?(e={lastEffect:null,stores:null},Ce.updateQueue=e,e.lastEffect=t.next=t):(n=e.lastEffect,n===null?e.lastEffect=t.next=t:(r=n.next,n.next=t,t.next=r,e.lastEffect=t)),t}function A_(){return Ft().memoizedState}function pa(t,e,n,r){var s=pn();Ce.flags|=t,s.memoizedState=Qi(1|e,n,void 0,r===void 0?null:r)}function Sl(t,e,n,r){var s=Ft();r=r===void 0?null:r;var i=void 0;if(je!==null){var o=je.memoizedState;if(i=o.destroy,r!==null&&_h(r,o.deps)){s.memoizedState=Qi(e,n,i,r);return}}Ce.flags|=t,s.memoizedState=Qi(1|e,n,i,r)}function em(t,e){return pa(8390656,8,t,e)}function Sh(t,e){return Sl(2048,8,t,e)}function P_(t,e){return Sl(4,2,t,e)}function M_(t,e){return Sl(4,4,t,e)}function D_(t,e){if(typeof e=="function")return t=t(),e(t),function(){e(null)};if(e!=null)return t=t(),e.current=t,function(){e.current=null}}function O_(t,e,n){return n=n!=null?n.concat([t]):null,Sl(4,4,D_.bind(null,e,t),n)}function bh(){}function N_(t,e){var n=Ft();e=e===void 0?null:e;var r=n.memoizedState;return r!==null&&e!==null&&_h(e,r[1])?r[0]:(n.memoizedState=[t,e],t)}function L_(t,e){var n=Ft();e=e===void 0?null:e;var r=n.memoizedState;return r!==null&&e!==null&&_h(e,r[1])?r[0]:(t=t(),n.memoizedState=[t,e],t)}function j_(t,e,n){return Lr&21?(on(n,e)||(n=Uv(),Ce.lanes|=n,jr|=n,t.baseState=!0),e):(t.baseState&&(t.baseState=!1,lt=!0),t.memoizedState=n)}function _k(t,e){var n=fe;fe=n!==0&&4>n?n:4,t(!0);var r=gu.transition;gu.transition={};try{t(!1),e()}finally{fe=n,gu.transition=r}}function $_(){return Ft().memoizedState}function wk(t,e,n){var r=nr(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},z_(t))F_(e,n);else if(n=w_(t,e,n,r),n!==null){var s=nt();tn(n,t,r,s),B_(n,e,r)}}function xk(t,e,n){var r=nr(t),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(z_(t))F_(e,s);else{var i=t.alternate;if(t.lanes===0&&(i===null||i.lanes===0)&&(i=e.lastRenderedReducer,i!==null))try{var o=e.lastRenderedState,a=i(o,n);if(s.hasEagerState=!0,s.eagerState=a,on(a,o)){var l=e.interleaved;l===null?(s.next=s,ph(e)):(s.next=l.next,l.next=s),e.interleaved=s;return}}catch{}finally{}n=w_(t,e,s,r),n!==null&&(s=nt(),tn(n,t,r,s),B_(n,e,r))}}function z_(t){var e=t.alternate;return t===Ce||e!==null&&e===Ce}function F_(t,e){xi=Va=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function B_(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,eh(t,n)}}var Ha={readContext:zt,useCallback:Ge,useContext:Ge,useEffect:Ge,useImperativeHandle:Ge,useInsertionEffect:Ge,useLayoutEffect:Ge,useMemo:Ge,useReducer:Ge,useRef:Ge,useState:Ge,useDebugValue:Ge,useDeferredValue:Ge,useTransition:Ge,useMutableSource:Ge,useSyncExternalStore:Ge,useId:Ge,unstable_isNewReconciler:!1},Sk={readContext:zt,useCallback:function(t,e){return pn().memoizedState=[t,e===void 0?null:e],t},useContext:zt,useEffect:em,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,pa(4194308,4,D_.bind(null,e,t),n)},useLayoutEffect:function(t,e){return pa(4194308,4,t,e)},useInsertionEffect:function(t,e){return pa(4,2,t,e)},useMemo:function(t,e){var n=pn();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=pn();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=wk.bind(null,Ce,t),[r.memoizedState,t]},useRef:function(t){var e=pn();return t={current:t},e.memoizedState=t},useState:Zp,useDebugValue:bh,useDeferredValue:function(t){return pn().memoizedState=t},useTransition:function(){var t=Zp(!1),e=t[0];return t=_k.bind(null,t[1]),pn().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=Ce,s=pn();if(be){if(n===void 0)throw Error(F(407));n=n()}else{if(n=e(),Be===null)throw Error(F(349));Lr&30||k_(r,e,n)}s.memoizedState=n;var i={value:n,getSnapshot:e};return s.queue=i,em(I_.bind(null,r,i,t),[t]),r.flags|=2048,Qi(9,C_.bind(null,r,i,n,e),void 0,null),n},useId:function(){var t=pn(),e=Be.identifierPrefix;if(be){var n=Rn,r=En;n=(r&~(1<<32-en(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Gi++,0<n&&(e+="H"+n.toString(32)),e+=":"}else n=vk++,e=":"+e+"r"+n.toString(32)+":";return t.memoizedState=e},unstable_isNewReconciler:!1},bk={readContext:zt,useCallback:N_,useContext:zt,useEffect:Sh,useImperativeHandle:O_,useInsertionEffect:P_,useLayoutEffect:M_,useMemo:L_,useReducer:yu,useRef:A_,useState:function(){return yu(Wi)},useDebugValue:bh,useDeferredValue:function(t){var e=Ft();return j_(e,je.memoizedState,t)},useTransition:function(){var t=yu(Wi)[0],e=Ft().memoizedState;return[t,e]},useMutableSource:b_,useSyncExternalStore:T_,useId:$_,unstable_isNewReconciler:!1},Tk={readContext:zt,useCallback:N_,useContext:zt,useEffect:Sh,useImperativeHandle:O_,useInsertionEffect:P_,useLayoutEffect:M_,useMemo:L_,useReducer:vu,useRef:A_,useState:function(){return vu(Wi)},useDebugValue:bh,useDeferredValue:function(t){var e=Ft();return je===null?e.memoizedState=t:j_(e,je.memoizedState,t)},useTransition:function(){var t=vu(Wi)[0],e=Ft().memoizedState;return[t,e]},useMutableSource:b_,useSyncExternalStore:T_,useId:$_,unstable_isNewReconciler:!1};function Gt(t,e){if(t&&t.defaultProps){e=Ie({},e),t=t.defaultProps;for(var n in t)e[n]===void 0&&(e[n]=t[n]);return e}return e}function Bc(t,e,n,r){e=t.memoizedState,n=n(r,e),n=n==null?e:Ie({},e,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}var bl={isMounted:function(t){return(t=t._reactInternals)?Gr(t)===t:!1},enqueueSetState:function(t,e,n){t=t._reactInternals;var r=nt(),s=nr(t),i=Pn(r,s);i.payload=e,n!=null&&(i.callback=n),e=er(t,i,s),e!==null&&(tn(e,t,s,r),ha(e,t,s))},enqueueReplaceState:function(t,e,n){t=t._reactInternals;var r=nt(),s=nr(t),i=Pn(r,s);i.tag=1,i.payload=e,n!=null&&(i.callback=n),e=er(t,i,s),e!==null&&(tn(e,t,s,r),ha(e,t,s))},enqueueForceUpdate:function(t,e){t=t._reactInternals;var n=nt(),r=nr(t),s=Pn(n,r);s.tag=2,e!=null&&(s.callback=e),e=er(t,s,r),e!==null&&(tn(e,t,r,n),ha(e,t,r))}};function tm(t,e,n,r,s,i,o){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(r,i,o):e.prototype&&e.prototype.isPureReactComponent?!Fi(n,r)||!Fi(s,i):!0}function U_(t,e,n){var r=!1,s=or,i=e.contextType;return typeof i=="object"&&i!==null?i=zt(i):(s=ct(e)?Or:Ye.current,r=e.contextTypes,i=(r=r!=null)?Es(t,s):or),e=new e(n,i),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=bl,t.stateNode=e,e._reactInternals=t,r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=i),e}function nm(t,e,n,r){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(n,r),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(n,r),e.state!==t&&bl.enqueueReplaceState(e,e.state,null)}function Uc(t,e,n,r){var s=t.stateNode;s.props=n,s.state=t.memoizedState,s.refs={},mh(t);var i=e.contextType;typeof i=="object"&&i!==null?s.context=zt(i):(i=ct(e)?Or:Ye.current,s.context=Es(t,i)),s.state=t.memoizedState,i=e.getDerivedStateFromProps,typeof i=="function"&&(Bc(t,e,i,n),s.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(e=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),e!==s.state&&bl.enqueueReplaceState(s,s.state,null),Ba(t,n,s,r),s.state=t.memoizedState),typeof s.componentDidMount=="function"&&(t.flags|=4194308)}function Ms(t,e){try{var n="",r=e;do n+=Xb(r),r=r.return;while(r);var s=n}catch(i){s=`
39
+ Error generating stack: `+i.message+`
40
+ `+i.stack}return{value:t,source:e,stack:s,digest:null}}function _u(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function Vc(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var kk=typeof WeakMap=="function"?WeakMap:Map;function V_(t,e,n){n=Pn(-1,n),n.tag=3,n.payload={element:null};var r=e.value;return n.callback=function(){Ga||(Ga=!0,Zc=r),Vc(t,e)},n}function H_(t,e,n){n=Pn(-1,n),n.tag=3;var r=t.type.getDerivedStateFromError;if(typeof r=="function"){var s=e.value;n.payload=function(){return r(s)},n.callback=function(){Vc(t,e)}}var i=t.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){Vc(t,e),typeof r!="function"&&(tr===null?tr=new Set([this]):tr.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),n}function rm(t,e,n){var r=t.pingCache;if(r===null){r=t.pingCache=new kk;var s=new Set;r.set(e,s)}else s=r.get(e),s===void 0&&(s=new Set,r.set(e,s));s.has(n)||(s.add(n),t=zk.bind(null,t,e,n),e.then(t,t))}function sm(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function im(t,e,n,r,s){return t.mode&1?(t.flags|=65536,t.lanes=s,t):(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=Pn(-1,1),e.tag=2,er(n,e,1))),n.lanes|=1),t)}var Ck=jn.ReactCurrentOwner,lt=!1;function Ze(t,e,n,r){e.child=t===null?__(e,null,n,r):As(e,t.child,n,r)}function om(t,e,n,r,s){n=n.render;var i=e.ref;return Ss(e,s),r=wh(t,e,n,r,i,s),n=xh(),t!==null&&!lt?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,Nn(t,e,s)):(be&&n&&lh(e),e.flags|=1,Ze(t,e,r,s),e.child)}function am(t,e,n,r,s){if(t===null){var i=n.type;return typeof i=="function"&&!Ph(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=i,q_(t,e,i,r,s)):(t=va(n.type,null,r,e,e.mode,s),t.ref=e.ref,t.return=e,e.child=t)}if(i=t.child,!(t.lanes&s)){var o=i.memoizedProps;if(n=n.compare,n=n!==null?n:Fi,n(o,r)&&t.ref===e.ref)return Nn(t,e,s)}return e.flags|=1,t=rr(i,r),t.ref=e.ref,t.return=e,e.child=t}function q_(t,e,n,r,s){if(t!==null){var i=t.memoizedProps;if(Fi(i,r)&&t.ref===e.ref)if(lt=!1,e.pendingProps=r=i,(t.lanes&s)!==0)t.flags&131072&&(lt=!0);else return e.lanes=t.lanes,Nn(t,e,s)}return Hc(t,e,n,r,s)}function G_(t,e,n){var r=e.pendingProps,s=r.children,i=t!==null?t.memoizedState:null;if(r.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},ve(ys,yt),yt|=n;else{if(!(n&1073741824))return t=i!==null?i.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,ve(ys,yt),yt|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,ve(ys,yt),yt|=r}else i!==null?(r=i.baseLanes|n,e.memoizedState=null):r=n,ve(ys,yt),yt|=r;return Ze(t,e,s,n),e.child}function W_(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function Hc(t,e,n,r,s){var i=ct(n)?Or:Ye.current;return i=Es(e,i),Ss(e,s),n=wh(t,e,n,r,i,s),r=xh(),t!==null&&!lt?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,Nn(t,e,s)):(be&&r&&lh(e),e.flags|=1,Ze(t,e,n,s),e.child)}function lm(t,e,n,r,s){if(ct(n)){var i=!0;La(e)}else i=!1;if(Ss(e,s),e.stateNode===null)ma(t,e),U_(e,n,r),Uc(e,n,r,s),r=!0;else if(t===null){var o=e.stateNode,a=e.memoizedProps;o.props=a;var l=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=zt(u):(u=ct(n)?Or:Ye.current,u=Es(e,u));var c=n.getDerivedStateFromProps,d=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function";d||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||l!==u)&&nm(e,o,r,u),Hn=!1;var h=e.memoizedState;o.state=h,Ba(e,r,o,s),l=e.memoizedState,a!==r||h!==l||ut.current||Hn?(typeof c=="function"&&(Bc(e,n,c,r),l=e.memoizedState),(a=Hn||tm(e,n,a,r,h,l,u))?(d||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=l),o.props=r,o.state=l,o.context=u,r=a):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{o=e.stateNode,x_(t,e),a=e.memoizedProps,u=e.type===e.elementType?a:Gt(e.type,a),o.props=u,d=e.pendingProps,h=o.context,l=n.contextType,typeof l=="object"&&l!==null?l=zt(l):(l=ct(n)?Or:Ye.current,l=Es(e,l));var f=n.getDerivedStateFromProps;(c=typeof f=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==d||h!==l)&&nm(e,o,r,l),Hn=!1,h=e.memoizedState,o.state=h,Ba(e,r,o,s);var p=e.memoizedState;a!==d||h!==p||ut.current||Hn?(typeof f=="function"&&(Bc(e,n,f,r),p=e.memoizedState),(u=Hn||tm(e,n,u,r,h,p,l)||!1)?(c||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,p,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,p,l)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&h===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&h===t.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=p),o.props=r,o.state=p,o.context=l,r=u):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&h===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&h===t.memoizedState||(e.flags|=1024),r=!1)}return qc(t,e,n,r,i,s)}function qc(t,e,n,r,s,i){W_(t,e);var o=(e.flags&128)!==0;if(!r&&!o)return s&&Wp(e,n,!1),Nn(t,e,i);r=e.stateNode,Ck.current=e;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,t!==null&&o?(e.child=As(e,t.child,null,i),e.child=As(e,null,a,i)):Ze(t,e,a,i),e.memoizedState=r.state,s&&Wp(e,n,!0),e.child}function Q_(t){var e=t.stateNode;e.pendingContext?Gp(t,e.pendingContext,e.pendingContext!==e.context):e.context&&Gp(t,e.context,!1),gh(t,e.containerInfo)}function um(t,e,n,r,s){return Rs(),ch(s),e.flags|=256,Ze(t,e,n,r),e.child}var Gc={dehydrated:null,treeContext:null,retryLane:0};function Wc(t){return{baseLanes:t,cachePool:null,transitions:null}}function K_(t,e,n){var r=e.pendingProps,s=ke.current,i=!1,o=(e.flags&128)!==0,a;if((a=o)||(a=t!==null&&t.memoizedState===null?!1:(s&2)!==0),a?(i=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(s|=1),ve(ke,s&1),t===null)return zc(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(o=r.children,t=r.fallback,i?(r=e.mode,i=e.child,o={mode:"hidden",children:o},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=Cl(o,r,0,null),t=Pr(t,r,n,null),i.return=e,t.return=e,i.sibling=t,e.child=i,e.child.memoizedState=Wc(n),e.memoizedState=Gc,t):Th(e,o));if(s=t.memoizedState,s!==null&&(a=s.dehydrated,a!==null))return Ik(t,e,o,r,a,s,n);if(i){i=r.fallback,o=e.mode,s=t.child,a=s.sibling;var l={mode:"hidden",children:r.children};return!(o&1)&&e.child!==s?(r=e.child,r.childLanes=0,r.pendingProps=l,e.deletions=null):(r=rr(s,l),r.subtreeFlags=s.subtreeFlags&14680064),a!==null?i=rr(a,i):(i=Pr(i,o,n,null),i.flags|=2),i.return=e,r.return=e,r.sibling=i,e.child=r,r=i,i=e.child,o=t.child.memoizedState,o=o===null?Wc(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=t.childLanes&~n,e.memoizedState=Gc,r}return i=t.child,t=i.sibling,r=rr(i,{mode:"visible",children:r.children}),!(e.mode&1)&&(r.lanes=n),r.return=e,r.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=r,e.memoizedState=null,r}function Th(t,e){return e=Cl({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function Uo(t,e,n,r){return r!==null&&ch(r),As(e,t.child,null,n),t=Th(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function Ik(t,e,n,r,s,i,o){if(n)return e.flags&256?(e.flags&=-257,r=_u(Error(F(422))),Uo(t,e,o,r)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(i=r.fallback,s=e.mode,r=Cl({mode:"visible",children:r.children},s,0,null),i=Pr(i,s,o,null),i.flags|=2,r.return=e,i.return=e,r.sibling=i,e.child=r,e.mode&1&&As(e,t.child,null,o),e.child.memoizedState=Wc(o),e.memoizedState=Gc,i);if(!(e.mode&1))return Uo(t,e,o,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var a=r.dgst;return r=a,i=Error(F(419)),r=_u(i,r,void 0),Uo(t,e,o,r)}if(a=(o&t.childLanes)!==0,lt||a){if(r=Be,r!==null){switch(o&-o){case 4:s=2;break;case 16:s=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(r.suspendedLanes|o)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,On(t,s),tn(r,t,s,-1))}return Ah(),r=_u(Error(F(421))),Uo(t,e,o,r)}return s.data==="$?"?(e.flags|=128,e.child=t.child,e=Fk.bind(null,t),s._reactRetry=e,null):(t=i.treeContext,vt=Zn(s.nextSibling),St=e,be=!0,Qt=null,t!==null&&(Mt[Dt++]=En,Mt[Dt++]=Rn,Mt[Dt++]=Nr,En=t.id,Rn=t.overflow,Nr=e),e=Th(e,r.children),e.flags|=4096,e)}function cm(t,e,n){t.lanes|=e;var r=t.alternate;r!==null&&(r.lanes|=e),Fc(t.return,e,n)}function wu(t,e,n,r,s){var i=t.memoizedState;i===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(i.isBackwards=e,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=s)}function Y_(t,e,n){var r=e.pendingProps,s=r.revealOrder,i=r.tail;if(Ze(t,e,r.children,n),r=ke.current,r&2)r=r&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&cm(t,n,e);else if(t.tag===19)cm(t,n,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}r&=1}if(ve(ke,r),!(e.mode&1))e.memoizedState=null;else switch(s){case"forwards":for(n=e.child,s=null;n!==null;)t=n.alternate,t!==null&&Ua(t)===null&&(s=n),n=n.sibling;n=s,n===null?(s=e.child,e.child=null):(s=n.sibling,n.sibling=null),wu(e,!1,s,n,i);break;case"backwards":for(n=null,s=e.child,e.child=null;s!==null;){if(t=s.alternate,t!==null&&Ua(t)===null){e.child=s;break}t=s.sibling,s.sibling=n,n=s,s=t}wu(e,!0,n,null,i);break;case"together":wu(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function ma(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function Nn(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),jr|=e.lanes,!(n&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(F(153));if(e.child!==null){for(t=e.child,n=rr(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=rr(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function Ek(t,e,n){switch(e.tag){case 3:Q_(e),Rs();break;case 5:S_(e);break;case 1:ct(e.type)&&La(e);break;case 4:gh(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,s=e.memoizedProps.value;ve(za,r._currentValue),r._currentValue=s;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(ve(ke,ke.current&1),e.flags|=128,null):n&e.child.childLanes?K_(t,e,n):(ve(ke,ke.current&1),t=Nn(t,e,n),t!==null?t.sibling:null);ve(ke,ke.current&1);break;case 19:if(r=(n&e.childLanes)!==0,t.flags&128){if(r)return Y_(t,e,n);e.flags|=128}if(s=e.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),ve(ke,ke.current),r)break;return null;case 22:case 23:return e.lanes=0,G_(t,e,n)}return Nn(t,e,n)}var J_,Qc,X_,Z_;J_=function(t,e){for(var n=e.child;n!==null;){if(n.tag===5||n.tag===6)t.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Qc=function(){};X_=function(t,e,n,r){var s=t.memoizedProps;if(s!==r){t=e.stateNode,Ir(_n.current);var i=null;switch(n){case"input":s=gc(t,s),r=gc(t,r),i=[];break;case"select":s=Ie({},s,{value:void 0}),r=Ie({},r,{value:void 0}),i=[];break;case"textarea":s=_c(t,s),r=_c(t,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(t.onclick=Oa)}xc(n,r);var o;n=null;for(u in s)if(!r.hasOwnProperty(u)&&s.hasOwnProperty(u)&&s[u]!=null)if(u==="style"){var a=s[u];for(o in a)a.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Di.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in r){var l=r[u];if(a=s!=null?s[u]:void 0,r.hasOwnProperty(u)&&l!==a&&(l!=null||a!=null))if(u==="style")if(a){for(o in a)!a.hasOwnProperty(o)||l&&l.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in l)l.hasOwnProperty(o)&&a[o]!==l[o]&&(n||(n={}),n[o]=l[o])}else n||(i||(i=[]),i.push(u,n)),n=l;else u==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(i=i||[]).push(u,l)):u==="children"?typeof l!="string"&&typeof l!="number"||(i=i||[]).push(u,""+l):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Di.hasOwnProperty(u)?(l!=null&&u==="onScroll"&&we("scroll",t),i||a===l||(i=[])):(i=i||[]).push(u,l))}n&&(i=i||[]).push("style",n);var u=i;(e.updateQueue=u)&&(e.flags|=4)}};Z_=function(t,e,n,r){n!==r&&(e.flags|=4)};function ri(t,e){if(!be)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:r.sibling=null}}function We(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,r=0;if(e)for(var s=t.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=t,s=s.sibling;else for(s=t.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=t,s=s.sibling;return t.subtreeFlags|=r,t.childLanes=n,e}function Rk(t,e,n){var r=e.pendingProps;switch(uh(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return We(e),null;case 1:return ct(e.type)&&Na(),We(e),null;case 3:return r=e.stateNode,Ps(),xe(ut),xe(Ye),vh(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(Fo(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,Qt!==null&&(nd(Qt),Qt=null))),Qc(t,e),We(e),null;case 5:yh(e);var s=Ir(qi.current);if(n=e.type,t!==null&&e.stateNode!=null)X_(t,e,n,r,s),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(F(166));return We(e),null}if(t=Ir(_n.current),Fo(e)){r=e.stateNode,n=e.type;var i=e.memoizedProps;switch(r[yn]=e,r[Vi]=i,t=(e.mode&1)!==0,n){case"dialog":we("cancel",r),we("close",r);break;case"iframe":case"object":case"embed":we("load",r);break;case"video":case"audio":for(s=0;s<fi.length;s++)we(fi[s],r);break;case"source":we("error",r);break;case"img":case"image":case"link":we("error",r),we("load",r);break;case"details":we("toggle",r);break;case"input":_p(r,i),we("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},we("invalid",r);break;case"textarea":xp(r,i),we("invalid",r)}xc(n,i),s=null;for(var o in i)if(i.hasOwnProperty(o)){var a=i[o];o==="children"?typeof a=="string"?r.textContent!==a&&(i.suppressHydrationWarning!==!0&&zo(r.textContent,a,t),s=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(i.suppressHydrationWarning!==!0&&zo(r.textContent,a,t),s=["children",""+a]):Di.hasOwnProperty(o)&&a!=null&&o==="onScroll"&&we("scroll",r)}switch(n){case"input":Po(r),wp(r,i,!0);break;case"textarea":Po(r),Sp(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=Oa)}r=s,e.updateQueue=r,r!==null&&(e.flags|=4)}else{o=s.nodeType===9?s:s.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=Iv(n)),t==="http://www.w3.org/1999/xhtml"?n==="script"?(t=o.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[yn]=e,t[Vi]=r,J_(t,e,!1,!1),e.stateNode=t;e:{switch(o=Sc(n,r),n){case"dialog":we("cancel",t),we("close",t),s=r;break;case"iframe":case"object":case"embed":we("load",t),s=r;break;case"video":case"audio":for(s=0;s<fi.length;s++)we(fi[s],t);s=r;break;case"source":we("error",t),s=r;break;case"img":case"image":case"link":we("error",t),we("load",t),s=r;break;case"details":we("toggle",t),s=r;break;case"input":_p(t,r),s=gc(t,r),we("invalid",t);break;case"option":s=r;break;case"select":t._wrapperState={wasMultiple:!!r.multiple},s=Ie({},r,{value:void 0}),we("invalid",t);break;case"textarea":xp(t,r),s=_c(t,r),we("invalid",t);break;default:s=r}xc(n,s),a=s;for(i in a)if(a.hasOwnProperty(i)){var l=a[i];i==="style"?Av(t,l):i==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&Ev(t,l)):i==="children"?typeof l=="string"?(n!=="textarea"||l!=="")&&Oi(t,l):typeof l=="number"&&Oi(t,""+l):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Di.hasOwnProperty(i)?l!=null&&i==="onScroll"&&we("scroll",t):l!=null&&Qd(t,i,l,o))}switch(n){case"input":Po(t),wp(t,r,!1);break;case"textarea":Po(t),Sp(t);break;case"option":r.value!=null&&t.setAttribute("value",""+ir(r.value));break;case"select":t.multiple=!!r.multiple,i=r.value,i!=null?vs(t,!!r.multiple,i,!1):r.defaultValue!=null&&vs(t,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(t.onclick=Oa)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return We(e),null;case 6:if(t&&e.stateNode!=null)Z_(t,e,t.memoizedProps,r);else{if(typeof r!="string"&&e.stateNode===null)throw Error(F(166));if(n=Ir(qi.current),Ir(_n.current),Fo(e)){if(r=e.stateNode,n=e.memoizedProps,r[yn]=e,(i=r.nodeValue!==n)&&(t=St,t!==null))switch(t.tag){case 3:zo(r.nodeValue,n,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&zo(r.nodeValue,n,(t.mode&1)!==0)}i&&(e.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[yn]=e,e.stateNode=r}return We(e),null;case 13:if(xe(ke),r=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(be&&vt!==null&&e.mode&1&&!(e.flags&128))y_(),Rs(),e.flags|=98560,i=!1;else if(i=Fo(e),r!==null&&r.dehydrated!==null){if(t===null){if(!i)throw Error(F(318));if(i=e.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(F(317));i[yn]=e}else Rs(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;We(e),i=!1}else Qt!==null&&(nd(Qt),Qt=null),i=!0;if(!i)return e.flags&65536?e:null}return e.flags&128?(e.lanes=n,e):(r=r!==null,r!==(t!==null&&t.memoizedState!==null)&&r&&(e.child.flags|=8192,e.mode&1&&(t===null||ke.current&1?$e===0&&($e=3):Ah())),e.updateQueue!==null&&(e.flags|=4),We(e),null);case 4:return Ps(),Qc(t,e),t===null&&Bi(e.stateNode.containerInfo),We(e),null;case 10:return fh(e.type._context),We(e),null;case 17:return ct(e.type)&&Na(),We(e),null;case 19:if(xe(ke),i=e.memoizedState,i===null)return We(e),null;if(r=(e.flags&128)!==0,o=i.rendering,o===null)if(r)ri(i,!1);else{if($e!==0||t!==null&&t.flags&128)for(t=e.child;t!==null;){if(o=Ua(t),o!==null){for(e.flags|=128,ri(i,!1),r=o.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),e.subtreeFlags=0,r=n,n=e.child;n!==null;)i=n,t=r,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=t,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,t=o.dependencies,i.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),n=n.sibling;return ve(ke,ke.current&1|2),e.child}t=t.sibling}i.tail!==null&&Me()>Ds&&(e.flags|=128,r=!0,ri(i,!1),e.lanes=4194304)}else{if(!r)if(t=Ua(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),ri(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!be)return We(e),null}else 2*Me()-i.renderingStartTime>Ds&&n!==1073741824&&(e.flags|=128,r=!0,ri(i,!1),e.lanes=4194304);i.isBackwards?(o.sibling=e.child,e.child=o):(n=i.last,n!==null?n.sibling=o:e.child=o,i.last=o)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Me(),e.sibling=null,n=ke.current,ve(ke,r?n&1|2:n&1),e):(We(e),null);case 22:case 23:return Rh(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?yt&1073741824&&(We(e),e.subtreeFlags&6&&(e.flags|=8192)):We(e),null;case 24:return null;case 25:return null}throw Error(F(156,e.tag))}function Ak(t,e){switch(uh(e),e.tag){case 1:return ct(e.type)&&Na(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ps(),xe(ut),xe(Ye),vh(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return yh(e),null;case 13:if(xe(ke),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(F(340));Rs()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return xe(ke),null;case 4:return Ps(),null;case 10:return fh(e.type._context),null;case 22:case 23:return Rh(),null;case 24:return null;default:return null}}var Vo=!1,Qe=!1,Pk=typeof WeakSet=="function"?WeakSet:Set,Q=null;function gs(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Pe(t,e,r)}else n.current=null}function Kc(t,e,n){try{n()}catch(r){Pe(t,e,r)}}var dm=!1;function Mk(t,e){if(Mc=Pa,t=s_(),ah(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,u=0,c=0,d=t,h=null;t:for(;;){for(var f;d!==n||s!==0&&d.nodeType!==3||(a=o+s),d!==i||r!==0&&d.nodeType!==3||(l=o+r),d.nodeType===3&&(o+=d.nodeValue.length),(f=d.firstChild)!==null;)h=d,d=f;for(;;){if(d===t)break t;if(h===n&&++u===s&&(a=o),h===i&&++c===r&&(l=o),(f=d.nextSibling)!==null)break;d=h,h=d.parentNode}d=f}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(Dc={focusedElem:t,selectionRange:n},Pa=!1,Q=e;Q!==null;)if(e=Q,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Q=t;else for(;Q!==null;){e=Q;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var g=p.memoizedProps,_=p.memoizedState,m=e.stateNode,y=m.getSnapshotBeforeUpdate(e.elementType===e.type?g:Gt(e.type,g),_);m.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var v=e.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(F(163))}}catch(S){Pe(e,e.return,S)}if(t=e.sibling,t!==null){t.return=e.return,Q=t;break}Q=e.return}return p=dm,dm=!1,p}function Si(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&t)===t){var i=s.destroy;s.destroy=void 0,i!==void 0&&Kc(e,n,i)}s=s.next}while(s!==r)}}function Tl(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function Yc(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function ew(t){var e=t.alternate;e!==null&&(t.alternate=null,ew(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[yn],delete e[Vi],delete e[Lc],delete e[pk],delete e[mk])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function tw(t){return t.tag===5||t.tag===3||t.tag===4}function hm(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||tw(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Jc(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Oa));else if(r!==4&&(t=t.child,t!==null))for(Jc(t,e,n),t=t.sibling;t!==null;)Jc(t,e,n),t=t.sibling}function Xc(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(Xc(t,e,n),t=t.sibling;t!==null;)Xc(t,e,n),t=t.sibling}var Ve=null,Wt=!1;function Fn(t,e,n){for(n=n.child;n!==null;)nw(t,e,n),n=n.sibling}function nw(t,e,n){if(vn&&typeof vn.onCommitFiberUnmount=="function")try{vn.onCommitFiberUnmount(gl,n)}catch{}switch(n.tag){case 5:Qe||gs(n,e);case 6:var r=Ve,s=Wt;Ve=null,Fn(t,e,n),Ve=r,Wt=s,Ve!==null&&(Wt?(t=Ve,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):Ve.removeChild(n.stateNode));break;case 18:Ve!==null&&(Wt?(t=Ve,n=n.stateNode,t.nodeType===8?fu(t.parentNode,n):t.nodeType===1&&fu(t,n),$i(t)):fu(Ve,n.stateNode));break;case 4:r=Ve,s=Wt,Ve=n.stateNode.containerInfo,Wt=!0,Fn(t,e,n),Ve=r,Wt=s;break;case 0:case 11:case 14:case 15:if(!Qe&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&Kc(n,e,o),s=s.next}while(s!==r)}Fn(t,e,n);break;case 1:if(!Qe&&(gs(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Pe(n,e,a)}Fn(t,e,n);break;case 21:Fn(t,e,n);break;case 22:n.mode&1?(Qe=(r=Qe)||n.memoizedState!==null,Fn(t,e,n),Qe=r):Fn(t,e,n);break;default:Fn(t,e,n)}}function fm(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new Pk),e.forEach(function(r){var s=Bk.bind(null,t,r);n.has(r)||(n.add(r),r.then(s,s))})}}function qt(t,e){var n=e.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var i=t,o=e,a=o;e:for(;a!==null;){switch(a.tag){case 5:Ve=a.stateNode,Wt=!1;break e;case 3:Ve=a.stateNode.containerInfo,Wt=!0;break e;case 4:Ve=a.stateNode.containerInfo,Wt=!0;break e}a=a.return}if(Ve===null)throw Error(F(160));nw(i,o,s),Ve=null,Wt=!1;var l=s.alternate;l!==null&&(l.return=null),s.return=null}catch(u){Pe(s,e,u)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)rw(e,t),e=e.sibling}function rw(t,e){var n=t.alternate,r=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(qt(e,t),hn(t),r&4){try{Si(3,t,t.return),Tl(3,t)}catch(g){Pe(t,t.return,g)}try{Si(5,t,t.return)}catch(g){Pe(t,t.return,g)}}break;case 1:qt(e,t),hn(t),r&512&&n!==null&&gs(n,n.return);break;case 5:if(qt(e,t),hn(t),r&512&&n!==null&&gs(n,n.return),t.flags&32){var s=t.stateNode;try{Oi(s,"")}catch(g){Pe(t,t.return,g)}}if(r&4&&(s=t.stateNode,s!=null)){var i=t.memoizedProps,o=n!==null?n.memoizedProps:i,a=t.type,l=t.updateQueue;if(t.updateQueue=null,l!==null)try{a==="input"&&i.type==="radio"&&i.name!=null&&kv(s,i),Sc(a,o);var u=Sc(a,i);for(o=0;o<l.length;o+=2){var c=l[o],d=l[o+1];c==="style"?Av(s,d):c==="dangerouslySetInnerHTML"?Ev(s,d):c==="children"?Oi(s,d):Qd(s,c,d,u)}switch(a){case"input":yc(s,i);break;case"textarea":Cv(s,i);break;case"select":var h=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var f=i.value;f!=null?vs(s,!!i.multiple,f,!1):h!==!!i.multiple&&(i.defaultValue!=null?vs(s,!!i.multiple,i.defaultValue,!0):vs(s,!!i.multiple,i.multiple?[]:"",!1))}s[Vi]=i}catch(g){Pe(t,t.return,g)}}break;case 6:if(qt(e,t),hn(t),r&4){if(t.stateNode===null)throw Error(F(162));s=t.stateNode,i=t.memoizedProps;try{s.nodeValue=i}catch(g){Pe(t,t.return,g)}}break;case 3:if(qt(e,t),hn(t),r&4&&n!==null&&n.memoizedState.isDehydrated)try{$i(e.containerInfo)}catch(g){Pe(t,t.return,g)}break;case 4:qt(e,t),hn(t);break;case 13:qt(e,t),hn(t),s=t.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(Ih=Me())),r&4&&fm(t);break;case 22:if(c=n!==null&&n.memoizedState!==null,t.mode&1?(Qe=(u=Qe)||c,qt(e,t),Qe=u):qt(e,t),hn(t),r&8192){if(u=t.memoizedState!==null,(t.stateNode.isHidden=u)&&!c&&t.mode&1)for(Q=t,c=t.child;c!==null;){for(d=Q=c;Q!==null;){switch(h=Q,f=h.child,h.tag){case 0:case 11:case 14:case 15:Si(4,h,h.return);break;case 1:gs(h,h.return);var p=h.stateNode;if(typeof p.componentWillUnmount=="function"){r=h,n=h.return;try{e=r,p.props=e.memoizedProps,p.state=e.memoizedState,p.componentWillUnmount()}catch(g){Pe(r,n,g)}}break;case 5:gs(h,h.return);break;case 22:if(h.memoizedState!==null){mm(d);continue}}f!==null?(f.return=h,Q=f):mm(d)}c=c.sibling}e:for(c=null,d=t;;){if(d.tag===5){if(c===null){c=d;try{s=d.stateNode,u?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(a=d.stateNode,l=d.memoizedProps.style,o=l!=null&&l.hasOwnProperty("display")?l.display:null,a.style.display=Rv("display",o))}catch(g){Pe(t,t.return,g)}}}else if(d.tag===6){if(c===null)try{d.stateNode.nodeValue=u?"":d.memoizedProps}catch(g){Pe(t,t.return,g)}}else if((d.tag!==22&&d.tag!==23||d.memoizedState===null||d===t)&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===t)break e;for(;d.sibling===null;){if(d.return===null||d.return===t)break e;c===d&&(c=null),d=d.return}c===d&&(c=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:qt(e,t),hn(t),r&4&&fm(t);break;case 21:break;default:qt(e,t),hn(t)}}function hn(t){var e=t.flags;if(e&2){try{e:{for(var n=t.return;n!==null;){if(tw(n)){var r=n;break e}n=n.return}throw Error(F(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Oi(s,""),r.flags&=-33);var i=hm(t);Xc(t,i,s);break;case 3:case 4:var o=r.stateNode.containerInfo,a=hm(t);Jc(t,a,o);break;default:throw Error(F(161))}}catch(l){Pe(t,t.return,l)}t.flags&=-3}e&4096&&(t.flags&=-4097)}function Dk(t,e,n){Q=t,sw(t)}function sw(t,e,n){for(var r=(t.mode&1)!==0;Q!==null;){var s=Q,i=s.child;if(s.tag===22&&r){var o=s.memoizedState!==null||Vo;if(!o){var a=s.alternate,l=a!==null&&a.memoizedState!==null||Qe;a=Vo;var u=Qe;if(Vo=o,(Qe=l)&&!u)for(Q=s;Q!==null;)o=Q,l=o.child,o.tag===22&&o.memoizedState!==null?gm(s):l!==null?(l.return=o,Q=l):gm(s);for(;i!==null;)Q=i,sw(i),i=i.sibling;Q=s,Vo=a,Qe=u}pm(t)}else s.subtreeFlags&8772&&i!==null?(i.return=s,Q=i):pm(t)}}function pm(t){for(;Q!==null;){var e=Q;if(e.flags&8772){var n=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:Qe||Tl(5,e);break;case 1:var r=e.stateNode;if(e.flags&4&&!Qe)if(n===null)r.componentDidMount();else{var s=e.elementType===e.type?n.memoizedProps:Gt(e.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=e.updateQueue;i!==null&&Xp(e,i,r);break;case 3:var o=e.updateQueue;if(o!==null){if(n=null,e.child!==null)switch(e.child.tag){case 5:n=e.child.stateNode;break;case 1:n=e.child.stateNode}Xp(e,o,n)}break;case 5:var a=e.stateNode;if(n===null&&e.flags&4){n=a;var l=e.memoizedProps;switch(e.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&n.focus();break;case"img":l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(e.memoizedState===null){var u=e.alternate;if(u!==null){var c=u.memoizedState;if(c!==null){var d=c.dehydrated;d!==null&&$i(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(F(163))}Qe||e.flags&512&&Yc(e)}catch(h){Pe(e,e.return,h)}}if(e===t){Q=null;break}if(n=e.sibling,n!==null){n.return=e.return,Q=n;break}Q=e.return}}function mm(t){for(;Q!==null;){var e=Q;if(e===t){Q=null;break}var n=e.sibling;if(n!==null){n.return=e.return,Q=n;break}Q=e.return}}function gm(t){for(;Q!==null;){var e=Q;try{switch(e.tag){case 0:case 11:case 15:var n=e.return;try{Tl(4,e)}catch(l){Pe(e,n,l)}break;case 1:var r=e.stateNode;if(typeof r.componentDidMount=="function"){var s=e.return;try{r.componentDidMount()}catch(l){Pe(e,s,l)}}var i=e.return;try{Yc(e)}catch(l){Pe(e,i,l)}break;case 5:var o=e.return;try{Yc(e)}catch(l){Pe(e,o,l)}}}catch(l){Pe(e,e.return,l)}if(e===t){Q=null;break}var a=e.sibling;if(a!==null){a.return=e.return,Q=a;break}Q=e.return}}var Ok=Math.ceil,qa=jn.ReactCurrentDispatcher,kh=jn.ReactCurrentOwner,$t=jn.ReactCurrentBatchConfig,ue=0,Be=null,Ne=null,He=0,yt=0,ys=cr(0),$e=0,Ki=null,jr=0,kl=0,Ch=0,bi=null,at=null,Ih=0,Ds=1/0,Tn=null,Ga=!1,Zc=null,tr=null,Ho=!1,Kn=null,Wa=0,Ti=0,ed=null,ga=-1,ya=0;function nt(){return ue&6?Me():ga!==-1?ga:ga=Me()}function nr(t){return t.mode&1?ue&2&&He!==0?He&-He:yk.transition!==null?(ya===0&&(ya=Uv()),ya):(t=fe,t!==0||(t=window.event,t=t===void 0?16:Kv(t.type)),t):1}function tn(t,e,n,r){if(50<Ti)throw Ti=0,ed=null,Error(F(185));vo(t,n,r),(!(ue&2)||t!==Be)&&(t===Be&&(!(ue&2)&&(kl|=n),$e===4&&Wn(t,He)),dt(t,r),n===1&&ue===0&&!(e.mode&1)&&(Ds=Me()+500,xl&&dr()))}function dt(t,e){var n=t.callbackNode;yT(t,e);var r=Aa(t,t===Be?He:0);if(r===0)n!==null&&kp(n),t.callbackNode=null,t.callbackPriority=0;else if(e=r&-r,t.callbackPriority!==e){if(n!=null&&kp(n),e===1)t.tag===0?gk(ym.bind(null,t)):p_(ym.bind(null,t)),hk(function(){!(ue&6)&&dr()}),n=null;else{switch(Vv(r)){case 1:n=Zd;break;case 4:n=Fv;break;case 16:n=Ra;break;case 536870912:n=Bv;break;default:n=Ra}n=hw(n,iw.bind(null,t))}t.callbackPriority=e,t.callbackNode=n}}function iw(t,e){if(ga=-1,ya=0,ue&6)throw Error(F(327));var n=t.callbackNode;if(bs()&&t.callbackNode!==n)return null;var r=Aa(t,t===Be?He:0);if(r===0)return null;if(r&30||r&t.expiredLanes||e)e=Qa(t,r);else{e=r;var s=ue;ue|=2;var i=aw();(Be!==t||He!==e)&&(Tn=null,Ds=Me()+500,Ar(t,e));do try{jk();break}catch(a){ow(t,a)}while(!0);hh(),qa.current=i,ue=s,Ne!==null?e=0:(Be=null,He=0,e=$e)}if(e!==0){if(e===2&&(s=Ic(t),s!==0&&(r=s,e=td(t,s))),e===1)throw n=Ki,Ar(t,0),Wn(t,r),dt(t,Me()),n;if(e===6)Wn(t,r);else{if(s=t.current.alternate,!(r&30)&&!Nk(s)&&(e=Qa(t,r),e===2&&(i=Ic(t),i!==0&&(r=i,e=td(t,i))),e===1))throw n=Ki,Ar(t,0),Wn(t,r),dt(t,Me()),n;switch(t.finishedWork=s,t.finishedLanes=r,e){case 0:case 1:throw Error(F(345));case 2:wr(t,at,Tn);break;case 3:if(Wn(t,r),(r&130023424)===r&&(e=Ih+500-Me(),10<e)){if(Aa(t,0)!==0)break;if(s=t.suspendedLanes,(s&r)!==r){nt(),t.pingedLanes|=t.suspendedLanes&s;break}t.timeoutHandle=Nc(wr.bind(null,t,at,Tn),e);break}wr(t,at,Tn);break;case 4:if(Wn(t,r),(r&4194240)===r)break;for(e=t.eventTimes,s=-1;0<r;){var o=31-en(r);i=1<<o,o=e[o],o>s&&(s=o),r&=~i}if(r=s,r=Me()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Ok(r/1960))-r,10<r){t.timeoutHandle=Nc(wr.bind(null,t,at,Tn),r);break}wr(t,at,Tn);break;case 5:wr(t,at,Tn);break;default:throw Error(F(329))}}}return dt(t,Me()),t.callbackNode===n?iw.bind(null,t):null}function td(t,e){var n=bi;return t.current.memoizedState.isDehydrated&&(Ar(t,e).flags|=256),t=Qa(t,e),t!==2&&(e=at,at=n,e!==null&&nd(e)),t}function nd(t){at===null?at=t:at.push.apply(at,t)}function Nk(t){for(var e=t;;){if(e.flags&16384){var n=e.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var s=n[r],i=s.getSnapshot;s=s.value;try{if(!on(i(),s))return!1}catch{return!1}}}if(n=e.child,e.subtreeFlags&16384&&n!==null)n.return=e,e=n;else{if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return!0;e=e.return}e.sibling.return=e.return,e=e.sibling}}return!0}function Wn(t,e){for(e&=~Ch,e&=~kl,t.suspendedLanes|=e,t.pingedLanes&=~e,t=t.expirationTimes;0<e;){var n=31-en(e),r=1<<n;t[n]=-1,e&=~r}}function ym(t){if(ue&6)throw Error(F(327));bs();var e=Aa(t,0);if(!(e&1))return dt(t,Me()),null;var n=Qa(t,e);if(t.tag!==0&&n===2){var r=Ic(t);r!==0&&(e=r,n=td(t,r))}if(n===1)throw n=Ki,Ar(t,0),Wn(t,e),dt(t,Me()),n;if(n===6)throw Error(F(345));return t.finishedWork=t.current.alternate,t.finishedLanes=e,wr(t,at,Tn),dt(t,Me()),null}function Eh(t,e){var n=ue;ue|=1;try{return t(e)}finally{ue=n,ue===0&&(Ds=Me()+500,xl&&dr())}}function $r(t){Kn!==null&&Kn.tag===0&&!(ue&6)&&bs();var e=ue;ue|=1;var n=$t.transition,r=fe;try{if($t.transition=null,fe=1,t)return t()}finally{fe=r,$t.transition=n,ue=e,!(ue&6)&&dr()}}function Rh(){yt=ys.current,xe(ys)}function Ar(t,e){t.finishedWork=null,t.finishedLanes=0;var n=t.timeoutHandle;if(n!==-1&&(t.timeoutHandle=-1,dk(n)),Ne!==null)for(n=Ne.return;n!==null;){var r=n;switch(uh(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Na();break;case 3:Ps(),xe(ut),xe(Ye),vh();break;case 5:yh(r);break;case 4:Ps();break;case 13:xe(ke);break;case 19:xe(ke);break;case 10:fh(r.type._context);break;case 22:case 23:Rh()}n=n.return}if(Be=t,Ne=t=rr(t.current,null),He=yt=e,$e=0,Ki=null,Ch=kl=jr=0,at=bi=null,Cr!==null){for(e=0;e<Cr.length;e++)if(n=Cr[e],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,i=n.pending;if(i!==null){var o=i.next;i.next=s,r.next=o}n.pending=r}Cr=null}return t}function ow(t,e){do{var n=Ne;try{if(hh(),fa.current=Ha,Va){for(var r=Ce.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Va=!1}if(Lr=0,Fe=je=Ce=null,xi=!1,Gi=0,kh.current=null,n===null||n.return===null){$e=1,Ki=e,Ne=null;break}e:{var i=t,o=n.return,a=n,l=e;if(e=He,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var u=l,c=a,d=c.tag;if(!(c.mode&1)&&(d===0||d===11||d===15)){var h=c.alternate;h?(c.updateQueue=h.updateQueue,c.memoizedState=h.memoizedState,c.lanes=h.lanes):(c.updateQueue=null,c.memoizedState=null)}var f=sm(o);if(f!==null){f.flags&=-257,im(f,o,a,i,e),f.mode&1&&rm(i,u,e),e=f,l=u;var p=e.updateQueue;if(p===null){var g=new Set;g.add(l),e.updateQueue=g}else p.add(l);break e}else{if(!(e&1)){rm(i,u,e),Ah();break e}l=Error(F(426))}}else if(be&&a.mode&1){var _=sm(o);if(_!==null){!(_.flags&65536)&&(_.flags|=256),im(_,o,a,i,e),ch(Ms(l,a));break e}}i=l=Ms(l,a),$e!==4&&($e=2),bi===null?bi=[i]:bi.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,e&=-e,i.lanes|=e;var m=V_(i,l,e);Jp(i,m);break e;case 1:a=l;var y=i.type,v=i.stateNode;if(!(i.flags&128)&&(typeof y.getDerivedStateFromError=="function"||v!==null&&typeof v.componentDidCatch=="function"&&(tr===null||!tr.has(v)))){i.flags|=65536,e&=-e,i.lanes|=e;var S=H_(i,a,e);Jp(i,S);break e}}i=i.return}while(i!==null)}uw(n)}catch(I){e=I,Ne===n&&n!==null&&(Ne=n=n.return);continue}break}while(!0)}function aw(){var t=qa.current;return qa.current=Ha,t===null?Ha:t}function Ah(){($e===0||$e===3||$e===2)&&($e=4),Be===null||!(jr&268435455)&&!(kl&268435455)||Wn(Be,He)}function Qa(t,e){var n=ue;ue|=2;var r=aw();(Be!==t||He!==e)&&(Tn=null,Ar(t,e));do try{Lk();break}catch(s){ow(t,s)}while(!0);if(hh(),ue=n,qa.current=r,Ne!==null)throw Error(F(261));return Be=null,He=0,$e}function Lk(){for(;Ne!==null;)lw(Ne)}function jk(){for(;Ne!==null&&!lT();)lw(Ne)}function lw(t){var e=dw(t.alternate,t,yt);t.memoizedProps=t.pendingProps,e===null?uw(t):Ne=e,kh.current=null}function uw(t){var e=t;do{var n=e.alternate;if(t=e.return,e.flags&32768){if(n=Ak(n,e),n!==null){n.flags&=32767,Ne=n;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{$e=6,Ne=null;return}}else if(n=Rk(n,e,yt),n!==null){Ne=n;return}if(e=e.sibling,e!==null){Ne=e;return}Ne=e=t}while(e!==null);$e===0&&($e=5)}function wr(t,e,n){var r=fe,s=$t.transition;try{$t.transition=null,fe=1,$k(t,e,n,r)}finally{$t.transition=s,fe=r}return null}function $k(t,e,n,r){do bs();while(Kn!==null);if(ue&6)throw Error(F(327));n=t.finishedWork;var s=t.finishedLanes;if(n===null)return null;if(t.finishedWork=null,t.finishedLanes=0,n===t.current)throw Error(F(177));t.callbackNode=null,t.callbackPriority=0;var i=n.lanes|n.childLanes;if(vT(t,i),t===Be&&(Ne=Be=null,He=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Ho||(Ho=!0,hw(Ra,function(){return bs(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=$t.transition,$t.transition=null;var o=fe;fe=1;var a=ue;ue|=4,kh.current=null,Mk(t,n),rw(n,t),sk(Dc),Pa=!!Mc,Dc=Mc=null,t.current=n,Dk(n),uT(),ue=a,fe=o,$t.transition=i}else t.current=n;if(Ho&&(Ho=!1,Kn=t,Wa=s),i=t.pendingLanes,i===0&&(tr=null),hT(n.stateNode),dt(t,Me()),e!==null)for(r=t.onRecoverableError,n=0;n<e.length;n++)s=e[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(Ga)throw Ga=!1,t=Zc,Zc=null,t;return Wa&1&&t.tag!==0&&bs(),i=t.pendingLanes,i&1?t===ed?Ti++:(Ti=0,ed=t):Ti=0,dr(),null}function bs(){if(Kn!==null){var t=Vv(Wa),e=$t.transition,n=fe;try{if($t.transition=null,fe=16>t?16:t,Kn===null)var r=!1;else{if(t=Kn,Kn=null,Wa=0,ue&6)throw Error(F(331));var s=ue;for(ue|=4,Q=t.current;Q!==null;){var i=Q,o=i.child;if(Q.flags&16){var a=i.deletions;if(a!==null){for(var l=0;l<a.length;l++){var u=a[l];for(Q=u;Q!==null;){var c=Q;switch(c.tag){case 0:case 11:case 15:Si(8,c,i)}var d=c.child;if(d!==null)d.return=c,Q=d;else for(;Q!==null;){c=Q;var h=c.sibling,f=c.return;if(ew(c),c===u){Q=null;break}if(h!==null){h.return=f,Q=h;break}Q=f}}}var p=i.alternate;if(p!==null){var g=p.child;if(g!==null){p.child=null;do{var _=g.sibling;g.sibling=null,g=_}while(g!==null)}}Q=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,Q=o;else e:for(;Q!==null;){if(i=Q,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Si(9,i,i.return)}var m=i.sibling;if(m!==null){m.return=i.return,Q=m;break e}Q=i.return}}var y=t.current;for(Q=y;Q!==null;){o=Q;var v=o.child;if(o.subtreeFlags&2064&&v!==null)v.return=o,Q=v;else e:for(o=y;Q!==null;){if(a=Q,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:Tl(9,a)}}catch(I){Pe(a,a.return,I)}if(a===o){Q=null;break e}var S=a.sibling;if(S!==null){S.return=a.return,Q=S;break e}Q=a.return}}if(ue=s,dr(),vn&&typeof vn.onPostCommitFiberRoot=="function")try{vn.onPostCommitFiberRoot(gl,t)}catch{}r=!0}return r}finally{fe=n,$t.transition=e}}return!1}function vm(t,e,n){e=Ms(n,e),e=V_(t,e,1),t=er(t,e,1),e=nt(),t!==null&&(vo(t,1,e),dt(t,e))}function Pe(t,e,n){if(t.tag===3)vm(t,t,n);else for(;e!==null;){if(e.tag===3){vm(e,t,n);break}else if(e.tag===1){var r=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(tr===null||!tr.has(r))){t=Ms(n,t),t=H_(e,t,1),e=er(e,t,1),t=nt(),e!==null&&(vo(e,1,t),dt(e,t));break}}e=e.return}}function zk(t,e,n){var r=t.pingCache;r!==null&&r.delete(e),e=nt(),t.pingedLanes|=t.suspendedLanes&n,Be===t&&(He&n)===n&&($e===4||$e===3&&(He&130023424)===He&&500>Me()-Ih?Ar(t,0):Ch|=n),dt(t,e)}function cw(t,e){e===0&&(t.mode&1?(e=Oo,Oo<<=1,!(Oo&130023424)&&(Oo=4194304)):e=1);var n=nt();t=On(t,e),t!==null&&(vo(t,e,n),dt(t,n))}function Fk(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),cw(t,n)}function Bk(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,s=t.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(F(314))}r!==null&&r.delete(e),cw(t,n)}var dw;dw=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||ut.current)lt=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return lt=!1,Ek(t,e,n);lt=!!(t.flags&131072)}else lt=!1,be&&e.flags&1048576&&m_(e,$a,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;ma(t,e),t=e.pendingProps;var s=Es(e,Ye.current);Ss(e,n),s=wh(null,e,r,t,s,n);var i=xh();return e.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,ct(r)?(i=!0,La(e)):i=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,mh(e),s.updater=bl,e.stateNode=s,s._reactInternals=e,Uc(e,r,t,n),e=qc(null,e,r,!0,i,n)):(e.tag=0,be&&i&&lh(e),Ze(null,e,s,n),e=e.child),e;case 16:r=e.elementType;e:{switch(ma(t,e),t=e.pendingProps,s=r._init,r=s(r._payload),e.type=r,s=e.tag=Vk(r),t=Gt(r,t),s){case 0:e=Hc(null,e,r,t,n);break e;case 1:e=lm(null,e,r,t,n);break e;case 11:e=om(null,e,r,t,n);break e;case 14:e=am(null,e,r,Gt(r.type,t),n);break e}throw Error(F(306,r,""))}return e;case 0:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:Gt(r,s),Hc(t,e,r,s,n);case 1:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:Gt(r,s),lm(t,e,r,s,n);case 3:e:{if(Q_(e),t===null)throw Error(F(387));r=e.pendingProps,i=e.memoizedState,s=i.element,x_(t,e),Ba(e,r,null,n);var o=e.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=i,e.memoizedState=i,e.flags&256){s=Ms(Error(F(423)),e),e=um(t,e,r,n,s);break e}else if(r!==s){s=Ms(Error(F(424)),e),e=um(t,e,r,n,s);break e}else for(vt=Zn(e.stateNode.containerInfo.firstChild),St=e,be=!0,Qt=null,n=__(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Rs(),r===s){e=Nn(t,e,n);break e}Ze(t,e,r,n)}e=e.child}return e;case 5:return S_(e),t===null&&zc(e),r=e.type,s=e.pendingProps,i=t!==null?t.memoizedProps:null,o=s.children,Oc(r,s)?o=null:i!==null&&Oc(r,i)&&(e.flags|=32),W_(t,e),Ze(t,e,o,n),e.child;case 6:return t===null&&zc(e),null;case 13:return K_(t,e,n);case 4:return gh(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=As(e,null,r,n):Ze(t,e,r,n),e.child;case 11:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:Gt(r,s),om(t,e,r,s,n);case 7:return Ze(t,e,e.pendingProps,n),e.child;case 8:return Ze(t,e,e.pendingProps.children,n),e.child;case 12:return Ze(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,s=e.pendingProps,i=e.memoizedProps,o=s.value,ve(za,r._currentValue),r._currentValue=o,i!==null)if(on(i.value,o)){if(i.children===s.children&&!ut.current){e=Nn(t,e,n);break e}}else for(i=e.child,i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){o=i.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(i.tag===1){l=Pn(-1,n&-n),l.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?l.next=l:(l.next=c.next,c.next=l),u.pending=l}}i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),Fc(i.return,n,e),a.lanes|=n;break}l=l.next}}else if(i.tag===10)o=i.type===e.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(F(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),Fc(o,n,e),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===e){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}Ze(t,e,s.children,n),e=e.child}return e;case 9:return s=e.type,r=e.pendingProps.children,Ss(e,n),s=zt(s),r=r(s),e.flags|=1,Ze(t,e,r,n),e.child;case 14:return r=e.type,s=Gt(r,e.pendingProps),s=Gt(r.type,s),am(t,e,r,s,n);case 15:return q_(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:Gt(r,s),ma(t,e),e.tag=1,ct(r)?(t=!0,La(e)):t=!1,Ss(e,n),U_(e,r,s),Uc(e,r,s,n),qc(null,e,r,!0,t,n);case 19:return Y_(t,e,n);case 22:return G_(t,e,n)}throw Error(F(156,e.tag))};function hw(t,e){return zv(t,e)}function Uk(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Lt(t,e,n,r){return new Uk(t,e,n,r)}function Ph(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Vk(t){if(typeof t=="function")return Ph(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Yd)return 11;if(t===Jd)return 14}return 2}function rr(t,e){var n=t.alternate;return n===null?(n=Lt(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function va(t,e,n,r,s,i){var o=2;if(r=t,typeof t=="function")Ph(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case as:return Pr(n.children,s,i,e);case Kd:o=8,s|=8;break;case hc:return t=Lt(12,n,e,s|2),t.elementType=hc,t.lanes=i,t;case fc:return t=Lt(13,n,e,s),t.elementType=fc,t.lanes=i,t;case pc:return t=Lt(19,n,e,s),t.elementType=pc,t.lanes=i,t;case Sv:return Cl(n,s,i,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case wv:o=10;break e;case xv:o=9;break e;case Yd:o=11;break e;case Jd:o=14;break e;case Vn:o=16,r=null;break e}throw Error(F(130,t==null?t:typeof t,""))}return e=Lt(o,n,e,s),e.elementType=t,e.type=r,e.lanes=i,e}function Pr(t,e,n,r){return t=Lt(7,t,r,e),t.lanes=n,t}function Cl(t,e,n,r){return t=Lt(22,t,r,e),t.elementType=Sv,t.lanes=n,t.stateNode={isHidden:!1},t}function xu(t,e,n){return t=Lt(6,t,null,e),t.lanes=n,t}function Su(t,e,n){return e=Lt(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function Hk(t,e,n,r,s){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=nu(0),this.expirationTimes=nu(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=nu(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Mh(t,e,n,r,s,i,o,a,l){return t=new Hk(t,e,n,a,l),e===1?(e=1,i===!0&&(e|=8)):e=0,i=Lt(3,null,null,e),t.current=i,i.stateNode=t,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},mh(i),t}function qk(t,e,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:os,key:r==null?null:""+r,children:t,containerInfo:e,implementation:n}}function fw(t){if(!t)return or;t=t._reactInternals;e:{if(Gr(t)!==t||t.tag!==1)throw Error(F(170));var e=t;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if(ct(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(F(171))}if(t.tag===1){var n=t.type;if(ct(n))return f_(t,n,e)}return e}function pw(t,e,n,r,s,i,o,a,l){return t=Mh(n,r,!0,t,s,i,o,a,l),t.context=fw(null),n=t.current,r=nt(),s=nr(n),i=Pn(r,s),i.callback=e??null,er(n,i,s),t.current.lanes=s,vo(t,s,r),dt(t,r),t}function Il(t,e,n,r){var s=e.current,i=nt(),o=nr(s);return n=fw(n),e.context===null?e.context=n:e.pendingContext=n,e=Pn(i,o),e.payload={element:t},r=r===void 0?null:r,r!==null&&(e.callback=r),t=er(s,e,o),t!==null&&(tn(t,s,o,i),ha(t,s,o)),o}function Ka(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function _m(t,e){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var n=t.retryLane;t.retryLane=n!==0&&n<e?n:e}}function Dh(t,e){_m(t,e),(t=t.alternate)&&_m(t,e)}function Gk(){return null}var mw=typeof reportError=="function"?reportError:function(t){console.error(t)};function Oh(t){this._internalRoot=t}El.prototype.render=Oh.prototype.render=function(t){var e=this._internalRoot;if(e===null)throw Error(F(409));Il(t,e,null,null)};El.prototype.unmount=Oh.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var e=t.containerInfo;$r(function(){Il(null,t,null,null)}),e[Dn]=null}};function El(t){this._internalRoot=t}El.prototype.unstable_scheduleHydration=function(t){if(t){var e=Gv();t={blockedOn:null,target:t,priority:e};for(var n=0;n<Gn.length&&e!==0&&e<Gn[n].priority;n++);Gn.splice(n,0,t),n===0&&Qv(t)}};function Nh(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Rl(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function wm(){}function Wk(t,e,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var u=Ka(o);i.call(u)}}var o=pw(e,r,t,0,null,!1,!1,"",wm);return t._reactRootContainer=o,t[Dn]=o.current,Bi(t.nodeType===8?t.parentNode:t),$r(),o}for(;s=t.lastChild;)t.removeChild(s);if(typeof r=="function"){var a=r;r=function(){var u=Ka(l);a.call(u)}}var l=Mh(t,0,!1,null,null,!1,!1,"",wm);return t._reactRootContainer=l,t[Dn]=l.current,Bi(t.nodeType===8?t.parentNode:t),$r(function(){Il(e,l,n,r)}),l}function Al(t,e,n,r,s){var i=n._reactRootContainer;if(i){var o=i;if(typeof s=="function"){var a=s;s=function(){var l=Ka(o);a.call(l)}}Il(e,o,t,s)}else o=Wk(n,e,t,s,r);return Ka(o)}Hv=function(t){switch(t.tag){case 3:var e=t.stateNode;if(e.current.memoizedState.isDehydrated){var n=hi(e.pendingLanes);n!==0&&(eh(e,n|1),dt(e,Me()),!(ue&6)&&(Ds=Me()+500,dr()))}break;case 13:$r(function(){var r=On(t,1);if(r!==null){var s=nt();tn(r,t,1,s)}}),Dh(t,1)}};th=function(t){if(t.tag===13){var e=On(t,134217728);if(e!==null){var n=nt();tn(e,t,134217728,n)}Dh(t,134217728)}};qv=function(t){if(t.tag===13){var e=nr(t),n=On(t,e);if(n!==null){var r=nt();tn(n,t,e,r)}Dh(t,e)}};Gv=function(){return fe};Wv=function(t,e){var n=fe;try{return fe=t,e()}finally{fe=n}};Tc=function(t,e,n){switch(e){case"input":if(yc(t,n),e=n.name,n.type==="radio"&&e!=null){for(n=t;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+e)+'][type="radio"]'),e=0;e<n.length;e++){var r=n[e];if(r!==t&&r.form===t.form){var s=wl(r);if(!s)throw Error(F(90));Tv(r),yc(r,s)}}}break;case"textarea":Cv(t,n);break;case"select":e=n.value,e!=null&&vs(t,!!n.multiple,e,!1)}};Dv=Eh;Ov=$r;var Qk={usingClientEntryPoint:!1,Events:[wo,ds,wl,Pv,Mv,Eh]},si={findFiberByHostInstance:kr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Kk={bundleType:si.bundleType,version:si.version,rendererPackageName:si.rendererPackageName,rendererConfig:si.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:jn.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=jv(t),t===null?null:t.stateNode},findFiberByHostInstance:si.findFiberByHostInstance||Gk,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var qo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!qo.isDisabled&&qo.supportsFiber)try{gl=qo.inject(Kk),vn=qo}catch{}}It.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Qk;It.createPortal=function(t,e){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Nh(e))throw Error(F(200));return qk(t,e,null,n)};It.createRoot=function(t,e){if(!Nh(t))throw Error(F(299));var n=!1,r="",s=mw;return e!=null&&(e.unstable_strictMode===!0&&(n=!0),e.identifierPrefix!==void 0&&(r=e.identifierPrefix),e.onRecoverableError!==void 0&&(s=e.onRecoverableError)),e=Mh(t,1,!1,null,null,n,!1,r,s),t[Dn]=e.current,Bi(t.nodeType===8?t.parentNode:t),new Oh(e)};It.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var e=t._reactInternals;if(e===void 0)throw typeof t.render=="function"?Error(F(188)):(t=Object.keys(t).join(","),Error(F(268,t)));return t=jv(e),t=t===null?null:t.stateNode,t};It.flushSync=function(t){return $r(t)};It.hydrate=function(t,e,n){if(!Rl(e))throw Error(F(200));return Al(null,t,e,!0,n)};It.hydrateRoot=function(t,e,n){if(!Nh(t))throw Error(F(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",o=mw;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),e=pw(e,null,t,1,n??null,s,!1,i,o),t[Dn]=e.current,Bi(t),r)for(t=0;t<r.length;t++)n=r[t],s=n._getVersion,s=s(n._source),e.mutableSourceEagerHydrationData==null?e.mutableSourceEagerHydrationData=[n,s]:e.mutableSourceEagerHydrationData.push(n,s);return new El(e)};It.render=function(t,e,n){if(!Rl(e))throw Error(F(200));return Al(null,t,e,!1,n)};It.unmountComponentAtNode=function(t){if(!Rl(t))throw Error(F(40));return t._reactRootContainer?($r(function(){Al(null,null,t,!1,function(){t._reactRootContainer=null,t[Dn]=null})}),!0):!1};It.unstable_batchedUpdates=Eh;It.unstable_renderSubtreeIntoContainer=function(t,e,n,r){if(!Rl(n))throw Error(F(200));if(t==null||t._reactInternals===void 0)throw Error(F(38));return Al(t,e,n,!1,r)};It.version="18.3.1-next-f1338f8080-20240426";function gw(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(gw)}catch(t){console.error(t)}}gw(),gv.exports=It;var yw=gv.exports,vw,xm=yw;vw=xm.createRoot,xm.hydrateRoot;let Ts=null;function Yk(t,e){t.currentIndex=0,t.wipContextDeps=null,t.wipCommitCallbacks=[];const n=Ts;Ts=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{Ts=n}}function wn(){if(!Ts)throw new Error("No resource fiber available");return Ts}function zs(){return Ts}const Jk=t=>({version:0,committedVersion:0,dispatchUpdate:t,changelog:[],committedLog:[],unsettledCount:0,rollbackCallbacks:[]}),_w=t=>{t.committedVersion=t.version;for(const e of t.changelog)e.logged=!1,e.settled||(e.settled=!0,t.unsettledCount--),t.committedLog.push(e);t.changelog.length=0,t.unsettledCount===0&&(t.committedLog.length=0),t.rollbackCallbacks.length=0},Sm=(t,e)=>{const n=t.version>e;if(t.version=e,n){for(let r=0;r<t.rollbackCallbacks.length;r++)t.rollbackCallbacks[r]();if(t.rollbackCallbacks.length=0,e<=t.committedVersion){const r=[];for(;t.committedVersion-r.length>e;){const s=t.committedLog.pop();if(s===void 0)break;Lh(s.fiber,s.cell),s.cell.workInProgress=s.prevState,r.push({record:s,prevState:s.prevState,eagerState:s.eagerState,hasEagerState:s.hasEagerState})}if(r.length>0){const s=t.committedVersion;Ml(t,()=>{for(let i=r.length-1;i>=0;i--){const o=r[i];o.record.prevState=o.prevState,o.record.eagerState=o.eagerState,o.record.hasEagerState=o.hasEagerState,t.committedLog.push(o.record)}t.committedVersion=s})}t.committedVersion=e;for(const s of t.changelog)s.logged=!1;t.changelog.length=0}else{for(;t.committedVersion+t.changelog.length>e;)t.changelog.pop().logged=!1;for(let r=0;r<t.changelog.length;r++)ww(t.changelog[r]);_w(t)}}},ww=t=>{var e;Lh(t.fiber,t.cell),t.queued||(t.queued=!0,((e=t.cell).queue??(e.queue=[])).push(t))},Pl=(t,e)=>{t.wipCommitCallbacks.push(e)},Ml=(t,e)=>{t.rollbackCallbacks.push(e)},Lh=(t,e)=>{var n;e.isDirty||(e.isDirty=!0,(n=t.markDirty)==null||n.call(t),Ml(t.root,()=>{if(e.queue!==null){for(const r of e.queue)r.queued=!1;e.queue=null}e.workInProgress=e.current,e.isDirty=!1}))},xw=Symbol.for("react.memo_cache_sentinel"),Sw=t=>new Array(t).fill(xw),Xk=(t,e)=>{const n=t.memoCache;let r=n.workInProgress;if(r===null){const o=n.current;r=o===null?[]:o.map(a=>a.slice()),n.workInProgress=r,Ml(t.root,()=>{n.workInProgress=null})}const s=n.index++;let i=r[s];return i===void 0&&(i=Sw(e),r[s]=i),i},bw=t=>Xk(wn(),t),Zk=Nt,eC=t=>ee.useMemo(()=>{const e=Sw(t);return e[xw]=!0,e},[]);var Ky;const tC=((Ky=Zk.__COMPILER_RUNTIME)==null?void 0:Ky.c)??eC,nC=()=>zs()!==null,O=t=>nC()?bw(t):tC(t),Te=(t,...e)=>Object.assign(Object.create(null),t,...e),jh=()=>{throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.")},$h=()=>{throw new Error("Hook order changed between renders")},rC=()=>({type:"effect",setup:void 0,setupDeps:void 0,cleanup:void 0,deps:null,generation:0});function nn(t,e){const n=wn(),r=n.currentIndex++,s=n.cells[r],i=s===void 0?rC():s.type==="effect"?s:$h();if(s===void 0&&(n.isFirstRender||jh(),n.cells[r]=i,n.effectCells.push(i)),i.deps!==null&&!!e!=!!i.deps)throw new Error("useEffect called with and without dependencies across re-renders");Pl(n,()=>{i.setup=t,i.setupDeps=e,i.generation++})}const Dl=(t,e)=>{for(let n=0;n<t.length&&n<e.length;n++)if(!Object.is(t[n],e[n]))return!1;return!0},bm=(t,e)=>{Pl(t,()=>{e.current=e.wip,e.currentDeps=e.wipDeps,e.isDirty=!1})},Ol=(t,e)=>{const n=wn(),r=n.currentIndex++;let s=n.cells[r];if(s===void 0){n.isFirstRender||jh();const a=t();return s={type:"memo",current:a,currentDeps:e,wip:a,wipDeps:e,isDirty:!1},n.cells[r]=s,a}s.type!=="memo"&&$h();const i=s;if(Dl(i.wipDeps,e))return i.isDirty&&bm(n,i),i.wip;const o=t();return i.wip=o,i.wipDeps=e,i.isDirty||(i.isDirty=!0,Ml(n.root,()=>{i.wip=i.current,i.wipDeps=i.currentDeps,i.isDirty=!1})),bm(n,i),o};function Fs(t){return Ol(()=>({current:t}),[])}const zh=Symbol("tap.Context.defaultValue"),sC=t=>t;let ss=new Map;const br=new Set,Tw=(t,e)=>{t[zh]=e},kw=t=>typeof t=="object"&&t!==null&&zh in t,Cw=t=>typeof t=="object"&&t!==null&&"$$typeof"in t&&t.$$typeof===Symbol.for("react.context"),Iw=t=>kw(t)||Cw(t),Ew=t=>{if(!kw(t)){if(Cw(t)){Tw(t,t._currentValue??t._currentValue2);return}throw new Error("A tap resource's `use()` only accepts a tap context.")}},So=(t,e,n)=>{if(typeof t!="object"||t===null)throw new Error("useContextProvider only accepts a React context.");Ew(t);const r=t,s=wn(),i=Fs(void 0),o=i.current===void 0||!Object.is(i.current.value,e);nn(()=>{i.current={value:e}},[e]);const a=ss.get(r),l=a!==void 0||ss.has(r);ss.set(r,{value:e,source:s});try{return iC(r,o,n)}finally{l?ss.set(r,a):ss.delete(r)}},iC=(t,e,n)=>{const r=br.has(t);e?br.add(t):br.delete(t);try{return n()}finally{r?br.add(t):br.delete(t)}},Rw=t=>{Ew(t);const e=t,n=oC(e,t),r=wn();return(r.wipContextDeps??(r.wipContextDeps=new Map)).set(e,n.source),n.value},oC=(t,e)=>ss.get(t)??{value:sC(e)[zh],source:null},aC=(t,e,n,r)=>{if(!r)return n;let s=n;for(const[i,o]of r)o===e||o===t||(s??(s=new Map)).set(i,o);return s},Aw=(t,e=t.wipContextDeps)=>{const n=zs();!n||!e||(n.wipContextDeps=aC(n,t,n.wipContextDeps,e))},Pw=()=>br.size>0,Fh=t=>{if(!t.contextDeps||!Pw())return!1;for(const e of br.keys())if(t.contextDeps.has(e))return!0;return!1},lC=(t,e,n)=>{if(t.isNeverMounted)throw new Error("Resource updated before mount");let r=!1,s=!0;t.root.unsettledCount++,t.root.dispatchUpdate(()=>(r||(r=!0,n&&t.root.changelog.length===0&&!e.cell.isDirty&&!e.hasEagerState&&(e.prevState=e.cell.workInProgress,e.eagerState=n(e.cell.workInProgress,e.action),e.hasEagerState=!0,s=!Object.is(e.cell.current,e.eagerState),!s&&!e.settled&&(e.settled=!0,t.root.unsettledCount--))),s),()=>(r=!0,s=!0,ww(e),e.logged||(e.logged=!0,t.root.changelog.push(e)),!0))},uC=(t,e,n,r,s)=>{const i=r?r(n):n,o={type:"reducer",workInProgress:i,current:i,isDirty:!1,queue:null,renderQueue:null,reducer:e,dispatch:a=>{const l=zs();if(l!==null){if(l!==t)throw new Error("Cannot update a resource while rendering a different resource.");(t.renderPendingCells??(t.renderPendingCells=new Set)).add(o),(o.renderQueue??(o.renderQueue=[])).push(a)}else{const u={fiber:t,cell:o,action:a,hasEagerState:!1,eagerState:void 0,prevState:o.current,settled:!1,queued:!1,logged:!1};lC(t,u,s?e:void 0)}}};return o};function Mw(t,e,n,r){var u;const s=wn(),i=s.currentIndex++,o=s.cells[i],a=(()=>{if(o!==void 0)return o.type==="reducer"?o:$h();s.isFirstRender||jh();const c=uC(s,t,e,n,r);return s.cells[i]=c,c})(),l=a.queue;if(l!==null){const c=t===a.reducer;for(let d=0;d<l.length;d++){const h=l[d];(!h.hasEagerState||!c||!Object.is(h.prevState,a.workInProgress))&&(h.prevState=a.workInProgress,h.eagerState=t(a.workInProgress,h.action),h.hasEagerState=!0),h.queued=!1,a.workInProgress=h.eagerState}a.queue=null}if(a.reducer=t,a.renderQueue!==null){let c=a.workInProgress;for(const d of a.renderQueue)c=t(c,d);a.renderQueue=null,(u=s.renderPendingCells)==null||u.delete(a),Object.is(c,a.workInProgress)||(Lh(s,a),a.workInProgress=c)}return a.isDirty&&Pl(s,()=>{a.current=a.workInProgress,a.isDirty=!1}),[a.workInProgress,a.dispatch]}function Bh(t,e,n){return Mw(t,e,n,!1)}const cC=(t,e)=>typeof e=="function"?e(t):e,dC=t=>t===void 0?void 0:typeof t=="function"?t():t;function Dw(t){return Mw(cC,t,dC,!0)}const Uh=(t,e)=>Ol(()=>t,e);function Vh(t){const e=wn(),n=Fs(t);return n.current!==t&&Pl(e,()=>{n.current=t}),Uh((...r)=>n.current(...r),[])}const hC=t=>t!==null&&typeof t=="object"&&typeof t.then=="function",Tm=()=>{},fC=t=>{const e=t;switch(typeof e.status!="string"?(e.status="pending",t.then(n=>{e.status==="pending"&&(e.status="fulfilled",e.value=n)},n=>{e.status==="pending"&&(e.status="rejected",e.reason=n)})):e.status!=="fulfilled"&&e.status!=="rejected"&&t.then(Tm,Tm),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw t}},Hh=t=>hC(t)?fC(t):Rw(t),Ow=(t,e,n=e)=>{const s=wn().isNeverMounted?n():e(),[,i]=Bh(l=>l+1,0),o=Fs(0),a=Vh(()=>{try{if(Object.is(s,e()))return o.current=0,!1}catch{}return!0});return nn(()=>t(()=>{a()&&i()}),[t]),nn(()=>{if(a()){if(++o.current>50)throw o.current=0,new Error("Maximum update depth exceeded. The result of getSnapshot should be cached to avoid an infinite loop.");i()}},[t,s,e]),s},Nw=(t,e)=>{};let pC=0;const Lw=()=>{const t=Fs(null);return t.current??(t.current=`:tap${pC++}:`),t.current},jw=(t,e,n)=>{const r=()=>{if(!t)return;const s=e();if(typeof t=="function"){const i=t(s);return typeof i=="function"?i:()=>t(null)}return t.current=s,()=>{t.current=null}};n==null?nn(r):nn(r,[...n,t])},mC=Nt;function gC(t){const e=ee.useRef(t);return ee.useInsertionEffect(()=>{e.current=t}),ee.useCallback((...n)=>e.current(...n),[])}const yC=mC.useEffectEvent??gC,it=()=>zs()!==null,Ee=Nt,ce=t=>it()?Dw(t):Ee.useState(t),vC=(t,e,n)=>it()?Bh(t,e,n):Ee.useReducer(t,e,n),te=t=>it()?Fs(t):Ee.useRef(t),ge=(t,e)=>it()?Ol(t,e):Ee.useMemo(t,e),_t=(t,e)=>it()?Uh(t,e):Ee.useCallback(t,e),J=(t,e)=>it()?nn(t,e):Ee.useEffect(t,e),rn=(t,e)=>it()?nn(t,e):Ee.useLayoutEffect(t,e),ht=t=>it()?Vh(t):yC(t),Wr=(t,e,n)=>it()?Ow(t,e,n):Ee.useSyncExternalStore(t,e,n),_C=(t,e)=>it()?Nw():Ee.useDebugValue(t,e),Qr=(t,e)=>it()?nn(t,e):Ee.useInsertionEffect(t,e),$w=()=>it()?Lw():Ee.useId(),wC=(t,e,n)=>it()?jw(t,e,n):Ee.useImperativeHandle(t,e,n),Re=t=>Ee.forwardRef(t),Ue=(t,e)=>Ee.memo(t,e),zw=Ee.Fragment,xC=(...t)=>Ee.createElement(...t),SC=(...t)=>Ee.cloneElement(...t),Nl=t=>Ee.isValidElement(t);Ee.Children;Ee.Suspense;const Rt=t=>{const e=Ee.createContext(t);return Tw(e,t),e},qh=t=>it()&&Iw(t)?Hh(t):Ee.use(t),At=t=>it()&&Iw(t)?Hh(t):Ee.useContext(t);function de(t){return(...e)=>({hook:t,args:e})}function kt(t,e,n){return typeof e=="function"?(...r)=>kt(t,e(...r)):n?{...e,key:t,deps:n}:{...e,key:t}}const Ll=(t,e)=>{if(t.length!==0){if(t.length===1)throw t[0];for(const n of t)console.error(n);throw new AggregateError(t,e)}};let Kt={schedulers:new Set,isScheduled:!1},pi=null;const km=[],bC=()=>{Kt.isScheduled||(Kt.isScheduled=!0,TC())},rd=()=>{const t=pi;pi=new Map;const e=[];try{for(const n of Kt.schedulers)if(Kt.schedulers.delete(n),!!n.isDirty)try{n.runTask()}catch(r){e.push(r)}}finally{if(pi=t,Kt.schedulers.clear(),Kt.isScheduled=!1,pi===null)for(;km.length>0;)try{km.shift()()}catch(n){e.push(n)}}Ll(e,"Errors occurred during flushSync")},TC=(()=>{if(typeof MessageChannel<"u"){let t=null,e;return()=>{var n;if(!t){const r=new MessageChannel;r.port1.onmessage=()=>{var s;(s=t==null?void 0:t.unref)==null||s.call(t),rd()},t=r.port1,e=r.port2}(n=t.ref)==null||n.call(t),e.postMessage(null)}}return()=>setTimeout(rd,0)})(),Cm=t=>{if(pi!==null)return t();const e=Kt;Kt={schedulers:new Set,isScheduled:!0};try{const n=t();return rd(),n}finally{const n=Kt.schedulers;if(Kt=e,n.size>0){for(const r of n)Kt.schedulers.add(r);bC()}}};function kC(t){const e=[];for(let n=0;n<t.length;n++)try{t[n]()}catch(r){e.push(r)}Ll(e,"Errors during commit")}function CC(t){const e=t.setup,n=t.setupDeps,r=t.generation;let s;try{const i=e();if(i!==void 0&&typeof i!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof i}`);s=i}finally{t.generation===r?(t.cleanup=s,t.deps=n):s==null||s()}}const IC=t=>t.setup===void 0?!1:t.deps===null||t.setupDeps===void 0?!0:!Dl(t.deps,t.setupDeps);function EC(t){const e=[],n=[];for(const r of t.effectCells)IC(r)&&n.push(r);for(const r of n)if(r.deps=null,r.cleanup!==void 0)try{r.cleanup()}catch(s){e.push(s)}finally{r.cleanup=void 0}for(const r of n)try{CC(r)}catch(s){e.push(s)}Ll(e,"Errors during commit")}function RC(t){var n;const e=[];for(const r of t.effectCells)if(r.deps=null,r.cleanup)try{(n=r.cleanup)==null||n.call(r)}catch(s){e.push(s)}finally{r.cleanup=void 0}Ll(e,"Errors during cleanup")}const AC={useState:Dw,useReducer:Bh,useRef:Fs,useMemo:Ol,useCallback:Uh,useEffect:nn,useLayoutEffect:nn,useInsertionEffect:nn,useEffectEvent:Vh,useContext:Rw,use:Hh,useSyncExternalStore:Ow,useDebugValue:Nw,useId:Lw,useImperativeHandle:jw,useMemoCache:bw},Im=Nt,gr=Im.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??Im.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Go=gr==null?null:"H"in gr?{get current(){return gr.H},set current(t){gr.H=t}}:"ReactCurrentDispatcher"in gr?{get current(){return gr.ReactCurrentDispatcher.current},set current(t){gr.ReactCurrentDispatcher.current=t}}:null;function PC(t){if(!Go)return t();const e=Go.current;Go.current=AC;try{return t()}finally{Go.current=e}}function MC(t,e,n=void 0,r){return{hook:t,root:e,markDirty:n,devStrictMode:r,cells:[],effectCells:[],contextDeps:null,wipContextDeps:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function Fw(t){t.wipCommitCallbacks=null,t.wipContextDeps=null,t.memoCache.workInProgress=null}function ki(t){t.isMounted&&(t.isMounted=!1,RC(t))}function Ci(t,e){var s;if(t.renderPendingCells!==null){for(const i of t.renderPendingCells)i.renderQueue=null;t.renderPendingCells.clear()}let n=0,r;try{do{if(++n>25)throw new Error("Too many re-renders. tap limits the number of renders to prevent an infinite loop.");t.memoCache.index=0,Yk(t,()=>{r=PC(()=>t.hook(...e))})}while((((s=t.renderPendingCells)==null?void 0:s.size)??0)>0)}catch(i){throw Fw(t),i}return Aw(t),r}function Ya(t){const e=t.wipCommitCallbacks;t.wipCommitCallbacks=null,t.isMounted=!0,t.isNeverMounted=!1,e!==null&&(t.contextDeps=t.wipContextDeps,_w(t.root),t.memoCache.workInProgress!==null&&(t.memoCache.current=t.memoCache.workInProgress,t.memoCache.workInProgress=null),kC(e)),EC(t)}const DC=()=>{const t=wn();return t.devStrictMode?t.isFirstRender?"child":"root":null},OC=()=>null,NC=()=>OC,LC=()=>zs()?DC:NC(),jC=()=>{const t=te(0),e=t.current,n=wn();return{version:e,markDirty:ge(()=>()=>{var r;t.current++,(r=n.markDirty)==null||r.call(n)},[n]),root:n.root}},$C=()=>{const[t]=ce(()=>Jk((s,i)=>{let o=!1;r(a=>(o=!s(),o?a:a+1)),o||n(i)})),[e,n]=vC((s,i)=>(Sm(t,s),s+(i()?1:0)),0),[,r]=ce(0);return Sm(t,e),{root:t,version:e,markDirty:void 0}},Gh=()=>{const t=LC(),{root:e,version:n,markDirty:r}=zs()?jC():$C();return{version:n,createFiber:_t((s,i,o)=>MC(s,e,o?()=>{o(),r==null||r()}:r,t()),[])}},Bw=(t,e,n)=>{const r=te(null),s=r.current??(r.current={wipDeps:null,wip:null,currentDeps:null,current:null});return s.wipDeps=s.currentDeps,s.wip=s.current,J(()=>{s.currentDeps=s.wipDeps,s.current=s.wip}),!n&&s.currentDeps&&Dl(s.currentDeps,e)?s.current:(s.wipDeps=e,s.wip=t(),s.wip)};function wt(t){const{version:e,createFiber:n}=Gh(),r=ge(()=>n(t.hook,t.key),[t.hook,t.key,n]),s=Bw(()=>({value:Ci(r,t.args)}),[r,e,t.args],Fh(r));return J(()=>()=>ki(r),[r]),J(()=>{Ya(r)},[r,s]),s.value}const Em=(t,e)=>{const n=t.get(e);n&&(n.isDirty=!0)},zC=(t,e)=>!t.isDirty&&!Fh(t.fiber)&&e!==void 0&&t.committedDeps!==void 0&&Dl(t.committedDeps,e),FC=t=>{if(!Pw())return!1;for(const{fiber:e}of t.values())if(Fh(e))return!0;return!1};function Yi(t){const[e]=ce(()=>new Map),{version:n,createFiber:r}=Gh(),s=FC(e),i=Bw(()=>{const o=new Set,a=[];let l=0;for(let u=0;u<t.length;u++){const c=t[u],d=c.key;if(d===void 0)throw new Error(`useResources did not provide a key for array at index ${u}`);if(o.has(d))throw new Error(`Duplicate key ${d} in useResources`);o.add(d);let h=e.get(d);if(h)if(h.fiber.hook!==c.hook){const f=r(c.hook,c.key,()=>Em(e,d)),p=Ci(f,c.args);h.next={value:p,deps:c.deps,remount:f}}else if(zC(h,c.deps))typeof h.next=="object"&&Fw(h.fiber),h.fiber.contextDeps&&Aw(h.fiber,h.fiber.contextDeps),h.next="skip";else{const f=Ci(h.fiber,c.args);h.next={value:f,deps:c.deps}}else{const f=r(c.hook,c.key,()=>Em(e,d));h={fiber:f,next:{value:Ci(f,c.args),deps:c.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},l++,e.set(d,h)}a.push(typeof h.next=="object"?h.next.value:h.committedValue)}if(e.size>a.length-l)for(const u of e.keys())o.has(u)||(e.get(u).next="delete");return a},[t,e,r,n],s);return J(()=>()=>{for(const o of e.keys())ki(e.get(o).fiber)},[e]),J(()=>{for(const[o,a]of e.entries()){const l=a.next;l==="delete"?(ki(a.fiber),e.delete(o)):l==="skip"?!a.fiber.isNeverMounted&&!a.fiber.isMounted&&Ya(a.fiber):(l.remount&&(ki(a.fiber),a.fiber=l.remount),Ya(a.fiber),a.committedDeps=l.deps,a.committedValue=l.value,a.isDirty=!1,a.next="skip")}},[i,e]),i}const BC=t=>t(),Uw=t=>{const{createFiber:e}=Gh(),n=ge(()=>e(BC,void 0),[e]),r=Ci(n,[t]);J(()=>()=>{ki(n)},[n]);let s=!1;const i=()=>{s&&n.isMounted||(s=!0,Ya(n))};return J(i),{value:r,effects:i}},UC=()=>{const t=O(4),[e,n]=ce(HC);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=(l,u)=>(n(c=>{const d=Te(c.renderers);return d[l]=[...d[l]??[],u],{...c,renderers:d}}),()=>{n(c=>{var f;const d=Te(c.renderers),h=((f=d[l])==null?void 0:f.filter(p=>p!==u))??[];return h.length>0?d[l]=h:delete d[l],{...c,renderers:d}})}),t[0]=r):r=t[0];const s=r;let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=l=>(n(u=>({...u,fallbacks:[...u.fallbacks,l]})),()=>{n(u=>({...u,fallbacks:u.fallbacks.filter(c=>c!==l)}))}),t[1]=i):i=t[1];const o=i;let a;return t[2]!==e?(a={getState:()=>e,setDataUI:s,setFallbackDataUI:o},t[2]=e,t[3]=a):a=t[3],a},VC=de(UC);function HC(){return{renderers:Te(),fallbacks:[]}}const bu=t=>{if(!t.overwrite)return t;const{overwrite:e,...n}=t;return n},qC=t=>{const e=Array.from(t).map(r=>r.getModelContext()).sort((r,s)=>(s.priority??0)-(r.priority??0)),n=Te();return e.reduce((r,s)=>{const i=s.priority??0;if(s.system&&(r.system?r.system+=`
41
+
42
+ ${s.system}`:r.system=s.system),s.tools)for(const[o,a]of Object.entries(s.tools)){const l=r.tools!==void 0&&Object.hasOwn(r.tools,o)?r.tools[o]:void 0;if(l&&l!==a){const u=n[o];if(u===i){if(!a.overwrite)throw new Error(`You tried to define a tool with the name ${o}, but it already exists.`);r.tools[o]=bu(a);continue}const c=u>i?l:a,d=u>i?a:l;r.tools[o]=bu({...d,...c}),n[o]=Math.max(u,i);continue}r.tools||(r.tools=Te()),r.tools[o]=bu(a),Object.hasOwn(n,o)||(n[o]=i)}return s.config&&(r.config={...r.config,...s.config}),s.callSettings&&(r.callSettings={...r.callSettings,...s.callSettings}),s.unstable_composerMetadata&&(r.unstable_composerMetadata={...r.unstable_composerMetadata,...s.unstable_composerMetadata}),r},{})},Yt=(t,e,n)=>{const r=s=>{console.error(`[assistant-ui] ${n} listener threw an error`,s)};for(const s of t)try{const i=s(typeof e=="function"?e():e);i!==null&&(typeof i=="object"||typeof i=="function")&&"then"in i&&typeof i.then=="function"&&Promise.resolve(i).catch(r)}catch(i){r(i)}},Ut=t=>t,GC=new Set(["$$typeof","nodeType","then","__v_raw","__v_isRef","__v_isReactive","__v_isReadonly","__v_isShallow","__v_skip"]),zr=(t,e)=>{if(t===Symbol.toStringTag)return e;if(typeof t!="symbol"){if(t==="toJSON")return()=>e;if(!GC.has(t))return!1}};var Ji=class{getOwnPropertyDescriptor(t,e){const n=this.get(t,e);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!0}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}};const Ja=Symbol("assistant-ui.store.clientId"),sd=Symbol("assistant-ui.store.instanceTag"),Vw=(t,e)=>{const n=new Proxy(()=>{},{apply:()=>(e(),n),get:(r,s)=>s==="source"?t.source:s==="query"?t.query:s==="name"?t.name:s===Ja?$l(e()):e()[s],has:(r,s)=>s==="source"||s==="query"||s==="name"||s===Ja||s in e(),ownKeys:()=>Reflect.ownKeys(e()),getOwnPropertyDescriptor:(r,s)=>{if(!(typeof s=="symbol"||!(s in e())))return{value:e()[s],writable:!1,enumerable:!0,configurable:!0}}});return n},Hw=(t,e)=>{const n=()=>{throw new Error(t)};return new Proxy(()=>{},{apply:n,get:(r,s)=>{if(s==="source"||s==="query")return null;if(s==="name")return e;if(s===Ja)return n();const i=zr(s,"AssistantClientAccessor");return i!==!1?i:n()},has:(r,s)=>s==="source"||s==="query"||s==="name",ownKeys:()=>[],getOwnPropertyDescriptor:()=>{}})},jl=t=>(t==null?void 0:t.source)!=null,id=t=>(t==null?void 0:t.source)===null,$l=t=>t[Ja]??t,WC=t=>t[sd]??$l(t),Er=t=>t==="optional"||t==="subscribe"||t==="on"||t==="__proto__"||typeof t=="symbol",od=t=>{const e=[];for(const n in t)Er(n)||e.push(n);return e};var Rr,Yy,QC=(Yy=class extends Ji{constructor(e){super();cn(this,Rr);dn(this,Rr,e)}get(e,n){const r=zr(n,"OptionalAssistantClient");if(r!==!1)return r;if(Er(n))return;const s=Pt(this,Rr)[n];return jl(s)?s:void 0}ownKeys(){return od(Pt(this,Rr))}has(e,n){return!Er(n)&&n in Pt(this,Rr)}},Rr=new WeakMap,Yy);const qw=t=>new Proxy({},new QC(t)),Rm=()=>()=>{},KC="You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.";var uo,co,ho,fl,Jy,YC=(Jy=class extends Ji{constructor(e,n,r){super();cn(this,uo);cn(this,co);cn(this,ho);cn(this,fl);dn(this,uo,e),dn(this,co,n),dn(this,ho,r)}get(e,n){if(n==="subscribe"||n==="on")return Rm;if(n==="optional")return Pt(this,fl)??dn(this,fl,qw(Pt(this,ho).call(this)));const r=zr(n,Pt(this,uo));return r!==!1?r:Hw(Pt(this,co).call(this,String(n)),String(n))}ownKeys(){return["subscribe","on","optional"]}getOwnPropertyDescriptor(e,n){if(n!=="optional")return super.getOwnPropertyDescriptor(e,n);const r=this.get(e,n);if(r!==void 0)return{value:r,writable:!1,enumerable:!1,configurable:!0}}has(e,n){return n==="subscribe"||n==="on"||n==="optional"}},uo=new WeakMap,co=new WeakMap,ho=new WeakMap,fl=new WeakMap,Jy);const JC=(t,e)=>{const n=new Proxy({},new YC(t,e,()=>n));return n},ks=JC("DefaultAssistantClient",()=>KC),XC=()=>new Proxy({},{get(t,e){const n=zr(e,"AssistantClient");return n!==!1?n:Hw(`The current scope does not have a "${String(e)}" property.`,String(e))}}),Wh=Rt(ks),ZC=()=>{},eI=new WeakMap,tI=t=>eI.get(t)??ZC,Qh=()=>At(Wh),Gw=(t,e)=>So(Wh,t,e),ad=Symbol("assistant-ui.transform-scopes");function Ww(t,e){const n=t;if(n[ad])throw new Error("transformScopes is already attached to this resource");n[ad]=e}function nI(t){return t[ad]}const Kh=t=>typeof t=="string"?{scope:t.split(".")[0],event:t}:{scope:t.scope,event:t.event},Am=t=>{console.error("NotificationManager: event listener error",t)},Pm=(t,e,n)=>{try{const r=t(e,n);r!==null&&(typeof r=="object"||typeof r=="function")&&typeof r.then=="function"&&Promise.resolve(r).catch(Am)}catch(r){Am(r)}},rI=()=>{const t=new Map,e=new Set,n=new Set;return{on(r,s){const i=s;if(r==="*")return e.add(i),()=>e.delete(i);let o=t.get(r);return o||(o=new Set,t.set(r,o)),o.add(i),()=>{o.delete(i),o.size===0&&t.get(r)===o&&t.delete(r)}},emit(r,s,i){!t.has(r)&&e.size===0||queueMicrotask(()=>{const o=t.get(r);if(o)for(const a of o)Pm(a,s,i);if(e.size>0){const a={event:r,payload:s};for(const l of e)Pm(l,a,i)}})},subscribe(r){return n.add(r),()=>n.delete(r)},notifySubscribers(){for(const r of n)try{r()}catch(s){console.error("NotificationManager: subscriber callback error",s)}}}},sI=()=>ce(rI)[0],ld=Symbol("assistant-ui.store.clientIndex"),iI=t=>t[ld],Qw=Rt([]),Yh=()=>qh(Qw),oI=(t,e)=>{const n=O(3),r=Yh();let s;return n[0]!==t||n[1]!==r?(s=[...r,t],n[0]=t,n[1]=r,n[2]=s):s=n[2],So(Qw,s,e)},Kw=Rt(null),Mm=Symbol("aui.scope-effect-unapplied"),aI=(t,e)=>So(Kw,t,e),Jh=()=>{const t=qh(Kw);if(!t)throw new Error("AssistantTapContext is not available");return t},Yw=()=>Jh().clientRef,Jw=(t,e,n)=>{const r=O(8),{clientRef:s}=Jh();let i;r[0]!==s||r[1]!==e||r[2]!==t?(i=()=>{const a=s.current;if(a===null)throw new Error("useAssistantScopeEffect ran before the client was committed. This is likely an internal bug in assistant-ui.");const l=()=>{var p;const f=(p=s.current)==null?void 0:p[t];return f!==void 0&&jl(f)?WC(f):void 0};let u=Mm,c;const d=f=>{if(c==null||c(),c=void 0,u=Mm,f!==void 0){const p=e();c=typeof p=="function"?p:void 0}u=f};d(l());const h=a.subscribe(()=>{const f=l();f!==u&&d(f)});return()=>{h(),c==null||c()}},r[0]=s,r[1]=e,r[2]=t,r[3]=i):i=r[3];let o;r[4]!==s||r[5]!==n||r[6]!==t?(o=[s,t,...n],r[4]=s,r[5]=n,r[6]=t,r[7]=o):o=r[7],J(i,o)},Bs=()=>{const t=O(3),{emit:e}=Jh(),n=Yh();let r;return t[0]!==n||t[1]!==e?(r=(s,i)=>{e(s,i,n)},t[0]=n,t[1]=e,t[2]=r):r=t[2],ht(r)},ud=Rt(void 0),Xw=(t,e)=>{const n=qh(ud);return So(ud,t??n,e)},lI=()=>{const t=O(3),[e]=ce(uI);let n,r;return t[0]!==e?(n=()=>()=>queueMicrotask(()=>e.abort()),r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),Qr(n,r),e.signal};function uI(){return new AbortController}const Xa=Symbol("assistant-ui.store.getValue"),Dm=t=>{var n;const e=t[Xa];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(n=e.getState)==null?void 0:n.call(e)},Om=new Map;function cI(t){let e=Om.get(t);return e||(e=function(...n){if(!this||typeof this!="object")throw new Error(`Method "${String(t)}" called without proper context. This may indicate the function was called incorrectly.`);const r=this[Xa];if(!r)throw new Error(`Method "${String(t)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);const s=r[t];if(!s)throw new Error(`Method "${String(t)}" is not implemented.`);if(typeof s!="function")throw new Error(`"${String(t)}" is not a function.`);return s(...n)},Om.set(t,e)),e}var dI=class extends Ji{constructor(e,n,r){super();w(this,"boundFns");w(this,"cachedReceiver");w(this,"outputRef");w(this,"tagRef");w(this,"index");this.outputRef=e,this.tagRef=n,this.index=r}get(e,n,r){if(n===Xa)return this.outputRef.current;if(n===ld)return this.index;if(n===sd)return this.tagRef.current;const s=zr(n,"ClientProxy");if(s!==!1)return s;const i=this.outputRef.current[n];if(typeof i=="function"){if(r===void 0)return i;(!this.boundFns||this.cachedReceiver!==r)&&(this.boundFns=new Map,this.cachedReceiver=r);let o=this.boundFns.get(n);return o||(o=cI(n).bind(r),this.boundFns.set(n,o)),o}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,n){return n===Xa||n===ld||n===sd?!0:n in this.outputRef.current}};const Xi=t=>{var a;const e=te(null),n=te(null),r=ge(()=>({}),[t.hook,t.key]),s=Yh().length,i=ge(()=>new Proxy({},new dI(e,n,s)),[s]),o=oI(i,function(){return wt(t)});return e.current||(e.current=o,n.current=r),J(()=>{e.current=o,n.current=r}),{methods:i,state:(a=o.getState)==null?void 0:a.call(o),key:t.key}},Zw=de(Xi),ar=(t,e)=>{if(Array.isArray(t)!==Array.isArray(e))return!1;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!Object.is(t[r],e[r]))return!1;return!0}const n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(r=>Object.hasOwn(e,r)&&Object.is(t[r],e[r]))},Za=t=>{const e=ge(()=>({}),[]);return e.v!==void 0&&ar(e.v,t)?e.v:(e.v=t,t)},Fr=t=>{const e=O(2),n=te(void 0);let r;return e[0]!==t?(r=s=>{const i=t(s);return n.current!==void 0&&ar(n.current,i)?n.current:(n.current=i,i)},e[0]=t,e[1]=r):r=e[1],r},e0=(()=>{try{return!1}catch{return!1}})(),hI=(t,e)=>{const n={...t},r=new Set;let s=!0;for(;s;){s=!1;for(const i of Object.values(n)){if(r.has(i.hook))continue;r.add(i.hook);const o=nI(i.hook);if(o){o(n,e),s=!0;break}}}return n},zl=t=>t.hook===i0,fI=t=>{if(!zl(t))return{source:"root",query:{}};const e=t.args[0];return{source:e.source,query:e.query??{}}},cd=Symbol.for("aui.event-receiver-ref"),t0=(t,e)=>{const n=t===ks?XC():t,r=Object.create(n);Object.assign(r,e);let s;return Object.defineProperty(r,"optional",{get:()=>s??(s=qw(r)),enumerable:!1}),r},pI=({notifications:t,clientRef:e})=>ge(()=>({subscribe:t.subscribe,on:function(n,r){if(!this)throw new Error("const { on } = useAui() is not supported. Use aui.on() instead.");const{scope:s,event:i}=Kh(n),o=n[cd];if(s!=="*"&&!o&&id(this[s]))throw new Error(`Scope "${s}" is not available. Use { scope: "*", event: "${i}" } to listen globally.`);const a=t.on(i,(u,c)=>{if(s==="*")return r(u);const d=((o??e).current??this)[s];if(!jl(d))return;const h=$l(d);if(h===c[iI(h)])return r(u)});if(s!=="*"){if(o){if(e.parent===ks)return a}else if(id(e.parent[s]))return a}const l=e.parent.on(n,r);return()=>{a(),l()}}}),[t,e]),n0=t=>{const e=O(5);let n;e[0]!==t?(n=fI(t),e[0]=t,e[1]=n):n=e[1];const{source:r,query:s}=n,i=Za(s);let o;return e[2]!==r||e[3]!==i?(o={source:r,query:i},e[2]=r,e[3]=i,e[4]=o):o=e[4],Za(o)},mI=(t,e)=>{const n=O(3);let r;return n[0]!==e||n[1]!==t?(r=e?t:Zw(t),n[0]=e,n[1]=t,n[2]=r):r=n[2],wt(r)},gI=(t,e)=>{const n=Qh(),r=zl(e),s=mI(e,r),i=r?s:s.methods,o=n0(e),a=ge(()=>Vw({name:t,...o},()=>i),[t,o,i]);return n[t]=a,a},yI=de(gI),vI=t=>{const e=O(2);let n;return e[0]!==t?(n=t.map(kI),e[0]=t,e[1]=n):n=e[1],Yi(n)},r0=(t,e)=>{const n=Za(e),r=ge(()=>({}),[]);return r.deps!==n&&(r.deps=n,r.client=t),r.client},_I=({parent:t,entries:e,clientRef:n,notifications:r})=>{const s=pI({notifications:r,clientRef:n}),i=t0(t,s),o=aI({clientRef:n,emit:r.emit},function(){return Gw(i,function(){return vI(e)})});return{client:r0(i,[t,...o])}},wI=({parent:t,entries:e,destroySignal:n})=>{const r=te({parent:t,current:null}).current,{value:s,effects:i}=Uw(function(){const a=sI(),{client:l}=Xw(n,function(){return _I({parent:t,entries:e,clientRef:r,notifications:a})});return J(()=>t.subscribe(a.notifySubscribers),[t,a]),J(()=>a.notifySubscribers()),l});return Qr(()=>{r.parent=t,r.current=s},[s,t,r]),{client:s,effects:i}},xI=(t,e,n,r)=>{const{get:s}=r.args[0],i=Wr(t.subscribe,()=>s(t),()=>s(t)),o=n0(r),a=ge(()=>Vw({name:n,...o},()=>i),[n,o,i]);return e[n]=a,a},SI=(t,e)=>{if(e0){const[a]=ce(()=>e.map(([c])=>c).join(",")),l=e.find(([,c])=>!zl(c));if(l)throw new Error(`Scope "${l[0]}" is a root scope but this useAui mounted derived-only; remount with a new key to change scope kinds.`);const u=e.map(([c])=>c).join(",");if(u!==a)throw new Error(`A derived-only config mounted scopes [${a}] but now has [${u}]; remount with a new key to change the scope set.`)}const n=te({parent:t,current:null}).current,r=function(a,l){if(!this)throw new Error("const { on } = useAui() is not supported. Use aui.on() instead.");const{scope:u,event:c}=Kh(a);if(u==="*")return t.on(a,l);const d=a[cd];if(!d&&id(this[u]))throw new Error(`Scope "${u}" is not available. Use { scope: "*", event: "${c}" } to listen globally.`);return t.on({scope:u,event:c,[cd]:d??n},l)},s=t0(t,{subscribe:t.subscribe,on:r}),i=e.map(([a,l])=>xI(t,s,a,l)),o=r0(s,[t,...i]);return Qr(()=>{n.parent=t,n.current=o},[o,t,n]),o},bI=(t,e)=>{const n=O(8);let r;n[0]!==e||n[1]!==t?(r=Object.entries(hI(e,t)),n[0]=e,n[1]=t,n[2]=r):r=n[2];const s=r;let i;n[3]!==s?(i=()=>s.length===0||s.some(CI),n[3]=s,n[4]=i):i=n[4];const[o]=ce(i);let a;return n[5]!==s||n[6]!==o?(a={entries:s,rooted:o},n[5]=s,n[6]=o,n[7]=a):a=n[7],a},TI=(t,e,n,r)=>{const{entries:s,rooted:i}=bI(t,e);return i?n({parent:t,entries:s,destroySignal:r}):{client:SI(t,s)}},s0=(t,e,n)=>TI(t,e,wI,n);function oe(t){return Qh()}function kI(t){const[e,n]=t;return kt(e,yI(e,n))}function CI(t){const[,e]=t;return!zl(e)}const II=t=>{let e;class n extends Ji{get(i,o){const a=zr(o,"OptionalAssistantState");if(a!==!1)return a;const l=o;if(!Er(l)&&jl(t[l]))return Dm(t[l]())}ownKeys(){return od(t)}has(i,o){return!Er(o)&&o in t}}class r extends Ji{get(i,o){const a=zr(o,"AssistantState");if(a!==!1)return a;if(o==="optional")return e??(e=new Proxy({},new n));const l=o;if(!Er(l))return Dm(t[l]())}ownKeys(){return[...od(t),"optional"]}has(i,o){return o==="optional"||!Er(o)&&o in t}}return new Proxy({},new r)},Nm=new WeakMap,EI=t=>{let e=Nm.get(t);return e||(e=II(t),Nm.set(t,e)),e},G=t=>{const e=O(6),n=oe();let r;e[0]!==n?(r=EI(n),e[0]=n,e[1]=r):r=e[1];const s=r;let i,o;e[2]!==s||e[3]!==t?(i=()=>t(s),o=()=>t(s),e[2]=s,e[3]=t,e[4]=i,e[5]=o):(i=e[4],o=e[5]);const a=Wr(n.subscribe,i,o);if(typeof a=="object"&&a!==null&&(a===s||a===s.optional))throw new Error("You tried to return the entire AssistantState. This is not supported due to technical limitations.");return _C(a),a},i0=t=>{const e=O(3),{get:n}=t,r=oe();let s;return e[0]!==r||e[1]!==n?(s=()=>n(r),e[0]=r,e[1]=n,e[2]=s):s=e[2],G(s)},xt=de(i0),o0=t=>{if(t.key===void 0)throw new Error("useClientLookup: Element has no key");return t.key};function lr(t){const e=O(12);let n;e[0]!==t?(n=t.map(PI),e[0]=t,e[1]=n):n=e[1];const r=Yi(n);let s;e[2]!==t?(s=t.reduce(AI,Object.create(null)),e[2]=t,e[3]=s):s=e[3];const i=s;let o;e[4]!==r?(o=r.map(RI),e[4]=r,e[5]=o):o=e[5];const a=o;let l;e[6]!==i||e[7]!==r?(l=c=>{if("index"in c){if(c.index<0||c.index>=r.length)throw new Error(`useClientLookup: index ${c.index} out of bounds (length: ${r.length}) (ignore if recovered)`);return r[c.index].methods}const d=i[c.key];if(d===void 0)throw new Error(`useClientLookup: key "${c.key}" not found (ignore if recovered)`);return r[d].methods},e[6]=i,e[7]=r,e[8]=l):l=e[8];let u;return e[9]!==a||e[10]!==l?(u={state:a,get:l},e[9]=a,e[10]=l,e[11]=u):u=e[11],u}function RI(t){return t.state}function AI(t,e,n){return t[o0(e)]=n,t}function PI(t){return kt(o0(t),Zw(t),t.deps)}const Lm=(t,e=0)=>e===0?Math.abs(t.scrollHeight-t.scrollTop-t.clientHeight)<=1||t.scrollHeight<=t.clientHeight:t.scrollHeight-e-t.scrollTop-t.clientHeight<=1||t.scrollHeight-e<=t.clientHeight,MI=(t,e=0)=>e===0?t.scrollHeight>t.clientHeight+1:t.scrollHeight-e>t.clientHeight+1,DI=(t,e)=>t.scrollTop>e.scrollTop&&t.scrollHeight===e.scrollHeight,Bt=Symbol("skip-update"),Jt=(t,...e)=>{const n=[];for(const r of t)try{r(...e)}catch(s){n.push(s)}if(n.length===1)throw n[0];if(n.length>1){for(const r of n)console.error(r);throw new AggregateError(n)}},Xh=t=>{Jt(t)},a0=(t,e)=>t===void 0||e===void 0?t===e:ar(t,e);var $n=class{constructor(){w(this,"_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(){Jt(this._subscribers)}},Zi=class extends $n{constructor(e){super();w(this,"_state");w(this,"getServerSnapshot");this._state=e,this.subscribe=this.subscribe.bind(this),this.getState=this.getState.bind(this),this.getServerSnapshot=()=>e}getState(){return this._state}setState(e){Object.is(e,this._state)||(this._state=e,this._notifySubscribers())}},Fl=class{constructor(){w(this,"_subscriptions",new Set);w(this,"_connection")}get isConnected(){return!!this._connection}notifySubscribers(t,e){if(e){Yt(this._subscriptions,t,e);return}Jt(this._subscriptions,t)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else{const t=this._connection;this._connection=void 0,t==null||t()}}subscribe(t){return this._subscriptions.add(t),this._updateConnection(),()=>{this._subscriptions.delete(t),this._updateConnection()}}},jt=class extends Fl{constructor(e){super();w(this,"binding");w(this,"_previousState");w(this,"getState",()=>(this.isConnected||this._syncState(),this._previousState));this.binding=e;const n=e.getState();if(n===Bt)throw new Error("Entry not available in the store");this._previousState=n}get path(){return this.binding.path}_syncState(){const e=this.binding.getState();return e===Bt||a0(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){const e=()=>{this._syncState()&&this.notifySubscribers()},n=this.binding.subscribe(e);return this._syncState(),n}},Zh=class extends Fl{constructor(e){super();w(this,"binding");w(this,"_previousStateDirty",!0);w(this,"_previousState");w(this,"getState",()=>{if(!this.isConnected||this._previousStateDirty){const e=this.binding.getState();e!==Bt&&(this._previousState===void 0||!a0(e,this._previousState))&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState});this.binding=e}get path(){return this.binding.path}_connect(){const e=()=>{this._previousStateDirty=!0,this.notifySubscribers()},n=this.binding.subscribe(e);return this._previousStateDirty=!0,n}},el=class extends Fl{constructor(e){super();w(this,"binding");this.binding=e}get path(){return this.binding.path}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){const e=()=>{this.notifySubscribers()};let n=this.binding.getState(),r=n==null?void 0:n.subscribe(e);const s=()=>{const o=this.binding.getState();if(o===n)return;n=o;const a=r;r=void 0;try{a==null||a()}finally{r=o==null?void 0:o.subscribe(e),e()}},i=this.outerSubscribe(s);return()=>Xh([()=>i==null?void 0:i(),()=>r==null?void 0:r()])}},l0=class extends Fl{constructor(e){super();w(this,"config");this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){const e=`Runtime event "${this.config.event}"`,n=a=>{this.notifySubscribers(a,e)};let r=this.config.binding.getState(),s=r==null?void 0:r.unstable_on(this.config.event,n);const i=()=>{const a=this.config.binding.getState();if(a===r)return;r=a;const l=s;s=void 0;try{l==null||l()}finally{s=a==null?void 0:a.unstable_on(this.config.event,n)}},o=this.outerSubscribe(i);return()=>Xh([()=>o==null?void 0:o(),()=>s==null?void 0:s()])}},u0=class{constructor(){w(this,"_providers",new Map);w(this,"_providerUnsubscribes",new Map);w(this,"_subscribers",new Set)}getModelContext(){return qC(new Set(this._providers.values()))}registerModelContextProvider(t){var s;const e=Symbol();this._providers.set(e,t);let n;try{n=(s=t.subscribe)==null?void 0:s.call(t,()=>{this.notifySubscribers()})}catch(i){this._providers.delete(e);try{this.notifySubscribers()}catch(o){console.error(o)}throw i}this._providerUnsubscribes.set(e,n),this.notifySubscribers();let r=!1;return()=>{if(r)return;r=!0,this._providers.delete(e);const i=this._providerUnsubscribes.get(e);this._providerUnsubscribes.delete(e);let o=!1,a;const l=u=>{try{u()}catch(c){o?console.error(c):(o=!0,a=c)}};if(i&&l(i),l(()=>this.notifySubscribers()),o)throw a}}notifySubscribers(){Jt(this._subscribers)}subscribe(t){return this._subscribers.add(t),()=>{this._subscribers.delete(t)}}};const dd=[],OI={modelName:void 0,toolNames:dd},NI=(t,e)=>t===e||ar(t,e),Wo=(t,e)=>{var o;const n=t.getModelContext(),r=(o=n.config)==null?void 0:o.modelName,s=n.tools?Object.keys(n.tools).sort():dd,i=s.length?s:dd;return r===e.modelName&&NI(i,e.toolNames)?e:{modelName:r,toolNames:i}},LI=()=>{const t=O(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=new u0,t[0]=e):e=t[0];const n=e;let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=()=>Wo(n,OI),t[1]=r):r=t[1];const[s,i]=ce(r);let o,a;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=()=>(i(f=>Wo(n,f)),n.subscribe(()=>{i(f=>Wo(n,f))})),a=[n],t[2]=o,t[3]=a):(o=t[2],a=t[3]),J(o,a);let l;t[4]!==s?(l=()=>Wo(n,s),t[4]=s,t[5]=l):l=t[5];let u,c,d;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>n.getModelContext(),c=f=>n.subscribe(f),d=f=>n.registerModelContextProvider(f),t[6]=u,t[7]=c,t[8]=d):(u=t[6],c=t[7],d=t[8]);let h;return t[9]!==l?(h={getState:l,getModelContext:u,subscribe:c,register:d},t[9]=l,t[10]=h):h=t[10],h},c0=de(LI),jI=(t,e)=>{var r,s;if(!(((r=e.status)==null?void 0:r.type)==="running"||((s=e.status)==null?void 0:s.type)==="requires-action")){const i=t.complete;return typeof i!="function"?i??null:i({args:e.args,result:e.result})}const n=t.running;return typeof n!="function"?n??null:n({args:e.args})},$I=t=>t.display!==void 0?t.display==="standalone":t.type==="human",zI=t=>function(n){return jI(t,n)},d0=t=>{const e=O(16),{toolkit:n,mcpApp:r}=t;let s;e[0]!==r?(s=r?[kt("mcpApp",r)]:[],e[0]=r,e[1]=s):s=e[1];const i=Yi(s)[0],[o,a]=ce(BI);let l;e[2]!==i||e[3]!==o?(l={toolUIs:o,mcpApp:i},e[2]=i,e[3]=o,e[4]=l):l=e[4];const u=l,c=Yw();let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=(y,v,S)=>{const I={render:v,renderText:S==null?void 0:S.renderText,standalone:(S==null?void 0:S.standalone)??!1};return a(b=>{const P=Te(b);return P[y]=[...P[y]??[],I],P}),()=>{a(b=>{var D;const P=((D=b[y])==null?void 0:D.filter(x=>x!==I))??[],A=Te(b);return P.length>0?(A[y]=P,A):(delete A[y],A)})}},e[5]=d):d=e[5];const h=d;let f,p;e[6]!==n?(f=()=>{if(!n)return;const y=[];for(const[v,S]of Object.entries(n)){const I="render"in S?S.render:void 0,b="renderText"in S?S.renderText:void 0,P=I??(b?zI(b):void 0);P&&y.push(h(v,P,{standalone:$I(S),renderText:b}))}return()=>{y.forEach(UI)}},p=[n,h],e[6]=n,e[7]=f,e[8]=p):(f=e[7],p=e[8]),J(f,p);let g;e[9]!==c||e[10]!==n?(g=()=>{if(!n)return;const y=Object.entries(n).reduce(VI,Te());return c.current.modelContext().register({getModelContext:()=>({tools:y})})},e[9]=c,e[10]=n,e[11]=g):g=e[11];let _;e[12]!==n?(_=[n],e[12]=n,e[13]=_):_=e[13],Jw("modelContext",g,_);let m;return e[14]!==u?(m={getState:()=>u,setToolUI:h},e[14]=u,e[15]=m):m=e[15],m},FI=de(d0);Ww(d0,(t,e)=>{!t.modelContext&&e.modelContext.source===null&&(t.modelContext=c0())});function BI(){return Te()}function UI(t){return t()}function VI(t,e){const[n,r]=e;if(r.type==="mcp")return t;const{display:s,render:i,renderText:o,...a}=r;return t[n]=a,t}const et=t=>Wr(t.subscribe,t.getState,t.getServerSnapshot),h0=Symbol.for("assistant-ui.silent-runtime-action"),f0=t=>typeof t=="object"&&t!==null&&h0 in t,p0=(t,e)=>{const n=e();return n.catch(r=>{f0(r)||console.error(`[assistant-ui] ${t} failed:`,r)}),n},HI=t=>{const e=O(9),{runtime:n}=t,r=et(n);let s;e[0]!==r?(s=()=>r,e[0]=r,e[1]=s):s=e[1];let i,o;e[2]!==n?(i=()=>p0("attachment remove",n.remove),o=()=>n,e[2]=n,e[3]=i,e[4]=o):(i=e[3],o=e[4]);let a;return e[5]!==s||e[6]!==i||e[7]!==o?(a={getState:s,remove:i,__internal_getRuntime:o},e[5]=s,e[6]=i,e[7]=o,e[8]=a):a=e[8],a},m0=de(HI),qI=t=>{const e=O(5),{runtime:n,index:r}=t;let s;e[0]!==r||e[1]!==n?(s=n.getAttachmentByIndex(r),e[0]=r,e[1]=n,e[2]=s):s=e[2];const i=s;let o;return e[3]!==i?(o=m0({runtime:i}),e[3]=i,e[4]=o):o=e[4],wt(o)},GI=de(qI),WI=({item:t,onMove:e,onRemove:n})=>({getState:()=>t,steer:()=>e({lane:"steer",insertAfter:null}),move:e,remove:n}),QI=de(WI),KI=t=>{const e=O(63),{threadIdRef:n,messageIdRef:r,runtime:s,isSuggestion:i}=t,o=et(s),a=Bs(),l=te(!1);let u,c;e[0]!==a||e[1]!==r||e[2]!==s||e[3]!==n?(u=()=>{const k=[],R=s.unstable_on("send",L=>{const z=l.current;l.current=!1,a("composer.send",{threadId:n.current,...r&&{messageId:r.current},chars:L.chars,attachments:L.attachments,...z?{suggestion:!0}:void 0})});k.push(R);const M=s.unstable_on("attachmentAdd",L=>{a("composer.attachmentAdd",{threadId:n.current,...r&&{messageId:r.current},...L.contentType?{contentType:L.contentType}:void 0})});return k.push(M),k.push(s.unstable_on("attachmentAddError",L=>{a("composer.attachmentAddError",{threadId:n.current,...r&&{messageId:r.current},...L.attachmentId&&{attachmentId:L.attachmentId},reason:L.reason,message:L.message,...L.contentType?{contentType:L.contentType}:void 0})})),()=>{for(const L of k)L()}},c=[s,a,n,r],e[0]=a,e[1]=r,e[2]=s,e[3]=n,e[4]=u,e[5]=c):(u=e[4],c=e[5]),J(u,c);let d;if(e[6]!==s||e[7]!==o.attachments){let k;e[9]!==s?(k=(R,M)=>kt(R.id,GI({runtime:s,index:M}),[s,M]),e[9]=s,e[10]=k):k=e[10],d=o.attachments.map(k),e[6]=s,e[7]=o.attachments,e[8]=d}else d=e[8];const h=lr(d),f=o.queue;let p;if(e[11]!==f||e[12]!==s){let k;e[14]!==s?(k=R=>kt(R.id,QI({item:R,onMove:M=>s.moveQueueItem(R.id,M),onRemove:()=>s.removeQueueItem(R.id)})),e[14]=s,e[15]=k):k=e[15],p=f.map(k),e[11]=f,e[12]=s,e[13]=p}else p=e[13];const g=lr(p),_=o.type??"thread";let m;e[16]!==h.state||e[17]!==f||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={text:o.text,role:o.role,attachments:h.state,runConfig:o.runConfig,isEditing:o.isEditing,canCancel:o.canCancel,canSend:o.canSend,attachmentAccept:o.attachmentAccept,isEmpty:o.isEmpty,type:_,dictation:o.dictation,quote:o.quote,queue:f},e[16]=h.state,e[17]=f,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]=_,e[29]=m):m=e[29];const y=m;let v;e[30]!==y?(v=()=>y,e[30]=y,e[31]=v):v=e[31];let S;e[32]!==i||e[33]!==s?(S=k=>{const R=s.getState();l.current=R.canSend&&((i==null?void 0:i(R.text))??!1),s.send(k)},e[32]=i,e[33]=s,e[34]=S):S=e[34];let I;e[35]!==a||e[36]!==r||e[37]!==s||e[38]!==n?(I=()=>{!r&&s.getState().canCancel&&a("composer.cancel",{threadId:n.current}),s.cancel()},e[35]=a,e[36]=r,e[37]=s,e[38]=n,e[39]=I):I=e[39];const b=s.beginEdit??YI;let P;e[40]!==h?(P=k=>"id"in k?h.get({key:k.id}):h.get(k),e[40]=h,e[41]=P):P=e[41];let A;e[42]!==g?(A=k=>"id"in k?g.get({key:k.id}):g.get(k),e[42]=g,e[43]=A):A=e[43];let D;e[44]!==s?(D=()=>s,e[44]=s,e[45]=D):D=e[45];let x;return e[46]!==s.addAttachment||e[47]!==s.clearAttachments||e[48]!==s.reset||e[49]!==s.setQuote||e[50]!==s.setRole||e[51]!==s.setRunConfig||e[52]!==s.setText||e[53]!==s.startDictation||e[54]!==s.stopDictation||e[55]!==b||e[56]!==P||e[57]!==A||e[58]!==D||e[59]!==v||e[60]!==S||e[61]!==I?(x={getState:v,setText:s.setText,setRole:s.setRole,setRunConfig:s.setRunConfig,addAttachment:s.addAttachment,reset:s.reset,clearAttachments:s.clearAttachments,send:S,cancel:I,beginEdit:b,startDictation:s.startDictation,stopDictation:s.stopDictation,setQuote:s.setQuote,attachment:P,queueItem:A,__internal_getRuntime:D},e[46]=s.addAttachment,e[47]=s.clearAttachments,e[48]=s.reset,e[49]=s.setQuote,e[50]=s.setRole,e[51]=s.setRunConfig,e[52]=s.setText,e[53]=s.startDictation,e[54]=s.stopDictation,e[55]=b,e[56]=P,e[57]=A,e[58]=D,e[59]=v,e[60]=S,e[61]=I,e[62]=x):x=e[62],x},g0=de(KI);function YI(){throw new Error("beginEdit is not supported in this runtime")}const y0=t=>({get current(){return t()}}),JI=t=>{const e=O(13),{runtime:n}=t,r=et(n);let s;e[0]!==r?(s=()=>r,e[0]=r,e[1]=s):s=e[1];let i,o,a,l;e[2]!==n?(i=c=>n.addToolResult(c),o=c=>n.resumeToolCall(c),a=c=>n.respondToToolApproval(c),l=()=>n,e[2]=n,e[3]=i,e[4]=o,e[5]=a,e[6]=l):(i=e[3],o=e[4],a=e[5],l=e[6]);let u;return e[7]!==s||e[8]!==i||e[9]!==o||e[10]!==a||e[11]!==l?(u={getState:s,addToolResult:i,resumeToolCall:o,respondToToolApproval:a,__internal_getRuntime:l},e[7]=s,e[8]=i,e[9]=o,e[10]=a,e[11]=l,e[12]=u):u=e[12],u},XI=de(JI),ZI=t=>{const e=O(5),{runtime:n,index:r}=t;let s;e[0]!==r||e[1]!==n?(s=n.getAttachmentByIndex(r),e[0]=r,e[1]=n,e[2]=s):s=e[2];const i=s;let o;return e[3]!==i?(o=m0({runtime:i}),e[3]=i,e[4]=o):o=e[4],wt(o)},eE=de(ZI),tE=t=>{const e=O(5),{runtime:n,index:r}=t;let s;e[0]!==r||e[1]!==n?(s=n.getMessagePartByIndex(r),e[0]=r,e[1]=n,e[2]=s):s=e[2];const i=s;let o;return e[3]!==i?(o=XI({runtime:i}),e[3]=i,e[4]=o):o=e[4],wt(o)},nE=de(tE),rE=t=>{const e=O(74),{runtime:n,threadIdRef:r,threadId:s}=t,i=et(n),o=Bs(),[a,l]=ce(!1),[u,c]=ce(!1);let d;e[0]!==n?(d=y0(()=>n.getState().id),e[0]=n,e[1]=d):d=e[1];const h=d,f=te(i.status);let p;e[2]!==o||e[3]!==n||e[4]!==s?(p=V=>{o(V,{threadId:s,messageId:n.getState().id})},e[2]=o,e[3]=n,e[4]=s,e[5]=p):p=e[5];const g=p;let _,m;e[6]!==o||e[7]!==i.id||e[8]!==i.status||e[9]!==s?(_=()=>{const V=i.status,he=f.current;f.current=V,(V==null?void 0:V.type)==="incomplete"&&V.reason==="error"&&((he==null?void 0:he.type)!=="incomplete"||he.reason!=="error")&&o("message.error",{threadId:s,messageId:i.id,reason:"error"})},m=[i.status,i.id,o,s],e[6]=o,e[7]=i.id,e[8]=i.status,e[9]=s,e[10]=_,e[11]=m):(_=e[10],m=e[11]),J(_,m);let y;e[12]!==h||e[13]!==n.composer||e[14]!==r?(y=g0({runtime:n.composer,threadIdRef:r,messageIdRef:h}),e[12]=h,e[13]=n.composer,e[14]=r,e[15]=y):y=e[15];const v=Xi(y);let S;if(e[16]!==n||e[17]!==i.content){let V;e[19]!==n?(V=(he,Ae)=>kt("toolCallId"in he&&he.toolCallId!=null?`toolCallId-${he.toolCallId}`:`index-${Ae}`,nE({runtime:n,index:Ae}),[n,Ae]),e[19]=n,e[20]=V):V=e[20],S=i.content.map(V),e[16]=n,e[17]=i.content,e[18]=S}else S=e[18];const I=lr(S);let b;e[21]!==i.attachments?(b=i.attachments??[],e[21]=i.attachments,e[22]=b):b=e[22];let P;if(e[23]!==n||e[24]!==b){let V;e[26]!==n?(V=(he,Ae)=>kt(he.id,eE({runtime:n,index:Ae}),[n,Ae]),e[26]=n,e[27]=V):V=e[27],P=b.map(V),e[23]=n,e[24]=b,e[25]=P}else P=e[25];const A=lr(P),D=i;let x;e[28]!==v.state||e[29]!==a||e[30]!==u||e[31]!==I.state||e[32]!==D?(x={...D,parts:I.state,composer:v.state,isCopied:a,isHovering:u},e[28]=v.state,e[29]=a,e[30]=u,e[31]=I.state,e[32]=D,e[33]=x):x=e[33];const k=x;let R;e[34]!==k?(R=()=>k,e[34]=k,e[35]=R):R=e[35];let M;e[36]!==v.methods?(M=()=>v.methods,e[36]=v.methods,e[37]=M):M=e[37];let L;e[38]!==n?(L=()=>n.delete(),e[38]=n,e[39]=L):L=e[39];let z,W;e[40]!==g||e[41]!==n?(z=V=>(g("message.reload"),n.reload(V)),W=()=>(g("message.speak"),n.speak()),e[40]=g,e[41]=n,e[42]=z,e[43]=W):(z=e[42],W=e[43]);let K,$;e[44]!==n?(K=()=>n.stopSpeaking(),$=V=>n.submitFeedback(V),e[44]=n,e[45]=K,e[46]=$):(K=e[45],$=e[46]);let U;e[47]!==g||e[48]!==n?(U=V=>(g("message.branchSwitched"),n.switchToBranch(V)),e[47]=g,e[48]=n,e[49]=U):U=e[49];let C;e[50]!==n?(C=()=>n.unstable_getCopyText(),e[50]=n,e[51]=C):C=e[51];let Y;e[52]!==I?(Y=V=>"index"in V?I.get({index:V.index}):I.get({key:`toolCallId-${V.toolCallId}`}),e[52]=I,e[53]=Y):Y=e[53];let j;e[54]!==A?(j=V=>"id"in V?A.get({key:V.id}):A.get(V),e[54]=A,e[55]=j):j=e[55];let E;e[56]!==g?(E=V=>{V&&g("message.copied"),l(V)},e[56]=g,e[57]=E):E=e[57];let q;e[58]!==n?(q=()=>n,e[58]=n,e[59]=q):q=e[59];let X;return e[60]!==R||e[61]!==M||e[62]!==L||e[63]!==z||e[64]!==W||e[65]!==K||e[66]!==$||e[67]!==U||e[68]!==C||e[69]!==Y||e[70]!==j||e[71]!==E||e[72]!==q?(X={getState:R,composer:M,delete:L,reload:z,speak:W,stopSpeaking:K,submitFeedback:$,switchToBranch:U,getCopyText:C,part:Y,attachment:j,setIsCopied:E,setIsHovering:c,__internal_getRuntime:q},e[60]=R,e[61]=M,e[62]=L,e[63]=z,e[64]=W,e[65]=K,e[66]=$,e[67]=U,e[68]=C,e[69]=Y,e[70]=j,e[71]=E,e[72]=q,e[73]=X):X=e[73],X},sE=de(rE),iE=t=>{const e=ge(()=>({}),[]),n=e.state,r=[];t.suggestions.forEach(i=>{const o=n==null?void 0:n.suggestions[r.length];r.push(o&&ar(o,i)?o:i)});const s=n&&ar(r,n.suggestions)?n:{suggestions:r};return e.state=s,s},oE=t=>({getState:()=>t}),aE=de(oE),lE=t=>{const e=O(9),n=iE(t);let r;e[0]!==n.suggestions?(r=n.suggestions.map(dE),e[0]=n.suggestions,e[1]=r):r=e[1];const s=lr(r);let i;e[2]!==n?(i=()=>n,e[2]=n,e[3]=i):i=e[3];let o;e[4]!==s?(o=l=>{const{index:u}=l;return s.get({index:u})},e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==i||e[7]!==o?(a={getState:i,suggestion:o},e[6]=i,e[7]=o,e[8]=a):a=e[8],a},uE=t=>{const e=O(4);let n;e[0]!==t?(n=t.map(hE),e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r={suggestions:n},e[2]=n,e[3]=r):r=e[3],lE(r)},cE=de(uE);function dE(t,e){return kt(e,aE(t),[t])}function hE(t){return{title:t.title??t.prompt,label:t.label??"",prompt:t.prompt}}const An=Object.freeze({type:"complete"}),ef=Object.freeze({type:"running"}),fE=Object.freeze({cancelled:Object.freeze({type:"incomplete",reason:"cancelled"}),length:Object.freeze({type:"incomplete",reason:"length"}),"content-filter":Object.freeze({type:"incomplete",reason:"content-filter"}),other:Object.freeze({type:"incomplete",reason:"other"}),error:Object.freeze({type:"incomplete",reason:"error"})}),pE=t=>{const e=t.status;if(!e||typeof e!="object")return;const{type:n}=e;if(n==="running")return ef;if(n==="complete")return An;if(n!=="incomplete")return;const{reason:r}=e;return fE[r==="cancelled"||r==="length"||r==="content-filter"||r==="other"||r==="error"?r:"other"]},v0=(t,e,n)=>{if(t.role!=="assistant")return An;if(n.type==="tool-call")return n.result===void 0?t.status:An;if(t.status.type==="running"){const s=pE(n);if(s)return s}const r=e===Math.max(0,t.content.length-1);return t.status.type==="requires-action"?An:r?t.status:An},mE=t=>"reason"in t?t.reason:void 0,gE=t=>"error"in t?t.error:void 0,yE=32,_0=new WeakMap,w0=t=>_0.get(t)??t.id,vE=(t,e,n)=>"status"in t&&t.status?v0(t,e,n):An,_E=()=>{let t=[],e=new Map;return n=>{const r=[],s=new Map;let i=!0;const o=(l,u,c,d)=>{if(!(c>yE))for(const[h,f]of l.entries())for(const[p,g]of f.content.entries()){if(g.type!=="tool-call"||g.messages===void 0)continue;const _=g.messages,m=vE(f,p,g),y=mE(m),v=gE(m),S=`${d}${h}.${p}`,I=e.get(S),b=(I==null?void 0:I.part)===g&&I.statusType===m.type&&I.statusReason===y&&Object.is(I.statusError,v)&&I.messages===_&&I.task.messageId===f.id&&I.task.parentTaskId===u&&I.task.depth===c?I.task:{id:g.toolCallId,toolName:g.toolName,args:g.args,result:g.result,...g.isError===void 0?void 0:{isError:g.isError},status:m,timing:g.timing,messageId:f.id,parentTaskId:u,depth:c,messages:_};b!==(I==null?void 0:I.task)&&(i=!1,_0.set(b,S)),r.push(b),s.set(S,{task:b,part:g,statusType:m.type,statusReason:y,statusError:v,messages:_}),o(_,b.id,c+1,`${S}.`)}};o(n,null,0,"");const a=i&&r.length===t.length&&r.every((l,u)=>l===t[u])?t:r;return t=a,e=s,a}},wE=({task:t})=>({getState:()=>t}),xE=de(wE),SE=t=>{const e=O(7),{runtime:n,id:r,threadIdRef:s,threadId:i}=t;let o;e[0]!==r||e[1]!==n?(o=n.getMessageById(r),e[0]=r,e[1]=n,e[2]=o):o=e[2];const a=o;let l;return e[3]!==a||e[4]!==i||e[5]!==s?(l=sE({runtime:a,threadIdRef:s,threadId:i}),e[3]=a,e[4]=i,e[5]=s,e[6]=l):l=e[6],wt(l)},bE=de(SE),TE=t=>{const e=O(93),{runtime:n}=t,r=et(n),s=Bs();let i,o;e[0]!==s||e[1]!==n?(i=()=>{const j=[];for(const E of["runStart","runEnd","initialize","modelContextUpdate"]){const q=n.unstable_on(E,()=>{var V;const X=((V=n.getState())==null?void 0:V.threadId)||"unknown";s(`thread.${E}`,{threadId:X})});j.push(q)}return j.push(n.unstable_on("toolApprovalAnswered",E=>{var X;const q=((X=n.getState())==null?void 0:X.threadId)||"unknown";s("thread.toolApprovalAnswered",{threadId:q,...E})})),()=>{for(const E of j)E()}},o=[n,s],e[0]=s,e[1]=n,e[2]=i,e[3]=o):(i=e[2],o=e[3]),J(i,o);let a;e[4]!==n?(a=y0(()=>n.getState().threadId),e[4]=n,e[5]=a):a=e[5];const l=a;let u;e[6]!==s||e[7]!==n?(u=j=>{s(j,{threadId:n.getState().threadId})},e[6]=s,e[7]=n,e[8]=u):u=e[8];const c=u;let d;e[9]!==n?(d=j=>n.getState().suggestions.some(E=>E.prompt===j),e[9]=n,e[10]=d):d=e[10];const h=d;let f;e[11]!==h||e[12]!==n.composer||e[13]!==l?(f=g0({runtime:n.composer,threadIdRef:l,isSuggestion:h}),e[11]=h,e[12]=n.composer,e[13]=l,e[14]=f):f=e[14];const p=Xi(f);let g;e[15]!==r.suggestions?(g=cE(r.suggestions),e[15]=r.suggestions,e[16]=g):g=e[16];const _=Xi(g);let m;e[17]===Symbol.for("react.memo_cache_sentinel")?(m=_E(),e[17]=m):m=e[17];const y=m;let v;e[18]!==r.messages?(v=y(r.messages),e[18]=r.messages,e[19]=v):v=e[19];const S=v;let I;e[20]!==S?(I=S.map(CE),e[20]=S,e[21]=I):I=e[21];const b=lr(I);let P;if(e[22]!==n||e[23]!==r.messages||e[24]!==r.threadId||e[25]!==l){let j;e[27]!==n||e[28]!==r.threadId||e[29]!==l?(j=E=>kt(E.id,bE({runtime:n,id:E.id,threadIdRef:l,threadId:r.threadId}),[n,E.id,l,r.threadId]),e[27]=n,e[28]=r.threadId,e[29]=l,e[30]=j):j=e[30],P=r.messages.map(j),e[22]=n,e[23]=r.messages,e[24]=r.threadId,e[25]=l,e[26]=P}else P=e[26];const A=lr(P),D=A.state.length===0&&!r.isLoading;let x;e[31]!==p.state||e[32]!==A.state||e[33]!==r.capabilities||e[34]!==r.extras||e[35]!==r.isDisabled||e[36]!==r.isLoading||e[37]!==r.isRunning||e[38]!==r.speech||e[39]!==r.state||e[40]!==r.suggestions||e[41]!==r.voice||e[42]!==D||e[43]!==S?(x={isEmpty:D,isDisabled:r.isDisabled,isLoading:r.isLoading,isRunning:r.isRunning,capabilities:r.capabilities,state:r.state,suggestions:r.suggestions,extras:r.extras,speech:r.speech,voice:r.voice,composer:p.state,messages:A.state,tasks:S},e[31]=p.state,e[32]=A.state,e[33]=r.capabilities,e[34]=r.extras,e[35]=r.isDisabled,e[36]=r.isLoading,e[37]=r.isRunning,e[38]=r.speech,e[39]=r.state,e[40]=r.suggestions,e[41]=r.voice,e[42]=D,e[43]=S,e[44]=x):x=e[44];const k=x;let R;e[45]!==k?(R=()=>k,e[45]=k,e[46]=R):R=e[46];let M;e[47]!==p.methods?(M=()=>p.methods,e[47]=p.methods,e[48]=M):M=e[48];let L;e[49]!==_?(L=()=>_.methods,e[49]=_,e[50]=L):L=e[50];let z;e[51]!==b||e[52]!==S?(z=j=>{if("id"in j){const E=S.find(q=>q.id===j.id);return b.get({key:E?w0(E):j.id})}return b.get(j)},e[51]=b,e[52]=S,e[53]=z):z=e[53];let W;e[54]!==s||e[55]!==h||e[56]!==n?(W=j=>{var q;const E=typeof j=="string"?{content:[{type:"text",text:j}]}:j;if((E.role??"user")==="user"){const X=E.content.map(IE).join("");s("composer.send",{threadId:n.getState().threadId,chars:X.length,attachments:((q=E.attachments)==null?void 0:q.length)??0,...h(X)?{suggestion:!0}:void 0})}n.append(j)},e[54]=s,e[55]=h,e[56]=n,e[57]=W):W=e[57];let K;e[58]!==c||e[59]!==n||e[60]!==r.isRunning?(K=()=>{r.isRunning&&c("thread.cancelRun"),n.cancelRun()},e[58]=c,e[59]=n,e[60]=r.isRunning,e[61]=K):K=e[61];let $;e[62]!==c||e[63]!==n?($=()=>{n.connectVoice(),c("thread.voiceStarted")},e[62]=c,e[63]=n,e[64]=$):$=e[64];let U;e[65]!==A?(U=j=>"id"in j?A.get({key:j.id}):A.get(j),e[65]=A,e[66]=U):U=e[66];let C;e[67]!==n?(C=()=>n,e[67]=n,e[68]=C):C=e[68];let Y;return e[69]!==n.deleteMessage||e[70]!==n.disconnectVoice||e[71]!==n.export||e[72]!==n.getModelContext||e[73]!==n.getVoiceVolume||e[74]!==n.import||e[75]!==n.importExternalState||e[76]!==n.muteVoice||e[77]!==n.reset||e[78]!==n.resumeRun||e[79]!==n.startRun||e[80]!==n.stopSpeaking||e[81]!==n.subscribeVoiceVolume||e[82]!==n.unmuteVoice||e[83]!==R||e[84]!==M||e[85]!==L||e[86]!==z||e[87]!==W||e[88]!==K||e[89]!==$||e[90]!==U||e[91]!==C?(Y={getState:R,composer:M,suggestions:L,task:z,append:W,deleteMessage:n.deleteMessage,startRun:n.startRun,resumeRun:n.resumeRun,importExternalState:n.importExternalState,cancelRun:K,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,connectVoice:$,disconnectVoice:n.disconnectVoice,getVoiceVolume:n.getVoiceVolume,subscribeVoiceVolume:n.subscribeVoiceVolume,muteVoice:n.muteVoice,unmuteVoice:n.unmuteVoice,message:U,__internal_getRuntime:C},e[69]=n.deleteMessage,e[70]=n.disconnectVoice,e[71]=n.export,e[72]=n.getModelContext,e[73]=n.getVoiceVolume,e[74]=n.import,e[75]=n.importExternalState,e[76]=n.muteVoice,e[77]=n.reset,e[78]=n.resumeRun,e[79]=n.startRun,e[80]=n.stopSpeaking,e[81]=n.subscribeVoiceVolume,e[82]=n.unmuteVoice,e[83]=R,e[84]=M,e[85]=L,e[86]=z,e[87]=W,e[88]=K,e[89]=$,e[90]=U,e[91]=C,e[92]=Y):Y=e[92],Y},kE=de(TE);function CE(t){return kt(w0(t),xE({task:t}),[t])}function IE(t){return t.type==="text"?t.text:""}const kn=(t,e)=>p0(`thread list ${t}`,e),EE=t=>{const e=O(35),{runtime:n,mainThreadIsRunning:r}=t,s=r===void 0?!1:r,i=et(n);let o;e:{const D=i.isRunning||i.isMain&&s;if(D===i.isRunning){o=i;break e}let x;e[0]!==D||e[1]!==i?(x={...i,isRunning:D},e[0]=D,e[1]=i,e[2]=x):x=e[2],o=x}const a=o,l=Bs(),{isMain:u,id:c}=i;let d;e[3]!==u||e[4]!==c?(d={isMain:u,threadId:c},e[3]=u,e[4]=c,e[5]=d):d=e[5];const h=te(d);let f,p;e[6]!==l||e[7]!==u||e[8]!==c?(f=()=>{const D=h.current;D.isMain===u&&D.threadId===c||(h.current={isMain:u,threadId:c},l(u?"threadListItem.switchedTo":"threadListItem.switchedAway",{threadId:c}))},p=[u,c,l],e[6]=l,e[7]=u,e[8]=c,e[9]=f,e[10]=p):(f=e[9],p=e[10]),J(f,p);let g;e[11]!==a?(g=()=>a,e[11]=a,e[12]=g):g=e[12];let _,m,y,v,S,I,b;e[13]!==n?(S=D=>kn("switch",()=>n.switchTo(D)),I=D=>kn("rename",()=>n.rename(D)),b=D=>kn("update custom metadata",()=>n.updateCustom(D)),_=()=>kn("archive",()=>n.archive()),m=()=>kn("unarchive",()=>n.unarchive()),y=()=>kn("delete",()=>n.delete()),v=D=>kn("generate title",()=>n.generateTitle(D)),e[13]=n,e[14]=_,e[15]=m,e[16]=y,e[17]=v,e[18]=S,e[19]=I,e[20]=b):(_=e[14],m=e[15],y=e[16],v=e[17],S=e[18],I=e[19],b=e[20]);let P;e[21]!==n?(P=()=>n,e[21]=n,e[22]=P):P=e[22];let A;return e[23]!==n.detach||e[24]!==n.initialize||e[25]!==_||e[26]!==m||e[27]!==y||e[28]!==v||e[29]!==P||e[30]!==g||e[31]!==S||e[32]!==I||e[33]!==b?(A={getState:g,switchTo:S,rename:I,updateCustom:b,archive:_,unarchive:m,delete:y,generateTitle:v,initialize:n.initialize,detach:n.detach,__internal_getRuntime:P},e[23]=n.detach,e[24]=n.initialize,e[25]=_,e[26]=m,e[27]=y,e[28]=v,e[29]=P,e[30]=g,e[31]=S,e[32]=I,e[33]=b,e[34]=A):A=e[34],A},tf=de(EE),RE=t=>{const e=O(4),n=Bs(),r=te(t);let s,i;e[0]!==n||e[1]!==t?(s=()=>{const o=r.current;o!==t&&(r.current=t,n("threads.selectionChanged",{threadId:t,previousThreadId:o}))},i=[t,n],e[0]=n,e[1]=t,e[2]=s,e[3]=i):(s=e[2],i=e[3]),J(s,i)},AE=t=>{const e=O(6),{runtime:n,id:r,mainThreadIsRunning:s}=t;let i;e[0]!==r||e[1]!==n?(i=n.getItemById(r),e[0]=r,e[1]=n,e[2]=i):i=e[2];const o=i;let a;return e[3]!==s||e[4]!==o?(a=tf({runtime:o,mainThreadIsRunning:s}),e[3]=s,e[4]=o,e[5]=a):a=e[5],wt(a)},PE=de(AE),ME=t=>{const e=O(48),{runtime:n,__internal_assistantRuntime:r}=t,s=et(n);RE(s.mainThreadId);const i=Bs();let o,a;e[0]!==i||e[1]!==n?(o=()=>n.unstable_subscribeThreadEvents(x=>{const{threadId:k,type:R}=x;k!==n.getState().mainThreadId&&i(`thread.${R}`,{threadId:k})}),a=[n,i],e[0]=i,e[1]=n,e[2]=o,e[3]=a):(o=e[2],a=e[3]),J(o,a);let l;e[4]!==n.main?(l=kE({runtime:n.main}),e[4]=n.main,e[5]=l):l=e[5];const u=Xi(l);let c;e[6]!==u.state||e[7]!==n||e[8]!==s.threadItems?(c=Object.keys(s.threadItems).map(x=>kt(x,PE({runtime:n,id:x,mainThreadIsRunning:u.state.isRunning}),[n,x,u.state.isRunning])),e[6]=u.state,e[7]=n,e[8]=s.threadItems,e[9]=c):c=e[9];const d=lr(c),h=s.newThreadId??null;let f;e[10]!==u.state||e[11]!==s.archivedThreadIds||e[12]!==s.hasMore||e[13]!==s.isLoading||e[14]!==s.isLoadingMore||e[15]!==s.loadError||e[16]!==s.mainThreadId||e[17]!==s.threadIds||e[18]!==h||e[19]!==d.state?(f={mainThreadId:s.mainThreadId,newThreadId:h,isLoading:s.isLoading,loadError:s.loadError,isLoadingMore:s.isLoadingMore,hasMore:s.hasMore,threadIds:s.threadIds,archivedThreadIds:s.archivedThreadIds,threadItems:d.state,main:u.state},e[10]=u.state,e[11]=s.archivedThreadIds,e[12]=s.hasMore,e[13]=s.isLoading,e[14]=s.isLoadingMore,e[15]=s.loadError,e[16]=s.mainThreadId,e[17]=s.threadIds,e[18]=h,e[19]=d.state,e[20]=f):f=e[20];const p=f;let g;e[21]!==p?(g=()=>p,e[21]=p,e[22]=g):g=e[22];let _;e[23]!==u.methods?(_=()=>u.methods,e[23]=u.methods,e[24]=_):_=e[24];let m;e[25]!==p||e[26]!==d?(m=x=>{if(x==="main")return d.get({key:p.mainThreadId});if("id"in x)return d.get({key:x.id});const{index:k,archived:R}=x,M=R!==void 0&&R?p.archivedThreadIds[k]:p.threadIds[k];return d.get({key:M})},e[25]=p,e[26]=d,e[27]=m):m=e[27];let y,v,S,I,b,P;e[28]!==n?(y=(x,k)=>kn("switch",()=>n.switchToThread(x,k)),v=()=>kn("create",()=>n.switchToNewThread()),S=()=>n.getLoadThreadsPromise(),I=()=>n.reload(),b=()=>n.reloadMainThread(),P=()=>n.loadMore(),e[28]=n,e[29]=y,e[30]=v,e[31]=S,e[32]=I,e[33]=b,e[34]=P):(y=e[29],v=e[30],S=e[31],I=e[32],b=e[33],P=e[34]);let A;e[35]!==r?(A=()=>r,e[35]=r,e[36]=A):A=e[36];let D;return e[37]!==y||e[38]!==v||e[39]!==S||e[40]!==I||e[41]!==b||e[42]!==P||e[43]!==A||e[44]!==g||e[45]!==_||e[46]!==m?(D={getState:g,thread:_,item:m,switchToThread:y,switchToNewThread:v,getLoadThreadsPromise:S,reload:I,reloadMainThread:b,loadMore:P,__internal_getAssistantRuntime:A},e[37]=y,e[38]=v,e[39]=S,e[40]=I,e[41]=b,e[42]=P,e[43]=A,e[44]=g,e[45]=_,e[46]=m,e[47]=D):D=e[47],D},DE=de(ME),OE=(t,e)=>{t.thread??(t.thread=xt({source:"threads",query:{type:"main"},get:n=>n.threads.thread("main")})),t.threadListItem??(t.threadListItem=xt({source:"threads",query:{type:"main"},get:n=>n.threads.item("main")})),t.composer??(t.composer=xt({source:"thread",query:{},get:n=>n.threads.thread("main").composer()})),!t.modelContext&&e.modelContext.source===null&&(t.modelContext=c0()),!t.suggestions&&e.suggestions.source===null&&(t.suggestions=xt({source:"thread",query:{},get:n=>n.thread.suggestions()}))},x0=t=>{const e=O(7),n=Yw();let r;e[0]!==n||e[1]!==t?(r=()=>t.registerModelContextProvider(n.current.modelContext()),e[0]=n,e[1]=t,e[2]=r):r=e[2];let s;e[3]!==t?(s=[t],e[3]=t,e[4]=s):s=e[4],Jw("modelContext",r,s);let i;return e[5]!==t?(i=DE({runtime:t.threads,__internal_assistantRuntime:t}),e[5]=t,e[6]=i):i=e[6],wt(i)},NE=de(x0),LE=(t,e)=>{OE(t,e),!t.tools&&e.tools.source===null&&(t.tools=FI({})),!t.dataRenderers&&e.dataRenderers.source===null&&(t.dataRenderers=VC())};Ww(x0,LE);const jE=Ut({}),jm=({effects:t})=>{"use no memo";return rn(t),null},an=Re(function(e,n){"use no memo";const{config:r,children:s}=e,i="extends"in e,o="value"in e,a=Qh();if(e0){if(i&&o)throw new Error("AuiProvider: pass either `extends` or `value`, not both.");if(i&&e.extends===void 0)throw new Error("AuiProvider: `extends` must be a client or null, not undefined.");if(i&&!r)throw new Error("AuiProvider: `extends` requires a `config`.");if(o&&r)throw new Error("AuiProvider: pass either `value` or `config`, not both.");if(!o&&!r)throw new Error("AuiProvider: a `config` is required.");if(!i&&!o&&a!==ks)throw new Error("A parent AuiProvider exists — pass extends={aui} to inherit it or extends={null} to isolate.")}const l=i?e.extends??ks:o?e.value??ks:a,u=lI(),{client:c,effects:d}=s0(l,r??jE,u);return wC(n,()=>c,[c]),T.jsx(ud.Provider,{value:u,children:T.jsxs(Wh.Provider,{value:c,children:[T.jsx(jm,{effects:tI(l)}),d&&T.jsx(jm,{effects:d}),s]})})}),$E=t=>{const e=oe(),n=te(!1),r=n.current?null:t(e);return G(()=>n.current?t(e):r),()=>(n.current=!0,t(e))},zE=Object.freeze({});function Us(t){const e=O(3),{getItemState:n,children:r}=t,s=$E(n);let i;return e[0]!==r||e[1]!==s?(i=r(s),e[0]=r,e[1]=s,e[2]=i):i=e[2],FE(i)}const FE=t=>{const e=typeof t=="object"&&t!=null&&"type"in t?t:null,n=e==null?void 0:e.type,r=e==null?void 0:e.key,s=typeof(e==null?void 0:e.props)=="object"&&e.props!=null&&Object.entries(e.props).length===0?zE:e==null?void 0:e.props;return ge(()=>e,[n,r,s])??t},$m=(t,e)=>{const n=O(11),r=oe(),s=ht(e);let i;n[0]!==t?(i=Kh(t),n[0]=t,n[1]=i):i=n[1];const{scope:o,event:a}=i;let l;n[2]!==r||n[3]!==s||n[4]!==a||n[5]!==o?(l=()=>r.on({scope:o,event:a},s),n[2]=r,n[3]=s,n[4]=a,n[5]=o,n[6]=l):l=n[6];let u;n[7]!==r||n[8]!==a||n[9]!==o?(u=[r,o,a],n[7]=r,n[8]=a,n[9]=o,n[10]=u):u=n[10],J(l,u)},BE=t=>{var e;return(e=t._core)==null?void 0:e.RenderComponent},UE=({runtime:t,aui:e,config:n,children:r})=>{"use no memo";const s=BE(t),i=Ut({...n,threads:NE(t)});return T.jsxs(an,{extends:e,config:i,children:[s&&T.jsx(s,{}),r]})},VE=Ue(t=>{const e=O(5),{runtime:n,aui:r,config:s,children:i}=t,o=r===void 0?null:r;let a;return e[0]!==o||e[1]!==i||e[2]!==s||e[3]!==n?(a=T.jsx(UE,{runtime:n,aui:o,config:s,children:i}),e[0]=o,e[1]=i,e[2]=s,e[3]=n,e[4]=a):a=e[4],a});function _e(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}function Br(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(n=>Br(n,e+1)):_e(t)?Object.entries(t).every(([n,r])=>typeof n=="string"&&Br(r,e+1)):!1}const HE=100,hd=(t,e,n)=>{if(t===e)return!0;if(n>HE||t==null||e==null)return!1;if(Array.isArray(t))return!Array.isArray(e)||t.length!==e.length?!1:t.every((i,o)=>hd(i,e[o],n+1));if(Array.isArray(e)||!_e(t)||!_e(e))return!1;const r=Object.keys(t),s=Object.keys(e);return r.length!==s.length?!1:r.every(i=>Object.hasOwn(e,i)&&hd(t[i],e[i],n+1))},nf=(t,e)=>!Br(t)||!Br(e)?!1:hd(t,e,0),fd={toResponse(t,e){return new Response(fd.toByteStream(t,e),{headers:e.headers??{}})},fromResponse(t,e){return fd.fromByteStream(t.body,e)},toByteStream(t,e){return t.pipeThrough(e)},fromByteStream(t,e){return t.pipeThrough(e)}},zm=Symbol.for("aui.tool-response"),pd="<no result>";var sr=class md{constructor(e){w(this,"artifact");w(this,"result");w(this,"isError");w(this,"modelContent");w(this,"messages");e.artifact!==void 0&&(this.artifact=e.artifact);const n=e.result;this.result=n===void 0?pd:n,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}get[zm](){return!0}static[Symbol.hasInstance](e){return typeof e=="object"&&e!==null&&zm in e}static toResponse(e){return e instanceof md?e:new md({result:e===void 0?pd:e})}};const rf=()=>{let t,e;const n=new Promise((r,s)=>{t=r,e=s});if(!t||!e)throw new Error("Failed to create promise");return{promise:n,resolve:t,reject:e}},qE=()=>{const t=[];let e=!1,n=!1,r=!1,s,i,o=0,a,l;const u=()=>(i=void 0,l??(l=Promise.all(t.splice(0).map(async g=>{try{await g.reader.cancel().catch(()=>{}),await g.pipeTask}finally{g.reader.releaseLock()}})).then(()=>{})),l),c=g=>{n||r||(r=!0,console.error(g),u(),s.error(g),a==null||a.reject(g),a=void 0)},d=g=>{g.promise||(g.promise=g.reader.read().then(({done:_,value:m})=>{g.promise=void 0,!(n||r)&&(_?(t.splice(t.indexOf(g),1),g.reader.releaseLock(),e&&t.length===0&&o===0&&s.close()):s.enqueue(m),a==null||a.resolve(),a=void 0)}).catch(c))},h=new ReadableStream({start(g){s=g},pull(){return a=rf(),t.forEach(g=>{d(g)}),a.promise},async cancel(){n=!0;const g=u();a==null||a.resolve(),a=void 0,await g}}),f=g=>{if(t.length>0&&(i=void 0),!i){const _=[];i=_,o++,Promise.resolve().then(()=>{if(o--,i===_&&(i=void 0),!(n||r)){for(const m of _)s.enqueue(m);e&&t.length===0&&o===0&&s.close(),a==null||a.resolve(),a=void 0}}).catch(c)}i.push(g)};return{readable:h,isSealed(){return e},isCancelled(){return n},isErrored(){return r},seal(){e||n||r||(e=!0,t.length===0&&o===0&&s.close())},addStream:(g,_)=>{const m=_==null?void 0:_.catch(()=>{});if(n||r){g.cancel().catch(()=>{});return}if(e)throw g.cancel().catch(()=>{}),new Error("Cannot add streams after the run callback has settled.");i=void 0;const y={reader:g.getReader(),pipeTask:m};t.push(y),d(y)},enqueue(g){if(!(n||r)){if(e)throw new Error("Cannot add streams after the run callback has settled.");f(g)}}}},S0=t=>t instanceof TypeError,Xt=(t,e,n)=>{try{t.enqueue(e)}catch(r){if(!S0(r))throw r;n==null||n(r)}},b0=t=>{try{t.close()}catch(e){if(!S0(e))throw e}},T0=(t,e)=>new ReadableStream({start(n){var r;return(r=t.start)==null?void 0:r.call(t,e(n))},pull(n){var r;return(r=t.pull)==null?void 0:r.call(t,e(n))},cancel(n){var r;return(r=t.cancel)==null?void 0:r.call(t,n)}}),k0=(t,e)=>{let n;return[T0({start(r){n=r},cancel(r){return e==null?void 0:e(n,r)}},t),n]};var C0=class{constructor(t,e={}){w(this,"_controller");w(this,"_strict");w(this,"_isClosed",!1);w(this,"_warnedDropped",!1);w(this,"_warnDroppedAfterClose",t=>{this._warnedDropped||(this._warnedDropped=!0,console.error(`Dropped text delta for closed stream: ${String(t)}`))});this._controller=t,this._strict=e.strict??!0}append(t){const e={type:"text-delta",path:[],textDelta:t};if(this._isClosed){if(this._strict)throw new TypeError("Cannot append to a closed TextStreamController");return Xt(this._controller,e,this._warnDroppedAfterClose),this}return Xt(this._controller,e),this}close(){this._isClosed||(this._isClosed=!0,Xt(this._controller,{type:"part-finish",path:[]}),b0(this._controller))}};const GE=(t,e={})=>T0(t,n=>new C0(n,e)),Fm=(t={})=>k0(e=>new C0(e,t));var WE=class{constructor(t,e={}){w(this,"_isClosed",!1);w(this,"_mergeTask");w(this,"_controller");w(this,"_argsTextController");this._controller=t;const n=GE({start:s=>{this._argsTextController=s}},e);let r=!1;this._mergeTask=n.pipeTo(new WritableStream({write:s=>{switch(s.type){case"text-delta":r=!0,Xt(this._controller,s);break;case"part-finish":r||Xt(this._controller,{type:"text-delta",textDelta:"{}",path:[]}),Xt(this._controller,{type:"tool-call-args-text-finish",path:[]});break;default:throw new Error(`Unexpected chunk type: ${s.type}`)}}}))}get argsText(){return this._argsTextController}async setResponse(t){if(this._isClosed)return;const e=t.result;Xt(this._controller,{type:"result",path:[],...t.artifact!==void 0?{artifact:t.artifact}:{},result:e===void 0?pd:e,isError:t.isError??!1,...t.modelContent!==void 0?{modelContent:t.modelContent}:{},...t.messages!==void 0?{messages:t.messages}:{}}),await this.close()}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,Xt(this._controller,{type:"part-finish",path:[]}),b0(this._controller))}};const QE=(t={})=>k0(e=>new WE(e,t));var I0=class{constructor(){w(this,"value",-1)}up(){return++this.value}},KE=class extends TransformStream{constructor(t){super({transform(e,n){n.enqueue({...e,path:[t,...e.path]})}})}};(class extends TransformStream{constructor(t){super({transform(e,n){const{path:[r,...s]}=e;if(t!==r)throw new Error(`Path mismatch: expected ${t}, got ${r}`);n.enqueue({...e,path:s})}})}});var YE=class extends TransformStream{constructor(t){const e=new I0,n=new Map;super({transform(r,s){r.type==="part-start"&&r.path.length===0&&n.set(e.up(),t.up());const[i,...o]=r.path;if(i===void 0){s.enqueue(r);return}const a=n.get(i);if(a===void 0)throw new Error("Path not found");s.enqueue({...r,path:[a,...o]})}})}};let E0=(t,e=21)=>(n=e)=>{let r="",s=n|0;for(;s-- >0;)r+=t[Math.random()*t.length|0];return r};const R0=E0("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7);var JE=class A0{constructor(e,n={}){w(this,"_state");w(this,"_parentId");this._state=e||{strict:n.strict??!0,merger:qE(),contentCounter:new I0}}get __internal_isClosed(){return this._state.merger.isSealed()||this._state.merger.isCancelled()||this._state.merger.isErrored()}get __internal_isCancelled(){return this._state.merger.isCancelled()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addTransformedStream(e,n){if(e.locked)throw new TypeError("Cannot merge a stream that is already locked to a reader.");const r=e.pipeTo(n.writable).catch(async s=>{throw await n.writable.abort(s).catch(()=>{}),s});this._state.merger.addStream(n.readable,r)}_addPart(e,n){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:"part-start",part:e,path:[]}),this._addTransformedStream(n,new KE(this._state.contentCounter.value))}merge(e){this._addTransformedStream(e,new YE(this._state.contentCounter))}appendText(e){var n;(((n=this._state.append)==null?void 0:n.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,n){var r;(n!==void 0||((r=this._state.append)==null?void 0:r.kind)!=="reasoning"||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:"reasoning",parentId:this._parentId,controller:this.addReasoningPart(n)}),!(n!==void 0&&e.length===0)&&this._state.append.controller.append(e)}addTextPart(){const[e,n]=Fm({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:"text"}),e),n}addReasoningPart(e){const[n,r]=Fm({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:"reasoning",...e}),n),r}addToolCallPart(e){const n=typeof e=="string"?{toolName:e}:e,r=n.toolName,s=n.toolCallId??R0(),[i,o]=QE({strict:this._state.strict});return this._addPart({type:"tool-call",toolName:r,toolCallId:s,...this._parentId&&{parentId:this._parentId}},i),n.argsText!==void 0&&(o.argsText.append(n.argsText),o.argsText.close()),n.args!==void 0&&(o.argsText.append(JSON.stringify(n.args)),o.argsText.close()),n.response!==void 0&&o.setResponse(n.response),o}_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 n=new A0(this._state);return n._parentId=e,n}close(){var e,n,r,s;(n=(e=this._state.append)==null?void 0:e.controller)==null||n.close(),this._state.merger.seal(),(s=(r=this._state).closeSubscriber)==null||s.call(r)}};function XE(t,e={}){const n=new JE(void 0,e);return(async()=>{try{await t(n)}catch(s){n.__internal_isClosed?n.__internal_isCancelled||console.error(s):n.enqueue({type:"error",path:[],error:String(s)})}finally{n.__internal_isClosed||n.close()}})(),n.__internal_getReadable()}function P0(t={}){const{resolve:e,promise:n}=rf();let r;return[XE(s=>(r=s,r.__internal_subscribeToClose(e),n),t),r]}var ZE=class extends TransformStream{constructor(t,e,n){const[r,s]=P0({strict:t.strict}),i=new AbortController;let o;super({start(u){var c;o=r.pipeTo(new WritableStream({write(d){u.enqueue(d)},abort(d){u.error(d)},close(){u.terminate()}}),{signal:i.signal}).catch(d=>{u.error(d)});try{return(c=t.start)==null?void 0:c.call(t,s)}catch(d){throw i.abort(d),d}},transform(u){var c;return(c=t.transform)==null?void 0:c.call(t,u,s)},async flush(){var u;await((u=t.flush)==null?void 0:u.call(t,s)),s.close(),await o}},e,n);const a=super.readable.getReader();let l=!1;Object.defineProperty(this,"readable",{value:new ReadableStream({start(u){a.closed.catch(c=>{i.abort(c),u.error(c),a.releaseLock()})},async pull(u){const c=await a.read();l||(c.done?(u.close(),a.releaseLock()):u.enqueue(c.value))},async cancel(u){l=!0;const c=a.cancel(u);i.abort(u);try{await c}finally{await o,a.releaseLock()}}},{highWaterMark:0}),writable:!1})}},M0=class extends TransformStream{constructor(t){super();const e=t(super.readable);Object.defineProperty(this,"readable",{value:e,writable:!1})}},Vs={exports:{}};const eR=typeof Buffer<"u",Bm=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Um=/"(?: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 D0(t,e,n){n==null&&e!==null&&typeof e=="object"&&(n=e,e=void 0),eR&&Buffer.isBuffer(t)&&(t=t.toString()),t&&t.charCodeAt(0)===65279&&(t=t.slice(1));const r=JSON.parse(t,e);if(r===null||typeof r!="object")return r;const s=n&&n.protoAction||"error",i=n&&n.constructorAction||"error";if(s==="ignore"&&i==="ignore")return r;if(s!=="ignore"&&i!=="ignore"){if(Bm.test(t)===!1&&Um.test(t)===!1)return r}else if(s!=="ignore"&&i==="ignore"){if(Bm.test(t)===!1)return r}else if(Um.test(t)===!1)return r;return O0(r,{protoAction:s,constructorAction:i,safe:n&&n.safe})}function O0(t,{protoAction:e="error",constructorAction:n="error",safe:r}={}){let s=[t];for(;s.length;){const i=s;s=[];for(const o of i){if(e!=="ignore"&&Object.prototype.hasOwnProperty.call(o,"__proto__")){if(r===!0)return null;if(e==="error")throw new SyntaxError("Object contains forbidden prototype property");delete o.__proto__}if(n!=="ignore"&&Object.prototype.hasOwnProperty.call(o,"constructor")&&o.constructor!==null&&typeof o.constructor=="object"&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype")){if(r===!0)return null;if(n==="error")throw new SyntaxError("Object contains forbidden prototype property");delete o.constructor}for(const a in o){const l=o[a];l&&typeof l=="object"&&s.push(l)}}}return t}function sf(t,e,n){const{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return D0(t,e,n)}finally{Error.stackTraceLimit=r}}function tR(t,e){const{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return D0(t,e,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}Vs.exports=sf;Vs.exports.default=sf;Vs.exports.parse=sf;Vs.exports.safeParse=tR;Vs.exports.scan=O0;var nR=Vs.exports;const gd=pl(nR);var N0=class extends TransformStream{constructor(){const t=[];super({transform(e,n){if(e.type==="part-start"){if(e.path.length!==0){n.error(new Error("Nested parts are not supported"));return}t.push(e.part),n.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){n.error(new Error(`${e.type} chunks must have a path of length 1`));return}const r=e.path[0];if(r<0||r>=t.length){n.error(new Error(`Invalid path index: ${r}`));return}const s=t[r];n.enqueue({...e,meta:s});return}n.enqueue(e)}})}};const rR=/[0-9a-fA-F]/;function sR(t){const e=["ROOT"];let n=-1,r=null,s=0;const i=[];let o;function a(){o!==void 0&&(i.push(JSON.parse(`"${o}"`)),o=void 0)}function l(h,f,p){switch(h){case'"':n=f,e.pop(),e.push(p),e.push("INSIDE_STRING"),a();break;case"f":case"t":case"n":n=f,r=f,e.pop(),e.push(p),e.push("INSIDE_LITERAL");break;case"-":e.pop(),e.push(p),e.push("INSIDE_NUMBER"),a();break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n=f,e.pop(),e.push(p),e.push("INSIDE_NUMBER"),a();break;case"{":n=f,e.pop(),e.push(p),e.push("INSIDE_OBJECT_START"),a();break;case"[":n=f,e.pop(),e.push(p),e.push("INSIDE_ARRAY_START"),a()}}function u(h,f){switch(h){case",":e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break;case"}":n=f,e.pop(),o=i.pop()}}function c(h,f){switch(h){case",":e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA"),o=(Number(o)+1).toString();break;case"]":n=f,e.pop(),o=i.pop()}}for(let h=0;h<t.length;h++){const f=t[h];switch(e[e.length-1]){case"ROOT":l(f,h,"FINISH");break;case"INSIDE_OBJECT_START":switch(f){case'"':e.pop(),e.push("INSIDE_OBJECT_KEY"),o="";break;case"}":n=h,e.pop(),o=i.pop()}break;case"INSIDE_OBJECT_AFTER_COMMA":switch(f){case'"':e.pop(),e.push("INSIDE_OBJECT_KEY"),o=""}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;case"INSIDE_OBJECT_AFTER_KEY":switch(f){case":":e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE")}break;case"INSIDE_OBJECT_BEFORE_VALUE":l(f,h,"INSIDE_OBJECT_AFTER_VALUE");break;case"INSIDE_OBJECT_AFTER_VALUE":u(f,h);break;case"INSIDE_STRING":switch(f){case'"':e.pop(),n=h,o=i.pop();break;case"\\":e.push("INSIDE_STRING_ESCAPE");break;default:n=h}break;case"INSIDE_ARRAY_START":switch(f){case"]":n=h,e.pop(),o=i.pop();break;default:o="0",l(f,h,"INSIDE_ARRAY_AFTER_VALUE")}break;case"INSIDE_ARRAY_AFTER_VALUE":switch(f){case",":e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA"),o=(Number(o)+1).toString();break;case"]":n=h,e.pop(),o=i.pop();break;default:n=h}break;case"INSIDE_ARRAY_AFTER_COMMA":l(f,h,"INSIDE_ARRAY_AFTER_VALUE");break;case"INSIDE_STRING_ESCAPE":{e.pop();const p=e[e.length-1];f==="u"?(e.push("INSIDE_STRING_UNICODE_ESCAPE"),s=0):p==="INSIDE_STRING"&&(n=h),p==="INSIDE_OBJECT_KEY"&&(o+=f);break}case"INSIDE_STRING_UNICODE_ESCAPE":{const p=e[e.length-2];if(!rR.test(f)){e.pop(),h--;break}s++,s===4&&(e.pop(),p==="INSIDE_STRING"&&(n=h)),p==="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":n=h;break;case"e":case"E":case"-":case"+":case".":break;case",":e.pop(),o=i.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&c(f,h),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&u(f,h);break;case"}":e.pop(),o=i.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&u(f,h);break;case"]":e.pop(),o=i.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&c(f,h);break;default:e.pop(),o=i.pop()}break;case"INSIDE_LITERAL":{const p=t.substring(r,h+1);!"false".startsWith(p)&&!"true".startsWith(p)&&!"null".startsWith(p)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?u(f,h):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&c(f,h)):n=h;break}}}let d=t.slice(0,n+1);for(let h=e.length-1;h>=0;h--)switch(e[h]){case"INSIDE_STRING":d+='"';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":d+="}";break;case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":d+="]";break;case"INSIDE_LITERAL":{const f=t.substring(r,t.length);"true".startsWith(f)?d+="true".slice(f.length):"false".startsWith(f)?d+="false".slice(f.length):"null".startsWith(f)&&(d+="null".slice(f.length))}}return[d,i]}const _a=Symbol("aui.parse-partial-json-object.meta"),iR=t=>t==null?void 0:t[_a],tl=t=>{if(t.length===0)return{[_a]:{state:"partial",partialPath:[]}};try{const e=gd.parse(t);if(typeof e!="object"||e===null)throw new Error("argsText is expected to be an object");return e[_a]={state:"complete",partialPath:[]},e}catch{try{const[e,n]=sR(t),r=gd.parse(e);if(typeof r!="object"||r===null)throw new Error("argsText is expected to be an object");return r[_a]={state:"partial",partialPath:n},r}catch{return}}},L0=(t,e,n)=>{if(typeof t!="object"||t===null)return e.state;if(e.state==="complete")return"complete";if(n.length===0)return e.state;const[r,...s]=n;if(!Object.hasOwn(t,r))return"partial";const[i,...o]=e.partialPath;if(r!==i)return"complete";const a=t[r];return L0(a,{state:"partial",partialPath:o},s)},eo=(t,e)=>{const n=iR(t);if(!n)throw new Error("unable to determine object state");return L0(t,n,e.map(String))},oR=new Set(["__proto__","constructor","prototype"]);function aR(t){if(oR.has(t))throw new Error(`Unsafe gorp path segment: ${t}`)}var lR=class{constructor(t=null,e={}){w(this,"_state");w(this,"_strict");w(this,"_logged",new Set);w(this,"_warnedClamp",!1);this._state=t,this._strict=e.strict??!0}get state(){return this._state}logOnce(t,e){this._logged.has(t)||this._logged.size>=20||(this._logged.add(t),e())}append(t){this._state=t.reduce((e,n)=>{if(this._strict)return this.apply(e,n);try{return this.apply(e,n)}catch(r){return this.logOnce(`skip:${String(r)}`,()=>console.error(`Skipped unappliable gorp operation: ${String(r)}`,n)),e}},this._state)}apply(t,e){const n=e.type;switch(n){case"set":return this.updatePath(t,e.path,()=>e.value);case"append-text":return this.updatePath(t,e.path,r=>{if(typeof r!="string")throw new Error(`Expected string at path [${e.path.join(", ")}]`);return r+e.value});default:throw new Error(`Invalid operation type: ${n}`)}}updatePath(t,e,n){if(e.length===0)return n(t);const r=[];let s=t;for(let o=0;o<e.length;o++){if(s??(s={}),typeof s!="object")throw new Error(`Invalid path: [${e.slice(o).join(", ")}]`);const a=e[o];if(aR(a),Array.isArray(s)){let l=Number(a);if(!Number.isInteger(l)||String(l)!==String(a))throw new Error(`Expected array index at [${e.slice(o).join(", ")}]`);if(l<0)throw new Error("Insert array index out of bounds");if(l>s.length){if(this._strict)throw new Error("Insert array index out of bounds");this._warnedClamp||(this._warnedClamp=!0,console.warn(`Clamped out-of-bounds gorp array index ${l} to ${s.length}`)),l=s.length}r.push({kind:"array",state:s,key:l}),s=Object.hasOwn(s,l)?s[l]:void 0}else{const l=s;r.push({kind:"object",state:l,key:a}),s=Object.hasOwn(l,a)?l[a]:void 0}}let i=n(s);for(let o=r.length-1;o>=0;o--){const a=r[o];if(a.kind==="array"){const l=[...a.state];l[a.key]=i,i=l}else{const l={...a.state};l[a.key]=i,i=l}}return i}},uR=class{constructor(){w(this,"_streamStartTime");w(this,"_firstTokenTime");w(this,"_totalChunks",0);w(this,"_toolCallIds",new Set);this._streamStartTime=Date.now()}recordChunk(){this._totalChunks++}recordFirstToken(){this._firstTokenTime===void 0&&(this._firstTokenTime=Date.now())}recordToolCallStart(t){this._toolCallIds.add(t)}getTiming(t,e){const n=Date.now()-this._streamStartTime,r=t&&t>0?t:e?Math.ceil(e.length/4):void 0,s=r&&n>0?r/n*1e3:void 0;return{streamStartTime:this._streamStartTime,...this._firstTokenTime!==void 0?{firstTokenTime:this._firstTokenTime-this._streamStartTime}:void 0,totalStreamTime:n,...r!==void 0?{tokenCount:r}:void 0,...s!==void 0?{tokensPerSecond:s}:void 0,totalChunks:this._totalChunks,toolCallCount:this._toolCallIds.size}}};const j0=(t,e)=>({...t,parts:e,get content(){return this.parts}}),ns=(t,e)=>j0(t,[...t.parts,e]),cR=({unstable_state:t=null}={})=>({role:"assistant",status:{type:"running"},parts:[],get content(){return this.parts},metadata:{unstable_state:t,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}),dR=16,Bl=(t,e,n,r)=>{const s=e.path.length===1?t.parts[e.path[0]]:void 0;if(s===void 0)return n(`no-part:${e.type}`,`Dropped ${e.type} chunk: no part at path [${e.path.join(", ")}]`),t;const i=e.path[0],o=r(s);return o===s?t:j0(t,[...t.parts.slice(0,i),o,...t.parts.slice(i+1)])},hR=(t,e,n)=>{const r=e.part;if(r.type==="text"||r.type==="reasoning"){const s={type:r.type,text:"",status:{type:"running"},...r.type==="reasoning"&&r.unstable_summary!==void 0?{unstable_summary:r.unstable_summary}:void 0,...r.parentId&&{parentId:r.parentId}};return ns(t,s)}else if(r.type==="tool-call"){const s={type:"tool-call",state:"partial-call",status:{type:"running",isArgsComplete:!1},toolCallId:r.toolCallId,toolName:r.toolName,argsText:"",args:{},timing:{startedAt:Date.now()},...r.parentId&&{parentId:r.parentId}};return ns(t,s)}else if(r.type==="source"){const s={type:"source",sourceType:r.sourceType,id:r.id,url:r.url,...r.title?{title:r.title}:void 0,...r.parentId&&{parentId:r.parentId}};return ns(t,s)}else if(r.type==="file"){const s={type:"file",mimeType:r.mimeType,data:r.data,...r.parentId&&{parentId:r.parentId}};return ns(t,s)}else if(r.type==="data"){const s={type:"data",name:r.name,data:r.data,...r.parentId&&{parentId:r.parentId}};return ns(t,s)}else{const s=String(r.type);return n(`unsupported-part-start:${s}`,`Unsupported part-start type ${s}: inserting an empty reasoning part to preserve part indices`),ns(t,{type:"reasoning",text:"",status:{type:"running"}})}},fR=(t,e,n)=>Bl(t,e,n,r=>r.type!=="tool-call"?(n("wrong-part:tool-call-args-text-finish","Dropped tool-call-args-text-finish chunk: part is not a tool-call"),r):r.state!=="partial-call"?r:{...r,state:"call",status:r.status.type==="running"?{type:"running",isArgsComplete:!0}:r.status}),pR=(t,e,n)=>Bl(t,e,n,r=>({...r,status:{type:"complete",reason:"unknown"}})),mR=(t,e,n)=>Bl(t,e,n,r=>{if(r.type==="text"||r.type==="reasoning")return{...r,text:r.text+e.textDelta};if(r.type==="tool-call"){const s=r.argsText+e.textDelta,i=tl(s)??r.args;return{...r,argsText:s,args:i}}else return n("wrong-part:text-delta","Dropped text-delta chunk: part is neither text nor tool-call"),r}),gR=(t,e,n)=>Bl(t,e,n,r=>r.type==="tool-call"?{...r,state:"result",...r.timing!==void 0?{timing:{...r.timing,completedAt:r.timing.completedAt??Date.now()}}:{},...e.artifact!==void 0?{artifact:e.artifact}:{},result:e.result,isError:e.isError??!1,...e.modelContent!==void 0?{modelContent:e.modelContent}:{},...e.messages!==void 0?{messages:e.messages}:{},status:{type:"complete",reason:"stop"}}:(n("wrong-part:result","Dropped result chunk: part is not a tool-call"),r)),Vm=(t,e)=>{var r,s;if(((r=t.status)==null?void 0:r.type)==="incomplete"&&((s=t.status)==null?void 0:s.reason)==="error")return t;const n=yR(e);return{...t,status:n}},yR=t=>t.finishReason==="tool-calls"?{type:"requires-action",reason:"tool-calls"}:t.finishReason==="stop"||t.finishReason==="unknown"?{type:"complete",reason:t.finishReason}:{type:"incomplete",reason:t.finishReason},vR=(t,e)=>({...t,metadata:{...t.metadata,unstable_annotations:[...t.metadata.unstable_annotations,...e.annotations]}}),_R=(t,e)=>({...t,metadata:{...t.metadata,unstable_data:[...t.metadata.unstable_data,...e.data]}}),wR=(t,e)=>({...t,metadata:{...t.metadata,steps:[...t.metadata.steps,{state:"started",messageId:e.messageId}]}}),xR=(t,e)=>{var s;const n=t.metadata.steps.slice(),r=n.length-1;return n.length>0&&((s=n[r])==null?void 0:s.state)==="started"?n[r]={...n[r],state:"finished",finishReason:e.finishReason,usage:e.usage,isContinued:e.isContinued}:n.push({state:"finished",messageId:R0(),finishReason:e.finishReason,usage:e.usage,isContinued:e.isContinued}),{...t,metadata:{...t.metadata,steps:n}}},SR=(t,e)=>{const n=e.severity==="critical"||e.severity==="warning"||e.severity==="info"?e.severity:void 0;return{...t,status:{type:"incomplete",reason:"error",error:{code:e.code??"unknown",message:e.error??"unknown error",...n!==void 0&&{severity:n}}}}},bR=(t,e,n)=>(n.append(e.operations),{...t,metadata:{...t.metadata,unstable_state:n.state}}),TR=t=>{let e=0;for(const n of t.metadata.steps)n.state==="finished"&&n.usage&&(e+=n.usage.outputTokens);return e},Hm=(t,e,n=0)=>{const r=n>0?n:TR(e);if(r>0)return t.getTiming(r);let s="";for(const i of e.parts)(i.type==="text"||i.type==="reasoning")&&(s+=i.text);return t.getTiming(void 0,s||void 0)},kR=t=>{let e=!1;return()=>{e||(e=!0,queueMicrotask(()=>{e=!1,t()}))}};var CR=class extends TransformStream{constructor({initialMessage:t,throttle:e,onError:n,strict:r=!0}={}){let s=t??cR(),i,o;const a=new uR,l=new Set,u=(h,f)=>{l.has(h)||l.size>=dR||(l.add(h),console.warn(f))};let c;const d=e?kR(()=>{c==null||c.enqueue(s)}):()=>{c==null||c.enqueue(s)};super({start(h){c=h},transform(h){var p;a.recordChunk();const f=h.type;switch(f){case"part-start":s=hR(s,h,u),h.part.type==="tool-call"&&a.recordToolCallStart(h.part.toolCallId);break;case"tool-call-args-text-finish":s=fR(s,h,u);break;case"part-finish":s=pR(s,h,u);break;case"text-delta":{const g=mR(s,h,u);g!==s&&a.recordFirstToken(),s=g;break}case"result":s=gR(s,h,u);break;case"message-finish":o=(p=h.usage)==null?void 0:p.outputTokens,s=Vm(s,h);break;case"annotations":s=vR(s,h);break;case"data":s=_R(s,h);break;case"step-start":s=wR(s,h);break;case"step-finish":s=xR(s,h);break;case"error":s=SR(s,h),n==null||n(h.error);break;case"update-state":i??(i=new lR(s.metadata.unstable_state,{strict:r})),s=bR(s,h,i);break;default:throw new Error(`Unsupported chunk type: ${f}`)}s.status.type!=="running"&&(s={...s,metadata:{...s.metadata,timing:Hm(a,s,o)}}),d()},flush(h){var f,p;if(((f=s.status)==null?void 0:f.type)==="running"){const g=((p=s.parts)==null?void 0:p.some(_=>_.type==="tool-call"&&(_.state==="call"||_.state==="partial-call")&&_.result===void 0))??!1;s=Vm(s,{finishReason:g?"tool-calls":"unknown"}),s={...s,metadata:{...s.metadata,timing:Hm(a,s,o)}},h.enqueue(s)}}})}},IR=class extends M0{constructor(){super(t=>{const e=new ZE({transform(n,r){r.appendText(n)}});return t.pipeThrough(new TextDecoderStream).pipeThrough(e)})}};async function*ER(){const t=this.getReader();let e=!0;try{for(;;){let n;try{n=await t.read()}catch(s){throw e=!1,s}if(n.done){e=!1;break}const{value:r}=n;yield r}}finally{try{e&&await t.cancel()}finally{t.releaseLock()}}}function wa(t){var e;return t[e=Symbol.asyncIterator]??(t[e]=ER),t}var RR=class xa{constructor(e){w(this,"readable");this.readable=e}static fromAssistantStream(e){return new xa(e.pipeThrough(new CR))}async unstable_result(){let e;for await(const n of this)e=n;return e||{role:"assistant",status:{type:"complete",reason:"unknown"},parts:[],content:[],metadata:{unstable_state:null,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}}[Symbol.asyncIterator](){return wa(this.readable)[Symbol.asyncIterator]()}tee(){const[e,n]=this.readable.tee();return[new xa(e),new xa(n)]}};function AR(t,e,n){try{const r=t();if(typeof r=="object"&&r!==null&&"then"in r)return r.then(e,n);e(r)}catch(r){n(r)}}function to(t,e){let n=t;for(const r of e){if(n==null||!Object.hasOwn(n,r))return;n=n[r]}return n}var PR=class{constructor(t,e,n){w(this,"resolve");w(this,"reject");w(this,"disposed",!1);w(this,"fieldPath");this.resolve=t,this.reject=e,this.fieldPath=n}get isDisposed(){return this.disposed}update(t){if(!this.disposed)try{if(eo(t,this.fieldPath)==="complete"){const e=to(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=to(t,this.fieldPath);this.resolve(e)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},MR=class{constructor(t,e){w(this,"controller");w(this,"disposed",!1);w(this,"fieldPath");this.controller=t,this.fieldPath=e}get isDisposed(){return this.disposed}update(t){if(!this.disposed)try{const e=to(t,this.fieldPath);e!==void 0&&this.controller.enqueue(e),eo(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}},DR=class{constructor(t,e){w(this,"controller");w(this,"disposed",!1);w(this,"fieldPath");w(this,"lastValue");this.controller=t,this.fieldPath=e}get isDisposed(){return this.disposed}update(t){var e;if(!this.disposed)try{const n=to(t,this.fieldPath);if(n!==void 0&&typeof n=="string"){const r=n.substring(((e=this.lastValue)==null?void 0:e.length)||0);this.lastValue=n,this.controller.enqueue(r)}eo(t,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(n){this.controller.error(n),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},OR=class{constructor(t,e){w(this,"controller");w(this,"disposed",!1);w(this,"fieldPath");w(this,"nextIndex",0);this.controller=t,this.fieldPath=e}get isDisposed(){return this.disposed}update(t){if(!this.disposed)try{const e=to(t,this.fieldPath);if(!Array.isArray(e))return;for(;this.nextIndex<e.length;this.nextIndex++){const n=[...this.fieldPath,this.nextIndex];if(eo(t,n)!=="complete")break;this.controller.enqueue(e[this.nextIndex])}eo(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}},NR=class{constructor(t){w(this,"argTextDeltas");w(this,"handles",new Set);w(this,"accumulatedText","");w(this,"parsedTextLength",-1);w(this,"args");w(this,"finished",!1);this.argTextDeltas=t,this.processStream()}async processStream(){try{const t=this.argTextDeltas.getReader();for(;;){const{value:e,done:n}=await t.read();if(n)break;this.accumulatedText+=e,this.handles.size!==0&&this.parseCurrentArgs()&&this.updateHandles()}}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()}}parseCurrentArgs(){if(this.parsedTextLength===this.accumulatedText.length)return!1;const t=tl(this.accumulatedText);return this.parsedTextLength=this.accumulatedText.length,t===void 0?(this.args??(this.args=tl("")),!1):(this.args=t,!0)}updateHandles(){for(const t of this.handles)t.update(this.args),t.isDisposed&&this.handles.delete(t)}activateHandle(t){if(this.parseCurrentArgs(),t.update(this.args),!t.isDisposed){if(this.finished){t.end(this.args);return}this.handles.add(t)}}get(...t){return new Promise((e,n)=>{const r=new PR(e,n,t);this.activateHandle(r)})}streamValues(...t){const e=t;let n;const r=new ReadableStream({start:s=>{n=new MR(s,e),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}});return wa(r)}streamText(...t){const e=t;let n;const r=new ReadableStream({start:s=>{n=new DR(s,e),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}});return wa(r)}forEach(...t){const e=t;let n;const r=new ReadableStream({start:s=>{n=new OR(s,e),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}});return wa(r)}},LR=class{constructor(t){w(this,"promise");this.promise=t}get(){return this.promise}},jR=class{constructor(){w(this,"args");w(this,"response");w(this,"writable");w(this,"resolve");w(this,"argsText","");w(this,"result",{get:async()=>(await this.response.get()).result});const t=new TransformStream;this.writable=t.writable,this.args=new NR(t.readable);const{promise:e,resolve:n}=rf();this.resolve=n,this.response=new LR(e)}async appendArgsTextDelta(t){const e=this.writable.getWriter();try{await e.write(t)}catch(n){console.warn(n)}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)}};const $R=Symbol.for("assistant-stream.tool-execution-id"),Tu=(t,e,n,r,s)=>{try{const i=e==null?void 0:e(n,r,s);Promise.resolve(i).catch(o=>{console.error(`[assistant-stream] ${t} callback threw an error`,o)})}catch(i){console.error(`[assistant-stream] ${t} callback threw an error`,i)}},rs=t=>t.join(","),ku=(t,e)=>{const n={...t};return Object.defineProperty(n,$R,{value:e,enumerable:!0}),n};var zR=class extends M0{constructor(t){const e=t,n=new Map,r=new Map,s=new Set,i=new Map;let o=0;super(a=>{const l=new TransformStream({async transform(u,c){const d=i.get(rs(u.path));switch((u.type!=="part-finish"||u.meta.type!=="tool-call")&&c.enqueue(d?ku(u,d):u),u.type){case"part-start":{const h=o;if(o+=1,u.part.type==="tool-call"){const f=new jR,p=Symbol();i.set(String(h),p),r.set(p,f),e.streamCall({reader:f,toolCallId:u.part.toolCallId,toolName:u.part.toolName,executionId:p})}break}case"text-delta":if(u.meta.type==="tool-call"){const h=i.get(rs(u.path)),f=h?r.get(h):void 0;if(!f)throw new Error("No controller found for tool call");await f.appendArgsTextDelta(u.textDelta)}break;case"result":{if(u.meta.type!=="tool-call")break;const h=i.get(rs(u.path)),f=h?r.get(h):void 0;if(!f)throw new Error("No controller found for tool call");f.setResponse(new sr({result:u.result,artifact:u.artifact,isError:u.isError,modelContent:u.modelContent,messages:u.messages})),s.add(h);break}case"tool-call-args-text-finish":{if(u.meta.type!=="tool-call")break;const{toolCallId:h,toolName:f}=u.meta,p=i.get(rs(u.path)),g=p?r.get(p):void 0;if(!g)throw new Error("No controller found for tool call");if(await g.finishArgsText(),s.has(p))break;let _=!1;const m=AR(()=>{let y;try{y=gd.parse(g.argsText)}catch(S){throw new Error(`Function parameter parsing failed. ${JSON.stringify(S.message)}`)}const v=e.execute({toolCallId:h,toolName:f,args:y,executionId:p});return v!==void 0&&(_=!0,Tu("onExecutionStart",e.onExecutionStart,h,f,p)),v},y=>{if(_&&Tu("onExecutionEnd",e.onExecutionEnd,h,f,p),y===void 0)return;const v=new sr({artifact:y.artifact,result:y.result,isError:y.isError,messages:y.messages,modelContent:y.modelContent});g.setResponse(v),Xt(c,ku({type:"result",path:u.path,...v},p))},y=>{_&&Tu("onExecutionEnd",e.onExecutionEnd,h,f,p);const v=new sr({result:String(y),isError:!0});g.setResponse(v),Xt(c,ku({type:"result",path:u.path,...v},p))});m&&n.set(p,m);break}case"part-finish":{if(u.meta.type!=="tool-call")break;const h=i.get(rs(u.path)),f=h?n.get(h):void 0,p=()=>{h&&(n.delete(h),r.delete(h),s.delete(h),i.delete(rs(u.path)))};f?f.then(()=>{p(),Xt(c,u)}):(p(),c.enqueue(u))}}},async flush(){await Promise.all(n.values())}});return a.pipeThrough(new N0).pipeThrough(l)})}};const $0=Symbol.for("assistant-stream.tool-execution-id"),nl=Symbol("assistant-stream.tool-aborted"),FR=t=>typeof t=="object"&&t!==null&&"~standard"in t&&t["~standard"].version===1,BR=t=>typeof(t==null?void 0:t.then)=="function",qm=async(t,e,n=!1)=>{let r;const s=new Promise(i=>{r=()=>{n?queueMicrotask(()=>queueMicrotask(()=>i(nl))):i(nl)},e.aborted?r():e.addEventListener("abort",r,{once:!0})});try{return await Promise.race([t,s])}finally{e.removeEventListener("abort",r)}},Qo=()=>new sr({result:"Tool execution was cancelled.",isError:!0});function UR(t,e,n,r){const s=t==null?void 0:t[n.toolName];return s!=null&&s.execute?(async o=>{if(e.aborted)return Qo();let a=o;if(FR(s.parameters)){const c=s.parameters["~standard"].validate(n.args),d=BR(c)?await qm(c,e):c;if(d===nl)return Qo();d.issues&&(a=s.experimental_onSchemaValidationError??(()=>{throw new Error(`Function parameter validation failed. ${JSON.stringify(d.issues)}`)}))}if(e.aborted)return Qo();const l=(async()=>{const c={toolCallId:n.toolCallId,abortSignal:e,human:f=>r(n.toolCallId,f,n.executionId),[$0]:n.executionId},d=await a(n.args,c),h=sr.toResponse(d);if(s.toModelOutput&&!h.isError&&h.modelContent===void 0)try{const f=await s.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:h.result});return new sr({result:h.result,artifact:h.artifact,isError:h.isError,messages:h.messages,modelContent:f})}catch(f){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,f)}return h})(),u=await qm(l,e,!0);return u===nl?Qo():u})(s.execute):void 0}function VR(t,e,n,r,s){var o,a;const i={toolCallId:r.toolCallId,abortSignal:e,human:l=>s(r.toolCallId,l,r.executionId),[$0]:r.executionId};(a=(o=t==null?void 0:t[r.toolName])==null?void 0:o.streamCall)==null||a.call(o,n,i)}function HR(t,e,n,r){const s=typeof t=="function"?t:()=>t,i=typeof e=="function"?e:()=>e,o=r,a=n,l={execute:u=>UR(s(),i(),u,a),streamCall:({reader:u,...c})=>VR(s(),i(),u,c,a),onExecutionStart:o==null?void 0:o.onExecutionStart,onExecutionEnd:o==null?void 0:o.onExecutionEnd};return new zR(l)}function qR(t){const e=t.metadata;if(!e||typeof e!="object")return;const n=e.custom;if(!n||typeof n!="object")return;const r=n.interactables;return Array.isArray(r)?r:void 0}function GR(t){return`update_${t.replace(/[^a-zA-Z0-9_-]/g,"_")}`}const Cu=t=>{if(!_e(t))return;const e=t.id;return typeof e=="string"||typeof e=="number"?e:void 0};function WR(t,e,n){let r=Array.isArray(e.set)?[...e.set]:[...t];if(e.clear===!0&&(r=[]),Array.isArray(e.remove)&&e.remove.length>0){const i=new Set(e.remove);r=r.filter(o=>{const a=Cu(o);return a!==void 0?!i.has(a):!i.has(o)})}const s=e.update;if(Array.isArray(s)&&s.length>0){const i=new Map;for(const o of s){const a=Cu(o);a!==void 0&&!Number.isNaN(a)&&!i.has(a)&&i.set(a,o)}r=r.map(o=>{const a=Cu(o);if(a===void 0||!_e(o))return o;const l=i.get(a);return l?{...o,...l}:o})}if(Array.isArray(e.add)&&e.add.length>0){const i=n?e.add.map(o=>{if(!_e(o)||o.id!==void 0)return o;const a=n();return a===void 0?o:{...o,id:a}}):e.add;r=[...r,...i]}return r}function Iu(t,e,n){if(!_e(t)||!_e(e))return e;const r=_e(n==null?void 0:n.arrayBaseline)?n.arrayBaseline:t,s=Object.entries(t);for(const[i,o]of Object.entries(e)){const a=r[i];if(Array.isArray(a)&&_e(o)){const l=n!=null&&n.idFactory&&(n.idKeyedFields===void 0||n.idKeyedFields.has(i))?()=>{var u;return(u=n.idFactory)==null?void 0:u.call(n,i)}:void 0;s.push([i,WR(a,o,l)])}else s.push([i,o])}return Object.fromEntries(s)}function QR(t,e){if(!_e(t)||!_e(e))return;for(const s of Object.keys(t))if(!Object.hasOwn(e,s))return;const n=[];for(const[s,i]of Object.entries(e))(!Object.hasOwn(t,s)||!nf(t[s],i))&&n.push([s,i]);const r=n.length;if(!(r===0||r===Object.keys(e).length))return Object.fromEntries(n)}const KR=t=>{if(!t||typeof t!="object")return;const e=t;return e.type==="tool-call"?e:void 0},YR=(t,e)=>{if(!t.args||typeof t.args!="object")return!1;const n=_e(t.result)?t.result:void 0;if((n==null?void 0:n.success)===!1)return!1;if(typeof(n==null?void 0:n.id)=="string")return n.id===e;const r=t.args.id;return r===e||r===void 0},JR=t=>{const e=_e(t)?t.addedItemIds:void 0;if(!_e(e))return;const n=new Map;for(const[r,s]of Object.entries(e)){if(!Array.isArray(s))continue;const i=s.filter(o=>typeof o=="string");i.length>0&&n.set(r,i)}if(n.size!==0)return r=>{var s;return(s=n.get(r))==null?void 0:s.shift()}},Gm=new WeakMap;function XR(t,e,n){var u;let r=Gm.get(t);r||(r=new Map,Gm.set(t,r));let s=r.get(n);s||(s=new Map,r.set(n,s));const i=s.get(e);if(i)return i;const o=GR(n),a=[],l=()=>a[a.length-1];for(const c of t){if(c.role==="user"){const d=(u=qR(c))==null?void 0:u.find(h=>h.id===e);if(!d)continue;if(d.partial){const h=l();h&&a.push({state:Iu(h.state,d.state),origin:"user-edit"})}else a.push({state:d.state,origin:"user-edit"});continue}if(c.role==="assistant")for(const d of c.content??[]){const h=KR(d);if(h){if(h.toolCallId===e&&h.toolName===n)h.args&&typeof h.args=="object"&&a.push({state:h.args,origin:"create",toolCallId:e});else if(h.toolName===o&&YR(h,e)){const f=l();if(f){const{id:p,...g}=h.args,_=JR(h.result);a.push({state:_?Iu(f.state,g,{idFactory:_}):Iu(f.state,g),origin:"update",toolCallId:h.toolCallId})}}}}}return s.set(e,a),a}function ZR(t,e,n){const r=XR(t,e,n),s=r[r.length-1];return s?{state:s.state}:void 0}function eA(t,e){if(!t)return;const{interactables:n,...r}=t,s={...r};if(Array.isArray(n)){const i=[];for(const o of n){const a=ZR(e,o.id,o.name);if(!a){i.push({id:o.id,name:o.name,state:o.state});continue}if(nf(o.state,a.state))continue;const l=QR(a.state,o.state);i.push(l?{id:o.id,name:o.name,state:l,partial:!0}:{id:o.id,name:o.name,state:o.state})}i.length&&(s.interactables=i)}return Object.keys(s).length?s:void 0}const rl=Rt(null),tA=(t,e)=>So(rl,t,e),of=()=>At(rl),nA={},rA=t=>{const e=Za(t??nA);return t==null?null:e},Ur=Symbol("innerMessage"),Eu=Symbol("innerMessages"),sA=[],Wm=(t,e)=>{Ur in t||(t[Ur]=e)},iA=t=>{const e="messages"in t?t.messages:t,n=e[Eu]||e[Ur];return n?Array.isArray(n)?n:(e[Eu]=[n],e[Eu]):sA},oA="__external_store_fallback_",Ct=E0("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7);function aA(t){const e=t.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return e?{mimeType:e[1].toLowerCase(),data:e[2]}:null}const Ru=(t,e)=>{if(t.startsWith("data-"))return{type:"data",name:t.substring(5),data:e}},Os=(t,e,n)=>{const{role:r,id:s,createdAt:i,attachments:o,status:a,metadata:l}=t,u={id:s??e,createdAt:i??new Date},c=typeof t.content=="string"?[{type:"text",text:t.content}]:t.content,d=({image:h,...f})=>{var p;return typeof h!="string"?null:(p=aA(h))!=null&&p.mimeType.startsWith("image/")?{...f,image:h}:/^(https:\/\/|blob:)/i.test(h)?{...f,image:h}:(console.warn("Invalid image data format detected"),null)};if(r!=="user"&&(o!=null&&o.length))throw new Error("attachments are only supported for user messages");if(r!=="assistant"&&a)throw new Error("status is only supported for assistant messages");if(r!=="assistant"&&(l!=null&&l.steps))throw new Error("metadata.steps is only supported for assistant messages");switch(r){case"assistant":return{...u,role:r,content:c.map(h=>{var p,g,_;const f=h.type;switch(f){case"text":return(p=h.text)!=null&&p.trim()?h:null;case"reasoning":return!((g=h.text)!=null&&g.trim())&&!((_=h.unstable_summary)!=null&&_.trim())?null:h;case"file":case"source":return h;case"image":return d(h);case"data":return h;case"generative-ui":return h;case"tool-call":{const{parentId:m,messages:y,...v}=h,S={...v,toolCallId:h.toolCallId||`tool-${Ct()}`,...m!==void 0&&{parentId:m},...y!==void 0&&{messages:y}};return h.args?{...S,args:h.args,argsText:h.argsText??JSON.stringify(h.args)}:{...S,args:tl(h.argsText??"")??{},argsText:h.argsText??""}}default:{const m=Ru(f,h.data);if(m)return m;throw new Error(`Unsupported assistant message part type: ${f}`)}}}).filter(h=>!!h),status:a??n,metadata:{unstable_state:(l==null?void 0:l.unstable_state)??null,unstable_annotations:(l==null?void 0:l.unstable_annotations)??[],unstable_data:(l==null?void 0:l.unstable_data)??[],custom:(l==null?void 0:l.custom)??{},steps:(l==null?void 0:l.steps)??[],...(l==null?void 0:l.timing)&&{timing:l.timing},...(l==null?void 0:l.submittedFeedback)&&{submittedFeedback:l.submittedFeedback},...(l==null?void 0:l.isOptimistic)&&{isOptimistic:!0},...(l==null?void 0:l.modality)&&{modality:l.modality}}};case"user":return{...u,role:r,content:c.map(h=>{const f=h.type;switch(f){case"text":case"image":case"audio":case"file":case"data":return h;default:{const p=Ru(f,h.data);if(p)return p;throw new Error(`Unsupported user message part type: ${f}`)}}}),attachments:(o??[]).map(h=>({...h,content:h.content.map(f=>Ru(f.type,f.data)??f)})),metadata:{custom:(l==null?void 0:l.custom)??{},...(l==null?void 0:l.isOptimistic)&&{isOptimistic:!0},...(l==null?void 0:l.modality)&&{modality:l.modality}}};case"system":if(c.length!==1||c[0].type!=="text")throw new Error("System messages must have exactly one text message part.");return{...u,role:r,content:c,metadata:{custom:(l==null?void 0:l.custom)??{}}};default:throw new Error(`Unknown message role: ${r}`)}},z0=t=>t.type==="tool-call"&&t.result===void 0,lA=t=>{var n;if(t.type!=="tool-call"||t.result!==void 0)return!1;const e=(n=t.messages)==null?void 0:n.at(-1);return(e==null?void 0:e.role)==="assistant"&&e.status.type==="running"},F0=t=>t.type!=="tool-call"||t.result!==void 0?!1:t.interrupt!=null||t.approval!=null&&t.approval.approved===void 0&&t.approval.resolution===void 0,Kr=Symbol("autoStatus"),Qm=Object.freeze(Object.assign({type:"running"},{[Kr]:!0})),uA=Object.freeze(Object.assign({type:"complete",reason:"unknown"},{[Kr]:!0})),cA=Object.freeze(Object.assign({type:"incomplete",reason:"cancelled"},{[Kr]:!0})),dA=Object.freeze(Object.assign({type:"requires-action",reason:"tool-calls"},{[Kr]:!0})),hA=Object.freeze(Object.assign({type:"requires-action",reason:"interrupt"},{[Kr]:!0})),fA=t=>t[Kr]===!0,af=(t,e,n,r,s,i,o)=>t&&s?Object.assign({type:"incomplete",reason:"error",error:s},{[Kr]:!0}):t&&e?Qm:n?hA:o&&!i?Qm:r?dA:i?cA:uA,Km=t=>af(!1,!1,typeof t!="string"&&t.some(F0),typeof t!="string"&&t.some(z0)),Ym=(t,e,n)=>af(e,n,typeof t!="string"&&t.some(F0),typeof t!="string"&&t.some(z0),void 0,void 0,typeof t!="string"&&t.some(lA));var Jm=class{constructor(){w(this,"cache",new WeakMap)}convertMessages(t,e){return t.map((n,r)=>{const s=e(this.cache.get(n),n,r);return this.cache.set(n,s),s})}};const Xm=(t,e)=>{if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0},B0=t=>{const e=O(6),{index:n,children:r}=t,s=oe();let i;e[0]!==n?(i=Ut({attachment:xt({source:"message",query:{type:"index",index:n},get:l=>l.message.attachment({index:n})})}),e[0]=n,e[1]=i):i=e[1];const o=i;let a;return e[2]!==s||e[3]!==r||e[4]!==o?(a=T.jsx(an,{extends:s,config:o,children:r}),e[2]=s,e[3]=r,e[4]=o,e[5]=a):a=e[5],a},U0=t=>{const e=O(6),{index:n,children:r}=t,s=oe();let i;e[0]!==n?(i=Ut({attachment:xt({source:"composer",query:{type:"index",index:n},get:l=>l.composer.attachment({index:n})})}),e[0]=n,e[1]=i):i=e[1];const o=i;let a;return e[2]!==s||e[3]!==r||e[4]!==o?(a=T.jsx(an,{extends:s,config:o,children:r}),e[2]=s,e[3]=r,e[4]=o,e[5]=a):a=e[5],a},pA=t=>{const e=O(6),{runtime:n,children:r}=t,s=oe();let i;e[0]!==n?(i=Ut({threadListItem:tf({runtime:n})}),e[0]=n,e[1]=i):i=e[1];const o=i;let a;return e[2]!==s||e[3]!==r||e[4]!==o?(a=T.jsx(an,{extends:s,config:o,children:r}),e[2]=s,e[3]=r,e[4]=o,e[5]=a):a=e[5],a},V0=t=>{const e=O(6),{index:n,children:r}=t,s=oe();let i;e[0]!==n?(i=Ut({message:xt({source:"thread",query:{type:"index",index:n},get:l=>l.thread.message({index:n})}),composer:xt({source:"message",query:{},get:l=>l.thread.message({index:n}).composer()})}),e[0]=n,e[1]=i):i=e[1];const o=i;let a;return e[2]!==s||e[3]!==r||e[4]!==o?(a=T.jsx(an,{extends:s,config:o,children:r}),e[2]=s,e[3]=r,e[4]=o,e[5]=a):a=e[5],a},lf=t=>{const e=O(6),{index:n,children:r}=t,s=oe();let i;e[0]!==n?(i=Ut({part:xt({source:"message",query:{type:"index",index:n},get:l=>l.message.part({index:n})})}),e[0]=n,e[1]=i):i=e[1];const o=i;let a;return e[2]!==s||e[3]!==r||e[4]!==o?(a=T.jsx(an,{extends:s,config:o,children:r}),e[2]=s,e[3]=r,e[4]=o,e[5]=a):a=e[5],a},mA=t=>{const e=O(7),{text:n,isRunning:r}=t;let s;e[0]!==r?(s=r?{type:"running"}:{type:"complete"},e[0]=r,e[1]=s):s=e[1];let i;e[2]!==s||e[3]!==n?(i={type:"text",text:n,status:s},e[2]=s,e[3]=n,e[4]=i):i=e[4];const o=i;let a;return e[5]!==o?(a={getState:()=>o,addToolResult:yA,resumeToolCall:vA,respondToToolApproval:_A},e[5]=o,e[6]=a):a=e[6],a},gA=de(mA),uf=t=>{const e=O(7),{text:n,isRunning:r,children:s}=t,i=r===void 0?!1:r,o=oe();let a;e[0]!==i||e[1]!==n?(a=Ut({part:gA({text:n,isRunning:i})}),e[0]=i,e[1]=n,e[2]=a):a=e[2];const l=a;let u;return e[3]!==o||e[4]!==s||e[5]!==l?(u=T.jsx(an,{extends:o,config:l,children:s}),e[3]=o,e[4]=s,e[5]=l,e[6]=u):u=e[6],u};function yA(){throw new Error("Not supported")}function vA(){throw new Error("Not supported")}function _A(){throw new Error("Not supported")}const wA=t=>{var e;for(const n of t)if((n==null?void 0:n.status.type)==="running")return ef;return((e=t.at(-1))==null?void 0:e.status)??An},xA=(t,e)=>{var i;const n={running:0,complete:0,incomplete:0,requiresAction:0};let r=An,s=!1;for(const o of e)switch(r=((i=t[o])==null?void 0:i.status)??An,r.type){case"running":n.running++,s=!0;break;case"complete":n.complete++;break;case"incomplete":n.incomplete++;break;case"requires-action":n.requiresAction++}return{status:s?ef:r,counts:n}},SA=t=>{const e=O(11),{parts:n,getMessagePart:r}=t,[s,i]=ce(!0);let o;e[0]!==n?(o=wA(n),e[0]=n,e[1]=o):o=e[1];const a=o;let l;e[2]!==s||e[3]!==n||e[4]!==a?(l={parts:n,collapsed:s,status:a},e[2]=s,e[3]=n,e[4]=a,e[5]=l):l=e[5];const u=l;let c;e[6]!==u?(c=()=>u,e[6]=u,e[7]=c):c=e[7];let d;return e[8]!==r||e[9]!==c?(d={getState:c,setCollapsed:i,part:r},e[8]=r,e[9]=c,e[10]=d):d=e[10],d},bA=de(SA),TA=t=>{const e=O(4),{startIndex:n,endIndex:r,children:s}=t,i=G(kA).slice(n,r+1),o=oe(),a=Ut({chainOfThought:bA({parts:i,getMessagePart:u=>{const{index:c}=u;if(c<0||c>=i.length)throw new Error(`ChainOfThought part index ${c} is out of bounds (0..${i.length-1})`);return o.message.part({index:n+c})}})});let l;return e[0]!==s||e[1]!==a||e[2]!==o?(l=T.jsx(an,{extends:o,config:a,children:s}),e[0]=s,e[1]=a,e[2]=o,e[3]=l):l=e[3],l};function kA(t){return t.message.parts}const H0=t=>{const e=O(6),{index:n,children:r}=t,s=oe();let i;e[0]!==n?(i=Ut({suggestion:xt({source:"suggestions",query:{index:n},get:l=>l.suggestions.suggestion({index:n})})}),e[0]=n,e[1]=i):i=e[1];const o=i;let a;return e[2]!==s||e[3]!==r||e[4]!==o?(a=T.jsx(an,{extends:s,config:o,children:r}),e[2]=s,e[3]=r,e[4]=o,e[5]=a):a=e[5],a},CA=t=>{const e=O(6),{index:n,children:r}=t,s=oe();let i;e[0]!==n?(i=Ut({queueItem:xt({source:"composer",query:{type:"index",index:n},get:l=>l.composer.queueItem({index:n})})}),e[0]=n,e[1]=i):i=e[1];const o=i;let a;return e[2]!==s||e[3]!==r||e[4]!==o?(a=T.jsx(an,{extends:s,config:o,children:r}),e[2]=s,e[3]=r,e[4]=o,e[5]=a):a=e[5],a},IA=["critical","warning","info"],EA=["inline","toast","silent","dev-only"],RA=t=>{if(typeof t!="object"||t===null)return!1;const e=t;return!(typeof e.code!="string"||typeof e.message!="string"||"severity"in e&&e.severity!==void 0&&(typeof e.severity!="string"||!IA.includes(e.severity))||"display"in e&&e.display!==void 0&&(typeof e.display!="string"||!EA.includes(e.display)))},q0=Symbol.for("assistant-ui.message-not-sent");var Xy,Zy,AA=class extends(Zy=Error,Xy=q0,Zy){constructor(e="The message was not sent."){super(e);w(this,Xy,!0);this.name="MessageNotSentError"}};const G0=t=>typeof t=="object"&&t!==null&&q0 in t,PA=t=>{if(RA(t))return t;if(t instanceof Error)return{code:"unknown",message:t.message};if(typeof t=="string")return{code:"unknown",message:t};try{return{code:"unknown",message:`[${typeof t}] ${String(t)}`}}catch{return{code:"unknown",message:`[${typeof t}]`}}};var W0=class{constructor(t){w(this,"_core");this._core=t,this.__internal_bindMethods()}get path(){return this._core.path}__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)}},Q0=class extends W0{constructor(e,n){super(e);w(this,"_composerApi");this._composerApi=n}remove(){const e=this._composerApi.getState();if(!e)throw new Error("Composer is not available");return e.removeAttachment(this.getState().id)}},MA=class extends Q0{get source(){return"thread-composer"}},DA=class extends Q0{get source(){return"edit-composer"}},OA=class extends W0{get source(){return"message"}remove(){throw new Error("Message attachments cannot be removed")}};const sl=Object.freeze([]),K0=Object.freeze({}),NA=t=>Object.freeze({type:"thread",isEditing:(t==null?void 0:t.isEditing)??!1,canCancel:(t==null?void 0:t.canCancel)??!1,canSend:(t==null?void 0:t.canSend)??!1,isEmpty:(t==null?void 0:t.isEmpty)??!0,attachments:(t==null?void 0:t.attachments)??sl,text:(t==null?void 0:t.text)??"",role:(t==null?void 0:t.role)??"user",runConfig:(t==null?void 0:t.runConfig)??K0,attachmentAccept:(t==null?void 0:t.attachmentAccept)??"",dictation:t==null?void 0:t.dictation,quote:t==null?void 0:t.quote,queue:(t==null?void 0:t.queue)??sl,value:(t==null?void 0:t.text)??""}),LA=t=>Object.freeze({type:"edit",isEditing:(t==null?void 0:t.isEditing)??!1,canCancel:(t==null?void 0:t.canCancel)??!1,canSend:(t==null?void 0:t.canSend)??!1,isEmpty:(t==null?void 0:t.isEmpty)??!0,text:(t==null?void 0:t.text)??"",role:(t==null?void 0:t.role)??"user",attachments:(t==null?void 0:t.attachments)??sl,runConfig:(t==null?void 0:t.runConfig)??K0,attachmentAccept:(t==null?void 0:t.attachmentAccept)??"",dictation:t==null?void 0:t.dictation,quote:t==null?void 0:t.quote,queue:(t==null?void 0:t.queue)??sl,parentId:(t==null?void 0:t.parentId)??null,sourceId:(t==null?void 0:t.sourceId)??null,value:(t==null?void 0:t.text)??""});var Y0=class{constructor(t){w(this,"_core");w(this,"_eventSubscriptionSubjects",new Map);this._core=t}get path(){return this._core.path}__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.moveQueueItem=this.moveQueueItem.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){this.moveQueueItem(t,{lane:"steer",insertAfter:null})}moveQueueItem(t,e){const n=this._core.getState();if(!n)throw new Error("Composer is not available");n.moveQueueItem(t,e)}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)}unstable_on(t,e){let n=this._eventSubscriptionSubjects.get(t);return n||(n=new l0({event:t,binding:this._core}),this._eventSubscriptionSubjects.set(t,n)),n.subscribe(e)}},jA=class extends Y0{constructor(e){const n=new Zh({path:e.path,getState:()=>NA(e.getState()),subscribe:r=>e.subscribe(r)});super({path:e.path,getState:()=>e.getState(),subscribe:r=>n.subscribe(r)});w(this,"_getState");this._getState=n.getState.bind(n),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"thread"}getState(){return this._getState()}getAttachmentByIndex(e){return new MA(new jt({path:{...this.path,attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{const n=this.getState().attachments[e];return n?{...n,source:"thread-composer"}:Bt},subscribe:n=>this._core.subscribe(n)}),this._core)}},$A=class extends Y0{constructor(e,n){const r=new Zh({path:e.path,getState:()=>LA(e.getState()),subscribe:s=>e.subscribe(s)});super({path:e.path,getState:()=>e.getState(),subscribe:s=>r.subscribe(s)});w(this,"_getState");w(this,"_beginEdit");this._beginEdit=n,this._getState=r.getState.bind(r),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"edit"}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new DA(new jt({path:{...this.path,attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{const n=this.getState().attachments[e];return n?{...n,source:"edit-composer"}:Bt},subscribe:n=>this._core.subscribe(n)}),this._core)}};const bo=t=>t.content.filter(e=>e.type==="text").map(e=>e.text).join(`
43
+
44
+ `),zA="ui://",J0=t=>!!(t!=null&&t.startsWith(zA)),FA=t=>t.display==="text"||t.allowFreeform===!0,Zm={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},BA=(t,e)=>{var i;const n=e.text;if(n!==void 0&&!FA(t))throw new Error(`Tool approval "${t.id}" does not accept a free-form answer; the request must declare display "text" or allowFreeform`);let r,s;if("optionId"in e){const o=(i=t.options)==null?void 0:i.find(a=>a.id===e.optionId);if(!o)throw new Error(`Tool approval has no option with id "${e.optionId}"`);if("approved"in e)r=e.approved;else{if(!Object.hasOwn(Zm,o.kind))throw new Error(`Tool approval option "${o.id}" has a custom kind "${o.kind}"; respond with an explicit approved value instead`);r=Zm[o.kind]}s=o.id}else if("approved"in e)r=e.approved;else{if(t.display!=="text"&&t.display!=="select")throw new Error(`Tool approval "${t.id}" is a decision, not a question; respond with an explicit approved value, optionally alongside the answer`);r=!0}return{approvalId:t.id,approved:r,...s!==void 0&&{optionId:s},...n!==void 0&&{text:n},...e.reason!=null&&{reason:e.reason}}};var eg=class{constructor(t,e,n){w(this,"contentBinding");w(this,"messageApi");w(this,"threadApi");this.contentBinding=t,this.messageApi=e,this.threadApi=n,this.__internal_bindMethods()}get path(){return this.contentBinding.path}__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 n=this.messageApi.getState();if(!n)throw new Error("Message is not available");const r=e.toolName,s=e.toolCallId,i=sr.toResponse(t);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:s,result:i.result,isError:i.isError,...i.artifact!==void 0&&{artifact:i.artifact},...i.modelContent!==void 0&&{modelContent:i.modelContent}})}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 n=e.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,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");return this.threadApi.getState().respondToToolApproval(BA(e.approval,t))}subscribe(t){return this.contentBinding.subscribe(t)}};const tg=(t,e)=>{const n=t.content[e];if(!n)return Bt;const r=v0(t,e,n);return Object.freeze({...n,[Ur]:n[Ur],status:r})};var UA=class{constructor(t,e){w(this,"_core");w(this,"_threadBinding");w(this,"composer");w(this,"_getEditComposerRuntimeCore",()=>this._threadBinding.getState().getEditComposer(this._core.getState().id));this._core=t,this._threadBinding=e,this.composer=new $A(new el({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:"edit"},getState:this._getEditComposerRuntimeCore,subscribe:n=>this._threadBinding.subscribe(n)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}get path(){return this._core.path}__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)}getState(){return this._core.getState()}delete(){const t=this._core.getState();return this._threadBinding.getState().deleteMessage(t.id)}reload(t={}){const e=this._getEditComposerRuntimeCore(),n=e??this._threadBinding.getState().composer,r=e??n,{runConfig:s=r.runConfig}=t,i=this._core.getState();if(i.role!=="assistant")throw new Error("Can only reload assistant messages");this._threadBinding.getState().startRun({parentId:i.parentId,sourceId:i.id,runConfig:s})}speak(){const t=this._core.getState();return this._threadBinding.getState().speak(t.id)}stopSpeaking(){var e;const t=this._core.getState();if(((e=this._threadBinding.getState().speech)==null?void 0:e.messageId)===t.id)this._threadBinding.getState().stopSpeaking();else throw new Error("Message is not being spoken")}submitFeedback({type:t,comment:e}){const n=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:n.id,type:t,...e!==void 0?{comment:e}:void 0})}switchToBranch({position:t,branchId:e}){const n=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 r=this._threadBinding.getState().getBranches(n.id);let s=e;if(t==="previous"?s=r[n.branchNumber-2]:t==="next"&&(s=r[n.branchNumber]),!s)throw new Error("Branch not found");this._threadBinding.getState().switchToBranch(s)}unstable_getCopyText(){return bo(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 eg(new jt({path:{...this.path,ref:`${this.path.ref}.content[${t}]`,messagePartSelector:{type:"index",index:t}},getState:()=>tg(this.getState(),t),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(t){return new eg(new jt({path:{...this.path,ref:`${this.path.ref}.content[toolCallId=${JSON.stringify(t)}]`,messagePartSelector:{type:"toolCallId",toolCallId:t}},getState:()=>{const e=this._core.getState(),n=e.content.findIndex(r=>r.type==="tool-call"&&r.toolCallId===t);return n===-1?Bt:tg(e,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(t){return new OA(new jt({path:{...this.path,ref:`${this.path.ref}.attachments[${t}]`,attachmentSource:"message",attachmentSelector:{type:"index",index:t}},getState:()=>{var n;const e=(n=this.getState().attachments)==null?void 0:n[t];return e?{...e,source:"message"}:Bt},subscribe:e=>this._core.subscribe(e)}))}};const VA=t=>({parentId:t.parentId??null,sourceId:t.sourceId??null,runConfig:t.runConfig??{},...t.stream?{stream:t.stream}:{}}),HA=t=>({parentId:t.parentId??null,sourceId:t.sourceId??null,runConfig:t.runConfig??{}}),qA=(t,e)=>{var n,r;return typeof e=="string"?{createdAt:new Date,parentId:((n=t.at(-1))==null?void 0:n.id)??null,sourceId:null,runConfig:{},role:"user",content:[{type:"text",text:e}],attachments:[],metadata:{custom:{}}}:{createdAt:e.createdAt??new Date,parentId:e.parentId===void 0?((r=t.at(-1))==null?void 0:r.id)??null:e.parentId,sourceId:e.sourceId??null,role:e.role??"user",content:e.content,attachments:e.attachments??[],metadata:e.metadata??{custom:{}},runConfig:e.runConfig??{},startRun:e.startRun}},il=t=>{if(t.isRunning!==void 0)return t.isRunning;const e=t.messages.at(-1);return(e==null?void 0:e.role)==="assistant"&&e.status.type==="running"},GA=(t,e)=>Object.freeze({threadId:e.id,metadata:e,capabilities:t.capabilities,isDisabled:t.isDisabled,isLoading:t.isLoading,isRunning:il(t),messages:t.messages,state:t.state,suggestions:t.suggestions,extras:t.extras,speech:t.speech,voice:t.voice});var WA=class{constructor(t,e){w(this,"_threadBinding");w(this,"_stateBinding");w(this,"composer");w(this,"_eventSubscriptionSubjects",new Map);const n=new jt({path:t.path,getState:()=>GA(t.getState(),e.getState()),subscribe:r=>{const s=t.subscribe(r),i=e.subscribe(r);return()=>Xh([s,i])}});this._stateBinding=n,this._threadBinding={path:t.path,getState:()=>t.getState(),getStateState:()=>n.getState(),outerSubscribe:r=>t.outerSubscribe(r),subscribe:r=>t.subscribe(r)},this.composer=new jA(new el({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:"thread"},getState:()=>this._threadBinding.getState().composer,subscribe:r=>this._threadBinding.subscribe(r)})),this.__internal_bindMethods()}get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}__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.unstable_notifySessionReset=this.unstable_notifySessionReset.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)}getState(){return this._threadBinding.getStateState()}append(t){const e=this._threadBinding.getState().append(qA(this._threadBinding.getState().messages,t));Promise.resolve(e).catch(n=>{if(!G0(n))throw n})}deleteMessage(t){return this._threadBinding.getState().deleteMessage(t)}subscribe(t){return this._stateBinding.subscribe(t)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(t){return this._threadBinding.getState().startRun(HA(t))}resumeRun(t){return this._threadBinding.getState().resumeRun(VA(t))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(t){this._threadBinding.getState().importExternalState(t)}cancelRun(){this._threadBinding.getState().cancelRun()}unstable_notifySessionReset(){this._threadBinding.getState().unstable_notifySessionReset()}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}},()=>{var r;const e=this._threadBinding.getState().messages,n=e[t];if(n)return{message:n,parentId:((r=e[t-1])==null?void 0:r.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 UA(new jt({path:t,getState:()=>{var l;const{message:n,parentId:r,index:s}=e()??{},{messages:i,speech:o}=this._threadBinding.getState();if(!n||r===void 0||s===void 0)return Bt;const a=this._threadBinding.getState().getBranches(n.id);return{...n,[Ur]:n[Ur],index:s,isLast:((l=i.at(-1))==null?void 0:l.id)===n.id,parentId:r,branchNumber:a.indexOf(n.id)+1,branchCount:a.length,speech:(o==null?void 0:o.messageId)===n.id?o:void 0}},subscribe:n=>this._threadBinding.subscribe(n)}),this._threadBinding)}unstable_on(t,e){let n=this._eventSubscriptionSubjects.get(t);return n||(n=new l0({event:t,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(t,n)),n.subscribe(e)}};const QA=(t,e)=>({attachments:[],attachmentAccept:"*",async addAttachment(){throw t},async removeAttachment(){throw t},isEditing:e,canCancel:!1,canSend:!1,isEmpty:!0,text:"",setText(){throw t},role:"user",setRole(){throw t},runConfig:{},setRunConfig(){throw t},async reset(){},async clearAttachments(){},send(){throw t},cancel(){},queue:[],moveQueueItem(){},removeQueueItem(){},dictation:void 0,startDictation(){throw t},stopDictation(){},quote:void 0,setQuote(){throw t},subscribe(){return()=>{}},unstable_on(){return()=>{}}});var KA=class extends $n{constructor(){super(...arguments);w(this,"getVoiceVolume",()=>0);w(this,"subscribeVoiceVolume",()=>()=>{});w(this,"speech");w(this,"voice");w(this,"capabilities",{switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1});w(this,"isDisabled",!1);w(this,"isSendDisabled",!1);w(this,"state",null);w(this,"suggestions",[]);w(this,"extras")}switchToBranch(){throw this.error}append(){throw this.error}deleteMessage(){throw this.error}startRun(){throw this.error}resumeRun(){throw this.error}cancelRun(){throw this.error}unstable_notifySessionReset(){throw this.error}addToolResult(){throw this.error}resumeToolCall(){throw this.error}respondToToolApproval(){throw this.error}speak(){throw this.error}stopSpeaking(){throw this.error}connectVoice(){throw this.error}disconnectVoice(){throw this.error}muteVoice(){throw this.error}unmuteVoice(){throw this.error}submitFeedback(){throw this.error}exportExternalState(){throw this.error}importExternalState(){throw this.error}beginEdit(){throw this.error}import(){throw this.error}reset(){throw this.error}getModelContext(){return{}}getEditComposer(){}unstable_on(){return()=>{}}};const ng=t=>{const e=O(6),{adapters:n,children:r}=t,s=At(rl);let i;e[0]!==n||e[1]!==s?(i={...s,...n},e[0]=n,e[1]=s,e[2]=i):i=e[2];const o=i;let a;return e[3]!==r||e[4]!==o?(a=T.jsx(rl.Provider,{value:o,children:r}),e[3]=r,e[4]=o,e[5]=a):a=e[5],a};var mi=class{constructor(t,e){w(this,"_core");w(this,"_threadListBinding");this._core=t,this._threadListBinding=e,this.__internal_bindMethods()}get path(){return this._core.path}__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(t){const e=this._core.getState();return this._threadListBinding.generateTitle(e.id,t)}unstable_on(t,e){let n=this._core.getState().isMain,r=this._core.getState().id;return this.subscribe(()=>{const s=this._core.getState(),i=s.isMain,o=s.id;n===i&&r===o||(n=i,r=o,!(t==="switchedTo"&&!i)&&(t==="switchedAway"&&i||Yt([e],{},`Thread list item "${t}"`)))})}subscribe(t){return this._core.subscribe(t)}detach(){const t=this._core.getState();this._threadListBinding.detach(t.id)}__internal_getRuntime(){return this}};const Au=Promise.resolve(),YA=()=>{},JA=t=>({mainThreadId:t.mainThreadId,newThreadId:t.newThreadId,threadIds:t.threadIds,archivedThreadIds:t.archivedThreadIds,isLoading:t.isLoading,loadError:t.loadError,isLoadingMore:t.isLoadingMore??!1,hasMore:t.hasMore??!1,threadItems:t.threadItems}),Ko=(t,e)=>{var r;if(e===void 0)return Bt;const n=t.getItemById(e);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,lastMessageAt:n.lastMessageAt,custom:n.custom,isMain:n.id===t.mainThreadId,isRunning:((r=t.unstable_isThreadRunning)==null?void 0:r.call(t,n.id))??!1}:Bt};var X0=class{constructor(t,e=WA){w(this,"_getState");w(this,"_stateBinding");w(this,"_core");w(this,"_runtimeFactory");w(this,"_mainThreadListItemRuntime");w(this,"main");this._core=t,this._runtimeFactory=e;const n=new Zh({path:{},getState:()=>JA(t),subscribe:r=>t.subscribe(r)});this._getState=n.getState.bind(n),this._stateBinding=n,this._mainThreadListItemRuntime=new mi(new jt({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>Ko(this._core,this._core.mainThreadId),subscribe:r=>this._core.subscribe(r)}),this._core),this.main=new e(new el({path:{ref:"threads.main",threadSelector:{type:"main"}},getState:()=>t.getMainThreadRuntimeCore(),subscribe:r=>t.subscribe(r)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.unstable_subscribeThreadEvents=this.unstable_subscribeThreadEvents.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.reloadMainThread=this.reloadMainThread.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()}unstable_subscribeThreadEvents(t){var e,n;return((n=(e=this._core).unstable_subscribeThreadEvents)==null?void 0:n.call(e,t))??YA}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){var t,e;return((e=(t=this._core).reload)==null?void 0:e.call(t))??Au}reloadMainThread(){var t,e;return((e=(t=this._core).reloadMainThread)==null?void 0:e.call(t))??Au}loadMore(){var t,e;return((e=(t=this._core).loadMore)==null?void 0:e.call(t))??Au}getState(){return this._getState()}subscribe(t){return this._stateBinding.subscribe(t)}get mainItem(){return this._mainThreadListItemRuntime}_createItemStateBinding(t){return new jt({path:{ref:`threadItems[threadId=${t}]`,threadSelector:{type:"threadId",threadId:t}},getState:()=>Ko(this._core,t),subscribe:e=>this._core.subscribe(e)})}getById(t){return new this._runtimeFactory(new el({path:{ref:`threads[threadId=${JSON.stringify(t)}]`,threadSelector:{type:"threadId",threadId:t}},getState:()=>this._core.getThreadRuntimeCore(t),subscribe:e=>this._core.subscribe(e)}),this._createItemStateBinding(t))}getItemByIndex(t){return new mi(new jt({path:{ref:`threadItems[${t}]`,threadSelector:{type:"index",index:t}},getState:()=>Ko(this._core,this._core.threadIds[t]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(t){return new mi(new jt({path:{ref:`archivedThreadItems[${t}]`,threadSelector:{type:"archiveIndex",index:t}},getState:()=>Ko(this._core,this._core.archivedThreadIds[t]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(t){return new mi(this._createItemStateBinding(t),this._core)}},cf=class{constructor(t){w(this,"threads");w(this,"_thread");w(this,"_core");this._core=t,this.threads=new X0(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)}};const Z0=new WeakMap,no=t=>Z0.get(t)??0,Ii=(t,e)=>no(t)===e,ro=t=>{Z0.set(t,no(t)+1)};var df=class{constructor(){w(this,"_contextProvider",new u0)}registerModelContextProvider(t){return this._contextProvider.registerModelContextProvider(t)}getModelContextProvider(){return this._contextProvider}};const yr=Object.freeze([]),Cs="DEFAULT_THREAD_ID",XA=Object.freeze([Cs]),ZA=Object.freeze({id:Cs,remoteId:void 0,externalId:void 0,status:"regular"}),e2=Promise.resolve(),rg=Object.freeze(Te({[Cs]:ZA}));var t2=class extends $n{constructor(e={},n){super();w(this,"_mainThreadId",Cs);w(this,"_threads",XA);w(this,"_archivedThreads",yr);w(this,"_threadData",rg);w(this,"adapter",{});w(this,"_mainThread");w(this,"threadFactory");this.threadFactory=n,this.__internal_setAdapter(e,!0)}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 e2}get mainThreadId(){return this._mainThreadId}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw new Error("Method not implemented.")}getItemById(e){return Object.hasOwn(this._threadData,e)?this._threadData[e]:void 0}__internal_setAdapter(e,n=!1){var c,d,h,f;const r=this.adapter;this.adapter=e;const s=e.threadId??Cs,i=e.threads??yr,o=e.archivedThreads??yr,a=r.threadId??Cs,l=r.threads??yr,u=r.archivedThreads??yr;!n&&(r.isLoading??!1)===(e.isLoading??!1)&&a===s&&l===i&&u===o||((l!==i||u!==o||a!==s)&&(this._threadData=Te(rg,Object.fromEntries(((c=e.threads)==null?void 0:c.map(p=>[p.id,{...p,remoteId:p.remoteId,externalId:p.externalId,status:"regular"}]))??[]),Object.fromEntries(((d=e.archivedThreads)==null?void 0:d.map(p=>[p.id,{...p,remoteId:p.remoteId,externalId:p.externalId,status:"archived"}]))??[]))),l!==i&&(this._threads=((h=this.adapter.threads)==null?void 0:h.map(p=>p.id))??yr),u!==o&&(this._archivedThreads=((f=this.adapter.archivedThreads)==null?void 0:f.map(p=>p.id))??yr),(n||a!==s)&&(n||ro(this._mainThread),this._mainThreadId=s,this._mainThread=this.threadFactory()),Object.hasOwn(this._threadData,this._mainThreadId)||(this._threadData=Te(this._threadData,{[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:"regular"}})),this._notifySubscribers())}async reloadMainThread(){this._mainThread.unstable_refetchThread&&await this._mainThread.unstable_refetchThread()}async switchToThread(e,n){if(this._mainThreadId===e)return;const r=this.adapter.onSwitchToThread;if(!r)throw new Error("External store adapter does not support switching to thread");await r(e)}async switchToNewThread(){const e=this.adapter.onSwitchToNewThread;if(!e)throw new Error("External store adapter does not support switching to new thread");await e()}async rename(e,n){const r=this.adapter.onRename;if(!r)throw new Error("External store adapter does not support renaming");await r(e,n)}async updateCustom(e,n){const r=this.adapter.onUpdateCustom;if(!r)throw new Error("External store adapter does not support updating custom metadata");await r(e,n)}async detach(){}async archive(e){const n=this.adapter.onArchive;if(!n)throw new Error("External store adapter does not support archiving");await n(e)}async unarchive(e){const n=this.adapter.onUnarchive;if(!n)throw new Error("External store adapter does not support unarchiving");await n(e)}async delete(e){const n=this.adapter.onDelete;if(!n)throw new Error("External store adapter does not support deleting");await n(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw new Error("Method not implemented.")}};const hf={fromArray:t=>{const e=t.map(n=>Os(n,Ct(),Km(n.content)));return{messages:e.map((n,r)=>({parentId:r>0?e[r-1].id:null,message:n}))}},fromBranchableArray:(t,e)=>({...(e==null?void 0: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:Os(n,n.id,Km(n.content))}})})},Yo=t=>{let e=t;for(;e.next;)e=e.next;return"current"in e?e:null};var n2=class{constructor(t){w(this,"_value",null);w(this,"func");this.func=t}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},e1=class{constructor(){w(this,"messages",new Map);w(this,"head",null);w(this,"root",{children:[],next:null});w(this,"_messages",new n2(()=>{var e;const t=new Array((((e=this.head)==null?void 0:e.level)??-1)+1);for(let n=this.head;n;n=n.prev)t[n.level]=n.current;return t}))}updateLevels(t,e){const n=[{message:t,level:e}];for(;n.length>0;){const r=n.pop();r.message.level=r.level;for(const s of r.message.children){const i=this.messages.get(s);i&&n.push({message:i,level:r.level+1})}}}selectPathTo(t){for(let e=t;e;e=e.prev)(e.prev??this.root).next=e}performOp(t,e,n){const r=e.prev??this.root,s=t??this.root;if(!(n==="relink"&&r===s)){if(n==="relink"){for(let i=t;i;i=i.prev)if(i.current.id===e.current.id)throw new Error("MessageRepository(performOp/relink): 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.")}if(n!=="link"&&(r.children=r.children.filter(i=>i!==e.current.id),r.next===e)){const i=r.children.at(-1),o=i?this.messages.get(i):null;if(o===void 0)throw new Error("MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.");r.next=o}if(n!=="cut"){s.children=[...s.children,e.current.id],e.prev=t,Yo(e)===this.head?this.selectPathTo(e):s.next===null&&(s.next=e,this.head===s&&(this.head=Yo(e)));const i=t?t.level+1:0;this.updateLevels(e,i)}}}get headId(){var t;return((t=this.head)==null?void 0:t.current.id)??null}get canonicalHeadId(){var e;let t=this.head;for(;(e=t==null?void 0:t.current.metadata)!=null&&e.isOptimistic;)t=t.prev;return(t==null?void 0:t.current.id)??null}getMessages(t){var r;if(t===void 0||t===((r=this.head)==null?void 0:r.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 n=new Array(e.level+1);for(let s=e;s;s=s.prev)n[s.level]=s.current;return n}addOrUpdateMessage(t,e){const n=this.messages.get(e.id),r=t?this.messages.get(t):null;if(r===void 0)throw new Error("MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.");if(n){n.current=e,this.performOp(r,n,"relink"),this._messages.dirty();return}const s={prev:r,current:e,next:null,children:[],level:r?r.level+1:0};this.messages.set(e.id,s),this.performOp(r,s,"link"),this.head===r&&(this.head=s),this._messages.dirty()}getMessage(t){var n;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:((n=e.prev)==null?void 0:n.current.id)??null,message:e.current,index:e.level}}deleteMessage(t,e){const n=this.messages.get(t);if(!n)throw new Error("MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.");const r=e===void 0?n.prev:e===null?null:this.messages.get(e);if(r===void 0)throw new Error("MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.");for(const s of n.children){const i=this.messages.get(s);if(!i)throw new Error("MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.");this.performOp(r,i,"relink")}this.performOp(null,n,"cut"),this.messages.delete(t),this.head===n&&(this.head=Yo(r??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:n}=e.prev??this.root;return n}evictOffBranchOptimisticMessages(t,e){var s;if(!t)return;const n=new Set;for(let i=e;i;i=i.prev)n.add(i.current.id);const r=[];for(let i=t;i&&!n.has(i.current.id);i=i.prev)(s=i.current.metadata)!=null&&s.isOptimistic&&r.push(i.current.id);for(const i of r)this.messages.has(i)&&this.deleteMessage(i)}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 n=this.head;this.selectPathTo(e),this.head=Yo(e),this.evictOffBranchOptimisticMessages(n,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 n=this.head;if(e.children.length>0){const r=[...e.children];for(;r.length>0;){const s=r.pop(),i=this.messages.get(s);if(i){for(const o of i.children)r.push(o);this.messages.delete(s)}}e.children=[],e.next=null}this.head=e,this.selectPathTo(e),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){var n,r;const t=[],e=[...this.root.children].reverse();for(;e.length>0;){const s=this.messages.get(e.pop());if(!s)continue;for(let o=s.children.length-1;o>=0;o--)e.push(s.children[o]);if((n=s.current.metadata)!=null&&n.isOptimistic)continue;let i=s.prev;for(;i&&((r=i.current.metadata)!=null&&r.isOptimistic);)i=i.prev;t.push({message:s.current,parentId:(i==null?void 0:i.current.id)??null})}return{headId:this.canonicalHeadId,messages:t}}import({headId:t,messages:e}){var n;for(const{message:r,parentId:s}of e)this.addOrUpdateMessage(s,r);this.resetHead(t??((n=e.at(-1))==null?void 0:n.message.id)??null)}};const Zt=Object.freeze([]);function*ff(t){var e;for(const n of t)if(!((n==null?void 0:n.role)!=="assistant"||!Array.isArray(n.content)))for(const r of n.content)!r||r.type!=="tool-call"||(yield{part:r,messageId:n.id},(e=r.messages)!=null&&e.length&&(yield*ff(r.messages)))}function sg(t,e){if(e==="*")return!0;const n=e.split(",").map(i=>i.trim().toLowerCase()),r=t.name.toLowerCase(),s=t.type.split(";",1)[0].trim().toLowerCase();for(const i of n){if(i.startsWith(".")&&r.endsWith(i)||i.includes("/")&&i===s)return!0;if(i.endsWith("/*")){const o=i.split("/")[0];if(s.startsWith(`${o}/`))return!0}}return!1}function r2(t){const e=Ct();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 s2(t){const e=[];for(const n of t)n.type!=="text"&&e.push(r2(n));return e}const i2=t=>"content"in t&&!("lastModified"in t),Jo=t=>t.status.type==="complete";var o2=class{constructor(){w(this,"operations",new Set)}start(){const t={cancelled:!1,attachmentIds:new Set};return this.operations.add(t),t}accept(t,e){return t.cancelled?!1:(t.attachmentIds.add(e),!0)}finish(t){this.operations.delete(t)}isCancelled(t){return t.cancelled}cancel(t){for(const e of[...this.operations])e.attachmentIds.has(t)&&(e.cancelled=!0,this.operations.delete(e))}cancelAll(){for(const t of this.operations)t.cancelled=!0;this.operations.clear()}};const a2=async(t,e)=>{if(Symbol.asyncIterator in t){for await(const n of t)if(!e(n))break}else e(await t)};var t1=class extends $n{constructor(){super(...arguments);w(this,"isEditing",!0);w(this,"_attachments",[]);w(this,"_text","");w(this,"_role","user");w(this,"_runConfig",{});w(this,"_quote");w(this,"_isSending",!1);w(this,"_removedDuringSend",new Set);w(this,"_sendGeneration",0);w(this,"_attachmentAddOperations",new o2);w(this,"_dictation");w(this,"_dictationSession");w(this,"_dictationUnsubscribes",[]);w(this,"_dictationBaseText","");w(this,"_currentInterimText","");w(this,"_dictationSessionIdCounter",0);w(this,"_activeDictationSessionId");w(this,"_isCleaningDictation",!1);w(this,"_eventSubscribers",new Map)}enrichWithComposerMetadata(e,n){var r;return n?{...e,metadata:{...e.metadata,custom:{...(r=e.metadata)==null?void 0:r.custom,...n}}}:e}get attachmentAccept(){var e;return((e=this.getAttachmentAdapter())==null?void 0:e.accept)??"*"}get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}get text(){return this._text}get role(){return this._role}get runConfig(){return this._runConfig}get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e){this._text!==e&&(this._text=e,this._rebaseDictation(e),this._notifySubscribers())}_rebaseDictation(e){if(!this._dictation)return;this._dictationBaseText=e,this._currentInterimText="";const{status:n,inputDisabled:r}=this._dictation;this._dictation=r?{status:n,inputDisabled:r}:{status:n}}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}_cancelAttachmentAdd(e){this._attachmentAddOperations.cancel(e)}_cancelAllAttachmentAdds(){this._attachmentAddOperations.cancelAll()}_emptyTextAndAttachments(){this._attachments=[],this._text="",this._rebaseDictation(""),this._notifySubscribers()}async _onClearAttachments(){const e=this.getAttachmentAdapter();if(e){const n=this._attachments.filter(r=>!Jo(r));await Promise.all(n.map(async r=>e.remove(r)))}}async reset(){if(this._cancelAllAttachmentAdds(),this._sendGeneration++,this._isSending=!1,this._removedDuringSend.clear(),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 e=this._onClearAttachments();this._emptyTextAndAttachments(),await e}async clearAttachments(){if(this._cancelAllAttachmentAdds(),this._isSending)for(const n of this._attachments)this._removedDuringSend.add(n.id);const e=this._onClearAttachments();this.setAttachments([]),await e}async send(e){if(!this.canSend||this._isSending)return;if(this._dictationSession)try{this._dictationSession.cancel()}catch(_){console.error("[assistant-ui] Dictation session cancel threw",_)}finally{this._cleanupDictation()}const n=this.getAttachmentAdapter(),r=this.attachments.map(async _=>{if(Jo(_))return _;if(!n)throw new Error("Attachments are not supported");return await n.send(_)}),s=this.attachments,i=this.text,o=this._quote,a=this.role,l=this.runConfig;this._quote=void 0,this._text="",this._isSending=!0;const u=++this._sendGeneration;this._notifySubscribers();let c;try{c=await Promise.all(r)}catch(_){throw u===this._sendGeneration&&(!this.text.trim()&&this._quote===void 0&&(this._text=i,this._rebaseDictation(i),this._quote=o,this._notifySubscribers()),Promise.allSettled(r).then(()=>{u===this._sendGeneration&&(this._removedDuringSend.clear(),this._isSending=!1,this._notifySubscribers())})),_}if(u!==this._sendGeneration)return;const d=new Set(s.map(_=>_.id));this._attachments=this._attachments.filter(_=>!d.has(_.id)),this._isSending=!1,this._notifySubscribers();const h=c.filter(_=>!this._removedDuringSend.has(_.id));this._removedDuringSend.clear();const f={createdAt:new Date,role:a,content:i?[{type:"text",text:i}]:[],attachments:h,runConfig:l,metadata:{custom:{...o?{quote:o}:{}}}},p={text:i,quote:o,attachments:h};let g;try{g=this.handleSend(f,e)}catch(_){throw this._restoreUnsentDraft(_,u,p),_}g&&g.catch(_=>{this._restoreUnsentDraft(_,u,p)}),this._notifyEventSubscribers("send",{chars:i.length,attachments:h.length})}restoreDraft(e){return this._text.trim()||this._quote!==void 0||this._attachments.length>0?!1:(this._text=e.text,this._rebaseDictation(e.text),this._quote=e.quote,this._attachments=e.attachments??[],this._notifySubscribers(),!0)}retractDraft(e){const n=e.attachments!==void 0?this._attachments===e.attachments:this._attachments.length===0;this._text!==e.text||this._quote!==e.quote||!n||(this._text="",this._rebaseDictation(""),this._quote=void 0,this._attachments=[],this._notifySubscribers())}_restoreUnsentDraft(e,n,r){G0(e)&&n===this._sendGeneration&&this.restoreDraft(r)}cancel(){this.handleCancel()}get queue(){return Zt}moveQueueItem(e,n){}removeQueueItem(e){}async addAttachment(e){if(i2(e)){const o=this.getAttachmentAdapter();if(o&&!sg({name:e.name,type:e.contentType??""},o.accept)){const l=`File type ${e.contentType||"unknown"} is not accepted. Accepted types: ${o.accept}`,u=new Error(l);throw this._safeEmitAttachmentAddError("not-accepted",l,void 0,u,e.contentType),u}const a={id:e.id??Ct(),type:e.type??"document",name:e.name,contentType:e.contentType,content:e.content,status:{type:"complete"}};this._attachments=[...this._attachments,a],this._notifySubscribers(),this._notifyEventSubscribers("attachmentAdd",{...a.contentType?{contentType:a.contentType}:void 0});return}const n=this.getAttachmentAdapter();if(!n){const o="Attachments are not supported",a=new Error(o);throw this._safeEmitAttachmentAddError("no-adapter",o,void 0,a,e.type),a}if(!sg({name:e.name,type:e.type},n.accept)){const o=`File type ${e.type||"unknown"} is not accepted. Accepted types: ${n.accept}`,a=new Error(o);throw this._safeEmitAttachmentAddError("not-accepted",o,void 0,a,e.type),a}const r=this._attachmentAddOperations.start(),s=o=>{if(!this._attachmentAddOperations.accept(r,o.id))return!1;const a=this._attachments.findIndex(l=>l.id===o.id);return a!==-1?this._attachments=[...this._attachments.slice(0,a),o,...this._attachments.slice(a+1)]:this._attachments=[...this._attachments,o],this._notifySubscribers(),!0};let i;try{await a2(n.add({file:e}),o=>(i=o,s(o)))}catch(o){if(this._attachmentAddOperations.isCancelled(r))return;throw i&&s({...i,status:{type:"incomplete",reason:"error",message:o instanceof Error?o.message:String(o)}}),this._safeEmitAttachmentAddError("adapter-error",o instanceof Error?o.message:String(o),i==null?void 0:i.id,o instanceof Error?o:void 0,(i==null?void 0:i.contentType)||e.type),o}finally{this._attachmentAddOperations.finish(r)}this._attachmentAddOperations.isCancelled(r)||((i==null?void 0:i.status.type)==="incomplete"&&i.status.reason==="error"?this._safeEmitAttachmentAddError("adapter-error",i.status.message??"Attachment upload did not complete successfully.",i.id,void 0,i.contentType||e.type):this._notifyEventSubscribers("attachmentAdd",{...i!=null&&i.contentType?{contentType:i.contentType}:e.type?{contentType:e.type}:void 0}))}_safeEmitAttachmentAddError(e,n,r,s,i){try{this._notifyEventSubscribers("attachmentAddError",{reason:e,message:n,...r!==void 0&&{attachmentId:r},...s!==void 0&&{error:s},...i?{contentType:i}:void 0})}catch(o){console.error("[assistant-ui] attachmentAddError subscriber threw:",o)}}async removeAttachment(e){const n=this._attachments.findIndex(s=>s.id===e);if(n===-1)throw new Error("Attachment not found");const r=this._attachments[n];if(this._cancelAttachmentAdd(e),this._isSending&&this._removedDuringSend.add(e),!Jo(r)){const s=this.getAttachmentAdapter();if(!s)throw new Error("Attachments are not supported");try{await s.remove(r)}catch(i){const o=i instanceof Error?i.message:String(i);throw this._attachments=this._attachments.map(a=>a.id===e&&!Jo(a)?{...a,status:{type:"incomplete",reason:"error",message:o}}:a),this._notifySubscribers(),i}}this._attachments=this._attachments.filter(s=>s.id!==e),this._notifySubscribers()}get dictation(){return this._dictation}_isActiveSession(e,n){return this._activeDictationSessionId===e&&this._dictationSession===n}startDictation(){const e=this.getDictationAdapter();if(!e)throw new Error("Dictation adapter not configured");const n=this._dictationSession!==void 0;if(this._dictationSession){const c=this._dictationSession;this._cleanupDictation({notify:!1}),this._stopDictationSession(c)}const r=e.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText="";let s;try{s=e.listen()}catch(c){if(n)try{this._notifySubscribers()}catch(d){console.error("[assistant-ui] Dictation replacement rollback notification threw",d)}throw c}this._dictationSession=s;const i=++this._dictationSessionIdCounter;this._activeDictationSessionId=i,this._dictation={status:s.status,inputDisabled:r},this._notifySubscribers();const o=s.onSpeech(c=>{if(!this._isActiveSession(i,s))return;const d=c.isFinal!==!1,h=this._dictationBaseText&&!this._dictationBaseText.endsWith(" ")&&c.transcript?" ":"";if(d){if(this._dictationBaseText=this._dictationBaseText+h+c.transcript,this._currentInterimText="",this._text=this._dictationBaseText,this._dictation){const{transcript:f,...p}=this._dictation;this._dictation=p}this._notifySubscribers()}else this._currentInterimText=h+c.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&(this._dictation={...this._dictation,transcript:c.transcript}),this._notifySubscribers()});this._dictationUnsubscribes.push(o);const a=s.onSpeechStart(()=>{var c;this._isActiveSession(i,s)&&(this._dictation={status:{type:"running"},inputDisabled:r,...((c=this._dictation)==null?void 0:c.transcript)&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(a);const l=s.onSpeechEnd(()=>{this._cleanupDictation({sessionId:i})});this._dictationUnsubscribes.push(l);const u=setInterval(()=>{this._isActiveSession(i,s)&&s.status.type==="ended"&&this._cleanupDictation({sessionId:i})},100);this._dictationUnsubscribes.push(()=>clearInterval(u))}stopDictation(){if(!this._dictationSession)return;const e=this._dictationSession,n=this._activeDictationSessionId,r=()=>this._cleanupDictation({sessionId:n});this._stopDictationSession(e,r)}_stopDictationSession(e,n=()=>{}){let r;try{r=e.stop()}catch(s){console.error("[assistant-ui] Dictation session stop threw",s),n();return}r.then(n,s=>{console.error("[assistant-ui] Dictation session stop rejected",s),n()})}_cleanupDictation(e){if((e==null?void 0:e.sessionId)!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)return;this._isCleaningDictation=!0;const n=r=>{try{r()}catch(s){console.error("[assistant-ui] Dictation cleanup threw",s)}};try{const r=this._dictationUnsubscribes;this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText="",this._currentInterimText="";for(const s of r)n(s);(e==null?void 0:e.notify)!==!1&&n(()=>this._notifySubscribers())}finally{this._isCleaningDictation=!1}}_notifyEventSubscribers(e,n){const r=this._eventSubscribers.get(e);r&&Yt(r,n,`Composer runtime "${e}"`)}unstable_on(e,n){const r=n;let s=this._eventSubscribers.get(e);return s||(s=new Set,this._eventSubscribers.set(e,s)),s.add(r),()=>{var i;(i=this._eventSubscribers.get(e))==null||i.delete(r)}}};const l2=t=>{var e;return(e=t.capabilities)!=null&&e.cancel?il(t):!1};var u2=class extends t1{constructor(e){super();w(this,"_queueCache");w(this,"runtime");this.runtime=e,this.connect()}get canCancel(){return l2(this.runtime)}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled&&!this.runtime.voice&&!this._isSending}get queue(){var i,o,a,l;const e=((o=(i=this.runtime).getSteerQueueItems)==null?void 0:o.call(i))??Zt,n=((l=(a=this.runtime).getQueueItems)==null?void 0:l.call(a))??Zt,r=this._queueCache;if(r&&r.steer===e&&r.queue===n)return r.flat;const s=e.length===0?n:n.length===0?e:[...e,...n];return this._queueCache={steer:e,queue:n,flat:s},s}moveQueueItem(e,n){var r,s;(s=(r=this.runtime).moveQueueItem)==null||s.call(r,e,n)}removeQueueItem(e){var n,r;(r=(n=this.runtime).removeQueueItem)==null||r.call(n,e)}getAttachmentAdapter(){var e;return(e=this.runtime.adapters)==null?void 0:e.attachments}getDictationAdapter(){var e;return(e=this.runtime.adapters)==null?void 0:e.dictation}connect(){let e=!1,n=this.runtime.isSendDisabled,r=this.runtime.voice!==void 0,s=this.queue;return this.runtime.subscribe(()=>{let i=!1;const o=this.canCancel;e!==o&&(e=o,i=!0),n!==this.runtime.isSendDisabled&&(n=this.runtime.isSendDisabled,i=!0);const a=this.runtime.voice!==void 0;r!==a&&(r=a,i=!0),s!==this.queue&&(s=this.queue,i=!0),i&&this._notifySubscribers()})}async handleSend(e,n){var r;return this.runtime.append({...e,parentId:((r=this.runtime.messages.at(-1))==null?void 0:r.id)??null,sourceId:null,startRun:n==null?void 0:n.startRun,steer:n==null?void 0:n.steer})}async handleCancel(){this.runtime.cancelRun()}},c2=class extends t1{constructor(e,n,{parentId:r,message:s}){super();w(this,"_nonTextPassthrough");w(this,"_parentId");w(this,"_sourceId");w(this,"runtime");w(this,"endEditCallback");this.runtime=e;let i=e.voice!==void 0;const o=e.subscribe(()=>{const l=e.voice!==void 0;l!==i&&(i=l,this._notifySubscribers())});this.endEditCallback=()=>{o(),n()},this._parentId=r,this._sourceId=s.id,this.setText(bo(s)),this.setRole(s.role);let a;s.role==="user"?(a=[...s.attachments??[],...s2(s.content)],this._nonTextPassthrough=[]):(a=s.attachments??[],this._nonTextPassthrough=s.content.filter(l=>l.type!=="text")),this.setAttachments(a),this.setRunConfig({...e.composer.runConfig})}get canCancel(){return!0}get canSend(){return!this.isEmpty&&!this.runtime.voice&&!this._isSending}getAttachmentAdapter(){var e;return(e=this.runtime.adapters)==null?void 0:e.attachments}getDictationAdapter(){var e;return(e=this.runtime.adapters)==null?void 0:e.dictation}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(e,n){const r=this._nonTextPassthrough.length>0?[...e.content,...this._nonTextPassthrough]:e.content,s=this.runtime.append({...e,content:r,parentId:this._parentId,sourceId:this._sourceId,startRun:n==null?void 0:n.startRun});return this.handleCancel(),s}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},n1=class extends $n{constructor(e){super();w(this,"_isInitialized",!1);w(this,"repository",new e1);w(this,"_voiceMessages",[]);w(this,"_voiceGeneration",0);w(this,"_cachedMergedMessages",null);w(this,"_cachedVoiceGeneration",-1);w(this,"_cachedMergedBase",null);w(this,"composer",new u2(this));w(this,"_contextProvider");w(this,"_editComposers",new Map);w(this,"_stopSpeaking");w(this,"speech");w(this,"_voiceSession");w(this,"_voiceUnsubs",[]);w(this,"voice");w(this,"_voiceVolume",0);w(this,"_voiceVolumeSubscribers",new Set);w(this,"getVoiceVolume",()=>this._voiceVolume);w(this,"subscribeVoiceVolume",e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e)));w(this,"_currentAssistantMsg",null);w(this,"_eventSubscribers",new Map);this._contextProvider=e}_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}_commitVoiceMessage(e){}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();const e=this._getBaseMessages();if(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e){const n=new Set(e.map(r=>r.id));this._cachedMergedMessages=[...e,...this._voiceMessages.filter(r=>!n.has(r.id))],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e}return this._cachedMergedMessages}get state(){let e;for(const n of this.messages)n.role==="assistant"&&(e=n);return(e==null?void 0:e.metadata.unstable_state)??null}getModelContext(){return this._contextProvider.getModelContext()}enrichAppendMetadata(e,n=e.parentId){var o;if(e.role!=="user")return e;const r=this.messages,s=n===null?-1:r.findIndex(a=>a.id===n),i=eA(this.getModelContext().unstable_composerMetadata,r.slice(0,s+1));return i?{...e,metadata:{...e.metadata,custom:{...(o=e.metadata)==null?void 0:o.custom,...i}}}:e}getEditComposer(e){return this._editComposers.get(e)}_isVoiceMessage(e){return e!==null&&this._voiceMessages.some(n=>n.id===e)}_resolveAppendParent(e){var n;return this._isVoiceMessage(e)?((n=this._getBaseMessages().at(-1))==null?void 0:n.id)??null:e}beginEdit(e){if(this.voice)throw new Error("Cannot edit a message while a voice session is connected");if(this._isVoiceMessage(e))throw new Error("Voice transcript messages cannot be edited");if(this._editComposers.has(e))throw new Error("Edit already in progress");this._editComposers.set(e,new c2(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){var n;try{return this.repository.getMessage(e)}catch{const r=this.repository.getMessages(),s=this._voiceMessages.findIndex(i=>i.id===e);return s!==-1?{parentId:s>0?this._voiceMessages[s-1].id:((n=r.at(-1))==null?void 0:n.id)??null,message:this._voiceMessages[s],index:r.length+s}:void 0}}getBranches(e){return this._voiceMessages.some(n=>n.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifyEventSubscribers(e,n){const r=this._eventSubscribers.get(e);r&&Yt(r,n,`Thread runtime "${e}"`)}_notifyToolApprovalAnswered(e,n,r,s){this._notifyEventSubscribers("toolApprovalAnswered",{messageId:e,toolCallId:n,toolName:r,approved:s})}submitFeedback({messageId:e,type:n,comment:r}){var c;const s=(c=this.adapters)==null?void 0:c.feedback,i=this.getMessageById(e);if(!i)throw new Error(`Message not found: ${e}`);const{message:o,parentId:a}=i,l=r==null?void 0:r.trim(),u={type:n,...l?{comment:l}:void 0};if(s==null||s.submit({message:o,...u}),o.role==="assistant"){const d={...o,metadata:{...o.metadata,submittedFeedback:u}},h=this._voiceMessages.findIndex(f=>f.id===e);h===-1?this.repository.addOrUpdateMessage(a,d):(this._voiceMessages[h]=d,this._currentAssistantMsg===o&&(this._currentAssistantMsg=d),this._markVoiceMessagesDirty())}this._notifySubscribers()}speak(e){var d;const n=(d=this.adapters)==null?void 0:d.speech;if(!n)throw new Error("Speech adapter not configured");const r=this.getMessageById(e);if(!r)throw new Error(`Message not found: ${e}`);const{message:s}=r,i=this._stopSpeaking;let o;try{i==null||i(),o=n.speak(bo(s))}catch(h){if(i&&!this._stopSpeaking)try{this._notifySubscribers()}catch(f){console.error("[assistant-ui] Speech rollback notification threw",f)}throw h}let a;const l=()=>{this._stopSpeaking=void 0,this.speech=void 0;const h=a;a=void 0,h==null||h()},u=()=>{if(this._stopSpeaking===u)try{l()}finally{o.cancel()}},c=()=>{this._stopSpeaking===u&&(o.status.type==="ended"?Jt([l,()=>this._notifySubscribers()]):(this.speech={messageId:e,status:o.status},this._notifySubscribers()))};this._stopSpeaking=u;try{if(a=o.subscribe(c),this._stopSpeaking!==u){a();return}c()}catch(h){if(this._stopSpeaking===u)try{Jt([u,()=>this._notifySubscribers()])}catch(f){console.error("[assistant-ui] Speech rollback cleanup threw",f)}throw h}}stopSpeaking(){if(!this._stopSpeaking)throw new Error("No message is being spoken");Jt([this._stopSpeaking,()=>this._notifySubscribers()])}_onVoiceConnected(){}_onVoiceDisconnected(){}_isRunActive(){if(this.isRunning)return!0;const e=this._getBaseMessages().at(-1);return(e==null?void 0:e.role)==="assistant"&&(e.status.type==="running"||e.status.type==="requires-action")}connectVoice(){var o;const e=(o=this.adapters)==null?void 0:o.voice;if(!e)throw new Error("Voice adapter not configured");if(this._isRunActive())throw new Error("Cannot start a voice session while a run is in progress or paused on a pending tool action");const n=this._voiceSession!==void 0;try{this._disconnectVoice(!1)}catch(a){console.error("[assistant-ui] Voice cleanup threw before reconnect",a)}let r;try{r=e.connect({})}catch(a){throw n&&this._voiceSession===void 0&&this._onVoiceDisconnected(),a}this._voiceSession=r;const s=[];this._voiceUnsubs=s;const i=()=>{if(this._voiceSession===r&&this._voiceUnsubs===s)return!1;try{Jt(s.splice(0))}catch(a){console.error("[assistant-ui] Detached voice setup cleanup threw",a)}return!0};try{let a="listening";if(this.voice={status:r.status,isMuted:r.isMuted,mode:a},this._voiceVolume=0,this._notifySubscribers(),i()||(s.push(r.onStatusChange(l=>{this._voiceSession===r&&(l.type==="ended"?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0,this._onVoiceDisconnected()):this.voice={status:l,isMuted:r.isMuted,mode:a},this._notifySubscribers())})),i())||(s.push(r.onModeChange(l=>{a=l,this.voice&&(this.voice={...this.voice,mode:l},this._notifySubscribers())})),i())||(s.push(r.onVolumeChange(l=>{this._voiceVolume=l,Yt(this._voiceVolumeSubscribers,void 0,"Voice volume")})),i()))return;s.push(r.onTranscript(l=>{this._handleVoiceTranscript(l)})),i()||this._onVoiceConnected()}catch(a){if(this._voiceSession===r&&this._voiceUnsubs===s){try{this._disconnectVoice(!1)}catch(l){console.error("[assistant-ui] Voice rollback cleanup threw",l)}n&&this._voiceSession===void 0&&this._onVoiceDisconnected()}else i();throw a}}_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role==="user"){if(this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal){const n={id:Ct(),role:"user",content:[{type:"text",text:e.text}],metadata:{modality:"voice",custom:{}},createdAt:new Date,status:{type:"complete",reason:"unknown"},attachments:[]};this._voiceMessages.push(n),this._commitVoiceMessage(n),this._markVoiceMessagesDirty(),this._notifySubscribers()}}else{const n=e.isFinal?{type:"complete",reason:"stop"}:{type:"running"};if(!this._currentAssistantMsg)this._currentAssistantMsg={id:Ct(),role:"assistant",content:[{type:"text",text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],modality:"voice",custom:{}},status:n,createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{const r=this._voiceMessages.indexOf(this._currentAssistantMsg);if(r===-1)return;const s={...this._currentAssistantMsg,content:[{type:"text",text:e.text}],status:n};this._voiceMessages[r]=s,this._currentAssistantMsg=s}e.isFinal&&(this._commitVoiceMessage(this._currentAssistantMsg),this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(e=!0){const n=this._voiceMessages.at(-1);if((n==null?void 0:n.role)==="assistant"&&n.status.type==="running"){const r=this._voiceMessages.length-1;this._voiceMessages[r]={...n,status:{type:"complete",reason:"stop"}},this._commitVoiceMessage(this._voiceMessages[r]),this._currentAssistantMsg=null,this._markVoiceMessagesDirty(),e&&this._notifySubscribers()}}disconnectVoice(){this._disconnectVoice(!0)}_disconnectVoice(e){this._finishVoiceAssistantMessage(!1),this._currentAssistantMsg=null;const n=this._voiceUnsubs.splice(0);this._voiceUnsubs=[];const r=this._voiceSession;this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;const s=this.speech&&this._isVoiceMessage(this.speech.messageId)?this._stopSpeaking:void 0;this._voiceMessages=[],this._markVoiceMessagesDirty();try{Jt([...n,...s?[s]:[],...r?[()=>r.disconnect()]:[],()=>Yt(this._voiceVolumeSubscribers,void 0,"Voice volume"),()=>this._notifySubscribers()])}finally{e&&r&&this._voiceSession===void 0&&this._onVoiceDisconnected()}}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(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(hf.fromArray(e??[]))}unstable_on(e,n){var i,o;const r=n;if(e==="modelContextUpdate")return((o=(i=this._contextProvider).subscribe)==null?void 0:o.call(i,()=>Yt([r],{},`Thread runtime "${e}"`)))??(()=>{});let s=this._eventSubscribers.get(e);return s||(s=new Set,this._eventSubscribers.set(e,s)),s.add(r),e==="initialize"&&this._isInitialized&&queueMicrotask(()=>{s.has(r)&&Yt([r],{},`Thread runtime "${e}"`)}),()=>{var a;(a=this._eventSubscribers.get(e))==null||a.delete(r)}}};const d2=Symbol.for("assistant-stream.tool-execution-id"),ii=t=>{try{return JSON.parse(t),!0}catch{return!1}},ig=t=>{try{return JSON.parse(t)}catch{return}},Pu=(t,e)=>{const n=ig(t),r=ig(e);return n===void 0||r===void 0?!1:nf(n,r)},Mu=t=>t[d2];var h2=class{constructor(t,e,n){w(this,"_getTools");w(this,"_callbacks");w(this,"_isClientToolCall");w(this,"_entries",new Map);w(this,"_humanInput",new Map);w(this,"_executing",new Set);w(this,"_discardedToolCallIds",new Set);w(this,"_settledResolvers",[]);w(this,"_statuses",new Map);w(this,"_ac",new AbortController);w(this,"_pendingRestore",!0);w(this,"_lastSnapshot",null);w(this,"_isRunning",!1);w(this,"_controller");w(this,"_pipelineDead",!1);w(this,"_pipelineRestartUsed",!1);this._getTools=t,this._callbacks=e,this._isClientToolCall=n,this._initPipeline()}_initPipeline(){const[t,e]=P0();this._controller=e;const r=HR(()=>this._getWrappedTools(),()=>this._ac.signal,(s,i,o)=>this._onHumanInput(s,i,o),{onExecutionStart:(s,i,o)=>this._onExecutionStart(s,o),onExecutionEnd:(s,i,o)=>this._onExecutionEnd(s,o)});t.pipeThrough(r).pipeThrough(new N0).pipeTo(new WritableStream({write:s=>{try{if(s.type!=="result")return;this._handleResultChunk(s)}catch(i){console.error("[ToolInvocationTracker] result chunk handling failed",i)}}})).catch(s=>{console.error("[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState",s),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(n){throw this._isRunning=e,n}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._discardedToolCallIds.clear(),this._lastSnapshot=null,this.abort(),this._statuses.size>0&&(this._statuses=new Map,this._invokeOnStatusesChange())}catch(t){console.error("[ToolInvocationTracker] reset failed",t)}}abort(t){try{if(this._humanInput.forEach(({reject:n})=>{try{n(new Error("Tool execution aborted"))}catch{}}),this._humanInput.clear(),t!=null&&t.discardPending)for(const[n,r]of this._entries)r.controller&&(r.argsComplete||r.hasResult||(this._discardedToolCallIds.add(n),r.skipExecute=!0));if(this._ac.abort(),this._ac=new AbortController,this._executing.size===0)return Promise.resolve();const e=new Set(this._executing);return new Promise(n=>{this._settledResolvers.push({executionIds:e,resolve:n})})}catch(e){return console.error("[ToolInvocationTracker] abort failed",e),Promise.resolve()}}resume(t,e){try{const n=this._humanInput.get(t);return n?(this._humanInput.delete(t),this._setStatus(t,{type:"executing"}),n.resolve(e),!0):!1}catch(n){return console.error("[ToolInvocationTracker] resume failed",n),!1}}getStatuses(){return this._statuses}_getWrappedTools(){const t=this._getTools();if(t)return Object.fromEntries(Object.entries(t).map(([e,n])=>{const r=n.execute,s=n.streamCall;return r===void 0&&s===void 0?[e,n]:[e,{...n,...r!==void 0&&{execute:(...[i,o])=>{const a=Mu(o),l=this._captureExecution(o.toolCallId,a);return!l||l.skipExecute?new Promise(()=>{}):r(i,o)}},...s!==void 0&&{streamCall:(...[i,o])=>{const a=Mu(o);if(this._captureExecution(o.toolCallId,a))return s(i,o)}}}]}))}_captureExecution(t,e){if(e===void 0)return;const n=this._entries.get(t);if(n!=null&&n.controller)return n.executionId===void 0&&(n.executionId=e),n.executionId===e?n:void 0}_onHumanInput(t,e,n){return new Promise((r,s)=>{const i=this._entries.get(t);if(!(i!=null&&i.controller)||i.executionId!==n){s(new Error("Tool execution aborted"));return}const o=this._humanInput.get(t);if(o)try{o.reject(new Error("Human input request was superseded by a new request"))}catch{}this._humanInput.set(t,{executionId:n,resolve:r,reject:s}),this._setStatus(t,{type:"interrupt",payload:{type:"human",payload:e}})})}_onExecutionStart(t,e){var n;this._captureExecution(t,e)&&(this._entries.get(t).skipExecute||(this._executing.add(e),((n=this._humanInput.get(t))==null?void 0:n.executionId)!==e&&this._setStatus(t,{type:"executing"})))}_onExecutionEnd(t,e){var r;if(e===void 0||!this._executing.delete(e))return;((r=this._entries.get(t))==null?void 0:r.executionId)===e&&this._deleteStatus(t);const n=[];this._settledResolvers.forEach(({executionIds:s,resolve:i})=>{if([...s].some(o=>this._executing.has(o))){n.push({executionIds:s,resolve:i});return}try{i()}catch{}}),this._settledResolvers.length=0,this._settledResolvers.push(...n)}_handleResultChunk(t){const e=t.meta.toolCallId,n=Mu(t),r=this._entries.get(e);!r||r.executionId!==n||r!=null&&r.hasResult||r.skipExecute||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 n=new Map(this._statuses);n.set(t,e),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(t){if(!this._statuses.has(t))return;const e=new Map(this._statuses);e.delete(t),this._statuses=e,this._invokeOnStatusesChange()}_warnProviderOwnedSkip(t,e){}_shouldCloseArgsStream({argsText:t,hasResult:e,clientOwned:n}){return e?!0:ii(t)?n||!this._isRunning:!1}_startActiveEntry(t,e,n,r){const s={toolName:e,controller:this._controller.addToolCallPart({toolName:e,toolCallId:t}),argsText:"",hasResult:!1,skipExecute:n,argsComplete:!1,clientOwned:r};return this._entries.set(t,s),s}_demoteEntriesToRestored(){for(const[t,e]of this._entries)if(e.controller){if(!e.argsComplete&&!e.hasResult){this._entries.delete(t);continue}this._entries.set(t,{toolName:e.toolName,argsText:e.argsText,hasResult:e.hasResult})}}_processArgsText(t,e){if(!t.controller)return;const n=e.result!==void 0;if(e.argsText!==t.argsText){let r=!0;if(t.argsComplete)Pu(t.argsText,e.argsText)&&(t.argsText=e.argsText),r=!1;else if(!e.argsText.startsWith(t.argsText))if(ii(t.argsText)&&ii(e.argsText)&&Pu(t.argsText,e.argsText)){const s=this._shouldCloseArgsStream({argsText:e.argsText,hasResult:n,clientOwned:t.clientOwned});s&&t.controller.argsText.close(),t.argsText=e.argsText,t.argsComplete=s,r=!1}else r=!1;if(r&&t.controller){const s=e.argsText.slice(t.argsText.length);t.controller.argsText.append(s);const i=this._shouldCloseArgsStream({argsText:e.argsText,hasResult:n,clientOwned:t.clientOwned});i&&t.controller.argsText.close(),t.argsText=e.argsText,t.argsComplete=i}}!t.argsComplete&&t.controller&&this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:t.clientOwned})&&(t.controller.argsText.close(),t.argsComplete=!0)}_processMessages(t){var n;const e=this._pendingRestore;for(const{part:r}of ff(t)){const s=this._entries.get(r.toolCallId);if(e){s!=null&&s.controller||this._entries.set(r.toolCallId,{toolName:r.toolName,argsText:r.argsText,hasResult:r.result!==void 0});continue}let i=s;if(r.result!==void 0&&this._discardedToolCallIds.delete(r.toolCallId),i&&!i.controller){if(i.hasResult||!(r.argsText!==i.argsText&&!(ii(i.argsText)&&ii(r.argsText)&&Pu(i.argsText,r.argsText)))&&r.result===void 0)continue;this._entries.delete(r.toolCallId),i=void 0}if(!i){const o=(n=this._isClientToolCall)==null?void 0:n.call(this,r),a=r.result===void 0&&o===!1;a&&this._warnProviderOwnedSkip(r.toolName,r.toolCallId),i=this._startActiveEntry(r.toolCallId,r.toolName,r.result!==void 0||a||this._discardedToolCallIds.has(r.toolCallId),o===!0)}if(r.approval!==void 0&&(i.skipExecute=!0),this._processArgsText(i,r),r.result!==void 0&&!i.hasResult){const{controller:o}=i;if(!o)continue;i.hasResult=!0,i.argsComplete=!0,o.setResponse(new sr({result:r.result,artifact:r.artifact,isError:r.isError,...r.modelContent!==void 0?{modelContent:r.modelContent}:{}})),o.close()}}}};const f2=Object.freeze([]),Du=(t,e)=>{Promise.resolve(e).catch(n=>{console.error(`[ExternalStoreThreadRuntimeCore] ${t} callback rejected`,n)})},p2=(t,e)=>{var n;return t&&((n=e[e.length-1])==null?void 0:n.role)!=="assistant"};var m2=class extends n1{constructor(e,n){super(e);w(this,"_capabilities",{switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1});w(this,"_messages");w(this,"isDisabled");w(this,"isSendDisabled");w(this,"suggestions",[]);w(this,"extras");w(this,"_converter",new Jm);w(this,"_pendingDeleteEvictions",new Set);w(this,"_optimistic",null);w(this,"_store");w(this,"_getInitializePromise");w(this,"_transformedQueue");w(this,"_toolInvocations",null);w(this,"_toolStatuses",new Map);w(this,"_effectiveIsRunning",!1);w(this,"_inTrackerUpdate",!1);w(this,"_pendingRunningRefresh",!1);w(this,"_toolCallToMessageId",new Map);w(this,"_messagesForToolCallIndex",null);w(this,"updateMessages",e=>{var n,r,s,i;this._store.convertMessage!==void 0?(r=(n=this._store).setMessages)==null||r.call(n,e.flatMap(iA)):(i=(s=this._store).setMessages)==null||i.call(s,e)});this.__internal_setAdapter(n)}get capabilities(){return this._capabilities}get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._hasExecutingTools(this._store)?!0:this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}get unstable_refetchThread(){if(this._store.onRefetchThread)return()=>this._store.onRefetchThread()}__internal_setGetInitializePromise(e){this._getInitializePromise=e}_runTrackerUpdate(e){this._inTrackerUpdate=!0;try{e()}finally{this._inTrackerUpdate=!1}this._pendingRunningRefresh&&(this._pendingRunningRefresh=!1,this._refreshEffectiveIsRunning())}_refreshEffectiveIsRunning(){const e=this._getEffectiveIsRunning(this._store);this._effectiveIsRunning!==e&&(this._effectiveIsRunning=e,this._notifyEventSubscribers(e?"runStart":"runEnd",{}),this._notifySubscribers())}_hasExecutingTools(e){if(e.unstable_enableToolInvocations!==!0||this._toolInvocations===null)return!1;for(const n of this._toolStatuses.values())if(n.type==="executing")return!0;return!1}_getEffectiveIsRunning(e){return(e.isRunning??!1)||this._hasExecutingTools(e)}beginEdit(e){if(!this._store.onEdit)throw new Error("Runtime does not support editing.");super.beginEdit(e)}__internal_setAdapter(e){this._store!==e&&this._updateStoreSnapshot(e)}_updateStoreSnapshot(e){var h,f,p,g,_,m,y,v,S,I,b,P,A;const n=this._effectiveIsRunning;this.isDisabled=e.isDisabled??!1,this.isSendDisabled=e.isSendDisabled??!1;const r=this._store;this._store=e;const s=this._getEffectiveIsRunning(e),i=e.unstable_messageRepositoryInstance,o=i!==void 0&&i!==this.repository;o&&(this.repository=i,this._pendingDeleteEvictions.clear()),(r==null?void 0:r.queue)!==e.queue&&(this._transformedQueue=void 0,(f=(h=e.queue)==null?void 0:h.__internal_setDispatchTransform)==null||f.call(h,D=>{var k;const x=((k=this.messages.at(-1))==null?void 0:k.id)??null;return this.enrichAppendMetadata({...D,parentId:x},x)}),(p=e.queue)!=null&&p.__internal_setDispatchTransform&&(this._transformedQueue=e.queue)),this.extras!==e.extras&&(this.extras=e.extras);const a=e.suggestions??f2;ar(this.suggestions,a)||(this.suggestions=a);const l={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,refetchThread:this._store.onRefetchThread!==void 0,cancel:this._store.onCancel!==void 0,speech:((g=this._store.adapters)==null?void 0:g.speech)!==void 0,dictation:((_=this._store.adapters)==null?void 0:_.dictation)!==void 0,voice:((m=this._store.adapters)==null?void 0:m.voice)!==void 0,unstable_copy:((y=this._store.unstable_capabilities)==null?void 0:y.copy)!==!1,attachments:!!((v=this._store.adapters)!=null&&v.attachments),feedback:!!((S=this._store.adapters)!=null&&S.feedback),queue:this._store.queue!==void 0};ar(this._capabilities,l)||(this._capabilities=l);let u;if(e.messageRepository){if(r&&!o&&r.isRunning===e.isRunning&&r.messageRepository===e.messageRepository&&n===s){this._notifySubscribers();return}const D=e.messageRepository.messages,x=e.messageRepository.headId??((I=D.at(-1))==null?void 0:I.message.id)??null;if(r&&!o&&r.messageRepository===e.messageRepository)this.repository.resetHead(x),u=this.repository.getMessages();else{const k=new Set(D.map(({message:R})=>R.id));for(const{message:R,parentId:M}of D)this.repository.addOrUpdateMessage(M,R);for(const{message:R}of this.repository.export().messages)k.has(R.id)||this.repository.deleteMessage(R.id);this._pendingDeleteEvictions.clear(),this.repository.resetHead(x),u=this.repository.getMessages()}}else if(e.messages){if(r){if(r.convertMessage!==e.convertMessage)this._converter=new Jm;else if(!o&&r.isRunning===e.isRunning&&r.messages===e.messages&&n===s){this._notifySubscribers();return}}u=e.convertMessage?this._converter.convertMessages(e.messages,(k,R,M)=>{var $;if(!e.convertMessage)return R;const L=M===((($=e.messages)==null?void 0:$.length)??0)-1,z=`${oA}${M}`;if(k&&(k.role!=="assistant"||!fA(k.status)||k.status===Ym(k.content,L,s))){if(k.id.startsWith("__external_store_fallback_")&&k.id!==z){const U={...k,id:z};return Wm(U,R),U}return k}const W=e.convertMessage(R,M),K=Os(W,z,Ym(W.content,L,s));return Wm(K,R),K}):e.messages;const D=new Set,x=[];for(let k=u.length-1;k>=0;k--){const R=u[k];if(D.has(R.id)){console.warn(`ExternalStoreThreadRuntimeCore: duplicate message id "${R.id}" in the provided messages array; keeping the last occurrence.`);continue}D.add(R.id),x.push(R)}x.length!==u.length&&(u=x.reverse());for(let k=0;k<u.length;k++){const R=u[k],M=u[k-1];this.repository.addOrUpdateMessage((M==null?void 0:M.id)??null,R)}if(this._pendingDeleteEvictions.size>0){const k=new Set(u.map(R=>R.id));for(const R of this._pendingDeleteEvictions)if(this._pendingDeleteEvictions.delete(R),!k.has(R)){try{this.repository.getMessage(R)}catch{continue}this.repository.deleteMessage(R)}}}else throw new Error("ExternalStoreAdapter must provide either 'messages' or 'messageRepository'");u.length>0&&this.ensureInitialized(),this._effectiveIsRunning=s,n!==s&&(s?this._notifyEventSubscribers("runStart",{}):this._notifyEventSubscribers("runEnd",{}));let c=null;if(p2(s,u)){const D=((b=u.at(-1))==null?void 0:b.id)??null;((P=this._optimistic)==null?void 0:P.parentId)!==D&&(this._optimistic={id:Ct(),parentId:D}),c=this._optimistic.id,this.repository.addOrUpdateMessage(D,Os({role:"assistant",content:[],metadata:{isOptimistic:!0}},c,{type:"running"}))}c===null&&(this._optimistic=null),this.repository.resetHead(c??((A=u.at(-1))==null?void 0:A.id)??null);const d=this.repository.getMessages();if((!this._messages||!Xm(this._messages,d))&&(this._messages=d),this._voiceMessages.length>0){const D=new Set(this._messages.map(k=>k.id)),x=this._voiceMessages.filter(k=>!D.has(k.id));x.length!==this._voiceMessages.length&&(this._voiceMessages=x,this._markVoiceMessagesDirty())}o&&this._runTrackerUpdate(()=>{var D;return(D=this._toolInvocations)==null?void 0:D.reset()}),this._runTrackerUpdate(()=>this._driveToolInvocations()),this._notifySubscribers()}_driveToolInvocations(){var e,n;if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._toolStatuses=new Map,(n=(e=this._store).setToolStatuses)==null||n.call(e,{}));return}this._toolInvocations||(this._toolInvocations=new h2(()=>this.getModelContext().tools,{onResult:r=>{var s,i;try{const o=this._findMessageIdForToolCall(r.toolCallId);if(o===void 0)return;Du("onAddToolResult",(i=(s=this._store).onAddToolResult)==null?void 0:i.call(s,{messageId:o,toolCallId:r.toolCallId,toolName:r.toolName,result:r.result,isError:r.isError,...r.artifact!==void 0&&{artifact:r.artifact},...r.modelContent!==void 0&&{modelContent:r.modelContent}}))}catch(o){console.error("[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed",o)}},onStatusesChange:r=>{var i,o;const s=this._hasExecutingTools(this._store);this._toolStatuses=r;try{(o=(i=this._store).setToolStatuses)==null||o.call(i,Object.fromEntries(r))}finally{s!==this._hasExecutingTools(this._store)&&(this._inTrackerUpdate?this._pendingRunningRefresh=!0:this._updateStoreSnapshot(this._store))}}},r=>{var s,i;return(i=(s=this._store).unstable_isClientToolCall)==null?void 0:i.call(s,r)})),this._toolInvocations.setState({messages:this._messages,isRunning:this._getEffectiveIsRunning(this._store),...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_findMessageIdForToolCall(e){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();for(const{part:n,messageId:r}of ff(this._messages))this._toolCallToMessageId.set(n.toolCallId,r);this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(e)}switchToBranch(e){if(!this._store.setMessages)throw new Error("Runtime does not support switching branches.");if(this._getEffectiveIsRunning(this._store))return;const n=this._store.unstable_onBranchChange,r=n?this.repository.canonicalHeadId:null;this.repository.switchToBranch(e),this._pendingDeleteEvictions.clear(),this.updateMessages(this.repository.getMessages()),n&&this._notifyBranchChange(r,n)}_notifyBranchChange(e,n){const r=this.repository.canonicalHeadId;r!==e&&n({headId:r,visibleMessageIds:this.repository.getMessages().map(s=>s.id)})}async append(e){var o,a,l;let n={...e,parentId:this._resolveAppendParent(e.parentId)};if(this.voice)throw new Error("Cannot send a text message while a voice session is connected");if(this._isVoiceMessage(n.sourceId))throw new Error("Voice transcript messages cannot be edited");const r=n.sourceId!=null||n.parentId!==(((o=this._getBaseMessages().at(-1))==null?void 0:o.id)??null);n=!r&&this._store.queue&&this._store.queue===this._transformedQueue?n:this.enrichAppendMetadata(n);const s=no(this);this.ensureInitialized();const i=(a=this._getInitializePromise)==null?void 0:a.call(this);if(!r&&this._store.queue){if(i&&await i,!Ii(this,s))return;n.steer??this._getEffectiveIsRunning(this._store)?this._store.queue.steer(n):this._store.queue.enqueue(n);return}if(i==null||i.catch(()=>{}),(n.startRun??n.role==="user")&&await((l=this._toolInvocations)==null?void 0:l.abort({discardPending:!0})),!!Ii(this,s))if(r){if(!this._store.onEdit)throw new Error("Runtime does not support editing messages.");this._pendingDeleteEvictions.clear(),await this._store.onEdit(n)}else await this._store.onNew(n)}_commitVoiceMessage(e){var n,r;(r=(n=this._store).onVoiceTranscript)==null||r.call(n,e)}async deleteMessage(e){var r;if(this._store.onDelete){this.repository.getMessages().some(s=>s.id===e)&&this._pendingDeleteEvictions.add(e);try{await this._store.onDelete(e)}catch(s){throw this._pendingDeleteEvictions.delete(e),s}return}if(!this._store.setMessages)throw new Error("Runtime does not support deleting messages.");this._getEffectiveIsRunning(this._store)&&await((r=this._toolInvocations)==null?void 0:r.abort());const n=this.repository.getMessages();if(n.findIndex(s=>s.id===e)===-1)throw new Error("Message not found.");this._pendingDeleteEvictions.clear(),this.updateMessages(n.filter(s=>s.id!==e)),this._evictDeletedMessage(e)}_evictDeletedMessage(e){if(!e.startsWith("__external_store_fallback_")){try{this.repository.getMessage(e)}catch{return}this.repository.deleteMessage(e),this._publishRepositoryMessages()}}_publishRepositoryMessages(){const e=this.repository.getMessages();Xm(this._messages,e)||(this._messages=e),this._notifySubscribers()}getQueueItems(){var e,n;return((n=(e=this._store)==null?void 0:e.queue)==null?void 0:n.items)??Zt}getSteerQueueItems(){var e,n;return((n=(e=this._store)==null?void 0:e.queue)==null?void 0:n.steerItems)??Zt}moveQueueItem(e,n){var r,s;(s=(r=this._store)==null?void 0:r.queue)==null||s.move(e,n)}removeQueueItem(e){var n,r;(r=(n=this._store)==null?void 0:n.queue)==null||r.remove(e)}async startRun(e){var n;if(!this._store.onReload)throw new Error("Runtime does not support reloading messages.");if(this.voice)throw new Error("Cannot start a run while a voice session is connected");if(this._isVoiceMessage(e.sourceId))throw new Error("Voice transcript messages cannot be reloaded");this._pendingDeleteEvictions.clear(),await((n=this._toolInvocations)==null?void 0:n.abort({discardPending:!0})),await this._store.onReload(e.parentId,e)}async resumeRun(e){if(!this._store.onResume)throw new Error("Runtime does not support resuming runs.");if(this.voice)throw new Error("Cannot start a run while a voice session is connected");if(this._isVoiceMessage(e.sourceId))throw new Error("Voice transcript messages cannot be reloaded");await this._store.onResume(e)}exportExternalState(){if(!this._store.onExportExternalState)throw new Error("Runtime does not support exporting external states.");return this._store.onExportExternalState()}importExternalState(e){if(!this._store.onLoadExternalState)throw new Error("Runtime does not support importing external states.");this._runTrackerUpdate(()=>{var n;return(n=this._toolInvocations)==null?void 0:n.reset()}),this._store.onLoadExternalState(e)}unstable_notifySessionReset(){var e,n;this._runTrackerUpdate(()=>{var r;return(r=this._toolInvocations)==null?void 0:r.reset()}),(n=(e=this._store.queue)==null?void 0:e.__internal_notifyCancelled)==null||n.call(e)}cancelRun(){var o,a,l,u;if(!this._store.onCancel)throw new Error("Runtime does not support cancelling runs.");const e=no(this);(o=this._toolInvocations)==null||o.abort({discardPending:!0}),(l=(a=this._store.queue)==null?void 0:a.__internal_notifyCancelled)==null||l.call(a),Du("onCancel",this._store.onCancel()),this.dropEmptyOptimisticHead();const n=this.repository.getMessages(),r=n[n.length-1],s=this._store.setMessages!==void 0&&(r==null?void 0:r.role)==="user"&&r.id===((u=n.at(-1))==null?void 0:u.id)&&r.content.every(c=>c.type==="text")?r:void 0;let i;if(s){const c={text:bo(s),attachments:s.attachments,quote:s.metadata.custom.quote};this.composer.restoreDraft(c)&&(this.repository.deleteMessage(s.id),i={id:s.id,draft:c})}this._publishRepositoryMessages(),setTimeout(()=>{var c;if(Ii(this,e)){if(this.dropEmptyOptimisticHead(),i){const d=this.repository.getMessages();((c=d.at(-1))==null?void 0:c.id)===i.id?this.repository.deleteMessage(i.id):d.some(h=>h.id===i.id)&&this.composer.retractDraft(i.draft)}this._publishRepositoryMessages(),this.updateMessages(this._messages)}},0)}dropEmptyOptimisticHead(){const e=this.repository.getMessages().at(-1);e&&e.metadata.isOptimistic&&e.content.length===0&&this.repository.deleteMessage(e.id)}addToolResult(e){if(!this._store.onAddToolResult)throw new Error("Runtime does not support tool results.");Du("onAddToolResult",this._store.onAddToolResult(e))}resumeToolCall(e){var n;if(!(((n=this._toolInvocations)==null?void 0:n.resume(e.toolCallId,e.payload))??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(e);return}throw new Error(`Tool call ${e.toolCallId} is not waiting for resume.`)}}respondToToolApproval(e){if(!this._store.onRespondToToolApproval)throw new Error("Runtime does not support tool approvals.");const n=this.messages.findLast(s=>s.role==="assistant"&&s.content.some(i=>{var o;return i.type==="tool-call"&&((o=i.approval)==null?void 0:o.id)===e.approvalId})),r=n==null?void 0:n.content.find(s=>{var i;return s.type==="tool-call"&&((i=s.approval)==null?void 0:i.id)===e.approvalId});try{return Promise.resolve(this._store.onRespondToToolApproval(e)).then(()=>{n&&(r==null?void 0:r.type)==="tool-call"&&this._notifyToolApprovalAnswered(n.id,r.toolCallId,r.toolName,e.approved)})}catch(s){return Promise.reject(s)}}reset(e){const n=new e1;n.import(hf.fromArray(e??[])),this.updateMessages(n.getMessages())}import(e){super.import(e),this._store.onImport&&this._store.onImport(this.repository.getMessages())}};const og=t=>{var e;return((e=t.adapters)==null?void 0:e.threadList)??{}};var g2=class extends df{constructor(e){super();w(this,"threads");this.threads=new t2(og(e),()=>new m2(this._contextProvider,e))}setAdapter(e){this.threads.__internal_setAdapter(og(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}};const y2=t=>{var p;const e=O(21),{modelContext:n,feedback:r}=of()??{};let s;e:{if(!r||(p=t.adapters)!=null&&p.feedback){s=t;break e}let g;e[0]!==r||e[1]!==t.adapters?(g={...t.adapters,feedback:r},e[0]=r,e[1]=t.adapters,e[2]=g):g=e[2];let _;e[3]!==t||e[4]!==g?(_={...t,adapters:g},e[3]=t,e[4]=g,e[5]=_):_=e[5],s=_}const i=s;let o;e[6]!==i?(o=()=>new g2(i),e[6]=i,e[7]=o):o=e[7];const[a]=ce(o);let l;e[8]!==a.threads?(l=()=>()=>{ro(a.threads.getMainThreadRuntimeCore())},e[8]=a.threads,e[9]=l):l=e[9];let u;e[10]!==a?(u=[a],e[10]=a,e[11]=u):u=e[11],J(l,u);let c;e[12]!==i||e[13]!==a?(c=()=>{a.setAdapter(i)},e[12]=i,e[13]=a,e[14]=c):c=e[14],J(c);let d,h;e[15]!==n||e[16]!==a?(d=()=>{if(n)return a.registerModelContextProvider(n)},h=[n,a],e[15]=n,e[16]=a,e[17]=d,e[18]=h):(d=e[17],h=e[18]),J(d,h);let f;return e[19]!==a?(f=new cf(a),e[19]=a,e[20]=f):f=e[20],f},r1=t=>{var e;return((e=t.status)==null?void 0:e.type)!=="running"},v2=async(t,e)=>{var r;const n=RR.fromAssistantStream(t);for await(const s of n){const i=(r=s.parts.filter(o=>o.type==="text")[0])==null?void 0:r.text;i!=null&&i.trim()&&await e(i)}},_2=(t,e)=>{const n=()=>void e.generateTitle({automatic:!0}).catch(i=>{f0(i)||console.error("[assistant-ui] Thread title generation failed",i)}),r=()=>t.getState().messages.some(r1);if(r())return n(),()=>{};const s=t.subscribe(()=>{r()&&(s(),n())});return s},w2=({threadId:t,generation:e,runtimeHook:n,publish:r,itemRuntime:s})=>{var g;const i=n(),o=(g=i==null?void 0:i.thread)==null?void 0:g.__internal_threadBinding,a=_t(()=>{o&&r(t,o.getState(),e)},[t,e,o,r]),l=te(!1);l.current||a(),J(()=>{if(o)return l.current=!0,a(),o.outerSubscribe(a)},[o,a]);const u=te(void 0),c=te(!1),d=te(void 0),h=te(!1),f=ht(()=>{if(c.current||s.getState().status!=="new")return;c.current=!0;const _=s.initialize();u.current=_,_.then(()=>{var m;h.current&&((m=d.current)==null||m.call(d),d.current=_2(i.thread,s))},()=>{u.current===_&&(u.current=void 0,c.current=!1)})}),p=ht(()=>(f(),u.current));return J(()=>{if(!o)return;const _=o.getState(),m=_.__internal_setGetInitializePromise;typeof m=="function"&&m.call(_,p)},[o]),J(()=>{var m;if(!((m=i==null?void 0:i.threads)!=null&&m.main))return;c.current=!1,h.current=!0;const _=i.threads.main.unstable_on("initialize",f);return()=>{var y;h.current=!1,_(),(y=d.current)==null||y.call(d),d.current=void 0}},[i]),i},x2=({threadId:t,generation:e,parentList:n,runtimeHook:r,parentClient:s,adapters:i,publish:o,destroySignal:a})=>{const l=ge(()=>new mi(new jt({path:{ref:`threadItems[threadId=${t}]`,threadSelector:{type:"threadId",threadId:t}},getState:()=>{var d;const c=n.getItemById(t);return c?{id:c.id,remoteId:c.remoteId,externalId:c.externalId,title:c.title,lastMessageAt:c.lastMessageAt,custom:c.custom,status:c.status,isMain:c.id===n.mainThreadId,isRunning:((d=n.unstable_isThreadRunning)==null?void 0:d.call(n,c.id))??!1}:Bt},subscribe:c=>n.subscribe(c)}),n),[n,t]),{client:u}=s0(s,{threadListItem:tf({runtime:l})});return Xw(a,function(){return Gw(u,function(){return tA(i,function(){return w2({threadId:t,generation:e,runtimeHook:r,publish:o,itemRuntime:l})})})})},S2=de(x2),b2=["runStart","runEnd","initialize","modelContextUpdate"],T2=t=>{const e=O(3),{detectorRef:n}=t;let r,s;return e[0]!==n?(r=()=>{n.current=!0},s=[n],e[0]=n,e[1]=r,e[2]=s):(r=e[1],s=e[2]),rn(r,s),null};var k2=class extends $n{constructor(e,n){super();w(this,"runtimeHook");w(this,"adapterStore",new Zi({defaultAdapters:null,threadAdapters:new Map}));w(this,"hostStore",new Zi({threads:[],hookEpoch:0}));w(this,"pendingThreadAdapters",new Map);w(this,"instances",new Map);w(this,"nextGeneration",0);w(this,"parent");w(this,"runningSubscribers",new Set);w(this,"threadEventSubscribers",new Set);w(this,"_publish",(e,n,r)=>{this._publishThreadRuntime(e,n,r)});w(this,"replacedSubscribers",new Set);w(this,"__internal_RenderThreadRuntimes",({provider:e})=>(et(this.hostStore),Array.from(this.instances.entries()).map(([n,{generation:r}])=>T.jsx(this._OuterActiveThreadProvider,{threadId:n,provider:e},`${n}:${r}`))));w(this,"__internal_Host",({parentClient:e})=>{const n=et(this.hostStore),r=et(this.adapterStore),s=this._threadElements(e,n,r),{effects:i}=Uw(function(){return Yi(s)});return rn(i),null});w(this,"_OuterActiveThreadProvider",Ue(({threadId:e,provider:n})=>{const r=ge(()=>new X0(this.parent).getItemById(e),[e]),s=te(!1);return J(()=>{},[n]),T.jsx(pA,{runtime:r,children:T.jsx(n,{children:T.jsx(this._AdapterSink,{threadId:e,detectorRef:s})})})}));w(this,"_AdapterSink",({threadId:e,detectorRef:n})=>{const r=of();return this.pendingThreadAdapters.set(e,r),rn(()=>(this.__internal_setThreadAdapters(e,r),()=>{this.pendingThreadAdapters.get(e)===r&&this.pendingThreadAdapters.delete(e),this.__internal_setThreadAdapters(e,null)}),[e,r]),T.jsx(T2,{detectorRef:n})});this.parent=n,this.runtimeHook=e}_whenRuntimeAttached(e){return new Promise((n,r)=>{const s=()=>{const o=this.instances.get(e);if(!o)i(),r(new Error("Thread was deleted before runtime was started"));else{if(!o.runtime||o.publishedGeneration!==o.generation)return;i(),n(o.runtime)}},i=this.subscribe(s);s()})}startThreadRuntime(e){if(!this.instances.has(e)){const n=this.nextGeneration++;this.instances.set(e,{generation:n,isRunning:!1,destroy:new AbortController}),this._syncHostThreads()}return this._whenRuntimeAttached(e)}__internal_restartThreadRuntime(e){var r;const n=this.instances.get(e);return n?(n.runtime&&ro(n.runtime),(r=n.unsubscribeRunning)==null||r.call(n),n.unsubscribeRunning=void 0,n.destroy.abort(),n.destroy=new AbortController,n.generation=this.nextGeneration++,this._syncHostThreads(),this._notifySubscribers(),this._whenRuntimeAttached(e)):this.startThreadRuntime(e)}getThreadRuntimeCore(e){const n=this.instances.get(e);if(n)return n.runtime}__internal_isThreadRunning(e){var n;return((n=this.instances.get(e))==null?void 0:n.isRunning)??!1}__internal_subscribeRunningChanged(e){return this.runningSubscribers.add(e),()=>this.runningSubscribers.delete(e)}__internal_subscribeThreadEvents(e){return this.threadEventSubscribers.add(e),()=>this.threadEventSubscribers.delete(e)}_publishThreadRuntime(e,n,r){const s=this.instances.get(e);if(!s||s.generation!==r)return;const i=s.runtime;s.runtime=n,s.publishedGeneration=r,i!==n&&this._trackRunning(e,s),this._notifySubscribers(),i!==void 0&&i!==n&&Jt(this.replacedSubscribers)}__internal_subscribeRuntimeReplaced(e){return this.replacedSubscribers.add(e),()=>this.replacedSubscribers.delete(e)}_trackRunning(e,n){var i;(i=n.unsubscribeRunning)==null||i.call(n);const r=n.runtime;if(!r){n.unsubscribeRunning=void 0,this._setRunning(n,!1);return}this._setRunning(n,il(r));const s=[r.subscribe(()=>{this._setRunning(n,il(r))}),...b2.map(o=>r.unstable_on(o,()=>{Yt(this.threadEventSubscribers,{threadId:e,type:o},`Thread event "${o}"`)}))];n.unsubscribeRunning=()=>{for(const o of s)o()}}_setRunning(e,n){e.isRunning!==n&&(e.isRunning=n,Jt(this.runningSubscribers))}stopThreadRuntime(e){var r;const n=this.instances.get(e);n!=null&&n.runtime&&ro(n.runtime),(r=n==null?void 0:n.unsubscribeRunning)==null||r.call(n),n==null||n.destroy.abort(),this.instances.delete(e),this.pendingThreadAdapters.delete(e),this._syncHostThreads(),this._notifySubscribers()}setRuntimeHook(e){if(this.runtimeHook===e)return;this.runtimeHook=e;const n=this.hostStore.getState();this.hostStore.setState({...n,hookEpoch:n.hookEpoch+1})}__internal_setDefaultAdapters(e){const n=this.adapterStore.getState();n.defaultAdapters!==e&&this.adapterStore.setState({...n,defaultAdapters:e})}__internal_setThreadAdapters(e,n){const r=this.adapterStore.getState(),s=new Map(r.threadAdapters);n===null?s.delete(e):s.set(e,n),this.adapterStore.setState({...r,threadAdapters:s})}__internal_dispose(){for(const e of[...this.instances.keys()])this.stopThreadRuntime(e)}_syncHostThreads(){const e=this.hostStore.getState();this.hostStore.setState({...e,threads:Array.from(this.instances.entries()).map(([n,{generation:r,destroy:s}])=>({id:n,generation:r,destroySignal:s.signal}))})}_threadElements(e,{threads:n,hookEpoch:r},s){const i=this.runtimeHook;return n.map(({id:o,generation:a,destroySignal:l})=>{const u=this.pendingThreadAdapters.has(o)?this.pendingThreadAdapters.get(o):s.threadAdapters.get(o)??s.defaultAdapters;return kt(`${o}:${a}:${r}`,S2({threadId:o,generation:a,parentList:this.parent,runtimeHook:i,parentClient:e,adapters:u,publish:this._publish,destroySignal:l}))})}__internal_useHost(e){const n=et(this.hostStore),r=et(this.adapterStore);return Yi(this._threadElements(e,n,r))}};function C2(t,e,n,...r){if(!n)return;const s=i=>{try{console.error(`[${t}] ${e} callback threw an error`,i)}catch{}};try{const i=n(...r);if(i!==null&&(typeof i=="object"||typeof i=="function")&&"then"in i&&typeof i.then=="function")return Promise.resolve(i).then(()=>{},o=>s(o))}catch(i){s(i)}}const ag=(t,e,n)=>n.reduce((r,s)=>(s==null?void 0:s(r,e))??r,t);var I2=class extends $n{constructor(e){super();w(this,"_pendingTransforms",[]);w(this,"_completedOptimistics",[]);w(this,"_nextTransformOrder",0);w(this,"_epoch",0);w(this,"_baseValue");w(this,"_cachedValue");this._baseValue=e,this._cachedValue=e}_updateState(){const e=[...this._pendingTransforms.map(n=>({order:n.order,apply:r=>ag(r,n.task,[n.loading,n.optimistic])})),...this._completedOptimistics.map(({order:n,optimistic:r})=>({order:n,apply:r}))].sort((n,r)=>n.order-r.order);this._cachedValue=e.reduce((n,r)=>r.apply(n),this._baseValue),this._notifySubscribers()}get baseValue(){return this._baseValue}get value(){return this._cachedValue}update(e){this._baseValue=e,this._updateState()}reset(e){this._epoch++,this._pendingTransforms.length=0,this._completedOptimistics.length=0,this._baseValue=e,this._cachedValue=e,this._notifySubscribers()}async optimisticUpdate(e){const n=this._epoch,r=this._nextTransformOrder++,s=e.execute(),i={...e,order:r,task:s};try{this._pendingTransforms.push(i),this._updateState();const o=await s;if(n!==this._epoch)return o;this._baseValue=ag(this._baseValue,o,[e.optimistic,e.then]);for(const a of this._completedOptimistics)(e.then||a.order>i.order)&&(this._baseValue=a.optimistic(this._baseValue));return e.optimistic&&(this._completedOptimistics.push({order:i.order,optimistic:e.optimistic}),this._completedOptimistics.sort((a,l)=>a.order-l.order)),o}finally{const o=this._pendingTransforms.indexOf(i);o>-1&&this._pendingTransforms.splice(o,1),this._pendingTransforms.length===0&&(this._completedOptimistics.length=0),this._updateState()}}};const Ou=new Error("This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead.");var E2=class extends KA{constructor(){super(...arguments);w(this,"messages",[]);w(this,"composer",QA(Ou,!0));w(this,"isLoading",!0)}get error(){return Ou}getMessageById(){}getBranches(){return[]}export(){return{messages:[]}}subscribe(){return()=>{}}waitForUpdate(){return Promise.reject(Ou)}};const R2=new E2;const A2="__LOCALID_",Nu=t=>t||void 0,Lu=(t,e)=>{let n=[...e.threadIds],r=[...e.archivedThreadIds];const s=Te(e.threadIdMap),i=Te(e.threadData),o=new Set([...n,...r]);for(const a of t){switch(a.status){case"regular":case"archived":break;default:{const f=a.status;throw new Error(`Unsupported state: ${f}`)}}const l=s[a.remoteId],u=l!==void 0?i[l]:void 0,c=(u==null?void 0:u.id)??a.remoteId,d=l??c,h=u!==void 0&&u.status!=="new"?u.initializeTask:void 0;o.has(c)?u!==void 0&&u.status!==a.status&&(a.status==="regular"?(r=r.filter(f=>f!==c),n.push(c)):(n=n.filter(f=>f!==c),r.push(c))):(o.add(c),a.status==="regular"?n.push(c):r.push(c)),s[c]=d,s[a.remoteId]=d,i[d]={...(u==null?void 0:u.localOrigin)===!0?{localOrigin:!0}:{},id:c,remoteId:a.remoteId,externalId:a.externalId,status:a.status,title:a.title,lastMessageAt:a.lastMessageAt,custom:a.custom,initializeTask:h??Promise.resolve({remoteId:a.remoteId,externalId:a.externalId})}}return{threadIds:n,archivedThreadIds:r,threadIdMap:s,threadData:i}},P2=()=>({isLoading:!0,loadError:void 0,isLoadingMore:!1,cursor:void 0,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:Te(),threadData:Te()}),lg=t=>{let e;do e=`${A2}${Ct()}`;while(t.threadIdMap[e]);const n=e;return{id:e,state:{...t,newThreadId:e,threadIdMap:Te(t.threadIdMap,{[e]:n}),threadData:Te(t.threadData,{[n]:{status:"new",id:e,remoteId:void 0,externalId:void 0,title:void 0,custom:void 0,localOrigin:!0}})}}},M2=(t,e,n)=>{const r=new Set(t.threadIds),s=new Set(t.archivedThreadIds),i=[],o=[],a=(u,c)=>u.has(c.id)||c.remoteId!==void 0&&u.has(c.remoteId);for(const u of Object.values(t.threadData)){const c=n.get(u.id);c!==void 0&&c!=="new"||c===void 0&&u.localOrigin!==!0||(u.status==="regular"&&!a(r,u)?(i.push(u),r.add(u.id)):u.status==="archived"&&!a(s,u)&&(o.push(u),s.add(u.id)))}if(i.length===0&&o.length===0)return t;const l=(u,c)=>{const d=u.indexOf(c.id);if(d!==-1)return d;const h=c.remoteId!==void 0?u.indexOf(c.remoteId):-1;return h!==-1?h:Number.MAX_SAFE_INTEGER};return i.sort((u,c)=>l(e.threadIds,u)-l(e.threadIds,c)),o.sort((u,c)=>l(e.archivedThreadIds,u)-l(e.archivedThreadIds,c)),{...t,threadIds:[...i.map(u=>u.id),...t.threadIds],archivedThreadIds:[...o.map(u=>u.id),...t.archivedThreadIds]}},D2=t=>new Map(Object.values(t.threadData).map(e=>[e.id,e.status])),xr=(t,e)=>{const n=Object.hasOwn(t.threadIdMap,e)?t.threadIdMap[e]:void 0;if(n!==void 0)return Object.hasOwn(t.threadData,n)?t.threadData[n]:void 0},O2=(t,e,n,r,s)=>{const i=e,o=Object.hasOwn(t.threadData,i)?t.threadData[i]:void 0;if(!o)return{state:t,removedMappingId:void 0,survivorMappingId:i};const a=Object.hasOwn(t.threadIdMap,n)?t.threadIdMap[n]:void 0,l=a!==void 0&&a!==i&&Object.hasOwn(t.threadData,a)?t.threadData[a]:void 0,u=a!==void 0&&l!==void 0?{mappingId:a,data:l}:void 0,c=s!==void 0&&Object.hasOwn(t.threadIdMap,s)?t.threadIdMap[s]:void 0,d=u!==void 0&&c===u.mappingId?u.mappingId:i,h=u===void 0?void 0:d===i?u.mappingId:i,f=r??(u==null?void 0:u.data.externalId),p=Te(t.threadData);h!==void 0&&delete p[h];const g={...o,id:d,initializeTask:Promise.resolve({remoteId:n,externalId:f}),remoteId:n,externalId:f};p[d]={...u==null?void 0:u.data,...g,title:o.title??(u==null?void 0:u.data.title),lastMessageAt:("lastMessageAt"in o?o.lastMessageAt:void 0)??(u&&"lastMessageAt"in u.data?u.data.lastMessageAt:void 0),custom:o.custom??(u==null?void 0:u.data.custom)};const _=Te(t.threadIdMap);if(h!==void 0)for(const[y,v]of Object.entries(_))v===h&&(_[y]=d);_[e]=d,_[n]=d;const m=y=>u===void 0?y:y.filter(v=>v!==u.data.id).map(v=>v===o.id?d:v);return{state:{...t,threadIds:m(t.threadIds),archivedThreadIds:m(t.archivedThreadIds),threadIdMap:_,threadData:p},removedMappingId:h,survivorMappingId:d}},s1=(t,e,n,r)=>{const s=xr(t,e);if(!s)return t;const{id:i,status:o}=s;if(o===n)return t;let a;if(n!=="deleted")if(s.status==="new"){if(r===void 0)return t;a={...s,initializeTask:r,status:n}}else a={...s,status:n};const l={...t};switch(o){case"new":l.newThreadId=void 0;break;case"regular":l.threadIds=l.threadIds.filter(u=>u!==i);break;case"archived":l.archivedThreadIds=l.archivedThreadIds.filter(u=>u!==i);break;default:throw new Error(`Unsupported state: ${o}`)}switch(n){case"regular":l.threadIds=[i,...l.threadIds];break;case"archived":l.archivedThreadIds=[i,...l.archivedThreadIds];break;case"deleted":{const u=t.threadIdMap[e],c=Te(l.threadData);delete c[u],l.threadData=c;const d=Te(l.threadIdMap);for(const[h,f]of Object.entries(d))f===u&&delete d[h];l.threadIdMap=d;break}default:throw new Error(`Unsupported state: ${n}`)}return a!==void 0&&(l.threadData={...l.threadData,[i]:a}),l},ju=(t,e,n)=>s1(t,e,n,void 0),N2=(t,e,n)=>s1(t,e,"regular",n);var ev,tv,$u=class extends(tv=Error,ev=h0,tv){constructor(){super("Thread list adapter changed while an operation was pending.");w(this,ev,!0);this.name="ThreadListAdapterChangedError"}};function pf(t,e){let n=t.get(e);return n===void 0&&(n={generations:new Set,pendingClaim:null,inFlightClaims:new Set,manualTitle:void 0,latestExplicit:null,nextOrder:0},t.set(e,n)),n}function mf(t,e,n){n.generations.size===0&&n.pendingClaim===null&&n.inFlightClaims.size===0&&n.manualTitle===void 0&&t.get(e)===n&&t.delete(e)}function Xo(t,e){var n;return!e.superseded&&(((n=t.latestExplicit)==null?void 0:n.order)??0)<=e.order}function ug(t,e){var n;return(((n=t.latestExplicit)==null?void 0:n.order)??0)<e.order}function L2(t,e,n){const r=pf(t,e);let s;const i=new Promise(a=>{s=a}),o={title:n,order:++r.nextOrder,settled:i,settle:s};r.pendingClaim=o,r.inFlightClaims.add(o);for(const a of r.generations)a.order<o.order&&(a.claim=o);return o}function cg(t,e,n,r){n.settle(r);const s=t.get(e);s!==void 0&&(s.inFlightClaims.delete(n),s.pendingClaim===n&&(s.pendingClaim=null,r&&(s.manualTitle=n.title)),mf(t,e,s))}function i1(t,e,n){const r=n.manualTitle;if(r!==void 0)return n.manualTitle=void 0,mf(t,e,n),r}function j2(t,e){t.delete(e)}function $2(t,e,n){const r=pf(t,e);if(n&&r.pendingClaim===null&&i1(t,e,r)!==void 0)return null;let s;const i=new Promise(a=>{s=a}),o={automatic:n,order:++r.nextOrder,claim:n?r.pendingClaim:null,beforeGenerationClaims:n?[]:[...r.inFlightClaims],superseded:!1,persisted:i,settlePersisted:s};if(!n){r.pendingClaim=null,r.manualTitle=void 0,r.latestExplicit=o;for(const a of r.generations)a.automatic&&(a.superseded=!0)}return r.generations.add(o),o}async function z2({states:t,threadId:e,automatic:n,generate:r,rename:s,applyTitle:i}){const o=pf(t,e),a=$2(t,e,n);if(a===null)return;let l,u=a.order;const c=async p=>{const g=await p.settled;if(a.claim===p)return g||(a.claim=null,o.pendingClaim===p&&(o.pendingClaim=null)),g},d=()=>n&&i1(t,e,o)!==void 0,h=async()=>{if(l!==void 0)for(;;){const p=a.claim;if(p!==null&&p.order>u&&ug(o,p)){await c(p)===!0&&(l=p.title,u=p.order,await s(p.title));continue}const g=o.latestExplicit;if(g===null||g.order<=u)return;const _=await g.persisted;if(o.latestExplicit===g){if(u=g.order,_===void 0||_===l)return;l=_,await s(_)}}},f=async()=>{if(a.beforeGenerationClaims.length>0&&await Promise.all(a.beforeGenerationClaims.map(_=>_.settled)),a.claim!==null){const _=await c(a.claim);if(_===!0){a.superseded=!0;return}if(_===!1&&d())return}if(!Xo(o,a))return;let p=!1,g;for(await r(async _=>{p=!0,g=_,_!==void 0&&(l=_);const m=a.claim;if(m!==null){if(await c(m)!==!1)return;if(d()){a.superseded=!0;return}}Xo(o,a)&&await i(g)});;){const _=a.claim;if(_===null)return;const m=await c(_);if(m!==void 0){if(m===!1){if(d())return;p&&Xo(o,a)&&await i(g);return}if(!ug(o,_))return;if(await s(_.title),l=_.title,u=_.order,a.claim===_){if(!Xo(o,a))return;await i(_.title),a.superseded=!0;return}}}};try{await f(),await h()}finally{a.settlePersisted(l),o.generations.delete(a),mf(t,e,o)}}const fn=(t,e)=>new Error(`Thread "${t}" not found while ${e}.`),Bn=(t,e,n)=>new Error(`Thread "${t}" has status "${e}", so it cannot ${n}.`),F2=P2();var B2=class extends $n{constructor(e,n){super();w(this,"_options");w(this,"_hookManager");w(this,"_runtimeAdapters");w(this,"_loadThreadsPromise");w(this,"_loadMorePromise");w(this,"_loadGeneration",0);w(this,"_adapterGeneration",0);w(this,"_replaceListOnNextLoad",!1);w(this,"_staleThreadIdsOnReplace");w(this,"_switchGeneration",0);w(this,"_switchTask");w(this,"_titleStates",new Map);w(this,"_mainThreadId");w(this,"_state",new I2(F2));w(this,"_useAdaptersProvider",({children:e})=>{const n=this._options.adapter.unstable_useAdapters;return n===void 0?e:T.jsx(this._SynthesizedAdapters,{useAdapters:n,children:e})});w(this,"_SynthesizedAdapters",({useAdapters:e,children:n})=>{const r=rA(e());return r==null?n:T.jsx(ng,{adapters:r,children:n})});w(this,"_initialThreadLoaded",!1);w(this,"providerStore");w(this,"_lastNotifiedThreadId");w(this,"initialize",async e=>{const n=this._options.adapter,r=this._adapterGeneration;if(this._state.value.newThreadId!==e){this._requireAdapterSettled();const l=this.getItemById(e);if(!l)throw fn(e,"initializing it");if(l.status==="new")throw Bn(e,l.status,"be initialized here");const{remoteId:u,externalId:c}=await l.initializeTask;return this._requireAdapterGeneration(r),{remoteId:u,externalId:c}}this._requireAdapterGeneration(r);const s=n.initialize(e);let i;const{remoteId:o,externalId:a}=await this._state.optimisticUpdate({execute:()=>s,optimistic:l=>N2(l,e,s),then:(l,{remoteId:u,externalId:c})=>{if(r!==this._adapterGeneration)return l;const d=O2(l,e,u,c,e);return i=d.removedMappingId,i===this._mainThreadId&&(this._mainThreadId=d.survivorMappingId),d.state}});return this._requireAdapterGeneration(r),i!==void 0&&this._hookManager.stopThreadRuntime(i),{remoteId:o,externalId:a}});w(this,"generateTitle",async(e,n)=>{this._requireAdapterSettled();const r=this._options.adapter,s=this._adapterGeneration,i=this.getItemById(e);if(!i)throw fn(e,"generating its title");if(i.status==="new")throw Bn(e,i.status,"generate a title");const{remoteId:o}=await i.initializeTask;this._requireAdapterGeneration(s);const a=this._hookManager.getThreadRuntimeCore(i.id);if(!a)return;const l=a.messages.filter(r1);await z2({states:this._titleStates,threadId:i.id,automatic:(n==null?void 0:n.automatic)===!0,generate:async u=>{const c=await r.generateTitle(o,l);this._requireAdapterGeneration(s),await v2(c,u)},rename:async u=>{this._requireAdapterGeneration(s),await r.rename(o,u)},applyTitle:async u=>{await this._state.optimisticUpdate({execute:async()=>{},optimistic:c=>{if(s!==this._adapterGeneration)return c;const d=xr(c,i.id);return d?{...c,threadData:{...c.threadData,[d.id]:{...d,title:u}}}:c}})}})});w(this,"boundIdsStore",new Zi([]));w(this,"__internal_RenderComponent",()=>{const e=$w();J(()=>(this.boundIdsStore.setState([...this.boundIdsStore.getState(),e]),()=>{this.boundIdsStore.setState(this.boundIdsStore.getState().filter(i=>i!==e))}),[e]);const n=et(this.boundIdsStore),r=et(this.providerStore),s=oe();return(n.length===0||n[0]===e)&&T.jsxs(ng,{adapters:this._runtimeAdapters,children:[T.jsx(this._hookManager.__internal_RenderThreadRuntimes,{provider:r}),T.jsx(this._hookManager.__internal_Host,{parentClient:s})]})});this._state.subscribe(()=>{this._notifySubscribers(),this._notifyThreadIdChange()}),this._runtimeAdapters={modelContext:n},this._hookManager=new k2(e.runtimeHook,this),this._hookManager.__internal_setDefaultAdapters(this._runtimeAdapters),this._hookManager.__internal_subscribeRunningChanged(()=>this._notifySubscribers()),this._hookManager.__internal_subscribeRuntimeReplaced(()=>{queueMicrotask(()=>this._notifySubscribers())}),this.providerStore=new Zi(this.resolveProvider(e.adapter)),this.__internal_setOptions(e),this.switchToNewThread()}resolveProvider(e){return e.unstable_Provider!==void 0?e.unstable_Provider:e.unstable_useAdapters===void 0?zw:this._useAdaptersProvider}get threadItems(){return this._state.value.threadData}getLoadThreadsPromise(){if(!this._loadThreadsPromise){const e=this._loadGeneration;let n=!1;const r=D2(this._state.baseValue);this._loadThreadsPromise=this._state.optimisticUpdate({execute:()=>this._options.adapter.list(),loading:s=>e!==this._loadGeneration?s:{...s,isLoading:!0,loadError:void 0},then:(s,i)=>{if(e!==this._loadGeneration)return s;if(this._replaceListOnNextLoad)return this._replaceListOnNextLoad=!1,n=!0,this._replaceWithThreads({...s,loadError:void 0},i.threads,Nu(i.nextCursor));const o=Lu(i.threads,{threadIds:[],archivedThreadIds:[],threadIdMap:{...s.threadIdMap},threadData:{...s.threadData}}),a={...s,isLoading:!1,loadError:void 0,cursor:Nu(i.nextCursor),threadIds:o.threadIds,archivedThreadIds:o.archivedThreadIds,threadIdMap:o.threadIdMap,threadData:o.threadData};return M2(a,s,r)}}).catch(s=>{if(e===this._loadGeneration){if(console.error("[assistant-ui] thread list load failed:",s),this._loadThreadsPromise=void 0,!this._replaceListOnNextLoad){this._state.update({...this._state.baseValue,isLoading:!1,loadError:s});return}this._replaceListOnNextLoad=!1,n=!0,this._state.update(this._replaceWithThreads({...this._state.baseValue,loadError:s},[],void 0))}}).then(()=>{var i;if(!n)return;const s=this._options.threadId;s!==void 0&&((i=this.getItemById(s))==null?void 0:i.id)!==this._mainThreadId&&this._switchToThreadFromProp(s).catch(()=>{})})}return this._loadThreadsPromise}loadMore(){if(this._loadMorePromise)return this._loadMorePromise;const e=this._state.value;if(e.cursor===void 0||e.isLoading)return Promise.resolve();const n=this._loadGeneration,r=this._options.adapter,s=e.cursor,i=this._state.optimisticUpdate({execute:()=>r.list({after:s}),loading:o=>n!==this._loadGeneration?o:{...o,isLoadingMore:!0},then:(o,a)=>{if(n!==this._loadGeneration||r!==this._options.adapter)return o;const l=Lu(a.threads,{threadIds:[...o.threadIds],archivedThreadIds:[...o.archivedThreadIds],threadIdMap:{...o.threadIdMap},threadData:{...o.threadData}});return{...o,isLoadingMore:!1,cursor:Nu(a.nextCursor),threadIds:l.threadIds,archivedThreadIds:l.archivedThreadIds,threadIdMap:l.threadIdMap,threadData:l.threadData}}}).catch(o=>{n===this._loadGeneration&&console.error("[assistant-ui] thread list loadMore failed:",o)}).then(()=>{this._loadMorePromise===i&&(this._loadMorePromise=void 0)});return this._loadMorePromise=i,i}__internal_setOptions(e){if(this._options===e)return;const n=this._options!==void 0&&this._options.adapter!==e.adapter,r=this._initialThreadLoaded&&this._options!==void 0&&this._options.threadId!==e.threadId;this._options=e,this.providerStore.setState(this.resolveProvider(e.adapter)),this._hookManager.setRuntimeHook(e.runtimeHook),n&&(this._loadGeneration++,this._adapterGeneration++,this._switchGeneration++,this._switchTask=void 0,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._replaceListOnNextLoad=!0,this._staleThreadIdsOnReplace=new Set(Object.values(this._state.baseValue.threadData).filter(s=>s.status!=="new").map(s=>s.id)),this._state.update({...this._state.baseValue,cursor:void 0,loadError:void 0}),this._titleStates.clear()),r&&this._switchToThreadFromProp(e.threadId).catch(()=>{})}_requireAdapterGeneration(e){if(e!==this._adapterGeneration)throw new $u}_requireAdapterSettled(){if(this._replaceListOnNextLoad)throw new $u}_replaceWithThreads(e,n,r){const s=[];if(e.newThreadId){const f=Object.hasOwn(e.threadIdMap,e.newThreadId)?e.threadIdMap[e.newThreadId]:void 0,p=f&&Object.hasOwn(e.threadData,f)?e.threadData[f]:void 0;(p==null?void 0:p.status)==="new"&&s.push(p)}const i=this._staleThreadIdsOnReplace;if(i)for(const f of Object.values(e.threadData))i.has(f.id)||f.status!=="new"&&f.remoteId===void 0||s.push(f);this._staleThreadIdsOnReplace=void 0;const o={threadIds:[],archivedThreadIds:[],threadIdMap:Te(),threadData:Te()};for(const f of s){const p=f.id;Object.hasOwn(o.threadData,p)||(o.threadIdMap[f.id]=p,f.remoteId!==void 0&&(o.threadIdMap[f.remoteId]=p),o.threadData[p]=f)}const{threadIds:a,archivedThreadIds:l,threadIdMap:u,threadData:c}=Lu(n,o);for(const f of s){if(f.remoteId===void 0)continue;const p=f.id,g=Object.hasOwn(c,p)?c[p]:void 0;g!==void 0&&(g.status==="regular"&&!a.includes(g.id)?a.push(g.id):g.status==="archived"&&!l.includes(g.id)&&l.push(g.id))}let d={...e,isLoading:!1,cursor:r,threadIds:a,archivedThreadIds:l,threadIdMap:u,threadData:c,newThreadId:e.newThreadId!==void 0&&!Object.hasOwn(u,e.newThreadId)?void 0:e.newThreadId};if(xr(d,this._mainThreadId)===void 0){const f=d.newThreadId;if(f!==void 0)this._mainThreadId=f;else{const p=lg(d);this._mainThreadId=p.id,d=p.state}this._options.threadId===void 0?this._notifyThreadIdChange():this._lastNotifiedThreadId=void 0}const h=new Set(Object.values(d.threadData).map(f=>f.id));for(const f of Object.values(e.threadData))h.has(f.id)||this._hookManager.stopThreadRuntime(f.id);return this._hookManager.startThreadRuntime(this._mainThreadId).then(()=>this._notifySubscribers(),()=>{}),d}__internal_load(){if(this.getLoadThreadsPromise(),this._initialThreadLoaded)return;this._initialThreadLoaded=!0;const e=this._options.threadId??this._options.initialThreadId;e!==void 0&&(this._options.threadId!==void 0?this._switchToThreadFromProp(e):this.switchToThread(e)).catch(()=>{})}async reloadMainThread(){var r;const e=this._mainThreadId;if(e===void 0||((r=this.getItemById(e))==null?void 0:r.status)==="new")return;const n=this._hookManager.getThreadRuntimeCore(e);try{n!=null&&n.unstable_refetchThread?await n.unstable_refetchThread():await this._hookManager.__internal_restartThreadRuntime(e)}catch(s){if(e!==this._mainThreadId)return;throw s}e===this._mainThreadId&&this._notifySubscribers()}reload(){return this._loadGeneration++,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._state.update({...this._state.baseValue,cursor:void 0}),this.getLoadThreadsPromise()}get isLoading(){return this._state.value.isLoading}get loadError(){return this._state.value.loadError}get isLoadingMore(){return this._state.value.isLoadingMore}get hasMore(){return this._state.value.cursor!==void 0}get threadIds(){return this._state.value.threadIds}get archivedThreadIds(){return this._state.value.archivedThreadIds}get newThreadId(){return this._state.value.newThreadId}get mainThreadId(){return this._mainThreadId}get _mainThreadRemoteId(){var e;if(this._mainThreadId!==void 0)return(e=xr(this._state.value,this._mainThreadId))==null?void 0:e.remoteId}_notifyThreadIdChange(e=!0){const n=this._mainThreadRemoteId;this._lastNotifiedThreadId!==n&&(this._lastNotifiedThreadId=n,e&&C2("assistant-ui","onThreadIdChange",this._options.onThreadIdChange,n))}getMainThreadRuntimeCore(){const e=this._hookManager.getThreadRuntimeCore(this._mainThreadId);return e||R2}getThreadRuntimeCore(e){const n=this.getItemById(e);if(!n)throw fn(e,"getting its runtime");const r=this._hookManager.getThreadRuntimeCore(n.id);if(!r)throw new Error(`Runtime for thread "${e}" not found while getting its runtime.`);return r}unstable_isThreadRunning(e){const n=this.getItemById(e);return n?this._hookManager.__internal_isThreadRunning(n.id):!1}unstable_subscribeThreadEvents(e){return this._hookManager.__internal_subscribeThreadEvents(e)}getItemById(e){return xr(this._state.value,e)}switchToThread(e,n){return this._startSwitchToThread(e,n,!0)}_startSwitchToThread(e,n,r){const s=++this._switchGeneration,i=this._switchToThread(e,n,s,r);return this._switchTask=i,i}async _switchToThread(e,n,r,s){if(this._replaceListOnNextLoad&&e!==this._state.value.newThreadId)throw new $u;let i=this.getItemById(e);if(!i){const l=await this._options.adapter.fetch(e);if(r!==this._switchGeneration)return;const u=this._state.value,c=l.remoteId,d={...u.threadData,[c]:{id:c,initializeTask:Promise.resolve({remoteId:l.remoteId,externalId:l.externalId}),remoteId:l.remoteId,externalId:l.externalId,status:l.status,title:l.title,lastMessageAt:l.lastMessageAt,custom:l.custom}},h={...u.threadIdMap,[l.remoteId]:c},f=l.remoteId,p=l.status==="regular"?u.threadIds.includes(f):u.archivedThreadIds.includes(f),g=u.threadIds.filter(v=>v!==f),_=u.archivedThreadIds.filter(v=>v!==f),m=l.status==="regular"?p?u.threadIds:[...g,f]:g,y=l.status==="archived"?p?u.archivedThreadIds:[..._,f]:_;this._state.update({...u,threadIds:m,archivedThreadIds:y,threadIdMap:h,threadData:d}),i=this.getItemById(e)}if(!i)throw fn(e,"switching to it");if(this._mainThreadId===i.id)return;const o=this._hookManager.startThreadRuntime(i.id);if(this.mainThreadId!==void 0?await o:o.then(()=>this._notifySubscribers(),()=>{}),r!==this._switchGeneration)return;let a=this.getItemById(i.id);(a==null?void 0:a.id)===i.id&&(a.status==="archived"&&(n==null?void 0:n.unarchive)!==!1&&(await a.initializeTask,r!==this._switchGeneration||(a=this.getItemById(i.id),(a==null?void 0:a.id)!==i.id)||a.status==="archived"&&(await this.unarchive(a.id),r!==this._switchGeneration||(a=this.getItemById(i.id),(a==null?void 0:a.id)!==i.id)))||(this._mainThreadId=a.id,this._notifySubscribers(),this._notifyThreadIdChange(s)))}switchToNewThread(){return this._startSwitchToNewThread(!0)}_switchToThreadFromProp(e){return e!==void 0?this._startSwitchToThread(e,void 0,!1):this._startSwitchToNewThread(!1)}_startSwitchToNewThread(e){const n=++this._switchGeneration,r=this._switchToNewThread(n,e);return this._switchTask=r,r}async _switchToNewThread(e,n){for(;this._state.baseValue.newThreadId!==void 0&&this._state.value.newThreadId===void 0;)if(await this._state.waitForUpdate(),e!==this._switchGeneration)return;const r=this._state.baseValue;let s=this._state.value.newThreadId;if(s===void 0){const i=lg(r);s=i.id,this._state.update(i.state)}return this._switchToThread(s,void 0,e,n)}async rename(e,n){this._requireAdapterSettled();const r=this._options.adapter,s=this._adapterGeneration,i=this.getItemById(e);if(!i)throw fn(e,"renaming it");if(i.status==="new")throw Bn(e,i.status,"be renamed");const o=L2(this._titleStates,i.id,n);try{const a=await this._state.optimisticUpdate({execute:async()=>{const{remoteId:l}=await i.initializeTask;return this._requireAdapterGeneration(s),r.rename(l,n)},optimistic:l=>{const u=xr(l,e);return u?{...l,threadData:{...l.threadData,[u.id]:{...u,title:n}}}:l}});return cg(this._titleStates,i.id,o,!0),a}catch(a){throw cg(this._titleStates,i.id,o,!1),a}}async updateCustom(e,n){this._requireAdapterSettled();const r=this._options.adapter,s=this._adapterGeneration,i=this.getItemById(e);if(!i)throw fn(e,"updating its custom metadata");if(i.status==="new")throw Bn(e,i.status,"update custom metadata");if(!r.updateCustom)throw new Error("Remote thread list adapter does not support updating custom metadata");return this._state.optimisticUpdate({execute:async()=>{const{remoteId:o}=await i.initializeTask;if(this._requireAdapterGeneration(s),!r.updateCustom)throw new Error("Remote thread list adapter does not support updating custom metadata");return r.updateCustom(o,n)},optimistic:o=>{const a=xr(o,e);return a?{...o,threadData:{...o.threadData,[a.id]:{...a,custom:n}}}:o}})}async _ensureThreadIsNotMain(e){if(e===this.newThreadId)throw new Error("Cannot ensure new thread is not main");let n;for(;e===this._mainThreadId;){let r=this._switchTask;const s=!r||r===n;s&&(r=this.switchToNewThread()),n=r;try{await r}catch(i){if(s&&this._switchTask===r)throw i}}}async archive(e){this._requireAdapterSettled();const n=this._options.adapter,r=this._adapterGeneration,s=this.getItemById(e);if(!s)throw fn(e,"archiving it");if(s.status!=="regular")throw Bn(e,s.status,"be archived");return await this._ensureThreadIsNotMain(s.id),this._requireAdapterGeneration(r),this._state.optimisticUpdate({execute:async()=>{const{remoteId:i}=await s.initializeTask;return this._requireAdapterGeneration(r),n.archive(i)},optimistic:i=>ju(i,s.id,"archived")})}async unarchive(e){this._requireAdapterSettled();const n=this._options.adapter,r=this._adapterGeneration,s=this.getItemById(e);if(!s)throw fn(e,"unarchiving it");if(s.status!=="archived")throw Bn(e,s.status,"be unarchived");return this._state.optimisticUpdate({execute:async()=>{try{const{remoteId:i}=await s.initializeTask;return this._requireAdapterGeneration(r),await n.unarchive(i)}catch(i){throw r===this._adapterGeneration&&await this._ensureThreadIsNotMain(s.id),i}},optimistic:i=>ju(i,s.id,"regular")})}async delete(e){this._requireAdapterSettled();const n=this._options.adapter,r=this._adapterGeneration,s=this.getItemById(e);if(!s)throw fn(e,"deleting it");if(s.status!=="regular"&&s.status!=="archived")throw Bn(e,s.status,"be deleted");await this._ensureThreadIsNotMain(s.id),this._requireAdapterGeneration(r);const i=await this._state.optimisticUpdate({execute:async()=>{const{remoteId:o}=await s.initializeTask;return this._requireAdapterGeneration(r),await n.delete(o)},optimistic:o=>ju(o,s.id,"deleted")});return this._hookManager.stopThreadRuntime(s.id),j2(this._titleStates,s.id),i}__internal_dispose(){this._hookManager.__internal_dispose()}async detach(e){const n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw fn(e,"detaching it");if(r.status!=="regular"&&r.status!=="archived")throw Bn(e,r.status,"be detached");await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n),this._hookManager.stopThreadRuntime(r.id)}},U2=class extends df{constructor(e){super();w(this,"threads");this.threads=new B2(e,this._contextProvider)}get RenderComponent(){return this.threads.__internal_RenderComponent}};const V2=t=>{const e=O(18);let n;e[0]!==t?(n=()=>new U2(t),e[0]=t,e[1]=n):n=e[1];const[r]=ce(n);let s;e[2]!==r.threads?(s=()=>()=>queueMicrotask(()=>r.threads.__internal_dispose()),e[2]=r.threads,e[3]=s):s=e[3];let i;e[4]!==r?(i=[r],e[4]=r,e[5]=i):i=e[5],Qr(s,i);let o;e[6]!==t||e[7]!==r.threads?(o=()=>{r.threads.__internal_setOptions(t),r.threads.__internal_load()},e[6]=t,e[7]=r.threads,e[8]=o):o=e[8];let a;e[9]!==t||e[10]!==r?(a=[r,t],e[9]=t,e[10]=r,e[11]=a):a=e[11],J(o,a);let l;e[12]!==r.threads?(l=()=>{if(typeof window>"u"||typeof document>"u")return;const d=()=>{r.threads.loadError!==void 0&&r.threads.reload()},h=()=>{document.visibilityState==="visible"&&d()};return window.addEventListener("online",d),document.addEventListener("visibilitychange",h),()=>{window.removeEventListener("online",d),document.removeEventListener("visibilitychange",h)}},e[12]=r.threads,e[13]=l):l=e[13];let u;e[14]!==r?(u=[r],e[14]=r,e[15]=u):u=e[15],J(l,u);let c;return e[16]!==r?(c=new cf(r),e[16]=r,e[17]=c):c=e[17],c},H2=t=>{const[e]=ce(()=>new Zi(t.runtimeHook));rn(()=>{e.setState(t.runtimeHook)},[e,t.runtimeHook]);const n=te(t.initialThreadId),r=_t(function(){return et({subscribe:e.subscribe,getState:e.getState,getServerSnapshot:e.getState})()},[e]),s=ht(o=>{var a;return(a=t.onThreadIdChange)==null?void 0:a.call(t,o)}),i=ge(()=>({adapter:t.adapter,allowNesting:t.allowNesting,threadId:t.threadId,initialThreadId:n.current,runtimeHook:r,onThreadIdChange:s}),[t.adapter,t.allowNesting,t.threadId,r]);if(oe().threadListItem.source!==null){if(!i.allowNesting)throw new Error("useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op).");return t.runtimeHook()}return V2(i)},q2=t=>{if(t instanceof Date&&!Number.isNaN(t.getTime()))return t;if(typeof t!="string"&&typeof t!="number")return null;const e=new Date(t);return Number.isNaN(e.getTime())?null:e},G2=t=>t==="system"||t==="user"||t==="assistant",o1=(t,e)=>{const n={text:r=>typeof r.text=="string",reasoning:r=>typeof r.text=="string"||typeof r.unstable_summary=="string",image:r=>typeof r.image=="string",file:r=>typeof r.data=="string"&&typeof r.mimeType=="string",audio:r=>_e(r.audio)&&typeof r.audio.data=="string"&&typeof r.audio.format=="string",data:r=>typeof r.name=="string",source:r=>typeof r.id=="string"&&(r.sourceType==="url"?typeof r.url=="string":r.sourceType==="document"&&typeof r.title=="string"&&typeof r.mediaType=="string"),"generative-ui":r=>_e(r.spec),"tool-call":r=>typeof r.toolCallId=="string"&&typeof r.toolName=="string"&&_e(r.args)&&typeof r.argsText=="string",...t};return r=>_e(r)&&typeof r.type=="string"&&(Object.hasOwn(n,r.type)?n[r.type](r):e(r.type))};o1({},()=>!0);const W2=o1({reasoning:t=>(t.text===void 0||typeof t.text=="string")&&(t.unstable_summary===void 0||typeof t.unstable_summary=="string")&&(typeof t.text=="string"||typeof t.unstable_summary=="string"),"tool-call":t=>typeof t.toolCallId=="string"&&typeof t.toolName=="string"&&(t.args===void 0||_e(t.args))&&(t.argsText===void 0||typeof t.argsText=="string")&&(t.args!==void 0||t.argsText!==void 0)},t=>t.startsWith("data-")),zu={user:{text:!0,image:!0,file:!0,data:!0,audio:!0},assistant:{text:!0,reasoning:!0,"tool-call":!0,source:!0,file:!0,image:!0,data:!0,"generative-ui":!0}},a1=(t,e)=>W2(e)&&(t==="system"?e.type==="text":Object.hasOwn(zu.assistant,e.type)||Object.hasOwn(zu.user,e.type)?Object.hasOwn(zu[t],e.type):!0),Q2=(t,e)=>!_e(t)||typeof t.id!="string"||typeof t.type!="string"||typeof t.name!="string"||!_e(t.status)||t.status.type!=="complete"||!Array.isArray(t.content)?null:{...t,content:t.content.filter(e)},K2=t=>{const e=t.type;switch(e){case"text":return{type:"text",text:t.text,...t.parentId!==void 0?{parentId:t.parentId}:void 0};case"image":return{type:"image",image:t.image,...t.filename!=null?{filename:t.filename}:void 0};case"file":return{type:"file",data:t.data,mimeType:t.mimeType,...t.filename!=null?{filename:t.filename}:void 0,...t.sourceType!=null?{sourceType:t.sourceType}:void 0,...t.parentId!==void 0?{parentId:t.parentId}:void 0};case"audio":return{type:"audio",audio:{data:t.audio.data,format:t.audio.format}};case"data":return Br(t.data)||console.warn(`attachment data is not JSON! ${JSON.stringify(t)}`),{type:"data",name:t.name,data:t.data};default:throw new Error(`Attachment part type not supported by aui/v0: ${e}`)}},Y2=t=>{if(!(t.role!=="user"||t.attachments.length===0))return t.attachments.map(({id:e,type:n,name:r,contentType:s,status:i,content:o})=>({id:e,type:n,name:r,status:i,...s!=null?{contentType:s}:void 0,content:o.map(K2)}))};function yd(t){var r;const e=((r=t.status)==null?void 0:r.type)==="running"?{type:"incomplete",reason:"cancelled"}:t.status,n=Y2(t);return{role:t.role,content:t.content.map(s=>{const i=s.type;switch(i){case"text":return{type:"text",text:s.text,...s.parentId!==void 0?{parentId:s.parentId}:void 0};case"reasoning":return{type:"reasoning",text:s.text,...s.unstable_summary!==void 0?{unstable_summary:s.unstable_summary}:void 0,...s.providerMetadata!==void 0?{providerMetadata:s.providerMetadata}:void 0,...s.parentId!==void 0?{parentId:s.parentId}:void 0};case"source":return s.sourceType==="url"?{type:"source",sourceType:"url",id:s.id,url:s.url,...s.title!=null?{title:s.title}:void 0,...s.providerMetadata!=null?{providerMetadata:s.providerMetadata}:void 0,...s.parentId!==void 0?{parentId:s.parentId}:void 0}:{type:"source",sourceType:"document",id:s.id,title:s.title,mediaType:s.mediaType,...s.filename!=null?{filename:s.filename}:void 0,...s.providerMetadata!=null?{providerMetadata:s.providerMetadata}:void 0,...s.parentId!==void 0?{parentId:s.parentId}:void 0};case"tool-call":return s.result!==void 0&&!Br(s.result)&&console.warn(`tool-call result is not JSON! ${JSON.stringify(s)}`),{type:"tool-call",toolCallId:s.toolCallId,toolName:s.toolName,...JSON.stringify(s.args)===s.argsText?{args:s.args}:{argsText:s.argsText},...s.result!==void 0?{result:s.result}:void 0,...s.isError?{isError:!0}:void 0,...s.interrupt!==void 0?{interrupt:{type:s.interrupt.type,payload:s.interrupt.payload}}:void 0,...s.timing!==void 0?{timing:s.timing}:void 0,...s.mcp!==void 0?{mcp:s.mcp}:void 0,...s.approval?{approval:s.approval}:void 0,...s.parentId!==void 0?{parentId:s.parentId}:void 0,...s.messages!==void 0?{messages:s.messages.map(eP)}:void 0};case"image":return{type:"image",image:s.image};case"file":return{type:"file",data:s.data,mimeType:s.mimeType,...s.filename?{filename:s.filename}:void 0,...s.sourceType?{sourceType:s.sourceType}:void 0,...s.parentId!==void 0?{parentId:s.parentId}:void 0};case"data":return Br(s.data)||console.warn(`data part is not JSON! ${JSON.stringify(s)}`),{type:"data",name:s.name,data:s.data};case"audio":return{type:"audio",audio:{data:s.audio.data,format:s.audio.format}};case"generative-ui":return{type:"generative-ui",spec:s.spec,...s.id!==void 0?{id:s.id}:void 0,...s.parentId!==void 0?{parentId:s.parentId}:void 0};default:throw new Error(`Message part type not supported by aui/v0: ${i}`)}}),metadata:t.metadata,...e?{status:e}:void 0,...n?{attachments:n}:void 0}}const J2=(t,e,n)=>e.flatMap(r=>{if(!a1(t,r))return[];if(r.type!=="tool-call"||r.messages===void 0)return[r];const{messages:s,...i}=r;return!Array.isArray(s)||n>=100?[i]:[{...i,messages:s.flatMap(o=>{const a=l1(o,n+1);return a?[a]:[]})}]}),X2=t=>t.flatMap(e=>{const n=Q2(e,r=>a1("user",r));return n?[n]:[]}),l1=(t,e)=>{if(!_e(t)||!G2(t.role)||!Array.isArray(t.content))return null;const{role:n}=t,r=J2(n,t.content,e);if(n==="system"&&r.length!==1)return null;const{attachments:s,createdAt:i,status:o,metadata:a,...l}=t,u=q2(i),c=n==="assistant"||!_e(a)?a:{...a,steps:void 0};return{...l,...u?{createdAt:i}:void 0,...n==="assistant"&&o!==void 0?{status:o}:void 0,...a!==void 0?{metadata:c}:void 0,content:r,...n==="user"&&Array.isArray(s)?{attachments:X2(s)}:void 0}};function Z2(t){try{const e=l1(t.content,0);if(!e)throw new Error("stored row is not an aui/v0 message");return{parentId:t.parent_id,message:u1({...e,id:t.id,createdAt:t.created_at},t.id)}}catch(e){return console.warn(`aui/v0: dropping unreadable message ${t.id}`,e),null}}const eP=t=>({...yd(t),id:t.id,createdAt:t.createdAt.toISOString()}),u1=(t,e)=>Os({...t,content:t.content.map((n,r)=>n.type!=="tool-call"||n.messages===void 0?n:{...n,messages:n.messages.map((s,i)=>u1({...s,createdAt:s.createdAt!==void 0?new Date(s.createdAt):t.createdAt},s.id??`${e}-${n.toolCallId}-${r}-${i}`))})},e,{type:"complete",reason:"unknown"});var so=class extends Error{constructor(t){super(t),this.name="CloudResponseError"}};const Ln=(t,e)=>new so(`Invalid Assistant Cloud response for "${t}": expected ${e}`),Le=(t,e)=>{if(typeof t!="object"||t===null||Array.isArray(t))throw Ln(e,"an object");return t},To=(t,e)=>{if(!Array.isArray(t))throw Ln(e,"an array");return t},Se=(t,e)=>{if(typeof t!="string")throw Ln(e,"a string");return t},tP=(t,e)=>{if(typeof t!="number"||!Number.isFinite(t))throw Ln(e,"a number");return t},nP=(t,e)=>t===null?null:tP(t,e),c1=(t,e,n)=>{const r=Se(t,e);if(!n.includes(r))throw Ln(e,`one of ${n.map(s=>`"${s}"`).join(", ")}`);return r},io=(t,e)=>t===null?null:Se(t,e),vd=(t,e)=>{if(typeof t!="boolean")throw Ln(e,"a boolean");return t},d1=(t,e)=>{if(!Number.isInteger(t))throw Ln(e,"an integer");return t},Ei=(t,e)=>{if(typeof t!="string")throw Ln(e,"a canonical ISO timestamp");const n=new Date(t);if(Number.isNaN(n.getTime())||n.toISOString()!==t)throw Ln(e,"a canonical ISO timestamp");return n},rP=(t,e)=>Le(t,e),dg=3e4,hg=async(t,e)=>{const n=new AbortController;let r=!1;const s=setTimeout(()=>{r=!0,n.abort()},dg);try{return await e(n.signal)}catch(i){throw r?new Error(`Assistant Cloud ${t} timed out after ${dg}ms`,{cause:i}):i}finally{clearTimeout(s)}},fg=t=>{try{const e=t.split(".")[1];if(!e)throw new Error("Invalid JWT format");let n=e.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4!==0;)n+="=";const r=atob(n),s=JSON.parse(r).exp;if(!s||typeof s!="number")throw new Error('JWT does not contain a valid "exp" field');return s*1e3}catch(e){throw new Error(`Unable to determine the token expiry: ${e}`)}},_d=(t,e)=>{const n=Se(t,e);if(n.length===0)throw new so(`Invalid Assistant Cloud response for "${e}": expected a non-empty string`);return n},pg=(t,e)=>{const n=Le(t,e);return{token:_d(n.token,`${e}.token`),expires_at:_d(n.expires_at,`${e}.expires_at`)}},mg=async(t,e)=>{let n;try{n=await t.json()}catch{throw new so(`Invalid Assistant Cloud response for "${e}": expected valid JSON`)}const r=Le(n,e);return{data:r,accessToken:_d(r.access_token,`${e}.access_token`)}};var fo,nv,h1=(nv=class{constructor(t){w(this,"strategy","jwt");w(this,"cachedToken",null);w(this,"tokenExpiry",null);w(this,"tokenRequest",null);cn(this,fo);dn(this,fo,t)}async getAuthHeaders(){const t=Date.now();if(this.cachedToken&&this.tokenExpiry&&this.tokenExpiry-t>3e4)return{Authorization:`Bearer ${this.cachedToken}`};this.tokenRequest||(this.tokenRequest=this.fetchAuthHeaders());const e=this.tokenRequest;try{return await e}finally{this.tokenRequest===e&&(this.tokenRequest=null)}}async fetchAuthHeaders(){const t=await Pt(this,fo).call(this);if(!t)return!1;const e=fg(t);return this.cachedToken=t,this.tokenExpiry=e,{Authorization:`Bearer ${t}`}}readAuthHeaders(t){const e=t.get("Authorization");if(!e)return;const[n,r]=e.split(" ");if(n!=="Bearer"||!r)throw new Error("Invalid auth header received");const s=fg(r);this.cachedToken=r,this.tokenExpiry=s}},fo=new WeakMap,nv),po,mo,go,rv,sP=(rv=class{constructor(t,e,n){w(this,"strategy","api-key");cn(this,po);cn(this,mo);cn(this,go);dn(this,po,t),dn(this,mo,e),dn(this,go,n)}async getAuthHeaders(){return{Authorization:`Bearer ${Pt(this,po)}`,"Aui-User-Id":Pt(this,mo),"Aui-Workspace-Id":Pt(this,go)}}readAuthHeaders(){}},po=new WeakMap,mo=new WeakMap,go=new WeakMap,rv);const gf="aui:refresh_token",yf=t=>`${gf}:${t}`,Fu=t=>{try{t.removeItem(gf)}catch{}},Ul=()=>{if(!("localStorage"in globalThis))return null;try{return globalThis.localStorage}catch{return null}},iP=t=>{const e=Ul();if(e)try{const n=yf(t),r=e.getItem(n);if(r)return Fu(e),JSON.parse(r);const s=e.getItem(gf);if(!s)return;let i;try{i=JSON.parse(s)}catch{Fu(e);return}return e.setItem(n,s),Fu(e),i}catch{return}},Bu=t=>!t||!t.endsWith("/")?t:t.slice(0,-1),gg=(t,e)=>{const n=Ul();if(n)try{n.setItem(yf(t),JSON.stringify(e))}catch{}},oP=t=>{const e=Ul();if(e)try{e.removeItem(yf(t))}catch{}},yg=new WeakMap,aP=()=>{var t;return"navigator"in globalThis?((t=globalThis.navigator)==null?void 0:t.locks)??null:null},lP=t=>`assistant-cloud:anonymous-auth:${t}`,uP=(t,e)=>{const n=Ul();if(!n)return e();let r=yg.get(n);r||(r=new Map,yg.set(n,r));const s=r.get(t);if(s)return s;const i=aP(),o=(i?i.request(lP(t),e):e()).finally(()=>{r.get(t)===o&&r.delete(t)});return r.set(t,o),o};var cP=class{constructor(t){w(this,"strategy","anon");w(this,"baseUrl");w(this,"jwtStrategy");this.baseUrl=t;const e=async()=>{const n=Date.now(),r=iP(this.baseUrl);if(r)if(new Date(r.expires_at).getTime()-n>3e4){const s=await hg("refresh token request",async i=>{const o=await fetch(`${this.baseUrl}/v1/auth/tokens/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:r.token}),signal:i});if(o.ok){const{data:a,accessToken:l}=await mg(o,"refresh auth token response");return a.refresh_token!=null&&gg(this.baseUrl,pg(a.refresh_token,"refresh auth token response.refresh_token")),l}if(o.status===429||o.status>=500)throw new Error(`Assistant Cloud token refresh failed with status ${o.status}`);return null});if(s!==null)return s}else oP(this.baseUrl);return hg("anonymous token request",async s=>{const i=await fetch(`${this.baseUrl}/v1/auth/tokens/anonymous`,{method:"POST",signal:s});if(!i.ok)return null;const{data:o,accessToken:a}=await mg(i,"anonymous auth token response");return gg(this.baseUrl,pg(o.refresh_token,"anonymous auth token response.refresh_token")),a})};this.jwtStrategy=new h1(()=>uP(this.baseUrl,e))}async getAuthHeaders(){return this.jwtStrategy.getAuthHeaders()}readAuthHeaders(t){this.jwtStrategy.readAuthHeaders(t)}};const dP="0.2.2";var f1=class extends Error{constructor(e,n,r,s){super(e);w(this,"status");w(this,"code");w(this,"details");this.status=n,r!==void 0&&(this.code=r),s!==void 0&&(this.details=s),this.name="CloudAPIError"}};const vg=/^[\x21-\x7e]+$/;var hP=class{constructor(t){w(this,"_auth");w(this,"_baseUrl");w(this,"registerSdk");w(this,"sdkHeader");const e=new Map;if(this.registerSdk=n=>{const r=n.name.trim(),s=n.version.trim();!vg.test(r)||!vg.test(s)||e.set(`${r}/${s}`,{name:r,version:s})},this.sdkHeader=()=>[`assistant-cloud/${dP}`,...Array.from(e.values(),({name:n,version:r})=>`${n}/${r}`)].join(" "),"authToken"in t)this._baseUrl=Bu(t.baseUrl),this._auth=new h1(t.authToken);else if("apiKey"in t)this._baseUrl=Bu(t.baseUrl??"https://backend.assistant-api.com"),this._auth=new sP(t.apiKey,t.userId,t.workspaceId);else if("anonymous"in t)this._baseUrl=Bu(t.baseUrl),this._auth=new cP(this._baseUrl);else throw new Error("Invalid configuration: Must provide authToken, apiKey, or anonymous configuration")}async initializeAuth(){return!!await this._auth.getAuthHeaders()}async makeRawRequest(t,e={}){const n=await this._auth.getAuthHeaders();if(!n)throw new Error("Authorization failed");const r={...n,...e.headers,"Content-Type":"application/json","Aui-Sdk":this.sdkHeader()},s=new URLSearchParams;if(e.query)for(const[a,l]of Object.entries(e.query))l!==!1&&(l===!0?s.set(a,"true"):s.set(a,l.toString()));const i=new URL(`${this._baseUrl}/v1${t}`);i.search=s.toString();const o=await fetch(i,{method:e.method??"GET",headers:r,body:e.body?JSON.stringify(e.body):null,...e.keepalive?{keepalive:!0}:{}});if(this._auth.readAuthHeaders(o.headers),!o.ok){const a=await o.text();let l,u,c;try{const d=JSON.parse(a);if(typeof d=="object"&&d!==null&&!Array.isArray(d)){const h=d;typeof h.message=="string"&&h.message.length>0&&(l=h.message),typeof h.error=="string"&&(u=h.error,c={...h},delete c.error)}}catch{}throw new f1(l??`Request failed with status ${o.status}, ${a}`,o.status,u,c)}return o}async makeRequest(t,e={}){const n=await this.makeRawRequest(t,e);if(n.status===204||n.headers.get("content-length")==="0")return;const r=await n.text();if(r.trim()!=="")return JSON.parse(r)}};const fP=20,pP=50,mP=2e3;var gP=class{constructor(t,e){w(this,"buffer",[]);w(this,"timer");w(this,"flushing");w(this,"cloud");w(this,"isEnabled");w(this,"listening",!1);w(this,"onVisibilityChange",()=>{document.visibilityState==="hidden"&&this.flush()});w(this,"flush",async()=>{if(!this.isEnabled()){this.buffer=[],this.clearFlushTimer(),this.unlisten();return}if(this.flushing)return this.flushing;this.clearFlushTimer();const t=this.flushPending();return this.flushing=t,t.then(()=>{this.flushing===t&&(this.flushing=void 0,this.buffer.length===0?(this.clearFlushTimer(),this.unlisten()):this.flush())}),t});this.cloud=t,this.isEnabled=e}track(t){if(this.isEnabled()){if(this.listen(),this.buffer.push(yP(t)),this.buffer.length>=fP){this.flush();return}this.scheduleFlush()}}listen(){this.listening||typeof window>"u"||typeof document>"u"||(this.listening=!0,window.addEventListener("pagehide",this.flush),document.addEventListener("visibilitychange",this.onVisibilityChange))}unlisten(){this.listening&&(this.listening=!1,window.removeEventListener("pagehide",this.flush),document.removeEventListener("visibilitychange",this.onVisibilityChange))}dispose(){this.unlisten(),this.clearFlushTimer(),this.flush()}async flushPending(){for(;this.buffer.length>0;){if(!this.isEnabled()){this.buffer=[];return}const t=this.buffer.splice(0,pP);try{await this.cloud.makeRequest("/events",{method:"POST",body:{events:t},keepalive:!0})}catch{}}}scheduleFlush(){this.timer===void 0&&(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},mP))}clearFlushTimer(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0)}};const yP=t=>{const e=_P(t.props);return{kind:t.kind,...Uu(t.thread_id)?{thread_id:t.thread_id}:{},...Uu(t.message_id)?{message_id:t.message_id}:{},...Uu(t.run_id)?{run_id:t.run_id}:{},...vP(t.value)?{value:t.value}:{},...e?{props:e}:{}}},Uu=t=>t&&t.length<=48?t:void 0,vP=t=>t!==void 0&&Number.isInteger(t)&&t>=0,_P=t=>{if(!t)return;const e=Object.entries(t);if(e.some(([,r])=>typeof r=="string"&&r.length>256||typeof r=="number"&&!Number.isFinite(r)||typeof r!="string"&&typeof r!="number"&&typeof r!="boolean"))return;const n=Object.fromEntries(e);return new TextEncoder().encode(JSON.stringify(n)).byteLength<=1024?n:void 0},wP=["numeric","categorical","boolean"];var xP=class{constructor(t){w(this,"cloud");this.cloud=t}async create(t){const e=Le(await this.cloud.makeRequest("/scores",{method:"POST",body:t}),"score response");return{score_id:Se(e.score_id,"score response.score_id"),name:Se(e.name,"score response.name"),data_type:c1(e.data_type,"score response.data_type",wP),value:nP(e.value,"score response.value"),string_value:io(e.string_value,"score response.string_value")}}},SP=class{constructor(t){w(this,"cloud");this.cloud=t}async create(){const t=Le(await this.cloud.makeRequest("/auth/tokens",{method:"POST"}),"auth token response");return{token:Se(t.token,"token")}}};const bP=["positive","negative"],p1=(t,e)=>{const n=Le(t,e);return{id:Se(n.id,`${e}.id`),parent_id:io(n.parent_id,`${e}.parent_id`),height:d1(n.height,`${e}.height`),created_at:Ei(n.created_at,`${e}.created_at`),updated_at:Ei(n.updated_at,`${e}.updated_at`),format:Se(n.format,`${e}.format`),content:rP(n.content,`${e}.content`)}};var TP=class{constructor(t){w(this,"cloud");this.cloud=t}async list(t,e){const n=Le(await this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}/messages`,{query:e}),"thread message list response");return{messages:To(n.messages,"messages").map((r,s)=>p1(r,`messages[${s}]`))}}async create(t,e){const n=Le(await this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}/messages`,{method:"POST",body:e}),"thread message create response");return{message_id:Se(n.message_id,"message_id")}}async update(t,e,n){return this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}/messages/${encodeURIComponent(e)}`,{method:"PUT",body:n})}async feedback(t,e,n){var i;const r=(i=n.comment)==null?void 0:i.trim(),s=Le(await this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}/messages/${encodeURIComponent(e)}/feedback`,{method:"POST",body:{type:n.type,...r?{comment:r}:void 0}}),"thread message feedback response");return{feedback_id:Se(s.feedback_id,"feedback_id"),type:c1(s.type,"type",bP),..."comment"in s?{comment:io(s.comment,"comment")}:void 0}}};const wd=(t,e)=>{const n=Le(t,e);return{title:io(n.title,`${e}.title`)??"",last_message_at:Ei(n.last_message_at,`${e}.last_message_at`),metadata:n.metadata,external_id:io(n.external_id,`${e}.external_id`),id:Se(n.id,`${e}.id`),project_id:Se(n.project_id,`${e}.project_id`),created_at:Ei(n.created_at,`${e}.created_at`),updated_at:Ei(n.updated_at,`${e}.updated_at`),workspace_id:Se(n.workspace_id,`${e}.workspace_id`),is_archived:vd(n.is_archived,`${e}.is_archived`)}};var kP=class{constructor(t){w(this,"messages");w(this,"cloud");this.cloud=t,this.messages=new TP(t)}async list(t){const e=(t==null?void 0:t.is_archived)===void 0?t:{...t,is_archived:String(t.is_archived)},n=Le(await this.cloud.makeRequest("/threads",{query:e}),"thread list response");return{threads:To(n.threads,"threads").map((r,s)=>wd(r,`threads[${s}]`))}}async get(t){const e=Le(await this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}`),"thread response");return wd(e.thread,"thread")}async create(t){const e=Le(await this.cloud.makeRequest("/threads",{method:"POST",body:t}),"thread create response");return{thread_id:Se(e.thread_id,"thread_id")}}async update(t,e){return this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}`,{method:"PUT",body:e})}async claim(t){const e=Le(await this.cloud.makeRequest("/threads/claim",{method:"POST",body:t}),"thread claim response");return{moved:d1(e.moved,"moved")}}async delete(t){return this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}`,{method:"DELETE"})}},CP=class{constructor(t){w(this,"cloud");this.cloud=t}async list(t,e){const n=Le(await this.cloud.makeRequest(`/projects/threads/${encodeURIComponent(t)}/messages`,{query:e}),"project thread message list response");return{messages:To(n.messages,"messages").map((r,s)=>p1(r,`messages[${s}]`))}}},IP=class{constructor(t){w(this,"messages");w(this,"cloud");this.cloud=t,this.messages=new CP(t)}async list(t){const e=Le(await this.cloud.makeRequest("/projects/threads",{query:{...t,...(t==null?void 0:t.is_archived)!==void 0?{is_archived:String(t.is_archived)}:{}}}),"project thread list response");return{threads:To(e.threads,"threads").map((n,r)=>wd(n,`threads[${r}]`))}}},EP=class{constructor(t){w(this,"threads");this.threads=new IP(t)}},RP=class{constructor(t){w(this,"cloud");this.cloud=t}__internal_getAssistantOptions(t){return{api:`${this.cloud._baseUrl}/v1/runs/stream`,headers:async()=>{const e=await this.cloud._auth.getAuthHeaders();if(!e)throw new Error("Authorization failed");return{...e,Accept:"text/plain","Aui-Sdk":this.cloud.sdkHeader()}},body:{assistant_id:t,response_format:"vercel-ai-data-stream/v1",thread_id:"unstable_todo"}}}async stream(t){var r;const e=await this.cloud.makeRawRequest("/runs/stream",{method:"POST",headers:{Accept:"text/plain"},body:t});if(!e.body)throw new so('Invalid Assistant Cloud response for "run stream": expected a response body');const n=e.headers.get("content-type");if(((r=n==null?void 0:n.split(";",1)[0])==null?void 0:r.trim().toLowerCase())!=="text/plain")throw await e.body.cancel().catch(()=>{}),new so(`Invalid Assistant Cloud response for "run stream": expected a "text/plain" content type, received ${n?`"${n}"`:"no Content-Type header"}`);return fd.fromResponse(e,new IR)}async report(t){const e=Le(await this.cloud.makeRequest("/runs",{method:"POST",body:t}),"run report response");return{run_id:Se(e.run_id,"run_id")}}},AP=class{constructor(t){w(this,"cloud");this.cloud=t}async pdfToImages(t){const e=Le(await this.cloud.makeRequest("/files/pdf-to-images",{method:"POST",body:t}),"PDF conversion response");return{success:vd(e.success,"PDF conversion response.success"),urls:To(e.urls,"PDF conversion response.urls").map((n,r)=>Se(n,`PDF conversion response.urls[${r}]`)),message:Se(e.message,"PDF conversion response.message")}}async generatePresignedUploadUrl(t){const e=Le(await this.cloud.makeRequest("/files/attachments/generate-presigned-upload-url",{method:"POST",body:t}),"presigned upload response");return{success:vd(e.success,"presigned upload response.success"),signedUrl:Se(e.signedUrl,"presigned upload response.signedUrl"),expiresAt:Se(e.expiresAt,"presigned upload response.expiresAt"),publicUrl:Se(e.publicUrl,"presigned upload response.publicUrl"),..."key"in e?{key:Se(e.key,"presigned upload response.key")}:{}}}async generatePresignedDownloadUrl(t){const e=Le(await this.cloud.makeRequest("/files/attachments/generate-presigned-download-url",{method:"POST",body:t}),"presigned download response");return{signedUrl:Se(e.signedUrl,"presigned download response.signedUrl"),expiresAt:Se(e.expiresAt,"presigned download response.expiresAt"),key:Se(e.key,"presigned download response.key")}}},PP=class{constructor(t){w(this,"threads");w(this,"projects");w(this,"auth");w(this,"runs");w(this,"files");w(this,"events");w(this,"scores");w(this,"telemetry");w(this,"registerSdk");const e=new hP(t);this.registerSdk=e.registerSdk;const n=t.telemetry;this.telemetry=n===!1?{enabled:!1}:n===!0||n===void 0?{enabled:!0}:{...n,enabled:n.enabled!==!1},this.threads=new kP(e),this.projects=new EP(e),this.auth={tokens:new SP(e)},this.runs=new RP(e),this.files=new AP(e),this.events=new gP(e,()=>this.telemetry.enabled!==!1&&this.telemetry.events!==!1),this.scores=new xP(e)}};const m1=256;function MP(t,e,n){t.delete(e),t.set(e,n),t.size>m1&&t.delete(t.keys().next().value)}function _g(t,e){t.delete(e),t.add(e),t.size>m1&&t.delete(t.values().next().value)}const DP=(t,e)=>({thread_id:t,...e!==void 0?{message_id:e}:void 0});var OP=class{constructor(t,e=DP){w(this,"runStartedAt",new Map);w(this,"runEndedAt",new Map);w(this,"shownErrors",new Set);w(this,"shownSuggestions",new Set);w(this,"getCloud");w(this,"resolveIds");this.getCloud=typeof t=="function"?t:()=>t,this.resolveIds=e}runStarted(t){this.runStartedAt.set(t,Date.now()),this.shownErrors.delete(t)}runEnded(t){this.runStartedAt.delete(t),MP(this.runEndedAt,t,Date.now())}runStopped(t){const e=this.runStartedAt.get(t);e!==void 0&&(this.runStartedAt.delete(t),this.track("run_stopped",t,void 0,{value:Math.max(0,Date.now()-e)}))}messageSent(t,e){const n=this.runEndedAt.get(t);this.track("message_sent",t,e.messageId,{props:{chars:e.chars,attachments:e.attachments},...n!==void 0?{value:Math.max(0,Date.now()-n)}:void 0},{awaitThread:!0})}messageEdited(t,e){this.track("message_edited",t,e.messageId,{props:{chars:e.chars}})}messageRegenerated(t,e){this.track("message_regenerated",t,e)}errorShown(t,e){this.shownErrors.has(t)||(_g(this.shownErrors,t),this.track("error_shown",t,e.messageId,{props:{reason:e.reason}}))}suggestionsShown(t,e){this.shownSuggestions.has(t)||(_g(this.shownSuggestions,t),this.track("suggestions_shown",t,void 0,{value:e}))}suggestionClicked(t){this.track("suggestion_clicked",t)}attachmentAdded(t,e){this.track("attachment_added",t,e.messageId,{...e.contentType?{props:{type:e.contentType}}:void 0})}attachmentFailed(t,e){this.track("attachment_failed",t,e.messageId,{...e.contentType?{props:{type:e.contentType}}:void 0})}voiceStarted(t){this.track("voice_started",t)}speechStarted(t,e){this.track("speech_started",t,e)}branchSwitched(t,e){this.track("branch_switched",t,e)}messageCopied(t,e){this.track("message_copied",t,e)}toolApproved(t,e,n,r){this.track("tool_approved",t,e,{props:{toolCallId:n,toolName:r}})}toolRejected(t,e,n,r){this.track("tool_rejected",t,e,{props:{toolCallId:n,toolName:r}})}threadSwitched(t){this.track("thread_switched",t)}track(t,e,n,r={},s={awaitThread:!1}){Promise.resolve().then(()=>this.resolveIds(e,n,s)).then(i=>{t==="thread_switched"&&!i.thread_id||this.getCloud().events.track({kind:t,...r,...i})}).catch(()=>{})}};const wg=200;var NP=class{constructor(t){w(this,"idMapping",new Map);w(this,"getCloud");this.getCloud=typeof t=="function"?t:()=>t}async append(t,e,n,r,s){const i=this.getCloud(),o=this.idMapping.get(e);if(o instanceof Promise){await o;return}const a=(async()=>{const l=n?this.idMapping.get(n):void 0,u=n?await l??n:null,{message_id:c}=await i.threads.messages.create(t,{parent_id:u,format:r,content:s});return c})();this.idMapping.set(e,a);try{const l=await a;this.idMapping.get(e)===a&&this.idMapping.set(e,l)}catch(l){throw this.idMapping.get(e)===a&&this.idMapping.delete(e),l}}async update(t,e,n,r){const s=this.getCloud(),i=await this.getRemoteId(e);if(!i){console.warn(`Skipping update for message ${e}: no remote id is mapped.`);return}await s.threads.messages.update(t,i,{content:r})}isPersisted(t){return this.idMapping.has(t)}async getRemoteId(t){const e=this.idMapping.get(t);if(e)return e}getResolvedRemoteId(t){const e=this.idMapping.get(t);return typeof e=="string"?e:void 0}async load(t,e){const n=this.idMapping,r=this.getCloud(),s=[],i=new Set;let o;for(;;){const a=await r.threads.messages.list(t,{...e?{format:e}:void 0,limit:wg,...o?{after:o}:void 0}),l=a.messages.at(-1);if(!l)break;const u=a.messages.filter(c=>!i.has(c.id));if(u.length===0)break;for(const c of u)i.add(c.id);if(s.push(...u),a.messages.length<wg)break;o=l.id}if(this.idMapping===n)for(const a of s){const l=n.get(a.id);l===void 0?n.set(a.id,a.id):l instanceof Promise&&l.catch(()=>{const u=n.get(a.id);(u===void 0||u===l)&&n.set(a.id,a.id)})}return s}reset(){this.idMapping=new Map}};const xg=5e4,LP=/^[A-Za-z0-9+/]{100,}={0,2}$/;function jP(t,e="completed"){if(t.isError)return{status:"error"};if(t.isAbort)return{status:"incomplete",outcome:"aborted"};if(t.isDisconnect)return{status:"incomplete",outcome:"disconnected"};switch(t.finishReason){case"length":return{status:"incomplete",outcome:"length"};case"content-filter":case"content_filter":return{status:"incomplete",outcome:"content_filter"};case"cancelled":return{status:"incomplete",outcome:"aborted"};case"error":return{status:"error"};default:return{status:t.finishReason===void 0?e:"completed"}}}const $P=64,zP=2048;function FP(t){if(t==null)return{};const e=typeof t=="object"?t:void 0,n=typeof t=="string"?t:typeof(e==null?void 0:e.message)=="string"?e.message:void 0,r=typeof(e==null?void 0:e.code)=="string"?e.code:typeof(e==null?void 0:e.name)=="string"&&e.name!=="Error"?e.name:void 0;return{...n?{error:n.slice(0,zP)}:void 0,...r?{errorCode:r.slice(0,$P)}:void 0}}function Hs(t){return t.length<=xg?t:t.slice(0,xg)}function xd(t){if(t!=null)try{return Hs(JSON.stringify(t))}catch{return}}function BP(t){if(t!=null){try{const e=typeof t=="string"?JSON.parse(t):t;if(Array.isArray(e)){const n=e.map(r=>{if(r&&typeof r=="object"&&r.type&&(r.type==="image"||r.type==="audio")&&typeof r.data=="string"&&LP.test(r.data.slice(0,200))){const s=(r.data.length*3/4/1024).toFixed(1);return{...r,data:`[${r.type}: ${s}KB]`}}return r});return Hs(JSON.stringify(n))}}catch{}return xd(t)}}function g1(t){const{toolName:e,toolCallId:n,args:r,argsText:s,result:i,toolSource:o}=t,a={tool_name:e,tool_call_id:n},l=s!=null?Hs(s):xd(r);l!==void 0&&(a.tool_args=l);const u=o==="mcp"?BP(i):xd(i);return u!==void 0&&(a.tool_result=u),o&&(a.tool_source=o),a}function y1(t){if(!t)return;if(typeof t.modelId=="string")return t.modelId;const e=t.custom;if(typeof(e==null?void 0:e.modelId)=="string")return e.modelId;const n=t.steps;if(Array.isArray(n))for(const r of n){if(!r||typeof r!="object")continue;const s=r.response;if(!s||typeof s!="object")continue;const i=s.modelId;if(typeof i=="string")return i}}function UP(t,e){if(!e)return;const n=oo(e);n&&(n.inputTokens!==void 0&&(t.input_tokens=n.inputTokens),n.outputTokens!==void 0&&(t.output_tokens=n.outputTokens),n.reasoningTokens!==void 0&&(t.reasoning_tokens=n.reasoningTokens),n.cachedInputTokens!==void 0&&(t.cached_input_tokens=n.cachedInputTokens))}function VP(t){const e={},n=t.usage?oo(t.usage):void 0;return(n==null?void 0:n.inputTokens)!==void 0&&(e.input_tokens=n.inputTokens),(n==null?void 0:n.outputTokens)!==void 0&&(e.output_tokens=n.outputTokens),(n==null?void 0:n.reasoningTokens)!==void 0&&(e.reasoning_tokens=n.reasoningTokens),(n==null?void 0:n.cachedInputTokens)!==void 0&&(e.cached_input_tokens=n.cachedInputTokens),t.toolCalls!==void 0&&(e.tool_calls=t.toolCalls),t.startMs!==void 0&&(e.start_ms=t.startMs),t.endMs!==void 0&&(e.end_ms=t.endMs),t.finishReason!==void 0&&(e.finish_reason=t.finishReason.slice(0,32)),e}function HP(t){if(!t)return;const e=[],n=new Set;for(const r of t){const s=r.trim().slice(0,64).trim();if(!(!s||n.has(s))&&(n.add(s),e.push(s),e.length===20))break}return e.length>0?e:void 0}function Sg(t){if(!(t===void 0||!Number.isFinite(t)))return Math.max(0,Math.round(t))}function qP(t){var o,a,l,u;const e={thread_id:t.threadId,status:t.status},n=(o=t.traceId)==null?void 0:o.toLowerCase();n&&/^[0-9a-f]{32}$/.test(n)&&(e.trace_id=n),t.outcome!==void 0&&(e.outcome_type=t.outcome),t.errorCode!==void 0&&(e.error_code=t.errorCode),t.error!==void 0&&(e.error=t.error),t.messageId!==void 0&&(e.message_id=t.messageId),t.modelId!==void 0&&(e.model_id=t.modelId),t.provider!==void 0&&(e.provider=t.provider,e.provider_type=t.provider),UP(e,t.usage),t.steps!==void 0?(e.steps=t.steps.map(VP),e.total_steps=t.steps.length):t.totalSteps!==void 0&&(e.total_steps=t.totalSteps),t.toolCalls!==void 0&&(e.tool_calls=t.toolCalls);const r=Sg(t.durationMs);r!==void 0&&(e.duration_ms=r);const s=Sg(t.firstTokenMs);s!==void 0&&(e.first_token_ms=s),t.outputText!==void 0&&(e.output_text=Hs(t.outputText)),t.metadata!==void 0&&(e.metadata=t.metadata),((a=t.telemetry)==null?void 0:a.environment)!==void 0&&(e.environment=t.telemetry.environment),((l=t.telemetry)==null?void 0:l.release)!==void 0&&(e.release=t.telemetry.release);const i=HP((u=t.telemetry)==null?void 0:u.tags);return i!==void 0&&(e.tags=i),e}function oo(t){var i,o;const e=t.inputTokens??t.promptTokens,n=t.outputTokens??t.completionTokens,r=t.reasoningTokens??((i=t.outputTokenDetails)==null?void 0:i.reasoningTokens),s=t.cachedInputTokens??((o=t.inputTokenDetails)==null?void 0:o.cacheReadTokens);if(!(e==null&&n==null&&r==null&&s==null))return{...e!=null?{inputTokens:e}:void 0,...n!=null?{outputTokens:n}:void 0,...r!=null?{reasoningTokens:r}:void 0,...s!=null?{cachedInputTokens:s}:void 0}}var GP=class{constructor(t){w(this,"reported",new Set);w(this,"getCloud");this.getCloud=typeof t=="function"?t:()=>t}async report(t,e){let n;try{const r=this.getCloud();if(!r.telemetry.enabled||e!==void 0&&this.reported.has(e))return;const s=qP({...t,telemetry:r.telemetry}),{beforeReport:i}=r.telemetry,o=i?i(s):s;if(!o)return;e!==void 0&&(this.reported.add(e),n=e),await r.runs.report(o)}catch(r){n!==void 0&&WP(r)&&this.reported.delete(n);return}}};const WP=t=>t instanceof f1&&t.status===429,QP=(t,e)=>({append:async(n,r)=>{const s=e.getId(r.message),i=e.encode(r);return t.append(n,s,r.parentId,e.format,i)},update:t.update?async(n,r,s)=>{const i=e.encode(r);return t.update(n,s,e.format,i)}:void 0,load:async n=>({messages:(await t.load(n,e.format)).filter(r=>r.format===e.format).map(r=>e.decode({id:r.id,parent_id:r.parent_id,format:r.format,content:r.content})).reverse()}),isPersisted:n=>t.isPersisted(n)});function Vr(t){return t!==null&&typeof t=="object"}function KP(t){return Vr(t)&&typeof t.type=="string"}function YP(t){if(typeof t.toolCallId!="string")return;const e=t.type.startsWith("tool-");if(!e&&t.type!=="dynamic-tool")return;const n=e?t.type.slice(5):typeof t.toolName=="string"?t.toolName:void 0;if(n)return g1({toolName:n,toolCallId:t.toolCallId,args:t.input??t.args,result:t.output??t.result,toolSource:e?"frontend":"mcp"})}function JP(t,e){const n=Vr(e==null?void 0:e.samplingCalls)?e.samplingCalls:void 0;if(n)for(const r of t){const s=n[r.tool_call_id];Array.isArray(s)&&s.length>0&&(r.sampling_calls=s)}}function v1(t){const e=t==null?void 0:t.steps;return Array.isArray(e)?e.map(n=>Vr(n)&&Vr(n.usage)?n.usage:void 0):[]}function _1(t){const e={};for(const n of t)n.inputTokens!=null&&(e.inputTokens=(e.inputTokens??0)+n.inputTokens),n.outputTokens!=null&&(e.outputTokens=(e.outputTokens??0)+n.outputTokens),n.reasoningTokens!=null&&(e.reasoningTokens=(e.reasoningTokens??0)+n.reasoningTokens),n.cachedInputTokens!=null&&(e.cachedInputTokens=(e.cachedInputTokens??0)+n.cachedInputTokens);return e}function XP(t){const e=Vr(t==null?void 0:t.usage)?oo(t.usage):void 0;if(e)return e;const n=v1(t).flatMap(r=>{const s=r?oo(r):void 0;return s?[s]:[]});return n.length>0?_1(n):void 0}function w1(t){const e=[],n=[],r=[],s=[];let i;for(const c of t){if(c.role!=="assistant")continue;i=c;const d=Vr(c.metadata)?c.metadata:void 0,h=v1(d),f=[];let p,g=-1;for(const m of c.parts){if(!KP(m))continue;if(m.type==="step-start"){g+=1;const v=h[g];p=v?{usage:v}:{},r.push(p);continue}if(m.type==="text"&&typeof m.text=="string"&&m.text){e.push(m.text);continue}const y=YP(m);y&&(n.push(y),f.push(y),p&&(p.toolCalls=[...p.toolCalls??[],y],p.finishReason="tool-calls"))}JP(f,d);const _=XP(d);_&&s.push(_)}if(!i)return null;const o=Vr(i.metadata)?i.metadata:void 0,a=s.length>0?_1(s):void 0,l=y1(o),u=e.length>0||n.length>0;return{...i.id!==void 0?{assistantMessageId:i.id}:void 0,status:u?"completed":"incomplete",...n.length>0?{toolCalls:n}:void 0,...r.length>0?{steps:r,totalSteps:r.length}:void 0,...e.length>0?{outputText:Hs(e.join(""))}:void 0,...a?{usage:a}:void 0,...l?{modelId:l}:void 0,...o?{metadata:o}:void 0}}const Vu=new WeakMap;var ZP=class{constructor(t,e){w(this,"cloudRef");w(this,"getAui");w(this,"runReporter");w(this,"engagementReporter");w(this,"feedback",{submit:({message:t,type:e,comment:n})=>{(async()=>{const r=this.tryGetKeyedThreadListItem(),s=r==null?void 0:r.getState().remoteId;if(!r||!s){console.warn(`[assistant-ui] Skipping feedback for message ${t.id}: the thread has no remote id.`);return}const i=await this.getPersistence(r).getRemoteId(t.id);if(!i){console.warn(`[assistant-ui] Skipping feedback for message ${t.id}: no cloud message id is mapped.`);return}await this.cloudRef.current.threads.messages.feedback(s,i,{type:e,...n?{comment:n}:void 0})})().catch(r=>{console.error("[assistant-ui] Cloud feedback submission failed:",r)})}});this.cloudRef=t,this.getAui=e,this.runReporter=new GP(()=>this.cloudRef.current),this.engagementReporter=new OP(()=>this.cloudRef.current,(n,r,s)=>this.resolveEngagementEventIds(n,r,s))}get aui(){return this.getAui()}getPersistence(t=this.aui.threadListItem){const e=$l(t);return Vu.has(e)||Vu.set(e,new NP(()=>this.cloudRef.current)),Vu.get(e)}get _persistence(){return this.getPersistence()}async resolveEngagementEventIds(t,e,n){const r=this.getThreadListItem(t);if(!r)return{};let s=r.getState().remoteId;!s&&(n!=null&&n.awaitThread)&&(s=await r.initialize().then(o=>o.remoteId).catch(()=>{}));const i=e?this.getPersistence(r).getResolvedRemoteId(e):void 0;return{...s?{thread_id:s}:void 0,...i?{message_id:i}:void 0}}tryGetKeyedThreadListItem(){const t=this.aui.threadListItem;if(!t.source)return;const e=t.getState().id;if(e!==void 0)return this.aui.threads.getState().threadItems.some(n=>n.id===e||n.remoteId===e)?this.aui.threads.item({id:e}):t}getThreadListItem(t){const e=this.aui.threadListItem,n=e.getState();if(n.id===t||n.remoteId===t)return e;const r=this.aui.threads.getState().threadItems.find(s=>s.id===t||s.remoteId===t);return r?this.aui.threads.item({id:r.id}):void 0}withFormat(t){const e=this;let n;const r=()=>{const o=e.tryGetKeyedThreadListItem();return o&&(n=o),n},s=()=>n??r(),i=o=>QP(e.getPersistence(o),t);return{pin(){r()},async append(o){const a=s();if(!a)throw new Error("Cannot persist cloud history without a thread list item.");const l=a.getState().remoteId??(await a.initialize()).remoteId;await i(a).append(l,o)},async update(o,a){var c,d;const l=s(),u=l==null?void 0:l.getState().remoteId;!u||!l||await((d=(c=i(l)).update)==null?void 0:d.call(c,u,o,a))},async delete(){throw new Error("Assistant Cloud does not support deleting thread messages yet.")},reportTelemetry(o,a){const l=o.map(u=>t.encode(u));e._reportRunTelemetry(t.format,l,a,s(),nM(tM(o,t),a!=null&&a.message?Sa(a.message,"aui/v0"):void 0))},async load(){const o=r(),a=e.aui.threadListItem,l=a.source?a.getState().remoteId:void 0;return l?i(o??a).load(l):{messages:[]}}}}async append({parentId:t,message:e}){const{remoteId:n}=await this.aui.threadListItem.initialize(),r=yd(e);await this._persistence.append(n,e.id,t,"aui/v0",r),this.cloudRef.current.telemetry.enabled&&this._maybeReportRun(n,"aui/v0",r,Sa(e,"aui/v0"))}async update(t){if(!this._persistence.isPersisted(t.message.id))return this.append(t);const{message:e}=t,n=this.aui.threadListItem.getState().remoteId;if(!n)return;const r=yd(e);await this._persistence.update(n,e.id,"aui/v0",r),this.cloudRef.current.telemetry.enabled&&this._maybeReportRun(n,"aui/v0",r,Sa(e,"aui/v0"))}async delete(){throw new Error("Assistant Cloud does not support deleting thread messages yet.")}async load(){const t=this.aui.threadListItem.getState().remoteId;if(!t)return{messages:[]};const e=(await this._persistence.load(t,"aui/v0")).filter(s=>s.format==="aui/v0").reverse(),n=[],r=new Set;for(const s of e){const i=Z2(s);i&&(i.parentId&&!r.has(i.parentId)||(r.add(i.message.id),n.push(i)))}return{messages:n}}_reportRunTelemetry(t,e,n,r,s){const i=r??this.aui.threadListItem,o=i.getState().remoteId;if(!o)return;const a=rM(t,e)??((s==null?void 0:s.status)!==void 0?{status:"incomplete"}:void 0);a&&this._sendReport(o,a,n==null?void 0:n.durationMs,n==null?void 0:n.stepTimestamps,s,this.getPersistence(i))}_maybeReportRun(t,e,n,r){const s=x1(e,n);s&&this._sendReport(t,s,void 0,void 0,r)}_sendReport(t,e,n,r,s,i=this._persistence){const o=eM(e.steps,r),a=s!=null&&s.localMessageId?i.getResolvedRemoteId(s.localMessageId):void 0;this.runReporter.report({threadId:t,status:(s==null?void 0:s.status)??e.status,outcome:s==null?void 0:s.outcomeType,error:s==null?void 0:s.error,errorCode:s==null?void 0:s.errorCode,messageId:a,traceId:s==null?void 0:s.traceId,modelId:e.modelId,provider:s==null?void 0:s.provider,usage:e.usage,steps:o,totalSteps:e.totalSteps,toolCalls:e.toolCalls,durationMs:n,firstTokenMs:s==null?void 0:s.firstTokenMs,outputText:e.outputText,metadata:e.metadata})}};function eM(t,e){if(!e)return t;if(!t)return e.map(({start_ms:r,end_ms:s})=>({startMs:r,endMs:s}));const n=Math.min(t.length,e.length);return t.map((r,s)=>({...r,...s<n?{startMs:e[s].start_ms,endMs:e[s].end_ms}:void 0}))}function tM(t,e){for(let n=t.length-1;n>=0;n--){const r=t[n],s=Sa(r.message,e.format,e.getId(r.message));if(s)return s}}function nM(t,e){if(!e)return t;const{localMessageId:n,...r}=e;return{...t,...r}}function Sa(t,e,n){var m;if(!oi(t)||t.role!=="assistant")return;const r=oi(t.status)?t.status:void 0,s=oi(t.metadata)?t.metadata:void 0,i=oi(s==null?void 0:s.custom)?s.custom:void 0,o=(m=oi(s==null?void 0:s.timing)?s.timing:void 0)==null?void 0:m.firstTokenTime,a=typeof o=="number"&&Number.isFinite(o)?Math.round(o):void 0,l=(r==null?void 0:r.type)==="incomplete"?typeof r.reason=="string"?r.reason:void 0:typeof(s==null?void 0:s.finishReason)=="string"?s.finishReason:void 0,u=(r==null?void 0:r.type)==="incomplete"&&r.reason==="error",c=jP({finishReason:l,isError:u}),d=c.outcome,h=c.status==="error"?"error":(r==null?void 0:r.type)==="incomplete"?"incomplete":l!==void 0?c.status:void 0,f=u?FP(r.error):{},p=n??(typeof t.id=="string"?t.id:void 0),g=e==="aui/v0"?i==null?void 0:i.traceId:e==="ai-sdk/v6"?s==null?void 0:s.traceId:void 0,_=typeof(i==null?void 0:i.provider)=="string"?i.provider:typeof(s==null?void 0:s.provider)=="string"?s.provider:void 0;return{...p?{localMessageId:p}:void 0,...h!==void 0?{status:h}:void 0,...d?{outcomeType:d}:void 0,...f,...a!=null&&a>=0?{firstTokenMs:a}:void 0,...typeof g=="string"?{traceId:g}:void 0,..._!==void 0?{provider:_}:void 0}}function oi(t){return t!==null&&typeof t=="object"}function x1(t,e){switch(t){case"aui/v0":return sM(e);case"ai-sdk/v6":return w1([e]);default:return null}}function rM(t,e){if(t==="ai-sdk/v6")return w1(e);for(let n=e.length-1;n>=0;n--){const r=x1(t,e[n]);if(r)return r}return null}function sM(t){var p,g,_,m,y,v;const e=t;if(e.role!=="assistant"||((p=e.status)==null?void 0:p.type)==="requires-action")return null;const n=(g=e.content)==null?void 0:g.filter(S=>S.type==="tool-call"&&S.toolName&&S.toolCallId).map(S=>g1({toolName:S.toolName,toolCallId:S.toolCallId,args:S.args,result:S.result,argsText:S.argsText})),r=(_=e.content)==null?void 0:_.filter(S=>S.type==="text"&&S.text),s=r&&r.length>0?Hs(r.map(S=>S.text).join("")):void 0,i=(m=e.metadata)==null?void 0:m.steps;let o,a,l,u;if(i&&i.length>0){let S=0,I=0,b=0,P=0,A=!1,D=!1,x=!1,k=!1;for(const R of i){if(!R.usage)continue;const M=oo(R.usage);M&&(M.inputTokens!=null&&(S+=M.inputTokens,A=!0),M.outputTokens!=null&&(I+=M.outputTokens,D=!0),M.reasoningTokens!=null&&(b+=M.reasoningTokens,x=!0),M.cachedInputTokens!=null&&(P+=M.cachedInputTokens,k=!0))}o=A?S:void 0,a=D?I:void 0,l=x?b:void 0,u=k?P:void 0}const c=((y=e.status)==null?void 0:y.type)==="incomplete"?"incomplete":"completed",d=(v=e.metadata)==null?void 0:v.custom,h=y1(e.metadata),f=i&&i.length>0?i.map(S=>S.usage?{usage:S.usage}:{}):void 0;return{status:c,...n&&n.length>0?{toolCalls:n}:void 0,...i!=null&&i.length?{totalSteps:i.length}:void 0,...o!=null||a!=null||l!=null||u!=null?{usage:{...o!=null?{inputTokens:o}:void 0,...a!=null?{outputTokens:a}:void 0,...l!=null?{reasoningTokens:l}:void 0,...u!=null?{cachedInputTokens:u}:void 0}}:void 0,...s!=null?{outputText:s}:void 0,...d?{metadata:d}:void 0,...f?{steps:f}:void 0,...h?{modelId:h}:void 0}}function iM(t){const e=oe(),n=te(e);J(()=>{n.current=e});const[r]=ce(()=>new ZP(t,()=>n.current));return aM(r,e),r}const Hu=new WeakMap,oM=(t,e)=>{const n=O(6);let r;n[0]!==t.engagementReporter||n[1]!==e?(r=()=>{let i=Hu.get(e);if(!i){const a={count:0,engagementReporter:t.engagementReporter,dispose:lM};a.dispose=e.on({scope:"*",event:"threads.selectionChanged"},l=>{a.engagementReporter.threadSwitched(l.threadId)}),Hu.set(e,a),i=a}const o=i;return o.engagementReporter=t.engagementReporter,o.count=o.count+1,()=>{o.count=o.count-1,o.count===0&&(o.dispose(),Hu.delete(e))}},n[0]=t.engagementReporter,n[1]=e,n[2]=r):r=n[2];let s;n[3]!==t||n[4]!==e?(s=[t,e],n[3]=t,n[4]=e,n[5]=s):s=n[5],J(r,s)},aM=(t,e)=>{const n=O(12);oM(t,e);let r;n[0]!==t.engagementReporter||n[1]!==e?(r=()=>{const a=t.engagementReporter,l=[e.on({scope:"thread",event:"composer.send"},u=>{u.messageId?a.messageEdited(u.threadId,{messageId:u.messageId,chars:u.chars}):a.messageSent(u.threadId,{chars:u.chars,attachments:u.attachments}),u.suggestion&&a.suggestionClicked(u.threadId)}),e.on({scope:"thread",event:"composer.attachmentAdd"},u=>{a.attachmentAdded(u.threadId,{messageId:u.messageId,contentType:u.contentType})}),e.on({scope:"thread",event:"composer.attachmentAddError"},u=>{a.attachmentFailed(u.threadId,{messageId:u.messageId,contentType:u.contentType})}),e.on({scope:"thread",event:"composer.cancel"},u=>{a.runStopped(u.threadId)}),e.on({scope:"thread",event:"thread.runStart"},u=>{a.runStarted(u.threadId)}),e.on({scope:"thread",event:"thread.runEnd"},u=>{a.runEnded(u.threadId)}),e.on({scope:"thread",event:"thread.cancelRun"},u=>{a.runStopped(u.threadId)}),e.on({scope:"thread",event:"thread.voiceStarted"},u=>{a.voiceStarted(u.threadId)}),e.on({scope:"thread",event:"message.reload"},u=>{a.messageRegenerated(u.threadId,u.messageId)}),e.on({scope:"thread",event:"message.branchSwitched"},u=>{a.branchSwitched(u.threadId,u.messageId)}),e.on({scope:"thread",event:"message.copied"},u=>{a.messageCopied(u.threadId,u.messageId)}),e.on({scope:"thread",event:"thread.toolApprovalAnswered"},u=>{u.approved?a.toolApproved(u.threadId,u.messageId,u.toolCallId,u.toolName):a.toolRejected(u.threadId,u.messageId,u.toolCallId,u.toolName)}),e.on({scope:"thread",event:"message.speak"},u=>{a.speechStarted(u.threadId,u.messageId)}),e.on({scope:"thread",event:"message.error"},u=>{a.errorShown(u.threadId,{messageId:u.messageId,reason:u.reason})})];return()=>{for(const u of l)u()}},n[0]=t.engagementReporter,n[1]=e,n[2]=r):r=n[2];let s;n[3]!==t||n[4]!==e?(s=[t,e],n[3]=t,n[4]=e,n[5]=s):s=n[5],J(r,s);let i;n[6]!==t.engagementReporter||n[7]!==e?(i=()=>{const a=()=>{const{mainThreadId:l}=e.threads.getState();if(e.threadListItem.getState().id!==l)return;const{isEmpty:u,suggestions:c}=e.thread.getState();!u||c.length===0||t.engagementReporter.suggestionsShown(l,c.length)};return a(),e.subscribe(a)},n[6]=t.engagementReporter,n[7]=e,n[8]=i):i=n[8];let o;n[9]!==t||n[10]!==e?(o=[t,e],n[9]=t,n[10]=e,n[11]=o):o=n[11],J(i,o)};function lM(){}const uM=t=>t.startsWith("image/")?"image":t.startsWith("text/")?"document":"file";var cM=class{constructor(t){w(this,"accept","*");w(this,"getCloud");w(this,"uploadedUrls",new Map);w(this,"activeUploads",new Map);this.getCloud=typeof t=="function"?t:()=>t}async*add({file:t}){const e=Ct();let n={id:e,type:uM(t.type),name:t.name,contentType:t.type,file:t,status:{type:"running",reason:"uploading",progress:0}};const r=new AbortController,s={cancelled:!1,controller:r};this.activeUploads.set(e,s);try{if(yield n,s.cancelled)return;const{signedUrl:i,publicUrl:o}=await this.getCloud().files.generatePresignedUploadUrl({filename:t.name});if(s.cancelled)return;const a=await fetch(i,{method:"PUT",body:t,headers:{"Content-Type":t.type},mode:"cors",signal:r.signal});if(s.cancelled)return;if(!a.ok)throw new Error(`Failed to upload file: ${a.status} ${a.statusText}`);this.uploadedUrls.set(e,o),n={...n,status:{type:"requires-action",reason:"composer-send"}},yield n}catch(i){if(s.cancelled)return;console.error("[assistant-ui] Failed to upload attachment:",i),n={...n,status:{type:"incomplete",reason:"error",message:i instanceof Error?i.message:String(i)}},yield n}finally{this.activeUploads.get(e)===s&&this.activeUploads.delete(e)}}async remove(t){const e=this.activeUploads.get(t.id);e&&(e.cancelled=!0,e.controller.abort(),this.activeUploads.delete(t.id)),this.uploadedUrls.delete(t.id)}async send(t){const e=this.uploadedUrls.get(t.id);if(!e)throw new Error("Attachment not uploaded");this.uploadedUrls.delete(t.id);let n;return t.type==="image"?n=[{type:"image",image:e,filename:t.name}]:n=[{type:"file",data:e,mimeType:t.contentType??"",filename:t.name}],{...t,status:{type:"complete"},content:n}}},dM=class{list(){return Promise.resolve({threads:[]})}rename(){return Promise.resolve()}updateCustom(){return Promise.resolve()}archive(){return Promise.resolve()}unarchive(){return Promise.resolve()}delete(){return Promise.resolve()}initialize(t){return Promise.resolve({remoteId:t,externalId:void 0})}generateTitle(){return Promise.resolve(new ReadableStream({start(t){t.close()}}))}fetch(t){return Promise.reject(new Error(`Thread "${t}" not found in in-memory thread list.`))}};const hM={name:"@assistant-ui/core",version:"0.3.20"},bg=t=>_e(t)?t:void 0;var sv;const Tg=typeof process<"u"&&((sv=process==null?void 0:process.env)==null?void 0:sv.NEXT_PUBLIC_ASSISTANT_BASE_URL),ol=Tg?new PP({baseUrl:Tg,anonymous:!0}):void 0,S1=t=>{const e=iM(t),[n]=ce(()=>new cM(()=>t.current));return ge(()=>({history:e,attachments:n,feedback:e.feedback}),[e,n])},Zo=20,fM=t=>{const e={activeCursor:t,archivedCursor:void 0,activeExhausted:!1,archivedExhausted:!1};if(!t||!t.startsWith("{"))return e;try{const n=JSON.parse(t);return _e(n)?{activeCursor:typeof n.a=="string"?n.a:void 0,archivedCursor:typeof n.r=="string"?n.r:void 0,activeExhausted:n.ae===!0,archivedExhausted:n.re===!0}:e}catch{return e}},pM=t=>{var i,o;const e=typeof t=="function"?t:()=>t,n=function(){return S1({get current(){return e().cloud??ol}})},r=e().cloud??ol;if(!r){const a=new dM;return a.initialize=async l=>{var u,c,d;return{remoteId:l,externalId:(d=await((c=(u=e()).create)==null?void 0:c.call(u)))==null?void 0:d.externalId}},a}(i=r.registerSdk)==null||i.call(r,hM);const s=e().sdk;return s&&((o=r.registerSdk)==null||o.call(r,s)),{list:async({after:a}={})=>{var _,m;const{activeCursor:l,archivedCursor:u,activeExhausted:c,archivedExhausted:d}=fM(a),[{threads:h},{threads:f}]=await Promise.all([c?Promise.resolve({threads:[]}):r.threads.list({limit:Zo,...l?{after:l}:{}}),d?Promise.resolve({threads:[]}):r.threads.list({is_archived:!0,limit:Zo,...u?{after:u}:{}})]),p=!c&&h.length===Zo?(_=h.at(-1))==null?void 0:_.id:void 0,g=!d&&f.length===Zo?(m=f.at(-1))==null?void 0:m.id:void 0;return{threads:[...h,...f].map(y=>({status:y.is_archived?"archived":"regular",remoteId:y.id,title:y.title,lastMessageAt:y.last_message_at?new Date(y.last_message_at):void 0,externalId:y.external_id??void 0,custom:bg(y.metadata)})),nextCursor:p||g?JSON.stringify({a:p,r:g,...p===void 0?{ae:!0}:{},...g===void 0?{re:!0}:{}}):void 0}},initialize:async()=>{var c,d;const a=await(((d=(c=e()).create)==null?void 0:d.call(c))??Promise.resolve()),l=a?a.externalId:void 0,{thread_id:u}=await r.threads.create({last_message_at:new Date,external_id:l});return{externalId:l,remoteId:u}},rename:async(a,l)=>r.threads.update(a,{title:l}),updateCustom:async(a,l)=>r.threads.update(a,{metadata:l??null}),archive:async a=>r.threads.update(a,{is_archived:!0}),unarchive:async a=>r.threads.update(a,{is_archived:!1}),delete:async a=>{var l,u;return await((u=(l=e()).delete)==null?void 0:u.call(l,a)),r.threads.delete(a)},generateTitle:async(a,l)=>{const u=l.map(c=>({...c,content:c.content.filter(d=>d.type==="text"||d.type==="tool-call")}));return r.runs.stream({thread_id:a,assistant_id:"system/thread_title",messages:u})},fetch:async a=>{const l=await r.threads.get(a);return{status:l.is_archived?"archived":"regular",remoteId:l.id,title:l.title,lastMessageAt:l.last_message_at?new Date(l.last_message_at):void 0,externalId:l.external_id??void 0,custom:bg(l.metadata)}},unstable_useAdapters:n}},mM=t=>{const e=te(t);Qr(()=>{e.current=t},[t]);const n=t.cloud??ol,r=ge(()=>pM(()=>({...e.current,cloud:n})),[n]),s=ge(()=>({get current(){return e.current.cloud??ol}}),[]),i=_t(function(){return S1(s)},[s]);return ge(()=>r.unstable_useAdapters===void 0?r:{...r,unstable_useAdapters:i},[r,i])},gM=t=>{const e=O(6),{id:n,children:r}=t,s=oe();let i;e[0]!==n?(i=Ut({message:xt({source:"thread",query:{type:"id",id:n},get:l=>l.thread.message({id:n})}),composer:xt({source:"message",query:{},get:l=>l.thread.message({id:n}).composer()})}),e[0]=n,e[1]=i):i=e[1];const o=i;let a;return e[2]!==s||e[3]!==r||e[4]!==o?(a=T.jsx(an,{extends:s,config:o,children:r}),e[2]=s,e[3]=r,e[4]=o,e[5]=a):a=e[5],a},vf=(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,kg=()=>null,Cg=new WeakMap,yM=(t,e)=>{let n=Cg.get(t);return n||(n=new Set(t.map(r=>r.id)),Cg.set(t,n)),n.has(e)},vM=(t,e,n)=>{switch(e){case"user":return n?t.UserEditComposer??t.EditComposer??t.UserMessage??t.Message:t.UserMessage??t.Message;case"assistant":return n?t.AssistantEditComposer??t.EditComposer??t.AssistantMessage??t.Message:t.AssistantMessage??t.Message;case"system":return n?t.SystemEditComposer??t.EditComposer??t.SystemMessage??t.Message??kg:t.SystemMessage??t.Message??kg;default:throw new Error(`Unknown message role: ${e}`)}},_f=t=>{const e=O(6),{components:n}=t,r=G(wM),s=G(xM);let i;e[0]!==n||e[1]!==s||e[2]!==r?(i=vM(n,r,s),e[0]=n,e[1]=s,e[2]=r,e[3]=i):i=e[3];const o=i;let a;return e[4]!==o?(a=T.jsx(o,{}),e[4]=o,e[5]=a):a=e[5],a},b1=Ue(t=>{const e=O(5),{index:n,components:r}=t;let s;e[0]!==r?(s=T.jsx(_f,{components:r}),e[0]=r,e[1]=s):s=e[1];let i;return e[2]!==n||e[3]!==s?(i=T.jsx(V0,{index:n,children:s}),e[2]=n,e[3]=s,e[4]=i):i=e[4],i},(t,e)=>t.index===e.index&&vf(t.components,e.components));b1.displayName="ThreadPrimitive.MessageByIndex";const T1=Ue(t=>{const e=O(7),{messageId:n,components:r}=t;let s;if(e[0]!==n?(s=a=>yM(a.thread.messages,n),e[0]=n,e[1]=s):s=e[1],!G(s))return null;let i;e[2]!==r?(i=T.jsx(_f,{components:r}),e[2]=r,e[3]=i):i=e[3];let o;return e[4]!==n||e[5]!==i?(o=T.jsx(gM,{id:n,children:i}),e[4]=n,e[5]=i,e[6]=o):o=e[6],o},(t,e)=>t.messageId===e.messageId&&vf(t.components,e.components));T1.displayName="ThreadPrimitive.Unstable_MessageById";const Ig=({children:t})=>{const e=G(Fr(n=>n.thread.messages.map(r=>r.id)));return ge(()=>e.length===0?null:e.map((n,r)=>T.jsx(V0,{index:r,children:T.jsx(Us,{getItemState:s=>s.thread.message({index:r}).getState(),children:s=>t({get message(){return s()}})})},n)),[e,t])},k1=t=>{const e=O(4),{components:n,children:r}=t;if(n){let i;return e[0]!==n?(i=T.jsx(Ig,{children:()=>T.jsx(_f,{components:n})}),e[0]=n,e[1]=i):i=e[1],i}let s;return e[2]!==r?(s=T.jsx(Ig,{children:r}),e[2]=r,e[3]=s):s=e[3],s};k1.displayName="ThreadPrimitive.Messages";const _M=Ue(k1,(t,e)=>t.children||e.children?t.children===e.children:vf(t.components,e.components));function wM(t){return t.message.role}function xM(t){return t.message.composer.isEditing}const C1=t=>{var n;const e=t.message.metadata;if(!(!e||typeof e!="object"))return(n=e.custom)==null?void 0:n.quote};var SM=class extends Error{constructor(e,n=`Component "${e}" is not in the generative-ui allowlist.`){super(n);w(this,"componentName");this.name="GenerativeUIRenderError",this.componentName=e}};const bM=t=>typeof t=="object"&&t!==null,I1=t=>t==null?[]:Array.isArray(t)?t:[t],E1=(t,e,n,r)=>{if(t==null)return null;if(typeof t=="string")return t;if(!bM(t)||!("component"in t)||typeof t.component!="string")return null;const{component:s,props:i,children:o,key:a}=t,l=e[s];if(!l){if(n)return T.jsx(n,{component:s,props:i},a??r);throw new SM(s)}return xC(l,{...i??{},key:a??r},...I1(o).map((u,c)=>E1(u,e,n,`${r}/${c}`)))},wf=t=>{const e=O(11),{spec:n,components:r,Fallback:s}=t,i=n==null?void 0:n.root;let o;e[0]!==i?(o=I1(i),e[0]=i,e[1]=o):o=e[1];const a=o;let l;if(e[2]!==s||e[3]!==r||e[4]!==a){let c;e[6]!==s||e[7]!==r?(c=(d,h)=>E1(d,r,s,`${h}`),e[6]=s,e[7]=r,e[8]=c):c=e[8],l=a.map(c),e[2]=s,e[3]=r,e[4]=a,e[5]=l}else l=e[5];let u;return e[9]!==l?(u=T.jsx(T.Fragment,{children:l}),e[9]=l,e[10]=u):u=e[10],u};wf.displayName="GenerativeUIRender";const R1=t=>{const e=O(4),{components:n,spec:r,Fallback:s}=t,i=G(TM),o=r??i;if(!o)return null;let a;return e[0]!==s||e[1]!==n||e[2]!==o?(a=T.jsx(wf,{spec:o,components:n,Fallback:s}),e[0]=s,e[1]=n,e[2]=o,e[3]=a):a=e[3],a};R1.displayName="MessagePrimitive.GenerativeUI";function TM(t){const e=t.part;return(e==null?void 0:e.type)==="generative-ui"?e.spec:void 0}const qu=t=>{let e=-1;return{startGroup:n=>{e===-1&&(e=n)},endGroup:(n,r)=>{e!==-1&&(r.push({type:t,startIndex:e,endIndex:n}),e=-1)},finalize:(n,r)=>{e!==-1&&r.push({type:t,startIndex:e,endIndex:n})}}},kM=(t,e,n)=>{const r=[];if(e){const s=qu("chainOfThoughtGroup");for(let i=0;i<t.length;i++){const o=t[i];o==="tool-call"||o==="reasoning"?s.startGroup(i):(s.endGroup(i-1,r),r.push({type:"single",index:i}))}s.finalize(t.length-1,r)}else{const s=qu("toolGroup"),i=qu("reasoningGroup");for(let o=0;o<t.length;o++){const a=t[o];a==="tool-call"?(i.endGroup(o-1,r),s.startGroup(o)):a==="reasoning"?(s.endGroup(o-1,r),i.startGroup(o)):(s.endGroup(o-1,r),i.endGroup(o-1,r),r.push({type:"single",index:o}))}s.finalize(t.length-1,r),i.finalize(t.length-1,r)}if(n){const s=new Set;for(const i of r){if(i.type==="single")continue;const o=n[i.startIndex];o!==void 0&&!s.has(o)&&(s.add(o),i.idKey=`id:${o}`)}}return r},CM=t=>{const e=O(10),n=G(Fr(HM)),r=G(Fr(GM));let s;e:{if(n.length===0){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=[],e[0]=a):a=e[0];let l;e[1]!==r?(l={ranges:a,partIds:r},e[1]=r,e[2]=l):l=e[2],s=l;break e}let i;e[3]!==n||e[4]!==r||e[5]!==t?(i=kM(n,t,r),e[3]=n,e[4]=r,e[5]=t,e[6]=i):i=e[6];let o;e[7]!==r||e[8]!==i?(o={ranges:i,partIds:r},e[7]=r,e[8]=i,e[9]=o):o=e[9],s=o}return s},IM=t=>{const e=O(9);let n,r;e[0]!==t?({Fallback:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let s;e[3]!==n||e[4]!==r.toolName?(s=a=>{var l,u;return((u=(l=a.tools.toolUIs[r.toolName])==null?void 0:l[0])==null?void 0:u.render)??n},e[3]=n,e[4]=r.toolName,e[5]=s):s=e[5];const i=G(s);if(!i)return null;let o;return e[6]!==i||e[7]!==r?(o=T.jsx(i,{...r}),e[6]=i,e[7]=r,e[8]=o):o=e[8],o},xf=(t,e,n)=>{var s;const r=(s=t.renderers[e])==null?void 0:s[0];return r||(t.fallbacks[0]??n)},EM=t=>{const e=O(9);let n,r;e[0]!==t?({Fallback:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let s;e[3]!==n||e[4]!==r.name?(s=a=>xf(a.dataRenderers,r.name,n),e[3]=n,e[4]=r.name,e[5]=s):s=e[5];const i=G(s);if(!i)return null;let o;return e[6]!==i||e[7]!==r?(o=T.jsx(i,{...r}),e[6]=i,e[7]=r,e[8]=o):o=e[8],o},gn={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:t})=>t,ReasoningGroup:({children:t})=>t},RM=t=>{var A,D,x;const e=O(41),{components:n}=t;let r;e[0]!==n?(r=n===void 0?{}:n,e[0]=n,e[1]=r):r=e[1];const{Text:s,Reasoning:i,Image:o,Source:a,File:l,Unstable_Audio:u,tools:c,data:d,generativeUI:h}=r,f=s===void 0?gn.Text:s,p=i===void 0?gn.Reasoning:i,g=o===void 0?gn.Image:o,_=a===void 0?gn.Source:a,m=l===void 0?gn.File:l,y=u===void 0?gn.Unstable_Audio:u;let v;e[2]!==c?(v=c===void 0?{}:c,e[2]=c,e[3]=v):v=e[3];const S=v,I=oe(),b=G(WM),P=b.type;if(P==="tool-call"){const k=I.part.addToolResult,R=I.part.resumeToolCall,M=I.part.respondToToolApproval;if("Override"in S){let W;return e[4]!==k||e[5]!==b||e[6]!==M||e[7]!==R||e[8]!==S.Override?(W=T.jsx(S.Override,{...b,addResult:k,resume:R,respondToApproval:M}),e[4]=k,e[5]=b,e[6]=M,e[7]=R,e[8]=S.Override,e[9]=W):W=e[9],W}const L=((A=S.by_name)==null?void 0:A[b.toolName])??S.Fallback;let z;return e[10]!==L||e[11]!==k||e[12]!==b||e[13]!==M||e[14]!==R?(z=T.jsx(IM,{...b,Fallback:L,addResult:k,resume:R,respondToApproval:M}),e[10]=L,e[11]=k,e[12]=b,e[13]=M,e[14]=R,e[15]=z):z=e[15],z}if(((D=b.status)==null?void 0:D.type)==="requires-action")throw new Error("Encountered unexpected requires-action status");switch(P){case"text":{let k;return e[16]!==f||e[17]!==b?(k=T.jsx(f,{...b}),e[16]=f,e[17]=b,e[18]=k):k=e[18],k}case"reasoning":{let k;return e[19]!==p||e[20]!==b?(k=T.jsx(p,{...b}),e[19]=p,e[20]=b,e[21]=k):k=e[21],k}case"source":{let k;return e[22]!==_||e[23]!==b?(k=T.jsx(_,{...b}),e[22]=_,e[23]=b,e[24]=k):k=e[24],k}case"image":{let k;return e[25]!==g||e[26]!==b?(k=T.jsx(g,{...b}),e[25]=g,e[26]=b,e[27]=k):k=e[27],k}case"file":{let k;return e[28]!==m||e[29]!==b?(k=T.jsx(m,{...b}),e[28]=m,e[29]=b,e[30]=k):k=e[30],k}case"audio":{let k;return e[31]!==y||e[32]!==b?(k=T.jsx(y,{...b}),e[31]=y,e[32]=b,e[33]=k):k=e[33],k}case"data":{const k=((x=d==null?void 0:d.by_name)==null?void 0:x[b.name])??(d==null?void 0:d.Fallback);let R;return e[34]!==k||e[35]!==b?(R=T.jsx(EM,{...b,Fallback:k}),e[34]=k,e[35]=b,e[36]=R):R=e[36],R}case"generative-ui":{if(!(h!=null&&h.components))return null;const k=b;let R;return e[37]!==h.Fallback||e[38]!==h.components||e[39]!==k.spec?(R=T.jsx(wf,{spec:k.spec,components:h.components,Fallback:h.Fallback}),e[37]=h.Fallback,e[38]=h.components,e[39]=k.spec,e[40]=R):R=e[40],R}default:return console.warn(`Unknown message part type: ${P}`),null}},Ri=Ue(t=>{const e=O(5),{index:n,components:r}=t;let s;e[0]!==r?(s=T.jsx(RM,{components:r}),e[0]=r,e[1]=s):s=e[1];let i;return e[2]!==n||e[3]!==s?(i=T.jsx(lf,{index:n,children:s}),e[2]=n,e[3]=s,e[4]=i):i=e[4],i},(t,e)=>{var n,r,s,i,o,a,l,u,c,d,h,f,p,g,_,m,y,v,S,I,b,P;return t.index===e.index&&((n=t.components)==null?void 0:n.Text)===((r=e.components)==null?void 0:r.Text)&&((s=t.components)==null?void 0:s.Reasoning)===((i=e.components)==null?void 0:i.Reasoning)&&((o=t.components)==null?void 0:o.Source)===((a=e.components)==null?void 0:a.Source)&&((l=t.components)==null?void 0:l.Image)===((u=e.components)==null?void 0:u.Image)&&((c=t.components)==null?void 0:c.File)===((d=e.components)==null?void 0:d.File)&&((h=t.components)==null?void 0:h.Unstable_Audio)===((f=e.components)==null?void 0:f.Unstable_Audio)&&((p=t.components)==null?void 0:p.tools)===((g=e.components)==null?void 0:g.tools)&&((_=t.components)==null?void 0:_.data)===((m=e.components)==null?void 0:m.data)&&((y=t.components)==null?void 0:y.generativeUI)===((v=e.components)==null?void 0:v.generativeUI)&&((S=t.components)==null?void 0:S.ToolGroup)===((I=e.components)==null?void 0:I.ToolGroup)&&((b=t.components)==null?void 0:b.ReasoningGroup)===((P=e.components)==null?void 0:P.ReasoningGroup)});Ri.displayName="MessagePrimitive.PartByIndex";const AM=t=>{const e=O(6),{status:n,component:r}=t,s=n.type==="running";let i;e[0]!==r||e[1]!==n?(i=T.jsx(r,{type:"text",text:"",status:n}),e[0]=r,e[1]=n,e[2]=i):i=e[2];let o;return e[3]!==s||e[4]!==i?(o=T.jsx(uf,{text:"",isRunning:s,children:i}),e[3]=s,e[4]=i,e[5]=o):o=e[5],o},PM=Object.freeze({type:"complete"}),MM=Object.freeze({type:"running"}),DM=t=>{const e=O(6),{components:n}=t,r=G(QM);if(n!=null&&n.Empty){let o;return e[0]!==n.Empty||e[1]!==r?(o=T.jsx(n.Empty,{status:r}),e[0]=n.Empty,e[1]=r,e[2]=o):o=e[2],o}if(r.type!=="running")return null;const s=(n==null?void 0:n.Text)??gn.Text;let i;return e[3]!==r||e[4]!==s?(i=T.jsx(AM,{status:r,component:s}),e[3]=r,e[4]=s,e[5]=i):i=e[5],i},A1=Ue(DM,(t,e)=>{var n,r,s,i;return((n=t.components)==null?void 0:n.Empty)===((r=e.components)==null?void 0:r.Empty)&&((s=t.components)==null?void 0:s.Text)===((i=e.components)==null?void 0:i.Text)}),OM=t=>{const e=O(4),{components:n,enabled:r}=t;let s;if(e[0]!==r?(s=o=>{if(!r||o.message.parts.length===0)return!1;const a=o.message.parts[o.message.parts.length-1];return(a==null?void 0:a.type)!=="text"&&(a==null?void 0:a.type)!=="reasoning"},e[0]=r,e[1]=s):s=e[1],!G(s))return null;let i;return e[2]!==n?(i=T.jsx(A1,{components:n}),e[2]=n,e[3]=i):i=e[3],i},NM=Ue(OM,(t,e)=>{var n,r,s,i;return t.enabled===e.enabled&&((n=t.components)==null?void 0:n.Empty)===((r=e.components)==null?void 0:r.Empty)&&((s=t.components)==null?void 0:s.Text)===((i=e.components)==null?void 0:i.Text)}),LM=t=>{const e=O(4),{Quote:n}=t,r=G(C1);if(!r)return null;let s;return e[0]!==n||e[1]!==r.messageId||e[2]!==r.text?(s=T.jsx(n,{text:r.text,messageId:r.messageId}),e[0]=n,e[1]=r.messageId,e[2]=r.text,e[3]=s):s=e[3],s},jM=Ue(LM);function P1(t,e){var r,s,i,o;const n=((s=(r=t.toolUIs[e.toolName])==null?void 0:r[0])==null?void 0:s.render)??null;return n||(J0((o=(i=e.mcp)==null?void 0:i.app)==null?void 0:o.resourceUri)&&t.mcpApp?t.mcpApp.render:null)}const M1=()=>{const t=O(6),e=oe(),n=G(KM),r=G(YM);if(!r||n.type!=="tool-call")return null;let s;return t[0]!==r||t[1]!==e.part.addToolResult||t[2]!==e.part.respondToToolApproval||t[3]!==e.part.resumeToolCall||t[4]!==n?(s=T.jsx(r,{...n,addResult:e.part.addToolResult,resume:e.part.resumeToolCall,respondToApproval:e.part.respondToToolApproval}),t[0]=r,t[1]=e.part.addToolResult,t[2]=e.part.respondToToolApproval,t[3]=e.part.resumeToolCall,t[4]=n,t[5]=s):s=t[5],s},D1=()=>{const t=O(3),e=G(JM),n=G(XM);if(!n||e.type!=="data")return null;const r=e;let s;return t[0]!==n||t[1]!==r?(s=T.jsx(n,{...r}),t[0]=n,t[1]=r,t[2]=s):s=t[2],s},$M=()=>{const t=O(2),e=G(ZM);if(e==="tool-call"){let n;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=T.jsx(M1,{}),t[0]=n):n=t[0],n}if(e==="data"){let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=T.jsx(D1,{}),t[1]=n):n=t[1],n}return null},zM=Object.freeze({type:"text",text:"",status:MM}),FM=({children:t})=>{const e=oe(),n=G(r=>r.dataRenderers);return T.jsx(Us,{getItemState:r=>r.part.getState(),children:r=>t({get part(){const s=r();if(s.type==="tool-call"){const i=P1(e.tools.getState(),s)!==null,o=e.part;return{...s,toolUI:i?T.jsx(M1,{}):null,addResult:o.addToolResult,resume:o.resumeToolCall,respondToApproval:o.respondToToolApproval}}if(s.type==="data"){const i=xf(n,s.name,void 0)!==void 0;return{...s,dataRendererUI:i?T.jsx(D1,{}):null}}return s}})})},O1=t=>{const e=O(5),{index:n,children:r}=t;let s;e[0]!==r?(s=T.jsx(FM,{children:r}),e[0]=r,e[1]=s):s=e[1];let i;return e[2]!==n||e[3]!==s?(i=T.jsx(lf,{index:n,children:s}),e[2]=n,e[3]=s,e[4]=i):i=e[4],i},BM=t=>{const e=O(9),{children:n}=t,r=G(e3),s=G(t3),i=r===0&&s;if(r===0){if(!i)return null;let a;e[0]!==n?(a=n({part:zM}),e[0]=n,e[1]=a):a=e[1];let l;return e[2]!==a?(l=T.jsx(uf,{text:"",isRunning:!0,children:a}),e[2]=a,e[3]=l):l=e[3],l}let o;if(e[4]!==n||e[5]!==r){let a;e[7]!==n?(a=(l,u)=>T.jsx(O1,{index:u,children:c=>n(c)??T.jsx($M,{})},u),e[7]=n,e[8]=a):a=e[8],o=T.jsx(T.Fragment,{children:Array.from({length:r},a)}),e[4]=n,e[5]=r,e[6]=o}else o=e[6];return o},Sd=t=>{const e=O(5),{components:n,unstable_showEmptyOnNonTextEnd:r,children:s}=t,i=r===void 0?!0:r;if(s){let a;return e[0]!==s?(a=T.jsx(BM,{children:s}),e[0]=s,e[1]=a):a=e[1],a}let o;return e[2]!==n||e[3]!==i?(o=T.jsx(UM,{components:n,unstable_showEmptyOnNonTextEnd:i}),e[2]=n,e[3]=i,e[4]=o):o=e[4],o};Sd.displayName="MessagePrimitive.Parts";const UM=t=>{const e=O(15),{components:n,unstable_showEmptyOnNonTextEnd:r}=t,s=G(n3),i=!!(n!=null&&n.ChainOfThought),{ranges:o,partIds:a}=CM(i);let l;e:{if(s===0){let p;e[0]!==n?(p=T.jsx(A1,{components:n}),e[0]=n,e[1]=p):p=e[1],l=p;break e}let f;if(e[2]!==n||e[3]!==o||e[4]!==a){const p=new Set,g=_=>{const m=a[_];return m!==void 0&&!p.has(m)?(p.add(m),`part-id:${m}`):`part-${_}`};f=o.map(_=>{if(_.type==="single")return T.jsx(Ri,{index:_.index,components:n},_.index);if(_.type==="chainOfThoughtGroup"){const m=n==null?void 0:n.ChainOfThought;return m?T.jsx(TA,{startIndex:_.startIndex,endIndex:_.endIndex,children:T.jsx(m,{})},`chainOfThought-${_.idKey??_.startIndex}`):null}else if(_.type==="toolGroup"){const m=(n==null?void 0:n.ToolGroup)??gn.ToolGroup;return T.jsx(m,{startIndex:_.startIndex,endIndex:_.endIndex,children:Array.from({length:_.endIndex-_.startIndex+1},(y,v)=>{const S=_.startIndex+v;return T.jsx(Ri,{index:S,components:n},g(S))})},`tool-${_.idKey??_.startIndex}`)}else{const m=(n==null?void 0:n.ReasoningGroup)??gn.ReasoningGroup;return T.jsx(m,{startIndex:_.startIndex,endIndex:_.endIndex,children:Array.from({length:_.endIndex-_.startIndex+1},(y,v)=>{const S=_.startIndex+v;return T.jsx(Ri,{index:S,components:n},`part-${S}`)})},`reasoning-${_.startIndex}`)}}),e[2]=n,e[3]=o,e[4]=a,e[5]=f}else f=e[5];l=f}const u=l;let c;e[6]!==n?(c=(n==null?void 0:n.Quote)&&T.jsx(jM,{Quote:n.Quote}),e[6]=n,e[7]=c):c=e[7];let d;e[8]!==n||e[9]!==r?(d=T.jsx(NM,{components:n,enabled:r}),e[8]=n,e[9]=r,e[10]=d):d=e[10];let h;return e[11]!==u||e[12]!==c||e[13]!==d?(h=T.jsxs(T.Fragment,{children:[c,u,d]}),e[11]=u,e[12]=c,e[13]=d,e[14]=h):h=e[14],h};function VM(t){return t.type}function HM(t){return t.message.parts.map(VM)}function qM(t){return t.type==="tool-call"?t.toolCallId:void 0}function GM(t){return t.message.parts.map(qM)}function WM(t){return t.part}function QM(t){return t.message.status??PM}function KM(t){return t.part}function YM(t){return t.part.type==="tool-call"?P1(t.tools,t.part):null}function JM(t){return t.part}function XM(t){return t.part.type==="data"?xf(t.dataRenderers,t.part.name,void 0)??null:null}function ZM(t){return t.part.type}function e3(t){return t.message.parts.length}function t3(t){var e;return(((e=t.message.status)==null?void 0:e.type)??"complete")==="running"}function n3(t){return t.message.parts.length}const N1=Symbol.for("@assistant-ui/groupBy.memoKey"),r3=t=>{const e=t,n=(s,i)=>{var o,a,l,u,c;if(s.type==="tool-call"){if((J0((a=(o=s.mcp)==null?void 0:o.app)==null?void 0:a.resourceUri)||(((c=(u=(l=i==null?void 0:i.toolUIs)==null?void 0:l[s.toolName])==null?void 0:u[0])==null?void 0:c.standalone)??!1))&&e["standalone-tool-call"]!==void 0)return e["standalone-tool-call"];const d=e[`tool-call:${s.toolName}`];return d!==void 0?d:e["tool-call"]??[]}return e[s.type]??[]},r=Object.keys(t).sort().map(s=>[s,t[s]]);return n[N1]=`groupPartByType:${JSON.stringify(r)}`,n},Eg=t=>{const e=t.nextChildIdx++;return t.nodeKey===""?String(e):`${t.nodeKey}.${e}`},Rg=(t,e)=>{if(!(e===void 0||t.claimed.has(e)))return t.claimed.add(e),`id:${e}`},s3=(t,e)=>{const n={key:"",nodeKey:"",indices:[],children:[],nextChildIdx:0,claimed:new Set},r=[n],s=()=>{const i=r.pop(),o=r[r.length-1];o.children.push({type:"group",key:i.key,nodeKey:i.nodeKey,idKey:Rg(o,e==null?void 0:e[i.indices[0]]),indices:i.indices,children:i.children})};for(let i=0;i<t.length;i++){const o=t[i];let a=0;for(;a<r.length-1&&a<o.length&&r[a+1].key===o[a];)a++;for(;r.length-1>a;)s();for(;r.length-1<o.length;){const u=r[r.length-1];r.push({key:o[r.length-1],nodeKey:Eg(u),indices:[],children:[],nextChildIdx:0,claimed:new Set})}const l=r[r.length-1];l.children.push({type:"part",index:i,nodeKey:Eg(l),idKey:Rg(l,e==null?void 0:e[i])});for(let u=1;u<r.length;u++)r[u].indices.push(i)}for(;r.length>1;)s();return n.children},i3=(t,e,n)=>{if(!n)return!1;switch(t){case"never":return!1;case"always":return!0;case"empty":return e.length===0;case"no-text":{const r=e[e.length-1];return r===void 0||r.type!=="text"&&r.type!=="reasoning"}}},L1=()=>{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.")},j1=(t,e,n)=>{if(t.type==="part")return T.jsx(O1,{index:t.index,children:({part:o})=>n({part:o,children:T.jsx(L1,{})})},t.idKey?`part-${t.idKey}`:`part-${t.index}`);const{status:r,counts:s}=xA(e,t.indices),i={type:t.key,status:r,counts:s,indices:t.indices};return T.jsx(zw,{children:n({part:i,children:T.jsx(T.Fragment,{children:t.children.map(o=>j1(o,e,n))})})},t.idKey??t.nodeKey)},$1=({groupBy:t,indicator:e="no-text",children:n})=>{const r=G(Fr(l=>l.message.parts)),s=G(l=>l.tools.toolUIs),i=G(l=>{var u;return e==="never"?!1:((u=l.message.status)==null?void 0:u.type)==="running"}),o=t[N1]??t,a=ge(()=>{const l={toolUIs:s};return s3(r.map(u=>t(u,l)??[]),r.map(u=>u.type==="tool-call"?u.toolCallId:void 0))},[r,o,s]);return T.jsxs(T.Fragment,{children:[a.map(l=>j1(l,r,n)),i3(e,r,i)&&n({part:{type:"indicator"},children:T.jsx(L1,{})})]})};$1.displayName="MessagePrimitive.GroupedParts";const o3=t=>{const e=O(5),{children:n}=t,r=G(C1);if(!r)return null;let s;e[0]!==n||e[1]!==r?(s=n(r),e[0]=n,e[1]=r,e[2]=s):s=e[2];let i;return e[3]!==s?(i=T.jsx(T.Fragment,{children:s}),e[3]=s,e[4]=i):i=e[4],i},z1=Ue(o3);z1.displayName="MessagePrimitive.Quote";const F1=(t,e)=>{switch(e.type){case"image":return(t==null?void 0:t.Image)??(t==null?void 0:t.Attachment);case"document":return(t==null?void 0:t.Document)??(t==null?void 0:t.Attachment);case"file":return(t==null?void 0:t.File)??(t==null?void 0:t.Attachment);default:return t==null?void 0:t.Attachment}},a3=t=>{const e=O(5),{components:n}=t,r=G(l3);if(!r)return null;const s=r;let i;e[0]!==n||e[1]!==s?(i=F1(n,s),e[0]=n,e[1]=s,e[2]=i):i=e[2];const o=i;if(!o)return null;let a;return e[3]!==o?(a=T.jsx(o,{}),e[3]=o,e[4]=a):a=e[4],a},B1=Ue(t=>{const e=O(5),{index:n,components:r}=t;let s;e[0]!==r?(s=T.jsx(a3,{components:r}),e[0]=r,e[1]=s):s=e[1];let i;return e[2]!==n||e[3]!==s?(i=T.jsx(B0,{index:n,children:s}),e[2]=n,e[3]=s,e[4]=i):i=e[4],i},(t,e)=>{var n,r,s,i,o,a,l,u;return t.index===e.index&&((n=t.components)==null?void 0:n.Image)===((r=e.components)==null?void 0:r.Image)&&((s=t.components)==null?void 0:s.Document)===((i=e.components)==null?void 0:i.Document)&&((o=t.components)==null?void 0:o.File)===((a=e.components)==null?void 0:a.File)&&((l=t.components)==null?void 0:l.Attachment)===((u=e.components)==null?void 0:u.Attachment)});B1.displayName="MessagePrimitive.AttachmentByIndex";const Ag=({children:t})=>{const e=G(Fr(n=>n.message.role!=="user"?[]:(n.message.attachments??[]).map(r=>r.id)));return ge(()=>e.map((n,r)=>T.jsx(B0,{index:r,children:T.jsx(Us,{getItemState:s=>s.message.attachment({index:r}).getState(),children:s=>t({get attachment(){return s()}})})},n)),[e,t])},U1=t=>{const e=O(4),{components:n,children:r}=t;if(n){let i;return e[0]!==n?(i=T.jsx(Ag,{children:o=>{const{attachment:a}=o,l=F1(n,a);return l?T.jsx(l,{}):null}}),e[0]=n,e[1]=i):i=e[1],i}let s;return e[2]!==r?(s=T.jsx(Ag,{children:r}),e[2]=r,e[3]=s):s=e[3],s};U1.displayName="MessagePrimitive.Attachments";function l3(t){return t.attachment}const V1=(t,e)=>{switch(e.type){case"image":return(t==null?void 0:t.Image)??(t==null?void 0:t.Attachment);case"document":return(t==null?void 0:t.Document)??(t==null?void 0:t.Attachment);case"file":return(t==null?void 0:t.File)??(t==null?void 0:t.Attachment);default:return t==null?void 0:t.Attachment}},u3=t=>{const e=O(5),{components:n}=t,r=G(c3);if(!r)return null;let s;e[0]!==r||e[1]!==n?(s=V1(n,r),e[0]=r,e[1]=n,e[2]=s):s=e[2];const i=s;if(!i)return null;let o;return e[3]!==i?(o=T.jsx(i,{}),e[3]=i,e[4]=o):o=e[4],o},H1=Ue(t=>{const e=O(5),{index:n,components:r}=t;let s;e[0]!==r?(s=T.jsx(u3,{components:r}),e[0]=r,e[1]=s):s=e[1];let i;return e[2]!==n||e[3]!==s?(i=T.jsx(U0,{index:n,children:s}),e[2]=n,e[3]=s,e[4]=i):i=e[4],i},(t,e)=>{var n,r,s,i,o,a,l,u;return t.index===e.index&&((n=t.components)==null?void 0:n.Image)===((r=e.components)==null?void 0:r.Image)&&((s=t.components)==null?void 0:s.Document)===((i=e.components)==null?void 0:i.Document)&&((o=t.components)==null?void 0:o.File)===((a=e.components)==null?void 0:a.File)&&((l=t.components)==null?void 0:l.Attachment)===((u=e.components)==null?void 0:u.Attachment)});H1.displayName="ComposerPrimitive.AttachmentByIndex";const Pg=({children:t})=>{const e=G(Fr(n=>n.composer.attachments.map(r=>r.id)));return ge(()=>e.map((n,r)=>T.jsx(U0,{index:r,children:T.jsx(Us,{getItemState:s=>s.composer.attachment({index:r}).getState(),children:s=>t({get attachment(){return s()}})})},n)),[e,t])},q1=t=>{const e=O(4),{components:n,children:r}=t;if(n){let i;return e[0]!==n?(i=T.jsx(Pg,{children:o=>{const{attachment:a}=o,l=V1(n,a);return l?T.jsx(l,{}):null}}),e[0]=n,e[1]=i):i=e[1],i}let s;return e[2]!==r?(s=T.jsx(Pg,{children:r}),e[2]=r,e[3]=s):s=e[3],s};q1.displayName="ComposerPrimitive.Attachments";function c3(t){return t.attachment}const d3=({children:t})=>{const e=G(Fr(n=>n.composer.queue.map(r=>r.id)));return ge(()=>e.map((n,r)=>T.jsx(CA,{index:r,children:T.jsx(Us,{getItemState:s=>s.composer.queueItem({index:r}).getState(),children:s=>t({get queueItem(){return s()}})})},n)),[e,t])},G1=Ue(d3);G1.displayName="ComposerPrimitive.Queue";const Sf=t=>{const{children:e}=t;return G(h3)?e:null};Sf.displayName="MessagePartPrimitive.InProgress";function h3(t){return t.part.status.type==="running"}const W1=t=>{const e=O(2),{components:n}=t,r=n.Suggestion;let s;return e[0]!==r?(s=T.jsx(r,{}),e[0]=r,e[1]=s):s=e[1],s},Q1=Ue(t=>{const e=O(5),{index:n,components:r}=t;let s;e[0]!==r?(s=T.jsx(W1,{components:r}),e[0]=r,e[1]=s):s=e[1];let i;return e[2]!==n||e[3]!==s?(i=T.jsx(H0,{index:n,children:s}),e[2]=n,e[3]=s,e[4]=i):i=e[4],i},(t,e)=>t.index===e.index&&t.components.Suggestion===e.components.Suggestion);Q1.displayName="ThreadPrimitive.SuggestionByIndex";const Mg=({children:t})=>{const e=G(n=>n.suggestions.suggestions.length);return ge(()=>e===0?null:Array.from({length:e},(n,r)=>T.jsx(H0,{index:r,children:T.jsx(Us,{getItemState:s=>s.suggestions.suggestion({index:r}).getState(),children:s=>t({get suggestion(){return s()}})})},r)),[e,t])},K1=t=>{const e=O(4),{components:n,children:r}=t;if(n){let i;return e[0]!==n?(i=T.jsx(Mg,{children:()=>T.jsx(W1,{components:n})}),e[0]=n,e[1]=i):i=e[1],i}let s;return e[2]!==r?(s=T.jsx(Mg,{children:r}),e[2]=r,e[3]=s):s=e[3],s};K1.displayName="ThreadPrimitive.Suggestions";const f3=Ue(K1,(t,e)=>t.children||e.children?t.children===e.children:t.components.Suggestion===e.components.Suggestion),p3=t=>{const e=O(3);let n;return e[0]!==t.dictation||e[1]!==t.editing?(n=r=>{if(t.editing===!0&&!r.composer.isEditing||t.editing===!1&&r.composer.isEditing)return!1;const s=r.composer.dictation!=null;return!(t.dictation===!0&&!s||t.dictation===!1&&s)},e[0]=t.dictation,e[1]=t.editing,e[2]=n):n=e[2],G(n)},Y1=t=>{const e=O(3);let n,r;return e[0]!==t?({children:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),p3(r)?n:null};Y1.displayName="ComposerPrimitive.If";const m3=t=>!t.composer.canSend||t.thread.isRunning&&!t.thread.capabilities.queue,g3=t=>!t.composer.canCancel,y3=(t,e)=>t.thread.isDisabled||e&&t.thread.isRunning&&!t.thread.capabilities.queue,v3=t=>{var n;if(((n=t.message.status)==null?void 0:n.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"},_3=()=>{const t=O(5),e=oe(),n=G(m3);let r;t[0]!==e?(r=o=>{e.composer.send(o)},t[0]=e,t[1]=r):r=t[1];const s=r;let i;return t[2]!==n||t[3]!==s?(i={send:s,disabled:n},t[2]=n,t[3]=s,t[4]=i):i=t[4],i},w3=()=>{const t=O(5),e=oe(),n=G(g3);let r;t[0]!==e?(r=()=>{e.composer.cancel()},t[0]=e,t[1]=r):r=t[1];const s=r;let i;return t[2]!==s||t[3]!==n?(i={cancel:s,disabled:n},t[2]=s,t[3]=n,t[4]=i):i=t[4],i},x3=()=>{const t=O(5),e=oe(),n=G(S3);let r;t[0]!==e?(r=()=>{e.composer.startDictation()},t[0]=e,t[1]=r):r=t[1];const s=r;let i;return t[2]!==n||t[3]!==s?(i={startDictation:s,disabled:n},t[2]=n,t[3]=s,t[4]=i):i=t[4],i};function S3(t){return t.composer.dictation!=null||!t.thread.capabilities.dictation||!t.composer.isEditing}const b3=()=>{const t=O(5),e=oe(),n=G(T3);let r;t[0]!==e?(r=o=>e.composer.addAttachment(o),t[0]=e,t[1]=r):r=t[1];const s=r;let i;return t[2]!==s||t[3]!==n?(i={addAttachment:s,disabled:n},t[2]=s,t[3]=n,t[4]=i):i=t[4],i};function T3(t){return!t.composer.isEditing}const k3=t=>{const e=O(10),{prompt:n,send:r,clearComposer:s}=t,i=s===void 0?!0:s,o=oe(),a=r??!1;let l;e[0]!==a?(l=f=>y3(f,a),e[0]=a,e[1]=l):l=e[1];const u=G(l);let c;e[2]!==o||e[3]!==i||e[4]!==n||e[5]!==a?(c=()=>{if(a){const{isRunning:f,capabilities:p}=o.thread.getState();if(f&&!p.queue)return;o.thread.append({content:[{type:"text",text:n}],runConfig:o.composer.getState().runConfig}),i&&!f&&o.composer.setText("")}else if(i)o.composer.setText(n);else{const f=o.composer.getState().text;o.composer.setText([f,n].filter(C3).join(" "))}},e[2]=o,e[3]=i,e[4]=n,e[5]=a,e[6]=c):c=e[6];const d=c;let h;return e[7]!==u||e[8]!==d?(h={trigger:d,disabled:u},e[7]=u,e[8]=d,e[9]=h):h=e[9],h};function C3(t){return t.trim()}const I3=()=>G(v3),E3=async(t,e)=>{const{signal:n,onUpdate:r}=e;if(Symbol.asyncIterator in t)for await(const s of t){if(n.aborted)break;r(s)}else{const s=await t;if(n.aborted)return;r(s)}},R3=t=>{const e=[...t.content,...(t.attachments??[]).flatMap(r=>(r.content??[]).filter(s=>s.type!=="text"))],n=[];for(const r of e)r.type==="file"||r.type==="text"?n.push(r):r.type==="image"&&n.push({type:"file",data:r.image,mimeType:"image/*",...r.filename!==void 0&&{filename:r.filename}});return n},A3=t=>{let e={queue:Zt,steer:Zt};const n=new Map,r=new Set;let s=!1,i=!1,o=!1,a=k=>k,l=0,u=0,c=!1,d=0;const h=()=>{Yt(r,void 0,"Message queue")},f=k=>{e=k,x.items=k.queue,x.steerItems=k.steer,h()},p=(k,R)=>({id:k,prompt:bo(R),parts:R3(R)}),g=(k,R,M=0)=>{i=!0,n.set(R.id,R.message),f({...e,[k]:[...e[k].slice(0,M),R.item,...e[k].slice(M)]})},_=k=>{if(e.steer.some(R=>R.id===k))return"steer";if(e.queue.some(R=>R.id===k))return"queue"},m=()=>{if(s||i||o)return;const k=e.steer.length>0?"steer":"queue",R=e[k][0];if(!R)return;const M=n.get(R.id);if(n.delete(R.id),f({...e,[k]:e[k].slice(1)}),!M)return;const L={id:R.id,item:R,message:M};s=!0;const z=d;try{t.run(a(M),{steer:!1})}catch(W){throw d===z&&(s=!1,g(k,L)),W}},y=(k,R="steer",M=0)=>{i=!1,l+=Math.max(u,1),u=0;const L=(W=!1)=>{if(W)return;const K=l;l=Math.max(K-1,0),u=K>0?1:0,s=K>0,g(R,k,M)};c=!0;try{t.cancel()}catch(W){throw L(),W}finally{c=!1}s=!0;const z=d;try{t.run(a(k.message),{steer:!0})}catch(W){throw L(d!==z),W}},v=(k,R)=>{i=!1;const M=Ct();n.set(M,R),f({...e,[k]:[...e[k],p(M,R)]}),m()},S=k=>{v("queue",k)},I=k=>{if(s&&t.cancel){const R=Ct();y({id:R,item:p(R,k),message:k});return}v("steer",k)},b=(k,R)=>{const M=_(k);if(!M)throw new Error(`Unknown queue item "${k}".`);const L=R.lane??M,z=e[M].findIndex(q=>q.id===k),W=e[M][z],K=(L===M?e[M]:e[L]).filter(q=>q.id!==k),$=q=>{if(q===k)throw new Error(`Queue item "${k}" cannot anchor itself.`);const X=K.findIndex(V=>V.id===q);if(X===-1)throw new Error(`Unknown anchor "${q}" in lane "${L}".`);return X},{insertAfter:U,insertBefore:C}=R;let Y;if(U===void 0&&C===void 0)Y=L===M?e[M].findIndex(q=>q.id===k):K.length;else if(U!==void 0&&C!==void 0){const q=U===null?-1:$(U);if((C===null?K.length:$(C))!==q+1)throw new Error(`insertAfter "${U}" and insertBefore "${C}" are not adjacent in lane "${L}".`);Y=q+1}else U!==void 0?Y=U===null?0:$(U)+1:Y=C===null?K.length:$(C);if(U===void 0&&C===void 0&&L==="steer"&&M!=="steer"&&s&&t.cancel){const q=n.get(k);n.delete(k),f({queue:e.queue.filter(X=>X.id!==k),steer:e.steer}),y({id:k,item:W,message:q},M,z);return}const j=[...K.slice(0,Y),W,...K.slice(Y)],E={...e,[L]:j};L!==M&&(E[M]=e[M].filter(q=>q.id!==k)),f(E),m()},P=(k,R)=>{const M=_(k);if(!M)throw new Error(`Unknown queue item "${k}".`);n.set(k,R),f({...e,[M]:e[M].map(L=>L.id===k?p(k,R):L)})},A=k=>{n.delete(k)&&f({queue:e.queue.filter(R=>R.id!==k),steer:e.steer.filter(R=>R.id!==k)})},D=()=>{c||s&&u===0&&(i=!0,u=1)},x={items:e.queue,steerItems:e.steer,enqueue:S,steer:I,move:b,edit:P,remove:A,__internal_setDispatchTransform:k=>{a=k},__internal_notifyCancelled:D};return{adapter:x,hold:()=>{o=!0},release:()=>{o=!1,m()},notifyBusy:()=>{i=!1,l+=u,u=0,s=!0,d++},notifyIdle:()=>{if(l>0){l--;return}u>0&&u--,s=!1,m()},notifyCancelled:D,clear:()=>{n.clear(),f({queue:Zt,steer:Zt})},subscribe:k=>(r.add(k),()=>{r.delete(k)})}},ai=(t,e)=>{var n;return((n=t.status)==null?void 0:n.type)!=="requires-action"||t.status.reason!=="tool-calls"||t.content.some(r=>r.type==="tool-call"&&r.result===void 0&&r.approval!==void 0&&r.approval.approved===void 0&&r.approval.resolution===void 0)?!1:e===void 0?t.content.every(r=>r.type!=="tool-call"||r.result!==void 0||r.approval!==void 0):t.content.every(r=>r.type!=="tool-call"||r.result!==void 0||r.approval!==void 0||!e.includes(r.toolName))};var Gu=class extends Error{constructor(e,n){super(n);w(this,"name","AbortError");w(this,"detach");this.detach=e}};const P3=t=>t.role!=="assistant"||t.status.type!=="requires-action"||t.status.reason!=="interrupt"||t.content.some(e=>e.type==="tool-call"&&e.result===void 0&&e.interrupt!=null)?t:{...t,status:af(!1,!1,!1,t.content.some(e=>e.type==="tool-call"&&e.result===void 0))},Dg=t=>({...t,messages:t.messages.map(e=>({...e,message:P3(e.message)}))});var M3=class extends n1{constructor(e,n){super(e);w(this,"capabilities",{switchToBranch:!0,switchBranchDuringRun:!0,edit:!0,delete:!1,reload:!0,refetchThread:!1,cancel:!0,unstable_copy:!0,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1});w(this,"abortController",null);w(this,"_queue",null);w(this,"_queueRunInFlight",null);w(this,"_activeRun",null);w(this,"_runGeneration",0);w(this,"_historyWrites",new Map);w(this,"isDisabled",!1);w(this,"isSendDisabled",!1);w(this,"_isLoading",!1);w(this,"_suggestions",[]);w(this,"_suggestionsController",null);w(this,"_options");w(this,"_lastRunConfig",{});w(this,"_getThreadId");w(this,"_getInitializePromise");w(this,"_loadPromise");w(this,"_loadRequested",!1);w(this,"_pendingAppends",0);this.__internal_setOptions(n)}_chainHistoryWrite(e,n){const r=(this._historyWrites.get(e)??Promise.resolve()).then(n,n),s=r.then(()=>{},()=>{});return this._historyWrites.set(e,s),s.then(()=>{this._historyWrites.get(e)===s&&this._historyWrites.delete(e)}),r}_persistPausedMessage(e,n){var o;if(((o=n.status)==null?void 0:o.type)!=="requires-action")return;const r=this._options.adapters.history;if(!(r!=null&&r.update))return;const s=r.update.bind(r),i={parentId:e,message:n,runConfig:this._lastRunConfig};this._chainHistoryWrite(n.id,()=>s(i)).catch(()=>{})}get isLoading(){return this._isLoading}get suggestions(){return this._suggestions}get adapters(){return this._options.adapters}__internal_setGetThreadId(e){this._getThreadId=e}__internal_setGetInitializePromise(e){this._getInitializePromise=e}get extras(){}__internal_setOptions(e){var d,h,f,p,g,_,m,y;if(this._options===e)return;const n=(d=this._options)==null?void 0:d.adapters.history;this._options=e;let r=!1;const s=((h=e.adapters)==null?void 0:h.speech)!==void 0;this.capabilities.speech!==s&&(this.capabilities.speech=s,r=!0);const i=((f=e.adapters)==null?void 0:f.dictation)!==void 0;this.capabilities.dictation!==i&&(this.capabilities.dictation=i,r=!0);const o=((p=e.adapters)==null?void 0:p.voice)!==void 0;this.capabilities.voice!==o&&(this.capabilities.voice=o,r=!0);const a=((g=e.adapters)==null?void 0:g.attachments)!==void 0;this.capabilities.attachments!==a&&(this.capabilities.attachments=a,r=!0);const l=((_=e.adapters)==null?void 0:_.feedback)!==void 0;this.capabilities.feedback!==l&&(this.capabilities.feedback=l,r=!0);const u=((y=(m=e.adapters)==null?void 0:m.history)==null?void 0:y.delete)!==void 0;this.capabilities.delete!==u&&(this.capabilities.delete=u,r=!0);const c=e.unstable_enableMessageQueue===!0;c&&!this._queue?(this._queue=A3({run:v=>{var b;const S={};this._queueRunInFlight=S;const I=this._runGeneration;this._runAppend({...v,parentId:this._resolveAppendParent(((b=this.messages.at(-1))==null?void 0:b.id)??null)}).finally(()=>{var P;this._queueRunInFlight===S&&(this._queueRunInFlight=null,this._runGeneration===I&&((P=this._queue)==null||P.notifyIdle()))}).catch(()=>{})}}),this.voice&&this._queue.hold(),this._queue.subscribe(()=>this._notifySubscribers())):!c&&this._queue&&(this._queue=null),this.capabilities.queue!==c&&(this.capabilities.queue=c,r=!0),r&&this._notifySubscribers(),this._loadRequested&&!this._loadPromise&&!n&&e.adapters.history&&this.messages.length===0&&this.__internal_load().catch(v=>{console.error("[assistant-ui] local thread history load failed:",v)})}__internal_load(){if(this._loadRequested=!0,this._loadPromise)return this._loadPromise;if(!this.adapters.history)return Promise.resolve();const e=this.adapters.history.load();return this._isLoading=!0,this._notifySubscribers(),this._loadPromise=e.then(n=>{var s,i;if(!n)return;this.repository.import(Dg(n)),n.messages.length>0&&this.ensureInitialized(),this._notifySubscribers();const r=(i=(s=this.adapters.history)==null?void 0:s.resume)==null?void 0:i.bind(this.adapters.history);n.unstable_resume&&r&&this.startRun({parentId:this.repository.headId,sourceId:this.repository.headId,runConfig:this._lastRunConfig},r).catch(()=>{})}).finally(()=>{this._isLoading=!1,this._notifySubscribers()}),this._loadPromise}async append(e){var s;if(e={...e,parentId:this._resolveAppendParent(e.parentId)},this.voice)throw new Error("Cannot send a text message while a voice session is connected");if(this._isVoiceMessage(e.sourceId))throw new Error("Voice transcript messages cannot be edited");const n=e.parentId===(((s=this.messages.at(-1))==null?void 0:s.id)??null),r=e.startRun??e.role==="user";if(this._queue&&r&&n){e.steer??this._queueRunInFlight!==null?this._queue.adapter.steer(e):this._queue.adapter.enqueue(e);return}return this._queue&&!n&&(this._options.unstable_queueClearOnRewind??!0)&&this._queue.clear(),this._runAppend(e)}_commitVoiceMessage(e){var s;const n=this.repository.headId;this.repository.addOrUpdateMessage(n,e),this.repository.resetHead(e.id),(s=this._options.adapters.history)==null||s.append({parentId:n,message:e}).catch(()=>{});const r=this._voiceMessages.findIndex(i=>i.id===e.id);r!==-1&&this._voiceMessages.splice(r,1),this._markVoiceMessagesDirty()}_onVoiceConnected(){var e;(e=this._queue)==null||e.hold()}_onVoiceDisconnected(){var e;(e=this._queue)==null||e.release()}getQueueItems(){var e;return((e=this._queue)==null?void 0:e.adapter.items)??Zt}getSteerQueueItems(){var e;return((e=this._queue)==null?void 0:e.adapter.steerItems)??Zt}moveQueueItem(e,n){var r;(r=this._queue)==null||r.adapter.move(e,n)}removeQueueItem(e){var n;(n=this._queue)==null||n.adapter.remove(e)}_rollbackAppend(e){try{this.repository.deleteMessage(e)}catch{return}this._notifySubscribers()}_isRunActive(){return this._pendingAppends>0||super._isRunActive()}async _runAppend(e){this._pendingAppends+=1;try{await this._runAppendInner(e)}finally{this._pendingAppends-=1}}async _runAppendInner(e){var o,a;const n=no(this),r=this.enrichAppendMetadata(e);this.ensureInitialized();const s=Os(r,Ct(),{type:"complete",reason:"unknown"});this.repository.addOrUpdateMessage(r.parentId,s),this._notifySubscribers();try{const l=(o=this._getInitializePromise)==null?void 0:o.call(this);l&&await l}catch(l){if(this._rollbackAppend(s.id),!Ii(this,n))return;const u=new AA;throw u.cause=l,u}if(!Ii(this,n)){this._rollbackAppend(s.id);return}const i=(a=this._options.adapters.history)==null?void 0:a.append({parentId:r.parentId,message:s,...r.runConfig!==void 0&&{runConfig:r.runConfig}});if(i==null||i.catch(()=>{}),r.startRun??r.role==="user"){const[l,u]=await Promise.allSettled([this.startRun({parentId:s.id,sourceId:r.sourceId,runConfig:r.runConfig??{}}),i]);if(l.status==="rejected")throw l.reason;if(u.status==="rejected")throw u.reason}else this.repository.resetHead(s.id),this._notifySubscribers(),await i}async deleteMessage(e){var a;const n=this._options.adapters.history;if(!(n!=null&&n.delete))throw new Error("Runtime does not support deleting messages.");const r=this.repository.getMessages(),s=r.findIndex(l=>l.id===e);if(s===-1)throw new Error("Message not found.");const i=r[s],o=[{parentId:((a=r[s-1])==null?void 0:a.id)??null,message:i}];await n.delete(o),this.repository.deleteMessage(e),this._notifySubscribers()}resumeRun({stream:e,...n}){if(!e)throw new Error("You must pass a stream parameter to resume runs.");return this.startRun(n,e)}exportExternalState(){throw new Error("Runtime does not support exporting external states.")}import(e){super.import(Dg(e))}importExternalState(){throw new Error("Runtime does not support importing external states.")}unstable_notifySessionReset(){throw new Error("Runtime does not support resetting sessions.")}async startRun({parentId:e,sourceId:n,runConfig:r},s){if(this.ensureInitialized(),this.voice)throw new Error("Cannot start a run while a voice session is connected");if(this._isVoiceMessage(n))throw new Error("Voice transcript messages cannot be reloaded");const i={id:Ct(),role:"assistant",status:{type:"running"},content:[],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},createdAt:new Date};return this._runLoop(e,i,r,s)}async _runLoop(e,n,r,s){var l,u,c,d,h;if(this.voice)throw new Error("Cannot start a run while a voice session is connected");this._notifyEventSubscribers("runStart",{});const i=((l=n.status)==null?void 0:l.type)==="requires-action"&&((u=this._options.adapters.history)==null?void 0:u.update)!==void 0,o={cancelled:!1};this._activeRun=o,this._runGeneration++;let a=!1;try{(c=this._queue)==null||c.notifyBusy(),this._suggestions=[],(d=this._suggestionsController)==null||d.abort(),this._suggestionsController=null,this._notifySubscribers();do if(n=await this.performRoundtrip(e,n,r,i,o,s),s=void 0,this._activeRun!==o)break;while(ai(n,this._options.unstable_humanToolNames))}finally{this._notifyEventSubscribers("runEnd",{}),a=this._activeRun===o,a&&(this._activeRun=null),(a||o.cancelled)&&queueMicrotask(()=>{var f;return(f=this._queue)==null?void 0:f.notifyIdle()})}if(a&&this.adapters.suggestion&&((h=n.status)==null?void 0:h.type)!=="requires-action"){this._suggestionsController=new AbortController;const f=this._suggestionsController.signal,p=this.adapters.suggestion;(async()=>{try{const g=p.generate({messages:this.messages,signal:f});await E3(g,{signal:f,onUpdate:_=>{this._suggestions=_,this._notifySubscribers()}})}catch{}})()}}async performRoundtrip(e,n,r,s,i,o){var y,v,S,I,b,P,A,D;const a=e?this.repository.getMessages(e):[];(y=this.abortController)==null||y.abort();const l=new AbortController;this.abortController=l;const u=n.content,c=(v=n.metadata)==null?void 0:v.unstable_annotations,d=(S=n.metadata)==null?void 0:S.unstable_data,h=(I=n.metadata)==null?void 0:I.steps,f=(b=n.metadata)==null?void 0:b.custom;let p=!0;try{this.repository.getMessage(n.id)}catch{p=!1}const g=()=>{if(!p)return this._activeRun===i;try{return this.repository.getMessage(n.id).message===n}catch{return!1}},_=x=>{var K,$,U,C,Y;if(!g())return;const k=(K=x.metadata)==null?void 0:K.steps,R=k?[...h??[],...k]:void 0,M=($=x.metadata)==null?void 0:$.unstable_annotations,L=(U=x.metadata)==null?void 0:U.unstable_data,z=M?[...c??[],...M]:void 0,W=L?[...d??[],...L]:void 0;n={...n,...x.content?{content:[...u,...x.content??[]]}:void 0,status:x.status??n.status,...x.metadata?{metadata:{...n.metadata,...x.metadata.unstable_state!==void 0?{unstable_state:x.metadata.unstable_state}:void 0,...z?{unstable_annotations:z}:void 0,...W?{unstable_data:W}:void 0,...R?{steps:R}:void 0,...(C=x.metadata)!=null&&C.timing?{timing:x.metadata.timing}:void 0,...(Y=x.metadata)!=null&&Y.custom?{custom:{...f??{},...x.metadata.custom}}:void 0}}:void 0},this.repository.addOrUpdateMessage(e,n),p=!0,this._notifySubscribers()},m=this._options.maxSteps??2;try{if((((A=(P=n.metadata)==null?void 0:P.steps)==null?void 0:A.length)??0)>=m)return _({status:{type:"incomplete",reason:"tool-calls"}}),n;_({status:{type:"running"}}),this.repository.resetHead(n.id),this._notifySubscribers(),this._lastRunConfig=r??{};const{unstable_composerMetadata:x,...k}=this.getModelContext();o=o??this.adapters.chatModel.run.bind(this.adapters.chatModel);const R=l.signal,M=()=>R.aborted&&(n.status.type==="running"||n.status.type==="requires-action"&&(this._activeRun!==i||ai(n,this._options.unstable_humanToolNames))),L=(D=this._getThreadId)==null?void 0:D.call(this),z=o({messages:a,runConfig:this._lastRunConfig,abortSignal:R,context:k,unstable_assistantMessageId:n.id,unstable_threadId:L,unstable_parentId:e,unstable_getMessage(){return n}});if(Symbol.asyncIterator in z)for await(const W of z){if(R.aborted){M()&&_({status:{type:"incomplete",reason:"cancelled"}});break}_(W)}else _(await z);M()?_({status:{type:"incomplete",reason:"cancelled"}}):n.status.type==="running"&&_({status:{type:"complete",reason:"unknown"}})}catch(x){if(x instanceof Gu)_({status:{type:"incomplete",reason:"cancelled"}});else if(x instanceof Error&&x.name==="AbortError")_({status:{type:"incomplete",reason:"cancelled"}});else throw _({status:{type:"incomplete",reason:"error",error:PA(x)}}),x}finally{this.abortController===l&&(this.abortController=null);const x=this._options.adapters.history,k={parentId:e,message:n,runConfig:this._lastRunConfig},R=n.status.type==="complete"||n.status.type==="incomplete",M=n.status.type==="requires-action"&&!ai(n,this._options.unstable_humanToolNames);if(g()&&(R||M&&(x!=null&&x.update))){const L=s&&(x!=null&&x.update)?x.update.bind(x):x==null?void 0:x.append.bind(x);L&&await this._chainHistoryWrite(n.id,()=>L(k))}}return n}detach(){var n,r;ro(this),this._queue=null;const e=new Gu(!0);(n=this.abortController)==null||n.abort(e),this.abortController=null,(r=this._suggestionsController)==null||r.abort(),this._suggestionsController=null}cancelRun(){var n,r;this._queue&&(this._options.unstable_queueClearOnCancel??!0?this._queue.clear():(this._queue.notifyCancelled(),this._activeRun&&(this._activeRun.cancelled=!0)));const e=new Gu(!1);(n=this.abortController)==null||n.abort(e),this.abortController=null,(r=this._suggestionsController)==null||r.abort(),this._suggestionsController=null}addToolResult({messageId:e,toolCallId:n,result:r,isError:s,artifact:i,modelContent:o}){if(this.voice)throw new Error("Cannot add a tool result while a voice session is connected");const a=this.repository.getMessage(e),{parentId:l}=a;let{message:u}=a;if(u.role!=="assistant")throw new Error("Tried to add tool result to non-assistant message");let c=!1,d=!1;const h=u.content.map(f=>f.type!=="tool-call"||f.toolCallId!==n?f:(d=!0,f.result===void 0&&(c=!0),{...f,result:r,isError:s,...i!==void 0&&{artifact:i},...o!==void 0&&{modelContent:o}}));if(!d)throw new Error("Tried to add tool result to non-existing tool call");u={...u,content:h},this.repository.addOrUpdateMessage(l,u),this._notifySubscribers(),c&&ai(u,this._options.unstable_humanToolNames)?this._runLoop(l,u,this._lastRunConfig).catch(()=>{}):c&&this._persistPausedMessage(l,u)}resumeToolCall(e){throw new Error("Local runtime does not support resuming tool calls. For human-in-the-loop tools, list the tool in unstable_humanToolNames and complete the call with addToolResult.")}respondToToolApproval({approvalId:e,approved:n,optionId:r,text:s,reason:i}){var d;if(this.voice)throw new Error("Cannot respond to a tool approval while a voice session is connected");let o=this.repository.getMessages().findLast(h=>h.role==="assistant"&&h.content.some(f=>{var p;return f.type==="tool-call"&&((p=f.approval)==null?void 0:p.id)===e}));if(!o)throw new Error("Tried to respond to a non-existing tool approval");if(this.abortController!==null)throw new Error("Tried to respond to a tool approval while a run is in progress");if(((d=o.status)==null?void 0:d.type)!=="requires-action")throw new Error("Tried to respond to a tool approval on a message whose status is not requires-action");const a=o.content.find(h=>{var f;return h.type==="tool-call"&&((f=h.approval)==null?void 0:f.id)===e});if((a==null?void 0:a.type)!=="tool-call"||!a.approval)throw new Error("Tried to respond to a non-existing tool approval");if(a.approval.resolution!==void 0)throw new Error("Tried to respond to a tool approval that was cancelled or expired");if(a.approval.approved!==void 0)throw new Error("Tried to respond to an already decided tool approval");const l=a.approval,u=o.content.map(h=>{if(h!==a)return h;const f={...l,approved:n,...r!=null&&{optionId:r},...s!=null&&{text:s},...i!=null&&{reason:i}};return n?{...h,approval:f}:{...h,approval:f,result:{error:i||"Tool approval denied"},isError:!0}});o={...o,content:u};const{parentId:c}=this.repository.getMessage(o.id);return this.repository.addOrUpdateMessage(c,o),this._notifySubscribers(),this._notifyToolApprovalAnswered(o.id,a.toolCallId,a.toolName,n),this.repository.headId===o.id&&ai(o,this._options.unstable_humanToolNames)?this._runLoop(c,o,this._lastRunConfig).catch(()=>{}):this._persistPausedMessage(c,o),Promise.resolve()}};const Og=Object.freeze([]),bd="__DEFAULT_ID__",D3=Object.freeze({[bd]:{id:bd,remoteId:void 0,externalId:void 0,status:"regular",title:void 0}});var O3=class extends $n{constructor(e){super();w(this,"_mainThread");this._mainThread=e()}get isLoading(){return!1}getMainThreadRuntimeCore(){return this._mainThread}get newThreadId(){}get threadIds(){return Og}get archivedThreadIds(){return Og}get mainThreadId(){return bd}get threadItems(){return D3}getThreadRuntimeCore(){throw new Error("Method not implemented.")}getLoadThreadsPromise(){return Promise.resolve()}getItemById(e){if(e===this.mainThreadId)return{status:"regular",id:this.mainThreadId,remoteId:this.mainThreadId,externalId:void 0,title:void 0,isMain:!0};throw new Error("Method not implemented")}async switchToThread(){throw new Error("Method not implemented.")}switchToNewThread(){throw new Error("Method not implemented.")}rename(){throw new Error("Method not implemented.")}archive(){throw new Error("Method not implemented.")}detach(){throw new Error("Method not implemented.")}unarchive(){throw new Error("Method not implemented.")}delete(){throw new Error("Method not implemented.")}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw new Error("Method not implemented.")}},N3=class extends df{constructor(e,n){super();w(this,"threads");w(this,"Provider");w(this,"_options");this._options=e,this.threads=new O3(()=>new M3(this._contextProvider,this._options)),n&&this.threads.getMainThreadRuntimeCore().import(hf.fromArray(n))}};const L3=(t,{initialMessages:e,...n})=>{const{modelContext:r,...s}=of()??{},i={...n,adapters:{...s,...n.adapters,chatModel:t}},[o]=ce(()=>new N3(i,e)),a=te(void 0),l=te(void 0);return a.current=G(u=>u.threadListItem.remoteId),J(()=>{o.threads.getMainThreadRuntimeCore().__internal_setGetThreadId(()=>a.current)},[o]),J(()=>()=>{o.threads.getMainThreadRuntimeCore().detach()},[o]),J(()=>{o.threads.getMainThreadRuntimeCore().__internal_setOptions(i)}),J(()=>{const u=o.threads.getMainThreadRuntimeCore().__internal_load();l.current!==u&&(l.current=u,u.catch(c=>{console.error("[assistant-ui] local thread history load failed:",c)}))},[o]),J(()=>{if(r)return o.registerModelContextProvider(r)},[r,o]),ge(()=>new cf(o),[o])},j3=(t,{cloud:e,...n}={})=>{const r=mM({cloud:e});return H2({runtimeHook:function(){return L3(t,n)},adapter:r,allowNesting:!0})};function $3(t,e){function n(r){const s=At(t);if(!(r!=null&&r.optional)&&!s)throw new Error(`This component must be used within ${e}.`);return s}return n}function J1(t,e){function n(s){const i=t(s);return i?i[e]:null}function r(s){let i=!1,o;typeof s=="function"?o=s:s&&typeof s=="object"&&(i=!!s.optional,o=s.selector);const a=n({optional:i});return a?o?a(o):a():null}return{[e]:r,[`${e}Store`]:n}}const X1=Rt(null),z3=$3(X1,"ThreadPrimitive.Viewport"),{useThreadViewport:hr,useThreadViewportStore:Yr}=J1(z3,"useThreadViewport"),Ng=t=>{let e;const n=new Set,r=(u,c)=>{const d=typeof u=="function"?u(e):u;if(!Object.is(d,e)){const h=e;e=c??(typeof d!="object"||d===null)?d:Object.assign({},e,d),n.forEach(f=>f(e,h))}},s=()=>e,a={setState:r,getState:s,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u))},l=e=t(r,s,a);return a},F3=t=>t?Ng(t):Ng,B3=t=>t;function U3(t,e=B3){const n=Nt.useSyncExternalStore(t.subscribe,Nt.useCallback(()=>e(t.getState()),[t,e]),Nt.useCallback(()=>e(t.getInitialState()),[t,e]));return Nt.useDebugValue(n),n}const Lg=t=>{const e=F3(t),n=r=>U3(e,r);return Object.assign(n,e),n},V3=t=>t?Lg(t):Lg,jg=t=>{const e=new Map,n=()=>{let r=0;for(const s of e.values())r+=s;t(r)};return{register:()=>{const r=Symbol();return e.set(r,0),{setHeight:s=>{e.get(r)!==s&&(e.set(r,s),n())},unregister:()=>{e.delete(r),n()}}}}},H3=(t={})=>{const e=new Set,n=jg(o=>{i.setState({height:{...i.getState().height,viewport:o}})}),r=jg(o=>{i.setState({height:{...i.getState().height,inset:o}})}),s=(o,a)=>(i.setState({element:{...i.getState().element,[o]:a}}),()=>{i.getState().element[o]===a&&i.setState({element:{...i.getState().element,[o]:null}})}),i=V3(()=>{var o,a;return{isAtBottom:!0,scrollToBottom:({behavior:l="auto"}={})=>{Yt(e,()=>({behavior:l}),"Thread viewport")},onScrollToBottom:l=>(e.add(l),()=>{e.delete(l)}),turnAnchor:t.turnAnchor??"bottom",topAnchorMessageClamp:{tallerThan:((o=t.topAnchorMessageClamp)==null?void 0:o.tallerThan)??"10em",visibleHeight:((a=t.topAnchorMessageClamp)==null?void 0:a.visibleHeight)??"6em"},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:r.register,registerViewportElement:l=>s("viewport",l),registerAnchorElement:l=>s("anchor",l),registerAnchorTargetElement:(l,u)=>(i.setState({element:{...i.getState().element,target:l},targetConfig:l&&u?u:null}),()=>{i.getState().element.target===l&&i.setState({element:{...i.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:l=>{i.setState({topAnchorTurn:l})}}});return i},al=t=>t,q3=t=>{const e=O(11);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={optional:!0},e[0]=n):n=e[0];const r=Yr(n);let s;e[1]!==t?(s=()=>H3(t),e[1]=t,e[2]=s):s=e[2];const[i]=ce(s);let o,a;e[3]!==r||e[4]!==i?(o=()=>r==null?void 0:r.getState().onScrollToBottom(c=>{i.getState().scrollToBottom(c)}),a=[r,i],e[3]=r,e[4]=i,e[5]=o,e[6]=a):(o=e[5],a=e[6]),J(o,a);let l,u;return e[7]!==r||e[8]!==i?(l=()=>{if(r)return i.subscribe(c=>{r.getState().isAtBottom!==c.isAtBottom&&al(r).setState({isAtBottom:c.isAtBottom})})},u=[i,r],e[7]=r,e[8]=i,e[9]=l,e[10]=u):(l=e[9],u=e[10]),J(l,u),i},bf=t=>{const e=O(7),{children:n,options:r}=t;let s;e[0]!==r?(s=r===void 0?{}:r,e[0]=r,e[1]=s):s=e[1];const i=q3(s);let o;e[2]!==i?(o=()=>({useThreadViewport:i}),e[2]=i,e[3]=o):o=e[3];const[a]=ce(o);let l;return e[4]!==n||e[5]!==a?(l=T.jsx(X1.Provider,{value:a,children:n}),e[4]=n,e[5]=a,e[6]=l):l=e[6],l},G3=()=>{const t=O(3),e=oe();let n,r;return t[0]!==e?(n=()=>{},r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),J(n,r),null},W3=t=>{const e=O(8),{children:n,aui:r,config:s,runtime:i}=t,o=r??null;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=T.jsx(G3,{}),e[0]=a):a=e[0];let l;e[1]!==n?(l=T.jsx(bf,{children:n}),e[1]=n,e[2]=l):l=e[2];let u;return e[3]!==s||e[4]!==i||e[5]!==o||e[6]!==l?(u=T.jsxs(VE,{runtime:i,aui:o,config:s,children:[a,l]}),e[3]=s,e[4]=i,e[5]=o,e[6]=l,e[7]=u):u=e[7],u},Z1=Ue(W3),Q3=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,ex={serialize(t){const e=t.id!==t.label?`{name=${t.id}}`:"";return`:${t.type}[${t.label}]${e}`},parse(t){const e=[];let n=0;for(const r of t.matchAll(Q3)){r.index>n&&e.push({kind:"text",text:t.slice(n,r.index)});const s=r[2];e.push({kind:"mention",type:r[1],label:s,id:r[3]??s}),n=r.index+r[0].length}return n<t.length&&e.push({kind:"text",text:t.slice(n)}),e}};var K3=Object.defineProperty,Tf=(t,e)=>K3(t,"name",{value:e,configurable:!0});function Td(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Tf(Td,"setRef");function tx(...t){return e=>{let n=!1;const r=t.map(s=>{const i=Td(s,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let s=0;s<r.length;s++){const i=r[s];typeof i=="function"?i():Td(t[s],null)}}}}Tf(tx,"composeRefs");function fr(...t){return ee.useCallback(tx(...t),t)}Tf(fr,"useComposedRefs");var Y3=Object.defineProperty,ln=(t,e)=>Y3(t,"name",{value:e,configurable:!0});function kf(t){const e=ee.forwardRef((n,r)=>{let{children:s,...i}=n,o=null,a=!1;const l=[];kd(s)&&typeof ea=="function"&&(s=ea(s._payload)),ee.Children.forEach(s,h=>{var f;if(ix(h)){a=!0;const p=h;let g="child"in p.props?p.props.child:p.props.children;kd(g)&&typeof ea=="function"&&(g=ea(g._payload)),o=X3(p,g),l.push((f=o==null?void 0:o.props)==null?void 0:f.children)}else l.push(h)}),o?o=ee.cloneElement(o,void 0,l):!a&&ee.Children.count(s)===1&&ee.isValidElement(s)&&(o=s);const u=o?sx(o):void 0,c=fr(r,u);if(!o){if(s||s===0)throw new Error(a?tD(t):eD(t));return s}const d=rx(i,o.props??{});return o.type!==ee.Fragment&&(d.ref=r?c:u),ee.cloneElement(o,d)});return e.displayName=`${t}.Slot`,e}ln(kf,"createSlot");var Cf=kf("Slot"),nx=Symbol.for("radix.slottable");function J3(t){const e=ln(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=nx,e}ln(J3,"createSlottable");var X3=ln((t,e)=>{if("child"in t.props){const n=t.props.child;return ee.isValidElement(n)?ee.cloneElement(n,void 0,t.props.children(n.props.children)):null}return ee.isValidElement(e)?e:null},"getSlottableElementFromSlottable");function rx(t,e){const n={...e};for(const r in e){const s=t[r],i=e[r];/^on[A-Z]/.test(r)?s&&i?n[r]=(...a)=>{const l=i(...a);return s(...a),l}:s&&(n[r]=s):r==="style"?n[r]={...s,...i}:r==="className"&&(n[r]=[s,i].filter(Boolean).join(" "))}return{...t,...n}}ln(rx,"mergeProps");function sx(t){var r,s;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}ln(sx,"getElementRef");function ix(t){return ee.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===nx}ln(ix,"isSlottable");var Z3=Symbol.for("react.lazy");function kd(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===Z3&&"_payload"in t&&ox(t._payload)}ln(kd,"isLazyComponent");function ox(t){return typeof t=="object"&&t!==null&&"then"in t}ln(ox,"isPromiseLike");var eD=ln(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),tD=ln(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),ea=zb[" use ".trim().toString()],nD=Object.defineProperty,rD=(t,e)=>nD(t,"name",{value:e,configurable:!0}),sD=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ax=sD.reduce((t,e)=>{const n=kf(`Primitive.${e}`),r=ee.forwardRef((s,i)=>{const{asChild:o,...a}=s,l=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),T.jsx(l,{...a,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function lx(t,e){t&&yw.flushSync(()=>t.dispatchEvent(e))}rD(lx,"dispatchDiscreteCustomEvent");var iD=Object.defineProperty,qs=(t,e)=>iD(t,"name",{value:e,configurable:!0}),ux=!!(typeof window<"u"&&window.document&&window.document.createElement);function Oe(t,e,{checkForDefaultPrevented:n=!0}={}){return qs(function(s){if(t==null||t(s),n===!1||!s||!s.defaultPrevented)return e==null?void 0:e(s)},"handleEvent")}qs(Oe,"composeEventHandlers");function oD(t){var e;if(!ux)throw new Error("Cannot access window outside of the DOM");return((e=t==null?void 0:t.ownerDocument)==null?void 0:e.defaultView)??window}qs(oD,"getOwnerWindow");function Cd(t){if(!ux)throw new Error("Cannot access document outside of the DOM");return(t==null?void 0:t.ownerDocument)??document}qs(Cd,"getOwnerDocument");function cx(t,e=!1){const{activeElement:n}=Cd(t);if(!(n!=null&&n.nodeName))return null;if(dx(n)&&n.contentDocument)return cx(n.contentDocument.body,e);if(e){const r=n.getAttribute("aria-activedescendant");if(r){const s=Cd(n).getElementById(r);if(s)return s}}return n}qs(cx,"getActiveElement");function dx(t){return t.tagName==="IFRAME"}qs(dx,"isFrame");var aD=Object.defineProperty,lD=(t,e)=>aD(t,"name",{value:e,configurable:!0});function ko(t){const e=ee.useRef(t);return ee.useEffect(()=>{e.current=t}),ee.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}lD(ko,"useCallbackRef");var uD=Object.defineProperty,hx=(t,e)=>uD(t,"name",{value:e,configurable:!0});function fx(t,e=globalThis==null?void 0:globalThis.document){const n=ko(t);ee.useEffect(()=>{const r=hx(s=>{s.key==="Escape"&&n(s)},"handleKeyDown");return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}hx(fx,"useEscapeKeydown");var If=ax;If.dispatchDiscreteCustomEvent=lx;If.Root=ax;var $g=Object.defineProperty,Ef=(t,e)=>{let n={};for(var r in t)$g(n,r,{get:t[r],enumerable:!0});return $g(n,Symbol.toStringTag,{value:"Module"}),n};const cD=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"];function px(t,e){return SC(t,void 0,e!==void 0?e:t.props.children)}function Rf(t,e,n){return T.jsx(Cf,{...n,children:px(t,e)})}function dD(t){const e=Re((n,r)=>{const s=O(17);let i,o,a,l;s[0]!==n?({render:a,asChild:i,children:o,...l}=n,s[0]=n,s[1]=i,s[2]=o,s[3]=a,s[4]=l):(i=s[1],o=s[2],a=s[3],l=s[4]);const u=t;if(a&&Nl(a)){const h=l;let f;s[5]!==o||s[6]!==a?(f=px(a,o),s[5]=o,s[6]=a,s[7]=f):f=s[7];let p;return s[8]!==r||s[9]!==h||s[10]!==f?(p=T.jsx(u,{...h,asChild:!0,ref:r,children:f}),s[8]=r,s[9]=h,s[10]=f,s[11]=p):p=s[11],p}const c=l;let d;return s[12]!==i||s[13]!==o||s[14]!==r||s[15]!==c?(d=T.jsx(u,{...c,asChild:i,ref:r,children:o}),s[12]=i,s[13]=o,s[14]=r,s[15]=c,s[16]=d):d=s[16],d});return e.displayName=typeof t=="string"?t:t.displayName??t.name??"Component",e}function hD(t){const e=If[t],n=dD(e);return n.displayName=`Primitive.${t}`,n}const ze=cD.reduce((t,e)=>(t[e]=hD(e),t),{}),Jr=(t,e,n=[])=>{const r=Re((s,i)=>{const o=O(6),a={},l={};Object.keys(s).forEach(g=>{n.includes(g)?a[g]=s[g]:l[g]=s[g]});const u=e(a)??void 0,c=ze,d="button",h=l.disabled||!u,f=Oe(l.onClick,u);let p;return o[0]!==i||o[1]!==l||o[2]!==c.button||o[3]!==h||o[4]!==f?(p=T.jsx(c.button,{type:d,...l,ref:i,disabled:h,onClick:f}),o[0]=i,o[1]=l,o[2]=c.button,o[3]=h,o[4]=f,o[5]=p):p=o[5],p});return r.displayName=t,r},mx=Rt(null),Af=()=>At(mx),fD=t=>{const e=O(8),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Map,e[0]=r):r=e[0];const s=te(r);let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[1]=i):i=e[1];const o=te(i);let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const _=Array.from(s.current.entries());_.sort(pD),o.current=_.map(mD)},e[2]=a):a=e[2];const l=a;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=(_,m)=>{const y=(m==null?void 0:m.priority)??0;return s.current.set(_,y),l(),()=>{s.current.delete(_),l()}},e[3]=u):u=e[3];const c=u;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=()=>o.current,e[4]=d):d=e[4];const h=d;let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f={register:c,getPlugins:h},e[5]=f):f=e[5];const p=f;let g;return e[6]!==n?(g=T.jsx(mx.Provider,{value:p,children:n}),e[6]=n,e[7]=g):g=e[7],g};function pD(t,e){return e[1]-t[1]}function mD(t){const[e]=t;return e}const Pf=Rt(null),gx=Rt(null),Mf=()=>{const t=At(Pf);if(!t)throw new Error("useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot");return t},Df=()=>At(Pf),gD=()=>{const t=At(gx);if(!t)throw new Error("useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot");return t},yD=()=>{const t=Mf();return Wr(t.subscribe,t.getTriggers,t.getTriggers)},vD=new Map,yx=()=>()=>{},zg=()=>vD,_D=()=>{const t=Df();return Wr(t?t.subscribe:yx,t?t.getTriggers:zg,t?t.getTriggers:zg)},Fg=()=>null,wD=()=>{const t=Df();return Wr(t?t.subscribeAria:yx,t?t.getActiveAria:Fg,t?t.getActiveAria:Fg)};function Bg(){const t=O(4);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=new Set,t[0]=e):e=t[0];const n=te(e);let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{for(const l of n.current)l()},t[1]=r):r=t[1];const s=r;let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=l=>(n.current.add(l),()=>{n.current.delete(l)}),t[2]=i):i=t[2];const o=i;let a;return t[3]===Symbol.for("react.memo_cache_sentinel")?(a={notify:s,subscribe:o},t[3]=a):a=t[3],a}const Ug=t=>{const e=O(21),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Map,e[0]=r):r=e[0];const s=te(r);let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[1]=i):i=e[1];const o=te(i),{notify:a,subscribe:l}=Bg();let u;e[2]!==a?(u=M=>{const{char:L}=M;if(s.current.has(L))return xD;const z=new Map(s.current);z.set(L,M),s.current=z,a();for(const W of o.current)W.added(M);return()=>{const W=new Map(s.current);W.delete(L),s.current=W,a();for(const K of o.current)K.removed(L)}},e[2]=a,e[3]=u):u=e[3];const c=u;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=()=>s.current,e[4]=d):d=e[4];const h=d;let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=M=>(o.current.add(M),()=>{o.current.delete(M)}),e[5]=f):f=e[5];const p=f,g=te(null),_=te(null),{notify:m,subscribe:y}=Bg();let v;e[6]!==m?(v=(M,L)=>{if(L===null){if(_.current!==M)return;g.current=null,_.current=null,m();return}const z=g.current;_.current===M&&z!==null&&z.popoverId===L.popoverId&&z.highlightedItemId===L.highlightedItemId||(g.current=L,_.current=M,m())},e[6]=m,e[7]=v):v=e[7];const S=v;let I;e[8]===Symbol.for("react.memo_cache_sentinel")?(I=()=>g.current,e[8]=I):I=e[8];const b=I;let P;e[9]!==c||e[10]!==l||e[11]!==y?(P={register:c,getTriggers:h,subscribe:l,subscribeLifecycle:p,getActiveAria:b,subscribeAria:y},e[9]=c,e[10]=l,e[11]=y,e[12]=P):P=e[12];const A=P;let D;e[13]!==S?(D={setActiveAria:S},e[13]=S,e[14]=D):D=e[14];const x=D;let k;e[15]!==x||e[16]!==n?(k=T.jsx(gx.Provider,{value:x,children:n}),e[15]=x,e[16]=n,e[17]=k):k=e[17];let R;return e[18]!==k||e[19]!==A?(R=T.jsx(Pf.Provider,{value:A,children:k}),e[18]=k,e[19]=A,e[20]=R):R=e[20],R},vx=t=>{const e=O(4),{children:n}=t;if(Af()){let s;return e[0]!==n?(s=T.jsx(Ug,{children:n}),e[0]=n,e[1]=s):s=e[1],s}let r;return e[2]!==n?(r=T.jsx(fD,{children:T.jsx(Ug,{children:n})}),e[2]=n,e[3]=r):r=e[3],r};vx.displayName="ComposerPrimitive.TriggerPopoverRoot";function xD(){}const Vg=/\s/u;function SD(t,e,n,r){if(r===null)return null;const{query:s,offset:i,endOffset:o}=r;return i<0||i+e.length>n||!t.startsWith(e,i)||o<i+e.length||o>t.length?null:{query:s,offset:i,endOffset:o}}function bD(t,e,n,r){if(r)return SD(t,e,n,r(t,e,n));const s=t.slice(0,n);for(let i=s.length-1;i>=0;i--){const o=s[i];if(Vg.test(o))return null;if(s.startsWith(e,i)){if(i>0&&!Vg.test(s[i-1]))continue;return{query:s.slice(i+e.length),offset:i,endOffset:n}}}return null}const TD=t=>{const e=O(8),{text:n,triggerChar:r,matcher:s}=t,[i,o]=ce(n.length),a=Math.min(i,n.length);let l;e[0]!==s||e[1]!==a||e[2]!==n||e[3]!==r?(l=bD(n,r,a,s),e[0]=s,e[1]=a,e[2]=n,e[3]=r,e[4]=l):l=e[4];const u=l,c=(u==null?void 0:u.query)??"";let d;return e[5]!==c||e[6]!==u?(d={trigger:u,query:c,setCursorPosition:o},e[5]=c,e[6]=u,e[7]=d):d=e[7],d},kD=de(TD);function CD(t){return"type"in t}const ID=t=>{const e=O(22),{navigableList:n,isSearchMode:r,activeCategoryId:s,query:i,popoverId:o,open:a,selectItem:l,selectCategory:u,goBack:c,close:d}=t,[h,f]=ce(0);let p;e[0]!==s||e[1]!==r||e[2]!==n?(p={navigableList:n,isSearchMode:r,activeCategoryId:s},e[0]=s,e[1]=r,e[2]=n,e[3]=p):p=e[3];const[g,_]=ce(p);(g.navigableList!==n||g.isSearchMode!==r||g.activeCategoryId!==s)&&(_({navigableList:n,isSearchMode:r,activeCategoryId:s}),f(0));let m;e[4]!==h||e[5]!==n.length?(m=A=>{A<0||A>=n.length||A!==h&&f(A)},e[4]=h,e[5]=n.length,e[6]=m):m=e[6];const y=ht(m);let v;e[7]!==s||e[8]!==d||e[9]!==c||e[10]!==h||e[11]!==n||e[12]!==a||e[13]!==i||e[14]!==u||e[15]!==l?(v=A=>{if(!a)return!1;switch(A.key){case"ArrowDown":return A.preventDefault(),f(D=>{const x=n.length;return x===0?0:D<x-1?D+1:0}),!0;case"ArrowUp":return A.preventDefault(),f(D=>{const x=n.length;return x===0?0:D>0?D-1:x-1}),!0;case"Enter":case"Tab":{if(A.shiftKey)return!1;A.preventDefault();const D=n[h];return D&&(CD(D)?l(D):u(D.id)),!0}case"Escape":return A.preventDefault(),d(),!0;case"Backspace":return s&&i===""?(A.preventDefault(),c(),!0):!1;default:return!1}},e[7]=s,e[8]=d,e[9]=c,e[10]=h,e[11]=n,e[12]=a,e[13]=i,e[14]=u,e[15]=l,e[16]=v):v=e[16];const S=ht(v),I=n[h],b=a&&I?`${o}-option-${I.id}`:void 0;let P;return e[17]!==S||e[18]!==y||e[19]!==h||e[20]!==b?(P={highlightedIndex:h,highlightedItemId:b,highlightIndex:y,handleKeyDown:S},e[17]=S,e[18]=y,e[19]=h,e[20]=b,e[21]=P):P=e[21],P},ED=de(ID);function Hg(t,e){var n;return e?t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e)||(((n=t.description)==null?void 0:n.toLowerCase().includes(e))??!1):!0}const RD=t=>{const e=O(35),{adapter:n,query:r,open:s}=t,[i,o]=ce(null),[a,l]=ce(s);a!==s&&(l(s),s||o(null));let u;e:{if(!s||!n){let M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M=[],e[0]=M):M=e[0],u=M;break e}let R;e[1]!==n?(R=n.categories(),e[1]=n,e[2]=R):R=e[2],u=R}const c=u,d=s?i:null;let h;e:{if(!d||!n){let M;e[3]===Symbol.for("react.memo_cache_sentinel")?(M=[],e[3]=M):M=e[3],h=M;break e}let R;e[4]!==n||e[5]!==d?(R=n.categoryItems(d),e[4]=n,e[5]=d,e[6]=R):R=e[6],h=R}const f=h;let p;e:{if(!s||!n||d){p=null;break e}if(!r&&c.length>0){p=null;break e}if(n.search){let M;e[7]!==n||e[8]!==r?(M=n.search(r),e[7]=n,e[8]=r,e[9]=M):M=e[9],p=M;break e}let R;if(e[10]!==n||e[11]!==c||e[12]!==r){R=[];const M=r.toLowerCase();for(const L of c)for(const z of n.categoryItems(L.id))Hg(z,M)&&R.push(z);e[10]=n,e[11]=c,e[12]=r,e[13]=R}else R=e[13];p=R}const g=p,_=g!==null;let m;e:{if(_){let M;e[14]===Symbol.for("react.memo_cache_sentinel")?(M=[],e[14]=M):M=e[14],m=M;break e}if(!r){m=c;break e}let R;if(e[15]!==c||e[16]!==r){const M=r.toLowerCase();R=c.filter(L=>L.label.toLowerCase().includes(M)),e[15]=c,e[16]=r,e[17]=R}else R=e[17];m=R}const y=m;let v;e:{if(_){let M;e[18]!==g?(M=g??[],e[18]=g,e[19]=M):M=e[19],v=M;break e}if(!r){v=f;break e}let R;if(e[20]!==f||e[21]!==r){const M=r.toLowerCase();R=f.filter(L=>Hg(L,M)),e[20]=f,e[21]=r,e[22]=R}else R=e[22];v=R}const S=v;let I;e:{if(_){let R;e[23]!==g?(R=g??[],e[23]=g,e[24]=R):R=e[24],I=R;break e}if(d){I=S;break e}I=y}const b=I;let P;e[25]===Symbol.for("react.memo_cache_sentinel")?(P=R=>{o(R)},e[25]=P):P=e[25];const A=ht(P);let D;e[26]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{o(null)},e[26]=D):D=e[26];const x=ht(D);let k;return e[27]!==d||e[28]!==y||e[29]!==S||e[30]!==x||e[31]!==_||e[32]!==b||e[33]!==A?(k={categories:y,items:S,isSearchMode:_,activeCategoryId:d,navigableList:b,selectCategory:A,goBack:x},e[27]=d,e[28]=y,e[29]=S,e[30]=x,e[31]=_,e[32]=b,e[33]=A,e[34]=k):k=e[34],k},AD=de(RD),PD=t=>{const e=O(15),{behavior:n,trigger:r,aui:s,setCursorPosition:i,onSelected:o}=t,a=te(null);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=g=>(a.current=g,()=>{a.current===g&&(a.current=null)}),e[0]=l):l=e[0];const u=ht(l);let c;e[1]!==s||e[2]!==n||e[3]!==o||e[4]!==i||e[5]!==r?(c=g=>{var S,I;if(!r||!n)return;if((S=a.current)!=null&&S.call(a,g)){o();return}const _=s.composer.getState().text,m=_.slice(0,r.offset),y=_.slice(r.endOffset),v=()=>{const b=n.formatter.serialize(g);s.composer.setText(m+b+(y.startsWith(" ")?y:` ${y}`)),i(m.length+b.length+1)};n.kind==="directive"?(v(),(I=n.onInserted)==null||I.call(n,g)):(n.removeOnExecute?(s.composer.setText(m+(y.startsWith(" ")?y.slice(1):y)),i(m.length)):v(),n.onExecute(g)),o()},e[1]=s,e[2]=n,e[3]=o,e[4]=i,e[5]=r,e[6]=c):c=e[6];const d=ht(c);let h;e[7]!==o||e[8]!==i||e[9]!==r?(h=()=>{o(),r&&i(r.offset)},e[7]=o,e[8]=i,e[9]=r,e[10]=h):h=e[10];const f=ht(h);let p;return e[11]!==f||e[12]!==u||e[13]!==d?(p={selectItem:d,close:f,registerSelectItemOverride:u},e[11]=f,e[12]=u,e[13]=d,e[14]=p):p=e[14],p},MD=de(PD),DD=t=>{const e=O(47),{adapter:n,text:r,triggerChar:s,matcher:i,behavior:o,aui:a,popoverId:l,isLoading:u}=t;let c;e[0]!==i||e[1]!==r||e[2]!==s?(c=kD({text:r,triggerChar:s,matcher:i}),e[0]=i,e[1]=r,e[2]=s,e[3]=c):c=e[3];const d=wt(c),h=d.trigger!==null&&n!==void 0&&o!==void 0;let f;e[4]!==n||e[5]!==d.query||e[6]!==h?(f=AD({adapter:n,query:d.query,open:h}),e[4]=n,e[5]=d.query,e[6]=h,e[7]=f):f=e[7];const p=wt(f);let g;e[8]!==p?(g=()=>{p.goBack()},e[8]=p,e[9]=g):g=e[9];const _=ht(g);let m;e[10]!==a||e[11]!==o||e[12]!==d.setCursorPosition||e[13]!==d.trigger||e[14]!==_||e[15]!==s?(m=MD({behavior:o,trigger:d.trigger,aui:a,triggerChar:s,setCursorPosition:d.setCursorPosition,onSelected:_}),e[10]=a,e[11]=o,e[12]=d.setCursorPosition,e[13]=d.trigger,e[14]=_,e[15]=s,e[16]=m):m=e[16];const y=wt(m);let v;e[17]!==d.query||e[18]!==p.activeCategoryId||e[19]!==p.goBack||e[20]!==p.isSearchMode||e[21]!==p.navigableList||e[22]!==p.selectCategory||e[23]!==h||e[24]!==l||e[25]!==y.close||e[26]!==y.selectItem?(v=ED({navigableList:p.navigableList,isSearchMode:p.isSearchMode,activeCategoryId:p.activeCategoryId,query:d.query,popoverId:l,open:h,selectItem:y.selectItem,selectCategory:p.selectCategory,goBack:p.goBack,close:y.close}),e[17]=d.query,e[18]=p.activeCategoryId,e[19]=p.goBack,e[20]=p.isSearchMode,e[21]=p.navigableList,e[22]=p.selectCategory,e[23]=h,e[24]=l,e[25]=y.close,e[26]=y.selectItem,e[27]=v):v=e[27];const S=wt(v);let I;return e[28]!==d.query||e[29]!==d.setCursorPosition||e[30]!==u||e[31]!==S.handleKeyDown||e[32]!==S.highlightIndex||e[33]!==S.highlightedIndex||e[34]!==S.highlightedItemId||e[35]!==p.activeCategoryId||e[36]!==p.categories||e[37]!==p.goBack||e[38]!==p.isSearchMode||e[39]!==p.items||e[40]!==p.selectCategory||e[41]!==h||e[42]!==l||e[43]!==y.close||e[44]!==y.registerSelectItemOverride||e[45]!==y.selectItem?(I={open:h,query:d.query,activeCategoryId:p.activeCategoryId,categories:p.categories,items:p.items,highlightedIndex:S.highlightedIndex,isSearchMode:p.isSearchMode,isLoading:u,popoverId:l,highlightedItemId:S.highlightedItemId,selectCategory:p.selectCategory,goBack:p.goBack,selectItem:y.selectItem,close:y.close,highlightIndex:S.highlightIndex,handleKeyDown:S.handleKeyDown,setCursorPosition:d.setCursorPosition,registerSelectItemOverride:y.registerSelectItemOverride},e[28]=d.query,e[29]=d.setCursorPosition,e[30]=u,e[31]=S.handleKeyDown,e[32]=S.highlightIndex,e[33]=S.highlightedIndex,e[34]=S.highlightedItemId,e[35]=p.activeCategoryId,e[36]=p.categories,e[37]=p.goBack,e[38]=p.isSearchMode,e[39]=p.items,e[40]=p.selectCategory,e[41]=h,e[42]=l,e[43]=y.close,e[44]=y.registerSelectItemOverride,e[45]=y.selectItem,e[46]=I):I=e[46],I},OD=de(DD),Of=Rt(null),Gs=()=>{const t=At(Of);if(!t)throw new Error("useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover");return t},ND=()=>At(Of),_x=Rt(null),wx=()=>{const t=At(_x);if(!t)throw new Error("TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover");return t},xx=Re((t,e)=>{const n=O(69);let r,s,i,o,a,l,u;n[0]!==t?({char:i,matcher:a,adapter:r,isLoading:u,"aria-label":s,children:o,...l}=t,n[0]=t,n[1]=r,n[2]=s,n[3]=i,n[4]=o,n[5]=a,n[6]=l,n[7]=u):(r=n[1],s=n[2],i=n[3],o=n[4],a=n[5],l=n[6],u=n[7]);const c=u===void 0?!1:u,d=oe(),h=G(LD),f=$w(),p=te(a);let g;n[8]!==a?(g=()=>{p.current=a},n[8]=a,n[9]=g):g=n[9],J(g);let _;n[10]===Symbol.for("react.memo_cache_sentinel")?(_=()=>(un,Kl,Yl)=>p.current(un,Kl,Yl),n[10]=_):_=n[10];const[m]=ce(_),y=a!==void 0,v=te(null),[S,I]=ce(null),b=te(0);let P;n[11]!==i?(P=un=>(b.current=b.current+1,v.current=un,I(un),()=>{b.current=Math.max(0,b.current-1),v.current===un&&(v.current=null,I(null))}),n[11]=i,n[12]=P):P=n[12];const A=P;let D;n[13]!==A?(D={register:A},n[13]=A,n[14]=D):D=n[14];const x=D,k=S??void 0;let R;n[15]!==r||n[16]!==d||n[17]!==i||n[18]!==c||n[19]!==a||n[20]!==f||n[21]!==k||n[22]!==h?(R=OD({adapter:r,text:h,triggerChar:i,matcher:a,behavior:k,aui:d,popoverId:f,isLoading:c}),n[15]=r,n[16]=d,n[17]=i,n[18]=c,n[19]=a,n[20]=f,n[21]=k,n[22]=h,n[23]=R):R=n[23];const M=wt(R);let L;n[24]!==M?(L=()=>M,n[24]=M,n[25]=L):L=n[25];const z=ht(L),W=Mf();let K;n[26]!==S||n[27]!==i||n[28]!==z||n[29]!==y||n[30]!==m||n[31]!==W?(K=()=>W.register({char:i,...y?{matcher:m}:{},...S?{behavior:S}:{},resource:z()}),n[26]=S,n[27]=i,n[28]=z,n[29]=y,n[30]=m,n[31]=W,n[32]=K):K=n[32];let $;n[33]!==S||n[34]!==i||n[35]!==y||n[36]!==W?($=[W,i,y,S],n[33]=S,n[34]=i,n[35]=y,n[36]=W,n[37]=$):$=n[37],J(K,$);const U=Af();let C;n[38]!==z||n[39]!==U?(C=()=>{if(U)return U.register(z())},n[38]=z,n[39]=U,n[40]=C):C=n[40];let Y;n[41]!==U?(Y=[U],n[41]=U,n[42]=Y):Y=n[42],J(C,Y);const j=S!==null&&M.open,E=gD();let q,X;n[43]!==E||n[44]!==i||n[45]!==j?(q=()=>{if(j)return()=>{E.setActiveAria(i,null)}},X=[E,i,j],n[43]=E,n[44]=i,n[45]=j,n[46]=q,n[47]=X):(q=n[46],X=n[47]),J(q,X);let V,he;n[48]!==E||n[49]!==i||n[50]!==j||n[51]!==f||n[52]!==M.highlightedItemId?(V=()=>{j&&E.setActiveAria(i,{popoverId:f,highlightedItemId:M.highlightedItemId})},he=[E,i,f,j,M.highlightedItemId],n[48]=E,n[49]=i,n[50]=j,n[51]=f,n[52]=M.highlightedItemId,n[53]=V,n[54]=he):(V=n[53],he=n[54]),J(V,he);let Ae;n[55]!==s||n[56]!==o||n[57]!==e||n[58]!==j||n[59]!==f||n[60]!==l||n[61]!==M.highlightedItemId?(Ae=j?T.jsx(ze.div,{role:"listbox",id:f,"aria-label":s??"Suggestions","aria-activedescendant":M.highlightedItemId,"data-state":"open",...l,ref:e,children:o}):o,n[55]=s,n[56]=o,n[57]=e,n[58]=j,n[59]=f,n[60]=l,n[61]=M.highlightedItemId,n[62]=Ae):Ae=n[62];let pt;n[63]!==M||n[64]!==Ae?(pt=T.jsx(Of.Provider,{value:M,children:Ae}),n[63]=M,n[64]=Ae,n[65]=pt):pt=n[65];let Vt;return n[66]!==x||n[67]!==pt?(Vt=T.jsx(_x.Provider,{value:x,children:pt}),n[66]=x,n[67]=pt,n[68]=Vt):Vt=n[68],Vt});xx.displayName="ComposerPrimitive.TriggerPopover";function LD(t){return t.composer.text}const Sx=()=>{const t=O(2),{disabled:e,send:n}=_3();let r;t[0]!==n?(r=()=>n(),t[0]=n,t[1]=r):r=t[1];const s=r;return e?null:s},jD=Jr("ComposerPrimitive.Send",Sx),bx=Rt(null),$D=()=>At(bx),Tx="[contenteditable]:not([contenteditable='false'])",zD=`textarea:not(:disabled), ${Tx}`,FD=["a","audio[controls]","button","details","embed","iframe","input","label","select","summary","textarea","video[controls]",Tx,"[tabindex]"].join(", "),kx=Re((t,e)=>{const n=O(24);let r,s,i,o;n[0]!==t?({onSubmit:i,onMouseDown:s,compact:r,...o}=t,n[0]=t,n[1]=r,n[2]=s,n[3]=i,n[4]=o):(r=n[1],s=n[2],i=n[3],o=n[4]);const a=Sx(),[l,u]=ce(!1);let c;n[5]===Symbol.for("react.memo_cache_sentinel")?(c={setMultiline:u},n[5]=c):c=n[5];const d=c;let h;n[6]!==r?(h=P=>r?P.composer.attachments.length===0&&P.composer.quote==null&&P.composer.queue.length===0&&P.composer.dictation==null&&!P.composer.text.includes(`
45
+ `):!1,n[6]=r,n[7]=h):h=n[7];const f=G(h)&&!l;let p;n[8]!==a?(p=P=>{P.preventDefault(),a&&a()},n[8]=a,n[9]=p):p=n[9];const g=p,_=BD,m=r?d:null,y=f?"":void 0;let v;n[10]!==g||n[11]!==i?(v=Oe(i,g),n[10]=g,n[11]=i,n[12]=v):v=n[12];let S;n[13]!==s?(S=Oe(s,_),n[13]=s,n[14]=S):S=n[14];let I;n[15]!==e||n[16]!==o||n[17]!==y||n[18]!==v||n[19]!==S?(I=T.jsx(ze.form,{...o,"data-compact":y,ref:e,onSubmit:v,onMouseDown:S}),n[15]=e,n[16]=o,n[17]=y,n[18]=v,n[19]=S,n[20]=I):I=n[20];let b;return n[21]!==m||n[22]!==I?(b=T.jsx(bx.Provider,{value:m,children:I}),n[21]=m,n[22]=I,n[23]=b):b=n[23],b});kx.displayName="ComposerPrimitive.Root";function BD(t){if(t.button!==0)return;const e=t.target;if(!(e instanceof Element)||!t.currentTarget.contains(e))return;const n=e.closest(FD);if(n&&t.currentTarget.contains(n))return;const r=t.currentTarget.querySelector(zD);r&&(t.preventDefault(),r.focus())}const Cx=t=>{const e=O(4),n=ko(t),r=hr(UD);let s,i;e[0]!==n||e[1]!==r?(s=()=>r(n),i=[r,n],e[0]=n,e[1]=r,e[2]=s,e[3]=i):(s=e[2],i=e[3]),J(s,i)};function UD(t){return t.onScrollToBottom}const VD=()=>!1,HD=()=>{},Ix=t=>{const e=O(4);let n;e[0]!==t?(n=i=>{if(typeof window>"u"||t===null||!window.matchMedia)return HD;const o=window.matchMedia(t);return o.addEventListener("change",i),()=>o.removeEventListener("change",i)},e[0]=t,e[1]=n):n=e[1];const r=n;let s;return e[2]!==t?(s=()=>typeof window>"u"||t===null||!window.matchMedia?!1:window.matchMedia(t).matches,e[2]=t,e[3]=s):s=e[3],Wr(r,s,VD)};function qD(){return G(GD)}function GD(t){return t.composer.isEditing?t.composer.text:""}function WD(t){return!!G(QD)||!!t}function QD(t){var e;return t.thread.isDisabled||((e=t.composer.dictation)==null?void 0:e.inputDisabled)}function KD(){const t=O(4),e=wD();if(!e){let r;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0],r}let n;return t[1]!==e.highlightedItemId||t[2]!==e.popoverId?(n={"aria-controls":e.popoverId,"aria-expanded":!0,"aria-haspopup":"listbox","aria-activedescendant":e.highlightedItemId},t[1]=e.highlightedItemId,t[2]=e.popoverId,t[3]=n):n=t[3],n}function Id(){return Id=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Id.apply(null,arguments)}function YD(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var JD=ee.useLayoutEffect,XD=function(e){var n=Nt.useRef(e);return JD(function(){n.current=e}),n},qg=function(e,n){if(typeof e=="function"){e(n);return}e.current=n},ZD=function(e,n){var r=Nt.useRef();return Nt.useCallback(function(s){e.current=s,r.current&&qg(r.current,null),r.current=n,n&&qg(n,s)},[n])},Gg={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},e4=function(e){Object.keys(Gg).forEach(function(n){e.style.setProperty(n,Gg[n],"important")})},Wg=e4,Xe=null,Qg=function(e,n){var r=e.scrollHeight;return n.sizingStyle.boxSizing==="border-box"?r+n.borderSize:r-n.paddingSize};function t4(t,e,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),Xe||(Xe=document.createElement("textarea"),Xe.setAttribute("tabindex","-1"),Xe.setAttribute("aria-hidden","true"),Wg(Xe)),Xe.parentNode===null&&document.body.appendChild(Xe);var s=t.paddingSize,i=t.borderSize,o=t.sizingStyle,a=o.boxSizing;Object.keys(o).forEach(function(h){var f=h;Xe.style[f]=o[f]}),Wg(Xe),Xe.value=e;var l=Qg(Xe,t);Xe.value=e,l=Qg(Xe,t),Xe.value="x";var u=Xe.scrollHeight-s,c=u*n;a==="border-box"&&(c=c+s+i),l=Math.max(c,l);var d=u*r;return a==="border-box"&&(d=d+s+i),l=Math.min(d,l),[l,u]}var Kg=function(){},n4=function(e,n){return e.reduce(function(r,s){return r[s]=n[s],r},{})},r4=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],s4=!!document.documentElement.currentStyle,i4=function(e){var n=window.getComputedStyle(e);if(n===null)return null;var r=n4(r4,n),s=r.boxSizing;if(s==="")return null;s4&&s==="border-box"&&(r.width=parseFloat(r.width)+parseFloat(r.borderRightWidth)+parseFloat(r.borderLeftWidth)+parseFloat(r.paddingRight)+parseFloat(r.paddingLeft)+"px");var i=parseFloat(r.paddingBottom)+parseFloat(r.paddingTop),o=parseFloat(r.borderBottomWidth)+parseFloat(r.borderTopWidth);return{sizingStyle:r,paddingSize:i,borderSize:o}},o4=i4;function Nf(t,e,n){var r=XD(n);ee.useLayoutEffect(function(){var s=function(o){return r.current(o)};if(t)return t.addEventListener(e,s),function(){return t.removeEventListener(e,s)}},[])}var a4=function(e,n){Nf(document.body,"reset",function(r){e.current.form===r.target&&n(r)})},l4=function(e){Nf(window,"resize",e)},u4=function(e){Nf(document.fonts,"loadingdone",e)},c4=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],d4=function(e,n){var r=e.cacheMeasurements,s=e.maxRows,i=e.minRows,o=e.onChange,a=o===void 0?Kg:o,l=e.onHeightChange,u=l===void 0?Kg:l,c=YD(e,c4),d=c.value!==void 0,h=ee.useRef(null),f=ZD(h,n),p=ee.useRef(0),g=ee.useRef(),_=function(){var v=h.current,S=r&&g.current?g.current:o4(v);if(S){g.current=S;var I=t4(S,v.value||v.placeholder||"x",i,s),b=I[0],P=I[1];p.current!==b&&(p.current=b,v.style.setProperty("height",b+"px","important"),u(b,{rowHeight:P}))}},m=function(v){d||_(),a(v)};return ee.useLayoutEffect(_),a4(h,function(){if(!d){var y=h.current.value;requestAnimationFrame(function(){var v=h.current;v&&y!==v.value&&_()})}}),l4(_),u4(_),ee.createElement("textarea",Id({},c,{onChange:m,ref:f}))},h4=ee.forwardRef(d4);const f4="(pointer: coarse) and (not (any-pointer: fine))",Ex=Re(({autoFocus:t=!1,asChild:e,render:n,disabled:r,onChange:s,onKeyDown:i,onPaste:o,onSelect:a,submitOnEnter:l,submitMode:u,cancelOnEscape:c=!0,unstable_focusOnRunStart:d=!0,unstable_focusOnScrollToBottom:h=!0,unstable_focusOnThreadSwitched:f=!0,unstable_insertNewlineOnTouchEnter:p=!1,addAttachmentOnPaste:g=!0,onHeightChange:_,...m},y)=>{const v=oe(),S=Af(),I=$D(),b=u??(l===!1?"none":"enter"),P=Ix(p?f4:null),A=p&&P&&b==="enter"?"none":b,D=qD(),x=WD(r),k=te(null),R=fr(y,k),M=te(!1);fx(j=>{var q;if(!((q=k.current)!=null&&q.contains(j.target))||j.isComposing)return;if(S){for(const X of S.getPlugins())if(X.handleKeyDown(j))return}if(!c)return;const E=v.composer;E.getState().canCancel&&(E.cancel(),j.preventDefault())});const L=j=>{var E,q;if(!x&&!j.nativeEvent.isComposing){if(S){for(const X of S.getPlugins())if(X.handleKeyDown(j))return}if(j.key==="Enter"){const X=v.thread.getState(),V=X.capabilities.queue;if(j.shiftKey&&(j.ctrlKey||j.metaKey)&&V&&b!=="none"&&v.composer.getState().canSend){j.preventDefault(),v.composer.send({steer:!0});return}if(j.shiftKey||X.isRunning&&!V)return;let he=!1;A==="ctrlEnter"?he=j.ctrlKey||j.metaKey:A==="enter"&&(he=!0),he&&(j.preventDefault(),(q=(E=k.current)==null?void 0:E.closest("form"))==null||q.requestSubmit())}}},z=async j=>{var X;if(!g)return;const E=v.thread.getState().capabilities,q=Array.from(((X=j.clipboardData)==null?void 0:X.files)||[]);E.attachments&&q.length>0&&(j.preventDefault(),await Promise.all(q.map(async V=>{try{await v.composer.addAttachment(V)}catch{}})))},W=(j,E)=>{if(_==null||_(j,E),!I)return;const q=k.current;if(!q||q.value==="")return;const X=getComputedStyle(q),V=X.boxSizing==="border-box"?j-parseFloat(X.paddingTop)-parseFloat(X.paddingBottom)-parseFloat(X.borderTopWidth)-parseFloat(X.borderBottomWidth):j;Math.round(V/E.rowHeight)>1&&I.setMultiline(!0)},K=t&&!x,$=_t(()=>{const j=k.current;!j||!K||(j.focus({preventScroll:!0}),j.setSelectionRange(j.value.length,j.value.length))},[K]);J(()=>$(),[$]),Cx(()=>{v.composer.getState().type==="thread"&&h&&$()}),J(()=>{if(!(v.composer.getState().type!=="thread"||!d))return v.on("thread.runStart",$)},[d,$,v]),J(()=>{if(!(v.composer.getState().type!=="thread"||!f))return v.on("threads.selectionChanged",$)},[f,$,v]),J(()=>{D===""&&(I==null||I.setMultiline(!1))},[D,I]);const U=KD(),C={name:"input",value:D,...m,...U,ref:R,disabled:x,onChange:Oe(s,j=>{if(!v.composer.getState().isEditing)return;const E=j.nativeEvent.isComposing===!0;M.current&&!E&&(M.current=!1);const q=E||M.current;if(Cm(()=>{v.composer.setText(j.target.value)}),q)return;const X=j.target.selectionStart??j.target.value.length;if(S)for(const V of S.getPlugins())V.setCursorPosition(X)}),onKeyDown:Oe(i,L),onCompositionStart:Oe(m.onCompositionStart,()=>{M.current=!0}),onCompositionEnd:Oe(m.onCompositionEnd,j=>{if(M.current=!1,!v.composer.getState().isEditing)return;const E=j.target;Cm(()=>{v.composer.setText(E.value)});const q=E.selectionStart??E.value.length;if(S)for(const X of S.getPlugins())X.setCursorPosition(q)}),onSelect:Oe(a,j=>{if(M.current)return;const E=j.target,q=E.selectionStart??E.value.length;if(S)for(const X of S.getPlugins())X.setCursorPosition(q)}),onPaste:Oe(o,z),...I?{onHeightChange:W}:_!==void 0?{onHeightChange:_}:{}};if(n&&Nl(n))return Rf(n,m.children,C);const Y=e?Cf:h4;return T.jsx(Y,{...C})});Ex.displayName="ComposerPrimitive.Input";const p4=()=>{const{disabled:t,cancel:e}=w3();return t?null:e},m4=Jr("ComposerPrimitive.Cancel",p4),g4=t=>{const e=O(6);let n;e[0]!==t?(n=t===void 0?{}:t,e[0]=t,e[1]=n):n=e[1];const{multiple:r}=n,s=r===void 0?!0:r,{disabled:i,addAttachment:o}=b3(),a=oe();let l;e[2]!==o||e[3]!==a.composer||e[4]!==s?(l=()=>{const c=document.createElement("input");c.type="file",c.multiple=s,c.hidden=!0;const d=a.composer.getState().attachmentAccept;d!=="*"&&(c.accept=d),document.body.appendChild(c),c.onchange=async h=>{const f=h.target.files;if(!f)return;const p=Array.from(f,async g=>{try{await o(g)}catch{}});document.body.removeChild(c),await Promise.all(p)},c.oncancel=()=>{(!c.files||c.files.length===0)&&document.body.removeChild(c)},c.click()},e[2]=o,e[3]=a.composer,e[4]=s,e[5]=l):l=e[5];const u=l;return i?null:u},y4=Jr("ComposerPrimitive.AddAttachment",g4,["multiple"]),Rx=Re(({disabled:t,asChild:e=!1,render:n,children:r,...s},i)=>{const[o,a]=ce(!1),l=oe(),u=_t(g=>{if(!t&&g.dataTransfer.types.includes("Files")){if(g.preventDefault(),!l.thread.getState().capabilities.attachments){g.dataTransfer.dropEffect="none";return}a(!0)}},[t,l]),c=_t(g=>{if(!t&&g.dataTransfer.types.includes("Files")){if(g.preventDefault(),!l.thread.getState().capabilities.attachments){g.dataTransfer.dropEffect="none";return}o||a(!0)}},[t,o,l]),d=_t(g=>{if(t)return;g.preventDefault();const _=g.relatedTarget;_&&g.currentTarget.contains(_)||a(!1)},[t]),h=_t(async g=>{if(t||(a(!1),!g.dataTransfer.types.includes("Files")))return;g.preventDefault();const _=Array.from(g.dataTransfer.files);!l.thread.getState().capabilities.attachments||_.length===0||await Promise.all(_.map(async m=>{try{await l.composer.addAttachment(m)}catch{}}))},[t,l]),f={...o?{"data-dragging":"true"}:null,...s,onDragEnterCapture:Oe(s.onDragEnterCapture,u),onDragOverCapture:Oe(s.onDragOverCapture,c),onDragLeaveCapture:Oe(s.onDragLeaveCapture,d),onDropCapture:Oe(s.onDropCapture,h),ref:i};if(n&&Nl(n))return Rf(n,r,f);const p=e?Cf:"div";return T.jsx(p,{...f,children:r})});Rx.displayName="ComposerPrimitive.AttachmentDropzone";const v4=()=>{const{disabled:t,startDictation:e}=x3();return t?null:e},_4=Jr("ComposerPrimitive.Dictate",v4),w4=()=>{const t=O(2),e=oe(),n=G(S4);let r;t[0]!==e.composer?(r=()=>{e.composer.stopDictation()},t[0]=e.composer,t[1]=r):r=t[1];const s=r;return n?s:null},x4=Jr("ComposerPrimitive.StopDictation",w4);function S4(t){return t.composer.dictation!=null}const Ax=Re((t,e)=>{const n=O(7);let r,s;n[0]!==t?({children:r,...s}=t,n[0]=t,n[1]=r,n[2]=s):(r=n[1],s=n[2]);const i=G(b4);if(!i)return null;const o=r??i;let a;return n[3]!==e||n[4]!==s||n[5]!==o?(a=T.jsx(ze.span,{...s,ref:e,children:o}),n[3]=e,n[4]=s,n[5]=o,n[6]=a):a=n[6],a});Ax.displayName="ComposerPrimitive.DictationTranscript";function b4(t){var e;return(e=t.composer.dictation)==null?void 0:e.transcript}const Px=Re((t,e)=>{const n=O(3);if(!G(T4))return null;let r;return n[0]!==e||n[1]!==t?(r=T.jsx(ze.div,{...t,ref:e}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});Px.displayName="ComposerPrimitive.Quote";const Mx=Re((t,e)=>{const n=O(7);let r,s;n[0]!==t?({children:r,...s}=t,n[0]=t,n[1]=r,n[2]=s):(r=n[1],s=n[2]);const i=G(k4);if(!i)return null;const o=r??i;let a;return n[3]!==e||n[4]!==s||n[5]!==o?(a=T.jsx(ze.span,{...s,ref:e,children:o}),n[3]=e,n[4]=s,n[5]=o,n[6]=a):a=n[6],a});Mx.displayName="ComposerPrimitive.QuoteText";const Dx=Re((t,e)=>{const n=O(12);let r,s;n[0]!==t?({onClick:r,...s}=t,n[0]=t,n[1]=r,n[2]=s):(r=n[1],s=n[2]);const i=oe();let o;n[3]!==i?(o=()=>{i.composer.setQuote(void 0)},n[3]=i,n[4]=o):o=n[4];const a=o;let l;n[5]!==a||n[6]!==r?(l=Oe(r,a),n[5]=a,n[6]=r,n[7]=l):l=n[7];let u;return n[8]!==e||n[9]!==s||n[10]!==l?(u=T.jsx(ze.button,{type:"button",...s,ref:e,onClick:l}),n[8]=e,n[9]=s,n[10]=l,n[11]=u):u=n[11],u});Dx.displayName="ComposerPrimitive.QuoteDismiss";function T4(t){return t.composer.quote}function k4(t){var e;return(e=t.composer.quote)==null?void 0:e.text}const Ox=Re((t,e)=>{const n=O(12);let r,s,i;n[0]!==t?({children:s,"aria-label":r,...i}=t,n[0]=t,n[1]=r,n[2]=s,n[3]=i):(r=n[1],s=n[2],i=n[3]);const{categories:o,activeCategoryId:a,isSearchMode:l,open:u}=Gs();if(!u||a||l)return null;const c=r??"Categories";let d;n[4]!==o||n[5]!==s?(d=s(o),n[4]=o,n[5]=s,n[6]=d):d=n[6];let h;return n[7]!==e||n[8]!==i||n[9]!==c||n[10]!==d?(h=T.jsx(ze.div,{role:"group","aria-label":c,...i,ref:e,children:d}),n[7]=e,n[8]=i,n[9]=c,n[10]=d,n[11]=h):h=n[11],h});Ox.displayName="ComposerPrimitive.TriggerPopoverCategories";const Nx=Re((t,e)=>{const n=O(30);let r,s,i,o;n[0]!==t?({categoryId:r,onClick:s,onMouseMove:i,...o}=t,n[0]=t,n[1]=r,n[2]=s,n[3]=i,n[4]=o):(r=n[1],s=n[2],i=n[3],o=n[4]);const{selectCategory:a,highlightIndex:l,categories:u,highlightedIndex:c,activeCategoryId:d,isSearchMode:h,popoverId:f}=Gs();let p;n[5]!==r||n[6]!==a?(p=()=>{a(r)},n[5]=r,n[6]=a,n[7]=p):p=n[7];const g=p;let _;if(n[8]!==u||n[9]!==r){let x;n[11]!==r?(x=k=>k.id===r,n[11]=r,n[12]=x):x=n[12],_=u.findIndex(x),n[8]=u,n[9]=r,n[10]=_}else _=n[10];const m=_,y=!d&&!h&&m===c;let v;n[13]!==m||n[14]!==l?(v=()=>{l(m)},n[13]=m,n[14]=l,n[15]=v):v=n[15];const S=v,I=`${f}-option-${r}`,b=y?"":void 0;let P;n[16]!==g||n[17]!==s?(P=Oe(s,g),n[16]=g,n[17]=s,n[18]=P):P=n[18];let A;n[19]!==S||n[20]!==i?(A=Oe(i,S),n[19]=S,n[20]=i,n[21]=A):A=n[21];let D;return n[22]!==e||n[23]!==y||n[24]!==o||n[25]!==I||n[26]!==b||n[27]!==P||n[28]!==A?(D=T.jsx(ze.button,{type:"button",role:"option",id:I,"aria-selected":y,"data-highlighted":b,...o,ref:e,onClick:P,onMouseMove:A}),n[22]=e,n[23]=y,n[24]=o,n[25]=I,n[26]=b,n[27]=P,n[28]=A,n[29]=D):D=n[29],D});Nx.displayName="ComposerPrimitive.TriggerPopoverCategoryItem";const Lx=Re((t,e)=>{const n=O(12);let r,s,i;n[0]!==t?({children:s,"aria-label":r,...i}=t,n[0]=t,n[1]=r,n[2]=s,n[3]=i):(r=n[1],s=n[2],i=n[3]);const{items:o,activeCategoryId:a,isSearchMode:l,open:u}=Gs();if(!u||!a&&!l)return null;const c=r??"Items";let d;n[4]!==s||n[5]!==o?(d=s(o),n[4]=s,n[5]=o,n[6]=d):d=n[6];let h;return n[7]!==e||n[8]!==i||n[9]!==c||n[10]!==d?(h=T.jsx(ze.div,{role:"group","aria-label":c,...i,ref:e,children:d}),n[7]=e,n[8]=i,n[9]=c,n[10]=d,n[11]=h):h=n[11],h});Lx.displayName="ComposerPrimitive.TriggerPopoverItems";const jx=Re((t,e)=>{const n=O(30);let r,s,i,o,a;n[0]!==t?({item:s,index:r,onClick:i,onMouseMove:o,...a}=t,n[0]=t,n[1]=r,n[2]=s,n[3]=i,n[4]=o,n[5]=a):(r=n[1],s=n[2],i=n[3],o=n[4],a=n[5]);const{selectItem:l,highlightIndex:u,items:c,highlightedIndex:d,activeCategoryId:h,isSearchMode:f,popoverId:p}=Gs();let g;n[6]!==s||n[7]!==l?(g=()=>{l(s)},n[6]=s,n[7]=l,n[8]=g):g=n[8];const _=g;let m;n[9]!==r||n[10]!==s.id||n[11]!==c?(m=r??c.findIndex(k=>k.id===s.id),n[9]=r,n[10]=s.id,n[11]=c,n[12]=m):m=n[12];const y=m,v=(f||h!==null)&&y===d;let S;n[13]!==u||n[14]!==y?(S=()=>{u(y)},n[13]=u,n[14]=y,n[15]=S):S=n[15];const I=S,b=`${p}-option-${s.id}`,P=v?"":void 0;let A;n[16]!==_||n[17]!==i?(A=Oe(i,_),n[16]=_,n[17]=i,n[18]=A):A=n[18];let D;n[19]!==I||n[20]!==o?(D=Oe(o,I),n[19]=I,n[20]=o,n[21]=D):D=n[21];let x;return n[22]!==e||n[23]!==v||n[24]!==a||n[25]!==b||n[26]!==P||n[27]!==A||n[28]!==D?(x=T.jsx(ze.button,{type:"button",role:"option",id:b,"aria-selected":v,"data-highlighted":P,...a,ref:e,onClick:A,onMouseMove:D}),n[22]=e,n[23]=v,n[24]=a,n[25]=b,n[26]=P,n[27]=A,n[28]=D,n[29]=x):x=n[29],x});jx.displayName="ComposerPrimitive.TriggerPopoverItem";const $x=Re((t,e)=>{const n=O(10);let r,s;n[0]!==t?({onClick:r,...s}=t,n[0]=t,n[1]=r,n[2]=s):(r=n[1],s=n[2]);const{activeCategoryId:i,isSearchMode:o,goBack:a,open:l}=Gs();if(!l||!i||o)return null;let u;n[3]!==a||n[4]!==r?(u=Oe(r,a),n[3]=a,n[4]=r,n[5]=u):u=n[5];let c;return n[6]!==e||n[7]!==s||n[8]!==u?(c=T.jsx(ze.button,{type:"button",...s,ref:e,onClick:u}),n[6]=e,n[7]=s,n[8]=u,n[9]=c):c=n[9],c});$x.displayName="ComposerPrimitive.TriggerPopoverBack";const zx=t=>{const e=O(8),{formatter:n,onExecute:r,removeOnExecute:s}=t,{register:i}=wx(),o=te(r);let a,l;e[0]!==r?(a=()=>{o.current=r},l=[r],e[0]=r,e[1]=a,e[2]=l):(a=e[1],l=e[2]),Qr(a,l);let u,c;return e[3]!==n||e[4]!==i||e[5]!==s?(u=()=>{const d={kind:"action",formatter:n??ex,onExecute:h=>o.current(h),...s!==void 0?{removeOnExecute:s}:{}};return i(d)},c=[i,n,s],e[3]=n,e[4]=i,e[5]=s,e[6]=u,e[7]=c):(u=e[6],c=e[7]),J(u,c),null};zx.displayName="ComposerPrimitive.TriggerPopoverAction";const Fx=t=>{const e=O(7),{formatter:n,onInserted:r}=t,{register:s}=wx(),i=te(r);let o,a;e[0]!==r?(o=()=>{i.current=r},a=[r],e[0]=r,e[1]=o,e[2]=a):(o=e[1],a=e[2]),Qr(o,a);let l,u;return e[3]!==n||e[4]!==s?(l=()=>s({kind:"directive",formatter:n??ex,onInserted:c=>{var d;return(d=i.current)==null?void 0:d.call(i,c)}}),u=[s,n],e[3]=n,e[4]=s,e[5]=l,e[6]=u):(l=e[5],u=e[6]),J(l,u),null};Fx.displayName="ComposerPrimitive.TriggerPopoverDirective";const C4=Object.assign(xx,{Directive:Fx,Action:zx});var ta=Ef({AddAttachment:()=>y4,AttachmentByIndex:()=>H1,AttachmentDropzone:()=>Rx,Attachments:()=>q1,Cancel:()=>m4,Dictate:()=>_4,DictationTranscript:()=>Ax,If:()=>Y1,Input:()=>Ex,Queue:()=>G1,Quote:()=>Px,QuoteDismiss:()=>Dx,QuoteText:()=>Mx,Root:()=>kx,Send:()=>jD,StopDictation:()=>x4,Unstable_TriggerPopover:()=>C4,Unstable_TriggerPopoverBack:()=>$x,Unstable_TriggerPopoverCategories:()=>Ox,Unstable_TriggerPopoverCategoryItem:()=>Nx,Unstable_TriggerPopoverItem:()=>jx,Unstable_TriggerPopoverItems:()=>Lx,Unstable_TriggerPopoverRoot:()=>vx,unstable_useTriggerPopoverRootContext:()=>Mf,unstable_useTriggerPopoverRootContextOptional:()=>Df,unstable_useTriggerPopoverScopeContext:()=>Gs,unstable_useTriggerPopoverScopeContextOptional:()=>ND,unstable_useTriggerPopoverTriggers:()=>yD,unstable_useTriggerPopoverTriggersOptional:()=>_D});const I4=Object.freeze({type:"complete"}),E4=Object.freeze({type:"text",text:"",status:I4}),Lf=()=>G(R4);function R4(t){return t.part.type!=="text"&&t.part.type!=="reasoning"?E4:t.part}const A4=Rt(null);function P4(t){const e=At(A4);if(!(t!=null&&t.optional)&&!e)throw new Error("This component must be used within a SmoothContextProvider.");return e}const{useSmoothStatus:t6,useSmoothStatusStore:M4}=J1(P4,"useSmoothStatus"),Bx=250,Ux=5;var D4=class{constructor(t,e){w(this,"animationFrameId",null);w(this,"lastUpdateTime",Date.now());w(this,"lastCommitTime",0);w(this,"targetText","");w(this,"drainMs",Bx);w(this,"maxCharIntervalMs",Ux);w(this,"maxCharsPerFrame",1/0);w(this,"minCommitMs",0);w(this,"currentText");w(this,"setText");w(this,"animate",()=>{const t=Date.now();let e=t-this.lastUpdateTime;const n=this.targetText.length-this.currentText.length,r=Math.min(this.maxCharIntervalMs,this.drainMs/n),s=Math.min(n,this.maxCharsPerFrame);let i=0;for(;e>=r&&i<s;)i++,e-=r;i===s&&s===this.maxCharsPerFrame&&(e=0),i!==n?this.animationFrameId=requestAnimationFrame(this.animate):this.animationFrameId=null,i!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+i),this.lastUpdateTime=t-e,(i===n||t-this.lastCommitTime>=this.minCommitMs)&&(this.lastCommitTime=t,this.setText(this.currentText)))});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)}};const Wu=Object.freeze({type:"running"}),na=(t,e)=>t!==void 0&&t>0?t:e,jf=(t,e=!1)=>{const{text:n}=t,r=Ix("(prefers-reduced-motion: reduce)"),s=typeof e=="object"&&e!==null?e:void 0,i=e!==!1&&e!==null&&!r,o=na(s==null?void 0:s.drainMs,Bx),a=na(s==null?void 0:s.maxCharIntervalMs,Ux),l=na(s==null?void 0:s.maxCharsPerFrame,1/0),u=na(s==null?void 0:s.minCommitMs,0),[c,d]=ce(t.status.type==="running"?"":n),h=oe(),f=G(()=>h.part),[p,g]=ce(f);(f!==p||!n.startsWith(c))&&(g(f),d(t.status.type==="running"?"":n));const _=M4({optional:!0}),m=ko(S=>{if(d(S),_){const I=c!==S||t.status.type==="running"?Wu:t.status;al(_).setState(I,!0)}});J(()=>{if(_){const S=i&&(c!==n||t.status.type==="running")?Wu:t.status;al(_).setState(S,!0)}},[_,i,n,c,t.status]);const[y]=ce(new D4(c,m));J(()=>{y.drainMs=o,y.maxCharIntervalMs=a,y.maxCharsPerFrame=l,y.minCommitMs=u},[y,o,a,l,u]);const v=te(f);return J(()=>{if(!i){y.stop();return}const S=v.current!==f;if(v.current=f,S||!n.startsWith(y.targetText)){t.status.type==="running"?(y.currentText="",y.targetText=n,y.lastCommitTime=0,y.start()):(y.currentText=n,y.targetText=n,y.stop(),m(n));return}if(y.targetText=n,t.status.type!=="running"){if(y.currentText===""){y.currentText=n,y.stop(),m(n);return}y.start();return}y.start()},[y,i,n,t.status.type,f,m]),J(()=>()=>{y.stop()},[y]),ge(()=>i?{...t,text:c,status:n===c?t.status:Wu}:t,[i,c,t,n])},O4=Object.freeze({type:"complete"}),N4=Object.freeze({type:"image",image:"",status:O4}),L4=()=>G(j4);function j4(t){return t.part.type!=="image"?N4:t.part}const $f=Re(({smooth:t=!0,component:e=ze.span,render:n,...r},s)=>{const{text:i,status:o}=jf(Lf(),t),a={"data-status":o.type,...r,ref:s};return n&&Nl(n)?Rf(n,i,a):T.jsx(e,{...a,children:i})});$f.displayName="MessagePartPrimitive.Text";const zf=Re((t,e)=>{const n=O(4),{image:r}=L4();let s;return n[0]!==e||n[1]!==r||n[2]!==t?(s=T.jsx(ze.img,{src:r,...t,ref:e}),n[0]=e,n[1]=r,n[2]=t,n[3]=s):s=n[3],s});zf.displayName="MessagePartPrimitive.Image";const Xr=t=>{const e=O(2),n=te(void 0);let r;return e[0]!==t?(r=s=>{n.current&&(n.current(),n.current=void 0),s&&(n.current=t(s))},e[0]=t,e[1]=r):r=e[1],r},Yg=(t,e)=>{const n=t.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(em|px|rem)$/);if(!n)return Number.POSITIVE_INFINITY;const r=Number(n[1]),s=n[2];return s==="px"?r:s==="em"?r*(parseFloat(getComputedStyle(e).fontSize)||16):s==="rem"?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):Number.POSITIVE_INFINITY},$4=t=>t.dataset.messageId,z4=()=>{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},Qu=(t,e)=>{const n=`${e}px`;return t.style.height!==n?(t.style.height=n,!0):!1},F4=t=>{const e=window.devicePixelRatio||1;return Math.round(t*e)/e},Vx=()=>{const t=O(4),e=oe();let n;t[0]!==e.message?(n=()=>e.message,t[0]=e.message,t[1]=n):n=t[1];const r=G(n);let s;return t[2]!==r?(s=i=>{const o=()=>{r.setIsHovering(!0)},a=()=>{r.setIsHovering(!1)};return i.addEventListener("mouseenter",o),i.addEventListener("mouseleave",a),i.matches(":hover")&&queueMicrotask(()=>r.setIsHovering(!0)),()=>{i.removeEventListener("mouseenter",o),i.removeEventListener("mouseleave",a),r.setIsHovering(!1)}},t[2]=r,t[3]=s):s=t[3],Xr(s)},B4=()=>{const t=O(2),e=hr(W4);let n;return t[0]!==e?(n=r=>{var s;return r.message.role==="user"&&r.message.index>0&&r.message.index===r.thread.messages.length-2&&((s=r.thread.messages.at(-1))==null?void 0:s.role)==="assistant"&&(r.message.id===e||r.thread.isRunning)},t[0]=e,t[1]=n):n=t[1],G(n)},U4=()=>{const t=O(2),e=hr(Q4);let n;return t[0]!==e?(n=r=>{var s;return r.message.isLast&&r.message.role==="assistant"&&r.message.index>=1&&((s=r.thread.messages.at(r.message.index-1))==null?void 0:s.role)==="user"&&(r.message.id===e||r.thread.isRunning)},t[0]=e,t[1]=n):n=t[1],G(n)},V4=(t,e)=>{const n=O(3);let r;return n[0]!==t||n[1]!==e?(r=s=>{if(t)return e.getState().registerAnchorElement(s)},n[0]=t,n[1]=e,n[2]=r):r=n[2],Xr(r)},H4=t=>{const e=O(3),{active:n,threadViewportStore:r}=t;let s;return e[0]!==n||e[1]!==r?(s=i=>{if(!n)return;const o=r.getState(),a=o.topAnchorMessageClamp;return o.registerAnchorTargetElement(i,{tallerThan:Yg(a.tallerThan,i),visibleHeight:Yg(a.visibleHeight,i)})},e[0]=n,e[1]=r,e[2]=s):s=e[2],Xr(s)},q4=t=>{const e=O(7);let n,r;e[0]!==t?({forwardedRef:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const s=Vx(),i=fr(n,s),o=G(K4);let a;return e[3]!==o||e[4]!==r||e[5]!==i?(a=T.jsx(ze.div,{...r,ref:i,"data-message-id":o}),e[3]=o,e[4]=r,e[5]=i,e[6]=a):a=e[6],a},G4=t=>{const e=O(13);let n,r,s;e[0]!==t?({forwardedRef:n,threadViewportStore:s,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=s):(n=e[1],r=e[2],s=e[3]);const i=Vx(),o=B4(),a=U4(),l=V4(o,s);let u;e[4]!==a||e[5]!==s?(u={active:a,threadViewportStore:s},e[4]=a,e[5]=s,e[6]=u):u=e[6];const c=H4(u),d=fr(n,i,l,c),h=G(Y4),f=o?"":void 0,p=a?"":void 0;let g;return e[7]!==h||e[8]!==r||e[9]!==d||e[10]!==f||e[11]!==p?(g=T.jsx(ze.div,{...r,ref:d,"data-message-id":h,"data-aui-top-anchor-user":f,"data-aui-top-anchor-target":p}),e[7]=h,e[8]=r,e[9]=d,e[10]=f,e[11]=p,e[12]=g):g=e[12],g},Hx=Re((t,e)=>{const n=O(7),r=Yr();if(r.getState().turnAnchor==="top"){let i;return n[0]!==e||n[1]!==t||n[2]!==r?(i=T.jsx(G4,{...t,forwardedRef:e,threadViewportStore:r}),n[0]=e,n[1]=t,n[2]=r,n[3]=i):i=n[3],i}let s;return n[4]!==e||n[5]!==t?(s=T.jsx(q4,{...t,forwardedRef:e}),n[4]=e,n[5]=t,n[6]=s):s=n[6],s});Hx.displayName="MessagePrimitive.Root";function W4(t){var e;return(e=t.topAnchorTurn)==null?void 0:e.anchorId}function Q4(t){var e;return(e=t.topAnchorTurn)==null?void 0:e.targetId}function K4(t){return t.message.id}function Y4(t){return t.message.id}const Ku={...gn,Text:()=>T.jsxs("p",{style:{whiteSpace:"pre-line"},children:[T.jsx($f,{}),T.jsx(Sf,{children:T.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Image:()=>T.jsx(zf,{})},Ed=t=>{const e=O(10);if("children"in t){let a;return e[0]!==t.children?(a=T.jsx(Sd,{children:t.children}),e[0]=t.children,e[1]=a):a=e[1],a}let n,r;e[2]!==t?({components:n,...r}=t,e[2]=t,e[3]=n,e[4]=r):(n=e[3],r=e[4]);let s;e[5]!==n?(s=n?{...n,Text:n.Text??Ku.Text,Image:n.Image??Ku.Image}:Ku,e[5]=n,e[6]=s):s=e[6];const i=s;let o;return e[7]!==r||e[8]!==i?(o=T.jsx(Sd,{components:i,...r}),e[7]=r,e[8]=i,e[9]=o):o=e[9],o};Ed.displayName="MessagePrimitive.Parts";const J4=t=>{const e=O(12);let n;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?(n=r=>{var h;const{role:s,attachments:i,parts:o,branchCount:a,isLast:l,speech:u,isCopied:c,isHovering:d}=r.message;return!(t.hasBranches===!0&&a<2||t.user&&s!=="user"||t.assistant&&s!=="assistant"||t.system&&s!=="system"||t.lastOrHover===!0&&!d&&!l||t.last!==void 0&&t.last!==l||t.copied===!0&&!c||t.copied===!1&&c||t.speaking===!0&&u==null||t.speaking===!1&&u!=null||t.hasAttachments===!0&&(s!=="user"||!(i!=null&&i.length))||t.hasAttachments===!1&&s==="user"&&(i!=null&&i.length)||t.hasContent===!0&&o.length===0||t.hasContent===!1&&o.length>0||t.submittedFeedback!==void 0&&(((h=r.message.metadata.submittedFeedback)==null?void 0:h.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]=n):n=e[11],G(n)},qx=t=>{const e=O(3);let n,r;return e[0]!==t?({children:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),J4(r)?n:null};qx.displayName="MessagePrimitive.If";const Gx=t=>{const{children:e}=t;return I3()!==void 0?e:null};Gx.displayName="MessagePrimitive.Error";const X4=t=>{var r;const e=new Map;for(let s=0;s<t.length;s++){const i=((r=t[s])==null?void 0:r.parentId)??s,o=e.get(i)??[];o.push(s),e.set(i,o)}const n=[];for(const[s,i]of e){const o=typeof s=="string"?s:void 0;n.push({groupKey:o,indices:i})}return n},Z4=t=>{const e=O(4),n=G(uO);let r;e:{if(n.length===0){let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0],r=i;break e}let s;e[1]!==t||e[2]!==n?(s=t(n),e[1]=t,e[2]=n,e[3]=s):s=e[3],r=s}return r},eO=t=>{const e=O(9);let n,r;e[0]!==t?({Fallback:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let s;e[3]!==n||e[4]!==r.toolName?(s=a=>{var l,u;return((u=(l=a.tools.toolUIs[r.toolName])==null?void 0:l[0])==null?void 0:u.render)??n},e[3]=n,e[4]=r.toolName,e[5]=s):s=e[5];const i=G(s);if(!i)return null;let o;return e[6]!==i||e[7]!==r?(o=T.jsx(i,{...r}),e[6]=i,e[7]=r,e[8]=o):o=e[8],o},tO=t=>{const e=O(9);let n,r;e[0]!==t?({Fallback:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let s;e[3]!==n||e[4]!==r.name?(s=a=>{const l=a.dataRenderers.renderers[r.name]??n;return Array.isArray(l)?l[0]??n:l},e[3]=n,e[4]=r.name,e[5]=s):s=e[5];const i=G(s);if(!i)return null;let o;return e[6]!==i||e[7]!==r?(o=T.jsx(i,{...r}),e[6]=i,e[7]=r,e[8]=o):o=e[8],o},qn={Text:()=>T.jsxs("p",{style:{whiteSpace:"pre-line"},children:[T.jsx($f,{}),T.jsx(Sf,{children:T.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>T.jsx(zf,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:t})=>t},nO=t=>{var P,A,D;const e=O(37),{components:n}=t;let r;e[0]!==n?(r=n===void 0?{}:n,e[0]=n,e[1]=r):r=e[1];const{Text:s,Reasoning:i,Image:o,Source:a,File:l,Unstable_Audio:u,tools:c,data:d}=r,h=s===void 0?qn.Text:s,f=i===void 0?qn.Reasoning:i,p=o===void 0?qn.Image:o,g=a===void 0?qn.Source:a,_=l===void 0?qn.File:l,m=u===void 0?qn.Unstable_Audio:u;let y;e[2]!==c?(y=c===void 0?{}:c,e[2]=c,e[3]=y):y=e[3];const v=y,S=oe(),I=G(cO),b=I.type;if(b==="tool-call"){const x=S.part.addToolResult,k=S.part.resumeToolCall,R=S.part.respondToToolApproval;if("Override"in v){let z;return e[4]!==x||e[5]!==I||e[6]!==R||e[7]!==k||e[8]!==v.Override?(z=T.jsx(v.Override,{...I,addResult:x,resume:k,respondToApproval:R}),e[4]=x,e[5]=I,e[6]=R,e[7]=k,e[8]=v.Override,e[9]=z):z=e[9],z}const M=((P=v.by_name)==null?void 0:P[I.toolName])??v.Fallback;let L;return e[10]!==M||e[11]!==x||e[12]!==I||e[13]!==R||e[14]!==k?(L=T.jsx(eO,{...I,Fallback:M,addResult:x,resume:k,respondToApproval:R}),e[10]=M,e[11]=x,e[12]=I,e[13]=R,e[14]=k,e[15]=L):L=e[15],L}if(((A=I.status)==null?void 0:A.type)==="requires-action")throw new Error("Encountered unexpected requires-action status");switch(b){case"text":{let x;return e[16]!==h||e[17]!==I?(x=T.jsx(h,{...I}),e[16]=h,e[17]=I,e[18]=x):x=e[18],x}case"reasoning":{let x;return e[19]!==f||e[20]!==I?(x=T.jsx(f,{...I}),e[19]=f,e[20]=I,e[21]=x):x=e[21],x}case"source":{let x;return e[22]!==g||e[23]!==I?(x=T.jsx(g,{...I}),e[22]=g,e[23]=I,e[24]=x):x=e[24],x}case"image":{let x;return e[25]!==p||e[26]!==I?(x=T.jsx(p,{...I}),e[25]=p,e[26]=I,e[27]=x):x=e[27],x}case"file":{let x;return e[28]!==_||e[29]!==I?(x=T.jsx(_,{...I}),e[28]=_,e[29]=I,e[30]=x):x=e[30],x}case"audio":{let x;return e[31]!==m||e[32]!==I?(x=T.jsx(m,{...I}),e[31]=m,e[32]=I,e[33]=x):x=e[33],x}case"data":{const x=((D=d==null?void 0:d.by_name)==null?void 0:D[I.name])??(d==null?void 0:d.Fallback);let k;return e[34]!==x||e[35]!==I?(k=T.jsx(tO,{...I,Fallback:x}),e[34]=x,e[35]=I,e[36]=k):k=e[36],k}default:return console.warn(`Unknown message part type: ${b}`),null}},rO=t=>{const e=O(5),{partIndex:n,components:r}=t;let s;e[0]!==r?(s=T.jsx(nO,{components:r}),e[0]=r,e[1]=s):s=e[1];let i;return e[2]!==n||e[3]!==s?(i=T.jsx(lf,{index:n,children:s}),e[2]=n,e[3]=s,e[4]=i):i=e[4],i},sO=Ue(rO,(t,e)=>{var n,r,s,i,o,a,l,u,c,d,h,f,p,g,_,m,y,v;return t.partIndex===e.partIndex&&((n=t.components)==null?void 0:n.Text)===((r=e.components)==null?void 0:r.Text)&&((s=t.components)==null?void 0:s.Reasoning)===((i=e.components)==null?void 0:i.Reasoning)&&((o=t.components)==null?void 0:o.Source)===((a=e.components)==null?void 0:a.Source)&&((l=t.components)==null?void 0:l.Image)===((u=e.components)==null?void 0:u.Image)&&((c=t.components)==null?void 0:c.File)===((d=e.components)==null?void 0:d.File)&&((h=t.components)==null?void 0:h.Unstable_Audio)===((f=e.components)==null?void 0:f.Unstable_Audio)&&((p=t.components)==null?void 0:p.tools)===((g=e.components)==null?void 0:g.tools)&&((_=t.components)==null?void 0:_.data)===((m=e.components)==null?void 0:m.data)&&((y=t.components)==null?void 0:y.Group)===((v=e.components)==null?void 0:v.Group)}),iO=t=>{const e=O(6),{status:n,component:r}=t,s=n.type==="running";let i;e[0]!==r||e[1]!==n?(i=T.jsx(r,{type:"text",text:"",status:n}),e[0]=r,e[1]=n,e[2]=i):i=e[2];let o;return e[3]!==s||e[4]!==i?(o=T.jsx(uf,{text:"",isRunning:s,children:i}),e[3]=s,e[4]=i,e[5]=o):o=e[5],o},oO=Object.freeze({type:"complete"}),aO=t=>{const e=O(6),{components:n}=t,r=G(dO);if(n!=null&&n.Empty){let o;return e[0]!==n.Empty||e[1]!==r?(o=T.jsx(n.Empty,{status:r}),e[0]=n.Empty,e[1]=r,e[2]=o):o=e[2],o}const s=(n==null?void 0:n.Text)??qn.Text;let i;return e[3]!==r||e[4]!==s?(i=T.jsx(iO,{status:r,component:s}),e[3]=r,e[4]=s,e[5]=i):i=e[5],i},lO=Ue(aO,(t,e)=>{var n,r,s,i;return((n=t.components)==null?void 0:n.Empty)===((r=e.components)==null?void 0:r.Empty)&&((s=t.components)==null?void 0:s.Text)===((i=e.components)==null?void 0:i.Text)}),Ff=t=>{const e=O(9),{groupingFunction:n,components:r}=t,s=G(hO),i=Z4(n);let o;e:{if(s===0){let c;e[0]!==r?(c=T.jsx(lO,{components:r}),e[0]=r,e[1]=c):c=e[1],o=c;break e}let u;if(e[2]!==r||e[3]!==i){let c;e[5]!==r?(c=(d,h)=>{const f=(r==null?void 0:r.Group)??qn.Group;return T.jsx(f,{groupKey:d.groupKey,indices:d.indices,children:d.indices.map(p=>T.jsx(sO,{partIndex:p,components:r},p))},`group-${h}-${d.groupKey??"ungrouped"}`)},e[5]=r,e[6]=c):c=e[6],u=i.map(c),e[2]=r,e[3]=i,e[4]=u}else u=e[4];o=u}const a=o;let l;return e[7]!==a?(l=T.jsx(T.Fragment,{children:a}),e[7]=a,e[8]=l):l=e[8],l};Ff.displayName="MessagePrimitive.Unstable_PartsGrouped";const Wx=t=>{const e=O(6);let n,r;e[0]!==t?({components:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let s;return e[3]!==n||e[4]!==r?(s=T.jsx(Ff,{...r,components:n,groupingFunction:X4}),e[3]=n,e[4]=r,e[5]=s):s=e[5],s};Wx.displayName="MessagePrimitive.Unstable_PartsGroupedByParentId";function uO(t){return t.message.parts}function cO(t){return t.part}function dO(t){return t.message.status??oO}function hO(t){return t.message.parts.length}var Mr=Ef({AttachmentByIndex:()=>B1,Attachments:()=>U1,Content:()=>Ed,Error:()=>Gx,GenerativeUI:()=>R1,GroupedParts:()=>$1,If:()=>qx,PartByIndex:()=>Ri,Parts:()=>Ed,Quote:()=>z1,Root:()=>Hx,Unstable_PartsGrouped:()=>Ff,Unstable_PartsGroupedByParentId:()=>Wx});const fO=t=>{const e=O(2),n=ko(t);let r;return e[0]!==n?(r=s=>{const i=new ResizeObserver(()=>{n()}),o=new MutationObserver(a=>{a.some(pO)&&n()});return i.observe(s),o.observe(s,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{i.disconnect(),o.disconnect()}},e[0]=n,e[1]=r):r=e[1],Xr(r)};function pO(t){return t.type!=="attributes"||t.attributeName!=="style"}const mO=({autoScroll:t,scrollToBottomOnRunStart:e=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{const s=te(null),i=G(A=>A.thread.messages.length>0),o=G(A=>A.thread.isRunning),a=te(!1),l=te(null),u=Yr();t===void 0&&(t=u.getState().turnAnchor!=="top");const c=te(0),d=te(0),h=te(0),f=te(0),p=te(null),g=te(t),_=te(t);rn(()=>{const A=_.current;if(_.current=t,A||!t)return;const D=s.current;g.current=D!==null&&Lm(D)},[t]);const m=_t(A=>{const D=s.current;D&&(g.current=!0,p.current=A,D.scrollTo({top:D.scrollHeight,behavior:A}))},[]),y=_t(()=>{l.current!==null&&(cancelAnimationFrame(l.current),l.current=null)},[]),v=_t(A=>{p.current=A,y(),l.current=requestAnimationFrame(()=>{l.current=null,m(A)})},[y,m]);rn(()=>()=>y(),[y]);const S=_t(()=>{const A=u.getState();return A.turnAnchor==="top"&&A.element.viewport===s.current&&A.element.anchor!==null},[u]),I=()=>{const A=s.current;if(!A)return;const D=u.getState().isAtBottom,x=Lm(A);if(!(!x&&c.current<A.scrollTop)){const k=DI({scrollTop:c.current,scrollHeight:d.current},A);x?(MI(A)&&(p.current=null),t&&(g.current=!0)):k&&(y(),p.current=null,g.current=!1),(x||p.current===null)&&x!==D&&al(u).setState({isAtBottom:x})}c.current=A.scrollTop,d.current=A.scrollHeight},b=fO(()=>{const A=s.current;if(!A)return;const{scrollHeight:D,clientHeight:x}=A;if(D===h.current&&x===f.current)return;h.current=D,f.current=x;const k=p.current;k&&S()?p.current=null:k?m(k):t&&!(o&&S())&&g.current&&m("instant"),I()}),P=Xr(A=>{const D=()=>{p.current=null};return A.addEventListener("scroll",I),A.addEventListener("pointerdown",D),()=>{A.removeEventListener("scroll",I),A.removeEventListener("pointerdown",D)}});return rn(()=>{if(n){if(!i){a.current=!1;return}a.current||(a.current=!0,p.current===null&&v("instant"))}},[i,v,n]),Cx(({behavior:A})=>{m(A)}),$m("thread.runStart",()=>{e&&u.getState().turnAnchor!=="top"&&v("auto")}),$m("threads.selectionChanged",()=>{r&&v("instant")}),fr(b,P,s)},Qx=Re((t,e)=>{const n=O(6),r=oe();let s,i;n[0]!==r?(s=()=>{const a=l=>{if(l.key==="Escape"&&!(l.defaultPrevented||r.thread.source===null)&&r.thread.getState().speech!=null){l.preventDefault();try{r.thread.stopSpeaking()}catch(u){const c=u;if(!(c instanceof Error)||c.message!=="No message is being spoken")throw c}}};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}},i=[r],n[0]=r,n[1]=s,n[2]=i):(s=n[1],i=n[2]),J(s,i);let o;return n[3]!==t||n[4]!==e?(o=T.jsx(ze.div,{...t,ref:e}),n[3]=t,n[4]=e,n[5]=o):o=n[5],o});Qx.displayName="ThreadPrimitive.Root";const Kx=t=>{const{children:e}=t;return G(gO)?e:null};Kx.displayName="ThreadPrimitive.Empty";function gO(t){return t.thread.isEmpty}const yO=t=>{const e=O(4);let n;return e[0]!==t.disabled||e[1]!==t.empty||e[2]!==t.running?(n=r=>!(t.empty===!0&&!r.thread.isEmpty||t.empty===!1&&r.thread.isEmpty||t.running===!0&&!r.thread.isRunning||t.running===!1&&r.thread.isRunning||t.disabled===!0&&!r.thread.isDisabled||t.disabled===!1&&r.thread.isDisabled),e[0]=t.disabled,e[1]=t.empty,e[2]=t.running,e[3]=n):n=e[3],G(n)},Yx=t=>{const e=O(3);let n,r;return e[0]!==t?({children:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),yO(r)?n:null};Yx.displayName="ThreadPrimitive.If";const Jx=(t,e)=>{const n=O(3);let r;return n[0]!==e||n[1]!==t?(r=s=>{if(!t)return;const i=t(),o=()=>{const l=e?e(s):s.offsetHeight;i.setHeight(l)},a=new ResizeObserver(o);return a.observe(s),o(),()=>{a.disconnect(),i.unregister()}},n[0]=e,n[1]=t,n[2]=r):r=n[2],Xr(r)},Jg=t=>{let e=0,n=t;for(;n;)e+=n.offsetTop,n=n.offsetParent;return e},vO=(t,e)=>{let n=0,r=t;for(;r&&r!==e;)n+=r.offsetTop,r=r.offsetParent;return r===e?n:Jg(t)-Jg(e)},Xx=({viewport:t,anchor:e,tallerThan:n,visibleHeight:r})=>{const s=vO(e,t),i=e.offsetHeight;return s+Math.max(0,i-(i<=n?i:r))},_O=({scrollHeight:t,...e})=>{const{viewport:n}=e,r=Xx(e)+n.clientHeight;return Math.max(0,r-t)},wO=({viewport:t,reserve:e,...n})=>_O({viewport:t,...n,scrollHeight:t.scrollHeight-e.offsetHeight}),xO=t=>{const e=new ResizeObserver(t),n=new MutationObserver(t);let r=null,s=null,i=null;const o=()=>{e.disconnect(),n.disconnect(),r=null,s=null,i=null};return{target:(a,l,u)=>{r===a&&s===l&&i===u||(o(),e.observe(a),e.observe(l),e.observe(u),n.observe(u,{childList:!0,subtree:!0,characterData:!0}),r=a,s=l,i=u)},disconnect:o}},SO=t=>{let e=null;return{schedule:()=>{e===null&&(e=requestAnimationFrame(()=>{e=null,t()}))},cancel:()=>{e!==null&&(cancelAnimationFrame(e),e=null)}}},bO=t=>{let e=null,n;function r(){const a=t.getState(),{viewport:l,anchor:u,target:c}=a.element,d=a.targetConfig;if(a.turnAnchor!=="top"||!l){i.disconnect(),e&&(Qu(e,0),e.remove());return}if(!u&&!c&&!d&&a.topAnchorTurn){i.disconnect(),e!=null&&e.parentElement&&e.parentElement.lastElementChild!==e&&e.parentElement.append(e);return}if(!u||!c||!d){i.disconnect(),e&&(Qu(e,0),e.remove());return}if(e??(e=z4()),(e.parentElement!==c.parentElement||e.previousElementSibling!==c)&&c.after(e),i.target(l,u,c),Qu(e,wO({viewport:l,anchor:u,reserve:e,...d}))){s.schedule();return}const h=$4(u);if(h!==void 0&&n===h)return;const f=F4(Xx({viewport:l,anchor:u,...d}));Math.abs(l.scrollTop-f)>1&&l.scrollTo({top:f,behavior:"smooth"}),h!==void 0&&(n=h)}const s=SO(r),i=xO(s.schedule);s.schedule();const o=t.subscribe(s.schedule);return()=>{s.cancel(),o(),i.disconnect(),e==null||e.remove()}},TO=t=>{const e=O(4),n=Yr();let r,s;e[0]!==t||e[1]!==n?(r=()=>{if(t)return bO(n)},s=[t,n],e[0]=t,e[1]=n,e[2]=r,e[3]=s):(r=e[2],s=e[3]),rn(r,s)},kO=(t,e)=>{var r;if(!t)return!1;const n=e.findIndex(s=>s.id===t.targetId);return n<1?!1:((r=e[n-1])==null?void 0:r.id)===t.anchorId&&e.slice(n+1).every(s=>s.role==="user")},Zx=({isRunning:t,messages:e})=>{if(!t)return null;const n=e.at(-1),r=e.at(-2);return(r==null?void 0:r.role)!=="user"||(n==null?void 0:n.role)!=="assistant"?null:{anchorId:r.id,targetId:n.id}},CO=t=>{var e;return(e=Zx(t))==null?void 0:e.anchorId},IO=t=>{var e;return(e=Zx(t))==null?void 0:e.targetId},EO=()=>{const t=hr(PO);return Jx(t,MO)},RO=()=>{const t=hr(DO);return Xr(t)},AO=t=>{const e=O(19),n=Yr();let r;e[0]!==t?(r=_=>{if(t)return CO(_.thread)},e[0]=t,e[1]=r):r=e[1];const s=G(r);let i;e[2]!==t?(i=_=>{if(t)return IO(_.thread)},e[2]=t,e[3]=i):i=e[3];const o=G(i),a=hr(OO);let l;e:{if(!s||!o){l=null;break e}let _;e[4]!==s||e[5]!==o?(_={anchorId:s,targetId:o},e[4]=s,e[5]=o,e[6]=_):_=e[6],l=_}const u=l;let c;e[7]!==t||e[8]!==a?(c=_=>t&&!!a&&kO(a,_.thread.messages),e[7]=t,e[8]=a,e[9]=c):c=e[9];const d=G(c);let h,f;e[10]!==n||e[11]!==a||e[12]!==d?(h=()=>{!a||d||n.getState().setTopAnchorTurn(null)},f=[n,a,d],e[10]=n,e[11]=a,e[12]=d,e[13]=h,e[14]=f):(h=e[13],f=e[14]),rn(h,f);let p,g;e[15]!==u||e[16]!==n?(p=()=>{if(!u)return;const _=n.getState(),m=_.topAnchorTurn;(m==null?void 0:m.anchorId)===u.anchorId&&m.targetId===u.targetId||_.setTopAnchorTurn(u)},g=[u,n],e[15]=u,e[16]=n,e[17]=p,e[18]=g):(p=e[17],g=e[18]),rn(p,g)},eS=Re((t,e)=>{const n=O(18);let r,s,i,o,a,l;n[0]!==t?({autoScroll:r,scrollToBottomOnRunStart:a,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:l,children:s,...i}=t,n[0]=t,n[1]=r,n[2]=s,n[3]=i,n[4]=o,n[5]=a,n[6]=l):(r=n[1],s=n[2],i=n[3],o=n[4],a=n[5],l=n[6]);let u;n[7]!==r||n[8]!==o||n[9]!==a||n[10]!==l?(u={autoScroll:r,scrollToBottomOnRunStart:a,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:l},n[7]=r,n[8]=o,n[9]=a,n[10]=l,n[11]=u):u=n[11];const c=mO(u),d=EO(),h=RO(),f=Yr();let p;n[12]!==f?(p=f.getState(),n[12]=f,n[13]=p):p=n[13];const g=p.turnAnchor==="top";AO(g),TO(g);const _=fr(e,c,d,h);let m;return n[14]!==s||n[15]!==_||n[16]!==i?(m=T.jsx(ze.div,{...i,ref:_,children:s}),n[14]=s,n[15]=_,n[16]=i,n[17]=m):m=n[17],m});eS.displayName="ThreadPrimitive.ViewportScrollable";const tS=Re((t,e)=>{const n=O(13);let r,s,i;n[0]!==t?({turnAnchor:i,topAnchorMessageClamp:s,...r}=t,n[0]=t,n[1]=r,n[2]=s,n[3]=i):(r=n[1],s=n[2],i=n[3]);let o;n[4]!==s||n[5]!==i?(o={turnAnchor:i,topAnchorMessageClamp:s},n[4]=s,n[5]=i,n[6]=o):o=n[6];let a;n[7]!==r||n[8]!==e?(a=T.jsx(eS,{...r,ref:e}),n[7]=r,n[8]=e,n[9]=a):a=n[9];let l;return n[10]!==o||n[11]!==a?(l=T.jsx(bf,{options:o,children:a}),n[10]=o,n[11]=a,n[12]=l):l=n[12],l});tS.displayName="ThreadPrimitive.Viewport";function PO(t){return t.registerViewport}function MO(t){return t.clientHeight}function DO(t){return t.registerViewportElement}function OO(t){return t.topAnchorTurn}const nS=Re((t,e)=>{const n=O(3),r=hr(NO),s=Jx(r,LO),i=fr(e,s);let o;return n[0]!==t||n[1]!==i?(o=T.jsx(ze.div,{...t,ref:i}),n[0]=t,n[1]=i,n[2]=o):o=n[2],o});nS.displayName="ThreadPrimitive.ViewportFooter";function NO(t){return t.registerContentInset}function LO(t){const e=parseFloat(getComputedStyle(t).marginTop)||0;return t.offsetHeight+e}const jO=t=>{const e=O(5);let n;e[0]!==t?(n=t===void 0?{}:t,e[0]=t,e[1]=n):n=e[1];const{behavior:r}=n,s=hr(zO),i=Yr();let o;e[2]!==r||e[3]!==i?(o=()=>{i.getState().scrollToBottom({behavior:r})},e[2]=r,e[3]=i,e[4]=o):o=e[4];const a=o;return s?null:a},$O=Jr("ThreadPrimitive.ScrollToBottom",jO,["behavior"]);function zO(t){return t.isAtBottom}const FO=t=>{const e=O(4),{prompt:n,send:r,clearComposer:s,autoSend:i}=t,o=r??i??!1;let a;e[0]!==s||e[1]!==n||e[2]!==o?(a={prompt:n,send:o,clearComposer:s},e[0]=s,e[1]=n,e[2]=o,e[3]=a):a=e[3];const{disabled:l,trigger:u}=k3(a);return l?null:u},BO=Jr("ThreadPrimitive.Suggestion",FO,["prompt","send","clearComposer","autoSend","method"]);var In=Ef({Empty:()=>Kx,If:()=>Yx,MessageByIndex:()=>b1,Messages:()=>_M,Root:()=>Qx,ScrollToBottom:()=>$O,Suggestion:()=>BO,SuggestionByIndex:()=>Q1,Suggestions:()=>f3,Unstable_MessageById:()=>T1,Viewport:()=>tS,ViewportFooter:()=>nS,ViewportProvider:()=>bf});const UO=Object.freeze({type:"complete"}),VO=Object.freeze({type:"reasoning",text:"",status:UO}),HO=()=>G(qO);function qO(t){return t.part.type!=="reasoning"?VO:t.part}function rS(t){const e=[],n=[];let r=0,s,i="";for(const o of t)for(const a of o.items)switch(a.kind){case"text":i+=a.text,e.push({type:"text",text:a.text});break;case"thinking":e.push({type:"reasoning",text:a.text});break;case"tool":{const l={type:"tool-call",toolCallId:`t${r++}`,toolName:"tool",args:{text:a.text,tool:a.toolName,full:a.fullText},argsText:a.text};e.push(l),n.push(l);break}case"tool_result":{let l=a.toolName?n.findIndex(c=>c.args.tool===a.toolName):-1;l<0&&n.length>0&&(l=0);const u=l>=0?n.splice(l,1)[0]:void 0;(u==null?void 0:u.type)==="tool-call"?u.result=a.text:e.push({type:"tool-call",toolCallId:`t${r++}`,toolName:"tool_result",args:{text:a.text,tool:a.toolName,full:a.fullText},argsText:a.text});break}case"permission":case"ask":e.push({type:"tool-call",toolCallId:`t${r++}`,toolName:a.kind,args:{text:a.text,tool:a.toolName,full:a.fullText},argsText:a.text});break;case"status":s!==a.text&&!(i&&i.includes(a.text))&&(s=a.text,e.push({type:"tool-call",toolCallId:`t${r++}`,toolName:"status",args:{text:a.text},argsText:a.text}));break}return e}async function*sS(t,e){const n=await fetch(t,{signal:e,headers:{accept:"text/event-stream"}});if(!n.ok||!n.body)throw new Error(`SSE 连接失败:${n.status}`);const r=n.body.getReader(),s=new TextDecoder;let i="";for(;;){const{value:o,done:a}=await r.read();if(a)break;i+=s.decode(o,{stream:!0});let l;for(;(l=i.indexOf(`
46
+
47
+ `))>=0;){const u=i.slice(0,l);i=i.slice(l+2);let c="message",d="";for(const h of u.split(`
48
+ `))h.startsWith("event:")?c=h.slice(6).trim():h.startsWith("data:")&&(d+=h.slice(5).trim());if(d)try{const h=JSON.parse(d);if(yield{run:h.run,groups:h.groups??[]},c==="finish")return}catch{}}}}const ll={},Rd=new Map;function GO(){Rd.clear()}function WO(t){for(let e=t.length-1;e>=0;e--){const n=t[e];if(n.role==="user")return n.content.filter(r=>r.type==="text").map(r=>r.text).join(`
49
+ `)}return""}const QO={async*run({messages:t,abortSignal:e,unstable_threadId:n}){var l;const r=WO(t);if(!r)return;const s=`chat-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,i={requestId:s,prompt:r};ll.agent&&(i.agent=ll.agent);const o=n?Rd.get(n):void 0;o&&(i.sessionId=o);const a=await fetch("/api/chat",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),signal:e});if(!a.ok){const u=await a.text().catch(()=>"");throw new Error(`受理失败 ${a.status}:${u}`)}e.addEventListener("abort",()=>{fetch(`/api/chat/${s}/stop`,{method:"POST"}).catch(()=>{})});try{for await(const u of sS(`/api/runs/${s}/stream`,e))if(yield{content:rS(u.groups)},(l=u.run)!=null&&l.sessionId&&n&&Rd.set(n,u.run.sessionId),u.run&&u.run.status!=="running"){u.run.status==="failed"&&u.run.error&&(yield{content:[{type:"text",text:`
50
+ (本轮失败:${u.run.error})`}]});break}}catch(u){if((u==null?void 0:u.name)!=="AbortError")throw u}}};function KO(t,e){const n={};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const YO=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,JO=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,XO={};function Xg(t,e){return(XO.jsx?JO:YO).test(t)}const ZO=/[ \t\n\f\r]/g;function eN(t){return typeof t=="object"?t.type==="text"?Zg(t.value):!1:Zg(t)}function Zg(t){return t.replace(ZO,"")===""}class Co{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}}Co.prototype.normal={};Co.prototype.property={};Co.prototype.space=void 0;function iS(t,e){const n={},r={};for(const s of t)Object.assign(n,s.property),Object.assign(r,s.normal);return new Co(n,r,e)}function Ad(t){return t.toLowerCase()}class ft{constructor(e,n){this.attribute=n,this.property=e}}ft.prototype.attribute="";ft.prototype.booleanish=!1;ft.prototype.boolean=!1;ft.prototype.commaOrSpaceSeparated=!1;ft.prototype.commaSeparated=!1;ft.prototype.defined=!1;ft.prototype.mustUseProperty=!1;ft.prototype.number=!1;ft.prototype.overloadedBoolean=!1;ft.prototype.property="";ft.prototype.spaceSeparated=!1;ft.prototype.space=void 0;let tN=0;const ne=Zr(),De=Zr(),Pd=Zr(),B=Zr(),me=Zr(),Dr=Zr(),gt=Zr();function Zr(){return 2**++tN}const Md=Object.freeze(Object.defineProperty({__proto__:null,boolean:ne,booleanish:De,commaOrSpaceSeparated:gt,commaSeparated:Dr,number:B,overloadedBoolean:Pd,spaceSeparated:me},Symbol.toStringTag,{value:"Module"})),Yu=Object.keys(Md);class Bf extends ft{constructor(e,n,r,s){let i=-1;if(super(e,n),ey(this,"space",s),typeof r=="number")for(;++i<Yu.length;){const o=Yu[i];ey(this,Yu[i],(r&Md[o])===Md[o])}}}Bf.prototype.defined=!0;function ey(t,e,n){n&&(t[e]=n)}function Ws(t){const e={},n={};for(const[r,s]of Object.entries(t.properties)){const i=new Bf(r,t.transform(t.attributes||{},r),s,t.space);t.mustUseProperty&&t.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),e[r]=i,n[Ad(r)]=r,n[Ad(i.attribute)]=r}return new Co(e,n,t.space)}const oS=Ws({properties:{ariaActiveDescendant:null,ariaAtomic:De,ariaAutoComplete:null,ariaBusy:De,ariaChecked:De,ariaColCount:B,ariaColIndex:B,ariaColSpan:B,ariaControls:me,ariaCurrent:null,ariaDescribedBy:me,ariaDetails:null,ariaDisabled:De,ariaDropEffect:me,ariaErrorMessage:null,ariaExpanded:De,ariaFlowTo:me,ariaGrabbed:De,ariaHasPopup:null,ariaHidden:De,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:me,ariaLevel:B,ariaLive:null,ariaModal:De,ariaMultiLine:De,ariaMultiSelectable:De,ariaOrientation:null,ariaOwns:me,ariaPlaceholder:null,ariaPosInSet:B,ariaPressed:De,ariaReadOnly:De,ariaRelevant:null,ariaRequired:De,ariaRoleDescription:me,ariaRowCount:B,ariaRowIndex:B,ariaRowSpan:B,ariaSelected:De,ariaSetSize:B,ariaSort:null,ariaValueMax:B,ariaValueMin:B,ariaValueNow:B,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function aS(t,e){return e in t?t[e]:e}function lS(t,e){return aS(t,e.toLowerCase())}const nN=Ws({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Dr,acceptCharset:me,accessKey:me,action:null,allow:null,allowFullScreen:ne,allowPaymentRequest:ne,allowUserMedia:ne,alpha:ne,alt:null,as:null,async:ne,autoCapitalize:null,autoComplete:me,autoFocus:ne,autoPlay:ne,blocking:me,capture:null,charSet:null,checked:ne,cite:null,className:me,closedBy:null,colorSpace:null,cols:B,colSpan:B,command:null,commandFor:null,content:null,contentEditable:De,controls:ne,controlsList:me,coords:B|Dr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ne,defer:ne,dir:null,dirName:null,disabled:ne,download:Pd,draggable:De,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ne,formTarget:null,headers:me,height:B,hidden:Pd,high:B,href:null,hrefLang:null,htmlFor:me,httpEquiv:me,id:null,imageSizes:null,imageSrcSet:null,inert:ne,inputMode:null,integrity:null,is:null,isMap:ne,itemId:null,itemProp:me,itemRef:me,itemScope:ne,itemType:me,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ne,low:B,manifest:null,max:null,maxLength:B,media:null,method:null,min:null,minLength:B,multiple:ne,muted:ne,name:null,nonce:null,noModule:ne,noValidate:ne,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ne,optimum:B,pattern:null,ping:me,placeholder:null,playsInline:ne,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ne,referrerPolicy:null,rel:me,required:ne,reversed:ne,rows:B,rowSpan:B,sandbox:me,scope:null,scoped:ne,seamless:ne,selected:ne,shadowRootClonable:ne,shadowRootCustomElementRegistry:ne,shadowRootDelegatesFocus:ne,shadowRootMode:null,shadowRootSerializable:ne,shape:null,size:B,sizes:null,slot:null,span:B,spellCheck:De,src:null,srcDoc:null,srcLang:null,srcSet:null,start:B,step:null,style:null,tabIndex:B,target:null,title:null,translate:null,type:null,typeMustMatch:ne,useMap:null,value:De,width:B,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:me,axis:null,background:null,bgColor:null,border:B,borderColor:null,bottomMargin:B,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ne,declare:ne,event:null,face:null,frame:null,frameBorder:null,hSpace:B,leftMargin:B,link:null,longDesc:null,lowSrc:null,marginHeight:B,marginWidth:B,noResize:ne,noHref:ne,noShade:ne,noWrap:ne,object:null,profile:null,prompt:null,rev:null,rightMargin:B,rules:null,scheme:null,scrolling:De,standby:null,summary:null,text:null,topMargin:B,valueType:null,version:null,vAlign:null,vLink:null,vSpace:B,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:ne,disablePictureInPicture:ne,disableRemotePlayback:ne,exportParts:Dr,part:me,prefix:null,property:null,results:B,security:null,unselectable:null},space:"html",transform:lS}),rN=Ws({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:gt,accentHeight:B,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:B,amplitude:B,arabicForm:null,ascent:B,attributeName:null,attributeType:null,azimuth:B,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:B,by:null,calcMode:null,capHeight:B,className:me,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:B,diffuseConstant:B,direction:null,display:null,dur:null,divisor:B,dominantBaseline:null,download:ne,dx:null,dy:null,edgeMode:null,editable:null,elevation:B,enableBackground:null,end:null,event:null,exponent:B,externalResourcesRequired:null,fill:null,fillOpacity:B,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Dr,g2:Dr,glyphName:Dr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:B,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:B,horizOriginX:B,horizOriginY:B,id:null,ideographic:B,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:B,k:B,k1:B,k2:B,k3:B,k4:B,kernelMatrix:gt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:B,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:B,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:B,overlineThickness:B,paintOrder:null,panose1:null,path:null,pathLength:B,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:me,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:B,pointsAtY:B,pointsAtZ:B,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:gt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:gt,rev:gt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:gt,requiredFeatures:gt,requiredFonts:gt,requiredFormats:gt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:B,specularExponent:B,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:B,strikethroughThickness:B,string:null,stroke:null,strokeDashArray:gt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:B,strokeOpacity:B,strokeWidth:null,style:null,surfaceScale:B,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:gt,tabIndex:B,tableValues:null,target:null,targetX:B,targetY:B,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:gt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:B,underlineThickness:B,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:B,values:null,vAlphabetic:B,vMathematical:B,vectorEffect:null,vHanging:B,vIdeographic:B,version:null,vertAdvY:B,vertOriginX:B,vertOriginY:B,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:B,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:aS}),uS=Ws({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),cS=Ws({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:lS}),dS=Ws({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),sN={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},iN=/[A-Z]/g,ty=/-[a-z]/g,oN=/^data[-\w.:]+$/i;function aN(t,e){const n=Ad(e);let r=e,s=ft;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&oN.test(e)){if(e.charAt(4)==="-"){const i=e.slice(5).replace(ty,uN);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=e.slice(4);if(!ty.test(i)){let o=i.replace(iN,lN);o.charAt(0)!=="-"&&(o="-"+o),e="data"+o}}s=Bf}return new s(r,e)}function lN(t){return"-"+t.toLowerCase()}function uN(t){return t.charAt(1).toUpperCase()}const cN=iS([oS,nN,uS,cS,dS],"html"),Uf=iS([oS,rN,uS,cS,dS],"svg");function dN(t){return t.join(" ").trim()}var Vf={},ny=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,hN=/\n/g,fN=/^\s*/,pN=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,mN=/^:\s*/,gN=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,yN=/^[;\s]*/,vN=/^\s+|\s+$/g,_N=`
51
+ `,ry="/",sy="*",Tr="",wN="comment",xN="declaration";function SN(t,e){if(typeof t!="string")throw new TypeError("First argument must be a string");if(!t)return[];e=e||{};var n=1,r=1;function s(p){var g=p.match(hN);g&&(n+=g.length);var _=p.lastIndexOf(_N);r=~_?p.length-_:r+p.length}function i(){var p={line:n,column:r};return function(g){return g.position=new o(p),u(),g}}function o(p){this.start=p,this.end={line:n,column:r},this.source=e.source}o.prototype.content=t;function a(p){var g=new Error(e.source+":"+n+":"+r+": "+p);if(g.reason=p,g.filename=e.source,g.line=n,g.column=r,g.source=t,!e.silent)throw g}function l(p){var g=p.exec(t);if(g){var _=g[0];return s(_),t=t.slice(_.length),g}}function u(){l(fN)}function c(p){var g;for(p=p||[];g=d();)g!==!1&&p.push(g);return p}function d(){var p=i();if(!(ry!=t.charAt(0)||sy!=t.charAt(1))){for(var g=2;Tr!=t.charAt(g)&&(sy!=t.charAt(g)||ry!=t.charAt(g+1));)++g;if(g+=2,Tr===t.charAt(g-1))return a("End of comment missing");var _=t.slice(2,g-2);return r+=2,s(_),t=t.slice(g),r+=2,p({type:wN,comment:_})}}function h(){var p=i(),g=l(pN);if(g){if(d(),!l(mN))return a("property missing ':'");var _=l(gN),m=p({type:xN,property:iy(g[0].replace(ny,Tr)),value:_?iy(_[0].replace(ny,Tr)):Tr});return l(yN),m}}function f(){var p=[];c(p);for(var g;g=h();)g!==!1&&(p.push(g),c(p));return p}return u(),f()}function iy(t){return t?t.replace(vN,Tr):Tr}var bN=SN,TN=ka&&ka.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Vf,"__esModule",{value:!0});Vf.default=CN;const kN=TN(bN);function CN(t,e){let n=null;if(!t||typeof t!="string")return n;const r=(0,kN.default)(t),s=typeof e=="function";return r.forEach(i=>{if(i.type!=="declaration")return;const{property:o,value:a}=i;s?e(o,a,i):a&&(n=n||{},n[o]=a)}),n}var Vl={};Object.defineProperty(Vl,"__esModule",{value:!0});Vl.camelCase=void 0;var IN=/^--[a-zA-Z0-9_-]+$/,EN=/-([a-z])/g,RN=/^[^-]+$/,AN=/^-(webkit|moz|ms|o|khtml)-/,PN=/^-(ms)-/,MN=function(t){return!t||RN.test(t)||IN.test(t)},DN=function(t,e){return e.toUpperCase()},oy=function(t,e){return"".concat(e,"-")},ON=function(t,e){return e===void 0&&(e={}),MN(t)?t:(t=t.toLowerCase(),e.reactCompat?t=t.replace(PN,oy):t=t.replace(AN,oy),t.replace(EN,DN))};Vl.camelCase=ON;var NN=ka&&ka.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},LN=NN(Vf),jN=Vl;function Dd(t,e){var n={};return!t||typeof t!="string"||(0,LN.default)(t,function(r,s){r&&s&&(n[(0,jN.camelCase)(r,e)]=s)}),n}Dd.default=Dd;var $N=Dd;const zN=pl($N),hS=fS("end"),Hf=fS("start");function fS(t){return e;function e(n){const r=n&&n.position&&n.position[t]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function FN(t){const e=Hf(t),n=hS(t);if(e&&n)return{start:e,end:n}}function Ai(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?ay(t.position):"start"in t||"end"in t?ay(t):"line"in t||"column"in t?Od(t):""}function Od(t){return ly(t&&t.line)+":"+ly(t&&t.column)}function ay(t){return Od(t&&t.start)+"-"+Od(t&&t.end)}function ly(t){return t&&typeof t=="number"?t:1}class Je extends Error{constructor(e,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",i={},o=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof e=="string"?s=e:!i.cause&&e&&(o=!0,s=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?i.ruleId=r:(i.source=r.slice(0,l),i.ruleId=r.slice(l+1))}if(!i.place&&i.ancestors&&i.ancestors){const l=i.ancestors[i.ancestors.length-1];l&&(i.place=l.position)}const a=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=a?a.line:void 0,this.name=Ai(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=o&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Je.prototype.file="";Je.prototype.name="";Je.prototype.reason="";Je.prototype.message="";Je.prototype.stack="";Je.prototype.column=void 0;Je.prototype.line=void 0;Je.prototype.ancestors=void 0;Je.prototype.cause=void 0;Je.prototype.fatal=void 0;Je.prototype.place=void 0;Je.prototype.ruleId=void 0;Je.prototype.source=void 0;const qf={}.hasOwnProperty,BN=new Map,UN=/[A-Z]/g,VN=new Set(["table","tbody","thead","tfoot","tr"]),HN=new Set(["td","th"]),pS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function qN(t,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=e.filePath||void 0;let r;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=ZN(n,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=XN(n,e.jsx,e.jsxs)}const s={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:r,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?Uf:cN,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},i=mS(s,t,void 0);return i&&typeof i!="string"?i:s.create(t,s.Fragment,{children:i||void 0},void 0)}function mS(t,e,n){if(e.type==="element")return GN(t,e,n);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return WN(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return KN(t,e,n);if(e.type==="mdxjsEsm")return QN(t,e);if(e.type==="root")return YN(t,e,n);if(e.type==="text")return JN(t,e)}function GN(t,e,n){const r=t.schema;let s=r;e.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=Uf,t.schema=s),t.ancestors.push(e);const i=yS(t,e.tagName,!1),o=eL(t,e);let a=Wf(t,e);return VN.has(e.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!eN(l):!0})),gS(t,o,i,e),Gf(o,a),t.ancestors.pop(),t.schema=r,t.create(e,i,o,n)}function WN(t,e){if(e.data&&e.data.estree&&t.evaluater){const r=e.data.estree.body[0];return r.type,t.evaluater.evaluateExpression(r.expression)}ao(t,e.position)}function QN(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);ao(t,e.position)}function KN(t,e,n){const r=t.schema;let s=r;e.name==="svg"&&r.space==="html"&&(s=Uf,t.schema=s),t.ancestors.push(e);const i=e.name===null?t.Fragment:yS(t,e.name,!0),o=tL(t,e),a=Wf(t,e);return gS(t,o,i,e),Gf(o,a),t.ancestors.pop(),t.schema=r,t.create(e,i,o,n)}function YN(t,e,n){const r={};return Gf(r,Wf(t,e)),t.create(e,t.Fragment,r,n)}function JN(t,e){return e.value}function gS(t,e,n,r){typeof n!="string"&&n!==t.Fragment&&t.passNode&&(e.node=r)}function Gf(t,e){if(e.length>0){const n=e.length>1?e:e[0];n&&(t.children=n)}}function XN(t,e,n){return r;function r(s,i,o,a){const u=Array.isArray(o.children)?n:e;return a?u(i,o,a):u(i,o)}}function ZN(t,e){return n;function n(r,s,i,o){const a=Array.isArray(i.children),l=Hf(r);return e(s,i,o,a,{columnNumber:l?l.column-1:void 0,fileName:t,lineNumber:l?l.line:void 0},void 0)}}function eL(t,e){const n={};let r,s;for(s in e.properties)if(s!=="children"&&qf.call(e.properties,s)){const i=nL(t,s,e.properties[s]);if(i){const[o,a]=i;t.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&HN.has(e.tagName)?r=a:n[o]=a}}if(r){const i=n.style||(n.style={});i[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function tL(t,e){const n={};for(const r of e.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&t.evaluater){const i=r.data.estree.body[0];i.type;const o=i.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,t.evaluater.evaluateExpression(a.argument))}else ao(t,e.position);else{const s=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&t.evaluater){const a=r.value.data.estree.body[0];a.type,i=t.evaluater.evaluateExpression(a.expression)}else ao(t,e.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function Wf(t,e){const n=[];let r=-1;const s=t.passKeys?new Map:BN;for(;++r<e.children.length;){const i=e.children[r];let o;if(t.passKeys){const l=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(l){const u=s.get(l)||0;o=l+"-"+u,s.set(l,u+1)}}const a=mS(t,i,o);a!==void 0&&n.push(a)}return n}function nL(t,e,n){const r=aN(t.schema,e);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?KO(n):dN(n)),r.property==="style"){let s=typeof n=="object"?n:rL(t,String(n));return t.stylePropertyNameCase==="css"&&(s=sL(s)),["style",s]}return[t.elementAttributeNameCase==="react"&&r.space?sN[r.property]||r.property:r.attribute,n]}}function rL(t,e){try{return zN(e,{reactCompat:!0})}catch(n){if(t.ignoreInvalidStyle)return{};const r=n,s=new Je("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=t.filePath||void 0,s.url=pS+"#cannot-parse-style-attribute",s}}function yS(t,e,n){let r;if(!n)r={type:"Literal",value:e};else if(e.includes(".")){const s=e.split(".");let i=-1,o;for(;++i<s.length;){const a=Xg(s[i])?{type:"Identifier",name:s[i]}:{type:"Literal",value:s[i]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(i&&a.type==="Literal"),optional:!1}:a}r=o}else r=Xg(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(r.type==="Literal"){const s=r.value;return qf.call(t.components,s)?t.components[s]:s}if(t.evaluater)return t.evaluater.evaluateExpression(r);ao(t)}function ao(t,e){const n=new Je("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=t.filePath||void 0,n.url=pS+"#cannot-handle-mdx-estrees-without-createevaluater",n}function sL(t){const e={};let n;for(n in t)qf.call(t,n)&&(e[iL(n)]=t[n]);return e}function iL(t){let e=t.replace(UN,oL);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function oL(t){return"-"+t.toLowerCase()}const Ju={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},aL={};function Qf(t,e){const n=aL,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return vS(t,r,s)}function vS(t,e,n){if(lL(t)){if("value"in t)return t.type==="html"&&!n?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return uy(t.children,e,n)}return Array.isArray(t)?uy(t,e,n):""}function uy(t,e,n){const r=[];let s=-1;for(;++s<t.length;)r[s]=vS(t[s],e,n);return r.join("")}function lL(t){return!!(t&&typeof t=="object")}const cy=document.createElement("i");function Kf(t){const e="&"+t+";";cy.innerHTML=e;const n=cy.textContent;return n.charCodeAt(n.length-1)===59&&t!=="semi"||n===e?!1:n}function bt(t,e,n,r){const s=t.length;let i=0,o;if(e<0?e=-e>s?0:s+e:e=e>s?s:e,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(e,n),t.splice(...o);else for(n&&t.splice(e,n);i<r.length;)o=r.slice(i,i+1e4),o.unshift(e,0),t.splice(...o),i+=1e4,e+=1e4}function Ot(t,e){return t.length>0?(bt(t,t.length,0,e),t):e}const dy={}.hasOwnProperty;function _S(t){const e={};let n=-1;for(;++n<t.length;)uL(e,t[n]);return e}function uL(t,e){let n;for(n in e){const s=(dy.call(t,n)?t[n]:void 0)||(t[n]={}),i=e[n];let o;if(i)for(o in i){dy.call(s,o)||(s[o]=[]);const a=i[o];cL(s[o],Array.isArray(a)?a:a?[a]:[])}}}function cL(t,e){let n=-1;const r=[];for(;++n<e.length;)(e[n].add==="after"?t:r).push(e[n]);bt(t,0,0,r)}function wS(t,e){const n=Number.parseInt(t,e);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function sn(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const tt=pr(/[A-Za-z]/),Ke=pr(/[\dA-Za-z]/),dL=pr(/[#-'*+\--9=?A-Z^-~]/);function ul(t){return t!==null&&(t<32||t===127)}const Nd=pr(/\d/),hL=pr(/[\dA-Fa-f]/),fL=pr(/[!-/:-@[-`{-~]/);function Z(t){return t!==null&&t<-2}function ye(t){return t!==null&&(t<0||t===32)}function se(t){return t===-2||t===-1||t===32}const Hl=pr(new RegExp("\\p{P}|\\p{S}","u")),Hr=pr(/\s/);function pr(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function Qs(t){const e=[];let n=-1,r=0,s=0;for(;++n<t.length;){const i=t.charCodeAt(n);let o="";if(i===37&&Ke(t.charCodeAt(n+1))&&Ke(t.charCodeAt(n+2)))s=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(o=String.fromCharCode(i));else if(i>55295&&i<57344){const a=t.charCodeAt(n+1);i<56320&&a>56319&&a<57344?(o=String.fromCharCode(i,a),s=1):o="�"}else o=String.fromCharCode(i);o&&(e.push(t.slice(r,n),encodeURIComponent(o)),r=n+s+1,o=""),s&&(n+=s,s=0)}return e.join("")+t.slice(r)}function le(t,e,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return o;function o(l){return se(l)?(t.enter(n),a(l)):e(l)}function a(l){return se(l)&&i++<s?(t.consume(l),a):(t.exit(n),e(l))}}const pL={tokenize:mL};function mL(t){const e=t.attempt(this.parser.constructs.contentInitial,r,s);let n;return e;function r(a){if(a===null){t.consume(a);return}return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),le(t,e,"linePrefix")}function s(a){return t.enter("paragraph"),i(a)}function i(a){const l=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(a);return}return Z(a)?(t.consume(a),t.exit("chunkText"),i):(t.consume(a),o)}}const gL={tokenize:yL},hy={tokenize:vL};function yL(t){const e=this,n=[];let r=0,s,i,o;return a;function a(v){if(r<n.length){const S=n[r];return e.containerState=S[1],t.attempt(S[0].continuation,l,u)(v)}return u(v)}function l(v){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,s&&y();const S=e.events.length;let I=S,b;for(;I--;)if(e.events[I][0]==="exit"&&e.events[I][1].type==="chunkFlow"){b=e.events[I][1].end;break}m(r);let P=S;for(;P<e.events.length;)e.events[P][1].end={...b},P++;return bt(e.events,I+1,0,e.events.slice(S)),e.events.length=P,u(v)}return a(v)}function u(v){if(r===n.length){if(!s)return h(v);if(s.currentConstruct&&s.currentConstruct.concrete)return p(v);e.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(hy,c,d)(v)}function c(v){return s&&y(),m(r),h(v)}function d(v){return e.parser.lazy[e.now().line]=r!==n.length,o=e.now().offset,p(v)}function h(v){return e.containerState={},t.attempt(hy,f,p)(v)}function f(v){return r++,n.push([e.currentConstruct,e.containerState]),h(v)}function p(v){if(v===null){s&&y(),m(0),t.consume(v);return}return s=s||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),g(v)}function g(v){if(v===null){_(t.exit("chunkFlow"),!0),m(0),t.consume(v);return}return Z(v)?(t.consume(v),_(t.exit("chunkFlow")),r=0,e.interrupt=void 0,a):(t.consume(v),g)}function _(v,S){const I=e.sliceStream(v);if(S&&I.push(null),v.previous=i,i&&(i.next=v),i=v,s.defineSkip(v.start),s.write(I),e.parser.lazy[v.start.line]){let b=s.events.length;for(;b--;)if(s.events[b][1].start.offset<o&&(!s.events[b][1].end||s.events[b][1].end.offset>o))return;const P=e.events.length;let A=P,D,x;for(;A--;)if(e.events[A][0]==="exit"&&e.events[A][1].type==="chunkFlow"){if(D){x=e.events[A][1].end;break}D=!0}for(m(r),b=P;b<e.events.length;)e.events[b][1].end={...x},b++;bt(e.events,A+1,0,e.events.slice(P)),e.events.length=b}}function m(v){let S=n.length;for(;S-- >v;){const I=n[S];e.containerState=I[1],I[0].exit.call(e,t)}n.length=v}function y(){s.write([null]),i=void 0,s=void 0,e.containerState._closeFlow=void 0}}function vL(t,e,n){return le(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ns(t){if(t===null||ye(t)||Hr(t))return 1;if(Hl(t))return 2}function ql(t,e,n){const r=[];let s=-1;for(;++s<t.length;){const i=t[s].resolveAll;i&&!r.includes(i)&&(e=i(e,n),r.push(i))}return e}const Ld={name:"attention",resolveAll:_L,tokenize:wL};function _L(t,e){let n=-1,r,s,i,o,a,l,u,c;for(;++n<t.length;)if(t[n][0]==="enter"&&t[n][1].type==="attentionSequence"&&t[n][1]._close){for(r=n;r--;)if(t[r][0]==="exit"&&t[r][1].type==="attentionSequence"&&t[r][1]._open&&e.sliceSerialize(t[r][1]).charCodeAt(0)===e.sliceSerialize(t[n][1]).charCodeAt(0)){if((t[r][1]._close||t[n][1]._open)&&(t[n][1].end.offset-t[n][1].start.offset)%3&&!((t[r][1].end.offset-t[r][1].start.offset+t[n][1].end.offset-t[n][1].start.offset)%3))continue;l=t[r][1].end.offset-t[r][1].start.offset>1&&t[n][1].end.offset-t[n][1].start.offset>1?2:1;const d={...t[r][1].end},h={...t[n][1].start};fy(d,-l),fy(h,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...t[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...t[n][1].start},end:h},i={type:l>1?"strongText":"emphasisText",start:{...t[r][1].end},end:{...t[n][1].start}},s={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},t[r][1].end={...o.start},t[n][1].start={...a.end},u=[],t[r][1].end.offset-t[r][1].start.offset&&(u=Ot(u,[["enter",t[r][1],e],["exit",t[r][1],e]])),u=Ot(u,[["enter",s,e],["enter",o,e],["exit",o,e],["enter",i,e]]),u=Ot(u,ql(e.parser.constructs.insideSpan.null,t.slice(r+1,n),e)),u=Ot(u,[["exit",i,e],["enter",a,e],["exit",a,e],["exit",s,e]]),t[n][1].end.offset-t[n][1].start.offset?(c=2,u=Ot(u,[["enter",t[n][1],e],["exit",t[n][1],e]])):c=0,bt(t,r-1,n-r+3,u),n=r+u.length-c-2;break}}for(n=-1;++n<t.length;)t[n][1].type==="attentionSequence"&&(t[n][1].type="data");return t}function wL(t,e){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=Ns(r);let i;return o;function o(l){return i=l,t.enter("attentionSequence"),a(l)}function a(l){if(l===i)return t.consume(l),a;const u=t.exit("attentionSequence"),c=Ns(l),d=!c||c===2&&s||n.includes(l),h=!s||s===2&&c||n.includes(r);return u._open=!!(i===42?d:d&&(s||!h)),u._close=!!(i===42?h:h&&(c||!d)),e(l)}}function fy(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const xL={name:"autolink",tokenize:SL};function SL(t,e,n){let r=0;return s;function s(f){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),i}function i(f){return tt(f)?(t.consume(f),o):f===64?n(f):u(f)}function o(f){return f===43||f===45||f===46||Ke(f)?(r=1,a(f)):u(f)}function a(f){return f===58?(t.consume(f),r=0,l):(f===43||f===45||f===46||Ke(f))&&r++<32?(t.consume(f),a):(r=0,u(f))}function l(f){return f===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.exit("autolink"),e):f===null||f===32||f===60||ul(f)?n(f):(t.consume(f),l)}function u(f){return f===64?(t.consume(f),c):dL(f)?(t.consume(f),u):n(f)}function c(f){return Ke(f)?d(f):n(f)}function d(f){return f===46?(t.consume(f),r=0,c):f===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.exit("autolink"),e):h(f)}function h(f){if((f===45||Ke(f))&&r++<63){const p=f===45?h:d;return t.consume(f),p}return n(f)}}const Io={partial:!0,tokenize:bL};function bL(t,e,n){return r;function r(i){return se(i)?le(t,s,"linePrefix")(i):s(i)}function s(i){return i===null||Z(i)?e(i):n(i)}}const xS={continuation:{tokenize:kL},exit:CL,name:"blockQuote",tokenize:TL};function TL(t,e,n){const r=this;return s;function s(o){if(o===62){const a=r.containerState;return a.open||(t.enter("blockQuote",{_container:!0}),a.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(o),t.exit("blockQuoteMarker"),i}return n(o)}function i(o){return se(o)?(t.enter("blockQuotePrefixWhitespace"),t.consume(o),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(o))}}function kL(t,e,n){const r=this;return s;function s(o){return se(o)?le(t,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):i(o)}function i(o){return t.attempt(xS,e,n)(o)}}function CL(t){t.exit("blockQuote")}const SS={name:"characterEscape",tokenize:IL};function IL(t,e,n){return r;function r(i){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(i),t.exit("escapeMarker"),s}function s(i){return fL(i)?(t.enter("characterEscapeValue"),t.consume(i),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(i)}}const bS={name:"characterReference",tokenize:EL};function EL(t,e,n){const r=this;let s=0,i,o;return a;function a(d){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(d),t.exit("characterReferenceMarker"),l}function l(d){return d===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(d),t.exit("characterReferenceMarkerNumeric"),u):(t.enter("characterReferenceValue"),i=31,o=Ke,c(d))}function u(d){return d===88||d===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(d),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),i=6,o=hL,c):(t.enter("characterReferenceValue"),i=7,o=Nd,c(d))}function c(d){if(d===59&&s){const h=t.exit("characterReferenceValue");return o===Ke&&!Kf(r.sliceSerialize(h))?n(d):(t.enter("characterReferenceMarker"),t.consume(d),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return o(d)&&s++<i?(t.consume(d),c):n(d)}}const py={partial:!0,tokenize:AL},my={concrete:!0,name:"codeFenced",tokenize:RL};function RL(t,e,n){const r=this,s={partial:!0,tokenize:I};let i=0,o=0,a;return l;function l(b){return u(b)}function u(b){const P=r.events[r.events.length-1];return i=P&&P[1].type==="linePrefix"?P[2].sliceSerialize(P[1],!0).length:0,a=b,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),c(b)}function c(b){return b===a?(o++,t.consume(b),c):o<3?n(b):(t.exit("codeFencedFenceSequence"),se(b)?le(t,d,"whitespace")(b):d(b))}function d(b){return b===null||Z(b)?(t.exit("codeFencedFence"),r.interrupt?e(b):t.check(py,g,S)(b)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),h(b))}function h(b){return b===null||Z(b)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),d(b)):se(b)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),le(t,f,"whitespace")(b)):b===96&&b===a?n(b):(t.consume(b),h)}function f(b){return b===null||Z(b)?d(b):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===null||Z(b)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),d(b)):b===96&&b===a?n(b):(t.consume(b),p)}function g(b){return t.attempt(s,S,_)(b)}function _(b){return t.enter("lineEnding"),t.consume(b),t.exit("lineEnding"),m}function m(b){return i>0&&se(b)?le(t,y,"linePrefix",i+1)(b):y(b)}function y(b){return b===null||Z(b)?t.check(py,g,S)(b):(t.enter("codeFlowValue"),v(b))}function v(b){return b===null||Z(b)?(t.exit("codeFlowValue"),y(b)):(t.consume(b),v)}function S(b){return t.exit("codeFenced"),e(b)}function I(b,P,A){let D=0;return x;function x(z){return b.enter("lineEnding"),b.consume(z),b.exit("lineEnding"),k}function k(z){return b.enter("codeFencedFence"),se(z)?le(b,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(z):R(z)}function R(z){return z===a?(b.enter("codeFencedFenceSequence"),M(z)):A(z)}function M(z){return z===a?(D++,b.consume(z),M):D>=o?(b.exit("codeFencedFenceSequence"),se(z)?le(b,L,"whitespace")(z):L(z)):A(z)}function L(z){return z===null||Z(z)?(b.exit("codeFencedFence"),P(z)):A(z)}}}function AL(t,e,n){const r=this;return s;function s(o){return o===null?n(o):(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),i)}function i(o){return r.parser.lazy[r.now().line]?n(o):e(o)}}const Xu={name:"codeIndented",tokenize:ML},PL={partial:!0,tokenize:DL};function ML(t,e,n){const r=this;return s;function s(u){return t.enter("codeIndented"),le(t,i,"linePrefix",5)(u)}function i(u){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):Z(u)?t.attempt(PL,o,l)(u):(t.enter("codeFlowValue"),a(u))}function a(u){return u===null||Z(u)?(t.exit("codeFlowValue"),o(u)):(t.consume(u),a)}function l(u){return t.exit("codeIndented"),e(u)}}function DL(t,e,n){const r=this;return s;function s(o){return r.parser.lazy[r.now().line]?n(o):Z(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s):le(t,i,"linePrefix",5)(o)}function i(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(o):Z(o)?s(o):n(o)}}const OL={name:"codeText",previous:LL,resolve:NL,tokenize:jL};function NL(t){let e=t.length-4,n=3,r,s;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(r=n;++r<e;)if(t[r][1].type==="codeTextData"){t[n][1].type="codeTextPadding",t[e][1].type="codeTextPadding",n+=2,e-=2;break}}for(r=n-1,e++;++r<=e;)s===void 0?r!==e&&t[r][1].type!=="lineEnding"&&(s=r):(r===e||t[r][1].type==="lineEnding")&&(t[s][1].type="codeTextData",r!==s+2&&(t[s][1].end=t[r-1][1].end,t.splice(s+2,r-s-2),e-=r-s-2,r=s+2),s=void 0);return t}function LL(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function jL(t,e,n){let r=0,s,i;return o;function o(d){return t.enter("codeText"),t.enter("codeTextSequence"),a(d)}function a(d){return d===96?(t.consume(d),r++,a):(t.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(t.enter("space"),t.consume(d),t.exit("space"),l):d===96?(i=t.enter("codeTextSequence"),s=0,c(d)):Z(d)?(t.enter("lineEnding"),t.consume(d),t.exit("lineEnding"),l):(t.enter("codeTextData"),u(d))}function u(d){return d===null||d===32||d===96||Z(d)?(t.exit("codeTextData"),l(d)):(t.consume(d),u)}function c(d){return d===96?(t.consume(d),s++,c):s===r?(t.exit("codeTextSequence"),t.exit("codeText"),e(d)):(i.type="codeTextData",u(d))}}class $L{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,n,r){const s=n||0;this.setCursor(Math.trunc(e));const i=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&li(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),li(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),li(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const n=this.left.splice(e,Number.POSITIVE_INFINITY);li(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);li(this.left,n.reverse())}}}function li(t,e){let n=0;if(e.length<1e4)t.push(...e);else for(;n<e.length;)t.push(...e.slice(n,n+1e4)),n+=1e4}function TS(t){const e={};let n=-1,r,s,i,o,a,l,u;const c=new $L(t);for(;++n<c.length;){for(;n in e;)n=e[n];if(r=c.get(n),n&&r[1].type==="chunkFlow"&&c.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,i=0,i<l.length&&l[i][1].type==="lineEndingBlank"&&(i+=2),i<l.length&&l[i][1].type==="content"))for(;++i<l.length&&l[i][1].type!=="content";)l[i][1].type==="chunkText"&&(l[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(e,zL(c,n)),n=e[n],u=!0);else if(r[1]._container){for(i=n,s=void 0;i--;)if(o=c.get(i),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(s&&(c.get(s)[1].type="lineEndingBlank"),o[1].type="lineEnding",s=i);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;s&&(r[1].end={...c.get(s)[1].start},a=c.slice(s,n),a.unshift(r),c.splice(s,n-s+1,a))}}return bt(t,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function zL(t,e){const n=t.get(e)[1],r=t.get(e)[2];let s=e-1;const i=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],u={};let c,d,h=-1,f=n,p=0,g=0;const _=[g];for(;f;){for(;t.get(++s)[1]!==f;);i.push(s),f._tokenizer||(c=r.sliceStream(f),f.next||c.push(null),d&&o.defineSkip(f.start),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(c),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=f,f=f.next}for(f=n;++h<a.length;)a[h][0]==="exit"&&a[h-1][0]==="enter"&&a[h][1].type===a[h-1][1].type&&a[h][1].start.line!==a[h][1].end.line&&(g=h+1,_.push(g),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(o.events=[],f?(f._tokenizer=void 0,f.previous=void 0):_.pop(),h=_.length;h--;){const m=a.slice(_[h],_[h+1]),y=i.pop();l.push([y,y+m.length-1]),t.splice(y,2,m)}for(l.reverse(),h=-1;++h<l.length;)u[p+l[h][0]]=p+l[h][1],p+=l[h][1]-l[h][0]-1;return u}const FL={resolve:UL,tokenize:VL},BL={partial:!0,tokenize:HL};function UL(t){return TS(t),t}function VL(t,e){let n;return r;function r(a){return t.enter("content"),n=t.enter("chunkContent",{contentType:"content"}),s(a)}function s(a){return a===null?i(a):Z(a)?t.check(BL,o,i)(a):(t.consume(a),s)}function i(a){return t.exit("chunkContent"),t.exit("content"),e(a)}function o(a){return t.consume(a),t.exit("chunkContent"),n.next=t.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function HL(t,e,n){const r=this;return s;function s(o){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),le(t,i,"linePrefix")}function i(o){if(o===null||Z(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(o):t.interrupt(r.parser.constructs.flow,n,e)(o)}}function kS(t,e,n,r,s,i,o,a,l){const u=l||Number.POSITIVE_INFINITY;let c=0;return d;function d(m){return m===60?(t.enter(r),t.enter(s),t.enter(i),t.consume(m),t.exit(i),h):m===null||m===32||m===41||ul(m)?n(m):(t.enter(r),t.enter(o),t.enter(a),t.enter("chunkString",{contentType:"string"}),g(m))}function h(m){return m===62?(t.enter(i),t.consume(m),t.exit(i),t.exit(s),t.exit(r),e):(t.enter(a),t.enter("chunkString",{contentType:"string"}),f(m))}function f(m){return m===62?(t.exit("chunkString"),t.exit(a),h(m)):m===null||m===60||Z(m)?n(m):(t.consume(m),m===92?p:f)}function p(m){return m===60||m===62||m===92?(t.consume(m),f):f(m)}function g(m){return!c&&(m===null||m===41||ye(m))?(t.exit("chunkString"),t.exit(a),t.exit(o),t.exit(r),e(m)):c<u&&m===40?(t.consume(m),c++,g):m===41?(t.consume(m),c--,g):m===null||m===32||m===40||ul(m)?n(m):(t.consume(m),m===92?_:g)}function _(m){return m===40||m===41||m===92?(t.consume(m),g):g(m)}}function CS(t,e,n,r,s,i){const o=this;let a=0,l;return u;function u(f){return t.enter(r),t.enter(s),t.consume(f),t.exit(s),t.enter(i),c}function c(f){return a>999||f===null||f===91||f===93&&!l||f===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(f):f===93?(t.exit(i),t.enter(s),t.consume(f),t.exit(s),t.exit(r),e):Z(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),c):(t.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===null||f===91||f===93||Z(f)||a++>999?(t.exit("chunkString"),c(f)):(t.consume(f),l||(l=!se(f)),f===92?h:d)}function h(f){return f===91||f===92||f===93?(t.consume(f),a++,d):d(f)}}function IS(t,e,n,r,s,i){let o;return a;function a(h){return h===34||h===39||h===40?(t.enter(r),t.enter(s),t.consume(h),t.exit(s),o=h===40?41:h,l):n(h)}function l(h){return h===o?(t.enter(s),t.consume(h),t.exit(s),t.exit(r),e):(t.enter(i),u(h))}function u(h){return h===o?(t.exit(i),l(o)):h===null?n(h):Z(h)?(t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),le(t,u,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),c(h))}function c(h){return h===o||h===null||Z(h)?(t.exit("chunkString"),u(h)):(t.consume(h),h===92?d:c)}function d(h){return h===o||h===92?(t.consume(h),c):c(h)}}function Pi(t,e){let n;return r;function r(s){return Z(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),n=!0,r):se(s)?le(t,r,n?"linePrefix":"lineSuffix")(s):e(s)}}const qL={name:"definition",tokenize:WL},GL={partial:!0,tokenize:QL};function WL(t,e,n){const r=this;let s;return i;function i(f){return t.enter("definition"),o(f)}function o(f){return CS.call(r,t,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function a(f){return s=sn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(t.enter("definitionMarker"),t.consume(f),t.exit("definitionMarker"),l):n(f)}function l(f){return ye(f)?Pi(t,u)(f):u(f)}function u(f){return kS(t,c,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function c(f){return t.attempt(GL,d,d)(f)}function d(f){return se(f)?le(t,h,"whitespace")(f):h(f)}function h(f){return f===null||Z(f)?(t.exit("definition"),r.parser.defined.push(s),e(f)):n(f)}}function QL(t,e,n){return r;function r(a){return ye(a)?Pi(t,s)(a):n(a)}function s(a){return IS(t,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return se(a)?le(t,o,"whitespace")(a):o(a)}function o(a){return a===null||Z(a)?e(a):n(a)}}const KL={name:"hardBreakEscape",tokenize:YL};function YL(t,e,n){return r;function r(i){return t.enter("hardBreakEscape"),t.consume(i),s}function s(i){return Z(i)?(t.exit("hardBreakEscape"),e(i)):n(i)}}const JL={name:"headingAtx",resolve:XL,tokenize:ZL};function XL(t,e){let n=t.length-2,r=3,s,i;return t[r][1].type==="whitespace"&&(r+=2),n-2>r&&t[n][1].type==="whitespace"&&(n-=2),t[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&t[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:t[r][1].start,end:t[n][1].end},i={type:"chunkText",start:t[r][1].start,end:t[n][1].end,contentType:"text"},bt(t,r,n-r+1,[["enter",s,e],["enter",i,e],["exit",i,e],["exit",s,e]])),t}function ZL(t,e,n){let r=0;return s;function s(c){return t.enter("atxHeading"),i(c)}function i(c){return t.enter("atxHeadingSequence"),o(c)}function o(c){return c===35&&r++<6?(t.consume(c),o):c===null||ye(c)?(t.exit("atxHeadingSequence"),a(c)):n(c)}function a(c){return c===35?(t.enter("atxHeadingSequence"),l(c)):c===null||Z(c)?(t.exit("atxHeading"),e(c)):se(c)?le(t,a,"whitespace")(c):(t.enter("atxHeadingText"),u(c))}function l(c){return c===35?(t.consume(c),l):(t.exit("atxHeadingSequence"),a(c))}function u(c){return c===null||c===35||ye(c)?(t.exit("atxHeadingText"),a(c)):(t.consume(c),u)}}const ej=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],gy=["pre","script","style","textarea"],tj={concrete:!0,name:"htmlFlow",resolveTo:sj,tokenize:ij},nj={partial:!0,tokenize:aj},rj={partial:!0,tokenize:oj};function sj(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function ij(t,e,n){const r=this;let s,i,o,a,l;return u;function u(E){return c(E)}function c(E){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(E),d}function d(E){return E===33?(t.consume(E),h):E===47?(t.consume(E),i=!0,g):E===63?(t.consume(E),s=3,r.interrupt?e:C):tt(E)?(t.consume(E),o=String.fromCharCode(E),_):n(E)}function h(E){return E===45?(t.consume(E),s=2,f):E===91?(t.consume(E),s=5,a=0,p):tt(E)?(t.consume(E),s=4,r.interrupt?e:C):n(E)}function f(E){return E===45?(t.consume(E),r.interrupt?e:C):n(E)}function p(E){const q="CDATA[";return E===q.charCodeAt(a++)?(t.consume(E),a===q.length?r.interrupt?e:R:p):n(E)}function g(E){return tt(E)?(t.consume(E),o=String.fromCharCode(E),_):n(E)}function _(E){if(E===null||E===47||E===62||ye(E)){const q=E===47,X=o.toLowerCase();return!q&&!i&&gy.includes(X)?(s=1,r.interrupt?e(E):R(E)):ej.includes(o.toLowerCase())?(s=6,q?(t.consume(E),m):r.interrupt?e(E):R(E)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(E):i?y(E):v(E))}return E===45||Ke(E)?(t.consume(E),o+=String.fromCharCode(E),_):n(E)}function m(E){return E===62?(t.consume(E),r.interrupt?e:R):n(E)}function y(E){return se(E)?(t.consume(E),y):x(E)}function v(E){return E===47?(t.consume(E),x):E===58||E===95||tt(E)?(t.consume(E),S):se(E)?(t.consume(E),v):x(E)}function S(E){return E===45||E===46||E===58||E===95||Ke(E)?(t.consume(E),S):I(E)}function I(E){return E===61?(t.consume(E),b):se(E)?(t.consume(E),I):v(E)}function b(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(t.consume(E),l=E,P):se(E)?(t.consume(E),b):A(E)}function P(E){return E===l?(t.consume(E),l=null,D):E===null||Z(E)?n(E):(t.consume(E),P)}function A(E){return E===null||E===34||E===39||E===47||E===60||E===61||E===62||E===96||ye(E)?I(E):(t.consume(E),A)}function D(E){return E===47||E===62||se(E)?v(E):n(E)}function x(E){return E===62?(t.consume(E),k):n(E)}function k(E){return E===null||Z(E)?R(E):se(E)?(t.consume(E),k):n(E)}function R(E){return E===45&&s===2?(t.consume(E),W):E===60&&s===1?(t.consume(E),K):E===62&&s===4?(t.consume(E),Y):E===63&&s===3?(t.consume(E),C):E===93&&s===5?(t.consume(E),U):Z(E)&&(s===6||s===7)?(t.exit("htmlFlowData"),t.check(nj,j,M)(E)):E===null||Z(E)?(t.exit("htmlFlowData"),M(E)):(t.consume(E),R)}function M(E){return t.check(rj,L,j)(E)}function L(E){return t.enter("lineEnding"),t.consume(E),t.exit("lineEnding"),z}function z(E){return E===null||Z(E)?M(E):(t.enter("htmlFlowData"),R(E))}function W(E){return E===45?(t.consume(E),C):R(E)}function K(E){return E===47?(t.consume(E),o="",$):R(E)}function $(E){if(E===62){const q=o.toLowerCase();return gy.includes(q)?(t.consume(E),Y):R(E)}return tt(E)&&o.length<8?(t.consume(E),o+=String.fromCharCode(E),$):R(E)}function U(E){return E===93?(t.consume(E),C):R(E)}function C(E){return E===62?(t.consume(E),Y):E===45&&s===2?(t.consume(E),C):R(E)}function Y(E){return E===null||Z(E)?(t.exit("htmlFlowData"),j(E)):(t.consume(E),Y)}function j(E){return t.exit("htmlFlow"),e(E)}}function oj(t,e,n){const r=this;return s;function s(o){return Z(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),i):n(o)}function i(o){return r.parser.lazy[r.now().line]?n(o):e(o)}}function aj(t,e,n){return r;function r(s){return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),t.attempt(Io,e,n)}}const lj={name:"htmlText",tokenize:uj};function uj(t,e,n){const r=this;let s,i,o;return a;function a(C){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(C),l}function l(C){return C===33?(t.consume(C),u):C===47?(t.consume(C),I):C===63?(t.consume(C),v):tt(C)?(t.consume(C),A):n(C)}function u(C){return C===45?(t.consume(C),c):C===91?(t.consume(C),i=0,p):tt(C)?(t.consume(C),y):n(C)}function c(C){return C===45?(t.consume(C),f):n(C)}function d(C){return C===null?n(C):C===45?(t.consume(C),h):Z(C)?(o=d,K(C)):(t.consume(C),d)}function h(C){return C===45?(t.consume(C),f):d(C)}function f(C){return C===62?W(C):C===45?h(C):d(C)}function p(C){const Y="CDATA[";return C===Y.charCodeAt(i++)?(t.consume(C),i===Y.length?g:p):n(C)}function g(C){return C===null?n(C):C===93?(t.consume(C),_):Z(C)?(o=g,K(C)):(t.consume(C),g)}function _(C){return C===93?(t.consume(C),m):g(C)}function m(C){return C===62?W(C):C===93?(t.consume(C),m):g(C)}function y(C){return C===null||C===62?W(C):Z(C)?(o=y,K(C)):(t.consume(C),y)}function v(C){return C===null?n(C):C===63?(t.consume(C),S):Z(C)?(o=v,K(C)):(t.consume(C),v)}function S(C){return C===62?W(C):v(C)}function I(C){return tt(C)?(t.consume(C),b):n(C)}function b(C){return C===45||Ke(C)?(t.consume(C),b):P(C)}function P(C){return Z(C)?(o=P,K(C)):se(C)?(t.consume(C),P):W(C)}function A(C){return C===45||Ke(C)?(t.consume(C),A):C===47||C===62||ye(C)?D(C):n(C)}function D(C){return C===47?(t.consume(C),W):C===58||C===95||tt(C)?(t.consume(C),x):Z(C)?(o=D,K(C)):se(C)?(t.consume(C),D):W(C)}function x(C){return C===45||C===46||C===58||C===95||Ke(C)?(t.consume(C),x):k(C)}function k(C){return C===61?(t.consume(C),R):Z(C)?(o=k,K(C)):se(C)?(t.consume(C),k):D(C)}function R(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(t.consume(C),s=C,M):Z(C)?(o=R,K(C)):se(C)?(t.consume(C),R):(t.consume(C),L)}function M(C){return C===s?(t.consume(C),s=void 0,z):C===null?n(C):Z(C)?(o=M,K(C)):(t.consume(C),M)}function L(C){return C===null||C===34||C===39||C===60||C===61||C===96?n(C):C===47||C===62||ye(C)?D(C):(t.consume(C),L)}function z(C){return C===47||C===62||ye(C)?D(C):n(C)}function W(C){return C===62?(t.consume(C),t.exit("htmlTextData"),t.exit("htmlText"),e):n(C)}function K(C){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(C),t.exit("lineEnding"),$}function $(C){return se(C)?le(t,U,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):U(C)}function U(C){return t.enter("htmlTextData"),o(C)}}const Yf={name:"labelEnd",resolveAll:fj,resolveTo:pj,tokenize:mj},cj={tokenize:gj},dj={tokenize:yj},hj={tokenize:vj};function fj(t){let e=-1;const n=[];for(;++e<t.length;){const r=t[e][1];if(n.push(t[e]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",e+=s}}return t.length!==n.length&&bt(t,0,t.length,n),t}function pj(t,e){let n=t.length,r=0,s,i,o,a;for(;n--;)if(s=t[n][1],i){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;t[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(o){if(t[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(i=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(o=n);const l={type:t[i][1].type==="labelLink"?"link":"image",start:{...t[i][1].start},end:{...t[t.length-1][1].end}},u={type:"label",start:{...t[i][1].start},end:{...t[o][1].end}},c={type:"labelText",start:{...t[i+r+2][1].end},end:{...t[o-2][1].start}};return a=[["enter",l,e],["enter",u,e]],a=Ot(a,t.slice(i+1,i+r+3)),a=Ot(a,[["enter",c,e]]),a=Ot(a,ql(e.parser.constructs.insideSpan.null,t.slice(i+r+4,o-3),e)),a=Ot(a,[["exit",c,e],t[o-2],t[o-1],["exit",u,e]]),a=Ot(a,t.slice(o+1)),a=Ot(a,[["exit",l,e]]),bt(t,i,t.length,a),t}function mj(t,e,n){const r=this;let s=r.events.length,i,o;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){i=r.events[s][1];break}return a;function a(h){return i?i._inactive?d(h):(o=r.parser.defined.includes(sn(r.sliceSerialize({start:i.end,end:r.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(h),t.exit("labelMarker"),t.exit("labelEnd"),l):n(h)}function l(h){return h===40?t.attempt(cj,c,o?c:d)(h):h===91?t.attempt(dj,c,o?u:d)(h):o?c(h):d(h)}function u(h){return t.attempt(hj,c,d)(h)}function c(h){return e(h)}function d(h){return i._balanced=!0,n(h)}}function gj(t,e,n){return r;function r(d){return t.enter("resource"),t.enter("resourceMarker"),t.consume(d),t.exit("resourceMarker"),s}function s(d){return ye(d)?Pi(t,i)(d):i(d)}function i(d){return d===41?c(d):kS(t,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return ye(d)?Pi(t,l)(d):c(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?IS(t,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):c(d)}function u(d){return ye(d)?Pi(t,c)(d):c(d)}function c(d){return d===41?(t.enter("resourceMarker"),t.consume(d),t.exit("resourceMarker"),t.exit("resource"),e):n(d)}}function yj(t,e,n){const r=this;return s;function s(a){return CS.call(r,t,i,o,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes(sn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(a):n(a)}function o(a){return n(a)}}function vj(t,e,n){return r;function r(i){return t.enter("reference"),t.enter("referenceMarker"),t.consume(i),t.exit("referenceMarker"),s}function s(i){return i===93?(t.enter("referenceMarker"),t.consume(i),t.exit("referenceMarker"),t.exit("reference"),e):n(i)}}const _j={name:"labelStartImage",resolveAll:Yf.resolveAll,tokenize:wj};function wj(t,e,n){const r=this;return s;function s(a){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(a),t.exit("labelImageMarker"),i}function i(a){return a===91?(t.enter("labelMarker"),t.consume(a),t.exit("labelMarker"),t.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):e(a)}}const xj={name:"labelStartLink",resolveAll:Yf.resolveAll,tokenize:Sj};function Sj(t,e,n){const r=this;return s;function s(o){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(o),t.exit("labelMarker"),t.exit("labelLink"),i}function i(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):e(o)}}const Zu={name:"lineEnding",tokenize:bj};function bj(t,e){return n;function n(r){return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),le(t,e,"linePrefix")}}const ba={name:"thematicBreak",tokenize:Tj};function Tj(t,e,n){let r=0,s;return i;function i(u){return t.enter("thematicBreak"),o(u)}function o(u){return s=u,a(u)}function a(u){return u===s?(t.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||Z(u))?(t.exit("thematicBreak"),e(u)):n(u)}function l(u){return u===s?(t.consume(u),r++,l):(t.exit("thematicBreakSequence"),se(u)?le(t,a,"whitespace")(u):a(u))}}const ot={continuation:{tokenize:Ej},exit:Aj,name:"list",tokenize:Ij},kj={partial:!0,tokenize:Pj},Cj={partial:!0,tokenize:Rj};function Ij(t,e,n){const r=this,s=r.events[r.events.length-1];let i=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,o=0;return a;function a(f){const p=r.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(p==="listUnordered"?!r.containerState.marker||f===r.containerState.marker:Nd(f)){if(r.containerState.type||(r.containerState.type=p,t.enter(p,{_container:!0})),p==="listUnordered")return t.enter("listItemPrefix"),f===42||f===45?t.check(ba,n,u)(f):u(f);if(!r.interrupt||f===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),l(f)}return n(f)}function l(f){return Nd(f)&&++o<10?(t.consume(f),l):(!r.interrupt||o<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(t.exit("listItemValue"),u(f)):n(f)}function u(f){return t.enter("listItemMarker"),t.consume(f),t.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||f,t.check(Io,r.interrupt?n:c,t.attempt(kj,h,d))}function c(f){return r.containerState.initialBlankLine=!0,i++,h(f)}function d(f){return se(f)?(t.enter("listItemPrefixWhitespace"),t.consume(f),t.exit("listItemPrefixWhitespace"),h):n(f)}function h(f){return r.containerState.size=i+r.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(f)}}function Ej(t,e,n){const r=this;return r.containerState._closeFlow=void 0,t.check(Io,s,i);function s(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,le(t,e,"listItemIndent",r.containerState.size+1)(a)}function i(a){return r.containerState.furtherBlankLines||!se(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,t.attempt(Cj,e,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,le(t,t.attempt(ot,e,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Rj(t,e,n){const r=this;return le(t,s,"listItemIndent",r.containerState.size+1);function s(i){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?e(i):n(i)}}function Aj(t){t.exit(this.containerState.type)}function Pj(t,e,n){const r=this;return le(t,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(i){const o=r.events[r.events.length-1];return!se(i)&&o&&o[1].type==="listItemPrefixWhitespace"?e(i):n(i)}}const yy={name:"setextUnderline",resolveTo:Mj,tokenize:Dj};function Mj(t,e){let n=t.length,r,s,i;for(;n--;)if(t[n][0]==="enter"){if(t[n][1].type==="content"){r=n;break}t[n][1].type==="paragraph"&&(s=n)}else t[n][1].type==="content"&&t.splice(n,1),!i&&t[n][1].type==="definition"&&(i=n);const o={type:"setextHeading",start:{...t[r][1].start},end:{...t[t.length-1][1].end}};return t[s][1].type="setextHeadingText",i?(t.splice(s,0,["enter",o,e]),t.splice(i+1,0,["exit",t[r][1],e]),t[r][1].end={...t[i][1].end}):t[r][1]=o,t.push(["exit",o,e]),t}function Dj(t,e,n){const r=this;let s;return i;function i(u){let c=r.events.length,d;for(;c--;)if(r.events[c][1].type!=="lineEnding"&&r.events[c][1].type!=="linePrefix"&&r.events[c][1].type!=="content"){d=r.events[c][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(t.enter("setextHeadingLine"),s=u,o(u)):n(u)}function o(u){return t.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===s?(t.consume(u),a):(t.exit("setextHeadingLineSequence"),se(u)?le(t,l,"lineSuffix")(u):l(u))}function l(u){return u===null||Z(u)?(t.exit("setextHeadingLine"),e(u)):n(u)}}const Oj={tokenize:Nj};function Nj(t){const e=this,n=t.attempt(Io,r,t.attempt(this.parser.constructs.flowInitial,s,le(t,t.attempt(this.parser.constructs.flow,s,t.attempt(FL,s)),"linePrefix")));return n;function r(i){if(i===null){t.consume(i);return}return t.enter("lineEndingBlank"),t.consume(i),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n}function s(i){if(i===null){t.consume(i);return}return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),e.currentConstruct=void 0,n}}const Lj={resolveAll:RS()},jj=ES("string"),$j=ES("text");function ES(t){return{resolveAll:RS(t==="text"?zj:void 0),tokenize:e};function e(n){const r=this,s=this.parser.constructs[t],i=n.attempt(s,o,a);return o;function o(c){return u(c)?i(c):a(c)}function a(c){if(c===null){n.consume(c);return}return n.enter("data"),n.consume(c),l}function l(c){return u(c)?(n.exit("data"),i(c)):(n.consume(c),l)}function u(c){if(c===null)return!0;const d=s[c];let h=-1;if(d)for(;++h<d.length;){const f=d[h];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function RS(t){return e;function e(n,r){let s=-1,i;for(;++s<=n.length;)i===void 0?n[s]&&n[s][1].type==="data"&&(i=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==i+2&&(n[i][1].end=n[s-1][1].end,n.splice(i+2,s-i-2),s=i+2),i=void 0);return t?t(n,r):n}}function zj(t,e){let n=0;for(;++n<=t.length;)if((n===t.length||t[n][1].type==="lineEnding")&&t[n-1][1].type==="data"){const r=t[n-1][1],s=e.sliceStream(r);let i=s.length,o=-1,a=0,l;for(;i--;){const u=s[i];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(u===-2)l=!0,a++;else if(u!==-1){i++;break}}if(e._contentTypeTextTrailing&&n===t.length&&(a=0),a){const u={type:n===t.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?o:r.start._bufferIndex+o,_index:r.start._index+i,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(t.splice(n,0,["enter",u,e],["exit",u,e]),n+=2)}n++}return t}const Fj={42:ot,43:ot,45:ot,48:ot,49:ot,50:ot,51:ot,52:ot,53:ot,54:ot,55:ot,56:ot,57:ot,62:xS},Bj={91:qL},Uj={[-2]:Xu,[-1]:Xu,32:Xu},Vj={35:JL,42:ba,45:[yy,ba],60:tj,61:yy,95:ba,96:my,126:my},Hj={38:bS,92:SS},qj={[-5]:Zu,[-4]:Zu,[-3]:Zu,33:_j,38:bS,42:Ld,60:[xL,lj],91:xj,92:[KL,SS],93:Yf,95:Ld,96:OL},Gj={null:[Ld,Lj]},Wj={null:[42,95]},Qj={null:[]},Kj=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Wj,contentInitial:Bj,disable:Qj,document:Fj,flow:Vj,flowInitial:Uj,insideSpan:Gj,string:Hj,text:qj},Symbol.toStringTag,{value:"Module"}));function Yj(t,e,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},i=[];let o=[],a=[];const l={attempt:P(I),check:P(b),consume:y,enter:v,exit:S,interrupt:P(b,{interrupt:!0})},u={code:null,containerState:{},defineSkip:g,events:[],now:p,parser:t,previous:null,sliceSerialize:h,sliceStream:f,write:d};let c=e.tokenize.call(u,l);return e.resolveAll&&i.push(e),u;function d(k){return o=Ot(o,k),_(),o[o.length-1]!==null?[]:(A(e,0),u.events=ql(i,u.events,u),u.events)}function h(k,R){return Xj(f(k),R)}function f(k){return Jj(o,k)}function p(){const{_bufferIndex:k,_index:R,line:M,column:L,offset:z}=r;return{_bufferIndex:k,_index:R,line:M,column:L,offset:z}}function g(k){s[k.line]=k.column,x()}function _(){let k;for(;r._index<o.length;){const R=o[r._index];if(typeof R=="string")for(k=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===k&&r._bufferIndex<R.length;)m(R.charCodeAt(r._bufferIndex));else m(R)}}function m(k){c=c(k)}function y(k){Z(k)?(r.line++,r.column=1,r.offset+=k===-3?2:1,x()):k!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=k}function v(k,R){const M=R||{};return M.type=k,M.start=p(),u.events.push(["enter",M,u]),a.push(M),M}function S(k){const R=a.pop();return R.end=p(),u.events.push(["exit",R,u]),R}function I(k,R){A(k,R.from)}function b(k,R){R.restore()}function P(k,R){return M;function M(L,z,W){let K,$,U,C;return Array.isArray(L)?j(L):"tokenize"in L?j([L]):Y(L);function Y(V){return he;function he(Ae){const pt=Ae!==null&&V[Ae],Vt=Ae!==null&&V.null,un=[...Array.isArray(pt)?pt:pt?[pt]:[],...Array.isArray(Vt)?Vt:Vt?[Vt]:[]];return j(un)(Ae)}}function j(V){return K=V,$=0,V.length===0?W:E(V[$])}function E(V){return he;function he(Ae){return C=D(),U=V,V.partial||(u.currentConstruct=V),V.name&&u.parser.constructs.disable.null.includes(V.name)?X():V.tokenize.call(R?Object.assign(Object.create(u),R):u,l,q,X)(Ae)}}function q(V){return k(U,C),z}function X(V){return C.restore(),++$<K.length?E(K[$]):W}}}function A(k,R){k.resolveAll&&!i.includes(k)&&i.push(k),k.resolve&&bt(u.events,R,u.events.length-R,k.resolve(u.events.slice(R),u)),k.resolveTo&&(u.events=k.resolveTo(u.events,u))}function D(){const k=p(),R=u.previous,M=u.currentConstruct,L=u.events.length,z=Array.from(a);return{from:L,restore:W};function W(){r=k,u.previous=R,u.currentConstruct=M,u.events.length=L,a=z,x()}}function x(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function Jj(t,e){const n=e.start._index,r=e.start._bufferIndex,s=e.end._index,i=e.end._bufferIndex;let o;if(n===s)o=[t[n].slice(r,i)];else{if(o=t.slice(n,s),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}i>0&&o.push(t[s].slice(0,i))}return o}function Xj(t,e){let n=-1;const r=[];let s;for(;++n<t.length;){const i=t[n];let o;if(typeof i=="string")o=i;else switch(i){case-5:{o="\r";break}case-4:{o=`
52
+ `;break}case-3:{o=`\r
53
+ `;break}case-2:{o=e?" ":" ";break}case-1:{if(!e&&s)continue;o=" ";break}default:o=String.fromCharCode(i)}s=i===-2,r.push(o)}return r.join("")}function Zj(t){const r={constructs:_S([Kj,...(t||{}).extensions||[]]),content:s(pL),defined:[],document:s(gL),flow:s(Oj),lazy:{},string:s(jj),text:s($j)};return r;function s(i){return o;function o(a){return Yj(r,i,a)}}}function e$(t){for(;!TS(t););return t}const vy=/[\0\t\n\r]/g;function t$(){let t=1,e="",n=!0,r;return s;function s(i,o,a){const l=[];let u,c,d,h,f;for(i=e+(typeof i=="string"?i.toString():new TextDecoder(o||void 0).decode(i)),d=0,e="",n&&(i.charCodeAt(0)===65279&&d++,n=void 0);d<i.length;){if(vy.lastIndex=d,u=vy.exec(i),h=u&&u.index!==void 0?u.index:i.length,f=i.charCodeAt(h),!u){e=i.slice(d);break}if(f===10&&d===h&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<h&&(l.push(i.slice(d,h)),t+=h-d),f){case 0:{l.push(65533),t++;break}case 9:{for(c=Math.ceil(t/4)*4,l.push(-2);t++<c;)l.push(-1);break}case 10:{l.push(-4),t=1;break}default:r=!0,t=1}d=h+1}return a&&(r&&l.push(-5),e&&l.push(e),l.push(null)),l}}const n$=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function r$(t){return t.replace(n$,s$)}function s$(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return wS(n.slice(i?2:1),i?16:10)}return Kf(n)||t}const AS={}.hasOwnProperty;function i$(t,e,n){return e&&typeof e=="object"&&(n=e,e=void 0),o$(n)(e$(Zj(n).document().write(t$()(t,e,!0))))}function o$(t){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(up),autolinkProtocol:D,autolinkEmail:D,atxHeading:i(op),blockQuote:i(Vt),characterEscape:D,characterReference:D,codeFenced:i(un),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:i(un,o),codeText:i(Kl,o),codeTextData:D,data:D,codeFlowValue:D,definition:i(Yl),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:i(pb),hardBreakEscape:i(ap),hardBreakTrailing:i(ap),htmlFlow:i(lp,o),htmlFlowData:D,htmlText:i(lp,o),htmlTextData:D,image:i(mb),label:o,link:i(up),listItem:i(gb),listItemValue:h,listOrdered:i(cp,d),listUnordered:i(cp),paragraph:i(yb),reference:E,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:i(op),strong:i(vb),thematicBreak:i(wb)},exit:{atxHeading:l(),atxHeadingSequence:I,autolink:l(),autolinkEmail:pt,autolinkProtocol:Ae,blockQuote:l(),characterEscapeValue:x,characterReferenceMarkerHexadecimal:X,characterReferenceMarkerNumeric:X,characterReferenceValue:V,characterReference:he,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:f,codeFencedFenceMeta:p,codeFlowValue:x,codeIndented:l(m),codeText:l(z),codeTextData:x,data:x,definition:l(),definitionDestinationString:S,definitionLabelString:y,definitionTitleString:v,emphasis:l(),hardBreakEscape:l(R),hardBreakTrailing:l(R),htmlFlow:l(M),htmlFlowData:x,htmlText:l(L),htmlTextData:x,image:l(K),label:U,labelText:$,lineEnding:k,link:l(W),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:q,resourceDestinationString:C,resourceTitleString:Y,resource:j,setextHeading:l(A),setextHeadingLineSequence:P,setextHeadingText:b,strong:l(),thematicBreak:l()}};PS(e,(t||{}).mdastExtensions||[]);const n={};return r;function r(N){let H={type:"root",children:[]};const re={stack:[H],tokenStack:[],config:e,enter:a,exit:u,buffer:o,resume:c,data:n},ae=[];let pe=-1;for(;++pe<N.length;)if(N[pe][1].type==="listOrdered"||N[pe][1].type==="listUnordered")if(N[pe][0]==="enter")ae.push(pe);else{const Ht=ae.pop();pe=s(N,Ht,pe)}for(pe=-1;++pe<N.length;){const Ht=e[N[pe][0]];AS.call(Ht,N[pe][1].type)&&Ht[N[pe][1].type].call(Object.assign({sliceSerialize:N[pe][2].sliceSerialize},re),N[pe][1])}if(re.tokenStack.length>0){const Ht=re.tokenStack[re.tokenStack.length-1];(Ht[1]||_y).call(re,void 0,Ht[0])}for(H.position={start:Un(N.length>0?N[0][1].start:{line:1,column:1,offset:0}),end:Un(N.length>0?N[N.length-2][1].end:{line:1,column:1,offset:0})},pe=-1;++pe<e.transforms.length;)H=e.transforms[pe](H)||H;return H}function s(N,H,re){let ae=H-1,pe=-1,Ht=!1,mr,Sn,Ks,Ys;for(;++ae<=re;){const mt=N[ae];switch(mt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{mt[0]==="enter"?pe++:pe--,Ys=void 0;break}case"lineEndingBlank":{mt[0]==="enter"&&(mr&&!Ys&&!pe&&!Ks&&(Ks=ae),Ys=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ys=void 0}if(!pe&&mt[0]==="enter"&&mt[1].type==="listItemPrefix"||pe===-1&&mt[0]==="exit"&&(mt[1].type==="listUnordered"||mt[1].type==="listOrdered")){if(mr){let es=ae;for(Sn=void 0;es--;){const bn=N[es];if(bn[1].type==="lineEnding"||bn[1].type==="lineEndingBlank"){if(bn[0]==="exit")continue;Sn&&(N[Sn][1].type="lineEndingBlank",Ht=!0),bn[1].type="lineEnding",Sn=es}else if(!(bn[1].type==="linePrefix"||bn[1].type==="blockQuotePrefix"||bn[1].type==="blockQuotePrefixWhitespace"||bn[1].type==="blockQuoteMarker"||bn[1].type==="listItemIndent"))break}Ks&&(!Sn||Ks<Sn)&&(mr._spread=!0),mr.end=Object.assign({},Sn?N[Sn][1].start:mt[1].end),N.splice(Sn||ae,0,["exit",mr,mt[2]]),ae++,re++}if(mt[1].type==="listItemPrefix"){const es={type:"listItem",_spread:!1,start:Object.assign({},mt[1].start),end:void 0};mr=es,N.splice(ae,0,["enter",es,mt[2]]),ae++,re++,Ks=void 0,Ys=!0}}}return N[H][1]._spread=Ht,re}function i(N,H){return re;function re(ae){a.call(this,N(ae),ae),H&&H.call(this,ae)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(N,H,re){this.stack[this.stack.length-1].children.push(N),this.stack.push(N),this.tokenStack.push([H,re||void 0]),N.position={start:Un(H.start),end:void 0}}function l(N){return H;function H(re){N&&N.call(this,re),u.call(this,re)}}function u(N,H){const re=this.stack.pop(),ae=this.tokenStack.pop();if(ae)ae[0].type!==N.type&&(H?H.call(this,N,ae[0]):(ae[1]||_y).call(this,N,ae[0]));else throw new Error("Cannot close `"+N.type+"` ("+Ai({start:N.start,end:N.end})+"): it’s not open");re.position.end=Un(N.end)}function c(){return Qf(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function h(N){if(this.data.expectingFirstListItemValue){const H=this.stack[this.stack.length-2];H.start=Number.parseInt(this.sliceSerialize(N),10),this.data.expectingFirstListItemValue=void 0}}function f(){const N=this.resume(),H=this.stack[this.stack.length-1];H.lang=N}function p(){const N=this.resume(),H=this.stack[this.stack.length-1];H.meta=N}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){const N=this.resume(),H=this.stack[this.stack.length-1];H.value=N.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function m(){const N=this.resume(),H=this.stack[this.stack.length-1];H.value=N.replace(/(\r?\n|\r)$/g,"")}function y(N){const H=this.resume(),re=this.stack[this.stack.length-1];re.label=H,re.identifier=sn(this.sliceSerialize(N)).toLowerCase()}function v(){const N=this.resume(),H=this.stack[this.stack.length-1];H.title=N}function S(){const N=this.resume(),H=this.stack[this.stack.length-1];H.url=N}function I(N){const H=this.stack[this.stack.length-1];if(!H.depth){const re=this.sliceSerialize(N).length;H.depth=re}}function b(){this.data.setextHeadingSlurpLineEnding=!0}function P(N){const H=this.stack[this.stack.length-1];H.depth=this.sliceSerialize(N).codePointAt(0)===61?1:2}function A(){this.data.setextHeadingSlurpLineEnding=void 0}function D(N){const re=this.stack[this.stack.length-1].children;let ae=re[re.length-1];(!ae||ae.type!=="text")&&(ae=_b(),ae.position={start:Un(N.start),end:void 0},re.push(ae)),this.stack.push(ae)}function x(N){const H=this.stack.pop();H.value+=this.sliceSerialize(N),H.position.end=Un(N.end)}function k(N){const H=this.stack[this.stack.length-1];if(this.data.atHardBreak){const re=H.children[H.children.length-1];re.position.end=Un(N.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(H.type)&&(D.call(this,N),x.call(this,N))}function R(){this.data.atHardBreak=!0}function M(){const N=this.resume(),H=this.stack[this.stack.length-1];H.value=N}function L(){const N=this.resume(),H=this.stack[this.stack.length-1];H.value=N}function z(){const N=this.resume(),H=this.stack[this.stack.length-1];H.value=N}function W(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const H=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=H,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function K(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const H=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=H,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function $(N){const H=this.sliceSerialize(N),re=this.stack[this.stack.length-2];re.label=r$(H),re.identifier=sn(H).toLowerCase()}function U(){const N=this.stack[this.stack.length-1],H=this.resume(),re=this.stack[this.stack.length-1];if(this.data.inReference=!0,re.type==="link"){const ae=N.children;re.children=ae}else re.alt=H}function C(){const N=this.resume(),H=this.stack[this.stack.length-1];H.url=N}function Y(){const N=this.resume(),H=this.stack[this.stack.length-1];H.title=N}function j(){this.data.inReference=void 0}function E(){this.data.referenceType="collapsed"}function q(N){const H=this.resume(),re=this.stack[this.stack.length-1];re.label=H,re.identifier=sn(this.sliceSerialize(N)).toLowerCase(),this.data.referenceType="full"}function X(N){this.data.characterReferenceType=N.type}function V(N){const H=this.sliceSerialize(N),re=this.data.characterReferenceType;let ae;re?(ae=wS(H,re==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ae=Kf(H);const pe=this.stack[this.stack.length-1];pe.value+=ae}function he(N){const H=this.stack.pop();H.position.end=Un(N.end)}function Ae(N){x.call(this,N);const H=this.stack[this.stack.length-1];H.url=this.sliceSerialize(N)}function pt(N){x.call(this,N);const H=this.stack[this.stack.length-1];H.url="mailto:"+this.sliceSerialize(N)}function Vt(){return{type:"blockquote",children:[]}}function un(){return{type:"code",lang:null,meta:null,value:""}}function Kl(){return{type:"inlineCode",value:""}}function Yl(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function pb(){return{type:"emphasis",children:[]}}function op(){return{type:"heading",depth:0,children:[]}}function ap(){return{type:"break"}}function lp(){return{type:"html",value:""}}function mb(){return{type:"image",title:null,url:"",alt:null}}function up(){return{type:"link",title:null,url:"",children:[]}}function cp(N){return{type:"list",ordered:N.type==="listOrdered",start:null,spread:N._spread,children:[]}}function gb(N){return{type:"listItem",spread:N._spread,checked:null,children:[]}}function yb(){return{type:"paragraph",children:[]}}function vb(){return{type:"strong",children:[]}}function _b(){return{type:"text",value:""}}function wb(){return{type:"thematicBreak"}}}function Un(t){return{line:t.line,column:t.column,offset:t.offset}}function PS(t,e){let n=-1;for(;++n<e.length;){const r=e[n];Array.isArray(r)?PS(t,r):a$(t,r)}}function a$(t,e){let n;for(n in e)if(AS.call(e,n))switch(n){case"canContainEols":{const r=e[n];r&&t[n].push(...r);break}case"transforms":{const r=e[n];r&&t[n].push(...r);break}case"enter":case"exit":{const r=e[n];r&&Object.assign(t[n],r);break}}}function _y(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+Ai({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+Ai({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+Ai({start:e.start,end:e.end})+") is still open")}function l$(t){const e=this;e.parser=n;function n(r){return i$(r,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function u$(t,e){const n={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,n),t.applyData(e,n)}function c$(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:`
54
+ `}]}function d$(t,e){const n=e.value?e.value+`
55
+ `:"",r={},s=e.lang?e.lang.split(/\s+/):[];s.length>0&&(r.className=["language-"+s[0]]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return e.meta&&(i.data={meta:e.meta}),t.patch(e,i),i=t.applyData(e,i),i={type:"element",tagName:"pre",properties:{},children:[i]},t.patch(e,i),i}function h$(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function f$(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function p$(t,e){const n=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",r=String(e.identifier).toUpperCase(),s=Qs(r.toLowerCase()),i=t.footnoteOrder.indexOf(r);let o,a=t.footnoteCounts.get(r);a===void 0?(a=0,t.footnoteOrder.push(r),o=t.footnoteOrder.length):o=i+1,a+=1,t.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+s,id:n+"fnref-"+s+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};t.patch(e,l);const u={type:"element",tagName:"sup",properties:{},children:[l]};return t.patch(e,u),t.applyData(e,u)}function m$(t,e){const n={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function g$(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}}function MS(t,e){const n=e.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+r}];const s=t.all(e),i=s[0];i&&i.type==="text"?i.value="["+i.value:s.unshift({type:"text",value:"["});const o=s[s.length-1];return o&&o.type==="text"?o.value+=r:s.push({type:"text",value:r}),s}function y$(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return MS(t,e);const s={src:Qs(r.url||""),alt:e.alt};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"img",properties:s,children:[]};return t.patch(e,i),t.applyData(e,i)}function v$(t,e){const n={src:Qs(e.url)};e.alt!==null&&e.alt!==void 0&&(n.alt=e.alt),e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"img",properties:n,children:[]};return t.patch(e,r),t.applyData(e,r)}function _$(t,e){const n={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return t.patch(e,r),t.applyData(e,r)}function w$(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return MS(t,e);const s={href:Qs(r.url||"")};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"a",properties:s,children:t.all(e)};return t.patch(e,i),t.applyData(e,i)}function x$(t,e){const n={href:Qs(e.url)};e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"a",properties:n,children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function S$(t,e,n){const r=t.all(e),s=n?b$(n):DS(e),i={},o=[];if(typeof e.checked=="boolean"){const c=r[0];let d;c&&c.type==="element"&&c.tagName==="p"?d=c:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const c=r[a];(s||a!==0||c.type!=="element"||c.tagName!=="p")&&o.push({type:"text",value:`
56
+ `}),c.type==="element"&&c.tagName==="p"&&!s?o.push(...c.children):o.push(c)}const l=r[r.length-1];l&&(s||l.type!=="element"||l.tagName!=="p")&&o.push({type:"text",value:`
57
+ `});const u={type:"element",tagName:"li",properties:i,children:o};return t.patch(e,u),t.applyData(e,u)}function b$(t){let e=!1;if(t.type==="list"){e=t.spread||!1;const n=t.children;let r=-1;for(;!e&&++r<n.length;)e=DS(n[r])}return e}function DS(t){const e=t.spread;return e??t.children.length>1}function T$(t,e){const n={},r=t.all(e);let s=-1;for(typeof e.start=="number"&&e.start!==1&&(n.start=e.start);++s<r.length;){const o=r[s];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const i={type:"element",tagName:e.ordered?"ol":"ul",properties:n,children:t.wrap(r,!0)};return t.patch(e,i),t.applyData(e,i)}function k$(t,e){const n={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function C$(t,e){const n={type:"root",children:t.wrap(t.all(e))};return t.patch(e,n),t.applyData(e,n)}function I$(t,e){const n={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function E$(t,e){const n=t.all(e),r=n.shift(),s=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:t.wrap([r],!0)};t.patch(e.children[0],o),s.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:t.wrap(n,!0)},a=Hf(e.children[1]),l=hS(e.children[e.children.length-1]);a&&l&&(o.position={start:a,end:l}),s.push(o)}const i={type:"element",tagName:"table",properties:{},children:t.wrap(s,!0)};return t.patch(e,i),t.applyData(e,i)}function R$(t,e,n){const r=n?n.children:void 0,i=(r?r.indexOf(e):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,a=o?o.length:e.children.length;let l=-1;const u=[];for(;++l<a;){const d=e.children[l],h={},f=o?o[l]:void 0;f&&(h.align=f);let p={type:"element",tagName:i,properties:h,children:[]};d&&(p.children=t.all(d),t.patch(d,p),p=t.applyData(d,p)),u.push(p)}const c={type:"element",tagName:"tr",properties:{},children:t.wrap(u,!0)};return t.patch(e,c),t.applyData(e,c)}function A$(t,e){const n={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}const wy=9,xy=32;function P$(t){const e=String(t),n=/\r?\n|\r/g;let r=n.exec(e),s=0;const i=[];for(;r;)i.push(Sy(e.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(e);return i.push(Sy(e.slice(s),s>0,!1)),i.join("")}function Sy(t,e,n){let r=0,s=t.length;if(e){let i=t.codePointAt(r);for(;i===wy||i===xy;)r++,i=t.codePointAt(r)}if(n){let i=t.codePointAt(s-1);for(;i===wy||i===xy;)s--,i=t.codePointAt(s-1)}return s>r?t.slice(r,s):""}function M$(t,e){const n={type:"text",value:P$(String(e.value))};return t.patch(e,n),t.applyData(e,n)}function D$(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)}const O$={blockquote:u$,break:c$,code:d$,delete:h$,emphasis:f$,footnoteReference:p$,heading:m$,html:g$,imageReference:y$,image:v$,inlineCode:_$,linkReference:w$,link:x$,listItem:S$,list:T$,paragraph:k$,root:C$,strong:I$,table:E$,tableCell:A$,tableRow:R$,text:M$,thematicBreak:D$,toml:ra,yaml:ra,definition:ra,footnoteDefinition:ra};function ra(){}const OS=-1,Gl=0,Mi=1,cl=2,Jf=3,Xf=4,Zf=5,ep=6,NS=7,LS=8,{defineProperty:N$}=Object,jS=typeof self=="object"?self:globalThis,by=(t,e)=>{switch(t){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+t)}return new jS[t](e)},L$=(t,e)=>{const n=(s,i)=>(t.set(i,s),s),r=s=>{if(t.has(s))return t.get(s);const[i,o]=e[s];switch(i){case Gl:case OS:return n(o,s);case Mi:{const a=n([],s);for(const l of o)a.push(r(l));return a}case cl:{const a=n({},s);for(const[l,u]of o){const c=r(l),d=r(u);c==="__proto__"?N$(a,c,{value:d,configurable:!0,enumerable:!0,writable:!0}):a[c]=d}return a}case Jf:return n(new Date(o),s);case Xf:{const{source:a,flags:l}=o;return n(new RegExp(a,l),s)}case Zf:{const a=n(new Map,s);for(const[l,u]of o)a.set(r(l),r(u));return a}case ep:{const a=n(new Set,s);for(const l of o)a.add(r(l));return a}case NS:{const{name:a,message:l}=o;return n(typeof jS[a]=="function"?by(a,l):new Error(l),s)}case LS:return n(BigInt(o),s);case"BigInt":return n(Object(BigInt(o)),s);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:a}=new Uint8Array(o);return n(new DataView(a),o)}case"-0":return-0}return n(by(i,o),s)};return r},Ty=t=>L$(new Map,t)(0),Sr="",{toString:j$}={},{keys:$$,is:z$}=Object,ui=t=>{const e=typeof t;if(e!=="object"||!t)return[Gl,e];const n=j$.call(t).slice(8,-1);switch(n){case"Array":return[Mi,Sr];case"Object":return[cl,Sr];case"Date":return[Jf,Sr];case"RegExp":return[Xf,Sr];case"Map":return[Zf,Sr];case"Set":return[ep,Sr];case"DataView":return[Mi,n]}return n.includes("Array")?[Mi,n]:t instanceof Error?[NS,t.name||"Error"]:[cl,n]},sa=([t,e])=>t===Gl&&(e==="function"||e==="symbol"),F$=(t,e,n,r)=>{const s=(o,a)=>{const l=r.push(o)-1;return n.set(a,l),l},i=o=>{if(n.has(o))return n.get(o);let[a,l]=ui(o);switch(a){case Gl:{let c=o;switch(l){case"bigint":a=LS,c=o.toString();break;case"number":if(!o&&z$(o,-0))return r.push(["-0"])-1;break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+l);c=null;break;case"undefined":return s([OS],o)}return s([a,c],o)}case Mi:{if(l){let h=o;return l==="DataView"?h=new Uint8Array(o.buffer):l==="ArrayBuffer"&&(h=new Uint8Array(o)),s([l,[...h]],o)}const c=[],d=s([a,c],o);for(const h of o)c.push(i(h));return d}case cl:{if(l)switch(l){case"BigInt":return s([l,o.toString()],o);case"Boolean":case"Number":case"String":return s([l,o.valueOf()],o)}if(e&&"toJSON"in o)return i(o.toJSON());const c=[],d=s([a,c],o);for(const h of $$(o))(t||!sa(ui(o[h])))&&c.push([i(h),i(o[h])]);return d}case Jf:return s([a,isNaN(o.getTime())?Sr:o.toISOString()],o);case Xf:{const{source:c,flags:d}=o;return s([a,{source:c,flags:d}],o)}case Zf:{const c=[],d=s([a,c],o);for(const[h,f]of o)(t||!(sa(ui(h))||sa(ui(f))))&&c.push([i(h),i(f)]);return d}case ep:{const c=[],d=s([a,c],o);for(const h of o)(t||!sa(ui(h)))&&c.push(i(h));return d}}const{message:u}=o;return s([a,{name:l,message:u}],o)};return i},ky=(t,{json:e,lossy:n}={})=>{const r=[];return F$(!(e||n),!!e,new Map,r)(t),r},dl=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?Ty(ky(t,e)):structuredClone(t):(t,e)=>Ty(ky(t,e));function B$(t,e){const n=[{type:"text",value:"↩"}];return e>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),n}function U$(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function V$(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=t.options.footnoteBackContent||B$,r=t.options.footnoteBackLabel||U$,s=t.options.footnoteLabel||"Footnotes",i=t.options.footnoteLabelTagName||"h2",o=t.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<t.footnoteOrder.length;){const u=t.footnoteById.get(t.footnoteOrder[l]);if(!u)continue;const c=t.all(u),d=String(u.identifier).toUpperCase(),h=Qs(d.toLowerCase());let f=0;const p=[],g=t.footnoteCounts.get(d);for(;g!==void 0&&++f<=g;){p.length>0&&p.push({type:"text",value:" "});let y=typeof n=="string"?n:n(l,f);typeof y=="string"&&(y={type:"text",value:y}),p.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+h+(f>1?"-"+f:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,f),className:["data-footnote-backref"]},children:Array.isArray(y)?y:[y]})}const _=c[c.length-1];if(_&&_.type==="element"&&_.tagName==="p"){const y=_.children[_.children.length-1];y&&y.type==="text"?y.value+=" ":_.children.push({type:"text",value:" "}),_.children.push(...p)}else c.push(...p);const m={type:"element",tagName:"li",properties:{id:e+"fn-"+h},children:t.wrap(c,!0)};t.patch(u,m),a.push(m)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...dl(o),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
58
+ `},{type:"element",tagName:"ol",properties:{},children:t.wrap(a,!0)},{type:"text",value:`
59
+ `}]}}const Wl=function(t){if(t==null)return W$;if(typeof t=="function")return Ql(t);if(typeof t=="object")return Array.isArray(t)?H$(t):q$(t);if(typeof t=="string")return G$(t);throw new Error("Expected function, string, or object as test")};function H$(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=Wl(t[n]);return Ql(r);function r(...s){let i=-1;for(;++i<e.length;)if(e[i].apply(this,s))return!0;return!1}}function q$(t){const e=t;return Ql(n);function n(r){const s=r;let i;for(i in t)if(s[i]!==e[i])return!1;return!0}}function G$(t){return Ql(e);function e(n){return n&&n.type===t}}function Ql(t){return e;function e(n,r,s){return!!(Q$(n)&&t.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function W$(){return!0}function Q$(t){return t!==null&&typeof t=="object"&&"type"in t}const $S=[],K$=!0,jd=!1,Y$="skip";function zS(t,e,n,r){let s;typeof e=="function"&&typeof n!="function"?(r=n,n=e):s=e;const i=Wl(s),o=r?-1:1;a(t,void 0,[])();function a(l,u,c){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const f=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(h,"name",{value:"node ("+(l.type+(f?"<"+f+">":""))+")"})}return h;function h(){let f=$S,p,g,_;if((!e||i(l,u,c[c.length-1]||void 0))&&(f=J$(n(l,c)),f[0]===jd))return f;if("children"in l&&l.children){const m=l;if(m.children&&f[0]!==Y$)for(g=(r?m.children.length:-1)+o,_=c.concat(m);g>-1&&g<m.children.length;){const y=m.children[g];if(p=a(y,g,_)(),p[0]===jd)return p;g=typeof p[1]=="number"?p[1]:g+o}}return f}}}function J$(t){return Array.isArray(t)?t:typeof t=="number"?[K$,t]:t==null?$S:[t]}function tp(t,e,n,r){let s,i,o;typeof e=="function"&&typeof n!="function"?(i=void 0,o=e,s=n):(i=e,o=n,s=r),zS(t,i,a,s);function a(l,u){const c=u[u.length-1],d=c?c.children.indexOf(l):void 0;return o(l,d,c)}}const $d={}.hasOwnProperty,X$={};function Z$(t,e){const n=e||X$,r=new Map,s=new Map,i=new Map,o={...O$,...n.handlers},a={all:u,applyData:t5,definitionById:r,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:o,one:l,options:n,patch:e5,wrap:r5};return tp(t,function(c){if(c.type==="definition"||c.type==="footnoteDefinition"){const d=c.type==="definition"?r:s,h=String(c.identifier).toUpperCase();d.has(h)||d.set(h,c)}}),a;function l(c,d){const h=c.type,f=a.handlers[h];if($d.call(a.handlers,h)&&f)return f(a,c,d);if(a.options.passThrough&&a.options.passThrough.includes(h)){if("children"in c){const{children:g,..._}=c,m=dl(_);return m.children=a.all(c),m}return dl(c)}return(a.options.unknownHandler||n5)(a,c,d)}function u(c){const d=[];if("children"in c){const h=c.children;let f=-1;for(;++f<h.length;){const p=a.one(h[f],c);if(p){if(f&&h[f-1].type==="break"&&(!Array.isArray(p)&&p.type==="text"&&(p.value=Cy(p.value)),!Array.isArray(p)&&p.type==="element")){const g=p.children[0];g&&g.type==="text"&&(g.value=Cy(g.value))}Array.isArray(p)?d.push(...p):d.push(p)}}}return d}}function e5(t,e){t.position&&(e.position=FN(t))}function t5(t,e){let n=e;if(t&&t.data){const r=t.data.hName,s=t.data.hChildren,i=t.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&i&&Object.assign(n.properties,dl(i)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function n5(t,e){const n=e.data||{},r="value"in e&&!($d.call(n,"hProperties")||$d.call(n,"hChildren"))?{type:"text",value:e.value}:{type:"element",tagName:"div",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function r5(t,e){const n=[];let r=-1;for(e&&n.push({type:"text",value:`
60
+ `});++r<t.length;)r&&n.push({type:"text",value:`
61
+ `}),n.push(t[r]);return e&&t.length>0&&n.push({type:"text",value:`
62
+ `}),n}function Cy(t){let e=0,n=t.charCodeAt(e);for(;n===9||n===32;)e++,n=t.charCodeAt(e);return t.slice(e)}function Iy(t,e){const n=Z$(t,e),r=n.one(t,void 0),s=V$(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&i.children.push({type:"text",value:`
63
+ `},s),i}function s5(t,e){return t&&"run"in t?async function(n,r){const s=Iy(n,{file:r,...e});await t.run(s,r)}:function(n,r){return Iy(n,{file:r,...t||e})}}function Ey(t){if(t)throw t}var Ta=Object.prototype.hasOwnProperty,FS=Object.prototype.toString,Ry=Object.defineProperty,Ay=Object.getOwnPropertyDescriptor,Py=function(e){return typeof Array.isArray=="function"?Array.isArray(e):FS.call(e)==="[object Array]"},My=function(e){if(!e||FS.call(e)!=="[object Object]")return!1;var n=Ta.call(e,"constructor"),r=e.constructor&&e.constructor.prototype&&Ta.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!r)return!1;var s;for(s in e);return typeof s>"u"||Ta.call(e,s)},Dy=function(e,n){Ry&&n.name==="__proto__"?Ry(e,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):e[n.name]=n.newValue},Oy=function(e,n){if(n==="__proto__")if(Ta.call(e,n)){if(Ay)return Ay(e,n).value}else return;return e[n]},i5=function t(){var e,n,r,s,i,o,a=arguments[0],l=1,u=arguments.length,c=!1;for(typeof a=="boolean"&&(c=a,a=arguments[1]||{},l=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});l<u;++l)if(e=arguments[l],e!=null)for(n in e)r=Oy(a,n),s=Oy(e,n),a!==s&&(c&&s&&(My(s)||(i=Py(s)))?(i?(i=!1,o=r&&Py(r)?r:[]):o=r&&My(r)?r:{},Dy(a,{name:n,newValue:t(c,o,s)})):typeof s<"u"&&Dy(a,{name:n,newValue:s}));return a};const ec=pl(i5);function zd(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function o5(){const t=[],e={run:n,use:r};return e;function n(...s){let i=-1;const o=s.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...s);function a(l,...u){const c=t[++i];let d=-1;if(l){o(l);return}for(;++d<s.length;)(u[d]===null||u[d]===void 0)&&(u[d]=s[d]);s=u,c?a5(c,a)(...u):o(null,...u)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return t.push(s),e}}function a5(t,e){let n;return r;function r(...o){const a=t.length>o.length;let l;a&&o.push(s);try{l=t.apply(this,o)}catch(u){const c=u;if(a&&n)throw c;return s(c)}a||(l&&l.then&&typeof l.then=="function"?l.then(i,s):l instanceof Error?s(l):i(l))}function s(o,...a){n||(n=!0,e(o,...a))}function i(o){s(null,o)}}const mn={basename:l5,dirname:u5,extname:c5,join:d5,sep:"/"};function l5(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Eo(t);let n=0,r=-1,s=t.length,i;if(e===void 0||e.length===0||e.length>t.length){for(;s--;)if(t.codePointAt(s)===47){if(i){n=s+1;break}}else r<0&&(i=!0,r=s+1);return r<0?"":t.slice(n,r)}if(e===t)return"";let o=-1,a=e.length-1;for(;s--;)if(t.codePointAt(s)===47){if(i){n=s+1;break}}else o<0&&(i=!0,o=s+1),a>-1&&(t.codePointAt(s)===e.codePointAt(a--)?a<0&&(r=s):(a=-1,r=o));return n===r?r=o:r<0&&(r=t.length),t.slice(n,r)}function u5(t){if(Eo(t),t.length===0)return".";let e=-1,n=t.length,r;for(;--n;)if(t.codePointAt(n)===47){if(r){e=n;break}}else r||(r=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function c5(t){Eo(t);let e=t.length,n=-1,r=0,s=-1,i=0,o;for(;e--;){const a=t.codePointAt(e);if(a===47){if(o){r=e+1;break}continue}n<0&&(o=!0,n=e+1),a===46?s<0?s=e:i!==1&&(i=1):s>-1&&(i=-1)}return s<0||n<0||i===0||i===1&&s===n-1&&s===r+1?"":t.slice(s,n)}function d5(...t){let e=-1,n;for(;++e<t.length;)Eo(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":h5(n)}function h5(t){Eo(t);const e=t.codePointAt(0)===47;let n=f5(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function f5(t,e){let n="",r=0,s=-1,i=0,o=-1,a,l;for(;++o<=t.length;){if(o<t.length)a=t.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(s===o-1||i===1))if(s!==o-1&&i===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),s=o,i=0;continue}}else if(n.length>0){n="",r=0,s=o,i=0;continue}}e&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+t.slice(s+1,o):n=t.slice(s+1,o),r=o-s-1;s=o,i=0}else a===46&&i>-1?i++:i=-1}return n}function Eo(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const p5={cwd:m5};function m5(){return"/"}function Fd(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function g5(t){if(typeof t=="string")t=new URL(t);else if(!Fd(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return y5(t)}function y5(t){if(t.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const e=t.pathname;let n=-1;for(;++n<e.length;)if(e.codePointAt(n)===37&&e.codePointAt(n+1)===50){const r=e.codePointAt(n+2);if(r===70||r===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(e)}const tc=["history","path","basename","stem","extname","dirname"];class BS{constructor(e){let n;e?Fd(e)?n={path:e}:typeof e=="string"||v5(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":p5.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<tc.length;){const i=tc[r];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let s;for(s in n)tc.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?mn.basename(this.path):void 0}set basename(e){rc(e,"basename"),nc(e,"basename"),this.path=mn.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?mn.dirname(this.path):void 0}set dirname(e){Ny(this.basename,"dirname"),this.path=mn.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?mn.extname(this.path):void 0}set extname(e){if(nc(e,"extname"),Ny(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=mn.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Fd(e)&&(e=g5(e)),rc(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?mn.basename(this.path,this.extname):void 0}set stem(e){rc(e,"stem"),nc(e,"stem"),this.path=mn.join(this.dirname||"",e+(this.extname||""))}fail(e,n,r){const s=this.message(e,n,r);throw s.fatal=!0,s}info(e,n,r){const s=this.message(e,n,r);return s.fatal=void 0,s}message(e,n,r){const s=new Je(e,n,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function nc(t,e){if(t&&t.includes(mn.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+mn.sep+"`")}function rc(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function Ny(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function v5(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const _5=function(t){const r=this.constructor.prototype,s=r[t],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,r),i},w5={}.hasOwnProperty;class np extends _5{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=o5()}copy(){const e=new np;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];e.use(...r)}return e.data(ec(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(oc("data",this.frozen),this.namespace[e]=n,this):w5.call(this.namespace,e)&&this.namespace[e]||void 0:e?(oc("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const s=n.call(e,...r);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const n=ia(e),r=this.parser||this.Parser;return sc("parse",r),r(String(n),n)}process(e,n){const r=this;return this.freeze(),sc("process",this.parser||this.Parser),ic("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(i,o){const a=ia(e),l=r.parse(a);r.run(l,a,function(c,d,h){if(c||!d||!h)return u(c);const f=d,p=r.stringify(f,h);b5(p)?h.value=p:h.result=p,u(c,h)});function u(c,d){c||!d?o(c):i?i(d):n(void 0,d)}}}processSync(e){let n=!1,r;return this.freeze(),sc("processSync",this.parser||this.Parser),ic("processSync",this.compiler||this.Compiler),this.process(e,s),jy("processSync","process",n),r;function s(i,o){n=!0,Ey(i),r=o}}run(e,n,r){Ly(e),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(o,a){const l=ia(n);s.run(e,l,u);function u(c,d,h){const f=d||e;c?a(c):o?o(f):r(void 0,f,h)}}}runSync(e,n){let r=!1,s;return this.run(e,n,i),jy("runSync","run",r),s;function i(o,a){Ey(o),s=a,r=!0}}stringify(e,n){this.freeze();const r=ia(n),s=this.compiler||this.Compiler;return ic("stringify",s),Ly(e),s(e,r)}use(e,...n){const r=this.attachers,s=this.namespace;if(oc("use",this.frozen),e!=null)if(typeof e=="function")l(e,n);else if(typeof e=="object")Array.isArray(e)?a(e):o(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function i(u){if(typeof u=="function")l(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[c,...d]=u;l(c,d)}else o(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function o(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(u.plugins),u.settings&&(s.settings=ec(!0,s.settings,u.settings))}function a(u){let c=-1;if(u!=null)if(Array.isArray(u))for(;++c<u.length;){const d=u[c];i(d)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,c){let d=-1,h=-1;for(;++d<r.length;)if(r[d][0]===u){h=d;break}if(h===-1)r.push([u,...c]);else if(c.length>0){let[f,...p]=c;const g=r[h][1];zd(g)&&zd(f)&&(f=ec(!0,g,f)),r[h]=[u,f,...p]}}}}const x5=new np().freeze();function sc(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function ic(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function oc(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Ly(t){if(!zd(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function jy(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function ia(t){return S5(t)?t:new BS(t)}function S5(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function b5(t){return typeof t=="string"||T5(t)}function T5(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const k5="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",$y=[],zy={allowDangerousHtml:!0},C5=/^(https?|ircs?|mailto|xmpp)$/i,I5=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function E5(t){const e=R5(t),n=A5(t);return P5(e.runSync(e.parse(n),n),t)}function R5(t){const e=t.rehypePlugins||$y,n=t.remarkPlugins||$y,r=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...zy}:zy;return x5().use(l$).use(n).use(s5,r).use(e)}function A5(t){const e=t.children||"",n=new BS;return typeof e=="string"&&(n.value=e),n}function P5(t,e){const n=e.allowedElements,r=e.allowElement,s=e.components,i=e.disallowedElements,o=e.skipHtml,a=e.unwrapDisallowed,l=e.urlTransform||M5;for(const c of I5)Object.hasOwn(e,c.from)&&(""+c.from+(c.to?"use `"+c.to+"` instead":"remove it")+k5+c.id,void 0);return tp(t,u),qN(t,{Fragment:T.Fragment,components:s,ignoreInvalidStyle:!0,jsx:T.jsx,jsxs:T.jsxs,passKeys:!0,passNode:!0});function u(c,d,h){if(c.type==="raw"&&h&&typeof d=="number")return o?h.children.splice(d,1):h.children[d]={type:"text",value:c.value},d;if(c.type==="element"){let f;for(f in Ju)if(Object.hasOwn(Ju,f)&&Object.hasOwn(c.properties,f)){const p=c.properties[f],g=Ju[f];(g===null||g.includes(c.tagName))&&(c.properties[f]=l(String(p||""),f,c))}}if(c.type==="element"){let f=n?!n.includes(c.tagName):i?i.includes(c.tagName):!1;if(!f&&r&&typeof d=="number"&&(f=!r(c,d,h)),f&&h&&typeof d=="number")return a&&c.children?h.children.splice(d,1,...c.children):h.children.splice(d,1),d}}}function M5(t){const e=t.indexOf(":"),n=t.indexOf("?"),r=t.indexOf("#"),s=t.indexOf("/");return e===-1||s!==-1&&e>s||n!==-1&&e>n||r!==-1&&e>r||C5.test(t.slice(0,e))?t:""}function Fy(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(e);for(;s!==-1;)r++,s=n.indexOf(e,s+e.length);return r}function D5(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function O5(t,e,n){const s=Wl((n||{}).ignore||[]),i=N5(e);let o=-1;for(;++o<i.length;)zS(t,"text",a);function a(u,c){let d=-1,h;for(;++d<c.length;){const f=c[d],p=h?h.children:void 0;if(s(f,p?p.indexOf(f):void 0,h))return;h=f}if(h)return l(u,c)}function l(u,c){const d=c[c.length-1],h=i[o][0],f=i[o][1];let p=0;const _=d.children.indexOf(u);let m=!1,y=[];h.lastIndex=0;let v=h.exec(u.value);for(;v;){const S=v.index,I={index:v.index,input:v.input,stack:[...c,u]};let b=f(...v,I);if(typeof b=="string"&&(b=b.length>0?{type:"text",value:b}:void 0),b===!1?h.lastIndex=S+1:(p!==S&&y.push({type:"text",value:u.value.slice(p,S)}),Array.isArray(b)?y.push(...b):b&&y.push(b),p=S+v[0].length,m=!0),!h.global)break;v=h.exec(u.value)}return m?(p<u.value.length&&y.push({type:"text",value:u.value.slice(p)}),d.children.splice(_,1,...y)):y=[u],_+y.length}}function N5(t){const e=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!t[0]||Array.isArray(t[0])?t:[t];let r=-1;for(;++r<n.length;){const s=n[r];e.push([L5(s[0]),j5(s[1])])}return e}function L5(t){return typeof t=="string"?new RegExp(D5(t),"g"):t}function j5(t){return typeof t=="function"?t:function(){return t}}const ac="phrasing",lc=["autolink","link","image","label"];function $5(){return{transforms:[q5],enter:{literalAutolink:F5,literalAutolinkEmail:uc,literalAutolinkHttp:uc,literalAutolinkWww:uc},exit:{literalAutolink:H5,literalAutolinkEmail:V5,literalAutolinkHttp:B5,literalAutolinkWww:U5}}}function z5(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ac,notInConstruct:lc},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ac,notInConstruct:lc},{character:":",before:"[ps]",after:"\\/",inConstruct:ac,notInConstruct:lc}]}}function F5(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function uc(t){this.config.enter.autolinkProtocol.call(this,t)}function B5(t){this.config.exit.autolinkProtocol.call(this,t)}function U5(t){this.config.exit.data.call(this,t);const e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function V5(t){this.config.exit.autolinkEmail.call(this,t)}function H5(t){this.exit(t)}function q5(t){O5(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,G5],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),W5]],{ignore:["link","linkReference"]})}function G5(t,e,n,r,s){let i="";if(!US(s)||(/^w/i.test(e)&&(n=e+n,e="",i="http://"),!Q5(n)))return!1;const o=K5(n+r);if(!o[0])return!1;const a={type:"link",title:null,url:i+e+o[0],children:[{type:"text",value:e+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function W5(t,e,n,r){return!US(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+n,children:[{type:"text",value:e+"@"+n}]}}function Q5(t){const e=t.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[a-zA-Z\d]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[a-zA-Z\d]/.test(e[e.length-2])))}function K5(t){const e=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!e)return[t,void 0];t=t.slice(0,e.index);let n=e[0],r=n.indexOf(")");const s=Fy(t,"(");let i=Fy(t,")");for(;r!==-1&&s>i;)t+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),i++;return[t,n]}function US(t,e){const n=t.input.charCodeAt(t.index-1);return(t.index===0||Hr(n)||Hl(n))&&(!e||n!==47)}VS.peek=sz;function Y5(){this.buffer()}function J5(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function X5(){this.buffer()}function Z5(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function ez(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=sn(this.sliceSerialize(t)).toLowerCase(),n.label=e}function tz(t){this.exit(t)}function nz(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=sn(this.sliceSerialize(t)).toLowerCase(),n.label=e}function rz(t){this.exit(t)}function sz(){return"["}function VS(t,e,n,r){const s=n.createTracker(r);let i=s.move("[^");const o=n.enter("footnoteReference"),a=n.enter("reference");return i+=s.move(n.safe(n.associationId(t),{after:"]",before:i})),a(),o(),i+=s.move("]"),i}function iz(){return{enter:{gfmFootnoteCallString:Y5,gfmFootnoteCall:J5,gfmFootnoteDefinitionLabelString:X5,gfmFootnoteDefinition:Z5},exit:{gfmFootnoteCallString:ez,gfmFootnoteCall:tz,gfmFootnoteDefinitionLabelString:nz,gfmFootnoteDefinition:rz}}}function oz(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:n,footnoteReference:VS},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,s,i,o){const a=i.createTracker(o);let l=a.move("[^");const u=i.enter("footnoteDefinition"),c=i.enter("label");return l+=a.move(i.safe(i.associationId(r),{before:l,after:"]"})),c(),l+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),l+=a.move((e?`
64
+ `:" ")+i.indentLines(i.containerFlow(r,a.current()),e?HS:az))),u(),l}}function az(t,e,n){return e===0?t:HS(t,e,n)}function HS(t,e,n){return(n?"":" ")+t}const lz=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];qS.peek=fz;function uz(){return{canContainEols:["delete"],enter:{strikethrough:dz},exit:{strikethrough:hz}}}function cz(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:lz}],handlers:{delete:qS}}}function dz(t){this.enter({type:"delete",children:[]},t)}function hz(t){this.exit(t)}function qS(t,e,n,r){const s=n.createTracker(r),i=n.enter("strikethrough");let o=s.move("~~");return o+=n.containerPhrasing(t,{...s.current(),before:o,after:"~"}),o+=s.move("~~"),i(),o}function fz(){return"~"}function pz(t){return t.length}function mz(t,e){const n=e||{},r=(n.align||[]).concat(),s=n.stringLength||pz,i=[],o=[],a=[],l=[];let u=0,c=-1;for(;++c<t.length;){const g=[],_=[];let m=-1;for(t[c].length>u&&(u=t[c].length);++m<t[c].length;){const y=gz(t[c][m]);if(n.alignDelimiters!==!1){const v=s(y);_[m]=v,(l[m]===void 0||v>l[m])&&(l[m]=v)}g.push(y)}o[c]=g,a[c]=_}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<u;)i[d]=By(r[d]);else{const g=By(r);for(;++d<u;)i[d]=g}d=-1;const h=[],f=[];for(;++d<u;){const g=i[d];let _="",m="";g===99?(_=":",m=":"):g===108?_=":":g===114&&(m=":");let y=n.alignDelimiters===!1?1:Math.max(1,l[d]-_.length-m.length);const v=_+"-".repeat(y)+m;n.alignDelimiters!==!1&&(y=_.length+y+m.length,y>l[d]&&(l[d]=y),f[d]=y),h[d]=v}o.splice(1,0,h),a.splice(1,0,f),c=-1;const p=[];for(;++c<o.length;){const g=o[c],_=a[c];d=-1;const m=[];for(;++d<u;){const y=g[d]||"";let v="",S="";if(n.alignDelimiters!==!1){const I=l[d]-(_[d]||0),b=i[d];b===114?v=" ".repeat(I):b===99?I%2?(v=" ".repeat(I/2+.5),S=" ".repeat(I/2-.5)):(v=" ".repeat(I/2),S=v):S=" ".repeat(I)}n.delimiterStart!==!1&&!d&&m.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&y==="")&&(n.delimiterStart!==!1||d)&&m.push(" "),n.alignDelimiters!==!1&&m.push(v),m.push(y),n.alignDelimiters!==!1&&m.push(S),n.padding!==!1&&m.push(" "),(n.delimiterEnd!==!1||d!==u-1)&&m.push("|")}p.push(n.delimiterEnd===!1?m.join("").replace(/ +$/,""):m.join(""))}return p.join(`
65
+ `)}function gz(t){return t==null?"":String(t)}function By(t){const e=typeof t=="string"?t.codePointAt(0):0;return e===67||e===99?99:e===76||e===108?108:e===82||e===114?114:0}function yz(t,e,n,r){const s=n.enter("blockquote"),i=n.createTracker(r);i.move("> "),i.shift(2);const o=n.indentLines(n.containerFlow(t,i.current()),vz);return s(),o}function vz(t,e,n){return">"+(n?"":" ")+t}function _z(t,e){return Uy(t,e.inConstruct,!0)&&!Uy(t,e.notInConstruct,!1)}function Uy(t,e,n){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return n;let r=-1;for(;++r<e.length;)if(t.includes(e[r]))return!0;return!1}function Vy(t,e,n,r){let s=-1;for(;++s<n.unsafe.length;)if(n.unsafe[s].character===`
66
+ `&&_z(n.stack,n.unsafe[s]))return/[ \t]/.test(r.before)?"":" ";return`\\
67
+ `}function wz(t,e){const n=String(t);let r=n.indexOf(e),s=r,i=0,o=0;if(typeof e!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===s?++i>o&&(o=i):i=1,s=r+e.length,r=n.indexOf(e,s);return o}function xz(t,e){return!!(e.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function Sz(t){const e=t.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function bz(t,e,n,r){const s=Sz(n),i=t.value||"",o=s==="`"?"GraveAccent":"Tilde";if(xz(t,n)){const d=n.enter("codeIndented"),h=n.indentLines(i,Tz);return d(),h}const a=n.createTracker(r),l=s.repeat(Math.max(wz(i,s)+1,3)),u=n.enter("codeFenced");let c=a.move(l);if(t.lang){const d=n.enter(`codeFencedLang${o}`);c+=a.move(n.safe(t.lang,{before:c,after:" ",encode:["`"],...a.current()})),d()}if(t.lang&&t.meta){const d=n.enter(`codeFencedMeta${o}`);c+=a.move(" "),c+=a.move(n.safe(t.meta,{before:c,after:`
68
+ `,encode:["`"],...a.current()})),d()}return c+=a.move(`
69
+ `),i&&(c+=a.move(i+`
70
+ `)),c+=a.move(l),u(),c}function Tz(t,e,n){return(n?"":" ")+t}function rp(t){const e=t.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function kz(t,e,n,r){const s=rp(n),i=s==='"'?"Quote":"Apostrophe",o=n.enter("definition");let a=n.enter("label");const l=n.createTracker(r);let u=l.move("[");return u+=l.move(n.safe(n.associationId(t),{before:u,after:"]",...l.current()})),u+=l.move("]: "),a(),!t.url||/[\0- \u007F]/.test(t.url)?(a=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(t.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(a=n.enter("destinationRaw"),u+=l.move(n.safe(t.url,{before:u,after:t.title?" ":`
71
+ `,...l.current()}))),a(),t.title&&(a=n.enter(`title${i}`),u+=l.move(" "+s),u+=l.move(n.safe(t.title,{before:u,after:s,...l.current()})),u+=l.move(s),a()),o(),u}function Cz(t){const e=t.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function lo(t){return"&#x"+t.toString(16).toUpperCase()+";"}function hl(t,e,n){const r=Ns(t),s=Ns(e);return r===void 0?s===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}GS.peek=Iz;function GS(t,e,n,r){const s=Cz(n),i=n.enter("emphasis"),o=n.createTracker(r),a=o.move(s);let l=o.move(n.containerPhrasing(t,{after:s,before:a,...o.current()}));const u=l.charCodeAt(0),c=hl(r.before.charCodeAt(r.before.length-1),u,s);c.inside&&(l=lo(u)+l.slice(1));const d=l.charCodeAt(l.length-1),h=hl(r.after.charCodeAt(0),d,s);h.inside&&(l=l.slice(0,-1)+lo(d));const f=o.move(s);return i(),n.attentionEncodeSurroundingInfo={after:h.outside,before:c.outside},a+l+f}function Iz(t,e,n){return n.options.emphasis||"*"}function Ez(t,e){let n=!1;return tp(t,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,jd}),!!((!t.depth||t.depth<3)&&Qf(t)&&(e.options.setext||n))}function Rz(t,e,n,r){const s=Math.max(Math.min(6,t.depth||1),1),i=n.createTracker(r);if(Ez(t,n)){const c=n.enter("headingSetext"),d=n.enter("phrasing"),h=n.containerPhrasing(t,{...i.current(),before:`
72
+ `,after:`
73
+ `});return d(),c(),h+`
74
+ `+(s===1?"=":"-").repeat(h.length-(Math.max(h.lastIndexOf("\r"),h.lastIndexOf(`
75
+ `))+1))}const o="#".repeat(s),a=n.enter("headingAtx"),l=n.enter("phrasing");i.move(o+" ");let u=n.containerPhrasing(t,{before:"# ",after:`
76
+ `,...i.current()});return/^[\t ]/.test(u)&&(u=lo(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,n.options.closeAtx&&(u+=" "+o),l(),a(),u}WS.peek=Az;function WS(t){return t.value||""}function Az(){return"<"}QS.peek=Pz;function QS(t,e,n,r){const s=rp(n),i=s==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=n.enter("label");const l=n.createTracker(r);let u=l.move("![");return u+=l.move(n.safe(t.alt,{before:u,after:"]",...l.current()})),u+=l.move("]("),a(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(a=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(t.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(a=n.enter("destinationRaw"),u+=l.move(n.safe(t.url,{before:u,after:t.title?" ":")",...l.current()}))),a(),t.title&&(a=n.enter(`title${i}`),u+=l.move(" "+s),u+=l.move(n.safe(t.title,{before:u,after:s,...l.current()})),u+=l.move(s),a()),u+=l.move(")"),o(),u}function Pz(){return"!"}KS.peek=Mz;function KS(t,e,n,r){const s=t.referenceType,i=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const u=n.safe(t.alt,{before:l,after:"]",...a.current()});l+=a.move(u+"]["),o();const c=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(t),{before:l,after:"]",...a.current()});return o(),n.stack=c,i(),s==="full"||!u||u!==d?l+=a.move(d+"]"):s==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function Mz(){return"!"}YS.peek=Dz;function YS(t,e,n){let r=t.value||"",s="`",i=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(r);)s+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++i<n.unsafe.length;){const o=n.unsafe[i],a=n.compilePattern(o);let l;if(o.atBreak)for(;l=a.exec(r);){let u=l.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(l.index+1)}}return s+r+s}function Dz(){return"`"}function JS(t,e){const n=Qf(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}XS.peek=Oz;function XS(t,e,n,r){const s=rp(n),i=s==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(JS(t,n)){const c=n.stack;n.stack=[],a=n.enter("autolink");let d=o.move("<");return d+=o.move(n.containerPhrasing(t,{before:d,after:">",...o.current()})),d+=o.move(">"),a(),n.stack=c,d}a=n.enter("link"),l=n.enter("label");let u=o.move("[");return u+=o.move(n.containerPhrasing(t,{before:u,after:"](",...o.current()})),u+=o.move("]("),l(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(t.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(t.url,{before:u,after:t.title?" ":")",...o.current()}))),l(),t.title&&(l=n.enter(`title${i}`),u+=o.move(" "+s),u+=o.move(n.safe(t.title,{before:u,after:s,...o.current()})),u+=o.move(s),l()),u+=o.move(")"),a(),u}function Oz(t,e,n){return JS(t,n)?"<":"["}ZS.peek=Nz;function ZS(t,e,n,r){const s=t.referenceType,i=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const u=n.containerPhrasing(t,{before:l,after:"]",...a.current()});l+=a.move(u+"]["),o();const c=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(t),{before:l,after:"]",...a.current()});return o(),n.stack=c,i(),s==="full"||!u||u!==d?l+=a.move(d+"]"):s==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function Nz(){return"["}function sp(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function Lz(t){const e=sp(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function jz(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function eb(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function $z(t,e,n,r){const s=n.enter("list"),i=n.bulletCurrent;let o=t.ordered?jz(n):sp(n);const a=t.ordered?o==="."?")":".":Lz(n);let l=e&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!t.ordered){const c=t.children?t.children[0]:void 0;if((o==="*"||o==="-")&&c&&(!c.children||!c.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),eb(n)===o&&c){let d=-1;for(;++d<t.children.length;){const h=t.children[d];if(h&&h.type==="listItem"&&h.children&&h.children[0]&&h.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=a),n.bulletCurrent=o;const u=n.containerFlow(t,r);return n.bulletLastUsed=o,n.bulletCurrent=i,s(),u}function zz(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function Fz(t,e,n,r){const s=zz(n);let i=n.bulletCurrent||sp(n);e&&e.type==="list"&&e.ordered&&(i=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+i);let o=i.length+1;(s==="tab"||s==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(i+" ".repeat(o-i.length)),a.shift(o);const l=n.enter("listItem"),u=n.indentLines(n.containerFlow(t,a.current()),c);return l(),u;function c(d,h,f){return h?(f?"":" ".repeat(o))+d:(f?i:i+" ".repeat(o-i.length))+d}}function Bz(t,e,n,r){const s=n.enter("paragraph"),i=n.enter("phrasing"),o=n.containerPhrasing(t,r);return i(),s(),o}const Uz=Wl(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Vz(t,e,n,r){return(t.children.some(function(o){return Uz(o)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function Hz(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}tb.peek=qz;function tb(t,e,n,r){const s=Hz(n),i=n.enter("strong"),o=n.createTracker(r),a=o.move(s+s);let l=o.move(n.containerPhrasing(t,{after:s,before:a,...o.current()}));const u=l.charCodeAt(0),c=hl(r.before.charCodeAt(r.before.length-1),u,s);c.inside&&(l=lo(u)+l.slice(1));const d=l.charCodeAt(l.length-1),h=hl(r.after.charCodeAt(0),d,s);h.inside&&(l=l.slice(0,-1)+lo(d));const f=o.move(s+s);return i(),n.attentionEncodeSurroundingInfo={after:h.outside,before:c.outside},a+l+f}function qz(t,e,n){return n.options.strong||"*"}function Gz(t,e,n,r){return n.safe(t.value,r)}function Wz(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function Qz(t,e,n){const r=(eb(n)+(n.options.ruleSpaces?" ":"")).repeat(Wz(n));return n.options.ruleSpaces?r.slice(0,-1):r}const nb={blockquote:yz,break:Vy,code:bz,definition:kz,emphasis:GS,hardBreak:Vy,heading:Rz,html:WS,image:QS,imageReference:KS,inlineCode:YS,link:XS,linkReference:ZS,list:$z,listItem:Fz,paragraph:Bz,root:Vz,strong:tb,text:Gz,thematicBreak:Qz};function Kz(){return{enter:{table:Yz,tableData:Hy,tableHeader:Hy,tableRow:Xz},exit:{codeText:Zz,table:Jz,tableData:cc,tableHeader:cc,tableRow:cc}}}function Yz(t){const e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function Jz(t){this.exit(t),this.data.inTable=void 0}function Xz(t){this.enter({type:"tableRow",children:[]},t)}function cc(t){this.exit(t)}function Hy(t){this.enter({type:"tableCell",children:[]},t)}function Zz(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,eF));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function eF(t,e){return e==="|"?e:t}function tF(t){const e=t||{},n=e.tableCellPadding,r=e.tablePipeAlign,s=e.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
77
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:h,table:o,tableCell:l,tableRow:a}};function o(f,p,g,_){return u(c(f,g,_),f.align)}function a(f,p,g,_){const m=d(f,g,_),y=u([m]);return y.slice(0,y.indexOf(`
78
+ `))}function l(f,p,g,_){const m=g.enter("tableCell"),y=g.enter("phrasing"),v=g.containerPhrasing(f,{..._,before:i,after:i});return y(),m(),v}function u(f,p){return mz(f,{align:p,alignDelimiters:r,padding:n,stringLength:s})}function c(f,p,g){const _=f.children;let m=-1;const y=[],v=p.enter("table");for(;++m<_.length;)y[m]=d(_[m],p,g);return v(),y}function d(f,p,g){const _=f.children;let m=-1;const y=[],v=p.enter("tableRow");for(;++m<_.length;)y[m]=l(_[m],f,p,g);return v(),y}function h(f,p,g){let _=nb.inlineCode(f,p,g);return g.stack.includes("tableCell")&&(_=_.replace(/\|/g,"\\$&")),_}}function nF(){return{exit:{taskListCheckValueChecked:qy,taskListCheckValueUnchecked:qy,paragraph:sF}}}function rF(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:iF}}}function qy(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function sF(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const s=e.children;let i=-1,o;for(;++i<s.length;){const a=s[i];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function iF(t,e,n,r){const s=t.children[0],i=typeof t.checked=="boolean"&&s&&s.type==="paragraph",o="["+(t.checked?"x":" ")+"] ",a=n.createTracker(r);i&&a.move(o);let l=nb.listItem(t,e,n,{...r,...a.current()});return i&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(c){return c+o}}function oF(){return[$5(),iz(),uz(),Kz(),nF()]}function aF(t){return{extensions:[z5(),oz(t),cz(),tF(t),rF()]}}const lF={tokenize:pF,partial:!0},rb={tokenize:mF,partial:!0},sb={tokenize:gF,partial:!0},ib={tokenize:yF,partial:!0},uF={tokenize:vF,partial:!0},ob={name:"wwwAutolink",tokenize:hF,previous:lb},ab={name:"protocolAutolink",tokenize:fF,previous:ub},zn={name:"emailAutolink",tokenize:dF,previous:cb},xn={};function cF(){return{text:xn}}let vr=48;for(;vr<123;)xn[vr]=zn,vr++,vr===58?vr=65:vr===91&&(vr=97);xn[43]=zn;xn[45]=zn;xn[46]=zn;xn[95]=zn;xn[72]=[zn,ab];xn[104]=[zn,ab];xn[87]=[zn,ob];xn[119]=[zn,ob];function dF(t,e,n){const r=this;let s,i;return o;function o(d){return!Bd(d)||!cb.call(r,r.previous)||ip(r.events)?n(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),a(d))}function a(d){return Bd(d)?(t.consume(d),a):d===64?(t.consume(d),l):n(d)}function l(d){return d===46?t.check(uF,c,u)(d):d===45||d===95||Ke(d)?(i=!0,t.consume(d),l):c(d)}function u(d){return t.consume(d),s=!0,l}function c(d){return i&&s&&tt(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(d)):n(d)}}function hF(t,e,n){const r=this;return s;function s(o){return o!==87&&o!==119||!lb.call(r,r.previous)||ip(r.events)?n(o):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(lF,t.attempt(rb,t.attempt(sb,i),n),n)(o))}function i(o){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(o)}}function fF(t,e,n){const r=this;let s="",i=!1;return o;function o(d){return(d===72||d===104)&&ub.call(r,r.previous)&&!ip(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),s+=String.fromCodePoint(d),t.consume(d),a):n(d)}function a(d){if(tt(d)&&s.length<5)return s+=String.fromCodePoint(d),t.consume(d),a;if(d===58){const h=s.toLowerCase();if(h==="http"||h==="https")return t.consume(d),l}return n(d)}function l(d){return d===47?(t.consume(d),i?u:(i=!0,l)):n(d)}function u(d){return d===null||ul(d)||ye(d)||Hr(d)||Hl(d)?n(d):t.attempt(rb,t.attempt(sb,c),n)(d)}function c(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}}function pF(t,e,n){let r=0;return s;function s(o){return(o===87||o===119)&&r<3?(r++,t.consume(o),s):o===46&&r===3?(t.consume(o),i):n(o)}function i(o){return o===null?n(o):e(o)}}function mF(t,e,n){let r,s,i;return o;function o(u){return u===46||u===95?t.check(ib,l,a)(u):u===null||ye(u)||Hr(u)||u!==45&&Hl(u)?l(u):(i=!0,t.consume(u),o)}function a(u){return u===95?r=!0:(s=r,r=void 0),t.consume(u),o}function l(u){return s||r||!i?n(u):e(u)}}function gF(t,e){let n=0,r=0;return s;function s(o){return o===40?(n++,t.consume(o),s):o===41&&r<n?i(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?t.check(ib,e,i)(o):o===null||ye(o)||Hr(o)?e(o):(t.consume(o),s)}function i(o){return o===41&&r++,t.consume(o),s}}function yF(t,e,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(t.consume(a),r):a===38?(t.consume(a),i):a===93?(t.consume(a),s):a===60||a===null||ye(a)||Hr(a)?e(a):n(a)}function s(a){return a===null||a===40||a===91||ye(a)||Hr(a)?e(a):r(a)}function i(a){return tt(a)?o(a):n(a)}function o(a){return a===59?(t.consume(a),r):tt(a)?(t.consume(a),o):n(a)}}function vF(t,e,n){return r;function r(i){return t.consume(i),s}function s(i){return Ke(i)?n(i):e(i)}}function lb(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||ye(t)}function ub(t){return!tt(t)}function cb(t){return!(t===47||Bd(t))}function Bd(t){return t===43||t===45||t===46||t===95||Ke(t)}function ip(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const _F={tokenize:IF,partial:!0};function wF(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:TF,continuation:{tokenize:kF},exit:CF}},text:{91:{name:"gfmFootnoteCall",tokenize:bF},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:xF,resolveTo:SF}}}}function xF(t,e,n){const r=this;let s=r.events.length;const i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;s--;){const l=r.events[s][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const u=sn(r.sliceSerialize({start:o.end,end:r.now()}));return u.codePointAt(0)!==94||!i.includes(u.slice(1))?n(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function SF(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},t[t.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},a=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",s,e],["exit",s,e],["enter",i,e],["enter",o,e],["exit",o,e],["exit",i,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...a),t}function bF(t,e,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i=0,o;return a;function a(d){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(t.enter("gfmFootnoteCallMarker"),t.consume(d),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",u)}function u(d){if(i>999||d===93&&!o||d===null||d===91||ye(d))return n(d);if(d===93){t.exit("chunkString");const h=t.exit("gfmFootnoteCallString");return s.includes(sn(r.sliceSerialize(h)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(d)}return ye(d)||(o=!0),i++,t.consume(d),d===92?c:u}function c(d){return d===91||d===92||d===93?(t.consume(d),i++,u):u(d)}}function TF(t,e,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i,o=0,a;return l;function l(p){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(p),t.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(p){return p===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(p),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",c):n(p)}function c(p){if(o>999||p===93&&!a||p===null||p===91||ye(p))return n(p);if(p===93){t.exit("chunkString");const g=t.exit("gfmFootnoteDefinitionLabelString");return i=sn(r.sliceSerialize(g)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(p),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),h}return ye(p)||(a=!0),o++,t.consume(p),p===92?d:c}function d(p){return p===91||p===92||p===93?(t.consume(p),o++,c):c(p)}function h(p){return p===58?(t.enter("definitionMarker"),t.consume(p),t.exit("definitionMarker"),s.includes(i)||s.push(i),le(t,f,"gfmFootnoteDefinitionWhitespace")):n(p)}function f(p){return e(p)}}function kF(t,e,n){return t.check(Io,e,t.attempt(_F,e,n))}function CF(t){t.exit("gfmFootnoteDefinition")}function IF(t,e,n){const r=this;return le(t,s,"gfmFootnoteDefinitionIndent",5);function s(i){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?e(i):n(i)}}function EF(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:i,resolveAll:s};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function s(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let u=l;for(;u--;)if(o[u][0]==="exit"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[l][1].type="strikethroughSequence",o[u][1].type="strikethroughSequence";const c={type:"strikethrough",start:Object.assign({},o[u][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[u][1].end),end:Object.assign({},o[l][1].start)},h=[["enter",c,a],["enter",o[u][1],a],["exit",o[u][1],a],["enter",d,a]],f=a.parser.constructs.insideSpan.null;f&&bt(h,h.length,0,ql(f,o.slice(u+1,l),a)),bt(h,h.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",c,a]]),bt(o,u-1,l-u+3,h),l=u+h.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function i(o,a,l){const u=this.previous,c=this.events;let d=0;return h;function h(p){return u===126&&c[c.length-1][1].type!=="characterEscape"?l(p):(o.enter("strikethroughSequenceTemporary"),f(p))}function f(p){const g=Ns(u);if(p===126)return d>1?l(p):(o.consume(p),d++,f);if(d<2&&!n)return l(p);const _=o.exit("strikethroughSequenceTemporary"),m=Ns(p);return _._open=!m||m===2&&!!g,_._close=!g||g===2&&!!m,a(p)}}}class RF{constructor(){this.map=[],this.index=new Map}add(e,n,r){AF(this,e,n,r)}consume(e){if(this.map.sort(function(i,o){return i[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let s=r.pop();for(;s;){for(const i of s)e.push(i);s=r.pop()}this.map.length=0,this.index.clear()}}function AF(t,e,n,r){if(n===0&&r.length===0)return;const s=t.index.get(e);if(s){s[1]+=n,s[2].push(...r);return}const i=[e,n,r];t.map.push(i),t.index.set(e,i)}function PF(t,e){let n=!1;const r=[];for(;e<t.length;){const s=t[e];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const i=r.length-1;r[i]=r[i]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function MF(){return{flow:{null:{name:"table",tokenize:DF,resolveAll:OF}}}}function DF(t,e,n){const r=this;let s=0,i=0,o;return a;function a(x){let k=r.events.length-1;for(;k>-1;){const{type:L}=r.events[k][1];if(L==="lineEnding"||L==="linePrefix")k--;else break}const R=k>-1?r.events[k][1].type:null,M=R==="tableHead"||R==="tableRow"?b:l;return M===b&&r.parser.lazy[r.now().line]?n(x):M(x)}function l(x){return t.enter("tableHead"),t.enter("tableRow"),u(x)}function u(x){return x===124||(o=!0,i+=1),c(x)}function c(x){return x===null?n(x):Z(x)?i>1?(i=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(x),t.exit("lineEnding"),f):n(x):se(x)?le(t,c,"whitespace")(x):(i+=1,o&&(o=!1,s+=1),x===124?(t.enter("tableCellDivider"),t.consume(x),t.exit("tableCellDivider"),o=!0,c):(t.enter("data"),d(x)))}function d(x){return x===null||x===124||ye(x)?(t.exit("data"),c(x)):(t.consume(x),x===92?h:d)}function h(x){return x===92||x===124?(t.consume(x),d):d(x)}function f(x){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(x):(t.enter("tableDelimiterRow"),o=!1,se(x)?le(t,p,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):p(x))}function p(x){return x===45||x===58?_(x):x===124?(o=!0,t.enter("tableCellDivider"),t.consume(x),t.exit("tableCellDivider"),g):I(x)}function g(x){return se(x)?le(t,_,"whitespace")(x):_(x)}function _(x){return x===58?(i+=1,o=!0,t.enter("tableDelimiterMarker"),t.consume(x),t.exit("tableDelimiterMarker"),m):x===45?(i+=1,m(x)):x===null||Z(x)?S(x):I(x)}function m(x){return x===45?(t.enter("tableDelimiterFiller"),y(x)):I(x)}function y(x){return x===45?(t.consume(x),y):x===58?(o=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(x),t.exit("tableDelimiterMarker"),v):(t.exit("tableDelimiterFiller"),v(x))}function v(x){return se(x)?le(t,S,"whitespace")(x):S(x)}function S(x){return x===124?p(x):x===null||Z(x)?!o||s!==i?I(x):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(x)):I(x)}function I(x){return n(x)}function b(x){return t.enter("tableRow"),P(x)}function P(x){return x===124?(t.enter("tableCellDivider"),t.consume(x),t.exit("tableCellDivider"),P):x===null||Z(x)?(t.exit("tableRow"),e(x)):se(x)?le(t,P,"whitespace")(x):(t.enter("data"),A(x))}function A(x){return x===null||x===124||ye(x)?(t.exit("data"),P(x)):(t.consume(x),x===92?D:A)}function D(x){return x===92||x===124?(t.consume(x),A):A(x)}}function OF(t,e){let n=-1,r=!0,s=0,i=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,u,c,d;const h=new RF;for(;++n<t.length;){const f=t[n],p=f[1];f[0]==="enter"?p.type==="tableHead"?(a=!1,l!==0&&(Gy(h,e,l,u,c),c=void 0,l=0),u={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[["enter",u,e]])):p.type==="tableRow"||p.type==="tableDelimiterRow"?(r=!0,d=void 0,i=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,c={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[["enter",c,e]])),s=p.type==="tableDelimiterRow"?2:c?3:1):s&&(p.type==="data"||p.type==="tableDelimiterMarker"||p.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(i[1]!==0&&(o[0]=o[1],d=oa(h,e,i,s,void 0,d),i=[0,0,0,0]),o[2]=n)):p.type==="tableCellDivider"&&(r?r=!1:(i[1]!==0&&(o[0]=o[1],d=oa(h,e,i,s,void 0,d)),i=o,o=[i[1],n,0,0])):p.type==="tableHead"?(a=!0,l=n):p.type==="tableRow"||p.type==="tableDelimiterRow"?(l=n,i[1]!==0?(o[0]=o[1],d=oa(h,e,i,s,n,d)):o[1]!==0&&(d=oa(h,e,o,s,n,d)),s=0):s&&(p.type==="data"||p.type==="tableDelimiterMarker"||p.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&Gy(h,e,l,u,c),h.consume(e.events),n=-1;++n<e.events.length;){const f=e.events[n];f[0]==="enter"&&f[1].type==="table"&&(f[1]._align=PF(e.events,n))}return t}function oa(t,e,n,r,s,i){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(i.end=Object.assign({},is(e.events,n[0])),t.add(n[0],0,[["exit",i,e]]));const l=is(e.events,n[1]);if(i={type:o,start:Object.assign({},l),end:Object.assign({},l)},t.add(n[1],0,[["enter",i,e]]),n[2]!==0){const u=is(e.events,n[2]),c=is(e.events,n[3]),d={type:a,start:Object.assign({},u),end:Object.assign({},c)};if(t.add(n[2],0,[["enter",d,e]]),r!==2){const h=e.events[n[2]],f=e.events[n[3]];if(h[1].end=Object.assign({},f[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const p=n[2]+1,g=n[3]-n[2]-1;t.add(p,g,[])}}t.add(n[3]+1,0,[["exit",d,e]])}return s!==void 0&&(i.end=Object.assign({},is(e.events,s)),t.add(s,0,[["exit",i,e]]),i=void 0),i}function Gy(t,e,n,r,s){const i=[],o=is(e.events,n);s&&(s.end=Object.assign({},o),i.push(["exit",s,e])),r.end=Object.assign({},o),i.push(["exit",r,e]),t.add(n+1,0,i)}function is(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const NF={name:"tasklistCheck",tokenize:jF};function LF(){return{text:{91:NF}}}function jF(t,e,n){const r=this;return s;function s(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),i)}function i(l){return ye(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),a):n(l)}function a(l){return Z(l)?e(l):se(l)?t.check({tokenize:$F},e,n)(l):n(l)}}function $F(t,e,n){return le(t,r,"whitespace");function r(s){return s===null?n(s):e(s)}}function zF(t){return _S([cF(),wF(),EF(t),MF(),LF()])}const FF={};function BF(t){const e=this,n=t||FF,r=e.data(),s=r.micromarkExtensions||(r.micromarkExtensions=[]),i=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);s.push(zF(n)),i.push(oF()),o.push(aF(n))}const db={drainMs:1600,maxCharsPerFrame:8};function UF(){const{text:t}=jf(Lf(),db);return T.jsx("div",{className:"part markdown",children:T.jsx(E5,{remarkPlugins:[BF],children:t})})}function hb(){const{text:t}=Lf();return T.jsx(T.Fragment,{children:t})}function VF(){const{text:t}=jf(HO(),db);return T.jsx("div",{className:"step reasoning",children:t})}function HF({toolName:t,argsText:e,args:n,result:r}){const s=n??{},i=s.full||s.text||e||"",o=typeof r=="string"?r:void 0;switch(t){case"status":return T.jsxs("div",{className:"part status",children:["◌ ",i]});case"ask":return T.jsxs("div",{className:"part ask",children:[T.jsx("div",{className:"ask-head",children:"⏸ 等待人工回答"}),T.jsx("div",{className:"ask-body",children:i})]});case"permission":return T.jsxs("details",{className:"part permission",open:!0,children:[T.jsxs("summary",{children:["🔐 权限请求",s.tool?` · ${s.tool}`:""]}),T.jsx("pre",{children:i})]});case"tool_result":return T.jsxs("details",{className:"part tool",children:[T.jsx("summary",{children:"↳ 工具结果"}),T.jsx("pre",{children:i})]});default:{const a=s.tool||"工具调用";return T.jsxs("details",{className:"part tool",children:[T.jsxs("summary",{children:["🔧 ",a,i&&i!==a?T.jsxs("span",{className:"hint",children:[" — ",i.split(`
79
+ `)[0]]}):null]}),i?T.jsx("pre",{children:i}):null,o?T.jsxs("div",{className:"tool-result",children:[T.jsx("span",{className:"lbl",children:"↳ 输出"}),T.jsx("pre",{children:o})]}):null]})}}}const qF=r3({reasoning:["group-thought"],"tool-call":["group-thought"]}),Wy=new Map;function GF({storeKey:t,count:e,children:n}){const[r,s]=ee.useState(()=>Wy.get(t)??!0);return T.jsxs("details",{className:"thought",open:r,onToggle:i=>{const o=i.currentTarget.open;Wy.set(t,o),s(o)},children:[T.jsxs("summary",{children:["思考过程 · ",e," 步"]}),T.jsx("div",{className:"thought-steps",children:n})]})}function fb(){const t=G(e=>{var n;return(n=e.message)==null?void 0:n.id});return T.jsx(Mr.GroupedParts,{groupBy:qF,children:({part:e,children:n})=>{switch(e.type){case"group-thought":return T.jsx(GF,{storeKey:`${t??"m"}:${e.indices[0]??0}`,count:e.indices.length,children:n});case"reasoning":return T.jsx(VF,{});case"tool-call":return e.toolUI??T.jsx(HF,{toolName:e.toolName,argsText:e.argsText,args:e.args,result:e.result});case"indicator":return T.jsx("div",{className:"step pending",children:"思考中…"});case"text":return T.jsx(UF,{});default:return null}}})}function WF({children:t}){const e=j3(QO);return T.jsx(Z1,{runtime:e,children:t})}function QF(t){const e=[];return t.forEach((n,r)=>{const s=rS([n]);s.length!==0&&e.push({id:`g-${r}`,role:"assistant",content:s})}),e}function KF({groups:t,isRunning:e}){const n=ee.useMemo(()=>QF(t),[t]),r=y2({messages:n,isRunning:e,isDisabled:!0,convertMessage:s=>s,onNew:async()=>{}});return T.jsx(Z1,{runtime:r,children:T.jsx(In.Root,{className:"thread",children:T.jsx(In.Viewport,{className:"viewport",children:T.jsx(In.Messages,{components:{UserMessage:()=>T.jsx(Mr.Root,{className:"msg user",children:T.jsx(Mr.Content,{components:{Text:hb}})}),AssistantMessage:()=>T.jsx(Mr.Root,{className:"msg assistant",children:T.jsx(fb,{})})}})})})})}const YF=5e3;function Qy(t){return t.length>18?`${t.slice(0,18)}…`:t}function JF({initialRunId:t}){const[e,n]=ee.useState([]),[r,s]=ee.useState(t??""),[i,o]=ee.useState([]),[a,l]=ee.useState(null),[u,c]=ee.useState(null);ee.useEffect(()=>{let f=!0;const p=()=>fetch("/api/runs").then(_=>_.ok?_.json():{runs:[]}).then(_=>{f&&n(_.runs??[])}).catch(()=>{});p();const g=setInterval(()=>void p(),YF);return()=>{f=!1,clearInterval(g)}},[]);const d=f=>{s(f);const p=new URL(location.href);p.searchParams.set("run",f),history.replaceState(null,"",p)};ee.useEffect(()=>{!r&&e[0]&&d(e[0].id)},[e,r]),ee.useEffect(()=>{if(!r)return;const f=new AbortController;return o([]),l(null),c(null),(async()=>{const p=encodeURIComponent(r);try{const g=await(await fetch(`/api/runs/${p}/events`)).json();o(g.groups??[]),l(g.run??null);for await(const _ of sS(`/api/runs/${p}/stream`,f.signal))if(o(_.groups),_.run&&l(_.run),_.run&&_.run.status!=="running")break}catch(g){(g==null?void 0:g.name)!=="AbortError"&&c(`加载失败:${g instanceof Error?g.message:String(g)}`)}})(),()=>f.abort()},[r]);const h=(a==null?void 0:a.status)==="running";return T.jsxs("div",{className:"runs-layout",children:[T.jsxs("aside",{className:"runs-side",children:[T.jsx("div",{className:"pane-head",children:"Runs"}),T.jsxs("ul",{className:"run-list",children:[e.length===0?T.jsx("li",{className:"empty-side",children:"暂无 run"}):null,e.map(f=>T.jsx("li",{children:T.jsxs("button",{type:"button",className:f.id===r?"run-item active":"run-item",onClick:()=>d(f.id),children:[T.jsx("span",{className:`badge ${f.status}`,children:f.status}),T.jsx("span",{className:`badge src ${f.source}`,children:f.source==="chat"?"chat":"engine"}),T.jsx("span",{className:"run-id mono",children:Qy(f.id)}),T.jsxs("span",{className:"muted",children:[f.agent," · ",f.eventCount," ev"]})]})},f.id))]})]}),T.jsxs("section",{className:"run-detail",children:[T.jsxs("div",{className:"pane-head",children:[T.jsx("span",{className:"mono",children:r?Qy(r):"(未选择 run)"}),T.jsx("span",{className:"spacer"}),a?T.jsx("span",{className:`badge ${a.status}`,children:a.status}):null,h?T.jsx("span",{className:"muted",children:"实时更新中…"}):null]}),u?T.jsx("div",{className:"notice",children:u}):i.length===0&&!h?T.jsx("div",{className:"empty",children:r?"该 run 暂无可展示输出(引擎 run 不保存 prompt,仅呈现 agent 输出)。":"选择左侧 run 查看。"}):T.jsx(KF,{groups:i,isRunning:h})]})]})}function XF(){const[t,e]=ee.useState(0),[n,r]=ee.useState([]),[s,i]=ee.useState("");ee.useEffect(()=>{fetch("/api/chat/agents").then(l=>l.ok?l.json():{agents:[]}).then(l=>{const u=l.agents??[];r(u),u[0]&&(i(u[0]),ll.agent=u[0])}).catch(()=>r([]))},[]);const o=l=>{i(l),ll.agent=l||void 0},a=()=>{GO(),e(l=>l+1)};return T.jsxs("div",{className:"chat-body",children:[T.jsxs("div",{className:"chat-controls",children:[T.jsxs("select",{className:"agent",value:s,onChange:l=>o(l.target.value),disabled:n.length===0,title:"本机可用 Agent",children:[n.length===0?T.jsx("option",{value:"",children:"(无可用 agent)"}):null,n.map(l=>T.jsx("option",{value:l,children:l},l))]}),T.jsx("button",{className:"ghost",onClick:a,children:"新会话"})]}),T.jsx(WF,{children:T.jsxs(In.Root,{className:"thread",children:[T.jsxs(In.Viewport,{className:"viewport",children:[T.jsx(In.Empty,{children:T.jsx("div",{className:"empty",children:"向本机 Agent 发一句(Enter 发送,运行中可停止;同一会话自动续聊)。"})}),T.jsx(In.Messages,{components:{UserMessage:()=>T.jsx(Mr.Root,{className:"msg user",children:T.jsx(Mr.Content,{components:{Text:hb}})}),AssistantMessage:()=>T.jsx(Mr.Root,{className:"msg assistant",children:T.jsx(fb,{})})}})]}),T.jsxs(ta.Root,{className:"composer",children:[T.jsx(ta.Input,{className:"input",placeholder:"输入消息…",submitOnEnter:!0}),T.jsx(In.If,{running:!1,children:T.jsx(ta.Send,{className:"btn primary",children:"发送"})}),T.jsx(In.If,{running:!0,children:T.jsx(ta.Cancel,{className:"btn",children:"停止"})})]})]})},t)]})}function ZF(){const[t,e]=ee.useState("runs"),[n]=ee.useState(()=>new URLSearchParams(location.search).get("run")??void 0),[r,s]=ee.useState(null);return ee.useEffect(()=>{fetch("/health").then(i=>i.json()).then(i=>s((i==null?void 0:i.chat)===!0)).catch(()=>s(!1))},[]),T.jsxs("main",{className:"page",children:[T.jsxs("header",{className:"topbar",children:[T.jsx("span",{className:"title",children:"aitable-workflow · Assistant"}),T.jsxs("nav",{className:"tabs",children:[T.jsx("button",{type:"button",className:t==="runs"?"tab active":"tab",onClick:()=>e("runs"),children:"运行"}),r===!0?T.jsx("button",{type:"button",className:t==="chat"?"tab active":"tab",onClick:()=>e("chat"),children:"对话"}):null]}),T.jsx("span",{className:"spacer"}),T.jsx("a",{className:"ghost link",href:"/classic",title:"返回经典监控视图",children:"经典视图"})]}),t==="runs"||r!==!0?T.jsx(JF,{initialRunId:n}):T.jsx(XF,{})]})}vw(document.getElementById("root")).render(T.jsx(ee.StrictMode,{children:T.jsx(ZF,{})}));