@idl3/claude-control 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -9
- package/lib/match.js +24 -32
- package/lib/optimize.js +5 -0
- package/lib/shell.js +8 -0
- package/package.json +1 -1
- package/web/dist/assets/{core-DM2iK52g.js → core-DjwRjAVq.js} +1 -1
- package/web/dist/assets/{index-DwNp83VT.css → index-DJcMTsha.css} +1 -1
- package/web/dist/assets/{index-DwmU8Yna.js → index-Dar5Ut3m.js} +39 -39
- package/web/dist/index.html +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Xb=Object.defineProperty;var Zb=(e,t,n)=>t in e?Xb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var T=(e,t,n)=>Zb(e,typeof t!="symbol"?t+"":t,n);function eS(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in e)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.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 Io=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ei(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Am={exports:{}},va={},jm={exports:{}},ue={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@ var Yb=Object.defineProperty;var Jb=(e,t,n)=>t in e?Yb(e,t,{enumerable:!0,config
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Ti=Symbol.for("react.element"),
|
|
9
|
+
*/var Ti=Symbol.for("react.element"),tS=Symbol.for("react.portal"),nS=Symbol.for("react.fragment"),rS=Symbol.for("react.strict_mode"),sS=Symbol.for("react.profiler"),iS=Symbol.for("react.provider"),oS=Symbol.for("react.context"),aS=Symbol.for("react.forward_ref"),lS=Symbol.for("react.suspense"),uS=Symbol.for("react.memo"),cS=Symbol.for("react.lazy"),of=Symbol.iterator;function dS(e){return e===null||typeof e!="object"?null:(e=of&&e[of]||e["@@iterator"],typeof e=="function"?e:null)}var Nm={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Mm=Object.assign,Dm={};function us(e,t,n){this.props=e,this.context=t,this.refs=Dm,this.updater=n||Nm}us.prototype.isReactComponent={};us.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=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,e,t,"setState")};us.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Lm(){}Lm.prototype=us.prototype;function yc(e,t,n){this.props=e,this.context=t,this.refs=Dm,this.updater=n||Nm}var vc=yc.prototype=new Lm;vc.constructor=yc;Mm(vc,us.prototype);vc.isPureReactComponent=!0;var af=Array.isArray,Om=Object.prototype.hasOwnProperty,xc={current:null},zm={key:!0,ref:!0,__self:!0,__source:!0};function Fm(e,t,n){var r,s={},i=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(i=""+t.key),t)Om.call(t,r)&&!zm.hasOwnProperty(r)&&(s[r]=t[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(e&&e.defaultProps)for(r in a=e.defaultProps,a)s[r]===void 0&&(s[r]=a[r]);return{$$typeof:Ti,type:e,key:i,ref:o,props:s,_owner:xc.current}}function fS(e,t){return{$$typeof:Ti,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function wc(e){return typeof e=="object"&&e!==null&&e.$$typeof===Ti}function hS(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var lf=/\/+/g;function Xa(e,t){return typeof e=="object"&&e!==null&&e.key!=null?hS(""+e.key):t.toString(36)}function co(e,t,n,r,s){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case Ti:case tS:o=!0}}if(o)return o=e,s=s(o),e=r===""?"."+Xa(o,0):r,af(s)?(n="",e!=null&&(n=e.replace(lf,"$&/")+"/"),co(s,t,n,"",function(u){return u})):s!=null&&(wc(s)&&(s=fS(s,n+(!s.key||o&&o.key===s.key?"":(""+s.key).replace(lf,"$&/")+"/")+e)),t.push(s)),1;if(o=0,r=r===""?".":r+":",af(e))for(var a=0;a<e.length;a++){i=e[a];var l=r+Xa(i,a);o+=co(i,t,n,l,s)}else if(l=dS(e),typeof l=="function")for(e=l.call(e),a=0;!(i=e.next()).done;)i=i.value,l=r+Xa(i,a++),o+=co(i,t,n,l,s);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return o}function Di(e,t,n){if(e==null)return e;var r=[],s=0;return co(e,r,"","",function(i){return t.call(n,i,s++)}),r}function pS(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var st={current:null},fo={transition:null},mS={ReactCurrentDispatcher:st,ReactCurrentBatchConfig:fo,ReactCurrentOwner:xc};function Bm(){throw Error("act(...) is not supported in production builds of React.")}ue.Children={map:Di,forEach:function(e,t,n){Di(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Di(e,function(){t++}),t},toArray:function(e){return Di(e,function(t){return t})||[]},only:function(e){if(!wc(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ue.Component=us;ue.Fragment=nS;ue.Profiler=sS;ue.PureComponent=yc;ue.StrictMode=rS;ue.Suspense=lS;ue.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=mS;ue.act=Bm;ue.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=Mm({},e.props),s=e.key,i=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,o=xc.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(l in t)Om.call(t,l)&&!zm.hasOwnProperty(l)&&(r[l]=t[l]===void 0&&a!==void 0?a[l]:t[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:Ti,type:e.type,key:s,ref:i,props:r,_owner:o}};ue.createContext=function(e){return e={$$typeof:oS,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:iS,_context:e},e.Consumer=e};ue.createElement=Fm;ue.createFactory=function(e){var t=Fm.bind(null,e);return t.type=e,t};ue.createRef=function(){return{current:null}};ue.forwardRef=function(e){return{$$typeof:aS,render:e}};ue.isValidElement=wc;ue.lazy=function(e){return{$$typeof:cS,_payload:{_status:-1,_result:e},_init:pS}};ue.memo=function(e,t){return{$$typeof:uS,type:e,compare:t===void 0?null:t}};ue.startTransition=function(e){var t=fo.transition;fo.transition={};try{e()}finally{fo.transition=t}};ue.unstable_act=Bm;ue.useCallback=function(e,t){return st.current.useCallback(e,t)};ue.useContext=function(e){return st.current.useContext(e)};ue.useDebugValue=function(){};ue.useDeferredValue=function(e){return st.current.useDeferredValue(e)};ue.useEffect=function(e,t){return st.current.useEffect(e,t)};ue.useId=function(){return st.current.useId()};ue.useImperativeHandle=function(e,t,n){return st.current.useImperativeHandle(e,t,n)};ue.useInsertionEffect=function(e,t){return st.current.useInsertionEffect(e,t)};ue.useLayoutEffect=function(e,t){return st.current.useLayoutEffect(e,t)};ue.useMemo=function(e,t){return st.current.useMemo(e,t)};ue.useReducer=function(e,t,n){return st.current.useReducer(e,t,n)};ue.useRef=function(e){return st.current.useRef(e)};ue.useState=function(e){return st.current.useState(e)};ue.useSyncExternalStore=function(e,t,n){return st.current.useSyncExternalStore(e,t,n)};ue.useTransition=function(){return st.current.useTransition()};ue.version="18.3.1";jm.exports=ue;var m=jm.exports;const ut=Ei(m),gS=eS({__proto__:null,default:ut},[m]);/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.production.min.js
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@ var Yb=Object.defineProperty;var Jb=(e,t,n)=>t in e?Yb(e,t,{enumerable:!0,config
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var yS=m,vS=Symbol.for("react.element"),xS=Symbol.for("react.fragment"),wS=Object.prototype.hasOwnProperty,bS=yS.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,SS={key:!0,ref:!0,__self:!0,__source:!0};function $m(e,t,n){var r,s={},i=null,o=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)wS.call(t,r)&&!SS.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:vS,type:e,key:i,ref:o,props:s,_owner:bS.current}}va.Fragment=xS;va.jsx=$m;va.jsxs=$m;Am.exports=va;var c=Am.exports,Um={exports:{}},Ct={},Vm={exports:{}},Hm={};/**
|
|
18
18
|
* @license React
|
|
19
19
|
* scheduler.production.min.js
|
|
20
20
|
*
|
|
@@ -22,7 +22,7 @@ var Yb=Object.defineProperty;var Jb=(e,t,n)=>t in e?Yb(e,t,{enumerable:!0,config
|
|
|
22
22
|
*
|
|
23
23
|
* This source code is licensed under the MIT license found in the
|
|
24
24
|
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/(function(e){function t(F,
|
|
25
|
+
*/(function(e){function t(F,D){var b=F.length;F.push(D);e:for(;0<b;){var J=b-1>>>1,Y=F[J];if(0<s(Y,D))F[J]=D,F[b]=Y,b=J;else break e}}function n(F){return F.length===0?null:F[0]}function r(F){if(F.length===0)return null;var D=F[0],b=F.pop();if(b!==D){F[0]=b;e:for(var J=0,Y=F.length,C=Y>>>1;J<C;){var ge=2*(J+1)-1,A=F[ge],O=ge+1,W=F[O];if(0>s(A,b))O<Y&&0>s(W,A)?(F[J]=W,F[O]=b,J=O):(F[J]=A,F[ge]=b,J=ge);else if(O<Y&&0>s(W,b))F[J]=W,F[O]=b,J=O;else break e}}return D}function s(F,D){var b=F.sortIndex-D.sortIndex;return b!==0?b:F.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var l=[],u=[],f=1,d=null,h=3,p=!1,g=!1,v=!1,S=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(F){for(var D=n(u);D!==null;){if(D.callback===null)r(u);else if(D.startTime<=F)r(u),D.sortIndex=D.expirationTime,t(l,D);else break;D=n(u)}}function E(F){if(v=!1,w(F),!g)if(n(l)!==null)g=!0,ee(I);else{var D=n(u);D!==null&&ae(E,D.startTime-F)}}function I(F,D){g=!1,v&&(v=!1,y(M),M=-1),p=!0;var b=h;try{for(w(D),d=n(l);d!==null&&(!(d.expirationTime>D)||F&&!z());){var J=d.callback;if(typeof J=="function"){d.callback=null,h=d.priorityLevel;var Y=J(d.expirationTime<=D);D=e.unstable_now(),typeof Y=="function"?d.callback=Y:d===n(l)&&r(l),w(D)}else r(l);d=n(l)}if(d!==null)var C=!0;else{var ge=n(u);ge!==null&&ae(E,ge.startTime-D),C=!1}return C}finally{d=null,h=b,p=!1}}var k=!1,R=null,M=-1,L=5,_=-1;function z(){return!(e.unstable_now()-_<L)}function N(){if(R!==null){var F=e.unstable_now();_=F;var D=!0;try{D=R(!0,F)}finally{D?K():(k=!1,R=null)}}else k=!1}var K;if(typeof x=="function")K=function(){x(N)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,B=P.port2;P.port1.onmessage=N,K=function(){B.postMessage(null)}}else K=function(){S(N,0)};function ee(F){R=F,k||(k=!0,K())}function ae(F,D){M=S(function(){F(e.unstable_now())},D)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(F){F.callback=null},e.unstable_continueExecution=function(){g||p||(g=!0,ee(I))},e.unstable_forceFrameRate=function(F){0>F||125<F?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<F?Math.floor(1e3/F):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(l)},e.unstable_next=function(F){switch(h){case 1:case 2:case 3:var D=3;break;default:D=h}var b=h;h=D;try{return F()}finally{h=b}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(F,D){switch(F){case 1:case 2:case 3:case 4:case 5:break;default:F=3}var b=h;h=F;try{return D()}finally{h=b}},e.unstable_scheduleCallback=function(F,D,b){var J=e.unstable_now();switch(typeof b=="object"&&b!==null?(b=b.delay,b=typeof b=="number"&&0<b?J+b:J):b=J,F){case 1:var Y=-1;break;case 2:Y=250;break;case 5:Y=1073741823;break;case 4:Y=1e4;break;default:Y=5e3}return Y=b+Y,F={id:f++,callback:D,priorityLevel:F,startTime:b,expirationTime:Y,sortIndex:-1},b>J?(F.sortIndex=b,t(u,F),n(l)===null&&F===n(u)&&(v?(y(M),M=-1):v=!0,ae(E,b-J))):(F.sortIndex=Y,t(l,F),g||p||(g=!0,ee(I))),F},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(F){var D=h;return function(){var b=h;h=D;try{return F.apply(this,arguments)}finally{h=b}}}})(Hm);Vm.exports=Hm;var kS=Vm.exports;/**
|
|
26
26
|
* @license React
|
|
27
27
|
* react-dom.production.min.js
|
|
28
28
|
*
|
|
@@ -30,60 +30,60 @@ var Yb=Object.defineProperty;var Jb=(e,t,n)=>t in e?Yb(e,t,{enumerable:!0,config
|
|
|
30
30
|
*
|
|
31
31
|
* This source code is licensed under the MIT license found in the
|
|
32
32
|
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var
|
|
33
|
+
*/var CS=m,St=kS;function $(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var Wm=new Set,ni={};function yr(e,t){Jr(e,t),Jr(e+"Capture",t)}function Jr(e,t){for(ni[e]=t,e=0;e<t.length;e++)Wm.add(t[e])}var mn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Yl=Object.prototype.hasOwnProperty,_S=/^[: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]*$/,uf={},cf={};function ES(e){return Yl.call(cf,e)?!0:Yl.call(uf,e)?!1:_S.test(e)?cf[e]=!0:(uf[e]=!0,!1)}function TS(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function IS(e,t,n,r){if(t===null||typeof t>"u"||TS(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function it(e,t,n,r,s,i,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=o}var qe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){qe[e]=new it(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];qe[t]=new it(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){qe[e]=new it(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){qe[e]=new it(e,2,!1,e,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(e){qe[e]=new it(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){qe[e]=new it(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){qe[e]=new it(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){qe[e]=new it(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){qe[e]=new it(e,5,!1,e.toLowerCase(),null,!1,!1)});var bc=/[\-:]([a-z])/g;function Sc(e){return e[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(e){var t=e.replace(bc,Sc);qe[t]=new it(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(bc,Sc);qe[t]=new it(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(bc,Sc);qe[t]=new it(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){qe[e]=new it(e,1,!1,e.toLowerCase(),null,!1,!1)});qe.xlinkHref=new it("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){qe[e]=new it(e,1,!1,e.toLowerCase(),null,!0,!0)});function kc(e,t,n,r){var s=qe.hasOwnProperty(t)?qe[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(IS(t,n,s,r)&&(n=null),r||s===null?ES(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):s.mustUseProperty?e[s.propertyName]=n===null?s.type===3?!1:"":n:(t=s.attributeName,r=s.attributeNamespace,n===null?e.removeAttribute(t):(s=s.type,n=s===3||s===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var xn=CS.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Li=Symbol.for("react.element"),Ar=Symbol.for("react.portal"),jr=Symbol.for("react.fragment"),Cc=Symbol.for("react.strict_mode"),Jl=Symbol.for("react.profiler"),qm=Symbol.for("react.provider"),Km=Symbol.for("react.context"),_c=Symbol.for("react.forward_ref"),Xl=Symbol.for("react.suspense"),Zl=Symbol.for("react.suspense_list"),Ec=Symbol.for("react.memo"),Cn=Symbol.for("react.lazy"),Gm=Symbol.for("react.offscreen"),df=Symbol.iterator;function Ss(e){return e===null||typeof e!="object"?null:(e=df&&e[df]||e["@@iterator"],typeof e=="function"?e:null)}var Re=Object.assign,Za;function Ns(e){if(Za===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Za=t&&t[1]||""}return`
|
|
34
34
|
`+Za+e}var el=!1;function tl(e,t){if(!e||el)return"";el=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var s=u.stack.split(`
|
|
35
35
|
`),i=r.stack.split(`
|
|
36
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 e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}while(1<=o&&0<=a);break}}}finally{el=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Ns(e):""}function TS(e){switch(e.tag){case 5:return Ns(e.type);case 16:return Ns("Lazy");case 13:return Ns("Suspense");case 19:return Ns("SuspenseList");case 0:case 2:case 15:return e=tl(e.type,!1),e;case 11:return e=tl(e.type.render,!1),e;case 1:return e=tl(e.type,!0),e;default:return""}}function eu(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case jr:return"Fragment";case Ar:return"Portal";case Jl:return"Profiler";case Cc:return"StrictMode";case Xl:return"Suspense";case Zl:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case qm:return(e.displayName||"Context")+".Consumer";case Wm:return(e._context.displayName||"Context")+".Provider";case _c:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ec:return t=e.displayName||null,t!==null?t:eu(e.type)||"Memo";case Cn:t=e._payload,e=e._init;try{return eu(e(t))}catch{}}return null}function IS(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return eu(t);case 8:return t===Cc?"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 t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Bn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Gm(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function RS(e){var t=Gm(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Oi(e){e._valueTracker||(e._valueTracker=RS(e))}function Qm(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Gm(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ro(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function tu(e,t){var n=t.checked;return Ie({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ff(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Bn(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Ym(e,t){t=t.checked,t!=null&&kc(e,"checked",t,!1)}function nu(e,t){Ym(e,t);var n=Bn(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?ru(e,t.type,n):t.hasOwnProperty("defaultValue")&&ru(e,t.type,Bn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function hf(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function ru(e,t,n){(t!=="number"||Ro(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Ms=Array.isArray;function Vr(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s<n.length;s++)t["$"+n[s]]=!0;for(n=0;n<e.length;n++)s=t.hasOwnProperty("$"+e[n].value),e[n].selected!==s&&(e[n].selected=s),s&&r&&(e[n].defaultSelected=!0)}else{for(n=""+Bn(n),t=null,s=0;s<e.length;s++){if(e[s].value===n){e[s].selected=!0,r&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function su(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error($(91));return Ie({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function pf(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error($(92));if(Ms(n)){if(1<n.length)throw Error($(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Bn(n)}}function Jm(e,t){var n=Bn(t.value),r=Bn(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function mf(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Xm(e){switch(e){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 iu(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Xm(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var zi,Zm=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,s){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,s)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(zi=zi||document.createElement("div"),zi.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=zi.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ri(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Os={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},PS=["Webkit","ms","Moz","O"];Object.keys(Os).forEach(function(e){PS.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Os[t]=Os[e]})});function eg(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Os.hasOwnProperty(e)&&Os[e]?(""+t).trim():t+"px"}function tg(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=eg(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var AS=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 ou(e,t){if(t){if(AS[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error($(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error($(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error($(61))}if(t.style!=null&&typeof t.style!="object")throw Error($(62))}}function au(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){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 lu=null;function Tc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var uu=null,Hr=null,Wr=null;function gf(e){if(e=Pi(e)){if(typeof uu!="function")throw Error($(280));var t=e.stateNode;t&&(t=ka(t),uu(e.stateNode,e.type,t))}}function ng(e){Hr?Wr?Wr.push(e):Wr=[e]:Hr=e}function rg(){if(Hr){var e=Hr,t=Wr;if(Wr=Hr=null,gf(e),t)for(e=0;e<t.length;e++)gf(t[e])}}function sg(e,t){return e(t)}function ig(){}var nl=!1;function og(e,t,n){if(nl)return e(t,n);nl=!0;try{return sg(e,t,n)}finally{nl=!1,(Hr!==null||Wr!==null)&&(ig(),rg())}}function si(e,t){var n=e.stateNode;if(n===null)return null;var r=ka(n);if(r===null)return null;n=r[t];e:switch(t){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)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error($(231,t,typeof n));return n}var cu=!1;if(mn)try{var ks={};Object.defineProperty(ks,"passive",{get:function(){cu=!0}}),window.addEventListener("test",ks,ks),window.removeEventListener("test",ks,ks)}catch{cu=!1}function jS(e,t,n,r,s,i,o,a,l){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(f){this.onError(f)}}var zs=!1,Po=null,Ao=!1,du=null,NS={onError:function(e){zs=!0,Po=e}};function MS(e,t,n,r,s,i,o,a,l){zs=!1,Po=null,jS.apply(NS,arguments)}function DS(e,t,n,r,s,i,o,a,l){if(MS.apply(this,arguments),zs){if(zs){var u=Po;zs=!1,Po=null}else throw Error($(198));Ao||(Ao=!0,du=u)}}function vr(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function ag(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function yf(e){if(vr(e)!==e)throw Error($(188))}function LS(e){var t=e.alternate;if(!t){if(t=vr(e),t===null)throw Error($(188));return t!==e?null:e}for(var n=e,r=t;;){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 yf(s),e;if(i===r)return yf(s),t;i=i.sibling}throw Error($(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($(189))}}if(n.alternate!==r)throw Error($(190))}if(n.tag!==3)throw Error($(188));return n.stateNode.current===n?e:t}function lg(e){return e=LS(e),e!==null?ug(e):null}function ug(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=ug(e);if(t!==null)return t;e=e.sibling}return null}var cg=St.unstable_scheduleCallback,vf=St.unstable_cancelCallback,OS=St.unstable_shouldYield,zS=St.unstable_requestPaint,Ae=St.unstable_now,FS=St.unstable_getCurrentPriorityLevel,Ic=St.unstable_ImmediatePriority,dg=St.unstable_UserBlockingPriority,jo=St.unstable_NormalPriority,BS=St.unstable_LowPriority,fg=St.unstable_IdlePriority,xa=null,Zt=null;function $S(e){if(Zt&&typeof Zt.onCommitFiberRoot=="function")try{Zt.onCommitFiberRoot(xa,e,void 0,(e.current.flags&128)===128)}catch{}}var Bt=Math.clz32?Math.clz32:HS,US=Math.log,VS=Math.LN2;function HS(e){return e>>>=0,e===0?32:31-(US(e)/VS|0)|0}var Fi=64,Bi=4194304;function Ds(e){switch(e&-e){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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function No(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~s;a!==0?r=Ds(a):(i&=o,i!==0&&(r=Ds(i)))}else o=n&~s,o!==0?r=Ds(o):i!==0&&(r=Ds(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Bt(t),s=1<<n,r|=e[n],t&=~s;return r}function WS(e,t){switch(e){case 1:case 2:case 4:return t+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 t+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 qS(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var o=31-Bt(i),a=1<<o,l=s[o];l===-1?(!(a&n)||a&r)&&(s[o]=WS(a,t)):l<=t&&(e.expiredLanes|=a),i&=~a}}function fu(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function hg(){var e=Fi;return Fi<<=1,!(Fi&4194240)&&(Fi=64),e}function rl(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ii(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Bt(t),e[t]=n}function KS(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var s=31-Bt(n),i=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~i}}function Rc(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Bt(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var me=0;function pg(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var mg,Pc,gg,yg,vg,hu=!1,$i=[],An=null,jn=null,Nn=null,ii=new Map,oi=new Map,Tn=[],GS="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 xf(e,t){switch(e){case"focusin":case"focusout":An=null;break;case"dragenter":case"dragleave":jn=null;break;case"mouseover":case"mouseout":Nn=null;break;case"pointerover":case"pointerout":ii.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":oi.delete(t.pointerId)}}function Cs(e,t,n,r,s,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[s]},t!==null&&(t=Pi(t),t!==null&&Pc(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function QS(e,t,n,r,s){switch(t){case"focusin":return An=Cs(An,e,t,n,r,s),!0;case"dragenter":return jn=Cs(jn,e,t,n,r,s),!0;case"mouseover":return Nn=Cs(Nn,e,t,n,r,s),!0;case"pointerover":var i=s.pointerId;return ii.set(i,Cs(ii.get(i)||null,e,t,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,oi.set(i,Cs(oi.get(i)||null,e,t,n,r,s)),!0}return!1}function xg(e){var t=nr(e.target);if(t!==null){var n=vr(t);if(n!==null){if(t=n.tag,t===13){if(t=ag(n),t!==null){e.blockedOn=t,vg(e.priority,function(){gg(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ho(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=pu(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);lu=r,n.target.dispatchEvent(r),lu=null}else return t=Pi(n),t!==null&&Pc(t),e.blockedOn=n,!1;t.shift()}return!0}function wf(e,t,n){ho(e)&&n.delete(t)}function YS(){hu=!1,An!==null&&ho(An)&&(An=null),jn!==null&&ho(jn)&&(jn=null),Nn!==null&&ho(Nn)&&(Nn=null),ii.forEach(wf),oi.forEach(wf)}function _s(e,t){e.blockedOn===t&&(e.blockedOn=null,hu||(hu=!0,St.unstable_scheduleCallback(St.unstable_NormalPriority,YS)))}function ai(e){function t(s){return _s(s,e)}if(0<$i.length){_s($i[0],e);for(var n=1;n<$i.length;n++){var r=$i[n];r.blockedOn===e&&(r.blockedOn=null)}}for(An!==null&&_s(An,e),jn!==null&&_s(jn,e),Nn!==null&&_s(Nn,e),ii.forEach(t),oi.forEach(t),n=0;n<Tn.length;n++)r=Tn[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Tn.length&&(n=Tn[0],n.blockedOn===null);)xg(n),n.blockedOn===null&&Tn.shift()}var qr=xn.ReactCurrentBatchConfig,Mo=!0;function JS(e,t,n,r){var s=me,i=qr.transition;qr.transition=null;try{me=1,Ac(e,t,n,r)}finally{me=s,qr.transition=i}}function XS(e,t,n,r){var s=me,i=qr.transition;qr.transition=null;try{me=4,Ac(e,t,n,r)}finally{me=s,qr.transition=i}}function Ac(e,t,n,r){if(Mo){var s=pu(e,t,n,r);if(s===null)hl(e,t,r,Do,n),xf(e,r);else if(QS(s,e,t,n,r))r.stopPropagation();else if(xf(e,r),t&4&&-1<GS.indexOf(e)){for(;s!==null;){var i=Pi(s);if(i!==null&&mg(i),i=pu(e,t,n,r),i===null&&hl(e,t,r,Do,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else hl(e,t,r,null,n)}}var Do=null;function pu(e,t,n,r){if(Do=null,e=Tc(r),e=nr(e),e!==null)if(t=vr(e),t===null)e=null;else if(n=t.tag,n===13){if(e=ag(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Do=e,null}function wg(e){switch(e){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(FS()){case Ic:return 1;case dg:return 4;case jo:case BS:return 16;case fg:return 536870912;default:return 16}default:return 16}}var Rn=null,jc=null,po=null;function bg(){if(po)return po;var e,t=jc,n=t.length,r,s="value"in Rn?Rn.value:Rn.textContent,i=s.length;for(e=0;e<n&&t[e]===s[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===s[i-r];r++);return po=s.slice(e,1<r?1-r:void 0)}function mo(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Ui(){return!0}function bf(){return!1}function _t(e){function t(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 e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(i):i[a]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Ui:bf,this.isPropagationStopped=bf,this}return Ie(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Ui)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Ui)},persist:function(){},isPersistent:Ui}),t}var cs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Nc=_t(cs),Ri=Ie({},cs,{view:0,detail:0}),ZS=_t(Ri),sl,il,Es,wa=Ie({},Ri,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mc,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Es&&(Es&&e.type==="mousemove"?(sl=e.screenX-Es.screenX,il=e.screenY-Es.screenY):il=sl=0,Es=e),sl)},movementY:function(e){return"movementY"in e?e.movementY:il}}),Sf=_t(wa),ek=Ie({},wa,{dataTransfer:0}),tk=_t(ek),nk=Ie({},Ri,{relatedTarget:0}),ol=_t(nk),rk=Ie({},cs,{animationName:0,elapsedTime:0,pseudoElement:0}),sk=_t(rk),ik=Ie({},cs,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ok=_t(ik),ak=Ie({},cs,{data:0}),kf=_t(ak),lk={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},uk={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"},ck={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function dk(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=ck[e])?!!t[e]:!1}function Mc(){return dk}var fk=Ie({},Ri,{key:function(e){if(e.key){var t=lk[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=mo(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?uk[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mc,charCode:function(e){return e.type==="keypress"?mo(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?mo(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),hk=_t(fk),pk=Ie({},wa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Cf=_t(pk),mk=Ie({},Ri,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mc}),gk=_t(mk),yk=Ie({},cs,{propertyName:0,elapsedTime:0,pseudoElement:0}),vk=_t(yk),xk=Ie({},wa,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),wk=_t(xk),bk=[9,13,27,32],Dc=mn&&"CompositionEvent"in window,Fs=null;mn&&"documentMode"in document&&(Fs=document.documentMode);var Sk=mn&&"TextEvent"in window&&!Fs,Sg=mn&&(!Dc||Fs&&8<Fs&&11>=Fs),_f=" ",Ef=!1;function kg(e,t){switch(e){case"keyup":return bk.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Cg(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Nr=!1;function kk(e,t){switch(e){case"compositionend":return Cg(t);case"keypress":return t.which!==32?null:(Ef=!0,_f);case"textInput":return e=t.data,e===_f&&Ef?null:e;default:return null}}function Ck(e,t){if(Nr)return e==="compositionend"||!Dc&&kg(e,t)?(e=bg(),po=jc=Rn=null,Nr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Sg&&t.locale!=="ko"?null:t.data;default:return null}}var _k={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 Tf(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!_k[e.type]:t==="textarea"}function _g(e,t,n,r){ng(r),t=Lo(t,"onChange"),0<t.length&&(n=new Nc("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Bs=null,li=null;function Ek(e){Lg(e,0)}function ba(e){var t=Lr(e);if(Qm(t))return e}function Tk(e,t){if(e==="change")return t}var Eg=!1;if(mn){var al;if(mn){var ll="oninput"in document;if(!ll){var If=document.createElement("div");If.setAttribute("oninput","return;"),ll=typeof If.oninput=="function"}al=ll}else al=!1;Eg=al&&(!document.documentMode||9<document.documentMode)}function Rf(){Bs&&(Bs.detachEvent("onpropertychange",Tg),li=Bs=null)}function Tg(e){if(e.propertyName==="value"&&ba(li)){var t=[];_g(t,li,e,Tc(e)),og(Ek,t)}}function Ik(e,t,n){e==="focusin"?(Rf(),Bs=t,li=n,Bs.attachEvent("onpropertychange",Tg)):e==="focusout"&&Rf()}function Rk(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ba(li)}function Pk(e,t){if(e==="click")return ba(t)}function Ak(e,t){if(e==="input"||e==="change")return ba(t)}function jk(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Vt=typeof Object.is=="function"?Object.is:jk;function ui(e,t){if(Vt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var s=n[r];if(!Yl.call(t,s)||!Vt(e[s],t[s]))return!1}return!0}function Pf(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Af(e,t){var n=Pf(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Pf(n)}}function Ig(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ig(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Rg(){for(var e=window,t=Ro();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ro(e.document)}return t}function Lc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Nk(e){var t=Rg(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Ig(n.ownerDocument.documentElement,n)){if(r!==null&&Lc(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Af(n,i);var o=Af(n,r);s&&o&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Mk=mn&&"documentMode"in document&&11>=document.documentMode,Mr=null,mu=null,$s=null,gu=!1;function jf(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;gu||Mr==null||Mr!==Ro(r)||(r=Mr,"selectionStart"in r&&Lc(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}),$s&&ui($s,r)||($s=r,r=Lo(mu,"onSelect"),0<r.length&&(t=new Nc("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Mr)))}function Vi(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Dr={animationend:Vi("Animation","AnimationEnd"),animationiteration:Vi("Animation","AnimationIteration"),animationstart:Vi("Animation","AnimationStart"),transitionend:Vi("Transition","TransitionEnd")},ul={},Pg={};mn&&(Pg=document.createElement("div").style,"AnimationEvent"in window||(delete Dr.animationend.animation,delete Dr.animationiteration.animation,delete Dr.animationstart.animation),"TransitionEvent"in window||delete Dr.transitionend.transition);function Sa(e){if(ul[e])return ul[e];if(!Dr[e])return e;var t=Dr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Pg)return ul[e]=t[n];return e}var Ag=Sa("animationend"),jg=Sa("animationiteration"),Ng=Sa("animationstart"),Mg=Sa("transitionend"),Dg=new Map,Nf="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 Wn(e,t){Dg.set(e,t),yr(t,[e])}for(var cl=0;cl<Nf.length;cl++){var dl=Nf[cl],Dk=dl.toLowerCase(),Lk=dl[0].toUpperCase()+dl.slice(1);Wn(Dk,"on"+Lk)}Wn(Ag,"onAnimationEnd");Wn(jg,"onAnimationIteration");Wn(Ng,"onAnimationStart");Wn("dblclick","onDoubleClick");Wn("focusin","onFocus");Wn("focusout","onBlur");Wn(Mg,"onTransitionEnd");Jr("onMouseEnter",["mouseout","mouseover"]);Jr("onMouseLeave",["mouseout","mouseover"]);Jr("onPointerEnter",["pointerout","pointerover"]);Jr("onPointerLeave",["pointerout","pointerover"]);yr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));yr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));yr("onBeforeInput",["compositionend","keypress","textInput","paste"]);yr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));yr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));yr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ls="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(" "),Ok=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ls));function Mf(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,DS(r,t,void 0,e),e.currentTarget=null}function Lg(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],s=r.event;r=r.listeners;e:{var i=void 0;if(t)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;Mf(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;Mf(s,a,u),i=l}}}if(Ao)throw e=du,Ao=!1,du=null,e}function Se(e,t){var n=t[bu];n===void 0&&(n=t[bu]=new Set);var r=e+"__bubble";n.has(r)||(Og(t,e,2,!1),n.add(r))}function fl(e,t,n){var r=0;t&&(r|=4),Og(n,e,r,t)}var Hi="_reactListening"+Math.random().toString(36).slice(2);function ci(e){if(!e[Hi]){e[Hi]=!0,Hm.forEach(function(n){n!=="selectionchange"&&(Ok.has(n)||fl(n,!1,e),fl(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Hi]||(t[Hi]=!0,fl("selectionchange",!1,t))}}function Og(e,t,n,r){switch(wg(t)){case 1:var s=JS;break;case 4:s=XS;break;default:s=Ac}n=s.bind(null,t,n,e),s=void 0,!cu||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),r?s!==void 0?e.addEventListener(t,n,{capture:!0,passive:s}):e.addEventListener(t,n,!0):s!==void 0?e.addEventListener(t,n,{passive:s}):e.addEventListener(t,n,!1)}function hl(e,t,n,r,s){var i=r;if(!(t&1)&&!(t&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=nr(a),o===null)return;if(l=o.tag,l===5||l===6){r=i=o;continue e}a=a.parentNode}}r=r.return}og(function(){var u=i,f=Tc(n),d=[];e:{var h=Dg.get(e);if(h!==void 0){var p=Nc,g=e;switch(e){case"keypress":if(mo(n)===0)break e;case"keydown":case"keyup":p=hk;break;case"focusin":g="focus",p=ol;break;case"focusout":g="blur",p=ol;break;case"beforeblur":case"afterblur":p=ol;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":p=Sf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=tk;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=gk;break;case Ag:case jg:case Ng:p=sk;break;case Mg:p=vk;break;case"scroll":p=ZS;break;case"wheel":p=wk;break;case"copy":case"cut":case"paste":p=ok;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=Cf}var x=(t&4)!==0,k=!x&&e==="scroll",y=x?h!==null?h+"Capture":null:h;x=[];for(var v=u,w;v!==null;){w=v;var E=w.stateNode;if(w.tag===5&&E!==null&&(w=E,y!==null&&(E=si(v,y),E!=null&&x.push(di(v,E,w)))),k)break;v=v.return}0<x.length&&(h=new p(h,g,null,n,f),d.push({event:h,listeners:x}))}}if(!(t&7)){e:{if(h=e==="mouseover"||e==="pointerover",p=e==="mouseout"||e==="pointerout",h&&n!==lu&&(g=n.relatedTarget||n.fromElement)&&(nr(g)||g[gn]))break e;if((p||h)&&(h=f.window===f?f:(h=f.ownerDocument)?h.defaultView||h.parentWindow:window,p?(g=n.relatedTarget||n.toElement,p=u,g=g?nr(g):null,g!==null&&(k=vr(g),g!==k||g.tag!==5&&g.tag!==6)&&(g=null)):(p=null,g=u),p!==g)){if(x=Sf,E="onMouseLeave",y="onMouseEnter",v="mouse",(e==="pointerout"||e==="pointerover")&&(x=Cf,E="onPointerLeave",y="onPointerEnter",v="pointer"),k=p==null?h:Lr(p),w=g==null?h:Lr(g),h=new x(E,v+"leave",p,n,f),h.target=k,h.relatedTarget=w,E=null,nr(f)===u&&(x=new x(y,v+"enter",g,n,f),x.target=w,x.relatedTarget=k,E=x),k=E,p&&g)t:{for(x=p,y=g,v=0,w=x;w;w=Ir(w))v++;for(w=0,E=y;E;E=Ir(E))w++;for(;0<v-w;)x=Ir(x),v--;for(;0<w-v;)y=Ir(y),w--;for(;v--;){if(x===y||y!==null&&x===y.alternate)break t;x=Ir(x),y=Ir(y)}x=null}else x=null;p!==null&&Df(d,h,p,x,!1),g!==null&&k!==null&&Df(d,k,g,x,!0)}}e:{if(h=u?Lr(u):window,p=h.nodeName&&h.nodeName.toLowerCase(),p==="select"||p==="input"&&h.type==="file")var I=Tk;else if(Tf(h))if(Eg)I=Ak;else{I=Rk;var S=Ik}else(p=h.nodeName)&&p.toLowerCase()==="input"&&(h.type==="checkbox"||h.type==="radio")&&(I=Pk);if(I&&(I=I(e,u))){_g(d,I,n,f);break e}S&&S(e,h,u),e==="focusout"&&(S=h._wrapperState)&&S.controlled&&h.type==="number"&&ru(h,"number",h.value)}switch(S=u?Lr(u):window,e){case"focusin":(Tf(S)||S.contentEditable==="true")&&(Mr=S,mu=u,$s=null);break;case"focusout":$s=mu=Mr=null;break;case"mousedown":gu=!0;break;case"contextmenu":case"mouseup":case"dragend":gu=!1,jf(d,n,f);break;case"selectionchange":if(Mk)break;case"keydown":case"keyup":jf(d,n,f)}var R;if(Dc)e:{switch(e){case"compositionstart":var N="onCompositionStart";break e;case"compositionend":N="onCompositionEnd";break e;case"compositionupdate":N="onCompositionUpdate";break e}N=void 0}else Nr?kg(e,n)&&(N="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(N="onCompositionStart");N&&(Sg&&n.locale!=="ko"&&(Nr||N!=="onCompositionStart"?N==="onCompositionEnd"&&Nr&&(R=bg()):(Rn=f,jc="value"in Rn?Rn.value:Rn.textContent,Nr=!0)),S=Lo(u,N),0<S.length&&(N=new kf(N,e,null,n,f),d.push({event:N,listeners:S}),R?N.data=R:(R=Cg(n),R!==null&&(N.data=R)))),(R=Sk?kk(e,n):Ck(e,n))&&(u=Lo(u,"onBeforeInput"),0<u.length&&(f=new kf("onBeforeInput","beforeinput",null,n,f),d.push({event:f,listeners:u}),f.data=R))}Lg(d,t)})}function di(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Lo(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=si(e,n),i!=null&&r.unshift(di(e,i,s)),i=si(e,t),i!=null&&r.push(di(e,i,s))),e=e.return}return r}function Ir(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Df(e,t,n,r,s){for(var i=t._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=si(n,i),l!=null&&o.unshift(di(n,l,a))):s||(l=si(n,i),l!=null&&o.push(di(n,l,a)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var zk=/\r\n?/g,Fk=/\u0000|\uFFFD/g;function Lf(e){return(typeof e=="string"?e:""+e).replace(zk,`
|
|
38
|
-
`).replace(Fk,"")}function Wi(e,t,n){if(t=Lf(t),Lf(e)!==t&&n)throw Error($(425))}function Oo(){}var yu=null,vu=null;function xu(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var wu=typeof setTimeout=="function"?setTimeout:void 0,Bk=typeof clearTimeout=="function"?clearTimeout:void 0,Of=typeof Promise=="function"?Promise:void 0,$k=typeof queueMicrotask=="function"?queueMicrotask:typeof Of<"u"?function(e){return Of.resolve(null).then(e).catch(Uk)}:wu;function Uk(e){setTimeout(function(){throw e})}function pl(e,t){var n=t,r=0;do{var s=n.nextSibling;if(e.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(r===0){e.removeChild(s),ai(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);ai(t)}function Mn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function zf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var ds=Math.random().toString(36).slice(2),Jt="__reactFiber$"+ds,fi="__reactProps$"+ds,gn="__reactContainer$"+ds,bu="__reactEvents$"+ds,Vk="__reactListeners$"+ds,Hk="__reactHandles$"+ds;function nr(e){var t=e[Jt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[gn]||n[Jt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=zf(e);e!==null;){if(n=e[Jt])return n;e=zf(e)}return t}e=n,n=e.parentNode}return null}function Pi(e){return e=e[Jt]||e[gn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Lr(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error($(33))}function ka(e){return e[fi]||null}var Su=[],Or=-1;function qn(e){return{current:e}}function ke(e){0>Or||(e.current=Su[Or],Su[Or]=null,Or--)}function we(e,t){Or++,Su[Or]=e.current,e.current=t}var $n={},Xe=qn($n),ft=qn(!1),ur=$n;function Xr(e,t){var n=e.type.contextTypes;if(!n)return $n;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function ht(e){return e=e.childContextTypes,e!=null}function zo(){ke(ft),ke(Xe)}function Ff(e,t,n){if(Xe.current!==$n)throw Error($(168));we(Xe,t),we(ft,n)}function zg(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error($(108,IS(e)||"Unknown",s));return Ie({},n,r)}function Fo(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||$n,ur=Xe.current,we(Xe,e),we(ft,ft.current),!0}function Bf(e,t,n){var r=e.stateNode;if(!r)throw Error($(169));n?(e=zg(e,t,ur),r.__reactInternalMemoizedMergedChildContext=e,ke(ft),ke(Xe),we(Xe,e)):ke(ft),we(ft,n)}var cn=null,Ca=!1,ml=!1;function Fg(e){cn===null?cn=[e]:cn.push(e)}function Wk(e){Ca=!0,Fg(e)}function Kn(){if(!ml&&cn!==null){ml=!0;var e=0,t=me;try{var n=cn;for(me=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}cn=null,Ca=!1}catch(s){throw cn!==null&&(cn=cn.slice(e+1)),cg(Ic,Kn),s}finally{me=t,ml=!1}}return null}var zr=[],Fr=0,Bo=null,$o=0,Et=[],Tt=0,cr=null,dn=1,fn="";function Xn(e,t){zr[Fr++]=$o,zr[Fr++]=Bo,Bo=e,$o=t}function Bg(e,t,n){Et[Tt++]=dn,Et[Tt++]=fn,Et[Tt++]=cr,cr=e;var r=dn;e=fn;var s=32-Bt(r)-1;r&=~(1<<s),n+=1;var i=32-Bt(t)+s;if(30<i){var o=s-s%5;i=(r&(1<<o)-1).toString(32),r>>=o,s-=o,dn=1<<32-Bt(t)+s|n<<s|r,fn=i+e}else dn=1<<i|n<<s|r,fn=e}function Oc(e){e.return!==null&&(Xn(e,1),Bg(e,1,0))}function zc(e){for(;e===Bo;)Bo=zr[--Fr],zr[Fr]=null,$o=zr[--Fr],zr[Fr]=null;for(;e===cr;)cr=Et[--Tt],Et[Tt]=null,fn=Et[--Tt],Et[Tt]=null,dn=Et[--Tt],Et[Tt]=null}var wt=null,xt=null,Ce=!1,zt=null;function $g(e,t){var n=Rt(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function $f(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,wt=e,xt=Mn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,wt=e,xt=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=cr!==null?{id:dn,overflow:fn}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Rt(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,wt=e,xt=null,!0):!1;default:return!1}}function ku(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Cu(e){if(Ce){var t=xt;if(t){var n=t;if(!$f(e,t)){if(ku(e))throw Error($(418));t=Mn(n.nextSibling);var r=wt;t&&$f(e,t)?$g(r,n):(e.flags=e.flags&-4097|2,Ce=!1,wt=e)}}else{if(ku(e))throw Error($(418));e.flags=e.flags&-4097|2,Ce=!1,wt=e}}}function Uf(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;wt=e}function qi(e){if(e!==wt)return!1;if(!Ce)return Uf(e),Ce=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!xu(e.type,e.memoizedProps)),t&&(t=xt)){if(ku(e))throw Ug(),Error($(418));for(;t;)$g(e,t),t=Mn(t.nextSibling)}if(Uf(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error($(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){xt=Mn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}xt=null}}else xt=wt?Mn(e.stateNode.nextSibling):null;return!0}function Ug(){for(var e=xt;e;)e=Mn(e.nextSibling)}function Zr(){xt=wt=null,Ce=!1}function Fc(e){zt===null?zt=[e]:zt.push(e)}var qk=xn.ReactCurrentBatchConfig;function Ts(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error($(309));var r=n.stateNode}if(!r)throw Error($(147,e));var s=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(o){var a=s.refs;o===null?delete a[i]:a[i]=o},t._stringRef=i,t)}if(typeof e!="string")throw Error($(284));if(!n._owner)throw Error($(290,e))}return e}function Ki(e,t){throw e=Object.prototype.toString.call(t),Error($(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Vf(e){var t=e._init;return t(e._payload)}function Vg(e){function t(y,v){if(e){var w=y.deletions;w===null?(y.deletions=[v],y.flags|=16):w.push(v)}}function n(y,v){if(!e)return null;for(;v!==null;)t(y,v),v=v.sibling;return null}function r(y,v){for(y=new Map;v!==null;)v.key!==null?y.set(v.key,v):y.set(v.index,v),v=v.sibling;return y}function s(y,v){return y=zn(y,v),y.index=0,y.sibling=null,y}function i(y,v,w){return y.index=w,e?(w=y.alternate,w!==null?(w=w.index,w<v?(y.flags|=2,v):w):(y.flags|=2,v)):(y.flags|=1048576,v)}function o(y){return e&&y.alternate===null&&(y.flags|=2),y}function a(y,v,w,E){return v===null||v.tag!==6?(v=Sl(w,y.mode,E),v.return=y,v):(v=s(v,w),v.return=y,v)}function l(y,v,w,E){var I=w.type;return I===jr?f(y,v,w.props.children,E,w.key):v!==null&&(v.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===Cn&&Vf(I)===v.type)?(E=s(v,w.props),E.ref=Ts(y,v,w),E.return=y,E):(E=So(w.type,w.key,w.props,null,y.mode,E),E.ref=Ts(y,v,w),E.return=y,E)}function u(y,v,w,E){return v===null||v.tag!==4||v.stateNode.containerInfo!==w.containerInfo||v.stateNode.implementation!==w.implementation?(v=kl(w,y.mode,E),v.return=y,v):(v=s(v,w.children||[]),v.return=y,v)}function f(y,v,w,E,I){return v===null||v.tag!==7?(v=or(w,y.mode,E,I),v.return=y,v):(v=s(v,w),v.return=y,v)}function d(y,v,w){if(typeof v=="string"&&v!==""||typeof v=="number")return v=Sl(""+v,y.mode,w),v.return=y,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case Li:return w=So(v.type,v.key,v.props,null,y.mode,w),w.ref=Ts(y,null,v),w.return=y,w;case Ar:return v=kl(v,y.mode,w),v.return=y,v;case Cn:var E=v._init;return d(y,E(v._payload),w)}if(Ms(v)||Ss(v))return v=or(v,y.mode,w,null),v.return=y,v;Ki(y,v)}return null}function h(y,v,w,E){var I=v!==null?v.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return I!==null?null:a(y,v,""+w,E);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Li:return w.key===I?l(y,v,w,E):null;case Ar:return w.key===I?u(y,v,w,E):null;case Cn:return I=w._init,h(y,v,I(w._payload),E)}if(Ms(w)||Ss(w))return I!==null?null:f(y,v,w,E,null);Ki(y,w)}return null}function p(y,v,w,E,I){if(typeof E=="string"&&E!==""||typeof E=="number")return y=y.get(w)||null,a(v,y,""+E,I);if(typeof E=="object"&&E!==null){switch(E.$$typeof){case Li:return y=y.get(E.key===null?w:E.key)||null,l(v,y,E,I);case Ar:return y=y.get(E.key===null?w:E.key)||null,u(v,y,E,I);case Cn:var S=E._init;return p(y,v,w,S(E._payload),I)}if(Ms(E)||Ss(E))return y=y.get(w)||null,f(v,y,E,I,null);Ki(v,E)}return null}function g(y,v,w,E){for(var I=null,S=null,R=v,N=v=0,D=null;R!==null&&N<w.length;N++){R.index>N?(D=R,R=null):D=R.sibling;var _=h(y,R,w[N],E);if(_===null){R===null&&(R=D);break}e&&R&&_.alternate===null&&t(y,R),v=i(_,v,N),S===null?I=_:S.sibling=_,S=_,R=D}if(N===w.length)return n(y,R),Ce&&Xn(y,N),I;if(R===null){for(;N<w.length;N++)R=d(y,w[N],E),R!==null&&(v=i(R,v,N),S===null?I=R:S.sibling=R,S=R);return Ce&&Xn(y,N),I}for(R=r(y,R);N<w.length;N++)D=p(R,y,N,w[N],E),D!==null&&(e&&D.alternate!==null&&R.delete(D.key===null?N:D.key),v=i(D,v,N),S===null?I=D:S.sibling=D,S=D);return e&&R.forEach(function(z){return t(y,z)}),Ce&&Xn(y,N),I}function x(y,v,w,E){var I=Ss(w);if(typeof I!="function")throw Error($(150));if(w=I.call(w),w==null)throw Error($(151));for(var S=I=null,R=v,N=v=0,D=null,_=w.next();R!==null&&!_.done;N++,_=w.next()){R.index>N?(D=R,R=null):D=R.sibling;var z=h(y,R,_.value,E);if(z===null){R===null&&(R=D);break}e&&R&&z.alternate===null&&t(y,R),v=i(z,v,N),S===null?I=z:S.sibling=z,S=z,R=D}if(_.done)return n(y,R),Ce&&Xn(y,N),I;if(R===null){for(;!_.done;N++,_=w.next())_=d(y,_.value,E),_!==null&&(v=i(_,v,N),S===null?I=_:S.sibling=_,S=_);return Ce&&Xn(y,N),I}for(R=r(y,R);!_.done;N++,_=w.next())_=p(R,y,N,_.value,E),_!==null&&(e&&_.alternate!==null&&R.delete(_.key===null?N:_.key),v=i(_,v,N),S===null?I=_:S.sibling=_,S=_);return e&&R.forEach(function(j){return t(y,j)}),Ce&&Xn(y,N),I}function k(y,v,w,E){if(typeof w=="object"&&w!==null&&w.type===jr&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Li:e:{for(var I=w.key,S=v;S!==null;){if(S.key===I){if(I=w.type,I===jr){if(S.tag===7){n(y,S.sibling),v=s(S,w.props.children),v.return=y,y=v;break e}}else if(S.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===Cn&&Vf(I)===S.type){n(y,S.sibling),v=s(S,w.props),v.ref=Ts(y,S,w),v.return=y,y=v;break e}n(y,S);break}else t(y,S);S=S.sibling}w.type===jr?(v=or(w.props.children,y.mode,E,w.key),v.return=y,y=v):(E=So(w.type,w.key,w.props,null,y.mode,E),E.ref=Ts(y,v,w),E.return=y,y=E)}return o(y);case Ar:e:{for(S=w.key;v!==null;){if(v.key===S)if(v.tag===4&&v.stateNode.containerInfo===w.containerInfo&&v.stateNode.implementation===w.implementation){n(y,v.sibling),v=s(v,w.children||[]),v.return=y,y=v;break e}else{n(y,v);break}else t(y,v);v=v.sibling}v=kl(w,y.mode,E),v.return=y,y=v}return o(y);case Cn:return S=w._init,k(y,v,S(w._payload),E)}if(Ms(w))return g(y,v,w,E);if(Ss(w))return x(y,v,w,E);Ki(y,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,v!==null&&v.tag===6?(n(y,v.sibling),v=s(v,w),v.return=y,y=v):(n(y,v),v=Sl(w,y.mode,E),v.return=y,y=v),o(y)):n(y,v)}return k}var es=Vg(!0),Hg=Vg(!1),Uo=qn(null),Vo=null,Br=null,Bc=null;function $c(){Bc=Br=Vo=null}function Uc(e){var t=Uo.current;ke(Uo),e._currentValue=t}function _u(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Kr(e,t){Vo=e,Bc=Br=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ct=!0),e.firstContext=null)}function jt(e){var t=e._currentValue;if(Bc!==e)if(e={context:e,memoizedValue:t,next:null},Br===null){if(Vo===null)throw Error($(308));Br=e,Vo.dependencies={lanes:0,firstContext:e}}else Br=Br.next=e;return t}var rr=null;function Vc(e){rr===null?rr=[e]:rr.push(e)}function Wg(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Vc(t)):(n.next=s.next,s.next=n),t.interleaved=n,yn(e,r)}function yn(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var _n=!1;function Hc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function qg(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function pn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Dn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,he&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,yn(e,n)}return s=r.interleaved,s===null?(t.next=t,Vc(r)):(t.next=s.next,s.next=t),r.interleaved=t,yn(e,n)}function go(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Rc(e,n)}}function Hf(e,t){var n=e.updateQueue,r=e.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=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Ho(e,t,n,r){var s=e.updateQueue;_n=!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 f=e.alternate;f!==null&&(f=f.updateQueue,a=f.lastBaseUpdate,a!==o&&(a===null?f.firstBaseUpdate=u:a.next=u,f.lastBaseUpdate=l))}if(i!==null){var d=s.baseState;o=0,f=u=l=null,a=i;do{var h=a.lane,p=a.eventTime;if((r&h)===h){f!==null&&(f=f.next={eventTime:p,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var g=e,x=a;switch(h=t,p=n,x.tag){case 1:if(g=x.payload,typeof g=="function"){d=g.call(p,d,h);break e}d=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=x.payload,h=typeof g=="function"?g.call(p,d,h):g,h==null)break e;d=Ie({},d,h);break e;case 2:_n=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,h=s.effects,h===null?s.effects=[a]:h.push(a))}else p={eventTime:p,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},f===null?(u=f=p,l=d):f=f.next=p,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(f===null&&(l=d),s.baseState=l,s.firstBaseUpdate=u,s.lastBaseUpdate=f,t=s.shared.interleaved,t!==null){s=t;do o|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);fr|=o,e.lanes=o,e.memoizedState=d}}function Wf(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error($(191,s));s.call(r)}}}var Ai={},en=qn(Ai),hi=qn(Ai),pi=qn(Ai);function sr(e){if(e===Ai)throw Error($(174));return e}function Wc(e,t){switch(we(pi,t),we(hi,e),we(en,Ai),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:iu(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=iu(t,e)}ke(en),we(en,t)}function ts(){ke(en),ke(hi),ke(pi)}function Kg(e){sr(pi.current);var t=sr(en.current),n=iu(t,e.type);t!==n&&(we(hi,e),we(en,n))}function qc(e){hi.current===e&&(ke(en),ke(hi))}var _e=qn(0);function Wo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var gl=[];function Kc(){for(var e=0;e<gl.length;e++)gl[e]._workInProgressVersionPrimary=null;gl.length=0}var yo=xn.ReactCurrentDispatcher,yl=xn.ReactCurrentBatchConfig,dr=0,Te=null,Oe=null,Fe=null,qo=!1,Us=!1,mi=0,Kk=0;function Ke(){throw Error($(321))}function Gc(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Vt(e[n],t[n]))return!1;return!0}function Qc(e,t,n,r,s,i){if(dr=i,Te=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,yo.current=e===null||e.memoizedState===null?Jk:Xk,e=n(r,s),Us){i=0;do{if(Us=!1,mi=0,25<=i)throw Error($(301));i+=1,Fe=Oe=null,t.updateQueue=null,yo.current=Zk,e=n(r,s)}while(Us)}if(yo.current=Ko,t=Oe!==null&&Oe.next!==null,dr=0,Fe=Oe=Te=null,qo=!1,t)throw Error($(300));return e}function Yc(){var e=mi!==0;return mi=0,e}function Qt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Fe===null?Te.memoizedState=Fe=e:Fe=Fe.next=e,Fe}function Nt(){if(Oe===null){var e=Te.alternate;e=e!==null?e.memoizedState:null}else e=Oe.next;var t=Fe===null?Te.memoizedState:Fe.next;if(t!==null)Fe=t,Oe=e;else{if(e===null)throw Error($(310));Oe=e,e={memoizedState:Oe.memoizedState,baseState:Oe.baseState,baseQueue:Oe.baseQueue,queue:Oe.queue,next:null},Fe===null?Te.memoizedState=Fe=e:Fe=Fe.next=e}return Fe}function gi(e,t){return typeof t=="function"?t(e):t}function vl(e){var t=Nt(),n=t.queue;if(n===null)throw Error($(311));n.lastRenderedReducer=e;var r=Oe,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 f=u.lane;if((dr&f)===f)l!==null&&(l=l.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var d={lane:f,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};l===null?(a=l=d,o=r):l=l.next=d,Te.lanes|=f,fr|=f}u=u.next}while(u!==null&&u!==i);l===null?o=r:l.next=a,Vt(r,t.memoizedState)||(ct=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=l,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do i=s.lane,Te.lanes|=i,fr|=i,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function xl(e){var t=Nt(),n=t.queue;if(n===null)throw Error($(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,i=t.memoizedState;if(s!==null){n.pending=null;var o=s=s.next;do i=e(i,o.action),o=o.next;while(o!==s);Vt(i,t.memoizedState)||(ct=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function Gg(){}function Qg(e,t){var n=Te,r=Nt(),s=t(),i=!Vt(r.memoizedState,s);if(i&&(r.memoizedState=s,ct=!0),r=r.queue,Jc(Xg.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||Fe!==null&&Fe.memoizedState.tag&1){if(n.flags|=2048,yi(9,Jg.bind(null,n,r,s,t),void 0,null),Be===null)throw Error($(349));dr&30||Yg(n,t,s)}return s}function Yg(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Te.updateQueue,t===null?(t={lastEffect:null,stores:null},Te.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Jg(e,t,n,r){t.value=n,t.getSnapshot=r,Zg(t)&&ey(e)}function Xg(e,t,n){return n(function(){Zg(t)&&ey(e)})}function Zg(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Vt(e,n)}catch{return!0}}function ey(e){var t=yn(e,1);t!==null&&$t(t,e,1,-1)}function qf(e){var t=Qt();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:gi,lastRenderedState:e},t.queue=e,e=e.dispatch=Yk.bind(null,Te,e),[t.memoizedState,e]}function yi(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Te.updateQueue,t===null?(t={lastEffect:null,stores:null},Te.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function ty(){return Nt().memoizedState}function vo(e,t,n,r){var s=Qt();Te.flags|=e,s.memoizedState=yi(1|t,n,void 0,r===void 0?null:r)}function _a(e,t,n,r){var s=Nt();r=r===void 0?null:r;var i=void 0;if(Oe!==null){var o=Oe.memoizedState;if(i=o.destroy,r!==null&&Gc(r,o.deps)){s.memoizedState=yi(t,n,i,r);return}}Te.flags|=e,s.memoizedState=yi(1|t,n,i,r)}function Kf(e,t){return vo(8390656,8,e,t)}function Jc(e,t){return _a(2048,8,e,t)}function ny(e,t){return _a(4,2,e,t)}function ry(e,t){return _a(4,4,e,t)}function sy(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function iy(e,t,n){return n=n!=null?n.concat([e]):null,_a(4,4,sy.bind(null,t,e),n)}function Xc(){}function oy(e,t){var n=Nt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Gc(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ay(e,t){var n=Nt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Gc(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function ly(e,t,n){return dr&21?(Vt(n,t)||(n=hg(),Te.lanes|=n,fr|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ct=!0),e.memoizedState=n)}function Gk(e,t){var n=me;me=n!==0&&4>n?n:4,e(!0);var r=yl.transition;yl.transition={};try{e(!1),t()}finally{me=n,yl.transition=r}}function uy(){return Nt().memoizedState}function Qk(e,t,n){var r=On(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},cy(e))dy(t,n);else if(n=Wg(e,t,n,r),n!==null){var s=rt();$t(n,e,r,s),fy(n,t,r)}}function Yk(e,t,n){var r=On(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(cy(e))dy(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var o=t.lastRenderedState,a=i(o,n);if(s.hasEagerState=!0,s.eagerState=a,Vt(a,o)){var l=t.interleaved;l===null?(s.next=s,Vc(t)):(s.next=l.next,l.next=s),t.interleaved=s;return}}catch{}finally{}n=Wg(e,t,s,r),n!==null&&(s=rt(),$t(n,e,r,s),fy(n,t,r))}}function cy(e){var t=e.alternate;return e===Te||t!==null&&t===Te}function dy(e,t){Us=qo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function fy(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Rc(e,n)}}var Ko={readContext:jt,useCallback:Ke,useContext:Ke,useEffect:Ke,useImperativeHandle:Ke,useInsertionEffect:Ke,useLayoutEffect:Ke,useMemo:Ke,useReducer:Ke,useRef:Ke,useState:Ke,useDebugValue:Ke,useDeferredValue:Ke,useTransition:Ke,useMutableSource:Ke,useSyncExternalStore:Ke,useId:Ke,unstable_isNewReconciler:!1},Jk={readContext:jt,useCallback:function(e,t){return Qt().memoizedState=[e,t===void 0?null:t],e},useContext:jt,useEffect:Kf,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,vo(4194308,4,sy.bind(null,t,e),n)},useLayoutEffect:function(e,t){return vo(4194308,4,e,t)},useInsertionEffect:function(e,t){return vo(4,2,e,t)},useMemo:function(e,t){var n=Qt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Qt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Qk.bind(null,Te,e),[r.memoizedState,e]},useRef:function(e){var t=Qt();return e={current:e},t.memoizedState=e},useState:qf,useDebugValue:Xc,useDeferredValue:function(e){return Qt().memoizedState=e},useTransition:function(){var e=qf(!1),t=e[0];return e=Gk.bind(null,e[1]),Qt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Te,s=Qt();if(Ce){if(n===void 0)throw Error($(407));n=n()}else{if(n=t(),Be===null)throw Error($(349));dr&30||Yg(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Kf(Xg.bind(null,r,i,e),[e]),r.flags|=2048,yi(9,Jg.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Qt(),t=Be.identifierPrefix;if(Ce){var n=fn,r=dn;n=(r&~(1<<32-Bt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=mi++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=Kk++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Xk={readContext:jt,useCallback:oy,useContext:jt,useEffect:Jc,useImperativeHandle:iy,useInsertionEffect:ny,useLayoutEffect:ry,useMemo:ay,useReducer:vl,useRef:ty,useState:function(){return vl(gi)},useDebugValue:Xc,useDeferredValue:function(e){var t=Nt();return ly(t,Oe.memoizedState,e)},useTransition:function(){var e=vl(gi)[0],t=Nt().memoizedState;return[e,t]},useMutableSource:Gg,useSyncExternalStore:Qg,useId:uy,unstable_isNewReconciler:!1},Zk={readContext:jt,useCallback:oy,useContext:jt,useEffect:Jc,useImperativeHandle:iy,useInsertionEffect:ny,useLayoutEffect:ry,useMemo:ay,useReducer:xl,useRef:ty,useState:function(){return xl(gi)},useDebugValue:Xc,useDeferredValue:function(e){var t=Nt();return Oe===null?t.memoizedState=e:ly(t,Oe.memoizedState,e)},useTransition:function(){var e=xl(gi)[0],t=Nt().memoizedState;return[e,t]},useMutableSource:Gg,useSyncExternalStore:Qg,useId:uy,unstable_isNewReconciler:!1};function Lt(e,t){if(e&&e.defaultProps){t=Ie({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Eu(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Ie({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ea={isMounted:function(e){return(e=e._reactInternals)?vr(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=rt(),s=On(e),i=pn(r,s);i.payload=t,n!=null&&(i.callback=n),t=Dn(e,i,s),t!==null&&($t(t,e,s,r),go(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=rt(),s=On(e),i=pn(r,s);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Dn(e,i,s),t!==null&&($t(t,e,s,r),go(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=rt(),r=On(e),s=pn(n,r);s.tag=2,t!=null&&(s.callback=t),t=Dn(e,s,r),t!==null&&($t(t,e,r,n),go(t,e,r))}};function Gf(e,t,n,r,s,i,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,o):t.prototype&&t.prototype.isPureReactComponent?!ui(n,r)||!ui(s,i):!0}function hy(e,t,n){var r=!1,s=$n,i=t.contextType;return typeof i=="object"&&i!==null?i=jt(i):(s=ht(t)?ur:Xe.current,r=t.contextTypes,i=(r=r!=null)?Xr(e,s):$n),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ea,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function Qf(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Ea.enqueueReplaceState(t,t.state,null)}function Tu(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},Hc(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=jt(i):(i=ht(t)?ur:Xe.current,s.context=Xr(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(Eu(e,t,i,n),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&Ea.enqueueReplaceState(s,s.state,null),Ho(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function ns(e,t){try{var n="",r=t;do n+=TS(r),r=r.return;while(r);var s=n}catch(i){s=`
|
|
37
|
+
`+s[o].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}while(1<=o&&0<=a);break}}}finally{el=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Ns(e):""}function RS(e){switch(e.tag){case 5:return Ns(e.type);case 16:return Ns("Lazy");case 13:return Ns("Suspense");case 19:return Ns("SuspenseList");case 0:case 2:case 15:return e=tl(e.type,!1),e;case 11:return e=tl(e.type.render,!1),e;case 1:return e=tl(e.type,!0),e;default:return""}}function eu(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case jr:return"Fragment";case Ar:return"Portal";case Jl:return"Profiler";case Cc:return"StrictMode";case Xl:return"Suspense";case Zl:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Km:return(e.displayName||"Context")+".Consumer";case qm:return(e._context.displayName||"Context")+".Provider";case _c:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ec:return t=e.displayName||null,t!==null?t:eu(e.type)||"Memo";case Cn:t=e._payload,e=e._init;try{return eu(e(t))}catch{}}return null}function PS(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return eu(t);case 8:return t===Cc?"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 t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function $n(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Qm(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function AS(e){var t=Qm(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Oi(e){e._valueTracker||(e._valueTracker=AS(e))}function Ym(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Qm(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ro(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function tu(e,t){var n=t.checked;return Re({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ff(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=$n(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Jm(e,t){t=t.checked,t!=null&&kc(e,"checked",t,!1)}function nu(e,t){Jm(e,t);var n=$n(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?ru(e,t.type,n):t.hasOwnProperty("defaultValue")&&ru(e,t.type,$n(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function hf(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function ru(e,t,n){(t!=="number"||Ro(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Ms=Array.isArray;function Vr(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s<n.length;s++)t["$"+n[s]]=!0;for(n=0;n<e.length;n++)s=t.hasOwnProperty("$"+e[n].value),e[n].selected!==s&&(e[n].selected=s),s&&r&&(e[n].defaultSelected=!0)}else{for(n=""+$n(n),t=null,s=0;s<e.length;s++){if(e[s].value===n){e[s].selected=!0,r&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function su(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error($(91));return Re({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function pf(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error($(92));if(Ms(n)){if(1<n.length)throw Error($(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:$n(n)}}function Xm(e,t){var n=$n(t.value),r=$n(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function mf(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Zm(e){switch(e){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 iu(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Zm(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var zi,eg=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,s){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,s)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(zi=zi||document.createElement("div"),zi.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=zi.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ri(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Os={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},jS=["Webkit","ms","Moz","O"];Object.keys(Os).forEach(function(e){jS.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Os[t]=Os[e]})});function tg(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Os.hasOwnProperty(e)&&Os[e]?(""+t).trim():t+"px"}function ng(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=tg(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var NS=Re({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 ou(e,t){if(t){if(NS[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error($(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error($(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error($(61))}if(t.style!=null&&typeof t.style!="object")throw Error($(62))}}function au(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){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 lu=null;function Tc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var uu=null,Hr=null,Wr=null;function gf(e){if(e=Pi(e)){if(typeof uu!="function")throw Error($(280));var t=e.stateNode;t&&(t=ka(t),uu(e.stateNode,e.type,t))}}function rg(e){Hr?Wr?Wr.push(e):Wr=[e]:Hr=e}function sg(){if(Hr){var e=Hr,t=Wr;if(Wr=Hr=null,gf(e),t)for(e=0;e<t.length;e++)gf(t[e])}}function ig(e,t){return e(t)}function og(){}var nl=!1;function ag(e,t,n){if(nl)return e(t,n);nl=!0;try{return ig(e,t,n)}finally{nl=!1,(Hr!==null||Wr!==null)&&(og(),sg())}}function si(e,t){var n=e.stateNode;if(n===null)return null;var r=ka(n);if(r===null)return null;n=r[t];e:switch(t){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)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error($(231,t,typeof n));return n}var cu=!1;if(mn)try{var ks={};Object.defineProperty(ks,"passive",{get:function(){cu=!0}}),window.addEventListener("test",ks,ks),window.removeEventListener("test",ks,ks)}catch{cu=!1}function MS(e,t,n,r,s,i,o,a,l){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(f){this.onError(f)}}var zs=!1,Po=null,Ao=!1,du=null,DS={onError:function(e){zs=!0,Po=e}};function LS(e,t,n,r,s,i,o,a,l){zs=!1,Po=null,MS.apply(DS,arguments)}function OS(e,t,n,r,s,i,o,a,l){if(LS.apply(this,arguments),zs){if(zs){var u=Po;zs=!1,Po=null}else throw Error($(198));Ao||(Ao=!0,du=u)}}function vr(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function lg(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function yf(e){if(vr(e)!==e)throw Error($(188))}function zS(e){var t=e.alternate;if(!t){if(t=vr(e),t===null)throw Error($(188));return t!==e?null:e}for(var n=e,r=t;;){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 yf(s),e;if(i===r)return yf(s),t;i=i.sibling}throw Error($(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($(189))}}if(n.alternate!==r)throw Error($(190))}if(n.tag!==3)throw Error($(188));return n.stateNode.current===n?e:t}function ug(e){return e=zS(e),e!==null?cg(e):null}function cg(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=cg(e);if(t!==null)return t;e=e.sibling}return null}var dg=St.unstable_scheduleCallback,vf=St.unstable_cancelCallback,FS=St.unstable_shouldYield,BS=St.unstable_requestPaint,je=St.unstable_now,$S=St.unstable_getCurrentPriorityLevel,Ic=St.unstable_ImmediatePriority,fg=St.unstable_UserBlockingPriority,jo=St.unstable_NormalPriority,US=St.unstable_LowPriority,hg=St.unstable_IdlePriority,xa=null,Zt=null;function VS(e){if(Zt&&typeof Zt.onCommitFiberRoot=="function")try{Zt.onCommitFiberRoot(xa,e,void 0,(e.current.flags&128)===128)}catch{}}var Bt=Math.clz32?Math.clz32:qS,HS=Math.log,WS=Math.LN2;function qS(e){return e>>>=0,e===0?32:31-(HS(e)/WS|0)|0}var Fi=64,Bi=4194304;function Ds(e){switch(e&-e){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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function No(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~s;a!==0?r=Ds(a):(i&=o,i!==0&&(r=Ds(i)))}else o=n&~s,o!==0?r=Ds(o):i!==0&&(r=Ds(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Bt(t),s=1<<n,r|=e[n],t&=~s;return r}function KS(e,t){switch(e){case 1:case 2:case 4:return t+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 t+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 GS(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var o=31-Bt(i),a=1<<o,l=s[o];l===-1?(!(a&n)||a&r)&&(s[o]=KS(a,t)):l<=t&&(e.expiredLanes|=a),i&=~a}}function fu(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function pg(){var e=Fi;return Fi<<=1,!(Fi&4194240)&&(Fi=64),e}function rl(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ii(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Bt(t),e[t]=n}function QS(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var s=31-Bt(n),i=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~i}}function Rc(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Bt(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var me=0;function mg(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var gg,Pc,yg,vg,xg,hu=!1,$i=[],jn=null,Nn=null,Mn=null,ii=new Map,oi=new Map,Tn=[],YS="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 xf(e,t){switch(e){case"focusin":case"focusout":jn=null;break;case"dragenter":case"dragleave":Nn=null;break;case"mouseover":case"mouseout":Mn=null;break;case"pointerover":case"pointerout":ii.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":oi.delete(t.pointerId)}}function Cs(e,t,n,r,s,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[s]},t!==null&&(t=Pi(t),t!==null&&Pc(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function JS(e,t,n,r,s){switch(t){case"focusin":return jn=Cs(jn,e,t,n,r,s),!0;case"dragenter":return Nn=Cs(Nn,e,t,n,r,s),!0;case"mouseover":return Mn=Cs(Mn,e,t,n,r,s),!0;case"pointerover":var i=s.pointerId;return ii.set(i,Cs(ii.get(i)||null,e,t,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,oi.set(i,Cs(oi.get(i)||null,e,t,n,r,s)),!0}return!1}function wg(e){var t=nr(e.target);if(t!==null){var n=vr(t);if(n!==null){if(t=n.tag,t===13){if(t=lg(n),t!==null){e.blockedOn=t,xg(e.priority,function(){yg(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ho(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=pu(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);lu=r,n.target.dispatchEvent(r),lu=null}else return t=Pi(n),t!==null&&Pc(t),e.blockedOn=n,!1;t.shift()}return!0}function wf(e,t,n){ho(e)&&n.delete(t)}function XS(){hu=!1,jn!==null&&ho(jn)&&(jn=null),Nn!==null&&ho(Nn)&&(Nn=null),Mn!==null&&ho(Mn)&&(Mn=null),ii.forEach(wf),oi.forEach(wf)}function _s(e,t){e.blockedOn===t&&(e.blockedOn=null,hu||(hu=!0,St.unstable_scheduleCallback(St.unstable_NormalPriority,XS)))}function ai(e){function t(s){return _s(s,e)}if(0<$i.length){_s($i[0],e);for(var n=1;n<$i.length;n++){var r=$i[n];r.blockedOn===e&&(r.blockedOn=null)}}for(jn!==null&&_s(jn,e),Nn!==null&&_s(Nn,e),Mn!==null&&_s(Mn,e),ii.forEach(t),oi.forEach(t),n=0;n<Tn.length;n++)r=Tn[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Tn.length&&(n=Tn[0],n.blockedOn===null);)wg(n),n.blockedOn===null&&Tn.shift()}var qr=xn.ReactCurrentBatchConfig,Mo=!0;function ZS(e,t,n,r){var s=me,i=qr.transition;qr.transition=null;try{me=1,Ac(e,t,n,r)}finally{me=s,qr.transition=i}}function ek(e,t,n,r){var s=me,i=qr.transition;qr.transition=null;try{me=4,Ac(e,t,n,r)}finally{me=s,qr.transition=i}}function Ac(e,t,n,r){if(Mo){var s=pu(e,t,n,r);if(s===null)hl(e,t,r,Do,n),xf(e,r);else if(JS(s,e,t,n,r))r.stopPropagation();else if(xf(e,r),t&4&&-1<YS.indexOf(e)){for(;s!==null;){var i=Pi(s);if(i!==null&&gg(i),i=pu(e,t,n,r),i===null&&hl(e,t,r,Do,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else hl(e,t,r,null,n)}}var Do=null;function pu(e,t,n,r){if(Do=null,e=Tc(r),e=nr(e),e!==null)if(t=vr(e),t===null)e=null;else if(n=t.tag,n===13){if(e=lg(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Do=e,null}function bg(e){switch(e){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($S()){case Ic:return 1;case fg:return 4;case jo:case US:return 16;case hg:return 536870912;default:return 16}default:return 16}}var Pn=null,jc=null,po=null;function Sg(){if(po)return po;var e,t=jc,n=t.length,r,s="value"in Pn?Pn.value:Pn.textContent,i=s.length;for(e=0;e<n&&t[e]===s[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===s[i-r];r++);return po=s.slice(e,1<r?1-r:void 0)}function mo(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Ui(){return!0}function bf(){return!1}function _t(e){function t(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 e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(i):i[a]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Ui:bf,this.isPropagationStopped=bf,this}return Re(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Ui)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Ui)},persist:function(){},isPersistent:Ui}),t}var cs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Nc=_t(cs),Ri=Re({},cs,{view:0,detail:0}),tk=_t(Ri),sl,il,Es,wa=Re({},Ri,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mc,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Es&&(Es&&e.type==="mousemove"?(sl=e.screenX-Es.screenX,il=e.screenY-Es.screenY):il=sl=0,Es=e),sl)},movementY:function(e){return"movementY"in e?e.movementY:il}}),Sf=_t(wa),nk=Re({},wa,{dataTransfer:0}),rk=_t(nk),sk=Re({},Ri,{relatedTarget:0}),ol=_t(sk),ik=Re({},cs,{animationName:0,elapsedTime:0,pseudoElement:0}),ok=_t(ik),ak=Re({},cs,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),lk=_t(ak),uk=Re({},cs,{data:0}),kf=_t(uk),ck={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},dk={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"},fk={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function hk(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=fk[e])?!!t[e]:!1}function Mc(){return hk}var pk=Re({},Ri,{key:function(e){if(e.key){var t=ck[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=mo(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?dk[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mc,charCode:function(e){return e.type==="keypress"?mo(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?mo(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),mk=_t(pk),gk=Re({},wa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Cf=_t(gk),yk=Re({},Ri,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mc}),vk=_t(yk),xk=Re({},cs,{propertyName:0,elapsedTime:0,pseudoElement:0}),wk=_t(xk),bk=Re({},wa,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Sk=_t(bk),kk=[9,13,27,32],Dc=mn&&"CompositionEvent"in window,Fs=null;mn&&"documentMode"in document&&(Fs=document.documentMode);var Ck=mn&&"TextEvent"in window&&!Fs,kg=mn&&(!Dc||Fs&&8<Fs&&11>=Fs),_f=" ",Ef=!1;function Cg(e,t){switch(e){case"keyup":return kk.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function _g(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Nr=!1;function _k(e,t){switch(e){case"compositionend":return _g(t);case"keypress":return t.which!==32?null:(Ef=!0,_f);case"textInput":return e=t.data,e===_f&&Ef?null:e;default:return null}}function Ek(e,t){if(Nr)return e==="compositionend"||!Dc&&Cg(e,t)?(e=Sg(),po=jc=Pn=null,Nr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return kg&&t.locale!=="ko"?null:t.data;default:return null}}var Tk={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 Tf(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Tk[e.type]:t==="textarea"}function Eg(e,t,n,r){rg(r),t=Lo(t,"onChange"),0<t.length&&(n=new Nc("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Bs=null,li=null;function Ik(e){Og(e,0)}function ba(e){var t=Lr(e);if(Ym(t))return e}function Rk(e,t){if(e==="change")return t}var Tg=!1;if(mn){var al;if(mn){var ll="oninput"in document;if(!ll){var If=document.createElement("div");If.setAttribute("oninput","return;"),ll=typeof If.oninput=="function"}al=ll}else al=!1;Tg=al&&(!document.documentMode||9<document.documentMode)}function Rf(){Bs&&(Bs.detachEvent("onpropertychange",Ig),li=Bs=null)}function Ig(e){if(e.propertyName==="value"&&ba(li)){var t=[];Eg(t,li,e,Tc(e)),ag(Ik,t)}}function Pk(e,t,n){e==="focusin"?(Rf(),Bs=t,li=n,Bs.attachEvent("onpropertychange",Ig)):e==="focusout"&&Rf()}function Ak(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ba(li)}function jk(e,t){if(e==="click")return ba(t)}function Nk(e,t){if(e==="input"||e==="change")return ba(t)}function Mk(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Vt=typeof Object.is=="function"?Object.is:Mk;function ui(e,t){if(Vt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var s=n[r];if(!Yl.call(t,s)||!Vt(e[s],t[s]))return!1}return!0}function Pf(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Af(e,t){var n=Pf(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Pf(n)}}function Rg(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Rg(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Pg(){for(var e=window,t=Ro();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ro(e.document)}return t}function Lc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Dk(e){var t=Pg(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Rg(n.ownerDocument.documentElement,n)){if(r!==null&&Lc(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Af(n,i);var o=Af(n,r);s&&o&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Lk=mn&&"documentMode"in document&&11>=document.documentMode,Mr=null,mu=null,$s=null,gu=!1;function jf(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;gu||Mr==null||Mr!==Ro(r)||(r=Mr,"selectionStart"in r&&Lc(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}),$s&&ui($s,r)||($s=r,r=Lo(mu,"onSelect"),0<r.length&&(t=new Nc("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Mr)))}function Vi(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Dr={animationend:Vi("Animation","AnimationEnd"),animationiteration:Vi("Animation","AnimationIteration"),animationstart:Vi("Animation","AnimationStart"),transitionend:Vi("Transition","TransitionEnd")},ul={},Ag={};mn&&(Ag=document.createElement("div").style,"AnimationEvent"in window||(delete Dr.animationend.animation,delete Dr.animationiteration.animation,delete Dr.animationstart.animation),"TransitionEvent"in window||delete Dr.transitionend.transition);function Sa(e){if(ul[e])return ul[e];if(!Dr[e])return e;var t=Dr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Ag)return ul[e]=t[n];return e}var jg=Sa("animationend"),Ng=Sa("animationiteration"),Mg=Sa("animationstart"),Dg=Sa("transitionend"),Lg=new Map,Nf="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 qn(e,t){Lg.set(e,t),yr(t,[e])}for(var cl=0;cl<Nf.length;cl++){var dl=Nf[cl],Ok=dl.toLowerCase(),zk=dl[0].toUpperCase()+dl.slice(1);qn(Ok,"on"+zk)}qn(jg,"onAnimationEnd");qn(Ng,"onAnimationIteration");qn(Mg,"onAnimationStart");qn("dblclick","onDoubleClick");qn("focusin","onFocus");qn("focusout","onBlur");qn(Dg,"onTransitionEnd");Jr("onMouseEnter",["mouseout","mouseover"]);Jr("onMouseLeave",["mouseout","mouseover"]);Jr("onPointerEnter",["pointerout","pointerover"]);Jr("onPointerLeave",["pointerout","pointerover"]);yr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));yr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));yr("onBeforeInput",["compositionend","keypress","textInput","paste"]);yr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));yr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));yr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ls="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(" "),Fk=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ls));function Mf(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,OS(r,t,void 0,e),e.currentTarget=null}function Og(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],s=r.event;r=r.listeners;e:{var i=void 0;if(t)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;Mf(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;Mf(s,a,u),i=l}}}if(Ao)throw e=du,Ao=!1,du=null,e}function Se(e,t){var n=t[bu];n===void 0&&(n=t[bu]=new Set);var r=e+"__bubble";n.has(r)||(zg(t,e,2,!1),n.add(r))}function fl(e,t,n){var r=0;t&&(r|=4),zg(n,e,r,t)}var Hi="_reactListening"+Math.random().toString(36).slice(2);function ci(e){if(!e[Hi]){e[Hi]=!0,Wm.forEach(function(n){n!=="selectionchange"&&(Fk.has(n)||fl(n,!1,e),fl(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Hi]||(t[Hi]=!0,fl("selectionchange",!1,t))}}function zg(e,t,n,r){switch(bg(t)){case 1:var s=ZS;break;case 4:s=ek;break;default:s=Ac}n=s.bind(null,t,n,e),s=void 0,!cu||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),r?s!==void 0?e.addEventListener(t,n,{capture:!0,passive:s}):e.addEventListener(t,n,!0):s!==void 0?e.addEventListener(t,n,{passive:s}):e.addEventListener(t,n,!1)}function hl(e,t,n,r,s){var i=r;if(!(t&1)&&!(t&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=nr(a),o===null)return;if(l=o.tag,l===5||l===6){r=i=o;continue e}a=a.parentNode}}r=r.return}ag(function(){var u=i,f=Tc(n),d=[];e:{var h=Lg.get(e);if(h!==void 0){var p=Nc,g=e;switch(e){case"keypress":if(mo(n)===0)break e;case"keydown":case"keyup":p=mk;break;case"focusin":g="focus",p=ol;break;case"focusout":g="blur",p=ol;break;case"beforeblur":case"afterblur":p=ol;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":p=Sf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=rk;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=vk;break;case jg:case Ng:case Mg:p=ok;break;case Dg:p=wk;break;case"scroll":p=tk;break;case"wheel":p=Sk;break;case"copy":case"cut":case"paste":p=lk;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=Cf}var v=(t&4)!==0,S=!v&&e==="scroll",y=v?h!==null?h+"Capture":null:h;v=[];for(var x=u,w;x!==null;){w=x;var E=w.stateNode;if(w.tag===5&&E!==null&&(w=E,y!==null&&(E=si(x,y),E!=null&&v.push(di(x,E,w)))),S)break;x=x.return}0<v.length&&(h=new p(h,g,null,n,f),d.push({event:h,listeners:v}))}}if(!(t&7)){e:{if(h=e==="mouseover"||e==="pointerover",p=e==="mouseout"||e==="pointerout",h&&n!==lu&&(g=n.relatedTarget||n.fromElement)&&(nr(g)||g[gn]))break e;if((p||h)&&(h=f.window===f?f:(h=f.ownerDocument)?h.defaultView||h.parentWindow:window,p?(g=n.relatedTarget||n.toElement,p=u,g=g?nr(g):null,g!==null&&(S=vr(g),g!==S||g.tag!==5&&g.tag!==6)&&(g=null)):(p=null,g=u),p!==g)){if(v=Sf,E="onMouseLeave",y="onMouseEnter",x="mouse",(e==="pointerout"||e==="pointerover")&&(v=Cf,E="onPointerLeave",y="onPointerEnter",x="pointer"),S=p==null?h:Lr(p),w=g==null?h:Lr(g),h=new v(E,x+"leave",p,n,f),h.target=S,h.relatedTarget=w,E=null,nr(f)===u&&(v=new v(y,x+"enter",g,n,f),v.target=w,v.relatedTarget=S,E=v),S=E,p&&g)t:{for(v=p,y=g,x=0,w=v;w;w=Ir(w))x++;for(w=0,E=y;E;E=Ir(E))w++;for(;0<x-w;)v=Ir(v),x--;for(;0<w-x;)y=Ir(y),w--;for(;x--;){if(v===y||y!==null&&v===y.alternate)break t;v=Ir(v),y=Ir(y)}v=null}else v=null;p!==null&&Df(d,h,p,v,!1),g!==null&&S!==null&&Df(d,S,g,v,!0)}}e:{if(h=u?Lr(u):window,p=h.nodeName&&h.nodeName.toLowerCase(),p==="select"||p==="input"&&h.type==="file")var I=Rk;else if(Tf(h))if(Tg)I=Nk;else{I=Ak;var k=Pk}else(p=h.nodeName)&&p.toLowerCase()==="input"&&(h.type==="checkbox"||h.type==="radio")&&(I=jk);if(I&&(I=I(e,u))){Eg(d,I,n,f);break e}k&&k(e,h,u),e==="focusout"&&(k=h._wrapperState)&&k.controlled&&h.type==="number"&&ru(h,"number",h.value)}switch(k=u?Lr(u):window,e){case"focusin":(Tf(k)||k.contentEditable==="true")&&(Mr=k,mu=u,$s=null);break;case"focusout":$s=mu=Mr=null;break;case"mousedown":gu=!0;break;case"contextmenu":case"mouseup":case"dragend":gu=!1,jf(d,n,f);break;case"selectionchange":if(Lk)break;case"keydown":case"keyup":jf(d,n,f)}var R;if(Dc)e:{switch(e){case"compositionstart":var M="onCompositionStart";break e;case"compositionend":M="onCompositionEnd";break e;case"compositionupdate":M="onCompositionUpdate";break e}M=void 0}else Nr?Cg(e,n)&&(M="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(M="onCompositionStart");M&&(kg&&n.locale!=="ko"&&(Nr||M!=="onCompositionStart"?M==="onCompositionEnd"&&Nr&&(R=Sg()):(Pn=f,jc="value"in Pn?Pn.value:Pn.textContent,Nr=!0)),k=Lo(u,M),0<k.length&&(M=new kf(M,e,null,n,f),d.push({event:M,listeners:k}),R?M.data=R:(R=_g(n),R!==null&&(M.data=R)))),(R=Ck?_k(e,n):Ek(e,n))&&(u=Lo(u,"onBeforeInput"),0<u.length&&(f=new kf("onBeforeInput","beforeinput",null,n,f),d.push({event:f,listeners:u}),f.data=R))}Og(d,t)})}function di(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Lo(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=si(e,n),i!=null&&r.unshift(di(e,i,s)),i=si(e,t),i!=null&&r.push(di(e,i,s))),e=e.return}return r}function Ir(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Df(e,t,n,r,s){for(var i=t._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=si(n,i),l!=null&&o.unshift(di(n,l,a))):s||(l=si(n,i),l!=null&&o.push(di(n,l,a)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Bk=/\r\n?/g,$k=/\u0000|\uFFFD/g;function Lf(e){return(typeof e=="string"?e:""+e).replace(Bk,`
|
|
38
|
+
`).replace($k,"")}function Wi(e,t,n){if(t=Lf(t),Lf(e)!==t&&n)throw Error($(425))}function Oo(){}var yu=null,vu=null;function xu(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var wu=typeof setTimeout=="function"?setTimeout:void 0,Uk=typeof clearTimeout=="function"?clearTimeout:void 0,Of=typeof Promise=="function"?Promise:void 0,Vk=typeof queueMicrotask=="function"?queueMicrotask:typeof Of<"u"?function(e){return Of.resolve(null).then(e).catch(Hk)}:wu;function Hk(e){setTimeout(function(){throw e})}function pl(e,t){var n=t,r=0;do{var s=n.nextSibling;if(e.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(r===0){e.removeChild(s),ai(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);ai(t)}function Dn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function zf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var ds=Math.random().toString(36).slice(2),Jt="__reactFiber$"+ds,fi="__reactProps$"+ds,gn="__reactContainer$"+ds,bu="__reactEvents$"+ds,Wk="__reactListeners$"+ds,qk="__reactHandles$"+ds;function nr(e){var t=e[Jt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[gn]||n[Jt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=zf(e);e!==null;){if(n=e[Jt])return n;e=zf(e)}return t}e=n,n=e.parentNode}return null}function Pi(e){return e=e[Jt]||e[gn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Lr(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error($(33))}function ka(e){return e[fi]||null}var Su=[],Or=-1;function Kn(e){return{current:e}}function ke(e){0>Or||(e.current=Su[Or],Su[Or]=null,Or--)}function we(e,t){Or++,Su[Or]=e.current,e.current=t}var Un={},Xe=Kn(Un),ft=Kn(!1),ur=Un;function Xr(e,t){var n=e.type.contextTypes;if(!n)return Un;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function ht(e){return e=e.childContextTypes,e!=null}function zo(){ke(ft),ke(Xe)}function Ff(e,t,n){if(Xe.current!==Un)throw Error($(168));we(Xe,t),we(ft,n)}function Fg(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error($(108,PS(e)||"Unknown",s));return Re({},n,r)}function Fo(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Un,ur=Xe.current,we(Xe,e),we(ft,ft.current),!0}function Bf(e,t,n){var r=e.stateNode;if(!r)throw Error($(169));n?(e=Fg(e,t,ur),r.__reactInternalMemoizedMergedChildContext=e,ke(ft),ke(Xe),we(Xe,e)):ke(ft),we(ft,n)}var cn=null,Ca=!1,ml=!1;function Bg(e){cn===null?cn=[e]:cn.push(e)}function Kk(e){Ca=!0,Bg(e)}function Gn(){if(!ml&&cn!==null){ml=!0;var e=0,t=me;try{var n=cn;for(me=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}cn=null,Ca=!1}catch(s){throw cn!==null&&(cn=cn.slice(e+1)),dg(Ic,Gn),s}finally{me=t,ml=!1}}return null}var zr=[],Fr=0,Bo=null,$o=0,Et=[],Tt=0,cr=null,dn=1,fn="";function Zn(e,t){zr[Fr++]=$o,zr[Fr++]=Bo,Bo=e,$o=t}function $g(e,t,n){Et[Tt++]=dn,Et[Tt++]=fn,Et[Tt++]=cr,cr=e;var r=dn;e=fn;var s=32-Bt(r)-1;r&=~(1<<s),n+=1;var i=32-Bt(t)+s;if(30<i){var o=s-s%5;i=(r&(1<<o)-1).toString(32),r>>=o,s-=o,dn=1<<32-Bt(t)+s|n<<s|r,fn=i+e}else dn=1<<i|n<<s|r,fn=e}function Oc(e){e.return!==null&&(Zn(e,1),$g(e,1,0))}function zc(e){for(;e===Bo;)Bo=zr[--Fr],zr[Fr]=null,$o=zr[--Fr],zr[Fr]=null;for(;e===cr;)cr=Et[--Tt],Et[Tt]=null,fn=Et[--Tt],Et[Tt]=null,dn=Et[--Tt],Et[Tt]=null}var wt=null,xt=null,Ce=!1,zt=null;function Ug(e,t){var n=Rt(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function $f(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,wt=e,xt=Dn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,wt=e,xt=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=cr!==null?{id:dn,overflow:fn}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Rt(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,wt=e,xt=null,!0):!1;default:return!1}}function ku(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Cu(e){if(Ce){var t=xt;if(t){var n=t;if(!$f(e,t)){if(ku(e))throw Error($(418));t=Dn(n.nextSibling);var r=wt;t&&$f(e,t)?Ug(r,n):(e.flags=e.flags&-4097|2,Ce=!1,wt=e)}}else{if(ku(e))throw Error($(418));e.flags=e.flags&-4097|2,Ce=!1,wt=e}}}function Uf(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;wt=e}function qi(e){if(e!==wt)return!1;if(!Ce)return Uf(e),Ce=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!xu(e.type,e.memoizedProps)),t&&(t=xt)){if(ku(e))throw Vg(),Error($(418));for(;t;)Ug(e,t),t=Dn(t.nextSibling)}if(Uf(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error($(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){xt=Dn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}xt=null}}else xt=wt?Dn(e.stateNode.nextSibling):null;return!0}function Vg(){for(var e=xt;e;)e=Dn(e.nextSibling)}function Zr(){xt=wt=null,Ce=!1}function Fc(e){zt===null?zt=[e]:zt.push(e)}var Gk=xn.ReactCurrentBatchConfig;function Ts(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error($(309));var r=n.stateNode}if(!r)throw Error($(147,e));var s=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(o){var a=s.refs;o===null?delete a[i]:a[i]=o},t._stringRef=i,t)}if(typeof e!="string")throw Error($(284));if(!n._owner)throw Error($(290,e))}return e}function Ki(e,t){throw e=Object.prototype.toString.call(t),Error($(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Vf(e){var t=e._init;return t(e._payload)}function Hg(e){function t(y,x){if(e){var w=y.deletions;w===null?(y.deletions=[x],y.flags|=16):w.push(x)}}function n(y,x){if(!e)return null;for(;x!==null;)t(y,x),x=x.sibling;return null}function r(y,x){for(y=new Map;x!==null;)x.key!==null?y.set(x.key,x):y.set(x.index,x),x=x.sibling;return y}function s(y,x){return y=Fn(y,x),y.index=0,y.sibling=null,y}function i(y,x,w){return y.index=w,e?(w=y.alternate,w!==null?(w=w.index,w<x?(y.flags|=2,x):w):(y.flags|=2,x)):(y.flags|=1048576,x)}function o(y){return e&&y.alternate===null&&(y.flags|=2),y}function a(y,x,w,E){return x===null||x.tag!==6?(x=Sl(w,y.mode,E),x.return=y,x):(x=s(x,w),x.return=y,x)}function l(y,x,w,E){var I=w.type;return I===jr?f(y,x,w.props.children,E,w.key):x!==null&&(x.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===Cn&&Vf(I)===x.type)?(E=s(x,w.props),E.ref=Ts(y,x,w),E.return=y,E):(E=So(w.type,w.key,w.props,null,y.mode,E),E.ref=Ts(y,x,w),E.return=y,E)}function u(y,x,w,E){return x===null||x.tag!==4||x.stateNode.containerInfo!==w.containerInfo||x.stateNode.implementation!==w.implementation?(x=kl(w,y.mode,E),x.return=y,x):(x=s(x,w.children||[]),x.return=y,x)}function f(y,x,w,E,I){return x===null||x.tag!==7?(x=or(w,y.mode,E,I),x.return=y,x):(x=s(x,w),x.return=y,x)}function d(y,x,w){if(typeof x=="string"&&x!==""||typeof x=="number")return x=Sl(""+x,y.mode,w),x.return=y,x;if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Li:return w=So(x.type,x.key,x.props,null,y.mode,w),w.ref=Ts(y,null,x),w.return=y,w;case Ar:return x=kl(x,y.mode,w),x.return=y,x;case Cn:var E=x._init;return d(y,E(x._payload),w)}if(Ms(x)||Ss(x))return x=or(x,y.mode,w,null),x.return=y,x;Ki(y,x)}return null}function h(y,x,w,E){var I=x!==null?x.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return I!==null?null:a(y,x,""+w,E);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Li:return w.key===I?l(y,x,w,E):null;case Ar:return w.key===I?u(y,x,w,E):null;case Cn:return I=w._init,h(y,x,I(w._payload),E)}if(Ms(w)||Ss(w))return I!==null?null:f(y,x,w,E,null);Ki(y,w)}return null}function p(y,x,w,E,I){if(typeof E=="string"&&E!==""||typeof E=="number")return y=y.get(w)||null,a(x,y,""+E,I);if(typeof E=="object"&&E!==null){switch(E.$$typeof){case Li:return y=y.get(E.key===null?w:E.key)||null,l(x,y,E,I);case Ar:return y=y.get(E.key===null?w:E.key)||null,u(x,y,E,I);case Cn:var k=E._init;return p(y,x,w,k(E._payload),I)}if(Ms(E)||Ss(E))return y=y.get(w)||null,f(x,y,E,I,null);Ki(x,E)}return null}function g(y,x,w,E){for(var I=null,k=null,R=x,M=x=0,L=null;R!==null&&M<w.length;M++){R.index>M?(L=R,R=null):L=R.sibling;var _=h(y,R,w[M],E);if(_===null){R===null&&(R=L);break}e&&R&&_.alternate===null&&t(y,R),x=i(_,x,M),k===null?I=_:k.sibling=_,k=_,R=L}if(M===w.length)return n(y,R),Ce&&Zn(y,M),I;if(R===null){for(;M<w.length;M++)R=d(y,w[M],E),R!==null&&(x=i(R,x,M),k===null?I=R:k.sibling=R,k=R);return Ce&&Zn(y,M),I}for(R=r(y,R);M<w.length;M++)L=p(R,y,M,w[M],E),L!==null&&(e&&L.alternate!==null&&R.delete(L.key===null?M:L.key),x=i(L,x,M),k===null?I=L:k.sibling=L,k=L);return e&&R.forEach(function(z){return t(y,z)}),Ce&&Zn(y,M),I}function v(y,x,w,E){var I=Ss(w);if(typeof I!="function")throw Error($(150));if(w=I.call(w),w==null)throw Error($(151));for(var k=I=null,R=x,M=x=0,L=null,_=w.next();R!==null&&!_.done;M++,_=w.next()){R.index>M?(L=R,R=null):L=R.sibling;var z=h(y,R,_.value,E);if(z===null){R===null&&(R=L);break}e&&R&&z.alternate===null&&t(y,R),x=i(z,x,M),k===null?I=z:k.sibling=z,k=z,R=L}if(_.done)return n(y,R),Ce&&Zn(y,M),I;if(R===null){for(;!_.done;M++,_=w.next())_=d(y,_.value,E),_!==null&&(x=i(_,x,M),k===null?I=_:k.sibling=_,k=_);return Ce&&Zn(y,M),I}for(R=r(y,R);!_.done;M++,_=w.next())_=p(R,y,M,_.value,E),_!==null&&(e&&_.alternate!==null&&R.delete(_.key===null?M:_.key),x=i(_,x,M),k===null?I=_:k.sibling=_,k=_);return e&&R.forEach(function(N){return t(y,N)}),Ce&&Zn(y,M),I}function S(y,x,w,E){if(typeof w=="object"&&w!==null&&w.type===jr&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Li:e:{for(var I=w.key,k=x;k!==null;){if(k.key===I){if(I=w.type,I===jr){if(k.tag===7){n(y,k.sibling),x=s(k,w.props.children),x.return=y,y=x;break e}}else if(k.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===Cn&&Vf(I)===k.type){n(y,k.sibling),x=s(k,w.props),x.ref=Ts(y,k,w),x.return=y,y=x;break e}n(y,k);break}else t(y,k);k=k.sibling}w.type===jr?(x=or(w.props.children,y.mode,E,w.key),x.return=y,y=x):(E=So(w.type,w.key,w.props,null,y.mode,E),E.ref=Ts(y,x,w),E.return=y,y=E)}return o(y);case Ar:e:{for(k=w.key;x!==null;){if(x.key===k)if(x.tag===4&&x.stateNode.containerInfo===w.containerInfo&&x.stateNode.implementation===w.implementation){n(y,x.sibling),x=s(x,w.children||[]),x.return=y,y=x;break e}else{n(y,x);break}else t(y,x);x=x.sibling}x=kl(w,y.mode,E),x.return=y,y=x}return o(y);case Cn:return k=w._init,S(y,x,k(w._payload),E)}if(Ms(w))return g(y,x,w,E);if(Ss(w))return v(y,x,w,E);Ki(y,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,x!==null&&x.tag===6?(n(y,x.sibling),x=s(x,w),x.return=y,y=x):(n(y,x),x=Sl(w,y.mode,E),x.return=y,y=x),o(y)):n(y,x)}return S}var es=Hg(!0),Wg=Hg(!1),Uo=Kn(null),Vo=null,Br=null,Bc=null;function $c(){Bc=Br=Vo=null}function Uc(e){var t=Uo.current;ke(Uo),e._currentValue=t}function _u(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Kr(e,t){Vo=e,Bc=Br=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ct=!0),e.firstContext=null)}function jt(e){var t=e._currentValue;if(Bc!==e)if(e={context:e,memoizedValue:t,next:null},Br===null){if(Vo===null)throw Error($(308));Br=e,Vo.dependencies={lanes:0,firstContext:e}}else Br=Br.next=e;return t}var rr=null;function Vc(e){rr===null?rr=[e]:rr.push(e)}function qg(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Vc(t)):(n.next=s.next,s.next=n),t.interleaved=n,yn(e,r)}function yn(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var _n=!1;function Hc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Kg(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function pn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Ln(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,he&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,yn(e,n)}return s=r.interleaved,s===null?(t.next=t,Vc(r)):(t.next=s.next,s.next=t),r.interleaved=t,yn(e,n)}function go(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Rc(e,n)}}function Hf(e,t){var n=e.updateQueue,r=e.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=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Ho(e,t,n,r){var s=e.updateQueue;_n=!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 f=e.alternate;f!==null&&(f=f.updateQueue,a=f.lastBaseUpdate,a!==o&&(a===null?f.firstBaseUpdate=u:a.next=u,f.lastBaseUpdate=l))}if(i!==null){var d=s.baseState;o=0,f=u=l=null,a=i;do{var h=a.lane,p=a.eventTime;if((r&h)===h){f!==null&&(f=f.next={eventTime:p,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var g=e,v=a;switch(h=t,p=n,v.tag){case 1:if(g=v.payload,typeof g=="function"){d=g.call(p,d,h);break e}d=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=v.payload,h=typeof g=="function"?g.call(p,d,h):g,h==null)break e;d=Re({},d,h);break e;case 2:_n=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,h=s.effects,h===null?s.effects=[a]:h.push(a))}else p={eventTime:p,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},f===null?(u=f=p,l=d):f=f.next=p,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(f===null&&(l=d),s.baseState=l,s.firstBaseUpdate=u,s.lastBaseUpdate=f,t=s.shared.interleaved,t!==null){s=t;do o|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);fr|=o,e.lanes=o,e.memoizedState=d}}function Wf(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error($(191,s));s.call(r)}}}var Ai={},en=Kn(Ai),hi=Kn(Ai),pi=Kn(Ai);function sr(e){if(e===Ai)throw Error($(174));return e}function Wc(e,t){switch(we(pi,t),we(hi,e),we(en,Ai),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:iu(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=iu(t,e)}ke(en),we(en,t)}function ts(){ke(en),ke(hi),ke(pi)}function Gg(e){sr(pi.current);var t=sr(en.current),n=iu(t,e.type);t!==n&&(we(hi,e),we(en,n))}function qc(e){hi.current===e&&(ke(en),ke(hi))}var Ee=Kn(0);function Wo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var gl=[];function Kc(){for(var e=0;e<gl.length;e++)gl[e]._workInProgressVersionPrimary=null;gl.length=0}var yo=xn.ReactCurrentDispatcher,yl=xn.ReactCurrentBatchConfig,dr=0,Ie=null,Fe=null,$e=null,qo=!1,Us=!1,mi=0,Qk=0;function Ke(){throw Error($(321))}function Gc(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Vt(e[n],t[n]))return!1;return!0}function Qc(e,t,n,r,s,i){if(dr=i,Ie=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,yo.current=e===null||e.memoizedState===null?Zk:eC,e=n(r,s),Us){i=0;do{if(Us=!1,mi=0,25<=i)throw Error($(301));i+=1,$e=Fe=null,t.updateQueue=null,yo.current=tC,e=n(r,s)}while(Us)}if(yo.current=Ko,t=Fe!==null&&Fe.next!==null,dr=0,$e=Fe=Ie=null,qo=!1,t)throw Error($(300));return e}function Yc(){var e=mi!==0;return mi=0,e}function Qt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return $e===null?Ie.memoizedState=$e=e:$e=$e.next=e,$e}function Nt(){if(Fe===null){var e=Ie.alternate;e=e!==null?e.memoizedState:null}else e=Fe.next;var t=$e===null?Ie.memoizedState:$e.next;if(t!==null)$e=t,Fe=e;else{if(e===null)throw Error($(310));Fe=e,e={memoizedState:Fe.memoizedState,baseState:Fe.baseState,baseQueue:Fe.baseQueue,queue:Fe.queue,next:null},$e===null?Ie.memoizedState=$e=e:$e=$e.next=e}return $e}function gi(e,t){return typeof t=="function"?t(e):t}function vl(e){var t=Nt(),n=t.queue;if(n===null)throw Error($(311));n.lastRenderedReducer=e;var r=Fe,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 f=u.lane;if((dr&f)===f)l!==null&&(l=l.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var d={lane:f,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};l===null?(a=l=d,o=r):l=l.next=d,Ie.lanes|=f,fr|=f}u=u.next}while(u!==null&&u!==i);l===null?o=r:l.next=a,Vt(r,t.memoizedState)||(ct=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=l,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do i=s.lane,Ie.lanes|=i,fr|=i,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function xl(e){var t=Nt(),n=t.queue;if(n===null)throw Error($(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,i=t.memoizedState;if(s!==null){n.pending=null;var o=s=s.next;do i=e(i,o.action),o=o.next;while(o!==s);Vt(i,t.memoizedState)||(ct=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function Qg(){}function Yg(e,t){var n=Ie,r=Nt(),s=t(),i=!Vt(r.memoizedState,s);if(i&&(r.memoizedState=s,ct=!0),r=r.queue,Jc(Zg.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||$e!==null&&$e.memoizedState.tag&1){if(n.flags|=2048,yi(9,Xg.bind(null,n,r,s,t),void 0,null),Ue===null)throw Error($(349));dr&30||Jg(n,t,s)}return s}function Jg(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ie.updateQueue,t===null?(t={lastEffect:null,stores:null},Ie.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Xg(e,t,n,r){t.value=n,t.getSnapshot=r,ey(t)&&ty(e)}function Zg(e,t,n){return n(function(){ey(t)&&ty(e)})}function ey(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Vt(e,n)}catch{return!0}}function ty(e){var t=yn(e,1);t!==null&&$t(t,e,1,-1)}function qf(e){var t=Qt();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:gi,lastRenderedState:e},t.queue=e,e=e.dispatch=Xk.bind(null,Ie,e),[t.memoizedState,e]}function yi(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Ie.updateQueue,t===null?(t={lastEffect:null,stores:null},Ie.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function ny(){return Nt().memoizedState}function vo(e,t,n,r){var s=Qt();Ie.flags|=e,s.memoizedState=yi(1|t,n,void 0,r===void 0?null:r)}function _a(e,t,n,r){var s=Nt();r=r===void 0?null:r;var i=void 0;if(Fe!==null){var o=Fe.memoizedState;if(i=o.destroy,r!==null&&Gc(r,o.deps)){s.memoizedState=yi(t,n,i,r);return}}Ie.flags|=e,s.memoizedState=yi(1|t,n,i,r)}function Kf(e,t){return vo(8390656,8,e,t)}function Jc(e,t){return _a(2048,8,e,t)}function ry(e,t){return _a(4,2,e,t)}function sy(e,t){return _a(4,4,e,t)}function iy(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function oy(e,t,n){return n=n!=null?n.concat([e]):null,_a(4,4,iy.bind(null,t,e),n)}function Xc(){}function ay(e,t){var n=Nt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Gc(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ly(e,t){var n=Nt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Gc(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function uy(e,t,n){return dr&21?(Vt(n,t)||(n=pg(),Ie.lanes|=n,fr|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ct=!0),e.memoizedState=n)}function Yk(e,t){var n=me;me=n!==0&&4>n?n:4,e(!0);var r=yl.transition;yl.transition={};try{e(!1),t()}finally{me=n,yl.transition=r}}function cy(){return Nt().memoizedState}function Jk(e,t,n){var r=zn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},dy(e))fy(t,n);else if(n=qg(e,t,n,r),n!==null){var s=rt();$t(n,e,r,s),hy(n,t,r)}}function Xk(e,t,n){var r=zn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(dy(e))fy(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var o=t.lastRenderedState,a=i(o,n);if(s.hasEagerState=!0,s.eagerState=a,Vt(a,o)){var l=t.interleaved;l===null?(s.next=s,Vc(t)):(s.next=l.next,l.next=s),t.interleaved=s;return}}catch{}finally{}n=qg(e,t,s,r),n!==null&&(s=rt(),$t(n,e,r,s),hy(n,t,r))}}function dy(e){var t=e.alternate;return e===Ie||t!==null&&t===Ie}function fy(e,t){Us=qo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function hy(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Rc(e,n)}}var Ko={readContext:jt,useCallback:Ke,useContext:Ke,useEffect:Ke,useImperativeHandle:Ke,useInsertionEffect:Ke,useLayoutEffect:Ke,useMemo:Ke,useReducer:Ke,useRef:Ke,useState:Ke,useDebugValue:Ke,useDeferredValue:Ke,useTransition:Ke,useMutableSource:Ke,useSyncExternalStore:Ke,useId:Ke,unstable_isNewReconciler:!1},Zk={readContext:jt,useCallback:function(e,t){return Qt().memoizedState=[e,t===void 0?null:t],e},useContext:jt,useEffect:Kf,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,vo(4194308,4,iy.bind(null,t,e),n)},useLayoutEffect:function(e,t){return vo(4194308,4,e,t)},useInsertionEffect:function(e,t){return vo(4,2,e,t)},useMemo:function(e,t){var n=Qt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Qt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Jk.bind(null,Ie,e),[r.memoizedState,e]},useRef:function(e){var t=Qt();return e={current:e},t.memoizedState=e},useState:qf,useDebugValue:Xc,useDeferredValue:function(e){return Qt().memoizedState=e},useTransition:function(){var e=qf(!1),t=e[0];return e=Yk.bind(null,e[1]),Qt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Ie,s=Qt();if(Ce){if(n===void 0)throw Error($(407));n=n()}else{if(n=t(),Ue===null)throw Error($(349));dr&30||Jg(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Kf(Zg.bind(null,r,i,e),[e]),r.flags|=2048,yi(9,Xg.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Qt(),t=Ue.identifierPrefix;if(Ce){var n=fn,r=dn;n=(r&~(1<<32-Bt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=mi++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=Qk++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},eC={readContext:jt,useCallback:ay,useContext:jt,useEffect:Jc,useImperativeHandle:oy,useInsertionEffect:ry,useLayoutEffect:sy,useMemo:ly,useReducer:vl,useRef:ny,useState:function(){return vl(gi)},useDebugValue:Xc,useDeferredValue:function(e){var t=Nt();return uy(t,Fe.memoizedState,e)},useTransition:function(){var e=vl(gi)[0],t=Nt().memoizedState;return[e,t]},useMutableSource:Qg,useSyncExternalStore:Yg,useId:cy,unstable_isNewReconciler:!1},tC={readContext:jt,useCallback:ay,useContext:jt,useEffect:Jc,useImperativeHandle:oy,useInsertionEffect:ry,useLayoutEffect:sy,useMemo:ly,useReducer:xl,useRef:ny,useState:function(){return xl(gi)},useDebugValue:Xc,useDeferredValue:function(e){var t=Nt();return Fe===null?t.memoizedState=e:uy(t,Fe.memoizedState,e)},useTransition:function(){var e=xl(gi)[0],t=Nt().memoizedState;return[e,t]},useMutableSource:Qg,useSyncExternalStore:Yg,useId:cy,unstable_isNewReconciler:!1};function Lt(e,t){if(e&&e.defaultProps){t=Re({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Eu(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Re({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ea={isMounted:function(e){return(e=e._reactInternals)?vr(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=rt(),s=zn(e),i=pn(r,s);i.payload=t,n!=null&&(i.callback=n),t=Ln(e,i,s),t!==null&&($t(t,e,s,r),go(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=rt(),s=zn(e),i=pn(r,s);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Ln(e,i,s),t!==null&&($t(t,e,s,r),go(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=rt(),r=zn(e),s=pn(n,r);s.tag=2,t!=null&&(s.callback=t),t=Ln(e,s,r),t!==null&&($t(t,e,r,n),go(t,e,r))}};function Gf(e,t,n,r,s,i,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,o):t.prototype&&t.prototype.isPureReactComponent?!ui(n,r)||!ui(s,i):!0}function py(e,t,n){var r=!1,s=Un,i=t.contextType;return typeof i=="object"&&i!==null?i=jt(i):(s=ht(t)?ur:Xe.current,r=t.contextTypes,i=(r=r!=null)?Xr(e,s):Un),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ea,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function Qf(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Ea.enqueueReplaceState(t,t.state,null)}function Tu(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},Hc(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=jt(i):(i=ht(t)?ur:Xe.current,s.context=Xr(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(Eu(e,t,i,n),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&Ea.enqueueReplaceState(s,s.state,null),Ho(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function ns(e,t){try{var n="",r=t;do n+=RS(r),r=r.return;while(r);var s=n}catch(i){s=`
|
|
39
39
|
Error generating stack: `+i.message+`
|
|
40
|
-
`+i.stack}return{value:e,source:t,stack:s,digest:null}}function wl(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Iu(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var eC=typeof WeakMap=="function"?WeakMap:Map;function py(e,t,n){n=pn(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Qo||(Qo=!0,zu=r),Iu(e,t)},n}function my(e,t,n){n=pn(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var s=t.value;n.payload=function(){return r(s)},n.callback=function(){Iu(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){Iu(e,t),typeof r!="function"&&(Ln===null?Ln=new Set([this]):Ln.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function Yf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new eC;var s=new Set;r.set(t,s)}else s=r.get(t),s===void 0&&(s=new Set,r.set(t,s));s.has(n)||(s.add(n),e=pC.bind(null,e,t,n),t.then(e,e))}function Jf(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function Xf(e,t,n,r,s){return e.mode&1?(e.flags|=65536,e.lanes=s,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=pn(-1,1),t.tag=2,Dn(n,t,1))),n.lanes|=1),e)}var tC=xn.ReactCurrentOwner,ct=!1;function tt(e,t,n,r){t.child=e===null?Hg(t,null,n,r):es(t,e.child,n,r)}function Zf(e,t,n,r,s){n=n.render;var i=t.ref;return Kr(t,s),r=Qc(e,t,n,r,i,s),n=Yc(),e!==null&&!ct?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,vn(e,t,s)):(Ce&&n&&Oc(t),t.flags|=1,tt(e,t,r,s),t.child)}function eh(e,t,n,r,s){if(e===null){var i=n.type;return typeof i=="function"&&!od(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,gy(e,t,i,r,s)):(e=So(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&s)){var o=i.memoizedProps;if(n=n.compare,n=n!==null?n:ui,n(o,r)&&e.ref===t.ref)return vn(e,t,s)}return t.flags|=1,e=zn(i,r),e.ref=t.ref,e.return=t,t.child=e}function gy(e,t,n,r,s){if(e!==null){var i=e.memoizedProps;if(ui(i,r)&&e.ref===t.ref)if(ct=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(ct=!0);else return t.lanes=e.lanes,vn(e,t,s)}return Ru(e,t,n,r,s)}function yy(e,t,n){var r=t.pendingProps,s=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},we(Ur,vt),vt|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,we(Ur,vt),vt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,we(Ur,vt),vt|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,we(Ur,vt),vt|=r;return tt(e,t,s,n),t.child}function vy(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ru(e,t,n,r,s){var i=ht(n)?ur:Xe.current;return i=Xr(t,i),Kr(t,s),n=Qc(e,t,n,r,i,s),r=Yc(),e!==null&&!ct?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,vn(e,t,s)):(Ce&&r&&Oc(t),t.flags|=1,tt(e,t,n,s),t.child)}function th(e,t,n,r,s){if(ht(n)){var i=!0;Fo(t)}else i=!1;if(Kr(t,s),t.stateNode===null)xo(e,t),hy(t,n,r),Tu(t,n,r,s),r=!0;else if(e===null){var o=t.stateNode,a=t.memoizedProps;o.props=a;var l=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=jt(u):(u=ht(n)?ur:Xe.current,u=Xr(t,u));var f=n.getDerivedStateFromProps,d=typeof f=="function"||typeof o.getSnapshotBeforeUpdate=="function";d||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||l!==u)&&Qf(t,o,r,u),_n=!1;var h=t.memoizedState;o.state=h,Ho(t,r,o,s),l=t.memoizedState,a!==r||h!==l||ft.current||_n?(typeof f=="function"&&(Eu(t,n,f,r),l=t.memoizedState),(a=_n||Gf(t,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"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),o.props=r,o.state=l,o.context=u,r=a):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,qg(e,t),a=t.memoizedProps,u=t.type===t.elementType?a:Lt(t.type,a),o.props=u,d=t.pendingProps,h=o.context,l=n.contextType,typeof l=="object"&&l!==null?l=jt(l):(l=ht(n)?ur:Xe.current,l=Xr(t,l));var p=n.getDerivedStateFromProps;(f=typeof p=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==d||h!==l)&&Qf(t,o,r,l),_n=!1,h=t.memoizedState,o.state=h,Ho(t,r,o,s);var g=t.memoizedState;a!==d||h!==g||ft.current||_n?(typeof p=="function"&&(Eu(t,n,p,r),g=t.memoizedState),(u=_n||Gf(t,n,u,r,h,g,l)||!1)?(f||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,g,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,g,l)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=g),o.props=r,o.state=g,o.context=l,r=u):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),r=!1)}return Pu(e,t,n,r,i,s)}function Pu(e,t,n,r,s,i){vy(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return s&&Bf(t,n,!1),vn(e,t,i);r=t.stateNode,tC.current=t;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=es(t,e.child,null,i),t.child=es(t,null,a,i)):tt(e,t,a,i),t.memoizedState=r.state,s&&Bf(t,n,!0),t.child}function xy(e){var t=e.stateNode;t.pendingContext?Ff(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Ff(e,t.context,!1),Wc(e,t.containerInfo)}function nh(e,t,n,r,s){return Zr(),Fc(s),t.flags|=256,tt(e,t,n,r),t.child}var Au={dehydrated:null,treeContext:null,retryLane:0};function ju(e){return{baseLanes:e,cachePool:null,transitions:null}}function wy(e,t,n){var r=t.pendingProps,s=_e.current,i=!1,o=(t.flags&128)!==0,a;if((a=o)||(a=e!==null&&e.memoizedState===null?!1:(s&2)!==0),a?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),we(_e,s&1),e===null)return Cu(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,i?(r=t.mode,i=t.child,o={mode:"hidden",children:o},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=Ra(o,r,0,null),e=or(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=ju(n),t.memoizedState=Au,e):Zc(t,o));if(s=e.memoizedState,s!==null&&(a=s.dehydrated,a!==null))return nC(e,t,o,r,a,s,n);if(i){i=r.fallback,o=t.mode,s=e.child,a=s.sibling;var l={mode:"hidden",children:r.children};return!(o&1)&&t.child!==s?(r=t.child,r.childLanes=0,r.pendingProps=l,t.deletions=null):(r=zn(s,l),r.subtreeFlags=s.subtreeFlags&14680064),a!==null?i=zn(a,i):(i=or(i,o,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,o=e.child.memoizedState,o=o===null?ju(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~n,t.memoizedState=Au,r}return i=e.child,e=i.sibling,r=zn(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Zc(e,t){return t=Ra({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Gi(e,t,n,r){return r!==null&&Fc(r),es(t,e.child,null,n),e=Zc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function nC(e,t,n,r,s,i,o){if(n)return t.flags&256?(t.flags&=-257,r=wl(Error($(422))),Gi(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=Ra({mode:"visible",children:r.children},s,0,null),i=or(i,s,o,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&es(t,e.child,null,o),t.child.memoizedState=ju(o),t.memoizedState=Au,i);if(!(t.mode&1))return Gi(e,t,o,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var a=r.dgst;return r=a,i=Error($(419)),r=wl(i,r,void 0),Gi(e,t,o,r)}if(a=(o&e.childLanes)!==0,ct||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,yn(e,s),$t(r,e,s,-1))}return id(),r=wl(Error($(421))),Gi(e,t,o,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=mC.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,xt=Mn(s.nextSibling),wt=t,Ce=!0,zt=null,e!==null&&(Et[Tt++]=dn,Et[Tt++]=fn,Et[Tt++]=cr,dn=e.id,fn=e.overflow,cr=t),t=Zc(t,r.children),t.flags|=4096,t)}function rh(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),_u(e.return,t,n)}function bl(e,t,n,r,s){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=s)}function by(e,t,n){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(tt(e,t,r.children,n),r=_e.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&rh(e,n,t);else if(e.tag===19)rh(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(we(_e,r),!(t.mode&1))t.memoizedState=null;else switch(s){case"forwards":for(n=t.child,s=null;n!==null;)e=n.alternate,e!==null&&Wo(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),bl(t,!1,s,n,i);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&Wo(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}bl(t,!0,n,null,i);break;case"together":bl(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function xo(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function vn(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),fr|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error($(153));if(t.child!==null){for(e=t.child,n=zn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=zn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function rC(e,t,n){switch(t.tag){case 3:xy(t),Zr();break;case 5:Kg(t);break;case 1:ht(t.type)&&Fo(t);break;case 4:Wc(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;we(Uo,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(we(_e,_e.current&1),t.flags|=128,null):n&t.child.childLanes?wy(e,t,n):(we(_e,_e.current&1),e=vn(e,t,n),e!==null?e.sibling:null);we(_e,_e.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return by(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),we(_e,_e.current),r)break;return null;case 22:case 23:return t.lanes=0,yy(e,t,n)}return vn(e,t,n)}var Sy,Nu,ky,Cy;Sy=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Nu=function(){};ky=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,sr(en.current);var i=null;switch(n){case"input":s=tu(e,s),r=tu(e,r),i=[];break;case"select":s=Ie({},s,{value:void 0}),r=Ie({},r,{value:void 0}),i=[];break;case"textarea":s=su(e,s),r=su(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Oo)}ou(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"&&(ni.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in r){var l=r[u];if(a=s?.[u],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"&&(ni.hasOwnProperty(u)?(l!=null&&u==="onScroll"&&Se("scroll",e),i||a===l||(i=[])):(i=i||[]).push(u,l))}n&&(i=i||[]).push("style",n);var u=i;(t.updateQueue=u)&&(t.flags|=4)}};Cy=function(e,t,n,r){n!==r&&(t.flags|=4)};function Is(e,t){if(!Ce)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ge(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function sC(e,t,n){var r=t.pendingProps;switch(zc(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ge(t),null;case 1:return ht(t.type)&&zo(),Ge(t),null;case 3:return r=t.stateNode,ts(),ke(ft),ke(Xe),Kc(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(qi(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,zt!==null&&($u(zt),zt=null))),Nu(e,t),Ge(t),null;case 5:qc(t);var s=sr(pi.current);if(n=t.type,e!==null&&t.stateNode!=null)ky(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error($(166));return Ge(t),null}if(e=sr(en.current),qi(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Jt]=t,r[fi]=i,e=(t.mode&1)!==0,n){case"dialog":Se("cancel",r),Se("close",r);break;case"iframe":case"object":case"embed":Se("load",r);break;case"video":case"audio":for(s=0;s<Ls.length;s++)Se(Ls[s],r);break;case"source":Se("error",r);break;case"img":case"image":case"link":Se("error",r),Se("load",r);break;case"details":Se("toggle",r);break;case"input":ff(r,i),Se("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},Se("invalid",r);break;case"textarea":pf(r,i),Se("invalid",r)}ou(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&&Wi(r.textContent,a,e),s=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(i.suppressHydrationWarning!==!0&&Wi(r.textContent,a,e),s=["children",""+a]):ni.hasOwnProperty(o)&&a!=null&&o==="onScroll"&&Se("scroll",r)}switch(n){case"input":Oi(r),hf(r,i,!0);break;case"textarea":Oi(r),mf(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=Oo)}r=s,t.updateQueue=r,r!==null&&(t.flags|=4)}else{o=s.nodeType===9?s:s.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Xm(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Jt]=t,e[fi]=r,Sy(e,t,!1,!1),t.stateNode=e;e:{switch(o=au(n,r),n){case"dialog":Se("cancel",e),Se("close",e),s=r;break;case"iframe":case"object":case"embed":Se("load",e),s=r;break;case"video":case"audio":for(s=0;s<Ls.length;s++)Se(Ls[s],e);s=r;break;case"source":Se("error",e),s=r;break;case"img":case"image":case"link":Se("error",e),Se("load",e),s=r;break;case"details":Se("toggle",e),s=r;break;case"input":ff(e,r),s=tu(e,r),Se("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=Ie({},r,{value:void 0}),Se("invalid",e);break;case"textarea":pf(e,r),s=su(e,r),Se("invalid",e);break;default:s=r}ou(n,s),a=s;for(i in a)if(a.hasOwnProperty(i)){var l=a[i];i==="style"?tg(e,l):i==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&Zm(e,l)):i==="children"?typeof l=="string"?(n!=="textarea"||l!=="")&&ri(e,l):typeof l=="number"&&ri(e,""+l):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(ni.hasOwnProperty(i)?l!=null&&i==="onScroll"&&Se("scroll",e):l!=null&&kc(e,i,l,o))}switch(n){case"input":Oi(e),hf(e,r,!1);break;case"textarea":Oi(e),mf(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Bn(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?Vr(e,!!r.multiple,i,!1):r.defaultValue!=null&&Vr(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=Oo)}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&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Ge(t),null;case 6:if(e&&t.stateNode!=null)Cy(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error($(166));if(n=sr(pi.current),sr(en.current),qi(t)){if(r=t.stateNode,n=t.memoizedProps,r[Jt]=t,(i=r.nodeValue!==n)&&(e=wt,e!==null))switch(e.tag){case 3:Wi(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Wi(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Jt]=t,t.stateNode=r}return Ge(t),null;case 13:if(ke(_e),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Ce&&xt!==null&&t.mode&1&&!(t.flags&128))Ug(),Zr(),t.flags|=98560,i=!1;else if(i=qi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error($(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error($(317));i[Jt]=t}else Zr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ge(t),i=!1}else zt!==null&&($u(zt),zt=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||_e.current&1?ze===0&&(ze=3):id())),t.updateQueue!==null&&(t.flags|=4),Ge(t),null);case 4:return ts(),Nu(e,t),e===null&&ci(t.stateNode.containerInfo),Ge(t),null;case 10:return Uc(t.type._context),Ge(t),null;case 17:return ht(t.type)&&zo(),Ge(t),null;case 19:if(ke(_e),i=t.memoizedState,i===null)return Ge(t),null;if(r=(t.flags&128)!==0,o=i.rendering,o===null)if(r)Is(i,!1);else{if(ze!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Wo(e),o!==null){for(t.flags|=128,Is(i,!1),r=o.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=e,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,e=o.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return we(_e,_e.current&1|2),t.child}e=e.sibling}i.tail!==null&&Ae()>rs&&(t.flags|=128,r=!0,Is(i,!1),t.lanes=4194304)}else{if(!r)if(e=Wo(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Is(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!Ce)return Ge(t),null}else 2*Ae()-i.renderingStartTime>rs&&n!==1073741824&&(t.flags|=128,r=!0,Is(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(n=i.last,n!==null?n.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Ae(),t.sibling=null,n=_e.current,we(_e,r?n&1|2:n&1),t):(Ge(t),null);case 22:case 23:return sd(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?vt&1073741824&&(Ge(t),t.subtreeFlags&6&&(t.flags|=8192)):Ge(t),null;case 24:return null;case 25:return null}throw Error($(156,t.tag))}function iC(e,t){switch(zc(t),t.tag){case 1:return ht(t.type)&&zo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ts(),ke(ft),ke(Xe),Kc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return qc(t),null;case 13:if(ke(_e),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error($(340));Zr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ke(_e),null;case 4:return ts(),null;case 10:return Uc(t.type._context),null;case 22:case 23:return sd(),null;case 24:return null;default:return null}}var Qi=!1,Qe=!1,oC=typeof WeakSet=="function"?WeakSet:Set,G=null;function $r(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Pe(e,t,r)}else n.current=null}function Mu(e,t,n){try{n()}catch(r){Pe(e,t,r)}}var sh=!1;function aC(e,t){if(yu=Mo,e=Rg(),Lc(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.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,f=0,d=e,h=null;t:for(;;){for(var p;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),(p=d.firstChild)!==null;)h=d,d=p;for(;;){if(d===e)break t;if(h===n&&++u===s&&(a=o),h===i&&++f===r&&(l=o),(p=d.nextSibling)!==null)break;d=h,h=d.parentNode}d=p}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(vu={focusedElem:e,selectionRange:n},Mo=!1,G=t;G!==null;)if(t=G,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,G=e;else for(;G!==null;){t=G;try{var g=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var x=g.memoizedProps,k=g.memoizedState,y=t.stateNode,v=y.getSnapshotBeforeUpdate(t.elementType===t.type?x:Lt(t.type,x),k);y.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error($(163))}}catch(E){Pe(t,t.return,E)}if(e=t.sibling,e!==null){e.return=t.return,G=e;break}G=t.return}return g=sh,sh=!1,g}function Vs(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&Mu(t,n,i)}s=s.next}while(s!==r)}}function Ta(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Du(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function _y(e){var t=e.alternate;t!==null&&(e.alternate=null,_y(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Jt],delete t[fi],delete t[bu],delete t[Vk],delete t[Hk])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Ey(e){return e.tag===5||e.tag===3||e.tag===4}function ih(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ey(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Lu(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Oo));else if(r!==4&&(e=e.child,e!==null))for(Lu(e,t,n),e=e.sibling;e!==null;)Lu(e,t,n),e=e.sibling}function Ou(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Ou(e,t,n),e=e.sibling;e!==null;)Ou(e,t,n),e=e.sibling}var Ue=null,Ot=!1;function Sn(e,t,n){for(n=n.child;n!==null;)Ty(e,t,n),n=n.sibling}function Ty(e,t,n){if(Zt&&typeof Zt.onCommitFiberUnmount=="function")try{Zt.onCommitFiberUnmount(xa,n)}catch{}switch(n.tag){case 5:Qe||$r(n,t);case 6:var r=Ue,s=Ot;Ue=null,Sn(e,t,n),Ue=r,Ot=s,Ue!==null&&(Ot?(e=Ue,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ue.removeChild(n.stateNode));break;case 18:Ue!==null&&(Ot?(e=Ue,n=n.stateNode,e.nodeType===8?pl(e.parentNode,n):e.nodeType===1&&pl(e,n),ai(e)):pl(Ue,n.stateNode));break;case 4:r=Ue,s=Ot,Ue=n.stateNode.containerInfo,Ot=!0,Sn(e,t,n),Ue=r,Ot=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)&&Mu(n,t,o),s=s.next}while(s!==r)}Sn(e,t,n);break;case 1:if(!Qe&&($r(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Pe(n,t,a)}Sn(e,t,n);break;case 21:Sn(e,t,n);break;case 22:n.mode&1?(Qe=(r=Qe)||n.memoizedState!==null,Sn(e,t,n),Qe=r):Sn(e,t,n);break;default:Sn(e,t,n)}}function oh(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new oC),t.forEach(function(r){var s=gC.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Dt(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var i=e,o=t,a=o;e:for(;a!==null;){switch(a.tag){case 5:Ue=a.stateNode,Ot=!1;break e;case 3:Ue=a.stateNode.containerInfo,Ot=!0;break e;case 4:Ue=a.stateNode.containerInfo,Ot=!0;break e}a=a.return}if(Ue===null)throw Error($(160));Ty(i,o,s),Ue=null,Ot=!1;var l=s.alternate;l!==null&&(l.return=null),s.return=null}catch(u){Pe(s,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Iy(t,e),t=t.sibling}function Iy(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Dt(t,e),Kt(e),r&4){try{Vs(3,e,e.return),Ta(3,e)}catch(x){Pe(e,e.return,x)}try{Vs(5,e,e.return)}catch(x){Pe(e,e.return,x)}}break;case 1:Dt(t,e),Kt(e),r&512&&n!==null&&$r(n,n.return);break;case 5:if(Dt(t,e),Kt(e),r&512&&n!==null&&$r(n,n.return),e.flags&32){var s=e.stateNode;try{ri(s,"")}catch(x){Pe(e,e.return,x)}}if(r&4&&(s=e.stateNode,s!=null)){var i=e.memoizedProps,o=n!==null?n.memoizedProps:i,a=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{a==="input"&&i.type==="radio"&&i.name!=null&&Ym(s,i),au(a,o);var u=au(a,i);for(o=0;o<l.length;o+=2){var f=l[o],d=l[o+1];f==="style"?tg(s,d):f==="dangerouslySetInnerHTML"?Zm(s,d):f==="children"?ri(s,d):kc(s,f,d,u)}switch(a){case"input":nu(s,i);break;case"textarea":Jm(s,i);break;case"select":var h=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var p=i.value;p!=null?Vr(s,!!i.multiple,p,!1):h!==!!i.multiple&&(i.defaultValue!=null?Vr(s,!!i.multiple,i.defaultValue,!0):Vr(s,!!i.multiple,i.multiple?[]:"",!1))}s[fi]=i}catch(x){Pe(e,e.return,x)}}break;case 6:if(Dt(t,e),Kt(e),r&4){if(e.stateNode===null)throw Error($(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(x){Pe(e,e.return,x)}}break;case 3:if(Dt(t,e),Kt(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{ai(t.containerInfo)}catch(x){Pe(e,e.return,x)}break;case 4:Dt(t,e),Kt(e);break;case 13:Dt(t,e),Kt(e),s=e.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(nd=Ae())),r&4&&oh(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Qe=(u=Qe)||f,Dt(t,e),Qe=u):Dt(t,e),Kt(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!f&&e.mode&1)for(G=e,f=e.child;f!==null;){for(d=G=f;G!==null;){switch(h=G,p=h.child,h.tag){case 0:case 11:case 14:case 15:Vs(4,h,h.return);break;case 1:$r(h,h.return);var g=h.stateNode;if(typeof g.componentWillUnmount=="function"){r=h,n=h.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(x){Pe(r,n,x)}}break;case 5:$r(h,h.return);break;case 22:if(h.memoizedState!==null){lh(d);continue}}p!==null?(p.return=h,G=p):lh(d)}f=f.sibling}e:for(f=null,d=e;;){if(d.tag===5){if(f===null){f=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=eg("display",o))}catch(x){Pe(e,e.return,x)}}}else if(d.tag===6){if(f===null)try{d.stateNode.nodeValue=u?"":d.memoizedProps}catch(x){Pe(e,e.return,x)}}else if((d.tag!==22&&d.tag!==23||d.memoizedState===null||d===e)&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===e)break e;for(;d.sibling===null;){if(d.return===null||d.return===e)break e;f===d&&(f=null),d=d.return}f===d&&(f=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:Dt(t,e),Kt(e),r&4&&oh(e);break;case 21:break;default:Dt(t,e),Kt(e)}}function Kt(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Ey(n)){var r=n;break e}n=n.return}throw Error($(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(ri(s,""),r.flags&=-33);var i=ih(e);Ou(e,i,s);break;case 3:case 4:var o=r.stateNode.containerInfo,a=ih(e);Lu(e,a,o);break;default:throw Error($(161))}}catch(l){Pe(e,e.return,l)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function lC(e,t,n){G=e,Ry(e)}function Ry(e,t,n){for(var r=(e.mode&1)!==0;G!==null;){var s=G,i=s.child;if(s.tag===22&&r){var o=s.memoizedState!==null||Qi;if(!o){var a=s.alternate,l=a!==null&&a.memoizedState!==null||Qe;a=Qi;var u=Qe;if(Qi=o,(Qe=l)&&!u)for(G=s;G!==null;)o=G,l=o.child,o.tag===22&&o.memoizedState!==null?uh(s):l!==null?(l.return=o,G=l):uh(s);for(;i!==null;)G=i,Ry(i),i=i.sibling;G=s,Qi=a,Qe=u}ah(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,G=i):ah(e)}}function ah(e){for(;G!==null;){var t=G;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Qe||Ta(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Qe)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Lt(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Wf(t,i,r);break;case 3:var o=t.updateQueue;if(o!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}Wf(t,o,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var l=t.memoizedProps;switch(t.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(t.memoizedState===null){var u=t.alternate;if(u!==null){var f=u.memoizedState;if(f!==null){var d=f.dehydrated;d!==null&&ai(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error($(163))}Qe||t.flags&512&&Du(t)}catch(h){Pe(t,t.return,h)}}if(t===e){G=null;break}if(n=t.sibling,n!==null){n.return=t.return,G=n;break}G=t.return}}function lh(e){for(;G!==null;){var t=G;if(t===e){G=null;break}var n=t.sibling;if(n!==null){n.return=t.return,G=n;break}G=t.return}}function uh(e){for(;G!==null;){var t=G;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Ta(4,t)}catch(l){Pe(t,n,l)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(l){Pe(t,s,l)}}var i=t.return;try{Du(t)}catch(l){Pe(t,i,l)}break;case 5:var o=t.return;try{Du(t)}catch(l){Pe(t,o,l)}}}catch(l){Pe(t,t.return,l)}if(t===e){G=null;break}var a=t.sibling;if(a!==null){a.return=t.return,G=a;break}G=t.return}}var uC=Math.ceil,Go=xn.ReactCurrentDispatcher,ed=xn.ReactCurrentOwner,Pt=xn.ReactCurrentBatchConfig,he=0,Be=null,De=null,He=0,vt=0,Ur=qn(0),ze=0,vi=null,fr=0,Ia=0,td=0,Hs=null,lt=null,nd=0,rs=1/0,un=null,Qo=!1,zu=null,Ln=null,Yi=!1,Pn=null,Yo=0,Ws=0,Fu=null,wo=-1,bo=0;function rt(){return he&6?Ae():wo!==-1?wo:wo=Ae()}function On(e){return e.mode&1?he&2&&He!==0?He&-He:qk.transition!==null?(bo===0&&(bo=hg()),bo):(e=me,e!==0||(e=window.event,e=e===void 0?16:wg(e.type)),e):1}function $t(e,t,n,r){if(50<Ws)throw Ws=0,Fu=null,Error($(185));Ii(e,n,r),(!(he&2)||e!==Be)&&(e===Be&&(!(he&2)&&(Ia|=n),ze===4&&In(e,He)),pt(e,r),n===1&&he===0&&!(t.mode&1)&&(rs=Ae()+500,Ca&&Kn()))}function pt(e,t){var n=e.callbackNode;qS(e,t);var r=No(e,e===Be?He:0);if(r===0)n!==null&&vf(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&vf(n),t===1)e.tag===0?Wk(ch.bind(null,e)):Fg(ch.bind(null,e)),$k(function(){!(he&6)&&Kn()}),n=null;else{switch(pg(r)){case 1:n=Ic;break;case 4:n=dg;break;case 16:n=jo;break;case 536870912:n=fg;break;default:n=jo}n=Oy(n,Py.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function Py(e,t){if(wo=-1,bo=0,he&6)throw Error($(327));var n=e.callbackNode;if(Gr()&&e.callbackNode!==n)return null;var r=No(e,e===Be?He:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Jo(e,r);else{t=r;var s=he;he|=2;var i=jy();(Be!==e||He!==t)&&(un=null,rs=Ae()+500,ir(e,t));do try{fC();break}catch(a){Ay(e,a)}while(!0);$c(),Go.current=i,he=s,De!==null?t=0:(Be=null,He=0,t=ze)}if(t!==0){if(t===2&&(s=fu(e),s!==0&&(r=s,t=Bu(e,s))),t===1)throw n=vi,ir(e,0),In(e,r),pt(e,Ae()),n;if(t===6)In(e,r);else{if(s=e.current.alternate,!(r&30)&&!cC(s)&&(t=Jo(e,r),t===2&&(i=fu(e),i!==0&&(r=i,t=Bu(e,i))),t===1))throw n=vi,ir(e,0),In(e,r),pt(e,Ae()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error($(345));case 2:Zn(e,lt,un);break;case 3:if(In(e,r),(r&130023424)===r&&(t=nd+500-Ae(),10<t)){if(No(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){rt(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=wu(Zn.bind(null,e,lt,un),t);break}Zn(e,lt,un);break;case 4:if(In(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var o=31-Bt(r);i=1<<o,o=t[o],o>s&&(s=o),r&=~i}if(r=s,r=Ae()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*uC(r/1960))-r,10<r){e.timeoutHandle=wu(Zn.bind(null,e,lt,un),r);break}Zn(e,lt,un);break;case 5:Zn(e,lt,un);break;default:throw Error($(329))}}}return pt(e,Ae()),e.callbackNode===n?Py.bind(null,e):null}function Bu(e,t){var n=Hs;return e.current.memoizedState.isDehydrated&&(ir(e,t).flags|=256),e=Jo(e,t),e!==2&&(t=lt,lt=n,t!==null&&$u(t)),e}function $u(e){lt===null?lt=e:lt.push.apply(lt,e)}function cC(e){for(var t=e;;){if(t.flags&16384){var n=t.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(!Vt(i(),s))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function In(e,t){for(t&=~td,t&=~Ia,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Bt(t),r=1<<n;e[n]=-1,t&=~r}}function ch(e){if(he&6)throw Error($(327));Gr();var t=No(e,0);if(!(t&1))return pt(e,Ae()),null;var n=Jo(e,t);if(e.tag!==0&&n===2){var r=fu(e);r!==0&&(t=r,n=Bu(e,r))}if(n===1)throw n=vi,ir(e,0),In(e,t),pt(e,Ae()),n;if(n===6)throw Error($(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Zn(e,lt,un),pt(e,Ae()),null}function rd(e,t){var n=he;he|=1;try{return e(t)}finally{he=n,he===0&&(rs=Ae()+500,Ca&&Kn())}}function hr(e){Pn!==null&&Pn.tag===0&&!(he&6)&&Gr();var t=he;he|=1;var n=Pt.transition,r=me;try{if(Pt.transition=null,me=1,e)return e()}finally{me=r,Pt.transition=n,he=t,!(he&6)&&Kn()}}function sd(){vt=Ur.current,ke(Ur)}function ir(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Bk(n)),De!==null)for(n=De.return;n!==null;){var r=n;switch(zc(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&zo();break;case 3:ts(),ke(ft),ke(Xe),Kc();break;case 5:qc(r);break;case 4:ts();break;case 13:ke(_e);break;case 19:ke(_e);break;case 10:Uc(r.type._context);break;case 22:case 23:sd()}n=n.return}if(Be=e,De=e=zn(e.current,null),He=vt=t,ze=0,vi=null,td=Ia=fr=0,lt=Hs=null,rr!==null){for(t=0;t<rr.length;t++)if(n=rr[t],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}rr=null}return e}function Ay(e,t){do{var n=De;try{if($c(),yo.current=Ko,qo){for(var r=Te.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}qo=!1}if(dr=0,Fe=Oe=Te=null,Us=!1,mi=0,ed.current=null,n===null||n.return===null){ze=1,vi=t,De=null;break}e:{var i=e,o=n.return,a=n,l=t;if(t=He,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var u=l,f=a,d=f.tag;if(!(f.mode&1)&&(d===0||d===11||d===15)){var h=f.alternate;h?(f.updateQueue=h.updateQueue,f.memoizedState=h.memoizedState,f.lanes=h.lanes):(f.updateQueue=null,f.memoizedState=null)}var p=Jf(o);if(p!==null){p.flags&=-257,Xf(p,o,a,i,t),p.mode&1&&Yf(i,u,t),t=p,l=u;var g=t.updateQueue;if(g===null){var x=new Set;x.add(l),t.updateQueue=x}else g.add(l);break e}else{if(!(t&1)){Yf(i,u,t),id();break e}l=Error($(426))}}else if(Ce&&a.mode&1){var k=Jf(o);if(k!==null){!(k.flags&65536)&&(k.flags|=256),Xf(k,o,a,i,t),Fc(ns(l,a));break e}}i=l=ns(l,a),ze!==4&&(ze=2),Hs===null?Hs=[i]:Hs.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=py(i,l,t);Hf(i,y);break e;case 1:a=l;var v=i.type,w=i.stateNode;if(!(i.flags&128)&&(typeof v.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(Ln===null||!Ln.has(w)))){i.flags|=65536,t&=-t,i.lanes|=t;var E=my(i,a,t);Hf(i,E);break e}}i=i.return}while(i!==null)}My(n)}catch(I){t=I,De===n&&n!==null&&(De=n=n.return);continue}break}while(!0)}function jy(){var e=Go.current;return Go.current=Ko,e===null?Ko:e}function id(){(ze===0||ze===3||ze===2)&&(ze=4),Be===null||!(fr&268435455)&&!(Ia&268435455)||In(Be,He)}function Jo(e,t){var n=he;he|=2;var r=jy();(Be!==e||He!==t)&&(un=null,ir(e,t));do try{dC();break}catch(s){Ay(e,s)}while(!0);if($c(),he=n,Go.current=r,De!==null)throw Error($(261));return Be=null,He=0,ze}function dC(){for(;De!==null;)Ny(De)}function fC(){for(;De!==null&&!OS();)Ny(De)}function Ny(e){var t=Ly(e.alternate,e,vt);e.memoizedProps=e.pendingProps,t===null?My(e):De=t,ed.current=null}function My(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=iC(n,t),n!==null){n.flags&=32767,De=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{ze=6,De=null;return}}else if(n=sC(n,t,vt),n!==null){De=n;return}if(t=t.sibling,t!==null){De=t;return}De=t=e}while(t!==null);ze===0&&(ze=5)}function Zn(e,t,n){var r=me,s=Pt.transition;try{Pt.transition=null,me=1,hC(e,t,n,r)}finally{Pt.transition=s,me=r}return null}function hC(e,t,n,r){do Gr();while(Pn!==null);if(he&6)throw Error($(327));n=e.finishedWork;var s=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error($(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(KS(e,i),e===Be&&(De=Be=null,He=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Yi||(Yi=!0,Oy(jo,function(){return Gr(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=Pt.transition,Pt.transition=null;var o=me;me=1;var a=he;he|=4,ed.current=null,aC(e,n),Iy(n,e),Nk(vu),Mo=!!yu,vu=yu=null,e.current=n,lC(n),zS(),he=a,me=o,Pt.transition=i}else e.current=n;if(Yi&&(Yi=!1,Pn=e,Yo=s),i=e.pendingLanes,i===0&&(Ln=null),$S(n.stateNode),pt(e,Ae()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)s=t[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(Qo)throw Qo=!1,e=zu,zu=null,e;return Yo&1&&e.tag!==0&&Gr(),i=e.pendingLanes,i&1?e===Fu?Ws++:(Ws=0,Fu=e):Ws=0,Kn(),null}function Gr(){if(Pn!==null){var e=pg(Yo),t=Pt.transition,n=me;try{if(Pt.transition=null,me=16>e?16:e,Pn===null)var r=!1;else{if(e=Pn,Pn=null,Yo=0,he&6)throw Error($(331));var s=he;for(he|=4,G=e.current;G!==null;){var i=G,o=i.child;if(G.flags&16){var a=i.deletions;if(a!==null){for(var l=0;l<a.length;l++){var u=a[l];for(G=u;G!==null;){var f=G;switch(f.tag){case 0:case 11:case 15:Vs(8,f,i)}var d=f.child;if(d!==null)d.return=f,G=d;else for(;G!==null;){f=G;var h=f.sibling,p=f.return;if(_y(f),f===u){G=null;break}if(h!==null){h.return=p,G=h;break}G=p}}}var g=i.alternate;if(g!==null){var x=g.child;if(x!==null){g.child=null;do{var k=x.sibling;x.sibling=null,x=k}while(x!==null)}}G=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,G=o;else e:for(;G!==null;){if(i=G,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Vs(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,G=y;break e}G=i.return}}var v=e.current;for(G=v;G!==null;){o=G;var w=o.child;if(o.subtreeFlags&2064&&w!==null)w.return=o,G=w;else e:for(o=v;G!==null;){if(a=G,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:Ta(9,a)}}catch(I){Pe(a,a.return,I)}if(a===o){G=null;break e}var E=a.sibling;if(E!==null){E.return=a.return,G=E;break e}G=a.return}}if(he=s,Kn(),Zt&&typeof Zt.onPostCommitFiberRoot=="function")try{Zt.onPostCommitFiberRoot(xa,e)}catch{}r=!0}return r}finally{me=n,Pt.transition=t}}return!1}function dh(e,t,n){t=ns(n,t),t=py(e,t,1),e=Dn(e,t,1),t=rt(),e!==null&&(Ii(e,1,t),pt(e,t))}function Pe(e,t,n){if(e.tag===3)dh(e,e,n);else for(;t!==null;){if(t.tag===3){dh(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Ln===null||!Ln.has(r))){e=ns(n,e),e=my(t,e,1),t=Dn(t,e,1),e=rt(),t!==null&&(Ii(t,1,e),pt(t,e));break}}t=t.return}}function pC(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=rt(),e.pingedLanes|=e.suspendedLanes&n,Be===e&&(He&n)===n&&(ze===4||ze===3&&(He&130023424)===He&&500>Ae()-nd?ir(e,0):td|=n),pt(e,t)}function Dy(e,t){t===0&&(e.mode&1?(t=Bi,Bi<<=1,!(Bi&130023424)&&(Bi=4194304)):t=1);var n=rt();e=yn(e,t),e!==null&&(Ii(e,t,n),pt(e,n))}function mC(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Dy(e,n)}function gC(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error($(314))}r!==null&&r.delete(t),Dy(e,n)}var Ly;Ly=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ft.current)ct=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ct=!1,rC(e,t,n);ct=!!(e.flags&131072)}else ct=!1,Ce&&t.flags&1048576&&Bg(t,$o,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;xo(e,t),e=t.pendingProps;var s=Xr(t,Xe.current);Kr(t,n),s=Qc(null,t,r,e,s,n);var i=Yc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ht(r)?(i=!0,Fo(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Hc(t),s.updater=Ea,t.stateNode=s,s._reactInternals=t,Tu(t,r,e,n),t=Pu(null,t,r,!0,i,n)):(t.tag=0,Ce&&i&&Oc(t),tt(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(xo(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=vC(r),e=Lt(r,e),s){case 0:t=Ru(null,t,r,e,n);break e;case 1:t=th(null,t,r,e,n);break e;case 11:t=Zf(null,t,r,e,n);break e;case 14:t=eh(null,t,r,Lt(r.type,e),n);break e}throw Error($(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Lt(r,s),Ru(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Lt(r,s),th(e,t,r,s,n);case 3:e:{if(xy(t),e===null)throw Error($(387));r=t.pendingProps,i=t.memoizedState,s=i.element,qg(e,t),Ho(t,r,null,n);var o=t.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=ns(Error($(423)),t),t=nh(e,t,r,n,s);break e}else if(r!==s){s=ns(Error($(424)),t),t=nh(e,t,r,n,s);break e}else for(xt=Mn(t.stateNode.containerInfo.firstChild),wt=t,Ce=!0,zt=null,n=Hg(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Zr(),r===s){t=vn(e,t,n);break e}tt(e,t,r,n)}t=t.child}return t;case 5:return Kg(t),e===null&&Cu(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,o=s.children,xu(r,s)?o=null:i!==null&&xu(r,i)&&(t.flags|=32),vy(e,t),tt(e,t,o,n),t.child;case 6:return e===null&&Cu(t),null;case 13:return wy(e,t,n);case 4:return Wc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=es(t,null,r,n):tt(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Lt(r,s),Zf(e,t,r,s,n);case 7:return tt(e,t,t.pendingProps,n),t.child;case 8:return tt(e,t,t.pendingProps.children,n),t.child;case 12:return tt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,o=s.value,we(Uo,r._currentValue),r._currentValue=o,i!==null)if(Vt(i.value,o)){if(i.children===s.children&&!ft.current){t=vn(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);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 f=u.pending;f===null?l.next=l:(l.next=f.next,f.next=l),u.pending=l}}i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),_u(i.return,n,t),a.lanes|=n;break}l=l.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error($(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),_u(o,n,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}tt(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Kr(t,n),s=jt(s),r=r(s),t.flags|=1,tt(e,t,r,n),t.child;case 14:return r=t.type,s=Lt(r,t.pendingProps),s=Lt(r.type,s),eh(e,t,r,s,n);case 15:return gy(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Lt(r,s),xo(e,t),t.tag=1,ht(r)?(e=!0,Fo(t)):e=!1,Kr(t,n),hy(t,r,s),Tu(t,r,s,n),Pu(null,t,r,!0,e,n);case 19:return by(e,t,n);case 22:return yy(e,t,n)}throw Error($(156,t.tag))};function Oy(e,t){return cg(e,t)}function yC(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,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 Rt(e,t,n,r){return new yC(e,t,n,r)}function od(e){return e=e.prototype,!(!e||!e.isReactComponent)}function vC(e){if(typeof e=="function")return od(e)?1:0;if(e!=null){if(e=e.$$typeof,e===_c)return 11;if(e===Ec)return 14}return 2}function zn(e,t){var n=e.alternate;return n===null?(n=Rt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function So(e,t,n,r,s,i){var o=2;if(r=e,typeof e=="function")od(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case jr:return or(n.children,s,i,t);case Cc:o=8,s|=8;break;case Jl:return e=Rt(12,n,t,s|2),e.elementType=Jl,e.lanes=i,e;case Xl:return e=Rt(13,n,t,s),e.elementType=Xl,e.lanes=i,e;case Zl:return e=Rt(19,n,t,s),e.elementType=Zl,e.lanes=i,e;case Km:return Ra(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Wm:o=10;break e;case qm:o=9;break e;case _c:o=11;break e;case Ec:o=14;break e;case Cn:o=16,r=null;break e}throw Error($(130,e==null?e:typeof e,""))}return t=Rt(o,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function or(e,t,n,r){return e=Rt(7,e,r,t),e.lanes=n,e}function Ra(e,t,n,r){return e=Rt(22,e,r,t),e.elementType=Km,e.lanes=n,e.stateNode={isHidden:!1},e}function Sl(e,t,n){return e=Rt(6,e,null,t),e.lanes=n,e}function kl(e,t,n){return t=Rt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function xC(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=rl(0),this.expirationTimes=rl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rl(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function ad(e,t,n,r,s,i,o,a,l){return e=new xC(e,t,n,a,l),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Rt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Hc(i),e}function wC(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Ar,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function zy(e){if(!e)return $n;e=e._reactInternals;e:{if(vr(e)!==e||e.tag!==1)throw Error($(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(ht(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error($(171))}if(e.tag===1){var n=e.type;if(ht(n))return zg(e,n,t)}return t}function Fy(e,t,n,r,s,i,o,a,l){return e=ad(n,r,!0,e,s,i,o,a,l),e.context=zy(null),n=e.current,r=rt(),s=On(n),i=pn(r,s),i.callback=t??null,Dn(n,i,s),e.current.lanes=s,Ii(e,s,r),pt(e,r),e}function Pa(e,t,n,r){var s=t.current,i=rt(),o=On(s);return n=zy(n),t.context===null?t.context=n:t.pendingContext=n,t=pn(i,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Dn(s,t,o),e!==null&&($t(e,s,o,i),go(e,s,o)),o}function Xo(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function fh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ld(e,t){fh(e,t),(e=e.alternate)&&fh(e,t)}function bC(){return null}var By=typeof reportError=="function"?reportError:function(e){console.error(e)};function ud(e){this._internalRoot=e}Aa.prototype.render=ud.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error($(409));Pa(e,t,null,null)};Aa.prototype.unmount=ud.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;hr(function(){Pa(null,e,null,null)}),t[gn]=null}};function Aa(e){this._internalRoot=e}Aa.prototype.unstable_scheduleHydration=function(e){if(e){var t=yg();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Tn.length&&t!==0&&t<Tn[n].priority;n++);Tn.splice(n,0,e),n===0&&xg(e)}};function cd(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ja(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function hh(){}function SC(e,t,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var u=Xo(o);i.call(u)}}var o=Fy(t,r,e,0,null,!1,!1,"",hh);return e._reactRootContainer=o,e[gn]=o.current,ci(e.nodeType===8?e.parentNode:e),hr(),o}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var a=r;r=function(){var u=Xo(l);a.call(u)}}var l=ad(e,0,!1,null,null,!1,!1,"",hh);return e._reactRootContainer=l,e[gn]=l.current,ci(e.nodeType===8?e.parentNode:e),hr(function(){Pa(t,l,n,r)}),l}function Na(e,t,n,r,s){var i=n._reactRootContainer;if(i){var o=i;if(typeof s=="function"){var a=s;s=function(){var l=Xo(o);a.call(l)}}Pa(t,o,e,s)}else o=SC(n,t,e,s,r);return Xo(o)}mg=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Ds(t.pendingLanes);n!==0&&(Rc(t,n|1),pt(t,Ae()),!(he&6)&&(rs=Ae()+500,Kn()))}break;case 13:hr(function(){var r=yn(e,1);if(r!==null){var s=rt();$t(r,e,1,s)}}),ld(e,1)}};Pc=function(e){if(e.tag===13){var t=yn(e,134217728);if(t!==null){var n=rt();$t(t,e,134217728,n)}ld(e,134217728)}};gg=function(e){if(e.tag===13){var t=On(e),n=yn(e,t);if(n!==null){var r=rt();$t(n,e,t,r)}ld(e,t)}};yg=function(){return me};vg=function(e,t){var n=me;try{return me=e,t()}finally{me=n}};uu=function(e,t,n){switch(t){case"input":if(nu(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var s=ka(r);if(!s)throw Error($(90));Qm(r),nu(r,s)}}}break;case"textarea":Jm(e,n);break;case"select":t=n.value,t!=null&&Vr(e,!!n.multiple,t,!1)}};sg=rd;ig=hr;var kC={usingClientEntryPoint:!1,Events:[Pi,Lr,ka,ng,rg,rd]},Rs={findFiberByHostInstance:nr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},CC={bundleType:Rs.bundleType,version:Rs.version,rendererPackageName:Rs.rendererPackageName,rendererConfig:Rs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:xn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=lg(e),e===null?null:e.stateNode},findFiberByHostInstance:Rs.findFiberByHostInstance||bC,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 Ji=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ji.isDisabled&&Ji.supportsFiber)try{xa=Ji.inject(CC),Zt=Ji}catch{}}Ct.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=kC;Ct.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!cd(t))throw Error($(200));return wC(e,t,null,n)};Ct.createRoot=function(e,t){if(!cd(e))throw Error($(299));var n=!1,r="",s=By;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=ad(e,1,!1,null,null,n,!1,r,s),e[gn]=t.current,ci(e.nodeType===8?e.parentNode:e),new ud(t)};Ct.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error($(188)):(e=Object.keys(e).join(","),Error($(268,e)));return e=lg(t),e=e===null?null:e.stateNode,e};Ct.flushSync=function(e){return hr(e)};Ct.hydrate=function(e,t,n){if(!ja(t))throw Error($(200));return Na(null,e,t,!0,n)};Ct.hydrateRoot=function(e,t,n){if(!cd(e))throw Error($(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",o=By;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=Fy(t,null,e,1,n??null,s,!1,i,o),e[gn]=t.current,ci(e),r)for(e=0;e<r.length;e++)n=r[e],s=n._getVersion,s=s(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,s]:t.mutableSourceEagerHydrationData.push(n,s);return new Aa(t)};Ct.render=function(e,t,n){if(!ja(t))throw Error($(200));return Na(null,e,t,!1,n)};Ct.unmountComponentAtNode=function(e){if(!ja(e))throw Error($(40));return e._reactRootContainer?(hr(function(){Na(null,null,e,!1,function(){e._reactRootContainer=null,e[gn]=null})}),!0):!1};Ct.unstable_batchedUpdates=rd;Ct.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!ja(n))throw Error($(200));if(e==null||e._reactInternals===void 0)throw Error($(38));return Na(e,t,n,!1,r)};Ct.version="18.3.1-next-f1338f8080-20240426";function $y(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE($y)}catch(e){console.error(e)}}$y(),$m.exports=Ct;var _C=$m.exports,Uy,ph=_C;Uy=ph.createRoot,ph.hydrateRoot;function EC(e,t){const n=e[Vy];if(!n)throw new Error("ResourceElement.type is not a valid Resource");return n(t)}const Vy=Symbol("fnSymbol");function ce(e){const t=n=>({type:t,props:n});return t[Vy]=e,t}function rn(e,t){return{...t,key:e}}let qs=null;function TC(e,t){e.currentIndex=0;const n=qs;qs=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw new Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{qs=n}}function Un(){if(!qs)throw new Error("No resource fiber available");return qs}function IC(e){return null}const Hy=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],dirtyCells:[]}),Zo=e=>{for(const t of e.dirtyCells)t.dirty=!1,t.queue.clear(),t.current=t.workInProgress;e.committedVersion=e.version,e.changelog.length=0,e.dirtyCells.length=0},Ks=(e,t)=>{const n=e.version>t;if(e.version=t,n){for(const r of e.dirtyCells)r.dirty=!1,r.queue.clear(),r.workInProgress=r.current;if(e.dirtyCells.length=0,t===e.committedVersion)e.changelog.length=0;else{if(e.committedVersion>t)throw new Error("Version is less than committed version");for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop();e.changelog.forEach(r=>r()),Zo(e)}}},mh=(e,t)=>{t.dirty||(t.dirty=!0,e.markDirty?.(),e.root.dirtyCells.push(t))},Wy=(e,t)=>{const n=Un(),r=n.currentIndex++;if(!n.isFirstRender&&r>=n.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");let s=n.cells[r];if(s||(s=t(),n.cells[r]=s),s.type!==e)throw new Error("Hook order changed between renders");return s},RC=e=>{Un().renderContext.effectTasks.push(e)},PC=(e,t)=>{if(e.renderContext)throw new Error("Resource updated during render");if(e.isNeverMounted)throw new Error("Resource updated before mount");e.root.dispatchUpdate(()=>{const n=t();return n?(n(),e.root.changelog.push(n),!0):!1})};function qy(e,t,n,r){const s=Wy("reducer",()=>{const a=Un(),l=r?r(n):n;return{type:"reducer",queue:new Set,dirty:!1,workInProgress:l,current:l,reducer:e,dispatch:u=>{const f={action:u,hasEagerState:!1,eagerState:void 0};PC(a,()=>a.root.dirtyCells.length===0&&!f.hasEagerState&&(f.eagerState=e(s.workInProgress,u),f.hasEagerState=!0,Object.is(s.current,f.eagerState))?null:()=>{mh(a,s),s.queue.add(f)})}}}),i=Un(),o=e===s.reducer;s.reducer=e;for(const a of s.queue)(!a.hasEagerState||!o)&&(a.eagerState=e(s.workInProgress,a.action),a.hasEagerState=!0),s.workInProgress=a.eagerState;if(s.queue.clear(),t){const a=t(s.workInProgress);Object.is(a,s.workInProgress)||(mh(i,s),s.workInProgress=a)}return[s.workInProgress,s.dispatch]}function AC(e,t,n){return qy(e,void 0,t,n)}function jC(e,t,n,r){return qy(e,t,n,r)}const NC=(e,t)=>typeof t=="function"?t(e):t,MC=e=>typeof e=="function"?e():e;function kt(e){return AC(NC,e,MC)}const Ky=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},DC=()=>({type:"effect",cleanup:void 0,deps:null});function je(e,t){const n=Wy("effect",DC);if(!(t&&n.deps&&Ky(n.deps,t))){if(n.deps!==null&&!!t!=!!n.deps)throw new Error("tapEffect called with and without dependencies across re-renders");RC(()=>{const r=[];try{n.cleanup?.()}catch(s){r.push(s)}finally{n.cleanup=void 0}try{const s=e();if(s!==void 0&&typeof s!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof s}`);n.cleanup=s}catch(s){r.push(s)}if(n.deps=t,r.length>0){if(r.length===1)throw r[0];for(const s of r)console.error(s);throw new AggregateError(r,"Errors during commit")}})}}function tn(e){const[t]=kt(()=>({current:e}));return t}function ar(e,t){const[n]=kt(e);return n}const LC=()=>{throw new Error("Memo reducer should not be called")},ie=(e,t)=>{Un();const[n]=jC(LC,r=>r&&Ky(r.deps,t)?r:{value:e(),deps:t},null);return n.value},xi=(e,t)=>ie(()=>e,t);function nn(e){const t=tn(e);je(()=>{t.current=e});const n=Un();return xi((...r)=>t.current(...r),[n])}function OC(e){const t=[];for(const n of e.effectTasks)try{n()}catch(r){t.push(r)}if(t.length>0){if(t.length===1)throw t[0];for(const n of t)console.error(n);throw new AggregateError(t,"Errors during commit")}}function zC(e){const t=[];for(const n of e.cells)if(n?.type==="effect"&&(n.deps=null,n.cleanup))try{n.cleanup?.()}catch(r){t.push(r)}finally{n.cleanup=void 0}if(t.length>0){if(t.length===1)throw t[0];for(const n of t)console.error(n);throw new AggregateError(t,"Errors during cleanup")}}function wi(e,t,n=void 0,r=IC()){return{type:e,root:t,markDirty:n,devStrictMode:r,cells:[],currentIndex:0,renderContext:void 0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function Qr(e){if(!e.isMounted)throw new Error("Tried to unmount a fiber that is already unmounted");e.isMounted=!1,zC(e)}function Fn(e,t){const n={effectTasks:[],props:t,output:void 0};return TC(e,()=>{e.renderContext=n;try{n.output=EC(e.type,t)}finally{e.renderContext=void 0}}),n}function ss(e,t){e.isMounted=!0,e.isNeverMounted=!1,OC(t)}function Ve(e,t){const n=Un(),r=tn(0),s=ie(()=>(e.key,wi(e.type,n.root,()=>{r.current++,n.markDirty?.()})),[e.type,e.key,n]),i=t?ie(()=>Fn(s,e.props),[s,...t,r.current]):Fn(s,e.props);return je(()=>()=>Qr(s),[s]),je(()=>{ss(s,i)},[s,i]),i.output}function Ma(e,t){const n=tn(0),r=n.current,s=ar(Un),i=ar(()=>()=>{n.current++,s.markDirty?.()}),o=ar(()=>new Map),a=t?xi(e,t):e,l=ie(()=>{const u=a(),f=new Set,d=[];let h=0;for(let p=0;p<u.length;p++){const g=u[p],x=g.key;if(x===void 0)throw new Error(`tapResources did not provide a key for array at index ${p}`);if(f.has(x))throw new Error(`Duplicate key ${x} in tapResources`);f.add(x);let k=o.get(x);if(k)if(k.fiber.type!==g.type){const y=wi(g.type,s.root,i),v=Fn(y,g.props);k.next=[y,v],d.push(v.output)}else k.next=Fn(k.fiber,g.props),d.push(k.next.output);else{const y=wi(g.type,s.root,i),v=Fn(y,g.props);k={fiber:y,next:v},h++,o.set(x,k),d.push(v.output)}}if(o.size>d.length-h)for(const p of o.keys())f.has(p)||(o.get(p).next="delete");return d},[a,r]);return je(()=>()=>{for(const u of o.keys()){const f=o.get(u).fiber;Qr(f)}},[]),je(()=>{for(const[u,f]of o.entries())f.next==="delete"?(f.fiber.isMounted&&Qr(f.fiber),o.delete(u)):Array.isArray(f.next)?(Qr(f.fiber),f.fiber=f.next[0],ss(f.fiber,f.next[1])):ss(f.fiber,f.next)},[l]),l}const FC=50;let Xt={schedulers:new Set([]),isScheduled:!1};var BC=class{constructor(e){T(this,"_task");T(this,"_isDirty",!1);this._task=e}get isDirty(){return this._isDirty}markDirty(){this._isDirty=!0,Xt.schedulers.add(this),$C()}runTask(){this._isDirty=!1,this._task()}};const $C=()=>{Xt.isScheduled||(Xt.isScheduled=!0,UC())},Uu=()=>{try{const e=[];let t=0;for(const n of Xt.schedulers)if(Xt.schedulers.delete(n),!!n.isDirty){if(t++,t>FC)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside tapEffect.");try{n.runTask()}catch(r){e.push(r)}}if(e.length>0){if(e.length===1)throw e[0];for(const n of e)console.error(n);throw new AggregateError(e,"Errors occurred during flushSync")}}finally{Xt.schedulers.clear(),Xt.isScheduled=!1}},UC=(()=>{if(typeof MessageChannel<"u"){const e=new MessageChannel;return e.port1.onmessage=Uu,()=>e.port2.postMessage(null)}return()=>setTimeout(Uu,0)})(),gh=e=>{const t=Xt;Xt={schedulers:new Set([]),isScheduled:!0};try{const n=e();return Uu(),n}finally{Xt=t}},VC=e=>{const t=ar(()=>new BC(()=>u(null))),n=ar(()=>[]),r=ie(()=>(e.key,wi(e.type,Hy(f=>{!t.isDirty&&!f()||(n.push(f),t.markDirty())}))),[e.type,e.key]);Ks(r.root,r.root.committedVersion);const s=Fn(r,e.props),i=tn(!1),o=tn(e.props),a=tn(s.output),l=ar(()=>new Set),u=nn(f=>{if(f===null&&(Ks(r.root,2),Ks(r.root,1),n.forEach(d=>{d()}),f=Fn(r,o.current)),t.isDirty)throw new Error("Scheduler is dirty, this should never happen");Zo(r.root),n.length=0,i.current&&ss(r,f),!(t.isDirty||a.current===f.output)&&(a.current=f.output,l.forEach(d=>d()))});return je(()=>(i.current=!0,()=>{i.current=!1,Qr(r)}),[r]),je(()=>{o.current=s.props,Zo(r.root),ss(r,s),!(t.isDirty||a.current===s.output)&&(a.current=s.output,l.forEach(f=>f()))}),ie(()=>({getValue:()=>a.current,subscribe:f=>(l.add(f),()=>l.delete(f))}),[])},Gs=Symbol("tap.Context"),Gy=e=>({[Gs]:e}),Qy=(e,t,n)=>{const r=e[Gs];e[Gs]=t;try{return n()}finally{e[Gs]=r}},Yy=e=>e[Gs],HC=ce(()=>{const[e,t]=kt(()=>({renderers:{},fallbacks:[]}));return{getState:()=>e,setDataUI:xi((n,r)=>(t(s=>({...s,renderers:{...s.renderers,[n]:[...s.renderers[n]??[],r]}})),()=>{t(s=>({...s,renderers:{...s.renderers,[n]:s.renderers[n]?.filter(i=>i!==r)??[]}}))}),[]),setFallbackDataUI:xi(n=>(t(r=>({...r,fallbacks:[...r.fallbacks,n]})),()=>{t(r=>({...r,fallbacks:r.fallbacks.filter(s=>s!==n)}))}),[])}}),WC=e=>{const t=Array.from(e).map(r=>r.getModelContext()).sort((r,s)=>(s.priority??0)-(r.priority??0)),n={};return t.reduce((r,s)=>{const i=s.priority??0;if(s.system&&(r.system?r.system+=`
|
|
40
|
+
`+i.stack}return{value:e,source:t,stack:s,digest:null}}function wl(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Iu(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var nC=typeof WeakMap=="function"?WeakMap:Map;function my(e,t,n){n=pn(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Qo||(Qo=!0,zu=r),Iu(e,t)},n}function gy(e,t,n){n=pn(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var s=t.value;n.payload=function(){return r(s)},n.callback=function(){Iu(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){Iu(e,t),typeof r!="function"&&(On===null?On=new Set([this]):On.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function Yf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new nC;var s=new Set;r.set(t,s)}else s=r.get(t),s===void 0&&(s=new Set,r.set(t,s));s.has(n)||(s.add(n),e=gC.bind(null,e,t,n),t.then(e,e))}function Jf(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function Xf(e,t,n,r,s){return e.mode&1?(e.flags|=65536,e.lanes=s,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=pn(-1,1),t.tag=2,Ln(n,t,1))),n.lanes|=1),e)}var rC=xn.ReactCurrentOwner,ct=!1;function tt(e,t,n,r){t.child=e===null?Wg(t,null,n,r):es(t,e.child,n,r)}function Zf(e,t,n,r,s){n=n.render;var i=t.ref;return Kr(t,s),r=Qc(e,t,n,r,i,s),n=Yc(),e!==null&&!ct?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,vn(e,t,s)):(Ce&&n&&Oc(t),t.flags|=1,tt(e,t,r,s),t.child)}function eh(e,t,n,r,s){if(e===null){var i=n.type;return typeof i=="function"&&!od(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,yy(e,t,i,r,s)):(e=So(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&s)){var o=i.memoizedProps;if(n=n.compare,n=n!==null?n:ui,n(o,r)&&e.ref===t.ref)return vn(e,t,s)}return t.flags|=1,e=Fn(i,r),e.ref=t.ref,e.return=t,t.child=e}function yy(e,t,n,r,s){if(e!==null){var i=e.memoizedProps;if(ui(i,r)&&e.ref===t.ref)if(ct=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(ct=!0);else return t.lanes=e.lanes,vn(e,t,s)}return Ru(e,t,n,r,s)}function vy(e,t,n){var r=t.pendingProps,s=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},we(Ur,vt),vt|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,we(Ur,vt),vt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,we(Ur,vt),vt|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,we(Ur,vt),vt|=r;return tt(e,t,s,n),t.child}function xy(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ru(e,t,n,r,s){var i=ht(n)?ur:Xe.current;return i=Xr(t,i),Kr(t,s),n=Qc(e,t,n,r,i,s),r=Yc(),e!==null&&!ct?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,vn(e,t,s)):(Ce&&r&&Oc(t),t.flags|=1,tt(e,t,n,s),t.child)}function th(e,t,n,r,s){if(ht(n)){var i=!0;Fo(t)}else i=!1;if(Kr(t,s),t.stateNode===null)xo(e,t),py(t,n,r),Tu(t,n,r,s),r=!0;else if(e===null){var o=t.stateNode,a=t.memoizedProps;o.props=a;var l=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=jt(u):(u=ht(n)?ur:Xe.current,u=Xr(t,u));var f=n.getDerivedStateFromProps,d=typeof f=="function"||typeof o.getSnapshotBeforeUpdate=="function";d||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||l!==u)&&Qf(t,o,r,u),_n=!1;var h=t.memoizedState;o.state=h,Ho(t,r,o,s),l=t.memoizedState,a!==r||h!==l||ft.current||_n?(typeof f=="function"&&(Eu(t,n,f,r),l=t.memoizedState),(a=_n||Gf(t,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"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),o.props=r,o.state=l,o.context=u,r=a):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,Kg(e,t),a=t.memoizedProps,u=t.type===t.elementType?a:Lt(t.type,a),o.props=u,d=t.pendingProps,h=o.context,l=n.contextType,typeof l=="object"&&l!==null?l=jt(l):(l=ht(n)?ur:Xe.current,l=Xr(t,l));var p=n.getDerivedStateFromProps;(f=typeof p=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==d||h!==l)&&Qf(t,o,r,l),_n=!1,h=t.memoizedState,o.state=h,Ho(t,r,o,s);var g=t.memoizedState;a!==d||h!==g||ft.current||_n?(typeof p=="function"&&(Eu(t,n,p,r),g=t.memoizedState),(u=_n||Gf(t,n,u,r,h,g,l)||!1)?(f||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,g,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,g,l)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=g),o.props=r,o.state=g,o.context=l,r=u):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),r=!1)}return Pu(e,t,n,r,i,s)}function Pu(e,t,n,r,s,i){xy(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return s&&Bf(t,n,!1),vn(e,t,i);r=t.stateNode,rC.current=t;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=es(t,e.child,null,i),t.child=es(t,null,a,i)):tt(e,t,a,i),t.memoizedState=r.state,s&&Bf(t,n,!0),t.child}function wy(e){var t=e.stateNode;t.pendingContext?Ff(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Ff(e,t.context,!1),Wc(e,t.containerInfo)}function nh(e,t,n,r,s){return Zr(),Fc(s),t.flags|=256,tt(e,t,n,r),t.child}var Au={dehydrated:null,treeContext:null,retryLane:0};function ju(e){return{baseLanes:e,cachePool:null,transitions:null}}function by(e,t,n){var r=t.pendingProps,s=Ee.current,i=!1,o=(t.flags&128)!==0,a;if((a=o)||(a=e!==null&&e.memoizedState===null?!1:(s&2)!==0),a?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),we(Ee,s&1),e===null)return Cu(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,i?(r=t.mode,i=t.child,o={mode:"hidden",children:o},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=Ra(o,r,0,null),e=or(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=ju(n),t.memoizedState=Au,e):Zc(t,o));if(s=e.memoizedState,s!==null&&(a=s.dehydrated,a!==null))return sC(e,t,o,r,a,s,n);if(i){i=r.fallback,o=t.mode,s=e.child,a=s.sibling;var l={mode:"hidden",children:r.children};return!(o&1)&&t.child!==s?(r=t.child,r.childLanes=0,r.pendingProps=l,t.deletions=null):(r=Fn(s,l),r.subtreeFlags=s.subtreeFlags&14680064),a!==null?i=Fn(a,i):(i=or(i,o,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,o=e.child.memoizedState,o=o===null?ju(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~n,t.memoizedState=Au,r}return i=e.child,e=i.sibling,r=Fn(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Zc(e,t){return t=Ra({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Gi(e,t,n,r){return r!==null&&Fc(r),es(t,e.child,null,n),e=Zc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function sC(e,t,n,r,s,i,o){if(n)return t.flags&256?(t.flags&=-257,r=wl(Error($(422))),Gi(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=Ra({mode:"visible",children:r.children},s,0,null),i=or(i,s,o,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&es(t,e.child,null,o),t.child.memoizedState=ju(o),t.memoizedState=Au,i);if(!(t.mode&1))return Gi(e,t,o,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var a=r.dgst;return r=a,i=Error($(419)),r=wl(i,r,void 0),Gi(e,t,o,r)}if(a=(o&e.childLanes)!==0,ct||a){if(r=Ue,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,yn(e,s),$t(r,e,s,-1))}return id(),r=wl(Error($(421))),Gi(e,t,o,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=yC.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,xt=Dn(s.nextSibling),wt=t,Ce=!0,zt=null,e!==null&&(Et[Tt++]=dn,Et[Tt++]=fn,Et[Tt++]=cr,dn=e.id,fn=e.overflow,cr=t),t=Zc(t,r.children),t.flags|=4096,t)}function rh(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),_u(e.return,t,n)}function bl(e,t,n,r,s){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=s)}function Sy(e,t,n){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(tt(e,t,r.children,n),r=Ee.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&rh(e,n,t);else if(e.tag===19)rh(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(we(Ee,r),!(t.mode&1))t.memoizedState=null;else switch(s){case"forwards":for(n=t.child,s=null;n!==null;)e=n.alternate,e!==null&&Wo(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),bl(t,!1,s,n,i);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&Wo(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}bl(t,!0,n,null,i);break;case"together":bl(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function xo(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function vn(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),fr|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error($(153));if(t.child!==null){for(e=t.child,n=Fn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Fn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function iC(e,t,n){switch(t.tag){case 3:wy(t),Zr();break;case 5:Gg(t);break;case 1:ht(t.type)&&Fo(t);break;case 4:Wc(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;we(Uo,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(we(Ee,Ee.current&1),t.flags|=128,null):n&t.child.childLanes?by(e,t,n):(we(Ee,Ee.current&1),e=vn(e,t,n),e!==null?e.sibling:null);we(Ee,Ee.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Sy(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),we(Ee,Ee.current),r)break;return null;case 22:case 23:return t.lanes=0,vy(e,t,n)}return vn(e,t,n)}var ky,Nu,Cy,_y;ky=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Nu=function(){};Cy=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,sr(en.current);var i=null;switch(n){case"input":s=tu(e,s),r=tu(e,r),i=[];break;case"select":s=Re({},s,{value:void 0}),r=Re({},r,{value:void 0}),i=[];break;case"textarea":s=su(e,s),r=su(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Oo)}ou(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"&&(ni.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in r){var l=r[u];if(a=s?.[u],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"&&(ni.hasOwnProperty(u)?(l!=null&&u==="onScroll"&&Se("scroll",e),i||a===l||(i=[])):(i=i||[]).push(u,l))}n&&(i=i||[]).push("style",n);var u=i;(t.updateQueue=u)&&(t.flags|=4)}};_y=function(e,t,n,r){n!==r&&(t.flags|=4)};function Is(e,t){if(!Ce)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ge(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function oC(e,t,n){var r=t.pendingProps;switch(zc(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ge(t),null;case 1:return ht(t.type)&&zo(),Ge(t),null;case 3:return r=t.stateNode,ts(),ke(ft),ke(Xe),Kc(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(qi(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,zt!==null&&($u(zt),zt=null))),Nu(e,t),Ge(t),null;case 5:qc(t);var s=sr(pi.current);if(n=t.type,e!==null&&t.stateNode!=null)Cy(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error($(166));return Ge(t),null}if(e=sr(en.current),qi(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Jt]=t,r[fi]=i,e=(t.mode&1)!==0,n){case"dialog":Se("cancel",r),Se("close",r);break;case"iframe":case"object":case"embed":Se("load",r);break;case"video":case"audio":for(s=0;s<Ls.length;s++)Se(Ls[s],r);break;case"source":Se("error",r);break;case"img":case"image":case"link":Se("error",r),Se("load",r);break;case"details":Se("toggle",r);break;case"input":ff(r,i),Se("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},Se("invalid",r);break;case"textarea":pf(r,i),Se("invalid",r)}ou(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&&Wi(r.textContent,a,e),s=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(i.suppressHydrationWarning!==!0&&Wi(r.textContent,a,e),s=["children",""+a]):ni.hasOwnProperty(o)&&a!=null&&o==="onScroll"&&Se("scroll",r)}switch(n){case"input":Oi(r),hf(r,i,!0);break;case"textarea":Oi(r),mf(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=Oo)}r=s,t.updateQueue=r,r!==null&&(t.flags|=4)}else{o=s.nodeType===9?s:s.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Zm(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Jt]=t,e[fi]=r,ky(e,t,!1,!1),t.stateNode=e;e:{switch(o=au(n,r),n){case"dialog":Se("cancel",e),Se("close",e),s=r;break;case"iframe":case"object":case"embed":Se("load",e),s=r;break;case"video":case"audio":for(s=0;s<Ls.length;s++)Se(Ls[s],e);s=r;break;case"source":Se("error",e),s=r;break;case"img":case"image":case"link":Se("error",e),Se("load",e),s=r;break;case"details":Se("toggle",e),s=r;break;case"input":ff(e,r),s=tu(e,r),Se("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=Re({},r,{value:void 0}),Se("invalid",e);break;case"textarea":pf(e,r),s=su(e,r),Se("invalid",e);break;default:s=r}ou(n,s),a=s;for(i in a)if(a.hasOwnProperty(i)){var l=a[i];i==="style"?ng(e,l):i==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&eg(e,l)):i==="children"?typeof l=="string"?(n!=="textarea"||l!=="")&&ri(e,l):typeof l=="number"&&ri(e,""+l):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(ni.hasOwnProperty(i)?l!=null&&i==="onScroll"&&Se("scroll",e):l!=null&&kc(e,i,l,o))}switch(n){case"input":Oi(e),hf(e,r,!1);break;case"textarea":Oi(e),mf(e);break;case"option":r.value!=null&&e.setAttribute("value",""+$n(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?Vr(e,!!r.multiple,i,!1):r.defaultValue!=null&&Vr(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=Oo)}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&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Ge(t),null;case 6:if(e&&t.stateNode!=null)_y(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error($(166));if(n=sr(pi.current),sr(en.current),qi(t)){if(r=t.stateNode,n=t.memoizedProps,r[Jt]=t,(i=r.nodeValue!==n)&&(e=wt,e!==null))switch(e.tag){case 3:Wi(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Wi(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Jt]=t,t.stateNode=r}return Ge(t),null;case 13:if(ke(Ee),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Ce&&xt!==null&&t.mode&1&&!(t.flags&128))Vg(),Zr(),t.flags|=98560,i=!1;else if(i=qi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error($(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error($(317));i[Jt]=t}else Zr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ge(t),i=!1}else zt!==null&&($u(zt),zt=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Ee.current&1?Be===0&&(Be=3):id())),t.updateQueue!==null&&(t.flags|=4),Ge(t),null);case 4:return ts(),Nu(e,t),e===null&&ci(t.stateNode.containerInfo),Ge(t),null;case 10:return Uc(t.type._context),Ge(t),null;case 17:return ht(t.type)&&zo(),Ge(t),null;case 19:if(ke(Ee),i=t.memoizedState,i===null)return Ge(t),null;if(r=(t.flags&128)!==0,o=i.rendering,o===null)if(r)Is(i,!1);else{if(Be!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Wo(e),o!==null){for(t.flags|=128,Is(i,!1),r=o.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=e,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,e=o.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return we(Ee,Ee.current&1|2),t.child}e=e.sibling}i.tail!==null&&je()>rs&&(t.flags|=128,r=!0,Is(i,!1),t.lanes=4194304)}else{if(!r)if(e=Wo(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Is(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!Ce)return Ge(t),null}else 2*je()-i.renderingStartTime>rs&&n!==1073741824&&(t.flags|=128,r=!0,Is(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(n=i.last,n!==null?n.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=je(),t.sibling=null,n=Ee.current,we(Ee,r?n&1|2:n&1),t):(Ge(t),null);case 22:case 23:return sd(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?vt&1073741824&&(Ge(t),t.subtreeFlags&6&&(t.flags|=8192)):Ge(t),null;case 24:return null;case 25:return null}throw Error($(156,t.tag))}function aC(e,t){switch(zc(t),t.tag){case 1:return ht(t.type)&&zo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ts(),ke(ft),ke(Xe),Kc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return qc(t),null;case 13:if(ke(Ee),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error($(340));Zr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ke(Ee),null;case 4:return ts(),null;case 10:return Uc(t.type._context),null;case 22:case 23:return sd(),null;case 24:return null;default:return null}}var Qi=!1,Qe=!1,lC=typeof WeakSet=="function"?WeakSet:Set,G=null;function $r(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ae(e,t,r)}else n.current=null}function Mu(e,t,n){try{n()}catch(r){Ae(e,t,r)}}var sh=!1;function uC(e,t){if(yu=Mo,e=Pg(),Lc(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.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,f=0,d=e,h=null;t:for(;;){for(var p;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),(p=d.firstChild)!==null;)h=d,d=p;for(;;){if(d===e)break t;if(h===n&&++u===s&&(a=o),h===i&&++f===r&&(l=o),(p=d.nextSibling)!==null)break;d=h,h=d.parentNode}d=p}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(vu={focusedElem:e,selectionRange:n},Mo=!1,G=t;G!==null;)if(t=G,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,G=e;else for(;G!==null;){t=G;try{var g=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var v=g.memoizedProps,S=g.memoizedState,y=t.stateNode,x=y.getSnapshotBeforeUpdate(t.elementType===t.type?v:Lt(t.type,v),S);y.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error($(163))}}catch(E){Ae(t,t.return,E)}if(e=t.sibling,e!==null){e.return=t.return,G=e;break}G=t.return}return g=sh,sh=!1,g}function Vs(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&Mu(t,n,i)}s=s.next}while(s!==r)}}function Ta(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Du(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Ey(e){var t=e.alternate;t!==null&&(e.alternate=null,Ey(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Jt],delete t[fi],delete t[bu],delete t[Wk],delete t[qk])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Ty(e){return e.tag===5||e.tag===3||e.tag===4}function ih(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ty(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Lu(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Oo));else if(r!==4&&(e=e.child,e!==null))for(Lu(e,t,n),e=e.sibling;e!==null;)Lu(e,t,n),e=e.sibling}function Ou(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Ou(e,t,n),e=e.sibling;e!==null;)Ou(e,t,n),e=e.sibling}var Ve=null,Ot=!1;function Sn(e,t,n){for(n=n.child;n!==null;)Iy(e,t,n),n=n.sibling}function Iy(e,t,n){if(Zt&&typeof Zt.onCommitFiberUnmount=="function")try{Zt.onCommitFiberUnmount(xa,n)}catch{}switch(n.tag){case 5:Qe||$r(n,t);case 6:var r=Ve,s=Ot;Ve=null,Sn(e,t,n),Ve=r,Ot=s,Ve!==null&&(Ot?(e=Ve,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ve.removeChild(n.stateNode));break;case 18:Ve!==null&&(Ot?(e=Ve,n=n.stateNode,e.nodeType===8?pl(e.parentNode,n):e.nodeType===1&&pl(e,n),ai(e)):pl(Ve,n.stateNode));break;case 4:r=Ve,s=Ot,Ve=n.stateNode.containerInfo,Ot=!0,Sn(e,t,n),Ve=r,Ot=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)&&Mu(n,t,o),s=s.next}while(s!==r)}Sn(e,t,n);break;case 1:if(!Qe&&($r(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Ae(n,t,a)}Sn(e,t,n);break;case 21:Sn(e,t,n);break;case 22:n.mode&1?(Qe=(r=Qe)||n.memoizedState!==null,Sn(e,t,n),Qe=r):Sn(e,t,n);break;default:Sn(e,t,n)}}function oh(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new lC),t.forEach(function(r){var s=vC.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Dt(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var i=e,o=t,a=o;e:for(;a!==null;){switch(a.tag){case 5:Ve=a.stateNode,Ot=!1;break e;case 3:Ve=a.stateNode.containerInfo,Ot=!0;break e;case 4:Ve=a.stateNode.containerInfo,Ot=!0;break e}a=a.return}if(Ve===null)throw Error($(160));Iy(i,o,s),Ve=null,Ot=!1;var l=s.alternate;l!==null&&(l.return=null),s.return=null}catch(u){Ae(s,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Ry(t,e),t=t.sibling}function Ry(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Dt(t,e),Kt(e),r&4){try{Vs(3,e,e.return),Ta(3,e)}catch(v){Ae(e,e.return,v)}try{Vs(5,e,e.return)}catch(v){Ae(e,e.return,v)}}break;case 1:Dt(t,e),Kt(e),r&512&&n!==null&&$r(n,n.return);break;case 5:if(Dt(t,e),Kt(e),r&512&&n!==null&&$r(n,n.return),e.flags&32){var s=e.stateNode;try{ri(s,"")}catch(v){Ae(e,e.return,v)}}if(r&4&&(s=e.stateNode,s!=null)){var i=e.memoizedProps,o=n!==null?n.memoizedProps:i,a=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{a==="input"&&i.type==="radio"&&i.name!=null&&Jm(s,i),au(a,o);var u=au(a,i);for(o=0;o<l.length;o+=2){var f=l[o],d=l[o+1];f==="style"?ng(s,d):f==="dangerouslySetInnerHTML"?eg(s,d):f==="children"?ri(s,d):kc(s,f,d,u)}switch(a){case"input":nu(s,i);break;case"textarea":Xm(s,i);break;case"select":var h=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var p=i.value;p!=null?Vr(s,!!i.multiple,p,!1):h!==!!i.multiple&&(i.defaultValue!=null?Vr(s,!!i.multiple,i.defaultValue,!0):Vr(s,!!i.multiple,i.multiple?[]:"",!1))}s[fi]=i}catch(v){Ae(e,e.return,v)}}break;case 6:if(Dt(t,e),Kt(e),r&4){if(e.stateNode===null)throw Error($(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(v){Ae(e,e.return,v)}}break;case 3:if(Dt(t,e),Kt(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{ai(t.containerInfo)}catch(v){Ae(e,e.return,v)}break;case 4:Dt(t,e),Kt(e);break;case 13:Dt(t,e),Kt(e),s=e.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(nd=je())),r&4&&oh(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Qe=(u=Qe)||f,Dt(t,e),Qe=u):Dt(t,e),Kt(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!f&&e.mode&1)for(G=e,f=e.child;f!==null;){for(d=G=f;G!==null;){switch(h=G,p=h.child,h.tag){case 0:case 11:case 14:case 15:Vs(4,h,h.return);break;case 1:$r(h,h.return);var g=h.stateNode;if(typeof g.componentWillUnmount=="function"){r=h,n=h.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(v){Ae(r,n,v)}}break;case 5:$r(h,h.return);break;case 22:if(h.memoizedState!==null){lh(d);continue}}p!==null?(p.return=h,G=p):lh(d)}f=f.sibling}e:for(f=null,d=e;;){if(d.tag===5){if(f===null){f=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=tg("display",o))}catch(v){Ae(e,e.return,v)}}}else if(d.tag===6){if(f===null)try{d.stateNode.nodeValue=u?"":d.memoizedProps}catch(v){Ae(e,e.return,v)}}else if((d.tag!==22&&d.tag!==23||d.memoizedState===null||d===e)&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===e)break e;for(;d.sibling===null;){if(d.return===null||d.return===e)break e;f===d&&(f=null),d=d.return}f===d&&(f=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:Dt(t,e),Kt(e),r&4&&oh(e);break;case 21:break;default:Dt(t,e),Kt(e)}}function Kt(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Ty(n)){var r=n;break e}n=n.return}throw Error($(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(ri(s,""),r.flags&=-33);var i=ih(e);Ou(e,i,s);break;case 3:case 4:var o=r.stateNode.containerInfo,a=ih(e);Lu(e,a,o);break;default:throw Error($(161))}}catch(l){Ae(e,e.return,l)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function cC(e,t,n){G=e,Py(e)}function Py(e,t,n){for(var r=(e.mode&1)!==0;G!==null;){var s=G,i=s.child;if(s.tag===22&&r){var o=s.memoizedState!==null||Qi;if(!o){var a=s.alternate,l=a!==null&&a.memoizedState!==null||Qe;a=Qi;var u=Qe;if(Qi=o,(Qe=l)&&!u)for(G=s;G!==null;)o=G,l=o.child,o.tag===22&&o.memoizedState!==null?uh(s):l!==null?(l.return=o,G=l):uh(s);for(;i!==null;)G=i,Py(i),i=i.sibling;G=s,Qi=a,Qe=u}ah(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,G=i):ah(e)}}function ah(e){for(;G!==null;){var t=G;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Qe||Ta(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Qe)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Lt(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Wf(t,i,r);break;case 3:var o=t.updateQueue;if(o!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}Wf(t,o,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var l=t.memoizedProps;switch(t.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(t.memoizedState===null){var u=t.alternate;if(u!==null){var f=u.memoizedState;if(f!==null){var d=f.dehydrated;d!==null&&ai(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error($(163))}Qe||t.flags&512&&Du(t)}catch(h){Ae(t,t.return,h)}}if(t===e){G=null;break}if(n=t.sibling,n!==null){n.return=t.return,G=n;break}G=t.return}}function lh(e){for(;G!==null;){var t=G;if(t===e){G=null;break}var n=t.sibling;if(n!==null){n.return=t.return,G=n;break}G=t.return}}function uh(e){for(;G!==null;){var t=G;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Ta(4,t)}catch(l){Ae(t,n,l)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(l){Ae(t,s,l)}}var i=t.return;try{Du(t)}catch(l){Ae(t,i,l)}break;case 5:var o=t.return;try{Du(t)}catch(l){Ae(t,o,l)}}}catch(l){Ae(t,t.return,l)}if(t===e){G=null;break}var a=t.sibling;if(a!==null){a.return=t.return,G=a;break}G=t.return}}var dC=Math.ceil,Go=xn.ReactCurrentDispatcher,ed=xn.ReactCurrentOwner,Pt=xn.ReactCurrentBatchConfig,he=0,Ue=null,Le=null,We=0,vt=0,Ur=Kn(0),Be=0,vi=null,fr=0,Ia=0,td=0,Hs=null,lt=null,nd=0,rs=1/0,un=null,Qo=!1,zu=null,On=null,Yi=!1,An=null,Yo=0,Ws=0,Fu=null,wo=-1,bo=0;function rt(){return he&6?je():wo!==-1?wo:wo=je()}function zn(e){return e.mode&1?he&2&&We!==0?We&-We:Gk.transition!==null?(bo===0&&(bo=pg()),bo):(e=me,e!==0||(e=window.event,e=e===void 0?16:bg(e.type)),e):1}function $t(e,t,n,r){if(50<Ws)throw Ws=0,Fu=null,Error($(185));Ii(e,n,r),(!(he&2)||e!==Ue)&&(e===Ue&&(!(he&2)&&(Ia|=n),Be===4&&In(e,We)),pt(e,r),n===1&&he===0&&!(t.mode&1)&&(rs=je()+500,Ca&&Gn()))}function pt(e,t){var n=e.callbackNode;GS(e,t);var r=No(e,e===Ue?We:0);if(r===0)n!==null&&vf(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&vf(n),t===1)e.tag===0?Kk(ch.bind(null,e)):Bg(ch.bind(null,e)),Vk(function(){!(he&6)&&Gn()}),n=null;else{switch(mg(r)){case 1:n=Ic;break;case 4:n=fg;break;case 16:n=jo;break;case 536870912:n=hg;break;default:n=jo}n=zy(n,Ay.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function Ay(e,t){if(wo=-1,bo=0,he&6)throw Error($(327));var n=e.callbackNode;if(Gr()&&e.callbackNode!==n)return null;var r=No(e,e===Ue?We:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Jo(e,r);else{t=r;var s=he;he|=2;var i=Ny();(Ue!==e||We!==t)&&(un=null,rs=je()+500,ir(e,t));do try{pC();break}catch(a){jy(e,a)}while(!0);$c(),Go.current=i,he=s,Le!==null?t=0:(Ue=null,We=0,t=Be)}if(t!==0){if(t===2&&(s=fu(e),s!==0&&(r=s,t=Bu(e,s))),t===1)throw n=vi,ir(e,0),In(e,r),pt(e,je()),n;if(t===6)In(e,r);else{if(s=e.current.alternate,!(r&30)&&!fC(s)&&(t=Jo(e,r),t===2&&(i=fu(e),i!==0&&(r=i,t=Bu(e,i))),t===1))throw n=vi,ir(e,0),In(e,r),pt(e,je()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error($(345));case 2:er(e,lt,un);break;case 3:if(In(e,r),(r&130023424)===r&&(t=nd+500-je(),10<t)){if(No(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){rt(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=wu(er.bind(null,e,lt,un),t);break}er(e,lt,un);break;case 4:if(In(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var o=31-Bt(r);i=1<<o,o=t[o],o>s&&(s=o),r&=~i}if(r=s,r=je()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*dC(r/1960))-r,10<r){e.timeoutHandle=wu(er.bind(null,e,lt,un),r);break}er(e,lt,un);break;case 5:er(e,lt,un);break;default:throw Error($(329))}}}return pt(e,je()),e.callbackNode===n?Ay.bind(null,e):null}function Bu(e,t){var n=Hs;return e.current.memoizedState.isDehydrated&&(ir(e,t).flags|=256),e=Jo(e,t),e!==2&&(t=lt,lt=n,t!==null&&$u(t)),e}function $u(e){lt===null?lt=e:lt.push.apply(lt,e)}function fC(e){for(var t=e;;){if(t.flags&16384){var n=t.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(!Vt(i(),s))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function In(e,t){for(t&=~td,t&=~Ia,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Bt(t),r=1<<n;e[n]=-1,t&=~r}}function ch(e){if(he&6)throw Error($(327));Gr();var t=No(e,0);if(!(t&1))return pt(e,je()),null;var n=Jo(e,t);if(e.tag!==0&&n===2){var r=fu(e);r!==0&&(t=r,n=Bu(e,r))}if(n===1)throw n=vi,ir(e,0),In(e,t),pt(e,je()),n;if(n===6)throw Error($(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,er(e,lt,un),pt(e,je()),null}function rd(e,t){var n=he;he|=1;try{return e(t)}finally{he=n,he===0&&(rs=je()+500,Ca&&Gn())}}function hr(e){An!==null&&An.tag===0&&!(he&6)&&Gr();var t=he;he|=1;var n=Pt.transition,r=me;try{if(Pt.transition=null,me=1,e)return e()}finally{me=r,Pt.transition=n,he=t,!(he&6)&&Gn()}}function sd(){vt=Ur.current,ke(Ur)}function ir(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Uk(n)),Le!==null)for(n=Le.return;n!==null;){var r=n;switch(zc(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&zo();break;case 3:ts(),ke(ft),ke(Xe),Kc();break;case 5:qc(r);break;case 4:ts();break;case 13:ke(Ee);break;case 19:ke(Ee);break;case 10:Uc(r.type._context);break;case 22:case 23:sd()}n=n.return}if(Ue=e,Le=e=Fn(e.current,null),We=vt=t,Be=0,vi=null,td=Ia=fr=0,lt=Hs=null,rr!==null){for(t=0;t<rr.length;t++)if(n=rr[t],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}rr=null}return e}function jy(e,t){do{var n=Le;try{if($c(),yo.current=Ko,qo){for(var r=Ie.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}qo=!1}if(dr=0,$e=Fe=Ie=null,Us=!1,mi=0,ed.current=null,n===null||n.return===null){Be=1,vi=t,Le=null;break}e:{var i=e,o=n.return,a=n,l=t;if(t=We,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var u=l,f=a,d=f.tag;if(!(f.mode&1)&&(d===0||d===11||d===15)){var h=f.alternate;h?(f.updateQueue=h.updateQueue,f.memoizedState=h.memoizedState,f.lanes=h.lanes):(f.updateQueue=null,f.memoizedState=null)}var p=Jf(o);if(p!==null){p.flags&=-257,Xf(p,o,a,i,t),p.mode&1&&Yf(i,u,t),t=p,l=u;var g=t.updateQueue;if(g===null){var v=new Set;v.add(l),t.updateQueue=v}else g.add(l);break e}else{if(!(t&1)){Yf(i,u,t),id();break e}l=Error($(426))}}else if(Ce&&a.mode&1){var S=Jf(o);if(S!==null){!(S.flags&65536)&&(S.flags|=256),Xf(S,o,a,i,t),Fc(ns(l,a));break e}}i=l=ns(l,a),Be!==4&&(Be=2),Hs===null?Hs=[i]:Hs.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=my(i,l,t);Hf(i,y);break e;case 1:a=l;var x=i.type,w=i.stateNode;if(!(i.flags&128)&&(typeof x.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(On===null||!On.has(w)))){i.flags|=65536,t&=-t,i.lanes|=t;var E=gy(i,a,t);Hf(i,E);break e}}i=i.return}while(i!==null)}Dy(n)}catch(I){t=I,Le===n&&n!==null&&(Le=n=n.return);continue}break}while(!0)}function Ny(){var e=Go.current;return Go.current=Ko,e===null?Ko:e}function id(){(Be===0||Be===3||Be===2)&&(Be=4),Ue===null||!(fr&268435455)&&!(Ia&268435455)||In(Ue,We)}function Jo(e,t){var n=he;he|=2;var r=Ny();(Ue!==e||We!==t)&&(un=null,ir(e,t));do try{hC();break}catch(s){jy(e,s)}while(!0);if($c(),he=n,Go.current=r,Le!==null)throw Error($(261));return Ue=null,We=0,Be}function hC(){for(;Le!==null;)My(Le)}function pC(){for(;Le!==null&&!FS();)My(Le)}function My(e){var t=Oy(e.alternate,e,vt);e.memoizedProps=e.pendingProps,t===null?Dy(e):Le=t,ed.current=null}function Dy(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=aC(n,t),n!==null){n.flags&=32767,Le=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Be=6,Le=null;return}}else if(n=oC(n,t,vt),n!==null){Le=n;return}if(t=t.sibling,t!==null){Le=t;return}Le=t=e}while(t!==null);Be===0&&(Be=5)}function er(e,t,n){var r=me,s=Pt.transition;try{Pt.transition=null,me=1,mC(e,t,n,r)}finally{Pt.transition=s,me=r}return null}function mC(e,t,n,r){do Gr();while(An!==null);if(he&6)throw Error($(327));n=e.finishedWork;var s=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error($(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(QS(e,i),e===Ue&&(Le=Ue=null,We=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Yi||(Yi=!0,zy(jo,function(){return Gr(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=Pt.transition,Pt.transition=null;var o=me;me=1;var a=he;he|=4,ed.current=null,uC(e,n),Ry(n,e),Dk(vu),Mo=!!yu,vu=yu=null,e.current=n,cC(n),BS(),he=a,me=o,Pt.transition=i}else e.current=n;if(Yi&&(Yi=!1,An=e,Yo=s),i=e.pendingLanes,i===0&&(On=null),VS(n.stateNode),pt(e,je()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)s=t[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(Qo)throw Qo=!1,e=zu,zu=null,e;return Yo&1&&e.tag!==0&&Gr(),i=e.pendingLanes,i&1?e===Fu?Ws++:(Ws=0,Fu=e):Ws=0,Gn(),null}function Gr(){if(An!==null){var e=mg(Yo),t=Pt.transition,n=me;try{if(Pt.transition=null,me=16>e?16:e,An===null)var r=!1;else{if(e=An,An=null,Yo=0,he&6)throw Error($(331));var s=he;for(he|=4,G=e.current;G!==null;){var i=G,o=i.child;if(G.flags&16){var a=i.deletions;if(a!==null){for(var l=0;l<a.length;l++){var u=a[l];for(G=u;G!==null;){var f=G;switch(f.tag){case 0:case 11:case 15:Vs(8,f,i)}var d=f.child;if(d!==null)d.return=f,G=d;else for(;G!==null;){f=G;var h=f.sibling,p=f.return;if(Ey(f),f===u){G=null;break}if(h!==null){h.return=p,G=h;break}G=p}}}var g=i.alternate;if(g!==null){var v=g.child;if(v!==null){g.child=null;do{var S=v.sibling;v.sibling=null,v=S}while(v!==null)}}G=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,G=o;else e:for(;G!==null;){if(i=G,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Vs(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,G=y;break e}G=i.return}}var x=e.current;for(G=x;G!==null;){o=G;var w=o.child;if(o.subtreeFlags&2064&&w!==null)w.return=o,G=w;else e:for(o=x;G!==null;){if(a=G,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:Ta(9,a)}}catch(I){Ae(a,a.return,I)}if(a===o){G=null;break e}var E=a.sibling;if(E!==null){E.return=a.return,G=E;break e}G=a.return}}if(he=s,Gn(),Zt&&typeof Zt.onPostCommitFiberRoot=="function")try{Zt.onPostCommitFiberRoot(xa,e)}catch{}r=!0}return r}finally{me=n,Pt.transition=t}}return!1}function dh(e,t,n){t=ns(n,t),t=my(e,t,1),e=Ln(e,t,1),t=rt(),e!==null&&(Ii(e,1,t),pt(e,t))}function Ae(e,t,n){if(e.tag===3)dh(e,e,n);else for(;t!==null;){if(t.tag===3){dh(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(On===null||!On.has(r))){e=ns(n,e),e=gy(t,e,1),t=Ln(t,e,1),e=rt(),t!==null&&(Ii(t,1,e),pt(t,e));break}}t=t.return}}function gC(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=rt(),e.pingedLanes|=e.suspendedLanes&n,Ue===e&&(We&n)===n&&(Be===4||Be===3&&(We&130023424)===We&&500>je()-nd?ir(e,0):td|=n),pt(e,t)}function Ly(e,t){t===0&&(e.mode&1?(t=Bi,Bi<<=1,!(Bi&130023424)&&(Bi=4194304)):t=1);var n=rt();e=yn(e,t),e!==null&&(Ii(e,t,n),pt(e,n))}function yC(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ly(e,n)}function vC(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error($(314))}r!==null&&r.delete(t),Ly(e,n)}var Oy;Oy=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ft.current)ct=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ct=!1,iC(e,t,n);ct=!!(e.flags&131072)}else ct=!1,Ce&&t.flags&1048576&&$g(t,$o,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;xo(e,t),e=t.pendingProps;var s=Xr(t,Xe.current);Kr(t,n),s=Qc(null,t,r,e,s,n);var i=Yc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ht(r)?(i=!0,Fo(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Hc(t),s.updater=Ea,t.stateNode=s,s._reactInternals=t,Tu(t,r,e,n),t=Pu(null,t,r,!0,i,n)):(t.tag=0,Ce&&i&&Oc(t),tt(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(xo(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=wC(r),e=Lt(r,e),s){case 0:t=Ru(null,t,r,e,n);break e;case 1:t=th(null,t,r,e,n);break e;case 11:t=Zf(null,t,r,e,n);break e;case 14:t=eh(null,t,r,Lt(r.type,e),n);break e}throw Error($(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Lt(r,s),Ru(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Lt(r,s),th(e,t,r,s,n);case 3:e:{if(wy(t),e===null)throw Error($(387));r=t.pendingProps,i=t.memoizedState,s=i.element,Kg(e,t),Ho(t,r,null,n);var o=t.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=ns(Error($(423)),t),t=nh(e,t,r,n,s);break e}else if(r!==s){s=ns(Error($(424)),t),t=nh(e,t,r,n,s);break e}else for(xt=Dn(t.stateNode.containerInfo.firstChild),wt=t,Ce=!0,zt=null,n=Wg(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Zr(),r===s){t=vn(e,t,n);break e}tt(e,t,r,n)}t=t.child}return t;case 5:return Gg(t),e===null&&Cu(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,o=s.children,xu(r,s)?o=null:i!==null&&xu(r,i)&&(t.flags|=32),xy(e,t),tt(e,t,o,n),t.child;case 6:return e===null&&Cu(t),null;case 13:return by(e,t,n);case 4:return Wc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=es(t,null,r,n):tt(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Lt(r,s),Zf(e,t,r,s,n);case 7:return tt(e,t,t.pendingProps,n),t.child;case 8:return tt(e,t,t.pendingProps.children,n),t.child;case 12:return tt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,o=s.value,we(Uo,r._currentValue),r._currentValue=o,i!==null)if(Vt(i.value,o)){if(i.children===s.children&&!ft.current){t=vn(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);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 f=u.pending;f===null?l.next=l:(l.next=f.next,f.next=l),u.pending=l}}i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),_u(i.return,n,t),a.lanes|=n;break}l=l.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error($(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),_u(o,n,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}tt(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Kr(t,n),s=jt(s),r=r(s),t.flags|=1,tt(e,t,r,n),t.child;case 14:return r=t.type,s=Lt(r,t.pendingProps),s=Lt(r.type,s),eh(e,t,r,s,n);case 15:return yy(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Lt(r,s),xo(e,t),t.tag=1,ht(r)?(e=!0,Fo(t)):e=!1,Kr(t,n),py(t,r,s),Tu(t,r,s,n),Pu(null,t,r,!0,e,n);case 19:return Sy(e,t,n);case 22:return vy(e,t,n)}throw Error($(156,t.tag))};function zy(e,t){return dg(e,t)}function xC(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,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 Rt(e,t,n,r){return new xC(e,t,n,r)}function od(e){return e=e.prototype,!(!e||!e.isReactComponent)}function wC(e){if(typeof e=="function")return od(e)?1:0;if(e!=null){if(e=e.$$typeof,e===_c)return 11;if(e===Ec)return 14}return 2}function Fn(e,t){var n=e.alternate;return n===null?(n=Rt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function So(e,t,n,r,s,i){var o=2;if(r=e,typeof e=="function")od(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case jr:return or(n.children,s,i,t);case Cc:o=8,s|=8;break;case Jl:return e=Rt(12,n,t,s|2),e.elementType=Jl,e.lanes=i,e;case Xl:return e=Rt(13,n,t,s),e.elementType=Xl,e.lanes=i,e;case Zl:return e=Rt(19,n,t,s),e.elementType=Zl,e.lanes=i,e;case Gm:return Ra(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case qm:o=10;break e;case Km:o=9;break e;case _c:o=11;break e;case Ec:o=14;break e;case Cn:o=16,r=null;break e}throw Error($(130,e==null?e:typeof e,""))}return t=Rt(o,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function or(e,t,n,r){return e=Rt(7,e,r,t),e.lanes=n,e}function Ra(e,t,n,r){return e=Rt(22,e,r,t),e.elementType=Gm,e.lanes=n,e.stateNode={isHidden:!1},e}function Sl(e,t,n){return e=Rt(6,e,null,t),e.lanes=n,e}function kl(e,t,n){return t=Rt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function bC(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=rl(0),this.expirationTimes=rl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rl(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function ad(e,t,n,r,s,i,o,a,l){return e=new bC(e,t,n,a,l),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Rt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Hc(i),e}function SC(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Ar,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function Fy(e){if(!e)return Un;e=e._reactInternals;e:{if(vr(e)!==e||e.tag!==1)throw Error($(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(ht(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error($(171))}if(e.tag===1){var n=e.type;if(ht(n))return Fg(e,n,t)}return t}function By(e,t,n,r,s,i,o,a,l){return e=ad(n,r,!0,e,s,i,o,a,l),e.context=Fy(null),n=e.current,r=rt(),s=zn(n),i=pn(r,s),i.callback=t??null,Ln(n,i,s),e.current.lanes=s,Ii(e,s,r),pt(e,r),e}function Pa(e,t,n,r){var s=t.current,i=rt(),o=zn(s);return n=Fy(n),t.context===null?t.context=n:t.pendingContext=n,t=pn(i,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Ln(s,t,o),e!==null&&($t(e,s,o,i),go(e,s,o)),o}function Xo(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function fh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ld(e,t){fh(e,t),(e=e.alternate)&&fh(e,t)}function kC(){return null}var $y=typeof reportError=="function"?reportError:function(e){console.error(e)};function ud(e){this._internalRoot=e}Aa.prototype.render=ud.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error($(409));Pa(e,t,null,null)};Aa.prototype.unmount=ud.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;hr(function(){Pa(null,e,null,null)}),t[gn]=null}};function Aa(e){this._internalRoot=e}Aa.prototype.unstable_scheduleHydration=function(e){if(e){var t=vg();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Tn.length&&t!==0&&t<Tn[n].priority;n++);Tn.splice(n,0,e),n===0&&wg(e)}};function cd(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ja(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function hh(){}function CC(e,t,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var u=Xo(o);i.call(u)}}var o=By(t,r,e,0,null,!1,!1,"",hh);return e._reactRootContainer=o,e[gn]=o.current,ci(e.nodeType===8?e.parentNode:e),hr(),o}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var a=r;r=function(){var u=Xo(l);a.call(u)}}var l=ad(e,0,!1,null,null,!1,!1,"",hh);return e._reactRootContainer=l,e[gn]=l.current,ci(e.nodeType===8?e.parentNode:e),hr(function(){Pa(t,l,n,r)}),l}function Na(e,t,n,r,s){var i=n._reactRootContainer;if(i){var o=i;if(typeof s=="function"){var a=s;s=function(){var l=Xo(o);a.call(l)}}Pa(t,o,e,s)}else o=CC(n,t,e,s,r);return Xo(o)}gg=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Ds(t.pendingLanes);n!==0&&(Rc(t,n|1),pt(t,je()),!(he&6)&&(rs=je()+500,Gn()))}break;case 13:hr(function(){var r=yn(e,1);if(r!==null){var s=rt();$t(r,e,1,s)}}),ld(e,1)}};Pc=function(e){if(e.tag===13){var t=yn(e,134217728);if(t!==null){var n=rt();$t(t,e,134217728,n)}ld(e,134217728)}};yg=function(e){if(e.tag===13){var t=zn(e),n=yn(e,t);if(n!==null){var r=rt();$t(n,e,t,r)}ld(e,t)}};vg=function(){return me};xg=function(e,t){var n=me;try{return me=e,t()}finally{me=n}};uu=function(e,t,n){switch(t){case"input":if(nu(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var s=ka(r);if(!s)throw Error($(90));Ym(r),nu(r,s)}}}break;case"textarea":Xm(e,n);break;case"select":t=n.value,t!=null&&Vr(e,!!n.multiple,t,!1)}};ig=rd;og=hr;var _C={usingClientEntryPoint:!1,Events:[Pi,Lr,ka,rg,sg,rd]},Rs={findFiberByHostInstance:nr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},EC={bundleType:Rs.bundleType,version:Rs.version,rendererPackageName:Rs.rendererPackageName,rendererConfig:Rs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:xn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=ug(e),e===null?null:e.stateNode},findFiberByHostInstance:Rs.findFiberByHostInstance||kC,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 Ji=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ji.isDisabled&&Ji.supportsFiber)try{xa=Ji.inject(EC),Zt=Ji}catch{}}Ct.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=_C;Ct.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!cd(t))throw Error($(200));return SC(e,t,null,n)};Ct.createRoot=function(e,t){if(!cd(e))throw Error($(299));var n=!1,r="",s=$y;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=ad(e,1,!1,null,null,n,!1,r,s),e[gn]=t.current,ci(e.nodeType===8?e.parentNode:e),new ud(t)};Ct.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error($(188)):(e=Object.keys(e).join(","),Error($(268,e)));return e=ug(t),e=e===null?null:e.stateNode,e};Ct.flushSync=function(e){return hr(e)};Ct.hydrate=function(e,t,n){if(!ja(t))throw Error($(200));return Na(null,e,t,!0,n)};Ct.hydrateRoot=function(e,t,n){if(!cd(e))throw Error($(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",o=$y;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=By(t,null,e,1,n??null,s,!1,i,o),e[gn]=t.current,ci(e),r)for(e=0;e<r.length;e++)n=r[e],s=n._getVersion,s=s(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,s]:t.mutableSourceEagerHydrationData.push(n,s);return new Aa(t)};Ct.render=function(e,t,n){if(!ja(t))throw Error($(200));return Na(null,e,t,!1,n)};Ct.unmountComponentAtNode=function(e){if(!ja(e))throw Error($(40));return e._reactRootContainer?(hr(function(){Na(null,null,e,!1,function(){e._reactRootContainer=null,e[gn]=null})}),!0):!1};Ct.unstable_batchedUpdates=rd;Ct.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!ja(n))throw Error($(200));if(e==null||e._reactInternals===void 0)throw Error($(38));return Na(e,t,n,!1,r)};Ct.version="18.3.1-next-f1338f8080-20240426";function Uy(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Uy)}catch(e){console.error(e)}}Uy(),Um.exports=Ct;var TC=Um.exports,Vy,ph=TC;Vy=ph.createRoot,ph.hydrateRoot;function IC(e,t){const n=e[Hy];if(!n)throw new Error("ResourceElement.type is not a valid Resource");return n(t)}const Hy=Symbol("fnSymbol");function ce(e){const t=n=>({type:t,props:n});return t[Hy]=e,t}function rn(e,t){return{...t,key:e}}let qs=null;function RC(e,t){e.currentIndex=0;const n=qs;qs=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw new Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{qs=n}}function Vn(){if(!qs)throw new Error("No resource fiber available");return qs}function PC(e){return null}const Wy=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],dirtyCells:[]}),Zo=e=>{for(const t of e.dirtyCells)t.dirty=!1,t.queue.clear(),t.current=t.workInProgress;e.committedVersion=e.version,e.changelog.length=0,e.dirtyCells.length=0},Ks=(e,t)=>{const n=e.version>t;if(e.version=t,n){for(const r of e.dirtyCells)r.dirty=!1,r.queue.clear(),r.workInProgress=r.current;if(e.dirtyCells.length=0,t===e.committedVersion)e.changelog.length=0;else{if(e.committedVersion>t)throw new Error("Version is less than committed version");for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop();e.changelog.forEach(r=>r()),Zo(e)}}},mh=(e,t)=>{t.dirty||(t.dirty=!0,e.markDirty?.(),e.root.dirtyCells.push(t))},qy=(e,t)=>{const n=Vn(),r=n.currentIndex++;if(!n.isFirstRender&&r>=n.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");let s=n.cells[r];if(s||(s=t(),n.cells[r]=s),s.type!==e)throw new Error("Hook order changed between renders");return s},AC=e=>{Vn().renderContext.effectTasks.push(e)},jC=(e,t)=>{if(e.renderContext)throw new Error("Resource updated during render");if(e.isNeverMounted)throw new Error("Resource updated before mount");e.root.dispatchUpdate(()=>{const n=t();return n?(n(),e.root.changelog.push(n),!0):!1})};function Ky(e,t,n,r){const s=qy("reducer",()=>{const a=Vn(),l=r?r(n):n;return{type:"reducer",queue:new Set,dirty:!1,workInProgress:l,current:l,reducer:e,dispatch:u=>{const f={action:u,hasEagerState:!1,eagerState:void 0};jC(a,()=>a.root.dirtyCells.length===0&&!f.hasEagerState&&(f.eagerState=e(s.workInProgress,u),f.hasEagerState=!0,Object.is(s.current,f.eagerState))?null:()=>{mh(a,s),s.queue.add(f)})}}}),i=Vn(),o=e===s.reducer;s.reducer=e;for(const a of s.queue)(!a.hasEagerState||!o)&&(a.eagerState=e(s.workInProgress,a.action),a.hasEagerState=!0),s.workInProgress=a.eagerState;if(s.queue.clear(),t){const a=t(s.workInProgress);Object.is(a,s.workInProgress)||(mh(i,s),s.workInProgress=a)}return[s.workInProgress,s.dispatch]}function NC(e,t,n){return Ky(e,void 0,t,n)}function MC(e,t,n,r){return Ky(e,t,n,r)}const DC=(e,t)=>typeof t=="function"?t(e):t,LC=e=>typeof e=="function"?e():e;function kt(e){return NC(DC,e,LC)}const Gy=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},OC=()=>({type:"effect",cleanup:void 0,deps:null});function Ne(e,t){const n=qy("effect",OC);if(!(t&&n.deps&&Gy(n.deps,t))){if(n.deps!==null&&!!t!=!!n.deps)throw new Error("tapEffect called with and without dependencies across re-renders");AC(()=>{const r=[];try{n.cleanup?.()}catch(s){r.push(s)}finally{n.cleanup=void 0}try{const s=e();if(s!==void 0&&typeof s!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof s}`);n.cleanup=s}catch(s){r.push(s)}if(n.deps=t,r.length>0){if(r.length===1)throw r[0];for(const s of r)console.error(s);throw new AggregateError(r,"Errors during commit")}})}}function tn(e){const[t]=kt(()=>({current:e}));return t}function ar(e,t){const[n]=kt(e);return n}const zC=()=>{throw new Error("Memo reducer should not be called")},ie=(e,t)=>{Vn();const[n]=MC(zC,r=>r&&Gy(r.deps,t)?r:{value:e(),deps:t},null);return n.value},xi=(e,t)=>ie(()=>e,t);function nn(e){const t=tn(e);Ne(()=>{t.current=e});const n=Vn();return xi((...r)=>t.current(...r),[n])}function FC(e){const t=[];for(const n of e.effectTasks)try{n()}catch(r){t.push(r)}if(t.length>0){if(t.length===1)throw t[0];for(const n of t)console.error(n);throw new AggregateError(t,"Errors during commit")}}function BC(e){const t=[];for(const n of e.cells)if(n?.type==="effect"&&(n.deps=null,n.cleanup))try{n.cleanup?.()}catch(r){t.push(r)}finally{n.cleanup=void 0}if(t.length>0){if(t.length===1)throw t[0];for(const n of t)console.error(n);throw new AggregateError(t,"Errors during cleanup")}}function wi(e,t,n=void 0,r=PC()){return{type:e,root:t,markDirty:n,devStrictMode:r,cells:[],currentIndex:0,renderContext:void 0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function Qr(e){if(!e.isMounted)throw new Error("Tried to unmount a fiber that is already unmounted");e.isMounted=!1,BC(e)}function Bn(e,t){const n={effectTasks:[],props:t,output:void 0};return RC(e,()=>{e.renderContext=n;try{n.output=IC(e.type,t)}finally{e.renderContext=void 0}}),n}function ss(e,t){e.isMounted=!0,e.isNeverMounted=!1,FC(t)}function He(e,t){const n=Vn(),r=tn(0),s=ie(()=>(e.key,wi(e.type,n.root,()=>{r.current++,n.markDirty?.()})),[e.type,e.key,n]),i=t?ie(()=>Bn(s,e.props),[s,...t,r.current]):Bn(s,e.props);return Ne(()=>()=>Qr(s),[s]),Ne(()=>{ss(s,i)},[s,i]),i.output}function Ma(e,t){const n=tn(0),r=n.current,s=ar(Vn),i=ar(()=>()=>{n.current++,s.markDirty?.()}),o=ar(()=>new Map),a=t?xi(e,t):e,l=ie(()=>{const u=a(),f=new Set,d=[];let h=0;for(let p=0;p<u.length;p++){const g=u[p],v=g.key;if(v===void 0)throw new Error(`tapResources did not provide a key for array at index ${p}`);if(f.has(v))throw new Error(`Duplicate key ${v} in tapResources`);f.add(v);let S=o.get(v);if(S)if(S.fiber.type!==g.type){const y=wi(g.type,s.root,i),x=Bn(y,g.props);S.next=[y,x],d.push(x.output)}else S.next=Bn(S.fiber,g.props),d.push(S.next.output);else{const y=wi(g.type,s.root,i),x=Bn(y,g.props);S={fiber:y,next:x},h++,o.set(v,S),d.push(x.output)}}if(o.size>d.length-h)for(const p of o.keys())f.has(p)||(o.get(p).next="delete");return d},[a,r]);return Ne(()=>()=>{for(const u of o.keys()){const f=o.get(u).fiber;Qr(f)}},[]),Ne(()=>{for(const[u,f]of o.entries())f.next==="delete"?(f.fiber.isMounted&&Qr(f.fiber),o.delete(u)):Array.isArray(f.next)?(Qr(f.fiber),f.fiber=f.next[0],ss(f.fiber,f.next[1])):ss(f.fiber,f.next)},[l]),l}const $C=50;let Xt={schedulers:new Set([]),isScheduled:!1};var UC=class{constructor(e){T(this,"_task");T(this,"_isDirty",!1);this._task=e}get isDirty(){return this._isDirty}markDirty(){this._isDirty=!0,Xt.schedulers.add(this),VC()}runTask(){this._isDirty=!1,this._task()}};const VC=()=>{Xt.isScheduled||(Xt.isScheduled=!0,HC())},Uu=()=>{try{const e=[];let t=0;for(const n of Xt.schedulers)if(Xt.schedulers.delete(n),!!n.isDirty){if(t++,t>$C)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside tapEffect.");try{n.runTask()}catch(r){e.push(r)}}if(e.length>0){if(e.length===1)throw e[0];for(const n of e)console.error(n);throw new AggregateError(e,"Errors occurred during flushSync")}}finally{Xt.schedulers.clear(),Xt.isScheduled=!1}},HC=(()=>{if(typeof MessageChannel<"u"){const e=new MessageChannel;return e.port1.onmessage=Uu,()=>e.port2.postMessage(null)}return()=>setTimeout(Uu,0)})(),gh=e=>{const t=Xt;Xt={schedulers:new Set([]),isScheduled:!0};try{const n=e();return Uu(),n}finally{Xt=t}},WC=e=>{const t=ar(()=>new UC(()=>u(null))),n=ar(()=>[]),r=ie(()=>(e.key,wi(e.type,Wy(f=>{!t.isDirty&&!f()||(n.push(f),t.markDirty())}))),[e.type,e.key]);Ks(r.root,r.root.committedVersion);const s=Bn(r,e.props),i=tn(!1),o=tn(e.props),a=tn(s.output),l=ar(()=>new Set),u=nn(f=>{if(f===null&&(Ks(r.root,2),Ks(r.root,1),n.forEach(d=>{d()}),f=Bn(r,o.current)),t.isDirty)throw new Error("Scheduler is dirty, this should never happen");Zo(r.root),n.length=0,i.current&&ss(r,f),!(t.isDirty||a.current===f.output)&&(a.current=f.output,l.forEach(d=>d()))});return Ne(()=>(i.current=!0,()=>{i.current=!1,Qr(r)}),[r]),Ne(()=>{o.current=s.props,Zo(r.root),ss(r,s),!(t.isDirty||a.current===s.output)&&(a.current=s.output,l.forEach(f=>f()))}),ie(()=>({getValue:()=>a.current,subscribe:f=>(l.add(f),()=>l.delete(f))}),[])},Gs=Symbol("tap.Context"),Qy=e=>({[Gs]:e}),Yy=(e,t,n)=>{const r=e[Gs];e[Gs]=t;try{return n()}finally{e[Gs]=r}},Jy=e=>e[Gs],qC=ce(()=>{const[e,t]=kt(()=>({renderers:{},fallbacks:[]}));return{getState:()=>e,setDataUI:xi((n,r)=>(t(s=>({...s,renderers:{...s.renderers,[n]:[...s.renderers[n]??[],r]}})),()=>{t(s=>({...s,renderers:{...s.renderers,[n]:s.renderers[n]?.filter(i=>i!==r)??[]}}))}),[]),setFallbackDataUI:xi(n=>(t(r=>({...r,fallbacks:[...r.fallbacks,n]})),()=>{t(r=>({...r,fallbacks:r.fallbacks.filter(s=>s!==n)}))}),[])}}),KC=e=>{const t=Array.from(e).map(r=>r.getModelContext()).sort((r,s)=>(s.priority??0)-(r.priority??0)),n={};return t.reduce((r,s)=>{const i=s.priority??0;if(s.system&&(r.system?r.system+=`
|
|
41
41
|
|
|
42
|
-
${s.system}`:r.system=s.system),s.tools)for(const[o,a]of Object.entries(s.tools)){const l=r.tools?.[o];if(l&&l!==a){const u=n[o];if(u===i)throw new Error(`You tried to define a tool with the name ${o}, but it already exists.`);const f=u>i?l:a,d=u>i?a:l;r.tools[o]={...d,...f},n[o]=Math.max(u,i);continue}r.tools||(r.tools={}),r.tools[o]=a,n[o]??(n[o]=i)}return s.config&&(r.config={...r.config,...s.config}),s.callSettings&&(r.callSettings={...r.callSettings,...s.callSettings}),r},{})};var dd=class{constructor(){T(this,"_providers",new Set);T(this,"_subscribers",new Set)}getModelContext(){return WC(this._providers)}registerModelContextProvider(e){this._providers.add(e);const t=e.subscribe?.(()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(e),t?.(),this.notifySubscribers()}}notifySubscribers(){for(const e of this._subscribers)e()}subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}};const Vu=[],qC={modelName:void 0,toolNames:Vu},KC=(e,t)=>e===t||e.length===t.length&&e.every((n,r)=>n===t[r]),Xi=(e,t)=>{const n=e.getModelContext(),r=n.config?.modelName,s=n.tools?Object.keys(n.tools).sort():Vu,i=s.length?s:Vu;return r===t.modelName&&KC(i,t.toolNames)?t:{modelName:r,toolNames:i}},Jy=ce(()=>{const e=ie(()=>new dd,[]),[t,n]=kt(()=>Xi(e,qC));return je(()=>(n(r=>Xi(e,r)),e.subscribe(()=>{n(r=>Xi(e,r))})),[e]),{getState:()=>Xi(e,t),getModelContext:()=>e.getModelContext(),subscribe:r=>e.subscribe(r),register:r=>e.registerModelContextProvider(r)}}),GC=e=>e.display!==void 0?e.display==="standalone":e.type==="human",QC=(e,t)=>{if(!(t.status?.type==="running"||t.status?.type==="requires-action")){const r=e.complete;return typeof r!="function"?r??null:r({args:t.args,result:t.result})}const n=e.running;return typeof n!="function"?n??null:n({args:t.args})},YC=e=>function(n){return QC(e,n)},Hu=Symbol("assistant-ui.store.clientIndex"),JC=e=>e[Hu],Xy=Gy([]),fd=()=>Yy(Xy),XC=(e,t)=>{const n=fd();return Qy(Xy,ie(()=>[...n,e],[n,e]),t)},ZC=new Set(["$$typeof","nodeType","then"]),Da=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!="symbol"){if(e==="toJSON")return()=>t;if(!ZC.has(e))return!1}};var hd=class{getOwnPropertyDescriptor(e,t){const n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!1}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}};const Zy=e=>{const t=ce(e);return n=>{const r=t(n);return n.key===void 0?r:rn(n.key,r)}},ea=Symbol("assistant-ui.store.getValue"),e0=e=>{const t=e[ea];if(!t)throw new Error("Client scope contains a non-client resource. Ensure your Derived get() returns a client created with tapClientResource(), not a plain resource.");return t.getState?.()},yh=new Map;function t0(e){let t=yh.get(e);return t||(t=function(...n){if(!this||typeof this!="object")throw new Error(`Method "${String(e)}" called without proper context. This may indicate the function was called incorrectly.`);const r=this[ea];if(!r)throw new Error(`Method "${String(e)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);const s=r[e];if(!s)throw new Error(`Method "${String(e)}" is not implemented.`);if(typeof s!="function")throw new Error(`"${String(e)}" is not a function.`);return s(...n)},yh.set(e,t)),t}var n0=class extends hd{constructor(t,n){super();T(this,"outputRef");T(this,"index");T(this,"boundFns");T(this,"cachedReceiver");this.outputRef=t,this.index=n}get(t,n,r){if(n===ea)return this.outputRef.current;if(n===Hu)return this.index;const s=Da(n,"ClientProxy");if(s!==!1)return s;const i=this.outputRef.current[n];if(typeof i=="function"){this.cachedReceiver!==r&&(this.boundFns=new Map,this.cachedReceiver=r);let o=this.boundFns.get(n);return o||(o=t0(n).bind(r),this.boundFns.set(n,o)),o}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(t,n){return n===ea||n===Hu?!0:n in this.outputRef.current}};const ev=Zy(e=>{const t=tn(null),n=fd().length,r=ie(()=>new Proxy({},new n0(t,n)),[n]),s=XC(r,()=>Ve(e));return t.current||(t.current=s),je(()=>{t.current=s}),{methods:r,state:s.getState?.(),key:e.key}}),La=e=>Ve(ev(e)),Qs=Symbol("assistant-ui.store.proxiedAssistantState"),Cl=e=>e==="on"||e==="subscribe"||typeof e=="symbol",tv=e=>{class t extends hd{get(r,s){const i=Da(s,"AssistantState");if(i!==!1)return i;const o=s;if(!Cl(o))return e0(e[o]())}ownKeys(){return Object.keys(e).filter(r=>!Cl(r))}has(r,s){return!Cl(s)&&s in e}}return new Proxy({},new t)},r0=e=>e[Qs],vh=()=>()=>{},nv=e=>{const t=()=>{throw new Error(e)};return t.source=null,t.query=null,t};var s0=class extends hd{get(e,t){if(t==="subscribe"||t==="on")return vh;if(t===Qs)return i0;const n=Da(t,"DefaultAssistantClient");return n!==!1?n:nv("You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.")}ownKeys(){return["subscribe","on",Qs]}has(e,t){return t==="subscribe"||t==="on"||t===Qs}};const Oa=new Proxy({},new s0),i0=tv(Oa),o0=()=>new Proxy({},{get(e,t){const n=Da(t,"AssistantClient");return n!==!1?n:nv(`The current scope does not have a "${String(t)}" property.`)}}),rv=m.createContext(Oa),a0=()=>m.useContext(rv),wn=({value:e,children:t})=>c.jsx(rv.Provider,{value:e,children:t}),At=ce(e=>null),Wu=Symbol("assistant-ui.transform-scopes");function sv(e,t){const n=e;if(n[Wu])throw new Error("transformScopes is already attached to this resource");n[Wu]=t}function l0(e){return e[Wu]}const iv=e=>typeof e=="string"?{scope:e.split(".")[0],event:e}:{scope:e.scope,event:e.event},ov=Gy(null),u0=(e,t)=>Qy(ov,e,t),av=()=>{const e=Yy(ov);if(!e)throw new Error("AssistantTapContext is not available");return e},lv=()=>av().clientRef,pd=()=>{const{emit:e}=av(),t=fd();return nn((n,r)=>{e(n,r,t)})};function c0(e,t){const n={...e},r=new Set;let s=!0;for(;s;){s=!1;for(const a of Object.values(n)){if(a.type===At||r.has(a.type))continue;r.add(a.type);const l=l0(a.type);if(l){l(n,t),s=!0;break}}}const i={},o={};for(const[a,l]of Object.entries(n))l.type===At?o[a]=l:i[a]=l;return{rootClients:i,derivedClients:o}}const xh=e=>ie(()=>e,[...Object.entries(e).flat()]),d0=(e,t)=>{const{rootClients:n,derivedClients:r}=c0(e,t);return{rootClients:xh(n),derivedClients:xh(r)}},f0=ce(()=>ar(()=>{const e=new Map,t=new Set,n=new Set;return{on(r,s){const i=s;if(r==="*")return t.add(i),()=>t.delete(i);let o=e.get(r);return o||(o=new Set,e.set(r,o)),o.add(i),()=>{o.delete(i),o.size===0&&e.delete(r)}},emit(r,s,i){const o=e.get(r);!o&&t.size===0||queueMicrotask(()=>{const a=[];if(o)for(const l of o)try{l(s,i)}catch(u){a.push(u)}if(t.size>0){const l={event:r,payload:s};for(const u of t)try{u(l,i)}catch(f){a.push(f)}}if(a.length>0){if(a.length===1)throw a[0];for(const l of a)console.error(l);throw new AggregateError(a,"Errors occurred during event emission")}})},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)}}}})),h0=()=>null;function uv(e){const t=m.useMemo(()=>Hy(a=>r(a)),[]),[n,r]=m.useReducer((a,l)=>(Ks(t,a),a+(l()?1:0)),0);Ks(t,n);const s=h0(),i=m.useMemo(()=>(e.key,wi(e.type,t,void 0,s)),[e.type,e.key,t,s]),o=Fn(i,e.props);return m.useLayoutEffect(()=>()=>Qr(i),[i]),m.useLayoutEffect(()=>{Zo(t),ss(i,o)}),o.output}const cv=e=>ie(()=>e,e),p0=ce(({element:e,emit:t,clientRef:n})=>{const{methods:r,state:s}=u0({clientRef:n,emit:t},()=>La(e));return ie(()=>({state:s,methods:r}),[r,s])}),m0=ce(({element:e,notifications:t,clientRef:n,name:r})=>{const s=VC(p0({element:e,emit:t.emit,clientRef:n}));return je(()=>s.subscribe(t.notifySubscribers),[s,t]),ie(()=>{const i=()=>s.getValue().methods;return Object.defineProperties(i,{source:{value:"root",writable:!1},query:{value:{},writable:!1},name:{value:r,configurable:!0}}),i},[s,r])}),g0=ce(()=>ie(()=>({clients:[],subscribe:void 0,on:void 0}),[])),y0=ce(({clients:e,clientRef:t})=>{const n=Ve(f0());je(()=>t.parent.subscribe(n.notifySubscribers),[t,n]);const r=cv(Ma(()=>Object.keys(e).map(s=>rn(s,m0({element:e[s],notifications:n,clientRef:t,name:s}))),[e,n,t]));return ie(()=>({clients:r,subscribe:n.subscribe,on:function(s,i){if(!this)throw new Error("const { on } = useAui() is not supported. Use aui.on() instead.");const{scope:o,event:a}=iv(s);if(o!=="*"&&this[o].source===null)throw new Error(`Scope "${o}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);const l=n.on(a,(f,d)=>{if(o==="*"){i(f);return}const h=this[o]();h===d[JC(h)]&&i(f)});if(o!=="*"&&t.parent[o].source===null)return l;const u=t.parent.on(s,i);return()=>{l(),u()}}}),[r,n,t])}),v0=ce(({element:e,clientRef:t,name:n})=>{const r=tn(e.props);return r.current=e.props,ie(()=>{const s=()=>r.current.get(t.current);return Object.defineProperties(s,{source:{value:r.current.source},query:{value:r.current.query},name:{value:n,configurable:!0}}),s},[t,n])}),x0=(e,t)=>{let n;try{const r={};for(const s of Object.keys(t.query).sort())r[s]=t.query[s];n=JSON.stringify(r)}catch{n=String(t.query)}return`${e}::${t.source}::${n}`},w0=ce(({clients:e,clientRef:t})=>cv(Ma(()=>Object.keys(e).map(n=>{const r=n,s=e[r];return rn(x0(r,s.props),v0({element:s,clientRef:t,name:r}))}),[e,t]))),b0=ce(({parent:e,clients:t})=>{const{rootClients:n,derivedClients:r}=d0(t,e),s=tn({parent:e,current:null}).current;je(()=>{s.current=a});const i=Ve(Object.keys(n).length>0?y0({clients:n,clientRef:s}):g0()),o=Ve(w0({clients:r,clientRef:s})),a=ie(()=>{const l=e===Oa?o0():e,u=Object.create(l);Object.assign(u,{subscribe:i.subscribe??e.subscribe,on:i.on??e.on,[Qs]:tv(u)});for(const f of i.clients)u[f.name]=f;for(const f of o)u[f.name]=f;return u},[e,i,o]);return s.current===null&&(s.current=a),a});function se(e,{parent:t}={parent:a0()}){if(e)return uv(b0({parent:t??Oa,clients:e}));if(t===null)throw new Error("received null parent, this usage is not allowed");return t}const V=e=>{const t=se(),n=r0(t),r=m.useSyncExternalStore(t.subscribe,()=>e(n),()=>e(n));if(r===n)throw new Error("You tried to return the entire AssistantState. This is not supported due to technical limitations.");return m.useDebugValue(r),r},S0=e=>{const t=se(),n=m.useRef(!1),r=n.current?null:e(t);return V(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},k0=Object.freeze({});function fs({getItemState:e,children:t}){return C0(t(S0(e)))}const C0=e=>{const t=typeof e=="object"&&e!=null&&"type"in e?e:null,n=t?.type,r=t?.key;return m.useMemo(()=>t,[n,r,typeof t?.props=="object"&&t.props!=null&&Object.entries(t.props).length===0?k0:t?.props])??e},_0=ut.createContext(!0);function wh(){throw new Error("A function wrapped in useEffectEvent can't be called during rendering.")}const E0="use"in ut?()=>{try{return ut.use(_0)}catch{return!1}}:()=>!1;function T0(e){const t=ut.useRef(wh);return ut.useInsertionEffect(()=>{t.current=e},[e]),(...n)=>{E0()&&wh();const r=t.current;return r(...n)}}const ta=(e,t)=>{const n=se(),r=T0(t),{scope:s,event:i}=iv(e);m.useEffect(()=>n.on({scope:s,event:i},r),[n,s,i])},I0=Zy(e=>{if(e.key===void 0)throw new Error("tapClientResource: Element has no key");return Ve(ev(e))});function is(e,t){const n=Ma(()=>e().map(i=>I0(i)),t),r=ie(()=>Object.keys(n),[n]),s=ie(()=>n.reduce((i,o,a)=>(i[o.key]=a,i),{}),[n]);return{state:ie(()=>n.map(i=>i.state),[n]),get:i=>{if("index"in i){if(i.index<0||i.index>=r.length)throw new Error(`tapClientLookup: Index ${i.index} out of bounds (length: ${r.length})`);return n[i.index].methods}const o=s[i.key];if(o===void 0)throw new Error(`tapClientLookup: Key "${i.key}" not found`);return n[o].methods}}}const dv=ce(({toolkit:e,mcpApp:t})=>{const n=Ma(()=>t?[rn("mcpApp",t)]:[],[t])[0],[r,s]=kt(()=>({})),i=ie(()=>({toolUIs:r,mcpApp:n,tools:Object.fromEntries(Object.entries(r).map(([l,u])=>[l,u.map(f=>f.render)]))}),[r,n]),o=lv(),a=xi((l,u,f)=>{const d={render:u,standalone:f?.standalone??!1};return s(h=>({...h,[l]:[...h[l]??[],d]})),()=>{s(h=>{const p=h[l]?.filter(k=>k!==d)??[];if(p.length>0)return{...h,[l]:p};const{[l]:g,...x}=h;return x})}},[]);return je(()=>{if(!e)return;const l=[];for(const[f,d]of Object.entries(e)){const h="render"in d?d.render:void 0,p="renderText"in d?d.renderText:void 0,g=h??(p?YC(p):void 0);g&&l.push(a(f,g,{standalone:GC(d)}))}const u=Object.entries(e).reduce((f,[d,h])=>{if(h.type==="mcp")return f;const{display:p,render:g,renderText:x,...k}=h;return f[d]=k,f},{});return l.push(o.current.modelContext().register({getModelContext:()=>({tools:u})})),()=>{l.forEach(f=>f())}},[e,a,o]),{getState:()=>i,setToolUI:a}});sv(dv,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=Jy())});const xr=e=>{const[,t]=kt(e.getState);return je(()=>(t(e.getState()),e.subscribe(()=>{t(e.getState())})),[e]),e.getState()},fv=ce(({runtime:e})=>{const t=xr(e);return{getState:()=>t,remove:e.remove,__internal_getRuntime:()=>e}}),R0=ce(({runtime:e,index:t})=>Ve(fv({runtime:ie(()=>e.getAttachmentByIndex(t),[e,t])}))),hv=ce(({threadIdRef:e,messageIdRef:t,runtime:n})=>{const r=xr(n),s=pd();je(()=>{const a=[];for(const l of["send","attachmentAdd"]){const u=n.unstable_on(l,()=>{s(`composer.${l}`,{threadId:e.current,...t&&{messageId:t.current}})});a.push(u)}return a.push(n.unstable_on("attachmentAddError",l=>{s("composer.attachmentAddError",{threadId:e.current,...t&&{messageId:t.current},...l.attachmentId&&{attachmentId:l.attachmentId},reason:l.reason,message:l.message})})),()=>{for(const l of a)l()}},[n,s,e,t]);const i=is(()=>r.attachments.map((a,l)=>rn(a.id,R0({runtime:n,index:l}))),[r.attachments,n]),o=ie(()=>({text:r.text,role:r.role,attachments:i.state,runConfig:r.runConfig,isEditing:r.isEditing,canCancel:r.canCancel,canSend:r.canSend,attachmentAccept:r.attachmentAccept,isEmpty:r.isEmpty,type:r.type??"thread",dictation:r.dictation,quote:r.quote,queue:[]}),[r,i.state]);return{getState:()=>o,setText:n.setText,setRole:n.setRole,setRunConfig:n.setRunConfig,addAttachment:n.addAttachment,reset:n.reset,clearAttachments:n.clearAttachments,send:n.send,cancel:n.cancel,beginEdit:n.beginEdit??(()=>{throw new Error("beginEdit is not supported in this runtime")}),startDictation:n.startDictation,stopDictation:n.stopDictation,setQuote:n.setQuote,attachment:a=>"id"in a?i.get({key:a.id}):i.get(a),queueItem:()=>{throw new Error("Queue is not supported in this runtime")},__internal_getRuntime:()=>n}}),P0=ce(({runtime:e})=>{const t=xr(e);return{getState:()=>t,addToolResult:n=>e.addToolResult(n),resumeToolCall:n=>e.resumeToolCall(n),respondToToolApproval:n=>e.respondToToolApproval(n),__internal_getRuntime:()=>e}}),A0=ce(({runtime:e,index:t})=>Ve(fv({runtime:ie(()=>e.getAttachmentByIndex(t),[e,t])}))),j0=ce(({runtime:e,index:t})=>Ve(P0({runtime:ie(()=>e.getMessagePartByIndex(t),[e,t])}))),N0=ce(({runtime:e,threadIdRef:t})=>{const n=xr(e),[r,s]=kt(!1),[i,o]=kt(!1),a=ie(()=>({get current(){return e.getState().id}}),[e]),l=La(hv({runtime:e.composer,threadIdRef:t,messageIdRef:a})),u=is(()=>n.content.map((h,p)=>rn("toolCallId"in h&&h.toolCallId!=null?`toolCallId-${h.toolCallId}`:`index-${p}`,j0({runtime:e,index:p}))),[n.content,e]),f=is(()=>(n.attachments??[]).map((h,p)=>rn(h.id,A0({runtime:e,index:p}))),[n.attachments,e]),d=ie(()=>({...n,parts:u.state,composer:l.state,isCopied:r,isHovering:i}),[n,u.state,l.state,r,i]);return{getState:()=>d,composer:()=>l.methods,reload:h=>e.reload(h),speak:()=>e.speak(),stopSpeaking:()=>e.stopSpeaking(),submitFeedback:h=>e.submitFeedback(h),switchToBranch:h=>e.switchToBranch(h),getCopyText:()=>e.unstable_getCopyText(),part:h=>"index"in h?u.get({index:h.index}):u.get({key:`toolCallId-${h.toolCallId}`}),attachment:h=>"id"in h?f.get({key:h.id}):f.get(h),setIsCopied:s,setIsHovering:o,__internal_getRuntime:()=>e}}),M0=ce(({runtime:e,id:t,threadIdRef:n})=>Ve(N0({runtime:ie(()=>e.getMessageById(t),[e,t]),threadIdRef:n}))),D0=ce(({runtime:e})=>{const t=xr(e),n=pd();je(()=>{const a=[];for(const l of["runStart","runEnd","initialize","modelContextUpdate"]){const u=e.unstable_on(l,()=>{const f=e.getState()?.threadId||"unknown";n(`thread.${l}`,{threadId:f})});a.push(u)}return()=>{for(const l of a)l()}},[e,n]);const r=ie(()=>({get current(){return e.getState().threadId}}),[e]),s=La(hv({runtime:e.composer,threadIdRef:r})),i=is(()=>t.messages.map(a=>rn(a.id,M0({runtime:e,id:a.id,threadIdRef:r}))),[t.messages,e,r]),o=ie(()=>({isEmpty:i.state.length===0&&!t.isLoading,isDisabled:t.isDisabled,isLoading:t.isLoading,isRunning:t.isRunning,capabilities:t.capabilities,state:t.state,suggestions:t.suggestions,extras:t.extras,speech:t.speech,voice:t.voice,composer:s.state,messages:i.state}),[t,i,s.state]);return{getState:()=>o,composer:()=>s.methods,append:e.append,startRun:e.startRun,resumeRun:e.resumeRun,cancelRun:e.cancelRun,getModelContext:e.getModelContext,export:e.export,import:e.import,reset:e.reset,stopSpeaking:e.stopSpeaking,connectVoice:e.connectVoice,disconnectVoice:e.disconnectVoice,getVoiceVolume:e.getVoiceVolume,subscribeVoiceVolume:e.subscribeVoiceVolume,muteVoice:e.muteVoice,unmuteVoice:e.unmuteVoice,message:a=>"id"in a?i.get({key:a.id}):i.get(a),__internal_getRuntime:()=>e}}),L0=ce(({runtime:e})=>{const t=xr(e),n=pd();return je(()=>{const r=[];for(const s of["switchedTo","switchedAway"]){const i=e.unstable_on(s,()=>{n(`threadListItem.${s}`,{threadId:e.getState().id})});r.push(i)}return()=>{for(const s of r)s()}},[e,n]),{getState:()=>t,switchTo:e.switchTo,rename:e.rename,updateCustom:e.updateCustom,archive:e.archive,unarchive:e.unarchive,delete:e.delete,generateTitle:e.generateTitle,initialize:e.initialize,detach:e.detach,__internal_getRuntime:()=>e}}),O0=ce(({runtime:e,id:t})=>Ve(L0({runtime:ie(()=>e.getItemById(t),[e,t])}))),z0=ce(({runtime:e,__internal_assistantRuntime:t})=>{const n=xr(e),r=La(D0({runtime:e.main})),s=is(()=>Object.keys(n.threadItems).map(o=>rn(o,O0({runtime:e,id:o}))),[n.threadItems,e]),i=ie(()=>({mainThreadId:n.mainThreadId,newThreadId:n.newThreadId??null,isLoading:n.isLoading,isLoadingMore:n.isLoadingMore,hasMore:n.hasMore,threadIds:n.threadIds,archivedThreadIds:n.archivedThreadIds,threadItems:s.state,main:r.state}),[n,s.state,r.state]);return{getState:()=>i,thread:()=>r.methods,item:o=>{if(o==="main")return s.get({key:i.mainThreadId});if("id"in o)return s.get({key:o.id});const{index:a,archived:l=!1}=o,u=l?i.archivedThreadIds[a]:i.threadIds[a];return s.get({key:u})},switchToThread:async(o,a)=>{await e.switchToThread(o,a)},switchToNewThread:async()=>{await e.switchToNewThread()},getLoadThreadsPromise:()=>e.getLoadThreadsPromise(),reload:()=>e.reload(),loadMore:()=>e.loadMore(),__internal_getAssistantRuntime:()=>t}}),F0=ce(e=>({getState:()=>e})),B0=ce(e=>{const[t]=kt(()=>({suggestions:(e??[]).map(r=>typeof r=="string"?{title:r,label:"",prompt:r}:{title:r.title,label:r.label,prompt:r.prompt})})),n=is(()=>t.suggestions.map((r,s)=>rn(s,F0(r))),[t.suggestions]);return{getState:()=>t,suggestion:({index:r})=>n.get({index:r})}}),$0=ce(e=>{const t=lv();return je(()=>e.registerModelContextProvider(t.current.modelContext()),[e,t]),Ve(z0({runtime:e.threads,__internal_assistantRuntime:e}))}),U0=(e,t)=>{e.thread??(e.thread=At({source:"threads",query:{type:"main"},get:n=>n.threads().thread("main")})),e.threadListItem??(e.threadListItem=At({source:"threads",query:{type:"main"},get:n=>n.threads().item("main")})),e.composer??(e.composer=At({source:"thread",query:{},get:n=>n.threads().thread("main").composer()})),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=Jy()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=B0())},pv=ce(e=>Ve($0(e)));sv(pv,(e,t)=>{U0(e,t),!e.tools&&t.tools.source===null&&(e.tools=dv({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=HC())});const V0=e=>e._core?.RenderComponent,H0=m.memo(({runtime:e,aui:t=null,children:n})=>{const r=se({threads:pv(e)},{parent:t}),s=V0(e);return c.jsxs(wn,{value:r,children:[s&&c.jsx(s,{}),n]})}),bh=e=>{let t;const n=new Set,r=(u,f)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(p=>p(t,h))}},s=()=>t,a={setState:r,getState:s,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u))},l=t=e(r,s,a);return a},W0=e=>e?bh(e):bh,q0=e=>e;function K0(e,t=q0){const n=ut.useSyncExternalStore(e.subscribe,ut.useCallback(()=>t(e.getState()),[e,t]),ut.useCallback(()=>t(e.getInitialState()),[e,t]));return ut.useDebugValue(n),n}const Sh=e=>{const t=W0(e),n=r=>K0(t,r);return Object.assign(n,t),n},mv=e=>e?Sh(e):Sh,md=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});if(!e||!t)throw new Error("Failed to create promise");return{promise:n,resolve:e,reject:t}},G0=()=>{const e=[];let t=!1,n,r;const s=i=>{i.promise||(i.promise=i.reader.read().then(({done:o,value:a})=>{i.promise=void 0,o?(e.splice(e.indexOf(i),1),t&&e.length===0&&n.close()):n.enqueue(a),r?.resolve(),r=void 0}).catch(o=>{console.error(o),e.forEach(a=>{a.reader.cancel()}),e.length=0,n.error(o),r?.reject(o),r=void 0}))};return{readable:new ReadableStream({start(i){n=i},pull(){return r=md(),e.forEach(i=>{s(i)}),r.promise},cancel(){e.forEach(i=>{i.reader.cancel()}),e.length=0}}),isSealed(){return t},seal(){t=!0,e.length===0&&n.close()},addStream(i){if(t)throw new Error("Cannot add streams after the run callback has settled.");const o={reader:i.getReader()};e.push(o),s(o)},enqueue(i){this.addStream(new ReadableStream({start(o){o.enqueue(i),o.close()}}))}}};var kh=class{constructor(e){T(this,"_controller");T(this,"_isClosed",!1);this._controller=e}append(e){return this._controller.enqueue({type:"text-delta",path:[],textDelta:e}),this}close(){this._isClosed||(this._isClosed=!0,this._controller.enqueue({type:"part-finish",path:[]}),this._controller.close())}};const gv=e=>new ReadableStream({start(t){return e.start?.(new kh(t))},pull(t){return e.pull?.(new kh(t))},cancel(t){return e.cancel?.(t)}}),Ch=()=>{let e;return[gv({start(t){e=t}}),e]};var _h=class{constructor(e){T(this,"_controller");T(this,"_isClosed",!1);T(this,"_mergeTask");T(this,"_argsTextController");this._controller=e;const t=gv({start:r=>{this._argsTextController=r}});let n=!1;this._mergeTask=t.pipeTo(new WritableStream({write:r=>{switch(r.type){case"text-delta":n=!0,this._controller.enqueue(r);break;case"part-finish":n||this._controller.enqueue({type:"text-delta",textDelta:"{}",path:[]}),this._controller.enqueue({type:"tool-call-args-text-finish",path:[]});break;default:throw new Error(`Unexpected chunk type: ${r.type}`)}}}))}get argsText(){return this._argsTextController}async setResponse(e){this._argsTextController.close(),await Promise.resolve(),this._controller.enqueue({type:"result",path:[],...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}:{}})}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,this._controller.enqueue({type:"part-finish",path:[]}),this._controller.close())}};const Q0=e=>new ReadableStream({start(t){return e.start?.(new _h(t))},pull(t){return e.pull?.(new _h(t))},cancel(t){return e.cancel?.(t)}}),Y0=()=>{let e;return[Q0({start(t){e=t}}),e]};var yv=class{constructor(){T(this,"value",-1)}up(){return++this.value}},J0=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};(class extends TransformStream{constructor(e){super({transform(t,n){const{path:[r,...s]}=t;if(e!==r)throw new Error(`Path mismatch: expected ${e}, got ${r}`);n.enqueue({...t,path:s})}})}});var X0=class extends TransformStream{constructor(e){const t=new yv,n=new Map;super({transform(r,s){r.type==="part-start"&&r.path.length===0&&n.set(t.up(),e.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]})}})}},Z0=class extends TransformStream{constructor(e){super();const t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},vv=class extends TransformStream{constructor(){const e=[];super({transform(t,n){if(t.type==="part-start"){if(t.path.length!==0){n.error(new Error("Nested parts are not supported"));return}e.push(t.part),n.enqueue(t);return}if(t.type==="text-delta"||t.type==="result"||t.type==="part-finish"||t.type==="tool-call-args-text-finish"){if(t.path.length!==1){n.error(new Error(`${t.type} chunks must have a path of length 1`));return}const r=t.path[0];if(r<0||r>=e.length){n.error(new Error(`Invalid path index: ${r}`));return}const s=e[r];n.enqueue({...t,meta:s});return}n.enqueue(t)}})}};let xv=(e,t=21)=>(n=t)=>{let r="",s=n|0;for(;s--;)r+=e[Math.random()*e.length|0];return r};const e_=xv("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7);var t_=class wv{constructor(t){T(this,"_state");T(this,"_parentId");this._state=t||{merger:G0(),contentCounter:new yv}}get __internal_isClosed(){return this._state.merger.isSealed()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(t){this._state.closeSubscriber=t}_addPart(t,n){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:"part-start",part:t,path:[]}),this._state.merger.addStream(n.pipeThrough(new J0(this._state.contentCounter.value)))}merge(t){this._state.merger.addStream(t.pipeThrough(new X0(this._state.contentCounter)))}appendText(t){(this._state.append?.kind!=="text"||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:"text",parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(t)}appendReasoning(t){(this._state.append?.kind!=="reasoning"||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:"reasoning",parentId:this._parentId,controller:this.addReasoningPart()}),this._state.append.controller.append(t)}addTextPart(){const[t,n]=Ch();return this._addPart(this._withParentIdOption({type:"text"}),t),n}addReasoningPart(){const[t,n]=Ch();return this._addPart(this._withParentIdOption({type:"reasoning"}),t),n}addToolCallPart(t){const n=typeof t=="string"?{toolName:t}:t,r=n.toolName,s=n.toolCallId??e_(),[i,o]=Y0();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(t){t.enqueue({type:"part-finish",path:[]}),t.close()}})}_withParentIdOption(t){return this._parentId?{...t,parentId:this._parentId}:t}appendSource(t){this._addPart(this._withParentIdOption(t),this._finishedPartStream())}appendFile(t){this._addPart(this._withParentIdOption(t),this._finishedPartStream())}appendData(t){this._addPart(this._withParentIdOption(t),this._finishedPartStream())}enqueue(t){this._state.merger.enqueue(t),t.type==="part-start"&&t.path.length===0&&this._state.contentCounter.up()}withParentId(t){const n=new wv(this._state);return n._parentId=t,n}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function n_(e){const t=new t_;return(async()=>{try{await e(t)}catch(r){throw t.__internal_isClosed||t.enqueue({type:"error",path:[],error:String(r)}),r}finally{t.__internal_isClosed||t.close()}})(),t.__internal_getReadable()}function r_(){const{resolve:e,promise:t}=md();let n;return[n_(r=>(n=r,n.__internal_subscribeToClose(e),t)),n]}function s_(e){const t=["ROOT"];let n=-1,r=null;const s=[];let i;function o(){i!==void 0&&(s.push(JSON.parse(`"${i}"`)),i=void 0)}function a(d,h,p){switch(d){case'"':n=h,t.pop(),t.push(p),t.push("INSIDE_STRING"),o();break;case"f":case"t":case"n":n=h,r=h,t.pop(),t.push(p),t.push("INSIDE_LITERAL");break;case"-":t.pop(),t.push(p),t.push("INSIDE_NUMBER"),o();break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n=h,t.pop(),t.push(p),t.push("INSIDE_NUMBER"),o();break;case"{":n=h,t.pop(),t.push(p),t.push("INSIDE_OBJECT_START"),o();break;case"[":n=h,t.pop(),t.push(p),t.push("INSIDE_ARRAY_START"),o();break}}function l(d,h){switch(d){case",":t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break;case"}":n=h,t.pop(),i=s.pop();break}}function u(d,h){switch(d){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA"),i=(Number(i)+1).toString();break;case"]":n=h,t.pop(),i=s.pop();break}}for(let d=0;d<e.length;d++){const h=e[d];switch(t[t.length-1]){case"ROOT":a(h,d,"FINISH");break;case"INSIDE_OBJECT_START":switch(h){case'"':t.pop(),t.push("INSIDE_OBJECT_KEY"),i="";break;case"}":n=d,t.pop(),i=s.pop();break}break;case"INSIDE_OBJECT_AFTER_COMMA":switch(h){case'"':t.pop(),t.push("INSIDE_OBJECT_KEY"),i="";break}break;case"INSIDE_OBJECT_KEY":switch(h){case'"':t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break;case"\\":t.push("INSIDE_STRING_ESCAPE"),i+=h;break;default:i+=h;break}break;case"INSIDE_OBJECT_AFTER_KEY":switch(h){case":":t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}break;case"INSIDE_OBJECT_BEFORE_VALUE":a(h,d,"INSIDE_OBJECT_AFTER_VALUE");break;case"INSIDE_OBJECT_AFTER_VALUE":l(h,d);break;case"INSIDE_STRING":switch(h){case'"':t.pop(),n=d,i=s.pop();break;case"\\":t.push("INSIDE_STRING_ESCAPE");break;default:n=d}break;case"INSIDE_ARRAY_START":switch(h){case"]":n=d,t.pop(),i=s.pop();break;default:n=d,i="0",a(h,d,"INSIDE_ARRAY_AFTER_VALUE");break}break;case"INSIDE_ARRAY_AFTER_VALUE":switch(h){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA"),i=(Number(i)+1).toString();break;case"]":n=d,t.pop(),i=s.pop();break;default:n=d;break}break;case"INSIDE_ARRAY_AFTER_COMMA":a(h,d,"INSIDE_ARRAY_AFTER_VALUE");break;case"INSIDE_STRING_ESCAPE":t.pop(),t[t.length-1]==="INSIDE_STRING"?n=d:t[t.length-1]==="INSIDE_OBJECT_KEY"&&(i+=h);break;case"INSIDE_NUMBER":switch(h){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n=d;break;case"e":case"E":case"-":case".":break;case",":t.pop(),i=s.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,d),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(h,d);break;case"}":t.pop(),i=s.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(h,d);break;case"]":t.pop(),i=s.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,d);break;default:t.pop(),i=s.pop();break}break;case"INSIDE_LITERAL":{const p=e.substring(r,d+1);!"false".startsWith(p)&&!"true".startsWith(p)&&!"null".startsWith(p)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?l(h,d):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,d)):n=d;break}}}let f=e.slice(0,n+1);for(let d=t.length-1;d>=0;d--)switch(t[d]){case"INSIDE_STRING":f+='"';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":f+="}";break;case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":f+="]";break;case"INSIDE_LITERAL":{const h=e.substring(r,e.length);"true".startsWith(h)?f+="true".slice(h.length):"false".startsWith(h)?f+="false".slice(h.length):"null".startsWith(h)&&(f+="null".slice(h.length))}}return[f,s]}var hs={exports:{}};const i_=typeof Buffer<"u",Eh=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Th=/"(?: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 bv(e,t,n){n==null&&t!==null&&typeof t=="object"&&(n=t,t=void 0),i_&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));const r=JSON.parse(e,t);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(Eh.test(e)===!1&&Th.test(e)===!1)return r}else if(s!=="ignore"&&i==="ignore"){if(Eh.test(e)===!1)return r}else if(Th.test(e)===!1)return r;return Sv(r,{protoAction:s,constructorAction:i,safe:n&&n.safe})}function Sv(e,{protoAction:t="error",constructorAction:n="error",safe:r}={}){let s=[e];for(;s.length;){const i=s;s=[];for(const o of i){if(t!=="ignore"&&Object.prototype.hasOwnProperty.call(o,"__proto__")){if(r===!0)return null;if(t==="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 e}function gd(e,t,n){const{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return bv(e,t,n)}finally{Error.stackTraceLimit=r}}function o_(e,t){const{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return bv(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}hs.exports=gd;hs.exports.default=gd;hs.exports.parse=gd;hs.exports.safeParse=o_;hs.exports.scan=Sv;var a_=hs.exports;const qu=Ei(a_),ko=Symbol("aui.parse-partial-json-object.meta"),l_=e=>e?.[ko],Ku=e=>{if(e.length===0)return{[ko]:{state:"partial",partialPath:[]}};try{const t=qu.parse(e);if(typeof t!="object"||t===null)throw new Error("argsText is expected to be an object");return t[ko]={state:"complete",partialPath:[]},t}catch{try{const[t,n]=s_(e),r=qu.parse(t);if(typeof r!="object"||r===null)throw new Error("argsText is expected to be an object");return r[ko]={state:"partial",partialPath:n},r}catch{return}}},kv=(e,t,n)=>{if(typeof e!="object"||e===null)return t.state;if(t.state==="complete")return"complete";if(n.length===0)return t.state;const[r,...s]=n;if(!Object.hasOwn(e,r))return"partial";const[i,...o]=t.partialPath;if(r!==i)return"complete";const a=e[r];return kv(a,{state:"partial",partialPath:o},s)},os=(e,t)=>{const n=l_(e);if(!n)throw new Error("unable to determine object state");return kv(e,n,t.map(String))};async function*u_(){const e=this.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{e.releaseLock()}}function _l(e){var t;return e[t=Symbol.asyncIterator]??(e[t]=u_),e}const Ih=Symbol.for("aui.tool-response");var hn=class Gu{constructor(t){T(this,"artifact");T(this,"result");T(this,"isError");T(this,"modelContent");T(this,"messages");t.artifact!==void 0&&(this.artifact=t.artifact),this.result=t.result,this.isError=t.isError??!1,t.modelContent!==void 0&&(this.modelContent=t.modelContent),t.messages!==void 0&&(this.messages=t.messages)}get[Ih](){return!0}static[Symbol.hasInstance](t){return typeof t=="object"&&t!==null&&Ih in t}static toResponse(t){return t instanceof Gu?t:new Gu({result:t===void 0?"<no result>":t})}};function c_(e,t,n){try{const r=e();if(typeof r=="object"&&r!==null&&"then"in r)return r.then(t,n);t(r)}catch(r){n(r)}}function as(e,t){let n=e;for(const r of t){if(n==null)return;n=n[r]}return n}var d_=class{constructor(e,t,n){T(this,"resolve");T(this,"reject");T(this,"disposed",!1);T(this,"fieldPath");this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(os(e,this.fieldPath)==="complete"){const t=as(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(t){this.reject(t),this.dispose()}}end(e){if(!this.disposed)try{const t=as(e,this.fieldPath);this.resolve(t)}catch(t){this.reject(t)}finally{this.dispose()}}dispose(){this.disposed=!0}},f_=class{constructor(e,t){T(this,"controller");T(this,"disposed",!1);T(this,"fieldPath");this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{const t=as(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),os(e,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(t){this.controller.error(t),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},h_=class{constructor(e,t){T(this,"controller");T(this,"disposed",!1);T(this,"fieldPath");T(this,"lastValue");this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{const t=as(e,this.fieldPath);if(t!==void 0&&typeof t=="string"){const n=t.substring(this.lastValue?.length||0);this.lastValue=t,this.controller.enqueue(n)}os(e,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(t){this.controller.error(t),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},p_=class{constructor(e,t){T(this,"controller");T(this,"disposed",!1);T(this,"fieldPath");T(this,"processedIndexes",new Set);this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{const t=as(e,this.fieldPath);if(!Array.isArray(t))return;for(let n=0;n<t.length;n++)this.processedIndexes.has(n)||os(e,[...this.fieldPath,n])==="complete"&&(this.controller.enqueue(t[n]),this.processedIndexes.add(n));os(e,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(t){this.controller.error(t),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},m_=class{constructor(e){T(this,"argTextDeltas");T(this,"handles",new Set);T(this,"args",Ku(""));T(this,"finished",!1);this.argTextDeltas=e,this.processStream()}async processStream(){try{let e="";const t=this.argTextDeltas.getReader();for(;;){const{value:n,done:r}=await t.read();if(r)break;e+=n;const s=Ku(e);if(s!==void 0){this.args=s;for(const i of this.handles)i.update(s)}}}catch(e){console.error("Error processing argument stream:",e)}finally{this.finished=!0;for(const e of this.handles)e.end(this.args);this.handles.clear()}}get(...e){return new Promise((t,n)=>{const r=new d_(t,n,e);if(this.args&&os(this.args,e)==="complete"){const s=as(this.args,e);if(s!==void 0){t(s);return}}if(this.finished){r.end(this.args);return}this.handles.add(r),r.update(this.args)})}streamValues(...e){const t=e;let n;return _l(new ReadableStream({start:r=>{n=new f_(r,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}streamText(...e){const t=e;let n;return _l(new ReadableStream({start:r=>{n=new h_(r,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}forEach(...e){const t=e;let n;return _l(new ReadableStream({start:r=>{n=new p_(r,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},g_=class{constructor(e){T(this,"promise");this.promise=e}get(){return this.promise}},y_=class{constructor(){T(this,"args");T(this,"response");T(this,"writable");T(this,"resolve");T(this,"argsText","");T(this,"result",{get:async()=>(await this.response.get()).result});const e=new TransformStream;this.writable=e.writable,this.args=new m_(e.readable);const{promise:t,resolve:n}=md();this.resolve=n,this.response=new g_(t)}async appendArgsTextDelta(e){const t=this.writable.getWriter();try{await t.write(e)}catch(n){console.warn(n)}finally{t.releaseLock()}this.argsText+=e}async finishArgsText(){const e=this.writable.getWriter();try{await e.close()}catch(t){console.warn(t)}finally{e.releaseLock()}}setResponse(e){this.resolve(e)}},v_=class extends Z0{constructor(e){const t=new Map,n=new Map;super(r=>{const s=new TransformStream({async transform(i,o){switch((i.type!=="part-finish"||i.meta.type!=="tool-call")&&o.enqueue(i),i.type){case"part-start":if(i.part.type==="tool-call"){const a=new y_;n.set(i.part.toolCallId,a),e.streamCall({reader:a,toolCallId:i.part.toolCallId,toolName:i.part.toolName})}break;case"text-delta":if(i.meta.type==="tool-call"){const a=i.meta.toolCallId,l=n.get(a);if(!l)throw new Error("No controller found for tool call");await l.appendArgsTextDelta(i.textDelta)}break;case"result":{if(i.meta.type!=="tool-call")break;const{toolCallId:a}=i.meta,l=n.get(a);if(!l)throw new Error("No controller found for tool call");l.setResponse(new hn({result:i.result,artifact:i.artifact,isError:i.isError,modelContent:i.modelContent}));break}case"tool-call-args-text-finish":{if(i.meta.type!=="tool-call")break;const{toolCallId:a,toolName:l}=i.meta,u=n.get(a);if(!u)throw new Error("No controller found for tool call");await u.finishArgsText();let f=!1;const d=c_(()=>{let h;try{h=qu.parse(u.argsText)}catch(g){throw new Error(`Function parameter parsing failed. ${JSON.stringify(g.message)}`)}const p=e.execute({toolCallId:a,toolName:l,args:h});return p!==void 0&&(f=!0,e.onExecutionStart?.(a,l)),p},h=>{if(f&&e.onExecutionEnd?.(a,l),h===void 0)return;const p=new hn({artifact:h.artifact,result:h.result,isError:h.isError,messages:h.messages,modelContent:h.modelContent});u.setResponse(p),o.enqueue({type:"result",path:i.path,...p})},h=>{f&&e.onExecutionEnd?.(a,l);const p=new hn({result:String(h),isError:!0});u.setResponse(p),o.enqueue({type:"result",path:i.path,...p})});d&&t.set(a,d);break}case"part-finish":{if(i.meta.type!=="tool-call")break;const{toolCallId:a}=i.meta,l=t.get(a);l?l.then(()=>{t.delete(a),n.delete(a),o.enqueue(i)}):o.enqueue(i)}}},async flush(){await Promise.all(t.values())}});return r.pipeThrough(new vv).pipeThrough(s)})}};const x_=e=>typeof e=="object"&&e!==null&&"~standard"in e&&e["~standard"].version===1;function w_(e,t,n,r){const s=e?.[n.toolName];return s?.execute?(async o=>{if(t.aborted)return new hn({result:"Tool execution was cancelled.",isError:!0});let a=o;if(x_(s.parameters)){let f=s.parameters["~standard"].validate(n.args);f instanceof Promise&&(f=await f),f.issues&&(a=s.experimental_onSchemaValidationError??(()=>{throw new Error(`Function parameter validation failed. ${JSON.stringify(f.issues)}`)}))}const l=new Promise(f=>{const d=()=>{queueMicrotask(()=>{queueMicrotask(()=>{f(new hn({result:"Tool execution was cancelled.",isError:!0}))})})};t.aborted?d():t.addEventListener("abort",d,{once:!0})}),u=(async()=>{const f=await a(n.args,{toolCallId:n.toolCallId,abortSignal:t,human:h=>r(n.toolCallId,h)}),d=hn.toResponse(f);if(s.toModelOutput&&!d.isError&&d.modelContent===void 0)try{const h=await s.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:d.result});return new hn({result:d.result,artifact:d.artifact,isError:d.isError,messages:d.messages,modelContent:h})}catch(h){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,h)}return d})();return Promise.race([u,l])})(s.execute):void 0}function b_(e,t,n,r,s){e?.[r.toolName]?.streamCall?.(n,{toolCallId:r.toolCallId,abortSignal:t,human:i=>s(r.toolCallId,i)})}function S_(e,t,n,r){const s=typeof e=="function"?e:()=>e,i=typeof t=="function"?t:()=>t;return new v_({execute:o=>w_(s(),i(),o,n),streamCall:({reader:o,...a})=>b_(s(),i(),o,a,n),onExecutionStart:r?.onExecutionStart,onExecutionEnd:r?.onExecutionEnd})}const Cv=({index:e,children:t})=>c.jsx(wn,{value:se({attachment:At({source:"message",query:{type:"index",index:e},get:n=>n.message().attachment({index:e})})}),children:t}),_v=({index:e,children:t})=>c.jsx(wn,{value:se({attachment:At({source:"composer",query:{type:"index",index:e},get:n=>n.composer().attachment({index:e})})}),children:t}),Ev=({index:e,children:t})=>c.jsx(wn,{value:se({message:At({source:"thread",query:{type:"index",index:e},get:n=>n.thread().message({index:e})}),composer:At({source:"message",query:{},get:n=>n.thread().message({index:e}).composer()})}),children:t}),yd=({index:e,children:t})=>c.jsx(wn,{value:se({part:At({source:"message",query:{type:"index",index:e},get:n=>n.message().part({index:e})})}),children:t}),k_=ce(({text:e,isRunning:t})=>{const n=ie(()=>({type:"text",text:e,status:t?{type:"running"}:{type:"complete"}}),[e,t]);return{getState:()=>n,addToolResult:()=>{throw new Error("Not supported")},resumeToolCall:()=>{throw new Error("Not supported")},respondToToolApproval:()=>{throw new Error("Not supported")}}}),vd=({text:e,isRunning:t=!1,children:n})=>c.jsx(wn,{value:se({part:k_({text:e,isRunning:t})}),children:n}),C_=Object.freeze({type:"complete"}),__=ce(({parts:e,getMessagePart:t})=>{const[n,r]=kt(!0),s=ie(()=>e[e.length-1]?.status??C_,[e]),i=ie(()=>({parts:e,collapsed:n,status:s}),[e,n,s]);return{getState:()=>i,setCollapsed:r,part:t}}),E_=({startIndex:e,endIndex:t,children:n})=>{const r=V(i=>i.message.parts).slice(e,t+1),s=se();return c.jsx(wn,{value:se({chainOfThought:__({parts:r,getMessagePart:({index:i})=>{if(i<0||i>=r.length)throw new Error(`ChainOfThought part index ${i} is out of bounds (0..${r.length-1})`);return s.message().part({index:e+i})}})}),children:n})},Tv=({index:e,children:t})=>c.jsx(wn,{value:se({suggestion:At({source:"suggestions",query:{index:e},get:n=>n.suggestions().suggestion({index:e})})}),children:t}),T_=({index:e,children:t})=>c.jsx(wn,{value:se({queueItem:At({source:"composer",query:{index:e},get:n=>n.composer().queueItem({index:e})})}),children:t}),pr=Symbol("innerMessage"),El=Symbol("innerMessages"),I_=[],R_=(e,t)=>{pr in e||(e[pr]=t)},P_=e=>{const t="messages"in e?e.messages:e,n=t[El]||t[pr];return n?Array.isArray(n)?n:(t[El]=[n],t[El]):I_},Ht=Symbol("skip-update");function A_(e,t){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0)return!1;for(const n of Object.keys(e)){const r=e[n],s=t[n];if(!Object.is(r,s))return!1}return!0}var j_=class{constructor(){T(this,"_subscribers",new Set)}subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{const t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){const e=[];for(const t of this._subscribers)try{t()}catch(n){e.push(n)}if(e.length>0){if(e.length===1)throw e[0];for(const t of e)console.error(t);throw new AggregateError(e)}}},za=class{constructor(){T(this,"_subscriptions",new Set);T(this,"_connection")}get isConnected(){return!!this._connection}notifySubscribers(e){for(const t of this._subscriptions)t(e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else this._connection?.(),this._connection=void 0}subscribe(e){return this._subscriptions.add(e),this._updateConnection(),()=>{this._subscriptions.delete(e),this._updateConnection()}}},Ft=class extends za{constructor(t){super();T(this,"binding");T(this,"_previousState");T(this,"getState",()=>(this.isConnected||this._syncState(),this._previousState));this.binding=t;const n=t.getState();if(n===Ht)throw new Error("Entry not available in the store");this._previousState=n}get path(){return this.binding.path}_syncState(){const t=this.binding.getState();return t===Ht||A_(t,this._previousState)?!1:(this._previousState=t,!0)}_connect(){const t=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(t)}},xd=class extends za{constructor(t){super();T(this,"binding");T(this,"_previousStateDirty",!0);T(this,"_previousState");T(this,"getState",()=>{if(!this.isConnected||this._previousStateDirty){const t=this.binding.getState();t!==Ht&&(this._previousState=t),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState});this.binding=t}get path(){return this.binding.path}_connect(){const t=()=>{this._previousStateDirty=!0,this.notifySubscribers()};return this.binding.subscribe(t)}},na=class extends za{constructor(t){super();T(this,"binding");this.binding=t}get path(){return this.binding.path}getState(){return this.binding.getState()}outerSubscribe(t){return this.binding.subscribe(t)}_connect(){const t=()=>{this.notifySubscribers()};let n=this.binding.getState(),r=n?.subscribe(t);const s=()=>{const o=this.binding.getState();o!==n&&(n=o,r?.(),r=o?.subscribe(t),t())},i=this.outerSubscribe(s);return()=>{i?.(),r?.()}}},Iv=class extends za{constructor(t){super();T(this,"config");this.config=t}getState(){return this.config.binding.getState()}outerSubscribe(t){return this.config.binding.subscribe(t)}_connect(){const t=o=>{this.notifySubscribers(o)};let n=this.config.binding.getState(),r=n?.unstable_on(this.config.event,t);const s=()=>{const o=this.config.binding.getState();o!==n&&(n=o,r?.(),r=o?.unstable_on(this.config.event,t))},i=this.outerSubscribe(s);return()=>{i?.(),r?.()}}},Rv=class{constructor(e){T(this,"_core");this._core=e,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(e){return this._core.subscribe(e)}},Pv=class extends Rv{constructor(t,n){super(t);T(this,"_composerApi");this._composerApi=n}remove(){const t=this._composerApi.getState();if(!t)throw new Error("Composer is not available");return t.removeAttachment(this.getState().id)}},N_=class extends Pv{get source(){return"thread-composer"}},M_=class extends Pv{get source(){return"edit-composer"}},D_=class extends Rv{get source(){return"message"}remove(){throw new Error("Message attachments cannot be removed")}};const Av=Object.freeze([]),jv=Object.freeze({}),L_=e=>Object.freeze({type:"thread",isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??Av,text:e?.text??"",role:e?.role??"user",runConfig:e?.runConfig??jv,attachmentAccept:e?.attachmentAccept??"",dictation:e?.dictation,quote:e?.quote,value:e?.text??""}),O_=e=>Object.freeze({type:"edit",isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,text:e?.text??"",role:e?.role??"user",attachments:e?.attachments??Av,runConfig:e?.runConfig??jv,attachmentAccept:e?.attachmentAccept??"",dictation:e?.dictation,quote:e?.quote,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??""});var Nv=class{constructor(e){T(this,"_core");T(this,"_eventSubscriptionSubjects",new Map);this._core=e}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.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(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setText(e)}setRunConfig(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setRunConfig(e)}addAttachment(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.addAttachment(e)}reset(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");return e.reset()}clearAttachments(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");return e.clearAttachments()}send(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.send(e)}cancel(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.cancel()}setRole(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setRole(e)}startDictation(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.startDictation()}stopDictation(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.stopDictation()}setQuote(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new Iv({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},z_=class extends Nv{constructor(t){const n=new xd({path:t.path,getState:()=>L_(t.getState()),subscribe:r=>t.subscribe(r)});super({path:t.path,getState:()=>t.getState(),subscribe:r=>n.subscribe(r)});T(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(t){return new N_(new Ft({path:{...this.path,attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:t},ref:`${this.path.ref}.attachments[${t}]`},getState:()=>{const n=this.getState().attachments[t];return n?{...n,source:"thread-composer"}:Ht},subscribe:n=>this._core.subscribe(n)}),this._core)}},F_=class extends Nv{constructor(t,n){const r=new xd({path:t.path,getState:()=>O_(t.getState()),subscribe:s=>t.subscribe(s)});super({path:t.path,getState:()=>t.getState(),subscribe:s=>r.subscribe(s)});T(this,"_beginEdit");T(this,"_getState");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(t){return new M_(new Ft({path:{...this.path,attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:t},ref:`${this.path.ref}.attachments[${t}]`},getState:()=>{const n=this.getState().attachments[t];return n?{...n,source:"edit-composer"}:Ht},subscribe:n=>this._core.subscribe(n)}),this._core)}};const bi=e=>e.content.filter(t=>t.type==="text").map(t=>t.text).join(`
|
|
42
|
+
${s.system}`:r.system=s.system),s.tools)for(const[o,a]of Object.entries(s.tools)){const l=r.tools?.[o];if(l&&l!==a){const u=n[o];if(u===i)throw new Error(`You tried to define a tool with the name ${o}, but it already exists.`);const f=u>i?l:a,d=u>i?a:l;r.tools[o]={...d,...f},n[o]=Math.max(u,i);continue}r.tools||(r.tools={}),r.tools[o]=a,n[o]??(n[o]=i)}return s.config&&(r.config={...r.config,...s.config}),s.callSettings&&(r.callSettings={...r.callSettings,...s.callSettings}),r},{})};var dd=class{constructor(){T(this,"_providers",new Set);T(this,"_subscribers",new Set)}getModelContext(){return KC(this._providers)}registerModelContextProvider(e){this._providers.add(e);const t=e.subscribe?.(()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(e),t?.(),this.notifySubscribers()}}notifySubscribers(){for(const e of this._subscribers)e()}subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}};const Vu=[],GC={modelName:void 0,toolNames:Vu},QC=(e,t)=>e===t||e.length===t.length&&e.every((n,r)=>n===t[r]),Xi=(e,t)=>{const n=e.getModelContext(),r=n.config?.modelName,s=n.tools?Object.keys(n.tools).sort():Vu,i=s.length?s:Vu;return r===t.modelName&&QC(i,t.toolNames)?t:{modelName:r,toolNames:i}},Xy=ce(()=>{const e=ie(()=>new dd,[]),[t,n]=kt(()=>Xi(e,GC));return Ne(()=>(n(r=>Xi(e,r)),e.subscribe(()=>{n(r=>Xi(e,r))})),[e]),{getState:()=>Xi(e,t),getModelContext:()=>e.getModelContext(),subscribe:r=>e.subscribe(r),register:r=>e.registerModelContextProvider(r)}}),YC=e=>e.display!==void 0?e.display==="standalone":e.type==="human",JC=(e,t)=>{if(!(t.status?.type==="running"||t.status?.type==="requires-action")){const r=e.complete;return typeof r!="function"?r??null:r({args:t.args,result:t.result})}const n=e.running;return typeof n!="function"?n??null:n({args:t.args})},XC=e=>function(n){return JC(e,n)},Hu=Symbol("assistant-ui.store.clientIndex"),ZC=e=>e[Hu],Zy=Qy([]),fd=()=>Jy(Zy),e0=(e,t)=>{const n=fd();return Yy(Zy,ie(()=>[...n,e],[n,e]),t)},t0=new Set(["$$typeof","nodeType","then"]),Da=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!="symbol"){if(e==="toJSON")return()=>t;if(!t0.has(e))return!1}};var hd=class{getOwnPropertyDescriptor(e,t){const n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!1}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}};const ev=e=>{const t=ce(e);return n=>{const r=t(n);return n.key===void 0?r:rn(n.key,r)}},ea=Symbol("assistant-ui.store.getValue"),n0=e=>{const t=e[ea];if(!t)throw new Error("Client scope contains a non-client resource. Ensure your Derived get() returns a client created with tapClientResource(), not a plain resource.");return t.getState?.()},yh=new Map;function r0(e){let t=yh.get(e);return t||(t=function(...n){if(!this||typeof this!="object")throw new Error(`Method "${String(e)}" called without proper context. This may indicate the function was called incorrectly.`);const r=this[ea];if(!r)throw new Error(`Method "${String(e)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);const s=r[e];if(!s)throw new Error(`Method "${String(e)}" is not implemented.`);if(typeof s!="function")throw new Error(`"${String(e)}" is not a function.`);return s(...n)},yh.set(e,t)),t}var s0=class extends hd{constructor(t,n){super();T(this,"outputRef");T(this,"index");T(this,"boundFns");T(this,"cachedReceiver");this.outputRef=t,this.index=n}get(t,n,r){if(n===ea)return this.outputRef.current;if(n===Hu)return this.index;const s=Da(n,"ClientProxy");if(s!==!1)return s;const i=this.outputRef.current[n];if(typeof i=="function"){this.cachedReceiver!==r&&(this.boundFns=new Map,this.cachedReceiver=r);let o=this.boundFns.get(n);return o||(o=r0(n).bind(r),this.boundFns.set(n,o)),o}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(t,n){return n===ea||n===Hu?!0:n in this.outputRef.current}};const tv=ev(e=>{const t=tn(null),n=fd().length,r=ie(()=>new Proxy({},new s0(t,n)),[n]),s=e0(r,()=>He(e));return t.current||(t.current=s),Ne(()=>{t.current=s}),{methods:r,state:s.getState?.(),key:e.key}}),La=e=>He(tv(e)),Qs=Symbol("assistant-ui.store.proxiedAssistantState"),Cl=e=>e==="on"||e==="subscribe"||typeof e=="symbol",nv=e=>{class t extends hd{get(r,s){const i=Da(s,"AssistantState");if(i!==!1)return i;const o=s;if(!Cl(o))return n0(e[o]())}ownKeys(){return Object.keys(e).filter(r=>!Cl(r))}has(r,s){return!Cl(s)&&s in e}}return new Proxy({},new t)},i0=e=>e[Qs],vh=()=>()=>{},rv=e=>{const t=()=>{throw new Error(e)};return t.source=null,t.query=null,t};var o0=class extends hd{get(e,t){if(t==="subscribe"||t==="on")return vh;if(t===Qs)return a0;const n=Da(t,"DefaultAssistantClient");return n!==!1?n:rv("You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.")}ownKeys(){return["subscribe","on",Qs]}has(e,t){return t==="subscribe"||t==="on"||t===Qs}};const Oa=new Proxy({},new o0),a0=nv(Oa),l0=()=>new Proxy({},{get(e,t){const n=Da(t,"AssistantClient");return n!==!1?n:rv(`The current scope does not have a "${String(t)}" property.`)}}),sv=m.createContext(Oa),u0=()=>m.useContext(sv),wn=({value:e,children:t})=>c.jsx(sv.Provider,{value:e,children:t}),At=ce(e=>null),Wu=Symbol("assistant-ui.transform-scopes");function iv(e,t){const n=e;if(n[Wu])throw new Error("transformScopes is already attached to this resource");n[Wu]=t}function c0(e){return e[Wu]}const ov=e=>typeof e=="string"?{scope:e.split(".")[0],event:e}:{scope:e.scope,event:e.event},av=Qy(null),d0=(e,t)=>Yy(av,e,t),lv=()=>{const e=Jy(av);if(!e)throw new Error("AssistantTapContext is not available");return e},uv=()=>lv().clientRef,pd=()=>{const{emit:e}=lv(),t=fd();return nn((n,r)=>{e(n,r,t)})};function f0(e,t){const n={...e},r=new Set;let s=!0;for(;s;){s=!1;for(const a of Object.values(n)){if(a.type===At||r.has(a.type))continue;r.add(a.type);const l=c0(a.type);if(l){l(n,t),s=!0;break}}}const i={},o={};for(const[a,l]of Object.entries(n))l.type===At?o[a]=l:i[a]=l;return{rootClients:i,derivedClients:o}}const xh=e=>ie(()=>e,[...Object.entries(e).flat()]),h0=(e,t)=>{const{rootClients:n,derivedClients:r}=f0(e,t);return{rootClients:xh(n),derivedClients:xh(r)}},p0=ce(()=>ar(()=>{const e=new Map,t=new Set,n=new Set;return{on(r,s){const i=s;if(r==="*")return t.add(i),()=>t.delete(i);let o=e.get(r);return o||(o=new Set,e.set(r,o)),o.add(i),()=>{o.delete(i),o.size===0&&e.delete(r)}},emit(r,s,i){const o=e.get(r);!o&&t.size===0||queueMicrotask(()=>{const a=[];if(o)for(const l of o)try{l(s,i)}catch(u){a.push(u)}if(t.size>0){const l={event:r,payload:s};for(const u of t)try{u(l,i)}catch(f){a.push(f)}}if(a.length>0){if(a.length===1)throw a[0];for(const l of a)console.error(l);throw new AggregateError(a,"Errors occurred during event emission")}})},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)}}}})),m0=()=>null;function cv(e){const t=m.useMemo(()=>Wy(a=>r(a)),[]),[n,r]=m.useReducer((a,l)=>(Ks(t,a),a+(l()?1:0)),0);Ks(t,n);const s=m0(),i=m.useMemo(()=>(e.key,wi(e.type,t,void 0,s)),[e.type,e.key,t,s]),o=Bn(i,e.props);return m.useLayoutEffect(()=>()=>Qr(i),[i]),m.useLayoutEffect(()=>{Zo(t),ss(i,o)}),o.output}const dv=e=>ie(()=>e,e),g0=ce(({element:e,emit:t,clientRef:n})=>{const{methods:r,state:s}=d0({clientRef:n,emit:t},()=>La(e));return ie(()=>({state:s,methods:r}),[r,s])}),y0=ce(({element:e,notifications:t,clientRef:n,name:r})=>{const s=WC(g0({element:e,emit:t.emit,clientRef:n}));return Ne(()=>s.subscribe(t.notifySubscribers),[s,t]),ie(()=>{const i=()=>s.getValue().methods;return Object.defineProperties(i,{source:{value:"root",writable:!1},query:{value:{},writable:!1},name:{value:r,configurable:!0}}),i},[s,r])}),v0=ce(()=>ie(()=>({clients:[],subscribe:void 0,on:void 0}),[])),x0=ce(({clients:e,clientRef:t})=>{const n=He(p0());Ne(()=>t.parent.subscribe(n.notifySubscribers),[t,n]);const r=dv(Ma(()=>Object.keys(e).map(s=>rn(s,y0({element:e[s],notifications:n,clientRef:t,name:s}))),[e,n,t]));return ie(()=>({clients:r,subscribe:n.subscribe,on:function(s,i){if(!this)throw new Error("const { on } = useAui() is not supported. Use aui.on() instead.");const{scope:o,event:a}=ov(s);if(o!=="*"&&this[o].source===null)throw new Error(`Scope "${o}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);const l=n.on(a,(f,d)=>{if(o==="*"){i(f);return}const h=this[o]();h===d[ZC(h)]&&i(f)});if(o!=="*"&&t.parent[o].source===null)return l;const u=t.parent.on(s,i);return()=>{l(),u()}}}),[r,n,t])}),w0=ce(({element:e,clientRef:t,name:n})=>{const r=tn(e.props);return r.current=e.props,ie(()=>{const s=()=>r.current.get(t.current);return Object.defineProperties(s,{source:{value:r.current.source},query:{value:r.current.query},name:{value:n,configurable:!0}}),s},[t,n])}),b0=(e,t)=>{let n;try{const r={};for(const s of Object.keys(t.query).sort())r[s]=t.query[s];n=JSON.stringify(r)}catch{n=String(t.query)}return`${e}::${t.source}::${n}`},S0=ce(({clients:e,clientRef:t})=>dv(Ma(()=>Object.keys(e).map(n=>{const r=n,s=e[r];return rn(b0(r,s.props),w0({element:s,clientRef:t,name:r}))}),[e,t]))),k0=ce(({parent:e,clients:t})=>{const{rootClients:n,derivedClients:r}=h0(t,e),s=tn({parent:e,current:null}).current;Ne(()=>{s.current=a});const i=He(Object.keys(n).length>0?x0({clients:n,clientRef:s}):v0()),o=He(S0({clients:r,clientRef:s})),a=ie(()=>{const l=e===Oa?l0():e,u=Object.create(l);Object.assign(u,{subscribe:i.subscribe??e.subscribe,on:i.on??e.on,[Qs]:nv(u)});for(const f of i.clients)u[f.name]=f;for(const f of o)u[f.name]=f;return u},[e,i,o]);return s.current===null&&(s.current=a),a});function se(e,{parent:t}={parent:u0()}){if(e)return cv(k0({parent:t??Oa,clients:e}));if(t===null)throw new Error("received null parent, this usage is not allowed");return t}const V=e=>{const t=se(),n=i0(t),r=m.useSyncExternalStore(t.subscribe,()=>e(n),()=>e(n));if(r===n)throw new Error("You tried to return the entire AssistantState. This is not supported due to technical limitations.");return m.useDebugValue(r),r},C0=e=>{const t=se(),n=m.useRef(!1),r=n.current?null:e(t);return V(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},_0=Object.freeze({});function fs({getItemState:e,children:t}){return E0(t(C0(e)))}const E0=e=>{const t=typeof e=="object"&&e!=null&&"type"in e?e:null,n=t?.type,r=t?.key;return m.useMemo(()=>t,[n,r,typeof t?.props=="object"&&t.props!=null&&Object.entries(t.props).length===0?_0:t?.props])??e},T0=ut.createContext(!0);function wh(){throw new Error("A function wrapped in useEffectEvent can't be called during rendering.")}const I0="use"in ut?()=>{try{return ut.use(T0)}catch{return!1}}:()=>!1;function R0(e){const t=ut.useRef(wh);return ut.useInsertionEffect(()=>{t.current=e},[e]),(...n)=>{I0()&&wh();const r=t.current;return r(...n)}}const ta=(e,t)=>{const n=se(),r=R0(t),{scope:s,event:i}=ov(e);m.useEffect(()=>n.on({scope:s,event:i},r),[n,s,i])},P0=ev(e=>{if(e.key===void 0)throw new Error("tapClientResource: Element has no key");return He(tv(e))});function is(e,t){const n=Ma(()=>e().map(i=>P0(i)),t),r=ie(()=>Object.keys(n),[n]),s=ie(()=>n.reduce((i,o,a)=>(i[o.key]=a,i),{}),[n]);return{state:ie(()=>n.map(i=>i.state),[n]),get:i=>{if("index"in i){if(i.index<0||i.index>=r.length)throw new Error(`tapClientLookup: Index ${i.index} out of bounds (length: ${r.length})`);return n[i.index].methods}const o=s[i.key];if(o===void 0)throw new Error(`tapClientLookup: Key "${i.key}" not found`);return n[o].methods}}}const fv=ce(({toolkit:e,mcpApp:t})=>{const n=Ma(()=>t?[rn("mcpApp",t)]:[],[t])[0],[r,s]=kt(()=>({})),i=ie(()=>({toolUIs:r,mcpApp:n,tools:Object.fromEntries(Object.entries(r).map(([l,u])=>[l,u.map(f=>f.render)]))}),[r,n]),o=uv(),a=xi((l,u,f)=>{const d={render:u,standalone:f?.standalone??!1};return s(h=>({...h,[l]:[...h[l]??[],d]})),()=>{s(h=>{const p=h[l]?.filter(S=>S!==d)??[];if(p.length>0)return{...h,[l]:p};const{[l]:g,...v}=h;return v})}},[]);return Ne(()=>{if(!e)return;const l=[];for(const[f,d]of Object.entries(e)){const h="render"in d?d.render:void 0,p="renderText"in d?d.renderText:void 0,g=h??(p?XC(p):void 0);g&&l.push(a(f,g,{standalone:YC(d)}))}const u=Object.entries(e).reduce((f,[d,h])=>{if(h.type==="mcp")return f;const{display:p,render:g,renderText:v,...S}=h;return f[d]=S,f},{});return l.push(o.current.modelContext().register({getModelContext:()=>({tools:u})})),()=>{l.forEach(f=>f())}},[e,a,o]),{getState:()=>i,setToolUI:a}});iv(fv,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=Xy())});const xr=e=>{const[,t]=kt(e.getState);return Ne(()=>(t(e.getState()),e.subscribe(()=>{t(e.getState())})),[e]),e.getState()},hv=ce(({runtime:e})=>{const t=xr(e);return{getState:()=>t,remove:e.remove,__internal_getRuntime:()=>e}}),A0=ce(({runtime:e,index:t})=>He(hv({runtime:ie(()=>e.getAttachmentByIndex(t),[e,t])}))),pv=ce(({threadIdRef:e,messageIdRef:t,runtime:n})=>{const r=xr(n),s=pd();Ne(()=>{const a=[];for(const l of["send","attachmentAdd"]){const u=n.unstable_on(l,()=>{s(`composer.${l}`,{threadId:e.current,...t&&{messageId:t.current}})});a.push(u)}return a.push(n.unstable_on("attachmentAddError",l=>{s("composer.attachmentAddError",{threadId:e.current,...t&&{messageId:t.current},...l.attachmentId&&{attachmentId:l.attachmentId},reason:l.reason,message:l.message})})),()=>{for(const l of a)l()}},[n,s,e,t]);const i=is(()=>r.attachments.map((a,l)=>rn(a.id,A0({runtime:n,index:l}))),[r.attachments,n]),o=ie(()=>({text:r.text,role:r.role,attachments:i.state,runConfig:r.runConfig,isEditing:r.isEditing,canCancel:r.canCancel,canSend:r.canSend,attachmentAccept:r.attachmentAccept,isEmpty:r.isEmpty,type:r.type??"thread",dictation:r.dictation,quote:r.quote,queue:[]}),[r,i.state]);return{getState:()=>o,setText:n.setText,setRole:n.setRole,setRunConfig:n.setRunConfig,addAttachment:n.addAttachment,reset:n.reset,clearAttachments:n.clearAttachments,send:n.send,cancel:n.cancel,beginEdit:n.beginEdit??(()=>{throw new Error("beginEdit is not supported in this runtime")}),startDictation:n.startDictation,stopDictation:n.stopDictation,setQuote:n.setQuote,attachment:a=>"id"in a?i.get({key:a.id}):i.get(a),queueItem:()=>{throw new Error("Queue is not supported in this runtime")},__internal_getRuntime:()=>n}}),j0=ce(({runtime:e})=>{const t=xr(e);return{getState:()=>t,addToolResult:n=>e.addToolResult(n),resumeToolCall:n=>e.resumeToolCall(n),respondToToolApproval:n=>e.respondToToolApproval(n),__internal_getRuntime:()=>e}}),N0=ce(({runtime:e,index:t})=>He(hv({runtime:ie(()=>e.getAttachmentByIndex(t),[e,t])}))),M0=ce(({runtime:e,index:t})=>He(j0({runtime:ie(()=>e.getMessagePartByIndex(t),[e,t])}))),D0=ce(({runtime:e,threadIdRef:t})=>{const n=xr(e),[r,s]=kt(!1),[i,o]=kt(!1),a=ie(()=>({get current(){return e.getState().id}}),[e]),l=La(pv({runtime:e.composer,threadIdRef:t,messageIdRef:a})),u=is(()=>n.content.map((h,p)=>rn("toolCallId"in h&&h.toolCallId!=null?`toolCallId-${h.toolCallId}`:`index-${p}`,M0({runtime:e,index:p}))),[n.content,e]),f=is(()=>(n.attachments??[]).map((h,p)=>rn(h.id,N0({runtime:e,index:p}))),[n.attachments,e]),d=ie(()=>({...n,parts:u.state,composer:l.state,isCopied:r,isHovering:i}),[n,u.state,l.state,r,i]);return{getState:()=>d,composer:()=>l.methods,reload:h=>e.reload(h),speak:()=>e.speak(),stopSpeaking:()=>e.stopSpeaking(),submitFeedback:h=>e.submitFeedback(h),switchToBranch:h=>e.switchToBranch(h),getCopyText:()=>e.unstable_getCopyText(),part:h=>"index"in h?u.get({index:h.index}):u.get({key:`toolCallId-${h.toolCallId}`}),attachment:h=>"id"in h?f.get({key:h.id}):f.get(h),setIsCopied:s,setIsHovering:o,__internal_getRuntime:()=>e}}),L0=ce(({runtime:e,id:t,threadIdRef:n})=>He(D0({runtime:ie(()=>e.getMessageById(t),[e,t]),threadIdRef:n}))),O0=ce(({runtime:e})=>{const t=xr(e),n=pd();Ne(()=>{const a=[];for(const l of["runStart","runEnd","initialize","modelContextUpdate"]){const u=e.unstable_on(l,()=>{const f=e.getState()?.threadId||"unknown";n(`thread.${l}`,{threadId:f})});a.push(u)}return()=>{for(const l of a)l()}},[e,n]);const r=ie(()=>({get current(){return e.getState().threadId}}),[e]),s=La(pv({runtime:e.composer,threadIdRef:r})),i=is(()=>t.messages.map(a=>rn(a.id,L0({runtime:e,id:a.id,threadIdRef:r}))),[t.messages,e,r]),o=ie(()=>({isEmpty:i.state.length===0&&!t.isLoading,isDisabled:t.isDisabled,isLoading:t.isLoading,isRunning:t.isRunning,capabilities:t.capabilities,state:t.state,suggestions:t.suggestions,extras:t.extras,speech:t.speech,voice:t.voice,composer:s.state,messages:i.state}),[t,i,s.state]);return{getState:()=>o,composer:()=>s.methods,append:e.append,startRun:e.startRun,resumeRun:e.resumeRun,cancelRun:e.cancelRun,getModelContext:e.getModelContext,export:e.export,import:e.import,reset:e.reset,stopSpeaking:e.stopSpeaking,connectVoice:e.connectVoice,disconnectVoice:e.disconnectVoice,getVoiceVolume:e.getVoiceVolume,subscribeVoiceVolume:e.subscribeVoiceVolume,muteVoice:e.muteVoice,unmuteVoice:e.unmuteVoice,message:a=>"id"in a?i.get({key:a.id}):i.get(a),__internal_getRuntime:()=>e}}),z0=ce(({runtime:e})=>{const t=xr(e),n=pd();return Ne(()=>{const r=[];for(const s of["switchedTo","switchedAway"]){const i=e.unstable_on(s,()=>{n(`threadListItem.${s}`,{threadId:e.getState().id})});r.push(i)}return()=>{for(const s of r)s()}},[e,n]),{getState:()=>t,switchTo:e.switchTo,rename:e.rename,updateCustom:e.updateCustom,archive:e.archive,unarchive:e.unarchive,delete:e.delete,generateTitle:e.generateTitle,initialize:e.initialize,detach:e.detach,__internal_getRuntime:()=>e}}),F0=ce(({runtime:e,id:t})=>He(z0({runtime:ie(()=>e.getItemById(t),[e,t])}))),B0=ce(({runtime:e,__internal_assistantRuntime:t})=>{const n=xr(e),r=La(O0({runtime:e.main})),s=is(()=>Object.keys(n.threadItems).map(o=>rn(o,F0({runtime:e,id:o}))),[n.threadItems,e]),i=ie(()=>({mainThreadId:n.mainThreadId,newThreadId:n.newThreadId??null,isLoading:n.isLoading,isLoadingMore:n.isLoadingMore,hasMore:n.hasMore,threadIds:n.threadIds,archivedThreadIds:n.archivedThreadIds,threadItems:s.state,main:r.state}),[n,s.state,r.state]);return{getState:()=>i,thread:()=>r.methods,item:o=>{if(o==="main")return s.get({key:i.mainThreadId});if("id"in o)return s.get({key:o.id});const{index:a,archived:l=!1}=o,u=l?i.archivedThreadIds[a]:i.threadIds[a];return s.get({key:u})},switchToThread:async(o,a)=>{await e.switchToThread(o,a)},switchToNewThread:async()=>{await e.switchToNewThread()},getLoadThreadsPromise:()=>e.getLoadThreadsPromise(),reload:()=>e.reload(),loadMore:()=>e.loadMore(),__internal_getAssistantRuntime:()=>t}}),$0=ce(e=>({getState:()=>e})),U0=ce(e=>{const[t]=kt(()=>({suggestions:(e??[]).map(r=>typeof r=="string"?{title:r,label:"",prompt:r}:{title:r.title,label:r.label,prompt:r.prompt})})),n=is(()=>t.suggestions.map((r,s)=>rn(s,$0(r))),[t.suggestions]);return{getState:()=>t,suggestion:({index:r})=>n.get({index:r})}}),V0=ce(e=>{const t=uv();return Ne(()=>e.registerModelContextProvider(t.current.modelContext()),[e,t]),He(B0({runtime:e.threads,__internal_assistantRuntime:e}))}),H0=(e,t)=>{e.thread??(e.thread=At({source:"threads",query:{type:"main"},get:n=>n.threads().thread("main")})),e.threadListItem??(e.threadListItem=At({source:"threads",query:{type:"main"},get:n=>n.threads().item("main")})),e.composer??(e.composer=At({source:"thread",query:{},get:n=>n.threads().thread("main").composer()})),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=Xy()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=U0())},mv=ce(e=>He(V0(e)));iv(mv,(e,t)=>{H0(e,t),!e.tools&&t.tools.source===null&&(e.tools=fv({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=qC())});const W0=e=>e._core?.RenderComponent,q0=m.memo(({runtime:e,aui:t=null,children:n})=>{const r=se({threads:mv(e)},{parent:t}),s=W0(e);return c.jsxs(wn,{value:r,children:[s&&c.jsx(s,{}),n]})}),bh=e=>{let t;const n=new Set,r=(u,f)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(p=>p(t,h))}},s=()=>t,a={setState:r,getState:s,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u))},l=t=e(r,s,a);return a},K0=e=>e?bh(e):bh,G0=e=>e;function Q0(e,t=G0){const n=ut.useSyncExternalStore(e.subscribe,ut.useCallback(()=>t(e.getState()),[e,t]),ut.useCallback(()=>t(e.getInitialState()),[e,t]));return ut.useDebugValue(n),n}const Sh=e=>{const t=K0(e),n=r=>Q0(t,r);return Object.assign(n,t),n},gv=e=>e?Sh(e):Sh,md=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});if(!e||!t)throw new Error("Failed to create promise");return{promise:n,resolve:e,reject:t}},Y0=()=>{const e=[];let t=!1,n,r;const s=i=>{i.promise||(i.promise=i.reader.read().then(({done:o,value:a})=>{i.promise=void 0,o?(e.splice(e.indexOf(i),1),t&&e.length===0&&n.close()):n.enqueue(a),r?.resolve(),r=void 0}).catch(o=>{console.error(o),e.forEach(a=>{a.reader.cancel()}),e.length=0,n.error(o),r?.reject(o),r=void 0}))};return{readable:new ReadableStream({start(i){n=i},pull(){return r=md(),e.forEach(i=>{s(i)}),r.promise},cancel(){e.forEach(i=>{i.reader.cancel()}),e.length=0}}),isSealed(){return t},seal(){t=!0,e.length===0&&n.close()},addStream(i){if(t)throw new Error("Cannot add streams after the run callback has settled.");const o={reader:i.getReader()};e.push(o),s(o)},enqueue(i){this.addStream(new ReadableStream({start(o){o.enqueue(i),o.close()}}))}}};var kh=class{constructor(e){T(this,"_controller");T(this,"_isClosed",!1);this._controller=e}append(e){return this._controller.enqueue({type:"text-delta",path:[],textDelta:e}),this}close(){this._isClosed||(this._isClosed=!0,this._controller.enqueue({type:"part-finish",path:[]}),this._controller.close())}};const yv=e=>new ReadableStream({start(t){return e.start?.(new kh(t))},pull(t){return e.pull?.(new kh(t))},cancel(t){return e.cancel?.(t)}}),Ch=()=>{let e;return[yv({start(t){e=t}}),e]};var _h=class{constructor(e){T(this,"_controller");T(this,"_isClosed",!1);T(this,"_mergeTask");T(this,"_argsTextController");this._controller=e;const t=yv({start:r=>{this._argsTextController=r}});let n=!1;this._mergeTask=t.pipeTo(new WritableStream({write:r=>{switch(r.type){case"text-delta":n=!0,this._controller.enqueue(r);break;case"part-finish":n||this._controller.enqueue({type:"text-delta",textDelta:"{}",path:[]}),this._controller.enqueue({type:"tool-call-args-text-finish",path:[]});break;default:throw new Error(`Unexpected chunk type: ${r.type}`)}}}))}get argsText(){return this._argsTextController}async setResponse(e){this._argsTextController.close(),await Promise.resolve(),this._controller.enqueue({type:"result",path:[],...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}:{}})}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,this._controller.enqueue({type:"part-finish",path:[]}),this._controller.close())}};const J0=e=>new ReadableStream({start(t){return e.start?.(new _h(t))},pull(t){return e.pull?.(new _h(t))},cancel(t){return e.cancel?.(t)}}),X0=()=>{let e;return[J0({start(t){e=t}}),e]};var vv=class{constructor(){T(this,"value",-1)}up(){return++this.value}},Z0=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};(class extends TransformStream{constructor(e){super({transform(t,n){const{path:[r,...s]}=t;if(e!==r)throw new Error(`Path mismatch: expected ${e}, got ${r}`);n.enqueue({...t,path:s})}})}});var e_=class extends TransformStream{constructor(e){const t=new vv,n=new Map;super({transform(r,s){r.type==="part-start"&&r.path.length===0&&n.set(t.up(),e.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]})}})}},t_=class extends TransformStream{constructor(e){super();const t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},xv=class extends TransformStream{constructor(){const e=[];super({transform(t,n){if(t.type==="part-start"){if(t.path.length!==0){n.error(new Error("Nested parts are not supported"));return}e.push(t.part),n.enqueue(t);return}if(t.type==="text-delta"||t.type==="result"||t.type==="part-finish"||t.type==="tool-call-args-text-finish"){if(t.path.length!==1){n.error(new Error(`${t.type} chunks must have a path of length 1`));return}const r=t.path[0];if(r<0||r>=e.length){n.error(new Error(`Invalid path index: ${r}`));return}const s=e[r];n.enqueue({...t,meta:s});return}n.enqueue(t)}})}};let wv=(e,t=21)=>(n=t)=>{let r="",s=n|0;for(;s--;)r+=e[Math.random()*e.length|0];return r};const n_=wv("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7);var r_=class bv{constructor(t){T(this,"_state");T(this,"_parentId");this._state=t||{merger:Y0(),contentCounter:new vv}}get __internal_isClosed(){return this._state.merger.isSealed()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(t){this._state.closeSubscriber=t}_addPart(t,n){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:"part-start",part:t,path:[]}),this._state.merger.addStream(n.pipeThrough(new Z0(this._state.contentCounter.value)))}merge(t){this._state.merger.addStream(t.pipeThrough(new e_(this._state.contentCounter)))}appendText(t){(this._state.append?.kind!=="text"||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:"text",parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(t)}appendReasoning(t){(this._state.append?.kind!=="reasoning"||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:"reasoning",parentId:this._parentId,controller:this.addReasoningPart()}),this._state.append.controller.append(t)}addTextPart(){const[t,n]=Ch();return this._addPart(this._withParentIdOption({type:"text"}),t),n}addReasoningPart(){const[t,n]=Ch();return this._addPart(this._withParentIdOption({type:"reasoning"}),t),n}addToolCallPart(t){const n=typeof t=="string"?{toolName:t}:t,r=n.toolName,s=n.toolCallId??n_(),[i,o]=X0();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(t){t.enqueue({type:"part-finish",path:[]}),t.close()}})}_withParentIdOption(t){return this._parentId?{...t,parentId:this._parentId}:t}appendSource(t){this._addPart(this._withParentIdOption(t),this._finishedPartStream())}appendFile(t){this._addPart(this._withParentIdOption(t),this._finishedPartStream())}appendData(t){this._addPart(this._withParentIdOption(t),this._finishedPartStream())}enqueue(t){this._state.merger.enqueue(t),t.type==="part-start"&&t.path.length===0&&this._state.contentCounter.up()}withParentId(t){const n=new bv(this._state);return n._parentId=t,n}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function s_(e){const t=new r_;return(async()=>{try{await e(t)}catch(r){throw t.__internal_isClosed||t.enqueue({type:"error",path:[],error:String(r)}),r}finally{t.__internal_isClosed||t.close()}})(),t.__internal_getReadable()}function i_(){const{resolve:e,promise:t}=md();let n;return[s_(r=>(n=r,n.__internal_subscribeToClose(e),t)),n]}function o_(e){const t=["ROOT"];let n=-1,r=null;const s=[];let i;function o(){i!==void 0&&(s.push(JSON.parse(`"${i}"`)),i=void 0)}function a(d,h,p){switch(d){case'"':n=h,t.pop(),t.push(p),t.push("INSIDE_STRING"),o();break;case"f":case"t":case"n":n=h,r=h,t.pop(),t.push(p),t.push("INSIDE_LITERAL");break;case"-":t.pop(),t.push(p),t.push("INSIDE_NUMBER"),o();break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n=h,t.pop(),t.push(p),t.push("INSIDE_NUMBER"),o();break;case"{":n=h,t.pop(),t.push(p),t.push("INSIDE_OBJECT_START"),o();break;case"[":n=h,t.pop(),t.push(p),t.push("INSIDE_ARRAY_START"),o();break}}function l(d,h){switch(d){case",":t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break;case"}":n=h,t.pop(),i=s.pop();break}}function u(d,h){switch(d){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA"),i=(Number(i)+1).toString();break;case"]":n=h,t.pop(),i=s.pop();break}}for(let d=0;d<e.length;d++){const h=e[d];switch(t[t.length-1]){case"ROOT":a(h,d,"FINISH");break;case"INSIDE_OBJECT_START":switch(h){case'"':t.pop(),t.push("INSIDE_OBJECT_KEY"),i="";break;case"}":n=d,t.pop(),i=s.pop();break}break;case"INSIDE_OBJECT_AFTER_COMMA":switch(h){case'"':t.pop(),t.push("INSIDE_OBJECT_KEY"),i="";break}break;case"INSIDE_OBJECT_KEY":switch(h){case'"':t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break;case"\\":t.push("INSIDE_STRING_ESCAPE"),i+=h;break;default:i+=h;break}break;case"INSIDE_OBJECT_AFTER_KEY":switch(h){case":":t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}break;case"INSIDE_OBJECT_BEFORE_VALUE":a(h,d,"INSIDE_OBJECT_AFTER_VALUE");break;case"INSIDE_OBJECT_AFTER_VALUE":l(h,d);break;case"INSIDE_STRING":switch(h){case'"':t.pop(),n=d,i=s.pop();break;case"\\":t.push("INSIDE_STRING_ESCAPE");break;default:n=d}break;case"INSIDE_ARRAY_START":switch(h){case"]":n=d,t.pop(),i=s.pop();break;default:n=d,i="0",a(h,d,"INSIDE_ARRAY_AFTER_VALUE");break}break;case"INSIDE_ARRAY_AFTER_VALUE":switch(h){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA"),i=(Number(i)+1).toString();break;case"]":n=d,t.pop(),i=s.pop();break;default:n=d;break}break;case"INSIDE_ARRAY_AFTER_COMMA":a(h,d,"INSIDE_ARRAY_AFTER_VALUE");break;case"INSIDE_STRING_ESCAPE":t.pop(),t[t.length-1]==="INSIDE_STRING"?n=d:t[t.length-1]==="INSIDE_OBJECT_KEY"&&(i+=h);break;case"INSIDE_NUMBER":switch(h){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n=d;break;case"e":case"E":case"-":case".":break;case",":t.pop(),i=s.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,d),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(h,d);break;case"}":t.pop(),i=s.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(h,d);break;case"]":t.pop(),i=s.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,d);break;default:t.pop(),i=s.pop();break}break;case"INSIDE_LITERAL":{const p=e.substring(r,d+1);!"false".startsWith(p)&&!"true".startsWith(p)&&!"null".startsWith(p)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?l(h,d):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,d)):n=d;break}}}let f=e.slice(0,n+1);for(let d=t.length-1;d>=0;d--)switch(t[d]){case"INSIDE_STRING":f+='"';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":f+="}";break;case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":f+="]";break;case"INSIDE_LITERAL":{const h=e.substring(r,e.length);"true".startsWith(h)?f+="true".slice(h.length):"false".startsWith(h)?f+="false".slice(h.length):"null".startsWith(h)&&(f+="null".slice(h.length))}}return[f,s]}var hs={exports:{}};const a_=typeof Buffer<"u",Eh=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Th=/"(?: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 Sv(e,t,n){n==null&&t!==null&&typeof t=="object"&&(n=t,t=void 0),a_&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));const r=JSON.parse(e,t);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(Eh.test(e)===!1&&Th.test(e)===!1)return r}else if(s!=="ignore"&&i==="ignore"){if(Eh.test(e)===!1)return r}else if(Th.test(e)===!1)return r;return kv(r,{protoAction:s,constructorAction:i,safe:n&&n.safe})}function kv(e,{protoAction:t="error",constructorAction:n="error",safe:r}={}){let s=[e];for(;s.length;){const i=s;s=[];for(const o of i){if(t!=="ignore"&&Object.prototype.hasOwnProperty.call(o,"__proto__")){if(r===!0)return null;if(t==="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 e}function gd(e,t,n){const{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return Sv(e,t,n)}finally{Error.stackTraceLimit=r}}function l_(e,t){const{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return Sv(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}hs.exports=gd;hs.exports.default=gd;hs.exports.parse=gd;hs.exports.safeParse=l_;hs.exports.scan=kv;var u_=hs.exports;const qu=Ei(u_),ko=Symbol("aui.parse-partial-json-object.meta"),c_=e=>e?.[ko],Ku=e=>{if(e.length===0)return{[ko]:{state:"partial",partialPath:[]}};try{const t=qu.parse(e);if(typeof t!="object"||t===null)throw new Error("argsText is expected to be an object");return t[ko]={state:"complete",partialPath:[]},t}catch{try{const[t,n]=o_(e),r=qu.parse(t);if(typeof r!="object"||r===null)throw new Error("argsText is expected to be an object");return r[ko]={state:"partial",partialPath:n},r}catch{return}}},Cv=(e,t,n)=>{if(typeof e!="object"||e===null)return t.state;if(t.state==="complete")return"complete";if(n.length===0)return t.state;const[r,...s]=n;if(!Object.hasOwn(e,r))return"partial";const[i,...o]=t.partialPath;if(r!==i)return"complete";const a=e[r];return Cv(a,{state:"partial",partialPath:o},s)},os=(e,t)=>{const n=c_(e);if(!n)throw new Error("unable to determine object state");return Cv(e,n,t.map(String))};async function*d_(){const e=this.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{e.releaseLock()}}function _l(e){var t;return e[t=Symbol.asyncIterator]??(e[t]=d_),e}const Ih=Symbol.for("aui.tool-response");var hn=class Gu{constructor(t){T(this,"artifact");T(this,"result");T(this,"isError");T(this,"modelContent");T(this,"messages");t.artifact!==void 0&&(this.artifact=t.artifact),this.result=t.result,this.isError=t.isError??!1,t.modelContent!==void 0&&(this.modelContent=t.modelContent),t.messages!==void 0&&(this.messages=t.messages)}get[Ih](){return!0}static[Symbol.hasInstance](t){return typeof t=="object"&&t!==null&&Ih in t}static toResponse(t){return t instanceof Gu?t:new Gu({result:t===void 0?"<no result>":t})}};function f_(e,t,n){try{const r=e();if(typeof r=="object"&&r!==null&&"then"in r)return r.then(t,n);t(r)}catch(r){n(r)}}function as(e,t){let n=e;for(const r of t){if(n==null)return;n=n[r]}return n}var h_=class{constructor(e,t,n){T(this,"resolve");T(this,"reject");T(this,"disposed",!1);T(this,"fieldPath");this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(os(e,this.fieldPath)==="complete"){const t=as(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(t){this.reject(t),this.dispose()}}end(e){if(!this.disposed)try{const t=as(e,this.fieldPath);this.resolve(t)}catch(t){this.reject(t)}finally{this.dispose()}}dispose(){this.disposed=!0}},p_=class{constructor(e,t){T(this,"controller");T(this,"disposed",!1);T(this,"fieldPath");this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{const t=as(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),os(e,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(t){this.controller.error(t),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},m_=class{constructor(e,t){T(this,"controller");T(this,"disposed",!1);T(this,"fieldPath");T(this,"lastValue");this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{const t=as(e,this.fieldPath);if(t!==void 0&&typeof t=="string"){const n=t.substring(this.lastValue?.length||0);this.lastValue=t,this.controller.enqueue(n)}os(e,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(t){this.controller.error(t),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},g_=class{constructor(e,t){T(this,"controller");T(this,"disposed",!1);T(this,"fieldPath");T(this,"processedIndexes",new Set);this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{const t=as(e,this.fieldPath);if(!Array.isArray(t))return;for(let n=0;n<t.length;n++)this.processedIndexes.has(n)||os(e,[...this.fieldPath,n])==="complete"&&(this.controller.enqueue(t[n]),this.processedIndexes.add(n));os(e,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(t){this.controller.error(t),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},y_=class{constructor(e){T(this,"argTextDeltas");T(this,"handles",new Set);T(this,"args",Ku(""));T(this,"finished",!1);this.argTextDeltas=e,this.processStream()}async processStream(){try{let e="";const t=this.argTextDeltas.getReader();for(;;){const{value:n,done:r}=await t.read();if(r)break;e+=n;const s=Ku(e);if(s!==void 0){this.args=s;for(const i of this.handles)i.update(s)}}}catch(e){console.error("Error processing argument stream:",e)}finally{this.finished=!0;for(const e of this.handles)e.end(this.args);this.handles.clear()}}get(...e){return new Promise((t,n)=>{const r=new h_(t,n,e);if(this.args&&os(this.args,e)==="complete"){const s=as(this.args,e);if(s!==void 0){t(s);return}}if(this.finished){r.end(this.args);return}this.handles.add(r),r.update(this.args)})}streamValues(...e){const t=e;let n;return _l(new ReadableStream({start:r=>{n=new p_(r,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}streamText(...e){const t=e;let n;return _l(new ReadableStream({start:r=>{n=new m_(r,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}forEach(...e){const t=e;let n;return _l(new ReadableStream({start:r=>{n=new g_(r,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},v_=class{constructor(e){T(this,"promise");this.promise=e}get(){return this.promise}},x_=class{constructor(){T(this,"args");T(this,"response");T(this,"writable");T(this,"resolve");T(this,"argsText","");T(this,"result",{get:async()=>(await this.response.get()).result});const e=new TransformStream;this.writable=e.writable,this.args=new y_(e.readable);const{promise:t,resolve:n}=md();this.resolve=n,this.response=new v_(t)}async appendArgsTextDelta(e){const t=this.writable.getWriter();try{await t.write(e)}catch(n){console.warn(n)}finally{t.releaseLock()}this.argsText+=e}async finishArgsText(){const e=this.writable.getWriter();try{await e.close()}catch(t){console.warn(t)}finally{e.releaseLock()}}setResponse(e){this.resolve(e)}},w_=class extends t_{constructor(e){const t=new Map,n=new Map;super(r=>{const s=new TransformStream({async transform(i,o){switch((i.type!=="part-finish"||i.meta.type!=="tool-call")&&o.enqueue(i),i.type){case"part-start":if(i.part.type==="tool-call"){const a=new x_;n.set(i.part.toolCallId,a),e.streamCall({reader:a,toolCallId:i.part.toolCallId,toolName:i.part.toolName})}break;case"text-delta":if(i.meta.type==="tool-call"){const a=i.meta.toolCallId,l=n.get(a);if(!l)throw new Error("No controller found for tool call");await l.appendArgsTextDelta(i.textDelta)}break;case"result":{if(i.meta.type!=="tool-call")break;const{toolCallId:a}=i.meta,l=n.get(a);if(!l)throw new Error("No controller found for tool call");l.setResponse(new hn({result:i.result,artifact:i.artifact,isError:i.isError,modelContent:i.modelContent}));break}case"tool-call-args-text-finish":{if(i.meta.type!=="tool-call")break;const{toolCallId:a,toolName:l}=i.meta,u=n.get(a);if(!u)throw new Error("No controller found for tool call");await u.finishArgsText();let f=!1;const d=f_(()=>{let h;try{h=qu.parse(u.argsText)}catch(g){throw new Error(`Function parameter parsing failed. ${JSON.stringify(g.message)}`)}const p=e.execute({toolCallId:a,toolName:l,args:h});return p!==void 0&&(f=!0,e.onExecutionStart?.(a,l)),p},h=>{if(f&&e.onExecutionEnd?.(a,l),h===void 0)return;const p=new hn({artifact:h.artifact,result:h.result,isError:h.isError,messages:h.messages,modelContent:h.modelContent});u.setResponse(p),o.enqueue({type:"result",path:i.path,...p})},h=>{f&&e.onExecutionEnd?.(a,l);const p=new hn({result:String(h),isError:!0});u.setResponse(p),o.enqueue({type:"result",path:i.path,...p})});d&&t.set(a,d);break}case"part-finish":{if(i.meta.type!=="tool-call")break;const{toolCallId:a}=i.meta,l=t.get(a);l?l.then(()=>{t.delete(a),n.delete(a),o.enqueue(i)}):o.enqueue(i)}}},async flush(){await Promise.all(t.values())}});return r.pipeThrough(new xv).pipeThrough(s)})}};const b_=e=>typeof e=="object"&&e!==null&&"~standard"in e&&e["~standard"].version===1;function S_(e,t,n,r){const s=e?.[n.toolName];return s?.execute?(async o=>{if(t.aborted)return new hn({result:"Tool execution was cancelled.",isError:!0});let a=o;if(b_(s.parameters)){let f=s.parameters["~standard"].validate(n.args);f instanceof Promise&&(f=await f),f.issues&&(a=s.experimental_onSchemaValidationError??(()=>{throw new Error(`Function parameter validation failed. ${JSON.stringify(f.issues)}`)}))}const l=new Promise(f=>{const d=()=>{queueMicrotask(()=>{queueMicrotask(()=>{f(new hn({result:"Tool execution was cancelled.",isError:!0}))})})};t.aborted?d():t.addEventListener("abort",d,{once:!0})}),u=(async()=>{const f=await a(n.args,{toolCallId:n.toolCallId,abortSignal:t,human:h=>r(n.toolCallId,h)}),d=hn.toResponse(f);if(s.toModelOutput&&!d.isError&&d.modelContent===void 0)try{const h=await s.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:d.result});return new hn({result:d.result,artifact:d.artifact,isError:d.isError,messages:d.messages,modelContent:h})}catch(h){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,h)}return d})();return Promise.race([u,l])})(s.execute):void 0}function k_(e,t,n,r,s){e?.[r.toolName]?.streamCall?.(n,{toolCallId:r.toolCallId,abortSignal:t,human:i=>s(r.toolCallId,i)})}function C_(e,t,n,r){const s=typeof e=="function"?e:()=>e,i=typeof t=="function"?t:()=>t;return new w_({execute:o=>S_(s(),i(),o,n),streamCall:({reader:o,...a})=>k_(s(),i(),o,a,n),onExecutionStart:r?.onExecutionStart,onExecutionEnd:r?.onExecutionEnd})}const _v=({index:e,children:t})=>c.jsx(wn,{value:se({attachment:At({source:"message",query:{type:"index",index:e},get:n=>n.message().attachment({index:e})})}),children:t}),Ev=({index:e,children:t})=>c.jsx(wn,{value:se({attachment:At({source:"composer",query:{type:"index",index:e},get:n=>n.composer().attachment({index:e})})}),children:t}),Tv=({index:e,children:t})=>c.jsx(wn,{value:se({message:At({source:"thread",query:{type:"index",index:e},get:n=>n.thread().message({index:e})}),composer:At({source:"message",query:{},get:n=>n.thread().message({index:e}).composer()})}),children:t}),yd=({index:e,children:t})=>c.jsx(wn,{value:se({part:At({source:"message",query:{type:"index",index:e},get:n=>n.message().part({index:e})})}),children:t}),__=ce(({text:e,isRunning:t})=>{const n=ie(()=>({type:"text",text:e,status:t?{type:"running"}:{type:"complete"}}),[e,t]);return{getState:()=>n,addToolResult:()=>{throw new Error("Not supported")},resumeToolCall:()=>{throw new Error("Not supported")},respondToToolApproval:()=>{throw new Error("Not supported")}}}),vd=({text:e,isRunning:t=!1,children:n})=>c.jsx(wn,{value:se({part:__({text:e,isRunning:t})}),children:n}),E_=Object.freeze({type:"complete"}),T_=ce(({parts:e,getMessagePart:t})=>{const[n,r]=kt(!0),s=ie(()=>e[e.length-1]?.status??E_,[e]),i=ie(()=>({parts:e,collapsed:n,status:s}),[e,n,s]);return{getState:()=>i,setCollapsed:r,part:t}}),I_=({startIndex:e,endIndex:t,children:n})=>{const r=V(i=>i.message.parts).slice(e,t+1),s=se();return c.jsx(wn,{value:se({chainOfThought:T_({parts:r,getMessagePart:({index:i})=>{if(i<0||i>=r.length)throw new Error(`ChainOfThought part index ${i} is out of bounds (0..${r.length-1})`);return s.message().part({index:e+i})}})}),children:n})},Iv=({index:e,children:t})=>c.jsx(wn,{value:se({suggestion:At({source:"suggestions",query:{index:e},get:n=>n.suggestions().suggestion({index:e})})}),children:t}),R_=({index:e,children:t})=>c.jsx(wn,{value:se({queueItem:At({source:"composer",query:{index:e},get:n=>n.composer().queueItem({index:e})})}),children:t}),pr=Symbol("innerMessage"),El=Symbol("innerMessages"),P_=[],A_=(e,t)=>{pr in e||(e[pr]=t)},j_=e=>{const t="messages"in e?e.messages:e,n=t[El]||t[pr];return n?Array.isArray(n)?n:(t[El]=[n],t[El]):P_},Ht=Symbol("skip-update");function N_(e,t){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0)return!1;for(const n of Object.keys(e)){const r=e[n],s=t[n];if(!Object.is(r,s))return!1}return!0}var M_=class{constructor(){T(this,"_subscribers",new Set)}subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{const t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){const e=[];for(const t of this._subscribers)try{t()}catch(n){e.push(n)}if(e.length>0){if(e.length===1)throw e[0];for(const t of e)console.error(t);throw new AggregateError(e)}}},za=class{constructor(){T(this,"_subscriptions",new Set);T(this,"_connection")}get isConnected(){return!!this._connection}notifySubscribers(e){for(const t of this._subscriptions)t(e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else this._connection?.(),this._connection=void 0}subscribe(e){return this._subscriptions.add(e),this._updateConnection(),()=>{this._subscriptions.delete(e),this._updateConnection()}}},Ft=class extends za{constructor(t){super();T(this,"binding");T(this,"_previousState");T(this,"getState",()=>(this.isConnected||this._syncState(),this._previousState));this.binding=t;const n=t.getState();if(n===Ht)throw new Error("Entry not available in the store");this._previousState=n}get path(){return this.binding.path}_syncState(){const t=this.binding.getState();return t===Ht||N_(t,this._previousState)?!1:(this._previousState=t,!0)}_connect(){const t=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(t)}},xd=class extends za{constructor(t){super();T(this,"binding");T(this,"_previousStateDirty",!0);T(this,"_previousState");T(this,"getState",()=>{if(!this.isConnected||this._previousStateDirty){const t=this.binding.getState();t!==Ht&&(this._previousState=t),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState});this.binding=t}get path(){return this.binding.path}_connect(){const t=()=>{this._previousStateDirty=!0,this.notifySubscribers()};return this.binding.subscribe(t)}},na=class extends za{constructor(t){super();T(this,"binding");this.binding=t}get path(){return this.binding.path}getState(){return this.binding.getState()}outerSubscribe(t){return this.binding.subscribe(t)}_connect(){const t=()=>{this.notifySubscribers()};let n=this.binding.getState(),r=n?.subscribe(t);const s=()=>{const o=this.binding.getState();o!==n&&(n=o,r?.(),r=o?.subscribe(t),t())},i=this.outerSubscribe(s);return()=>{i?.(),r?.()}}},Rv=class extends za{constructor(t){super();T(this,"config");this.config=t}getState(){return this.config.binding.getState()}outerSubscribe(t){return this.config.binding.subscribe(t)}_connect(){const t=o=>{this.notifySubscribers(o)};let n=this.config.binding.getState(),r=n?.unstable_on(this.config.event,t);const s=()=>{const o=this.config.binding.getState();o!==n&&(n=o,r?.(),r=o?.unstable_on(this.config.event,t))},i=this.outerSubscribe(s);return()=>{i?.(),r?.()}}},Pv=class{constructor(e){T(this,"_core");this._core=e,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(e){return this._core.subscribe(e)}},Av=class extends Pv{constructor(t,n){super(t);T(this,"_composerApi");this._composerApi=n}remove(){const t=this._composerApi.getState();if(!t)throw new Error("Composer is not available");return t.removeAttachment(this.getState().id)}},D_=class extends Av{get source(){return"thread-composer"}},L_=class extends Av{get source(){return"edit-composer"}},O_=class extends Pv{get source(){return"message"}remove(){throw new Error("Message attachments cannot be removed")}};const jv=Object.freeze([]),Nv=Object.freeze({}),z_=e=>Object.freeze({type:"thread",isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??jv,text:e?.text??"",role:e?.role??"user",runConfig:e?.runConfig??Nv,attachmentAccept:e?.attachmentAccept??"",dictation:e?.dictation,quote:e?.quote,value:e?.text??""}),F_=e=>Object.freeze({type:"edit",isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,text:e?.text??"",role:e?.role??"user",attachments:e?.attachments??jv,runConfig:e?.runConfig??Nv,attachmentAccept:e?.attachmentAccept??"",dictation:e?.dictation,quote:e?.quote,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??""});var Mv=class{constructor(e){T(this,"_core");T(this,"_eventSubscriptionSubjects",new Map);this._core=e}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.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(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setText(e)}setRunConfig(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setRunConfig(e)}addAttachment(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.addAttachment(e)}reset(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");return e.reset()}clearAttachments(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");return e.clearAttachments()}send(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.send(e)}cancel(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.cancel()}setRole(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setRole(e)}startDictation(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.startDictation()}stopDictation(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.stopDictation()}setQuote(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new Rv({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},B_=class extends Mv{constructor(t){const n=new xd({path:t.path,getState:()=>z_(t.getState()),subscribe:r=>t.subscribe(r)});super({path:t.path,getState:()=>t.getState(),subscribe:r=>n.subscribe(r)});T(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(t){return new D_(new Ft({path:{...this.path,attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:t},ref:`${this.path.ref}.attachments[${t}]`},getState:()=>{const n=this.getState().attachments[t];return n?{...n,source:"thread-composer"}:Ht},subscribe:n=>this._core.subscribe(n)}),this._core)}},$_=class extends Mv{constructor(t,n){const r=new xd({path:t.path,getState:()=>F_(t.getState()),subscribe:s=>t.subscribe(s)});super({path:t.path,getState:()=>t.getState(),subscribe:s=>r.subscribe(s)});T(this,"_beginEdit");T(this,"_getState");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(t){return new L_(new Ft({path:{...this.path,attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:t},ref:`${this.path.ref}.attachments[${t}]`},getState:()=>{const n=this.getState().attachments[t];return n?{...n,source:"edit-composer"}:Ht},subscribe:n=>this._core.subscribe(n)}),this._core)}};const bi=e=>e.content.filter(t=>t.type==="text").map(t=>t.text).join(`
|
|
43
43
|
|
|
44
|
-
`);var Rh=class{constructor(e,t,n){T(this,"contentBinding");T(this,"messageApi");T(this,"threadApi");this.contentBinding=e,this.messageApi=t,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(e){const t=this.contentBinding.getState();if(!t)throw new Error("Message part is not available");if(t.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=t.toolName,s=t.toolCallId,i=hn.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:s,result:i.result,artifact:i.artifact,isError:i.isError})}resumeToolCall(e){const t=this.contentBinding.getState();if(!t)throw new Error("Message part is not available");if(t.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=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}respondToToolApproval(e){const t=this.contentBinding.getState();if(!t)throw new Error("Message part is not available");if(t.type!=="tool-call")throw new Error("Tried to respond to tool approval on non-tool message part");if(!t.approval||t.approval.approved!==void 0)throw new Error("Tool call has no pending approval");if(!this.threadApi)throw new Error("Thread API is not available");this.threadApi.getState().respondToToolApproval({approvalId:t.approval.id,approved:e.approved,...e.reason!=null&&{reason:e.reason}})}subscribe(e){return this.contentBinding.subscribe(e)}};const Zi=Object.freeze({type:"complete"}),B_=(e,t,n)=>{if(e.role!=="assistant")return Zi;if(n.type==="tool-call")return n.result?Zi:e.status;const r=t===Math.max(0,e.content.length-1);return e.status.type==="requires-action"?Zi:r?e.status:Zi},Ph=(e,t)=>{const n=e.content[t];if(!n)return Ht;const r=B_(e,t,n);return Object.freeze({...n,[pr]:n[pr],status:r})};var $_=class{constructor(e,t){T(this,"_core");T(this,"_threadBinding");T(this,"composer");T(this,"_getEditComposerRuntimeCore",()=>this._threadBinding.getState().getEditComposer(this._core.getState().id));this._core=e,this._threadBinding=t,this.composer=new F_(new na({path:{...this.path,ref:`${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.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()}reload(e={}){const t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:s=r.runConfig}=e,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 e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){const e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw new Error("Message is not being spoken")}submitFeedback({type:e}){const t=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:t.id,type:e})}switchToBranch({position:e,branchId:t}){const n=this._core.getState();if(t&&e)throw new Error("May not specify both branchId and position");if(!t&&!e)throw new Error("Must specify either branchId or position");const r=this._threadBinding.getState().getBranches(n.id);let s=t;if(e==="previous"?s=r[n.branchNumber-2]:e==="next"&&(s=r[n.branchNumber]),!s)throw new Error("Branch not found");this._threadBinding.getState().switchToBranch(s)}unstable_getCopyText(){return bi(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw new Error("Message part index must be >= 0");return new Rh(new Ft({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.content[${e}]`,messagePartSelector:{type:"index",index:e}},getState:()=>Ph(this.getState(),e),subscribe:t=>this._core.subscribe(t)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new Rh(new Ft({path:{...this.path,ref:this.path.ref+`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:"toolCallId",toolCallId:e}},getState:()=>{const t=this._core.getState(),n=t.content.findIndex(r=>r.type==="tool-call"&&r.toolCallId===e);return n===-1?Ht:Ph(t,n)},subscribe:t=>this._core.subscribe(t)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new D_(new Ft({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.attachments[${e}]`,attachmentSource:"message",attachmentSelector:{type:"index",index:e}},getState:()=>{const t=this.getState().attachments?.[e];return t?{...t,source:"message"}:Ht},subscribe:t=>this._core.subscribe(t)}))}};const U_=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),V_=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),H_=(e,t)=>typeof t=="string"?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:"user",content:[{type:"text",text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId??e.at(-1)?.id??null,sourceId:t.sourceId??null,role:t.role??"user",content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},W_=(e,t)=>{const n=e.messages.at(-1);return Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:e.isRunning??(n?.role!=="assistant"?!1:n.status.type==="running"),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice})};var Mv=class{constructor(e,t){T(this,"_threadBinding");T(this,"composer");T(this,"_eventSubscriptionSubjects",new Map);const n=new Ft({path:e.path,getState:()=>W_(e.getState(),t.getState()),subscribe:r=>{const s=e.subscribe(r),i=t.subscribe(r);return()=>{s(),i()}}});this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:r=>e.outerSubscribe(r),subscribe:r=>e.subscribe(r)},this.composer=new z_(new na({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.resumeRun=this.resumeRun.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getState=this.getState.bind(this)}getState(){return this._threadBinding.getStateState()}append(e){this._threadBinding.getState().append(H_(this._threadBinding.getState().messages,e))}subscribe(e){return this._threadBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun(V_(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(U_(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(e){return this._threadBinding.getState().subscribeVoiceVolume(e)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(e){this._threadBinding.getState().import(e)}reset(e){this._threadBinding.getState().reset(e)}getMessageByIndex(e){if(e<0)throw new Error("Message index must be >= 0");return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:"index",index:e}},()=>{const t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[messageId=${JSON.stringify(e)}]`,messageSelector:{type:"messageId",messageId:e}},()=>this._threadBinding.getState().getMessageById(e))}_getMessageRuntime(e,t){return new $_(new Ft({path:e,getState:()=>{const{message:n,parentId:r,index:s}=t()??{},{messages:i,speech:o}=this._threadBinding.getState();if(!n||r===void 0||s===void 0)return Ht;const a=this._threadBinding.getState().getBranches(n.id);return{...n,[pr]:n[pr],index:s,isLast:i.at(-1)?.id===n.id,parentId:r,branchNumber:a.indexOf(n.id)+1,branchCount:a.length,speech:o?.messageId===n.id?o:void 0}},subscribe:n=>this._threadBinding.subscribe(n)}),this._threadBinding)}unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new Iv({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}};const q_=m.createContext(null),K_=()=>m.useContext(q_);var eo=class{constructor(e,t){T(this,"_core");T(this,"_threadListBinding");this._core=e,this._threadListBinding=t,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(e){const t=this._core.getState();return this._threadListBinding.switchToThread(t.id,e)}rename(e){const t=this._core.getState();return this._threadListBinding.rename(t.id,e)}updateCustom(e){const t=this._core.getState();if(!this._threadListBinding.updateCustom)throw new Error("Thread list runtime does not support updating custom metadata");return this._threadListBinding.updateCustom(t.id,e)}archive(){const e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){const e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){const e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){const e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(){const e=this._core.getState();return this._threadListBinding.generateTitle(e.id)}unstable_on(e,t){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,!(e==="switchedTo"&&!i)&&(e==="switchedAway"&&i||t({})))})}subscribe(e){return this._core.subscribe(e)}detach(){const e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}};const Ah=Promise.resolve(),G_=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,isLoadingMore:e.isLoadingMore??!1,hasMore:e.hasMore??!1,threadItems:e.threadItems}),to=(e,t)=>{if(t===void 0)return Ht;const n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,custom:n.custom,isMain:n.id===e.mainThreadId}:Ht};var Q_=class{constructor(e,t=Mv){T(this,"_core");T(this,"_runtimeFactory");T(this,"_getState");T(this,"_mainThreadListItemRuntime");T(this,"main");this._core=e,this._runtimeFactory=t;const n=new xd({path:{},getState:()=>G_(e),subscribe:r=>e.subscribe(r)});this._getState=n.getState.bind(n),this._mainThreadListItemRuntime=new eo(new Ft({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>to(this._core,this._core.mainThreadId),subscribe:r=>this._core.subscribe(r)}),this._core),this.main=new t(new na({path:{ref:"threads.main",threadSelector:{type:"main"}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:r=>e.subscribe(r)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.loadMore=this.loadMore.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e,t){return this._core.switchToThread(e,t)}switchToNewThread(){return this._core.switchToNewThread()}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??Ah}loadMore(){return this._core.loadMore?.()??Ah}getState(){return this._getState()}subscribe(e){return this._core.subscribe(e)}get mainItem(){return this._mainThreadListItemRuntime}getById(e){return new this._runtimeFactory(new na({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:"threadId",threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:t=>this._core.subscribe(t)}),this.mainItem)}getItemByIndex(e){return new eo(new Ft({path:{ref:`threadItems[${e}]`,threadSelector:{type:"index",index:e}},getState:()=>to(this._core,this._core.threadIds[e]),subscribe:t=>this._core.subscribe(t)}),this._core)}getArchivedItemByIndex(e){return new eo(new Ft({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:"archiveIndex",index:e}},getState:()=>to(this._core,this._core.archivedThreadIds[e]),subscribe:t=>this._core.subscribe(t)}),this._core)}getItemById(e){return new eo(new Ft({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:"threadId",threadId:e}},getState:()=>to(this._core,e),subscribe:t=>this._core.subscribe(t)}),this._core)}},Dv=class{constructor(e){T(this,"_core");T(this,"threads");T(this,"_thread");this._core=e,this.threads=new Q_(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}},Lv=class{constructor(){T(this,"_contextProvider",new dd)}registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}};const Yn=Object.freeze([]),Yr="DEFAULT_THREAD_ID",Y_=Object.freeze([Yr]),J_=Object.freeze({id:Yr,remoteId:void 0,externalId:void 0,status:"regular"}),X_=Promise.resolve(),jh=Object.freeze({[Yr]:J_});var Z_=class{constructor(e={},t){T(this,"threadFactory");T(this,"_mainThreadId",Yr);T(this,"_threads",Y_);T(this,"_archivedThreads",Yn);T(this,"_threadData",jh);T(this,"adapter",{});T(this,"_mainThread");T(this,"_subscriptions",new Set);this.threadFactory=t,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 X_}get mainThreadId(){return this._mainThreadId}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw new Error("Method not implemented.")}getItemById(e){return this._threadData[e]}__internal_setAdapter(e,t=!1){const n=this.adapter;this.adapter=e;const r=e.threadId??Yr,s=e.threads??Yn,i=e.archivedThreads??Yn,o=n.threadId??Yr,a=n.threads??Yn,l=n.archivedThreads??Yn;!t&&o===r&&a===s&&l===i||((a!==s||l!==i||o!==r)&&(this._threadData={...jh,...Object.fromEntries(e.threads?.map(u=>[u.id,{...u,remoteId:u.remoteId,externalId:u.externalId,status:"regular"}])??[]),...Object.fromEntries(e.archivedThreads?.map(u=>[u.id,{...u,remoteId:u.remoteId,externalId:u.externalId,status:"archived"}])??[])}),a!==s&&(this._threads=this.adapter.threads?.map(u=>u.id)??Yn),l!==i&&(this._archivedThreads=this.adapter.archivedThreads?.map(u=>u.id)??Yn),(t||o!==r)&&(this._mainThreadId=r,this._mainThread=this.threadFactory()),this._threadData[this._mainThreadId]||(this._threadData={...this._threadData,[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:"regular"}}),this._notifySubscribers())}async switchToThread(e,t){if(this._mainThreadId===e)return;const n=this.adapter.onSwitchToThread;if(!n)throw new Error("External store adapter does not support switching to thread");await n(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,t){const n=this.adapter.onRename;if(!n)throw new Error("External store adapter does not support renaming");await n(e,t)}async updateCustom(e,t){const n=this.adapter.onUpdateCustom;if(!n)throw new Error("External store adapter does not support updating custom metadata");await n(e,t)}async detach(){}async archive(e){const t=this.adapter.onArchive;if(!t)throw new Error("External store adapter does not support archiving");await t(e)}async unarchive(e){const t=this.adapter.onUnarchive;if(!t)throw new Error("External store adapter does not support unarchiving");await t(e)}async delete(e){const t=this.adapter.onDelete;if(!t)throw new Error("External store adapter does not support deleting");await t(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw new Error("Method not implemented.")}subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}_notifySubscribers(){for(const e of this._subscriptions)e()}};const Vn=xv("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),ps=Symbol("autoStatus"),e1=Object.freeze(Object.assign({type:"running"},{[ps]:!0})),t1=Object.freeze(Object.assign({type:"complete",reason:"unknown"},{[ps]:!0})),n1=Object.freeze(Object.assign({type:"requires-action",reason:"tool-calls"},{[ps]:!0})),r1=Object.freeze(Object.assign({type:"requires-action",reason:"interrupt"},{[ps]:!0})),s1=e=>e[ps]===!0,ra=(e,t,n,r,s)=>e&&s?Object.assign({type:"incomplete",reason:"error",error:s},{[ps]:!0}):e&&t?e1:n?r1:r?n1:t1,Tl=(e,t)=>{if(e.startsWith("data-"))return{type:"data",name:e.substring(5),data:t}},Si=(e,t,n)=>{const{role:r,id:s,createdAt:i,attachments:o,status:a,metadata:l}=e,u={id:s??t,createdAt:i??new Date},f=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content,d=({image:h,...p})=>h.match(/^data:image\/(png|jpeg|jpg|gif|webp|svg\+xml);base64,(.*)$/)?{...p,image:h}:/^(https:\/\/|blob:)/.test(h)?{...p,image:h}:(console.warn("Invalid image data format detected"),null);if(r!=="user"&&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?.steps)throw new Error("metadata.steps is only supported for assistant messages");switch(r){case"assistant":return{...u,role:r,content:f.map(h=>{const p=h.type;switch(p){case"text":case"reasoning":return h.text.trim().length===0?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:g,messages:x,...k}=h,y={...k,toolCallId:h.toolCallId??`tool-${Vn()}`,...g!==void 0&&{parentId:g},...x!==void 0&&{messages:x}};return h.args?{...y,args:h.args,argsText:h.argsText??JSON.stringify(h.args)}:{...y,args:Ku(h.argsText??"")??{},argsText:h.argsText??""}}default:{const g=Tl(p,h.data);if(g)return g;throw new Error(`Unsupported assistant message part type: ${p}`)}}}).filter(h=>!!h),status:a??n,metadata:{unstable_state:l?.unstable_state??null,unstable_annotations:l?.unstable_annotations??[],unstable_data:l?.unstable_data??[],custom:l?.custom??{},steps:l?.steps??[],...l?.timing&&{timing:l.timing},...l?.submittedFeedback&&{submittedFeedback:l.submittedFeedback},...l?.isOptimistic&&{isOptimistic:!0}}};case"user":return{...u,role:r,content:f.map(h=>{const p=h.type;switch(p){case"text":case"image":case"audio":case"file":case"data":return h;default:{const g=Tl(p,h.data);if(g)return g;throw new Error(`Unsupported user message part type: ${p}`)}}}),attachments:(o??[]).map(h=>({...h,content:h.content.map(p=>Tl(p.type,p.data)??p)})),metadata:{custom:l?.custom??{}}};case"system":if(f.length!==1||f[0].type!=="text")throw new Error("System messages must have exactly one text message part.");return{...u,role:r,content:f,metadata:{custom:l?.custom??{}}};default:throw new Error(`Unknown message role: ${r}`)}},Ov={fromArray:e=>{const t=e.map(n=>Si(n,Vn(),ra(!1,!1,!1,!1,void 0)));return{messages:t.map((n,r)=>({parentId:r>0?t[r-1].id:null,message:n}))}},fromBranchableArray:(e,t)=>{const n=ra(!1,!1,!1,!1,void 0);return{...t?.headId!==void 0?{headId:t.headId}:void 0,messages:e.map(({message:r,parentId:s})=>{if(!r.id)throw new Error("ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.");return{parentId:s,message:Si(r,r.id,n)}})}}},Co=e=>e.next?Co(e.next):"current"in e?e:null;var i1=class{constructor(e){T(this,"func");T(this,"_value",null);this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},wd=class{constructor(){T(this,"messages",new Map);T(this,"head",null);T(this,"root",{children:[],next:null});T(this,"_messages",new i1(()=>{const e=new Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e}))}updateLevels(e,t){e.level=t;for(const n of e.children){const r=this.messages.get(n);r&&this.updateLevels(r,t+1)}}performOp(e,t,n){const r=t.prev??this.root,s=e??this.root;if(!(n==="relink"&&r===s)){if(n!=="link"&&(r.children=r.children.filter(i=>i!==t.current.id),r.next===t)){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"){for(let o=e;o;o=o.prev)if(o.current.id===t.current.id)throw new Error("MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.");s.children=[...s.children,t.current.id],(Co(t)===this.head||s.next===null)&&(s.next=t),t.prev=e;const i=e?e.level+1:0;this.updateLevels(t,i)}}}get headId(){return this.head?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.");const n=new Array(t.level+1);for(let r=t;r;r=r.prev)n[r.level]=r.current;return n}addOrUpdateMessage(e,t){const n=this.messages.get(t.id),r=e?this.messages.get(e):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=t,this.performOp(r,n,"relink"),this._messages.dirty();return}const s={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,s),this.performOp(r,s,"link"),this.head===r&&(this.head=s),this._messages.dirty()}getMessage(e){const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.");return{parentId:t.prev?.current.id??null,message:t.current,index:t.level}}deleteMessage(e,t){const n=this.messages.get(e);if(!n)throw new Error("MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.");const r=t===void 0?n.prev:t===null?null:this.messages.get(t);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(e),this.head===n&&(this.head=Co(r??this.root)),this._messages.dirty()}getBranches(e){const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.");const{children:n}=t.prev??this.root;return n}evictOffBranchOptimisticMessages(e,t){if(!e)return;const n=new Set;for(let s=t;s;s=s.prev)n.add(s.current.id);const r=[];for(let s=e;s&&!n.has(s.current.id);s=s.prev)s.current.metadata?.isOptimistic&&r.push(s.current.id);for(const s of r)this.messages.has(s)&&this.deleteMessage(s)}switchToBranch(e){const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.");const n=this.head,r=t.prev??this.root;r.next=t,this.head=Co(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.");const n=this.head;if(t.children.length>0){const r=s=>{for(const i of s.children){const o=this.messages.get(i);o&&(r(o),this.messages.delete(i))}};r(t),t.children=[],t.next=null}this.head=t;for(let r=t;r;r=r.prev)r.prev?r.prev.next=r:this.root.next=r;this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){const e=[];for(const[,n]of this.messages)n.current.metadata?.isOptimistic||e.push({message:n.current,parentId:n.prev?.current.id??null});let t=this.head;for(;t?.current.metadata?.isOptimistic;)t=t.prev;return{headId:t?.current.id??null,messages:e}}import({headId:e,messages:t}){for(const{message:n,parentId:r}of t)this.addOrUpdateMessage(r,n);this.resetHead(e??t.at(-1)?.message.id??null)}};function Nh(e,t){if(t==="*")return!0;const n=t.split(",").map(i=>i.trim().toLowerCase()),r=`.${e.name.split(".").pop().toLowerCase()}`,s=e.type.toLowerCase();for(const i of n){if(i.startsWith(".")&&i===r||i.includes("/")&&i===s)return!0;if(i.endsWith("/*")){const o=i.split("/")[0];if(s.startsWith(`${o}/`))return!0}}return!1}function o1(e,t){return e.length!==t.length?!1:e.every((n,r)=>n.id===t[r].id)}function a1(e){const t=Vn();return e.type==="image"?{id:t,type:"image",name:e.filename??"image",content:[e],status:{type:"complete"}}:e.type==="file"?{id:t,type:"document",name:e.filename??"document",contentType:e.mimeType,content:[e],status:{type:"complete"}}:e.type==="audio"?{id:t,type:"audio",name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:"complete"}}:{id:t,type:"data",name:e.name,content:[e],status:{type:"complete"}}}function l1(e){const t=[];for(const n of e)n.type!=="text"&&t.push(a1(n));return t}const Il=e=>e.status.type==="complete";var zv=class extends j_{constructor(){super(...arguments);T(this,"isEditing",!0);T(this,"_attachments",[]);T(this,"_text","");T(this,"_role","user");T(this,"_runConfig",{});T(this,"_quote");T(this,"_dictation");T(this,"_dictationSession");T(this,"_dictationUnsubscribes",[]);T(this,"_dictationBaseText","");T(this,"_currentInterimText","");T(this,"_dictationSessionIdCounter",0);T(this,"_activeDictationSessionId");T(this,"_isCleaningDictation",!1);T(this,"_eventSubscribers",new Map)}get attachmentAccept(){return this.getAttachmentAdapter()?.accept??"*"}get attachments(){return this._attachments}setAttachments(t){this._attachments=t,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(t){this._quote!==t&&(this._quote=t,this._notifySubscribers())}setText(t){if(this._text!==t){if(this._text=t,this._dictation){this._dictationBaseText=t,this._currentInterimText="";const{status:n,inputDisabled:r}=this._dictation;this._dictation=r?{status:n,inputDisabled:r}:{status:n}}this._notifySubscribers()}}setRole(t){this._role!==t&&(this._role=t,this._notifySubscribers())}setRunConfig(t){this._runConfig!==t&&(this._runConfig=t,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text="",this._notifySubscribers()}async _onClearAttachments(){const t=this.getAttachmentAdapter();if(t){const n=this._attachments.filter(r=>!Il(r));await Promise.all(n.map(r=>t.remove(r)))}}async reset(){if(this._attachments.length===0&&this._text===""&&this._role==="user"&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role="user",this._runConfig={},this._quote=void 0;const t=this._onClearAttachments();this._emptyTextAndAttachments(),await t}async clearAttachments(){const t=this._onClearAttachments();this.setAttachments([]),await t}async send(t){if(!this.canSend)return;this._dictationSession&&(this._dictationSession.cancel(),this._cleanupDictation());const n=this.getAttachmentAdapter(),r=this.attachments.length>0?Promise.all(this.attachments.map(async a=>{if(Il(a))return a;if(!n)throw new Error("Attachments are not supported");return await n.send(a)})):[],s=this.text,i=this._quote;this._quote=void 0,this._emptyTextAndAttachments();const o={createdAt:new Date,role:this.role,content:s?[{type:"text",text:s}]:[],attachments:await r,runConfig:this.runConfig,metadata:{custom:{...i?{quote:i}:{}}}};this.handleSend(o,t),this._notifyEventSubscribers("send",{})}cancel(){this.handleCancel()}async addAttachment(t){if(!(t instanceof File)){const i=this.getAttachmentAdapter();if(i&&!Nh({name:t.name,type:t.contentType??""},i.accept)){const a=`File type ${t.contentType||"unknown"} is not accepted. Accepted types: ${i.accept}`,l=new Error(a);throw this._safeEmitAttachmentAddError("not-accepted",a,void 0,l),l}const o={id:t.id??Vn(),type:t.type??"document",name:t.name,contentType:t.contentType,content:t.content,status:{type:"complete"}};this._attachments=[...this._attachments,o],this._notifySubscribers(),this._notifyEventSubscribers("attachmentAdd",{});return}const n=i=>{const o=this._attachments.findIndex(a=>a.id===i.id);o!==-1?this._attachments=[...this._attachments.slice(0,o),i,...this._attachments.slice(o+1)]:this._attachments=[...this._attachments,i],this._notifySubscribers()},r=this.getAttachmentAdapter();if(!r){const i="Attachments are not supported",o=new Error(i);throw this._safeEmitAttachmentAddError("no-adapter",i,void 0,o),o}if(!Nh({name:t.name,type:t.type},r.accept)){const i=`File type ${t.type||"unknown"} is not accepted. Accepted types: ${r.accept}`,o=new Error(i);throw this._safeEmitAttachmentAddError("not-accepted",i,void 0,o),o}let s;try{const i=r.add({file:t});if(Symbol.asyncIterator in i)for await(const o of i)s=o,n(o);else s=await i,n(s)}catch(i){throw s&&n({...s,status:{type:"incomplete",reason:"error"}}),this._safeEmitAttachmentAddError("adapter-error",i instanceof Error?i.message:String(i),s?.id,i instanceof Error?i:void 0),i}s?.status.type==="incomplete"&&s.status.reason==="error"?this._safeEmitAttachmentAddError("adapter-error","Attachment upload did not complete successfully.",s?.id):this._notifyEventSubscribers("attachmentAdd",{})}_safeEmitAttachmentAddError(t,n,r,s){try{this._notifyEventSubscribers("attachmentAddError",{reason:t,message:n,...r!==void 0&&{attachmentId:r},...s!==void 0&&{error:s}})}catch(i){console.error("[assistant-ui] attachmentAddError subscriber threw:",i)}}async removeAttachment(t){const n=this._attachments.findIndex(s=>s.id===t);if(n===-1)throw new Error("Attachment not found");const r=this._attachments[n];if(!Il(r)){const s=this.getAttachmentAdapter();if(!s)throw new Error("Attachments are not supported");await s.remove(r)}this._attachments=this._attachments.filter(s=>s.id!==t),this._notifySubscribers()}get dictation(){return this._dictation}_isActiveSession(t,n){return this._activeDictationSessionId===t&&this._dictationSession===n}startDictation(){const t=this.getDictationAdapter();if(!t)throw new Error("Dictation adapter not configured");if(this._dictationSession){for(const u of this._dictationUnsubscribes)u();this._dictationUnsubscribes=[],this._dictationSession.stop().catch(()=>{}),this._dictationSession=void 0}const n=t.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText="";const r=t.listen();this._dictationSession=r;const s=++this._dictationSessionIdCounter;this._activeDictationSessionId=s,this._dictation={status:r.status,inputDisabled:n},this._notifySubscribers();const i=r.onSpeech(u=>{if(!this._isActiveSession(s,r))return;const f=u.isFinal!==!1,d=this._dictationBaseText&&!this._dictationBaseText.endsWith(" ")&&u.transcript?" ":"";if(f){if(this._dictationBaseText=this._dictationBaseText+d+u.transcript,this._currentInterimText="",this._text=this._dictationBaseText,this._dictation){const{transcript:h,...p}=this._dictation;this._dictation=p}this._notifySubscribers()}else this._currentInterimText=d+u.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&(this._dictation={...this._dictation,transcript:u.transcript}),this._notifySubscribers()});this._dictationUnsubscribes.push(i);const o=r.onSpeechStart(()=>{this._isActiveSession(s,r)&&(this._dictation={status:{type:"running"},inputDisabled:n,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(o);const a=r.onSpeechEnd(()=>{this._cleanupDictation({sessionId:s})});this._dictationUnsubscribes.push(a);const l=setInterval(()=>{this._isActiveSession(s,r)&&r.status.type==="ended"&&this._cleanupDictation({sessionId:s})},100);this._dictationUnsubscribes.push(()=>clearInterval(l))}stopDictation(){if(!this._dictationSession)return;const t=this._dictationSession,n=this._activeDictationSessionId;t.stop().finally(()=>{this._cleanupDictation({sessionId:n})})}_cleanupDictation(t){if(!(t?.sessionId!==void 0&&t.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)){this._isCleaningDictation=!0;try{for(const n of this._dictationUnsubscribes)n();this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText="",this._currentInterimText="",this._notifySubscribers()}finally{this._isCleaningDictation=!1}}}_notifyEventSubscribers(t,n){const r=this._eventSubscribers.get(t);if(r)for(const s of r)s(n)}unstable_on(t,n){const r=n;let s=this._eventSubscribers.get(t);return s||(s=new Set,this._eventSubscribers.set(t,s)),s.add(r),()=>{this._eventSubscribers.get(t)?.delete(r)}}},Fv=class extends zv{constructor(t){super();T(this,"runtime");T(this,"_canCancel",!1);this.runtime=t,this.connect()}get canCancel(){return this._canCancel}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}connect(){let t=this.runtime.isSendDisabled;return this.runtime.subscribe(()=>{let n=!1;this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,n=!0),t!==this.runtime.isSendDisabled&&(t=this.runtime.isSendDisabled,n=!0),n&&this._notifySubscribers()})}async handleSend(t,n){this.runtime.append({...t,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:n?.startRun})}async handleCancel(){this.runtime.cancelRun()}},u1=class extends zv{constructor(t,n,{parentId:r,message:s}){super();T(this,"runtime");T(this,"endEditCallback");T(this,"_previousText");T(this,"_previousAttachments");T(this,"_nonTextPassthrough");T(this,"_parentId");T(this,"_sourceId");this.runtime=t,this.endEditCallback=n,this._parentId=r,this._sourceId=s.id,this._previousText=bi(s),this.setText(this._previousText),this.setRole(s.role),s.role==="user"?(this._previousAttachments=[...s.attachments??[],...l1(s.content)],this._nonTextPassthrough=[]):(this._previousAttachments=s.attachments??[],this._nonTextPassthrough=s.content.filter(i=>i.type!=="text")),this.setAttachments(this._previousAttachments),this.setRunConfig({...t.composer.runConfig})}get canCancel(){return!0}get canSend(){return!this.isEmpty}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(t,n){const r=bi(t),s=!o1(t.attachments??[],this._previousAttachments);if(r!==this._previousText||s||n?.startRun){const i=this._nonTextPassthrough.length>0?[...t.content,...this._nonTextPassthrough]:t.content;this.runtime.append({...t,content:i,parentId:this._parentId,sourceId:this._sourceId,startRun:n?.startRun})}this.handleCancel()}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},c1=class{constructor(e){T(this,"_contextProvider");T(this,"_subscriptions",new Set);T(this,"_isInitialized",!1);T(this,"repository",new wd);T(this,"_voiceMessages",[]);T(this,"_voiceGeneration",0);T(this,"_cachedMergedMessages",null);T(this,"_cachedVoiceGeneration",-1);T(this,"_cachedMergedBase",null);T(this,"composer",new Fv(this));T(this,"_editComposers",new Map);T(this,"_stopSpeaking");T(this,"speech");T(this,"_voiceSession");T(this,"_voiceUnsubs",[]);T(this,"voice");T(this,"_voiceVolume",0);T(this,"_voiceVolumeSubscribers",new Set);T(this,"getVoiceVolume",()=>this._voiceVolume);T(this,"subscribeVoiceVolume",e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e)));T(this,"_currentAssistantMsg",null);T(this,"_eventSubscribers",new Map);this._contextProvider=e}_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();const e=this._getBaseMessages();return(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e)&&(this._cachedMergedMessages=[...e,...this._voiceMessages],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e),this._cachedMergedMessages}get state(){let e;for(const t of this.messages)t.role==="assistant"&&(e=t);return e?.metadata.unstable_state??null}getModelContext(){return this._contextProvider.getModelContext()}getEditComposer(e){return this._editComposers.get(e)}beginEdit(e){if(this._editComposers.has(e))throw new Error("Edit already in progress");this._editComposers.set(e,new u1(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{const t=this.repository.getMessages(),n=this._voiceMessages.findIndex(r=>r.id===e);return n!==-1?{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}:void 0}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifySubscribers(){for(const e of this._subscriptions)e()}_notifyEventSubscribers(e,t){const n=this._eventSubscribers.get(e);if(n)for(const r of n)r(t)}subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}submitFeedback({messageId:e,type:t}){const n=this.adapters?.feedback;if(!n)throw new Error("Feedback adapter not configured");const{message:r,parentId:s}=this.repository.getMessage(e);if(n.submit({message:r,type:t}),r.role==="assistant"){const i={...r,metadata:{...r.metadata,submittedFeedback:{type:t}}};this.repository.addOrUpdateMessage(s,i)}this._notifySubscribers()}speak(e){const t=this.adapters?.speech;if(!t)throw new Error("Speech adapter not configured");const{message:n}=this.repository.getMessage(e);this._stopSpeaking?.();const r=t.speak(bi(n)),s=r.subscribe(()=>{r.status.type==="ended"?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:e,status:r.status},this._notifySubscribers()});this.speech={messageId:e,status:r.status},this._notifySubscribers(),this._stopSpeaking=()=>{r.cancel(),s(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw new Error("No message is being spoken");this._stopSpeaking(),this._notifySubscribers()}connectVoice(){const e=this.adapters?.voice;if(!e)throw new Error("Voice adapter not configured");this.disconnectVoice();const t=e.connect({});this._voiceSession=t;const n=[];let r="listening";this.voice={status:t.status,isMuted:t.isMuted,mode:r},this._voiceVolume=0,this._notifySubscribers(),n.push(t.onStatusChange(s=>{s.type==="ended"?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0):this.voice={status:s,isMuted:t.isMuted,mode:r},this._notifySubscribers()})),n.push(t.onModeChange(s=>{r=s,this.voice&&(this.voice={...this.voice,mode:s},this._notifySubscribers())})),n.push(t.onVolumeChange(s=>{this._voiceVolume=s;for(const i of this._voiceVolumeSubscribers)i()})),n.push(t.onTranscript(s=>{this._handleVoiceTranscript(s)})),this._voiceUnsubs=n}_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role==="user")this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal&&(this._voiceMessages.push({id:Vn(),role:"user",content:[{type:"text",text:e.text}],metadata:{custom:{}},createdAt:new Date,status:{type:"complete",reason:"unknown"},attachments:[]}),this._markVoiceMessagesDirty(),this._notifySubscribers());else{if(!this._currentAssistantMsg)this._currentAssistantMsg={id:Vn(),role:"assistant",content:[{type:"text",text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},status:{type:"running"},createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{const t=this._voiceMessages.indexOf(this._currentAssistantMsg);if(t===-1)return;const n={...this._currentAssistantMsg,content:[{type:"text",text:e.text}],...e.isFinal?{status:{type:"complete",reason:"stop"}}:{}};this._voiceMessages[t]=n,this._currentAssistantMsg=n}e.isFinal&&(this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(){const e=this._voiceMessages.at(-1);if(e?.role==="assistant"&&e.status.type==="running"){const t=this._voiceMessages.length-1;this._voiceMessages[t]={...e,status:{type:"complete",reason:"stop"}},this._markVoiceMessagesDirty(),this._notifySubscribers()}}disconnectVoice(){this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null;for(const e of this._voiceUnsubs)e();this._voiceUnsubs=[],this._voiceSession?.disconnect(),this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;for(const e of this._voiceVolumeSubscribers)e();this._voiceMessages=[],this._markVoiceMessagesDirty(),this._notifySubscribers()}muteVoice(){if(!this._voiceSession)throw new Error("No active voice session");this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw new Error("No active voice session");this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers("initialize",{}))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(Ov.fromArray(e??[]))}unstable_on(e,t){const n=t;if(e==="modelContextUpdate")return this._contextProvider.subscribe?.(()=>n({}))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e==="initialize"&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&n({})}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},Mh=class{constructor(){T(this,"cache",new WeakMap)}convertMessages(e,t){return e.map((n,r)=>{const s=t(this.cache.get(n),n,r);return this.cache.set(n,s),s})}};function Qu(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function sa(e,t=0){return t>100?!1:e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?!Number.isNaN(e)&&Number.isFinite(e):Array.isArray(e)?e.every(n=>sa(n,t+1)):Qu(e)?Object.entries(e).every(([n,r])=>typeof n=="string"&&sa(r,t+1)):!1}const d1=100,Yu=(e,t,n)=>{if(e===t)return!0;if(n>d1||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((i,o)=>Yu(i,t[o],n+1));if(Array.isArray(t)||!Qu(e)||!Qu(t))return!1;const r=Object.keys(e),s=Object.keys(t);return r.length!==s.length?!1:r.every(i=>Object.hasOwn(t,i)&&Yu(e[i],t[i],n+1))},f1=(e,t)=>!sa(e)||!sa(t)?!1:Yu(e,t,0),no=e=>{try{return JSON.parse(e),!0}catch{return!1}},Dh=e=>{try{return JSON.parse(e)}catch{return}},Lh=(e,t)=>{const n=Dh(e),r=Dh(t);return n===void 0||r===void 0?!1:f1(n,r)};var h1=class{constructor(e,t){T(this,"_getTools");T(this,"_callbacks");T(this,"_entries",new Map);T(this,"_skipExecuteStreamIds",new Set);T(this,"_humanInput",new Map);T(this,"_executing",new Set);T(this,"_settledResolvers",[]);T(this,"_statuses",new Map);T(this,"_ac",new AbortController);T(this,"_pendingRestore",!0);T(this,"_lastSnapshot",null);T(this,"_isRunning",!1);T(this,"_controller");T(this,"_pipelineDead",!1);T(this,"_pipelineRestartUsed",!1);this._getTools=e,this._callbacks=t,this._initPipeline()}_initPipeline(){const[e,t]=r_();this._controller=t;const n=S_(()=>this._getWrappedTools(),()=>this._ac.signal,(r,s)=>this._onHumanInput(r,s),{onExecutionStart:r=>this._onExecutionStart(r),onExecutionEnd:r=>this._onExecutionEnd(r)});e.pipeThrough(n).pipeThrough(new vv).pipeTo(new WritableStream({write:r=>{try{if(r.type!=="result")return;this._handleResultChunk(r)}catch(s){console.error("[ToolInvocationTracker] result chunk handling failed",s)}}})).catch(r=>{console.error("[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState",r),this._pipelineDead=!0})}setState(e){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===e.messages&&this._lastSnapshot.isRunning===e.isRunning&&this._lastSnapshot.isLoading===e.isLoading)return;e.isLoading===!0&&(this._pendingRestore=!0);const t=this._isRunning;this._isRunning=e.isRunning;try{this._processMessages(e.messages)}catch(n){throw this._isRunning=t,n}this._lastSnapshot=e,this._pendingRestore=!1}catch(t){console.error("[ToolInvocationTracker] setState failed; snapshot dropped",t)}}reset(){try{this._pendingRestore=!0,this._entries.clear(),this._lastSnapshot=null,this.abort().finally(()=>{this._executing.clear()})}catch(e){console.error("[ToolInvocationTracker] reset failed",e)}}abort(){try{return this._humanInput.forEach(({reject:e})=>{try{e(new Error("Tool execution aborted"))}catch{}}),this._humanInput.clear(),this._ac.abort(),this._ac=new AbortController,this._executing.size===0?Promise.resolve():new Promise(e=>{this._settledResolvers.push(e)})}catch(e){return console.error("[ToolInvocationTracker] abort failed",e),Promise.resolve()}}resume(e,t){try{const n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:"executing"}),n.resolve(t),!0):!1}catch(n){return console.error("[ToolInvocationTracker] resume failed",n),!1}}getStatuses(){return this._statuses}_getWrappedTools(){const e=this._getTools();if(e)return Object.fromEntries(Object.entries(e).map(([t,n])=>{const r=n.execute;return r===void 0?[t,n]:[t,{...n,execute:(...[s,i])=>this._skipExecuteStreamIds.has(i.toolCallId)?new Promise(()=>{}):r(s,i)}]}))}_onHumanInput(e,t){return new Promise((n,r)=>{const s=this._humanInput.get(e);if(s)try{s.reject(new Error("Human input request was superseded by a new request"))}catch{}this._humanInput.set(e,{resolve:n,reject:r}),this._setStatus(e,{type:"interrupt",payload:{type:"human",payload:t}})})}_onExecutionStart(e){this._skipExecuteStreamIds.has(e)||(this._executing.add(e),this._setStatus(e,{type:"executing"}))}_onExecutionEnd(e){this._executing.delete(e)&&(this._deleteStatus(e),this._executing.size===0&&this._settledResolvers.splice(0).forEach(t=>{try{t()}catch{}}))}_handleResultChunk(e){const t=e.meta.toolCallId,n=this._entries.get(t);!n&&this._skipExecuteStreamIds.has(t)||n?.hasResult||this._invokeOnResult({type:"add-tool-result",toolCallId:t,toolName:e.meta.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}})}_invokeOnResult(e){try{this._callbacks.onResult(e)}catch(t){console.error("[ToolInvocationTracker] onResult callback threw; result dropped",t)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(e){console.error("[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated",e)}}_setStatus(e,t){const n=new Map(this._statuses);n.set(e,t),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(e){if(!this._statuses.has(e))return;const t=new Map(this._statuses);t.delete(e),this._statuses=t,this._invokeOnStatusesChange()}_hasExecutableTool(e){const t=this._getTools()?.[e];return t?.execute!==void 0||t?.streamCall!==void 0}_shouldCloseArgsStream({toolName:e,argsText:t,hasResult:n}){return n?!0:(this._hasExecutableTool(e)||!this._isRunning)&&no(t)}_startActiveEntry(e,t,n){const r=this._controller.addToolCallPart({toolName:t,toolCallId:e});n&&this._skipExecuteStreamIds.add(e);const s={toolName:t,controller:r,argsText:"",hasResult:!1,argsComplete:!1};return this._entries.set(e,s),s}_demoteEntriesToRestored(){for(const[e,t]of this._entries)t.controller&&this._entries.set(e,{toolName:t.toolName,argsText:t.argsText,hasResult:t.hasResult})}_processArgsText(e,t){if(!e.controller)return;const n=t.result!==void 0;if(t.argsText!==e.argsText){let r=!0;if(e.argsComplete)Lh(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText))if(no(e.argsText)&&no(t.argsText)&&Lh(e.argsText,t.argsText)){const s=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});s&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=s,r=!1}else r=!1;if(r&&e.controller){const s=t.argsText.slice(e.argsText.length);e.controller.argsText.append(s);const i=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n})&&(e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=!0)}_processMessages(e){const t=this._pendingRestore;for(const n of e)if(!(!n||!Array.isArray(n.content)))for(const r of n.content){if(!r||r.type!=="tool-call")continue;const s=this._entries.get(r.toolCallId);if(t){s?.controller||this._entries.set(r.toolCallId,{toolName:r.toolName,argsText:r.argsText,hasResult:r.result!==void 0}),r.messages&&this._processMessages(r.messages);continue}let i=s;if(i&&!i.controller){if(!(r.argsText!==i.argsText||r.result!==void 0!==i.hasResult)){r.messages&&this._processMessages(r.messages);continue}this._entries.delete(r.toolCallId),i=void 0}if(i||(i=this._startActiveEntry(r.toolCallId,r.toolName,r.result!==void 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 hn({result:r.result,artifact:r.artifact,isError:r.isError,...r.modelContent!==void 0?{modelContent:r.modelContent}:{}})),o.close()}r.messages&&this._processMessages(r.messages)}}};const p1=Object.freeze([]),Oh=(e,t)=>{const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(e[r]!==t[r])return!1;return!0},m1=(e,t)=>e&&t[t.length-1]?.role!=="assistant";var g1=class extends c1{constructor(t,n){super(t);T(this,"_capabilities",{switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,reload:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1});T(this,"_messages");T(this,"isDisabled");T(this,"isSendDisabled");T(this,"suggestions",[]);T(this,"extras");T(this,"_converter",new Mh);T(this,"_store");T(this,"_toolInvocations",null);T(this,"_toolCallToMessageId",new Map);T(this,"_messagesForToolCallIndex",null);T(this,"updateMessages",t=>{this._store.convertMessage!==void 0?this._store.setMessages?.(t.flatMap(P_)):this._store.setMessages?.(t)});this.__internal_setAdapter(n)}get capabilities(){return this._capabilities}get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}beginEdit(t){if(!this._store.onEdit)throw new Error("Runtime does not support editing.");super.beginEdit(t)}__internal_setAdapter(t){if(this._store===t)return;const n=t.isRunning??!1;this.isDisabled=t.isDisabled??!1,this.isSendDisabled=t.isSendDisabled??!1;const r=this._store;this._store=t,this.extras!==t.extras&&(this.extras=t.extras);const s=t.suggestions??p1;Oh(this.suggestions,s)||(this.suggestions=s);const i={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,reload:this._store.onReload!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:!1};Oh(this._capabilities,i)||(this._capabilities=i);let o;if(t.messageRepository){if(r&&r.isRunning===t.isRunning&&r.messageRepository===t.messageRepository){this._notifySubscribers();return}this.repository.clear(),this.repository.import(t.messageRepository),o=this.repository.getMessages()}else if(t.messages){if(r){if(r.convertMessage!==t.convertMessage)this._converter=new Mh;else if(r.isRunning===t.isRunning&&r.messages===t.messages){this._notifySubscribers();return}}o=t.convertMessage?this._converter.convertMessages(t.messages,(l,u,f)=>{if(!t.convertMessage)return u;const d=ra(f===(t.messages?.length??0)-1,n,!1,!1,void 0);if(l&&(l.role!=="assistant"||!s1(l.status)||l.status===d))return l;const h=Si(t.convertMessage(u,f),f.toString(),d);return R_(h,u),h}):t.messages;for(let l=0;l<o.length;l++){const u=o[l],f=o[l-1];this.repository.addOrUpdateMessage(f?.id??null,u)}}else throw new Error("ExternalStoreAdapter must provide either 'messages' or 'messageRepository'");o.length>0&&this.ensureInitialized(),(r?.isRunning??!1)!==(t.isRunning??!1)&&(t.isRunning?this._notifyEventSubscribers("runStart",{}):this._notifyEventSubscribers("runEnd",{}));let a=null;m1(n,o)&&(a=Vn(),this.repository.addOrUpdateMessage(o.at(-1)?.id??null,Si({role:"assistant",content:[],metadata:{isOptimistic:!0}},a,{type:"running"}))),this.repository.resetHead(a??o.at(-1)?.id??null),this._messages=this.repository.getMessages(),this._driveToolInvocations(),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._store.setToolStatuses?.({}));return}this._toolInvocations||(this._toolInvocations=new h1(()=>this.getModelContext().tools,{onResult:t=>{try{const n=this._findMessageIdForToolCall(t.toolCallId);if(n===void 0)return;this._store.onAddToolResult?.({messageId:n,toolCallId:t.toolCallId,toolName:t.toolName,result:t.result,isError:t.isError,...t.artifact!==void 0&&{artifact:t.artifact},...t.modelContent!==void 0&&{modelContent:t.modelContent}})}catch(n){console.error("[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed",n)}},onStatusesChange:t=>{this._store.setToolStatuses?.(Object.fromEntries(t))}})),this._toolInvocations.setState({messages:this._messages,isRunning:this._store.isRunning??!1,...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_findMessageIdForToolCall(t){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();const n=r=>{for(const s of r)if(Array.isArray(s.content))for(const i of s.content)!i||i.type!=="tool-call"||(this._toolCallToMessageId.set(i.toolCallId,s.id),i.messages&&n(i.messages))};n(this._messages),this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(t)}switchToBranch(t){if(!this._store.setMessages)throw new Error("Runtime does not support switching branches.");this._store.isRunning||(this.repository.switchToBranch(t),this.updateMessages(this.repository.getMessages()))}async append(t){if((t.startRun??t.role==="user")&&await this._toolInvocations?.abort(),t.parentId!==(this.messages.at(-1)?.id??null)){if(!this._store.onEdit)throw new Error("Runtime does not support editing messages.");await this._store.onEdit(t)}else await this._store.onNew(t)}async startRun(t){if(!this._store.onReload)throw new Error("Runtime does not support reloading messages.");await this._toolInvocations?.abort(),await this._store.onReload(t.parentId,t)}async resumeRun(t){if(!this._store.onResume)throw new Error("Runtime does not support resuming runs.");await this._store.onResume(t)}exportExternalState(){if(!this._store.onExportExternalState)throw new Error("Runtime does not support exporting external states.");return this._store.onExportExternalState()}importExternalState(t){if(!this._store.onLoadExternalState)throw new Error("Runtime does not support importing external states.");this._toolInvocations&&(this._toolInvocations.reset(),this._store.setToolStatuses?.({})),this._store.onLoadExternalState(t)}cancelRun(){if(!this._store.onCancel)throw new Error("Runtime does not support cancelling runs.");this._toolInvocations?.abort(),this._store.onCancel();const t=this.repository.getMessages().at(-1);t&&t.metadata.isOptimistic&&t.content.length===0&&this.repository.deleteMessage(t.id);let n=this.repository.getMessages();const r=n[n.length-1];r?.role==="user"&&r.id===n.at(-1)?.id?(this.repository.deleteMessage(r.id),this.composer.text.trim()||this.composer.setText(bi(r)),n=this.repository.getMessages()):this._notifySubscribers(),setTimeout(()=>{this.updateMessages(n)},0)}addToolResult(t){if(!this._store.onAddToolResult)throw new Error("Runtime does not support tool results.");this._store.onAddToolResult?.(t)}resumeToolCall(t){if(!(this._toolInvocations?.resume(t.toolCallId,t.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(t);return}throw new Error(`Tool call ${t.toolCallId} is not waiting for resume.`)}}respondToToolApproval(t){if(!this._store.onRespondToToolApproval)throw new Error("Runtime does not support tool approvals.");this._store.onRespondToToolApproval(t)}reset(t){const n=new wd;n.import(Ov.fromArray(t??[])),this.updateMessages(n.getMessages())}import(t){super.import(t),this._store.onImport&&this._store.onImport(this.repository.getMessages())}};const zh=e=>e.adapters?.threadList??{};var y1=class extends Lv{constructor(t){super();T(this,"threads");this.threads=new Z_(zh(t),()=>new g1(this._contextProvider,t))}setAdapter(t){this.threads.__internal_setAdapter(zh(t)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(t)}};const Fa=e=>{const[t]=m.useState(()=>new y1(e));m.useEffect(()=>{t.setAdapter(e)});const{modelContext:n}=K_()??{};return m.useEffect(()=>{if(n)return t.registerModelContextProvider(n)},[n,t]),m.useMemo(()=>new Dv(t),[t])},Bv=(e,t)=>e.Message===t.Message&&e.EditComposer===t.EditComposer&&e.UserEditComposer===t.UserEditComposer&&e.AssistantEditComposer===t.AssistantEditComposer&&e.SystemEditComposer===t.SystemEditComposer&&e.UserMessage===t.UserMessage&&e.AssistantMessage===t.AssistantMessage&&e.SystemMessage===t.SystemMessage,v1=()=>null,x1=(e,t,n)=>{switch(t){case"user":return n?e.UserEditComposer??e.EditComposer??e.UserMessage??e.Message:e.UserMessage??e.Message;case"assistant":return n?e.AssistantEditComposer??e.EditComposer??e.AssistantMessage??e.Message:e.AssistantMessage??e.Message;case"system":return n?e.SystemEditComposer??e.EditComposer??e.SystemMessage??e.Message:e.SystemMessage??e.Message??v1;default:throw new Error(`Unknown message role: ${t}`)}},$v=({components:e})=>c.jsx(x1(e,V(t=>t.message.role),V(t=>t.message.composer.isEditing)),{}),Uv=m.memo(({index:e,components:t})=>c.jsx(Ev,{index:e,children:c.jsx($v,{components:t})}),(e,t)=>e.index===t.index&&Bv(e.components,t.components));Uv.displayName="ThreadPrimitive.MessageByIndex";const Fh=({children:e})=>{const t=V(n=>n.thread.messages.length);return m.useMemo(()=>t===0?null:Array.from({length:t},(n,r)=>c.jsx(Ev,{index:r,children:c.jsx(fs,{getItemState:s=>s.thread().message({index:r}).getState(),children:s=>e({get message(){return s()}})})},r)),[t,e])},Vv=({components:e,children:t})=>e?c.jsx(Fh,{children:()=>c.jsx($v,{components:e})}):c.jsx(Fh,{children:t});Vv.displayName="ThreadPrimitive.Messages";const w1=m.memo(Vv,(e,t)=>e.children||t.children?e.children===t.children:Bv(e.components,t.components)),Hv=e=>{const t=e.message.metadata;if(!(!t||typeof t!="object"))return t.custom?.quote};var b1=class extends Error{constructor(t,n=`Component "${t}" is not in the generative-ui allowlist.`){super(n);T(this,"componentName");this.name="GenerativeUIRenderError",this.componentName=t}};const S1=e=>typeof e=="object"&&e!==null,Wv=(e,t,n,r)=>{if(e==null)return null;if(typeof e=="string")return e;if(!S1(e)||!("component"in e))return null;const{component:s,props:i,children:o,key:a}=e,l=t[s];if(!l){if(n)return c.jsx(n,{component:s,props:i},a??r);throw new b1(s)}const u=o?.length?o.map((f,d)=>Wv(f,t,n,`${r}/${d}`)):void 0;return m.createElement(l,{...i??{},key:a??r},...u??[])},k1=e=>{if(!e||e.root===void 0||e.root===null)return[];const t=e.root;return Array.isArray(t)?t:[t]},bd=({spec:e,components:t,Fallback:n})=>c.jsx(c.Fragment,{children:m.useMemo(()=>k1(e),[e]).map((r,s)=>Wv(r,t,n,`${s}`))});bd.displayName="GenerativeUIRender";const qv=({components:e,spec:t,Fallback:n})=>{const r=V(i=>{const o=i.part;return o?.type==="generative-ui"?o.spec:void 0}),s=t??r;return s?c.jsx(bd,{spec:s,components:e,Fallback:n}):null};qv.displayName="MessagePrimitive.GenerativeUI";const C1="ui://",_1=e=>!!e?.startsWith(C1),Bh=e=>Symbol.iterator in e,$h=e=>"entries"in e,Uh=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(const[s,i]of n)if(!r.has(s)||!Object.is(i,r.get(s)))return!1;return!0},E1=(e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let s=n.next(),i=r.next();for(;!s.done&&!i.done;){if(!Object.is(s.value,i.value))return!1;s=n.next(),i=r.next()}return!!s.done&&!!i.done};function T1(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Bh(e)&&Bh(t)?$h(e)&&$h(t)?Uh(e,t):E1(e,t):Uh({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function Kv(e){const t=ut.useRef(void 0);return n=>{const r=e(n);return T1(t.current,r)?t.current:t.current=r}}const Rl=e=>{let t=-1;return{startGroup:n=>{t===-1&&(t=n)},endGroup:(n,r)=>{t!==-1&&(r.push({type:e,startIndex:t,endIndex:n}),t=-1)},finalize:(n,r)=>{t!==-1&&r.push({type:e,startIndex:t,endIndex:n})}}},I1=(e,t)=>{const n=[];if(t){const r=Rl("chainOfThoughtGroup");for(let s=0;s<e.length;s++){const i=e[s];i==="tool-call"||i==="reasoning"?r.startGroup(s):(r.endGroup(s-1,n),n.push({type:"single",index:s}))}r.finalize(e.length-1,n)}else{const r=Rl("toolGroup"),s=Rl("reasoningGroup");for(let i=0;i<e.length;i++){const o=e[i];o==="tool-call"?(s.endGroup(i-1,n),r.startGroup(i)):o==="reasoning"?(r.endGroup(i-1,n),s.startGroup(i)):(r.endGroup(i-1,n),s.endGroup(i-1,n),n.push({type:"single",index:i}))}r.finalize(e.length-1,n),s.finalize(e.length-1,n)}return n},R1=e=>{const t=V(Kv(n=>n.message.parts.map(r=>r.type)));return m.useMemo(()=>t.length===0?[]:I1(t,e),[t,e])},P1=({Fallback:e,...t})=>{const n=V(r=>r.tools.toolUIs[t.toolName]?.[0]?.render??e);return n?c.jsx(n,{...t}):null},Sd=(e,t,n)=>{const r=e.renderers[t]?.[0];return r||(e.fallbacks[0]??n)},A1=({Fallback:e,...t})=>{const n=V(r=>Sd(r.dataRenderers,t.name,e));return n?c.jsx(n,{...t}):null},Ye={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},j1=({components:{Text:e=Ye.Text,Reasoning:t=Ye.Reasoning,Image:n=Ye.Image,Source:r=Ye.Source,File:s=Ye.File,Unstable_Audio:i=Ye.Unstable_Audio,tools:o={},data:a,generativeUI:l}={}})=>{const u=se(),f=V(h=>h.part),d=f.type;if(d==="tool-call"){const h=u.part().addToolResult,p=u.part().resumeToolCall,g=u.part().respondToToolApproval;if("Override"in o)return c.jsx(o.Override,{...f,addResult:h,resume:p,respondToApproval:g});const x=o.by_name?.[f.toolName]??o.Fallback;return c.jsx(P1,{...f,Fallback:x,addResult:h,resume:p,respondToApproval:g})}if(f.status?.type==="requires-action")throw new Error("Encountered unexpected requires-action status");switch(d){case"text":return c.jsx(e,{...f});case"reasoning":return c.jsx(t,{...f});case"source":return c.jsx(r,{...f});case"image":return c.jsx(n,{...f});case"file":return c.jsx(s,{...f});case"audio":return c.jsx(i,{...f});case"data":{const h=a?.by_name?.[f.name]??a?.Fallback;return c.jsx(A1,{...f,Fallback:h})}case"generative-ui":return l?.components?c.jsx(bd,{spec:f.spec,components:l.components,Fallback:l.Fallback}):null;default:return console.warn(`Unknown message part type: ${d}`),null}},Ys=m.memo(({index:e,components:t})=>c.jsx(yd,{index:e,children:c.jsx(j1,{components:t})}),(e,t)=>e.index===t.index&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.generativeUI===t.components?.generativeUI&&e.components?.ToolGroup===t.components?.ToolGroup&&e.components?.ReasoningGroup===t.components?.ReasoningGroup);Ys.displayName="MessagePrimitive.PartByIndex";const N1=({status:e,component:t})=>c.jsx(vd,{text:"",isRunning:e.type==="running",children:c.jsx(t,{type:"text",text:"",status:e})}),M1=Object.freeze({type:"complete"}),D1=Object.freeze({type:"running"}),L1=({components:e})=>{const t=V(n=>n.message.status??M1);return e?.Empty?c.jsx(e.Empty,{status:t}):t.type!=="running"?null:c.jsx(N1,{status:t,component:e?.Text??Ye.Text})},Gv=m.memo(L1,(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),O1=({components:e,enabled:t})=>V(n=>{if(!t||n.message.parts.length===0)return!1;const r=n.message.parts[n.message.parts.length-1];return r?.type!=="text"&&r?.type!=="reasoning"})?c.jsx(Gv,{components:e}):null,z1=m.memo(O1,(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),F1=({Quote:e})=>{const t=V(Hv);return t?c.jsx(e,{text:t.text,messageId:t.messageId}):null},B1=m.memo(F1);function Qv(e,t){const n=e.toolUIs[t.toolName]?.[0]?.render??null;return n||(_1(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}const Yv=()=>{const e=se(),t=V(r=>r.part),n=V(r=>r.part.type==="tool-call"?Qv(r.tools,r.part):null);return!n||t.type!=="tool-call"?null:c.jsx(n,{...t,addResult:e.part().addToolResult,resume:e.part().resumeToolCall,respondToApproval:e.part().respondToToolApproval})},Jv=()=>{const e=V(n=>n.part),t=V(n=>n.part.type==="data"?Sd(n.dataRenderers,n.part.name,void 0)??null:null);return!t||e.type!=="data"?null:c.jsx(t,{...e})},$1=()=>{const e=V(t=>t.part.type);return e==="tool-call"?c.jsx(Yv,{}):e==="data"?c.jsx(Jv,{}):null},U1=Object.freeze({type:"text",text:"",status:D1}),Xv=({index:e,children:t})=>{const n=se(),r=V(s=>s.dataRenderers);return c.jsx(yd,{index:e,children:c.jsx(fs,{getItemState:s=>s.message().part({index:e}).getState(),children:s=>t({get part(){const i=s();if(i.type==="tool-call"){const o=Qv(n.tools().getState(),i)!==null,a=n.message().part({index:e});return{...i,toolUI:o?c.jsx(Yv,{}):null,addResult:a.addToolResult,resume:a.resumeToolCall,respondToApproval:a.respondToToolApproval}}if(i.type==="data"){const o=Sd(r,i.name,void 0)!==void 0;return{...i,dataRendererUI:o?c.jsx(Jv,{}):null}}return i}})})})},V1=({children:e})=>{const t=V(s=>s.message.parts.length),n=V(s=>(s.message.status?.type??"complete")==="running"),r=t===0&&n;return t===0?r?c.jsx(vd,{text:"",isRunning:!0,children:e({part:U1})}):null:c.jsx(c.Fragment,{children:Array.from({length:t},(s,i)=>c.jsx(Xv,{index:i,children:o=>e(o)??c.jsx($1,{})},i))})},Ju=({components:e,unstable_showEmptyOnNonTextEnd:t=!0,children:n})=>n?c.jsx(V1,{children:n}):c.jsx(H1,{components:e,unstable_showEmptyOnNonTextEnd:t});Ju.displayName="MessagePrimitive.Parts";const H1=({components:e,unstable_showEmptyOnNonTextEnd:t})=>{const n=V(i=>i.message.parts.length),r=R1(!!e?.ChainOfThought),s=m.useMemo(()=>n===0?c.jsx(Gv,{components:e}):r.map(i=>{if(i.type==="single")return c.jsx(Ys,{index:i.index,components:e},i.index);if(i.type==="chainOfThoughtGroup"){const o=e?.ChainOfThought;return o?c.jsx(E_,{startIndex:i.startIndex,endIndex:i.endIndex,children:c.jsx(o,{})},`chainOfThought-${i.startIndex}`):null}else return i.type==="toolGroup"?c.jsx(e?.ToolGroup??Ye.ToolGroup,{startIndex:i.startIndex,endIndex:i.endIndex,children:Array.from({length:i.endIndex-i.startIndex+1},(o,a)=>{const l=i.startIndex+a;return c.jsx(Ys,{index:l,components:e},`part-${l}`)})},`tool-${i.startIndex}`):c.jsx(e?.ReasoningGroup??Ye.ReasoningGroup,{startIndex:i.startIndex,endIndex:i.endIndex,children:Array.from({length:i.endIndex-i.startIndex+1},(o,a)=>{const l=i.startIndex+a;return c.jsx(Ys,{index:l,components:e},`part-${l}`)})},`reasoning-${i.startIndex}`)}),[r,e,n]);return c.jsxs(c.Fragment,{children:[e?.Quote&&c.jsx(B1,{Quote:e.Quote}),s,c.jsx(z1,{components:e,enabled:t})]})},W1=Symbol.for("@assistant-ui/groupBy.memoKey"),Vh=e=>{const t=e.nextChildIdx++;return e.nodeKey===""?String(t):`${e.nodeKey}.${t}`},q1=e=>{const t={key:"",nodeKey:"",indices:[],children:[],nextChildIdx:0},n=[t],r=()=>{const s=n.pop();n[n.length-1].children.push({type:"group",key:s.key,nodeKey:s.nodeKey,indices:s.indices,children:s.children})};for(let s=0;s<e.length;s++){const i=e[s];let o=0;for(;o<n.length-1&&o<i.length&&n[o+1].key===i[o];)o++;for(;n.length-1>o;)r();for(;n.length-1<i.length;){const l=n[n.length-1];n.push({key:i[n.length-1],nodeKey:Vh(l),indices:[],children:[],nextChildIdx:0})}const a=n[n.length-1];a.children.push({type:"part",index:s,nodeKey:Vh(a)});for(let l=1;l<n.length;l++)n[l].indices.push(s)}for(;n.length>1;)r();return t.children},K1=Object.freeze({type:"complete"}),G1=(e,t,n)=>{if(!n)return!1;switch(e){case"never":return!1;case"always":return!0;case"empty":return t.length===0;case"no-text":{const r=t[t.length-1];return r!==void 0&&r.type!=="text"&&r.type!=="reasoning"}}},Zv=()=>{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.")},ex=(e,t,n)=>{if(e.type==="part")return c.jsx(Xv,{index:e.index,children:({part:s})=>n({part:s,children:c.jsx(Zv,{})})},`part-${e.index}`);const r=t[e.indices.at(-1)]?.status??K1;return c.jsx(m.Fragment,{children:n({part:{type:e.key,status:r,indices:e.indices},children:c.jsx(c.Fragment,{children:e.children.map(s=>ex(s,t,n))})})},e.nodeKey)},tx=({groupBy:e,indicator:t="no-text",children:n})=>{const r=V(Kv(o=>o.message.parts)),s=V(o=>o.tools.toolUIs),i=V(o=>t==="never"?!1:o.message.status?.type==="running");return c.jsxs(c.Fragment,{children:[m.useMemo(()=>{const o={toolUIs:s};return q1(r.map(a=>e(a,o)??[]))},[r,e[W1]??e,s]).map(o=>ex(o,r,n)),G1(t,r,i)&&n({part:{type:"indicator"},children:c.jsx(Zv,{})})]})};tx.displayName="MessagePrimitive.GroupedParts";const Q1=({children:e})=>{const t=V(Hv);return t?c.jsx(c.Fragment,{children:e(t)}):null},nx=m.memo(Q1);nx.displayName="MessagePrimitive.Quote";const rx=(e,t)=>{switch(t.type){case"image":return e?.Image??e?.Attachment;case"document":return e?.Document??e?.Attachment;case"file":return e?.File??e?.Attachment;default:return e?.Attachment}},Y1=({components:e})=>{const t=V(r=>r.attachment);if(!t)return null;const n=rx(e,t);return n?c.jsx(n,{}):null},sx=m.memo(({index:e,components:t})=>c.jsx(Cv,{index:e,children:c.jsx(Y1,{components:t})}),(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);sx.displayName="MessagePrimitive.AttachmentByIndex";const Hh=({children:e})=>{const t=V(n=>n.message.role!=="user"?0:(n.message.attachments??[]).length);return m.useMemo(()=>Array.from({length:t},(n,r)=>c.jsx(Cv,{index:r,children:c.jsx(fs,{getItemState:s=>s.message().attachment({index:r}).getState(),children:s=>e({get attachment(){return s()}})})},r)),[t,e])},ix=({components:e,children:t})=>e?c.jsx(Hh,{children:({attachment:n})=>{const r=rx(e,n);return r?c.jsx(r,{}):null}}):c.jsx(Hh,{children:t});ix.displayName="MessagePrimitive.Attachments";const ox=(e,t)=>{switch(t.type){case"image":return e?.Image??e?.Attachment;case"document":return e?.Document??e?.Attachment;case"file":return e?.File??e?.Attachment;default:return e?.Attachment}},J1=({components:e})=>{const t=V(r=>r.attachment);if(!t)return null;const n=ox(e,t);return n?c.jsx(n,{}):null},ax=m.memo(({index:e,components:t})=>c.jsx(_v,{index:e,children:c.jsx(J1,{components:t})}),(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);ax.displayName="ComposerPrimitive.AttachmentByIndex";const Wh=({children:e})=>{const t=V(n=>n.composer.attachments.length);return m.useMemo(()=>Array.from({length:t},(n,r)=>c.jsx(_v,{index:r,children:c.jsx(fs,{getItemState:s=>s.composer().attachment({index:r}).getState(),children:s=>e({get attachment(){return s()}})})},r)),[t,e])},lx=({components:e,children:t})=>e?c.jsx(Wh,{children:({attachment:n})=>{const r=ox(e,n);return r?c.jsx(r,{}):null}}):c.jsx(Wh,{children:t});lx.displayName="ComposerPrimitive.Attachments";const X1=({children:e})=>{const t=V(n=>n.composer.queue.length);return m.useMemo(()=>Array.from({length:t},(n,r)=>c.jsx(T_,{index:r,children:c.jsx(fs,{getItemState:s=>s.composer().queueItem({index:r}).getState(),children:s=>e({get queueItem(){return s()}})})},r)),[t,e])},ux=m.memo(X1);ux.displayName="ComposerPrimitive.Queue";const kd=({children:e})=>V(t=>t.part.status.type==="running")?e:null;kd.displayName="MessagePartPrimitive.InProgress";const cx=({components:e})=>{const t=e.Suggestion;return c.jsx(t,{})},dx=m.memo(({index:e,components:t})=>c.jsx(Tv,{index:e,children:c.jsx(cx,{components:t})}),(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);dx.displayName="ThreadPrimitive.SuggestionByIndex";const qh=({children:e})=>{const t=V(n=>n.suggestions.suggestions.length);return m.useMemo(()=>t===0?null:Array.from({length:t},(n,r)=>c.jsx(Tv,{index:r,children:c.jsx(fs,{getItemState:s=>s.suggestions().suggestion({index:r}).getState(),children:s=>e({get suggestion(){return s()}})})},r)),[t,e])},fx=({components:e,children:t})=>e?c.jsx(qh,{children:()=>c.jsx(cx,{components:e})}):c.jsx(qh,{children:t});fx.displayName="ThreadPrimitive.Suggestions";const Z1=m.memo(fx,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),eE=e=>V(t=>{if(e.editing===!0&&!t.composer.isEditing||e.editing===!1&&t.composer.isEditing)return!1;const n=t.composer.dictation!=null;return!(e.dictation===!0&&!n||e.dictation===!1&&n)}),hx=({children:e,...t})=>eE(t)?e:null;hx.displayName="ComposerPrimitive.If";const tE=()=>{const e=se(),t=V(n=>!n.composer.canSend||n.thread.isRunning&&!n.thread.capabilities.queue);return{send:m.useCallback(n=>{e.composer().send(n)},[e]),disabled:t}},nE=()=>{const e=se(),t=V(n=>!n.composer.canCancel);return{cancel:m.useCallback(()=>{e.composer().cancel()},[e]),disabled:t}},rE=()=>{const e=se(),t=V(n=>n.composer.dictation!=null||!n.thread.capabilities.dictation||!n.composer.isEditing);return{startDictation:m.useCallback(()=>{e.composer().startDictation()},[e]),disabled:t}},sE=()=>{const e=se(),t=V(n=>!n.composer.isEditing);return{addAttachment:m.useCallback(n=>e.composer().addAttachment(n),[e]),disabled:t}},iE=({copiedDuration:e=3e3,copyToClipboard:t}={})=>{const n=se(),r=V(a=>!((a.message.role!=="assistant"||a.message.status?.type!=="running")&&a.message.parts.some(l=>l.type==="text"&&l.text.length>0))),s=V(a=>a.message.isCopied),i=V(a=>a.composer.isEditing),o=V(a=>a.composer.text);return{copy:m.useCallback(()=>{const a=i?o:n.message().getCopyText();if(!a)return;const l=t??(()=>{});Promise.resolve(l(a)).then(()=>{n.message().setIsCopied(!0),setTimeout(()=>n.message().setIsCopied(!1),e)},()=>{})},[n,i,o,e,t]),disabled:r,isCopied:s}},oE=()=>{const e=se(),t=V(n=>n.composer.isEditing);return{edit:m.useCallback(()=>{e.composer().beginEdit()},[e]),disabled:t}},aE=()=>{const e=se(),t=V(n=>n.thread.isRunning||n.thread.isDisabled||n.message.role!=="assistant");return{reload:m.useCallback(()=>{e.message().reload()},[e]),disabled:t}},lE=()=>{const e=se(),t=V(n=>n.message.metadata.submittedFeedback?.type==="positive");return{submit:m.useCallback(()=>{e.message().submitFeedback({type:"positive"})},[e]),isSubmitted:t}},uE=()=>{const e=se(),t=V(n=>n.message.metadata.submittedFeedback?.type==="negative");return{submit:m.useCallback(()=>{e.message().submitFeedback({type:"negative"})},[e]),isSubmitted:t}},cE=()=>{const e=se(),t=V(n=>!((n.message.role!=="assistant"||n.message.status?.type!=="running")&&n.message.parts.some(r=>r.type==="text"&&r.text.length>0)));return{speak:m.useCallback(async()=>{e.message().speak()},[e]),disabled:t}},dE=()=>{const e=se(),t=V(n=>n.message.speech==null);return{stopSpeaking:m.useCallback(()=>{e.message().stopSpeaking()},[e]),disabled:t}},fE=({prompt:e,send:t,clearComposer:n=!0})=>{const r=se(),s=V(o=>o.thread.isDisabled),i=t??!1;return{trigger:m.useCallback(()=>{const o=r.thread().getState().isRunning;if(i&&!o)r.thread().append({content:[{type:"text",text:e}],runConfig:r.composer().getState().runConfig}),n&&r.composer().setText("");else if(n)r.composer().setText(e);else{const a=r.composer().getState().text;r.composer().setText(a.trim()?`${a} ${e}`:e)}},[r,i,n,e]),disabled:s}},hE=()=>V(e=>e.message.status?.type==="incomplete"&&e.message.status.reason==="error"?e.message.status.error??"An error occurred":void 0),pE=e=>{const{cloud:t,initialMessages:n,maxSteps:r,adapters:s,unstable_humanToolNames:i,...o}=e;return{localRuntimeOptions:{cloud:t,initialMessages:n,maxSteps:r,adapters:s,unstable_humanToolNames:i},otherOptions:o}},mE=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,px={serialize(e){const t=e.id!==e.label?`{name=${e.id}}`:"";return`:${e.type}[${e.label}]${t}`},parse(e){const t=[];let n=0;for(const r of e.matchAll(mE)){r.index>n&&t.push({kind:"text",text:e.slice(n,r.index)});const s=r[2];t.push({kind:"mention",type:r[1],label:s,id:r[3]??s}),n=r.index+r[0].length}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}};function gE(e,t){function n(r){const s=m.useContext(e);if(!r?.optional&&!s)throw new Error(`This component must be used within ${t}.`);return s}return n}function mx(e,t){function n(s){const i=e(s);return i?i[t]: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{[t]:r,[`${t}Store`]:n}}const gx=m.createContext(null),{useThreadViewport:wr,useThreadViewportStore:br}=mx(gE(gx,"ThreadPrimitive.Viewport"),"useThreadViewport"),Kh=e=>{const t=new Map,n=()=>{let r=0;for(const s of t.values())r+=s;e(r)};return{register:()=>{const r=Symbol();return t.set(r,0),{setHeight:s=>{t.get(r)!==s&&(t.set(r,s),n())},unregister:()=>{t.delete(r),n()}}}}},yE=(e={})=>{const t=new Set,n=Kh(o=>{i.setState({height:{...i.getState().height,viewport:o}})}),r=Kh(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=mv(()=>({isAtBottom:!0,scrollToBottom:({behavior:o="auto"}={})=>{for(const a of t)a({behavior:o})},onScrollToBottom:o=>(t.add(o),()=>{t.delete(o)}),turnAnchor:e.turnAnchor??"bottom",topAnchorMessageClamp:{tallerThan:e.topAnchorMessageClamp?.tallerThan??"10em",visibleHeight:e.topAnchorMessageClamp?.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:o=>s("viewport",o),registerAnchorElement:o=>s("anchor",o),registerAnchorTargetElement:(o,a)=>(i.setState({element:{...i.getState().element,target:o},targetConfig:o&&a?a:null}),()=>{i.getState().element.target===o&&i.setState({element:{...i.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:o=>{i.setState({topAnchorTurn:o})}}));return i},ia=e=>e,vE=e=>{const t=br({optional:!0}),[n]=m.useState(()=>yE(e));return m.useEffect(()=>t?.getState().onScrollToBottom(()=>{n.getState().scrollToBottom()}),[t,n]),m.useEffect(()=>{if(t)return n.subscribe(r=>{t.getState().isAtBottom!==r.isAtBottom&&ia(t).setState({isAtBottom:r.isAtBottom})})},[n,t]),n},Cd=({children:e,options:t={}})=>{const n=vE(t),[r]=m.useState(()=>({useThreadViewport:n}));return c.jsx(gx.Provider,{value:r,children:e})},xE=()=>{const e=se();return m.useEffect(()=>{},[e]),null},wE=({children:e,aui:t,runtime:n})=>c.jsxs(H0,{runtime:n,aui:t??null,children:[c.jsx(xE,{}),c.jsx(Cd,{children:e})]}),Ba=m.memo(wE),bE=e=>{const t=e;t.__isBound||(t.__internal_bindMethods?.(),t.__isBound=!0)};function SE(e,t=kE){bE(e);const n=m.useSyncExternalStore(e.subscribe,()=>t(e.getState()),()=>t(e.getState()));return m.useDebugValue(n),n}const kE=e=>e;function CE(e){function t(n){let r=!1,s;typeof n=="function"?s=n:n&&(r=!!n.optional,s=n.selector);const i=e({optional:r});return i?SE(i,s):null}return t}function _E(e){const t=se(),n=V(()=>t.composer.source?t.composer().__internal_getRuntime?.()??null:null);if(!n&&!e?.optional)throw new Error("ComposerRuntime is not available");return n}function EE(e){const t=se(),n=V(()=>t.message.source?t.message().__internal_getRuntime?.()??null:null);if(!n&&!e?.optional)throw new Error("MessageRuntime is not available");return n}const oa=CE(EE);function Gh(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function TE(...e){return t=>{let n=!1;const r=e.map(s=>{const i=Gh(s,t);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():Gh(e[s],null)}}}}function Sr(...e){return m.useCallback(TE(...e),e)}var Qh=Object.defineProperty,ms=(e,t)=>{let n={};for(var r in e)Qh(n,r,{get:e[r],enumerable:!0});return Qh(n,Symbol.toStringTag,{value:"Module"}),n};function yx(e){const t=m.forwardRef((n,r)=>{let{children:s,...i}=n,o=null,a=!1;const l=[];Yh(s)&&typeof ro=="function"&&(s=ro(s._payload)),m.Children.forEach(s,h=>{if(jE(h)){a=!0;const p=h;let g="child"in p.props?p.props.child:p.props.children;Yh(g)&&typeof ro=="function"&&(g=ro(g._payload)),o=RE(p,g),l.push(o?.props?.children)}else l.push(h)}),o?o=m.cloneElement(o,void 0,l):!a&&m.Children.count(s)===1&&m.isValidElement(s)&&(o=s);const u=o?AE(o):void 0,f=Sr(r,u);if(!o){if(s||s===0)throw new Error(a?LE(e):DE(e));return s}const d=PE(i,o.props??{});return o.type!==m.Fragment&&(d.ref=r?f:u),m.cloneElement(o,d)});return t.displayName=`${e}.Slot`,t}var aa=yx("Slot"),IE=Symbol.for("radix.slottable"),RE=(e,t)=>{if("child"in e.props){const n=e.props.child;return m.isValidElement(n)?m.cloneElement(n,void 0,e.props.children(n.props.children)):null}return m.isValidElement(t)?t:null};function PE(e,t){const n={...t};for(const r in t){const s=e[r],i=t[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{...e,...n}}function AE(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function jE(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===IE}var NE=Symbol.for("react.lazy");function Yh(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===NE&&"_payload"in e&&ME(e._payload)}function ME(e){return typeof e=="object"&&e!==null&&"then"in e}var DE=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,LE=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,ro=pS[" use ".trim().toString()],OE=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],zE=OE.reduce((e,t)=>{const n=yx(`Primitive.${t}`),r=m.forwardRef((s,i)=>{const{asChild:o,...a}=s,l=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});const FE=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"];function BE(e){const t=m.forwardRef(({render:n,asChild:r,children:s,...i},o)=>{const a=e;if(n&&m.isValidElement(n)){const l=s!==void 0?s:n.props.children;return c.jsx(a,{...i,asChild:!0,ref:o,children:m.cloneElement(n,void 0,l)})}return c.jsx(a,{...i,asChild:r,ref:o,children:s})});return t.displayName=typeof e=="string"?e:e.displayName??e.name??"Component",t}function $E(e){const t=zE[e],n=BE(t);return n.displayName=`Primitive.${e}`,n}const be=FE.reduce((e,t)=>(e[t]=$E(t),e),{}),UE=({hideWhenRunning:e,autohide:t,autohideFloat:n,forceVisible:r})=>V(s=>{if(e&&s.thread.isRunning)return"hidden";const i=t==="always"||t==="not-last"&&!s.message.isLast,o=r||s.message.isHovering;return i?o?n==="always"||n==="single-branch"&&s.message.branchCount<=1?"floating":"normal":"hidden":"normal"}),VE=m.createContext(null),vx=m.forwardRef(({hideWhenRunning:e,autohide:t,autohideFloat:n,...r},s)=>{const[i,o]=m.useState(0),a=m.useCallback(()=>{let f=!1;return o(d=>d+1),()=>{f||(f=!0,o(d=>Math.max(0,d-1)))}},[]),l=m.useMemo(()=>({acquireInteractionLock:a}),[a]),u=UE({hideWhenRunning:e,autohide:t,autohideFloat:n,forceVisible:i>0});return u==="hidden"?null:c.jsx(VE.Provider,{value:l,children:c.jsx(be.div,{...u==="floating"?{"data-floating":"true"}:null,...r,ref:s})})});vx.displayName="ActionBarPrimitive.Root";function Ee(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e?.(s),n===!1||!s.defaultPrevented)return t?.(s)}}const HE=({copiedDuration:e=3e3}={})=>{const{copy:t,disabled:n}=iE({copiedDuration:e,copyToClipboard:r=>typeof navigator>"u"||!navigator.clipboard?Promise.reject(new Error("Clipboard API is unavailable")):navigator.clipboard.writeText(r)});return n?null:t},xx=m.forwardRef(({copiedDuration:e,onClick:t,disabled:n,...r},s)=>{const i=V(a=>a.message.isCopied),o=HE({copiedDuration:e});return c.jsx(be.button,{type:"button",...i?{"data-copied":"true"}:{},...r,ref:s,disabled:n||!o,onClick:Ee(t,()=>{o?.()})})});xx.displayName="ActionBarPrimitive.Copy";const Wt=(e,t,n=[])=>{const r=m.forwardRef((s,i)=>{const o={},a={};Object.keys(s).forEach(u=>{n.includes(u)?o[u]=s[u]:a[u]=s[u]});const l=t(o)??void 0;return c.jsx(be.button,{...a,type:"button",ref:i,disabled:a.disabled||!l,onClick:Ee(a.onClick,l)})});return r.displayName=e,r},WE=()=>{const{disabled:e,reload:t}=aE();return e?null:t},qE=Wt("ActionBarPrimitive.Reload",WE),KE=()=>{const{disabled:e,edit:t}=oE();return e?null:t},GE=Wt("ActionBarPrimitive.Edit",KE),QE=()=>{const{disabled:e,speak:t}=cE();return e?null:t},YE=Wt("ActionBarPrimitive.Speak",QE);function mr(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>t.current?.(...n),[])}function wx(e,t=globalThis?.document){const n=mr(e);m.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}const JE=()=>{const{disabled:e,stopSpeaking:t}=dE();return e?null:t},bx=m.forwardRef((e,t)=>{const n=JE();return wx(r=>{n&&(r.preventDefault(),n())}),c.jsx(be.button,{type:"button",disabled:!n,...e,ref:t,onClick:Ee(e.onClick,()=>{n?.()})})});bx.displayName="ActionBarPrimitive.StopSpeaking";const XE=()=>{const{submit:e}=lE();return e},Sx=m.forwardRef(({onClick:e,disabled:t,...n},r)=>{const s=V(o=>o.message.metadata.submittedFeedback?.type==="positive"),i=XE();return c.jsx(be.button,{type:"button",...s?{"data-submitted":"true"}:{},...n,ref:r,disabled:t||!i,onClick:Ee(e,()=>{i?.()})})});Sx.displayName="ActionBarPrimitive.FeedbackPositive";const ZE=()=>{const{submit:e}=uE();return e},kx=m.forwardRef(({onClick:e,disabled:t,...n},r)=>{const s=V(o=>o.message.metadata.submittedFeedback?.type==="negative"),i=ZE();return c.jsx(be.button,{type:"button",...s?{"data-submitted":"true"}:{},...n,ref:r,disabled:t||!i,onClick:Ee(e,()=>{i?.()})})});kx.displayName="ActionBarPrimitive.FeedbackNegative";const eT=({filename:e,onExport:t}={})=>{const n=se(),r=V(i=>(i.message.role!=="assistant"||i.message.status?.type!=="running")&&i.message.parts.some(o=>o.type==="text"&&o.text.length>0)),s=m.useCallback(async()=>{const i=n.message().getCopyText();if(!i)return;if(t){await t(i);return}const o=new Blob([i],{type:"text/markdown"}),a=URL.createObjectURL(o),l=document.createElement("a");l.href=a,l.download=e??`message-${Date.now()}.md`,l.click(),URL.revokeObjectURL(a)},[n,e,t]);return r?s:null},Cx=m.forwardRef(({filename:e,onExport:t,onClick:n,disabled:r,...s},i)=>{const o=eT({filename:e,onExport:t});return c.jsx(be.button,{type:"button",...s,ref:i,disabled:r||!o,onClick:Ee(n,()=>{o?.()})})});Cx.displayName="ActionBarPrimitive.ExportMarkdown";var Jh=ms({Copy:()=>xx,Edit:()=>GE,ExportMarkdown:()=>Cx,FeedbackNegative:()=>kx,FeedbackPositive:()=>Sx,Reload:()=>qE,Root:()=>vx,Speak:()=>YE,StopSpeaking:()=>bx});const _x=m.forwardRef((e,t)=>c.jsx(be.div,{...e,ref:t}));_x.displayName="AttachmentPrimitive.Root";const Ex=m.forwardRef((e,t)=>{const n=V(r=>{const s=r.attachment.name.split(".");return s.length>1?s.pop():""});return c.jsxs(be.div,{...e,ref:t,children:[".",n]})});Ex.displayName="AttachmentPrimitive.unstable_Thumb";const Tx=()=>c.jsx(c.Fragment,{children:V(e=>e.attachment.name)});Tx.displayName="AttachmentPrimitive.Name";const tT=()=>{const e=se();return m.useCallback(()=>{e.attachment().remove()},[e])},nT=Wt("AttachmentPrimitive.Remove",tT);var Xh=ms({Name:()=>Tx,Remove:()=>nT,Root:()=>_x,unstable_Thumb:()=>Ex});const rT=e=>V(t=>{const{role:n,attachments:r,parts:s,branchCount:i,isLast:o,speech:a,isCopied:l,isHovering:u}=t.message;return!(e.hasBranches===!0&&i<2||e.user&&n!=="user"||e.assistant&&n!=="assistant"||e.system&&n!=="system"||e.lastOrHover===!0&&!u&&!o||e.last!==void 0&&e.last!==o||e.copied===!0&&!l||e.copied===!1&&l||e.speaking===!0&&a==null||e.speaking===!1&&a!=null||e.hasAttachments===!0&&(n!=="user"||!r?.length)||e.hasAttachments===!1&&n==="user"&&r?.length||e.hasContent===!0&&s.length===0||e.hasContent===!1&&s.length>0||e.submittedFeedback!==void 0&&(t.message.metadata.submittedFeedback?.type??null)!==e.submittedFeedback)}),Ix=({children:e,...t})=>rT(t)?e:null;Ix.displayName="MessagePrimitive.If";const Rx=m.createContext(null),$a=()=>m.useContext(Rx),sT=({children:e})=>{const t=m.useRef(new Map),n=m.useRef([]),r=m.useCallback(()=>{const a=Array.from(t.current.entries());a.sort((l,u)=>u[1]-l[1]),n.current=a.map(([l])=>l)},[]),s=m.useCallback((a,l)=>{const u=l?.priority??0;return t.current.set(a,u),r(),()=>{t.current.delete(a),r()}},[r]),i=m.useCallback(()=>n.current,[]),o=m.useMemo(()=>({register:s,getPlugins:i}),[s,i]);return c.jsx(Rx.Provider,{value:o,children:e})},_d=m.createContext(null),Px=m.createContext(null),Ed=()=>{const e=m.useContext(_d);if(!e)throw new Error("useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot");return e},Td=()=>m.useContext(_d),iT=()=>{const e=m.useContext(Px);if(!e)throw new Error("useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot");return e},oT=()=>{const e=Ed();return m.useSyncExternalStore(e.subscribe,e.getTriggers,e.getTriggers)},aT=new Map,Ax=()=>()=>{},Zh=()=>aT,lT=()=>{const e=Td();return m.useSyncExternalStore(e?e.subscribe:Ax,e?e.getTriggers:Zh,e?e.getTriggers:Zh)},ep=()=>null,uT=()=>{const e=Td();return m.useSyncExternalStore(e?e.subscribeAria:Ax,e?e.getActiveAria:ep,e?e.getActiveAria:ep)};function tp(){const e=m.useRef(new Set);return{notify:m.useCallback(()=>{for(const t of e.current)t()},[]),subscribe:m.useCallback(t=>(e.current.add(t),()=>{e.current.delete(t)}),[])}}const np=({children:e})=>{const t=m.useRef(new Map),n=m.useRef(new Set),{notify:r,subscribe:s}=tp(),i=m.useCallback(k=>{const{char:y}=k;if(t.current.has(y))return()=>{};const v=new Map(t.current);v.set(y,k),t.current=v,r();for(const w of n.current)w.added(k);return()=>{const w=new Map(t.current);w.delete(y),t.current=w,r();for(const E of n.current)E.removed(y)}},[r]),o=m.useCallback(()=>t.current,[]),a=m.useCallback(k=>(n.current.add(k),()=>{n.current.delete(k)}),[]),l=m.useRef(null),u=m.useRef(null),{notify:f,subscribe:d}=tp(),h=m.useCallback((k,y)=>{if(y===null){if(u.current!==k)return;l.current=null,u.current=null,f();return}const v=l.current;u.current===k&&v!==null&&v.popoverId===y.popoverId&&v.highlightedItemId===y.highlightedItemId||(l.current=y,u.current=k,f())},[f]),p=m.useCallback(()=>l.current,[]),g=m.useMemo(()=>({register:i,getTriggers:o,subscribe:s,subscribeLifecycle:a,getActiveAria:p,subscribeAria:d}),[i,o,s,a,p,d]),x=m.useMemo(()=>({setActiveAria:h}),[h]);return c.jsx(_d.Provider,{value:g,children:c.jsx(Px.Provider,{value:x,children:e})})},jx=({children:e})=>$a()?c.jsx(np,{children:e}):c.jsx(sT,{children:c.jsx(np,{children:e})});jx.displayName="ComposerPrimitive.TriggerPopoverRoot";const rp=/\s/u;function cT(e,t,n){const r=e.slice(0,n);for(let s=r.length-1;s>=0;s--){const i=r[s];if(rp.test(i))return null;if(r.startsWith(t,s)){if(s>0&&!rp.test(r[s-1]))continue;return{query:r.slice(s+t.length),offset:s}}}return null}const dT=ce(({text:e,triggerChar:t})=>{const[n,r]=kt(e.length),s=ie(()=>cT(e,t,Math.min(n,e.length)),[n,e,t]);return{trigger:s,query:s?.query??"",setCursorPosition:r}});function fT(e){return"type"in e}const hT=ce(({navigableList:e,isSearchMode:t,activeCategoryId:n,query:r,popoverId:s,open:i,selectItem:o,selectCategory:a,goBack:l,close:u})=>{const[f,d]=kt(0);je(()=>{d(0)},[e]),je(()=>{d(0)},[t,n]);const h=nn(x=>{x<0||x>=e.length||x!==f&&d(x)}),p=nn(x=>{if(!i)return!1;switch(x.key){case"ArrowDown":return x.preventDefault(),d(k=>{const y=e.length;return y===0?0:k<y-1?k+1:0}),!0;case"ArrowUp":return x.preventDefault(),d(k=>{const y=e.length;return y===0?0:k>0?k-1:y-1}),!0;case"Enter":case"Tab":{if(x.shiftKey)return!1;x.preventDefault();const k=e[f];return k&&(fT(k)?o(k):a(k.id)),!0}case"Escape":return x.preventDefault(),u(),!0;case"Backspace":return n&&r===""?(x.preventDefault(),l(),!0):!1;default:return!1}}),g=e[f];return{highlightedIndex:f,highlightedItemId:i&&g?`${s}-option-${g.id}`:void 0,highlightIndex:h,handleKeyDown:p}});function sp(e,t){return e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}const pT=ce(({adapter:e,query:t,open:n})=>{const[r,s]=kt(null);je(()=>{n||s(null)},[n]);const i=ie(()=>!n||!e?[]:e.categories(),[n,e]),o=n?r:null,a=ie(()=>!o||!e?[]:e.categoryItems(o),[o,e]),l=ie(()=>{if(!n||!e||o||!t&&i.length>0)return null;if(e.search)return e.search(t);const h=[],p=t.toLowerCase();for(const g of i)for(const x of e.categoryItems(g.id))sp(x,p)&&h.push(x);return h},[n,e,t,o,i]),u=l!==null,f=ie(()=>{if(u)return[];if(!t)return i;const h=t.toLowerCase();return i.filter(p=>p.label.toLowerCase().includes(h))},[i,t,u]),d=ie(()=>{if(u)return l??[];if(!t)return a;const h=t.toLowerCase();return a.filter(p=>sp(p,h))},[a,t,u,l]);return{categories:f,items:d,isSearchMode:u,activeCategoryId:o,navigableList:ie(()=>u?l??[]:o?d:f,[u,l,o,d,f]),selectCategory:nn(h=>{s(h)}),goBack:nn(()=>{s(null)})}}),mT=ce(({behavior:e,trigger:t,aui:n,triggerChar:r,setCursorPosition:s,onSelected:i})=>{const o=tn(null),a=nn(l=>(o.current=l,()=>{o.current===l&&(o.current=null)}));return{selectItem:nn(l=>{if(!t||!e)return;if(o.current?.(l)){i();return}const u=n.composer().getState().text,f=u.slice(0,t.offset),d=u.slice(t.offset+r.length+t.query.length),h=()=>{const p=e.formatter.serialize(l);n.composer().setText(f+p+(d.startsWith(" ")?d:` ${d}`))};e.kind==="directive"?(h(),e.onInserted?.(l)):(e.removeOnExecute?n.composer().setText(f+(d.startsWith(" ")?d.slice(1):d)):h(),e.onExecute(l)),i()}),close:nn(()=>{i(),t&&s(t.offset)}),registerSelectItemOverride:a}}),gT=ce(({adapter:e,text:t,triggerChar:n,behavior:r,aui:s,popoverId:i})=>{const o=Ve(dT({text:t,triggerChar:n})),a=o.trigger!==null&&e!==void 0&&r!==void 0,l=Ve(pT({adapter:e,query:o.query,open:a})),u=nn(()=>{l.goBack()}),f=Ve(mT({behavior:r,trigger:o.trigger,aui:s,triggerChar:n,setCursorPosition:o.setCursorPosition,onSelected:u})),d=Ve(hT({navigableList:l.navigableList,isSearchMode:l.isSearchMode,activeCategoryId:l.activeCategoryId,query:o.query,popoverId:i,open:a,selectItem:f.selectItem,selectCategory:l.selectCategory,goBack:l.goBack,close:f.close}));return{open:a,query:o.query,activeCategoryId:l.activeCategoryId,categories:l.categories,items:l.items,highlightedIndex:d.highlightedIndex,isSearchMode:l.isSearchMode,popoverId:i,highlightedItemId:d.highlightedItemId,selectCategory:l.selectCategory,goBack:l.goBack,selectItem:f.selectItem,close:f.close,highlightIndex:d.highlightIndex,handleKeyDown:d.handleKeyDown,setCursorPosition:o.setCursorPosition,registerSelectItemOverride:f.registerSelectItemOverride}}),Id=m.createContext(null),gs=()=>{const e=m.useContext(Id);if(!e)throw new Error("useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover");return e},yT=()=>m.useContext(Id),Nx=m.createContext(null),Mx=()=>{const e=m.useContext(Nx);if(!e)throw new Error("TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover");return e},Dx=m.forwardRef(({char:e,adapter:t,"aria-label":n,children:r,...s},i)=>{const o=se(),a=V(I=>I.composer.text),l=m.useId(),u=m.useRef(null),[f,d]=m.useState(null),h=m.useRef(0),p=m.useCallback(I=>(h.current+=1,u.current=I,d(I),()=>{h.current=Math.max(0,h.current-1),u.current===I&&(u.current=null,d(null))}),[e]),g=m.useMemo(()=>({register:p}),[p]),x=uv(gT({adapter:t,text:a,triggerChar:e,behavior:f??void 0,aui:o,popoverId:l})),k=m.useRef(x);k.current=x;const y=Ed();m.useEffect(()=>y.register({char:e,...f?{behavior:f}:{},resource:k.current}),[y,e,f]);const v=$a();m.useEffect(()=>{if(v)return v.register(k.current)},[v]);const w=f!==null&&x.open,E=iT();return m.useEffect(()=>{if(w)return()=>{E.setActiveAria(e,null)}},[E,e,w]),m.useEffect(()=>{w&&E.setActiveAria(e,{popoverId:l,highlightedItemId:x.highlightedItemId})},[E,e,l,w,x.highlightedItemId]),c.jsx(Nx.Provider,{value:g,children:c.jsx(Id.Provider,{value:x,children:w?c.jsx(be.div,{role:"listbox",id:l,"aria-label":n??"Suggestions","aria-activedescendant":x.highlightedItemId,"data-state":"open",...s,ref:i,children:r}):r})})});Dx.displayName="ComposerPrimitive.TriggerPopover";const Lx=()=>{const{disabled:e,send:t}=tE(),n=m.useCallback(()=>t(),[t]);return e?null:n},vT=Wt("ComposerPrimitive.Send",Lx),Ox=m.forwardRef(({onSubmit:e,...t},n)=>{const r=Lx(),s=i=>{i.preventDefault(),r&&r()};return c.jsx(be.form,{...t,ref:n,onSubmit:Ee(e,s)})});Ox.displayName="ComposerPrimitive.Root";const zx=e=>{const t=mr(e),n=wr(r=>r.onScrollToBottom);m.useEffect(()=>n(t),[n,t])},xT=()=>!1,wT=()=>{},bT=e=>m.useSyncExternalStore(m.useCallback(t=>{if(typeof window>"u"||e===null)return wT;const n=window.matchMedia(e);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)},[e]),m.useCallback(()=>typeof window>"u"||e===null?!1:window.matchMedia(e).matches,[e]),xT);function Xu(){return Xu=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Xu.apply(null,arguments)}function ST(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var kT=m.useLayoutEffect,CT=function(t){var n=ut.useRef(t);return kT(function(){n.current=t}),n},ip=function(t,n){if(typeof t=="function"){t(n);return}t.current=n},_T=function(t,n){var r=ut.useRef();return ut.useCallback(function(s){t.current=s,r.current&&ip(r.current,null),r.current=n,n&&ip(n,s)},[n])},op={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},ET=function(t){Object.keys(op).forEach(function(n){t.style.setProperty(n,op[n],"important")})},ap=ET,et=null,lp=function(t,n){var r=t.scrollHeight;return n.sizingStyle.boxSizing==="border-box"?r+n.borderSize:r-n.paddingSize};function TT(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),et||(et=document.createElement("textarea"),et.setAttribute("tabindex","-1"),et.setAttribute("aria-hidden","true"),ap(et)),et.parentNode===null&&document.body.appendChild(et);var s=e.paddingSize,i=e.borderSize,o=e.sizingStyle,a=o.boxSizing;Object.keys(o).forEach(function(h){var p=h;et.style[p]=o[p]}),ap(et),et.value=t;var l=lp(et,e);et.value=t,l=lp(et,e),et.value="x";var u=et.scrollHeight-s,f=u*n;a==="border-box"&&(f=f+s+i),l=Math.max(f,l);var d=u*r;return a==="border-box"&&(d=d+s+i),l=Math.min(d,l),[l,u]}var up=function(){},IT=function(t,n){return t.reduce(function(r,s){return r[s]=n[s],r},{})},RT=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],PT=!!document.documentElement.currentStyle,AT=function(t){var n=window.getComputedStyle(t);if(n===null)return null;var r=IT(RT,n),s=r.boxSizing;if(s==="")return null;PT&&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}},jT=AT;function Rd(e,t,n){var r=CT(n);m.useLayoutEffect(function(){var s=function(o){return r.current(o)};if(e)return e.addEventListener(t,s),function(){return e.removeEventListener(t,s)}},[])}var NT=function(t,n){Rd(document.body,"reset",function(r){t.current.form===r.target&&n(r)})},MT=function(t){Rd(window,"resize",t)},DT=function(t){Rd(document.fonts,"loadingdone",t)},LT=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],OT=function(t,n){var r=t.cacheMeasurements,s=t.maxRows,i=t.minRows,o=t.onChange,a=o===void 0?up:o,l=t.onHeightChange,u=l===void 0?up:l,f=ST(t,LT),d=f.value!==void 0,h=m.useRef(null),p=_T(h,n),g=m.useRef(0),x=m.useRef(),k=function(){var w=h.current,E=r&&x.current?x.current:jT(w);if(E){x.current=E;var I=TT(E,w.value||w.placeholder||"x",i,s),S=I[0],R=I[1];g.current!==S&&(g.current=S,w.style.setProperty("height",S+"px","important"),u(S,{rowHeight:R}))}},y=function(w){d||k(),a(w)};return m.useLayoutEffect(k),NT(h,function(){if(!d){var v=h.current.value;requestAnimationFrame(function(){var w=h.current;w&&v!==w.value&&k()})}}),MT(k),DT(k),m.createElement("textarea",Xu({},f,{onChange:y,ref:p}))},zT=m.forwardRef(OT);const FT="(pointer: coarse) and (not (any-pointer: fine))",Fx=m.forwardRef(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:s,onKeyDown:i,onPaste:o,onSelect:a,submitOnEnter:l,submitMode:u,cancelOnEscape:f=!0,unstable_focusOnRunStart:d=!0,unstable_focusOnScrollToBottom:h=!0,unstable_focusOnThreadSwitched:p=!0,unstable_insertNewlineOnTouchEnter:g=!1,addAttachmentOnPaste:x=!0,...k},y)=>{const v=se(),w=$a(),E=uT(),I=u??(l===!1?"none":"enter"),S=bT(g?FT:null),R=g&&S&&I==="enter"?"none":I,N=V(M=>M.composer.isEditing?M.composer.text:""),D=V(M=>M.thread.isDisabled||M.composer.dictation?.inputDisabled)||r,_=m.useRef(null),z=Sr(y,_),j=m.useRef(!1);wx(M=>{if(!_.current?.contains(M.target))return;if(w){for(const J of w.getPlugins())if(J.handleKeyDown(M))return}if(!f)return;const b=v.composer();b.getState().canCancel&&(b.cancel(),M.preventDefault())});const K=M=>{if(!D&&!M.nativeEvent.isComposing){if(w){for(const b of w.getPlugins())if(b.handleKeyDown(M))return}if(M.key==="Enter"){const b=v.thread().getState(),J=b.capabilities.queue;if(M.shiftKey&&(M.ctrlKey||M.metaKey)&&J&&I!=="none"&&v.composer().getState().canSend){M.preventDefault(),v.composer().send({steer:!0});return}if(M.shiftKey||b.isRunning&&!J)return;let Y=!1;R==="ctrlEnter"?Y=M.ctrlKey||M.metaKey:R==="enter"&&(Y=!0),Y&&(M.preventDefault(),_.current?.closest("form")?.requestSubmit())}}},P=async M=>{if(!x)return;const b=v.thread().getState().capabilities,J=Array.from(M.clipboardData?.files||[]);if(b.attachments&&J.length>0)try{M.preventDefault(),await Promise.all(J.map(Y=>v.composer().addAttachment(Y)))}catch(Y){console.error("Error adding attachment:",Y)}},B=e&&!D,ee=m.useCallback(()=>{const M=_.current;!M||!B||(M.focus({preventScroll:!0}),M.setSelectionRange(M.value.length,M.value.length))},[B]);m.useEffect(()=>ee(),[ee]),zx(()=>{v.composer().getState().type==="thread"&&h&&ee()}),m.useEffect(()=>{if(!(v.composer().getState().type!=="thread"||!d))return v.on("thread.runStart",ee)},[d,ee,v]),m.useEffect(()=>{if(!(v.composer().getState().type!=="thread"||!p))return v.on("threadListItem.switchedTo",ee)},[p,ee,v]);const ae=E?{"aria-controls":E.popoverId,"aria-expanded":!0,"aria-haspopup":"listbox","aria-activedescendant":E.highlightedItemId}:{},F={name:"input",value:N,...k,...ae,ref:z,disabled:D,onChange:Ee(s,M=>{if(!v.composer().getState().isEditing)return;const b=M.nativeEvent.isComposing===!0;j.current&&!b&&(j.current=!1);const J=b||j.current;if(gh(()=>{v.composer().setText(M.target.value)}),J)return;const Y=M.target.selectionStart??M.target.value.length;if(w)for(const C of w.getPlugins())C.setCursorPosition(Y)}),onKeyDown:Ee(i,K),onCompositionStart:Ee(k.onCompositionStart,()=>{j.current=!0}),onCompositionEnd:Ee(k.onCompositionEnd,M=>{if(j.current=!1,!v.composer().getState().isEditing)return;const b=M.target;gh(()=>{v.composer().setText(b.value)});const J=b.selectionStart??b.value.length;if(w)for(const Y of w.getPlugins())Y.setCursorPosition(J)}),onSelect:Ee(a,M=>{if(j.current)return;const b=M.target,J=b.selectionStart??b.value.length;if(w)for(const Y of w.getPlugins())Y.setCursorPosition(J)}),onPaste:Ee(o,P)};if(n&&m.isValidElement(n)){const M=k.children!==void 0?k.children:n.props.children;return c.jsx(aa,{...F,children:m.cloneElement(n,void 0,M)})}return c.jsx(t?aa:zT,{...F})});Fx.displayName="ComposerPrimitive.Input";const BT=()=>{const{disabled:e,cancel:t}=nE();return e?null:t},$T=Wt("ComposerPrimitive.Cancel",BT),UT=({multiple:e=!0}={})=>{const{disabled:t,addAttachment:n}=sE(),r=se(),s=m.useCallback(()=>{const i=document.createElement("input");i.type="file",i.multiple=e,i.hidden=!0;const o=r.composer().getState().attachmentAccept;o!=="*"&&(i.accept=o),document.body.appendChild(i),i.onchange=a=>{const l=a.target.files;if(l){for(const u of l)n(u);document.body.removeChild(i)}},i.oncancel=()=>{(!i.files||i.files.length===0)&&document.body.removeChild(i)},i.click()},[r,e,n]);return t?null:s},VT=Wt("ComposerPrimitive.AddAttachment",UT,["multiple"]),Bx=m.forwardRef(({disabled:e,asChild:t=!1,render:n,children:r,...s},i)=>{const[o,a]=m.useState(!1),l=se(),u=m.useCallback(g=>{e||(g.preventDefault(),a(!0))},[e]),f=m.useCallback(g=>{e||(g.preventDefault(),o||a(!0))},[e,o]),d=m.useCallback(g=>{if(e)return;g.preventDefault();const x=g.relatedTarget;x&&g.currentTarget.contains(x)||a(!1)},[e]),h=m.useCallback(async g=>{if(e)return;g.preventDefault(),a(!1);const x=Array.from(g.dataTransfer.files);await Promise.all(x.map(async k=>{try{await l.composer().addAttachment(k)}catch(y){console.error("Failed to add attachment:",y)}}))},[e,l]),p={...o?{"data-dragging":"true"}:null,...s,onDragEnterCapture:Ee(s.onDragEnterCapture,u),onDragOverCapture:Ee(s.onDragOverCapture,f),onDragLeaveCapture:Ee(s.onDragLeaveCapture,d),onDropCapture:Ee(s.onDropCapture,h),ref:i};if(n&&m.isValidElement(n)){const g=r!==void 0?r:n.props.children;return c.jsx(aa,{...p,children:m.cloneElement(n,void 0,g)})}return c.jsx(t?aa:"div",{...p,children:r})});Bx.displayName="ComposerPrimitive.AttachmentDropzone";const HT=()=>{const{disabled:e,startDictation:t}=rE();return e?null:t},WT=Wt("ComposerPrimitive.Dictate",HT),qT=()=>{const e=se(),t=V(r=>r.composer.dictation!=null),n=m.useCallback(()=>{e.composer().stopDictation()},[e]);return t?n:null},KT=Wt("ComposerPrimitive.StopDictation",qT),$x=m.forwardRef(({children:e,...t},n)=>{const r=V(s=>s.composer.dictation?.transcript);return r?c.jsx(be.span,{...t,ref:n,children:e??r}):null});$x.displayName="ComposerPrimitive.DictationTranscript";const Ux=m.forwardRef((e,t)=>V(n=>n.composer.quote)?c.jsx(be.div,{...e,ref:t}):null);Ux.displayName="ComposerPrimitive.Quote";const Vx=m.forwardRef(({children:e,...t},n)=>{const r=V(s=>s.composer.quote?.text);return r?c.jsx(be.span,{...t,ref:n,children:e??r}):null});Vx.displayName="ComposerPrimitive.QuoteText";const Hx=m.forwardRef(({onClick:e,...t},n)=>{const r=se(),s=m.useCallback(()=>{r.composer().setQuote(void 0)},[r]);return c.jsx(be.button,{type:"button",...t,ref:n,onClick:Ee(e,s)})});Hx.displayName="ComposerPrimitive.QuoteDismiss";const Wx=m.forwardRef(({children:e,"aria-label":t,...n},r)=>{const{categories:s,activeCategoryId:i,isSearchMode:o,open:a}=gs();return!a||i||o?null:c.jsx(be.div,{role:"group","aria-label":t??"Categories",...n,ref:r,children:e(s)})});Wx.displayName="ComposerPrimitive.TriggerPopoverCategories";const qx=m.forwardRef(({categoryId:e,onClick:t,onMouseMove:n,...r},s)=>{const{selectCategory:i,highlightIndex:o,categories:a,highlightedIndex:l,activeCategoryId:u,isSearchMode:f,popoverId:d}=gs(),h=m.useCallback(()=>{i(e)},[i,e]),p=a.findIndex(k=>k.id===e),g=!u&&!f&&p===l,x=m.useCallback(()=>{o(p)},[o,p]);return c.jsx(be.button,{type:"button",role:"option",id:`${d}-option-${e}`,"aria-selected":g,"data-highlighted":g?"":void 0,...r,ref:s,onClick:Ee(t,h),onMouseMove:Ee(n,x)})});qx.displayName="ComposerPrimitive.TriggerPopoverCategoryItem";const Kx=m.forwardRef(({children:e,"aria-label":t,...n},r)=>{const{items:s,activeCategoryId:i,isSearchMode:o,open:a}=gs();return!a||!i&&!o?null:c.jsx(be.div,{role:"group","aria-label":t??"Items",...n,ref:r,children:e(s)})});Kx.displayName="ComposerPrimitive.TriggerPopoverItems";const Gx=m.forwardRef(({item:e,index:t,onClick:n,onMouseMove:r,...s},i)=>{const{selectItem:o,highlightIndex:a,items:l,highlightedIndex:u,activeCategoryId:f,isSearchMode:d,popoverId:h}=gs(),p=m.useCallback(()=>{o(e)},[o,e]),g=t??l.findIndex(y=>y.id===e.id),x=(d||f!==null)&&g===u,k=m.useCallback(()=>{a(g)},[a,g]);return c.jsx(be.button,{type:"button",role:"option",id:`${h}-option-${e.id}`,"aria-selected":x,"data-highlighted":x?"":void 0,...s,ref:i,onClick:Ee(n,p),onMouseMove:Ee(r,k)})});Gx.displayName="ComposerPrimitive.TriggerPopoverItem";const Qx=m.forwardRef(({onClick:e,...t},n)=>{const{activeCategoryId:r,isSearchMode:s,goBack:i,open:o}=gs();return!o||!r||s?null:c.jsx(be.button,{type:"button",...t,ref:n,onClick:Ee(e,i)})});Qx.displayName="ComposerPrimitive.TriggerPopoverBack";const Yx=({formatter:e,onExecute:t,removeOnExecute:n})=>{const{register:r}=Mx(),s=m.useRef(t);return s.current=t,m.useEffect(()=>r({kind:"action",formatter:e??px,onExecute:i=>s.current(i),...n!==void 0?{removeOnExecute:n}:{}}),[r,e,n]),null};Yx.displayName="ComposerPrimitive.TriggerPopoverAction";const Jx=({formatter:e,onInserted:t})=>{const{register:n}=Mx(),r=m.useRef(t);return r.current=t,m.useEffect(()=>n({kind:"directive",formatter:e??px,onInserted:s=>r.current?.(s)}),[n,e]),null};Jx.displayName="ComposerPrimitive.TriggerPopoverDirective";const GT=Object.assign(Dx,{Directive:Jx,Action:Yx});var so=ms({AddAttachment:()=>VT,AttachmentByIndex:()=>ax,AttachmentDropzone:()=>Bx,Attachments:()=>lx,Cancel:()=>$T,Dictate:()=>WT,DictationTranscript:()=>$x,If:()=>hx,Input:()=>Fx,Queue:()=>ux,Quote:()=>Ux,QuoteDismiss:()=>Hx,QuoteText:()=>Vx,Root:()=>Ox,Send:()=>vT,StopDictation:()=>KT,Unstable_TriggerPopover:()=>GT,Unstable_TriggerPopoverBack:()=>Qx,Unstable_TriggerPopoverCategories:()=>Wx,Unstable_TriggerPopoverCategoryItem:()=>qx,Unstable_TriggerPopoverItem:()=>Gx,Unstable_TriggerPopoverItems:()=>Kx,Unstable_TriggerPopoverRoot:()=>jx,unstable_useTriggerPopoverRootContext:()=>Ed,unstable_useTriggerPopoverRootContextOptional:()=>Td,unstable_useTriggerPopoverScopeContext:()=>gs,unstable_useTriggerPopoverScopeContextOptional:()=>yT,unstable_useTriggerPopoverTriggers:()=>oT,unstable_useTriggerPopoverTriggersOptional:()=>lT});const Xx=()=>V(e=>{if(e.part.type!=="text"&&e.part.type!=="reasoning")throw new Error("MessagePartText can only be used inside text or reasoning message parts.");return e.part}),QT=()=>V(e=>{if(e.part.type!=="image")throw new Error("MessagePartImage can only be used inside image message parts.");return e.part}),Zx=m.createContext(null),YT=e=>({useSmoothStatus:mv(()=>e)}),JT=({children:e})=>{const t=ew({optional:!0}),n=se(),[r]=m.useState(()=>YT(n.part().getState().status));return t?e:c.jsx(Zx.Provider,{value:r,children:e})},XT=e=>{const t=m.forwardRef((n,r)=>c.jsx(JT,{children:c.jsx(e,{...n,ref:r})}));return t.displayName=e.displayName,t};function ew(e){const t=m.useContext(Zx);if(!e?.optional&&!t)throw new Error("This component must be used within a SmoothContextProvider.");return t}const{useSmoothStatus:ZT,useSmoothStatusStore:eI}=mx(ew,"useSmoothStatus");var tI=class{constructor(e,t){T(this,"currentText");T(this,"setText");T(this,"animationFrameId",null);T(this,"lastUpdateTime",Date.now());T(this,"targetText","");T(this,"animate",()=>{const e=Date.now();let t=e-this.lastUpdateTime;const n=this.targetText.length-this.currentText.length,r=Math.min(5,250/n);let s=0;for(;t>=r&&s<n;)s++,t-=r;s!==n?this.animationFrameId=requestAnimationFrame(this.animate):this.animationFrameId=null,s!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+s),this.lastUpdateTime=e-t,this.setText(this.currentText))});this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}};const Pl=Object.freeze({type:"running"}),tw=(e,t=!1)=>{const{text:n}=e,[r,s]=m.useState(e.status.type==="running"?"":n),i=se(),o=V(()=>i.part()),[a,l]=m.useState(o);(o!==a||!n.startsWith(r))&&(l(o),s(e.status.type==="running"?"":n));const u=eI({optional:!0}),f=mr(p=>{if(s(p),u){const g=r!==p||e.status.type==="running"?Pl:e.status;ia(u).setState(g,!0)}});m.useEffect(()=>{if(u){const p=t&&(r!==n||e.status.type==="running")?Pl:e.status;ia(u).setState(p,!0)}},[u,t,n,r,e.status]);const[d]=m.useState(new tI(r,f)),h=m.useRef(o);return m.useEffect(()=>{if(!t){d.stop();return}const p=h.current!==o;if(h.current=o,p||!n.startsWith(d.targetText)){e.status.type==="running"?(d.currentText="",d.targetText=n,d.start()):(d.currentText=n,d.targetText=n,d.stop());return}d.targetText=n,d.start()},[d,t,n,e.status.type,o]),m.useEffect(()=>()=>{d.stop()},[d]),m.useMemo(()=>t?{type:"text",text:r,status:n===r?e.status:Pl}:e,[t,r,e,n])},Pd=m.forwardRef(({smooth:e=!0,component:t="span",...n},r)=>{const{text:s,status:i}=tw(Xx(),e);return c.jsx(t,{"data-status":i.type,...n,ref:r,children:s})});Pd.displayName="MessagePartPrimitive.Text";const Ad=m.forwardRef((e,t)=>{const{image:n}=QT();return c.jsx(be.img,{src:n,...e,ref:t})});Ad.displayName="MessagePartPrimitive.Image";const kr=e=>{const t=m.useRef(void 0);return m.useCallback(n=>{t.current&&(t.current(),t.current=void 0),n&&(t.current=e(n))},[e])},cp=(e,t)=>{const n=e.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(t).fontSize)||16):s==="rem"?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):Number.POSITIVE_INFINITY},nI=e=>e.dataset.messageId,rI=()=>{const e=document.createElement("div");return e.dataset.auiTopAnchorReserve="",e.style.height="0px",e.style.flexShrink="0",e.style.pointerEvents="none",e.setAttribute("aria-hidden","true"),e},dp=(e,t)=>{const n=`${t}px`;return e.style.height!==n?(e.style.height=n,!0):!1},sI=e=>{const t=window.devicePixelRatio||1;return Math.round(e*t)/t},nw=()=>{const e=se(),t=V(()=>e.message());return kr(m.useCallback(n=>{const r=()=>{t.setIsHovering(!0)},s=()=>{t.setIsHovering(!1)};return n.addEventListener("mouseenter",r),n.addEventListener("mouseleave",s),n.matches(":hover")&&queueMicrotask(()=>t.setIsHovering(!0)),()=>{n.removeEventListener("mouseenter",r),n.removeEventListener("mouseleave",s),t.setIsHovering(!1)}},[t]))},iI=()=>{const e=wr(t=>t.topAnchorTurn?.anchorId);return V(t=>t.message.role==="user"&&t.message.index>0&&t.message.index===t.thread.messages.length-2&&t.thread.messages.at(-1)?.role==="assistant"&&(t.message.id===e||t.thread.isRunning))},oI=()=>{const e=wr(t=>t.topAnchorTurn?.targetId);return V(t=>t.message.isLast&&t.message.role==="assistant"&&t.message.index>=1&&t.thread.messages.at(t.message.index-1)?.role==="user"&&(t.message.id===e||t.thread.isRunning))},aI=(e,t)=>kr(m.useCallback(n=>{if(e)return t.getState().registerAnchorElement(n)},[e,t])),lI=({active:e,threadViewportStore:t})=>kr(m.useCallback(n=>{if(!e)return;const r=t.getState(),s=r.topAnchorMessageClamp;return r.registerAnchorTargetElement(n,{tallerThan:cp(s.tallerThan,n),visibleHeight:cp(s.visibleHeight,n)})},[e,t])),uI=({forwardedRef:e,...t})=>{const n=Sr(e,nw()),r=V(s=>s.message.id);return c.jsx(be.div,{...t,ref:n,"data-message-id":r})},cI=({forwardedRef:e,threadViewportStore:t,...n})=>{const r=nw(),s=iI(),i=oI(),o=Sr(e,r,aI(s,t),lI({active:i,threadViewportStore:t})),a=V(l=>l.message.id);return c.jsx(be.div,{...n,ref:o,"data-message-id":a,"data-aui-top-anchor-user":s?"":void 0,"data-aui-top-anchor-target":i?"":void 0})},rw=m.forwardRef((e,t)=>{const n=br();return n.getState().turnAnchor==="top"?c.jsx(cI,{...e,forwardedRef:t,threadViewportStore:n}):c.jsx(uI,{...e,forwardedRef:t})});rw.displayName="MessagePrimitive.Root";const Al={...Ye,Text:()=>c.jsxs("p",{style:{whiteSpace:"pre-line"},children:[c.jsx(Pd,{}),c.jsx(kd,{children:c.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Image:()=>c.jsx(Ad,{})},Zu=e=>{if("children"in e)return c.jsx(Ju,{children:e.children});const{components:t,...n}=e;return c.jsx(Ju,{components:t?{Text:t.Text??Al.Text,Image:t.Image??Al.Image,Reasoning:t.Reasoning??Ye.Reasoning,Source:t.Source??Ye.Source,File:t.File??Ye.File,Unstable_Audio:t.Unstable_Audio??Ye.Unstable_Audio,..."ChainOfThought"in t?{ChainOfThought:t.ChainOfThought}:{tools:t.tools,data:t.data,ToolGroup:t.ToolGroup??Ye.ToolGroup,ReasoningGroup:t.ReasoningGroup??Ye.ReasoningGroup},Empty:t.Empty,Quote:t.Quote,generativeUI:t.generativeUI}:Al,...n})};Zu.displayName="MessagePrimitive.Parts";const sw=({children:e})=>hE()!==void 0?e:null;sw.displayName="MessagePrimitive.Error";const dI=e=>{const t=new Map;for(let r=0;r<e.length;r++){const s=e[r]?.parentId??`__ungrouped_${r}`,i=t.get(s)??[];i.push(r),t.set(s,i)}const n=[];for(const[r,s]of t){const i=r.startsWith("__ungrouped_")?void 0:r;n.push({groupKey:i,indices:s})}return n},fI=e=>{const t=V(n=>n.message.parts);return m.useMemo(()=>t.length===0?[]:e(t),[t,e])},hI=({Fallback:e,...t})=>{const n=V(r=>{const s=r.tools.tools[t.toolName]??e;return Array.isArray(s)?s[0]??e:s});return n?c.jsx(n,{...t}):null},pI=({Fallback:e,...t})=>{const n=V(r=>{const s=r.dataRenderers.renderers[t.name]??e;return Array.isArray(s)?s[0]??e:s});return n?c.jsx(n,{...t}):null},En={Text:()=>c.jsxs("p",{style:{whiteSpace:"pre-line"},children:[c.jsx(Pd,{}),c.jsx(kd,{children:c.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>c.jsx(Ad,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},mI=({components:{Text:e=En.Text,Reasoning:t=En.Reasoning,Image:n=En.Image,Source:r=En.Source,File:s=En.File,Unstable_Audio:i=En.Unstable_Audio,tools:o={},data:a}={}})=>{const l=se(),u=V(d=>d.part),f=u.type;if(f==="tool-call"){const d=l.part().addToolResult,h=l.part().resumeToolCall,p=l.part().respondToToolApproval;if("Override"in o)return c.jsx(o.Override,{...u,addResult:d,resume:h,respondToApproval:p});const g=o.by_name?.[u.toolName]??o.Fallback;return c.jsx(hI,{...u,Fallback:g,addResult:d,resume:h,respondToApproval:p})}if(u.status?.type==="requires-action")throw new Error("Encountered unexpected requires-action status");switch(f){case"text":return c.jsx(e,{...u});case"reasoning":return c.jsx(t,{...u});case"source":return c.jsx(r,{...u});case"image":return c.jsx(n,{...u});case"file":return c.jsx(s,{...u});case"audio":return c.jsx(i,{...u});case"data":{const d=a?.by_name?.[u.name]??a?.Fallback;return c.jsx(pI,{...u,Fallback:d})}default:return console.warn(`Unknown message part type: ${f}`),null}},gI=({partIndex:e,components:t})=>c.jsx(yd,{index:e,children:c.jsx(mI,{components:t})}),yI=m.memo(gI,(e,t)=>e.partIndex===t.partIndex&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.Group===t.components?.Group),vI=({status:e,component:t})=>c.jsx(vd,{text:"",isRunning:e.type==="running",children:c.jsx(t,{type:"text",text:"",status:e})}),xI=Object.freeze({type:"complete"}),wI=({components:e})=>{const t=V(n=>n.message.status??xI);return e?.Empty?c.jsx(e.Empty,{status:t}):c.jsx(vI,{status:t,component:e?.Text??En.Text})},bI=m.memo(wI,(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),jd=({groupingFunction:e,components:t})=>{const n=V(s=>s.message.parts.length),r=fI(e);return c.jsx(c.Fragment,{children:m.useMemo(()=>n===0?c.jsx(bI,{components:t}):r.map((s,i)=>c.jsx(t?.Group??En.Group,{groupKey:s.groupKey,indices:s.indices,children:s.indices.map(o=>c.jsx(yI,{partIndex:o,components:t},o))},`group-${i}-${s.groupKey??"ungrouped"}`)),[r,t,n])})};jd.displayName="MessagePrimitive.Unstable_PartsGrouped";const iw=({components:e,...t})=>c.jsx(jd,{...t,components:e,groupingFunction:dI});iw.displayName="MessagePrimitive.Unstable_PartsGroupedByParentId";var la=ms({AttachmentByIndex:()=>sx,Attachments:()=>ix,Content:()=>Zu,Error:()=>sw,GenerativeUI:()=>qv,GroupedParts:()=>tx,If:()=>Ix,PartByIndex:()=>Ys,Parts:()=>Zu,Quote:()=>nx,Root:()=>rw,Unstable_PartsGrouped:()=>jd,Unstable_PartsGroupedByParentId:()=>iw});const SI=e=>{const t=mr(e);return kr(m.useCallback(n=>{const r=new ResizeObserver(()=>{t()}),s=new MutationObserver(i=>{i.some(o=>o.type!=="attributes"||o.attributeName!=="style")&&t()});return r.observe(n),s.observe(n,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{r.disconnect(),s.disconnect()}},[t]))},kI=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{const s=m.useRef(null),i=V(E=>E.thread.messages.length>0),o=m.useRef(!1),a=m.useRef(null),l=br();e===void 0&&(e=l.getState().turnAnchor!=="top");const u=m.useRef(0),f=m.useRef(0),d=m.useRef(0),h=m.useRef(0),p=m.useRef(null),g=m.useCallback(E=>{const I=s.current;I&&(p.current=E,I.scrollTo({top:I.scrollHeight,behavior:E}))},[]),x=m.useCallback(E=>{p.current=E,a.current!==null&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{a.current=null,g(E)})},[g]);m.useLayoutEffect(()=>()=>{a.current!==null&&cancelAnimationFrame(a.current)},[]);const k=m.useCallback(()=>{const E=l.getState();return E.turnAnchor==="top"&&E.element.viewport===s.current&&E.element.anchor!==null},[l]),y=()=>{const E=s.current;if(!E)return;const I=l.getState().isAtBottom,S=Math.abs(E.scrollHeight-E.scrollTop-E.clientHeight)<=1||E.scrollHeight<=E.clientHeight;!S&&u.current<E.scrollTop||(S?E.scrollHeight>E.clientHeight+1&&(p.current=null):u.current>E.scrollTop&&f.current===E.scrollHeight&&(p.current=null),(S||p.current===null)&&S!==I&&ia(l).setState({isAtBottom:S})),u.current=E.scrollTop,f.current=E.scrollHeight},v=SI(()=>{const E=s.current;if(!E)return;const{scrollHeight:I,clientHeight:S}=E;if(I===d.current&&S===h.current)return;d.current=I,h.current=S;const R=p.current;R&&k()?p.current=null:R?g(R):e&&l.getState().isAtBottom&&g("instant"),y()}),w=kr(E=>(E.addEventListener("scroll",y),()=>{E.removeEventListener("scroll",y)}));return m.useLayoutEffect(()=>{if(n){if(!i){o.current=!1;return}o.current||(o.current=!0,p.current===null&&x("instant"))}},[i,x,n]),zx(({behavior:E})=>{g(E)}),ta("thread.runStart",()=>{t&&l.getState().turnAnchor!=="top"&&x("auto")}),ta("threadListItem.switchedTo",()=>{r&&x("instant")}),Sr(v,w,s)},ow=m.forwardRef((e,t)=>c.jsx(be.div,{...e,ref:t}));ow.displayName="ThreadPrimitive.Root";const aw=({children:e})=>V(t=>t.thread.isEmpty)?e:null;aw.displayName="ThreadPrimitive.Empty";const CI=e=>V(t=>!(e.empty===!0&&!t.thread.isEmpty||e.empty===!1&&t.thread.isEmpty||e.running===!0&&!t.thread.isRunning||e.running===!1&&t.thread.isRunning||e.disabled===!0&&!t.thread.isDisabled||e.disabled===!1&&t.thread.isDisabled)),lw=({children:e,...t})=>CI(t)?e:null;lw.displayName="ThreadPrimitive.If";const uw=(e,t)=>kr(m.useCallback(n=>{if(!e)return;const r=e(),s=()=>{const o=t?t(n):n.offsetHeight;r.setHeight(o)},i=new ResizeObserver(s);return i.observe(n),s(),()=>{i.disconnect(),r.unregister()}},[e,t])),fp=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},_I=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:fp(e)-fp(t)},cw=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{const s=_I(t,e),i=t.offsetHeight;return s+Math.max(0,i-(i<=n?i:r))},EI=({scrollHeight:e,...t})=>{const{viewport:n}=t,r=cw(t)+n.clientHeight;return Math.max(0,r-e)},TI=({viewport:e,reserve:t,...n})=>EI({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),II=e=>{const t=new ResizeObserver(e),n=new MutationObserver(e);let r=null,s=null,i=null;const o=()=>{t.disconnect(),n.disconnect(),r=null,s=null,i=null};return{target:(a,l,u)=>{r===a&&s===l&&i===u||(o(),t.observe(a),t.observe(l),t.observe(u),n.observe(u,{childList:!0,subtree:!0,characterData:!0}),r=a,s=l,i=u)},disconnect:o}},RI=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},PI=e=>{let t=null,n;function r(){const a=e.getState(),{viewport:l,anchor:u,target:f}=a.element,d=a.targetConfig;if(a.turnAnchor!=="top"||!l||!u||!f||!d){i.disconnect(),t&&(dp(t,0),t.remove());return}if(t??(t=rI()),(t.parentElement!==f.parentElement||t.previousElementSibling!==f)&&f.after(t),i.target(l,u,f),dp(t,TI({viewport:l,anchor:u,reserve:t,...d}))){s.schedule();return}const h=nI(u);if(h!==void 0&&n===h)return;const p=sI(cw({viewport:l,anchor:u,...d}));Math.abs(l.scrollTop-p)>1&&l.scrollTo({top:p,behavior:"smooth"}),h!==void 0&&(n=h)}const s=RI(r),i=II(s.schedule);s.schedule();const o=e.subscribe(s.schedule);return()=>{s.cancel(),o(),i.disconnect(),t?.remove()}},AI=e=>{const t=br();m.useLayoutEffect(()=>{if(e)return PI(t)},[e,t])},dw=({isRunning:e,messages:t})=>{if(!e)return null;const n=t.at(-1),r=t.at(-2);return r?.role!=="user"||n?.role!=="assistant"?null:{anchorId:r.id,targetId:n.id}},jI=e=>dw(e)?.anchorId,NI=e=>dw(e)?.targetId,MI=()=>uw(wr(e=>e.registerViewport),m.useCallback(e=>e.clientHeight,[])),DI=()=>kr(wr(e=>e.registerViewportElement)),LI=e=>{const t=br(),n=V(o=>{if(e)return jI(o.thread)}),r=V(o=>{if(e)return NI(o.thread)}),s=m.useMemo(()=>!n||!r?null:{anchorId:n,targetId:r},[n,r]);m.useLayoutEffect(()=>{if(!s)return;const o=t.getState(),a=o.topAnchorTurn;a?.anchorId===s.anchorId&&a.targetId===s.targetId||o.setTopAnchorTurn(s)},[s,t]);const i=m.useCallback(()=>{t.getState().setTopAnchorTurn(null)},[t]);ta("thread.initialize",i),ta("threadListItem.switchedTo",i)},fw=m.forwardRef(({autoScroll:e,scrollToBottomOnRunStart:t,scrollToBottomOnInitialize:n,scrollToBottomOnThreadSwitch:r,children:s,...i},o)=>{const a=kI({autoScroll:e,scrollToBottomOnRunStart:t,scrollToBottomOnInitialize:n,scrollToBottomOnThreadSwitch:r}),l=MI(),u=DI(),f=br().getState().turnAnchor==="top";LI(f),AI(f);const d=Sr(o,a,l,u);return c.jsx(be.div,{...i,ref:d,children:s})});fw.displayName="ThreadPrimitive.ViewportScrollable";const hw=m.forwardRef(({turnAnchor:e,topAnchorMessageClamp:t,...n},r)=>c.jsx(Cd,{options:{turnAnchor:e,topAnchorMessageClamp:t},children:c.jsx(fw,{...n,ref:r})}));hw.displayName="ThreadPrimitive.Viewport";const pw=m.forwardRef((e,t)=>{const n=Sr(t,uw(wr(r=>r.registerContentInset),m.useCallback(r=>{const s=parseFloat(getComputedStyle(r).marginTop)||0;return r.offsetHeight+s},[])));return c.jsx(be.div,{...e,ref:n})});pw.displayName="ThreadPrimitive.ViewportFooter";const OI=({behavior:e}={})=>{const t=wr(s=>s.isAtBottom),n=br(),r=m.useCallback(()=>{n.getState().scrollToBottom({behavior:e})},[n,e]);return t?null:r},zI=Wt("ThreadPrimitive.ScrollToBottom",OI,["behavior"]),FI=({prompt:e,send:t,clearComposer:n,autoSend:r,method:s})=>{const{disabled:i,trigger:o}=fE({prompt:e,send:t??r??!1,clearComposer:n});return i?null:o},BI=Wt("ThreadPrimitive.Suggestion",FI,["prompt","send","clearComposer","autoSend","method"]);var dt=ms({Empty:()=>aw,If:()=>lw,MessageByIndex:()=>Uv,Messages:()=>w1,Root:()=>ow,ScrollToBottom:()=>zI,Suggestion:()=>BI,SuggestionByIndex:()=>dx,Suggestions:()=>Z1,Viewport:()=>hw,ViewportFooter:()=>pw,ViewportProvider:()=>Cd}),$I=ms({AssistantRuntimeImpl:()=>Dv,BaseAssistantRuntimeCore:()=>Lv,CompositeContextProvider:()=>dd,DefaultThreadComposerRuntimeCore:()=>Fv,MessageRepository:()=>wd,ThreadRuntimeImpl:()=>Mv,fromThreadMessageLike:()=>Si,generateId:()=>Vn,getAutoStatus:()=>ra,splitLocalRuntimeOptions:()=>pE,useComposerInputPluginRegistryOptional:()=>$a,useSmooth:()=>tw,useSmoothStatus:()=>ZT,withSmoothContextProvider:()=>XT});const Nd="claude-control.token";let ua=null,ca=!1;function UI(){try{return window.localStorage.getItem(Nd)}catch{return null}}const VI="claude-control";function Ua(){return ca||(ua=UI(),ca=!0),ua}function mw(e){ua=e,ca=!0;try{window.localStorage.setItem(Nd,e)}catch{}}function gw(){ua=null,ca=!0;try{window.localStorage.removeItem(Nd)}catch{}}function HI(){if(typeof window>"u"||!window.location)return;let e;try{e=new URLSearchParams(window.location.search)}catch{return}const t=e.get("token");if(!t)return;mw(t),e.delete("token");const n=e.toString(),r=window.location.pathname+(n?`?${n}`:"")+window.location.hash;try{window.history.replaceState(null,"",r)}catch{}}HI();const ec=new Set;function WI(e){return ec.add(e),()=>ec.delete(e)}function yw(){gw();for(const e of ec)e()}function qI(e){const t=Ua(),n={...e??{}};return t&&(n.Authorization=`Bearer ${t}`),n}async function Le(e,t){const n=await fetch(e,{...t,headers:qI(t?.headers)});return n.status===401&&yw(),n}function KI(e){const t=`/term/${encodeURIComponent(e)}/`,n=Ua();return n?`${t}?token=${encodeURIComponent(n)}`:t}function GI(){const e=window.location;return`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}/`}async function QI(e,t){const n=await Le("/api/pins",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:e,transcriptPath:t})}),r=await n.json().catch(()=>({}));if(!n.ok||!r.ok)throw new Error(r.error||`HTTP ${n.status}`);return r.pins??{}}async function YI(){const e=await Le("/api/transcripts");if(!e.ok)throw new Error(`HTTP ${e.status}`);return(await e.json()).transcripts??[]}async function vw(){try{const e=await Le("/api/version");return e.ok?await e.json():null}catch{return null}}async function JI(){try{const e=await Le("/api/update",{method:"POST"}),t=await e.json().catch(()=>({}));return e.ok&&!!t.ok}catch{return!0}}async function XI(){try{const e=await Le("/api/push/vapid");return e.ok?(await e.json()).publicKey??null:null}catch{return null}}async function ZI(e){try{return(await Le("/api/push/subscribe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)})).ok}catch{return!1}}async function eR(e){try{return(await Le("/api/push/unsubscribe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:e})})).ok}catch{return!1}}async function tR(e){const t=await Le("/api/icon",{method:"POST",body:e}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok)throw new Error(n.error||`HTTP ${t.status}`)}async function nR(){const e=await Le("/api/icon",{method:"DELETE"}),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok)throw new Error(t.error||`HTTP ${e.status}`)}async function rR(){const e=await Le("/api/models");if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}async function sR(e,t){const n=await Le("/api/optimize",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:e})}),r=await n.json().catch(()=>({}));if(!n.ok||typeof r.optimized!="string")throw new Error(r.error||`HTTP ${n.status}`);return{optimized:r.optimized,rationale:r.rationale??[],changes:r.changes??[],mode:r.mode==="rules"?"rules":"llm"}}async function iR(e,t="webm"){const n=await Le(`/api/transcribe?ext=${encodeURIComponent(t)}`,{method:"POST",body:e}),r=await n.json().catch(()=>({}));if(!n.ok||!r.ok)throw new Error(r.error||`HTTP ${n.status}`);return r.text??""}async function oR(){const e=await Le("/api/config");if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}async function aR(e){const t=await Le("/api/config",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));if(!t.ok)throw new Error("error"in n&&n.error||`HTTP ${t.status}`);return n}async function lR(e){const t=await Le("/api/session/new",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e??{})}),n=await t.json().catch(()=>({}));if(!t.ok||!("ok"in n)||!n.ok){const r="error"in n&&n.error||`HTTP ${t.status}`;throw new Error(r)}return n}async function uR(e,t){const n=await Le("/api/session/rename",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:e,name:t})}),r=await n.json().catch(()=>({}));if(!n.ok||!("ok"in r)||!r.ok){const s="error"in r&&r.error||`HTTP ${n.status}`;throw new Error(s)}}function cR(e){return`/api/uploads/${encodeURIComponent(e)}`}async function xw(){const e=await Le("/api/skills");if(!e.ok)throw new Error(`HTTP ${e.status}`);return(await e.json()).skills??[]}async function dR(e){const t=`/api/upload?name=${encodeURIComponent(e.name)}`,n=await Le(t,{method:"POST",body:e});let r=null;try{r=await n.json()}catch{}const s=r??{};if(!n.ok||!s.ok||!s.path)throw new Error(s.error||`HTTP ${n.status}`);return{ok:!0,path:s.path,name:s.name??e.name}}const fR=1008,hp=1e3,hR=3e4;class pR{constructor(){T(this,"ws",null);T(this,"reconnectTimer",null);T(this,"reconnectDelay",hp);T(this,"selectedId",null);T(this,"closed",!1);T(this,"msgHandlers",new Set);T(this,"stateHandlers",new Set)}connect(){if(this.ws&&(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING))return;this.emitState("connecting");const t=Ua(),n=t?[VI,t]:void 0,r=new WebSocket(GI(),n);this.ws=r,r.addEventListener("open",()=>{this.reconnectDelay=hp,this.emitState("connected"),this.selectedId&&this.send({type:"subscribe",id:this.selectedId})}),r.addEventListener("message",s=>{let i;try{i=JSON.parse(s.data)}catch{return}for(const o of this.msgHandlers)o(i)}),r.addEventListener("close",s=>{if(this.ws=null,this.emitState("disconnected"),s.code===fR){yw();return}this.closed||this.scheduleReconnect()}),r.addEventListener("error",()=>{})}scheduleReconnect(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,hR)}send(t){return this.ws&&this.ws.readyState===WebSocket.OPEN?(this.ws.send(JSON.stringify(t)),!0):!1}isOpen(){return this.ws?.readyState===WebSocket.OPEN}select(t){this.selectedId!==t&&(this.selectedId&&this.send({type:"unsubscribe",id:this.selectedId}),this.selectedId=t,t&&this.send({type:"subscribe",id:t}))}resubscribe(){const t=this.selectedId;t&&(this.send({type:"unsubscribe",id:t}),this.send({type:"subscribe",id:t}))}onMessage(t){return this.msgHandlers.add(t),()=>this.msgHandlers.delete(t)}onState(t){return this.stateHandlers.add(t),()=>this.stateHandlers.delete(t)}emitState(t){for(const n of this.stateHandlers)n(t)}close(){this.closed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws?.close(),this.ws=null}}const pp=2e3;function mR(e,t){if(!e||e.length===0)return mp(t);if(t.length===0)return e;const n=new Set;for(const s of e)n.add(s.uuid);const r=t.filter(s=>!n.has(s.uuid));return r.length===0?e:mp([...e,...r])}function mp(e){return e.length>pp?e.slice(e.length-pp):e}function gR(){const e=m.useRef(null);e.current||(e.current=new pR);const t=e.current,[n,r]=m.useState([]),[s,i]=m.useState(null),[o,a]=m.useState("connecting"),[l,u]=m.useState({snapshot:null,warning:null}),[f,d]=m.useState(null),[h,p]=m.useState(null),[g,x]=m.useState({}),[k,y]=m.useState({}),[v,w]=m.useState({}),[E,I]=m.useState({}),S=m.useRef(null);S.current=s;const R=m.useRef([]);R.current=n,m.useEffect(()=>{const O=t.onState(a),W=t.onMessage(Q=>{switch(Q.type){case"sessions":r(Q.sessions??[]);break;case"messages":x(X=>({...X,[Q.id]:mR(X[Q.id],Q.messages??[])})),y(X=>({...X,[Q.id]:Q.pending??null}));break;case"append":x(X=>({...X,[Q.id]:[...X[Q.id]??[],...Q.messages??[]]}));break;case"pending":y(X=>({...X,[Q.id]:Q.pending})),r(X=>X.map(pe=>pe.id===Q.id?{...pe,pending:!!Q.pending}:pe));break;case"resources":u({snapshot:Q.snapshot??null,warning:Q.warning??null});break;case"capture":Q.id===S.current&&d(Q.text??"");break;case"shell-output":(!Q.id||Q.id===S.current)&&p(Q.text??"");break;case"prompt":I(X=>({...X,[Q.id]:Q.prompt}));break;case"subagents":w(X=>({...X,[Q.id]:Object.fromEntries((Q.subagents??[]).map(pe=>[pe.agentId,pe]))}));break;case"subagent":w(X=>({...X,[Q.id]:{...X[Q.id]??{},[Q.subagent.agentId]:Q.subagent}}));break;case"ack":window.dispatchEvent(new CustomEvent("cockpit:ack",{detail:Q}));break}});return t.connect(),()=>{O(),W()}},[t]),m.useEffect(()=>()=>t.close(),[t]);const N=m.useCallback(O=>{O!==S.current&&(i(O),d(null),t.select(O))},[t]),D=m.useCallback(O=>{const W=S.current;return!W||!O.trim()?!1:t.send({type:"reply",id:W,text:O})},[t]),_=m.useCallback((O,W)=>{const Q=S.current;return Q?t.send({type:"answer",id:Q,toolUseId:O,selections:W}):!1},[t]),z=m.useCallback((O,W)=>{const Q=S.current;return Q?t.send({type:"capture",id:Q,lines:O,escapes:W}):!1},[t]),j=m.useCallback(()=>d(null),[]),K=m.useCallback(O=>{const W=S.current;return W?t.send({type:"pane-text",id:W,text:O}):!1},[t]),P=m.useCallback(O=>{const W=S.current;return W?t.send({type:"pane-key",id:W,key:O}):!1},[t]),B=m.useCallback(O=>{const W=S.current;return W?t.send({type:"shell-input",id:W,line:O}):!1},[t]),ee=m.useCallback(O=>{const W=S.current;return W?t.send({type:"shell-text",id:W,text:O}):!1},[t]),ae=m.useCallback(O=>{const W=S.current;return W?t.send({type:"shell-key",id:W,key:O}):!1},[t]),F=m.useCallback(O=>{const W=S.current;return W?t.send({type:"shell-capture",id:W,lines:O}):!1},[t]),M=m.useCallback(()=>p(null),[]),b=m.useCallback(()=>t.resubscribe(),[t]),J=m.useCallback(O=>{const W=S.current;return W?t.send({type:"promptkey",id:W,key:O}):!1},[t]),Y=m.useMemo(()=>s?g[s]??[]:[],[s,g]),C=m.useMemo(()=>s?k[s]??null:null,[s,k]),ge=m.useMemo(()=>s?E[s]??null:null,[s,E]),L=m.useMemo(()=>{const O=s?v[s]:null;return O?Object.values(O).sort((W,Q)=>(Q.createdAt??-1/0)-(W.createdAt??-1/0)):[]},[s,v]);return{sessions:n,selectedId:s,messages:Y,pending:C,prompt:ge,subagents:L,conn:o,resources:l,capture:f,shellOutput:h,select:N,resubscribe:b,sendReply:D,sendPromptKey:J,sendAnswer:_,requestCapture:z,clearCapture:j,sendPaneText:K,sendPaneKey:P,sendShellInput:B,sendShellText:ee,sendShellKey:ae,requestShellCapture:F,clearShellOutput:M}}const jl="cc:push:intent";function yR(){return typeof window>"u"||!("serviceWorker"in navigator)||!("PushManager"in window)||!("Notification"in window)?!1:window.isSecureContext===!0}function vR(){if(typeof navigator>"u")return!1;const e=navigator.userAgent||"",t=/iPad|iPhone|iPod/.test(e),n=navigator.platform==="MacIntel"&&typeof navigator.maxTouchPoints=="number"&&navigator.maxTouchPoints>1;return t||n}function gp(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),s=new ArrayBuffer(r.length),i=new Uint8Array(s);for(let o=0;o<r.length;o+=1)i[o]=r.charCodeAt(o);return s}function xR(){const e=yR(),t=vR(),[n,r]=m.useState(e?"off":"unsupported"),s=m.useCallback(async()=>{const a=await navigator.serviceWorker.register("/sw.js");if(await navigator.serviceWorker.ready,await Notification.requestPermission()!=="granted")return r("denied"),!1;const u=await XI();if(!u)return r("off"),!1;let f=await a.pushManager.getSubscription();if(f)try{const h=gp(u),p=f.options?.applicationServerKey;let g=!1;if(p instanceof ArrayBuffer){const x=new Uint8Array(p),k=new Uint8Array(h);if(x.length!==k.length)g=!0;else for(let y=0;y<x.length;y++)if(x[y]!==k[y]){g=!0;break}}g&&(await f.unsubscribe(),f=null)}catch{}return f||(f=await a.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:gp(u)})),await ZI(f.toJSON())},[]),i=m.useCallback(async()=>{if(e){r("working");try{await s()?(localStorage.setItem(jl,"1"),r("on")):r(l=>l==="denied"?"denied":"off")}catch{r("off")}}},[e,s]),o=m.useCallback(async()=>{r("working"),localStorage.removeItem(jl);try{const l=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();l&&(await eR(l.endpoint),await l.unsubscribe())}catch{}r("off")},[]);return m.useEffect(()=>{if(!e||localStorage.getItem(jl)!=="1")return;if(Notification.permission!=="granted"){r(Notification.permission==="denied"?"denied":"off");return}let a=!1;return(async()=>{try{const l=await s();a||r(l?"on":"off")}catch{a||r("off")}})(),()=>{a=!0}},[e,s]),{status:n,supported:e,iosHint:t,enable:i,disable:o}}const tc=70,wR=110,bR=.5,SR=".thread-viewport, .rail, .live-pane-body";function kR(e,t=()=>window.location.reload()){const[n,r]=m.useState(0),[s,i]=m.useState(!1),o=m.useRef(0),a=m.useRef(!1),l=m.useRef(0),u=m.useRef(null),f=d=>{o.current=d,r(d)};return m.useEffect(()=>{const d=e.current;if(!d)return;const h=x=>{if(x.touches.length!==1){a.current=!1;return}const y=x.target?.closest(SR)??null;y&&y.scrollTop<=0?(u.current=y,l.current=x.touches[0].clientY,a.current=!0):a.current=!1},p=x=>{if(!a.current)return;const k=x.touches[0].clientY-l.current,y=u.current;if(k<=0||y&&y.scrollTop>0){o.current!==0&&f(0),y&&y.scrollTop>0&&(a.current=!1);return}const v=Math.min(wR,k*bR);f(v),x.cancelable&&x.preventDefault()},g=()=>{a.current&&(a.current=!1,o.current>=tc?(f(tc),i(!0),setTimeout(t,150)):f(0))};return d.addEventListener("touchstart",h,{passive:!0}),d.addEventListener("touchmove",p,{passive:!1}),d.addEventListener("touchend",g,{passive:!0}),d.addEventListener("touchcancel",g,{passive:!0}),()=>{d.removeEventListener("touchstart",h),d.removeEventListener("touchmove",p),d.removeEventListener("touchend",g),d.removeEventListener("touchcancel",g)}},[e,t]),{pull:n,refreshing:s}}const CR=tc,da="__cockpitSummary";function _R(e){if(e&&typeof e=="object"&&da in e){const t=e[da];return typeof t=="string"?t:""}return""}function ww(e){if(!e||typeof e!="object")return e;const t={};for(const[n,r]of Object.entries(e))n!==da&&(t[n]=r);return t}function ER(e){if(e&&typeof e=="object"&&"text"in e){const t=e;return{text:String(t.text??""),isError:!!t.isError}}return null}function bw(e){const t=new Map;for(const r of e)for(const s of r.blocks??[])s.kind==="tool_result"&&t.set(s.forId,{text:s.text??"",isError:!!s.isError});const n=[];return e.forEach((r,s)=>{const i=RR(r.blocks??[],t,r.role==="user");if(i.length===0)return;const o=r.role==="user"?"user":"assistant";n.push({role:o,id:r.uuid||`m-${s}`,createdAt:r.ts?new Date(r.ts):void 0,content:i,metadata:{custom:{cockpitRole:r.role}}})}),TR(n)}function TR(e){const t=r=>r.role==="assistant"&&(r.metadata?.custom?.cockpitRole??"assistant")==="assistant",n=[];for(const r of e){const s=n[n.length-1];s&&t(s)&&t(r)?n[n.length-1]={...s,content:[...s.content,...r.content]}:n.push(r)}return n}function IR(e){const t=e.trimStart();if(!t.startsWith("<"))return null;const n=/<summary>([\s\S]*?)<\/summary>/.exec(t)?.[1]?.trim();return t.startsWith("<task-notification")?`⚙ background task ${n?`— ${n}`:"update"}`:t.startsWith("<system-reminder")?"⚙ system reminder":t.startsWith("<command-name")||t.startsWith("<command-message")?"⌘ slash command":t.startsWith("<local-command-stdout")?"⌘ command output":t.startsWith("<user-prompt-submit-hook")||t.startsWith("<session-")?"⚙ session hook":null}function RR(e,t,n=!1){const r=[];for(const s of e)switch(s.kind){case"text":{if(s.text&&s.text.length>0){const i=n?IR(s.text):null;r.push({type:"text",text:i??s.text})}break}case"thinking":{s.text&&s.text.trim().length>0&&r.push({type:"reasoning",text:s.text});break}case"tool_use":{const i=t.get(s.id),o=s.input&&typeof s.input=="object"?s.input:s.input!=null?{value:s.input}:{};r.push({type:"tool-call",toolCallId:s.id,toolName:s.name||"tool",args:{...o,[da]:s.inputSummary??""},argsText:s.inputSummary??"",result:i??void 0,isError:i?.isError});break}}return r}const PR="image/*,application/pdf,text/*,.md,.json,.csv,.log",nc=" cockpit-path:";function AR(e){return nc+e}const _o=new Map;function jR(e){return _o.get(e)??null}function NR(e){for(const t of e.content??[])if(t.type==="text"&&t.text.startsWith(nc))return t.text.slice(nc.length);return jR(e.id)}function MR(e){return`${e.name}-${e.size}-${e.lastModified}`}function DR(e){return{accept:PR,async add({file:t}){const n=MR(t),r=t.type.startsWith("image/"),s=t.type==="application/pdf",i={id:n,type:r?"image":s?"document":"file",name:t.name,contentType:t.type||"application/octet-stream",file:t};e(`Uploading ${t.name}…`);try{const o=await dR(t);return _o.set(n,o.path),e(`Attached ${o.name}`,"ok"),{...i,status:{type:"requires-action",reason:"composer-send"}}}catch(o){const a=o instanceof Error?o.message:String(o);return e(`Attach failed: ${a}`,"error"),{...i,status:{type:"incomplete",reason:"error"}}}},async send(t){const n=_o.get(t.id);if(!n)throw new Error(`attachment ${t.name} was not uploaded`);return{...t,status:{type:"complete"},content:[{type:"text",text:AR(n)}]}},async remove(t){_o.delete(t.id)}}}function LR(e){if(!e)return"";const t=e.replace(/\/$/,"").split("/");return t[t.length-1]||e}function OR(e){const t=new Map;for(const n of e){const r=n.sessionName??"?",s=n.windowIndex??0;t.has(r)||t.set(r,new Map);const i=t.get(r);i.has(s)||i.set(s,[]),i.get(s).push(n)}return[...t.entries()].sort(([n],[r])=>n.localeCompare(r,void 0,{numeric:!0})).map(([n,r])=>({sessionName:n,windows:[...r.entries()].sort(([s],[i])=>s-i).map(([s,i])=>({windowIndex:s,windowName:i[0]?.tmuxName||`window ${s}`,panes:[...i].sort((o,a)=>(o.paneIndex??0)-(a.paneIndex??0))}))}))}function zR({s:e,selected:t,onSelect:n}){const r=e.kind==="terminal",s=r?e.ccShell?`shell · ${e.cmd||"sh"}`:e.cmd||e.tmuxName||"shell":e.title||e.name||e.id;return c.jsxs("li",{role:"option","aria-selected":t,tabIndex:0,className:"session-item","data-active":e.active?"true":"false","data-selected":t?"true":"false","data-kind":e.kind??"claude",onClick:()=>n(e.id),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),n(e.id))},children:[c.jsxs("div",{className:"session-top",children:[c.jsx("span",{className:"active-dot","data-on":e.active?"true":"false","aria-hidden":"true"}),c.jsx("span",{className:"pane-glyph","aria-hidden":"true",children:r?">_":"✳"}),c.jsx("span",{className:"session-name",children:s}),e.pending?c.jsx("span",{className:"ask-badge","aria-label":"pending question",children:"ASK"}):null]}),c.jsxs("div",{className:"session-meta",children:[c.jsxs("span",{className:"meta-prov",children:["p",e.paneIndex??0]}),r?e.cwd?c.jsx("span",{className:"meta-cwd",children:LR(e.cwd)}):null:c.jsxs(c.Fragment,{children:[e.model?c.jsx("span",{className:"meta-model",children:e.model}):null,e.ctxPct!=null?c.jsxs("span",{className:"meta-ctx",children:["ctx:",Math.round(e.ctxPct),"%"]}):null]})]})]})}function FR({sessions:e,selectedId:t,onSelect:n}){const r=m.useMemo(()=>OR(e),[e]);return r.length===0?c.jsx("div",{className:"session-list",role:"listbox","aria-label":"Sessions",children:c.jsx("div",{className:"session-empty",children:"no tmux panes"})}):c.jsx("div",{className:"session-list",role:"listbox","aria-label":"Sessions",children:r.map(s=>c.jsxs("section",{className:"session-group",children:[c.jsx("div",{className:"session-group-head",children:s.sessionName}),s.windows.map(i=>c.jsxs("div",{className:"session-window",children:[c.jsxs("div",{className:"session-window-head",children:[c.jsx("span",{className:"window-idx",children:i.windowIndex}),c.jsx("span",{className:"window-name",children:i.windowName})]}),c.jsx("ul",{className:"session-pane-list",children:i.panes.map(o=>c.jsx(zR,{s:o,selected:o.id===t,onSelect:n},o.id))})]},i.windowIndex))]},s.sessionName))})}const BR={on:"Notifications on",off:"Enable notifications",denied:"Notifications blocked",unsupported:"Notifications unsupported",working:"Working…"};function $R({push:e}){const{status:t,supported:n,enable:r,disable:s}=e,i=t==="on",o=!n||t==="unsupported"||t==="working"||t==="denied",a=BR[t]??"Notifications",l=()=>{o||(i?s():r())};return c.jsx("button",{type:"button",className:"notify-bell","data-state":t,"aria-pressed":i,"aria-label":a,title:a,disabled:o,onClick:l,children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24","aria-hidden":"true",children:[c.jsx("path",{d:"M12 22a2.5 2.5 0 0 0 2.45-2h-4.9A2.5 2.5 0 0 0 12 22Zm7-5-1.6-1.6V10a5.4 5.4 0 0 0-4-5.2V4a1.4 1.4 0 0 0-2.8 0v.8A5.4 5.4 0 0 0 6.6 10v5.4L5 17v1h14Z",fill:i?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),t==="denied"||t==="unsupported"?c.jsx("line",{x1:"4",y1:"4",x2:"20",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}):null]})})}function UR({size:e=18}){return c.jsxs("svg",{width:e,height:Math.round(e*1.2),viewBox:"0 0 10 12","aria-hidden":"true",focusable:"false",style:{display:"block",flexShrink:0},children:[c.jsx("rect",{x:"1",y:"2",width:"8",height:"7",fill:"#c97c5a"}),c.jsx("rect",{x:"0",y:"3",width:"1",height:"2",fill:"#c97c5a"}),c.jsx("rect",{x:"9",y:"3",width:"1",height:"2",fill:"#c97c5a"}),c.jsx("rect",{x:"2",y:"4",width:"2",height:"2",fill:"var(--bg)"}),c.jsx("rect",{x:"6",y:"4",width:"2",height:"2",fill:"var(--bg)"}),c.jsx("rect",{x:"2",y:"9",width:"2",height:"2",fill:"#c97c5a"}),c.jsx("rect",{x:"6",y:"9",width:"2",height:"2",fill:"#c97c5a"})]})}function yp(e,t=""){return e!=null?`${Math.round(e)}${t}`:"—"}function VR({resources:e,conn:t,push:n}){const r=e.snapshot,s=r?.self??{},i=r?.system??{},o=!!r?.overLimit||!!e.warning,a=i.loadavg?.[0];return c.jsxs("div",{className:"hud","data-warn":o?"true":"false",role:"status",children:[c.jsxs("span",{className:"hud-brand",children:[c.jsx(UR,{size:18}),"claude control"]}),c.jsx("span",{className:`conn-dot conn-${t}`,title:t,"aria-label":t}),c.jsxs("span",{className:"hud-group",children:[c.jsx("span",{className:"hud-k",children:"cpu"}),c.jsx("span",{className:"hud-v",children:s.cpuPct!=null?`${s.cpuPct.toFixed(0)}%`:"—"})]}),c.jsxs("span",{className:"hud-group",children:[c.jsx("span",{className:"hud-k",children:"rss"}),c.jsx("span",{className:"hud-v",children:yp(s.rssMB,"m")})]}),c.jsxs("span",{className:"hud-group",children:[c.jsx("span",{className:"hud-k",children:"load"}),c.jsx("span",{className:"hud-v",children:a!=null?a.toFixed(2):"—"})]}),c.jsxs("span",{className:"hud-group",children:[c.jsx("span",{className:"hud-k",children:"mem"}),c.jsx("span",{className:"hud-v",children:yp(i.memUsedPct,"%")})]}),o?c.jsx("span",{className:"hud-warn-text",children:e.warning||"over limit"}):null,c.jsx("span",{className:"hud-spacer"}),c.jsx($R,{push:n})]})}const HR={direction:"down",stagger:45,duration:300,exitOffset:50,easing:"cubic-bezier(0.34, 1.56, 0.64, 1)",bounce:.6,colorFade:280,skipUnchanged:!0,interrupt:!0},WR=" ",Md=e=>e===" "?WR:e,Js=new WeakMap;function Sw(e){const t=Js.get(e);t&&(t.timers.forEach(n=>window.clearTimeout(n)),Js.delete(e),fa(e,t.target))}function kw(e){const t=document.createElement("span");return t.className="char-face",t.textContent=Md(e),t}function Cw(e){const t=document.createElement("span");t.className="char-slot",t.dataset.char=e;const n=document.createElement("span");return n.className="char-sizer",n.textContent=Md(e),t.append(n,kw(e)),t}function fa(e,t){e.classList.add("slot-text"),e.replaceChildren(...Array.from(t,Cw))}function _w(e,t,n={}){const{direction:r,stagger:s,duration:i,exitOffset:o,easing:a,bounce:l,color:u,colorFade:f,skipUnchanged:d,interrupt:h}={...HR,...n},p=Js.get(e);if(p&&!h){t!==p.target&&(p.pending={text:t,options:n});return}if(Sw(e),!e.querySelector(".char-slot")){fa(e,t);return}const g=Array.from(e.querySelectorAll(".char-slot")),x=g.map(j=>j.dataset.char??"").join("");if(!h&&x===t)return;const k=Math.max(x.length,t.length),y=g.find(j=>(j.dataset.char??"")!=="")??g[0],v=getComputedStyle(e),w=Math.ceil(y?.getBoundingClientRect().height||y?.offsetHeight||e.getBoundingClientRect().height||parseFloat(v.lineHeight)||0)||Math.ceil(parseFloat(v.fontSize)*1.3)||18,E=u?v.color:"";for(let j=g.length;j<k;j++){const K=Cw("");e.appendChild(K),g.push(K)}const I=[],S={timers:I,target:t};Js.set(e,S);const R=r==="down"?w:-w,N=r==="down"?-w:w,D=(j,K)=>{const P=Math.sin((j+1)*12.9898+K*78.233)*43758.5453;return(P-Math.floor(P))*2-1};let _=0;for(let j=0;j<k;j++){const K=x[j]||"",P=t[j]||"";if(K===P&&(d||K===""))continue;const B=g[j],ee=B.querySelector(".char-sizer"),ae=B.querySelector(".char-face"),F=B.getBoundingClientRect().width;ee.textContent=Md(P);const M=ee.getBoundingClientRect().width,b=Math.abs(M-F)>.5;b&&(B.style.width=`${F}px`),(K===""||P==="")&&B.classList.add("is-resizing");const J=typeof u=="function"?u(j,k):u,Y=P==="",C=Math.round(i*(Y?.75:1)*(1+l*.45*D(j,1))),ge=Y?t.length*.5+(j-t.length)*.25:j,L=Math.round(ge*s*(1+l*.25*D(j,2))),O=(l*5*D(j,3)).toFixed(2),W=`transform ${C}ms ${a}`,Q=u?`${W}, color ${f}ms linear ${C}ms`:W,X=kw(P);if(X.style.transformOrigin="50% 50%",X.style.transform=`translateY(${N}px) rotate(${O}deg)`,J&&(X.style.color=J),B.appendChild(X),B.offsetWidth,b){let pe=L,$e=C;Y?(pe=L+Math.round(C*.55),$e=Math.max(140,Math.round(C*.6))):K===""&&($e=Math.max(140,Math.round(C*.45))),I.push(window.setTimeout(()=>{B.style.transition=`width ${$e}ms cubic-bezier(0.2, 0, 0, 1)`,B.style.width=`${M}px`},pe)),_=Math.max(_,pe+$e)}_=Math.max(_,L+o+C+(u?f:0)),ae&&I.push(window.setTimeout(()=>{ae.style.transition=W,ae.style.transform=`translateY(${R}px) rotate(${-Number(O)}deg)`},L)),I.push(window.setTimeout(()=>{X.style.transition=Q,X.style.transform="translateY(0) rotate(0deg)",u&&(X.style.color=E);const pe=$e=>{$e.propertyName==="transform"&&(X.removeEventListener("transitionend",pe),B.dataset.char=P,B.style.removeProperty("transition"),B.style.removeProperty("width"),B.classList.remove("is-resizing"),B.querySelectorAll(".char-face").forEach(qe=>{qe!==X&&qe.remove()}))};X.addEventListener("transitionend",pe)},L+o))}const z=_+80;I.push(window.setTimeout(()=>{const j=S.pending;Js.delete(e),fa(e,t),j&&_w(e,j.text,j.options)},z))}function qR(e,t=""){Sw(e),e.classList.remove("slot-text"),e.textContent=t}const Ew=m.forwardRef(({text:e,options:t,"aria-label":n,...r},s)=>{const i=m.useRef(null),o=m.useRef(!1),a=m.useRef(!0),l=m.useRef(t);return m.useImperativeHandle(s,()=>i.current,[]),m.useEffect(()=>{l.current=t},[t]),m.useEffect(()=>{const u=i.current;if(u)return fa(u,e),o.current=!0,()=>{qR(u),o.current=!1,a.current=!0}},[]),m.useEffect(()=>{const u=i.current;if(!(!u||!o.current)){if(a.current){a.current=!1;return}_w(u,e,l.current)}},[e]),m.createElement("span",{...r,"aria-label":n??e,ref:i})});Ew.displayName="SlotText";const KR=(e,t)=>typeof e=="string"?e===t:JSON.stringify(e)===JSON.stringify(t),GR=(e,t)=>{if(!e||!t)return!1;const n=r=>{const{position:s,data:i,...o}=r||{};return o};return JSON.stringify(n(e.properties))===JSON.stringify(n(t.properties))&&KR(e.children,t.children)},Tw=(e,t)=>GR(e.node,t.node),Dd=m.createContext(null),QR=()=>m.useContext(Dd)!==null,YR=({children:e,...t})=>c.jsx(Dd.Provider,{value:t,children:e}),JR=m.memo(YR,Tw),XR=({node:e,...t})=>c.jsx("pre",{...t}),ZR=({node:e,...t})=>c.jsx("code",{...t}),Ld=({node:e,components:{Pre:t,Code:n},code:r})=>c.jsx(t,{children:c.jsx(n,{node:e,children:r})}),eP=()=>null,tP=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:s},language:i,code:o})=>{const a=m.useMemo(()=>({Pre:t,Code:n}),[t,n]);return c.jsxs(c.Fragment,{children:[c.jsx(s,{node:e,language:i,code:o}),c.jsx(i?r:Ld,{node:e,components:a,language:i??"unknown",code:o})]})};var Iw={exports:{}};/*!
|
|
44
|
+
`);var Rh=class{constructor(e,t,n){T(this,"contentBinding");T(this,"messageApi");T(this,"threadApi");this.contentBinding=e,this.messageApi=t,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(e){const t=this.contentBinding.getState();if(!t)throw new Error("Message part is not available");if(t.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=t.toolName,s=t.toolCallId,i=hn.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:s,result:i.result,artifact:i.artifact,isError:i.isError})}resumeToolCall(e){const t=this.contentBinding.getState();if(!t)throw new Error("Message part is not available");if(t.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=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}respondToToolApproval(e){const t=this.contentBinding.getState();if(!t)throw new Error("Message part is not available");if(t.type!=="tool-call")throw new Error("Tried to respond to tool approval on non-tool message part");if(!t.approval||t.approval.approved!==void 0)throw new Error("Tool call has no pending approval");if(!this.threadApi)throw new Error("Thread API is not available");this.threadApi.getState().respondToToolApproval({approvalId:t.approval.id,approved:e.approved,...e.reason!=null&&{reason:e.reason}})}subscribe(e){return this.contentBinding.subscribe(e)}};const Zi=Object.freeze({type:"complete"}),U_=(e,t,n)=>{if(e.role!=="assistant")return Zi;if(n.type==="tool-call")return n.result?Zi:e.status;const r=t===Math.max(0,e.content.length-1);return e.status.type==="requires-action"?Zi:r?e.status:Zi},Ph=(e,t)=>{const n=e.content[t];if(!n)return Ht;const r=U_(e,t,n);return Object.freeze({...n,[pr]:n[pr],status:r})};var V_=class{constructor(e,t){T(this,"_core");T(this,"_threadBinding");T(this,"composer");T(this,"_getEditComposerRuntimeCore",()=>this._threadBinding.getState().getEditComposer(this._core.getState().id));this._core=e,this._threadBinding=t,this.composer=new $_(new na({path:{...this.path,ref:`${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.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()}reload(e={}){const t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:s=r.runConfig}=e,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 e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){const e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw new Error("Message is not being spoken")}submitFeedback({type:e}){const t=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:t.id,type:e})}switchToBranch({position:e,branchId:t}){const n=this._core.getState();if(t&&e)throw new Error("May not specify both branchId and position");if(!t&&!e)throw new Error("Must specify either branchId or position");const r=this._threadBinding.getState().getBranches(n.id);let s=t;if(e==="previous"?s=r[n.branchNumber-2]:e==="next"&&(s=r[n.branchNumber]),!s)throw new Error("Branch not found");this._threadBinding.getState().switchToBranch(s)}unstable_getCopyText(){return bi(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw new Error("Message part index must be >= 0");return new Rh(new Ft({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.content[${e}]`,messagePartSelector:{type:"index",index:e}},getState:()=>Ph(this.getState(),e),subscribe:t=>this._core.subscribe(t)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new Rh(new Ft({path:{...this.path,ref:this.path.ref+`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:"toolCallId",toolCallId:e}},getState:()=>{const t=this._core.getState(),n=t.content.findIndex(r=>r.type==="tool-call"&&r.toolCallId===e);return n===-1?Ht:Ph(t,n)},subscribe:t=>this._core.subscribe(t)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new O_(new Ft({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.attachments[${e}]`,attachmentSource:"message",attachmentSelector:{type:"index",index:e}},getState:()=>{const t=this.getState().attachments?.[e];return t?{...t,source:"message"}:Ht},subscribe:t=>this._core.subscribe(t)}))}};const H_=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),W_=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),q_=(e,t)=>typeof t=="string"?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:"user",content:[{type:"text",text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId??e.at(-1)?.id??null,sourceId:t.sourceId??null,role:t.role??"user",content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},K_=(e,t)=>{const n=e.messages.at(-1);return Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:e.isRunning??(n?.role!=="assistant"?!1:n.status.type==="running"),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice})};var Dv=class{constructor(e,t){T(this,"_threadBinding");T(this,"composer");T(this,"_eventSubscriptionSubjects",new Map);const n=new Ft({path:e.path,getState:()=>K_(e.getState(),t.getState()),subscribe:r=>{const s=e.subscribe(r),i=t.subscribe(r);return()=>{s(),i()}}});this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:r=>e.outerSubscribe(r),subscribe:r=>e.subscribe(r)},this.composer=new B_(new na({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.resumeRun=this.resumeRun.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getState=this.getState.bind(this)}getState(){return this._threadBinding.getStateState()}append(e){this._threadBinding.getState().append(q_(this._threadBinding.getState().messages,e))}subscribe(e){return this._threadBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun(W_(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(H_(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(e){return this._threadBinding.getState().subscribeVoiceVolume(e)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(e){this._threadBinding.getState().import(e)}reset(e){this._threadBinding.getState().reset(e)}getMessageByIndex(e){if(e<0)throw new Error("Message index must be >= 0");return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:"index",index:e}},()=>{const t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[messageId=${JSON.stringify(e)}]`,messageSelector:{type:"messageId",messageId:e}},()=>this._threadBinding.getState().getMessageById(e))}_getMessageRuntime(e,t){return new V_(new Ft({path:e,getState:()=>{const{message:n,parentId:r,index:s}=t()??{},{messages:i,speech:o}=this._threadBinding.getState();if(!n||r===void 0||s===void 0)return Ht;const a=this._threadBinding.getState().getBranches(n.id);return{...n,[pr]:n[pr],index:s,isLast:i.at(-1)?.id===n.id,parentId:r,branchNumber:a.indexOf(n.id)+1,branchCount:a.length,speech:o?.messageId===n.id?o:void 0}},subscribe:n=>this._threadBinding.subscribe(n)}),this._threadBinding)}unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new Rv({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}};const G_=m.createContext(null),Q_=()=>m.useContext(G_);var eo=class{constructor(e,t){T(this,"_core");T(this,"_threadListBinding");this._core=e,this._threadListBinding=t,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(e){const t=this._core.getState();return this._threadListBinding.switchToThread(t.id,e)}rename(e){const t=this._core.getState();return this._threadListBinding.rename(t.id,e)}updateCustom(e){const t=this._core.getState();if(!this._threadListBinding.updateCustom)throw new Error("Thread list runtime does not support updating custom metadata");return this._threadListBinding.updateCustom(t.id,e)}archive(){const e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){const e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){const e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){const e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(){const e=this._core.getState();return this._threadListBinding.generateTitle(e.id)}unstable_on(e,t){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,!(e==="switchedTo"&&!i)&&(e==="switchedAway"&&i||t({})))})}subscribe(e){return this._core.subscribe(e)}detach(){const e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}};const Ah=Promise.resolve(),Y_=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,isLoadingMore:e.isLoadingMore??!1,hasMore:e.hasMore??!1,threadItems:e.threadItems}),to=(e,t)=>{if(t===void 0)return Ht;const n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,custom:n.custom,isMain:n.id===e.mainThreadId}:Ht};var J_=class{constructor(e,t=Dv){T(this,"_core");T(this,"_runtimeFactory");T(this,"_getState");T(this,"_mainThreadListItemRuntime");T(this,"main");this._core=e,this._runtimeFactory=t;const n=new xd({path:{},getState:()=>Y_(e),subscribe:r=>e.subscribe(r)});this._getState=n.getState.bind(n),this._mainThreadListItemRuntime=new eo(new Ft({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>to(this._core,this._core.mainThreadId),subscribe:r=>this._core.subscribe(r)}),this._core),this.main=new t(new na({path:{ref:"threads.main",threadSelector:{type:"main"}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:r=>e.subscribe(r)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.loadMore=this.loadMore.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e,t){return this._core.switchToThread(e,t)}switchToNewThread(){return this._core.switchToNewThread()}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??Ah}loadMore(){return this._core.loadMore?.()??Ah}getState(){return this._getState()}subscribe(e){return this._core.subscribe(e)}get mainItem(){return this._mainThreadListItemRuntime}getById(e){return new this._runtimeFactory(new na({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:"threadId",threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:t=>this._core.subscribe(t)}),this.mainItem)}getItemByIndex(e){return new eo(new Ft({path:{ref:`threadItems[${e}]`,threadSelector:{type:"index",index:e}},getState:()=>to(this._core,this._core.threadIds[e]),subscribe:t=>this._core.subscribe(t)}),this._core)}getArchivedItemByIndex(e){return new eo(new Ft({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:"archiveIndex",index:e}},getState:()=>to(this._core,this._core.archivedThreadIds[e]),subscribe:t=>this._core.subscribe(t)}),this._core)}getItemById(e){return new eo(new Ft({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:"threadId",threadId:e}},getState:()=>to(this._core,e),subscribe:t=>this._core.subscribe(t)}),this._core)}},Lv=class{constructor(e){T(this,"_core");T(this,"threads");T(this,"_thread");this._core=e,this.threads=new J_(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}},Ov=class{constructor(){T(this,"_contextProvider",new dd)}registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}};const Jn=Object.freeze([]),Yr="DEFAULT_THREAD_ID",X_=Object.freeze([Yr]),Z_=Object.freeze({id:Yr,remoteId:void 0,externalId:void 0,status:"regular"}),e1=Promise.resolve(),jh=Object.freeze({[Yr]:Z_});var t1=class{constructor(e={},t){T(this,"threadFactory");T(this,"_mainThreadId",Yr);T(this,"_threads",X_);T(this,"_archivedThreads",Jn);T(this,"_threadData",jh);T(this,"adapter",{});T(this,"_mainThread");T(this,"_subscriptions",new Set);this.threadFactory=t,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 e1}get mainThreadId(){return this._mainThreadId}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw new Error("Method not implemented.")}getItemById(e){return this._threadData[e]}__internal_setAdapter(e,t=!1){const n=this.adapter;this.adapter=e;const r=e.threadId??Yr,s=e.threads??Jn,i=e.archivedThreads??Jn,o=n.threadId??Yr,a=n.threads??Jn,l=n.archivedThreads??Jn;!t&&o===r&&a===s&&l===i||((a!==s||l!==i||o!==r)&&(this._threadData={...jh,...Object.fromEntries(e.threads?.map(u=>[u.id,{...u,remoteId:u.remoteId,externalId:u.externalId,status:"regular"}])??[]),...Object.fromEntries(e.archivedThreads?.map(u=>[u.id,{...u,remoteId:u.remoteId,externalId:u.externalId,status:"archived"}])??[])}),a!==s&&(this._threads=this.adapter.threads?.map(u=>u.id)??Jn),l!==i&&(this._archivedThreads=this.adapter.archivedThreads?.map(u=>u.id)??Jn),(t||o!==r)&&(this._mainThreadId=r,this._mainThread=this.threadFactory()),this._threadData[this._mainThreadId]||(this._threadData={...this._threadData,[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:"regular"}}),this._notifySubscribers())}async switchToThread(e,t){if(this._mainThreadId===e)return;const n=this.adapter.onSwitchToThread;if(!n)throw new Error("External store adapter does not support switching to thread");await n(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,t){const n=this.adapter.onRename;if(!n)throw new Error("External store adapter does not support renaming");await n(e,t)}async updateCustom(e,t){const n=this.adapter.onUpdateCustom;if(!n)throw new Error("External store adapter does not support updating custom metadata");await n(e,t)}async detach(){}async archive(e){const t=this.adapter.onArchive;if(!t)throw new Error("External store adapter does not support archiving");await t(e)}async unarchive(e){const t=this.adapter.onUnarchive;if(!t)throw new Error("External store adapter does not support unarchiving");await t(e)}async delete(e){const t=this.adapter.onDelete;if(!t)throw new Error("External store adapter does not support deleting");await t(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw new Error("Method not implemented.")}subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}_notifySubscribers(){for(const e of this._subscriptions)e()}};const Hn=wv("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),ps=Symbol("autoStatus"),n1=Object.freeze(Object.assign({type:"running"},{[ps]:!0})),r1=Object.freeze(Object.assign({type:"complete",reason:"unknown"},{[ps]:!0})),s1=Object.freeze(Object.assign({type:"requires-action",reason:"tool-calls"},{[ps]:!0})),i1=Object.freeze(Object.assign({type:"requires-action",reason:"interrupt"},{[ps]:!0})),o1=e=>e[ps]===!0,ra=(e,t,n,r,s)=>e&&s?Object.assign({type:"incomplete",reason:"error",error:s},{[ps]:!0}):e&&t?n1:n?i1:r?s1:r1,Tl=(e,t)=>{if(e.startsWith("data-"))return{type:"data",name:e.substring(5),data:t}},Si=(e,t,n)=>{const{role:r,id:s,createdAt:i,attachments:o,status:a,metadata:l}=e,u={id:s??t,createdAt:i??new Date},f=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content,d=({image:h,...p})=>h.match(/^data:image\/(png|jpeg|jpg|gif|webp|svg\+xml);base64,(.*)$/)?{...p,image:h}:/^(https:\/\/|blob:)/.test(h)?{...p,image:h}:(console.warn("Invalid image data format detected"),null);if(r!=="user"&&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?.steps)throw new Error("metadata.steps is only supported for assistant messages");switch(r){case"assistant":return{...u,role:r,content:f.map(h=>{const p=h.type;switch(p){case"text":case"reasoning":return h.text.trim().length===0?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:g,messages:v,...S}=h,y={...S,toolCallId:h.toolCallId??`tool-${Hn()}`,...g!==void 0&&{parentId:g},...v!==void 0&&{messages:v}};return h.args?{...y,args:h.args,argsText:h.argsText??JSON.stringify(h.args)}:{...y,args:Ku(h.argsText??"")??{},argsText:h.argsText??""}}default:{const g=Tl(p,h.data);if(g)return g;throw new Error(`Unsupported assistant message part type: ${p}`)}}}).filter(h=>!!h),status:a??n,metadata:{unstable_state:l?.unstable_state??null,unstable_annotations:l?.unstable_annotations??[],unstable_data:l?.unstable_data??[],custom:l?.custom??{},steps:l?.steps??[],...l?.timing&&{timing:l.timing},...l?.submittedFeedback&&{submittedFeedback:l.submittedFeedback},...l?.isOptimistic&&{isOptimistic:!0}}};case"user":return{...u,role:r,content:f.map(h=>{const p=h.type;switch(p){case"text":case"image":case"audio":case"file":case"data":return h;default:{const g=Tl(p,h.data);if(g)return g;throw new Error(`Unsupported user message part type: ${p}`)}}}),attachments:(o??[]).map(h=>({...h,content:h.content.map(p=>Tl(p.type,p.data)??p)})),metadata:{custom:l?.custom??{}}};case"system":if(f.length!==1||f[0].type!=="text")throw new Error("System messages must have exactly one text message part.");return{...u,role:r,content:f,metadata:{custom:l?.custom??{}}};default:throw new Error(`Unknown message role: ${r}`)}},zv={fromArray:e=>{const t=e.map(n=>Si(n,Hn(),ra(!1,!1,!1,!1,void 0)));return{messages:t.map((n,r)=>({parentId:r>0?t[r-1].id:null,message:n}))}},fromBranchableArray:(e,t)=>{const n=ra(!1,!1,!1,!1,void 0);return{...t?.headId!==void 0?{headId:t.headId}:void 0,messages:e.map(({message:r,parentId:s})=>{if(!r.id)throw new Error("ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.");return{parentId:s,message:Si(r,r.id,n)}})}}},Co=e=>e.next?Co(e.next):"current"in e?e:null;var a1=class{constructor(e){T(this,"func");T(this,"_value",null);this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},wd=class{constructor(){T(this,"messages",new Map);T(this,"head",null);T(this,"root",{children:[],next:null});T(this,"_messages",new a1(()=>{const e=new Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e}))}updateLevels(e,t){e.level=t;for(const n of e.children){const r=this.messages.get(n);r&&this.updateLevels(r,t+1)}}performOp(e,t,n){const r=t.prev??this.root,s=e??this.root;if(!(n==="relink"&&r===s)){if(n!=="link"&&(r.children=r.children.filter(i=>i!==t.current.id),r.next===t)){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"){for(let o=e;o;o=o.prev)if(o.current.id===t.current.id)throw new Error("MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.");s.children=[...s.children,t.current.id],(Co(t)===this.head||s.next===null)&&(s.next=t),t.prev=e;const i=e?e.level+1:0;this.updateLevels(t,i)}}}get headId(){return this.head?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.");const n=new Array(t.level+1);for(let r=t;r;r=r.prev)n[r.level]=r.current;return n}addOrUpdateMessage(e,t){const n=this.messages.get(t.id),r=e?this.messages.get(e):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=t,this.performOp(r,n,"relink"),this._messages.dirty();return}const s={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,s),this.performOp(r,s,"link"),this.head===r&&(this.head=s),this._messages.dirty()}getMessage(e){const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.");return{parentId:t.prev?.current.id??null,message:t.current,index:t.level}}deleteMessage(e,t){const n=this.messages.get(e);if(!n)throw new Error("MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.");const r=t===void 0?n.prev:t===null?null:this.messages.get(t);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(e),this.head===n&&(this.head=Co(r??this.root)),this._messages.dirty()}getBranches(e){const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.");const{children:n}=t.prev??this.root;return n}evictOffBranchOptimisticMessages(e,t){if(!e)return;const n=new Set;for(let s=t;s;s=s.prev)n.add(s.current.id);const r=[];for(let s=e;s&&!n.has(s.current.id);s=s.prev)s.current.metadata?.isOptimistic&&r.push(s.current.id);for(const s of r)this.messages.has(s)&&this.deleteMessage(s)}switchToBranch(e){const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.");const n=this.head,r=t.prev??this.root;r.next=t,this.head=Co(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.");const n=this.head;if(t.children.length>0){const r=s=>{for(const i of s.children){const o=this.messages.get(i);o&&(r(o),this.messages.delete(i))}};r(t),t.children=[],t.next=null}this.head=t;for(let r=t;r;r=r.prev)r.prev?r.prev.next=r:this.root.next=r;this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){const e=[];for(const[,n]of this.messages)n.current.metadata?.isOptimistic||e.push({message:n.current,parentId:n.prev?.current.id??null});let t=this.head;for(;t?.current.metadata?.isOptimistic;)t=t.prev;return{headId:t?.current.id??null,messages:e}}import({headId:e,messages:t}){for(const{message:n,parentId:r}of t)this.addOrUpdateMessage(r,n);this.resetHead(e??t.at(-1)?.message.id??null)}};function Nh(e,t){if(t==="*")return!0;const n=t.split(",").map(i=>i.trim().toLowerCase()),r=`.${e.name.split(".").pop().toLowerCase()}`,s=e.type.toLowerCase();for(const i of n){if(i.startsWith(".")&&i===r||i.includes("/")&&i===s)return!0;if(i.endsWith("/*")){const o=i.split("/")[0];if(s.startsWith(`${o}/`))return!0}}return!1}function l1(e,t){return e.length!==t.length?!1:e.every((n,r)=>n.id===t[r].id)}function u1(e){const t=Hn();return e.type==="image"?{id:t,type:"image",name:e.filename??"image",content:[e],status:{type:"complete"}}:e.type==="file"?{id:t,type:"document",name:e.filename??"document",contentType:e.mimeType,content:[e],status:{type:"complete"}}:e.type==="audio"?{id:t,type:"audio",name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:"complete"}}:{id:t,type:"data",name:e.name,content:[e],status:{type:"complete"}}}function c1(e){const t=[];for(const n of e)n.type!=="text"&&t.push(u1(n));return t}const Il=e=>e.status.type==="complete";var Fv=class extends M_{constructor(){super(...arguments);T(this,"isEditing",!0);T(this,"_attachments",[]);T(this,"_text","");T(this,"_role","user");T(this,"_runConfig",{});T(this,"_quote");T(this,"_dictation");T(this,"_dictationSession");T(this,"_dictationUnsubscribes",[]);T(this,"_dictationBaseText","");T(this,"_currentInterimText","");T(this,"_dictationSessionIdCounter",0);T(this,"_activeDictationSessionId");T(this,"_isCleaningDictation",!1);T(this,"_eventSubscribers",new Map)}get attachmentAccept(){return this.getAttachmentAdapter()?.accept??"*"}get attachments(){return this._attachments}setAttachments(t){this._attachments=t,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(t){this._quote!==t&&(this._quote=t,this._notifySubscribers())}setText(t){if(this._text!==t){if(this._text=t,this._dictation){this._dictationBaseText=t,this._currentInterimText="";const{status:n,inputDisabled:r}=this._dictation;this._dictation=r?{status:n,inputDisabled:r}:{status:n}}this._notifySubscribers()}}setRole(t){this._role!==t&&(this._role=t,this._notifySubscribers())}setRunConfig(t){this._runConfig!==t&&(this._runConfig=t,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text="",this._notifySubscribers()}async _onClearAttachments(){const t=this.getAttachmentAdapter();if(t){const n=this._attachments.filter(r=>!Il(r));await Promise.all(n.map(r=>t.remove(r)))}}async reset(){if(this._attachments.length===0&&this._text===""&&this._role==="user"&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role="user",this._runConfig={},this._quote=void 0;const t=this._onClearAttachments();this._emptyTextAndAttachments(),await t}async clearAttachments(){const t=this._onClearAttachments();this.setAttachments([]),await t}async send(t){if(!this.canSend)return;this._dictationSession&&(this._dictationSession.cancel(),this._cleanupDictation());const n=this.getAttachmentAdapter(),r=this.attachments.length>0?Promise.all(this.attachments.map(async a=>{if(Il(a))return a;if(!n)throw new Error("Attachments are not supported");return await n.send(a)})):[],s=this.text,i=this._quote;this._quote=void 0,this._emptyTextAndAttachments();const o={createdAt:new Date,role:this.role,content:s?[{type:"text",text:s}]:[],attachments:await r,runConfig:this.runConfig,metadata:{custom:{...i?{quote:i}:{}}}};this.handleSend(o,t),this._notifyEventSubscribers("send",{})}cancel(){this.handleCancel()}async addAttachment(t){if(!(t instanceof File)){const i=this.getAttachmentAdapter();if(i&&!Nh({name:t.name,type:t.contentType??""},i.accept)){const a=`File type ${t.contentType||"unknown"} is not accepted. Accepted types: ${i.accept}`,l=new Error(a);throw this._safeEmitAttachmentAddError("not-accepted",a,void 0,l),l}const o={id:t.id??Hn(),type:t.type??"document",name:t.name,contentType:t.contentType,content:t.content,status:{type:"complete"}};this._attachments=[...this._attachments,o],this._notifySubscribers(),this._notifyEventSubscribers("attachmentAdd",{});return}const n=i=>{const o=this._attachments.findIndex(a=>a.id===i.id);o!==-1?this._attachments=[...this._attachments.slice(0,o),i,...this._attachments.slice(o+1)]:this._attachments=[...this._attachments,i],this._notifySubscribers()},r=this.getAttachmentAdapter();if(!r){const i="Attachments are not supported",o=new Error(i);throw this._safeEmitAttachmentAddError("no-adapter",i,void 0,o),o}if(!Nh({name:t.name,type:t.type},r.accept)){const i=`File type ${t.type||"unknown"} is not accepted. Accepted types: ${r.accept}`,o=new Error(i);throw this._safeEmitAttachmentAddError("not-accepted",i,void 0,o),o}let s;try{const i=r.add({file:t});if(Symbol.asyncIterator in i)for await(const o of i)s=o,n(o);else s=await i,n(s)}catch(i){throw s&&n({...s,status:{type:"incomplete",reason:"error"}}),this._safeEmitAttachmentAddError("adapter-error",i instanceof Error?i.message:String(i),s?.id,i instanceof Error?i:void 0),i}s?.status.type==="incomplete"&&s.status.reason==="error"?this._safeEmitAttachmentAddError("adapter-error","Attachment upload did not complete successfully.",s?.id):this._notifyEventSubscribers("attachmentAdd",{})}_safeEmitAttachmentAddError(t,n,r,s){try{this._notifyEventSubscribers("attachmentAddError",{reason:t,message:n,...r!==void 0&&{attachmentId:r},...s!==void 0&&{error:s}})}catch(i){console.error("[assistant-ui] attachmentAddError subscriber threw:",i)}}async removeAttachment(t){const n=this._attachments.findIndex(s=>s.id===t);if(n===-1)throw new Error("Attachment not found");const r=this._attachments[n];if(!Il(r)){const s=this.getAttachmentAdapter();if(!s)throw new Error("Attachments are not supported");await s.remove(r)}this._attachments=this._attachments.filter(s=>s.id!==t),this._notifySubscribers()}get dictation(){return this._dictation}_isActiveSession(t,n){return this._activeDictationSessionId===t&&this._dictationSession===n}startDictation(){const t=this.getDictationAdapter();if(!t)throw new Error("Dictation adapter not configured");if(this._dictationSession){for(const u of this._dictationUnsubscribes)u();this._dictationUnsubscribes=[],this._dictationSession.stop().catch(()=>{}),this._dictationSession=void 0}const n=t.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText="";const r=t.listen();this._dictationSession=r;const s=++this._dictationSessionIdCounter;this._activeDictationSessionId=s,this._dictation={status:r.status,inputDisabled:n},this._notifySubscribers();const i=r.onSpeech(u=>{if(!this._isActiveSession(s,r))return;const f=u.isFinal!==!1,d=this._dictationBaseText&&!this._dictationBaseText.endsWith(" ")&&u.transcript?" ":"";if(f){if(this._dictationBaseText=this._dictationBaseText+d+u.transcript,this._currentInterimText="",this._text=this._dictationBaseText,this._dictation){const{transcript:h,...p}=this._dictation;this._dictation=p}this._notifySubscribers()}else this._currentInterimText=d+u.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&(this._dictation={...this._dictation,transcript:u.transcript}),this._notifySubscribers()});this._dictationUnsubscribes.push(i);const o=r.onSpeechStart(()=>{this._isActiveSession(s,r)&&(this._dictation={status:{type:"running"},inputDisabled:n,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(o);const a=r.onSpeechEnd(()=>{this._cleanupDictation({sessionId:s})});this._dictationUnsubscribes.push(a);const l=setInterval(()=>{this._isActiveSession(s,r)&&r.status.type==="ended"&&this._cleanupDictation({sessionId:s})},100);this._dictationUnsubscribes.push(()=>clearInterval(l))}stopDictation(){if(!this._dictationSession)return;const t=this._dictationSession,n=this._activeDictationSessionId;t.stop().finally(()=>{this._cleanupDictation({sessionId:n})})}_cleanupDictation(t){if(!(t?.sessionId!==void 0&&t.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)){this._isCleaningDictation=!0;try{for(const n of this._dictationUnsubscribes)n();this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText="",this._currentInterimText="",this._notifySubscribers()}finally{this._isCleaningDictation=!1}}}_notifyEventSubscribers(t,n){const r=this._eventSubscribers.get(t);if(r)for(const s of r)s(n)}unstable_on(t,n){const r=n;let s=this._eventSubscribers.get(t);return s||(s=new Set,this._eventSubscribers.set(t,s)),s.add(r),()=>{this._eventSubscribers.get(t)?.delete(r)}}},Bv=class extends Fv{constructor(t){super();T(this,"runtime");T(this,"_canCancel",!1);this.runtime=t,this.connect()}get canCancel(){return this._canCancel}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}connect(){let t=this.runtime.isSendDisabled;return this.runtime.subscribe(()=>{let n=!1;this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,n=!0),t!==this.runtime.isSendDisabled&&(t=this.runtime.isSendDisabled,n=!0),n&&this._notifySubscribers()})}async handleSend(t,n){this.runtime.append({...t,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:n?.startRun})}async handleCancel(){this.runtime.cancelRun()}},d1=class extends Fv{constructor(t,n,{parentId:r,message:s}){super();T(this,"runtime");T(this,"endEditCallback");T(this,"_previousText");T(this,"_previousAttachments");T(this,"_nonTextPassthrough");T(this,"_parentId");T(this,"_sourceId");this.runtime=t,this.endEditCallback=n,this._parentId=r,this._sourceId=s.id,this._previousText=bi(s),this.setText(this._previousText),this.setRole(s.role),s.role==="user"?(this._previousAttachments=[...s.attachments??[],...c1(s.content)],this._nonTextPassthrough=[]):(this._previousAttachments=s.attachments??[],this._nonTextPassthrough=s.content.filter(i=>i.type!=="text")),this.setAttachments(this._previousAttachments),this.setRunConfig({...t.composer.runConfig})}get canCancel(){return!0}get canSend(){return!this.isEmpty}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(t,n){const r=bi(t),s=!l1(t.attachments??[],this._previousAttachments);if(r!==this._previousText||s||n?.startRun){const i=this._nonTextPassthrough.length>0?[...t.content,...this._nonTextPassthrough]:t.content;this.runtime.append({...t,content:i,parentId:this._parentId,sourceId:this._sourceId,startRun:n?.startRun})}this.handleCancel()}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},f1=class{constructor(e){T(this,"_contextProvider");T(this,"_subscriptions",new Set);T(this,"_isInitialized",!1);T(this,"repository",new wd);T(this,"_voiceMessages",[]);T(this,"_voiceGeneration",0);T(this,"_cachedMergedMessages",null);T(this,"_cachedVoiceGeneration",-1);T(this,"_cachedMergedBase",null);T(this,"composer",new Bv(this));T(this,"_editComposers",new Map);T(this,"_stopSpeaking");T(this,"speech");T(this,"_voiceSession");T(this,"_voiceUnsubs",[]);T(this,"voice");T(this,"_voiceVolume",0);T(this,"_voiceVolumeSubscribers",new Set);T(this,"getVoiceVolume",()=>this._voiceVolume);T(this,"subscribeVoiceVolume",e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e)));T(this,"_currentAssistantMsg",null);T(this,"_eventSubscribers",new Map);this._contextProvider=e}_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();const e=this._getBaseMessages();return(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e)&&(this._cachedMergedMessages=[...e,...this._voiceMessages],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e),this._cachedMergedMessages}get state(){let e;for(const t of this.messages)t.role==="assistant"&&(e=t);return e?.metadata.unstable_state??null}getModelContext(){return this._contextProvider.getModelContext()}getEditComposer(e){return this._editComposers.get(e)}beginEdit(e){if(this._editComposers.has(e))throw new Error("Edit already in progress");this._editComposers.set(e,new d1(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{const t=this.repository.getMessages(),n=this._voiceMessages.findIndex(r=>r.id===e);return n!==-1?{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}:void 0}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifySubscribers(){for(const e of this._subscriptions)e()}_notifyEventSubscribers(e,t){const n=this._eventSubscribers.get(e);if(n)for(const r of n)r(t)}subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}submitFeedback({messageId:e,type:t}){const n=this.adapters?.feedback;if(!n)throw new Error("Feedback adapter not configured");const{message:r,parentId:s}=this.repository.getMessage(e);if(n.submit({message:r,type:t}),r.role==="assistant"){const i={...r,metadata:{...r.metadata,submittedFeedback:{type:t}}};this.repository.addOrUpdateMessage(s,i)}this._notifySubscribers()}speak(e){const t=this.adapters?.speech;if(!t)throw new Error("Speech adapter not configured");const{message:n}=this.repository.getMessage(e);this._stopSpeaking?.();const r=t.speak(bi(n)),s=r.subscribe(()=>{r.status.type==="ended"?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:e,status:r.status},this._notifySubscribers()});this.speech={messageId:e,status:r.status},this._notifySubscribers(),this._stopSpeaking=()=>{r.cancel(),s(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw new Error("No message is being spoken");this._stopSpeaking(),this._notifySubscribers()}connectVoice(){const e=this.adapters?.voice;if(!e)throw new Error("Voice adapter not configured");this.disconnectVoice();const t=e.connect({});this._voiceSession=t;const n=[];let r="listening";this.voice={status:t.status,isMuted:t.isMuted,mode:r},this._voiceVolume=0,this._notifySubscribers(),n.push(t.onStatusChange(s=>{s.type==="ended"?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0):this.voice={status:s,isMuted:t.isMuted,mode:r},this._notifySubscribers()})),n.push(t.onModeChange(s=>{r=s,this.voice&&(this.voice={...this.voice,mode:s},this._notifySubscribers())})),n.push(t.onVolumeChange(s=>{this._voiceVolume=s;for(const i of this._voiceVolumeSubscribers)i()})),n.push(t.onTranscript(s=>{this._handleVoiceTranscript(s)})),this._voiceUnsubs=n}_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role==="user")this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal&&(this._voiceMessages.push({id:Hn(),role:"user",content:[{type:"text",text:e.text}],metadata:{custom:{}},createdAt:new Date,status:{type:"complete",reason:"unknown"},attachments:[]}),this._markVoiceMessagesDirty(),this._notifySubscribers());else{if(!this._currentAssistantMsg)this._currentAssistantMsg={id:Hn(),role:"assistant",content:[{type:"text",text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},status:{type:"running"},createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{const t=this._voiceMessages.indexOf(this._currentAssistantMsg);if(t===-1)return;const n={...this._currentAssistantMsg,content:[{type:"text",text:e.text}],...e.isFinal?{status:{type:"complete",reason:"stop"}}:{}};this._voiceMessages[t]=n,this._currentAssistantMsg=n}e.isFinal&&(this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(){const e=this._voiceMessages.at(-1);if(e?.role==="assistant"&&e.status.type==="running"){const t=this._voiceMessages.length-1;this._voiceMessages[t]={...e,status:{type:"complete",reason:"stop"}},this._markVoiceMessagesDirty(),this._notifySubscribers()}}disconnectVoice(){this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null;for(const e of this._voiceUnsubs)e();this._voiceUnsubs=[],this._voiceSession?.disconnect(),this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;for(const e of this._voiceVolumeSubscribers)e();this._voiceMessages=[],this._markVoiceMessagesDirty(),this._notifySubscribers()}muteVoice(){if(!this._voiceSession)throw new Error("No active voice session");this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw new Error("No active voice session");this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers("initialize",{}))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(zv.fromArray(e??[]))}unstable_on(e,t){const n=t;if(e==="modelContextUpdate")return this._contextProvider.subscribe?.(()=>n({}))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e==="initialize"&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&n({})}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},Mh=class{constructor(){T(this,"cache",new WeakMap)}convertMessages(e,t){return e.map((n,r)=>{const s=t(this.cache.get(n),n,r);return this.cache.set(n,s),s})}};function Qu(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function sa(e,t=0){return t>100?!1:e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?!Number.isNaN(e)&&Number.isFinite(e):Array.isArray(e)?e.every(n=>sa(n,t+1)):Qu(e)?Object.entries(e).every(([n,r])=>typeof n=="string"&&sa(r,t+1)):!1}const h1=100,Yu=(e,t,n)=>{if(e===t)return!0;if(n>h1||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((i,o)=>Yu(i,t[o],n+1));if(Array.isArray(t)||!Qu(e)||!Qu(t))return!1;const r=Object.keys(e),s=Object.keys(t);return r.length!==s.length?!1:r.every(i=>Object.hasOwn(t,i)&&Yu(e[i],t[i],n+1))},p1=(e,t)=>!sa(e)||!sa(t)?!1:Yu(e,t,0),no=e=>{try{return JSON.parse(e),!0}catch{return!1}},Dh=e=>{try{return JSON.parse(e)}catch{return}},Lh=(e,t)=>{const n=Dh(e),r=Dh(t);return n===void 0||r===void 0?!1:p1(n,r)};var m1=class{constructor(e,t){T(this,"_getTools");T(this,"_callbacks");T(this,"_entries",new Map);T(this,"_skipExecuteStreamIds",new Set);T(this,"_humanInput",new Map);T(this,"_executing",new Set);T(this,"_settledResolvers",[]);T(this,"_statuses",new Map);T(this,"_ac",new AbortController);T(this,"_pendingRestore",!0);T(this,"_lastSnapshot",null);T(this,"_isRunning",!1);T(this,"_controller");T(this,"_pipelineDead",!1);T(this,"_pipelineRestartUsed",!1);this._getTools=e,this._callbacks=t,this._initPipeline()}_initPipeline(){const[e,t]=i_();this._controller=t;const n=C_(()=>this._getWrappedTools(),()=>this._ac.signal,(r,s)=>this._onHumanInput(r,s),{onExecutionStart:r=>this._onExecutionStart(r),onExecutionEnd:r=>this._onExecutionEnd(r)});e.pipeThrough(n).pipeThrough(new xv).pipeTo(new WritableStream({write:r=>{try{if(r.type!=="result")return;this._handleResultChunk(r)}catch(s){console.error("[ToolInvocationTracker] result chunk handling failed",s)}}})).catch(r=>{console.error("[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState",r),this._pipelineDead=!0})}setState(e){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===e.messages&&this._lastSnapshot.isRunning===e.isRunning&&this._lastSnapshot.isLoading===e.isLoading)return;e.isLoading===!0&&(this._pendingRestore=!0);const t=this._isRunning;this._isRunning=e.isRunning;try{this._processMessages(e.messages)}catch(n){throw this._isRunning=t,n}this._lastSnapshot=e,this._pendingRestore=!1}catch(t){console.error("[ToolInvocationTracker] setState failed; snapshot dropped",t)}}reset(){try{this._pendingRestore=!0,this._entries.clear(),this._lastSnapshot=null,this.abort().finally(()=>{this._executing.clear()})}catch(e){console.error("[ToolInvocationTracker] reset failed",e)}}abort(){try{return this._humanInput.forEach(({reject:e})=>{try{e(new Error("Tool execution aborted"))}catch{}}),this._humanInput.clear(),this._ac.abort(),this._ac=new AbortController,this._executing.size===0?Promise.resolve():new Promise(e=>{this._settledResolvers.push(e)})}catch(e){return console.error("[ToolInvocationTracker] abort failed",e),Promise.resolve()}}resume(e,t){try{const n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:"executing"}),n.resolve(t),!0):!1}catch(n){return console.error("[ToolInvocationTracker] resume failed",n),!1}}getStatuses(){return this._statuses}_getWrappedTools(){const e=this._getTools();if(e)return Object.fromEntries(Object.entries(e).map(([t,n])=>{const r=n.execute;return r===void 0?[t,n]:[t,{...n,execute:(...[s,i])=>this._skipExecuteStreamIds.has(i.toolCallId)?new Promise(()=>{}):r(s,i)}]}))}_onHumanInput(e,t){return new Promise((n,r)=>{const s=this._humanInput.get(e);if(s)try{s.reject(new Error("Human input request was superseded by a new request"))}catch{}this._humanInput.set(e,{resolve:n,reject:r}),this._setStatus(e,{type:"interrupt",payload:{type:"human",payload:t}})})}_onExecutionStart(e){this._skipExecuteStreamIds.has(e)||(this._executing.add(e),this._setStatus(e,{type:"executing"}))}_onExecutionEnd(e){this._executing.delete(e)&&(this._deleteStatus(e),this._executing.size===0&&this._settledResolvers.splice(0).forEach(t=>{try{t()}catch{}}))}_handleResultChunk(e){const t=e.meta.toolCallId,n=this._entries.get(t);!n&&this._skipExecuteStreamIds.has(t)||n?.hasResult||this._invokeOnResult({type:"add-tool-result",toolCallId:t,toolName:e.meta.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}})}_invokeOnResult(e){try{this._callbacks.onResult(e)}catch(t){console.error("[ToolInvocationTracker] onResult callback threw; result dropped",t)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(e){console.error("[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated",e)}}_setStatus(e,t){const n=new Map(this._statuses);n.set(e,t),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(e){if(!this._statuses.has(e))return;const t=new Map(this._statuses);t.delete(e),this._statuses=t,this._invokeOnStatusesChange()}_hasExecutableTool(e){const t=this._getTools()?.[e];return t?.execute!==void 0||t?.streamCall!==void 0}_shouldCloseArgsStream({toolName:e,argsText:t,hasResult:n}){return n?!0:(this._hasExecutableTool(e)||!this._isRunning)&&no(t)}_startActiveEntry(e,t,n){const r=this._controller.addToolCallPart({toolName:t,toolCallId:e});n&&this._skipExecuteStreamIds.add(e);const s={toolName:t,controller:r,argsText:"",hasResult:!1,argsComplete:!1};return this._entries.set(e,s),s}_demoteEntriesToRestored(){for(const[e,t]of this._entries)t.controller&&this._entries.set(e,{toolName:t.toolName,argsText:t.argsText,hasResult:t.hasResult})}_processArgsText(e,t){if(!e.controller)return;const n=t.result!==void 0;if(t.argsText!==e.argsText){let r=!0;if(e.argsComplete)Lh(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText))if(no(e.argsText)&&no(t.argsText)&&Lh(e.argsText,t.argsText)){const s=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});s&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=s,r=!1}else r=!1;if(r&&e.controller){const s=t.argsText.slice(e.argsText.length);e.controller.argsText.append(s);const i=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n})&&(e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=!0)}_processMessages(e){const t=this._pendingRestore;for(const n of e)if(!(!n||!Array.isArray(n.content)))for(const r of n.content){if(!r||r.type!=="tool-call")continue;const s=this._entries.get(r.toolCallId);if(t){s?.controller||this._entries.set(r.toolCallId,{toolName:r.toolName,argsText:r.argsText,hasResult:r.result!==void 0}),r.messages&&this._processMessages(r.messages);continue}let i=s;if(i&&!i.controller){if(!(r.argsText!==i.argsText||r.result!==void 0!==i.hasResult)){r.messages&&this._processMessages(r.messages);continue}this._entries.delete(r.toolCallId),i=void 0}if(i||(i=this._startActiveEntry(r.toolCallId,r.toolName,r.result!==void 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 hn({result:r.result,artifact:r.artifact,isError:r.isError,...r.modelContent!==void 0?{modelContent:r.modelContent}:{}})),o.close()}r.messages&&this._processMessages(r.messages)}}};const g1=Object.freeze([]),Oh=(e,t)=>{const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(e[r]!==t[r])return!1;return!0},y1=(e,t)=>e&&t[t.length-1]?.role!=="assistant";var v1=class extends f1{constructor(t,n){super(t);T(this,"_capabilities",{switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,reload:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1});T(this,"_messages");T(this,"isDisabled");T(this,"isSendDisabled");T(this,"suggestions",[]);T(this,"extras");T(this,"_converter",new Mh);T(this,"_store");T(this,"_toolInvocations",null);T(this,"_toolCallToMessageId",new Map);T(this,"_messagesForToolCallIndex",null);T(this,"updateMessages",t=>{this._store.convertMessage!==void 0?this._store.setMessages?.(t.flatMap(j_)):this._store.setMessages?.(t)});this.__internal_setAdapter(n)}get capabilities(){return this._capabilities}get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}beginEdit(t){if(!this._store.onEdit)throw new Error("Runtime does not support editing.");super.beginEdit(t)}__internal_setAdapter(t){if(this._store===t)return;const n=t.isRunning??!1;this.isDisabled=t.isDisabled??!1,this.isSendDisabled=t.isSendDisabled??!1;const r=this._store;this._store=t,this.extras!==t.extras&&(this.extras=t.extras);const s=t.suggestions??g1;Oh(this.suggestions,s)||(this.suggestions=s);const i={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,reload:this._store.onReload!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:!1};Oh(this._capabilities,i)||(this._capabilities=i);let o;if(t.messageRepository){if(r&&r.isRunning===t.isRunning&&r.messageRepository===t.messageRepository){this._notifySubscribers();return}this.repository.clear(),this.repository.import(t.messageRepository),o=this.repository.getMessages()}else if(t.messages){if(r){if(r.convertMessage!==t.convertMessage)this._converter=new Mh;else if(r.isRunning===t.isRunning&&r.messages===t.messages){this._notifySubscribers();return}}o=t.convertMessage?this._converter.convertMessages(t.messages,(l,u,f)=>{if(!t.convertMessage)return u;const d=ra(f===(t.messages?.length??0)-1,n,!1,!1,void 0);if(l&&(l.role!=="assistant"||!o1(l.status)||l.status===d))return l;const h=Si(t.convertMessage(u,f),f.toString(),d);return A_(h,u),h}):t.messages;for(let l=0;l<o.length;l++){const u=o[l],f=o[l-1];this.repository.addOrUpdateMessage(f?.id??null,u)}}else throw new Error("ExternalStoreAdapter must provide either 'messages' or 'messageRepository'");o.length>0&&this.ensureInitialized(),(r?.isRunning??!1)!==(t.isRunning??!1)&&(t.isRunning?this._notifyEventSubscribers("runStart",{}):this._notifyEventSubscribers("runEnd",{}));let a=null;y1(n,o)&&(a=Hn(),this.repository.addOrUpdateMessage(o.at(-1)?.id??null,Si({role:"assistant",content:[],metadata:{isOptimistic:!0}},a,{type:"running"}))),this.repository.resetHead(a??o.at(-1)?.id??null),this._messages=this.repository.getMessages(),this._driveToolInvocations(),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._store.setToolStatuses?.({}));return}this._toolInvocations||(this._toolInvocations=new m1(()=>this.getModelContext().tools,{onResult:t=>{try{const n=this._findMessageIdForToolCall(t.toolCallId);if(n===void 0)return;this._store.onAddToolResult?.({messageId:n,toolCallId:t.toolCallId,toolName:t.toolName,result:t.result,isError:t.isError,...t.artifact!==void 0&&{artifact:t.artifact},...t.modelContent!==void 0&&{modelContent:t.modelContent}})}catch(n){console.error("[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed",n)}},onStatusesChange:t=>{this._store.setToolStatuses?.(Object.fromEntries(t))}})),this._toolInvocations.setState({messages:this._messages,isRunning:this._store.isRunning??!1,...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_findMessageIdForToolCall(t){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();const n=r=>{for(const s of r)if(Array.isArray(s.content))for(const i of s.content)!i||i.type!=="tool-call"||(this._toolCallToMessageId.set(i.toolCallId,s.id),i.messages&&n(i.messages))};n(this._messages),this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(t)}switchToBranch(t){if(!this._store.setMessages)throw new Error("Runtime does not support switching branches.");this._store.isRunning||(this.repository.switchToBranch(t),this.updateMessages(this.repository.getMessages()))}async append(t){if((t.startRun??t.role==="user")&&await this._toolInvocations?.abort(),t.parentId!==(this.messages.at(-1)?.id??null)){if(!this._store.onEdit)throw new Error("Runtime does not support editing messages.");await this._store.onEdit(t)}else await this._store.onNew(t)}async startRun(t){if(!this._store.onReload)throw new Error("Runtime does not support reloading messages.");await this._toolInvocations?.abort(),await this._store.onReload(t.parentId,t)}async resumeRun(t){if(!this._store.onResume)throw new Error("Runtime does not support resuming runs.");await this._store.onResume(t)}exportExternalState(){if(!this._store.onExportExternalState)throw new Error("Runtime does not support exporting external states.");return this._store.onExportExternalState()}importExternalState(t){if(!this._store.onLoadExternalState)throw new Error("Runtime does not support importing external states.");this._toolInvocations&&(this._toolInvocations.reset(),this._store.setToolStatuses?.({})),this._store.onLoadExternalState(t)}cancelRun(){if(!this._store.onCancel)throw new Error("Runtime does not support cancelling runs.");this._toolInvocations?.abort(),this._store.onCancel();const t=this.repository.getMessages().at(-1);t&&t.metadata.isOptimistic&&t.content.length===0&&this.repository.deleteMessage(t.id);let n=this.repository.getMessages();const r=n[n.length-1];r?.role==="user"&&r.id===n.at(-1)?.id?(this.repository.deleteMessage(r.id),this.composer.text.trim()||this.composer.setText(bi(r)),n=this.repository.getMessages()):this._notifySubscribers(),setTimeout(()=>{this.updateMessages(n)},0)}addToolResult(t){if(!this._store.onAddToolResult)throw new Error("Runtime does not support tool results.");this._store.onAddToolResult?.(t)}resumeToolCall(t){if(!(this._toolInvocations?.resume(t.toolCallId,t.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(t);return}throw new Error(`Tool call ${t.toolCallId} is not waiting for resume.`)}}respondToToolApproval(t){if(!this._store.onRespondToToolApproval)throw new Error("Runtime does not support tool approvals.");this._store.onRespondToToolApproval(t)}reset(t){const n=new wd;n.import(zv.fromArray(t??[])),this.updateMessages(n.getMessages())}import(t){super.import(t),this._store.onImport&&this._store.onImport(this.repository.getMessages())}};const zh=e=>e.adapters?.threadList??{};var x1=class extends Ov{constructor(t){super();T(this,"threads");this.threads=new t1(zh(t),()=>new v1(this._contextProvider,t))}setAdapter(t){this.threads.__internal_setAdapter(zh(t)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(t)}};const Fa=e=>{const[t]=m.useState(()=>new x1(e));m.useEffect(()=>{t.setAdapter(e)});const{modelContext:n}=Q_()??{};return m.useEffect(()=>{if(n)return t.registerModelContextProvider(n)},[n,t]),m.useMemo(()=>new Lv(t),[t])},$v=(e,t)=>e.Message===t.Message&&e.EditComposer===t.EditComposer&&e.UserEditComposer===t.UserEditComposer&&e.AssistantEditComposer===t.AssistantEditComposer&&e.SystemEditComposer===t.SystemEditComposer&&e.UserMessage===t.UserMessage&&e.AssistantMessage===t.AssistantMessage&&e.SystemMessage===t.SystemMessage,w1=()=>null,b1=(e,t,n)=>{switch(t){case"user":return n?e.UserEditComposer??e.EditComposer??e.UserMessage??e.Message:e.UserMessage??e.Message;case"assistant":return n?e.AssistantEditComposer??e.EditComposer??e.AssistantMessage??e.Message:e.AssistantMessage??e.Message;case"system":return n?e.SystemEditComposer??e.EditComposer??e.SystemMessage??e.Message:e.SystemMessage??e.Message??w1;default:throw new Error(`Unknown message role: ${t}`)}},Uv=({components:e})=>c.jsx(b1(e,V(t=>t.message.role),V(t=>t.message.composer.isEditing)),{}),Vv=m.memo(({index:e,components:t})=>c.jsx(Tv,{index:e,children:c.jsx(Uv,{components:t})}),(e,t)=>e.index===t.index&&$v(e.components,t.components));Vv.displayName="ThreadPrimitive.MessageByIndex";const Fh=({children:e})=>{const t=V(n=>n.thread.messages.length);return m.useMemo(()=>t===0?null:Array.from({length:t},(n,r)=>c.jsx(Tv,{index:r,children:c.jsx(fs,{getItemState:s=>s.thread().message({index:r}).getState(),children:s=>e({get message(){return s()}})})},r)),[t,e])},Hv=({components:e,children:t})=>e?c.jsx(Fh,{children:()=>c.jsx(Uv,{components:e})}):c.jsx(Fh,{children:t});Hv.displayName="ThreadPrimitive.Messages";const S1=m.memo(Hv,(e,t)=>e.children||t.children?e.children===t.children:$v(e.components,t.components)),Wv=e=>{const t=e.message.metadata;if(!(!t||typeof t!="object"))return t.custom?.quote};var k1=class extends Error{constructor(t,n=`Component "${t}" is not in the generative-ui allowlist.`){super(n);T(this,"componentName");this.name="GenerativeUIRenderError",this.componentName=t}};const C1=e=>typeof e=="object"&&e!==null,qv=(e,t,n,r)=>{if(e==null)return null;if(typeof e=="string")return e;if(!C1(e)||!("component"in e))return null;const{component:s,props:i,children:o,key:a}=e,l=t[s];if(!l){if(n)return c.jsx(n,{component:s,props:i},a??r);throw new k1(s)}const u=o?.length?o.map((f,d)=>qv(f,t,n,`${r}/${d}`)):void 0;return m.createElement(l,{...i??{},key:a??r},...u??[])},_1=e=>{if(!e||e.root===void 0||e.root===null)return[];const t=e.root;return Array.isArray(t)?t:[t]},bd=({spec:e,components:t,Fallback:n})=>c.jsx(c.Fragment,{children:m.useMemo(()=>_1(e),[e]).map((r,s)=>qv(r,t,n,`${s}`))});bd.displayName="GenerativeUIRender";const Kv=({components:e,spec:t,Fallback:n})=>{const r=V(i=>{const o=i.part;return o?.type==="generative-ui"?o.spec:void 0}),s=t??r;return s?c.jsx(bd,{spec:s,components:e,Fallback:n}):null};Kv.displayName="MessagePrimitive.GenerativeUI";const E1="ui://",T1=e=>!!e?.startsWith(E1),Bh=e=>Symbol.iterator in e,$h=e=>"entries"in e,Uh=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(const[s,i]of n)if(!r.has(s)||!Object.is(i,r.get(s)))return!1;return!0},I1=(e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let s=n.next(),i=r.next();for(;!s.done&&!i.done;){if(!Object.is(s.value,i.value))return!1;s=n.next(),i=r.next()}return!!s.done&&!!i.done};function R1(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Bh(e)&&Bh(t)?$h(e)&&$h(t)?Uh(e,t):I1(e,t):Uh({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function Gv(e){const t=ut.useRef(void 0);return n=>{const r=e(n);return R1(t.current,r)?t.current:t.current=r}}const Rl=e=>{let t=-1;return{startGroup:n=>{t===-1&&(t=n)},endGroup:(n,r)=>{t!==-1&&(r.push({type:e,startIndex:t,endIndex:n}),t=-1)},finalize:(n,r)=>{t!==-1&&r.push({type:e,startIndex:t,endIndex:n})}}},P1=(e,t)=>{const n=[];if(t){const r=Rl("chainOfThoughtGroup");for(let s=0;s<e.length;s++){const i=e[s];i==="tool-call"||i==="reasoning"?r.startGroup(s):(r.endGroup(s-1,n),n.push({type:"single",index:s}))}r.finalize(e.length-1,n)}else{const r=Rl("toolGroup"),s=Rl("reasoningGroup");for(let i=0;i<e.length;i++){const o=e[i];o==="tool-call"?(s.endGroup(i-1,n),r.startGroup(i)):o==="reasoning"?(r.endGroup(i-1,n),s.startGroup(i)):(r.endGroup(i-1,n),s.endGroup(i-1,n),n.push({type:"single",index:i}))}r.finalize(e.length-1,n),s.finalize(e.length-1,n)}return n},A1=e=>{const t=V(Gv(n=>n.message.parts.map(r=>r.type)));return m.useMemo(()=>t.length===0?[]:P1(t,e),[t,e])},j1=({Fallback:e,...t})=>{const n=V(r=>r.tools.toolUIs[t.toolName]?.[0]?.render??e);return n?c.jsx(n,{...t}):null},Sd=(e,t,n)=>{const r=e.renderers[t]?.[0];return r||(e.fallbacks[0]??n)},N1=({Fallback:e,...t})=>{const n=V(r=>Sd(r.dataRenderers,t.name,e));return n?c.jsx(n,{...t}):null},Ye={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},M1=({components:{Text:e=Ye.Text,Reasoning:t=Ye.Reasoning,Image:n=Ye.Image,Source:r=Ye.Source,File:s=Ye.File,Unstable_Audio:i=Ye.Unstable_Audio,tools:o={},data:a,generativeUI:l}={}})=>{const u=se(),f=V(h=>h.part),d=f.type;if(d==="tool-call"){const h=u.part().addToolResult,p=u.part().resumeToolCall,g=u.part().respondToToolApproval;if("Override"in o)return c.jsx(o.Override,{...f,addResult:h,resume:p,respondToApproval:g});const v=o.by_name?.[f.toolName]??o.Fallback;return c.jsx(j1,{...f,Fallback:v,addResult:h,resume:p,respondToApproval:g})}if(f.status?.type==="requires-action")throw new Error("Encountered unexpected requires-action status");switch(d){case"text":return c.jsx(e,{...f});case"reasoning":return c.jsx(t,{...f});case"source":return c.jsx(r,{...f});case"image":return c.jsx(n,{...f});case"file":return c.jsx(s,{...f});case"audio":return c.jsx(i,{...f});case"data":{const h=a?.by_name?.[f.name]??a?.Fallback;return c.jsx(N1,{...f,Fallback:h})}case"generative-ui":return l?.components?c.jsx(bd,{spec:f.spec,components:l.components,Fallback:l.Fallback}):null;default:return console.warn(`Unknown message part type: ${d}`),null}},Ys=m.memo(({index:e,components:t})=>c.jsx(yd,{index:e,children:c.jsx(M1,{components:t})}),(e,t)=>e.index===t.index&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.generativeUI===t.components?.generativeUI&&e.components?.ToolGroup===t.components?.ToolGroup&&e.components?.ReasoningGroup===t.components?.ReasoningGroup);Ys.displayName="MessagePrimitive.PartByIndex";const D1=({status:e,component:t})=>c.jsx(vd,{text:"",isRunning:e.type==="running",children:c.jsx(t,{type:"text",text:"",status:e})}),L1=Object.freeze({type:"complete"}),O1=Object.freeze({type:"running"}),z1=({components:e})=>{const t=V(n=>n.message.status??L1);return e?.Empty?c.jsx(e.Empty,{status:t}):t.type!=="running"?null:c.jsx(D1,{status:t,component:e?.Text??Ye.Text})},Qv=m.memo(z1,(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),F1=({components:e,enabled:t})=>V(n=>{if(!t||n.message.parts.length===0)return!1;const r=n.message.parts[n.message.parts.length-1];return r?.type!=="text"&&r?.type!=="reasoning"})?c.jsx(Qv,{components:e}):null,B1=m.memo(F1,(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),$1=({Quote:e})=>{const t=V(Wv);return t?c.jsx(e,{text:t.text,messageId:t.messageId}):null},U1=m.memo($1);function Yv(e,t){const n=e.toolUIs[t.toolName]?.[0]?.render??null;return n||(T1(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}const Jv=()=>{const e=se(),t=V(r=>r.part),n=V(r=>r.part.type==="tool-call"?Yv(r.tools,r.part):null);return!n||t.type!=="tool-call"?null:c.jsx(n,{...t,addResult:e.part().addToolResult,resume:e.part().resumeToolCall,respondToApproval:e.part().respondToToolApproval})},Xv=()=>{const e=V(n=>n.part),t=V(n=>n.part.type==="data"?Sd(n.dataRenderers,n.part.name,void 0)??null:null);return!t||e.type!=="data"?null:c.jsx(t,{...e})},V1=()=>{const e=V(t=>t.part.type);return e==="tool-call"?c.jsx(Jv,{}):e==="data"?c.jsx(Xv,{}):null},H1=Object.freeze({type:"text",text:"",status:O1}),Zv=({index:e,children:t})=>{const n=se(),r=V(s=>s.dataRenderers);return c.jsx(yd,{index:e,children:c.jsx(fs,{getItemState:s=>s.message().part({index:e}).getState(),children:s=>t({get part(){const i=s();if(i.type==="tool-call"){const o=Yv(n.tools().getState(),i)!==null,a=n.message().part({index:e});return{...i,toolUI:o?c.jsx(Jv,{}):null,addResult:a.addToolResult,resume:a.resumeToolCall,respondToApproval:a.respondToToolApproval}}if(i.type==="data"){const o=Sd(r,i.name,void 0)!==void 0;return{...i,dataRendererUI:o?c.jsx(Xv,{}):null}}return i}})})})},W1=({children:e})=>{const t=V(s=>s.message.parts.length),n=V(s=>(s.message.status?.type??"complete")==="running"),r=t===0&&n;return t===0?r?c.jsx(vd,{text:"",isRunning:!0,children:e({part:H1})}):null:c.jsx(c.Fragment,{children:Array.from({length:t},(s,i)=>c.jsx(Zv,{index:i,children:o=>e(o)??c.jsx(V1,{})},i))})},Ju=({components:e,unstable_showEmptyOnNonTextEnd:t=!0,children:n})=>n?c.jsx(W1,{children:n}):c.jsx(q1,{components:e,unstable_showEmptyOnNonTextEnd:t});Ju.displayName="MessagePrimitive.Parts";const q1=({components:e,unstable_showEmptyOnNonTextEnd:t})=>{const n=V(i=>i.message.parts.length),r=A1(!!e?.ChainOfThought),s=m.useMemo(()=>n===0?c.jsx(Qv,{components:e}):r.map(i=>{if(i.type==="single")return c.jsx(Ys,{index:i.index,components:e},i.index);if(i.type==="chainOfThoughtGroup"){const o=e?.ChainOfThought;return o?c.jsx(I_,{startIndex:i.startIndex,endIndex:i.endIndex,children:c.jsx(o,{})},`chainOfThought-${i.startIndex}`):null}else return i.type==="toolGroup"?c.jsx(e?.ToolGroup??Ye.ToolGroup,{startIndex:i.startIndex,endIndex:i.endIndex,children:Array.from({length:i.endIndex-i.startIndex+1},(o,a)=>{const l=i.startIndex+a;return c.jsx(Ys,{index:l,components:e},`part-${l}`)})},`tool-${i.startIndex}`):c.jsx(e?.ReasoningGroup??Ye.ReasoningGroup,{startIndex:i.startIndex,endIndex:i.endIndex,children:Array.from({length:i.endIndex-i.startIndex+1},(o,a)=>{const l=i.startIndex+a;return c.jsx(Ys,{index:l,components:e},`part-${l}`)})},`reasoning-${i.startIndex}`)}),[r,e,n]);return c.jsxs(c.Fragment,{children:[e?.Quote&&c.jsx(U1,{Quote:e.Quote}),s,c.jsx(B1,{components:e,enabled:t})]})},K1=Symbol.for("@assistant-ui/groupBy.memoKey"),Vh=e=>{const t=e.nextChildIdx++;return e.nodeKey===""?String(t):`${e.nodeKey}.${t}`},G1=e=>{const t={key:"",nodeKey:"",indices:[],children:[],nextChildIdx:0},n=[t],r=()=>{const s=n.pop();n[n.length-1].children.push({type:"group",key:s.key,nodeKey:s.nodeKey,indices:s.indices,children:s.children})};for(let s=0;s<e.length;s++){const i=e[s];let o=0;for(;o<n.length-1&&o<i.length&&n[o+1].key===i[o];)o++;for(;n.length-1>o;)r();for(;n.length-1<i.length;){const l=n[n.length-1];n.push({key:i[n.length-1],nodeKey:Vh(l),indices:[],children:[],nextChildIdx:0})}const a=n[n.length-1];a.children.push({type:"part",index:s,nodeKey:Vh(a)});for(let l=1;l<n.length;l++)n[l].indices.push(s)}for(;n.length>1;)r();return t.children},Q1=Object.freeze({type:"complete"}),Y1=(e,t,n)=>{if(!n)return!1;switch(e){case"never":return!1;case"always":return!0;case"empty":return t.length===0;case"no-text":{const r=t[t.length-1];return r!==void 0&&r.type!=="text"&&r.type!=="reasoning"}}},ex=()=>{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.")},tx=(e,t,n)=>{if(e.type==="part")return c.jsx(Zv,{index:e.index,children:({part:s})=>n({part:s,children:c.jsx(ex,{})})},`part-${e.index}`);const r=t[e.indices.at(-1)]?.status??Q1;return c.jsx(m.Fragment,{children:n({part:{type:e.key,status:r,indices:e.indices},children:c.jsx(c.Fragment,{children:e.children.map(s=>tx(s,t,n))})})},e.nodeKey)},nx=({groupBy:e,indicator:t="no-text",children:n})=>{const r=V(Gv(o=>o.message.parts)),s=V(o=>o.tools.toolUIs),i=V(o=>t==="never"?!1:o.message.status?.type==="running");return c.jsxs(c.Fragment,{children:[m.useMemo(()=>{const o={toolUIs:s};return G1(r.map(a=>e(a,o)??[]))},[r,e[K1]??e,s]).map(o=>tx(o,r,n)),Y1(t,r,i)&&n({part:{type:"indicator"},children:c.jsx(ex,{})})]})};nx.displayName="MessagePrimitive.GroupedParts";const J1=({children:e})=>{const t=V(Wv);return t?c.jsx(c.Fragment,{children:e(t)}):null},rx=m.memo(J1);rx.displayName="MessagePrimitive.Quote";const sx=(e,t)=>{switch(t.type){case"image":return e?.Image??e?.Attachment;case"document":return e?.Document??e?.Attachment;case"file":return e?.File??e?.Attachment;default:return e?.Attachment}},X1=({components:e})=>{const t=V(r=>r.attachment);if(!t)return null;const n=sx(e,t);return n?c.jsx(n,{}):null},ix=m.memo(({index:e,components:t})=>c.jsx(_v,{index:e,children:c.jsx(X1,{components:t})}),(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);ix.displayName="MessagePrimitive.AttachmentByIndex";const Hh=({children:e})=>{const t=V(n=>n.message.role!=="user"?0:(n.message.attachments??[]).length);return m.useMemo(()=>Array.from({length:t},(n,r)=>c.jsx(_v,{index:r,children:c.jsx(fs,{getItemState:s=>s.message().attachment({index:r}).getState(),children:s=>e({get attachment(){return s()}})})},r)),[t,e])},ox=({components:e,children:t})=>e?c.jsx(Hh,{children:({attachment:n})=>{const r=sx(e,n);return r?c.jsx(r,{}):null}}):c.jsx(Hh,{children:t});ox.displayName="MessagePrimitive.Attachments";const ax=(e,t)=>{switch(t.type){case"image":return e?.Image??e?.Attachment;case"document":return e?.Document??e?.Attachment;case"file":return e?.File??e?.Attachment;default:return e?.Attachment}},Z1=({components:e})=>{const t=V(r=>r.attachment);if(!t)return null;const n=ax(e,t);return n?c.jsx(n,{}):null},lx=m.memo(({index:e,components:t})=>c.jsx(Ev,{index:e,children:c.jsx(Z1,{components:t})}),(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);lx.displayName="ComposerPrimitive.AttachmentByIndex";const Wh=({children:e})=>{const t=V(n=>n.composer.attachments.length);return m.useMemo(()=>Array.from({length:t},(n,r)=>c.jsx(Ev,{index:r,children:c.jsx(fs,{getItemState:s=>s.composer().attachment({index:r}).getState(),children:s=>e({get attachment(){return s()}})})},r)),[t,e])},ux=({components:e,children:t})=>e?c.jsx(Wh,{children:({attachment:n})=>{const r=ax(e,n);return r?c.jsx(r,{}):null}}):c.jsx(Wh,{children:t});ux.displayName="ComposerPrimitive.Attachments";const eE=({children:e})=>{const t=V(n=>n.composer.queue.length);return m.useMemo(()=>Array.from({length:t},(n,r)=>c.jsx(R_,{index:r,children:c.jsx(fs,{getItemState:s=>s.composer().queueItem({index:r}).getState(),children:s=>e({get queueItem(){return s()}})})},r)),[t,e])},cx=m.memo(eE);cx.displayName="ComposerPrimitive.Queue";const kd=({children:e})=>V(t=>t.part.status.type==="running")?e:null;kd.displayName="MessagePartPrimitive.InProgress";const dx=({components:e})=>{const t=e.Suggestion;return c.jsx(t,{})},fx=m.memo(({index:e,components:t})=>c.jsx(Iv,{index:e,children:c.jsx(dx,{components:t})}),(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);fx.displayName="ThreadPrimitive.SuggestionByIndex";const qh=({children:e})=>{const t=V(n=>n.suggestions.suggestions.length);return m.useMemo(()=>t===0?null:Array.from({length:t},(n,r)=>c.jsx(Iv,{index:r,children:c.jsx(fs,{getItemState:s=>s.suggestions().suggestion({index:r}).getState(),children:s=>e({get suggestion(){return s()}})})},r)),[t,e])},hx=({components:e,children:t})=>e?c.jsx(qh,{children:()=>c.jsx(dx,{components:e})}):c.jsx(qh,{children:t});hx.displayName="ThreadPrimitive.Suggestions";const tE=m.memo(hx,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),nE=e=>V(t=>{if(e.editing===!0&&!t.composer.isEditing||e.editing===!1&&t.composer.isEditing)return!1;const n=t.composer.dictation!=null;return!(e.dictation===!0&&!n||e.dictation===!1&&n)}),px=({children:e,...t})=>nE(t)?e:null;px.displayName="ComposerPrimitive.If";const rE=()=>{const e=se(),t=V(n=>!n.composer.canSend||n.thread.isRunning&&!n.thread.capabilities.queue);return{send:m.useCallback(n=>{e.composer().send(n)},[e]),disabled:t}},sE=()=>{const e=se(),t=V(n=>!n.composer.canCancel);return{cancel:m.useCallback(()=>{e.composer().cancel()},[e]),disabled:t}},iE=()=>{const e=se(),t=V(n=>n.composer.dictation!=null||!n.thread.capabilities.dictation||!n.composer.isEditing);return{startDictation:m.useCallback(()=>{e.composer().startDictation()},[e]),disabled:t}},oE=()=>{const e=se(),t=V(n=>!n.composer.isEditing);return{addAttachment:m.useCallback(n=>e.composer().addAttachment(n),[e]),disabled:t}},aE=({copiedDuration:e=3e3,copyToClipboard:t}={})=>{const n=se(),r=V(a=>!((a.message.role!=="assistant"||a.message.status?.type!=="running")&&a.message.parts.some(l=>l.type==="text"&&l.text.length>0))),s=V(a=>a.message.isCopied),i=V(a=>a.composer.isEditing),o=V(a=>a.composer.text);return{copy:m.useCallback(()=>{const a=i?o:n.message().getCopyText();if(!a)return;const l=t??(()=>{});Promise.resolve(l(a)).then(()=>{n.message().setIsCopied(!0),setTimeout(()=>n.message().setIsCopied(!1),e)},()=>{})},[n,i,o,e,t]),disabled:r,isCopied:s}},lE=()=>{const e=se(),t=V(n=>n.composer.isEditing);return{edit:m.useCallback(()=>{e.composer().beginEdit()},[e]),disabled:t}},uE=()=>{const e=se(),t=V(n=>n.thread.isRunning||n.thread.isDisabled||n.message.role!=="assistant");return{reload:m.useCallback(()=>{e.message().reload()},[e]),disabled:t}},cE=()=>{const e=se(),t=V(n=>n.message.metadata.submittedFeedback?.type==="positive");return{submit:m.useCallback(()=>{e.message().submitFeedback({type:"positive"})},[e]),isSubmitted:t}},dE=()=>{const e=se(),t=V(n=>n.message.metadata.submittedFeedback?.type==="negative");return{submit:m.useCallback(()=>{e.message().submitFeedback({type:"negative"})},[e]),isSubmitted:t}},fE=()=>{const e=se(),t=V(n=>!((n.message.role!=="assistant"||n.message.status?.type!=="running")&&n.message.parts.some(r=>r.type==="text"&&r.text.length>0)));return{speak:m.useCallback(async()=>{e.message().speak()},[e]),disabled:t}},hE=()=>{const e=se(),t=V(n=>n.message.speech==null);return{stopSpeaking:m.useCallback(()=>{e.message().stopSpeaking()},[e]),disabled:t}},pE=({prompt:e,send:t,clearComposer:n=!0})=>{const r=se(),s=V(o=>o.thread.isDisabled),i=t??!1;return{trigger:m.useCallback(()=>{const o=r.thread().getState().isRunning;if(i&&!o)r.thread().append({content:[{type:"text",text:e}],runConfig:r.composer().getState().runConfig}),n&&r.composer().setText("");else if(n)r.composer().setText(e);else{const a=r.composer().getState().text;r.composer().setText(a.trim()?`${a} ${e}`:e)}},[r,i,n,e]),disabled:s}},mE=()=>V(e=>e.message.status?.type==="incomplete"&&e.message.status.reason==="error"?e.message.status.error??"An error occurred":void 0),gE=e=>{const{cloud:t,initialMessages:n,maxSteps:r,adapters:s,unstable_humanToolNames:i,...o}=e;return{localRuntimeOptions:{cloud:t,initialMessages:n,maxSteps:r,adapters:s,unstable_humanToolNames:i},otherOptions:o}},yE=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,mx={serialize(e){const t=e.id!==e.label?`{name=${e.id}}`:"";return`:${e.type}[${e.label}]${t}`},parse(e){const t=[];let n=0;for(const r of e.matchAll(yE)){r.index>n&&t.push({kind:"text",text:e.slice(n,r.index)});const s=r[2];t.push({kind:"mention",type:r[1],label:s,id:r[3]??s}),n=r.index+r[0].length}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}};function vE(e,t){function n(r){const s=m.useContext(e);if(!r?.optional&&!s)throw new Error(`This component must be used within ${t}.`);return s}return n}function gx(e,t){function n(s){const i=e(s);return i?i[t]: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{[t]:r,[`${t}Store`]:n}}const yx=m.createContext(null),{useThreadViewport:wr,useThreadViewportStore:br}=gx(vE(yx,"ThreadPrimitive.Viewport"),"useThreadViewport"),Kh=e=>{const t=new Map,n=()=>{let r=0;for(const s of t.values())r+=s;e(r)};return{register:()=>{const r=Symbol();return t.set(r,0),{setHeight:s=>{t.get(r)!==s&&(t.set(r,s),n())},unregister:()=>{t.delete(r),n()}}}}},xE=(e={})=>{const t=new Set,n=Kh(o=>{i.setState({height:{...i.getState().height,viewport:o}})}),r=Kh(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=gv(()=>({isAtBottom:!0,scrollToBottom:({behavior:o="auto"}={})=>{for(const a of t)a({behavior:o})},onScrollToBottom:o=>(t.add(o),()=>{t.delete(o)}),turnAnchor:e.turnAnchor??"bottom",topAnchorMessageClamp:{tallerThan:e.topAnchorMessageClamp?.tallerThan??"10em",visibleHeight:e.topAnchorMessageClamp?.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:o=>s("viewport",o),registerAnchorElement:o=>s("anchor",o),registerAnchorTargetElement:(o,a)=>(i.setState({element:{...i.getState().element,target:o},targetConfig:o&&a?a:null}),()=>{i.getState().element.target===o&&i.setState({element:{...i.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:o=>{i.setState({topAnchorTurn:o})}}));return i},ia=e=>e,wE=e=>{const t=br({optional:!0}),[n]=m.useState(()=>xE(e));return m.useEffect(()=>t?.getState().onScrollToBottom(()=>{n.getState().scrollToBottom()}),[t,n]),m.useEffect(()=>{if(t)return n.subscribe(r=>{t.getState().isAtBottom!==r.isAtBottom&&ia(t).setState({isAtBottom:r.isAtBottom})})},[n,t]),n},Cd=({children:e,options:t={}})=>{const n=wE(t),[r]=m.useState(()=>({useThreadViewport:n}));return c.jsx(yx.Provider,{value:r,children:e})},bE=()=>{const e=se();return m.useEffect(()=>{},[e]),null},SE=({children:e,aui:t,runtime:n})=>c.jsxs(q0,{runtime:n,aui:t??null,children:[c.jsx(bE,{}),c.jsx(Cd,{children:e})]}),Ba=m.memo(SE),kE=e=>{const t=e;t.__isBound||(t.__internal_bindMethods?.(),t.__isBound=!0)};function CE(e,t=_E){kE(e);const n=m.useSyncExternalStore(e.subscribe,()=>t(e.getState()),()=>t(e.getState()));return m.useDebugValue(n),n}const _E=e=>e;function EE(e){function t(n){let r=!1,s;typeof n=="function"?s=n:n&&(r=!!n.optional,s=n.selector);const i=e({optional:r});return i?CE(i,s):null}return t}function TE(e){const t=se(),n=V(()=>t.composer.source?t.composer().__internal_getRuntime?.()??null:null);if(!n&&!e?.optional)throw new Error("ComposerRuntime is not available");return n}function IE(e){const t=se(),n=V(()=>t.message.source?t.message().__internal_getRuntime?.()??null:null);if(!n&&!e?.optional)throw new Error("MessageRuntime is not available");return n}const oa=EE(IE);function Gh(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function RE(...e){return t=>{let n=!1;const r=e.map(s=>{const i=Gh(s,t);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():Gh(e[s],null)}}}}function Sr(...e){return m.useCallback(RE(...e),e)}var Qh=Object.defineProperty,ms=(e,t)=>{let n={};for(var r in e)Qh(n,r,{get:e[r],enumerable:!0});return Qh(n,Symbol.toStringTag,{value:"Module"}),n};function vx(e){const t=m.forwardRef((n,r)=>{let{children:s,...i}=n,o=null,a=!1;const l=[];Yh(s)&&typeof ro=="function"&&(s=ro(s._payload)),m.Children.forEach(s,h=>{if(ME(h)){a=!0;const p=h;let g="child"in p.props?p.props.child:p.props.children;Yh(g)&&typeof ro=="function"&&(g=ro(g._payload)),o=AE(p,g),l.push(o?.props?.children)}else l.push(h)}),o?o=m.cloneElement(o,void 0,l):!a&&m.Children.count(s)===1&&m.isValidElement(s)&&(o=s);const u=o?NE(o):void 0,f=Sr(r,u);if(!o){if(s||s===0)throw new Error(a?zE(e):OE(e));return s}const d=jE(i,o.props??{});return o.type!==m.Fragment&&(d.ref=r?f:u),m.cloneElement(o,d)});return t.displayName=`${e}.Slot`,t}var aa=vx("Slot"),PE=Symbol.for("radix.slottable"),AE=(e,t)=>{if("child"in e.props){const n=e.props.child;return m.isValidElement(n)?m.cloneElement(n,void 0,e.props.children(n.props.children)):null}return m.isValidElement(t)?t:null};function jE(e,t){const n={...t};for(const r in t){const s=e[r],i=t[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{...e,...n}}function NE(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function ME(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===PE}var DE=Symbol.for("react.lazy");function Yh(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===DE&&"_payload"in e&&LE(e._payload)}function LE(e){return typeof e=="object"&&e!==null&&"then"in e}var OE=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,zE=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,ro=gS[" use ".trim().toString()],FE=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],BE=FE.reduce((e,t)=>{const n=vx(`Primitive.${t}`),r=m.forwardRef((s,i)=>{const{asChild:o,...a}=s,l=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});const $E=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"];function UE(e){const t=m.forwardRef(({render:n,asChild:r,children:s,...i},o)=>{const a=e;if(n&&m.isValidElement(n)){const l=s!==void 0?s:n.props.children;return c.jsx(a,{...i,asChild:!0,ref:o,children:m.cloneElement(n,void 0,l)})}return c.jsx(a,{...i,asChild:r,ref:o,children:s})});return t.displayName=typeof e=="string"?e:e.displayName??e.name??"Component",t}function VE(e){const t=BE[e],n=UE(t);return n.displayName=`Primitive.${e}`,n}const be=$E.reduce((e,t)=>(e[t]=VE(t),e),{}),HE=({hideWhenRunning:e,autohide:t,autohideFloat:n,forceVisible:r})=>V(s=>{if(e&&s.thread.isRunning)return"hidden";const i=t==="always"||t==="not-last"&&!s.message.isLast,o=r||s.message.isHovering;return i?o?n==="always"||n==="single-branch"&&s.message.branchCount<=1?"floating":"normal":"hidden":"normal"}),WE=m.createContext(null),xx=m.forwardRef(({hideWhenRunning:e,autohide:t,autohideFloat:n,...r},s)=>{const[i,o]=m.useState(0),a=m.useCallback(()=>{let f=!1;return o(d=>d+1),()=>{f||(f=!0,o(d=>Math.max(0,d-1)))}},[]),l=m.useMemo(()=>({acquireInteractionLock:a}),[a]),u=HE({hideWhenRunning:e,autohide:t,autohideFloat:n,forceVisible:i>0});return u==="hidden"?null:c.jsx(WE.Provider,{value:l,children:c.jsx(be.div,{...u==="floating"?{"data-floating":"true"}:null,...r,ref:s})})});xx.displayName="ActionBarPrimitive.Root";function Te(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e?.(s),n===!1||!s.defaultPrevented)return t?.(s)}}const qE=({copiedDuration:e=3e3}={})=>{const{copy:t,disabled:n}=aE({copiedDuration:e,copyToClipboard:r=>typeof navigator>"u"||!navigator.clipboard?Promise.reject(new Error("Clipboard API is unavailable")):navigator.clipboard.writeText(r)});return n?null:t},wx=m.forwardRef(({copiedDuration:e,onClick:t,disabled:n,...r},s)=>{const i=V(a=>a.message.isCopied),o=qE({copiedDuration:e});return c.jsx(be.button,{type:"button",...i?{"data-copied":"true"}:{},...r,ref:s,disabled:n||!o,onClick:Te(t,()=>{o?.()})})});wx.displayName="ActionBarPrimitive.Copy";const Wt=(e,t,n=[])=>{const r=m.forwardRef((s,i)=>{const o={},a={};Object.keys(s).forEach(u=>{n.includes(u)?o[u]=s[u]:a[u]=s[u]});const l=t(o)??void 0;return c.jsx(be.button,{...a,type:"button",ref:i,disabled:a.disabled||!l,onClick:Te(a.onClick,l)})});return r.displayName=e,r},KE=()=>{const{disabled:e,reload:t}=uE();return e?null:t},GE=Wt("ActionBarPrimitive.Reload",KE),QE=()=>{const{disabled:e,edit:t}=lE();return e?null:t},YE=Wt("ActionBarPrimitive.Edit",QE),JE=()=>{const{disabled:e,speak:t}=fE();return e?null:t},XE=Wt("ActionBarPrimitive.Speak",JE);function mr(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>t.current?.(...n),[])}function bx(e,t=globalThis?.document){const n=mr(e);m.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}const ZE=()=>{const{disabled:e,stopSpeaking:t}=hE();return e?null:t},Sx=m.forwardRef((e,t)=>{const n=ZE();return bx(r=>{n&&(r.preventDefault(),n())}),c.jsx(be.button,{type:"button",disabled:!n,...e,ref:t,onClick:Te(e.onClick,()=>{n?.()})})});Sx.displayName="ActionBarPrimitive.StopSpeaking";const eT=()=>{const{submit:e}=cE();return e},kx=m.forwardRef(({onClick:e,disabled:t,...n},r)=>{const s=V(o=>o.message.metadata.submittedFeedback?.type==="positive"),i=eT();return c.jsx(be.button,{type:"button",...s?{"data-submitted":"true"}:{},...n,ref:r,disabled:t||!i,onClick:Te(e,()=>{i?.()})})});kx.displayName="ActionBarPrimitive.FeedbackPositive";const tT=()=>{const{submit:e}=dE();return e},Cx=m.forwardRef(({onClick:e,disabled:t,...n},r)=>{const s=V(o=>o.message.metadata.submittedFeedback?.type==="negative"),i=tT();return c.jsx(be.button,{type:"button",...s?{"data-submitted":"true"}:{},...n,ref:r,disabled:t||!i,onClick:Te(e,()=>{i?.()})})});Cx.displayName="ActionBarPrimitive.FeedbackNegative";const nT=({filename:e,onExport:t}={})=>{const n=se(),r=V(i=>(i.message.role!=="assistant"||i.message.status?.type!=="running")&&i.message.parts.some(o=>o.type==="text"&&o.text.length>0)),s=m.useCallback(async()=>{const i=n.message().getCopyText();if(!i)return;if(t){await t(i);return}const o=new Blob([i],{type:"text/markdown"}),a=URL.createObjectURL(o),l=document.createElement("a");l.href=a,l.download=e??`message-${Date.now()}.md`,l.click(),URL.revokeObjectURL(a)},[n,e,t]);return r?s:null},_x=m.forwardRef(({filename:e,onExport:t,onClick:n,disabled:r,...s},i)=>{const o=nT({filename:e,onExport:t});return c.jsx(be.button,{type:"button",...s,ref:i,disabled:r||!o,onClick:Te(n,()=>{o?.()})})});_x.displayName="ActionBarPrimitive.ExportMarkdown";var Jh=ms({Copy:()=>wx,Edit:()=>YE,ExportMarkdown:()=>_x,FeedbackNegative:()=>Cx,FeedbackPositive:()=>kx,Reload:()=>GE,Root:()=>xx,Speak:()=>XE,StopSpeaking:()=>Sx});const Ex=m.forwardRef((e,t)=>c.jsx(be.div,{...e,ref:t}));Ex.displayName="AttachmentPrimitive.Root";const Tx=m.forwardRef((e,t)=>{const n=V(r=>{const s=r.attachment.name.split(".");return s.length>1?s.pop():""});return c.jsxs(be.div,{...e,ref:t,children:[".",n]})});Tx.displayName="AttachmentPrimitive.unstable_Thumb";const Ix=()=>c.jsx(c.Fragment,{children:V(e=>e.attachment.name)});Ix.displayName="AttachmentPrimitive.Name";const rT=()=>{const e=se();return m.useCallback(()=>{e.attachment().remove()},[e])},sT=Wt("AttachmentPrimitive.Remove",rT);var Xh=ms({Name:()=>Ix,Remove:()=>sT,Root:()=>Ex,unstable_Thumb:()=>Tx});const iT=e=>V(t=>{const{role:n,attachments:r,parts:s,branchCount:i,isLast:o,speech:a,isCopied:l,isHovering:u}=t.message;return!(e.hasBranches===!0&&i<2||e.user&&n!=="user"||e.assistant&&n!=="assistant"||e.system&&n!=="system"||e.lastOrHover===!0&&!u&&!o||e.last!==void 0&&e.last!==o||e.copied===!0&&!l||e.copied===!1&&l||e.speaking===!0&&a==null||e.speaking===!1&&a!=null||e.hasAttachments===!0&&(n!=="user"||!r?.length)||e.hasAttachments===!1&&n==="user"&&r?.length||e.hasContent===!0&&s.length===0||e.hasContent===!1&&s.length>0||e.submittedFeedback!==void 0&&(t.message.metadata.submittedFeedback?.type??null)!==e.submittedFeedback)}),Rx=({children:e,...t})=>iT(t)?e:null;Rx.displayName="MessagePrimitive.If";const Px=m.createContext(null),$a=()=>m.useContext(Px),oT=({children:e})=>{const t=m.useRef(new Map),n=m.useRef([]),r=m.useCallback(()=>{const a=Array.from(t.current.entries());a.sort((l,u)=>u[1]-l[1]),n.current=a.map(([l])=>l)},[]),s=m.useCallback((a,l)=>{const u=l?.priority??0;return t.current.set(a,u),r(),()=>{t.current.delete(a),r()}},[r]),i=m.useCallback(()=>n.current,[]),o=m.useMemo(()=>({register:s,getPlugins:i}),[s,i]);return c.jsx(Px.Provider,{value:o,children:e})},_d=m.createContext(null),Ax=m.createContext(null),Ed=()=>{const e=m.useContext(_d);if(!e)throw new Error("useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot");return e},Td=()=>m.useContext(_d),aT=()=>{const e=m.useContext(Ax);if(!e)throw new Error("useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot");return e},lT=()=>{const e=Ed();return m.useSyncExternalStore(e.subscribe,e.getTriggers,e.getTriggers)},uT=new Map,jx=()=>()=>{},Zh=()=>uT,cT=()=>{const e=Td();return m.useSyncExternalStore(e?e.subscribe:jx,e?e.getTriggers:Zh,e?e.getTriggers:Zh)},ep=()=>null,dT=()=>{const e=Td();return m.useSyncExternalStore(e?e.subscribeAria:jx,e?e.getActiveAria:ep,e?e.getActiveAria:ep)};function tp(){const e=m.useRef(new Set);return{notify:m.useCallback(()=>{for(const t of e.current)t()},[]),subscribe:m.useCallback(t=>(e.current.add(t),()=>{e.current.delete(t)}),[])}}const np=({children:e})=>{const t=m.useRef(new Map),n=m.useRef(new Set),{notify:r,subscribe:s}=tp(),i=m.useCallback(S=>{const{char:y}=S;if(t.current.has(y))return()=>{};const x=new Map(t.current);x.set(y,S),t.current=x,r();for(const w of n.current)w.added(S);return()=>{const w=new Map(t.current);w.delete(y),t.current=w,r();for(const E of n.current)E.removed(y)}},[r]),o=m.useCallback(()=>t.current,[]),a=m.useCallback(S=>(n.current.add(S),()=>{n.current.delete(S)}),[]),l=m.useRef(null),u=m.useRef(null),{notify:f,subscribe:d}=tp(),h=m.useCallback((S,y)=>{if(y===null){if(u.current!==S)return;l.current=null,u.current=null,f();return}const x=l.current;u.current===S&&x!==null&&x.popoverId===y.popoverId&&x.highlightedItemId===y.highlightedItemId||(l.current=y,u.current=S,f())},[f]),p=m.useCallback(()=>l.current,[]),g=m.useMemo(()=>({register:i,getTriggers:o,subscribe:s,subscribeLifecycle:a,getActiveAria:p,subscribeAria:d}),[i,o,s,a,p,d]),v=m.useMemo(()=>({setActiveAria:h}),[h]);return c.jsx(_d.Provider,{value:g,children:c.jsx(Ax.Provider,{value:v,children:e})})},Nx=({children:e})=>$a()?c.jsx(np,{children:e}):c.jsx(oT,{children:c.jsx(np,{children:e})});Nx.displayName="ComposerPrimitive.TriggerPopoverRoot";const rp=/\s/u;function fT(e,t,n){const r=e.slice(0,n);for(let s=r.length-1;s>=0;s--){const i=r[s];if(rp.test(i))return null;if(r.startsWith(t,s)){if(s>0&&!rp.test(r[s-1]))continue;return{query:r.slice(s+t.length),offset:s}}}return null}const hT=ce(({text:e,triggerChar:t})=>{const[n,r]=kt(e.length),s=ie(()=>fT(e,t,Math.min(n,e.length)),[n,e,t]);return{trigger:s,query:s?.query??"",setCursorPosition:r}});function pT(e){return"type"in e}const mT=ce(({navigableList:e,isSearchMode:t,activeCategoryId:n,query:r,popoverId:s,open:i,selectItem:o,selectCategory:a,goBack:l,close:u})=>{const[f,d]=kt(0);Ne(()=>{d(0)},[e]),Ne(()=>{d(0)},[t,n]);const h=nn(v=>{v<0||v>=e.length||v!==f&&d(v)}),p=nn(v=>{if(!i)return!1;switch(v.key){case"ArrowDown":return v.preventDefault(),d(S=>{const y=e.length;return y===0?0:S<y-1?S+1:0}),!0;case"ArrowUp":return v.preventDefault(),d(S=>{const y=e.length;return y===0?0:S>0?S-1:y-1}),!0;case"Enter":case"Tab":{if(v.shiftKey)return!1;v.preventDefault();const S=e[f];return S&&(pT(S)?o(S):a(S.id)),!0}case"Escape":return v.preventDefault(),u(),!0;case"Backspace":return n&&r===""?(v.preventDefault(),l(),!0):!1;default:return!1}}),g=e[f];return{highlightedIndex:f,highlightedItemId:i&&g?`${s}-option-${g.id}`:void 0,highlightIndex:h,handleKeyDown:p}});function sp(e,t){return e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}const gT=ce(({adapter:e,query:t,open:n})=>{const[r,s]=kt(null);Ne(()=>{n||s(null)},[n]);const i=ie(()=>!n||!e?[]:e.categories(),[n,e]),o=n?r:null,a=ie(()=>!o||!e?[]:e.categoryItems(o),[o,e]),l=ie(()=>{if(!n||!e||o||!t&&i.length>0)return null;if(e.search)return e.search(t);const h=[],p=t.toLowerCase();for(const g of i)for(const v of e.categoryItems(g.id))sp(v,p)&&h.push(v);return h},[n,e,t,o,i]),u=l!==null,f=ie(()=>{if(u)return[];if(!t)return i;const h=t.toLowerCase();return i.filter(p=>p.label.toLowerCase().includes(h))},[i,t,u]),d=ie(()=>{if(u)return l??[];if(!t)return a;const h=t.toLowerCase();return a.filter(p=>sp(p,h))},[a,t,u,l]);return{categories:f,items:d,isSearchMode:u,activeCategoryId:o,navigableList:ie(()=>u?l??[]:o?d:f,[u,l,o,d,f]),selectCategory:nn(h=>{s(h)}),goBack:nn(()=>{s(null)})}}),yT=ce(({behavior:e,trigger:t,aui:n,triggerChar:r,setCursorPosition:s,onSelected:i})=>{const o=tn(null),a=nn(l=>(o.current=l,()=>{o.current===l&&(o.current=null)}));return{selectItem:nn(l=>{if(!t||!e)return;if(o.current?.(l)){i();return}const u=n.composer().getState().text,f=u.slice(0,t.offset),d=u.slice(t.offset+r.length+t.query.length),h=()=>{const p=e.formatter.serialize(l);n.composer().setText(f+p+(d.startsWith(" ")?d:` ${d}`))};e.kind==="directive"?(h(),e.onInserted?.(l)):(e.removeOnExecute?n.composer().setText(f+(d.startsWith(" ")?d.slice(1):d)):h(),e.onExecute(l)),i()}),close:nn(()=>{i(),t&&s(t.offset)}),registerSelectItemOverride:a}}),vT=ce(({adapter:e,text:t,triggerChar:n,behavior:r,aui:s,popoverId:i})=>{const o=He(hT({text:t,triggerChar:n})),a=o.trigger!==null&&e!==void 0&&r!==void 0,l=He(gT({adapter:e,query:o.query,open:a})),u=nn(()=>{l.goBack()}),f=He(yT({behavior:r,trigger:o.trigger,aui:s,triggerChar:n,setCursorPosition:o.setCursorPosition,onSelected:u})),d=He(mT({navigableList:l.navigableList,isSearchMode:l.isSearchMode,activeCategoryId:l.activeCategoryId,query:o.query,popoverId:i,open:a,selectItem:f.selectItem,selectCategory:l.selectCategory,goBack:l.goBack,close:f.close}));return{open:a,query:o.query,activeCategoryId:l.activeCategoryId,categories:l.categories,items:l.items,highlightedIndex:d.highlightedIndex,isSearchMode:l.isSearchMode,popoverId:i,highlightedItemId:d.highlightedItemId,selectCategory:l.selectCategory,goBack:l.goBack,selectItem:f.selectItem,close:f.close,highlightIndex:d.highlightIndex,handleKeyDown:d.handleKeyDown,setCursorPosition:o.setCursorPosition,registerSelectItemOverride:f.registerSelectItemOverride}}),Id=m.createContext(null),gs=()=>{const e=m.useContext(Id);if(!e)throw new Error("useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover");return e},xT=()=>m.useContext(Id),Mx=m.createContext(null),Dx=()=>{const e=m.useContext(Mx);if(!e)throw new Error("TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover");return e},Lx=m.forwardRef(({char:e,adapter:t,"aria-label":n,children:r,...s},i)=>{const o=se(),a=V(I=>I.composer.text),l=m.useId(),u=m.useRef(null),[f,d]=m.useState(null),h=m.useRef(0),p=m.useCallback(I=>(h.current+=1,u.current=I,d(I),()=>{h.current=Math.max(0,h.current-1),u.current===I&&(u.current=null,d(null))}),[e]),g=m.useMemo(()=>({register:p}),[p]),v=cv(vT({adapter:t,text:a,triggerChar:e,behavior:f??void 0,aui:o,popoverId:l})),S=m.useRef(v);S.current=v;const y=Ed();m.useEffect(()=>y.register({char:e,...f?{behavior:f}:{},resource:S.current}),[y,e,f]);const x=$a();m.useEffect(()=>{if(x)return x.register(S.current)},[x]);const w=f!==null&&v.open,E=aT();return m.useEffect(()=>{if(w)return()=>{E.setActiveAria(e,null)}},[E,e,w]),m.useEffect(()=>{w&&E.setActiveAria(e,{popoverId:l,highlightedItemId:v.highlightedItemId})},[E,e,l,w,v.highlightedItemId]),c.jsx(Mx.Provider,{value:g,children:c.jsx(Id.Provider,{value:v,children:w?c.jsx(be.div,{role:"listbox",id:l,"aria-label":n??"Suggestions","aria-activedescendant":v.highlightedItemId,"data-state":"open",...s,ref:i,children:r}):r})})});Lx.displayName="ComposerPrimitive.TriggerPopover";const Ox=()=>{const{disabled:e,send:t}=rE(),n=m.useCallback(()=>t(),[t]);return e?null:n},wT=Wt("ComposerPrimitive.Send",Ox),zx=m.forwardRef(({onSubmit:e,...t},n)=>{const r=Ox(),s=i=>{i.preventDefault(),r&&r()};return c.jsx(be.form,{...t,ref:n,onSubmit:Te(e,s)})});zx.displayName="ComposerPrimitive.Root";const Fx=e=>{const t=mr(e),n=wr(r=>r.onScrollToBottom);m.useEffect(()=>n(t),[n,t])},bT=()=>!1,ST=()=>{},kT=e=>m.useSyncExternalStore(m.useCallback(t=>{if(typeof window>"u"||e===null)return ST;const n=window.matchMedia(e);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)},[e]),m.useCallback(()=>typeof window>"u"||e===null?!1:window.matchMedia(e).matches,[e]),bT);function Xu(){return Xu=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Xu.apply(null,arguments)}function CT(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var _T=m.useLayoutEffect,ET=function(t){var n=ut.useRef(t);return _T(function(){n.current=t}),n},ip=function(t,n){if(typeof t=="function"){t(n);return}t.current=n},TT=function(t,n){var r=ut.useRef();return ut.useCallback(function(s){t.current=s,r.current&&ip(r.current,null),r.current=n,n&&ip(n,s)},[n])},op={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},IT=function(t){Object.keys(op).forEach(function(n){t.style.setProperty(n,op[n],"important")})},ap=IT,et=null,lp=function(t,n){var r=t.scrollHeight;return n.sizingStyle.boxSizing==="border-box"?r+n.borderSize:r-n.paddingSize};function RT(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),et||(et=document.createElement("textarea"),et.setAttribute("tabindex","-1"),et.setAttribute("aria-hidden","true"),ap(et)),et.parentNode===null&&document.body.appendChild(et);var s=e.paddingSize,i=e.borderSize,o=e.sizingStyle,a=o.boxSizing;Object.keys(o).forEach(function(h){var p=h;et.style[p]=o[p]}),ap(et),et.value=t;var l=lp(et,e);et.value=t,l=lp(et,e),et.value="x";var u=et.scrollHeight-s,f=u*n;a==="border-box"&&(f=f+s+i),l=Math.max(f,l);var d=u*r;return a==="border-box"&&(d=d+s+i),l=Math.min(d,l),[l,u]}var up=function(){},PT=function(t,n){return t.reduce(function(r,s){return r[s]=n[s],r},{})},AT=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],jT=!!document.documentElement.currentStyle,NT=function(t){var n=window.getComputedStyle(t);if(n===null)return null;var r=PT(AT,n),s=r.boxSizing;if(s==="")return null;jT&&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}},MT=NT;function Rd(e,t,n){var r=ET(n);m.useLayoutEffect(function(){var s=function(o){return r.current(o)};if(e)return e.addEventListener(t,s),function(){return e.removeEventListener(t,s)}},[])}var DT=function(t,n){Rd(document.body,"reset",function(r){t.current.form===r.target&&n(r)})},LT=function(t){Rd(window,"resize",t)},OT=function(t){Rd(document.fonts,"loadingdone",t)},zT=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],FT=function(t,n){var r=t.cacheMeasurements,s=t.maxRows,i=t.minRows,o=t.onChange,a=o===void 0?up:o,l=t.onHeightChange,u=l===void 0?up:l,f=CT(t,zT),d=f.value!==void 0,h=m.useRef(null),p=TT(h,n),g=m.useRef(0),v=m.useRef(),S=function(){var w=h.current,E=r&&v.current?v.current:MT(w);if(E){v.current=E;var I=RT(E,w.value||w.placeholder||"x",i,s),k=I[0],R=I[1];g.current!==k&&(g.current=k,w.style.setProperty("height",k+"px","important"),u(k,{rowHeight:R}))}},y=function(w){d||S(),a(w)};return m.useLayoutEffect(S),DT(h,function(){if(!d){var x=h.current.value;requestAnimationFrame(function(){var w=h.current;w&&x!==w.value&&S()})}}),LT(S),OT(S),m.createElement("textarea",Xu({},f,{onChange:y,ref:p}))},BT=m.forwardRef(FT);const $T="(pointer: coarse) and (not (any-pointer: fine))",Bx=m.forwardRef(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:s,onKeyDown:i,onPaste:o,onSelect:a,submitOnEnter:l,submitMode:u,cancelOnEscape:f=!0,unstable_focusOnRunStart:d=!0,unstable_focusOnScrollToBottom:h=!0,unstable_focusOnThreadSwitched:p=!0,unstable_insertNewlineOnTouchEnter:g=!1,addAttachmentOnPaste:v=!0,...S},y)=>{const x=se(),w=$a(),E=dT(),I=u??(l===!1?"none":"enter"),k=kT(g?$T:null),R=g&&k&&I==="enter"?"none":I,M=V(D=>D.composer.isEditing?D.composer.text:""),L=V(D=>D.thread.isDisabled||D.composer.dictation?.inputDisabled)||r,_=m.useRef(null),z=Sr(y,_),N=m.useRef(!1);bx(D=>{if(!_.current?.contains(D.target))return;if(w){for(const J of w.getPlugins())if(J.handleKeyDown(D))return}if(!f)return;const b=x.composer();b.getState().canCancel&&(b.cancel(),D.preventDefault())});const K=D=>{if(!L&&!D.nativeEvent.isComposing){if(w){for(const b of w.getPlugins())if(b.handleKeyDown(D))return}if(D.key==="Enter"){const b=x.thread().getState(),J=b.capabilities.queue;if(D.shiftKey&&(D.ctrlKey||D.metaKey)&&J&&I!=="none"&&x.composer().getState().canSend){D.preventDefault(),x.composer().send({steer:!0});return}if(D.shiftKey||b.isRunning&&!J)return;let Y=!1;R==="ctrlEnter"?Y=D.ctrlKey||D.metaKey:R==="enter"&&(Y=!0),Y&&(D.preventDefault(),_.current?.closest("form")?.requestSubmit())}}},P=async D=>{if(!v)return;const b=x.thread().getState().capabilities,J=Array.from(D.clipboardData?.files||[]);if(b.attachments&&J.length>0)try{D.preventDefault(),await Promise.all(J.map(Y=>x.composer().addAttachment(Y)))}catch(Y){console.error("Error adding attachment:",Y)}},B=e&&!L,ee=m.useCallback(()=>{const D=_.current;!D||!B||(D.focus({preventScroll:!0}),D.setSelectionRange(D.value.length,D.value.length))},[B]);m.useEffect(()=>ee(),[ee]),Fx(()=>{x.composer().getState().type==="thread"&&h&&ee()}),m.useEffect(()=>{if(!(x.composer().getState().type!=="thread"||!d))return x.on("thread.runStart",ee)},[d,ee,x]),m.useEffect(()=>{if(!(x.composer().getState().type!=="thread"||!p))return x.on("threadListItem.switchedTo",ee)},[p,ee,x]);const ae=E?{"aria-controls":E.popoverId,"aria-expanded":!0,"aria-haspopup":"listbox","aria-activedescendant":E.highlightedItemId}:{},F={name:"input",value:M,...S,...ae,ref:z,disabled:L,onChange:Te(s,D=>{if(!x.composer().getState().isEditing)return;const b=D.nativeEvent.isComposing===!0;N.current&&!b&&(N.current=!1);const J=b||N.current;if(gh(()=>{x.composer().setText(D.target.value)}),J)return;const Y=D.target.selectionStart??D.target.value.length;if(w)for(const C of w.getPlugins())C.setCursorPosition(Y)}),onKeyDown:Te(i,K),onCompositionStart:Te(S.onCompositionStart,()=>{N.current=!0}),onCompositionEnd:Te(S.onCompositionEnd,D=>{if(N.current=!1,!x.composer().getState().isEditing)return;const b=D.target;gh(()=>{x.composer().setText(b.value)});const J=b.selectionStart??b.value.length;if(w)for(const Y of w.getPlugins())Y.setCursorPosition(J)}),onSelect:Te(a,D=>{if(N.current)return;const b=D.target,J=b.selectionStart??b.value.length;if(w)for(const Y of w.getPlugins())Y.setCursorPosition(J)}),onPaste:Te(o,P)};if(n&&m.isValidElement(n)){const D=S.children!==void 0?S.children:n.props.children;return c.jsx(aa,{...F,children:m.cloneElement(n,void 0,D)})}return c.jsx(t?aa:BT,{...F})});Bx.displayName="ComposerPrimitive.Input";const UT=()=>{const{disabled:e,cancel:t}=sE();return e?null:t},VT=Wt("ComposerPrimitive.Cancel",UT),HT=({multiple:e=!0}={})=>{const{disabled:t,addAttachment:n}=oE(),r=se(),s=m.useCallback(()=>{const i=document.createElement("input");i.type="file",i.multiple=e,i.hidden=!0;const o=r.composer().getState().attachmentAccept;o!=="*"&&(i.accept=o),document.body.appendChild(i),i.onchange=a=>{const l=a.target.files;if(l){for(const u of l)n(u);document.body.removeChild(i)}},i.oncancel=()=>{(!i.files||i.files.length===0)&&document.body.removeChild(i)},i.click()},[r,e,n]);return t?null:s},WT=Wt("ComposerPrimitive.AddAttachment",HT,["multiple"]),$x=m.forwardRef(({disabled:e,asChild:t=!1,render:n,children:r,...s},i)=>{const[o,a]=m.useState(!1),l=se(),u=m.useCallback(g=>{e||(g.preventDefault(),a(!0))},[e]),f=m.useCallback(g=>{e||(g.preventDefault(),o||a(!0))},[e,o]),d=m.useCallback(g=>{if(e)return;g.preventDefault();const v=g.relatedTarget;v&&g.currentTarget.contains(v)||a(!1)},[e]),h=m.useCallback(async g=>{if(e)return;g.preventDefault(),a(!1);const v=Array.from(g.dataTransfer.files);await Promise.all(v.map(async S=>{try{await l.composer().addAttachment(S)}catch(y){console.error("Failed to add attachment:",y)}}))},[e,l]),p={...o?{"data-dragging":"true"}:null,...s,onDragEnterCapture:Te(s.onDragEnterCapture,u),onDragOverCapture:Te(s.onDragOverCapture,f),onDragLeaveCapture:Te(s.onDragLeaveCapture,d),onDropCapture:Te(s.onDropCapture,h),ref:i};if(n&&m.isValidElement(n)){const g=r!==void 0?r:n.props.children;return c.jsx(aa,{...p,children:m.cloneElement(n,void 0,g)})}return c.jsx(t?aa:"div",{...p,children:r})});$x.displayName="ComposerPrimitive.AttachmentDropzone";const qT=()=>{const{disabled:e,startDictation:t}=iE();return e?null:t},KT=Wt("ComposerPrimitive.Dictate",qT),GT=()=>{const e=se(),t=V(r=>r.composer.dictation!=null),n=m.useCallback(()=>{e.composer().stopDictation()},[e]);return t?n:null},QT=Wt("ComposerPrimitive.StopDictation",GT),Ux=m.forwardRef(({children:e,...t},n)=>{const r=V(s=>s.composer.dictation?.transcript);return r?c.jsx(be.span,{...t,ref:n,children:e??r}):null});Ux.displayName="ComposerPrimitive.DictationTranscript";const Vx=m.forwardRef((e,t)=>V(n=>n.composer.quote)?c.jsx(be.div,{...e,ref:t}):null);Vx.displayName="ComposerPrimitive.Quote";const Hx=m.forwardRef(({children:e,...t},n)=>{const r=V(s=>s.composer.quote?.text);return r?c.jsx(be.span,{...t,ref:n,children:e??r}):null});Hx.displayName="ComposerPrimitive.QuoteText";const Wx=m.forwardRef(({onClick:e,...t},n)=>{const r=se(),s=m.useCallback(()=>{r.composer().setQuote(void 0)},[r]);return c.jsx(be.button,{type:"button",...t,ref:n,onClick:Te(e,s)})});Wx.displayName="ComposerPrimitive.QuoteDismiss";const qx=m.forwardRef(({children:e,"aria-label":t,...n},r)=>{const{categories:s,activeCategoryId:i,isSearchMode:o,open:a}=gs();return!a||i||o?null:c.jsx(be.div,{role:"group","aria-label":t??"Categories",...n,ref:r,children:e(s)})});qx.displayName="ComposerPrimitive.TriggerPopoverCategories";const Kx=m.forwardRef(({categoryId:e,onClick:t,onMouseMove:n,...r},s)=>{const{selectCategory:i,highlightIndex:o,categories:a,highlightedIndex:l,activeCategoryId:u,isSearchMode:f,popoverId:d}=gs(),h=m.useCallback(()=>{i(e)},[i,e]),p=a.findIndex(S=>S.id===e),g=!u&&!f&&p===l,v=m.useCallback(()=>{o(p)},[o,p]);return c.jsx(be.button,{type:"button",role:"option",id:`${d}-option-${e}`,"aria-selected":g,"data-highlighted":g?"":void 0,...r,ref:s,onClick:Te(t,h),onMouseMove:Te(n,v)})});Kx.displayName="ComposerPrimitive.TriggerPopoverCategoryItem";const Gx=m.forwardRef(({children:e,"aria-label":t,...n},r)=>{const{items:s,activeCategoryId:i,isSearchMode:o,open:a}=gs();return!a||!i&&!o?null:c.jsx(be.div,{role:"group","aria-label":t??"Items",...n,ref:r,children:e(s)})});Gx.displayName="ComposerPrimitive.TriggerPopoverItems";const Qx=m.forwardRef(({item:e,index:t,onClick:n,onMouseMove:r,...s},i)=>{const{selectItem:o,highlightIndex:a,items:l,highlightedIndex:u,activeCategoryId:f,isSearchMode:d,popoverId:h}=gs(),p=m.useCallback(()=>{o(e)},[o,e]),g=t??l.findIndex(y=>y.id===e.id),v=(d||f!==null)&&g===u,S=m.useCallback(()=>{a(g)},[a,g]);return c.jsx(be.button,{type:"button",role:"option",id:`${h}-option-${e.id}`,"aria-selected":v,"data-highlighted":v?"":void 0,...s,ref:i,onClick:Te(n,p),onMouseMove:Te(r,S)})});Qx.displayName="ComposerPrimitive.TriggerPopoverItem";const Yx=m.forwardRef(({onClick:e,...t},n)=>{const{activeCategoryId:r,isSearchMode:s,goBack:i,open:o}=gs();return!o||!r||s?null:c.jsx(be.button,{type:"button",...t,ref:n,onClick:Te(e,i)})});Yx.displayName="ComposerPrimitive.TriggerPopoverBack";const Jx=({formatter:e,onExecute:t,removeOnExecute:n})=>{const{register:r}=Dx(),s=m.useRef(t);return s.current=t,m.useEffect(()=>r({kind:"action",formatter:e??mx,onExecute:i=>s.current(i),...n!==void 0?{removeOnExecute:n}:{}}),[r,e,n]),null};Jx.displayName="ComposerPrimitive.TriggerPopoverAction";const Xx=({formatter:e,onInserted:t})=>{const{register:n}=Dx(),r=m.useRef(t);return r.current=t,m.useEffect(()=>n({kind:"directive",formatter:e??mx,onInserted:s=>r.current?.(s)}),[n,e]),null};Xx.displayName="ComposerPrimitive.TriggerPopoverDirective";const YT=Object.assign(Lx,{Directive:Xx,Action:Jx});var so=ms({AddAttachment:()=>WT,AttachmentByIndex:()=>lx,AttachmentDropzone:()=>$x,Attachments:()=>ux,Cancel:()=>VT,Dictate:()=>KT,DictationTranscript:()=>Ux,If:()=>px,Input:()=>Bx,Queue:()=>cx,Quote:()=>Vx,QuoteDismiss:()=>Wx,QuoteText:()=>Hx,Root:()=>zx,Send:()=>wT,StopDictation:()=>QT,Unstable_TriggerPopover:()=>YT,Unstable_TriggerPopoverBack:()=>Yx,Unstable_TriggerPopoverCategories:()=>qx,Unstable_TriggerPopoverCategoryItem:()=>Kx,Unstable_TriggerPopoverItem:()=>Qx,Unstable_TriggerPopoverItems:()=>Gx,Unstable_TriggerPopoverRoot:()=>Nx,unstable_useTriggerPopoverRootContext:()=>Ed,unstable_useTriggerPopoverRootContextOptional:()=>Td,unstable_useTriggerPopoverScopeContext:()=>gs,unstable_useTriggerPopoverScopeContextOptional:()=>xT,unstable_useTriggerPopoverTriggers:()=>lT,unstable_useTriggerPopoverTriggersOptional:()=>cT});const Zx=()=>V(e=>{if(e.part.type!=="text"&&e.part.type!=="reasoning")throw new Error("MessagePartText can only be used inside text or reasoning message parts.");return e.part}),JT=()=>V(e=>{if(e.part.type!=="image")throw new Error("MessagePartImage can only be used inside image message parts.");return e.part}),ew=m.createContext(null),XT=e=>({useSmoothStatus:gv(()=>e)}),ZT=({children:e})=>{const t=tw({optional:!0}),n=se(),[r]=m.useState(()=>XT(n.part().getState().status));return t?e:c.jsx(ew.Provider,{value:r,children:e})},eI=e=>{const t=m.forwardRef((n,r)=>c.jsx(ZT,{children:c.jsx(e,{...n,ref:r})}));return t.displayName=e.displayName,t};function tw(e){const t=m.useContext(ew);if(!e?.optional&&!t)throw new Error("This component must be used within a SmoothContextProvider.");return t}const{useSmoothStatus:tI,useSmoothStatusStore:nI}=gx(tw,"useSmoothStatus");var rI=class{constructor(e,t){T(this,"currentText");T(this,"setText");T(this,"animationFrameId",null);T(this,"lastUpdateTime",Date.now());T(this,"targetText","");T(this,"animate",()=>{const e=Date.now();let t=e-this.lastUpdateTime;const n=this.targetText.length-this.currentText.length,r=Math.min(5,250/n);let s=0;for(;t>=r&&s<n;)s++,t-=r;s!==n?this.animationFrameId=requestAnimationFrame(this.animate):this.animationFrameId=null,s!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+s),this.lastUpdateTime=e-t,this.setText(this.currentText))});this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}};const Pl=Object.freeze({type:"running"}),nw=(e,t=!1)=>{const{text:n}=e,[r,s]=m.useState(e.status.type==="running"?"":n),i=se(),o=V(()=>i.part()),[a,l]=m.useState(o);(o!==a||!n.startsWith(r))&&(l(o),s(e.status.type==="running"?"":n));const u=nI({optional:!0}),f=mr(p=>{if(s(p),u){const g=r!==p||e.status.type==="running"?Pl:e.status;ia(u).setState(g,!0)}});m.useEffect(()=>{if(u){const p=t&&(r!==n||e.status.type==="running")?Pl:e.status;ia(u).setState(p,!0)}},[u,t,n,r,e.status]);const[d]=m.useState(new rI(r,f)),h=m.useRef(o);return m.useEffect(()=>{if(!t){d.stop();return}const p=h.current!==o;if(h.current=o,p||!n.startsWith(d.targetText)){e.status.type==="running"?(d.currentText="",d.targetText=n,d.start()):(d.currentText=n,d.targetText=n,d.stop());return}d.targetText=n,d.start()},[d,t,n,e.status.type,o]),m.useEffect(()=>()=>{d.stop()},[d]),m.useMemo(()=>t?{type:"text",text:r,status:n===r?e.status:Pl}:e,[t,r,e,n])},Pd=m.forwardRef(({smooth:e=!0,component:t="span",...n},r)=>{const{text:s,status:i}=nw(Zx(),e);return c.jsx(t,{"data-status":i.type,...n,ref:r,children:s})});Pd.displayName="MessagePartPrimitive.Text";const Ad=m.forwardRef((e,t)=>{const{image:n}=JT();return c.jsx(be.img,{src:n,...e,ref:t})});Ad.displayName="MessagePartPrimitive.Image";const kr=e=>{const t=m.useRef(void 0);return m.useCallback(n=>{t.current&&(t.current(),t.current=void 0),n&&(t.current=e(n))},[e])},cp=(e,t)=>{const n=e.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(t).fontSize)||16):s==="rem"?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):Number.POSITIVE_INFINITY},sI=e=>e.dataset.messageId,iI=()=>{const e=document.createElement("div");return e.dataset.auiTopAnchorReserve="",e.style.height="0px",e.style.flexShrink="0",e.style.pointerEvents="none",e.setAttribute("aria-hidden","true"),e},dp=(e,t)=>{const n=`${t}px`;return e.style.height!==n?(e.style.height=n,!0):!1},oI=e=>{const t=window.devicePixelRatio||1;return Math.round(e*t)/t},rw=()=>{const e=se(),t=V(()=>e.message());return kr(m.useCallback(n=>{const r=()=>{t.setIsHovering(!0)},s=()=>{t.setIsHovering(!1)};return n.addEventListener("mouseenter",r),n.addEventListener("mouseleave",s),n.matches(":hover")&&queueMicrotask(()=>t.setIsHovering(!0)),()=>{n.removeEventListener("mouseenter",r),n.removeEventListener("mouseleave",s),t.setIsHovering(!1)}},[t]))},aI=()=>{const e=wr(t=>t.topAnchorTurn?.anchorId);return V(t=>t.message.role==="user"&&t.message.index>0&&t.message.index===t.thread.messages.length-2&&t.thread.messages.at(-1)?.role==="assistant"&&(t.message.id===e||t.thread.isRunning))},lI=()=>{const e=wr(t=>t.topAnchorTurn?.targetId);return V(t=>t.message.isLast&&t.message.role==="assistant"&&t.message.index>=1&&t.thread.messages.at(t.message.index-1)?.role==="user"&&(t.message.id===e||t.thread.isRunning))},uI=(e,t)=>kr(m.useCallback(n=>{if(e)return t.getState().registerAnchorElement(n)},[e,t])),cI=({active:e,threadViewportStore:t})=>kr(m.useCallback(n=>{if(!e)return;const r=t.getState(),s=r.topAnchorMessageClamp;return r.registerAnchorTargetElement(n,{tallerThan:cp(s.tallerThan,n),visibleHeight:cp(s.visibleHeight,n)})},[e,t])),dI=({forwardedRef:e,...t})=>{const n=Sr(e,rw()),r=V(s=>s.message.id);return c.jsx(be.div,{...t,ref:n,"data-message-id":r})},fI=({forwardedRef:e,threadViewportStore:t,...n})=>{const r=rw(),s=aI(),i=lI(),o=Sr(e,r,uI(s,t),cI({active:i,threadViewportStore:t})),a=V(l=>l.message.id);return c.jsx(be.div,{...n,ref:o,"data-message-id":a,"data-aui-top-anchor-user":s?"":void 0,"data-aui-top-anchor-target":i?"":void 0})},sw=m.forwardRef((e,t)=>{const n=br();return n.getState().turnAnchor==="top"?c.jsx(fI,{...e,forwardedRef:t,threadViewportStore:n}):c.jsx(dI,{...e,forwardedRef:t})});sw.displayName="MessagePrimitive.Root";const Al={...Ye,Text:()=>c.jsxs("p",{style:{whiteSpace:"pre-line"},children:[c.jsx(Pd,{}),c.jsx(kd,{children:c.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Image:()=>c.jsx(Ad,{})},Zu=e=>{if("children"in e)return c.jsx(Ju,{children:e.children});const{components:t,...n}=e;return c.jsx(Ju,{components:t?{Text:t.Text??Al.Text,Image:t.Image??Al.Image,Reasoning:t.Reasoning??Ye.Reasoning,Source:t.Source??Ye.Source,File:t.File??Ye.File,Unstable_Audio:t.Unstable_Audio??Ye.Unstable_Audio,..."ChainOfThought"in t?{ChainOfThought:t.ChainOfThought}:{tools:t.tools,data:t.data,ToolGroup:t.ToolGroup??Ye.ToolGroup,ReasoningGroup:t.ReasoningGroup??Ye.ReasoningGroup},Empty:t.Empty,Quote:t.Quote,generativeUI:t.generativeUI}:Al,...n})};Zu.displayName="MessagePrimitive.Parts";const iw=({children:e})=>mE()!==void 0?e:null;iw.displayName="MessagePrimitive.Error";const hI=e=>{const t=new Map;for(let r=0;r<e.length;r++){const s=e[r]?.parentId??`__ungrouped_${r}`,i=t.get(s)??[];i.push(r),t.set(s,i)}const n=[];for(const[r,s]of t){const i=r.startsWith("__ungrouped_")?void 0:r;n.push({groupKey:i,indices:s})}return n},pI=e=>{const t=V(n=>n.message.parts);return m.useMemo(()=>t.length===0?[]:e(t),[t,e])},mI=({Fallback:e,...t})=>{const n=V(r=>{const s=r.tools.tools[t.toolName]??e;return Array.isArray(s)?s[0]??e:s});return n?c.jsx(n,{...t}):null},gI=({Fallback:e,...t})=>{const n=V(r=>{const s=r.dataRenderers.renderers[t.name]??e;return Array.isArray(s)?s[0]??e:s});return n?c.jsx(n,{...t}):null},En={Text:()=>c.jsxs("p",{style:{whiteSpace:"pre-line"},children:[c.jsx(Pd,{}),c.jsx(kd,{children:c.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>c.jsx(Ad,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},yI=({components:{Text:e=En.Text,Reasoning:t=En.Reasoning,Image:n=En.Image,Source:r=En.Source,File:s=En.File,Unstable_Audio:i=En.Unstable_Audio,tools:o={},data:a}={}})=>{const l=se(),u=V(d=>d.part),f=u.type;if(f==="tool-call"){const d=l.part().addToolResult,h=l.part().resumeToolCall,p=l.part().respondToToolApproval;if("Override"in o)return c.jsx(o.Override,{...u,addResult:d,resume:h,respondToApproval:p});const g=o.by_name?.[u.toolName]??o.Fallback;return c.jsx(mI,{...u,Fallback:g,addResult:d,resume:h,respondToApproval:p})}if(u.status?.type==="requires-action")throw new Error("Encountered unexpected requires-action status");switch(f){case"text":return c.jsx(e,{...u});case"reasoning":return c.jsx(t,{...u});case"source":return c.jsx(r,{...u});case"image":return c.jsx(n,{...u});case"file":return c.jsx(s,{...u});case"audio":return c.jsx(i,{...u});case"data":{const d=a?.by_name?.[u.name]??a?.Fallback;return c.jsx(gI,{...u,Fallback:d})}default:return console.warn(`Unknown message part type: ${f}`),null}},vI=({partIndex:e,components:t})=>c.jsx(yd,{index:e,children:c.jsx(yI,{components:t})}),xI=m.memo(vI,(e,t)=>e.partIndex===t.partIndex&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.Group===t.components?.Group),wI=({status:e,component:t})=>c.jsx(vd,{text:"",isRunning:e.type==="running",children:c.jsx(t,{type:"text",text:"",status:e})}),bI=Object.freeze({type:"complete"}),SI=({components:e})=>{const t=V(n=>n.message.status??bI);return e?.Empty?c.jsx(e.Empty,{status:t}):c.jsx(wI,{status:t,component:e?.Text??En.Text})},kI=m.memo(SI,(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),jd=({groupingFunction:e,components:t})=>{const n=V(s=>s.message.parts.length),r=pI(e);return c.jsx(c.Fragment,{children:m.useMemo(()=>n===0?c.jsx(kI,{components:t}):r.map((s,i)=>c.jsx(t?.Group??En.Group,{groupKey:s.groupKey,indices:s.indices,children:s.indices.map(o=>c.jsx(xI,{partIndex:o,components:t},o))},`group-${i}-${s.groupKey??"ungrouped"}`)),[r,t,n])})};jd.displayName="MessagePrimitive.Unstable_PartsGrouped";const ow=({components:e,...t})=>c.jsx(jd,{...t,components:e,groupingFunction:hI});ow.displayName="MessagePrimitive.Unstable_PartsGroupedByParentId";var la=ms({AttachmentByIndex:()=>ix,Attachments:()=>ox,Content:()=>Zu,Error:()=>iw,GenerativeUI:()=>Kv,GroupedParts:()=>nx,If:()=>Rx,PartByIndex:()=>Ys,Parts:()=>Zu,Quote:()=>rx,Root:()=>sw,Unstable_PartsGrouped:()=>jd,Unstable_PartsGroupedByParentId:()=>ow});const CI=e=>{const t=mr(e);return kr(m.useCallback(n=>{const r=new ResizeObserver(()=>{t()}),s=new MutationObserver(i=>{i.some(o=>o.type!=="attributes"||o.attributeName!=="style")&&t()});return r.observe(n),s.observe(n,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{r.disconnect(),s.disconnect()}},[t]))},_I=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{const s=m.useRef(null),i=V(E=>E.thread.messages.length>0),o=m.useRef(!1),a=m.useRef(null),l=br();e===void 0&&(e=l.getState().turnAnchor!=="top");const u=m.useRef(0),f=m.useRef(0),d=m.useRef(0),h=m.useRef(0),p=m.useRef(null),g=m.useCallback(E=>{const I=s.current;I&&(p.current=E,I.scrollTo({top:I.scrollHeight,behavior:E}))},[]),v=m.useCallback(E=>{p.current=E,a.current!==null&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{a.current=null,g(E)})},[g]);m.useLayoutEffect(()=>()=>{a.current!==null&&cancelAnimationFrame(a.current)},[]);const S=m.useCallback(()=>{const E=l.getState();return E.turnAnchor==="top"&&E.element.viewport===s.current&&E.element.anchor!==null},[l]),y=()=>{const E=s.current;if(!E)return;const I=l.getState().isAtBottom,k=Math.abs(E.scrollHeight-E.scrollTop-E.clientHeight)<=1||E.scrollHeight<=E.clientHeight;!k&&u.current<E.scrollTop||(k?E.scrollHeight>E.clientHeight+1&&(p.current=null):u.current>E.scrollTop&&f.current===E.scrollHeight&&(p.current=null),(k||p.current===null)&&k!==I&&ia(l).setState({isAtBottom:k})),u.current=E.scrollTop,f.current=E.scrollHeight},x=CI(()=>{const E=s.current;if(!E)return;const{scrollHeight:I,clientHeight:k}=E;if(I===d.current&&k===h.current)return;d.current=I,h.current=k;const R=p.current;R&&S()?p.current=null:R?g(R):e&&l.getState().isAtBottom&&g("instant"),y()}),w=kr(E=>(E.addEventListener("scroll",y),()=>{E.removeEventListener("scroll",y)}));return m.useLayoutEffect(()=>{if(n){if(!i){o.current=!1;return}o.current||(o.current=!0,p.current===null&&v("instant"))}},[i,v,n]),Fx(({behavior:E})=>{g(E)}),ta("thread.runStart",()=>{t&&l.getState().turnAnchor!=="top"&&v("auto")}),ta("threadListItem.switchedTo",()=>{r&&v("instant")}),Sr(x,w,s)},aw=m.forwardRef((e,t)=>c.jsx(be.div,{...e,ref:t}));aw.displayName="ThreadPrimitive.Root";const lw=({children:e})=>V(t=>t.thread.isEmpty)?e:null;lw.displayName="ThreadPrimitive.Empty";const EI=e=>V(t=>!(e.empty===!0&&!t.thread.isEmpty||e.empty===!1&&t.thread.isEmpty||e.running===!0&&!t.thread.isRunning||e.running===!1&&t.thread.isRunning||e.disabled===!0&&!t.thread.isDisabled||e.disabled===!1&&t.thread.isDisabled)),uw=({children:e,...t})=>EI(t)?e:null;uw.displayName="ThreadPrimitive.If";const cw=(e,t)=>kr(m.useCallback(n=>{if(!e)return;const r=e(),s=()=>{const o=t?t(n):n.offsetHeight;r.setHeight(o)},i=new ResizeObserver(s);return i.observe(n),s(),()=>{i.disconnect(),r.unregister()}},[e,t])),fp=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},TI=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:fp(e)-fp(t)},dw=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{const s=TI(t,e),i=t.offsetHeight;return s+Math.max(0,i-(i<=n?i:r))},II=({scrollHeight:e,...t})=>{const{viewport:n}=t,r=dw(t)+n.clientHeight;return Math.max(0,r-e)},RI=({viewport:e,reserve:t,...n})=>II({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),PI=e=>{const t=new ResizeObserver(e),n=new MutationObserver(e);let r=null,s=null,i=null;const o=()=>{t.disconnect(),n.disconnect(),r=null,s=null,i=null};return{target:(a,l,u)=>{r===a&&s===l&&i===u||(o(),t.observe(a),t.observe(l),t.observe(u),n.observe(u,{childList:!0,subtree:!0,characterData:!0}),r=a,s=l,i=u)},disconnect:o}},AI=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},jI=e=>{let t=null,n;function r(){const a=e.getState(),{viewport:l,anchor:u,target:f}=a.element,d=a.targetConfig;if(a.turnAnchor!=="top"||!l||!u||!f||!d){i.disconnect(),t&&(dp(t,0),t.remove());return}if(t??(t=iI()),(t.parentElement!==f.parentElement||t.previousElementSibling!==f)&&f.after(t),i.target(l,u,f),dp(t,RI({viewport:l,anchor:u,reserve:t,...d}))){s.schedule();return}const h=sI(u);if(h!==void 0&&n===h)return;const p=oI(dw({viewport:l,anchor:u,...d}));Math.abs(l.scrollTop-p)>1&&l.scrollTo({top:p,behavior:"smooth"}),h!==void 0&&(n=h)}const s=AI(r),i=PI(s.schedule);s.schedule();const o=e.subscribe(s.schedule);return()=>{s.cancel(),o(),i.disconnect(),t?.remove()}},NI=e=>{const t=br();m.useLayoutEffect(()=>{if(e)return jI(t)},[e,t])},fw=({isRunning:e,messages:t})=>{if(!e)return null;const n=t.at(-1),r=t.at(-2);return r?.role!=="user"||n?.role!=="assistant"?null:{anchorId:r.id,targetId:n.id}},MI=e=>fw(e)?.anchorId,DI=e=>fw(e)?.targetId,LI=()=>cw(wr(e=>e.registerViewport),m.useCallback(e=>e.clientHeight,[])),OI=()=>kr(wr(e=>e.registerViewportElement)),zI=e=>{const t=br(),n=V(o=>{if(e)return MI(o.thread)}),r=V(o=>{if(e)return DI(o.thread)}),s=m.useMemo(()=>!n||!r?null:{anchorId:n,targetId:r},[n,r]);m.useLayoutEffect(()=>{if(!s)return;const o=t.getState(),a=o.topAnchorTurn;a?.anchorId===s.anchorId&&a.targetId===s.targetId||o.setTopAnchorTurn(s)},[s,t]);const i=m.useCallback(()=>{t.getState().setTopAnchorTurn(null)},[t]);ta("thread.initialize",i),ta("threadListItem.switchedTo",i)},hw=m.forwardRef(({autoScroll:e,scrollToBottomOnRunStart:t,scrollToBottomOnInitialize:n,scrollToBottomOnThreadSwitch:r,children:s,...i},o)=>{const a=_I({autoScroll:e,scrollToBottomOnRunStart:t,scrollToBottomOnInitialize:n,scrollToBottomOnThreadSwitch:r}),l=LI(),u=OI(),f=br().getState().turnAnchor==="top";zI(f),NI(f);const d=Sr(o,a,l,u);return c.jsx(be.div,{...i,ref:d,children:s})});hw.displayName="ThreadPrimitive.ViewportScrollable";const pw=m.forwardRef(({turnAnchor:e,topAnchorMessageClamp:t,...n},r)=>c.jsx(Cd,{options:{turnAnchor:e,topAnchorMessageClamp:t},children:c.jsx(hw,{...n,ref:r})}));pw.displayName="ThreadPrimitive.Viewport";const mw=m.forwardRef((e,t)=>{const n=Sr(t,cw(wr(r=>r.registerContentInset),m.useCallback(r=>{const s=parseFloat(getComputedStyle(r).marginTop)||0;return r.offsetHeight+s},[])));return c.jsx(be.div,{...e,ref:n})});mw.displayName="ThreadPrimitive.ViewportFooter";const FI=({behavior:e}={})=>{const t=wr(s=>s.isAtBottom),n=br(),r=m.useCallback(()=>{n.getState().scrollToBottom({behavior:e})},[n,e]);return t?null:r},BI=Wt("ThreadPrimitive.ScrollToBottom",FI,["behavior"]),$I=({prompt:e,send:t,clearComposer:n,autoSend:r,method:s})=>{const{disabled:i,trigger:o}=pE({prompt:e,send:t??r??!1,clearComposer:n});return i?null:o},UI=Wt("ThreadPrimitive.Suggestion",$I,["prompt","send","clearComposer","autoSend","method"]);var dt=ms({Empty:()=>lw,If:()=>uw,MessageByIndex:()=>Vv,Messages:()=>S1,Root:()=>aw,ScrollToBottom:()=>BI,Suggestion:()=>UI,SuggestionByIndex:()=>fx,Suggestions:()=>tE,Viewport:()=>pw,ViewportFooter:()=>mw,ViewportProvider:()=>Cd}),VI=ms({AssistantRuntimeImpl:()=>Lv,BaseAssistantRuntimeCore:()=>Ov,CompositeContextProvider:()=>dd,DefaultThreadComposerRuntimeCore:()=>Bv,MessageRepository:()=>wd,ThreadRuntimeImpl:()=>Dv,fromThreadMessageLike:()=>Si,generateId:()=>Hn,getAutoStatus:()=>ra,splitLocalRuntimeOptions:()=>gE,useComposerInputPluginRegistryOptional:()=>$a,useSmooth:()=>nw,useSmoothStatus:()=>tI,withSmoothContextProvider:()=>eI});const Nd="claude-control.token";let ua=null,ca=!1;function HI(){try{return window.localStorage.getItem(Nd)}catch{return null}}const WI="claude-control";function Ua(){return ca||(ua=HI(),ca=!0),ua}function gw(e){ua=e,ca=!0;try{window.localStorage.setItem(Nd,e)}catch{}}function yw(){ua=null,ca=!0;try{window.localStorage.removeItem(Nd)}catch{}}function qI(){if(typeof window>"u"||!window.location)return;let e;try{e=new URLSearchParams(window.location.search)}catch{return}const t=e.get("token");if(!t)return;gw(t),e.delete("token");const n=e.toString(),r=window.location.pathname+(n?`?${n}`:"")+window.location.hash;try{window.history.replaceState(null,"",r)}catch{}}qI();const ec=new Set;function KI(e){return ec.add(e),()=>ec.delete(e)}function vw(){yw();for(const e of ec)e()}function GI(e){const t=Ua(),n={...e??{}};return t&&(n.Authorization=`Bearer ${t}`),n}async function Oe(e,t){const n=await fetch(e,{...t,headers:GI(t?.headers)});return n.status===401&&vw(),n}function QI(e){const t=`/term/${encodeURIComponent(e)}/`,n=Ua();return n?`${t}?token=${encodeURIComponent(n)}`:t}function YI(){const e=window.location;return`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}/`}async function JI(e,t){const n=await Oe("/api/pins",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:e,transcriptPath:t})}),r=await n.json().catch(()=>({}));if(!n.ok||!r.ok)throw new Error(r.error||`HTTP ${n.status}`);return r.pins??{}}async function XI(){const e=await Oe("/api/transcripts");if(!e.ok)throw new Error(`HTTP ${e.status}`);return(await e.json()).transcripts??[]}async function xw(){try{const e=await Oe("/api/version");return e.ok?await e.json():null}catch{return null}}async function ZI(){try{const e=await Oe("/api/update",{method:"POST"}),t=await e.json().catch(()=>({}));return e.ok&&!!t.ok}catch{return!0}}async function eR(){try{const e=await Oe("/api/push/vapid");return e.ok?(await e.json()).publicKey??null:null}catch{return null}}async function tR(e){try{return(await Oe("/api/push/subscribe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)})).ok}catch{return!1}}async function nR(e){try{return(await Oe("/api/push/unsubscribe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:e})})).ok}catch{return!1}}async function rR(e){const t=await Oe("/api/icon",{method:"POST",body:e}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok)throw new Error(n.error||`HTTP ${t.status}`)}async function sR(){const e=await Oe("/api/icon",{method:"DELETE"}),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok)throw new Error(t.error||`HTTP ${e.status}`)}async function iR(){const e=await Oe("/api/models");if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}async function oR(e,t){const n=await Oe("/api/optimize",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:e})}),r=await n.json().catch(()=>({}));if(!n.ok||typeof r.optimized!="string")throw new Error(r.error||`HTTP ${n.status}`);return{optimized:r.optimized,rationale:r.rationale??[],changes:r.changes??[],mode:r.mode==="rules"?"rules":"llm"}}async function aR(e,t="webm"){const n=await Oe(`/api/transcribe?ext=${encodeURIComponent(t)}`,{method:"POST",body:e}),r=await n.json().catch(()=>({}));if(!n.ok||!r.ok)throw new Error(r.error||`HTTP ${n.status}`);return r.text??""}async function lR(){const e=await Oe("/api/config");if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}async function uR(e){const t=await Oe("/api/config",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));if(!t.ok)throw new Error("error"in n&&n.error||`HTTP ${t.status}`);return n}async function cR(e){const t=await Oe("/api/session/new",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e??{})}),n=await t.json().catch(()=>({}));if(!t.ok||!("ok"in n)||!n.ok){const r="error"in n&&n.error||`HTTP ${t.status}`;throw new Error(r)}return n}async function dR(e,t){const n=await Oe("/api/session/rename",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:e,name:t})}),r=await n.json().catch(()=>({}));if(!n.ok||!("ok"in r)||!r.ok){const s="error"in r&&r.error||`HTTP ${n.status}`;throw new Error(s)}}function fR(e){return`/api/uploads/${encodeURIComponent(e)}`}async function ww(){const e=await Oe("/api/skills");if(!e.ok)throw new Error(`HTTP ${e.status}`);return(await e.json()).skills??[]}async function hR(e){const t=`/api/upload?name=${encodeURIComponent(e.name)}`,n=await Oe(t,{method:"POST",body:e});let r=null;try{r=await n.json()}catch{}const s=r??{};if(!n.ok||!s.ok||!s.path)throw new Error(s.error||`HTTP ${n.status}`);return{ok:!0,path:s.path,name:s.name??e.name}}const pR=1008,hp=1e3,mR=3e4;class gR{constructor(){T(this,"ws",null);T(this,"reconnectTimer",null);T(this,"reconnectDelay",hp);T(this,"selectedId",null);T(this,"closed",!1);T(this,"msgHandlers",new Set);T(this,"stateHandlers",new Set)}connect(){if(this.ws&&(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING))return;this.emitState("connecting");const t=Ua(),n=t?[WI,t]:void 0,r=new WebSocket(YI(),n);this.ws=r,r.addEventListener("open",()=>{this.reconnectDelay=hp,this.emitState("connected"),this.selectedId&&this.send({type:"subscribe",id:this.selectedId})}),r.addEventListener("message",s=>{let i;try{i=JSON.parse(s.data)}catch{return}for(const o of this.msgHandlers)o(i)}),r.addEventListener("close",s=>{if(this.ws=null,this.emitState("disconnected"),s.code===pR){vw();return}this.closed||this.scheduleReconnect()}),r.addEventListener("error",()=>{})}scheduleReconnect(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,mR)}send(t){return this.ws&&this.ws.readyState===WebSocket.OPEN?(this.ws.send(JSON.stringify(t)),!0):!1}isOpen(){return this.ws?.readyState===WebSocket.OPEN}select(t){this.selectedId!==t&&(this.selectedId&&this.send({type:"unsubscribe",id:this.selectedId}),this.selectedId=t,t&&this.send({type:"subscribe",id:t}))}resubscribe(){const t=this.selectedId;t&&(this.send({type:"unsubscribe",id:t}),this.send({type:"subscribe",id:t}))}onMessage(t){return this.msgHandlers.add(t),()=>this.msgHandlers.delete(t)}onState(t){return this.stateHandlers.add(t),()=>this.stateHandlers.delete(t)}emitState(t){for(const n of this.stateHandlers)n(t)}close(){this.closed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws?.close(),this.ws=null}}const pp=2e3;function yR(e,t){if(!e||e.length===0)return mp(t);if(t.length===0)return e;const n=new Set;for(const s of e)n.add(s.uuid);const r=t.filter(s=>!n.has(s.uuid));return r.length===0?e:mp([...e,...r])}function mp(e){return e.length>pp?e.slice(e.length-pp):e}function vR(){const e=m.useRef(null);e.current||(e.current=new gR);const t=e.current,[n,r]=m.useState([]),[s,i]=m.useState(null),[o,a]=m.useState("connecting"),[l,u]=m.useState({snapshot:null,warning:null}),[f,d]=m.useState(null),[h,p]=m.useState(null),[g,v]=m.useState({}),[S,y]=m.useState({}),[x,w]=m.useState({}),[E,I]=m.useState({}),k=m.useRef(null);k.current=s;const R=m.useRef([]);R.current=n,m.useEffect(()=>{const O=t.onState(a),W=t.onMessage(Q=>{switch(Q.type){case"sessions":r(Q.sessions??[]);break;case"messages":v(X=>({...X,[Q.id]:yR(X[Q.id],Q.messages??[])})),y(X=>({...X,[Q.id]:Q.pending??null}));break;case"append":v(X=>({...X,[Q.id]:[...X[Q.id]??[],...Q.messages??[]]}));break;case"pending":y(X=>({...X,[Q.id]:Q.pending})),r(X=>X.map(pe=>pe.id===Q.id?{...pe,pending:!!Q.pending}:pe));break;case"resources":u({snapshot:Q.snapshot??null,warning:Q.warning??null});break;case"capture":Q.id===k.current&&d(Q.text??"");break;case"shell-output":(!Q.id||Q.id===k.current)&&p(Q.text??"");break;case"prompt":I(X=>({...X,[Q.id]:Q.prompt}));break;case"subagents":w(X=>({...X,[Q.id]:Object.fromEntries((Q.subagents??[]).map(pe=>[pe.agentId,pe]))}));break;case"subagent":w(X=>({...X,[Q.id]:{...X[Q.id]??{},[Q.subagent.agentId]:Q.subagent}}));break;case"ack":window.dispatchEvent(new CustomEvent("cockpit:ack",{detail:Q}));break}});return t.connect(),()=>{O(),W()}},[t]),m.useEffect(()=>()=>t.close(),[t]);const M=m.useCallback(O=>{O!==k.current&&(i(O),d(null),t.select(O))},[t]),L=m.useCallback(O=>{const W=k.current;return!W||!O.trim()?!1:t.send({type:"reply",id:W,text:O})},[t]),_=m.useCallback((O,W)=>{const Q=k.current;return Q?t.send({type:"answer",id:Q,toolUseId:O,selections:W}):!1},[t]),z=m.useCallback((O,W)=>{const Q=k.current;return Q?t.send({type:"capture",id:Q,lines:O,escapes:W}):!1},[t]),N=m.useCallback(()=>d(null),[]),K=m.useCallback(O=>{const W=k.current;return W?t.send({type:"pane-text",id:W,text:O}):!1},[t]),P=m.useCallback(O=>{const W=k.current;return W?t.send({type:"pane-key",id:W,key:O}):!1},[t]),B=m.useCallback(O=>{const W=k.current;return W?t.send({type:"shell-input",id:W,line:O}):!1},[t]),ee=m.useCallback(O=>{const W=k.current;return W?t.send({type:"shell-text",id:W,text:O}):!1},[t]),ae=m.useCallback(O=>{const W=k.current;return W?t.send({type:"shell-key",id:W,key:O}):!1},[t]),F=m.useCallback(O=>{const W=k.current;return W?t.send({type:"shell-capture",id:W,lines:O}):!1},[t]),D=m.useCallback(()=>p(null),[]),b=m.useCallback(()=>t.resubscribe(),[t]),J=m.useCallback(O=>{const W=k.current;return W?t.send({type:"promptkey",id:W,key:O}):!1},[t]),Y=m.useMemo(()=>s?g[s]??[]:[],[s,g]),C=m.useMemo(()=>s?S[s]??null:null,[s,S]),ge=m.useMemo(()=>s?E[s]??null:null,[s,E]),A=m.useMemo(()=>{const O=s?x[s]:null;return O?Object.values(O).sort((W,Q)=>(Q.createdAt??-1/0)-(W.createdAt??-1/0)):[]},[s,x]);return{sessions:n,selectedId:s,messages:Y,pending:C,prompt:ge,subagents:A,conn:o,resources:l,capture:f,shellOutput:h,select:M,resubscribe:b,sendReply:L,sendPromptKey:J,sendAnswer:_,requestCapture:z,clearCapture:N,sendPaneText:K,sendPaneKey:P,sendShellInput:B,sendShellText:ee,sendShellKey:ae,requestShellCapture:F,clearShellOutput:D}}const jl="cc:push:intent";function xR(){return typeof window>"u"||!("serviceWorker"in navigator)||!("PushManager"in window)||!("Notification"in window)?!1:window.isSecureContext===!0}function wR(){if(typeof navigator>"u")return!1;const e=navigator.userAgent||"",t=/iPad|iPhone|iPod/.test(e),n=navigator.platform==="MacIntel"&&typeof navigator.maxTouchPoints=="number"&&navigator.maxTouchPoints>1;return t||n}function gp(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),s=new ArrayBuffer(r.length),i=new Uint8Array(s);for(let o=0;o<r.length;o+=1)i[o]=r.charCodeAt(o);return s}function bR(){const e=xR(),t=wR(),[n,r]=m.useState(e?"off":"unsupported"),s=m.useCallback(async()=>{const a=await navigator.serviceWorker.register("/sw.js");if(await navigator.serviceWorker.ready,await Notification.requestPermission()!=="granted")return r("denied"),!1;const u=await eR();if(!u)return r("off"),!1;let f=await a.pushManager.getSubscription();if(f)try{const h=gp(u),p=f.options?.applicationServerKey;let g=!1;if(p instanceof ArrayBuffer){const v=new Uint8Array(p),S=new Uint8Array(h);if(v.length!==S.length)g=!0;else for(let y=0;y<v.length;y++)if(v[y]!==S[y]){g=!0;break}}g&&(await f.unsubscribe(),f=null)}catch{}return f||(f=await a.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:gp(u)})),await tR(f.toJSON())},[]),i=m.useCallback(async()=>{if(e){r("working");try{await s()?(localStorage.setItem(jl,"1"),r("on")):r(l=>l==="denied"?"denied":"off")}catch{r("off")}}},[e,s]),o=m.useCallback(async()=>{r("working"),localStorage.removeItem(jl);try{const l=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();l&&(await nR(l.endpoint),await l.unsubscribe())}catch{}r("off")},[]);return m.useEffect(()=>{if(!e||localStorage.getItem(jl)!=="1")return;if(Notification.permission!=="granted"){r(Notification.permission==="denied"?"denied":"off");return}let a=!1;return(async()=>{try{const l=await s();a||r(l?"on":"off")}catch{a||r("off")}})(),()=>{a=!0}},[e,s]),{status:n,supported:e,iosHint:t,enable:i,disable:o}}const tc=70,SR=110,kR=.5,CR=".thread-viewport, .rail, .live-pane-body";function _R(e,t=()=>window.location.reload()){const[n,r]=m.useState(0),[s,i]=m.useState(!1),o=m.useRef(0),a=m.useRef(!1),l=m.useRef(0),u=m.useRef(null),f=d=>{o.current=d,r(d)};return m.useEffect(()=>{const d=e.current;if(!d)return;const h=v=>{if(v.touches.length!==1){a.current=!1;return}const y=v.target?.closest(CR)??null;y&&y.scrollTop<=0?(u.current=y,l.current=v.touches[0].clientY,a.current=!0):a.current=!1},p=v=>{if(!a.current)return;const S=v.touches[0].clientY-l.current,y=u.current;if(S<=0||y&&y.scrollTop>0){o.current!==0&&f(0),y&&y.scrollTop>0&&(a.current=!1);return}const x=Math.min(SR,S*kR);f(x),v.cancelable&&v.preventDefault()},g=()=>{a.current&&(a.current=!1,o.current>=tc?(f(tc),i(!0),setTimeout(t,150)):f(0))};return d.addEventListener("touchstart",h,{passive:!0}),d.addEventListener("touchmove",p,{passive:!1}),d.addEventListener("touchend",g,{passive:!0}),d.addEventListener("touchcancel",g,{passive:!0}),()=>{d.removeEventListener("touchstart",h),d.removeEventListener("touchmove",p),d.removeEventListener("touchend",g),d.removeEventListener("touchcancel",g)}},[e,t]),{pull:n,refreshing:s}}const ER=tc,da="__cockpitSummary";function TR(e){if(e&&typeof e=="object"&&da in e){const t=e[da];return typeof t=="string"?t:""}return""}function bw(e){if(!e||typeof e!="object")return e;const t={};for(const[n,r]of Object.entries(e))n!==da&&(t[n]=r);return t}function IR(e){if(e&&typeof e=="object"&&"text"in e){const t=e;return{text:String(t.text??""),isError:!!t.isError}}return null}function Sw(e){const t=new Map;for(const r of e)for(const s of r.blocks??[])s.kind==="tool_result"&&t.set(s.forId,{text:s.text??"",isError:!!s.isError});const n=[];return e.forEach((r,s)=>{const i=AR(r.blocks??[],t,r.role==="user");if(i.length===0)return;const o=r.role==="user"?"user":"assistant";n.push({role:o,id:r.uuid||`m-${s}`,createdAt:r.ts?new Date(r.ts):void 0,content:i,metadata:{custom:{cockpitRole:r.role}}})}),RR(n)}function RR(e){const t=r=>r.role==="assistant"&&(r.metadata?.custom?.cockpitRole??"assistant")==="assistant",n=[];for(const r of e){const s=n[n.length-1];s&&t(s)&&t(r)?n[n.length-1]={...s,content:[...s.content,...r.content]}:n.push(r)}return n}function PR(e){const t=e.trimStart();if(!t.startsWith("<"))return null;const n=/<summary>([\s\S]*?)<\/summary>/.exec(t)?.[1]?.trim();return t.startsWith("<task-notification")?`⚙ background task ${n?`— ${n}`:"update"}`:t.startsWith("<system-reminder")?"⚙ system reminder":t.startsWith("<command-name")||t.startsWith("<command-message")?"⌘ slash command":t.startsWith("<local-command-stdout")?"⌘ command output":t.startsWith("<user-prompt-submit-hook")||t.startsWith("<session-")?"⚙ session hook":null}function AR(e,t,n=!1){const r=[];for(const s of e)switch(s.kind){case"text":{if(s.text&&s.text.length>0){const i=n?PR(s.text):null;r.push({type:"text",text:i??s.text})}break}case"thinking":{s.text&&s.text.trim().length>0&&r.push({type:"reasoning",text:s.text});break}case"tool_use":{const i=t.get(s.id),o=s.input&&typeof s.input=="object"?s.input:s.input!=null?{value:s.input}:{};r.push({type:"tool-call",toolCallId:s.id,toolName:s.name||"tool",args:{...o,[da]:s.inputSummary??""},argsText:s.inputSummary??"",result:i??void 0,isError:i?.isError});break}}return r}const jR="image/*,application/pdf,text/*,.md,.json,.csv,.log",nc=" cockpit-path:";function NR(e){return nc+e}const _o=new Map;function MR(e){return _o.get(e)??null}function DR(e){for(const t of e.content??[])if(t.type==="text"&&t.text.startsWith(nc))return t.text.slice(nc.length);return MR(e.id)}function LR(e){return`${e.name}-${e.size}-${e.lastModified}`}function OR(e){return{accept:jR,async add({file:t}){const n=LR(t),r=t.type.startsWith("image/"),s=t.type==="application/pdf",i={id:n,type:r?"image":s?"document":"file",name:t.name,contentType:t.type||"application/octet-stream",file:t};e(`Uploading ${t.name}…`);try{const o=await hR(t);return _o.set(n,o.path),e(`Attached ${o.name}`,"ok"),{...i,status:{type:"requires-action",reason:"composer-send"}}}catch(o){const a=o instanceof Error?o.message:String(o);return e(`Attach failed: ${a}`,"error"),{...i,status:{type:"incomplete",reason:"error"}}}},async send(t){const n=_o.get(t.id);if(!n)throw new Error(`attachment ${t.name} was not uploaded`);return{...t,status:{type:"complete"},content:[{type:"text",text:NR(n)}]}},async remove(t){_o.delete(t.id)}}}function zR(e){if(!e)return"";const t=e.replace(/\/$/,"").split("/");return t[t.length-1]||e}function FR(e){const t=new Map;for(const n of e){const r=n.sessionName??"?",s=n.windowIndex??0;t.has(r)||t.set(r,new Map);const i=t.get(r);i.has(s)||i.set(s,[]),i.get(s).push(n)}return[...t.entries()].sort(([n],[r])=>n.localeCompare(r,void 0,{numeric:!0})).map(([n,r])=>({sessionName:n,windows:[...r.entries()].sort(([s],[i])=>s-i).map(([s,i])=>({windowIndex:s,windowName:i[0]?.tmuxName||`window ${s}`,panes:[...i].sort((o,a)=>(o.paneIndex??0)-(a.paneIndex??0))}))}))}function BR({s:e,selected:t,onSelect:n}){const r=e.kind==="terminal",s=r?e.ccShell?`shell · ${e.cmd||"sh"}`:e.cmd||e.tmuxName||"shell":e.title||e.name||e.id;return c.jsxs("li",{role:"option","aria-selected":t,tabIndex:0,className:"session-item","data-active":e.active?"true":"false","data-selected":t?"true":"false","data-kind":e.kind??"claude",onClick:()=>n(e.id),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),n(e.id))},children:[c.jsxs("div",{className:"session-top",children:[c.jsx("span",{className:"active-dot","data-on":e.active?"true":"false","aria-hidden":"true"}),c.jsx("span",{className:"pane-glyph","aria-hidden":"true",children:r?">_":"✳"}),c.jsx("span",{className:"session-name",children:s}),e.pending?c.jsx("span",{className:"ask-badge","aria-label":"pending question",children:"ASK"}):null]}),c.jsxs("div",{className:"session-meta",children:[c.jsxs("span",{className:"meta-prov",children:["p",e.paneIndex??0]}),r?e.cwd?c.jsx("span",{className:"meta-cwd",children:zR(e.cwd)}):null:c.jsxs(c.Fragment,{children:[e.model?c.jsx("span",{className:"meta-model",children:e.model}):null,e.ctxPct!=null?c.jsxs("span",{className:"meta-ctx",children:["ctx:",Math.round(e.ctxPct),"%"]}):null]})]})]})}function $R({sessions:e,selectedId:t,onSelect:n}){const r=m.useMemo(()=>FR(e),[e]);return r.length===0?c.jsx("div",{className:"session-list",role:"listbox","aria-label":"Sessions",children:c.jsx("div",{className:"session-empty",children:"no tmux panes"})}):c.jsx("div",{className:"session-list",role:"listbox","aria-label":"Sessions",children:r.map(s=>c.jsxs("section",{className:"session-group",children:[c.jsx("div",{className:"session-group-head",children:s.sessionName}),s.windows.map(i=>c.jsxs("div",{className:"session-window",children:[c.jsxs("div",{className:"session-window-head",children:[c.jsx("span",{className:"window-idx",children:i.windowIndex}),c.jsx("span",{className:"window-name",children:i.windowName})]}),c.jsx("ul",{className:"session-pane-list",children:i.panes.map(o=>c.jsx(BR,{s:o,selected:o.id===t,onSelect:n},o.id))})]},i.windowIndex))]},s.sessionName))})}const UR={on:"Notifications on",off:"Enable notifications",denied:"Notifications blocked",unsupported:"Notifications unsupported",working:"Working…"};function VR({push:e}){const{status:t,supported:n,enable:r,disable:s}=e,i=t==="on",o=!n||t==="unsupported"||t==="working"||t==="denied",a=UR[t]??"Notifications",l=()=>{o||(i?s():r())};return c.jsx("button",{type:"button",className:"notify-bell","data-state":t,"aria-pressed":i,"aria-label":a,title:a,disabled:o,onClick:l,children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24","aria-hidden":"true",children:[c.jsx("path",{d:"M12 22a2.5 2.5 0 0 0 2.45-2h-4.9A2.5 2.5 0 0 0 12 22Zm7-5-1.6-1.6V10a5.4 5.4 0 0 0-4-5.2V4a1.4 1.4 0 0 0-2.8 0v.8A5.4 5.4 0 0 0 6.6 10v5.4L5 17v1h14Z",fill:i?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),t==="denied"||t==="unsupported"?c.jsx("line",{x1:"4",y1:"4",x2:"20",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}):null]})})}function HR({size:e=18}){return c.jsxs("svg",{width:e,height:Math.round(e*1.2),viewBox:"0 0 10 12","aria-hidden":"true",focusable:"false",style:{display:"block",flexShrink:0},children:[c.jsx("rect",{x:"1",y:"2",width:"8",height:"7",fill:"#c97c5a"}),c.jsx("rect",{x:"0",y:"3",width:"1",height:"2",fill:"#c97c5a"}),c.jsx("rect",{x:"9",y:"3",width:"1",height:"2",fill:"#c97c5a"}),c.jsx("rect",{x:"2",y:"4",width:"2",height:"2",fill:"var(--bg)"}),c.jsx("rect",{x:"6",y:"4",width:"2",height:"2",fill:"var(--bg)"}),c.jsx("rect",{x:"2",y:"9",width:"2",height:"2",fill:"#c97c5a"}),c.jsx("rect",{x:"6",y:"9",width:"2",height:"2",fill:"#c97c5a"})]})}function yp(e,t=""){return e!=null?`${Math.round(e)}${t}`:"—"}function WR({resources:e,conn:t,push:n}){const r=e.snapshot,s=r?.self??{},i=r?.system??{},o=!!r?.overLimit||!!e.warning,a=i.loadavg?.[0];return c.jsxs("div",{className:"hud","data-warn":o?"true":"false",role:"status",children:[c.jsxs("span",{className:"hud-brand",children:[c.jsx(HR,{size:18}),"claude control"]}),c.jsx("span",{className:`conn-dot conn-${t}`,title:t,"aria-label":t}),c.jsxs("span",{className:"hud-group",children:[c.jsx("span",{className:"hud-k",children:"cpu"}),c.jsx("span",{className:"hud-v",children:s.cpuPct!=null?`${s.cpuPct.toFixed(0)}%`:"—"})]}),c.jsxs("span",{className:"hud-group",children:[c.jsx("span",{className:"hud-k",children:"rss"}),c.jsx("span",{className:"hud-v",children:yp(s.rssMB,"m")})]}),c.jsxs("span",{className:"hud-group",children:[c.jsx("span",{className:"hud-k",children:"load"}),c.jsx("span",{className:"hud-v",children:a!=null?a.toFixed(2):"—"})]}),c.jsxs("span",{className:"hud-group",children:[c.jsx("span",{className:"hud-k",children:"mem"}),c.jsx("span",{className:"hud-v",children:yp(i.memUsedPct,"%")})]}),o?c.jsx("span",{className:"hud-warn-text",children:e.warning||"over limit"}):null,c.jsx("span",{className:"hud-spacer"}),c.jsx(VR,{push:n})]})}const qR={direction:"down",stagger:45,duration:300,exitOffset:50,easing:"cubic-bezier(0.34, 1.56, 0.64, 1)",bounce:.6,colorFade:280,skipUnchanged:!0,interrupt:!0},KR=" ",Md=e=>e===" "?KR:e,Js=new WeakMap;function kw(e){const t=Js.get(e);t&&(t.timers.forEach(n=>window.clearTimeout(n)),Js.delete(e),fa(e,t.target))}function Cw(e){const t=document.createElement("span");return t.className="char-face",t.textContent=Md(e),t}function _w(e){const t=document.createElement("span");t.className="char-slot",t.dataset.char=e;const n=document.createElement("span");return n.className="char-sizer",n.textContent=Md(e),t.append(n,Cw(e)),t}function fa(e,t){e.classList.add("slot-text"),e.replaceChildren(...Array.from(t,_w))}function Ew(e,t,n={}){const{direction:r,stagger:s,duration:i,exitOffset:o,easing:a,bounce:l,color:u,colorFade:f,skipUnchanged:d,interrupt:h}={...qR,...n},p=Js.get(e);if(p&&!h){t!==p.target&&(p.pending={text:t,options:n});return}if(kw(e),!e.querySelector(".char-slot")){fa(e,t);return}const g=Array.from(e.querySelectorAll(".char-slot")),v=g.map(N=>N.dataset.char??"").join("");if(!h&&v===t)return;const S=Math.max(v.length,t.length),y=g.find(N=>(N.dataset.char??"")!=="")??g[0],x=getComputedStyle(e),w=Math.ceil(y?.getBoundingClientRect().height||y?.offsetHeight||e.getBoundingClientRect().height||parseFloat(x.lineHeight)||0)||Math.ceil(parseFloat(x.fontSize)*1.3)||18,E=u?x.color:"";for(let N=g.length;N<S;N++){const K=_w("");e.appendChild(K),g.push(K)}const I=[],k={timers:I,target:t};Js.set(e,k);const R=r==="down"?w:-w,M=r==="down"?-w:w,L=(N,K)=>{const P=Math.sin((N+1)*12.9898+K*78.233)*43758.5453;return(P-Math.floor(P))*2-1};let _=0;for(let N=0;N<S;N++){const K=v[N]||"",P=t[N]||"";if(K===P&&(d||K===""))continue;const B=g[N],ee=B.querySelector(".char-sizer"),ae=B.querySelector(".char-face"),F=B.getBoundingClientRect().width;ee.textContent=Md(P);const D=ee.getBoundingClientRect().width,b=Math.abs(D-F)>.5;b&&(B.style.width=`${F}px`),(K===""||P==="")&&B.classList.add("is-resizing");const J=typeof u=="function"?u(N,S):u,Y=P==="",C=Math.round(i*(Y?.75:1)*(1+l*.45*L(N,1))),ge=Y?t.length*.5+(N-t.length)*.25:N,A=Math.round(ge*s*(1+l*.25*L(N,2))),O=(l*5*L(N,3)).toFixed(2),W=`transform ${C}ms ${a}`,Q=u?`${W}, color ${f}ms linear ${C}ms`:W,X=Cw(P);if(X.style.transformOrigin="50% 50%",X.style.transform=`translateY(${M}px) rotate(${O}deg)`,J&&(X.style.color=J),B.appendChild(X),B.offsetWidth,b){let pe=A,_e=C;Y?(pe=A+Math.round(C*.55),_e=Math.max(140,Math.round(C*.6))):K===""&&(_e=Math.max(140,Math.round(C*.45))),I.push(window.setTimeout(()=>{B.style.transition=`width ${_e}ms cubic-bezier(0.2, 0, 0, 1)`,B.style.width=`${D}px`},pe)),_=Math.max(_,pe+_e)}_=Math.max(_,A+o+C+(u?f:0)),ae&&I.push(window.setTimeout(()=>{ae.style.transition=W,ae.style.transform=`translateY(${R}px) rotate(${-Number(O)}deg)`},A)),I.push(window.setTimeout(()=>{X.style.transition=Q,X.style.transform="translateY(0) rotate(0deg)",u&&(X.style.color=E);const pe=_e=>{_e.propertyName==="transform"&&(X.removeEventListener("transitionend",pe),B.dataset.char=P,B.style.removeProperty("transition"),B.style.removeProperty("width"),B.classList.remove("is-resizing"),B.querySelectorAll(".char-face").forEach(ze=>{ze!==X&&ze.remove()}))};X.addEventListener("transitionend",pe)},A+o))}const z=_+80;I.push(window.setTimeout(()=>{const N=k.pending;Js.delete(e),fa(e,t),N&&Ew(e,N.text,N.options)},z))}function GR(e,t=""){kw(e),e.classList.remove("slot-text"),e.textContent=t}const Tw=m.forwardRef(({text:e,options:t,"aria-label":n,...r},s)=>{const i=m.useRef(null),o=m.useRef(!1),a=m.useRef(!0),l=m.useRef(t);return m.useImperativeHandle(s,()=>i.current,[]),m.useEffect(()=>{l.current=t},[t]),m.useEffect(()=>{const u=i.current;if(u)return fa(u,e),o.current=!0,()=>{GR(u),o.current=!1,a.current=!0}},[]),m.useEffect(()=>{const u=i.current;if(!(!u||!o.current)){if(a.current){a.current=!1;return}Ew(u,e,l.current)}},[e]),m.createElement("span",{...r,"aria-label":n??e,ref:i})});Tw.displayName="SlotText";const QR=(e,t)=>typeof e=="string"?e===t:JSON.stringify(e)===JSON.stringify(t),YR=(e,t)=>{if(!e||!t)return!1;const n=r=>{const{position:s,data:i,...o}=r||{};return o};return JSON.stringify(n(e.properties))===JSON.stringify(n(t.properties))&&QR(e.children,t.children)},Iw=(e,t)=>YR(e.node,t.node),Dd=m.createContext(null),JR=()=>m.useContext(Dd)!==null,XR=({children:e,...t})=>c.jsx(Dd.Provider,{value:t,children:e}),ZR=m.memo(XR,Iw),eP=({node:e,...t})=>c.jsx("pre",{...t}),tP=({node:e,...t})=>c.jsx("code",{...t}),Ld=({node:e,components:{Pre:t,Code:n},code:r})=>c.jsx(t,{children:c.jsx(n,{node:e,children:r})}),nP=()=>null,rP=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:s},language:i,code:o})=>{const a=m.useMemo(()=>({Pre:t,Code:n}),[t,n]);return c.jsxs(c.Fragment,{children:[c.jsx(s,{node:e,language:i,code:o}),c.jsx(i?r:Ld,{node:e,components:a,language:i??"unknown",code:o})]})};var Rw={exports:{}};/*!
|
|
45
45
|
Copyright (c) 2018 Jed Watson.
|
|
46
46
|
Licensed under the MIT License (MIT), see
|
|
47
47
|
http://jedwatson.github.io/classnames
|
|
48
|
-
*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var i="",o=0;o<arguments.length;o++){var a=arguments[o];a&&(i=s(i,r(a)))}return i}function r(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return n.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var o="";for(var a in i)t.call(i,a)&&i[a]&&(o=s(o,a));return o}function s(i,o){return o?i?i+" "+o:i+o:i}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Iw);var nP=Iw.exports;const Rw=Ei(nP),vp=({className:e,...t})=>({className:n,...r})=>({className:Rw(e,n),...t,...r}),rP=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:s},componentsByLanguage:i={},children:o,...a})=>{const l=vp(m.useContext(Dd)),u=mr(p=>c.jsx(t,{...l(p)})),f=vp(a),d=mr(p=>c.jsx(n,{...f(p)})),h=/language-(\w+)/.exec(a.className||"")?.[1]??"";return typeof o!="string"?c.jsx(Ld,{node:e,components:{Pre:u,Code:d},code:o}):c.jsx(tP,{node:e,components:{Pre:u,Code:d,SyntaxHighlighter:i[h]?.SyntaxHighlighter??r,CodeHeader:i[h]?.CodeHeader??s},language:h||"unknown",code:o})},sP=({node:e,components:t,componentsByLanguage:n,...r})=>QR()?c.jsx(rP,{node:e,components:t,componentsByLanguage:n,...r}):c.jsx(t.Code,{...r}),iP=m.memo(sP,(e,t)=>e.components===t.components&&e.componentsByLanguage===t.componentsByLanguage&&Tw(e,t));function oP(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const aP=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lP=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,uP={};function xp(e,t){return(uP.jsx?lP:aP).test(e)}const cP=/[ \t\n\f\r]/g;function dP(e){return typeof e=="object"?e.type==="text"?wp(e.value):!1:wp(e)}function wp(e){return e.replace(cP,"")===""}class ji{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}ji.prototype.normal={};ji.prototype.property={};ji.prototype.space=void 0;function Pw(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new ji(n,r,t)}function rc(e){return e.toLowerCase()}class mt{constructor(t,n){this.attribute=n,this.property=t}}mt.prototype.attribute="";mt.prototype.booleanish=!1;mt.prototype.boolean=!1;mt.prototype.commaOrSpaceSeparated=!1;mt.prototype.commaSeparated=!1;mt.prototype.defined=!1;mt.prototype.mustUseProperty=!1;mt.prototype.number=!1;mt.prototype.overloadedBoolean=!1;mt.prototype.property="";mt.prototype.spaceSeparated=!1;mt.prototype.space=void 0;let fP=0;const te=Cr(),Me=Cr(),sc=Cr(),U=Cr(),ve=Cr(),lr=Cr(),yt=Cr();function Cr(){return 2**++fP}const ic=Object.freeze(Object.defineProperty({__proto__:null,boolean:te,booleanish:Me,commaOrSpaceSeparated:yt,commaSeparated:lr,number:U,overloadedBoolean:sc,spaceSeparated:ve},Symbol.toStringTag,{value:"Module"})),Nl=Object.keys(ic);class Od extends mt{constructor(t,n,r,s){let i=-1;if(super(t,n),bp(this,"space",s),typeof r=="number")for(;++i<Nl.length;){const o=Nl[i];bp(this,Nl[i],(r&ic[o])===ic[o])}}}Od.prototype.defined=!0;function bp(e,t,n){n&&(e[t]=n)}function ys(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new Od(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[rc(r)]=r,n[rc(i.attribute)]=r}return new ji(t,n,e.space)}const Aw=ys({properties:{ariaActiveDescendant:null,ariaAtomic:Me,ariaAutoComplete:null,ariaBusy:Me,ariaChecked:Me,ariaColCount:U,ariaColIndex:U,ariaColSpan:U,ariaControls:ve,ariaCurrent:null,ariaDescribedBy:ve,ariaDetails:null,ariaDisabled:Me,ariaDropEffect:ve,ariaErrorMessage:null,ariaExpanded:Me,ariaFlowTo:ve,ariaGrabbed:Me,ariaHasPopup:null,ariaHidden:Me,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ve,ariaLevel:U,ariaLive:null,ariaModal:Me,ariaMultiLine:Me,ariaMultiSelectable:Me,ariaOrientation:null,ariaOwns:ve,ariaPlaceholder:null,ariaPosInSet:U,ariaPressed:Me,ariaReadOnly:Me,ariaRelevant:null,ariaRequired:Me,ariaRoleDescription:ve,ariaRowCount:U,ariaRowIndex:U,ariaRowSpan:U,ariaSelected:Me,ariaSetSize:U,ariaSort:null,ariaValueMax:U,ariaValueMin:U,ariaValueNow:U,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function jw(e,t){return t in e?e[t]:t}function Nw(e,t){return jw(e,t.toLowerCase())}const hP=ys({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:lr,acceptCharset:ve,accessKey:ve,action:null,allow:null,allowFullScreen:te,allowPaymentRequest:te,allowUserMedia:te,alpha:te,alt:null,as:null,async:te,autoCapitalize:null,autoComplete:ve,autoFocus:te,autoPlay:te,blocking:ve,capture:null,charSet:null,checked:te,cite:null,className:ve,closedBy:null,colorSpace:null,cols:U,colSpan:U,command:null,commandFor:null,content:null,contentEditable:Me,controls:te,controlsList:ve,coords:U|lr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:te,defer:te,dir:null,dirName:null,disabled:te,download:sc,draggable:Me,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:te,formTarget:null,headers:ve,height:U,hidden:sc,high:U,href:null,hrefLang:null,htmlFor:ve,httpEquiv:ve,id:null,imageSizes:null,imageSrcSet:null,inert:te,inputMode:null,integrity:null,is:null,isMap:te,itemId:null,itemProp:ve,itemRef:ve,itemScope:te,itemType:ve,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:te,low:U,manifest:null,max:null,maxLength:U,media:null,method:null,min:null,minLength:U,multiple:te,muted:te,name:null,nonce:null,noModule:te,noValidate:te,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:te,optimum:U,pattern:null,ping:ve,placeholder:null,playsInline:te,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:te,referrerPolicy:null,rel:ve,required:te,reversed:te,rows:U,rowSpan:U,sandbox:ve,scope:null,scoped:te,seamless:te,selected:te,shadowRootClonable:te,shadowRootCustomElementRegistry:te,shadowRootDelegatesFocus:te,shadowRootMode:null,shadowRootSerializable:te,shape:null,size:U,sizes:null,slot:null,span:U,spellCheck:Me,src:null,srcDoc:null,srcLang:null,srcSet:null,start:U,step:null,style:null,tabIndex:U,target:null,title:null,translate:null,type:null,typeMustMatch:te,useMap:null,value:Me,width:U,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ve,axis:null,background:null,bgColor:null,border:U,borderColor:null,bottomMargin:U,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:te,declare:te,event:null,face:null,frame:null,frameBorder:null,hSpace:U,leftMargin:U,link:null,longDesc:null,lowSrc:null,marginHeight:U,marginWidth:U,noResize:te,noHref:te,noShade:te,noWrap:te,object:null,profile:null,prompt:null,rev:null,rightMargin:U,rules:null,scheme:null,scrolling:Me,standby:null,summary:null,text:null,topMargin:U,valueType:null,version:null,vAlign:null,vLink:null,vSpace:U,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:te,disablePictureInPicture:te,disableRemotePlayback:te,exportParts:lr,part:ve,prefix:null,property:null,results:U,security:null,unselectable:null},space:"html",transform:Nw}),pP=ys({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:yt,accentHeight:U,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:U,amplitude:U,arabicForm:null,ascent:U,attributeName:null,attributeType:null,azimuth:U,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:U,by:null,calcMode:null,capHeight:U,className:ve,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:U,diffuseConstant:U,direction:null,display:null,dur:null,divisor:U,dominantBaseline:null,download:te,dx:null,dy:null,edgeMode:null,editable:null,elevation:U,enableBackground:null,end:null,event:null,exponent:U,externalResourcesRequired:null,fill:null,fillOpacity:U,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:lr,g2:lr,glyphName:lr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:U,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:U,horizOriginX:U,horizOriginY:U,id:null,ideographic:U,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:U,k:U,k1:U,k2:U,k3:U,k4:U,kernelMatrix:yt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:U,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:U,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:U,overlineThickness:U,paintOrder:null,panose1:null,path:null,pathLength:U,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ve,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:U,pointsAtY:U,pointsAtZ:U,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:yt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:yt,rev:yt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:yt,requiredFeatures:yt,requiredFonts:yt,requiredFormats:yt,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:U,specularExponent:U,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:U,strikethroughThickness:U,string:null,stroke:null,strokeDashArray:yt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:U,strokeOpacity:U,strokeWidth:null,style:null,surfaceScale:U,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:yt,tabIndex:U,tableValues:null,target:null,targetX:U,targetY:U,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:yt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:U,underlineThickness:U,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:U,values:null,vAlphabetic:U,vMathematical:U,vectorEffect:null,vHanging:U,vIdeographic:U,version:null,vertAdvY:U,vertOriginX:U,vertOriginY:U,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:U,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:jw}),Mw=ys({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Dw=ys({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Nw}),Lw=ys({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),mP={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"},gP=/[A-Z]/g,Sp=/-[a-z]/g,yP=/^data[-\w.:]+$/i;function vP(e,t){const n=rc(t);let r=t,s=mt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&yP.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(Sp,wP);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!Sp.test(i)){let o=i.replace(gP,xP);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}s=Od}return new s(r,t)}function xP(e){return"-"+e.toLowerCase()}function wP(e){return e.charAt(1).toUpperCase()}const bP=Pw([Aw,hP,Mw,Dw,Lw],"html"),zd=Pw([Aw,pP,Mw,Dw,Lw],"svg");function SP(e){return e.join(" ").trim()}var Fd={},kp=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,kP=/\n/g,CP=/^\s*/,_P=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,EP=/^:\s*/,TP=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,IP=/^[;\s]*/,RP=/^\s+|\s+$/g,PP=`
|
|
49
|
-
`,Cp="/",_p="*",er="",AP="comment",jP="declaration";function NP(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(g){var x=g.match(kP);x&&(n+=x.length);var k=g.lastIndexOf(PP);r=~k?g.length-k:r+g.length}function i(){var g={line:n,column:r};return function(x){return x.position=new o(g),u(),x}}function o(g){this.start=g,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function a(g){var x=new Error(t.source+":"+n+":"+r+": "+g);if(x.reason=g,x.filename=t.source,x.line=n,x.column=r,x.source=e,!t.silent)throw x}function l(g){var x=g.exec(e);if(x){var k=x[0];return s(k),e=e.slice(k.length),x}}function u(){l(CP)}function f(g){var x;for(g=g||[];x=d();)x!==!1&&g.push(x);return g}function d(){var g=i();if(!(Cp!=e.charAt(0)||_p!=e.charAt(1))){for(var x=2;er!=e.charAt(x)&&(_p!=e.charAt(x)||Cp!=e.charAt(x+1));)++x;if(x+=2,er===e.charAt(x-1))return a("End of comment missing");var k=e.slice(2,x-2);return r+=2,s(k),e=e.slice(x),r+=2,g({type:AP,comment:k})}}function h(){var g=i(),x=l(_P);if(x){if(d(),!l(EP))return a("property missing ':'");var k=l(TP),y=g({type:jP,property:Ep(x[0].replace(kp,er)),value:k?Ep(k[0].replace(kp,er)):er});return l(IP),y}}function p(){var g=[];f(g);for(var x;x=h();)x!==!1&&(g.push(x),f(g));return g}return u(),p()}function Ep(e){return e?e.replace(RP,er):er}var MP=NP,DP=Io&&Io.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Fd,"__esModule",{value:!0});Fd.default=OP;const LP=DP(MP);function OP(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,LP.default)(e),s=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;const{property:o,value:a}=i;s?t(o,a,i):a&&(n=n||{},n[o]=a)}),n}var Va={};Object.defineProperty(Va,"__esModule",{value:!0});Va.camelCase=void 0;var zP=/^--[a-zA-Z0-9_-]+$/,FP=/-([a-z])/g,BP=/^[^-]+$/,$P=/^-(webkit|moz|ms|o|khtml)-/,UP=/^-(ms)-/,VP=function(e){return!e||BP.test(e)||zP.test(e)},HP=function(e,t){return t.toUpperCase()},Tp=function(e,t){return"".concat(t,"-")},WP=function(e,t){return t===void 0&&(t={}),VP(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(UP,Tp):e=e.replace($P,Tp),e.replace(FP,HP))};Va.camelCase=WP;var qP=Io&&Io.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},KP=qP(Fd),GP=Va;function oc(e,t){var n={};return!e||typeof e!="string"||(0,KP.default)(e,function(r,s){r&&s&&(n[(0,GP.camelCase)(r,t)]=s)}),n}oc.default=oc;var QP=oc;const YP=Ei(QP),Ow=zw("end"),Bd=zw("start");function zw(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};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 JP(e){const t=Bd(e),n=Ow(e);if(t&&n)return{start:t,end:n}}function Xs(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Ip(e.position):"start"in e||"end"in e?Ip(e):"line"in e||"column"in e?ac(e):""}function ac(e){return Rp(e&&e.line)+":"+Rp(e&&e.column)}function Ip(e){return ac(e&&e.start)+"-"+ac(e&&e.end)}function Rp(e){return e&&typeof e=="number"?e:1}class Ze extends Error{constructor(t,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 t=="string"?s=t:!i.cause&&t&&(o=!0,s=t.message,i.cause=t),!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=Xs(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}}Ze.prototype.file="";Ze.prototype.name="";Ze.prototype.reason="";Ze.prototype.message="";Ze.prototype.stack="";Ze.prototype.column=void 0;Ze.prototype.line=void 0;Ze.prototype.ancestors=void 0;Ze.prototype.cause=void 0;Ze.prototype.fatal=void 0;Ze.prototype.place=void 0;Ze.prototype.ruleId=void 0;Ze.prototype.source=void 0;const $d={}.hasOwnProperty,XP=new Map,ZP=/[A-Z]/g,eA=new Set(["table","tbody","thead","tfoot","tr"]),tA=new Set(["td","th"]),Fw="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function nA(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=cA(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=uA(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?zd:bP,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=Bw(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function Bw(e,t,n){if(t.type==="element")return rA(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return sA(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return oA(e,t,n);if(t.type==="mdxjsEsm")return iA(e,t);if(t.type==="root")return aA(e,t,n);if(t.type==="text")return lA(e,t)}function rA(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=zd,e.schema=s),e.ancestors.push(t);const i=Uw(e,t.tagName,!1),o=dA(e,t);let a=Vd(e,t);return eA.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!dP(l):!0})),$w(e,o,i,t),Ud(o,a),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function sA(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ki(e,t.position)}function iA(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ki(e,t.position)}function oA(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=zd,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:Uw(e,t.name,!0),o=fA(e,t),a=Vd(e,t);return $w(e,o,i,t),Ud(o,a),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function aA(e,t,n){const r={};return Ud(r,Vd(e,t)),e.create(t,e.Fragment,r,n)}function lA(e,t){return t.value}function $w(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Ud(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function uA(e,t,n){return r;function r(s,i,o,a){const u=Array.isArray(o.children)?n:t;return a?u(i,o,a):u(i,o)}}function cA(e,t){return n;function n(r,s,i,o){const a=Array.isArray(i.children),l=Bd(r);return t(s,i,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function dA(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&$d.call(t.properties,s)){const i=hA(e,s,t.properties[s]);if(i){const[o,a]=i;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&tA.has(t.tagName)?r=a:n[o]=a}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function fA(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.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,e.evaluater.evaluateExpression(a.argument))}else ki(e,t.position);else{const s=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,i=e.evaluater.evaluateExpression(a.expression)}else ki(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function Vd(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:XP;for(;++r<t.children.length;){const i=t.children[r];let o;if(e.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=Bw(e,i,o);a!==void 0&&n.push(a)}return n}function hA(e,t,n){const r=vP(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?oP(n):SP(n)),r.property==="style"){let s=typeof n=="object"?n:pA(e,String(n));return e.stylePropertyNameCase==="css"&&(s=mA(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?mP[r.property]||r.property:r.attribute,n]}}function pA(e,t){try{return YP(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Ze("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=Fw+"#cannot-parse-style-attribute",s}}function Uw(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let i=-1,o;for(;++i<s.length;){const a=xp(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=xp(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return $d.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);ki(e)}function ki(e,t){const n=new Ze("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Fw+"#cannot-handle-mdx-estrees-without-createevaluater",n}function mA(e){const t={};let n;for(n in e)$d.call(e,n)&&(t[gA(n)]=e[n]);return t}function gA(e){let t=e.replace(ZP,yA);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function yA(e){return"-"+e.toLowerCase()}const Ml={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"]},vA={};function Hd(e,t){const n=vA,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Vw(e,r,s)}function Vw(e,t,n){if(xA(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Pp(e.children,t,n)}return Array.isArray(e)?Pp(e,t,n):""}function Pp(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=Vw(e[s],t,n);return r.join("")}function xA(e){return!!(e&&typeof e=="object")}const Ap=document.createElement("i");function Wd(e){const t="&"+e+";";Ap.innerHTML=t;const n=Ap.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function bt(e,t,n,r){const s=e.length;let i=0,o;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);i<r.length;)o=r.slice(i,i+1e4),o.unshift(t,0),e.splice(...o),i+=1e4,t+=1e4}function It(e,t){return e.length>0?(bt(e,e.length,0,t),e):t}const jp={}.hasOwnProperty;function Hw(e){const t={};let n=-1;for(;++n<e.length;)wA(t,e[n]);return t}function wA(e,t){let n;for(n in t){const s=(jp.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let o;if(i)for(o in i){jp.call(s,o)||(s[o]=[]);const a=i[o];bA(s[o],Array.isArray(a)?a:a?[a]:[])}}}function bA(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);bt(e,0,0,r)}function Ww(e,t){const n=Number.parseInt(e,t);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 Ut(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const nt=Gn(/[A-Za-z]/),Je=Gn(/[\dA-Za-z]/),SA=Gn(/[#-'*+\--9=?A-Z^-~]/);function ha(e){return e!==null&&(e<32||e===127)}const lc=Gn(/\d/),kA=Gn(/[\dA-Fa-f]/),CA=Gn(/[!-/:-@[-`{-~]/);function Z(e){return e!==null&&e<-2}function xe(e){return e!==null&&(e<0||e===32)}function le(e){return e===-2||e===-1||e===32}const Ha=Gn(/\p{P}|\p{S}/u),gr=Gn(/\s/);function Gn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function vs(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const i=e.charCodeAt(n);let o="";if(i===37&&Je(e.charCodeAt(n+1))&&Je(e.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=e.charCodeAt(n+1);i<56320&&a>56319&&a<57344?(o=String.fromCharCode(i,a),s=1):o="�"}else o=String.fromCharCode(i);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+s+1,o=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function fe(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return o;function o(l){return le(l)?(e.enter(n),a(l)):t(l)}function a(l){return le(l)&&i++<s?(e.consume(l),a):(e.exit(n),t(l))}}const _A={tokenize:EA};function EA(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),fe(e,t,"linePrefix")}function s(a){return e.enter("paragraph"),i(a)}function i(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return Z(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),o)}}const TA={tokenize:IA},Np={tokenize:RA};function IA(e){const t=this,n=[];let r=0,s,i,o;return a;function a(w){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,l,u)(w)}return u(w)}function l(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&v();const E=t.events.length;let I=E,S;for(;I--;)if(t.events[I][0]==="exit"&&t.events[I][1].type==="chunkFlow"){S=t.events[I][1].end;break}y(r);let R=E;for(;R<t.events.length;)t.events[R][1].end={...S},R++;return bt(t.events,I+1,0,t.events.slice(E)),t.events.length=R,u(w)}return a(w)}function u(w){if(r===n.length){if(!s)return h(w);if(s.currentConstruct&&s.currentConstruct.concrete)return g(w);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Np,f,d)(w)}function f(w){return s&&v(),y(r),h(w)}function d(w){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(w)}function h(w){return t.containerState={},e.attempt(Np,p,g)(w)}function p(w){return r++,n.push([t.currentConstruct,t.containerState]),h(w)}function g(w){if(w===null){s&&v(),y(0),e.consume(w);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),x(w)}function x(w){if(w===null){k(e.exit("chunkFlow"),!0),y(0),e.consume(w);return}return Z(w)?(e.consume(w),k(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(w),x)}function k(w,E){const I=t.sliceStream(w);if(E&&I.push(null),w.previous=i,i&&(i.next=w),i=w,s.defineSkip(w.start),s.write(I),t.parser.lazy[w.start.line]){let S=s.events.length;for(;S--;)if(s.events[S][1].start.offset<o&&(!s.events[S][1].end||s.events[S][1].end.offset>o))return;const R=t.events.length;let N=R,D,_;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){if(D){_=t.events[N][1].end;break}D=!0}for(y(r),S=R;S<t.events.length;)t.events[S][1].end={..._},S++;bt(t.events,N+1,0,t.events.slice(R)),t.events.length=S}}function y(w){let E=n.length;for(;E-- >w;){const I=n[E];t.containerState=I[1],I[0].exit.call(t,e)}n.length=w}function v(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function RA(e,t,n){return fe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ls(e){if(e===null||xe(e)||gr(e))return 1;if(Ha(e))return 2}function Wa(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const i=e[s].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const uc={name:"attention",resolveAll:PA,tokenize:AA};function PA(e,t){let n=-1,r,s,i,o,a,l,u,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},h={...e[n][1].start};Mp(d,-l),Mp(h,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},i={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=It(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=It(u,[["enter",s,t],["enter",o,t],["exit",o,t],["enter",i,t]]),u=It(u,Wa(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=It(u,[["exit",i,t],["enter",a,t],["exit",a,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,u=It(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,bt(e,r-1,n-r+3,u),n=r+u.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function AA(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=ls(r);let i;return o;function o(l){return i=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===i)return e.consume(l),a;const u=e.exit("attentionSequence"),f=ls(l),d=!f||f===2&&s||n.includes(l),h=!s||s===2&&f||n.includes(r);return u._open=!!(i===42?d:d&&(s||!h)),u._close=!!(i===42?h:h&&(f||!d)),t(l)}}function Mp(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const jA={name:"autolink",tokenize:NA};function NA(e,t,n){let r=0;return s;function s(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(p){return nt(p)?(e.consume(p),o):p===64?n(p):u(p)}function o(p){return p===43||p===45||p===46||Je(p)?(r=1,a(p)):u(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||Je(p))&&r++<32?(e.consume(p),a):(r=0,u(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||ha(p)?n(p):(e.consume(p),l)}function u(p){return p===64?(e.consume(p),f):SA(p)?(e.consume(p),u):n(p)}function f(p){return Je(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,f):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):h(p)}function h(p){if((p===45||Je(p))&&r++<63){const g=p===45?h:d;return e.consume(p),g}return n(p)}}const Ni={partial:!0,tokenize:MA};function MA(e,t,n){return r;function r(i){return le(i)?fe(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||Z(i)?t(i):n(i)}}const qw={continuation:{tokenize:LA},exit:OA,name:"blockQuote",tokenize:DA};function DA(e,t,n){const r=this;return s;function s(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),i}return n(o)}function i(o){return le(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function LA(e,t,n){const r=this;return s;function s(o){return le(o)?fe(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):i(o)}function i(o){return e.attempt(qw,t,n)(o)}}function OA(e){e.exit("blockQuote")}const Kw={name:"characterEscape",tokenize:zA};function zA(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),s}function s(i){return CA(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const Gw={name:"characterReference",tokenize:FA};function FA(e,t,n){const r=this;let s=0,i,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),i=31,o=Je,f(d))}function u(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,o=kA,f):(e.enter("characterReferenceValue"),i=7,o=lc,f(d))}function f(d){if(d===59&&s){const h=e.exit("characterReferenceValue");return o===Je&&!Wd(r.sliceSerialize(h))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(d)&&s++<i?(e.consume(d),f):n(d)}}const Dp={partial:!0,tokenize:$A},Lp={concrete:!0,name:"codeFenced",tokenize:BA};function BA(e,t,n){const r=this,s={partial:!0,tokenize:I};let i=0,o=0,a;return l;function l(S){return u(S)}function u(S){const R=r.events[r.events.length-1];return i=R&&R[1].type==="linePrefix"?R[2].sliceSerialize(R[1],!0).length:0,a=S,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(S)}function f(S){return S===a?(o++,e.consume(S),f):o<3?n(S):(e.exit("codeFencedFenceSequence"),le(S)?fe(e,d,"whitespace")(S):d(S))}function d(S){return S===null||Z(S)?(e.exit("codeFencedFence"),r.interrupt?t(S):e.check(Dp,x,E)(S)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(S))}function h(S){return S===null||Z(S)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(S)):le(S)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),fe(e,p,"whitespace")(S)):S===96&&S===a?n(S):(e.consume(S),h)}function p(S){return S===null||Z(S)?d(S):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(S))}function g(S){return S===null||Z(S)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(S)):S===96&&S===a?n(S):(e.consume(S),g)}function x(S){return e.attempt(s,E,k)(S)}function k(S){return e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),y}function y(S){return i>0&&le(S)?fe(e,v,"linePrefix",i+1)(S):v(S)}function v(S){return S===null||Z(S)?e.check(Dp,x,E)(S):(e.enter("codeFlowValue"),w(S))}function w(S){return S===null||Z(S)?(e.exit("codeFlowValue"),v(S)):(e.consume(S),w)}function E(S){return e.exit("codeFenced"),t(S)}function I(S,R,N){let D=0;return _;function _(B){return S.enter("lineEnding"),S.consume(B),S.exit("lineEnding"),z}function z(B){return S.enter("codeFencedFence"),le(B)?fe(S,j,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):j(B)}function j(B){return B===a?(S.enter("codeFencedFenceSequence"),K(B)):N(B)}function K(B){return B===a?(D++,S.consume(B),K):D>=o?(S.exit("codeFencedFenceSequence"),le(B)?fe(S,P,"whitespace")(B):P(B)):N(B)}function P(B){return B===null||Z(B)?(S.exit("codeFencedFence"),R(B)):N(B)}}}function $A(e,t,n){const r=this;return s;function s(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i)}function i(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Dl={name:"codeIndented",tokenize:VA},UA={partial:!0,tokenize:HA};function VA(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),fe(e,i,"linePrefix",5)(u)}function i(u){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):Z(u)?e.attempt(UA,o,l)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||Z(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),a)}function l(u){return e.exit("codeIndented"),t(u)}}function HA(e,t,n){const r=this;return s;function s(o){return r.parser.lazy[r.now().line]?n(o):Z(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):fe(e,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?t(o):Z(o)?s(o):n(o)}}const WA={name:"codeText",previous:KA,resolve:qA,tokenize:GA};function qA(e){let t=e.length-4,n=3,r,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function KA(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function GA(e,t,n){let r=0,s,i;return o;function o(d){return e.enter("codeText"),e.enter("codeTextSequence"),a(d)}function a(d){return d===96?(e.consume(d),r++,a):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(i=e.enter("codeTextSequence"),s=0,f(d)):Z(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(d))}function u(d){return d===null||d===32||d===96||Z(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),u)}function f(d){return d===96?(e.consume(d),s++,f):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(i.type="codeTextData",u(d))}}class QA{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&Ps(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Ps(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ps(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Ps(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ps(this.left,n.reverse())}}}function Ps(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Qw(e){const t={};let n=-1,r,s,i,o,a,l,u;const f=new QA(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.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(t,YA(f,n)),n=t[n],u=!0);else if(r[1]._container){for(i=n,s=void 0;i--;)if(o=f.get(i),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(s&&(f.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={...f.get(s)[1].start},a=f.slice(s,n),a.unshift(r),f.splice(s,n-s+1,a))}}return bt(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!u}function YA(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-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 f,d,h=-1,p=n,g=0,x=0;const k=[x];for(;p;){for(;e.get(++s)[1]!==p;);i.push(s),p._tokenizer||(f=r.sliceStream(p),p.next||f.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(f),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=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&&(x=h+1,k.push(x),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):k.pop(),h=k.length;h--;){const y=a.slice(k[h],k[h+1]),v=i.pop();l.push([v,v+y.length-1]),e.splice(v,2,y)}for(l.reverse(),h=-1;++h<l.length;)u[g+l[h][0]]=g+l[h][1],g+=l[h][1]-l[h][0]-1;return u}const JA={resolve:ZA,tokenize:ej},XA={partial:!0,tokenize:tj};function ZA(e){return Qw(e),e}function ej(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(a)}function s(a){return a===null?i(a):Z(a)?e.check(XA,o,i)(a):(e.consume(a),s)}function i(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function tj(e,t,n){const r=this;return s;function s(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),fe(e,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?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Yw(e,t,n,r,s,i,o,a,l){const u=l||Number.POSITIVE_INFINITY;let f=0;return d;function d(y){return y===60?(e.enter(r),e.enter(s),e.enter(i),e.consume(y),e.exit(i),h):y===null||y===32||y===41||ha(y)?n(y):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),x(y))}function h(y){return y===62?(e.enter(i),e.consume(y),e.exit(i),e.exit(s),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===62?(e.exit("chunkString"),e.exit(a),h(y)):y===null||y===60||Z(y)?n(y):(e.consume(y),y===92?g:p)}function g(y){return y===60||y===62||y===92?(e.consume(y),p):p(y)}function x(y){return!f&&(y===null||y===41||xe(y))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(y)):f<u&&y===40?(e.consume(y),f++,x):y===41?(e.consume(y),f--,x):y===null||y===32||y===40||ha(y)?n(y):(e.consume(y),y===92?k:x)}function k(y){return y===40||y===41||y===92?(e.consume(y),x):x(y)}}function Jw(e,t,n,r,s,i){const o=this;let a=0,l;return u;function u(p){return e.enter(r),e.enter(s),e.consume(p),e.exit(s),e.enter(i),f}function f(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(i),e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):Z(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||Z(p)||a++>999?(e.exit("chunkString"),f(p)):(e.consume(p),l||(l=!le(p)),p===92?h:d)}function h(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function Xw(e,t,n,r,s,i){let o;return a;function a(h){return h===34||h===39||h===40?(e.enter(r),e.enter(s),e.consume(h),e.exit(s),o=h===40?41:h,l):n(h)}function l(h){return h===o?(e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):(e.enter(i),u(h))}function u(h){return h===o?(e.exit(i),l(o)):h===null?n(h):Z(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),fe(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===o||h===null||Z(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?d:f)}function d(h){return h===o||h===92?(e.consume(h),f):f(h)}}function Zs(e,t){let n;return r;function r(s){return Z(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):le(s)?fe(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const nj={name:"definition",tokenize:sj},rj={partial:!0,tokenize:ij};function sj(e,t,n){const r=this;let s;return i;function i(p){return e.enter("definition"),o(p)}function o(p){return Jw.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return s=Ut(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return xe(p)?Zs(e,u)(p):u(p)}function u(p){return Yw(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function f(p){return e.attempt(rj,d,d)(p)}function d(p){return le(p)?fe(e,h,"whitespace")(p):h(p)}function h(p){return p===null||Z(p)?(e.exit("definition"),r.parser.defined.push(s),t(p)):n(p)}}function ij(e,t,n){return r;function r(a){return xe(a)?Zs(e,s)(a):n(a)}function s(a){return Xw(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return le(a)?fe(e,o,"whitespace")(a):o(a)}function o(a){return a===null||Z(a)?t(a):n(a)}}const oj={name:"hardBreakEscape",tokenize:aj};function aj(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return Z(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const lj={name:"headingAtx",resolve:uj,tokenize:cj};function uj(e,t){let n=e.length-2,r=3,s,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},bt(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function cj(e,t,n){let r=0;return s;function s(f){return e.enter("atxHeading"),i(f)}function i(f){return e.enter("atxHeadingSequence"),o(f)}function o(f){return f===35&&r++<6?(e.consume(f),o):f===null||xe(f)?(e.exit("atxHeadingSequence"),a(f)):n(f)}function a(f){return f===35?(e.enter("atxHeadingSequence"),l(f)):f===null||Z(f)?(e.exit("atxHeading"),t(f)):le(f)?fe(e,a,"whitespace")(f):(e.enter("atxHeadingText"),u(f))}function l(f){return f===35?(e.consume(f),l):(e.exit("atxHeadingSequence"),a(f))}function u(f){return f===null||f===35||xe(f)?(e.exit("atxHeadingText"),a(f)):(e.consume(f),u)}}const dj=["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"],Op=["pre","script","style","textarea"],fj={concrete:!0,name:"htmlFlow",resolveTo:mj,tokenize:gj},hj={partial:!0,tokenize:vj},pj={partial:!0,tokenize:yj};function mj(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function gj(e,t,n){const r=this;let s,i,o,a,l;return u;function u(C){return f(C)}function f(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),d}function d(C){return C===33?(e.consume(C),h):C===47?(e.consume(C),i=!0,x):C===63?(e.consume(C),s=3,r.interrupt?t:b):nt(C)?(e.consume(C),o=String.fromCharCode(C),k):n(C)}function h(C){return C===45?(e.consume(C),s=2,p):C===91?(e.consume(C),s=5,a=0,g):nt(C)?(e.consume(C),s=4,r.interrupt?t:b):n(C)}function p(C){return C===45?(e.consume(C),r.interrupt?t:b):n(C)}function g(C){const ge="CDATA[";return C===ge.charCodeAt(a++)?(e.consume(C),a===ge.length?r.interrupt?t:j:g):n(C)}function x(C){return nt(C)?(e.consume(C),o=String.fromCharCode(C),k):n(C)}function k(C){if(C===null||C===47||C===62||xe(C)){const ge=C===47,L=o.toLowerCase();return!ge&&!i&&Op.includes(L)?(s=1,r.interrupt?t(C):j(C)):dj.includes(o.toLowerCase())?(s=6,ge?(e.consume(C),y):r.interrupt?t(C):j(C)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(C):i?v(C):w(C))}return C===45||Je(C)?(e.consume(C),o+=String.fromCharCode(C),k):n(C)}function y(C){return C===62?(e.consume(C),r.interrupt?t:j):n(C)}function v(C){return le(C)?(e.consume(C),v):_(C)}function w(C){return C===47?(e.consume(C),_):C===58||C===95||nt(C)?(e.consume(C),E):le(C)?(e.consume(C),w):_(C)}function E(C){return C===45||C===46||C===58||C===95||Je(C)?(e.consume(C),E):I(C)}function I(C){return C===61?(e.consume(C),S):le(C)?(e.consume(C),I):w(C)}function S(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),l=C,R):le(C)?(e.consume(C),S):N(C)}function R(C){return C===l?(e.consume(C),l=null,D):C===null||Z(C)?n(C):(e.consume(C),R)}function N(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||xe(C)?I(C):(e.consume(C),N)}function D(C){return C===47||C===62||le(C)?w(C):n(C)}function _(C){return C===62?(e.consume(C),z):n(C)}function z(C){return C===null||Z(C)?j(C):le(C)?(e.consume(C),z):n(C)}function j(C){return C===45&&s===2?(e.consume(C),ee):C===60&&s===1?(e.consume(C),ae):C===62&&s===4?(e.consume(C),J):C===63&&s===3?(e.consume(C),b):C===93&&s===5?(e.consume(C),M):Z(C)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(hj,Y,K)(C)):C===null||Z(C)?(e.exit("htmlFlowData"),K(C)):(e.consume(C),j)}function K(C){return e.check(pj,P,Y)(C)}function P(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),B}function B(C){return C===null||Z(C)?K(C):(e.enter("htmlFlowData"),j(C))}function ee(C){return C===45?(e.consume(C),b):j(C)}function ae(C){return C===47?(e.consume(C),o="",F):j(C)}function F(C){if(C===62){const ge=o.toLowerCase();return Op.includes(ge)?(e.consume(C),J):j(C)}return nt(C)&&o.length<8?(e.consume(C),o+=String.fromCharCode(C),F):j(C)}function M(C){return C===93?(e.consume(C),b):j(C)}function b(C){return C===62?(e.consume(C),J):C===45&&s===2?(e.consume(C),b):j(C)}function J(C){return C===null||Z(C)?(e.exit("htmlFlowData"),Y(C)):(e.consume(C),J)}function Y(C){return e.exit("htmlFlow"),t(C)}}function yj(e,t,n){const r=this;return s;function s(o){return Z(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):n(o)}function i(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function vj(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Ni,t,n)}}const xj={name:"htmlText",tokenize:wj};function wj(e,t,n){const r=this;let s,i,o;return a;function a(b){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(b),l}function l(b){return b===33?(e.consume(b),u):b===47?(e.consume(b),I):b===63?(e.consume(b),w):nt(b)?(e.consume(b),N):n(b)}function u(b){return b===45?(e.consume(b),f):b===91?(e.consume(b),i=0,g):nt(b)?(e.consume(b),v):n(b)}function f(b){return b===45?(e.consume(b),p):n(b)}function d(b){return b===null?n(b):b===45?(e.consume(b),h):Z(b)?(o=d,ae(b)):(e.consume(b),d)}function h(b){return b===45?(e.consume(b),p):d(b)}function p(b){return b===62?ee(b):b===45?h(b):d(b)}function g(b){const J="CDATA[";return b===J.charCodeAt(i++)?(e.consume(b),i===J.length?x:g):n(b)}function x(b){return b===null?n(b):b===93?(e.consume(b),k):Z(b)?(o=x,ae(b)):(e.consume(b),x)}function k(b){return b===93?(e.consume(b),y):x(b)}function y(b){return b===62?ee(b):b===93?(e.consume(b),y):x(b)}function v(b){return b===null||b===62?ee(b):Z(b)?(o=v,ae(b)):(e.consume(b),v)}function w(b){return b===null?n(b):b===63?(e.consume(b),E):Z(b)?(o=w,ae(b)):(e.consume(b),w)}function E(b){return b===62?ee(b):w(b)}function I(b){return nt(b)?(e.consume(b),S):n(b)}function S(b){return b===45||Je(b)?(e.consume(b),S):R(b)}function R(b){return Z(b)?(o=R,ae(b)):le(b)?(e.consume(b),R):ee(b)}function N(b){return b===45||Je(b)?(e.consume(b),N):b===47||b===62||xe(b)?D(b):n(b)}function D(b){return b===47?(e.consume(b),ee):b===58||b===95||nt(b)?(e.consume(b),_):Z(b)?(o=D,ae(b)):le(b)?(e.consume(b),D):ee(b)}function _(b){return b===45||b===46||b===58||b===95||Je(b)?(e.consume(b),_):z(b)}function z(b){return b===61?(e.consume(b),j):Z(b)?(o=z,ae(b)):le(b)?(e.consume(b),z):D(b)}function j(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),s=b,K):Z(b)?(o=j,ae(b)):le(b)?(e.consume(b),j):(e.consume(b),P)}function K(b){return b===s?(e.consume(b),s=void 0,B):b===null?n(b):Z(b)?(o=K,ae(b)):(e.consume(b),K)}function P(b){return b===null||b===34||b===39||b===60||b===61||b===96?n(b):b===47||b===62||xe(b)?D(b):(e.consume(b),P)}function B(b){return b===47||b===62||xe(b)?D(b):n(b)}function ee(b){return b===62?(e.consume(b),e.exit("htmlTextData"),e.exit("htmlText"),t):n(b)}function ae(b){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),F}function F(b){return le(b)?fe(e,M,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):M(b)}function M(b){return e.enter("htmlTextData"),o(b)}}const qd={name:"labelEnd",resolveAll:Cj,resolveTo:_j,tokenize:Ej},bj={tokenize:Tj},Sj={tokenize:Ij},kj={tokenize:Rj};function Cj(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&bt(e,0,e.length,n),e}function _j(e,t){let n=e.length,r=0,s,i,o,a;for(;n--;)if(s=e[n][1],i){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(o){if(e[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:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[i][1].start},end:{...e[o][1].end}},f={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",u,t]],a=It(a,e.slice(i+1,i+r+3)),a=It(a,[["enter",f,t]]),a=It(a,Wa(t.parser.constructs.insideSpan.null,e.slice(i+r+4,o-3),t)),a=It(a,[["exit",f,t],e[o-2],e[o-1],["exit",u,t]]),a=It(a,e.slice(o+1)),a=It(a,[["exit",l,t]]),bt(e,i,e.length,a),e}function Ej(e,t,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(Ut(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),l):n(h)}function l(h){return h===40?e.attempt(bj,f,o?f:d)(h):h===91?e.attempt(Sj,f,o?u:d)(h):o?f(h):d(h)}function u(h){return e.attempt(kj,f,d)(h)}function f(h){return t(h)}function d(h){return i._balanced=!0,n(h)}}function Tj(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),s}function s(d){return xe(d)?Zs(e,i)(d):i(d)}function i(d){return d===41?f(d):Yw(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return xe(d)?Zs(e,l)(d):f(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?Xw(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):f(d)}function u(d){return xe(d)?Zs(e,f)(d):f(d)}function f(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function Ij(e,t,n){const r=this;return s;function s(a){return Jw.call(r,e,i,o,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes(Ut(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function Rj(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),s}function s(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const Pj={name:"labelStartImage",resolveAll:qd.resolveAll,tokenize:Aj};function Aj(e,t,n){const r=this;return s;function s(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),i}function i(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const jj={name:"labelStartLink",resolveAll:qd.resolveAll,tokenize:Nj};function Nj(e,t,n){const r=this;return s;function s(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),i}function i(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Ll={name:"lineEnding",tokenize:Mj};function Mj(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),fe(e,t,"linePrefix")}}const Eo={name:"thematicBreak",tokenize:Dj};function Dj(e,t,n){let r=0,s;return i;function i(u){return e.enter("thematicBreak"),o(u)}function o(u){return s=u,a(u)}function a(u){return u===s?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||Z(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===s?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),le(u)?fe(e,a,"whitespace")(u):a(u))}}const at={continuation:{tokenize:Fj},exit:$j,name:"list",tokenize:zj},Lj={partial:!0,tokenize:Uj},Oj={partial:!0,tokenize:Bj};function zj(e,t,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(p){const g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:lc(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Eo,n,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return lc(p)&&++o<10?(e.consume(p),l):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Ni,r.interrupt?n:f,e.attempt(Lj,h,d))}function f(p){return r.containerState.initialBlankLine=!0,i++,h(p)}function d(p){return le(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function Fj(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Ni,s,i);function s(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,fe(e,t,"listItemIndent",r.containerState.size+1)(a)}function i(a){return r.containerState.furtherBlankLines||!le(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Oj,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,fe(e,e.attempt(at,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Bj(e,t,n){const r=this;return fe(e,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?t(i):n(i)}}function $j(e){e.exit(this.containerState.type)}function Uj(e,t,n){const r=this;return fe(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(i){const o=r.events[r.events.length-1];return!le(i)&&o&&o[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const zp={name:"setextUnderline",resolveTo:Vj,tokenize:Hj};function Vj(e,t){let n=e.length,r,s,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",i?(e.splice(s,0,["enter",o,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Hj(e,t,n){const r=this;let s;return i;function i(u){let f=r.events.length,d;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){d=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),s=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===s?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),le(u)?fe(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||Z(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Wj={tokenize:qj};function qj(e){const t=this,n=e.attempt(Ni,r,e.attempt(this.parser.constructs.flowInitial,s,fe(e,e.attempt(this.parser.constructs.flow,s,e.attempt(JA,s)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Kj={resolveAll:eb()},Gj=Zw("string"),Qj=Zw("text");function Zw(e){return{resolveAll:eb(e==="text"?Yj:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],i=n.attempt(s,o,a);return o;function o(f){return u(f)?i(f):a(f)}function a(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),l}function l(f){return u(f)?(n.exit("data"),i(f)):(n.consume(f),l)}function u(f){if(f===null)return!0;const d=s[f];let h=-1;if(d)for(;++h<d.length;){const p=d[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function eb(e){return t;function t(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 e?e(n,r):n}}function Yj(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.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(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.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):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const Jj={42:at,43:at,45:at,48:at,49:at,50:at,51:at,52:at,53:at,54:at,55:at,56:at,57:at,62:qw},Xj={91:nj},Zj={[-2]:Dl,[-1]:Dl,32:Dl},eN={35:lj,42:Eo,45:[zp,Eo],60:fj,61:zp,95:Eo,96:Lp,126:Lp},tN={38:Gw,92:Kw},nN={[-5]:Ll,[-4]:Ll,[-3]:Ll,33:Pj,38:Gw,42:uc,60:[jA,xj],91:jj,92:[oj,Kw],93:qd,95:uc,96:WA},rN={null:[uc,Kj]},sN={null:[42,95]},iN={null:[]},oN=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:sN,contentInitial:Xj,disable:iN,document:Jj,flow:eN,flowInitial:Zj,insideSpan:rN,string:tN,text:nN},Symbol.toStringTag,{value:"Module"}));function aN(e,t,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:R(I),check:R(S),consume:v,enter:w,exit:E,interrupt:R(S,{interrupt:!0})},u={code:null,containerState:{},defineSkip:x,events:[],now:g,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:d};let f=t.tokenize.call(u,l);return t.resolveAll&&i.push(t),u;function d(z){return o=It(o,z),k(),o[o.length-1]!==null?[]:(N(t,0),u.events=Wa(i,u.events,u),u.events)}function h(z,j){return uN(p(z),j)}function p(z){return lN(o,z)}function g(){const{_bufferIndex:z,_index:j,line:K,column:P,offset:B}=r;return{_bufferIndex:z,_index:j,line:K,column:P,offset:B}}function x(z){s[z.line]=z.column,_()}function k(){let z;for(;r._index<o.length;){const j=o[r._index];if(typeof j=="string")for(z=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===z&&r._bufferIndex<j.length;)y(j.charCodeAt(r._bufferIndex));else y(j)}}function y(z){f=f(z)}function v(z){Z(z)?(r.line++,r.column=1,r.offset+=z===-3?2:1,_()):z!==-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=z}function w(z,j){const K=j||{};return K.type=z,K.start=g(),u.events.push(["enter",K,u]),a.push(K),K}function E(z){const j=a.pop();return j.end=g(),u.events.push(["exit",j,u]),j}function I(z,j){N(z,j.from)}function S(z,j){j.restore()}function R(z,j){return K;function K(P,B,ee){let ae,F,M,b;return Array.isArray(P)?Y(P):"tokenize"in P?Y([P]):J(P);function J(O){return W;function W(Q){const X=Q!==null&&O[Q],pe=Q!==null&&O.null,$e=[...Array.isArray(X)?X:X?[X]:[],...Array.isArray(pe)?pe:pe?[pe]:[]];return Y($e)(Q)}}function Y(O){return ae=O,F=0,O.length===0?ee:C(O[F])}function C(O){return W;function W(Q){return b=D(),M=O,O.partial||(u.currentConstruct=O),O.name&&u.parser.constructs.disable.null.includes(O.name)?L():O.tokenize.call(j?Object.assign(Object.create(u),j):u,l,ge,L)(Q)}}function ge(O){return z(M,b),B}function L(O){return b.restore(),++F<ae.length?C(ae[F]):ee}}}function N(z,j){z.resolveAll&&!i.includes(z)&&i.push(z),z.resolve&&bt(u.events,j,u.events.length-j,z.resolve(u.events.slice(j),u)),z.resolveTo&&(u.events=z.resolveTo(u.events,u))}function D(){const z=g(),j=u.previous,K=u.currentConstruct,P=u.events.length,B=Array.from(a);return{from:P,restore:ee};function ee(){r=z,u.previous=j,u.currentConstruct=K,u.events.length=P,a=B,_()}}function _(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function lN(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,i=t.end._bufferIndex;let o;if(n===s)o=[e[n].slice(r,i)];else{if(o=e.slice(n,s),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}i>0&&o.push(e[s].slice(0,i))}return o}function uN(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const i=e[n];let o;if(typeof i=="string")o=i;else switch(i){case-5:{o="\r";break}case-4:{o=`
|
|
48
|
+
*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var i="",o=0;o<arguments.length;o++){var a=arguments[o];a&&(i=s(i,r(a)))}return i}function r(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return n.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var o="";for(var a in i)t.call(i,a)&&i[a]&&(o=s(o,a));return o}function s(i,o){return o?i?i+" "+o:i+o:i}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Rw);var sP=Rw.exports;const Pw=Ei(sP),vp=({className:e,...t})=>({className:n,...r})=>({className:Pw(e,n),...t,...r}),iP=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:s},componentsByLanguage:i={},children:o,...a})=>{const l=vp(m.useContext(Dd)),u=mr(p=>c.jsx(t,{...l(p)})),f=vp(a),d=mr(p=>c.jsx(n,{...f(p)})),h=/language-(\w+)/.exec(a.className||"")?.[1]??"";return typeof o!="string"?c.jsx(Ld,{node:e,components:{Pre:u,Code:d},code:o}):c.jsx(rP,{node:e,components:{Pre:u,Code:d,SyntaxHighlighter:i[h]?.SyntaxHighlighter??r,CodeHeader:i[h]?.CodeHeader??s},language:h||"unknown",code:o})},oP=({node:e,components:t,componentsByLanguage:n,...r})=>JR()?c.jsx(iP,{node:e,components:t,componentsByLanguage:n,...r}):c.jsx(t.Code,{...r}),aP=m.memo(oP,(e,t)=>e.components===t.components&&e.componentsByLanguage===t.componentsByLanguage&&Iw(e,t));function lP(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const uP=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cP=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,dP={};function xp(e,t){return(dP.jsx?cP:uP).test(e)}const fP=/[ \t\n\f\r]/g;function hP(e){return typeof e=="object"?e.type==="text"?wp(e.value):!1:wp(e)}function wp(e){return e.replace(fP,"")===""}class ji{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}ji.prototype.normal={};ji.prototype.property={};ji.prototype.space=void 0;function Aw(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new ji(n,r,t)}function rc(e){return e.toLowerCase()}class mt{constructor(t,n){this.attribute=n,this.property=t}}mt.prototype.attribute="";mt.prototype.booleanish=!1;mt.prototype.boolean=!1;mt.prototype.commaOrSpaceSeparated=!1;mt.prototype.commaSeparated=!1;mt.prototype.defined=!1;mt.prototype.mustUseProperty=!1;mt.prototype.number=!1;mt.prototype.overloadedBoolean=!1;mt.prototype.property="";mt.prototype.spaceSeparated=!1;mt.prototype.space=void 0;let pP=0;const te=Cr(),De=Cr(),sc=Cr(),U=Cr(),ve=Cr(),lr=Cr(),yt=Cr();function Cr(){return 2**++pP}const ic=Object.freeze(Object.defineProperty({__proto__:null,boolean:te,booleanish:De,commaOrSpaceSeparated:yt,commaSeparated:lr,number:U,overloadedBoolean:sc,spaceSeparated:ve},Symbol.toStringTag,{value:"Module"})),Nl=Object.keys(ic);class Od extends mt{constructor(t,n,r,s){let i=-1;if(super(t,n),bp(this,"space",s),typeof r=="number")for(;++i<Nl.length;){const o=Nl[i];bp(this,Nl[i],(r&ic[o])===ic[o])}}}Od.prototype.defined=!0;function bp(e,t,n){n&&(e[t]=n)}function ys(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new Od(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[rc(r)]=r,n[rc(i.attribute)]=r}return new ji(t,n,e.space)}const jw=ys({properties:{ariaActiveDescendant:null,ariaAtomic:De,ariaAutoComplete:null,ariaBusy:De,ariaChecked:De,ariaColCount:U,ariaColIndex:U,ariaColSpan:U,ariaControls:ve,ariaCurrent:null,ariaDescribedBy:ve,ariaDetails:null,ariaDisabled:De,ariaDropEffect:ve,ariaErrorMessage:null,ariaExpanded:De,ariaFlowTo:ve,ariaGrabbed:De,ariaHasPopup:null,ariaHidden:De,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ve,ariaLevel:U,ariaLive:null,ariaModal:De,ariaMultiLine:De,ariaMultiSelectable:De,ariaOrientation:null,ariaOwns:ve,ariaPlaceholder:null,ariaPosInSet:U,ariaPressed:De,ariaReadOnly:De,ariaRelevant:null,ariaRequired:De,ariaRoleDescription:ve,ariaRowCount:U,ariaRowIndex:U,ariaRowSpan:U,ariaSelected:De,ariaSetSize:U,ariaSort:null,ariaValueMax:U,ariaValueMin:U,ariaValueNow:U,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Nw(e,t){return t in e?e[t]:t}function Mw(e,t){return Nw(e,t.toLowerCase())}const mP=ys({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:lr,acceptCharset:ve,accessKey:ve,action:null,allow:null,allowFullScreen:te,allowPaymentRequest:te,allowUserMedia:te,alpha:te,alt:null,as:null,async:te,autoCapitalize:null,autoComplete:ve,autoFocus:te,autoPlay:te,blocking:ve,capture:null,charSet:null,checked:te,cite:null,className:ve,closedBy:null,colorSpace:null,cols:U,colSpan:U,command:null,commandFor:null,content:null,contentEditable:De,controls:te,controlsList:ve,coords:U|lr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:te,defer:te,dir:null,dirName:null,disabled:te,download:sc,draggable:De,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:te,formTarget:null,headers:ve,height:U,hidden:sc,high:U,href:null,hrefLang:null,htmlFor:ve,httpEquiv:ve,id:null,imageSizes:null,imageSrcSet:null,inert:te,inputMode:null,integrity:null,is:null,isMap:te,itemId:null,itemProp:ve,itemRef:ve,itemScope:te,itemType:ve,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:te,low:U,manifest:null,max:null,maxLength:U,media:null,method:null,min:null,minLength:U,multiple:te,muted:te,name:null,nonce:null,noModule:te,noValidate:te,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:te,optimum:U,pattern:null,ping:ve,placeholder:null,playsInline:te,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:te,referrerPolicy:null,rel:ve,required:te,reversed:te,rows:U,rowSpan:U,sandbox:ve,scope:null,scoped:te,seamless:te,selected:te,shadowRootClonable:te,shadowRootCustomElementRegistry:te,shadowRootDelegatesFocus:te,shadowRootMode:null,shadowRootSerializable:te,shape:null,size:U,sizes:null,slot:null,span:U,spellCheck:De,src:null,srcDoc:null,srcLang:null,srcSet:null,start:U,step:null,style:null,tabIndex:U,target:null,title:null,translate:null,type:null,typeMustMatch:te,useMap:null,value:De,width:U,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ve,axis:null,background:null,bgColor:null,border:U,borderColor:null,bottomMargin:U,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:te,declare:te,event:null,face:null,frame:null,frameBorder:null,hSpace:U,leftMargin:U,link:null,longDesc:null,lowSrc:null,marginHeight:U,marginWidth:U,noResize:te,noHref:te,noShade:te,noWrap:te,object:null,profile:null,prompt:null,rev:null,rightMargin:U,rules:null,scheme:null,scrolling:De,standby:null,summary:null,text:null,topMargin:U,valueType:null,version:null,vAlign:null,vLink:null,vSpace:U,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:te,disablePictureInPicture:te,disableRemotePlayback:te,exportParts:lr,part:ve,prefix:null,property:null,results:U,security:null,unselectable:null},space:"html",transform:Mw}),gP=ys({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:yt,accentHeight:U,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:U,amplitude:U,arabicForm:null,ascent:U,attributeName:null,attributeType:null,azimuth:U,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:U,by:null,calcMode:null,capHeight:U,className:ve,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:U,diffuseConstant:U,direction:null,display:null,dur:null,divisor:U,dominantBaseline:null,download:te,dx:null,dy:null,edgeMode:null,editable:null,elevation:U,enableBackground:null,end:null,event:null,exponent:U,externalResourcesRequired:null,fill:null,fillOpacity:U,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:lr,g2:lr,glyphName:lr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:U,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:U,horizOriginX:U,horizOriginY:U,id:null,ideographic:U,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:U,k:U,k1:U,k2:U,k3:U,k4:U,kernelMatrix:yt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:U,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:U,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:U,overlineThickness:U,paintOrder:null,panose1:null,path:null,pathLength:U,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ve,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:U,pointsAtY:U,pointsAtZ:U,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:yt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:yt,rev:yt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:yt,requiredFeatures:yt,requiredFonts:yt,requiredFormats:yt,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:U,specularExponent:U,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:U,strikethroughThickness:U,string:null,stroke:null,strokeDashArray:yt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:U,strokeOpacity:U,strokeWidth:null,style:null,surfaceScale:U,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:yt,tabIndex:U,tableValues:null,target:null,targetX:U,targetY:U,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:yt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:U,underlineThickness:U,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:U,values:null,vAlphabetic:U,vMathematical:U,vectorEffect:null,vHanging:U,vIdeographic:U,version:null,vertAdvY:U,vertOriginX:U,vertOriginY:U,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:U,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Nw}),Dw=ys({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Lw=ys({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Mw}),Ow=ys({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),yP={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"},vP=/[A-Z]/g,Sp=/-[a-z]/g,xP=/^data[-\w.:]+$/i;function wP(e,t){const n=rc(t);let r=t,s=mt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&xP.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(Sp,SP);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!Sp.test(i)){let o=i.replace(vP,bP);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}s=Od}return new s(r,t)}function bP(e){return"-"+e.toLowerCase()}function SP(e){return e.charAt(1).toUpperCase()}const kP=Aw([jw,mP,Dw,Lw,Ow],"html"),zd=Aw([jw,gP,Dw,Lw,Ow],"svg");function CP(e){return e.join(" ").trim()}var Fd={},kp=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,_P=/\n/g,EP=/^\s*/,TP=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,IP=/^:\s*/,RP=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,PP=/^[;\s]*/,AP=/^\s+|\s+$/g,jP=`
|
|
49
|
+
`,Cp="/",_p="*",tr="",NP="comment",MP="declaration";function DP(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(g){var v=g.match(_P);v&&(n+=v.length);var S=g.lastIndexOf(jP);r=~S?g.length-S:r+g.length}function i(){var g={line:n,column:r};return function(v){return v.position=new o(g),u(),v}}function o(g){this.start=g,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function a(g){var v=new Error(t.source+":"+n+":"+r+": "+g);if(v.reason=g,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function l(g){var v=g.exec(e);if(v){var S=v[0];return s(S),e=e.slice(S.length),v}}function u(){l(EP)}function f(g){var v;for(g=g||[];v=d();)v!==!1&&g.push(v);return g}function d(){var g=i();if(!(Cp!=e.charAt(0)||_p!=e.charAt(1))){for(var v=2;tr!=e.charAt(v)&&(_p!=e.charAt(v)||Cp!=e.charAt(v+1));)++v;if(v+=2,tr===e.charAt(v-1))return a("End of comment missing");var S=e.slice(2,v-2);return r+=2,s(S),e=e.slice(v),r+=2,g({type:NP,comment:S})}}function h(){var g=i(),v=l(TP);if(v){if(d(),!l(IP))return a("property missing ':'");var S=l(RP),y=g({type:MP,property:Ep(v[0].replace(kp,tr)),value:S?Ep(S[0].replace(kp,tr)):tr});return l(PP),y}}function p(){var g=[];f(g);for(var v;v=h();)v!==!1&&(g.push(v),f(g));return g}return u(),p()}function Ep(e){return e?e.replace(AP,tr):tr}var LP=DP,OP=Io&&Io.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Fd,"__esModule",{value:!0});Fd.default=FP;const zP=OP(LP);function FP(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,zP.default)(e),s=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;const{property:o,value:a}=i;s?t(o,a,i):a&&(n=n||{},n[o]=a)}),n}var Va={};Object.defineProperty(Va,"__esModule",{value:!0});Va.camelCase=void 0;var BP=/^--[a-zA-Z0-9_-]+$/,$P=/-([a-z])/g,UP=/^[^-]+$/,VP=/^-(webkit|moz|ms|o|khtml)-/,HP=/^-(ms)-/,WP=function(e){return!e||UP.test(e)||BP.test(e)},qP=function(e,t){return t.toUpperCase()},Tp=function(e,t){return"".concat(t,"-")},KP=function(e,t){return t===void 0&&(t={}),WP(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(HP,Tp):e=e.replace(VP,Tp),e.replace($P,qP))};Va.camelCase=KP;var GP=Io&&Io.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},QP=GP(Fd),YP=Va;function oc(e,t){var n={};return!e||typeof e!="string"||(0,QP.default)(e,function(r,s){r&&s&&(n[(0,YP.camelCase)(r,t)]=s)}),n}oc.default=oc;var JP=oc;const XP=Ei(JP),zw=Fw("end"),Bd=Fw("start");function Fw(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};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 ZP(e){const t=Bd(e),n=zw(e);if(t&&n)return{start:t,end:n}}function Xs(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Ip(e.position):"start"in e||"end"in e?Ip(e):"line"in e||"column"in e?ac(e):""}function ac(e){return Rp(e&&e.line)+":"+Rp(e&&e.column)}function Ip(e){return ac(e&&e.start)+"-"+ac(e&&e.end)}function Rp(e){return e&&typeof e=="number"?e:1}class Ze extends Error{constructor(t,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 t=="string"?s=t:!i.cause&&t&&(o=!0,s=t.message,i.cause=t),!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=Xs(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}}Ze.prototype.file="";Ze.prototype.name="";Ze.prototype.reason="";Ze.prototype.message="";Ze.prototype.stack="";Ze.prototype.column=void 0;Ze.prototype.line=void 0;Ze.prototype.ancestors=void 0;Ze.prototype.cause=void 0;Ze.prototype.fatal=void 0;Ze.prototype.place=void 0;Ze.prototype.ruleId=void 0;Ze.prototype.source=void 0;const $d={}.hasOwnProperty,eA=new Map,tA=/[A-Z]/g,nA=new Set(["table","tbody","thead","tfoot","tr"]),rA=new Set(["td","th"]),Bw="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function sA(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=fA(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=dA(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?zd:kP,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=$w(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function $w(e,t,n){if(t.type==="element")return iA(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return oA(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return lA(e,t,n);if(t.type==="mdxjsEsm")return aA(e,t);if(t.type==="root")return uA(e,t,n);if(t.type==="text")return cA(e,t)}function iA(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=zd,e.schema=s),e.ancestors.push(t);const i=Vw(e,t.tagName,!1),o=hA(e,t);let a=Vd(e,t);return nA.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!hP(l):!0})),Uw(e,o,i,t),Ud(o,a),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function oA(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ki(e,t.position)}function aA(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ki(e,t.position)}function lA(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=zd,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:Vw(e,t.name,!0),o=pA(e,t),a=Vd(e,t);return Uw(e,o,i,t),Ud(o,a),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function uA(e,t,n){const r={};return Ud(r,Vd(e,t)),e.create(t,e.Fragment,r,n)}function cA(e,t){return t.value}function Uw(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Ud(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function dA(e,t,n){return r;function r(s,i,o,a){const u=Array.isArray(o.children)?n:t;return a?u(i,o,a):u(i,o)}}function fA(e,t){return n;function n(r,s,i,o){const a=Array.isArray(i.children),l=Bd(r);return t(s,i,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function hA(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&$d.call(t.properties,s)){const i=mA(e,s,t.properties[s]);if(i){const[o,a]=i;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&rA.has(t.tagName)?r=a:n[o]=a}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function pA(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.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,e.evaluater.evaluateExpression(a.argument))}else ki(e,t.position);else{const s=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,i=e.evaluater.evaluateExpression(a.expression)}else ki(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function Vd(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:eA;for(;++r<t.children.length;){const i=t.children[r];let o;if(e.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=$w(e,i,o);a!==void 0&&n.push(a)}return n}function mA(e,t,n){const r=wP(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?lP(n):CP(n)),r.property==="style"){let s=typeof n=="object"?n:gA(e,String(n));return e.stylePropertyNameCase==="css"&&(s=yA(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?yP[r.property]||r.property:r.attribute,n]}}function gA(e,t){try{return XP(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Ze("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=Bw+"#cannot-parse-style-attribute",s}}function Vw(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let i=-1,o;for(;++i<s.length;){const a=xp(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=xp(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return $d.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);ki(e)}function ki(e,t){const n=new Ze("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Bw+"#cannot-handle-mdx-estrees-without-createevaluater",n}function yA(e){const t={};let n;for(n in e)$d.call(e,n)&&(t[vA(n)]=e[n]);return t}function vA(e){let t=e.replace(tA,xA);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function xA(e){return"-"+e.toLowerCase()}const Ml={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"]},wA={};function Hd(e,t){const n=wA,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Hw(e,r,s)}function Hw(e,t,n){if(bA(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Pp(e.children,t,n)}return Array.isArray(e)?Pp(e,t,n):""}function Pp(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=Hw(e[s],t,n);return r.join("")}function bA(e){return!!(e&&typeof e=="object")}const Ap=document.createElement("i");function Wd(e){const t="&"+e+";";Ap.innerHTML=t;const n=Ap.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function bt(e,t,n,r){const s=e.length;let i=0,o;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);i<r.length;)o=r.slice(i,i+1e4),o.unshift(t,0),e.splice(...o),i+=1e4,t+=1e4}function It(e,t){return e.length>0?(bt(e,e.length,0,t),e):t}const jp={}.hasOwnProperty;function Ww(e){const t={};let n=-1;for(;++n<e.length;)SA(t,e[n]);return t}function SA(e,t){let n;for(n in t){const s=(jp.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let o;if(i)for(o in i){jp.call(s,o)||(s[o]=[]);const a=i[o];kA(s[o],Array.isArray(a)?a:a?[a]:[])}}}function kA(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);bt(e,0,0,r)}function qw(e,t){const n=Number.parseInt(e,t);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 Ut(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const nt=Qn(/[A-Za-z]/),Je=Qn(/[\dA-Za-z]/),CA=Qn(/[#-'*+\--9=?A-Z^-~]/);function ha(e){return e!==null&&(e<32||e===127)}const lc=Qn(/\d/),_A=Qn(/[\dA-Fa-f]/),EA=Qn(/[!-/:-@[-`{-~]/);function Z(e){return e!==null&&e<-2}function xe(e){return e!==null&&(e<0||e===32)}function le(e){return e===-2||e===-1||e===32}const Ha=Qn(/\p{P}|\p{S}/u),gr=Qn(/\s/);function Qn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function vs(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const i=e.charCodeAt(n);let o="";if(i===37&&Je(e.charCodeAt(n+1))&&Je(e.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=e.charCodeAt(n+1);i<56320&&a>56319&&a<57344?(o=String.fromCharCode(i,a),s=1):o="�"}else o=String.fromCharCode(i);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+s+1,o=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function fe(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return o;function o(l){return le(l)?(e.enter(n),a(l)):t(l)}function a(l){return le(l)&&i++<s?(e.consume(l),a):(e.exit(n),t(l))}}const TA={tokenize:IA};function IA(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),fe(e,t,"linePrefix")}function s(a){return e.enter("paragraph"),i(a)}function i(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return Z(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),o)}}const RA={tokenize:PA},Np={tokenize:AA};function PA(e){const t=this,n=[];let r=0,s,i,o;return a;function a(w){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,l,u)(w)}return u(w)}function l(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&x();const E=t.events.length;let I=E,k;for(;I--;)if(t.events[I][0]==="exit"&&t.events[I][1].type==="chunkFlow"){k=t.events[I][1].end;break}y(r);let R=E;for(;R<t.events.length;)t.events[R][1].end={...k},R++;return bt(t.events,I+1,0,t.events.slice(E)),t.events.length=R,u(w)}return a(w)}function u(w){if(r===n.length){if(!s)return h(w);if(s.currentConstruct&&s.currentConstruct.concrete)return g(w);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Np,f,d)(w)}function f(w){return s&&x(),y(r),h(w)}function d(w){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(w)}function h(w){return t.containerState={},e.attempt(Np,p,g)(w)}function p(w){return r++,n.push([t.currentConstruct,t.containerState]),h(w)}function g(w){if(w===null){s&&x(),y(0),e.consume(w);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),v(w)}function v(w){if(w===null){S(e.exit("chunkFlow"),!0),y(0),e.consume(w);return}return Z(w)?(e.consume(w),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(w),v)}function S(w,E){const I=t.sliceStream(w);if(E&&I.push(null),w.previous=i,i&&(i.next=w),i=w,s.defineSkip(w.start),s.write(I),t.parser.lazy[w.start.line]){let k=s.events.length;for(;k--;)if(s.events[k][1].start.offset<o&&(!s.events[k][1].end||s.events[k][1].end.offset>o))return;const R=t.events.length;let M=R,L,_;for(;M--;)if(t.events[M][0]==="exit"&&t.events[M][1].type==="chunkFlow"){if(L){_=t.events[M][1].end;break}L=!0}for(y(r),k=R;k<t.events.length;)t.events[k][1].end={..._},k++;bt(t.events,M+1,0,t.events.slice(R)),t.events.length=k}}function y(w){let E=n.length;for(;E-- >w;){const I=n[E];t.containerState=I[1],I[0].exit.call(t,e)}n.length=w}function x(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function AA(e,t,n){return fe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ls(e){if(e===null||xe(e)||gr(e))return 1;if(Ha(e))return 2}function Wa(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const i=e[s].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const uc={name:"attention",resolveAll:jA,tokenize:NA};function jA(e,t){let n=-1,r,s,i,o,a,l,u,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},h={...e[n][1].start};Mp(d,-l),Mp(h,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},i={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=It(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=It(u,[["enter",s,t],["enter",o,t],["exit",o,t],["enter",i,t]]),u=It(u,Wa(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=It(u,[["exit",i,t],["enter",a,t],["exit",a,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,u=It(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,bt(e,r-1,n-r+3,u),n=r+u.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function NA(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=ls(r);let i;return o;function o(l){return i=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===i)return e.consume(l),a;const u=e.exit("attentionSequence"),f=ls(l),d=!f||f===2&&s||n.includes(l),h=!s||s===2&&f||n.includes(r);return u._open=!!(i===42?d:d&&(s||!h)),u._close=!!(i===42?h:h&&(f||!d)),t(l)}}function Mp(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const MA={name:"autolink",tokenize:DA};function DA(e,t,n){let r=0;return s;function s(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(p){return nt(p)?(e.consume(p),o):p===64?n(p):u(p)}function o(p){return p===43||p===45||p===46||Je(p)?(r=1,a(p)):u(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||Je(p))&&r++<32?(e.consume(p),a):(r=0,u(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||ha(p)?n(p):(e.consume(p),l)}function u(p){return p===64?(e.consume(p),f):CA(p)?(e.consume(p),u):n(p)}function f(p){return Je(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,f):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):h(p)}function h(p){if((p===45||Je(p))&&r++<63){const g=p===45?h:d;return e.consume(p),g}return n(p)}}const Ni={partial:!0,tokenize:LA};function LA(e,t,n){return r;function r(i){return le(i)?fe(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||Z(i)?t(i):n(i)}}const Kw={continuation:{tokenize:zA},exit:FA,name:"blockQuote",tokenize:OA};function OA(e,t,n){const r=this;return s;function s(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),i}return n(o)}function i(o){return le(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function zA(e,t,n){const r=this;return s;function s(o){return le(o)?fe(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):i(o)}function i(o){return e.attempt(Kw,t,n)(o)}}function FA(e){e.exit("blockQuote")}const Gw={name:"characterEscape",tokenize:BA};function BA(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),s}function s(i){return EA(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const Qw={name:"characterReference",tokenize:$A};function $A(e,t,n){const r=this;let s=0,i,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),i=31,o=Je,f(d))}function u(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,o=_A,f):(e.enter("characterReferenceValue"),i=7,o=lc,f(d))}function f(d){if(d===59&&s){const h=e.exit("characterReferenceValue");return o===Je&&!Wd(r.sliceSerialize(h))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(d)&&s++<i?(e.consume(d),f):n(d)}}const Dp={partial:!0,tokenize:VA},Lp={concrete:!0,name:"codeFenced",tokenize:UA};function UA(e,t,n){const r=this,s={partial:!0,tokenize:I};let i=0,o=0,a;return l;function l(k){return u(k)}function u(k){const R=r.events[r.events.length-1];return i=R&&R[1].type==="linePrefix"?R[2].sliceSerialize(R[1],!0).length:0,a=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(k)}function f(k){return k===a?(o++,e.consume(k),f):o<3?n(k):(e.exit("codeFencedFenceSequence"),le(k)?fe(e,d,"whitespace")(k):d(k))}function d(k){return k===null||Z(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(Dp,v,E)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(k))}function h(k){return k===null||Z(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):le(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),fe(e,p,"whitespace")(k)):k===96&&k===a?n(k):(e.consume(k),h)}function p(k){return k===null||Z(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(k))}function g(k){return k===null||Z(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(k)):k===96&&k===a?n(k):(e.consume(k),g)}function v(k){return e.attempt(s,E,S)(k)}function S(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),y}function y(k){return i>0&&le(k)?fe(e,x,"linePrefix",i+1)(k):x(k)}function x(k){return k===null||Z(k)?e.check(Dp,v,E)(k):(e.enter("codeFlowValue"),w(k))}function w(k){return k===null||Z(k)?(e.exit("codeFlowValue"),x(k)):(e.consume(k),w)}function E(k){return e.exit("codeFenced"),t(k)}function I(k,R,M){let L=0;return _;function _(B){return k.enter("lineEnding"),k.consume(B),k.exit("lineEnding"),z}function z(B){return k.enter("codeFencedFence"),le(B)?fe(k,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):N(B)}function N(B){return B===a?(k.enter("codeFencedFenceSequence"),K(B)):M(B)}function K(B){return B===a?(L++,k.consume(B),K):L>=o?(k.exit("codeFencedFenceSequence"),le(B)?fe(k,P,"whitespace")(B):P(B)):M(B)}function P(B){return B===null||Z(B)?(k.exit("codeFencedFence"),R(B)):M(B)}}}function VA(e,t,n){const r=this;return s;function s(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i)}function i(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Dl={name:"codeIndented",tokenize:WA},HA={partial:!0,tokenize:qA};function WA(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),fe(e,i,"linePrefix",5)(u)}function i(u){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):Z(u)?e.attempt(HA,o,l)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||Z(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),a)}function l(u){return e.exit("codeIndented"),t(u)}}function qA(e,t,n){const r=this;return s;function s(o){return r.parser.lazy[r.now().line]?n(o):Z(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):fe(e,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?t(o):Z(o)?s(o):n(o)}}const KA={name:"codeText",previous:QA,resolve:GA,tokenize:YA};function GA(e){let t=e.length-4,n=3,r,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function QA(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function YA(e,t,n){let r=0,s,i;return o;function o(d){return e.enter("codeText"),e.enter("codeTextSequence"),a(d)}function a(d){return d===96?(e.consume(d),r++,a):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(i=e.enter("codeTextSequence"),s=0,f(d)):Z(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(d))}function u(d){return d===null||d===32||d===96||Z(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),u)}function f(d){return d===96?(e.consume(d),s++,f):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(i.type="codeTextData",u(d))}}class JA{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&Ps(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Ps(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ps(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Ps(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ps(this.left,n.reverse())}}}function Ps(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Yw(e){const t={};let n=-1,r,s,i,o,a,l,u;const f=new JA(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.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(t,XA(f,n)),n=t[n],u=!0);else if(r[1]._container){for(i=n,s=void 0;i--;)if(o=f.get(i),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(s&&(f.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={...f.get(s)[1].start},a=f.slice(s,n),a.unshift(r),f.splice(s,n-s+1,a))}}return bt(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!u}function XA(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-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 f,d,h=-1,p=n,g=0,v=0;const S=[v];for(;p;){for(;e.get(++s)[1]!==p;);i.push(s),p._tokenizer||(f=r.sliceStream(p),p.next||f.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(f),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=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&&(v=h+1,S.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):S.pop(),h=S.length;h--;){const y=a.slice(S[h],S[h+1]),x=i.pop();l.push([x,x+y.length-1]),e.splice(x,2,y)}for(l.reverse(),h=-1;++h<l.length;)u[g+l[h][0]]=g+l[h][1],g+=l[h][1]-l[h][0]-1;return u}const ZA={resolve:tj,tokenize:nj},ej={partial:!0,tokenize:rj};function tj(e){return Yw(e),e}function nj(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(a)}function s(a){return a===null?i(a):Z(a)?e.check(ej,o,i)(a):(e.consume(a),s)}function i(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function rj(e,t,n){const r=this;return s;function s(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),fe(e,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?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Jw(e,t,n,r,s,i,o,a,l){const u=l||Number.POSITIVE_INFINITY;let f=0;return d;function d(y){return y===60?(e.enter(r),e.enter(s),e.enter(i),e.consume(y),e.exit(i),h):y===null||y===32||y===41||ha(y)?n(y):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(y))}function h(y){return y===62?(e.enter(i),e.consume(y),e.exit(i),e.exit(s),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===62?(e.exit("chunkString"),e.exit(a),h(y)):y===null||y===60||Z(y)?n(y):(e.consume(y),y===92?g:p)}function g(y){return y===60||y===62||y===92?(e.consume(y),p):p(y)}function v(y){return!f&&(y===null||y===41||xe(y))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(y)):f<u&&y===40?(e.consume(y),f++,v):y===41?(e.consume(y),f--,v):y===null||y===32||y===40||ha(y)?n(y):(e.consume(y),y===92?S:v)}function S(y){return y===40||y===41||y===92?(e.consume(y),v):v(y)}}function Xw(e,t,n,r,s,i){const o=this;let a=0,l;return u;function u(p){return e.enter(r),e.enter(s),e.consume(p),e.exit(s),e.enter(i),f}function f(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(i),e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):Z(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||Z(p)||a++>999?(e.exit("chunkString"),f(p)):(e.consume(p),l||(l=!le(p)),p===92?h:d)}function h(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function Zw(e,t,n,r,s,i){let o;return a;function a(h){return h===34||h===39||h===40?(e.enter(r),e.enter(s),e.consume(h),e.exit(s),o=h===40?41:h,l):n(h)}function l(h){return h===o?(e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):(e.enter(i),u(h))}function u(h){return h===o?(e.exit(i),l(o)):h===null?n(h):Z(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),fe(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===o||h===null||Z(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?d:f)}function d(h){return h===o||h===92?(e.consume(h),f):f(h)}}function Zs(e,t){let n;return r;function r(s){return Z(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):le(s)?fe(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const sj={name:"definition",tokenize:oj},ij={partial:!0,tokenize:aj};function oj(e,t,n){const r=this;let s;return i;function i(p){return e.enter("definition"),o(p)}function o(p){return Xw.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return s=Ut(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return xe(p)?Zs(e,u)(p):u(p)}function u(p){return Jw(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function f(p){return e.attempt(ij,d,d)(p)}function d(p){return le(p)?fe(e,h,"whitespace")(p):h(p)}function h(p){return p===null||Z(p)?(e.exit("definition"),r.parser.defined.push(s),t(p)):n(p)}}function aj(e,t,n){return r;function r(a){return xe(a)?Zs(e,s)(a):n(a)}function s(a){return Zw(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return le(a)?fe(e,o,"whitespace")(a):o(a)}function o(a){return a===null||Z(a)?t(a):n(a)}}const lj={name:"hardBreakEscape",tokenize:uj};function uj(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return Z(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const cj={name:"headingAtx",resolve:dj,tokenize:fj};function dj(e,t){let n=e.length-2,r=3,s,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},bt(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function fj(e,t,n){let r=0;return s;function s(f){return e.enter("atxHeading"),i(f)}function i(f){return e.enter("atxHeadingSequence"),o(f)}function o(f){return f===35&&r++<6?(e.consume(f),o):f===null||xe(f)?(e.exit("atxHeadingSequence"),a(f)):n(f)}function a(f){return f===35?(e.enter("atxHeadingSequence"),l(f)):f===null||Z(f)?(e.exit("atxHeading"),t(f)):le(f)?fe(e,a,"whitespace")(f):(e.enter("atxHeadingText"),u(f))}function l(f){return f===35?(e.consume(f),l):(e.exit("atxHeadingSequence"),a(f))}function u(f){return f===null||f===35||xe(f)?(e.exit("atxHeadingText"),a(f)):(e.consume(f),u)}}const hj=["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"],Op=["pre","script","style","textarea"],pj={concrete:!0,name:"htmlFlow",resolveTo:yj,tokenize:vj},mj={partial:!0,tokenize:wj},gj={partial:!0,tokenize:xj};function yj(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function vj(e,t,n){const r=this;let s,i,o,a,l;return u;function u(C){return f(C)}function f(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),d}function d(C){return C===33?(e.consume(C),h):C===47?(e.consume(C),i=!0,v):C===63?(e.consume(C),s=3,r.interrupt?t:b):nt(C)?(e.consume(C),o=String.fromCharCode(C),S):n(C)}function h(C){return C===45?(e.consume(C),s=2,p):C===91?(e.consume(C),s=5,a=0,g):nt(C)?(e.consume(C),s=4,r.interrupt?t:b):n(C)}function p(C){return C===45?(e.consume(C),r.interrupt?t:b):n(C)}function g(C){const ge="CDATA[";return C===ge.charCodeAt(a++)?(e.consume(C),a===ge.length?r.interrupt?t:N:g):n(C)}function v(C){return nt(C)?(e.consume(C),o=String.fromCharCode(C),S):n(C)}function S(C){if(C===null||C===47||C===62||xe(C)){const ge=C===47,A=o.toLowerCase();return!ge&&!i&&Op.includes(A)?(s=1,r.interrupt?t(C):N(C)):hj.includes(o.toLowerCase())?(s=6,ge?(e.consume(C),y):r.interrupt?t(C):N(C)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(C):i?x(C):w(C))}return C===45||Je(C)?(e.consume(C),o+=String.fromCharCode(C),S):n(C)}function y(C){return C===62?(e.consume(C),r.interrupt?t:N):n(C)}function x(C){return le(C)?(e.consume(C),x):_(C)}function w(C){return C===47?(e.consume(C),_):C===58||C===95||nt(C)?(e.consume(C),E):le(C)?(e.consume(C),w):_(C)}function E(C){return C===45||C===46||C===58||C===95||Je(C)?(e.consume(C),E):I(C)}function I(C){return C===61?(e.consume(C),k):le(C)?(e.consume(C),I):w(C)}function k(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),l=C,R):le(C)?(e.consume(C),k):M(C)}function R(C){return C===l?(e.consume(C),l=null,L):C===null||Z(C)?n(C):(e.consume(C),R)}function M(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||xe(C)?I(C):(e.consume(C),M)}function L(C){return C===47||C===62||le(C)?w(C):n(C)}function _(C){return C===62?(e.consume(C),z):n(C)}function z(C){return C===null||Z(C)?N(C):le(C)?(e.consume(C),z):n(C)}function N(C){return C===45&&s===2?(e.consume(C),ee):C===60&&s===1?(e.consume(C),ae):C===62&&s===4?(e.consume(C),J):C===63&&s===3?(e.consume(C),b):C===93&&s===5?(e.consume(C),D):Z(C)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(mj,Y,K)(C)):C===null||Z(C)?(e.exit("htmlFlowData"),K(C)):(e.consume(C),N)}function K(C){return e.check(gj,P,Y)(C)}function P(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),B}function B(C){return C===null||Z(C)?K(C):(e.enter("htmlFlowData"),N(C))}function ee(C){return C===45?(e.consume(C),b):N(C)}function ae(C){return C===47?(e.consume(C),o="",F):N(C)}function F(C){if(C===62){const ge=o.toLowerCase();return Op.includes(ge)?(e.consume(C),J):N(C)}return nt(C)&&o.length<8?(e.consume(C),o+=String.fromCharCode(C),F):N(C)}function D(C){return C===93?(e.consume(C),b):N(C)}function b(C){return C===62?(e.consume(C),J):C===45&&s===2?(e.consume(C),b):N(C)}function J(C){return C===null||Z(C)?(e.exit("htmlFlowData"),Y(C)):(e.consume(C),J)}function Y(C){return e.exit("htmlFlow"),t(C)}}function xj(e,t,n){const r=this;return s;function s(o){return Z(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):n(o)}function i(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function wj(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Ni,t,n)}}const bj={name:"htmlText",tokenize:Sj};function Sj(e,t,n){const r=this;let s,i,o;return a;function a(b){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(b),l}function l(b){return b===33?(e.consume(b),u):b===47?(e.consume(b),I):b===63?(e.consume(b),w):nt(b)?(e.consume(b),M):n(b)}function u(b){return b===45?(e.consume(b),f):b===91?(e.consume(b),i=0,g):nt(b)?(e.consume(b),x):n(b)}function f(b){return b===45?(e.consume(b),p):n(b)}function d(b){return b===null?n(b):b===45?(e.consume(b),h):Z(b)?(o=d,ae(b)):(e.consume(b),d)}function h(b){return b===45?(e.consume(b),p):d(b)}function p(b){return b===62?ee(b):b===45?h(b):d(b)}function g(b){const J="CDATA[";return b===J.charCodeAt(i++)?(e.consume(b),i===J.length?v:g):n(b)}function v(b){return b===null?n(b):b===93?(e.consume(b),S):Z(b)?(o=v,ae(b)):(e.consume(b),v)}function S(b){return b===93?(e.consume(b),y):v(b)}function y(b){return b===62?ee(b):b===93?(e.consume(b),y):v(b)}function x(b){return b===null||b===62?ee(b):Z(b)?(o=x,ae(b)):(e.consume(b),x)}function w(b){return b===null?n(b):b===63?(e.consume(b),E):Z(b)?(o=w,ae(b)):(e.consume(b),w)}function E(b){return b===62?ee(b):w(b)}function I(b){return nt(b)?(e.consume(b),k):n(b)}function k(b){return b===45||Je(b)?(e.consume(b),k):R(b)}function R(b){return Z(b)?(o=R,ae(b)):le(b)?(e.consume(b),R):ee(b)}function M(b){return b===45||Je(b)?(e.consume(b),M):b===47||b===62||xe(b)?L(b):n(b)}function L(b){return b===47?(e.consume(b),ee):b===58||b===95||nt(b)?(e.consume(b),_):Z(b)?(o=L,ae(b)):le(b)?(e.consume(b),L):ee(b)}function _(b){return b===45||b===46||b===58||b===95||Je(b)?(e.consume(b),_):z(b)}function z(b){return b===61?(e.consume(b),N):Z(b)?(o=z,ae(b)):le(b)?(e.consume(b),z):L(b)}function N(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),s=b,K):Z(b)?(o=N,ae(b)):le(b)?(e.consume(b),N):(e.consume(b),P)}function K(b){return b===s?(e.consume(b),s=void 0,B):b===null?n(b):Z(b)?(o=K,ae(b)):(e.consume(b),K)}function P(b){return b===null||b===34||b===39||b===60||b===61||b===96?n(b):b===47||b===62||xe(b)?L(b):(e.consume(b),P)}function B(b){return b===47||b===62||xe(b)?L(b):n(b)}function ee(b){return b===62?(e.consume(b),e.exit("htmlTextData"),e.exit("htmlText"),t):n(b)}function ae(b){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),F}function F(b){return le(b)?fe(e,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):D(b)}function D(b){return e.enter("htmlTextData"),o(b)}}const qd={name:"labelEnd",resolveAll:Ej,resolveTo:Tj,tokenize:Ij},kj={tokenize:Rj},Cj={tokenize:Pj},_j={tokenize:Aj};function Ej(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&bt(e,0,e.length,n),e}function Tj(e,t){let n=e.length,r=0,s,i,o,a;for(;n--;)if(s=e[n][1],i){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(o){if(e[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:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[i][1].start},end:{...e[o][1].end}},f={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",u,t]],a=It(a,e.slice(i+1,i+r+3)),a=It(a,[["enter",f,t]]),a=It(a,Wa(t.parser.constructs.insideSpan.null,e.slice(i+r+4,o-3),t)),a=It(a,[["exit",f,t],e[o-2],e[o-1],["exit",u,t]]),a=It(a,e.slice(o+1)),a=It(a,[["exit",l,t]]),bt(e,i,e.length,a),e}function Ij(e,t,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(Ut(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),l):n(h)}function l(h){return h===40?e.attempt(kj,f,o?f:d)(h):h===91?e.attempt(Cj,f,o?u:d)(h):o?f(h):d(h)}function u(h){return e.attempt(_j,f,d)(h)}function f(h){return t(h)}function d(h){return i._balanced=!0,n(h)}}function Rj(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),s}function s(d){return xe(d)?Zs(e,i)(d):i(d)}function i(d){return d===41?f(d):Jw(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return xe(d)?Zs(e,l)(d):f(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?Zw(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):f(d)}function u(d){return xe(d)?Zs(e,f)(d):f(d)}function f(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function Pj(e,t,n){const r=this;return s;function s(a){return Xw.call(r,e,i,o,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes(Ut(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function Aj(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),s}function s(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const jj={name:"labelStartImage",resolveAll:qd.resolveAll,tokenize:Nj};function Nj(e,t,n){const r=this;return s;function s(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),i}function i(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Mj={name:"labelStartLink",resolveAll:qd.resolveAll,tokenize:Dj};function Dj(e,t,n){const r=this;return s;function s(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),i}function i(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Ll={name:"lineEnding",tokenize:Lj};function Lj(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),fe(e,t,"linePrefix")}}const Eo={name:"thematicBreak",tokenize:Oj};function Oj(e,t,n){let r=0,s;return i;function i(u){return e.enter("thematicBreak"),o(u)}function o(u){return s=u,a(u)}function a(u){return u===s?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||Z(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===s?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),le(u)?fe(e,a,"whitespace")(u):a(u))}}const at={continuation:{tokenize:$j},exit:Vj,name:"list",tokenize:Bj},zj={partial:!0,tokenize:Hj},Fj={partial:!0,tokenize:Uj};function Bj(e,t,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(p){const g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:lc(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Eo,n,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return lc(p)&&++o<10?(e.consume(p),l):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Ni,r.interrupt?n:f,e.attempt(zj,h,d))}function f(p){return r.containerState.initialBlankLine=!0,i++,h(p)}function d(p){return le(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function $j(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Ni,s,i);function s(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,fe(e,t,"listItemIndent",r.containerState.size+1)(a)}function i(a){return r.containerState.furtherBlankLines||!le(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Fj,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,fe(e,e.attempt(at,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Uj(e,t,n){const r=this;return fe(e,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?t(i):n(i)}}function Vj(e){e.exit(this.containerState.type)}function Hj(e,t,n){const r=this;return fe(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(i){const o=r.events[r.events.length-1];return!le(i)&&o&&o[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const zp={name:"setextUnderline",resolveTo:Wj,tokenize:qj};function Wj(e,t){let n=e.length,r,s,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",i?(e.splice(s,0,["enter",o,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function qj(e,t,n){const r=this;let s;return i;function i(u){let f=r.events.length,d;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){d=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),s=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===s?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),le(u)?fe(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||Z(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Kj={tokenize:Gj};function Gj(e){const t=this,n=e.attempt(Ni,r,e.attempt(this.parser.constructs.flowInitial,s,fe(e,e.attempt(this.parser.constructs.flow,s,e.attempt(ZA,s)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Qj={resolveAll:tb()},Yj=eb("string"),Jj=eb("text");function eb(e){return{resolveAll:tb(e==="text"?Xj:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],i=n.attempt(s,o,a);return o;function o(f){return u(f)?i(f):a(f)}function a(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),l}function l(f){return u(f)?(n.exit("data"),i(f)):(n.consume(f),l)}function u(f){if(f===null)return!0;const d=s[f];let h=-1;if(d)for(;++h<d.length;){const p=d[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function tb(e){return t;function t(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 e?e(n,r):n}}function Xj(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.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(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.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):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const Zj={42:at,43:at,45:at,48:at,49:at,50:at,51:at,52:at,53:at,54:at,55:at,56:at,57:at,62:Kw},eN={91:sj},tN={[-2]:Dl,[-1]:Dl,32:Dl},nN={35:cj,42:Eo,45:[zp,Eo],60:pj,61:zp,95:Eo,96:Lp,126:Lp},rN={38:Qw,92:Gw},sN={[-5]:Ll,[-4]:Ll,[-3]:Ll,33:jj,38:Qw,42:uc,60:[MA,bj],91:Mj,92:[lj,Gw],93:qd,95:uc,96:KA},iN={null:[uc,Qj]},oN={null:[42,95]},aN={null:[]},lN=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:oN,contentInitial:eN,disable:aN,document:Zj,flow:nN,flowInitial:tN,insideSpan:iN,string:rN,text:sN},Symbol.toStringTag,{value:"Module"}));function uN(e,t,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:R(I),check:R(k),consume:x,enter:w,exit:E,interrupt:R(k,{interrupt:!0})},u={code:null,containerState:{},defineSkip:v,events:[],now:g,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:d};let f=t.tokenize.call(u,l);return t.resolveAll&&i.push(t),u;function d(z){return o=It(o,z),S(),o[o.length-1]!==null?[]:(M(t,0),u.events=Wa(i,u.events,u),u.events)}function h(z,N){return dN(p(z),N)}function p(z){return cN(o,z)}function g(){const{_bufferIndex:z,_index:N,line:K,column:P,offset:B}=r;return{_bufferIndex:z,_index:N,line:K,column:P,offset:B}}function v(z){s[z.line]=z.column,_()}function S(){let z;for(;r._index<o.length;){const N=o[r._index];if(typeof N=="string")for(z=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===z&&r._bufferIndex<N.length;)y(N.charCodeAt(r._bufferIndex));else y(N)}}function y(z){f=f(z)}function x(z){Z(z)?(r.line++,r.column=1,r.offset+=z===-3?2:1,_()):z!==-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=z}function w(z,N){const K=N||{};return K.type=z,K.start=g(),u.events.push(["enter",K,u]),a.push(K),K}function E(z){const N=a.pop();return N.end=g(),u.events.push(["exit",N,u]),N}function I(z,N){M(z,N.from)}function k(z,N){N.restore()}function R(z,N){return K;function K(P,B,ee){let ae,F,D,b;return Array.isArray(P)?Y(P):"tokenize"in P?Y([P]):J(P);function J(O){return W;function W(Q){const X=Q!==null&&O[Q],pe=Q!==null&&O.null,_e=[...Array.isArray(X)?X:X?[X]:[],...Array.isArray(pe)?pe:pe?[pe]:[]];return Y(_e)(Q)}}function Y(O){return ae=O,F=0,O.length===0?ee:C(O[F])}function C(O){return W;function W(Q){return b=L(),D=O,O.partial||(u.currentConstruct=O),O.name&&u.parser.constructs.disable.null.includes(O.name)?A():O.tokenize.call(N?Object.assign(Object.create(u),N):u,l,ge,A)(Q)}}function ge(O){return z(D,b),B}function A(O){return b.restore(),++F<ae.length?C(ae[F]):ee}}}function M(z,N){z.resolveAll&&!i.includes(z)&&i.push(z),z.resolve&&bt(u.events,N,u.events.length-N,z.resolve(u.events.slice(N),u)),z.resolveTo&&(u.events=z.resolveTo(u.events,u))}function L(){const z=g(),N=u.previous,K=u.currentConstruct,P=u.events.length,B=Array.from(a);return{from:P,restore:ee};function ee(){r=z,u.previous=N,u.currentConstruct=K,u.events.length=P,a=B,_()}}function _(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function cN(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,i=t.end._bufferIndex;let o;if(n===s)o=[e[n].slice(r,i)];else{if(o=e.slice(n,s),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}i>0&&o.push(e[s].slice(0,i))}return o}function dN(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const i=e[n];let o;if(typeof i=="string")o=i;else switch(i){case-5:{o="\r";break}case-4:{o=`
|
|
50
50
|
`;break}case-3:{o=`\r
|
|
51
|
-
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&s)continue;o=" ";break}default:o=String.fromCharCode(i)}s=i===-2,r.push(o)}return r.join("")}function cN(e){const r={constructs:Hw([oN,...(e||{}).extensions||[]]),content:s(_A),defined:[],document:s(TA),flow:s(Wj),lazy:{},string:s(Gj),text:s(Qj)};return r;function s(i){return o;function o(a){return aN(r,i,a)}}}function dN(e){for(;!Qw(e););return e}const Fp=/[\0\t\n\r]/g;function fN(){let e=1,t="",n=!0,r;return s;function s(i,o,a){const l=[];let u,f,d,h,p;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(o||void 0).decode(i)),d=0,t="",n&&(i.charCodeAt(0)===65279&&d++,n=void 0);d<i.length;){if(Fp.lastIndex=d,u=Fp.exec(i),h=u&&u.index!==void 0?u.index:i.length,p=i.charCodeAt(h),!u){t=i.slice(d);break}if(p===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)),e+=h-d),p){case 0:{l.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,l.push(-2);e++<f;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=h+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const hN=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function pN(e){return e.replace(hN,mN)}function mN(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return Ww(n.slice(i?2:1),i?16:10)}return Wd(n)||e}const tb={}.hasOwnProperty;function gN(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),yN(n)(dN(cN(n).document().write(fN()(e,t,!0))))}function yN(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(ne),autolinkProtocol:D,autolinkEmail:D,atxHeading:i(xs),blockQuote:i(pe),characterEscape:D,characterReference:D,codeFenced:i($e),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:i($e,o),codeText:i(qe,o),codeTextData:D,data:D,codeFlowValue:D,definition:i(Re),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:i(Ya),hardBreakEscape:i(_r),hardBreakTrailing:i(_r),htmlFlow:i(Er,o),htmlFlowData:D,htmlText:i(Er,o),htmlTextData:D,image:i(q),label:o,link:i(ne),listItem:i(Ne),listItemValue:h,listOrdered:i(oe,d),listUnordered:i(oe),paragraph:i(on),reference:C,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:i(xs),strong:i(ot),thematicBreak:i(Ja)},exit:{atxHeading:l(),atxHeadingSequence:I,autolink:l(),autolinkEmail:X,autolinkProtocol:Q,blockQuote:l(),characterEscapeValue:_,characterReferenceMarkerHexadecimal:L,characterReferenceMarkerNumeric:L,characterReferenceValue:O,characterReference:W,codeFenced:l(k),codeFencedFence:x,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:_,codeIndented:l(y),codeText:l(B),codeTextData:_,data:_,definition:l(),definitionDestinationString:E,definitionLabelString:v,definitionTitleString:w,emphasis:l(),hardBreakEscape:l(j),hardBreakTrailing:l(j),htmlFlow:l(K),htmlFlowData:_,htmlText:l(P),htmlTextData:_,image:l(ae),label:M,labelText:F,lineEnding:z,link:l(ee),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ge,resourceDestinationString:b,resourceTitleString:J,resource:Y,setextHeading:l(N),setextHeadingLineSequence:R,setextHeadingText:S,strong:l(),thematicBreak:l()}};nb(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(A){let H={type:"root",children:[]};const re={stack:[H],tokenStack:[],config:t,enter:a,exit:u,buffer:o,resume:f,data:n},de=[];let ye=-1;for(;++ye<A.length;)if(A[ye][1].type==="listOrdered"||A[ye][1].type==="listUnordered")if(A[ye][0]==="enter")de.push(ye);else{const Mt=de.pop();ye=s(A,Mt,ye)}for(ye=-1;++ye<A.length;){const Mt=t[A[ye][0]];tb.call(Mt,A[ye][1].type)&&Mt[A[ye][1].type].call(Object.assign({sliceSerialize:A[ye][2].sliceSerialize},re),A[ye][1])}if(re.tokenStack.length>0){const Mt=re.tokenStack[re.tokenStack.length-1];(Mt[1]||Bp).call(re,void 0,Mt[0])}for(H.position={start:kn(A.length>0?A[0][1].start:{line:1,column:1,offset:0}),end:kn(A.length>0?A[A.length-2][1].end:{line:1,column:1,offset:0})},ye=-1;++ye<t.transforms.length;)H=t.transforms[ye](H)||H;return H}function s(A,H,re){let de=H-1,ye=-1,Mt=!1,Qn,an,ws,bs;for(;++de<=re;){const gt=A[de];switch(gt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{gt[0]==="enter"?ye++:ye--,bs=void 0;break}case"lineEndingBlank":{gt[0]==="enter"&&(Qn&&!bs&&!ye&&!ws&&(ws=de),bs=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:bs=void 0}if(!ye&>[0]==="enter"&>[1].type==="listItemPrefix"||ye===-1&>[0]==="exit"&&(gt[1].type==="listUnordered"||gt[1].type==="listOrdered")){if(Qn){let Tr=de;for(an=void 0;Tr--;){const ln=A[Tr];if(ln[1].type==="lineEnding"||ln[1].type==="lineEndingBlank"){if(ln[0]==="exit")continue;an&&(A[an][1].type="lineEndingBlank",Mt=!0),ln[1].type="lineEnding",an=Tr}else if(!(ln[1].type==="linePrefix"||ln[1].type==="blockQuotePrefix"||ln[1].type==="blockQuotePrefixWhitespace"||ln[1].type==="blockQuoteMarker"||ln[1].type==="listItemIndent"))break}ws&&(!an||ws<an)&&(Qn._spread=!0),Qn.end=Object.assign({},an?A[an][1].start:gt[1].end),A.splice(an||de,0,["exit",Qn,gt[2]]),de++,re++}if(gt[1].type==="listItemPrefix"){const Tr={type:"listItem",_spread:!1,start:Object.assign({},gt[1].start),end:void 0};Qn=Tr,A.splice(de,0,["enter",Tr,gt[2]]),de++,re++,ws=void 0,bs=!0}}}return A[H][1]._spread=Mt,re}function i(A,H){return re;function re(de){a.call(this,A(de),de),H&&H.call(this,de)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(A,H,re){this.stack[this.stack.length-1].children.push(A),this.stack.push(A),this.tokenStack.push([H,re||void 0]),A.position={start:kn(H.start),end:void 0}}function l(A){return H;function H(re){A&&A.call(this,re),u.call(this,re)}}function u(A,H){const re=this.stack.pop(),de=this.tokenStack.pop();if(de)de[0].type!==A.type&&(H?H.call(this,A,de[0]):(de[1]||Bp).call(this,A,de[0]));else throw new Error("Cannot close `"+A.type+"` ("+Xs({start:A.start,end:A.end})+"): it’s not open");re.position.end=kn(A.end)}function f(){return Hd(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function h(A){if(this.data.expectingFirstListItemValue){const H=this.stack[this.stack.length-2];H.start=Number.parseInt(this.sliceSerialize(A),10),this.data.expectingFirstListItemValue=void 0}}function p(){const A=this.resume(),H=this.stack[this.stack.length-1];H.lang=A}function g(){const A=this.resume(),H=this.stack[this.stack.length-1];H.meta=A}function x(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){const A=this.resume(),H=this.stack[this.stack.length-1];H.value=A.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const A=this.resume(),H=this.stack[this.stack.length-1];H.value=A.replace(/(\r?\n|\r)$/g,"")}function v(A){const H=this.resume(),re=this.stack[this.stack.length-1];re.label=H,re.identifier=Ut(this.sliceSerialize(A)).toLowerCase()}function w(){const A=this.resume(),H=this.stack[this.stack.length-1];H.title=A}function E(){const A=this.resume(),H=this.stack[this.stack.length-1];H.url=A}function I(A){const H=this.stack[this.stack.length-1];if(!H.depth){const re=this.sliceSerialize(A).length;H.depth=re}}function S(){this.data.setextHeadingSlurpLineEnding=!0}function R(A){const H=this.stack[this.stack.length-1];H.depth=this.sliceSerialize(A).codePointAt(0)===61?1:2}function N(){this.data.setextHeadingSlurpLineEnding=void 0}function D(A){const re=this.stack[this.stack.length-1].children;let de=re[re.length-1];(!de||de.type!=="text")&&(de=qt(),de.position={start:kn(A.start),end:void 0},re.push(de)),this.stack.push(de)}function _(A){const H=this.stack.pop();H.value+=this.sliceSerialize(A),H.position.end=kn(A.end)}function z(A){const H=this.stack[this.stack.length-1];if(this.data.atHardBreak){const re=H.children[H.children.length-1];re.position.end=kn(A.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(H.type)&&(D.call(this,A),_.call(this,A))}function j(){this.data.atHardBreak=!0}function K(){const A=this.resume(),H=this.stack[this.stack.length-1];H.value=A}function P(){const A=this.resume(),H=this.stack[this.stack.length-1];H.value=A}function B(){const A=this.resume(),H=this.stack[this.stack.length-1];H.value=A}function ee(){const A=this.stack[this.stack.length-1];if(this.data.inReference){const H=this.data.referenceType||"shortcut";A.type+="Reference",A.referenceType=H,delete A.url,delete A.title}else delete A.identifier,delete A.label;this.data.referenceType=void 0}function ae(){const A=this.stack[this.stack.length-1];if(this.data.inReference){const H=this.data.referenceType||"shortcut";A.type+="Reference",A.referenceType=H,delete A.url,delete A.title}else delete A.identifier,delete A.label;this.data.referenceType=void 0}function F(A){const H=this.sliceSerialize(A),re=this.stack[this.stack.length-2];re.label=pN(H),re.identifier=Ut(H).toLowerCase()}function M(){const A=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 de=A.children;re.children=de}else re.alt=H}function b(){const A=this.resume(),H=this.stack[this.stack.length-1];H.url=A}function J(){const A=this.resume(),H=this.stack[this.stack.length-1];H.title=A}function Y(){this.data.inReference=void 0}function C(){this.data.referenceType="collapsed"}function ge(A){const H=this.resume(),re=this.stack[this.stack.length-1];re.label=H,re.identifier=Ut(this.sliceSerialize(A)).toLowerCase(),this.data.referenceType="full"}function L(A){this.data.characterReferenceType=A.type}function O(A){const H=this.sliceSerialize(A),re=this.data.characterReferenceType;let de;re?(de=Ww(H,re==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):de=Wd(H);const ye=this.stack[this.stack.length-1];ye.value+=de}function W(A){const H=this.stack.pop();H.position.end=kn(A.end)}function Q(A){_.call(this,A);const H=this.stack[this.stack.length-1];H.url=this.sliceSerialize(A)}function X(A){_.call(this,A);const H=this.stack[this.stack.length-1];H.url="mailto:"+this.sliceSerialize(A)}function pe(){return{type:"blockquote",children:[]}}function $e(){return{type:"code",lang:null,meta:null,value:""}}function qe(){return{type:"inlineCode",value:""}}function Re(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ya(){return{type:"emphasis",children:[]}}function xs(){return{type:"heading",depth:0,children:[]}}function _r(){return{type:"break"}}function Er(){return{type:"html",value:""}}function q(){return{type:"image",title:null,url:"",alt:null}}function ne(){return{type:"link",title:null,url:"",children:[]}}function oe(A){return{type:"list",ordered:A.type==="listOrdered",start:null,spread:A._spread,children:[]}}function Ne(A){return{type:"listItem",spread:A._spread,checked:null,children:[]}}function on(){return{type:"paragraph",children:[]}}function ot(){return{type:"strong",children:[]}}function qt(){return{type:"text",value:""}}function Ja(){return{type:"thematicBreak"}}}function kn(e){return{line:e.line,column:e.column,offset:e.offset}}function nb(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?nb(e,r):vN(e,r)}}function vN(e,t){let n;for(n in t)if(tb.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Bp(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Xs({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Xs({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Xs({start:t.start,end:t.end})+") is still open")}function xN(e){const t=this;t.parser=n;function n(r){return gN(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function wN(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function bN(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
52
|
-
`}]}function
|
|
53
|
-
`:"",r={},s=t.lang?t.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 t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i}function
|
|
51
|
+
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&s)continue;o=" ";break}default:o=String.fromCharCode(i)}s=i===-2,r.push(o)}return r.join("")}function fN(e){const r={constructs:Ww([lN,...(e||{}).extensions||[]]),content:s(TA),defined:[],document:s(RA),flow:s(Kj),lazy:{},string:s(Yj),text:s(Jj)};return r;function s(i){return o;function o(a){return uN(r,i,a)}}}function hN(e){for(;!Yw(e););return e}const Fp=/[\0\t\n\r]/g;function pN(){let e=1,t="",n=!0,r;return s;function s(i,o,a){const l=[];let u,f,d,h,p;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(o||void 0).decode(i)),d=0,t="",n&&(i.charCodeAt(0)===65279&&d++,n=void 0);d<i.length;){if(Fp.lastIndex=d,u=Fp.exec(i),h=u&&u.index!==void 0?u.index:i.length,p=i.charCodeAt(h),!u){t=i.slice(d);break}if(p===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)),e+=h-d),p){case 0:{l.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,l.push(-2);e++<f;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=h+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const mN=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function gN(e){return e.replace(mN,yN)}function yN(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return qw(n.slice(i?2:1),i?16:10)}return Wd(n)||e}const nb={}.hasOwnProperty;function vN(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),xN(n)(hN(fN(n).document().write(pN()(e,t,!0))))}function xN(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(ne),autolinkProtocol:L,autolinkEmail:L,atxHeading:i(xs),blockQuote:i(pe),characterEscape:L,characterReference:L,codeFenced:i(_e),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:i(_e,o),codeText:i(ze,o),codeTextData:L,data:L,codeFlowValue:L,definition:i(Pe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:i(Ya),hardBreakEscape:i(_r),hardBreakTrailing:i(_r),htmlFlow:i(Er,o),htmlFlowData:L,htmlText:i(Er,o),htmlTextData:L,image:i(q),label:o,link:i(ne),listItem:i(Me),listItemValue:h,listOrdered:i(oe,d),listUnordered:i(oe),paragraph:i(on),reference:C,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:i(xs),strong:i(ot),thematicBreak:i(Ja)},exit:{atxHeading:l(),atxHeadingSequence:I,autolink:l(),autolinkEmail:X,autolinkProtocol:Q,blockQuote:l(),characterEscapeValue:_,characterReferenceMarkerHexadecimal:A,characterReferenceMarkerNumeric:A,characterReferenceValue:O,characterReference:W,codeFenced:l(S),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:_,codeIndented:l(y),codeText:l(B),codeTextData:_,data:_,definition:l(),definitionDestinationString:E,definitionLabelString:x,definitionTitleString:w,emphasis:l(),hardBreakEscape:l(N),hardBreakTrailing:l(N),htmlFlow:l(K),htmlFlowData:_,htmlText:l(P),htmlTextData:_,image:l(ae),label:D,labelText:F,lineEnding:z,link:l(ee),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ge,resourceDestinationString:b,resourceTitleString:J,resource:Y,setextHeading:l(M),setextHeadingLineSequence:R,setextHeadingText:k,strong:l(),thematicBreak:l()}};rb(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(j){let H={type:"root",children:[]};const re={stack:[H],tokenStack:[],config:t,enter:a,exit:u,buffer:o,resume:f,data:n},de=[];let ye=-1;for(;++ye<j.length;)if(j[ye][1].type==="listOrdered"||j[ye][1].type==="listUnordered")if(j[ye][0]==="enter")de.push(ye);else{const Mt=de.pop();ye=s(j,Mt,ye)}for(ye=-1;++ye<j.length;){const Mt=t[j[ye][0]];nb.call(Mt,j[ye][1].type)&&Mt[j[ye][1].type].call(Object.assign({sliceSerialize:j[ye][2].sliceSerialize},re),j[ye][1])}if(re.tokenStack.length>0){const Mt=re.tokenStack[re.tokenStack.length-1];(Mt[1]||Bp).call(re,void 0,Mt[0])}for(H.position={start:kn(j.length>0?j[0][1].start:{line:1,column:1,offset:0}),end:kn(j.length>0?j[j.length-2][1].end:{line:1,column:1,offset:0})},ye=-1;++ye<t.transforms.length;)H=t.transforms[ye](H)||H;return H}function s(j,H,re){let de=H-1,ye=-1,Mt=!1,Yn,an,ws,bs;for(;++de<=re;){const gt=j[de];switch(gt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{gt[0]==="enter"?ye++:ye--,bs=void 0;break}case"lineEndingBlank":{gt[0]==="enter"&&(Yn&&!bs&&!ye&&!ws&&(ws=de),bs=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:bs=void 0}if(!ye&>[0]==="enter"&>[1].type==="listItemPrefix"||ye===-1&>[0]==="exit"&&(gt[1].type==="listUnordered"||gt[1].type==="listOrdered")){if(Yn){let Tr=de;for(an=void 0;Tr--;){const ln=j[Tr];if(ln[1].type==="lineEnding"||ln[1].type==="lineEndingBlank"){if(ln[0]==="exit")continue;an&&(j[an][1].type="lineEndingBlank",Mt=!0),ln[1].type="lineEnding",an=Tr}else if(!(ln[1].type==="linePrefix"||ln[1].type==="blockQuotePrefix"||ln[1].type==="blockQuotePrefixWhitespace"||ln[1].type==="blockQuoteMarker"||ln[1].type==="listItemIndent"))break}ws&&(!an||ws<an)&&(Yn._spread=!0),Yn.end=Object.assign({},an?j[an][1].start:gt[1].end),j.splice(an||de,0,["exit",Yn,gt[2]]),de++,re++}if(gt[1].type==="listItemPrefix"){const Tr={type:"listItem",_spread:!1,start:Object.assign({},gt[1].start),end:void 0};Yn=Tr,j.splice(de,0,["enter",Tr,gt[2]]),de++,re++,ws=void 0,bs=!0}}}return j[H][1]._spread=Mt,re}function i(j,H){return re;function re(de){a.call(this,j(de),de),H&&H.call(this,de)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(j,H,re){this.stack[this.stack.length-1].children.push(j),this.stack.push(j),this.tokenStack.push([H,re||void 0]),j.position={start:kn(H.start),end:void 0}}function l(j){return H;function H(re){j&&j.call(this,re),u.call(this,re)}}function u(j,H){const re=this.stack.pop(),de=this.tokenStack.pop();if(de)de[0].type!==j.type&&(H?H.call(this,j,de[0]):(de[1]||Bp).call(this,j,de[0]));else throw new Error("Cannot close `"+j.type+"` ("+Xs({start:j.start,end:j.end})+"): it’s not open");re.position.end=kn(j.end)}function f(){return Hd(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function h(j){if(this.data.expectingFirstListItemValue){const H=this.stack[this.stack.length-2];H.start=Number.parseInt(this.sliceSerialize(j),10),this.data.expectingFirstListItemValue=void 0}}function p(){const j=this.resume(),H=this.stack[this.stack.length-1];H.lang=j}function g(){const j=this.resume(),H=this.stack[this.stack.length-1];H.meta=j}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const j=this.resume(),H=this.stack[this.stack.length-1];H.value=j.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const j=this.resume(),H=this.stack[this.stack.length-1];H.value=j.replace(/(\r?\n|\r)$/g,"")}function x(j){const H=this.resume(),re=this.stack[this.stack.length-1];re.label=H,re.identifier=Ut(this.sliceSerialize(j)).toLowerCase()}function w(){const j=this.resume(),H=this.stack[this.stack.length-1];H.title=j}function E(){const j=this.resume(),H=this.stack[this.stack.length-1];H.url=j}function I(j){const H=this.stack[this.stack.length-1];if(!H.depth){const re=this.sliceSerialize(j).length;H.depth=re}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function R(j){const H=this.stack[this.stack.length-1];H.depth=this.sliceSerialize(j).codePointAt(0)===61?1:2}function M(){this.data.setextHeadingSlurpLineEnding=void 0}function L(j){const re=this.stack[this.stack.length-1].children;let de=re[re.length-1];(!de||de.type!=="text")&&(de=qt(),de.position={start:kn(j.start),end:void 0},re.push(de)),this.stack.push(de)}function _(j){const H=this.stack.pop();H.value+=this.sliceSerialize(j),H.position.end=kn(j.end)}function z(j){const H=this.stack[this.stack.length-1];if(this.data.atHardBreak){const re=H.children[H.children.length-1];re.position.end=kn(j.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(H.type)&&(L.call(this,j),_.call(this,j))}function N(){this.data.atHardBreak=!0}function K(){const j=this.resume(),H=this.stack[this.stack.length-1];H.value=j}function P(){const j=this.resume(),H=this.stack[this.stack.length-1];H.value=j}function B(){const j=this.resume(),H=this.stack[this.stack.length-1];H.value=j}function ee(){const j=this.stack[this.stack.length-1];if(this.data.inReference){const H=this.data.referenceType||"shortcut";j.type+="Reference",j.referenceType=H,delete j.url,delete j.title}else delete j.identifier,delete j.label;this.data.referenceType=void 0}function ae(){const j=this.stack[this.stack.length-1];if(this.data.inReference){const H=this.data.referenceType||"shortcut";j.type+="Reference",j.referenceType=H,delete j.url,delete j.title}else delete j.identifier,delete j.label;this.data.referenceType=void 0}function F(j){const H=this.sliceSerialize(j),re=this.stack[this.stack.length-2];re.label=gN(H),re.identifier=Ut(H).toLowerCase()}function D(){const j=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 de=j.children;re.children=de}else re.alt=H}function b(){const j=this.resume(),H=this.stack[this.stack.length-1];H.url=j}function J(){const j=this.resume(),H=this.stack[this.stack.length-1];H.title=j}function Y(){this.data.inReference=void 0}function C(){this.data.referenceType="collapsed"}function ge(j){const H=this.resume(),re=this.stack[this.stack.length-1];re.label=H,re.identifier=Ut(this.sliceSerialize(j)).toLowerCase(),this.data.referenceType="full"}function A(j){this.data.characterReferenceType=j.type}function O(j){const H=this.sliceSerialize(j),re=this.data.characterReferenceType;let de;re?(de=qw(H,re==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):de=Wd(H);const ye=this.stack[this.stack.length-1];ye.value+=de}function W(j){const H=this.stack.pop();H.position.end=kn(j.end)}function Q(j){_.call(this,j);const H=this.stack[this.stack.length-1];H.url=this.sliceSerialize(j)}function X(j){_.call(this,j);const H=this.stack[this.stack.length-1];H.url="mailto:"+this.sliceSerialize(j)}function pe(){return{type:"blockquote",children:[]}}function _e(){return{type:"code",lang:null,meta:null,value:""}}function ze(){return{type:"inlineCode",value:""}}function Pe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ya(){return{type:"emphasis",children:[]}}function xs(){return{type:"heading",depth:0,children:[]}}function _r(){return{type:"break"}}function Er(){return{type:"html",value:""}}function q(){return{type:"image",title:null,url:"",alt:null}}function ne(){return{type:"link",title:null,url:"",children:[]}}function oe(j){return{type:"list",ordered:j.type==="listOrdered",start:null,spread:j._spread,children:[]}}function Me(j){return{type:"listItem",spread:j._spread,checked:null,children:[]}}function on(){return{type:"paragraph",children:[]}}function ot(){return{type:"strong",children:[]}}function qt(){return{type:"text",value:""}}function Ja(){return{type:"thematicBreak"}}}function kn(e){return{line:e.line,column:e.column,offset:e.offset}}function rb(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?rb(e,r):wN(e,r)}}function wN(e,t){let n;for(n in t)if(nb.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Bp(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Xs({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Xs({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Xs({start:t.start,end:t.end})+") is still open")}function bN(e){const t=this;t.parser=n;function n(r){return vN(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function SN(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function kN(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
52
|
+
`}]}function CN(e,t){const n=t.value?t.value+`
|
|
53
|
+
`:"",r={},s=t.lang?t.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 t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i}function _N(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function EN(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function TN(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=vs(r.toLowerCase()),i=e.footnoteOrder.indexOf(r);let o,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=i+1,a+=1,e.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)}]};e.patch(t,l);const u={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,u),e.applyData(t,u)}function IN(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function RN(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function sb(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const s=e.all(t),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 PN(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return sb(e,t);const s={src:vs(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,i),e.applyData(t,i)}function AN(e,t){const n={src:vs(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function jN(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function NN(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return sb(e,t);const s={href:vs(r.url||"")};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function MN(e,t){const n={href:vs(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function DN(e,t,n){const r=e.all(t),s=n?LN(n):ib(t),i={},o=[];if(typeof t.checked=="boolean"){const f=r[0];let d;f&&f.type==="element"&&f.tagName==="p"?d=f:(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:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const f=r[a];(s||a!==0||f.type!=="element"||f.tagName!=="p")&&o.push({type:"text",value:`
|
|
54
54
|
`}),f.type==="element"&&f.tagName==="p"&&!s?o.push(...f.children):o.push(f)}const l=r[r.length-1];l&&(s||l.type!=="element"||l.tagName!=="p")&&o.push({type:"text",value:`
|
|
55
|
-
`});const u={type:"element",tagName:"li",properties:i,children:o};return e.patch(t,u),e.applyData(t,u)}function
|
|
55
|
+
`});const u={type:"element",tagName:"li",properties:i,children:o};return e.patch(t,u),e.applyData(t,u)}function LN(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=ib(n[r])}return t}function ib(e){const t=e.spread;return t??e.children.length>1}function ON(e,t){const n={},r=e.all(t);let s=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.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:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)}function zN(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function FN(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function BN(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $N(e,t){const n=e.all(t),r=n.shift(),s=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),s.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=Bd(t.children[1]),l=zw(t.children[t.children.length-1]);a&&l&&(o.position={start:a,end:l}),s.push(o)}const i={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,i),e.applyData(t,i)}function UN(e,t,n){const r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,a=o?o.length:t.children.length;let l=-1;const u=[];for(;++l<a;){const d=t.children[l],h={},p=o?o[l]:void 0;p&&(h.align=p);let g={type:"element",tagName:i,properties:h,children:[]};d&&(g.children=e.all(d),e.patch(d,g),g=e.applyData(d,g)),u.push(g)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,f),e.applyData(t,f)}function VN(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const $p=9,Up=32;function HN(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const i=[];for(;r;)i.push(Vp(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return i.push(Vp(t.slice(s),s>0,!1)),i.join("")}function Vp(e,t,n){let r=0,s=e.length;if(t){let i=e.codePointAt(r);for(;i===$p||i===Up;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(s-1);for(;i===$p||i===Up;)s--,i=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function WN(e,t){const n={type:"text",value:HN(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function qN(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const KN={blockquote:SN,break:kN,code:CN,delete:_N,emphasis:EN,footnoteReference:TN,heading:IN,html:RN,imageReference:PN,image:AN,inlineCode:jN,linkReference:NN,link:MN,listItem:DN,list:ON,paragraph:zN,root:FN,strong:BN,table:$N,tableCell:VN,tableRow:UN,text:WN,thematicBreak:qN,toml:io,yaml:io,definition:io,footnoteDefinition:io};function io(){}const ob=-1,qa=0,ei=1,pa=2,Kd=3,Gd=4,Qd=5,Yd=6,ab=7,lb=8,GN=typeof self=="object"?self:globalThis,Hp=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new GN[e](t)},QN=(e,t)=>{const n=(s,i)=>(e.set(i,s),s),r=s=>{if(e.has(s))return e.get(s);const[i,o]=t[s];switch(i){case qa:case ob:return n(o,s);case ei:{const a=n([],s);for(const l of o)a.push(r(l));return a}case pa:{const a=n({},s);for(const[l,u]of o)a[r(l)]=r(u);return a}case Kd:return n(new Date(o),s);case Gd:{const{source:a,flags:l}=o;return n(new RegExp(a,l),s)}case Qd:{const a=n(new Map,s);for(const[l,u]of o)a.set(r(l),r(u));return a}case Yd:{const a=n(new Set,s);for(const l of o)a.add(r(l));return a}case ab:{const{name:a,message:l}=o;return n(Hp(a,l),s)}case lb: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)}}return n(Hp(i,o),s)};return r},Wp=e=>QN(new Map,e)(0),Rr="",{toString:YN}={},{keys:JN}=Object,As=e=>{const t=typeof e;if(t!=="object"||!e)return[qa,t];const n=YN.call(e).slice(8,-1);switch(n){case"Array":return[ei,Rr];case"Object":return[pa,Rr];case"Date":return[Kd,Rr];case"RegExp":return[Gd,Rr];case"Map":return[Qd,Rr];case"Set":return[Yd,Rr];case"DataView":return[ei,n]}return n.includes("Array")?[ei,n]:n.includes("Error")?[ab,n]:[pa,n]},oo=([e,t])=>e===qa&&(t==="function"||t==="symbol"),XN=(e,t,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]=As(o);switch(a){case qa:{let f=o;switch(l){case"bigint":a=lb,f=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);f=null;break;case"undefined":return s([ob],o)}return s([a,f],o)}case ei:{if(l){let h=o;return l==="DataView"?h=new Uint8Array(o.buffer):l==="ArrayBuffer"&&(h=new Uint8Array(o)),s([l,[...h]],o)}const f=[],d=s([a,f],o);for(const h of o)f.push(i(h));return d}case pa:{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(t&&"toJSON"in o)return i(o.toJSON());const f=[],d=s([a,f],o);for(const h of JN(o))(e||!oo(As(o[h])))&&f.push([i(h),i(o[h])]);return d}case Kd:return s([a,o.toISOString()],o);case Gd:{const{source:f,flags:d}=o;return s([a,{source:f,flags:d}],o)}case Qd:{const f=[],d=s([a,f],o);for(const[h,p]of o)(e||!(oo(As(h))||oo(As(p))))&&f.push([i(h),i(p)]);return d}case Yd:{const f=[],d=s([a,f],o);for(const h of o)(e||!oo(As(h)))&&f.push(i(h));return d}}const{message:u}=o;return s([a,{name:l,message:u}],o)};return i},qp=(e,{json:t,lossy:n}={})=>{const r=[];return XN(!(t||n),!!t,new Map,r)(e),r},ma=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Wp(qp(e,t)):structuredClone(e):(e,t)=>Wp(qp(e,t));function ZN(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function eM(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function tM(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||ZN,r=e.options.footnoteBackLabel||eM,s=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[l]);if(!u)continue;const f=e.all(u),d=String(u.identifier).toUpperCase(),h=vs(d.toLowerCase());let p=0;const g=[],v=e.footnoteCounts.get(d);for(;v!==void 0&&++p<=v;){g.length>0&&g.push({type:"text",value:" "});let x=typeof n=="string"?n:n(l,p);typeof x=="string"&&(x={type:"text",value:x}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+h+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,p),className:["data-footnote-backref"]},children:Array.isArray(x)?x:[x]})}const S=f[f.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const x=S.children[S.children.length-1];x&&x.type==="text"?x.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...g)}else f.push(...g);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+h},children:e.wrap(f,!0)};e.patch(u,y),a.push(y)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...ma(o),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
|
|
56
56
|
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
|
|
57
|
-
`}]}}const Ka=function(e){if(e==null)return
|
|
57
|
+
`}]}}const Ka=function(e){if(e==null)return iM;if(typeof e=="function")return Ga(e);if(typeof e=="object")return Array.isArray(e)?nM(e):rM(e);if(typeof e=="string")return sM(e);throw new Error("Expected function, string, or object as test")};function nM(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Ka(e[n]);return Ga(r);function r(...s){let i=-1;for(;++i<t.length;)if(t[i].apply(this,s))return!0;return!1}}function rM(e){const t=e;return Ga(n);function n(r){const s=r;let i;for(i in e)if(s[i]!==t[i])return!1;return!0}}function sM(e){return Ga(t);function t(n){return n&&n.type===e}}function Ga(e){return t;function t(n,r,s){return!!(oM(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function iM(){return!0}function oM(e){return e!==null&&typeof e=="object"&&"type"in e}const ub=[],aM=!0,cc=!1,lM="skip";function cb(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const i=Ka(s),o=r?-1:1;a(e,void 0,[])();function a(l,u,f){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const p=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(h,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return h;function h(){let p=ub,g,v,S;if((!t||i(l,u,f[f.length-1]||void 0))&&(p=uM(n(l,f)),p[0]===cc))return p;if("children"in l&&l.children){const y=l;if(y.children&&p[0]!==lM)for(v=(r?y.children.length:-1)+o,S=f.concat(y);v>-1&&v<y.children.length;){const x=y.children[v];if(g=a(x,v,S)(),g[0]===cc)return g;v=typeof g[1]=="number"?g[1]:v+o}}return p}}}function uM(e){return Array.isArray(e)?e:typeof e=="number"?[aM,e]:e==null?ub:[e]}function Jd(e,t,n,r){let s,i,o;typeof t=="function"&&typeof n!="function"?(i=void 0,o=t,s=n):(i=t,o=n,s=r),cb(e,i,a,s);function a(l,u){const f=u[u.length-1],d=f?f.children.indexOf(l):void 0;return o(l,d,f)}}const dc={}.hasOwnProperty,cM={};function dM(e,t){const n=t||cM,r=new Map,s=new Map,i=new Map,o={...KN,...n.handlers},a={all:u,applyData:hM,definitionById:r,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:o,one:l,options:n,patch:fM,wrap:mM};return Jd(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const d=f.type==="definition"?r:s,h=String(f.identifier).toUpperCase();d.has(h)||d.set(h,f)}}),a;function l(f,d){const h=f.type,p=a.handlers[h];if(dc.call(a.handlers,h)&&p)return p(a,f,d);if(a.options.passThrough&&a.options.passThrough.includes(h)){if("children"in f){const{children:v,...S}=f,y=ma(S);return y.children=a.all(f),y}return ma(f)}return(a.options.unknownHandler||pM)(a,f,d)}function u(f){const d=[];if("children"in f){const h=f.children;let p=-1;for(;++p<h.length;){const g=a.one(h[p],f);if(g){if(p&&h[p-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=Kp(g.value)),!Array.isArray(g)&&g.type==="element")){const v=g.children[0];v&&v.type==="text"&&(v.value=Kp(v.value))}Array.isArray(g)?d.push(...g):d.push(g)}}}return d}}function fM(e,t){e.position&&(t.position=ZP(e))}function hM(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,i=e.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,ma(i)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function pM(e,t){const n=t.data||{},r="value"in t&&!(dc.call(n,"hProperties")||dc.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function mM(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
58
58
|
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
59
59
|
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
60
|
-
`}),n}function Kp(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Gp(e,t){const n=
|
|
61
|
-
`},s),i}function pM(e,t){return e&&"run"in e?async function(n,r){const s=Gp(n,{file:r,...t});await e.run(s,r)}:function(n,r){return Gp(n,{file:r,...e||t})}}function Qp(e){if(e)throw e}var To=Object.prototype.hasOwnProperty,cb=Object.prototype.toString,Yp=Object.defineProperty,Jp=Object.getOwnPropertyDescriptor,Xp=function(t){return typeof Array.isArray=="function"?Array.isArray(t):cb.call(t)==="[object Array]"},Zp=function(t){if(!t||cb.call(t)!=="[object Object]")return!1;var n=To.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&To.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||To.call(t,s)},em=function(t,n){Yp&&n.name==="__proto__"?Yp(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},tm=function(t,n){if(n==="__proto__")if(To.call(t,n)){if(Jp)return Jp(t,n).value}else return;return t[n]},mM=function e(){var t,n,r,s,i,o,a=arguments[0],l=1,u=arguments.length,f=!1;for(typeof a=="boolean"&&(f=a,a=arguments[1]||{},l=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});l<u;++l)if(t=arguments[l],t!=null)for(n in t)r=tm(a,n),s=tm(t,n),a!==s&&(f&&s&&(Zp(s)||(i=Xp(s)))?(i?(i=!1,o=r&&Xp(r)?r:[]):o=r&&Zp(r)?r:{},em(a,{name:n,newValue:e(f,o,s)})):typeof s<"u"&&em(a,{name:n,newValue:s}));return a};const Ol=Ei(mM);function fc(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function gM(){const e=[],t={run:n,use:r};return t;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 f=e[++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,f?yM(f,a)(...u):o(null,...u)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function yM(e,t){let n;return r;function r(...o){const a=e.length>o.length;let l;a&&o.push(s);try{l=e.apply(this,o)}catch(u){const f=u;if(a&&n)throw f;return s(f)}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,t(o,...a))}function i(o){s(null,o)}}const Yt={basename:vM,dirname:xM,extname:wM,join:bM,sep:"/"};function vM(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Mi(e);let n=0,r=-1,s=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else r<0&&(i=!0,r=s+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,a=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else o<0&&(i=!0,o=s+1),a>-1&&(e.codePointAt(s)===t.codePointAt(a--)?a<0&&(r=s):(a=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function xM(e){if(Mi(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function wM(e){Mi(e);let t=e.length,n=-1,r=0,s=-1,i=0,o;for(;t--;){const a=e.codePointAt(t);if(a===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),a===46?s<0?s=t:i!==1&&(i=1):s>-1&&(i=-1)}return s<0||n<0||i===0||i===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function bM(...e){let t=-1,n;for(;++t<e.length;)Mi(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":SM(n)}function SM(e){Mi(e);const t=e.codePointAt(0)===47;let n=kM(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function kM(e,t){let n="",r=0,s=-1,i=0,o=-1,a,l;for(;++o<=e.length;){if(o<e.length)a=e.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}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(s+1,o):n=e.slice(s+1,o),r=o-s-1;s=o,i=0}else a===46&&i>-1?i++:i=-1}return n}function Mi(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const CM={cwd:_M};function _M(){return"/"}function hc(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function EM(e){if(typeof e=="string")e=new URL(e);else if(!hc(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return TM(e)}function TM(e){if(e.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 t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.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(t)}const zl=["history","path","basename","stem","extname","dirname"];class db{constructor(t){let n;t?hc(t)?n={path:t}:typeof t=="string"||IM(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":CM.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<zl.length;){const i=zl[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)zl.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Yt.basename(this.path):void 0}set basename(t){Bl(t,"basename"),Fl(t,"basename"),this.path=Yt.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Yt.dirname(this.path):void 0}set dirname(t){nm(this.basename,"dirname"),this.path=Yt.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Yt.extname(this.path):void 0}set extname(t){if(Fl(t,"extname"),nm(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Yt.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){hc(t)&&(t=EM(t)),Bl(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Yt.basename(this.path,this.extname):void 0}set stem(t){Bl(t,"stem"),Fl(t,"stem"),this.path=Yt.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const s=this.message(t,n,r);throw s.fatal=!0,s}info(t,n,r){const s=this.message(t,n,r);return s.fatal=void 0,s}message(t,n,r){const s=new Ze(t,n,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Fl(e,t){if(e&&e.includes(Yt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Yt.sep+"`")}function Bl(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function nm(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function IM(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const RM=function(e){const r=this.constructor.prototype,s=r[e],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,r),i},PM={}.hasOwnProperty;class Xd extends RM{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=gM()}copy(){const t=new Xd;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Ol(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Vl("data",this.frozen),this.namespace[t]=n,this):PM.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Vl("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=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(t,...r);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=ao(t),r=this.parser||this.Parser;return $l("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),$l("process",this.parser||this.Parser),Ul("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(i,o){const a=ao(t),l=r.parse(a);r.run(l,a,function(f,d,h){if(f||!d||!h)return u(f);const p=d,g=r.stringify(p,h);NM(g)?h.value=g:h.result=g,u(f,h)});function u(f,d){f||!d?o(f):i?i(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),$l("processSync",this.parser||this.Parser),Ul("processSync",this.compiler||this.Compiler),this.process(t,s),sm("processSync","process",n),r;function s(i,o){n=!0,Qp(i),r=o}}run(t,n,r){rm(t),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=ao(n);s.run(t,l,u);function u(f,d,h){const p=d||t;f?a(f):o?o(p):r(void 0,p,h)}}}runSync(t,n){let r=!1,s;return this.run(t,n,i),sm("runSync","run",r),s;function i(o,a){Qp(o),s=a,r=!0}}stringify(t,n){this.freeze();const r=ao(n),s=this.compiler||this.Compiler;return Ul("stringify",s),rm(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(Vl("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(u){if(typeof u=="function")l(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[f,...d]=u;l(f,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=Ol(!0,s.settings,u.settings))}function a(u){let f=-1;if(u!=null)if(Array.isArray(u))for(;++f<u.length;){const d=u[f];i(d)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,f){let d=-1,h=-1;for(;++d<r.length;)if(r[d][0]===u){h=d;break}if(h===-1)r.push([u,...f]);else if(f.length>0){let[p,...g]=f;const x=r[h][1];fc(x)&&fc(p)&&(p=Ol(!0,x,p)),r[h]=[u,p,...g]}}}}const AM=new Xd().freeze();function $l(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Ul(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Vl(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function rm(e){if(!fc(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function sm(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ao(e){return jM(e)?e:new db(e)}function jM(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function NM(e){return typeof e=="string"||MM(e)}function MM(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const DM="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",im=[],om={allowDangerousHtml:!0},LM=/^(https?|ircs?|mailto|xmpp)$/i,OM=[{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 zM(e){const t=FM(e),n=BM(e);return $M(t.runSync(t.parse(n),n),e)}function FM(e){const t=e.rehypePlugins||im,n=e.remarkPlugins||im,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...om}:om;return AM().use(xN).use(n).use(pM,r).use(t)}function BM(e){const t=e.children||"",n=new db;return typeof t=="string"&&(n.value=t),n}function $M(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,i=t.disallowedElements,o=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||UM;for(const f of OM)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+DM+f.id,void 0);return Jd(e,u),nA(e,{Fragment:c.Fragment,components:s,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function u(f,d,h){if(f.type==="raw"&&h&&typeof d=="number")return o?h.children.splice(d,1):h.children[d]={type:"text",value:f.value},d;if(f.type==="element"){let p;for(p in Ml)if(Object.hasOwn(Ml,p)&&Object.hasOwn(f.properties,p)){const g=f.properties[p],x=Ml[p];(x===null||x.includes(f.tagName))&&(f.properties[p]=l(String(g||""),p,f))}}if(f.type==="element"){let p=n?!n.includes(f.tagName):i?i.includes(f.tagName):!1;if(!p&&r&&typeof d=="number"&&(p=!r(f,d,h)),p&&h&&typeof d=="number")return a&&f.children?h.children.splice(d,1,...f.children):h.children.splice(d,1),d}}}function UM(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||r!==-1&&t>r||LM.test(e.slice(0,t))?e:""}const{useSmooth:VM,useSmoothStatus:HM,withSmoothContextProvider:WM}=$I,qM=({components:e,componentsByLanguage:t,smooth:n=!0,preprocess:r,...s})=>{const i=Xx(),{text:o}=VM(m.useMemo(()=>r?{...i,text:r(i.text)}:i,[i,r]),n),{pre:a=XR,code:l=ZR,SyntaxHighlighter:u=Ld,CodeHeader:f=eP}=e??{},d=m.useMemo(()=>({Pre:a,Code:l,SyntaxHighlighter:u,CodeHeader:f}),[a,l,u,f]),h=mr(p=>c.jsx(iP,{components:d,componentsByLanguage:t,...p}));return c.jsx(zM,{components:m.useMemo(()=>{const{pre:p,code:g,SyntaxHighlighter:x,CodeHeader:k,...y}=e??{};return{...y,pre:JR,code:h}},[h,e]),...s,children:o})},fb=m.forwardRef(({className:e,containerProps:t,containerComponent:n="div",...r},s)=>c.jsx(n,{"data-status":HM().type,...t,className:Rw(e,t?.className),ref:s,children:c.jsx(qM,{...r})}));fb.displayName="MarkdownTextPrimitive";const KM=WM(fb);function am(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(t);for(;s!==-1;)r++,s=n.indexOf(t,s+t.length);return r}function GM(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function QM(e,t,n){const s=Ka((n||{}).ignore||[]),i=YM(t);let o=-1;for(;++o<i.length;)ub(e,"text",a);function a(u,f){let d=-1,h;for(;++d<f.length;){const p=f[d],g=h?h.children:void 0;if(s(p,g?g.indexOf(p):void 0,h))return;h=p}if(h)return l(u,f)}function l(u,f){const d=f[f.length-1],h=i[o][0],p=i[o][1];let g=0;const k=d.children.indexOf(u);let y=!1,v=[];h.lastIndex=0;let w=h.exec(u.value);for(;w;){const E=w.index,I={index:w.index,input:w.input,stack:[...f,u]};let S=p(...w,I);if(typeof S=="string"&&(S=S.length>0?{type:"text",value:S}:void 0),S===!1?h.lastIndex=E+1:(g!==E&&v.push({type:"text",value:u.value.slice(g,E)}),Array.isArray(S)?v.push(...S):S&&v.push(S),g=E+w[0].length,y=!0),!h.global)break;w=h.exec(u.value)}return y?(g<u.value.length&&v.push({type:"text",value:u.value.slice(g)}),d.children.splice(k,1,...v)):v=[u],k+v.length}}function YM(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const s=n[r];t.push([JM(s[0]),XM(s[1])])}return t}function JM(e){return typeof e=="string"?new RegExp(GM(e),"g"):e}function XM(e){return typeof e=="function"?e:function(){return e}}const Hl="phrasing",Wl=["autolink","link","image","label"];function ZM(){return{transforms:[oD],enter:{literalAutolink:tD,literalAutolinkEmail:ql,literalAutolinkHttp:ql,literalAutolinkWww:ql},exit:{literalAutolink:iD,literalAutolinkEmail:sD,literalAutolinkHttp:nD,literalAutolinkWww:rD}}}function eD(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Hl,notInConstruct:Wl},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Hl,notInConstruct:Wl},{character:":",before:"[ps]",after:"\\/",inConstruct:Hl,notInConstruct:Wl}]}}function tD(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ql(e){this.config.enter.autolinkProtocol.call(this,e)}function nD(e){this.config.exit.autolinkProtocol.call(this,e)}function rD(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function sD(e){this.config.exit.autolinkEmail.call(this,e)}function iD(e){this.exit(e)}function oD(e){QM(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,aD],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,lD]],{ignore:["link","linkReference"]})}function aD(e,t,n,r,s){let i="";if(!hb(s)||(/^w/i.test(t)&&(n=t+n,t="",i="http://"),!uD(n)))return!1;const o=cD(n+r);if(!o[0])return!1;const a={type:"link",title:null,url:i+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function lD(e,t,n,r){return!hb(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function uD(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function cD(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const s=am(e,"(");let i=am(e,")");for(;r!==-1&&s>i;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),i++;return[e,n]}function hb(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||gr(n)||Ha(n))&&(!t||n!==47)}pb.peek=xD;function dD(){this.buffer()}function fD(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function hD(){this.buffer()}function pD(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function mD(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ut(this.sliceSerialize(e)).toLowerCase(),n.label=t}function gD(e){this.exit(e)}function yD(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ut(this.sliceSerialize(e)).toLowerCase(),n.label=t}function vD(e){this.exit(e)}function xD(){return"["}function pb(e,t,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(e),{after:"]",before:i})),a(),o(),i+=s.move("]"),i}function wD(){return{enter:{gfmFootnoteCallString:dD,gfmFootnoteCall:fD,gfmFootnoteDefinitionLabelString:hD,gfmFootnoteDefinition:pD},exit:{gfmFootnoteCallString:mD,gfmFootnoteCall:gD,gfmFootnoteDefinitionLabelString:yD,gfmFootnoteDefinition:vD}}}function bD(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:pb},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"),f=i.enter("label");return l+=a.move(i.safe(i.associationId(r),{before:l,after:"]"})),f(),l+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),l+=a.move((t?`
|
|
62
|
-
`:" ")+i.indentLines(i.containerFlow(r,a.current()),t?
|
|
63
|
-
`)}function
|
|
64
|
-
`&&
|
|
65
|
-
`}function
|
|
60
|
+
`}),n}function Kp(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Gp(e,t){const n=dM(e,t),r=n.one(e,void 0),s=tM(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&i.children.push({type:"text",value:`
|
|
61
|
+
`},s),i}function gM(e,t){return e&&"run"in e?async function(n,r){const s=Gp(n,{file:r,...t});await e.run(s,r)}:function(n,r){return Gp(n,{file:r,...e||t})}}function Qp(e){if(e)throw e}var To=Object.prototype.hasOwnProperty,db=Object.prototype.toString,Yp=Object.defineProperty,Jp=Object.getOwnPropertyDescriptor,Xp=function(t){return typeof Array.isArray=="function"?Array.isArray(t):db.call(t)==="[object Array]"},Zp=function(t){if(!t||db.call(t)!=="[object Object]")return!1;var n=To.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&To.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||To.call(t,s)},em=function(t,n){Yp&&n.name==="__proto__"?Yp(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},tm=function(t,n){if(n==="__proto__")if(To.call(t,n)){if(Jp)return Jp(t,n).value}else return;return t[n]},yM=function e(){var t,n,r,s,i,o,a=arguments[0],l=1,u=arguments.length,f=!1;for(typeof a=="boolean"&&(f=a,a=arguments[1]||{},l=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});l<u;++l)if(t=arguments[l],t!=null)for(n in t)r=tm(a,n),s=tm(t,n),a!==s&&(f&&s&&(Zp(s)||(i=Xp(s)))?(i?(i=!1,o=r&&Xp(r)?r:[]):o=r&&Zp(r)?r:{},em(a,{name:n,newValue:e(f,o,s)})):typeof s<"u"&&em(a,{name:n,newValue:s}));return a};const Ol=Ei(yM);function fc(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function vM(){const e=[],t={run:n,use:r};return t;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 f=e[++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,f?xM(f,a)(...u):o(null,...u)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function xM(e,t){let n;return r;function r(...o){const a=e.length>o.length;let l;a&&o.push(s);try{l=e.apply(this,o)}catch(u){const f=u;if(a&&n)throw f;return s(f)}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,t(o,...a))}function i(o){s(null,o)}}const Yt={basename:wM,dirname:bM,extname:SM,join:kM,sep:"/"};function wM(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Mi(e);let n=0,r=-1,s=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else r<0&&(i=!0,r=s+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,a=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else o<0&&(i=!0,o=s+1),a>-1&&(e.codePointAt(s)===t.codePointAt(a--)?a<0&&(r=s):(a=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function bM(e){if(Mi(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function SM(e){Mi(e);let t=e.length,n=-1,r=0,s=-1,i=0,o;for(;t--;){const a=e.codePointAt(t);if(a===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),a===46?s<0?s=t:i!==1&&(i=1):s>-1&&(i=-1)}return s<0||n<0||i===0||i===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function kM(...e){let t=-1,n;for(;++t<e.length;)Mi(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":CM(n)}function CM(e){Mi(e);const t=e.codePointAt(0)===47;let n=_M(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function _M(e,t){let n="",r=0,s=-1,i=0,o=-1,a,l;for(;++o<=e.length;){if(o<e.length)a=e.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}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(s+1,o):n=e.slice(s+1,o),r=o-s-1;s=o,i=0}else a===46&&i>-1?i++:i=-1}return n}function Mi(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const EM={cwd:TM};function TM(){return"/"}function hc(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function IM(e){if(typeof e=="string")e=new URL(e);else if(!hc(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return RM(e)}function RM(e){if(e.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 t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.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(t)}const zl=["history","path","basename","stem","extname","dirname"];class fb{constructor(t){let n;t?hc(t)?n={path:t}:typeof t=="string"||PM(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":EM.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<zl.length;){const i=zl[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)zl.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Yt.basename(this.path):void 0}set basename(t){Bl(t,"basename"),Fl(t,"basename"),this.path=Yt.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Yt.dirname(this.path):void 0}set dirname(t){nm(this.basename,"dirname"),this.path=Yt.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Yt.extname(this.path):void 0}set extname(t){if(Fl(t,"extname"),nm(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Yt.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){hc(t)&&(t=IM(t)),Bl(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Yt.basename(this.path,this.extname):void 0}set stem(t){Bl(t,"stem"),Fl(t,"stem"),this.path=Yt.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const s=this.message(t,n,r);throw s.fatal=!0,s}info(t,n,r){const s=this.message(t,n,r);return s.fatal=void 0,s}message(t,n,r){const s=new Ze(t,n,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Fl(e,t){if(e&&e.includes(Yt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Yt.sep+"`")}function Bl(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function nm(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function PM(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const AM=function(e){const r=this.constructor.prototype,s=r[e],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,r),i},jM={}.hasOwnProperty;class Xd extends AM{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=vM()}copy(){const t=new Xd;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Ol(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Vl("data",this.frozen),this.namespace[t]=n,this):jM.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Vl("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=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(t,...r);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=ao(t),r=this.parser||this.Parser;return $l("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),$l("process",this.parser||this.Parser),Ul("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(i,o){const a=ao(t),l=r.parse(a);r.run(l,a,function(f,d,h){if(f||!d||!h)return u(f);const p=d,g=r.stringify(p,h);DM(g)?h.value=g:h.result=g,u(f,h)});function u(f,d){f||!d?o(f):i?i(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),$l("processSync",this.parser||this.Parser),Ul("processSync",this.compiler||this.Compiler),this.process(t,s),sm("processSync","process",n),r;function s(i,o){n=!0,Qp(i),r=o}}run(t,n,r){rm(t),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=ao(n);s.run(t,l,u);function u(f,d,h){const p=d||t;f?a(f):o?o(p):r(void 0,p,h)}}}runSync(t,n){let r=!1,s;return this.run(t,n,i),sm("runSync","run",r),s;function i(o,a){Qp(o),s=a,r=!0}}stringify(t,n){this.freeze();const r=ao(n),s=this.compiler||this.Compiler;return Ul("stringify",s),rm(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(Vl("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(u){if(typeof u=="function")l(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[f,...d]=u;l(f,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=Ol(!0,s.settings,u.settings))}function a(u){let f=-1;if(u!=null)if(Array.isArray(u))for(;++f<u.length;){const d=u[f];i(d)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,f){let d=-1,h=-1;for(;++d<r.length;)if(r[d][0]===u){h=d;break}if(h===-1)r.push([u,...f]);else if(f.length>0){let[p,...g]=f;const v=r[h][1];fc(v)&&fc(p)&&(p=Ol(!0,v,p)),r[h]=[u,p,...g]}}}}const NM=new Xd().freeze();function $l(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Ul(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Vl(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function rm(e){if(!fc(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function sm(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ao(e){return MM(e)?e:new fb(e)}function MM(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function DM(e){return typeof e=="string"||LM(e)}function LM(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const OM="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",im=[],om={allowDangerousHtml:!0},zM=/^(https?|ircs?|mailto|xmpp)$/i,FM=[{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 BM(e){const t=$M(e),n=UM(e);return VM(t.runSync(t.parse(n),n),e)}function $M(e){const t=e.rehypePlugins||im,n=e.remarkPlugins||im,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...om}:om;return NM().use(bN).use(n).use(gM,r).use(t)}function UM(e){const t=e.children||"",n=new fb;return typeof t=="string"&&(n.value=t),n}function VM(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,i=t.disallowedElements,o=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||HM;for(const f of FM)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+OM+f.id,void 0);return Jd(e,u),sA(e,{Fragment:c.Fragment,components:s,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function u(f,d,h){if(f.type==="raw"&&h&&typeof d=="number")return o?h.children.splice(d,1):h.children[d]={type:"text",value:f.value},d;if(f.type==="element"){let p;for(p in Ml)if(Object.hasOwn(Ml,p)&&Object.hasOwn(f.properties,p)){const g=f.properties[p],v=Ml[p];(v===null||v.includes(f.tagName))&&(f.properties[p]=l(String(g||""),p,f))}}if(f.type==="element"){let p=n?!n.includes(f.tagName):i?i.includes(f.tagName):!1;if(!p&&r&&typeof d=="number"&&(p=!r(f,d,h)),p&&h&&typeof d=="number")return a&&f.children?h.children.splice(d,1,...f.children):h.children.splice(d,1),d}}}function HM(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||r!==-1&&t>r||zM.test(e.slice(0,t))?e:""}const{useSmooth:WM,useSmoothStatus:qM,withSmoothContextProvider:KM}=VI,GM=({components:e,componentsByLanguage:t,smooth:n=!0,preprocess:r,...s})=>{const i=Zx(),{text:o}=WM(m.useMemo(()=>r?{...i,text:r(i.text)}:i,[i,r]),n),{pre:a=eP,code:l=tP,SyntaxHighlighter:u=Ld,CodeHeader:f=nP}=e??{},d=m.useMemo(()=>({Pre:a,Code:l,SyntaxHighlighter:u,CodeHeader:f}),[a,l,u,f]),h=mr(p=>c.jsx(aP,{components:d,componentsByLanguage:t,...p}));return c.jsx(BM,{components:m.useMemo(()=>{const{pre:p,code:g,SyntaxHighlighter:v,CodeHeader:S,...y}=e??{};return{...y,pre:ZR,code:h}},[h,e]),...s,children:o})},hb=m.forwardRef(({className:e,containerProps:t,containerComponent:n="div",...r},s)=>c.jsx(n,{"data-status":qM().type,...t,className:Pw(e,t?.className),ref:s,children:c.jsx(GM,{...r})}));hb.displayName="MarkdownTextPrimitive";const QM=KM(hb);function am(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(t);for(;s!==-1;)r++,s=n.indexOf(t,s+t.length);return r}function YM(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function JM(e,t,n){const s=Ka((n||{}).ignore||[]),i=XM(t);let o=-1;for(;++o<i.length;)cb(e,"text",a);function a(u,f){let d=-1,h;for(;++d<f.length;){const p=f[d],g=h?h.children:void 0;if(s(p,g?g.indexOf(p):void 0,h))return;h=p}if(h)return l(u,f)}function l(u,f){const d=f[f.length-1],h=i[o][0],p=i[o][1];let g=0;const S=d.children.indexOf(u);let y=!1,x=[];h.lastIndex=0;let w=h.exec(u.value);for(;w;){const E=w.index,I={index:w.index,input:w.input,stack:[...f,u]};let k=p(...w,I);if(typeof k=="string"&&(k=k.length>0?{type:"text",value:k}:void 0),k===!1?h.lastIndex=E+1:(g!==E&&x.push({type:"text",value:u.value.slice(g,E)}),Array.isArray(k)?x.push(...k):k&&x.push(k),g=E+w[0].length,y=!0),!h.global)break;w=h.exec(u.value)}return y?(g<u.value.length&&x.push({type:"text",value:u.value.slice(g)}),d.children.splice(S,1,...x)):x=[u],S+x.length}}function XM(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const s=n[r];t.push([ZM(s[0]),eD(s[1])])}return t}function ZM(e){return typeof e=="string"?new RegExp(YM(e),"g"):e}function eD(e){return typeof e=="function"?e:function(){return e}}const Hl="phrasing",Wl=["autolink","link","image","label"];function tD(){return{transforms:[lD],enter:{literalAutolink:rD,literalAutolinkEmail:ql,literalAutolinkHttp:ql,literalAutolinkWww:ql},exit:{literalAutolink:aD,literalAutolinkEmail:oD,literalAutolinkHttp:sD,literalAutolinkWww:iD}}}function nD(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Hl,notInConstruct:Wl},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Hl,notInConstruct:Wl},{character:":",before:"[ps]",after:"\\/",inConstruct:Hl,notInConstruct:Wl}]}}function rD(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ql(e){this.config.enter.autolinkProtocol.call(this,e)}function sD(e){this.config.exit.autolinkProtocol.call(this,e)}function iD(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function oD(e){this.config.exit.autolinkEmail.call(this,e)}function aD(e){this.exit(e)}function lD(e){JM(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,uD],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,cD]],{ignore:["link","linkReference"]})}function uD(e,t,n,r,s){let i="";if(!pb(s)||(/^w/i.test(t)&&(n=t+n,t="",i="http://"),!dD(n)))return!1;const o=fD(n+r);if(!o[0])return!1;const a={type:"link",title:null,url:i+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function cD(e,t,n,r){return!pb(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function dD(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function fD(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const s=am(e,"(");let i=am(e,")");for(;r!==-1&&s>i;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),i++;return[e,n]}function pb(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||gr(n)||Ha(n))&&(!t||n!==47)}mb.peek=bD;function hD(){this.buffer()}function pD(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function mD(){this.buffer()}function gD(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function yD(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ut(this.sliceSerialize(e)).toLowerCase(),n.label=t}function vD(e){this.exit(e)}function xD(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ut(this.sliceSerialize(e)).toLowerCase(),n.label=t}function wD(e){this.exit(e)}function bD(){return"["}function mb(e,t,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(e),{after:"]",before:i})),a(),o(),i+=s.move("]"),i}function SD(){return{enter:{gfmFootnoteCallString:hD,gfmFootnoteCall:pD,gfmFootnoteDefinitionLabelString:mD,gfmFootnoteDefinition:gD},exit:{gfmFootnoteCallString:yD,gfmFootnoteCall:vD,gfmFootnoteDefinitionLabelString:xD,gfmFootnoteDefinition:wD}}}function kD(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:mb},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"),f=i.enter("label");return l+=a.move(i.safe(i.associationId(r),{before:l,after:"]"})),f(),l+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),l+=a.move((t?`
|
|
62
|
+
`:" ")+i.indentLines(i.containerFlow(r,a.current()),t?gb:CD))),u(),l}}function CD(e,t,n){return t===0?e:gb(e,t,n)}function gb(e,t,n){return(n?"":" ")+e}const _D=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];yb.peek=PD;function ED(){return{canContainEols:["delete"],enter:{strikethrough:ID},exit:{strikethrough:RD}}}function TD(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:_D}],handlers:{delete:yb}}}function ID(e){this.enter({type:"delete",children:[]},e)}function RD(e){this.exit(e)}function yb(e,t,n,r){const s=n.createTracker(r),i=n.enter("strikethrough");let o=s.move("~~");return o+=n.containerPhrasing(e,{...s.current(),before:o,after:"~"}),o+=s.move("~~"),i(),o}function PD(){return"~"}function AD(e){return e.length}function jD(e,t){const n=t||{},r=(n.align||[]).concat(),s=n.stringLength||AD,i=[],o=[],a=[],l=[];let u=0,f=-1;for(;++f<e.length;){const v=[],S=[];let y=-1;for(e[f].length>u&&(u=e[f].length);++y<e[f].length;){const x=ND(e[f][y]);if(n.alignDelimiters!==!1){const w=s(x);S[y]=w,(l[y]===void 0||w>l[y])&&(l[y]=w)}v.push(x)}o[f]=v,a[f]=S}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<u;)i[d]=lm(r[d]);else{const v=lm(r);for(;++d<u;)i[d]=v}d=-1;const h=[],p=[];for(;++d<u;){const v=i[d];let S="",y="";v===99?(S=":",y=":"):v===108?S=":":v===114&&(y=":");let x=n.alignDelimiters===!1?1:Math.max(1,l[d]-S.length-y.length);const w=S+"-".repeat(x)+y;n.alignDelimiters!==!1&&(x=S.length+x+y.length,x>l[d]&&(l[d]=x),p[d]=x),h[d]=w}o.splice(1,0,h),a.splice(1,0,p),f=-1;const g=[];for(;++f<o.length;){const v=o[f],S=a[f];d=-1;const y=[];for(;++d<u;){const x=v[d]||"";let w="",E="";if(n.alignDelimiters!==!1){const I=l[d]-(S[d]||0),k=i[d];k===114?w=" ".repeat(I):k===99?I%2?(w=" ".repeat(I/2+.5),E=" ".repeat(I/2-.5)):(w=" ".repeat(I/2),E=w):E=" ".repeat(I)}n.delimiterStart!==!1&&!d&&y.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&x==="")&&(n.delimiterStart!==!1||d)&&y.push(" "),n.alignDelimiters!==!1&&y.push(w),y.push(x),n.alignDelimiters!==!1&&y.push(E),n.padding!==!1&&y.push(" "),(n.delimiterEnd!==!1||d!==u-1)&&y.push("|")}g.push(n.delimiterEnd===!1?y.join("").replace(/ +$/,""):y.join(""))}return g.join(`
|
|
63
|
+
`)}function ND(e){return e==null?"":String(e)}function lm(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function MD(e,t,n,r){const s=n.enter("blockquote"),i=n.createTracker(r);i.move("> "),i.shift(2);const o=n.indentLines(n.containerFlow(e,i.current()),DD);return s(),o}function DD(e,t,n){return">"+(n?"":" ")+e}function LD(e,t){return um(e,t.inConstruct,!0)&&!um(e,t.notInConstruct,!1)}function um(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function cm(e,t,n,r){let s=-1;for(;++s<n.unsafe.length;)if(n.unsafe[s].character===`
|
|
64
|
+
`&&LD(n.stack,n.unsafe[s]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
65
|
+
`}function OD(e,t){const n=String(e);let r=n.indexOf(t),s=r,i=0,o=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===s?++i>o&&(o=i):i=1,s=r+t.length,r=n.indexOf(t,s);return o}function zD(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function FD(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function BD(e,t,n,r){const s=FD(n),i=e.value||"",o=s==="`"?"GraveAccent":"Tilde";if(zD(e,n)){const d=n.enter("codeIndented"),h=n.indentLines(i,$D);return d(),h}const a=n.createTracker(r),l=s.repeat(Math.max(OD(i,s)+1,3)),u=n.enter("codeFenced");let f=a.move(l);if(e.lang){const d=n.enter(`codeFencedLang${o}`);f+=a.move(n.safe(e.lang,{before:f,after:" ",encode:["`"],...a.current()})),d()}if(e.lang&&e.meta){const d=n.enter(`codeFencedMeta${o}`);f+=a.move(" "),f+=a.move(n.safe(e.meta,{before:f,after:`
|
|
66
66
|
`,encode:["`"],...a.current()})),d()}return f+=a.move(`
|
|
67
67
|
`),i&&(f+=a.move(i+`
|
|
68
|
-
`)),f+=a.move(l),u(),f}function
|
|
69
|
-
`,...l.current()}))),a(),e.title&&(a=n.enter(`title${i}`),u+=l.move(" "+s),u+=l.move(n.safe(e.title,{before:u,after:s,...l.current()})),u+=l.move(s),a()),o(),u}function
|
|
68
|
+
`)),f+=a.move(l),u(),f}function $D(e,t,n){return(n?"":" ")+e}function Zd(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function UD(e,t,n,r){const s=Zd(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(e),{before:u,after:"]",...l.current()})),u+=l.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(a=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":`
|
|
69
|
+
`,...l.current()}))),a(),e.title&&(a=n.enter(`title${i}`),u+=l.move(" "+s),u+=l.move(n.safe(e.title,{before:u,after:s,...l.current()})),u+=l.move(s),a()),o(),u}function VD(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Ci(e){return"&#x"+e.toString(16).toUpperCase()+";"}function ga(e,t,n){const r=ls(e),s=ls(t);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}}vb.peek=HD;function vb(e,t,n,r){const s=VD(n),i=n.enter("emphasis"),o=n.createTracker(r),a=o.move(s);let l=o.move(n.containerPhrasing(e,{after:s,before:a,...o.current()}));const u=l.charCodeAt(0),f=ga(r.before.charCodeAt(r.before.length-1),u,s);f.inside&&(l=Ci(u)+l.slice(1));const d=l.charCodeAt(l.length-1),h=ga(r.after.charCodeAt(0),d,s);h.inside&&(l=l.slice(0,-1)+Ci(d));const p=o.move(s);return i(),n.attentionEncodeSurroundingInfo={after:h.outside,before:f.outside},a+l+p}function HD(e,t,n){return n.options.emphasis||"*"}function WD(e,t){let n=!1;return Jd(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,cc}),!!((!e.depth||e.depth<3)&&Hd(e)&&(t.options.setext||n))}function qD(e,t,n,r){const s=Math.max(Math.min(6,e.depth||1),1),i=n.createTracker(r);if(WD(e,n)){const f=n.enter("headingSetext"),d=n.enter("phrasing"),h=n.containerPhrasing(e,{...i.current(),before:`
|
|
70
70
|
`,after:`
|
|
71
71
|
`});return d(),f(),h+`
|
|
72
72
|
`+(s===1?"=":"-").repeat(h.length-(Math.max(h.lastIndexOf("\r"),h.lastIndexOf(`
|
|
73
73
|
`))+1))}const o="#".repeat(s),a=n.enter("headingAtx"),l=n.enter("phrasing");i.move(o+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
|
|
74
|
-
`,...i.current()});return/^[\t ]/.test(u)&&(u=Ci(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,n.options.closeAtx&&(u+=" "+o),l(),a(),u}
|
|
75
|
-
`,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(p,g,
|
|
76
|
-
`))}function l(p,g,x,k){const y=x.enter("tableCell"),v=x.enter("phrasing"),w=x.containerPhrasing(p,{...k,before:i,after:i});return v(),y(),w}function u(p,g){return PD(p,{align:g,alignDelimiters:r,padding:n,stringLength:s})}function f(p,g,x){const k=p.children;let y=-1;const v=[],w=g.enter("table");for(;++y<k.length;)v[y]=d(k[y],g,x);return w(),v}function d(p,g,x){const k=p.children;let y=-1;const v=[],w=g.enter("tableRow");for(;++y<k.length;)v[y]=l(k[y],p,g,x);return w(),v}function h(p,g,x){let k=Tb.inlineCode(p,g,x);return x.stack.includes("tableCell")&&(k=k.replace(/\|/g,"\\$&")),k}}function yL(){return{exit:{taskListCheckValueChecked:fm,taskListCheckValueUnchecked:fm,paragraph:xL}}}function vL(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:wL}}}function fm(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function xL(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const s=t.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(e)}function wL(e,t,n,r){const s=e.children[0],i=typeof e.checked=="boolean"&&s&&s.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);i&&a.move(o);let l=Tb.listItem(e,t,n,{...r,...a.current()});return i&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(f){return f+o}}function bL(){return[ZM(),wD(),CD(),cL(),yL()]}function SL(e){return{extensions:[eD(),bD(e),_D(),gL(e),vL()]}}const kL={tokenize:RL,partial:!0},Ib={tokenize:PL,partial:!0},Rb={tokenize:AL,partial:!0},Pb={tokenize:jL,partial:!0},CL={tokenize:NL,partial:!0},Ab={name:"wwwAutolink",tokenize:TL,previous:Nb},jb={name:"protocolAutolink",tokenize:IL,previous:Mb},bn={name:"emailAutolink",tokenize:EL,previous:Db},sn={};function _L(){return{text:sn}}let Jn=48;for(;Jn<123;)sn[Jn]=bn,Jn++,Jn===58?Jn=65:Jn===91&&(Jn=97);sn[43]=bn;sn[45]=bn;sn[46]=bn;sn[95]=bn;sn[72]=[bn,jb];sn[104]=[bn,jb];sn[87]=[bn,Ab];sn[119]=[bn,Ab];function EL(e,t,n){const r=this;let s,i;return o;function o(d){return!pc(d)||!Db.call(r,r.previous)||tf(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(d))}function a(d){return pc(d)?(e.consume(d),a):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(CL,f,u)(d):d===45||d===95||Je(d)?(i=!0,e.consume(d),l):f(d)}function u(d){return e.consume(d),s=!0,l}function f(d){return i&&s&&nt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function TL(e,t,n){const r=this;return s;function s(o){return o!==87&&o!==119||!Nb.call(r,r.previous)||tf(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(kL,e.attempt(Ib,e.attempt(Rb,i),n),n)(o))}function i(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function IL(e,t,n){const r=this;let s="",i=!1;return o;function o(d){return(d===72||d===104)&&Mb.call(r,r.previous)&&!tf(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(d),e.consume(d),a):n(d)}function a(d){if(nt(d)&&s.length<5)return s+=String.fromCodePoint(d),e.consume(d),a;if(d===58){const h=s.toLowerCase();if(h==="http"||h==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),i?u:(i=!0,l)):n(d)}function u(d){return d===null||ha(d)||xe(d)||gr(d)||Ha(d)?n(d):e.attempt(Ib,e.attempt(Rb,f),n)(d)}function f(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function RL(e,t,n){let r=0;return s;function s(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),s):o===46&&r===3?(e.consume(o),i):n(o)}function i(o){return o===null?n(o):t(o)}}function PL(e,t,n){let r,s,i;return o;function o(u){return u===46||u===95?e.check(Pb,l,a)(u):u===null||xe(u)||gr(u)||u!==45&&Ha(u)?l(u):(i=!0,e.consume(u),o)}function a(u){return u===95?r=!0:(s=r,r=void 0),e.consume(u),o}function l(u){return s||r||!i?n(u):t(u)}}function AL(e,t){let n=0,r=0;return s;function s(o){return o===40?(n++,e.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?e.check(Pb,t,i)(o):o===null||xe(o)||gr(o)?t(o):(e.consume(o),s)}function i(o){return o===41&&r++,e.consume(o),s}}function jL(e,t,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?(e.consume(a),r):a===38?(e.consume(a),i):a===93?(e.consume(a),s):a===60||a===null||xe(a)||gr(a)?t(a):n(a)}function s(a){return a===null||a===40||a===91||xe(a)||gr(a)?t(a):r(a)}function i(a){return nt(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):nt(a)?(e.consume(a),o):n(a)}}function NL(e,t,n){return r;function r(i){return e.consume(i),s}function s(i){return Je(i)?n(i):t(i)}}function Nb(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||xe(e)}function Mb(e){return!nt(e)}function Db(e){return!(e===47||pc(e))}function pc(e){return e===43||e===45||e===46||e===95||Je(e)}function tf(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const ML={tokenize:UL,partial:!0};function DL(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:FL,continuation:{tokenize:BL},exit:$L}},text:{91:{name:"gfmFootnoteCall",tokenize:zL},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:LL,resolveTo:OL}}}}function LL(e,t,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=Ut(r.sliceSerialize({start:o.end,end:r.now()}));return u.codePointAt(0)!==94||!i.includes(u.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function OL(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[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({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",s,t],["exit",s,t],["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function zL(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i=0,o;return a;function a(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(d){if(i>999||d===93&&!o||d===null||d===91||xe(d))return n(d);if(d===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return s.includes(Ut(r.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return xe(d)||(o=!0),i++,e.consume(d),d===92?f:u}function f(d){return d===91||d===92||d===93?(e.consume(d),i++,u):u(d)}}function FL(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i,o=0,a;return l;function l(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):n(g)}function f(g){if(o>999||g===93&&!a||g===null||g===91||xe(g))return n(g);if(g===93){e.exit("chunkString");const x=e.exit("gfmFootnoteDefinitionLabelString");return i=Ut(r.sliceSerialize(x)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return xe(g)||(a=!0),o++,e.consume(g),g===92?d:f}function d(g){return g===91||g===92||g===93?(e.consume(g),o++,f):f(g)}function h(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),s.includes(i)||s.push(i),fe(e,p,"gfmFootnoteDefinitionWhitespace")):n(g)}function p(g){return t(g)}}function BL(e,t,n){return e.check(Ni,t,e.attempt(ML,t,n))}function $L(e){e.exit("gfmFootnoteDefinition")}function UL(e,t,n){const r=this;return fe(e,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?t(i):n(i)}}function VL(e){let n=(e||{}).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 f={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",f,a],["enter",o[u][1],a],["exit",o[u][1],a],["enter",d,a]],p=a.parser.constructs.insideSpan.null;p&&bt(h,h.length,0,Wa(p,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",f,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,f=this.events;let d=0;return h;function h(g){return u===126&&f[f.length-1][1].type!=="characterEscape"?l(g):(o.enter("strikethroughSequenceTemporary"),p(g))}function p(g){const x=ls(u);if(g===126)return d>1?l(g):(o.consume(g),d++,p);if(d<2&&!n)return l(g);const k=o.exit("strikethroughSequenceTemporary"),y=ls(g);return k._open=!y||y===2&&!!x,k._close=!x||x===2&&!!y,a(g)}}}class HL{constructor(){this.map=[]}add(t,n,r){WL(this,t,n,r)}consume(t){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(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let s=r.pop();for(;s;){for(const i of s)t.push(i);s=r.pop()}this.map.length=0}}function WL(e,t,n,r){let s=0;if(!(n===0&&r.length===0)){for(;s<e.map.length;){if(e.map[s][0]===t){e.map[s][1]+=n,e.map[s][2].push(...r);return}s+=1}e.map.push([t,n,r])}}function qL(e,t){let n=!1;const r=[];for(;t<e.length;){const s=e[t];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(e[t-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);t+=1}return r}function KL(){return{flow:{null:{name:"table",tokenize:GL,resolveAll:QL}}}}function GL(e,t,n){const r=this;let s=0,i=0,o;return a;function a(_){let z=r.events.length-1;for(;z>-1;){const P=r.events[z][1].type;if(P==="lineEnding"||P==="linePrefix")z--;else break}const j=z>-1?r.events[z][1].type:null,K=j==="tableHead"||j==="tableRow"?S:l;return K===S&&r.parser.lazy[r.now().line]?n(_):K(_)}function l(_){return e.enter("tableHead"),e.enter("tableRow"),u(_)}function u(_){return _===124||(o=!0,i+=1),f(_)}function f(_){return _===null?n(_):Z(_)?i>1?(i=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),p):n(_):le(_)?fe(e,f,"whitespace")(_):(i+=1,o&&(o=!1,s+=1),_===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),o=!0,f):(e.enter("data"),d(_)))}function d(_){return _===null||_===124||xe(_)?(e.exit("data"),f(_)):(e.consume(_),_===92?h:d)}function h(_){return _===92||_===124?(e.consume(_),d):d(_)}function p(_){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(_):(e.enter("tableDelimiterRow"),o=!1,le(_)?fe(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):g(_))}function g(_){return _===45||_===58?k(_):_===124?(o=!0,e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),x):I(_)}function x(_){return le(_)?fe(e,k,"whitespace")(_):k(_)}function k(_){return _===58?(i+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),y):_===45?(i+=1,y(_)):_===null||Z(_)?E(_):I(_)}function y(_){return _===45?(e.enter("tableDelimiterFiller"),v(_)):I(_)}function v(_){return _===45?(e.consume(_),v):_===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(_))}function w(_){return le(_)?fe(e,E,"whitespace")(_):E(_)}function E(_){return _===124?g(_):_===null||Z(_)?!o||s!==i?I(_):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(_)):I(_)}function I(_){return n(_)}function S(_){return e.enter("tableRow"),R(_)}function R(_){return _===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),R):_===null||Z(_)?(e.exit("tableRow"),t(_)):le(_)?fe(e,R,"whitespace")(_):(e.enter("data"),N(_))}function N(_){return _===null||_===124||xe(_)?(e.exit("data"),R(_)):(e.consume(_),_===92?D:N)}function D(_){return _===92||_===124?(e.consume(_),N):N(_)}}function QL(e,t){let n=-1,r=!0,s=0,i=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,u,f,d;const h=new HL;for(;++n<e.length;){const p=e[n],g=p[1];p[0]==="enter"?g.type==="tableHead"?(a=!1,l!==0&&(hm(h,t,l,u,f),f=void 0,l=0),u={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",u,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,d=void 0,i=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,f={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",f,t]])),s=g.type==="tableDelimiterRow"?2:f?3:1):s&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(i[1]!==0&&(o[0]=o[1],d=lo(h,t,i,s,void 0,d),i=[0,0,0,0]),o[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(i[1]!==0&&(o[0]=o[1],d=lo(h,t,i,s,void 0,d)),i=o,o=[i[1],n,0,0])):g.type==="tableHead"?(a=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,i[1]!==0?(o[0]=o[1],d=lo(h,t,i,s,n,d)):o[1]!==0&&(d=lo(h,t,o,s,n,d)),s=0):s&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&hm(h,t,l,u,f),h.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=qL(t.events,n))}return e}function lo(e,t,n,r,s,i){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(i.end=Object.assign({},Pr(t.events,n[0])),e.add(n[0],0,[["exit",i,t]]));const l=Pr(t.events,n[1]);if(i={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",i,t]]),n[2]!==0){const u=Pr(t.events,n[2]),f=Pr(t.events,n[3]),d={type:a,start:Object.assign({},u),end:Object.assign({},f)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const h=t.events[n[2]],p=t.events[n[3]];if(h[1].end=Object.assign({},p[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,x=n[3]-n[2]-1;e.add(g,x,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return s!==void 0&&(i.end=Object.assign({},Pr(t.events,s)),e.add(s,0,[["exit",i,t]]),i=void 0),i}function hm(e,t,n,r,s){const i=[],o=Pr(t.events,n);s&&(s.end=Object.assign({},o),i.push(["exit",s,t])),r.end=Object.assign({},o),i.push(["exit",r,t]),e.add(n+1,0,i)}function Pr(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const YL={name:"tasklistCheck",tokenize:XL};function JL(){return{text:{91:YL}}}function XL(e,t,n){const r=this;return s;function s(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),i)}function i(l){return xe(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return Z(l)?t(l):le(l)?e.check({tokenize:ZL},t,n)(l):n(l)}}function ZL(e,t,n){return fe(e,r,"whitespace");function r(s){return s===null?n(s):t(s)}}function eO(e){return Hw([_L(),DL(),VL(e),KL(),JL()])}const tO={};function nO(e){const t=this,n=e||tO,r=t.data(),s=r.micromarkExtensions||(r.micromarkExtensions=[]),i=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);s.push(eO(n)),i.push(bL()),o.push(SL(n))}const rO="modulepreload",sO=function(e,t){return new URL(e,t).href},pm={},Gt=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){const o=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");s=Promise.allSettled(n.map(u=>{if(u=sO(u,r),u in pm)return;pm[u]=!0;const f=u.endsWith(".css"),d=f?'[rel="stylesheet"]':"";if(!!r)for(let g=o.length-1;g>=0;g--){const x=o[g];if(x.href===u&&(!f||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${d}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":rO,f||(p.as="script"),p.crossOrigin="",p.href=u,l&&p.setAttribute("nonce",l),document.head.appendChild(p),f)return new Promise((g,x)=>{p.addEventListener("load",g),p.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return t().catch(i)})},iO={ts:"typescript",typescript:"typescript",tsx:"typescript",js:"javascript",javascript:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",sh:"bash",bash:"bash",shell:"bash",zsh:"bash",py:"python",python:"python",diff:"diff",patch:"diff",md:"markdown",markdown:"markdown",html:"xml",xml:"xml",css:"css"};function nf(e){return e?iO[e.trim().toLowerCase()]??null:null}let Gl=null;async function oO(){return Gl||(Gl=(async()=>{const{default:e}=await Gt(async()=>{const{default:f}=await import("./core-DM2iK52g.js");return{default:f}},[],import.meta.url),[t,n,r,s,i,o,a,l,u]=await Promise.all([Gt(()=>import("./typescript-C2FFdlUC.js"),[],import.meta.url),Gt(()=>import("./javascript-BKRaQes9.js"),[],import.meta.url),Gt(()=>import("./json-DIYVocXf.js"),[],import.meta.url),Gt(()=>import("./bash-I8pq0VWm.js"),[],import.meta.url),Gt(()=>import("./python-sE43i1Pi.js"),[],import.meta.url),Gt(()=>import("./diff-DiTmLxSS.js"),[],import.meta.url),Gt(()=>import("./markdown-BrP960CR.js"),[],import.meta.url),Gt(()=>import("./xml-BXBhIUeX.js"),[],import.meta.url),Gt(()=>import("./css-DazXZka4.js"),[],import.meta.url)]);return e.registerLanguage("typescript",t.default),e.registerLanguage("javascript",n.default),e.registerLanguage("json",r.default),e.registerLanguage("bash",s.default),e.registerLanguage("python",i.default),e.registerLanguage("diff",o.default),e.registerLanguage("markdown",a.default),e.registerLanguage("xml",l.default),e.registerLanguage("css",u.default),e})()),Gl}async function Lb(e,t){const n=nf(e);if(!n)return null;try{const r=await oO(),{value:s}=r.highlight(t,{language:n,ignoreIllegals:!0});return s}catch{return null}}function aO(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n),t=t>>>0;return t.toString(36)}function lO(e,t){return"code-"+aO((e??"")+`
|
|
77
|
-
`+t)}const mm=8,
|
|
74
|
+
`,...i.current()});return/^[\t ]/.test(u)&&(u=Ci(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,n.options.closeAtx&&(u+=" "+o),l(),a(),u}xb.peek=KD;function xb(e){return e.value||""}function KD(){return"<"}wb.peek=GD;function wb(e,t,n,r){const s=Zd(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(e.alt,{before:u,after:"]",...l.current()})),u+=l.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(a=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=n.enter(`title${i}`),u+=l.move(" "+s),u+=l.move(n.safe(e.title,{before:u,after:s,...l.current()})),u+=l.move(s),a()),u+=l.move(")"),o(),u}function GD(){return"!"}bb.peek=QD;function bb(e,t,n,r){const s=e.referenceType,i=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const u=n.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(u+"]["),o();const f=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=f,i(),s==="full"||!u||u!==d?l+=a.move(d+"]"):s==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function QD(){return"!"}Sb.peek=YD;function Sb(e,t,n){let r=e.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 YD(){return"`"}function kb(e,t){const n=Hd(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Cb.peek=JD;function Cb(e,t,n,r){const s=Zd(n),i=s==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(kb(e,n)){const f=n.stack;n.stack=[],a=n.enter("autolink");let d=o.move("<");return d+=o.move(n.containerPhrasing(e,{before:d,after:">",...o.current()})),d+=o.move(">"),a(),n.stack=f,d}a=n.enter("link"),l=n.enter("label");let u=o.move("[");return u+=o.move(n.containerPhrasing(e,{before:u,after:"](",...o.current()})),u+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${i}`),u+=o.move(" "+s),u+=o.move(n.safe(e.title,{before:u,after:s,...o.current()})),u+=o.move(s),l()),u+=o.move(")"),a(),u}function JD(e,t,n){return kb(e,n)?"<":"["}_b.peek=XD;function _b(e,t,n,r){const s=e.referenceType,i=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const u=n.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(u+"]["),o();const f=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=f,i(),s==="full"||!u||u!==d?l+=a.move(d+"]"):s==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function XD(){return"["}function ef(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function ZD(e){const t=ef(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function eL(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Eb(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function tL(e,t,n,r){const s=n.enter("list"),i=n.bulletCurrent;let o=e.ordered?eL(n):ef(n);const a=e.ordered?o==="."?")":".":ZD(n);let l=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const f=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&f&&(!f.children||!f.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&&f){let d=-1;for(;++d<e.children.length;){const h=e.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(e,r);return n.bulletLastUsed=o,n.bulletCurrent=i,s(),u}function nL(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function rL(e,t,n,r){const s=nL(n);let i=n.bulletCurrent||ef(n);t&&t.type==="list"&&t.ordered&&(i=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+i);let o=i.length+1;(s==="tab"||s==="mixed"&&(t&&t.type==="list"&&t.spread||e.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(e,a.current()),f);return l(),u;function f(d,h,p){return h?(p?"":" ".repeat(o))+d:(p?i:i+" ".repeat(o-i.length))+d}}function sL(e,t,n,r){const s=n.enter("paragraph"),i=n.enter("phrasing"),o=n.containerPhrasing(e,r);return i(),s(),o}const iL=Ka(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function oL(e,t,n,r){return(e.children.some(function(o){return iL(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function aL(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Tb.peek=lL;function Tb(e,t,n,r){const s=aL(n),i=n.enter("strong"),o=n.createTracker(r),a=o.move(s+s);let l=o.move(n.containerPhrasing(e,{after:s,before:a,...o.current()}));const u=l.charCodeAt(0),f=ga(r.before.charCodeAt(r.before.length-1),u,s);f.inside&&(l=Ci(u)+l.slice(1));const d=l.charCodeAt(l.length-1),h=ga(r.after.charCodeAt(0),d,s);h.inside&&(l=l.slice(0,-1)+Ci(d));const p=o.move(s+s);return i(),n.attentionEncodeSurroundingInfo={after:h.outside,before:f.outside},a+l+p}function lL(e,t,n){return n.options.strong||"*"}function uL(e,t,n,r){return n.safe(e.value,r)}function cL(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function dL(e,t,n){const r=(Eb(n)+(n.options.ruleSpaces?" ":"")).repeat(cL(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Ib={blockquote:MD,break:cm,code:BD,definition:UD,emphasis:vb,hardBreak:cm,heading:qD,html:xb,image:wb,imageReference:bb,inlineCode:Sb,link:Cb,linkReference:_b,list:tL,listItem:rL,paragraph:sL,root:oL,strong:Tb,text:uL,thematicBreak:dL};function fL(){return{enter:{table:hL,tableData:dm,tableHeader:dm,tableRow:mL},exit:{codeText:gL,table:pL,tableData:Kl,tableHeader:Kl,tableRow:Kl}}}function hL(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function pL(e){this.exit(e),this.data.inTable=void 0}function mL(e){this.enter({type:"tableRow",children:[]},e)}function Kl(e){this.exit(e)}function dm(e){this.enter({type:"tableCell",children:[]},e)}function gL(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,yL));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function yL(e,t){return t==="|"?t:e}function vL(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,s=t.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
75
|
+
`,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(p,g,v,S){return u(f(p,v,S),p.align)}function a(p,g,v,S){const y=d(p,v,S),x=u([y]);return x.slice(0,x.indexOf(`
|
|
76
|
+
`))}function l(p,g,v,S){const y=v.enter("tableCell"),x=v.enter("phrasing"),w=v.containerPhrasing(p,{...S,before:i,after:i});return x(),y(),w}function u(p,g){return jD(p,{align:g,alignDelimiters:r,padding:n,stringLength:s})}function f(p,g,v){const S=p.children;let y=-1;const x=[],w=g.enter("table");for(;++y<S.length;)x[y]=d(S[y],g,v);return w(),x}function d(p,g,v){const S=p.children;let y=-1;const x=[],w=g.enter("tableRow");for(;++y<S.length;)x[y]=l(S[y],p,g,v);return w(),x}function h(p,g,v){let S=Ib.inlineCode(p,g,v);return v.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function xL(){return{exit:{taskListCheckValueChecked:fm,taskListCheckValueUnchecked:fm,paragraph:bL}}}function wL(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:SL}}}function fm(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function bL(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const s=t.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(e)}function SL(e,t,n,r){const s=e.children[0],i=typeof e.checked=="boolean"&&s&&s.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);i&&a.move(o);let l=Ib.listItem(e,t,n,{...r,...a.current()});return i&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(f){return f+o}}function kL(){return[tD(),SD(),ED(),fL(),xL()]}function CL(e){return{extensions:[nD(),kD(e),TD(),vL(e),wL()]}}const _L={tokenize:AL,partial:!0},Rb={tokenize:jL,partial:!0},Pb={tokenize:NL,partial:!0},Ab={tokenize:ML,partial:!0},EL={tokenize:DL,partial:!0},jb={name:"wwwAutolink",tokenize:RL,previous:Mb},Nb={name:"protocolAutolink",tokenize:PL,previous:Db},bn={name:"emailAutolink",tokenize:IL,previous:Lb},sn={};function TL(){return{text:sn}}let Xn=48;for(;Xn<123;)sn[Xn]=bn,Xn++,Xn===58?Xn=65:Xn===91&&(Xn=97);sn[43]=bn;sn[45]=bn;sn[46]=bn;sn[95]=bn;sn[72]=[bn,Nb];sn[104]=[bn,Nb];sn[87]=[bn,jb];sn[119]=[bn,jb];function IL(e,t,n){const r=this;let s,i;return o;function o(d){return!pc(d)||!Lb.call(r,r.previous)||tf(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(d))}function a(d){return pc(d)?(e.consume(d),a):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(EL,f,u)(d):d===45||d===95||Je(d)?(i=!0,e.consume(d),l):f(d)}function u(d){return e.consume(d),s=!0,l}function f(d){return i&&s&&nt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function RL(e,t,n){const r=this;return s;function s(o){return o!==87&&o!==119||!Mb.call(r,r.previous)||tf(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(_L,e.attempt(Rb,e.attempt(Pb,i),n),n)(o))}function i(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function PL(e,t,n){const r=this;let s="",i=!1;return o;function o(d){return(d===72||d===104)&&Db.call(r,r.previous)&&!tf(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(d),e.consume(d),a):n(d)}function a(d){if(nt(d)&&s.length<5)return s+=String.fromCodePoint(d),e.consume(d),a;if(d===58){const h=s.toLowerCase();if(h==="http"||h==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),i?u:(i=!0,l)):n(d)}function u(d){return d===null||ha(d)||xe(d)||gr(d)||Ha(d)?n(d):e.attempt(Rb,e.attempt(Pb,f),n)(d)}function f(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function AL(e,t,n){let r=0;return s;function s(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),s):o===46&&r===3?(e.consume(o),i):n(o)}function i(o){return o===null?n(o):t(o)}}function jL(e,t,n){let r,s,i;return o;function o(u){return u===46||u===95?e.check(Ab,l,a)(u):u===null||xe(u)||gr(u)||u!==45&&Ha(u)?l(u):(i=!0,e.consume(u),o)}function a(u){return u===95?r=!0:(s=r,r=void 0),e.consume(u),o}function l(u){return s||r||!i?n(u):t(u)}}function NL(e,t){let n=0,r=0;return s;function s(o){return o===40?(n++,e.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?e.check(Ab,t,i)(o):o===null||xe(o)||gr(o)?t(o):(e.consume(o),s)}function i(o){return o===41&&r++,e.consume(o),s}}function ML(e,t,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?(e.consume(a),r):a===38?(e.consume(a),i):a===93?(e.consume(a),s):a===60||a===null||xe(a)||gr(a)?t(a):n(a)}function s(a){return a===null||a===40||a===91||xe(a)||gr(a)?t(a):r(a)}function i(a){return nt(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):nt(a)?(e.consume(a),o):n(a)}}function DL(e,t,n){return r;function r(i){return e.consume(i),s}function s(i){return Je(i)?n(i):t(i)}}function Mb(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||xe(e)}function Db(e){return!nt(e)}function Lb(e){return!(e===47||pc(e))}function pc(e){return e===43||e===45||e===46||e===95||Je(e)}function tf(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const LL={tokenize:HL,partial:!0};function OL(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:$L,continuation:{tokenize:UL},exit:VL}},text:{91:{name:"gfmFootnoteCall",tokenize:BL},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:zL,resolveTo:FL}}}}function zL(e,t,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=Ut(r.sliceSerialize({start:o.end,end:r.now()}));return u.codePointAt(0)!==94||!i.includes(u.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function FL(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[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({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",s,t],["exit",s,t],["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function BL(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i=0,o;return a;function a(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(d){if(i>999||d===93&&!o||d===null||d===91||xe(d))return n(d);if(d===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return s.includes(Ut(r.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return xe(d)||(o=!0),i++,e.consume(d),d===92?f:u}function f(d){return d===91||d===92||d===93?(e.consume(d),i++,u):u(d)}}function $L(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i,o=0,a;return l;function l(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):n(g)}function f(g){if(o>999||g===93&&!a||g===null||g===91||xe(g))return n(g);if(g===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return i=Ut(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return xe(g)||(a=!0),o++,e.consume(g),g===92?d:f}function d(g){return g===91||g===92||g===93?(e.consume(g),o++,f):f(g)}function h(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),s.includes(i)||s.push(i),fe(e,p,"gfmFootnoteDefinitionWhitespace")):n(g)}function p(g){return t(g)}}function UL(e,t,n){return e.check(Ni,t,e.attempt(LL,t,n))}function VL(e){e.exit("gfmFootnoteDefinition")}function HL(e,t,n){const r=this;return fe(e,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?t(i):n(i)}}function WL(e){let n=(e||{}).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 f={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",f,a],["enter",o[u][1],a],["exit",o[u][1],a],["enter",d,a]],p=a.parser.constructs.insideSpan.null;p&&bt(h,h.length,0,Wa(p,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",f,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,f=this.events;let d=0;return h;function h(g){return u===126&&f[f.length-1][1].type!=="characterEscape"?l(g):(o.enter("strikethroughSequenceTemporary"),p(g))}function p(g){const v=ls(u);if(g===126)return d>1?l(g):(o.consume(g),d++,p);if(d<2&&!n)return l(g);const S=o.exit("strikethroughSequenceTemporary"),y=ls(g);return S._open=!y||y===2&&!!v,S._close=!v||v===2&&!!y,a(g)}}}class qL{constructor(){this.map=[]}add(t,n,r){KL(this,t,n,r)}consume(t){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(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let s=r.pop();for(;s;){for(const i of s)t.push(i);s=r.pop()}this.map.length=0}}function KL(e,t,n,r){let s=0;if(!(n===0&&r.length===0)){for(;s<e.map.length;){if(e.map[s][0]===t){e.map[s][1]+=n,e.map[s][2].push(...r);return}s+=1}e.map.push([t,n,r])}}function GL(e,t){let n=!1;const r=[];for(;t<e.length;){const s=e[t];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(e[t-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);t+=1}return r}function QL(){return{flow:{null:{name:"table",tokenize:YL,resolveAll:JL}}}}function YL(e,t,n){const r=this;let s=0,i=0,o;return a;function a(_){let z=r.events.length-1;for(;z>-1;){const P=r.events[z][1].type;if(P==="lineEnding"||P==="linePrefix")z--;else break}const N=z>-1?r.events[z][1].type:null,K=N==="tableHead"||N==="tableRow"?k:l;return K===k&&r.parser.lazy[r.now().line]?n(_):K(_)}function l(_){return e.enter("tableHead"),e.enter("tableRow"),u(_)}function u(_){return _===124||(o=!0,i+=1),f(_)}function f(_){return _===null?n(_):Z(_)?i>1?(i=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),p):n(_):le(_)?fe(e,f,"whitespace")(_):(i+=1,o&&(o=!1,s+=1),_===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),o=!0,f):(e.enter("data"),d(_)))}function d(_){return _===null||_===124||xe(_)?(e.exit("data"),f(_)):(e.consume(_),_===92?h:d)}function h(_){return _===92||_===124?(e.consume(_),d):d(_)}function p(_){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(_):(e.enter("tableDelimiterRow"),o=!1,le(_)?fe(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):g(_))}function g(_){return _===45||_===58?S(_):_===124?(o=!0,e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),v):I(_)}function v(_){return le(_)?fe(e,S,"whitespace")(_):S(_)}function S(_){return _===58?(i+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),y):_===45?(i+=1,y(_)):_===null||Z(_)?E(_):I(_)}function y(_){return _===45?(e.enter("tableDelimiterFiller"),x(_)):I(_)}function x(_){return _===45?(e.consume(_),x):_===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(_))}function w(_){return le(_)?fe(e,E,"whitespace")(_):E(_)}function E(_){return _===124?g(_):_===null||Z(_)?!o||s!==i?I(_):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(_)):I(_)}function I(_){return n(_)}function k(_){return e.enter("tableRow"),R(_)}function R(_){return _===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),R):_===null||Z(_)?(e.exit("tableRow"),t(_)):le(_)?fe(e,R,"whitespace")(_):(e.enter("data"),M(_))}function M(_){return _===null||_===124||xe(_)?(e.exit("data"),R(_)):(e.consume(_),_===92?L:M)}function L(_){return _===92||_===124?(e.consume(_),M):M(_)}}function JL(e,t){let n=-1,r=!0,s=0,i=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,u,f,d;const h=new qL;for(;++n<e.length;){const p=e[n],g=p[1];p[0]==="enter"?g.type==="tableHead"?(a=!1,l!==0&&(hm(h,t,l,u,f),f=void 0,l=0),u={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",u,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,d=void 0,i=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,f={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",f,t]])),s=g.type==="tableDelimiterRow"?2:f?3:1):s&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(i[1]!==0&&(o[0]=o[1],d=lo(h,t,i,s,void 0,d),i=[0,0,0,0]),o[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(i[1]!==0&&(o[0]=o[1],d=lo(h,t,i,s,void 0,d)),i=o,o=[i[1],n,0,0])):g.type==="tableHead"?(a=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,i[1]!==0?(o[0]=o[1],d=lo(h,t,i,s,n,d)):o[1]!==0&&(d=lo(h,t,o,s,n,d)),s=0):s&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&hm(h,t,l,u,f),h.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=GL(t.events,n))}return e}function lo(e,t,n,r,s,i){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(i.end=Object.assign({},Pr(t.events,n[0])),e.add(n[0],0,[["exit",i,t]]));const l=Pr(t.events,n[1]);if(i={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",i,t]]),n[2]!==0){const u=Pr(t.events,n[2]),f=Pr(t.events,n[3]),d={type:a,start:Object.assign({},u),end:Object.assign({},f)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const h=t.events[n[2]],p=t.events[n[3]];if(h[1].end=Object.assign({},p[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,v=n[3]-n[2]-1;e.add(g,v,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return s!==void 0&&(i.end=Object.assign({},Pr(t.events,s)),e.add(s,0,[["exit",i,t]]),i=void 0),i}function hm(e,t,n,r,s){const i=[],o=Pr(t.events,n);s&&(s.end=Object.assign({},o),i.push(["exit",s,t])),r.end=Object.assign({},o),i.push(["exit",r,t]),e.add(n+1,0,i)}function Pr(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const XL={name:"tasklistCheck",tokenize:eO};function ZL(){return{text:{91:XL}}}function eO(e,t,n){const r=this;return s;function s(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),i)}function i(l){return xe(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return Z(l)?t(l):le(l)?e.check({tokenize:tO},t,n)(l):n(l)}}function tO(e,t,n){return fe(e,r,"whitespace");function r(s){return s===null?n(s):t(s)}}function nO(e){return Ww([TL(),OL(),WL(e),QL(),ZL()])}const rO={};function sO(e){const t=this,n=e||rO,r=t.data(),s=r.micromarkExtensions||(r.micromarkExtensions=[]),i=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);s.push(nO(n)),i.push(kL()),o.push(CL(n))}const iO="modulepreload",oO=function(e,t){return new URL(e,t).href},pm={},Gt=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){const o=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");s=Promise.allSettled(n.map(u=>{if(u=oO(u,r),u in pm)return;pm[u]=!0;const f=u.endsWith(".css"),d=f?'[rel="stylesheet"]':"";if(!!r)for(let g=o.length-1;g>=0;g--){const v=o[g];if(v.href===u&&(!f||v.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${d}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":iO,f||(p.as="script"),p.crossOrigin="",p.href=u,l&&p.setAttribute("nonce",l),document.head.appendChild(p),f)return new Promise((g,v)=>{p.addEventListener("load",g),p.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return t().catch(i)})},aO={ts:"typescript",typescript:"typescript",tsx:"typescript",js:"javascript",javascript:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",sh:"bash",bash:"bash",shell:"bash",zsh:"bash",py:"python",python:"python",diff:"diff",patch:"diff",md:"markdown",markdown:"markdown",html:"xml",xml:"xml",css:"css"};function nf(e){return e?aO[e.trim().toLowerCase()]??null:null}let Gl=null;async function lO(){return Gl||(Gl=(async()=>{const{default:e}=await Gt(async()=>{const{default:f}=await import("./core-DjwRjAVq.js");return{default:f}},[],import.meta.url),[t,n,r,s,i,o,a,l,u]=await Promise.all([Gt(()=>import("./typescript-C2FFdlUC.js"),[],import.meta.url),Gt(()=>import("./javascript-BKRaQes9.js"),[],import.meta.url),Gt(()=>import("./json-DIYVocXf.js"),[],import.meta.url),Gt(()=>import("./bash-I8pq0VWm.js"),[],import.meta.url),Gt(()=>import("./python-sE43i1Pi.js"),[],import.meta.url),Gt(()=>import("./diff-DiTmLxSS.js"),[],import.meta.url),Gt(()=>import("./markdown-BrP960CR.js"),[],import.meta.url),Gt(()=>import("./xml-BXBhIUeX.js"),[],import.meta.url),Gt(()=>import("./css-DazXZka4.js"),[],import.meta.url)]);return e.registerLanguage("typescript",t.default),e.registerLanguage("javascript",n.default),e.registerLanguage("json",r.default),e.registerLanguage("bash",s.default),e.registerLanguage("python",i.default),e.registerLanguage("diff",o.default),e.registerLanguage("markdown",a.default),e.registerLanguage("xml",l.default),e.registerLanguage("css",u.default),e})()),Gl}async function Ob(e,t){const n=nf(e);if(!n)return null;try{const r=await lO(),{value:s}=r.highlight(t,{language:n,ignoreIllegals:!0});return s}catch{return null}}function uO(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n),t=t>>>0;return t.toString(36)}function cO(e,t){return"code-"+uO((e??"")+`
|
|
77
|
+
`+t)}const mm=8,zb=m.createContext(null);function rf(){const e=m.useContext(zb);if(!e)throw new Error("useArtifactPanel must be used inside <ArtifactPanelProvider>");return e}function dO(e,t){const n=e.artifacts.findIndex(s=>s.id===t.id);if(n>=0)return{artifacts:[e.artifacts[n],...e.artifacts.filter((i,o)=>o!==n)],activeId:t.id};const r=[t,...e.artifacts];return{artifacts:r.length>mm?r.slice(0,mm):r,activeId:t.id}}function fO(e,t){const n=e.artifacts.findIndex(i=>i.id===t);if(n<0)return e;const r=e.artifacts.filter((i,o)=>o!==n);let s=e.activeId;if(e.activeId===t)if(r.length===0)s=null;else{const i=Math.min(n,r.length-1);s=r[i].id}return{artifacts:r,activeId:s}}function hO({children:e}){const[t,n]=m.useState({artifacts:[],activeId:null}),r=m.useCallback(a=>{n(l=>dO(l,a))},[]),s=m.useCallback(a=>{n(l=>({...l,activeId:a}))},[]),i=m.useCallback(a=>{n(l=>fO(l,a))},[]),o=m.useMemo(()=>({artifacts:t.artifacts,activeId:t.activeId,open:r,setActive:s,close:i}),[t,r,s,i]);return c.jsx(zb.Provider,{value:o,children:e})}const pO=({language:e,code:t})=>{const{open:n}=rf();if(!e)return null;const r=typeof t=="string"&&t.length>0,s=()=>{if(!r||typeof t!="string")return;const i=e||"code";n({id:cO(e,t),kind:"code",title:i,language:e,content:t})};return c.jsxs("div",{className:"aui-md-code-lang",children:[c.jsx("span",{className:"aui-md-code-lang-name",children:e}),r?c.jsx("button",{type:"button",className:"aui-md-code-open-btn",onClick:s,title:"Open in side panel","aria-label":`Open ${e} code in side panel`,children:"↗"}):null]})},mO=({components:e,language:t,code:n})=>{const{Pre:r,Code:s}=e,i=nf(t)!==null,[o,a]=m.useState(null);return m.useEffect(()=>{if(!i){a(null);return}let l=!0;return a(null),Ob(t,n).then(u=>{l&&a(u)}).catch(()=>{l&&a(null)}),()=>{l=!1}},[i,t,n]),i&&o!=null?c.jsx(r,{children:c.jsx(s,{className:"hljs",dangerouslySetInnerHTML:{__html:o}})}):c.jsx(r,{children:c.jsx(s,{className:i?"hljs":void 0,children:n})})},gO=({node:e,...t})=>c.jsx("div",{className:"md-table-wrap",children:c.jsx("table",{...t})}),yO=()=>c.jsx(QM,{className:"aui-md",remarkPlugins:[sO],components:{CodeHeader:pO,SyntaxHighlighter:mO,table:gO}}),vO=m.memo(yO);function xO(e){const[t,n]=m.useState(null);return m.useEffect(()=>{let r=!1,s=null;return Oe(fR(e)).then(i=>i.ok?i.blob():null).then(i=>{!i||r||(s=URL.createObjectURL(i),n(s))}).catch(()=>{}),()=>{r=!0,s&&URL.revokeObjectURL(s),n(null)}},[e]),t}const wO=new Set([".jpg",".jpeg",".png",".gif",".webp",".avif",".heic",".heif",".svg"]),gm=/(?:^|\s)(\/[^\s]*\/\.claude-control\/uploads\/([^\s]+))/g;function bO(e){const t=[],n=new Set;let r;for(gm.lastIndex=0;(r=gm.exec(e))!==null;){const s=r[1].trim();if(n.has(s))continue;n.add(s);const i=r[2],o=i.slice(i.lastIndexOf(".")).toLowerCase();t.push({fullPath:s,basename:i,isImage:wO.has(o)})}return t}function SO({src:e,alt:t,onClose:n}){const r=m.useRef(null);m.useEffect(()=>{r.current?.focus()},[]);const s=m.useCallback(i=>{i.key==="Escape"&&(i.preventDefault(),n())},[n]);return c.jsx("div",{className:"lightbox-backdrop",role:"dialog","aria-modal":"true","aria-label":`Preview: ${t}`,ref:r,tabIndex:-1,onClick:n,onKeyDown:s,children:c.jsx("img",{className:"lightbox-img",src:e,alt:t,onClick:i=>i.stopPropagation()})})}function kO({ref_:e}){const[t,n]=m.useState(!1),r=xO(e.basename);return e.isImage?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"transcript-thumb-btn","aria-label":`Preview ${e.basename}`,title:e.basename,onClick:()=>n(!0),children:r?c.jsx("img",{className:"transcript-thumb",src:r,alt:e.basename,loading:"lazy"}):c.jsx("span",{className:"transcript-thumb transcript-thumb-loading","aria-hidden":"true"})}),t&&r?c.jsx(SO,{src:r,alt:e.basename,onClose:()=>n(!1)}):null]}):c.jsxs("a",{className:"transcript-file-chip",href:r??void 0,download:e.basename,"aria-label":`Download ${e.basename}`,title:e.basename,"aria-disabled":r?void 0:!0,children:[c.jsx("span",{className:"chip-icon","aria-hidden":"true",children:"📎"}),c.jsx("span",{className:"chip-name",children:e.basename})]})}function CO({text:e}){const t=bO(e);return t.length===0?null:c.jsx("div",{className:"transcript-attachments","aria-label":"Attachments",children:t.map(n=>c.jsx(kO,{ref_:n},n.fullPath))})}function _O(e){return e.trimStart().startsWith("Base directory for this skill:")}function EO(e){const n=e.trim().replace(/\/SKILL\.md$/i,"").split("/").filter(Boolean);return n[n.length-1]??"skill"}function TO(e){const t=e.split(`
|
|
78
78
|
`);if(t[0]?.trim()!=="---")return{entries:[],rest:e};const n=[];let r=-1;for(let i=1;i<t.length;i++){if(t[i].trim()==="---"){r=i;break}const o=t[i].indexOf(":");if(o!==-1){const a=t[i].slice(0,o).trim(),l=t[i].slice(o+1).trim();a&&n.push({key:a,value:l})}}if(r===-1)return{entries:[],rest:e};const s=t.slice(r+1).join(`
|
|
79
|
-
`);return{entries:n,rest:s}}function
|
|
80
|
-
`),s=(t[0]??"").match(/Base directory for this skill:\s*(.+)/)?.[1]??"",i=
|
|
81
|
-
`).trimStart(),{entries:a,rest:l}=
|
|
82
|
-
`);for(let n=t.length-1;n>=0;n--){const r=t[n].trim();if(r)return r.length>ym?r.slice(0,ym-1)+"…":r}return""}function
|
|
79
|
+
`);return{entries:n,rest:s}}function IO(e){const t=e.trimStart().split(`
|
|
80
|
+
`),s=(t[0]??"").match(/Base directory for this skill:\s*(.+)/)?.[1]??"",i=EO(s),o=t.slice(1).join(`
|
|
81
|
+
`).trimStart(),{entries:a,rest:l}=TO(o),u=a.find(d=>d.key==="name")?.value??null,f=a.find(d=>d.key==="description")?.value??null;return{name:u??i,description:f,frontmatter:a,body:l.trimStart()}}const RO={UserMessage:Qa,AssistantMessage:Wn,SystemMessage:Wn};function PO({markdown:e}){const t=m.useMemo(()=>[{role:"assistant",id:"skill-body",content:[{type:"text",text:e}],metadata:{custom:{cockpitRole:"assistant"}}}],[e]),n=Fa({messages:t,isDisabled:!0,convertMessage:r=>r,onNew:async()=>{}});return c.jsx(Ba,{runtime:n,children:c.jsx(dt.Root,{className:"skill-body-thread",children:c.jsx(dt.Viewport,{className:"skill-body-viewport",children:c.jsx(dt.Messages,{components:RO})})})})}function AO({parsed:e,onClose:t}){return m.useEffect(()=>{const n=r=>{r.key==="Escape"&&(r.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]),c.jsx("div",{className:"modal-backdrop",onClick:n=>{n.target===n.currentTarget&&t()},children:c.jsxs("div",{className:"modal modal-skill",role:"dialog","aria-modal":"true","aria-label":`Skill: ${e.name}`,children:[c.jsxs("div",{className:"modal-head",children:[c.jsxs("span",{className:"modal-title modal-title-skill",children:["🧩 Skill: ",e.name]}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Close skill detail",onClick:t,children:"✕"})]}),c.jsxs("div",{className:"modal-body skill-modal-body",children:[e.frontmatter.length>0&&c.jsx("dl",{className:"skill-fm",children:e.frontmatter.map(({key:n,value:r})=>c.jsxs("div",{className:"skill-fm-row",children:[c.jsx("dt",{className:"skill-fm-key",children:n}),c.jsx("dd",{className:"skill-fm-val",children:r})]},n))}),e.body.length>0&&c.jsx("div",{className:"skill-body-wrap",children:c.jsx(PO,{markdown:e.body})})]})]})})}function jO({text:e}){const[t,n]=m.useState(!1),r=m.useMemo(()=>IO(e),[e]);return c.jsxs(c.Fragment,{children:[c.jsxs("button",{type:"button",className:"skill-chip",onClick:()=>n(!0),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),n(!0))},title:r.description??`Skill: ${r.name}`,children:[c.jsx("span",{className:"skill-chip-icon","aria-hidden":"true",children:"🧩"}),c.jsx("span",{className:"skill-chip-name",children:r.name}),c.jsx("span",{className:"skill-chip-tag",children:"skill"})]}),t&&c.jsx(AO,{parsed:r,onClose:()=>n(!1)})]})}const NO=/^\s*working…?\s*$/i,MO=e=>typeof e.text=="string"&&NO.test(e.text)?c.jsxs("span",{className:"working-indicator",role:"status","aria-live":"polite",children:[c.jsx("span",{className:"working-spinner","aria-hidden":"true"}),c.jsx("span",{className:"shimmer-text",children:"Working…"})]}):typeof e.text=="string"&&_O(e.text)?c.jsx(jO,{text:e.text}):c.jsxs(c.Fragment,{children:[c.jsx(vO,{...e}),typeof e.text=="string"?c.jsx(CO,{text:e.text}):null]}),ym=90;function DO(e){const t=e.split(`
|
|
82
|
+
`);for(let n=t.length-1;n>=0;n--){const r=t[n].trim();if(r)return r.length>ym?r.slice(0,ym-1)+"…":r}return""}function LO(e){const t=bw(e);if(t==null||typeof t=="object"&&Object.keys(t).length===0)return"";try{return JSON.stringify(t,null,2)}catch{return String(t)}}const OO=({toolCallId:e,toolName:t,args:n,result:r})=>{const{open:s}=rf(),[i,o]=m.useState(!1),a=TR(n),l=LO(n),u=IR(r),f=l.length>0||u!=null,d=bw(n),h=d&&typeof d=="object"&&"file_path"in d?String(d.file_path):void 0,p=h&&h.includes(".")?h.split(".").pop():void 0,g=u?.text??l,v=g.length>0,S=()=>{v&&s({id:e,kind:"tool",title:t+(a?` — ${a}`:""),language:p,content:g,filePath:h})},y=v?c.jsx("button",{type:"button",className:"tool-name tool-name-btn",onClick:S,title:"Open in side panel",children:t}):c.jsx("span",{className:"tool-name",children:t}),x=c.jsxs("span",{className:"tool-head",children:[f?c.jsx("button",{type:"button",className:"tool-arrow-btn","aria-expanded":i,"aria-label":i?"Collapse":"Expand",onClick:()=>o(w=>!w),children:c.jsx("span",{className:"tool-arrow","data-peek":i?"true":"false","aria-hidden":"true",children:"▸"})}):c.jsx("span",{className:"tool-arrow","aria-hidden":"true",children:"▸"}),y,a?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"tool-sep",children:"—"}),c.jsx("span",{className:"tool-input",children:a})]}):null]});return c.jsxs("div",{className:"block-tool",children:[c.jsx("div",{className:"block-tool-use",children:x}),f&&i?c.jsxs("div",{className:"block-tool-body",children:[l?c.jsx("pre",{className:"block-tool-args",children:l}):null,u!=null?c.jsx("div",{className:"block-tool-result","data-error":u.isError?"true":"false",children:u.text}):null]}):null]})},Fb=m.createContext(null);function zO(){return m.useContext(Fb)}function FO(){return c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[c.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"2"}),c.jsx("path",{d:"M5 15V5a2 2 0 0 1 2-2h10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function BO(){return c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:c.jsx("path",{d:"M5 12l5 5L19 6",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Bb(){return c.jsx(Jh.Root,{className:"msg-actions",children:c.jsxs(Jh.Copy,{className:"act-btn","aria-label":"Copy message",children:[c.jsxs("span",{className:"act-copy-idle",children:[c.jsx(FO,{})," copy"]}),c.jsxs("span",{className:"act-copy-done",children:[c.jsx(BO,{})," copied"]})]})})}const $O=new Set(["AskUserQuestion","ExitPlanMode"]);function UO(e){const t=[],n=[];function r(){if(n.length===0)return;if(n.filter(i=>e[i].type==="reasoning"||e[i].type==="tool-call").length>=2)t.push({groupKey:"group-thought",indices:[...n]});else for(const i of n)t.push({groupKey:void 0,indices:[i]});n.length=0}for(let s=0;s<e.length;s+=1){const i=e[s];i.type==="text"||i.type==="tool-call"&&i.toolName!==void 0&&$O.has(i.toolName)?(r(),t.push({groupKey:void 0,indices:[s]})):n.push(s)}return r(),t}function VO({text:e}){return!e||!e.trim()?null:c.jsx("div",{className:"cot-reasoning thinking-text",children:e})}const $b={Text:MO,Reasoning:VO,tools:{Fallback:OO}};function HO({indices:e,children:t}){const n=oa(v=>v.id),r=zO(),s=!!r&&n===r,[i,o]=m.useState(!1),a=s||i,l=oa(v=>v.content);let u=0,f=0,d="";for(const v of e){const S=l[v];S&&(S.type==="reasoning"?(u+=1,S.text?.trim()&&(d=S.text)):S.type==="tool-call"&&(f+=1))}const h=u+f,p=u>0?"chain of thought":`${f} tool call${f===1?"":"s"}`,g=DO(d);return c.jsxs("details",{className:"block-cot","data-thinking":s?"true":void 0,open:a,onToggle:v=>o(v.currentTarget.open),children:[c.jsxs("summary",{children:[c.jsx("span",{className:"cot-label",children:s?"thinking":p}),u>0?c.jsxs("span",{className:"cot-steps",children:["· ",h," step",h===1?"":"s"]}):null,g?c.jsx("span",{className:"cot-last",children:s?c.jsx(Tw,{text:g}):g}):null]}),a?c.jsx("div",{className:"cot-body",children:t}):null]})}function WO(){return c.jsx(la.Unstable_PartsGrouped,{groupingFunction:UO,components:{...$b,Group:({groupKey:e,indices:t,children:n})=>e?c.jsx(HO,{indices:t,children:n}):c.jsx(c.Fragment,{children:n})}})}function Qa(){return c.jsxs(la.Root,{className:"msg-row","data-role":"user",children:[c.jsx("div",{className:"msg-body",children:c.jsx(la.Parts,{components:$b})}),c.jsx(Bb,{})]})}function Wn(){const e=oa(n=>n.metadata?.custom?.cockpitRole)??"assistant",t=oa(n=>n.metadata?.custom?.working);return c.jsxs(la.Root,{className:"msg-row","data-role":e,children:[c.jsx("div",{className:"msg-body",children:c.jsx(WO,{})}),!t&&c.jsx(Bb,{})]})}function Rn({children:e}){return c.jsx("kbd",{className:"kbd",children:e})}const vm=3;function qO(e){if(e.backend==="mlx"){const t=(e.model||"").replace(/^mlx-community\//,"").replace(/-Instruct-4bit$/i,"").replace(/-4bit$/i,"");return t?`MLX · ${t}`:"MLX"}return e.backend==="claude"?"claude -p":e.backend==="rules"?"rules":e.mode==="llm"?"llm":"rules"}function KO(e,t){const n=e.split(`
|
|
83
83
|
`),r=t.split(`
|
|
84
|
-
`),s=new Set(n),i=new Set(r),o=[];let a=0,l=0;for(;a<n.length||l<r.length;){const u=n[a],f=r[l];a>=n.length?(o.push({kind:"add",text:f}),l++):l>=r.length?(o.push({kind:"del",text:u}),a++):u===f?(o.push({kind:"same",text:u}),a++,l++):!i.has(u)&&s.has(f)?(o.push({kind:"del",text:u}),o.push({kind:"add",text:f}),a++,l++):i.has(u)?s.has(f)?(o.push({kind:"same",text:u}),a++,l++):(o.push({kind:"add",text:f}),l++):(o.push({kind:"del",text:u}),a++)}return o}function KO({original:e,result:t,onSend:n,onAccept:r,onClose:s}){const[i,o]=m.useState(t.optimized),a=m.useRef(null),[l,u]=m.useState(HO),[f,d]=m.useState(!0),h=m.useRef(i);h.current=i;const p=m.useRef(n);p.current=n;const g=()=>d(!1);m.useEffect(()=>{a.current?.focus({preventScroll:!0})},[]),m.useEffect(()=>{if(!f)return;if(l<=0){p.current(h.current);return}const y=setTimeout(()=>u(v=>v-1),1e3);return()=>clearTimeout(y)},[f,l]),m.useEffect(()=>{const y=v=>{v.key==="Escape"&&(v.preventDefault(),s())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]);const x=qO(e,t.optimized),k=x.some(y=>y.kind!=="same");return c.jsx("div",{className:"modal-backdrop",onClick:y=>{y.target===y.currentTarget&&s()},children:c.jsxs("div",{className:"modal modal-optimize",role:"dialog","aria-modal":!0,"aria-label":"Review enhanced prompt",children:[c.jsxs("div",{className:"modal-head",children:[c.jsxs("div",{className:"modal-head-group",children:[c.jsx("span",{className:"modal-title modal-title-optimize",children:"Enhanced prompt"}),c.jsx("span",{className:"optimize-mode-badge","data-mode":t.mode,children:WO(t)})]}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Close",onClick:s,children:"✕"})]}),c.jsxs("div",{className:"modal-body",onScroll:g,onWheel:g,onTouchMove:g,children:[c.jsxs("div",{className:"optimize-section",children:[c.jsx("span",{className:"optimize-section-label",children:"Suggestion"}),c.jsx("textarea",{ref:a,className:"optimize-suggestion",value:i,onChange:y=>{o(y.target.value),g()},rows:6,spellCheck:!1,autoComplete:"off"})]}),k?c.jsxs("div",{className:"optimize-section",children:[c.jsx("span",{className:"optimize-section-label",children:"Changes vs original"}),c.jsx("div",{className:"optimize-diff",children:x.map((y,v)=>c.jsxs("div",{className:y.kind==="add"?"diff-add":y.kind==="del"?"diff-del":"diff-same",children:[y.kind==="add"?"+ ":y.kind==="del"?"- ":" ",y.text||" "]},v))})]}):null,t.rationale.length>0?c.jsxs("div",{className:"optimize-section",children:[c.jsx("span",{className:"optimize-section-label",children:"Rationale"}),c.jsx("ul",{className:"optimize-list",children:t.rationale.map((y,v)=>c.jsx("li",{children:y},v))})]}):null,t.changes.length>0?c.jsxs("div",{className:"optimize-section",children:[c.jsx("span",{className:"optimize-section-label",children:"What changed"}),c.jsx("ul",{className:"optimize-list",children:t.changes.map((y,v)=>c.jsx("li",{children:y},v))})]}):null]}),c.jsxs("div",{className:"modal-foot",children:[c.jsx("button",{type:"button",className:"btn-secondary",onClick:s,children:"Discard"}),c.jsx("span",{className:"modal-foot-spacer"}),c.jsx("button",{type:"button",className:"btn-secondary",onClick:()=>r(i),onMouseEnter:g,children:"To Composer"}),c.jsx("button",{type:"button",className:"btn-primary",onClick:()=>n(i),children:f?`Send ${l}`:"Send"})]})]})})}const vm="(max-width:760px)";function $b(){const[e,t]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(vm).matches);return m.useEffect(()=>{if(typeof window>"u")return;const n=window.matchMedia(vm),r=s=>t(s.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function GO({onPick:e,onClose:t}){const n=$b(),[r,s]=m.useState([]),[i,o]=m.useState(!0),[a,l]=m.useState(""),u=m.useRef(null);m.useEffect(()=>{let p=!0;return o(!0),xw().then(g=>{p&&(s(g),o(!1))}).catch(()=>{p&&o(!1)}),()=>{p=!1}},[]),m.useEffect(()=>{requestAnimationFrame(()=>u.current?.focus())},[]),m.useEffect(()=>{const p=g=>{g.key==="Escape"&&(g.preventDefault(),t())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]);const f=a.trim().toLowerCase(),d=f?r.filter(p=>p.name.toLowerCase().includes(f)||p.description.toLowerCase().includes(f)):r,h=c.jsxs("div",{className:"skill-browser","data-mode":n?"sheet":"modal",role:"dialog","aria-modal":"true","aria-label":"Skill browser",children:[c.jsxs("div",{className:"skill-browser-head",children:[c.jsx("span",{className:"skill-browser-title",children:"Skills"}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Close skill browser",onClick:t,children:"✕"})]}),c.jsx("div",{className:"skill-browser-search",children:c.jsx("input",{ref:u,type:"search",className:"skill-search-input",placeholder:"Search skills…",value:a,onChange:p=>l(p.currentTarget.value),"aria-label":"Search skills",autoComplete:"off",spellCheck:!1})}),c.jsx("div",{className:"skill-browser-list",role:"list",children:i?c.jsx("div",{className:"skill-browser-empty",children:"Loading…"}):d.length===0?c.jsx("div",{className:"skill-browser-empty",children:f?"No skills match your search.":"No skills found."}):d.map(p=>c.jsxs("button",{type:"button",className:"skill-card",role:"listitem",onClick:()=>e(p.name),title:`Prefill /${p.name}`,children:[c.jsxs("span",{className:"tool-head",children:[c.jsx("span",{className:"tool-arrow","aria-hidden":"true",children:"▸"}),c.jsx("span",{className:"tool-name skill-card-name",children:p.name}),p.description?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"tool-sep",children:"—"}),c.jsx("span",{className:"tool-input skill-card-desc",children:p.description})]}):null]}),p.source==="plugin"?c.jsx("span",{className:"skill-source-tag",children:"plugin"}):null]},p.name))})]});return n?c.jsx("div",{className:"skill-browser-sheet-wrap",children:h}):c.jsx("div",{className:"modal-backdrop",onClick:p=>{p.target===p.currentTarget&&t()},children:h})}function QO(){if(typeof window>"u")return null;const e=window;return e.AudioContext??e.webkitAudioContext??null}function YO(){const e=typeof window<"u"?window.MediaRecorder:void 0,t=[{mime:"audio/webm;codecs=opus",ext:"webm"},{mime:"audio/webm",ext:"webm"},{mime:"audio/mp4",ext:"mp4"},{mime:"audio/aac",ext:"aac"},{mime:"audio/ogg;codecs=opus",ext:"ogg"}];if(e&&typeof e.isTypeSupported=="function"){for(const n of t)if(e.isTypeSupported(n.mime))return n}return{mime:"",ext:"webm"}}function JO({onCommit:e,onClose:t}){const[n,r]=m.useState("starting"),[s,i]=m.useState(null),o=typeof window<"u"&&"MediaRecorder"in window,a=m.useRef(null),l=m.useRef(null),u=m.useRef(null),f=m.useRef(null),d=m.useRef([]),h=m.useRef({mime:"",ext:"webm"}),p=m.useRef(null),g=m.useRef(null),x=m.useRef(!1),k=m.useRef(!1),y=m.useCallback(()=>{x.current=!1,g.current!=null&&cancelAnimationFrame(g.current),g.current=null},[]),v=m.useCallback(()=>{const D=p.current,_=u.current;if(!D||!_)return;const z=D.getContext("2d");if(!z)return;const j=new Uint8Array(_.fftSize),K=getComputedStyle(D).getPropertyValue("--accent").trim()||"#7aa2f7";x.current=!0;const P=()=>{if(!x.current)return;D.width!==D.clientWidth&&(D.width=D.clientWidth),_.getByteTimeDomainData(j);const B=D.width,ee=D.height;z.clearRect(0,0,B,ee),z.lineWidth=2,z.strokeStyle=K,z.beginPath();const ae=B/j.length;for(let F=0;F<j.length;F+=1){const b=j[F]/128*ee/2,J=F*ae;F===0?z.moveTo(J,b):z.lineTo(J,b)}z.stroke(),g.current=requestAnimationFrame(P)};g.current=requestAnimationFrame(P)},[]),w=m.useCallback(()=>{y(),a.current?.getTracks().forEach(D=>D.stop()),a.current=null,l.current?.close().catch(()=>{}),l.current=null,u.current=null},[y]);m.useEffect(()=>{let D=!1;return(async()=>{try{if(!navigator.mediaDevices?.getUserMedia)throw new Error("no-getusermedia");const _=await navigator.mediaDevices.getUserMedia({audio:!0});if(D){_.getTracks().forEach(P=>P.stop());return}a.current=_;const z=QO();if(z){const P=new z;l.current=P,P.state==="suspended"&&await P.resume();const B=P.createMediaStreamSource(_),ee=P.createAnalyser();ee.fftSize=512,B.connect(ee),u.current=ee}if(!("MediaRecorder"in window))throw new Error("no-mediarecorder");const j=YO();h.current=j;const K=j.mime?new MediaRecorder(_,{mimeType:j.mime}):new MediaRecorder(_);K.ondataavailable=P=>{P.data&&P.data.size>0&&d.current.push(P.data)},f.current=K,K.start(),r("recording"),v()}catch(_){const z=_ instanceof Error?_.message:"";i(z==="no-mediarecorder"?"Audio recording isn’t supported in this browser.":"Microphone permission denied or unavailable."),r("error")}})(),()=>{D=!0,y();try{f.current?.stop()}catch{}f.current=null,a.current?.getTracks().forEach(_=>_.stop()),a.current=null,l.current?.close().catch(()=>{}),l.current=null,u.current=null}},[]);const E=m.useCallback(()=>{try{f.current?.pause()}catch{}y(),r("paused")},[y]),I=m.useCallback(()=>{try{f.current?.resume()}catch{}r("recording"),v()},[v]),S=m.useCallback(()=>{if(k.current)return;k.current=!0;const D=f.current;if(!D){w(),e("");return}r("transcribing"),D.onstop=async()=>{const{mime:_,ext:z}=h.current,j=new Blob(d.current,{type:_||"audio/webm"});if(w(),j.size===0){e("");return}try{const K=await iR(j,z);e(K)}catch(K){i(K instanceof Error?K.message:"Transcription failed."),r("error")}};try{D.stop()}catch{w(),e("")}},[w,e]),R=m.useCallback(()=>{k.current=!0;try{f.current?.stop()}catch{}f.current=null,w(),t()},[w,t]);m.useEffect(()=>{const D=_=>{_.key==="Escape"&&n!=="transcribing"&&(_.preventDefault(),R())};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[R,n]);const N=n==="error"?"Microphone unavailable":n==="transcribing"?"Transcribing…":n==="paused"?"Paused":n==="starting"?"Starting…":"Listening…";return c.jsx("div",{className:"modal-backdrop",onClick:D=>{D.target===D.currentTarget&&n!=="transcribing"&&R()},children:c.jsxs("div",{className:"modal voice-dialog",role:"dialog","aria-modal":"true","aria-label":"Voice input",children:[c.jsxs("div",{className:"voice-status",children:[c.jsx("span",{className:"voice-dot","data-on":n==="recording"?"true":void 0}),N]}),c.jsx("canvas",{ref:p,className:"voice-wave",height:72,"data-paused":n!=="recording"?"true":void 0}),c.jsx("div",{className:"voice-transcript",children:n==="transcribing"?c.jsx("span",{className:"voice-placeholder",children:"Converting speech to text…"}):c.jsx("span",{className:"voice-placeholder",children:"Speak, then tap “Stop & insert” to transcribe."})}),n==="error"?c.jsx("div",{className:"voice-error",children:s||"Could not start recording."}):o?null:c.jsx("div",{className:"voice-note",children:"Audio recording isn’t supported in this browser."}),c.jsxs("div",{className:"voice-actions",children:[c.jsx("button",{type:"button",className:"btn-secondary",onClick:R,disabled:n==="transcribing",children:"Cancel"}),c.jsx("span",{className:"voice-actions-spacer"}),n==="recording"?c.jsx("button",{type:"button",className:"btn-secondary",onClick:E,children:"Pause"}):n==="paused"?c.jsx("button",{type:"button",className:"btn-secondary",onClick:I,children:"Resume"}):null,c.jsx("button",{type:"button",className:"btn-primary",onClick:S,disabled:n==="error"||n==="transcribing"||n==="starting",children:n==="transcribing"?"Transcribing…":"Stop & Insert"})]})]})})}const mc=["#414868","#f7768e","#9ece6a","#e0af68","#7aa2f7","#bb9af7","#7dcfff","#a9b1d6"],gc=["#565f89","#ff7a93","#b9f27c","#ff9e64","#9bb5ff","#c7a9ff","#a4daff","#c0caf5"];function XO(e){if(e<8)return mc[e];if(e<16)return gc[e-8];if(e>=232){const o=8+(e-232)*10;return`rgb(${o},${o},${o})`}const t=e-16,n=Math.floor(t/36),r=Math.floor(t%36/6),s=t%6,i=o=>o===0?0:o*40+55;return`rgb(${i(n)},${i(r)},${i(s)})`}function ZO(e,t){for(let n=0;n<t.length;n+=1){const r=t[n];if(r===0)e.fg=void 0,e.bg=void 0,e.bold=!1,e.dim=!1,e.italic=!1,e.underline=!1;else if(r===1)e.bold=!0;else if(r===2)e.dim=!0;else if(r===3)e.italic=!0;else if(r===4)e.underline=!0;else if(r===22)e.bold=!1,e.dim=!1;else if(r===23)e.italic=!1;else if(r===24)e.underline=!1;else if(r>=30&&r<=37)e.fg=mc[r-30];else if(r===39)e.fg=void 0;else if(r>=90&&r<=97)e.fg=gc[r-90];else if(r>=40&&r<=47)e.bg=mc[r-40];else if(r===49)e.bg=void 0;else if(r>=100&&r<=107)e.bg=gc[r-100];else if(r===38||r===48){const s=r===38?"fg":"bg";t[n+1]===5?(e[s]=XO(t[n+2]??0),n+=2):t[n+1]===2&&(e[s]=`rgb(${t[n+2]??0},${t[n+3]??0},${t[n+4]??0})`,n+=4)}}}const Ql=/\x1b\[([0-9;]*)m/g,e2=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g,t2=/\x1b\[[0-9;?]*[ -/]*[@-~]|\x1b[@-Z\\-_]/g,n2=/\x1b\[[0-9;?]*[ -/]*[@-~]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[@-Z\\-_]/g;function r2(e){const t=String(e).split(`
|
|
85
|
-
`);for(;t.length&&t[t.length-1].replace(
|
|
86
|
-
`)}function
|
|
87
|
-
`);if($e!==-1){for(let qe=0;qe<Q;qe+=1)Y.current.key("BSpace");X.slice(0,$e)&&Y.current.text(X.slice(0,$e)),Y.current.key("Enter"),C.current="",n.setText("");return}for(let qe=0;qe<Q;qe+=1)Y.current.key("BSpace");X&&Y.current.text(X),C.current=O};return n.subscribe(L)},[l,n]),c.jsxs(so.Root,{className:"composer",children:[z?c.jsx("div",{className:"skill-ac",role:"listbox","aria-label":"Skill suggestions",children:_.map((L,O)=>c.jsx("button",{type:"button",role:"option","aria-selected":O===I,"data-on":O===I?"true":void 0,className:"skill-ac-item",onMouseDown:W=>{W.preventDefault(),K(L.name)},onMouseEnter:()=>S(O),children:c.jsxs("span",{className:"tool-head",children:[c.jsx("span",{className:"tool-arrow","aria-hidden":"true",children:"▸"}),c.jsx("span",{className:"tool-name skill-card-name",children:L.name}),L.description?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"tool-sep",children:"—"}),c.jsx("span",{className:"tool-input skill-card-desc",children:L.description})]}):null]})},L.name))}):null,l?c.jsx(Ub,{output:r.output,requestCapture:r.poll,clearOutput:r.clear,sendKey:r.key,mods:M,onToggleMod:ge}):null,c.jsxs("div",{className:"composer-card","data-terminal":l?"true":void 0,children:[j?c.jsx("div",{className:"composer-skill-chip-row",children:c.jsxs("span",{className:"skill-chip composer-skill-chip",title:`Invoking /${j}`,children:[c.jsx("span",{className:"skill-chip-icon","aria-hidden":"true",children:"⌁"}),c.jsxs("span",{className:"skill-chip-name",children:["/",j]})]})}):null,c.jsxs("div",{className:"composer-input-wrap",children:[c.jsx(so.Input,{className:"composer-input",placeholder:e&&!l?"Select a session…":" ",submitOnEnter:!1,onKeyDown:L=>{if(l){if(L.metaKey)return;const O=M,W=L.ctrlKey||O.ctrl,Q=L.altKey||O.alt;if((W||Q)&&L.key.length===1&&_i(L.key)){L.preventDefault();const pe=ya({ctrl:W,alt:Q},L.key);pe&&r.key(pe),(O.ctrl||O.alt)&&b({ctrl:!1,alt:!1});return}const X=Wb(L.key,L.shiftKey);X&&(L.preventDefault(),r.key(X),X==="Enter"&&(C.current="",n.setText("")));return}if(z){if(L.key==="ArrowDown"){L.preventDefault(),S(O=>(O+1)%_.length);return}if(L.key==="ArrowUp"){L.preventDefault(),S(O=>(O-1+_.length)%_.length);return}if(L.key==="Enter"&&!L.metaKey&&!L.ctrlKey){L.preventDefault(),K(_[I].name);return}if(L.key==="Tab"){L.preventDefault(),K(_[I].name);return}if(L.key==="Escape"){L.preventDefault(),N(!0);return}}if(L.key==="Enter"&&(L.metaKey||L.ctrlKey)){if(L.preventDefault(),e||p)return;L.shiftKey?(n.send(),k()):F()}L.key.toLowerCase()==="o"&&(L.metaKey||L.ctrlKey)&&(L.preventDefault(),F())},rows:1,disabled:e&&!l,autoComplete:"off"}),l?c.jsxs("div",{className:"composer-hint","aria-hidden":"true",children:[c.jsx("span",{className:"composer-hint-lead",children:"Keys go to the shell…"}),c.jsxs("span",{className:"composer-hint-keys",children:[c.jsx(tr,{children:"Tab"})," completes",c.jsx("span",{className:"composer-hint-dot",children:"·"}),c.jsx(tr,{children:"↑"})," history"]})]}):e?null:c.jsxs("div",{className:"composer-hint","aria-hidden":"true",children:[c.jsx("span",{className:"composer-hint-lead",children:"Reply…"}),c.jsxs("span",{className:"composer-hint-keys",children:[c.jsx(tr,{children:"⌘/Ctrl+↵"})," optimise",c.jsx("span",{className:"composer-hint-dot",children:"·"}),c.jsx(tr,{children:"⌘/Ctrl+⇧+↵"})," send raw",c.jsx("span",{className:"composer-hint-dot",children:"·"}),c.jsx(tr,{children:"↵"})," newline"]})]})]}),c.jsx("div",{className:"composer-attachments",children:c.jsx(so.Attachments,{children:({attachment:L})=>c.jsx(y2,{attachment:L})})}),c.jsxs("div",{className:"composer-toolbar",children:[l?null:c.jsxs(c.Fragment,{children:[c.jsx(so.AddAttachment,{className:"composer-attach","aria-label":"Attach a file",title:"Attach a file",multiple:!0,disabled:e,children:c.jsx(v2,{})}),c.jsx("button",{type:"button",className:"composer-skills-btn","aria-label":"Browse skills",title:"Browse skills",disabled:e,onClick:()=>a(L=>!L),children:c.jsx(w2,{})}),c.jsx("button",{type:"button",className:"composer-mic","aria-label":"Voice input",title:"Voice input",disabled:e,onClick:()=>B(!0),children:c.jsx(b2,{})})]}),c.jsx("button",{type:"button",className:"composer-skills-btn composer-term-toggle","aria-label":"Terminal mode",title:"Terminal mode — run shell commands","aria-pressed":l,"data-on":l?"true":void 0,onClick:()=>u(L=>!L),children:c.jsx(x2,{})}),c.jsx("span",{className:"composer-toolbar-spacer"}),l?null:c.jsx("button",{type:"button",className:"composer-enhance composer-bypass","aria-label":"Send without optimising",title:"Send raw — skip the optimiser (⌘/Ctrl+⇧+↵)",disabled:e||p||s,onClick:()=>{n.send(),k()},children:c.jsx(Sm,{})}),l?c.jsx("button",{type:"button",className:"composer-send","data-terminal":"true","aria-label":"Send Enter",title:"Enter",onMouseDown:L=>L.preventDefault(),onClick:()=>r.key("Enter"),children:c.jsx(Sm,{})}):c.jsx("button",{type:"button",className:"composer-send","aria-label":"Optimise and send",title:"Optimise & send (⌘/Ctrl+↵)",disabled:e||p||s,onClick:()=>void F(),children:p?c.jsx("span",{className:"composer-enhance-spinner","aria-hidden":"true"}):c.jsx(S2,{})})]})]}),g?c.jsx(KO,{original:g.original,result:g,onSend:L=>{x(h,{review:null}),n.setText(L),requestAnimationFrame(()=>{e||n.send(),k()})},onAccept:L=>{n.setText(L),x(h,{review:null}),k()},onClose:()=>{x(h,{review:null}),k()}}):null,o?c.jsx(GO,{onPick:ae,onClose:()=>a(!1)}):null,P?c.jsx(JO,{onCommit:ee,onClose:()=>B(!1)}):null]})}function v2(){return c.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:c.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}function Sm(){return c.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:c.jsx("path",{d:"M12 19V5M6 11l6-6 6 6",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function x2(){return c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:c.jsx("path",{d:"M5 8l4 4-4 4M12 16h7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function w2(){return c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:c.jsx("path",{d:"M7 20L17 4",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round"})})}function b2(){return c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[c.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:"currentColor"}),c.jsx("path",{d:"M6 11a6 6 0 0 0 12 0M12 17v3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function S2(){return c.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[c.jsx("path",{d:"M12 2 L13.5 9.5 L21 11 L13.5 12.5 L12 20 L10.5 12.5 L3 11 L10.5 9.5 Z",fill:"currentColor",opacity:"0.9"}),c.jsx("path",{d:"M19 2 L19.8 4.2 L22 5 L19.8 5.8 L19 8 L18.2 5.8 L16 5 L18.2 4.2 Z",fill:"currentColor",opacity:"0.6"})]})}const k2={UserMessage:Qa,AssistantMessage:Hn,SystemMessage:Hn};function C2({hasSelection:e,sessionId:t,hiddenCount:n,onLoadEarlier:r}){return c.jsxs(dt.Root,{className:"thread-root",children:[c.jsx("div",{className:"thread-fade","aria-hidden":"true"}),c.jsxs(dt.Viewport,{className:"thread-viewport",autoScroll:!0,children:[e?c.jsx(dt.Empty,{children:c.jsx("div",{className:"thread-empty",children:"no messages yet"})}):c.jsx("div",{className:"thread-empty",children:"select a session"}),e&&n>0?c.jsxs("button",{type:"button",className:"load-earlier",onClick:r,children:["Load earlier messages (",n," hidden)"]}):null,c.jsx(dt.Messages,{components:k2})]}),c.jsx(qb,{disabled:!e,sessionId:t})]})}const _2=256*1024,js=40,km=90,E2=25,T2=15,I2=95;function R2(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Cm({language:e,content:t,artifactId:n}){const[r,s]=m.useState(null),i=t.length>_2,o=nf(e),a=!i&&o!==null;return m.useEffect(()=>{if(!a){s(null);return}let l=!0;return s(null),Lb(e,t).then(u=>{l&&s(u)}).catch(()=>{l&&s(null)}),()=>{l=!1}},[n,t,a,e]),i?c.jsxs("div",{className:"artifact-body-wrap",children:[c.jsx("p",{className:"artifact-large-note",children:"(large file — shown as plain text)"}),c.jsx("pre",{className:"artifact-pre",children:c.jsx("code",{children:t})})]}):a&&r!==null?c.jsx("div",{className:"artifact-body-wrap",children:c.jsx("pre",{className:"artifact-pre",children:c.jsx("code",{className:"hljs",dangerouslySetInnerHTML:{__html:r}})})}):c.jsx("div",{className:"artifact-body-wrap",children:c.jsx("pre",{className:"artifact-pre",children:c.jsx("code",{className:a?"hljs":void 0,dangerouslySetInnerHTML:{__html:R2(t)}})})})}function P2(){const{artifacts:e,activeId:t,setActive:n,close:r}=rf(),s=$b(),i=m.useRef(null),o=m.useRef(null),a=m.useId(),[l,u]=m.useState(js),f=m.useRef(null),[d,h]=m.useState(!1),p=e.find(I=>I.id===t)??null,g=p!==null;m.useEffect(()=>{g&&u(js)},[g]);const x=m.useRef(!1);m.useEffect(()=>{const I=x.current;if(x.current=g,!I&&g&&requestAnimationFrame(()=>{const S=o.current?.querySelector('[role="tab"][aria-selected="true"]');S?S.focus():i.current?.focus()}),I&&!g){const S=document.querySelector(".thread-root");S&&(S.hasAttribute("tabindex")||S.setAttribute("tabindex","-1"),S.focus())}},[g]);const k=m.useCallback(I=>{I.key==="Escape"&&t&&(I.preventDefault(),r(t))},[t,r]),y=m.useCallback(I=>{if(I.key!=="ArrowLeft"&&I.key!=="ArrowRight")return;const S=Array.from(o.current?.querySelectorAll('[role="tab"]')??[]),R=document.activeElement,N=S.indexOf(R);if(N<0)return;const D=I.key==="ArrowRight"?S[(N+1)%S.length]:S[(N-1+S.length)%S.length];D?.focus();const _=D?.dataset.artifactId;_&&n(_)},[n]),v=m.useCallback(I=>{f.current={startY:I.clientY,startH:l},I.currentTarget.setPointerCapture(I.pointerId),h(!0)},[l]),w=m.useCallback(I=>{if(!f.current)return;const{startY:S,startH:R}=f.current,N=(S-I.clientY)/window.innerHeight*100,D=Math.min(I2,Math.max(T2,R+N));u(D)},[]),E=m.useCallback(I=>{f.current&&(I.currentTarget.releasePointerCapture(I.pointerId),f.current=null,h(!1),u(S=>{if(S<E2)return t&&r(t),js;const R=Math.abs(S-js),N=Math.abs(S-km);return R<=N?js:km}))},[t,r]);return g?s?c.jsxs("div",{className:"artifact-panel","data-mode":"sheet",style:{height:`${l}dvh`},"data-dragging":d?"true":"false",role:"region","aria-label":"Artifact panel",ref:i,tabIndex:-1,onKeyDown:k,children:[c.jsx("div",{className:"artifact-drag-handle",role:"separator","aria-label":"Resize panel",onPointerDown:v,onPointerMove:w,onPointerUp:E,children:c.jsx("div",{className:"artifact-drag-pip","aria-hidden":"true"})}),c.jsxs("div",{className:"artifact-panel-head",children:[c.jsx("div",{role:"tablist","aria-label":"Open artifacts",ref:o,className:"artifact-tablist",onKeyDown:y,children:e.map(I=>{const S=I.id===t,R=`artifact-tab-${I.id}`;return c.jsxs("div",{role:"presentation",className:"artifact-tab-wrap",children:[c.jsx("button",{role:"tab",id:R,className:"artifact-tab","aria-selected":S,tabIndex:S?0:-1,"data-artifact-id":I.id,onClick:()=>n(I.id),children:I.title}),c.jsx("button",{className:"artifact-tab-close","aria-label":`Close ${I.title}`,tabIndex:-1,onClick:N=>{N.stopPropagation(),r(I.id)},children:"✕"})]},I.id)})}),c.jsx("button",{className:"artifact-close-all","aria-label":"Close artifact panel",onClick:()=>t&&r(t),children:"×"})]}),p&&c.jsx("div",{role:"tabpanel",id:`${a}-body`,"aria-labelledby":`artifact-tab-${p.id}`,className:"artifact-panel-body",children:c.jsx(Cm,{language:p.language,content:p.content,artifactId:p.id})})]}):c.jsxs("div",{className:"artifact-panel",role:"region","aria-label":"Artifact panel",ref:i,tabIndex:-1,onKeyDown:k,children:[c.jsxs("div",{className:"artifact-panel-head",children:[c.jsx("div",{role:"tablist","aria-label":"Open artifacts",ref:o,className:"artifact-tablist",onKeyDown:y,children:e.map(I=>{const S=I.id===t,R=`artifact-tab-${I.id}`;return c.jsxs("div",{role:"presentation",className:"artifact-tab-wrap",children:[c.jsx("button",{role:"tab",id:R,className:"artifact-tab","aria-selected":S,tabIndex:S?0:-1,"data-artifact-id":I.id,onClick:()=>n(I.id),children:I.title}),c.jsx("button",{className:"artifact-tab-close","aria-label":`Close ${I.title}`,tabIndex:-1,onClick:N=>{N.stopPropagation(),r(I.id)},children:"✕"})]},I.id)})}),c.jsx("button",{className:"artifact-close-all","aria-label":"Close artifact panel",onClick:()=>t&&r(t),children:"×"})]}),p&&c.jsx("div",{role:"tabpanel",id:`${a}-body`,"aria-labelledby":`artifact-tab-${p.id}`,className:"artifact-panel-body",children:c.jsx(Cm,{language:p.language,content:p.content,artifactId:p.id})})]}):null}const _m=200,A2=2e3;function j2({sessionId:e,capture:t,requestCapture:n,clearCapture:r}){const s=m.useRef(null),i=m.useRef(!0);m.useEffect(()=>{n(_m);const a=setInterval(()=>n(_m),A2);return()=>{clearInterval(a),r()}},[e,n,r]),m.useLayoutEffect(()=>{const a=s.current;a&&i.current&&(a.scrollTop=a.scrollHeight)},[t]);const o=()=>{const a=s.current;a&&(i.current=a.scrollHeight-a.scrollTop-a.clientHeight<24)};return c.jsxs("div",{className:"live-pane",children:[c.jsx("div",{className:"live-pane-head",children:"live pane (no transcript)"}),c.jsx("pre",{className:"live-pane-body",ref:s,onScroll:o,children:t??"capturing live pane…"})]})}function N2(e){const[t,n]=m.useState(""),[r,s]=m.useState({ctrl:!1,alt:!1}),i=m.useRef(""),o=m.useRef(r);o.current=r;const a=m.useRef(e);a.current=e;const l=m.useCallback(h=>{s(p=>({...p,[h]:!p[h]}))},[]),u=m.useCallback(h=>{const p=i.current;if(h===p)return;const{removed:g,added:x}=Hb(p,h),k=o.current,y=a.current;if((k.ctrl||k.alt)&&g===0&&x.length===1&&_i(x)){const w=ya(k,x);w&&y.sendKey(w),s({ctrl:!1,alt:!1}),n(p);return}const v=x.indexOf(`
|
|
88
|
-
`);if(v!==-1){for(let w=0;w<g;w+=1)y.sendKey("BSpace");x.slice(0,v)&&y.sendText(x.slice(0,v)),y.sendKey("Enter"),i.current="",n("");return}for(let w=0;w<g;w+=1)y.sendKey("BSpace");x&&y.sendText(x),i.current=h,n(h)},[]),f=m.useCallback(h=>u(h.target.value),[u]),d=m.useCallback(h=>{if(h.metaKey)return;const p=o.current,g=a.current,x=h.ctrlKey||p.ctrl,k=h.altKey||p.alt;if((x||k)&&h.key.length===1&&_i(h.key)){h.preventDefault();const v=ya({ctrl:x,alt:k},h.key);v&&g.sendKey(v),(p.ctrl||p.alt)&&s({ctrl:!1,alt:!1});return}const y=Wb(h.key,h.shiftKey);y&&(h.preventDefault(),g.sendKey(y),y==="Enter"&&(i.current="",n("")))},[]);return m.useMemo(()=>({value:t,onChange:f,onKeyDown:d,sticky:r,toggleMod:l}),[t,f,d,r,l])}function M2({sessionId:e,capture:t,requestCapture:n,clearCapture:r,sendText:s,sendKey:i}){const o=m.useMemo(()=>u=>n(u,!0),[n]),a=m.useMemo(()=>({sendText:u=>void s(u),sendKey:u=>void i(u)}),[s,i]),l=N2(a);return c.jsxs("div",{className:"thread-root terminal-pane-root",children:[c.jsx("div",{className:"thread-fade","aria-hidden":"true"}),c.jsx(Ub,{output:t,requestCapture:o,clearOutput:r,sendKey:i,mods:l.sticky,onToggleMod:l.toggleMod},e),c.jsx("div",{className:"terminal-pane-input",children:c.jsx("textarea",{className:"composer-input","aria-label":"Terminal input",placeholder:"Keys go to the pane…",rows:1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,value:l.value,onChange:l.onChange,onKeyDown:l.onKeyDown})})]})}function Em(e){return e.questions.map(()=>new Set)}function D2({pending:e,capture:t,onAnswer:n,onCapture:r,onClose:s}){const[i,o]=m.useState(()=>Em(e)),a=m.useRef(null),l=m.useRef(null);m.useEffect(()=>{o(Em(e))},[e]),m.useEffect(()=>(l.current=document.activeElement,(a.current?.querySelector("button:not([disabled]), [tabindex]")??a.current)?.focus(),()=>{l.current?.focus?.()}),[]);const u=m.useMemo(()=>i.length>0&&i.every(p=>p.size>0),[i]),f=(p,g,x)=>{o(k=>{const y=k.map(w=>new Set(w)),v=y[p];return x?v.has(g)?v.delete(g):v.add(g):y[p]=new Set([g]),y})},d=p=>{if(p.key==="Escape"){p.preventDefault(),s();return}if(p.key!=="Tab")return;const g=a.current?.querySelectorAll('button:not([disabled]), [tabindex="0"]');if(!g||g.length===0)return;const x=g[0],k=g[g.length-1];p.shiftKey&&document.activeElement===x?(p.preventDefault(),k.focus()):!p.shiftKey&&document.activeElement===k&&(p.preventDefault(),x.focus())},h=()=>{u&&n(e.toolUseId,i.map(p=>[...p]))};return c.jsx("div",{className:"modal-backdrop",onClick:p=>{p.target===p.currentTarget&&s()},children:c.jsxs("div",{ref:a,className:"modal",role:"dialog","aria-modal":"true","aria-label":"Question from Claude",tabIndex:-1,onKeyDown:d,children:[c.jsxs("div",{className:"modal-head",children:[c.jsx("span",{className:"modal-title",children:"Claude is asking"}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Close",onClick:s,children:"✕"})]}),c.jsxs("div",{className:"modal-body",children:[e.questions.map((p,g)=>c.jsxs("div",{className:"question",children:[p.header?c.jsx("div",{className:"q-header",children:p.header}):null,c.jsx("div",{className:"q-text",children:p.question}),p.multiSelect?c.jsx("div",{className:"q-hint",children:"select one or more"}):null,c.jsx("div",{className:"q-options",children:p.options.map(x=>{const k=i[g]?.has(x.label);return c.jsxs("button",{type:"button",className:"option-btn","data-on":k?"true":"false","aria-pressed":k,onClick:()=>f(g,x.label,!!p.multiSelect),children:[c.jsx("span",{className:"option-label",children:x.label}),x.description?c.jsx("span",{className:"option-desc",children:x.description}):null]},x.label)})})]},g)),t!=null?c.jsx("pre",{className:"capture-output",children:t}):null]}),c.jsxs("div",{className:"modal-foot",children:[c.jsx("button",{type:"button",className:"btn-secondary",onClick:r,children:"Show Terminal"}),c.jsx("span",{className:"modal-foot-spacer"}),c.jsx("button",{type:"button",className:"btn-secondary",onClick:s,children:"Cancel"}),c.jsx("button",{type:"button",className:"btn-primary",disabled:!u,onClick:h,children:"Send Answer"})]})]})})}function L2({toast:e}){const[t,n]=m.useState(!1);return m.useEffect(()=>{if(!e)return;n(!0);const r=setTimeout(()=>n(!1),2200);return()=>clearTimeout(r)},[e]),e?c.jsx("div",{className:`toast ${t?"show":""} ${e.kind?`toast-${e.kind}`:""}`,role:"status","aria-live":"polite",children:e.text}):null}const Tm="claude-control-update-dismissed";function O2(e){if(e.latest&&e.latest!==e.current)return`Update available — v${e.latest} (you’re on v${e.current}).`;const t=e.behind||1;return`Update available — ${t} new commit${t===1?"":"s"} (v${e.current}).`}function z2(){const[e,t]=m.useState(null),[n,r]=m.useState(!1);return m.useEffect(()=>{let s=!0;return vw().then(i=>{if(!s||!i?.updateAvailable)return;const o=i.latest??`behind-${i.behind??0}`;localStorage.getItem(Tm)!==o&&t({current:i.current,latest:i.latest,behind:i.behind??0})}),()=>{s=!1}},[]),e?n?c.jsx("div",{className:"update-banner",role:"status",children:c.jsx("span",{children:"Updating… the page will reconnect shortly."})}):c.jsxs("div",{className:"update-banner",role:"status",children:[c.jsx("span",{children:O2(e)}),c.jsxs("span",{className:"update-actions",children:[c.jsx("button",{type:"button",className:"update-now",onClick:()=>{r(!0),JI()},children:"Update now"}),c.jsx("button",{type:"button",className:"update-dismiss","aria-label":"Dismiss update notice",onClick:()=>{localStorage.setItem(Tm,e.latest??`behind-${e.behind}`),t(null)},children:"×"})]})]}):null}function F2({onClose:e,onToast:t}){const[n,r]=m.useState(""),[s,i]=m.useState(""),[o,a]=m.useState(""),[l,u]=m.useState(""),[f,d]=m.useState("mlx"),[h,p]=m.useState(""),[g,x]=m.useState(null),[k,y]=m.useState(!0),[v,w]=m.useState(!1),[E,I]=m.useState(null),[S,R]=m.useState(()=>Date.now()),[N,D]=m.useState(!1),_=m.useRef(null);m.useEffect(()=>{let P=!0;return vw().then(B=>P&&B&&I(B)).catch(()=>{}),rR().then(B=>P&&x(B)).catch(()=>{}),()=>{P=!1}},[]),m.useEffect(()=>{let P=!0;return oR().then(B=>{P&&(r(B.launchCommand),i(B.defaultCwd),a(B.optimizeModel??""),u(B.claudeBin??""),d(B.optimizeBackend??"mlx"),p(B.mlxModel??""))}).catch(B=>t(`Load config failed: ${B.message}`,"error")).finally(()=>{P&&y(!1)}),()=>{P=!1}},[t]),m.useEffect(()=>{const P=B=>{B.key==="Escape"&&e()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[e]);const z=async P=>{const B=P.target.files?.[0];if(P.target.value="",!!B){if(B.type!=="image/png"){t("Icon must be a PNG image","error");return}D(!0);try{await tR(B),R(Date.now()),t("App icon updated — re-add to Home Screen to see it","ok")}catch(ee){t(`Icon upload failed: ${ee.message}`,"error")}finally{D(!1)}}},j=async()=>{D(!0);try{await nR(),R(Date.now()),t("App icon reset to default","ok")}catch(P){t(`Icon reset failed: ${P.message}`,"error")}finally{D(!1)}},K=async()=>{w(!0);try{const P=await aR({launchCommand:n,defaultCwd:s,optimizeModel:o,claudeBin:l,optimizeBackend:f,mlxModel:h});r(P.launchCommand),i(P.defaultCwd),a(P.optimizeModel??""),u(P.claudeBin??""),d(P.optimizeBackend??"mlx"),p(P.mlxModel??"");const B=g?.mlxModels.find(ee=>ee.id===P.mlxModel);P.optimizeBackend==="mlx"&&B&&B.installed===!1?t(`Downloading ${B.label} (${B.sizeGB} GB)… enhancer uses claude until ready`,"ok"):t("Config saved","ok"),e()}catch(P){t(`Save failed: ${P.message}`,"error")}finally{w(!1)}};return c.jsx("div",{className:"config-overlay",role:"presentation",onClick:P=>{P.target===P.currentTarget&&e()},children:c.jsxs("div",{className:"config-modal",role:"dialog","aria-modal":"true","aria-label":"Settings",children:[c.jsxs("div",{className:"config-head",children:[c.jsx("span",{className:"config-title",children:"Settings"}),c.jsx("button",{type:"button",className:"config-close","aria-label":"Close settings",onClick:e,children:"×"})]}),c.jsxs("div",{className:"config-body",children:[c.jsxs("label",{className:"config-field",children:[c.jsx("span",{className:"config-label",children:"Launch command"}),c.jsx("input",{className:"config-input",type:"text",placeholder:"claude",value:n,disabled:k,onChange:P=>r(P.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),c.jsx("span",{className:"config-hint",children:"Run in each new session's pane."})]}),c.jsxs("label",{className:"config-field",children:[c.jsx("span",{className:"config-label",children:"Default cwd"}),c.jsx("input",{className:"config-input",type:"text",value:s,disabled:k,onChange:P=>i(P.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),c.jsx("span",{className:"config-hint",children:"Existing dir new sessions start in."})]}),c.jsxs("label",{className:"config-field",children:[c.jsx("span",{className:"config-label",children:"Enhancer backend"}),c.jsxs("select",{className:"config-input",value:f,disabled:k,onChange:P=>d(P.target.value),children:[c.jsx("option",{value:"mlx",children:"Local MLX (→ claude → rules)"}),c.jsx("option",{value:"claude",children:"claude -p (→ rules)"}),c.jsx("option",{value:"rules",children:"Rules only (offline)"})]}),c.jsxs("span",{className:"config-hint",children:["Powers ✨. ",c.jsx("code",{children:"mlx"})," = on-device, no key."]})]}),c.jsxs("label",{className:"config-field",children:[c.jsx("span",{className:"config-label",children:"Claude model"}),c.jsxs("select",{className:"config-input",value:o,disabled:k,onChange:P=>a(P.target.value),children:[o&&!g?.claudeModels.some(P=>P.id===o)?c.jsxs("option",{value:o,children:[o,g?" (custom)":""]}):null,(g?.claudeModels??[]).map(P=>c.jsxs("option",{value:P.id,children:[P.label,P.id===g?.recommendedClaudeModel?" · recommended":""]},P.id))]}),c.jsxs("span",{className:"config-hint",children:["For the ",c.jsx("code",{children:"claude -p"})," backend/fallback."]})]}),c.jsxs("label",{className:"config-field config-field--wide",children:[c.jsx("span",{className:"config-label",children:"MLX model"}),c.jsxs("select",{className:"config-input",value:h,disabled:k||f!=="mlx",onChange:P=>p(P.target.value),children:[h&&!g?.mlxModels.some(P=>P.id===h)?c.jsxs("option",{value:h,children:[h,g?" (custom)":""]}):null,(g?.mlxModels??[]).map(P=>c.jsxs("option",{value:P.id,children:[P.label," · ",P.sizeGB," GB",P.installed?" · downloaded":" · ⬇ download",P.id===g?.recommendedMlxModel?" · recommended":"",g&&P.minRamGB>g.machine.ramGB?` (needs ≥${P.minRamGB} GB)`:""]},P.id))]}),c.jsx("span",{className:"config-hint",children:g?`Your ${g.machine.appleSilicon?"Apple Silicon ":""}Mac has ${g.machine.ramGB} GB — recommended: ${g.mlxModels.find(P=>P.id===g.recommendedMlxModel)?.label??g.recommendedMlxModel}. Auto-downloads on first use.`:"On-device model for the ✨ enhancer. Auto-downloads on first use."})]}),c.jsxs("label",{className:"config-field config-field--wide",children:[c.jsx("span",{className:"config-label",children:"Claude CLI path (optional)"}),c.jsx("input",{className:"config-input",type:"text",placeholder:"auto-detected",value:l,disabled:k,onChange:P=>u(P.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),c.jsxs("span",{className:"config-hint",children:["Path to the ",c.jsx("code",{children:"claude"})," binary. Blank = auto-detect."]})]}),c.jsxs("div",{className:"config-field config-field--wide",children:[c.jsx("span",{className:"config-label",children:"App icon"}),c.jsxs("div",{className:"config-icon-row",children:[c.jsx("img",{className:"config-icon-preview",src:`/api/icon?size=192&t=${S}`,alt:"Current home-screen icon",width:44,height:44}),c.jsxs("div",{className:"config-icon-actions",children:[c.jsx("button",{type:"button",className:"config-cancel",disabled:N,onClick:()=>_.current?.click(),children:N?"Working…":"Upload PNG"}),c.jsx("button",{type:"button",className:"config-cancel",disabled:N,onClick:j,children:"Reset"})]}),c.jsx("input",{ref:_,type:"file",accept:"image/png",hidden:!0,onChange:z})]}),c.jsx("span",{className:"config-hint",children:"Defaults to the Claude Control logo. Re-add to Home Screen after changing."})]})]}),c.jsxs("div",{className:"config-foot",children:[c.jsx("div",{className:"config-version",children:E?c.jsxs(c.Fragment,{children:[c.jsxs("span",{children:["claude-control v",E.current]}),E.updateAvailable&&E.latest?c.jsxs("span",{className:"config-version-update",children:["· update available: v",E.latest]}):null]}):null}),c.jsxs("div",{className:"config-actions",children:[c.jsx("button",{type:"button",className:"config-cancel",onClick:e,disabled:v,children:"Cancel"}),c.jsx("button",{type:"button",className:"config-save",onClick:K,disabled:k||v,children:v?"Saving…":"Save"})]})]})]})})}function Im(e=Date.now()){return`session-${e.toString(36).slice(-6)}`}function B2({onToast:e,onOpenSettings:t}){const[n,r]=m.useState(!1),[s,i]=m.useState(""),[o,a]=m.useState(!1),[l,u]=m.useState(Im),f=m.useRef(null);m.useEffect(()=>{n&&(u(Im()),f.current?.focus())},[n]);const d=m.useCallback(()=>{r(!1),i("")},[]),h=m.useCallback(async()=>{if(o)return;a(!0);const p=s.trim()||l;e("Creating session…");try{const g=await lR({name:p});e(`Session created → ${g.name}`,"ok"),d()}catch(g){e(`New session failed: ${g.message}`,"error")}finally{a(!1)}},[o,s,l,e,d]);return n?c.jsxs("form",{className:"rail-new-form","aria-label":"Create session",onSubmit:p=>{p.preventDefault(),h()},children:[c.jsx("input",{ref:f,className:"rail-new-name",type:"text",value:s,placeholder:l,disabled:o,onChange:p=>i(p.target.value),onKeyDown:p=>{p.key==="Escape"&&(p.preventDefault(),d())},"aria-label":"Session name",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),c.jsxs("div",{className:"rail-new-actions",children:[c.jsx("button",{type:"button",className:"rail-new-cancel",onClick:d,disabled:o,children:"Cancel"}),c.jsx("button",{type:"submit",className:"rail-new-create",disabled:o,children:o?"Creating…":"Create"})]})]}):c.jsxs("div",{className:"rail-head",children:[c.jsx("button",{type:"button",className:"rail-new",onClick:()=>r(!0),children:"+ New session"}),c.jsx("button",{type:"button",className:"rail-gear","aria-label":"Settings",title:"Settings",onClick:t,children:"⚙"})]})}function $2(e){return e==="Escape"}function U2({sessionId:e,label:t,onClose:n}){const r=KI(e),s=m.useRef(null);m.useEffect(()=>{const o=a=>{$2(a.key)&&n()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n]);const i=()=>{s.current?.focus()};return m.useEffect(()=>{i()},[]),c.jsxs("div",{className:"term-overlay",role:"dialog","aria-modal":"true","aria-label":`Raw terminal — ${t}`,children:[c.jsxs("header",{className:"term-head",children:[c.jsxs("span",{className:"term-title",children:[c.jsx("span",{"aria-hidden":"true",children:"⛶"})," ",t]}),c.jsxs("span",{className:"term-actions",children:[c.jsx("a",{className:"term-newtab",href:r,target:"_blank",rel:"noopener noreferrer",title:"Open in a new tab",children:"↗ New tab"}),c.jsx("button",{type:"button",className:"term-close","aria-label":"Close terminal",onClick:n,children:"✕"})]})]}),c.jsx("iframe",{ref:s,className:"term-frame",src:r,title:`Raw terminal for ${t}`,onLoad:i})]})}function V2({children:e}){const[t,n]=m.useState("probing"),[r,s]=m.useState(null),[i,o]=m.useState(""),a=m.useCallback(async()=>{try{return(await Le("/api/health")).ok?(n("authed"),s(null),!0):!1}catch{return s("Cannot reach the server. Check the connection and retry."),!1}},[]);m.useEffect(()=>{let u=!1;return(async()=>{const f=await a();u||f||n("needs-token")})(),()=>{u=!0}},[a]),m.useEffect(()=>WI(()=>{n("needs-token"),o(""),s("Session expired — enter your access token again.")}),[]);const l=m.useCallback(async u=>{u.preventDefault();const f=i.trim();if(!f){s("Enter an access token.");return}n("submitting"),s(null),mw(f),await a()||(gw(),n("needs-token"),s("Invalid token."))},[i,a]);return t==="authed"?c.jsx(c.Fragment,{children:e}):t==="probing"?c.jsx("div",{className:"gate-root",role:"status","aria-live":"polite",children:c.jsxs("div",{className:"gate-card gate-card--probing",children:[c.jsx("span",{className:"gate-spinner","aria-hidden":"true"}),c.jsx("span",{className:"gate-probing-text",children:"Connecting…"})]})}):(Ua(),c.jsx("div",{className:"gate-root",children:c.jsxs("form",{className:"gate-card",onSubmit:l,"aria-label":"Sign in",children:[c.jsxs("div",{className:"gate-brand",children:[c.jsx("span",{className:"gate-glyph","aria-hidden":"true",children:"◧"}),c.jsx("span",{className:"gate-title",children:"claude control"})]}),c.jsx("label",{className:"gate-label",htmlFor:"gate-token",children:"Access token"}),c.jsx("input",{id:"gate-token",className:"gate-input",type:"password",autoComplete:"current-password",autoFocus:!0,spellCheck:!1,value:i,onChange:u=>{o(u.target.value),r&&s(null)},"aria-invalid":r?!0:void 0,"aria-describedby":r?"gate-error":void 0,placeholder:"••••••••••••"}),r?c.jsx("p",{id:"gate-error",className:"gate-error",role:"alert",children:r}):null,c.jsx("button",{type:"submit",className:"gate-submit",disabled:t==="submitting",children:t==="submitting"?"Connecting…":"Connect"})]})}))}function H2(e){if(!e)return"";const t=Date.parse(e);return Number.isNaN(t)?"":new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function W2({session:e,onClose:t,onToast:n,onPinned:r}){const[s,i]=m.useState(null),[o,a]=m.useState(""),[l,u]=m.useState(!1);m.useEffect(()=>{let h=!0;return YI().then(p=>h&&i(p)).catch(p=>{h&&(i([]),n(`Couldn't load transcripts: ${p.message}`,"error"))}),()=>{h=!1}},[n]);const f=m.useMemo(()=>{if(!s)return[];const h=o.trim().toLowerCase();return h?s.filter(p=>[p.title,p.cwd,p.sessionId].some(g=>g?.toLowerCase().includes(h))):s},[s,o]),d=async h=>{if(!l){u(!0);try{await QI(e.id,h),n(h?"Pinned →":"Unpinned","ok"),r(),t()}catch(p){n(`Pin failed: ${p.message}`,"error")}finally{u(!1)}}};return c.jsx("div",{className:"modal-backdrop",role:"dialog","aria-modal":"true",onClick:t,children:c.jsxs("div",{className:"modal pin-modal",onClick:h=>h.stopPropagation(),children:[c.jsxs("header",{className:"modal-head",children:[c.jsxs("span",{className:"modal-title",children:["Pin transcript — ",e.name||e.id]}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Close",onClick:t,children:"×"})]}),e.pinned?c.jsx("button",{type:"button",className:"pin-unpin",disabled:l,onClick:()=>d(null),children:"Unpin (return to auto-match)"}):null,c.jsx("input",{className:"pin-search",type:"text",placeholder:"filter by title, cwd, or session id…",value:o,onChange:h=>a(h.target.value),autoFocus:!0}),c.jsx("div",{className:"pin-list",children:s===null?c.jsx("div",{className:"pin-empty",children:"loading…"}):f.length===0?c.jsx("div",{className:"pin-empty",children:"no transcripts match"}):f.map(h=>{const p=h.transcriptPath===e.transcriptPath;return c.jsxs("button",{type:"button",className:"pin-row","data-current":p?"true":void 0,disabled:l,onClick:()=>d(h.transcriptPath),children:[c.jsxs("span",{className:"pin-row-title",children:[h.title||h.sessionId||h.transcriptPath,p?c.jsx("span",{className:"pin-row-cur",children:" · current"}):null]}),c.jsxs("span",{className:"pin-row-meta",children:[h.cwd?c.jsx("span",{className:"pin-row-cwd",children:h.cwd}):null,c.jsx("span",{className:"pin-row-when",children:H2(h.lastActivity)})]})]},h.transcriptPath)})})]})})}const q2={UserMessage:Qa,AssistantMessage:Hn,SystemMessage:Hn};function K2({markdown:e}){const t=m.useMemo(()=>[{role:"assistant",id:"plan",content:[{type:"text",text:e}],metadata:{custom:{cockpitRole:"assistant"}}}],[e]),n=Fa({messages:t,isDisabled:!0,convertMessage:r=>r,onNew:async()=>{}});return c.jsx(Ba,{runtime:n,children:c.jsx(dt.Root,{className:"plan-review",children:c.jsx(dt.Viewport,{className:"plan-review-viewport",children:c.jsx(dt.Messages,{components:q2})})})})}function G2({prompt:e,onKey:t,onClose:n,planMarkdown:r}){const s=m.useMemo(()=>e.options.find(x=>x.selected)?.key??e.options[0]?.key??null,[e]),[i,o]=m.useState(s),[a,l]=m.useState(null),u=JSON.stringify(e);m.useEffect(()=>{o(s),l(null)},[u,s]);const f=g=>{a||(l(g),t(g))},d=()=>{i&&f(i)};m.useEffect(()=>{const g=x=>{if(!a){if(x.key==="Escape"){x.preventDefault(),n();return}if(x.key==="Enter"){x.preventDefault(),i&&f(i);return}e.options.some(k=>k.key===x.key)&&(x.preventDefault(),o(x.key))}};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[n,a,i,u]);const h=a!==null,p=!!r;return c.jsx("div",{className:"modal-backdrop",onClick:g=>{g.target===g.currentTarget&&!h&&n()},children:c.jsxs("div",{className:p?"modal modal-plan":"modal",role:"dialog","aria-modal":"true","aria-label":p?"Review plan":"Terminal prompt",children:[c.jsxs("div",{className:"modal-head",children:[c.jsx("span",{className:"modal-title",children:p?"Review plan":"Claude needs a choice"}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Hide",onClick:n,children:"✕"})]}),c.jsxs("div",{className:"modal-body",children:[p?c.jsx(K2,{markdown:r}):null,c.jsxs("div",{className:"question",children:[p?null:c.jsx("div",{className:"q-text",children:e.question}),c.jsx("div",{className:"q-options",role:"radiogroup","aria-label":"Options",children:e.options.map(g=>c.jsxs("button",{type:"button",className:"option-btn",role:"radio","aria-checked":i===g.key,"data-on":i===g.key?"true":"false","data-sending":a===g.key?"true":void 0,disabled:h,onClick:()=>o(g.key),children:[c.jsxs("span",{className:"option-label",children:[g.key,". ",g.label]}),a===g.key?c.jsxs("span",{className:"option-sending","aria-live":"polite",children:[c.jsx("span",{className:"working-spinner","aria-hidden":"true"})," sending…"]}):null]},g.key))})]})]}),c.jsxs("div",{className:"modal-foot",children:[c.jsxs("button",{type:"button",className:"btn-secondary",disabled:h,onClick:()=>f("Escape"),children:["Cancel ",c.jsx(tr,{children:"Esc"})]}),c.jsx("span",{className:"modal-foot-spacer"}),h?c.jsx("span",{className:"prompt-status",children:"submitting your answer…"}):null,c.jsxs("button",{type:"button",className:"btn-primary",disabled:h||!i,onClick:d,children:["Confirm ",c.jsx(tr,{children:"↵"})]})]})]})})}const Q2={UserMessage:Qa,AssistantMessage:Hn,SystemMessage:Hn};function Y2({messages:e}){const t=m.useMemo(()=>bw(e),[e]),n=Fa({messages:t,isDisabled:!0,convertMessage:r=>r,onNew:async()=>{}});return c.jsx(Ba,{runtime:n,children:c.jsx(dt.Root,{className:"sa-thread-root",children:c.jsxs(dt.Viewport,{className:"sa-thread-viewport",autoScroll:!0,children:[c.jsx(dt.Empty,{children:c.jsx("div",{className:"thread-empty",children:"no output yet…"})}),c.jsx(dt.Messages,{components:Q2})]})})})}const J2={active:"Active",completed:"Completed",all:"All"};function Kb(e){return e.model?e.model:e.def?.model?e.def.model:null}function sf({agentType:e,model:t}){return c.jsxs("span",{className:"agent-chip",children:[c.jsx("span",{className:"agent-chip-name",children:e||"sub-agent"}),t?c.jsx("span",{className:"agent-chip-model",children:t}):null]})}function X2({def:e,agentType:t}){if(!e)return c.jsx("div",{className:"agent-def",children:c.jsx("span",{className:"agent-def-no-def",children:t||"sub-agent"})});const n=new Set(["name","description","tools","model"]),r=Object.keys(e).filter(s=>!n.has(s));return c.jsxs("div",{className:"agent-def",children:[e.description?c.jsx("div",{className:"agent-def-row agent-def-desc",children:e.description}):null,e.tools?c.jsxs("div",{className:"agent-def-row",children:[c.jsx("span",{className:"agent-def-label",children:"tools"}),c.jsx("span",{className:"agent-def-val agent-def-tools",children:e.tools})]}):null,e.model?c.jsxs("div",{className:"agent-def-row",children:[c.jsx("span",{className:"agent-def-label",children:"model"}),c.jsx("span",{className:"agent-def-val",children:e.model})]}):null,r.map(s=>c.jsxs("div",{className:"agent-def-row",children:[c.jsx("span",{className:"agent-def-label",children:s}),c.jsx("span",{className:"agent-def-val",children:e[s]})]},s))]})}function Z2({nested:e}){return!e||e.length===0?null:c.jsxs("div",{className:"agent-nested",children:[c.jsxs("span",{className:"agent-nested-label",children:["nested (",e.length,")"]}),c.jsx("div",{className:"agent-nested-list",children:e.map(t=>c.jsx(sf,{agentType:t.agentType,model:t.model},t.agentId))})]})}function ez({agent:e}){const t=Kb(e);return c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"sa-dot","data-status":e.status,"aria-hidden":"true"}),c.jsx(sf,{agentType:e.agentType,model:t}),e.description?c.jsx("span",{className:"sa-desc",children:e.description}):null,c.jsx("span",{className:"sa-status",children:e.status==="running"?"· running":"· done"})]})}function tz({subagents:e,open:t,onClose:n}){const[r,s]=m.useState("active"),[i,o]=m.useState(null),a=e.filter(d=>d.status==="running").length,l={active:a,completed:e.length-a,all:e.length},u=i?e.find(d=>d.agentId===i)??null:null,f=m.useMemo(()=>e.filter(d=>r==="all"?!0:r==="active"?d.status==="running":d.status==="done"),[e,r]);if(!t)return null;if(u){const d=Kb(u);return c.jsxs("div",{className:"sa-panel",role:"complementary","aria-label":"Sub-agent transcript",children:[c.jsxs("header",{className:"sa-panel-head",children:[c.jsx("button",{type:"button",className:"sa-back","aria-label":"Back to list",onClick:()=>o(null),children:"‹"}),c.jsxs("span",{className:"sa-panel-title sa-detail-title",children:[c.jsx("span",{className:"sa-dot","data-status":u.status,"aria-hidden":"true"}),c.jsx(sf,{agentType:u.agentType,model:d}),c.jsx("span",{className:"sa-status",children:u.status==="running"?"· running":"· done"})]}),c.jsx("button",{type:"button",className:"sa-panel-close","aria-label":"Close",onClick:n,children:"×"})]}),c.jsx(X2,{def:u.def,agentType:u.agentType}),c.jsx(Z2,{nested:u.nested}),c.jsx(Y2,{messages:u.messages})]})}return c.jsxs("div",{className:"sa-panel",role:"complementary","aria-label":"Sub-agents",children:[c.jsxs("header",{className:"sa-panel-head",children:[c.jsxs("span",{className:"sa-panel-title",children:["Sub-agents ",c.jsx("span",{className:"sa-count",children:e.length}),a?c.jsxs("span",{className:"sa-count-running",children:[a," running"]}):null]}),c.jsx("button",{type:"button",className:"sa-panel-close","aria-label":"Close sub-agents panel",onClick:n,children:"×"})]}),c.jsx("div",{className:"sa-tabs",role:"tablist",children:["active","completed","all"].map(d=>c.jsxs("button",{type:"button",role:"tab","aria-selected":r===d,className:"sa-tab","data-on":r===d?"true":void 0,onClick:()=>s(d),children:[J2[d],c.jsx("span",{className:"sa-tab-count",children:l[d]})]},d))}),c.jsx("div",{className:"sa-panel-body",children:f.length===0?c.jsxs("div",{className:"sa-empty",children:["No ",r==="all"?"":`${r} `,"sub-agents."]}):f.map(d=>c.jsxs("button",{type:"button",className:"sa-item-row",onClick:()=>o(d.agentId),children:[c.jsx(ez,{agent:d}),c.jsx("span",{className:"sa-chevron","aria-hidden":"true",children:"›"})]},d.agentId))})]})}function nz(e){return(e.blocks??[]).filter(t=>t.kind==="text").map(t=>t.text).join(" ")}const rz=18e5,Gb="cc_drafts";function sz(){try{return JSON.parse(localStorage.getItem(Gb)||"{}")||{}}catch{return{}}}function iz(e){try{localStorage.setItem(Gb,JSON.stringify(e))}catch{}}const Rm=150,oz=150;function az(e){return typeof e.content=="string"?e.content:e.content.filter(t=>t.type==="text").map(t=>t.text).join(`
|
|
89
|
-
`)}function
|
|
84
|
+
`),s=new Set(n),i=new Set(r),o=[];let a=0,l=0;for(;a<n.length||l<r.length;){const u=n[a],f=r[l];a>=n.length?(o.push({kind:"add",text:f}),l++):l>=r.length?(o.push({kind:"del",text:u}),a++):u===f?(o.push({kind:"same",text:u}),a++,l++):!i.has(u)&&s.has(f)?(o.push({kind:"del",text:u}),o.push({kind:"add",text:f}),a++,l++):i.has(u)?s.has(f)?(o.push({kind:"same",text:u}),a++,l++):(o.push({kind:"add",text:f}),l++):(o.push({kind:"del",text:u}),a++)}return o}function GO({original:e,result:t,onSend:n,onAccept:r,onClose:s}){const[i,o]=m.useState(t.optimized),a=m.useRef(null),[l,u]=m.useState(!0),f=m.useRef(i);f.current=i;const d=m.useRef(n);d.current=n;const h=()=>u(!1);m.useEffect(()=>{a.current?.focus({preventScroll:!0})},[]),m.useEffect(()=>{if(!l)return;const v=setTimeout(()=>d.current(f.current),vm*1e3);return()=>clearTimeout(v)},[l]),m.useEffect(()=>{const v=S=>{S.key==="Escape"?(S.preventDefault(),s()):S.key==="Enter"&&(S.metaKey||S.ctrlKey)&&(S.preventDefault(),d.current(f.current))};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[s]);const p=KO(e,t.optimized),g=p.some(v=>v.kind!=="same");return c.jsx("div",{className:"modal-backdrop",onClick:v=>{v.target===v.currentTarget&&s()},children:c.jsxs("div",{className:"modal modal-optimize",role:"dialog","aria-modal":!0,"aria-label":"Review enhanced prompt",children:[c.jsxs("div",{className:"modal-head",children:[c.jsxs("div",{className:"modal-head-group",children:[c.jsx("span",{className:"modal-title modal-title-optimize",children:"Enhanced prompt"}),c.jsx("span",{className:"optimize-mode-badge","data-mode":t.mode,children:qO(t)})]}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Close",onClick:s,children:"✕"})]}),c.jsxs("div",{className:"modal-body",onScroll:h,onWheel:h,onTouchMove:h,children:[c.jsxs("div",{className:"optimize-section",children:[c.jsx("span",{className:"optimize-section-label",children:"Suggestion"}),c.jsx("textarea",{ref:a,className:"optimize-suggestion",value:i,onChange:v=>{o(v.target.value),h()},rows:6,spellCheck:!1,autoComplete:"off"})]}),g?c.jsxs("div",{className:"optimize-section",children:[c.jsx("span",{className:"optimize-section-label",children:"Changes vs original"}),c.jsx("div",{className:"optimize-diff",children:p.map((v,S)=>c.jsxs("div",{className:v.kind==="add"?"diff-add":v.kind==="del"?"diff-del":"diff-same",children:[v.kind==="add"?"+ ":v.kind==="del"?"- ":" ",v.text||" "]},S))})]}):null,t.rationale.length>0?c.jsxs("div",{className:"optimize-section",children:[c.jsx("span",{className:"optimize-section-label",children:"Rationale"}),c.jsx("ul",{className:"optimize-list",children:t.rationale.map((v,S)=>c.jsx("li",{children:v},S))})]}):null,t.changes.length>0?c.jsxs("div",{className:"optimize-section",children:[c.jsx("span",{className:"optimize-section-label",children:"What changed"}),c.jsx("ul",{className:"optimize-list",children:t.changes.map((v,S)=>c.jsx("li",{children:v},S))})]}):null]}),c.jsxs("div",{className:"modal-foot",children:[c.jsx("button",{type:"button",className:"btn-secondary",onClick:s,children:"Discard"}),c.jsx("span",{className:"modal-foot-spacer"}),c.jsx("button",{type:"button",className:"btn-secondary",onClick:()=>r(i),onMouseEnter:h,children:"To Composer"}),c.jsx("button",{type:"button",className:`btn-primary btn-send${l?" btn-send-armed":""}`,style:l?{"--auto-send-secs":`${vm}s`}:void 0,onClick:()=>n(i),children:c.jsxs("span",{className:"btn-send-label",children:["Send ",c.jsx(Rn,{children:"⌘/Ctrl+↵"})]})})]})]})})}const xm="(max-width:760px)";function Ub(){const[e,t]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(xm).matches);return m.useEffect(()=>{if(typeof window>"u")return;const n=window.matchMedia(xm),r=s=>t(s.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function QO({onPick:e,onClose:t}){const n=Ub(),[r,s]=m.useState([]),[i,o]=m.useState(!0),[a,l]=m.useState(""),u=m.useRef(null);m.useEffect(()=>{let p=!0;return o(!0),ww().then(g=>{p&&(s(g),o(!1))}).catch(()=>{p&&o(!1)}),()=>{p=!1}},[]),m.useEffect(()=>{requestAnimationFrame(()=>u.current?.focus())},[]),m.useEffect(()=>{const p=g=>{g.key==="Escape"&&(g.preventDefault(),t())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]);const f=a.trim().toLowerCase(),d=f?r.filter(p=>p.name.toLowerCase().includes(f)||p.description.toLowerCase().includes(f)):r,h=c.jsxs("div",{className:"skill-browser","data-mode":n?"sheet":"modal",role:"dialog","aria-modal":"true","aria-label":"Skill browser",children:[c.jsxs("div",{className:"skill-browser-head",children:[c.jsx("span",{className:"skill-browser-title",children:"Skills"}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Close skill browser",onClick:t,children:"✕"})]}),c.jsx("div",{className:"skill-browser-search",children:c.jsx("input",{ref:u,type:"search",className:"skill-search-input",placeholder:"Search skills…",value:a,onChange:p=>l(p.currentTarget.value),"aria-label":"Search skills",autoComplete:"off",spellCheck:!1})}),c.jsx("div",{className:"skill-browser-list",role:"list",children:i?c.jsx("div",{className:"skill-browser-empty",children:"Loading…"}):d.length===0?c.jsx("div",{className:"skill-browser-empty",children:f?"No skills match your search.":"No skills found."}):d.map(p=>c.jsxs("button",{type:"button",className:"skill-card",role:"listitem",onClick:()=>e(p.name),title:`Prefill /${p.name}`,children:[c.jsxs("span",{className:"tool-head",children:[c.jsx("span",{className:"tool-arrow","aria-hidden":"true",children:"▸"}),c.jsx("span",{className:"tool-name skill-card-name",children:p.name}),p.description?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"tool-sep",children:"—"}),c.jsx("span",{className:"tool-input skill-card-desc",children:p.description})]}):null]}),p.source==="plugin"?c.jsx("span",{className:"skill-source-tag",children:"plugin"}):null]},p.name))})]});return n?c.jsx("div",{className:"skill-browser-sheet-wrap",children:h}):c.jsx("div",{className:"modal-backdrop",onClick:p=>{p.target===p.currentTarget&&t()},children:h})}function YO(){if(typeof window>"u")return null;const e=window;return e.AudioContext??e.webkitAudioContext??null}function JO(){const e=typeof window<"u"?window.MediaRecorder:void 0,t=[{mime:"audio/webm;codecs=opus",ext:"webm"},{mime:"audio/webm",ext:"webm"},{mime:"audio/mp4",ext:"mp4"},{mime:"audio/aac",ext:"aac"},{mime:"audio/ogg;codecs=opus",ext:"ogg"}];if(e&&typeof e.isTypeSupported=="function"){for(const n of t)if(e.isTypeSupported(n.mime))return n}return{mime:"",ext:"webm"}}function XO({onCommit:e,onClose:t}){const[n,r]=m.useState("starting"),[s,i]=m.useState(null),o=typeof window<"u"&&"MediaRecorder"in window,a=m.useRef(null),l=m.useRef(null),u=m.useRef(null),f=m.useRef(null),d=m.useRef([]),h=m.useRef({mime:"",ext:"webm"}),p=m.useRef(null),g=m.useRef(null),v=m.useRef(!1),S=m.useRef(!1),y=m.useCallback(()=>{v.current=!1,g.current!=null&&cancelAnimationFrame(g.current),g.current=null},[]),x=m.useCallback(()=>{const L=p.current,_=u.current;if(!L||!_)return;const z=L.getContext("2d");if(!z)return;const N=new Uint8Array(_.fftSize),K=getComputedStyle(L).getPropertyValue("--accent").trim()||"#7aa2f7";v.current=!0;const P=()=>{if(!v.current)return;L.width!==L.clientWidth&&(L.width=L.clientWidth),_.getByteTimeDomainData(N);const B=L.width,ee=L.height;z.clearRect(0,0,B,ee),z.lineWidth=2,z.strokeStyle=K,z.beginPath();const ae=B/N.length;for(let F=0;F<N.length;F+=1){const b=N[F]/128*ee/2,J=F*ae;F===0?z.moveTo(J,b):z.lineTo(J,b)}z.stroke(),g.current=requestAnimationFrame(P)};g.current=requestAnimationFrame(P)},[]),w=m.useCallback(()=>{y(),a.current?.getTracks().forEach(L=>L.stop()),a.current=null,l.current?.close().catch(()=>{}),l.current=null,u.current=null},[y]);m.useEffect(()=>{let L=!1;return(async()=>{try{if(!navigator.mediaDevices?.getUserMedia)throw new Error("no-getusermedia");const _=await navigator.mediaDevices.getUserMedia({audio:!0});if(L){_.getTracks().forEach(P=>P.stop());return}a.current=_;const z=YO();if(z){const P=new z;l.current=P,P.state==="suspended"&&await P.resume();const B=P.createMediaStreamSource(_),ee=P.createAnalyser();ee.fftSize=512,B.connect(ee),u.current=ee}if(!("MediaRecorder"in window))throw new Error("no-mediarecorder");const N=JO();h.current=N;const K=N.mime?new MediaRecorder(_,{mimeType:N.mime}):new MediaRecorder(_);K.ondataavailable=P=>{P.data&&P.data.size>0&&d.current.push(P.data)},f.current=K,K.start(),r("recording"),x()}catch(_){const z=_ instanceof Error?_.message:"";i(z==="no-mediarecorder"?"Audio recording isn’t supported in this browser.":"Microphone permission denied or unavailable."),r("error")}})(),()=>{L=!0,y();try{f.current?.stop()}catch{}f.current=null,a.current?.getTracks().forEach(_=>_.stop()),a.current=null,l.current?.close().catch(()=>{}),l.current=null,u.current=null}},[]);const E=m.useCallback(()=>{try{f.current?.pause()}catch{}y(),r("paused")},[y]),I=m.useCallback(()=>{try{f.current?.resume()}catch{}r("recording"),x()},[x]),k=m.useCallback(()=>{if(S.current)return;S.current=!0;const L=f.current;if(!L){w(),e("");return}r("transcribing"),L.onstop=async()=>{const{mime:_,ext:z}=h.current,N=new Blob(d.current,{type:_||"audio/webm"});if(w(),N.size===0){e("");return}try{const K=await aR(N,z);e(K)}catch(K){i(K instanceof Error?K.message:"Transcription failed."),r("error")}};try{L.stop()}catch{w(),e("")}},[w,e]),R=m.useCallback(()=>{S.current=!0;try{f.current?.stop()}catch{}f.current=null,w(),t()},[w,t]);m.useEffect(()=>{const L=_=>{_.key==="Escape"&&n!=="transcribing"&&(_.preventDefault(),R())};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[R,n]);const M=n==="error"?"Microphone unavailable":n==="transcribing"?"Transcribing…":n==="paused"?"Paused":n==="starting"?"Starting…":"Listening…";return c.jsx("div",{className:"modal-backdrop",onClick:L=>{L.target===L.currentTarget&&n!=="transcribing"&&R()},children:c.jsxs("div",{className:"modal voice-dialog",role:"dialog","aria-modal":"true","aria-label":"Voice input",children:[c.jsxs("div",{className:"voice-status",children:[c.jsx("span",{className:"voice-dot","data-on":n==="recording"?"true":void 0}),M]}),c.jsx("canvas",{ref:p,className:"voice-wave",height:72,"data-paused":n!=="recording"?"true":void 0}),c.jsx("div",{className:"voice-transcript",children:n==="transcribing"?c.jsx("span",{className:"voice-placeholder",children:"Converting speech to text…"}):c.jsx("span",{className:"voice-placeholder",children:"Speak, then tap “Stop & insert” to transcribe."})}),n==="error"?c.jsx("div",{className:"voice-error",children:s||"Could not start recording."}):o?null:c.jsx("div",{className:"voice-note",children:"Audio recording isn’t supported in this browser."}),c.jsxs("div",{className:"voice-actions",children:[c.jsx("button",{type:"button",className:"btn-secondary",onClick:R,disabled:n==="transcribing",children:"Cancel"}),c.jsx("span",{className:"voice-actions-spacer"}),n==="recording"?c.jsx("button",{type:"button",className:"btn-secondary",onClick:E,children:"Pause"}):n==="paused"?c.jsx("button",{type:"button",className:"btn-secondary",onClick:I,children:"Resume"}):null,c.jsx("button",{type:"button",className:"btn-primary",onClick:k,disabled:n==="error"||n==="transcribing"||n==="starting",children:n==="transcribing"?"Transcribing…":"Stop & Insert"})]})]})})}const mc=["#414868","#f7768e","#9ece6a","#e0af68","#7aa2f7","#bb9af7","#7dcfff","#a9b1d6"],gc=["#565f89","#ff7a93","#b9f27c","#ff9e64","#9bb5ff","#c7a9ff","#a4daff","#c0caf5"];function ZO(e){if(e<8)return mc[e];if(e<16)return gc[e-8];if(e>=232){const o=8+(e-232)*10;return`rgb(${o},${o},${o})`}const t=e-16,n=Math.floor(t/36),r=Math.floor(t%36/6),s=t%6,i=o=>o===0?0:o*40+55;return`rgb(${i(n)},${i(r)},${i(s)})`}function e2(e,t){for(let n=0;n<t.length;n+=1){const r=t[n];if(r===0)e.fg=void 0,e.bg=void 0,e.bold=!1,e.dim=!1,e.italic=!1,e.underline=!1;else if(r===1)e.bold=!0;else if(r===2)e.dim=!0;else if(r===3)e.italic=!0;else if(r===4)e.underline=!0;else if(r===22)e.bold=!1,e.dim=!1;else if(r===23)e.italic=!1;else if(r===24)e.underline=!1;else if(r>=30&&r<=37)e.fg=mc[r-30];else if(r===39)e.fg=void 0;else if(r>=90&&r<=97)e.fg=gc[r-90];else if(r>=40&&r<=47)e.bg=mc[r-40];else if(r===49)e.bg=void 0;else if(r>=100&&r<=107)e.bg=gc[r-100];else if(r===38||r===48){const s=r===38?"fg":"bg";t[n+1]===5?(e[s]=ZO(t[n+2]??0),n+=2):t[n+1]===2&&(e[s]=`rgb(${t[n+2]??0},${t[n+3]??0},${t[n+4]??0})`,n+=4)}}}const Ql=/\x1b\[([0-9;]*)m/g,t2=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g,n2=/\x1b\[[0-9;?]*[ -/]*[@-~]|\x1b[@-Z\\-_]/g,r2=/\x1b\[[0-9;?]*[ -/]*[@-~]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[@-Z\\-_]/g;function s2(e){const t=String(e).split(`
|
|
85
|
+
`);for(;t.length&&t[t.length-1].replace(r2,"").trim()==="";)t.pop();return t.join(`
|
|
86
|
+
`)}function i2(e){return e.replace(n2,"")}function o2(e){const t=String(e).replace(t2,""),n=[],r={};let s=0,i;Ql.lastIndex=0;const o=a=>{const l=i2(a);l&&n.push({text:l,...r})};for(;(i=Ql.exec(t))!==null;){i.index>s&&o(t.slice(s,i.index));const a=(i[1]===""?"0":i[1]).split(";").map(l=>Number(l)||0);e2(r,a),s=Ql.lastIndex}return s<t.length&&o(t.slice(s)),n}const wm=/(https?:\/\/[^\s'"`<>()\][]+)/g;function a2(e){const t=[];let n=0,r;for(wm.lastIndex=0;(r=wm.exec(e))!==null;){let s=r[0],i="";const o=s.match(/[.,;:!?]+$/);o&&(i=o[0],s=s.slice(0,-i.length)),r.index>n&&t.push({text:e.slice(n,r.index)}),t.push({text:s,href:s}),i&&t.push({text:i}),n=r.index+r[0].length}return n<e.length&&t.push({text:e.slice(n)}),t.length?t:[{text:e}]}const bm=400,l2=800,u2=[{label:"↑",key:"Up",title:"Up"},{label:"↓",key:"Down",title:"Down"},{label:"←",key:"Left",title:"Left"},{label:"→",key:"Right",title:"Right"},"gap",{label:"Tab",key:"Tab",title:"Tab"},{label:"Esc",key:"Escape",title:"Escape"},"gap",{label:"^C",key:"C-c",title:"Interrupt (Ctrl-C)"},{label:"^D",key:"C-d",title:"EOF (Ctrl-D)"},{label:"^R",key:"C-r",title:"Reverse search (Ctrl-R)"},{label:"^Z",key:"C-z",title:"Suspend (Ctrl-Z)"},{label:"^L",key:"C-l",title:"Clear (Ctrl-L)"},"gap",{label:"Home",key:"Home",title:"Home"},{label:"End",key:"End",title:"End"},{label:"PgUp",key:"PPage",title:"Page Up"},{label:"PgDn",key:"NPage",title:"Page Down"}];function Vb({output:e,requestCapture:t,clearOutput:n,sendKey:r,mods:s,onToggleMod:i}){const o=m.useRef(null),a=m.useRef(!0);m.useEffect(()=>{t(bm);const f=setInterval(()=>t(bm),l2);return()=>{clearInterval(f),n()}},[t,n]),m.useLayoutEffect(()=>{const f=o.current;f&&a.current&&(f.scrollTop=f.scrollHeight)},[e]);const l=()=>{const f=o.current;f&&(a.current=f.scrollHeight-f.scrollTop-f.clientHeight<24)},u=m.useMemo(()=>e==null?null:o2(s2(e)).map((f,d)=>{const h={color:f.fg,background:f.bg,fontWeight:f.bold?700:void 0,fontStyle:f.italic?"italic":void 0,textDecoration:f.underline?"underline":void 0,opacity:f.dim?.7:void 0};return c.jsx("span",{style:h,children:a2(f.text).map((p,g)=>p.href?c.jsx("a",{href:p.href,target:"_blank",rel:"noopener noreferrer",children:p.text},g):p.text)},d)}),[e]);return c.jsxs("div",{className:"terminal-view",children:[c.jsxs("div",{className:"terminal-view-head",children:[c.jsx("span",{className:"terminal-view-title",children:"terminal · cc-shell"}),c.jsx("button",{type:"button",className:"terminal-view-btn",onClick:()=>r("C-c"),title:"Interrupt (Ctrl-C)",children:"Stop"})]}),c.jsx("pre",{className:"terminal-view-body",ref:o,onScroll:l,children:u??"starting shell…"}),c.jsxs("div",{className:"terminal-key-bar",role:"toolbar","aria-label":"Terminal keys",children:[c.jsx("button",{type:"button",className:"terminal-key terminal-key-mod","aria-pressed":s.ctrl,"data-on":s.ctrl?"true":void 0,title:"Sticky Ctrl — applies to the next key",onMouseDown:f=>f.preventDefault(),onClick:()=>i("ctrl"),children:"Ctrl"}),c.jsx("button",{type:"button",className:"terminal-key terminal-key-mod","aria-pressed":s.alt,"data-on":s.alt?"true":void 0,title:"Sticky Opt/Meta — applies to the next key",onMouseDown:f=>f.preventDefault(),onClick:()=>i("alt"),children:"Opt"}),c.jsx("span",{className:"terminal-key-gap","aria-hidden":"true"}),u2.map((f,d)=>f==="gap"?c.jsx("span",{className:"terminal-key-gap","aria-hidden":"true"},`gap-${d}`):c.jsx("button",{type:"button",className:"terminal-key",title:f.title,"aria-label":f.title,onMouseDown:h=>h.preventDefault(),onClick:()=>r(f.key),children:f.label},f.key))]})]})}const c2={output:null,run:()=>!1,text:()=>!1,key:()=>!1,poll:()=>!1,clear:()=>{}},Hb=m.createContext(c2),d2=()=>m.useContext(Hb);function Wb(e,t){if(e===t)return{removed:0,added:""};let n=0;const r=Math.min(e.length,t.length);for(;n<r&&e[n]===t[n];)n+=1;let s=0;const i=Math.min(e.length-n,t.length-n);for(;s<i&&e[e.length-1-s]===t[t.length-1-s];)s+=1;return{removed:e.length-n-s,added:t.slice(n,t.length-s)}}const _i=e=>/^[a-z]$/i.test(e);function ya(e,t){return _i(t)?e.ctrl?`C-${t.toLowerCase()}`:e.alt?`M-${t.toLowerCase()}`:null:null}const f2={Enter:"Enter",Escape:"Escape"};function qb(e,t=!1){return e==="Tab"?t?"BTab":"Tab":f2[e]??null}const h2={ArrowUp:"Up",ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right",Home:"Home",End:"End",PageUp:"PPage",PageDown:"NPage"};function Kb(e,t){const n=h2[e];return n?`${t.ctrl?"C-":""}${t.alt?"M-":""}${t.shift?"S-":""}`+n:null}let ti=null,uo=null;function p2(){return ti?Promise.resolve(ti):(uo||(uo=ww().then(e=>(ti=e,e)).catch(()=>(uo=null,[]))),uo)}const m2=/^\/([A-Za-z0-9:_-]*)$/,g2=/^\/([A-Za-z0-9:_-]+)(?:\s|$)/,y2=4;function v2({file:e}){const[t,n]=m.useState(null);return m.useEffect(()=>{const r=URL.createObjectURL(e);return n(r),()=>URL.revokeObjectURL(r)},[e]),t?c.jsx("img",{className:"chip-thumb",src:t,alt:"",role:"button",tabIndex:0,title:"Open preview",onClick:()=>window.open(t,"_blank","noopener"),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),window.open(t,"_blank","noopener"))}}):c.jsx("div",{className:"chip-thumb chip-thumb-empty"})}function x2({attachment:e}){const t=e.type==="image",n=e.status.type==="running";return c.jsxs(Xh.Root,{className:"attach-chip","data-pending":n,children:[t&&e.file?c.jsx(v2,{file:e.file}):c.jsx("span",{className:"chip-icon","aria-hidden":"true",children:e.type==="document"?"📄":"📎"}),c.jsx("span",{className:"chip-name",title:e.name,children:e.name}),n?c.jsx("span",{className:"chip-spinner","aria-hidden":"true"}):null,c.jsx(Xh.Remove,{className:"chip-remove","aria-label":`Remove ${e.name}`,children:"×"})]})}const Sm={optimizing:!1,review:null};function Gb({disabled:e,sessionId:t}){const n=TE(),r=d2(),[s,i]=m.useState(!0),[o,a]=m.useState(!1),[l,u]=m.useState(!1),[f,d]=m.useState({}),h=t??"",{optimizing:p,review:g}=f[h]??Sm,v=m.useCallback((A,O)=>{d(W=>({...W,[A]:{...W[A]??Sm,...O}}))},[]),S=m.useCallback(()=>{requestAnimationFrame(()=>{document.querySelector(".composer-input")?.focus()})},[]),[y,x]=m.useState(()=>ti??[]),[w,E]=m.useState(""),[I,k]=m.useState(0),[R,M]=m.useState(!1);m.useEffect(()=>{ti||p2().then(x)},[]),m.useEffect(()=>{const A=()=>{const O=n.getState().text??"";E(O),i(!O.trim())};return A(),n.subscribe(A)},[n]);const L=m.useMemo(()=>{const A=m2.exec(w);return A?A[1]:null},[w]);m.useEffect(()=>{k(0),M(!1)},[L]);const _=m.useMemo(()=>{if(L==null||R)return[];const A=L.toLowerCase();return y.filter(O=>O.name.toLowerCase().includes(A)).sort((O,W)=>{const Q=O.name.toLowerCase().startsWith(A)?0:1,X=W.name.toLowerCase().startsWith(A)?0:1;return Q!==X?Q-X:O.name.localeCompare(W.name)}).slice(0,y2)},[L,R,y]),z=!l&&_.length>0,N=m.useMemo(()=>{const A=g2.exec(w);return A&&y.some(O=>O.name===A[1])?A[1]:null},[w,y]),K=m.useCallback(A=>{n.setText(`/${A} `),M(!0),requestAnimationFrame(()=>{document.querySelector(".composer-input")?.focus()})},[n]),[P,B]=m.useState(!1),ee=m.useCallback(A=>{B(!1);const O=A.trim();if(!O)return;const W=n.getState().text??"",Q=W&&!/\s$/.test(W)?" ":"";n.setText(W+Q+O+" ")},[n]);m.useEffect(()=>{a(!1),B(!1)},[t]);const ae=m.useCallback(A=>{n.setText(`/${A} `),a(!1),requestAnimationFrame(()=>{document.querySelector(".composer-input")?.focus()})},[n]),F=m.useCallback(async()=>{if(e||p)return;const A=n.getState().text??"";if(!A.trim())return;const O=h;v(O,{optimizing:!0});try{const W=await oR(A);v(O,{optimizing:!1,review:{...W,original:A}})}catch{v(O,{optimizing:!1})}},[n,e,p,h,v]),[D,b]=m.useState({ctrl:!1,alt:!1}),J=m.useRef(D);J.current=D;const Y=m.useRef(r);Y.current=r;const C=m.useRef(""),ge=m.useCallback(A=>{b(O=>({...O,[A]:!O[A]}))},[]);return m.useEffect(()=>{if(!l){C.current="";return}n.setText(""),C.current="",b({ctrl:!1,alt:!1});const A=()=>{const O=n.getState().text??"",W=C.current;if(O===W)return;const{removed:Q,added:X}=Wb(W,O),pe=J.current;if((pe.ctrl||pe.alt)&&Q===0&&X.length===1&&_i(X)){const ze=ya(pe,X);ze&&Y.current.key(ze),b({ctrl:!1,alt:!1}),n.setText(W);return}const _e=X.indexOf(`
|
|
87
|
+
`);if(_e!==-1){for(let ze=0;ze<Q;ze+=1)Y.current.key("BSpace");X.slice(0,_e)&&Y.current.text(X.slice(0,_e)),Y.current.key("Enter"),C.current="",n.setText("");return}for(let ze=0;ze<Q;ze+=1)Y.current.key("BSpace");X&&Y.current.text(X),C.current=O};return n.subscribe(A)},[l,n]),c.jsxs(so.Root,{className:"composer",children:[z?c.jsx("div",{className:"skill-ac",role:"listbox","aria-label":"Skill suggestions",children:_.map((A,O)=>c.jsx("button",{type:"button",role:"option","aria-selected":O===I,"data-on":O===I?"true":void 0,className:"skill-ac-item",onMouseDown:W=>{W.preventDefault(),K(A.name)},onMouseEnter:()=>k(O),children:c.jsxs("span",{className:"tool-head",children:[c.jsx("span",{className:"tool-arrow","aria-hidden":"true",children:"▸"}),c.jsx("span",{className:"tool-name skill-card-name",children:A.name}),A.description?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"tool-sep",children:"—"}),c.jsx("span",{className:"tool-input skill-card-desc",children:A.description})]}):null]})},A.name))}):null,l?c.jsx(Vb,{output:r.output,requestCapture:r.poll,clearOutput:r.clear,sendKey:r.key,mods:D,onToggleMod:ge}):null,c.jsxs("div",{className:"composer-card","data-terminal":l?"true":void 0,children:[N?c.jsx("div",{className:"composer-skill-chip-row",children:c.jsxs("span",{className:"skill-chip composer-skill-chip",title:`Invoking /${N}`,children:[c.jsx("span",{className:"skill-chip-icon","aria-hidden":"true",children:"⌁"}),c.jsxs("span",{className:"skill-chip-name",children:["/",N]})]})}):null,c.jsxs("div",{className:"composer-input-wrap",children:[c.jsx(so.Input,{className:"composer-input",placeholder:e&&!l?"Select a session…":" ",submitOnEnter:!1,onKeyDown:A=>{if(A.key.toLowerCase()==="s"&&(A.metaKey||A.ctrlKey)&&!A.shiftKey){A.preventDefault(),B(!0);return}if(l){if(A.metaKey)return;if(A.key==="Escape"){A.preventDefault(),u(!1),S();return}const O=D,W=A.ctrlKey||O.ctrl,Q=A.altKey||O.alt;if((W||Q)&&A.key.length===1&&_i(A.key)){A.preventDefault();const _e=ya({ctrl:W,alt:Q},A.key);_e&&r.key(_e),(O.ctrl||O.alt)&&b({ctrl:!1,alt:!1});return}const X=Kb(A.key,{ctrl:A.ctrlKey,alt:A.altKey,shift:A.shiftKey});if(X){A.preventDefault(),r.key(X);return}if(A.key==="Backspace"){A.preventDefault(),r.key("BSpace");const _e=n.getState().text??"";if(_e){const ze=_e.slice(0,-1);n.setText(ze),C.current=ze}return}if(A.key==="Delete"){A.preventDefault(),r.key("DC");return}const pe=qb(A.key,A.shiftKey);pe&&(A.preventDefault(),r.key(pe),pe==="Enter"&&(C.current="",n.setText("")));return}if(s&&A.key==="!"){A.preventDefault(),u(!0);return}if(z){if(A.key==="ArrowDown"){A.preventDefault(),k(O=>(O+1)%_.length);return}if(A.key==="ArrowUp"){A.preventDefault(),k(O=>(O-1+_.length)%_.length);return}if(A.key==="Enter"&&!A.metaKey&&!A.ctrlKey){A.preventDefault(),K(_[I].name);return}if(A.key==="Tab"){A.preventDefault(),K(_[I].name);return}if(A.key==="Escape"){A.preventDefault(),M(!0);return}}if(A.key==="Enter"&&(A.metaKey||A.ctrlKey)){if(A.preventDefault(),e||p)return;A.shiftKey?(n.send(),S()):F()}A.key.toLowerCase()==="o"&&(A.metaKey||A.ctrlKey)&&(A.preventDefault(),F())},rows:1,disabled:e&&!l,autoComplete:"off",autoCorrect:l?"off":void 0,autoCapitalize:l?"none":void 0,spellCheck:l?!1:void 0}),l?c.jsxs("div",{className:"composer-hint","aria-hidden":"true",children:[c.jsx("span",{className:"composer-hint-lead",children:"Keys go to the shell…"}),c.jsxs("span",{className:"composer-hint-keys",children:[c.jsx(Rn,{children:"Tab"})," completes",c.jsx("span",{className:"composer-hint-dot",children:"·"}),c.jsx(Rn,{children:"↑"})," history"]})]}):e?null:c.jsxs("div",{className:"composer-hint","aria-hidden":"true",children:[c.jsx("span",{className:"composer-hint-lead",children:"Reply…"}),c.jsxs("span",{className:"composer-hint-keys",children:[c.jsx(Rn,{children:"⌘/Ctrl+↵"})," optimise",c.jsx("span",{className:"composer-hint-dot",children:"·"}),c.jsx(Rn,{children:"⌘/Ctrl+⇧+↵"})," send raw",c.jsx("span",{className:"composer-hint-dot",children:"·"}),c.jsx(Rn,{children:"↵"})," newline"]})]})]}),c.jsx("div",{className:"composer-attachments",children:c.jsx(so.Attachments,{children:({attachment:A})=>c.jsx(x2,{attachment:A})})}),c.jsxs("div",{className:"composer-toolbar",children:[l?null:c.jsxs(c.Fragment,{children:[c.jsx(so.AddAttachment,{className:"composer-attach","aria-label":"Attach a file",title:"Attach a file",multiple:!0,disabled:e,children:c.jsx(w2,{})}),c.jsx("button",{type:"button",className:"composer-skills-btn","aria-label":"Browse skills",title:"Browse skills",disabled:e,onClick:()=>a(A=>!A),children:c.jsx(S2,{})}),c.jsx("button",{type:"button",className:"composer-mic","aria-label":"Voice input",title:"Voice input",disabled:e,onClick:()=>B(!0),children:c.jsx(k2,{})})]}),c.jsx("button",{type:"button",className:"composer-skills-btn composer-term-toggle","aria-label":"Terminal mode",title:"Terminal mode — run shell commands","aria-pressed":l,"data-on":l?"true":void 0,onClick:()=>u(A=>!A),children:c.jsx(b2,{})}),c.jsx("span",{className:"composer-toolbar-spacer"}),l?null:c.jsx("button",{type:"button",className:"composer-enhance composer-bypass","aria-label":"Send without optimising",title:"Send raw — skip the optimiser (⌘/Ctrl+⇧+↵)",disabled:e||p||s,onClick:()=>{n.send(),S()},children:c.jsx(km,{})}),l?c.jsx("button",{type:"button",className:"composer-send","data-terminal":"true","aria-label":"Send Enter",title:"Enter",onMouseDown:A=>A.preventDefault(),onClick:()=>r.key("Enter"),children:c.jsx(km,{})}):c.jsx("button",{type:"button",className:"composer-send","aria-label":"Optimise and send",title:"Optimise & send (⌘/Ctrl+↵)",disabled:e||p||s,onClick:()=>void F(),children:p?c.jsx("span",{className:"composer-enhance-spinner","aria-hidden":"true"}):c.jsx(C2,{})})]})]}),g?c.jsx(GO,{original:g.original,result:g,onSend:A=>{v(h,{review:null}),n.setText(A),requestAnimationFrame(()=>{e||n.send(),S()})},onAccept:A=>{n.setText(A),v(h,{review:null}),S()},onClose:()=>{v(h,{review:null}),S()}}):null,o?c.jsx(QO,{onPick:ae,onClose:()=>a(!1)}):null,P?c.jsx(XO,{onCommit:ee,onClose:()=>B(!1)}):null]})}function w2(){return c.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:c.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}function km(){return c.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:c.jsx("path",{d:"M12 19V5M6 11l6-6 6 6",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function b2(){return c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:c.jsx("path",{d:"M5 8l4 4-4 4M12 16h7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function S2(){return c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:c.jsx("path",{d:"M7 20L17 4",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round"})})}function k2(){return c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[c.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:"currentColor"}),c.jsx("path",{d:"M6 11a6 6 0 0 0 12 0M12 17v3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function C2(){return c.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[c.jsx("path",{d:"M12 2 L13.5 9.5 L21 11 L13.5 12.5 L12 20 L10.5 12.5 L3 11 L10.5 9.5 Z",fill:"currentColor",opacity:"0.9"}),c.jsx("path",{d:"M19 2 L19.8 4.2 L22 5 L19.8 5.8 L19 8 L18.2 5.8 L16 5 L18.2 4.2 Z",fill:"currentColor",opacity:"0.6"})]})}const _2={UserMessage:Qa,AssistantMessage:Wn,SystemMessage:Wn};function E2({hasSelection:e,sessionId:t,hiddenCount:n,onLoadEarlier:r}){return c.jsxs(dt.Root,{className:"thread-root",children:[c.jsx("div",{className:"thread-fade","aria-hidden":"true"}),c.jsxs(dt.Viewport,{className:"thread-viewport",autoScroll:!0,children:[e?c.jsx(dt.Empty,{children:c.jsx("div",{className:"thread-empty",children:"no messages yet"})}):c.jsx("div",{className:"thread-empty",children:"select a session"}),e&&n>0?c.jsxs("button",{type:"button",className:"load-earlier",onClick:r,children:["Load earlier messages (",n," hidden)"]}):null,c.jsx(dt.Messages,{components:_2})]}),c.jsx(Gb,{disabled:!e,sessionId:t})]})}const T2=256*1024,js=40,Cm=90,I2=25,R2=15,P2=95;function A2(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function _m({language:e,content:t,artifactId:n}){const[r,s]=m.useState(null),i=t.length>T2,o=nf(e),a=!i&&o!==null;return m.useEffect(()=>{if(!a){s(null);return}let l=!0;return s(null),Ob(e,t).then(u=>{l&&s(u)}).catch(()=>{l&&s(null)}),()=>{l=!1}},[n,t,a,e]),i?c.jsxs("div",{className:"artifact-body-wrap",children:[c.jsx("p",{className:"artifact-large-note",children:"(large file — shown as plain text)"}),c.jsx("pre",{className:"artifact-pre",children:c.jsx("code",{children:t})})]}):a&&r!==null?c.jsx("div",{className:"artifact-body-wrap",children:c.jsx("pre",{className:"artifact-pre",children:c.jsx("code",{className:"hljs",dangerouslySetInnerHTML:{__html:r}})})}):c.jsx("div",{className:"artifact-body-wrap",children:c.jsx("pre",{className:"artifact-pre",children:c.jsx("code",{className:a?"hljs":void 0,dangerouslySetInnerHTML:{__html:A2(t)}})})})}function j2(){const{artifacts:e,activeId:t,setActive:n,close:r}=rf(),s=Ub(),i=m.useRef(null),o=m.useRef(null),a=m.useId(),[l,u]=m.useState(js),f=m.useRef(null),[d,h]=m.useState(!1),p=e.find(I=>I.id===t)??null,g=p!==null;m.useEffect(()=>{g&&u(js)},[g]);const v=m.useRef(!1);m.useEffect(()=>{const I=v.current;if(v.current=g,!I&&g&&requestAnimationFrame(()=>{const k=o.current?.querySelector('[role="tab"][aria-selected="true"]');k?k.focus():i.current?.focus()}),I&&!g){const k=document.querySelector(".thread-root");k&&(k.hasAttribute("tabindex")||k.setAttribute("tabindex","-1"),k.focus())}},[g]);const S=m.useCallback(I=>{I.key==="Escape"&&t&&(I.preventDefault(),r(t))},[t,r]),y=m.useCallback(I=>{if(I.key!=="ArrowLeft"&&I.key!=="ArrowRight")return;const k=Array.from(o.current?.querySelectorAll('[role="tab"]')??[]),R=document.activeElement,M=k.indexOf(R);if(M<0)return;const L=I.key==="ArrowRight"?k[(M+1)%k.length]:k[(M-1+k.length)%k.length];L?.focus();const _=L?.dataset.artifactId;_&&n(_)},[n]),x=m.useCallback(I=>{f.current={startY:I.clientY,startH:l},I.currentTarget.setPointerCapture(I.pointerId),h(!0)},[l]),w=m.useCallback(I=>{if(!f.current)return;const{startY:k,startH:R}=f.current,M=(k-I.clientY)/window.innerHeight*100,L=Math.min(P2,Math.max(R2,R+M));u(L)},[]),E=m.useCallback(I=>{f.current&&(I.currentTarget.releasePointerCapture(I.pointerId),f.current=null,h(!1),u(k=>{if(k<I2)return t&&r(t),js;const R=Math.abs(k-js),M=Math.abs(k-Cm);return R<=M?js:Cm}))},[t,r]);return g?s?c.jsxs("div",{className:"artifact-panel","data-mode":"sheet",style:{height:`${l}dvh`},"data-dragging":d?"true":"false",role:"region","aria-label":"Artifact panel",ref:i,tabIndex:-1,onKeyDown:S,children:[c.jsx("div",{className:"artifact-drag-handle",role:"separator","aria-label":"Resize panel",onPointerDown:x,onPointerMove:w,onPointerUp:E,children:c.jsx("div",{className:"artifact-drag-pip","aria-hidden":"true"})}),c.jsxs("div",{className:"artifact-panel-head",children:[c.jsx("div",{role:"tablist","aria-label":"Open artifacts",ref:o,className:"artifact-tablist",onKeyDown:y,children:e.map(I=>{const k=I.id===t,R=`artifact-tab-${I.id}`;return c.jsxs("div",{role:"presentation",className:"artifact-tab-wrap",children:[c.jsx("button",{role:"tab",id:R,className:"artifact-tab","aria-selected":k,tabIndex:k?0:-1,"data-artifact-id":I.id,onClick:()=>n(I.id),children:I.title}),c.jsx("button",{className:"artifact-tab-close","aria-label":`Close ${I.title}`,tabIndex:-1,onClick:M=>{M.stopPropagation(),r(I.id)},children:"✕"})]},I.id)})}),c.jsx("button",{className:"artifact-close-all","aria-label":"Close artifact panel",onClick:()=>t&&r(t),children:"×"})]}),p&&c.jsx("div",{role:"tabpanel",id:`${a}-body`,"aria-labelledby":`artifact-tab-${p.id}`,className:"artifact-panel-body",children:c.jsx(_m,{language:p.language,content:p.content,artifactId:p.id})})]}):c.jsxs("div",{className:"artifact-panel",role:"region","aria-label":"Artifact panel",ref:i,tabIndex:-1,onKeyDown:S,children:[c.jsxs("div",{className:"artifact-panel-head",children:[c.jsx("div",{role:"tablist","aria-label":"Open artifacts",ref:o,className:"artifact-tablist",onKeyDown:y,children:e.map(I=>{const k=I.id===t,R=`artifact-tab-${I.id}`;return c.jsxs("div",{role:"presentation",className:"artifact-tab-wrap",children:[c.jsx("button",{role:"tab",id:R,className:"artifact-tab","aria-selected":k,tabIndex:k?0:-1,"data-artifact-id":I.id,onClick:()=>n(I.id),children:I.title}),c.jsx("button",{className:"artifact-tab-close","aria-label":`Close ${I.title}`,tabIndex:-1,onClick:M=>{M.stopPropagation(),r(I.id)},children:"✕"})]},I.id)})}),c.jsx("button",{className:"artifact-close-all","aria-label":"Close artifact panel",onClick:()=>t&&r(t),children:"×"})]}),p&&c.jsx("div",{role:"tabpanel",id:`${a}-body`,"aria-labelledby":`artifact-tab-${p.id}`,className:"artifact-panel-body",children:c.jsx(_m,{language:p.language,content:p.content,artifactId:p.id})})]}):null}const Em=200,N2=2e3;function M2({sessionId:e,capture:t,requestCapture:n,clearCapture:r}){const s=m.useRef(null),i=m.useRef(!0);m.useEffect(()=>{n(Em);const a=setInterval(()=>n(Em),N2);return()=>{clearInterval(a),r()}},[e,n,r]),m.useLayoutEffect(()=>{const a=s.current;a&&i.current&&(a.scrollTop=a.scrollHeight)},[t]);const o=()=>{const a=s.current;a&&(i.current=a.scrollHeight-a.scrollTop-a.clientHeight<24)};return c.jsxs("div",{className:"live-pane",children:[c.jsx("div",{className:"live-pane-head",children:"live pane (no transcript)"}),c.jsx("pre",{className:"live-pane-body",ref:s,onScroll:o,children:t??"capturing live pane…"})]})}function D2(e){const[t,n]=m.useState(""),[r,s]=m.useState({ctrl:!1,alt:!1}),i=m.useRef(""),o=m.useRef(r);o.current=r;const a=m.useRef(e);a.current=e;const l=m.useCallback(h=>{s(p=>({...p,[h]:!p[h]}))},[]),u=m.useCallback(h=>{const p=i.current;if(h===p)return;const{removed:g,added:v}=Wb(p,h),S=o.current,y=a.current;if((S.ctrl||S.alt)&&g===0&&v.length===1&&_i(v)){const w=ya(S,v);w&&y.sendKey(w),s({ctrl:!1,alt:!1}),n(p);return}const x=v.indexOf(`
|
|
88
|
+
`);if(x!==-1){for(let w=0;w<g;w+=1)y.sendKey("BSpace");v.slice(0,x)&&y.sendText(v.slice(0,x)),y.sendKey("Enter"),i.current="",n("");return}for(let w=0;w<g;w+=1)y.sendKey("BSpace");v&&y.sendText(v),i.current=h,n(h)},[]),f=m.useCallback(h=>u(h.target.value),[u]),d=m.useCallback(h=>{if(h.metaKey)return;const p=o.current,g=a.current,v=h.ctrlKey||p.ctrl,S=h.altKey||p.alt;if((v||S)&&h.key.length===1&&_i(h.key)){h.preventDefault();const w=ya({ctrl:v,alt:S},h.key);w&&g.sendKey(w),(p.ctrl||p.alt)&&s({ctrl:!1,alt:!1});return}const y=Kb(h.key,{ctrl:h.ctrlKey,alt:h.altKey,shift:h.shiftKey});if(y){h.preventDefault(),g.sendKey(y);return}if(h.key==="Backspace"){h.preventDefault(),g.sendKey("BSpace");const w=i.current.slice(0,-1);i.current=w,n(w);return}if(h.key==="Delete"){h.preventDefault(),g.sendKey("DC");return}const x=qb(h.key,h.shiftKey);x&&(h.preventDefault(),g.sendKey(x),x==="Enter"&&(i.current="",n("")))},[]);return m.useMemo(()=>({value:t,onChange:f,onKeyDown:d,sticky:r,toggleMod:l}),[t,f,d,r,l])}function L2({sessionId:e,capture:t,requestCapture:n,clearCapture:r,sendText:s,sendKey:i}){const o=m.useMemo(()=>u=>n(u,!0),[n]),a=m.useMemo(()=>({sendText:u=>void s(u),sendKey:u=>void i(u)}),[s,i]),l=D2(a);return c.jsxs("div",{className:"thread-root terminal-pane-root",children:[c.jsx("div",{className:"thread-fade","aria-hidden":"true"}),c.jsx(Vb,{output:t,requestCapture:o,clearOutput:r,sendKey:i,mods:l.sticky,onToggleMod:l.toggleMod},e),c.jsx("div",{className:"terminal-pane-input",children:c.jsx("textarea",{className:"composer-input","aria-label":"Terminal input",placeholder:"Keys go to the pane…",rows:1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,value:l.value,onChange:l.onChange,onKeyDown:l.onKeyDown})})]})}function Tm(e){return e.questions.map(()=>new Set)}function O2({pending:e,capture:t,onAnswer:n,onCapture:r,onClose:s}){const[i,o]=m.useState(()=>Tm(e)),a=m.useRef(null),l=m.useRef(null);m.useEffect(()=>{o(Tm(e))},[e]),m.useEffect(()=>(l.current=document.activeElement,(a.current?.querySelector("button:not([disabled]), [tabindex]")??a.current)?.focus(),()=>{l.current?.focus?.()}),[]);const u=m.useMemo(()=>i.length>0&&i.every(p=>p.size>0),[i]),f=(p,g,v)=>{o(S=>{const y=S.map(w=>new Set(w)),x=y[p];return v?x.has(g)?x.delete(g):x.add(g):y[p]=new Set([g]),y})},d=p=>{if(p.key==="Escape"){p.preventDefault(),s();return}if(p.key!=="Tab")return;const g=a.current?.querySelectorAll('button:not([disabled]), [tabindex="0"]');if(!g||g.length===0)return;const v=g[0],S=g[g.length-1];p.shiftKey&&document.activeElement===v?(p.preventDefault(),S.focus()):!p.shiftKey&&document.activeElement===S&&(p.preventDefault(),v.focus())},h=()=>{u&&n(e.toolUseId,i.map(p=>[...p]))};return c.jsx("div",{className:"modal-backdrop",onClick:p=>{p.target===p.currentTarget&&s()},children:c.jsxs("div",{ref:a,className:"modal",role:"dialog","aria-modal":"true","aria-label":"Question from Claude",tabIndex:-1,onKeyDown:d,children:[c.jsxs("div",{className:"modal-head",children:[c.jsx("span",{className:"modal-title",children:"Claude is asking"}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Close",onClick:s,children:"✕"})]}),c.jsxs("div",{className:"modal-body",children:[e.questions.map((p,g)=>c.jsxs("div",{className:"question",children:[p.header?c.jsx("div",{className:"q-header",children:p.header}):null,c.jsx("div",{className:"q-text",children:p.question}),p.multiSelect?c.jsx("div",{className:"q-hint",children:"select one or more"}):null,c.jsx("div",{className:"q-options",children:p.options.map(v=>{const S=i[g]?.has(v.label);return c.jsxs("button",{type:"button",className:"option-btn","data-on":S?"true":"false","aria-pressed":S,onClick:()=>f(g,v.label,!!p.multiSelect),children:[c.jsx("span",{className:"option-label",children:v.label}),v.description?c.jsx("span",{className:"option-desc",children:v.description}):null]},v.label)})})]},g)),t!=null?c.jsx("pre",{className:"capture-output",children:t}):null]}),c.jsxs("div",{className:"modal-foot",children:[c.jsx("button",{type:"button",className:"btn-secondary",onClick:r,children:"Show Terminal"}),c.jsx("span",{className:"modal-foot-spacer"}),c.jsx("button",{type:"button",className:"btn-secondary",onClick:s,children:"Cancel"}),c.jsx("button",{type:"button",className:"btn-primary",disabled:!u,onClick:h,children:"Send Answer"})]})]})})}function z2({toast:e}){const[t,n]=m.useState(!1);return m.useEffect(()=>{if(!e)return;n(!0);const r=setTimeout(()=>n(!1),2200);return()=>clearTimeout(r)},[e]),e?c.jsx("div",{className:`toast ${t?"show":""} ${e.kind?`toast-${e.kind}`:""}`,role:"status","aria-live":"polite",children:e.text}):null}const Im="claude-control-update-dismissed";function F2(e){if(e.latest&&e.latest!==e.current)return`Update available — v${e.latest} (you’re on v${e.current}).`;const t=e.behind||1;return`Update available — ${t} new commit${t===1?"":"s"} (v${e.current}).`}function B2(){const[e,t]=m.useState(null),[n,r]=m.useState(!1);return m.useEffect(()=>{let s=!0;return xw().then(i=>{if(!s||!i?.updateAvailable)return;const o=i.latest??`behind-${i.behind??0}`;localStorage.getItem(Im)!==o&&t({current:i.current,latest:i.latest,behind:i.behind??0})}),()=>{s=!1}},[]),e?n?c.jsx("div",{className:"update-banner",role:"status",children:c.jsx("span",{children:"Updating… the page will reconnect shortly."})}):c.jsxs("div",{className:"update-banner",role:"status",children:[c.jsx("span",{children:F2(e)}),c.jsxs("span",{className:"update-actions",children:[c.jsx("button",{type:"button",className:"update-now",onClick:()=>{r(!0),ZI()},children:"Update now"}),c.jsx("button",{type:"button",className:"update-dismiss","aria-label":"Dismiss update notice",onClick:()=>{localStorage.setItem(Im,e.latest??`behind-${e.behind}`),t(null)},children:"×"})]})]}):null}function $2({onClose:e,onToast:t}){const[n,r]=m.useState(""),[s,i]=m.useState(""),[o,a]=m.useState(""),[l,u]=m.useState(""),[f,d]=m.useState("mlx"),[h,p]=m.useState(""),[g,v]=m.useState(null),[S,y]=m.useState(!0),[x,w]=m.useState(!1),[E,I]=m.useState(null),[k,R]=m.useState(()=>Date.now()),[M,L]=m.useState(!1),_=m.useRef(null);m.useEffect(()=>{let P=!0;return xw().then(B=>P&&B&&I(B)).catch(()=>{}),iR().then(B=>P&&v(B)).catch(()=>{}),()=>{P=!1}},[]),m.useEffect(()=>{let P=!0;return lR().then(B=>{P&&(r(B.launchCommand),i(B.defaultCwd),a(B.optimizeModel??""),u(B.claudeBin??""),d(B.optimizeBackend??"mlx"),p(B.mlxModel??""))}).catch(B=>t(`Load config failed: ${B.message}`,"error")).finally(()=>{P&&y(!1)}),()=>{P=!1}},[t]),m.useEffect(()=>{const P=B=>{B.key==="Escape"&&e()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[e]);const z=async P=>{const B=P.target.files?.[0];if(P.target.value="",!!B){if(B.type!=="image/png"){t("Icon must be a PNG image","error");return}L(!0);try{await rR(B),R(Date.now()),t("App icon updated — re-add to Home Screen to see it","ok")}catch(ee){t(`Icon upload failed: ${ee.message}`,"error")}finally{L(!1)}}},N=async()=>{L(!0);try{await sR(),R(Date.now()),t("App icon reset to default","ok")}catch(P){t(`Icon reset failed: ${P.message}`,"error")}finally{L(!1)}},K=async()=>{w(!0);try{const P=await uR({launchCommand:n,defaultCwd:s,optimizeModel:o,claudeBin:l,optimizeBackend:f,mlxModel:h});r(P.launchCommand),i(P.defaultCwd),a(P.optimizeModel??""),u(P.claudeBin??""),d(P.optimizeBackend??"mlx"),p(P.mlxModel??"");const B=g?.mlxModels.find(ee=>ee.id===P.mlxModel);P.optimizeBackend==="mlx"&&B&&B.installed===!1?t(`Downloading ${B.label} (${B.sizeGB} GB)… enhancer uses claude until ready`,"ok"):t("Config saved","ok"),e()}catch(P){t(`Save failed: ${P.message}`,"error")}finally{w(!1)}};return c.jsx("div",{className:"config-overlay",role:"presentation",onClick:P=>{P.target===P.currentTarget&&e()},children:c.jsxs("div",{className:"config-modal",role:"dialog","aria-modal":"true","aria-label":"Settings",children:[c.jsxs("div",{className:"config-head",children:[c.jsx("span",{className:"config-title",children:"Settings"}),c.jsx("button",{type:"button",className:"config-close","aria-label":"Close settings",onClick:e,children:"×"})]}),c.jsxs("div",{className:"config-body",children:[c.jsxs("label",{className:"config-field",children:[c.jsx("span",{className:"config-label",children:"Launch command"}),c.jsx("input",{className:"config-input",type:"text",placeholder:"claude",value:n,disabled:S,onChange:P=>r(P.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),c.jsx("span",{className:"config-hint",children:"Run in each new session's pane."})]}),c.jsxs("label",{className:"config-field",children:[c.jsx("span",{className:"config-label",children:"Default cwd"}),c.jsx("input",{className:"config-input",type:"text",value:s,disabled:S,onChange:P=>i(P.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),c.jsx("span",{className:"config-hint",children:"Existing dir new sessions start in."})]}),c.jsxs("label",{className:"config-field",children:[c.jsx("span",{className:"config-label",children:"Enhancer backend"}),c.jsxs("select",{className:"config-input",value:f,disabled:S,onChange:P=>d(P.target.value),children:[c.jsx("option",{value:"mlx",children:"Local MLX (→ claude → rules)"}),c.jsx("option",{value:"claude",children:"claude -p (→ rules)"}),c.jsx("option",{value:"rules",children:"Rules only (offline)"})]}),c.jsxs("span",{className:"config-hint",children:["Powers ✨. ",c.jsx("code",{children:"mlx"})," = on-device, no key."]})]}),c.jsxs("label",{className:"config-field",children:[c.jsx("span",{className:"config-label",children:"Claude model"}),c.jsxs("select",{className:"config-input",value:o,disabled:S,onChange:P=>a(P.target.value),children:[o&&!g?.claudeModels.some(P=>P.id===o)?c.jsxs("option",{value:o,children:[o,g?" (custom)":""]}):null,(g?.claudeModels??[]).map(P=>c.jsxs("option",{value:P.id,children:[P.label,P.id===g?.recommendedClaudeModel?" · recommended":""]},P.id))]}),c.jsxs("span",{className:"config-hint",children:["For the ",c.jsx("code",{children:"claude -p"})," backend/fallback."]})]}),c.jsxs("label",{className:"config-field config-field--wide",children:[c.jsx("span",{className:"config-label",children:"MLX model"}),c.jsxs("select",{className:"config-input",value:h,disabled:S||f!=="mlx",onChange:P=>p(P.target.value),children:[h&&!g?.mlxModels.some(P=>P.id===h)?c.jsxs("option",{value:h,children:[h,g?" (custom)":""]}):null,(g?.mlxModels??[]).map(P=>c.jsxs("option",{value:P.id,children:[P.label," · ",P.sizeGB," GB",P.installed?" · downloaded":" · ⬇ download",P.id===g?.recommendedMlxModel?" · recommended":"",g&&P.minRamGB>g.machine.ramGB?` (needs ≥${P.minRamGB} GB)`:""]},P.id))]}),c.jsx("span",{className:"config-hint",children:g?`Your ${g.machine.appleSilicon?"Apple Silicon ":""}Mac has ${g.machine.ramGB} GB — recommended: ${g.mlxModels.find(P=>P.id===g.recommendedMlxModel)?.label??g.recommendedMlxModel}. Auto-downloads on first use.`:"On-device model for the ✨ enhancer. Auto-downloads on first use."})]}),c.jsxs("label",{className:"config-field config-field--wide",children:[c.jsx("span",{className:"config-label",children:"Claude CLI path (optional)"}),c.jsx("input",{className:"config-input",type:"text",placeholder:"auto-detected",value:l,disabled:S,onChange:P=>u(P.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),c.jsxs("span",{className:"config-hint",children:["Path to the ",c.jsx("code",{children:"claude"})," binary. Blank = auto-detect."]})]}),c.jsxs("div",{className:"config-field config-field--wide",children:[c.jsx("span",{className:"config-label",children:"App icon"}),c.jsxs("div",{className:"config-icon-row",children:[c.jsx("img",{className:"config-icon-preview",src:`/api/icon?size=192&t=${k}`,alt:"Current home-screen icon",width:44,height:44}),c.jsxs("div",{className:"config-icon-actions",children:[c.jsx("button",{type:"button",className:"config-cancel",disabled:M,onClick:()=>_.current?.click(),children:M?"Working…":"Upload PNG"}),c.jsx("button",{type:"button",className:"config-cancel",disabled:M,onClick:N,children:"Reset"})]}),c.jsx("input",{ref:_,type:"file",accept:"image/png",hidden:!0,onChange:z})]}),c.jsx("span",{className:"config-hint",children:"Defaults to the Claude Control logo. Re-add to Home Screen after changing."})]})]}),c.jsxs("div",{className:"config-foot",children:[c.jsx("div",{className:"config-version",children:E?c.jsxs(c.Fragment,{children:[c.jsxs("span",{children:["claude-control v",E.current]}),E.updateAvailable&&E.latest?c.jsxs("span",{className:"config-version-update",children:["· update available: v",E.latest]}):null]}):null}),c.jsxs("div",{className:"config-actions",children:[c.jsx("button",{type:"button",className:"config-cancel",onClick:e,disabled:x,children:"Cancel"}),c.jsx("button",{type:"button",className:"config-save",onClick:K,disabled:S||x,children:x?"Saving…":"Save"})]})]})]})})}function Rm(e=Date.now()){return`session-${e.toString(36).slice(-6)}`}function U2({onToast:e,onOpenSettings:t}){const[n,r]=m.useState(!1),[s,i]=m.useState(""),[o,a]=m.useState(!1),[l,u]=m.useState(Rm),f=m.useRef(null);m.useEffect(()=>{n&&(u(Rm()),f.current?.focus())},[n]);const d=m.useCallback(()=>{r(!1),i("")},[]),h=m.useCallback(async()=>{if(o)return;a(!0);const p=s.trim()||l;e("Creating session…");try{const g=await cR({name:p});e(`Session created → ${g.name}`,"ok"),d()}catch(g){e(`New session failed: ${g.message}`,"error")}finally{a(!1)}},[o,s,l,e,d]);return n?c.jsxs("form",{className:"rail-new-form","aria-label":"Create session",onSubmit:p=>{p.preventDefault(),h()},children:[c.jsx("input",{ref:f,className:"rail-new-name",type:"text",value:s,placeholder:l,disabled:o,onChange:p=>i(p.target.value),onKeyDown:p=>{p.key==="Escape"&&(p.preventDefault(),d())},"aria-label":"Session name",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),c.jsxs("div",{className:"rail-new-actions",children:[c.jsx("button",{type:"button",className:"rail-new-cancel",onClick:d,disabled:o,children:"Cancel"}),c.jsx("button",{type:"submit",className:"rail-new-create",disabled:o,children:o?"Creating…":"Create"})]})]}):c.jsxs("div",{className:"rail-head",children:[c.jsx("button",{type:"button",className:"rail-new",onClick:()=>r(!0),children:"+ New session"}),c.jsx("button",{type:"button",className:"rail-gear","aria-label":"Settings",title:"Settings",onClick:t,children:"⚙"})]})}function V2(e){return e==="Escape"}function H2({sessionId:e,label:t,onClose:n}){const r=QI(e),s=m.useRef(null);m.useEffect(()=>{const o=a=>{V2(a.key)&&n()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n]);const i=()=>{s.current?.focus()};return m.useEffect(()=>{i()},[]),c.jsxs("div",{className:"term-overlay",role:"dialog","aria-modal":"true","aria-label":`Raw terminal — ${t}`,children:[c.jsxs("header",{className:"term-head",children:[c.jsxs("span",{className:"term-title",children:[c.jsx("span",{"aria-hidden":"true",children:"⛶"})," ",t]}),c.jsxs("span",{className:"term-actions",children:[c.jsx("a",{className:"term-newtab",href:r,target:"_blank",rel:"noopener noreferrer",title:"Open in a new tab",children:"↗ New tab"}),c.jsx("button",{type:"button",className:"term-close","aria-label":"Close terminal",onClick:n,children:"✕"})]})]}),c.jsx("iframe",{ref:s,className:"term-frame",src:r,title:`Raw terminal for ${t}`,onLoad:i})]})}function W2({children:e}){const[t,n]=m.useState("probing"),[r,s]=m.useState(null),[i,o]=m.useState(""),a=m.useCallback(async()=>{try{return(await Oe("/api/health")).ok?(n("authed"),s(null),!0):!1}catch{return s("Cannot reach the server. Check the connection and retry."),!1}},[]);m.useEffect(()=>{let u=!1;return(async()=>{const f=await a();u||f||n("needs-token")})(),()=>{u=!0}},[a]),m.useEffect(()=>KI(()=>{n("needs-token"),o(""),s("Session expired — enter your access token again.")}),[]);const l=m.useCallback(async u=>{u.preventDefault();const f=i.trim();if(!f){s("Enter an access token.");return}n("submitting"),s(null),gw(f),await a()||(yw(),n("needs-token"),s("Invalid token."))},[i,a]);return t==="authed"?c.jsx(c.Fragment,{children:e}):t==="probing"?c.jsx("div",{className:"gate-root",role:"status","aria-live":"polite",children:c.jsxs("div",{className:"gate-card gate-card--probing",children:[c.jsx("span",{className:"gate-spinner","aria-hidden":"true"}),c.jsx("span",{className:"gate-probing-text",children:"Connecting…"})]})}):(Ua(),c.jsx("div",{className:"gate-root",children:c.jsxs("form",{className:"gate-card",onSubmit:l,"aria-label":"Sign in",children:[c.jsxs("div",{className:"gate-brand",children:[c.jsx("span",{className:"gate-glyph","aria-hidden":"true",children:"◧"}),c.jsx("span",{className:"gate-title",children:"claude control"})]}),c.jsx("label",{className:"gate-label",htmlFor:"gate-token",children:"Access token"}),c.jsx("input",{id:"gate-token",className:"gate-input",type:"password",autoComplete:"current-password",autoFocus:!0,spellCheck:!1,value:i,onChange:u=>{o(u.target.value),r&&s(null)},"aria-invalid":r?!0:void 0,"aria-describedby":r?"gate-error":void 0,placeholder:"••••••••••••"}),r?c.jsx("p",{id:"gate-error",className:"gate-error",role:"alert",children:r}):null,c.jsx("button",{type:"submit",className:"gate-submit",disabled:t==="submitting",children:t==="submitting"?"Connecting…":"Connect"}),c.jsxs("p",{className:"gate-hint",children:["Find your token in ",c.jsx("code",{children:"~/.claude-control/token"})," on the server, or wherever ",c.jsx("code",{children:"CLAUDE_CONTROL_TOKEN"})," is set. It's also printed when the server starts."]})]})}))}function q2(e){if(!e)return"";const t=Date.parse(e);return Number.isNaN(t)?"":new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function K2({session:e,onClose:t,onToast:n,onPinned:r}){const[s,i]=m.useState(null),[o,a]=m.useState(""),[l,u]=m.useState(!1);m.useEffect(()=>{let h=!0;return XI().then(p=>h&&i(p)).catch(p=>{h&&(i([]),n(`Couldn't load transcripts: ${p.message}`,"error"))}),()=>{h=!1}},[n]);const f=m.useMemo(()=>{if(!s)return[];const h=o.trim().toLowerCase();return h?s.filter(p=>[p.title,p.cwd,p.sessionId].some(g=>g?.toLowerCase().includes(h))):s},[s,o]),d=async h=>{if(!l){u(!0);try{await JI(e.id,h),n(h?"Pinned →":"Unpinned","ok"),r(),t()}catch(p){n(`Pin failed: ${p.message}`,"error")}finally{u(!1)}}};return c.jsx("div",{className:"modal-backdrop",role:"dialog","aria-modal":"true",onClick:t,children:c.jsxs("div",{className:"modal pin-modal",onClick:h=>h.stopPropagation(),children:[c.jsxs("header",{className:"modal-head",children:[c.jsxs("span",{className:"modal-title",children:["Pin transcript — ",e.name||e.id]}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Close",onClick:t,children:"×"})]}),e.pinned?c.jsx("button",{type:"button",className:"pin-unpin",disabled:l,onClick:()=>d(null),children:"Unpin (return to auto-match)"}):null,c.jsx("input",{className:"pin-search",type:"text",placeholder:"filter by title, cwd, or session id…",value:o,onChange:h=>a(h.target.value),autoFocus:!0}),c.jsx("div",{className:"pin-list",children:s===null?c.jsx("div",{className:"pin-empty",children:"loading…"}):f.length===0?c.jsx("div",{className:"pin-empty",children:"no transcripts match"}):f.map(h=>{const p=h.transcriptPath===e.transcriptPath;return c.jsxs("button",{type:"button",className:"pin-row","data-current":p?"true":void 0,disabled:l,onClick:()=>d(h.transcriptPath),children:[c.jsxs("span",{className:"pin-row-title",children:[h.title||h.sessionId||h.transcriptPath,p?c.jsx("span",{className:"pin-row-cur",children:" · current"}):null]}),c.jsxs("span",{className:"pin-row-meta",children:[h.cwd?c.jsx("span",{className:"pin-row-cwd",children:h.cwd}):null,c.jsx("span",{className:"pin-row-when",children:q2(h.lastActivity)})]})]},h.transcriptPath)})})]})})}const G2={UserMessage:Qa,AssistantMessage:Wn,SystemMessage:Wn};function Q2({markdown:e}){const t=m.useMemo(()=>[{role:"assistant",id:"plan",content:[{type:"text",text:e}],metadata:{custom:{cockpitRole:"assistant"}}}],[e]),n=Fa({messages:t,isDisabled:!0,convertMessage:r=>r,onNew:async()=>{}});return c.jsx(Ba,{runtime:n,children:c.jsx(dt.Root,{className:"plan-review",children:c.jsx(dt.Viewport,{className:"plan-review-viewport",children:c.jsx(dt.Messages,{components:G2})})})})}function Y2({prompt:e,onKey:t,onClose:n,planMarkdown:r}){const s=m.useMemo(()=>e.options.find(v=>v.selected)?.key??e.options[0]?.key??null,[e]),[i,o]=m.useState(s),[a,l]=m.useState(null),u=JSON.stringify(e);m.useEffect(()=>{o(s),l(null)},[u,s]);const f=g=>{a||(l(g),t(g))},d=()=>{i&&f(i)};m.useEffect(()=>{const g=v=>{if(!a){if(v.key==="Escape"){v.preventDefault(),n();return}if(v.key==="Enter"){v.preventDefault(),i&&f(i);return}e.options.some(S=>S.key===v.key)&&(v.preventDefault(),o(v.key))}};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[n,a,i,u]);const h=a!==null,p=!!r;return c.jsx("div",{className:"modal-backdrop",onClick:g=>{g.target===g.currentTarget&&!h&&n()},children:c.jsxs("div",{className:p?"modal modal-plan":"modal",role:"dialog","aria-modal":"true","aria-label":p?"Review plan":"Terminal prompt",children:[c.jsxs("div",{className:"modal-head",children:[c.jsx("span",{className:"modal-title",children:p?"Review plan":"Claude needs a choice"}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Hide",onClick:n,children:"✕"})]}),c.jsxs("div",{className:"modal-body",children:[p?c.jsx(Q2,{markdown:r}):null,c.jsxs("div",{className:"question",children:[p?null:c.jsx("div",{className:"q-text",children:e.question}),c.jsx("div",{className:"q-options",role:"radiogroup","aria-label":"Options",children:e.options.map(g=>c.jsxs("button",{type:"button",className:"option-btn",role:"radio","aria-checked":i===g.key,"data-on":i===g.key?"true":"false","data-sending":a===g.key?"true":void 0,disabled:h,onClick:()=>o(g.key),children:[c.jsxs("span",{className:"option-label",children:[g.key,". ",g.label]}),a===g.key?c.jsxs("span",{className:"option-sending","aria-live":"polite",children:[c.jsx("span",{className:"working-spinner","aria-hidden":"true"})," sending…"]}):null]},g.key))})]})]}),c.jsxs("div",{className:"modal-foot",children:[c.jsxs("button",{type:"button",className:"btn-secondary",disabled:h,onClick:()=>f("Escape"),children:["Cancel ",c.jsx(Rn,{children:"Esc"})]}),c.jsx("span",{className:"modal-foot-spacer"}),h?c.jsx("span",{className:"prompt-status",children:"submitting your answer…"}):null,c.jsxs("button",{type:"button",className:"btn-primary",disabled:h||!i,onClick:d,children:["Confirm ",c.jsx(Rn,{children:"↵"})]})]})]})})}const J2={UserMessage:Qa,AssistantMessage:Wn,SystemMessage:Wn};function X2({messages:e}){const t=m.useMemo(()=>Sw(e),[e]),n=Fa({messages:t,isDisabled:!0,convertMessage:r=>r,onNew:async()=>{}});return c.jsx(Ba,{runtime:n,children:c.jsx(dt.Root,{className:"sa-thread-root",children:c.jsxs(dt.Viewport,{className:"sa-thread-viewport",autoScroll:!0,children:[c.jsx(dt.Empty,{children:c.jsx("div",{className:"thread-empty",children:"no output yet…"})}),c.jsx(dt.Messages,{components:J2})]})})})}const Z2={active:"Active",completed:"Completed",all:"All"};function Qb(e){return e.model?e.model:e.def?.model?e.def.model:null}function sf({agentType:e,model:t}){return c.jsxs("span",{className:"agent-chip",children:[c.jsx("span",{className:"agent-chip-name",children:e||"sub-agent"}),t?c.jsx("span",{className:"agent-chip-model",children:t}):null]})}function ez({def:e,agentType:t}){if(!e)return c.jsx("div",{className:"agent-def",children:c.jsx("span",{className:"agent-def-no-def",children:t||"sub-agent"})});const n=new Set(["name","description","tools","model"]),r=Object.keys(e).filter(s=>!n.has(s));return c.jsxs("div",{className:"agent-def",children:[e.description?c.jsx("div",{className:"agent-def-row agent-def-desc",children:e.description}):null,e.tools?c.jsxs("div",{className:"agent-def-row",children:[c.jsx("span",{className:"agent-def-label",children:"tools"}),c.jsx("span",{className:"agent-def-val agent-def-tools",children:e.tools})]}):null,e.model?c.jsxs("div",{className:"agent-def-row",children:[c.jsx("span",{className:"agent-def-label",children:"model"}),c.jsx("span",{className:"agent-def-val",children:e.model})]}):null,r.map(s=>c.jsxs("div",{className:"agent-def-row",children:[c.jsx("span",{className:"agent-def-label",children:s}),c.jsx("span",{className:"agent-def-val",children:e[s]})]},s))]})}function tz({nested:e}){return!e||e.length===0?null:c.jsxs("div",{className:"agent-nested",children:[c.jsxs("span",{className:"agent-nested-label",children:["nested (",e.length,")"]}),c.jsx("div",{className:"agent-nested-list",children:e.map(t=>c.jsx(sf,{agentType:t.agentType,model:t.model},t.agentId))})]})}function nz({agent:e}){const t=Qb(e);return c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"sa-dot","data-status":e.status,"aria-hidden":"true"}),c.jsx(sf,{agentType:e.agentType,model:t}),e.description?c.jsx("span",{className:"sa-desc",children:e.description}):null,c.jsx("span",{className:"sa-status",children:e.status==="running"?"· running":"· done"})]})}function rz({subagents:e,open:t,onClose:n}){const[r,s]=m.useState("active"),[i,o]=m.useState(null),a=e.filter(d=>d.status==="running").length,l={active:a,completed:e.length-a,all:e.length},u=i?e.find(d=>d.agentId===i)??null:null,f=m.useMemo(()=>e.filter(d=>r==="all"?!0:r==="active"?d.status==="running":d.status==="done"),[e,r]);if(!t)return null;if(u){const d=Qb(u);return c.jsxs("div",{className:"sa-panel",role:"complementary","aria-label":"Sub-agent transcript",children:[c.jsxs("header",{className:"sa-panel-head",children:[c.jsx("button",{type:"button",className:"sa-back","aria-label":"Back to list",onClick:()=>o(null),children:"‹"}),c.jsxs("span",{className:"sa-panel-title sa-detail-title",children:[c.jsx("span",{className:"sa-dot","data-status":u.status,"aria-hidden":"true"}),c.jsx(sf,{agentType:u.agentType,model:d}),c.jsx("span",{className:"sa-status",children:u.status==="running"?"· running":"· done"})]}),c.jsx("button",{type:"button",className:"sa-panel-close","aria-label":"Close",onClick:n,children:"×"})]}),c.jsx(ez,{def:u.def,agentType:u.agentType}),c.jsx(tz,{nested:u.nested}),c.jsx(X2,{messages:u.messages})]})}return c.jsxs("div",{className:"sa-panel",role:"complementary","aria-label":"Sub-agents",children:[c.jsxs("header",{className:"sa-panel-head",children:[c.jsxs("span",{className:"sa-panel-title",children:["Sub-agents ",c.jsx("span",{className:"sa-count",children:e.length}),a?c.jsxs("span",{className:"sa-count-running",children:[a," running"]}):null]}),c.jsx("button",{type:"button",className:"sa-panel-close","aria-label":"Close sub-agents panel",onClick:n,children:"×"})]}),c.jsx("div",{className:"sa-tabs",role:"tablist",children:["active","completed","all"].map(d=>c.jsxs("button",{type:"button",role:"tab","aria-selected":r===d,className:"sa-tab","data-on":r===d?"true":void 0,onClick:()=>s(d),children:[Z2[d],c.jsx("span",{className:"sa-tab-count",children:l[d]})]},d))}),c.jsx("div",{className:"sa-panel-body",children:f.length===0?c.jsxs("div",{className:"sa-empty",children:["No ",r==="all"?"":`${r} `,"sub-agents."]}):f.map(d=>c.jsxs("button",{type:"button",className:"sa-item-row",onClick:()=>o(d.agentId),children:[c.jsx(nz,{agent:d}),c.jsx("span",{className:"sa-chevron","aria-hidden":"true",children:"›"})]},d.agentId))})]})}function sz(e){return(e.blocks??[]).filter(t=>t.kind==="text").map(t=>t.text).join(" ")}const iz=18e5,Yb="cc_drafts";function oz(){try{return JSON.parse(localStorage.getItem(Yb)||"{}")||{}}catch{return{}}}function az(e){try{localStorage.setItem(Yb,JSON.stringify(e))}catch{}}const Pm=150,lz=150;function uz(e){return typeof e.content=="string"?e.content:e.content.filter(t=>t.type==="text").map(t=>t.text).join(`
|
|
89
|
+
`)}function cz(){const e=vR(),t=bR(),[n,r]=m.useState(null),s=m.useRef(0),i=m.useCallback((q,ne="")=>{r({id:++s.current,text:q,kind:ne})},[]);m.useEffect(()=>{const q=ne=>{const oe=ne.detail;oe.ok?oe.op==="answer"&&i("Answer sent →","ok"):i(`${oe.op} failed: ${oe.error??"error"}`,"error")};return window.addEventListener("cockpit:ack",q),()=>window.removeEventListener("cockpit:ack",q)},[i]);const o=m.useMemo(()=>OR(i),[i]),a=m.useMemo(()=>({output:e.shellOutput,run:e.sendShellInput,text:e.sendShellText,key:e.sendShellKey,poll:e.requestShellCapture,clear:e.clearShellOutput}),[e.shellOutput,e.sendShellInput,e.sendShellText,e.sendShellKey,e.requestShellCapture,e.clearShellOutput]),[l,u]=m.useState([]),f=m.useRef(0),[d,h]=m.useState(null),p=m.useCallback(async q=>{const ne=uz(q).trim(),oe=(q.attachments??[]).map(ot=>DR(ot)).filter(ot=>!!ot),Me=[ne,...oe].filter(Boolean).join(" ");if(!Me)return;const on=e.sendReply(Me);if(i(on?"Sent →":"Not connected — reconnecting…",on?"ok":"error"),on&&e.selectedId){const ot=ne||(oe.length?`📎 ${oe.length} attachment(s)`:Me);u(qt=>[...qt,{key:++f.current,sessionId:e.selectedId,text:Me,label:ot,at:Date.now()}])}},[e,i]),g=m.useRef({});m.useEffect(()=>{const q=e.selectedId;if(!q)return;const ne=e.messages,oe=g.current[q],Me=oe==null?ne.length:Math.min(oe,ne.length);if(ne.length>Me){const on=[];for(let ot=Me;ot<ne.length;ot++){if(ne[ot].role!=="user")continue;const qt=sz(ne[ot]).trim();qt&&on.push(qt)}on.length&&u(ot=>{const qt=[...ot];for(const Ja of on){const j=qt.findIndex(H=>H.sessionId===q&&H.text.trim()===Ja);j>=0&&qt.splice(j,1)}return qt})}g.current[q]=ne.length},[e.selectedId,e.messages]),m.useEffect(()=>{if(l.length===0)return;const q=setInterval(()=>{const ne=Date.now()-iz;u(oe=>oe.some(Me=>Me.at<ne)?oe.filter(Me=>Me.at>=ne):oe)},5e3);return()=>clearInterval(q)},[l.length]),m.useEffect(()=>{if(!d)return;if(e.selectedId!==d.sessionId||e.messages.length>d.baseCount){h(null);return}const q=setTimeout(()=>h(null),9e4);return()=>clearTimeout(q)},[d,e.selectedId,e.messages.length]);const[v,S]=m.useState(Pm);m.useEffect(()=>{S(Pm)},[e.selectedId]);const y=m.useMemo(()=>Sw(e.messages),[e.messages]),x=Math.max(0,y.length-v),w=m.useMemo(()=>l.filter(q=>q.sessionId===e.selectedId),[l,e.selectedId]),E=m.useMemo(()=>{if(!e.prompt)return null;const q=e.messages;for(let ne=q.length-1;ne>=0;ne--)for(const oe of q[ne].blocks??[])if(oe.kind==="tool_use"&&oe.name==="ExitPlanMode"){const Me=oe.input?.plan;if(typeof Me=="string"&&Me.trim())return Me}return null},[e.prompt,e.messages]),I=m.useMemo(()=>{const q=x>0?y.slice(x):y.slice();for(const oe of w)q.push({role:"user",id:`queued-${oe.key}`,content:[{type:"text",text:oe.label}],metadata:{custom:{cockpitRole:"user",optimistic:!0}}});return(w.length>0||d!==null&&d.sessionId===e.selectedId)&&q.push({role:"assistant",id:"optimistic-working",content:[{type:"text",text:"Working…"}],metadata:{custom:{cockpitRole:"assistant",working:!0}}}),q},[y,x,e.selectedId,w,d]),k=m.useCallback(()=>{S(q=>q+lz)},[]),R=Fa({messages:I,isDisabled:!e.selectedId,convertMessage:q=>q,onNew:p,adapters:{attachments:o}}),M=m.useRef(oz()),L=m.useRef(e.selectedId);m.useEffect(()=>{const q=R.thread.composer,ne=()=>{const oe=L.current;if(!oe)return;const Me=q.getState().text??"";Me?M.current[oe]=Me:delete M.current[oe],az(M.current)};return q.subscribe(ne)},[R]),m.useEffect(()=>{const q=R.thread.composer,ne=e.selectedId,oe=ne?M.current[ne]??"":"";L.current=ne;try{q.reset(),oe&&q.setText(oe)}catch{}},[e.selectedId,R]);const[_,z]=m.useState(null),[N,K]=m.useState(!1),[P,B]=m.useState(null),[ee,ae]=m.useState(!1),[F,D]=m.useState(!1),[b,J]=m.useState(null);m.useEffect(()=>{ae(!1),D(!1)},[e.selectedId]);const[Y,C]=m.useState(null),ge=m.useRef(null),A=Y!==null;m.useEffect(()=>{A&&ge.current?.select()},[A]);const O=m.useCallback(async()=>{const q=e.selectedId,ne=(Y??"").trim();if(C(null),!(!q||!ne))try{await dR(q,ne),i("Renamed →","ok")}catch(oe){i(`rename failed: ${oe instanceof Error?oe.message:"error"}`,"error")}},[e.selectedId,Y,i]),[W,Q]=m.useState(!0),X=m.useCallback(q=>{e.select(q),Q(!1),window.location.hash=encodeURIComponent(q)},[e]);m.useEffect(()=>{if(!("serviceWorker"in navigator))return;const q=ne=>{const oe=ne.data;oe?.type==="open-session"&&oe.id&&X(oe.id)};return navigator.serviceWorker.addEventListener("message",q),()=>navigator.serviceWorker.removeEventListener("message",q)},[X]);const pe=typeof window<"u"&&(window.matchMedia?.("(display-mode: standalone)").matches||navigator.standalone===!0),_e=t.iosHint&&!pe&&t.status!=="on",ze=m.useRef(!1);m.useEffect(()=>{const q=()=>{const ne=decodeURIComponent(window.location.hash.replace(/^#/,""));ne&&ne!==e.selectedId&&e.sessions.some(oe=>oe.id===ne)&&(e.select(ne),Q(!1))};return!ze.current&&e.sessions.length>0&&(ze.current=!0,q()),window.addEventListener("hashchange",q),()=>window.removeEventListener("hashchange",q)},[e,e.sessions,e.selectedId]);const Pe=e.sessions.find(q=>q.id===e.selectedId),Ya=Pe?.thinking&&y.length>0?y[y.length-1].id??null:null,xs=m.useRef(null),{pull:_r,refreshing:Er}=_R(xs);return c.jsx(Ba,{runtime:R,children:c.jsx(hO,{children:c.jsxs("div",{ref:xs,className:"app","data-detail":e.selectedId&&!W?"open":"closed",children:[_r>0||Er?c.jsx("div",{className:"ptr-indicator",style:{transform:`translate(-50%, ${Math.round(_r)}px)`},"data-ready":!Er&&_r>=ER?"true":void 0,"data-refreshing":Er?"true":void 0,"aria-hidden":"true",children:c.jsx("span",{className:"ptr-spinner"})}):null,c.jsx("button",{type:"button",className:"reload-btn","aria-label":"Reload app",title:"Reload app",onClick:()=>window.location.reload(),children:"↻"}),c.jsx("div",{className:"app-top-fade","aria-hidden":"true"}),c.jsx(WR,{resources:e.resources,conn:e.conn,push:t}),c.jsx(B2,{}),_e?c.jsx("div",{className:"ios-push-hint",role:"note",children:"On iPhone/iPad, add this site to your Home Screen to receive push notifications."}):null,c.jsxs("div",{className:"app-body",children:[c.jsxs("aside",{className:"rail",children:[c.jsx(U2,{onToast:i,onOpenSettings:()=>K(!0)}),c.jsx($R,{sessions:e.sessions,selectedId:e.selectedId,onSelect:X})]}),c.jsxs("main",{className:"detail",children:[c.jsxs("header",{className:"detail-head",children:[c.jsx("button",{type:"button",className:"back-btn","aria-label":"Back to sessions",onClick:()=>Q(!0),children:"‹"}),c.jsxs("div",{className:"detail-title",children:[Y!==null?c.jsx("input",{ref:ge,className:"detail-rename-input",type:"text",value:Y,"aria-label":"Session name",onChange:q=>C(q.target.value),onKeyDown:q=>{q.key==="Enter"?(q.preventDefault(),O()):q.key==="Escape"&&(q.preventDefault(),C(null))},onBlur:()=>void O()}):c.jsxs("span",{className:"detail-name-row",children:[c.jsx("span",{className:"detail-name",children:Pe?.name||e.selectedId||"claude control"}),Pe?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"rename-btn","aria-label":"Rename session",title:"Rename session",onClick:()=>C(Pe.name??Pe.id),children:"✎"}),c.jsx("button",{type:"button",className:"rename-btn term-btn","aria-label":"Open raw terminal",title:"Raw terminal",onClick:()=>B(Pe.id),children:"⛶"}),c.jsx("button",{type:"button",className:"rename-btn pin-btn","aria-pressed":!!Pe.pinned,"aria-label":Pe.pinned?"Transcript pinned":"Pin a transcript",title:Pe.pinned?"Transcript pinned":"Pin a transcript",onClick:()=>ae(!0),children:Pe.pinned?"📌":"📍"}),e.subagents.length>0?c.jsxs("button",{type:"button",className:"rename-btn agents-btn","aria-pressed":F,title:"Sub-agents",onClick:()=>D(q=>!q),children:["🤖 ",e.subagents.length]}):null]}):null]}),Pe?.cwd?c.jsx("span",{className:"detail-cwd",children:Pe.cwd}):null]})]}),c.jsx(Hb.Provider,{value:a,children:Pe&&Pe.kind==="terminal"?c.jsx(L2,{sessionId:Pe.id,capture:e.capture,requestCapture:e.requestCapture,clearCapture:e.clearCapture,sendText:e.sendPaneText,sendKey:e.sendPaneKey}):Pe&&!Pe.transcriptPath?c.jsxs("div",{className:"thread-root",children:[c.jsx("div",{className:"thread-fade","aria-hidden":"true"}),c.jsx(M2,{sessionId:Pe.id,capture:e.capture,requestCapture:e.requestCapture,clearCapture:e.clearCapture}),c.jsx(Gb,{disabled:!1,sessionId:e.selectedId})]}):c.jsxs("div",{className:"detail-split",children:[c.jsx(Fb.Provider,{value:Ya,children:c.jsx(E2,{hasSelection:!!e.selectedId,sessionId:e.selectedId,hiddenCount:x,onLoadEarlier:k})}),c.jsx(j2,{})]})})]})]}),e.pending&&e.pending.toolUseId!==_?c.jsx(O2,{pending:e.pending,capture:e.capture,onAnswer:(q,ne)=>{e.sendAnswer(q,ne),z(q),e.clearCapture(),e.selectedId&&h({sessionId:e.selectedId,baseCount:e.messages.length})},onCapture:e.requestCapture,onClose:()=>{z(e.pending?.toolUseId??null),e.clearCapture()}},e.pending.toolUseId):null,N?c.jsx($2,{onClose:()=>K(!1),onToast:i}):null,P?c.jsx(H2,{sessionId:P,label:e.sessions.find(q=>q.id===P)?.name??P,onClose:()=>B(null)},P):null,c.jsx(rz,{subagents:e.subagents,open:F&&e.subagents.length>0,onClose:()=>D(!1)}),ee&&Pe?c.jsx(K2,{session:Pe,onClose:()=>ae(!1),onToast:i,onPinned:()=>e.resubscribe()}):null,e.prompt&&!e.pending&&JSON.stringify(e.prompt)!==b?c.jsx(Y2,{prompt:e.prompt,planMarkdown:E,onKey:q=>e.sendPromptKey(q),onClose:()=>J(JSON.stringify(e.prompt))}):null,c.jsx(z2,{toast:n})]})})})}function dz(){return c.jsx(W2,{children:c.jsx(cz,{})})}const Jb=document.getElementById("root");if(!Jb)throw new Error("#root not found");Vy(Jb).render(c.jsx(m.StrictMode,{children:c.jsx(dz,{})}));export{Ei as g};
|