agentus 0.14.1 → 0.15.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.
@@ -0,0 +1,131 @@
1
+ (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function s(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(i){if(i.ep)return;i.ep=!0;const r=s(i);fetch(i.href,r)}})();function Qb(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ew={exports:{}},Gh={},tw={exports:{}},Xe={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Cc=Symbol.for("react.element"),IC=Symbol.for("react.portal"),PC=Symbol.for("react.fragment"),LC=Symbol.for("react.strict_mode"),OC=Symbol.for("react.profiler"),BC=Symbol.for("react.provider"),$C=Symbol.for("react.context"),FC=Symbol.for("react.forward_ref"),zC=Symbol.for("react.suspense"),HC=Symbol.for("react.memo"),UC=Symbol.for("react.lazy"),H_=Symbol.iterator;function WC(e){return e===null||typeof e!="object"?null:(e=H_&&e[H_]||e["@@iterator"],typeof e=="function"?e:null)}var sw={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},nw=Object.assign,iw={};function Na(e,t,s){this.props=e,this.context=t,this.refs=iw,this.updater=s||sw}Na.prototype.isReactComponent={};Na.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")};Na.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function rw(){}rw.prototype=Na.prototype;function og(e,t,s){this.props=e,this.context=t,this.refs=iw,this.updater=s||sw}var ag=og.prototype=new rw;ag.constructor=og;nw(ag,Na.prototype);ag.isPureReactComponent=!0;var U_=Array.isArray,ow=Object.prototype.hasOwnProperty,lg={current:null},aw={key:!0,ref:!0,__self:!0,__source:!0};function lw(e,t,s){var n,i={},r=null,a=null;if(t!=null)for(n in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(r=""+t.key),t)ow.call(t,n)&&!aw.hasOwnProperty(n)&&(i[n]=t[n]);var l=arguments.length-2;if(l===1)i.children=s;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];i.children=c}if(e&&e.defaultProps)for(n in l=e.defaultProps,l)i[n]===void 0&&(i[n]=l[n]);return{$$typeof:Cc,type:e,key:r,ref:a,props:i,_owner:lg.current}}function KC(e,t){return{$$typeof:Cc,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function cg(e){return typeof e=="object"&&e!==null&&e.$$typeof===Cc}function qC(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return t[s]})}var W_=/\/+/g;function Md(e,t){return typeof e=="object"&&e!==null&&e.key!=null?qC(""+e.key):t.toString(36)}function Au(e,t,s,n,i){var r=typeof e;(r==="undefined"||r==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(r){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case Cc:case IC:a=!0}}if(a)return a=e,i=i(a),e=n===""?"."+Md(a,0):n,U_(i)?(s="",e!=null&&(s=e.replace(W_,"$&/")+"/"),Au(i,t,s,"",function(u){return u})):i!=null&&(cg(i)&&(i=KC(i,s+(!i.key||a&&a.key===i.key?"":(""+i.key).replace(W_,"$&/")+"/")+e)),t.push(i)),1;if(a=0,n=n===""?".":n+":",U_(e))for(var l=0;l<e.length;l++){r=e[l];var c=n+Md(r,l);a+=Au(r,t,s,c,i)}else if(c=WC(e),typeof c=="function")for(e=c.call(e),l=0;!(r=e.next()).done;)r=r.value,c=n+Md(r,l++),a+=Au(r,t,s,c,i);else if(r==="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 a}function qc(e,t,s){if(e==null)return e;var n=[],i=0;return Au(e,n,"","",function(r){return t.call(s,r,i++)}),n}function VC(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(s){(e._status===0||e._status===-1)&&(e._status=1,e._result=s)},function(s){(e._status===0||e._status===-1)&&(e._status=2,e._result=s)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Os={current:null},Mu={transition:null},YC={ReactCurrentDispatcher:Os,ReactCurrentBatchConfig:Mu,ReactCurrentOwner:lg};function cw(){throw Error("act(...) is not supported in production builds of React.")}Xe.Children={map:qc,forEach:function(e,t,s){qc(e,function(){t.apply(this,arguments)},s)},count:function(e){var t=0;return qc(e,function(){t++}),t},toArray:function(e){return qc(e,function(t){return t})||[]},only:function(e){if(!cg(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Xe.Component=Na;Xe.Fragment=PC;Xe.Profiler=OC;Xe.PureComponent=og;Xe.StrictMode=LC;Xe.Suspense=zC;Xe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=YC;Xe.act=cw;Xe.cloneElement=function(e,t,s){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var n=nw({},e.props),i=e.key,r=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(r=t.ref,a=lg.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)ow.call(t,c)&&!aw.hasOwnProperty(c)&&(n[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)n.children=s;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];n.children=l}return{$$typeof:Cc,type:e.type,key:i,ref:r,props:n,_owner:a}};Xe.createContext=function(e){return e={$$typeof:$C,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:BC,_context:e},e.Consumer=e};Xe.createElement=lw;Xe.createFactory=function(e){var t=lw.bind(null,e);return t.type=e,t};Xe.createRef=function(){return{current:null}};Xe.forwardRef=function(e){return{$$typeof:FC,render:e}};Xe.isValidElement=cg;Xe.lazy=function(e){return{$$typeof:UC,_payload:{_status:-1,_result:e},_init:VC}};Xe.memo=function(e,t){return{$$typeof:HC,type:e,compare:t===void 0?null:t}};Xe.startTransition=function(e){var t=Mu.transition;Mu.transition={};try{e()}finally{Mu.transition=t}};Xe.unstable_act=cw;Xe.useCallback=function(e,t){return Os.current.useCallback(e,t)};Xe.useContext=function(e){return Os.current.useContext(e)};Xe.useDebugValue=function(){};Xe.useDeferredValue=function(e){return Os.current.useDeferredValue(e)};Xe.useEffect=function(e,t){return Os.current.useEffect(e,t)};Xe.useId=function(){return Os.current.useId()};Xe.useImperativeHandle=function(e,t,s){return Os.current.useImperativeHandle(e,t,s)};Xe.useInsertionEffect=function(e,t){return Os.current.useInsertionEffect(e,t)};Xe.useLayoutEffect=function(e,t){return Os.current.useLayoutEffect(e,t)};Xe.useMemo=function(e,t){return Os.current.useMemo(e,t)};Xe.useReducer=function(e,t,s){return Os.current.useReducer(e,t,s)};Xe.useRef=function(e){return Os.current.useRef(e)};Xe.useState=function(e){return Os.current.useState(e)};Xe.useSyncExternalStore=function(e,t,s){return Os.current.useSyncExternalStore(e,t,s)};Xe.useTransition=function(){return Os.current.useTransition()};Xe.version="18.3.1";tw.exports=Xe;var g=tw.exports;const GC=Qb(g);/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var JC=g,XC=Symbol.for("react.element"),ZC=Symbol.for("react.fragment"),QC=Object.prototype.hasOwnProperty,eE=JC.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,tE={key:!0,ref:!0,__self:!0,__source:!0};function uw(e,t,s){var n,i={},r=null,a=null;s!==void 0&&(r=""+s),t.key!==void 0&&(r=""+t.key),t.ref!==void 0&&(a=t.ref);for(n in t)QC.call(t,n)&&!tE.hasOwnProperty(n)&&(i[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)i[n]===void 0&&(i[n]=t[n]);return{$$typeof:XC,type:e,key:r,ref:a,props:i,_owner:eE.current}}Gh.Fragment=ZC;Gh.jsx=uw;Gh.jsxs=uw;ew.exports=Gh;var o=ew.exports,hw={exports:{}},un={},dw={exports:{}},fw={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */(function(e){function t(T,O){var K=T.length;T.push(O);e:for(;0<K;){var U=K-1>>>1,re=T[U];if(0<i(re,O))T[U]=O,T[K]=re,K=U;else break e}}function s(T){return T.length===0?null:T[0]}function n(T){if(T.length===0)return null;var O=T[0],K=T.pop();if(K!==O){T[0]=K;e:for(var U=0,re=T.length,J=re>>>1;U<J;){var Y=2*(U+1)-1,_e=T[Y],xe=Y+1,fe=T[xe];if(0>i(_e,K))xe<re&&0>i(fe,_e)?(T[U]=fe,T[xe]=K,U=xe):(T[U]=_e,T[Y]=K,U=Y);else if(xe<re&&0>i(fe,K))T[U]=fe,T[xe]=K,U=xe;else break e}}return O}function i(T,O){var K=T.sortIndex-O.sortIndex;return K!==0?K:T.id-O.id}if(typeof performance=="object"&&typeof performance.now=="function"){var r=performance;e.unstable_now=function(){return r.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var c=[],u=[],h=1,d=null,p=3,f=!1,m=!1,b=!1,_=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(T){for(var O=s(u);O!==null;){if(O.callback===null)n(u);else if(O.startTime<=T)n(u),O.sortIndex=O.expirationTime,t(c,O);else break;O=s(u)}}function x(T){if(b=!1,w(T),!m)if(s(c)!==null)m=!0,D(S);else{var O=s(u);O!==null&&z(x,O.startTime-T)}}function S(T,O){m=!1,b&&(b=!1,v(N),N=-1),f=!0;var K=p;try{for(w(O),d=s(c);d!==null&&(!(d.expirationTime>O)||T&&!B());){var U=d.callback;if(typeof U=="function"){d.callback=null,p=d.priorityLevel;var re=U(d.expirationTime<=O);O=e.unstable_now(),typeof re=="function"?d.callback=re:d===s(c)&&n(c),w(O)}else n(c);d=s(c)}if(d!==null)var J=!0;else{var Y=s(u);Y!==null&&z(x,Y.startTime-O),J=!1}return J}finally{d=null,p=K,f=!1}}var E=!1,R=null,N=-1,I=5,F=-1;function B(){return!(e.unstable_now()-F<I)}function C(){if(R!==null){var T=e.unstable_now();F=T;var O=!0;try{O=R(!0,T)}finally{O?A():(E=!1,R=null)}}else E=!1}var A;if(typeof y=="function")A=function(){y(C)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,H=M.port2;M.port1.onmessage=C,A=function(){H.postMessage(null)}}else A=function(){_(C,0)};function D(T){R=T,E||(E=!0,A())}function z(T,O){N=_(function(){T(e.unstable_now())},O)}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(T){T.callback=null},e.unstable_continueExecution=function(){m||f||(m=!0,D(S))},e.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<T?Math.floor(1e3/T):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return s(c)},e.unstable_next=function(T){switch(p){case 1:case 2:case 3:var O=3;break;default:O=p}var K=p;p=O;try{return T()}finally{p=K}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(T,O){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var K=p;p=T;try{return O()}finally{p=K}},e.unstable_scheduleCallback=function(T,O,K){var U=e.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?U+K:U):K=U,T){case 1:var re=-1;break;case 2:re=250;break;case 5:re=1073741823;break;case 4:re=1e4;break;default:re=5e3}return re=K+re,T={id:h++,callback:O,priorityLevel:T,startTime:K,expirationTime:re,sortIndex:-1},K>U?(T.sortIndex=K,t(u,T),s(c)===null&&T===s(u)&&(b?(v(N),N=-1):b=!0,z(x,K-U))):(T.sortIndex=re,t(c,T),m||f||(m=!0,D(S))),T},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(T){var O=p;return function(){var K=p;p=O;try{return T.apply(this,arguments)}finally{p=K}}}})(fw);dw.exports=fw;var sE=dw.exports;/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var nE=g,cn=sE;function ie(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,s=1;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s]);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 pw=new Set,ql={};function po(e,t){da(e,t),da(e+"Capture",t)}function da(e,t){for(ql[e]=t,e=0;e<t.length;e++)pw.add(t[e])}var Ai=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Zf=Object.prototype.hasOwnProperty,iE=/^[: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]*$/,K_={},q_={};function rE(e){return Zf.call(q_,e)?!0:Zf.call(K_,e)?!1:iE.test(e)?q_[e]=!0:(K_[e]=!0,!1)}function oE(e,t,s,n){if(s!==null&&s.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return n?!1:s!==null?!s.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function aE(e,t,s,n){if(t===null||typeof t>"u"||oE(e,t,s,n))return!0;if(n)return!1;if(s!==null)switch(s.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 Bs(e,t,s,n,i,r,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=n,this.attributeNamespace=i,this.mustUseProperty=s,this.propertyName=e,this.type=t,this.sanitizeURL=r,this.removeEmptyString=a}var bs={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){bs[e]=new Bs(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];bs[t]=new Bs(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){bs[e]=new Bs(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){bs[e]=new Bs(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){bs[e]=new Bs(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){bs[e]=new Bs(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){bs[e]=new Bs(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){bs[e]=new Bs(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){bs[e]=new Bs(e,5,!1,e.toLowerCase(),null,!1,!1)});var ug=/[\-:]([a-z])/g;function hg(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(ug,hg);bs[t]=new Bs(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(ug,hg);bs[t]=new Bs(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(ug,hg);bs[t]=new Bs(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){bs[e]=new Bs(e,1,!1,e.toLowerCase(),null,!1,!1)});bs.xlinkHref=new Bs("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){bs[e]=new Bs(e,1,!1,e.toLowerCase(),null,!0,!0)});function dg(e,t,s,n){var i=bs.hasOwnProperty(t)?bs[t]:null;(i!==null?i.type!==0:n||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(aE(t,s,i,n)&&(s=null),n||i===null?rE(t)&&(s===null?e.removeAttribute(t):e.setAttribute(t,""+s)):i.mustUseProperty?e[i.propertyName]=s===null?i.type===3?!1:"":s:(t=i.attributeName,n=i.attributeNamespace,s===null?e.removeAttribute(t):(i=i.type,s=i===3||i===4&&s===!0?"":""+s,n?e.setAttributeNS(n,t,s):e.setAttribute(t,s))))}var Pi=nE.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Vc=Symbol.for("react.element"),Uo=Symbol.for("react.portal"),Wo=Symbol.for("react.fragment"),fg=Symbol.for("react.strict_mode"),Qf=Symbol.for("react.profiler"),mw=Symbol.for("react.provider"),gw=Symbol.for("react.context"),pg=Symbol.for("react.forward_ref"),ep=Symbol.for("react.suspense"),tp=Symbol.for("react.suspense_list"),mg=Symbol.for("react.memo"),Zi=Symbol.for("react.lazy"),_w=Symbol.for("react.offscreen"),V_=Symbol.iterator;function Wa(e){return e===null||typeof e!="object"?null:(e=V_&&e[V_]||e["@@iterator"],typeof e=="function"?e:null)}var Mt=Object.assign,Dd;function bl(e){if(Dd===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);Dd=t&&t[1]||""}return`
34
+ `+Dd+e}var Id=!1;function Pd(e,t){if(!e||Id)return"";Id=!0;var s=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 n=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){n=u}e.call(t.prototype)}else{try{throw Error()}catch(u){n=u}e()}}catch(u){if(u&&n&&typeof u.stack=="string"){for(var i=u.stack.split(`
35
+ `),r=n.stack.split(`
36
+ `),a=i.length-1,l=r.length-1;1<=a&&0<=l&&i[a]!==r[l];)l--;for(;1<=a&&0<=l;a--,l--)if(i[a]!==r[l]){if(a!==1||l!==1)do if(a--,l--,0>l||i[a]!==r[l]){var c=`
37
+ `+i[a].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=a&&0<=l);break}}}finally{Id=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?bl(e):""}function lE(e){switch(e.tag){case 5:return bl(e.type);case 16:return bl("Lazy");case 13:return bl("Suspense");case 19:return bl("SuspenseList");case 0:case 2:case 15:return e=Pd(e.type,!1),e;case 11:return e=Pd(e.type.render,!1),e;case 1:return e=Pd(e.type,!0),e;default:return""}}function sp(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 Wo:return"Fragment";case Uo:return"Portal";case Qf:return"Profiler";case fg:return"StrictMode";case ep:return"Suspense";case tp:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case gw:return(e.displayName||"Context")+".Consumer";case mw:return(e._context.displayName||"Context")+".Provider";case pg:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case mg:return t=e.displayName||null,t!==null?t:sp(e.type)||"Memo";case Zi:t=e._payload,e=e._init;try{return sp(e(t))}catch{}}return null}function cE(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 sp(t);case 8:return t===fg?"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 br(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function vw(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function uE(e){var t=vw(e)?"checked":"value",s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),n=""+e[t];if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var i=s.get,r=s.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(a){n=""+a,r.call(this,a)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return n},setValue:function(a){n=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Yc(e){e._valueTracker||(e._valueTracker=uE(e))}function yw(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),n="";return e&&(n=vw(e)?e.checked?"true":"false":e.value),e=n,e!==s?(t.setValue(e),!0):!1}function Zu(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 np(e,t){var s=t.checked;return Mt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function Y_(e,t){var s=t.defaultValue==null?"":t.defaultValue,n=t.checked!=null?t.checked:t.defaultChecked;s=br(t.value!=null?t.value:s),e._wrapperState={initialChecked:n,initialValue:s,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function bw(e,t){t=t.checked,t!=null&&dg(e,"checked",t,!1)}function ip(e,t){bw(e,t);var s=br(t.value),n=t.type;if(s!=null)n==="number"?(s===0&&e.value===""||e.value!=s)&&(e.value=""+s):e.value!==""+s&&(e.value=""+s);else if(n==="submit"||n==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?rp(e,t.type,s):t.hasOwnProperty("defaultValue")&&rp(e,t.type,br(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function G_(e,t,s){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var n=t.type;if(!(n!=="submit"&&n!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,s||t===e.value||(e.value=t),e.defaultValue=t}s=e.name,s!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,s!==""&&(e.name=s)}function rp(e,t,s){(t!=="number"||Zu(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var wl=Array.isArray;function na(e,t,s,n){if(e=e.options,t){t={};for(var i=0;i<s.length;i++)t["$"+s[i]]=!0;for(s=0;s<e.length;s++)i=t.hasOwnProperty("$"+e[s].value),e[s].selected!==i&&(e[s].selected=i),i&&n&&(e[s].defaultSelected=!0)}else{for(s=""+br(s),t=null,i=0;i<e.length;i++){if(e[i].value===s){e[i].selected=!0,n&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function op(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(ie(91));return Mt({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function J_(e,t){var s=t.value;if(s==null){if(s=t.children,t=t.defaultValue,s!=null){if(t!=null)throw Error(ie(92));if(wl(s)){if(1<s.length)throw Error(ie(93));s=s[0]}t=s}t==null&&(t=""),s=t}e._wrapperState={initialValue:br(s)}}function ww(e,t){var s=br(t.value),n=br(t.defaultValue);s!=null&&(s=""+s,s!==e.value&&(e.value=s),t.defaultValue==null&&e.defaultValue!==s&&(e.defaultValue=s)),n!=null&&(e.defaultValue=""+n)}function X_(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function xw(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 ap(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?xw(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Gc,Sw=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,s,n,i){MSApp.execUnsafeLocalFunction(function(){return e(t,s,n,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Gc=Gc||document.createElement("div"),Gc.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Gc.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Vl(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var Al={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},hE=["Webkit","ms","Moz","O"];Object.keys(Al).forEach(function(e){hE.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Al[t]=Al[e]})});function kw(e,t,s){return t==null||typeof t=="boolean"||t===""?"":s||typeof t!="number"||t===0||Al.hasOwnProperty(e)&&Al[e]?(""+t).trim():t+"px"}function Cw(e,t){e=e.style;for(var s in t)if(t.hasOwnProperty(s)){var n=s.indexOf("--")===0,i=kw(s,t[s],n);s==="float"&&(s="cssFloat"),n?e.setProperty(s,i):e[s]=i}}var dE=Mt({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 lp(e,t){if(t){if(dE[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(ie(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(ie(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(ie(61))}if(t.style!=null&&typeof t.style!="object")throw Error(ie(62))}}function cp(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 up=null;function gg(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var hp=null,ia=null,ra=null;function Z_(e){if(e=Rc(e)){if(typeof hp!="function")throw Error(ie(280));var t=e.stateNode;t&&(t=ed(t),hp(e.stateNode,e.type,t))}}function Ew(e){ia?ra?ra.push(e):ra=[e]:ia=e}function Nw(){if(ia){var e=ia,t=ra;if(ra=ia=null,Z_(e),t)for(e=0;e<t.length;e++)Z_(t[e])}}function Rw(e,t){return e(t)}function jw(){}var Ld=!1;function Tw(e,t,s){if(Ld)return e(t,s);Ld=!0;try{return Rw(e,t,s)}finally{Ld=!1,(ia!==null||ra!==null)&&(jw(),Nw())}}function Yl(e,t){var s=e.stateNode;if(s===null)return null;var n=ed(s);if(n===null)return null;s=n[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":(n=!n.disabled)||(e=e.type,n=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!n;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(ie(231,t,typeof s));return s}var dp=!1;if(Ai)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){dp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{dp=!1}function fE(e,t,s,n,i,r,a,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(s,u)}catch(h){this.onError(h)}}var Ml=!1,Qu=null,eh=!1,fp=null,pE={onError:function(e){Ml=!0,Qu=e}};function mE(e,t,s,n,i,r,a,l,c){Ml=!1,Qu=null,fE.apply(pE,arguments)}function gE(e,t,s,n,i,r,a,l,c){if(mE.apply(this,arguments),Ml){if(Ml){var u=Qu;Ml=!1,Qu=null}else throw Error(ie(198));eh||(eh=!0,fp=u)}}function mo(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function Aw(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 Q_(e){if(mo(e)!==e)throw Error(ie(188))}function _E(e){var t=e.alternate;if(!t){if(t=mo(e),t===null)throw Error(ie(188));return t!==e?null:e}for(var s=e,n=t;;){var i=s.return;if(i===null)break;var r=i.alternate;if(r===null){if(n=i.return,n!==null){s=n;continue}break}if(i.child===r.child){for(r=i.child;r;){if(r===s)return Q_(i),e;if(r===n)return Q_(i),t;r=r.sibling}throw Error(ie(188))}if(s.return!==n.return)s=i,n=r;else{for(var a=!1,l=i.child;l;){if(l===s){a=!0,s=i,n=r;break}if(l===n){a=!0,n=i,s=r;break}l=l.sibling}if(!a){for(l=r.child;l;){if(l===s){a=!0,s=r,n=i;break}if(l===n){a=!0,n=r,s=i;break}l=l.sibling}if(!a)throw Error(ie(189))}}if(s.alternate!==n)throw Error(ie(190))}if(s.tag!==3)throw Error(ie(188));return s.stateNode.current===s?e:t}function Mw(e){return e=_E(e),e!==null?Dw(e):null}function Dw(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Dw(e);if(t!==null)return t;e=e.sibling}return null}var Iw=cn.unstable_scheduleCallback,ev=cn.unstable_cancelCallback,vE=cn.unstable_shouldYield,yE=cn.unstable_requestPaint,zt=cn.unstable_now,bE=cn.unstable_getCurrentPriorityLevel,_g=cn.unstable_ImmediatePriority,Pw=cn.unstable_UserBlockingPriority,th=cn.unstable_NormalPriority,wE=cn.unstable_LowPriority,Lw=cn.unstable_IdlePriority,Jh=null,ri=null;function xE(e){if(ri&&typeof ri.onCommitFiberRoot=="function")try{ri.onCommitFiberRoot(Jh,e,void 0,(e.current.flags&128)===128)}catch{}}var $n=Math.clz32?Math.clz32:CE,SE=Math.log,kE=Math.LN2;function CE(e){return e>>>=0,e===0?32:31-(SE(e)/kE|0)|0}var Jc=64,Xc=4194304;function xl(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 sh(e,t){var s=e.pendingLanes;if(s===0)return 0;var n=0,i=e.suspendedLanes,r=e.pingedLanes,a=s&268435455;if(a!==0){var l=a&~i;l!==0?n=xl(l):(r&=a,r!==0&&(n=xl(r)))}else a=s&~i,a!==0?n=xl(a):r!==0&&(n=xl(r));if(n===0)return 0;if(t!==0&&t!==n&&!(t&i)&&(i=n&-n,r=t&-t,i>=r||i===16&&(r&4194240)!==0))return t;if(n&4&&(n|=s&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=n;0<t;)s=31-$n(t),i=1<<s,n|=e[s],t&=~i;return n}function EE(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 NE(e,t){for(var s=e.suspendedLanes,n=e.pingedLanes,i=e.expirationTimes,r=e.pendingLanes;0<r;){var a=31-$n(r),l=1<<a,c=i[a];c===-1?(!(l&s)||l&n)&&(i[a]=EE(l,t)):c<=t&&(e.expiredLanes|=l),r&=~l}}function pp(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Ow(){var e=Jc;return Jc<<=1,!(Jc&4194240)&&(Jc=64),e}function Od(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function Ec(e,t,s){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-$n(t),e[t]=s}function RE(e,t){var s=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 n=e.eventTimes;for(e=e.expirationTimes;0<s;){var i=31-$n(s),r=1<<i;t[i]=0,n[i]=-1,e[i]=-1,s&=~r}}function vg(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var n=31-$n(s),i=1<<n;i&t|e[n]&t&&(e[n]|=t),s&=~i}}var ct=0;function Bw(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var $w,yg,Fw,zw,Hw,mp=!1,Zc=[],hr=null,dr=null,fr=null,Gl=new Map,Jl=new Map,nr=[],jE="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 tv(e,t){switch(e){case"focusin":case"focusout":hr=null;break;case"dragenter":case"dragleave":dr=null;break;case"mouseover":case"mouseout":fr=null;break;case"pointerover":case"pointerout":Gl.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Jl.delete(t.pointerId)}}function qa(e,t,s,n,i,r){return e===null||e.nativeEvent!==r?(e={blockedOn:t,domEventName:s,eventSystemFlags:n,nativeEvent:r,targetContainers:[i]},t!==null&&(t=Rc(t),t!==null&&yg(t)),e):(e.eventSystemFlags|=n,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function TE(e,t,s,n,i){switch(t){case"focusin":return hr=qa(hr,e,t,s,n,i),!0;case"dragenter":return dr=qa(dr,e,t,s,n,i),!0;case"mouseover":return fr=qa(fr,e,t,s,n,i),!0;case"pointerover":var r=i.pointerId;return Gl.set(r,qa(Gl.get(r)||null,e,t,s,n,i)),!0;case"gotpointercapture":return r=i.pointerId,Jl.set(r,qa(Jl.get(r)||null,e,t,s,n,i)),!0}return!1}function Uw(e){var t=Wr(e.target);if(t!==null){var s=mo(t);if(s!==null){if(t=s.tag,t===13){if(t=Aw(s),t!==null){e.blockedOn=t,Hw(e.priority,function(){Fw(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Du(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=gp(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(s===null){s=e.nativeEvent;var n=new s.constructor(s.type,s);up=n,s.target.dispatchEvent(n),up=null}else return t=Rc(s),t!==null&&yg(t),e.blockedOn=s,!1;t.shift()}return!0}function sv(e,t,s){Du(e)&&s.delete(t)}function AE(){mp=!1,hr!==null&&Du(hr)&&(hr=null),dr!==null&&Du(dr)&&(dr=null),fr!==null&&Du(fr)&&(fr=null),Gl.forEach(sv),Jl.forEach(sv)}function Va(e,t){e.blockedOn===t&&(e.blockedOn=null,mp||(mp=!0,cn.unstable_scheduleCallback(cn.unstable_NormalPriority,AE)))}function Xl(e){function t(i){return Va(i,e)}if(0<Zc.length){Va(Zc[0],e);for(var s=1;s<Zc.length;s++){var n=Zc[s];n.blockedOn===e&&(n.blockedOn=null)}}for(hr!==null&&Va(hr,e),dr!==null&&Va(dr,e),fr!==null&&Va(fr,e),Gl.forEach(t),Jl.forEach(t),s=0;s<nr.length;s++)n=nr[s],n.blockedOn===e&&(n.blockedOn=null);for(;0<nr.length&&(s=nr[0],s.blockedOn===null);)Uw(s),s.blockedOn===null&&nr.shift()}var oa=Pi.ReactCurrentBatchConfig,nh=!0;function ME(e,t,s,n){var i=ct,r=oa.transition;oa.transition=null;try{ct=1,bg(e,t,s,n)}finally{ct=i,oa.transition=r}}function DE(e,t,s,n){var i=ct,r=oa.transition;oa.transition=null;try{ct=4,bg(e,t,s,n)}finally{ct=i,oa.transition=r}}function bg(e,t,s,n){if(nh){var i=gp(e,t,s,n);if(i===null)Vd(e,t,n,ih,s),tv(e,n);else if(TE(i,e,t,s,n))n.stopPropagation();else if(tv(e,n),t&4&&-1<jE.indexOf(e)){for(;i!==null;){var r=Rc(i);if(r!==null&&$w(r),r=gp(e,t,s,n),r===null&&Vd(e,t,n,ih,s),r===i)break;i=r}i!==null&&n.stopPropagation()}else Vd(e,t,n,null,s)}}var ih=null;function gp(e,t,s,n){if(ih=null,e=gg(n),e=Wr(e),e!==null)if(t=mo(e),t===null)e=null;else if(s=t.tag,s===13){if(e=Aw(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return ih=e,null}function Ww(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(bE()){case _g:return 1;case Pw:return 4;case th:case wE:return 16;case Lw:return 536870912;default:return 16}default:return 16}}var or=null,wg=null,Iu=null;function Kw(){if(Iu)return Iu;var e,t=wg,s=t.length,n,i="value"in or?or.value:or.textContent,r=i.length;for(e=0;e<s&&t[e]===i[e];e++);var a=s-e;for(n=1;n<=a&&t[s-n]===i[r-n];n++);return Iu=i.slice(e,1<n?1-n:void 0)}function Pu(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 Qc(){return!0}function nv(){return!1}function hn(e){function t(s,n,i,r,a){this._reactName=s,this._targetInst=i,this.type=n,this.nativeEvent=r,this.target=a,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(s=e[l],this[l]=s?s(r):r[l]);return this.isDefaultPrevented=(r.defaultPrevented!=null?r.defaultPrevented:r.returnValue===!1)?Qc:nv,this.isPropagationStopped=nv,this}return Mt(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=Qc)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Qc)},persist:function(){},isPersistent:Qc}),t}var Ra={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},xg=hn(Ra),Nc=Mt({},Ra,{view:0,detail:0}),IE=hn(Nc),Bd,$d,Ya,Xh=Mt({},Nc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Sg,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!==Ya&&(Ya&&e.type==="mousemove"?(Bd=e.screenX-Ya.screenX,$d=e.screenY-Ya.screenY):$d=Bd=0,Ya=e),Bd)},movementY:function(e){return"movementY"in e?e.movementY:$d}}),iv=hn(Xh),PE=Mt({},Xh,{dataTransfer:0}),LE=hn(PE),OE=Mt({},Nc,{relatedTarget:0}),Fd=hn(OE),BE=Mt({},Ra,{animationName:0,elapsedTime:0,pseudoElement:0}),$E=hn(BE),FE=Mt({},Ra,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),zE=hn(FE),HE=Mt({},Ra,{data:0}),rv=hn(HE),UE={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},WE={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"},KE={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function qE(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=KE[e])?!!t[e]:!1}function Sg(){return qE}var VE=Mt({},Nc,{key:function(e){if(e.key){var t=UE[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Pu(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?WE[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Sg,charCode:function(e){return e.type==="keypress"?Pu(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Pu(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),YE=hn(VE),GE=Mt({},Xh,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ov=hn(GE),JE=Mt({},Nc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Sg}),XE=hn(JE),ZE=Mt({},Ra,{propertyName:0,elapsedTime:0,pseudoElement:0}),QE=hn(ZE),e2=Mt({},Xh,{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}),t2=hn(e2),s2=[9,13,27,32],kg=Ai&&"CompositionEvent"in window,Dl=null;Ai&&"documentMode"in document&&(Dl=document.documentMode);var n2=Ai&&"TextEvent"in window&&!Dl,qw=Ai&&(!kg||Dl&&8<Dl&&11>=Dl),av=" ",lv=!1;function Vw(e,t){switch(e){case"keyup":return s2.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yw(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ko=!1;function i2(e,t){switch(e){case"compositionend":return Yw(t);case"keypress":return t.which!==32?null:(lv=!0,av);case"textInput":return e=t.data,e===av&&lv?null:e;default:return null}}function r2(e,t){if(Ko)return e==="compositionend"||!kg&&Vw(e,t)?(e=Kw(),Iu=wg=or=null,Ko=!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 qw&&t.locale!=="ko"?null:t.data;default:return null}}var o2={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 cv(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!o2[e.type]:t==="textarea"}function Gw(e,t,s,n){Ew(n),t=rh(t,"onChange"),0<t.length&&(s=new xg("onChange","change",null,s,n),e.push({event:s,listeners:t}))}var Il=null,Zl=null;function a2(e){ox(e,0)}function Zh(e){var t=Yo(e);if(yw(t))return e}function l2(e,t){if(e==="change")return t}var Jw=!1;if(Ai){var zd;if(Ai){var Hd="oninput"in document;if(!Hd){var uv=document.createElement("div");uv.setAttribute("oninput","return;"),Hd=typeof uv.oninput=="function"}zd=Hd}else zd=!1;Jw=zd&&(!document.documentMode||9<document.documentMode)}function hv(){Il&&(Il.detachEvent("onpropertychange",Xw),Zl=Il=null)}function Xw(e){if(e.propertyName==="value"&&Zh(Zl)){var t=[];Gw(t,Zl,e,gg(e)),Tw(a2,t)}}function c2(e,t,s){e==="focusin"?(hv(),Il=t,Zl=s,Il.attachEvent("onpropertychange",Xw)):e==="focusout"&&hv()}function u2(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Zh(Zl)}function h2(e,t){if(e==="click")return Zh(t)}function d2(e,t){if(e==="input"||e==="change")return Zh(t)}function f2(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Hn=typeof Object.is=="function"?Object.is:f2;function Ql(e,t){if(Hn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),n=Object.keys(t);if(s.length!==n.length)return!1;for(n=0;n<s.length;n++){var i=s[n];if(!Zf.call(t,i)||!Hn(e[i],t[i]))return!1}return!0}function dv(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function fv(e,t){var s=dv(e);e=0;for(var n;s;){if(s.nodeType===3){if(n=e+s.textContent.length,e<=t&&n>=t)return{node:s,offset:t-e};e=n}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=dv(s)}}function Zw(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Zw(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Qw(){for(var e=window,t=Zu();t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=Zu(e.document)}return t}function Cg(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 p2(e){var t=Qw(),s=e.focusedElem,n=e.selectionRange;if(t!==s&&s&&s.ownerDocument&&Zw(s.ownerDocument.documentElement,s)){if(n!==null&&Cg(s)){if(t=n.start,e=n.end,e===void 0&&(e=t),"selectionStart"in s)s.selectionStart=t,s.selectionEnd=Math.min(e,s.value.length);else if(e=(t=s.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=s.textContent.length,r=Math.min(n.start,i);n=n.end===void 0?r:Math.min(n.end,i),!e.extend&&r>n&&(i=n,n=r,r=i),i=fv(s,r);var a=fv(s,n);i&&a&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),r>n?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=s;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;s<t.length;s++)e=t[s],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var m2=Ai&&"documentMode"in document&&11>=document.documentMode,qo=null,_p=null,Pl=null,vp=!1;function pv(e,t,s){var n=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;vp||qo==null||qo!==Zu(n)||(n=qo,"selectionStart"in n&&Cg(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),Pl&&Ql(Pl,n)||(Pl=n,n=rh(_p,"onSelect"),0<n.length&&(t=new xg("onSelect","select",null,t,s),e.push({event:t,listeners:n}),t.target=qo)))}function eu(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var Vo={animationend:eu("Animation","AnimationEnd"),animationiteration:eu("Animation","AnimationIteration"),animationstart:eu("Animation","AnimationStart"),transitionend:eu("Transition","TransitionEnd")},Ud={},ex={};Ai&&(ex=document.createElement("div").style,"AnimationEvent"in window||(delete Vo.animationend.animation,delete Vo.animationiteration.animation,delete Vo.animationstart.animation),"TransitionEvent"in window||delete Vo.transitionend.transition);function Qh(e){if(Ud[e])return Ud[e];if(!Vo[e])return e;var t=Vo[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in ex)return Ud[e]=t[s];return e}var tx=Qh("animationend"),sx=Qh("animationiteration"),nx=Qh("animationstart"),ix=Qh("transitionend"),rx=new Map,mv="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 kr(e,t){rx.set(e,t),po(t,[e])}for(var Wd=0;Wd<mv.length;Wd++){var Kd=mv[Wd],g2=Kd.toLowerCase(),_2=Kd[0].toUpperCase()+Kd.slice(1);kr(g2,"on"+_2)}kr(tx,"onAnimationEnd");kr(sx,"onAnimationIteration");kr(nx,"onAnimationStart");kr("dblclick","onDoubleClick");kr("focusin","onFocus");kr("focusout","onBlur");kr(ix,"onTransitionEnd");da("onMouseEnter",["mouseout","mouseover"]);da("onMouseLeave",["mouseout","mouseover"]);da("onPointerEnter",["pointerout","pointerover"]);da("onPointerLeave",["pointerout","pointerover"]);po("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));po("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));po("onBeforeInput",["compositionend","keypress","textInput","paste"]);po("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));po("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));po("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Sl="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(" "),v2=new Set("cancel close invalid load scroll toggle".split(" ").concat(Sl));function gv(e,t,s){var n=e.type||"unknown-event";e.currentTarget=s,gE(n,t,void 0,e),e.currentTarget=null}function ox(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var n=e[s],i=n.event;n=n.listeners;e:{var r=void 0;if(t)for(var a=n.length-1;0<=a;a--){var l=n[a],c=l.instance,u=l.currentTarget;if(l=l.listener,c!==r&&i.isPropagationStopped())break e;gv(i,l,u),r=c}else for(a=0;a<n.length;a++){if(l=n[a],c=l.instance,u=l.currentTarget,l=l.listener,c!==r&&i.isPropagationStopped())break e;gv(i,l,u),r=c}}}if(eh)throw e=fp,eh=!1,fp=null,e}function vt(e,t){var s=t[Sp];s===void 0&&(s=t[Sp]=new Set);var n=e+"__bubble";s.has(n)||(ax(t,e,2,!1),s.add(n))}function qd(e,t,s){var n=0;t&&(n|=4),ax(s,e,n,t)}var tu="_reactListening"+Math.random().toString(36).slice(2);function ec(e){if(!e[tu]){e[tu]=!0,pw.forEach(function(s){s!=="selectionchange"&&(v2.has(s)||qd(s,!1,e),qd(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[tu]||(t[tu]=!0,qd("selectionchange",!1,t))}}function ax(e,t,s,n){switch(Ww(t)){case 1:var i=ME;break;case 4:i=DE;break;default:i=bg}s=i.bind(null,t,s,e),i=void 0,!dp||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),n?i!==void 0?e.addEventListener(t,s,{capture:!0,passive:i}):e.addEventListener(t,s,!0):i!==void 0?e.addEventListener(t,s,{passive:i}):e.addEventListener(t,s,!1)}function Vd(e,t,s,n,i){var r=n;if(!(t&1)&&!(t&2)&&n!==null)e:for(;;){if(n===null)return;var a=n.tag;if(a===3||a===4){var l=n.stateNode.containerInfo;if(l===i||l.nodeType===8&&l.parentNode===i)break;if(a===4)for(a=n.return;a!==null;){var c=a.tag;if((c===3||c===4)&&(c=a.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;a=a.return}for(;l!==null;){if(a=Wr(l),a===null)return;if(c=a.tag,c===5||c===6){n=r=a;continue e}l=l.parentNode}}n=n.return}Tw(function(){var u=r,h=gg(s),d=[];e:{var p=rx.get(e);if(p!==void 0){var f=xg,m=e;switch(e){case"keypress":if(Pu(s)===0)break e;case"keydown":case"keyup":f=YE;break;case"focusin":m="focus",f=Fd;break;case"focusout":m="blur",f=Fd;break;case"beforeblur":case"afterblur":f=Fd;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":f=iv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":f=LE;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":f=XE;break;case tx:case sx:case nx:f=$E;break;case ix:f=QE;break;case"scroll":f=IE;break;case"wheel":f=t2;break;case"copy":case"cut":case"paste":f=zE;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":f=ov}var b=(t&4)!==0,_=!b&&e==="scroll",v=b?p!==null?p+"Capture":null:p;b=[];for(var y=u,w;y!==null;){w=y;var x=w.stateNode;if(w.tag===5&&x!==null&&(w=x,v!==null&&(x=Yl(y,v),x!=null&&b.push(tc(y,x,w)))),_)break;y=y.return}0<b.length&&(p=new f(p,m,null,s,h),d.push({event:p,listeners:b}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",f=e==="mouseout"||e==="pointerout",p&&s!==up&&(m=s.relatedTarget||s.fromElement)&&(Wr(m)||m[Mi]))break e;if((f||p)&&(p=h.window===h?h:(p=h.ownerDocument)?p.defaultView||p.parentWindow:window,f?(m=s.relatedTarget||s.toElement,f=u,m=m?Wr(m):null,m!==null&&(_=mo(m),m!==_||m.tag!==5&&m.tag!==6)&&(m=null)):(f=null,m=u),f!==m)){if(b=iv,x="onMouseLeave",v="onMouseEnter",y="mouse",(e==="pointerout"||e==="pointerover")&&(b=ov,x="onPointerLeave",v="onPointerEnter",y="pointer"),_=f==null?p:Yo(f),w=m==null?p:Yo(m),p=new b(x,y+"leave",f,s,h),p.target=_,p.relatedTarget=w,x=null,Wr(h)===u&&(b=new b(v,y+"enter",m,s,h),b.target=w,b.relatedTarget=_,x=b),_=x,f&&m)t:{for(b=f,v=m,y=0,w=b;w;w=Ao(w))y++;for(w=0,x=v;x;x=Ao(x))w++;for(;0<y-w;)b=Ao(b),y--;for(;0<w-y;)v=Ao(v),w--;for(;y--;){if(b===v||v!==null&&b===v.alternate)break t;b=Ao(b),v=Ao(v)}b=null}else b=null;f!==null&&_v(d,p,f,b,!1),m!==null&&_!==null&&_v(d,_,m,b,!0)}}e:{if(p=u?Yo(u):window,f=p.nodeName&&p.nodeName.toLowerCase(),f==="select"||f==="input"&&p.type==="file")var S=l2;else if(cv(p))if(Jw)S=d2;else{S=u2;var E=c2}else(f=p.nodeName)&&f.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(S=h2);if(S&&(S=S(e,u))){Gw(d,S,s,h);break e}E&&E(e,p,u),e==="focusout"&&(E=p._wrapperState)&&E.controlled&&p.type==="number"&&rp(p,"number",p.value)}switch(E=u?Yo(u):window,e){case"focusin":(cv(E)||E.contentEditable==="true")&&(qo=E,_p=u,Pl=null);break;case"focusout":Pl=_p=qo=null;break;case"mousedown":vp=!0;break;case"contextmenu":case"mouseup":case"dragend":vp=!1,pv(d,s,h);break;case"selectionchange":if(m2)break;case"keydown":case"keyup":pv(d,s,h)}var R;if(kg)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 Ko?Vw(e,s)&&(N="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(N="onCompositionStart");N&&(qw&&s.locale!=="ko"&&(Ko||N!=="onCompositionStart"?N==="onCompositionEnd"&&Ko&&(R=Kw()):(or=h,wg="value"in or?or.value:or.textContent,Ko=!0)),E=rh(u,N),0<E.length&&(N=new rv(N,e,null,s,h),d.push({event:N,listeners:E}),R?N.data=R:(R=Yw(s),R!==null&&(N.data=R)))),(R=n2?i2(e,s):r2(e,s))&&(u=rh(u,"onBeforeInput"),0<u.length&&(h=new rv("onBeforeInput","beforeinput",null,s,h),d.push({event:h,listeners:u}),h.data=R))}ox(d,t)})}function tc(e,t,s){return{instance:e,listener:t,currentTarget:s}}function rh(e,t){for(var s=t+"Capture",n=[];e!==null;){var i=e,r=i.stateNode;i.tag===5&&r!==null&&(i=r,r=Yl(e,s),r!=null&&n.unshift(tc(e,r,i)),r=Yl(e,t),r!=null&&n.push(tc(e,r,i))),e=e.return}return n}function Ao(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function _v(e,t,s,n,i){for(var r=t._reactName,a=[];s!==null&&s!==n;){var l=s,c=l.alternate,u=l.stateNode;if(c!==null&&c===n)break;l.tag===5&&u!==null&&(l=u,i?(c=Yl(s,r),c!=null&&a.unshift(tc(s,c,l))):i||(c=Yl(s,r),c!=null&&a.push(tc(s,c,l)))),s=s.return}a.length!==0&&e.push({event:t,listeners:a})}var y2=/\r\n?/g,b2=/\u0000|\uFFFD/g;function vv(e){return(typeof e=="string"?e:""+e).replace(y2,`
38
+ `).replace(b2,"")}function su(e,t,s){if(t=vv(t),vv(e)!==t&&s)throw Error(ie(425))}function oh(){}var yp=null,bp=null;function wp(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 xp=typeof setTimeout=="function"?setTimeout:void 0,w2=typeof clearTimeout=="function"?clearTimeout:void 0,yv=typeof Promise=="function"?Promise:void 0,x2=typeof queueMicrotask=="function"?queueMicrotask:typeof yv<"u"?function(e){return yv.resolve(null).then(e).catch(S2)}:xp;function S2(e){setTimeout(function(){throw e})}function Yd(e,t){var s=t,n=0;do{var i=s.nextSibling;if(e.removeChild(s),i&&i.nodeType===8)if(s=i.data,s==="/$"){if(n===0){e.removeChild(i),Xl(t);return}n--}else s!=="$"&&s!=="$?"&&s!=="$!"||n++;s=i}while(s);Xl(t)}function pr(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 bv(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"){if(t===0)return e;t--}else s==="/$"&&t++}e=e.previousSibling}return null}var ja=Math.random().toString(36).slice(2),ei="__reactFiber$"+ja,sc="__reactProps$"+ja,Mi="__reactContainer$"+ja,Sp="__reactEvents$"+ja,k2="__reactListeners$"+ja,C2="__reactHandles$"+ja;function Wr(e){var t=e[ei];if(t)return t;for(var s=e.parentNode;s;){if(t=s[Mi]||s[ei]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=bv(e);e!==null;){if(s=e[ei])return s;e=bv(e)}return t}e=s,s=e.parentNode}return null}function Rc(e){return e=e[ei]||e[Mi],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Yo(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(ie(33))}function ed(e){return e[sc]||null}var kp=[],Go=-1;function Cr(e){return{current:e}}function bt(e){0>Go||(e.current=kp[Go],kp[Go]=null,Go--)}function pt(e,t){Go++,kp[Go]=e.current,e.current=t}var wr={},js=Cr(wr),Vs=Cr(!1),no=wr;function fa(e,t){var s=e.type.contextTypes;if(!s)return wr;var n=e.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===t)return n.__reactInternalMemoizedMaskedChildContext;var i={},r;for(r in s)i[r]=t[r];return n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Ys(e){return e=e.childContextTypes,e!=null}function ah(){bt(Vs),bt(js)}function wv(e,t,s){if(js.current!==wr)throw Error(ie(168));pt(js,t),pt(Vs,s)}function lx(e,t,s){var n=e.stateNode;if(t=t.childContextTypes,typeof n.getChildContext!="function")return s;n=n.getChildContext();for(var i in n)if(!(i in t))throw Error(ie(108,cE(e)||"Unknown",i));return Mt({},s,n)}function lh(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||wr,no=js.current,pt(js,e),pt(Vs,Vs.current),!0}function xv(e,t,s){var n=e.stateNode;if(!n)throw Error(ie(169));s?(e=lx(e,t,no),n.__reactInternalMemoizedMergedChildContext=e,bt(Vs),bt(js),pt(js,e)):bt(Vs),pt(Vs,s)}var wi=null,td=!1,Gd=!1;function cx(e){wi===null?wi=[e]:wi.push(e)}function E2(e){td=!0,cx(e)}function Er(){if(!Gd&&wi!==null){Gd=!0;var e=0,t=ct;try{var s=wi;for(ct=1;e<s.length;e++){var n=s[e];do n=n(!0);while(n!==null)}wi=null,td=!1}catch(i){throw wi!==null&&(wi=wi.slice(e+1)),Iw(_g,Er),i}finally{ct=t,Gd=!1}}return null}var Jo=[],Xo=0,ch=null,uh=0,vn=[],yn=0,io=null,ki=1,Ci="";function $r(e,t){Jo[Xo++]=uh,Jo[Xo++]=ch,ch=e,uh=t}function ux(e,t,s){vn[yn++]=ki,vn[yn++]=Ci,vn[yn++]=io,io=e;var n=ki;e=Ci;var i=32-$n(n)-1;n&=~(1<<i),s+=1;var r=32-$n(t)+i;if(30<r){var a=i-i%5;r=(n&(1<<a)-1).toString(32),n>>=a,i-=a,ki=1<<32-$n(t)+i|s<<i|n,Ci=r+e}else ki=1<<r|s<<i|n,Ci=e}function Eg(e){e.return!==null&&($r(e,1),ux(e,1,0))}function Ng(e){for(;e===ch;)ch=Jo[--Xo],Jo[Xo]=null,uh=Jo[--Xo],Jo[Xo]=null;for(;e===io;)io=vn[--yn],vn[yn]=null,Ci=vn[--yn],vn[yn]=null,ki=vn[--yn],vn[yn]=null}var ln=null,on=null,wt=!1,On=null;function hx(e,t){var s=wn(5,null,null,0);s.elementType="DELETED",s.stateNode=t,s.return=e,t=e.deletions,t===null?(e.deletions=[s],e.flags|=16):t.push(s)}function Sv(e,t){switch(e.tag){case 5:var s=e.type;return t=t.nodeType!==1||s.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,ln=e,on=pr(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ln=e,on=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(s=io!==null?{id:ki,overflow:Ci}:null,e.memoizedState={dehydrated:t,treeContext:s,retryLane:1073741824},s=wn(18,null,null,0),s.stateNode=t,s.return=e,e.child=s,ln=e,on=null,!0):!1;default:return!1}}function Cp(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Ep(e){if(wt){var t=on;if(t){var s=t;if(!Sv(e,t)){if(Cp(e))throw Error(ie(418));t=pr(s.nextSibling);var n=ln;t&&Sv(e,t)?hx(n,s):(e.flags=e.flags&-4097|2,wt=!1,ln=e)}}else{if(Cp(e))throw Error(ie(418));e.flags=e.flags&-4097|2,wt=!1,ln=e}}}function kv(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ln=e}function nu(e){if(e!==ln)return!1;if(!wt)return kv(e),wt=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!wp(e.type,e.memoizedProps)),t&&(t=on)){if(Cp(e))throw dx(),Error(ie(418));for(;t;)hx(e,t),t=pr(t.nextSibling)}if(kv(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(ie(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(t===0){on=pr(e.nextSibling);break e}t--}else s!=="$"&&s!=="$!"&&s!=="$?"||t++}e=e.nextSibling}on=null}}else on=ln?pr(e.stateNode.nextSibling):null;return!0}function dx(){for(var e=on;e;)e=pr(e.nextSibling)}function pa(){on=ln=null,wt=!1}function Rg(e){On===null?On=[e]:On.push(e)}var N2=Pi.ReactCurrentBatchConfig;function Ga(e,t,s){if(e=s.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(s._owner){if(s=s._owner,s){if(s.tag!==1)throw Error(ie(309));var n=s.stateNode}if(!n)throw Error(ie(147,e));var i=n,r=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===r?t.ref:(t=function(a){var l=i.refs;a===null?delete l[r]:l[r]=a},t._stringRef=r,t)}if(typeof e!="string")throw Error(ie(284));if(!s._owner)throw Error(ie(290,e))}return e}function iu(e,t){throw e=Object.prototype.toString.call(t),Error(ie(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Cv(e){var t=e._init;return t(e._payload)}function fx(e){function t(v,y){if(e){var w=v.deletions;w===null?(v.deletions=[y],v.flags|=16):w.push(y)}}function s(v,y){if(!e)return null;for(;y!==null;)t(v,y),y=y.sibling;return null}function n(v,y){for(v=new Map;y!==null;)y.key!==null?v.set(y.key,y):v.set(y.index,y),y=y.sibling;return v}function i(v,y){return v=vr(v,y),v.index=0,v.sibling=null,v}function r(v,y,w){return v.index=w,e?(w=v.alternate,w!==null?(w=w.index,w<y?(v.flags|=2,y):w):(v.flags|=2,y)):(v.flags|=1048576,y)}function a(v){return e&&v.alternate===null&&(v.flags|=2),v}function l(v,y,w,x){return y===null||y.tag!==6?(y=sf(w,v.mode,x),y.return=v,y):(y=i(y,w),y.return=v,y)}function c(v,y,w,x){var S=w.type;return S===Wo?h(v,y,w.props.children,x,w.key):y!==null&&(y.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Zi&&Cv(S)===y.type)?(x=i(y,w.props),x.ref=Ga(v,y,w),x.return=v,x):(x=Hu(w.type,w.key,w.props,null,v.mode,x),x.ref=Ga(v,y,w),x.return=v,x)}function u(v,y,w,x){return y===null||y.tag!==4||y.stateNode.containerInfo!==w.containerInfo||y.stateNode.implementation!==w.implementation?(y=nf(w,v.mode,x),y.return=v,y):(y=i(y,w.children||[]),y.return=v,y)}function h(v,y,w,x,S){return y===null||y.tag!==7?(y=Jr(w,v.mode,x,S),y.return=v,y):(y=i(y,w),y.return=v,y)}function d(v,y,w){if(typeof y=="string"&&y!==""||typeof y=="number")return y=sf(""+y,v.mode,w),y.return=v,y;if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Vc:return w=Hu(y.type,y.key,y.props,null,v.mode,w),w.ref=Ga(v,null,y),w.return=v,w;case Uo:return y=nf(y,v.mode,w),y.return=v,y;case Zi:var x=y._init;return d(v,x(y._payload),w)}if(wl(y)||Wa(y))return y=Jr(y,v.mode,w,null),y.return=v,y;iu(v,y)}return null}function p(v,y,w,x){var S=y!==null?y.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return S!==null?null:l(v,y,""+w,x);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Vc:return w.key===S?c(v,y,w,x):null;case Uo:return w.key===S?u(v,y,w,x):null;case Zi:return S=w._init,p(v,y,S(w._payload),x)}if(wl(w)||Wa(w))return S!==null?null:h(v,y,w,x,null);iu(v,w)}return null}function f(v,y,w,x,S){if(typeof x=="string"&&x!==""||typeof x=="number")return v=v.get(w)||null,l(y,v,""+x,S);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Vc:return v=v.get(x.key===null?w:x.key)||null,c(y,v,x,S);case Uo:return v=v.get(x.key===null?w:x.key)||null,u(y,v,x,S);case Zi:var E=x._init;return f(v,y,w,E(x._payload),S)}if(wl(x)||Wa(x))return v=v.get(w)||null,h(y,v,x,S,null);iu(y,x)}return null}function m(v,y,w,x){for(var S=null,E=null,R=y,N=y=0,I=null;R!==null&&N<w.length;N++){R.index>N?(I=R,R=null):I=R.sibling;var F=p(v,R,w[N],x);if(F===null){R===null&&(R=I);break}e&&R&&F.alternate===null&&t(v,R),y=r(F,y,N),E===null?S=F:E.sibling=F,E=F,R=I}if(N===w.length)return s(v,R),wt&&$r(v,N),S;if(R===null){for(;N<w.length;N++)R=d(v,w[N],x),R!==null&&(y=r(R,y,N),E===null?S=R:E.sibling=R,E=R);return wt&&$r(v,N),S}for(R=n(v,R);N<w.length;N++)I=f(R,v,N,w[N],x),I!==null&&(e&&I.alternate!==null&&R.delete(I.key===null?N:I.key),y=r(I,y,N),E===null?S=I:E.sibling=I,E=I);return e&&R.forEach(function(B){return t(v,B)}),wt&&$r(v,N),S}function b(v,y,w,x){var S=Wa(w);if(typeof S!="function")throw Error(ie(150));if(w=S.call(w),w==null)throw Error(ie(151));for(var E=S=null,R=y,N=y=0,I=null,F=w.next();R!==null&&!F.done;N++,F=w.next()){R.index>N?(I=R,R=null):I=R.sibling;var B=p(v,R,F.value,x);if(B===null){R===null&&(R=I);break}e&&R&&B.alternate===null&&t(v,R),y=r(B,y,N),E===null?S=B:E.sibling=B,E=B,R=I}if(F.done)return s(v,R),wt&&$r(v,N),S;if(R===null){for(;!F.done;N++,F=w.next())F=d(v,F.value,x),F!==null&&(y=r(F,y,N),E===null?S=F:E.sibling=F,E=F);return wt&&$r(v,N),S}for(R=n(v,R);!F.done;N++,F=w.next())F=f(R,v,N,F.value,x),F!==null&&(e&&F.alternate!==null&&R.delete(F.key===null?N:F.key),y=r(F,y,N),E===null?S=F:E.sibling=F,E=F);return e&&R.forEach(function(C){return t(v,C)}),wt&&$r(v,N),S}function _(v,y,w,x){if(typeof w=="object"&&w!==null&&w.type===Wo&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Vc:e:{for(var S=w.key,E=y;E!==null;){if(E.key===S){if(S=w.type,S===Wo){if(E.tag===7){s(v,E.sibling),y=i(E,w.props.children),y.return=v,v=y;break e}}else if(E.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Zi&&Cv(S)===E.type){s(v,E.sibling),y=i(E,w.props),y.ref=Ga(v,E,w),y.return=v,v=y;break e}s(v,E);break}else t(v,E);E=E.sibling}w.type===Wo?(y=Jr(w.props.children,v.mode,x,w.key),y.return=v,v=y):(x=Hu(w.type,w.key,w.props,null,v.mode,x),x.ref=Ga(v,y,w),x.return=v,v=x)}return a(v);case Uo:e:{for(E=w.key;y!==null;){if(y.key===E)if(y.tag===4&&y.stateNode.containerInfo===w.containerInfo&&y.stateNode.implementation===w.implementation){s(v,y.sibling),y=i(y,w.children||[]),y.return=v,v=y;break e}else{s(v,y);break}else t(v,y);y=y.sibling}y=nf(w,v.mode,x),y.return=v,v=y}return a(v);case Zi:return E=w._init,_(v,y,E(w._payload),x)}if(wl(w))return m(v,y,w,x);if(Wa(w))return b(v,y,w,x);iu(v,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,y!==null&&y.tag===6?(s(v,y.sibling),y=i(y,w),y.return=v,v=y):(s(v,y),y=sf(w,v.mode,x),y.return=v,v=y),a(v)):s(v,y)}return _}var ma=fx(!0),px=fx(!1),hh=Cr(null),dh=null,Zo=null,jg=null;function Tg(){jg=Zo=dh=null}function Ag(e){var t=hh.current;bt(hh),e._currentValue=t}function Np(e,t,s){for(;e!==null;){var n=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,n!==null&&(n.childLanes|=t)):n!==null&&(n.childLanes&t)!==t&&(n.childLanes|=t),e===s)break;e=e.return}}function aa(e,t){dh=e,jg=Zo=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(qs=!0),e.firstContext=null)}function kn(e){var t=e._currentValue;if(jg!==e)if(e={context:e,memoizedValue:t,next:null},Zo===null){if(dh===null)throw Error(ie(308));Zo=e,dh.dependencies={lanes:0,firstContext:e}}else Zo=Zo.next=e;return t}var Kr=null;function Mg(e){Kr===null?Kr=[e]:Kr.push(e)}function mx(e,t,s,n){var i=t.interleaved;return i===null?(s.next=s,Mg(t)):(s.next=i.next,i.next=s),t.interleaved=s,Di(e,n)}function Di(e,t){e.lanes|=t;var s=e.alternate;for(s!==null&&(s.lanes|=t),s=e,e=e.return;e!==null;)e.childLanes|=t,s=e.alternate,s!==null&&(s.childLanes|=t),s=e,e=e.return;return s.tag===3?s.stateNode:null}var Qi=!1;function Dg(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function gx(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 Ni(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function mr(e,t,s){var n=e.updateQueue;if(n===null)return null;if(n=n.shared,it&2){var i=n.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),n.pending=t,Di(e,s)}return i=n.interleaved,i===null?(t.next=t,Mg(n)):(t.next=i.next,i.next=t),n.interleaved=t,Di(e,s)}function Lu(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194240)!==0)){var n=t.lanes;n&=e.pendingLanes,s|=n,t.lanes=s,vg(e,s)}}function Ev(e,t){var s=e.updateQueue,n=e.alternate;if(n!==null&&(n=n.updateQueue,s===n)){var i=null,r=null;if(s=s.firstBaseUpdate,s!==null){do{var a={eventTime:s.eventTime,lane:s.lane,tag:s.tag,payload:s.payload,callback:s.callback,next:null};r===null?i=r=a:r=r.next=a,s=s.next}while(s!==null);r===null?i=r=t:r=r.next=t}else i=r=t;s={baseState:n.baseState,firstBaseUpdate:i,lastBaseUpdate:r,shared:n.shared,effects:n.effects},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}function fh(e,t,s,n){var i=e.updateQueue;Qi=!1;var r=i.firstBaseUpdate,a=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var c=l,u=c.next;c.next=null,a===null?r=u:a.next=u,a=c;var h=e.alternate;h!==null&&(h=h.updateQueue,l=h.lastBaseUpdate,l!==a&&(l===null?h.firstBaseUpdate=u:l.next=u,h.lastBaseUpdate=c))}if(r!==null){var d=i.baseState;a=0,h=u=c=null,l=r;do{var p=l.lane,f=l.eventTime;if((n&p)===p){h!==null&&(h=h.next={eventTime:f,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var m=e,b=l;switch(p=t,f=s,b.tag){case 1:if(m=b.payload,typeof m=="function"){d=m.call(f,d,p);break e}d=m;break e;case 3:m.flags=m.flags&-65537|128;case 0:if(m=b.payload,p=typeof m=="function"?m.call(f,d,p):m,p==null)break e;d=Mt({},d,p);break e;case 2:Qi=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=i.effects,p===null?i.effects=[l]:p.push(l))}else f={eventTime:f,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},h===null?(u=h=f,c=d):h=h.next=f,a|=p;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;p=l,l=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(!0);if(h===null&&(c=d),i.baseState=c,i.firstBaseUpdate=u,i.lastBaseUpdate=h,t=i.shared.interleaved,t!==null){i=t;do a|=i.lane,i=i.next;while(i!==t)}else r===null&&(i.shared.lanes=0);oo|=a,e.lanes=a,e.memoizedState=d}}function Nv(e,t,s){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var n=e[t],i=n.callback;if(i!==null){if(n.callback=null,n=s,typeof i!="function")throw Error(ie(191,i));i.call(n)}}}var jc={},oi=Cr(jc),nc=Cr(jc),ic=Cr(jc);function qr(e){if(e===jc)throw Error(ie(174));return e}function Ig(e,t){switch(pt(ic,t),pt(nc,e),pt(oi,jc),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:ap(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=ap(t,e)}bt(oi),pt(oi,t)}function ga(){bt(oi),bt(nc),bt(ic)}function _x(e){qr(ic.current);var t=qr(oi.current),s=ap(t,e.type);t!==s&&(pt(nc,e),pt(oi,s))}function Pg(e){nc.current===e&&(bt(oi),bt(nc))}var Tt=Cr(0);function ph(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||s.data==="$?"||s.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 Jd=[];function Lg(){for(var e=0;e<Jd.length;e++)Jd[e]._workInProgressVersionPrimary=null;Jd.length=0}var Ou=Pi.ReactCurrentDispatcher,Xd=Pi.ReactCurrentBatchConfig,ro=0,At=null,Qt=null,rs=null,mh=!1,Ll=!1,rc=0,R2=0;function ks(){throw Error(ie(321))}function Og(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!Hn(e[s],t[s]))return!1;return!0}function Bg(e,t,s,n,i,r){if(ro=r,At=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Ou.current=e===null||e.memoizedState===null?M2:D2,e=s(n,i),Ll){r=0;do{if(Ll=!1,rc=0,25<=r)throw Error(ie(301));r+=1,rs=Qt=null,t.updateQueue=null,Ou.current=I2,e=s(n,i)}while(Ll)}if(Ou.current=gh,t=Qt!==null&&Qt.next!==null,ro=0,rs=Qt=At=null,mh=!1,t)throw Error(ie(300));return e}function $g(){var e=rc!==0;return rc=0,e}function Qn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return rs===null?At.memoizedState=rs=e:rs=rs.next=e,rs}function Cn(){if(Qt===null){var e=At.alternate;e=e!==null?e.memoizedState:null}else e=Qt.next;var t=rs===null?At.memoizedState:rs.next;if(t!==null)rs=t,Qt=e;else{if(e===null)throw Error(ie(310));Qt=e,e={memoizedState:Qt.memoizedState,baseState:Qt.baseState,baseQueue:Qt.baseQueue,queue:Qt.queue,next:null},rs===null?At.memoizedState=rs=e:rs=rs.next=e}return rs}function oc(e,t){return typeof t=="function"?t(e):t}function Zd(e){var t=Cn(),s=t.queue;if(s===null)throw Error(ie(311));s.lastRenderedReducer=e;var n=Qt,i=n.baseQueue,r=s.pending;if(r!==null){if(i!==null){var a=i.next;i.next=r.next,r.next=a}n.baseQueue=i=r,s.pending=null}if(i!==null){r=i.next,n=n.baseState;var l=a=null,c=null,u=r;do{var h=u.lane;if((ro&h)===h)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),n=u.hasEagerState?u.eagerState:e(n,u.action);else{var d={lane:h,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=d,a=n):c=c.next=d,At.lanes|=h,oo|=h}u=u.next}while(u!==null&&u!==r);c===null?a=n:c.next=l,Hn(n,t.memoizedState)||(qs=!0),t.memoizedState=n,t.baseState=a,t.baseQueue=c,s.lastRenderedState=n}if(e=s.interleaved,e!==null){i=e;do r=i.lane,At.lanes|=r,oo|=r,i=i.next;while(i!==e)}else i===null&&(s.lanes=0);return[t.memoizedState,s.dispatch]}function Qd(e){var t=Cn(),s=t.queue;if(s===null)throw Error(ie(311));s.lastRenderedReducer=e;var n=s.dispatch,i=s.pending,r=t.memoizedState;if(i!==null){s.pending=null;var a=i=i.next;do r=e(r,a.action),a=a.next;while(a!==i);Hn(r,t.memoizedState)||(qs=!0),t.memoizedState=r,t.baseQueue===null&&(t.baseState=r),s.lastRenderedState=r}return[r,n]}function vx(){}function yx(e,t){var s=At,n=Cn(),i=t(),r=!Hn(n.memoizedState,i);if(r&&(n.memoizedState=i,qs=!0),n=n.queue,Fg(xx.bind(null,s,n,e),[e]),n.getSnapshot!==t||r||rs!==null&&rs.memoizedState.tag&1){if(s.flags|=2048,ac(9,wx.bind(null,s,n,i,t),void 0,null),cs===null)throw Error(ie(349));ro&30||bx(s,t,i)}return i}function bx(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=At.updateQueue,t===null?(t={lastEffect:null,stores:null},At.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function wx(e,t,s,n){t.value=s,t.getSnapshot=n,Sx(t)&&kx(e)}function xx(e,t,s){return s(function(){Sx(t)&&kx(e)})}function Sx(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!Hn(e,s)}catch{return!0}}function kx(e){var t=Di(e,1);t!==null&&Fn(t,e,1,-1)}function Rv(e){var t=Qn();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:oc,lastRenderedState:e},t.queue=e,e=e.dispatch=A2.bind(null,At,e),[t.memoizedState,e]}function ac(e,t,s,n){return e={tag:e,create:t,destroy:s,deps:n,next:null},t=At.updateQueue,t===null?(t={lastEffect:null,stores:null},At.updateQueue=t,t.lastEffect=e.next=e):(s=t.lastEffect,s===null?t.lastEffect=e.next=e:(n=s.next,s.next=e,e.next=n,t.lastEffect=e)),e}function Cx(){return Cn().memoizedState}function Bu(e,t,s,n){var i=Qn();At.flags|=e,i.memoizedState=ac(1|t,s,void 0,n===void 0?null:n)}function sd(e,t,s,n){var i=Cn();n=n===void 0?null:n;var r=void 0;if(Qt!==null){var a=Qt.memoizedState;if(r=a.destroy,n!==null&&Og(n,a.deps)){i.memoizedState=ac(t,s,r,n);return}}At.flags|=e,i.memoizedState=ac(1|t,s,r,n)}function jv(e,t){return Bu(8390656,8,e,t)}function Fg(e,t){return sd(2048,8,e,t)}function Ex(e,t){return sd(4,2,e,t)}function Nx(e,t){return sd(4,4,e,t)}function Rx(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 jx(e,t,s){return s=s!=null?s.concat([e]):null,sd(4,4,Rx.bind(null,t,e),s)}function zg(){}function Tx(e,t){var s=Cn();t=t===void 0?null:t;var n=s.memoizedState;return n!==null&&t!==null&&Og(t,n[1])?n[0]:(s.memoizedState=[e,t],e)}function Ax(e,t){var s=Cn();t=t===void 0?null:t;var n=s.memoizedState;return n!==null&&t!==null&&Og(t,n[1])?n[0]:(e=e(),s.memoizedState=[e,t],e)}function Mx(e,t,s){return ro&21?(Hn(s,t)||(s=Ow(),At.lanes|=s,oo|=s,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,qs=!0),e.memoizedState=s)}function j2(e,t){var s=ct;ct=s!==0&&4>s?s:4,e(!0);var n=Xd.transition;Xd.transition={};try{e(!1),t()}finally{ct=s,Xd.transition=n}}function Dx(){return Cn().memoizedState}function T2(e,t,s){var n=_r(e);if(s={lane:n,action:s,hasEagerState:!1,eagerState:null,next:null},Ix(e))Px(t,s);else if(s=mx(e,t,s,n),s!==null){var i=Ls();Fn(s,e,n,i),Lx(s,t,n)}}function A2(e,t,s){var n=_r(e),i={lane:n,action:s,hasEagerState:!1,eagerState:null,next:null};if(Ix(e))Px(t,i);else{var r=e.alternate;if(e.lanes===0&&(r===null||r.lanes===0)&&(r=t.lastRenderedReducer,r!==null))try{var a=t.lastRenderedState,l=r(a,s);if(i.hasEagerState=!0,i.eagerState=l,Hn(l,a)){var c=t.interleaved;c===null?(i.next=i,Mg(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}s=mx(e,t,i,n),s!==null&&(i=Ls(),Fn(s,e,n,i),Lx(s,t,n))}}function Ix(e){var t=e.alternate;return e===At||t!==null&&t===At}function Px(e,t){Ll=mh=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function Lx(e,t,s){if(s&4194240){var n=t.lanes;n&=e.pendingLanes,s|=n,t.lanes=s,vg(e,s)}}var gh={readContext:kn,useCallback:ks,useContext:ks,useEffect:ks,useImperativeHandle:ks,useInsertionEffect:ks,useLayoutEffect:ks,useMemo:ks,useReducer:ks,useRef:ks,useState:ks,useDebugValue:ks,useDeferredValue:ks,useTransition:ks,useMutableSource:ks,useSyncExternalStore:ks,useId:ks,unstable_isNewReconciler:!1},M2={readContext:kn,useCallback:function(e,t){return Qn().memoizedState=[e,t===void 0?null:t],e},useContext:kn,useEffect:jv,useImperativeHandle:function(e,t,s){return s=s!=null?s.concat([e]):null,Bu(4194308,4,Rx.bind(null,t,e),s)},useLayoutEffect:function(e,t){return Bu(4194308,4,e,t)},useInsertionEffect:function(e,t){return Bu(4,2,e,t)},useMemo:function(e,t){var s=Qn();return t=t===void 0?null:t,e=e(),s.memoizedState=[e,t],e},useReducer:function(e,t,s){var n=Qn();return t=s!==void 0?s(t):t,n.memoizedState=n.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},n.queue=e,e=e.dispatch=T2.bind(null,At,e),[n.memoizedState,e]},useRef:function(e){var t=Qn();return e={current:e},t.memoizedState=e},useState:Rv,useDebugValue:zg,useDeferredValue:function(e){return Qn().memoizedState=e},useTransition:function(){var e=Rv(!1),t=e[0];return e=j2.bind(null,e[1]),Qn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,s){var n=At,i=Qn();if(wt){if(s===void 0)throw Error(ie(407));s=s()}else{if(s=t(),cs===null)throw Error(ie(349));ro&30||bx(n,t,s)}i.memoizedState=s;var r={value:s,getSnapshot:t};return i.queue=r,jv(xx.bind(null,n,r,e),[e]),n.flags|=2048,ac(9,wx.bind(null,n,r,s,t),void 0,null),s},useId:function(){var e=Qn(),t=cs.identifierPrefix;if(wt){var s=Ci,n=ki;s=(n&~(1<<32-$n(n)-1)).toString(32)+s,t=":"+t+"R"+s,s=rc++,0<s&&(t+="H"+s.toString(32)),t+=":"}else s=R2++,t=":"+t+"r"+s.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},D2={readContext:kn,useCallback:Tx,useContext:kn,useEffect:Fg,useImperativeHandle:jx,useInsertionEffect:Ex,useLayoutEffect:Nx,useMemo:Ax,useReducer:Zd,useRef:Cx,useState:function(){return Zd(oc)},useDebugValue:zg,useDeferredValue:function(e){var t=Cn();return Mx(t,Qt.memoizedState,e)},useTransition:function(){var e=Zd(oc)[0],t=Cn().memoizedState;return[e,t]},useMutableSource:vx,useSyncExternalStore:yx,useId:Dx,unstable_isNewReconciler:!1},I2={readContext:kn,useCallback:Tx,useContext:kn,useEffect:Fg,useImperativeHandle:jx,useInsertionEffect:Ex,useLayoutEffect:Nx,useMemo:Ax,useReducer:Qd,useRef:Cx,useState:function(){return Qd(oc)},useDebugValue:zg,useDeferredValue:function(e){var t=Cn();return Qt===null?t.memoizedState=e:Mx(t,Qt.memoizedState,e)},useTransition:function(){var e=Qd(oc)[0],t=Cn().memoizedState;return[e,t]},useMutableSource:vx,useSyncExternalStore:yx,useId:Dx,unstable_isNewReconciler:!1};function Pn(e,t){if(e&&e.defaultProps){t=Mt({},t),e=e.defaultProps;for(var s in e)t[s]===void 0&&(t[s]=e[s]);return t}return t}function Rp(e,t,s,n){t=e.memoizedState,s=s(n,t),s=s==null?t:Mt({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var nd={isMounted:function(e){return(e=e._reactInternals)?mo(e)===e:!1},enqueueSetState:function(e,t,s){e=e._reactInternals;var n=Ls(),i=_r(e),r=Ni(n,i);r.payload=t,s!=null&&(r.callback=s),t=mr(e,r,i),t!==null&&(Fn(t,e,i,n),Lu(t,e,i))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var n=Ls(),i=_r(e),r=Ni(n,i);r.tag=1,r.payload=t,s!=null&&(r.callback=s),t=mr(e,r,i),t!==null&&(Fn(t,e,i,n),Lu(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=Ls(),n=_r(e),i=Ni(s,n);i.tag=2,t!=null&&(i.callback=t),t=mr(e,i,n),t!==null&&(Fn(t,e,n,s),Lu(t,e,n))}};function Tv(e,t,s,n,i,r,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(n,r,a):t.prototype&&t.prototype.isPureReactComponent?!Ql(s,n)||!Ql(i,r):!0}function Ox(e,t,s){var n=!1,i=wr,r=t.contextType;return typeof r=="object"&&r!==null?r=kn(r):(i=Ys(t)?no:js.current,n=t.contextTypes,r=(n=n!=null)?fa(e,i):wr),t=new t(s,r),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=nd,e.stateNode=t,t._reactInternals=e,n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=r),t}function Av(e,t,s,n){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,n),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,n),t.state!==e&&nd.enqueueReplaceState(t,t.state,null)}function jp(e,t,s,n){var i=e.stateNode;i.props=s,i.state=e.memoizedState,i.refs={},Dg(e);var r=t.contextType;typeof r=="object"&&r!==null?i.context=kn(r):(r=Ys(t)?no:js.current,i.context=fa(e,r)),i.state=e.memoizedState,r=t.getDerivedStateFromProps,typeof r=="function"&&(Rp(e,t,r,s),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&nd.enqueueReplaceState(i,i.state,null),fh(e,s,i,n),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function _a(e,t){try{var s="",n=t;do s+=lE(n),n=n.return;while(n);var i=s}catch(r){i=`
39
+ Error generating stack: `+r.message+`
40
+ `+r.stack}return{value:e,source:t,stack:i,digest:null}}function ef(e,t,s){return{value:e,source:null,stack:s??null,digest:t??null}}function Tp(e,t){try{console.error(t.value)}catch(s){setTimeout(function(){throw s})}}var P2=typeof WeakMap=="function"?WeakMap:Map;function Bx(e,t,s){s=Ni(-1,s),s.tag=3,s.payload={element:null};var n=t.value;return s.callback=function(){vh||(vh=!0,Fp=n),Tp(e,t)},s}function $x(e,t,s){s=Ni(-1,s),s.tag=3;var n=e.type.getDerivedStateFromError;if(typeof n=="function"){var i=t.value;s.payload=function(){return n(i)},s.callback=function(){Tp(e,t)}}var r=e.stateNode;return r!==null&&typeof r.componentDidCatch=="function"&&(s.callback=function(){Tp(e,t),typeof n!="function"&&(gr===null?gr=new Set([this]):gr.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),s}function Mv(e,t,s){var n=e.pingCache;if(n===null){n=e.pingCache=new P2;var i=new Set;n.set(t,i)}else i=n.get(t),i===void 0&&(i=new Set,n.set(t,i));i.has(s)||(i.add(s),e=G2.bind(null,e,t,s),t.then(e,e))}function Dv(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 Iv(e,t,s,n,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,s.flags|=131072,s.flags&=-52805,s.tag===1&&(s.alternate===null?s.tag=17:(t=Ni(-1,1),t.tag=2,mr(s,t,1))),s.lanes|=1),e)}var L2=Pi.ReactCurrentOwner,qs=!1;function Ps(e,t,s,n){t.child=e===null?px(t,null,s,n):ma(t,e.child,s,n)}function Pv(e,t,s,n,i){s=s.render;var r=t.ref;return aa(t,i),n=Bg(e,t,s,n,r,i),s=$g(),e!==null&&!qs?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Ii(e,t,i)):(wt&&s&&Eg(t),t.flags|=1,Ps(e,t,n,i),t.child)}function Lv(e,t,s,n,i){if(e===null){var r=s.type;return typeof r=="function"&&!Gg(r)&&r.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(t.tag=15,t.type=r,Fx(e,t,r,n,i)):(e=Hu(s.type,null,n,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(r=e.child,!(e.lanes&i)){var a=r.memoizedProps;if(s=s.compare,s=s!==null?s:Ql,s(a,n)&&e.ref===t.ref)return Ii(e,t,i)}return t.flags|=1,e=vr(r,n),e.ref=t.ref,e.return=t,t.child=e}function Fx(e,t,s,n,i){if(e!==null){var r=e.memoizedProps;if(Ql(r,n)&&e.ref===t.ref)if(qs=!1,t.pendingProps=n=r,(e.lanes&i)!==0)e.flags&131072&&(qs=!0);else return t.lanes=e.lanes,Ii(e,t,i)}return Ap(e,t,s,n,i)}function zx(e,t,s){var n=t.pendingProps,i=n.children,r=e!==null?e.memoizedState:null;if(n.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},pt(ea,sn),sn|=s;else{if(!(s&1073741824))return e=r!==null?r.baseLanes|s:s,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,pt(ea,sn),sn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},n=r!==null?r.baseLanes:s,pt(ea,sn),sn|=n}else r!==null?(n=r.baseLanes|s,t.memoizedState=null):n=s,pt(ea,sn),sn|=n;return Ps(e,t,i,s),t.child}function Hx(e,t){var s=t.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(t.flags|=512,t.flags|=2097152)}function Ap(e,t,s,n,i){var r=Ys(s)?no:js.current;return r=fa(t,r),aa(t,i),s=Bg(e,t,s,n,r,i),n=$g(),e!==null&&!qs?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Ii(e,t,i)):(wt&&n&&Eg(t),t.flags|=1,Ps(e,t,s,i),t.child)}function Ov(e,t,s,n,i){if(Ys(s)){var r=!0;lh(t)}else r=!1;if(aa(t,i),t.stateNode===null)$u(e,t),Ox(t,s,n),jp(t,s,n,i),n=!0;else if(e===null){var a=t.stateNode,l=t.memoizedProps;a.props=l;var c=a.context,u=s.contextType;typeof u=="object"&&u!==null?u=kn(u):(u=Ys(s)?no:js.current,u=fa(t,u));var h=s.getDerivedStateFromProps,d=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function";d||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==n||c!==u)&&Av(t,a,n,u),Qi=!1;var p=t.memoizedState;a.state=p,fh(t,n,a,i),c=t.memoizedState,l!==n||p!==c||Vs.current||Qi?(typeof h=="function"&&(Rp(t,s,h,n),c=t.memoizedState),(l=Qi||Tv(t,s,l,n,p,c,u))?(d||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=n,t.memoizedState=c),a.props=n,a.state=c,a.context=u,n=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),n=!1)}else{a=t.stateNode,gx(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:Pn(t.type,l),a.props=u,d=t.pendingProps,p=a.context,c=s.contextType,typeof c=="object"&&c!==null?c=kn(c):(c=Ys(s)?no:js.current,c=fa(t,c));var f=s.getDerivedStateFromProps;(h=typeof f=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==d||p!==c)&&Av(t,a,n,c),Qi=!1,p=t.memoizedState,a.state=p,fh(t,n,a,i);var m=t.memoizedState;l!==d||p!==m||Vs.current||Qi?(typeof f=="function"&&(Rp(t,s,f,n),m=t.memoizedState),(u=Qi||Tv(t,s,u,n,p,m,c)||!1)?(h||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(n,m,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(n,m,c)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=n,t.memoizedState=m),a.props=n,a.state=m,a.context=c,n=u):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),n=!1)}return Mp(e,t,s,n,r,i)}function Mp(e,t,s,n,i,r){Hx(e,t);var a=(t.flags&128)!==0;if(!n&&!a)return i&&xv(t,s,!1),Ii(e,t,r);n=t.stateNode,L2.current=t;var l=a&&typeof s.getDerivedStateFromError!="function"?null:n.render();return t.flags|=1,e!==null&&a?(t.child=ma(t,e.child,null,r),t.child=ma(t,null,l,r)):Ps(e,t,l,r),t.memoizedState=n.state,i&&xv(t,s,!0),t.child}function Ux(e){var t=e.stateNode;t.pendingContext?wv(e,t.pendingContext,t.pendingContext!==t.context):t.context&&wv(e,t.context,!1),Ig(e,t.containerInfo)}function Bv(e,t,s,n,i){return pa(),Rg(i),t.flags|=256,Ps(e,t,s,n),t.child}var Dp={dehydrated:null,treeContext:null,retryLane:0};function Ip(e){return{baseLanes:e,cachePool:null,transitions:null}}function Wx(e,t,s){var n=t.pendingProps,i=Tt.current,r=!1,a=(t.flags&128)!==0,l;if((l=a)||(l=e!==null&&e.memoizedState===null?!1:(i&2)!==0),l?(r=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),pt(Tt,i&1),e===null)return Ep(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):(a=n.children,e=n.fallback,r?(n=t.mode,r=t.child,a={mode:"hidden",children:a},!(n&1)&&r!==null?(r.childLanes=0,r.pendingProps=a):r=od(a,n,0,null),e=Jr(e,n,s,null),r.return=t,e.return=t,r.sibling=e,t.child=r,t.child.memoizedState=Ip(s),t.memoizedState=Dp,e):Hg(t,a));if(i=e.memoizedState,i!==null&&(l=i.dehydrated,l!==null))return O2(e,t,a,n,l,i,s);if(r){r=n.fallback,a=t.mode,i=e.child,l=i.sibling;var c={mode:"hidden",children:n.children};return!(a&1)&&t.child!==i?(n=t.child,n.childLanes=0,n.pendingProps=c,t.deletions=null):(n=vr(i,c),n.subtreeFlags=i.subtreeFlags&14680064),l!==null?r=vr(l,r):(r=Jr(r,a,s,null),r.flags|=2),r.return=t,n.return=t,n.sibling=r,t.child=n,n=r,r=t.child,a=e.child.memoizedState,a=a===null?Ip(s):{baseLanes:a.baseLanes|s,cachePool:null,transitions:a.transitions},r.memoizedState=a,r.childLanes=e.childLanes&~s,t.memoizedState=Dp,n}return r=e.child,e=r.sibling,n=vr(r,{mode:"visible",children:n.children}),!(t.mode&1)&&(n.lanes=s),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n}function Hg(e,t){return t=od({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function ru(e,t,s,n){return n!==null&&Rg(n),ma(t,e.child,null,s),e=Hg(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function O2(e,t,s,n,i,r,a){if(s)return t.flags&256?(t.flags&=-257,n=ef(Error(ie(422))),ru(e,t,a,n)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(r=n.fallback,i=t.mode,n=od({mode:"visible",children:n.children},i,0,null),r=Jr(r,i,a,null),r.flags|=2,n.return=t,r.return=t,n.sibling=r,t.child=n,t.mode&1&&ma(t,e.child,null,a),t.child.memoizedState=Ip(a),t.memoizedState=Dp,r);if(!(t.mode&1))return ru(e,t,a,null);if(i.data==="$!"){if(n=i.nextSibling&&i.nextSibling.dataset,n)var l=n.dgst;return n=l,r=Error(ie(419)),n=ef(r,n,void 0),ru(e,t,a,n)}if(l=(a&e.childLanes)!==0,qs||l){if(n=cs,n!==null){switch(a&-a){case 4:i=2;break;case 16:i=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:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(n.suspendedLanes|a)?0:i,i!==0&&i!==r.retryLane&&(r.retryLane=i,Di(e,i),Fn(n,e,i,-1))}return Yg(),n=ef(Error(ie(421))),ru(e,t,a,n)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=J2.bind(null,e),i._reactRetry=t,null):(e=r.treeContext,on=pr(i.nextSibling),ln=t,wt=!0,On=null,e!==null&&(vn[yn++]=ki,vn[yn++]=Ci,vn[yn++]=io,ki=e.id,Ci=e.overflow,io=t),t=Hg(t,n.children),t.flags|=4096,t)}function $v(e,t,s){e.lanes|=t;var n=e.alternate;n!==null&&(n.lanes|=t),Np(e.return,t,s)}function tf(e,t,s,n,i){var r=e.memoizedState;r===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:n,tail:s,tailMode:i}:(r.isBackwards=t,r.rendering=null,r.renderingStartTime=0,r.last=n,r.tail=s,r.tailMode=i)}function Kx(e,t,s){var n=t.pendingProps,i=n.revealOrder,r=n.tail;if(Ps(e,t,n.children,s),n=Tt.current,n&2)n=n&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&&$v(e,s,t);else if(e.tag===19)$v(e,s,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}n&=1}if(pt(Tt,n),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(s=t.child,i=null;s!==null;)e=s.alternate,e!==null&&ph(e)===null&&(i=s),s=s.sibling;s=i,s===null?(i=t.child,t.child=null):(i=s.sibling,s.sibling=null),tf(t,!1,i,s,r);break;case"backwards":for(s=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&ph(e)===null){t.child=i;break}e=i.sibling,i.sibling=s,s=i,i=e}tf(t,!0,s,null,r);break;case"together":tf(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function $u(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Ii(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),oo|=t.lanes,!(s&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(ie(153));if(t.child!==null){for(e=t.child,s=vr(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=vr(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function B2(e,t,s){switch(t.tag){case 3:Ux(t),pa();break;case 5:_x(t);break;case 1:Ys(t.type)&&lh(t);break;case 4:Ig(t,t.stateNode.containerInfo);break;case 10:var n=t.type._context,i=t.memoizedProps.value;pt(hh,n._currentValue),n._currentValue=i;break;case 13:if(n=t.memoizedState,n!==null)return n.dehydrated!==null?(pt(Tt,Tt.current&1),t.flags|=128,null):s&t.child.childLanes?Wx(e,t,s):(pt(Tt,Tt.current&1),e=Ii(e,t,s),e!==null?e.sibling:null);pt(Tt,Tt.current&1);break;case 19:if(n=(s&t.childLanes)!==0,e.flags&128){if(n)return Kx(e,t,s);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),pt(Tt,Tt.current),n)break;return null;case 22:case 23:return t.lanes=0,zx(e,t,s)}return Ii(e,t,s)}var qx,Pp,Vx,Yx;qx=function(e,t){for(var s=t.child;s!==null;){if(s.tag===5||s.tag===6)e.appendChild(s.stateNode);else if(s.tag!==4&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return;s=s.return}s.sibling.return=s.return,s=s.sibling}};Pp=function(){};Vx=function(e,t,s,n){var i=e.memoizedProps;if(i!==n){e=t.stateNode,qr(oi.current);var r=null;switch(s){case"input":i=np(e,i),n=np(e,n),r=[];break;case"select":i=Mt({},i,{value:void 0}),n=Mt({},n,{value:void 0}),r=[];break;case"textarea":i=op(e,i),n=op(e,n),r=[];break;default:typeof i.onClick!="function"&&typeof n.onClick=="function"&&(e.onclick=oh)}lp(s,n);var a;s=null;for(u in i)if(!n.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var l=i[u];for(a in l)l.hasOwnProperty(a)&&(s||(s={}),s[a]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(ql.hasOwnProperty(u)?r||(r=[]):(r=r||[]).push(u,null));for(u in n){var c=n[u];if(l=i?.[u],n.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(a in l)!l.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(s||(s={}),s[a]="");for(a in c)c.hasOwnProperty(a)&&l[a]!==c[a]&&(s||(s={}),s[a]=c[a])}else s||(r||(r=[]),r.push(u,s)),s=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(r=r||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(r=r||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(ql.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&vt("scroll",e),r||l===c||(r=[])):(r=r||[]).push(u,c))}s&&(r=r||[]).push("style",s);var u=r;(t.updateQueue=u)&&(t.flags|=4)}};Yx=function(e,t,s,n){s!==n&&(t.flags|=4)};function Ja(e,t){if(!wt)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var n=null;s!==null;)s.alternate!==null&&(n=s),s=s.sibling;n===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:n.sibling=null}}function Cs(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,n=0;if(t)for(var i=e.child;i!==null;)s|=i.lanes|i.childLanes,n|=i.subtreeFlags&14680064,n|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)s|=i.lanes|i.childLanes,n|=i.subtreeFlags,n|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=n,e.childLanes=s,t}function $2(e,t,s){var n=t.pendingProps;switch(Ng(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Cs(t),null;case 1:return Ys(t.type)&&ah(),Cs(t),null;case 3:return n=t.stateNode,ga(),bt(Vs),bt(js),Lg(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(nu(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,On!==null&&(Up(On),On=null))),Pp(e,t),Cs(t),null;case 5:Pg(t);var i=qr(ic.current);if(s=t.type,e!==null&&t.stateNode!=null)Vx(e,t,s,n,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!n){if(t.stateNode===null)throw Error(ie(166));return Cs(t),null}if(e=qr(oi.current),nu(t)){n=t.stateNode,s=t.type;var r=t.memoizedProps;switch(n[ei]=t,n[sc]=r,e=(t.mode&1)!==0,s){case"dialog":vt("cancel",n),vt("close",n);break;case"iframe":case"object":case"embed":vt("load",n);break;case"video":case"audio":for(i=0;i<Sl.length;i++)vt(Sl[i],n);break;case"source":vt("error",n);break;case"img":case"image":case"link":vt("error",n),vt("load",n);break;case"details":vt("toggle",n);break;case"input":Y_(n,r),vt("invalid",n);break;case"select":n._wrapperState={wasMultiple:!!r.multiple},vt("invalid",n);break;case"textarea":J_(n,r),vt("invalid",n)}lp(s,r),i=null;for(var a in r)if(r.hasOwnProperty(a)){var l=r[a];a==="children"?typeof l=="string"?n.textContent!==l&&(r.suppressHydrationWarning!==!0&&su(n.textContent,l,e),i=["children",l]):typeof l=="number"&&n.textContent!==""+l&&(r.suppressHydrationWarning!==!0&&su(n.textContent,l,e),i=["children",""+l]):ql.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&vt("scroll",n)}switch(s){case"input":Yc(n),G_(n,r,!0);break;case"textarea":Yc(n),X_(n);break;case"select":case"option":break;default:typeof r.onClick=="function"&&(n.onclick=oh)}n=i,t.updateQueue=n,n!==null&&(t.flags|=4)}else{a=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=xw(s)),e==="http://www.w3.org/1999/xhtml"?s==="script"?(e=a.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof n.is=="string"?e=a.createElement(s,{is:n.is}):(e=a.createElement(s),s==="select"&&(a=e,n.multiple?a.multiple=!0:n.size&&(a.size=n.size))):e=a.createElementNS(e,s),e[ei]=t,e[sc]=n,qx(e,t,!1,!1),t.stateNode=e;e:{switch(a=cp(s,n),s){case"dialog":vt("cancel",e),vt("close",e),i=n;break;case"iframe":case"object":case"embed":vt("load",e),i=n;break;case"video":case"audio":for(i=0;i<Sl.length;i++)vt(Sl[i],e);i=n;break;case"source":vt("error",e),i=n;break;case"img":case"image":case"link":vt("error",e),vt("load",e),i=n;break;case"details":vt("toggle",e),i=n;break;case"input":Y_(e,n),i=np(e,n),vt("invalid",e);break;case"option":i=n;break;case"select":e._wrapperState={wasMultiple:!!n.multiple},i=Mt({},n,{value:void 0}),vt("invalid",e);break;case"textarea":J_(e,n),i=op(e,n),vt("invalid",e);break;default:i=n}lp(s,i),l=i;for(r in l)if(l.hasOwnProperty(r)){var c=l[r];r==="style"?Cw(e,c):r==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&Sw(e,c)):r==="children"?typeof c=="string"?(s!=="textarea"||c!=="")&&Vl(e,c):typeof c=="number"&&Vl(e,""+c):r!=="suppressContentEditableWarning"&&r!=="suppressHydrationWarning"&&r!=="autoFocus"&&(ql.hasOwnProperty(r)?c!=null&&r==="onScroll"&&vt("scroll",e):c!=null&&dg(e,r,c,a))}switch(s){case"input":Yc(e),G_(e,n,!1);break;case"textarea":Yc(e),X_(e);break;case"option":n.value!=null&&e.setAttribute("value",""+br(n.value));break;case"select":e.multiple=!!n.multiple,r=n.value,r!=null?na(e,!!n.multiple,r,!1):n.defaultValue!=null&&na(e,!!n.multiple,n.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=oh)}switch(s){case"button":case"input":case"select":case"textarea":n=!!n.autoFocus;break e;case"img":n=!0;break e;default:n=!1}}n&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Cs(t),null;case 6:if(e&&t.stateNode!=null)Yx(e,t,e.memoizedProps,n);else{if(typeof n!="string"&&t.stateNode===null)throw Error(ie(166));if(s=qr(ic.current),qr(oi.current),nu(t)){if(n=t.stateNode,s=t.memoizedProps,n[ei]=t,(r=n.nodeValue!==s)&&(e=ln,e!==null))switch(e.tag){case 3:su(n.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&su(n.nodeValue,s,(e.mode&1)!==0)}r&&(t.flags|=4)}else n=(s.nodeType===9?s:s.ownerDocument).createTextNode(n),n[ei]=t,t.stateNode=n}return Cs(t),null;case 13:if(bt(Tt),n=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(wt&&on!==null&&t.mode&1&&!(t.flags&128))dx(),pa(),t.flags|=98560,r=!1;else if(r=nu(t),n!==null&&n.dehydrated!==null){if(e===null){if(!r)throw Error(ie(318));if(r=t.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(ie(317));r[ei]=t}else pa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Cs(t),r=!1}else On!==null&&(Up(On),On=null),r=!0;if(!r)return t.flags&65536?t:null}return t.flags&128?(t.lanes=s,t):(n=n!==null,n!==(e!==null&&e.memoizedState!==null)&&n&&(t.child.flags|=8192,t.mode&1&&(e===null||Tt.current&1?es===0&&(es=3):Yg())),t.updateQueue!==null&&(t.flags|=4),Cs(t),null);case 4:return ga(),Pp(e,t),e===null&&ec(t.stateNode.containerInfo),Cs(t),null;case 10:return Ag(t.type._context),Cs(t),null;case 17:return Ys(t.type)&&ah(),Cs(t),null;case 19:if(bt(Tt),r=t.memoizedState,r===null)return Cs(t),null;if(n=(t.flags&128)!==0,a=r.rendering,a===null)if(n)Ja(r,!1);else{if(es!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=ph(e),a!==null){for(t.flags|=128,Ja(r,!1),n=a.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),t.subtreeFlags=0,n=s,s=t.child;s!==null;)r=s,e=n,r.flags&=14680066,a=r.alternate,a===null?(r.childLanes=0,r.lanes=e,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=a.childLanes,r.lanes=a.lanes,r.child=a.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=a.memoizedProps,r.memoizedState=a.memoizedState,r.updateQueue=a.updateQueue,r.type=a.type,e=a.dependencies,r.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),s=s.sibling;return pt(Tt,Tt.current&1|2),t.child}e=e.sibling}r.tail!==null&&zt()>va&&(t.flags|=128,n=!0,Ja(r,!1),t.lanes=4194304)}else{if(!n)if(e=ph(a),e!==null){if(t.flags|=128,n=!0,s=e.updateQueue,s!==null&&(t.updateQueue=s,t.flags|=4),Ja(r,!0),r.tail===null&&r.tailMode==="hidden"&&!a.alternate&&!wt)return Cs(t),null}else 2*zt()-r.renderingStartTime>va&&s!==1073741824&&(t.flags|=128,n=!0,Ja(r,!1),t.lanes=4194304);r.isBackwards?(a.sibling=t.child,t.child=a):(s=r.last,s!==null?s.sibling=a:t.child=a,r.last=a)}return r.tail!==null?(t=r.tail,r.rendering=t,r.tail=t.sibling,r.renderingStartTime=zt(),t.sibling=null,s=Tt.current,pt(Tt,n?s&1|2:s&1),t):(Cs(t),null);case 22:case 23:return Vg(),n=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==n&&(t.flags|=8192),n&&t.mode&1?sn&1073741824&&(Cs(t),t.subtreeFlags&6&&(t.flags|=8192)):Cs(t),null;case 24:return null;case 25:return null}throw Error(ie(156,t.tag))}function F2(e,t){switch(Ng(t),t.tag){case 1:return Ys(t.type)&&ah(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ga(),bt(Vs),bt(js),Lg(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Pg(t),null;case 13:if(bt(Tt),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(ie(340));pa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return bt(Tt),null;case 4:return ga(),null;case 10:return Ag(t.type._context),null;case 22:case 23:return Vg(),null;case 24:return null;default:return null}}var ou=!1,Rs=!1,z2=typeof WeakSet=="function"?WeakSet:Set,we=null;function Qo(e,t){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(n){Pt(e,t,n)}else s.current=null}function Lp(e,t,s){try{s()}catch(n){Pt(e,t,n)}}var Fv=!1;function H2(e,t){if(yp=nh,e=Qw(),Cg(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var n=s.getSelection&&s.getSelection();if(n&&n.rangeCount!==0){s=n.anchorNode;var i=n.anchorOffset,r=n.focusNode;n=n.focusOffset;try{s.nodeType,r.nodeType}catch{s=null;break e}var a=0,l=-1,c=-1,u=0,h=0,d=e,p=null;t:for(;;){for(var f;d!==s||i!==0&&d.nodeType!==3||(l=a+i),d!==r||n!==0&&d.nodeType!==3||(c=a+n),d.nodeType===3&&(a+=d.nodeValue.length),(f=d.firstChild)!==null;)p=d,d=f;for(;;){if(d===e)break t;if(p===s&&++u===i&&(l=a),p===r&&++h===n&&(c=a),(f=d.nextSibling)!==null)break;d=p,p=d.parentNode}d=f}s=l===-1||c===-1?null:{start:l,end:c}}else s=null}s=s||{start:0,end:0}}else s=null;for(bp={focusedElem:e,selectionRange:s},nh=!1,we=t;we!==null;)if(t=we,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,we=e;else for(;we!==null;){t=we;try{var m=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(m!==null){var b=m.memoizedProps,_=m.memoizedState,v=t.stateNode,y=v.getSnapshotBeforeUpdate(t.elementType===t.type?b:Pn(t.type,b),_);v.__reactInternalSnapshotBeforeUpdate=y}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(ie(163))}}catch(x){Pt(t,t.return,x)}if(e=t.sibling,e!==null){e.return=t.return,we=e;break}we=t.return}return m=Fv,Fv=!1,m}function Ol(e,t,s){var n=t.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var r=i.destroy;i.destroy=void 0,r!==void 0&&Lp(t,s,r)}i=i.next}while(i!==n)}}function id(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var s=t=t.next;do{if((s.tag&e)===e){var n=s.create;s.destroy=n()}s=s.next}while(s!==t)}}function Op(e){var t=e.ref;if(t!==null){var s=e.stateNode;switch(e.tag){case 5:e=s;break;default:e=s}typeof t=="function"?t(e):t.current=e}}function Gx(e){var t=e.alternate;t!==null&&(e.alternate=null,Gx(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ei],delete t[sc],delete t[Sp],delete t[k2],delete t[C2])),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 Jx(e){return e.tag===5||e.tag===3||e.tag===4}function zv(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Jx(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 Bp(e,t,s){var n=e.tag;if(n===5||n===6)e=e.stateNode,t?s.nodeType===8?s.parentNode.insertBefore(e,t):s.insertBefore(e,t):(s.nodeType===8?(t=s.parentNode,t.insertBefore(e,s)):(t=s,t.appendChild(e)),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=oh));else if(n!==4&&(e=e.child,e!==null))for(Bp(e,t,s),e=e.sibling;e!==null;)Bp(e,t,s),e=e.sibling}function $p(e,t,s){var n=e.tag;if(n===5||n===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(n!==4&&(e=e.child,e!==null))for($p(e,t,s),e=e.sibling;e!==null;)$p(e,t,s),e=e.sibling}var gs=null,Ln=!1;function Ki(e,t,s){for(s=s.child;s!==null;)Xx(e,t,s),s=s.sibling}function Xx(e,t,s){if(ri&&typeof ri.onCommitFiberUnmount=="function")try{ri.onCommitFiberUnmount(Jh,s)}catch{}switch(s.tag){case 5:Rs||Qo(s,t);case 6:var n=gs,i=Ln;gs=null,Ki(e,t,s),gs=n,Ln=i,gs!==null&&(Ln?(e=gs,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):gs.removeChild(s.stateNode));break;case 18:gs!==null&&(Ln?(e=gs,s=s.stateNode,e.nodeType===8?Yd(e.parentNode,s):e.nodeType===1&&Yd(e,s),Xl(e)):Yd(gs,s.stateNode));break;case 4:n=gs,i=Ln,gs=s.stateNode.containerInfo,Ln=!0,Ki(e,t,s),gs=n,Ln=i;break;case 0:case 11:case 14:case 15:if(!Rs&&(n=s.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){i=n=n.next;do{var r=i,a=r.destroy;r=r.tag,a!==void 0&&(r&2||r&4)&&Lp(s,t,a),i=i.next}while(i!==n)}Ki(e,t,s);break;case 1:if(!Rs&&(Qo(s,t),n=s.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=s.memoizedProps,n.state=s.memoizedState,n.componentWillUnmount()}catch(l){Pt(s,t,l)}Ki(e,t,s);break;case 21:Ki(e,t,s);break;case 22:s.mode&1?(Rs=(n=Rs)||s.memoizedState!==null,Ki(e,t,s),Rs=n):Ki(e,t,s);break;default:Ki(e,t,s)}}function Hv(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new z2),t.forEach(function(n){var i=X2.bind(null,e,n);s.has(n)||(s.add(n),n.then(i,i))})}}function Dn(e,t){var s=t.deletions;if(s!==null)for(var n=0;n<s.length;n++){var i=s[n];try{var r=e,a=t,l=a;e:for(;l!==null;){switch(l.tag){case 5:gs=l.stateNode,Ln=!1;break e;case 3:gs=l.stateNode.containerInfo,Ln=!0;break e;case 4:gs=l.stateNode.containerInfo,Ln=!0;break e}l=l.return}if(gs===null)throw Error(ie(160));Xx(r,a,i),gs=null,Ln=!1;var c=i.alternate;c!==null&&(c.return=null),i.return=null}catch(u){Pt(i,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Zx(t,e),t=t.sibling}function Zx(e,t){var s=e.alternate,n=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Dn(t,e),Gn(e),n&4){try{Ol(3,e,e.return),id(3,e)}catch(b){Pt(e,e.return,b)}try{Ol(5,e,e.return)}catch(b){Pt(e,e.return,b)}}break;case 1:Dn(t,e),Gn(e),n&512&&s!==null&&Qo(s,s.return);break;case 5:if(Dn(t,e),Gn(e),n&512&&s!==null&&Qo(s,s.return),e.flags&32){var i=e.stateNode;try{Vl(i,"")}catch(b){Pt(e,e.return,b)}}if(n&4&&(i=e.stateNode,i!=null)){var r=e.memoizedProps,a=s!==null?s.memoizedProps:r,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&r.type==="radio"&&r.name!=null&&bw(i,r),cp(l,a);var u=cp(l,r);for(a=0;a<c.length;a+=2){var h=c[a],d=c[a+1];h==="style"?Cw(i,d):h==="dangerouslySetInnerHTML"?Sw(i,d):h==="children"?Vl(i,d):dg(i,h,d,u)}switch(l){case"input":ip(i,r);break;case"textarea":ww(i,r);break;case"select":var p=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!r.multiple;var f=r.value;f!=null?na(i,!!r.multiple,f,!1):p!==!!r.multiple&&(r.defaultValue!=null?na(i,!!r.multiple,r.defaultValue,!0):na(i,!!r.multiple,r.multiple?[]:"",!1))}i[sc]=r}catch(b){Pt(e,e.return,b)}}break;case 6:if(Dn(t,e),Gn(e),n&4){if(e.stateNode===null)throw Error(ie(162));i=e.stateNode,r=e.memoizedProps;try{i.nodeValue=r}catch(b){Pt(e,e.return,b)}}break;case 3:if(Dn(t,e),Gn(e),n&4&&s!==null&&s.memoizedState.isDehydrated)try{Xl(t.containerInfo)}catch(b){Pt(e,e.return,b)}break;case 4:Dn(t,e),Gn(e);break;case 13:Dn(t,e),Gn(e),i=e.child,i.flags&8192&&(r=i.memoizedState!==null,i.stateNode.isHidden=r,!r||i.alternate!==null&&i.alternate.memoizedState!==null||(Kg=zt())),n&4&&Hv(e);break;case 22:if(h=s!==null&&s.memoizedState!==null,e.mode&1?(Rs=(u=Rs)||h,Dn(t,e),Rs=u):Dn(t,e),Gn(e),n&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!h&&e.mode&1)for(we=e,h=e.child;h!==null;){for(d=we=h;we!==null;){switch(p=we,f=p.child,p.tag){case 0:case 11:case 14:case 15:Ol(4,p,p.return);break;case 1:Qo(p,p.return);var m=p.stateNode;if(typeof m.componentWillUnmount=="function"){n=p,s=p.return;try{t=n,m.props=t.memoizedProps,m.state=t.memoizedState,m.componentWillUnmount()}catch(b){Pt(n,s,b)}}break;case 5:Qo(p,p.return);break;case 22:if(p.memoizedState!==null){Wv(d);continue}}f!==null?(f.return=p,we=f):Wv(d)}h=h.sibling}e:for(h=null,d=e;;){if(d.tag===5){if(h===null){h=d;try{i=d.stateNode,u?(r=i.style,typeof r.setProperty=="function"?r.setProperty("display","none","important"):r.display="none"):(l=d.stateNode,c=d.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=kw("display",a))}catch(b){Pt(e,e.return,b)}}}else if(d.tag===6){if(h===null)try{d.stateNode.nodeValue=u?"":d.memoizedProps}catch(b){Pt(e,e.return,b)}}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;h===d&&(h=null),d=d.return}h===d&&(h=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:Dn(t,e),Gn(e),n&4&&Hv(e);break;case 21:break;default:Dn(t,e),Gn(e)}}function Gn(e){var t=e.flags;if(t&2){try{e:{for(var s=e.return;s!==null;){if(Jx(s)){var n=s;break e}s=s.return}throw Error(ie(160))}switch(n.tag){case 5:var i=n.stateNode;n.flags&32&&(Vl(i,""),n.flags&=-33);var r=zv(e);$p(e,r,i);break;case 3:case 4:var a=n.stateNode.containerInfo,l=zv(e);Bp(e,l,a);break;default:throw Error(ie(161))}}catch(c){Pt(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function U2(e,t,s){we=e,Qx(e)}function Qx(e,t,s){for(var n=(e.mode&1)!==0;we!==null;){var i=we,r=i.child;if(i.tag===22&&n){var a=i.memoizedState!==null||ou;if(!a){var l=i.alternate,c=l!==null&&l.memoizedState!==null||Rs;l=ou;var u=Rs;if(ou=a,(Rs=c)&&!u)for(we=i;we!==null;)a=we,c=a.child,a.tag===22&&a.memoizedState!==null?Kv(i):c!==null?(c.return=a,we=c):Kv(i);for(;r!==null;)we=r,Qx(r),r=r.sibling;we=i,ou=l,Rs=u}Uv(e)}else i.subtreeFlags&8772&&r!==null?(r.return=i,we=r):Uv(e)}}function Uv(e){for(;we!==null;){var t=we;if(t.flags&8772){var s=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Rs||id(5,t);break;case 1:var n=t.stateNode;if(t.flags&4&&!Rs)if(s===null)n.componentDidMount();else{var i=t.elementType===t.type?s.memoizedProps:Pn(t.type,s.memoizedProps);n.componentDidUpdate(i,s.memoizedState,n.__reactInternalSnapshotBeforeUpdate)}var r=t.updateQueue;r!==null&&Nv(t,r,n);break;case 3:var a=t.updateQueue;if(a!==null){if(s=null,t.child!==null)switch(t.child.tag){case 5:s=t.child.stateNode;break;case 1:s=t.child.stateNode}Nv(t,a,s)}break;case 5:var l=t.stateNode;if(s===null&&t.flags&4){s=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&s.focus();break;case"img":c.src&&(s.src=c.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 h=u.memoizedState;if(h!==null){var d=h.dehydrated;d!==null&&Xl(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(ie(163))}Rs||t.flags&512&&Op(t)}catch(p){Pt(t,t.return,p)}}if(t===e){we=null;break}if(s=t.sibling,s!==null){s.return=t.return,we=s;break}we=t.return}}function Wv(e){for(;we!==null;){var t=we;if(t===e){we=null;break}var s=t.sibling;if(s!==null){s.return=t.return,we=s;break}we=t.return}}function Kv(e){for(;we!==null;){var t=we;try{switch(t.tag){case 0:case 11:case 15:var s=t.return;try{id(4,t)}catch(c){Pt(t,s,c)}break;case 1:var n=t.stateNode;if(typeof n.componentDidMount=="function"){var i=t.return;try{n.componentDidMount()}catch(c){Pt(t,i,c)}}var r=t.return;try{Op(t)}catch(c){Pt(t,r,c)}break;case 5:var a=t.return;try{Op(t)}catch(c){Pt(t,a,c)}}}catch(c){Pt(t,t.return,c)}if(t===e){we=null;break}var l=t.sibling;if(l!==null){l.return=t.return,we=l;break}we=t.return}}var W2=Math.ceil,_h=Pi.ReactCurrentDispatcher,Ug=Pi.ReactCurrentOwner,xn=Pi.ReactCurrentBatchConfig,it=0,cs=null,Yt=null,ys=0,sn=0,ea=Cr(0),es=0,lc=null,oo=0,rd=0,Wg=0,Bl=null,Ws=null,Kg=0,va=1/0,bi=null,vh=!1,Fp=null,gr=null,au=!1,ar=null,yh=0,$l=0,zp=null,Fu=-1,zu=0;function Ls(){return it&6?zt():Fu!==-1?Fu:Fu=zt()}function _r(e){return e.mode&1?it&2&&ys!==0?ys&-ys:N2.transition!==null?(zu===0&&(zu=Ow()),zu):(e=ct,e!==0||(e=window.event,e=e===void 0?16:Ww(e.type)),e):1}function Fn(e,t,s,n){if(50<$l)throw $l=0,zp=null,Error(ie(185));Ec(e,s,n),(!(it&2)||e!==cs)&&(e===cs&&(!(it&2)&&(rd|=s),es===4&&ir(e,ys)),Gs(e,n),s===1&&it===0&&!(t.mode&1)&&(va=zt()+500,td&&Er()))}function Gs(e,t){var s=e.callbackNode;NE(e,t);var n=sh(e,e===cs?ys:0);if(n===0)s!==null&&ev(s),e.callbackNode=null,e.callbackPriority=0;else if(t=n&-n,e.callbackPriority!==t){if(s!=null&&ev(s),t===1)e.tag===0?E2(qv.bind(null,e)):cx(qv.bind(null,e)),x2(function(){!(it&6)&&Er()}),s=null;else{switch(Bw(n)){case 1:s=_g;break;case 4:s=Pw;break;case 16:s=th;break;case 536870912:s=Lw;break;default:s=th}s=aS(s,eS.bind(null,e))}e.callbackPriority=t,e.callbackNode=s}}function eS(e,t){if(Fu=-1,zu=0,it&6)throw Error(ie(327));var s=e.callbackNode;if(la()&&e.callbackNode!==s)return null;var n=sh(e,e===cs?ys:0);if(n===0)return null;if(n&30||n&e.expiredLanes||t)t=bh(e,n);else{t=n;var i=it;it|=2;var r=sS();(cs!==e||ys!==t)&&(bi=null,va=zt()+500,Gr(e,t));do try{V2();break}catch(l){tS(e,l)}while(!0);Tg(),_h.current=r,it=i,Yt!==null?t=0:(cs=null,ys=0,t=es)}if(t!==0){if(t===2&&(i=pp(e),i!==0&&(n=i,t=Hp(e,i))),t===1)throw s=lc,Gr(e,0),ir(e,n),Gs(e,zt()),s;if(t===6)ir(e,n);else{if(i=e.current.alternate,!(n&30)&&!K2(i)&&(t=bh(e,n),t===2&&(r=pp(e),r!==0&&(n=r,t=Hp(e,r))),t===1))throw s=lc,Gr(e,0),ir(e,n),Gs(e,zt()),s;switch(e.finishedWork=i,e.finishedLanes=n,t){case 0:case 1:throw Error(ie(345));case 2:Fr(e,Ws,bi);break;case 3:if(ir(e,n),(n&130023424)===n&&(t=Kg+500-zt(),10<t)){if(sh(e,0)!==0)break;if(i=e.suspendedLanes,(i&n)!==n){Ls(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=xp(Fr.bind(null,e,Ws,bi),t);break}Fr(e,Ws,bi);break;case 4:if(ir(e,n),(n&4194240)===n)break;for(t=e.eventTimes,i=-1;0<n;){var a=31-$n(n);r=1<<a,a=t[a],a>i&&(i=a),n&=~r}if(n=i,n=zt()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*W2(n/1960))-n,10<n){e.timeoutHandle=xp(Fr.bind(null,e,Ws,bi),n);break}Fr(e,Ws,bi);break;case 5:Fr(e,Ws,bi);break;default:throw Error(ie(329))}}}return Gs(e,zt()),e.callbackNode===s?eS.bind(null,e):null}function Hp(e,t){var s=Bl;return e.current.memoizedState.isDehydrated&&(Gr(e,t).flags|=256),e=bh(e,t),e!==2&&(t=Ws,Ws=s,t!==null&&Up(t)),e}function Up(e){Ws===null?Ws=e:Ws.push.apply(Ws,e)}function K2(e){for(var t=e;;){if(t.flags&16384){var s=t.updateQueue;if(s!==null&&(s=s.stores,s!==null))for(var n=0;n<s.length;n++){var i=s[n],r=i.getSnapshot;i=i.value;try{if(!Hn(r(),i))return!1}catch{return!1}}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;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 ir(e,t){for(t&=~Wg,t&=~rd,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var s=31-$n(t),n=1<<s;e[s]=-1,t&=~n}}function qv(e){if(it&6)throw Error(ie(327));la();var t=sh(e,0);if(!(t&1))return Gs(e,zt()),null;var s=bh(e,t);if(e.tag!==0&&s===2){var n=pp(e);n!==0&&(t=n,s=Hp(e,n))}if(s===1)throw s=lc,Gr(e,0),ir(e,t),Gs(e,zt()),s;if(s===6)throw Error(ie(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Fr(e,Ws,bi),Gs(e,zt()),null}function qg(e,t){var s=it;it|=1;try{return e(t)}finally{it=s,it===0&&(va=zt()+500,td&&Er())}}function ao(e){ar!==null&&ar.tag===0&&!(it&6)&&la();var t=it;it|=1;var s=xn.transition,n=ct;try{if(xn.transition=null,ct=1,e)return e()}finally{ct=n,xn.transition=s,it=t,!(it&6)&&Er()}}function Vg(){sn=ea.current,bt(ea)}function Gr(e,t){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,w2(s)),Yt!==null)for(s=Yt.return;s!==null;){var n=s;switch(Ng(n),n.tag){case 1:n=n.type.childContextTypes,n!=null&&ah();break;case 3:ga(),bt(Vs),bt(js),Lg();break;case 5:Pg(n);break;case 4:ga();break;case 13:bt(Tt);break;case 19:bt(Tt);break;case 10:Ag(n.type._context);break;case 22:case 23:Vg()}s=s.return}if(cs=e,Yt=e=vr(e.current,null),ys=sn=t,es=0,lc=null,Wg=rd=oo=0,Ws=Bl=null,Kr!==null){for(t=0;t<Kr.length;t++)if(s=Kr[t],n=s.interleaved,n!==null){s.interleaved=null;var i=n.next,r=s.pending;if(r!==null){var a=r.next;r.next=i,n.next=a}s.pending=n}Kr=null}return e}function tS(e,t){do{var s=Yt;try{if(Tg(),Ou.current=gh,mh){for(var n=At.memoizedState;n!==null;){var i=n.queue;i!==null&&(i.pending=null),n=n.next}mh=!1}if(ro=0,rs=Qt=At=null,Ll=!1,rc=0,Ug.current=null,s===null||s.return===null){es=1,lc=t,Yt=null;break}e:{var r=e,a=s.return,l=s,c=t;if(t=ys,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,h=l,d=h.tag;if(!(h.mode&1)&&(d===0||d===11||d===15)){var p=h.alternate;p?(h.updateQueue=p.updateQueue,h.memoizedState=p.memoizedState,h.lanes=p.lanes):(h.updateQueue=null,h.memoizedState=null)}var f=Dv(a);if(f!==null){f.flags&=-257,Iv(f,a,l,r,t),f.mode&1&&Mv(r,u,t),t=f,c=u;var m=t.updateQueue;if(m===null){var b=new Set;b.add(c),t.updateQueue=b}else m.add(c);break e}else{if(!(t&1)){Mv(r,u,t),Yg();break e}c=Error(ie(426))}}else if(wt&&l.mode&1){var _=Dv(a);if(_!==null){!(_.flags&65536)&&(_.flags|=256),Iv(_,a,l,r,t),Rg(_a(c,l));break e}}r=c=_a(c,l),es!==4&&(es=2),Bl===null?Bl=[r]:Bl.push(r),r=a;do{switch(r.tag){case 3:r.flags|=65536,t&=-t,r.lanes|=t;var v=Bx(r,c,t);Ev(r,v);break e;case 1:l=c;var y=r.type,w=r.stateNode;if(!(r.flags&128)&&(typeof y.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(gr===null||!gr.has(w)))){r.flags|=65536,t&=-t,r.lanes|=t;var x=$x(r,l,t);Ev(r,x);break e}}r=r.return}while(r!==null)}iS(s)}catch(S){t=S,Yt===s&&s!==null&&(Yt=s=s.return);continue}break}while(!0)}function sS(){var e=_h.current;return _h.current=gh,e===null?gh:e}function Yg(){(es===0||es===3||es===2)&&(es=4),cs===null||!(oo&268435455)&&!(rd&268435455)||ir(cs,ys)}function bh(e,t){var s=it;it|=2;var n=sS();(cs!==e||ys!==t)&&(bi=null,Gr(e,t));do try{q2();break}catch(i){tS(e,i)}while(!0);if(Tg(),it=s,_h.current=n,Yt!==null)throw Error(ie(261));return cs=null,ys=0,es}function q2(){for(;Yt!==null;)nS(Yt)}function V2(){for(;Yt!==null&&!vE();)nS(Yt)}function nS(e){var t=oS(e.alternate,e,sn);e.memoizedProps=e.pendingProps,t===null?iS(e):Yt=t,Ug.current=null}function iS(e){var t=e;do{var s=t.alternate;if(e=t.return,t.flags&32768){if(s=F2(s,t),s!==null){s.flags&=32767,Yt=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{es=6,Yt=null;return}}else if(s=$2(s,t,sn),s!==null){Yt=s;return}if(t=t.sibling,t!==null){Yt=t;return}Yt=t=e}while(t!==null);es===0&&(es=5)}function Fr(e,t,s){var n=ct,i=xn.transition;try{xn.transition=null,ct=1,Y2(e,t,s,n)}finally{xn.transition=i,ct=n}return null}function Y2(e,t,s,n){do la();while(ar!==null);if(it&6)throw Error(ie(327));s=e.finishedWork;var i=e.finishedLanes;if(s===null)return null;if(e.finishedWork=null,e.finishedLanes=0,s===e.current)throw Error(ie(177));e.callbackNode=null,e.callbackPriority=0;var r=s.lanes|s.childLanes;if(RE(e,r),e===cs&&(Yt=cs=null,ys=0),!(s.subtreeFlags&2064)&&!(s.flags&2064)||au||(au=!0,aS(th,function(){return la(),null})),r=(s.flags&15990)!==0,s.subtreeFlags&15990||r){r=xn.transition,xn.transition=null;var a=ct;ct=1;var l=it;it|=4,Ug.current=null,H2(e,s),Zx(s,e),p2(bp),nh=!!yp,bp=yp=null,e.current=s,U2(s),yE(),it=l,ct=a,xn.transition=r}else e.current=s;if(au&&(au=!1,ar=e,yh=i),r=e.pendingLanes,r===0&&(gr=null),xE(s.stateNode),Gs(e,zt()),t!==null)for(n=e.onRecoverableError,s=0;s<t.length;s++)i=t[s],n(i.value,{componentStack:i.stack,digest:i.digest});if(vh)throw vh=!1,e=Fp,Fp=null,e;return yh&1&&e.tag!==0&&la(),r=e.pendingLanes,r&1?e===zp?$l++:($l=0,zp=e):$l=0,Er(),null}function la(){if(ar!==null){var e=Bw(yh),t=xn.transition,s=ct;try{if(xn.transition=null,ct=16>e?16:e,ar===null)var n=!1;else{if(e=ar,ar=null,yh=0,it&6)throw Error(ie(331));var i=it;for(it|=4,we=e.current;we!==null;){var r=we,a=r.child;if(we.flags&16){var l=r.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(we=u;we!==null;){var h=we;switch(h.tag){case 0:case 11:case 15:Ol(8,h,r)}var d=h.child;if(d!==null)d.return=h,we=d;else for(;we!==null;){h=we;var p=h.sibling,f=h.return;if(Gx(h),h===u){we=null;break}if(p!==null){p.return=f,we=p;break}we=f}}}var m=r.alternate;if(m!==null){var b=m.child;if(b!==null){m.child=null;do{var _=b.sibling;b.sibling=null,b=_}while(b!==null)}}we=r}}if(r.subtreeFlags&2064&&a!==null)a.return=r,we=a;else e:for(;we!==null;){if(r=we,r.flags&2048)switch(r.tag){case 0:case 11:case 15:Ol(9,r,r.return)}var v=r.sibling;if(v!==null){v.return=r.return,we=v;break e}we=r.return}}var y=e.current;for(we=y;we!==null;){a=we;var w=a.child;if(a.subtreeFlags&2064&&w!==null)w.return=a,we=w;else e:for(a=y;we!==null;){if(l=we,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:id(9,l)}}catch(S){Pt(l,l.return,S)}if(l===a){we=null;break e}var x=l.sibling;if(x!==null){x.return=l.return,we=x;break e}we=l.return}}if(it=i,Er(),ri&&typeof ri.onPostCommitFiberRoot=="function")try{ri.onPostCommitFiberRoot(Jh,e)}catch{}n=!0}return n}finally{ct=s,xn.transition=t}}return!1}function Vv(e,t,s){t=_a(s,t),t=Bx(e,t,1),e=mr(e,t,1),t=Ls(),e!==null&&(Ec(e,1,t),Gs(e,t))}function Pt(e,t,s){if(e.tag===3)Vv(e,e,s);else for(;t!==null;){if(t.tag===3){Vv(t,e,s);break}else if(t.tag===1){var n=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof n.componentDidCatch=="function"&&(gr===null||!gr.has(n))){e=_a(s,e),e=$x(t,e,1),t=mr(t,e,1),e=Ls(),t!==null&&(Ec(t,1,e),Gs(t,e));break}}t=t.return}}function G2(e,t,s){var n=e.pingCache;n!==null&&n.delete(t),t=Ls(),e.pingedLanes|=e.suspendedLanes&s,cs===e&&(ys&s)===s&&(es===4||es===3&&(ys&130023424)===ys&&500>zt()-Kg?Gr(e,0):Wg|=s),Gs(e,t)}function rS(e,t){t===0&&(e.mode&1?(t=Xc,Xc<<=1,!(Xc&130023424)&&(Xc=4194304)):t=1);var s=Ls();e=Di(e,t),e!==null&&(Ec(e,t,s),Gs(e,s))}function J2(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),rS(e,s)}function X2(e,t){var s=0;switch(e.tag){case 13:var n=e.stateNode,i=e.memoizedState;i!==null&&(s=i.retryLane);break;case 19:n=e.stateNode;break;default:throw Error(ie(314))}n!==null&&n.delete(t),rS(e,s)}var oS;oS=function(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps||Vs.current)qs=!0;else{if(!(e.lanes&s)&&!(t.flags&128))return qs=!1,B2(e,t,s);qs=!!(e.flags&131072)}else qs=!1,wt&&t.flags&1048576&&ux(t,uh,t.index);switch(t.lanes=0,t.tag){case 2:var n=t.type;$u(e,t),e=t.pendingProps;var i=fa(t,js.current);aa(t,s),i=Bg(null,t,n,e,i,s);var r=$g();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ys(n)?(r=!0,lh(t)):r=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Dg(t),i.updater=nd,t.stateNode=i,i._reactInternals=t,jp(t,n,e,s),t=Mp(null,t,n,!0,r,s)):(t.tag=0,wt&&r&&Eg(t),Ps(null,t,i,s),t=t.child),t;case 16:n=t.elementType;e:{switch($u(e,t),e=t.pendingProps,i=n._init,n=i(n._payload),t.type=n,i=t.tag=Q2(n),e=Pn(n,e),i){case 0:t=Ap(null,t,n,e,s);break e;case 1:t=Ov(null,t,n,e,s);break e;case 11:t=Pv(null,t,n,e,s);break e;case 14:t=Lv(null,t,n,Pn(n.type,e),s);break e}throw Error(ie(306,n,""))}return t;case 0:return n=t.type,i=t.pendingProps,i=t.elementType===n?i:Pn(n,i),Ap(e,t,n,i,s);case 1:return n=t.type,i=t.pendingProps,i=t.elementType===n?i:Pn(n,i),Ov(e,t,n,i,s);case 3:e:{if(Ux(t),e===null)throw Error(ie(387));n=t.pendingProps,r=t.memoizedState,i=r.element,gx(e,t),fh(t,n,null,s);var a=t.memoizedState;if(n=a.element,r.isDehydrated)if(r={element:n,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=r,t.memoizedState=r,t.flags&256){i=_a(Error(ie(423)),t),t=Bv(e,t,n,s,i);break e}else if(n!==i){i=_a(Error(ie(424)),t),t=Bv(e,t,n,s,i);break e}else for(on=pr(t.stateNode.containerInfo.firstChild),ln=t,wt=!0,On=null,s=px(t,null,n,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(pa(),n===i){t=Ii(e,t,s);break e}Ps(e,t,n,s)}t=t.child}return t;case 5:return _x(t),e===null&&Ep(t),n=t.type,i=t.pendingProps,r=e!==null?e.memoizedProps:null,a=i.children,wp(n,i)?a=null:r!==null&&wp(n,r)&&(t.flags|=32),Hx(e,t),Ps(e,t,a,s),t.child;case 6:return e===null&&Ep(t),null;case 13:return Wx(e,t,s);case 4:return Ig(t,t.stateNode.containerInfo),n=t.pendingProps,e===null?t.child=ma(t,null,n,s):Ps(e,t,n,s),t.child;case 11:return n=t.type,i=t.pendingProps,i=t.elementType===n?i:Pn(n,i),Pv(e,t,n,i,s);case 7:return Ps(e,t,t.pendingProps,s),t.child;case 8:return Ps(e,t,t.pendingProps.children,s),t.child;case 12:return Ps(e,t,t.pendingProps.children,s),t.child;case 10:e:{if(n=t.type._context,i=t.pendingProps,r=t.memoizedProps,a=i.value,pt(hh,n._currentValue),n._currentValue=a,r!==null)if(Hn(r.value,a)){if(r.children===i.children&&!Vs.current){t=Ii(e,t,s);break e}}else for(r=t.child,r!==null&&(r.return=t);r!==null;){var l=r.dependencies;if(l!==null){a=r.child;for(var c=l.firstContext;c!==null;){if(c.context===n){if(r.tag===1){c=Ni(-1,s&-s),c.tag=2;var u=r.updateQueue;if(u!==null){u=u.shared;var h=u.pending;h===null?c.next=c:(c.next=h.next,h.next=c),u.pending=c}}r.lanes|=s,c=r.alternate,c!==null&&(c.lanes|=s),Np(r.return,s,t),l.lanes|=s;break}c=c.next}}else if(r.tag===10)a=r.type===t.type?null:r.child;else if(r.tag===18){if(a=r.return,a===null)throw Error(ie(341));a.lanes|=s,l=a.alternate,l!==null&&(l.lanes|=s),Np(a,s,t),a=r.sibling}else a=r.child;if(a!==null)a.return=r;else for(a=r;a!==null;){if(a===t){a=null;break}if(r=a.sibling,r!==null){r.return=a.return,a=r;break}a=a.return}r=a}Ps(e,t,i.children,s),t=t.child}return t;case 9:return i=t.type,n=t.pendingProps.children,aa(t,s),i=kn(i),n=n(i),t.flags|=1,Ps(e,t,n,s),t.child;case 14:return n=t.type,i=Pn(n,t.pendingProps),i=Pn(n.type,i),Lv(e,t,n,i,s);case 15:return Fx(e,t,t.type,t.pendingProps,s);case 17:return n=t.type,i=t.pendingProps,i=t.elementType===n?i:Pn(n,i),$u(e,t),t.tag=1,Ys(n)?(e=!0,lh(t)):e=!1,aa(t,s),Ox(t,n,i),jp(t,n,i,s),Mp(null,t,n,!0,e,s);case 19:return Kx(e,t,s);case 22:return zx(e,t,s)}throw Error(ie(156,t.tag))};function aS(e,t){return Iw(e,t)}function Z2(e,t,s,n){this.tag=e,this.key=s,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=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function wn(e,t,s,n){return new Z2(e,t,s,n)}function Gg(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Q2(e){if(typeof e=="function")return Gg(e)?1:0;if(e!=null){if(e=e.$$typeof,e===pg)return 11;if(e===mg)return 14}return 2}function vr(e,t){var s=e.alternate;return s===null?(s=wn(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&14680064,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s}function Hu(e,t,s,n,i,r){var a=2;if(n=e,typeof e=="function")Gg(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Wo:return Jr(s.children,i,r,t);case fg:a=8,i|=8;break;case Qf:return e=wn(12,s,t,i|2),e.elementType=Qf,e.lanes=r,e;case ep:return e=wn(13,s,t,i),e.elementType=ep,e.lanes=r,e;case tp:return e=wn(19,s,t,i),e.elementType=tp,e.lanes=r,e;case _w:return od(s,i,r,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case mw:a=10;break e;case gw:a=9;break e;case pg:a=11;break e;case mg:a=14;break e;case Zi:a=16,n=null;break e}throw Error(ie(130,e==null?e:typeof e,""))}return t=wn(a,s,t,i),t.elementType=e,t.type=n,t.lanes=r,t}function Jr(e,t,s,n){return e=wn(7,e,n,t),e.lanes=s,e}function od(e,t,s,n){return e=wn(22,e,n,t),e.elementType=_w,e.lanes=s,e.stateNode={isHidden:!1},e}function sf(e,t,s){return e=wn(6,e,null,t),e.lanes=s,e}function nf(e,t,s){return t=wn(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function eN(e,t,s,n,i){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=Od(0),this.expirationTimes=Od(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Od(0),this.identifierPrefix=n,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Jg(e,t,s,n,i,r,a,l,c){return e=new eN(e,t,s,l,c),t===1?(t=1,r===!0&&(t|=8)):t=0,r=wn(3,null,null,t),e.current=r,r.stateNode=e,r.memoizedState={element:n,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},Dg(r),e}function tN(e,t,s){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Uo,key:n==null?null:""+n,children:e,containerInfo:t,implementation:s}}function lS(e){if(!e)return wr;e=e._reactInternals;e:{if(mo(e)!==e||e.tag!==1)throw Error(ie(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Ys(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(ie(171))}if(e.tag===1){var s=e.type;if(Ys(s))return lx(e,s,t)}return t}function cS(e,t,s,n,i,r,a,l,c){return e=Jg(s,n,!0,e,i,r,a,l,c),e.context=lS(null),s=e.current,n=Ls(),i=_r(s),r=Ni(n,i),r.callback=t??null,mr(s,r,i),e.current.lanes=i,Ec(e,i,n),Gs(e,n),e}function ad(e,t,s,n){var i=t.current,r=Ls(),a=_r(i);return s=lS(s),t.context===null?t.context=s:t.pendingContext=s,t=Ni(r,a),t.payload={element:e},n=n===void 0?null:n,n!==null&&(t.callback=n),e=mr(i,t,a),e!==null&&(Fn(e,i,a,r),Lu(e,i,a)),a}function wh(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 Yv(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function Xg(e,t){Yv(e,t),(e=e.alternate)&&Yv(e,t)}function sN(){return null}var uS=typeof reportError=="function"?reportError:function(e){console.error(e)};function Zg(e){this._internalRoot=e}ld.prototype.render=Zg.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(ie(409));ad(e,t,null,null)};ld.prototype.unmount=Zg.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ao(function(){ad(null,e,null,null)}),t[Mi]=null}};function ld(e){this._internalRoot=e}ld.prototype.unstable_scheduleHydration=function(e){if(e){var t=zw();e={blockedOn:null,target:e,priority:t};for(var s=0;s<nr.length&&t!==0&&t<nr[s].priority;s++);nr.splice(s,0,e),s===0&&Uw(e)}};function Qg(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function cd(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Gv(){}function nN(e,t,s,n,i){if(i){if(typeof n=="function"){var r=n;n=function(){var u=wh(a);r.call(u)}}var a=cS(t,n,e,0,null,!1,!1,"",Gv);return e._reactRootContainer=a,e[Mi]=a.current,ec(e.nodeType===8?e.parentNode:e),ao(),a}for(;i=e.lastChild;)e.removeChild(i);if(typeof n=="function"){var l=n;n=function(){var u=wh(c);l.call(u)}}var c=Jg(e,0,!1,null,null,!1,!1,"",Gv);return e._reactRootContainer=c,e[Mi]=c.current,ec(e.nodeType===8?e.parentNode:e),ao(function(){ad(t,c,s,n)}),c}function ud(e,t,s,n,i){var r=s._reactRootContainer;if(r){var a=r;if(typeof i=="function"){var l=i;i=function(){var c=wh(a);l.call(c)}}ad(t,a,e,i)}else a=nN(s,t,e,i,n);return wh(a)}$w=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var s=xl(t.pendingLanes);s!==0&&(vg(t,s|1),Gs(t,zt()),!(it&6)&&(va=zt()+500,Er()))}break;case 13:ao(function(){var n=Di(e,1);if(n!==null){var i=Ls();Fn(n,e,1,i)}}),Xg(e,1)}};yg=function(e){if(e.tag===13){var t=Di(e,134217728);if(t!==null){var s=Ls();Fn(t,e,134217728,s)}Xg(e,134217728)}};Fw=function(e){if(e.tag===13){var t=_r(e),s=Di(e,t);if(s!==null){var n=Ls();Fn(s,e,t,n)}Xg(e,t)}};zw=function(){return ct};Hw=function(e,t){var s=ct;try{return ct=e,t()}finally{ct=s}};hp=function(e,t,s){switch(t){case"input":if(ip(e,s),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<s.length;t++){var n=s[t];if(n!==e&&n.form===e.form){var i=ed(n);if(!i)throw Error(ie(90));yw(n),ip(n,i)}}}break;case"textarea":ww(e,s);break;case"select":t=s.value,t!=null&&na(e,!!s.multiple,t,!1)}};Rw=qg;jw=ao;var iN={usingClientEntryPoint:!1,Events:[Rc,Yo,ed,Ew,Nw,qg]},Xa={findFiberByHostInstance:Wr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},rN={bundleType:Xa.bundleType,version:Xa.version,rendererPackageName:Xa.rendererPackageName,rendererConfig:Xa.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Pi.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Mw(e),e===null?null:e.stateNode},findFiberByHostInstance:Xa.findFiberByHostInstance||sN,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 lu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!lu.isDisabled&&lu.supportsFiber)try{Jh=lu.inject(rN),ri=lu}catch{}}un.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=iN;un.createPortal=function(e,t){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Qg(t))throw Error(ie(200));return tN(e,t,null,s)};un.createRoot=function(e,t){if(!Qg(e))throw Error(ie(299));var s=!1,n="",i=uS;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(n=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=Jg(e,1,!1,null,null,s,!1,n,i),e[Mi]=t.current,ec(e.nodeType===8?e.parentNode:e),new Zg(t)};un.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(ie(188)):(e=Object.keys(e).join(","),Error(ie(268,e)));return e=Mw(t),e=e===null?null:e.stateNode,e};un.flushSync=function(e){return ao(e)};un.hydrate=function(e,t,s){if(!cd(t))throw Error(ie(200));return ud(null,e,t,!0,s)};un.hydrateRoot=function(e,t,s){if(!Qg(e))throw Error(ie(405));var n=s!=null&&s.hydratedSources||null,i=!1,r="",a=uS;if(s!=null&&(s.unstable_strictMode===!0&&(i=!0),s.identifierPrefix!==void 0&&(r=s.identifierPrefix),s.onRecoverableError!==void 0&&(a=s.onRecoverableError)),t=cS(t,null,e,1,s??null,i,!1,r,a),e[Mi]=t.current,ec(e),n)for(e=0;e<n.length;e++)s=n[e],i=s._getVersion,i=i(s._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[s,i]:t.mutableSourceEagerHydrationData.push(s,i);return new ld(t)};un.render=function(e,t,s){if(!cd(t))throw Error(ie(200));return ud(null,e,t,!1,s)};un.unmountComponentAtNode=function(e){if(!cd(e))throw Error(ie(40));return e._reactRootContainer?(ao(function(){ud(null,null,e,!1,function(){e._reactRootContainer=null,e[Mi]=null})}),!0):!1};un.unstable_batchedUpdates=qg;un.unstable_renderSubtreeIntoContainer=function(e,t,s,n){if(!cd(s))throw Error(ie(200));if(e==null||e._reactInternals===void 0)throw Error(ie(38));return ud(e,t,s,!1,n)};un.version="18.3.1-next-f1338f8080-20240426";function hS(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(hS)}catch(e){console.error(e)}}hS(),hw.exports=un;var cc=hw.exports,dS,Jv=cc;dS=Jv.createRoot,Jv.hydrateRoot;const cu=10,Xv=6;function lo(e,t,s){const n=g.useRef(t);n.current=t;const i=g.useRef(s);i.current=s,g.useEffect(()=>{if(!e)return;const r=c=>n.current.some(u=>u.current&&c instanceof Node&&u.current.contains(c)),a=c=>{r(c.target)||i.current()},l=c=>{c.key==="Escape"&&!c.defaultPrevented&&i.current()};return document.addEventListener("pointerdown",a,!0),document.addEventListener("keydown",l),()=>{document.removeEventListener("pointerdown",a,!0),document.removeEventListener("keydown",l)}},[e])}function fS(){const e=g.useRef(null);return g.useLayoutEffect(()=>{const t=e.current;if(!t)return;const s=()=>{if(t.style.top="",t.style.left="",t.style.maxHeight="",window.matchMedia("(max-width: 720px)").matches)return;const n=t.parentElement,i=(n?.firstElementChild??n)?.getBoundingClientRect();if(!i)return;const r=t.getBoundingClientRect().height,a=i.top-cu,l=window.innerHeight-i.bottom-cu,c=l>a,u=Math.min(Math.max(a,l),window.innerHeight*.46);t.style.maxHeight=`${Math.round(u)}px`;const h=Math.min(r,u);t.style.top=`${Math.round(c?i.bottom+Xv:i.top-Xv-h)}px`;const d=t.getBoundingClientRect().width;t.style.left=`${Math.round(Math.min(Math.max(i.left,cu),window.innerWidth-cu-d))}px`;const p=t.querySelector(".tb-opt.sel"),f=p?.closest(".tb-scroll")??t;if(p){const m=p.getBoundingClientRect(),b=f.getBoundingClientRect();m.top<b.top?f.scrollTop-=b.top-m.top+8:m.bottom>b.bottom&&(f.scrollTop+=m.bottom-b.bottom+8)}};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[]),e}function Ta(e,t){const s=g.useRef(t);s.current=t,g.useEffect(()=>{if(!e)return;const n=i=>{i.key==="Escape"&&!i.defaultPrevented&&s.current()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e])}function Te(e,{size:t=16,className:s}){return o.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:s,children:e})}const pS=(e={})=>Te(o.jsx(o.Fragment,{children:o.jsx("path",{d:"M3 6h18M3 12h18M3 18h18"})}),e),oN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"5",r:"1.4"}),o.jsx("circle",{cx:"12",cy:"12",r:"1.4"}),o.jsx("circle",{cx:"12",cy:"19",r:"1.4"})]}),e),mS=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 20h9"}),o.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L8 18l-4 1 1-4z"})]}),e),gS=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"9",y:"9",width:"12",height:"12",rx:"2"}),o.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),e),_S=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 3v11"}),o.jsx("path",{d:"M7 10l5 5 5-5"}),o.jsx("path",{d:"M4 20h16"})]}),e),aN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"3",y:"7",width:"18",height:"13",rx:"2"}),o.jsx("path",{d:"M3 11h18"}),o.jsx("path",{d:"M9 3h6"})]}),e),lN=(e={})=>Te(o.jsx("path",{d:"m4 12.5 5 5L20 6.5"}),e),co=(e={})=>Te(o.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h5l2 2h7a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),e),cN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h5l2 2h7a2 2 0 0 1 2 2v1.4"}),o.jsx("path",{d:"M3 10.4h17.2a1 1 0 0 1 .97 1.24l-1.6 6.06A2 2 0 0 1 17.65 19.2H5a2 2 0 0 1-2-2z"})]}),e),uN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"9",cy:"8",r:"3"}),o.jsx("path",{d:"M3.5 20a5.5 5.5 0 0 1 11 0"}),o.jsx("circle",{cx:"17",cy:"9.2",r:"2.2"}),o.jsx("path",{d:"M16.2 20a4.6 4.6 0 0 1 5.3-3.2"})]}),e),vS=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M3 10.5 12 3l9 7.5"}),o.jsx("path",{d:"M5 9.5V21h14V9.5"})]}),e),yS=(e={})=>Te(o.jsx("path",{d:"M12 3l7 3v5c0 4.5-3 8-7 10-4-2-7-5.5-7-10V6z"}),e),Zv=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M4 17a8 8 0 1 1 16 0"}),o.jsx("path",{d:"M12 17l4-5"})]}),e),hN=(e={})=>Te(o.jsx("path",{d:"M3 12h4l2.5-7 4 14 2.5-7H21"}),e),xh=(e={})=>Te(o.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5",fill:"currentColor",stroke:"none"}),e),En=(e={})=>Te(o.jsx("path",{d:"M6 6l12 12M18 6L6 18"}),e),ya=(e={})=>Te(o.jsx("path",{d:"M6 9l6 6 6-6"}),e),an=(e={})=>Te(o.jsx("path",{d:"M9 6l6 6-6 6"}),e),bS=(e={})=>Te(o.jsx("path",{d:"M12 19V5M6 11l6-6 6 6"}),e),wS=(e={})=>Te(o.jsx("path",{d:"M12 5v14M6 13l6 6 6-6"}),e),Sh=(e={})=>Te(o.jsx("path",{d:"M4 12l16-8-6 8 6 8z"}),e),kh=(e={})=>Te(o.jsx("path",{d:"M12 5v14M5 12h14"}),e),dN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"11",cy:"11",r:"6.5"}),o.jsx("path",{d:"M16 16l4 4"})]}),e),xS=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 4v8"}),o.jsx("path",{d:"M7.5 7a7 7 0 1 0 9 0"})]}),e),rf=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),o.jsx("path",{d:"M3 4v4h4"})]}),e),fN=(e={})=>Te(o.jsx("circle",{cx:"12",cy:"12",r:"4",fill:"currentColor",stroke:"none"}),e),pN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),o.jsx("path",{d:"M15 4v16"})]}),e),mN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),o.jsx("path",{d:"M9 4v16"})]}),e),gN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),o.jsx("path",{d:"M15 4v16"})]}),e),_N=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),o.jsx("path",{d:"m7 9 3 3-3 3M13 15h4"})]}),e),ci=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M6 2h8l4 4v16H6z"}),o.jsx("path",{d:"M14 2v4h4"})]}),e),Ri=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),o.jsx("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6"})]}),e),hd=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M11 5 6 9H3v6h3l5 4z"}),o.jsx("path",{d:"M15.5 8.5a5 5 0 0 1 0 7M18.5 5.5a9 9 0 0 1 0 13"})]}),e),SS=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M11 5 6 9H3v6h3l5 4z"}),o.jsx("path",{d:"m16 9 5 6M21 9l-5 6"})]}),e),kS=o.jsx("path",{d:"M6.6 3.5h1.9c.8 0 1.5.6 1.7 1.4l.7 2.6c.2.8-.1 1.7-.8 2.2l-1.2.8a12.5 12.5 0 0 0 5.6 5.6l.8-1.2c.5-.7 1.4-1 2.2-.8l2.6.7c.8.2 1.4.9 1.4 1.7v1.9c0 1.2-1 2.2-2.2 2.1C11 20.9 3.1 13 3.2 5.7c0-1.2 1-2.2 2.2-2.2z"}),vN=(e={})=>Te(kS,e),yN=(e={})=>Te(o.jsx("g",{transform:"rotate(135 12 12)",children:kS}),e),bN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M9 9v2a3 3 0 0 0 4.6 2.5M15 11.5V6a3 3 0 0 0-5.7-1.3"}),o.jsx("path",{d:"M5 11a7 7 0 0 0 10.8 5.9M19 11v.5"}),o.jsx("path",{d:"M12 18v3M9 21h6"}),o.jsx("path",{d:"m4 4 16 16"})]}),e),wN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),o.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M7 14h10"})]}),e),xN=(e={})=>Te(o.jsx("path",{d:"M20 11.5 12 19.5a5 5 0 0 1-7-7l8-8a3.5 3.5 0 0 1 5 5l-8 8a2 2 0 0 1-3-3l7-7"}),e),Tc=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.jsx("path",{d:"M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-2.9 1.2v.2a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-2.9-1.2l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1A1.7 1.7 0 0 0 3 15a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.2-2.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1A1.7 1.7 0 0 0 10 4.2V4a2 2 0 1 1 4 0v.2a1.7 1.7 0 0 0 2.9 1.2l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1A1.7 1.7 0 0 0 21 11h.2a2 2 0 1 1 0 4H21z"})]}),e),e_=(e={})=>Te(o.jsx("path",{d:"M19 12H5M11 6l-6 6 6 6"}),e),ba=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M20 11a8 8 0 1 0-2 6"}),o.jsx("path",{d:"M20 5v6h-6"})]}),e),SN=(e={})=>Te(o.jsx(o.Fragment,{children:o.jsx("path",{d:"M4 8h13l-3-3M20 16H7l3 3"})}),e),t_=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"7",y:"7",width:"10",height:"10",rx:"2"}),o.jsx("path",{d:"M10 3v4M14 3v4M10 17v4M14 17v4M3 10h4M3 14h4M17 10h4M17 14h4"})]}),e),kN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M9.5 4a2.5 2.5 0 0 1 2.5 2.5v11a2.5 2.5 0 0 1-4.96.44 2.5 2.5 0 0 1-2.96-3.08 3 3 0 0 1-.34-5.58 2.5 2.5 0 0 1 2.26-4.9A2.5 2.5 0 0 1 9.5 4Z"}),o.jsx("path",{d:"M14.5 4A2.5 2.5 0 0 0 12 6.5v11a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-2.26-4.9A2.5 2.5 0 0 0 14.5 4Z"})]}),e),CS=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"7",cy:"5",r:"2"}),o.jsx("circle",{cx:"7",cy:"19",r:"2"}),o.jsx("circle",{cx:"17",cy:"9",r:"2"}),o.jsx("path",{d:"M7 7v10M17 11c0 3-3 4-6 4H9"})]}),e),ES=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M2 12s3.6-6 10-6 10 6 10 6-3.6 6-10 6-10-6-10-6z"}),o.jsx("circle",{cx:"12",cy:"12",r:"2.6"})]}),e),CN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M3 3l18 18"}),o.jsx("path",{d:"M10.6 6.2A9.9 9.9 0 0 1 12 6c6.4 0 10 6 10 6a17 17 0 0 1-2.8 3.3"}),o.jsx("path",{d:"M6.3 7.9A16.5 16.5 0 0 0 2 12s3.6 6 10 6c1.5 0 2.8-.3 4-.8"})]}),e),EN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"3",y:"4",width:"18",height:"12",rx:"2"}),o.jsx("path",{d:"M8 20h8M12 16v4"})]}),e),NN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"4",y:"10",width:"16",height:"10",rx:"2"}),o.jsx("path",{d:"M8 10V7a4 4 0 0 1 8 0v3"})]}),e),RN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M3.5 12a8.5 8.5 0 1 0 2.6-6.1"}),o.jsx("path",{d:"M3 4v4h4"}),o.jsx("path",{d:"M12 8v4.4l3 1.8"})]}),e),jN=(e={})=>Te(o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"2.5",y:"5",width:"19",height:"14",rx:"3.5"}),o.jsx("path",{d:"M6.5 10.5h4.5M13.5 10.5h4M6.5 14h7"})]}),e);function s_(e,t){const s=(e||t||"").trim();if(!s)return"";const n=s.includes("·")?s.split("·").pop().trim():s;return(n.includes(":")?n.split(":").pop().trim():n)||n||s}function Qv(e){const t=i=>i.replace(/[•·|,-]?\s*\b(current|active|selected|default)\b\s*$/i,"").replace(/[•·|,\s-]+$/g,"").trim(),s=/^\s*provider:\s*(.+)$/i.exec(e.description??"");if(s){const i=t(s[1]);if(i)return i}const n=e.modelId.includes(":")?e.modelId.split(":")[0]:e.modelId.includes("/")?e.modelId.split("/")[0]:"";return t(n)||"other"}function TN(e,t){const s=s_(e.name??"",e.modelId),n=`${t}/`;return s.startsWith(n)?s.slice(n.length):s}const AN=12;function NS({models:e,current:t,usage:s={},pending:n=null,onPick:i,bad:r={},err:a=null}){const[l,c]=g.useState(""),[u,h]=g.useState({}),d=fS(),p=g.useMemo(()=>{const f=l.trim().toLowerCase(),m=f?e.filter(w=>`${w.modelId} ${w.name} ${w.description??""}`.toLowerCase().includes(f)):e,b=new Map;for(const w of m){const x=Qv(w),S=b.get(x);S?S.push(w):b.set(x,[w])}const _=e.find(w=>w.modelId===t),v=_?Qv(_):"",y=w=>s[w]??0;return[...b.entries()].map(([w,x])=>{const S=[...x].sort((E,R)=>y(R.modelId)-y(E.modelId)||E.modelId.localeCompare(R.modelId));return{provider:w,list:S.slice(0,200),truncated:S.length>200,current:w===v,heat:S.reduce((E,R)=>E+y(R.modelId),0)}}).sort((w,x)=>w.current!==x.current?w.current?-1:1:x.heat-w.heat||w.provider.localeCompare(x.provider))},[e,l,t,s]);return o.jsxs("div",{className:"tb-list wide stacked",ref:d,children:[a?o.jsxs("div",{className:"tb-err",role:"alert","data-model-err":a.id,children:[o.jsx("span",{className:"tb-err-id",children:a.id}),o.jsx("span",{className:"tb-err-text",children:a.text})]}):null,e.length>AN?o.jsx("input",{className:"tb-search",autoFocus:!0,value:l,placeholder:`filter ${e.length} models…`,"aria-label":"filter models",onChange:f=>c(f.target.value)}):null,o.jsxs("div",{className:"tb-scroll",children:[p.map(f=>{const m=!!l.trim()||!u[f.provider];return o.jsxs("div",{className:"tb-group",children:[o.jsxs("button",{type:"button",className:`tb-group-head ${m?"open":""}`,"aria-expanded":m,title:`${f.provider} · ${f.list.length} model(s)`,"data-provider":f.provider,onClick:()=>h(b=>({...b,[f.provider]:!b[f.provider]})),children:[o.jsx(an,{size:11,className:`tb-group-chev ${m?"open":""}`}),o.jsx("span",{className:"tb-group-name",children:f.provider}),o.jsx("span",{className:"tb-group-count",children:f.list.length})]}),m?o.jsx("div",{className:"tb-group-body",children:f.list.map(b=>o.jsxs("button",{className:`tb-opt ${b.modelId===t?"sel":""} ${n===b.modelId?"pending":""} ${a?.id===b.modelId||r[b.modelId]?"bad":""}`,title:r[b.modelId]?`${b.modelId} — this agent refused it: ${r[b.modelId]}`:b.description?`${b.modelId} — ${b.description}`:b.modelId,"data-model":b.modelId,"data-model-refused":r[b.modelId]?"1":void 0,onClick:()=>i(b.modelId),children:[o.jsx("span",{className:"tb-opt-name",children:TN(b,f.provider)}),n===b.modelId?o.jsx("span",{className:"tb-opt-pending",children:"待生效"}):null]},b.modelId))}):null]},f.provider)}),p.length?null:o.jsxs("div",{className:"tb-empty",children:["no model matches “",l,"”"]})]})]})}let Xr=null,uu=null,Wp=0;const Kp=new Set;function qp(){Wp+=1;for(const e of Kp)e()}function MN(e){return Kp.add(e),()=>{Kp.delete(e)}}function DN(){return Xr?Promise.resolve():(uu||(uu=fetch("/api/model-usage",{headers:{accept:"application/json"}}).then(e=>{if(!e.ok)throw new Error(`model-usage ${e.status}`);return e.json()}).then(e=>{Xr=e.usage??{},qp()}).catch(()=>{Xr=null,uu=null,qp()})),uu)}function IN(e,t){const s=`${e}|${t}`;Xr={...Xr??{},[s]:((Xr??{})[s]??0)+1},qp()}function RS(e){return g.useSyncExternalStore(MN,()=>Wp,()=>0),g.useEffect(()=>{DN()},[]),g.useMemo(()=>{const t={},s=Xr??{},n=`${e}|`;for(const[i,r]of Object.entries(s)){const a=i.indexOf("|");if(a<0||e&&!i.startsWith(n))continue;const l=i.slice(a+1);t[l]=(t[l]??0)+r}return t},[e,Wp])}function e0(e,t){const s=t?.messageId;return typeof s=="string"&&s?`${e}:${s}`:null}function PN(e,t){return e===t||e.replace(/\s+/g,"")===t.replace(/\s+/g,"")}function LN(e,t){const s=t.delta;if(s===void 0)return e===void 0?{action:"create",text:t.text}:t.key?PN(e,t.text)?{action:"skip"}:{action:"replace",text:t.text}:{action:"append",add:t.text};if(e===void 0)return{action:"create",text:s};if(t.n!==void 0){const i=t.n-e.length;return i<=0?{action:"skip"}:i>=s.length?{action:"append",add:s}:{action:"append",add:s.slice(s.length-i)}}const n=BN(e,s);return n?{action:"append",add:n}:{action:"skip"}}function ON(e,t,s,n){const i=e,r=d=>d,a=d=>{const p=s.key??`anon@${i.length}`;return i.push(r(n(p,{...s,text:d}))),s.key&&t.set(s.key,i.length-1),{pushed:!0,at:i.length-1}},l=s.key?t.get(s.key):void 0,c=l===void 0?void 0:i[l],u=c&&c.kind===s.kind?l:!s.key&&i.length>0&&i[i.length-1].kind===s.kind?i.length-1:void 0,h=LN(u===void 0?void 0:i[u].text,s);return h.action==="create"?a(h.text):u===void 0?h.action==="append"?a(h.add):h.action==="replace"?a(h.text):a(s.delta??s.text):h.action==="skip"?{pushed:!1,at:u}:(e[u]={...e[u],text:h.action==="append"?i[u].text+h.add:h.text},{pushed:!1,at:u})}function t0(e){const t=new Map;return e.forEach((s,n)=>{s.key.startsWith("anon@")?t.delete(s.key):t.set(s.key,n)}),t}function BN(e,t){if(!e||!t)return t;if(t.startsWith(e))return t.slice(e.length);const s=Math.min(e.length,t.length);for(let n=s;n>=16;n--)if(e.endsWith(t.slice(0,n)))return t.slice(n);return t}function n_(e,t){const s=e.length?e.replace(/\n$/,"").split(`
41
+ `):[],n=t.length?t.replace(/\n$/,"").split(`
42
+ `):[];let i=0;for(;i<s.length&&i<n.length&&s[i]===n[i];)i++;let r=0;for(;r<s.length-i&&r<n.length-i&&s[s.length-1-r]===n[n.length-1-r];)r++;const a=[],l=3;i>l&&a.push({kind:"gap",text:`⋯ 上面 ${i-l} 行未变 ⋯`,oldNo:null,newNo:null});for(let b=Math.max(0,i-l);b<i;b++)a.push({kind:"ctx",text:s[b],oldNo:b+1,newNo:b+1});const c=s.slice(i,s.length-r),u=n.slice(i,n.length-r),h=[];if(c.length*u.length>25e4)c.forEach((b,_)=>h.push({kind:"del",text:b,oldNo:i+_+1,newNo:null})),u.forEach((b,_)=>h.push({kind:"add",text:b,oldNo:null,newNo:i+_+1}));else{const b=c.length,_=u.length,v=Array.from({length:b+1},()=>new Array(_+1).fill(0));for(let x=b-1;x>=0;x--)for(let S=_-1;S>=0;S--)v[x][S]=c[x]===u[S]?v[x+1][S+1]+1:Math.max(v[x+1][S],v[x][S+1]);let y=0,w=0;for(;y<b&&w<_;)c[y]===u[w]?(h.push({kind:"ctx",text:c[y],oldNo:i+y+1,newNo:i+w+1}),y++,w++):v[y+1][w]>=v[y][w+1]?(h.push({kind:"del",text:c[y],oldNo:i+y+1,newNo:null}),y++):(h.push({kind:"add",text:u[w],oldNo:null,newNo:i+w+1}),w++);for(;y<b;)h.push({kind:"del",text:c[y],oldNo:i+y+1,newNo:null}),y++;for(;w<_;)h.push({kind:"add",text:u[w],oldNo:null,newNo:i+w+1}),w++}const d=[];for(let b=0;b<Math.min(r,l);b++)d.push({kind:"ctx",text:s[s.length-r+b],oldNo:s.length-r+b+1,newNo:n.length-r+b+1});r>l&&d.push({kind:"gap",text:`⋯ 下面 ${r-l} 行未变 ⋯`,oldNo:null,newNo:null});const p=new Array(h.length).fill(!1);h.forEach((b,_)=>{if(b.kind!=="ctx")for(let v=Math.max(0,_-l);v<=Math.min(h.length-1,_+l);v++)p[v]=!0});const f=[];let m=0;return h.forEach((b,_)=>{if(!p[_]){m++;return}m&&(f.push({kind:"gap",text:`⋯ 中间 ${m} 行未变 ⋯`,oldNo:null,newNo:null}),m=0),f.push(b)}),m&&f.push({kind:"gap",text:`⋯ 中间 ${m} 行未变 ⋯`,oldNo:null,newNo:null}),[...a,...f,...d]}const of=e=>typeof e=="string";function $N(e){const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t>=0?e.slice(t+1):e}function jS(e){if(!e||!/^(\+\+\+|---) /m.test(e))return null;let t="",s=0,n=0;for(const i of e.split(`
43
+ `)){if(i.startsWith("+++ ")){const r=i.slice(4).trim().replace(/^b\//,"").replace(/\t.*$/,"");r&&r!=="/dev/null"&&(t=r);continue}i.startsWith("--- ")||(i.startsWith("+")?s++:i.startsWith("-")&&n++)}return t?{path:t,insertions:s,deletions:n}:null}function FN(e){const t=e??{},s=Array.isArray(t.content)?t.content:[],n=[],i=new Set,r=a=>{i.has(a.path)||(i.add(a.path),n.push(a))};for(const a of s){if(!a||typeof a!="object")continue;if(of(a.path)&&a.path&&(a.oldText!=null||a.newText!=null||a.type==="diff")){r({path:a.path,oldText:a.oldText??"",newText:a.newText??""});continue}const l=of(a.text)?a.text:of(a.content?.text)?a.content.text:"";if(!l)continue;const c=jS(l);c&&r({path:c.path,diffText:l})}return n}function zN(e){const t=[],s=new Map;for(const n of e){const i=s.get(n.path);if(!i){t.push(n.path),s.set(n.path,{first:n,last:n,edits:1,diffText:n.diffText});continue}i.last=n,i.edits++,n.oldText!=null||n.newText!=null?i.diffText=void 0:i.diffText||(i.diffText=n.diffText)}return t.map(n=>{const{first:i,last:r,edits:a,diffText:l}=s.get(n),c={path:n,name:$N(n),edits:a};if(i.oldText!=null||r.newText!=null){const u=i.oldText??"",h=r.newText??r.oldText??"",d=n_(u,h);return{...c,insertions:d.filter(p=>p.kind==="add").length,deletions:d.filter(p=>p.kind==="del").length,oldText:u,newText:h}}if(l){const u=jS(l);return{...c,insertions:u?.insertions??0,deletions:u?.deletions??0,oldText:"",newText:"",diffText:l}}return{...c,insertions:0,deletions:0,oldText:"",newText:""}})}function HN(e){let t=null,s=!1,n=[];function i(){const a=n;n=[];for(const l of a)l()}async function r(){if(!s){s=!0;try{for(;t;){const a=t;t=null;try{await e(a)}catch{}}}finally{s=!1,i()}}}return{push(a){t=a,r()},hush(){t=null,s||i()},get speaking(){return s},get waiting(){return t},settled(){return!s&&!t?Promise.resolve():new Promise(a=>{n.push(a)})}}}const TS="agentus.voice",kl={autoRead:!1,speakMode:"off",voiceURI:"",rate:1,lang:typeof navigator<"u"&&navigator.language?navigator.language:"en-US",serverTts:!1,stt:"auto"};function UN(){try{const e=localStorage.getItem(TS);if(!e)return{...kl};const t=JSON.parse(e),s=Number(t.rate);return{...kl,...t,rate:Number.isFinite(s)?Math.min(2,Math.max(.5,s)):kl.rate}}catch{return{...kl}}}function AS(e){try{localStorage.setItem(TS,JSON.stringify(e))}catch{}}const i_={provider:"browser",tts:{server:!1,model:null,voice:null},stt:{server:!1,streaming:!1,model:null,batchModel:null,language:null},hotwords:{fixed:0,dynamic:!1,limit:0}};let $o=null;const Vp=new Set;async function Ch(e=!1){if($o&&!e)return $o;try{const t=await fetch("/api/voice",{credentials:"same-origin"});if(!t.ok)throw new Error(String(t.status));$o=await t.json()}catch{$o=i_}for(const t of Vp)t();return $o}function ai(){return $o??i_}function WN(e){return Vp.add(e),()=>Vp.delete(e)}const s0=80,MS=220,KN=2,qN=12,VN=3,n0=2,YN=400,af=0,GN=1,JN=4,XN=400,ZN=60;let lf=0;const Za=[];async function QN(e,t,s){lf>=VN&&await new Promise((n,i)=>{const r={priority:e,run:n};Za.push(r),Za.sort((l,c)=>l.priority-c.priority);const a=()=>{const l=Za.indexOf(r);l>=0&&Za.splice(l,1),i(new rn)};t&&(t.aborted?a():t.addEventListener("abort",a,{once:!0}))}),lf++;try{return await s()}finally{const n=Za.shift();n?n.run():lf--}}function i0(e,t=MS){const s=e.replace(/```[\s\S]*?```/g," code block ").replace(/[*_`#>|]/g," ").replace(/\s+/g," ").trim();if(!s)return[];const n=[];let i=s;for(;i.length>t;){const r=i.slice(0,t),a=Math.max(r.lastIndexOf(". "),r.lastIndexOf("。"),r.lastIndexOf("! "),r.lastIndexOf("? ")),l=Math.max(r.lastIndexOf(", "),r.lastIndexOf("; "),r.lastIndexOf(",")),c=a>t*.5?a+1:l>t*.5?l+1:r.lastIndexOf(" "),u=c>0?c:t;n.push(i.slice(0,u).trim()),i=i.slice(u).trim()}return i&&n.push(i),n.filter(Boolean)}let nn=null;function DS(){return window.AudioContext??window.webkitAudioContext??null}const Fl={echoCancellation:null,noiseSuppression:null};function eR(e,t){const s=e.getAudioTracks()[0],n=typeof s?.getSettings=="function"?s.getSettings():void 0;Fl.echoCancellation=typeof n?.echoCancellation=="boolean"?n.echoCancellation:t>0?!1:null,Fl.noiseSuppression=typeof n?.noiseSuppression=="boolean"?n.noiseSuppression:t>0?!1:null,Fl.echoCancellation===!1&&console.warn("[voice] microphone opened WITHOUT echo cancellation — the call may hear itself")}function r0(){return Fl.echoCancellation!==!1}function cf(){return{...Fl}}async function o0(e){const t=[e,{audio:{channelCount:1,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}},{audio:!0}];let s=null;for(let n=0;n<t.length;n++)try{const i=await navigator.mediaDevices.getUserMedia(t[n]);return n>0&&console.warn("[voice] microphone opened only with degraded constraints",t[n]),eR(i,n),i}catch(i){s=i;const r=i?.name??"";if(r==="NotAllowedError"||r==="SecurityError")throw i;await new Promise(a=>setTimeout(a,250))}throw s instanceof Error?s:new Error(String(s))}async function tR(){const e=DS();if(!e)return!1;try{return nn=nn??new e,nn.state==="suspended"&&await nn.resume(),nn.state==="running"}catch{return!1}}const rr={analyser:null};let lr=null;function a0(){const e=rr.analyser;if(!e)return-1;const t=lr&&lr.length===e.fftSize?lr:new Float32Array(new ArrayBuffer(e.fftSize*4));lr=t,e.getFloatTimeDomainData(t);let s=0;for(let n=0;n<t.length;n++)s+=t[n]*t[n];return Math.min(1,Math.sqrt(s/t.length)*4)}function sR(){const e=rr.analyser;if(!e)return-1;const t=lr&&lr.length===e.fftSize?lr:new Float32Array(new ArrayBuffer(e.fftSize*4));lr=t,e.getFloatTimeDomainData(t);let s=0;for(let n=0;n<t.length;n++)s+=t[n]*t[n];return Math.min(1,Math.sqrt(s/t.length))}function nR(e){const t=rr.analyser;if(!t)return!1;const s=new Float32Array(new ArrayBuffer(t.fftSize*4));t.getFloatTimeDomainData(s);const n=Math.max(1,Math.floor(s.length/e.length));for(let i=0,r=0;i<e.length;i++,r+=n)e[i]=s[r]??0;return!0}class rn extends Error{constructor(){super("stopped"),this.name="SpeechStopped"}}async function IS(e,t){const s=DS();if(s)try{nn=nn??new s,nn.state==="suspended"&&await nn.resume();const i=await nn.decodeAudioData(await e.arrayBuffer());await new Promise((r,a)=>{const l=nn.createBufferSource();l.buffer=i;const c=nn.createAnalyser();c.fftSize=512,l.connect(c),c.connect(nn.destination),rr.analyser=c,l.onended=()=>{rr.analyser===c&&(rr.analyser=null),r()};const u=()=>{rr.analyser===c&&(rr.analyser=null);try{l.stop()}catch{}a(new rn)};if(t){if(t.aborted)return u();t.addEventListener("abort",u,{once:!0})}l.start()});return}catch(i){if(i instanceof rn)throw i;if(t?.aborted)throw new rn}const n=URL.createObjectURL(e);try{await new Promise((i,r)=>{const a=new Audio(n),l=()=>{try{a.pause()}catch{}r(new rn)};a.onended=()=>{c(),i()},a.onerror=()=>{c(),r(new Error("audio playback failed"))};const c=()=>{t&&t.removeEventListener("abort",l)};if(t){if(t.aborted)return l();t.addEventListener("abort",l,{once:!0})}a.play().catch(u=>{c(),r(new Error(String(u?.message??u)))})})}finally{URL.revokeObjectURL(n)}}function Qa(){return typeof window<"u"&&"speechSynthesis"in window}class iR{#e={speakingId:null,speaking:!1,error:"",note:""};#l=new Set;#i=null;#s=0;#o=!1;#t=[];#n=new Set;subscribe=t=>(this.#l.add(t),()=>this.#l.delete(t));getSnapshot=()=>this.#e;#c(t){this.#e={...this.#e,...t};for(const s of this.#l)s()}subscribeVoices=t=>(this.#n.add(t),()=>this.#n.delete(t));voices=()=>this.#t;init(){if(!Qa())return;const t=()=>{const i=window.speechSynthesis.getVoices();if(i.length!==this.#t.length){this.#t=i;for(const r of this.#n)r()}};t(),window.speechSynthesis.addEventListener("voiceschanged",t);let s=0;const n=window.setInterval(()=>{s+=1,t(),(this.#t.length||s>40)&&window.clearInterval(n)},250);window.addEventListener("pointerdown",t,{once:!0})}pickVoice(t){const s=this.#t.length?this.#t:Qa()?window.speechSynthesis.getVoices():[];if(!s.length)return null;if(t.voiceURI){const r=s.find(a=>a.voiceURI===t.voiceURI);if(r)return r}const n=t.lang.toLowerCase(),i=n.split("-")[0];return s.find(r=>r.lang.toLowerCase()===n)??s.find(r=>r.lang.toLowerCase().startsWith(i))??s.find(r=>r.default)??s[0]}async speak(t,s,n){const i=String(t??"").trim();if(!i)return;this.stop();const r=++this.#s;this.#o=!1;const a=n.serverTts&&ai().tts.server,l=i0(i,a?s0:MS);if(!l.length)return;const c=new AbortController;this.#i=c,this.#c({error:"",note:"",speakingId:s,speaking:!0});try{a?await this.#v(l,n,c.signal):await this.#h(l,n,c.signal)}catch(u){if(this.#o||r!==this.#s||u instanceof rn||u?.name==="AbortError")return;if(n.serverTts&&Qa()){this.#c({note:`服务端语音这一句失败了(${String(u?.message??u)}),已改用浏览器语音`});try{await this.#h(l,n,c.signal);return}catch(h){if(this.#o||h instanceof rn)return;this.#c({error:String(h?.message??h)})}}else this.#c({error:String(u?.message??u)})}finally{this.#i===c&&(this.#i=null),r===this.#s&&this.#c({speaking:!1,speakingId:null})}}async#h(t,s,n){if(!Qa())throw new Error("this browser has no speech synthesis");const i=window.speechSynthesis,r=this.pickVoice(s);for(const[a,l]of t.entries()){if(n?.aborted)throw new rn;if(await new Promise((c,u)=>{const h=new SpeechSynthesisUtterance(l);r?(h.voice=r,h.lang=r.lang):h.lang=s.lang,h.rate=s.rate,h.onend=()=>c(),h.onerror=d=>u(new Error(`speech error: ${d.error??"unknown"}`)),i.speak(h),a===0&&i.resume()}),n?.aborted)throw new rn;i.paused&&i.resume()}}#_(t,s,n,i){return QN(i,n,async()=>{const r=await fetch("/api/tts",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},signal:n,body:JSON.stringify({text:t,speed:s.rate})});if(!r.ok){const a=await r.json().catch(()=>({error:`${r.status}`}));throw new Error(a.error??`tts ${r.status}`)}return await r.blob()})}async#p(t,s,n,i=af){let r=null;for(let a=0;a<=n0;a++){if(n?.aborted)throw new rn;try{return await this.#_(t,s,n,i)}catch(l){if(l instanceof rn||l?.name==="AbortError"||n?.aborted)throw l;r=l,a<n0&&await new Promise(c=>{window.setTimeout(c,YN*(a+1))})}}throw r instanceof Error?r:new Error(String(r))}#d=new Map;#f(t,s){return`${s.rate}|${ai().tts.voice??""}|${t}`}prefetch(t,s){if(!(s.serverTts&&ai().tts.server))return;const n=String(t??"").trim();if(n)for(const i of i0(n,s0)){const r=this.#f(i,s);if(this.#d.has(r))continue;const a=this.#p(i,s,void 0,GN);for(a.catch(()=>{}),this.#d.set(r,a);this.#d.size>qN;){const l=this.#d.keys().next().value;if(l===void 0)break;this.#d.delete(l)}}}async#v(t,s,n){const i=[],r=a=>{const l=this.#f(a,s),c=this.#d.get(l);if(c)return this.#d.delete(l),c.catch(()=>this.#p(a,s,n,af));const u=this.#p(a,s,n,af);return u.catch(()=>{}),u};for(let a=0;a<t.length;a++){if(n.aborted)throw new rn;for(;i.length<Math.min(KN,t.length-a);)i.push(r(t[a+i.length]));if(await IS(await i.shift(),n),n.aborted)throw new rn}}stop(){this.#o=!0,this.#i?.abort(),this.#i=null,Qa()&&window.speechSynthesis.cancel(),this.#e.speaking&&this.#c({speaking:!1,speakingId:null})}}const Ft=new iR;Ft.init();function dd(){return g.useSyncExternalStore(Ft.subscribe,Ft.getSnapshot)}const el=new Set,rR=1024,PS=HN(e=>Ft.speak(e.text,e.key,zn));function uc(){PS.hush(),Ft.stop()}function oR(e){PS.push({key:e.key,text:e.text})}let r_=!1;function l0(e){r_=e}function Eh(){return r_}function aR(e,t,s){if(r_||!s||el.has(e))return!1;for(el.add(e);el.size>rR;){const n=el.values().next().value;if(n===void 0)break;el.delete(n)}return!0}function LS(){const e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function Yp(){return!!LS()}function OS(){const e=window.AgentusMic;return e&&typeof e.start=="function"&&typeof e.stop=="function"?e:null}function BS(){const e=OS();if(!e)return!1;try{return!!e.available()}catch{return!1}}function lR(){return BS()||typeof navigator.mediaDevices?.getUserMedia=="function"}function cR(){return typeof window<"u"&&!window.isSecureContext?"当前页面是明文 http,浏览器不允许网页录音。请改用 https 入口访问(在服务前放一层终结 TLS 的反代或隧道),或走本机 localhost;手机上也可以用 Agentus app。":"this browser cannot record audio"}function uR(){return new Promise(e=>{const t=document.createElement("input");t.type="file",t.accept="audio/*",t.setAttribute("capture","microphone"),t.style.position="fixed",t.style.left="-9999px";let s=!1;const n=i=>{s||(s=!0,t.remove(),e(i))};t.onchange=()=>n(t.files?.[0]??null),window.addEventListener("focus",()=>{window.setTimeout(()=>n(t.files?.[0]??null),600)},{once:!0}),document.body.appendChild(t),t.click()})}class hR{#e={status:"idle",text:"",interim:"",error:"",engine:null,seconds:0};#l=new Set;#i=null;#s=null;#o=[];#t=null;#n=null;#c=null;#h=null;#_=null;#p=null;#d="";#f=0;#v=0;#b=new Float32Array(256);#D=null;#x=!0;#I;#k=!1;#a=0;#m=[];#S=null;#C=0;#y="";#w=!1;#E=()=>{const t=globalThis.__asFeed;return t&&typeof t=="object"?t:null};level=()=>{const t=this.#E();if(!t)return this.#f;const s=Number(t.level);return Number.isFinite(s)?s:0};levelRms=()=>{const t=this.#E();if(!t)return this.#v;const s=Number(t.rms??(Number.isFinite(Number(t.level))?Number(t.level)/6:NaN));return Number.isFinite(s)?Math.max(0,s):0};wave=()=>this.#b;setVadTap=t=>{this.#D=t};setRelay(t){if(this.#x=t,!t){this.#w=!0,this.#$();return}this.#w=!1,this.#k&&this.#N()}#$(){this.#S!==null&&(window.clearTimeout(this.#S),this.#S=null);const t=this.#n;if(this.#n=null,this.#m.length=0,!!t){t.onmessage=null,t.onerror=null,t.onclose=null;try{t.close()}catch{}}}resetText(){this.#d="",this.#r({text:"",interim:""})}commitForTest(t){this.#d=`${this.#d}${t}`.replace(/\s+/g," ").trim(),this.#r({status:"idle",text:this.#d,interim:""})}#T(t){let s=0;for(let a=0;a<t.length;a++)s+=t[a]*t[a];const n=Math.sqrt(s/t.length),i=Math.min(1,n*6);this.#f=i>this.#f?this.#f+(i-this.#f)*.6:this.#f*.72+i*.28,this.#v=n>this.#v?this.#v+(n-this.#v)*.6:this.#v*.72+n*.28,this.#D?.(t);const r=Math.max(1,Math.floor(t.length/this.#b.length));for(let a=0,l=0;a<this.#b.length&&l<t.length;a++,l+=r)this.#b[a]=t[l]}subscribe=t=>(this.#l.add(t),()=>this.#l.delete(t));#P=null;getSnapshot=()=>{const t=this.#E();if(!t)return this.#e;const s=String(t.text??""),n=String(t.interim??""),i=this.#P;return i&&i.text===s&&i.interim===n&&i.status===this.#e.status&&i.error===this.#e.error&&i.engine===this.#e.engine&&i.seconds===this.#e.seconds?i:(this.#P={...this.#e,text:s,interim:n},this.#P)};#r(t){this.#e={...this.#e,...t};for(const s of this.#l)s()}async start(t,s){if(this.#e.status!=="idle"&&this.#e.status!=="error")return!1;uc();const n=++this.#a;this.#r({status:"idle",text:"",interim:"",error:"",seconds:0}),this.#d="";const i=this.#E();if(i)return this.#x=!0,this.#r({status:"listening",engine:"stream",error:"",text:String(i.text??""),interim:String(i.interim??"")}),!0;const r=t.stt,a=ai().stt.server,l=ai().stt.streaming,c=(r==="browser"||r==="auto")&&Yp();try{if(r==="stream"||r==="auto"&&l){if(!l)throw new Error("streaming STT is not configured on the server (settings → 语音)");return await this.#L(t,s,n),!0}return c?(this.#H(t),!0):a?(await this.#K(t,n),!0):(this.#r({status:"error",engine:null,error:(typeof window<"u"&&!window.isSecureContext&&!lR()?`${cR()} `:"")+(r==="server"||a?"no dictation available: this browser has no speech recognition and the server has no STT endpoint (AGENTUS_STT_BASE_URL)":"no dictation available in this browser — set the server STT endpoint or use Chromium/Edge")}),!1)}catch(u){return this.#R(n)||this.#r({status:"error",error:String(u?.message??u)}),!1}}#H(t){const s=LS();if(!s)throw new Error("speech recognition unavailable");const n=new s;n.lang=t.lang,n.continuous=!0,n.interimResults=!0,n.maxAlternatives=1;let i="";n.onstart=()=>this.#r({status:"listening",engine:"browser",error:""}),n.onresult=r=>{let a="";for(let l=r.resultIndex;l<r.results.length;l+=1){const c=r.results[l],u=c[0]?.transcript??"";c.isFinal?i+=u:a+=u}this.#r({text:i.trim(),interim:a.trim()})},n.onerror=r=>{const a=String(r?.error??"unknown");this.#r({status:"error",error:a==="not-allowed"||a==="service-not-allowed"?"microphone permission denied":a==="no-speech"?"heard nothing — try again closer to the microphone":`speech recognition failed: ${a}`})},n.onend=()=>{this.#e.status==="listening"&&this.#r({status:"idle",interim:""}),this.#i=null},this.#i=n,this.#r({status:"requesting",engine:"browser"});try{n.start()}catch(r){throw this.#i=null,new Error(String(r?.message??r))}}async#L(t,s,n){const i=BS()?OS():null;if(!i&&typeof navigator.mediaDevices?.getUserMedia!="function"){await this.#u(t);return}const r=window.AudioContext??window.webkitAudioContext;if(!i&&!r)throw new Error("this browser cannot process audio");this.#r({status:"requesting",engine:"stream",error:""}),this.#x=!0,this.#w=!1,this.#C=0,this.#y="",this.#I=s,this.#k=!0,this.#m.length=0,this.#N();const a=l=>this.#U(l);if(i?await this.#F(i,a,n):await this.#W(r,a,n),this.#R(n)){this.#A(),this.#O(),this.#r({status:"idle",interim:"",text:""});return}this.#r({status:"listening",engine:"stream",seconds:0}),this.#t=window.setInterval(()=>this.#r({seconds:this.#e.seconds+1}),1e3)}#U(t){const s=this.#n;s&&s.readyState===WebSocket.OPEN?s.send(t):this.#m.length<ZN&&this.#m.push(t)}#N(){if(this.#n||!this.#k)return;const t=this.#I?`?sessionId=${encodeURIComponent(this.#I)}`:"",s=new WebSocket(`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws/asr${t}`);s.binaryType="arraybuffer",this.#n=s,s.onopen=()=>{this.#C=0,this.#y="";for(const n of this.#m)s.send(n);this.#m.length=0,this.#e.status!=="listening"&&this.#r({status:"listening",engine:"stream",error:""})},s.onmessage=n=>{let i;try{i=JSON.parse(String(n.data))}catch{return}i.t==="asr-partial"?this.#r({interim:String(i.text??"")}):i.t==="asr-final"?(this.#d=`${this.#d}${i.text??""}`.replace(/\s+/g," ").trim(),this.#r({text:this.#d,interim:""})):i.t==="asr-error"?this.#g(String(i.error??"streaming asr failed")):i.t==="asr-done"&&(this.#w||!this.#k||!this.#x?this.#j():this.#g("the recogniser ended the turn by itself"))},s.onerror=()=>this.#g("the streaming socket failed — is the server up?"),s.onclose=()=>{this.#n===s&&(this.#n=null),this.#g(this.#y||"the streaming socket failed — is the server up?")}}#g(t){if(!(!this.#k||this.#w||!this.#x)&&(this.#y||(this.#y=t),this.#S===null)){if(this.#C>=JN){this.#r({status:"error",error:this.#y}),this.#y="",this.#j();return}this.#C+=1,this.#S=window.setTimeout(()=>{this.#S=null,this.#N()},XN*this.#C)}}async#W(t,s,n){const i=await o0({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}});if(this.#R(n)){for(const u of i.getTracks())u.stop();return}this.#_=i;const r=new t({sampleRate:16e3});this.#c=r;const a=r.createMediaStreamSource(i),l=r.createScriptProcessor(2048,1,1),c=r.createGain();c.gain.value=0,this.#h=l,l.onaudioprocess=u=>{const h=u.inputBuffer.getChannelData(0);if(this.#T(h),!this.#x)return;const d=$S(h,r.sampleRate,16e3);d.length&&s(d.buffer)},a.connect(l),l.connect(c),c.connect(r.destination)}async#F(t,s,n){let i="permission";for(let r=0;r<12&&(i=String(t.start(16e3)),!(i==="ok"||i==="already"));r++){if(i==="permission"){this.#r({status:"requesting",engine:"stream"}),await new Promise(a=>setTimeout(a,600));continue}throw new Error(`手机上的原生麦克风打不开(${i})`)}if(i!=="ok"&&i!=="already")throw new Error(`手机上的原生麦克风打不开(${i})`);if(this.#R(n)){try{t.stop()}catch{}return}this.#p=t,window.__asMic=r=>{const a=atob(r),l=a.length>>1,c=new Int16Array(l);for(let h=0;h<l;h++){const d=a.charCodeAt(2*h),p=a.charCodeAt(2*h+1);c[h]=(p<<8|d)<<16>>16}const u=new Float32Array(l);for(let h=0;h<l;h++)u[h]=c[h]/32768;this.#T(u),this.#x&&s(c.buffer)}}#O(){this.#$(),this.#k=!1,this.#w=!1,this.#C=0,this.#y="",this.#A(),this.#t&&(window.clearInterval(this.#t),this.#t=null),this.#x=!0}#R(t){return t!==this.#a}#A(){if(this.#h){this.#h.onaudioprocess=null;try{this.#h.disconnect()}catch{}this.#h=null}if(this.#c&&(this.#c.close().catch(()=>{}),this.#c=null),this.#_){for(const t of this.#_.getTracks())t.stop();this.#_=null}if(this.#p){try{this.#p.stop()}catch{}this.#p=null}window.__asMic=void 0,this.#f=0,this.#b.fill(0)}#j(){this.#O(),this.#r({status:"idle",interim:""})}async#K(t,s){if(typeof navigator.mediaDevices?.getUserMedia!="function"){await this.#u(t);return}this.#r({status:"requesting",engine:"server",error:""});const n=await o0({audio:!0});if(this.#R(s)){for(const a of n.getTracks())a.stop();return}const i=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"",r=new MediaRecorder(n,i?{mimeType:i}:void 0);this.#o=[],r.ondataavailable=a=>{a.data.size&&this.#o.push(a.data)},r.onstop=()=>{for(const a of n.getTracks())a.stop();this.#q(t)},this.#s=r,r.start(1e3),this.#r({status:"recording",engine:"server",seconds:0}),this.#t=window.setInterval(()=>this.#r({seconds:this.#e.seconds+1}),1e3)}async#u(t){this.#r({status:"requesting",engine:"server",error:""});const s=await uR();if(!s){this.#r({status:"idle",text:"",interim:"",error:""});return}await this.#M(t,s)}async#M(t,s){this.#r({status:"transcribing"});try{const n=await fetch(`/api/stt?language=${encodeURIComponent(t.lang)}`,{method:"POST",credentials:"same-origin",headers:{"content-type":s.type||"audio/webm"},body:s}),i=await n.json().catch(()=>({}));if(!n.ok)throw new Error(i.error??`stt ${n.status}`);this.#r({status:"idle",text:String(i.text??"").trim(),interim:""})}catch(n){this.#r({status:"error",error:String(n?.message??n)})}}async#q(t){this.#t&&(window.clearInterval(this.#t),this.#t=null);const s=new Blob(this.#o,{type:this.#o[0]?.type||"audio/webm"});if(this.#o=[],this.#s=null,!s.size){this.#r({status:"error",error:"nothing was recorded — check the microphone"});return}await this.#M(t,s)}stop(){if(this.#a+=1,this.#e.status==="requesting"){this.cancel();return}if(this.#i){try{this.#i.stop()}catch{}return}if(this.#n&&this.#n.readyState===WebSocket.OPEN){this.#A(),this.#t&&(window.clearInterval(this.#t),this.#t=null),this.#w=!0,this.#r({status:"transcribing"});try{this.#n.send(JSON.stringify({t:"asr-stop"}))}catch{this.#j();return}window.setTimeout(()=>{this.#e.status==="transcribing"&&this.#j()},8e3);return}this.#s&&this.#s.state!=="inactive"&&this.#s.stop(),this.#t&&(window.clearInterval(this.#t),this.#t=null),this.#e.status==="listening"&&this.#r({status:"idle",interim:""})}cancel(){if(this.#a+=1,this.#i){try{this.#i.abort()}catch{}this.#i=null}this.#s&&this.#s.state!=="inactive"&&(this.#s.onstop=null,this.#s.stop(),this.#s=null),this.#t&&(window.clearInterval(this.#t),this.#t=null),this.#O(),this.#d="",this.#o=[],this.#r({status:"idle",text:"",interim:"",error:"",seconds:0})}consume(){const t=this.#e.text.trim();return this.#r({status:"idle",text:"",interim:"",seconds:0}),t}setOwner(t){this.#z=t}owns(t){return this.#z===t}#z="chat"}function $S(e,t,s){if(t===s){const a=new Int16Array(e.length);for(let l=0;l<e.length;l+=1)a[l]=c0(e[l]);return a}const n=t/s,i=Math.max(0,Math.floor(e.length/n)),r=new Int16Array(i);for(let a=0;a<i;a+=1){const l=a*n,c=Math.floor(l),u=Math.min(c+1,e.length-1),h=l-c;r[a]=c0(e[c]*(1-h)+e[u]*h)}return r}function c0(e){const t=Math.round((Number.isFinite(e)?e:0)*32767);return t>32767?32767:t<-32768?-32768:t}const pe=new hR;typeof window<"u"&&(window.__asDictation=pe);function o_(){return g.useSyncExternalStore(pe.subscribe,pe.getSnapshot)}let zn=UN();const Nh=new Set;async function FS(){try{const e=await fetch("/api/settings",{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({prefs:zn})});return e.ok?"":(await e.json().catch(()=>({}))).error??`save failed (${e.status})`}catch(e){return String(e?.message??e)}}function u0(e){const t={...kl};if(!e||typeof e!="object")return t;const s=e;return{autoRead:typeof s.autoRead=="boolean"?s.autoRead:t.autoRead,speakMode:s.speakMode==="off"||s.speakMode==="reply"||s.speakMode==="brief"?s.speakMode:typeof s.autoRead=="boolean"&&s.autoRead?"reply":"off",voiceURI:typeof s.voiceURI=="string"?s.voiceURI:t.voiceURI,rate:Number.isFinite(Number(s.rate))?Math.min(2,Math.max(.5,Number(s.rate))):t.rate,lang:typeof s.lang=="string"&&s.lang?s.lang:t.lang,serverTts:typeof s.serverTts=="boolean"?s.serverTts:t.serverTts,stt:s.stt==="browser"||s.stt==="stream"||s.stt==="server"?s.stt:"auto"}}function dR(e){zn=e,AS(zn);for(const t of Nh)t()}async function fR(){try{const e=await fetch("/api/settings",{credentials:"same-origin"});if(!e.ok)return;const t=await e.json(),s=u0(t.prefs),n=u0(t.prefsDefaults);if(uf.every(r=>s[r]===n[r])&&uf.some(r=>zn[r]!==s[r])){FS();return}uf.some(r=>zn[r]!==s[r])&&dR(s)}catch{}}const uf=["speakMode","voiceURI","rate","lang","serverTts","stt"];function pR(e){const t={...zn,...e},s=Number.isFinite(t.rate)?Math.min(2,Math.max(.5,t.rate)):1;zn={...t,rate:s},AS(zn);for(const n of Nh)n();FS()}function mR(){return zn}function go(){return[g.useSyncExternalStore(t=>(Nh.add(t),()=>Nh.delete(t)),()=>zn),pR]}function gR(e,t,s){const[n]=go(),i=(s??n.speakMode??(n.autoRead?"reply":"off"))==="reply",r=e?.length?e.map(a=>a.key).join(""):"";g.useEffect(()=>{if(!(!i||!t||!e?.length))for(const a of e)a.text.trim()&&aR(a.key,!0,i)&&oR(a)},[r,t,i])}function _R(e,t,s){const[n]=go(),i=(s??n.speakMode??(n.autoRead?"reply":"off"))==="brief";g.useEffect(()=>{!i||!t||!e||!e.text.trim()||Ft.speak(e.text,e.key,n)},[e?.key,t,i])}const Fo=2,Gp="agentus.webnotify",er={on:!0,sound:"chime",volume:.6};function vR(e){return e.available&&e.permission==="granted"&&e.enabled&&e.hidden}function yR(e,t,s,n){return e.sound!=="chime"||n||!s.enabled||!s.hidden?!1:t==="approval"||t==="agent_done"||t==="error"}function bR(e){return e==="approval"?[{freq:659.25,at:0,dur:.13},{freq:987.77,at:.15,dur:.28}]:e==="error"?[{freq:739.99,at:0,dur:.11},{freq:1046.5,at:.12,dur:.13},{freq:739.99,at:.27,dur:.26}]:[{freq:880,at:0,dur:.16},{freq:659.25,at:.2,dur:.3}]}function wR(e){try{return new URL(e,typeof location>"u"?"http://localhost/":location.href).searchParams.get("session")}catch{return null}}function xR(){try{const e=localStorage.getItem(Gp);if(!e)return{...er,v:Fo};const t=JSON.parse(e),s={on:typeof t.on=="boolean"?t.on:er.on,sound:t.sound==="chime"||t.sound==="silent"||t.sound==="default"?t.sound:er.sound,volume:typeof t.volume=="number"&&Number.isFinite(t.volume)?Math.min(1,Math.max(0,t.volume)):er.volume};if(t.v!==Fo&&s.sound==="default"&&(s.sound=er.sound),t.v!==Fo){s.v=Fo;try{localStorage.setItem(Gp,JSON.stringify(s))}catch{}}return s}catch{return{...er,v:Fo}}}function hu(){return typeof window>"u"||!("Notification"in window)?"no-api":window.isSecureContext?"ok":"insecure"}let hf=null;function zS(){if(typeof window>"u")return null;const e=window.AudioContext??window.webkitAudioContext;if(!e)return null;if(!hf)try{hf=new e}catch{return null}return hf}function ca(){const e=zS();e&&e.state==="suspended"&&e.resume()}function SR(e,t,s,n,i){const r=e.createOscillator(),a=e.createGain();r.type="sine",r.frequency.value=t,a.gain.setValueAtTime(1e-4,s),a.gain.linearRampToValueAtTime(i,s+.012),a.gain.exponentialRampToValueAtTime(1e-4,s+n),r.connect(a),a.connect(e.destination),r.start(s),r.stop(s+n+.02)}function Jp(e,t){const s=zS();if(!s)return;s.state==="suspended"&&s.resume();const n=s.currentTime+.01;for(const i of bR(t))SR(s,i.freq,n+i.at,i.dur,e)}const Xp=new Map;let Zp=0;async function HS(){if(typeof navigator>"u"||!("serviceWorker"in navigator))return null;try{return await navigator.serviceWorker.getRegistration()??null}catch{return null}}let Qp=null;function kR(e){Qp=e}function US(e){if(!e)return;const t=wR(e);if(t&&Qp){Qp(t);return}location.assign(e)}const h0="/icons/icon-192.png";async function d0(e,t){const s={body:e.body,tag:e.noticeId,icon:h0,badge:h0,data:{open:e.open??null,noticeId:e.noticeId},renotify:!0,requireInteraction:!!e.sticky,silent:t.sound!=="default"},n=await HS();if(n&&typeof n.showNotification=="function")try{return await n.showNotification(e.title,s),Zp=Date.now(),!0}catch{}try{const i=new Notification(e.title,s);return i.onclick=()=>{US(e.open),i.close()},Xp.set(e.noticeId,i),Zp=Date.now(),!0}catch{return!1}}async function f0(e){const t=Xp.get(e);t&&(t.close(),Xp.delete(e));const s=await HS();if(!(!s||typeof s.getNotifications!="function"))try{for(const n of await s.getNotifications({tag:e}))n.close()}catch{}}class CR{#e=er;#l=null;#i=new Set;#s;constructor(){this.#e=typeof localStorage>"u"?{...er}:xR(),this.#s=this.#o()}#o(){const t=hu();return{availability:t,permission:t==="ok"?Notification.permission:"unavailable",prefs:this.#e,last:this.#l}}#t(){this.#s=this.#o();for(const t of this.#i)t()}subscribe=t=>(this.#i.add(t),()=>this.#i.delete(t));getSnapshot=()=>this.#s;setPrefs(t){this.#e={...this.#e,...t},t.volume!==void 0&&(this.#e.volume=Math.min(1,Math.max(0,t.volume)));try{localStorage.setItem(Gp,JSON.stringify({...this.#e,v:Fo}))}catch{}this.#t()}async requestPermission(){if(hu()!=="ok")return"unavailable";ca();try{const t=await Notification.requestPermission();return this.#t(),this.#o().permission}catch{return this.#o().permission}}handle(t){if(t.op==="dismiss"){f0(t.noticeId);return}const s=hu(),n={available:s==="ok",permission:s==="ok"?Notification.permission:"unavailable",enabled:this.#e.on,hidden:typeof document>"u"?!1:document.hidden},i={enabled:this.#e.on,hidden:typeof document>"u"?!1:document.hidden};yR(this.#e,t.kind,i,Eh())&&Jp(this.#e.volume,t.kind),vR(n)&&d0(t,this.#e).then(r=>{this.#l={title:t.title,at:Date.now(),drawn:r},this.#t()})}async test(){if(hu()!=="ok")return!1;ca();const t={op:"upsert",noticeId:`test:${Date.now()}`,kind:"agent_done",title:"测试通知",body:"这条通知能弹出来,就说明这台设备没问题",open:null,at:Date.now()},s=await d0(t,this.#e);return this.#l={title:t.title,at:Date.now(),drawn:s},this.#t(),this.#e.sound==="chime"&&!Eh()&&Jp(this.#e.volume,"agent_done"),s}async closeAll(t){for(const s of t)await f0(s)}lastDrawnAt(){return Zp}}const xi=new CR;function ER(){typeof navigator>"u"||!("serviceWorker"in navigator)||navigator.serviceWorker.addEventListener("message",e=>{const t=e.data;t?.t==="agentus:notify-open"&&US(t.open??null)})}function NR(){return g.useSyncExternalStore(xi.subscribe,xi.getSnapshot)}class df extends Error{constructor(){super("unauthorized"),this.name="AuthRequired"}}const em="agentus.unread",RR=8e3,jR=8e3;function TR(){try{const e=localStorage.getItem(em),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}catch{return[]}}function AR(e){try{const t=[...e];t.length?localStorage.setItem(em,JSON.stringify(t)):localStorage.removeItem(em)}catch{}}class MR{sessions=[];cold=[];archived=[];byId=new Map;activeId=null;conn="connecting";net="ok";netError="";auth="unknown";authInfo=null;authError="";authBusy=!1;blocked=null;lastSeq={};ws=null;#e=0;#l=null;#i=[];#s=new Map;#o=new Map;#t=new Set;#n=new Map;#c=new Set;#h=new Set(TR());#_=new Set;#p=new Map;#d=new Set;#f=null;#v;#b(t){try{t?localStorage.setItem("agentus.active",t):localStorage.removeItem("agentus.active")}catch{}}#D(){try{return new URL(location.href).searchParams.get("session")}catch{return null}}#x(t){try{const s=new URL(location.href),n=t??null;if((s.searchParams.get("session")??null)===n)return;n?s.searchParams.set("session",n):s.searchParams.delete("session"),history.replaceState(history.state,"",s.toString())}catch{}}followUrl(){const t=this.#D();!t||t===this.activeId||this.byId.has(t)&&this.setActive(t)}#I(){const t=this.#D();if(t)return this.#b(t),t;try{return localStorage.getItem("agentus.active")}catch{return null}}#k=0;constructor(){this.#v=this.#w()}async#a(t,s,n){const i=n?.timeoutMs??15e3,r=n?.retry===!1?1:2;let a=null;for(let l=0;l<r;l++){const c=new AbortController,u=setTimeout(()=>c.abort(),i);try{const h=await fetch(t,{...s,signal:c.signal});if(clearTimeout(u),h.status===401)throw this.#S("会话已过期,请重新登录"),new df;const d=h.status===204?null:await h.json().catch(()=>null);if(!h.ok){const p=d?.error??`HTTP ${h.status}`,f=new Error(p);throw f.httpStatus=h.status,f.httpBody=d,f}return this.#m(!0,""),d}catch(h){if(clearTimeout(u),h instanceof df||h.httpStatus!==void 0)throw h;a=h;const d=h?.name==="AbortError"?`请求超时 ${i/1e3}s`:String(h?.message??h);if(l===r-1)throw this.#m(!1,`${d} (${t})`),new Error(d);await new Promise(p=>setTimeout(p,600))}}throw a instanceof Error?a:new Error(String(a))}#m(t,s){const n=t?"ok":"degraded";this.net===n&&this.netError===s||(this.net=n,this.netError=s,this.bump())}#S(t){const s=this.auth==="in";if(this.auth="out",this.authError=s?t:this.authError,this.ws){const n=this.ws;this.ws=null,n.onclose=null;try{n.close()}catch{}}this.conn="offline",(s||this.sessions.length)&&(this.sessions=[],this.cold=[],this.archived=[],this.byId.clear(),this.activeId=null,this.#b(null)),this.bump()}async checkAuth(){try{const t=await this.#a("/api/auth/me",void 0,{retry:!1,timeoutMs:8e3});if(this.authInfo=t,t.authEnabled&&!t.authenticated){this.#S(""),this.authError="";return}this.#e=0,this.auth="in",this.authError="",this.bump(),this.connect(),this.refreshRows()}catch(t){if(t instanceof df)return;const s=`无法连接服务端:${String(t.message??t)}`;if(this.auth==="in"){this.#m(!1,s),this.#C(Math.min(1e4,800*2**this.#e++));return}this.auth="out",this.authError=s,this.bump()}}#C(t){this.#l||(this.#l=setTimeout(()=>{this.#l=null,this.checkAuth()},t))}async login(t,s){if(this.authBusy)return!1;this.authBusy=!0,this.authError="",this.bump();try{const n=await fetch("/api/auth/login",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:t,password:s})});if(n.status===401)return this.authError="用户名或密码不正确",!1;if(n.status===429){const r=await n.json().catch(()=>({})),a=Math.ceil((r.retryAfterMs??3e4)/1e3);return this.authError=`尝试次数过多,请 ${a} 秒后再试`,!1}if(!n.ok)return this.authError=`登录失败:HTTP ${n.status}`,!1;const i=await n.json();return this.authInfo={authEnabled:!0,authenticated:!0,kind:"session",username:i.username,expiresAt:i.expiresAt??null,usingDefaultPassword:!!i.usingDefaultPassword},this.auth="in",this.authError="",this.bump(),this.connect(),!0}catch(n){return this.authError=`登录请求失败:${String(n.message??n)}`,!1}finally{this.authBusy=!1,this.bump()}}async logout(){try{await fetch("/api/auth/logout",{method:"POST"})}catch{}this.#S(""),this.authError="",this.bump()}subscribe=t=>(this.#d.add(t),()=>this.#d.delete(t));getSnapshot=()=>this.#v;markPermAnswered(t,s,n=!0){this.#p.set(t,{label:s,at:Date.now(),armed:n}),this.bump()}permAnswer(t){const s=this.#p.get(t);if(s)return{label:s.label,at:s.at,lapsed:s.armed&&Date.now()-s.at>RR}}#y(){if(!this.#p.size)return;const t=new Set;for(const s of this.byId.values())for(const n of s.perms)t.add(n.requestId);for(const s of[...this.#p.keys()])t.has(s)||this.#p.delete(s)}#w(){return{sessions:this.sessions,cold:this.cold,archived:this.archived,activeId:this.activeId,active:this.activeId?this.byId.get(this.activeId):void 0,conn:this.conn,net:this.net,netError:this.netError,auth:this.auth,authInfo:this.authInfo,authError:this.authError,authBusy:this.authBusy,blocked:this.blocked,unread:new Set([...this.#c,...this.#h]),version:this.#k}}bump(){this.#k++,this.#f==null&&(typeof requestAnimationFrame=="function"?this.#f=requestAnimationFrame(()=>{this.#f=null,this.#E()}):typeof setTimeout=="function"?this.#f=setTimeout(()=>{this.#f=null,this.#E()},0):this.#E()),this.#$()}#E(){this.#f!=null&&(typeof cancelAnimationFrame=="function"?cancelAnimationFrame(this.#f):typeof clearTimeout=="function"&&clearTimeout(this.#f),this.#f=null);for(const t of this.byId.values())t.busy=t.info.status==="running";this.#v=this.#w();for(const t of this.#d)t()}#$(){typeof document>"u"||!document.hidden||this.#f!=null&&this.#E()}connect(){if(this.auth==="out")return;const t=location.protocol==="https:"?"wss":"ws",s=new WebSocket(`${t}://${location.host}/ws`);this.ws=s,s.onopen=()=>{for(this.conn="online",this.net="ok",this.netError="",this.#e=0,s.send(JSON.stringify({t:"resume",lastSeq:this.lastSeq}));this.#i.length;){const n=this.#i.shift();try{s.send(JSON.stringify(n))}catch{this.#i.unshift(n);break}}this.bump(),this.refreshRows(),window.setTimeout(()=>this.drainPersistedQueues(),700)},s.onmessage=n=>this.apply(JSON.parse(n.data)),s.onclose=()=>{if(this.conn="offline",this.bump(),this.auth==="out")return;const n=Math.min(1e4,800*2**this.#e++);this.#C(n)},s.onerror=()=>s.close()}sendPrompt(t,s,n=[]){!s.trim()&&!n.length||this.#T(t,{text:s,attachments:n})}#T(t,s){const n=`p-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,i={t:"prompt",sessionId:t,text:s.text,attachments:s.attachments,pid:n,...s.interrupt?{interrupt:!0}:{}};if(!this.send(i)){if(s.rowId){const l=this.#s.get(t)??[];this.#g(t,l.map(c=>c.id===s.rowId?{...c,inflight:!1}:c))}return}const a=setTimeout(()=>this.#H(n),jR);this.#n.set(n,{sessionId:t,pid:n,text:s.text,attachments:s.attachments,rowId:s.rowId,timer:a})}#P(t,s){const n=s?this.#n.get(s):[...this.#n.values()].find(r=>r.sessionId===t);if(!n)return;for(const r of[...this.#n.values()])r.sessionId===t&&(clearTimeout(r.timer),this.#n.delete(r.pid));clearTimeout(n.timer),this.#n.delete(n.pid);const i=this.#s.get(t)??[];i.some(r=>r.pid===n.pid)&&this.#g(t,i.filter(r=>r.pid!==n.pid))}#r(t){const s=this.#n.get(t);s&&(clearTimeout(s.timer),this.#n.delete(t))}#H(t){const s=this.#n.get(t);if(!s)return;this.#n.delete(t),this.#t.delete(s.sessionId);const n=this.#s.get(s.sessionId)??[];s.rowId&&n.some(i=>i.id===s.rowId)?this.#g(s.sessionId,n.map(i=>i.id===s.rowId?{...i,inflight:!1,unsure:!0}:i)):n.some(i=>i.pid===s.pid)||this.#g(s.sessionId,[...n,{id:`q-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,text:s.text,attachments:s.attachments,at:Date.now(),unsure:!0,pid:s.pid}]),this.#m(!1,"消息未确认送达 — 已放回队列,点 ↑ 重发")}send(t){return this.auth==="out"?(this.#m(!1,"未登录 — 请先登录再发送指令"),!1):this.ws?.readyState===WebSocket.OPEN?(this.ws.send(JSON.stringify(t)),!0):t.t==="prompt"?(this.enqueuePrompt(t.sessionId,t.text,t.attachments??[]),this.#m(!1,"连接已断开 — 消息已排队,重连后自动发送"),!1):t.t==="respond-permission"?(this.#i.push(t),this.#i.length>20&&this.#i.shift(),this.#m(!1,"连接已断开 — 指令已排队,重连后自动发送"),!1):(this.#m(!1,"连接已断开 — 该操作未能送达"),!1)}#L(t){return`agentus.queue.${t}`}#U(t){try{const s=localStorage.getItem(this.#L(t)),n=s?JSON.parse(s):[];return Array.isArray(n)?n.filter(i=>i&&typeof i.text=="string"&&i.text.trim()).map(i=>({id:String(i.id??`q-${i.at??Date.now()}`),text:i.text,attachments:i.attachments??[],at:i.at??Date.now(),...i.unsure?{unsure:!0,pid:typeof i.pid=="string"?i.pid:void 0}:{}})):[]}catch{return[]}}#N(t){const s=this.#s.get(t)??this.#U(t);return s.length&&this.#s.set(t,s),s}drainPersistedQueues(){try{for(let t=0;t<localStorage.length;t++){const s=localStorage.key(t);if(!s?.startsWith("agentus.queue."))continue;const n=s.slice(14);this.#N(n),this.drainQueue(n)}}catch{}}#g(t,s){s.length?this.#s.set(t,s):this.#s.delete(t);try{s.length?localStorage.setItem(this.#L(t),JSON.stringify(s)):localStorage.removeItem(this.#L(t))}catch{}const n=this.byId.get(t);n&&(n.queue=s),this.bump()}queueSetup(t,s){s.length&&this.#o.set(t,s)}#W(t){const s=this.#o.get(t);if(s?.length){this.#o.delete(t);for(const n of s)n.kind==="model"?this.send({t:"set-model",sessionId:t,modelId:n.value}):n.kind==="mode"?this.send({t:"set-mode",sessionId:t,modeId:n.value}):this.send({t:"set-config",sessionId:t,configId:n.id,value:n.value})}}enqueuePrompt(t,s,n=[]){const i=this.#s.get(t)??[];this.#g(t,[...i,{id:`q-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,text:s,attachments:n,at:Date.now()}])}sendToCold(t,s,n=[]){const i=this.#s.get(t)??this.#N(t),r=i[i.length-1],a=this.sessions.some(u=>u.id===t&&u.status==="ready"),l=!!(r&&r.text===s&&!a&&Date.now()-r.at<5e3),c=!s.trim()&&!n.length;!l&&!c&&this.enqueuePrompt(t,s,n),this.resume(t)}dropQueued(t,s){const n=this.#s.get(t)??[];this.#g(t,n.filter(i=>i.id!==s))}editQueued(t,s,n){const i=this.#s.get(t)??[],r=n.trim();this.#g(t,r?i.map(a=>a.id===s?{...a,text:r}:a):i.filter(a=>a.id!==s))}sendQueuedNow(t,s){const n=this.#s.get(t)??[],i=n.find(r=>r.id===s);i&&(this.#t.add(t),this.#g(t,n.map(r=>r.id===s?{...r,inflight:!0,unsure:!1}:r)),this.#T(t,{text:i.text,attachments:i.attachments,interrupt:!0,rowId:s}))}sendNow(t,s,n=[]){if(!s.trim()&&!n.length)return;this.#N(t),this.enqueuePrompt(t,s,n);const i=this.#s.get(t)??[],r=i[i.length-1];r&&this.sendQueuedNow(t,r.id)}drainQueue(t){const s=this.#s.get(t)??this.#N(t),n=s[0];!n||n.inflight||n.unsure||this.#t.has(t)||Zr(this.byId.get(t))||this.sessions.find(r=>r.id===t)?.status==="running"||(this.#g(t,s.map(r=>r.id===n.id?{...r,inflight:!0}:r)),this.#T(t,{text:n.text,attachments:n.attachments,interrupt:!0,rowId:n.id}))}#F(t){this.#t.delete(t);const s=this.#s.get(t)??[];s.some(n=>n.inflight)&&this.#g(t,s.filter(n=>!n.inflight))}#O(t){this.#t.delete(t);const s=this.#s.get(t)??[];s.some(n=>n.inflight)&&this.#g(t,s.map(n=>n.inflight?{...n,inflight:!1}:n))}setActive(t){this.activeId=t,this.#b(t),this.#x(t),this.clearUnread(t),this.#v=this.#w(),this.bump();const s=this.byId.get(t);s&&!s.loaded&&this.loadHistory(t)}markUnread(t){this.#c.has(t)||(this.#c=new Set(this.#c).add(t),this.bump())}clearUnread(t){if(!this.#c.has(t))return;const s=new Set(this.#c);s.delete(t),this.#c=s,this.bump()}isUnread(t){return this.#c.has(t)||this.#h.has(t)}toggleUnread(t){if(this.isUnread(t)){const s=new Set(this.#c);s.delete(t),this.#c=s;const n=new Set(this.#h);n.delete(t),this.#h=n}else this.#h=new Set(this.#h).add(t);AR(this.#h),this.bump()}async loadHistory(t){try{const{messages:s,hasOlder:n}=await this.#a(`/api/sessions/${t}/messages?tail=1`),i=this.#u(t);i.seen.clear(),i.msgs=[],i.blocks.clear(),i.minSeq=null,i.plan=null,i.turn=0,i.turnStart=0;for(const r of s)this.#B(i,r);i.loaded=!0,i.hasOlder=!!n,this.#M(i),this.#q(i),this.bump(),this.#K(i)}catch{}}async loadEarlier(t){const s=this.#u(t);if(s.loadingOlder||!s.hasOlder||s.minSeq==null)return 0;s.loadingOlder=!0,this.bump();try{const{messages:n,hasOlder:i}=await this.#a(`/api/sessions/${t}/messages?before=${s.minSeq}`),r=[],a=new Map;for(const c of n)this.#B(s,c,{list:r,index:a});const l=[];for(const c of r){const u=s.blocks.get(c.key),h=u===void 0?void 0:s.msgs[u];if(h&&h.kind===c.kind&&(c.kind==="agent"||c.kind==="thought")&&h.kind===c.kind){const d=h,p=c;if(p.text.length>d.text.length){const f=s.msgs.indexOf(d);f>=0&&(s.msgs[f]={...d,text:p.text})}continue}l.push(c)}return l.length&&(s.msgs=[...l,...s.msgs]),s.blocks=t0(s.msgs),s.hasOlder=!!i,l.length}catch{return-1}finally{s.loadingOlder=!1,this.bump()}}async loadBackends(){return await this.#a("/api/backends")}async createBackend(t){await this.#a("/api/backends",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)})}async updateBackend(t,s){await this.#a(`/api/backends/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(s)})}async deleteBackend(t){await this.#a(`/api/backends/${encodeURIComponent(t)}`,{method:"DELETE"})}async inspectBackend(t){return await this.#a(`/api/backends/${encodeURIComponent(t)}/inspect`,{method:"POST"},{timeoutMs:6e4,retry:!1})}async listEntries(t){return await this.#a(`/api/fs/dirs?files=1&path=${encodeURIComponent(t)}`)}async readFile(t){return await this.#a(`/api/fs/file?path=${encodeURIComponent(t)}`)}async statFile(t){return await this.#a(`/api/fs/stat?path=${encodeURIComponent(t)}`)}async writeFile(t,s,n){return await this.#a("/api/fs/file",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({path:t,content:s,...n?{ifHash:n}:{}})},{retry:!1})}async fork(t){const s=await this.#a(`/api/sessions/${t}/fork`,{method:"POST"},{timeoutMs:12e4,retry:!1});return this.sessions.some(n=>n.id===s.id)||(this.sessions=[s,...this.sessions]),this.cold=this.cold.filter(n=>n.id!==s.id),this.archived=this.archived.filter(n=>n.id!==s.id),this.setActive(s.id),s.id}async setModel(t,s){const n=await this.#a(`/api/sessions/${t}/model`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({modelId:s})},{timeoutMs:9e4,retry:!1}),i=this.byId.get(t);i&&(i.info={...i.info,...n});const r=this.sessions.findIndex(a=>a.id===t);return r>=0&&(this.sessions[r]={...this.sessions[r],...n}),this.bump(),n}async setContextLimit(t,s,n={}){const i=await this.#a(`/api/sessions/${t}/context-limit`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({limit:s,...n})}),r=this.byId.get(t);r&&(r.info={...r.info,...i});const a=this.sessions.findIndex(c=>c.id===t);a>=0&&(this.sessions[a]={...this.sessions[a],...i});const l=this.archived.findIndex(c=>c.id===t);l>=0&&(this.archived[l]={...this.archived[l],...i}),this.bump()}async setWorkspace(t,s){const n=await this.#a(`/api/sessions/${t}/workspace`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:s})}),i=this.byId.get(t);i&&(i.info={...i.info,...n});const r=this.sessions.findIndex(a=>a.id===t);r>=0&&(this.sessions[r]={...this.sessions[r],...n}),this.bump()}async createSession(t,s,n){const i=await this.#a("/api/sessions",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({backend:t,cwd:s,title:n||void 0})},{retry:!1}),r=this.#u(i.id);return r.info={...r.info,...i},this.sessions.some(a=>a.id===i.id)||(this.sessions=[i,...this.sessions]),this.bump(),i.id}async refreshRows(){try{const{cold:t,archived:s}=await this.#a("/api/sessions");this.cold=t??[],this.archived=s??[],this.bump()}catch{}}async rename(t,s){const n=await this.#a(`/api/sessions/${t}/rename`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:s})}),i=this.byId.get(t);i&&(i.info={...i.info,...n});for(const r of[this.sessions,this.archived]){const a=r.findIndex(l=>l.id===t);a>=0&&(r[a]={...r[a],...n})}return this.bump(),n}async regenerateTitle(t){const s=await this.#a(`/api/sessions/${t}/title/regenerate`,{method:"POST"}),n=s.info,i=this.byId.get(t);i&&(i.info={...i.info,...n});for(const r of[this.sessions,this.cold,this.archived]){const a=r.findIndex(l=>l.id===t);a>=0&&(r[a]={...r[a],...n})}return this.bump(),s}async resume(t){if(this.#u(t),this.setActive(t),!this.#_.has(t)){this.#_.add(t),this.#u(t).resuming=!0,this.bump();try{const s=await this.#a(`/api/sessions/${t}/resume`,{method:"POST"},{timeoutMs:12e4,retry:!1});this.#u(t).info=s,this.sessions.some(n=>n.id===t)||(this.sessions=[s,...this.sessions]),this.cold=this.cold.filter(n=>n.id!==t),await this.loadHistory(t)}catch(s){const n=s.httpStatus,i=s.httpBody;if(n===409&&(i?.code==="home_mismatch"||i?.code==="context_missing")){const r=this.sessions.find(a=>a.id===t)??this.cold.find(a=>a.id===t)??this.archived.find(a=>a.id===t);this.blocked={id:t,title:r?.title??t,code:i.code,sessionHome:i.sessionHome??null,rowHome:i.rowHome??null},this.bump();return}this.#m(!1,`恢复失败:${String(s.message??s)}`)}finally{this.#_.delete(t),this.#u(t).resuming=!1,this.bump()}}}async restart(t){try{const s=await this.#a(`/api/sessions/${t}/restart`,{method:"POST"},{timeoutMs:12e4,retry:!1}),n=this.#u(t);n.info={...n.info,...s};for(const i of[this.sessions,this.cold,this.archived]){const r=i.findIndex(a=>a.id===t);r>=0&&(i[r]={...i[r],...s})}this.bump()}catch(s){const n=s.httpStatus,i=s.httpBody;if(n===409&&(i?.code==="home_mismatch"||i?.code==="context_missing")){const r=this.sessions.find(a=>a.id===t);this.blocked={id:t,title:r?.title??t,code:i.code,sessionHome:i.sessionHome??null,rowHome:i.rowHome??null},this.bump();return}this.#m(!1,`重启 agent 进程失败:${String(s.message??s)}`)}}dismissBlocked(){this.blocked=null,this.bump()}deleteBlocked(){const t=this.blocked;this.blocked=null,t&&this.purgeCold(t.id),this.bump()}purgeCold(t){this.sessions=this.sessions.filter(s=>s.id!==t),this.cold=this.cold.filter(s=>s.id!==t),this.archived=this.archived.filter(s=>s.id!==t),this.byId.delete(t),this.bump(),this.#a(`/api/sessions/${t}`,{method:"DELETE"}).catch(()=>this.refreshRows()).then(()=>this.refreshRows())}async setArchived(t,s){try{const n=await this.#a(`/api/sessions/${t}/${s?"archive":"unarchive"}`,{method:"POST"}),i=this.byId.get(t);return i&&(i.info={...i.info,...n}),s?(this.sessions=this.sessions.filter(r=>r.id!==t),this.cold=this.cold.filter(r=>r.id!==t),this.archived.some(r=>r.id===t)||(this.archived=[n,...this.archived]),this.activeId===t&&this.#R()):(this.archived=this.archived.filter(r=>r.id!==t),!this.sessions.some(r=>r.id===t)&&!this.cold.some(r=>r.id===t)&&(this.cold=[n,...this.cold])),this.bump(),n}catch(n){return this.#m(!1,`${s?"归档":"取消归档"}失败:${String(n.message??n)}`),null}}async unarchiveAndResume(t){await this.setArchived(t,!1),await this.resume(t)}#R(){const t=this.sessions[0]??this.cold[0]??this.archived[0]??null;this.activeId=t?.id??null,this.#b(this.activeId),t&&!this.sessions.some(s=>s.id===t.id)&&this.loadHistory(t.id)}#A(t,s,n,i,r,a){const l=t.plan;if(!l){t.plan={key:`plan-${t.turn}`,items:s,terminal:n,explanation:r,at:i,turn:t.turn,title:a??void 0};return}if(l.turn===t.turn){l.items=s,l.terminal=n,l.explanation=r,a!==void 0&&(l.title=a??void 0);return}const c=t.turnStart>0&&t.turnStart<=t.msgs.length?t.turnStart:t.msgs.length;t.msgs.splice(c,0,{key:l.key,kind:"plan",items:l.items,terminal:l.terminal,explanation:l.explanation,at:l.at,title:l.title}),t.blocks=t0(t.msgs),t.turnStart=Math.min(t.turnStart+1,t.msgs.length),t.plan={key:`plan-${t.turn}`,items:s,terminal:n,explanation:r,at:i,turn:t.turn,title:a??void 0}}#j(t,s){this.#A(t,s.items.map(n=>({content:n.content,status:n.status,priority:n.priority})),s.terminal??void 0,s.updatedAt,s.explanation??void 0,s.title?.trim()||null)}async#K(t){try{const{plan:s}=await this.#a(`/api/sessions/${t.info.id}/plan`);if(!s)return;this.#j(t,s),this.bump()}catch{}}#u(t){let s=this.byId.get(t);return s||(s={info:this.sessions.find(n=>n.id===t)??{id:t},msgs:[],notes:[],perms:[],busy:!1,busySince:null,loaded:!1,hasOlder:!1,loadingOlder:!1,minSeq:null,lastAt:Date.now(),rev:0,seen:new Set,blocks:new Map,plan:null,turn:0,turnStart:0,queue:this.#N(t)},this.byId.set(t,s)),s}apply(t){switch(t.t){case"hello":break;case"sessions":{this.sessions=t.sessions,t.cold&&(this.cold=t.cold),t.archived&&(this.archived=t.archived);const s=new Set([...t.sessions.map(n=>n.id),...this.cold.map(n=>n.id),...this.archived.map(n=>n.id)]);for(const n of[...t.sessions,...this.cold,...this.archived]){const i=this.#u(n.id);i.info={...i.info,...n}}if(t.background){const n=new Set(t.background.map(i=>i.sessionId));for(const i of t.background)this.#u(i.sessionId).background=i.tasks;for(const[i,r]of this.byId)!n.has(i)&&r.background?.length&&(r.background=[])}if(t.pending){const n=new Map;for(const i of t.pending){const r=n.get(i.sessionId);r?r.push(i):n.set(i.sessionId,[i])}for(const[i,r]of n)this.#u(i).perms=r;for(const i of this.byId.values())n.has(i.info.id)||(i.perms=[]);this.#y()}for(const n of[...this.byId.keys()])s.has(n)||this.byId.delete(n);if(this.activeId&&!s.has(this.activeId)&&(this.activeId=null,this.#b(null)),!this.activeId&&s.size){const n=this.#I(),i=n&&s.has(n)?n:t.sessions[0]?.id??this.cold[0]?.id??this.archived[0]?.id;i&&(this.activeId=i,this.loadHistory(i))}for(const n of this.sessions)n.status==="ready"&&this.#s.get(n.id)?.length&&this.drainQueue(n.id);break}case"session":{t.session.cold===!0?(this.sessions=this.sessions.filter(s=>s.id!==t.session.id),this.cold=this.cold.map(s=>s.id===t.session.id?t.session:s),this.cold.some(s=>s.id===t.session.id)||this.cold.push(t.session)):(this.sessions=this.sessions.map(s=>s.id===t.session.id?t.session:s),this.sessions.some(s=>s.id===t.session.id)||this.sessions.push(t.session),this.cold=this.cold.filter(s=>s.id!==t.session.id)),this.#u(t.session.id).info=t.session,t.session.status==="ready"&&this.#W(t.session.id),t.session.status==="ready"&&this.#s.get(t.session.id)?.length&&this.drainQueue(t.session.id);break}case"messages":{const s=this.#u(t.sessionId);if(t.partial){for(const n of t.messages)this.#B(s,n,{resync:!0});s.lastAt=Date.now();break}s.seen.clear(),s.msgs=[],s.blocks.clear(),s.plan=null,s.turn=0,s.turnStart=0,this.#M(s);for(const n of t.messages)this.#B(s,n);s.loaded=!0;break}case"message":{const s=this.#u(t.message.sessionId),n=t.message.payload?.rejectedPrompt,i=t.message.payload?.pid;typeof i=="string"&&this.#r(i),t.message.kind==="meta"&&typeof n=="string"&&n.trim()&&this.enqueuePrompt(t.message.sessionId,n),this.#B(s,t.message,{delta:t.delta,n:t.n}),s.lastAt=Date.now(),this.lastSeq[t.message.sessionId]=Math.max(this.lastSeq[t.message.sessionId]??0,t.message.seq);break}case"status":{const s=this.#u(t.sessionId),n=Date.now(),i=s.notes[s.notes.length-1],r=s.msgs.length?s.msgs[s.msgs.length-1].key:null;i&&t.statusKind&&i.kind===t.statusKind?(i.text=t.text,i.afterKey=r):(s.notes.push({key:`st-${n}-${s.notes.length}`,kind:t.statusKind,text:t.text,at:n,afterKey:r}),s.notes.length>200&&s.notes.splice(0,s.notes.length-200)),s.lastAt=n;break}case"background":{this.#u(t.sessionId).background=t.tasks;break}case"turn-start":{const s=this.#u(t.sessionId);s.busy=!0,s.busySince=Date.now(),s.lastAt=Date.now(),s.trace=t.trace??null,this.#F(t.sessionId),this.#P(t.sessionId,t.pid);break}case"plan":{const s=this.#u(t.sessionId);this.#j(s,t.plan),s.lastAt=Date.now();break}case"speak":{const s=this.#u(t.sessionId),n={id:t.id,text:t.text,kind:t.kind,priority:t.priority,at:Date.now()};s.speaks=[...s.speaks??[],n].slice(-10);break}case"usage":{const s=this.#u(t.sessionId);s.info={...s.info,usage:t.usage},s.lastAt=Date.now();break}case"turn-end":{const s=this.#u(t.sessionId);if(s.busy=!1,t.sessionId!==this.activeId&&this.markUnread(t.sessionId),s.busySince=null,this.#M(s),t.error&&s.msgs.push({key:`err-${Date.now()}`,kind:"meta",text:t.error}),t.error?this.#O(t.sessionId):this.#F(t.sessionId),!t.error){const n=t.sessionId;window.setTimeout(()=>this.drainQueue(n),250)}break}case"permission":this.#u(t.request.sessionId).perms.push(t.request);break;case"permission-resolved":for(const s of this.byId.values())s.perms=s.perms.filter(n=>n.requestId!==t.requestId);this.#y();break;case"permission-expired":for(const s of this.byId.values())s.perms=s.perms.filter(n=>n.requestId!==t.requestId);this.#y(),this.#u(t.sessionId).msgs.push({key:`perm-exp-${t.requestId}`,kind:"meta",text:"这条审批已经过期:agent 等不到答复、先自己放过了(或它已经放弃这一轮)。你的点击没有生效。"});break;case"config-rejected":{const s=this.#u(t.sessionId),n=t.name||t.configId;s.msgs.push({key:`cfg-rej-${t.configId}-${Date.now()}`,kind:"meta",text:`${n} 这一档没生效:agent 没有接受「${t.value}」${t.actual?`,实际仍是「${t.actual}」`:""}。(模型只认它公布的那几档;换档位或换模型再试。)`});break}case"notify":{xi.handle(t.notice);break}case"error":{this.activeId&&this.#u(this.activeId).msgs.push({key:`e-${Date.now()}`,kind:"meta",text:t.error});break}}this.bump()}#M(t){for(let s=0;s<t.msgs.length;s++){const n=t.msgs[s];(n.kind==="agent"||n.kind==="thought")&&n.open&&(t.msgs[s]={...n,open:!1})}}#q(t){const s=t.msgs[t.msgs.length-1];s&&(s.kind==="agent"||s.kind==="thought")&&t.busy&&!s.open&&(t.msgs[t.msgs.length-1]={...s,open:!0})}#z(t,s){for(let n=0;n<t.length;n++){const i=t[n];i.kind==="thought"&&i.open&&i.key!==s&&(t[n]={...i,open:!1})}}#B(t,s,n){const i=n?.list??t.msgs,r=n?.index??t.blocks,a=n?.delta,l=s.payload;let c=null;const u=a!==void 0,h=(s.kind==="agent"||s.kind==="thought")&&e0(s.kind,l)!==null;if(!(n?.resync===!0&&(s.kind==="tool"||s.kind==="plan"||s.kind==="user"||s.kind==="meta"||h)||s.kind==="tool"||s.kind==="meta"||s.kind==="note"||s.kind==="approval"||s.kind==="project-skills"||s.seq<=0||u)){if(t.seen.has(s.seq))return;t.seen.add(s.seq)}s.seq>0&&(t.minSeq==null||s.seq<t.minSeq)&&(t.minSeq=s.seq);const f=s.payload,m=typeof s.createdAt=="number"?s.createdAt:Date.now(),b=DR(f);switch(i[i.length-1],s.kind){case"user":if(i.some(v=>v.key===`m${s.seq}`))break;const _=f.origin??null;i.push({key:`m${s.seq}`,kind:"user",text:String(f.text??""),at:m,..._&&typeof _.sessionId=="string"?{from:{id:_.sessionId,title:String(_.title??"").trim()||"另一个会话"}}:{},files:Array.isArray(f.attachments)?f.attachments.map(v=>({kind:String(v.kind??""),name:String(v.name??"file")})):[]}),n?.list||(t.turn+=1,t.turnStart=i.length-1);break;case"agent":case"thought":{const v=s.kind,y=e0(v,f),{at:w}=ON(i,r,{key:y,kind:v,text:b,delta:a,n:n?.n},(S,E)=>({key:S,kind:E.kind,text:E.text,open:!0,at:m})),x=i[w];a!==void 0&&t.info.status==="running"&&x&&(x.kind==="agent"||x.kind==="thought")&&!x.open&&(i[w]={...x,open:!0}),v==="thought"&&(c=i[w]?.key??null);break}case"note":{const v=`n${s.seq}`,y=typeof f.hits=="number"?f.hits:void 0,w={key:v,kind:"note",category:String(f.category??""),text:typeof f.text=="string"?f.text:"",hits:y,at:m,items:Array.isArray(f.items)?f.items.filter(S=>S&&typeof S.text=="string"&&S.text.trim()):void 0,truncated:f.truncated===!0},x=r.get(v);x!==void 0&&i[x]?.kind==="note"?i[x]=w:(i.push(w),r.set(v,i.length-1));break}case"approval":{const v=`p${s.seq}`,y=f.decision,w={key:v,kind:"approval",requestId:String(f.requestId??""),title:String(f.toolCallTitle??"tool call"),kind2:String(f.kind??"other"),path:typeof f.path=="string"?f.path:null,diff:f.diff??null,options:Array.isArray(f.options)?f.options:[],decision:y??null,at:m},x=r.get(v);x!==void 0&&i[x]?.kind==="approval"?i[x]=w:(i.push(w),r.set(v,i.length-1));break}case"project-skills":{const v=`s${s.seq}`,y={key:v,kind:"project-skills",root:String(f.root??""),count:typeof f.count=="number"?f.count:0,text:String(f.text??""),state:String(f.state??"ask"),at:m},w=r.get(v);w!==void 0&&i[w]?.kind==="project-skills"?i[w]=y:(i.push(y),r.set(v,i.length-1));break}case"tool":{const v=String(f.toolCallId??s.toolCallId??s.seq),y=i.find(N=>N.kind==="tool"&&N.toolCallId===v),w=IR(f),x=PR(f),S=new Set((y?.changes??[]).map(N=>`${N.path}\0${N.oldText??""}\0${N.newText??""}\0${N.diffText??""}`)),E=FN(f).filter(N=>!S.has(`${N.path}\0${N.oldText??""}\0${N.newText??""}\0${N.diffText??""}`)),R=E.length?[...y?.changes??[],...E]:y?.changes;if(y){const N=i.indexOf(y),I={...y,title:f.title?String(f.title):y.title,status:f.status?String(f.status):y.status,detail:w??y.detail,input:x??y.input,changes:R};N>=0&&(i[N]=I)}else i.push({key:`tc-${v}`,kind:"tool",toolCallId:v,at:m,title:String(f.title??"tool call"),status:String(f.status??"pending"),kind2:String(f.kind??""),detail:w,input:x,changes:R});break}case"plan":{const v=f._meta??{},y=(f.entries??[]).map(S=>({content:String(S?.content??""),status:String(S?.status??"pending"),priority:S?.priority})),w=typeof f._slotPlanTerminal=="string"?f._slotPlanTerminal:void 0,x=typeof v["agentus/explanation"]=="string"?String(v["agentus/explanation"]):void 0;if(n?.list){const S=i.find(E=>E.kind==="plan");if(S&&S.kind==="plan"){const E=i.indexOf(S);i[E]={...S,items:y,terminal:w,explanation:x}}else i.push({key:`m${s.seq}`,kind:"plan",items:y,terminal:w,explanation:x,at:m});break}this.#A(t,y,w,m,x);break}case"meta":if(i.some(v=>v.key===`m${s.seq}`))break;i.push({key:`m${s.seq}`,kind:"meta",text:b||JSON.stringify(f)});break}this.#z(i,c),this.lastSeq[t.info.id]=Math.max(this.lastSeq[t.info.id]??0,s.seq),t.rev+=1,t.lastAt=Date.now()}}function DR(e){const t=e.content;return t?.type==="text"&&typeof t.text=="string"?t.text:""}function IR(e){const s=r=>r.length>4e3?`${r.slice(0,4e3)}
44
+ … (${r.length-4e3} more chars)`:r,n=e.rawOutput;if(typeof n=="string"&&n.trim())return s(n);if(n&&typeof n=="object")try{return s(JSON.stringify(n,null,1))}catch{}const i=e.content;if(Array.isArray(i)){const r=[];for(const a of i){const l=String(a?.type??"");if(l==="content"){const c=a.content;c?.type==="text"&&c.text&&r.push(String(c.text))}else if(l==="diff"){const c=String(a.path??"file"),u=typeof a.newText=="string"?a.newText:"";r.push(`--- ${c}
45
+ ${u.slice(0,1500)}`)}else if(l==="terminal"){const c=a.output;c&&r.push(String(c))}}if(r.length)return s(r.join(`
46
+ `))}return""}function PR(e){const t=e.rawInput;if(typeof t=="string"&&t.trim())return t.slice(0,1200);if(t&&typeof t=="object")try{return JSON.stringify(t,null,1).slice(0,1200)}catch{return""}return""}const ee=new MR;if(typeof window<"u"){const e=window;e.__agentusOpenSession=t=>{const s=String(t??"").trim();if(!s||!ee.byId.has(s))return!1;ee.setActive(s);const n=ee.byId.get(s);return n&&!n.loaded&&ee.resume(s).catch(()=>{}),!0},window.addEventListener("popstate",()=>ee.followUrl())}function Zr(e){return!!(e&&(e.busy||e.info.status==="running"))}function Rh(e){return`/api/fs/raw?path=${encodeURIComponent(e)}`}async function fd(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="-1000px",t.style.opacity="0",document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);const s=document.execCommand("copy");return t.remove(),s}catch{return!1}}const tm=new Set;function LR(e){return tm.add(e),()=>{tm.delete(e)}}function WS(e){for(const t of[...tm])try{t(e)}catch{}}const sm="data-agentus-table",OR=4,nm="⇕",BR={asc:"▲",desc:"▼",none:nm};function im(e){if(!e)return"";const t=e.querySelector(".md-table-sort");return t?(t.querySelector(".md-table-sort-label")?.textContent??"").trim():(e.textContent??"").trim()}function $R(e,t,s){const n=e.tBodies[0];if(!n)return;const i=Array.from(n.rows).filter(a=>a.parentElement===n),r=a=>Number(a.dataset.mdRow??0);i.sort((a,l)=>{if(s==="none")return r(a)-r(l);const c=im(a.cells[t]).localeCompare(im(l.cells[t]),void 0,{numeric:!0,sensitivity:"base"});return c!==0?s==="asc"?c:-c:r(a)-r(l)});for(const a of i)n.appendChild(a)}function FR(e){const t=e.cloneNode(!0);t.removeAttribute(sm);for(const s of Array.from(t.querySelectorAll(".md-table-sort"))){const n=s.querySelector(".md-table-sort-label"),i=s.parentElement;i&&n&&(i.textContent=n.textContent??"",i.removeAttribute("aria-sort"))}return t}function zR(e){if(document.querySelector(".md-table-overlay"))return;const t=document.createElement("div");t.className="md-table-overlay",t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","table");const s=document.createElement("div");s.className="md-table-bar";const n=document.createElement("button");n.type="button",n.className="md-table-btn",n.textContent="rotate";const i=document.createElement("span");i.className="head-spacer";const r=document.createElement("button");r.type="button",r.className="md-table-btn",r.textContent="copy";const a=document.createElement("button");a.type="button",a.className="md-table-btn",a.textContent="close",a.setAttribute("aria-label","close table"),s.append(n,i,r,a);const l=document.createElement("div");l.className="md-table-stage";const c=document.createElement("div");c.className="md-table-zoom md";const u=FR(e);c.appendChild(u),l.appendChild(c),t.append(s,l),document.body.appendChild(t),a_(c);const h=window.innerHeight>window.innerWidth;c.classList.toggle("rot",h);const d=()=>{t.remove(),window.removeEventListener("keydown",p)},p=f=>{f.key==="Escape"&&d()};window.addEventListener("keydown",p),n.addEventListener("click",()=>c.classList.toggle("rot")),a.addEventListener("click",d),t.addEventListener("click",f=>{(f.target===t||f.target===l)&&d()}),r.addEventListener("click",()=>{const f=Array.from(u.rows).map(m=>Array.from(m.cells).map(b=>im(b).replace(/\s+/g," ")).join(" "));fd(f.join(`
47
+ `)).then(m=>{r.textContent=m?"copied":"copy failed",window.setTimeout(()=>{r.textContent="copy"},1200)})}),a.focus()}function a_(e){if(e?.querySelectorAll)for(const t of Array.from(e.querySelectorAll(`table:not([${sm}])`))){if(t.closest(".md-code")||t.closest(".file-source"))continue;const s=t.tHead?.rows[0]??t.rows[0],n=t.tBodies[0];if(!s||!n||n.rows.length===0)continue;t.setAttribute(sm,"1");const i={col:-1,dir:"asc"};Array.from(n.rows).forEach((l,c)=>{l.dataset.mdRow=String(c)});for(const[l,c]of Array.from(s.cells).entries()){const u=(c.textContent??"").trim()||`column ${l+1}`,h=document.createElement("button");h.type="button",h.className="md-table-sort",h.title=`sort by ${u}`,h.setAttribute("aria-label",`sort by ${u}`);const d=document.createElement("span");for(d.className="md-table-sort-label";c.firstChild;)d.appendChild(c.firstChild);const p=document.createElement("span");p.className="md-table-sort-indicator",p.setAttribute("aria-hidden","true"),p.textContent="⇕",c.setAttribute("aria-sort","none"),h.append(d,p),h.addEventListener("click",()=>{const f=i.col!==l?"asc":i.dir==="asc"?"desc":i.dir==="desc"?"none":"asc";i.col=l,i.dir=f;for(const m of Array.from(s.cells)){m.setAttribute("aria-sort","none");const b=m.querySelector(".md-table-sort-indicator");b&&(b.textContent=nm)}f==="none"?(c.setAttribute("aria-sort","none"),p.textContent=nm):(c.setAttribute("aria-sort",f==="asc"?"ascending":"descending"),p.textContent=BR[f]),$R(t,l,f)}),c.appendChild(h)}const r=document.createElement("div");if(r.className="md-table-bar",n.rows.length>=OR){const l=document.createElement("input");l.type="search",l.className="md-table-filter",l.placeholder="filter rows…",l.setAttribute("aria-label",`filter ${s.cells.length}-column table`),l.autocomplete="off",l.addEventListener("input",()=>{const c=l.value.trim().toLowerCase();for(const u of Array.from(n.rows))u.hidden=!!c&&!(u.textContent??"").toLowerCase().includes(c)}),r.appendChild(l)}const a=document.createElement("button");a.type="button",a.className="md-table-btn",a.title="open this table full screen (landscape on a phone)",a.setAttribute("aria-label","open table full screen"),a.textContent="⤢",a.addEventListener("click",()=>zR(t)),r.appendChild(a),t.parentElement?.insertBefore(r,t)}}const p0={};function HR(e){let t=p0[e];if(t)return t;t=p0[e]=[];for(let s=0;s<128;s++){const n=String.fromCharCode(s);t.push(n)}for(let s=0;s<e.length;s++){const n=e.charCodeAt(s);t[n]="%"+("0"+n.toString(16).toUpperCase()).slice(-2)}return t}function wa(e,t){typeof t!="string"&&(t=wa.defaultChars);const s=HR(t);return e.replace(/(%[a-f0-9]{2})+/gi,function(n){let i="";for(let r=0,a=n.length;r<a;r+=3){const l=parseInt(n.slice(r+1,r+3),16);if(l<128){i+=s[l];continue}if((l&224)===192&&r+3<a){const c=parseInt(n.slice(r+4,r+6),16);if((c&192)===128){const u=l<<6&1984|c&63;u<128?i+="��":i+=String.fromCharCode(u),r+=3;continue}}if((l&240)===224&&r+6<a){const c=parseInt(n.slice(r+4,r+6),16),u=parseInt(n.slice(r+7,r+9),16);if((c&192)===128&&(u&192)===128){const h=l<<12&61440|c<<6&4032|u&63;h<2048||h>=55296&&h<=57343?i+="���":i+=String.fromCharCode(h),r+=6;continue}}if((l&248)===240&&r+9<a){const c=parseInt(n.slice(r+4,r+6),16),u=parseInt(n.slice(r+7,r+9),16),h=parseInt(n.slice(r+10,r+12),16);if((c&192)===128&&(u&192)===128&&(h&192)===128){let d=l<<18&1835008|c<<12&258048|u<<6&4032|h&63;d<65536||d>1114111?i+="����":(d-=65536,i+=String.fromCharCode(55296+(d>>10),56320+(d&1023))),r+=9;continue}}i+="�"}return i})}wa.defaultChars=";/?:@&=+$,#";wa.componentChars="";const m0={};function UR(e){let t=m0[e];if(t)return t;t=m0[e]=[];for(let s=0;s<128;s++){const n=String.fromCharCode(s);/^[0-9a-z]$/i.test(n)?t.push(n):t.push("%"+("0"+s.toString(16).toUpperCase()).slice(-2))}for(let s=0;s<e.length;s++)t[e.charCodeAt(s)]=e[s];return t}function Si(e,t,s){typeof t!="string"&&(s=t,t=Si.defaultChars),typeof s>"u"&&(s=!0);const n=UR(t);let i="";for(let r=0,a=e.length;r<a;r++){const l=e.charCodeAt(r);if(s&&l===37&&r+2<a&&/^[0-9a-f]{2}$/i.test(e.slice(r+1,r+3))){i+=e.slice(r,r+3),r+=2;continue}if(l<128){i+=n[l];continue}if(l>=55296&&l<=57343){if(l>=55296&&l<=56319&&r+1<a){const c=e.charCodeAt(r+1);if(c>=56320&&c<=57343){i+=encodeURIComponent(e[r]+e[r+1]),r++;continue}}i+="%EF%BF%BD";continue}i+=encodeURIComponent(e[r])}return i}Si.defaultChars=";/?:@&=+$,-_.!~*'()#";Si.componentChars="-_.!~*'()";function rm(e){let t="";return t+=e.protocol||"",t+=e.slashes?"//":"",t+=e.auth?e.auth+"@":"",e.hostname&&e.hostname.indexOf(":")!==-1?t+="["+e.hostname+"]":t+=e.hostname||"",t+=e.port?":"+e.port:"",t+=e.pathname||"",t+=e.search||"",t+=e.hash||"",t}function jh(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}const WR=/^([a-z0-9.+-]+:)/i,KR=/:[0-9]*$/,qR=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,VR=["<",">",'"',"`"," ","\r",`
48
+ `," "],YR=["{","}","|","\\","^","`"].concat(VR),GR=["'"].concat(YR),g0=["%","/","?",";","#"].concat(GR),_0=["/","?","#"],JR=255,v0=/^[+a-z0-9A-Z_-]{0,63}$/,XR=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y0={javascript:!0,"javascript:":!0},b0={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function om(e,t){if(e&&e instanceof jh)return e;const s=new jh;return s.parse(e,t),s}jh.prototype.parse=function(e,t){let s,n,i,r=e;if(r=r.trim(),!t&&e.split("#").length===1){const u=qR.exec(r);if(u)return this.pathname=u[1],u[2]&&(this.search=u[2]),this}let a=WR.exec(r);if(a&&(a=a[0],s=a.toLowerCase(),this.protocol=a,r=r.substr(a.length)),(t||a||r.match(/^\/\/[^@\/]+@[^@\/]+/))&&(i=r.substr(0,2)==="//",i&&!(a&&y0[a])&&(r=r.substr(2),this.slashes=!0)),!y0[a]&&(i||a&&!b0[a])){let u=-1;for(let m=0;m<_0.length;m++)n=r.indexOf(_0[m]),n!==-1&&(u===-1||n<u)&&(u=n);let h,d;u===-1?d=r.lastIndexOf("@"):d=r.lastIndexOf("@",u),d!==-1&&(h=r.slice(0,d),r=r.slice(d+1),this.auth=h),u=-1;for(let m=0;m<g0.length;m++)n=r.indexOf(g0[m]),n!==-1&&(u===-1||n<u)&&(u=n);u===-1&&(u=r.length),r[u-1]===":"&&u--;const p=r.slice(0,u);r=r.slice(u),this.parseHost(p),this.hostname=this.hostname||"";const f=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!f){const m=this.hostname.split(/\./);for(let b=0,_=m.length;b<_;b++){const v=m[b];if(v&&!v.match(v0)){let y="";for(let w=0,x=v.length;w<x;w++)v.charCodeAt(w)>127?y+="x":y+=v[w];if(!y.match(v0)){const w=m.slice(0,b),x=m.slice(b+1),S=v.match(XR);S&&(w.push(S[1]),x.unshift(S[2])),x.length&&(r=x.join(".")+r),this.hostname=w.join(".");break}}}}this.hostname.length>JR&&(this.hostname=""),f&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}const l=r.indexOf("#");l!==-1&&(this.hash=r.substr(l),r=r.slice(0,l));const c=r.indexOf("?");return c!==-1&&(this.search=r.substr(c),r=r.slice(0,c)),r&&(this.pathname=r),b0[s]&&this.hostname&&!this.pathname&&(this.pathname=""),this};jh.prototype.parseHost=function(e){let t=KR.exec(e);t&&(t=t[0],t!==":"&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)};const ZR=Object.freeze(Object.defineProperty({__proto__:null,decode:wa,encode:Si,format:rm,parse:om},Symbol.toStringTag,{value:"Module"})),KS=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,qS=/[\0-\x1F\x7F-\x9F]/,QR=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/,l_=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B4E\u1B4F\u1B5A-\u1B60\u1B7D-\u1B7F\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDD6E\uDEAD\uDED0\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9\uDFD4\uDFD5\uDFD7\uDFD8]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09\uDFE1]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDD6D-\uDD6F\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD839\uDDFF|\uD83A[\uDD5E\uDD5F]/,VS=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C1\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD803[\uDD8E\uDD8F\uDED1-\uDED8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA]/,YS=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,ej=Object.freeze(Object.defineProperty({__proto__:null,Any:KS,Cc:qS,Cf:QR,P:l_,S:VS,Z:YS},Symbol.toStringTag,{value:"Module"})),tj=[8364,0,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,0,381,0,0,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,0,382,376];function sj(e){return e===0||e>=55296&&e<=57343||e>1114111}function nj(e){return sj(e)?65533:e>=128&&e<=159&&tj[e-128]||e}function ij(e){return e-1>>>0<127||e-160>>>0<55136?String.fromCharCode(e):String.fromCodePoint(nj(e))}const In=(()=>{const e=new Uint8Array(127);let t=0;for(let s=33;s<=126;s++)s!==34&&s!==36&&s!==92&&(e[s]=t++);return e})();function rj(e,t,s,n,i,r){const l=e.length,c=r*90;let u=0;const h=()=>{const I=In[e.charCodeAt(u++)];return I<r?I:I*91-c+In[e.charCodeAt(u++)]},d=s-n,p=s+i,f=new Int32Array(p);f.fill(-1,n,r),f.fill(-1,r+d,p);const m=new Int32Array(p),b=new Int32Array(p);function _(I,F){let B=0,C=F;const A=F+I;for(;C<A;){const M=In[e.charCodeAt(u++)];if(M<89)B+=M,f[C++]=B;else if(M===89){let H=In[e.charCodeAt(u++)]+2;for(;H--;)f[C++]=++B}else{const H=In[e.charCodeAt(u++)];B+=89+(H<90?H*91+In[e.charCodeAt(u++)]:In[e.charCodeAt(u++)]*8281+In[e.charCodeAt(u++)]*91+In[e.charCodeAt(u++)]),f[C++]=B}}}_(n,0),_(d,r);const v=new Int32Array(i*2);let y=0,w=0;function x(I,F){for(let B=0;B<I;B++){const C=F+B,A=h(),M=h();v[w*2]=A,v[w*2+1]=M,w+=1,m[C]=y;const H=(f[A]<0?b[A]:1)+(f[M]<0?b[M]:1);b[C]=H,y+=H}}x(i-r+n,r+d),x(r-n,n);const S=new Uint16Array(y);let E=0;for(let I=0;I<w;I++)for(let F=0;F<2;F++){const B=v[I*2+F],C=f[B];if(C<0){let A=m[B];const M=A+b[B];for(;A<M;)S[E++]=S[A++]}else S[E++]=C}const R=new Uint16Array(t);let N=0;for(;u<l;){let I=In[e.charCodeAt(u++)];I>=r&&(I=I*91-c+In[e.charCodeAt(u++)]);const F=f[I];if(F<0){let B=m[I];const C=B+b[I];for(;B<C;)R[N++]=S[B++]}else R[N++]=F}return R}const oj=rj("!}.&u%}'&}*'~!6*)%&,~!J~!J~%L~y<~!R,~~%Lu~~#GD~~#|)1#%}^%}2%+#.##%##%}&%##%'#%##&%#%#'%#&#%#&#'#%%#&#%##%#)%''%&%#%#'%#%%#%%}%%%#%#&(23#%%#&-%0%('1#(##%#'##+%'*.:1}#%#6-+(%'%%#%%%}#L'2351&('%}&/N'(0(/*-%(%%}#'+&T%7.2}#&%&#%#36/5##%&%%#&#%%#))2%%##%&&'0~!#*+&'%1~!%).'3q?&%'1~!.##%6(~!+%%%(Gw'rT~!E#<nA%#jZ~!H%(~!42##~!*31&~!G%U~#)5~#`3~!J~!Z~%]~%Y~%C~!q~!u~#kz~%#~!6'~!D~!U~!?~#T~!c%~!G#'~%7|~!G~!J~!G&~#pb~(Df}#%}*&}#%##%##%##&#-}&'#'&%#.++}%mI,#,@&(}*%}*'%&##&#%##%}&0}#.},U},%}+%}&%}#%##&}B%(}(%}+%)})%##%#&}&%##%&}<%}>%#%&}*%}(%}9%}/%})%}*%}*%}?&}&%}3%}&*#%})%#%#)}#&#-#+*%E%%'%'#%}#*V##&##I}#&&##%&%#&&Qf%%))w/0+&%#(#.%-''''++++7}>%4'',##1,#%#&%##&#'##&#*#9)%&%}#*}%,#+P(%A&%#'&##wSD',9E00#y#@}(+}&%&>~!#~!X}#*}(&&}(&}(,%}%&#+&}#&}I%#%}%)#(},'%#*}4%%#%}(''}#/##(##),%-##%%)#&}(.}&%#&}%%}*&#%},&&}&%}#%*'#%})%}D&}&%}-&}6&#&}-,%}#%})-(~+`~,=?~I9'9%~!,#%})%})%}@%}?%}(~!?~#<~#pP~#BG~#=1#%K+~#?#~%;)~#A~#mF1~#A'~'X%'~#lR~#N~'N~#r~#m#-~#i'?%#'%~#B%##%,%#~#_%#0%~#]732~,w~2+#:&#%&'0%&>%}#>##F+)#%&&#(+_}4&}-%}(&}@&}O7Fdf0@+/v4}&WU##&/0#&'('B#%}.%}'+#%}#%%&#&%#%##+#&#)#6#'#.},%}c%},%#%##%&#&%#&~#>'*-.%##%##%}#%%}%'~#)D1}#%*&~#_%%'(~#S2%'.}#~#=##*'*-%}&'%'##&&~'E%.#&~#M4}%%##&'%#~#O1##%&#'+~#<B%##%%'%+~#;#@%}#&%#&&%#(~#H1}'%'##&&~#?A}&'~#D#%32}'&&&&~#[}'(#%}'~#;C})&}%%#%~#=&%,3}%'(#%%~#^'#&&)#%'~#Y%-~#d-%'~#^%%&#&&&}#~#b~2t*&'~&(~&@~0%~e~3}%*''0})&}+~!9##-}#%-hD*)1fC#%/&/fB#40~!+#)*4~!+~!K'&:~!/*7~!.#~!H~!L':~%x&~!H#~!*~%1~!I#~!+A~#p'~!F~~#-#~,,(~.Z~!V~%;'B'mq-W~!N~%I%#&&#&}#%},%%}'%}+X#%}#&}(%}'%}<%}#%}%%'}'%}:~![)9@~%>~#UA%-%##&~!C%~!-.9:~!1~!-^2/:a~!y,D*J#-5)/4~%23,~#G~!L1~!0X3`~!2+~!!0-~&E~!W~!o,>Y&]~%cZx_&~#O*9#A#'#+I'%#)~!0B*-5A+-((F&*M#)(-7-5+'-3a5Vi~!Y~!?+[)%3),ERHm~!+:D,VG.+)?fB%%*(%)'(#&80%1'8`K8?`+'Z#&O&'H5#*9)A%%5&3))0%39+.*7#()&&*=4@**L)<'_&*+..;(#*+)./&0#3)%')-8(4ixD(&.}%,('aI:,)%,k2231T)I'#/-W7,/'Q#.'Y24+h')37</31&83##&0#),H(?'&?/1##%#&&#%''-%&&&#(&''&#.-'%#%%(,')*'&#&#'##%(%(#%('#&##%%%%('%#%#%%#%#&%##h>w+v<ayvyvcg.uuhKr}g/v|g>u9i[~>g5uI~=RvdwEg;v/g;uk!!TTSx]@RT!U!#!@VBRUU!'UTe-d0c`e&gSdicedFcrdTaqb.kYcAohdYd@a3e+d}dMdtd.aJ#bqcK`dle/e.e'dwdPdodddjbEb}ogd^ofdpduc6j?l%d{drdqc)d7bacOdQ%T#Y)X.sR[yH>6Vyv3[xwLu>vo'!*.[yBacahoj>6Rew3[xqdZa#!a&#^(X-[yG>6Vyu3[xvg3sEr|g.u/Ri9db0T#^(Xa)!-[y;>6Vylg4wKs{JwNZt3@3r=c4Z([xlg;wKt!cpq's@v7A'*a(a+!-a#[y<3Dt?3Dt'>6Vym3[xmg9rxsNJwLZt4~?r?db1T#`-!(Xa,!0[yS>6Vz%NuQs.g4wKtnJwNZtS@3r>c4Z([y%g;wKtrdga8!a(!#&T*Y-Xa#!a0<or[yc3Dtq>6Vz43[y3JwNZtf@3s!Ju}!%Dti:pm3c_%X#tjB5pkd6q!r]u?voC'*-a.a2!0a&a+[yI3DtI3Ds~3DtH>6Vyw3[xx;:s#~<5pKJwNZtE@3r~d`a)!a2T#a.(!+U.X1[yT3Dt`3Dtv>6Vz&3[y&g9rxwzcxstPu.<rAJwLZtT~?r@dZa%!a.&^*Za(/Reu[ya>6Vz23[y1g3sEr}wkg{NuQRg{ci(U#5@b`~,cg#U(2WnH5wugcRh7dX#T(Y,a'Ta!!a,[yZ<]mj>6Vz,3[y+Pv#5ReZKu+=,%!H}7ABwkaS?Rh:BcW(X#<]mrj:ubv/ARekdg%!(!a.*Ta(Y.X1!#sP>Rl*Dt6[y>>6Vyo3Wf*jOvuumvuRgRJuq*!:9<B@bX~3jVv&v@s@5Re[d/rQt{uAvo&a&a*)a2!,0Wf!3Dt0=Bs'>6Re}3[xy~<5s%JwJZt1~Gs)c;&!#2sJkNuXvzq7rxu,Re8dka4!a8(aEZ+a@Y.X1Xa)[yd=Bs(3DtP>6Vz53[y4cX#X&Re:avRe9~<5s&JwJZtQ~Gs*i^rzvdRg+Jv{%!2sbB@bX}kdga,!Za?&^*T1/!a'Dt+[y6>6Vyf3Wf%g/u;s4hGu6?Rh-JvZ,!c%#&RoX54Rivj7uyvf8RgTKvZB%*!2sGh<vu5Rgq<=C::9bb~#dZ#T&Ta6Y.X*Dt>[y93Wf)coZ(T,6VyifluvRgC@95@B@bX~/hFu34cC#T,k/unq8w8Q5RkUklwQuzunq8w8Q5Rk8d/rJu?v8w9)-&!a0a;a&aIWejg3sEr/h1s<DtDJvyZqY5aws3Jvy!&Wei~Hr1:au5@Bag>23E~5c:Z&bX};kKv?w&unuVu5Rjc;>bs)#~@:Rh.=ay<a]C;b`}Vd6s/t{uAvoaxa()!a,a7%-a#a2Dt,[yF2Wo[>6Vyt3[xuNuPRi&NuPwpi#RoWh?vf8Ri%Jv]!%Ri:KvxD!.'2WeAjZu`q9rxu,Re7woeAg-unLq(qA_/*2Wg_g3u5q^9:4E}/jTrxrzv=Wkkd~0UX#^^Xa-a1a5T&a=U1a'*aEa]!a*aPaA-adok[y54Rn>;:p3~Dp5g9rpsFNvZqjg3uJp4~<5p0Pw;5qlJwNZt*@3p1Pw:5p/Ou!5p2JvG'!6Vye=<qnJvh_[xhg3v,Rh3kOwOw-sDuev/Re^dha[a%!%!a+#Ta7)-5TaCaO!aka!a)sf[yb2>Rl!9ARiq5E}Qg=ucRkBE|oJrJ_@Wk~@Wk{JrJ_@Wk|@WkyJrJ_@Wk}@WkzJvO_[y2g-vMRmiKuYC!)&>Ri;>Ri<@3RkNc](X#@9Rk=g5vuRmhKvDB!+'=]meg3u4Rmgd)#Y'Vz3CARmfd`a+!%T'!+#Ta1Ta6TaM-sTDt9[yA9sYd'%Y#s[[xpj:ueunaXRgEjRq,v-vuqdd2'`#6Rev<32@5>:2<E}5xIo9a*X#Y(;5RePJvD_g>vyRgNj8w)v8<wggs:RgXiZt|vjx,hSq3ah!-(~@:Ro/Ou!5RhWj^v(pyw8unRhUdx-UY#^Ua.a3a70!)%UX1TaDa)'omRiRRhE[y:3Dsz=Br,>6Vyj3[xkg6ruwjcqsrPw;5r*Ku]D'Zt-@3r(~?r.i[vwv]dU1a--U#`a4(g/vsRhPOu!5RhLj:rmu9Wo!~@:wdh@g/vsRiTjXuvvNr}:RhBj^v(pyw8unRn]dz1UYa'a+^Y(!aETZalaRY.Ta?a4[yDJw1!#qLsW>6Vyrfzq-pLflpwRe|Js>%!Dt@3Dt&Jvy_[xs~HrnjMuwpsw'RecKu+D#'!t<~Grl~?rjg5u-x,gwp{ah!-(~@:Rg~Ou!5Rh'jXuvvNr}:Rh#cW#X/c;&!#2sLi[v7u7RgpJv)(!iLrxu,Re6j7v@s@5Se[e7d`aW!Za(a`T.a#!a3!&aDa-!9)Dt_=6s+3[x~~DR|h~DS6avhGun5RkZj3w)v-]mkKunB!&*]kb97R|i<ARk<c:Z(6Vy}Juh'!wziMRoS:F|vkLuauJv5vtvQRh1d='T+Y#VyO~DR|jcF#T'7R|g97R|kJv3'!ay<Rj,Jvh&!:ReXcsa6*a+#a#_aIRf9aLRf?c,Z&Rf5Rf7c.Z&Rf;Rf>cQ#%T'p-Rf8Rf=ct#%'(*!,p,Rf4p+Rf6Rf:Rf<d~'Ua%U*^UYa(!a,-!#a4YaTalaEX0a8a<Weo3Dt/3Dsx=Br93Wen~Dr;~<5p<JwNZt2@3p=Pw:5p;Ou!5r3c7&!#:p>3Ds}KvGB)_6Vyk2sM=<r7x'eovA(!hFu1ARf}cV#X&@r5j6rvwQa^Rf3c=Za'wkghJv__g;unRggA53B9=b^}%j6uduo5Jq;!(hIv%2Re`Ou4ARe_e%a#^^^Xa&!a*a2!&a6YaP!*ad!#a:aE/5Rn?[y@>6Vyp;:pE~DrY~<5pBJwNZt8@3pCh=rt3rWPw:5pAJup_[xoNuPpF9c!#'45pD5ARn)d8#X'X*3@rU72s]h>v<<sSjJpqvewOJq/(!hNw'5ReBk0s2u3w/w'5ReE5@Jq.!a+JQ!&WeU23d(#Y&RjG5]jBk!u7w&u0udARjEe#+^^^Ub#!a2/a`Z(agT1!a-a;|@TaG!aS[yV=Re~fow'RguNuPRe?bz#'>RoUWeL>:Cbb|?JwPZtVg6ruRmzJvD'!6Vz(g/vmRh~Jvy_[y(g9voRgyx*cy(#2>Ri2B9b]~9kIw9u7rluJu3Rg]dI#a%UY'@=p%CAx.gQZ&RhwwygtRm{x5g_Z'+ABqR9Woa=Bp&dV#^*Xa'!&@o{g4v]Rk;Jv{!%Rk[wkkiA5RkiwwfUB=x,fUuqC&*!>RfTg8v0RfV~ARfSd;rJsAuAv9wR'ae+/aO!a@aza/a#[yQ@Wg!2Wemg3sEr0JvB_g>uvReWg2v+Re=KupB_+[y!2AbY~-~Hr2AJwD!(h<~El>h<~El?Kun@+_:9b`}Kg-v/Ri3g;vtwyk_9]k_d=&T#*U.6qh@Ab`|K9:H|CJv[!&3Dtex'fDwC%!Rf[9WlMd[(^X,!a%Z06Vz!@WgBg=v~Rgvg,QRe@awd,#Y+jTv|Q~EfWj]uNr|~FRfXdy#Y&^Ua%!aO.!(a)Ua;=!a@aKap!a-,a!Ta]a[rSa]p?[y82sK=Bq~;:p:~<5p8Pw:5p7d'#Y'Wf(;RnRi[u4w&RgJJvG'!6Vyh=<r#ijuuv/sIKuYD'ZtG@3p9~Gr&d2#`(g<vtRgFj`u5w&rqpxRf2CJuY!+:wfnTOu!5Rg}jNs1ucv&RfwJvA!&3@q|BDcC#T,k/unq8w8Q5RkTklwQuzunq8w8Q5Rk9dga#!a'!a=#a0!:+Tb*b@aO.a4!aba8aFJv^}?!VyR~Dr<g;u%Rn.~<5p[x'e`wNZtR@3p]Pw:5pZhNvjBp.woe_g5u-r4JwF!%DtO3:ooc7&!#:p^3DtpLuGw(!+%)Dtk6Vz#2sd=<r8d'#Y([y#<x3gJt`w@!)%}MRiowzikRij=]ilxAf3,U(#B2Rf#g0v-Rm[ck{`U#]giKv3>)!&6Ri154s,KuGB_%@r68r:dJ|t`#X(9<E|u2@H|rx3gJu?w'!+'1Nu7Reg4=H~+9<wxgY95Rm]xLggZ-`(X}U2:Ri4h<uOawRmsJv__5@bb{jbV~3dka#a'a]!,#a+U=a>b6a3b%!/aKa/)!arwve^VyJ;:pR~DpTg3uJpS~<5pOPw;5qmPw:5pNOu!5pQJvG'!6Vyx=<qoJvA!{~Jup!%@qk7Rn/KvyD!}''[xz;>wkh'?Rh,x8gyt`w5D!&),(SgyccRgztJ@3pPB5p#d'(Y#<]mmifubw&RgoJvE&!82s^JvF&!8Rf,ADb]~;x=h'rNu]vK!,%'*0RnORh)4Rh*AqQg-vaRnNg;wHwkh'ba~4cE#Ta*x3gctyw@'!+%RnFRnD<4Rn@hFvK5RnCxWg[#`&a0Ua()`1Rm75Rg[c]%X#qi8Rg^NvdRj>BwzgZauwji7Rm6A4wgg]d1#&(*,.0a#Rm;Rm<Rm=Rm>Rm?Rm@RmARmBe%#^^^Xaea?aC/b+(,!a+a#!a/!>a&Ta<aKbD!2wphBRnk[yPw}hE|.=Br-3Dtm>6Vy~g6urRf.x,hPrNav!%'RnqRo%Ro#Nu;q[Pw;5r+JwNZtM@3r)d'#Y'Weh;xChL#`&RnmRnoKu}>%(!Rne~Bs-;2wjcussJv+'!aYSO}6@B<5?ba~8LrNvj!.%*ROwungw~ng~:9;Ri^>wtnig;wHRnixDh@|(UZ.x1h@|)!#:2<H|*xHn]#-UX'3Ro)z=iT}6ARns=Bwsn_wpnaRncw]aR(#UXa&Ua*a/=]iPd'#Y&Ro'WnXf{QRm2hNvj]nZd`'T~&1`{|`#9b]{}c:'!#Wl{>@=be}]?cl{{U#:5Abb}Jds#^YaF!a*b4a#a3aPa>&Tb!bH!*a_!Eau?/a&RjY<]gj>6Vz*;:pe~DrZg,QRj1JwNZtX@wihspcJvZ&!VyX9WmOJu|!|N2WmHJvh&!]ht~Bpbcn&T(!#RmQ<s7Nu;padH#X'`+WmJ@>RmKCARhnKup=!)&Wf+:RhqNuPpf9c!#'45pd5AwghpARn(Ls@w!%,)!RmP@Wfe<E|IJva!&WmNg8vsRmLd`*.`#Y'Xa!axRn*]hrA8Rhug5s@rXg8u!RmMd8#X'X*3@rV72smdI*#UY&RmICARho~GsgxVgd)Ta'U-Y&Xa!T#RnEWnA@Wffg1uDRi0hFvK5RnBxGnG&#`%owp)@wsf+bX}Ze-*1!a*^^^Ua|!#a.aq&Ya2!a>.a6!a:aO`aJDtL[y`@Wg#>6Vz12@wzoYRoZNuPRi!NuPRhzg=ucRi,@=b`{Yg=ucRi-ACJvB!&Sh[ebSh]ebi`wUuFRm4Jw2_[y0JvB!.<Ju(!&SoG}6Shd}6<Ju(!&SoH}6She}6Kur@._g5vHRieJvx!{L2G{Kx6gd'T#?Rh82Wi5cZ#X(g1w)Rm5dW-Y(Ta#!a)!#aYa=wnfE=su2>>bU{0j9udv:<svj8uQv-7RgHdE%#^'sq9sp=>Bb_{TJv`!&g/r|snj6v(us5d,#Y(56H}[978H}]Jw5!&g1rushJvB!+j;v{u5?zDhd}6}bj;v{u5?zDhe}6}ce*#`(^^^a[aea!=!a6a*aoXb1a.!aAbL!b>,b'aL!aV@Wf|2Wlg3[y/JwNZt^@3piPw:5pgJunZou3@rsJva&!Vy_g<v~Rm#JvG'!6Vz0=<r{Ju{%!:pj@WfsiXuJu3Rm:JvZ&!WfA~Bph@c4Z&Dtwax5rubx(#:awRk1@d,#Y&RfjRfid1#,Y(@Wfp2Wlrg5s@ryKu[@!,'=]ig9wlk?Rk>g5u-rqJvy'!@9RkQcH(T#=>Ri~@<wkj(Wj(KuZB*!&<7rw@9RkRcH(T#=>Ri}@<wkj)Wj)dg(Ta2Xa9X#`-!a*CARhg@@=I}d9x;c~#X%so=<sj>2@@=aybb}XjWv0Q~EfEj3vLv;<d,#Y(56H}`978H}_dgaPaFa'a/!#a3Y0a_a;a|!1(a7-[yE3[xt;:pJNvZrrg3uJrvJwNZt=@3pIh=rt3rxPw:5pGOu!5rpJvG'!6Vys=<rz@c4Z&Dt(ax5rtJvZ!&~BpH@wsfNg-vaRlNci*U#=<wei<F}a5@Jq.!a*JQ!%@qZ23d(#Y&RjH5]jCk!u7w&u0udARjFd/prq=tyvpaEa(a:.!a1aZ(@@=I}:9wpd%=<sX55w_h}@@=I{t=ay<aU@@=I}T=ay<2@@=I})?C9:9au@9Cb]}DP~=x-fAZ(2Wl1=ay<aU@@=I}>5@d##Y+jTv|vV~EfFj]uNpn~FRfGdgaK!Z2&!a8a-Tb({E!acTbM*!a(DtY[yYd'%Y#sl[y*hHvh>Re5x2c{Z}.j4uCvcawRiMd+#X+_x&d!},<5RkX;2Hzw@x,gavfB-!{CcF&T#Roe;RodwWbBg5urRgaKvHC*_6Vz+<4opieuew&Rmq@d]&Y)X,T#X0Rh}<BqP=4qS9:ReMg/ujReNJw0!/<Jui%!bd{kawwnemRelAxUa?a3#*.&UX(Ya+a/RhvRnQ<o}9Wmtd-#Y&RgSRmw9;Rmxay=Rmyg-vaRmuxEhSrNu,v-voC!%(aR.a(a7+1Ro1>Ro5CE{A9b]{@;5x#eO{:g;urRi+KrNA!%(Ro3>Ro79;Ri_Ku@>{;&!x%gX|{KunA_+g5QRj/g3u5Rj#g>uERj%wio/xRhS&!,!#^1U}wba{8>>@=be}qC@:D5ba{7Ku+A&!}x?ba}t>>@=be}se(aA^^^Uat!b0#{pa+awUazbGa#aLb9bgaWac'a5TbS=Br!d1#`%scp_Jvl!#rT>Re0JvX&!VyN=H{Fcm#U&:pY=ReaJv2&!]h0=]nUJvG'!6Vy|=<r%JrM_=]h2@Wlud'#)U'Wf'b]{i=]h/Jvh!&~BpWg=v]RnMx+ny#'Nu;pVwjnu=]nwxJnx,T#`&Reqwjnt=]nvieu9vrRjLLuYwP(#+!th@wih5pX~Gr'g5v/Rh4KunA'!-CARnP@wwiN:Rm_9x'cvw>!|l=<saKvAA!0&3@q}>w^e1bp#&Re2Re3BDx7gH#T|f5H|eKuZ>!%(:qNAH{]Jv6!+3B2B9=b^{X<5<B92:E{ZLvhwA(a;a%!igQuyRmad+#Y}m@3Rh5d8#X'X*:AqUAHzmaxwbh<aXRnVcF}RT#Nw&cj#U(BWnug/vsRntdka)(a3+.Zb7aYYan1!bVa@Xa}[y^@b[{G=H{+hFu73Rj&Pv#5ReQcK%T#sig1v{Rj'Ku+D#'!t]~Grm~?rkKuMB!01d5#`'Vy.ta3Dtu~Hroc8#'{^45s85AwZbP&!#Rn!wghxWn#KvEA!)&2RlA2RlBx:h|#(T,=]j09Wobz>x]z/@awRoTd+#Y(az]hFhCrm4d,#Y+jTv|Q~EfMj]uNr|~FRfOdCa!Xa9_X#@<plJvf!%b`{(9;Rgwc;.!#2x7cw#T|UDb]|T5Ju={(!=@E{&Jv)&!Ab`{'awJvf!~*>>@=be{#KuY>!+&4Ezyi[ugv&RjIdea+T)#UXa&T-T&a!Rh9auRmW=]kLg5vuRn+g3u4Rn-Ow6ARn,hHus5xNk?#UX(U~)/g8v0RkD~AwkkF?Ri.OuNBwkkA?Ri/d|a2`a*^UYa.!aBTZaTa'Xa;!(!2!-a#b2[yC>6Vyq3[xr2Wi?g1rusVh%s?DtF~<5rbJs;%!DtBfswKtCj[uvuSsEu3RgVx3o:u+wN'*Zt;@3rd~Grh~?rfg8w)Lq)qE&-a%!>bI|`jWv0vV~EfCjTv|vV~Ef@j]uNpn~FRfBcK#T']gWNu7x,k7q4ai(0!hHv8<RhmkMu9vrsBuev/RhlCJvB!,g<v{wchh~@:Rhji[vrv{wchi~@:RhkdS&a5UY#Ta!RgPwwiI5BwciI~@:Rh`x'iJvj'!5]iJPu8Bwch]~@:Rhach)U#h3rp]gLh@t|Ax,hTq3ah!-(~@:Ro0Ou!5RhXj^v(pyw8unRhVd|)`,^UYas!a?/a2Z'a^Ta{Tb7Ta(a#!a,Wf&9sZ3DtAadamov=Bqt3[xig8vsRm~>waiL2b`{QJv*_Ouv2qgj<v]v2BqfdR'X*X#Y-@3qr~Gqv~?p6hHv-]glPup5Lq+q?_%*b_{qF{n9b^{rOu4ARhpKvCD!+&~Bqp:5Dbb}nwoiKl&unuTuBv]v+ueunaXRf0=Jvh!0nKufu8v1w&w7q%w&uHrz:Rgnj5w,uxDJq/(!hNw'5ReCk0s2u3w/w'5ReFd>Za&!*UaA=<wkgsRnSJv^!%Refifw3vyRgOKu_B'!,<]gkiiu:w&Rh<=C@a^<B57@2F{[<B5@aW:=3away9A5aW=<B=C@a^<B57@2F{Ie-#`(^^^bCara.b8aza6!/bZ,!adTbnTbOb+aFaS!aAT9@Wf~2Wli3Dtl2@d,#Y&RfnRfmJwJZtN~GqyJva&!VyMg<v~Rm%iXuJu3Rm9Jv[_=]ih9wlkDRkCd1#`(@Wg>2Wls3cH#T(@<Rj*=>Ri|b~'#23s9h<~El.d'#Y&Dtxi^rzvdRl#d*#U%(o|B2s`hJwSaxRmDKv4B&!1:Rmdd5#`'Vx}to~Hq{x'f1v3(!BA5ba|bJv_&!Wfug1v]ReIdO+U/Y#&G}-8wze=Rh{g1v]ReHg/uQRf/by#)ibQwERl/cH#T(@<Rj+=>Ri{cNu+vlax-!(#a0qa9<Rii2;;bU{H;x<i=&X#Rk`<4wwi=C9H~8xAI(Y#<azRi@45wXI<B9;5bb~7dL(X#Xa(+!aL6Vy{g5QqOau:5au2@ay547EzbxOcU(UX-T#Ta#:Cbb|A?wjh/b_|SOw6ARgtihr}u7Rhy<d1#T)X1@@=I|~=ay<2@@=aybb}Sj3vLv;<d,#Y(56H}A978H}@dGpvs@uAu`vcw9*!aFa+ai%(b!aXa8.a?a[ozWey=sU2@G}Nch&U#Rf_WexKu+D#'!t:~Gr`~?r^j]uNr|~FRg*j^psurwJt|RmcKv)@&!)7Rkv~Br[@wxfO:Rl3co#U'6Rezj_q#vIuavjRltwzeyh@vr5JqD0!>aY?C9:9au@9Cb]}9cl#U*5;5<H||jbuus1ucv&Rfvg1v~d/pppzqFr^a--a~!aMat1(hFv;Wiz@@=Izoj5uuv-7Rix~Cw`fk2WlVcZ#X,k)u3vWs@u2]ktg;wEx'fBq(_2Wg/jTv|vV~EfoJv]!15x'hzqG!(P~EfU~CRl_j6v(us5x4i-#T(2WmZ?C2F|d>Kq<aj1!*jTqIsBv=Wl`~Cw`fi2WlWj`v0u*~>RlR=c>Z,k#u3vWs@u2]kr<c1Z+jTqIsBv=Wla~Cw`fm2WlXdmb3!a{(arZa`bkTa%TbQTa-a9+c'!aM!/[yL=Bqug.w'RifhFvyDRj.g>vgwyk^9]k^Jv3_@WfbAARkhJw2_[x|JvB_wkoIRoKwkoJRoLd'(Y#<]gm=<9<H|yd'%_X#skDtb3awwqkgNulRkgdB#^',9:p'hJwSaxRmEBwVb8@4=H|qLu+w50&!)@3qs~?pU>Awwn;;Rn=c:Z'ARn<=<qwKvC@!/&~BqqJv6!&]eVb^z^xRge'/a%+^`#Sge}6<4Rn3=]n0Pw2>Rn8Jw0!&>Rn:>Rn6cY#a7+!a&=<wkaNw~h3z_c5Z{=wjh#=]nLKv^D!&)Vyz=bW|swYb<WetcG#T(2wxa@qVx@gD#Y&b^|V5JwG&!5bb|pg/w&RgD@x=kHs=uAvn!a%%/'+RmSRh694Ro`g-vaRmRhHv-]mlxCcS#`&ba~.5cD#Ta)P~=d,#Y(56H{>978H{Dd_#{2^Y%_+qbbb{6g3sERhsbU{?dfa.,`a(Xa<!aiX#(55RiG54RiHcI#T'WiU3RiVNvdwtfcRlKNvdd,#Y&RlHRlExQgf.1*^T'X#Sgf}6Wn4=]hfPrk>Rn7Jw0!&>Rn5>Rn9Lunw?&a2!,5<oq@@wqfdRlJj5Q~=d,#Y(~ARfcOuN]fdDKw;ay(}i!547E}j?cI#T(@5bV}iCbV}hdv(^^Tb?a40,b##Tbo!a*bR!a<b|a/!aKai!aU[yK=]o^g:v>ReGJwPZtK<7Rh+h<~El,Pv#5ReR@awwxjCg,ulRjDJv6&!]j!z?aQeeg>w=Sh<eeJw;!&axEzOg,Qosc!#*:wkeJ]eJ>x'h-u(!%Ro.w~h.zPdNZ(X,Ya![x{;9ReY;wkgxRiF:x?ap#Y&RmUg<s2Rkod]+UY0TZ'!a&A9sw<=bczLNvuw{gqzNhJwSaxRmCKuLay!#&s_Rf-55b^{uJvZa!!c%#(55Ri654wmiu5RiuawLu,vp!+}^%b_}Y9;wkgxba}o>A9:=b^}zKuh=a''!3awRk3c*'!#aHRk6c+Z&Rk5Rk4Jv)&!awRjSawd9*`#0?C2@EzMj8u<uJ5RmbjQrquJu3x,k>uq@_+=ayb^|W~ARkEOuN]k@7dhzV^X/X&a-#zRzSb`zXcJzTT#2WkVKvDBzW!%FzY9;5bbzWjQrquJu3Jw3%!b`zU=ayb^zQd:#X(T-a!6Vyywxh}=b]{Jg=u1RiAdGp~qHtzv!w(wA+a+a;<!aJaYai'anasb(=azRmV:Cbb{MLq2vb!%')RjuRjrRjtRjqx3jnqCw3!%')Rk(Rk+Rk&Rk)Lq2vb!%')Rj{RjxRjzRjwLq2vb!%')RjsRjpRjfRjex3jcqCw3!%')Rk'Rk*RjkRjl9<CbbzfOu4ARhxLq2vb!%')RjyRjvRjhRjgx=joq*uKvb!%')+-Rk.Rk%Rj~Rk-Rk#Rj}x=jdq*uKvb!%')+-Rk,Rk!Rj|RjmRjjRjidAq&qKs@uAv8Aa.'*-a@a&0!aM@a5[y73Dsy3Ds|3Dt):wxgI2sHJwJZt.~Gqxwsf0ikrzt}Rl0Jvy_[xj~HqzKv_A|D!&WfP8axRoVcf,U#k(v]v+ueunaXRf1Ju}'!g8u#Ri=jQw!sCunLprq>!,')~<5qeGzq9F{W=c##%s5au:5aU3CBE|;d4#X(D!a&6Vygx(b;#(=]ed?C2F{N<capoq2r[a&!aPa9,'Pw;5s:@@=I|,55w_h|@@=IzcP~=x'fCqB_2Wl2>aU@@=I|1OuNBc1Z+jTqIsBv=Wlc~Cw`fl2WlZ~AcTa%!Z+jTqIsBv=Wlb~Cw`fh2WlYk+uNqJsBv=WlSg,u3dca3#UXaMYa)TaB-=cM|7T#<bI}l5@B932:aV2G{BOuNBJq:|M!5Ezt=<B=C@a^<B57@2F{v>cB{/T#=ay<bI{3Jv6!a.6BKq0ah&+!5E}HP~Ef{978BaU@@=Iza<7d#.Y#978BaU@@=IzH~AJq0!(@@=IzG978BaU@@=IzFe,aU*Y&^^^bvJb,b:bFad!a,c2Ta>aL.bo6!a#CbTa'T#Re{2Wlh2@G{yg6t~Ro_NvdRfticuRQRllJv3&!x&c|zs@Jw3!%RflwpfkRlpKuL;%(!Re<@G|C2GzdhIvuBwgjAg-u0RjAKQB%!(GzZ@G|5NuuRl7d='T+Y#Vy[g<v~Rm!==G|>JvA!)@wma=]m1ifuaw&RmnLs@vT'!|/+[y,g:v>ReTJw1!#qX=x!eC{bLu+wT&)ZtZauq_~Graci&U#F|89:r_Lupvq!.)&2RlG8RfaC=x!eF{_h?rpWlmd&'!#X|&]k::xJey#`'T|+<E|&2@H|%dE#(^,g;u.RiEg6vjRiC9xCkA{O|zY#g=ucRmXKs0@!&*@G|m@awRknJuh!,3d(}gY}eJvj!%Rm):Jw3!%Rm+Rm-Ls0w(&!a(a#@b[|6cZ#X'7RkxWgAOu4ARn'dH'U#Y*Vz-Wm'CARm}d]*#a%^a*T'aK!a<9bV{PC=p*Jw4!&SgxcbB5r]idw(wBRmF7xFkt#&`(Rm/Rm8E|!JuY_9:Rl5=wrgr2:bbxd@xXfB(a*#T+!.X0X1Ta/a'T&RlDRfL>RlyARl9b[z[>RfZ:RlL:RfRwlg/ARl;9;RlxKv,A/!%7s69<74=BA5ba{-8Bde#`a<XaKYa1,a'P~=wxfB2bZ}}?C972@@=I}r8@55B9;5bb}G978B2@@=aybb}3j3vLv;<Jw3&!>Rfk=ayb^}4~Ad1#`*@@=aybb{w2@>==<bbz]dx+UY#^UaF!a9!bB'Ya1.!ajXa#%olRhD[y=3Dt#Ov5BrHKuMB%!(Rf^Wep~HrJwkiQjKr|~FRg)Ku+D#'!t5~GrF~?rDdV)UY,Z/_7RkuG{<~BrBg,rlsO:235B@bX}|d?a1!#`(6Vyn5@d##Y+jTv|vV~EfIj]uNpn~FRfH7Lq2vb1!a9-978BaU@@=Iz9978BbU}#~AJq0!(@@=Iz8978BaU@@=Iz7~AJQ|}!978BbU}!JvkaK!AdUa21-U#`a+(g/vsRn~Ou!5RPj:rmu9WhOjXuvvNr}:RhAj^v(pyw8unRn[kPr}p|u7vwv]RiSBd;pppzq@qHQa?(b.!a.a`@.|xa(hFv;Wiyj5uuv-7Riw~Cw`fg2WlU978BbU|wOuNBJqG!(P~EfD~CRlQcZ#X,k)u3vWs@u2]ksg;wEx'f@q1_2Wg.j]uNpn~FRfqJv]!15x'h{qG!(@@=IzK~CRl^j6v(us5x4i,#T(2WmY?C2F{1>Kq<aj1!*jTqIsBv=Wld~Cw`fj2Wl[j`v0u*~>RlT=c>Z,k#u3vWs@u2]kq<c1Z+jTqIsBv=Wle~Cw`fn2Wl]dn1#c(a(b^a2!b/bAT(bj!aDa7bu,a_a{c0!2T0g:v>ReD2@G{42@G{5~DpM~<5rc=Bx6i>{RT#RnI@zCx]y]z:2Jv[!zr5Awyk]9]k]dD(Y+X#6Vz.g=wKtgwhaCwgmTWj2Lu,w%_+/[y-B;b^xeg3u3Rj-2@bX{*KrJ<!+'@Wg(g?QRlC@Jv`!%b[zIwsfII}8JQ_@w|kW|=Jv(%!AqcOuNBJvEzh!bYzjLs@wP#(0!oy@>RkdJwMZtc3Dtd@BcG#T'9bWxg2@2Fznd*#Y+;2x'c}w<zizixNgwa#Z'U+!/!a'!a+w~g~z6wcn{Rn}wcnzRn|5Rh%=]nJg5vuRmvNvdRlvcprJu}w*az*a#!%.a.'Bot9qT]kj@Wg'ay2Gzv@Jv`!%b[zEwsfHI}1;ck#Ux`<Cbbx_Lu+w!a&0*!wko*wwo,So,}6Juqxf!E}PigQuyRm`d3(`#8>Rn%:A5B;bZ~%KvhCa!a2!x>k7#Uxb@b{#xaRk7Jw0!)>wwhlShl}6>wwhmShm}6CJvB!.x'hhvj{!!5Bwkhhbaz}x'hivjz~!5Bwkhibaz|xEhTrNu,v-vpD!a%&/)a3a.,%Ro2t[CE{)@3re9b]{%wjo09:rgc:Z&Ro6=<riifuaw&RmoKrNA!%(Ro4>Ro89;Ri`dSaL'UYzxZb)7Rka3xRhT&!,!#^1U}vbaz{>>@=be}yC@:D5bazzKu+A&!}{?ba}y>>@=be}wxBh[t`u~vJvr!%a!a()a,a0a4RoC=]o;Ju(!%RoGRhdwjh`=]oAg>w#Ro?g5vuRo=NvdRl|Ku]C.!&;RoEJvB!%RoORoMBx'h[v+_?w~h`}~5?w~hd~!xKh]oiptu-utv.vp!#%&a30a@a'a+(a/aOp(o~p!RoDJu(!%RoHRhewjha=]oBNvdRl}g>w#Ro@g5vuRo>c[#X']o<CauRoRAd-#Y':RkpauRoQKu]C.!&;RoFJvB!%RoNRoPBx'h]v+_?w~ha}t5?w~he}ue!/UbhYacXaW^Tc&a;b:a-c/#b&aja1(!cL+!bKbt!bmcRc9aIc?8[yW3Dtt94Rg`Jv}!&SiRMzBhEebShEMNuPRe>x7gL#TzuwjirRipc<Z&>on;>z=h-MSh.Mwqczx'a7vj&!>Re4@=ResJt__NuPRi*NuPRi)j]uNr|~FRfzKrJ>_+@Wfy@Wf]2WocKrJ<!+'@Wg%g/QRl@@Jv`!&awRl<wsfFIzgLu(w*!.*&ShBMwvhIRhI9;RhNx1hK'!#Sn]Mx1hK~0!#:2<H~7cNu+w7D*'1ZtW>Rn1~?rOc:Z&Rn2=<rQ<7wjh&=BSnLMc]#X(6Vz)w[b=a!U#9wzgMc3#&(RgMRitRis<x,gKt`ax!&+SioM=BSilMc3#&(RgKRinRimKurB,!&SiQMzBhDebShDM6BJQ!(P~Efx978B2@@=I}WLrJw!!,a*&@G}O@9wkibRid@@x'fKwC!&SlDMSfLMjUv~Q~EfKKv3@a+!(hFv-]mpx/hYZ(C5RiWz<o/MwkhY?So/M@x,gbvfB*&!SgEM:SoeeehFu3:Rgbda(,^TZa)X/7Sg[eb:2RgI~BrMC@wgkc:wwkcRerx3h(uUvK!&*,SnOM4Sh*MArRg;wHRh(x=h;rJvPwI!a4',a'0@Wg&=BSh/Mg>w=Rh=g3w*wwgGRgGcW(X#;Sg}M2Gzk@Jv`!&awRl=wsfGIz`dKZ*T'Y-:RhR7RhQg5u-p`j6v(us5d,#Y+~Awkia?RicOuNBwkibba}Ld6p~tyu_vbAa'a+!a/'a3aEa8a!>Sh,ebJv{!&Sh@ebSaReb9;SgwebNuPRi(NvdRl)NuPRi'hHu^<Rm^Jvv_@Wl(g;u1Si/ebKu'B&!*Sh?eb@Wl'z@aPeb95Si.ebcpputyvjB)!,&a+0a%ShAMWeK@G}C@WfJ9;RhMwvhH9w{ia}ix,hJvRA1(!zAn[MRhHx1hJ~*!#hFv(BSn[MBJQ!(@@=I~'978B2@@=I}2db.Ua<'X}+T#a0XaG2G}E;wkg|wuh!Rh!x,hZu,@)!&So0MVy)C5RiXACJvB!&5RiY5RiZg8w)cG}*T#2@bU}=KsA>(!a.3wkhZba~(x,h^u(A!&(SoCMRhb5Bz=h[eb?w~hb~6x,h_u(A!&(SoDMRhc5Bz=h]eb?w~hc~6e)aA1T#T,^^^c-bMb&blcPaP(a/!0!bA=b5c@a(!bfbrc#2afwmhARnjwchORnp2Wlf3DtsNvdRl-2@wpa<]m0bx(#:awRk2@Jw3!%RfhwpfgRlnKQB%!(G{V@G|'NuuRl6d='T+Y#VyUg<v~Rl~==G|<Jv+'!aYShC}6@B<5?ba~8@Jw3'!g2QRljhLrpWlOd+#Y'g.w'rIg>w*wgj@g-u0Rj@Lu+wT&)ZtUauq]~GrGci&U#F|39:rELrNvj!.%*RhCwunfw~nf~:9;Ri]>wtnhg;wHRnhx3hDs@v~!/+'@Wfr@9RkSNu&Rlo=@<5GzoKs0@_+@Wl+@awRkmJuh!-3d(}pY#qWJvj!%Rm(:Jw3!%Rm,Rm*de&!1U-U#`)Re;@G|.@9Ri82@wjfvRlq=@<5GzpLvOvr!).&2RlF8Rf`C=x!eE{.Jw3_g2QRlkhLrpWlPde(!#U{s,UXa*Ta'[y'g:v>ReS;x0PZ&RnlRnn~HrKJw1}f!=x!eB|2w]aP(#Xa&a*Ta.Ua2a7=]iOd'#Y&Ro&WnWg;u.RiDg6vjRiBNvdRlzhNvj]nYJuW_2Wm3x)kFze{9d])!a.!,Y01!#&aC!a3RndC=ox~BrC@2b^{pg,rlse7x'ksuq!%Rm.E{xidw(wBRmGx9o+)X#wwo-So-}69:Rl4@xSf@a#XZ'X)X,Ta(/ARl8b[xc>RfY:RlI:RfQwlg.ARl:9;Rlwdn'#^XafaQa1X1TaHTa)@b[{zcZ#X'7RkwWg@Ou4ARn&x)kG#{,g7u/RkGdH'U#Y*Vz'Wm&CARm|bx#(A]gUbUzJj9Q~=d,#Y(56H}l978H{U7d,0#U*2>ABb_xZ978BbU{e~AJQ{g!978BbU{hxMh?ad{oUYZ.x1h?{l!#:2<H{mx3n[t{vl!,&a%3Ro(z=iS}6ARnr=Bwsn^wvn`Rnbd`*T}B0!#^X'BG{c9b]{a>>@=be}F?JvS!&BG{d7BG}(Bde#`a1X,Ya@!a'P~=wxf@2bZ}I56B2@@=aybb}08@55B9;5bb}<j3vLv;<Jw3&!>Rfg=ayb^}&OuNBKuLA!)a!P~=x#fD{f2@>==<bbzl?C972@@=Ix^d6rSu,v7w*C(0a)a6#B+a%!sQ[y?3Dt%3[xn~<5rLOu!5p@Ku+D#'!t7~GrP~?rNKvlaya7'!h+v-5qMg=t|cd,U#5AAaa5Abb{S@52B5@a[@52B5Gx[iXueu;d<#`a(!/549C;ag>23ExY5@Dah89b^~689Jv)!~2b[~1Lv'w(%*!a#bX|aPrmawRe]keu7uhv-q6rxu,q`xTo]/a5aU!bNaDXbi!b-!ao!b<bwA!#5@B932:aV2G|:d-)Y#hJrL>RhG<7@C5<H|_=Cau:5aj5@B932:bJ|ng>vIbs)#?C2F|9jPv0w.vISh-MKvUaz(.!9ABbb|[5;5<H|Eg>unwfh;9:4E|YjQsBt|vjx'hYq3!(?C2F|J:2<BaY?C2F|GOu!5x,g|p{ah!-(?C2F|c9:4E|OjXuvvNr}:Rh&i[w*t|cd+U#jJvsu)vsSn~Mkfrmu9p}u7vwv]So!McW#Xa!ax5@A5aY:5;5<H|>kJv~vYrquJu3x4ib#T)2@SmZM?C2F|Bj:rmu9@xPhI(a*a#U#`a3-5Abb|L~@:RhK9:4E|0@52B5G|#C::aY?C2F|-:2<BaY?C2F|.5Jvk!a)javYrquJu3x4ia#T)2@SmYM?C2F|HAxPhH(!a#U#`a*-5Abb|4~@:RhJ9:4E|R@52B5G|F:2<BaY?C2F|Sc^#Xa2j=Qq5CJvB!-g<v{z;hhM?C2F|Zi[vrv{z;hiM?C2F|XKsA>!a)-g<v{z;h[eb?C2F|]i[vrv{z;h]eb?C2F|^iZu.vix,hZq3ah!.(?C2F|QOu!5ShXM:2<BaY?C2F|P",13494,2713,49,25,61);var ns;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.FLAG13=8192]="FLAG13",e[e.BRANCH_LENGTH=8064]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE",e[e.VALUE_MASK=8191]="VALUE_MASK"})(ns||(ns={}));var Ks;(function(e){e[e.AMP=38]="AMP",e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_X=120]="LOWER_X"})(Ks||(Ks={}));const Th=32,GS=21,aj=2097151,am=2047;let JS=0;function lj(e){const t=e>>>GS;return t===am?JS:t}function cj(e){return e-Ks.ZERO>>>0<=9}function uj(e){return(e|Th)-Ks.LOWER_A>>>0<=5}function hj(e){return(e|Th)-Ks.LOWER_A>>>0<=25}var w0;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(w0||(w0={}));var x0;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(x0||(x0={}));function dj(e,t,s,n){const i=(t&ns.BRANCH_LENGTH)>>7,r=t&ns.JUMP_TABLE;if(r){if(i===0)return n===r?s:-1;const c=n-r;if(c>>>0>=i)return-1;const u=e[s+c];return u===0?-1:s+i+u-1&65535}if(i===0)return-1;const a=i+1>>1,l=s+a+i;for(let c=0;c<i;c++){const h=e[s+(c>>1)]>>((c&1)<<3)&255;if(h===n){const d=s+a+c;return l+e[d]&65535}if(h>n)return-1}return-1}function S0(e,t,s){return s===1?String.fromCharCode(e[t]&ns.VALUE_MASK):s===2?String.fromCharCode(e[t+1]):String.fromCharCode(e[t+1],e[t+2])}function fj(e,t,s){let n=t+1,i=0,r=n;if(n<s&&(e.charCodeAt(n)|Th)===Ks.LOWER_X)for(n+=1,r=n;n<s;){const l=e.charCodeAt(n);if(cj(l))i=i*16+(l-Ks.ZERO);else if(uj(l))i=i*16+((l|Th)-Ks.LOWER_A+10);else break;n+=1}else for(;n<s;){const l=e.charCodeAt(n)-Ks.ZERO;if(l>>>0>9)break;i=i*10+l,n+=1}if(n===r)return 0;n<s&&e.charCodeAt(n)===Ks.SEMI&&(n+=1),i>1114111&&(i=1114112);let a=n-t;return a>=am&&(JS=a,a=am),a<<GS|i}function pj(e,t,s){const n=oj;let i=e.indexOf("&");if(i<0)return e;const r=e.length;let a=0,l="";const c=n[0],u=c&ns.JUMP_TABLE,h=(c&ns.BRANCH_LENGTH)>>7;do{const d=i+1,p=e.charCodeAt(d);let f,m;if(p===Ks.NUM){const b=fj(e,d,r);f=lj(b),f>0&&e.charCodeAt(d+f-1)!==Ks.SEMI&&(f=0),m=f===0?"":ij(b&aj)}else if(hj(p)){f=0,m="";const b=p-u;let _;if(b>>>0<h){const S=n[1+b];_=S===0?-1:h+S&65535}else _=-1;let v=0,y=0,w=_<0?0:n[_],x=d+1;e:for(;x<r;){for(;!(w&(ns.VALUE_LENGTH|ns.FLAG13))&&w&ns.JUMP_TABLE;){const N=w&ns.JUMP_TABLE,I=(w&ns.BRANCH_LENGTH)>>7;if(I===0){if(e.charCodeAt(x)!==N)break e;_+=1}else{const F=e.charCodeAt(x)-N;if(F>>>0>=I)break e;const B=n[_+1+F];if(B===0)break e;_=_+I+B&65535}if(w=n[_],x+=1,x>=r)break e}if((w&(ns.VALUE_LENGTH|ns.FLAG13))===ns.FLAG13){const N=(w&ns.BRANCH_LENGTH)>>7;if(e.charCodeAt(x)!==(w&ns.JUMP_TABLE))break;x+=1;const I=N-1;let F=_+1,B=0;for(;B+1<I;B+=2){const C=n[F];if(e.charCodeAt(x)!==(C&255)||(x+=1,e.charCodeAt(x)!==(C>>8&255)))break e;x+=1,F+=1}if(B<I){if(e.charCodeAt(x)!==(n[F]&255))break;x+=1}_+=1+(N>>1),w=n[_];continue}const S=w>>>14,E=e.charCodeAt(x);if(S!==0){if(E===Ks.SEMI){f=x-d+1,m=S===1?String.fromCharCode(w&ns.VALUE_MASK):S0(n,_,S);break}if(S===1)break}const R=dj(n,w,_+(S||1),E);if(R<0)break;_=R,w=n[_],x+=1}m===""&&f>0&&(m=S0(n,v,y))}else f=0,m="";f===0||s?i=d:(a<i&&(l+=e.slice(a,i)),l+=m,i=a=d+f),e.charCodeAt(i)!==Ks.AMP&&(i=e.indexOf("&",i))}while(i>=0);return l+e.slice(a)}function XS(e){return pj(e,!0,!1)}var mj=class{src_Any=KS.source;src_Cc=qS.source;src_Z=YS.source;src_P=l_.source;src_ZPCc=[this.src_Z,this.src_P,this.src_Cc].join("|");src_ZCc=[this.src_Z,this.src_Cc].join("|");cache={};opts={maxLength:1e4,urlAuth:!1,schema_names:[]};constructor(e={}){this.opts={...this.opts,...e}}set(e={}){return this.opts={...this.opts,...e},this.cache={},this}escapeRE(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}nestedPairRE(e,t,s=4){const n=this.escapeRE(e),i=this.escapeRE(t),r=`(?:(?!${this.src_ZCc}|${n}|${i}).)`;let a=`${n}${r}{0,1000}${i}`;for(let l=2;l<=s;l++)a=`${n}(?:${r}|${a}){0,1000}${i}`;return a}get_text_separators(){return this.cache.text_separators??=/[><\uff5c]/}get_pseudo_letter(){return this.cache.src_pseudo_letter??=new RegExp(`(?:(?!${this.get_text_separators().source}|${this.src_ZPCc})${this.src_Any})`)}get_ipv4_addr(){return this.cache.src_ip4??=new RegExp("(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])[.]){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])")}get_ipv6_addr(){const e="[0-9A-Fa-f]{1,4}",t=`(?:(?:${e}:${e})|${this.get_ipv4_addr().source})`;return this.cache.src_ip6_addr??=new RegExp(`(?:(?:${e}:){6}${t}|::(?:${e}:){5}${t}|(?:${e})?::(?:${e}:){4}${t}|(?:(?:${e}:){0,1}${e})?::(?:${e}:){3}${t}|(?:(?:${e}:){0,2}${e})?::(?:${e}:){2}${t}|(?:(?:${e}:){0,3}${e})?::${e}:${t}|(?:(?:${e}:){0,4}${e})?::${t}|(?:(?:${e}:){0,5}${e})?::${e}|(?:(?:${e}:){0,6}${e})?::)`)}get_ipv6_url_host(){return this.cache.src_ip6_host??=new RegExp(`\\[${this.get_ipv6_addr().source}\\]`)}get_ipv6_mail_host(){return this.cache.src_ipv6_mail_host??=new RegExp(`\\[IPv6:${this.get_ipv6_addr().source}\\]`)}get_auth(){return this.cache.src_auth??=new RegExp(`(?:(?:(?!${this.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`)}get_port(){return this.cache.src_port??=new RegExp("(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?")}get_host_terminator(){return this.cache.src_host_terminator??=new RegExp(`(?=$|${this.get_text_separators().source}|${this.src_ZPCc})(?!${this.opts["---"]?"-(?!--)|":"-|"}_|:\\d|\\.-|\\.(?!$|${this.src_ZPCc}))`)}get_path_terminator(){return this.cache.src_path_terminator??=new RegExp(`${this.src_ZPCc}|${this.get_text_separators().source}`)}get_path(){return this.cache.src_path??=new RegExp(`(?:[/?#](?:${this.nestedPairRE("[","]")}|${this.nestedPairRE("(",")")}|${this.nestedPairRE("{","}")}|\\"(?:(?!${this.src_ZCc}|["]).){1,100}\\"|\\'(?:(?!${this.src_ZCc}|[']).){1,100}\\'|\\'(?=${this.get_pseudo_letter().source}|[-])|\\.{2,20}[:]?[a-zA-Z0-9%/&]|\\.(?!${this.src_ZCc}|[.]|$)|`+(this.opts["---"]?"\\-(?!--(?:[^-]|$))(?:-{0,19})|":"\\-{1,20}|")+`,(?!${this.src_ZCc}|$)|;(?!${this.src_ZCc}|$)|\\!{1,20}(?!${this.src_ZCc}|[!]|$)|\\?(?!${this.src_ZCc}|[?]|$)|`+this.get_path_extra().source+`[\\\\/:%@#&=_~*]|(?!${this.get_path_terminator().source}).){1,${this.opts.maxLength}}|\\/)?`)}get_mail_name(){return this.cache.src_mail_name??=new RegExp("[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9](?:[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9]|[.](?=[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9])){0,63}")}get_xn(){return this.cache.src_xn??=new RegExp("xn--[a-z0-9\\-]{1,59}")}get_tld(){if(this.cache.tld)return this.cache.tld;const e=[...new Set(this.opts.tlds||[])].sort().reverse().join("|");return this.cache.tld=new RegExp(`${e||"$#none#$"}|${this.get_xn().source}`),this.cache.tld}get_domain_root(){return this.cache.src_domain_root??=new RegExp("(?:"+this.get_xn().source+`|${this.get_pseudo_letter().source}{1,63})`)}get_domain(){return this.cache.src_domain??=new RegExp("(?:"+this.get_xn().source+`|(?:${this.get_pseudo_letter().source})|(?:${this.get_pseudo_letter().source}(?:-|${this.get_pseudo_letter().source}){0,61}${this.get_pseudo_letter().source}))`)}get_url_host_port(){return this.cache.url_host_port??=new RegExp("(?:"+this.get_ipv6_url_host().source+`|(?:(?:(?:${this.get_domain().source})\\.){0,10}${this.get_domain().source}))`+this.get_port().source+this.get_host_terminator().source)}get_fuzzy_url_host_port(){return this.cache.fuzzy_url_host_port??=new RegExp("(?:"+(this.opts.fuzzyIP?this.get_ipv4_addr().source+"|":"")+`(?:(?:(?:${this.get_domain().source})\\.){1,10}(?:${this.get_tld().source})))`+this.get_host_terminator().source)}get_mail_host(){return this.cache.src_mail_host??=new RegExp("(?:"+this.get_ipv6_mail_host().source+`|(?:(?:(?:${this.get_domain().source})\\.){0,4}${this.get_domain().source}))`+this.get_host_terminator().source)}get_fuzzy_mail_host(){return this.cache.src_fuzzy_mail_host??=new RegExp("(?:"+this.get_ipv6_mail_host().source+`|(?:(?:(?:${this.get_domain().source})[.]){1,4}${this.get_domain_root().source}))`+this.get_host_terminator().source)}get_path_extra(){return this.cache.src_path_extra??=new RegExp("")}get_fuzzy_mail_host_search(){return this.cache.mail_fuzzy_host_search??=new RegExp(`@${this.get_fuzzy_mail_host().source}`,"ig")}get_fuzzy_link_search(){return this.cache.link_fuzzy_search??=new RegExp(`(^|(?![.:/\\-_@])(?:[$+<=>^\`||]|${this.src_ZPCc}))(?:(?![$+<=>^\`||])${this.get_fuzzy_url_host_port().source}${this.get_path().source})`,"ig")}get_http_validator(){return this.cache.http_validator??=new RegExp("\\/\\/"+(this.opts.urlAuth?this.get_auth().source:"")+this.get_url_host_port().source+this.get_path().source,"iy")}get_relative_proto_validator(){return this.cache.relative_proto_validator??=new RegExp((this.opts.urlAuth?this.get_auth().source:"")+`(?:localhost|${this.get_ipv6_url_host().source}|(?:(?:${this.get_domain().source})[.]){1,10}${this.get_domain_root().source})`+this.get_port().source+this.get_host_terminator().source+this.get_path().source,"iy")}get_mail_name_validator(){return this.cache.mail_name_validator??=new RegExp(`(?:^|${this.get_text_separators().source}|"|\\(|${this.src_ZCc})(${this.get_mail_name().source})$`)}get_mailto_validator(){return this.cache.mailto_validator??=new RegExp(`${this.get_mail_name().source}@${this.get_mail_host().source}`,"iy")}get_schema_names(){return this.cache.schema_names??=new RegExp((this.opts.schema_names||[]).map(e=>this.escapeRE(e)).join("|"))}get_schema_search(){return this.cache.schema_search??=new RegExp(`(^|(?!_)(?:[><|]|${this.src_ZPCc}))(${this.get_schema_names().source})`,"ig")}get_schema_at_start(){return this.cache.schema_at_start??=new RegExp(`^${this.get_schema_search().source}`,"i")}},ff={validate:(e,t,s)=>{const n=s.re.get_http_validator();n.lastIndex=t;const i=n.exec(e);return i?i[0].length:0},normalize:(e,t)=>t.normalize(e)},gj={"http:":ff,"https:":ff,"ftp:":ff,"//":{validate:function(e,t,s){const n=s.re.get_relative_proto_validator();n.lastIndex=t;const i=n.exec(e);return i?t>=3&&e[t-3]===":"||t>=3&&e[t-3]==="/"?0:i[0].length:0},normalize:(e,t)=>t.normalize(e)},"mailto:":{validate:function(e,t,s){const n=s.re.get_mailto_validator();n.lastIndex=t;const i=n.exec(e);return i?i[0].length:0},normalize:(e,t)=>t.normalize(e)}},_j="a:cdefgilmnoqrstuwxz|b:abdefghijmnorstvwyz|c:acdfghiklmnoruvwxyz|d:ejkmoz|e:cegrstu|f:ijkmor|g:abdefghilmnpqrstuwy|h:kmnrtu|i:delmnoqrst|j:emop|k:eghimnprwyz|l:abcikrstuvy|m:acdeghklmnopqrstuvwxyz|n:acefgilopruz|o:m|p:aefghklmnrstwy|q:a|r:eosuw|s:abcdeghijklmnortuvxyz|t:cdfghjklmnortvwz|u:agksyz|v:aceginu|w:fs|y:et|z:amw",vj="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф";function yj(){const e=vj.split("|");return _j.split("|").forEach(t=>{const s=t.indexOf(":"),n=t.slice(0,s);for(const i of t.slice(s+1))e.push(n+i)}),e}var bj={fuzzyLink:!1,fuzzyEmail:!0,fuzzyIP:!1,"---":!1,tlds:yj(),urlAuth:!1,maxLength:1e4},k0=class{schema;index;lastIndex;raw;text;url;constructor(e,t,s,n){const i=e.slice(s,n);this.schema=t.toLowerCase(),this.index=s,this.lastIndex=n,this.raw=i,this.text=i,this.url=i}},wj=class{__opts__;__schemas__;re;constructor(e={}){const{rebuilder:t,...s}=e;this.__opts__={...bj,...s},this.__schemas__={...gj},this.re=t||new mj,this.re.set({...this.__opts__,schema_names:Object.keys(this.__schemas__)})}add(e,t=null){if(!t)delete this.__schemas__[e];else{const s={normalize:(n,i)=>i.normalize(n),...t};this.__schemas__[e]=s}return this.re.set({...this.__opts__,schema_names:Object.keys(this.__schemas__)}),this}set(e={}){return this.__opts__={...this.__opts__,...e},this.re.set({...this.__opts__,schema_names:Object.keys(this.__schemas__)}),this}test(e){if(!e.length)return!1;let t,s;for(s=this.re.get_schema_search(),s.lastIndex=0;(t=s.exec(e))!==null;)if(this.testSchemaAt(e,t[2],s.lastIndex))return!0;if(this.__opts__.fuzzyLink&&this.__schemas__["http:"]&&(s=this.re.get_fuzzy_link_search(),s.lastIndex=0,s.exec(e)!==null))return!0;if(this.__opts__.fuzzyEmail&&this.__schemas__["mailto:"]&&e.indexOf("@")>=0){const n=this.re.get_fuzzy_mail_host_search(),i=this.re.get_mail_name_validator();for(n.lastIndex=0;(t=n.exec(e))!==null;){const r=e.slice(Math.max(0,t.index-65),t.index);if(i.test(r))return!0}}return!1}testSchemaAt(e,t,s){return this.__schemas__[t.toLowerCase()]?this.__schemas__[t.toLowerCase()].validate(e.slice(0,s+this.__opts__.maxLength),s,this):0}match(e){const t=[],s=this.re.get_schema_search();let n,i,r,a,l,c,u=!1,h=!1,d=!1,p=0;if(!e.length)return null;for(s.lastIndex=0,this.__opts__.fuzzyLink&&this.__schemas__["http:"]&&(n=this.re.get_fuzzy_link_search(),n.lastIndex=0),this.__opts__.fuzzyEmail&&this.__schemas__["mailto:"]&&(i=this.re.get_fuzzy_mail_host_search(),i.lastIndex=0,r=this.re.get_mail_name_validator());;){const f=Math.max(p-1,0);if(i&&r&&!d&&(!l||l.index<p))for(i.lastIndex<f&&(i.lastIndex=f);;){const y=i.exec(e);if(!y){d=!0,l=void 0;break}const w=r.exec(e.slice(Math.max(0,y.index-65),y.index));if(w){if(l={schema:"mailto:",index:y.index-w[1].length,lastIndex:y.index+y[0].length},l.index>=p)break;i.lastIndex<f&&(i.lastIndex=f)}}if(n&&!h&&(!a||a.index<p))for(n.lastIndex<f&&(n.lastIndex=f);;){const y=n.exec(e);if(!y){h=!0,a=void 0;break}if(a={schema:"",index:y.index+y[1].length,lastIndex:y.index+y[0].length},a.index>=p)break;n.lastIndex<f&&(n.lastIndex=f)}let m=l;(!m||a&&(a.index<m.index||a.index===m.index&&a.lastIndex>m.lastIndex))&&(m=a);let b;if(!u)for(;;){if(!c){s.lastIndex<f&&(s.lastIndex=f);const x=s.exec(e);if(!x){u=!0;break}c={schema:x[2],index:x.index+x[1].length,lastIndex:x.index+x[0].length}}if(c.index<p){c=void 0;continue}if(m&&c.index>m.index)break;const y=c;c=void 0;const w=this.testSchemaAt(e,y.schema,y.lastIndex);if(w){b={schema:y.schema,index:y.index,lastIndex:y.lastIndex+w};break}}let _=b;if((!_||l&&(l.index<_.index||l.index===_.index&&l.lastIndex>_.lastIndex))&&(_=l),(!_||a&&(a.index<_.index||a.index===_.index&&a.lastIndex>_.lastIndex))&&(_=a),!_)break;_===l?l=void 0:_===a&&(a=void 0);const v=new k0(e,_.schema,_.index,_.lastIndex);v.schema?this.__schemas__[v.schema].normalize(v,this):this.normalize(v),t.push(v),p=_.lastIndex}return t.length?t:null}matchAtStart(e){if(!e.length)return null;const t=this.re.get_schema_at_start().exec(e);if(!t)return null;const s=this.testSchemaAt(e,t[2],t[0].length);if(!s)return null;const n=new k0(e,t[2],t.index+t[1].length,t.index+t[0].length+s);return this.__schemas__[n.schema].normalize(n,this),n}tlds(e,t=!1){return e=Array.isArray(e)?e:[e],t?this.__opts__.tlds=this.__opts__.tlds.concat(e):this.__opts__.tlds=e,this.re.set({...this.__opts__,schema_names:Object.keys(this.__schemas__)}),this}normalize(e){e.schema||(e.url=`http://${e.url}`),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url=`mailto:${e.url}`)}};const ua=2147483647,ti=36,c_=1,hc=26,xj=38,Sj=700,ZS=72,QS=128,e1="-",kj=/^xn--/,Cj=/[^\0-\x7F]/,Ej=/[\x2E\u3002\uFF0E\uFF61]/g,Nj={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},pf=ti-c_,si=Math.floor,mf=String.fromCharCode;function tr(e){throw new RangeError(Nj[e])}function Rj(e,t){const s=[];let n=e.length;for(;n--;)s[n]=t(e[n]);return s}function t1(e,t){const s=e.split("@");let n="";s.length>1&&(n=s[0]+"@",e=s[1]),e=e.replace(Ej,".");const i=e.split("."),r=Rj(i,t).join(".");return n+r}function s1(e){const t=[];let s=0;const n=e.length;for(;s<n;){const i=e.charCodeAt(s++);if(i>=55296&&i<=56319&&s<n){const r=e.charCodeAt(s++);(r&64512)==56320?t.push(((i&1023)<<10)+(r&1023)+65536):(t.push(i),s--)}else t.push(i)}return t}const jj=e=>String.fromCodePoint(...e),Tj=function(e){return e>=48&&e<58?26+(e-48):e>=65&&e<91?e-65:e>=97&&e<123?e-97:ti},C0=function(e,t){return e+22+75*(e<26)-((t!=0)<<5)},n1=function(e,t,s){let n=0;for(e=s?si(e/Sj):e>>1,e+=si(e/t);e>pf*hc>>1;n+=ti)e=si(e/pf);return si(n+(pf+1)*e/(e+xj))},i1=function(e){const t=[],s=e.length;let n=0,i=QS,r=ZS,a=e.lastIndexOf(e1);a<0&&(a=0);for(let l=0;l<a;++l)e.charCodeAt(l)>=128&&tr("not-basic"),t.push(e.charCodeAt(l));for(let l=a>0?a+1:0;l<s;){const c=n;for(let h=1,d=ti;;d+=ti){l>=s&&tr("invalid-input");const p=Tj(e.charCodeAt(l++));p>=ti&&tr("invalid-input"),p>si((ua-n)/h)&&tr("overflow"),n+=p*h;const f=d<=r?c_:d>=r+hc?hc:d-r;if(p<f)break;const m=ti-f;h>si(ua/m)&&tr("overflow"),h*=m}const u=t.length+1;r=n1(n-c,u,c==0),si(n/u)>ua-i&&tr("overflow"),i+=si(n/u),n%=u,t.splice(n++,0,i)}return String.fromCodePoint(...t)},r1=function(e){const t=[];e=s1(e);const s=e.length;let n=QS,i=0,r=ZS;for(const c of e)c<128&&t.push(mf(c));const a=t.length;let l=a;for(a&&t.push(e1);l<s;){let c=ua;for(const h of e)h>=n&&h<c&&(c=h);const u=l+1;c-n>si((ua-i)/u)&&tr("overflow"),i+=(c-n)*u,n=c;for(const h of e)if(h<n&&++i>ua&&tr("overflow"),h===n){let d=i;for(let p=ti;;p+=ti){const f=p<=r?c_:p>=r+hc?hc:p-r;if(d<f)break;const m=d-f,b=ti-f;t.push(mf(C0(f+m%b,0))),d=si(m/b)}t.push(mf(C0(d,0))),r=n1(i,u,l===a),i=0,++l}++i,++n}return t.join("")},Aj=function(e){return t1(e,function(t){return kj.test(t)?i1(t.slice(4).toLowerCase()):t})},Mj=function(e){return t1(e,function(t){return Cj.test(t)?"xn--"+r1(t):t})},E0={version:"2.3.1",ucs2:{decode:s1,encode:jj},decode:i1,encode:r1,toASCII:Mj,toUnicode:Aj};/*! markdown-it 15.0.2 https://github.com/markdown-it/markdown-it @license MIT */var N0=Object.defineProperty,o1=(e,t)=>{let s={};for(var n in e)N0(s,n,{get:e[n],enumerable:!0});return N0(s,Symbol.toStringTag,{value:"Module"}),s},Dj=o1({arrayReplaceAt:()=>Ij,asciiTrim:()=>md,callable:()=>a1,escapeHtml:()=>xr,escapeRE:()=>Wj,fromCodePoint:()=>dc,isMdAsciiPunct:()=>mc,isPunctChar:()=>c1,isPunctCharCode:()=>pc,isSpace:()=>mt,isValidEntityCode:()=>u_,isWhiteSpace:()=>fc,lib:()=>Kj,normalizeReference:()=>pd,unescapeAll:()=>xa,unescapeMd:()=>Bj});function a1(e){const t=function(...s){return Reflect.construct(e,s,new.target&&new.target!==t?new.target:e)};return Object.defineProperty(t,"name",{value:e.name}),Object.setPrototypeOf(t,e),t.prototype=e.prototype,t}function Ij(e,t,s){return[].concat(e.slice(0,t),s,e.slice(t+1))}function u_(e){return!(e>=55296&&e<=57343||e>=64976&&e<=65007||(e&65535)===65535||(e&65535)===65534||e>=0&&e<=8||e===11||e>=14&&e<=31||e>=127&&e<=159||e>1114111)}function dc(e){if(e>65535){e-=65536;const t=55296+(e>>10),s=56320+(e&1023);return String.fromCharCode(t,s)}return String.fromCharCode(e)}var l1=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,Pj=new RegExp(`${l1.source}|${/&([a-z#][a-z0-9]{1,31});/gi.source}`,"gi"),Lj=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function Oj(e,t){if(t.charCodeAt(0)===35&&Lj.test(t)){const n=t[1].toLowerCase()==="x"?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return u_(n)?dc(n):e}const s=XS(e);return s!==e?s:e}function Bj(e){return e.indexOf("\\")<0?e:e.replace(l1,"$1")}function xa(e){return e.indexOf("\\")<0&&e.indexOf("&")<0?e:e.replace(Pj,function(t,s,n){return s||Oj(t,n)})}var $j=/[&<>"]/,Fj=/[&<>"]/g,zj={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function Hj(e){return zj[e]}function xr(e){return $j.test(e)?e.replace(Fj,Hj):e}var Uj=/[.?*+^$[\]\\(){}|-]/g;function Wj(e){return e.replace(Uj,"\\$&")}function mt(e){switch(e){case 9:case 32:return!0}return!1}function fc(e){if(e>=8192&&e<=8202)return!0;switch(e){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1}function c1(e){return l_.test(e)||VS.test(e)}function pc(e){return c1(dc(e))}function mc(e){switch(e){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}}function pd(e){return e=e.trim().replace(/\s+/g," "),e.toLowerCase().toUpperCase()}function R0(e){return e===32||e===9||e===10||e===13}function md(e){let t=0;for(;t<e.length&&R0(e.charCodeAt(t));t++);let s=e.length-1;for(;s>=t&&R0(e.charCodeAt(s));s--);return e.slice(t,s+1)}var Kj={mdurl:ZR,ucmicro:ej};function qj(e,t,s){let n,i,r,a;const l=e.posMax,c=e.pos;for(e.pos=t+1,n=1;e.pos<l;){if(r=e.src.charCodeAt(e.pos),r===93&&(n--,n===0)){i=!0;break}if(a=e.pos,e.md.inline.skipToken(e),r===91){if(a===e.pos-1)n++;else if(s)return e.pos=c,-1}}let u=-1;return i&&(u=e.pos),e.pos=c,u}function Vj(e,t,s){let n,i=t;const r={ok:!1,pos:0,str:""};if(e.charCodeAt(i)===60){for(i++;i<s;){if(n=e.charCodeAt(i),n===10||n===60)return r;if(n===62)return r.pos=i+1,r.str=xa(e.slice(t+1,i)),r.ok=!0,r;if(n===92&&i+1<s){i+=2;continue}i++}return r}let a=0;for(;i<s&&(n=e.charCodeAt(i),!(n===32||n<32||n===127));){if(n===92&&i+1<s){if(e.charCodeAt(i+1)===32){i++;continue}i+=2;continue}if(n===40&&(a++,a>32))return r;if(n===41){if(a===0)break;a--}i++}return t===i||a!==0||(r.str=xa(e.slice(t,i)),r.pos=i,r.ok=!0),r}function Yj(e,t,s,n){let i,r=t;const a={ok:!1,can_continue:!1,pos:0,str:"",marker:0};if(n)a.str=n.str,a.marker=n.marker;else{if(r>=s)return a;let l=e.charCodeAt(r);if(l!==34&&l!==39&&l!==40)return a;t++,r++,l===40&&(l=41),a.marker=l}for(;r<s;){if(i=e.charCodeAt(r),i===a.marker)return a.pos=r+1,a.str+=xa(e.slice(t,r)),a.ok=!0,a;if(i===40&&a.marker===41)return a;i===92&&r+1<s&&r++,r++}return a.can_continue=!0,a.str+=xa(e.slice(t,r)),a}var Gj=o1({parseLinkDestination:()=>Vj,parseLinkLabel:()=>qj,parseLinkTitle:()=>Yj});function gc(e){"@babel/helpers - typeof";return gc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gc(e)}function Jj(e,t){if(gc(e)!="object"||!e)return e;var s=e[Symbol.toPrimitive];if(s!==void 0){var n=s.call(e,t);if(gc(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Xj(e){var t=Jj(e,"string");return gc(t)=="symbol"?t:t+""}function Ce(e,t,s){return(t=Xj(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}var Qr=class{constructor(e,t,s){Ce(this,"map",null),Ce(this,"level",0),Ce(this,"children",null),Ce(this,"content",""),Ce(this,"markup",""),Ce(this,"info",""),Ce(this,"block",!1),Ce(this,"hidden",!1),this.type=e,this.tag=t,this.attrs=null,this.nesting=s,this.meta=null}attrIndex(e){if(!this.attrs)return-1;const t=this.attrs;for(let s=0,n=t.length;s<n;s++)if(t[s][0]===e)return s;return-1}attrPush(e){this.attrs?this.attrs.push(e):this.attrs=[e]}attrSet(e,t){const s=this.attrIndex(e),n=[e,t];s<0?this.attrPush(n):this.attrs[s]=n}attrGet(e){const t=this.attrIndex(e);let s=null;return t>=0&&(s=this.attrs[t][1]),s}attrJoin(e,t){const s=this.attrIndex(e);s<0?this.attrPush([e,t]):this.attrs[s][1]=`${this.attrs[s][1]} ${t}`}},_c=class{constructor(){Ce(this,"__rules__",[]),Ce(this,"__cache__",null)}__find__(e){for(let t=0;t<this.__rules__.length;t++)if(this.__rules__[t].name===e)return t;return-1}__compile__(){const e=new Set;this.__rules__.forEach(t=>{t.enabled&&t.alt.forEach(s=>{s&&e.add(s)})}),this.__cache__=Object.create(null),this.__cache__[""]=[],this.__rules__.forEach(t=>{t.enabled&&this.__cache__[""].push(t.fn)}),e.forEach(t=>{this.__cache__[t]=[],this.__rules__.forEach(s=>{s.enabled&&s.alt.indexOf(t)>=0&&this.__cache__[t].push(s.fn)})})}at(e,t,s={}){const n=this.__find__(e);if(n===-1)throw new Error(`Parser rule not found: ${e}`);this.__rules__[n].fn=t,this.__rules__[n].alt=s.alt||[],this.__cache__=null}before(e,t,s,n={}){const i=this.__find__(e);if(i===-1)throw new Error(`Parser rule not found: ${e}`);this.__rules__.splice(i,0,{name:t,enabled:!0,fn:s,alt:n.alt||[]}),this.__cache__=null}after(e,t,s,n={}){const i=this.__find__(e);if(i===-1)throw new Error(`Parser rule not found: ${e}`);this.__rules__.splice(i+1,0,{name:t,enabled:!0,fn:s,alt:n.alt||[]}),this.__cache__=null}push(e,t,s={}){this.__rules__.push({name:e,enabled:!0,fn:t,alt:s.alt||[]}),this.__cache__=null}enable(e,t=!1){Array.isArray(e)||(e=[e]);const s=[];return e.forEach(n=>{const i=this.__find__(n);if(i<0){if(t)return;throw new Error(`Rules manager: invalid rule name ${n}`)}this.__rules__[i].enabled=!0,s.push(n)}),this.__cache__=null,s}enableOnly(e,t=!1){Array.isArray(e)||(e=[e]),this.__rules__.forEach(s=>{s.enabled=!1}),this.enable(e,t)}disable(e,t=!1){Array.isArray(e)||(e=[e]);const s=[];return e.forEach(n=>{const i=this.__find__(n);if(i<0){if(t)return;throw new Error(`Rules manager: invalid rule name ${n}`)}this.__rules__[i].enabled=!1,s.push(n)}),this.__cache__=null,s}getRules(e){return this.__cache__||this.__compile__(),this.__cache__[e]||[]}},di={};di.code_inline=function(e,t,s,n,i){const r=e[t];return`<code${i.renderAttrs(r)}>${xr(r.content)}</code>`};di.code_block=function(e,t,s,n,i){const r=e[t];return`<pre${i.renderAttrs(r)}><code>${xr(e[t].content)}</code></pre>
49
+ `};di.fence=function(e,t,s,n,i){const r=e[t],a=r.info?xa(r.info).trim():"";let l="",c="";if(a){const h=a.split(/(\s+)/g);l=h[0],c=h.slice(2).join("")}let u;if(s.highlight?u=s.highlight(r.content,l,c)||xr(r.content):u=xr(r.content),u.indexOf("<pre")===0)return u+`
50
+ `;if(a){const h=r.attrIndex("class"),d=r.attrs?r.attrs.slice():[];h<0?d.push(["class",`${s.langPrefix}${l}`]):(d[h]=[d[h][0],d[h][1]],d[h][1]+=` ${s.langPrefix}${l}`);const p={attrs:d};return`<pre><code${i.renderAttrs(p)}>${u}</code></pre>
51
+ `}return`<pre><code${i.renderAttrs(r)}>${u}</code></pre>
52
+ `};di.image=function(e,t,s,n,i){const r=e[t];return r.attrs[r.attrIndex("alt")][1]=i.renderInlineAsText(r.children,s,n),i.renderToken(e,t,s)};di.hardbreak=function(e,t,s){return s.xhtmlOut?`<br />
53
+ `:`<br>
54
+ `};di.softbreak=function(e,t,s){return s.breaks?s.xhtmlOut?`<br />
55
+ `:`<br>
56
+ `:`
57
+ `};di.text=function(e,t){return xr(e[t].content)};di.html_block=function(e,t){return e[t].content};di.html_inline=function(e,t){return e[t].content};var u1=class{constructor(){Ce(this,"rules",Object.assign({},di))}renderAttrs(e){let t,s,n;if(!e.attrs)return"";for(n="",t=0,s=e.attrs.length;t<s;t++)n+=` ${xr(e.attrs[t][0])}="${xr(String(e.attrs[t][1]))}"`;return n}renderToken(e,t,s){const n=e[t];let i="";if(n.hidden)return"";let r=t-1;for(;r>=0&&e[r].hidden&&e[r].nesting===0;)r--;n.block&&n.nesting!==-1&&r>=0&&e[r].hidden&&e[r].nesting===-1&&(i+=`
58
+ `),i+=(n.nesting===-1?"</":"<")+n.tag,i+=this.renderAttrs(n),n.nesting===0&&s.xhtmlOut&&(i+=" /");let a=!1;if(n.block&&(a=!0,n.nesting===1)){let l=t+1;for(;l<e.length&&e[l].hidden&&e[l].nesting===0;)l++;if(l<e.length){const c=e[l];(c.type==="inline"||c.hidden||c.nesting===-1&&c.tag===n.tag)&&(a=!1)}}return i+=a?`>
59
+ `:">",i}renderInline(e,t,s){let n="";const i=this.rules;for(let r=0,a=e.length;r<a;r++){const l=e[r].type;typeof i[l]<"u"?n+=i[l](e,r,t,s,this):n+=this.renderToken(e,r,t)}return n}renderInlineAsText(e,t,s){let n="";for(let i=0,r=e.length;i<r;i++)switch(e[i].type){case"text":case"code_inline":n+=e[i].content;break;case"image":n+=this.renderInlineAsText(e[i].children,t,s);break;case"html_inline":case"html_block":n+=e[i].content;break;case"softbreak":case"hardbreak":n+=`
60
+ `}return n}render(e,t,s){let n="";const i=this.rules;for(let r=0,a=e.length;r<a;r++){const l=e[r].type;l==="inline"?n+=this.renderInline(e[r].children,t,s):typeof i[l]<"u"?n+=i[l](e,r,t,s,this):n+=this.renderToken(e,r,t)}return n}},h1=class{constructor(e,t,s){Ce(this,"tokens",[]),Ce(this,"inlineMode",!1),Ce(this,"Token",Qr),this.src=e,this.env=s,this.md=t}},Zj=/\r\n?/g,Qj=/\0/g;function eT(e){let t;t=e.src.replace(Zj,`
61
+ `),t=t.replace(Qj,"�"),e.src=t}function tT(e){let t;e.inlineMode?(t=new e.Token("inline","",0),t.content=e.src,t.map=[0,1],t.children=[],e.tokens.push(t)):e.md.block.parse(e.src,e.md,e.env,e.tokens)}function sT(e){const t=e.tokens;let s=0;for(let n=0;n<t.length;n++)t[n].type!=="reference_definition"&&(n!==s&&(t[s]=t[n]),s++);t.length!==s&&(t.length=s)}function nT(e){const t=e.tokens;for(let s=0,n=t.length;s<n;s++){const i=t[s];i.type==="inline"&&e.md.inline.parse(i.content,e.md,e.env,i.children)}}function iT(e){return/^<a[>\s]/i.test(e)}function rT(e){return/^<\/a\s*>/i.test(e)}function oT(e){const t=e.tokens;if(e.md.options.linkify)for(let s=0,n=t.length;s<n;s++){if(t[s].type!=="inline"||!e.md.linkify.test(t[s].content))continue;const i=t[s].children,r=[];let a=0;for(let l=i.length-1;l>=0;l--){const c=i[l];if(c.type==="link_close"){for(l--;i[l].level!==c.level&&i[l].type!=="link_open";)l--;continue}if(c.type==="html_inline"&&(iT(c.content)&&a>0&&a--,rT(c.content)&&a++),!(a>0)&&c.type==="text"&&e.md.linkify.test(c.content)){const u=c.content;let h=e.md.linkify.match(u);const d=[];let p=c.level,f=0;h.length>0&&h[0].index===0&&l>0&&i[l-1].type==="text_special"&&(h=h.slice(1));for(let m=0;m<h.length;m++){const b=h[m].url,_=e.md.normalizeLink(b);if(!e.md.validateLink(_))continue;let v=h[m].text;h[m].schema?h[m].schema==="mailto:"&&!/^mailto:/i.test(v)?v=e.md.normalizeLinkText(`mailto:${v}`).replace(/^mailto:/,""):v=e.md.normalizeLinkText(v):v=e.md.normalizeLinkText(`http://${v}`).replace(/^http:\/\//,"");const y=h[m].index;if(y>f){const E=new e.Token("text","",0);E.content=u.slice(f,y),E.level=p,d.push(E)}const w=new e.Token("link_open","a",1);w.attrs=[["href",_]],w.level=p++,w.markup="linkify",w.info="auto",d.push(w);const x=new e.Token("text","",0);x.content=v,x.level=p,d.push(x);const S=new e.Token("link_close","a",-1);S.level=--p,S.markup="linkify",S.info="auto",d.push(S),f=h[m].lastIndex}if(f<u.length){const m=new e.Token("text","",0);m.content=u.slice(f),m.level=p,d.push(m)}r.push({index:l,nodes:d})}}if(r.length>0){let l=i.length;for(const d of r)l+=d.nodes.length-1;const c=new Array(l);let u=0,h=0;r.reverse();for(let d=0;d<i.length;d++){const p=r[u];if(p?.index===d){for(const f of p.nodes)c[h++]=f;u++}else c[h++]=i[d]}t[s].children=c}}}var d1=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,aT=/\((c|tm|r)\)/i,lT=/\((c|tm|r)\)/gi,cT={c:"©",r:"®",tm:"™"};function uT(e,t){return cT[t.toLowerCase()]}function hT(e){let t=0;for(let s=e.length-1;s>=0;s--){const n=e[s];n.type==="text"&&!t&&(n.content=n.content.replace(lT,uT)),n.type==="link_open"&&n.info==="auto"&&t--,n.type==="link_close"&&n.info==="auto"&&t++}}function dT(e){let t=0;for(let s=e.length-1;s>=0;s--){const n=e[s];n.type==="text"&&!t&&d1.test(n.content)&&(n.content=n.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/gm,"$1—").replace(/(^|\s)--(?=\s|$)/gm,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,"$1–")),n.type==="link_open"&&n.info==="auto"&&t--,n.type==="link_close"&&n.info==="auto"&&t++}}function fT(e){let t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type==="inline"&&(aT.test(e.tokens[t].content)&&hT(e.tokens[t].children),d1.test(e.tokens[t].content)&&dT(e.tokens[t].children))}var pT=/['"]/,j0=/['"]/g,T0="’",mT=1e3;function A0(e,t,s){for(;e.length>s;){const n=e.pop();n.isSingleQuote?t.single=n.prevSameQuoteIdx:t.double=n.prevSameQuoteIdx}}function du(e,t,s,n){e[t]||(e[t]=[]),e[t].push({pos:s,ch:n})}function gT(e,t){let s="",n=0;t.sort((i,r)=>i.pos-r.pos);for(let i=0;i<t.length;i++){const r=t[i];s+=e.slice(n,r.pos)+r.ch,n=r.pos+1}return s+e.slice(n)}function _T(e,t){let s;const n=[],i={single:-1,double:-1},r={};for(let a=0;a<e.length;a++){const l=e[a],c=e[a].level;for(s=n.length-1;s>=0&&!(n[s].level<=c);s--);if(A0(n,i,s+1),l.type!=="text")continue;const u=l.content;let h=0;const d=u.length;e:for(;h<d;){j0.lastIndex=h;const p=j0.exec(u);if(!p)break;let f=!0,m=!0;h=p.index+1;const b=p[0]==="'";let _=32;if(p.index-1>=0)_=u.charCodeAt(p.index-1);else for(s=a-1;s>=0&&!(e[s].type==="softbreak"||e[s].type==="hardbreak");s--)if(e[s].content){_=e[s].content.charCodeAt(e[s].content.length-1);break}let v=32;if(h<d)v=u.charCodeAt(h);else for(s=a+1;s<e.length&&!(e[s].type==="softbreak"||e[s].type==="hardbreak");s++)if(e[s].content){v=e[s].content.charCodeAt(0);break}const y=mc(_)||pc(_),w=mc(v)||pc(v),x=fc(_),S=fc(v);if(S?f=!1:w&&(x||y||(f=!1)),x?m=!1:y&&(S||w||(m=!1)),v===34&&p[0]==='"'&&_>=48&&_<=57&&(m=f=!1),f&&m&&(f=y,m=w),!f&&!m){b&&du(r,a,p.index,T0);continue}if(m&&(s=b?i.single:i.double,s>=0&&n[s].level===c)){const E=n[s];let R,N;b?(R=t.md.options.quotes[2],N=t.md.options.quotes[3]):(R=t.md.options.quotes[0],N=t.md.options.quotes[1]),du(r,a,p.index,N),du(r,E.tokenIdx,E.contentPos,R),A0(n,i,s);continue e}if(f){if(n.length>=mT)return;n.push({tokenIdx:a,contentPos:p.index,isSingleQuote:b,level:c,prevSameQuoteIdx:b?i.single:i.double}),b?i.single=n.length-1:i.double=n.length-1}else m&&b&&du(r,a,p.index,T0)}}Object.keys(r).forEach(function(a){const l=Number(a);e[l].content=gT(e[l].content,r[a])})}function vT(e){if(e.md.options.typographer)for(let t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!=="inline"||!pT.test(e.tokens[t].content)||_T(e.tokens[t].children,e)}function yT(e){let t,s;const n=e.length;for(t=0;t<n;t++)e[t].type==="text_special"&&(e[t].type="text");for(t=s=0;t<n;t++)e[t].type==="text"&&t+1<n&&e[t+1].type==="text"?e[t+1].content=e[t].content+e[t+1].content:(t!==s&&(e[s]=e[t]),s++);t!==s&&(e.length=s)}function bT(e){let t,s;const n=e.tokens,i=n.length;for(let r=0;r<i;r++){if(n[r].type!=="inline")continue;const a=n[r].children,l=a.length;for(t=0;t<l;t++)a[t].type==="text_special"&&(a[t].type="text"),a[t].children&&yT(a[t].children);for(t=s=0;t<l;t++)a[t].type==="text"&&t+1<l&&a[t+1].type==="text"?a[t+1].content=a[t].content+a[t+1].content:(t!==s&&(a[s]=a[t]),s++);t!==s&&(a.length=s)}}var gf=[["normalize",eT],["block",tT],["strip_references",sT],["inline",nT],["linkify",oT],["replacements",fT],["smartquotes",vT],["text_join",bT]],f1=class{constructor(){Ce(this,"ruler",new _c),Ce(this,"State",h1);for(let e=0;e<gf.length;e++)this.ruler.push(gf[e][0],gf[e][1])}process(e){const t=this.ruler.getRules("");for(let s=0,n=t.length;s<n;s++)t[s](e)}},p1=class{constructor(e,t,s,n){Ce(this,"bMarks",[]),Ce(this,"eMarks",[]),Ce(this,"tShift",[]),Ce(this,"sCount",[]),Ce(this,"bsCount",[]),Ce(this,"blkIndent",0),Ce(this,"line",0),Ce(this,"lineMax",0),Ce(this,"tight",!1),Ce(this,"listIndent",-1),Ce(this,"parentType","root"),Ce(this,"level",0),Ce(this,"Token",Qr),this.src=e,this.md=t,this.env=s,this.tokens=n;const i=this.src;for(let r=0,a=0,l=0,c=0,u=i.length,h=!1;a<u;a++){const d=i.charCodeAt(a);if(!h)if(mt(d)){l++,d===9?c+=4-c%4:c++;continue}else h=!0;(d===10||a===u-1)&&(d!==10&&a++,this.bMarks.push(r),this.eMarks.push(a),this.tShift.push(l),this.sCount.push(c),this.bsCount.push(0),h=!1,l=0,c=0,r=a+1)}this.bMarks.push(i.length),this.eMarks.push(i.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}push(e,t,s){const n=new Qr(e,t,s);return n.block=!0,s<0&&this.level--,n.level=this.level,s>0&&this.level++,this.tokens.push(n),n}isEmpty(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]}skipEmptyLines(e){for(let t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e}skipSpaces(e){for(let t=this.src.length;e<t&&mt(this.src.charCodeAt(e));e++);return e}skipSpacesBack(e,t){if(e<=t)return e;for(;e>t;)if(!mt(this.src.charCodeAt(--e)))return e+1;return e}skipChars(e,t){for(let s=this.src.length;e<s&&this.src.charCodeAt(e)===t;e++);return e}skipCharsBack(e,t,s){if(e<=s)return e;for(;e>s;)if(t!==this.src.charCodeAt(--e))return e+1;return e}getLines(e,t,s,n){if(e>=t)return"";const i=new Array(t-e);for(let r=0,a=e;a<t;a++,r++){let l=0;const c=this.bMarks[a];let u=c,h;for(a+1<t||n?h=this.eMarks[a]+1:h=this.eMarks[a];u<h&&l<s;){const d=this.src.charCodeAt(u);if(mt(d))d===9?l+=4-(l+this.bsCount[a])%4:l++;else if(u-c<this.tShift[a])l++;else break;u++}l>s?i[r]=new Array(l-s+1).join(" ")+this.src.slice(u,h):i[r]=this.src.slice(u,h)}return i.join("")}},wT=65536;function _f(e,t){const s=e.bMarks[t]+e.tShift[t],n=e.eMarks[t];return e.src.slice(s,n)}function M0(e){const t=[],s=e.length;let n=0,i=e.charCodeAt(n),r=!1,a=0,l="";for(;n<s;)i===124&&(r?(l+=e.substring(a,n-1),a=n):(t.push(l+e.substring(a,n)),l="",a=n+1)),r=i===92,n++,i=e.charCodeAt(n);return t.push(l+e.substring(a)),t}function xT(e,t,s,n){if(t+2>s)return!1;let i=t+1;if(e.sCount[i]<e.blkIndent||e.sCount[i]-e.blkIndent>=4)return!1;let r=e.bMarks[i]+e.tShift[i];if(r>=e.eMarks[i])return!1;const a=e.src.charCodeAt(r++);if(a!==124&&a!==45&&a!==58||r>=e.eMarks[i])return!1;const l=e.src.charCodeAt(r++);if(l!==124&&l!==45&&l!==58&&!mt(l)||a===45&&mt(l))return!1;for(;r<e.eMarks[i];){const x=e.src.charCodeAt(r);if(x!==124&&x!==45&&x!==58&&!mt(x))return!1;r++}let c=_f(e,t+1),u=c.split("|");const h=[];for(let x=0;x<u.length;x++){const S=u[x].trim();if(!S){if(x===0||x===u.length-1)continue;return!1}if(!/^:?-+:?$/.test(S))return!1;S.charCodeAt(S.length-1)===58?h.push(S.charCodeAt(0)===58?"center":"right"):S.charCodeAt(0)===58?h.push("left"):h.push("")}if(c=_f(e,t).trim(),c.indexOf("|")===-1||e.sCount[t]-e.blkIndent>=4)return!1;u=M0(c),u.length&&u[0]===""&&u.shift(),u.length&&u[u.length-1]===""&&u.pop();const d=u.length;if(d===0||d!==h.length)return!1;if(n)return!0;const p=e.parentType;e.parentType="table";const f=e.md.block.ruler.getRules("blockquote"),m=e.push("table_open","table",1),b=[t,0];m.map=b;const _=e.push("thead_open","thead",1);_.map=[t,t+1];const v=e.push("tr_open","tr",1);v.map=[t,t+1];for(let x=0;x<u.length;x++){const S=e.push("th_open","th",1);h[x]&&(S.attrs=[["style",`text-align:${h[x]}`]]);const E=e.push("inline","",0);E.content=u[x].trim(),E.children=[],e.push("th_close","th",-1)}e.push("tr_close","tr",-1),e.push("thead_close","thead",-1);let y,w=0;for(i=t+2;i<s&&!(e.sCount[i]<e.blkIndent);i++){let x=!1;for(let E=0,R=f.length;E<R;E++)if(f[E](e,i,s,!0)){x=!0;break}if(x||(c=_f(e,i).trim(),!c)||e.sCount[i]-e.blkIndent>=4||(u=M0(c),u.length&&u[0]===""&&u.shift(),u.length&&u[u.length-1]===""&&u.pop(),w+=d-u.length,w>wT))break;if(i===t+2){const E=e.push("tbody_open","tbody",1);E.map=y=[t+2,0]}const S=e.push("tr_open","tr",1);S.map=[i,i+1];for(let E=0;E<d;E++){const R=e.push("td_open","td",1);h[E]&&(R.attrs=[["style",`text-align:${h[E]}`]]);const N=e.push("inline","",0);N.content=u[E]?u[E].trim():"",N.children=[],e.push("td_close","td",-1)}e.push("tr_close","tr",-1)}return y&&(e.push("tbody_close","tbody",-1),y[1]=i),e.push("table_close","table",-1),b[1]=i,e.parentType=p,e.line=i,!0}function ST(e,t,s){if(e.sCount[t]-e.blkIndent<4)return!1;let n=t+1,i=n;for(;n<s;){if(e.isEmpty(n)){n++;continue}if(e.sCount[n]-e.blkIndent>=4){n++,i=n;continue}break}e.line=i;const r=e.push("code_block","code",0);return r.content=e.getLines(t,i,4+e.blkIndent,!1)+`
62
+ `,r.map=[t,e.line],!0}function kT(e,t,s,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||i+3>r)return!1;const a=e.src.charCodeAt(i);if(a!==126&&a!==96)return!1;let l=i;i=e.skipChars(i,a);let c=i-l;if(c<3)return!1;const u=e.src.slice(l,i),h=e.src.slice(i,r);if(a===96&&h.indexOf(String.fromCharCode(a))>=0)return!1;if(n)return!0;let d=t,p=!1;for(;d++,!(d>=s||(i=l=e.bMarks[d]+e.tShift[d],r=e.eMarks[d],i<r&&e.sCount[d]<e.blkIndent));)if(e.src.charCodeAt(i)===a&&!(e.sCount[d]-e.blkIndent>=4)&&(i=e.skipChars(i,a),!(i-l<c)&&(i=e.skipSpaces(i),!(i<r)))){p=!0;break}c=e.sCount[t],e.line=d+(p?1:0);const f=e.push("fence","code",0);return f.info=h,f.content=e.getLines(t+1,d,c,!0),f.markup=u,f.map=[t,e.line],!0}function CT(e,t,s,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];const a=e.lineMax;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(i)!==62)return!1;if(n)return!0;const l=[],c=[],u=[],h=[],d=e.md.block.ruler.getRules("blockquote"),p=e.parentType;e.parentType="blockquote";let f=!1,m;for(m=t;m<s;m++){const w=e.sCount[m]<e.blkIndent;if(i=e.bMarks[m]+e.tShift[m],r=e.eMarks[m],i>=r)break;if(e.src.charCodeAt(i++)===62&&!w){let S=e.sCount[m]+1,E,R;e.src.charCodeAt(i)===32?(i++,S++,R=!1,E=!0):e.src.charCodeAt(i)===9?(E=!0,(e.bsCount[m]+S)%4===3?(i++,S++,R=!1):R=!0):E=!1;let N=S;for(l.push(e.bMarks[m]),e.bMarks[m]=i;i<r;){const I=e.src.charCodeAt(i);if(mt(I))I===9?N+=4-(N+e.bsCount[m]+(R?1:0))%4:N++;else break;i++}f=i>=r,c.push(e.bsCount[m]),e.bsCount[m]=e.sCount[m]+1+(E?1:0),u.push(e.sCount[m]),e.sCount[m]=N-S,h.push(e.tShift[m]),e.tShift[m]=i-e.bMarks[m];continue}if(f)break;let x=!1;for(let S=0,E=d.length;S<E;S++)if(d[S](e,m,s,!0)){x=!0;break}if(x){e.lineMax=m,e.blkIndent!==0&&(l.push(e.bMarks[m]),c.push(e.bsCount[m]),h.push(e.tShift[m]),u.push(e.sCount[m]),e.sCount[m]-=e.blkIndent);break}l.push(e.bMarks[m]),c.push(e.bsCount[m]),h.push(e.tShift[m]),u.push(e.sCount[m]),e.sCount[m]=-1}const b=e.blkIndent;e.blkIndent=0;const _=e.push("blockquote_open","blockquote",1);_.markup=">";const v=[t,0];_.map=v,e.md.block.tokenize(e,t,m);const y=e.push("blockquote_close","blockquote",-1);y.markup=">",e.lineMax=a,e.parentType=p,v[1]=e.line;for(let w=0;w<h.length;w++)e.bMarks[w+t]=l[w],e.tShift[w+t]=h[w],e.sCount[w+t]=u[w],e.bsCount[w+t]=c[w];return e.blkIndent=b,!0}function ET(e,t,s,n){const i=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let r=e.bMarks[t]+e.tShift[t];const a=e.src.charCodeAt(r++);if(a!==42&&a!==45&&a!==95)return!1;let l=1;for(;r<i;){const u=e.src.charCodeAt(r++);if(u!==a&&!mt(u))return!1;u===a&&l++}if(l<3)return!1;if(n)return!0;e.line=t+1;const c=e.push("hr","hr",0);return c.map=[t,e.line],c.markup=Array(l+1).join(String.fromCharCode(a)),!0}function D0(e,t){const s=e.eMarks[t];let n=e.bMarks[t]+e.tShift[t];const i=e.src.charCodeAt(n++);return i!==42&&i!==45&&i!==43||n<s&&!mt(e.src.charCodeAt(n))?-1:n}function I0(e,t){const s=e.bMarks[t]+e.tShift[t],n=e.eMarks[t];let i=s;if(i+1>=n)return-1;let r=e.src.charCodeAt(i++);if(r<48||r>57)return-1;for(;;){if(i>=n)return-1;if(r=e.src.charCodeAt(i++),r>=48&&r<=57){if(i-s>=10)return-1;continue}if(r===41||r===46)break;return-1}return i<n&&(r=e.src.charCodeAt(i),!mt(r))?-1:i}function NT(e,t){const s=e.level+2;for(let n=t+2,i=e.tokens.length-2;n<i;n++)e.tokens[n].level===s&&e.tokens[n].type==="paragraph_open"&&(e.tokens[n+2].hidden=!0,e.tokens[n].hidden=!0,n+=2)}function RT(e,t,s,n){let i,r,a,l,c=t,u=!0;if(e.sCount[c]-e.blkIndent>=4||e.listIndent>=0&&e.sCount[c]-e.listIndent>=4&&e.sCount[c]<e.blkIndent)return!1;let h=!1;n&&e.parentType==="paragraph"&&e.sCount[c]>=e.blkIndent&&(h=!0);let d,p,f;if((f=I0(e,c))>=0){if(d=!0,a=e.bMarks[c]+e.tShift[c],p=Number(e.src.slice(a,f-1)),h&&p!==1)return!1}else if((f=D0(e,c))>=0)d=!1;else return!1;if(h&&e.skipSpaces(f)>=e.eMarks[c])return!1;if(n)return!0;const m=e.src.charCodeAt(f-1),b=e.tokens.length;d?(l=e.push("ordered_list_open","ol",1),p!==1&&(l.attrs=[["start",p]])):l=e.push("bullet_list_open","ul",1);const _=[c,0];l.map=_,l.markup=String.fromCharCode(m);let v=!1;const y=e.md.block.ruler.getRules("list"),w=e.parentType;for(e.parentType="list";c<s;){r=f,i=e.eMarks[c];const x=e.sCount[c]+f-(e.bMarks[c]+e.tShift[c]);let S=x;for(;r<i;){const H=e.src.charCodeAt(r);if(H===9)S+=4-(S+e.bsCount[c])%4;else if(H===32)S++;else break;r++}const E=r;let R;E>=i?R=1:R=S-x,R>4&&(R=1);const N=x+R;l=e.push("list_item_open","li",1),l.markup=String.fromCharCode(m);const I=[c,0];l.map=I,d&&(l.info=e.src.slice(a,f-1));const F=e.tight,B=e.tShift[c],C=e.sCount[c],A=e.listIndent;if(e.listIndent=e.blkIndent,e.blkIndent=N,e.tight=!0,e.tShift[c]=E-e.bMarks[c],e.sCount[c]=S,E>=i&&e.isEmpty(c+1)?e.line=Math.min(e.line+2,s):e.md.block.tokenize(e,c,s),(!e.tight||v)&&(u=!1),v=e.line-c>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=A,e.tShift[c]=B,e.sCount[c]=C,e.tight=F,l=e.push("list_item_close","li",-1),l.markup=String.fromCharCode(m),c=e.line,I[1]=c,c>=s||e.sCount[c]<e.blkIndent||e.sCount[c]-e.blkIndent>=4)break;let M=!1;for(let H=0,D=y.length;H<D;H++)if(y[H](e,c,s,!0)){M=!0;break}if(M)break;if(d){if(f=I0(e,c),f<0)break;a=e.bMarks[c]+e.tShift[c]}else if(f=D0(e,c),f<0)break;if(m!==e.src.charCodeAt(f-1))break}return d?l=e.push("ordered_list_close","ol",-1):l=e.push("bullet_list_close","ul",-1),l.markup=String.fromCharCode(m),_[1]=c,e.line=c,e.parentType=w,u&&NT(e,b),!0}function jT(e,t,s,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t],a=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(i)!==91)return!1;function l(x){const S=e.lineMax;if(x>=S||e.isEmpty(x))return null;let E=!1;if(e.sCount[x]-e.blkIndent>3&&(E=!0),e.sCount[x]<0&&(E=!0),!E){const I=e.md.block.ruler.getRules("reference"),F=e.parentType;e.parentType="reference";let B=!1;for(let C=0,A=I.length;C<A;C++)if(I[C](e,x,S,!0)){B=!0;break}if(e.parentType=F,B)return null}const R=e.bMarks[x]+e.tShift[x],N=e.eMarks[x];return e.src.slice(R,N+1)}let c=e.src.slice(i,r+1);r=c.length;let u=-1;for(i=1;i<r;i++){const x=c.charCodeAt(i);if(x===91)return!1;if(x===93){u=i;break}else if(x===10){const S=l(a);S!==null&&(c+=S,r=c.length,a++)}else if(x===92&&(i++,i<r&&c.charCodeAt(i)===10)){const S=l(a);S!==null&&(c+=S,r=c.length,a++)}}if(u<0||c.charCodeAt(u+1)!==58)return!1;for(i=u+2;i<r;i++){const x=c.charCodeAt(i);if(x===10){const S=l(a);S!==null&&(c+=S,r=c.length,a++)}else if(!mt(x))break}const h=e.md.helpers.parseLinkDestination(c,i,r);if(!h.ok)return!1;const d=e.md.normalizeLink(h.str);if(!e.md.validateLink(d))return!1;i=h.pos;const p=i,f=a,m=i;for(;i<r;i++){const x=c.charCodeAt(i);if(x===10){const S=l(a);S!==null&&(c+=S,r=c.length,a++)}else if(!mt(x))break}let b=e.md.helpers.parseLinkTitle(c,i,r);for(;b.can_continue;){const x=l(a);if(x===null)break;c+=x,i=r,r=c.length,a++,b=e.md.helpers.parseLinkTitle(c,i,r,b)}let _;for(i<r&&m!==i&&b.ok?(_=b.str,i=b.pos):(_="",i=p,a=f);i<r&&mt(c.charCodeAt(i));)i++;if(i<r&&c.charCodeAt(i)!==10&&_)for(_="",i=p,a=f;i<r&&mt(c.charCodeAt(i));)i++;if(i<r&&c.charCodeAt(i)!==10)return!1;const v=pd(c.slice(1,u));if(!v)return!1;if(n)return!0;typeof e.env.references>"u"&&(e.env.references={}),typeof e.env.references[v]>"u"&&(e.env.references[v]={title:_,href:d});const y=e.push("reference_definition","",0);y.map=[t,a],y.hidden=!0;const w=Object.create(null);return w.label=v,y.meta=w,e.line=a,!0}var TT=["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"],m1=`<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^"'=<>\`\\x00-\\x20]+|'[^']*'|"[^"]*"))?)*\\s*\\/?>`,g1="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",AT=new RegExp(`^(?:${m1}|${g1}|<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)`),MT=new RegExp(`^(?:${m1}|${g1})`),Or=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Za-z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp(`^</?(${TT.join("|")})(?=(\\s|/?>|$))`,"i"),/^$/,!0],[new RegExp(`${MT.source}\\s*$`),/^$/,!1]];function DT(e,t,s,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(i)!==60)return!1;let a=e.src.slice(i,r),l=0;for(;l<Or.length&&!Or[l][0].test(a);l++);if(l===Or.length)return!1;if(n)return Or[l][2];let c=t+1;const u=Or[l][1].test("");if(!Or[l][1].test(a)){for(;c<s&&!(e.sCount[c]<e.blkIndent&&(u||!e.isEmpty(c)));c++)if(i=e.bMarks[c]+e.tShift[c],r=e.eMarks[c],a=e.src.slice(i,r),Or[l][1].test(a)){a.length!==0&&c++;break}}e.line=c;const h=e.push("html_block","",0);return h.map=[t,c],h.content=e.getLines(t,c,e.blkIndent,!0),!0}function IT(e,t,s,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let a=e.src.charCodeAt(i);if(a!==35||i>=r)return!1;let l=1;for(a=e.src.charCodeAt(++i);a===35&&i<r&&l<=6;)l++,a=e.src.charCodeAt(++i);if(l>6||i<r&&!mt(a))return!1;if(n)return!0;r=e.skipSpacesBack(r,i);const c=e.skipCharsBack(r,35,i);c>i&&mt(e.src.charCodeAt(c-1))&&(r=c),e.line=t+1;const u=e.push("heading_open",`h${l}`,1);u.markup="########".slice(0,l),u.map=[t,e.line];const h=e.push("inline","",0);h.content=md(e.src.slice(i,r)),h.map=[t,e.line],h.children=[];const d=e.push("heading_close",`h${l}`,-1);return d.markup="########".slice(0,l),!0}function PT(e,t,s){const n=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;const i=e.parentType;e.parentType="paragraph";let r=0,a,l=t+1;for(;l<s&&!e.isEmpty(l);l++){if(e.sCount[l]-e.blkIndent>3)continue;if(e.sCount[l]>=e.blkIndent){let f=e.bMarks[l]+e.tShift[l];const m=e.eMarks[l];if(f<m&&(a=e.src.charCodeAt(f),(a===45||a===61)&&(f=e.skipChars(f,a),f=e.skipSpaces(f),f>=m))){r=a===61?1:2;break}}if(e.sCount[l]<0)continue;let p=!1;for(let f=0,m=n.length;f<m;f++)if(n[f](e,l,s,!0)){p=!0;break}if(p)break}if(!r)return e.parentType=i,!1;const c=md(e.getLines(t,l,e.blkIndent,!1));e.line=l+1;const u=e.push("heading_open",`h${r}`,1);u.markup=String.fromCharCode(a),u.map=[t,e.line];const h=e.push("inline","",0);h.content=c,h.map=[t,e.line-1],h.children=[];const d=e.push("heading_close",`h${r}`,-1);return d.markup=String.fromCharCode(a),e.parentType=i,!0}function LT(e,t,s){const n=e.md.block.ruler.getRules("paragraph"),i=e.parentType;let r=t+1;for(e.parentType="paragraph";r<s&&!e.isEmpty(r);r++){if(e.sCount[r]-e.blkIndent>3||e.sCount[r]<0)continue;let u=!1;for(let h=0,d=n.length;h<d;h++)if(n[h](e,r,s,!0)){u=!0;break}if(u)break}const a=md(e.getLines(t,r,e.blkIndent,!1));e.line=r;const l=e.push("paragraph_open","p",1);l.map=[t,e.line];const c=e.push("inline","",0);return c.content=a,c.map=[t,e.line],c.children=[],e.push("paragraph_close","p",-1),e.parentType=i,!0}var fu=[["table",xT,["paragraph","reference"]],["code",ST],["fence",kT,["paragraph","reference","blockquote","list"]],["blockquote",CT,["paragraph","reference","blockquote","list"]],["hr",ET,["paragraph","reference","blockquote","list"]],["list",RT,["paragraph","reference","blockquote"]],["reference",jT],["html_block",DT,["paragraph","reference","blockquote"]],["heading",IT,["paragraph","reference","blockquote"]],["lheading",PT],["paragraph",LT]],_1=class{constructor(){Ce(this,"ruler",new _c),Ce(this,"State",p1);for(let e=0;e<fu.length;e++)this.ruler.push(fu[e][0],fu[e][1],{alt:(fu[e][2]||[]).slice()})}tokenize(e,t,s){const n=this.ruler.getRules(""),i=n.length,r=e.md.options.maxNesting;let a=t,l=!1;for(;a<s&&(e.line=a=e.skipEmptyLines(a),!(a>=s||e.sCount[a]<e.blkIndent));){if(e.level>=r){e.line=s;break}const c=e.line;let u=!1;for(let h=0;h<i;h++)if(u=n[h](e,a,s,!1),u){if(c>=e.line)throw new Error("block rule didn't increment state.line");break}if(!u)throw new Error("none of the block rules matched");e.tight=!l,e.isEmpty(e.line-1)&&(l=!0),a=e.line,a<s&&e.isEmpty(a)&&(l=!0,a++,e.line=a)}}parse(e,t,s,n){if(!e)return;const i=new this.State(e,t,s,n);this.tokenize(i,i.line,i.lineMax)}},v1=class{constructor(e,t,s,n){Ce(this,"pos",0),Ce(this,"level",0),Ce(this,"pending",""),Ce(this,"pendingLevel",0),Ce(this,"cache",{}),Ce(this,"backticks",{}),Ce(this,"backticksScanned",!1),Ce(this,"linkLevel",0),Ce(this,"delimiters",[]),Ce(this,"_prev_delimiters",[]),Ce(this,"Token",Qr),this.src=e,this.env=s,this.md=t,this.tokens=n,this.tokens_meta=Array(n.length),this.posMax=this.src.length}pushPending(){const e=new Qr("text","",0);return e.content=this.pending,e.level=this.pendingLevel,this.tokens.push(e),this.pending="",e}push(e,t,s){this.pending&&this.pushPending();const n=new Qr(e,t,s);let i;return s<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),n.level=this.level,s>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],i={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(n),this.tokens_meta.push(i),n}scanDelims(e,t){const s=this.posMax,n=this.src.charCodeAt(e);let i;if(e===0)i=32;else if(e===1)i=this.src.charCodeAt(0),(i&63488)===55296&&(i=65533);else if(i=this.src.charCodeAt(e-1),(i&64512)===56320){const m=this.src.charCodeAt(e-2);i=(m&64512)===55296?65536+(m-55296<<10)+(i-56320):65533}else(i&64512)===55296&&(i=65533);let r=e;for(;r<s&&this.src.charCodeAt(r)===n;)r++;const a=r-e;let l=r<s?this.src.charCodeAt(r):32;if((l&64512)===55296){const m=this.src.charCodeAt(r+1);l=(m&64512)===56320?65536+(l-55296<<10)+(m-56320):65533}else(l&64512)===56320&&(l=65533);const c=mc(i)||pc(i),u=mc(l)||pc(l),h=fc(i),d=fc(l),p=!d&&(!u||h||c),f=!h&&(!c||d||u);return{can_open:p&&(t||!f||c),can_close:f&&(t||!p||u),length:a}}};function OT(e){switch(e){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}function BT(e,t){let s=e.pos;for(;s<e.posMax&&!OT(e.src.charCodeAt(s));)s++;return s===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,s)),e.pos=s,!0)}function $T(e){return e>=65&&e<=90||e>=97&&e<=122}function FT(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===43||e===45||e===46}function zT(e,t){if(!e.md.options.linkify||e.linkLevel>0)return!1;const s=e.pos,n=e.posMax;if(s+3>n||e.src.charCodeAt(s)!==58||e.src.charCodeAt(s+1)!==47||e.src.charCodeAt(s+2)!==47)return!1;const i=s-Math.min(10,e.pending.length,s);let r=s;for(;r>i&&FT(e.src.charCodeAt(r-1));)r--;if(r===s||!$T(e.src.charCodeAt(r)))return!1;const a=s-r,l=e.md.linkify.matchAtStart(e.src.slice(r));if(!l)return!1;let c=l.url;if(c.length<=a)return!1;let u=c.length;for(;u>0&&c.charCodeAt(u-1)===42;)u--;u!==c.length&&(c=c.slice(0,u));const h=e.md.normalizeLink(c);if(!e.md.validateLink(h))return!1;if(!t){e.pending=e.pending.slice(0,-a);const d=e.push("link_open","a",1);d.attrs=[["href",h]],d.markup="linkify",d.info="auto";const p=e.push("text","",0);p.content=e.md.normalizeLinkText(c);const f=e.push("link_close","a",-1);f.markup="linkify",f.info="auto"}return e.pos+=c.length-a,!0}function HT(e,t){let s=e.pos;if(e.src.charCodeAt(s)!==10)return!1;const n=e.pending.length-1,i=e.posMax;if(!t)if(n>=0&&e.pending.charCodeAt(n)===32)if(n>=1&&e.pending.charCodeAt(n-1)===32){let r=n-1;for(;r>=1&&e.pending.charCodeAt(r-1)===32;)r--;e.pending=e.pending.slice(0,r),e.push("hardbreak","br",0)}else e.pending=e.pending.slice(0,-1),e.push("softbreak","br",0);else e.push("softbreak","br",0);for(s++;s<i&&mt(e.src.charCodeAt(s));)s++;return e.pos=s,!0}var h_=[];for(let e=0;e<256;e++)h_.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(e){h_[e.charCodeAt(0)]=1});function UT(e,t){let s=e.pos;const n=e.posMax;if(e.src.charCodeAt(s)!==92||(s++,s>=n))return!1;let i=e.src.charCodeAt(s);if(i===10){for(t||e.push("hardbreak","br",0),s++;s<n&&(i=e.src.charCodeAt(s),!!mt(i));)s++;return e.pos=s,!0}if(i===32){if(!t){const l=e.push("text_special","",0);l.content="\\",l.markup="\\",l.info="escape"}return e.pos=s,!0}let r=e.src[s];if(i>=55296&&i<=56319&&s+1<n){const l=e.src.charCodeAt(s+1);l>=56320&&l<=57343&&(r+=e.src[s+1],s++)}const a="\\"+r;if(!t){const l=e.push("text_special","",0);i<256&&h_[i]!==0?l.content=r:l.content=a,l.markup=a,l.info="escape"}return e.pos=s+1,!0}function WT(e){const t={};let s=0;for(;(s=e.indexOf("`",s))!==-1;){const n=s;for(;e.charCodeAt(++s)===96;);t[s-n]=n}return t}function KT(e,t){var s;const n=e.pos;if(e.src.charCodeAt(n)!==96)return!1;const i=e.posMax;let r=n+1;for(;r<i&&e.src.charCodeAt(r)===96;)r++;const a=e.src.slice(n,r),l=a.length;if(e.backticksScanned||(e.backticks=WT(e.src),e.backticksScanned=!0),((s=e.backticks[l])!==null&&s!==void 0?s:-1)>=r){let c=r,u;for(;(u=e.src.indexOf("`",c))!==-1&&u<i;){for(c=u+1;e.src.charCodeAt(c)===96;)c++;if(c>i)break;if(c-u===l){if(!t){const h=e.push("code_inline","code",0);h.markup=a;let d=e.src.slice(r,u).replace(/\n/g," ");d.startsWith(" ")&&d.endsWith(" ")&&/[^ ]/.test(d)&&(d=d.slice(1,-1)),h.content=d}return e.pos=c,!0}}}return t||(e.pending+=a),e.pos=r,!0}function qT(e,t){const s=e.pos,n=e.src.charCodeAt(s);if(t||n!==126)return!1;const i=e.scanDelims(e.pos,!0);let r=i.length;const a=String.fromCharCode(n);if(r<2)return!1;let l;r%2&&(l=e.push("text","",0),l.content=a,r--);for(let c=0;c<r;c+=2)l=e.push("text","",0),l.content=a+a,e.delimiters.push({marker:n,length:0,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return e.pos+=i.length,!0}function P0(e,t){let s;const n=[],i=t.length;for(let r=0;r<i;r++){const a=t[r];if(a.marker!==126||a.end===-1)continue;const l=t[a.end];s=e.tokens[a.token],s.type="s_open",s.tag="s",s.nesting=1,s.markup="~~",s.content="",s=e.tokens[l.token],s.type="s_close",s.tag="s",s.nesting=-1,s.markup="~~",s.content="",e.tokens[l.token-1].type==="text"&&e.tokens[l.token-1].content==="~"&&n.push(l.token-1)}for(;n.length;){const r=n.pop();let a=r+1;for(;a<e.tokens.length&&e.tokens[a].type==="s_close";)a++;a--,r!==a&&(s=e.tokens[a],e.tokens[a]=e.tokens[r],e.tokens[r]=s)}}function VT(e){const t=e.tokens_meta,s=e.tokens_meta.length;P0(e,e.delimiters);for(let i=0;i<s;i++){var n;const r=(n=t[i])===null||n===void 0?void 0:n.delimiters;r&&P0(e,r)}}var y1={tokenize:qT,postProcess:VT};function YT(e,t){const s=e.pos,n=e.src.charCodeAt(s);if(t||n!==95&&n!==42)return!1;const i=e.scanDelims(e.pos,n===42);for(let r=0;r<i.length;r++){const a=e.push("text","",0);a.content=String.fromCharCode(n),e.delimiters.push({marker:n,length:i.length,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close})}return e.pos+=i.length,!0}function L0(e,t){const s=t.length;for(let n=s-1;n>=0;n--){const i=t[n];if(i.marker!==95&&i.marker!==42||i.end===-1)continue;const r=t[i.end],a=n>0&&t[n-1].end===i.end+1&&t[n-1].marker===i.marker&&t[n-1].token===i.token-1&&t[i.end+1].token===r.token+1,l=String.fromCharCode(i.marker),c=e.tokens[i.token];c.type=a?"strong_open":"em_open",c.tag=a?"strong":"em",c.nesting=1,c.markup=a?l+l:l,c.content="";const u=e.tokens[r.token];u.type=a?"strong_close":"em_close",u.tag=a?"strong":"em",u.nesting=-1,u.markup=a?l+l:l,u.content="",a&&(e.tokens[t[n-1].token].content="",e.tokens[t[i.end+1].token].content="",n--)}}function GT(e){const t=e.tokens_meta,s=e.tokens_meta.length;L0(e,e.delimiters);for(let i=0;i<s;i++){var n;const r=(n=t[i])===null||n===void 0?void 0:n.delimiters;r&&L0(e,r)}}var b1={tokenize:YT,postProcess:GT};function JT(e,t){let s,n,i,r,a="",l="",c=e.pos,u=!0;if(e.src.charCodeAt(e.pos)!==91)return!1;const h=e.pos,d=e.posMax,p=e.pos+1,f=e.md.helpers.parseLinkLabel(e,e.pos,!0);if(f<0)return!1;let m=f+1;if(m<d&&e.src.charCodeAt(m)===40){for(u=!1,m++;m<d&&(s=e.src.charCodeAt(m),!(!mt(s)&&s!==10));m++);if(m>=d)return!1;if(c=m,i=e.md.helpers.parseLinkDestination(e.src,m,e.posMax),i.ok){for(a=e.md.normalizeLink(i.str),e.md.validateLink(a)?m=i.pos:a="",c=m;m<d&&(s=e.src.charCodeAt(m),!(!mt(s)&&s!==10));m++);if(i=e.md.helpers.parseLinkTitle(e.src,m,e.posMax),m<d&&c!==m&&i.ok)for(l=i.str,m=i.pos;m<d&&(s=e.src.charCodeAt(m),!(!mt(s)&&s!==10));m++);}(m>=d||e.src.charCodeAt(m)!==41)&&(u=!0),m++}if(u){if(typeof e.env.references>"u")return!1;if(m<d&&e.src.charCodeAt(m)===91?(c=m+1,m=e.md.helpers.parseLinkLabel(e,m),m>=0?n=e.src.slice(c,m++):m=f+1):m=f+1,n||(n=e.src.slice(p,f)),n=pd(n),r=e.env.references[n],!r)return e.pos=h,!1;a=r.href,l=r.title}if(!t){e.pos=p,e.posMax=f;const b=e.push("link_open","a",1),_=[["href",a]];if(b.attrs=_,l&&_.push(["title",l]),n){const v=Object.create(null);v.label=n,b.meta=v}e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,e.push("link_close","a",-1)}return e.pos=m,e.posMax=d,!0}function XT(e,t){let s,n,i,r,a,l,c,u,h="";const d=e.pos,p=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91)return!1;const f=e.pos+2,m=e.md.helpers.parseLinkLabel(e,e.pos+1,!1);if(m<0)return!1;if(r=m+1,r<p&&e.src.charCodeAt(r)===40){for(r++;r<p&&(s=e.src.charCodeAt(r),!(!mt(s)&&s!==10));r++);if(r>=p)return!1;for(u=r,l=e.md.helpers.parseLinkDestination(e.src,r,e.posMax),l.ok&&(h=e.md.normalizeLink(l.str),e.md.validateLink(h)?r=l.pos:h=""),u=r;r<p&&(s=e.src.charCodeAt(r),!(!mt(s)&&s!==10));r++);if(l=e.md.helpers.parseLinkTitle(e.src,r,e.posMax),r<p&&u!==r&&l.ok)for(c=l.str,r=l.pos;r<p&&(s=e.src.charCodeAt(r),!(!mt(s)&&s!==10));r++);else c="";if(r>=p||e.src.charCodeAt(r)!==41)return e.pos=d,!1;r++}else{if(typeof e.env.references>"u")return!1;if(r<p&&e.src.charCodeAt(r)===91?(u=r+1,r=e.md.helpers.parseLinkLabel(e,r),r>=0?i=e.src.slice(u,r++):r=m+1):r=m+1,i||(i=e.src.slice(f,m)),i=pd(i),a=e.env.references[i],!a)return e.pos=d,!1;h=a.href,c=a.title}if(!t){n=e.src.slice(f,m);const b=[];e.md.inline.parse(n,e.md,e.env,b);const _=e.push("image","img",0),v=[["src",h],["alt",""]];if(_.attrs=v,_.children=b,_.content=n,c&&v.push(["title",c]),i){const y=Object.create(null);y.label=i,_.meta=y}}return e.pos=r,e.posMax=p,!0}var ZT=/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,QT=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function eA(e,t){let s=e.pos;if(e.src.charCodeAt(s)!==60)return!1;const n=e.pos,i=e.posMax;for(;;){if(++s>=i)return!1;const a=e.src.charCodeAt(s);if(a===60)return!1;if(a===62)break}const r=e.src.slice(n+1,s);if(QT.test(r)){const a=e.md.normalizeLink(r);if(!e.md.validateLink(a))return!1;if(!t){const l=e.push("link_open","a",1);l.attrs=[["href",a]],l.markup="autolink",l.info="auto";const c=e.push("text","",0);c.content=e.md.normalizeLinkText(r);const u=e.push("link_close","a",-1);u.markup="autolink",u.info="auto"}return e.pos+=r.length+2,!0}if(ZT.test(r)){const a=e.md.normalizeLink(`mailto:${r}`);if(!e.md.validateLink(a))return!1;if(!t){const l=e.push("link_open","a",1);l.attrs=[["href",a]],l.markup="autolink",l.info="auto";const c=e.push("text","",0);c.content=e.md.normalizeLinkText(r);const u=e.push("link_close","a",-1);u.markup="autolink",u.info="auto"}return e.pos+=r.length+2,!0}return!1}function tA(e){return/^<a[>\s]/i.test(e)}function sA(e){return/^<\/a\s*>/i.test(e)}function nA(e){const t=e|32;return t>=97&&t<=122}function iA(e,t){if(!e.md.options.html)return!1;const s=e.posMax,n=e.pos;if(e.src.charCodeAt(n)!==60||n+2>=s)return!1;const i=e.src.charCodeAt(n+1);if(i!==33&&i!==63&&i!==47&&!nA(i))return!1;const r=e.src.slice(n).match(AT);if(!r)return!1;if(!t){const a=e.push("html_inline","",0);a.content=r[0],tA(a.content)&&e.linkLevel++,sA(a.content)&&e.linkLevel--}return e.pos+=r[0].length,!0}var rA=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,oA=/^&([a-z][a-z0-9]{1,31});/i;function aA(e,t){const s=e.pos,n=e.posMax;if(e.src.charCodeAt(s)!==38||s+1>=n)return!1;if(e.src.charCodeAt(s+1)===35){const i=e.src.slice(s).match(rA);if(i){if(!t){const r=i[1][0].toLowerCase()==="x"?parseInt(i[1].slice(1),16):parseInt(i[1],10),a=e.push("text_special","",0);a.content=u_(r)?dc(r):dc(65533),a.markup=i[0],a.info="entity"}return e.pos+=i[0].length,!0}}else{const i=e.src.slice(s).match(oA);if(i){const r=XS(i[0]);if(r!==i[0]){if(!t){const a=e.push("text_special","",0);a.content=r,a.markup=i[0],a.info="entity"}return e.pos+=i[0].length,!0}}}return!1}function O0(e){const t={},s=e.length;if(!s)return;let n=0,i=-2;const r=[];for(let a=0;a<s;a++){const l=e[a];if(r.push(0),(e[n].marker!==l.marker||i!==l.token-1)&&(n=a),i=l.token,l.length=l.length||0,!l.close)continue;t.hasOwnProperty(l.marker)||(t[l.marker]=[-1,-1,-1,-1,-1,-1]);const c=t[l.marker][(l.open?3:0)+l.length%3];let u=n-r[n]-1,h=u;for(;u>c;u-=r[u]+1){const d=e[u];if(d.marker===l.marker&&d.open&&d.end<0){let p=!1;if((d.close||l.open)&&(d.length+l.length)%3===0&&(d.length%3!==0||l.length%3!==0)&&(p=!0),!p){const f=u>0&&!e[u-1].open?r[u-1]+1:0;r[a]=a-u+f,r[u]=f,l.open=!1,d.end=a,d.close=!1,h=-1,i=-2;break}}}h!==-1&&(t[l.marker][(l.open?3:0)+(l.length||0)%3]=h)}}function lA(e){const t=e.tokens_meta,s=e.tokens_meta.length;O0(e.delimiters);for(let i=0;i<s;i++){var n;const r=(n=t[i])===null||n===void 0?void 0:n.delimiters;r&&O0(r)}}function cA(e){let t,s,n=0;const i=e.tokens,r=e.tokens.length;for(t=s=0;t<r;t++)i[t].nesting<0&&n--,i[t].level=n,i[t].nesting>0&&n++,i[t].type==="text"&&t+1<r&&i[t+1].type==="text"?i[t+1].content=i[t].content+i[t+1].content:(t!==s&&(i[s]=i[t]),s++);t!==s&&(i.length=s)}var vf=[["text",BT],["linkify",zT],["newline",HT],["escape",UT],["backticks",KT],["strikethrough",y1.tokenize],["emphasis",b1.tokenize],["link",JT],["image",XT],["autolink",eA],["html_inline",iA],["entity",aA]],yf=[["balance_pairs",lA],["strikethrough",y1.postProcess],["emphasis",b1.postProcess],["fragments_join",cA]],w1=class{constructor(){Ce(this,"ruler",new _c),Ce(this,"ruler2",new _c),Ce(this,"State",v1);for(let e=0;e<vf.length;e++)this.ruler.push(vf[e][0],vf[e][1]);for(let e=0;e<yf.length;e++)this.ruler2.push(yf[e][0],yf[e][1])}skipToken(e){const t=e.pos,s=this.ruler.getRules(""),n=s.length,i=e.md.options.maxNesting,r=e.cache;if(typeof r[t]<"u"){e.pos=r[t];return}let a=!1;if(e.level<i){for(let l=0;l<n;l++)if(e.level++,a=s[l](e,!0),e.level--,a){if(t>=e.pos)throw new Error("inline rule didn't increment state.pos");break}}else e.pos=e.posMax;a||e.pos++,r[t]=e.pos}tokenize(e){const t=this.ruler.getRules(""),s=t.length,n=e.posMax,i=e.md.options.maxNesting;for(;e.pos<n;){const r=e.pos;let a=!1;if(e.level<i){for(let l=0;l<s;l++)if(a=t[l](e,!1),a){if(r>=e.pos)throw new Error("inline rule didn't increment state.pos");break}}if(a){if(e.pos>=n)break;continue}e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()}parse(e,t,s,n){const i=new this.State(e,t,s,n);this.tokenize(i);const r=this.ruler2.getRules(""),a=r.length;for(let l=0;l<a;l++)r[l](i)}},uA={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},zero:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","strip_references","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}},commonmark:{options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","strip_references","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}}},hA=/^(vbscript|javascript|file|data):/,dA=/^data:image\/(gif|png|jpeg|webp);/,B0=["http:","https:","mailto:"],fi=class{validateLink(e){const t=e.trim().toLowerCase();return hA.test(t)?dA.test(t):!0}normalizeLink(e){const t=om(e,!0);if(t.hostname&&(!t.protocol||B0.indexOf(t.protocol)>=0))try{t.hostname=E0.toASCII(t.hostname)}catch{}return t.auth&&(t.auth=Si(t.auth)),t.hostname&&(t.hostname=Si(t.hostname)),t.pathname&&(t.pathname=Si(t.pathname)),t.search&&(t.search=Si(t.search)),t.hash&&(t.hash=Si(t.hash)),rm(t)}normalizeLinkText(e){const t=om(e,!0);if(t.hostname&&(!t.protocol||B0.indexOf(t.protocol)>=0))try{t.hostname=E0.toUnicode(t.hostname)}catch{}return wa(rm(t),wa.defaultChars+"%")}constructor(...e){Ce(this,"inline",new w1),Ce(this,"block",new _1),Ce(this,"core",new f1),Ce(this,"renderer",new u1),Ce(this,"linkify",new wj),Ce(this,"utils",Dj),Ce(this,"helpers",Object.assign({},Gj));const[t,s]=e;typeof t=="string"?(this.configure(t),s&&this.set(s)):(this.configure("default"),this.set(t||{}))}set(e){return Object.assign(this.options,e),this}configure(e){let t;if(typeof e=="string"){const i=e;if(t=uA[i],!t)throw new Error(`Wrong 'markdown-it' preset "${i}", check name`)}else t=e;if(!t)throw new Error("Wrong `markdown-it` preset, can't be empty");t.options&&(this.options={...t.options});const s=t.components;if(s){var n;["core","block","inline"].forEach(r=>{var a;const l=(a=s[r])===null||a===void 0?void 0:a.rules;l&&this[r].ruler.enableOnly(l)});const i=(n=s.inline)===null||n===void 0?void 0:n.rules2;i&&this.inline.ruler2.enableOnly(i)}return this}enable(e,t=!1){let s=[];Array.isArray(e)||(e=[e]),["core","block","inline"].forEach(i=>{s=s.concat(this[i].ruler.enable(e,!0))}),s=s.concat(this.inline.ruler2.enable(e,!0));const n=e.filter(i=>s.indexOf(i)<0);if(n.length&&!t)throw new Error(`MarkdownIt. Failed to enable unknown rule(s): ${n}`);return this}disable(e,t=!1){let s=[];Array.isArray(e)||(e=[e]),["core","block","inline"].forEach(i=>{s=s.concat(this[i].ruler.disable(e,!0))}),s=s.concat(this.inline.ruler2.disable(e,!0));const n=e.filter(i=>s.indexOf(i)<0);if(n.length&&!t)throw new Error(`MarkdownIt. Failed to disable unknown rule(s): ${n}`);return this}use(e,...t){return e.apply(e,[this,...t]),this}parse(e,t){if(typeof e!="string")throw new Error("Input data should be a String");const s=new this.core.State(e,this,t);return this.core.process(s),s.tokens}render(e,t={}){return this.renderer.render(this.parse(e,t),this.options,t)}parseInline(e,t){const s=new this.core.State(e,this,t);return s.inlineMode=!0,this.core.process(s),s.tokens}renderInline(e,t={}){return this.renderer.render(this.parseInline(e,t),this.options,t)}};Ce(fi,"Token",Qr);Ce(fi,"Ruler",_c);Ce(fi,"Renderer",u1);Ce(fi,"ParserCore",f1);Ce(fi,"StateCore",h1);Ce(fi,"ParserBlock",_1);Ce(fi,"StateBlock",p1);Ce(fi,"ParserInline",w1);Ce(fi,"StateInline",v1);var fA=a1(fi);/*! @license DOMPurify 3.4.16 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.16/LICENSE */function $0(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,n=Array(t);s<t;s++)n[s]=e[s];return n}function pA(e){if(Array.isArray(e))return e}function mA(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var n,i,r,a,l=[],c=!0,u=!1;try{if(r=(s=s.call(e)).next,t!==0)for(;!(c=(n=r.call(s)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(h){u=!0,i=h}finally{try{if(!c&&s.return!=null&&(a=s.return(),Object(a)!==a))return}finally{if(u)throw i}}return l}}function gA(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
63
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */function _A(e,t){return pA(e)||mA(e,t)||vA(e,t)||gA()}function vA(e,t){if(e){if(typeof e=="string")return $0(e,t);var s={}.toString.call(e).slice(8,-1);return s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set"?Array.from(e):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?$0(e,t):void 0}}const x1=Object.entries,F0=Object.setPrototypeOf,yA=Object.isFrozen,bA=Object.getPrototypeOf,wA=Object.getOwnPropertyDescriptor;let ts=Object.freeze,us=Object.seal,zo=Object.create,S1=typeof Reflect<"u"&&Reflect,lm=S1.apply,cm=S1.construct;ts||(ts=function(t){return t});us||(us=function(t){return t});lm||(lm=function(t,s){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return t.apply(s,i)});cm||(cm=function(t){for(var s=arguments.length,n=new Array(s>1?s-1:0),i=1;i<s;i++)n[i-1]=arguments[i];return new t(...n)});const zr=Gt(Array.prototype.forEach),xA=Gt(Array.prototype.lastIndexOf),z0=Gt(Array.prototype.pop),tl=Gt(Array.prototype.push),SA=Gt(Array.prototype.splice),ha=Array.isArray,Cl=Gt(String.prototype.toLowerCase),bf=Gt(String.prototype.toString),H0=Gt(String.prototype.match),sl=Gt(String.prototype.replace),U0=Gt(String.prototype.indexOf),kA=Gt(String.prototype.trim),CA=Gt(Number.prototype.toString),EA=Gt(Boolean.prototype.toString),W0=typeof BigInt>"u"?null:Gt(BigInt.prototype.toString),K0=typeof Symbol>"u"?null:Gt(Symbol.prototype.toString),Us=Gt(Object.prototype.hasOwnProperty),nl=Gt(Object.prototype.toString),Es=Gt(RegExp.prototype.test),qi=NA(TypeError);function Gt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var s=arguments.length,n=new Array(s>1?s-1:0),i=1;i<s;i++)n[i-1]=arguments[i];return lm(e,t,n)}}function NA(e){return function(){for(var t=arguments.length,s=new Array(t),n=0;n<t;n++)s[n]=arguments[n];return cm(e,s)}}function nt(e,t){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Cl;if(F0&&F0(e,null),!ha(t))return e;let n=t.length;for(;n--;){let i=t[n];if(typeof i=="string"){const r=s(i);r!==i&&(yA(t)||(t[n]=r),i=r)}e[i]=!0}return e}function RA(e){for(let t=0;t<e.length;t++)Us(e,t)||(e[t]=null);return e}function en(e){const t=zo(null);for(const n of x1(e)){var s=_A(n,2);const i=s[0],r=s[1];Us(e,i)&&(ha(r)?t[i]=RA(r):r&&typeof r=="object"&&r.constructor===Object?t[i]=en(r):t[i]=r)}return t}function jA(e){switch(typeof e){case"string":return e;case"number":return CA(e);case"boolean":return EA(e);case"bigint":return W0?W0(e):"0";case"symbol":return K0?K0(e):"Symbol()";case"undefined":return nl(e);case"function":case"object":{if(e===null)return nl(e);const t=e,s=mn(t,"toString");if(typeof s=="function"){const n=s(t);return typeof n=="string"?n:nl(n)}return nl(e)}default:return nl(e)}}function mn(e,t){for(;e!==null;){const n=wA(e,t);if(n){if(n.get)return Gt(n.get);if(typeof n.value=="function")return Gt(n.value)}e=bA(e)}function s(){return null}return s}function TA(e){try{return Es(e,""),!0}catch{return!1}}const q0=ts(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),wf=ts(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),xf=ts(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),AA=ts(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Sf=ts(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),MA=ts(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),V0=ts(["#text"]),Y0=ts(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),kf=ts(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),G0=ts(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),pu=ts(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),DA=us(/{{[\w\W]*|^[\w\W]*}}/g),IA=us(/<%[\w\W]*|^[\w\W]*%>/g),PA=us(/\${[\w\W]*/g),LA=us(/^data-[\-\w.\u00B7-\uFFFF]+$/),OA=us(/^aria-[\-\w]+$/),J0=us(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),BA=us(/^(?:\w+script|data):/i),$A=us(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),FA=us(/^html$/i),zA=us(/^[a-z][.\w]*(-[.\w]+)+$/i),X0=us(/<[/\w!]/g),Z0=us(/<[/\w]/g),HA=us(/<\/no(script|embed|frames)/i),UA=us(/\/>/i),Xs={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},k1=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],WA=ts(nt({},k1)),KA=function(){const e={};return zr(k1,t=>{e[t]=us(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),ts(e)}(),qA=function(){return typeof window>"u"?null:window},VA=function(t,s){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";s&&s.hasAttribute(i)&&(n=s.getAttribute(i));const r="dompurify"+(n?"#"+n:"");try{return t.createPolicy(r,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},Q0=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Vi=function(t,s,n,i){return Us(t,s)&&ha(t[s])?nt(i.base?en(i.base):{},t[s],i.transform):n},Cf=function(t,s,n){const i=Us(t,s)?t[s]:void 0;return i&&typeof i=="object"?en(i):n()};function C1(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qA();const t=ne=>C1(ne);if(t.version="3.4.16",t.removed=[],!e||!e.document||e.document.nodeType!==Xs.document||!e.Element)return t.isSupported=!1,t;let s=e.document;const n=s,i=n.currentScript;e.DocumentFragment;const r=e.HTMLTemplateElement,a=e.Node,l=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const u=e.DOMParser,h=e.trustedTypes,d=l.prototype,p=mn(d,"cloneNode"),f=mn(d,"remove"),m=mn(d,"removeAttributeNode"),b=mn(d,"nextSibling"),_=mn(d,"childNodes"),v=mn(d,"parentNode"),y=mn(d,"shadowRoot"),w=mn(d,"attributes"),x=a&&a.prototype?mn(a.prototype,"nodeType"):null,S=a&&a.prototype?mn(a.prototype,"nodeName"):null,E=a&&a.prototype?mn(a.prototype,"ownerDocument"):null,R=function(k){return x?x(k):k.nodeType},N=function(k){return S?S(k):k.nodeName};if(typeof r=="function"){const ne=s.createElement("template");ne.content&&ne.content.ownerDocument&&(s=ne.content.ownerDocument)}let I,F="",B,C=!1,A=0;const M=function(){if(A>0)throw qi('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},H=function(k){M(),A++;try{return I.createHTML(k)}finally{A--}},D=function(k){M(),A++;try{return I.createScriptURL(k)}finally{A--}},z=function(){return C||(B=VA(h,i),C=!0),B},T=s,O=T.implementation,K=T.createNodeIterator,U=T.createDocumentFragment,re=T.getElementsByTagName,J=n.importNode;let Y=Q0();t.isSupported=typeof x1=="function"&&typeof v=="function"&&O&&O.createHTMLDocument!==void 0;const _e=DA,xe=IA,fe=PA,et=LA,Oe=OA,tt=BA,Pe=$A,Le=zA;let Ee=J0,Ae=null;const Ze=nt({},[...q0,...wf,...xf,...Sf,...V0]);let me=null;const Ye=nt({},[...Y0,...kf,...G0,...pu]);let de=Object.seal(zo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),lt=null,ae=null;const be=Object.seal(zo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Be=!0,W=!0,Se=!1,He=!0,q=!1,Z=!0,ge=!1,P=!1,le=null,je=null,Ie=!1,Ge=!1,ot=!1,dt=!1,at=!0,Q=!1;const ke="user-content-";let Ne=!0,$e=!1,gt={},St=null;const Jt=nt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let dn=null;const ye=nt({},["audio","video","img","source","image","track"]);let Dt=null;const Me=nt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),kt="http://www.w3.org/1998/Math/MathML",Nn="http://www.w3.org/2000/svg",Ts="http://www.w3.org/1999/xhtml";let Rn=Ts,Un=!1,jn=null;const zs=nt({},[kt,Nn,Ts],bf),Nr=ts(["mi","mo","mn","ms","mtext"]);let Bi=nt({},Nr);const bo=ts(["annotation-xml"]);let Ot=nt({},bo);const ws=nt({},["title","style","font","a","script"]);let ds=null;const Tn=["application/xhtml+xml","text/html"],Rr="text/html";let rt=null,Qe=null;const jr=s.createElement("form"),Tr=function(k){return k instanceof RegExp||k instanceof Function},j=function(){let k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Qe&&Qe===k)return;(!k||typeof k!="object")&&(k={}),k=en(k),ds=Tn.indexOf(k.PARSER_MEDIA_TYPE)===-1?Rr:k.PARSER_MEDIA_TYPE,rt=ds==="application/xhtml+xml"?bf:Cl,Ae=Vi(k,"ALLOWED_TAGS",Ze,{transform:rt}),me=Vi(k,"ALLOWED_ATTR",Ye,{transform:rt}),jn=Vi(k,"ALLOWED_NAMESPACES",zs,{transform:bf}),Dt=Vi(k,"ADD_URI_SAFE_ATTR",Me,{transform:rt,base:Me}),dn=Vi(k,"ADD_DATA_URI_TAGS",ye,{transform:rt,base:ye}),St=Vi(k,"FORBID_CONTENTS",Jt,{transform:rt}),lt=Vi(k,"FORBID_TAGS",en({}),{transform:rt}),ae=Vi(k,"FORBID_ATTR",en({}),{transform:rt}),gt=Us(k,"USE_PROFILES")?k.USE_PROFILES&&typeof k.USE_PROFILES=="object"?en(k.USE_PROFILES):k.USE_PROFILES:!1,Be=k.ALLOW_ARIA_ATTR!==!1,W=k.ALLOW_DATA_ATTR!==!1,Se=k.ALLOW_UNKNOWN_PROTOCOLS||!1,He=k.ALLOW_SELF_CLOSE_IN_ATTR!==!1,q=k.SAFE_FOR_TEMPLATES||!1,Z=k.SAFE_FOR_XML!==!1,ge=k.WHOLE_DOCUMENT||!1,Ge=k.RETURN_DOM||!1,ot=k.RETURN_DOM_FRAGMENT||!1,dt=k.RETURN_TRUSTED_TYPE||!1,Ie=k.FORCE_BODY||!1,at=k.SANITIZE_DOM!==!1,Q=k.SANITIZE_NAMED_PROPS||!1,Ne=k.KEEP_CONTENT!==!1,$e=k.IN_PLACE||!1,Ee=TA(k.ALLOWED_URI_REGEXP)?k.ALLOWED_URI_REGEXP:J0,Rn=typeof k.NAMESPACE=="string"?k.NAMESPACE:Ts,Bi=Cf(k,"MATHML_TEXT_INTEGRATION_POINTS",()=>nt({},Nr)),Ot=Cf(k,"HTML_INTEGRATION_POINTS",()=>nt({},bo));const $=Cf(k,"CUSTOM_ELEMENT_HANDLING",()=>zo(null));if(de=zo(null),Us($,"tagNameCheck")&&Tr($.tagNameCheck)&&(de.tagNameCheck=$.tagNameCheck),Us($,"attributeNameCheck")&&Tr($.attributeNameCheck)&&(de.attributeNameCheck=$.attributeNameCheck),Us($,"allowCustomizedBuiltInElements")&&typeof $.allowCustomizedBuiltInElements=="boolean"&&(de.allowCustomizedBuiltInElements=$.allowCustomizedBuiltInElements),us(de),q&&(W=!1),ot&&(Ge=!0),gt&&(Ae=nt({},V0),me=zo(null),gt.html===!0&&(nt(Ae,q0),nt(me,Y0)),gt.svg===!0&&(nt(Ae,wf),nt(me,kf),nt(me,pu)),gt.svgFilters===!0&&(nt(Ae,xf),nt(me,kf),nt(me,pu)),gt.mathMl===!0&&(nt(Ae,Sf),nt(me,G0),nt(me,pu))),be.tagCheck=null,be.attributeCheck=null,Us(k,"ADD_TAGS")&&(typeof k.ADD_TAGS=="function"?be.tagCheck=k.ADD_TAGS:ha(k.ADD_TAGS)&&(Ae===Ze&&(Ae=en(Ae)),nt(Ae,k.ADD_TAGS,rt))),Us(k,"ADD_ATTR")&&(typeof k.ADD_ATTR=="function"?be.attributeCheck=k.ADD_ATTR:ha(k.ADD_ATTR)&&(me===Ye&&(me=en(me)),nt(me,k.ADD_ATTR,rt))),Us(k,"ADD_FORBID_CONTENTS")&&ha(k.ADD_FORBID_CONTENTS)&&(St===Jt&&(St=en(St)),nt(St,k.ADD_FORBID_CONTENTS,rt)),Ne&&(Ae["#text"]=!0),ge&&nt(Ae,["html","head","body"]),Ae.table&&(nt(Ae,["tbody"]),delete lt.tbody),k.TRUSTED_TYPES_POLICY){if(typeof k.TRUSTED_TYPES_POLICY.createHTML!="function")throw qi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof k.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw qi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const te=I;I=k.TRUSTED_TYPES_POLICY;try{F=H("")}catch(oe){throw I=te,oe}}else k.TRUSTED_TYPES_POLICY===null?(I=void 0,F=""):(I===void 0&&(I=z()),I&&typeof F=="string"&&(F=H("")));ts&&ts(k),Qe=k},V=nt({},[...wf,...xf,...AA]),se=nt({},[...Sf,...MA]),ze=function(k,$,te){return $.namespaceURI===Ts?k==="svg":$.namespaceURI===kt?k==="svg"&&(te==="annotation-xml"||Bi[te]):!!V[k]},Je=function(k,$,te){return $.namespaceURI===Ts?k==="math":$.namespaceURI===Nn?k==="math"&&Ot[te]:!!se[k]},Ct=function(k,$,te){return $.namespaceURI===Nn&&!Ot[te]||$.namespaceURI===kt&&!Bi[te]?!1:!se[k]&&(ws[k]||!V[k])},Ue=function(k){let $=v(k);(!$||!$.tagName)&&($={namespaceURI:Rn,tagName:"template"});const te=Cl(k.tagName),oe=Cl($.tagName);return jn[k.namespaceURI]?k.namespaceURI===Nn?ze(te,$,oe):k.namespaceURI===kt?Je(te,$,oe):k.namespaceURI===Ts?Ct(te,$,oe):!!(ds==="application/xhtml+xml"&&jn[k.namespaceURI]):!1},st=function(k){tl(t.removed,{element:k});try{v(k).removeChild(k)}catch{if(f(k),!v(k))throw qi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Lc=function(k,$,te){try{m(k,$)}catch{try{k.removeAttribute(te)}catch{}}},pi=function(k){$i(k);const $=_(k);if($){const oe=[];zr($,Re=>{tl(oe,Re)}),zr(oe,Re=>{try{f(Re)}catch{}})}const te=w(k);if(te)for(let oe=te.length-1;oe>=0;--oe){const Re=te[oe],We=Re&&Re.name;typeof We=="string"&&Lc(k,Re,We)}},mi=function(k,$,te){if(!te)try{te=$.getAttributeNode(k)}catch{te=null}tl(t.removed,{attribute:te||null,from:$});try{te?m($,te):$.removeAttribute(k)}catch{try{$.removeAttribute(k)}catch{}}if(k==="is")if(Ge||ot)try{st($)}catch{}else try{$.setAttribute(k,"")}catch{}},Sd=function(k){const $=w(k);if($)for(let te=$.length-1;te>=0;--te){const oe=$[te],Re=oe&&oe.name;typeof Re!="string"||me[rt(Re)]||Lc(k,oe,Re)}},$i=function(k){const $=[k];for(;$.length>0;){const te=$.pop();R(te)===Xs.element&&Sd(te);const oe=_(te);if(oe)for(let Re=oe.length-1;Re>=0;--Re)$.push(oe[Re])}},wo=function(k,$){return Z?k==="patchsrc"?!0:k==="for"&&$!=="label"&&$!=="output":!1},kd=function(k){if(!Z)return;const $=[k];for(;$.length>0;){const te=$.pop(),oe=R(te);if(oe===Xs.processingInstruction||oe===Xs.comment&&Es(Z0,te.data)){try{f(te)}catch{}continue}if(oe===Xs.element){const We=te,Ke=rt(N(te));try{We.hasAttribute&&We.hasAttribute("patchsrc")&&We.removeAttribute("patchsrc"),We.hasAttribute&&We.hasAttribute("for")&&wo("for",Ke)&&We.removeAttribute("for")}catch{}}const Re=_(te);if(Re)for(let We=Re.length-1;We>=0;--We)$.push(Re[We])}},Oc=function(k){let $=null,te=null;if(Ie)k="<remove></remove>"+k;else{const We=H0(k,/^[\r\n\t ]+/);te=We&&We[0]}ds==="application/xhtml+xml"&&Rn===Ts&&(k='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+k+"</body></html>");const oe=I?H(k):k;if(Rn===Ts)try{$=new u().parseFromString(oe,ds)}catch{}if(!$||!$.documentElement){$=O.createDocument(Rn,"template",null);try{$.documentElement.innerHTML=Un?F:oe}catch{}}const Re=$.body||$.documentElement;return k&&te&&Re.insertBefore(s.createTextNode(te),Re.childNodes[0]||null),Rn===Ts?re.call($,ge?"html":"body")[0]:ge?$.documentElement:Re},Da=function(k){const $=E?E(k):k.ownerDocument;return K.call($||k,k,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},xo=function(k){return k=sl(k,_e," "),k=sl(k,xe," "),k=sl(k,fe," "),k},Ar=function(k){var $;k.normalize();const te=E?E(k):k.ownerDocument,oe=K.call(te||k,k,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let Re=oe.nextNode();for(;Re;)Re.data=xo(Re.data),Re=oe.nextNode();const We=($=k.querySelectorAll)===null||$===void 0?void 0:$.call(k,"template");We&&zr(We,Ke=>{Wn(Ke.content)&&Ar(Ke.content)})},Js=function(k){const $=S?S(k):null;return typeof $!="string"||rt($)!=="form"?!1:typeof k.nodeName!="string"||typeof k.textContent!="string"||typeof k.removeChild!="function"||k.attributes!==w(k)||typeof k.removeAttribute!="function"||typeof k.removeAttributeNode!="function"||typeof k.getAttributeNode!="function"||typeof k.setAttribute!="function"||typeof k.namespaceURI!="string"||typeof k.insertBefore!="function"||typeof k.hasChildNodes!="function"||k.nodeType!==x(k)||k.childNodes!==_(k)},Wn=function(k){if(!x||typeof k!="object"||k===null)return!1;try{return x(k)===Xs.documentFragment}catch{return!1}},Kn=function(k){if(!x||typeof k!="object"||k===null)return!1;try{return typeof x(k)=="number"}catch{return!1}};function fs(ne,k,$){ne.length!==0&&zr(ne,te=>{te.call(t,k,$,Qe)})}const Bc=function(k,$){return!!(Z&&k.hasChildNodes()&&!Kn(k.firstElementChild)&&Es(X0,k.textContent)&&Es(X0,k.innerHTML)||Z&&k.namespaceURI===Ts&&WA[$]&&(Kn(k.firstElementChild)||typeof k.textContent=="string"&&Es(KA[$],k.textContent))||k.nodeType===Xs.processingInstruction||Z&&k.nodeType===Xs.comment&&Es(Z0,k.data))},So=function(k,$){if(k instanceof RegExp)return Es(k,$);if(k instanceof Function){for(var te=arguments.length,oe=new Array(te>2?te-2:0),Re=2;Re<te;Re++)oe[Re-2]=arguments[Re];return!!k($,...oe)}return!1},$c=function(k,$,te){if(!lt[$]&&qn($)&&So(de.tagNameCheck,$))return!1;if(Ne&&!St[$]){const oe=v(k),Re=_(k);if(Re&&oe){const We=Re.length;for(let Ke=We-1;Ke>=0;--Ke){const ft=k===te?p(Re[Ke],!0):Re[Ke];oe.insertBefore(ft,b(k))}}}return st(k),!0},Ia=function(k,$,te,oe){return k.length===0?$:$===te||$===oe?en($):$},An=function(k,$){return k===$||v(k)!==null?!1:($e&&$i(k),!0)},ko=function(k,$){if(fs(Y.beforeSanitizeElements,k,null),An(k,$))return!0;if(Js(k))return st(k),!0;const te=rt(N(k));if(Ae=Ia(Y.uponSanitizeElement,Ae,Ze,le),fs(Y.uponSanitizeElement,k,{tagName:te,allowedTags:Ae}),An(k,$))return!0;if(Bc(k,te))return st(k),!0;if(lt[te]||!(be.tagCheck instanceof Function&&be.tagCheck(te))&&!Ae[te]){const oe=$c(k,te,$);return oe===!1&&(fs(Y.afterSanitizeElements,k,null),An(k,$))?!0:oe}if(R(k)===Xs.element&&!Ue(k)||(te==="noscript"||te==="noembed"||te==="noframes")&&Es(HA,k.innerHTML))return st(k),!0;if(q&&k.nodeType===Xs.text){const oe=xo(k.textContent);k.textContent!==oe&&(tl(t.removed,{element:k.cloneNode()}),k.textContent=oe)}return fs(Y.afterSanitizeElements,k,null),An(k,$)},Pa=function(k,$,te){if(ae[$]||wo($,k)||at&&($==="id"||$==="name")&&(te in s||te in jr))return!1;const oe=me[$]||be.attributeCheck instanceof Function&&be.attributeCheck($,k);return W&&Es(et,$)||Be&&Es(Oe,$)?!0:oe?Dt[$]||Es(Ee,sl(te,Pe,""))||($==="src"||$==="xlink:href"||$==="href")&&k!=="script"&&U0(te,"data:")===0&&dn[k]||Se&&!Es(tt,sl(te,Pe,""))?!0:!te:qn(k)&&So(de.tagNameCheck,k)&&So(de.attributeNameCheck,$,k)||$==="is"&&de.allowCustomizedBuiltInElements&&So(de.tagNameCheck,te)},Fi=nt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),qn=function(k){return!Fi[Cl(k)]&&Es(Le,k)},Cd=function(k,$,te,oe){if(I&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!te)switch(h.getAttributeType(k,$)){case"TrustedHTML":return H(oe);case"TrustedScriptURL":return D(oe)}return oe},Mr=function(k,$,te,oe){try{return te?k.setAttributeNS(te,$,oe):k.setAttribute($,oe),Js(k)?(st(k),!1):!0}catch{return mi($,k),!1}},Co=function(k,$){if(fs(Y.beforeSanitizeAttributes,k,null),An(k,$))return;const te=k.attributes;if(!te||Js(k))return;me=Ia(Y.uponSanitizeAttribute,me,Ye,je);const oe={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:me,forceKeepAttr:void 0};let Re=te.length;const We=rt(k.nodeName);for(;Re--;){const Ke=te[Re],ft=Ke.name,xs=Ke.namespaceURI,Ms=Ke.value,zi=rt(ft),Oa=Ms;let ps=ft==="value"?Oa:kA(Oa),Fc=!1;if(oe.attrName=zi,oe.attrValue=ps,oe.keepAttr=!0,oe.forceKeepAttr=void 0,fs(Y.uponSanitizeAttribute,k,oe),ps=oe.attrValue,Q&&(zi==="id"||zi==="name")&&U0(ps,ke)!==0&&(mi(ft,k,Ke),ps=ke+ps,Fc=!0),Z&&Es(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ps)){mi(ft,k,Ke);continue}if(zi==="attributename"&&H0(ps,"href")){mi(ft,k,Ke);continue}if(!oe.forceKeepAttr){if(!oe.keepAttr){mi(ft,k,Ke);continue}if(!He&&Es(UA,ps)){mi(ft,k,Ke);continue}if(q&&(ps=xo(ps)),!Pa(We,zi,ps)){mi(ft,k,Ke);continue}ps=Cd(We,zi,xs,ps),ps!==Oa&&Mr(k,ft,xs,ps)&&Fc&&z0(t.removed)}}fs(Y.afterSanitizeAttributes,k,null),An(k,$)},As=function(k){let $=null;const te=Da(k);for(fs(Y.beforeSanitizeShadowDOM,k,null);$=te.nextNode();)if(fs(Y.uponSanitizeShadowNode,$,null),ko($,k),Co($,k),Wn($.content)&&As($.content),R($)===Xs.element){const oe=y($);Wn(oe)&&(La(oe),As(oe))}fs(Y.afterSanitizeShadowDOM,k,null)},La=function(k){const $=[{node:k,shadow:null}];for(;$.length>0;){const te=$.pop();if(te.shadow){As(te.shadow);continue}const oe=te.node,Re=R(oe)===Xs.element,We=_(oe);if(We)for(let Ke=We.length-1;Ke>=0;--Ke)$.push({node:We[Ke],shadow:null});if(Re){const Ke=S?S(oe):null;if(typeof Ke=="string"&&rt(Ke)==="template"){const ft=oe.content;Wn(ft)&&$.push({node:ft,shadow:null})}}if(Re){const Ke=y(oe);Wn(Ke)&&$.push({node:null,shadow:Ke},{node:Ke,shadow:null})}}};return t.sanitize=function(ne){let k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},$=null,te=null,oe=null,Re=null;if(Un=!ne,Un&&(ne="<!-->"),typeof ne!="string"&&!Kn(ne)&&(ne=jA(ne),typeof ne!="string"))throw qi("dirty is not a string, aborting");if(!t.isSupported)return ne;P?(Ae=le,me=je):j(k),(Y.uponSanitizeElement.length>0||Y.uponSanitizeAttribute.length>0)&&(Ae=en(Ae)),Y.uponSanitizeAttribute.length>0&&(me=en(me)),t.removed=[];const We=$e&&typeof ne!="string"&&Kn(ne);if(We){kd(ne);const xs=N(ne);if(typeof xs=="string"){const Ms=rt(xs);if(!Ae[Ms]||lt[Ms])throw pi(ne),qi("root node is forbidden and cannot be sanitized in-place")}if(Js(ne))throw pi(ne),qi("root node is clobbered and cannot be sanitized in-place");try{La(ne)}catch(Ms){throw pi(ne),Ms}}else if(Kn(ne))$=Oc("<!---->"),te=$.ownerDocument.importNode(ne,!0),te.nodeType===Xs.element&&te.nodeName==="BODY"||te.nodeName==="HTML"?$=te:$.appendChild(te),La($);else{if(!Ge&&!q&&!ge&&ne.indexOf("<")===-1)return I&&dt?H(ne):ne;if($=Oc(ne),!$)return Ge?null:dt?F:""}$&&Ie&&st($.firstChild);const Ke=We?ne:$;try{const xs=Da(Ke);for(;oe=xs.nextNode();)ko(oe,Ke),Co(oe,Ke),Wn(oe.content)&&As(oe.content)}catch(xs){throw We&&(pi(ne),zr(t.removed,Ms=>{Ms.element&&$i(Ms.element)})),xs}if(We){let xs=!1;if(zr(t.removed,Ms=>{Ms.element&&(Ms.element===ne&&(xs=!0),$i(Ms.element))}),xs)throw qi("a node selected for removal could not be safely returned; refusing to sanitize in place");return q&&Ar(ne),ne}if(Ge){if(q&&Ar($),ot)for(Re=U.call($.ownerDocument);$.firstChild;)Re.appendChild($.firstChild);else Re=$;return(me.shadowroot||me.shadowrootmode)&&(Re=J.call(n,Re,!0)),Re}let ft=ge?$.outerHTML:$.innerHTML;return ge&&Ae["!doctype"]&&$.ownerDocument&&$.ownerDocument.doctype&&$.ownerDocument.doctype.name&&Es(FA,$.ownerDocument.doctype.name)&&(ft="<!DOCTYPE "+$.ownerDocument.doctype.name+`>
64
+ `+ft),q&&(ft=xo(ft)),I&&dt?H(ft):ft},t.setConfig=function(){let ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};j(ne),P=!0,le=Ae,je=me},t.clearConfig=function(){Qe=null,P=!1,le=null,je=null,I=B,F=""},t.isValidAttribute=function(ne,k,$){Qe||j({});const te=rt(ne),oe=rt(k);return Pa(te,oe,$)},t.addHook=function(ne,k){typeof k=="function"&&Us(Y,ne)&&tl(Y[ne],k)},t.removeHook=function(ne,k){if(Us(Y,ne)){if(k!==void 0){const $=xA(Y[ne],k);return $===-1?void 0:SA(Y[ne],$,1)[0]}return z0(Y[ne])}},t.removeHooks=function(ne){Us(Y,ne)&&(Y[ne]=[])},t.removeAllHooks=function(){Y=Q0()},t}var YA=C1();function E1(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{const s=e[t],n=typeof s;(n==="object"||n==="function")&&!Object.isFrozen(s)&&E1(s)}),e}class ey{constructor(t){t.data===void 0&&(t.data={}),this.data=t.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function N1(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function cr(e,...t){const s=Object.create(null);for(const n in e)s[n]=e[n];return t.forEach(function(n){for(const i in n)s[i]=n[i]}),s}const GA="</span>",ty=e=>!!e.scope,JA=(e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const s=e.split(".");return[`${t}${s.shift()}`,...s.map((n,i)=>`${n}${"_".repeat(i+1)}`)].join(" ")}return`${t}${e}`};class XA{constructor(t,s){this.buffer="",this.classPrefix=s.classPrefix,t.walk(this)}addText(t){this.buffer+=N1(t)}openNode(t){if(!ty(t))return;const s=JA(t.scope,{prefix:this.classPrefix});this.span(s)}closeNode(t){ty(t)&&(this.buffer+=GA)}value(){return this.buffer}span(t){this.buffer+=`<span class="${t}">`}}const sy=(e={})=>{const t={children:[]};return Object.assign(t,e),t};class d_{constructor(){this.rootNode=sy(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(t){this.top.children.push(t)}openNode(t){const s=sy({scope:t});this.add(s),this.stack.push(s)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(t){return this.constructor._walk(t,this.rootNode)}static _walk(t,s){return typeof s=="string"?t.addText(s):s.children&&(t.openNode(s),s.children.forEach(n=>this._walk(t,n)),t.closeNode(s)),t}static _collapse(t){typeof t!="string"&&t.children&&(t.children.every(s=>typeof s=="string")?t.children=[t.children.join("")]:t.children.forEach(s=>{d_._collapse(s)}))}}class ZA extends d_{constructor(t){super(),this.options=t}addText(t){t!==""&&this.add(t)}startScope(t){this.openNode(t)}endScope(){this.closeNode()}__addSublanguage(t,s){const n=t.root;s&&(n.scope=`language:${s}`),this.add(n)}toHTML(){return new XA(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function vc(e){return e?typeof e=="string"?e:e.source:null}function R1(e){return _o("(?=",e,")")}function QA(e){return _o("(?:",e,")*")}function eM(e){return _o("(?:",e,")?")}function _o(...e){return e.map(s=>vc(s)).join("")}function tM(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function gd(...e){return"("+(tM(e).capture?"":"?:")+e.map(n=>vc(n)).join("|")+")"}function j1(e){return new RegExp(e.toString()+"|").exec("").length-1}function sM(e,t){const s=e&&e.exec(t);return s&&s.index===0}const nM=new RegExp(gd(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function f_(e,{joinWith:t}){let s=0;return e.map(n=>{s+=1;const i=s;let r=vc(n),a="";for(;r.length>0;){const l=nM.exec(r);if(!l){a+=r;break}a+=r.substring(0,l.index),r=r.substring(l.index+l[0].length),l[0][0]==="\\"&&l[1]?a+="\\"+String(Number(l[1])+i):(a+=l[0],(l[0]==="("||/^\(\?[<']/.test(l[0]))&&s++)}return a}).map(n=>`(${n})`).join(t)}const iM=/\b\B/,T1="[a-zA-Z]\\w*",p_="[a-zA-Z_]\\w*",A1="\\b\\d+(\\.\\d+)?",M1="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",D1="\\b(0b[01]+)",rM="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",oM=(e={})=>{const t=/^#![ ]*\//;return e.binary&&(e.begin=_o(t,/.*\b/,e.binary,/\b.*/)),cr({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(s,n)=>{s.index!==0&&n.ignoreMatch()}},e)},yc={begin:"\\\\[\\s\\S]",relevance:0},aM={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[yc]},lM={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[yc]},cM={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},_d=function(e,t,s={}){const n=cr({scope:"comment",begin:e,end:t,contains:[]},s);n.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const i=gd("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return n.contains.push({begin:_o(/[ ]+/,"(",i,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),n},uM=_d("//","$"),hM=_d("/\\*","\\*/"),dM=_d("#","$"),fM={scope:"number",begin:A1,relevance:0},pM={scope:"number",begin:M1,relevance:0},mM={scope:"number",begin:D1,relevance:0},gM={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[yc,{begin:/\[/,end:/\]/,relevance:0,contains:[yc]}]},_M={scope:"title",begin:T1,relevance:0},vM={scope:"title",begin:p_,relevance:0},yM={begin:"\\.\\s*"+p_,relevance:0},bM=function(e){return Object.assign(e,{"on:begin":(t,s)=>{s.data._beginMatch=t[1]},"on:end":(t,s)=>{s.data._beginMatch!==t[1]&&s.ignoreMatch()}})};var mu=Object.freeze({__proto__:null,APOS_STRING_MODE:aM,BACKSLASH_ESCAPE:yc,BINARY_NUMBER_MODE:mM,BINARY_NUMBER_RE:D1,COMMENT:_d,C_BLOCK_COMMENT_MODE:hM,C_LINE_COMMENT_MODE:uM,C_NUMBER_MODE:pM,C_NUMBER_RE:M1,END_SAME_AS_BEGIN:bM,HASH_COMMENT_MODE:dM,IDENT_RE:T1,MATCH_NOTHING_RE:iM,METHOD_GUARD:yM,NUMBER_MODE:fM,NUMBER_RE:A1,PHRASAL_WORDS_MODE:cM,QUOTE_STRING_MODE:lM,REGEXP_MODE:gM,RE_STARTERS_RE:rM,SHEBANG:oM,TITLE_MODE:_M,UNDERSCORE_IDENT_RE:p_,UNDERSCORE_TITLE_MODE:vM});function wM(e,t){e.input[e.index-1]==="."&&t.ignoreMatch()}function xM(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function SM(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=wM,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function kM(e,t){Array.isArray(e.illegal)&&(e.illegal=gd(...e.illegal))}function CM(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function EM(e,t){e.relevance===void 0&&(e.relevance=1)}const NM=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const s=Object.assign({},e);Object.keys(e).forEach(n=>{delete e[n]}),e.keywords=s.keywords,e.begin=_o(s.beforeMatch,R1(s.begin)),e.starts={relevance:0,contains:[Object.assign(s,{endsParent:!0})]},e.relevance=0,delete s.beforeMatch},RM=["of","and","for","in","not","or","if","then","parent","list","value"],jM="keyword";function I1(e,t,s=jM){const n=Object.create(null);return typeof e=="string"?i(s,e.split(" ")):Array.isArray(e)?i(s,e):Object.keys(e).forEach(function(r){Object.assign(n,I1(e[r],t,r))}),n;function i(r,a){t&&(a=a.map(l=>l.toLowerCase())),a.forEach(function(l){const c=l.split("|");n[c[0]]=[r,TM(c[0],c[1])]})}}function TM(e,t){return t?Number(t):AM(e)?0:1}function AM(e){return RM.includes(e.toLowerCase())}const ny={},eo=e=>{console.error(e)},iy=(e,...t)=>{console.log(`WARN: ${e}`,...t)},Mo=(e,t)=>{ny[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),ny[`${e}/${t}`]=!0)},Ah=new Error;function P1(e,t,{key:s}){let n=0;const i=e[s],r={},a={};for(let l=1;l<=t.length;l++)a[l+n]=i[l],r[l+n]=!0,n+=j1(t[l-1]);e[s]=a,e[s]._emit=r,e[s]._multi=!0}function MM(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw eo("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Ah;if(typeof e.beginScope!="object"||e.beginScope===null)throw eo("beginScope must be object"),Ah;P1(e,e.begin,{key:"beginScope"}),e.begin=f_(e.begin,{joinWith:""})}}function DM(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw eo("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Ah;if(typeof e.endScope!="object"||e.endScope===null)throw eo("endScope must be object"),Ah;P1(e,e.end,{key:"endScope"}),e.end=f_(e.end,{joinWith:""})}}function IM(e){e.scope&&typeof e.scope=="object"&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function PM(e){IM(e),typeof e.beginScope=="string"&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope=="string"&&(e.endScope={_wrap:e.endScope}),MM(e),DM(e)}function LM(e){function t(a,l){return new RegExp(vc(a),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(l?"g":""))}class s{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(l,c){c.position=this.position++,this.matchIndexes[this.matchAt]=c,this.regexes.push([c,l]),this.matchAt+=j1(l)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const l=this.regexes.map(c=>c[1]);this.matcherRe=t(f_(l,{joinWith:"|"}),!0),this.lastIndex=0}exec(l){this.matcherRe.lastIndex=this.lastIndex;const c=this.matcherRe.exec(l);if(!c)return null;const u=c.findIndex((d,p)=>p>0&&d!==void 0),h=this.matchIndexes[u];return c.splice(0,u),Object.assign(c,h)}}class n{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(l){if(this.multiRegexes[l])return this.multiRegexes[l];const c=new s;return this.rules.slice(l).forEach(([u,h])=>c.addRule(u,h)),c.compile(),this.multiRegexes[l]=c,c}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(l,c){this.rules.push([l,c]),c.type==="begin"&&this.count++}exec(l){const c=this.getMatcher(this.regexIndex);c.lastIndex=this.lastIndex;let u=c.exec(l);if(this.resumingScanAtSamePosition()&&!(u&&u.index===this.lastIndex)){const h=this.getMatcher(0);h.lastIndex=this.lastIndex+1,u=h.exec(l)}return u&&(this.regexIndex+=u.position+1,this.regexIndex===this.count&&this.considerAll()),u}}function i(a){const l=new n;return a.contains.forEach(c=>l.addRule(c.begin,{rule:c,type:"begin"})),a.terminatorEnd&&l.addRule(a.terminatorEnd,{type:"end"}),a.illegal&&l.addRule(a.illegal,{type:"illegal"}),l}function r(a,l){const c=a;if(a.isCompiled)return c;[xM,CM,PM,NM].forEach(h=>h(a,l)),e.compilerExtensions.forEach(h=>h(a,l)),a.__beforeBegin=null,[SM,kM,EM].forEach(h=>h(a,l)),a.isCompiled=!0;let u=null;return typeof a.keywords=="object"&&a.keywords.$pattern&&(a.keywords=Object.assign({},a.keywords),u=a.keywords.$pattern,delete a.keywords.$pattern),u=u||/\w+/,a.keywords&&(a.keywords=I1(a.keywords,e.case_insensitive)),c.keywordPatternRe=t(u,!0),l&&(a.begin||(a.begin=/\B|\b/),c.beginRe=t(c.begin),!a.end&&!a.endsWithParent&&(a.end=/\B|\b/),a.end&&(c.endRe=t(c.end)),c.terminatorEnd=vc(c.end)||"",a.endsWithParent&&l.terminatorEnd&&(c.terminatorEnd+=(a.end?"|":"")+l.terminatorEnd)),a.illegal&&(c.illegalRe=t(a.illegal)),a.contains||(a.contains=[]),a.contains=[].concat(...a.contains.map(function(h){return OM(h==="self"?a:h)})),a.contains.forEach(function(h){r(h,c)}),a.starts&&r(a.starts,l),c.matcher=i(c),c}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=cr(e.classNameAliases||{}),r(e)}function L1(e){return e?e.endsWithParent||L1(e.starts):!1}function OM(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return cr(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:L1(e)?cr(e,{starts:e.starts?cr(e.starts):null}):Object.isFrozen(e)?cr(e):e}var BM="11.12.0";class $M extends Error{constructor(t,s){super(t),this.name="HTMLInjectionError",this.html=s}}const Ef=N1,ry=cr,oy=Symbol("nomatch"),FM=7,O1=function(e){const t=Object.create(null),s=Object.create(null),n=[];let i=!0;const r="Could not find the language '{}', did you forget to load/include a language module?",a={disableAutodetect:!0,name:"Plain text",contains:[]};let l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:ZA};function c(D){return l.noHighlightRe.test(D)}function u(D){let z=D.className+" ";z+=D.parentNode?D.parentNode.className:"";const T=l.languageDetectRe.exec(z);if(T){const O=N(T[1]);return O||(iy(r.replace("{}",T[1])),iy("Falling back to no-highlight mode for this block.",D)),O?T[1]:"no-highlight"}return z.split(/\s+/).find(O=>c(O)||N(O))}function h(D,z,T){let O="",K="";typeof z=="object"?(O=D,T=z.ignoreIllegals,K=z.language):(Mo("10.7.0","highlight(lang, code, ...args) has been deprecated."),Mo("10.7.0",`Please use highlight(code, options) instead.
65
+ https://github.com/highlightjs/highlight.js/issues/2277`),K=D,O=z),T===void 0&&(T=!0);const U={code:O,language:K};M("before:highlight",U);const re=U.result?U.result:d(U.language,U.code,T);return re.code=U.code,M("after:highlight",re),re}function d(D,z,T,O){const K=Object.create(null);function U(q,Z){return q.keywords[Z]}function re(){if(!de.keywords){ae.addText(be);return}let q=0;de.keywordPatternRe.lastIndex=0;let Z=de.keywordPatternRe.exec(be),ge="";for(;Z;){ge+=be.substring(q,Z.index);const P=Ze.case_insensitive?Z[0].toLowerCase():Z[0],le=U(de,P);if(le){const[je,Ie]=le;if(ae.addText(ge),ge="",K[P]=(K[P]||0)+1,K[P]<=FM&&(Be+=Ie),je.startsWith("_"))ge+=Z[0];else{const Ge=Ze.classNameAliases[je]||je;_e(Z[0],Ge)}}else ge+=Z[0];q=de.keywordPatternRe.lastIndex,Z=de.keywordPatternRe.exec(be)}ge+=be.substring(q),ae.addText(ge)}function J(){if(be==="")return;let q=null;if(typeof de.subLanguage=="string"){if(!t[de.subLanguage]){ae.addText(be);return}q=d(de.subLanguage,be,!0,lt[de.subLanguage]),lt[de.subLanguage]=q._top}else q=f(be,de.subLanguage.length?de.subLanguage:null);de.relevance>0&&(Be+=q.relevance),ae.__addSublanguage(q._emitter,q.language)}function Y(){de.subLanguage!=null?J():re(),be=""}function _e(q,Z){q!==""&&(ae.startScope(Z),ae.addText(q),ae.endScope())}function xe(q,Z){let ge=1;const P=Z.length-1;for(;ge<=P;){if(!q._emit[ge]){ge++;continue}const le=Ze.classNameAliases[q[ge]]||q[ge],je=Z[ge];le?_e(je,le):(be=je,re(),be=""),ge++}}function fe(q,Z){return q.scope&&typeof q.scope=="string"&&ae.openNode(Ze.classNameAliases[q.scope]||q.scope),q.beginScope&&(q.beginScope._wrap?(_e(be,Ze.classNameAliases[q.beginScope._wrap]||q.beginScope._wrap),be=""):q.beginScope._multi&&(xe(q.beginScope,Z),be="")),de=Object.create(q,{parent:{value:de}}),de}function et(q,Z,ge){let P=sM(q.endRe,ge);if(P){if(q["on:end"]){const le=new ey(q);q["on:end"](Z,le),le.isMatchIgnored&&(P=!1)}if(P){for(;q.endsParent&&q.parent;)q=q.parent;return q}}if(q.endsWithParent)return et(q.parent,Z,ge)}function Oe(q){return de.matcher.regexIndex===0?(be+=q[0],1):(He=!0,0)}function tt(q){const Z=q[0],ge=q.rule,P=new ey(ge),le=[ge.__beforeBegin,ge["on:begin"]];for(const je of le)if(je&&(je(q,P),P.isMatchIgnored))return Oe(Z);return ge.skip?be+=Z:(ge.excludeBegin&&(be+=Z),Y(),!ge.returnBegin&&!ge.excludeBegin&&(be=Z)),fe(ge,q),ge.returnBegin?0:Z.length}function Pe(q){const Z=q[0],ge=z.substring(q.index),P=et(de,q,ge);if(!P)return oy;const le=de;de.endScope&&de.endScope._wrap?(Y(),_e(Z,de.endScope._wrap)):de.endScope&&de.endScope._multi?(Y(),xe(de.endScope,q)):le.skip?be+=Z:(le.returnEnd||le.excludeEnd||(be+=Z),Y(),le.excludeEnd&&(be=Z));do de.scope&&ae.closeNode(),!de.skip&&!de.subLanguage&&(Be+=de.relevance),de=de.parent;while(de!==P.parent);return P.starts&&fe(P.starts,q),le.returnEnd?0:Z.length}function Le(){const q=[];for(let Z=de;Z!==Ze;Z=Z.parent)Z.scope&&q.unshift(Z.scope);q.forEach(Z=>ae.openNode(Z))}let Ee={};function Ae(q,Z){const ge=Z&&Z[0];if(be+=q,ge==null)return Y(),0;if(Ee.type==="begin"&&Z.type==="end"&&Ee.index===Z.index&&ge===""){if(be+=z.slice(Z.index,Z.index+1),!i){const P=new Error(`0 width match regex (${D})`);throw P.languageName=D,P.badRule=Ee.rule,P}return 1}if(Ee=Z,Z.type==="begin")return tt(Z);if(Z.type==="illegal"&&!T){const P=new Error('Illegal lexeme "'+ge+'" for mode "'+(de.scope||"<unnamed>")+'"');throw P.mode=de,P}else if(Z.type==="end"){const P=Pe(Z);if(P!==oy)return P}if(Z.type==="illegal"&&ge==="")return Z.index===z.length||(be+=`
66
+ `),1;if(Se>1e5&&Se>Z.index*3)throw new Error("potential infinite loop, way more iterations than matches");return be+=ge,ge.length}const Ze=N(D);if(!Ze)throw eo(r.replace("{}",D)),new Error('Unknown language: "'+D+'"');const me=LM(Ze);let Ye="",de=O||me;const lt={},ae=new l.__emitter(l);Le();let be="",Be=0,W=0,Se=0,He=!1;try{if(Ze.__emitTokens)Ze.__emitTokens(z,ae);else{for(de.matcher.considerAll();;){Se++,He?He=!1:de.matcher.considerAll(),de.matcher.lastIndex=W;const q=de.matcher.exec(z);if(!q)break;const Z=z.substring(W,q.index),ge=Ae(Z,q);W=q.index+ge}Ae(z.substring(W))}return ae.finalize(),Ye=ae.toHTML(),{language:D,value:Ye,relevance:Be,illegal:!1,_emitter:ae,_top:de}}catch(q){if(q.message&&q.message.includes("Illegal"))return{language:D,value:Ef(z),illegal:!0,relevance:0,_illegalBy:{message:q.message,index:W,context:z.slice(W-100,W+100),mode:q.mode,resultSoFar:Ye},_emitter:ae};if(i)return{language:D,value:Ef(z),illegal:!1,relevance:0,errorRaised:q,_emitter:ae,_top:de};throw q}}function p(D){const z={value:Ef(D),illegal:!1,relevance:0,_top:a,_emitter:new l.__emitter(l)};return z._emitter.addText(D),z}function f(D,z){z=z||l.languages||Object.keys(t);const T=p(D),O=z.filter(N).filter(F).map(Y=>d(Y,D,!1));O.unshift(T);const K=O.sort((Y,_e)=>{if(Y.relevance!==_e.relevance)return _e.relevance-Y.relevance;if(Y.language&&_e.language){if(N(Y.language).supersetOf===_e.language)return 1;if(N(_e.language).supersetOf===Y.language)return-1}return 0}),[U,re]=K,J=U;return J.secondBest=re,J}function m(D,z,T){const O=z&&s[z]||T;D.classList.add("hljs"),D.classList.add(`language-${O}`)}function b(D){let z=null;const T=u(D);if(c(T))return;if(M("before:highlightElement",{el:D,language:T}),D.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",D);return}if(D.children.length>0&&(l.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(D)),l.throwUnescapedHTML))throw new $M("One of your code blocks includes unescaped HTML.",D.innerHTML);z=D;const O=z.textContent,K=T?h(O,{language:T,ignoreIllegals:!0}):f(O);D.innerHTML=K.value,D.dataset.highlighted="yes",m(D,T,K.language),D.result={language:K.language,re:K.relevance,relevance:K.relevance},K.secondBest&&(D.secondBest={language:K.secondBest.language,relevance:K.secondBest.relevance}),M("after:highlightElement",{el:D,result:K,text:O})}function _(D){l=ry(l,D)}const v=()=>{x(),Mo("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function y(){x(),Mo("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let w=!1;function x(){function D(){x()}if(document.readyState==="loading"){w||window.addEventListener("DOMContentLoaded",D,!1),w=!0;return}document.querySelectorAll(l.cssSelector).forEach(b)}function S(D,z){let T=null;try{T=z(e)}catch(O){if(eo("Language definition for '{}' could not be registered.".replace("{}",D)),i)eo(O);else throw O;T=a}T.name||(T.name=D),t[D]=T,T.rawDefinition=z.bind(null,e),T.aliases&&I(T.aliases,{languageName:D})}function E(D){delete t[D];for(const z of Object.keys(s))s[z]===D&&delete s[z]}function R(){return Object.keys(t)}function N(D){return D=(D||"").toLowerCase(),t[D]||t[s[D]]}function I(D,{languageName:z}){typeof D=="string"&&(D=[D]),D.forEach(T=>{s[T.toLowerCase()]=z})}function F(D){const z=N(D);return z&&!z.disableAutodetect}function B(D){D["before:highlightBlock"]&&!D["before:highlightElement"]&&(D["before:highlightElement"]=z=>{D["before:highlightBlock"](Object.assign({block:z.el},z))}),D["after:highlightBlock"]&&!D["after:highlightElement"]&&(D["after:highlightElement"]=z=>{D["after:highlightBlock"](Object.assign({block:z.el},z))})}function C(D){B(D),n.push(D)}function A(D){const z=n.indexOf(D);z!==-1&&n.splice(z,1)}function M(D,z){const T=D;n.forEach(function(O){O[T]&&O[T](z)})}function H(D){return Mo("10.7.0","highlightBlock will be removed entirely in v12.0"),Mo("10.7.0","Please use highlightElement now."),b(D)}Object.assign(e,{highlight:h,highlightAuto:f,highlightAll:x,highlightElement:b,highlightBlock:H,configure:_,initHighlighting:v,initHighlightingOnLoad:y,registerLanguage:S,unregisterLanguage:E,listLanguages:R,getLanguage:N,registerAliases:I,autoDetection:F,inherit:ry,addPlugin:C,removePlugin:A}),e.debugMode=function(){i=!1},e.safeMode=function(){i=!0},e.versionString=BM,e.regex={concat:_o,lookahead:R1,either:gd,optional:eM,anyNumberOfTimes:QA};for(const D in mu)typeof mu[D]=="object"&&E1(mu[D]);return Object.assign(e,mu),e},Sa=O1({});Sa.newInstance=()=>O1({});var zM=Sa;Sa.HighlightJS=Sa;Sa.default=Sa;const Mh=Qb(zM);function HM(e){const t=e.regex,s={},n={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[s]}]};Object.assign(s,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},n]});const i={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},r=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),a={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},l={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,s,i]};i.contains.push(l);const c={match:/\\"/},u={className:"string",begin:/'/,end:/'/},h={match:/\\'/},d={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,s]},p=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],f=e.SHEBANG({binary:`(${p.join("|")})`,relevance:10}),m={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},b=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],_=["true","false"],v={match:/(\/[a-z._-]+)+/},y=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],w=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],x=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],S=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:b,literal:_,built_in:[...y,...w,"set","shopt",...x,...S]},contains:[f,e.SHEBANG(),m,d,r,a,v,l,c,u,h,s]}}const UM=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},UNICODE_RANGE:{scope:"number",begin:/\b[Uu]\+[0-9A-Fa-f][0-9A-Fa-f?]{0,5}(-[0-9A-Fa-f][0-9A-Fa-f]{0,5})?/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),WM=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],KM=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],qM=[...WM,...KM],VM=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),YM=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),GM=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),JM=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","corner-bottom-left-shape","corner-bottom-right-shape","corner-shape","corner-top-left-shape","corner-top-right-shape","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","unicode-range","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function XM(e){const t=e.regex,s=UM(e),n={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i="and or not only",r=/@-?\w[\w]*(-\w+)*/,a="[a-zA-Z-][a-zA-Z0-9_-]*",l=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[s.BLOCK_COMMENT,n,s.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+a,relevance:0},s.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+YM.join("|")+")"},{begin:":(:)?("+GM.join("|")+")"}]},s.CSS_VARIABLE,{className:"attribute",begin:"\\b("+JM.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[s.BLOCK_COMMENT,s.HEXCOLOR,s.IMPORTANT,s.CSS_NUMBER_MODE,s.UNICODE_RANGE,...l,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...l,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},s.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:r},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:VM.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,s.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+qM.join("|")+")\\b"}]}}function ZM(e){const t=e.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^@@ +-\d+ +\+\d+,\d+ +@@/,/^@@ +-\d+,\d+ +\+\d+ +@@/,/^@@ +-\d+ +\+\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}function QM(e){const r={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:r,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\b0[bB](_?[01])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:r,illegal:/["']/}]}]}}function eD(e){const t=e.regex,s={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},n=e.COMMENT();n.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const i={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},r={className:"literal",begin:/\bon|off|true|false|yes|no\b/},a={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},l={begin:/\[/,end:/\]/,contains:[n,r,i,a,s,"self"],relevance:0},c=/[A-Za-z0-9_-]+/,u=/"(\\"|[^"])*"/,h=/'[^']*'/,d=t.either(c,u,h),p=t.concat(d,"(\\s*\\.\\s*",d,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[n,{className:"section",begin:/\[+/,end:/\]+/},{begin:p,className:"attr",starts:{end:/$/,contains:[n,l,r,i,a,s]}}]}}var Ho="[0-9](_*[0-9])*",gu=`\\.(${Ho})`,_u="[0-9a-fA-F](_*[0-9a-fA-F])*",ay={className:"number",variants:[{begin:`(\\b(${Ho})((${gu})|\\.)?|(${gu}))[eE][+-]?(${Ho})[fFdD]?\\b`},{begin:`\\b(${Ho})((${gu})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${gu})[fFdD]?\\b`},{begin:`\\b(${Ho})[fFdD]\\b`},{begin:`\\b0[xX]((${_u})\\.?|(${_u})?\\.(${_u}))[pP][+-]?(${Ho})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${_u})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function B1(e,t,s){return s===-1?"":e.replace(t,n=>B1(e,t,s-1))}function tD(e){const t=e.regex,s="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",n="(?:(?:\\s*\\[\\s*])+)?",i=s+"<@@@>"+n,a="(?:"+("\\?(?:\\s+(?:extends|super)\\s+"+i+")?")+"|"+i+")",l=B1("(?:\\s*<\\s*"+a+"(?:\\s*,\\s*"+a+")*\\s*>)?",/<@@@>/g,2),p={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},f={className:"meta",begin:"@"+s,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},m={className:"params",begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:p,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,s],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{beginKeywords:"new throw return else yield assert",relevance:0},{begin:[s,t.concat(l,n,/\s+/),s,n,/\s*/,/=(?!=)/],className:{1:"type",3:"variable",6:"operator"}},{begin:[/record/,/\s+/,s],className:{1:"keyword",3:"title.class"},contains:[m,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{begin:[s,t.concat(l,n,/\s+/),s,/\s*(?=\()/],className:{1:"type",3:"title.function"},keywords:p,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:[f,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,ay,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},ay,f]}}const ly="[A-Za-z$_][0-9A-Za-z$_]*",sD=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],nD=["true","false","null","undefined","NaN","Infinity"],$1=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],F1=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],z1=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],iD=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],rD=[].concat(z1,$1,F1);function oD(e){const t=e.regex,s=(T,{after:O})=>{const K="</"+T[0].slice(1);return T.input.indexOf(K,O)!==-1},n=ly,i={begin:"<>",end:"</>"},r=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(T,O)=>{const K=T[0].length+T.index,U=T.input[K];if(U==="<"||U===","){O.ignoreMatch();return}U===">"&&(s(T,{after:K})||O.ignoreMatch());let re;const J=T.input.substring(K);if(re=J.match(/^\s*=/)){O.ignoreMatch();return}if((re=J.match(/^\s+extends\s+/))&&re.index===0){O.ignoreMatch();return}}},l={$pattern:ly,keyword:sD,literal:nD,built_in:rD,"variable.language":iD},c="[0-9](_?[0-9])*",u=`\\.(${c})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${h})((${u})|\\.)?|(${u}))[eE][+-]?(${c})\\b`},{begin:`\\b(${h})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},p={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},f={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"xml"}},m={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"graphql"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,p]},y={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:n+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},w=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,f,m,b,_,{match:/\$\d+/},d];p.contains=w.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(w)});const x=[].concat(y,p.contains),S=x.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(x)}]),E={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:S},R={variants:[{match:[/class/,/\s+/,n,/\s+/,/extends/,/\s+/,t.concat(n,"(",t.concat(/\./,n),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,n],scope:{1:"keyword",3:"title.class"}}]},N={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...$1,...F1]}},I={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},F={variants:[{match:[/function/,/\s+/,n,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[E],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function C(T){return t.concat("(?!",T.join("|"),")")}const A={match:t.concat(/\b/,C([...z1,"super","import","await"].map(T=>`${T}\\s*\\(`)),n,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},M={begin:t.concat(/\./,t.lookahead(t.concat(n,/(?![0-9A-Za-z$_(])/))),end:n,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},H={match:[/get|set/,/\s+/,n,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},E]},D="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",z={match:[/const|var|let/,/\s+/,n,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(D)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[E]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:S,CLASS_REFERENCE:N},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),I,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,f,m,b,_,y,{match:/\$\d+/},d,N,{scope:"attr",match:n+t.lookahead(":"),relevance:0},z,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[y,e.REGEXP_MODE,{className:"function",begin:D,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:S}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:r},{begin:a.begin,"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},F,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[E,e.inherit(e.TITLE_MODE,{begin:n,className:"title.function"})]},{match:/\.\.\./,relevance:0},M,{match:"\\$"+n,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[E]},A,B,R,H,{match:/\$[(.]/}]}}const aD="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",lD={scope:"number",match:aD,relevance:0};function cD(e){const t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},s={match:/[{}[\],:]/,className:"punctuation",relevance:0},n=["true","false","null"],i={scope:"literal",beginKeywords:n.join(" ")};return{name:"JSON",aliases:["jsonc","json5"],keywords:{literal:n},contains:[t,s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,i,lD,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function uD(e){const t=e.regex,s={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},n={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},i={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},r={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},a={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},l=/[A-Za-z][A-Za-z0-9+.-]*/,c={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,l,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},u={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},h={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},d=e.inherit(u,{contains:[]}),p=e.inherit(h,{contains:[]});u.contains.push(p),h.contains.push(d);let f=[s,c];return[u,h,d,p].forEach(v=>{v.contains=v.contains.concat(f)}),f=f.concat(u,h),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:f},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:f}]}]},s,r,n,u,h,{className:"quote",begin:"^>\\s+",contains:f,end:"$"},i,c,a,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function hD(e){const t=e.regex,s=/[\p{XID_Start}_]\p{XID_Continue}*/u,n=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","lazy","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],l={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:n,built_in:["__import__","abs","aiter","all","anext","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozendict","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","sentinel","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},c={className:"meta",begin:/^(>>>|\.\.\.) /},u={className:"subst",begin:/\{/,end:/\}/,keywords:l,illegal:/#/},h={begin:/\{\{/,relevance:0},d={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,c,h,u]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,c,h,u]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,h,u]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,h,u]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},p="[0-9](_?[0-9])*",f=`(\\b(${p}))?\\.(${p})|\\b(${p})\\.`,m=`\\b|${n.join("|")}`,b={className:"number",relevance:0,variants:[{begin:`(\\b(${p})|(${f}))[eE][+-]?(${p})[jJ]?(?=${m})`},{begin:`(${f})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${m})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${m})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${m})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${m})`},{begin:`\\b(${p})[jJ](?=${m})`}]},_={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:l,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},v={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:["self",c,b,d,e.HASH_COMMENT_MODE]}]};return u.contains=[d,b,c],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[c,b,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},d,_,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,s],scope:{1:"keyword",3:"title.function"},contains:[v]},{variants:[{match:[/\bclass/,/\s+/,s,/\s*/,/\(\s*/,s,/\s*\)/]},{match:[/\bclass/,/\s+/,s]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[b,v,d]}]}}function dD(e){const t=e.regex,s=/(r#)?/,n=t.concat(s,e.UNDERSCORE_IDENT_RE),i=t.concat(s,e.IDENT_RE),r={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,i,t.lookahead(/\s*\(/))},a="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",l=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","raw","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],c=["true","false","Some","None","Ok","Err"],u=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],h=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f16","f32","f64","f128","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:h,keyword:l,literal:c,built_in:u},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|"|\\|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{scope:"number",variants:[{begin:"\\b0b([01_]+)"+a},{begin:"\\b0o([0-7_]+)"+a},{begin:"\\b0x([A-Fa-f0-9_]+)"+a},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+a}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:"keyword",3:"keyword"}},{begin:[/fn/,/\s+/,n],scope:{1:"keyword",3:"title.function"}},{scope:"meta",begin:"#!?\\[",end:"\\]",contains:[{scope:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,n],scope:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,n,/\s+/,/in/],scope:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,n],scope:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,n],scope:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:u,type:h}},{scope:"punctuation",begin:"->"},r]}}function fD(e){const t=e.regex,s=e.COMMENT("--","$"),n={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},r=["true","false","unknown"],a=["double precision","large object","with timezone","without timezone"],l=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],c=["add","asc","collation","desc","final","first","last","view"],u=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],h=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],d=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],p=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],f=h,m=[...u,...c].filter(S=>!h.includes(S)),b={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},_={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},v={match:t.concat(/\b/,t.either(...f),/\s*\(/),relevance:0,keywords:{built_in:f}};function y(S){return t.concat(/\b/,t.either(...S.map(E=>E.replace(/\s+/,"\\s+"))),/\b/)}const w={scope:"keyword",match:y(p),relevance:0};function x(S,{exceptions:E,when:R}={}){const N=R;return E=E||[],S.map(I=>I.match(/\|\d+$/)||E.includes(I)?I:N(I)?`${I}|0`:I)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:x(m,{when:S=>S.length<3}),literal:r,type:l,built_in:d},contains:[{scope:"type",match:y(a)},w,v,b,n,i,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,s,_]}}const Dh="[A-Za-z$_][0-9A-Za-z$_]*",H1=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],U1=["true","false","null","undefined","NaN","Infinity"],W1=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],K1=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],q1=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],V1=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],Y1=[].concat(q1,W1,K1);function pD(e){const t=e.regex,s=(T,{after:O})=>{const K="</"+T[0].slice(1);return T.input.indexOf(K,O)!==-1},n=Dh,i={begin:"<>",end:"</>"},r=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(T,O)=>{const K=T[0].length+T.index,U=T.input[K];if(U==="<"||U===","){O.ignoreMatch();return}U===">"&&(s(T,{after:K})||O.ignoreMatch());let re;const J=T.input.substring(K);if(re=J.match(/^\s*=/)){O.ignoreMatch();return}if((re=J.match(/^\s+extends\s+/))&&re.index===0){O.ignoreMatch();return}}},l={$pattern:Dh,keyword:H1,literal:U1,built_in:Y1,"variable.language":V1},c="[0-9](_?[0-9])*",u=`\\.(${c})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${h})((${u})|\\.)?|(${u}))[eE][+-]?(${c})\\b`},{begin:`\\b(${h})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},p={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},f={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"xml"}},m={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"graphql"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,p]},y={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:n+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},w=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,f,m,b,_,{match:/\$\d+/},d];p.contains=w.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(w)});const x=[].concat(y,p.contains),S=x.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(x)}]),E={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:S},R={variants:[{match:[/class/,/\s+/,n,/\s+/,/extends/,/\s+/,t.concat(n,"(",t.concat(/\./,n),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,n],scope:{1:"keyword",3:"title.class"}}]},N={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...W1,...K1]}},I={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},F={variants:[{match:[/function/,/\s+/,n,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[E],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function C(T){return t.concat("(?!",T.join("|"),")")}const A={match:t.concat(/\b/,C([...q1,"super","import","await"].map(T=>`${T}\\s*\\(`)),n,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},M={begin:t.concat(/\./,t.lookahead(t.concat(n,/(?![0-9A-Za-z$_(])/))),end:n,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},H={match:[/get|set/,/\s+/,n,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},E]},D="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",z={match:[/const|var|let/,/\s+/,n,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(D)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[E]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:S,CLASS_REFERENCE:N},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),I,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,f,m,b,_,y,{match:/\$\d+/},d,N,{scope:"attr",match:n+t.lookahead(":"),relevance:0},z,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[y,e.REGEXP_MODE,{className:"function",begin:D,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:S}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:r},{begin:a.begin,"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},F,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[E,e.inherit(e.TITLE_MODE,{begin:n,className:"title.function"})]},{match:/\.\.\./,relevance:0},M,{match:"\\$"+n,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[E]},A,B,R,H,{match:/\$[(.]/}]}}function mD(e){const t=e.regex,s=pD(e),n=Dh,i=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],r={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},a={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:i},contains:[s.exports.CLASS_REFERENCE]},l={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},c=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],u={$pattern:Dh,keyword:H1.concat(c),literal:U1,built_in:Y1.concat(i),"variable.language":V1},h={className:"meta",begin:"@"+n},d=(b,_,v)=>{const y=b.contains.findIndex(w=>w.label===_);if(y===-1)throw new Error("can not find mode to replace");b.contains.splice(y,1,v)};Object.assign(s.keywords,u),s.exports.PARAMS_CONTAINS.push(h);const p=s.contains.find(b=>b.scope==="attr"),f=Object.assign({},p,{match:t.concat(n,t.lookahead(/\s*\?:/))});s.exports.PARAMS_CONTAINS.push([s.exports.CLASS_REFERENCE,p,f]),s.contains=s.contains.concat([h,r,a,f]),d(s,"shebang",e.SHEBANG()),d(s,"use_strict",l);const m=s.contains.find(b=>b.label==="func.def");return m.relevance=0,Object.assign(s,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),s}function gD(e){const t=e.regex,s=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),n=/[\p{L}0-9._:-]+/u,i={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},r={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},a=e.inherit(r,{begin:/\(/,end:/\)/}),l=e.inherit(e.APOS_STRING_MODE,{className:"string"}),c=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),u={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:n,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[r,c,l,a,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[r,a,c,l]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[u],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[u],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:"javascript"}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(s,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:s,relevance:0,starts:u}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(s,/>/))),contains:[{className:"name",begin:s,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function _D(e){const t="true false yes no null",s="[\\w#;/?:@&=+$,.~*'()[\\]]+",n={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},i={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},r={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},a={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,i]},l=e.inherit(a,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),p={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},f={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},m={begin:/\{/,end:/\}/,contains:[f],illegal:"\\n",relevance:0},b={begin:"\\[",end:"\\]",contains:[f],illegal:"\\n",relevance:0},_=[n,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+s},{className:"type",begin:"!<"+s+">"},{className:"type",begin:"!"+s},{className:"type",begin:"!!"+s},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},p,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},m,b,r,a],v=[..._];return v.pop(),v.push(l),f.contains=v,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:_}}for(const[e,t]of Object.entries({bash:HM,css:XM,diff:ZM,go:QM,ini:eD,java:tD,javascript:oD,json:cD,markdown:uD,python:hD,rust:dD,sql:fD,typescript:mD,xml:gD,yaml:_D}))Mh.registerLanguage(e,t);for(const[e,t]of Object.entries({sh:"bash",shell:"bash",zsh:"bash",console:"bash",ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",py:"python",python3:"python",yml:"yaml",rb:"ruby",rs:"rust",golang:"go",html:"xml",vue:"xml",svg:"xml",md:"markdown",toml:"ini",conf:"ini",text:"bash",txt:"bash"}))try{Mh.registerAliases(e,{languageName:t})}catch{}const vD=/(?:#L(\d+)|#(\d+)|:(\d+))$/;function m_(e,t){let s=String(e??"").trim();if(!s||s==="#")return null;if(/^file:\/\//i.test(s))s=decodeURIComponent(s.replace(/^file:\/\/(?:localhost)?/i,""));else if(/^[a-z][a-z0-9+.-]*:/i.test(s))return null;const n=vD.exec(s);let i;if(n&&(i=Number(n[1]??n[2]??n[3]),s=s.slice(0,n.index)),!s)return null;if(!s.startsWith("/")&&!s.startsWith("~/")){const r=s.includes("/")||/\.[A-Za-z0-9]{1,8}$/.test(s);if(!t||!r||!/^[\w.@+/-]+$/.test(s))return null;s=yD(t,s)}return i==null||!Number.isFinite(i)?{path:s}:{path:s,line:i}}function yD(e,t){const s=e.split("/").filter(Boolean);for(const n of t.split("/"))!n||n==="."||(n===".."?s.pop():s.push(n));return`/${s.join("/")}`}function g_(e){const t=e?.base;return typeof t=="string"&&t?t:void 0}const Ht=new fA({html:!1,linkify:!0,breaks:!0,highlight(e,t){const s=e.replace(/\n$/,""),n=(t||"").trim().toLowerCase();if(n&&Mh.getLanguage(n))try{return Mh.highlight(s,{language:n,ignoreIllegals:!0}).value}catch{}return Ht.utils.escapeHtml(s)}}),bD=Ht.renderer.rules.link_open??((e,t,s,n,i)=>i.renderToken(e,t,s)),wD=(e,t,s,n,i)=>{const r=String(e[t].attrGet("href")??""),a=r?m_(r,g_(n)):null;return a?(e[t].attrSet("href","#"),e[t].attrSet("class","md-file-link"),e[t].attrSet("data-file-path",a.path),a.line&&e[t].attrSet("data-file-line",String(a.line)),i.renderToken(e,t,s)):(e[t].attrSet("target","_blank"),e[t].attrSet("rel","noopener noreferrer"),bD(e,t,s,n,i))};Ht.renderer.rules.link_open=wD;Ht.renderer.rules.image=(e,t,s,n,i)=>{const r=String(e[t].attrGet("src")??""),a=r?m_(r,g_(n)):null;if(a){e[t].attrSet("src",Rh(a.path)),e[t].attrSet("loading","lazy"),e[t].attrSet("class","md-img");const l=e[t].content??"",c=i.renderToken(e,t,s);return`<a class="md-img-link" href="${Ht.utils.escapeHtml(Rh(a.path))}" target="_blank" rel="noopener noreferrer" title="${Ht.utils.escapeHtml(l||a.path)}">${c}</a>`}return i.renderToken(e,t,s)};const cy=/(?<![\w"'`/.\-])(?:file:\/\/)?((?:~\/|\/)[\w.@+/-]*[\w.@+-]\.[A-Za-z0-9]{1,8})(?::(\d+))?/g,uy=Ht.renderer.rules.text??((e,t)=>Ht.utils.escapeHtml(e[t].content));Ht.renderer.rules.text=(e,t,s,n,i)=>{const r=e[t].content;if(e[t].inLink||!r)return uy(e,t,s,n,i);const a=g_(n);let l="",c=0;cy.lastIndex=0;for(const u of r.matchAll(cy)){const h=m_(u[0],a),d=u.index??0;if(!h)continue;l+=Ht.utils.escapeHtml(r.slice(c,d));const p=h.line?` data-file-line="${h.line}"`:"",f=`${Ht.utils.escapeHtml(u[1])}${u[2]?`<span class="md-file-line">:${u[2]}</span>`:""}`;l+=`<a class="md-file-link" href="#" data-file-path="${Ht.utils.escapeHtml(h.path)}"${p}>${f}</a>`,c=d+u[0].length}return l?l+Ht.utils.escapeHtml(r.slice(c)):uy(e,t,s,n,i)};Ht.core.ruler.push("local-file-mark",e=>{for(const t of e.tokens){if(t.type!=="inline"||!t.children)continue;let s=0;for(const n of t.children)n.type==="link_open"?s+=1:n.type==="link_close"?s=Math.max(0,s-1):s>0&&(n.inLink=!0)}return!0});const xD=Ht.validateLink.bind(Ht);Ht.validateLink=e=>/^file:/i.test(e)?!0:xD(e);const SD=Ht.renderer.rules.fence??((e,t,s,n,i)=>i.renderToken(e,t,s)),kD=(e,t,s,n,i)=>{const a=(e[t].info||"").trim().split(/\s+/)[0]??"",l=SD(e,t,s,n,i);return`<div class="md-code"><div class="md-code-bar"><span class="md-lang">${Ht.utils.escapeHtml(a||"code")}</span><button class="md-copy" type="button" data-copy>copy</button></div>${l}</div>`};Ht.renderer.rules.fence=kD;function __(e,t){const s=Ht.render(String(e??""),{base:t});return YA.sanitize(s,{ADD_ATTR:["target","rel","data-copy","data-file-path","data-file-line","loading"],ADD_TAGS:["div","span","button","table","thead","tbody","tr","th","td"]})}function G1({text:e,base:t}){const s=g.useMemo(()=>__(e,t),[e,t]),n=g.useRef(null);return g.useEffect(()=>{a_(n.current)},[s]),g.useEffect(()=>{const i=n.current;if(!i)return;const r=a=>{const l=a.target,c=l?.closest("a.md-file-link");if(c){a.preventDefault();const p=c.dataset.filePath??"",f=Number(c.dataset.fileLine??"")||void 0;p&&WS({path:p,...f?{line:f}:{}});return}const u=l?.closest("button[data-copy]");if(!u)return;const d=u.closest(".md-code")?.querySelector("code")?.textContent??"";fd(d).then(p=>{u.textContent=p?"copied":"copy failed",window.setTimeout(()=>{u.textContent="copy"},1200)})};return i.addEventListener("click",r),()=>i.removeEventListener("click",r)},[]),o.jsx("div",{className:"md",ref:n,dangerouslySetInnerHTML:{__html:s}})}const hy={mode:"system",accent:""},J1="agentus.theme",CD="#4aacdf",um=new Set;let ji=ED();function ED(){try{const e=localStorage.getItem(J1);return e?v_(JSON.parse(e)):{...hy}}catch{return{...hy}}}function v_(e){const t=e??{},s=t.mode==="light"||t.mode==="dark"?t.mode:"system",n=typeof t.accent=="string"&&Ih(t.accent)?t.accent:"";return{mode:s,accent:n}}function Ih(e){const t=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.exec(String(e??"").trim());if(!t)return null;let s=t[1];s.length===3&&(s=s.split("").map(i=>i+i).join(""));const n=Number.parseInt(s.slice(0,6),16);return`${n>>16&255}, ${n>>8&255}, ${n&255}`}function X1(){return ji}function ND(e){return um.add(e),()=>um.delete(e)}function Z1(){return g.useSyncExternalStore(ND,X1)}function Q1(e){return e.mode==="dark"||e.mode==="system"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches}function dy(e,t,s){const n=l=>{let c=l.replace("#","");c.length===3&&(c=c.split("").map(h=>h+h).join(""));const u=Number.parseInt(c.slice(0,6),16);return[u>>16&255,u>>8&255,u&255]},i=n(e),r=n(t);return`#${i.map((l,c)=>Math.round(l+(r[c]-l)*s)).map(l=>l.toString(16).padStart(2,"0")).join("")}`}function Ph(e){const[t,s,n]=[1,3,5].map(r=>Number.parseInt(e.slice(r,r+2),16)/255),i=r=>r<=.03928?r/12.92:((r+.055)/1.055)**2.4;return .2126*i(t)+.7152*i(s)+.0722*i(n)}function RD(e,t){const s=Ph(e),n=Ph(t);return(Math.max(s,n)+.05)/(Math.min(s,n)+.05)}const jD=4.8,TD=.66,AD=.18;function MD(e){const[t,s,n]=[1,3,5].map(r=>Number.parseInt(e.slice(r,r+2),16)),i=Math.max(t,s,n);return i===0?0:(i-Math.min(t,s,n))/i}function DD(e,t){const[s,n,i]=[1,3,5].map(w=>Number.parseInt(e.slice(w,w+2),16)/255),r=Math.max(s,n,i),a=Math.min(s,n,i),l=r-a;if(r===0||l===0||l/r>=t)return e;const c=Math.min(1,t+.01),u=r===s?((n-i)/l+(n<i?6:0))/6:r===n?((i-s)/l+2)/6:((s-n)/l+4)/6,h=r*c,d=h*(1-Math.abs(u*6%2-1)),p=r-h,f=Math.floor(u*6)%6,m=[[h,d,0],[d,h,0],[0,h,d],[0,d,h],[d,0,h],[h,0,d]],[b,_,v]=m[f],y=w=>Math.round((w+p)*255).toString(16).padStart(2,"0");return`#${y(b)}${y(_)}${y(v)}`}function ID(e){const[t,s,n]=[1,3,5].map(h=>Number.parseInt(e.slice(h,h+2),16)/255),i=Math.max(t,s,n),r=Math.min(t,s,n),a=(i+r)/2;if(i===r)return[0,0,a];const l=i-r,c=a>.5?l/(2-i-r):l/(i+r);return[i===t?((s-n)/l+(s<n?6:0))/6:i===s?((n-t)/l+2)/6:((t-s)/l+4)/6,c,a]}function PD(e,t,s){const n=i=>{const r=(i+e*12)%12,a=t*Math.min(s,1-s);return Math.round(255*(s-a*Math.max(-1,Math.min(r-3,9-r,1))))};return`#${[n(0),n(8),n(4)].map(i=>i.toString(16).padStart(2,"0")).join("")}`}function LD(e,t){if(!Ih(e))return e;const[s,n,i]=ID(e),r=Ph(t)>.5?-1:1,a=c=>RD(c,t)>=jD,l=MD(e)>=AD;for(let c=0;c<=100;c+=1){const u=i+r*c*.01;if(c>0&&(u<=0||u>=1))break;const h=c===0?e:PD(s,n,u),d=l?DD(h,TD):h;if(a(d))return d;if(a(h))return h}return e}function OD(e){if(typeof document>"u")return e;const t=getComputedStyle(document.documentElement).getPropertyValue("--bg-panel").trim();return/^#[0-9a-f]{6}$/i.test(t)?t:e}function hm(e){if(typeof document>"u")return;const t=document.documentElement,s=e.accent?Ih(e.accent):null;if(t.dataset.theme=e.mode,e.accent&&s){t.style.setProperty("--accent",e.accent),t.style.setProperty("--accent-rgb",s);const n=Q1(e);t.style.setProperty("--accent-text",LD(e.accent,OD(n?"#121a22":"#ffffff"))),t.style.setProperty("--accent-dim",n?dy(e.accent,"#000000",.45):dy(e.accent,"#ffffff",.45)),t.style.setProperty("--on-accent",Ph(e.accent)>.45?"#101820":"#f2f6fa")}else t.style.removeProperty("--accent"),t.style.removeProperty("--accent-text"),t.style.removeProperty("--accent-dim"),t.style.removeProperty("--on-accent"),t.style.setProperty("--accent-rgb",Ih(CD)??"74, 172, 223");t.style.colorScheme=e.mode==="system"?"":e.mode}function ek(e){ji=v_(e);try{localStorage.setItem(J1,JSON.stringify(ji))}catch{}hm(ji);for(const t of um)t()}function tk(e){const t=v_(e);t.mode===ji.mode&&t.accent===ji.accent||ek(t)}async function BD(e){ek(e);try{const t=await fetch("/api/settings",{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({theme:ji})});if(!t.ok)return(await t.json().catch(()=>({}))).error??`save failed (${t.status})`;const s=await t.json();return tk(s.theme),""}catch(t){return String(t?.message??t)}}async function $D(){try{const e=await fetch("/api/settings",{credentials:"same-origin"});if(!e.ok)return;const t=await e.json();tk(t.theme)}catch{}}function FD(){hm(ji),typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>hm(ji))}function sk(){const e=Z1(),t=g.useSyncExternalStore(s=>{const n=typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)"):null;return n?.addEventListener("change",s),()=>n?.removeEventListener("change",s)},()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1);return e.mode==="dark"||e.mode==="system"&&t}const fy={"content-type":"application/json"};function zD(e){if(!e)return"unknown client";const t=/Edg\//.test(e)?"Edge":/OPR\//.test(e)?"Opera":/Firefox\//.test(e)?"Firefox":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)?"Safari":/curl\//.test(e)?"curl":/node/i.test(e)?"script":e.slice(0,24),s=/Mac OS X|Macintosh/.test(e)?"macOS":/iPhone|iPad/.test(e)?"iOS":/Android/.test(e)?"Android":/Windows/.test(e)?"Windows":/Linux/.test(e)?"Linux":"";return s?`${t} · ${s}`:t}function HD(e){const t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t} 秒前`:t<3600?`${Math.round(t/60)} 分钟前`:t<86400?`${Math.round(t/3600)} 小时前`:`${Math.round(t/86400)} 天前`}function Nf(e){const t=Math.max(0,Math.round(e/1e3));return t<60?`${t} 秒`:t<3600?`${Math.round(t/60)} 分钟`:t<86400?`${Math.round(t/3600)} 小时`:`${Math.round(t/86400)} 天`}function py({title:e,children:t,onClose:s}){return o.jsx("div",{className:"modal-bg",onClick:s,children:o.jsxs("div",{className:"modal narrow",onClick:n=>n.stopPropagation(),role:"dialog","aria-label":e,children:[o.jsxs("div",{className:"modal-head",children:[o.jsx("h3",{children:e}),o.jsx("button",{className:"icon-btn",onClick:s,"aria-label":"close",children:o.jsx(En,{size:13})})]}),t]})})}function vu({value:e,onChange:t,label:s,placeholder:n,onEnter:i}){const[r,a]=g.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsx("label",{children:s}),o.jsxs("div",{className:"pw-wrap",children:[o.jsx("input",{type:r?"text":"password",value:e,autoComplete:"off","aria-label":s,placeholder:n,onChange:l=>t(l.target.value),onKeyDown:l=>{l.key==="Enter"&&i&&i()}}),o.jsx("button",{type:"button",className:"pw-eye",onClick:()=>a(l=>!l),title:r?"隐藏":"显示","aria-label":r?"hide password":"show password",children:r?o.jsx(CN,{size:14}):o.jsx(ES,{size:14})})]})]})}function UD({account:e,onChanged:t}){const[s,n]=g.useState([]),[i,r]=g.useState(0),[a,l]=g.useState([]),[c,u]=g.useState({maxFails:5,lockMs:3e4}),[h,d]=g.useState(""),[p,f]=g.useState(""),[m,b]=g.useState(""),[_,v]=g.useState(!1),[y,w]=g.useState(!1),[x,S]=g.useState(""),[E,R]=g.useState(""),[N,I]=g.useState(""),[F,B]=g.useState(""),C=J=>{b(J),window.setTimeout(()=>b(""),4e3)},A=g.useCallback(async()=>{try{const J=await fetch("/api/auth/sessions",{credentials:"same-origin"}),Y=await J.json().catch(()=>({}));J.ok&&(n(Y.sessions??[]),Y.ttlMs&&r(Y.ttlMs))}catch{}},[]),M=g.useCallback(async()=>{try{const J=await fetch("/api/auth/locked-ips",{credentials:"same-origin"}),Y=await J.json().catch(()=>({}));J.ok&&(l(Y.locks??[]),u({maxFails:Y.maxFails??5,lockMs:Y.lockMs??3e4}))}catch{}},[]);g.useEffect(()=>{A(),M()},[A,M]);const H=async(J,Y)=>{d(Y),f("");try{const _e=await fetch("/api/auth/credentials",{method:"POST",credentials:"same-origin",headers:fy,body:JSON.stringify(J)}),xe=await _e.json().catch(()=>({}));if(!_e.ok)throw new Error(xe.error??`HTTP ${_e.status}`);return t({username:xe.username,configuredUsername:xe.username,credentialSource:xe.credentialSource??"saved",usingDefaultPassword:!!xe.usingDefaultPassword}),await A(),!0}catch(_e){return f(String(_e?.message??_e)),!1}finally{d("")}},D=async()=>{f("");const J=E.trim();if(J.length<2){f("用户名至少 2 位");return}if(J===e?.configuredUsername){f("和现在的用户名一样");return}await H({currentPassword:x,username:J},"user")&&(v(!1),S(""),R(""),C("用户名已更新"))},z=async()=>{if(f(""),N!==F){f("两次输入的新密码不一致");return}if(N.length<(e?.minPasswordLen??6)){f(`密码至少 ${e?.minPasswordLen??6} 位`);return}await H({currentPassword:x,newPassword:N},"pass")&&(w(!1),S(""),I(""),B(""),C("密码已更新;其他设备已登出"))},T=async J=>{d(J),f("");try{const Y=await fetch("/api/auth/sessions/revoke",{method:"POST",credentials:"same-origin",headers:fy,body:JSON.stringify({jti:J})});if(!Y.ok)throw new Error((await Y.json().catch(()=>({}))).error??`HTTP ${Y.status}`);await A(),C("已撤销该设备")}catch(Y){f(String(Y?.message??Y))}finally{d("")}},O=async()=>{d("others"),f("");try{const J=await fetch("/api/auth/sessions/revoke-others",{method:"POST",credentials:"same-origin"}),Y=await J.json().catch(()=>({}));if(!J.ok)throw new Error(Y.error??`HTTP ${J.status}`);await A(),C(Y.count?`已登出其他 ${Y.count} 个会话`:"没有其他会话")}catch(J){f(String(J?.message??J))}finally{d("")}},K=async J=>{d(J??"all"),f("");try{const Y=await fetch(`/api/auth/locked-ips${J?`?ip=${encodeURIComponent(J)}`:""}`,{method:"DELETE",credentials:"same-origin"}),_e=await Y.json().catch(()=>({}));if(!Y.ok)throw new Error(_e.error??`HTTP ${Y.status}`);await M(),C(J?`已解除 ${J} 的锁定`:`已解除全部锁定(${_e.count??0})`)}catch(Y){f(String(Y?.message??Y))}finally{d("")}},U=s.filter(J=>!J.current).length,re=s.slice(0,8);return o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"set-card",id:"set-account","data-setgroup":"account",children:[o.jsx("h3",{children:"账号"}),o.jsxs("p",{className:"set-hint",children:[e?.credentialSource==="default"?o.jsxs(o.Fragment,{children:["现在是",o.jsx("b",{children:"内置默认口令"}),"(",o.jsx("code",{children:"admin / 123456"}),"),对公网开放时务必改掉。"]}):e?.credentialSource==="env"?o.jsxs(o.Fragment,{children:["当前口令来自环境变量(",o.jsx("code",{children:"AGENTUS_USERNAME"})," / ",o.jsx("code",{children:"AGENTUS_PASSWORD"}),"); 在这里保存后以本页为准,环境变量只当引导。"]}):o.jsxs(o.Fragment,{children:["当前口令存在数据目录的 ",o.jsx("code",{children:"credentials.json"}),"(0600,scrypt 哈希,明文不落盘)。"]})," ","改密码会让",o.jsx("b",{children:"其他设备"}),"立刻登出(本机自动续上)。"]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"当前账号"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("span",{className:"acct-name",children:e?.configuredUsername??"—"}),o.jsx("button",{className:"set-mini",onClick:()=>{f(""),v(!0)},children:"改用户名"}),o.jsx("button",{className:"set-mini",onClick:()=>{f(""),w(!0)},children:"改密码"}),m?o.jsx("span",{className:"set-toast",children:m}):null,p&&!_&&!y?o.jsx("span",{className:"set-inline-err",children:p}):null]})]})]}),o.jsxs("section",{className:"set-card",id:"set-sessions","data-setgroup":"account",children:[o.jsxs("h3",{children:[o.jsx(EN,{size:14})," 登录会话"]}),o.jsxs("p",{className:"set-hint",children:["每个浏览器/脚本各占一行;会话有效期 ",i?Math.round(i/864e5):7," 天, 可以单独踢掉一台设备。改密码等于把其他设备全部登出。"]}),o.jsxs("div",{className:"acct-list",children:[s.length===0?o.jsx("div",{className:"acct-empty",children:"没有可显示的会话"}):null,re.map(J=>o.jsxs("div",{className:"acct-row",children:[o.jsxs("div",{className:"acct-main",children:[o.jsxs("span",{className:"acct-name",children:[zD(J.ua),J.current?o.jsx("span",{className:"acct-badge",children:"当前"}):null]}),o.jsxs("span",{className:"acct-sub",children:[J.ip||"未知 IP"," · ",J.current?"现在":`活跃 ${HD(J.lastSeen)}`," · 到期还有 ",Nf(J.expiresAt-Date.now())]})]}),J.current?o.jsx("span",{className:"acct-when",children:"这台设备"}):o.jsx("button",{className:"set-mini danger",disabled:h===J.jti,onClick:()=>void T(J.jti),children:h===J.jti?"…":"撤销"})]},J.jti)),s.length>re.length?o.jsxs("div",{className:"acct-empty",children:["还有 ",s.length-re.length," 个会话未列出 —— 点“登出其他设备”可以一次清掉。"]}):null]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{}),o.jsxs("div",{className:"set-pair",children:[o.jsx("button",{className:"set-mini",onClick:()=>void A(),disabled:h==="reload",children:"刷新"}),o.jsx("button",{className:"set-mini danger",onClick:()=>void O(),disabled:h==="others"||U===0,children:h==="others"?"…":U?`登出其他设备(${U})`:"没有其他设备"})]})]})]}),o.jsxs("section",{className:"set-card",id:"set-locks","data-setgroup":"account",children:[o.jsxs("h3",{children:[o.jsx(NN,{size:14})," 登录失败锁定"]}),o.jsxs("p",{className:"set-hint",children:["同一个 IP 连续失败 ",c.maxFails," 次会被锁定 ",Math.round(c.lockMs/1e3)," 秒 (防爆破;把自己锁在门外时可以在这里放行)。清单在内存里,重启即清空。"]}),o.jsxs("div",{className:"acct-list",children:[a.length===0?o.jsx("div",{className:"acct-empty",children:"没有失败的来源,也没有被锁的 IP"}):null,a.map(J=>o.jsxs("div",{className:"acct-row",children:[o.jsxs("div",{className:"acct-main",children:[o.jsxs("span",{className:"acct-name",children:[J.ip,J.locked?o.jsxs("span",{className:"acct-badge danger",children:["已锁定 ",Nf(J.retryAfterMs)]}):null]}),o.jsx("span",{className:"acct-sub",children:J.locked?`剩余 ${Nf(J.retryAfterMs)} 后自动解除`:`已失败 ${J.fails} 次`})]}),o.jsx("button",{className:"set-mini",disabled:h===J.ip,onClick:()=>void K(J.ip),children:h===J.ip?"…":"解锁"})]},J.ip))]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{}),o.jsxs("div",{className:"set-pair",children:[o.jsx("button",{className:"set-mini",onClick:()=>void M(),children:"刷新"}),o.jsx("button",{className:"set-mini danger",disabled:h==="all"||a.length===0,onClick:()=>void K(),children:h==="all"?"…":"全部解锁"})]})]})]}),_?o.jsxs(py,{title:"改用户名",onClose:()=>{v(!1),f("")},children:[o.jsx(vu,{label:"当前密码",value:x,onChange:S,placeholder:"改之前先证明是你"}),o.jsx("label",{children:"新用户名"}),o.jsx("input",{value:E,autoComplete:"off","aria-label":"new username",placeholder:e?.configuredUsername??"",onChange:J=>R(J.target.value),onKeyDown:J=>{J.key==="Enter"&&D()}}),p?o.jsx("div",{className:"err",children:p}):null,o.jsxs("div",{className:"row",children:[o.jsx("button",{className:"cancel",onClick:()=>{v(!1),f("")},children:"取消"}),o.jsx("button",{className:"go",disabled:h==="user"||!x||!E.trim(),onClick:()=>void D(),children:h==="user"?"…":"保存"})]})]}):null,y?o.jsxs(py,{title:"改密码",onClose:()=>{w(!1),f("")},children:[o.jsx(vu,{label:"当前密码",value:x,onChange:S}),o.jsx(vu,{label:"新密码",value:N,onChange:I,placeholder:`至少 ${e?.minPasswordLen??6} 位`}),o.jsx(vu,{label:"确认新密码",value:F,onChange:B,onEnter:()=>void z()}),o.jsx("div",{className:"set-hint",children:"保存后其他设备会被登出;本机自动续上。"}),p?o.jsx("div",{className:"err",children:p}):null,o.jsxs("div",{className:"row",children:[o.jsx("button",{className:"cancel",onClick:()=>{w(!1),f("")},children:"取消"}),o.jsx("button",{className:"go",disabled:h==="pass"||!x||!N||!F,onClick:()=>void z(),children:h==="pass"?"…":"保存"})]})]}):null]})}const WD=["This session has an `update_plan` tool mounted on it (MCP server `agentus_plan`), and the","plan it holds is the one the operator sees — a todo list of your own is invisible there and","dies with your process. For anything with more than one step, publish the steps with","`update_plan` and update it as you go: mark a step completed only once its work is actually","verified, and drop or cancel what you are no longer doing. If `update_plan` is not in your","tool list it is deferred — search for `agentus_plan update_plan` to find it, then call it by","that exact name. On that first call also give a `title`: one short action phrase (≤40 chars)","naming the job — it is the line the operator's completion notification shows, so the phone says","what finished instead of just which conversation ended. A one-step request needs no plan."].join(`
67
+ `),KD=["Carry on with it, and keep it updated with the `update_plan` tool as you go — that list is","the ONLY one the cockpit shows the operator, so a built-in todo/checklist tool of yours will","not be seen there. Mark a step completed once its work is actually verified, and drop or","cancel what you are no longer doing. If you disagree with an item, change it rather than","quietly skipping it."].join(`
68
+ `),qD=["Carry on with it, and keep it updated with your own plan/todo tool as you go: mark a step","completed only once its work is actually verified, and drop or cancel what you are no","longer doing. If you disagree with an item, change it rather than quietly skipping it."].join(`
69
+ `),VD=[{id:"intro",when:"该会话还没有计划(最要紧的一刻:不告诉它,它就会用自己的 todo)",text:WD},{id:"active",when:"已有未完成的计划,且 agent 是 MCP 驱动",text:KD},{id:"native",when:"该后端的计划卡由它自己的原生计划帧喂(不用 update_plan)",text:qD}],YD=[{key:"turnStart",label:"任务开始",hint:"agent 开始跑 → 一条进行中的卡片(Android 16 可提升成实时动态)"},{key:"approval",label:"需要我批准",hint:"权限请求 → 带按钮的通知,锁屏上就能按「仅此次 / 拒绝」"},{key:"completion",label:"跑完 / 出错",hint:"回合结束 → 一条可点开该会话的通知"},{key:"quietWhenWatching",label:"我正在看这个会话时不推",hint:"页面就在眼前时,手机上再响一次是噪音(审批除外——那是我必须做的决定)"}];function GD(e){if(!e)return"—";const t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t} 秒前`:t<3600?`${Math.round(t/60)} 分钟前`:`${Math.round(t/3600)} 小时前`}function JD({sessionId:e}){const[t,s]=g.useState(null),[n,i]=g.useState(""),[r,a]=g.useState(""),[l,c]=g.useState(!1),u=g.useCallback(async()=>{try{const f=await fetch("/api/notify/settings",{credentials:"same-origin"});if(!f.ok)throw new Error(`${f.status} ${f.statusText}`);s(await f.json()),i("")}catch(f){i(`读不到手机通知设置:${f.message}`)}},[]);g.useEffect(()=>{u();const f=window.setInterval(()=>void u(),5e3);return()=>window.clearInterval(f)},[u]);const h=async(f,m,b)=>{c(!0);try{const _=await fetch(f,{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(m)}),v=await _.json().catch(()=>({}));if(!_.ok)throw new Error(v.error??`${_.status}`);return a(b),i(""),await u(),!0}catch(_){return i(`${b}失败:${_.message}`),!1}finally{c(!1)}},d=f=>{if(!t)return;const m={...t.rules,[f]:!t.rules[f]};s({...t,rules:m}),h("/api/notify/settings",{rules:m},"已保存规则")},p=async f=>{try{await navigator.clipboard.writeText(f),a("配对串已复制")}catch{a("复制失败,请手动选中")}};return o.jsxs("section",{className:"set-card",id:"set-notify","data-setgroup":"notify",children:[o.jsx("h3",{children:"手机通知(Android 伴侣)"}),o.jsxs("p",{className:"set-hint",children:["App 只是一个通用渲染器——它显示什么、什么时候响,全由这里的规则决定,",o.jsx("b",{children:"改规则不需要重新装 APK"}),"。手机在外面也能收:App 自己开一条套接字连回这台服务端, 服务端就知道要往哪台手机推。"]}),n?o.jsx("div",{className:"set-err",role:"alert",children:n}):null,r?o.jsx("div",{className:"set-toast",children:r}):null,o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"装 App"}),o.jsxs("div",{children:[o.jsx("a",{className:"set-mini",href:t?.apkUrl??"/agentus-companion.apk",download:!0,children:"agentus-companion.apk"}),t?.apkBytes?o.jsxs("span",{className:"set-hint",children:[" · ",(t.apkBytes/1048576).toFixed(1)," MB"]}):null,o.jsx("span",{className:"set-hint",children:" · 装完在 App 里贴下面这行配对串,或直接填地址 + 用户名密码"})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"配对串"}),o.jsxs("div",{children:[o.jsx("code",{className:"set-input",style:{display:"inline-block",minWidth:"20em"},children:t?.pairUri??"…"}),o.jsx("button",{type:"button",className:"set-mini",disabled:!t,onClick:()=>void p(t?.pairUri??""),children:"复制"}),o.jsx("button",{type:"button",className:"set-mini",disabled:l,onClick:()=>void h("/api/notify/pair-code/rotate",{},"已换新配对码"),children:"换一个"}),o.jsxs("span",{className:"set-hint",children:[" · 当前码 ",o.jsx("b",{children:t?.code??"…"})]})]})]}),YD.map(f=>o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:f.label}),o.jsxs("div",{children:[o.jsx("button",{type:"button",className:`set-mini ${t?.rules[f.key]?"on":""}`,"aria-pressed":!!t?.rules[f.key],disabled:!t||l,onClick:()=>d(f.key),children:t?.rules[f.key]?"开":"关"}),o.jsxs("span",{className:"set-hint",children:[" ",f.hint]})]})]},f.key)),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"现在"}),o.jsx("div",{className:"set-hint",children:t?.presence.call?o.jsxs(o.Fragment,{children:["正在通话 ",o.jsx("b",{children:t.presence.sessionId?.slice(0,8)??""}),"(这个会话的进行中/完成通知不推,其它通知照发但静音 —— 免提的声音会进麦克风)"]}):t?.presence.sessionId?o.jsxs(o.Fragment,{children:["你正看着 ",o.jsx("b",{children:t.presence.sessionId.slice(0,8)}),t.watching?"(这个会话的进行中/完成通知暂时不推)":"(但「我正在看就不推」是关的)"]}):"没有正在查看的会话"})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"操作"}),o.jsxs("div",{children:[o.jsx("button",{type:"button",className:"set-mini",disabled:l,onClick:()=>void h("/api/notify/probe",{},"已发测试通知"),children:"发测试通知到手机"}),o.jsx("button",{type:"button",className:"set-mini",disabled:l||!e,title:e?"把这条会话推成一条手机通知":"先打开一个会话",onClick:()=>void h("/api/notify/push",{sessionId:e,kind:"note",title:"来自驾驶舱的推送"},"已推到手机"),children:"把当前会话推到手机"})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"试上岛"}),o.jsxs("div",{children:[o.jsx("button",{type:"button",className:"set-mini",disabled:l,title:"按 App 自己的顺序(先小米焦点通知,再安卓原生实时动态)",onClick:()=>void h("/api/notify/push",{sessionId:e,kind:"island",title:"上岛测试 · 自动"},"已推自动通道"),children:"自动通道"}),o.jsx("button",{type:"button",className:"set-mini",disabled:l,title:"只走安卓 16 原生实时动态(不需要小米任何授权)",onClick:()=>void h("/api/notify/push",{sessionId:e,kind:"island",path:"aosp",title:"上岛测试 · 原生实时动态"},"已推原生通道"),children:"原生实时动态"}),o.jsx("button",{type:"button",className:"set-mini",disabled:l,title:"只走小米超级岛 / 焦点通知(需要小米平台侧开通)",onClick:()=>void h("/api/notify/push",{sessionId:e,kind:"island",path:"xiaomi",title:"上岛测试 · 小米岛"},"已推小米通道"),children:"小米岛"})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"已配对设备"}),o.jsx("div",{children:(t?.devices.length??0)===0?o.jsx("span",{className:"set-hint",children:"还没有设备。装好 App、贴上面那行配对串,这里就会多一台。"}):o.jsx("table",{style:{borderCollapse:"collapse"},children:o.jsx("tbody",{children:t?.devices.map(f=>o.jsxs("tr",{children:[o.jsxs("td",{style:{padding:"2px 10px 2px 0"},children:[o.jsx("b",{style:{color:f.online?"#4ec9a0":"inherit"},children:f.online?"●":"○"})," ",f.name]}),o.jsxs("td",{className:"set-hint",style:{padding:"2px 10px 2px 0"},children:[f.platform," ",f.sdkInt," · v",f.appVersion," · ",f.online?"在线":`最后在线 ${GD(f.lastSeenAt)}`]}),o.jsxs("td",{className:"set-hint",style:{padding:"2px 10px 2px 0"},title:f.capabilities.join(", "),children:[(f.capabilities??[]).length," 项能力"]}),o.jsx("td",{children:o.jsx("button",{type:"button",className:"set-mini",disabled:l,onClick:()=>void h("/api/notify/devices/revoke",{deviceId:f.deviceId},`已撤销 ${f.name}`),children:"撤销"})})]},f.deviceId))})})})]})]})}const my="agentus.tls.card.seen";function XD(e){const t=Date.parse(e??"");if(Number.isNaN(t))return e??"—";const s=new Date(t);return`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`}const ZD=[{os:"安卓",items:[o.jsx(o.Fragment,{children:"用手机浏览器打开本页 → 点上面的「下载」(存进「下载」目录)。"}),o.jsxs(o.Fragment,{children:["设置 → 安全 → ",o.jsx("b",{children:"加密与凭据"})," → 安装证书 → ",o.jsx("b",{children:"CA 证书"})," → 选刚下载的 ",o.jsx("code",{children:"agentus-ca.crt"}),"。",o.jsx("br",{}),o.jsx("span",{className:"tls-side",children:"小米:安全 → 更多安全设置 → 加密与凭据;华为:安全 → 更多安全设置 → 加密和凭据。"})]}),o.jsx(o.Fragment,{children:"系统会要求输一次锁屏密码,装完会有一条「网络可能会被监控」的提示 —— 那是系统对任何用户证书的标准警告。"}),o.jsxs(o.Fragment,{children:["Chrome 重进本站,地址栏不再报警。",o.jsx("b",{children:"伴侣 App 不用装"}),",它的 APK 里已经带了这张根。"]})]},{os:"iPhone / iPad",items:[o.jsx(o.Fragment,{children:"Safari 打开本页(会先报「不是私密连接」→ 显示详细信息 → 访问此网站)→ 点「下载」→「此网站正尝试下载配置描述文件」→ 允许。"}),o.jsxs(o.Fragment,{children:["设置 → 通用 → VPN 与设备管理 → ",o.jsx("b",{children:"已下载的描述文件"})," → 安装 → 输锁屏密码。"]}),o.jsxs(o.Fragment,{children:[o.jsx("b",{children:"关键一步"}),":设置 → 通用 → ",o.jsx("b",{children:"关于本机"})," → 拉到底 → ",o.jsx("b",{children:"证书信任设置"})," → 把这张根打开。不做这步,上一步等于没装。"]}),o.jsx(o.Fragment,{children:"Safari 重进本站不再报警;分享 → 添加到主屏幕,就能像 App 一样独立打开。"})]},{os:"电脑(Mac)",items:[o.jsxs(o.Fragment,{children:["点「下载」,双击 ",o.jsx("code",{children:"agentus-ca.crt"}),"。"]}),o.jsxs(o.Fragment,{children:["钥匙串访问里把钥匙串选成 ",o.jsx("b",{children:"系统"})," → 添加(要输一次管理员密码)。"]}),o.jsxs(o.Fragment,{children:["在钥匙串里找到它 → 双击 → 展开「信任」→ 使用此证书时:",o.jsx("b",{children:"始终信任"}),"。"]}),o.jsxs(o.Fragment,{children:["或者一条命令:",o.jsx("br",{}),o.jsx("code",{className:"tls-cmd",children:"sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/Downloads/agentus-ca.crt"})]})]}];function QD(){const[e,t]=g.useState(null),[s,n]=g.useState("loading"),[i,r]=g.useState(""),[a,l]=g.useState(()=>localStorage.getItem(my)==="1");g.useEffect(()=>{let u=!0;return fetch("/api/tls",{credentials:"same-origin"}).then(async h=>{if(h.status===404)return u&&n("missing"),null;if(!h.ok)throw new Error(`HTTP ${h.status}`);return h.json()}).then(h=>{!u||!h||(t(h),n("ok"))}).catch(h=>{u&&(r(h.message),n("error"))}),()=>{u=!1}},[]);const c=()=>{localStorage.setItem(my,"1"),l(!0)};return o.jsxs("section",{className:"set-card",id:"set-roots","data-setgroup":"notify",children:[o.jsx("h3",{children:"根证书(自签 HTTPS)"}),o.jsx("p",{className:"set-hint",children:"本站的 HTTPS 由这台服务器的自签根签发。新设备第一次进来会看到「不是私密连接」—— 把这张根装一次,这台设备以后就直接是绿色的锁。"}),!a&&o.jsxs("div",{className:"tls-once",children:[o.jsx("b",{children:"头一回看到这个?"}),"只有全新设备才需要装,装过的设备不用再管。",o.jsx("button",{className:"set-mini",onClick:c,children:"知道了"})]}),o.jsx("p",{className:"set-hint tls-warn",children:"只装你自己的设备。信任一张根,等于把这台设备上「本站到底是不是真的」的判断权交给它 —— 别装到别人的手机或公司的电脑上。"}),s==="loading"&&o.jsx("p",{className:"set-hint",children:"正在读证书…"}),s==="missing"&&o.jsxs("p",{className:"set-hint tls-warn",children:["这台服务器没有配置根证书(",o.jsx("code",{children:"AGENTUS_CA_FILE"})," 未设置,默认位置也没有文件),所以这里没有可下载的东西。"]}),s==="error"&&o.jsxs("p",{className:"set-err",children:["读证书失败:",i]}),s==="ok"&&e&&o.jsxs("div",{className:"tls-cols",children:[o.jsxs("div",{className:"tls-left",children:[o.jsx("a",{className:"tls-dl",href:"/api/tls/ca.crt",children:"下载 agentus-ca.crt"}),o.jsxs("p",{className:"set-hint tls-meta",children:[o.jsx("span",{children:e.selfSigned?"自签根":"根证书"}),o.jsxs("span",{children:[e.bytes," 字节"]}),o.jsxs("span",{children:["到期 ",XD(e.notAfter)]})]}),o.jsx("p",{className:"set-hint tls-meta",children:o.jsxs("span",{title:e.fingerprint256,children:["SHA-256 ",e.fingerprint256.slice(0,23),"…"]})}),o.jsx("p",{className:"set-hint tls-side",children:e.subject})]}),o.jsxs("div",{className:"tls-right",children:[o.jsx("div",{className:"tls-steps-title",children:"安装方法"}),ZD.map(u=>o.jsxs("div",{className:"tls-os",children:[o.jsx("div",{className:"tls-os-name",children:u.os}),o.jsx("ol",{children:u.items.map((h,d)=>o.jsx("li",{children:h},d))})]},u.os))]})]})]})}function gy(){if(typeof navigator>"u")return!1;const e=navigator.userAgent,t=/iPad|iPhone|iPod/.test(e),s=/Macintosh/.test(e)&&navigator.maxTouchPoints>1;return t||s}function e3(){return typeof window>"u"?!1:!!(window.matchMedia?.("(display-mode: standalone)").matches||navigator.standalone)}function yu(){return typeof window>"u"?"no-sw":window.isSecureContext?"serviceWorker"in navigator?!("PushManager"in window)||!("Notification"in window)?gy()?"ios-needs-home":"no-push":gy()&&!e3()?"ios-needs-home":"ok":"no-sw":"insecure"}function t3(e){const t="=".repeat((4-e.length%4)%4),s=(e+t).replace(/-/g,"+").replace(/_/g,"/"),n=atob(s),i=new Uint8Array(new ArrayBuffer(n.length));for(let r=0;r<n.length;r++)i[r]=n.charCodeAt(r);return i}async function il(e,t){const s=await fetch(`/api/notify/webpush${e}`,{credentials:"same-origin",...t}),n=await s.json().catch(()=>({}));if(!s.ok)throw new Error(n.error??`${s.status} ${s.statusText}`);return n}async function Rf(){if(!("serviceWorker"in navigator))return null;try{return await navigator.serviceWorker.getRegistration()??await navigator.serviceWorker.ready}catch{return null}}const bu={availability:yu,async status(){const e=typeof Notification>"u"?"n/a":Notification.permission;let t=!1;const s=await Rf();if(s)try{t=!!await s.pushManager.getSubscription()}catch{}let n=[];try{n=(await il("",{method:"GET"})).subs??[]}catch{}return{availability:yu(),permission:e,subscribed:t,subs:n}},async enable(){if(yu()!=="ok")return{ok:!1,error:nk[yu()]};if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted")return{ok:!1,error:"浏览器没有给通知权限"};const e=await Rf();if(!e)return{ok:!1,error:"service worker 没注册成功 —— 刷新一次再试(必须是 https 或 localhost)"};const{publicKey:t}=await il("",{method:"GET"});let s=await e.pushManager.getSubscription();s||(s=await e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:t3(t)}));const n=s.toJSON();return{ok:!0,subs:(await il("/subscribe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:n.endpoint,keys:n.keys,ua:navigator.userAgent})})).subs}},async disable(){const e=await Rf(),t=e?await e.pushManager.getSubscription():null;if(t){const s=t.endpoint;try{await t.unsubscribe()}catch{}try{return{ok:!0,subs:(await il("/unsubscribe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})).subs}}catch{return{ok:!0}}}return{ok:!0}},async test(){try{const e=await il("/test",{method:"POST"});return{ok:e.ok,sent:e.results.length,error:e.results.find(t=>!t.ok)?.error}}catch(e){return{ok:!1,sent:0,error:e.message}}}},nk={ok:"",insecure:"需要 https 或 localhost 打开才能订阅推送(局域网明文地址不行)。","no-push":"这个浏览器没有 Push API —— 页面通知还能用,但关屏收不到。","ios-needs-home":"iPhone/iPad 上先「分享 → 添加到主屏幕」,再从主屏幕打开这个页面来开启(Safari 标签页不给推送权限)。","no-sw":"service worker 没注册成功,刷新一次再试。"},s3=[{key:"turnStart",label:"任务开始",hint:"「运行中」的一条 —— 桌面正在显示转录时通常是噪音,所以默认关"},{key:"approval",label:"需要我批准",hint:"agent 卡在权限请求上 → 通知不点不走,点一下回到那个会话"},{key:"completion",label:"跑完 / 出错",hint:"回合结束 → 一条通知;同一个会话只留最新一条,不堆一屏"}],n3=[["default","系统默认","交给操作系统响它自己的通知音(可能被系统的通知设置静音)"],["chime","自带提示音","驾驶舱自己响一声(在浏览器里合成,不加载音频文件),音量可调"],["silent","静音","只弹出来,不响"]];function i3(){const e=NR(),[t,s]=g.useState(null),[n,i]=g.useState(""),[r,a]=g.useState(""),[l,c]=g.useState(!1),[u,h]=g.useState(null),[d,p]=g.useState(""),f=g.useCallback(async()=>{try{const N=await fetch("/api/notify/settings",{credentials:"same-origin"});if(!N.ok)throw new Error(`${N.status} ${N.statusText}`);const I=await N.json();I.rules?.web&&s(I.rules.web),i("")}catch(N){i(`读不到网页通知规则:${N.message}`)}},[]),m=g.useCallback(async()=>{h(await bu.status())},[]);g.useEffect(()=>{f(),m()},[f,m]);const b=async(N,I)=>{s(N),c(!0);try{const F=await fetch("/api/notify/settings",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({rules:{web:N}})}),B=await F.json().catch(()=>({}));if(!F.ok)throw new Error(B.error??`${F.status}`);B.rules?.web&&s(B.rules.web),a(I),i("")}catch(F){i(`${I}失败:${F.message}`),await f()}finally{c(!1)}},_=async()=>{const N=await xi.requestPermission();N==="granted"?(xi.setPrefs({on:!0}),a("这台设备已开启网页通知"),i("")):N==="denied"&&i("浏览器拒绝了通知权限 —— 需要在浏览器的网站设置里手动允许")},v=N=>{ca(),Jp(e.prefs.volume,N)},y=async()=>{const N=await xi.test();a(N?"已发一条测试通知":"没弹出来 —— 看下面的权限/地址提示")},w=async()=>{c(!0),p("");try{const N=await bu.enable();p(N.ok?"这台设备已开通推送 —— 锁屏上应该能收到「跑完」了":`没开成:${N.error}`),await m()}finally{c(!1)}},x=async()=>{c(!0);try{await bu.disable(),p("这台设备已退订推送"),await m()}finally{c(!1)}},S=async()=>{c(!0);try{const N=await bu.test();p(N.ok?`已推到 ${N.sent} 台设备 —— 现在把屏幕锁上等一下`:`推送失败:${N.error??"推送服务拒绝了"}`),await m()}finally{c(!1)}},E=()=>e.availability==="no-api"?o.jsx("span",{className:"set-hint",children:"这个浏览器没有通知能力。手机 App 里的页面就是这种情况(WebView 不提供通知 API), 那台手机由 App 自己的通道负责 —— 这里不影响它。"}):e.availability==="insecure"?o.jsxs("span",{className:"set-hint",children:["需要 ",o.jsx("b",{children:"https"})," 或 ",o.jsx("b",{children:"localhost"})," 打开驾驶舱才能弹系统通知:局域网明文地址 (",o.jsx("code",{children:"http://192.168.x.x:8788"}),")浏览器不给这个能力。隧道入口或 127.0.0.1 都可以。"]}):e.permission==="granted"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:`set-mini ${e.prefs.on?"on":""}`,"aria-pressed":e.prefs.on,onClick:()=>{ca(),xi.setPrefs({on:!e.prefs.on})},children:e.prefs.on?"开":"关"}),o.jsx("span",{className:"set-hint",children:" · 已授权。只有标签页不在前台(切走了/最小化了)时才弹,你盯着这个页面时不打扰。"})]}):e.permission==="denied"?o.jsx("span",{className:"set-hint",children:"通知被浏览器拦下了 —— 去浏览器的「网站设置 → 通知」里允许本网站,再刷新这个页面。"}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"set-mini",disabled:l,onClick:()=>void _(),children:"开启浏览器通知"}),o.jsx("span",{className:"set-hint",children:" · 会弹出浏览器的授权框(必须由点击触发,浏览器不允许自动要权限)。"})]}),R=e.last;return o.jsxs("section",{className:"set-card",id:"set-webnotify","data-setgroup":"notify",children:[o.jsx("h3",{children:"网页通知(这台设备)"}),o.jsxs("p",{className:"set-hint",children:["用浏览器打开驾驶舱时,由浏览器弹系统通知:切到别的标签页/别的应用后,「跑完」和「要我确认」 会落到系统的通知中心,点一下就回到那条会话。什么时候该弹由服务端判定(和手机同一套文案、同一份事件),",o.jsx("b",{children:"这台设备是否显示、响不响是这台设备自己的事"}),"(跟听写引擎一样,不跨设备同步)。"]}),n?o.jsx("div",{className:"set-err",role:"alert",children:n}):null,r?o.jsx("div",{className:"set-toast",children:r}):null,d?o.jsx("div",{className:"set-toast",children:d}):null,o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"这台设备"}),o.jsx("div",{children:E()})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"锁屏 / 切后台"}),o.jsx("div",{children:u?.availability!=="ok"?o.jsx("span",{className:"set-hint",children:nk[u?.availability??"no-sw"]}):u.subscribed?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"set-mini on","aria-pressed":!0,disabled:l,onClick:()=>void x(),children:"已开通"}),o.jsx("span",{className:"set-hint",children:" · 点一下退订。页面关掉、手机锁屏时,「跑完」和「要我确认」会走系统的推送服务到这里。"})]}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"set-mini",disabled:l,onClick:()=>void w(),children:"开启推送"}),o.jsx("span",{className:"set-hint",children:" · 上面那个开关只管「页面还开着」,屏幕一锁就失效;推送才是关屏也能收的那条。"})]})})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"推送测试"}),o.jsxs("div",{children:[o.jsx("button",{type:"button",className:"set-mini",disabled:l||!u?.subs.length,onClick:()=>void S(),children:"往所有设备推一条"}),o.jsx("span",{className:"set-hint",children:u?.subs.length?` · 服务端已记下 ${u.subs.length} 台设备的订阅${u.subs.some(N=>N.fails)?"(有设备最近推失败,见下)":""}`:" · 还没有设备订阅推送"})]})]}),u?.subs.length?o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"已订阅"}),o.jsx("div",{className:"set-hint",style:{display:"grid",gap:"3px"},children:u.subs.map(N=>o.jsxs("span",{children:[N.host," · …",N.tail," · ",N.lastOkAt?`上次送达 ${new Date(N.lastOkAt).toLocaleString()}`:"还没送达过",N.fails?` · 失败 ${N.fails} 次${N.lastError?`(${N.lastError.slice(0,60)})`:""}`:""]},`${N.host}-${N.tail}`))})]}):null,o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"铃声"}),o.jsxs("div",{children:[o.jsx("div",{className:"set-seg",role:"group","aria-label":"notification sound",children:n3.map(([N,I,F])=>o.jsx("button",{type:"button",className:e.prefs.sound===N?"on":"","aria-pressed":e.prefs.sound===N,title:F,onClick:()=>{ca(),xi.setPrefs({sound:N})},children:I},N))}),e.prefs.sound==="chime"?o.jsxs("label",{className:"settings-range",style:{display:"inline-flex",marginLeft:"10px"},children:[o.jsx("input",{type:"range",min:0,max:1,step:.05,value:e.prefs.volume,"aria-label":"volume",onChange:N=>xi.setPrefs({volume:Number(N.target.value)})}),o.jsxs("span",{className:"set-hint",children:[Math.round(e.prefs.volume*100),"%"]})]}):null,o.jsx("button",{type:"button",className:"set-mini",style:{marginLeft:"10px"},onClick:()=>v("agent_done"),children:"试听·完成"}),o.jsx("button",{type:"button",className:"set-mini",style:{marginLeft:"6px"},onClick:()=>v("approval"),children:"试听·等你处理"}),o.jsxs("div",{className:"set-hint",style:{marginTop:"4px"},children:["听到的就是真实通知的两段:",o.jsx("b",{children:"完成"}),"是平稳的两声「叮—咚」;",o.jsx("b",{children:"等你处理"}),"(审批/出错)更急、音往上走。 点这两个按钮能听到,通知就能听到 —— 顺带这也是让浏览器解锁音频的那一次点击。 通话中不会响(麦克风开着,声音会被 agent 听见)。"]})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"测试"}),o.jsxs("div",{children:[o.jsx("button",{type:"button",className:"set-mini",disabled:l,onClick:()=>void y(),children:"发一条测试通知"}),o.jsx("span",{className:"set-hint",children:R?` · 最近一次:${R.title}(${R.drawn?"已交给系统":"被系统拒了"},${Math.max(0,Math.round((Date.now()-R.at)/1e3))} 秒前)`:" · 只弹到这台设备,不打扰手机"})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"要弹哪些"}),o.jsxs("div",{children:[o.jsx("button",{type:"button",className:`set-mini ${t?.enabled?"on":""}`,"aria-pressed":!!t?.enabled,disabled:!t||l,onClick:()=>t&&void b({...t,enabled:!t.enabled},"已保存网页通知总开关"),children:t?.enabled?"总开关:开":"总开关:关"}),o.jsx("span",{className:"set-hint",children:" · 关掉就是服务端不再往任何浏览器推(手机渠道不受影响)"})]})]}),s3.map(N=>o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:N.label}),o.jsxs("div",{children:[o.jsx("button",{type:"button",className:`set-mini ${t?.[N.key]?"on":""}`,"aria-pressed":!!t?.[N.key],disabled:!t||l,onClick:()=>t&&void b({...t,[N.key]:!t[N.key]},"已保存网页通知规则"),children:t?.[N.key]?"开":"关"}),o.jsxs("span",{className:"set-hint",children:[" ",N.hint]})]})]},N.key))]})}const _y={id:"",label:"",kind:"hermes",cmd:"hermes",args:"acp",env:"",home:"",profile:"",cwd:"",notes:"",defaultMode:"",nativePlanSource:"none"};function ik(e){return Array.isArray(e)?e.join(" "):e??""}function r3(e,t){return(t??[]).map(s=>`${s}=`).join(`
70
+ `)}function jf(e){return{id:e.id,label:e.label,kind:e.kind,cmd:e.cmd,args:ik(e.args),env:r3(void 0,e.env),home:e.home??"",profile:e.profile??"",cwd:e.cwd??"",defaultMode:e.defaultMode??"",notes:e.notes??"",nativePlanSource:e.nativePlanSource??"none"}}function o3(e,t){const s=e.handshake?.modes?.names?.[t];return s&&s!==t?`${s}(${t})`:t}function Uu({tone:e,children:t}){return o.jsx("span",{className:`be-badge be-${e}`,children:t})}const dm={online:"在线",offline:"不可用",missing:"找不到命令",unchecked:"未检测"},a3={startup:"启动检查",manual:"手动探测",session:"真实会话"};function fm(e){return e==="online"?"ok":e==="offline"?"danger":e==="missing"?"warn":"dim"}function pm(e){if(!e)return"—";const t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<45?"刚刚":t<3600?`${Math.round(t/60)} 分钟前`:t<86400?`${Math.round(t/3600)} 小时前`:`${Math.round(t/86400)} 天前`}function l3({row:e}){const t=e.health;if(!t||!t.at)return null;const s=t.kind?a3[t.kind]??t.kind:"未知深度";return o.jsxs("div",{className:"be-health",children:[o.jsx(Uu,{tone:fm(t.status),children:dm[t.status]??t.status}),o.jsxs("span",{className:"be-dim",children:["上次检查 ",pm(t.at)," · ",s,t.latencyMs!==null&&t.latencyMs!==void 0?` · ${t.latencyMs}ms`:"",t.lastSuccessAt?` · 上次成功 ${pm(t.lastSuccessAt)}`:""]}),t.errorCode?o.jsx("code",{className:"be-code",children:t.errorCode}):null,t.errorCode&&t.guidance?o.jsx("div",{className:"be-guidance",children:t.guidance}):null]})}function c3({row:e}){const t=e.handshake;if(!t)return null;const s=[t.modes?`模式 ${t.modes.available.length}`:null,t.configOptions?.length?`选项 ${t.configOptions.length}`:null,t.models?`模型 ${t.models.available.length}`:null,t.commands?.length?`命令 ${t.commands.length}`:null,t.loadSession===null||t.loadSession===void 0?null:`session/load ${t.loadSession?"有":"无"}`].filter(Boolean);return o.jsxs("div",{className:"be-handshake",children:["握手(上次真实会话):",o.jsx("code",{children:s.join(" · ")||"无可用信息"}),o.jsxs("span",{className:"be-dim",children:[" · ",pm(t.at)]})]})}function u3(){const[e,t]=g.useState([]),[s,n]=g.useState(null),[i,r]=g.useState(null),[a,l]=g.useState(""),[c,u]=g.useState(""),[h,d]=g.useState(""),[p,f]=g.useState(null),m=g.useCallback(async()=>{try{t(await ee.loadBackends()),d("")}catch(C){d(`后端列表拉取失败:${String(C.message??C)}`)}},[]);g.useEffect(()=>{m()},[m]);const b=g.useRef(null),_=g.useRef(null),v=(C,A,M="")=>{if(b.current=document.activeElement??null,d(""),u(M),A){r(null),n(A);return}if(C){r(C.id),n(jf(C));return}r(null),n({..._y})},y=()=>{n(null),r(null);const C=b.current;b.current=null,C&&document.body.contains(C)&&C.focus()},w=s!==null;g.useEffect(()=>{if(!w)return;const C=document.querySelector("[data-set-scroll]"),A=C?C.style.overflow:"";C&&(C.style.overflow="hidden");const M=D=>{D.key==="Escape"&&y()};window.addEventListener("keydown",M);const H=window.setTimeout(()=>{_.current?.querySelector("input:not([disabled]), select, textarea")?.focus()},0);return()=>{window.removeEventListener("keydown",M),window.clearTimeout(H),C&&(C.style.overflow=A)}},[w]);const x=(C,A)=>n(M=>({...M??_y,[C]:A})),E=(i?e.find(C=>C.id===i)??null:null)?.handshake?.modes??null,R=(E?.available??[]).map(C=>({id:C,name:E?.names?.[C]??C})),N=!!s?.defaultMode&&!R.some(C=>C.id===s?.defaultMode),I=async()=>{if(s){l("save"),d(""),u("");try{if(i){const C=e.find(H=>H.id===i),A=C?jf(C):null,M={};if(A)for(const[H,D]of Object.entries(s))H!=="id"&&String(A[H]??"")!==String(D??"")&&(M[H]=D);else Object.assign(M,s),delete M.id;if(!Object.keys(M).length){u("没有改动"),n(null),r(null);return}await ee.updateBackend(i,M)}else await ee.createBackend(s);u(i?"已保存":"已创建"),n(null),r(null),await m()}catch(C){d(String(C.message??C))}finally{l("")}}},F=async C=>{if(window.confirm(`删除后端 ${C.id}?(被会话引用的后端不能删)`)){l(`del:${C.id}`),d(""),u("");try{await ee.deleteBackend(C.id),u(`已删除 ${C.id}`),i===C.id&&(r(null),n(null)),await m()}catch(A){d(String(A.message??A))}finally{l("")}}},B=async C=>{l(`probe:${C.id}`),d(""),u("");try{const A=await ee.inspectBackend(C.id);f({id:C.id,data:A}),await m()}catch(A){d(String(A.message??A)),await m()}finally{l("")}};return o.jsxs("section",{className:"set-card",id:"set-backends","data-setgroup":"agent",children:[o.jsx("h3",{children:"后端"}),o.jsxs("p",{className:"set-hint",children:["一条后端 = ",o.jsx("b",{children:"用哪个命令"})," · ",o.jsx("b",{children:"哪套环境变量"})," · ",o.jsx("b",{children:"哪个主目录"})," · ",o.jsx("b",{children:"哪套配置"}),"。 新建会话时按行选择,所以每个槽位可以各自隔离。"]}),o.jsxs("div",{className:"be-list",children:[e.map(C=>o.jsxs("div",{className:"be-row",children:[o.jsxs("div",{className:"be-row-main",children:[o.jsxs("div",{className:"be-row-title",children:[o.jsx("b",{children:C.label})," ",o.jsx("code",{children:C.id}),C.builtin?o.jsx(Uu,{tone:"dim",children:"内置"}):null,C.health?.at?o.jsx(Uu,{tone:fm(C.health.status),children:dm[C.health.status]??C.health.status}):null]}),o.jsxs("div",{className:"be-row-sub",children:[o.jsxs("code",{children:[C.cmd," ",(C.args??[]).join(" ")]}),C.profile?o.jsxs(o.Fragment,{children:[" · profile ",o.jsx("code",{children:C.profile})]}):null,C.home?o.jsxs(o.Fragment,{children:[" · home ",o.jsx("code",{children:C.home})]}):null,(C.env??[]).length?o.jsxs(o.Fragment,{children:[" · env ",o.jsx("code",{children:(C.env??[]).join(", ")})]}):null," ",C.nativePlanSource==="acp"?o.jsxs(o.Fragment,{children:[" · 计划 ",o.jsx("code",{children:"原生帧"})]}):o.jsxs(o.Fragment,{children:[" · 计划 ",o.jsx("code",{children:"agentus-plan 工具"})]}),C.defaultMode?o.jsxs(o.Fragment,{children:[" · 默认权限 ",o.jsx("code",{children:o3(C,C.defaultMode)})]}):null]}),C.notes?o.jsx("div",{className:"be-row-note",children:C.notes}):null,(C.warnings??[]).map((A,M)=>o.jsx("div",{className:"hint-warn",children:A},M)),o.jsx(l3,{row:C}),o.jsx(c3,{row:C})]}),o.jsxs("div",{className:"be-row-actions",children:[o.jsx("button",{className:"set-mini",onClick:()=>void B(C),disabled:a===`probe:${C.id}`,children:a===`probe:${C.id}`?"探测中…":"探测"}),o.jsx("button",{className:"set-mini",onClick:()=>v(C),children:"编辑"}),o.jsx("button",{className:"set-mini",onClick:()=>v(null,{...jf(C),id:`${C.id}-copy`,label:`${C.label} copy`},"复制为新行:确认 id 后保存"),children:"复制"}),o.jsx("button",{className:"set-mini",onClick:()=>void F(C),disabled:a===`del:${C.id}`,children:"删除"})]})]},C.id)),e.length?null:o.jsx("p",{className:"set-hint",children:"还没有后端行。"})]}),p?o.jsxs("div",{className:"be-inspect",children:[o.jsxs("div",{className:"be-inspect-head",children:[o.jsxs("b",{children:["探测结果:",p.id]}),o.jsx("button",{className:"set-mini",onClick:()=>f(null),children:"收起"})]}),o.jsxs("ul",{children:[o.jsxs("li",{children:["判定: ",o.jsx(Uu,{tone:fm(p.data.status),children:dm[p.data.status]??p.data.status}),p.data.errorCode?o.jsxs(o.Fragment,{children:[" ",o.jsx("code",{className:"be-code",children:p.data.errorCode})]}):null,o.jsxs("span",{className:"be-dim",children:[" · 用时 ",p.data.latencyMs,"ms"]}),p.data.guidance?o.jsx("div",{className:"be-guidance",children:p.data.guidance}):null]}),o.jsxs("li",{children:["命令: ",o.jsx("code",{children:p.data.cmd}),p.data.resolved?o.jsxs(o.Fragment,{children:[" → ",o.jsx("code",{children:p.data.resolved})]}):o.jsxs(o.Fragment,{children:[" ",o.jsx("span",{className:"be-danger",children:"找不到"})]})]}),o.jsxs("li",{children:["argv: ",o.jsx("code",{children:(p.data.args??[]).join(" ")}),p.data.profile?o.jsxs(o.Fragment,{children:["(profile ",o.jsx("code",{children:p.data.profile}),")"]}):null]}),o.jsxs("li",{children:["版本: ",o.jsx("code",{children:p.data.version??"—"})]}),o.jsxs("li",{children:["代码树(它真正加载的那份): ",o.jsx("code",{children:p.data.installDir??"—"})]}),o.jsxs("li",{children:["home: ",o.jsx("code",{children:p.data.home??"—"}),p.data.homeExists?o.jsxs(o.Fragment,{children:["(存在,",p.data.homeEntries," 项",p.data.stateDb?`,state.db ${(p.data.stateDb.bytes/1024).toFixed(0)}KB`:",无 state.db",")"]}):o.jsxs(o.Fragment,{children:["(",o.jsx("span",{className:"be-danger",children:"不存在"}),",首次启动会创建)"]})]}),p.data.acpCheck?o.jsxs("li",{children:["acp --check: ",p.data.acpCheck.ok?"OK":o.jsx("span",{className:"be-danger",children:"失败"})," ",o.jsx("span",{className:"be-dim",children:"(过了也不代表能起会话:检查在适配器的 server 模块导入之前就返回了)"}),o.jsx("div",{className:"be-inspect-out",children:p.data.acpCheck.output})]}):null,p.data.error?o.jsx("li",{className:"be-danger",children:p.data.error}):null,(p.data.warnings??[]).map((C,A)=>o.jsx("li",{className:"hint-warn",children:C},A))]})]}):null,o.jsxs("div",{className:"row",children:[o.jsx("button",{className:"set-mini",onClick:()=>v(null),children:"新建后端"}),o.jsx("button",{className:"set-mini",onClick:()=>void m(),children:"刷新"})]}),c?o.jsx("span",{className:"set-toast",children:c}):null,!s&&h?o.jsx("div",{className:"set-err",role:"alert",children:h}):null,s?cc.createPortal(o.jsx("div",{className:"be-backdrop",onMouseDown:C=>{C.target===C.currentTarget&&y()},children:o.jsxs("div",{className:"be-modal",role:"dialog","aria-modal":"true",ref:_,"aria-label":i?`编辑后端 ${s.label||i}`:"新建后端",children:[o.jsxs("div",{className:"be-modal-head",children:[o.jsx("b",{children:i?"编辑后端":"新建后端"}),i?o.jsx("code",{children:i}):null,o.jsx("button",{className:"set-mini be-modal-x",onClick:y,"aria-label":"关闭",children:"✕"})]}),o.jsxs("div",{className:"be-modal-body",children:[o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"id"}),o.jsx("input",{className:"set-input",value:s.id??"",spellCheck:!1,disabled:!!i,placeholder:"hermes-fork",onChange:C=>x("id",C.target.value.trim())})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"名称"}),o.jsx("input",{className:"set-input",value:s.label??"",onChange:C=>x("label",C.target.value),placeholder:"Hermes(源码树)"})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"类型"}),o.jsxs("select",{className:"set-select",value:s.kind??"hermes",onChange:C=>x("kind",C.target.value),children:[o.jsx("option",{value:"hermes",children:"hermes(ACP + home 隔离)"}),o.jsx("option",{value:"qoder",children:"qoder"}),o.jsx("option",{value:"mock",children:"mock(QA)"})]})]}),(s.kind??"hermes")==="hermes"?o.jsxs("p",{className:"set-hint be-kind-help",children:["hermes 行的四件事:",o.jsx("b",{children:"命令"})," 填 ",o.jsx("code",{children:"hermes"}),",或指向某份源码树的启动器 (如 ",o.jsx("code",{children:"~/.local/bin/hermes-dev"}),");",o.jsx("b",{children:"HERMES_HOME"})," 是这一行读写的",o.jsx("code",{children:"~/.hermes"})," 目录 —— ",o.jsxs("b",{children:["留空就用默认的 ",o.jsx("code",{children:"~/.hermes"})]}),"(也就是你现在这个 hermes 的数据目录:共用它会共用会话列表、记忆和 cron); 想让某个槽位用干净的数据,就填一个别的目录;",o.jsx("b",{children:"profile"})," 以 ",o.jsx("code",{children:"-p"})," 传给命令;",o.jsx("b",{children:"额外环境"})," 里放 ",o.jsx("code",{children:"PYTHONPATH"})," 就能让这一行跑那份源码树。"]}):null,o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"计划来源"}),o.jsxs("select",{className:"set-select",value:s.nativePlanSource??"none",onChange:C=>x("nativePlanSource",C.target.value),children:[o.jsx("option",{value:"none",children:"注入 agentus-plan 计划工具(推荐)"}),o.jsx("option",{value:"acp",children:"agent 自己发计划帧(原生 ACP)"})]})]}),o.jsxs("p",{className:"set-hint be-kind-help",children:["计划卡的数据由谁写:",o.jsx("b",{children:"计划工具"})," 会在握手时给 agent 注入 ",o.jsx("code",{children:"agentus-plan"}),"(",o.jsx("code",{children:"update_plan"}),"/",o.jsx("code",{children:"read_plan"}),"),工具写的计划存在座舱里、重启不丢, 新 agent 不用改一行代码就有计划卡 —— 所有后端默认走这条。",o.jsx("b",{children:"原生"})," 是逃生口:只有 在这个 agent 自己发的 ACP ",o.jsx("code",{children:"plan"})," 帧比座舱对象更可信时才选它,选了之后 该会话的帧才会被渲染(否则帧一律丢弃)。 两者不会打架:MCP 驱动的会话里原生帧整条被丢弃,卡片只由工具写。"]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"命令"}),o.jsx("input",{className:"set-input",value:s.cmd??"",spellCheck:!1,onChange:C=>x("cmd",C.target.value),placeholder:"hermes 或 /path/to/hermes-dev"})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"参数"}),o.jsx("input",{className:"set-input",value:ik(s.args),spellCheck:!1,onChange:C=>x("args",C.target.value),placeholder:"acp"})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"HERMES_HOME"}),o.jsx("input",{className:"set-input",value:s.home??"",spellCheck:!1,onChange:C=>x("home",C.target.value),placeholder:"留空 = 默认 ~/.hermes"})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"profile"}),o.jsx("input",{className:"set-input",value:s.profile??"",spellCheck:!1,onChange:C=>x("profile",C.target.value),placeholder:"留空 = 该 home 的默认 profile"})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"额外环境"}),o.jsx("textarea",{className:"set-textarea",value:typeof s.env=="string"?s.env:"",spellCheck:!1,placeholder:`每行 KEY=VALUE,例如
71
+ PYTHONPATH=/srv/app/lib`,onChange:C=>x("env",C.target.value)})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"默认工作目录"}),o.jsx("input",{className:"set-input",value:s.cwd??"",spellCheck:!1,onChange:C=>x("cwd",C.target.value),placeholder:"留空 = 新建会话时再选"})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"默认权限"}),o.jsxs("select",{className:"set-select",value:s.defaultMode??"",onChange:C=>x("defaultMode",C.target.value),children:[o.jsx("option",{value:"",children:"不指定(用 agent 自己的默认)"}),R.map(C=>o.jsx("option",{value:C.id,children:C.name},C.id)),N?o.jsxs("option",{value:s.defaultMode??"",children:[s.defaultMode,"(不在缓存档位里)"]}):null]})]}),o.jsxs("p",{className:"set-hint be-kind-help",children:["新建会话时按这里选中,第一句话就已经按它来;会话里随时能改,",o.jsx("b",{children:"恢复旧会话不会被它覆盖"}),"(那是你在那段会话里的选择)。档位来自这个后端上次的握手:",R.length?o.jsxs(o.Fragment,{children:[" 现在是 ",R.map(C=>C.name).join(" / "),"。"]}):o.jsx(o.Fragment,{children:" 这个行还没起过会话,所以只有「不指定」——新建一个会话(不用发消息)握手一次就有了。"})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"备注"}),o.jsx("input",{className:"set-input",value:s.notes??"",onChange:C=>x("notes",C.target.value)})]})]}),o.jsxs("div",{className:"be-modal-foot",children:[h?o.jsx("span",{className:"set-err be-modal-err",role:"alert",children:h}):null,o.jsx("button",{className:"set-mini",onClick:y,disabled:a==="save",children:"取消"}),o.jsx("button",{className:"set-save",onClick:()=>void I(),disabled:a==="save"||!(s.id||"").trim(),children:a==="save"?"保存中…":i?"保存":"创建"})]})]})}),document.body):null]})}const ta=["/sfx/thinking.m4a","/sfx/thinking.mp3"],vy="/sfx/interrupt.wav";let rl=null,ui=null,ka=null,mm="",ol=null,_s=null,wu=null;function h3(){return typeof window>"u"?null:window.AudioContext??window.webkitAudioContext??null}function vo(){try{if(!rl){const e=h3();if(!e)return null;rl=new e}return rl.state==="suspended"&&rl.resume().catch(()=>{}),rl}catch{return null}}function Wu(){const e=vo();e&&e.state==="suspended"&&e.resume().catch(()=>{})}function zl(){if(ol)return ol;const e=vo();if(!e)return mm="这个浏览器没有 AudioContext",Promise.resolve();const t=i=>fetch(i).then(r=>{if(!r.ok)throw new Error(`${i} → HTTP ${r.status}`);return r.arrayBuffer()}).then(r=>{const a=e.decodeAudioData(r),l=new Promise((c,u)=>window.setTimeout(()=>u(new Error(`${i}: 解码超时`)),4e3));return Promise.race([a,l])}),s=[],n=async i=>{if(i>=ta.length){s.push(`背景音:${ta.length} 个容器都解不了`);return}try{ui=await t(ta[i])}catch(r){s.push(`${ta[i]}: ${String(r?.message??r)}`),await n(i+1)}};return ol=Promise.all([n(0),t(vy).then(i=>{ka=i}).catch(i=>{s.push(`${vy}: ${String(i?.message??i)}`)})]).then(()=>{mm=s.join(" | "),(!ui||!ka)&&(ol=null)}),ol}function Lh(){const e=vo();return{ctxState:e?e.state:"unavailable",bed:ui?ui.duration:null,cut:ka?ka.duration:null,error:mm,channel:ok()}}let Bn=null;function rk(){return typeof Audio>"u"?null:(Bn||(Bn=new Audio(ta[ta.length-1]),Bn.loop=!0,Bn.preload="auto",Bn.volume=Math.min(1,ni*2)),Bn)}function d3(){return!!ui||typeof Audio<"u"}function ok(){return ui?"webaudio":Bn?"element":"none"}function y_(){const e=vo();if(!(!e||!ka))try{const t=e.createBufferSource(),s=e.createGain();s.gain.value=.6,t.buffer=ka,t.connect(s).connect(e.destination),t.start()}catch{}}const ak="agentus.sfx.bed";let ni=(()=>{try{const e=Number(localStorage.getItem(ak));return Number.isFinite(e)&&e>0&&e<=1?e:.22}catch{return .22}})();function lk(){return ni}function ck(e,t=0){ni=Math.min(1,Math.max(.02,e));try{localStorage.setItem(ak,String(ni))}catch{}if(Bn&&(Bn.volume=Math.min(1,ni*2)),_s){const s=vo();s&&(_s.gain.gain.cancelScheduledValues(s.currentTime),_s.gain.gain.setTargetAtTime(ni,s.currentTime,.08))}t>0&&b_(t)}function gm(e,t=1200){if(!ui){const i=rk();if(!i)return;e?(i.volume=Math.min(1,ni*2),i.play().catch(()=>{})):i.pause();return}const s=vo();if(!s)return;if(e){if(!_s){const i=s.createGain();i.gain.value=1e-4,i.connect(s.destination),_s={gain:i,src:null}}if(!_s.src){const i=s.createBufferSource();i.buffer=ui,i.loop=!0,i.connect(_s.gain),i.start(),_s.src=i}_s.gain.gain.cancelScheduledValues(s.currentTime),_s.gain.gain.setValueAtTime(Math.max(1e-4,_s.gain.gain.value),s.currentTime),_s.gain.gain.exponentialRampToValueAtTime(Math.max(2e-4,ni),s.currentTime+t/1e3);return}if(!_s)return;const n=_s;_s=null;try{n.gain.gain.cancelScheduledValues(s.currentTime),n.gain.gain.setValueAtTime(Math.max(1e-4,n.gain.gain.value),s.currentTime),n.gain.gain.exponentialRampToValueAtTime(1e-4,s.currentTime+t/2e3);const i=n.src;window.setTimeout(()=>{try{i?.stop()}catch{}n.gain.disconnect()},t/2+80)}catch{}}function f3(){return!!(_s&&_s.src)||!!(Bn&&!Bn.paused)}function b_(e=3){const t=vo();if(t){if(wu){try{wu.stop()}catch{}wu=null}if(!ui){const s=rk();if(!s)return;s.currentTime=0,s.volume=Math.min(1,ni*2),s.play().then(()=>{window.setTimeout(()=>{try{s.pause()}catch{}},e*1e3)}).catch(()=>{});return}try{const s=t.createBufferSource(),n=t.createGain();s.buffer=ui,s.loop=!0;const i=Math.min(1,Math.max(.35,ni*1.8));n.gain.value=1e-4,s.connect(n).connect(t.destination),n.gain.exponentialRampToValueAtTime(i,t.currentTime+.3),n.gain.setValueAtTime(i,t.currentTime+e),n.gain.exponentialRampToValueAtTime(1e-4,t.currentTime+e+.2),s.start(),s.stop(t.currentTime+e+.3),wu=s}catch{}}}typeof window<"u"&&(window.__sfx={loadSfx:zl,previewBed:b_,playCut:y_,setBed:gm,sfxStatus:Lh,bedPlaying:f3,channel:ok,getBedLevel:lk,setBedLevel:ck});const al=[{id:"account",label:"账号与安全",hint:"谁能进这台驾驶舱",items:[{anchor:"set-account",label:"账号"},{anchor:"set-sessions",label:"登录会话"},{anchor:"set-locks",label:"登录失败锁定"}]},{id:"agent",label:"智能体",hint:"槽位跑哪个后端",items:[{anchor:"set-backends",label:"后端"},{anchor:"set-lifecycle",label:"回收与热备"},{anchor:"set-plan",label:"计划提示"},{anchor:"set-cockpit",label:"驾驶舱互发"},{anchor:"set-observer",label:"观察智能体"}]},{id:"notify",label:"通知",hint:"电脑上怎么收到",items:[{anchor:"set-webnotify",label:"网页通知(这台设备)"},{anchor:"set-notify",label:"手机通知(Android 伴侣)"},{anchor:"set-roots",label:"根证书(自签 HTTPS)"}]},{id:"look",label:"外观",hint:"配色",items:[{anchor:"set-theme",label:"主题"}]},{id:"voice",label:"语音",hint:"怎么听、怎么说",items:[{anchor:"set-asr",label:"语音识别(ASR)"},{anchor:"set-hotwords",label:"热词"},{anchor:"set-tts",label:"语音合成(TTS)"},{anchor:"set-summary",label:"语音总结"},{anchor:"set-browser",label:"这个浏览器"}]}],p3=["#4aacdf","#ffb454","#76bbdf","#4ec9a0","#8f7bd7","#ff6b9d"];function ll(e){return{provider:e.provider,baseUrl:e.baseUrl,asrModel:e.asrModel,asrBatchModel:e.asrBatchModel,asrStream:e.asrStream,ttsModel:e.ttsModel,ttsVoice:e.ttsVoice,ttsFormat:e.ttsFormat,dynamicHotwords:e.dynamicHotwords,hotwordLimit:e.hotwordLimit,hotwordsText:e.hotwords.join(`
72
+ `)}}const m3=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function g3({onClose:e,sessionId:t}){const s=Z1(),[n,i]=g.useState(null),[r,a]=g.useState(null),[l,c]=g.useState(null),[u,h]=g.useState(""),[d,p]=g.useState(i_),[f,m]=g.useState(null),[b,_]=g.useState(""),[v,y]=g.useState(""),[w,x]=g.useState(()=>Math.round(lk()*100)),[S,E]=g.useState(""),[R,N]=g.useState(""),[I,F]=g.useState(""),[B,C]=g.useState(""),[A,M]=g.useState(!1),[H,D]=g.useState("Agentus 语音合成自测:龙安欢音色。"),[z,T]=g.useState(null),[O,K]=go(),U=o_(),[re,J]=g.useState(null),[Y,_e]=g.useState(""),[xe,fe]=g.useState(null),[et,Oe]=g.useState(null),[tt,Pe]=g.useState(""),[Le,Ee]=g.useState(null),[Ae,Ze]=g.useState(null),[me,Ye]=g.useState(""),[de,lt]=g.useState(null),[ae,be]=g.useState(""),[Be,W]=g.useState(null),[Se,He]=g.useState(null),[q,Z]=g.useState(""),[ge,P]=g.useState(null),[le,je]=g.useState(""),[Ie,Ge]=g.useState(null),[ot,dt]=g.useState(""),[at,Q]=g.useState(null),[ke,Ne]=g.useState(""),[$e,gt]=g.useState([]),St=g.useCallback(async()=>{F("");try{const j=await fetch("/api/auth/me",{credentials:"same-origin"});if(j.ok){const Ue=await j.json().catch(()=>({}));Ue.configuredUsername&&T({configuredUsername:Ue.configuredUsername,credentialSource:Ue.credentialSource??"default",minPasswordLen:Ue.minPasswordLen??6,usingDefaultPassword:!!Ue.usingDefaultPassword})}const V=await fetch("/api/settings",{credentials:"same-origin"}),se=await V.json().catch(()=>({}));if(!V.ok)throw new Error(se.error??`settings ${V.status}`);i(se),a(Ue=>Ue??ll(se)),typeof se.agent?.idleKillMin=="number"&&J(se.agent.idleKillMin),typeof se.agent?.warmSlots=="number"&&fe(se.agent.warmSlots),typeof se.agent?.warmTtlHours=="number"&&Oe(se.agent.warmTtlHours),typeof se.agent?.recallItemChars=="number"&&Ee(se.agent.recallItemChars),typeof se.agent?.recallTotalChars=="number"&&Ze(se.agent.recallTotalChars),se.prefs?.planHint&&lt(se.prefs.planHint),typeof se.agent?.cockpitSend=="boolean"&&W(se.agent.cockpitSend),typeof se.agent?.modelWriteBack=="boolean"&&He(se.agent.modelWriteBack),typeof se.agent?.showSilentBackground=="boolean"&&P(se.agent.showSilentBackground),se.observer&&Ge(se.observer),se.summary&&Q(se.summary);const ze=await fetch("/api/backends",{credentials:"same-origin"}).then(Ue=>Ue.ok?Ue.json():[]).catch(()=>[]);gt((Array.isArray(ze)?ze:[]).map(Ue=>({id:Ue.id,label:Ue.label??Ue.id}))),await Ch(!0),p(ai());const[Je,Ct]=await Promise.all([fetch("/api/voice/models",{credentials:"same-origin"}),fetch(`/api/voice/hotwords${t?`?sessionId=${encodeURIComponent(t)}`:""}`,{credentials:"same-origin"})]);if(Je.ok)c(await Je.json()),h("");else{const Ue=await Je.json().catch(()=>({}));h(Ue.error??`model list ${Je.status}`)}Ct.ok&&m(await Ct.json())}catch(j){F(String(j?.message??j))}},[t]);g.useEffect(()=>{St()},[St]);const Jt=!!(n&&r&&!m3(r,ll(n))),dn=async()=>{if(re==null)return;const[j,V]=n?.agentIdleRange??[0,60],se=Math.max(j,Math.min(V,Math.round(re)));J(se),_e("");try{const ze=await fetch("/api/settings",{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({agent:{idleKillMin:se}})}),Je=await ze.json().catch(()=>({}));if(!ze.ok)throw new Error(Je.error??`save failed (${ze.status})`);i(Je),_e(se===0?"已保存:空闲槽位不再被回收。":`已保存:空闲 ${se} 分钟后停掉 agent 进程。`)}catch(ze){_e(`保存失败:${String(ze?.message??ze)}`)}},ye=async()=>{if(xe==null&&et==null)return;const[j,V]=n?.agentWarmRange??[0,20],[se,ze]=n?.agentWarmTtlRange??[0,168],Je=Math.max(j,Math.min(V,Math.round(xe??n?.agentDefaults?.warmSlots??5))),Ct=Math.max(se,Math.min(ze,Math.round(et??n?.agentDefaults?.warmTtlHours??24)));fe(Je),Oe(Ct),Pe("");try{const Ue=await fetch("/api/settings",{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({agent:{warmSlots:Je,warmTtlHours:Ct}})}),st=await Ue.json().catch(()=>({}));if(!Ue.ok)throw new Error(st.error??`save failed (${Ue.status})`);i(st),Pe(Je===0?"已保存:热备已关闭,只按上面的空闲时长回收。":Ct===0?`已保存:最近 ${Je} 个会话保底保活,不过期。`:`已保存:最近 ${Je} 个会话保活,闲置超过 ${Ct} 小时才回收。`)}catch(Ue){Pe(`保存失败:${String(Ue?.message??Ue)}`)}},Dt=async()=>{if(Le==null&&Ae==null)return;const[j,V]=n?.agentRecallItemRange??[80,2e3],[se,ze]=n?.agentRecallTotalRange??[2e3,6e4],Je=Math.max(j,Math.min(V,Math.round(Le??n?.agentDefaults?.recallItemChars??400))),Ct=Math.max(se,Math.min(ze,Math.round(Ae??n?.agentDefaults?.recallTotalChars??12e3)));Ee(Je),Ze(Ct),Ye("");try{const Ue=await fetch("/api/settings",{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({agent:{recallItemChars:Je,recallTotalChars:Ct}})}),st=await Ue.json().catch(()=>({}));if(!Ue.ok)throw new Error(st.error??`save failed (${Ue.status})`);i(st),Ye(`已保存:单条最多 ${Je} 字、一轮最多 ${Ct} 字(下一个回合生效)。`)}catch(Ue){Ye(`保存失败:${String(Ue?.message??Ue)}`)}},Me=async j=>{const V={enabled:Ie?.enabled??!1,backend:Ie?.backend??null,systemPrompt:Ie?.systemPrompt??"",throttleSec:Ie?.throttleSec??120,intervalSec:Ie?.intervalSec??0,...j};Ge(V),dt("");try{const se=await fetch("/api/settings",{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({observer:V})}),ze=await se.json().catch(()=>({}));if(!se.ok)throw new Error(ze.error??`save failed (${se.status})`);i(ze),ze.observer&&Ge(ze.observer),dt("已保存:下一次播报就是新设置。")}catch(se){dt(`保存失败:${String(se?.message??se)}`)}},kt=async j=>{const V={enabled:at?.enabled??!0,prompt:at?.prompt??"",maxChars:at?.maxChars??120,followSession:at?.followSession??!0,model:at?.model??"",timeoutSec:at?.timeoutSec??20,...j};Q(V),Ne("");try{const se=await fetch("/api/settings",{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({summary:V})}),ze=await se.json().catch(()=>({}));if(!se.ok)throw new Error(ze.error??`save failed (${se.status})`);i(ze),ze.summary&&Q(ze.summary),Ne("已保存 —— 下一次长按就用新的设置。")}catch(se){Ne(`保存失败:${String(se?.message??se)}`)}},Nn=async j=>{W(j),je("");try{const V=await fetch("/api/settings",{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({agent:{cockpitSend:j}})}),se=await V.json().catch(()=>({}));if(!V.ok)throw new Error(se.error??`save failed (${V.status})`);i(se),W(!!se.agent?.cockpitSend),je(j?"已保存:会话之间可以互发消息了(仅限空闲的会话)。":"已保存:agent 只能读,不能给别的会话发消息。")}catch(V){W(!j),je(`保存失败:${String(V?.message??V)}`)}},Ts=async j=>{He(j),Z("");try{const V=await fetch("/api/settings",{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({agent:{modelWriteBack:j}})}),se=await V.json().catch(()=>({}));if(!V.ok)throw new Error(se.error??`save failed (${V.status})`);i(se),He(!!se.agent?.modelWriteBack),Z(j?"已开启:换一次模型,agent 的默认模型就跟着变(新会话、命令行都吃这个默认)。":"已关闭:换模型只影响当前会话,agent 自己的配置文件不动。")}catch(V){He(!j),Z(`保存失败:${String(V?.message??V)}`)}},Rn=async j=>{P(j);try{const V=await fetch("/api/settings",{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({agent:{showSilentBackground:j}})}),se=await V.json().catch(()=>({}));if(!V.ok)throw new Error(se.error??`save failed (${V.status})`);i(se),P(!!se.agent?.showSilentBackground)}catch{P(!j)}},Un=async j=>{const V={on:de?.on??!0,everyTurn:de?.everyTurn??!0,instruction:de?.instruction??"",...j};lt(V),be("");try{const se=await fetch("/api/settings",{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({prefs:{planHint:V}})}),ze=await se.json().catch(()=>({}));if(!se.ok)throw new Error(ze.error??`save failed (${se.status})`);i(ze),lt(ze.prefs?.planHint??V),be(V.on?V.everyTurn?"已保存:每回合都提醒 agent 用 update_plan。":"已保存:只在每个 agent 进程的首条提醒一次。":"已保存:prompt 里不再追加计划提示。")}catch(se){be(`保存失败:${String(se?.message??se)}`)}},jn=async()=>{if(!r)return!1;E("save"),F(""),N("");try{const j={...r,hotwords:r.hotwordsText.split(`
73
+ `).map(Je=>Je.trim()).filter(Boolean)};delete j.hotwordsText,A&&b.trim()&&(j.apiKey=b.trim());const V=await fetch("/api/settings",{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({voice:j})}),se=await V.json().catch(()=>({}));if(!V.ok)throw C(typeof se.field=="string"?se.field:""),new Error(se.error??`save failed (${V.status})`);C(""),M(!1),i(se),a(ll(se)),_(""),await Ch(!0),p(ai());const ze=await fetch(`/api/voice/hotwords${t?`?sessionId=${encodeURIComponent(t)}`:""}`,{credentials:"same-origin"});return ze.ok&&m(await ze.json()),N("已保存"),window.setTimeout(()=>N(""),2500),!0}catch(j){return F(String(j?.message??j)),!1}finally{E("")}},zs=async j=>{const V=await BD(j);V&&F(V)},Nr=async()=>{if(await tR(),!(Jt&&!await jn())){E("tts"),F(""),N("");try{const j=await fetch("/api/tts",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({text:H,voice:r?.ttsVoice})});if(!j.ok){const se=await j.json().catch(()=>({}));throw new Error(se.error??`tts ${j.status}`)}const V=await j.blob();await IS(V),N(`合成成功 · ${V.type||"audio"} · ${Math.round(V.size/1024)} KB`)}catch(j){F(String(j?.message??j))}finally{E("")}}},Bi=()=>{F(""),pe.start(mR(),t)},bo=async()=>{E("models"),h("");try{const j=await fetch("/api/voice/models",{credentials:"same-origin"}),V=await j.json().catch(()=>({}));if(!j.ok)throw new Error(V.error??`model list ${j.status}`);c(V),N(`endpoint 报告 ${V.total} 个模型`)}catch(j){h(String(j?.message??j))}finally{E("")}},Ot=(j,V)=>{a(se=>se&&{...se,[j]:V})},ws=U.status==="listening"||U.status==="requesting"||U.status==="recording",ds=g.useRef(null),[Tn,Rr]=g.useState(al[0].id),[rt,Qe]=g.useState(al[0].items[0].anchor),jr=g.useCallback(j=>{const V=al.find(se=>se.id===j);Rr(j),Qe(V?.items[0]?.anchor??""),ds.current?.scrollTo({top:0,behavior:"auto"})},[]),Tr=g.useCallback(j=>{document.getElementById(j)?.scrollIntoView({block:"start",behavior:"smooth"}),Qe(j)},[]);return g.useEffect(()=>{const j=ds.current;if(!j)return;const V=(al.find(ze=>ze.id===Tn)?.items??[]).map(ze=>ze.anchor);if(!V.length)return;const se=()=>{const ze=j.getBoundingClientRect().top;let Je=V[0];for(const Ct of V){const Ue=document.getElementById(Ct);Ue&&Ue.getBoundingClientRect().height>0&&Ue.getBoundingClientRect().top-ze<=32&&(Je=Ct)}j.scrollTop+j.clientHeight>=j.scrollHeight-4&&(Je=V[V.length-1]),Qe(Ct=>Ct===Je?Ct:Je)};return j.addEventListener("scroll",se,{passive:!0}),se(),()=>j.removeEventListener("scroll",se)},[Tn]),o.jsxs("div",{className:"main",children:[o.jsxs("div",{className:"chat-head set-head",children:[o.jsx("button",{className:"icon-btn",onClick:e,title:"返回会话","aria-label":"back",children:o.jsx(e_,{size:16})}),o.jsxs("span",{className:"title",children:[o.jsx(Tc,{size:14})," 设置"]}),o.jsx("span",{className:"head-spacer"}),R?o.jsx("span",{className:"set-toast",children:R}):null,o.jsx("button",{className:"set-save",onClick:()=>void jn(),disabled:S==="save"||!Jt,children:S==="save"?"保存中…":Jt?"保存":"已保存"})]}),o.jsxs("div",{className:"set-main",children:[o.jsx("nav",{className:"set-nav","aria-label":"设置分类",children:al.map(j=>o.jsxs("div",{className:"set-nav-group",children:[o.jsx("button",{type:"button",className:`set-nav-cat ${Tn===j.id?"on":""}`,"aria-current":Tn===j.id?"page":void 0,onClick:()=>jr(j.id),title:j.hint,children:j.label}),Tn===j.id?j.items.map(V=>o.jsx("button",{type:"button",className:`set-nav-item ${rt===V.anchor?"on":""}`,"aria-current":rt===V.anchor?"true":void 0,onClick:()=>Tr(V.anchor),children:V.label},V.anchor)):null]},j.id))}),o.jsxs("div",{className:"set-body",ref:ds,"data-cat":Tn,"data-set-scroll":!0,children:[I?o.jsxs("div",{className:"set-err",role:"alert",children:[I,o.jsx("button",{className:"draft-x",onClick:()=>F(""),"aria-label":"dismiss",children:o.jsx(En,{size:11})})]}):null,o.jsx("h4",{className:"set-group",id:"grp-account","data-setgroup":"account",children:"账号与安全"}),o.jsx(UD,{account:z,onChanged:j=>T(V=>V&&{...V,...j})}),o.jsx("h4",{className:"set-group",id:"grp-agent","data-setgroup":"agent",children:"智能体"}),o.jsx(u3,{}),o.jsx("h4",{className:"set-group",id:"grp-notify","data-setgroup":"notify",children:"通知"}),o.jsx(i3,{}),o.jsx(JD,{sessionId:t}),o.jsx(QD,{}),o.jsx("h4",{className:"set-group",id:"grp-look","data-setgroup":"look",children:"外观"}),o.jsxs("section",{className:"set-card",id:"set-theme","data-setgroup":"look",children:[o.jsx("h3",{children:"主题"}),o.jsx("p",{className:"set-hint",children:"亮/暗跟随系统;强调色会重新给整套驾驶舱上色(按钮、链接、流式光标、用量环)。 选择存在服务端,换一台设备也一致。"}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"外观"}),o.jsx("div",{className:"set-seg",role:"group","aria-label":"theme mode",children:[["system","跟随系统"],["light","亮"],["dark","暗"]].map(([j,V])=>o.jsx("button",{type:"button",className:s.mode===j?"on":"","aria-pressed":s.mode===j,onClick:()=>void zs({...s,mode:j}),children:V},j))})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"强调色"}),o.jsxs("div",{className:"set-swatches",children:[p3.map(j=>o.jsx("button",{type:"button",className:`set-swatch ${s.accent===j?"on":""}`,style:{background:j},title:j,"aria-label":`accent ${j}`,onClick:()=>void zs({...s,accent:j})},j)),o.jsx("input",{type:"color",className:"set-color",value:s.accent||"#4aacdf",onChange:j=>void zs({...s,accent:j.target.value}),"aria-label":"custom accent"}),o.jsx("button",{type:"button",className:"set-mini",onClick:()=>void zs({...s,accent:""}),children:"默认"})]})]})]}),o.jsx("h4",{className:"set-group",id:"grp-voice","data-setgroup":"voice",children:"语音"}),o.jsxs("section",{className:"set-card",id:"set-lifecycle","data-setgroup":"agent",children:[o.jsx("h3",{children:"槽位回收与热备"}),o.jsxs("p",{className:"set-hint",children:["空闲超过这个时长后,自动停掉槽位的 ",o.jsx("b",{children:"agent 进程"})," 以释放内存 —— 对话记录、模型、思考深度全都 保留,点一下该槽位就会重新起来(状态显示「已回收(空闲)」)。这是「回收进程」,不是「归档会话」: 归档只在你手动点击时发生,两者互不影响。数值对齐 AionUi 的「Agent 空闲超时」,",o.jsx("b",{children:"0 = 关闭"}),"。"]}),o.jsxs("p",{className:"set-hint",children:["下面的 ",o.jsx("b",{children:"热备"})," 是保底,不是上限:最近 N 个会话即使空闲也留着进程 —— 「我只是离开浏览器」 不该丢掉刚才那个会话的 agent。名额自己也有寿命(小时),超时照样回收:5 个热备 × 约 137 MB ≈ 700 MB,这就是它默认 24 小时过期的原因。正在跑回合、等你审批、你正看着的会话从不被回收。"]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"Agent 空闲超时(分钟)"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{className:"set-num",type:"number",min:n?.agentIdleRange?.[0]??0,max:n?.agentIdleRange?.[1]??60,step:5,value:re??n?.agentDefaults?.idleKillMin??5,onChange:j=>J(Number(j.target.value)),onBlur:()=>void dn()}),o.jsx("span",{className:"set-hint",children:re===0?"已关闭:空闲的槽位不会被回收(长跑任务可以这么做)":`空闲 ${re??n?.agentDefaults?.idleKillMin??5} 分钟后回收`})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"热备槽位(最近 N 个)"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{className:"set-num",type:"number",min:n?.agentWarmRange?.[0]??0,max:n?.agentWarmRange?.[1]??20,step:1,value:xe??n?.agentDefaults?.warmSlots??5,onChange:j=>fe(Number(j.target.value)),onBlur:()=>void ye()}),o.jsx("span",{className:"set-hint",children:xe===0?"已关闭:没有保底名额,只按上面的空闲时长回收":`最近 ${xe??n?.agentDefaults?.warmSlots??5} 个会话即使空闲也不回收`})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"热备最长闲置(小时)"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{className:"set-num",type:"number",min:n?.agentWarmTtlRange?.[0]??0,max:n?.agentWarmTtlRange?.[1]??168,step:1,value:et??n?.agentDefaults?.warmTtlHours??24,onChange:j=>Oe(Number(j.target.value)),onBlur:()=>void ye()}),o.jsx("span",{className:"set-hint",children:et===0?"不过期:一直留着(内存也就一直占着)":`闲置超过 ${et??n?.agentDefaults?.warmTtlHours??24} 小时,连热备名额也停掉`})]})]}),Y?o.jsx("p",{className:"set-hint",children:Y}):null,tt?o.jsx("p",{className:"set-hint",children:tt}):null,o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"召回条目:单条字数"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{className:"set-num",type:"number",min:n?.agentRecallItemRange?.[0]??80,max:n?.agentRecallItemRange?.[1]??2e3,step:50,value:Le??n?.agentDefaults?.recallItemChars??400,onChange:j=>Ee(Number(j.target.value)),onBlur:()=>void Dt()}),o.jsxs("span",{className:"set-hint",children:["展开「N 条」后每条最多 ",Le??n?.agentDefaults?.recallItemChars??400," 字,超了截断"]})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"召回条目:一轮总字数"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{className:"set-num",type:"number",min:n?.agentRecallTotalRange?.[0]??2e3,max:n?.agentRecallTotalRange?.[1]??6e4,step:1e3,value:Ae??n?.agentDefaults?.recallTotalChars??12e3,onChange:j=>Ze(Number(j.target.value)),onBlur:()=>void Dt()}),o.jsx("span",{className:"set-hint",children:"不按条数限制,只按这个总量截:短记忆能多进几条,长记忆少进几条"})]})]}),me?o.jsx("p",{className:"set-hint",children:me}):null]}),o.jsxs("section",{className:"set-card",id:"set-plan","data-setgroup":"agent",children:[o.jsx("h3",{children:"计划提示注入"}),o.jsxs("p",{className:"set-hint",children:["驾驶舱给每个会话挂了一个 ",o.jsx("b",{children:"plan MCP"}),"(工具名 ",o.jsx("code",{children:"update_plan"}),"),会话卡片上那份计划就是它写进来的。 问题出在最后一公里:这类工具在 agent 侧是",o.jsx("b",{children:"懒加载"}),"的 —— 它自己的工具描述写着「优先于你自带的 todo」, 但模型不去检索就永远看不到这句话,于是 agent 全程用自己那个「进程一死就没了、驾驶舱也看不见」的 todo, 计划卡片一直是空的。"]}),o.jsxs("p",{className:"set-hint",children:["打开后,驾驶舱会在你那条消息的尾部追加一小段指引,告诉 agent 这个工具存在、多步任务应当用它发布并逐步更新、 以及懒加载时怎么检索到它。做法对齐 Hermes Studio 的",o.jsx("b",{children:"每回合注入"})," —— 它就是这么做到 agent 爱用的。",o.jsx("b",{children:"关掉后,prompt 里只有你自己打的那句话。"}),"改完立刻对下一个回合生效,不用重启会话。"]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"注入计划使用提示"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{type:"checkbox",checked:de?.on??!0,onChange:j=>void Un({on:j.target.checked})}),o.jsx("span",{className:"set-hint",children:de?.on??!0?"已开启:让 agent 知道该用 update_plan 维护计划":"已关闭:prompt 不再被追加任何内容"})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"注入频率"}),o.jsx("div",{className:"set-pair",children:o.jsxs("select",{className:"set-select",value:de?.everyTurn??!0?"every":"first",disabled:!(de?.on??!0),onChange:j=>void Un({everyTurn:j.target.value==="every"}),children:[o.jsx("option",{value:"every",children:"每回合(默认,对齐 Studio)"}),o.jsx("option",{value:"first",children:"仅每个 agent 进程的首条(省 token)"})]})})]}),o.jsx("div",{className:"set-row",children:o.jsx("label",{children:"注入内容"})}),o.jsx("textarea",{className:"set-textarea",rows:6,spellCheck:!1,disabled:!(de?.on??!0),value:de?.instruction??"",placeholder:"留空即用内置文案 —— 原文就在下面「内置文案」里,能直接看、能照着改。",onChange:j=>lt(V=>({...V??{on:!0,everyTurn:!0,instruction:""},instruction:j.target.value})),onBlur:j=>void Un({instruction:j.target.value})}),o.jsxs("details",{className:"set-builtin",open:!de?.instruction?.trim(),children:[o.jsx("summary",{children:de?.instruction?.trim()?"内置文案(你写了自定义的,下面这些不再生效;清空即可恢复)":"内置文案(留空时生效的就是它,按情况三选一)"}),o.jsxs("p",{className:"set-hint",children:["驾驶舱按这次的情况挑一条,接在「这次还有哪些步骤没做完」后面一起发给你那条消息的尾部。 内容会随计划变,所以这里只列",o.jsx("b",{children:"指引"}),"那半段的原文。"]}),VD.map(j=>o.jsxs("div",{className:"set-builtin-item",children:[o.jsx("div",{className:"set-builtin-when",children:j.when}),o.jsx("pre",{className:"set-builtin-text",children:j.text})]},j.id))]}),o.jsxs("p",{className:"set-hint",children:["这里写的只是",o.jsx("b",{children:"指引"}),"那一半(告诉 agent 有个计划工具、该怎么用它)。另一半是",o.jsx("b",{children:"计划状态"})," —— 「哪些步骤还没做完」,那是每个回合从驾驶舱的计划卡片现取的,任何人都改不了,所以这里的文字永远不会和卡片说的不一样。 清空即恢复内置文案。"]}),o.jsx("p",{className:"set-hint",children:"没有计划可提醒时不会硬凑字数:频率选「每回合」也只在该会话确有未完成计划时才重复注入; 一步就能做完的请求不受影响。没注入过的那次不会作废,打开开关或从「仅首条」切回来的那一回合会补上。"}),ae?o.jsx("p",{className:"set-hint",children:ae}):null]}),o.jsxs("section",{className:"set-card",id:"set-observer","data-setgroup":"agent",children:[o.jsx("h3",{children:"观察智能体(工作播报)"}),o.jsxs("p",{className:"set-hint",children:["「工作播报」不是把长回复念一遍,而是由一个",o.jsx("b",{children:"观察员"}),"念一句进展。它就是一个普通的 ACP 会话, 每个被观察的会话配一个,",o.jsx("b",{children:"常驻、上下文连续"}),":第一次看完之后它就记得这个会话在做什么, 之后每次只收到一行触发语(「这一轮结束了,看看进展」)。"]}),o.jsxs("p",{className:"set-hint",children:["事实",o.jsx("b",{children:"全靠它自己查"}),":它用 ",o.jsx("code",{children:"$AGENTUS_COCKPIT_BIN"})," 读会话、消息尾部、计划、待审批, 驾驶舱",o.jsx("b",{children:"不塞任何现成数据"}),"进去 —— 这样播报不会跟着我们的模板一起说错。 它跑在自己的",o.jsx("b",{children:"草稿目录"}),"里(",o.jsx("code",{children:"~/.hermes/agentus/observers/<会话 id>"}),"), 不看你的项目目录,也不出现在会话列表里。"]}),o.jsxs("p",{className:"set-hint",children:["花钱的地方只有一处:",o.jsx("b",{children:"回合结束"}),"时让它写一句。待审批、计划里完成一步这类事件是现成的事实, 驾驶舱直接念,",o.jsx("b",{children:"不花 token"}),"。观察员起不来时,会降级成 #11 的那句「会话名 · 任务名」。"]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"启用观察员"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{type:"checkbox",checked:Ie?.enabled??!1,onChange:j=>void Me({enabled:j.target.checked})}),o.jsx("span",{className:"set-hint",children:Ie?.enabled?"已启用:回合结束时由它念一句进展":"已关闭:播报降级成「会话名 · 任务名」,不起任何模型"})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"用哪个后端跑它"}),o.jsxs("div",{className:"set-pair",children:[o.jsxs("select",{className:"set-select",value:Ie?.backend??"",disabled:!(Ie?.enabled??!1),onChange:j=>void Me({backend:j.target.value||null}),children:[o.jsx("option",{value:"",children:"跟被观察的会话同一个后端(默认)"}),$e.map(j=>o.jsx("option",{value:j.id,children:j.label},j.id))]}),o.jsx("span",{className:"set-hint",children:"建议挑一个便宜、快的模型 —— 它只做「看一眼、说一句」。"})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"同一会话最短间隔(秒)"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{className:"set-num",type:"number",min:n?.observerThrottleRange?.[0]??0,max:n?.observerThrottleRange?.[1]??3600,step:30,value:Ie?.throttleSec??120,onChange:j=>Ge(V=>V&&{...V,throttleSec:Number(j.target.value)}),onBlur:j=>void Me({throttleSec:Number(j.target.value)})}),o.jsx("span",{className:"set-hint",children:"0 = 每回合都播报;待审批这类零成本事件不受它限制。"})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"节拍(每 N 秒报一次)"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{className:"set-num",type:"number",min:n?.observerIntervalRange?.[0]??0,max:n?.observerIntervalRange?.[1]??3600,step:30,value:Ie?.intervalSec??0,onChange:j=>Ge(V=>V&&{...V,intervalSec:Number(j.target.value)}),onBlur:j=>void Me({intervalSec:Number(j.target.value)})}),o.jsxs("span",{className:"set-hint",children:["0 = 关(只在回合结束、待审批时说)。设了节拍之后,",o.jsx("b",{children:"只有「有任务在跑」"}),"时才按节拍说话 —— 空闲的会话不报平安;同一个回合最多 8 条。顶部喇叭长按也能直接选 1/2/5 分钟。"]})]})]}),o.jsx("div",{className:"set-row",children:o.jsx("label",{children:"它的设定(system prompt)"})}),o.jsx("textarea",{className:"set-textarea",rows:6,spellCheck:!1,disabled:!(Ie?.enabled??!1),value:Ie?.systemPrompt??"",placeholder:"留空即用内置模板 —— 原文就在下面,能直接看、能照着改。",onChange:j=>Ge(V=>V&&{...V,systemPrompt:j.target.value}),onBlur:j=>void Me({systemPrompt:j.target.value})}),o.jsxs("details",{className:"set-builtin",open:!(Ie?.systemPrompt??"").trim(),children:[o.jsx("summary",{children:(Ie?.systemPrompt??"").trim()?"内置模板(你写了自定义的,它不再生效;清空即可恢复)":"内置模板(留空时生效的就是它)"}),o.jsx("pre",{className:"set-builtin-text",children:n?.observerPromptDefault??""})]}),o.jsx("p",{className:"set-hint",children:"你写的设定之后会自动补上一句「你负责的会话 id 是 …」,那一句不能改 —— 观察员靠它才知道看哪一个。 改完立刻对下一次播报生效,不用重启会话。"}),ot?o.jsx("p",{className:"set-hint",children:ot}):null]}),o.jsxs("section",{className:"set-card",id:"set-cockpit","data-setgroup":"agent",children:[o.jsx("h3",{children:"驾驶舱互发消息(cockpit CLI)"}),o.jsxs("p",{className:"set-hint",children:["每个会话里的 agent 都拿到了一个本机命令 ",o.jsx("code",{children:"$AGENTUS_COCKPIT_BIN"}),",可以用它",o.jsx("b",{children:"读"})," 这个驾驶舱:有哪些会话、谁在跑、各自的消息尾部、计划、正在等哪个审批。 数据面只做选择和截断,不做摘要、不改写 —— 会转述驾驶舱的机器就会说错驾驶舱。"]}),o.jsxs("p",{className:"set-hint",children:["下面这个开关管的是另一半:",o.jsx("b",{children:"往别的会话里发消息"}),"。默认关,因为两个 agent 互相回话 会变成一台烧 token 的循环生成器。打开后也只对",o.jsx("b",{children:"空闲"}),"会话生效 —— 正在跑回合的会话会 直接拒绝(",o.jsx("code",{children:"target_busy"}),"),",o.jsx("b",{children:"绝不抢占你开的那一轮"}),";已回收/归档的会话也拒绝 (",o.jsx("code",{children:"target_cold"})," / ",o.jsx("code",{children:"out_of_scope"}),"),驾驶舱不会替你把它唤醒。"]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"允许会话之间互发消息"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{type:"checkbox",checked:Be??!1,onChange:j=>void Nn(j.target.checked)}),o.jsx("span",{className:"set-hint",children:Be?"已开启:agent 可以给空闲会话留话(对方不一定读、也不一定回)":"已关闭:agent 只能读驾驶舱,不能往里写"})]})]}),o.jsxs("p",{className:"set-hint",children:["这个通道的身份是",o.jsx("b",{children:"随进程发的一次性令牌"}),"(放在环境变量里,不进命令行、不进 ",o.jsx("code",{children:"ps"}),"), 进程一死就失效;也只听本机回环地址。改动立刻对下一轮生效,不用重启会话。"]}),le?o.jsx("p",{className:"set-hint",children:le}):null]}),o.jsxs("section",{className:"set-card",id:"set-model-default","data-setgroup":"agent",children:[o.jsx("h3",{children:"模型默认值"}),o.jsxs("p",{className:"set-hint",children:['在会话里换一次模型,就是"以后都用这个"的意思 —— 所以选定',o.jsx("b",{children:"成功之后"}),",server 会把 它写进 agent 自己的配置文件。新会话、常驻服务、命令行都吃这个默认,重启也还在。"]}),o.jsxs("p",{className:"set-hint",children:[o.jsx("b",{children:"只对 Hermes 后端生效"}),":写的是 ",o.jsx("code",{children:"$HERMES_HOME/config.yaml"})," 里的",o.jsx("code",{children:"model.default"}),"(用了 ",o.jsx("code",{children:"-p"})," profile 的会话写",o.jsx("code",{children:"profiles/<名字>/config.yaml"}),")。",o.jsx("code",{children:"model.provider"}),' 只在 agent 自己报了 provider 时才一起同步 —— 描述里带人话标签("Anthropic (Claude Sonnet 4.5)") 的就不猜,宁可只改一行。Qoder 等其它后端目前不回写,开关留在开也没有副作用。']}),o.jsxs("p",{className:"set-hint",children:["只动那两行,其它字节原样保留;写入是原子的(临时文件 + rename),比 0600 宽的权限会被 收紧,改之前留一份 ",o.jsx("code",{children:".bak"}),'。写完会用 YAML 解析器验一遍能不能读回来 —— 验不过就一个字都不写。被 agent 拒绝的模型不会落盘,和"用过才算数"的排序是同一个收口点。']}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"选定模型时同步为全局默认"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{type:"checkbox",checked:Se??!0,onChange:j=>void Ts(j.target.checked)}),o.jsx("span",{className:"set-hint",children:Se===!1?"已关闭:换模型只影响当前会话":"已开启:最近一次选择就是这个 agent 的默认模型"})]})]}),q?o.jsx("p",{className:"set-hint",children:q}):null]}),o.jsxs("section",{className:"set-card",id:"set-background","data-setgroup":"agent",children:[o.jsx("h3",{children:"后台任务行"}),o.jsxs("p",{className:"set-hint",children:["后台任务行和会话轨上的 ",o.jsx("b",{children:"⚡ 角标"}),"默认只显示",o.jsx("b",{children:"会唤醒 agent 的进程"}),"(",o.jsx("code",{children:"notify_on_complete"}),")—— 那种进程意味着 agent 没有真正收工,它还在等这次 结果回来继续干活,所以那一行是绿的、会呼吸,会话也保持「进行中」。"]}),o.jsx("p",{className:"set-hint",children:"静默进程(agent 自己轮询取结果、不打算被唤醒的那种)默认不显示:它们只是噪音, 会把「这个会话还要不要我看」这个问题淹没。打开下面的开关就会显示全部, 包括跑完就静默消失的那些。"}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"显示不唤醒的后台进程"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{type:"checkbox",checked:ge??!1,onChange:j=>void Rn(j.target.checked)}),o.jsx("span",{className:"set-hint",children:ge?"已开启:所有后台进程都显示(静默型跑完即消失)":"已关闭:只显示会唤醒会话的进程"})]})]}),o.jsxs("p",{className:"set-hint",children:["需要带这个标记的后端(Hermes fork ",o.jsx("code",{children:"agentus/v0.22.0/merge-*"})," 那一版起)。 旧后端不发这个字段,于是所有进程都被当作静默型 —— 那时这一行不会出现, 开关也没有东西可显示。"]})]}),o.jsxs("section",{className:"set-card",id:"set-asr","data-setgroup":"voice",children:[o.jsx("h3",{children:"语音识别(ASR)"}),o.jsxs("p",{className:"set-hint",children:["当前生效:",o.jsx("b",{children:d.provider}),d.stt.streaming?" · 流式":"",d.stt.server?` · ${d.stt.streaming?d.stt.model:d.stt.batchModel}`:" · 未配置(只能用浏览器自带识别)"]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"提供方"}),o.jsxs("select",{className:"set-select",value:r?.provider??"browser",onChange:j=>Ot("provider",j.target.value),children:[o.jsx("option",{value:"dashscope",children:"阿里百炼(DashScope,本文档默认)"}),o.jsx("option",{value:"openai",children:"OpenAI 兼容端点"}),o.jsx("option",{value:"browser",children:"浏览器自带(不经过服务端)"})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"端点"}),o.jsx("input",{className:"set-input",placeholder:"https://llm-xxxx.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",value:r?.baseUrl??"",onChange:j=>Ot("baseUrl",j.target.value),spellCheck:!1})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"API Key"}),A?o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{className:"set-input",type:"password",name:"agentus-voice-apikey",autoComplete:"new-password",placeholder:n?.apiKeySet?`已保存 ${n.apiKeyMasked}(留空不改)`:"sk-…",value:b,onChange:j=>_(j.target.value),spellCheck:!1,autoFocus:!0}),o.jsx("button",{type:"button",className:"set-btn",onClick:()=>{M(!1),_(""),F(""),C("")},children:"取消"})]}):o.jsxs("div",{className:"set-pair",children:[o.jsx("span",{className:"set-hint",children:n?.apiKeySet?`已保存 ${n.apiKeyMasked}`:"未设置"}),o.jsx("button",{type:"button",className:"set-btn",onClick:()=>M(!0),children:"改密钥"}),n?.apiKeySet?o.jsx("button",{type:"button",className:"set-btn",onClick:()=>{fetch("/api/settings",{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({voice:{apiKey:""}})}).then(j=>j.ok?j.json():null).then(j=>{j&&(i(j),a(ll(j)),N("已清除密钥"))}).catch(()=>{})},children:"清除"}):null]})]}),I&&B==="voice.apiKey"?o.jsx("p",{className:"set-hint",style:{color:"#e5534b"},children:I}):null,n?.apiKeySource?o.jsxs("p",{className:"set-hint",children:["密钥来自环境:",o.jsx("code",{children:n.apiKeySource}),"(",o.jsx("code",{children:"DASHSCOPE_API_KEY"})," / ",o.jsx("code",{children:"DASHSCOPE_BASE_URL"}),")"]}):null,o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"流式模型"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{className:"set-input",list:"asr-models",value:r?.asrModel??"",onChange:j=>Ot("asrModel",j.target.value),spellCheck:!1}),o.jsxs("label",{className:"set-check",children:[o.jsx("input",{type:"checkbox",checked:!!r?.asrStream,onChange:j=>Ot("asrStream",j.target.checked)}),"启用流式(边说边出字)"]})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"批量模型"}),o.jsx("input",{className:"set-input",list:"asr-models",value:r?.asrBatchModel??"",onChange:j=>Ot("asrBatchModel",j.target.value),spellCheck:!1})]}),o.jsx("datalist",{id:"asr-models",children:(l?.asr??[]).map(j=>o.jsx("option",{value:j},j))}),o.jsxs("p",{className:"set-hint",children:[u?`无法读取端点模型列表:${u}`:l?`端点报告 ${l.total} 个模型,其中识别类 ${l.asr.length} 个(上面可直接选,也可以手填任意 id)`:"正在读取端点模型列表…",o.jsxs("button",{className:"set-mini",onClick:()=>void bo(),disabled:S==="models",children:[o.jsx(ba,{size:11})," 重新读取"]})]})]}),o.jsxs("section",{className:"set-card",id:"set-sfx","data-setgroup":"voice",children:[o.jsx("h3",{children:"通话状态音"}),o.jsx("p",{className:"set-hint",children:"它干活的时候有一点很轻的底音,它开口说话就停;你打断它的时候响一声短的。 这里放的和通话里放的是同一份素材、同一个音频上下文,所以这里能听到、通话里就该能听到。"}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"音量"}),o.jsx("input",{type:"range",min:5,max:100,value:w,onChange:j=>{const V=Number(j.target.value);x(V),Wu(),zl().then(()=>ck(V/100,1.6))}}),o.jsxs("span",{className:"set-hint",children:[w,"%"]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("button",{type:"button",className:"set-btn",onClick:()=>{Wu(),y("正在解码…"),zl().then(()=>{const j=Lh();b_(3),y(`上下文 ${j.ctxState} · 通道 ${j.channel} · 背景音 ${j.bed?j.bed.toFixed(1)+"s":"没解码"} · 打断音 ${j.cut?j.cut.toFixed(2)+"s":"没解码"}${j.error?" · 错误:"+j.error:""}`)})},children:"试听背景音(3 秒)"}),o.jsx("button",{type:"button",className:"set-btn",onClick:()=>{Wu(),y("正在解码…"),zl().then(()=>{const j=Lh();y_(),y(`上下文 ${j.ctxState} · 通道 ${j.channel} · 打断音 ${j.cut?j.cut.toFixed(2)+"s":"没解码"}${j.error?" · 错误:"+j.error:""}`)})},children:"试听打断音"})]}),v?o.jsx("p",{className:"set-hint",children:o.jsx("b",{children:v})}):null,o.jsx("p",{className:"set-hint",children:"如果这里显示「上下文 suspended」或者「没解码」,问题在浏览器或格式,不在通话页 —— 把这一行发我。"})]}),o.jsxs("section",{className:"set-card",id:"set-hotwords","data-setgroup":"voice",children:[o.jsx("h3",{children:"热词"}),o.jsxs("p",{className:"set-hint",children:["固定热词每行一个,可写 ",o.jsx("code",{children:"词=权重"}),"(1–5,",o.jsx("code",{children:"50"})," 是超级热词); 动态热词从当前会话的上下文里自动抽取高频实体词,一起送进识别。"]}),o.jsx("textarea",{className:"set-textarea",rows:5,placeholder:`Agentus=5
74
+ ACP
75
+ qodercli`,value:r?.hotwordsText??"",onChange:j=>Ot("hotwordsText",j.target.value),spellCheck:!1}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"动态热词"}),o.jsxs("div",{className:"set-pair",children:[o.jsxs("label",{className:"set-check",children:[o.jsx("input",{type:"checkbox",checked:!!r?.dynamicHotwords,onChange:j=>Ot("dynamicHotwords",j.target.checked)}),"从上下文抽取"]}),o.jsxs("label",{className:"set-check",children:["上限",o.jsx("input",{className:"set-num",type:"number",min:0,max:200,value:r?.hotwordLimit??30,onChange:j=>Ot("hotwordLimit",Number(j.target.value))})]})]})]}),o.jsxs("div",{className:"set-hot",children:[o.jsx("span",{className:"set-hot-title",children:f?`下次识别携带 ${f.words.length} 个热词(固定 ${f.fixed} / 动态 ${f.dynamic}),上下文 ${f.contextTurns??0} 轮`:"…"}),o.jsxs("div",{className:"set-hot-list",children:[(f?.words??[]).slice(0,40).map(j=>o.jsxs("span",{className:`set-chip ${j.origin}`,title:`${j.origin} · 权重 ${j.weight}`,children:[j.word,j.weight>=5?o.jsx("b",{children:j.weight===50?"50":j.weight}):null]},`${j.origin}-${j.word}`)),f&&!f.words.length?o.jsx("span",{className:"set-hint",children:"还没有热词:写几个固定词,或先聊两句再回来看动态抽取。"}):null]})]})]}),o.jsxs("section",{className:"set-card",id:"set-summary","data-setgroup":"voice",children:[o.jsx("h3",{children:"语音总结(消息喇叭长按)"}),o.jsxs("p",{className:"set-hint",children:[o.jsx("b",{children:"长按"}),"任意一条消息旁边的喇叭(电脑上右键)→「语音播报总结」:把这一条压成几十秒能听完的一段话再念出来。 适合那种一屏表格、或者很长的输出 —— 通勤时听完就能知道结论。"]}),o.jsxs("p",{className:"set-hint",children:["它",o.jsx("b",{children:"不经过 agent"}),",也不带会话历史:只把",o.jsx("b",{children:"这一条消息"}),"加下面这段指令,发一次",o.jsx("code",{children:"chat/completions"}),",拿回一段话交给同一个 TTS 念。 消息本身就短于字数上限时",o.jsx("b",{children:"直接念原文"}),",不花一次模型调用。"]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"启用"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{type:"checkbox",checked:at?.enabled??!0,onChange:j=>void kt({enabled:j.target.checked})}),o.jsx("span",{className:"set-hint",children:at?.enabled??!0?"已启用:长按菜单里会出现「语音播报总结」":"已关闭:长按只出菜单,没有这一项"})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"用会话自己的模型"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{type:"checkbox",checked:at?.followSession??!0,onChange:j=>void kt({followSession:j.target.checked})}),o.jsx("span",{className:"set-hint",children:at?.followSession??!0?"已开启:跟这个会话当前选的 provider 和模型走 —— 你在用 DeepSeek,这笔就记在 DeepSeek 上":"已关闭:改用下面那个模型,走「语音」里配的 DashScope 端点"})]})]}),o.jsxs("p",{className:"set-hint",children:["端点与 key ",o.jsx("b",{children:"不在这里配第二份"}),":驾驶舱读 agent 自己的家 —— ",o.jsx("code",{children:"config.yaml"})," 里的",o.jsx("code",{children:"providers.<id>"}),"(本机的 ",o.jsx("code",{children:"lab"})," 就是),或那几家的 key (",o.jsx("code",{children:"~/.hermes/.env"})," 的 ",o.jsx("code",{children:"DEEPSEEK_API_KEY"}),"、",o.jsx("code",{children:"OPENROUTER_API_KEY"})," 等)。 只认 OpenAI 兼容的 ",o.jsx("code",{children:"/v1/chat/completions"}),";Anthropic Messages / Bedrock / Vertex 这类形状解析不出来, 会退到下面那个模型,并在播报稿那一行写明「语音端点」。"]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"字数上限"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{className:"set-num",type:"number",min:n?.summaryCharsRange?.[0]??40,max:n?.summaryCharsRange?.[1]??400,step:10,value:at?.maxChars??120,onChange:j=>Q(V=>V&&{...V,maxChars:Number(j.target.value)}),onBlur:j=>void kt({maxChars:Number(j.target.value)})}),o.jsx("span",{className:"set-hint",children:"中文大约每字 0.2–0.3 秒(120 字 ≈ 25–35 秒)。它同时也是「短于此就念原文」的阈值。"})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"备用模型(语音端点)"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{className:"set-input",type:"text",placeholder:`${n?.summaryModelDefault??"qwen-flash"}(默认)`,value:at?.model??"",onChange:j=>Q(V=>V&&{...V,model:j.target.value}),onBlur:j=>void kt({model:j.target.value})}),o.jsxs("span",{className:"set-hint",children:["只在上面关掉、或会话那个 provider 解析不出来时用。",o.jsx("code",{children:n?.summaryModelDefault??"qwen-flash"})," 是默认。"]})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"超时(秒)"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{className:"set-num",type:"number",min:n?.summaryTimeoutRange?.[0]??5,max:n?.summaryTimeoutRange?.[1]??60,step:5,value:at?.timeoutSec??20,onChange:j=>Q(V=>V&&{...V,timeoutSec:Number(j.target.value)}),onBlur:j=>void kt({timeoutSec:Number(j.target.value)})}),o.jsxs("span",{className:"set-hint",children:["超时就",o.jsx("b",{children:"明说失败"}),",不会拿原文冒充总结。可以重试。"]})]})]}),o.jsx("div",{className:"set-row",children:o.jsx("label",{children:"怎么改写"})}),o.jsx("textarea",{className:"set-textarea",rows:7,spellCheck:!1,value:at?.prompt??"",placeholder:"留空即用内置模板 —— 原文就在下面,能直接看、能照着改。",onChange:j=>Q(V=>V&&{...V,prompt:j.target.value}),onBlur:j=>void kt({prompt:j.target.value})}),o.jsxs("details",{className:"set-builtin",open:!(at?.prompt??"").trim(),children:[o.jsx("summary",{children:(at?.prompt??"").trim()?"内置模板(你写了自定义的,它不再生效;清空即可恢复)":"内置模板(留空时生效的就是它)"}),o.jsx("pre",{className:"set-builtin-text",children:n?.summaryPromptDefault??""})]}),o.jsxs("p",{className:"set-hint",children:[o.jsx("code",{children:"{maxChars}"})," 会被换成上面的字数上限。消息正文作为",o.jsx("b",{children:"用户那一轮"}),"单独发出去, 不带系统人设、不带历史、不带工具 —— 所以它只会总结你长按的那一条。"]}),ke?o.jsx("p",{className:"set-hint",children:ke}):null]}),o.jsxs("section",{className:"set-card",id:"set-tts","data-setgroup":"voice",children:[o.jsx("h3",{children:"语音合成(TTS)"}),o.jsxs("p",{className:"set-hint",children:["走百炼的 ",o.jsx("code",{children:"SpeechSynthesizer"}),"(合成结果由服务端取回,密钥不出服务端)。 朗读按钮仍可在下面选择走浏览器自带声音。"]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"模型"}),o.jsx("input",{className:"set-input",list:"tts-models",value:r?.ttsModel??"",onChange:j=>Ot("ttsModel",j.target.value),spellCheck:!1})]}),o.jsx("datalist",{id:"tts-models",children:(l?.tts??[]).map(j=>o.jsx("option",{value:j},j))}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"音色"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{className:"set-input",list:"tts-voices",value:r?.ttsVoice??"",onChange:j=>Ot("ttsVoice",j.target.value),spellCheck:!1}),o.jsxs("select",{className:"set-select",value:r?.ttsFormat??"wav",onChange:j=>Ot("ttsFormat",j.target.value),children:[o.jsx("option",{value:"wav",children:"wav"}),o.jsx("option",{value:"mp3",children:"mp3"})]})]})]}),o.jsx("datalist",{id:"tts-voices",children:(n?.ttsVoices??[]).map(j=>o.jsx("option",{value:j},j))}),o.jsxs("p",{className:"set-hint",children:["默认 ",o.jsx("code",{children:"longanhuan_v3.6"})," = 龙安欢。系统音色还有 loongjielidou / loongeva / loongjohn,手填任意音色 id 也可以。"]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"试听"}),o.jsxs("div",{className:"set-pair",children:[o.jsx("input",{className:"set-input",value:H,onChange:j=>D(j.target.value)}),o.jsxs("button",{className:"set-mini",onClick:()=>void Nr(),disabled:S==="tts",children:[o.jsx(hd,{size:12})," ",S==="tts"?"合成中…":"合成并播放"]})]})]}),o.jsx("p",{className:"set-hint",children:"试听使用已保存的配置(有未保存修改会先保存)。"})]}),o.jsxs("section",{className:"set-card",id:"set-browser","data-setgroup":"voice",children:[o.jsx("h3",{children:"这个浏览器"}),o.jsx("p",{className:"set-hint",children:"听写引擎与朗读声音是本机设置:手机和电脑的麦克风/声音本来就不一样。"}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"听写引擎"}),o.jsxs("select",{className:"set-select",value:O.stt,onChange:j=>K({stt:j.target.value}),children:[o.jsx("option",{value:"auto",children:"自动(优先服务端流式)"}),o.jsx("option",{value:"stream",children:"服务端流式(百炼,带热词)"}),o.jsx("option",{value:"browser",children:"浏览器自带"}),o.jsx("option",{value:"server",children:"服务端批量上传"})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"测试识别"}),o.jsxs("div",{className:"set-pair",children:[o.jsxs("button",{className:"set-mini",onClick:Bi,disabled:ws||U.status==="transcribing",children:[o.jsx(Ri,{size:12})," 开麦说一句"]}),ws||U.status==="transcribing"?o.jsxs("button",{className:"set-mini",onClick:()=>pe.stop(),children:[o.jsx(xh,{size:11})," 停止"]}):null,o.jsx("span",{className:`dict-chip ${U.error?"err":""}`,style:{margin:0},children:U.error?U.error:U.status==="requesting"?"等待麦克风…":U.status==="transcribing"?"收尾中…":`${U.text}${U.interim?` ${U.interim}`:""}${U.engine?` · ${U.engine}`:""}`})]})]}),o.jsxs("div",{className:"set-row",children:[o.jsx("label",{children:"朗读"}),o.jsxs("div",{className:"set-pair",children:[o.jsxs("select",{className:"set-select",value:O.speakMode??(O.autoRead?"reply":"off"),onChange:j=>{const V=j.target.value;K({speakMode:V,autoRead:V==="reply"})},children:[o.jsx("option",{value:"off",children:"关(不自动出声)"}),o.jsx("option",{value:"reply",children:"自动朗读(念整条回复)"}),o.jsx("option",{value:"brief",children:"工作播报(念驾驶舱的一句话)"})]}),o.jsxs("label",{className:"set-check",children:[o.jsx("input",{type:"checkbox",checked:O.serverTts,onChange:j=>K({serverTts:j.target.checked})}),"用服务端声音(否则用系统声音)"]})]})]})]}),o.jsxs("div",{className:"set-actions",children:[o.jsx("button",{className:"set-save",onClick:()=>void jn(),disabled:S==="save"||!Jt,children:S==="save"?"保存中…":"保存"}),Jt?o.jsx("button",{className:"set-mini",onClick:()=>a(n?ll(n):null),children:"撤销修改"}):null]})]})]})]})}const Ca=e=>String(e).padStart(2,"0"),_3=["周日","周一","周二","周三","周四","周五","周六"];function Ti(e){const t=new Date(e);return`${Ca(t.getHours())}:${Ca(t.getMinutes())}`}function uo(e){const t=new Date(e);return`${t.getFullYear()}-${Ca(t.getMonth()+1)}-${Ca(t.getDate())} ${Ti(e)}`}function uk(e,t){const s=new Date(e),n=new Date(t),i=new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime(),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return Math.round((r-i)/864e5)}function _m(e,t=Date.now()){const s=new Date(e),n=uk(e,t);return n<=0?Ti(e):n===1?`昨天 ${Ti(e)}`:s.getFullYear()===new Date(t).getFullYear()?`${s.getMonth()+1}月${s.getDate()}日 ${Ti(e)}`:uo(e)}function v3(e,t=Date.now()){const s=Math.floor((t-e)/1e3);if(s<0)return Ti(e);if(s<45)return"刚刚";if(s<3600)return`${Math.max(1,Math.floor(s/60))} 分钟前`;const n=new Date(e),i=uk(e,t);return i<=0?Ti(e):i===1?"昨天":i<7?_3[n.getDay()]:n.getFullYear()===new Date(t).getFullYear()?`${n.getMonth()+1}月${n.getDate()}日`:`${n.getFullYear()}-${Ca(n.getMonth()+1)}-${Ca(n.getDate())}`}const y3=6e4;function Oh(e){const t=Math.round(Math.max(0,e)/1e3);return t<60?`${t} 秒`:`${Math.floor(t/60)} 分 ${t%60} 秒`}function b3(e,t){const s=Math.max(0,t-e),n=s>=y3;return{quiet:n,gapMs:s,said:n?`agent 已经 ${Oh(s)} 没有输出了 —— 回合还在跑,可以点下面的停止`:"agent 正在工作(有输出就会重置这个计时)"}}const w3={hermes:{letter:"H",label:"Hermes",icon:"/coding-agents/hermes.png"},qoder:{letter:"Q",label:"Qoder",icon:"/coding-agents/qoder.svg"},mock:{letter:"M",label:"Mock"}};function vd(e){return w3[e]??{letter:e.slice(0,1).toUpperCase(),label:e}}function yy(e,t){const s=e.filter(n=>n.kind!=="mock"||t);return s.length?s:e}function x3(e,t){const s=[],n=/(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g;let i=0,r,a=0;for(;r=n.exec(e);){r.index>i&&s.push(e.slice(i,r.index));const l=r[0],c=`${t}-i${a++}`;if(l.startsWith("**"))s.push(o.jsx("strong",{children:l.slice(2,-2)},c));else if(l.startsWith("`"))s.push(o.jsx("code",{className:"inline",children:l.slice(1,-1)},c));else{const u=/\[([^\]]+)\]\(([^)]+)\)/.exec(l);s.push(o.jsx("a",{href:u[2],target:"_blank",rel:"noreferrer",children:u[1]},c))}i=r.index+l.length}return i<e.length&&s.push(e.slice(i)),s}function S3({text:e}){const t=e.split(/```/);return o.jsx(o.Fragment,{children:t.map((s,n)=>n%2===1?o.jsx("pre",{className:"code",children:o.jsx("code",{children:s.replace(/^[a-z]*\n/,"").replace(/\n$/,"")})},n):o.jsx(g.Fragment,{children:x3(s,`p${n}`)},n))})}const by=12,k3=80;function C3(e){const t=[],s=/[^。!?!?\n…]*[。!?!?\n…]+/g;let n=0;for(const l of e.matchAll(s)){const c=l[0].trim();c&&t.push(c),n=(l.index??0)+l[0].length}const i=[];for(const l of t){const c=i[i.length-1];c!==void 0&&c.length<by&&c.length+l.length<=k3?i[i.length-1]=`${c} ${l}`:i.push(l)}const r=[],a=i[i.length-1];return a!==void 0&&a.length<by&&r.push(i.pop()),{done:i,tail:[...r,e.slice(n).trim()].filter(Boolean).join(" ")}}const E3={leadingDelayMs:2e3,firstToolGapMs:5e3,minGapMs:1e4,dwellMs:9e3,maxCues:3},N3=/[\u0000-\u001f]|^\s*$/;function R3(e){const t=e.replace(/\s*·.*$/,"").trim();if(!t||N3.test(t))return"在跑一个工具";const s=t.split(/[\s/\\]+/).find(n=>n.length>0)??"";return s?`在跑 ${s.slice(0,12)}`:"在跑一个工具"}class wy{#e;#l=0;#i=!1;#s=0;#o=0;#t=null;#n=0;#c=!1;#h=!1;constructor(t={}){this.#e={...E3,...t}}turnStarted(t){this.#i=!0,this.#l=t,this.#s=0,this.#o=0,this.#t=null,this.#n=0,this.#c=!1,this.#h=!1}get turnActive(){return this.#i&&!this.#c}get cuesSpoken(){return this.#o}thinking(t){return!this.turnActive||this.#h||t-this.#l<this.#e.leadingDelayMs?null:(this.#h=!0,this.#p({text:"我查一下",kind:"leading"},t))}tool(t,s){if(!this.turnActive)return null;const n={text:R3(s),kind:"tool"};return this.#o===0&&(this.#s!==0||t-this.#l>=this.#e.firstToolGapMs)?this.#p(n,t):(this.#_(n,t),null)}plan(t,s,n){if(!this.turnActive||n<=0)return null;const i={text:`第 ${Math.min(s+1,n)} 步,共 ${n} 步`,kind:"plan"};return this.#o===0&&t-this.#l>=this.#e.firstToolGapMs?this.#p(i,t):(this.#_(i,t),null)}tick(t){if(!this.turnActive||!this.#t||t-this.#n<this.#e.dwellMs)return null;const s=this.#p(this.#t,t);return s&&(this.#t=null),s}answerStarted(){this.#c=!0,this.#t=null}turnEnded(){this.#i=!1,this.#l=0,this.#t=null,this.#c=!1}#_(t,s){this.#t?.kind==="plan"&&t.kind==="tool"||(this.#t=t,this.#n=s)}#p(t,s){return this.#o>=this.#e.maxCues?null:this.#s&&s-this.#s<this.#e.minGapMs?(this.#t?this.#n=Math.min(this.#n,s):this.#_(t,s),null):(this.#o+=1,this.#s=s,t)}}const Yi=(e,t,s,n,i,r)=>[{off:e,wid:t,lidY:s,oval:n,tilt:i,ridge:r},{off:e,wid:t,lidY:s,oval:n,tilt:i,ridge:r}],hk={neutral:Yi([0,0],.13,1,[0,0],0,[0,0,-.155,.155]),happy:Yi([.03,.03],.1305,1,[0,0],0,[-.16,.16,-.04,.12]),surprised:Yi([.03,0],.21,1,[0,0],0,[0,0,-.22,.22]),inspecting:[{off:[.04,0],wid:.27,lidY:1,oval:[0,0],tilt:0,ridge:[0,0,0,0]},{off:[.04,0],wid:.18,lidY:1,oval:[0,0],tilt:0,ridge:[0,0,0,0]}],sad:Yi([-.05,0],.13,1,[0,0],0,[-.0563,.0563,-.106,.106]),sleepy:Yi([.01,0],.13,1,[0,0],0,[-.11,.11,-.0125,.025]),squinted:Yi([.01,0],.13,1,[0,0],0,[-.12,.12,0,0]),calm:Yi([.05,0],.247,1,[.296,.247],0,[-.296,.296,0,0]),confused:Yi([-.1,0],.1305,1,[0,0],0,[-.08,.01,-.16,.16])},j3=Object.keys(hk);new Set(j3);const Do={x:34/.26,y:70/.57},xy={w:64,h:82};function Tf(e,t){const s=hk[e][t?1:0],[n,i,r,a]=s.ridge,l=2*Math.max(Math.abs(n),Math.abs(i))+2*s.wid,c=a-r+2*s.wid*s.lidY,u=Math.min(1,xy.w/(l*Do.x),xy.h/(c*Do.y));return{w:l*Do.x*u,h:c*Do.y*u,x:s.off[0]*Do.x*u,y:s.off[1]*Do.y*u,rot:s.tilt*180/Math.PI}}function T3(e){switch(e){case"focus":case"strive":return 48;case"curious":return 54;case"drowsy":case"sleep":return 56;case"working":return 46;case"asking":return 52;case"calm":return 62;case"confused":return 54;default:return 60}}function A3(e){const t=a=>Number.isFinite(a)?Math.max(0,a):0,s=e.ballR,n=s!==void 0&&Number.isFinite(s)&&s>0?s:98,i=T3(e.mood)+(t(e.leftW)+t(e.rightW))/2,r=Math.min(1,Math.max(0,i/(2*n)));return Math.asin(r)*180/Math.PI*2}const dk=["happy","sad","confused","focus","drowsy","error","scan","loading","strive","sleep"];function fk(e=Math.random){return 2800+e()*3600}const vm=260,cl=70.833,Af=33.333,M3=1.06,D3=.01;function I3(e){if(!Number.isFinite(e)||e<0||e>=vm)return 0;const t=n=>n*n*(3-2*n);if(e<cl)return t(e/cl);if(e<cl+Af)return 1;const s=vm-cl-Af;return 1-t((e-cl-Af)/s)}const Sy=2400,P3=3e4,L3=9e4,O3=12e4,B3=1600,pk=6e3,$3=.56;function F3(e,t,s,n={}){const i=bn(n.warmth??0);switch(e){case"listening":return{mode:"listening",attention:Math.min(1,.72+t*.38),energy:.78,warmth:i,phaseElapsed:s};case"thinking":return{mode:"thinking",attention:.88,energy:Math.min(1,.62+s*.08),warmth:i,phaseElapsed:s};case"speaking":return{mode:"speaking",attention:.7,energy:Math.min(1,.72+t*.35),warmth:Math.max(i,.25),phaseElapsed:s};case"curious":case"asking":return{mode:"listening",attention:Math.min(1,.82+t*.34),energy:.86,warmth:i,phaseElapsed:s};case"focus":case"working":case"strive":case"loading":return{mode:"thinking",attention:.9,energy:Math.min(1,.64+s*.08),warmth:i,phaseElapsed:s};case"talking":case"happy":case"surprise":case"wink":return{mode:"speaking",attention:.74,energy:Math.min(1,.76+t*.33),warmth:Math.max(i,.28),phaseElapsed:s};case"lookLeft":case"lookRight":case"scan":return{mode:"listening",attention:.66,energy:.7,warmth:i,phaseElapsed:s};case"drowsy":case"sleep":return{mode:"idle",attention:.1,energy:.16+i*.1,warmth:i,phaseElapsed:s};case"calm":return{mode:"idle",attention:.5,energy:.56,warmth:i,phaseElapsed:s};case"confused":return{mode:"listening",attention:.64,energy:.6,warmth:i,phaseElapsed:s};default:return{mode:"idle",attention:n.resting?.12:.38,energy:(n.resting?.18:.48)+i*.2,warmth:i,phaseElapsed:s}}}function z3(e){const{phase:t,activity:s="none",emotion:n,life:i,resting:r,drowsy:a}=e;return t==="error"?"error":t==="connecting"?"loading":s==="asking"?(e.askingMs??0)>=O3?"drowsy":"asking":e.waking?"surprise":t==="speaking"?n&&n!=="idle"?n:"talking":s==="tools"?"working":r?"sleep":a?"drowsy":t==="listening"?i??"calm":t==="thinking"?"focus":i??"idle"}function mk(e){return e<1.2?0:e<3.2?1:2}function ky(e){const{mood:t,right:s,t:n,expr:i}=e,r=e.blinking??!1,a=bn(e.blink??(r?1:0)),l=e.substate??"idle",c=bn(e.level),u=bn(e.sleep??0),{right:h}={right:s},d=t==="surprise"?Tf("surprised",s):t==="calm"?Tf("calm",s):t==="confused"?Tf("confused",s):null;if(t==="error")return Mf({shape:"x",w:45,h:45,yScale:1,xScale:1,rot:0,x:0,y:0,alpha:.86,glow:10,jitter:6},l,s,n);if(t==="happy"||t==="sad")return Mf({shape:"arc",w:45,h:30,yScale:1,xScale:1,rot:0,x:0,y:t==="happy"?20+Math.sin(n*10)*3:-10,alpha:bn(.72+i.energy*.22+i.warmth*.06),glow:9+c*12+i.warmth*5,jitter:0,arc:t},l,s,n);const p=mk(i.phaseElapsed),f=p===0?48:p===1?56:60,m=p===0?18:p===1?13:10+Math.sin(n*2)*2,b=p===0?12:p===1?22:28,_=p===0?4:p===1?10:14,v=t==="focus"&&i.mode==="thinking",y=t==="focus"&&i.mode==="listening";let w;switch(t){case"scan":w=65+c*8;break;case"strive":w=f;break;case"drowsy":w=42+u*5;break;case"sleep":w=45;break;case"surprise":w=d.w;break;case"calm":w=d.w;break;case"confused":w=d.w;break;case"loading":w=16;break;case"curious":w=34;break;case"working":w=46;break;case"asking":w=38;break;case"focus":w=y?40+c*8:v?46+Math.min(i.phaseElapsed,3)*2.5:32+i.attention*8;break;default:w=34}let x;switch(t){case"scan":x=12+c*8;break;case"strive":x=m;break;case"drowsy":x=Math.max(8,78-u*66);break;case"sleep":x=4+Math.sin(n*1.1)*1.2+1.2;break;case"surprise":x=d.h;break;case"calm":x=d.h;break;case"confused":x=d.h;break;case"loading":x=16;break;case"wink":x=h?2:40;break;case"working":x=46;break;case"asking":x=74;break;case"focus":x=y?68+c*14:v?44-Math.min(i.phaseElapsed,3)*3.5:78+i.attention*12+c*8;break;default:x=70}let S=0;t==="strive"?S=h?-b:b:t==="curious"?S=6:t==="asking"?S=8:t==="confused"?S=d.rot-8:v&&(S=h?4:-4);let E=0;switch(t){case"lookLeft":E=-40;break;case"lookRight":E=40;break;case"scan":E=Math.sin(n*3.5)*45;break;case"working":E=0;break;case"asking":E=Math.sin(n*.9)*1.2;break;case"calm":E=d.x*2+Math.sin(n*.7)*1.2;break;case"confused":E=d.x*2+Math.sin(n*1.3)*2;break;case"surprise":E=d.x*2;break;case"strive":E=Math.sin(n*(p===0?1.8:p===1?4.2:5))*_;break;case"focus":E=y?Math.sin(n*1.2)*1.8:v?Math.sin(n*2.4)*(i.phaseElapsed<1.2?2.5:6):Math.sin(n*1.8)*(2+i.attention*2);break}let R=0;switch(t){case"talking":R=Math.sin(n*10)*2-c*4+i.warmth*2;break;case"strive":R=Math.cos(n*3.2)*(2+i.energy*2);break;case"drowsy":R=4+u*12+Math.sin(n*1.2)*1.4;break;case"wink":R=h?0:-10;break;case"working":R=6+Math.sin(n*1.6)*1.2;break;case"surprise":R=d.y;break;case"calm":R=d.y+Math.sin(n*1.1)*1.1;break;case"confused":R=d.y+Math.sin(n*1.7)*1.5;break}let N=1;t==="talking"?N=.72+c*.42+Math.sin(n*8)*.06+i.warmth*.04:t==="drowsy"?N=Math.max(.18,1-u*.74):t==="working"?N=.58+Math.sin(n*1.6)*.02:t==="calm"?N=.82+Math.sin(n*1.1)*.02:t==="confused"?N=.98+Math.sin(n*1.7)*.015:t==="focus"&&(N=y?.9+c*.12+Math.sin(n*1.4)*.015:v?.82+Math.sin(n*1.8)*.025:.94+i.attention*.06+Math.sin(n*2)*.02);let I=1;t==="lookLeft"?I=h?1.2:.8:t==="lookRight"&&(I=h?.8:1.2);let F;return t==="drowsy"?F=.72-u*.44:t==="sleep"?F=.18:F=Math.min(1,.72+i.energy*.22+i.warmth*.06),a>0&&!dk.includes(t)&&(N=Math.min(N,Math.max(D3,1-M3*a))),Mf({shape:"capsule",w,h:x,yScale:N,xScale:I,rot:S,x:E,y:R,alpha:bn(F),glow:9+c*12+i.warmth*5,jitter:t==="strive"?.8:0},l,s,n)}function Mf(e,t,s,n){switch(t){case"reading":return{...e,w:e.w*.9,h:e.h*.82,rot:e.rot+3,y:e.y+2};case"running":return{...e,w:e.w*1.06,h:e.h*.74,yScale:e.yScale*.82,jitter:Math.max(e.jitter,1.1),y:e.y+Math.sin(n*5.5)*1.2};case"writing":return{...e,w:e.w*(s?.76:.88),h:e.h*.9,rot:e.rot+(s?4:1),y:e.y+3};case"awaiting":return{...e,w:e.w*.94,h:e.h*1.08,alpha:Math.min(1,e.alpha+.06),glow:e.glow+3,rot:e.rot*.3};case"done":return{...e,w:e.w*.92,h:e.h*.72,y:e.y-5,rot:e.rot*.4,alpha:Math.min(1,e.alpha+.04)};case"failed":return{...e,w:e.w*.96,h:e.h*.8,y:e.y+5,rot:e.rot+(s?5:-5),alpha:e.alpha*.88,glow:e.glow*.8};default:return e}}const H3=2e4;function U3(e){return e.pending>0?"asking":e.busy?e.newestKind==="tool"?"tools":"thinking":"none"}function W3(e="",t=""){const s=t.toLowerCase();if(s==="edit"||s==="write"||s==="patch"||s==="create")return"writing";if(s==="read"||s==="search"||s==="fetch")return"reading";if(s==="execute"||s==="run"||s==="command"||s==="terminal")return"running";const n=e.toLowerCase();return/\b(write|edit|patch|apply_patch|multi_edit|create|mkdir|delete|move|rename)\b|写入|编辑|修改/.test(n)?"writing":/\b(read|cat|head|tail|view|open|glob|grep|search|find|list|ls|tree)\b|读取|查看|搜索/.test(n)?"reading":"running"}function K3(e){if(e.pending>0)return"awaiting";if(!e.busy||e.newestKind!=="tool")return"idle";const t=String(e.newestToolStatus??"").toLowerCase();return t==="failed"||t==="error"||t==="cancelled"?"failed":t==="completed"||t==="success"?"done":W3(e.newestToolTitle,e.newestToolKind)}function q3(e,t=Math.random,s={}){if(e>L3)return s.busy?null:"rest";const n=e>P3?["lookLeft","lookRight","curious","wink","focus","calm"]:["lookLeft","lookRight","wink"];if(t()>=$3)return null;const i=n[Math.min(n.length-1,Math.floor(t()*n.length))];return{mood:i,durationMs:i==="wink"?750:1800+t()*1400}}const V3=[{mood:"happy",words:["开心","高兴","太好了","喜欢","棒","恭喜","成功","完成了","搞定","哈哈","谢谢"]},{mood:"sad",words:["抱歉","难过","遗憾","可惜","失败了","没成功","不舒服","唉"]},{mood:"surprise",words:["竟然","居然","没想到","原来","意外","真的吗"]},{mood:"curious",words:["要不要","是不是","你觉得","哪个","为什么","要我","需要我"]},{mood:"strive",words:["麻烦","麻烦你","冲突","错误","报错","卡住","超时"]}],Y3=/[不没别未无](?:有|是|会|太|要)?\s*$/;function G3(e){const t=String(e??"");if(!t)return null;let s=null;for(const{mood:n,words:i}of V3)for(const r of i){let a=t.indexOf(r);for(;a>=0;){if(!Y3.test(t.slice(Math.max(0,a-2),a))){(!s||a<s.at)&&(s={mood:n,at:a});break}a=t.indexOf(r,a+1)}}return s?.mood??null}const gk=2e4,J3=45e3,X3={neutral:"idle",happy:"happy",surprised:"surprise",inspecting:"curious",sad:"sad",sleepy:"drowsy",squinted:"focus",calm:"calm",confused:"confused",smile:"happy",inspect:"curious",strange:"curious",squint:"focus",idle:"idle",thinking:"sad",focus:"focus",angry:"strive",sleep:"sleep",joy:"happy",love:"happy",surprise:"surprise",curious:"curious",strive:"strive",shy:"wink",wink:"wink"},w_=/\[\s*(?:emo|emotion)\s*[::]\s*([a-zA-Z\u4e00-\u9fa5_-]{1,16})\s*\]/gi;function Z3(e){const t=[];for(const s of String(e??"").matchAll(w_)){const n=X3[s[1].toLowerCase()];n&&t.push(n)}return t}const Cy=/\s*\[\s*(?:emo|emotion)\s*[::]\s*[a-zA-Z\u4e00-\u9fa5_-]*\s*\]?\s*$/i,Q3=new RegExp(w_.source,"i");function Bh(e){const t=String(e??"");return!Q3.test(t)&&!Cy.test(t)?t:t.replace(w_,"").replace(Cy,"").trim()}function e5(e){return String(e??"").replace(/[ \t]{2,}/g," ").trim()}function bn(e){return e<0?0:e>1?1:e}function t5(e,t,s=.55,n=.1){const i=bn(e),r=bn(t);return bn(i+(r-i)*(r>i?s:n))}function s5(e,t){return bn(t)-bn(e)>.18&&t>.22?"tick":null}const Ey=2400,n5=4600;function i5(e=Math.random){return Ey+e()*(n5-Ey)}function r5(e=Math.random){const t=e();return{mood:t<.42?"lookLeft":t<.84?"lookRight":"wink",durationMs:300+e()*220}}function o5(e,t={}){const s=a5(e,t);return l5(s,t.substate??"idle")}function a5(e,t){const s=bn(t.level??0),n=t.breath??0,i=e==="sleep",r=e==="drowsy";switch(e){case"talking":return{r:96+s*7,sx:1+s*.03,sy:1-s*.025,dy:-1.5-s*2,rot:0};case"happy":case"wink":return{r:100,sx:1.03,sy:.97,dy:-3,rot:-4};case"surprise":return{r:104,sx:.98,sy:1.04,dy:-4,rot:0};case"sad":return{r:93,sx:1.02,sy:.94,dy:3,rot:3};case"strive":return{r:95,sx:1.05,sy:.92,dy:1,rot:-3};case"working":return{r:92,sx:1.06,sy:.9,dy:4,rot:7};case"asking":return{r:99,sx:.99,sy:1.01,dy:-1,rot:0};case"calm":return{r:100,sx:1.01,sy:.99,dy:-1,rot:-2};case"confused":return{r:96,sx:1.02,sy:.96,dy:2,rot:8};case"focus":return{r:94,sx:.98,sy:1,dy:0,rot:-5};case"drowsy":return{r:97,sx:1.02,sy:.95,dy:6,rot:6};case"sleep":return{r:95,sx:1.04,sy:.93,dy:7,rot:8};case"loading":return{r:92+(t.breath??0)*3,sx:1,sy:1,dy:0,rot:0};case"error":return{r:96,sx:1.03,sy:.96,dy:0,rot:0};default:return{r:i?95:98,sx:1+n*.006,sy:1-n*.006,dy:r?5:-n*2,rot:e==="curious"?4:e==="lookLeft"?-3:e==="lookRight"?3:0}}}function l5(e,t){switch(t){case"reading":return{...e,r:e.r-1,rot:e.rot-4,dy:e.dy+2};case"running":return{...e,r:e.r-2,sx:e.sx*.98,sy:e.sy*.96,rot:e.rot+2,dy:e.dy+3};case"writing":return{...e,r:e.r-2,sx:e.sx*1.02,sy:e.sy*.95,rot:e.rot+9,dy:e.dy+4};case"awaiting":return{...e,r:e.r+3,sy:e.sy*1.02,dy:e.dy-2,rot:e.rot*.4};case"done":return{...e,r:e.r+4,sy:e.sy*1.05,dy:e.dy-5,rot:e.rot-3};case"failed":return{...e,r:e.r-4,sy:e.sy*.94,dy:e.dy+5,rot:e.rot+3};default:return e}}const c5=6,u5=9,Vr={min:1.36,max:1.5},Kt={r:1,sx:1,sy:1,dy:0,rot:0},Ny={"listen-in":{frames:[Kt,{r:1.02,sx:1.03,sy:1.06,dy:-1.42,rot:-.6},{r:1.01,sx:.99,sy:1.02,dy:.8,rot:.35},Kt],ms:[180,260,960],ease:["out","inOut","out"]},"say-in":{frames:[Kt,{r:1.05,sx:1.05,sy:.93,dy:-1.1,rot:.2},{r:1.06,sx:.98,sy:1.08,dy:1.4,rot:-.3},Kt],ms:[120,220,1160],ease:["in","out","inOut"]},"think-turn":{frames:[Kt,{r:.99,sx:1.06,sy:.92,dy:.7,rot:-1.36},{r:1.01,sx:.98,sy:1.03,dy:-.9,rot:.5},Kt],ms:[200,700,1100],ease:["out","inOut","out"]},"tool-start":{frames:[Kt,{r:.98,sx:1.12,sy:.86,dy:1.2,rot:.3},{r:1.02,sx:.96,sy:1.06,dy:-1.42,rot:-.6},Kt],ms:[150,250,1400],ease:["in","out","inOut"]},"tool-done":{frames:[Kt,{r:1.04,sx:1,sy:1.08,dy:-1.45,rot:-1.1},{r:1.01,sx:1.03,sy:.96,dy:1.36,rot:.5},Kt],ms:[220,380,1400],ease:["out","in","out"]},"error-frown":{frames:[Kt,{r:.95,sx:1.06,sy:.92,dy:1.3,rot:-1.45},{r:.98,sx:1.02,sy:.96,dy:.7,rot:1.36},Kt],ms:[180,520,1200],ease:["out","inOut","out"]},"ask-hold":{frames:[Kt,{r:1.02,sx:.99,sy:1.02,dy:-.7,rot:1.36},{r:1.01,sx:1.02,sy:1,dy:.5,rot:1.1},Kt],ms:[260,1200,1600],ease:["out","inOut","inOut"]},"blink-pop":{frames:[Kt,{r:.99,sx:1.01,sy:.97,dy:1.4,rot:0},Kt],ms:[180,1220],ease:["out","out"]},"tool-fail":{frames:[Kt,{r:.94,sx:1.08,sy:.9,dy:1.45,rot:-.8},{r:.97,sx:.98,sy:.96,dy:.4,rot:.7},Kt],ms:[160,380,1400],ease:["out","inOut","out"]},wake:{frames:[Kt,{r:1.05,sx:.97,sy:1.06,dy:-1.45,rot:.4},{r:1,sx:1.02,sy:.98,dy:.6,rot:-.2},Kt],ms:[200,600,1800],ease:["out","inOut","out"]}};function h5(e){let t=0;for(const s of e.frames)t=Math.max(t,Math.abs(s.r-1),Math.abs(s.sx-1),Math.abs(s.sy-1),Math.abs(s.dy),Math.abs(s.rot));return t}function d5(e){const t=h5(e);if(!(t>0))return e;const s=t>Vr.max?Vr.max/t:t<Vr.min?Vr.min/t:1;return s===1?e:{...e,frames:e.frames.map(n=>({r:1+(n.r-1)*s,sx:1+(n.sx-1)*s,sy:1+(n.sy-1)*s,dy:n.dy*s,rot:n.rot*s}))}}const Ry=Object.fromEntries(Object.keys(Ny).map(e=>[e,d5(Ny[e])])),jy={"blink-pop":0,"tool-start":1,"listen-in":2,"say-in":2,"think-turn":2,wake:2,"ask-hold":3,"tool-done":4,"tool-fail":4,"error-frown":4};function f5(e){return e.ms.reduce((t,s)=>t+s,0)}const p5={linear:e=>e,in:e=>e*e*e,out:e=>1-Math.pow(1-e,3),inOut:e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2};function m5(e){const t=n=>Math.min(Vr.max,Math.max(1/Vr.max,n)),s=n=>Math.min(Vr.max,Math.max(-1.5,n));return{r:t(e.r),sx:t(e.sx),sy:t(e.sy),dy:s(e.dy),rot:s(e.rot)}}function g5(e,t){if(!Number.isFinite(t)||t<0)return null;let s=t;for(let n=0;n<e.ms.length;n++){const i=e.ms[n];if(s<=i){const r=i>0?s/i:1,a=p5[e.ease[n]??"linear"](r),l=e.frames[n],c=e.frames[n+1]??l;return m5({r:l.r+(c.r-l.r)*a,sx:l.sx+(c.sx-l.sx)*a,sy:l.sy+(c.sy-l.sy)*a,dy:l.dy+(c.dy-l.dy)*a,rot:l.rot+(c.rot-l.rot)*a})}s-=i}return null}function _5(e,t){return{r:e.r*t.r,sx:e.sx*t.sx,sy:e.sy*t.sy,dy:e.dy+t.dy*c5,rot:e.rot+t.rot*u5}}function Ty(e){switch(e.kind){case"tool":return e.status==="start"?"tool-start":e.status==="done"?"tool-done":"tool-fail";case"blink":return"blink-pop";case"think":return e.stage===0?null:"think-turn";case"mood":{const{from:t,to:s}=e;return s==="error"?"error-frown":s==="asking"?"ask-hold":s==="working"?"tool-start":s==="talking"?"say-in":s==="focus"?"think-turn":s==="curious"?t==="lookLeft"||t==="lookRight"||t==="wink"||t==="scan"?null:"listen-in":(s==="idle"||s==="happy")&&(t==="sleep"||t==="drowsy")?"wake":null}}}function ul(e,t,s,n,i=26,r=.55){const a=-2*r*i*t-i*i*(e-s),l=t+a*n;return{x:e+l*n,v:l}}const Ay={maxX:14,maxY:18};function v5(e){const t=e.elapsed??0;let s=0,n=0;switch(e.mood){case"focus":s=-.55,n=-.7;break;case"working":s=-.25,n=.85;break;case"asking":s=0,n=.1;break;case"sad":s=0,n=.8;break;case"happy":case"wink":s=.15,n=-.25;break;case"surprise":s=0,n=-.15;break;case"drowsy":case"sleep":s=0,n=.75;break;case"lookLeft":s=-.9;break;case"lookRight":s=.9;break;case"scan":s=Math.sin(t*2.2)*.9;break;case"curious":s=.35,n=-.2;break;case"calm":s=.08,n=.05;break;case"confused":s=-.4,n=-.12;break}switch(e.substate??"idle"){case"reading":s-=.35,n+=.55;break;case"running":s+=.05,n+=.75;break;case"writing":s+=.4,n+=.75;break;case"awaiting":s*=.3,n=.15;break;case"done":s+=.1,n-=.5;break;case"failed":s*=.6,n+=.65;break}return{ax:s*.7*Ay.maxX,ay:n*.7*Ay.maxY}}function y5(e){const t=(e.ax+e.side*e.sep/2)*Math.PI/180,s=e.ay*Math.PI/180;return{x:e.R*Math.sin(t),y:e.R*Math.sin(s),cos:Math.max(0,Math.cos(t)*Math.cos(s))}}function b5(e){const t=e.k??1,s=Number.isFinite(t)&&t>0?t:1,n=e.ballR,i=(n!==void 0&&Number.isFinite(n)&&n>0?n:98)*s,r=A3({mood:e.mood,leftW:e.left.w,rightW:e.right.w,ballR:e.ballR}),a=(d,p,f,m)=>{const b=y5({ax:e.gaze.ax,ay:e.gaze.ay,side:p,R:i,sep:f}),_=.55+.45*b.cos;return{x:b.x+d.x*s*.5*m,y:b.y+d.y*s,w:Math.max(2,d.w*s*d.xScale*_),cos:b.cos}},l=1.05*i,c=(d,p)=>{const f=a(e.left,-1,d,p),m=a(e.right,1,d,p);return{l:f,r:m,out:Math.max(Math.abs(f.x)+f.w/2,Math.abs(m.x)+m.w/2)}};let u=r,h=c(u,1);if(h.out>l)if(c(u,0).out<=l){let d=0,p=1;for(let f=0;f<18;f++){const m=(d+p)/2;c(u,m).out>l?p=m:d=m}h=c(u,d)}else{let d=0,p=r;for(let f=0;f<18;f++){const m=(d+p)/2;c(m,0).out>l?p=m:d=m}u=d,h=c(u,0)}return{left:h.l,right:h.r,gap:h.r.x-h.r.w/2-(h.l.x+h.l.w/2),sep:u}}const w5=e=>({phase:"idle",life:null,lifeUntil:0,nextBlinkAt:e+fk(),blinkAt:e-vm,nextBeatAt:e+pk,nextActionAt:e+gk,resting:!1,drowsy:!1,sleep:0,sleepTarget:0,phaseAt:e,warmthUntil:0,lastEventAt:e,quietSince:e,micro:null,microAt:0,microUntil:0,mood:"idle",moodAt:e,ticks:0,level:0,rawLevel:0,toolStatus:"",clip:null,clipAt:0,clipMs:0,thinkStage:0,nextSaccadeAt:e+900,ball:{r:98,sx:1,sy:1,dy:0},ballV:{r:0,sx:0,sy:0,dy:0},ballRot:0,ballRotV:0,askingSince:0,wakeUntil:0,dots:0});function x5({phase:e,activity:t,substate:s="idle",emotion:n=null,ticks:i=0,toolStatus:r="",getLevel:a,onMood:l}){const c=g.useRef(null),u=g.useRef({phase:e,activity:t,substate:s,emotion:n,ticks:i,toolStatus:r});u.current={phase:e,activity:t,substate:s,emotion:n,ticks:i,toolStatus:r};const h=g.useRef(a);h.current=a;const d=g.useRef(l);d.current=l,g.useEffect(()=>{const f=c.current;if(!f)return;const m=f.getContext("2d");if(!m)return;const b=Math.min(1.5,window.devicePixelRatio||1),_=w5(performance.now());_.ticks=u.current.ticks,_.toolStatus=u.current.toolStatus;const v=(R,N)=>{_.clip&&_.clipAt===N&&jy[R]<jy[_.clip]||(_.clip=R,_.clipAt=N,_.clipMs=f5(Ry[R]))};let y=0,w=0;const x=()=>{const R=f.getBoundingClientRect();f.width=Math.max(1,Math.round(R.width*b)),f.height=Math.max(1,Math.round(R.height*b))};x();const S=new ResizeObserver(x);S.observe(f);const E=R=>{if(y=window.requestAnimationFrame(E),R-w<33)return;w=R;const N=R/1e3,I=u.current;_.rawLevel=Math.max(0,Math.min(1,h.current()||0));const F=_.level;_.level=t5(_.level,_.rawLevel);const B=s5(F,_.level);if(B&&I.phase==="listening"&&(_.micro=B,_.microAt=R,_.microUntil=R+280,_.quietSince=R),I.phase!==_.phase&&(_.phase=I.phase,_.phaseAt=R,_.quietSince=R),I.ticks!==_.ticks&&(_.ticks=I.ticks,_.lastEventAt=R,_.quietSince=R,_.micro="tick",_.microAt=R,_.microUntil=R+260,v("tool-start",R)),I.toolStatus!==_.toolStatus){const ae=I.toolStatus.toLowerCase();_.toolStatus=I.toolStatus,ae==="completed"||ae==="success"?v("tool-done",R):ae==="failed"||ae==="error"||ae==="cancelled"?v("tool-fail",R):ae&&v("tool-start",R)}const C=I.activity!=="none"||I.phase==="thinking"||I.phase==="speaking";if(R>=_.nextBlinkAt&&(_.nextBlinkAt=R+fk(),dk.includes(_.mood)||(_.blinkAt=R,_.clip||v("blink-pop",R))),R>=_.nextBeatAt){_.nextBeatAt=R+pk;const ae=q3(R-_.quietSince,Math.random,{busy:C});ae==="rest"?(_.drowsy=!0,_.sleepTarget=1):ae&&(_.life=ae.mood,_.lifeUntil=R+ae.durationMs)}if(I.phase==="listening"&&R>=_.nextSaccadeAt&&(_.nextSaccadeAt=R+i5(),!_.life)){const ae=r5();_.life=ae.mood,_.lifeUntil=R+ae.durationMs,_.lastEventAt=R}_.life&&R>_.lifeUntil&&(_.life=null),_.drowsy&&_.sleepTarget>0&&_.sleep>=.995&&(_.drowsy=!1,_.resting=!0),_.sleep+=Math.max(-1,Math.min(1,(_.sleepTarget-_.sleep)*.06)),(_.resting||_.drowsy)&&C&&(_.resting=!1,_.drowsy=!1,_.sleepTarget=0,_.wakeUntil=R+B3,v("wake",R)),I.activity==="asking"?_.askingSince||(_.askingSince=R):_.askingSince=0;const A=R-_.lastEventAt;if(C&&A>H3&&R-_.microAt>gk){const ae=A>J3?"stretch":Math.random()<.7?"flick":"tick";_.micro=ae,_.microAt=R,_.microUntil=R+(ae==="stretch"?1400:420)}_.micro&&R>_.microUntil&&(_.micro=null);const M=z3({phase:I.phase,activity:I.activity,emotion:I.emotion,life:_.life,resting:_.resting,drowsy:_.drowsy,waking:R<_.wakeUntil,askingMs:_.askingSince?R-_.askingSince:0});if(M!==_.mood){const ae=Ty({kind:"mood",from:_.mood,to:M});_.moodAt=R;try{d.current?.(M)}catch{}M!=="sleep"&&(_.resting||_.drowsy)&&(_.resting=!1,_.drowsy=!1,_.sleepTarget=0,_.sleep=0),I.phase!=="speaking"&&(_.warmthUntil=R+Sy),_.mood=M,ae&&v(ae,R)}const H=I.phase==="thinking"&&M==="focus"?1:0;_.dots+=(H-_.dots)*.14,_.dots<.002?_.dots=0:_.dots>.998&&(_.dots=1);const D=Math.max(0,Math.min(1,(_.warmthUntil-R)/Sy)),z=(R-_.phaseAt)/1e3,T=F3(M,_.level,z,{resting:_.resting,warmth:D}),O=mk(z);if(O!==_.thinkStage&&(_.thinkStage=O,M==="focus")){const ae=Ty({kind:"think",stage:O});ae&&v(ae,R)}const K=I3(R-_.blinkAt),U=ky({mood:M,right:!1,blink:K,t:N,level:_.level,expr:T,sleep:_.sleep,substate:I.substate}),re=ky({mood:M,right:!0,blink:K,t:N,level:_.level,expr:T,sleep:_.sleep,substate:I.substate}),J=f.width,Y=f.height;m.setTransform(1,0,0,1,0,0),m.clearRect(0,0,J,Y),m.scale(b,b);const _e=J/b,xe=Y/b,fe=Math.max(.5,Math.min(3.2,Math.min(_e/260,xe/260)));let et=o5(M,{level:_.level,breath:["idle","drowsy","sleep","curious","asking","working"].includes(M)?Math.sin(N*Math.PI*2/2)*6:0,substate:I.substate});if(_.clip)if(R-_.clipAt>=_.clipMs)_.clip=null;else{const ae=g5(Ry[_.clip],R-_.clipAt);ae?et=_5(et,ae):_.clip=null}const Oe=_.clip??"";f.dataset.clip!==Oe&&(Oe?f.dataset.clip=Oe:delete f.dataset.clip),f.dataset.substate!==I.substate&&(f.dataset.substate=I.substate);const tt=_.dots>=.5?"1":"";(f.dataset.dots??"")!==tt&&(tt?f.dataset.dots=tt:delete f.dataset.dots);for(let ae=0;ae<4;ae++){const be=.008333333333333333,Be=ul(_.ball.r,_.ballV.r,et.r,be,22,.6);_.ball.r=Be.x,_.ballV.r=Be.v;const W=ul(_.ball.sx,_.ballV.sx,et.sx,be,30,.5);_.ball.sx=W.x,_.ballV.sx=W.v;const Se=ul(_.ball.sy,_.ballV.sy,et.sy,be,30,.5);_.ball.sy=Se.x,_.ballV.sy=Se.v;const He=ul(_.ball.dy,_.ballV.dy,et.dy,be,24,.62);_.ball.dy=He.x,_.ballV.dy=He.v;const q=ul(_.ballRot,_.ballRotV,et.rot,be,18,.5);_.ballRot=q.x,_.ballRotV=q.v}const Pe=_.ball.r*fe,Le=_e/2,Ee=xe/2+_.ball.dy*fe,Ae=["idle","drowsy","sleep","curious","asking","working","calm"].includes(M)?Math.sin(N*Math.PI*2/2)*6*fe:0;let Ze=0,me=0;_.micro==="tick"?me=2.5*fe:_.micro==="flick"?(Ze=4*fe,me=1.5*fe):_.micro==="stretch"&&(me=-5*fe),m.save(),m.globalAlpha=1-_.dots,m.translate(Le,Ee),m.rotate(_.ballRot*Math.PI/180),m.scale(_.ball.sx,_.ball.sy),m.beginPath(),m.arc(0,0,Pe,0,Math.PI*2),m.shadowColor="rgba(15,20,26,0.30)",m.shadowBlur=30*fe,m.shadowOffsetY=12*fe;const Ye=m.createRadialGradient(-Pe*.32,-Pe*.42,Pe*.06,0,0,Pe*1.02);Ye.addColorStop(0,"#31383f"),Ye.addColorStop(.52,"#171b20"),Ye.addColorStop(1,"#0a0c0f"),m.fillStyle=Ye,m.fill(),m.shadowBlur=0,m.shadowOffsetY=0,m.strokeStyle="rgba(255,255,255,0.12)",m.lineWidth=Math.max(1,1.6*fe),m.stroke(),m.restore(),m.save(),m.translate(Le,Ee),m.rotate(_.ballRot*Math.PI/180),m.beginPath(),m.ellipse(0,0,Pe*_.ball.sx,Pe*_.ball.sy,0,0,Math.PI*2),m.clip(),m.translate(-Le,-Ee);const de=v5({mood:M,elapsed:z,substate:I.substate}),lt=b5({mood:M,left:U,right:re,gaze:de,ballR:_.ball.r,k:fe});for(const ae of[U,re]){const Be=(ae===re?1:-1)===1?lt.right:lt.left,W=Le+Be.x+Ze,Se=Ee+Be.y+Ae*.4+me;m.save(),m.translate(W,Se),m.rotate(ae.rot*Math.PI/180),m.globalAlpha=Math.max(0,Math.min(1,ae.alpha))*(1-_.dots);const He=M==="error"?"248,113,113":M==="sad"?"190,190,200":"255,255,255";if(m.shadowColor=`rgba(${He},${Math.min(.5,.16+_.level*.2+D*.14)})`,m.shadowBlur=Math.min(ae.w*fe*.45,ae.glow*fe),m.fillStyle=`rgba(${He},1)`,m.strokeStyle=`rgba(${He},1)`,ae.shape==="x"){const q=Be.w/2,Z=Math.sin(N*24)*ae.jitter*fe;m.lineWidth=6*fe,m.beginPath(),m.moveTo(-q+Z,-q),m.lineTo(q+Z,q),m.moveTo(q+Z,-q),m.lineTo(-q+Z,q),m.stroke()}else if(ae.shape==="arc"){const q=Be.w/2;m.lineWidth=6*fe,m.beginPath(),ae.arc==="happy"?m.arc(0,q,q,Math.PI,Math.PI*2):m.arc(0,-q,q,0,Math.PI),m.stroke()}else{const q=Be.w,Z=Math.max(1,ae.h*fe*ae.yScale),ge=Math.min(q,Z)/2,P=ae.jitter?Math.sin(N*24)*ae.jitter*fe:0,le=ae.jitter?Math.cos(N*19)*ae.jitter*fe:0,je=m.createLinearGradient(0,-Z/2,0,Z/2);je.addColorStop(0,`rgba(${He},1)`),je.addColorStop(1,`rgba(${He},0.94)`),m.fillStyle=je,m.beginPath(),typeof m.roundRect=="function"?m.roundRect(-q/2+P,-Z/2+le,q,Z,ge):m.ellipse(0,0,q/2,Z/2,0,0,Math.PI*2),m.fill(),m.shadowBlur=0,m.lineWidth=1,m.strokeStyle=`rgba(${He},0.5)`,m.stroke()}m.restore()}if(m.restore(),_.dots>0){const ae=Pe*.56,be=Pe*.08,Be=Se=>Math.sin(N*Math.PI*2/1.4+Se*Math.PI*2),W=[{x:Le-ae,r:Pe*.17,tone:"109,114,120",offset:-.12},{x:Le,r:Pe*.24,tone:"13,15,18",offset:0},{x:Le+ae,r:Pe*.19,tone:"125,131,139",offset:.12}];m.save();for(const Se of W){const He=Ee+Be(Se.offset)*be,q=Se.r*(1+.04*Be(Se.offset+.25));m.globalAlpha=_.dots,m.fillStyle=`rgb(${Se.tone})`,m.shadowColor=`rgba(${Se.tone},0.28)`,m.shadowBlur=q*.9,m.beginPath(),m.arc(Se.x,He,q,0,Math.PI*2),m.fill()}m.restore()}};return y=window.requestAnimationFrame(E),()=>{window.cancelAnimationFrame(y),S.disconnect()}},[]);const p=g.useRef(e);return p.current!==e&&(p.current=e),o.jsx("canvas",{ref:c,className:"tus-face-canvas","aria-hidden":"true"})}const hl={ratio:2.6,minRms:.004,hangMs:700,rise:.3,fall:.35};function S5(e=0){return{floor:e,lastVoiceAt:-1/0,prev:Number.NaN,speech:!1}}function k5(e,t,s,n={}){const i=n.hangMs??hl.hangMs,r=e.prev;if(!Number.isFinite(t))return e.speech=s-e.lastVoiceAt<=i,e.speech;const a=Math.max(0,t);e.prev=a;const l=n.ratio??hl.ratio,c=Math.max(n.minRms??hl.minRms,e.floor*l),u=a>c,h=Number.isFinite(r)&&Math.abs(a-r)<=Math.max(.0015,a*.08);if(!u||h){const d=a<e.floor?n.fall??hl.fall:n.rise??hl.rise;e.floor=e.floor===0?a:e.floor+(a-e.floor)*d}return u&&(e.lastVoiceAt=s),e.speech=s-e.lastVoiceAt<=i,e.speech}const C5="modulepreload",E5=function(e){return"/"+e},My={},N5=function(t,s,n){let i=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");i=Promise.allSettled(s.map(c=>{if(c=E5(c),c in My)return;My[c]=!0;const u=c.endsWith(".css"),h=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${h}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":C5,u||(d.as="script"),d.crossOrigin="",d.href=c,l&&d.setAttribute("nonce",l),document.head.appendChild(d),u)return new Promise((p,f)=>{d.addEventListener("load",p),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${c}`)))})}))}function r(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return i.then(a=>{for(const l of a||[])l.status==="rejected"&&r(l.reason);return t().catch(r)})},R5=.5,j5=.35,dl=512,fl=64,T5=700;function Dy(){return{prob:-1,speech:!1,lastVoiceAt:-1/0,frames:0}}function A5(e,t,s,n=T5){return e.prob=t,t>=R5?e.lastVoiceAt=s:t<j5&&(e.lastVoiceAt=s-n-1),e.speech=s-e.lastVoiceAt<=n,e.frames+=1,e.speech}class M5{#e=null;#l=null;#i=null;#s=new Float32Array(fl);#o=[];#t=!1;#n=[];#c=0;st=Dy();get ready(){return this.#e!==null}async load(t){if(this.#e)return!0;try{const s=await N5(()=>import("./ort.wasm.bundle.min-kEi4lvn9.js"),[]);return s.env.wasm.numThreads=1,s.env.logLevel="error",this.#l=s,this.#e=await s.InferenceSession.create(t,{executionProviders:["wasm"],graphOptimizationLevel:"all"}),this.#i=new s.Tensor("float32",new Float32Array(2*1*128),[2,1,128]),!0}catch(s){return console.warn("[vad] silero unavailable, falling back to the level gate:",s?.message??s),this.#e=null,this.#l=null,!1}}reset(){this.st=Dy(),this.#s.fill(0),this.#o=[],this.#n=[],this.#l&&this.#i&&(this.#i=new this.#l.Tensor("float32",new Float32Array(2*1*128),[2,1,128]))}push(t){if(this.#e){for(let s=0;s<t.length;s++)this.#o.push(t[s]);for(;this.#o.length>=dl;){const s=new Float32Array(this.#o.splice(0,dl));this.#n.push(s),this.#n.length>2&&this.#n.shift()}this.#h()}}async#h(){if(!(this.#t||!this.#e||!this.#l||!this.#i)){this.#t=!0;try{for(;this.#n.length&&this.#e;){const t=this.#n.shift(),s=new Float32Array(fl+dl);s.set(this.#s,0),s.set(t,fl);const n=await this.#e.run({input:new this.#l.Tensor("float32",s,[1,fl+dl]),state:this.#i,sr:new this.#l.Tensor("int64",BigInt64Array.from([16000n]),[])});this.#i=n.stateN,this.#s.set(t.subarray(dl-fl));const i=Number(n.output.data[0]);A5(this.st,Number.isFinite(i)?i:0,Date.now())}}catch(t){++this.#c>=3&&(console.warn("[vad] silero run failed, falling back to the level gate:",t?.message??t),this.#e=null,this.#n=[])}finally{this.#t=!1}}}}const Io=new M5,Ac={interruptMode:"voice",bargeSensitivity:60,bargeMs:300,silenceMs:1500,minChars:3,wakePhrase:"hi, Tus"},_k=[{id:"voice",label:"语音打断",hint:"说一句就能打断它(灵敏度、持续时间在设置里调)"},{id:"keyword",label:"关键词打断",hint:"要先说出你设的那句话才算打断(设置里填),比语音打断稳、不用碰屏幕"},{id:"button",label:"按键打断",hint:"只认按钮:它说话的时候麦克风关着,不识别、不抢话——外放串音、环境吵的时候用它"}],$h={bargeSensitivity:[0,100],bargeMs:[100,1e3],silenceMs:[400,4e3],minChars:[1,20]},D5=[{key:"bargeSensitivity",label:"抢话灵敏度",show:e=>`${Math.round(e)}%`,ends:["迟钝","灵敏"],hint:"越高越容易打断它(100% 最灵敏)。手机外放容易串音,串音频繁就调低一点"},{key:"bargeMs",label:"抢话持续时间",show:e=>e>=1e3?`${(e/1e3).toFixed(1)} 秒`:`${e} 毫秒`,ends:["快","稳"],hint:"要连续这么大声才算抢话"},{key:"silenceMs",label:"说完停顿",show:e=>`${(e/1e3).toFixed(1)} 秒`,ends:["快","慢"],hint:"静音这么久就算你说完了,自动把话发出去;怕被提前截断就用「按住说话」"},{key:"minChars",label:"最少字数",show:e=>e<=1?"不限制":`${e} 字`,ends:["1","20"],hint:"自动发送时少于这个字数不发送(1 = 不限制);点一下圆球是明确指令,照发。默认 3 字,挡掉语气词和噪音"}];function I5(e){const t=Math.min(100,Math.max(0,Number(e)));return .008+.075*Math.pow(1-t/100,1.2)}const Iy={aec:.55,raw:1.4},P5=1.6;function Py(e,t,s,n,i){return e>I5(n)?t>.002?s>.002?e>s*P5:e>t*(i?Iy.aec:Iy.raw):!0:!1}const Ly=600,Oy=900,vk="agentus.call",L5=Object.keys($h);function O5(e,t){const[s,n]=$h[e],i=Number(t);return Number.isFinite(i)?Math.min(n,Math.max(s,i)):Ac[e]}function x_(e){const t={...Ac};if(!e||typeof e!="object")return t;const s=e;_k.some(n=>n.id===s.interruptMode)&&(t.interruptMode=s.interruptMode);for(const n of L5)n in s&&(t[n]=O5(n,s[n]));return"wakePhrase"in s&&(t.wakePhrase=yk(s.wakePhrase)),t}function yk(e){const t=[...String(e??"").replace(/\s+/g," ").trim()].slice(0,B5).join("");return t.replace(/[\s\p{P}\p{S}]/gu,"")===""?"":t}const B5=24;function ym(e,t){const s=i=>String(i??"").toLowerCase().replace(/[\s\p{P}\p{S}]/gu,""),n=s(t);return n?s(e).includes(n):!1}const $5=2500;function F5(e){return!(e.muted||!e.heard||!e.phrase||!e.graceOpen||!(e.heardAgoMs<=$5)||e.own&&ym(e.own,e.phrase)||!ym(e.heard,e.phrase)||e.playRms>=0&&!e.evidence)}function z5(){try{return x_(JSON.parse(localStorage.getItem(vk)??"null"))}catch{return{...Ac}}}let bc=z5();const bm=new Set;function bk(e){bc=e;try{localStorage.setItem(vk,JSON.stringify(bc))}catch{}for(const t of bm)t()}async function wk(e){const t=x_({...bc,...e});bk(t);try{const s=await fetch("/api/settings",{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({call:t})});return s.ok?(xk((await s.json()).call),""):(await s.json().catch(()=>({}))).error??`save failed (${s.status})`}catch(s){return String(s?.message??s)}}function xk(e){const t=x_(e);Object.keys(Ac).every(s=>t[s]===bc[s])||bk(t)}async function H5(){try{const e=await fetch("/api/settings",{credentials:"same-origin"});if(!e.ok)return;xk((await e.json()).call)}catch{}}function U5(){return[g.useSyncExternalStore(t=>(bm.add(t),()=>bm.delete(t)),()=>bc),t=>void wk(t)]}const W5={connecting:{core:[125,145,200],glow:"rgba(125,145,200,0.30)"},listening:{core:[56,189,248],glow:"rgba(56,189,248,0.34)"},thinking:{core:[167,139,250],glow:"rgba(167,139,250,0.30)"},speaking:{core:[251,191,36],glow:"rgba(251,191,36,0.32)"},error:{core:[248,113,113],glow:"rgba(248,113,113,0.30)"}},Po={connecting:"正在接通…",listening:"在听你说",thinking:"思考中…",speaking:"正在回答",error:"出错了"},K5=.01,By=120,q5=/^(?:Stopped waiting for another Hermes process on this session\. Your message was not processed\.|⏳? ?Another Hermes process kept this session busy too long[\s\S]*not processed[\s\S]*)$/;function $y(e){return[...e].length}const V5=1,Y5=4e3,G5=15e3,J5=45e3,X5=3e3,Fy="agentus.call.caption",zy="agentus.call.voiceMode",Hy="agentus.call.brief",Z5=g.memo(function({kind:t,who:s,text:n,current:i}){return n.trim()?o.jsxs("div",{className:`call-hm ${t}${i?" current":""}`,children:[s?o.jsx("span",{className:"call-hm-who",children:s}):null,t==="agent"||t==="user"?o.jsx(S3,{text:n}):o.jsx("span",{children:n})]}):null});function Uy(e){switch(e.kind){case"user":return{kind:"user",who:e.from?`来自「${e.from.title}」`:"你",text:e.text};case"agent":return{kind:"agent",who:"它",text:e.text};case"meta":return{kind:"meta",who:"",text:e.text};case"tool":return{kind:"tool",who:"",text:`${e.title||e.kind2||"工具"}${e.status?` · ${e.status}`:""}`};case"plan":return{kind:"tool",who:"",text:`计划:${e.items.map(t=>t.content).join(";")}`};case"thought":return{kind:"tool",who:"",text:e.text};case"note":return{kind:"meta",who:"",text:e.text};case"approval":return{kind:"meta",who:"",text:`审批:${e.title}${e.decision?e.decision.outcome==="selected"?"(已答)":"(已取消)":""}`};case"project-skills":return{kind:"meta",who:"",text:e.text}}}function Q5({sessionId:e,onClose:t,onKeyboard:s,renderTranscript:n,tus:i=!1,pending:r=0}){const[a]=go(),l=dd(),[c,u]=g.useState("connecting"),[h,d]=g.useState(!1),[p,f]=g.useState(""),[m,b]=g.useState(""),[_,v]=g.useState(0),[y,w]=g.useState(!1),[x,S]=g.useState(""),[E]=U5(),[R,N]=g.useState(!1),[I,F]=g.useState(!1),[B,C]=g.useState(!0),A=g.useRef(null),[M,H]=g.useState(()=>{try{return localStorage.getItem(Fy)==="1"}catch{return!1}}),D=g.useRef(M);D.current=M;const[z,T]=g.useState(()=>{try{return localStorage.getItem(Hy)!=="0"}catch{return!0}}),O=g.useRef(z);O.current=z;const K=()=>{const L=!z;T(L);try{localStorage.setItem(Hy,L?"1":"0")}catch{}L||Dt.current.turnEnded()},[U,re]=g.useState(()=>{try{return localStorage.getItem(zy)==="1"}catch{return!1}}),J=()=>{const L=!U;re(L);try{localStorage.setItem(zy,L?"1":"0")}catch{}},[Y,_e]=g.useState(!0),xe=g.useRef(null),[fe,et]=g.useState(""),[Oe,tt]=g.useState(null),Pe=i?{...E,interruptMode:"keyword"}:E,Le=g.useRef(Pe);Le.current=Pe;const Ee=L=>{wk(L).then(et)},Ae=g.useRef(null),Ze=g.useRef(null),me=g.useRef("connecting");me.current=c;const Ye=g.useRef(0),de=g.useRef([]),lt=g.useRef(0),ae=g.useRef(0),be=g.useRef(S5()),Be=g.useRef(0),W=g.useRef(0),Se=g.useRef(0),He=g.useRef(0),q=g.useRef(0),Z=g.useRef(""),ge=g.useRef(null),P=g.useRef(-1),le=g.useRef(0),je=g.useRef(""),Ie=g.useRef(0),Ge=g.useRef(0),ot=g.useRef(!1),dt=g.useRef(!1),[at,Q]=g.useState(!1),ke=g.useRef(!1),Ne=g.useRef([]),$e=g.useRef(!1),gt=g.useRef(0),St=g.useRef(""),Jt=g.useRef(""),dn=g.useRef(""),ye=g.useRef(!1),Dt=g.useRef(new wy),Me=g.useRef(new Set),[kt,Nn]=g.useState(""),Ts=g.useRef(Promise.resolve()),Rn=async L=>{const ce=Ts.current;let X=()=>{};Ts.current=new Promise(ue=>{X=ue}),await ce;try{await L()}finally{X()}},Un=g.useRef(""),jn=g.useRef(0),zs=g.useRef(""),Nr=g.useRef(!1),Bi=g.useRef(!1),bo=g.useRef(Date.now()),Ot=g.useRef(""),ws=g.useRef(!0),ds=g.useRef(!1);ds.current=h;const Tn=g.useSyncExternalStore(ee.subscribe,ee.getSnapshot),Rr=g.useMemo(()=>typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,[]);g.useEffect(()=>{let L=!1;l0(!0);const ce=ue=>{fetch("/api/notify/presence",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({sessionId:ue?e:null,visible:ue,call:ue})}).catch(()=>{})};return ce(!0),(async()=>{try{const ue=ee.getSnapshot(),Fe=ue.active?.info.id===e?ue.active:void 0;if(pe.cancel(),Fe?.busy){if(L)return;ke.current=!0,Bi.current=!0,St.current="",u("thinking");return}const Ut=[...Fe?.msgs??[]].reverse().find(Wt=>Wt.kind==="agent");if(zs.current=Ut?.key??"",Le.current.interruptMode!=="button"){const Wt=await pe.start(a,e);if(L)return;if(!Wt)throw new Error(pe.getSnapshot().error||"无法打开麦克风");u("listening"),Io.load("/vad/silero_vad.onnx").then(Bt=>{L||!Bt||(Io.reset(),pe.setVadTap(gi=>Io.push(gi)))})}else u("listening")}catch(ue){if(L)return;f(String(ue?.message??ue)),u("error")}})(),()=>{L=!0,pe.setVadTap(null),Io.reset(),ws.current=!1,Ft.stop(),pe.cancel(),l0(!1),ce(!1)}},[]),g.useEffect(()=>{if(!_)return;const L=window.setTimeout(()=>v(0),2600);return()=>window.clearTimeout(L)},[_]),g.useEffect(()=>{const L=window.setInterval(()=>{const ce=Le.current,X=pe.getSnapshot(),ue=pe.levelRms(),Fe=sR();P.current=Fe,Fe>.004&&He.current<=.004&&(Se.current=Date.now()),Fe>.004&&(q.current=Date.now()),He.current=Fe;const Ut=`${X.text||""} ${X.interim||""}`.trim();if(Ut!==je.current&&(je.current=Ut,le.current=Date.now()),X.error&&me.current==="listening"){f(X.error),u("error");return}if(ce.interruptMode==="button"&&(me.current==="speaking"||me.current==="thinking")){X.status!=="idle"&&!ds.current&&pe.stop(),Be.current=0,Ge.current=0;return}if(ce.interruptMode==="keyword"&&(me.current==="speaking"||me.current==="thinking")){ds.current||pe.setRelay(!0),Be.current=0;const Bt=Date.now(),gi=Ut,Dr=Math.max(W.current,Se.current),Hi=Bt-Dr>Ly&&Bt-Ie.current>Oy,Ba=Py(ue,Fe,Ge.current,ce.bargeSensitivity,r0()),Ss=F5({heard:gi,own:Z.current,heardAgoMs:Bt-le.current,phrase:ce.wakePhrase,graceOpen:Hi,evidence:Ba,playRms:Fe,muted:ds.current});if(Ss){Ie.current=Bt,pe.resetText(),Mr();return}Fe>.002&&!Ba&&!Ss&&(Ge.current=Ge.current*.88+ue*.12);return}const Wt=me.current==="listening"?Io.ready?Io.st.speech:k5(be.current,ue,Date.now()):!1;if(me.current==="listening"&&(Wt||ue>K5)&&(ae.current=Date.now()),me.current==="listening"){b((X.text+(X.interim?` ${X.interim}`:"")).trim());const Bt=(X.text||X.interim).trim();if(ce.interruptMode==="keyword"&&!ds.current&&Bt&&ym(Bt,ce.wakePhrase)){pe.resetText(),v(Date.now()),ae.current=0;return}const gi=Date.now()-ae.current;Bt&&!ds.current&&!ot.current&&!dt.current&&$y(Bt)>=ce.minChars&&gi>ce.silenceMs&&!ke.current&&(ke.current=!0,u("thinking"),b(Bt),f(""),zs.current=Ot.current,pe.setRelay(!1),ee.send({t:"prompt",sessionId:e,text:Bt,interrupt:!0}),pe.resetText())}else if(me.current==="speaking"){const Bt=Date.now(),gi=Math.max(W.current,Se.current),Dr=Bt-gi>Ly&&Bt-Ie.current>Oy,Hi=ce.interruptMode==="voice"&&!ds.current&&Dr&&Py(ue,Fe,Ge.current,ce.bargeSensitivity,r0());Dr&&!Hi&&(Ge.current=Ge.current*.88+ue*.12),Be.current=Hi?Be.current+By:0,Be.current>=ce.bargeMs&&(Be.current=0,Ie.current=Bt,Mr())}else Be.current=0},By);return()=>window.clearInterval(L)},[e]);const rt=Tn.active?.info.id===e?Tn.active:void 0,Qe=rt?.msgs??[],jr=Qe.map(L=>L.kind),Tr=jr.lastIndexOf("user"),j=jr.lastIndexOf("agent");Ot.current=j>=0?Qe[j].key??"":"";const V=j>Tr?Qe[j]:void 0,se=V?.kind==="agent"?V.text:"",ze=V?V.at??0:0,Je=V?.key??"",Ct=jr.lastIndexOf("meta"),Ue=Ct>Tr&&Qe[Ct]?.kind==="meta"?Qe[Ct].text:"",st=!!rt?.busy,Lc=Qe.reduce((L,ce)=>L+(ce.kind==="tool"?1:0),0),pi=Qe.length?Qe[Qe.length-1]:void 0,mi=(()=>{for(let L=Qe.length-1;L>=0;L--){const ce=Qe[L];if(ce.kind==="tool")return ce}})(),Sd=U3({busy:st||c==="thinking",pending:r,newestKind:pi?.kind}),$i=pi?.kind==="tool"?pi:void 0,wo=K3({busy:st||c==="thinking",pending:r,newestKind:pi?.kind,newestToolStatus:$i?.status,newestToolTitle:$i?.title,newestToolKind:$i?.kind2}),[kd,Oc]=g.useState(null),Da=(()=>{const L=Z3(se);return L.length?L[L.length-1]:G3(Bh(se))})(),xo=()=>{const L=me.current==="speaking"?a0():pe.level();return Number.isFinite(L)?Math.max(0,Math.min(1,L)):0},Ar=()=>{for(const L of Ne.current.slice(0,V5))Ft.prefetch(L,a)};g.useEffect(()=>{const L=me.current;if(L==="connecting"||L==="error"||!Je||Je===zs.current||Je&&Je===Un.current||jn.current&&ze&&ze<=jn.current)return;if(!Nr.current&&(Nr.current=!0,!zs.current&&!Bi.current&&!ke.current&&Je&&Date.now()-bo.current<X5)){zs.current=Je;return}if(q5.test(se.trim())){f("刚才那句没被处理(这个会话正被另一个 Hermes 进程占用),再说一次即可。"),As(!1);return}if(se.trim()&&(Dt.current.answerStarted(),Nn("")),Je!==St.current){const Fe=St.current;St.current=Je,Jt.current&&!ye.current&&dn.current===Fe&&(Ne.current.push(Jt.current),ye.current=!0,Ar()),gt.current=0}const{done:ce,tail:X}=C3(e5(Bh(se)));Jt.current=X,X&&(dn.current=Je),ye.current=!1;const ue=ce.slice(gt.current);ue.length&&(gt.current=ce.length,Ne.current.push(...ue),S(Fe=>`${Fe}${Fe?" ":""}${ue.join(" ")}`),me.current!=="speaking"&&u("speaking"),Ar()),!st&&X&&gt.current>=ce.length&&(gt.current=ce.length+1,ye.current=!0,Ne.current.push(X),S(Fe=>`${Fe}${Fe?" ":""}${X}`)),!st&&me.current==="thinking"&&!Ne.current.length&&ce.length===0&&!X&&(Ue&&f(Ue),As(!1))},[se,Je,st,Ue]);const[Js,Wn]=g.useState(""),Kn=g.useRef(0),fs=g.useRef(0),[Bc,So]=g.useState(!1),$c=(L=[880,1180])=>{try{const ce=window.AudioContext??window.webkitAudioContext;if(!ce)return;const X=new ce;L.forEach((ue,Fe)=>{const Ut=X.createOscillator(),Wt=X.createGain();Ut.type="sine",Ut.frequency.value=ue,Wt.gain.setValueAtTime(1e-4,X.currentTime+Fe*.16),Wt.gain.exponentialRampToValueAtTime(.16,X.currentTime+Fe*.16+.02),Wt.gain.exponentialRampToValueAtTime(1e-4,X.currentTime+Fe*.16+.15),Ut.connect(Wt).connect(X.destination),Ut.start(X.currentTime+Fe*.16),Ut.stop(X.currentTime+Fe*.16+.18)}),window.setTimeout(()=>void X.close().catch(()=>{}),800)}catch{}};g.useEffect(()=>{const L=()=>{Wu();const ue=Lh();(ue.ctxState==="running"||ue.ctxState==="unavailable")&&X()},ce=["pointerdown","touchstart","keydown","click"],X=()=>{for(const ue of ce)window.removeEventListener(ue,L,!0)};for(const ue of ce)window.addEventListener(ue,L,{capture:!0});return L(),X},[]),g.useEffect(()=>{let L=!0;return zl().then(()=>{L&&So(!0)}),()=>{L=!1}},[]),g.useEffect(()=>{const L=(st||c==="thinking")&&c!=="speaking"&&Bc&&d3();gm(L),window.__callBed=L?{playing:!0,level:.1}:{playing:!1,level:0}},[st,c,Bc]),g.useEffect(()=>()=>{gm(!1,0)},[]);const Ia=g.useRef(r);g.useEffect(()=>{const L=r>Ia.current,ce=r===0;if(Ia.current=r,L){Kn.current=Date.now(),fs.current=0,Wn(r===1?"有个操作等你批准":`有 ${r} 个操作等你批准`),$c(),An({text:r===1?"有个操作等你批准":`有 ${r} 个操作等你批准`,kind:"approval"});return}ce&&(Kn.current=0,fs.current=0,Wn(""))},[r]),g.useEffect(()=>{if(r<=0||!Kn.current)return;const L=window.__approveRemindMs??[6e4,3e5],ce=window.setInterval(()=>{const X=Date.now()-Kn.current;for(;fs.current<L.length&&X>=L[fs.current];){fs.current+=1;const ue=L[fs.current-1],Ut=`审批还挂着,${ue<6e4?`${Math.round(ue/1e3)} 秒`:ue>=3e5?"已经五分钟":`${Math.round(ue/6e4)} 分钟`}了`;Wn(Ut),$c(),An({text:Ut,kind:"approval"})}},1e3);return()=>window.clearInterval(ce)},[r]);const An=async L=>{if(!ws.current||L.kind!=="approval"&&!O.current)return;const ce=me.current;ce!=="thinking"&&ce!=="listening"||dt.current||ot.current||m||Z.current||$e.current||(Nn(L.text),await Rn(async()=>{await Ft.speak(L.text,"call",a).catch(()=>{})}))},ko=g.useRef(!1);g.useEffect(()=>{const L=Date.now();st&&!ko.current?(Dt.current=new wy,Me.current=new Set,Dt.current.turnStarted(L),Nn("")):!st&&ko.current&&(Dt.current.turnEnded(),Nn("")),ko.current=st},[st]),g.useEffect(()=>{if(!st||!O.current)return;const L=Qe[Qe.length-1];if(!L||Me.current.has(L.key))return;const ce=Date.now(),X=Dt.current;let ue=null;if(L.kind==="tool")Me.current.add(L.key),ue=X.tool(ce,L.title||L.kind2||"工具");else if(L.kind==="plan"){Me.current.add(L.key);const Fe=L.items.filter(Ut=>Ut.status==="completed").length;ue=X.plan(ce,Fe,L.items.length)}ue&&An(ue)},[Qe,st,z]),g.useEffect(()=>{if(!st||!z)return;const L=window.setInterval(()=>{const ce=Date.now(),X=Dt.current.thinking(ce)??Dt.current.tick(ce);X&&An(X)},500);return()=>window.clearInterval(L)},[st,z]),g.useEffect(()=>{me.current!=="speaking"||$e.current||($e.current=!0,(async()=>{try{for(;ws.current&&Ne.current.length&&me.current!=="error";){const L=Ne.current.shift();Ar(),W.current=Date.now(),Ge.current=0,Z.current=L;try{await Rn(()=>new Promise((ce,X)=>{ge.current=()=>X(new Error("clip abandoned")),Ft.speak(L,"call",a).then(ce,X)}))}catch{}finally{ge.current=null,Z.current=""}if(!ws.current||me.current!=="speaking")break}}catch{}finally{$e.current=!1,ws.current&&me.current==="speaking"&&!Ne.current.length&&!st&&As(!1)}})())},[c,x,st]);const Pa=g.useRef(!1);Pa.current=st;const Fi=g.useRef(l);Fi.current=l;const qn=g.useRef(0);g.useEffect(()=>{const L=window.setInterval(()=>{const ce=me.current;if(ce!=="speaking"&&ce!=="thinking"){qn.current=0;return}if(me.current==="speaking"&&Fi.current.speaking){const ue=P.current>=0,Fe=Date.now()-Math.max(q.current,W.current);if(ue?Fe>G5:Fe>J5){qn.current=0,f(Fi.current.error||(ue?"这一句卡住了(合成或播放没有响应),已跳过它继续往下念。":"这一句卡住了,已跳过它继续往下念。")),ge.current?.(),Ft.stop();return}}if(!(!$e.current&&!Ne.current.length&&!Fi.current.speaking&&!Pa.current)){qn.current=0;return}if(!qn.current){qn.current=Date.now();return}Date.now()-qn.current<Y5||(qn.current=0,Fi.current.error&&f(Fi.current.error),As(!1))},1e3);return()=>window.clearInterval(L)},[e]);const Cd=()=>{ws.current&&y_()},Mr=async()=>{Co(),await As(!1)},Co=()=>{Un.current=Ot.current||St.current,jn.current=Date.now(),Ft.stop();const L=ee.getSnapshot().sessions.find(ue=>ue.id===e)?.status==="running";L&&ee.send({t:"cancel",sessionId:e});const ce=me.current;(L||$e.current||ce==="speaking"||ce==="thinking")&&Cd(),Ne.current=[],gt.current=0,$e.current=!1,ke.current=!1,Jt.current="",dn.current="",ye.current=!0,q.current=Date.now(),pe.setRelay(!1),pe.resetText()},As=async L=>{if(ws.current&&(L&&Ft.stop(),dt.current=!1,Q(!1),Ne.current=[],gt.current=0,$e.current=!1,ke.current=!1,Jt.current="",dn.current="",ye.current=!0,q.current=Date.now(),u("listening"),S(""),b(""),ae.current=Date.now(),pe.setRelay(!1),pe.resetText(),Le.current.interruptMode!=="button"))try{const ce=pe.getSnapshot();if(ce.status==="transcribing"&&pe.cancel(),ce.status==="idle"||ce.status==="error"||ce.status==="transcribing"){if(!await pe.start(a,e))throw new Error(pe.getSnapshot().error||"无法打开麦克风");pe.setRelay(!0)}else pe.setRelay(!0)}catch(ce){f(String(ce?.message??ce)),u("error")}},La=()=>{ws.current=!1,Ft.stop(),pe.cancel(),t()},ne=async()=>{if(h){d(!1);try{await pe.start(a,e),pe.setRelay(me.current==="listening")}catch(L){f(String(L?.message??L))}return}d(!0),pe.stop()},k=async()=>{const L=me.current;if(Le.current.interruptMode==="button"){dt.current?We():await Re();return}if(L==="listening"){const ce=pe.getSnapshot(),X=(ce.text||ce.interim).trim();X&&(ke.current=!0,u("thinking"),f(""),zs.current=Ot.current,pe.setRelay(!1),ee.send({t:"prompt",sessionId:e,text:X,interrupt:!0}),pe.resetText());return}if(L==="speaking"){await Mr();return}if(L==="thinking"){await Mr();return}L==="error"&&await As(!1)},$=async()=>{if(!(ot.current||!ws.current)){ot.current=!0,w(!0),dt.current=!1,Q(!1),Co(),u("listening"),S(""),b(""),ae.current=Date.now();try{const L=pe.getSnapshot();L.status==="idle"||L.status==="error"||L.status==="transcribing"?await pe.start(a,e):pe.resetText(),pe.setRelay(!0)}catch(L){f(String(L?.message??L)),u("error")}}},te=()=>{const L=pe.getSnapshot(),ce=(L.text||L.interim).trim();ce&&(ke.current=!0,u("thinking"),b(ce),f(""),dt.current=!1,Q(!1),zs.current=Ot.current,Le.current.interruptMode==="button"?pe.cancel():pe.setRelay(!1),ee.send({t:"prompt",sessionId:e,text:ce,interrupt:!0}),pe.resetText())},oe=()=>{if(!ot.current)return;ot.current=!1,w(!1);const L=pe.getSnapshot();if(!(L.text||L.interim).trim()){if(pe.resetText(),Le.current.interruptMode==="button"){pe.cancel(),As(!1);return}pe.setRelay(!0),u("listening");return}te()},Re=async()=>{if(ws.current){ot.current=!1,w(!1),Co(),dt.current=!0,Q(!0),u("listening"),S(""),b(""),f(""),ae.current=Date.now();try{if(pe.cancel(),!await pe.start(a,e))throw new Error(pe.getSnapshot().error||"无法打开麦克风");pe.setRelay(!0)}catch(L){dt.current=!1,Q(!1),f(String(L?.message??L)),u("error")}}},We=()=>{dt.current=!1,Q(!1);const L=pe.getSnapshot();if(!(L.text||L.interim).trim()){pe.cancel(),As(!1);return}te()},Ke=g.useRef(null),ft=g.useRef({pttStart:$,pttEnd:oe,backToListening:As});ft.current={pttStart:$,pttEnd:oe,backToListening:As},g.useEffect(()=>{const L=ue=>{const Fe=ue;return!Fe||!Fe.tagName?!1:Fe.tagName==="INPUT"||Fe.tagName==="TEXTAREA"||Fe.tagName==="SELECT"||Fe.isContentEditable},ce=ue=>{ue.code!=="Space"||ue.repeat||ue.metaKey||ue.ctrlKey||ue.altKey||!ws.current||L(ue.target)||(ue.preventDefault(),!(Le.current.interruptMode==="button"&&dt.current)&&(Ke.current||(Ke.current={at:Date.now()},ft.current.pttStart())))},X=ue=>{if(ue.code!=="Space"||!Ke.current)return;const Fe=Date.now()-Ke.current.at;if(Ke.current=null,ue.preventDefault(),Fe<150){ot.current=!1,w(!1),pe.cancel(),ft.current.backToListening(!1);return}ft.current.pttEnd()};return window.addEventListener("keydown",ce),window.addEventListener("keyup",X),()=>{window.removeEventListener("keydown",ce),window.removeEventListener("keyup",X)}},[]),g.useEffect(()=>{const L=Ae.current,ce=Ze.current;if(!L||!ce)return;const X=L.getContext("2d"),ue=ce.getContext("2d");if(!X||!ue||i)return;const Fe=Math.min(2,window.devicePixelRatio||1),Ut=()=>D.current?1.25:Fe,Wt=new Float32Array(96);let Bt=0,gi=0;const Dr=()=>{const Ss=Ut(),_i=L.getBoundingClientRect();L.width=Math.max(1,Math.round(_i.width*Ss)),L.height=Math.max(1,Math.round(_i.height*Ss));const Ds=ce.getBoundingClientRect();ce.width=Math.max(1,Math.round(Ds.width*Ss)),ce.height=Math.max(1,Math.round(Ds.height*Ss))};Dr();const Hi=new ResizeObserver(Dr);Hi.observe(L),Hi.observe(ce);const Ba=Ss=>{if(Bt=window.requestAnimationFrame(Ba),D.current&&gi++&1)return;const _i=me.current,Ds=W5[_i],$a=_i==="listening"?pe.level():_i==="speaking"?Math.max(0,a0()):-1,zc=$a<0?-1:$a;Ye.current=zc<0?Ye.current*.9:zc>Ye.current?Ye.current+(zc-Ye.current)*.45:Ye.current*.88+zc*.12;const Hc=Math.min(1,Ye.current),z_=1+.05*Math.sin(Ss/1150),fn=$a<0?.22+.1*Math.sin(Ss/1150):.2+.8*Hc,Ui=Ut(),Uc=L.width/Ui,Wc=L.height/Ui;X.setTransform(Ui,0,0,Ui,0,0),X.clearRect(0,0,Uc,Wc);const Vn=Uc/2,Yn=Wc/2,MC=Math.min(Uc,Wc)*(D.current?.52:.33),Ro=Math.sin(Ss/900)*(3+14*fn),jo=Math.cos(Ss/1410)*(2+10*fn),DC=1+.05*Math.sin(Ss/770)*(.4+fn),Et=MC*(.86+.34*fn)*z_*DC,Mn=`${Ds.core[0]},${Ds.core[1]},${Ds.core[2]}`,Ir=de.current,Fa=Ss;($a>=0?Hc>.4&&Fa-lt.current>380:Fa-lt.current>1300)&&_i!=="connecting"&&(lt.current=Fa,Ir.push({born:Fa,strength:$a>=0?.6+.4*Hc:.4}),Ir.length>6&&Ir.shift()),X.globalCompositeOperation="lighter";for(let _t=0;_t<3;_t++){const ms=Ss/(2100+_t*900)+_t*Math.PI*2/3,ut=Et*(.1+.11*_t)*(.8+.5*fn),Nt=Vn+Math.cos(ms)*ut+Ro*.8,Pr=Yn+Math.sin(ms)*ut+jo*.8,Lr=Et*Math.min(1.22+.16*_t,.98*(Math.min(Uc,Wc)/2)/Et)*(.95+.2*fn),Kc=X.createRadialGradient(Nt,Pr,0,Nt,Pr,Lr);Kc.addColorStop(0,`rgba(${Mn},0.20)`),Kc.addColorStop(.45,`rgba(${Mn},0.09)`),Kc.addColorStop(1,"rgba(0,0,0,0)"),X.fillStyle=Kc,X.beginPath(),X.arc(Nt,Pr,Lr,0,Math.PI*2),X.fill()}const za=X.createRadialGradient(Vn+Ro,Yn+jo,Et*.82,Vn+Ro,Yn+jo,Et*1.42);za.addColorStop(0,`rgba(${Mn},0)`),za.addColorStop(.22,`rgba(${Mn},${.42-.16*fn})`),za.addColorStop(.6,`rgba(${Mn},${.14-.06*fn})`),za.addColorStop(1,"rgba(0,0,0,0)"),X.fillStyle=za,X.beginPath(),X.arc(Vn+Ro,Yn+jo,Et*1.42,0,Math.PI*2),X.fill();for(let _t=Ir.length-1;_t>=0;_t--){const ms=(Fa-Ir[_t].born)/(Rr?2600:1400);if(ms>=1){Ir.splice(_t,1);continue}const ut=Et*(1+ms*1.05)*z_;X.beginPath(),X.arc(Vn+Ro*.3,Yn+jo*.3,ut,0,Math.PI*2),X.strokeStyle=`rgba(${Mn},${(1-ms)*.5*Ir[_t].strength})`,X.lineWidth=1.2+2.4*(1-ms),X.stroke()}const Ha=Vn+Ro*.7,Ua=Yn+jo*.7,To=X.createRadialGradient(Ha-Et*.18,Ua-Et*.18,Et*.05,Ha,Ua,Et);To.addColorStop(0,`rgba(255,255,255,${.92-.18*fn})`),To.addColorStop(.3,`rgba(${Mn},0.92)`),To.addColorStop(.66,`rgba(${Mn},0.62)`),To.addColorStop(.88,`rgba(${Mn},0.28)`),To.addColorStop(1,`rgba(${Mn},0)`),X.fillStyle=To,X.beginPath(),X.arc(Ha,Ua,Et,0,Math.PI*2),X.fill(),X.globalCompositeOperation="source-over",X.beginPath(),X.arc(Ha,Ua,Et*.97,0,Math.PI*2),X.strokeStyle="rgba(255,255,255,0.10)",X.lineWidth=1.4,X.stroke(),X.beginPath(),X.arc(Ha,Ua,Et*.985,-2.5,-.35),X.strokeStyle=`rgba(255,255,255,${.42-.12*fn})`,X.lineWidth=2,X.lineCap="round",X.stroke();const jd=X.createRadialGradient(Vn-Et*.34,Yn-Et*.42,0,Vn-Et*.34,Yn-Et*.42,Et*.55);if(jd.addColorStop(0,"rgba(255,255,255,0.40)"),jd.addColorStop(1,"rgba(255,255,255,0)"),X.fillStyle=jd,X.beginPath(),X.arc(Vn-Et*.34,Yn-Et*.42,Et*.55,0,Math.PI*2),X.fill(),!Rr){X.globalCompositeOperation="lighter";for(let _t=0;_t<3;_t++){const ms=Ss/(1150+_t*520)+_t*2.1,ut=Et*(1.08+.11*_t),Nt=Vn+Math.cos(ms)*ut,Pr=Yn+Math.sin(ms)*ut*.95,Lr=X.createRadialGradient(Nt,Pr,0,Nt,Pr,9);Lr.addColorStop(0,`rgba(255,255,255,${.5+.4*fn})`),Lr.addColorStop(.35,`rgba(${Mn},${.4+.3*fn})`),Lr.addColorStop(1,"rgba(0,0,0,0)"),X.fillStyle=Lr,X.beginPath(),X.arc(Nt,Pr,9,0,Math.PI*2),X.fill()}}X.globalCompositeOperation="source-over";const Td=ce.width/Ui,Wi=ce.height/Ui;ue.setTransform(Ui,0,0,Ui,0,0),ue.clearRect(0,0,Td,Wi);let Ad=!1;if(_i==="listening"){const _t=pe.wave(),ms=Math.max(1,Math.floor(_t.length/Wt.length));for(let ut=0,Nt=0;ut<Wt.length;ut++,Nt+=ms)Wt[ut]=_t[Nt]??0;Ad=!0}else _i==="speaking"&&(Ad=nR(Wt));if(Ad){const _t=ut=>({x:ut/(Wt.length-1)*Td,y:Wi/2-Wt[ut]*Wi*1.35});ue.beginPath();for(let ut=0;ut<Wt.length;ut++){const Nt=_t(ut);ut?ue.lineTo(Nt.x,Nt.y):ue.moveTo(Nt.x,Nt.y)}for(let ut=Wt.length-1;ut>=0;ut--){const Nt=_t(ut);ue.lineTo(Nt.x,Wi/2-(Nt.y-Wi/2)*.35)}ue.closePath();const ms=ue.createLinearGradient(0,0,0,Wi);ms.addColorStop(0,`rgba(${Ds.core[0]},${Ds.core[1]},${Ds.core[2]},0.05)`),ms.addColorStop(.5,`rgba(${Ds.core[0]},${Ds.core[1]},${Ds.core[2]},0.30)`),ms.addColorStop(1,`rgba(${Ds.core[0]},${Ds.core[1]},${Ds.core[2]},0.05)`),ue.fillStyle=ms,ue.fill(),ue.beginPath();for(let ut=0;ut<Wt.length;ut++){const Nt=_t(ut);ut?ue.lineTo(Nt.x,Nt.y):ue.moveTo(Nt.x,Nt.y)}ue.strokeStyle=`rgba(255,255,255,${.55+.3*Hc})`,ue.lineWidth=1.7,ue.lineJoin="round",ue.lineCap="round",ue.stroke()}else ue.beginPath(),ue.moveTo(0,Wi/2),ue.lineTo(Td,Wi/2),ue.strokeStyle="rgba(255,255,255,0.07)",ue.lineWidth=1,ue.stroke()};return Bt=window.requestAnimationFrame(Ba),()=>{window.cancelAnimationFrame(Bt),Hi.disconnect()}},[Rr,i]);const xs=Qe.length?Uy(Qe[Qe.length-1]).text:"";g.useEffect(()=>{if(!I||!B)return;const L=A.current;L&&(L.scrollTop=L.scrollHeight)},[I,B,Qe.length,xs]);const Ms=()=>{const L=A.current;L&&C(L.scrollHeight-L.scrollTop-L.clientHeight<24)},zi=()=>{const L=A.current;L&&(L.scrollTop=L.scrollHeight),C(!0)},Oa=()=>{I||C(!0),F(!I)},ps=()=>{const L=!M;H(L),L&&_e(!0);try{localStorage.setItem(Fy,L?"1":"0")}catch{}},Fc=()=>{const L=xe.current;L&&_e(L.scrollHeight-L.scrollTop-L.clientHeight<28)},jC=()=>{const L=xe.current;L&&(L.scrollTop=L.scrollHeight),_e(!0)};g.useEffect(()=>{if(!M||!Y)return;const L=xe.current;L&&(L.scrollTop=L.scrollHeight)},[M,Y,Qe.length,m,x,c]);const Ed=$y(m),$_=c==="listening"&&Ed>0&&Ed<E.minChars,Nd=E.interruptMode==="keyword"?`唤醒词「${E.wakePhrase||"未设置"}」${m?` · 听到:${m.slice(-18)}`:""}`:"",Eo=c==="listening"&&_?`听到「${E.wakePhrase}」了`:c==="listening"?m?Ed<E.minChars?`太短了(少于 ${E.minChars} 字,不会自动发送)——继续说,或点一下圆球直接发送`:"点一下直接发送,或说完停一下":h?"麦克风已静音":E.interruptMode==="button"?at?"正在听你说,说完点「结束」":"点「开始说话」,或按住圆球/空格说话":Nd||"说点什么…":c==="speaking"?E.interruptMode==="voice"?"说一句就能打断它,点圆球也可以":E.interruptMode==="keyword"?`${Nd} · 说唤醒词打断`:"点「打断」就开口,说完再点「结束」":c==="thinking"?E.interruptMode==="keyword"?`${Nd} · 说唤醒词打断`:E.interruptMode==="button"?"点「打断」就开口,说完再点「结束」":"点一下停止它":"",No=c==="speaking"||c==="thinking",TC=c==="listening"&&!y&&m.trim().length>0,Rd=o.jsxs("button",{type:"button",className:`call-floor is-ptt${y?" on":""}`,onPointerDown:L=>{L.preventDefault();try{L.currentTarget.setPointerCapture(L.pointerId)}catch{}$()},onPointerUp:L=>{L.preventDefault(),oe()},onPointerCancel:()=>oe(),onLostPointerCapture:()=>oe(),onContextMenu:L=>L.preventDefault(),"aria-pressed":y,title:"按住说话,松开就发出去;按住的时候不会自动发送","aria-label":y?"松开发送":"按住说话",children:[o.jsx(Ri,{size:17}),o.jsx("span",{children:y?"松开发送":"按住说话"})]}),AC=_k.filter(L=>L.id!=="voice"||U||E.interruptMode==="voice"),F_=o.jsx("div",{className:"call-modes",role:"group","aria-label":"打断方式","data-mode":E.interruptMode,children:AC.map(L=>o.jsx("button",{type:"button",className:`call-mode-btn ${E.interruptMode===L.id?"on":""}`,"aria-pressed":E.interruptMode===L.id,title:L.hint,onClick:()=>Ee({interruptMode:L.id}),children:L.label},L.id))});return cc.createPortal(o.jsxs("div",{className:"call-mode","data-phase":c,"data-mood":i?Da:void 0,"data-face":i?kd??void 0:void 0,"data-substate":i?wo:void 0,"data-caption":M,"data-tus":i?"true":"false",role:"dialog","aria-modal":"true","aria-label":i?"Tus 模式通话":"语音通话",children:[o.jsx("button",{type:"button",className:"call-gear",onClick:()=>N(!0),"aria-label":"通话设置",title:"通话设置",children:o.jsx(Tc,{size:18})}),o.jsx("button",{type:"button",className:`call-cc-btn${M?" on":""}`,onClick:ps,"aria-pressed":M,"aria-label":M?"收起聊天记录":"显示聊天记录",title:M?"收起聊天记录":"显示聊天记录",children:o.jsx(jN,{size:18})}),!M&&!i?o.jsxs("div",{className:"call-head",children:[o.jsx("span",{className:"call-title",children:Po[c]}),o.jsx("span",{className:"call-sub",children:h?"麦克风已静音":"免提 · 语音通话"}),F_]}):null,Js&&!M?o.jsx("p",{className:"call-cue call-cue-stage call-approve","data-cue":Js,children:Js}):null,!Js&&kt&&!M?o.jsx("p",{className:"call-cue call-cue-stage","data-cue":kt,children:kt}):null,o.jsx("button",{type:"button",className:"call-orb",onClick:()=>void k(),"aria-label":`${Po[c]} — ${Eo||"点击切换"}`,title:Eo,children:o.jsx("canvas",{ref:Ae,className:"call-orb-canvas"})}),i?o.jsxs("div",{className:"call-tus-face","data-substate":wo,children:[o.jsx(x5,{phase:c,activity:Sd,substate:wo,emotion:Da,ticks:Lc,toolStatus:mi?.status??"",getLevel:xo,onMood:Oc}),o.jsxs("div",{className:"tus-face-foot",children:[o.jsx("span",{className:"tus-face-state",children:Po[c]}),i&&!E.wakePhrase?o.jsx("span",{className:"tus-face-warn",title:"Tus 模式固定用关键词打断;没设唤醒词时只有按住说话能抢话筒",children:"Tus 模式用关键词打断 · 还没设唤醒词"}):null]})]}):null,M||i?o.jsxs("div",{className:"call-cc",children:[o.jsxs("div",{className:"call-cc-head",children:[o.jsxs("button",{type:"button",className:"call-cc-state",onClick:()=>void k(),title:Eo||"点击切换","aria-label":`${Po[c]} — ${Eo||"点击切换"}`,children:[o.jsx("span",{className:"call-cc-dot","aria-hidden":"true"}),Po[c]]}),F_,o.jsxs("span",{className:"call-cc-n",children:[Qe.length," 条"]})]}),o.jsx("div",{className:"call-cc-list",ref:xe,onScroll:Fc,role:"log","aria-live":"polite",children:o.jsxs("div",{className:"call-cc-inner",children:[n&&rt?n({msgs:Qe,sid:e,backend:rt.info.backend,busy:!!rt.busy,base:rt.info.workspace||rt.info.cwd,speaking:c==="speaking"}):null,c==="listening"&&m?o.jsxs("div",{className:"msg user live",children:[o.jsx("div",{className:"role",children:"YOU"}),o.jsx("div",{className:"bubble",children:m})]}):null,Js&&!p?o.jsx("p",{className:"call-cue call-approve","data-cue":Js,children:Js}):null,!Js&&kt&&!p?o.jsx("p",{className:"call-cue","data-cue":kt,children:kt}):null,p?o.jsx("p",{className:"call-err",children:p}):null,!p&&l.error?o.jsx("p",{className:"call-err",children:l.error}):null,!p&&l.note?o.jsx("p",{className:"call-note",children:l.note}):null,!m&&!Qe.length||$_?o.jsx("p",{className:"call-hint",children:Eo}):null]})}),Y?null:o.jsx("button",{type:"button",className:"call-cc-latest",onClick:jC,children:"回到最新 ↓"}),o.jsx("div",{className:`call-floor-row${No||E.interruptMode==="button"?"":" single"}`,children:E.interruptMode==="button"?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:`call-floor is-take${at?" on":""}`,onClick:()=>{at?We():Re()},title:No?"停下它,接着说你的":at?"说完了,再点一下就发出去":"点一下开始说,说完再点一下发送;不会自己发出去","aria-label":No?"打断":at?"结束":"开始说话","aria-pressed":at,children:[No?o.jsx(xh,{size:17}):at?o.jsx(Sh,{size:17}):o.jsx(Ri,{size:17}),o.jsx("span",{children:No?"打断":at?"结束":"开始说话"})]}),Rd]}):No?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"call-floor is-take",onClick:()=>void Mr(),title:"停下它,接着说你的","aria-label":"打断",children:[o.jsx(xh,{size:17}),o.jsx("span",{children:"打断"})]}),Rd]}):TC?o.jsxs("button",{type:"button",className:"call-floor is-done",onClick:()=>te(),title:"说完了就把这句发出去,不用等它判断停顿","aria-label":"说完了",children:[o.jsx(Sh,{size:17}),o.jsx("span",{children:"说完了"})]}):Rd})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"call-lines",children:[m?o.jsx("p",{className:"call-heard",children:m}):null,x?o.jsx("p",{className:"call-reply",children:x}):null,p?o.jsx("p",{className:"call-err",children:p}):null,!p&&l.error?o.jsx("p",{className:"call-err",children:l.error}):null,!p&&l.note?o.jsx("p",{className:"call-note",children:l.note}):null,!m&&!x&&!p||$_?o.jsx("p",{className:"call-hint",children:Eo}):null]}),o.jsxs("div",{className:"call-hist","data-open":I,children:[o.jsxs("button",{type:"button",className:"call-hist-bar",onClick:Oa,"aria-expanded":I,"aria-label":I?"收起历史聊天记录":"翻阅历史聊天记录",title:I?"收起":"翻阅历史聊天记录",children:[o.jsx(RN,{size:15}),o.jsx("span",{className:"call-hist-title",children:"历史记录"}),o.jsxs("span",{className:"call-hist-n",children:[Qe.length," 条"]}),!I&&xs?o.jsx("span",{className:"call-hist-peek",children:xs.slice(0,60)}):null,o.jsx("span",{className:"call-hist-chev","aria-hidden":"true",children:o.jsx(ya,{size:14})})]}),I?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"call-hist-list",ref:A,onScroll:Ms,children:Qe.map((L,ce)=>{const X=Uy(L);return o.jsx(Z5,{kind:X.kind,who:X.who,text:X.text,current:ce===Qe.length-1&&c==="speaking"},L.key)})}),B?null:o.jsx("button",{type:"button",className:"call-hist-back",onClick:zi,children:"回到最新 ↓"})]}):null]})]}),o.jsx("canvas",{ref:Ze,className:"call-wave","aria-hidden":"true"}),o.jsxs("div",{className:"call-controls",children:[o.jsx("button",{type:"button",className:`call-btn ${h?"on":""}`,onClick:()=>void ne(),"aria-pressed":h,title:h?"打开麦克风":"静音麦克风",children:h?o.jsx(bN,{size:18}):o.jsx(Ri,{size:18})}),o.jsx("button",{type:"button",className:"call-btn hangup",onClick:La,title:"挂断","aria-label":"挂断",children:o.jsx(yN,{size:20})}),o.jsx("button",{type:"button",className:"call-btn",onClick:s,title:"改用键盘","aria-label":"改用键盘",children:o.jsx(wN,{size:18})})]}),R?o.jsx("div",{className:"call-sheet",role:"dialog","aria-label":"通话设置",children:o.jsxs("div",{className:"call-sheet-card",children:[o.jsxs("div",{className:"call-sheet-head",children:[o.jsx("span",{children:"通话设置"}),o.jsx("button",{type:"button",className:"call-sheet-x",onClick:()=>N(!1),"aria-label":"关闭设置",children:o.jsx(En,{size:16})})]}),o.jsx("p",{className:"call-sheet-note",children:fe?`保存失败:${fe}(已在本机生效)`:"调整立即生效,并保存到服务器(换设备也一样)"}),E.interruptMode==="button"?o.jsx("p",{className:"call-sheet-warn",children:"现在是「按键打断」:它说话的时候麦克风是关的 —— 不识别、不抢话,只在你说完之后才重新打开。 所以灵敏度和持续时间这会儿不起作用(切回「语音打断」就恢复)。"}):null,Pe.interruptMode==="keyword"?o.jsxs("label",{className:"call-knob",children:[o.jsxs("span",{className:"call-knob-top",children:[o.jsx("span",{className:"call-knob-name",children:"唤醒词"}),o.jsx("span",{className:"call-knob-val",children:(Oe??E.wakePhrase)||"未设置"})]}),o.jsx("input",{type:"text",value:Oe??E.wakePhrase,placeholder:"例如:小灵 / hey agent",onChange:L=>tt(L.target.value),onBlur:()=>{Oe!==null&&(Ee({wakePhrase:yk(Oe)}),tt(null))},onKeyDown:L=>{L.key==="Enter"&&L.currentTarget.blur()},"aria-label":"唤醒词"}),o.jsx("span",{className:"call-knob-hint",children:"只有听到这句话才抢话(关键词打断)。空着 = 这个模式不生效,不会误触发。 灵敏度在这一档仍然有用:它决定「多大声才算压过外放的回声」;持续时间不起作用。"})]}):null,o.jsx("p",{className:`call-sheet-echo ${cf().echoCancellation===!1?"bad":""}`,children:cf().echoCancellation===!1?"回声消除没生效:这台设备只给了原始麦克风。外放时它容易把自己当成你——用「按键打断」,或者戴耳机":cf().echoCancellation===!0?"回声消除:已生效(抢话要盖过你听到的那个声音,不会自己打断自己)":"回声消除:这台设备没报告(浏览器语音路径)——抢话按「比回复更响」判断"}),o.jsxs("label",{className:"call-check",children:[o.jsx("input",{type:"checkbox",checked:z,onChange:K,"aria-label":"干活期间报进度"}),o.jsxs("span",{children:[o.jsx("span",{className:"call-check-name",children:"干活期间报进度"}),o.jsx("span",{className:"call-check-hint",children:"它去跑工具、深思考、等计划推进的时候,隔一阵用一句话告诉你还在干什么(「我查一下」 「在跑 terminal」「第 2 步,共 5 步」)。答案一开始读就闭嘴,一轮最多三句。"})]})]}),o.jsxs("label",{className:"call-check",children:[o.jsx("input",{type:"checkbox",checked:U,onChange:J,"aria-label":"在通话页显示语音打断"}),o.jsxs("span",{children:[o.jsx("span",{className:"call-check-name",children:"在通话页显示「语音打断」"}),o.jsx("span",{className:"call-check-hint",children:"默认收起:它说一句就能打断,外放、嘈杂的房间里也最容易自己打断自己。 勾上之后它回到通话页那一排,阈值和判定跟以前一样。"})]})]}),D5.map(L=>o.jsxs("label",{className:`call-knob ${L.key==="bargeMs"?E.interruptMode!=="voice"?"off":"":E.interruptMode==="button"?"off":""}`,children:[o.jsxs("span",{className:"call-knob-top",children:[o.jsx("span",{className:"call-knob-name",children:L.label}),o.jsx("span",{className:"call-knob-val",children:L.show(E[L.key])})]}),o.jsx("input",{type:"range",min:$h[L.key][0],max:$h[L.key][1],step:L.key==="bargeSensitivity"?5:L.key==="silenceMs"?100:L.key==="minChars"?1:50,value:E[L.key],onChange:ce=>Ee({[L.key]:Number(ce.target.value)}),"aria-label":L.label,disabled:E.interruptMode!=="voice"&&L.key.startsWith("barge")}),o.jsxs("span",{className:"call-knob-ends",children:[o.jsx("span",{children:L.ends[0]}),o.jsx("span",{children:L.ends[1]})]}),o.jsx("span",{className:"call-knob-hint",children:L.hint})]},L.key)),o.jsxs("div",{className:"call-sheet-foot",children:[o.jsx("button",{type:"button",className:"call-sheet-btn",onClick:()=>Ee(Ac),children:"恢复默认"}),o.jsx("button",{type:"button",className:"call-sheet-btn primary",onClick:()=>N(!1),children:"完成"})]})]})}):null,o.jsx("p",{className:"sr-only","aria-live":"polite",children:Po[c]})]}),document.body)}function S_({size:e=22}){const t=sk();return o.jsx("img",{className:"brand-mark",src:t?"/icons/agentus-mark-inverse.svg":"/icons/agentus-mark.svg",width:e,height:Math.round(e*(880/1484)),alt:"","aria-hidden":"true",draggable:!1})}const eI=12e4;function tI(e){if(!e.visible)return!1;const t=e.idleMs??eI;return e.now-e.lastInputAt<t}const sI=6;function k_({value:e,onChange:t}){const[s,n]=g.useState(null),[i,r]=g.useState(e),[a,l]=g.useState(!1),[c,u]=g.useState(""),h=async f=>{const m=f?`?path=${encodeURIComponent(f)}`:"",b=await fetch(`/api/fs/dirs${m}`),_=await b.json().catch(()=>({}));if(!b.ok)throw new Error(_.error??`HTTP ${b.status}`);return _},d=async(f,m=!1)=>{l(!0),u("");try{const b=await h(f);if(n(b),!m)return;const _=b.recent?.[0]||b.path;if(!_)return;t(_),_!==b.path&&n(await h(_))}catch(b){u(String(b?.message??b))}finally{l(!1)}};g.useEffect(()=>{d(e||"",!e)},[]),g.useEffect(()=>{r(e)},[e]);const p=f=>{const m=f.trim();m&&(t(m),d(m))};return o.jsxs("div",{className:"wp",children:[o.jsxs("div",{className:"wp-bar",children:[o.jsx("input",{className:"wp-path",value:i,spellCheck:!1,onChange:f=>r(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),p(i))},placeholder:"~/project — Enter 选中","aria-label":"选中的工作目录"}),o.jsx("button",{className:"wp-use",disabled:a||!i.trim()||i.trim()===e,title:"选中这个目录",onClick:()=>p(i),children:"选中"}),o.jsx("button",{className:"icon-btn",title:"home","aria-label":"home",disabled:a,onClick:()=>void d(s?.home??""),children:o.jsx(vS,{size:14})}),o.jsx("button",{className:"icon-btn",title:"上一级目录","aria-label":"上一级目录",disabled:a||!s?.parent,onClick:()=>s?.parent&&void d(s.parent),children:o.jsx(bS,{size:14})})]}),s?.recent?.length?o.jsx("div",{className:"wp-recent",children:s.recent.slice(0,sI).map(f=>o.jsx("button",{className:`wp-chip ${e===f?"sel":""}`,title:`选中 ${f}`,onClick:()=>p(f),children:f.split("/").filter(Boolean).pop()??f},f))}):null,o.jsxs("div",{className:"wp-list",role:"listbox","aria-label":"folders",children:[a&&!s?o.jsx("div",{className:"wp-note",children:"loading…"}):null,c?o.jsx("div",{className:"wp-note err",children:c}):null,s?.entries.map(f=>o.jsxs("div",{role:"option","aria-selected":e===f.path,className:`wp-row ${e===f.path?"sel":""}`,onClick:()=>t(f.path),title:`选中 ${f.path}`,children:[o.jsx(co,{size:13}),o.jsx("span",{className:"wp-name",children:f.name}),o.jsx("button",{className:"wp-enter",title:`进入 ${f.name}`,"aria-label":`进入 ${f.name}`,onClick:m=>{m.stopPropagation(),d(f.path)},children:o.jsx(an,{size:13})})]},f.path)),s&&!s.entries.length&&!c?o.jsx("div",{className:"wp-note",children:"这里没有子目录 —— 点这一行就是选中它"}):null,s?.truncated?o.jsx("div",{className:"wp-note",children:"只列出前 300 项"}):null]})]})}function nI(e){const t=e.split("/").filter(Boolean);return t.length?t[t.length-1]:e}function iI({value:e,onChange:t,locked:s=!1,testId:n="ws-pill"}){const[i,r]=g.useState(!1),[a,l]=g.useState(e);return o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:`ws-pill ${e?"":"empty"} ${s?"locked":""}`,"data-testid":n,"aria-label":"工作空间",title:e||"选择这个会话在哪个目录里跑",disabled:s,onClick:()=>{l(e),r(!0)},children:[o.jsx(co,{size:14}),o.jsx("span",{className:"ws-pill-name",children:e?nI(e):"选择工作空间"}),s?null:o.jsx(ya,{size:11})]}),i?o.jsx("div",{className:"modal-bg ws-modal-bg",onClick:()=>r(!1),children:o.jsxs("div",{className:"modal ws-modal",onClick:c=>c.stopPropagation(),children:[o.jsx("h3",{children:"工作空间"}),o.jsx(k_,{value:a,onChange:c=>{t(c),r(!1)}}),o.jsx("div",{className:"row",children:o.jsx("button",{className:"cancel",onClick:()=>r(!1),children:"取消"})})]})}):null]})}/**
76
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
77
+ * @license MIT
78
+ *
79
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
80
+ * @license MIT
81
+ *
82
+ * Originally forked from (with the author's permission):
83
+ * Fabrice Bellard's javascript vt100 for jslinux:
84
+ * http://bellard.org/jslinux/
85
+ * Copyright (c) 2011 Fabrice Bellard
86
+ */var Sk=Object.defineProperty,rI=Object.getOwnPropertyDescriptor,oI=(e,t)=>{for(var s in t)Sk(e,s,{get:t[s],enumerable:!0})},Lt=(e,t,s,n)=>{for(var i=n>1?void 0:n?rI(t,s):t,r=e.length-1,a;r>=0;r--)(a=e[r])&&(i=(n?a(t,s,i):a(i))||i);return n&&i&&Sk(t,s,i),i},ve=(e,t)=>(s,n)=>t(s,n,e),Wy="Terminal input",wm={get:()=>Wy,set:e=>Wy=e},Ky="Too much output to announce, navigate to rows manually to read",xm={get:()=>Ky,set:e=>Ky=e};function aI(e){return e.replace(/\r?\n/g,"\r")}function lI(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function cI(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function uI(e,t,s,n){if(e.stopPropagation(),e.clipboardData){let i=e.clipboardData.getData("text/plain");kk(i,t,s,n)}}function kk(e,t,s,n){e=aI(e),e=lI(e,s.decPrivateModes.bracketedPasteMode&&n.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function Ck(e,t,s){let n=s.getBoundingClientRect(),i=e.clientX-n.left-10,r=e.clientY-n.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${i}px`,t.style.top=`${r}px`,t.style.zIndex="1000",t.focus()}function qy(e,t,s,n,i){Ck(e,t,s),i&&n.rightClickSelect(e),t.value=n.selectionText,t.select()}function sr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function yd(e,t=0,s=e.length){let n="";for(let i=t;i<s;++i){let r=e[i];r>65535?(r-=65536,n+=String.fromCharCode((r>>10)+55296)+String.fromCharCode(r%1024+56320)):n+=String.fromCharCode(r)}return n}var hI=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let n=0,i=0;if(this._interim){let r=e.charCodeAt(i++);56320<=r&&r<=57343?t[n++]=(this._interim-55296)*1024+r-56320+65536:(t[n++]=this._interim,t[n++]=r),this._interim=0}for(let r=i;r<s;++r){let a=e.charCodeAt(r);if(55296<=a&&a<=56319){if(++r>=s)return this._interim=a,n;let l=e.charCodeAt(r);56320<=l&&l<=57343?t[n++]=(a-55296)*1024+l-56320+65536:(t[n++]=a,t[n++]=l);continue}a!==65279&&(t[n++]=a)}return n}},dI=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let n=0,i,r,a,l,c=0,u=0;if(this.interim[0]){let p=!1,f=this.interim[0];f&=(f&224)===192?31:(f&240)===224?15:7;let m=0,b;for(;(b=this.interim[++m]&63)&&m<4;)f<<=6,f|=b;let _=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=_-m;for(;u<v;){if(u>=s)return 0;if(b=e[u++],(b&192)!==128){u--,p=!0;break}else this.interim[m++]=b,f<<=6,f|=b&63}p||(_===2?f<128?u--:t[n++]=f:_===3?f<2048||f>=55296&&f<=57343||f===65279||(t[n++]=f):f<65536||f>1114111||(t[n++]=f)),this.interim.fill(0)}let h=s-4,d=u;for(;d<s;){for(;d<h&&!((i=e[d])&128)&&!((r=e[d+1])&128)&&!((a=e[d+2])&128)&&!((l=e[d+3])&128);)t[n++]=i,t[n++]=r,t[n++]=a,t[n++]=l,d+=4;if(i=e[d++],i<128)t[n++]=i;else if((i&224)===192){if(d>=s)return this.interim[0]=i,n;if(r=e[d++],(r&192)!==128){d--;continue}if(c=(i&31)<<6|r&63,c<128){d--;continue}t[n++]=c}else if((i&240)===224){if(d>=s)return this.interim[0]=i,n;if(r=e[d++],(r&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=r,n;if(a=e[d++],(a&192)!==128){d--;continue}if(c=(i&15)<<12|(r&63)<<6|a&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[n++]=c}else if((i&248)===240){if(d>=s)return this.interim[0]=i,n;if(r=e[d++],(r&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=r,n;if(a=e[d++],(a&192)!==128){d--;continue}if(d>=s)return this.interim[0]=i,this.interim[1]=r,this.interim[2]=a,n;if(l=e[d++],(l&192)!==128){d--;continue}if(c=(i&7)<<18|(r&63)<<12|(a&63)<<6|l&63,c<65536||c>1114111)continue;t[n++]=c}}return n}},Ek="",ur=" ",Mc=class Nk{constructor(){this.fg=0,this.bg=0,this.extended=new Fh}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Nk;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Fh=class Rk{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Rk(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Sn=class jk extends Mc{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Fh,this.combinedData=""}static fromCharData(t){let s=new jk;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?sr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let n=t[1].charCodeAt(0);if(55296<=n&&n<=56319){let i=t[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(n-55296)*1024+i-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Vy="di$target",Sm="di$dependencies",Df=new Map;function fI(e){return e[Sm]||[]}function hs(e){if(Df.has(e))return Df.get(e);let t=function(s,n,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");pI(t,s,i)};return t._id=e,Df.set(e,t),t}function pI(e,t,s){t[Vy]===t?t[Sm].push({id:e,index:s}):(t[Sm]=[{id:e,index:s}],t[Vy]=t)}var $s=hs("BufferService"),Tk=hs("CoreMouseService"),yo=hs("CoreService"),mI=hs("CharsetService"),C_=hs("InstantiationService"),Ak=hs("LogService"),Fs=hs("OptionsService"),Mk=hs("OscLinkService"),gI=hs("UnicodeService"),Dc=hs("DecorationService"),km=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let n=[],i=this._optionsService.rawOptions.linkHandler,r=new Sn,a=s.getTrimmedLength(),l=-1,c=-1,u=!1;for(let h=0;h<a;h++)if(!(c===-1&&!s.hasContent(h))){if(s.loadCell(h,r),r.hasExtendedAttrs()&&r.extended.urlId)if(c===-1){c=h,l=r.extended.urlId;continue}else u=r.extended.urlId!==l;else c!==-1&&(u=!0);if(u||c!==-1&&h===a-1){let d=this._oscLinkService.getLinkData(l)?.uri;if(d){let p={start:{x:c+1,y:e},end:{x:h+(!u&&h===a-1?1:0),y:e}},f=!1;if(!i?.allowNonHttpProtocols)try{let m=new URL(d);["http:","https:"].includes(m.protocol)||(f=!0)}catch{f=!0}f||n.push({text:d,range:p,activate:(m,b)=>i?i.activate(m,b,p):_I(m,b),hover:(m,b)=>i?.hover?.(m,b,p),leave:(m,b)=>i?.leave?.(m,b,p)})}u=!1,r.hasExtendedAttrs()&&r.extended.urlId?(c=h,l=r.extended.urlId):(c=-1,l=-1)}}t(n)}};km=Lt([ve(0,$s),ve(1,Fs),ve(2,Mk)],km);function _I(e,t){if(confirm(`Do you want to navigate to ${t}?
87
+
88
+ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var bd=hs("CharSizeService"),Li=hs("CoreBrowserService"),E_=hs("MouseService"),Oi=hs("RenderService"),vI=hs("SelectionService"),Dk=hs("CharacterJoinerService"),Aa=hs("ThemeService"),Ik=hs("LinkProviderService"),yI=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Yy.isErrorNoTelemetry(e)?new Yy(e.message+`
89
+
90
+ `+e.stack):new Error(e.message+`
91
+
92
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},bI=new yI;function Ku(e){wI(e)||bI.onUnexpectedError(e)}var Cm="Canceled";function wI(e){return e instanceof xI?!0:e instanceof Error&&e.name===Cm&&e.message===Cm}var xI=class extends Error{constructor(){super(Cm),this.name=this.message}};function SI(e){return new Error(`Illegal argument: ${e}`)}var Yy=class Em extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Em)return t;let s=new Em;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Nm=class Pk extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Pk.prototype)}};function Zs(e,t=0){return e[e.length-(1+t)]}var kI;(e=>{function t(r){return r<0}e.isLessThan=t;function s(r){return r<=0}e.isLessThanOrEqual=s;function n(r){return r>0}e.isGreaterThan=n;function i(r){return r===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(kI||={});function CI(e,t){let s=this,n=!1,i;return function(){return n||(n=!0,t||(i=e.apply(s,arguments))),i}}var Lk;(e=>{function t(x){return x&&typeof x=="object"&&typeof x[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function n(){return s}e.empty=n;function*i(x){yield x}e.single=i;function r(x){return t(x)?x:i(x)}e.wrap=r;function a(x){return x||s}e.from=a;function*l(x){for(let S=x.length-1;S>=0;S--)yield x[S]}e.reverse=l;function c(x){return!x||x[Symbol.iterator]().next().done===!0}e.isEmpty=c;function u(x){return x[Symbol.iterator]().next().value}e.first=u;function h(x,S){let E=0;for(let R of x)if(S(R,E++))return!0;return!1}e.some=h;function d(x,S){for(let E of x)if(S(E))return E}e.find=d;function*p(x,S){for(let E of x)S(E)&&(yield E)}e.filter=p;function*f(x,S){let E=0;for(let R of x)yield S(R,E++)}e.map=f;function*m(x,S){let E=0;for(let R of x)yield*S(R,E++)}e.flatMap=m;function*b(...x){for(let S of x)yield*S}e.concat=b;function _(x,S,E){let R=E;for(let N of x)R=S(R,N);return R}e.reduce=_;function*v(x,S,E=x.length){for(S<0&&(S+=x.length),E<0?E+=x.length:E>x.length&&(E=x.length);S<E;S++)yield x[S]}e.slice=v;function y(x,S=Number.POSITIVE_INFINITY){let E=[];if(S===0)return[E,x];let R=x[Symbol.iterator]();for(let N=0;N<S;N++){let I=R.next();if(I.done)return[E,e.empty()];E.push(I.value)}return[E,{[Symbol.iterator](){return R}}]}e.consume=y;async function w(x){let S=[];for await(let E of x)S.push(E);return Promise.resolve(S)}e.asyncToArray=w})(Lk||={});function ho(e){if(Lk.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(n){t.push(n)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function EI(...e){return xt(()=>ho(e))}function xt(e){return{dispose:CI(()=>{e()})}}var Ok=class Bk{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ho(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Bk.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Ok.DISABLE_DISPOSED_WARNING=!1;var yr=Ok,Ve=class{constructor(){this._store=new yr,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Ve.None=Object.freeze({dispose(){}});var Ea=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Ei=typeof window=="object"?window:globalThis,Rm=class jm{constructor(t){this.element=t,this.next=jm.Undefined,this.prev=jm.Undefined}};Rm.Undefined=new Rm(void 0);var Rt=Rm,Gy=class{constructor(){this._first=Rt.Undefined,this._last=Rt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Rt.Undefined}clear(){let e=this._first;for(;e!==Rt.Undefined;){let t=e.next;e.prev=Rt.Undefined,e.next=Rt.Undefined,e=t}this._first=Rt.Undefined,this._last=Rt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new Rt(e);if(this._first===Rt.Undefined)this._first=s,this._last=s;else if(t){let i=this._last;this._last=s,s.prev=i,i.next=s}else{let i=this._first;this._first=s,s.next=i,i.prev=s}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(s))}}shift(){if(this._first!==Rt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Rt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Rt.Undefined&&e.next!==Rt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Rt.Undefined&&e.next===Rt.Undefined?(this._first=Rt.Undefined,this._last=Rt.Undefined):e.next===Rt.Undefined?(this._last=this._last.prev,this._last.next=Rt.Undefined):e.prev===Rt.Undefined&&(this._first=this._first.next,this._first.prev=Rt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Rt.Undefined;)yield e.element,e=e.next}},NI=globalThis.performance&&typeof globalThis.performance.now=="function",RI=class $k{static create(t){return new $k(t)}constructor(t){this._now=NI&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},vs;(e=>{e.None=()=>Ve.None;function t(C,A){return d(C,()=>{},0,void 0,!0,void 0,A)}e.defer=t;function s(C){return(A,M=null,H)=>{let D=!1,z;return z=C(T=>{if(!D)return z?z.dispose():D=!0,A.call(M,T)},null,H),D&&z.dispose(),z}}e.once=s;function n(C,A,M){return u((H,D=null,z)=>C(T=>H.call(D,A(T)),null,z),M)}e.map=n;function i(C,A,M){return u((H,D=null,z)=>C(T=>{A(T),H.call(D,T)},null,z),M)}e.forEach=i;function r(C,A,M){return u((H,D=null,z)=>C(T=>A(T)&&H.call(D,T),null,z),M)}e.filter=r;function a(C){return C}e.signal=a;function l(...C){return(A,M=null,H)=>{let D=EI(...C.map(z=>z(T=>A.call(M,T))));return h(D,H)}}e.any=l;function c(C,A,M,H){let D=M;return n(C,z=>(D=A(D,z),D),H)}e.reduce=c;function u(C,A){let M,H={onWillAddFirstListener(){M=C(D.fire,D)},onDidRemoveLastListener(){M?.dispose()}},D=new he(H);return A?.add(D),D.event}function h(C,A){return A instanceof Array?A.push(C):A&&A.add(C),C}function d(C,A,M=100,H=!1,D=!1,z,T){let O,K,U,re=0,J,Y={leakWarningThreshold:z,onWillAddFirstListener(){O=C(xe=>{re++,K=A(K,xe),H&&!U&&(_e.fire(K),K=void 0),J=()=>{let fe=K;K=void 0,U=void 0,(!H||re>1)&&_e.fire(fe),re=0},typeof M=="number"?(clearTimeout(U),U=setTimeout(J,M)):U===void 0&&(U=0,queueMicrotask(J))})},onWillRemoveListener(){D&&re>0&&J?.()},onDidRemoveLastListener(){J=void 0,O.dispose()}},_e=new he(Y);return T?.add(_e),_e.event}e.debounce=d;function p(C,A=0,M){return e.debounce(C,(H,D)=>H?(H.push(D),H):[D],A,void 0,!0,void 0,M)}e.accumulate=p;function f(C,A=(H,D)=>H===D,M){let H=!0,D;return r(C,z=>{let T=H||!A(z,D);return H=!1,D=z,T},M)}e.latch=f;function m(C,A,M){return[e.filter(C,A,M),e.filter(C,H=>!A(H),M)]}e.split=m;function b(C,A=!1,M=[],H){let D=M.slice(),z=C(K=>{D?D.push(K):O.fire(K)});H&&H.add(z);let T=()=>{D?.forEach(K=>O.fire(K)),D=null},O=new he({onWillAddFirstListener(){z||(z=C(K=>O.fire(K)),H&&H.add(z))},onDidAddFirstListener(){D&&(A?setTimeout(T):T())},onDidRemoveLastListener(){z&&z.dispose(),z=null}});return H&&H.add(O),O.event}e.buffer=b;function _(C,A){return(M,H,D)=>{let z=A(new y);return C(function(T){let O=z.evaluate(T);O!==v&&M.call(H,O)},void 0,D)}}e.chain=_;let v=Symbol("HaltChainable");class y{constructor(){this.steps=[]}map(A){return this.steps.push(A),this}forEach(A){return this.steps.push(M=>(A(M),M)),this}filter(A){return this.steps.push(M=>A(M)?M:v),this}reduce(A,M){let H=M;return this.steps.push(D=>(H=A(H,D),H)),this}latch(A=(M,H)=>M===H){let M=!0,H;return this.steps.push(D=>{let z=M||!A(D,H);return M=!1,H=D,z?D:v}),this}evaluate(A){for(let M of this.steps)if(A=M(A),A===v)break;return A}}function w(C,A,M=H=>H){let H=(...O)=>T.fire(M(...O)),D=()=>C.on(A,H),z=()=>C.removeListener(A,H),T=new he({onWillAddFirstListener:D,onDidRemoveLastListener:z});return T.event}e.fromNodeEventEmitter=w;function x(C,A,M=H=>H){let H=(...O)=>T.fire(M(...O)),D=()=>C.addEventListener(A,H),z=()=>C.removeEventListener(A,H),T=new he({onWillAddFirstListener:D,onDidRemoveLastListener:z});return T.event}e.fromDOMEventEmitter=x;function S(C){return new Promise(A=>s(C)(A))}e.toPromise=S;function E(C){let A=new he;return C.then(M=>{A.fire(M)},()=>{A.fire(void 0)}).finally(()=>{A.dispose()}),A.event}e.fromPromise=E;function R(C,A){return C(M=>A.fire(M))}e.forward=R;function N(C,A,M){return A(M),C(H=>A(H))}e.runAndSubscribe=N;class I{constructor(A,M){this._observable=A,this._counter=0,this._hasChanged=!1;let H={onWillAddFirstListener:()=>{A.addObserver(this)},onDidRemoveLastListener:()=>{A.removeObserver(this)}};this.emitter=new he(H),M&&M.add(this.emitter)}beginUpdate(A){this._counter++}handlePossibleChange(A){}handleChange(A,M){this._hasChanged=!0}endUpdate(A){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function F(C,A){return new I(C,A).emitter.event}e.fromObservable=F;function B(C){return(A,M,H)=>{let D=0,z=!1,T={beginUpdate(){D++},endUpdate(){D--,D===0&&(C.reportChanges(),z&&(z=!1,A.call(M)))},handlePossibleChange(){},handleChange(){z=!0}};C.addObserver(T),C.reportChanges();let O={dispose(){C.removeObserver(T)}};return H instanceof yr?H.add(O):Array.isArray(H)&&H.push(O),O}}e.fromObservableLight=B})(vs||={});var Tm=class Am{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Am._idPool++}`,Am.all.add(this)}start(t){this._stopWatch=new RI,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Tm.all=new Set,Tm._idPool=0;var jI=Tm,TI=-1,Fk=class zk{constructor(t,s,n=(zk._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=n,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,s){let n=this.threshold;if(n<=0||s<n)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=n*.5;let[r,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(r);let c=new DI(l,r);this._errorHandler(c)}return()=>{let r=this._stacks.get(t.value)||0;this._stacks.set(t.value,r-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[n,i]of this._stacks)(!t||s<i)&&(t=[n,i],s=i);return t}};Fk._idPool=1;var AI=Fk,MI=class Hk{constructor(t){this.value=t}static create(){let t=new Error;return new Hk(t.stack??"")}print(){console.warn(this.value.split(`
93
+ `).slice(2).join(`
94
+ `))}},DI=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},II=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},PI=0,If=class{constructor(e){this.value=e,this.id=PI++}},LI=2,OI,he=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new AI(e?.onListenerError??Ku,this._options?.leakWarningThreshold??TI):void 0,this._perfMon=this._options?._profName?new jI(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],c=new II(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||Ku)(c),Ve.None}if(this._disposed)return Ve.None;t&&(e=e.bind(t));let n=new If(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=MI.create(),i=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof If?(this._deliveryQueue??=new BI,this._listeners=[this._listeners,n]):this._listeners.push(n):(this._options?.onWillAddFirstListener?.(this),this._listeners=n,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=xt(()=>{i?.(),this._removeListener(n)});return s instanceof yr?s.add(r):Array.isArray(s)&&s.push(r),r},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[s]=void 0;let n=this._deliveryQueue.current===this;if(this._size*LI<=t.length){let i=0;for(let r=0;r<t.length;r++)t[r]?t[i++]=t[r]:n&&(this._deliveryQueue.end--,i<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=i}}_deliver(e,t){if(!e)return;let s=this._options?.onListenerError||Ku;if(!s){e.value(t);return}try{e.value(t)}catch(n){s(n)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof If)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},BI=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Mm=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new he,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new he,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let n=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(n,t),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let n=this.getWindowId(s);this.mapWindowIdToFullScreen.set(n,t),this._onDidChangeFullscreen.fire(n)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Mm.INSTANCE=new Mm;var N_=Mm;function $I(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}N_.INSTANCE.onDidChangeZoomLevel;function FI(e){return N_.INSTANCE.getZoomFactor(e)}N_.INSTANCE.onDidChangeFullscreen;var Ma=typeof navigator=="object"?navigator.userAgent:"",Dm=Ma.indexOf("Firefox")>=0,zI=Ma.indexOf("AppleWebKit")>=0,R_=Ma.indexOf("Chrome")>=0,HI=!R_&&Ma.indexOf("Safari")>=0;Ma.indexOf("Electron/")>=0;Ma.indexOf("Android")>=0;var Pf=!1;if(typeof Ei.matchMedia=="function"){let e=Ei.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Ei.matchMedia("(display-mode: fullscreen)");Pf=e.matches,$I(Ei,e,({matches:s})=>{Pf&&t.matches||(Pf=s)})}var sa="en",Im=!1,Pm=!1,qu=!1,Uk=!1,xu,Vu=sa,Jy=sa,UI,yi,to=globalThis,tn;typeof to.vscode<"u"&&typeof to.vscode.process<"u"?tn=to.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(tn=process);var WI=typeof tn?.versions?.electron=="string",KI=WI&&tn?.type==="renderer";if(typeof tn=="object"){Im=tn.platform==="win32",Pm=tn.platform==="darwin",qu=tn.platform==="linux",qu&&tn.env.SNAP&&tn.env.SNAP_REVISION,tn.env.CI||tn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,xu=sa,Vu=sa;let e=tn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);xu=t.userLocale,Jy=t.osLocale,Vu=t.resolvedLanguage||sa,UI=t.languagePack?.translationsConfigFile}catch{}Uk=!0}else typeof navigator=="object"&&!KI?(yi=navigator.userAgent,Im=yi.indexOf("Windows")>=0,Pm=yi.indexOf("Macintosh")>=0,(yi.indexOf("Macintosh")>=0||yi.indexOf("iPad")>=0||yi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,qu=yi.indexOf("Linux")>=0,yi?.indexOf("Mobi")>=0,Vu=globalThis._VSCODE_NLS_LANGUAGE||sa,xu=navigator.language.toLowerCase(),Jy=xu):console.error("Unable to resolve platform.");var Wk=Im,li=Pm,qI=qu,Xy=Uk,hi=yi,Gi=Vu,VI;(e=>{function t(){return Gi}e.value=t;function s(){return Gi.length===2?Gi==="en":Gi.length>=3?Gi[0]==="e"&&Gi[1]==="n"&&Gi[2]==="-":!1}e.isDefaultVariant=s;function n(){return Gi==="en"}e.isDefault=n})(VI||={});var YI=typeof to.postMessage=="function"&&!to.importScripts;(()=>{if(YI){let e=[];to.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let n=0,i=e.length;n<i;n++){let r=e[n];if(r.id===s.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return s=>{let n=++t;e.push({id:n,callback:s}),to.postMessage({vscodeScheduleAsyncWork:n},"*")}}return e=>setTimeout(e)})();var GI=!!(hi&&hi.indexOf("Chrome")>=0);hi&&hi.indexOf("Firefox")>=0;!GI&&hi&&hi.indexOf("Safari")>=0;hi&&hi.indexOf("Edg/")>=0;hi&&hi.indexOf("Android")>=0;var Lo=typeof navigator=="object"?navigator:{};Xy||document.queryCommandSupported&&document.queryCommandSupported("copy")||Lo&&Lo.clipboard&&Lo.clipboard.writeText,Xy||Lo&&Lo.clipboard&&Lo.clipboard.readText;var j_=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Lf=new j_,Zy=new j_,Qy=new j_,JI=new Array(230),Kk;(e=>{function t(l){return Lf.keyCodeToStr(l)}e.toString=t;function s(l){return Lf.strToKeyCode(l)}e.fromString=s;function n(l){return Zy.keyCodeToStr(l)}e.toUserSettingsUS=n;function i(l){return Qy.keyCodeToStr(l)}e.toUserSettingsGeneral=i;function r(l){return Zy.strToKeyCode(l)||Qy.strToKeyCode(l)}e.fromUserSettings=r;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Lf.keyCodeToStr(l)}e.toElectronAccelerator=a})(Kk||={});var XI=class qk{constructor(t,s,n,i,r){this.ctrlKey=t,this.shiftKey=s,this.altKey=n,this.metaKey=i,this.keyCode=r}equals(t){return t instanceof qk&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",n=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${t}${s}${n}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new ZI([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},ZI=class{constructor(e){if(e.length===0)throw SI("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function QI(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return Kk.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Dm)switch(t){case 59:return 85;case 60:if(qI)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(li)return 57;break}else if(zI&&(li&&t===93||!li&&t===92))return 57;return JI[t]||0}var eP=li?256:2048,tP=512,sP=1024,nP=li?2048:256,eb=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.("AltGraph"),this.keyCode=QI(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=eP),this.altKey&&(t|=tP),this.shiftKey&&(t|=sP),this.metaKey&&(t|=nP),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new XI(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},tb=new WeakMap;function iP(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var rP=class{static getSameOriginWindowChain(e){let t=tb.get(e);if(!t){t=[],tb.set(e,t);let s=e,n;do n=iP(s),n?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=n;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,n=0,i=this.getSameOriginWindowChain(e);for(let r of i){let a=r.window.deref();if(s+=a?.scrollY??0,n+=a?.scrollX??0,a===t||!r.iframeElement)break;let l=r.iframeElement.getBoundingClientRect();s+=l.top,n+=l.left}return{top:s,left:n}}},Su=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=rP.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},sb=class{constructor(e,t=0,s=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let n=!1;if(R_){let i=navigator.userAgent.match(/Chrome\/(\d+)/);n=(i?parseInt(i[1]):123)<=122}if(e){let i=e,r=e,a=e.view?.devicePixelRatio||1;if(typeof i.wheelDeltaY<"u")n?this.deltaY=i.wheelDeltaY/(120*a):this.deltaY=i.wheelDeltaY/120;else if(typeof r.VERTICAL_AXIS<"u"&&r.axis===r.VERTICAL_AXIS)this.deltaY=-r.detail/3;else if(e.type==="wheel"){let l=e;l.deltaMode===l.DOM_DELTA_LINE?Dm&&!li?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof i.wheelDeltaX<"u")HI&&Wk?this.deltaX=-(i.wheelDeltaX/120):n?this.deltaX=i.wheelDeltaX/(120*a):this.deltaX=i.wheelDeltaX/120;else if(typeof r.HORIZONTAL_AXIS<"u"&&r.axis===r.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let l=e;l.deltaMode===l.DOM_DELTA_LINE?Dm&&!li?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(n?this.deltaY=e.wheelDelta/(120*a):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Vk=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),oP;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof aP?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:vs.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Vk})})(oP||={});var aP=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Vk:(this._emitter||(this._emitter=new he),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},T_=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Nm("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Nm("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},lP=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new Nm("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let n=s.setInterval(()=>{e()},t);this.disposable=xt(()=>{s.clearInterval(n),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},cP;(e=>{async function t(n){let i,r=await Promise.all(n.map(a=>a.then(l=>l,l=>{i||(i=l)})));if(typeof i<"u")throw i;return r}e.settled=t;function s(n){return new Promise(async(i,r)=>{try{await n(i,r)}catch(a){r(a)}})}e.withAsyncBody=s})(cP||={});var nb=class gn{static fromArray(t){return new gn(s=>{s.emitMany(t)})}static fromPromise(t){return new gn(async s=>{s.emitMany(await t)})}static fromPromises(t){return new gn(async s=>{await Promise.all(t.map(async n=>s.emitOne(await n)))})}static merge(t){return new gn(async s=>{await Promise.all(t.map(async n=>{for await(let i of n)s.emitOne(i)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new he,queueMicrotask(async()=>{let n={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(t(n)),this.resolve()}catch(i){this.reject(i)}finally{n.emitOne=void 0,n.emitMany=void 0,n.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await vs.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,s){return new gn(async n=>{for await(let i of t)n.emitOne(s(i))})}map(t){return gn.map(this,t)}static filter(t,s){return new gn(async n=>{for await(let i of t)s(i)&&n.emitOne(i)})}filter(t){return gn.filter(this,t)}static coalesce(t){return gn.filter(t,s=>!!s)}coalesce(){return gn.coalesce(this)}static async toPromise(t){let s=[];for await(let n of t)s.push(n);return s}toPromise(){return gn.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};nb.EMPTY=nb.fromArray([]);var{getWindow:ii,getWindowId:uP,onDidRegisterWindow:hP}=function(){let e=new Map,t={window:Ei,disposables:new yr};e.set(Ei.vscodeWindowId,t);let s=new he,n=new he,i=new he;function r(a,l){return(typeof a=="number"?e.get(a):void 0)??(l?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:n.event,registerWindow(a){if(e.has(a.vscodeWindowId))return Ve.None;let l=new yr,c={window:a,disposables:l.add(new yr)};return e.set(a.vscodeWindowId,c),l.add(xt(()=>{e.delete(a.vscodeWindowId),n.fire(a)})),l.add(De(a,is.BEFORE_UNLOAD,()=>{i.fire(a)})),s.fire(c),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:r,getWindow(a){let l=a;if(l?.ownerDocument?.defaultView)return l.ownerDocument.defaultView.window;let c=a;return c?.view?c.view.window:Ei},getDocument(a){return ii(a).document}}}(),dP=class{constructor(e,t,s,n){this._node=e,this._type=t,this._handler=s,this._options=n||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function De(e,t,s,n){return new dP(e,t,s,n)}var ib=function(e,t,s,n){return De(e,t,s,n)},A_,fP=class extends lP{constructor(e){super(),this.defaultTarget=e&&ii(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},rb=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Ku(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,n=new Map,i=r=>{s.set(r,!1);let a=e.get(r)??[];for(t.set(r,a),e.set(r,[]),n.set(r,!0);a.length>0;)a.sort(rb.sort),a.shift().execute();n.set(r,!1)};A_=(r,a,l=0)=>{let c=uP(r),u=new rb(a,l),h=e.get(c);return h||(h=[],e.set(c,h)),h.push(u),s.get(c)||(s.set(c,!0),r.requestAnimationFrame(()=>i(c))),u}})();function pP(e){let t=e.getBoundingClientRect(),s=ii(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var is={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},mP=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=Hs(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Hs(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Hs(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Hs(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Hs(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Hs(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Hs(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Hs(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Hs(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Hs(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Hs(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=Hs(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=Hs(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Hs(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Hs(e){return typeof e=="number"?`${e}px`:e}function Hl(e){return new mP(e)}var Yk=class{constructor(){this._hooks=new yr,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,n,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=n,this._onStopCallback=i;let r=e;try{e.setPointerCapture(t),this._hooks.add(xt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{r=ii(e)}this._hooks.add(De(r,is.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(De(r,is.POINTER_UP,a=>this.stopMonitoring(!0)))}};function gP(e,t,s){let n=null,i=null;if(typeof s.value=="function"?(n="value",i=s.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(n="get",i=s.get),!i)throw new Error("not supported");let r=`$memoize$${t}`;s[n]=function(...a){return this.hasOwnProperty(r)||Object.defineProperty(this,r,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,a)}),this[r]}}var Zn;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Zn||={});var El=class Ns extends Ve{constructor(){super(),this.dispatched=!1,this.targets=new Gy,this.ignoreTargets=new Gy,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(vs.runAndSubscribe(hP,({window:t,disposables:s})=>{s.add(De(t.document,"touchstart",n=>this.onTouchStart(n),{passive:!1})),s.add(De(t.document,"touchend",n=>this.onTouchEnd(t,n))),s.add(De(t.document,"touchmove",n=>this.onTouchMove(n),{passive:!1}))},{window:Ei,disposables:this._store}))}static addTarget(t){if(!Ns.isTouchDevice())return Ve.None;Ns.INSTANCE||(Ns.INSTANCE=new Ns);let s=Ns.INSTANCE.targets.push(t);return xt(s)}static ignoreTarget(t){if(!Ns.isTouchDevice())return Ve.None;Ns.INSTANCE||(Ns.INSTANCE=new Ns);let s=Ns.INSTANCE.ignoreTargets.push(t);return xt(s)}static isTouchDevice(){return"ontouchstart"in Ei||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let n=0,i=t.targetTouches.length;n<i;n++){let r=t.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:s,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[s],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let a=this.newGestureEvent(Zn.Start,r.target);a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let n=Date.now(),i=Object.keys(this.activeTouches).length;for(let r=0,a=s.changedTouches.length;r<a;r++){let l=s.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let c=this.activeTouches[l.identifier],u=Date.now()-c.initialTimeStamp;if(u<Ns.HOLD_DELAY&&Math.abs(c.initialPageX-Zs(c.rollingPageX))<30&&Math.abs(c.initialPageY-Zs(c.rollingPageY))<30){let h=this.newGestureEvent(Zn.Tap,c.initialTarget);h.pageX=Zs(c.rollingPageX),h.pageY=Zs(c.rollingPageY),this.dispatchEvent(h)}else if(u>=Ns.HOLD_DELAY&&Math.abs(c.initialPageX-Zs(c.rollingPageX))<30&&Math.abs(c.initialPageY-Zs(c.rollingPageY))<30){let h=this.newGestureEvent(Zn.Contextmenu,c.initialTarget);h.pageX=Zs(c.rollingPageX),h.pageY=Zs(c.rollingPageY),this.dispatchEvent(h)}else if(i===1){let h=Zs(c.rollingPageX),d=Zs(c.rollingPageY),p=Zs(c.rollingTimestamps)-c.rollingTimestamps[0],f=h-c.rollingPageX[0],m=d-c.rollingPageY[0],b=[...this.targets].filter(_=>c.initialTarget instanceof Node&&_.contains(c.initialTarget));this.inertia(t,b,n,Math.abs(f)/p,f>0?1:-1,h,Math.abs(m)/p,m>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(Zn.End,c.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let n=document.createEvent("CustomEvent");return n.initEvent(t,!1,!0),n.initialTarget=s,n.tapCount=0,n}dispatchEvent(t){if(t.type===Zn.Tap){let s=new Date().getTime(),n=0;s-this._lastSetTapCountTime>Ns.CLEAR_TAP_COUNT_TIME?n=1:n=2,this._lastSetTapCountTime=s,t.tapCount=n}else(t.type===Zn.Change||t.type===Zn.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let n of this.ignoreTargets)if(n.contains(t.initialTarget))return;let s=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let i=0,r=t.initialTarget;for(;r&&r!==n;)i++,r=r.parentElement;s.push([i,n])}s.sort((n,i)=>n[0]-i[0]);for(let[n,i]of s)i.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,n,i,r,a,l,c,u){this.handle=A_(t,()=>{let h=Date.now(),d=h-n,p=0,f=0,m=!0;i+=Ns.SCROLL_FRICTION*d,l+=Ns.SCROLL_FRICTION*d,i>0&&(m=!1,p=r*i*d),l>0&&(m=!1,f=c*l*d);let b=this.newGestureEvent(Zn.Change);b.translationX=p,b.translationY=f,s.forEach(_=>_.dispatchEvent(b)),m||this.inertia(t,s,h,i,r,a+p,l,c,u+f)})}onTouchMove(t){let s=Date.now();for(let n=0,i=t.changedTouches.length;n<i;n++){let r=t.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn("end of an UNKNOWN touch",r);continue}let a=this.activeTouches[r.identifier],l=this.newGestureEvent(Zn.Change,a.initialTarget);l.translationX=r.pageX-Zs(a.rollingPageX),l.translationY=r.pageY-Zs(a.rollingPageY),l.pageX=r.pageX,l.pageY=r.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(r.pageX),a.rollingPageY.push(r.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};El.SCROLL_FRICTION=-.005,El.HOLD_DELAY=700,El.CLEAR_TAP_COUNT_TIME=400,Lt([gP],El,"isTouchDevice",1);var _P=El,M_=class extends Ve{onclick(e,t){this._register(De(e,is.CLICK,s=>t(new Su(ii(e),s))))}onmousedown(e,t){this._register(De(e,is.MOUSE_DOWN,s=>t(new Su(ii(e),s))))}onmouseover(e,t){this._register(De(e,is.MOUSE_OVER,s=>t(new Su(ii(e),s))))}onmouseleave(e,t){this._register(De(e,is.MOUSE_LEAVE,s=>t(new Su(ii(e),s))))}onkeydown(e,t){this._register(De(e,is.KEY_DOWN,s=>t(new eb(s))))}onkeyup(e,t){this._register(De(e,is.KEY_UP,s=>t(new eb(s))))}oninput(e,t){this._register(De(e,is.INPUT,t))}onblur(e,t){this._register(De(e,is.BLUR,t))}onfocus(e,t){this._register(De(e,is.FOCUS,t))}onchange(e,t){this._register(De(e,is.CHANGE,t))}ignoreGesture(e){return _P.ignoreTarget(e)}},ob=11,vP=class extends M_{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=ob+"px",this.domNode.style.height=ob+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Yk),this._register(ib(this.bgDomNode,is.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(ib(this.domNode,is.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new fP),this._pointerdownScheduleRepeatTimer=this._register(new T_)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ii(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},yP=class Lm{constructor(t,s,n,i,r,a,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,n=n|0,i=i|0,r=r|0,a=a|0,l=l|0),this.rawScrollLeft=i,this.rawScrollTop=l,s<0&&(s=0),i+s>n&&(i=n-s),i<0&&(i=0),r<0&&(r=0),l+r>a&&(l=a-r),l<0&&(l=0),this.width=s,this.scrollWidth=n,this.scrollLeft=i,this.height=r,this.scrollHeight=a,this.scrollTop=l}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new Lm(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Lm(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let n=this.width!==t.width,i=this.scrollWidth!==t.scrollWidth,r=this.scrollLeft!==t.scrollLeft,a=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,c=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:i,scrollLeftChanged:r,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:c}}},bP=class extends Ve{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new yP(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let n;t?n=new lb(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):n=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=n}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=lb.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},ab=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function Of(e,t){let s=t-e;return function(n){return e+s*SP(n)}}function wP(e,t,s){return function(n){return n<s?e(n/s):t((n-s)/(1-s))}}var lb=class Om{constructor(t,s,n,i){this.from=t,this.to=s,this.duration=i,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,n){if(Math.abs(t-s)>2.5*n){let i,r;return t<s?(i=t+.75*n,r=s-.75*n):(i=t-.75*n,r=s+.75*n),wP(Of(t,i),Of(r,s),.33)}return Of(t,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let s=(t-this.startTime)/this.duration;if(s<1){let n=this.scrollLeft(s),i=this.scrollTop(s);return new ab(n,i,!1)}return new ab(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,n){return Om.start(t,s,n)}static start(t,s,n){n=n+10;let i=Date.now()-10;return new Om(t,s,i,n)}};function xP(e){return Math.pow(e,3)}function SP(e){return 1-xP(1-e)}var kP=class extends Ve{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new T_)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},CP=140,Gk=class extends M_{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new kP(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Yk),this._shouldRender=!0,this.domNode=Hl(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(De(this.domNode.domNode,is.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new vP(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,n){this.slider=Hl(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof n=="number"&&this.slider.setHeight(n),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(De(this.slider.domNode,is.POINTER_DOWN,i=>{i.button===0&&(i.preventDefault(),this._sliderPointerDown(i))})),this.onclick(this.slider.domNode,i=>{i.leftButton&&i.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),n=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);s<=i&&i<=n?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let i=pP(this.domNode.domNode);t=e.pageX-i.left,s=e.pageY-i.top}let n=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),n=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{let r=this._sliderOrthogonalPointerPosition(i),a=Math.abs(r-s);if(Wk&&a>CP){this._setDesiredScrollPositionNow(n.getScrollPosition());return}let l=this._sliderPointerPosition(i)-t;this._setDesiredScrollPositionNow(n.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Jk=class Bm{constructor(t,s,n,i,r,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(t),this._visibleSize=i,this._scrollSize=r,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Bm(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,n,i,r){let a=Math.max(0,n-t),l=Math.max(0,a-2*s),c=i>0&&i>n;if(!c)return{computedAvailableSize:Math.round(a),computedIsNeeded:c,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let u=Math.round(Math.max(20,Math.floor(n*l/i))),h=(l-u)/(i-n),d=r*h;return{computedAvailableSize:Math.round(a),computedIsNeeded:c,computedSliderSize:Math.round(u),computedSliderRatio:h,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=Bm._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,n=this._scrollPosition;return s<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},EP=class extends Gk{constructor(e,t,s){let n=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new Jk(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,n.width,n.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},NP=class extends Gk{constructor(e,t,s){let n=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new Jk(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,n.height,n.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},RP=500,cb=50,jP=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},$m=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,s=0,n=1,i=this._rear;do{let r=i===this._front?t:Math.pow(2,-n);if(t-=r,s+=this._memory[i].score*r,i===this._front)break;i=(this._capacity+i-1)%this._capacity,n++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(R_){let s=ii(t.browserEvent),n=FI(s);this.accept(Date.now(),t.deltaX*n,t.deltaY*n)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,n){let i=null,r=new jP(t,s,n);this._front===-1&&this._rear===-1?(this._memory[0]=r,this._front=0,this._rear=0):(i=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=r),r.score=this._computeScore(r,i)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(n+=.25),s){let i=Math.abs(t.deltaX),r=Math.abs(t.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),c=Math.max(Math.min(i,a),1),u=Math.max(Math.min(r,l),1),h=Math.max(i,a),d=Math.max(r,l);h%c===0&&d%u===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};$m.INSTANCE=new $m;var TP=$m,AP=class extends M_{constructor(e,t,s){super(),this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new he),this.onWillScroll=this._onWillScroll.event,this._options=DP(t),this._scrollable=s,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let n={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new NP(this._scrollable,this._options,n)),this._horizontalScrollbar=this._register(new EP(this._scrollable,this._options,n)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Hl(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Hl(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Hl(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new T_),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ho(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,li&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new sb(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ho(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new sb(s))};this._mouseWheelToDispose.push(De(this._listenOnDomNode,is.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=TP.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let i=e.deltaY*this._options.mouseWheelScrollSensitivity,r=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&r+i===0?r=i=0:Math.abs(i)>=Math.abs(r)?r=0:i=0),this._options.flipAxes&&([i,r]=[r,i]);let a=!li&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!r&&(r=i,i=0),e.browserEvent&&e.browserEvent.altKey&&(r=r*this._options.fastScrollSensitivity,i=i*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),c={};if(i){let u=cb*i,h=l.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,h)}if(r){let u=cb*r,h=l.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(c,h)}c=this._scrollable.validateScrollPosition(c),(l.scrollLeft!==c.scrollLeft||l.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let n=s;!n&&this._options.alwaysConsumeMouseWheel&&(n=!0),!n&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(n=!0),n&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,n=s?" left":"",i=t?" top":"",r=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${n}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${r}${i}${n}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),RP)}},MP=class extends AP{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function DP(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,li&&(t.className+=" mac"),t}var Fm=class extends Ve{constructor(e,t,s,n,i,r,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new he),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new bP({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:u=>A_(n.window,u)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new MP(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(u=>{this._scrollableElement.updateOptions({handleMouseWheel:!(u&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(vs.runAndSubscribe(r.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=r.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(xt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=n.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(xt(()=>this._styleElement.remove())),this._register(vs.runAndSubscribe(r.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${r.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${r.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${r.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
95
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(u=>this._handleScroll(u)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Fm=Lt([ve(2,$s),ve(3,Li),ve(4,Tk),ve(5,Aa),ve(6,Fs),ve(7,Oi)],Fm);var zm=class extends Ve{constructor(e,t,s,n,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=n,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(r=>this._removeDecoration(r))),this._register(xt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};zm=Lt([ve(1,$s),ve(2,Li),ve(3,Dc),ve(4,Oi)],zm);var IP=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Jn={full:0,left:0,center:0,right:0},Ji={full:0,left:0,center:0,right:0},pl={full:0,left:0,center:0,right:0},zh=class extends Ve{constructor(e,t,s,n,i,r,a,l){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=n,this._renderService=i,this._optionsService=r,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new IP,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(xt(()=>this._canvas?.remove()));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Ji.full=this._canvas.width,Ji.left=e,Ji.center=t,Ji.right=e,this._refreshDrawHeightConstants(),pl.full=1,pl.left=1,pl.center=1+Ji.left,pl.right=1+Ji.left+Ji.center}_refreshDrawHeightConstants(){Jn.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Jn.left=t,Jn.center=t,Jn.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Jn.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Jn.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Jn.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Jn.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(pl[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Jn[e.position||"full"]/2),Ji[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Jn[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};zh=Lt([ve(2,$s),ve(3,Dc),ve(4,Oi),ve(5,Fs),ve(6,Aa),ve(7,Li)],zh);var G;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
96
+ `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(G||={});var Yu;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(Yu||={});var Xk;(e=>e.ST=`${G.ESC}\\`)(Xk||={});var Hm=class{constructor(e,t,s,n,i,r){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=n,this._coreService=i,this._renderService=r,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${G.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,i=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=i+"px",this._compositionView.style.top=n+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let r=this._compositionView.getBoundingClientRect();this._textarea.style.left=i+"px",this._textarea.style.top=n+"px",this._textarea.style.width=Math.max(r.width,1)+"px",this._textarea.style.height=Math.max(r.height,1)+"px",this._textarea.style.lineHeight=r.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Hm=Lt([ve(2,$s),ve(3,Fs),ve(4,yo),ve(5,Oi)],Hm);var os=0,as=0,ls=0,It=0,ub={css:"#00000000",rgba:0},Vt;(e=>{function t(i,r,a,l){return l!==void 0?`#${Br(i)}${Br(r)}${Br(a)}${Br(l)}`:`#${Br(i)}${Br(r)}${Br(a)}`}e.toCss=t;function s(i,r,a,l=255){return(i<<24|r<<16|a<<8|l)>>>0}e.toRgba=s;function n(i,r,a,l){return{css:e.toCss(i,r,a,l),rgba:e.toRgba(i,r,a,l)}}e.toColor=n})(Vt||={});var yt;(e=>{function t(c,u){if(It=(u.rgba&255)/255,It===1)return{css:u.css,rgba:u.rgba};let h=u.rgba>>24&255,d=u.rgba>>16&255,p=u.rgba>>8&255,f=c.rgba>>24&255,m=c.rgba>>16&255,b=c.rgba>>8&255;os=f+Math.round((h-f)*It),as=m+Math.round((d-m)*It),ls=b+Math.round((p-b)*It);let _=Vt.toCss(os,as,ls),v=Vt.toRgba(os,as,ls);return{css:_,rgba:v}}e.blend=t;function s(c){return(c.rgba&255)===255}e.isOpaque=s;function n(c,u,h){let d=Gu.ensureContrastRatio(c.rgba,u.rgba,h);if(d)return Vt.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=n;function i(c){let u=(c.rgba|255)>>>0;return[os,as,ls]=Gu.toChannels(u),{css:Vt.toCss(os,as,ls),rgba:u}}e.opaque=i;function r(c,u){return It=Math.round(u*255),[os,as,ls]=Gu.toChannels(c.rgba),{css:Vt.toCss(os,as,ls,It),rgba:Vt.toRgba(os,as,ls,It)}}e.opacity=r;function a(c,u){return It=c.rgba&255,r(c,It*u/255)}e.multiplyOpacity=a;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}e.toColorRGB=l})(yt||={});var jt;(e=>{let t,s;try{let i=document.createElement("canvas");i.width=1,i.height=1;let r=i.getContext("2d",{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function n(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return os=parseInt(i.slice(1,2).repeat(2),16),as=parseInt(i.slice(2,3).repeat(2),16),ls=parseInt(i.slice(3,4).repeat(2),16),Vt.toColor(os,as,ls);case 5:return os=parseInt(i.slice(1,2).repeat(2),16),as=parseInt(i.slice(2,3).repeat(2),16),ls=parseInt(i.slice(3,4).repeat(2),16),It=parseInt(i.slice(4,5).repeat(2),16),Vt.toColor(os,as,ls,It);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let r=i.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return os=parseInt(r[1]),as=parseInt(r[2]),ls=parseInt(r[3]),It=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),Vt.toColor(os,as,ls,It);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=i,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[os,as,ls,It]=t.getImageData(0,0,1,1).data,It!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Vt.toRgba(os,as,ls,It),css:i}}e.toColor=n})(jt||={});var Is;(e=>{function t(n){return s(n>>16&255,n>>8&255,n&255)}e.relativeLuminance=t;function s(n,i,r){let a=n/255,l=i/255,c=r/255,u=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),h=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),d=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return u*.2126+h*.7152+d*.0722}e.relativeLuminance2=s})(Is||={});var Gu;(e=>{function t(a,l){if(It=(l&255)/255,It===1)return l;let c=l>>24&255,u=l>>16&255,h=l>>8&255,d=a>>24&255,p=a>>16&255,f=a>>8&255;return os=d+Math.round((c-d)*It),as=p+Math.round((u-p)*It),ls=f+Math.round((h-f)*It),Vt.toRgba(os,as,ls)}e.blend=t;function s(a,l,c){let u=Is.relativeLuminance(a>>8),h=Is.relativeLuminance(l>>8);if(vi(u,h)<c){if(h<u){let f=n(a,l,c),m=vi(u,Is.relativeLuminance(f>>8));if(m<c){let b=i(a,l,c),_=vi(u,Is.relativeLuminance(b>>8));return m>_?f:b}return f}let d=i(a,l,c),p=vi(u,Is.relativeLuminance(d>>8));if(p<c){let f=n(a,l,c),m=vi(u,Is.relativeLuminance(f>>8));return p>m?d:f}return d}}e.ensureContrastRatio=s;function n(a,l,c){let u=a>>24&255,h=a>>16&255,d=a>>8&255,p=l>>24&255,f=l>>16&255,m=l>>8&255,b=vi(Is.relativeLuminance2(p,f,m),Is.relativeLuminance2(u,h,d));for(;b<c&&(p>0||f>0||m>0);)p-=Math.max(0,Math.ceil(p*.1)),f-=Math.max(0,Math.ceil(f*.1)),m-=Math.max(0,Math.ceil(m*.1)),b=vi(Is.relativeLuminance2(p,f,m),Is.relativeLuminance2(u,h,d));return(p<<24|f<<16|m<<8|255)>>>0}e.reduceLuminance=n;function i(a,l,c){let u=a>>24&255,h=a>>16&255,d=a>>8&255,p=l>>24&255,f=l>>16&255,m=l>>8&255,b=vi(Is.relativeLuminance2(p,f,m),Is.relativeLuminance2(u,h,d));for(;b<c&&(p<255||f<255||m<255);)p=Math.min(255,p+Math.ceil((255-p)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),b=vi(Is.relativeLuminance2(p,f,m),Is.relativeLuminance2(u,h,d));return(p<<24|f<<16|m<<8|255)>>>0}e.increaseLuminance=i;function r(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=r})(Gu||={});function Br(e){let t=e.toString(16);return t.length<2?"0"+t:t}function vi(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var PP=class extends Mc{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Hh=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Sn}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],n=t.translateToString(!0),i=0,r=0,a=0,l=t.getFg(0),c=t.getBg(0);for(let u=0;u<t.getTrimmedLength();u++)if(t.loadCell(u,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==c){if(u-i>1){let h=this._getJoinedRanges(n,a,r,t,i);for(let d=0;d<h.length;d++)s.push(h[d])}i=u,a=r,l=this._workCell.fg,c=this._workCell.bg}r+=this._workCell.getChars().length||ur.length}if(this._bufferService.cols-i>1){let u=this._getJoinedRanges(n,a,r,t,i);for(let h=0;h<u.length;h++)s.push(u[h])}return s}_getJoinedRanges(e,t,s,n,i){let r=e.substring(t,s),a=[];try{a=this._characterJoiners[0].handler(r)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let c=this._characterJoiners[l].handler(r);for(let u=0;u<c.length;u++)Hh._mergeRanges(a,c[u])}catch(c){console.error(c)}return this._stringRangesToCellRanges(a,n,i),a}_stringRangesToCellRanges(e,t,s){let n=0,i=!1,r=0,a=e[n];if(a){for(let l=s;l<this._bufferService.cols;l++){let c=t.getWidth(l),u=t.getString(l).length||ur.length;if(c!==0){if(!i&&a[0]<=r&&(a[0]=l,i=!0),a[1]<=r){if(a[1]=l,a=e[++n],!a)break;a[0]<=r?(a[0]=l,i=!0):i=!1}r+=u}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let n=0;n<e.length;n++){let i=e[n];if(s){if(t[1]<=i[0])return e[n-1][1]=t[1],e;if(t[1]<=i[1])return e[n-1][1]=Math.max(t[1],i[1]),e.splice(n,1),e;e.splice(n,1),n--}else{if(t[1]<=i[0])return e.splice(n,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};Hh=Lt([ve(0,$s)],Hh);function LP(e){return 57508<=e&&e<=57558}function OP(e){return 9472<=e&&e<=9631}function BP(e){return LP(e)||OP(e)}function $P(){return{css:{canvas:ku(),cell:ku()},device:{canvas:ku(),cell:ku(),char:{width:0,height:0,left:0,top:0}}}}function ku(){return{width:0,height:0}}var Um=class{constructor(e,t,s,n,i,r,a){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=n,this._coreService=i,this._decorationService=r,this._themeService=a,this._workCell=new Sn,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,n,i,r,a,l,c,u,h){let d=[],p=this._characterJoinerService.getJoinedCharacters(t),f=this._themeService.colors,m=e.getNoBgTrimmedLength();s&&m<r+1&&(m=r+1);let b,_=0,v="",y=0,w=0,x=0,S=0,E=!1,R=0,N=!1,I=0,F=0,B=[],C=u!==-1&&h!==-1;for(let A=0;A<m;A++){e.loadCell(A,this._workCell);let M=this._workCell.getWidth();if(M===0)continue;let H=!1,D=A>=F,z=A,T=this._workCell;if(p.length>0&&A===p[0][0]&&D){let Ee=p.shift(),Ae=this._isCellInSelection(Ee[0],t);for(y=Ee[0]+1;y<Ee[1];y++)D&&=Ae===this._isCellInSelection(y,t);D&&=!s||r<Ee[0]||r>=Ee[1],D?(H=!0,T=new PP(this._workCell,e.translateToString(!0,Ee[0],Ee[1]),Ee[1]-Ee[0]),z=Ee[1]-1,M=T.getWidth()):F=Ee[1]}let O=this._isCellInSelection(A,t),K=s&&A===r,U=C&&A>=u&&A<=h,re=!1;this._decorationService.forEachDecorationAtCell(A,t,void 0,Ee=>{re=!0});let J=T.getChars()||ur;if(J===" "&&(T.isUnderline()||T.isOverline())&&(J=" "),I=M*l-c.get(J,T.isBold(),T.isItalic()),!b)b=this._document.createElement("span");else if(_&&(O&&N||!O&&!N&&T.bg===w)&&(O&&N&&f.selectionForeground||T.fg===x)&&T.extended.ext===S&&U===E&&I===R&&!K&&!H&&!re&&D){T.isInvisible()?v+=ur:v+=J,_++;continue}else _&&(b.textContent=v),b=this._document.createElement("span"),_=0,v="";if(w=T.bg,x=T.fg,S=T.extended.ext,E=U,R=I,N=O,H&&r>=A&&r<=z&&(r=A),!this._coreService.isCursorHidden&&K&&this._coreService.isCursorInitialized){if(B.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&B.push("xterm-cursor-blink"),B.push(n==="bar"?"xterm-cursor-bar":n==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":B.push("xterm-cursor-outline");break;case"block":B.push("xterm-cursor-block");break;case"bar":B.push("xterm-cursor-bar");break;case"underline":B.push("xterm-cursor-underline");break}}if(T.isBold()&&B.push("xterm-bold"),T.isItalic()&&B.push("xterm-italic"),T.isDim()&&B.push("xterm-dim"),T.isInvisible()?v=ur:v=T.getChars()||ur,T.isUnderline()&&(B.push(`xterm-underline-${T.extended.underlineStyle}`),v===" "&&(v=" "),!T.isUnderlineColorDefault()))if(T.isUnderlineColorRGB())b.style.textDecorationColor=`rgb(${Mc.toColorRGB(T.getUnderlineColor()).join(",")})`;else{let Ee=T.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&T.isBold()&&Ee<8&&(Ee+=8),b.style.textDecorationColor=f.ansi[Ee].css}T.isOverline()&&(B.push("xterm-overline"),v===" "&&(v=" ")),T.isStrikethrough()&&B.push("xterm-strikethrough"),U&&(b.style.textDecoration="underline");let Y=T.getFgColor(),_e=T.getFgColorMode(),xe=T.getBgColor(),fe=T.getBgColorMode(),et=!!T.isInverse();if(et){let Ee=Y;Y=xe,xe=Ee;let Ae=_e;_e=fe,fe=Ae}let Oe,tt,Pe=!1;this._decorationService.forEachDecorationAtCell(A,t,void 0,Ee=>{Ee.options.layer!=="top"&&Pe||(Ee.backgroundColorRGB&&(fe=50331648,xe=Ee.backgroundColorRGB.rgba>>8&16777215,Oe=Ee.backgroundColorRGB),Ee.foregroundColorRGB&&(_e=50331648,Y=Ee.foregroundColorRGB.rgba>>8&16777215,tt=Ee.foregroundColorRGB),Pe=Ee.options.layer==="top")}),!Pe&&O&&(Oe=this._coreBrowserService.isFocused?f.selectionBackgroundOpaque:f.selectionInactiveBackgroundOpaque,xe=Oe.rgba>>8&16777215,fe=50331648,Pe=!0,f.selectionForeground&&(_e=50331648,Y=f.selectionForeground.rgba>>8&16777215,tt=f.selectionForeground)),Pe&&B.push("xterm-decoration-top");let Le;switch(fe){case 16777216:case 33554432:Le=f.ansi[xe],B.push(`xterm-bg-${xe}`);break;case 50331648:Le=Vt.toColor(xe>>16,xe>>8&255,xe&255),this._addStyle(b,`background-color:#${hb((xe>>>0).toString(16),"0",6)}`);break;case 0:default:et?(Le=f.foreground,B.push("xterm-bg-257")):Le=f.background}switch(Oe||T.isDim()&&(Oe=yt.multiplyOpacity(Le,.5)),_e){case 16777216:case 33554432:T.isBold()&&Y<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Y+=8),this._applyMinimumContrast(b,Le,f.ansi[Y],T,Oe,void 0)||B.push(`xterm-fg-${Y}`);break;case 50331648:let Ee=Vt.toColor(Y>>16&255,Y>>8&255,Y&255);this._applyMinimumContrast(b,Le,Ee,T,Oe,tt)||this._addStyle(b,`color:#${hb(Y.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(b,Le,f.foreground,T,Oe,tt)||et&&B.push("xterm-fg-257")}B.length&&(b.className=B.join(" "),B.length=0),!K&&!H&&!re&&D?_++:b.textContent=v,I!==this.defaultSpacing&&(b.style.letterSpacing=`${I}px`),d.push(b),A=z}return b&&_&&(b.textContent=v),d}_applyMinimumContrast(e,t,s,n,i,r){if(this._optionsService.rawOptions.minimumContrastRatio===1||BP(n.getCode()))return!1;let a=this._getContrastCache(n),l;if(!i&&!r&&(l=a.getColor(t.rgba,s.rgba)),l===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(n.isDim()?2:1);l=yt.ensureContrastRatio(i||t,r||s,c),a.setColor((i||t).rgba,(r||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,n=this._selectionEnd;return!s||!n?!1:this._columnSelectMode?s[0]<=n[0]?e>=s[0]&&t>=s[1]&&e<n[0]&&t<=n[1]:e<s[0]&&t>=s[1]&&e>=n[0]&&t<=n[1]:t>s[1]&&t<n[1]||s[1]===n[1]&&t===s[1]&&e>=s[0]&&e<n[0]||s[1]<n[1]&&t===n[1]&&e<n[0]||s[1]<n[1]&&t===s[1]&&e>=s[0]}};Um=Lt([ve(1,Dk),ve(2,Fs),ve(3,Li),ve(4,yo),ve(5,Dc),ve(6,Aa)],Um);function hb(e,t,s){for(;e.length<s;)e=t+e;return e}var FP=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold";let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontStyle="italic";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold",r.style.fontStyle="italic",this._measureElements=[s,n,i,r],this._container.appendChild(s),this._container.appendChild(n),this._container.appendChild(i),this._container.appendChild(r),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,s,n){e===this._font&&t===this._fontSize&&s===this._weight&&n===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=n,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${n}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${n}`,this.clear())}get(e,t,s){let n=0;if(!t&&!s&&e.length===1&&(n=e.charCodeAt(0))<256){if(this._flat[n]!==-9999)return this._flat[n];let a=this._measure(e,0);return a>0&&(this._flat[n]=a),a}let i=e;t&&(i+="B"),s&&(i+="I");let r=this._holey.get(i);if(r===void 0){let a=0;t&&(a|=1),s&&(a|=2),r=this._measure(e,a),r>0&&this._holey.set(i,r)}return r}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},zP=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,n=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let i=e.buffers.active.ydisp,r=t[1]-i,a=s[1]-i,l=Math.max(r,0),c=Math.min(a,e.rows-1);if(l>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=n,this.viewportStartRow=r,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function HP(){return new zP}var Bf="xterm-dom-renderer-owner-",pn="xterm-rows",Cu="xterm-fg-",db="xterm-bg-",ml="xterm-focus",Eu="xterm-selection",UP=1,Wm=class extends Ve{constructor(e,t,s,n,i,r,a,l,c,u,h,d,p,f){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=n,this._viewportElement=i,this._helperContainer=r,this._linkifier2=a,this._charSizeService=c,this._optionsService=u,this._bufferService=h,this._coreService=d,this._coreBrowserService=p,this._themeService=f,this._terminalClass=UP++,this._rowElements=[],this._selectionRenderModel=HP(),this.onRequestRedraw=this._register(new he).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(pn),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Eu),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=$P(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Um,document),this._element.classList.add(Bf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(xt(()=>{this._element.classList.remove(Bf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new FP(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${pn} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${pn} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${pn} .xterm-dim { color: ${yt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,n=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${n} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${pn}.${ml} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${pn}.${ml} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${pn}.${ml} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${pn} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${pn} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${pn} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${pn} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${pn} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Eu} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Eu} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Eu} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[r,a]of e.ansi.entries())t+=`${this._terminalSelector} .${Cu}${r} { color: ${a.css}; }${this._terminalSelector} .${Cu}${r}.xterm-dim { color: ${yt.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${db}${r} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${Cu}257 { color: ${yt.opaque(e.background).css}; }${this._terminalSelector} .${Cu}257.xterm-dim { color: ${yt.multiplyOpacity(yt.opaque(e.background),.5).css}; }${this._terminalSelector} .${db}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let n=this._document.createElement("div");this._rowContainer.appendChild(n),this._rowElements.push(n)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(ml),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ml),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let n=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,r=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let c=e[0]>t[0];l.appendChild(this._createSelectionElement(r,c?t[0]:e[0],c?e[0]:t[0],a-r+1))}else{let c=n===r?e[0]:0,u=r===i?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(r,c,u));let h=a-r-1;if(l.appendChild(this._createSelectionElement(r+1,0,this._bufferService.cols,h)),r!==a){let d=i===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,d))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,s,n=1){let i=this._document.createElement("div"),r=t*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-t);return r+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-r),i.style.height=`${n*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${r}px`,i.style.width=`${a}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,n=s.ybase+s.y,i=Math.min(s.x,this._bufferService.cols-1),r=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let u=c+s.ydisp,h=this._rowElements[c],d=s.lines.get(u);if(!h||!d)break;h.replaceChildren(...this._rowFactory.createRow(d,u,u===n,a,l,i,r,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Bf}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,n,i,r){s<0&&(e=0),n<0&&(t=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),n=Math.max(Math.min(n,a),0),i=Math.min(i,this._bufferService.cols);let l=this._bufferService.buffer,c=l.ybase+l.y,u=Math.min(l.x,i-1),h=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,p=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=s;f<=n;++f){let m=f+l.ydisp,b=this._rowElements[f],_=l.lines.get(m);if(!b||!_)break;b.replaceChildren(...this._rowFactory.createRow(_,m,m===c,d,p,u,h,this.dimensions.css.cell.width,this._widthCache,r?f===s?e:0:-1,r?(f===n?t:i)-1:-1))}}};Wm=Lt([ve(7,C_),ve(8,bd),ve(9,Fs),ve(10,$s),ve(11,yo),ve(12,Li),ve(13,Aa)],Wm);var Km=class extends Ve{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new he),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new KP(this._optionsService))}catch{this._measureStrategy=this._register(new WP(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Km=Lt([ve(2,Fs)],Km);var Zk=class extends Ve{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},WP=class extends Zk{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},KP=class extends Zk{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},qP=class extends Ve{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new VP(this._window)),this._onDprChange=this._register(new he),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new he),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(n=>this._screenDprMonitor.setWindow(n))),this._register(vs.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(De(this._textarea,"focus",()=>this._isFocused=!0)),this._register(De(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},VP=class extends Ve{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ea),this._onDprChange=this._register(new he),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(xt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=De(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},YP=class extends Ve{constructor(){super(),this.linkProviders=[],this._register(xt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function D_(e,t,s){let n=s.getBoundingClientRect(),i=e.getComputedStyle(s),r=parseInt(i.getPropertyValue("padding-left")),a=parseInt(i.getPropertyValue("padding-top"));return[t.clientX-n.left-r,t.clientY-n.top-a]}function GP(e,t,s,n,i,r,a,l,c){if(!r)return;let u=D_(e,t,s);if(u)return u[0]=Math.ceil((u[0]+(c?a/2:0))/a),u[1]=Math.ceil(u[1]/l),u[0]=Math.min(Math.max(u[0],1),n+(c?1:0)),u[1]=Math.min(Math.max(u[1],1),i),u}var qm=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,n,i){return GP(window,e,t,s,n,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let s=D_(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};qm=Lt([ve(0,Oi),ve(1,bd)],qm);var JP=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Qk={};oI(Qk,{getSafariVersion:()=>ZP,isChromeOS:()=>nC,isFirefox:()=>eC,isIpad:()=>QP,isIphone:()=>eL,isLegacyEdge:()=>XP,isLinux:()=>I_,isMac:()=>Uh,isNode:()=>wd,isSafari:()=>tC,isWindows:()=>sC});var wd=typeof process<"u"&&"title"in process,Ic=wd?"node":navigator.userAgent,Pc=wd?"node":navigator.platform,eC=Ic.includes("Firefox"),XP=Ic.includes("Edge"),tC=/^((?!chrome|android).)*safari/i.test(Ic);function ZP(){if(!tC)return 0;let e=Ic.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Uh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Pc),QP=Pc==="iPad",eL=Pc==="iPhone",sC=["Windows","Win16","Win32","WinCE"].includes(Pc),I_=Pc.indexOf("Linux")>=0,nC=/\bCrOS\b/.test(Ic),iC=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,s=0,n=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),i=e.timeRemaining(),s*1.5>i){n-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-t))}ms`),this._start();return}n=i}this.clear()}},tL=class extends iC{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},sL=class extends iC{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Wh=!wd&&"requestIdleCallback"in window?sL:tL,nL=class{constructor(){this._queue=new Wh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Vm=class extends Ve{constructor(e,t,s,n,i,r,a,l,c){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=n,this._coreService=i,this._coreBrowserService=l,this._renderer=this._register(new Ea),this._pausedResizeTask=new nL,this._observerDisposable=this._register(new Ea),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new he),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new he),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new he),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new he),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new JP((u,h)=>this._renderRows(u,h),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new iL(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(xt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(r.onDecorationRegistered(()=>this._fullRefresh())),this._register(r.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(u=>this._registerIntersectionObserver(u,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(n=>this._handleIntersectionChange(n[n.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=xt(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let n=this._syncOutputHandler.flush();n&&(e=Math.min(e,n.start),t=Math.max(t,n.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,s){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,t,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Vm=Lt([ve(2,Fs),ve(3,bd),ve(4,yo),ve(5,Dc),ve(6,$s),ve(7,Li),ve(8,Aa)],Vm);var iL=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function rL(e,t,s,n){let i=s.buffer.x,r=s.buffer.y;if(!s.buffer.hasScrollback)return lL(i,r,e,t,s,n)+xd(r,t,s,n)+cL(i,r,e,t,s,n);let a;if(r===t)return a=i>e?"D":"C",xc(Math.abs(i-e),wc(a,n));a=r>t?"D":"C";let l=Math.abs(r-t),c=aL(r>t?e:i,s)+(l-1)*s.cols+1+oL(r>t?i:e);return xc(c,wc(a,n))}function oL(e,t){return e-1}function aL(e,t){return t.cols-e}function lL(e,t,s,n,i,r){return xd(t,n,i,r).length===0?"":xc(oC(e,t,e,t-fo(t,i),!1,i).length,wc("D",r))}function xd(e,t,s,n){let i=e-fo(e,s),r=t-fo(t,s),a=Math.abs(i-r)-uL(e,t,s);return xc(a,wc(rC(e,t),n))}function cL(e,t,s,n,i,r){let a;xd(t,n,i,r).length>0?a=n-fo(n,i):a=t;let l=n,c=hL(e,t,s,n,i,r);return xc(oC(e,a,s,l,c==="C",i).length,wc(c,r))}function uL(e,t,s){let n=0,i=e-fo(e,s),r=t-fo(t,s);for(let a=0;a<Math.abs(i-r);a++){let l=rC(e,t)==="A"?-1:1;s.buffer.lines.get(i+l*a)?.isWrapped&&n++}return n}function fo(e,t){let s=0,n=t.buffer.lines.get(e),i=n?.isWrapped;for(;i&&e>=0&&e<t.rows;)s++,n=t.buffer.lines.get(--e),i=n?.isWrapped;return s}function hL(e,t,s,n,i,r){let a;return xd(s,n,i,r).length>0?a=n-fo(n,i):a=t,e<s&&a<=n||e>=s&&a<n?"C":"D"}function rC(e,t){return e>t?"A":"B"}function oC(e,t,s,n,i,r){let a=e,l=t,c="";for(;(a!==s||l!==n)&&l>=0&&l<r.buffer.lines.length;)a+=i?1:-1,i&&a>r.cols-1?(c+=r.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!i&&a<0&&(c+=r.buffer.translateBufferLineToString(l,!1,0,e+1),a=r.cols-1,e=a,l--);return c+r.buffer.translateBufferLineToString(l,!1,e,a)}function wc(e,t){let s=t?"O":"[";return G.ESC+s+e}function xc(e,t){e=Math.floor(e);let s="";for(let n=0;n<e;n++)s+=t;return s}var dL=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function fb(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var $f=50,fL=15,pL=50,mL=500,gL=" ",_L=new RegExp(gL,"g"),Ym=class extends Ve{constructor(e,t,s,n,i,r,a,l,c){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=n,this._coreService=i,this._mouseService=r,this._optionsService=a,this._renderService=l,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Sn,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new he),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new he),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new he),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new he),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=u=>this._handleMouseMove(u),this._mouseUpListener=u=>this._handleMouseUp(u),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(u=>this._handleTrim(u)),this._register(this._bufferService.buffers.onBufferActivate(u=>this._handleBufferActivate(u))),this.enable(),this._model=new dL(this._bufferService),this._activeSelectionMode=0,this._register(xt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(u=>{u.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,n=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let i=e[0]<t[0]?e[0]:t[0],r=e[0]<t[0]?t[0]:e[0];for(let a=e[1];a<=t[1];a++){let l=s.translateBufferLineToString(a,!0,i,r);n.push(l)}}else{let i=e[1]===t[1]?t[0]:void 0;n.push(s.translateBufferLineToString(e[1],!0,e[0],i));for(let r=e[1]+1;r<=t[1]-1;r++){let a=s.lines.get(r),l=s.translateBufferLineToString(r,!0);a?.isWrapped?n[n.length-1]+=l:n.push(l)}if(e[1]!==t[1]){let r=s.lines.get(t[1]),a=s.translateBufferLineToString(t[1],!0,0,t[0]);r&&r.isWrapped?n[n.length-1]+=a:n.push(a)}}return n.map(i=>i.replace(_L," ")).join(sC?`\r
97
+ `:`
98
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),I_&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!s||!n||!t?!1:this._areCoordsInSelection(t,s,n)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!s||!n?!1:this._areCoordsInSelection([e,t],s,n)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=fb(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(e);return n?(this._selectWordAt(n,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=D_(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-$f),$f),t/=$f,t/Math.abs(t)+Math.round(t*(fL-1)))}shouldForceSelection(e){return Uh?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),pL)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Uh&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let n=s.lines.get(this._model.selectionEnd[1]);n&&n.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<mL&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let n=rL(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(n,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let n=0;t>=n;n++){let i=e.loadCell(n,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:i>1&&t!==n&&(s+=i-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,n=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,r=i.lines.get(e[1]);if(!r)return;let a=i.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(r,e[0]),c=l,u=e[0]-l,h=0,d=0,p=0,f=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;c<a.length&&a.charAt(c+1)===" ";)c++}else{let _=e[0],v=e[0];r.getWidth(_)===0&&(h++,_--),r.getWidth(v)===2&&(d++,v++);let y=r.getString(v).length;for(y>1&&(f+=y-1,c+=y-1);_>0&&l>0&&!this._isCharWordSeparator(r.loadCell(_-1,this._workCell));){r.loadCell(_-1,this._workCell);let w=this._workCell.getChars().length;this._workCell.getWidth()===0?(h++,_--):w>1&&(p+=w-1,l-=w-1),l--,_--}for(;v<r.length&&c+1<a.length&&!this._isCharWordSeparator(r.loadCell(v+1,this._workCell));){r.loadCell(v+1,this._workCell);let w=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,v++):w>1&&(f+=w-1,c+=w-1),c++,v++}}c++;let m=l+u-h+p,b=Math.min(this._bufferService.cols,c-l+h+d-p-f);if(!(!t&&a.slice(l,c).trim()==="")){if(s&&m===0&&r.getCodePoint(0)!==32){let _=i.lines.get(e[1]-1);if(_&&r.isWrapped&&_.getCodePoint(this._bufferService.cols-1)!==32){let v=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(v){let y=this._bufferService.cols-v.start;m-=y,b+=y}}}if(n&&m+b===this._bufferService.cols&&r.getCodePoint(this._bufferService.cols-1)!==32){let _=i.lines.get(e[1]+1);if(_?.isWrapped&&_.getCodePoint(0)!==32){let v=this._getWordAt([0,e[1]+1],!1,!1,!0);v&&(b+=v.length)}}return{start:m,length:b}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=fb(s,this._bufferService.cols)}};Ym=Lt([ve(3,$s),ve(4,yo),ve(5,E_),ve(6,Fs),ve(7,Oi),ve(8,Li)],Ym);var pb=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},mb=class{constructor(){this._color=new pb,this._css=new pb}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Xt=Object.freeze((()=>{let e=[jt.toColor("#2e3436"),jt.toColor("#cc0000"),jt.toColor("#4e9a06"),jt.toColor("#c4a000"),jt.toColor("#3465a4"),jt.toColor("#75507b"),jt.toColor("#06989a"),jt.toColor("#d3d7cf"),jt.toColor("#555753"),jt.toColor("#ef2929"),jt.toColor("#8ae234"),jt.toColor("#fce94f"),jt.toColor("#729fcf"),jt.toColor("#ad7fa8"),jt.toColor("#34e2e2"),jt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let n=t[s/36%6|0],i=t[s/6%6|0],r=t[s%6];e.push({css:Vt.toCss(n,i,r),rgba:Vt.toRgba(n,i,r)})}for(let s=0;s<24;s++){let n=8+s*10;e.push({css:Vt.toCss(n,n,n),rgba:Vt.toRgba(n,n,n)})}return e})()),Hr=jt.toColor("#ffffff"),Nl=jt.toColor("#000000"),gb=jt.toColor("#ffffff"),_b=Nl,gl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},vL=Hr,Gm=class extends Ve{constructor(e){super(),this._optionsService=e,this._contrastCache=new mb,this._halfContrastCache=new mb,this._onChangeColors=this._register(new he),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Hr,background:Nl,cursor:gb,cursorAccent:_b,selectionForeground:void 0,selectionBackgroundTransparent:gl,selectionBackgroundOpaque:yt.blend(Nl,gl),selectionInactiveBackgroundTransparent:gl,selectionInactiveBackgroundOpaque:yt.blend(Nl,gl),scrollbarSliderBackground:yt.opacity(Hr,.2),scrollbarSliderHoverBackground:yt.opacity(Hr,.4),scrollbarSliderActiveBackground:yt.opacity(Hr,.5),overviewRulerBorder:Hr,ansi:Xt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=ht(e.foreground,Hr),t.background=ht(e.background,Nl),t.cursor=yt.blend(t.background,ht(e.cursor,gb)),t.cursorAccent=yt.blend(t.background,ht(e.cursorAccent,_b)),t.selectionBackgroundTransparent=ht(e.selectionBackground,gl),t.selectionBackgroundOpaque=yt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ht(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=yt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ht(e.selectionForeground,ub):void 0,t.selectionForeground===ub&&(t.selectionForeground=void 0),yt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=yt.opacity(t.selectionBackgroundTransparent,.3)),yt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=yt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=ht(e.scrollbarSliderBackground,yt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ht(e.scrollbarSliderHoverBackground,yt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ht(e.scrollbarSliderActiveBackground,yt.opacity(t.foreground,.5)),t.overviewRulerBorder=ht(e.overviewRulerBorder,vL),t.ansi=Xt.slice(),t.ansi[0]=ht(e.black,Xt[0]),t.ansi[1]=ht(e.red,Xt[1]),t.ansi[2]=ht(e.green,Xt[2]),t.ansi[3]=ht(e.yellow,Xt[3]),t.ansi[4]=ht(e.blue,Xt[4]),t.ansi[5]=ht(e.magenta,Xt[5]),t.ansi[6]=ht(e.cyan,Xt[6]),t.ansi[7]=ht(e.white,Xt[7]),t.ansi[8]=ht(e.brightBlack,Xt[8]),t.ansi[9]=ht(e.brightRed,Xt[9]),t.ansi[10]=ht(e.brightGreen,Xt[10]),t.ansi[11]=ht(e.brightYellow,Xt[11]),t.ansi[12]=ht(e.brightBlue,Xt[12]),t.ansi[13]=ht(e.brightMagenta,Xt[13]),t.ansi[14]=ht(e.brightCyan,Xt[14]),t.ansi[15]=ht(e.brightWhite,Xt[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let n=0;n<s;n++)t.ansi[n+16]=ht(e.extendedAnsi[n],Xt[n+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Gm=Lt([ve(0,Fs)],Gm);function ht(e,t){if(e!==void 0)try{return jt.toColor(e)}catch{}return t}var yL=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},bL=class{constructor(){this._services=new yL,this._services.set(C_,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=fI(e).sort((r,a)=>r.index-a.index),n=[];for(let r of s){let a=this._services.get(r.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${r.id._id}.`);n.push(a)}let i=s.length>0?s[0].index:t.length;if(t.length!==i)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...n)}},wL={trace:0,debug:1,info:2,warn:3,error:4,off:5},xL="xterm.js: ",Jm=class extends Ve{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=wL[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":xL)+t,...s)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};Jm=Lt([ve(0,Fs)],Jm);var vb=class extends Ve{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new he),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new he),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new he),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...s){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let n=this._length-1;n>=e;n--)this._array[this._getCyclicIndex(n+s.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<s.length;n++)this._array[this._getCyclicIndex(e+n)]=s[n];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let n=this._length+s.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let i=t-1;i>=0;i--)this.set(e+i+s,this.get(e+i));let n=e+t+s-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<t;n++)this.set(e+n+s,this.get(e+n))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},qe=3,qt=Object.freeze(new Mc),Nu=0,Ff=2,Rl=class aC{constructor(t,s,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*qe);let i=s||Sn.fromCharData([0,Ek,1,0]);for(let r=0;r<t;++r)this.setCell(r,i);this.length=t}get(t){let s=this._data[t*qe+0],n=s&2097151;return[this._data[t*qe+1],s&2097152?this._combined[t]:n?sr(n):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n]}set(t,s){this._data[t*qe+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*qe+0]=t|2097152|s[2]<<22):this._data[t*qe+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*qe+0]>>22}hasWidth(t){return this._data[t*qe+0]&12582912}getFg(t){return this._data[t*qe+1]}getBg(t){return this._data[t*qe+2]}hasContent(t){return this._data[t*qe+0]&4194303}getCodePoint(t){let s=this._data[t*qe+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*qe+0]&2097152}getString(t){let s=this._data[t*qe+0];return s&2097152?this._combined[t]:s&2097151?sr(s&2097151):""}isProtected(t){return this._data[t*qe+2]&536870912}loadCell(t,s){return Nu=t*qe,s.content=this._data[Nu+0],s.fg=this._data[Nu+1],s.bg=this._data[Nu+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*qe+0]=s.content,this._data[t*qe+1]=s.fg,this._data[t*qe+2]=s.bg}setCellFromCodepoint(t,s,n,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*qe+0]=s|n<<22,this._data[t*qe+1]=i.fg,this._data[t*qe+2]=i.bg}addCodepointToCell(t,s,n){let i=this._data[t*qe+0];i&2097152?this._combined[t]+=sr(s):i&2097151?(this._combined[t]=sr(i&2097151)+sr(s),i&=-2097152,i|=2097152):i=s|1<<22,n&&(i&=-12582913,i|=n<<22),this._data[t*qe+0]=i}insertCells(t,s,n){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),s<this.length-t){let i=new Sn;for(let r=this.length-t-s-1;r>=0;--r)this.setCell(t+s+r,this.loadCell(t+r,i));for(let r=0;r<s;++r)this.setCell(t+r,n)}else for(let i=t;i<this.length;++i)this.setCell(i,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(t,s,n){if(t%=this.length,s<this.length-t){let i=new Sn;for(let r=0;r<this.length-t-s;++r)this.setCell(t+r,this.loadCell(t+s+r,i));for(let r=this.length-s;r<this.length;++r)this.setCell(r,n)}else for(let i=t;i<this.length;++i)this.setCell(i,n);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,n)}replaceCells(t,s,n,i=!1){if(i){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,n),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,n);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,n),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,n);t<s&&t<this.length;)this.setCell(t++,n)}resize(t,s){if(t===this.length)return this._data.length*4*Ff<this._data.buffer.byteLength;let n=t*qe;if(t>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let i=new Uint32Array(n);i.set(this._data),this._data=i}for(let i=this.length;i<t;++i)this.setCell(i,s)}else{this._data=this._data.subarray(0,n);let i=Object.keys(this._combined);for(let a=0;a<i.length;a++){let l=parseInt(i[a],10);l>=t&&delete this._combined[l]}let r=Object.keys(this._extendedAttrs);for(let a=0;a<r.length;a++){let l=parseInt(r[a],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,n*4*Ff<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ff<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let n=0;n<this.length;++n)this.isProtected(n)||this.setCell(n,t);return}this._combined={},this._extendedAttrs={};for(let n=0;n<this.length;++n)this.setCell(n,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new aC(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*qe+0]&4194303)return t+(this._data[t*qe+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*qe+0]&4194303||this._data[t*qe+2]&50331648)return t+(this._data[t*qe+0]>>22);return 0}copyCellsFrom(t,s,n,i,r){let a=t._data;if(r)for(let c=i-1;c>=0;c--){for(let u=0;u<qe;u++)this._data[(n+c)*qe+u]=a[(s+c)*qe+u];a[(s+c)*qe+2]&268435456&&(this._extendedAttrs[n+c]=t._extendedAttrs[s+c])}else for(let c=0;c<i;c++){for(let u=0;u<qe;u++)this._data[(n+c)*qe+u]=a[(s+c)*qe+u];a[(s+c)*qe+2]&268435456&&(this._extendedAttrs[n+c]=t._extendedAttrs[s+c])}let l=Object.keys(t._combined);for(let c=0;c<l.length;c++){let u=parseInt(l[c],10);u>=s&&(this._combined[u-s+n]=t._combined[u])}}translateToString(t,s,n,i){s=s??0,n=n??this.length,t&&(n=Math.min(n,this.getTrimmedLength())),i&&(i.length=0);let r="";for(;s<n;){let a=this._data[s*qe+0],l=a&2097151,c=a&2097152?this._combined[s]:l?sr(l):ur;if(r+=c,i)for(let u=0;u<c.length;++u)i.push(s);s+=a>>22||1}return i&&i.push(s),r}};function SL(e,t,s,n,i,r){let a=[];for(let l=0;l<e.length-1;l++){let c=l,u=e.get(++c);if(!u.isWrapped)continue;let h=[e.get(l)];for(;c<e.length&&u.isWrapped;)h.push(u),u=e.get(++c);if(!r&&n>=l&&n<c){l+=h.length-1;continue}let d=0,p=Sc(h,d,t),f=1,m=0;for(;f<h.length;){let _=Sc(h,f,t),v=_-m,y=s-p,w=Math.min(v,y);h[d].copyCellsFrom(h[f],m,p,w,!1),p+=w,p===s&&(d++,p=0),m+=w,m===_&&(f++,m=0),p===0&&d!==0&&h[d-1].getWidth(s-1)===2&&(h[d].copyCellsFrom(h[d-1],s-1,p++,1,!1),h[d-1].setCell(s-1,i))}h[d].replaceCells(p,s,i);let b=0;for(let _=h.length-1;_>0&&(_>d||h[_].getTrimmedLength()===0);_--)b++;b>0&&(a.push(l+h.length-b),a.push(b)),l+=h.length-1}return a}function kL(e,t){let s=[],n=0,i=t[n],r=0;for(let a=0;a<e.length;a++)if(i===a){let l=t[++n];e.onDeleteEmitter.fire({index:a-r,amount:l}),a+=l-1,r+=l,i=t[++n]}else s.push(a);return{layout:s,countRemoved:r}}function CL(e,t){let s=[];for(let n=0;n<t.length;n++)s.push(e.get(t[n]));for(let n=0;n<s.length;n++)e.set(n,s[n]);e.length=t.length}function EL(e,t,s){let n=[],i=e.map((c,u)=>Sc(e,u,t)).reduce((c,u)=>c+u),r=0,a=0,l=0;for(;l<i;){if(i-l<s){n.push(i-l);break}r+=s;let c=Sc(e,a,t);r>c&&(r-=c,a++);let u=e[a].getWidth(r-1)===2;u&&r--;let h=u?s-1:s;n.push(h),l+=h}return n}function Sc(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let n=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,i=e[t+1].getWidth(0)===2;return n&&i?s-1:s}var lC=class cC{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=cC._nextId++,this._onDispose=this.register(new he),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ho(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};lC._nextId=1;var NL=lC,ss={},Ur=ss.B;ss[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};ss.A={"#":"£"};ss.B=void 0;ss[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};ss.C=ss[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ss.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};ss.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};ss.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};ss.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};ss.E=ss[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};ss.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};ss.H=ss[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ss["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var yb=4294967295,bb=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=qt.clone(),this.savedCharset=Ur,this.markers=[],this._nullCell=Sn.fromCharData([0,Ek,1,0]),this._whitespaceCell=Sn.fromCharData([0,ur,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Wh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new vb(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Fh),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Fh),this._whitespaceCell}getBlankLine(e,t){return new Rl(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>yb?yb:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=qt);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new vb(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(qt),n=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let a=0;a<this.lines.length;a++)n+=+this.lines.get(a).resize(e,s);let r=0;if(this._rows<t)for(let a=this._rows;a<t;a++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Rl(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+r+1?(this.ybase--,r++,this.ydisp>0&&this.ydisp--):this.lines.push(new Rl(e,s)));else for(let a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let a=this.lines.length-i;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),r&&(this.y+=r),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let r=0;r<this.lines.length;r++)n+=+this.lines.get(r).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),n>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,n=SL(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(qt),s);if(n.length>0){let i=kL(this.lines,n);CL(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let n=this.getNullCell(qt),i=s;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Rl(e,n))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,n=this.getNullCell(qt),i=[],r=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let c=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),c.unshift(l);if(!s){let w=this.ybase+this.y;if(w>=a&&w<a+c.length)continue}let u=c[c.length-1].getTrimmedLength(),h=EL(c,this._cols,e),d=h.length-c.length,p;this.ybase===0&&this.y!==this.lines.length-1?p=Math.max(0,this.y-this.lines.maxLength+d):p=Math.max(0,this.lines.length-this.lines.maxLength+d);let f=[];for(let w=0;w<d;w++){let x=this.getBlankLine(qt,!0);f.push(x)}f.length>0&&(i.push({start:a+c.length+r,newLines:f}),r+=f.length),c.push(...f);let m=h.length-1,b=h[m];b===0&&(m--,b=h[m]);let _=c.length-d-1,v=u;for(;_>=0;){let w=Math.min(v,b);if(c[m]===void 0)break;if(c[m].copyCellsFrom(c[_],v-w,b-w,w,!0),b-=w,b===0&&(m--,b=h[m]),v-=w,v===0){_--;let x=Math.max(_,0);v=Sc(c,x,this._cols)}}for(let w=0;w<c.length;w++)h[w]<e&&c[w].setCell(h[w],n);let y=d-p;for(;y-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+r)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let a=[],l=[];for(let b=0;b<this.lines.length;b++)l.push(this.lines.get(b));let c=this.lines.length,u=c-1,h=0,d=i[h];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+r);let p=0;for(let b=Math.min(this.lines.maxLength-1,c+r-1);b>=0;b--)if(d&&d.start>u+p){for(let _=d.newLines.length-1;_>=0;_--)this.lines.set(b--,d.newLines[_]);b++,a.push({index:u+1,amount:d.newLines.length}),p+=d.newLines.length,d=i[++h]}else this.lines.set(b,l[u--]);let f=0;for(let b=a.length-1;b>=0;b--)a[b].index+=f,this.lines.onInsertEmitter.fire(a[b]),f+=a[b].amount;let m=Math.max(0,c+r-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(e,t,s=0,n){let i=this.lines.get(e);return i?i.translateToString(t,s,n):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new NL(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},RL=class extends Ve{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new he),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new bb(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new bb(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},uC=2,hC=1,Xm=class extends Ve{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new he),this.onResize=this._onResize.event,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,uC),this.rows=Math.max(e.rawOptions.rows||0,hC),this.buffers=this._register(new RL(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,n=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,n;n=this._cachedBlankLine,(!n||n.length!==this.cols||n.getFg(0)!==e.fg||n.getBg(0)!==e.bg)&&(n=s.getBlankLine(e,t),this._cachedBlankLine=n),n.isWrapped=t;let i=s.ybase+s.scrollTop,r=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;r===s.lines.length-1?a?s.lines.recycle().copyFrom(n):s.lines.push(n.clone()):s.lines.splice(r+1,0,n.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=r-i+1;s.lines.shiftElements(i+1,a-1,-1),s.lines.set(r,n.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let n=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),n!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};Xm=Lt([ve(0,Fs)],Xm);var Oo={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Uh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},jL=["normal","bold","100","200","300","400","500","600","700","800","900"],TL=class extends Ve{constructor(e){super(),this._onOptionChange=this._register(new he),this.onOptionChange=this._onOptionChange.event;let t={...Oo};for(let s in e)if(s in t)try{let n=e[s];t[s]=this._sanitizeAndValidateOption(s,n)}catch(n){console.error(n)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(xt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in Oo))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,n)=>{if(!(s in Oo))throw new Error(`No option with key "${s}"`);n=this._sanitizeAndValidateOption(s,n),this.rawOptions[s]!==n&&(this.rawOptions[s]=n,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let n={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,n)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Oo[e]),!AL(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Oo[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=jL.includes(t)?t:Oo[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function AL(e){return e==="block"||e==="underline"||e==="bar"}function jl(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let n in e)s[n]=t<=1?e[n]:e[n]&&jl(e[n],t-1);return s}var wb=Object.freeze({insertMode:!1}),xb=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Zm=class extends Ve{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new he),this.onData=this._onData.event,this._onUserInput=this._register(new he),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new he),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new he),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=jl(wb),this.decPrivateModes=jl(xb)}reset(){this.modes=jl(wb),this.decPrivateModes=jl(xb)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(n=>n.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Zm=Lt([ve(0,$s),ve(1,Ak),ve(2,Fs)],Zm);var Sb={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function zf(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var Hf=String.fromCharCode,kb={DEFAULT:e=>{let t=[zf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Hf(t[0])}${Hf(t[1])}${Hf(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${zf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${zf(e,!0)};${e.x};${e.y}${t}`}},Qm=class extends Ve{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new he),this.onProtocolChange=this._onProtocolChange.event;for(let n of Object.keys(Sb))this.addProtocol(n,Sb[n]);for(let n of Object.keys(kb))this.addEncoding(n,kb[n]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let n=t/s,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=n+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Qm=Lt([ve(0,$s),ve(1,yo),ve(2,Fs)],Qm);var Uf=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],ML=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Zt;function DL(e,t){let s=0,n=t.length-1,i;if(e<t[0][0]||e>t[n][1])return!1;for(;n>=s;)if(i=s+n>>1,e>t[i][1])s=i+1;else if(e<t[i][0])n=i-1;else return!0;return!1}var IL=class{constructor(){if(this.version="6",!Zt){Zt=new Uint8Array(65536),Zt.fill(1),Zt[0]=0,Zt.fill(0,1,32),Zt.fill(0,127,160),Zt.fill(2,4352,4448),Zt[9001]=2,Zt[9002]=2,Zt.fill(2,11904,42192),Zt[12351]=1,Zt.fill(2,44032,55204),Zt.fill(2,63744,64256),Zt.fill(2,65040,65050),Zt.fill(2,65072,65136),Zt.fill(2,65280,65377),Zt.fill(2,65504,65511);for(let e=0;e<Uf.length;++e)Zt.fill(0,Uf[e][0],Uf[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Zt[e]:DL(e,ML)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),n=s===0&&t!==0;if(n){let i=Yr.extractWidth(t);i===0?n=!1:i>s&&(s=i)}return Yr.createPropertyValue(0,s,n)}},Yr=class Ju{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new he,this.onChange=this._onChange.event;let t=new IL;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,n=!1){return(t&16777215)<<3|(s&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,n=0,i=t.length;for(let r=0;r<i;++r){let a=t.charCodeAt(r);if(55296<=a&&a<=56319){if(++r>=i)return s+this.wcwidth(a);let u=t.charCodeAt(r);56320<=u&&u<=57343?a=(a-55296)*1024+u-56320+65536:s+=this.wcwidth(u)}let l=this.charProperties(a,n),c=Ju.extractWidth(l);Ju.extractShouldJoin(l)&&(c-=Ju.extractWidth(n)),s+=c,n=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},PL=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Cb(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var _l=2147483647,LL=256,dC=class eg{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>LL)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new eg;if(!t.length)return s;for(let n=Array.isArray(t[0])?1:0;n<t.length;++n){let i=t[n];if(Array.isArray(i))for(let r=0;r<i.length;++r)s.addSubParam(i[r]);else s.addParam(i)}return s}clone(){let t=new eg(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let n=this._subParamsIdx[s]>>8,i=this._subParamsIdx[s]&255;i-n>0&&t.push(Array.prototype.slice.call(this._subParams,n,i))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>_l?_l:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>_l?_l:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,n=this._subParamsIdx[t]&255;return n-s>0?this._subParams.subarray(s,n):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let n=this._subParamsIdx[s]>>8,i=this._subParamsIdx[s]&255;i-n>0&&(t[s]=this._subParams.slice(n,i))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,i=n[s-1];n[s-1]=~i?Math.min(i*10+t,_l):t}},vl=[],OL=class{constructor(){this._state=0,this._active=vl,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let n=s.indexOf(t);n!==-1&&s.splice(n,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=vl}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=vl,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||vl,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",yd(e,t,s));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;n>=0&&(s=this._active[n].end(e),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}this._active=vl,this._id=-1,this._state=0}}},Qs=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=yd(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},yl=[],BL=class{constructor(){this._handlers=Object.create(null),this._active=yl,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=yl}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let n=s.indexOf(t);n!==-1&&s.splice(n,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=yl,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||yl,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",yd(e,t,s));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;n>=0&&(s=this._active[n].unhook(e),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}this._active=yl,this._ident=0}},Tl=new dC;Tl.addParam(0);var Eb=class{constructor(e){this._handler=e,this._data="",this._params=Tl,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Tl,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=yd(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=Tl,this._data="",this._hitLimit=!1,s));return this._params=Tl,this._data="",this._hitLimit=!1,t}},$L=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,n){this.table[t<<8|e]=s<<4|n}addMany(e,t,s,n){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=s<<4|n}},_n=160,FL=function(){let e=new $L(4095),t=Array.apply(null,Array(256)).map((l,c)=>c),s=(l,c)=>t.slice(l,c),n=s(32,127),i=s(0,24);i.push(25),i.push.apply(i,s(28,32));let r=s(0,14),a;e.setDefault(1,0),e.addMany(n,0,2,0);for(a in r)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(n,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(n,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(n,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(_n,0,2,0),e.add(_n,8,5,8),e.add(_n,6,0,6),e.add(_n,11,0,11),e.add(_n,13,13,13),e}(),zL=class extends Ve{constructor(e=FL){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new dC,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,n)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(xt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new OL),this._dcsParser=this._register(new BL),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let i=0;i<e.intermediates.length;++i){let r=e.intermediates.charCodeAt(i);if(32>r||r>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=r}}if(e.final.length!==1)throw new Error("final must be a single byte");let n=e.final.charCodeAt(0);if(t[0]>n||n>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=n,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let n=this._escHandlers[s];return n.push(t),{dispose:()=>{let i=n.indexOf(t);i!==-1&&n.splice(i,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let n=this._csiHandlers[s];return n.push(t),{dispose:()=>{let i=n.indexOf(t);i!==-1&&n.splice(i,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,n,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=n,this._parseStack.chunkPos=i}parse(e,t,s){let n=0,i=0,r=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,r=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&c>-1){for(;c>=0&&(a=l[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._parseStack.handlerPos=c,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&c>-1){for(;c>=0&&(a=l[c](),a!==!0);c--)if(a instanceof Promise)return this._parseStack.handlerPos=c,a}this._parseStack.handlers=[];break;case 6:if(n=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(n!==24&&n!==26,s),a)return a;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=e[this._parseStack.chunkPos],a=this._oscParser.end(n!==24&&n!==26,s),a)return a;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,r=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=r;l<t;++l){switch(n=e[l],i=this._transitions.table[this.currentState<<8|(n<160?n:_n)],i>>4){case 2:for(let p=l+1;;++p){if(p>=t||(n=e[p])<32||n>126&&n<_n){this._printHandler(e,l,p),l=p-1;break}if(++p>=t||(n=e[p])<32||n>126&&n<_n){this._printHandler(e,l,p),l=p-1;break}if(++p>=t||(n=e[p])<32||n>126&&n<_n){this._printHandler(e,l,p),l=p-1;break}if(++p>=t||(n=e[p])<32||n>126&&n<_n){this._printHandler(e,l,p),l=p-1;break}}break;case 3:this._executeHandlers[n]?this._executeHandlers[n]():this._executeHandlerFb(n),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:n,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|n],u=c?c.length-1:-1;for(;u>=0&&(a=c[u](this._params),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(3,c,u,i,l),a;u<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingJoinState=0;break;case 8:do switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(n-48)}while(++l<t&&(n=e[l])>47&&n<60);l--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:let h=this._escHandlers[this._collect<<8|n],d=h?h.length-1:-1;for(;d>=0&&(a=h[d](),a!==!0);d--)if(a instanceof Promise)return this._preserveStack(4,h,d,i,l),a;d<0&&this._escHandlerFb(this._collect<<8|n),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|n,this._params);break;case 13:for(let p=l+1;;++p)if(p>=t||(n=e[p])===24||n===26||n===27||n>127&&n<_n){this._dcsParser.put(e,l,p),l=p-1;break}break;case 14:if(a=this._dcsParser.unhook(n!==24&&n!==26),a)return this._preserveStack(6,[],0,i,l),a;n===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let p=l+1;;p++)if(p>=t||(n=e[p])<32||n>127&&n<_n){this._oscParser.put(e,l,p),l=p-1;break}break;case 6:if(a=this._oscParser.end(n!==24&&n!==26),a)return this._preserveStack(5,[],0,i,l),a;n===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},HL=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,UL=/^[\da-f]+$/;function Nb(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=HL.exec(t);if(s){let n=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/n*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/n*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/n*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),UL.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,n=[0,0,0];for(let i=0;i<3;++i){let r=parseInt(t.slice(s*i,s*i+s),16);n[i]=s===1?r<<4:s===2?r:s===3?r>>4:r>>8}return n}}function Wf(e,t){let s=e.toString(16),n=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return n;case 12:return(n+n).slice(0,3);default:return n+n}}function WL(e,t=16){let[s,n,i]=e;return`rgb:${Wf(s,t)}/${Wf(n,t)}/${Wf(i,t)}`}var KL={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Xi=131072,Rb=10;function jb(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Tb=5e3,Ab=0,qL=class extends Ve{constructor(e,t,s,n,i,r,a,l,c=new zL){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=n,this._optionsService=i,this._oscLinkService=r,this._coreMouseService=a,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new hI,this._utf8Decoder=new dI,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=qt.clone(),this._eraseAttrDataInternal=qt.clone(),this._onRequestBell=this._register(new he),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new he),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new he),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new he),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new he),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new he),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new he),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new he),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new he),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new he),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new he),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new he),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new tg(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(u=>this._activeBuffer=u.activeBuffer)),this._parser.setCsiHandlerFallback((u,h)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(u),params:h.toArray()})}),this._parser.setEscHandlerFallback(u=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(u)})}),this._parser.setExecuteHandlerFallback(u=>{this._logService.debug("Unknown EXECUTE code: ",{code:u})}),this._parser.setOscHandlerFallback((u,h,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:u,action:h,data:d})}),this._parser.setDcsHandlerFallback((u,h,d)=>{h==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(u),action:h,payload:d})}),this._parser.setPrintHandler((u,h,d)=>this.print(u,h,d)),this._parser.registerCsiHandler({final:"@"},u=>this.insertChars(u)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},u=>this.scrollLeft(u)),this._parser.registerCsiHandler({final:"A"},u=>this.cursorUp(u)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},u=>this.scrollRight(u)),this._parser.registerCsiHandler({final:"B"},u=>this.cursorDown(u)),this._parser.registerCsiHandler({final:"C"},u=>this.cursorForward(u)),this._parser.registerCsiHandler({final:"D"},u=>this.cursorBackward(u)),this._parser.registerCsiHandler({final:"E"},u=>this.cursorNextLine(u)),this._parser.registerCsiHandler({final:"F"},u=>this.cursorPrecedingLine(u)),this._parser.registerCsiHandler({final:"G"},u=>this.cursorCharAbsolute(u)),this._parser.registerCsiHandler({final:"H"},u=>this.cursorPosition(u)),this._parser.registerCsiHandler({final:"I"},u=>this.cursorForwardTab(u)),this._parser.registerCsiHandler({final:"J"},u=>this.eraseInDisplay(u,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},u=>this.eraseInDisplay(u,!0)),this._parser.registerCsiHandler({final:"K"},u=>this.eraseInLine(u,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},u=>this.eraseInLine(u,!0)),this._parser.registerCsiHandler({final:"L"},u=>this.insertLines(u)),this._parser.registerCsiHandler({final:"M"},u=>this.deleteLines(u)),this._parser.registerCsiHandler({final:"P"},u=>this.deleteChars(u)),this._parser.registerCsiHandler({final:"S"},u=>this.scrollUp(u)),this._parser.registerCsiHandler({final:"T"},u=>this.scrollDown(u)),this._parser.registerCsiHandler({final:"X"},u=>this.eraseChars(u)),this._parser.registerCsiHandler({final:"Z"},u=>this.cursorBackwardTab(u)),this._parser.registerCsiHandler({final:"`"},u=>this.charPosAbsolute(u)),this._parser.registerCsiHandler({final:"a"},u=>this.hPositionRelative(u)),this._parser.registerCsiHandler({final:"b"},u=>this.repeatPrecedingCharacter(u)),this._parser.registerCsiHandler({final:"c"},u=>this.sendDeviceAttributesPrimary(u)),this._parser.registerCsiHandler({prefix:">",final:"c"},u=>this.sendDeviceAttributesSecondary(u)),this._parser.registerCsiHandler({final:"d"},u=>this.linePosAbsolute(u)),this._parser.registerCsiHandler({final:"e"},u=>this.vPositionRelative(u)),this._parser.registerCsiHandler({final:"f"},u=>this.hVPosition(u)),this._parser.registerCsiHandler({final:"g"},u=>this.tabClear(u)),this._parser.registerCsiHandler({final:"h"},u=>this.setMode(u)),this._parser.registerCsiHandler({prefix:"?",final:"h"},u=>this.setModePrivate(u)),this._parser.registerCsiHandler({final:"l"},u=>this.resetMode(u)),this._parser.registerCsiHandler({prefix:"?",final:"l"},u=>this.resetModePrivate(u)),this._parser.registerCsiHandler({final:"m"},u=>this.charAttributes(u)),this._parser.registerCsiHandler({final:"n"},u=>this.deviceStatus(u)),this._parser.registerCsiHandler({prefix:"?",final:"n"},u=>this.deviceStatusPrivate(u)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},u=>this.softReset(u)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},u=>this.setCursorStyle(u)),this._parser.registerCsiHandler({final:"r"},u=>this.setScrollRegion(u)),this._parser.registerCsiHandler({final:"s"},u=>this.saveCursor(u)),this._parser.registerCsiHandler({final:"t"},u=>this.windowOptions(u)),this._parser.registerCsiHandler({final:"u"},u=>this.restoreCursor(u)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},u=>this.insertColumns(u)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},u=>this.deleteColumns(u)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},u=>this.selectProtected(u)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},u=>this.requestMode(u,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},u=>this.requestMode(u,!1)),this._parser.setExecuteHandler(G.BEL,()=>this.bell()),this._parser.setExecuteHandler(G.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(G.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(G.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(G.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(G.BS,()=>this.backspace()),this._parser.setExecuteHandler(G.HT,()=>this.tab()),this._parser.setExecuteHandler(G.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(G.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Yu.IND,()=>this.index()),this._parser.setExecuteHandler(Yu.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Yu.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Qs(u=>(this.setTitle(u),this.setIconName(u),!0))),this._parser.registerOscHandler(1,new Qs(u=>this.setIconName(u))),this._parser.registerOscHandler(2,new Qs(u=>this.setTitle(u))),this._parser.registerOscHandler(4,new Qs(u=>this.setOrReportIndexedColor(u))),this._parser.registerOscHandler(8,new Qs(u=>this.setHyperlink(u))),this._parser.registerOscHandler(10,new Qs(u=>this.setOrReportFgColor(u))),this._parser.registerOscHandler(11,new Qs(u=>this.setOrReportBgColor(u))),this._parser.registerOscHandler(12,new Qs(u=>this.setOrReportCursorColor(u))),this._parser.registerOscHandler(104,new Qs(u=>this.restoreIndexedColor(u))),this._parser.registerOscHandler(110,new Qs(u=>this.restoreFgColor(u))),this._parser.registerOscHandler(111,new Qs(u=>this.restoreBgColor(u))),this._parser.registerOscHandler(112,new Qs(u=>this.restoreCursorColor(u))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let u in ss)this._parser.registerEscHandler({intermediates:"(",final:u},()=>this.selectCharset("("+u)),this._parser.registerEscHandler({intermediates:")",final:u},()=>this.selectCharset(")"+u)),this._parser.registerEscHandler({intermediates:"*",final:u},()=>this.selectCharset("*"+u)),this._parser.registerEscHandler({intermediates:"+",final:u},()=>this.selectCharset("+"+u)),this._parser.registerEscHandler({intermediates:"-",final:u},()=>this.selectCharset("-"+u)),this._parser.registerEscHandler({intermediates:".",final:u},()=>this.selectCharset("."+u)),this._parser.registerEscHandler({intermediates:"/",final:u},()=>this.selectCharset("/"+u));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(u=>(this._logService.error("Parsing error: ",u),u)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Eb((u,h)=>this.requestStatusString(u,h)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,n){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=n}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),Tb))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Tb} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,n=this._activeBuffer.x,i=this._activeBuffer.y,r=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;n=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Xi&&(r=this._parseStack.position+Xi)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,u=>String.fromCharCode(u)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(u=>u.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Xi&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Xi))),a||this._dirtyRowTracker.clearRange(),e.length>Xi)for(let u=r;u<e.length;u+=Xi){let h=u+Xi<e.length?u+Xi:e.length,d=typeof e=="string"?this._stringDecoder.decode(e.substring(u,h),this._parseBuffer):this._utf8Decoder.decode(e.subarray(u,h),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,d))return this._preserveStack(n,i,d,u),this._logSlowResolvingAsync(s),s}else if(!a){let u=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,u))return this._preserveStack(n,i,u,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==n||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,t,s){let n,i,r=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,u=this._coreService.modes.insertMode,h=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let p=this._parser.precedingJoinState;for(let f=t;f<s;++f){if(n=e[f],n<127&&r){let v=r[String.fromCharCode(n)];v&&(n=v.charCodeAt(0))}let m=this._unicodeService.charProperties(n,p);i=Yr.extractWidth(m);let b=Yr.extractShouldJoin(m),_=b?Yr.extractWidth(p):0;if(p=m,a&&this._onA11yChar.fire(sr(n)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-_>l){if(c){let v=d,y=this._activeBuffer.x-_;for(this._activeBuffer.x=_,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),_>0&&d instanceof Rl&&d.copyCellsFrom(v,y,0,_,!1);y<l;)v.setCellFromCodepoint(y++,0,1,h)}else if(this._activeBuffer.x=l-1,i===2)continue}if(b&&this._activeBuffer.x){let v=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-v,n,i);for(let y=i-_;--y>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(u&&(d.insertCells(this._activeBuffer.x,i-_,this._activeBuffer.getNullCell(h)),d.getWidth(l-1)===2&&d.setCellFromCodepoint(l-1,0,1,h)),d.setCellFromCodepoint(this._activeBuffer.x++,n,i,h),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=p,this._activeBuffer.x<l&&s-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>jb(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Eb(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Qs(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,n=!1,i=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),i),n&&(r.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-n+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,n;for(n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-n;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(qt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,n=Yr.extractWidth(t),i=this._activeBuffer.x-n,r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),a=new Uint32Array(r.length*s),l=0;for(let u=0;u<r.length;){let h=r.codePointAt(u)||0;a[l++]=h,u+=h>65535?2:1}let c=l;for(let u=1;u<s;++u)a.copyWithin(c,0,l),c+=l;return this.print(a,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(G.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(G.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(G.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(G.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(G.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Ur),this._charsetService.setgCharset(1,Ur),this._charsetService.setgCharset(2,Ur),this._charsetService.setgCharset(3,Ur);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let s;(b=>(b[b.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",b[b.SET=1]="SET",b[b.RESET=2]="RESET",b[b.PERMANENTLY_SET=3]="PERMANENTLY_SET",b[b.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let n=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:r}=this._coreMouseService,a=this._coreService,{buffers:l,cols:c}=this._bufferService,{active:u,alt:h}=l,d=this._optionsService.rawOptions,p=(b,_)=>(a.triggerDataEvent(`${G.ESC}[${t?"":"?"}${b};${_}$y`),!0),f=b=>b?1:2,m=e.params[0];return t?m===2?p(m,4):m===4?p(m,f(a.modes.insertMode)):m===12?p(m,3):m===20?p(m,f(d.convertEol)):p(m,0):m===1?p(m,f(n.applicationCursorKeys)):m===3?p(m,d.windowOptions.setWinLines?c===80?2:c===132?1:0:0):m===6?p(m,f(n.origin)):m===7?p(m,f(n.wraparound)):m===8?p(m,3):m===9?p(m,f(i==="X10")):m===12?p(m,f(d.cursorBlink)):m===25?p(m,f(!a.isCursorHidden)):m===45?p(m,f(n.reverseWraparound)):m===66?p(m,f(n.applicationKeypad)):m===67?p(m,4):m===1e3?p(m,f(i==="VT200")):m===1002?p(m,f(i==="DRAG")):m===1003?p(m,f(i==="ANY")):m===1004?p(m,f(n.sendFocus)):m===1005?p(m,4):m===1006?p(m,f(r==="SGR")):m===1015?p(m,4):m===1016?p(m,f(r==="SGR_PIXELS")):m===1048?p(m,1):m===47||m===1047||m===1049?p(m,f(u===h)):m===2004?p(m,f(n.bracketedPasteMode)):m===2026?p(m,f(n.synchronizedOutput)):p(m,0)}_updateAttrColor(e,t,s,n,i){return t===2?(e|=50331648,e&=-16777216,e|=Mc.fromColorRGB([s,n,i])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let n=[0,0,-1,0,0,0],i=0,r=0;do{if(n[r+i]=e.params[t+r],e.hasSubParams(t+r)){let a=e.getSubParams(t+r),l=0;do n[1]===5&&(i=1),n[r+l+1+i]=a[l];while(++l<a.length&&l+r+1+i<n.length);break}if(n[1]===5&&r+i>=2||n[1]===2&&r+i>=5)break;n[1]&&(i=1)}while(++r+t<e.length&&r+i<n.length);for(let a=2;a<n.length;++a)n[a]===-1&&(n[a]=0);switch(n[0]){case 38:s.fg=this._updateAttrColor(s.fg,n[1],n[3],n[4],n[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,n[1],n[3],n[4],n[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,n[1],n[3],n[4],n[5])}return r}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=qt.fg,e.bg=qt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,n=this._curAttrData;for(let i=0;i<t;i++)s=e.params[i],s>=30&&s<=37?(n.fg&=-50331904,n.fg|=16777216|s-30):s>=40&&s<=47?(n.bg&=-50331904,n.bg|=16777216|s-40):s>=90&&s<=97?(n.fg&=-50331904,n.fg|=16777216|s-90|8):s>=100&&s<=107?(n.bg&=-50331904,n.bg|=16777216|s-100|8):s===0?this._processSGR0(n):s===1?n.fg|=134217728:s===3?n.bg|=67108864:s===4?(n.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,n)):s===5?n.fg|=536870912:s===7?n.fg|=67108864:s===8?n.fg|=1073741824:s===9?n.fg|=2147483648:s===2?n.bg|=134217728:s===21?this._processUnderline(2,n):s===22?(n.fg&=-134217729,n.bg&=-134217729):s===23?n.bg&=-67108865:s===24?(n.fg&=-268435457,this._processUnderline(0,n)):s===25?n.fg&=-536870913:s===27?n.fg&=-67108865:s===28?n.fg&=-1073741825:s===29?n.fg&=2147483647:s===39?(n.fg&=-67108864,n.fg|=qt.fg&16777215):s===49?(n.bg&=-67108864,n.bg|=qt.bg&16777215):s===38||s===48||s===58?i+=this._extractColor(e,i,n):s===53?n.bg|=1073741824:s===55?n.bg&=-1073741825:s===59?(n.extended=n.extended.clone(),n.extended.underlineColor=-1,n.updateExtended()):s===100?(n.fg&=-67108864,n.fg|=qt.fg&16777215,n.bg&=-67108864,n.bg|=qt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${G.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${G.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${G.ESC}[?${t};${s}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=qt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!jb(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${G.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Rb&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Rb&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let n=s.shift(),i=s.shift();if(/^\d+$/.exec(n)){let r=parseInt(n);if(Mb(r))if(i==="?")t.push({type:0,index:r});else{let a=Nb(i);a&&t.push({type:1,index:r,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),n=e.slice(t+1);return n?this._createHyperlink(s,n):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),n,i=s.findIndex(r=>r.startsWith("id="));return i!==-1&&(n=s[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:n,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let n=0;n<s.length&&!(t>=this._specialColors.length);++n,++t)if(s[n]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let i=Nb(s[n]);i&&this._onColor.fire([{type:1,index:this._specialColors[t],color:i}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let n=0;n<s.length;++n)if(/^\d+$/.exec(s[n])){let i=parseInt(s[n]);Mb(i)&&t.push({type:2,index:i})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Ur),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(KL[e[0]],ss[e[1]]||Ur),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=qt.clone(),this._eraseAttrDataInternal=qt.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Sn;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,n=this._activeBuffer.lines.get(s);n&&(n.fill(e),n.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=a=>(this._coreService.triggerDataEvent(`${G.ESC}${a}${G.ESC}\\`),!0),n=this._bufferService.buffer,i=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},tg=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Ab=e,e=t,t=Ab),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};tg=Lt([ve(0,$s)],tg);function Mb(e){return 0<=e&&e<256}var VL=5e7,Db=12,YL=50,GL=class extends Ve{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new he),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>VL)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let n=this._writeBuffer[this._bufferOffset],i=this._action(n,t);if(i){let a=l=>performance.now()-s>=Db?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);i.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let r=this._callbacks[this._bufferOffset];if(r&&r(),this._bufferOffset++,this._pendingData-=n.length,performance.now()-s>=Db)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>YL&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},sg=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let l=t.addMarker(t.ybase+t.y),c={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(c,l)),this._dataByLinkId.set(c.id,c),c.id}let s=e,n=this._getEntryIdKey(s),i=this._entriesWithId.get(n);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let r=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[r]};return r.onDispose(()=>this._removeMarkerFromLink(a,r)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(n=>n.line!==t)){let n=this._bufferService.buffer.addMarker(t);s.lines.push(n),n.onDispose(()=>this._removeMarkerFromLink(s,n))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};sg=Lt([ve(0,$s)],sg);var Ib=!1,JL=class extends Ve{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ea),this._onBinary=this._register(new he),this.onBinary=this._onBinary.event,this._onData=this._register(new he),this.onData=this._onData.event,this._onLineFeed=this._register(new he),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new he),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new he),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new he),this._instantiationService=new bL,this.optionsService=this._register(new TL(e)),this._instantiationService.setService(Fs,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Xm)),this._instantiationService.setService($s,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Jm)),this._instantiationService.setService(Ak,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Zm)),this._instantiationService.setService(yo,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Qm)),this._instantiationService.setService(Tk,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Yr)),this._instantiationService.setService(gI,this.unicodeService),this._charsetService=this._instantiationService.createInstance(PL),this._instantiationService.setService(mI,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(sg),this._instantiationService.setService(Mk,this._oscLinkService),this._inputHandler=this._register(new qL(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(vs.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(vs.forward(this._bufferService.onResize,this._onResize)),this._register(vs.forward(this.coreService.onData,this._onData)),this._register(vs.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new GL((t,s)=>this._inputHandler.parse(t,s))),this._register(vs.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new he),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Ib&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Ib=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,uC),t=Math.max(t,hC),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Cb.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Cb(this._bufferService),!1))),this._windowsWrappingHeuristics.value=xt(()=>{for(let t of e)t.dispose()})}}},XL={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function ZL(e,t,s,n){let i={type:0,cancel:!1,key:void 0},r=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?i.key=G.ESC+"OA":i.key=G.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=G.ESC+"OD":i.key=G.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=G.ESC+"OC":i.key=G.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=G.ESC+"OB":i.key=G.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":G.DEL,e.altKey&&(i.key=G.ESC+i.key);break;case 9:if(e.shiftKey){i.key=G.ESC+"[Z";break}i.key=G.HT,i.cancel=!0;break;case 13:i.key=e.altKey?G.ESC+G.CR:G.CR,i.cancel=!0;break;case 27:i.key=G.ESC,e.altKey&&(i.key=G.ESC+G.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;r?i.key=G.ESC+"[1;"+(r+1)+"D":t?i.key=G.ESC+"OD":i.key=G.ESC+"[D";break;case 39:if(e.metaKey)break;r?i.key=G.ESC+"[1;"+(r+1)+"C":t?i.key=G.ESC+"OC":i.key=G.ESC+"[C";break;case 38:if(e.metaKey)break;r?i.key=G.ESC+"[1;"+(r+1)+"A":t?i.key=G.ESC+"OA":i.key=G.ESC+"[A";break;case 40:if(e.metaKey)break;r?i.key=G.ESC+"[1;"+(r+1)+"B":t?i.key=G.ESC+"OB":i.key=G.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=G.ESC+"[2~");break;case 46:r?i.key=G.ESC+"[3;"+(r+1)+"~":i.key=G.ESC+"[3~";break;case 36:r?i.key=G.ESC+"[1;"+(r+1)+"H":t?i.key=G.ESC+"OH":i.key=G.ESC+"[H";break;case 35:r?i.key=G.ESC+"[1;"+(r+1)+"F":t?i.key=G.ESC+"OF":i.key=G.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=G.ESC+"[5;"+(r+1)+"~":i.key=G.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=G.ESC+"[6;"+(r+1)+"~":i.key=G.ESC+"[6~";break;case 112:r?i.key=G.ESC+"[1;"+(r+1)+"P":i.key=G.ESC+"OP";break;case 113:r?i.key=G.ESC+"[1;"+(r+1)+"Q":i.key=G.ESC+"OQ";break;case 114:r?i.key=G.ESC+"[1;"+(r+1)+"R":i.key=G.ESC+"OR";break;case 115:r?i.key=G.ESC+"[1;"+(r+1)+"S":i.key=G.ESC+"OS";break;case 116:r?i.key=G.ESC+"[15;"+(r+1)+"~":i.key=G.ESC+"[15~";break;case 117:r?i.key=G.ESC+"[17;"+(r+1)+"~":i.key=G.ESC+"[17~";break;case 118:r?i.key=G.ESC+"[18;"+(r+1)+"~":i.key=G.ESC+"[18~";break;case 119:r?i.key=G.ESC+"[19;"+(r+1)+"~":i.key=G.ESC+"[19~";break;case 120:r?i.key=G.ESC+"[20;"+(r+1)+"~":i.key=G.ESC+"[20~";break;case 121:r?i.key=G.ESC+"[21;"+(r+1)+"~":i.key=G.ESC+"[21~";break;case 122:r?i.key=G.ESC+"[23;"+(r+1)+"~":i.key=G.ESC+"[23~";break;case 123:r?i.key=G.ESC+"[24;"+(r+1)+"~":i.key=G.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=G.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=G.DEL:e.keyCode===219?i.key=G.ESC:e.keyCode===220?i.key=G.FS:e.keyCode===221&&(i.key=G.GS);else if((!s||n)&&e.altKey&&!e.metaKey){let a=XL[e.keyCode]?.[e.shiftKey?1:0];if(a)i.key=G.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let l=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(l);e.shiftKey&&(c=c.toUpperCase()),i.key=G.ESC+c}else if(e.keyCode===32)i.key=G.ESC+(e.ctrlKey?G.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let l=e.code.slice(3,4);e.shiftKey||(l=l.toLowerCase()),i.key=G.ESC+l,i.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(i.key=G.US),e.key==="@"&&(i.key=G.NUL));break}return i}var $t=0,QL=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Wh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Wh,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((i,r)=>this._getKey(i)-this._getKey(r)),t=0,s=0,n=new Array(this._array.length+this._insertedValues.length);for(let i=0;i<n.length;i++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(n[i]=e[t],t++):n[i]=this._array[s++];this._array=n,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||($t=this._search(t),$t===-1)||this._getKey(this._array[$t])!==t)return!1;do if(this._array[$t]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push($t),!0;while(++$t<this._array.length&&this._getKey(this._array[$t])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((i,r)=>i-r),t=0,s=new Array(this._array.length-e.length),n=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:s[n++]=this._array[i];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&($t=this._search(e),!($t<0||$t>=this._array.length)&&this._getKey(this._array[$t])===e))do yield this._array[$t];while(++$t<this._array.length&&this._getKey(this._array[$t])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&($t=this._search(e),!($t<0||$t>=this._array.length)&&this._getKey(this._array[$t])===e))do t(this._array[$t]);while(++$t<this._array.length&&this._getKey(this._array[$t])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let n=t+s>>1,i=this._getKey(this._array[n]);if(i>e)s=n-1;else if(i<e)t=n+1;else{for(;n>0&&this._getKey(this._array[n-1])===e;)n--;return n}}return t}},Kf=0,Pb=0,eO=class extends Ve{constructor(){super(),this._decorations=new QL(e=>e?.marker.line),this._onDecorationRegistered=this._register(new he),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new he),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(xt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new tO(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let n=0,i=0;for(let r of this._decorations.getKeyIterator(t))n=r.options.x??0,i=n+(r.options.width??1),e>=n&&e<i&&(!s||(r.options.layer??"bottom")===s)&&(yield r)}forEachDecorationAtCell(e,t,s,n){this._decorations.forEachByKey(t,i=>{Kf=i.options.x??0,Pb=Kf+(i.options.width??1),e>=Kf&&e<Pb&&(!s||(i.options.layer??"bottom")===s)&&n(i)})}},tO=class extends yr{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new he),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new he),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=jt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=jt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},sO=1e3,nO=class{constructor(e,t=sO){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let n=performance.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=n-this._lastRefreshMs,r=this._debounceThresholdMS-i;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},r)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Lb=20,Kh=class extends Ve{constructor(e,t,s,n){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=n,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let r=0;r<this._terminal.rows;r++)this._rowElements[r]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[r]);if(this._topBoundaryFocusListener=r=>this._handleBoundaryFocus(r,0),this._bottomBoundaryFocusListener=r=>this._handleBoundaryFocus(r,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new nO(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(r=>this._handleResize(r.rows))),this._register(this._terminal.onRender(r=>this._refreshRows(r.start,r.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(r=>this._handleChar(r))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
99
+ `))),this._register(this._terminal.onA11yTab(r=>this._handleTab(r))),this._register(this._terminal.onKey(r=>this._handleKey(r.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(De(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(xt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Lb+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
100
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Lb+1&&(this._liveRegion.textContent+=xm.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,n=s.lines.length.toString();for(let i=e;i<=t;i++){let r=s.lines.get(s.ydisp+i),a=[],l=r?.translateToString(!0,void 0,void 0,a)||"",c=(s.ydisp+i+1).toString(),u=this._rowElements[i];u&&(l.length===0?(u.textContent=" ",this._rowColumns.set(u,[0,1])):(u.textContent=l,this._rowColumns.set(u,a)),u.setAttribute("aria-posinset",c),u.setAttribute("aria-setsize",n),this._alignRowWidth(u))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,n=this._rowElements[t===0?1:this._rowElements.length-2],i=s.getAttribute("aria-posinset"),r=t===0?"1":`${this._terminal.buffer.lines.length}`;if(i===r||e.relatedTarget!==n)return;let a,l;if(t===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let n=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:n,offset:n.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let i=({node:l,offset:c})=>{let u=l instanceof Text?l.parentNode:l,h=parseInt(u?.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let d=this._rowColumns.get(u);if(!d)return console.warn("columns is null. Race condition?"),null;let p=c<d.length?d[c]:d.slice(-1)[0]+1;return p>=this._terminal.cols&&(++h,p=0),{row:h,column:p}},r=i(t),a=i(s);if(!(!r||!a)){if(r.row>a.row||r.row===a.row&&r.column>=a.column)throw new Error("invalid range");this._terminal.select(r.column,r.row,(a.row-r.row)*this._terminal.cols-r.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let n=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${n/t})`}};Kh=Lt([ve(1,C_),ve(2,Li),ve(3,Oi)],Kh);var ng=class extends Ve{constructor(e,t,s,n,i){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=n,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new he),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new he),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(xt(()=>{ho(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(De(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(De(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(De(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(De(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let n=0;n<s.length;n++){let i=s[n];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(n=>{n?.forEach(i=>{i.link.dispose&&i.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[n,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(n)&&(s=this._checkLinkProviderResult(n,e,s)):i.provideLinks(e.y,r=>{if(this._isMouseOut)return;let a=r?.map(l=>({link:l}));this._activeProviderReplies?.set(n,a),s=this._checkLinkProviderResult(n,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let n=0;n<t.size;n++){let i=t.get(n);if(i)for(let r=0;r<i.length;r++){let a=i[r],l=a.link.range.start.y<e?0:a.link.range.start.x,c=a.link.range.end.y>e?this._bufferService.cols:a.link.range.end.x;for(let u=l;u<=c;u++){if(s.has(u)){i.splice(r--,1);break}s.add(u)}}}}_checkLinkProviderResult(e,t,s){if(!this._activeProviderReplies)return s;let n=this._activeProviderReplies.get(e),i=!1;for(let r=0;r<e;r++)(!this._activeProviderReplies.has(r)||this._activeProviderReplies.get(r))&&(i=!0);if(!i&&n){let r=n.find(a=>this._linkAtPosition(a.link,t));r&&(s=!0,this._handleNewLink(r))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let r=0;r<this._activeProviderReplies.size;r++){let a=this._activeProviderReplies.get(r)?.find(l=>this._linkAtPosition(l.link,t));if(a){s=!0,this._handleNewLink(a);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&iO(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,ho(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let n=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(n,i),this._lastMouseEvent)){let r=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);r&&this._askForLink(r,!1)}})))}_linkHover(e,t,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,n=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-n-1,s.end.x,s.end.y-n-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,n=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return s<=i&&i<=n}_positionFromMouseEvent(e,t,s){let n=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(n)return{x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,n,i){return{x1:e,y1:t,x2:s,y2:n,cols:this._bufferService.cols,fg:i}}};ng=Lt([ve(1,E_),ve(2,Oi),ve(3,$s),ve(4,Ik)],ng);function iO(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var rO=class extends JL{constructor(e={}){super(e),this._linkifier=this._register(new Ea),this.browser=Qk,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ea),this._onCursorMove=this._register(new he),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new he),this.onKey=this._onKey.event,this._onRender=this._register(new he),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new he),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new he),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new he),this.onBell=this._onBell.event,this._onFocus=this._register(new he),this._onBlur=this._register(new he),this._onA11yCharEmitter=this._register(new he),this._onA11yTabEmitter=this._register(new he),this._onWillOpen=this._register(new he),this._setup(),this._decorationService=this._instantiationService.createInstance(eO),this._instantiationService.setService(Dc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(YP),this._instantiationService.setService(Ik,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(km)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(vs.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(vs.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(vs.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(vs.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(xt(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,n="";switch(t.index){case 256:s="foreground",n="10";break;case 257:s="background",n="11";break;case 258:s="cursor",n="12";break;default:s="ansi",n="4;"+t.index}switch(t.type){case 0:let i=yt.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${G.ESC}]${n};${WL(i)}${Xk.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(r=>r.ansi[t.index]=Vt.toColor(...t.color));else{let r=s;this._themeService.modifyColors(a=>a[r]=Vt.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Kh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(G.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(G.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),n=this._renderService.dimensions.css.cell.height,i=t.getWidth(s),r=this._renderService.dimensions.css.cell.width*i,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=r+"px",this.textarea.style.height=n+"px",this.textarea.style.lineHeight=n+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(De(this.element,"copy",t=>{this.hasSelection()&&cI(t,this._selectionService)}));let e=t=>uI(t,this.textarea,this.coreService,this.optionsService);this._register(De(this.textarea,"paste",e)),this._register(De(this.element,"paste",e)),eC?this._register(De(this.element,"mousedown",t=>{t.button===2&&qy(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(De(this.element,"contextmenu",t=>{qy(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),I_&&this._register(De(this.element,"auxclick",t=>{t.button===1&&Ck(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(De(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(De(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(De(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(De(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(De(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(De(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(De(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(De(this.screenElement,"mousemove",i=>this.updateCursorStyle(i))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",wm.get()),nC||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(qP,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Li,this._coreBrowserService),this._register(De(this.textarea,"focus",i=>this._handleTextAreaFocus(i))),this._register(De(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Km,this._document,this._helperContainer),this._instantiationService.setService(bd,this._charSizeService),this._themeService=this._instantiationService.createInstance(Gm),this._instantiationService.setService(Aa,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Hh),this._instantiationService.setService(Dk,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Vm,this.rows,this.screenElement)),this._instantiationService.setService(Oi,this._renderService),this._register(this._renderService.onRenderedViewportChange(i=>this._onRender.fire(i))),this.onResize(i=>this._renderService.resize(i.cols,i.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Hm,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(qm),this._instantiationService.setService(E_,this._mouseService);let n=this._linkifier.value=this._register(this._instantiationService.createInstance(ng,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Fm,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(i=>{super.scrollLines(i,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Ym,this.element,this.screenElement,n)),this._instantiationService.setService(vI,this._selectionService),this._register(this._selectionService.onRequestScrollLines(i=>this.scrollLines(i.amount,i.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(i=>this._renderService.handleSelectionChanged(i.start,i.end,i.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(i=>{this.textarea.value=i,this.textarea.focus(),this.textarea.select()})),this._register(vs.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(zm,this.screenElement)),this._register(De(this.element,"mousedown",i=>this._selectionService.handleMouseDown(i))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Kh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",i=>this._handleScreenReaderModeOptionChange(i))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(zh,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",i=>{!this._overviewRulerRenderer&&i&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(zh,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Wm,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(r){let a=e._mouseService.getMouseReportCoords(r,e.screenElement);if(!a)return!1;let l,c;switch(r.overrideType||r.type){case"mousemove":c=32,r.buttons===void 0?(l=3,r.button!==void 0&&(l=r.button<3?r.button:3)):l=r.buttons&1?0:r.buttons&4?1:r.buttons&2?2:3;break;case"mouseup":c=0,l=r.button<3?r.button:3;break;case"mousedown":c=1,l=r.button<3?r.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(r)===!1)return!1;let u=r.deltaY;if(u===0||e.coreMouseService.consumeWheelEvent(r,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;c=u<0?0:1,l=4;break;default:return!1}return c===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:c,ctrl:r.ctrlKey,alt:r.altKey,shift:r.shiftKey})}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:r=>(s(r),r.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.mousedrag)),this.cancel(r)),wheel:r=>(s(r),this.cancel(r,!0)),mousedrag:r=>{r.buttons&&s(r)},mousemove:r=>{r.buttons||s(r)}};this._register(this.coreMouseService.onProtocolChange(r=>{r?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(r)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),r&8?n.mousemove||(t.addEventListener("mousemove",i.mousemove),n.mousemove=i.mousemove):(t.removeEventListener("mousemove",n.mousemove),n.mousemove=null),r&16?n.wheel||(t.addEventListener("wheel",i.wheel,{passive:!1}),n.wheel=i.wheel):(t.removeEventListener("wheel",n.wheel),n.wheel=null),r&2?n.mouseup||(n.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),r&4?n.mousedrag||(n.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(De(t,"mousedown",r=>{if(r.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(r)))return s(r),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(r)})),this._register(De(t,"wheel",r=>{if(!n.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(r)===!1)return!1;if(!this.buffer.hasScrollback){if(r.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(r,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(r,!0);let a=G.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(r.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(a,!0),this.cancel(r,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){kk(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=ZL(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let n=this.rows-1;return this.scrollLines(s.type===2?-n:n),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===G.ETX||s.key===G.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(oO(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(qt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(G.ESC+"[I"):this.coreService.triggerDataEvent(G.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${G.ESC}[4;${s};${t}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),i=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${G.ESC}[6;${i};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function oO(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var aO=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},lO=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Sn)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},Ob=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new lO(t)}getNullCell(){return new Sn}},cO=class extends Ve{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new he),this.onBufferChange=this._onBufferChange.event,this._normal=new Ob(this._core.buffers.normal,"normal"),this._alternate=new Ob(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},uO=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,n)=>t(s,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},hO=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},dO=["cols","rows"],Xn=0,fO=class extends Ve{constructor(e){super(),this._core=this._register(new rO(e)),this._addonManager=this._register(new aO),this._publicOptions={...this._core.options};let t=n=>this._core.options[n],s=(n,i)=>{this._checkReadonlyOptions(n),this._core.options[n]=i};for(let n in this._core.options){let i={get:t.bind(this,n),set:s.bind(this,n)};Object.defineProperty(this._publicOptions,n,i)}}_checkReadonlyOptions(e){if(dO.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new uO(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new hO(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new cO(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
101
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return wm.get()},set promptLabel(e){wm.set(e)},get tooMuchOutput(){return xm.get()},set tooMuchOutput(e){xm.set(e)}}}_verifyIntegers(...e){for(Xn of e)if(Xn===1/0||isNaN(Xn)||Xn%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Xn of e)if(Xn&&(Xn===1/0||isNaN(Xn)||Xn%1!==0||Xn<0))throw new Error("This API only accepts positive integers")}};/**
102
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
103
+ * @license MIT
104
+ *
105
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
106
+ * @license MIT
107
+ *
108
+ * Originally forked from (with the author's permission):
109
+ * Fabrice Bellard's javascript vt100 for jslinux:
110
+ * http://bellard.org/jslinux/
111
+ * Copyright (c) 2011 Fabrice Bellard
112
+ */var pO=2,mO=1,gO=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),n=parseInt(s.getPropertyValue("height")),i=Math.max(0,parseInt(s.getPropertyValue("width"))),r=window.getComputedStyle(this._terminal.element),a={top:parseInt(r.getPropertyValue("padding-top")),bottom:parseInt(r.getPropertyValue("padding-bottom")),right:parseInt(r.getPropertyValue("padding-right")),left:parseInt(r.getPropertyValue("padding-left"))},l=a.top+a.bottom,c=a.right+a.left,u=n-l,h=i-c-t;return{cols:Math.max(pO,Math.floor(h/e.css.cell.width)),rows:Math.max(mO,Math.floor(u/e.css.cell.height))}}};function _O(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} kB`:`${(e/1048576).toFixed(1)} MB`}const Bb=new Set(["markdown","code","text","csv","html"]);function vO(e){const t=e?.httpBody;return!t||t.error!=="changed_on_disk"?null:{content:t.content??"",hash:t.hash??""}}function yO({path:e,line:t,onClose:s}){const[n,i]=g.useState(null),[r,a]=g.useState(""),[l,c]=g.useState(!1),[u,h]=g.useState(!1),[d,p]=g.useState(""),[f,m]=g.useState(null),[b,_]=g.useState(!1),[v,y]=g.useState(""),w=g.useRef(e),x=g.useCallback(async(I,F={})=>{w.current=I,c(!0),a("");try{const B=await ee.statFile(I);if(w.current!==I)return;if(!Bb.has(B.kind)){i({...B,content:"",truncated:!1,binary:!0}),m(null);return}const C=await ee.readFile(I);if(w.current!==I)return;i({...B,content:C.content,truncated:C.truncated,binary:C.binary}),F.keepDraft||(p(C.content),h(!1)),m(null)}catch(B){w.current===I&&a(String(B?.message??B))}finally{w.current===I&&c(!1)}},[]);g.useEffect(()=>{x(e)},[e,x]),g.useEffect(()=>{i(null),h(!1),p(""),y("")},[e]),g.useEffect(()=>{if(!n)return;const I=window.setInterval(()=>{(async()=>{try{const F=await ee.statFile(e);if(w.current!==e||F.hash===n.hash)return;if(u){m({content:"",hash:F.hash});return}await x(e)}catch{}})()},3e3);return()=>window.clearInterval(I)},[n,u,e,x]);const S=!!(n&&u&&d!==n.content),E=g.useCallback(async()=>{if(n){_(!0),y("");try{const I=await ee.writeFile(n.path,d,n.hash);i({...n,content:d,hash:I.hash,mtimeMs:I.mtimeMs,size:I.size}),h(!1),y("saved"),window.setTimeout(()=>y(""),1500)}catch(I){const F=vO(I);F?m(F):a(String(I?.message??I))}finally{_(!1)}}},[n,d]);g.useEffect(()=>{if(!u)return;const I=F=>{(F.metaKey||F.ctrlKey)&&F.key.toLowerCase()==="s"&&(F.preventDefault(),E())};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[u,E]);const R=!!n?.editable&&!n?.binary,N=g.useMemo(()=>n?n.binary&&!Bb.has(n.kind)?o.jsx(bO,{file:n}):u?o.jsx("textarea",{className:"file-edit",value:d,spellCheck:!1,"aria-label":`edit ${n.name}`,onChange:I=>p(I.target.value)}):o.jsx(wO,{file:n,line:t}):o.jsx("div",{className:"tool-note",children:"loading…"}),[n,u,d,t]);return o.jsxs("div",{className:"file-preview",children:[o.jsxs("div",{className:"file-preview-head",children:[o.jsx("button",{className:"icon-btn",title:"close preview","aria-label":"close preview",onClick:s,children:o.jsx(e_,{size:14})}),o.jsx(ci,{size:13}),o.jsxs("span",{className:"file-name",title:n?.path??e,children:[n?.name??e.split("/").pop()??e,S?o.jsx("span",{className:"file-dirty",title:"unsaved changes",children:" ●"}):null]}),o.jsxs("span",{className:"file-size",children:[_O(n?.size),n?.truncated&&!u?" · showing the head":"",v?` · ${v}`:"",l&&n?" · loading…":""]}),o.jsx("span",{className:"head-spacer"}),o.jsx("button",{className:"icon-btn",title:`open ${n?.name??"file"} in a new tab`,"aria-label":"open raw",onClick:()=>window.open(Rh(n?.path??e),"_blank","noopener"),children:o.jsx(_S,{size:13})}),R?u?o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"icon-btn",title:"save (⌘S)","aria-label":"save",disabled:b||!S,onClick:()=>void E(),children:"save"}),o.jsx("button",{className:"icon-btn",title:"discard and leave the editor","aria-label":"cancel edit",onClick:()=>{h(!1),p(n?.content??"")},children:"cancel"})]}):o.jsx("button",{className:"icon-btn",title:"edit this file","aria-label":"edit",onClick:()=>{h(!0),p(n?.content??"")},children:"edit"}):null]}),f?o.jsxs("div",{className:"file-conflict",children:[o.jsx("span",{children:f.content?"this file changed on disk since you opened it":"the agent changed this file while you were editing"}),o.jsx("button",{className:"icon-btn",onClick:()=>{S&&!window.confirm("discard your changes and load the file from disk?")||(m(null),x(e))},children:"reload theirs"}),o.jsx("button",{className:"icon-btn",onClick:()=>m(null),children:"keep mine"})]}):null,r?o.jsx("div",{className:"tool-error",children:r}):null,o.jsx("div",{className:"file-preview-body",children:N})]})}function bO({file:e}){const t=Rh(e.path);return e.kind==="image"?o.jsx("a",{className:"file-image-wrap",href:t,target:"_blank",rel:"noopener noreferrer",title:"open full size",children:o.jsx("img",{className:"file-image",src:t,alt:e.name})}):e.kind==="pdf"?o.jsx("iframe",{className:"file-frame",src:t,title:e.name}):e.kind==="audio"?o.jsx("audio",{className:"file-audio",src:t,controls:!0,preload:"metadata"}):e.kind==="video"?o.jsx("video",{className:"file-video",src:t,controls:!0,preload:"metadata"}):o.jsxs("div",{className:"tool-note",children:["no preview for this type yet (",e.kind,")",o.jsx("div",{className:"file-fallback",children:o.jsx("a",{className:"icon-btn",href:t,target:"_blank",rel:"noopener noreferrer",children:"open in a new tab"})})]})}function wO({file:e,line:t}){const[s,n]=g.useState(!!t||e.kind!=="markdown"),i=g.useRef(null),r=g.useRef(null);return g.useEffect(()=>{s||a_(r.current)},[s,e.content]),g.useEffect(()=>{n(!!t||e.kind!=="markdown")},[e.path,e.kind,t]),g.useEffect(()=>{if(!t||!i.current)return;i.current.querySelector(`[data-line="${t}"]`)?.scrollIntoView({block:"center"})},[t,s,e.content]),e.binary?o.jsx("div",{className:"tool-note",children:"binary file — no preview"}):o.jsxs(o.Fragment,{children:[e.kind==="markdown"?o.jsxs("div",{className:"file-view-toggle",children:[o.jsx("button",{className:`tool-tab ${s?"":"active"}`,onClick:()=>n(!1),children:"rendered"}),o.jsx("button",{className:`tool-tab ${s?"active":""}`,onClick:()=>n(!0),children:"source"})]}):null,s?o.jsx("div",{className:"file-source",ref:i,children:e.content.split(`
113
+ `).map((a,l)=>o.jsxs("div",{className:`file-line ${t===l+1?"hit":""}`,"data-line":l+1,children:[o.jsx("span",{className:"file-ln",children:l+1}),o.jsx("span",{className:"file-lt",children:a||" "})]},`${l}-${a}`))}):o.jsx("div",{className:"md file-md",ref:r,dangerouslySetInnerHTML:{__html:__(e.content,e.path.replace(/\/[^/]*$/,"")||"/")}})]})}const $b=360,qf=(e,t,s)=>Math.max(t,Math.min(s,e));function xO(e,t){try{const s=window.localStorage.getItem(e),n=s===null?Number.NaN:Number.parseFloat(s);return Number.isFinite(n)&&n>0?n:t}catch{return t}}function Vf(e,t){try{window.localStorage.setItem(e,String(Math.round(t)))}catch{}}function ig(e){const{storage:t,fallback:s,min:n,max:i,rightEdge:r=!1,label:a}=e,[l,c]=g.useState(()=>xO(t,s)),[,u]=g.useState(0);g.useEffect(()=>{const b=()=>u(_=>_+1);return window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[]);const h=Math.max(n,i()),d=qf(l,n,h),p=g.useRef(d);p.current=d,g.useEffect(()=>{l>h&&(c(h),Vf(t,h))},[l,h,t]);const f=g.useCallback(b=>{if(b.pointerType!=="touch"&&b.button!==0)return;b.preventDefault();const _=b.currentTarget,v=b.clientX,y=p.current,w=Math.max(n,i());let x=y,S=0,E=!1;const R=document.body;R.classList.add("pane-dragging");const N=A=>{if(!E){if(E=!0,S&&window.cancelAnimationFrame(S),typeof A=="number"){const M=r?A-v:v-A;x=qf(y+M,n,w)}c(x),Vf(t,x),R.classList.remove("pane-dragging"),window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",F),window.removeEventListener("pointercancel",F),window.removeEventListener("blur",B),_.removeEventListener("lostpointercapture",C);try{_.hasPointerCapture?.(b.pointerId)&&_.releasePointerCapture(b.pointerId)}catch{}}},I=A=>{if(E)return;if(A.buttons===0){N(A.clientX);return}const M=r?A.clientX-v:v-A.clientX;x=qf(y+M,n,w),!S&&(S=window.requestAnimationFrame(()=>{S=0,c(x)}))},F=A=>N(A.clientX),B=()=>N(),C=()=>N();try{_.setPointerCapture(b.pointerId)}catch{}_.addEventListener("lostpointercapture",C),window.addEventListener("pointermove",I),window.addEventListener("pointerup",F),window.addEventListener("pointercancel",F),window.addEventListener("blur",B)},[n,i,r,t]),m=o.jsx("div",{className:"pane-handle",role:"separator","aria-orientation":"vertical","aria-label":a,title:`${a} — drag to resize, double-click to reset`,onPointerDown:f,onDoubleClick:()=>{c(s),Vf(t,s)},children:o.jsx("span",{className:"pane-handle-line"})});return{width:d,handle:m}}const SO={black:"#2e3436",red:"#cc0000",green:"#4e9a06",yellow:"#c4a000",blue:"#3465a4",magenta:"#75507b",cyan:"#06989a",white:"#d3d7cf",brightBlack:"#555753",brightRed:"#ef2929",brightGreen:"#8ae234",brightYellow:"#fce94f",brightBlue:"#729fcf",brightMagenta:"#ad7fa8",brightCyan:"#34e2e2",brightWhite:"#eeeeec"},kO={black:"#636c79",red:"#e06c75",green:"#98c379",yellow:"#e5c07b",blue:"#61afef",magenta:"#c678dd",cyan:"#56b6c2",white:"#dcdfe4",brightBlack:"#8b949e",brightRed:"#ff7b86",brightGreen:"#b5e08f",brightYellow:"#ffd580",brightBlue:"#82c4ff",brightMagenta:"#e0a0f0",brightCyan:"#7fd8e0",brightWhite:"#ffffff"};function Fb(e){return e?kO:SO}function zb(e){const t=[],s=[0,95,135,175,215,255];for(const r of s)for(const a of s)for(const l of s)t.push(Hb(r,a,l));const n=e?78:8,i=e?242:238;for(let r=0;r<24;r+=1){const a=Math.round(n+r*(i-n)/23);t.push(Hb(a,a,a))}return t}function Hb(e,t,s){return`#${[e,t,s].map(n=>n.toString(16).padStart(2,"0")).join("")}`}const CO=300,Yf="agentus.panel-tree-folded",Gf="agentus.panel-preview-folded";function Ub(e,t){try{const s=localStorage.getItem(e);return s==null?t:s==="1"}catch{return t}}function Ru(e,t){try{localStorage.setItem(e,t?"1":"0")}catch{}}function EO(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} kB`:`${(e/1048576).toFixed(1)} MB`}function NO({v:e,onClose:t,onPickWorkspace:s,focus:n,panelWidth:i,panelHandle:r}){Ta(typeof window<"u"&&window.matchMedia("(max-width: 720px)").matches,t);const[a,l]=g.useState("files"),c=e.info.workspace||e.info.cwd,[u,h]=g.useState(c),d=ig({storage:"agentus.explorer-width",fallback:300,min:220,max:()=>Math.max(220,Math.min(460,i-CO)),rightEdge:!1,label:"resize the file tree"}),[p,f]=g.useState(null),[m,b]=g.useState(""),[_,v]=g.useState(null),[y,w]=g.useState(!1),[x,S]=g.useState(()=>Ub(Yf,!1)),[E,R]=g.useState(()=>Ub(Gf,!1)),N=M=>{const H=!x;S(H),Ru(Yf,H),H&&E&&(R(!1),Ru(Gf,!1))},I=M=>{const H=M??!E;R(H),Ru(Gf,H),H&&x&&(S(!1),Ru(Yf,!1))};g.useEffect(()=>{h(c),v(null)},[c,e.info.id]),g.useEffect(()=>{if(!n)return;l("files"),v(n),I(!1);const M=n.path.replace(/\/[^/]*$/,"")||"/";h(M)},[n]);const F=g.useCallback(async M=>{w(!0),b("");try{const H=await ee.listEntries(M);f(H)}catch(H){b(String(H?.message??H))}finally{w(!1)}},[]);g.useEffect(()=>{F(u)},[u,F]);const B=M=>{if(M.kind==="dir"){h(M.path),v(null);return}v({path:M.path}),I(!1)},A=g.useMemo(()=>{if(!p)return[];const M=p.path.startsWith("/")?"/":"\\";if(!(p.root&&(p.path===p.root||p.path.startsWith(`${p.root}${M}`)))||!p.root)return[{label:p.path===p.home?"~":p.path,path:p.path}];const D=p.path.slice(p.root.length).split(M).filter(Boolean),z=[{label:c.split(M).filter(Boolean).pop()??c,path:p.root}];let T=p.root;for(const O of D)T=`${T}${M}${O}`,z.push({label:O,path:T});return z},[p,c]).map(M=>M.label).join(" / ");return o.jsxs("aside",{className:"tool-panel","aria-label":"workspace panel",style:{"--panel-w":`${i}px`},children:[r,o.jsxs("div",{className:"tool-tabs",children:[o.jsxs("button",{className:`tool-tab ${a==="files"?"active":""}`,onClick:()=>l("files"),children:[o.jsx(ci,{size:14})," files"]}),o.jsxs("button",{className:`tool-tab ${a==="terminal"?"active":""}`,onClick:()=>l("terminal"),children:[o.jsx(_N,{size:14})," terminal"]}),o.jsx("span",{className:"head-spacer"}),a==="files"?o.jsxs(o.Fragment,{children:[o.jsx("button",{className:`icon-btn ${_&&!E?"on":""}`,disabled:!_,title:E||!_?"展开预览列":"收起预览列","aria-label":"toggle the preview column","aria-pressed":!!_&&!E,onClick:()=>I(),children:o.jsx(mN,{size:15})}),o.jsx("button",{className:`icon-btn ${x?"":"on"}`,title:x?"展开文件树":"收起文件树","aria-label":"toggle the file tree column","aria-pressed":!x,onClick:()=>N(),children:o.jsx(gN,{size:15})})]}):null,o.jsx("button",{className:"icon-btn",title:`workspace: ${c}
114
+ click to point this session at another directory`,"aria-label":"change workspace",onClick:s,children:o.jsx(SN,{size:15})}),o.jsx("button",{className:"icon-btn",title:"close panel","aria-label":"close panel",onClick:t,children:o.jsx(En,{size:15})})]}),a==="files"?o.jsxs("div",{className:`panel-split ${_?"has-preview":""} ${x?"tree-folded":""} ${E?"preview-folded":""}`,children:[_?o.jsx("div",{className:"preview-col",children:o.jsx(yO,{path:_.path,line:_.line,onClose:()=>v(null)})}):null,o.jsxs("div",{className:"explorer-col",style:{"--explorer-w":`${d.width}px`},children:[_?d.handle:null,o.jsxs("div",{className:"ws-root",title:c,children:[o.jsx(co,{size:13}),o.jsx("span",{className:"ws-root-name",children:A||c})]}),o.jsxs("div",{className:"file-bar",children:[o.jsx("button",{className:"icon-btn",title:"parent directory","aria-label":"parent directory",disabled:!p?.parent,onClick:()=>p?.parent&&h(p.parent),children:o.jsx(e_,{size:15})}),o.jsx("button",{className:"icon-btn",title:`home (${p?.home??"~"})`,"aria-label":"home",onClick:()=>p?.home&&h(p.home),children:o.jsx(vS,{size:15})}),o.jsx("span",{className:"file-bar-path",title:p?.path??u,children:p?.path??u}),o.jsx("button",{className:"icon-btn",title:"refresh","aria-label":"refresh",onClick:()=>void F(u),children:o.jsx(ba,{size:14})})]}),m?o.jsx("div",{className:"tool-error",children:m}):null,y&&!p?o.jsx("div",{className:"tool-note",children:"loading…"}):null,o.jsxs("div",{className:"file-list",children:[p?.entries.map(M=>o.jsxs("button",{className:`file-row ${_?.path===M.path?"sel":""}`,title:M.path,onClick:()=>B(M),children:[M.kind==="dir"?o.jsx(co,{size:14}):o.jsx(ci,{size:14}),o.jsx("span",{className:"file-name",children:M.name}),M.kind==="file"?o.jsx("span",{className:"file-size",children:EO(M.size)}):null,M.kind==="dir"?o.jsx(an,{size:13,className:"file-enter"}):null]},M.path)),p&&!p.entries.length?o.jsx("div",{className:"tool-note",children:"empty directory"}):null,p?.truncated?o.jsxs("div",{className:"tool-note",children:["list capped at ",p.entries.length," entries"]}):null]})]})]}):o.jsx(TO,{v:e,root:c})]})}function Wb(e){const t=getComputedStyle(document.documentElement),s=(n,i)=>t.getPropertyValue(n).trim()||i;return e?{background:s("--bg-panel","#121a22"),foreground:s("--text","#e3ecf3"),cursor:s("--accent","#4aacdf"),selectionBackground:"rgba(74,172,223,0.30)",...Fb(!0),extendedAnsi:zb(!0)}:{background:s("--bg-panel","#ffffff"),foreground:s("--text","#1c2735"),cursor:s("--accent","#2679a5"),selectionBackground:"rgba(38,121,165,0.25)",...Fb(!1),extendedAnsi:zb(!1)}}const RO=384*1024,jO=96*1024;function TO({v:e,root:t}){const[s,n]=g.useState("connecting"),[i,r]=g.useState(""),[a,l]=g.useState(0),[c,u]=g.useState(null),h=g.useRef(null),d=g.useRef(null),p=g.useRef(null),f=g.useRef(()=>{});g.useEffect(()=>{const _=h.current;if(!_)return;let v=!1,y=0,w=!1,x=0,S=0;n("connecting"),r(""),u(null);const E=Q1(X1()),R=new fO({theme:Wb(E),fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',fontSize:12.5,lineHeight:1.25,cursorBlink:!0,scrollback:5e3,allowProposedApi:!0}),N=new gO;R.loadAddon(N),R.open(_),d.current=R;try{N.fit()}catch{}const I=R.cols||80,F=R.rows||24;x=I,S=F;const C=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws/term?sessionId=${encodeURIComponent(e.info.id)}&cols=${I}&rows=${F}`;let A;try{A=new WebSocket(C)}catch(K){n("error"),r(String(K?.message??K));return}p.current=A;const M=()=>p.current===A;A.onopen=()=>{M()&&(n("ready"),r(""))},A.onmessage=K=>{if(!M())return;let U;try{U=JSON.parse(String(K.data))}catch{return}if(U.t==="term-data"&&typeof U.data=="string"){const re=U.data.length;y+=re,R.write(U.data,()=>{y-=re,w&&y<=jO&&M()&&A.readyState===WebSocket.OPEN&&(w=!1,A.send(JSON.stringify({t:"term-resume"})))}),!w&&y>=RO&&A.readyState===WebSocket.OPEN&&(w=!0,A.send(JSON.stringify({t:"term-pause"})));return}if(U.t==="term-ready"){n("ready"),r(""),typeof U.tty=="boolean"&&u(U.tty);return}if(U.t==="term-exit"){n("closed");return}U.t==="term-error"&&(n("error"),r(U.error??"terminal error"))},A.onclose=()=>{v||!M()||n(K=>K==="error"?K:"closed")},A.onerror=()=>{M()&&r(K=>K||"terminal socket failed")};const H=K=>{A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({t:"term-input",data:K}))};f.current=H;const D=R.onData(H),z=()=>{try{N.fit()}catch{return}_.dataset.termCols=String(R.cols),_.dataset.termRows=String(R.rows),!(R.cols===x&&R.rows===S)&&(x=R.cols,S=R.rows,A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({t:"term-resize",cols:R.cols,rows:R.rows})))},T=new ResizeObserver(()=>z());T.observe(_.parentElement??_);const O=()=>z();return window.addEventListener("resize",O),R.focus(),()=>{v=!0,T.disconnect(),window.removeEventListener("resize",O),D.dispose();try{A.send(JSON.stringify({t:"term-close"}))}catch{}A.close(),p.current=null,R.dispose(),d.current=null}},[e.info.id,t,a]);const m=sk();g.useEffect(()=>{const _=d.current;_&&(_.options.theme=Wb(m))},[m]);const b=s==="ready"?c===!1?"shell (no tty)":"shell":s==="connecting"?"starting…":s;return o.jsxs("div",{className:"tool-body term-body",children:[o.jsxs("div",{className:"term-bar",children:[o.jsx("span",{className:`term-dot ${s}`}),o.jsxs("span",{className:"term-status",title:c===!1?"this shell runs on pipes, not a tty: no prompt, no colours, no full-screen apps":void 0,children:[b,s==="ready"?o.jsxs("span",{className:"term-cwd",title:t,children:[" ",t.split("/").filter(Boolean).pop()]}):null]}),o.jsx("span",{className:"head-spacer"}),o.jsx("button",{className:"icon-btn",title:"send Ctrl-C","aria-label":"send interrupt",onClick:()=>f.current(""),children:o.jsx(En,{size:13})}),o.jsx("button",{className:"icon-btn",title:"new shell","aria-label":"new shell",onClick:()=>l(_=>_+1),children:o.jsx(ba,{size:14})})]}),i?o.jsx("div",{className:"tool-error",children:i}):null,o.jsx("div",{className:"term-host",ref:h,"data-term-host":"1",onClick:()=>d.current?.focus()}),c===!1?o.jsx("div",{className:"term-note",children:"no tty on this machine (python3 missing) — pipe shell: no prompt, no colours, no full-screen apps"}):null]})}const Xu=5;function AO(e,t){const s=new Map;for(const n of t)s.set(n.id,{s:n,cold:!0});for(const n of e)s.set(n.id,{s:n,cold:!!n.cold});return[...s.values()]}function MO(e,t={}){const s=Math.min(100,Math.max(1,Math.floor(t.limit??Xu))),n=[...e];if(t.searching||t.expanded||n.length<=s)return{shown:n,hidden:0};const i=n.slice(0,s),r=u=>!!(t.isActive?.(u)||t.mustShow?.(u)),a=n.slice(s).filter(r);if(!a.length)return{shown:i,hidden:n.length-i.length};const l=Math.max(0,Math.min(i.length,a.length)),c=[...i.slice(0,i.length-l),...a];return{shown:c,hidden:n.length-c.length}}const DO=9.5,IO="(max-width: 720px)";function PO(e,t){return e.getBoundingClientRect().height>t*1.2}function fC(e){if(!e||typeof window>"u")return;const t=window.matchMedia?.(IO)?.matches??!1,s=[...e.querySelectorAll(".step-title")],n=s.map(r=>(r.style.fontSize="",null));if(!t)return;let i=1/0;for(let r=0;r<s.length;r++){const a=s[r],l=getComputedStyle(a),c=parseFloat(l.lineHeight)||parseFloat(l.fontSize)*1.4;let u=parseFloat(l.fontSize)||13;for(;PO(a,c)&&u>DO;)u=Math.round((u-.5)*10)/10,a.style.fontSize=`${u}px`;n[r]=u,i=Math.min(i,u)}if(Number.isFinite(i))for(const r of s)r.style.fontSize=`${i}px`}const LO="[IMPORTANT: Background process ";function OO(e){const t=e.trim();if(!t.startsWith(LO))return null;const s=t.split(`
115
+ `),n=/^\[IMPORTANT: Background process (\S+) (.+?)\.?\]?$/.exec(s[0]??"");if(!n)return null;const i=n[2].trim(),r=/\(exit code (-?\d+)\)/.exec(i),a=i.replace(/\(exit code -?\d+\)/,"").replace(/\.$/,"").trim(),l=/matched watch pattern\s+"(.*)"/.exec(a);let c="",u=-1;for(let d=1;d<s.length;d++)if(s[d].startsWith("Command: "))c=s[d].slice(9).trim();else if(/^(Matched output|Output):$/.test(s[d].trim())){u=d+1;break}let h=u>=0?s.slice(u).join(`
116
+ `):"";return h=h.replace(/\n?\]\s*$/,""),{id:n[1],command:c,exitCode:r?Number(r[1]):null,ok:l?!0:/^completed normally$/i.test(a),kind:l?"watch":"exit",pattern:l?l[1]:"",output:h.replace(/\s+$/,"")}}function Kb(e,t=64){const s=e.replace(/\s+/g," ").trim();return s?s.length<=t?s:`${s.slice(0,t-1)}…`:"(no command)"}const BO=/^\[?ASYNC DELEGATION (?:BATCH )?COMPLETE\s*[—–-]\s*(\S+?)\]?$/,$O=/^---\s*(✓|✗|!|\?)?\s*TASK (\d+)\/(\d+):\s*(.*?)\s*(?:\(([^)]*)\))?\s*---$/;function FO(e){const s=e.trim().split(`
117
+ `),n=BO.exec((s[0]??"").trim());if(!n)return null;const i={id:n[1],dispatched:"",ago:"",role:"",total:"",tasks:[]};let r=null,a=[];const l=()=>{r&&(r.body=a.join(`
118
+ `).replace(/^\s*\n+/,"").replace(/\s+$/,""),i.tasks.push(r),a=[])};for(let c=1;c<s.length;c++){const u=s[c],h=$O.exec(u.trim());if(h){l();const m=(h[5]??"").trim(),b=/status\s*=\s*([\w-]+)/.exec(m);r={index:Number(h[2]),total:Number(h[3]),ok:h[1]!=="✗"&&h[1]!=="!"&&(!b||!/^(interrupted|failed|error|cancelled)$/i.test(b[1])),goal:(h[4]??"").trim(),status:b?b[1]:h[1]==="✓"?"completed":"",meta:m.replace(/status\s*=\s*[\w-]+\s*,?\s*/i,"").replace(/,\s*$/,"").trim(),body:""};continue}if(r){a.push(u);continue}const d=/^Dispatched:\s*(.+?)(?:\s*\(([^)]*)\))?\s*$/.exec(u);if(d){i.dispatched=d[1].trim(),i.ago=(d[2]??"").trim();continue}const p=/^Role:\s*([^\s]+)/.exec(u);p&&(i.role=p[1]);const f=/Total duration:\s*([\w.]+)/.exec(u);f&&(i.total=f[1])}return l(),i.tasks.length?i:null}function zO(e){const t=e.tasks.length,s=e.tasks.filter(i=>!i.ok).length,n=e.ago||e.total;return`${t} 个任务${s?` · ${s} 个未完成`:""}${n?` · ${n}`:""}`}function Bo(e){const t=Number.isFinite(e)?Math.max(0,Math.round(e)):0;return t<1024?String(t):t<1048576?`${qb(t/1024)}k`:`${qb(t/1048576)}m`}function qb(e){return Number.isInteger(e)?String(e):e.toFixed(1)}const so=new Map,Ul=new Map,qh=new Set;let P_=0;function pC(e,t){return t==null?e:`${e}#${t}`}function HO(e){return qh.add(e),()=>qh.delete(e)}function Vb(){return P_}function UO(e){return so.get(e)}function WO(e){const t=Ul.get(e);return t?so.get(t):so.get(e)}function KO(e,t,s){so.set(t,s),Ul.set(e,t),P_++;for(const n of qh)n()}function qO(e){const t=e.includes("#")?e.slice(0,e.lastIndexOf("#")):e;let s=!1;for(const n of[...so.keys()])n!==e&&n!==t&&!n.startsWith(`${t}#`)||(so.delete(n),s=!0);if((Ul.get(t)===e||!so.has(Ul.get(t)??""))&&Ul.delete(t),!!s){P_++;for(const n of qh)n()}}class VO extends Error{constructor(t,s){super(t),this.hint=s}}async function YO(e,t,s){const n=await fetch(`/api/sessions/${encodeURIComponent(e)}/speech-summary`,{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(s===void 0?{key:t}:{key:t,maxChars:s})}),i=await n.json().catch(()=>({}));if(!n.ok){const a=i.code==="disabled"?"到 设置 → 语音总结 打开开关":i.code==="not_configured"?"先到 设置 → 语音 配置 DashScope 端点与 API Key(ASR / TTS 用的就是它)":i.code==="timeout"?"模型超时了,可以重试;或把超时时间调大":void 0;throw new VO(i.error||`HTTP ${n.status}`,a)}const r={text:String(i.text??""),via:i.via==="verbatim"?"verbatim":"model",chars:Number(i.chars??String(i.text??"").length),ms:Number(i.ms??0),model:i.model,route:i.route==="session"?"session":i.route==="voice"?"voice":void 0,provider:i.provider,routeNote:i.routeNote,truncated:i.truncated===!0,maxChars:i.maxChars===void 0?s:Number(i.maxChars)};return KO(t,pC(t,s),r),r}const GO=3e4;function JO(e,t=Date.now()){if(!e||!e.loaded||t-e.lastAt>GO)return null;let s=0;for(let i=e.msgs.length-1;i>=0;i-=1)if(e.msgs[i].kind==="user"){s=i+1;break}const n=[];for(let i=s;i<e.msgs.length;i+=1){const r=e.msgs[i],a=String(r.text??"");r.kind!=="agent"||!a.trim()||e.busy&&i===e.msgs.length-1||n.push({key:r.key,text:Bh(a)})}return n}function XO(){const e=g.useSyncExternalStore(ee.subscribe,ee.getSnapshot),[t,s]=g.useState(!1),[n,i]=g.useState(()=>{try{const y=localStorage.getItem("agentus.rail-mode");return y==="compact"||y==="hidden"?y:"expanded"}catch{return"expanded"}});g.useEffect(()=>{try{localStorage.setItem("agentus.rail-mode",n)}catch{}},[n]);const r=g.useCallback(()=>{if(window.matchMedia("(max-width: 720px)").matches){s(!0);return}i(y=>y==="expanded"?"compact":y==="compact"?"hidden":"expanded")},[]),[a,l]=g.useState(!1),[c,u]=g.useState({}),[h,d]=g.useState(""),[p,f]=g.useState(!1);g.useEffect(()=>{const y=()=>{f(!0),s(!1)};return window.addEventListener("agentus:open-settings",y),()=>window.removeEventListener("agentus:open-settings",y)},[]);const m=ig({storage:"agentus.rail-width",fallback:268,min:200,max:()=>Math.min(460,window.innerWidth-$b-200),rightEdge:!0,label:"resize the session rail"}),b=ig({storage:"agentus.panel-width",fallback:760,min:380,max:()=>Math.max(380,window.innerWidth-m.width-$b),label:"resize the workspace panel"});if(g.useEffect(()=>{ee.checkAuth()},[]),g.useEffect(()=>{s(!1)},[e.activeId]),g.useEffect(()=>{e.blocked&&s(!1)},[e.blocked]),Ta(t,()=>s(!1)),g.useEffect(()=>{e.auth==="in"&&($D(),H5(),fR())},[e.auth]),e.auth!=="in")return o.jsx(eB,{});const _=e.activeId?ee.byId.get(e.activeId):void 0,v=_?.perms[0]??null;return o.jsxs("div",{className:"app",children:[t&&o.jsx("div",{className:"scrim",onClick:()=>s(!1)}),o.jsx(rB,{open:t,mode:n,onNew:()=>l({}),onNewIn:y=>l({cwd:y}),onSettings:()=>{f(!0),s(!1)},settingsOpen:p,railWidth:m.width,railHandle:m.handle}),o.jsx(oB,{onMenu:r,settingsOpen:p,onCloseSettings:()=>f(!1),onPermClick:()=>{v&&d(v.requestId)},panelWidth:b.width,panelHandle:b.handle}),a&&o.jsx(HB,{cwd:a.cwd,onClose:()=>l(!1)}),e.blocked&&o.jsx(QO,{slot:e.blocked}),v&&_&&(h===v.requestId||!c[v.requestId])?o.jsx(AB,{req:v,sessionTitle:_.info.title,waiting:_.perms.length,onSkip:()=>{u(y=>({...y,[v.requestId]:!0})),d("")}}):null,o.jsx(ZO,{})]})}function ZO(){const[e,t]=g.useState(!1);return g.useEffect(()=>{const s=document.querySelector('script[src*="/assets/index-"]')?.src.match(/index-([A-Za-z0-9_-]+)\.js/)?.[1]??null;if(!s)return;let n=!0;const i=async()=>{try{const c=await(await fetch("/api/version",{cache:"no-store"})).json();n&&c.asset&&c.asset!==s&&t(!0)}catch{}};i();const r=window.setInterval(()=>void i(),6e4),a=()=>{document.visibilityState==="visible"&&i()};return document.addEventListener("visibilitychange",a),()=>{n=!1,window.clearInterval(r),document.removeEventListener("visibilitychange",a)}},[]),e?o.jsx("button",{type:"button",className:"stale-banner",title:"服务端已经换成新的一组前端资源,这个页面还跑着旧的",onClick:()=>window.location.reload(),children:"已有新版本 · 点这里刷新(这个页面跑的还是旧代码)"}):null}function QO({slot:e}){Ta(!0,()=>ee.dismissBlocked());const t=e.code==="home_mismatch";return o.jsx("div",{className:"modal-bg",onClick:()=>ee.dismissBlocked(),children:o.jsxs("div",{className:"modal narrow",onClick:s=>s.stopPropagation(),children:[o.jsx("h3",{children:"这个会话不能继续使用"}),o.jsx("div",{className:"hint",children:t?"它是在另一个 agent home 里创建的,而这行后端现在指向另一个 home —— agent 那边没有这份会话,发消息不会有任何回复。":"agent 那边已经找不到这份会话了(它所在的 home 里没有这个会话),发消息不会有任何回复。"}),o.jsxs("div",{className:"blocked-homes",children:[o.jsxs("div",{children:[o.jsx("span",{children:"会话所属 home"}),o.jsx("code",{children:e.sessionHome??"(早期会话,未记录)"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"后端当前 home"}),o.jsx("code",{children:e.rowHome??"(该后端没有 home)"})]})]}),o.jsxs("div",{className:"hint",children:["「",e.title,"」的历史消息在本地库里,删除会连同记录一起清掉且无法撤销;想留着就先取消,再从会话菜单里导出。"]}),o.jsxs("div",{className:"row",children:[o.jsx("button",{className:"cancel",onClick:()=>ee.dismissBlocked(),children:"取消"}),o.jsx("button",{className:"go danger",onClick:()=>ee.deleteBlocked(),children:"删除会话"})]})]})})}function eB(){const{auth:e,authError:t,authBusy:s,authInfo:n}=g.useSyncExternalStore(ee.subscribe,ee.getSnapshot),[i,r]=g.useState("admin"),[a,l]=g.useState(""),c=e==="unknown",u=h=>{h.preventDefault(),ee.login(i.trim(),a).then(d=>{d&&l("")})};return o.jsx("div",{className:"auth-wrap",children:o.jsxs("form",{className:"auth-card",onSubmit:u,children:[o.jsxs("div",{className:"auth-logo",children:[o.jsx(S_,{size:30})," Agentus"]}),o.jsx("div",{className:"auth-sub",children:"keep your agents on the track"}),c?o.jsx("div",{className:"auth-note",children:"正在检查登录状态…"}):o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"auth-field",children:[o.jsx("span",{children:"用户名"}),o.jsx("input",{value:i,onChange:h=>r(h.target.value),autoComplete:"username",autoCapitalize:"none",spellCheck:!1})]}),o.jsxs("label",{className:"auth-field",children:[o.jsx("span",{children:"密码"}),o.jsx("input",{type:"password",value:a,onChange:h=>l(h.target.value),autoComplete:"current-password",autoFocus:!0})]}),t?o.jsx("div",{className:"auth-err",role:"alert",children:t}):null,o.jsx("button",{className:"auth-btn",type:"submit",disabled:s,children:s?"登录中…":"登录"}),n?.usingDefaultPassword?o.jsxs("div",{className:"auth-warn",children:["⚠ 当前是默认口令 ",o.jsx("code",{children:"admin / 123456"}),"。够挡住误闯,挡不住同网段的人 — 设置 ",o.jsx("code",{children:"AGENTUS_PASSWORD"})," 后重启即可更换。"]}):null,o.jsxs("div",{className:"auth-foot",children:["会话保存在 HttpOnly Cookie 中(7 天)。脚本可用 ",o.jsx("code",{children:"Authorization: Bearer"})," + 数据目录里的 ",o.jsx("code",{children:"auth.token"}),"。"]})]})]})})}function Vh({text:e,what:t="消息"}){const[s,n]=g.useState(""),i=g.useRef(null);g.useEffect(()=>()=>{i.current&&window.clearTimeout(i.current)},[]);const r=s==="ok"?"已复制":s==="no"?"复制失败(浏览器拒绝)":`复制${t}`;return o.jsx("button",{type:"button",className:`bubble-btn copy ${s}`,title:r,"aria-label":r,"data-copy-state":s,onClick:async a=>{a.stopPropagation();const l=await fd(e);n(l?"ok":"no"),i.current&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>n(""),1500)},children:s==="ok"?o.jsx(lN,{size:13}):o.jsx(gS,{size:13})})}function tB({sid:e,busy:t}){const[s,n]=g.useState("idle"),[i,r]=g.useState("");return o.jsx("button",{type:"button",className:`bubble-btn fork ${s}`,disabled:t||s==="working",title:i||(s==="failed"?"fork 失败":"从这里 fork —— agent 把这段上下文复制到一个新会话"),"aria-label":s==="failed"?"fork 失败":"从这里 fork",onClick:async a=>{a.stopPropagation(),n("working"),r("");try{await ee.fork(e),n("idle")}catch(l){r(String(l?.message??l)),n("failed")}},children:o.jsx(CS,{size:13})})}function Wl(e){return e.lastAt??e.createdAt}function Yb(e){const t=new Map;for(const n of e){const i=n.s.workspace||n.s.cwd,r=i.split("/").filter(Boolean).pop()??i,a=t.get(i)??{path:i,label:r,items:[]};a.items.push(n),t.set(i,a)}const s=n=>n.items.reduce((i,r)=>Math.max(i,Wl(r.s)),0);return[...t.values()].map(n=>({...n,items:[...n.items].sort((i,r)=>Wl(r.s)-Wl(i.s)||r.s.createdAt-i.s.createdAt)})).sort((n,i)=>s(i)-s(n)||n.label.localeCompare(i.label))}const sB={starting:"启动中",ready:"待命",running:"运行中",error:"出错",closed:"已关闭",reaped:"已回收(空闲)"};function mC({backend:e,cold:t,status:s,wake:n}){const i=vd(e),[r,a]=g.useState(!1),l=i.icon&&!r,c=!t&&(s==="running"||n===!0);return o.jsxs("span",{className:`be-avatar be-${e} ${t?"cold":""} ${c?"live":""}`,"data-backend":e,"data-letter":i.letter,title:`${i.label} · ${t?"无进程":n&&s!=="running"?"等后台任务唤醒":sB[s]??s}`,"aria-hidden":"true",children:[l?o.jsx("img",{src:i.icon,alt:"",draggable:!1,onError:()=>a(!0)}):i.letter,t?null:o.jsx("span",{className:`be-dot proc ${c?"running":""}`})]})}function nB({backend:e}){const t=vd(e),[s,n]=g.useState(!1);return!t.icon||s?null:o.jsx("span",{className:"agent-mark","data-backend":e,"aria-hidden":"true",children:o.jsx("img",{src:t.icon,alt:"",draggable:!1,onError:()=>n(!0)})})}function iB({x:e,y:t,trigger:s,info:n,cold:i,archived:r,unread:a,canFork:l,onDismiss:c,onRename:u,onRetitle:h,retitling:d,onFork:p,onWorkspace:f,onExport:m,onRestart:b,onResume:_,onArchive:v,onUnarchive:y,onUnarchiveResume:w,onToggleUnread:x,onDelete:S}){const E=g.useRef(null),R=g.useRef(s);R.current=s,lo(!0,[E,R],c);const[N,I]=g.useState(null);g.useEffect(()=>{const B=E.current;if(!B)return;const C=B.getBoundingClientRect();I({left:Math.max(6,Math.min(e,window.innerWidth-C.width-6)),top:Math.max(6,Math.min(t,window.innerHeight-C.height-6))})},[e,t]);const F=(B,C,A,M=!1)=>o.jsxs("button",{type:"button",role:"menuitem",className:`sess-menu-item ${M?"danger":""}`,onClick:H=>{H.stopPropagation(),A()},children:[C,o.jsx("span",{children:B})]});return o.jsxs("div",{ref:E,className:"sess-menu",role:"menu","aria-label":`会话设置:${n.title}`,style:N?{left:N.left,top:N.top}:{left:e,top:t,visibility:"hidden"},onClick:B=>B.stopPropagation(),children:[o.jsxs("div",{className:"sess-menu-head",children:[o.jsx(mC,{backend:n.backend,cold:i,status:n.status}),o.jsx("span",{className:"sess-menu-title",title:n.workspace||n.cwd,children:n.title})]}),F("重命名",o.jsx(mS,{size:14}),u),F(a?"设为已读":"设为未读",a?o.jsx(ES,{size:14}):o.jsx(fN,{size:14}),x),F(d?"正在重新生成…":"重新生成会话名",d?o.jsx(ba,{size:14,className:"spin"}):o.jsx(ba,{size:14}),h),l?F(i?"fork 会话(先恢复)":"fork 会话",o.jsx(CS,{size:14}),p):null,F("工作目录…",o.jsx(co,{size:14}),f),F("导出会话(Markdown)",o.jsx(_S,{size:14}),m),F("复制会话 ID",o.jsx(gS,{size:14}),()=>{fd(n.id)}),r&&i?F("取消归档并恢复",o.jsx(rf,{size:14}),w):i?F("恢复会话",o.jsx(rf,{size:14}),_):F("重启 agent 进程",o.jsx(xS,{size:14}),b),r?i?null:F("取消归档",o.jsx(rf,{size:14}),y):F("归档会话",o.jsx(aN,{size:14}),v),i?F("删除会话(连记录)",o.jsx(En,{size:14}),S,!0):null]})}function rB({open:e,mode:t,onNew:s,onNewIn:n,onSettings:i,settingsOpen:r,railWidth:a,railHandle:l}){const{sessions:c,cold:u,archived:h,activeId:d,conn:p,net:f,netError:m,authInfo:b}=g.useSyncExternalStore(ee.subscribe,ee.getSnapshot),_=B_(),v=g.useRef(Date.now()),[,y]=g.useState(0);g.useEffect(()=>{const Q=window.setInterval(()=>y(ke=>ke+1),6e4);return()=>window.clearInterval(Q)},[]),g.useEffect(()=>{const Q=()=>{v.current=Date.now()},ke=["pointerdown","keydown","mousemove","wheel","touchstart"];for(const Ne of ke)window.addEventListener(Ne,Q,{passive:!0});return()=>{for(const Ne of ke)window.removeEventListener(Ne,Q)}},[]);const w=()=>tI({visible:document.visibilityState==="visible",lastInputAt:v.current,now:Date.now()}),x=()=>Eh(),S=(Q,ke,Ne=!1,$e=!1)=>{fetch("/api/notify/presence",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},keepalive:Ne,body:JSON.stringify({sessionId:Q,visible:ke,call:$e})}).catch(()=>{})};g.useEffect(()=>{x()?S(d??null,!0,!1,!0):w()?S(d??null,!0):S(null,!1)},[d]);const E=g.useRef(d??null);E.current=d??null,g.useEffect(()=>{const Q=()=>{x()?S(E.current,!0,!1,!0):w()?S(E.current,!0):S(null,!1)},ke=window.setInterval(Q,3e4);return document.addEventListener("visibilitychange",Q),()=>{window.clearInterval(ke),document.removeEventListener("visibilitychange",Q),S(null,!1,!0)}},[]),g.useEffect(()=>{ER(),kR(Ne=>ee.setActive(Ne));const Q=()=>ca(),ke=["pointerdown","keydown","touchstart"];for(const Ne of ke)window.addEventListener(Ne,Q,{passive:!0});return()=>{for(const Ne of ke)window.removeEventListener(Ne,Q)}},[]);const[R,N]=g.useState(""),I="agentus.railClosed",F="agentus.railMore",B=Q=>{try{const ke=JSON.parse(localStorage.getItem(Q)??"{}");return ke&&typeof ke=="object"?ke:{}}catch{return{}}},[C,A]=g.useState(()=>B(I)),[M,H]=g.useState(()=>B(F));g.useEffect(()=>{try{localStorage.setItem(I,JSON.stringify(C))}catch{}},[C]),g.useEffect(()=>{try{localStorage.setItem(F,JSON.stringify(M))}catch{}},[M]);const D="agentus.railSections",[z,T]=g.useState(()=>{try{return JSON.parse(localStorage.getItem(D)??"{}")}catch{return{}}});g.useEffect(()=>{try{localStorage.setItem(D,JSON.stringify(z))}catch{}},[z]);const[O,K]=g.useState(""),[U,re]=g.useState(""),J=g.useRef(new Map),[Y,_e]=g.useState(null),[xe,fe]=g.useState(""),[et,Oe]=g.useState(""),[tt,Pe]=g.useState(""),[Le,Ee]=g.useState(""),Ae=g.useRef(null),Ze=g.useRef(!1),me=()=>{Ae.current&&(window.clearTimeout(Ae.current),Ae.current=null)};g.useEffect(()=>me,[]);const Ye=(Q,ke,Ne)=>{Ze.current=!1,me(),Ae.current=window.setTimeout(()=>{Ze.current=!0,de(Q,ke,Ne,J.current.get(Q)??null)},500)},de=(Q,ke,Ne,$e)=>{_e({id:Q,x:ke,y:Ne,trigger:$e})},lt=(Q,ke,Ne)=>{const $e=J.current.get(Q),gt=Ne??$e??null,St=gt?.getBoundingClientRect(),Jt=Number.isFinite(ke.clientX)&&Number.isFinite(ke.clientY)&&(ke.clientX!==0||ke.clientY!==0),dn=Jt?Number(ke.clientX):St?St.right-6:12,ye=Jt?Number(ke.clientY):St?St.bottom+4:12;de(Q,dn,ye,gt)},ae=Q=>{_e(null),Oe(Q.title),fe(Q.id)},be=async Q=>{const ke=et.trim();fe("");const Ne=c.find($e=>$e.id===Q)??h.find($e=>$e.id===Q);if(!(!Ne||ke===Ne.title)){re("");try{await ee.rename(Q,ke.length?ke:null)}catch($e){re(`改名失败:${String($e?.message??$e)}`)}}},Be=async Q=>{re(""),Ee(Q.id);try{const{via:ke}=await ee.regenerateTitle(Q.id);_e(null),ke==="derived"&&re("已按最新一条消息生成会话名(该后端不支持摘要式重新生成)")}catch(ke){re(`生成会话名失败:${String(ke?.message??ke)}`)}finally{Ee("")}},W=Y?c.find(Q=>Q.id===Y.id)??u.find(Q=>Q.id===Y.id)??h.find(Q=>Q.id===Y.id)??null:null,Se=!!W?.cold,He=!!W?.archivedAt,q=tt?c.find(Q=>Q.id===tt)??u.find(Q=>Q.id===tt)??h.find(Q=>Q.id===tt)??null:null,Z=R.trim().toLowerCase(),ge=Q=>!Z||`${Q.title} ${Q.backend} ${Q.workspace||Q.cwd}`.toLowerCase().includes(Z),P=g.useMemo(()=>{const Q=AO(c,u).filter(({s:ke})=>ge(ke));return Yb(Q)},[c,u,Z]),le=g.useMemo(()=>Yb(h.map(Q=>({s:Q,cold:!!Q.cold})).filter(({s:Q})=>ge(Q))),[h,Z]),je=!!Z||!z.team,Ie=!!Z||!z.workspaces,Ge=!!(Z&&le.length||!z.archived),ot=g.useMemo(()=>new Set([...P,...le].map(Q=>Q.path)),[P,le]);g.useEffect(()=>{if(!ot.size)return;const Q=ke=>{const Ne=Object.entries(ke).filter(([$e])=>ot.has($e.replace(/^(ws|arch):/,"")));return Ne.length===Object.keys(ke).length?ke:Object.fromEntries(Ne)};A(Q),H(Q)},[ot]);const dt=(Q,ke)=>Q.map(Ne=>{const $e=ke+Ne.path,gt=!!Z||!C[$e],St=Ne.items.filter(ye=>!ye.cold).length,{shown:Jt,hidden:dn}=MO(Ne.items,{searching:!!Z,isActive:ye=>ye.s.id===d,mustShow:ye=>!!ee.byId.get(ye.s.id)?.perms.length,expanded:!!M[$e]});return o.jsxs("div",{className:"rail-group",children:[o.jsxs("div",{className:"rail-group-row",children:[o.jsxs("button",{type:"button",className:`rail-group-head ${gt?"open":""}`,title:Ne.path,"aria-expanded":gt,"data-workspace":Ne.path,onClick:()=>A(ye=>({...ye,[$e]:!ye[$e]})),children:[gt?o.jsx(cN,{size:13,className:"rail-group-folder"}):o.jsx(co,{size:13,className:"rail-group-folder"}),o.jsx("span",{className:"rail-group-name",children:Ne.label}),o.jsx("span",{className:"rail-group-count",children:Ne.label&&St?`${St}/${Ne.items.length}`:Ne.items.length})]}),o.jsx("button",{type:"button",className:"item-btn group-add",title:`在 ${Ne.path} 新建会话`,"aria-label":`在 ${Ne.path} 新建会话`,onClick:ye=>{ye.stopPropagation(),ye.preventDefault(),A(Dt=>({...Dt,[$e]:!1})),n(Ne.path)},children:o.jsx(kh,{size:12})})]}),gt?o.jsx("div",{className:"rail-group-body",children:Jt.map(({s:ye,cold:Dt})=>o.jsxs("div",{ref:Me=>{Me?J.current.set(ye.id,Me):J.current.delete(ye.id)},className:`session-item ${Dt?"cold":""} ${ye.id===d?"active":""} ${xe===ye.id?"editing":""}`,"data-session":ye.id,title:(ye.archivedAt?`${ye.title} — 已归档${Dt?"(进程已停)":""},点一下打开;菜单里可取消归档并恢复`:`${ye.title}${Dt?" — 进程已停,点一下恢复":""}`)+(ye.titleBy?`
119
+ 名字由会话 ${ye.titleBy} 的 agent 改的`:""),onContextMenu:Me=>{Me.preventDefault(),lt(ye.id,Me)},onTouchStart:Me=>{const kt=Me.touches[0];Ye(ye.id,kt?.clientX??0,kt?.clientY??0)},onTouchEnd:me,onTouchMove:me,onTouchCancel:me,onClick:Me=>{if(Ze.current){Ze.current=!1,Me.preventDefault();return}xe!==ye.id&&(Dt&&!ye.archivedAt?ee.resume(ye.id):ee.setActive(ye.id))},children:[o.jsx(mC,{backend:ye.backend,cold:Dt,status:ye.status,wake:(ee.byId.get(ye.id)?.background??[]).some(Me=>Me.status==="running")}),xe===ye.id?o.jsx("input",{className:"title-input",value:et,autoFocus:!0,"aria-label":`重命名 ${ye.title}`,onChange:Me=>Oe(Me.target.value),onClick:Me=>Me.stopPropagation(),onPointerDown:Me=>Me.stopPropagation(),onBlur:()=>void be(ye.id),..._.handlers,onKeyDown:Me=>{_.isComposing(Me)||(Me.key==="Enter"?(Me.preventDefault(),be(ye.id)):Me.key==="Escape"&&(Me.preventDefault(),Me.stopPropagation(),fe("")))}}):o.jsx("span",{className:"title",onDoubleClick:Me=>{Me.stopPropagation(),ae(ye)},children:ye.title}),ee.byId.get(ye.id)?.perms.length?o.jsxs("span",{className:"badge perm",title:"有审批在等你",children:["⚿ ",ee.byId.get(ye.id).perms.length]}):null,(()=>{const Me=ee.byId.get(ye.id)?.background?.filter(kt=>kt.status==="running").length??0;return Me?o.jsxs("span",{className:"badge bg",title:`${Me} 个后台任务还在跑(完成后会唤醒会话)`,children:[o.jsx(hN,{size:9}),Me]}):null})(),o.jsx("span",{className:"rail-at",title:`最后一次消息:${uo(Wl(ye))}`,children:v3(Wl(ye))}),ee.isUnread(ye.id)&&!ee.byId.get(ye.id)?.busy&&!ee.byId.get(ye.id)?.perms.length&&!(ee.byId.get(ye.id)?.background??[]).some(Me=>Me.status==="running")?o.jsx("span",{className:"unread-dot","data-unread":!0,title:"这轮已经结束了,你还没看","aria-label":"未读"}):null,o.jsx("button",{type:"button",className:"item-btn row-menu",title:"会话设置:重命名 / fork / 工作目录 / 导出 / 归档","aria-label":`${ye.title} 的会话设置`,"aria-haspopup":"menu","aria-expanded":Y?.id===ye.id,onClick:Me=>{Me.stopPropagation(),Me.preventDefault(),lt(ye.id,Me,Me.currentTarget)},children:o.jsx(oN,{size:14})})]},ye.id))}):null,gt&&!Z&&Ne.items.length>Xu&&o.jsxs("button",{type:"button",className:`rail-more ${M[$e]?"open":""}`,onClick:()=>H(ye=>({...ye,[$e]:!ye[$e]})),"aria-expanded":!!M[$e],title:M[$e]?"只显示最近几个":`展开这个工作空间里其余的 ${Ne.items.length-Xu} 个会话`,children:[o.jsx(an,{size:10,className:`rail-more-chev ${M[$e]?"open":""}`}),M[$e]?"收起":`展开其余 ${Ne.items.length-Xu} 条`]})]},Ne.path)}),at=async Q=>{K(Q),re("");try{await ee.fork(Q)}catch(ke){re(String(ke?.message??ke))}finally{K("")}};return o.jsxs("aside",{className:`sidebar ${e?"open":""} ${t}`,style:{"--rail-w":`${t==="compact"?60:a}px`},children:[l,o.jsxs("header",{children:[o.jsxs("span",{className:"logo",children:[o.jsx(S_,{size:24})," Agentus"]}),o.jsx("span",{className:"tagline",children:"keep your agents on the track"}),o.jsx("button",{className:`icon-btn rail-gear ${r?"on":""}`,title:"设置 — 后端、主题、语音识别、语音合成、热词","aria-label":"settings","aria-pressed":r,onClick:i,children:o.jsx(Tc,{size:15})})]}),f==="degraded"||p==="offline"?o.jsxs("div",{className:"net-banner",title:m,children:[o.jsx("span",{children:p==="offline"?"⚠ 与服务的连接已断开 — 正在重连(指令会排队)":`⚠ 服务不可达 — ${m||"请求超时"}`}),o.jsx("button",{onClick:()=>location.reload(),children:"reload"})]}):null,o.jsxs("button",{className:"new-btn",onClick:s,title:"new session (pick a backend + working directory)",children:[o.jsx(kh,{size:14})," ",o.jsx("span",{className:"new-label",children:"new session"})]}),o.jsxs("div",{className:"rail-search-wrap",children:[o.jsx(dN,{size:13}),o.jsx("input",{className:"rail-search",value:R,onChange:Q=>N(Q.target.value),placeholder:"search sessions…","aria-label":"search sessions"})]}),U?o.jsxs("div",{className:"rail-error",title:U,children:[U,o.jsx("button",{className:"draft-x","aria-label":"dismiss",onClick:()=>re(""),children:o.jsx(En,{size:11})})]}):null,o.jsxs("div",{className:"session-list",children:[o.jsxs("button",{type:"button",className:`rail-section ${je?"open":""}`,"data-section":"team","aria-expanded":je,"aria-controls":"rail-team",title:je?"折叠团队":"展开团队",onClick:()=>T(Q=>({...Q,team:!Q.team})),children:[o.jsx(an,{size:11,className:`rail-section-chev ${je?"open":""}`}),o.jsx("span",{children:"团队"})]}),je?o.jsxs("div",{className:"rail-placeholder","data-placeholder":"team",id:"rail-team","aria-disabled":"true",title:"团队 — 还没有实现,先占个位(现在的驾驶舱一条会话就是一个 agent,没有团队/成员的概念)",children:[o.jsx(uN,{size:13}),o.jsx("span",{className:"rail-placeholder-name",children:"还没做,先占个位"})]}):null,o.jsxs("button",{type:"button",className:`rail-section ${Ie?"open":""}`,"data-section":"workspaces","aria-expanded":Ie,"aria-controls":"rail-workspaces",title:Ie?"折叠工作空间":"展开工作空间",onClick:()=>T(Q=>({...Q,workspaces:!Q.workspaces})),children:[o.jsx(an,{size:11,className:`rail-section-chev ${Ie?"open":""}`}),o.jsx("span",{children:"工作空间"})]}),o.jsxs("div",{id:"rail-workspaces",children:[Ie?dt(P,"ws:"):null,Ie&&!P.length&&o.jsx("div",{className:"rail-empty",children:Z?"no session matches that search.":"No sessions yet — create one."})]}),o.jsxs("button",{type:"button",className:`rail-section ${Ge?"open":""}`,"data-section":"archived","aria-expanded":Ge,"aria-controls":"rail-archived",title:Ge?"折叠已归档":"展开已归档",onClick:()=>T(Q=>({...Q,archived:!Q.archived})),children:[o.jsx(an,{size:11,className:`rail-section-chev ${Ge?"open":""}`}),o.jsx("span",{children:"已归档"}),h.length?o.jsx("span",{className:"rail-section-count",children:h.length}):null]}),o.jsxs("div",{id:"rail-archived","data-archived":"1",children:[Ge?dt(le,"arch:"):null,Ge&&!le.length&&o.jsx("div",{className:"rail-empty",children:Z?"no archived session matches that search.":"Nothing archived yet."})]})]}),Y&&W?cc.createPortal(o.jsx(iB,{x:Y.x,y:Y.y,trigger:Y.trigger,info:W,cold:Se,archived:He,unread:ee.isUnread(W.id),onToggleUnread:()=>{_e(null),ee.toggleUnread(W.id)},canFork:!!W.acpSessionId||Se,onDismiss:()=>_e(null),onRename:()=>ae(W),retitling:Le===W.id,onRetitle:()=>{Be(W)},onFork:()=>{_e(null),at(W.id)},onWorkspace:()=>{_e(null),Pe(W.id)},onExport:()=>{_e(null);const Q=document.createElement("a");Q.href=`/api/sessions/${W.id}/export?format=md`,Q.download="",document.body.appendChild(Q),Q.click(),Q.remove()},onResume:()=>{_e(null),ee.resume(W.id)},onArchive:()=>{_e(null),confirm(`归档“${W.title}”?
120
+
121
+ 收进「已归档」,随时可以取消归档并恢复。${Se?"":"运行中的 agent 进程会一起停掉(对话记录保留)。"}`)&&ee.setArchived(W.id,!0)},onUnarchive:()=>{_e(null),ee.setArchived(W.id,!1)},onUnarchiveResume:()=>{_e(null),ee.unarchiveAndResume(W.id)},onRestart:()=>{_e(null),confirm(`重启“${W.title}”的 agent 进程?
122
+
123
+ 旧进程退出、新进程接管同一个会话:对话记录、模型和思考深度都保留,只有进程换新(改完代码或改了后端配置后,用它让槽位吃到新东西)。正在跑的这一轮会被中断。`)&&ee.restart(W.id)},onDelete:()=>{_e(null),confirm(`删除“${W.title}”?
124
+
125
+ 记录会从磁盘上移除,无法撤销。`)&&ee.purgeCold(W.id)}}),document.body):null,tt?cc.createPortal(o.jsx("div",{className:"modal-bg",onClick:()=>Pe(""),children:o.jsxs("div",{className:"modal narrow",onClick:Q=>Q.stopPropagation(),children:[o.jsx("h3",{children:"工作目录"}),o.jsx("div",{className:"hint",children:"文件面板与终端以它为根。运行中的 agent 仍留在启动时的目录 —— 新目录对下一次恢复生效。"}),o.jsx(k_,{value:q?.workspace??q?.cwd??"",onChange:Q=>{const ke=tt;Pe(""),ee.setWorkspace(ke,Q)}}),o.jsx("div",{className:"row",children:o.jsx("button",{className:"cancel",onClick:()=>Pe(""),children:"取消"})})]})}),document.body):null,o.jsxs("footer",{children:[o.jsx("span",{className:`conn ${p}`,children:p==="online"?"● online":p}),b?o.jsx("span",{className:"who",title:`signed in as ${b.username??"?"}`,children:b.username}):null,o.jsx("button",{className:"logout-btn",title:`signed in as ${b?.username??"?"} — sign out`,"aria-label":"sign out",onClick:()=>void ee.logout(),children:o.jsx(xS,{size:14})})]})]})}function oB({onMenu:e,settingsOpen:t,onCloseSettings:s,onPermClick:n,panelWidth:i,panelHandle:r}){const{active:a}=g.useSyncExternalStore(ee.subscribe,ee.getSnapshot),[l,c]=g.useState(!1),[u,h]=g.useState(null);g.useEffect(()=>LR(y=>{c(!0),h({...y})}),[]);const[d,p]=g.useState(!1),[f,m]=g.useState(!1),[b,_]=g.useState(!1);g.useEffect(()=>{const y=f&&Eh(),w=document.visibilityState==="visible";fetch("/api/notify/presence",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({sessionId:a?.info.id??null,visible:w||y,call:y})}).catch(()=>{})},[f,a?.info.id]),g.useEffect(()=>{Ch()},[]);const v=MB(a?.info.id);return gR(JO(a),!!(a&&a.loaded),v.mode),_R(aB(a),!!a,v.mode),t?o.jsx(g3,{onClose:s,sessionId:a?.info.id}):a?o.jsxs("div",{className:"main",children:[o.jsx(uB,{v:a,onMenu:e,panelOpen:l,onTogglePanel:()=>c(y=>!y),onPickWorkspace:()=>p(!0),call:f,onCall:y=>{pe.stop(),_(y),m(!0)},onPerm:n,speak:v}),o.jsxs("div",{className:"main-body",children:[o.jsxs("div",{className:"chat-col",children:[o.jsx(pB,{v:a}),o.jsx(FB,{v:a,call:f,tus:b,onCloseCall:()=>{m(!1),_(!1)}})]}),l&&o.jsx(NO,{v:a,onClose:()=>c(!1),onPickWorkspace:()=>p(!0),focus:u,panelWidth:i,panelHandle:r})]}),d&&o.jsx(lB,{v:a,onClose:()=>p(!1)})]}):o.jsxs("div",{className:"main",children:[o.jsxs("div",{className:"chat-head",children:[o.jsx("button",{className:"icon-btn menu-btn",onClick:e,title:"sessions","aria-label":"sessions",children:o.jsx(pS,{})}),o.jsx("span",{className:"title",children:"Agentus"})]}),o.jsxs("div",{className:"empty",children:[o.jsx("div",{className:"big",children:o.jsx(S_,{size:72})}),o.jsxs("p",{children:["No session selected.",o.jsx("br",{}),"Create one and point it at a real ",o.jsx("code",{children:"hermes acp"})," / ",o.jsx("code",{children:"qodercli --acp"}),"."]})]})]})}function aB(e){const t=e?.speaks?.[e.speaks.length-1];return t?{key:`brief:${t.id}`,text:t.text}:null}function lB({v:e,onClose:t}){Ta(!0,t);const s=e.info.workspace||e.info.cwd,[n,i]=g.useState(s),[r,a]=g.useState(!1),[l,c]=g.useState(""),u=async()=>{a(!0),c("");try{await ee.setWorkspace(e.info.id,n.trim()),t()}catch(h){c(String(h?.message??h))}finally{a(!1)}};return o.jsx("div",{className:"modal-bg",onClick:t,children:o.jsxs("div",{className:"modal narrow",onClick:h=>h.stopPropagation(),children:[o.jsx("h3",{children:"workspace"}),o.jsx("div",{className:"hint",children:"the file panel and terminal work here. A running agent keeps the directory it was started in — the new one applies to this session from the next resume."}),o.jsx(k_,{value:n,onChange:i}),l&&o.jsx("div",{className:"err",children:l}),o.jsxs("div",{className:"row",children:[o.jsx("button",{className:"cancel",onClick:t,children:"cancel"}),o.jsx("button",{className:"go",disabled:r||!n.trim(),onClick:()=>void u(),children:r?"saving…":"use this folder"})]})]})})}const cB=480;function uB({v:e,onMenu:t,panelOpen:s,onTogglePanel:n,onPickWorkspace:i,call:r,onCall:a,onPerm:l,speak:c}){const u=e.info;(u.workspace||u.cwd).split("/").filter(Boolean).pop()??u.cwd;const[h,d]=g.useState(!1),p=g.useRef(null),f=g.useRef(null),m=g.useRef(!1),b=()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null),f.current=null,d(!1)},_=U=>{m.current=!1,f.current={x:U.clientX,y:U.clientY};try{U.currentTarget.setPointerCapture(U.pointerId)}catch{}d(!0),p.current=window.setTimeout(()=>{p.current=null,m.current=!0,d(!1),a(!0)},cB)},v=()=>{const U=p.current!==null;b(),U&&!m.current&&a(!1)},y=U=>{const re=f.current;re&&Math.hypot(U.clientX-re.x,U.clientY-re.y)>8&&b()};g.useEffect(()=>()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null)},[]);const x=g.useSyncExternalStore(WN,ai).tts.server||typeof window<"u"&&"speechSynthesis"in window,S=c.mode,E=c.intervalSec,[R,N]=g.useState(!1),I=g.useRef(null),F=dd();lo(R,[I],()=>N(!1));const B=(U,re=0)=>{N(!1),c.save(U,U==="brief"?re:0)},C=g.useRef({timer:null,fired:!1}),A=()=>{C.current.timer&&(window.clearTimeout(C.current.timer),C.current.timer=null)};g.useEffect(()=>A,[]);const M=()=>{C.current.fired=!1,A(),C.current.timer=window.setTimeout(()=>{C.current.fired=!0,N(!0)},500)},H=()=>{if(C.current.fired){C.current.fired=!1;return}if(F.speaking){uc();return}B(S==="off"?"reply":"off")},D=[{key:"off",mode:"off",interval:null,label:"关"},{key:"reply",mode:"reply",interval:null,label:"自动朗读(点一下就是这个 · 默认)"},{key:"brief",mode:"brief",interval:0,label:"工作播报(有进展就说一句)"},{key:"brief-30",mode:"brief",interval:30,label:"工作播报(每 30 秒也报一次)"},{key:"brief-60",mode:"brief",interval:60,label:"工作播报(每 1 分钟也报一次)"},{key:"brief-120",mode:"brief",interval:120,label:"工作播报(每 2 分钟也报一次)"},{key:"brief-300",mode:"brief",interval:300,label:"工作播报(每 5 分钟也报一次)"}],z=U=>U.mode===S&&(U.mode!=="brief"||U.interval===E),T=S==="brief"&&!D.some(U=>U.mode==="brief"&&U.interval===E),O=S==="off"?"关":S==="reply"?"自动朗读(念整条回复)":E>0?`工作播报 · 每 ${Xf(E)}`:"工作播报(念驾驶舱的一句话)",K=x?`朗读:${O} —— 点一下开/关,长按选档(右键同)`:"朗读:这台设备没有可用语音(浏览器无 speechSynthesis,服务端也没配)";return o.jsxs("div",{className:"chat-head",children:[o.jsx("button",{className:"icon-btn menu-btn",onClick:t,title:"sessions","aria-label":"sessions",children:o.jsx(pS,{})}),o.jsx("span",{className:"title",title:u.title,children:u.title}),o.jsx(hB,{busy:Zr(e),lastAt:e.lastAt}),e.perms.length>0?o.jsxs("button",{type:"button",className:"chip perm-chip",title:"这个会话有请求等你的答复 —— 点一下打开授权弹窗","aria-label":`有 ${e.perms.length} 个请求等你授权`,onClick:l,children:[o.jsx("span",{className:"perm-pulse"}),"⚿ ",e.perms.length]}):null,o.jsx("span",{className:"head-spacer"}),o.jsxs("span",{className:"head-actions",children:[o.jsxs("button",{className:`icon-btn call-entry ${r?"on":""}${h?" press-armed":""}`,title:"语音通话 —— 像打电话一样跟这个会话说话(长按 = Tus 模式:一张会动的脸 + 会话记录)","aria-label":"开始语音通话",onPointerDown:_,onPointerUp:v,onPointerCancel:b,onPointerLeave:b,onPointerMove:y,onContextMenu:U=>U.preventDefault(),onClick:U=>{U.detail===0&&a(!1)},children:[o.jsx(vN,{}),o.jsx("span",{className:"press-fill","aria-hidden":"true"})]}),o.jsxs("span",{className:"speak-wrap",ref:I,children:[o.jsxs("button",{className:`icon-btn auto-read ${S!=="off"?"on":""}`,title:K,"aria-label":"朗读:点一下开/关,长按选读什么","aria-pressed":S!=="off","aria-haspopup":"menu","aria-expanded":R,"data-speak-mode":S,disabled:!x,onClick:H,onPointerDown:M,onPointerUp:A,onPointerLeave:A,onPointerCancel:A,onContextMenu:U=>{U.preventDefault(),A(),N(!0)},onKeyDown:U=>{(U.key==="F10"&&U.shiftKey||U.key==="ContextMenu")&&(U.preventDefault(),N(!0))},children:[S==="off"?o.jsx(SS,{}):o.jsx(hd,{}),S==="brief"?o.jsx("span",{className:"speak-dot","aria-hidden":!0}):null]}),R?o.jsxs("div",{className:"speak-menu",role:"menu",children:[D.map(U=>o.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":z(U),className:`speak-menu-item ${z(U)?"on":""}`,"data-speak-option":U.key,onClick:()=>B(U.mode,U.interval??void 0),children:[o.jsx("span",{className:"speak-check",children:z(U)?"✓":""}),o.jsx("span",{className:"speak-name",children:U.label})]},U.key)),o.jsxs("button",{type:"button",role:"menuitem","aria-checked":T,className:`speak-menu-item ${T?"on":""}`,"data-speak-option":"custom",onClick:()=>{N(!1),window.dispatchEvent(new CustomEvent("agentus:open-settings",{detail:"voice"}))},children:[o.jsx("span",{className:"speak-check",children:T?"✓":""}),o.jsx("span",{className:"speak-name",children:T?`自定义节拍(现在 · 每 ${Xf(E)})`:"自定义节拍…"})]}),o.jsx("p",{className:"speak-hint",children:S==="brief"&&!c.observerEnabled?"⚠ 观察智能体没启用,这一档现在不会响 —— 它要起一个 agent 替你盯着。去 设置 → 观察智能体 打开。":S==="brief"?E>0?`有任务在跑时每 ${Xf(E)} 念一句;没任务在跑不念`:"回合结束、待审批时由一个观察智能体念一句":S==="reply"?"每条回复结束后念全文 —— 长回复会被截断":"不自动出声;点消息旁的喇叭可以按需念"}),c.source==="session"?o.jsx("p",{className:"speak-hint",children:"只对这个会话生效;其它会话仍按 设置 里的默认档位。"}):null]}):null]}),o.jsx("button",{className:"icon-btn",title:`workspace: ${u.workspace||u.cwd}
126
+ click to point this session at another directory`,"aria-label":"workspace",onClick:i,children:o.jsx(co,{})}),o.jsx("button",{className:`icon-btn ${s?"on":""}`,title:"workspace panel — files and terminal","aria-label":"workspace panel","aria-expanded":s,onClick:n,children:o.jsx(pN,{})})]})]})}const Kl={current:()=>{}},Gb=4,hB=g.memo(function({busy:t,lastAt:s}){const[,n]=g.useState(0);if(g.useEffect(()=>{if(!t)return;const a=window.setInterval(()=>n(l=>l+1),1e3);return()=>window.clearInterval(a)},[t]),!t)return null;const{quiet:i,said:r}=b3(s,Date.now());return o.jsx("span",{className:`turn-pulse ${i?"quiet":""}`,role:"status","aria-label":r,title:r})}),dB=g.memo(function({busy:t,since:s}){const[n,i]=g.useState(null),[r,a]=g.useState(()=>Date.now());if(g.useEffect(()=>{if(!t){i(null);return}i(s??Date.now()),a(Date.now());const c=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(c)},[t,s]),!t)return null;const l=n??s;return o.jsxs("div",{className:"stream-hint",role:"status","data-anchor":l??void 0,children:[o.jsx("span",{className:"stream-spin","aria-hidden":"true"}),o.jsx("span",{children:"处理中"}),l!=null?o.jsxs("span",{className:"elapsed",children:["(",Oh(r-l),")"]}):null]})});function fB({v:e}){const t=e.background??[],[s,n]=g.useState(!1);if(!t.length)return null;const i=t.filter(c=>c.status==="running"),r=t.filter(c=>c.status!=="running"),a=i.reduce((c,u)=>c+(u.kind==="delegation"?u.taskCount??1:0),0),l=i.length?`后台任务 ${i.length} 个运行中${a?`(含 ${a} 个子任务)`:""} · 完成后会唤醒会话`:`${r.length} 个后台任务已结束`;return o.jsxs("div",{className:`bg-row ${s?"open":""}`,"data-count":t.length,children:[o.jsxs("button",{type:"button",className:"bg-head","aria-expanded":s,onClick:()=>n(!s),children:[o.jsx("span",{className:"bg-dot","aria-hidden":"true","data-state":i.length?"running":"exited","data-wake":i.length?"1":void 0}),o.jsx("span",{className:"bg-text",children:l}),i.length&&!e.busy?o.jsx("span",{className:"bg-hint",children:"会话已空闲,后台仍在跑"}):null,o.jsx("span",{className:"bg-caret","aria-hidden":"true",children:s?"▾":"▸"})]}),s&&o.jsx("ul",{className:"bg-list",children:t.map(c=>o.jsxs("li",{className:"bg-item","data-state":c.status,"data-kind":c.kind??"process",children:[c.kind==="delegation"?o.jsx("span",{className:"bg-tag",children:"子任务"}):null,o.jsx("pre",{className:"bg-cmd-full",children:c.command||c.id}),o.jsxs("div",{className:"bg-item-foot",children:[o.jsx("span",{className:"bg-meta",children:c.kind==="delegation"?o.jsxs(o.Fragment,{children:[(c.taskCount??1)>1?`${c.taskCount} 个子代理 · `:"",c.status==="running"?`运行 ${Oh((c.uptimeSeconds??0)*1e3)}${c.phase==="stalling"?" · 停滞中":c.phase==="finalizing"?" · 收尾中":""}`:"已结束"]}):o.jsxs(o.Fragment,{children:[c.pid?`pid ${c.pid} · `:"",c.status==="running"?`运行 ${Oh((c.uptimeSeconds??0)*1e3)}`:`exit ${c.exitCode??"?"}`]})}),c.command?o.jsx(Vh,{text:c.command,what:c.kind==="delegation"?"这个目标":"这条命令"}):null]})]},c.id))})]})}function ju({n:e}){const t=new Date(e.at),s=`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`,n=e.items??[],[i,r]=g.useState(!1),a=g.useRef(null),[l,c]=g.useState(!1);return g.useLayoutEffect(()=>{if(!i){c(!1);return}const u=a.current;if(!u)return;const h=()=>c(u.scrollHeight-u.clientHeight>4);h();const d=new ResizeObserver(h);return d.observe(u),()=>d.disconnect()},[i,n.length]),o.jsxs("div",{className:"status-note","data-kind":e.kind||"lifecycle",role:"note",title:t.toLocaleString(),children:[o.jsx("span",{className:"status-note-time",children:s}),o.jsx("span",{className:"status-note-text",children:e.text}),n.length?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"status-note-toggle","aria-expanded":i,"aria-label":`${i?"收起":"展开"}这 ${n.length} 条记忆`,onClick:()=>r(u=>!u),children:i?"收起":`${n.length} 条`}),i?o.jsx("div",{className:"status-note-drawer-wrap",children:o.jsxs("div",{className:"status-note-drawer","data-scroll":l?"1":"0",children:[o.jsxs("div",{className:"status-note-drawer-head",children:[o.jsxs("span",{children:["共 ",n.length," 条"]}),l?o.jsx("span",{className:"status-note-drawer-hint",children:"滚轮查看"}):null]}),o.jsxs("ol",{className:"status-note-items",ref:a,children:[n.map((u,h)=>o.jsxs("li",{className:"status-note-item",children:[o.jsx("span",{className:"status-note-item-n",children:h+1}),o.jsxs("span",{className:"status-note-item-body",children:[o.jsx("span",{className:"status-note-item-text",children:u.text}),u.tags?.length?o.jsx("span",{className:"status-note-item-tags",children:u.tags.join(" · ")}):null]})]},h)),e.truncated?o.jsx("li",{className:"status-note-item more",children:"…还有更多,已截断"}):null]})]})}):null]}):null]})}function gC({msgs:e,sid:t,backend:s,busy:n,base:i,notes:r=[],speaking:a=!1}){const l=EB(e),c=a?l.map(d=>d.kind==="msg"&&d.m.kind==="thought"&&d.live?{...d,live:!1}:d):l,u=[];let h=0;for(;h<r.length&&r[h].afterKey===null;)u.push(o.jsx(ju,{n:r[h]},r[h].key)),h++;for(const d of c){d.kind==="work"?(u.push(o.jsx(NB,{items:d.items},d.key)),u.push(o.jsx(Zb,{msgs:d.items},`fc-${d.key}`))):d.m.kind==="note"?u.push(o.jsx(ju,{n:{key:d.m.key,kind:d.m.category,text:d.m.text,at:d.m.at??Date.now(),hits:d.m.hits,items:d.m.items,truncated:d.m.truncated}},d.m.key)):(u.push(o.jsx(wB,{m:d.m,sid:t,backend:s,busy:n,last:d.tail,live:d.live,base:i},d.m.key)),d.m.kind==="tool"&&u.push(o.jsx(Zb,{msgs:[d.m]},`fc-${d.m.key}`)));const p=new Set(d.kind==="msg"?[d.m.key]:d.items.map(f=>f.key));for(let f=r[h];f&&f.afterKey!==null&&p.has(f.afterKey);f=r[h])u.push(o.jsx(ju,{n:f},f.key)),h++}for(;h<r.length;)u.push(o.jsx(ju,{n:r[h]},r[h].key)),h++;return o.jsx(o.Fragment,{children:u})}function pB({v:e}){const t=g.useRef(null),s=g.useRef(!0),n=g.useRef(0),i=g.useRef(-1e9),r=g.useRef(0),a=g.useRef(0),l=g.useRef(0),[c,u]=g.useState(!0),[h,d]=g.useState(!1),p=64,f=()=>performance.now(),m=B=>B.scrollHeight-B.scrollTop-B.clientHeight<=p,b=1200,_=B=>{r.current=f()+150,a.current=B.scrollTop,l.current=B.scrollHeight},v=()=>{const B=t.current;B&&(B.scrollTop=B.scrollHeight,_(B))},y=()=>{s.current=!1,n.current=0,u(!1)};Kl.current=()=>{s.current=!0,n.current=f()+1200,u(!0),d(!1),v()},g.useEffect(()=>{const B=t.current;if(!B)return;const C=()=>{i.current=f()},A=()=>{const K=B.scrollTop,U=K-a.current;a.current=K;const re=B.scrollHeight,J=re<l.current-1;if(l.current=re,U<-2&&!J&&f()-i.current<b){y();return}if(f()<r.current)return;const Y=m(B);Y!==s.current&&(s.current=Y,u(Y)),Y&&d(!1)},M=K=>{C(),K.deltaY<0&&y()};let H=0;const D=K=>{C(),H=K.touches[0]?.clientY??0},z=K=>{C(),(K.touches[0]?.clientY??0)>H+4&&y()},T=K=>{C(),(K.key==="PageUp"||K.key==="ArrowUp"||K.key==="Home")&&y()},O=()=>C();return B.addEventListener("scroll",A,{passive:!0}),B.addEventListener("wheel",M,{passive:!0}),B.addEventListener("touchstart",D,{passive:!0}),B.addEventListener("touchmove",z,{passive:!0}),B.addEventListener("keydown",T),B.addEventListener("pointerdown",O,{passive:!0}),_(B),()=>{B.removeEventListener("scroll",A),B.removeEventListener("wheel",M),B.removeEventListener("touchstart",D),B.removeEventListener("touchmove",z),B.removeEventListener("keydown",T),B.removeEventListener("pointerdown",O)}},[]),g.useEffect(()=>{if(s.current||f()<n.current){v();return}e.msgs.length&&d(!0)},[e.rev,e.busy,e.perms.length]),g.useEffect(()=>{const B=t.current,C=B?.firstElementChild??null;if(!B||!C||typeof ResizeObserver>"u")return;const A=new ResizeObserver(()=>{!s.current&&f()>=n.current||requestAnimationFrame(()=>{(s.current||f()<n.current)&&v()})});return A.observe(C),()=>A.disconnect()},[e.info.id]);const[w,x]=g.useState(null);g.useEffect(()=>{x(null)},[e.info.id]);const S=async B=>{const C=t.current,A=C?.scrollHeight??0,M=C?.scrollTop??0;B||(s.current=!1,u(!1)),F(!0);const H=await ee.loadEarlier(e.info.id);H===0?x("这一页没有新内容(更早的记录都是屏幕上已有内容的碎片)"):H>0&&x(null),requestAnimationFrame(()=>{const D=t.current;D&&(D.scrollTop=D.scrollHeight-A+M,_(D))})},E=()=>{S(!1)},R=async B=>{const C=[...B.queue];try{const A=await ee.createSession(String(B.info.backend),B.info.cwd,"");ee.setActive(A);for(const M of C)ee.enqueuePrompt(A,M.text,M.attachments);ee.purgeCold(B.info.id)}catch{}},N=g.useRef(0),[I,F]=g.useState(!1);return g.useEffect(()=>{N.current=0,F(!1)},[e.info.id]),g.useEffect(()=>{const B=t.current;!B||!e.hasOlder||e.loadingOlder||N.current>=Gb||B.scrollHeight>B.clientHeight+80||(N.current+=1,S(!0))},[e.rev,e.hasOlder,e.loadingOlder,e.info.id]),g.useEffect(()=>{const B=t.current;if(!B)return;const C=()=>{!e.hasOlder||e.loadingOlder||N.current>=Gb||B.scrollTop>B.clientHeight*1.5||(N.current+=1,S(!0))};return B.addEventListener("scroll",C,{passive:!0}),()=>B.removeEventListener("scroll",C)},[e.info.id,e.hasOlder,e.loadingOlder]),o.jsxs("div",{className:"stream-wrap",children:[o.jsx("div",{className:"stream",ref:t,tabIndex:0,children:o.jsxs("div",{className:"stream-inner",children:[e.info.status==="starting"?o.jsxs("div",{className:"start-hold",role:"status",children:[o.jsx("span",{className:"stream-spin","aria-hidden":"true"}),o.jsx("span",{children:"正在启动 agent 进程…好了会自动把消息发出去"})]}):null,e.info.status==="error"&&e.info.lastError?o.jsxs("div",{className:"start-fail",role:"alert",children:[o.jsxs("div",{className:"start-fail-why",children:["会话启动失败:",e.info.lastError]}),o.jsxs("div",{className:"start-fail-act",children:[o.jsx("button",{className:"ghost-btn",onClick:()=>void R(e),children:"再试一次"}),o.jsx("button",{className:"ghost-btn",onClick:()=>ee.purgeCold(e.info.id),children:"删除这个会话"})]})]}):null,e.hasOlder?o.jsxs("div",{className:"load-earlier",children:[e.loadingOlder?o.jsx("span",{className:"load-earlier-busy",children:"正在加载更早的消息…"}):o.jsx("button",{className:"ghost-btn",onClick:()=>E(),children:"↑ load earlier messages"}),w&&!e.loadingOlder?o.jsx("span",{className:"load-earlier-end",children:w}):null]}):I&&e.msgs.length?o.jsx("div",{className:"load-earlier",children:o.jsx("span",{className:"load-earlier-end",children:"已到开头"})}):null,o.jsx(gC,{msgs:e.msgs,notes:e.notes,sid:e.info.id,backend:e.info.backend,busy:Zr(e),base:e.info.workspace||e.info.cwd}),o.jsx(dB,{busy:Zr(e),since:e.busySince}),e.perms.filter(B=>!e.msgs.some(C=>C.kind==="approval"&&C.requestId===B.requestId)).map(B=>o.jsx(yC,{sid:e.info.id,req:B},B.requestId))]})}),!c&&o.jsxs("button",{className:`jump-latest ${h?"has-new":""}`,onClick:()=>Kl.current(),title:h?"new output — jump to the newest":"jump to the newest","aria-label":"jump to newest output",children:[o.jsx(wS,{size:14}),h?o.jsx("span",{className:"jump-dot","aria-hidden":"true"}):null]})]})}const _C=g.memo(CB,(e,t)=>e.live===t.live&&e.m.key===t.m.key&&e.m.text===t.m.text&&e.m.at===t.m.at),mB=(e,t)=>{const s=e.m,n=t.m;return s.key===n.key&&s.title===n.title&&s.status===n.status&&s.detail===n.detail&&s.input===n.input&&s.at===n.at},vC=g.memo(kB,mB),gB=(e,t)=>{const s=e.m,n=t.m;return e.busy===t.busy&&s.key===n.key&&s.at===n.at&&s.terminal===n.terminal&&s.explanation===n.explanation&&JSON.stringify(s.items)===JSON.stringify(n.items)},_B=g.memo(SB,gB);function vB({text:e}){const t=OO(e),[s,n]=g.useState(!1);return t?o.jsxs("div",{className:`bg-notice ${s?"open":""}`,"data-ok":t.ok?"ok":"fail",children:[o.jsxs("button",{type:"button",className:"bg-notice-head","aria-expanded":s,onClick:()=>n(!s),children:[o.jsx("span",{className:"bg-notice-dot","aria-hidden":"true"}),o.jsx("span",{className:"bg-notice-title",children:t.kind==="watch"?"后台任务命中":"后台任务完成"}),o.jsx("code",{className:"bg-notice-cmd",title:t.command,children:Kb(t.command)}),t.kind==="watch"?o.jsxs("code",{className:"bg-notice-code",title:t.pattern,children:["「",Kb(t.pattern,28),"」"]}):t.exitCode===null?o.jsx("span",{className:"bg-notice-code",children:"已结束"}):o.jsxs("span",{className:"bg-notice-code",children:["exit ",t.exitCode]}),o.jsx("span",{className:"bg-notice-caret","aria-hidden":"true",children:s?"▾":"▸"})]}),s?o.jsxs("div",{className:"bg-notice-body",children:[o.jsx("div",{className:"bg-notice-label",children:"命令"}),o.jsx("pre",{className:"bg-notice-pre",children:t.command||"(未报告)"}),o.jsxs("div",{className:"bg-notice-label",children:[t.kind==="watch"?"命中行":"输出",t.output?"":"(空)"]}),t.output?o.jsx("pre",{className:"bg-notice-pre",children:t.output}):null]}):null]}):o.jsx(o.Fragment,{children:e})}function yB({d:e,base:t}){const[s,n]=g.useState(!1),i=e.tasks.filter(r=>!r.ok).length;return o.jsxs("div",{className:`bg-notice deleg-notice ${s?"open":""}`,"data-ok":i?"fail":"ok",children:[o.jsxs("button",{type:"button",className:"bg-notice-head","aria-expanded":s,onClick:()=>n(!s),children:[o.jsx("span",{className:"bg-notice-dot","aria-hidden":"true"}),o.jsx("span",{className:"bg-notice-title",children:"子代理回来了"}),o.jsx("code",{className:"bg-notice-cmd",title:e.tasks.map(r=>r.goal).join(`
127
+ `),children:zO(e)}),o.jsx("span",{className:"bg-notice-caret","aria-hidden":"true",children:s?"▾":"▸"})]}),s?o.jsxs("div",{className:"bg-notice-body",children:[e.dispatched?o.jsxs("div",{className:"bg-notice-label",children:["派发于 ",e.dispatched,e.role?` · ${e.role}`:"",e.total?` · 合计 ${e.total}`:""," · ",e.id]}):null,e.tasks.map(r=>o.jsxs("div",{className:"deleg-task","data-ok":r.ok?"ok":"fail",children:[o.jsxs("div",{className:"deleg-task-head",children:[o.jsx("span",{className:"deleg-mark","aria-hidden":"true",children:r.ok?"✓":"✗"}),o.jsx("span",{className:"deleg-goal",children:r.goal||`任务 ${r.index}`}),o.jsxs("span",{className:"deleg-meta",children:[r.status,r.meta?` · ${r.meta}`:""]})]}),r.body?o.jsx("div",{className:"deleg-body",children:o.jsx(G1,{text:r.body,base:t})}):null]},r.index))]}):null]})}function bB({text:e,base:t}){const s=FO(e);return s?o.jsx(yB,{d:s,base:t}):o.jsx(vB,{text:e})}function wB({m:e,sid:t,backend:s,last:n,busy:i,live:r,base:a}){switch(e.kind){case"user":return o.jsxs("div",{className:`msg user${e.from?" from-agent":""}`,children:[o.jsx("div",{className:"role",title:e.from?`会话 ${e.from.id}`:void 0,children:e.from?`来自「${e.from.title}」`:"YOU"}),o.jsxs("div",{className:"bubble",children:[e.files.length>0?o.jsx("div",{className:"bubble-files",children:e.files.map((l,c)=>o.jsxs("span",{className:"bubble-file",title:l.name,children:[l.kind==="image"?o.jsx(xN,{size:12}):o.jsx(ci,{size:12}),l.name]},`${l.name}-${c}`))}):null,o.jsx(bB,{text:e.text,base:a}),o.jsxs("div",{className:"bubble-actions",children:[e.at?o.jsx("span",{className:"msg-at",title:uo(e.at),children:_m(e.at)}):null,o.jsx(Vh,{text:e.text,what:"这条消息"})]})]})]});case"agent":{const l=Bh(e.text);return o.jsxs("div",{className:"msg agent",children:[o.jsxs("div",{className:"role with-mark",children:[o.jsx(nB,{backend:s}),vd(s).label||"AGENT"]}),o.jsxs("div",{className:"bubble",children:[o.jsx(G1,{text:l,base:a}),o.jsxs("div",{className:"bubble-actions",children:[e.at?o.jsx("span",{className:"msg-at",title:uo(e.at),children:_m(e.at)}):null,o.jsx(Vh,{text:l,what:"这条回复"}),o.jsx(DB,{id:e.key,text:l,sid:t}),n&&!i?o.jsx(tB,{sid:t,busy:i}):null]}),o.jsx(IB,{mkey:e.key})]})]})}case"thought":return e.text.trim()?o.jsx(_C,{m:e,live:!!r}):null;case"approval":return o.jsx(RB,{m:e,sid:t});case"project-skills":return o.jsx(jB,{m:e,sid:t});case"tool":return o.jsx(vC,{m:e});case"plan":return o.jsx(_B,{m:e,busy:i});case"meta":return o.jsx("div",{className:"msg meta",children:o.jsx("div",{className:"bubble",children:e.text})});default:return null}}function xB({v:e}){const[t,s]=g.useState(!1),n=g.useRef(null),i=e.plan;if(g.useLayoutEffect(()=>{t&&fC(n.current)},[t,i]),!i||!i.items.length)return null;const r=i.items.length,a=i.items.filter(h=>h.status==="completed").length,l=a===r,c=i.terminal==="interrupted"?"已打断":i.terminal==="failed"?"运行出错":i.terminal==="ended"?"回合结束":l?"已完成":e.busy?"进行中":"待命中",u=i.terminal?"terminal":l?"done":e.busy?"running":"";return o.jsxs("div",{className:`plan-bar ${l&&!i.terminal?"completed":""}`,children:[o.jsxs("button",{type:"button",className:"plan-head",onClick:()=>s(h=>!h),"aria-expanded":t,title:"任务计划 · 点击展开/折叠",children:[o.jsx("span",{className:"plan-title",children:"任务计划"}),o.jsx("span",{className:"plan-dots","aria-hidden":"true",children:i.items.map((h,d)=>o.jsx("span",{className:`dot ${h.status}`},d))}),o.jsxs("span",{className:"plan-count",children:[a,"/",r]}),o.jsx("span",{className:`plan-state ${u}`,children:c}),o.jsx(an,{size:11,className:`tool-chev ${t?"open":""}`})]}),t?o.jsxs("ol",{className:"plan-body",ref:n,children:[i.title?o.jsx("li",{className:"plan-name","aria-label":"计划名",children:i.title}):null,i.items.map((h,d)=>o.jsxs("li",{className:`plan-step ${h.status}`,children:[o.jsx("span",{className:"step-icon","aria-hidden":"true",children:h.status==="completed"?"✓":h.status==="in_progress"?"◉":h.status==="cancelled"?"✕":"○"}),o.jsx("span",{className:"step-title",children:h.content})]},d))]}):null,t&&i.explanation?o.jsx("p",{className:"plan-explanation",children:i.explanation}):null]})}function SB({m:e,busy:t}){const[s,n]=g.useState(!1),i=g.useRef(null);g.useLayoutEffect(()=>{s&&fC(i.current)},[s,e]);const r=e.items.length;if(!r)return null;const a=e.items.filter(h=>h.status==="completed").length,l=a===r,c=e.terminal==="interrupted"?"已打断":e.terminal==="failed"?"运行出错":e.terminal==="ended"?"回合结束":l?"已完成":t?"进行中":"",u=e.terminal?"terminal":l?"done":t?"running":"";return o.jsx("div",{className:"msg",children:o.jsxs("div",{className:`plan-card ${l&&!e.terminal?"completed":""}`,children:[o.jsxs("button",{type:"button",className:"plan-head",onClick:()=>n(h=>!h),"aria-expanded":s,title:"任务计划 · click to collapse/expand",children:[o.jsx("span",{className:"plan-title",children:"任务计划"}),o.jsx("span",{className:"plan-dots","aria-hidden":"true",children:e.items.map((h,d)=>o.jsx("span",{className:`dot ${h.status}`},d))}),o.jsxs("span",{className:"plan-count",children:[a,"/",r]}),c?o.jsx("span",{className:`plan-state ${u}`,children:c}):null,o.jsx(an,{size:11,className:`tool-chev ${s?"open":""}`})]}),s?o.jsxs("ol",{className:"plan-body",ref:i,children:[e.title?o.jsx("li",{className:"plan-name","aria-label":"计划名",children:e.title}):null,e.items.map((h,d)=>o.jsxs("li",{className:`plan-step ${h.status}`,children:[o.jsx("span",{className:"step-icon","aria-hidden":"true",children:h.status==="completed"?"✓":h.status==="in_progress"?"◉":h.status==="cancelled"?"✕":"○"}),o.jsx("span",{className:"step-title",children:h.content})]},d))]}):null,s&&e.explanation?o.jsx("p",{className:"plan-explanation",children:e.explanation}):null]})})}function kB({m:e}){const[t,s]=g.useState(!1),n=!!(e.input||e.detail),i=rg(e.status);return o.jsx("div",{className:"msg",children:o.jsxs("div",{className:`tool-card ${e.status}`,children:[o.jsxs("button",{type:"button",className:"tool-head",onClick:()=>n&&s(r=>!r),title:n?`${e.title}
128
+ click for the full call and its result`:e.title,"aria-expanded":n?t:void 0,children:[o.jsx("span",{className:`tool-dot ${i}`,"aria-hidden":"true"}),o.jsx("span",{className:"tool-title",children:e.title}),e.at?o.jsx("span",{className:"msg-at",title:uo(e.at),children:Ti(e.at)}):null,n?o.jsx(an,{size:11,className:`tool-chev ${t?"open":""}`}):null]}),t&&o.jsxs("div",{className:"tool-body",children:[o.jsx("div",{className:"lbl",children:"tool"}),o.jsx("pre",{className:"tool-meta",children:e.title}),o.jsx("div",{className:"lbl",children:"kind · status"}),o.jsxs("pre",{className:"tool-meta",children:[e.kind2?`${e.kind2} · `:"",e.status]}),e.input?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"lbl",children:"input"}),o.jsx("pre",{children:e.input})]}):null,e.detail?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"lbl",children:"output"}),o.jsx("pre",{children:e.detail})]}):null]})]})})}function rg(e){const t=String(e||"").toLowerCase();return t==="completed"||t==="success"?"ok":t==="failed"||t==="error"||t==="cancelled"?"err":t==="in_progress"||t==="running"||t==="pending"?"running":"idle"}function CB({m:e,live:t}){const[s,n]=g.useState(null),i=s??t,r=g.useRef(null),[a,l]=g.useState(!0),c=24;g.useEffect(()=>{const h=r.current;if(!h||!t)return;let d=h.scrollTop;const p=()=>h.scrollHeight-h.scrollTop-h.clientHeight<=c,f=()=>{const w=h.scrollTop,x=w-d;if(d=w,x<-2){l(!1);return}l(p())},m=w=>{w.deltaY<0&&l(!1)};let b=0;const _=w=>{b=w.touches[0]?.clientY??0},v=w=>{(w.touches[0]?.clientY??0)>b+4&&l(!1)},y=w=>{(w.key==="PageUp"||w.key==="ArrowUp"||w.key==="Home")&&l(!1)};return h.addEventListener("scroll",f,{passive:!0}),h.addEventListener("wheel",m,{passive:!0}),h.addEventListener("touchstart",_,{passive:!0}),h.addEventListener("touchmove",v,{passive:!0}),h.addEventListener("keydown",y),()=>{h.removeEventListener("scroll",f),h.removeEventListener("wheel",m),h.removeEventListener("touchstart",_),h.removeEventListener("touchmove",v),h.removeEventListener("keydown",y)}},[t,i]),g.useEffect(()=>{if(!t||!a)return;const h=r.current;h&&(h.scrollTop=h.scrollHeight)},[e.text,t,a]);const u=()=>{l(!0);const h=r.current;h&&(h.scrollTop=h.scrollHeight)};return o.jsxs("div",{className:`msg thought${t?" live":""}`,children:[o.jsxs("button",{type:"button",className:"role thought-head","aria-expanded":i,"aria-label":`${i?"fold":"open"} the agent's thinking`,onClick:()=>n(!i),children:[o.jsx(an,{size:11,className:`thought-chev${i?" open":""}`}),"💭 ",t?"思考中…":"思考",o.jsxs("span",{className:"thought-meta",children:[e.at?`${_m(e.at)} · `:"",e.text.length," 字"]})]}),i&&o.jsxs("div",{className:`bubble${t?" live":""}`,ref:r,children:[e.text,t?null:o.jsx("div",{className:"bubble-actions",children:o.jsx(Vh,{text:e.text,what:"这段思考"})})]}),t&&i&&!a&&o.jsxs("button",{type:"button",className:"thought-stick",onClick:u,title:"follow the newest thinking again","aria-label":"follow the newest thinking again",children:[o.jsx(wS,{size:11})," 回到最新"]})]})}const Jf=e=>e.kind==="thought"||e.kind==="tool";function EB(e){const t=[];let s=0;for(;s<e.length;){const c=e[s];if(!Jf(c)){t.push({kind:"msg",m:c}),s++;continue}let u=s;for(;u<e.length&&Jf(e[u]);)u++;t.push({kind:"work",items:e.slice(s,u).filter(Jf),current:!1}),s=u}const n=t.map(c=>c.kind).lastIndexOf("work");let i=-1;if(t.forEach((c,u)=>{c.kind==="msg"&&c.m.kind==="user"&&(i=u)}),n>i){const c=t[n];c.kind==="work"&&(c.current=!0)}const r=[],a=c=>({kind:"msg",m:c,live:!1,tail:!1});for(const c of t){if(c.kind==="msg"){r.push(a(c.m));continue}const u=c.current?c.items.slice(-5):[],h=c.items.slice(0,c.items.length-u.length);h.length>=(c.current?1:2)?r.push({kind:"work",key:`work-${r.length}`,items:h,tail:!1}):h.forEach(d=>r.push(a(d))),u.forEach(d=>r.push(a(d)))}const l=[...r].reverse().find(c=>c.kind==="msg");l&&l.kind==="msg"&&(l.tail=!0);for(const c of r)c.kind==="msg"&&(c.m.kind==="agent"||c.m.kind==="thought")&&(c.live=!!c.m.open);return r}function NB({items:e}){const[t,s]=g.useState(!1),n=e.filter(m=>m.kind==="tool"),i=e.filter(m=>m.kind==="thought"),r=n.filter(m=>rg(m.status)==="err").length,a=n.some(m=>rg(m.status)==="running"),l=i.reduce((m,b)=>m+b.text.length,0),c=[...new Set(n.map(m=>m.title.replace(/\s+/g," ").trim()))],u=c.slice(0,2).map(m=>m.length>34?`${m.slice(0,33)}…`:m).join(" · "),h=n.length&&i.length?`${n.length} 次工具调用 · ${i.length} 段思考`:n.length?`${n.length} 次工具调用`:`${i.length} 段思考`,d=e.map(m=>m.at).filter(m=>typeof m=="number"),p=d.length?Math.min(...d):null,f=d.length?Math.max(...d):null;return o.jsx("div",{className:"msg",children:o.jsxs("div",{className:"work-run",children:[o.jsxs("button",{type:"button",className:"work-run-head","aria-expanded":t,title:[`折叠了 ${n.length} 次工具调用、${i.length} 段思考(${l} 字)`,"点开看它们",...n.map(m=>`· ${m.title}`)].join(`
129
+ `),onClick:()=>s(m=>!m),children:[o.jsx(an,{size:11,className:`work-chev${t?" open":""}`}),o.jsx("span",{className:"work-run-icon","aria-hidden":"true",children:n.length?"⚙":"💭"}),o.jsx("span",{className:"work-run-count",children:h}),c.length?o.jsx("span",{className:"work-run-names",children:c.length>2?`${u} +${c.length-2}`:u}):o.jsxs("span",{className:"work-run-chars",children:[l," 字"]}),o.jsx("span",{className:`work-run-state ${r?"err":a?"run":"ok"}`,"aria-hidden":"true",children:r?`✗ ${r}`:a?"•••":"✓"}),p?o.jsxs("span",{className:"msg-at",title:`${uo(p)}${f&&f!==p?` → ${uo(f)}`:""}`,children:[Ti(p),f&&f-p>=6e4?`–${Ti(f)}`:""]}):null]}),t&&o.jsx("div",{className:"work-run-items",children:e.map(m=>m.kind==="thought"?o.jsx(_C,{m,live:!1},m.key):o.jsx(vC,{m},m.key))})]})})}function yC({sid:e,req:t}){return o.jsx("div",{className:"msg",children:o.jsxs("div",{className:"perm-card",children:[o.jsxs("div",{className:"q",children:["🔑 agent 要执行:",o.jsx("b",{children:t.toolCallTitle}),"(",t.kind,")"]}),o.jsx(L_,{req:t}),o.jsx("div",{className:"opts",children:o.jsx(bC,{sid:e,req:t})})]})})}function RB({m:e,sid:t}){const s=g.useSyncExternalStore(ee.subscribe,ee.getSnapshot),n=s.active?.info.id===t&&!!s.active?.perms.some(r=>r.requestId===e.requestId),i={requestId:e.requestId,sessionId:t,toolCallTitle:e.title,kind:e.kind2,options:e.options,createdAt:e.at??Date.now(),path:e.path,diff:e.diff};return e.decision?o.jsx(Jb,{m:e}):n||!s.active?o.jsx(yC,{sid:t,req:i}):o.jsx(Jb,{m:e,lapsed:!0})}function Jb({m:e,lapsed:t}){const s=e.decision&&e.decision.outcome==="selected"?e.decision.optionId:null,n=e.options.find(a=>a.optionId===s),i=t?"已作废(服务端不再等这个请求了)":e.decision?.outcome==="selected"?`已答:${n?.name??"已选"}`:"已取消",r=t||e.decision?.outcome!=="selected"?"no":"yes";return o.jsx("div",{className:"msg",children:o.jsxs("div",{className:`perm-card done ${r}`,children:[o.jsxs("div",{className:"q",children:["🔑 agent 曾要执行:",o.jsx("b",{children:e.title}),"(",e.kind2,")"]}),o.jsx(L_,{req:{requestId:e.requestId,sessionId:"",toolCallTitle:e.title,kind:e.kind2,options:e.options,createdAt:e.at??0,path:e.path,diff:e.diff}}),o.jsx("div",{className:"perm-decision",children:i})]})})}function jB({m:e,sid:t}){const s=e.state==="trusted"||e.state==="ignore",n=i=>{ee.send({t:"set-config",sessionId:t,configId:"project_skills",value:i})};return o.jsx("div",{className:"msg",children:o.jsxs("div",{className:`perm-card skills ${s?"done":""} ${e.state==="trusted"?"yes":e.state==="ignore"?"no":""}`,children:[o.jsxs("div",{className:"q",children:["📦 ",e.text]}),e.root?o.jsxs("div",{className:"perm-file",title:e.root,children:[o.jsx(ci,{size:12}),o.jsx("code",{children:e.root})]}):null,s?o.jsx("div",{className:"perm-decision",children:e.state==="trusted"?"已信任:这个仓库的 skill 会随会话加载":"已忽略:不再问,也不加载"}):o.jsxs("div",{className:"opts",children:[o.jsxs("button",{className:"opt primary",onClick:()=>n("trusted"),children:["信任这个仓库(",e.count," 个 skill)"]}),o.jsx("button",{className:"opt",onClick:()=>n("ignore"),children:"这个仓库不用问"})]})]})})}function L_({req:e}){if(e.diff)return o.jsx(TB,{diff:e.diff});const t=e.path??null;return t?o.jsxs("div",{className:"perm-file",title:t,children:[o.jsx(ci,{size:12}),o.jsx("code",{children:t})]}):null}function bC({sid:e,req:t,onAnswered:s}){const n=(a,l,c)=>{const u=ee.permAnswer(t.requestId);if(u&&!u.lapsed)return;const h=ee.send({t:"respond-permission",sessionId:e,requestId:t.requestId,decision:a,...c?{optionKind:c.kind,signature:`${t.kind}:${t.toolCallTitle}`}:{}});ee.markPermAnswered(t.requestId,l,h),s?.(l)},i=ee.permAnswer(t.requestId),[,r]=g.useState(0);return g.useEffect(()=>{if(!i||i.lapsed)return;const a=window.setInterval(()=>r(l=>l+1),1e3);return()=>window.clearInterval(a)},[i?.lapsed,t.requestId]),i&&!i.lapsed?o.jsxs("div",{className:"perm-answered",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"perm-answered-tick","aria-hidden":"true",children:"✓"}),o.jsxs("span",{children:["已提交「",i.label,"」—— 正在等 agent 那边回应"]})]}):o.jsxs(o.Fragment,{children:[i?.lapsed&&o.jsxs("div",{className:"perm-unconfirmed",role:"status","aria-live":"polite",children:["还没收到 agent 那边的确认(等了 ",Math.max(1,Math.round((Date.now()-i.at)/1e3))," 秒) —— 可能是这一次答复没送出去,可以再点一次。"]}),t.options.map(a=>o.jsx("button",{className:a.kind.startsWith("allow")?"allow":"reject",onClick:()=>n({outcome:"selected",optionId:a.optionId},a.name,a),children:a.name},a.optionId)),o.jsx("button",{title:"不选任何一项:agent 会收到 cancelled,这一轮就停在这里",onClick:()=>n({outcome:"cancelled"},"取消这次请求"),children:"取消这次请求"})]})}function wC({lines:e}){return o.jsx("div",{className:"perm-diff",role:"region","aria-label":"变更内容",children:e.map((t,s)=>t.kind==="gap"?o.jsx("div",{className:"perm-diff-gap",children:t.text},s):o.jsxs("div",{className:`perm-diff-line ${t.kind}`,children:[o.jsx("span",{className:"no",children:t.oldNo??""}),o.jsx("span",{className:"no",children:t.newNo??""}),o.jsx("span",{className:"sig",children:t.kind==="add"?"+":t.kind==="del"?"−":" "}),o.jsx("span",{className:"txt",children:t.text||" "})]},s))})}function TB({diff:e}){const[t,s]=g.useState(!1),n=e.oldText??"",i=e.newText??"",r=i.length>0&&n.length===0,a=n_(n,i),l=a.filter(u=>u.kind==="add").length,c=a.filter(u=>u.kind==="del").length;return o.jsxs("div",{className:"perm-changes",children:[o.jsxs("button",{type:"button",className:"perm-change-row","aria-expanded":t,"aria-label":`${t?"收起":"查看"} ${e.path??"这份文件"} 的变更`,onClick:()=>s(u=>!u),children:[o.jsx(ci,{size:13}),o.jsx("code",{title:e.path??"",children:e.path??"(未命名文件)"}),o.jsx("span",{className:"perm-counts",children:r?o.jsxs("span",{className:"add",children:["新文件 · ",l," 行"]}):o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"add",children:["+",l]}),o.jsxs("span",{className:"del",children:["−",c]})]})}),o.jsx("span",{className:"perm-caret","aria-hidden":"true",children:t?"▾":"▸"})]}),t?o.jsx(wC,{lines:a}):null,e.truncated?o.jsx("div",{className:"perm-cut",children:"agent 发来的是整份文件,这里只保留了改动附近的部分"}):null]})}function Xb({f:e}){const[t,s]=g.useState(!1),n=e.oldText.length===0&&e.newText.length>0,i=n||e.oldText.length>0||e.newText.length>0,r=g.useMemo(()=>i?n_(e.oldText,e.newText):[],[i,e.oldText,e.newText]),a=e.path===e.name?"":e.path.slice(0,e.path.length-e.name.length).replace(/[\\/]+$/,"");return o.jsxs("div",{className:"fc-row",children:[o.jsxs("div",{className:"fc-line",children:[o.jsx("span",{className:"fc-dot","aria-hidden":"true"}),o.jsxs("button",{type:"button",className:"fc-name",title:`在右侧面板打开 ${e.path}`,onClick:()=>WS({path:e.path}),children:[e.name,a?o.jsx("span",{className:"fc-dir",children:a}):null,e.edits>1?o.jsxs("span",{className:"fc-edits",children:["改了 ",e.edits," 次"]}):null]}),o.jsx("button",{type:"button",className:"fc-counts","aria-expanded":t,"aria-label":`${t?"收起":"查看"} ${e.path} 的变更`,disabled:!i,onClick:()=>s(l=>!l),children:n?o.jsxs("span",{className:"add",children:["新文件 · ",e.insertions," 行"]}):o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"add",children:["+",e.insertions]}),o.jsxs("span",{className:"del",children:["−",e.deletions]})]})})]}),t&&i?o.jsx(wC,{lines:r}):null]})}function Zb({msgs:e}){const t=g.useMemo(()=>{const a=[];for(const l of e)l.kind==="tool"&&l.changes?.length&&a.push(...l.changes);return zN(a)},[e]),[s,n]=g.useState(!0);if(!t.length)return null;if(t.length===1)return o.jsx("div",{className:"file-changes one",children:o.jsx(Xb,{f:t[0]})});const i=t.reduce((a,l)=>a+l.insertions,0),r=t.reduce((a,l)=>a+l.deletions,0);return o.jsxs("div",{className:"file-changes",children:[o.jsxs("button",{type:"button",className:"fc-head","aria-expanded":s,"aria-label":`${s?"收起":"展开"} ${t.length} 个文件变更`,onClick:()=>n(a=>!a),children:[o.jsx(ci,{size:13}),o.jsxs("span",{className:"fc-title",children:[t.length," 个文件变更"]}),o.jsxs("span",{className:"fc-counts static",children:[o.jsxs("span",{className:"add",children:["+",i]}),o.jsxs("span",{className:"del",children:["−",r]})]}),o.jsx("span",{className:"perm-caret","aria-hidden":"true",children:s?"▾":"▸"})]}),s?t.map(a=>o.jsx(Xb,{f:a},a.path)):null]})}function AB({req:e,sessionTitle:t,waiting:s,onSkip:n}){Ta(!0,n);const[i,r]=g.useState(()=>Date.now());g.useEffect(()=>{const u=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(u)},[e.requestId]);const a=Math.max(0,Math.round((i-e.createdAt)/1e3)),l=ee.permAnswer(e.requestId),c=Math.max(0,s-1);return o.jsx("div",{className:"modal-bg perm-bg",onClick:n,children:o.jsxs("div",{className:"modal perm-dialog",role:"dialog","aria-modal":"true","aria-label":"agent 请求授权","data-request-id":e.requestId,"data-session-id":e.sessionId,"data-waiting":s,onClick:u=>u.stopPropagation(),children:[o.jsx("h3",{children:"Agent 请求授权"}),o.jsxs("div",{className:"perm-ask",children:["「",t,"」里的 agent 停在这里等你答复 —— 它要执行 ",o.jsx("b",{children:e.toolCallTitle}),"(",e.kind,")。"]}),o.jsx(L_,{req:e}),o.jsx("div",{className:"opts perm-opts",children:o.jsx(bC,{sid:e.sessionId,req:e})}),c>0&&o.jsxs("div",{className:"perm-queue",role:"note",children:["这个会话还有 ",o.jsx("b",{children:c})," 个请求等着答复 —— 答完这个,下一个会接着显示在这里。"]}),o.jsxs("div",{className:"perm-note",children:["已等待 ",a," 秒。一直不答复的话,agent 那边会自己放弃这次请求(等同拒绝),这一轮就停在这里。"]}),!l&&o.jsx("div",{className:"row",children:o.jsx("button",{className:"cancel",onClick:n,children:"稍后处理"})})]})})}function Xf(e){if(e<=0)return"";if(e%60===0){const t=e/60;return t<60?`${t} 分钟`:`${Math.round(t/60)} 小时`}return`${e} 秒`}function MB(e){const t=e??"",[s,n]=g.useState({mode:"off",intervalSec:0,source:"default"}),[i,r]=g.useState(!0);g.useEffect(()=>{if(!t)return;let c=!0;return fetch(`/api/sessions/${encodeURIComponent(t)}/speak`,{credentials:"same-origin"}).then(u=>u.ok?u.json():null).then(u=>{c&&u?.speak&&n(u.speak)}).catch(()=>{}),()=>{c=!1}},[t]),g.useEffect(()=>{let c=!0;return fetch("/api/speak-modes",{credentials:"same-origin"}).then(u=>u.ok?u.json():null).then(u=>{c&&typeof u?.observerEnabled=="boolean"&&r(u.observerEnabled)}).catch(()=>{}),()=>{c=!1}},[]);const a=g.useCallback((c,u=0)=>{t&&(n({mode:c,intervalSec:c==="brief"?u:0,source:"session"}),fetch(`/api/sessions/${encodeURIComponent(t)}/speak`,{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({mode:c,intervalSec:c==="brief"?u:0})}).catch(()=>{}))},[t]),l=g.useCallback(()=>{t&&fetch(`/api/sessions/${encodeURIComponent(t)}/speak`,{method:"DELETE",credentials:"same-origin"}).then(c=>c.ok?c.json():null).then(c=>{c?.resolved&&n(c.resolved)}).catch(()=>{})},[t]);return{...s,observerEnabled:i,save:a,reset:l}}function DB({id:e,text:t,sid:s}){const[n]=go(),i=dd(),[r,a]=g.useState(!1),[l,c]=g.useState(!1),[u,h]=g.useState(null),d=g.useRef(null);lo(r,[d],()=>a(!1));const p=g.useRef({timer:null,fired:!1}),f=()=>{p.current.timer&&(window.clearTimeout(p.current.timer),p.current.timer=null)};g.useEffect(()=>f,[]);const m=()=>{p.current.fired=!1,f(),p.current.timer=window.setTimeout(()=>{p.current.fired=!0,a(!0)},500)};if(!t.trim())return null;const b=i.speaking&&i.speakingId===e;if(typeof window<"u"&&!("speechSynthesis"in window)&&!n.serverTts)return o.jsx("span",{className:"bubble-note",title:"this browser has no speech synthesis",children:"no voices"});const _=async v=>{if(l)return;const y=UO(pC(e,v));if(y){a(!1),Ft.speak(y.text,`${e}#summary:${v??"cfg"}`,n);return}c(!0),h(null);try{const w=await YO(s,e,v);a(!1),Ft.speak(w.text,`${e}#summary:${v??"cfg"}`,n)}catch(w){const x=w;h({msg:x?.message??String(w),hint:x?.hint}),a(!1)}finally{c(!1)}};return o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"speak-wrap bubble-speak",ref:d,children:[o.jsx("button",{className:`bubble-btn speak ${b?"on":""} ${l?"working":""}`,title:l?"正在生成语音播报总结…":b?"stop reading(长按:语音播报总结)":"read this reply aloud(长按:语音播报总结)","aria-label":b?"stop reading":"read aloud","aria-haspopup":"menu","aria-expanded":r,onClick:()=>{if(p.current.fired){p.current.fired=!1;return}b?uc():Ft.speak(t,e,n)},onPointerDown:m,onPointerUp:f,onPointerLeave:f,onPointerCancel:f,onContextMenu:v=>{v.preventDefault(),f(),a(!0)},onKeyDown:v=>{(v.key==="F10"&&v.shiftKey||v.key==="ContextMenu")&&(v.preventDefault(),a(!0))},children:l?o.jsx(ba,{size:13,className:"spin"}):b?o.jsx(SS,{size:13}):o.jsx(hd,{size:13})}),r?o.jsxs("div",{className:"speak-menu bubble-menu",role:"menu",children:[o.jsxs("button",{type:"button",role:"menuitem",className:"speak-menu-item","data-speak-summary":"verbatim",onClick:()=>{a(!1),Ft.speak(t,e,n)},children:[o.jsx("span",{className:"speak-check",children:"›"}),o.jsx("span",{className:"speak-name",children:"读整条"})]}),[100,150,200].map(v=>o.jsxs("button",{type:"button",role:"menuitem",className:"speak-menu-item",disabled:l,"data-speak-summary":String(v),onClick:()=>void _(v),children:[o.jsx("span",{className:"speak-check",children:l?"•":"›"}),o.jsx("span",{className:"speak-name",children:l?"总结中…":`语音播报总结 · 约 ${v} 字`})]},v)),o.jsxs("button",{type:"button",role:"menuitem",className:"speak-menu-item",disabled:l,"data-speak-summary":"cfg",onClick:()=>void _(),children:[o.jsx("span",{className:"speak-check",children:"›"}),o.jsx("span",{className:"speak-name",children:l?"总结中…":"语音播报总结 · 按设置"})]}),o.jsx("p",{className:"speak-hint",children:"把这条压成一段能听完的话;字数写进提示词交给模型(提示词在 设置 → 语音总结)"})]}):null]}),u?o.jsxs("span",{className:"bubble-note err",role:"status",children:[u.msg,u.hint?` · ${u.hint}`:""]}):null]})}function IB({mkey:e}){const t=g.useSyncExternalStore(HO,Vb,Vb),[s,n]=g.useState(!1),i=WO(e);if(!i)return null;const r=i.route==="session"?`${i.provider??""}${i.provider?" · ":""}${i.model??""}`:i.model?`语音端点 · ${i.model}`:"",a=i.maxChars?` · 按 ${i.maxChars} 字压`:"",l=i.via==="verbatim"?"原文本身就够短,直接念":`${i.chars} 字${a} · ${(i.ms/1e3).toFixed(1)}s${r?` · ${r}`:""}`;return o.jsxs("div",{className:`bubble-note speech-note${s?" open":""}`,"data-summary-chars":i.chars,children:[o.jsx("button",{type:"button",className:"speech-note-tag","aria-expanded":s,onClick:()=>n(c=>!c),children:"播报稿"}),o.jsx("span",{className:"speech-note-text",onClick:()=>n(c=>!c),title:"点击展开/收起",children:i.text}),o.jsx("span",{className:"speech-note-meta",title:i.routeNote??void 0,children:l}),o.jsx("button",{type:"button",className:"speech-note-x",title:"丢掉这份稿子(下次长按会重新生成)","aria-label":"drop this summary",onClick:()=>qO(e),children:o.jsx(En,{size:11})}),o.jsx("span",{hidden:!0,children:t})]})}const O_=["image/png","image/jpeg","image/webp","image/gif"],PB=4*1024*1024,LB=256*1024;function B_(){const e=g.useRef(!1);return{handlers:{onCompositionStart:()=>{e.current=!0},onCompositionEnd:()=>{e.current=!1}},isComposing:t=>e.current||t.nativeEvent.isComposing===!0}}function xC(e){return O_.includes(e.type)?e.size>PB?Promise.resolve({error:`${e.name}: image larger than 4MB`}):new Promise(s=>{const n=new FileReader;n.onload=()=>{const i=String(n.result??"");s({id:`${e.name}-${e.size}-${Math.random().toString(36).slice(2,7)}`,name:e.name,kind:"image",mimeType:e.type,preview:i,payload:i.slice(i.indexOf(",")+1),bytes:e.size})},n.onerror=()=>s({error:`${e.name}: could not be read`}),n.readAsDataURL(e)}):e.size>LB?Promise.resolve({error:`${e.name}: larger than 256kB — attach it as a path instead`}):new Promise(s=>{const n=new FileReader;n.onload=()=>s({id:`${e.name}-${e.size}-${Math.random().toString(36).slice(2,7)}`,name:e.name,kind:"text",mimeType:e.type||"text/plain",payload:String(n.result??""),bytes:e.size}),n.onerror=()=>s({error:`${e.name}: could not be read`}),n.readAsText(e)})}function SC(e){if(!e)return[];const t=Array.from(e.files??[]);for(const s of Array.from(e.items??[])){if(s.kind!=="file")continue;const n=s.getAsFile();n&&!t.some(i=>i.name===n.name&&i.size===n.size&&i.type===n.type)&&t.push(n)}return t}function kC(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(0)} kB`:`${(e/1048576).toFixed(1)} MB`}const Sr=["#7f8c98","#5fb3a1","#7fb069","#d9a441","#e8843c","#f0603f","#ff4d4d"];function CC(e,t){const s=Math.max(1,t.length),n=t.findIndex(a=>String(a.value)===String(e)),i=n<0?0:n+1;return{color:n<0?"var(--text-dim)":Sr[Math.min(n,Sr.length-1)],level:i,total:s}}function EC({level:e,total:t,color:s}){const n=Math.min(7,t),i=Math.max(0,Math.min(n,Math.round(e/t*n)));return o.jsx("span",{className:"tb-pips","aria-hidden":"true",children:Array.from({length:n}).map((r,a)=>o.jsx("i",{style:{background:a<i?s:"var(--line)"}},a))})}function kc(e,t){const s=t==="effort"?["thought_level","reasoning"]:["model","model_config"],n=t==="effort"?/reason|effort|think|depth/i:/model/i;return e.find(i=>i.type==="select"&&i.category&&s.includes(String(i.category)))??e.find(i=>i.type==="select"&&n.test(i.id))}function NC({label:e,title:t,icon:s,value:n,children:i,open:r,onToggle:a,testId:l}){const c=g.useRef(null);return lo(r,[c],a),o.jsxs("div",{className:"tb-wrap",ref:c,children:[o.jsxs("button",{type:"button",className:`tb-btn ${r?"on":""}`,title:t,"aria-label":t,"aria-expanded":r,"data-testid":l,onClick:a,children:[s,o.jsx("span",{className:"tb-label",children:n||e}),o.jsx(ya,{size:11,className:"tb-chev"})]}),r?i:null]})}function Yh({items:e,current:t,onPick:s,empty:n}){const i=fS();return e.length?o.jsx("div",{className:"tb-list",role:"listbox",ref:i,children:e.map(r=>o.jsxs("button",{role:"option","aria-selected":r.value===t,className:`tb-opt ${r.value===t?"sel":""}`,title:r.hint?`${r.name} — ${r.hint}`:r.name,onClick:()=>s(r.value),children:[o.jsxs("span",{className:"tb-opt-name",children:[r.color?o.jsx("i",{className:"tb-dot",style:{background:r.color}}):null,r.name]}),r.hint?o.jsx("span",{className:"tb-opt-hint",children:r.hint}):null]},r.value))}):o.jsx("div",{className:"tb-list",ref:i,children:o.jsx("div",{className:"tb-empty",children:n})})}function RC(e){return e.category==="_context_window"?!0:/budget|context/i.test(`${e.id} ${e.name??""}`)}function OB({v:e}){const t=e.info.usage,s=e.info.configOptions.find(RC),[n,i]=g.useState(!1),r=g.useRef(null),[a,l]=g.useState(!1),[c,u]=g.useState(""),[h,d]=g.useState(!0),[p,f]=g.useState(""),[m,b]=g.useState(""),_=B_(),v=e.trace;lo(n,[r],()=>{i(!1),l(!1)});const y=t?.used??0,w=t?.size??0,x=y>0||w>0,S=e.info.contextLimit&&e.info.contextLimit>0?e.info.contextLimit:null,E=e.info.modelContextLimit&&e.info.modelContextLimit>0?e.info.modelContextLimit:null,R=S?"session":E?"model":"agent",N=S??E??w,I=N>0?Math.min(100,Math.round(y/N*100)):0,F=x?I>=85?"hot":I>=65?"warn":"ok":"ok",B=N>0?Math.max(0,N-y):0,C=e.info.commands??[],A=O=>C.some(K=>K.name===O),M=R==="session"?"你为本会话声明":R==="model"?"你为这个模型记下的":"agent 上报(usage_update)",H=async(O,K={})=>{f(K.forgetModel?"forget":"save"),b("");try{await ee.setContextLimit(e.info.id,O,K),l(!1)}catch(U){b(String(U?.message??U))}finally{f("")}},D=O=>{if(e.info.cold){i(!1),ee.resume(e.info.id);return}ee.send({t:"prompt",sessionId:e.info.id,text:`/${O}`}),i(!1)},z=(O,K)=>{const U=K.trim();U&&(ee.send({t:"set-config",sessionId:e.info.id,configId:O,value:U}),u(""))},T=String(s?.currentValue??"");return o.jsxs("div",{className:`usage-row ${F}`,ref:r,children:[o.jsxs("button",{className:"usage-text",onClick:()=>i(O=>!O),title:"上下文窗口 — 点这里改",children:[o.jsx(Zv,{size:12,className:"usage-icon"}),x?N>0?`${Bo(y)} / ${Bo(N)}`:`${Bo(y)} / —`:N>0?`未上报用量 · 窗口 ${Bo(N)}`:"agent 未上报用量 · 设窗口",x&&N>0?` · ${I}%`:"",R==="session"?" · 声明":R==="model"?" · 模型记录":""]}),N>0?o.jsx("div",{className:"usage-bar",title:x?`${y} / ${N} tokens (${I}%)`:`agent 未上报用量 · 已声明 ${N} tokens`,children:o.jsx("i",{style:{width:`${x?I:0}%`}})}):null,F==="hot"&&A("compress")&&!e.busy?o.jsxs("button",{className:"usage-act",onClick:()=>D("compress"),title:"发送 /compress:让 agent 压缩上下文(这是它自己公告的命令)",children:[o.jsx(t_,{size:11})," 压缩上下文"]}):null,n?o.jsxs("div",{className:"usage-detail",children:[o.jsxs("div",{className:"usage-set",children:[o.jsxs("div",{className:"usage-set-head",children:[o.jsx(Zv,{size:12})," 上下文窗口",o.jsx("span",{className:"usage-set-scope",children:s?String(s.meta?.scope??"")==="model"?"按模型":"":"仅声明"})]}),s?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"usage-set-chips",children:(s.options??[]).map(O=>o.jsx("button",{className:`usage-chip ${T===String(O.value)?"sel":""}`,onClick:()=>z(s.id,String(O.value)),children:String(O.value)==="auto"?"自动":O.name},String(O.value)))}),o.jsxs("div",{className:"usage-edit",children:[o.jsx("input",{value:c,inputMode:"numeric","aria-label":"context window in tokens",placeholder:s.meta?.freeform===!0?"任意 token 数,如 300000":"填一个数",onChange:O=>u(O.target.value),onKeyDown:O=>{_.isComposing(O)||(O.key==="Enter"&&z(s.id,c),O.key==="Escape"&&(O.stopPropagation(),i(!1)))}}),o.jsx("button",{className:"usage-edit-btn",disabled:!c.trim(),onClick:()=>z(s.id,c),children:"set"})]}),o.jsx("div",{className:"settings-note",children:"常用:256k / 512k / 768k / 1m;填 auto 回到模型自己的窗口。"}),o.jsxs("div",{className:"usage-note",children:["改的是",o.jsx("b",{children:"这个模型"}),":同模型的所有会话(含新开的、别的槽位)都用同一个上限。它只会让 Hermes 更早压缩,不会把窗口撑过模型本身。"]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"usage-note",children:e.info.backend==="qoder"?o.jsxs(o.Fragment,{children:["这个后端不公告上下文旋钮,也不上报用量(所以没有仪表盘数字)。下面的",o.jsx("b",{children:"声明"}),"对 qoder 是真的: 它会在",o.jsx("b",{children:"下次启动"}),"(冷启 / 重启 / 恢复)时作为 ",o.jsx("code",{children:"--context-window"})," 交给 CLI, 当场改要先停一次会话。"]}):o.jsxs(o.Fragment,{children:["这个后端没公告上下文旋钮,所以下面这个数只是仪表盘的",o.jsx("b",{children:"声明"}),",只影响百分比;真减上下文用压缩命令或换模型。"]})}),a?o.jsxs("div",{className:"usage-edit",children:[o.jsx("input",{autoFocus:!0,value:c,inputMode:"numeric","aria-label":"context window in tokens",placeholder:String(w||e.info.contextLimit||2e5),onChange:O=>u(O.target.value),..._.handlers,onKeyDown:O=>{if(!_.isComposing(O)){if(O.key==="Enter"){const K=Number(c.replace(/[^0-9]/g,""));K>0&&H(K,{remember:h})}O.key==="Escape"&&(O.stopPropagation(),l(!1))}}}),o.jsx("button",{className:"usage-edit-btn",disabled:p!==""||!Number(c.replace(/[^0-9]/g,"")),onClick:()=>void H(Number(c.replace(/[^0-9]/g,"")),{remember:h}),children:p==="save"?"…":"set"}),o.jsxs("label",{className:"usage-check",title:"像 studio 那样按模型记住:下次用这个模型自动带回来",children:[o.jsx("input",{type:"checkbox",checked:h,onChange:O=>d(O.target.checked)}),"记到本模型"]}),E?o.jsx("button",{className:"usage-edit-btn",disabled:p!=="",onClick:()=>void H(null,{forgetModel:!0}),children:p==="forget"?"…":"忘掉本模型记录"}):null]}):o.jsx("button",{className:"usage-edit-btn",onClick:()=>{u(String(N||2e5)),l(!0)},children:"声明窗口长度"})]})]}),o.jsx("div",{children:x?`已用 ${y} / ${N||"—"} tokens(${I}%)`:"agent 未上报用量(这个后端不发 usage_update)"}),o.jsxs("div",{children:["剩余:",x&&N>0?`${B} tokens`:"unknown"]}),o.jsxs("div",{children:["窗口来源:",o.jsx("b",{children:M})]}),w>0&&R!=="agent"?o.jsxs("div",{children:["agent 上报:",Bo(w)," tokens (usage_update)"]}):null,E&&R==="session"?o.jsxs("div",{children:["本模型记录:",Bo(E)," tokens"]}):null,t?.cost!=null?o.jsxs("div",{children:["本轮花费:$",t.cost.toFixed(6)]}):null,v?.model?o.jsxs("div",{children:["model:",v.model]}):null,v&&(v.effort||v.mode)?o.jsxs("div",{children:["本轮:",[v.effort&&`思考强度 ${v.effort}`,v.mode&&`模式 ${v.mode}`].filter(Boolean).join(",")]}):null,A("compress")||A("context")?o.jsxs("div",{className:"usage-actions",children:[A("compress")?o.jsx("button",{className:"usage-act",onClick:()=>D("compress"),title:"让 agent 压缩上下文(/compress,它自己公告的命令)",children:"压缩上下文"}):null,A("context")?o.jsx("button",{className:"usage-act",onClick:()=>D("context"),title:"看消息按角色分布(/context)",children:"消息分布"}):null]}):null,m?o.jsx("div",{className:"usage-edit-err",children:m}):null]}):null]})}function BB({o:e,sessionId:t}){const s=e.meta??{},n=s.freeform===!0,[i,r]=g.useState(""),a=String(e.currentValue??""),l=typeof s.unit=="string"?s.unit:"tokens",c=h=>ee.send({t:"set-config",sessionId:t,configId:e.id,value:h}),u=B_();return o.jsxs("div",{className:"settings-group",children:[o.jsxs("div",{className:"settings-label",children:[o.jsx(Tc,{size:13})," ",e.name||e.id]}),e.options?.map(h=>o.jsx("button",{className:`settings-opt ${a===String(h.value)?"sel":""}`,onClick:()=>c(String(h.value)),children:h.name},String(h.value))),n?o.jsxs("div",{className:"settings-freeform",children:[o.jsx("input",{className:"settings-input",type:"number",inputMode:"numeric",min:typeof s.min=="number"?s.min:void 0,step:typeof s.step=="number"?s.step:1024,placeholder:`任意 ${l}`,"aria-label":`${e.name||e.id} value`,value:i,onChange:h=>r(h.target.value),...u.handlers,onKeyDown:h=>{u.isComposing(h)||h.key==="Enter"&&i.trim()&&c(i.trim())}}),o.jsx("button",{className:"settings-opt",disabled:!i.trim(),onClick:()=>c(i.trim()),children:"set"})]}):null]})}function $B({v:e,prefs:t,setPrefs:s,onClose:n,panelRef:i}){const r=e.info,a=r.modes?.availableModes??[],l=kc(r.configOptions,"effort"),c=kc(r.configOptions,"model"),h=g.useSyncExternalStore(Ft.subscribeVoices,()=>Ft.voices().length)?Ft.voices():[],d=ai();return o.jsxs("div",{className:"settings-pop",role:"dialog","aria-label":"chat settings",ref:i,children:[o.jsxs("div",{className:"settings-head",children:[o.jsx("span",{children:"chat settings"}),o.jsx("span",{className:"head-spacer"}),o.jsx("button",{className:"icon-btn",title:"close","aria-label":"close",onClick:n,children:o.jsx(En,{size:13})})]}),a.length>0&&o.jsxs("div",{className:"settings-group",children:[o.jsxs("div",{className:"settings-label",children:[o.jsx(yS,{size:13})," permission mode"]}),a.map(p=>o.jsx("button",{className:`settings-opt ${r.modes?.currentModeId===p.id?"sel":""}`,onClick:()=>ee.send({t:"set-mode",sessionId:r.id,modeId:p.id}),children:p.name},p.id))]}),l?.options?.length?o.jsxs("div",{className:"settings-group",children:[o.jsxs("div",{className:"settings-label",children:[o.jsx(kN,{size:13})," thinking depth"]}),l.options.map((p,f)=>o.jsxs("button",{className:`settings-opt ${String(l.currentValue??"")===String(p.value)?"sel":""}`,onClick:()=>ee.send({t:"set-config",sessionId:r.id,configId:l.id,value:String(p.value)}),children:[o.jsx("i",{className:"settings-dot",style:{"--effort":Sr[Math.min(f,Sr.length-1)]}}),p.name]},String(p.value))),o.jsx("div",{className:"settings-note",children:"只列这个路由真支持的档;改的是本会话。"})]}):null,r.configOptions.filter(p=>p.type==="select"&&p.options&&p!==l&&p!==c&&!RC(p)).map(p=>o.jsx(BB,{o:p,sessionId:r.id},p.id)),o.jsxs("div",{className:"settings-group",children:[o.jsxs("div",{className:"settings-label",children:[o.jsx(hd,{size:13})," read replies aloud"]}),o.jsxs("label",{className:"settings-toggle",children:[o.jsx("input",{type:"checkbox",checked:t.autoRead,onChange:p=>s({autoRead:p.target.checked})}),o.jsx("span",{children:"speak every finished reply"})]}),h.length>0&&o.jsxs("select",{className:"settings-select",value:t.voiceURI,onChange:p=>s({voiceURI:p.target.value}),"aria-label":"voice",children:[o.jsxs("option",{value:"",children:["auto voice (",t.lang,")"]}),h.map(p=>o.jsxs("option",{value:p.voiceURI,children:[p.name," — ",p.lang]},p.voiceURI))]}),h.length===0?o.jsx("div",{className:"settings-note",children:"this browser exposes no voices"}):null,o.jsxs("label",{className:"settings-range",children:[o.jsxs("span",{children:["speed ",t.rate.toFixed(2),"×"]}),o.jsx("input",{type:"range",min:.5,max:2,step:.05,value:t.rate,onChange:p=>s({rate:Number(p.target.value)})})]}),d.tts.server?o.jsxs("label",{className:"settings-toggle",children:[o.jsx("input",{type:"checkbox",checked:t.serverTts,onChange:p=>s({serverTts:p.target.checked})}),o.jsxs("span",{children:["use the server voice (",d.tts.model??"configured",")"]})]}):null]}),o.jsxs("div",{className:"settings-group",children:[o.jsxs("div",{className:"settings-label",children:[o.jsx(Ri,{size:13})," dictation"]}),o.jsxs("select",{className:"settings-select",value:t.stt,onChange:p=>s({stt:p.target.value}),"aria-label":"dictation engine",children:[o.jsx("option",{value:"auto",children:"auto — 服务端流式 > 浏览器 > 批量"}),o.jsxs("option",{value:"stream",children:["stream",d.stt.streaming?` (${d.stt.model??"百炼"})`:" (not configured)"]}),o.jsxs("option",{value:"browser",children:["browser",Yp()?"":" (unavailable)"]}),o.jsxs("option",{value:"server",children:["server",d.stt.server?` (${d.stt.batchModel??"configured"})`:" (not configured)"]})]}),o.jsx("input",{className:"settings-input",value:t.lang,onChange:p=>s({lang:p.target.value}),placeholder:"language, e.g. zh-CN","aria-label":"speech language"}),o.jsxs("div",{className:"settings-note",children:["browser dictation ",Yp()?"available":"unavailable"," · ",d.provider," STT"," ",d.stt.streaming?"streaming":d.stt.server?"batch":"not configured"]})]})]})}const Tu=new Map;function FB({v:e,call:t,tus:s,onCloseCall:n}){const[i,r]=g.useState(()=>Tu.get(e.info.id)??""),a=RS(e.info.backend),l=window.innerWidth<720?"message… (/ for commands)":"message… (Enter send, Shift+Enter newline, / for commands)",c=/Mac|iPhone|iPad/.test(navigator.platform??"")?"⌘":"Ctrl+",u=window.innerWidth<=720?"message… (Enter queues)":`message… (${c}Enter interrupts · Enter queues)`,[h,d]=g.useState(0),[p,f]=g.useState(!1),m=g.useRef(null),b=g.useRef(null),_=g.useRef(null),v=g.useRef(!1),y=g.useRef(null),w=g.useRef(""),x=g.useRef(!1),S=g.useMemo(()=>e.msgs.filter(P=>P.kind==="user").map(P=>P.text).filter(P=>P.trim()),[e.msgs]),E=g.useRef(e.info.id);g.useEffect(()=>{Tu.set(E.current,i)},[i]),g.useEffect(()=>{E.current!==e.info.id&&(Tu.set(E.current,i),E.current=e.info.id,r(Tu.get(e.info.id)??""),y.current=null,w.current="",f(!1),d(0))},[e.info.id,i]);const[R,N]=g.useState([]),[I,F]=g.useState(null),[B,C]=g.useState(""),[A,M]=g.useState(!1),[H,D]=g.useState(!1),[z,T]=g.useState(null);g.useEffect(()=>{const P=Oe.current;P&&(P.style.height="42px",P.style.height=`${Math.min(P.scrollHeight,window.innerHeight*.4)}px`)},[i]);const[O,K]=g.useState(!1),[U,re]=g.useState(null),[J,Y]=g.useState({});g.useEffect(()=>{Y({}),re(null)},[e.info.id]);const[_e,xe]=go(),fe=o_(),et=dd(),Oe=g.useRef(null),tt=g.useRef(null),Pe=async P=>{const le=Array.from(P);if(!le.length)return;const je=await Promise.all(le.map(ot=>xC(ot))),Ie=[],Ge=[];for(const ot of je)"error"in ot?Ge.push(ot.error):Ie.push(ot);Ie.length&&N(ot=>[...ot,...Ie]),C(Ge.join(" · "))},Le=()=>R.map(P=>P.kind==="image"?{kind:"image",mimeType:P.mimeType,data:P.payload,name:P.name}:{kind:"text",name:P.name,text:P.payload}),Ee=P=>{if(P.key!=="ArrowUp"&&P.key!=="ArrowDown"||P.shiftKey||P.altKey||P.metaKey||P.ctrlKey||!S.length)return!1;const le=P.currentTarget,je=le.selectionStart??0;if(P.key==="ArrowUp"&&le.value.slice(0,je).includes(`
130
+ `)||P.key==="ArrowDown"&&le.value.slice(je).includes(`
131
+ `))return!1;if(P.preventDefault(),P.key==="ArrowUp")y.current===null?(w.current=le.value,y.current=S.length-1):y.current=Math.max(0,y.current-1);else{if(y.current===null)return!0;if(y.current>=S.length-1)return y.current=null,x.current=!0,r(w.current),requestAnimationFrame(()=>Oe.current?.setSelectionRange(w.current.length,w.current.length)),!0;y.current+=1}const Ie=S[y.current];return x.current=!0,r(Ie),requestAnimationFrame(()=>Oe.current?.setSelectionRange(Ie.length,Ie.length)),!0},Ae=()=>{const P=i.trim();if(!P&&!R.length)return;uc();const le=Le();if(e.info.cold){ee.sendToCold(e.info.id,P,le),r(""),N([]),C(""),d(0),Kl.current();return}if(Zr(e)||e.info.status!=="ready"){if(!P&&!le.length)return;ee.enqueuePrompt(e.info.id,P,le)}else ee.sendPrompt(e.info.id,P,le);r(""),N([]),C(""),d(0),y.current=null,w.current="",Kl.current()},Ze=()=>{const P=i.trim();if(!P&&!R.length)return;uc();const le=Le();e.info.cold?ee.sendToCold(e.info.id,P,le):ee.sendNow(e.info.id,P,le),r(""),N([]),C(""),d(0),Kl.current()};g.useEffect(()=>{if(t||!pe.owns("chat")||fe.status!=="idle"||!fe.text)return;const P=pe.consume();P&&(r(le=>le.trim()?`${le.trim()} ${P}`:P),Oe.current?.focus())},[fe.status,fe.text,t]),g.useEffect(()=>{if(t)return;let P=null,le=!1;const je=()=>{P!==null&&(window.clearTimeout(P),P=null)},Ie=dt=>{if(dt.key!=="Control"){P!==null&&je();return}dt.repeat||P!==null||le||document.activeElement===Oe.current&&(P=window.setTimeout(()=>{P=null,le=!0,pe.cancel(),pe.start(_e,e.info.id)},250))},Ge=dt=>{dt.key==="Control"&&(je(),le&&(le=!1,pe.owns("chat")&&pe.stop()))},ot=()=>{je(),le&&(le=!1,pe.owns("chat")&&pe.stop())};return window.addEventListener("keydown",Ie),window.addEventListener("keyup",Ge),window.addEventListener("blur",ot),()=>{je(),window.removeEventListener("keydown",Ie),window.removeEventListener("keyup",Ge),window.removeEventListener("blur",ot)}},[t,_e,e.info.id]);const me=/^\/\S*$/.test(i)?i.slice(1).toLowerCase():null,Ye=me===null?[]:e.info.commands.filter(P=>P.name.toLowerCase().includes(me)).slice(0,8),de=me!==null&&e.info.status==="ready"&&!p;lo(de,[m],()=>f(!0)),lo(H||z!==null,[b,_],()=>{T(null),D(!1)}),g.useEffect(()=>{T(null),D(!1),f(!1)},[e.info.id]);const lt=P=>{r(`/${P} `),d(0),Oe.current?.focus()},ae=fe.status==="listening"||fe.status==="recording"||fe.status==="requesting",be=kc(e.info.configOptions,"effort"),Be=kc(e.info.configOptions,"model"),W=e.info.models?.availableModels??[],Se=e.info.models?.currentModelId??"",He=W.find(P=>P.modelId===Se)?.name??Be?.options?.find(P=>String(P.value)===String(Be.currentValue??""))?.name??Se,q=s_(He,Se),Z=be?.options?.find(P=>String(P.value)===String(be.currentValue??""))?.name??"",ge=be?CC(String(be.currentValue??""),be.options??[]):null;return o.jsxs("div",{className:`composer ${A?"drop-active":""}`,onDragOver:P=>{P.preventDefault(),M(!0)},onDragLeave:()=>M(!1),onDrop:P=>{P.preventDefault(),M(!1),P.dataTransfer?.files?.length&&Pe(P.dataTransfer.files)},onPaste:P=>{const le=SC(P.clipboardData);le.length&&(P.preventDefault(),Pe(le))},children:[o.jsx(fB,{v:e}),o.jsx(xB,{v:e}),o.jsx(OB,{v:e}),o.jsxs("div",{className:"composer-inner",ref:m,children:[de&&o.jsx("div",{className:"slash-palette",role:"listbox","aria-label":"slash commands",children:Ye.length?Ye.map((P,le)=>o.jsxs("div",{role:"option","aria-selected":le===h,className:`slash-item ${le===h?"sel":""}`,onMouseEnter:()=>d(le),onClick:()=>lt(P.name),children:[o.jsxs("span",{className:"cmd",children:["/",P.name]}),P.description?o.jsx("span",{className:"desc",children:P.description}):null,o.jsx("span",{className:"src",title:"advertised by the agent over ACP",children:"agent"})]},P.name)):o.jsx("div",{className:"slash-item empty",children:e.info.commands.length?`no command matches “/${me}”`:"this agent advertises no slash commands"})}),H&&o.jsx($B,{v:e,prefs:_e,setPrefs:xe,onClose:()=>D(!1),panelRef:b}),R.length>0&&o.jsxs("div",{className:"draft-row",children:[R.map(P=>o.jsxs("span",{className:`draft ${P.kind}`,title:`${P.name} · ${kC(P.bytes)}`,children:[P.preview?o.jsx("img",{src:P.preview,alt:P.name}):o.jsx(ci,{size:13}),o.jsx("span",{className:"draft-name",children:P.name}),o.jsx("button",{className:"draft-x","aria-label":`remove ${P.name}`,onClick:()=>N(le=>le.filter(je=>je.id!==P.id)),children:o.jsx(En,{size:11})})]},P.id)),o.jsx("button",{className:"draft-clear",onClick:()=>N([]),children:"clear"})]}),B&&o.jsx("div",{className:"composer-note err",children:B}),e.queue.length>0&&o.jsxs("div",{className:"queue-list","aria-label":"queued messages",children:[o.jsxs("div",{className:"queue-head",children:[o.jsxs("span",{className:"queue-title",children:["Queued · ",e.queue.length]}),o.jsx("span",{className:"queue-hint",children:e.queue.some(P=>P.unsure)?"未确认送达 — 点 ↑ 重发,或 ✕ 丢掉":e.queue.some(P=>P.inflight)?"sending…":e.resuming?"waking the agent — sends once it is up":e.info.cold?"sends when you wake this session":e.info.status!=="ready"?"process starting — sends once ready":"goes out when this turn ends"})]}),e.queue.map((P,le)=>o.jsxs("div",{className:`queue-row${P.inflight?" inflight":""}${P.unsure?" unsure":""}`,"data-queue-id":P.id,children:[o.jsx("span",{className:"queue-idx","aria-hidden":"true",children:le+1}),I?.id===P.id?o.jsx("textarea",{className:"queue-edit",rows:1,autoFocus:!0,value:I.text,"aria-label":"edit the queued message",onChange:je=>F({id:P.id,text:je.target.value}),onKeyDown:je=>{if(je.key==="Escape"){je.preventDefault(),F(null);return}je.key==="Enter"&&!je.shiftKey&&(je.preventDefault(),ee.editQueued(e.info.id,P.id,I.text),F(null))},onBlur:()=>{ee.editQueued(e.info.id,P.id,I.text),F(null)}}):o.jsx("span",{className:"queue-text",title:P.text,children:P.text}),P.unsure?o.jsx("span",{className:"queue-flag",title:"服务器没回执 —— 点 ↑ 重发",children:"未送达"}):null,o.jsxs("span",{className:"queue-actions",children:[o.jsx("button",{className:"queue-btn",title:"send now — stops the running turn and takes the floor","aria-label":"send this one now",onClick:()=>ee.sendQueuedNow(e.info.id,P.id),children:o.jsx(bS,{size:13})}),o.jsx("button",{className:"queue-btn",title:"edit this message","aria-label":"edit this queued message",onClick:()=>F(I?.id===P.id?null:{id:P.id,text:P.text}),children:o.jsx(mS,{size:13})}),o.jsx("button",{className:"queue-btn danger",title:"drop it — it will not be sent","aria-label":"drop this queued message",onClick:()=>ee.dropQueued(e.info.id,P.id),children:o.jsx(En,{size:13})})]})]},P.id))]}),et.note?o.jsx("div",{className:"composer-note",children:et.note}):null,et.error?o.jsx("div",{className:"composer-note err",children:et.error}):null,ae||fe.status==="transcribing"||fe.error?o.jsxs("div",{className:`dict-chip ${fe.error?"err":""}`,children:[o.jsx(Ri,{size:13}),fe.error?fe.error:fe.status==="requesting"?"waiting for the microphone…":fe.status==="transcribing"?"transcribing…":o.jsxs(o.Fragment,{children:[fe.text," ",o.jsx("span",{className:"interim",children:fe.interim}),fe.engine==="stream"?" · 流式":"",fe.engine==="server"?` · ${fe.seconds}s`:""]}),ae?o.jsx("button",{className:"dict-stop",onClick:()=>pe.stop(),children:"stop"}):null]}):null,o.jsxs("div",{className:"composer-box",children:[o.jsx("textarea",{ref:Oe,rows:1,value:i,onFocus:()=>f(!1),placeholder:e.resuming?"waking the agent…":e.info.cold?"no ACP process — Enter wakes it":Zr(e)?u:e.info.status==="ready"?l:e.info.status,onChange:P=>{r(P.target.value),f(!1),d(0),x.current?x.current=!1:y.current=null},onCompositionStart:()=>{v.current=!0},onCompositionEnd:()=>{v.current=!1},onKeyDown:P=>{if(!(v.current||P.nativeEvent.isComposing)){if(P.key==="Enter"&&(P.metaKey||P.ctrlKey)&&!P.shiftKey){P.preventDefault(),Ze();return}if(de&&Ye.length){if(P.key==="ArrowDown"){P.preventDefault(),d(le=>(le+1)%Ye.length);return}if(P.key==="ArrowUp"){P.preventDefault(),d(le=>(le-1+Ye.length)%Ye.length);return}if(P.key==="Tab"||P.key==="Enter"&&!P.shiftKey){P.preventDefault(),lt(Ye[h].name);return}if(P.key==="Escape"){P.preventDefault(),r("");return}}if(!Ee(P)){if(P.key==="Escape"&&y.current!==null){P.preventDefault(),y.current=null,r(w.current);return}P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),Ae())}}}}),o.jsxs("div",{className:"composer-bar",ref:_,children:[o.jsx("input",{ref:tt,type:"file",multiple:!0,hidden:!0,accept:`${O_.join(",")},.txt,.md,.json,.log,.csv,.ts,.tsx,.js,.jsx,.py,.rb,.go,.rs,.java,.c,.cpp,.h,.sh,.yaml,.yml,.toml,.ini,.html,.css`,onChange:P=>{const le=P.target.files;le&&le.length?Pe(le):C("选择器没有返回文件 —— 再试一次,或从相册 / 文件管理里选"),P.target.value=""}}),o.jsx("button",{className:"icon-btn",title:"attach an image or a text file","aria-label":"attach",onClick:()=>tt.current?.click(),children:o.jsx(kh,{size:16})}),be&&ge?o.jsxs("div",{className:"tb-wrap",style:{"--effort":ge.color},children:[o.jsxs("button",{type:"button",className:`tb-btn tb-effort ${z==="effort"?"on":""}`,style:{color:ge.level?ge.color:void 0},title:`thinking depth — ${Z||"agent default"}`,"aria-label":`thinking depth: ${Z||"agent default"}`,"aria-expanded":z==="effort","data-testid":"tb-effort",onClick:()=>{D(!1),T(P=>P==="effort"?null:"effort")},children:[o.jsx(EC,{level:ge.level,total:ge.total,color:ge.color}),o.jsx(ya,{size:11,className:"tb-chev"})]}),z==="effort"?o.jsx(Yh,{items:(be.options??[]).map((P,le)=>({value:String(P.value),name:P.name,hint:null,color:Sr[Math.min(le,Sr.length-1)]})),current:String(be.currentValue??""),empty:"the agent advertises no levels",onPick:P=>{ee.send({t:"set-config",sessionId:e.info.id,configId:be.id,value:P}),T(null)}}):null]}):null,o.jsx("button",{className:`icon-btn ${H?"on":""}`,title:"chat settings — permission mode, voice","aria-label":"chat settings","aria-expanded":H,onClick:()=>{T(null),D(P=>!P)},children:o.jsx(Tc,{size:16})}),W.length>0||Be?o.jsx(NC,{label:"model",title:`model — currently ${q||"unknown"}`,icon:o.jsx(t_,{size:15}),value:O?`${q} …`:q,testId:"tb-model",open:z==="model",onToggle:()=>{D(!1),T(P=>P==="model"?null:"model")},children:W.length>0?o.jsx(NS,{models:W,current:Se,usage:a,pending:e.info.pendingModelId??null,bad:J,err:U,onPick:P=>{if(P===Se){T(null);return}K(!0),re(null),ee.setModel(e.info.id,P).then(le=>{le?.models?.currentModelId===P&&IN(e.info.backend,P),T(null),re(null),C("")}).catch(le=>{const je=String(le?.message??le);re({id:P,text:je}),Y(Ie=>({...Ie,[P]:je})),C(`model switch failed: ${je}`)}).finally(()=>K(!1))}}):o.jsx(Yh,{items:(Be?.options??[]).map(P=>({value:String(P.value),name:P.name})),current:String(Be?.currentValue??""),empty:"the agent lists no models",onPick:P=>{Be&&ee.send({t:"set-config",sessionId:e.info.id,configId:Be.id,value:P}),T(null)}})}):null,o.jsx("span",{className:"head-spacer"}),o.jsx("button",{className:`icon-btn ${ae?"on rec":""}`,title:fe.error?fe.error:ae?"stop dictation(或松开 Ctrl)":"dictate a prompt(或按住 Ctrl 说话)","aria-label":"dictate",onClick:()=>{pe.cancel(),pe.start(_e,e.info.id)},children:o.jsx(Ri,{size:16})}),t?o.jsx(Q5,{sessionId:e.info.id,tus:s,pending:e.perms.length,onClose:n,onKeyboard:()=>{n(),window.setTimeout(()=>Oe.current?.focus(),30)},renderTranscript:P=>o.jsx(gC,{...P,notes:e.notes})}):null,Zr(e)?o.jsx("button",{className:"send-btn stop",title:"stop this turn","aria-label":"stop this turn",onClick:()=>ee.send({t:"cancel",sessionId:e.info.id}),children:o.jsx(xh,{size:14})}):o.jsx("button",{className:"send-btn",onClick:Ae,disabled:!i.trim()&&!R.length||e.resuming||!e.info.cold&&e.info.status!=="ready",title:e.resuming?"正在唤醒 agent 进程…":e.info.cold?"唤醒会话 (Enter)":"send (Enter)","aria-label":"send",children:o.jsx(Sh,{size:16})})]})]})]})]})}function zB({backend:e}){const t=vd(e),[s,n]=g.useState(!1);return o.jsx("span",{className:"be-card-mark","data-backend":e,"data-letter":t.letter,children:t.icon&&!s?o.jsx("img",{src:t.icon,alt:"",draggable:!1,onError:()=>n(!0)}):t.letter})}function HB({cwd:e,onClose:t}){Ta(!0,t);const[s,n]=g.useState(""),i=RS(s),[r,a]=g.useState(e??""),l=e??"",[c,u]=g.useState(""),[h,d]=g.useState([]),[p,f]=g.useState(""),[m,b]=g.useState(!1),[_,v]=g.useState(""),[y,w]=g.useState(!0),[x,S]=g.useState([]),[E,R]=g.useState(!1),[N,I]=g.useState(!1),[F,B]=g.useState(null),[C,A]=g.useState(null),[M,H]=g.useState(null),[D,z]=g.useState(null),[T]=go(),O=o_(),K=O.status==="listening"||O.status==="recording"||O.status==="requesting",U=g.useRef(!1),re=g.useRef(null),J=g.useRef(null);g.useEffect(()=>{const W=re.current;W&&(W.style.height="42px",W.style.height=`${Math.min(W.scrollHeight,window.innerHeight*.4)}px`)},[c]);const Y=()=>{w(!0),v(""),Promise.all([ee.loadBackends(),fetch("/api/version",{cache:"no-store"}).then(W=>W.json()).catch(()=>({dev:!1})),fetch("/api/fs/dirs",{cache:"no-store"}).then(W=>W.json()).catch(()=>({}))]).then(([W,Se,He])=>{S(W),R(!!Se?.dev),n(q=>q||yy(W,!!Se?.dev)[0]?.id||""),a(q=>q||He?.home||"")}).catch(W=>v(`后端列表拉取失败:${String(W.message??W)}`)).finally(()=>w(!1))};g.useEffect(Y,[]),g.useLayoutEffect(()=>(pe.setOwner("start"),()=>pe.setOwner("chat")),[]),g.useEffect(()=>{if(!pe.owns("start")||O.status!=="idle"||!O.text)return;const W=pe.consume();W&&(u(Se=>Se.trim()?`${Se.trim()} ${W}`:W),re.current?.focus())},[O.status,O.text]);const _e=yy(x,E),xe=x.find(W=>W.id===s)??null,fe=xe?.handshake??null,et=fe?.configOptions??[],Oe=kc(et,"effort"),tt=Oe?.options??[],Pe=C??String(Oe?.currentValue??""),Le=Oe?CC(Pe,tt):null,Ee=tt.find(W=>String(W.value)===Pe)?.name??"",Ae=fe?.modes?.available??[],Ze=M??fe?.modes?.currentModeId??"",me=Ze?fe?.modes?.names?.[Ze]??Ze:"默认权限",Ye=fe?.models?.available??[],de=F??fe?.models?.currentModelId??"",lt=de?s_(de):"默认模型",ae=()=>{const W=[];return F&&W.push({kind:"model",value:F}),C&&Oe&&W.push({kind:"config",id:String(Oe.id),value:C}),M&&W.push({kind:"mode",value:M}),W},be=async W=>{const Se=Array.from(W);if(!Se.length)return;const He=await Promise.all(Se.map(ge=>xC(ge))),q=[],Z=[];for(const ge of He)"error"in ge?Z.push(ge.error):q.push(ge);q.length&&d(ge=>[...ge,...q]),f(Z.join(" · "))},Be=async()=>{const W=c.trim();if(!(!W&&!h.length||!s||!r.trim())){b(!0),v("");try{K&&pe.stop();const Se=h.map(q=>q.kind==="image"?{kind:"image",mimeType:q.mimeType,data:q.payload,name:q.name}:{kind:"text",name:q.name,text:q.payload}),He=await ee.createSession(s,r.trim(),"");ee.queueSetup(He,ae()),ee.setActive(He),ee.enqueuePrompt(He,W,Se),t()}catch(Se){v(String(Se.message??Se))}finally{b(!1)}}};return o.jsx("div",{className:"modal-bg",onClick:t,children:o.jsxs("div",{className:"modal start-page",onClick:W=>W.stopPropagation(),children:[o.jsxs("div",{className:"start-head",children:[o.jsx("h3",{children:"新建会话"}),o.jsx(iI,{value:l||r,onChange:a,locked:!!l})]}),o.jsx("div",{className:"composer start-composer",onPaste:W=>{const Se=SC(W.clipboardData);Se.length&&(W.preventDefault(),be(Se))},children:o.jsxs("div",{className:"composer-inner",children:[h.length>0&&o.jsxs("div",{className:"draft-row",children:[h.map(W=>o.jsxs("span",{className:`draft ${W.kind}`,title:`${W.name} · ${kC(W.bytes)}`,children:[W.preview?o.jsx("img",{src:W.preview,alt:W.name}):o.jsx(ci,{size:13}),o.jsx("span",{className:"draft-name",children:W.name}),o.jsx("button",{className:"draft-x","aria-label":`remove ${W.name}`,onClick:()=>d(Se=>Se.filter(He=>He.id!==W.id)),children:o.jsx(En,{size:11})})]},W.id)),o.jsx("button",{className:"draft-clear",onClick:()=>d([]),children:"clear"})]}),p&&o.jsx("div",{className:"composer-note err",children:p}),o.jsxs("div",{className:"composer-box",children:[o.jsx("textarea",{ref:re,rows:1,autoFocus:!0,value:c,"aria-label":"first message",placeholder:"say something to start… (Enter sends)",onChange:W=>u(W.target.value),onCompositionStart:()=>{U.current=!0},onCompositionEnd:()=>{U.current=!1},onKeyDown:W=>{U.current||W.nativeEvent.isComposing||W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),Be())}}),o.jsxs("div",{className:"composer-bar",children:[o.jsx("input",{ref:J,type:"file",multiple:!0,hidden:!0,accept:`${O_.join(",")},.txt,.md,.json,.log,.csv,.ts,.tsx,.js,.jsx,.py,.rb,.go,.rs,.java,.c,.cpp,.h,.sh,.yaml,.yml,.toml,.ini,.html,.css`,onChange:W=>{const Se=W.target.files;Se&&Se.length?be(Se):f("选择器没有返回文件 —— 再试一次,或从相册 / 文件管理里选"),W.target.value=""}}),o.jsx("button",{className:"icon-btn",title:"attach an image or a text file","aria-label":"attach",onClick:()=>J.current?.click(),children:o.jsx(kh,{size:16})}),Oe&&tt.length?o.jsxs("div",{className:"tb-wrap",style:{"--effort":Le?.color},children:[o.jsxs("button",{type:"button",className:`tb-btn tb-effort ${D==="effort"?"on":""}`,style:{color:Pe?Le?.color:void 0},title:`thinking depth — ${Ee||"agent default"}`,"aria-label":`thinking depth: ${Ee||"agent default"}`,"aria-expanded":D==="effort","data-testid":"start-effort",onClick:()=>z(W=>W==="effort"?null:"effort"),children:[o.jsx(EC,{level:Le?.level??0,total:Le?.total??1,color:Le?.color??"var(--text-dim)"}),o.jsx(ya,{size:11,className:"tb-chev"})]}),D==="effort"?o.jsx(Yh,{items:tt.map((W,Se)=>({value:String(W.value),name:String(W.name??W.value),hint:null,color:Sr[Math.min(Se,Sr.length-1)]})),current:Pe,empty:"the agent advertises no levels",onPick:W=>{A(W),z(null)}}):null]}):null,Ae.length?o.jsxs("div",{className:"tb-wrap",children:[o.jsxs("button",{type:"button",className:`tb-btn ${D==="mode"?"on":""}`,title:`权限模式 — ${me}`,"aria-label":`permission mode: ${me}`,"aria-expanded":D==="mode","data-testid":"start-mode",onClick:()=>z(W=>W==="mode"?null:"mode"),children:[o.jsx(yS,{size:14}),o.jsx("span",{className:"tb-label",children:me}),o.jsx(ya,{size:11,className:"tb-chev"})]}),D==="mode"?o.jsx(Yh,{items:Ae.map(W=>({value:W,name:fe?.modes?.names?.[W]??W})),current:Ze,empty:"the agent lists no modes",onPick:W=>{H(W),z(null)}}):null]}):null,Ye.length?o.jsx(NC,{label:"model",title:`model — ${lt}`,icon:o.jsx(t_,{size:15}),value:lt,testId:"start-model",open:D==="model",onToggle:()=>z(W=>W==="model"?null:"model"),children:o.jsx(NS,{models:Ye.map(W=>({modelId:W})),current:de,usage:i,onPick:W=>{B(W),z(null)}})}):null,o.jsx("span",{className:"head-spacer"}),o.jsx("button",{className:`icon-btn ${K?"on rec":""}`,title:O.error?O.error:K?"stop dictation(或松开 Ctrl)":"dictate a prompt(或按住 Ctrl 说话)","aria-label":"dictate",onClick:()=>{pe.cancel(),pe.start(T)},children:o.jsx(Ri,{size:16})}),o.jsx("button",{className:"send-btn",onClick:()=>void Be(),disabled:m||!c.trim()&&!h.length||!r.trim(),title:m?"创建中…":"创建并发送 (Enter)","aria-label":"send",children:o.jsx(Sh,{size:16})})]})]}),K||O.status==="transcribing"||O.error?o.jsxs("div",{className:`dict-chip ${O.error?"err":""}`,children:[o.jsx(Ri,{size:13}),O.error?O.error:O.status==="requesting"?"waiting for the microphone…":O.status==="transcribing"?"transcribing…":o.jsxs(o.Fragment,{children:[O.text," ",o.jsx("span",{className:"interim",children:O.interim})]}),K?o.jsx("button",{className:"dict-stop",onClick:()=>pe.stop(),children:"stop"}):null]}):null]})}),o.jsxs("div",{className:"backend-pick",role:"radiogroup","aria-label":"backend",children:[y&&!x.length&&o.jsx("span",{className:"dim",children:"loading…"}),!y&&!_e.length&&o.jsx("span",{className:"dim",children:"no backends"}),_e.map(W=>o.jsxs("button",{type:"button",role:"radio","aria-checked":s===W.id,"data-backend":W.id,title:W.home?`${W.label} · home: ${W.home}`:W.label,className:`be-card ${s===W.id?"sel":""}`,onClick:()=>n(W.id),children:[o.jsx(zB,{backend:W.kind||W.id}),o.jsx("span",{className:"be-card-label",children:W.label})]},W.id)),o.jsx("button",{type:"button",className:"be-card reload",title:"重新拉取后端列表","aria-label":"重新拉取后端列表",onClick:Y,children:"⟳"})]}),(xe?.warnings??[]).map((W,Se)=>o.jsx("div",{className:"hint-warn",children:W},Se)),xe?o.jsxs("div",{className:`be-detail ${N?"open":""}`,children:[o.jsxs("button",{type:"button",className:"be-detail-head","aria-expanded":N,onClick:()=>I(W=>!W),children:[o.jsx(an,{size:12,className:"be-detail-arrow"})," 后端详情"]}),N?o.jsxs("div",{className:"hint be-hint",children:[o.jsxs("div",{children:["runs: ",o.jsxs("code",{children:[xe.cmd," ",(xe.args??[]).join(" ")]}),xe.profile?o.jsxs(o.Fragment,{children:[" · profile ",o.jsx("code",{children:xe.profile})]}):null]}),xe.home?o.jsxs("div",{children:["home: ",o.jsx("code",{children:xe.home})]}):null,xe.cwd?o.jsxs("div",{children:["cwd: ",o.jsx("code",{children:xe.cwd})]}):null,(xe.env??[]).length?o.jsxs("div",{children:["env: ",o.jsx("code",{children:(xe.env??[]).join(", ")})]}):null,fe&&!et.length&&!Ye.length?o.jsx("div",{children:"这个后端还没真跑过,所以没有可选的模型 / 设置 —— 建会话后由 agent 自己的清单决定"}):null]}):null]}):null,_&&o.jsx("div",{className:"err",children:_})]})})}FD();window.__cockpit=ee;window.__voice={dictation:pe,loadVoiceCaps:Ch,resampleToPcm16:$S,voiceCaps:ai};window.__renderMarkdown=__;dS(document.getElementById("root")).render(o.jsx(GC.StrictMode,{children:o.jsx(XO,{})}));