octiqflow-linux-x64 0.1.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/bin/octiq-server +0 -0
- package/bin/v2/apple-touch-icon.png +0 -0
- package/bin/v2/assets/clike-B9uivgTg.js +1 -0
- package/bin/v2/assets/diff-DbItnlRl.js +1 -0
- package/bin/v2/assets/dockerfile-ZL4hHokT.js +1 -0
- package/bin/v2/assets/go-CTD25R5P.js +1 -0
- package/bin/v2/assets/index-B3amz3YD.js +3 -0
- package/bin/v2/assets/index-B6nZyhSd.js +1 -0
- package/bin/v2/assets/index-BJPOH430.js +1 -0
- package/bin/v2/assets/index-BkI_sJNx.js +6 -0
- package/bin/v2/assets/index-C3qkbCLt.js +1 -0
- package/bin/v2/assets/index-CAT3p_Ey.js +1 -0
- package/bin/v2/assets/index-CkSsGSUZ.js +13 -0
- package/bin/v2/assets/index-CrP4aOLs.js +1 -0
- package/bin/v2/assets/index-Czi1vLYr.js +1 -0
- package/bin/v2/assets/index-DecdvRvX.js +1 -0
- package/bin/v2/assets/index-DpgjZUbN.css +1 -0
- package/bin/v2/assets/index-MhXUMNK1.js +291 -0
- package/bin/v2/assets/index-nLNkR2xP.js +2 -0
- package/bin/v2/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/bin/v2/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/bin/v2/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/bin/v2/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/bin/v2/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/bin/v2/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/bin/v2/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/bin/v2/assets/lua-VAEuO923.js +1 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-100-DLPe7tEt.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-101-d3VsZKWT.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-102-ClzJuLq6.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-103-DuDnQ6K-.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-104-kPGW3Eem.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-105-BzD54h-0.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-106-BQ7fIzlx.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-107-D8tDfFHI.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-108-tGhkpwep.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-109-7SMVSrly.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-110-_uDKrFed.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-111-Bio825RE.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-112-D2ee0i-C.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-113-JPFVDrga.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-114-BcfxYA4w.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-115-B1HeeOsd.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-116-hY12tXpq.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-117-BvuZwmre.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-118-tzvs_H7j.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-119-J2DWuYDN.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-21-pDubCJV5.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-22-ChAPMpqp.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-23-BBx3oNpT.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-24-CYt-Oagk.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-25-Cx3j-ZUv.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-26-B9AfZ3LL.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-27-Bh2s9MNE.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-28-C02JPoKP.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-29-T_tbUGhk.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-30-DMfyNzhz.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-31-DFfdzbkg.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-32-Bs1fz2iW.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-33-cpB96OkZ.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-34-BhinPYWX.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-35-D_njRQqA.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-36-DqXlLE3t.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-37-j5LbvMph.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-38-oO4jWdKm.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-39-CabsX4rw.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-4-PatS3YHh.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-40-yrLg3C3e.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-41-DBXmCQhc.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-42-Bqij_UiQ.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-43-D3kp0Ntc.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-44-B_BNGvK4.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-45-CZc0cQWs.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-46-CHQX5Kd9.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-47-Ci8gLrHA.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-48-run3ugD3.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-49-DgfiUb6u.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-5-B0CtGbX_.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-50-CdCG-POr.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-51-L2okeQZ2.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-52-BZAqyGJW.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-53-B0xWqLeU.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-54-BZVQX-EA.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-55-093mkIUJ.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-56-CbhWG8G-.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-57-pLQuvo6c.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-58-BHhoY50x.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-59-D1_6DuIQ.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-6-BnAelmYU.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-60-HDBIuLTZ.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-61-C-c13SeU.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-62-kHRVOhZ2.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-63-C0MCsvFv.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-64-DZekguCj.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-65-CtP6c3IU.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-66-DLVWoMSf.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-67-BVuOnayH.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-68-DpxQ6Mnx.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-69-qesBxLmC.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-70-BBt1xN7h.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-71-BWqZacwB.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-72-B1wP_Yst.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-73-C99T7jNZ.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-74-DrUTsWBe.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-75-C4M5XXQe.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-76-Bq8spVWF.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-77-D9vNupE2.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-78-D6th7Gnu.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-79-bezM85cS.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-80-DD8pnhG2.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-81-N6jtSyBs.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-82-D6c180bZ.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-83-em17AadM.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-84-CJ8gdrMK.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-85-9PPGO1eB.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-86-CjWPf-u5.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-87-8D_X_yOC.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-88-9vtKFPBx.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-89-BhE5jAKX.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-90-D2Npfm5E.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-91-C6Ft1-Eu.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-97-CaExyQP9.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-98-CPoVbsUd.woff2 +0 -0
- package/bin/v2/assets/lxgwwenkaiscreen-subset-99-ZUQZGVgH.woff2 +0 -0
- package/bin/v2/assets/powershell-CFHJl5sT.js +1 -0
- package/bin/v2/assets/properties-C78fOPTZ.js +1 -0
- package/bin/v2/assets/ruby-B2Rjki9n.js +1 -0
- package/bin/v2/assets/shell-CjFT_Tl9.js +1 -0
- package/bin/v2/assets/swift-BzpIVaGY.js +1 -0
- package/bin/v2/assets/toml-Bm5Em-hy.js +1 -0
- package/bin/v2/assets/xml-BQQZnNBQ.js +1 -0
- package/bin/v2/favicon.ico +0 -0
- package/bin/v2/fonts/lxgw-wenkai-screen/LICENSE +21 -0
- package/bin/v2/fonts/lxgw-wenkai-screen/OFL.txt +91 -0
- package/bin/v2/fonts/lxgw-wenkai-screen/README.md +11 -0
- package/bin/v2/icon-192.png +0 -0
- package/bin/v2/icon-32.png +0 -0
- package/bin/v2/icon-512.png +0 -0
- package/bin/v2/index.html +54 -0
- package/bin/v2/manifest.webmanifest +15 -0
- package/bin/v2/sw.js +189 -0
- package/package.json +23 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-CkSsGSUZ.js","./index-CAT3p_Ey.js","./index-B6nZyhSd.js","./index-CrP4aOLs.js","./index-BkI_sJNx.js","./index-BJPOH430.js","./index-DecdvRvX.js","./index-C3qkbCLt.js","./index-B3amz3YD.js","./index-nLNkR2xP.js","./index-Czi1vLYr.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function i(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(s){if(s.ep)return;s.ep=!0;const r=i(s);fetch(s.href,r)}})();function GT(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var _1={exports:{}},Ad={};var r5;function pO(){if(r5)return Ad;r5=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function i(n,s,r){var o=null;if(r!==void 0&&(o=""+r),s.key!==void 0&&(o=""+s.key),"key"in s){r={};for(var a in s)a!=="key"&&(r[a]=s[a])}else r=s;return s=r.ref,{$$typeof:t,type:n,key:o,ref:s!==void 0?s:null,props:r}}return Ad.Fragment=e,Ad.jsx=i,Ad.jsxs=i,Ad}var o5;function mO(){return o5||(o5=1,_1.exports=pO()),_1.exports}var d=mO(),y1={exports:{}},ut={};var l5;function gO(){if(l5)return ut;l5=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),r=Symbol.for("react.consumer"),o=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),v=Symbol.iterator;function _($){return $===null||typeof $!="object"?null:($=v&&$[v]||$["@@iterator"],typeof $=="function"?$:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,C={};function k($,Y,B){this.props=$,this.context=Y,this.refs=C,this.updater=B||x}k.prototype.isReactComponent={},k.prototype.setState=function($,Y){if(typeof $!="object"&&typeof $!="function"&&$!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,$,Y,"setState")},k.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function M(){}M.prototype=k.prototype;function L($,Y,B){this.props=$,this.context=Y,this.refs=C,this.updater=B||x}var N=L.prototype=new M;N.constructor=L,S(N,k.prototype),N.isPureReactComponent=!0;var j=Array.isArray;function R(){}var z={H:null,A:null,T:null,S:null},J=Object.prototype.hasOwnProperty;function G($,Y,B){var ee=B.ref;return{$$typeof:t,type:$,key:Y,ref:ee!==void 0?ee:null,props:B}}function q($,Y){return G($.type,Y,$.props)}function X($){return typeof $=="object"&&$!==null&&$.$$typeof===t}function I($){var Y={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(B){return Y[B]})}var T=/\/+/g;function H($,Y){return typeof $=="object"&&$!==null&&$.key!=null?I(""+$.key):Y.toString(36)}function F($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(R,R):($.status="pending",$.then(function(Y){$.status==="pending"&&($.status="fulfilled",$.value=Y)},function(Y){$.status==="pending"&&($.status="rejected",$.reason=Y)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function P($,Y,B,ee,ie){var re=typeof $;(re==="undefined"||re==="boolean")&&($=null);var ge=!1;if($===null)ge=!0;else switch(re){case"bigint":case"string":case"number":ge=!0;break;case"object":switch($.$$typeof){case t:case e:ge=!0;break;case p:return ge=$._init,P(ge($._payload),Y,B,ee,ie)}}if(ge)return ie=ie($),ge=ee===""?"."+H($,0):ee,j(ie)?(B="",ge!=null&&(B=ge.replace(T,"$&/")+"/"),P(ie,Y,B,"",function(Pe){return Pe})):ie!=null&&(X(ie)&&(ie=q(ie,B+(ie.key==null||$&&$.key===ie.key?"":(""+ie.key).replace(T,"$&/")+"/")+ge)),Y.push(ie)),1;ge=0;var Ee=ee===""?".":ee+":";if(j($))for(var fe=0;fe<$.length;fe++)ee=$[fe],re=Ee+H(ee,fe),ge+=P(ee,Y,B,re,ie);else if(fe=_($),typeof fe=="function")for($=fe.call($),fe=0;!(ee=$.next()).done;)ee=ee.value,re=Ee+H(ee,fe++),ge+=P(ee,Y,B,re,ie);else if(re==="object"){if(typeof $.then=="function")return P(F($),Y,B,ee,ie);throw Y=String($),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return ge}function U($,Y,B){if($==null)return $;var ee=[],ie=0;return P($,ee,"","",function(re){return Y.call(B,re,ie++)}),ee}function V($){if($._status===-1){var Y=$._result;Y=Y(),Y.then(function(B){($._status===0||$._status===-1)&&($._status=1,$._result=B)},function(B){($._status===0||$._status===-1)&&($._status=2,$._result=B)}),$._status===-1&&($._status=0,$._result=Y)}if($._status===1)return $._result.default;throw $._result}var K=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},D={map:U,forEach:function($,Y,B){U($,function(){Y.apply(this,arguments)},B)},count:function($){var Y=0;return U($,function(){Y++}),Y},toArray:function($){return U($,function(Y){return Y})||[]},only:function($){if(!X($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return ut.Activity=m,ut.Children=D,ut.Component=k,ut.Fragment=i,ut.Profiler=s,ut.PureComponent=L,ut.StrictMode=n,ut.Suspense=u,ut.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=z,ut.__COMPILER_RUNTIME={__proto__:null,c:function($){return z.H.useMemoCache($)}},ut.cache=function($){return function(){return $.apply(null,arguments)}},ut.cacheSignal=function(){return null},ut.cloneElement=function($,Y,B){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var ee=S({},$.props),ie=$.key;if(Y!=null)for(re in Y.key!==void 0&&(ie=""+Y.key),Y)!J.call(Y,re)||re==="key"||re==="__self"||re==="__source"||re==="ref"&&Y.ref===void 0||(ee[re]=Y[re]);var re=arguments.length-2;if(re===1)ee.children=B;else if(1<re){for(var ge=Array(re),Ee=0;Ee<re;Ee++)ge[Ee]=arguments[Ee+2];ee.children=ge}return G($.type,ie,ee)},ut.createContext=function($){return $={$$typeof:o,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null},$.Provider=$,$.Consumer={$$typeof:r,_context:$},$},ut.createElement=function($,Y,B){var ee,ie={},re=null;if(Y!=null)for(ee in Y.key!==void 0&&(re=""+Y.key),Y)J.call(Y,ee)&&ee!=="key"&&ee!=="__self"&&ee!=="__source"&&(ie[ee]=Y[ee]);var ge=arguments.length-2;if(ge===1)ie.children=B;else if(1<ge){for(var Ee=Array(ge),fe=0;fe<ge;fe++)Ee[fe]=arguments[fe+2];ie.children=Ee}if($&&$.defaultProps)for(ee in ge=$.defaultProps,ge)ie[ee]===void 0&&(ie[ee]=ge[ee]);return G($,re,ie)},ut.createRef=function(){return{current:null}},ut.forwardRef=function($){return{$$typeof:a,render:$}},ut.isValidElement=X,ut.lazy=function($){return{$$typeof:p,_payload:{_status:-1,_result:$},_init:V}},ut.memo=function($,Y){return{$$typeof:h,type:$,compare:Y===void 0?null:Y}},ut.startTransition=function($){var Y=z.T,B={};z.T=B;try{var ee=$(),ie=z.S;ie!==null&&ie(B,ee),typeof ee=="object"&&ee!==null&&typeof ee.then=="function"&&ee.then(R,K)}catch(re){K(re)}finally{Y!==null&&B.types!==null&&(Y.types=B.types),z.T=Y}},ut.unstable_useCacheRefresh=function(){return z.H.useCacheRefresh()},ut.use=function($){return z.H.use($)},ut.useActionState=function($,Y,B){return z.H.useActionState($,Y,B)},ut.useCallback=function($,Y){return z.H.useCallback($,Y)},ut.useContext=function($){return z.H.useContext($)},ut.useDebugValue=function(){},ut.useDeferredValue=function($,Y){return z.H.useDeferredValue($,Y)},ut.useEffect=function($,Y){return z.H.useEffect($,Y)},ut.useEffectEvent=function($){return z.H.useEffectEvent($)},ut.useId=function(){return z.H.useId()},ut.useImperativeHandle=function($,Y,B){return z.H.useImperativeHandle($,Y,B)},ut.useInsertionEffect=function($,Y){return z.H.useInsertionEffect($,Y)},ut.useLayoutEffect=function($,Y){return z.H.useLayoutEffect($,Y)},ut.useMemo=function($,Y){return z.H.useMemo($,Y)},ut.useOptimistic=function($,Y){return z.H.useOptimistic($,Y)},ut.useReducer=function($,Y,B){return z.H.useReducer($,Y,B)},ut.useRef=function($){return z.H.useRef($)},ut.useState=function($){return z.H.useState($)},ut.useSyncExternalStore=function($,Y,B){return z.H.useSyncExternalStore($,Y,B)},ut.useTransition=function(){return z.H.useTransition()},ut.version="19.2.8",ut}var a5;function yw(){return a5||(a5=1,y1.exports=gO()),y1.exports}var w=yw(),x1={exports:{}},Ld={},b1={exports:{}},w1={};var c5;function vO(){return c5||(c5=1,(function(t){function e(P,U){var V=P.length;P.push(U);e:for(;0<V;){var K=V-1>>>1,D=P[K];if(0<s(D,U))P[K]=U,P[V]=D,V=K;else break e}}function i(P){return P.length===0?null:P[0]}function n(P){if(P.length===0)return null;var U=P[0],V=P.pop();if(V!==U){P[0]=V;e:for(var K=0,D=P.length,$=D>>>1;K<$;){var Y=2*(K+1)-1,B=P[Y],ee=Y+1,ie=P[ee];if(0>s(B,V))ee<D&&0>s(ie,B)?(P[K]=ie,P[ee]=V,K=ee):(P[K]=B,P[Y]=V,K=Y);else if(ee<D&&0>s(ie,V))P[K]=ie,P[ee]=V,K=ee;else break e}}return U}function s(P,U){var V=P.sortIndex-U.sortIndex;return V!==0?V:P.id-U.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var r=performance;t.unstable_now=function(){return r.now()}}else{var o=Date,a=o.now();t.unstable_now=function(){return o.now()-a}}var u=[],h=[],p=1,m=null,v=3,_=!1,x=!1,S=!1,C=!1,k=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function N(P){for(var U=i(h);U!==null;){if(U.callback===null)n(h);else if(U.startTime<=P)n(h),U.sortIndex=U.expirationTime,e(u,U);else break;U=i(h)}}function j(P){if(S=!1,N(P),!x)if(i(u)!==null)x=!0,R||(R=!0,I());else{var U=i(h);U!==null&&F(j,U.startTime-P)}}var R=!1,z=-1,J=5,G=-1;function q(){return C?!0:!(t.unstable_now()-G<J)}function X(){if(C=!1,R){var P=t.unstable_now();G=P;var U=!0;try{e:{x=!1,S&&(S=!1,M(z),z=-1),_=!0;var V=v;try{t:{for(N(P),m=i(u);m!==null&&!(m.expirationTime>P&&q());){var K=m.callback;if(typeof K=="function"){m.callback=null,v=m.priorityLevel;var D=K(m.expirationTime<=P);if(P=t.unstable_now(),typeof D=="function"){m.callback=D,N(P),U=!0;break t}m===i(u)&&n(u),N(P)}else n(u);m=i(u)}if(m!==null)U=!0;else{var $=i(h);$!==null&&F(j,$.startTime-P),U=!1}}break e}finally{m=null,v=V,_=!1}U=void 0}}finally{U?I():R=!1}}}var I;if(typeof L=="function")I=function(){L(X)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,H=T.port2;T.port1.onmessage=X,I=function(){H.postMessage(null)}}else I=function(){k(X,0)};function F(P,U){z=k(function(){P(t.unstable_now())},U)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(P){P.callback=null},t.unstable_forceFrameRate=function(P){0>P||125<P?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):J=0<P?Math.floor(1e3/P):5},t.unstable_getCurrentPriorityLevel=function(){return v},t.unstable_next=function(P){switch(v){case 1:case 2:case 3:var U=3;break;default:U=v}var V=v;v=U;try{return P()}finally{v=V}},t.unstable_requestPaint=function(){C=!0},t.unstable_runWithPriority=function(P,U){switch(P){case 1:case 2:case 3:case 4:case 5:break;default:P=3}var V=v;v=P;try{return U()}finally{v=V}},t.unstable_scheduleCallback=function(P,U,V){var K=t.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0<V?K+V:K):V=K,P){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=V+D,P={id:p++,callback:U,priorityLevel:P,startTime:V,expirationTime:D,sortIndex:-1},V>K?(P.sortIndex=V,e(h,P),i(u)===null&&P===i(h)&&(S?(M(z),z=-1):S=!0,F(j,V-K))):(P.sortIndex=D,e(u,P),x||_||(x=!0,R||(R=!0,I()))),P},t.unstable_shouldYield=q,t.unstable_wrapCallback=function(P){var U=v;return function(){var V=v;v=U;try{return P.apply(this,arguments)}finally{v=V}}}})(w1)),w1}var u5;function _O(){return u5||(u5=1,b1.exports=vO()),b1.exports}var S1={exports:{}},Vn={};var h5;function yO(){if(h5)return Vn;h5=1;var t=yw();function e(u){var h="https://react.dev/errors/"+u;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)h+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+u+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(){}var n={d:{f:i,r:function(){throw Error(e(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},s=Symbol.for("react.portal");function r(u,h,p){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:m==null?null:""+m,children:u,containerInfo:h,implementation:p}}var o=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function a(u,h){if(u==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Vn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=n,Vn.createPortal=function(u,h){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(e(299));return r(u,h,null,p)},Vn.flushSync=function(u){var h=o.T,p=n.p;try{if(o.T=null,n.p=2,u)return u()}finally{o.T=h,n.p=p,n.d.f()}},Vn.preconnect=function(u,h){typeof u=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,n.d.C(u,h))},Vn.prefetchDNS=function(u){typeof u=="string"&&n.d.D(u)},Vn.preinit=function(u,h){if(typeof u=="string"&&h&&typeof h.as=="string"){var p=h.as,m=a(p,h.crossOrigin),v=typeof h.integrity=="string"?h.integrity:void 0,_=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;p==="style"?n.d.S(u,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:m,integrity:v,fetchPriority:_}):p==="script"&&n.d.X(u,{crossOrigin:m,integrity:v,fetchPriority:_,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Vn.preinitModule=function(u,h){if(typeof u=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var p=a(h.as,h.crossOrigin);n.d.M(u,{crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&n.d.M(u)},Vn.preload=function(u,h){if(typeof u=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var p=h.as,m=a(p,h.crossOrigin);n.d.L(u,p,{crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Vn.preloadModule=function(u,h){if(typeof u=="string")if(h){var p=a(h.as,h.crossOrigin);n.d.m(u,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else n.d.m(u)},Vn.requestFormReset=function(u){n.d.r(u)},Vn.unstable_batchedUpdates=function(u,h){return u(h)},Vn.useFormState=function(u,h,p){return o.H.useFormState(u,h,p)},Vn.useFormStatus=function(){return o.H.useHostTransitionStatus()},Vn.version="19.2.8",Vn}var d5;function QT(){if(d5)return S1.exports;d5=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),S1.exports=yO(),S1.exports}var f5;function xO(){if(f5)return Ld;f5=1;var t=_O(),e=yw(),i=QT();function n(l){var c="https://react.dev/errors/"+l;if(1<arguments.length){c+="?args[]="+encodeURIComponent(arguments[1]);for(var f=2;f<arguments.length;f++)c+="&args[]="+encodeURIComponent(arguments[f])}return"Minified React error #"+l+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function r(l){var c=l,f=l;if(l.alternate)for(;c.return;)c=c.return;else{l=c;do c=l,(c.flags&4098)!==0&&(f=c.return),l=c.return;while(l)}return c.tag===3?f:null}function o(l){if(l.tag===13){var c=l.memoizedState;if(c===null&&(l=l.alternate,l!==null&&(c=l.memoizedState)),c!==null)return c.dehydrated}return null}function a(l){if(l.tag===31){var c=l.memoizedState;if(c===null&&(l=l.alternate,l!==null&&(c=l.memoizedState)),c!==null)return c.dehydrated}return null}function u(l){if(r(l)!==l)throw Error(n(188))}function h(l){var c=l.alternate;if(!c){if(c=r(l),c===null)throw Error(n(188));return c!==l?null:l}for(var f=l,g=c;;){var y=f.return;if(y===null)break;var b=y.alternate;if(b===null){if(g=y.return,g!==null){f=g;continue}break}if(y.child===b.child){for(b=y.child;b;){if(b===f)return u(y),l;if(b===g)return u(y),c;b=b.sibling}throw Error(n(188))}if(f.return!==g.return)f=y,g=b;else{for(var E=!1,O=y.child;O;){if(O===f){E=!0,f=y,g=b;break}if(O===g){E=!0,g=y,f=b;break}O=O.sibling}if(!E){for(O=b.child;O;){if(O===f){E=!0,f=b,g=y;break}if(O===g){E=!0,g=b,f=y;break}O=O.sibling}if(!E)throw Error(n(189))}}if(f.alternate!==g)throw Error(n(190))}if(f.tag!==3)throw Error(n(188));return f.stateNode.current===f?l:c}function p(l){var c=l.tag;if(c===5||c===26||c===27||c===6)return l;for(l=l.child;l!==null;){if(c=p(l),c!==null)return c;l=l.sibling}return null}var m=Object.assign,v=Symbol.for("react.element"),_=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),L=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),G=Symbol.for("react.activity"),q=Symbol.for("react.memo_cache_sentinel"),X=Symbol.iterator;function I(l){return l===null||typeof l!="object"?null:(l=X&&l[X]||l["@@iterator"],typeof l=="function"?l:null)}var T=Symbol.for("react.client.reference");function H(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===T?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case S:return"Fragment";case k:return"Profiler";case C:return"StrictMode";case j:return"Suspense";case R:return"SuspenseList";case G:return"Activity"}if(typeof l=="object")switch(l.$$typeof){case x:return"Portal";case L:return l.displayName||"Context";case M:return(l._context.displayName||"Context")+".Consumer";case N:var c=l.render;return l=l.displayName,l||(l=c.displayName||c.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case z:return c=l.displayName||null,c!==null?c:H(l.type)||"Memo";case J:c=l._payload,l=l._init;try{return H(l(c))}catch{}}return null}var F=Array.isArray,P=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V={pending:!1,data:null,method:null,action:null},K=[],D=-1;function $(l){return{current:l}}function Y(l){0>D||(l.current=K[D],K[D]=null,D--)}function B(l,c){D++,K[D]=l.current,l.current=c}var ee=$(null),ie=$(null),re=$(null),ge=$(null);function Ee(l,c){switch(B(re,c),B(ie,l),B(ee,null),c.nodeType){case 9:case 11:l=(l=c.documentElement)&&(l=l.namespaceURI)?A2(l):0;break;default:if(l=c.tagName,c=c.namespaceURI)c=A2(c),l=L2(c,l);else switch(l){case"svg":l=1;break;case"math":l=2;break;default:l=0}}Y(ee),B(ee,l)}function fe(){Y(ee),Y(ie),Y(re)}function Pe(l){l.memoizedState!==null&&B(ge,l);var c=ee.current,f=L2(c,l.type);c!==f&&(B(ie,l),B(ee,f))}function De(l){ie.current===l&&(Y(ee),Y(ie)),ge.current===l&&(Y(ge),kd._currentValue=V)}var He,_e;function Le(l){if(He===void 0)try{throw Error()}catch(f){var c=f.stack.trim().match(/\n( *(at )?)/);He=c&&c[1]||"",_e=-1<f.stack.indexOf(`
|
|
3
|
+
at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
+
`+He+l+_e}var jt=!1;function di(l,c){if(!l||jt)return"";jt=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var g={DetermineComponentFrameRoot:function(){try{if(c){var xe=function(){throw Error()};if(Object.defineProperty(xe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(xe,[])}catch(ue){var ce=ue}Reflect.construct(l,[],xe)}else{try{xe.call()}catch(ue){ce=ue}l.call(xe.prototype)}}else{try{throw Error()}catch(ue){ce=ue}(xe=l())&&typeof xe.catch=="function"&&xe.catch(function(){})}}catch(ue){if(ue&&ce&&typeof ue.stack=="string")return[ue.stack,ce.stack]}return[null,null]}};g.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var y=Object.getOwnPropertyDescriptor(g.DetermineComponentFrameRoot,"name");y&&y.configurable&&Object.defineProperty(g.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var b=g.DetermineComponentFrameRoot(),E=b[0],O=b[1];if(E&&O){var Q=E.split(`
|
|
5
|
+
`),le=O.split(`
|
|
6
|
+
`);for(y=g=0;g<Q.length&&!Q[g].includes("DetermineComponentFrameRoot");)g++;for(;y<le.length&&!le[y].includes("DetermineComponentFrameRoot");)y++;if(g===Q.length||y===le.length)for(g=Q.length-1,y=le.length-1;1<=g&&0<=y&&Q[g]!==le[y];)y--;for(;1<=g&&0<=y;g--,y--)if(Q[g]!==le[y]){if(g!==1||y!==1)do if(g--,y--,0>y||Q[g]!==le[y]){var me=`
|
|
7
|
+
`+Q[g].replace(" at new "," at ");return l.displayName&&me.includes("<anonymous>")&&(me=me.replace("<anonymous>",l.displayName)),me}while(1<=g&&0<=y);break}}}finally{jt=!1,Error.prepareStackTrace=f}return(f=l?l.displayName||l.name:"")?Le(f):""}function xt(l,c){switch(l.tag){case 26:case 27:case 5:return Le(l.type);case 16:return Le("Lazy");case 13:return l.child!==c&&c!==null?Le("Suspense Fallback"):Le("Suspense");case 19:return Le("SuspenseList");case 0:case 15:return di(l.type,!1);case 11:return di(l.type.render,!1);case 1:return di(l.type,!0);case 31:return Le("Activity");default:return""}}function be(l){try{var c="",f=null;do c+=xt(l,f),f=l,l=l.return;while(l);return c}catch(g){return`
|
|
8
|
+
Error generating stack: `+g.message+`
|
|
9
|
+
`+g.stack}}var We=Object.prototype.hasOwnProperty,Ze=t.unstable_scheduleCallback,ve=t.unstable_cancelCallback,fi=t.unstable_shouldYield,Mt=t.unstable_requestPaint,Kt=t.unstable_now,gn=t.unstable_getCurrentPriorityLevel,de=t.unstable_ImmediatePriority,Me=t.unstable_UserBlockingPriority,Ke=t.unstable_NormalPriority,Je=t.unstable_LowPriority,ot=t.unstable_IdlePriority,Gt=t.log,wt=t.unstable_setDisableYieldValue,pt=null,Ht=null;function gi(l){if(typeof Gt=="function"&&wt(l),Ht&&typeof Ht.setStrictMode=="function")try{Ht.setStrictMode(pt,l)}catch{}}var Tt=Math.clz32?Math.clz32:vs,vi=Math.log,Qt=Math.LN2;function vs(l){return l>>>=0,l===0?32:31-(vi(l)/Qt|0)|0}var lr=256,st=262144,Yt=4194304;function Gi(l){var c=l&42;if(c!==0)return c;switch(l&-l){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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return l&261888;case 262144:case 524288:case 1048576:case 2097152:return l&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function Ds(l,c,f){var g=l.pendingLanes;if(g===0)return 0;var y=0,b=l.suspendedLanes,E=l.pingedLanes;l=l.warmLanes;var O=g&134217727;return O!==0?(g=O&~b,g!==0?y=Gi(g):(E&=O,E!==0?y=Gi(E):f||(f=O&~l,f!==0&&(y=Gi(f))))):(O=g&~b,O!==0?y=Gi(O):E!==0?y=Gi(E):f||(f=g&~l,f!==0&&(y=Gi(f)))),y===0?0:c!==0&&c!==y&&(c&b)===0&&(b=y&-y,f=c&-c,b>=f||b===32&&(f&4194048)!==0)?c:y}function to(l,c){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&c)===0}function Bs(l,c){switch(l){case 1:case 2:case 4:case 8:case 64:return c+250;case 16:case 32: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 c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function _s(){var l=Yt;return Yt<<=1,(Yt&62914560)===0&&(Yt=4194304),l}function ys(l){for(var c=[],f=0;31>f;f++)c.push(l);return c}function zr(l,c){l.pendingLanes|=c,c!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function io(l,c,f,g,y,b){var E=l.pendingLanes;l.pendingLanes=f,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=f,l.entangledLanes&=f,l.errorRecoveryDisabledLanes&=f,l.shellSuspendCounter=0;var O=l.entanglements,Q=l.expirationTimes,le=l.hiddenUpdates;for(f=E&~f;0<f;){var me=31-Tt(f),xe=1<<me;O[me]=0,Q[me]=-1;var ce=le[me];if(ce!==null)for(le[me]=null,me=0;me<ce.length;me++){var ue=ce[me];ue!==null&&(ue.lane&=-536870913)}f&=~xe}g!==0&&ar(l,g,0),b!==0&&y===0&&l.tag!==0&&(l.suspendedLanes|=b&~(E&~c))}function ar(l,c,f){l.pendingLanes|=c,l.suspendedLanes&=~c;var g=31-Tt(c);l.entangledLanes|=c,l.entanglements[g]=l.entanglements[g]|1073741824|f&261930}function Al(l,c){var f=l.entangledLanes|=c;for(l=l.entanglements;f;){var g=31-Tt(f),y=1<<g;y&c|l[g]&c&&(l[g]|=c),f&=~y}}function Ll(l,c){var f=c&-c;return f=(f&42)!==0?1:Os(f),(f&(l.suspendedLanes|c))!==0?0:f}function Os(l){switch(l){case 2:l=1;break;case 8:l=4;break;case 32:l=16;break;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:l=128;break;case 268435456:l=134217728;break;default:l=0}return l}function $r(l){return l&=-l,2<l?8<l?(l&134217727)!==0?32:268435456:8:2}function xs(){var l=U.p;return l!==0?l:(l=window.event,l===void 0?32:Z2(l.type))}function Io(l,c){var f=U.p;try{return U.p=l,c()}finally{U.p=f}}var _i=Math.random().toString(36).slice(2),Ni="__reactFiber$"+_i,ht="__reactProps$"+_i,Fn="__reactContainer$"+_i,$i="__reactEvents$"+_i,Is="__reactListeners$"+_i,bs="__reactHandles$"+_i,Po="__reactResources$"+_i,on="__reactMarker$"+_i;function Ia(l){delete l[Ni],delete l[ht],delete l[$i],delete l[Is],delete l[bs]}function no(l){var c=l[Ni];if(c)return c;for(var f=l.parentNode;f;){if(c=f[Fn]||f[Ni]){if(f=c.alternate,c.child!==null||f!==null&&f.child!==null)for(l=O2(l);l!==null;){if(f=l[Ni])return f;l=O2(l)}return c}l=f,f=l.parentNode}return null}function Hn(l){if(l=l[Ni]||l[Fn]){var c=l.tag;if(c===5||c===6||c===13||c===31||c===26||c===27||c===3)return l}return null}function Fr(l){var c=l.tag;if(c===5||c===26||c===27||c===6)return l.stateNode;throw Error(n(33))}function Ps(l){var c=l[Po];return c||(c=l[Po]={hoistableStyles:new Map,hoistableScripts:new Map}),c}function pi(l){l[on]=!0}var Ci=new Set,cr={};function es(l,c){ln(l,c),ln(l+"Capture",c)}function ln(l,c){for(cr[l]=c,l=0;l<c.length;l++)Ci.add(c[l])}var ae=RegExp("^[: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]*$"),ze={},it={};function Bt(l){return We.call(it,l)?!0:We.call(ze,l)?!1:ae.test(l)?it[l]=!0:(ze[l]=!0,!1)}function Xt(l,c,f){if(Bt(c))if(f===null)l.removeAttribute(c);else{switch(typeof f){case"undefined":case"function":case"symbol":l.removeAttribute(c);return;case"boolean":var g=c.toLowerCase().slice(0,5);if(g!=="data-"&&g!=="aria-"){l.removeAttribute(c);return}}l.setAttribute(c,""+f)}}function Wn(l,c,f){if(f===null)l.removeAttribute(c);else{switch(typeof f){case"undefined":case"function":case"symbol":case"boolean":l.removeAttribute(c);return}l.setAttribute(c,""+f)}}function Pt(l,c,f,g){if(g===null)l.removeAttribute(f);else{switch(typeof g){case"undefined":case"function":case"symbol":case"boolean":l.removeAttribute(f);return}l.setAttributeNS(c,f,""+g)}}function yi(l){switch(typeof l){case"bigint":case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function zs(l){var c=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function ws(l,c,f){var g=Object.getOwnPropertyDescriptor(l.constructor.prototype,c);if(!l.hasOwnProperty(c)&&typeof g<"u"&&typeof g.get=="function"&&typeof g.set=="function"){var y=g.get,b=g.set;return Object.defineProperty(l,c,{configurable:!0,get:function(){return y.call(this)},set:function(E){f=""+E,b.call(this,E)}}),Object.defineProperty(l,c,{enumerable:g.enumerable}),{getValue:function(){return f},setValue:function(E){f=""+E},stopTracking:function(){l._valueTracker=null,delete l[c]}}}}function Uc(l){if(!l._valueTracker){var c=zs(l)?"checked":"value";l._valueTracker=ws(l,c,""+l[c])}}function Dh(l){if(!l)return!1;var c=l._valueTracker;if(!c)return!0;var f=c.getValue(),g="";return l&&(g=zs(l)?l.checked?"true":"false":l.value),l=g,l!==f?(c.setValue(l),!0):!1}function an(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}var $s=/[\n"\\]/g;function Tn(l){return l.replace($s,function(c){return"\\"+c.charCodeAt(0).toString(16)+" "})}function ur(l,c,f,g,y,b,E,O){l.name="",E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?l.type=E:l.removeAttribute("type"),c!=null?E==="number"?(c===0&&l.value===""||l.value!=c)&&(l.value=""+yi(c)):l.value!==""+yi(c)&&(l.value=""+yi(c)):E!=="submit"&&E!=="reset"||l.removeAttribute("value"),c!=null?Vc(l,E,yi(c)):f!=null?Vc(l,E,yi(f)):g!=null&&l.removeAttribute("value"),y==null&&b!=null&&(l.defaultChecked=!!b),y!=null&&(l.checked=y&&typeof y!="function"&&typeof y!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?l.name=""+yi(O):l.removeAttribute("name")}function ap(l,c,f,g,y,b,E,O){if(b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(l.type=b),c!=null||f!=null){if(!(b!=="submit"&&b!=="reset"||c!=null)){Uc(l);return}f=f!=null?""+yi(f):"",c=c!=null?""+yi(c):f,O||c===l.value||(l.value=c),l.defaultValue=c}g=g??y,g=typeof g!="function"&&typeof g!="symbol"&&!!g,l.checked=O?l.checked:!!g,l.defaultChecked=!!g,E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"&&(l.name=E),Uc(l)}function Vc(l,c,f){c==="number"&&an(l.ownerDocument)===l||l.defaultValue===""+f||(l.defaultValue=""+f)}function so(l,c,f,g){if(l=l.options,c){c={};for(var y=0;y<f.length;y++)c["$"+f[y]]=!0;for(f=0;f<l.length;f++)y=c.hasOwnProperty("$"+l[f].value),l[f].selected!==y&&(l[f].selected=y),y&&g&&(l[f].defaultSelected=!0)}else{for(f=""+yi(f),c=null,y=0;y<l.length;y++){if(l[y].value===f){l[y].selected=!0,g&&(l[y].defaultSelected=!0);return}c!==null||l[y].disabled||(c=l[y])}c!==null&&(c.selected=!0)}}function Kc(l,c,f){if(c!=null&&(c=""+yi(c),c!==l.value&&(l.value=c),f==null)){l.defaultValue!==c&&(l.defaultValue=c);return}l.defaultValue=f!=null?""+yi(f):""}function cp(l,c,f,g){if(c==null){if(g!=null){if(f!=null)throw Error(n(92));if(F(g)){if(1<g.length)throw Error(n(93));g=g[0]}f=g}f==null&&(f=""),c=f}f=yi(c),l.defaultValue=f,g=l.textContent,g===f&&g!==""&&g!==null&&(l.value=g),Uc(l)}function zo(l,c){if(c){var f=l.firstChild;if(f&&f===l.lastChild&&f.nodeType===3){f.nodeValue=c;return}}l.textContent=c}var up=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Pa(l,c,f){var g=c.indexOf("--")===0;f==null||typeof f=="boolean"||f===""?g?l.setProperty(c,""):c==="float"?l.cssFloat="":l[c]="":g?l.setProperty(c,f):typeof f!="number"||f===0||up.has(c)?c==="float"?l.cssFloat=f:l[c]=(""+f).trim():l[c]=f+"px"}function $o(l,c,f){if(c!=null&&typeof c!="object")throw Error(n(62));if(l=l.style,f!=null){for(var g in f)!f.hasOwnProperty(g)||c!=null&&c.hasOwnProperty(g)||(g.indexOf("--")===0?l.setProperty(g,""):g==="float"?l.cssFloat="":l[g]="");for(var y in c)g=c[y],c.hasOwnProperty(y)&&f[y]!==g&&Pa(l,y,g)}else for(var b in c)c.hasOwnProperty(b)&&Pa(l,b,c[b])}function hr(l){if(l.indexOf("-")===-1)return!1;switch(l){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 hp=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Yc=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Gc(l){return Yc.test(""+l)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":l}function Nn(){}var Qc=null;function Xc(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var Fs=null,Hr=null;function Bh(l){var c=Hn(l);if(c&&(l=c.stateNode)){var f=l[ht]||null;e:switch(l=c.stateNode,c.type){case"input":if(ur(l,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name),c=f.name,f.type==="radio"&&c!=null){for(f=l;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll('input[name="'+Tn(""+c)+'"][type="radio"]'),c=0;c<f.length;c++){var g=f[c];if(g!==l&&g.form===l.form){var y=g[ht]||null;if(!y)throw Error(n(90));ur(g,y.value,y.defaultValue,y.defaultValue,y.checked,y.defaultChecked,y.type,y.name)}}for(c=0;c<f.length;c++)g=f[c],g.form===l.form&&Dh(g)}break e;case"textarea":Kc(l,f.value,f.defaultValue);break e;case"select":c=f.value,c!=null&&so(l,!!f.multiple,c,!1)}}}var mt=!1;function dp(l,c,f){if(mt)return l(c,f);mt=!0;try{var g=l(c);return g}finally{if(mt=!1,(Fs!==null||Hr!==null)&&(um(),Fs&&(c=Fs,l=Hr,Hr=Fs=null,Bh(c),l)))for(c=0;c<l.length;c++)Bh(l[c])}}function Fo(l,c){var f=l.stateNode;if(f===null)return null;var g=f[ht]||null;if(g===null)return null;f=g[c];e:switch(c){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(g=!g.disabled)||(l=l.type,g=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!g;break e;default:l=!1}if(l)return null;if(f&&typeof f!="function")throw Error(n(231,c,typeof f));return f}var Hs=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Tl=!1;if(Hs)try{var za={};Object.defineProperty(za,"passive",{get:function(){Tl=!0}}),window.addEventListener("test",za,za),window.removeEventListener("test",za,za)}catch{Tl=!1}var cn=null,Oh=null,Zc=null;function Ih(){if(Zc)return Zc;var l,c=Oh,f=c.length,g,y="value"in cn?cn.value:cn.textContent,b=y.length;for(l=0;l<f&&c[l]===y[l];l++);var E=f-l;for(g=1;g<=E&&c[f-g]===y[b-g];g++);return Zc=y.slice(l,1<g?1-g:void 0)}function Nl(l){var c=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&c===13&&(l=13)):l=c,l===10&&(l=13),32<=l||l===13?l:0}function jl(){return!0}function fp(){return!1}function vn(l){function c(f,g,y,b,E){this._reactName=f,this._targetInst=y,this.type=g,this.nativeEvent=b,this.target=E,this.currentTarget=null;for(var O in l)l.hasOwnProperty(O)&&(f=l[O],this[O]=f?f(b):b[O]);return this.isDefaultPrevented=(b.defaultPrevented!=null?b.defaultPrevented:b.returnValue===!1)?jl:fp,this.isPropagationStopped=fp,this}return m(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=jl)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=jl)},persist:function(){},isPersistent:jl}),c}var gt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},$a=vn(gt),Fa=m({},gt,{view:0,detail:0}),bv=vn(Fa),Qe,Wr,qn,qr=m({},Fa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pr,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==qn&&(qn&&l.type==="mousemove"?(Qe=l.screenX-qn.screenX,Wr=l.screenY-qn.screenY):Wr=Qe=0,qn=l),Qe)},movementY:function(l){return"movementY"in l?l.movementY:Wr}}),pp=vn(qr),mp=m({},qr,{dataTransfer:0}),Jc=vn(mp),gp=m({},Fa,{relatedTarget:0}),ro=vn(gp),dr=m({},gt,{animationName:0,elapsedTime:0,pseudoElement:0}),Ho=vn(dr),Ws=m({},gt,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),fr=vn(Ws),vp=m({},gt,{data:0}),Ph=vn(vp),wv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Sv={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"},kv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function _p(l){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(l):(l=kv[l])?!!c[l]:!1}function pr(){return _p}var Cv=m({},Fa,{key:function(l){if(l.key){var c=wv[l.key]||l.key;if(c!=="Unidentified")return c}return l.type==="keypress"?(l=Nl(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?Sv[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pr,charCode:function(l){return l.type==="keypress"?Nl(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?Nl(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),Ev=vn(Cv),yp=m({},qr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),xp=vn(yp),Wo=m({},Fa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pr}),qo=vn(Wo),Rl=m({},gt,{propertyName:0,elapsedTime:0,pseudoElement:0}),Mv=vn(Rl),Av=m({},qr,{deltaX:function(l){return"deltaX"in l?l.deltaX:"wheelDeltaX"in l?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:"wheelDeltaY"in l?-l.wheelDeltaY:"wheelDelta"in l?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),eu=vn(Av),Dl=m({},gt,{newState:0,oldState:0}),bp=vn(Dl),tu=[9,13,27,32],Bl=Hs&&"CompositionEvent"in window,Ol=null;Hs&&"documentMode"in document&&(Ol=document.documentMode);var zh=Hs&&"TextEvent"in window&&!Ol,Uo=Hs&&(!Bl||Ol&&8<Ol&&11>=Ol),$h=" ",Fh=!1;function Il(l,c){switch(l){case"keyup":return tu.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Hh(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Vo=!1;function iu(l,c){switch(l){case"compositionend":return Hh(c);case"keypress":return c.which!==32?null:(Fh=!0,$h);case"textInput":return l=c.data,l===$h&&Fh?null:l;default:return null}}function Wh(l,c){if(Vo)return l==="compositionend"||!Bl&&Il(l,c)?(l=Ih(),Zc=Oh=cn=null,Vo=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1<c.char.length)return c.char;if(c.which)return String.fromCharCode(c.which)}return null;case"compositionend":return Uo&&c.locale!=="ko"?null:c.data;default:return null}}var nu={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 qh(l){var c=l&&l.nodeName&&l.nodeName.toLowerCase();return c==="input"?!!nu[l.type]:c==="textarea"}function Uh(l,c,f,g){Fs?Hr?Hr.push(g):Hr=[g]:Fs=g,c=vm(c,"onChange"),0<c.length&&(f=new $a("onChange","change",null,f,g),l.push({event:f,listeners:c}))}var Ha=null,Wa=null;function Lv(l){w2(l,0)}function qa(l){var c=Fr(l);if(Dh(c))return l}function Ko(l,c){if(l==="change")return c}var wp=!1;if(Hs){var Pl;if(Hs){var Vh="oninput"in document;if(!Vh){var Sp=document.createElement("div");Sp.setAttribute("oninput","return;"),Vh=typeof Sp.oninput=="function"}Pl=Vh}else Pl=!1;wp=Pl&&(!document.documentMode||9<document.documentMode)}function kp(){Ha&&(Ha.detachEvent("onpropertychange",Cp),Wa=Ha=null)}function Cp(l){if(l.propertyName==="value"&&qa(Wa)){var c=[];Uh(c,Wa,l,Xc(l)),dp(Lv,c)}}function Ep(l,c,f){l==="focusin"?(kp(),Ha=c,Wa=f,Ha.attachEvent("onpropertychange",Cp)):l==="focusout"&&kp()}function Tv(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return qa(Wa)}function Nv(l,c){if(l==="click")return qa(c)}function Mp(l,c){if(l==="input"||l==="change")return qa(c)}function Kh(l,c){return l===c&&(l!==0||1/l===1/c)||l!==l&&c!==c}var ts=typeof Object.is=="function"?Object.is:Kh;function Ua(l,c){if(ts(l,c))return!0;if(typeof l!="object"||l===null||typeof c!="object"||c===null)return!1;var f=Object.keys(l),g=Object.keys(c);if(f.length!==g.length)return!1;for(g=0;g<f.length;g++){var y=f[g];if(!We.call(c,y)||!ts(l[y],c[y]))return!1}return!0}function zl(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function Ap(l,c){var f=zl(l);l=0;for(var g;f;){if(f.nodeType===3){if(g=l+f.textContent.length,l<=c&&g>=c)return{node:f,offset:c-l};l=g}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=zl(f)}}function Yh(l,c){return l&&c?l===c?!0:l&&l.nodeType===3?!1:c&&c.nodeType===3?Yh(l,c.parentNode):"contains"in l?l.contains(c):l.compareDocumentPosition?!!(l.compareDocumentPosition(c)&16):!1:!1}function Gh(l){l=l!=null&&l.ownerDocument!=null&&l.ownerDocument.defaultView!=null?l.ownerDocument.defaultView:window;for(var c=an(l.document);c instanceof l.HTMLIFrameElement;){try{var f=typeof c.contentWindow.location.href=="string"}catch{f=!1}if(f)l=c.contentWindow;else break;c=an(l.document)}return c}function A(l){var c=l&&l.nodeName&&l.nodeName.toLowerCase();return c&&(c==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||c==="textarea"||l.contentEditable==="true")}var W=Hs&&"documentMode"in document&&11>=document.documentMode,Z=null,se=null,pe=null,ke=!1;function Ne(l,c,f){var g=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;ke||Z==null||Z!==an(g)||(g=Z,"selectionStart"in g&&A(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),pe&&Ua(pe,g)||(pe=g,g=vm(se,"onSelect"),0<g.length&&(c=new $a("onSelect","select",null,c,f),l.push({event:c,listeners:g}),c.target=Z)))}function et(l,c){var f={};return f[l.toLowerCase()]=c.toLowerCase(),f["Webkit"+l]="webkit"+c,f["Moz"+l]="moz"+c,f}var rt={animationend:et("Animation","AnimationEnd"),animationiteration:et("Animation","AnimationIteration"),animationstart:et("Animation","AnimationStart"),transitionrun:et("Transition","TransitionRun"),transitionstart:et("Transition","TransitionStart"),transitioncancel:et("Transition","TransitionCancel"),transitionend:et("Transition","TransitionEnd")},Ye={},Re={};Hs&&(Re=document.createElement("div").style,"AnimationEvent"in window||(delete rt.animationend.animation,delete rt.animationiteration.animation,delete rt.animationstart.animation),"TransitionEvent"in window||delete rt.transitionend.transition);function Ve(l){if(Ye[l])return Ye[l];if(!rt[l])return l;var c=rt[l],f;for(f in c)if(c.hasOwnProperty(f)&&f in Re)return Ye[l]=c[f];return l}var Ot=Ve("animationend"),ji=Ve("animationiteration"),is=Ve("animationstart"),Un=Ve("transitionrun"),Fi=Ve("transitionstart"),Lp=Ve("transitioncancel"),Wt=Ve("transitionend"),ns=new Map,$l="abort auxClick beforeToggle 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(" ");$l.push("scrollEnd");function Ur(l,c){ns.set(l,c),es(c,[l])}var Tp=typeof reportError=="function"?reportError:function(l){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var c=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof l=="object"&&l!==null&&typeof l.message=="string"?String(l.message):String(l),error:l});if(!window.dispatchEvent(c))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",l);return}console.error(l)},mr=[],su=0,jv=0;function Np(){for(var l=su,c=jv=su=0;c<l;){var f=mr[c];mr[c++]=null;var g=mr[c];mr[c++]=null;var y=mr[c];mr[c++]=null;var b=mr[c];if(mr[c++]=null,g!==null&&y!==null){var E=g.pending;E===null?y.next=y:(y.next=E.next,E.next=y),g.pending=y}b!==0&&nk(f,y,b)}}function jp(l,c,f,g){mr[su++]=l,mr[su++]=c,mr[su++]=f,mr[su++]=g,jv|=g,l.lanes|=g,l=l.alternate,l!==null&&(l.lanes|=g)}function Rv(l,c,f,g){return jp(l,c,f,g),Rp(l)}function Va(l,c){return jp(l,null,null,c),Rp(l)}function nk(l,c,f){l.lanes|=f;var g=l.alternate;g!==null&&(g.lanes|=f);for(var y=!1,b=l.return;b!==null;)b.childLanes|=f,g=b.alternate,g!==null&&(g.childLanes|=f),b.tag===22&&(l=b.stateNode,l===null||l._visibility&1||(y=!0)),l=b,b=b.return;return l.tag===3?(b=l.stateNode,y&&c!==null&&(y=31-Tt(f),l=b.hiddenUpdates,g=l[y],g===null?l[y]=[c]:g.push(c),c.lane=f|536870912),b):null}function Rp(l){if(50<vd)throw vd=0,H_=null,Error(n(185));for(var c=l.return;c!==null;)l=c,c=l.return;return l.tag===3?l.stateNode:null}var ru={};function X6(l,c,f,g){this.tag=l,this.key=f,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=c,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function qs(l,c,f,g){return new X6(l,c,f,g)}function Dv(l){return l=l.prototype,!(!l||!l.isReactComponent)}function Yo(l,c){var f=l.alternate;return f===null?(f=qs(l.tag,c,l.key,l.mode),f.elementType=l.elementType,f.type=l.type,f.stateNode=l.stateNode,f.alternate=l,l.alternate=f):(f.pendingProps=c,f.type=l.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=l.flags&65011712,f.childLanes=l.childLanes,f.lanes=l.lanes,f.child=l.child,f.memoizedProps=l.memoizedProps,f.memoizedState=l.memoizedState,f.updateQueue=l.updateQueue,c=l.dependencies,f.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},f.sibling=l.sibling,f.index=l.index,f.ref=l.ref,f.refCleanup=l.refCleanup,f}function sk(l,c){l.flags&=65011714;var f=l.alternate;return f===null?(l.childLanes=0,l.lanes=c,l.child=null,l.subtreeFlags=0,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=f.childLanes,l.lanes=f.lanes,l.child=f.child,l.subtreeFlags=0,l.deletions=null,l.memoizedProps=f.memoizedProps,l.memoizedState=f.memoizedState,l.updateQueue=f.updateQueue,l.type=f.type,c=f.dependencies,l.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext}),l}function Dp(l,c,f,g,y,b){var E=0;if(g=l,typeof l=="function")Dv(l)&&(E=1);else if(typeof l=="string")E=iO(l,f,ee.current)?26:l==="html"||l==="head"||l==="body"?27:5;else e:switch(l){case G:return l=qs(31,f,c,y),l.elementType=G,l.lanes=b,l;case S:return Ka(f.children,y,b,c);case C:E=8,y|=24;break;case k:return l=qs(12,f,c,y|2),l.elementType=k,l.lanes=b,l;case j:return l=qs(13,f,c,y),l.elementType=j,l.lanes=b,l;case R:return l=qs(19,f,c,y),l.elementType=R,l.lanes=b,l;default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case L:E=10;break e;case M:E=9;break e;case N:E=11;break e;case z:E=14;break e;case J:E=16,g=null;break e}E=29,f=Error(n(130,l===null?"null":typeof l,"")),g=null}return c=qs(E,f,c,y),c.elementType=l,c.type=g,c.lanes=b,c}function Ka(l,c,f,g){return l=qs(7,l,g,c),l.lanes=f,l}function Bv(l,c,f){return l=qs(6,l,null,c),l.lanes=f,l}function rk(l){var c=qs(18,null,null,0);return c.stateNode=l,c}function Ov(l,c,f){return c=qs(4,l.children!==null?l.children:[],l.key,c),c.lanes=f,c.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},c}var ok=new WeakMap;function gr(l,c){if(typeof l=="object"&&l!==null){var f=ok.get(l);return f!==void 0?f:(c={value:l,source:c,stack:be(c)},ok.set(l,c),c)}return{value:l,source:c,stack:be(c)}}var ou=[],lu=0,Bp=null,Qh=0,vr=[],_r=0,Fl=null,oo=1,lo="";function Go(l,c){ou[lu++]=Qh,ou[lu++]=Bp,Bp=l,Qh=c}function lk(l,c,f){vr[_r++]=oo,vr[_r++]=lo,vr[_r++]=Fl,Fl=l;var g=oo;l=lo;var y=32-Tt(g)-1;g&=~(1<<y),f+=1;var b=32-Tt(c)+y;if(30<b){var E=y-y%5;b=(g&(1<<E)-1).toString(32),g>>=E,y-=E,oo=1<<32-Tt(c)+y|f<<y|g,lo=b+l}else oo=1<<b|f<<y|g,lo=l}function Iv(l){l.return!==null&&(Go(l,1),lk(l,1,0))}function Pv(l){for(;l===Bp;)Bp=ou[--lu],ou[lu]=null,Qh=ou[--lu],ou[lu]=null;for(;l===Fl;)Fl=vr[--_r],vr[_r]=null,lo=vr[--_r],vr[_r]=null,oo=vr[--_r],vr[_r]=null}function ak(l,c){vr[_r++]=oo,vr[_r++]=lo,vr[_r++]=Fl,oo=c.id,lo=c.overflow,Fl=l}var jn=null,xi=null,Nt=!1,Hl=null,yr=!1,zv=Error(n(519));function Wl(l){var c=Error(n(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Xh(gr(c,l)),zv}function ck(l){var c=l.stateNode,f=l.type,g=l.memoizedProps;switch(c[Ni]=l,c[ht]=g,f){case"dialog":kt("cancel",c),kt("close",c);break;case"iframe":case"object":case"embed":kt("load",c);break;case"video":case"audio":for(f=0;f<yd.length;f++)kt(yd[f],c);break;case"source":kt("error",c);break;case"img":case"image":case"link":kt("error",c),kt("load",c);break;case"details":kt("toggle",c);break;case"input":kt("invalid",c),ap(c,g.value,g.defaultValue,g.checked,g.defaultChecked,g.type,g.name,!0);break;case"select":kt("invalid",c);break;case"textarea":kt("invalid",c),cp(c,g.value,g.defaultValue,g.children)}f=g.children,typeof f!="string"&&typeof f!="number"&&typeof f!="bigint"||c.textContent===""+f||g.suppressHydrationWarning===!0||E2(c.textContent,f)?(g.popover!=null&&(kt("beforetoggle",c),kt("toggle",c)),g.onScroll!=null&&kt("scroll",c),g.onScrollEnd!=null&&kt("scrollend",c),g.onClick!=null&&(c.onclick=Nn),c=!0):c=!1,c||Wl(l,!0)}function uk(l){for(jn=l.return;jn;)switch(jn.tag){case 5:case 31:case 13:yr=!1;return;case 27:case 3:yr=!0;return;default:jn=jn.return}}function au(l){if(l!==jn)return!1;if(!Nt)return uk(l),Nt=!0,!1;var c=l.tag,f;if((f=c!==3&&c!==27)&&((f=c===5)&&(f=l.type,f=!(f!=="form"&&f!=="button")||n1(l.type,l.memoizedProps)),f=!f),f&&xi&&Wl(l),uk(l),c===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(n(317));xi=B2(l)}else if(c===31){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(n(317));xi=B2(l)}else c===27?(c=xi,na(l.type)?(l=a1,a1=null,xi=l):xi=c):xi=jn?br(l.stateNode.nextSibling):null;return!0}function Ya(){xi=jn=null,Nt=!1}function $v(){var l=Hl;return l!==null&&(Es===null?Es=l:Es.push.apply(Es,l),Hl=null),l}function Xh(l){Hl===null?Hl=[l]:Hl.push(l)}var Fv=$(null),Ga=null,Qo=null;function ql(l,c,f){B(Fv,c._currentValue),c._currentValue=f}function Xo(l){l._currentValue=Fv.current,Y(Fv)}function Hv(l,c,f){for(;l!==null;){var g=l.alternate;if((l.childLanes&c)!==c?(l.childLanes|=c,g!==null&&(g.childLanes|=c)):g!==null&&(g.childLanes&c)!==c&&(g.childLanes|=c),l===f)break;l=l.return}}function Wv(l,c,f,g){var y=l.child;for(y!==null&&(y.return=l);y!==null;){var b=y.dependencies;if(b!==null){var E=y.child;b=b.firstContext;e:for(;b!==null;){var O=b;b=y;for(var Q=0;Q<c.length;Q++)if(O.context===c[Q]){b.lanes|=f,O=b.alternate,O!==null&&(O.lanes|=f),Hv(b.return,f,l),g||(E=null);break e}b=O.next}}else if(y.tag===18){if(E=y.return,E===null)throw Error(n(341));E.lanes|=f,b=E.alternate,b!==null&&(b.lanes|=f),Hv(E,f,l),E=null}else E=y.child;if(E!==null)E.return=y;else for(E=y;E!==null;){if(E===l){E=null;break}if(y=E.sibling,y!==null){y.return=E.return,E=y;break}E=E.return}y=E}}function cu(l,c,f,g){l=null;for(var y=c,b=!1;y!==null;){if(!b){if((y.flags&524288)!==0)b=!0;else if((y.flags&262144)!==0)break}if(y.tag===10){var E=y.alternate;if(E===null)throw Error(n(387));if(E=E.memoizedProps,E!==null){var O=y.type;ts(y.pendingProps.value,E.value)||(l!==null?l.push(O):l=[O])}}else if(y===ge.current){if(E=y.alternate,E===null)throw Error(n(387));E.memoizedState.memoizedState!==y.memoizedState.memoizedState&&(l!==null?l.push(kd):l=[kd])}y=y.return}l!==null&&Wv(c,l,f,g),c.flags|=262144}function Op(l){for(l=l.firstContext;l!==null;){if(!ts(l.context._currentValue,l.memoizedValue))return!0;l=l.next}return!1}function Qa(l){Ga=l,Qo=null,l=l.dependencies,l!==null&&(l.firstContext=null)}function Rn(l){return hk(Ga,l)}function Ip(l,c){return Ga===null&&Qa(l),hk(l,c)}function hk(l,c){var f=c._currentValue;if(c={context:c,memoizedValue:f,next:null},Qo===null){if(l===null)throw Error(n(308));Qo=c,l.dependencies={lanes:0,firstContext:c},l.flags|=524288}else Qo=Qo.next=c;return f}var Z6=typeof AbortController<"u"?AbortController:function(){var l=[],c=this.signal={aborted:!1,addEventListener:function(f,g){l.push(g)}};this.abort=function(){c.aborted=!0,l.forEach(function(f){return f()})}},J6=t.unstable_scheduleCallback,eB=t.unstable_NormalPriority,Qi={$$typeof:L,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function qv(){return{controller:new Z6,data:new Map,refCount:0}}function Zh(l){l.refCount--,l.refCount===0&&J6(eB,function(){l.controller.abort()})}var Jh=null,Uv=0,uu=0,hu=null;function tB(l,c){if(Jh===null){var f=Jh=[];Uv=0,uu=Y_(),hu={status:"pending",value:void 0,then:function(g){f.push(g)}}}return Uv++,c.then(dk,dk),c}function dk(){if(--Uv===0&&Jh!==null){hu!==null&&(hu.status="fulfilled");var l=Jh;Jh=null,uu=0,hu=null;for(var c=0;c<l.length;c++)(0,l[c])()}}function iB(l,c){var f=[],g={status:"pending",value:null,reason:null,then:function(y){f.push(y)}};return l.then(function(){g.status="fulfilled",g.value=c;for(var y=0;y<f.length;y++)(0,f[y])(c)},function(y){for(g.status="rejected",g.reason=y,y=0;y<f.length;y++)(0,f[y])(void 0)}),g}var fk=P.S;P.S=function(l,c){QC=Kt(),typeof c=="object"&&c!==null&&typeof c.then=="function"&&tB(l,c),fk!==null&&fk(l,c)};var Xa=$(null);function Vv(){var l=Xa.current;return l!==null?l:si.pooledCache}function Pp(l,c){c===null?B(Xa,Xa.current):B(Xa,c.pool)}function pk(){var l=Vv();return l===null?null:{parent:Qi._currentValue,pool:l}}var du=Error(n(460)),Kv=Error(n(474)),zp=Error(n(542)),$p={then:function(){}};function mk(l){return l=l.status,l==="fulfilled"||l==="rejected"}function gk(l,c,f){switch(f=l[f],f===void 0?l.push(c):f!==c&&(c.then(Nn,Nn),c=f),c.status){case"fulfilled":return c.value;case"rejected":throw l=c.reason,_k(l),l;default:if(typeof c.status=="string")c.then(Nn,Nn);else{if(l=si,l!==null&&100<l.shellSuspendCounter)throw Error(n(482));l=c,l.status="pending",l.then(function(g){if(c.status==="pending"){var y=c;y.status="fulfilled",y.value=g}},function(g){if(c.status==="pending"){var y=c;y.status="rejected",y.reason=g}})}switch(c.status){case"fulfilled":return c.value;case"rejected":throw l=c.reason,_k(l),l}throw Ja=c,du}}function Za(l){try{var c=l._init;return c(l._payload)}catch(f){throw f!==null&&typeof f=="object"&&typeof f.then=="function"?(Ja=f,du):f}}var Ja=null;function vk(){if(Ja===null)throw Error(n(459));var l=Ja;return Ja=null,l}function _k(l){if(l===du||l===zp)throw Error(n(483))}var fu=null,ed=0;function Fp(l){var c=ed;return ed+=1,fu===null&&(fu=[]),gk(fu,l,c)}function td(l,c){c=c.props.ref,l.ref=c!==void 0?c:null}function Hp(l,c){throw c.$$typeof===v?Error(n(525)):(l=Object.prototype.toString.call(c),Error(n(31,l==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":l)))}function yk(l){function c(ne,te){if(l){var oe=ne.deletions;oe===null?(ne.deletions=[te],ne.flags|=16):oe.push(te)}}function f(ne,te){if(!l)return null;for(;te!==null;)c(ne,te),te=te.sibling;return null}function g(ne){for(var te=new Map;ne!==null;)ne.key!==null?te.set(ne.key,ne):te.set(ne.index,ne),ne=ne.sibling;return te}function y(ne,te){return ne=Yo(ne,te),ne.index=0,ne.sibling=null,ne}function b(ne,te,oe){return ne.index=oe,l?(oe=ne.alternate,oe!==null?(oe=oe.index,oe<te?(ne.flags|=67108866,te):oe):(ne.flags|=67108866,te)):(ne.flags|=1048576,te)}function E(ne){return l&&ne.alternate===null&&(ne.flags|=67108866),ne}function O(ne,te,oe,ye){return te===null||te.tag!==6?(te=Bv(oe,ne.mode,ye),te.return=ne,te):(te=y(te,oe),te.return=ne,te)}function Q(ne,te,oe,ye){var Xe=oe.type;return Xe===S?me(ne,te,oe.props.children,ye,oe.key):te!==null&&(te.elementType===Xe||typeof Xe=="object"&&Xe!==null&&Xe.$$typeof===J&&Za(Xe)===te.type)?(te=y(te,oe.props),td(te,oe),te.return=ne,te):(te=Dp(oe.type,oe.key,oe.props,null,ne.mode,ye),td(te,oe),te.return=ne,te)}function le(ne,te,oe,ye){return te===null||te.tag!==4||te.stateNode.containerInfo!==oe.containerInfo||te.stateNode.implementation!==oe.implementation?(te=Ov(oe,ne.mode,ye),te.return=ne,te):(te=y(te,oe.children||[]),te.return=ne,te)}function me(ne,te,oe,ye,Xe){return te===null||te.tag!==7?(te=Ka(oe,ne.mode,ye,Xe),te.return=ne,te):(te=y(te,oe),te.return=ne,te)}function xe(ne,te,oe){if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return te=Bv(""+te,ne.mode,oe),te.return=ne,te;if(typeof te=="object"&&te!==null){switch(te.$$typeof){case _:return oe=Dp(te.type,te.key,te.props,null,ne.mode,oe),td(oe,te),oe.return=ne,oe;case x:return te=Ov(te,ne.mode,oe),te.return=ne,te;case J:return te=Za(te),xe(ne,te,oe)}if(F(te)||I(te))return te=Ka(te,ne.mode,oe,null),te.return=ne,te;if(typeof te.then=="function")return xe(ne,Fp(te),oe);if(te.$$typeof===L)return xe(ne,Ip(ne,te),oe);Hp(ne,te)}return null}function ce(ne,te,oe,ye){var Xe=te!==null?te.key:null;if(typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint")return Xe!==null?null:O(ne,te,""+oe,ye);if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case _:return oe.key===Xe?Q(ne,te,oe,ye):null;case x:return oe.key===Xe?le(ne,te,oe,ye):null;case J:return oe=Za(oe),ce(ne,te,oe,ye)}if(F(oe)||I(oe))return Xe!==null?null:me(ne,te,oe,ye,null);if(typeof oe.then=="function")return ce(ne,te,Fp(oe),ye);if(oe.$$typeof===L)return ce(ne,te,Ip(ne,oe),ye);Hp(ne,oe)}return null}function ue(ne,te,oe,ye,Xe){if(typeof ye=="string"&&ye!==""||typeof ye=="number"||typeof ye=="bigint")return ne=ne.get(oe)||null,O(te,ne,""+ye,Xe);if(typeof ye=="object"&&ye!==null){switch(ye.$$typeof){case _:return ne=ne.get(ye.key===null?oe:ye.key)||null,Q(te,ne,ye,Xe);case x:return ne=ne.get(ye.key===null?oe:ye.key)||null,le(te,ne,ye,Xe);case J:return ye=Za(ye),ue(ne,te,oe,ye,Xe)}if(F(ye)||I(ye))return ne=ne.get(oe)||null,me(te,ne,ye,Xe,null);if(typeof ye.then=="function")return ue(ne,te,oe,Fp(ye),Xe);if(ye.$$typeof===L)return ue(ne,te,oe,Ip(te,ye),Xe);Hp(te,ye)}return null}function $e(ne,te,oe,ye){for(var Xe=null,zt=null,qe=te,ft=te=0,Lt=null;qe!==null&&ft<oe.length;ft++){qe.index>ft?(Lt=qe,qe=null):Lt=qe.sibling;var $t=ce(ne,qe,oe[ft],ye);if($t===null){qe===null&&(qe=Lt);break}l&&qe&&$t.alternate===null&&c(ne,qe),te=b($t,te,ft),zt===null?Xe=$t:zt.sibling=$t,zt=$t,qe=Lt}if(ft===oe.length)return f(ne,qe),Nt&&Go(ne,ft),Xe;if(qe===null){for(;ft<oe.length;ft++)qe=xe(ne,oe[ft],ye),qe!==null&&(te=b(qe,te,ft),zt===null?Xe=qe:zt.sibling=qe,zt=qe);return Nt&&Go(ne,ft),Xe}for(qe=g(qe);ft<oe.length;ft++)Lt=ue(qe,ne,ft,oe[ft],ye),Lt!==null&&(l&&Lt.alternate!==null&&qe.delete(Lt.key===null?ft:Lt.key),te=b(Lt,te,ft),zt===null?Xe=Lt:zt.sibling=Lt,zt=Lt);return l&&qe.forEach(function(aa){return c(ne,aa)}),Nt&&Go(ne,ft),Xe}function nt(ne,te,oe,ye){if(oe==null)throw Error(n(151));for(var Xe=null,zt=null,qe=te,ft=te=0,Lt=null,$t=oe.next();qe!==null&&!$t.done;ft++,$t=oe.next()){qe.index>ft?(Lt=qe,qe=null):Lt=qe.sibling;var aa=ce(ne,qe,$t.value,ye);if(aa===null){qe===null&&(qe=Lt);break}l&&qe&&aa.alternate===null&&c(ne,qe),te=b(aa,te,ft),zt===null?Xe=aa:zt.sibling=aa,zt=aa,qe=Lt}if($t.done)return f(ne,qe),Nt&&Go(ne,ft),Xe;if(qe===null){for(;!$t.done;ft++,$t=oe.next())$t=xe(ne,$t.value,ye),$t!==null&&(te=b($t,te,ft),zt===null?Xe=$t:zt.sibling=$t,zt=$t);return Nt&&Go(ne,ft),Xe}for(qe=g(qe);!$t.done;ft++,$t=oe.next())$t=ue(qe,ne,ft,$t.value,ye),$t!==null&&(l&&$t.alternate!==null&&qe.delete($t.key===null?ft:$t.key),te=b($t,te,ft),zt===null?Xe=$t:zt.sibling=$t,zt=$t);return l&&qe.forEach(function(fO){return c(ne,fO)}),Nt&&Go(ne,ft),Xe}function ii(ne,te,oe,ye){if(typeof oe=="object"&&oe!==null&&oe.type===S&&oe.key===null&&(oe=oe.props.children),typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case _:e:{for(var Xe=oe.key;te!==null;){if(te.key===Xe){if(Xe=oe.type,Xe===S){if(te.tag===7){f(ne,te.sibling),ye=y(te,oe.props.children),ye.return=ne,ne=ye;break e}}else if(te.elementType===Xe||typeof Xe=="object"&&Xe!==null&&Xe.$$typeof===J&&Za(Xe)===te.type){f(ne,te.sibling),ye=y(te,oe.props),td(ye,oe),ye.return=ne,ne=ye;break e}f(ne,te);break}else c(ne,te);te=te.sibling}oe.type===S?(ye=Ka(oe.props.children,ne.mode,ye,oe.key),ye.return=ne,ne=ye):(ye=Dp(oe.type,oe.key,oe.props,null,ne.mode,ye),td(ye,oe),ye.return=ne,ne=ye)}return E(ne);case x:e:{for(Xe=oe.key;te!==null;){if(te.key===Xe)if(te.tag===4&&te.stateNode.containerInfo===oe.containerInfo&&te.stateNode.implementation===oe.implementation){f(ne,te.sibling),ye=y(te,oe.children||[]),ye.return=ne,ne=ye;break e}else{f(ne,te);break}else c(ne,te);te=te.sibling}ye=Ov(oe,ne.mode,ye),ye.return=ne,ne=ye}return E(ne);case J:return oe=Za(oe),ii(ne,te,oe,ye)}if(F(oe))return $e(ne,te,oe,ye);if(I(oe)){if(Xe=I(oe),typeof Xe!="function")throw Error(n(150));return oe=Xe.call(oe),nt(ne,te,oe,ye)}if(typeof oe.then=="function")return ii(ne,te,Fp(oe),ye);if(oe.$$typeof===L)return ii(ne,te,Ip(ne,oe),ye);Hp(ne,oe)}return typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint"?(oe=""+oe,te!==null&&te.tag===6?(f(ne,te.sibling),ye=y(te,oe),ye.return=ne,ne=ye):(f(ne,te),ye=Bv(oe,ne.mode,ye),ye.return=ne,ne=ye),E(ne)):f(ne,te)}return function(ne,te,oe,ye){try{ed=0;var Xe=ii(ne,te,oe,ye);return fu=null,Xe}catch(qe){if(qe===du||qe===zp)throw qe;var zt=qs(29,qe,null,ne.mode);return zt.lanes=ye,zt.return=ne,zt}}}var ec=yk(!0),xk=yk(!1),Ul=!1;function Yv(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Gv(l,c){l=l.updateQueue,c.updateQueue===l&&(c.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function Vl(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function Kl(l,c,f){var g=l.updateQueue;if(g===null)return null;if(g=g.shared,(qt&2)!==0){var y=g.pending;return y===null?c.next=c:(c.next=y.next,y.next=c),g.pending=c,c=Rp(l),nk(l,null,f),c}return jp(l,g,c,f),Rp(l)}function id(l,c,f){if(c=c.updateQueue,c!==null&&(c=c.shared,(f&4194048)!==0)){var g=c.lanes;g&=l.pendingLanes,f|=g,c.lanes=f,Al(l,f)}}function Qv(l,c){var f=l.updateQueue,g=l.alternate;if(g!==null&&(g=g.updateQueue,f===g)){var y=null,b=null;if(f=f.firstBaseUpdate,f!==null){do{var E={lane:f.lane,tag:f.tag,payload:f.payload,callback:null,next:null};b===null?y=b=E:b=b.next=E,f=f.next}while(f!==null);b===null?y=b=c:b=b.next=c}else y=b=c;f={baseState:g.baseState,firstBaseUpdate:y,lastBaseUpdate:b,shared:g.shared,callbacks:g.callbacks},l.updateQueue=f;return}l=f.lastBaseUpdate,l===null?f.firstBaseUpdate=c:l.next=c,f.lastBaseUpdate=c}var Xv=!1;function nd(){if(Xv){var l=hu;if(l!==null)throw l}}function sd(l,c,f,g){Xv=!1;var y=l.updateQueue;Ul=!1;var b=y.firstBaseUpdate,E=y.lastBaseUpdate,O=y.shared.pending;if(O!==null){y.shared.pending=null;var Q=O,le=Q.next;Q.next=null,E===null?b=le:E.next=le,E=Q;var me=l.alternate;me!==null&&(me=me.updateQueue,O=me.lastBaseUpdate,O!==E&&(O===null?me.firstBaseUpdate=le:O.next=le,me.lastBaseUpdate=Q))}if(b!==null){var xe=y.baseState;E=0,me=le=Q=null,O=b;do{var ce=O.lane&-536870913,ue=ce!==O.lane;if(ue?(At&ce)===ce:(g&ce)===ce){ce!==0&&ce===uu&&(Xv=!0),me!==null&&(me=me.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var $e=l,nt=O;ce=c;var ii=f;switch(nt.tag){case 1:if($e=nt.payload,typeof $e=="function"){xe=$e.call(ii,xe,ce);break e}xe=$e;break e;case 3:$e.flags=$e.flags&-65537|128;case 0:if($e=nt.payload,ce=typeof $e=="function"?$e.call(ii,xe,ce):$e,ce==null)break e;xe=m({},xe,ce);break e;case 2:Ul=!0}}ce=O.callback,ce!==null&&(l.flags|=64,ue&&(l.flags|=8192),ue=y.callbacks,ue===null?y.callbacks=[ce]:ue.push(ce))}else ue={lane:ce,tag:O.tag,payload:O.payload,callback:O.callback,next:null},me===null?(le=me=ue,Q=xe):me=me.next=ue,E|=ce;if(O=O.next,O===null){if(O=y.shared.pending,O===null)break;ue=O,O=ue.next,ue.next=null,y.lastBaseUpdate=ue,y.shared.pending=null}}while(!0);me===null&&(Q=xe),y.baseState=Q,y.firstBaseUpdate=le,y.lastBaseUpdate=me,b===null&&(y.shared.lanes=0),Zl|=E,l.lanes=E,l.memoizedState=xe}}function bk(l,c){if(typeof l!="function")throw Error(n(191,l));l.call(c)}function wk(l,c){var f=l.callbacks;if(f!==null)for(l.callbacks=null,l=0;l<f.length;l++)bk(f[l],c)}var pu=$(null),Wp=$(0);function Sk(l,c){l=ol,B(Wp,l),B(pu,c),ol=l|c.baseLanes}function Zv(){B(Wp,ol),B(pu,pu.current)}function Jv(){ol=Wp.current,Y(pu),Y(Wp)}var Us=$(null),xr=null;function Yl(l){var c=l.alternate;B(Hi,Hi.current&1),B(Us,l),xr===null&&(c===null||pu.current!==null||c.memoizedState!==null)&&(xr=l)}function e_(l){B(Hi,Hi.current),B(Us,l),xr===null&&(xr=l)}function kk(l){l.tag===22?(B(Hi,Hi.current),B(Us,l),xr===null&&(xr=l)):Gl()}function Gl(){B(Hi,Hi.current),B(Us,Us.current)}function Vs(l){Y(Us),xr===l&&(xr=null),Y(Hi)}var Hi=$(0);function qp(l){for(var c=l;c!==null;){if(c.tag===13){var f=c.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||o1(f)||l1(f)))return c}else if(c.tag===19&&(c.memoizedProps.revealOrder==="forwards"||c.memoizedProps.revealOrder==="backwards"||c.memoizedProps.revealOrder==="unstable_legacy-backwards"||c.memoizedProps.revealOrder==="together")){if((c.flags&128)!==0)return c}else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===l)break;for(;c.sibling===null;){if(c.return===null||c.return===l)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var Zo=0,dt=null,ei=null,Xi=null,Up=!1,mu=!1,tc=!1,Vp=0,rd=0,gu=null,nB=0;function Ri(){throw Error(n(321))}function t_(l,c){if(c===null)return!1;for(var f=0;f<c.length&&f<l.length;f++)if(!ts(l[f],c[f]))return!1;return!0}function i_(l,c,f,g,y,b){return Zo=b,dt=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,P.H=l===null||l.memoizedState===null?lC:v_,tc=!1,b=f(g,y),tc=!1,mu&&(b=Ek(c,f,g,y)),Ck(l),b}function Ck(l){P.H=ad;var c=ei!==null&&ei.next!==null;if(Zo=0,Xi=ei=dt=null,Up=!1,rd=0,gu=null,c)throw Error(n(300));l===null||Zi||(l=l.dependencies,l!==null&&Op(l)&&(Zi=!0))}function Ek(l,c,f,g){dt=l;var y=0;do{if(mu&&(gu=null),rd=0,mu=!1,25<=y)throw Error(n(301));if(y+=1,Xi=ei=null,l.updateQueue!=null){var b=l.updateQueue;b.lastEffect=null,b.events=null,b.stores=null,b.memoCache!=null&&(b.memoCache.index=0)}P.H=aC,b=c(f,g)}while(mu);return b}function sB(){var l=P.H,c=l.useState()[0];return c=typeof c.then=="function"?od(c):c,l=l.useState()[0],(ei!==null?ei.memoizedState:null)!==l&&(dt.flags|=1024),c}function n_(){var l=Vp!==0;return Vp=0,l}function s_(l,c,f){c.updateQueue=l.updateQueue,c.flags&=-2053,l.lanes&=~f}function r_(l){if(Up){for(l=l.memoizedState;l!==null;){var c=l.queue;c!==null&&(c.pending=null),l=l.next}Up=!1}Zo=0,Xi=ei=dt=null,mu=!1,rd=Vp=0,gu=null}function ss(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Xi===null?dt.memoizedState=Xi=l:Xi=Xi.next=l,Xi}function Wi(){if(ei===null){var l=dt.alternate;l=l!==null?l.memoizedState:null}else l=ei.next;var c=Xi===null?dt.memoizedState:Xi.next;if(c!==null)Xi=c,ei=l;else{if(l===null)throw dt.alternate===null?Error(n(467)):Error(n(310));ei=l,l={memoizedState:ei.memoizedState,baseState:ei.baseState,baseQueue:ei.baseQueue,queue:ei.queue,next:null},Xi===null?dt.memoizedState=Xi=l:Xi=Xi.next=l}return Xi}function Kp(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function od(l){var c=rd;return rd+=1,gu===null&&(gu=[]),l=gk(gu,l,c),c=dt,(Xi===null?c.memoizedState:Xi.next)===null&&(c=c.alternate,P.H=c===null||c.memoizedState===null?lC:v_),l}function Yp(l){if(l!==null&&typeof l=="object"){if(typeof l.then=="function")return od(l);if(l.$$typeof===L)return Rn(l)}throw Error(n(438,String(l)))}function o_(l){var c=null,f=dt.updateQueue;if(f!==null&&(c=f.memoCache),c==null){var g=dt.alternate;g!==null&&(g=g.updateQueue,g!==null&&(g=g.memoCache,g!=null&&(c={data:g.data.map(function(y){return y.slice()}),index:0})))}if(c==null&&(c={data:[],index:0}),f===null&&(f=Kp(),dt.updateQueue=f),f.memoCache=c,f=c.data[c.index],f===void 0)for(f=c.data[c.index]=Array(l),g=0;g<l;g++)f[g]=q;return c.index++,f}function Jo(l,c){return typeof c=="function"?c(l):c}function Gp(l){var c=Wi();return l_(c,ei,l)}function l_(l,c,f){var g=l.queue;if(g===null)throw Error(n(311));g.lastRenderedReducer=f;var y=l.baseQueue,b=g.pending;if(b!==null){if(y!==null){var E=y.next;y.next=b.next,b.next=E}c.baseQueue=y=b,g.pending=null}if(b=l.baseState,y===null)l.memoizedState=b;else{c=y.next;var O=E=null,Q=null,le=c,me=!1;do{var xe=le.lane&-536870913;if(xe!==le.lane?(At&xe)===xe:(Zo&xe)===xe){var ce=le.revertLane;if(ce===0)Q!==null&&(Q=Q.next={lane:0,revertLane:0,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),xe===uu&&(me=!0);else if((Zo&ce)===ce){le=le.next,ce===uu&&(me=!0);continue}else xe={lane:0,revertLane:le.revertLane,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},Q===null?(O=Q=xe,E=b):Q=Q.next=xe,dt.lanes|=ce,Zl|=ce;xe=le.action,tc&&f(b,xe),b=le.hasEagerState?le.eagerState:f(b,xe)}else ce={lane:xe,revertLane:le.revertLane,gesture:le.gesture,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},Q===null?(O=Q=ce,E=b):Q=Q.next=ce,dt.lanes|=xe,Zl|=xe;le=le.next}while(le!==null&&le!==c);if(Q===null?E=b:Q.next=O,!ts(b,l.memoizedState)&&(Zi=!0,me&&(f=hu,f!==null)))throw f;l.memoizedState=b,l.baseState=E,l.baseQueue=Q,g.lastRenderedState=b}return y===null&&(g.lanes=0),[l.memoizedState,g.dispatch]}function a_(l){var c=Wi(),f=c.queue;if(f===null)throw Error(n(311));f.lastRenderedReducer=l;var g=f.dispatch,y=f.pending,b=c.memoizedState;if(y!==null){f.pending=null;var E=y=y.next;do b=l(b,E.action),E=E.next;while(E!==y);ts(b,c.memoizedState)||(Zi=!0),c.memoizedState=b,c.baseQueue===null&&(c.baseState=b),f.lastRenderedState=b}return[b,g]}function Mk(l,c,f){var g=dt,y=Wi(),b=Nt;if(b){if(f===void 0)throw Error(n(407));f=f()}else f=c();var E=!ts((ei||y).memoizedState,f);if(E&&(y.memoizedState=f,Zi=!0),y=y.queue,h_(Tk.bind(null,g,y,l),[l]),y.getSnapshot!==c||E||Xi!==null&&Xi.memoizedState.tag&1){if(g.flags|=2048,vu(9,{destroy:void 0},Lk.bind(null,g,y,f,c),null),si===null)throw Error(n(349));b||(Zo&127)!==0||Ak(g,c,f)}return f}function Ak(l,c,f){l.flags|=16384,l={getSnapshot:c,value:f},c=dt.updateQueue,c===null?(c=Kp(),dt.updateQueue=c,c.stores=[l]):(f=c.stores,f===null?c.stores=[l]:f.push(l))}function Lk(l,c,f,g){c.value=f,c.getSnapshot=g,Nk(c)&&jk(l)}function Tk(l,c,f){return f(function(){Nk(c)&&jk(l)})}function Nk(l){var c=l.getSnapshot;l=l.value;try{var f=c();return!ts(l,f)}catch{return!0}}function jk(l){var c=Va(l,2);c!==null&&Ms(c,l,2)}function c_(l){var c=ss();if(typeof l=="function"){var f=l;if(l=f(),tc){gi(!0);try{f()}finally{gi(!1)}}}return c.memoizedState=c.baseState=l,c.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jo,lastRenderedState:l},c}function Rk(l,c,f,g){return l.baseState=f,l_(l,ei,typeof g=="function"?g:Jo)}function rB(l,c,f,g,y){if(Zp(l))throw Error(n(485));if(l=c.action,l!==null){var b={payload:y,action:l,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(E){b.listeners.push(E)}};P.T!==null?f(!0):b.isTransition=!1,g(b),f=c.pending,f===null?(b.next=c.pending=b,Dk(c,b)):(b.next=f.next,c.pending=f.next=b)}}function Dk(l,c){var f=c.action,g=c.payload,y=l.state;if(c.isTransition){var b=P.T,E={};P.T=E;try{var O=f(y,g),Q=P.S;Q!==null&&Q(E,O),Bk(l,c,O)}catch(le){u_(l,c,le)}finally{b!==null&&E.types!==null&&(b.types=E.types),P.T=b}}else try{b=f(y,g),Bk(l,c,b)}catch(le){u_(l,c,le)}}function Bk(l,c,f){f!==null&&typeof f=="object"&&typeof f.then=="function"?f.then(function(g){Ok(l,c,g)},function(g){return u_(l,c,g)}):Ok(l,c,f)}function Ok(l,c,f){c.status="fulfilled",c.value=f,Ik(c),l.state=f,c=l.pending,c!==null&&(f=c.next,f===c?l.pending=null:(f=f.next,c.next=f,Dk(l,f)))}function u_(l,c,f){var g=l.pending;if(l.pending=null,g!==null){g=g.next;do c.status="rejected",c.reason=f,Ik(c),c=c.next;while(c!==g)}l.action=null}function Ik(l){l=l.listeners;for(var c=0;c<l.length;c++)(0,l[c])()}function Pk(l,c){return c}function zk(l,c){if(Nt){var f=si.formState;if(f!==null){e:{var g=dt;if(Nt){if(xi){t:{for(var y=xi,b=yr;y.nodeType!==8;){if(!b){y=null;break t}if(y=br(y.nextSibling),y===null){y=null;break t}}b=y.data,y=b==="F!"||b==="F"?y:null}if(y){xi=br(y.nextSibling),g=y.data==="F!";break e}}Wl(g)}g=!1}g&&(c=f[0])}}return f=ss(),f.memoizedState=f.baseState=c,g={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Pk,lastRenderedState:c},f.queue=g,f=sC.bind(null,dt,g),g.dispatch=f,g=c_(!1),b=g_.bind(null,dt,!1,g.queue),g=ss(),y={state:c,dispatch:null,action:l,pending:null},g.queue=y,f=rB.bind(null,dt,y,b,f),y.dispatch=f,g.memoizedState=l,[c,f,!1]}function $k(l){var c=Wi();return Fk(c,ei,l)}function Fk(l,c,f){if(c=l_(l,c,Pk)[0],l=Gp(Jo)[0],typeof c=="object"&&c!==null&&typeof c.then=="function")try{var g=od(c)}catch(E){throw E===du?zp:E}else g=c;c=Wi();var y=c.queue,b=y.dispatch;return f!==c.memoizedState&&(dt.flags|=2048,vu(9,{destroy:void 0},oB.bind(null,y,f),null)),[g,b,l]}function oB(l,c){l.action=c}function Hk(l){var c=Wi(),f=ei;if(f!==null)return Fk(c,f,l);Wi(),c=c.memoizedState,f=Wi();var g=f.queue.dispatch;return f.memoizedState=l,[c,g,!1]}function vu(l,c,f,g){return l={tag:l,create:f,deps:g,inst:c,next:null},c=dt.updateQueue,c===null&&(c=Kp(),dt.updateQueue=c),f=c.lastEffect,f===null?c.lastEffect=l.next=l:(g=f.next,f.next=l,l.next=g,c.lastEffect=l),l}function Wk(){return Wi().memoizedState}function Qp(l,c,f,g){var y=ss();dt.flags|=l,y.memoizedState=vu(1|c,{destroy:void 0},f,g===void 0?null:g)}function Xp(l,c,f,g){var y=Wi();g=g===void 0?null:g;var b=y.memoizedState.inst;ei!==null&&g!==null&&t_(g,ei.memoizedState.deps)?y.memoizedState=vu(c,b,f,g):(dt.flags|=l,y.memoizedState=vu(1|c,b,f,g))}function qk(l,c){Qp(8390656,8,l,c)}function h_(l,c){Xp(2048,8,l,c)}function lB(l){dt.flags|=4;var c=dt.updateQueue;if(c===null)c=Kp(),dt.updateQueue=c,c.events=[l];else{var f=c.events;f===null?c.events=[l]:f.push(l)}}function Uk(l){var c=Wi().memoizedState;return lB({ref:c,nextImpl:l}),function(){if((qt&2)!==0)throw Error(n(440));return c.impl.apply(void 0,arguments)}}function Vk(l,c){return Xp(4,2,l,c)}function Kk(l,c){return Xp(4,4,l,c)}function Yk(l,c){if(typeof c=="function"){l=l();var f=c(l);return function(){typeof f=="function"?f():c(null)}}if(c!=null)return l=l(),c.current=l,function(){c.current=null}}function Gk(l,c,f){f=f!=null?f.concat([l]):null,Xp(4,4,Yk.bind(null,c,l),f)}function d_(){}function Qk(l,c){var f=Wi();c=c===void 0?null:c;var g=f.memoizedState;return c!==null&&t_(c,g[1])?g[0]:(f.memoizedState=[l,c],l)}function Xk(l,c){var f=Wi();c=c===void 0?null:c;var g=f.memoizedState;if(c!==null&&t_(c,g[1]))return g[0];if(g=l(),tc){gi(!0);try{l()}finally{gi(!1)}}return f.memoizedState=[g,c],g}function f_(l,c,f){return f===void 0||(Zo&1073741824)!==0&&(At&261930)===0?l.memoizedState=c:(l.memoizedState=f,l=ZC(),dt.lanes|=l,Zl|=l,f)}function Zk(l,c,f,g){return ts(f,c)?f:pu.current!==null?(l=f_(l,f,g),ts(l,c)||(Zi=!0),l):(Zo&42)===0||(Zo&1073741824)!==0&&(At&261930)===0?(Zi=!0,l.memoizedState=f):(l=ZC(),dt.lanes|=l,Zl|=l,c)}function Jk(l,c,f,g,y){var b=U.p;U.p=b!==0&&8>b?b:8;var E=P.T,O={};P.T=O,g_(l,!1,c,f);try{var Q=y(),le=P.S;if(le!==null&&le(O,Q),Q!==null&&typeof Q=="object"&&typeof Q.then=="function"){var me=iB(Q,g);ld(l,c,me,Gs(l))}else ld(l,c,g,Gs(l))}catch(xe){ld(l,c,{then:function(){},status:"rejected",reason:xe},Gs())}finally{U.p=b,E!==null&&O.types!==null&&(E.types=O.types),P.T=E}}function aB(){}function p_(l,c,f,g){if(l.tag!==5)throw Error(n(476));var y=eC(l).queue;Jk(l,y,c,V,f===null?aB:function(){return tC(l),f(g)})}function eC(l){var c=l.memoizedState;if(c!==null)return c;c={memoizedState:V,baseState:V,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jo,lastRenderedState:V},next:null};var f={};return c.next={memoizedState:f,baseState:f,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jo,lastRenderedState:f},next:null},l.memoizedState=c,l=l.alternate,l!==null&&(l.memoizedState=c),c}function tC(l){var c=eC(l);c.next===null&&(c=l.alternate.memoizedState),ld(l,c.next.queue,{},Gs())}function m_(){return Rn(kd)}function iC(){return Wi().memoizedState}function nC(){return Wi().memoizedState}function cB(l){for(var c=l.return;c!==null;){switch(c.tag){case 24:case 3:var f=Gs();l=Vl(f);var g=Kl(c,l,f);g!==null&&(Ms(g,c,f),id(g,c,f)),c={cache:qv()},l.payload=c;return}c=c.return}}function uB(l,c,f){var g=Gs();f={lane:g,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},Zp(l)?rC(c,f):(f=Rv(l,c,f,g),f!==null&&(Ms(f,l,g),oC(f,c,g)))}function sC(l,c,f){var g=Gs();ld(l,c,f,g)}function ld(l,c,f,g){var y={lane:g,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null};if(Zp(l))rC(c,y);else{var b=l.alternate;if(l.lanes===0&&(b===null||b.lanes===0)&&(b=c.lastRenderedReducer,b!==null))try{var E=c.lastRenderedState,O=b(E,f);if(y.hasEagerState=!0,y.eagerState=O,ts(O,E))return jp(l,c,y,0),si===null&&Np(),!1}catch{}if(f=Rv(l,c,y,g),f!==null)return Ms(f,l,g),oC(f,c,g),!0}return!1}function g_(l,c,f,g){if(g={lane:2,revertLane:Y_(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},Zp(l)){if(c)throw Error(n(479))}else c=Rv(l,f,g,2),c!==null&&Ms(c,l,2)}function Zp(l){var c=l.alternate;return l===dt||c!==null&&c===dt}function rC(l,c){mu=Up=!0;var f=l.pending;f===null?c.next=c:(c.next=f.next,f.next=c),l.pending=c}function oC(l,c,f){if((f&4194048)!==0){var g=c.lanes;g&=l.pendingLanes,f|=g,c.lanes=f,Al(l,f)}}var ad={readContext:Rn,use:Yp,useCallback:Ri,useContext:Ri,useEffect:Ri,useImperativeHandle:Ri,useLayoutEffect:Ri,useInsertionEffect:Ri,useMemo:Ri,useReducer:Ri,useRef:Ri,useState:Ri,useDebugValue:Ri,useDeferredValue:Ri,useTransition:Ri,useSyncExternalStore:Ri,useId:Ri,useHostTransitionStatus:Ri,useFormState:Ri,useActionState:Ri,useOptimistic:Ri,useMemoCache:Ri,useCacheRefresh:Ri};ad.useEffectEvent=Ri;var lC={readContext:Rn,use:Yp,useCallback:function(l,c){return ss().memoizedState=[l,c===void 0?null:c],l},useContext:Rn,useEffect:qk,useImperativeHandle:function(l,c,f){f=f!=null?f.concat([l]):null,Qp(4194308,4,Yk.bind(null,c,l),f)},useLayoutEffect:function(l,c){return Qp(4194308,4,l,c)},useInsertionEffect:function(l,c){Qp(4,2,l,c)},useMemo:function(l,c){var f=ss();c=c===void 0?null:c;var g=l();if(tc){gi(!0);try{l()}finally{gi(!1)}}return f.memoizedState=[g,c],g},useReducer:function(l,c,f){var g=ss();if(f!==void 0){var y=f(c);if(tc){gi(!0);try{f(c)}finally{gi(!1)}}}else y=c;return g.memoizedState=g.baseState=y,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:y},g.queue=l,l=l.dispatch=uB.bind(null,dt,l),[g.memoizedState,l]},useRef:function(l){var c=ss();return l={current:l},c.memoizedState=l},useState:function(l){l=c_(l);var c=l.queue,f=sC.bind(null,dt,c);return c.dispatch=f,[l.memoizedState,f]},useDebugValue:d_,useDeferredValue:function(l,c){var f=ss();return f_(f,l,c)},useTransition:function(){var l=c_(!1);return l=Jk.bind(null,dt,l.queue,!0,!1),ss().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,c,f){var g=dt,y=ss();if(Nt){if(f===void 0)throw Error(n(407));f=f()}else{if(f=c(),si===null)throw Error(n(349));(At&127)!==0||Ak(g,c,f)}y.memoizedState=f;var b={value:f,getSnapshot:c};return y.queue=b,qk(Tk.bind(null,g,b,l),[l]),g.flags|=2048,vu(9,{destroy:void 0},Lk.bind(null,g,b,f,c),null),f},useId:function(){var l=ss(),c=si.identifierPrefix;if(Nt){var f=lo,g=oo;f=(g&~(1<<32-Tt(g)-1)).toString(32)+f,c="_"+c+"R_"+f,f=Vp++,0<f&&(c+="H"+f.toString(32)),c+="_"}else f=nB++,c="_"+c+"r_"+f.toString(32)+"_";return l.memoizedState=c},useHostTransitionStatus:m_,useFormState:zk,useActionState:zk,useOptimistic:function(l){var c=ss();c.memoizedState=c.baseState=l;var f={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return c.queue=f,c=g_.bind(null,dt,!0,f),f.dispatch=c,[l,c]},useMemoCache:o_,useCacheRefresh:function(){return ss().memoizedState=cB.bind(null,dt)},useEffectEvent:function(l){var c=ss(),f={impl:l};return c.memoizedState=f,function(){if((qt&2)!==0)throw Error(n(440));return f.impl.apply(void 0,arguments)}}},v_={readContext:Rn,use:Yp,useCallback:Qk,useContext:Rn,useEffect:h_,useImperativeHandle:Gk,useInsertionEffect:Vk,useLayoutEffect:Kk,useMemo:Xk,useReducer:Gp,useRef:Wk,useState:function(){return Gp(Jo)},useDebugValue:d_,useDeferredValue:function(l,c){var f=Wi();return Zk(f,ei.memoizedState,l,c)},useTransition:function(){var l=Gp(Jo)[0],c=Wi().memoizedState;return[typeof l=="boolean"?l:od(l),c]},useSyncExternalStore:Mk,useId:iC,useHostTransitionStatus:m_,useFormState:$k,useActionState:$k,useOptimistic:function(l,c){var f=Wi();return Rk(f,ei,l,c)},useMemoCache:o_,useCacheRefresh:nC};v_.useEffectEvent=Uk;var aC={readContext:Rn,use:Yp,useCallback:Qk,useContext:Rn,useEffect:h_,useImperativeHandle:Gk,useInsertionEffect:Vk,useLayoutEffect:Kk,useMemo:Xk,useReducer:a_,useRef:Wk,useState:function(){return a_(Jo)},useDebugValue:d_,useDeferredValue:function(l,c){var f=Wi();return ei===null?f_(f,l,c):Zk(f,ei.memoizedState,l,c)},useTransition:function(){var l=a_(Jo)[0],c=Wi().memoizedState;return[typeof l=="boolean"?l:od(l),c]},useSyncExternalStore:Mk,useId:iC,useHostTransitionStatus:m_,useFormState:Hk,useActionState:Hk,useOptimistic:function(l,c){var f=Wi();return ei!==null?Rk(f,ei,l,c):(f.baseState=l,[l,f.queue.dispatch])},useMemoCache:o_,useCacheRefresh:nC};aC.useEffectEvent=Uk;function __(l,c,f,g){c=l.memoizedState,f=f(g,c),f=f==null?c:m({},c,f),l.memoizedState=f,l.lanes===0&&(l.updateQueue.baseState=f)}var y_={enqueueSetState:function(l,c,f){l=l._reactInternals;var g=Gs(),y=Vl(g);y.payload=c,f!=null&&(y.callback=f),c=Kl(l,y,g),c!==null&&(Ms(c,l,g),id(c,l,g))},enqueueReplaceState:function(l,c,f){l=l._reactInternals;var g=Gs(),y=Vl(g);y.tag=1,y.payload=c,f!=null&&(y.callback=f),c=Kl(l,y,g),c!==null&&(Ms(c,l,g),id(c,l,g))},enqueueForceUpdate:function(l,c){l=l._reactInternals;var f=Gs(),g=Vl(f);g.tag=2,c!=null&&(g.callback=c),c=Kl(l,g,f),c!==null&&(Ms(c,l,f),id(c,l,f))}};function cC(l,c,f,g,y,b,E){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(g,b,E):c.prototype&&c.prototype.isPureReactComponent?!Ua(f,g)||!Ua(y,b):!0}function uC(l,c,f,g){l=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(f,g),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(f,g),c.state!==l&&y_.enqueueReplaceState(c,c.state,null)}function ic(l,c){var f=c;if("ref"in c){f={};for(var g in c)g!=="ref"&&(f[g]=c[g])}if(l=l.defaultProps){f===c&&(f=m({},f));for(var y in l)f[y]===void 0&&(f[y]=l[y])}return f}function hC(l){Tp(l)}function dC(l){console.error(l)}function fC(l){Tp(l)}function Jp(l,c){try{var f=l.onUncaughtError;f(c.value,{componentStack:c.stack})}catch(g){setTimeout(function(){throw g})}}function pC(l,c,f){try{var g=l.onCaughtError;g(f.value,{componentStack:f.stack,errorBoundary:c.tag===1?c.stateNode:null})}catch(y){setTimeout(function(){throw y})}}function x_(l,c,f){return f=Vl(f),f.tag=3,f.payload={element:null},f.callback=function(){Jp(l,c)},f}function mC(l){return l=Vl(l),l.tag=3,l}function gC(l,c,f,g){var y=f.type.getDerivedStateFromError;if(typeof y=="function"){var b=g.value;l.payload=function(){return y(b)},l.callback=function(){pC(c,f,g)}}var E=f.stateNode;E!==null&&typeof E.componentDidCatch=="function"&&(l.callback=function(){pC(c,f,g),typeof y!="function"&&(Jl===null?Jl=new Set([this]):Jl.add(this));var O=g.stack;this.componentDidCatch(g.value,{componentStack:O!==null?O:""})})}function hB(l,c,f,g,y){if(f.flags|=32768,g!==null&&typeof g=="object"&&typeof g.then=="function"){if(c=f.alternate,c!==null&&cu(c,f,y,!0),f=Us.current,f!==null){switch(f.tag){case 31:case 13:return xr===null?hm():f.alternate===null&&Di===0&&(Di=3),f.flags&=-257,f.flags|=65536,f.lanes=y,g===$p?f.flags|=16384:(c=f.updateQueue,c===null?f.updateQueue=new Set([g]):c.add(g),U_(l,g,y)),!1;case 22:return f.flags|=65536,g===$p?f.flags|=16384:(c=f.updateQueue,c===null?(c={transitions:null,markerInstances:null,retryQueue:new Set([g])},f.updateQueue=c):(f=c.retryQueue,f===null?c.retryQueue=new Set([g]):f.add(g)),U_(l,g,y)),!1}throw Error(n(435,f.tag))}return U_(l,g,y),hm(),!1}if(Nt)return c=Us.current,c!==null?((c.flags&65536)===0&&(c.flags|=256),c.flags|=65536,c.lanes=y,g!==zv&&(l=Error(n(422),{cause:g}),Xh(gr(l,f)))):(g!==zv&&(c=Error(n(423),{cause:g}),Xh(gr(c,f))),l=l.current.alternate,l.flags|=65536,y&=-y,l.lanes|=y,g=gr(g,f),y=x_(l.stateNode,g,y),Qv(l,y),Di!==4&&(Di=2)),!1;var b=Error(n(520),{cause:g});if(b=gr(b,f),gd===null?gd=[b]:gd.push(b),Di!==4&&(Di=2),c===null)return!0;g=gr(g,f),f=c;do{switch(f.tag){case 3:return f.flags|=65536,l=y&-y,f.lanes|=l,l=x_(f.stateNode,g,l),Qv(f,l),!1;case 1:if(c=f.type,b=f.stateNode,(f.flags&128)===0&&(typeof c.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(Jl===null||!Jl.has(b))))return f.flags|=65536,y&=-y,f.lanes|=y,y=mC(y),gC(y,l,f,g),Qv(f,y),!1}f=f.return}while(f!==null);return!1}var b_=Error(n(461)),Zi=!1;function Dn(l,c,f,g){c.child=l===null?xk(c,null,f,g):ec(c,l.child,f,g)}function vC(l,c,f,g,y){f=f.render;var b=c.ref;if("ref"in g){var E={};for(var O in g)O!=="ref"&&(E[O]=g[O])}else E=g;return Qa(c),g=i_(l,c,f,E,b,y),O=n_(),l!==null&&!Zi?(s_(l,c,y),el(l,c,y)):(Nt&&O&&Iv(c),c.flags|=1,Dn(l,c,g,y),c.child)}function _C(l,c,f,g,y){if(l===null){var b=f.type;return typeof b=="function"&&!Dv(b)&&b.defaultProps===void 0&&f.compare===null?(c.tag=15,c.type=b,yC(l,c,b,g,y)):(l=Dp(f.type,null,g,c,c.mode,y),l.ref=c.ref,l.return=c,c.child=l)}if(b=l.child,!L_(l,y)){var E=b.memoizedProps;if(f=f.compare,f=f!==null?f:Ua,f(E,g)&&l.ref===c.ref)return el(l,c,y)}return c.flags|=1,l=Yo(b,g),l.ref=c.ref,l.return=c,c.child=l}function yC(l,c,f,g,y){if(l!==null){var b=l.memoizedProps;if(Ua(b,g)&&l.ref===c.ref)if(Zi=!1,c.pendingProps=g=b,L_(l,y))(l.flags&131072)!==0&&(Zi=!0);else return c.lanes=l.lanes,el(l,c,y)}return w_(l,c,f,g,y)}function xC(l,c,f,g){var y=g.children,b=l!==null?l.memoizedState:null;if(l===null&&c.stateNode===null&&(c.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.mode==="hidden"){if((c.flags&128)!==0){if(b=b!==null?b.baseLanes|f:f,l!==null){for(g=c.child=l.child,y=0;g!==null;)y=y|g.lanes|g.childLanes,g=g.sibling;g=y&~b}else g=0,c.child=null;return bC(l,c,b,f,g)}if((f&536870912)!==0)c.memoizedState={baseLanes:0,cachePool:null},l!==null&&Pp(c,b!==null?b.cachePool:null),b!==null?Sk(c,b):Zv(),kk(c);else return g=c.lanes=536870912,bC(l,c,b!==null?b.baseLanes|f:f,f,g)}else b!==null?(Pp(c,b.cachePool),Sk(c,b),Gl(),c.memoizedState=null):(l!==null&&Pp(c,null),Zv(),Gl());return Dn(l,c,y,f),c.child}function cd(l,c){return l!==null&&l.tag===22||c.stateNode!==null||(c.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.sibling}function bC(l,c,f,g,y){var b=Vv();return b=b===null?null:{parent:Qi._currentValue,pool:b},c.memoizedState={baseLanes:f,cachePool:b},l!==null&&Pp(c,null),Zv(),kk(c),l!==null&&cu(l,c,g,!0),c.childLanes=y,null}function em(l,c){return c=im({mode:c.mode,children:c.children},l.mode),c.ref=l.ref,l.child=c,c.return=l,c}function wC(l,c,f){return ec(c,l.child,null,f),l=em(c,c.pendingProps),l.flags|=2,Vs(c),c.memoizedState=null,l}function dB(l,c,f){var g=c.pendingProps,y=(c.flags&128)!==0;if(c.flags&=-129,l===null){if(Nt){if(g.mode==="hidden")return l=em(c,g),c.lanes=536870912,cd(null,l);if(e_(c),(l=xi)?(l=D2(l,yr),l=l!==null&&l.data==="&"?l:null,l!==null&&(c.memoizedState={dehydrated:l,treeContext:Fl!==null?{id:oo,overflow:lo}:null,retryLane:536870912,hydrationErrors:null},f=rk(l),f.return=c,c.child=f,jn=c,xi=null)):l=null,l===null)throw Wl(c);return c.lanes=536870912,null}return em(c,g)}var b=l.memoizedState;if(b!==null){var E=b.dehydrated;if(e_(c),y)if(c.flags&256)c.flags&=-257,c=wC(l,c,f);else if(c.memoizedState!==null)c.child=l.child,c.flags|=128,c=null;else throw Error(n(558));else if(Zi||cu(l,c,f,!1),y=(f&l.childLanes)!==0,Zi||y){if(g=si,g!==null&&(E=Ll(g,f),E!==0&&E!==b.retryLane))throw b.retryLane=E,Va(l,E),Ms(g,l,E),b_;hm(),c=wC(l,c,f)}else l=b.treeContext,xi=br(E.nextSibling),jn=c,Nt=!0,Hl=null,yr=!1,l!==null&&ak(c,l),c=em(c,g),c.flags|=4096;return c}return l=Yo(l.child,{mode:g.mode,children:g.children}),l.ref=c.ref,c.child=l,l.return=c,l}function tm(l,c){var f=c.ref;if(f===null)l!==null&&l.ref!==null&&(c.flags|=4194816);else{if(typeof f!="function"&&typeof f!="object")throw Error(n(284));(l===null||l.ref!==f)&&(c.flags|=4194816)}}function w_(l,c,f,g,y){return Qa(c),f=i_(l,c,f,g,void 0,y),g=n_(),l!==null&&!Zi?(s_(l,c,y),el(l,c,y)):(Nt&&g&&Iv(c),c.flags|=1,Dn(l,c,f,y),c.child)}function SC(l,c,f,g,y,b){return Qa(c),c.updateQueue=null,f=Ek(c,g,f,y),Ck(l),g=n_(),l!==null&&!Zi?(s_(l,c,b),el(l,c,b)):(Nt&&g&&Iv(c),c.flags|=1,Dn(l,c,f,b),c.child)}function kC(l,c,f,g,y){if(Qa(c),c.stateNode===null){var b=ru,E=f.contextType;typeof E=="object"&&E!==null&&(b=Rn(E)),b=new f(g,b),c.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,b.updater=y_,c.stateNode=b,b._reactInternals=c,b=c.stateNode,b.props=g,b.state=c.memoizedState,b.refs={},Yv(c),E=f.contextType,b.context=typeof E=="object"&&E!==null?Rn(E):ru,b.state=c.memoizedState,E=f.getDerivedStateFromProps,typeof E=="function"&&(__(c,f,E,g),b.state=c.memoizedState),typeof f.getDerivedStateFromProps=="function"||typeof b.getSnapshotBeforeUpdate=="function"||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(E=b.state,typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount(),E!==b.state&&y_.enqueueReplaceState(b,b.state,null),sd(c,g,b,y),nd(),b.state=c.memoizedState),typeof b.componentDidMount=="function"&&(c.flags|=4194308),g=!0}else if(l===null){b=c.stateNode;var O=c.memoizedProps,Q=ic(f,O);b.props=Q;var le=b.context,me=f.contextType;E=ru,typeof me=="object"&&me!==null&&(E=Rn(me));var xe=f.getDerivedStateFromProps;me=typeof xe=="function"||typeof b.getSnapshotBeforeUpdate=="function",O=c.pendingProps!==O,me||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(O||le!==E)&&uC(c,b,g,E),Ul=!1;var ce=c.memoizedState;b.state=ce,sd(c,g,b,y),nd(),le=c.memoizedState,O||ce!==le||Ul?(typeof xe=="function"&&(__(c,f,xe,g),le=c.memoizedState),(Q=Ul||cC(c,f,Q,g,ce,le,E))?(me||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount()),typeof b.componentDidMount=="function"&&(c.flags|=4194308)):(typeof b.componentDidMount=="function"&&(c.flags|=4194308),c.memoizedProps=g,c.memoizedState=le),b.props=g,b.state=le,b.context=E,g=Q):(typeof b.componentDidMount=="function"&&(c.flags|=4194308),g=!1)}else{b=c.stateNode,Gv(l,c),E=c.memoizedProps,me=ic(f,E),b.props=me,xe=c.pendingProps,ce=b.context,le=f.contextType,Q=ru,typeof le=="object"&&le!==null&&(Q=Rn(le)),O=f.getDerivedStateFromProps,(le=typeof O=="function"||typeof b.getSnapshotBeforeUpdate=="function")||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(E!==xe||ce!==Q)&&uC(c,b,g,Q),Ul=!1,ce=c.memoizedState,b.state=ce,sd(c,g,b,y),nd();var ue=c.memoizedState;E!==xe||ce!==ue||Ul||l!==null&&l.dependencies!==null&&Op(l.dependencies)?(typeof O=="function"&&(__(c,f,O,g),ue=c.memoizedState),(me=Ul||cC(c,f,me,g,ce,ue,Q)||l!==null&&l.dependencies!==null&&Op(l.dependencies))?(le||typeof b.UNSAFE_componentWillUpdate!="function"&&typeof b.componentWillUpdate!="function"||(typeof b.componentWillUpdate=="function"&&b.componentWillUpdate(g,ue,Q),typeof b.UNSAFE_componentWillUpdate=="function"&&b.UNSAFE_componentWillUpdate(g,ue,Q)),typeof b.componentDidUpdate=="function"&&(c.flags|=4),typeof b.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof b.componentDidUpdate!="function"||E===l.memoizedProps&&ce===l.memoizedState||(c.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||E===l.memoizedProps&&ce===l.memoizedState||(c.flags|=1024),c.memoizedProps=g,c.memoizedState=ue),b.props=g,b.state=ue,b.context=Q,g=me):(typeof b.componentDidUpdate!="function"||E===l.memoizedProps&&ce===l.memoizedState||(c.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||E===l.memoizedProps&&ce===l.memoizedState||(c.flags|=1024),g=!1)}return b=g,tm(l,c),g=(c.flags&128)!==0,b||g?(b=c.stateNode,f=g&&typeof f.getDerivedStateFromError!="function"?null:b.render(),c.flags|=1,l!==null&&g?(c.child=ec(c,l.child,null,y),c.child=ec(c,null,f,y)):Dn(l,c,f,y),c.memoizedState=b.state,l=c.child):l=el(l,c,y),l}function CC(l,c,f,g){return Ya(),c.flags|=256,Dn(l,c,f,g),c.child}var S_={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function k_(l){return{baseLanes:l,cachePool:pk()}}function C_(l,c,f){return l=l!==null?l.childLanes&~f:0,c&&(l|=Ys),l}function EC(l,c,f){var g=c.pendingProps,y=!1,b=(c.flags&128)!==0,E;if((E=b)||(E=l!==null&&l.memoizedState===null?!1:(Hi.current&2)!==0),E&&(y=!0,c.flags&=-129),E=(c.flags&32)!==0,c.flags&=-33,l===null){if(Nt){if(y?Yl(c):Gl(),(l=xi)?(l=D2(l,yr),l=l!==null&&l.data!=="&"?l:null,l!==null&&(c.memoizedState={dehydrated:l,treeContext:Fl!==null?{id:oo,overflow:lo}:null,retryLane:536870912,hydrationErrors:null},f=rk(l),f.return=c,c.child=f,jn=c,xi=null)):l=null,l===null)throw Wl(c);return l1(l)?c.lanes=32:c.lanes=536870912,null}var O=g.children;return g=g.fallback,y?(Gl(),y=c.mode,O=im({mode:"hidden",children:O},y),g=Ka(g,y,f,null),O.return=c,g.return=c,O.sibling=g,c.child=O,g=c.child,g.memoizedState=k_(f),g.childLanes=C_(l,E,f),c.memoizedState=S_,cd(null,g)):(Yl(c),E_(c,O))}var Q=l.memoizedState;if(Q!==null&&(O=Q.dehydrated,O!==null)){if(b)c.flags&256?(Yl(c),c.flags&=-257,c=M_(l,c,f)):c.memoizedState!==null?(Gl(),c.child=l.child,c.flags|=128,c=null):(Gl(),O=g.fallback,y=c.mode,g=im({mode:"visible",children:g.children},y),O=Ka(O,y,f,null),O.flags|=2,g.return=c,O.return=c,g.sibling=O,c.child=g,ec(c,l.child,null,f),g=c.child,g.memoizedState=k_(f),g.childLanes=C_(l,E,f),c.memoizedState=S_,c=cd(null,g));else if(Yl(c),l1(O)){if(E=O.nextSibling&&O.nextSibling.dataset,E)var le=E.dgst;E=le,g=Error(n(419)),g.stack="",g.digest=E,Xh({value:g,source:null,stack:null}),c=M_(l,c,f)}else if(Zi||cu(l,c,f,!1),E=(f&l.childLanes)!==0,Zi||E){if(E=si,E!==null&&(g=Ll(E,f),g!==0&&g!==Q.retryLane))throw Q.retryLane=g,Va(l,g),Ms(E,l,g),b_;o1(O)||hm(),c=M_(l,c,f)}else o1(O)?(c.flags|=192,c.child=l.child,c=null):(l=Q.treeContext,xi=br(O.nextSibling),jn=c,Nt=!0,Hl=null,yr=!1,l!==null&&ak(c,l),c=E_(c,g.children),c.flags|=4096);return c}return y?(Gl(),O=g.fallback,y=c.mode,Q=l.child,le=Q.sibling,g=Yo(Q,{mode:"hidden",children:g.children}),g.subtreeFlags=Q.subtreeFlags&65011712,le!==null?O=Yo(le,O):(O=Ka(O,y,f,null),O.flags|=2),O.return=c,g.return=c,g.sibling=O,c.child=g,cd(null,g),g=c.child,O=l.child.memoizedState,O===null?O=k_(f):(y=O.cachePool,y!==null?(Q=Qi._currentValue,y=y.parent!==Q?{parent:Q,pool:Q}:y):y=pk(),O={baseLanes:O.baseLanes|f,cachePool:y}),g.memoizedState=O,g.childLanes=C_(l,E,f),c.memoizedState=S_,cd(l.child,g)):(Yl(c),f=l.child,l=f.sibling,f=Yo(f,{mode:"visible",children:g.children}),f.return=c,f.sibling=null,l!==null&&(E=c.deletions,E===null?(c.deletions=[l],c.flags|=16):E.push(l)),c.child=f,c.memoizedState=null,f)}function E_(l,c){return c=im({mode:"visible",children:c},l.mode),c.return=l,l.child=c}function im(l,c){return l=qs(22,l,null,c),l.lanes=0,l}function M_(l,c,f){return ec(c,l.child,null,f),l=E_(c,c.pendingProps.children),l.flags|=2,c.memoizedState=null,l}function MC(l,c,f){l.lanes|=c;var g=l.alternate;g!==null&&(g.lanes|=c),Hv(l.return,c,f)}function A_(l,c,f,g,y,b){var E=l.memoizedState;E===null?l.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:g,tail:f,tailMode:y,treeForkCount:b}:(E.isBackwards=c,E.rendering=null,E.renderingStartTime=0,E.last=g,E.tail=f,E.tailMode=y,E.treeForkCount=b)}function AC(l,c,f){var g=c.pendingProps,y=g.revealOrder,b=g.tail;g=g.children;var E=Hi.current,O=(E&2)!==0;if(O?(E=E&1|2,c.flags|=128):E&=1,B(Hi,E),Dn(l,c,g,f),g=Nt?Qh:0,!O&&l!==null&&(l.flags&128)!==0)e:for(l=c.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&MC(l,f,c);else if(l.tag===19)MC(l,f,c);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===c)break e;for(;l.sibling===null;){if(l.return===null||l.return===c)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}switch(y){case"forwards":for(f=c.child,y=null;f!==null;)l=f.alternate,l!==null&&qp(l)===null&&(y=f),f=f.sibling;f=y,f===null?(y=c.child,c.child=null):(y=f.sibling,f.sibling=null),A_(c,!1,y,f,b,g);break;case"backwards":case"unstable_legacy-backwards":for(f=null,y=c.child,c.child=null;y!==null;){if(l=y.alternate,l!==null&&qp(l)===null){c.child=y;break}l=y.sibling,y.sibling=f,f=y,y=l}A_(c,!0,f,null,b,g);break;case"together":A_(c,!1,null,null,void 0,g);break;default:c.memoizedState=null}return c.child}function el(l,c,f){if(l!==null&&(c.dependencies=l.dependencies),Zl|=c.lanes,(f&c.childLanes)===0)if(l!==null){if(cu(l,c,f,!1),(f&c.childLanes)===0)return null}else return null;if(l!==null&&c.child!==l.child)throw Error(n(153));if(c.child!==null){for(l=c.child,f=Yo(l,l.pendingProps),c.child=f,f.return=c;l.sibling!==null;)l=l.sibling,f=f.sibling=Yo(l,l.pendingProps),f.return=c;f.sibling=null}return c.child}function L_(l,c){return(l.lanes&c)!==0?!0:(l=l.dependencies,!!(l!==null&&Op(l)))}function fB(l,c,f){switch(c.tag){case 3:Ee(c,c.stateNode.containerInfo),ql(c,Qi,l.memoizedState.cache),Ya();break;case 27:case 5:Pe(c);break;case 4:Ee(c,c.stateNode.containerInfo);break;case 10:ql(c,c.type,c.memoizedProps.value);break;case 31:if(c.memoizedState!==null)return c.flags|=128,e_(c),null;break;case 13:var g=c.memoizedState;if(g!==null)return g.dehydrated!==null?(Yl(c),c.flags|=128,null):(f&c.child.childLanes)!==0?EC(l,c,f):(Yl(c),l=el(l,c,f),l!==null?l.sibling:null);Yl(c);break;case 19:var y=(l.flags&128)!==0;if(g=(f&c.childLanes)!==0,g||(cu(l,c,f,!1),g=(f&c.childLanes)!==0),y){if(g)return AC(l,c,f);c.flags|=128}if(y=c.memoizedState,y!==null&&(y.rendering=null,y.tail=null,y.lastEffect=null),B(Hi,Hi.current),g)break;return null;case 22:return c.lanes=0,xC(l,c,f,c.pendingProps);case 24:ql(c,Qi,l.memoizedState.cache)}return el(l,c,f)}function LC(l,c,f){if(l!==null)if(l.memoizedProps!==c.pendingProps)Zi=!0;else{if(!L_(l,f)&&(c.flags&128)===0)return Zi=!1,fB(l,c,f);Zi=(l.flags&131072)!==0}else Zi=!1,Nt&&(c.flags&1048576)!==0&&lk(c,Qh,c.index);switch(c.lanes=0,c.tag){case 16:e:{var g=c.pendingProps;if(l=Za(c.elementType),c.type=l,typeof l=="function")Dv(l)?(g=ic(l,g),c.tag=1,c=kC(null,c,l,g,f)):(c.tag=0,c=w_(null,c,l,g,f));else{if(l!=null){var y=l.$$typeof;if(y===N){c.tag=11,c=vC(null,c,l,g,f);break e}else if(y===z){c.tag=14,c=_C(null,c,l,g,f);break e}}throw c=H(l)||l,Error(n(306,c,""))}}return c;case 0:return w_(l,c,c.type,c.pendingProps,f);case 1:return g=c.type,y=ic(g,c.pendingProps),kC(l,c,g,y,f);case 3:e:{if(Ee(c,c.stateNode.containerInfo),l===null)throw Error(n(387));g=c.pendingProps;var b=c.memoizedState;y=b.element,Gv(l,c),sd(c,g,null,f);var E=c.memoizedState;if(g=E.cache,ql(c,Qi,g),g!==b.cache&&Wv(c,[Qi],f,!0),nd(),g=E.element,b.isDehydrated)if(b={element:g,isDehydrated:!1,cache:E.cache},c.updateQueue.baseState=b,c.memoizedState=b,c.flags&256){c=CC(l,c,g,f);break e}else if(g!==y){y=gr(Error(n(424)),c),Xh(y),c=CC(l,c,g,f);break e}else for(l=c.stateNode.containerInfo,l.nodeType===9?l=l.body:l=l.nodeName==="HTML"?l.ownerDocument.body:l,xi=br(l.firstChild),jn=c,Nt=!0,Hl=null,yr=!0,f=xk(c,null,g,f),c.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling;else{if(Ya(),g===y){c=el(l,c,f);break e}Dn(l,c,g,f)}c=c.child}return c;case 26:return tm(l,c),l===null?(f=$2(c.type,null,c.pendingProps,null))?c.memoizedState=f:Nt||(f=c.type,l=c.pendingProps,g=_m(re.current).createElement(f),g[Ni]=c,g[ht]=l,Bn(g,f,l),pi(g),c.stateNode=g):c.memoizedState=$2(c.type,l.memoizedProps,c.pendingProps,l.memoizedState),null;case 27:return Pe(c),l===null&&Nt&&(g=c.stateNode=I2(c.type,c.pendingProps,re.current),jn=c,yr=!0,y=xi,na(c.type)?(a1=y,xi=br(g.firstChild)):xi=y),Dn(l,c,c.pendingProps.children,f),tm(l,c),l===null&&(c.flags|=4194304),c.child;case 5:return l===null&&Nt&&((y=g=xi)&&(g=WB(g,c.type,c.pendingProps,yr),g!==null?(c.stateNode=g,jn=c,xi=br(g.firstChild),yr=!1,y=!0):y=!1),y||Wl(c)),Pe(c),y=c.type,b=c.pendingProps,E=l!==null?l.memoizedProps:null,g=b.children,n1(y,b)?g=null:E!==null&&n1(y,E)&&(c.flags|=32),c.memoizedState!==null&&(y=i_(l,c,sB,null,null,f),kd._currentValue=y),tm(l,c),Dn(l,c,g,f),c.child;case 6:return l===null&&Nt&&((l=f=xi)&&(f=qB(f,c.pendingProps,yr),f!==null?(c.stateNode=f,jn=c,xi=null,l=!0):l=!1),l||Wl(c)),null;case 13:return EC(l,c,f);case 4:return Ee(c,c.stateNode.containerInfo),g=c.pendingProps,l===null?c.child=ec(c,null,g,f):Dn(l,c,g,f),c.child;case 11:return vC(l,c,c.type,c.pendingProps,f);case 7:return Dn(l,c,c.pendingProps,f),c.child;case 8:return Dn(l,c,c.pendingProps.children,f),c.child;case 12:return Dn(l,c,c.pendingProps.children,f),c.child;case 10:return g=c.pendingProps,ql(c,c.type,g.value),Dn(l,c,g.children,f),c.child;case 9:return y=c.type._context,g=c.pendingProps.children,Qa(c),y=Rn(y),g=g(y),c.flags|=1,Dn(l,c,g,f),c.child;case 14:return _C(l,c,c.type,c.pendingProps,f);case 15:return yC(l,c,c.type,c.pendingProps,f);case 19:return AC(l,c,f);case 31:return dB(l,c,f);case 22:return xC(l,c,f,c.pendingProps);case 24:return Qa(c),g=Rn(Qi),l===null?(y=Vv(),y===null&&(y=si,b=qv(),y.pooledCache=b,b.refCount++,b!==null&&(y.pooledCacheLanes|=f),y=b),c.memoizedState={parent:g,cache:y},Yv(c),ql(c,Qi,y)):((l.lanes&f)!==0&&(Gv(l,c),sd(c,null,null,f),nd()),y=l.memoizedState,b=c.memoizedState,y.parent!==g?(y={parent:g,cache:g},c.memoizedState=y,c.lanes===0&&(c.memoizedState=c.updateQueue.baseState=y),ql(c,Qi,g)):(g=b.cache,ql(c,Qi,g),g!==y.cache&&Wv(c,[Qi],f,!0))),Dn(l,c,c.pendingProps.children,f),c.child;case 29:throw c.pendingProps}throw Error(n(156,c.tag))}function tl(l){l.flags|=4}function T_(l,c,f,g,y){if((c=(l.mode&32)!==0)&&(c=!1),c){if(l.flags|=16777216,(y&335544128)===y)if(l.stateNode.complete)l.flags|=8192;else if(i2())l.flags|=8192;else throw Ja=$p,Kv}else l.flags&=-16777217}function TC(l,c){if(c.type!=="stylesheet"||(c.state.loading&4)!==0)l.flags&=-16777217;else if(l.flags|=16777216,!U2(c))if(i2())l.flags|=8192;else throw Ja=$p,Kv}function nm(l,c){c!==null&&(l.flags|=4),l.flags&16384&&(c=l.tag!==22?_s():536870912,l.lanes|=c,bu|=c)}function ud(l,c){if(!Nt)switch(l.tailMode){case"hidden":c=l.tail;for(var f=null;c!==null;)c.alternate!==null&&(f=c),c=c.sibling;f===null?l.tail=null:f.sibling=null;break;case"collapsed":f=l.tail;for(var g=null;f!==null;)f.alternate!==null&&(g=f),f=f.sibling;g===null?c||l.tail===null?l.tail=null:l.tail.sibling=null:g.sibling=null}}function bi(l){var c=l.alternate!==null&&l.alternate.child===l.child,f=0,g=0;if(c)for(var y=l.child;y!==null;)f|=y.lanes|y.childLanes,g|=y.subtreeFlags&65011712,g|=y.flags&65011712,y.return=l,y=y.sibling;else for(y=l.child;y!==null;)f|=y.lanes|y.childLanes,g|=y.subtreeFlags,g|=y.flags,y.return=l,y=y.sibling;return l.subtreeFlags|=g,l.childLanes=f,c}function pB(l,c,f){var g=c.pendingProps;switch(Pv(c),c.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return bi(c),null;case 1:return bi(c),null;case 3:return f=c.stateNode,g=null,l!==null&&(g=l.memoizedState.cache),c.memoizedState.cache!==g&&(c.flags|=2048),Xo(Qi),fe(),f.pendingContext&&(f.context=f.pendingContext,f.pendingContext=null),(l===null||l.child===null)&&(au(c)?tl(c):l===null||l.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,$v())),bi(c),null;case 26:var y=c.type,b=c.memoizedState;return l===null?(tl(c),b!==null?(bi(c),TC(c,b)):(bi(c),T_(c,y,null,g,f))):b?b!==l.memoizedState?(tl(c),bi(c),TC(c,b)):(bi(c),c.flags&=-16777217):(l=l.memoizedProps,l!==g&&tl(c),bi(c),T_(c,y,l,g,f)),null;case 27:if(De(c),f=re.current,y=c.type,l!==null&&c.stateNode!=null)l.memoizedProps!==g&&tl(c);else{if(!g){if(c.stateNode===null)throw Error(n(166));return bi(c),null}l=ee.current,au(c)?ck(c):(l=I2(y,g,f),c.stateNode=l,tl(c))}return bi(c),null;case 5:if(De(c),y=c.type,l!==null&&c.stateNode!=null)l.memoizedProps!==g&&tl(c);else{if(!g){if(c.stateNode===null)throw Error(n(166));return bi(c),null}if(b=ee.current,au(c))ck(c);else{var E=_m(re.current);switch(b){case 1:b=E.createElementNS("http://www.w3.org/2000/svg",y);break;case 2:b=E.createElementNS("http://www.w3.org/1998/Math/MathML",y);break;default:switch(y){case"svg":b=E.createElementNS("http://www.w3.org/2000/svg",y);break;case"math":b=E.createElementNS("http://www.w3.org/1998/Math/MathML",y);break;case"script":b=E.createElement("div"),b.innerHTML="<script><\/script>",b=b.removeChild(b.firstChild);break;case"select":b=typeof g.is=="string"?E.createElement("select",{is:g.is}):E.createElement("select"),g.multiple?b.multiple=!0:g.size&&(b.size=g.size);break;default:b=typeof g.is=="string"?E.createElement(y,{is:g.is}):E.createElement(y)}}b[Ni]=c,b[ht]=g;e:for(E=c.child;E!==null;){if(E.tag===5||E.tag===6)b.appendChild(E.stateNode);else if(E.tag!==4&&E.tag!==27&&E.child!==null){E.child.return=E,E=E.child;continue}if(E===c)break e;for(;E.sibling===null;){if(E.return===null||E.return===c)break e;E=E.return}E.sibling.return=E.return,E=E.sibling}c.stateNode=b;e:switch(Bn(b,y,g),y){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}g&&tl(c)}}return bi(c),T_(c,c.type,l===null?null:l.memoizedProps,c.pendingProps,f),null;case 6:if(l&&c.stateNode!=null)l.memoizedProps!==g&&tl(c);else{if(typeof g!="string"&&c.stateNode===null)throw Error(n(166));if(l=re.current,au(c)){if(l=c.stateNode,f=c.memoizedProps,g=null,y=jn,y!==null)switch(y.tag){case 27:case 5:g=y.memoizedProps}l[Ni]=c,l=!!(l.nodeValue===f||g!==null&&g.suppressHydrationWarning===!0||E2(l.nodeValue,f)),l||Wl(c,!0)}else l=_m(l).createTextNode(g),l[Ni]=c,c.stateNode=l}return bi(c),null;case 31:if(f=c.memoizedState,l===null||l.memoizedState!==null){if(g=au(c),f!==null){if(l===null){if(!g)throw Error(n(318));if(l=c.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(n(557));l[Ni]=c}else Ya(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;bi(c),l=!1}else f=$v(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=f),l=!0;if(!l)return c.flags&256?(Vs(c),c):(Vs(c),null);if((c.flags&128)!==0)throw Error(n(558))}return bi(c),null;case 13:if(g=c.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(y=au(c),g!==null&&g.dehydrated!==null){if(l===null){if(!y)throw Error(n(318));if(y=c.memoizedState,y=y!==null?y.dehydrated:null,!y)throw Error(n(317));y[Ni]=c}else Ya(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;bi(c),y=!1}else y=$v(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=y),y=!0;if(!y)return c.flags&256?(Vs(c),c):(Vs(c),null)}return Vs(c),(c.flags&128)!==0?(c.lanes=f,c):(f=g!==null,l=l!==null&&l.memoizedState!==null,f&&(g=c.child,y=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(y=g.alternate.memoizedState.cachePool.pool),b=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(b=g.memoizedState.cachePool.pool),b!==y&&(g.flags|=2048)),f!==l&&f&&(c.child.flags|=8192),nm(c,c.updateQueue),bi(c),null);case 4:return fe(),l===null&&Z_(c.stateNode.containerInfo),bi(c),null;case 10:return Xo(c.type),bi(c),null;case 19:if(Y(Hi),g=c.memoizedState,g===null)return bi(c),null;if(y=(c.flags&128)!==0,b=g.rendering,b===null)if(y)ud(g,!1);else{if(Di!==0||l!==null&&(l.flags&128)!==0)for(l=c.child;l!==null;){if(b=qp(l),b!==null){for(c.flags|=128,ud(g,!1),l=b.updateQueue,c.updateQueue=l,nm(c,l),c.subtreeFlags=0,l=f,f=c.child;f!==null;)sk(f,l),f=f.sibling;return B(Hi,Hi.current&1|2),Nt&&Go(c,g.treeForkCount),c.child}l=l.sibling}g.tail!==null&&Kt()>am&&(c.flags|=128,y=!0,ud(g,!1),c.lanes=4194304)}else{if(!y)if(l=qp(b),l!==null){if(c.flags|=128,y=!0,l=l.updateQueue,c.updateQueue=l,nm(c,l),ud(g,!0),g.tail===null&&g.tailMode==="hidden"&&!b.alternate&&!Nt)return bi(c),null}else 2*Kt()-g.renderingStartTime>am&&f!==536870912&&(c.flags|=128,y=!0,ud(g,!1),c.lanes=4194304);g.isBackwards?(b.sibling=c.child,c.child=b):(l=g.last,l!==null?l.sibling=b:c.child=b,g.last=b)}return g.tail!==null?(l=g.tail,g.rendering=l,g.tail=l.sibling,g.renderingStartTime=Kt(),l.sibling=null,f=Hi.current,B(Hi,y?f&1|2:f&1),Nt&&Go(c,g.treeForkCount),l):(bi(c),null);case 22:case 23:return Vs(c),Jv(),g=c.memoizedState!==null,l!==null?l.memoizedState!==null!==g&&(c.flags|=8192):g&&(c.flags|=8192),g?(f&536870912)!==0&&(c.flags&128)===0&&(bi(c),c.subtreeFlags&6&&(c.flags|=8192)):bi(c),f=c.updateQueue,f!==null&&nm(c,f.retryQueue),f=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(f=l.memoizedState.cachePool.pool),g=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(g=c.memoizedState.cachePool.pool),g!==f&&(c.flags|=2048),l!==null&&Y(Xa),null;case 24:return f=null,l!==null&&(f=l.memoizedState.cache),c.memoizedState.cache!==f&&(c.flags|=2048),Xo(Qi),bi(c),null;case 25:return null;case 30:return null}throw Error(n(156,c.tag))}function mB(l,c){switch(Pv(c),c.tag){case 1:return l=c.flags,l&65536?(c.flags=l&-65537|128,c):null;case 3:return Xo(Qi),fe(),l=c.flags,(l&65536)!==0&&(l&128)===0?(c.flags=l&-65537|128,c):null;case 26:case 27:case 5:return De(c),null;case 31:if(c.memoizedState!==null){if(Vs(c),c.alternate===null)throw Error(n(340));Ya()}return l=c.flags,l&65536?(c.flags=l&-65537|128,c):null;case 13:if(Vs(c),l=c.memoizedState,l!==null&&l.dehydrated!==null){if(c.alternate===null)throw Error(n(340));Ya()}return l=c.flags,l&65536?(c.flags=l&-65537|128,c):null;case 19:return Y(Hi),null;case 4:return fe(),null;case 10:return Xo(c.type),null;case 22:case 23:return Vs(c),Jv(),l!==null&&Y(Xa),l=c.flags,l&65536?(c.flags=l&-65537|128,c):null;case 24:return Xo(Qi),null;case 25:return null;default:return null}}function NC(l,c){switch(Pv(c),c.tag){case 3:Xo(Qi),fe();break;case 26:case 27:case 5:De(c);break;case 4:fe();break;case 31:c.memoizedState!==null&&Vs(c);break;case 13:Vs(c);break;case 19:Y(Hi);break;case 10:Xo(c.type);break;case 22:case 23:Vs(c),Jv(),l!==null&&Y(Xa);break;case 24:Xo(Qi)}}function hd(l,c){try{var f=c.updateQueue,g=f!==null?f.lastEffect:null;if(g!==null){var y=g.next;f=y;do{if((f.tag&l)===l){g=void 0;var b=f.create,E=f.inst;g=b(),E.destroy=g}f=f.next}while(f!==y)}}catch(O){Jt(c,c.return,O)}}function Ql(l,c,f){try{var g=c.updateQueue,y=g!==null?g.lastEffect:null;if(y!==null){var b=y.next;g=b;do{if((g.tag&l)===l){var E=g.inst,O=E.destroy;if(O!==void 0){E.destroy=void 0,y=c;var Q=f,le=O;try{le()}catch(me){Jt(y,Q,me)}}}g=g.next}while(g!==b)}}catch(me){Jt(c,c.return,me)}}function jC(l){var c=l.updateQueue;if(c!==null){var f=l.stateNode;try{wk(c,f)}catch(g){Jt(l,l.return,g)}}}function RC(l,c,f){f.props=ic(l.type,l.memoizedProps),f.state=l.memoizedState;try{f.componentWillUnmount()}catch(g){Jt(l,c,g)}}function dd(l,c){try{var f=l.ref;if(f!==null){switch(l.tag){case 26:case 27:case 5:var g=l.stateNode;break;case 30:g=l.stateNode;break;default:g=l.stateNode}typeof f=="function"?l.refCleanup=f(g):f.current=g}}catch(y){Jt(l,c,y)}}function ao(l,c){var f=l.ref,g=l.refCleanup;if(f!==null)if(typeof g=="function")try{g()}catch(y){Jt(l,c,y)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof f=="function")try{f(null)}catch(y){Jt(l,c,y)}else f.current=null}function DC(l){var c=l.type,f=l.memoizedProps,g=l.stateNode;try{e:switch(c){case"button":case"input":case"select":case"textarea":f.autoFocus&&g.focus();break e;case"img":f.src?g.src=f.src:f.srcSet&&(g.srcset=f.srcSet)}}catch(y){Jt(l,l.return,y)}}function N_(l,c,f){try{var g=l.stateNode;IB(g,l.type,f,c),g[ht]=c}catch(y){Jt(l,l.return,y)}}function BC(l){return l.tag===5||l.tag===3||l.tag===26||l.tag===27&&na(l.type)||l.tag===4}function j_(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||BC(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.tag===27&&na(l.type)||l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function R_(l,c,f){var g=l.tag;if(g===5||g===6)l=l.stateNode,c?(f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f).insertBefore(l,c):(c=f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f,c.appendChild(l),f=f._reactRootContainer,f!=null||c.onclick!==null||(c.onclick=Nn));else if(g!==4&&(g===27&&na(l.type)&&(f=l.stateNode,c=null),l=l.child,l!==null))for(R_(l,c,f),l=l.sibling;l!==null;)R_(l,c,f),l=l.sibling}function sm(l,c,f){var g=l.tag;if(g===5||g===6)l=l.stateNode,c?f.insertBefore(l,c):f.appendChild(l);else if(g!==4&&(g===27&&na(l.type)&&(f=l.stateNode),l=l.child,l!==null))for(sm(l,c,f),l=l.sibling;l!==null;)sm(l,c,f),l=l.sibling}function OC(l){var c=l.stateNode,f=l.memoizedProps;try{for(var g=l.type,y=c.attributes;y.length;)c.removeAttributeNode(y[0]);Bn(c,g,f),c[Ni]=l,c[ht]=f}catch(b){Jt(l,l.return,b)}}var il=!1,Ji=!1,D_=!1,IC=typeof WeakSet=="function"?WeakSet:Set,_n=null;function gB(l,c){if(l=l.containerInfo,t1=Cm,l=Gh(l),A(l)){if("selectionStart"in l)var f={start:l.selectionStart,end:l.selectionEnd};else e:{f=(f=l.ownerDocument)&&f.defaultView||window;var g=f.getSelection&&f.getSelection();if(g&&g.rangeCount!==0){f=g.anchorNode;var y=g.anchorOffset,b=g.focusNode;g=g.focusOffset;try{f.nodeType,b.nodeType}catch{f=null;break e}var E=0,O=-1,Q=-1,le=0,me=0,xe=l,ce=null;t:for(;;){for(var ue;xe!==f||y!==0&&xe.nodeType!==3||(O=E+y),xe!==b||g!==0&&xe.nodeType!==3||(Q=E+g),xe.nodeType===3&&(E+=xe.nodeValue.length),(ue=xe.firstChild)!==null;)ce=xe,xe=ue;for(;;){if(xe===l)break t;if(ce===f&&++le===y&&(O=E),ce===b&&++me===g&&(Q=E),(ue=xe.nextSibling)!==null)break;xe=ce,ce=xe.parentNode}xe=ue}f=O===-1||Q===-1?null:{start:O,end:Q}}else f=null}f=f||{start:0,end:0}}else f=null;for(i1={focusedElem:l,selectionRange:f},Cm=!1,_n=c;_n!==null;)if(c=_n,l=c.child,(c.subtreeFlags&1028)!==0&&l!==null)l.return=c,_n=l;else for(;_n!==null;){switch(c=_n,b=c.alternate,l=c.flags,c.tag){case 0:if((l&4)!==0&&(l=c.updateQueue,l=l!==null?l.events:null,l!==null))for(f=0;f<l.length;f++)y=l[f],y.ref.impl=y.nextImpl;break;case 11:case 15:break;case 1:if((l&1024)!==0&&b!==null){l=void 0,f=c,y=b.memoizedProps,b=b.memoizedState,g=f.stateNode;try{var $e=ic(f.type,y);l=g.getSnapshotBeforeUpdate($e,b),g.__reactInternalSnapshotBeforeUpdate=l}catch(nt){Jt(f,f.return,nt)}}break;case 3:if((l&1024)!==0){if(l=c.stateNode.containerInfo,f=l.nodeType,f===9)r1(l);else if(f===1)switch(l.nodeName){case"HEAD":case"HTML":case"BODY":r1(l);break;default:l.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((l&1024)!==0)throw Error(n(163))}if(l=c.sibling,l!==null){l.return=c.return,_n=l;break}_n=c.return}}function PC(l,c,f){var g=f.flags;switch(f.tag){case 0:case 11:case 15:sl(l,f),g&4&&hd(5,f);break;case 1:if(sl(l,f),g&4)if(l=f.stateNode,c===null)try{l.componentDidMount()}catch(E){Jt(f,f.return,E)}else{var y=ic(f.type,c.memoizedProps);c=c.memoizedState;try{l.componentDidUpdate(y,c,l.__reactInternalSnapshotBeforeUpdate)}catch(E){Jt(f,f.return,E)}}g&64&&jC(f),g&512&&dd(f,f.return);break;case 3:if(sl(l,f),g&64&&(l=f.updateQueue,l!==null)){if(c=null,f.child!==null)switch(f.child.tag){case 27:case 5:c=f.child.stateNode;break;case 1:c=f.child.stateNode}try{wk(l,c)}catch(E){Jt(f,f.return,E)}}break;case 27:c===null&&g&4&&OC(f);case 26:case 5:sl(l,f),c===null&&g&4&&DC(f),g&512&&dd(f,f.return);break;case 12:sl(l,f);break;case 31:sl(l,f),g&4&&FC(l,f);break;case 13:sl(l,f),g&4&&HC(l,f),g&64&&(l=f.memoizedState,l!==null&&(l=l.dehydrated,l!==null&&(f=CB.bind(null,f),UB(l,f))));break;case 22:if(g=f.memoizedState!==null||il,!g){c=c!==null&&c.memoizedState!==null||Ji,y=il;var b=Ji;il=g,(Ji=c)&&!b?rl(l,f,(f.subtreeFlags&8772)!==0):sl(l,f),il=y,Ji=b}break;case 30:break;default:sl(l,f)}}function zC(l){var c=l.alternate;c!==null&&(l.alternate=null,zC(c)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(c=l.stateNode,c!==null&&Ia(c)),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}var Ei=null,Ss=!1;function nl(l,c,f){for(f=f.child;f!==null;)$C(l,c,f),f=f.sibling}function $C(l,c,f){if(Ht&&typeof Ht.onCommitFiberUnmount=="function")try{Ht.onCommitFiberUnmount(pt,f)}catch{}switch(f.tag){case 26:Ji||ao(f,c),nl(l,c,f),f.memoizedState?f.memoizedState.count--:f.stateNode&&(f=f.stateNode,f.parentNode.removeChild(f));break;case 27:Ji||ao(f,c);var g=Ei,y=Ss;na(f.type)&&(Ei=f.stateNode,Ss=!1),nl(l,c,f),bd(f.stateNode),Ei=g,Ss=y;break;case 5:Ji||ao(f,c);case 6:if(g=Ei,y=Ss,Ei=null,nl(l,c,f),Ei=g,Ss=y,Ei!==null)if(Ss)try{(Ei.nodeType===9?Ei.body:Ei.nodeName==="HTML"?Ei.ownerDocument.body:Ei).removeChild(f.stateNode)}catch(b){Jt(f,c,b)}else try{Ei.removeChild(f.stateNode)}catch(b){Jt(f,c,b)}break;case 18:Ei!==null&&(Ss?(l=Ei,j2(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,f.stateNode),Lu(l)):j2(Ei,f.stateNode));break;case 4:g=Ei,y=Ss,Ei=f.stateNode.containerInfo,Ss=!0,nl(l,c,f),Ei=g,Ss=y;break;case 0:case 11:case 14:case 15:Ql(2,f,c),Ji||Ql(4,f,c),nl(l,c,f);break;case 1:Ji||(ao(f,c),g=f.stateNode,typeof g.componentWillUnmount=="function"&&RC(f,c,g)),nl(l,c,f);break;case 21:nl(l,c,f);break;case 22:Ji=(g=Ji)||f.memoizedState!==null,nl(l,c,f),Ji=g;break;default:nl(l,c,f)}}function FC(l,c){if(c.memoizedState===null&&(l=c.alternate,l!==null&&(l=l.memoizedState,l!==null))){l=l.dehydrated;try{Lu(l)}catch(f){Jt(c,c.return,f)}}}function HC(l,c){if(c.memoizedState===null&&(l=c.alternate,l!==null&&(l=l.memoizedState,l!==null&&(l=l.dehydrated,l!==null))))try{Lu(l)}catch(f){Jt(c,c.return,f)}}function vB(l){switch(l.tag){case 31:case 13:case 19:var c=l.stateNode;return c===null&&(c=l.stateNode=new IC),c;case 22:return l=l.stateNode,c=l._retryCache,c===null&&(c=l._retryCache=new IC),c;default:throw Error(n(435,l.tag))}}function rm(l,c){var f=vB(l);c.forEach(function(g){if(!f.has(g)){f.add(g);var y=EB.bind(null,l,g);g.then(y,y)}})}function ks(l,c){var f=c.deletions;if(f!==null)for(var g=0;g<f.length;g++){var y=f[g],b=l,E=c,O=E;e:for(;O!==null;){switch(O.tag){case 27:if(na(O.type)){Ei=O.stateNode,Ss=!1;break e}break;case 5:Ei=O.stateNode,Ss=!1;break e;case 3:case 4:Ei=O.stateNode.containerInfo,Ss=!0;break e}O=O.return}if(Ei===null)throw Error(n(160));$C(b,E,y),Ei=null,Ss=!1,b=y.alternate,b!==null&&(b.return=null),y.return=null}if(c.subtreeFlags&13886)for(c=c.child;c!==null;)WC(c,l),c=c.sibling}var Vr=null;function WC(l,c){var f=l.alternate,g=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:ks(c,l),Cs(l),g&4&&(Ql(3,l,l.return),hd(3,l),Ql(5,l,l.return));break;case 1:ks(c,l),Cs(l),g&512&&(Ji||f===null||ao(f,f.return)),g&64&&il&&(l=l.updateQueue,l!==null&&(g=l.callbacks,g!==null&&(f=l.shared.hiddenCallbacks,l.shared.hiddenCallbacks=f===null?g:f.concat(g))));break;case 26:var y=Vr;if(ks(c,l),Cs(l),g&512&&(Ji||f===null||ao(f,f.return)),g&4){var b=f!==null?f.memoizedState:null;if(g=l.memoizedState,f===null)if(g===null)if(l.stateNode===null){e:{g=l.type,f=l.memoizedProps,y=y.ownerDocument||y;t:switch(g){case"title":b=y.getElementsByTagName("title")[0],(!b||b[on]||b[Ni]||b.namespaceURI==="http://www.w3.org/2000/svg"||b.hasAttribute("itemprop"))&&(b=y.createElement(g),y.head.insertBefore(b,y.querySelector("head > title"))),Bn(b,g,f),b[Ni]=l,pi(b),g=b;break e;case"link":var E=W2("link","href",y).get(g+(f.href||""));if(E){for(var O=0;O<E.length;O++)if(b=E[O],b.getAttribute("href")===(f.href==null||f.href===""?null:f.href)&&b.getAttribute("rel")===(f.rel==null?null:f.rel)&&b.getAttribute("title")===(f.title==null?null:f.title)&&b.getAttribute("crossorigin")===(f.crossOrigin==null?null:f.crossOrigin)){E.splice(O,1);break t}}b=y.createElement(g),Bn(b,g,f),y.head.appendChild(b);break;case"meta":if(E=W2("meta","content",y).get(g+(f.content||""))){for(O=0;O<E.length;O++)if(b=E[O],b.getAttribute("content")===(f.content==null?null:""+f.content)&&b.getAttribute("name")===(f.name==null?null:f.name)&&b.getAttribute("property")===(f.property==null?null:f.property)&&b.getAttribute("http-equiv")===(f.httpEquiv==null?null:f.httpEquiv)&&b.getAttribute("charset")===(f.charSet==null?null:f.charSet)){E.splice(O,1);break t}}b=y.createElement(g),Bn(b,g,f),y.head.appendChild(b);break;default:throw Error(n(468,g))}b[Ni]=l,pi(b),g=b}l.stateNode=g}else q2(y,l.type,l.stateNode);else l.stateNode=H2(y,g,l.memoizedProps);else b!==g?(b===null?f.stateNode!==null&&(f=f.stateNode,f.parentNode.removeChild(f)):b.count--,g===null?q2(y,l.type,l.stateNode):H2(y,g,l.memoizedProps)):g===null&&l.stateNode!==null&&N_(l,l.memoizedProps,f.memoizedProps)}break;case 27:ks(c,l),Cs(l),g&512&&(Ji||f===null||ao(f,f.return)),f!==null&&g&4&&N_(l,l.memoizedProps,f.memoizedProps);break;case 5:if(ks(c,l),Cs(l),g&512&&(Ji||f===null||ao(f,f.return)),l.flags&32){y=l.stateNode;try{zo(y,"")}catch($e){Jt(l,l.return,$e)}}g&4&&l.stateNode!=null&&(y=l.memoizedProps,N_(l,y,f!==null?f.memoizedProps:y)),g&1024&&(D_=!0);break;case 6:if(ks(c,l),Cs(l),g&4){if(l.stateNode===null)throw Error(n(162));g=l.memoizedProps,f=l.stateNode;try{f.nodeValue=g}catch($e){Jt(l,l.return,$e)}}break;case 3:if(bm=null,y=Vr,Vr=ym(c.containerInfo),ks(c,l),Vr=y,Cs(l),g&4&&f!==null&&f.memoizedState.isDehydrated)try{Lu(c.containerInfo)}catch($e){Jt(l,l.return,$e)}D_&&(D_=!1,qC(l));break;case 4:g=Vr,Vr=ym(l.stateNode.containerInfo),ks(c,l),Cs(l),Vr=g;break;case 12:ks(c,l),Cs(l);break;case 31:ks(c,l),Cs(l),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,rm(l,g)));break;case 13:ks(c,l),Cs(l),l.child.flags&8192&&l.memoizedState!==null!=(f!==null&&f.memoizedState!==null)&&(lm=Kt()),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,rm(l,g)));break;case 22:y=l.memoizedState!==null;var Q=f!==null&&f.memoizedState!==null,le=il,me=Ji;if(il=le||y,Ji=me||Q,ks(c,l),Ji=me,il=le,Cs(l),g&8192)e:for(c=l.stateNode,c._visibility=y?c._visibility&-2:c._visibility|1,y&&(f===null||Q||il||Ji||nc(l)),f=null,c=l;;){if(c.tag===5||c.tag===26){if(f===null){Q=f=c;try{if(b=Q.stateNode,y)E=b.style,typeof E.setProperty=="function"?E.setProperty("display","none","important"):E.display="none";else{O=Q.stateNode;var xe=Q.memoizedProps.style,ce=xe!=null&&xe.hasOwnProperty("display")?xe.display:null;O.style.display=ce==null||typeof ce=="boolean"?"":(""+ce).trim()}}catch($e){Jt(Q,Q.return,$e)}}}else if(c.tag===6){if(f===null){Q=c;try{Q.stateNode.nodeValue=y?"":Q.memoizedProps}catch($e){Jt(Q,Q.return,$e)}}}else if(c.tag===18){if(f===null){Q=c;try{var ue=Q.stateNode;y?R2(ue,!0):R2(Q.stateNode,!1)}catch($e){Jt(Q,Q.return,$e)}}}else if((c.tag!==22&&c.tag!==23||c.memoizedState===null||c===l)&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===l)break e;for(;c.sibling===null;){if(c.return===null||c.return===l)break e;f===c&&(f=null),c=c.return}f===c&&(f=null),c.sibling.return=c.return,c=c.sibling}g&4&&(g=l.updateQueue,g!==null&&(f=g.retryQueue,f!==null&&(g.retryQueue=null,rm(l,f))));break;case 19:ks(c,l),Cs(l),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,rm(l,g)));break;case 30:break;case 21:break;default:ks(c,l),Cs(l)}}function Cs(l){var c=l.flags;if(c&2){try{for(var f,g=l.return;g!==null;){if(BC(g)){f=g;break}g=g.return}if(f==null)throw Error(n(160));switch(f.tag){case 27:var y=f.stateNode,b=j_(l);sm(l,b,y);break;case 5:var E=f.stateNode;f.flags&32&&(zo(E,""),f.flags&=-33);var O=j_(l);sm(l,O,E);break;case 3:case 4:var Q=f.stateNode.containerInfo,le=j_(l);R_(l,le,Q);break;default:throw Error(n(161))}}catch(me){Jt(l,l.return,me)}l.flags&=-3}c&4096&&(l.flags&=-4097)}function qC(l){if(l.subtreeFlags&1024)for(l=l.child;l!==null;){var c=l;qC(c),c.tag===5&&c.flags&1024&&c.stateNode.reset(),l=l.sibling}}function sl(l,c){if(c.subtreeFlags&8772)for(c=c.child;c!==null;)PC(l,c.alternate,c),c=c.sibling}function nc(l){for(l=l.child;l!==null;){var c=l;switch(c.tag){case 0:case 11:case 14:case 15:Ql(4,c,c.return),nc(c);break;case 1:ao(c,c.return);var f=c.stateNode;typeof f.componentWillUnmount=="function"&&RC(c,c.return,f),nc(c);break;case 27:bd(c.stateNode);case 26:case 5:ao(c,c.return),nc(c);break;case 22:c.memoizedState===null&&nc(c);break;case 30:nc(c);break;default:nc(c)}l=l.sibling}}function rl(l,c,f){for(f=f&&(c.subtreeFlags&8772)!==0,c=c.child;c!==null;){var g=c.alternate,y=l,b=c,E=b.flags;switch(b.tag){case 0:case 11:case 15:rl(y,b,f),hd(4,b);break;case 1:if(rl(y,b,f),g=b,y=g.stateNode,typeof y.componentDidMount=="function")try{y.componentDidMount()}catch(le){Jt(g,g.return,le)}if(g=b,y=g.updateQueue,y!==null){var O=g.stateNode;try{var Q=y.shared.hiddenCallbacks;if(Q!==null)for(y.shared.hiddenCallbacks=null,y=0;y<Q.length;y++)bk(Q[y],O)}catch(le){Jt(g,g.return,le)}}f&&E&64&&jC(b),dd(b,b.return);break;case 27:OC(b);case 26:case 5:rl(y,b,f),f&&g===null&&E&4&&DC(b),dd(b,b.return);break;case 12:rl(y,b,f);break;case 31:rl(y,b,f),f&&E&4&&FC(y,b);break;case 13:rl(y,b,f),f&&E&4&&HC(y,b);break;case 22:b.memoizedState===null&&rl(y,b,f),dd(b,b.return);break;case 30:break;default:rl(y,b,f)}c=c.sibling}}function B_(l,c){var f=null;l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(f=l.memoizedState.cachePool.pool),l=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(l=c.memoizedState.cachePool.pool),l!==f&&(l!=null&&l.refCount++,f!=null&&Zh(f))}function O_(l,c){l=null,c.alternate!==null&&(l=c.alternate.memoizedState.cache),c=c.memoizedState.cache,c!==l&&(c.refCount++,l!=null&&Zh(l))}function Kr(l,c,f,g){if(c.subtreeFlags&10256)for(c=c.child;c!==null;)UC(l,c,f,g),c=c.sibling}function UC(l,c,f,g){var y=c.flags;switch(c.tag){case 0:case 11:case 15:Kr(l,c,f,g),y&2048&&hd(9,c);break;case 1:Kr(l,c,f,g);break;case 3:Kr(l,c,f,g),y&2048&&(l=null,c.alternate!==null&&(l=c.alternate.memoizedState.cache),c=c.memoizedState.cache,c!==l&&(c.refCount++,l!=null&&Zh(l)));break;case 12:if(y&2048){Kr(l,c,f,g),l=c.stateNode;try{var b=c.memoizedProps,E=b.id,O=b.onPostCommit;typeof O=="function"&&O(E,c.alternate===null?"mount":"update",l.passiveEffectDuration,-0)}catch(Q){Jt(c,c.return,Q)}}else Kr(l,c,f,g);break;case 31:Kr(l,c,f,g);break;case 13:Kr(l,c,f,g);break;case 23:break;case 22:b=c.stateNode,E=c.alternate,c.memoizedState!==null?b._visibility&2?Kr(l,c,f,g):fd(l,c):b._visibility&2?Kr(l,c,f,g):(b._visibility|=2,_u(l,c,f,g,(c.subtreeFlags&10256)!==0||!1)),y&2048&&B_(E,c);break;case 24:Kr(l,c,f,g),y&2048&&O_(c.alternate,c);break;default:Kr(l,c,f,g)}}function _u(l,c,f,g,y){for(y=y&&((c.subtreeFlags&10256)!==0||!1),c=c.child;c!==null;){var b=l,E=c,O=f,Q=g,le=E.flags;switch(E.tag){case 0:case 11:case 15:_u(b,E,O,Q,y),hd(8,E);break;case 23:break;case 22:var me=E.stateNode;E.memoizedState!==null?me._visibility&2?_u(b,E,O,Q,y):fd(b,E):(me._visibility|=2,_u(b,E,O,Q,y)),y&&le&2048&&B_(E.alternate,E);break;case 24:_u(b,E,O,Q,y),y&&le&2048&&O_(E.alternate,E);break;default:_u(b,E,O,Q,y)}c=c.sibling}}function fd(l,c){if(c.subtreeFlags&10256)for(c=c.child;c!==null;){var f=l,g=c,y=g.flags;switch(g.tag){case 22:fd(f,g),y&2048&&B_(g.alternate,g);break;case 24:fd(f,g),y&2048&&O_(g.alternate,g);break;default:fd(f,g)}c=c.sibling}}var pd=8192;function yu(l,c,f){if(l.subtreeFlags&pd)for(l=l.child;l!==null;)VC(l,c,f),l=l.sibling}function VC(l,c,f){switch(l.tag){case 26:yu(l,c,f),l.flags&pd&&l.memoizedState!==null&&nO(f,Vr,l.memoizedState,l.memoizedProps);break;case 5:yu(l,c,f);break;case 3:case 4:var g=Vr;Vr=ym(l.stateNode.containerInfo),yu(l,c,f),Vr=g;break;case 22:l.memoizedState===null&&(g=l.alternate,g!==null&&g.memoizedState!==null?(g=pd,pd=16777216,yu(l,c,f),pd=g):yu(l,c,f));break;default:yu(l,c,f)}}function KC(l){var c=l.alternate;if(c!==null&&(l=c.child,l!==null)){c.child=null;do c=l.sibling,l.sibling=null,l=c;while(l!==null)}}function md(l){var c=l.deletions;if((l.flags&16)!==0){if(c!==null)for(var f=0;f<c.length;f++){var g=c[f];_n=g,GC(g,l)}KC(l)}if(l.subtreeFlags&10256)for(l=l.child;l!==null;)YC(l),l=l.sibling}function YC(l){switch(l.tag){case 0:case 11:case 15:md(l),l.flags&2048&&Ql(9,l,l.return);break;case 3:md(l);break;case 12:md(l);break;case 22:var c=l.stateNode;l.memoizedState!==null&&c._visibility&2&&(l.return===null||l.return.tag!==13)?(c._visibility&=-3,om(l)):md(l);break;default:md(l)}}function om(l){var c=l.deletions;if((l.flags&16)!==0){if(c!==null)for(var f=0;f<c.length;f++){var g=c[f];_n=g,GC(g,l)}KC(l)}for(l=l.child;l!==null;){switch(c=l,c.tag){case 0:case 11:case 15:Ql(8,c,c.return),om(c);break;case 22:f=c.stateNode,f._visibility&2&&(f._visibility&=-3,om(c));break;default:om(c)}l=l.sibling}}function GC(l,c){for(;_n!==null;){var f=_n;switch(f.tag){case 0:case 11:case 15:Ql(8,f,c);break;case 23:case 22:if(f.memoizedState!==null&&f.memoizedState.cachePool!==null){var g=f.memoizedState.cachePool.pool;g!=null&&g.refCount++}break;case 24:Zh(f.memoizedState.cache)}if(g=f.child,g!==null)g.return=f,_n=g;else e:for(f=l;_n!==null;){g=_n;var y=g.sibling,b=g.return;if(zC(g),g===f){_n=null;break e}if(y!==null){y.return=b,_n=y;break e}_n=b}}}var _B={getCacheForType:function(l){var c=Rn(Qi),f=c.data.get(l);return f===void 0&&(f=l(),c.data.set(l,f)),f},cacheSignal:function(){return Rn(Qi).controller.signal}},yB=typeof WeakMap=="function"?WeakMap:Map,qt=0,si=null,St=null,At=0,Zt=0,Ks=null,Xl=!1,xu=!1,I_=!1,ol=0,Di=0,Zl=0,sc=0,P_=0,Ys=0,bu=0,gd=null,Es=null,z_=!1,lm=0,QC=0,am=1/0,cm=null,Jl=null,un=0,ea=null,wu=null,ll=0,$_=0,F_=null,XC=null,vd=0,H_=null;function Gs(){return(qt&2)!==0&&At!==0?At&-At:P.T!==null?Y_():xs()}function ZC(){if(Ys===0)if((At&536870912)===0||Nt){var l=st;st<<=1,(st&3932160)===0&&(st=262144),Ys=l}else Ys=536870912;return l=Us.current,l!==null&&(l.flags|=32),Ys}function Ms(l,c,f){(l===si&&(Zt===2||Zt===9)||l.cancelPendingCommit!==null)&&(Su(l,0),ta(l,At,Ys,!1)),zr(l,f),((qt&2)===0||l!==si)&&(l===si&&((qt&2)===0&&(sc|=f),Di===4&&ta(l,At,Ys,!1)),co(l))}function JC(l,c,f){if((qt&6)!==0)throw Error(n(327));var g=!f&&(c&127)===0&&(c&l.expiredLanes)===0||to(l,c),y=g?wB(l,c):q_(l,c,!0),b=g;do{if(y===0){xu&&!g&&ta(l,c,0,!1);break}else{if(f=l.current.alternate,b&&!xB(f)){y=q_(l,c,!1),b=!1;continue}if(y===2){if(b=c,l.errorRecoveryDisabledLanes&b)var E=0;else E=l.pendingLanes&-536870913,E=E!==0?E:E&536870912?536870912:0;if(E!==0){c=E;e:{var O=l;y=gd;var Q=O.current.memoizedState.isDehydrated;if(Q&&(Su(O,E).flags|=256),E=q_(O,E,!1),E!==2){if(I_&&!Q){O.errorRecoveryDisabledLanes|=b,sc|=b,y=4;break e}b=Es,Es=y,b!==null&&(Es===null?Es=b:Es.push.apply(Es,b))}y=E}if(b=!1,y!==2)continue}}if(y===1){Su(l,0),ta(l,c,0,!0);break}e:{switch(g=l,b=y,b){case 0:case 1:throw Error(n(345));case 4:if((c&4194048)!==c)break;case 6:ta(g,c,Ys,!Xl);break e;case 2:Es=null;break;case 3:case 5:break;default:throw Error(n(329))}if((c&62914560)===c&&(y=lm+300-Kt(),10<y)){if(ta(g,c,Ys,!Xl),Ds(g,0,!0)!==0)break e;ll=c,g.timeoutHandle=T2(e2.bind(null,g,f,Es,cm,z_,c,Ys,sc,bu,Xl,b,"Throttled",-0,0),y);break e}e2(g,f,Es,cm,z_,c,Ys,sc,bu,Xl,b,null,-0,0)}}break}while(!0);co(l)}function e2(l,c,f,g,y,b,E,O,Q,le,me,xe,ce,ue){if(l.timeoutHandle=-1,xe=c.subtreeFlags,xe&8192||(xe&16785408)===16785408){xe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Nn},VC(c,b,xe);var $e=(b&62914560)===b?lm-Kt():(b&4194048)===b?QC-Kt():0;if($e=sO(xe,$e),$e!==null){ll=b,l.cancelPendingCommit=$e(a2.bind(null,l,c,b,f,g,y,E,O,Q,me,xe,null,ce,ue)),ta(l,b,E,!le);return}}a2(l,c,b,f,g,y,E,O,Q)}function xB(l){for(var c=l;;){var f=c.tag;if((f===0||f===11||f===15)&&c.flags&16384&&(f=c.updateQueue,f!==null&&(f=f.stores,f!==null)))for(var g=0;g<f.length;g++){var y=f[g],b=y.getSnapshot;y=y.value;try{if(!ts(b(),y))return!1}catch{return!1}}if(f=c.child,c.subtreeFlags&16384&&f!==null)f.return=c,c=f;else{if(c===l)break;for(;c.sibling===null;){if(c.return===null||c.return===l)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function ta(l,c,f,g){c&=~P_,c&=~sc,l.suspendedLanes|=c,l.pingedLanes&=~c,g&&(l.warmLanes|=c),g=l.expirationTimes;for(var y=c;0<y;){var b=31-Tt(y),E=1<<b;g[b]=-1,y&=~E}f!==0&&ar(l,f,c)}function um(){return(qt&6)===0?(_d(0),!1):!0}function W_(){if(St!==null){if(Zt===0)var l=St.return;else l=St,Qo=Ga=null,r_(l),fu=null,ed=0,l=St;for(;l!==null;)NC(l.alternate,l),l=l.return;St=null}}function Su(l,c){var f=l.timeoutHandle;f!==-1&&(l.timeoutHandle=-1,$B(f)),f=l.cancelPendingCommit,f!==null&&(l.cancelPendingCommit=null,f()),ll=0,W_(),si=l,St=f=Yo(l.current,null),At=c,Zt=0,Ks=null,Xl=!1,xu=to(l,c),I_=!1,bu=Ys=P_=sc=Zl=Di=0,Es=gd=null,z_=!1,(c&8)!==0&&(c|=c&32);var g=l.entangledLanes;if(g!==0)for(l=l.entanglements,g&=c;0<g;){var y=31-Tt(g),b=1<<y;c|=l[y],g&=~b}return ol=c,Np(),f}function t2(l,c){dt=null,P.H=ad,c===du||c===zp?(c=vk(),Zt=3):c===Kv?(c=vk(),Zt=4):Zt=c===b_?8:c!==null&&typeof c=="object"&&typeof c.then=="function"?6:1,Ks=c,St===null&&(Di=1,Jp(l,gr(c,l.current)))}function i2(){var l=Us.current;return l===null?!0:(At&4194048)===At?xr===null:(At&62914560)===At||(At&536870912)!==0?l===xr:!1}function n2(){var l=P.H;return P.H=ad,l===null?ad:l}function s2(){var l=P.A;return P.A=_B,l}function hm(){Di=4,Xl||(At&4194048)!==At&&Us.current!==null||(xu=!0),(Zl&134217727)===0&&(sc&134217727)===0||si===null||ta(si,At,Ys,!1)}function q_(l,c,f){var g=qt;qt|=2;var y=n2(),b=s2();(si!==l||At!==c)&&(cm=null,Su(l,c)),c=!1;var E=Di;e:do try{if(Zt!==0&&St!==null){var O=St,Q=Ks;switch(Zt){case 8:W_(),E=6;break e;case 3:case 2:case 9:case 6:Us.current===null&&(c=!0);var le=Zt;if(Zt=0,Ks=null,ku(l,O,Q,le),f&&xu){E=0;break e}break;default:le=Zt,Zt=0,Ks=null,ku(l,O,Q,le)}}bB(),E=Di;break}catch(me){t2(l,me)}while(!0);return c&&l.shellSuspendCounter++,Qo=Ga=null,qt=g,P.H=y,P.A=b,St===null&&(si=null,At=0,Np()),E}function bB(){for(;St!==null;)r2(St)}function wB(l,c){var f=qt;qt|=2;var g=n2(),y=s2();si!==l||At!==c?(cm=null,am=Kt()+500,Su(l,c)):xu=to(l,c);e:do try{if(Zt!==0&&St!==null){c=St;var b=Ks;t:switch(Zt){case 1:Zt=0,Ks=null,ku(l,c,b,1);break;case 2:case 9:if(mk(b)){Zt=0,Ks=null,o2(c);break}c=function(){Zt!==2&&Zt!==9||si!==l||(Zt=7),co(l)},b.then(c,c);break e;case 3:Zt=7;break e;case 4:Zt=5;break e;case 7:mk(b)?(Zt=0,Ks=null,o2(c)):(Zt=0,Ks=null,ku(l,c,b,7));break;case 5:var E=null;switch(St.tag){case 26:E=St.memoizedState;case 5:case 27:var O=St;if(E?U2(E):O.stateNode.complete){Zt=0,Ks=null;var Q=O.sibling;if(Q!==null)St=Q;else{var le=O.return;le!==null?(St=le,dm(le)):St=null}break t}}Zt=0,Ks=null,ku(l,c,b,5);break;case 6:Zt=0,Ks=null,ku(l,c,b,6);break;case 8:W_(),Di=6;break e;default:throw Error(n(462))}}SB();break}catch(me){t2(l,me)}while(!0);return Qo=Ga=null,P.H=g,P.A=y,qt=f,St!==null?0:(si=null,At=0,Np(),Di)}function SB(){for(;St!==null&&!fi();)r2(St)}function r2(l){var c=LC(l.alternate,l,ol);l.memoizedProps=l.pendingProps,c===null?dm(l):St=c}function o2(l){var c=l,f=c.alternate;switch(c.tag){case 15:case 0:c=SC(f,c,c.pendingProps,c.type,void 0,At);break;case 11:c=SC(f,c,c.pendingProps,c.type.render,c.ref,At);break;case 5:r_(c);default:NC(f,c),c=St=sk(c,ol),c=LC(f,c,ol)}l.memoizedProps=l.pendingProps,c===null?dm(l):St=c}function ku(l,c,f,g){Qo=Ga=null,r_(c),fu=null,ed=0;var y=c.return;try{if(hB(l,y,c,f,At)){Di=1,Jp(l,gr(f,l.current)),St=null;return}}catch(b){if(y!==null)throw St=y,b;Di=1,Jp(l,gr(f,l.current)),St=null;return}c.flags&32768?(Nt||g===1?l=!0:xu||(At&536870912)!==0?l=!1:(Xl=l=!0,(g===2||g===9||g===3||g===6)&&(g=Us.current,g!==null&&g.tag===13&&(g.flags|=16384))),l2(c,l)):dm(c)}function dm(l){var c=l;do{if((c.flags&32768)!==0){l2(c,Xl);return}l=c.return;var f=pB(c.alternate,c,ol);if(f!==null){St=f;return}if(c=c.sibling,c!==null){St=c;return}St=c=l}while(c!==null);Di===0&&(Di=5)}function l2(l,c){do{var f=mB(l.alternate,l);if(f!==null){f.flags&=32767,St=f;return}if(f=l.return,f!==null&&(f.flags|=32768,f.subtreeFlags=0,f.deletions=null),!c&&(l=l.sibling,l!==null)){St=l;return}St=l=f}while(l!==null);Di=6,St=null}function a2(l,c,f,g,y,b,E,O,Q){l.cancelPendingCommit=null;do fm();while(un!==0);if((qt&6)!==0)throw Error(n(327));if(c!==null){if(c===l.current)throw Error(n(177));if(b=c.lanes|c.childLanes,b|=jv,io(l,f,b,E,O,Q),l===si&&(St=si=null,At=0),wu=c,ea=l,ll=f,$_=b,F_=y,XC=g,(c.subtreeFlags&10256)!==0||(c.flags&10256)!==0?(l.callbackNode=null,l.callbackPriority=0,MB(Ke,function(){return f2(),null})):(l.callbackNode=null,l.callbackPriority=0),g=(c.flags&13878)!==0,(c.subtreeFlags&13878)!==0||g){g=P.T,P.T=null,y=U.p,U.p=2,E=qt,qt|=4;try{gB(l,c,f)}finally{qt=E,U.p=y,P.T=g}}un=1,c2(),u2(),h2()}}function c2(){if(un===1){un=0;var l=ea,c=wu,f=(c.flags&13878)!==0;if((c.subtreeFlags&13878)!==0||f){f=P.T,P.T=null;var g=U.p;U.p=2;var y=qt;qt|=4;try{WC(c,l);var b=i1,E=Gh(l.containerInfo),O=b.focusedElem,Q=b.selectionRange;if(E!==O&&O&&O.ownerDocument&&Yh(O.ownerDocument.documentElement,O)){if(Q!==null&&A(O)){var le=Q.start,me=Q.end;if(me===void 0&&(me=le),"selectionStart"in O)O.selectionStart=le,O.selectionEnd=Math.min(me,O.value.length);else{var xe=O.ownerDocument||document,ce=xe&&xe.defaultView||window;if(ce.getSelection){var ue=ce.getSelection(),$e=O.textContent.length,nt=Math.min(Q.start,$e),ii=Q.end===void 0?nt:Math.min(Q.end,$e);!ue.extend&&nt>ii&&(E=ii,ii=nt,nt=E);var ne=Ap(O,nt),te=Ap(O,ii);if(ne&&te&&(ue.rangeCount!==1||ue.anchorNode!==ne.node||ue.anchorOffset!==ne.offset||ue.focusNode!==te.node||ue.focusOffset!==te.offset)){var oe=xe.createRange();oe.setStart(ne.node,ne.offset),ue.removeAllRanges(),nt>ii?(ue.addRange(oe),ue.extend(te.node,te.offset)):(oe.setEnd(te.node,te.offset),ue.addRange(oe))}}}}for(xe=[],ue=O;ue=ue.parentNode;)ue.nodeType===1&&xe.push({element:ue,left:ue.scrollLeft,top:ue.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;O<xe.length;O++){var ye=xe[O];ye.element.scrollLeft=ye.left,ye.element.scrollTop=ye.top}}Cm=!!t1,i1=t1=null}finally{qt=y,U.p=g,P.T=f}}l.current=c,un=2}}function u2(){if(un===2){un=0;var l=ea,c=wu,f=(c.flags&8772)!==0;if((c.subtreeFlags&8772)!==0||f){f=P.T,P.T=null;var g=U.p;U.p=2;var y=qt;qt|=4;try{PC(l,c.alternate,c)}finally{qt=y,U.p=g,P.T=f}}un=3}}function h2(){if(un===4||un===3){un=0,Mt();var l=ea,c=wu,f=ll,g=XC;(c.subtreeFlags&10256)!==0||(c.flags&10256)!==0?un=5:(un=0,wu=ea=null,d2(l,l.pendingLanes));var y=l.pendingLanes;if(y===0&&(Jl=null),$r(f),c=c.stateNode,Ht&&typeof Ht.onCommitFiberRoot=="function")try{Ht.onCommitFiberRoot(pt,c,void 0,(c.current.flags&128)===128)}catch{}if(g!==null){c=P.T,y=U.p,U.p=2,P.T=null;try{for(var b=l.onRecoverableError,E=0;E<g.length;E++){var O=g[E];b(O.value,{componentStack:O.stack})}}finally{P.T=c,U.p=y}}(ll&3)!==0&&fm(),co(l),y=l.pendingLanes,(f&261930)!==0&&(y&42)!==0?l===H_?vd++:(vd=0,H_=l):vd=0,_d(0)}}function d2(l,c){(l.pooledCacheLanes&=c)===0&&(c=l.pooledCache,c!=null&&(l.pooledCache=null,Zh(c)))}function fm(){return c2(),u2(),h2(),f2()}function f2(){if(un!==5)return!1;var l=ea,c=$_;$_=0;var f=$r(ll),g=P.T,y=U.p;try{U.p=32>f?32:f,P.T=null,f=F_,F_=null;var b=ea,E=ll;if(un=0,wu=ea=null,ll=0,(qt&6)!==0)throw Error(n(331));var O=qt;if(qt|=4,YC(b.current),UC(b,b.current,E,f),qt=O,_d(0,!1),Ht&&typeof Ht.onPostCommitFiberRoot=="function")try{Ht.onPostCommitFiberRoot(pt,b)}catch{}return!0}finally{U.p=y,P.T=g,d2(l,c)}}function p2(l,c,f){c=gr(f,c),c=x_(l.stateNode,c,2),l=Kl(l,c,2),l!==null&&(zr(l,2),co(l))}function Jt(l,c,f){if(l.tag===3)p2(l,l,f);else for(;c!==null;){if(c.tag===3){p2(c,l,f);break}else if(c.tag===1){var g=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Jl===null||!Jl.has(g))){l=gr(f,l),f=mC(2),g=Kl(c,f,2),g!==null&&(gC(f,g,c,l),zr(g,2),co(g));break}}c=c.return}}function U_(l,c,f){var g=l.pingCache;if(g===null){g=l.pingCache=new yB;var y=new Set;g.set(c,y)}else y=g.get(c),y===void 0&&(y=new Set,g.set(c,y));y.has(f)||(I_=!0,y.add(f),l=kB.bind(null,l,c,f),c.then(l,l))}function kB(l,c,f){var g=l.pingCache;g!==null&&g.delete(c),l.pingedLanes|=l.suspendedLanes&f,l.warmLanes&=~f,si===l&&(At&f)===f&&(Di===4||Di===3&&(At&62914560)===At&&300>Kt()-lm?(qt&2)===0&&Su(l,0):P_|=f,bu===At&&(bu=0)),co(l)}function m2(l,c){c===0&&(c=_s()),l=Va(l,c),l!==null&&(zr(l,c),co(l))}function CB(l){var c=l.memoizedState,f=0;c!==null&&(f=c.retryLane),m2(l,f)}function EB(l,c){var f=0;switch(l.tag){case 31:case 13:var g=l.stateNode,y=l.memoizedState;y!==null&&(f=y.retryLane);break;case 19:g=l.stateNode;break;case 22:g=l.stateNode._retryCache;break;default:throw Error(n(314))}g!==null&&g.delete(c),m2(l,f)}function MB(l,c){return Ze(l,c)}var pm=null,Cu=null,V_=!1,mm=!1,K_=!1,ia=0;function co(l){l!==Cu&&l.next===null&&(Cu===null?pm=Cu=l:Cu=Cu.next=l),mm=!0,V_||(V_=!0,LB())}function _d(l,c){if(!K_&&mm){K_=!0;do for(var f=!1,g=pm;g!==null;){if(l!==0){var y=g.pendingLanes;if(y===0)var b=0;else{var E=g.suspendedLanes,O=g.pingedLanes;b=(1<<31-Tt(42|l)+1)-1,b&=y&~(E&~O),b=b&201326741?b&201326741|1:b?b|2:0}b!==0&&(f=!0,y2(g,b))}else b=At,b=Ds(g,g===si?b:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(b&3)===0||to(g,b)||(f=!0,y2(g,b));g=g.next}while(f);K_=!1}}function AB(){g2()}function g2(){mm=V_=!1;var l=0;ia!==0&&zB()&&(l=ia);for(var c=Kt(),f=null,g=pm;g!==null;){var y=g.next,b=v2(g,c);b===0?(g.next=null,f===null?pm=y:f.next=y,y===null&&(Cu=f)):(f=g,(l!==0||(b&3)!==0)&&(mm=!0)),g=y}un!==0&&un!==5||_d(l),ia!==0&&(ia=0)}function v2(l,c){for(var f=l.suspendedLanes,g=l.pingedLanes,y=l.expirationTimes,b=l.pendingLanes&-62914561;0<b;){var E=31-Tt(b),O=1<<E,Q=y[E];Q===-1?((O&f)===0||(O&g)!==0)&&(y[E]=Bs(O,c)):Q<=c&&(l.expiredLanes|=O),b&=~O}if(c=si,f=At,f=Ds(l,l===c?f:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),g=l.callbackNode,f===0||l===c&&(Zt===2||Zt===9)||l.cancelPendingCommit!==null)return g!==null&&g!==null&&ve(g),l.callbackNode=null,l.callbackPriority=0;if((f&3)===0||to(l,f)){if(c=f&-f,c===l.callbackPriority)return c;switch(g!==null&&ve(g),$r(f)){case 2:case 8:f=Me;break;case 32:f=Ke;break;case 268435456:f=ot;break;default:f=Ke}return g=_2.bind(null,l),f=Ze(f,g),l.callbackPriority=c,l.callbackNode=f,c}return g!==null&&g!==null&&ve(g),l.callbackPriority=2,l.callbackNode=null,2}function _2(l,c){if(un!==0&&un!==5)return l.callbackNode=null,l.callbackPriority=0,null;var f=l.callbackNode;if(fm()&&l.callbackNode!==f)return null;var g=At;return g=Ds(l,l===si?g:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),g===0?null:(JC(l,g,c),v2(l,Kt()),l.callbackNode!=null&&l.callbackNode===f?_2.bind(null,l):null)}function y2(l,c){if(fm())return null;JC(l,c,!0)}function LB(){FB(function(){(qt&6)!==0?Ze(de,AB):g2()})}function Y_(){if(ia===0){var l=uu;l===0&&(l=lr,lr<<=1,(lr&261888)===0&&(lr=256)),ia=l}return ia}function x2(l){return l==null||typeof l=="symbol"||typeof l=="boolean"?null:typeof l=="function"?l:Gc(""+l)}function b2(l,c){var f=c.ownerDocument.createElement("input");return f.name=c.name,f.value=c.value,l.id&&f.setAttribute("form",l.id),c.parentNode.insertBefore(f,c),l=new FormData(l),f.parentNode.removeChild(f),l}function TB(l,c,f,g,y){if(c==="submit"&&f&&f.stateNode===y){var b=x2((y[ht]||null).action),E=g.submitter;E&&(c=(c=E[ht]||null)?x2(c.formAction):E.getAttribute("formAction"),c!==null&&(b=c,E=null));var O=new $a("action","action",null,g,y);l.push({event:O,listeners:[{instance:null,listener:function(){if(g.defaultPrevented){if(ia!==0){var Q=E?b2(y,E):new FormData(y);p_(f,{pending:!0,data:Q,method:y.method,action:b},null,Q)}}else typeof b=="function"&&(O.preventDefault(),Q=E?b2(y,E):new FormData(y),p_(f,{pending:!0,data:Q,method:y.method,action:b},b,Q))},currentTarget:y}]})}}for(var G_=0;G_<$l.length;G_++){var Q_=$l[G_],NB=Q_.toLowerCase(),jB=Q_[0].toUpperCase()+Q_.slice(1);Ur(NB,"on"+jB)}Ur(Ot,"onAnimationEnd"),Ur(ji,"onAnimationIteration"),Ur(is,"onAnimationStart"),Ur("dblclick","onDoubleClick"),Ur("focusin","onFocus"),Ur("focusout","onBlur"),Ur(Un,"onTransitionRun"),Ur(Fi,"onTransitionStart"),Ur(Lp,"onTransitionCancel"),Ur(Wt,"onTransitionEnd"),ln("onMouseEnter",["mouseout","mouseover"]),ln("onMouseLeave",["mouseout","mouseover"]),ln("onPointerEnter",["pointerout","pointerover"]),ln("onPointerLeave",["pointerout","pointerover"]),es("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),es("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),es("onBeforeInput",["compositionend","keypress","textInput","paste"]),es("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),es("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),es("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var yd="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(" "),RB=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(yd));function w2(l,c){c=(c&4)!==0;for(var f=0;f<l.length;f++){var g=l[f],y=g.event;g=g.listeners;e:{var b=void 0;if(c)for(var E=g.length-1;0<=E;E--){var O=g[E],Q=O.instance,le=O.currentTarget;if(O=O.listener,Q!==b&&y.isPropagationStopped())break e;b=O,y.currentTarget=le;try{b(y)}catch(me){Tp(me)}y.currentTarget=null,b=Q}else for(E=0;E<g.length;E++){if(O=g[E],Q=O.instance,le=O.currentTarget,O=O.listener,Q!==b&&y.isPropagationStopped())break e;b=O,y.currentTarget=le;try{b(y)}catch(me){Tp(me)}y.currentTarget=null,b=Q}}}}function kt(l,c){var f=c[$i];f===void 0&&(f=c[$i]=new Set);var g=l+"__bubble";f.has(g)||(S2(c,l,2,!1),f.add(g))}function X_(l,c,f){var g=0;c&&(g|=4),S2(f,l,g,c)}var gm="_reactListening"+Math.random().toString(36).slice(2);function Z_(l){if(!l[gm]){l[gm]=!0,Ci.forEach(function(f){f!=="selectionchange"&&(RB.has(f)||X_(f,!1,l),X_(f,!0,l))});var c=l.nodeType===9?l:l.ownerDocument;c===null||c[gm]||(c[gm]=!0,X_("selectionchange",!1,c))}}function S2(l,c,f,g){switch(Z2(c)){case 2:var y=lO;break;case 8:y=aO;break;default:y=f1}f=y.bind(null,c,f,l),y=void 0,!Tl||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(y=!0),g?y!==void 0?l.addEventListener(c,f,{capture:!0,passive:y}):l.addEventListener(c,f,!0):y!==void 0?l.addEventListener(c,f,{passive:y}):l.addEventListener(c,f,!1)}function J_(l,c,f,g,y){var b=g;if((c&1)===0&&(c&2)===0&&g!==null)e:for(;;){if(g===null)return;var E=g.tag;if(E===3||E===4){var O=g.stateNode.containerInfo;if(O===y)break;if(E===4)for(E=g.return;E!==null;){var Q=E.tag;if((Q===3||Q===4)&&E.stateNode.containerInfo===y)return;E=E.return}for(;O!==null;){if(E=no(O),E===null)return;if(Q=E.tag,Q===5||Q===6||Q===26||Q===27){g=b=E;continue e}O=O.parentNode}}g=g.return}dp(function(){var le=b,me=Xc(f),xe=[];e:{var ce=ns.get(l);if(ce!==void 0){var ue=$a,$e=l;switch(l){case"keypress":if(Nl(f)===0)break e;case"keydown":case"keyup":ue=Ev;break;case"focusin":$e="focus",ue=ro;break;case"focusout":$e="blur",ue=ro;break;case"beforeblur":case"afterblur":ue=ro;break;case"click":if(f.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ue=pp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ue=Jc;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ue=qo;break;case Ot:case ji:case is:ue=Ho;break;case Wt:ue=Mv;break;case"scroll":case"scrollend":ue=bv;break;case"wheel":ue=eu;break;case"copy":case"cut":case"paste":ue=fr;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ue=xp;break;case"toggle":case"beforetoggle":ue=bp}var nt=(c&4)!==0,ii=!nt&&(l==="scroll"||l==="scrollend"),ne=nt?ce!==null?ce+"Capture":null:ce;nt=[];for(var te=le,oe;te!==null;){var ye=te;if(oe=ye.stateNode,ye=ye.tag,ye!==5&&ye!==26&&ye!==27||oe===null||ne===null||(ye=Fo(te,ne),ye!=null&&nt.push(xd(te,ye,oe))),ii)break;te=te.return}0<nt.length&&(ce=new ue(ce,$e,null,f,me),xe.push({event:ce,listeners:nt}))}}if((c&7)===0){e:{if(ce=l==="mouseover"||l==="pointerover",ue=l==="mouseout"||l==="pointerout",ce&&f!==Qc&&($e=f.relatedTarget||f.fromElement)&&(no($e)||$e[Fn]))break e;if((ue||ce)&&(ce=me.window===me?me:(ce=me.ownerDocument)?ce.defaultView||ce.parentWindow:window,ue?($e=f.relatedTarget||f.toElement,ue=le,$e=$e?no($e):null,$e!==null&&(ii=r($e),nt=$e.tag,$e!==ii||nt!==5&&nt!==27&&nt!==6)&&($e=null)):(ue=null,$e=le),ue!==$e)){if(nt=pp,ye="onMouseLeave",ne="onMouseEnter",te="mouse",(l==="pointerout"||l==="pointerover")&&(nt=xp,ye="onPointerLeave",ne="onPointerEnter",te="pointer"),ii=ue==null?ce:Fr(ue),oe=$e==null?ce:Fr($e),ce=new nt(ye,te+"leave",ue,f,me),ce.target=ii,ce.relatedTarget=oe,ye=null,no(me)===le&&(nt=new nt(ne,te+"enter",$e,f,me),nt.target=oe,nt.relatedTarget=ii,ye=nt),ii=ye,ue&&$e)t:{for(nt=DB,ne=ue,te=$e,oe=0,ye=ne;ye;ye=nt(ye))oe++;ye=0;for(var Xe=te;Xe;Xe=nt(Xe))ye++;for(;0<oe-ye;)ne=nt(ne),oe--;for(;0<ye-oe;)te=nt(te),ye--;for(;oe--;){if(ne===te||te!==null&&ne===te.alternate){nt=ne;break t}ne=nt(ne),te=nt(te)}nt=null}else nt=null;ue!==null&&k2(xe,ce,ue,nt,!1),$e!==null&&ii!==null&&k2(xe,ii,$e,nt,!0)}}e:{if(ce=le?Fr(le):window,ue=ce.nodeName&&ce.nodeName.toLowerCase(),ue==="select"||ue==="input"&&ce.type==="file")var zt=Ko;else if(qh(ce))if(wp)zt=Mp;else{zt=Tv;var qe=Ep}else ue=ce.nodeName,!ue||ue.toLowerCase()!=="input"||ce.type!=="checkbox"&&ce.type!=="radio"?le&&hr(le.elementType)&&(zt=Ko):zt=Nv;if(zt&&(zt=zt(l,le))){Uh(xe,zt,f,me);break e}qe&&qe(l,ce,le),l==="focusout"&&le&&ce.type==="number"&&le.memoizedProps.value!=null&&Vc(ce,"number",ce.value)}switch(qe=le?Fr(le):window,l){case"focusin":(qh(qe)||qe.contentEditable==="true")&&(Z=qe,se=le,pe=null);break;case"focusout":pe=se=Z=null;break;case"mousedown":ke=!0;break;case"contextmenu":case"mouseup":case"dragend":ke=!1,Ne(xe,f,me);break;case"selectionchange":if(W)break;case"keydown":case"keyup":Ne(xe,f,me)}var ft;if(Bl)e:{switch(l){case"compositionstart":var Lt="onCompositionStart";break e;case"compositionend":Lt="onCompositionEnd";break e;case"compositionupdate":Lt="onCompositionUpdate";break e}Lt=void 0}else Vo?Il(l,f)&&(Lt="onCompositionEnd"):l==="keydown"&&f.keyCode===229&&(Lt="onCompositionStart");Lt&&(Uo&&f.locale!=="ko"&&(Vo||Lt!=="onCompositionStart"?Lt==="onCompositionEnd"&&Vo&&(ft=Ih()):(cn=me,Oh="value"in cn?cn.value:cn.textContent,Vo=!0)),qe=vm(le,Lt),0<qe.length&&(Lt=new Ph(Lt,l,null,f,me),xe.push({event:Lt,listeners:qe}),ft?Lt.data=ft:(ft=Hh(f),ft!==null&&(Lt.data=ft)))),(ft=zh?iu(l,f):Wh(l,f))&&(Lt=vm(le,"onBeforeInput"),0<Lt.length&&(qe=new Ph("onBeforeInput","beforeinput",null,f,me),xe.push({event:qe,listeners:Lt}),qe.data=ft)),TB(xe,l,le,f,me)}w2(xe,c)})}function xd(l,c,f){return{instance:l,listener:c,currentTarget:f}}function vm(l,c){for(var f=c+"Capture",g=[];l!==null;){var y=l,b=y.stateNode;if(y=y.tag,y!==5&&y!==26&&y!==27||b===null||(y=Fo(l,f),y!=null&&g.unshift(xd(l,y,b)),y=Fo(l,c),y!=null&&g.push(xd(l,y,b))),l.tag===3)return g;l=l.return}return[]}function DB(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5&&l.tag!==27);return l||null}function k2(l,c,f,g,y){for(var b=c._reactName,E=[];f!==null&&f!==g;){var O=f,Q=O.alternate,le=O.stateNode;if(O=O.tag,Q!==null&&Q===g)break;O!==5&&O!==26&&O!==27||le===null||(Q=le,y?(le=Fo(f,b),le!=null&&E.unshift(xd(f,le,Q))):y||(le=Fo(f,b),le!=null&&E.push(xd(f,le,Q)))),f=f.return}E.length!==0&&l.push({event:c,listeners:E})}var BB=/\r\n?/g,OB=/\u0000|\uFFFD/g;function C2(l){return(typeof l=="string"?l:""+l).replace(BB,`
|
|
10
|
+
`).replace(OB,"")}function E2(l,c){return c=C2(c),C2(l)===c}function ti(l,c,f,g,y,b){switch(f){case"children":typeof g=="string"?c==="body"||c==="textarea"&&g===""||zo(l,g):(typeof g=="number"||typeof g=="bigint")&&c!=="body"&&zo(l,""+g);break;case"className":Wn(l,"class",g);break;case"tabIndex":Wn(l,"tabindex",g);break;case"dir":case"role":case"viewBox":case"width":case"height":Wn(l,f,g);break;case"style":$o(l,g,b);break;case"data":if(c!=="object"){Wn(l,"data",g);break}case"src":case"href":if(g===""&&(c!=="a"||f!=="href")){l.removeAttribute(f);break}if(g==null||typeof g=="function"||typeof g=="symbol"||typeof g=="boolean"){l.removeAttribute(f);break}g=Gc(""+g),l.setAttribute(f,g);break;case"action":case"formAction":if(typeof g=="function"){l.setAttribute(f,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof b=="function"&&(f==="formAction"?(c!=="input"&&ti(l,c,"name",y.name,y,null),ti(l,c,"formEncType",y.formEncType,y,null),ti(l,c,"formMethod",y.formMethod,y,null),ti(l,c,"formTarget",y.formTarget,y,null)):(ti(l,c,"encType",y.encType,y,null),ti(l,c,"method",y.method,y,null),ti(l,c,"target",y.target,y,null)));if(g==null||typeof g=="symbol"||typeof g=="boolean"){l.removeAttribute(f);break}g=Gc(""+g),l.setAttribute(f,g);break;case"onClick":g!=null&&(l.onclick=Nn);break;case"onScroll":g!=null&&kt("scroll",l);break;case"onScrollEnd":g!=null&&kt("scrollend",l);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(n(61));if(f=g.__html,f!=null){if(y.children!=null)throw Error(n(60));l.innerHTML=f}}break;case"multiple":l.multiple=g&&typeof g!="function"&&typeof g!="symbol";break;case"muted":l.muted=g&&typeof g!="function"&&typeof g!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(g==null||typeof g=="function"||typeof g=="boolean"||typeof g=="symbol"){l.removeAttribute("xlink:href");break}f=Gc(""+g),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":g!=null&&typeof g!="function"&&typeof g!="symbol"?l.setAttribute(f,""+g):l.removeAttribute(f);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":g&&typeof g!="function"&&typeof g!="symbol"?l.setAttribute(f,""):l.removeAttribute(f);break;case"capture":case"download":g===!0?l.setAttribute(f,""):g!==!1&&g!=null&&typeof g!="function"&&typeof g!="symbol"?l.setAttribute(f,g):l.removeAttribute(f);break;case"cols":case"rows":case"size":case"span":g!=null&&typeof g!="function"&&typeof g!="symbol"&&!isNaN(g)&&1<=g?l.setAttribute(f,g):l.removeAttribute(f);break;case"rowSpan":case"start":g==null||typeof g=="function"||typeof g=="symbol"||isNaN(g)?l.removeAttribute(f):l.setAttribute(f,g);break;case"popover":kt("beforetoggle",l),kt("toggle",l),Xt(l,"popover",g);break;case"xlinkActuate":Pt(l,"http://www.w3.org/1999/xlink","xlink:actuate",g);break;case"xlinkArcrole":Pt(l,"http://www.w3.org/1999/xlink","xlink:arcrole",g);break;case"xlinkRole":Pt(l,"http://www.w3.org/1999/xlink","xlink:role",g);break;case"xlinkShow":Pt(l,"http://www.w3.org/1999/xlink","xlink:show",g);break;case"xlinkTitle":Pt(l,"http://www.w3.org/1999/xlink","xlink:title",g);break;case"xlinkType":Pt(l,"http://www.w3.org/1999/xlink","xlink:type",g);break;case"xmlBase":Pt(l,"http://www.w3.org/XML/1998/namespace","xml:base",g);break;case"xmlLang":Pt(l,"http://www.w3.org/XML/1998/namespace","xml:lang",g);break;case"xmlSpace":Pt(l,"http://www.w3.org/XML/1998/namespace","xml:space",g);break;case"is":Xt(l,"is",g);break;case"innerText":case"textContent":break;default:(!(2<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(f=hp.get(f)||f,Xt(l,f,g))}}function e1(l,c,f,g,y,b){switch(f){case"style":$o(l,g,b);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(n(61));if(f=g.__html,f!=null){if(y.children!=null)throw Error(n(60));l.innerHTML=f}}break;case"children":typeof g=="string"?zo(l,g):(typeof g=="number"||typeof g=="bigint")&&zo(l,""+g);break;case"onScroll":g!=null&&kt("scroll",l);break;case"onScrollEnd":g!=null&&kt("scrollend",l);break;case"onClick":g!=null&&(l.onclick=Nn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!cr.hasOwnProperty(f))e:{if(f[0]==="o"&&f[1]==="n"&&(y=f.endsWith("Capture"),c=f.slice(2,y?f.length-7:void 0),b=l[ht]||null,b=b!=null?b[f]:null,typeof b=="function"&&l.removeEventListener(c,b,y),typeof g=="function")){typeof b!="function"&&b!==null&&(f in l?l[f]=null:l.hasAttribute(f)&&l.removeAttribute(f)),l.addEventListener(c,g,y);break e}f in l?l[f]=g:g===!0?l.setAttribute(f,""):Xt(l,f,g)}}}function Bn(l,c,f){switch(c){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":kt("error",l),kt("load",l);var g=!1,y=!1,b;for(b in f)if(f.hasOwnProperty(b)){var E=f[b];if(E!=null)switch(b){case"src":g=!0;break;case"srcSet":y=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(n(137,c));default:ti(l,c,b,E,f,null)}}y&&ti(l,c,"srcSet",f.srcSet,f,null),g&&ti(l,c,"src",f.src,f,null);return;case"input":kt("invalid",l);var O=b=E=y=null,Q=null,le=null;for(g in f)if(f.hasOwnProperty(g)){var me=f[g];if(me!=null)switch(g){case"name":y=me;break;case"type":E=me;break;case"checked":Q=me;break;case"defaultChecked":le=me;break;case"value":b=me;break;case"defaultValue":O=me;break;case"children":case"dangerouslySetInnerHTML":if(me!=null)throw Error(n(137,c));break;default:ti(l,c,g,me,f,null)}}ap(l,b,O,Q,le,E,y,!1);return;case"select":kt("invalid",l),g=E=b=null;for(y in f)if(f.hasOwnProperty(y)&&(O=f[y],O!=null))switch(y){case"value":b=O;break;case"defaultValue":E=O;break;case"multiple":g=O;default:ti(l,c,y,O,f,null)}c=b,f=E,l.multiple=!!g,c!=null?so(l,!!g,c,!1):f!=null&&so(l,!!g,f,!0);return;case"textarea":kt("invalid",l),b=y=g=null;for(E in f)if(f.hasOwnProperty(E)&&(O=f[E],O!=null))switch(E){case"value":g=O;break;case"defaultValue":y=O;break;case"children":b=O;break;case"dangerouslySetInnerHTML":if(O!=null)throw Error(n(91));break;default:ti(l,c,E,O,f,null)}cp(l,g,y,b);return;case"option":for(Q in f)f.hasOwnProperty(Q)&&(g=f[Q],g!=null)&&(Q==="selected"?l.selected=g&&typeof g!="function"&&typeof g!="symbol":ti(l,c,Q,g,f,null));return;case"dialog":kt("beforetoggle",l),kt("toggle",l),kt("cancel",l),kt("close",l);break;case"iframe":case"object":kt("load",l);break;case"video":case"audio":for(g=0;g<yd.length;g++)kt(yd[g],l);break;case"image":kt("error",l),kt("load",l);break;case"details":kt("toggle",l);break;case"embed":case"source":case"link":kt("error",l),kt("load",l);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(le in f)if(f.hasOwnProperty(le)&&(g=f[le],g!=null))switch(le){case"children":case"dangerouslySetInnerHTML":throw Error(n(137,c));default:ti(l,c,le,g,f,null)}return;default:if(hr(c)){for(me in f)f.hasOwnProperty(me)&&(g=f[me],g!==void 0&&e1(l,c,me,g,f,void 0));return}}for(O in f)f.hasOwnProperty(O)&&(g=f[O],g!=null&&ti(l,c,O,g,f,null))}function IB(l,c,f,g){switch(c){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var y=null,b=null,E=null,O=null,Q=null,le=null,me=null;for(ue in f){var xe=f[ue];if(f.hasOwnProperty(ue)&&xe!=null)switch(ue){case"checked":break;case"value":break;case"defaultValue":Q=xe;default:g.hasOwnProperty(ue)||ti(l,c,ue,null,g,xe)}}for(var ce in g){var ue=g[ce];if(xe=f[ce],g.hasOwnProperty(ce)&&(ue!=null||xe!=null))switch(ce){case"type":b=ue;break;case"name":y=ue;break;case"checked":le=ue;break;case"defaultChecked":me=ue;break;case"value":E=ue;break;case"defaultValue":O=ue;break;case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(n(137,c));break;default:ue!==xe&&ti(l,c,ce,ue,g,xe)}}ur(l,E,O,Q,le,me,b,y);return;case"select":ue=E=O=ce=null;for(b in f)if(Q=f[b],f.hasOwnProperty(b)&&Q!=null)switch(b){case"value":break;case"multiple":ue=Q;default:g.hasOwnProperty(b)||ti(l,c,b,null,g,Q)}for(y in g)if(b=g[y],Q=f[y],g.hasOwnProperty(y)&&(b!=null||Q!=null))switch(y){case"value":ce=b;break;case"defaultValue":O=b;break;case"multiple":E=b;default:b!==Q&&ti(l,c,y,b,g,Q)}c=O,f=E,g=ue,ce!=null?so(l,!!f,ce,!1):!!g!=!!f&&(c!=null?so(l,!!f,c,!0):so(l,!!f,f?[]:"",!1));return;case"textarea":ue=ce=null;for(O in f)if(y=f[O],f.hasOwnProperty(O)&&y!=null&&!g.hasOwnProperty(O))switch(O){case"value":break;case"children":break;default:ti(l,c,O,null,g,y)}for(E in g)if(y=g[E],b=f[E],g.hasOwnProperty(E)&&(y!=null||b!=null))switch(E){case"value":ce=y;break;case"defaultValue":ue=y;break;case"children":break;case"dangerouslySetInnerHTML":if(y!=null)throw Error(n(91));break;default:y!==b&&ti(l,c,E,y,g,b)}Kc(l,ce,ue);return;case"option":for(var $e in f)ce=f[$e],f.hasOwnProperty($e)&&ce!=null&&!g.hasOwnProperty($e)&&($e==="selected"?l.selected=!1:ti(l,c,$e,null,g,ce));for(Q in g)ce=g[Q],ue=f[Q],g.hasOwnProperty(Q)&&ce!==ue&&(ce!=null||ue!=null)&&(Q==="selected"?l.selected=ce&&typeof ce!="function"&&typeof ce!="symbol":ti(l,c,Q,ce,g,ue));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var nt in f)ce=f[nt],f.hasOwnProperty(nt)&&ce!=null&&!g.hasOwnProperty(nt)&&ti(l,c,nt,null,g,ce);for(le in g)if(ce=g[le],ue=f[le],g.hasOwnProperty(le)&&ce!==ue&&(ce!=null||ue!=null))switch(le){case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(n(137,c));break;default:ti(l,c,le,ce,g,ue)}return;default:if(hr(c)){for(var ii in f)ce=f[ii],f.hasOwnProperty(ii)&&ce!==void 0&&!g.hasOwnProperty(ii)&&e1(l,c,ii,void 0,g,ce);for(me in g)ce=g[me],ue=f[me],!g.hasOwnProperty(me)||ce===ue||ce===void 0&&ue===void 0||e1(l,c,me,ce,g,ue);return}}for(var ne in f)ce=f[ne],f.hasOwnProperty(ne)&&ce!=null&&!g.hasOwnProperty(ne)&&ti(l,c,ne,null,g,ce);for(xe in g)ce=g[xe],ue=f[xe],!g.hasOwnProperty(xe)||ce===ue||ce==null&&ue==null||ti(l,c,xe,ce,g,ue)}function M2(l){switch(l){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function PB(){if(typeof performance.getEntriesByType=="function"){for(var l=0,c=0,f=performance.getEntriesByType("resource"),g=0;g<f.length;g++){var y=f[g],b=y.transferSize,E=y.initiatorType,O=y.duration;if(b&&O&&M2(E)){for(E=0,O=y.responseEnd,g+=1;g<f.length;g++){var Q=f[g],le=Q.startTime;if(le>O)break;var me=Q.transferSize,xe=Q.initiatorType;me&&M2(xe)&&(Q=Q.responseEnd,E+=me*(Q<O?1:(O-le)/(Q-le)))}if(--g,c+=8*(b+E)/(y.duration/1e3),l++,10<l)break}}if(0<l)return c/l/1e6}return navigator.connection&&(l=navigator.connection.downlink,typeof l=="number")?l:5}var t1=null,i1=null;function _m(l){return l.nodeType===9?l:l.ownerDocument}function A2(l){switch(l){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function L2(l,c){if(l===0)switch(c){case"svg":return 1;case"math":return 2;default:return 0}return l===1&&c==="foreignObject"?0:l}function n1(l,c){return l==="textarea"||l==="noscript"||typeof c.children=="string"||typeof c.children=="number"||typeof c.children=="bigint"||typeof c.dangerouslySetInnerHTML=="object"&&c.dangerouslySetInnerHTML!==null&&c.dangerouslySetInnerHTML.__html!=null}var s1=null;function zB(){var l=window.event;return l&&l.type==="popstate"?l===s1?!1:(s1=l,!0):(s1=null,!1)}var T2=typeof setTimeout=="function"?setTimeout:void 0,$B=typeof clearTimeout=="function"?clearTimeout:void 0,N2=typeof Promise=="function"?Promise:void 0,FB=typeof queueMicrotask=="function"?queueMicrotask:typeof N2<"u"?function(l){return N2.resolve(null).then(l).catch(HB)}:T2;function HB(l){setTimeout(function(){throw l})}function na(l){return l==="head"}function j2(l,c){var f=c,g=0;do{var y=f.nextSibling;if(l.removeChild(f),y&&y.nodeType===8)if(f=y.data,f==="/$"||f==="/&"){if(g===0){l.removeChild(y),Lu(c);return}g--}else if(f==="$"||f==="$?"||f==="$~"||f==="$!"||f==="&")g++;else if(f==="html")bd(l.ownerDocument.documentElement);else if(f==="head"){f=l.ownerDocument.head,bd(f);for(var b=f.firstChild;b;){var E=b.nextSibling,O=b.nodeName;b[on]||O==="SCRIPT"||O==="STYLE"||O==="LINK"&&b.rel.toLowerCase()==="stylesheet"||f.removeChild(b),b=E}}else f==="body"&&bd(l.ownerDocument.body);f=y}while(f);Lu(c)}function R2(l,c){var f=l;l=0;do{var g=f.nextSibling;if(f.nodeType===1?c?(f._stashedDisplay=f.style.display,f.style.display="none"):(f.style.display=f._stashedDisplay||"",f.getAttribute("style")===""&&f.removeAttribute("style")):f.nodeType===3&&(c?(f._stashedText=f.nodeValue,f.nodeValue=""):f.nodeValue=f._stashedText||""),g&&g.nodeType===8)if(f=g.data,f==="/$"){if(l===0)break;l--}else f!=="$"&&f!=="$?"&&f!=="$~"&&f!=="$!"||l++;f=g}while(f)}function r1(l){var c=l.firstChild;for(c&&c.nodeType===10&&(c=c.nextSibling);c;){var f=c;switch(c=c.nextSibling,f.nodeName){case"HTML":case"HEAD":case"BODY":r1(f),Ia(f);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(f.rel.toLowerCase()==="stylesheet")continue}l.removeChild(f)}}function WB(l,c,f,g){for(;l.nodeType===1;){var y=f;if(l.nodeName.toLowerCase()!==c.toLowerCase()){if(!g&&(l.nodeName!=="INPUT"||l.type!=="hidden"))break}else if(g){if(!l[on])switch(c){case"meta":if(!l.hasAttribute("itemprop"))break;return l;case"link":if(b=l.getAttribute("rel"),b==="stylesheet"&&l.hasAttribute("data-precedence"))break;if(b!==y.rel||l.getAttribute("href")!==(y.href==null||y.href===""?null:y.href)||l.getAttribute("crossorigin")!==(y.crossOrigin==null?null:y.crossOrigin)||l.getAttribute("title")!==(y.title==null?null:y.title))break;return l;case"style":if(l.hasAttribute("data-precedence"))break;return l;case"script":if(b=l.getAttribute("src"),(b!==(y.src==null?null:y.src)||l.getAttribute("type")!==(y.type==null?null:y.type)||l.getAttribute("crossorigin")!==(y.crossOrigin==null?null:y.crossOrigin))&&b&&l.hasAttribute("async")&&!l.hasAttribute("itemprop"))break;return l;default:return l}}else if(c==="input"&&l.type==="hidden"){var b=y.name==null?null:""+y.name;if(y.type==="hidden"&&l.getAttribute("name")===b)return l}else return l;if(l=br(l.nextSibling),l===null)break}return null}function qB(l,c,f){if(c==="")return null;for(;l.nodeType!==3;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!f||(l=br(l.nextSibling),l===null))return null;return l}function D2(l,c){for(;l.nodeType!==8;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!c||(l=br(l.nextSibling),l===null))return null;return l}function o1(l){return l.data==="$?"||l.data==="$~"}function l1(l){return l.data==="$!"||l.data==="$?"&&l.ownerDocument.readyState!=="loading"}function UB(l,c){var f=l.ownerDocument;if(l.data==="$~")l._reactRetry=c;else if(l.data!=="$?"||f.readyState!=="loading")c();else{var g=function(){c(),f.removeEventListener("DOMContentLoaded",g)};f.addEventListener("DOMContentLoaded",g),l._reactRetry=g}}function br(l){for(;l!=null;l=l.nextSibling){var c=l.nodeType;if(c===1||c===3)break;if(c===8){if(c=l.data,c==="$"||c==="$!"||c==="$?"||c==="$~"||c==="&"||c==="F!"||c==="F")break;if(c==="/$"||c==="/&")return null}}return l}var a1=null;function B2(l){l=l.nextSibling;for(var c=0;l;){if(l.nodeType===8){var f=l.data;if(f==="/$"||f==="/&"){if(c===0)return br(l.nextSibling);c--}else f!=="$"&&f!=="$!"&&f!=="$?"&&f!=="$~"&&f!=="&"||c++}l=l.nextSibling}return null}function O2(l){l=l.previousSibling;for(var c=0;l;){if(l.nodeType===8){var f=l.data;if(f==="$"||f==="$!"||f==="$?"||f==="$~"||f==="&"){if(c===0)return l;c--}else f!=="/$"&&f!=="/&"||c++}l=l.previousSibling}return null}function I2(l,c,f){switch(c=_m(f),l){case"html":if(l=c.documentElement,!l)throw Error(n(452));return l;case"head":if(l=c.head,!l)throw Error(n(453));return l;case"body":if(l=c.body,!l)throw Error(n(454));return l;default:throw Error(n(451))}}function bd(l){for(var c=l.attributes;c.length;)l.removeAttributeNode(c[0]);Ia(l)}var wr=new Map,P2=new Set;function ym(l){return typeof l.getRootNode=="function"?l.getRootNode():l.nodeType===9?l:l.ownerDocument}var al=U.d;U.d={f:VB,r:KB,D:YB,C:GB,L:QB,m:XB,X:JB,S:ZB,M:eO};function VB(){var l=al.f(),c=um();return l||c}function KB(l){var c=Hn(l);c!==null&&c.tag===5&&c.type==="form"?tC(c):al.r(l)}var Eu=typeof document>"u"?null:document;function z2(l,c,f){var g=Eu;if(g&&typeof c=="string"&&c){var y=Tn(c);y='link[rel="'+l+'"][href="'+y+'"]',typeof f=="string"&&(y+='[crossorigin="'+f+'"]'),P2.has(y)||(P2.add(y),l={rel:l,crossOrigin:f,href:c},g.querySelector(y)===null&&(c=g.createElement("link"),Bn(c,"link",l),pi(c),g.head.appendChild(c)))}}function YB(l){al.D(l),z2("dns-prefetch",l,null)}function GB(l,c){al.C(l,c),z2("preconnect",l,c)}function QB(l,c,f){al.L(l,c,f);var g=Eu;if(g&&l&&c){var y='link[rel="preload"][as="'+Tn(c)+'"]';c==="image"&&f&&f.imageSrcSet?(y+='[imagesrcset="'+Tn(f.imageSrcSet)+'"]',typeof f.imageSizes=="string"&&(y+='[imagesizes="'+Tn(f.imageSizes)+'"]')):y+='[href="'+Tn(l)+'"]';var b=y;switch(c){case"style":b=Mu(l);break;case"script":b=Au(l)}wr.has(b)||(l=m({rel:"preload",href:c==="image"&&f&&f.imageSrcSet?void 0:l,as:c},f),wr.set(b,l),g.querySelector(y)!==null||c==="style"&&g.querySelector(wd(b))||c==="script"&&g.querySelector(Sd(b))||(c=g.createElement("link"),Bn(c,"link",l),pi(c),g.head.appendChild(c)))}}function XB(l,c){al.m(l,c);var f=Eu;if(f&&l){var g=c&&typeof c.as=="string"?c.as:"script",y='link[rel="modulepreload"][as="'+Tn(g)+'"][href="'+Tn(l)+'"]',b=y;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":b=Au(l)}if(!wr.has(b)&&(l=m({rel:"modulepreload",href:l},c),wr.set(b,l),f.querySelector(y)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(f.querySelector(Sd(b)))return}g=f.createElement("link"),Bn(g,"link",l),pi(g),f.head.appendChild(g)}}}function ZB(l,c,f){al.S(l,c,f);var g=Eu;if(g&&l){var y=Ps(g).hoistableStyles,b=Mu(l);c=c||"default";var E=y.get(b);if(!E){var O={loading:0,preload:null};if(E=g.querySelector(wd(b)))O.loading=5;else{l=m({rel:"stylesheet",href:l,"data-precedence":c},f),(f=wr.get(b))&&c1(l,f);var Q=E=g.createElement("link");pi(Q),Bn(Q,"link",l),Q._p=new Promise(function(le,me){Q.onload=le,Q.onerror=me}),Q.addEventListener("load",function(){O.loading|=1}),Q.addEventListener("error",function(){O.loading|=2}),O.loading|=4,xm(E,c,g)}E={type:"stylesheet",instance:E,count:1,state:O},y.set(b,E)}}}function JB(l,c){al.X(l,c);var f=Eu;if(f&&l){var g=Ps(f).hoistableScripts,y=Au(l),b=g.get(y);b||(b=f.querySelector(Sd(y)),b||(l=m({src:l,async:!0},c),(c=wr.get(y))&&u1(l,c),b=f.createElement("script"),pi(b),Bn(b,"link",l),f.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},g.set(y,b))}}function eO(l,c){al.M(l,c);var f=Eu;if(f&&l){var g=Ps(f).hoistableScripts,y=Au(l),b=g.get(y);b||(b=f.querySelector(Sd(y)),b||(l=m({src:l,async:!0,type:"module"},c),(c=wr.get(y))&&u1(l,c),b=f.createElement("script"),pi(b),Bn(b,"link",l),f.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},g.set(y,b))}}function $2(l,c,f,g){var y=(y=re.current)?ym(y):null;if(!y)throw Error(n(446));switch(l){case"meta":case"title":return null;case"style":return typeof f.precedence=="string"&&typeof f.href=="string"?(c=Mu(f.href),f=Ps(y).hoistableStyles,g=f.get(c),g||(g={type:"style",instance:null,count:0,state:null},f.set(c,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(f.rel==="stylesheet"&&typeof f.href=="string"&&typeof f.precedence=="string"){l=Mu(f.href);var b=Ps(y).hoistableStyles,E=b.get(l);if(E||(y=y.ownerDocument||y,E={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},b.set(l,E),(b=y.querySelector(wd(l)))&&!b._p&&(E.instance=b,E.state.loading=5),wr.has(l)||(f={rel:"preload",as:"style",href:f.href,crossOrigin:f.crossOrigin,integrity:f.integrity,media:f.media,hrefLang:f.hrefLang,referrerPolicy:f.referrerPolicy},wr.set(l,f),b||tO(y,l,f,E.state))),c&&g===null)throw Error(n(528,""));return E}if(c&&g!==null)throw Error(n(529,""));return null;case"script":return c=f.async,f=f.src,typeof f=="string"&&c&&typeof c!="function"&&typeof c!="symbol"?(c=Au(f),f=Ps(y).hoistableScripts,g=f.get(c),g||(g={type:"script",instance:null,count:0,state:null},f.set(c,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,l))}}function Mu(l){return'href="'+Tn(l)+'"'}function wd(l){return'link[rel="stylesheet"]['+l+"]"}function F2(l){return m({},l,{"data-precedence":l.precedence,precedence:null})}function tO(l,c,f,g){l.querySelector('link[rel="preload"][as="style"]['+c+"]")?g.loading=1:(c=l.createElement("link"),g.preload=c,c.addEventListener("load",function(){return g.loading|=1}),c.addEventListener("error",function(){return g.loading|=2}),Bn(c,"link",f),pi(c),l.head.appendChild(c))}function Au(l){return'[src="'+Tn(l)+'"]'}function Sd(l){return"script[async]"+l}function H2(l,c,f){if(c.count++,c.instance===null)switch(c.type){case"style":var g=l.querySelector('style[data-href~="'+Tn(f.href)+'"]');if(g)return c.instance=g,pi(g),g;var y=m({},f,{"data-href":f.href,"data-precedence":f.precedence,href:null,precedence:null});return g=(l.ownerDocument||l).createElement("style"),pi(g),Bn(g,"style",y),xm(g,f.precedence,l),c.instance=g;case"stylesheet":y=Mu(f.href);var b=l.querySelector(wd(y));if(b)return c.state.loading|=4,c.instance=b,pi(b),b;g=F2(f),(y=wr.get(y))&&c1(g,y),b=(l.ownerDocument||l).createElement("link"),pi(b);var E=b;return E._p=new Promise(function(O,Q){E.onload=O,E.onerror=Q}),Bn(b,"link",g),c.state.loading|=4,xm(b,f.precedence,l),c.instance=b;case"script":return b=Au(f.src),(y=l.querySelector(Sd(b)))?(c.instance=y,pi(y),y):(g=f,(y=wr.get(b))&&(g=m({},f),u1(g,y)),l=l.ownerDocument||l,y=l.createElement("script"),pi(y),Bn(y,"link",g),l.head.appendChild(y),c.instance=y);case"void":return null;default:throw Error(n(443,c.type))}else c.type==="stylesheet"&&(c.state.loading&4)===0&&(g=c.instance,c.state.loading|=4,xm(g,f.precedence,l));return c.instance}function xm(l,c,f){for(var g=f.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),y=g.length?g[g.length-1]:null,b=y,E=0;E<g.length;E++){var O=g[E];if(O.dataset.precedence===c)b=O;else if(b!==y)break}b?b.parentNode.insertBefore(l,b.nextSibling):(c=f.nodeType===9?f.head:f,c.insertBefore(l,c.firstChild))}function c1(l,c){l.crossOrigin==null&&(l.crossOrigin=c.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=c.referrerPolicy),l.title==null&&(l.title=c.title)}function u1(l,c){l.crossOrigin==null&&(l.crossOrigin=c.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=c.referrerPolicy),l.integrity==null&&(l.integrity=c.integrity)}var bm=null;function W2(l,c,f){if(bm===null){var g=new Map,y=bm=new Map;y.set(f,g)}else y=bm,g=y.get(f),g||(g=new Map,y.set(f,g));if(g.has(l))return g;for(g.set(l,null),f=f.getElementsByTagName(l),y=0;y<f.length;y++){var b=f[y];if(!(b[on]||b[Ni]||l==="link"&&b.getAttribute("rel")==="stylesheet")&&b.namespaceURI!=="http://www.w3.org/2000/svg"){var E=b.getAttribute(c)||"";E=l+E;var O=g.get(E);O?O.push(b):g.set(E,[b])}}return g}function q2(l,c,f){l=l.ownerDocument||l,l.head.insertBefore(f,c==="title"?l.querySelector("head > title"):null)}function iO(l,c,f){if(f===1||c.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof c.precedence!="string"||typeof c.href!="string"||c.href==="")break;return!0;case"link":if(typeof c.rel!="string"||typeof c.href!="string"||c.href===""||c.onLoad||c.onError)break;return c.rel==="stylesheet"?(l=c.disabled,typeof c.precedence=="string"&&l==null):!0;case"script":if(c.async&&typeof c.async!="function"&&typeof c.async!="symbol"&&!c.onLoad&&!c.onError&&c.src&&typeof c.src=="string")return!0}return!1}function U2(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function nO(l,c,f,g){if(f.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(f.state.loading&4)===0){if(f.instance===null){var y=Mu(g.href),b=c.querySelector(wd(y));if(b){c=b._p,c!==null&&typeof c=="object"&&typeof c.then=="function"&&(l.count++,l=wm.bind(l),c.then(l,l)),f.state.loading|=4,f.instance=b,pi(b);return}b=c.ownerDocument||c,g=F2(g),(y=wr.get(y))&&c1(g,y),b=b.createElement("link"),pi(b);var E=b;E._p=new Promise(function(O,Q){E.onload=O,E.onerror=Q}),Bn(b,"link",g),f.instance=b}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(f,c),(c=f.state.preload)&&(f.state.loading&3)===0&&(l.count++,f=wm.bind(l),c.addEventListener("load",f),c.addEventListener("error",f))}}var h1=0;function sO(l,c){return l.stylesheets&&l.count===0&&km(l,l.stylesheets),0<l.count||0<l.imgCount?function(f){var g=setTimeout(function(){if(l.stylesheets&&km(l,l.stylesheets),l.unsuspend){var b=l.unsuspend;l.unsuspend=null,b()}},6e4+c);0<l.imgBytes&&h1===0&&(h1=62500*PB());var y=setTimeout(function(){if(l.waitingForImages=!1,l.count===0&&(l.stylesheets&&km(l,l.stylesheets),l.unsuspend)){var b=l.unsuspend;l.unsuspend=null,b()}},(l.imgBytes>h1?50:800)+c);return l.unsuspend=f,function(){l.unsuspend=null,clearTimeout(g),clearTimeout(y)}}:null}function wm(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)km(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var Sm=null;function km(l,c){l.stylesheets=null,l.unsuspend!==null&&(l.count++,Sm=new Map,c.forEach(rO,l),Sm=null,wm.call(l))}function rO(l,c){if(!(c.state.loading&4)){var f=Sm.get(l);if(f)var g=f.get(null);else{f=new Map,Sm.set(l,f);for(var y=l.querySelectorAll("link[data-precedence],style[data-precedence]"),b=0;b<y.length;b++){var E=y[b];(E.nodeName==="LINK"||E.getAttribute("media")!=="not all")&&(f.set(E.dataset.precedence,E),g=E)}g&&f.set(null,g)}y=c.instance,E=y.getAttribute("data-precedence"),b=f.get(E)||g,b===g&&f.set(null,y),f.set(E,y),this.count++,g=wm.bind(this),y.addEventListener("load",g),y.addEventListener("error",g),b?b.parentNode.insertBefore(y,b.nextSibling):(l=l.nodeType===9?l.head:l,l.insertBefore(y,l.firstChild)),c.state.loading|=4}}var kd={$$typeof:L,Provider:null,Consumer:null,_currentValue:V,_currentValue2:V,_threadCount:0};function oO(l,c,f,g,y,b,E,O,Q){this.tag=1,this.containerInfo=l,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ys(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ys(0),this.hiddenUpdates=ys(null),this.identifierPrefix=g,this.onUncaughtError=y,this.onCaughtError=b,this.onRecoverableError=E,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Q,this.incompleteTransitions=new Map}function V2(l,c,f,g,y,b,E,O,Q,le,me,xe){return l=new oO(l,c,f,E,Q,le,me,xe,O),c=1,b===!0&&(c|=24),b=qs(3,null,null,c),l.current=b,b.stateNode=l,c=qv(),c.refCount++,l.pooledCache=c,c.refCount++,b.memoizedState={element:g,isDehydrated:f,cache:c},Yv(b),l}function K2(l){return l?(l=ru,l):ru}function Y2(l,c,f,g,y,b){y=K2(y),g.context===null?g.context=y:g.pendingContext=y,g=Vl(c),g.payload={element:f},b=b===void 0?null:b,b!==null&&(g.callback=b),f=Kl(l,g,c),f!==null&&(Ms(f,l,c),id(f,l,c))}function G2(l,c){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var f=l.retryLane;l.retryLane=f!==0&&f<c?f:c}}function d1(l,c){G2(l,c),(l=l.alternate)&&G2(l,c)}function Q2(l){if(l.tag===13||l.tag===31){var c=Va(l,67108864);c!==null&&Ms(c,l,67108864),d1(l,67108864)}}function X2(l){if(l.tag===13||l.tag===31){var c=Gs();c=Os(c);var f=Va(l,c);f!==null&&Ms(f,l,c),d1(l,c)}}var Cm=!0;function lO(l,c,f,g){var y=P.T;P.T=null;var b=U.p;try{U.p=2,f1(l,c,f,g)}finally{U.p=b,P.T=y}}function aO(l,c,f,g){var y=P.T;P.T=null;var b=U.p;try{U.p=8,f1(l,c,f,g)}finally{U.p=b,P.T=y}}function f1(l,c,f,g){if(Cm){var y=p1(g);if(y===null)J_(l,c,g,Em,f),J2(l,g);else if(uO(y,l,c,f,g))g.stopPropagation();else if(J2(l,g),c&4&&-1<cO.indexOf(l)){for(;y!==null;){var b=Hn(y);if(b!==null)switch(b.tag){case 3:if(b=b.stateNode,b.current.memoizedState.isDehydrated){var E=Gi(b.pendingLanes);if(E!==0){var O=b;for(O.pendingLanes|=2,O.entangledLanes|=2;E;){var Q=1<<31-Tt(E);O.entanglements[1]|=Q,E&=~Q}co(b),(qt&6)===0&&(am=Kt()+500,_d(0))}}break;case 31:case 13:O=Va(b,2),O!==null&&Ms(O,b,2),um(),d1(b,2)}if(b=p1(g),b===null&&J_(l,c,g,Em,f),b===y)break;y=b}y!==null&&g.stopPropagation()}else J_(l,c,g,null,f)}}function p1(l){return l=Xc(l),m1(l)}var Em=null;function m1(l){if(Em=null,l=no(l),l!==null){var c=r(l);if(c===null)l=null;else{var f=c.tag;if(f===13){if(l=o(c),l!==null)return l;l=null}else if(f===31){if(l=a(c),l!==null)return l;l=null}else if(f===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;l=null}else c!==l&&(l=null)}}return Em=l,null}function Z2(l){switch(l){case"beforetoggle":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"toggle":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 2;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"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(gn()){case de:return 2;case Me:return 8;case Ke:case Je:return 32;case ot:return 268435456;default:return 32}default:return 32}}var g1=!1,sa=null,ra=null,oa=null,Cd=new Map,Ed=new Map,la=[],cO="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".split(" ");function J2(l,c){switch(l){case"focusin":case"focusout":sa=null;break;case"dragenter":case"dragleave":ra=null;break;case"mouseover":case"mouseout":oa=null;break;case"pointerover":case"pointerout":Cd.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ed.delete(c.pointerId)}}function Md(l,c,f,g,y,b){return l===null||l.nativeEvent!==b?(l={blockedOn:c,domEventName:f,eventSystemFlags:g,nativeEvent:b,targetContainers:[y]},c!==null&&(c=Hn(c),c!==null&&Q2(c)),l):(l.eventSystemFlags|=g,c=l.targetContainers,y!==null&&c.indexOf(y)===-1&&c.push(y),l)}function uO(l,c,f,g,y){switch(c){case"focusin":return sa=Md(sa,l,c,f,g,y),!0;case"dragenter":return ra=Md(ra,l,c,f,g,y),!0;case"mouseover":return oa=Md(oa,l,c,f,g,y),!0;case"pointerover":var b=y.pointerId;return Cd.set(b,Md(Cd.get(b)||null,l,c,f,g,y)),!0;case"gotpointercapture":return b=y.pointerId,Ed.set(b,Md(Ed.get(b)||null,l,c,f,g,y)),!0}return!1}function e5(l){var c=no(l.target);if(c!==null){var f=r(c);if(f!==null){if(c=f.tag,c===13){if(c=o(f),c!==null){l.blockedOn=c,Io(l.priority,function(){X2(f)});return}}else if(c===31){if(c=a(f),c!==null){l.blockedOn=c,Io(l.priority,function(){X2(f)});return}}else if(c===3&&f.stateNode.current.memoizedState.isDehydrated){l.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}l.blockedOn=null}function Mm(l){if(l.blockedOn!==null)return!1;for(var c=l.targetContainers;0<c.length;){var f=p1(l.nativeEvent);if(f===null){f=l.nativeEvent;var g=new f.constructor(f.type,f);Qc=g,f.target.dispatchEvent(g),Qc=null}else return c=Hn(f),c!==null&&Q2(c),l.blockedOn=f,!1;c.shift()}return!0}function t5(l,c,f){Mm(l)&&f.delete(c)}function hO(){g1=!1,sa!==null&&Mm(sa)&&(sa=null),ra!==null&&Mm(ra)&&(ra=null),oa!==null&&Mm(oa)&&(oa=null),Cd.forEach(t5),Ed.forEach(t5)}function Am(l,c){l.blockedOn===c&&(l.blockedOn=null,g1||(g1=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,hO)))}var Lm=null;function i5(l){Lm!==l&&(Lm=l,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Lm===l&&(Lm=null);for(var c=0;c<l.length;c+=3){var f=l[c],g=l[c+1],y=l[c+2];if(typeof g!="function"){if(m1(g||f)===null)continue;break}var b=Hn(f);b!==null&&(l.splice(c,3),c-=3,p_(b,{pending:!0,data:y,method:f.method,action:g},g,y))}}))}function Lu(l){function c(Q){return Am(Q,l)}sa!==null&&Am(sa,l),ra!==null&&Am(ra,l),oa!==null&&Am(oa,l),Cd.forEach(c),Ed.forEach(c);for(var f=0;f<la.length;f++){var g=la[f];g.blockedOn===l&&(g.blockedOn=null)}for(;0<la.length&&(f=la[0],f.blockedOn===null);)e5(f),f.blockedOn===null&&la.shift();if(f=(l.ownerDocument||l).$$reactFormReplay,f!=null)for(g=0;g<f.length;g+=3){var y=f[g],b=f[g+1],E=y[ht]||null;if(typeof b=="function")E||i5(f);else if(E){var O=null;if(b&&b.hasAttribute("formAction")){if(y=b,E=b[ht]||null)O=E.formAction;else if(m1(y)!==null)continue}else O=E.action;typeof O=="function"?f[g+1]=O:(f.splice(g,3),g-=3),i5(f)}}}function n5(){function l(b){b.canIntercept&&b.info==="react-transition"&&b.intercept({handler:function(){return new Promise(function(E){return y=E})},focusReset:"manual",scroll:"manual"})}function c(){y!==null&&(y(),y=null),g||setTimeout(f,20)}function f(){if(!g&&!navigation.transition){var b=navigation.currentEntry;b&&b.url!=null&&navigation.navigate(b.url,{state:b.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var g=!1,y=null;return navigation.addEventListener("navigate",l),navigation.addEventListener("navigatesuccess",c),navigation.addEventListener("navigateerror",c),setTimeout(f,100),function(){g=!0,navigation.removeEventListener("navigate",l),navigation.removeEventListener("navigatesuccess",c),navigation.removeEventListener("navigateerror",c),y!==null&&(y(),y=null)}}}function v1(l){this._internalRoot=l}Tm.prototype.render=v1.prototype.render=function(l){var c=this._internalRoot;if(c===null)throw Error(n(409));var f=c.current,g=Gs();Y2(f,g,l,c,null,null)},Tm.prototype.unmount=v1.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var c=l.containerInfo;Y2(l.current,2,null,l,null,null),um(),c[Fn]=null}};function Tm(l){this._internalRoot=l}Tm.prototype.unstable_scheduleHydration=function(l){if(l){var c=xs();l={blockedOn:null,target:l,priority:c};for(var f=0;f<la.length&&c!==0&&c<la[f].priority;f++);la.splice(f,0,l),f===0&&e5(l)}};var s5=e.version;if(s5!=="19.2.8")throw Error(n(527,s5,"19.2.8"));U.findDOMNode=function(l){var c=l._reactInternals;if(c===void 0)throw typeof l.render=="function"?Error(n(188)):(l=Object.keys(l).join(","),Error(n(268,l)));return l=h(c),l=l!==null?p(l):null,l=l===null?null:l.stateNode,l};var dO={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:P,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Nm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Nm.isDisabled&&Nm.supportsFiber)try{pt=Nm.inject(dO),Ht=Nm}catch{}}return Ld.createRoot=function(l,c){if(!s(l))throw Error(n(299));var f=!1,g="",y=hC,b=dC,E=fC;return c!=null&&(c.unstable_strictMode===!0&&(f=!0),c.identifierPrefix!==void 0&&(g=c.identifierPrefix),c.onUncaughtError!==void 0&&(y=c.onUncaughtError),c.onCaughtError!==void 0&&(b=c.onCaughtError),c.onRecoverableError!==void 0&&(E=c.onRecoverableError)),c=V2(l,1,!1,null,null,f,g,null,y,b,E,n5),l[Fn]=c.current,Z_(l),new v1(c)},Ld.hydrateRoot=function(l,c,f){if(!s(l))throw Error(n(299));var g=!1,y="",b=hC,E=dC,O=fC,Q=null;return f!=null&&(f.unstable_strictMode===!0&&(g=!0),f.identifierPrefix!==void 0&&(y=f.identifierPrefix),f.onUncaughtError!==void 0&&(b=f.onUncaughtError),f.onCaughtError!==void 0&&(E=f.onCaughtError),f.onRecoverableError!==void 0&&(O=f.onRecoverableError),f.formState!==void 0&&(Q=f.formState)),c=V2(l,1,!0,c,f??null,g,y,Q,b,E,O,n5),c.context=K2(null),f=c.current,g=Gs(),g=Os(g),y=Vl(g),y.callback=null,Kl(f,y,g),f=g,c.current.lanes=f,zr(c,f),co(c),l[Fn]=c.current,Z_(l),new Tm(c)},Ld.version="19.2.8",Ld}var p5;function bO(){if(p5)return x1.exports;p5=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),x1.exports=xO(),x1.exports}var wO=bO();const Gg="octiq.web.token";function jm(){return location.port==="5273"?"127.0.0.1:1421":location.host}function Td(){const t=new URL(location.href),e=t.searchParams.get("token");if(e){try{localStorage.setItem(Gg,e)}catch{}return t.searchParams.delete("token"),history.replaceState(null,"",t.pathname+t.search+t.hash),e}try{return localStorage.getItem(Gg)??""}catch{return""}}class SO{socket=null;seq=1;pending=new Map;listeners=new Map;queue=[];retry=0;stateFns=new Set;state="connecting";constructor(){this.start()}async start(){Td()||await this.tryLocalToken(),this.connect()}async tryLocalToken(){const e=location.protocol==="https:"?"https":"http";try{const i=await fetch(`${e}://${jm()}/token`,{cache:"no-store"});if(!i.ok)return!1;const n=(await i.text()).trim();return n?(localStorage.setItem(Gg,n),!0):!1}catch{return!1}}setState(e){this.state=e;for(const i of this.stateFns)i(e)}connect(){const i=`${location.protocol==="https:"?"wss":"ws"}://${jm()}/ws?token=${encodeURIComponent(Td())}`;this.setState("connecting");const n=new WebSocket(i);this.socket=n,n.addEventListener("open",()=>{this.retry=0,this.setState("open");const s=this.queue;this.queue=[];for(const r of this.pending.values())r.sent=!0;for(const r of s)n.send(r)}),n.addEventListener("message",s=>{let r;try{r=JSON.parse(s.data)}catch{return}if(r.t==="reply"){const o=this.pending.get(r.id);if(!o)return;this.pending.delete(r.id),r.ok?o.resolve(r.result):o.reject(new Error(r.error??"command failed"));return}if(r.t==="event"){const o=this.listeners.get(r.event);if(!o)return;for(const a of[...o])try{a(r.payload)}catch(u){console.error("[octiq] listener failed",r.event,u)}}}),n.addEventListener("close",async()=>{if(this.socket===n){for(const[s,r]of this.pending)r.sent&&(this.pending.delete(s),r.reject(new Error("Connection closed before the command answered")));if(await this.tokenRejected()){if(await this.tryLocalToken()){this.connect();return}this.setState("unauthorized");return}this.setState("closed"),this.retry=Math.min(this.retry+1,6),setTimeout(()=>this.connect(),Math.min(500*2**(this.retry-1),8e3))}}),n.addEventListener("error",()=>n.close())}async tokenRejected(){const e=location.protocol==="https:"?"https":"http";try{return(await fetch(`${e}://${jm()}/auth?token=${encodeURIComponent(Td())}`,{cache:"no-store"})).status===401}catch{return!1}}async fetchFile(e){const i=await fetch(this.fileUrl(e),{cache:"no-store"});if(!i.ok)throw new Error(`could not read the file (${i.status})`);return i.blob()}openFileInBrowser(e){const i=document.createElement("form");i.method="post",i.action=this.fileEndpoint(),i.target="_blank",i.rel="noopener",i.hidden=!0;for(const[n,s]of[["path",e],["token",Td()]]){const r=document.createElement("input");r.type="hidden",r.name=n,r.value=s,i.appendChild(r)}document.body.appendChild(i),i.submit(),i.remove()}fileUrl(e){return`${this.fileEndpoint()}?path=${encodeURIComponent(e)}&token=${encodeURIComponent(Td())}`}fileEndpoint(){return`${location.protocol==="https:"?"https":"http"}://${jm()}/file`}useToken(e){try{localStorage.setItem(Gg,e.trim())}catch{}this.retry=0,this.connect()}send(e){const i=JSON.stringify(e);this.socket?.readyState===WebSocket.OPEN?this.socket.send(i):this.queue.push(i)}invoke(e,i={}){return new Promise((n,s)=>{const r=this.seq++;this.pending.set(r,{resolve:n,reject:s,sent:this.socket?.readyState===WebSocket.OPEN}),this.send({t:"invoke",id:r,cmd:e,args:i})})}on(e,i){let n=this.listeners.get(e);return n||this.listeners.set(e,n=new Set),n.add(i),()=>n.delete(i)}onState(e){return this.stateFns.add(e),e(this.state),()=>this.stateFns.delete(e)}}const he=new SO,kO=2e4;class CO{seenAt=new Map;whole=new Set;held=new Map;asked=new Map;torn=new Set;mark(e){return this.seenAt.get(e)??0}holds(e){return this.whole.has(e)}own(e){this.whole.add(e),this.seenAt.set(e,0),this.held.delete(e),this.asked.delete(e),this.torn.delete(e)}forget(e){this.seenAt.delete(e),this.whole.delete(e),this.held.delete(e),this.asked.delete(e),this.torn.delete(e)}begin(e,i){const n=this.whole.has(e)?this.mark(e):i??0;return this.asked.set(e,n),this.held.set(e,[]),this.torn.delete(e),n}end(e,i){if(this.torn.has(e))throw this.abandon(e),new Error("Too many live events arrived during chat sync; reopen the chat to retry.");let n=Math.max(this.mark(e),this.asked.get(e)??0);const s=[];for(const r of[...i,...this.held.get(e)??[]])r.seq<=n||(s.push(r),n=r.seq);return this.asked.delete(e),this.held.delete(e),this.seenAt.set(e,n),this.whole.add(e),s}abandon(e){this.asked.delete(e),this.held.delete(e),this.torn.delete(e)}live(e,i,n){const s=this.held.get(e);return s&&typeof i=="number"?(s.length>=kO?this.torn.add(e):s.push({seq:i,event:n}),[]):typeof i!="number"?this.whole.has(e)?[{seq:this.mark(e),event:n}]:[]:this.whole.has(e)?i<=this.mark(e)?[]:(this.seenAt.set(e,i),[{seq:i,event:n}]):[{seq:i,event:n}]}}const EO="octiq.chat-cache",Ac="checkpoints",MO=12;function xw(){return new Promise(t=>{let e=!1;const i=s=>{if(e){s?.close();return}e=!0,clearTimeout(n),t(s)},n=setTimeout(()=>i(),500);try{const s=indexedDB.open(EO,1);s.onupgradeneeded=()=>{s.result.createObjectStore(Ac,{keyPath:"id"}).createIndex("updatedAt","updatedAt")},s.onsuccess=()=>i(s.result),s.onerror=()=>i(),s.onblocked=()=>i()}catch{i()}})}async function AO(t){const e=await xw();if(e)return new Promise(i=>{const n=r=>{clearTimeout(s),e.close(),i(r)},s=setTimeout(()=>n(),500);try{const r=e.transaction(Ac).objectStore(Ac).get(t);r.onsuccess=()=>{const o=r.result;n(o?.id===t&&Number.isSafeInteger(o.seq)&&o.seq>=0&&Array.isArray(o.state?.messages)?o:void 0)},r.onerror=()=>n()}catch{n()}})}async function bw(t){const e=await xw();if(e)try{const i=e.transaction(Ac,"readwrite"),n=i.objectStore(Ac);n.put(t);let s=0;const r=n.index("updatedAt").openKeyCursor(null,"prev");r.onsuccess=()=>{const o=r.result;o&&(++s>MO&&n.delete(o.primaryKey),o.continue())},await new Promise(o=>{i.oncomplete=()=>o(),i.onerror=()=>o(),i.onabort=()=>o()})}catch{}finally{e.close()}}async function m5(t){const e=await xw();if(e)try{e.transaction(Ac,"readwrite").objectStore(Ac).delete(t)}catch{}finally{e.close()}}const XT="Base directory for this skill: ",LO=/\/plugins\/cache\/[^/]+\/([^/]+)\/[^/]+\/skills\/[^/]+\/?$/;function ZT(t){return t.startsWith(XT)}function JT(t){if(!ZT(t)){const o=t.trim();return o?{dir:"",name:"",summary:g5(o),body:o}:null}const e=t.indexOf(`
|
|
11
|
+
`),i=(e===-1?t:t.slice(0,e)).slice(XT.length).trim();if(!i)return null;const n=e===-1?"":t.slice(e+1).trim(),s=i.replace(/\/+$/,"").split("/").pop()||i,r=LO.exec(i)?.[1];return{dir:i,name:s,scope:r,summary:g5(n),body:n}}function g5(t){const e=t.split(/\n\s*\n/);for(const i of e){const n=i.trim();if(!n||/^(#|>|```|---|\||[-*+] |\d+\. |<)/.test(n))continue;const s=n.replace(/\s+/g," ").replace(/\*\*|__|`/g,"").replace(/(^|\s)[*_](\S[^*_]*\S|\S)[*_](?=[\s.,;:!?)]|$)/g,"$1$2").trim(),r=/^(.*?[.!?])(?:\s|$)/.exec(s);return r?r[1]:s}return""}function TO(t){const e=/<command-name>([\s\S]*?)<\/command-name>/.exec(t)?.[1]?.trim();if(!e)return null;const i=/<command-args>([\s\S]*?)<\/command-args>/.exec(t)?.[1]?.trim()??"",n=e.startsWith("/")?e:`/${e}`;return i?`${n} ${i}`:n}function Qg(t){const e=/^\/([a-zA-Z0-9_-]+:)?([a-zA-Z0-9_-]+)(\s[\s\S]*)?$/.exec(t.trim());return e?{plugin:(e[1]??"").replace(/:$/,""),name:e[2]??"",args:(e[3]??"").trim()}:null}function eN(t,e){const i=Qg(t),n=Qg(e);return!i||!n?t.trim()===e.trim():i.name!==n.name||i.args!==n.args?!1:!i.plugin||!n.plugin||i.plugin===n.plugin}function NO(t,e){if(!eN(t,e))return;const i=Qg(t),n=Qg(e);if(!(!i||!n||i.plugin||!n.plugin))return`${n.plugin}:${n.name}`}function kg(t){return t&&typeof t=="object"?t:{}}function tr(t){return typeof t=="string"?t:""}function jO(t){const e=tr(t.server).trim(),i=tr(t.tool).trim();return i.toLowerCase().startsWith("mcp__")?i:e&&i?`mcp__${e}__${i}`:i||(e?`mcp__${e}`:"mcp_tool_call")}function RO(t){const e=tr(kg(t.error).message).trim();if(e)return e;if(t.result===void 0||t.result===null)return"";if(typeof t.result=="string")return t.result;try{return JSON.stringify(t.result,null,2)}catch{return String(t.result)}}function Rm(t,e){return t==="failed"?"error":t==="completed"?"done":t==="in_progress"?"running":e?"done":"running"}function DO(t){const e=kg(t),i=tr(e.type);if(i==="turn.completed")return{kind:"done"};if(i!=="item.started"&&i!=="item.completed")return null;const n=kg(e.item),s=tr(n.id);if(!s)return null;const r=i==="item.completed",o=tr(n.status);switch(tr(n.type)){case"agent_message":{const a=tr(n.text).trim(),u=tr(n.phase),h=u==="commentary"||u==="final_answer"?u:void 0;return r&&a?{kind:"say",text:a,...h?{phase:h}:{}}:null}case"command_execution":return{kind:"tool",id:s,name:"command_execution",args:{command:tr(n.command)},state:Rm(o,r),...r?{result:tr(n.aggregated_output)}:{},...r&&typeof n.exit_code=="number"&&Number.isInteger(n.exit_code)?{details:{exit_code:n.exit_code}}:{}};case"file_change":{const a=Array.isArray(n.changes)?n.changes:[],u=kg(a[0]);return{kind:"tool",id:s,name:"file_change",args:{file_path:tr(u.path),changes:a},state:Rm(o,r)}}case"web_search":return{kind:"tool",id:s,name:"web_search",args:{query:tr(n.query)},state:Rm(o,r)};case"mcp_tool_call":{const a=r?RO(n):"";return{kind:"tool",id:s,name:jO(n),args:n.arguments??{},state:Rm(o,r),...r&&a?{result:a}:{}}}default:return null}}function ba(t){return t&&typeof t=="object"?t:{}}function nn(t){return typeof t=="string"?t:""}function tN(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(i=>{const n=ba(i);return nn(n.text)||nn(n.output)}).filter(Boolean).join(`
|
|
12
|
+
`);const e=ba(t);return nn(e.output)||nn(e.text)||tN(e.content)}function iN(t){return nn(t)}function BO(t){return Array.isArray(t)?t.flatMap(e=>{const i=ba(e);switch(nn(i.type)){case"text":return nn(i.text)?[{kind:"text",text:nn(i.text)}]:[];case"thinking":return nn(i.thinking)?[{kind:"thinking",text:nn(i.thinking)}]:[];case"toolCall":{const n=nn(i.id);return n?[{kind:"tool",id:n,name:iN(i.name),args:i.arguments}]:[]}default:return[]}}):[]}function OO(t){const e=ba(t),i=nn(e.type);if(i==="session"){const n=nn(e.id);return n?{kind:"session",id:n,cwd:nn(e.cwd)}:null}if(i==="turn_start")return{kind:"turn"};if(i==="agent_settled")return{kind:"done"};if(i==="agent_end"&&!("willRetry"in e))return{kind:"done"};if(i==="message_update"){const n=ba(e.assistantMessageEvent),s=nn(n.delta);return s?n.type==="text_delta"?{kind:"delta",block:"text",text:s}:n.type==="thinking_delta"?{kind:"delta",block:"thinking",text:s}:null:null}if(i==="message_end"){const n=ba(e.message);if(n.role!=="assistant")return null;const s=nn(n.stopReason);return{kind:"message",content:BO(n.content),model:nn(n.responseModel)||nn(n.model),usage:ba(n.usage),...s==="error"?{error:nn(n.errorMessage)||"Provider request failed"}:{},aborted:s==="aborted"}}if(i==="tool_execution_start"||i==="tool_execution_end"){const n=nn(e.toolCallId);if(!n)return null;const s=i==="tool_execution_end";return{kind:"tool",id:n,name:iN(e.toolName),args:e.args,state:s?e.isError===!0?"error":"done":"running",...s?{result:tN(e.result),details:ba(e.result).details}:{}}}return null}const IO=/^<local-command-(?:stdout|stderr)>([\s\S]*)<\/local-command-(?:stdout|stderr)>$/,PO=/\u001b\[[0-9;]*m/g;function zO(t){const e=IO.exec(t.trim());return e?(e[1]??"").replace(PO,"").trim():null}const $O="<task-notification>";function FO(t){const e=t.trim();if(!e.startsWith($O)||!e.includes("</task-notification>"))return null;const i=Nd(e,"task-id");return i?{taskId:i,toolUseId:Nd(e,"tool-use-id"),outputFile:Nd(e,"output-file"),status:Nd(e,"status"),summary:Nd(e,"summary")??""}:null}function Nd(t,e){return new RegExp(`<${e}>([\\s\\S]*?)</${e}>`).exec(t)?.[1]?.trim()||void 0}const HO="=== chat service resumed ===",WO="Chat service resumed.",qO="=== carry on where you stopped ===";function UO(t){if(!(!t.startsWith(HO)&&!t.startsWith(qO)))return WO}function VO({id:t,running:e}){return e.has(t)}const KO="=== what the others in this chat just said ===",YO=/^--- (.+) ---$/gm;function GO(t){const e=[];for(const i of t.matchAll(YO)){const n=i[1]?.trim();n&&!e.includes(n)&&e.push(n)}return e}function QO(t){return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function XO(t){if(!t.startsWith(KO))return;const e=GO(t);return e.length?`passed on what ${QO(e)} said`:"passed the answers on"}const ZO=new Set(["edit","update","write","multiedit","applypatch","notebookedit"]);function JO(t){return ZO.has((t||"").toLowerCase())}const Xg=t=>t&&typeof t=="object"?t:{},Mr=t=>typeof t=="string"?t:"",v5=t=>typeof t=="number"&&Number.isFinite(t)?t:0;function nN(t,e,i){if(!JO(t))return null;const n=(t||"").toLowerCase(),s=Xg(e),r=Xg(i),o=Mr(r.filePath)||Mr(s.file_path)||Mr(s.path)||Mr(s.notebook_path),a=e8(o,r);if(a)return a;if(n==="write"){const p=Mr(s.content);return p?sN(o,p,"create"):null}if(n==="multiedit")return i8(o,s);const u=Mr(s.old_string),h=Mr(s.new_string);return!u&&!h?null:W0({path:o,kind:"edit",rows:rN(kf(u),kf(h)),numbered:!1})}function e8(t,e){const i=Mr(e.type)==="create",n=Array.isArray(e.structuredPatch)?e.structuredPatch:null;if(!n)return null;if(!n.length)return i?sN(t,Mr(e.content),"create"):{path:t,kind:"edit",rows:[],added:0,removed:0,numbered:!0};const s=[];let r=0;for(const o of n){const a=Xg(o);let u=v5(a.oldStart)||1,h=v5(a.newStart)||1;s.length&&s.push({kind:"gap",text:t8(h-r)});for(const p of(Array.isArray(a.lines)?a.lines:[]).map(Mr)){if(p.startsWith("\\"))continue;const m=p.slice(1);p.startsWith("+")?s.push({kind:"add",new:h++,text:m}):p.startsWith("-")?s.push({kind:"del",old:u++,text:m}):s.push({kind:"ctx",old:u++,new:h++,text:m})}r=h}return W0({path:t,kind:i?"create":"edit",rows:s,numbered:!0})}function t8(t){return t<=0?"⋯":`⋯ ${t} unchanged line${t===1?"":"s"}`}function sN(t,e,i){const n=kf(e);return W0({path:t,kind:i,rows:n.map((s,r)=>({kind:"add",new:r+1,text:s})),numbered:!0})}function i8(t,e){const i=Array.isArray(e.edits)?e.edits:[];if(!i.length)return null;const n=[];for(const s of i){const r=Xg(s);n.length&&n.push({kind:"gap",text:"⋯"}),n.push(...rN(kf(Mr(r.old_string)),kf(Mr(r.new_string))))}return W0({path:t,kind:"edit",rows:n,numbered:!1})}function kf(t){if(!t)return[];const e=t.split(`
|
|
13
|
+
`);return e.length>1&&e[e.length-1]===""&&e.pop(),e}const n8=4e5;function rN(t,e){const i=t.length,n=e.length;if(!i)return e.map(h=>({kind:"add",text:h}));if(!n)return t.map(h=>({kind:"del",text:h}));if(i*n>n8)return[...t.map(h=>({kind:"del",text:h})),...e.map(h=>({kind:"add",text:h}))];const s=n+1,r=new Uint32Array((i+1)*s);for(let h=i-1;h>=0;h--)for(let p=n-1;p>=0;p--)r[h*s+p]=t[h]===e[p]?r[(h+1)*s+p+1]+1:Math.max(r[(h+1)*s+p],r[h*s+p+1]);const o=[];let a=0,u=0;for(;a<i&&u<n;)t[a]===e[u]?(o.push({kind:"ctx",text:t[a]}),a++,u++):r[(a+1)*s+u]>=r[a*s+u+1]?o.push({kind:"del",text:t[a++]}):o.push({kind:"add",text:e[u++]});for(;a<i;)o.push({kind:"del",text:t[a++]});for(;u<n;)o.push({kind:"add",text:e[u++]});return o}function W0(t){let e=0,i=0;for(const n of t.rows)n.kind==="add"&&e++,n.kind==="del"&&i++;return{...t,added:e,removed:i}}const s8={read:"read",notebookread:"read",taskoutput:"read",write:"edit",edit:"edit",multiedit:"edit",notebookedit:"edit",applypatch:"edit",file_change:"edit",bash:"run",bashoutput:"run",killshell:"run",killbash:"run",command_execution:"run",glob:"search",grep:"search",ls:"search",toolsearch:"search",webfetch:"web",websearch:"web",web_search:"web",task:"agent",agent:"agent",workflow:"agent",sendmessage:"message",listagents:"other",todowrite:"plan",exitplanmode:"plan",enterplanmode:"plan",askuserquestion:"plan"};function Zg(t,e){if(!t||typeof t!="object")return"";const i=t[e];return typeof i=="string"?i.trim():""}const r8=new Set([".","cd","export","readonly","set","source","unset"]),oN=new Set(["fd","find","grep","rg"]),lN=new Set(["cat","head","sed","tail"]),o8=new Set(["-e","--regexp"]),_5=new Set(["-A","-B","-C","-D","-E","-F","-M","-T","-d","-f","-g","-j","-m","-p","-r","-t","-x","--after-context","--before-context","--color","--colors","--context","--context-separator","--encoding","--engine","--exclude","--exclude-dir","--field-context-separator","--field-match-separator","--file","--glob","--iglob","--ignore-file","--include","--max-columns","--max-count","--max-depth","--path-separator","--pre","--pre-glob","--replace","--sort","--sortr","--threads","--type","--type-add","--type-clear"]),l8=new Set(["-ilname","-iname","-ipath","-iregex","-iwholename","-lname","-name","-path","-regex","-wholename"]),a8=new Set(["-C","-c","--config-env","--exec-path","--git-dir","--namespace","--super-prefix","--work-tree"]),y5=new Set(["-R","--hostname","--repo"]),c8=new Set(["alias","attestation","auth","cache","codespace","extension","gist","gpg-key","issue","label","pr","project","release","repo","run","search","secret","ssh-key","variable","workflow"]);function u8(t){const e=[];let i="",n="",s=!1;for(let r=0;r<t.length;r++){const o=t[r];if(n){o===n?n="":o==="\\"&&n==='"'&&r+1<t.length&&t[r+1]==='"'?i+=t[++r]:i+=o,s=!0;continue}o==='"'||o==="'"?(n=o,s=!0):/\s/.test(o)?(s&&e.push(i),i="",s=!1):(i+=o,s=!0)}return s&&e.push(i),e}function ix(t){const e=t.replace(/\\/g,"/").split("/").filter(s=>s&&s!=="."),i=e.at(-1)??"",n=e.at(-2);return n?`${e.length>2?"...":""}${n}/${i}`:i}function x5(t){for(const e of["file_path","path","notebook_path"]){const i=Zg(t,e);if(i)return ix(i)}return""}function ww(t,e){const i=t.toLowerCase(),n=Zg(e,"command");if(i==="bash")return n?{shell:"bash",body:n}:null;if(i!=="command_execution")return null;const s=n.match(/^\s*(?:"([^"]+)"|'([^']+)'|(\S+))\s+((?:-[A-Za-z]+\s+)+)([\s\S]+)$/);if(!s||!s[4].split(/\s+/).some(u=>u.slice(1).includes("c")))return null;const o=(s[1]||s[2]||s[3]||"").replace(/\\/g,"/").split("/").pop()?.toLowerCase();if(o!=="zsh"&&o!=="bash")return null;let a=s[5].trim();return(a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'"))&&(a=a.slice(1,-1)),{shell:o,body:a}}function q0(t,e){const i=ww(t,e);if(!i)return null;for(const n of i.body.split(/\s*(?:&&|\|\||;|\n)\s*/)){const s=u8(n.trim());let r=0;for(;r<s.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(s[r]);)r++;const a=(s[r]??"").replace(/\\/g,"/").split("/").pop()?.toLowerCase()??"";if(!(!a||r8.has(a)))return{...i,tool:a,args:s.slice(r+1)}}return null}function aN(t,e){return q0(t,e)?.tool??""}function h8(t,e){const i=q0(t,e);if(!i||!oN.has(i.tool)||i.tool==="rg"&&i.args.includes("--files"))return"";if(i.tool==="find"){for(let n=0;n<i.args.length-1;n++)if(l8.has(i.args[n]))return i.args[n+1];return""}for(let n=0;n<i.args.length;n++){const s=i.args[n];if(s==="--"||o8.has(s))return i.args[n+1]??"";if(s.startsWith("--regexp="))return s.slice(9);if(s.startsWith("-e")&&s.length>2)return s.slice(2);if(_5.has(s)){n++;continue}if(![..._5].some(r=>r.length===2&&s.startsWith(r)&&s.length>2)&&!s.startsWith("-"))return s}return""}function d8(t){return t.replace(/^["'$(]+|["')\\]+$/g,"")}function f8(t,e){const i=ww(t,e);if(!i)return[];const n=[],s=/(?:^|[^\w.-])gh(?=\s)/gm;for(const r of i.body.matchAll(s)){const o=(r.index??0)+r[0].lastIndexOf("gh")+2,u=i.body.slice(o).split(/\s*(?:&&|\|\||;|\n)\s*/,1)[0].trim().split(/\s+/).map(d8).filter(Boolean);let h=0;for(;h<u.length&&u[h].startsWith("-");)y5.has(u[h])&&h++,h++;const p=u[h]?.toLowerCase()??"";if(!/^[a-z0-9][a-z0-9-]*$/.test(p))continue;let m=p;if(c8.has(p)){let v=h+1;for(;v<u.length&&u[v].startsWith("-");)y5.has(u[v])&&v++,v++;const _=u[v]?.toLowerCase()??"";/^[a-z0-9][a-z0-9-]*$/.test(_)&&(m+=` ${_}`)}n.push(m)}return n}function p8(t){const e=new Map;for(const s of t)e.set(s,(e.get(s)??0)+1);const i=[...e.entries()],n=i.slice(0,3).map(([s,r])=>`${s}${r>1?`×${r}`:""}`);return i.length>n.length&&n.push(`+${i.length-n.length} more`),n.join(", ")}function m8(t,e){const i=q0(t,e);if(!i||!lN.has(i.tool))return"";const n=i.args.findIndex(o=>o==="|"||/^[<>]/.test(o)),s=n>=0?i.args.slice(0,n):i.args;if(i.tool==="sed"){const o=[];let a=!1;for(let u=0;u<s.length;u++){const h=s[u];if(["-e","--expression","-f","--file"].includes(h)){a=!0,u++;continue}if(h.startsWith("-e")||h.startsWith("-f")){a=!0;continue}if(!h.startsWith("-")){if(!a){a=!0;continue}o.push(h)}}return ix(o.at(-1)??"")}const r=[];for(let o=0;o<s.length;o++){const a=s[o];if(["-n","--lines","-c","--bytes"].includes(a)){o++;continue}if(a==="--"){r.push(...s.slice(o+1));break}!a.startsWith("-")&&!/^\+?\d+$/.test(a)&&r.push(a)}return ix(r.at(-1)??"")}function g8(t,e){const i=q0(t,e);if(i?.tool!=="git")return"";for(let n=0;n<i.args.length;n++){const s=i.args[n];if(a8.has(s)){n++;continue}if(!(s.startsWith("-C")||s.startsWith("-c")||s.startsWith("--"))&&!s.startsWith("-"))return s.toLowerCase()}return""}function v8(t){const e=t.match(/^mcp__(.+?)__(.+)$/i);return e?`mcp(${e[1]}:${e[2]})`:""}function Lc(t,e){const i=t||"",n=i.toLowerCase();if(n==="file_change"){const r=x5(e);return{kind:"edit",label:r?`edit(${r})`:"edit"}}if(n==="command_execution"||n==="bash"){const r=ww(t,e),o=f8(t,e);if(r&&o.length>0)return{kind:"run",label:`gh(${p8(o)})`};const a=aN(t,e);if(oN.has(a)){const u=h8(t,e);return{kind:"search",label:`search(${a}${u?`: ${u}`:""})`}}if(lN.has(a))return{kind:"read",label:`read(${m8(t,e)||a})`};if(a==="git"){const u=g8(t,e);return{kind:"run",label:u?`git(${u})`:"git"}}if(a==="gh")return{kind:"run",label:"gh"};if(a)return{kind:"run",label:`${r?.shell??"shell"}(${a})`}}if(n==="skill")return{kind:"skill",label:i||"tool"};if(n.startsWith("mcp__"))return{kind:"mcp",label:v8(i)||i};const s=s8[n]??"other";if(s==="read"||s==="edit"){const r=x5(e);if(r)return{kind:s,label:`${s}(${r})`}}return{kind:s,label:i||"tool"}}function Sw(t,e,i=!1){const n=e;if(!n||typeof n!="object")return"";if(Lc(t,e).kind==="skill"){const r=Zg(e,"skill"),o=Zg(e,"args");return[r,o].filter(Boolean).join(" ")}const s=i?["description","subagent_type","prompt"]:["file_path","path","pattern","command","query","url","prompt"];for(const r of s){const o=n[r];if(typeof o=="string"&&o.trim())return o}return""}const _8=1,y8=new Set(["agent","skill"]),cN=new Set(["ask_user","ask_user_questions","askuserquestion"]),x8=[...cN].map(t=>`__${t}`);function b8(t){const e=/^```([\w+-]*)\n([\s\S]*?)\n?```$/.exec(t.trim());return e?{lang:e[1]??"",body:e[2]??""}:null}function w8(t,e){const i=[];let n=[];const s=()=>{if(n.length>=_8){const r=n.slice(0,-1),o=n[n.length-1];i.push({kind:"group",tools:r.map(a=>a.tool),newest:o.tool,index:o.index})}else for(const r of n)i.push({kind:"block",block:r.tool,index:r.index});n=[]};return t.forEach((r,o)=>{if(r.kind==="tool"&&S8(r,e)){n.push({tool:r,index:o});return}if(r.kind==="thinking")return;s();const a=i[i.length-1],u=a?.kind==="block"&&a.block.kind==="tool"&&!a.note||a?.kind==="group"&&a.tools.length===0&&!a.note;if(r.kind==="text"&&u){const h=b8(r.text);if(h){i[i.length-1]={...a,note:h,index:o};return}}i.push({kind:"block",block:r,index:o})}),s(),i}function S8(t,e){if(e?.(t)||t.id.startsWith("agent-error-"))return!1;const i=t.name.toLowerCase();return cN.has(i)||x8.some(n=>i.endsWith(n))||t.state==="stopped"?!1:!y8.has(Lc(t.name,t.args).kind)}function k8(t){const e=t.map(o=>Lc(o.name,o.args)),i=t[t.length-1],n=t.every(o=>o.name===t[0].name),s=t.filter(o=>o.state==="done").length,r=t.filter(o=>o.state==="error").length;return{kind:n?e[0].kind:Lc(i.name,i.args).kind,count:t.length,noun:n?`× ${e[0].label}`:"calls",state:t.some(o=>o.state==="running")?"running":r?"error":"done",success:s,failed:r,detail:Sw(i.name,i.args)}}const C8=["edit","read","run","search","web","message","mcp","plan","other"],E8={edit:{verb:"Edited",singular:"file",plural:"files"},run:{verb:"ran",singular:"command",plural:"commands"},read:{verb:"read",singular:"file",plural:"files"},search:{verb:"searched",singular:"time",plural:"times"},web:{verb:"browsed",singular:"page",plural:"pages"},agent:{verb:"started",singular:"agent",plural:"agents"},message:{verb:"sent",singular:"message",plural:"messages"},skill:{verb:"used",singular:"skill",plural:"skills"},mcp:{verb:"used",singular:"tool",plural:"tools"},plan:{verb:"updated",singular:"plan",plural:"plans"},other:{verb:"used",singular:"tool",plural:"tools"}};function M8(t){const e=new Map,i=new Map;for(const o of t){const a=Lc(o.name,o.args).kind;if(e.set(a,(e.get(a)??0)+1),a==="read"||a==="edit"){const u=A8(o.args);if(u){const h=i.get(a)??new Set;h.add(u),i.set(a,h)}}}const n=C8.filter(o=>e.has(o)),s=n.slice(0,3),r=s.map(o=>{const a=i.get(o)?.size||e.get(o)||0,u=E8[o];if(o==="edit"||o==="read")return`${u.verb} files`;const h=a===1?`a ${u.singular}`:`${a} ${u.plural}`;return`${u.verb} ${h}`});return n.length>s.length&&r.push(`+${n.length-s.length} more`),{kind:s[0]??"other",label:r.join(", ")||"Used tools"}}function A8(t){const e=t;if(!e||typeof e!="object")return"";for(const i of["file_path","path","notebook_path"]){const n=e[i];if(!(typeof n!="string"||!n.trim()))return n.trim().replace(/[/\\]+$/,"").split(/[/\\]/).pop()??""}return""}const L8=new Set(["git","gh","pnpm","npm","npx","yarn","cargo","docker","brew","go","kubectl","dotnet","tauri"]);function T8(t){const e=t.trim().split(/\s+/).filter(Boolean);let i=0;for(;i<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[i]);)i++;const n=(e[i]??"").split("/").pop()??"";if(!n)return t.trim().slice(0,24);const s=e[i+1];return L8.has(n)&&s&&!s.startsWith("-")?`${n} ${s}`:n}function N8(t,e,i){return e.trim()?e.trim():i.trim()?T8(i):t==="local_agent"?"subagent":t==="local_workflow"?"workflow":"background command"}function j8(t){const e=new Set;for(const i of t)i.toolUseId&&e.add(i.toolUseId);return e}function R8(t,e){if(t.length===0)return null;const i=t.reduce((n,s)=>s.startedAt<n.startedAt?s:n);return{count:t.length,label:i.label,elapsedMs:Math.max(0,e-i.startedAt)}}function Vu(t){return t.startsWith("[OctiqFlow automatic resume after usage reset]")?"automatically resumed after the usage limit reset":XO(t)??UO(t)}const Tc=()=>({messages:[],agents:[],background:[],busy:!1,notices:[],stopping:!1}),D8=/^\[Request interrupted by user(?: for tool use)?\]$/,Jg=t=>t.kind==="tool"&&t.state==="running"?{...t,state:"stopped"}:t,B8="<synthetic>",O8=/^\/model\s+(\S+)\s*$/,I8=/^\/config\s+(?:\S+\s+)*?model=(\S+)/,b5=/\[Image:[^\]]*\]/g;function nx(t,e){const i=e.trim();if(/usage limit|session limit|weekly limit|out of credits|quota|rate.?limit|purchase more credits|upgrade to pro/i.test(i)){const s=/try again (?:at|after|on)\s+([^.()]+)/i.exec(i)?.[1]?.trim()??/resets\s+([^.·]+)/i.exec(i)?.[1]?.trim();return{title:t==="codex"||t==="pi"?"Your Codex account is out of credits":"You have hit your Claude usage limit",detail:s?`It comes back at ${s}.`:i,link:/https?:\/\/[^\s)]+/.exec(i)?.[0],outOfCredit:!0}}return{title:"The agent stopped with an error",detail:i||void 0}}function P8(t){switch(t){case"compacting":return"Compacting the conversation to make room…";case"retrying":return"Retrying…";case"queued":return"Queued behind another request…";case"resuming":return"Picking the session back up…";case"starting":return"Starting…";case"waiting":return"Waiting…";default:return}}const Ct=t=>t&&typeof t=="object"?t:{},of=t=>Array.isArray(t)?t:[],Ce=t=>typeof t=="string"?t:"";function z8(t){const e=Ct(t),i=s=>typeof s=="number"&&s>=0?s:0,n=i(e.input_tokens)+i(e.cache_creation_input_tokens)+i(e.cache_read_input_tokens)+i(e.output_tokens);return n>0?n:void 0}function sx(t,e,i){const n=t[t.length-1];if(n&&n.kind===e){const s={...n,text:n.text+i};return[...t.slice(0,-1),s]}return[...t,{kind:e,text:i}]}function $8(t){if(t==null)return;const e=Ct(t),i=Ce(e.id),n=Ce(e.name);return!i&&!n?{id:"",name:"Unknown",agent:""}:{id:i,name:n||"Unknown",agent:Ce(e.agent)}}function jd(t,e,i,n){const s=t.messages.map(o=>o.streaming&&o.parent===e&&o.speaker?.id===i?.id).lastIndexOf(!0);if(s<0){const o={id:`m${t.messages.length}`,role:"assistant",blocks:[],streaming:!0,parent:e,speaker:i};return{...t,messages:[...t.messages,n(o)]}}const r=[...t.messages];return r[s]=n(r[s]),{...t,messages:r}}const F8=t=>{if(!t.busy||t.status&&t.status!=="thinking"&&t.status!=="requesting")return!1;const e=[...t.messages].reverse().find(n=>n.streaming);if(!e)return!0;const i=e.blocks[e.blocks.length-1];return!i||i.kind==="thinking"},H8=t=>{if(!t.busy)return"";const e=[...t.messages].reverse().find(n=>n.streaming),i=e?.blocks[e.blocks.length-1];return i?.kind==="thinking"?i.text:""},W8=t=>(t.turnTokens??0)+(t.turnDraft??0),q8=t=>(t.turnDraft??0)>0,w5=t=>t.length/4,ka={turnStartedAt:void 0,turnTokens:void 0,turnDraft:void 0,status:void 0,activity:void 0,compactingSince:void 0,awaitingSummary:void 0};function uN(t,e){return t.kind!==e.kind?!1:t.kind==="tool"?e.kind==="tool"&&t.id===e.id:"text"in t&&"text"in e&&t.text===e.text}const U8=new Set(["local_agent","local_workflow"]);function V8(t,e,i){const n=Ce(e.task_id);if(!n||t.agents.some(o=>o.id===n))return t;const s=Ce(e.task_type);if(s&&!U8.has(s))return t;const r={id:n,toolUseId:Ce(e.tool_use_id)||void 0,label:Ce(e.description)||Ce(e.workflow_name)||"agent",kind:Ce(e.task_type)||"local_agent",detail:Ce(e.subagent_type)||Ce(e.workflow_name)||void 0,status:"running",startedAt:i};return{...t,agents:[...t.agents,r]}}function kw(t,e,i){return!e||!t.agents.some(n=>n.id===e)?t:{...t,agents:t.agents.map(n=>n.id===e?{...n,...i}:n)}}function K8(t,e){return kw(t,Ce(e.task_id),hN(Ct(e.patch).status))}function Y8(t,e){const i=Ct(e.usage),n=s=>typeof s=="number"?s:void 0;return kw(t,Ce(e.task_id),{...hN(e.status),toolUseId:Ce(e.tool_use_id)||void 0,tokens:n(i.total_tokens),toolCalls:n(i.tool_uses),durationMs:n(i.duration_ms),summary:Ce(e.summary)||void 0,outputFile:Ce(e.output_file)||void 0})}const Cw=new Set(["running","in_progress","pending","queued"]);function G8(t,e,i){const n=Ce(e.task_id);if(!n||t.background.some(o=>o.id===n))return t;const s=Ce(e.task_type)||"local_agent",r={id:n,toolUseId:Ce(e.tool_use_id)||void 0,label:N8(s,Ce(e.description)||Ce(e.workflow_name),Ce(e.command)),kind:s,startedAt:i};return{...t,background:[...t.background,r]}}function Ew(t,e){return!e||!t.background.some(i=>i.id===e)?t:{...t,background:t.background.filter(i=>i.id!==e)}}function Q8(t,e){const i=Ct(e.patch),n=Ce(i.status);return!n&&i.end_time===void 0||n&&Cw.has(n)?t:Ew(t,Ce(e.task_id))}function X8(t,e){const i=Ce(e.status);return i&&Cw.has(i)?t:Ew(t,Ce(e.task_id))}function Z8(t,e){const i=Ct(e.usage),n=o=>typeof o=="number"?o:void 0,s={tokens:n(i.total_tokens),toolCalls:n(i.tool_uses),durationMs:n(i.duration_ms)},r=e.workflow_progress;return Array.isArray(r)&&(s.phases=J8(r),s.workers=eI(r)),kw(t,Ce(e.task_id),s)}function J8(t){return t.map(Ct).filter(e=>Ce(e.type)==="workflow_phase").map(e=>({index:Number(e.index)||0,title:Ce(e.title)})).sort((e,i)=>e.index-i.index)}function eI(t){const e=i=>typeof i=="number"?i:void 0;return t.map(Ct).filter(i=>Ce(i.type)==="workflow_agent").map(i=>({id:Ce(i.agentId),index:Number(i.index)||0,label:Ce(i.label),phaseIndex:Number(i.phaseIndex)||0,model:Ce(i.model)||void 0,state:Ce(i.state)==="done"?"done":"start",queuedAt:e(i.queuedAt),startedAt:e(i.startedAt),attempt:e(i.attempt),tokens:e(i.tokens),toolCalls:e(i.toolCalls),durationMs:e(i.durationMs),promptPreview:Ce(i.promptPreview)||void 0,resultPreview:Ce(i.resultPreview)||void 0}))}function hN(t){const e=Ce(t);return e==="completed"||e==="failed"||e==="running"?{status:e}:{}}function qf(t,e,i=Date.now()){const n=Ct(e),s=Ce(n.type),r=Ce(n.parent_tool_use_id)||void 0,o=$8(n.octiq_speaker);if((r||o)&&(s==="system"||s==="result"||s==="thread.started"))return t;if(s==="octiq_user_turn_cancelled"||s==="octiq_user_turn_dismissed"){const h=Ce(n.uuid);return h?{...t,messages:t.messages.filter(p=>p.turnId!==h)}:t}if(s==="octiq_user_turn_delivery"){const h=Ce(n.uuid),p=Ce(n.state);return["queued","starting","dispatched","failed","unknown"].includes(p)?{...t,messages:t.messages.map(m=>m.turnId===h&&!m.echo&&!m.takenUp?{...m,delivery:p,queueLost:p==="failed"||void 0,queueAction:void 0,queueError:void 0}:m)}:t}if(s==="octiq_auto_resume_scheduled"){const h=Ce(n.id),p=Ce(n.agent),m=typeof n.reset_at=="number"?n.reset_at:0,v=typeof n.run_at=="number"?n.run_at:0;return!h||!["claude","codex","pi"].includes(p)||!m||!v?t:{...t,autoResume:{id:h,agent:p,resetAt:m,runAt:v}}}if(s==="octiq_auto_resume_cancelled"){const h=Ce(n.id);return!t.autoResume||h&&t.autoResume.id!==h?t:{...t,autoResume:void 0}}if(s==="octiq_auto_resume_started"){const h=Ce(n.id);return t.autoResume&&h&&t.autoResume.id!==h?t:{...t,autoResume:void 0,failure:void 0,busy:!0,stopping:!1,exited:void 0,turnStartedAt:i,turnTokens:0,turnDraft:0}}if(s==="octiq_auto_resume_failed")return{...t,autoResume:void 0,busy:!1,failure:{title:"Auto-resume could not start",detail:Ce(n.message)||"Resume this chat manually."}};const a=DO(n);if(a)return oI(t,a,r,o);const u=OO(n);if(u)return lI(t,u,n,r,o,i);if(s==="system"){const h=Ce(n.subtype);if(h==="status"){const m=Ce(n.status),v=m==="compacting";return{...t,status:m||void 0,activity:m?P8(m):void 0,compactingSince:v?t.compactingSince??i:void 0}}if(h==="thinking_tokens"){const m=n.estimated_tokens_delta;return typeof m!="number"||m<=0?t:{...t,turnDraft:(t.turnDraft??0)+m}}if(h.includes("compact")&&h.includes("boundary")){const m=Ct(n.compact_metadata),v=_=>typeof _=="number"&&_>0?_:void 0;return{...t,compactingSince:void 0,messages:[...t.messages,{id:`compact-${t.messages.length}`,role:"assistant",blocks:[{kind:"compacted",text:"",trigger:Ce(m.trigger)||void 0,preTokens:v(m.pre_tokens),postTokens:v(m.post_tokens),durationMs:v(m.duration_ms)}],streaming:!1}],awaitingSummary:!0}}if(h==="task_started")return G8(V8(t,n,i),n,i);if(h==="task_updated")return Q8(K8(t,n),n);if(h==="task_progress")return Z8(t,n);if(h==="task_notification")return X8(Y8(t,n),n);if(h!=="init")return t;const p=of(n.slash_commands).filter(m=>typeof m=="string");return{...t,sessionId:Ce(n.session_id)||t.sessionId,model:t.modelAsked?t.model:Ce(n.model)||t.model,cwd:Ce(n.cwd)||t.cwd,commands:p.length?p:t.commands}}if(s==="thread.started"){const h=Ce(n.thread_id);return h?{...t,sessionId:h}:t}if(s==="turn.started")return dN(t,n,r,o,i);if(s==="error"||s==="turn.failed"){const h=Ce(n.message)||Ce(Ct(n.error).message),p=nx("codex",h),m=t.messages.map(v=>v.streaming?{...v,streaming:!1}:v);if(!p.outOfCredit){p.inline=!0;let v=m.at(-1);(!v||v.role!=="assistant"||v.parent||v.speaker)&&(v={id:`m${m.length}`,role:"assistant",blocks:[],streaming:!1},m.push(v));const _=[...v.blocks],x=_.at(-1),S=`agent-error-${v.id}`,C={kind:"tool",id:S,name:"Agent stream",argsJson:"",args:{},result:h||p.title,state:"error"};x?.kind==="tool"&&x.id===S?_[_.length-1]=h?C:x:_.push(C),m[m.length-1]={...v,blocks:_}}return{...t,...ka,busy:!1,stopping:!1,failure:p,messages:m}}if(s==="token_count"){const h=Ct(n.info),p=Ct(h).context_window??n.context_window,m=Ct(h).total_token_usage??n.total_token_usage,v=Ct(m).input_tokens,_={...t};return typeof p=="number"&&p>0&&(_.contextWindow=p),typeof v=="number"&&v>0&&(_.contextTokens=v),_}if(s==="stream_event")return pI(t,Ct(n.event),r,o,i);if(s==="assistant"){const h=Ct(n.message),p=Ce(h.id),m=n.aborted===!0,v=r||o?void 0:z8(h.usage);v&&(t={...t,contextTokens:v});const _=Ce(h.model);if(!r&&!o&&_&&_!==B8&&_!==t.model&&(t={...t,model:_}),m&&t.messages.some(C=>C.id===p))return{...t,...ka,busy:!1,stopping:!1,stoppedAt:p,messages:t.messages.map(C=>C.id===p?{...C,streaming:!1,blocks:C.blocks.map(Jg)}:C)};const x=[];for(const C of of(h.content)){const k=Ct(C),M=Ce(k.type);M==="text"?x.push({kind:"text",text:Ce(k.text)}):M==="thinking"?x.push({kind:"thinking",text:Ce(k.thinking)}):M==="tool_use"&&x.push({kind:"tool",id:Ce(k.id),name:Ce(k.name),argsJson:"",args:k.input,state:"running"})}const S=t.messages.find(C=>C.id===p);if(S){const C=x.filter(k=>!S.blocks.some(M=>uN(M,k)));return{...t,messages:t.messages.map(k=>k.id===p?{...k,blocks:C.length?[...k.blocks,...C]:k.blocks,streaming:k.partial?k.streaming:!1}:k)}}return x.length?{...t,messages:[...t.messages,{id:p||`m${t.messages.length}`,role:"assistant",blocks:x,streaming:!1,parent:r,speaker:o}]}:t}if(s==="user"){const h=Ct(n.message).content,p=typeof h=="string"?[{type:"text",text:h}]:of(h);if(r)return S5(t,p,n);if(n.octiq_user_turn===!0){const M=Ce(n.uuid),L=p.filter(G=>Ce(Ct(G).type)==="text").map(G=>Ce(Ct(G).text)).join("").replace(b5,""),N=of(n.octiq_attachments).flatMap(G=>{const q=Ct(G),X=Ce(q.path);return X?[{path:X,name:Ce(q.name)||X.split(/[\\/]/).pop()||X,isImage:q.isImage!==!1}]:[]}),j=Ct(n.octiq_to),R=Ce(j.id),z=R?{id:R,name:Ce(j.name)||"Unknown"}:void 0,J=[...t.messages].reverse().find(G=>G.role==="user"&&(M&&G.turnId===M||!G.turnId&&!G.echo&&!G.takenUp&&G.blocks.some(q=>q.kind==="text"&&"text"in q&&q.text===L)));return J?!M||J.turnId===M?t:{...t,messages:t.messages.map(G=>G===J?{...G,turnId:M}:G)}:{...t,messages:[...t.messages,{id:M?`u:${M}`:`u${t.messages.length}`,role:"user",blocks:[{kind:"text",text:L}],streaming:!1,...N.length?{attachments:N}:{},...z?{to:z}:{},...M?{turnId:M}:{},...Vu(L)?{relay:Vu(L)}:{}}]}}if(p.some(M=>D8.test(Ce(Ct(M).text).trim()))){const M=t.messages[t.messages.length-1];return{...t,...ka,busy:!1,stopping:!1,stoppedAt:M?.id,messages:t.messages.map(L=>L.streaming||L.blocks.some(N=>N.kind==="tool"&&N.state==="running")?{...L,streaming:!1,blocks:L.blocks.map(Jg)}:L)}}const m=p.filter(M=>Ce(Ct(M).type)==="text").map(M=>Ce(Ct(M).text)).join("").replace(b5,"").trim(),v=Ce(n.uuid),_=zO(m);if(_!==null)return rI(t,_);if(rx(m)||t.awaitingSummary&&n.isSynthetic===!0){const M=hI(t,m);if(M)return M}const x=FO(m);if(x)return dI(t,x);const S=Ce(n.sourceToolUseID)||Ce(n.source_tool_use_id);if(ZT(m)||n.isMeta===!0&&nI(t,S)||n.isSynthetic===!0&&iI(t))return fI(t,m,S,v);const C=TO(m)??m,k=p.some(M=>Ce(Ct(M).type)==="image");if((C||k)&&!p.some(M=>Ce(Ct(M).type)==="tool_result")){if(v&&t.messages.some(N=>N.echo===v))return t;const M=Ce(n.octiq_user_turn_id),L=t.messages.find(N=>N.role==="user"&&!N.echo&&(M?N.turnId===M:!N.queueLost&&N.blocks.some(j=>j.kind==="text"&&eN(j.text,C))));if(L){const N=L.blocks.find(R=>R.kind==="text"),j=N&&"text"in N?NO(N.text,C):void 0;return{...t,messages:t.messages.map(R=>R===L?{...R,echo:v,delivery:"dispatched",queueLost:void 0,queueAction:void 0,queueError:void 0,...j?{ranSkill:j}:{}}:R)}}return{...t,messages:[...t.messages,{id:v||`u${t.messages.length}`,role:"user",blocks:[{kind:"text",text:C}],streaming:!1,echo:v,...Vu(C)?{relay:Vu(C)}:{}}]}}return S5(t,p,n)}if(s==="result"){const h=Ct(n.modelUsage);let p=t.contextWindow;for(const _ of Object.keys(h)){const x=Ct(h[_]).contextWindow;typeof x=="number"&&x>0&&(!p||x>p)&&(p=x)}const m=Ce(n.subtype),v=n.is_error===!0&&m!=="error_during_execution"&&!t.stopping;return{...t,...ka,busy:!1,stopping:!1,modelAsked:void 0,failure:v?nx("claude",Ce(n.result)||Ce(n.api_error_status)||m):t.failure,lastCostUsd:typeof n.total_cost_usd=="number"?n.total_cost_usd:t.lastCostUsd,lastDurationMs:typeof n.duration_ms=="number"?n.duration_ms:t.lastDurationMs,contextWindow:p,messages:t.messages.map(_=>_.streaming?{..._,streaming:!1}:_)}}return t}function S5(t,e,i){let n=t;const r=e.filter(o=>Ce(Ct(o).type)==="tool_result").length===1?i.tool_use_result??i.toolUseResult:void 0;for(const o of e){const a=Ct(o);if(Ce(a.type)!=="tool_result")continue;const u=Ce(a.tool_use_id),h=a.is_error===!0,p=typeof a.content=="string"?a.content:of(a.content).map(m=>Ce(Ct(m).text)).join("");n={...n,messages:n.messages.map(m=>({...m,blocks:m.blocks.map(v=>v.kind==="tool"&&v.id===u?{...v,result:p,details:r,state:h?"error":"done"}:v)}))}}return n}function tI(t){for(let e=t.messages.length-1;e>=0;e--){const i=t.messages[e].blocks;for(let n=i.length-1;n>=0;n--){const s=i[n];if(s.kind==="tool"&&s.name.toLowerCase()==="skill")return s}}}function iI(t){for(let e=t.messages.length-1;e>=0;e--){const i=t.messages[e].blocks.filter(n=>n.kind==="tool");if(i.length!==0)return i.some(n=>n.name.toLowerCase()==="skill"&&n.state!=="running"&&n.brief===void 0)}return!1}function nI(t,e){return!!e&&Mw(t,e)?.name.toLowerCase()==="skill"}function Mw(t,e){for(const i of t.messages)for(const n of i.blocks)if(n.kind==="tool"&&n.id===e)return n}const sI=/^compacted\b/i;function rI(t,e){if(!e)return t;const i=t.messages[t.messages.length-1];return sI.test(e)&&i?.blocks.some(n=>n.kind==="compacted")?t:{...t,messages:[...t.messages,{id:`local-${t.messages.length}`,role:"assistant",blocks:[{kind:"notice",text:e}],streaming:!1}]}}function oI(t,e,i,n){if(e.kind==="done")return{...t,...!n&&!i?{...ka,busy:!1,stopping:!1}:{},messages:t.messages.map(a=>a.streaming&&a.parent===i&&a.speaker?.id===n?.id?Aw(a):a)};if(e.kind==="say")return t0(t,i,n,o=>{const a=o.codexCandidate?[o.codexCandidate]:[],u=[...o.progress??[],...a];return e.phase==="commentary"?{...o,progress:[...u,e.text],codexCandidate:void 0}:e.phase==="final_answer"?{...o,progress:u.length?u:void 0,codexCandidate:void 0,blocks:[...o.blocks,{kind:"text",text:e.text}]}:{...o,progress:u.length?u:void 0,codexCandidate:e.text}});const s=`codex:${n?.id??"host"}:${e.id}`;return t.messages.flatMap(o=>o.blocks).filter(o=>o.kind==="tool"&&o.id===s&&o.state==="running").length>0?{...t,messages:t.messages.map(o=>({...o,blocks:o.blocks.map(a=>a.kind==="tool"&&a.id===s&&a.state==="running"?{...a,state:e.state,args:e.args,argsJson:JSON.stringify(e.args),...e.result!==void 0?{result:e.result}:{},...e.details!==void 0?{details:e.details}:{}}:a)}))}:t0(t,i,n,o=>({...o,blocks:[...o.blocks,{kind:"tool",id:s,name:e.name,args:e.args,argsJson:JSON.stringify(e.args),state:e.state,...e.result!==void 0?{result:e.result}:{},...e.details!==void 0?{details:e.details}:{}}]}))}function lI(t,e,i,n,s,r){if(e.kind==="session")return n||s?t:{...t,sessionId:e.id,cwd:e.cwd||t.cwd};if(e.kind==="turn")return dN(t,i,n,s,r);if(e.kind==="delta")return t0(t,n,s,a=>({...a,blocks:sx(a.blocks,e.block,e.text)}));if(e.kind==="tool"){const a=`pi:${s?.id??"host"}:${e.id}`;return t.messages.some(h=>h.blocks.some(p=>p.kind==="tool"&&p.id===a&&p.state==="running"))?{...t,messages:t.messages.map(h=>({...h,blocks:h.blocks.map(p=>p.kind==="tool"&&p.id===a&&p.state==="running"?{...p,name:e.name||p.name,args:e.args??p.args,argsJson:JSON.stringify(e.args??p.args??{}),state:e.state,...e.result!==void 0?{result:e.result}:{},...e.details!==void 0?{details:e.details}:{}}:p)}))}:t0(t,n,s,h=>({...h,blocks:[...h.blocks,{kind:"tool",id:a,name:e.name,args:e.args,argsJson:JSON.stringify(e.args??{}),state:e.state,...e.result!==void 0?{result:e.result}:{},...e.details!==void 0?{details:e.details}:{}}]}))}if(e.kind==="message"){const a=e.content.map(_=>aI(_,s)),u=t.messages.map(_=>_.streaming&&_.parent===n&&_.speaker?.id===s?.id).lastIndexOf(!0);let h=t.messages;if(u>=0){const _=[...h],x=_[u],S=a.filter(C=>!x.blocks.some(k=>uN(k,C)));_[u]={...x,blocks:S.length?[...x.blocks,...S]:x.blocks,streaming:!1},h=_}else a.length&&(h=[...h,{id:`m${h.length}`,role:"assistant",blocks:a,streaming:!1,parent:n,speaker:s}]);const p=!n&&!s?cI(e.usage):void 0,m={...t,messages:h,...p?{contextTokens:p}:{},...!n&&!s&&e.model?{model:e.model}:{},...e.error?{...ka,busy:!1,stopping:!1,failure:nx("pi",e.error)}:{}};if(!e.aborted)return m;const v=h[u>=0?u:h.length-1];return{...m,...ka,busy:!1,stopping:!1,stoppedAt:v?.id}}return{...t,...!s&&!n?{...ka,busy:!1,stopping:!1}:{},messages:t.messages.map(a=>a.streaming&&a.parent===n&&a.speaker?.id===s?.id?{...a,streaming:!1,blocks:a.blocks.map(Jg)}:a)}}function aI(t,e){return t.kind==="text"||t.kind==="thinking"?t:{kind:"tool",id:`pi:${e?.id??"host"}:${t.id}`,name:t.name,args:t.args,argsJson:JSON.stringify(t.args??{}),state:"running"}}function cI(t){const e=n=>typeof n=="number"&&n>=0?n:0,i=e(t.input)+e(t.cacheRead)+e(t.cacheWrite)+e(t.output);return i>0?i:void 0}function e0(t){return t.role==="user"&&!t.echo&&!t.takenUp&&!t.queueLost&&t.delivery!=="unknown"&&!t.to}function t0(t,e,i,n){const s=t.messages.map(p=>p.streaming&&p.parent===e&&p.speaker?.id===i?.id).lastIndexOf(!0),r=!e&&!i&&s>=0&&t.messages.slice(s+1).every(e0);if(s>=0&&(s===t.messages.length-1||r)){const p=[...t.messages];return p[s]=n(p[s]),{...t,messages:p}}const o=t.messages.map((p,m)=>m===s?Aw(p):p),a=n({id:`m${t.messages.length}`,role:"assistant",blocks:[],streaming:!0,parent:e,speaker:i}),u=!e&&!i?o.findIndex(e0):-1;if(u<0)return{...t,messages:[...o,a]};const h=[...o];return h.splice(u,0,a),{...t,messages:h}}function Aw(t){const e=t.codexCandidate?.trim();return{...t,streaming:!1,codexCandidate:void 0,blocks:[...t.blocks.map(Jg),...e?[{kind:"text",text:e}]:[]]}}function dN(t,e,i,n,s){if(i||n)return t;const r=Ce(e.octiq_user_turn_id),o=r?t.messages.findIndex(h=>h.role==="user"&&!h.echo&&!h.takenUp&&!h.to&&h.turnId===r):t.messages.findIndex(h=>h.role==="user"&&!h.echo&&!h.takenUp&&!h.queueLost&&!h.to),a=t.messages.map(h=>r&&h.turnId!==r&&h.role==="user"&&!h.to&&!h.echo&&!h.takenUp&&h.delivery==="dispatched"?{...h,delivery:"unknown",queueLost:void 0}:h.streaming&&!h.parent&&!h.speaker?Aw(h):h);let u=a;if(o>=0){const h={...a[o],takenUp:!0,delivery:"dispatched",queueLost:void 0,queueAction:void 0,queueError:void 0},p=a.filter((_,x)=>x!==o),m=p.filter(_=>!e0(_)),v=p.filter(e0);u=[...m,h,...v]}return{...t,busy:!0,exited:void 0,turnStartedAt:t.turnStartedAt??s,messages:u}}const uI=/^this session is being continued from a previous conversation/i;function rx(t){return uI.test(t.trim())}function hI(t,e){const i=e.trim();if(!i)return null;let n=-1;for(let r=t.messages.length-1;r>=0;r--)if(t.messages[r].blocks.some(o=>o.kind==="compacted")){n=r;break}return n===-1?rx(i)?{...t,awaitingSummary:!1,messages:[...t.messages,{id:`compact-${t.messages.length}`,role:"assistant",blocks:[{kind:"compacted",text:i}],streaming:!1}]}:null:t.messages[n].blocks.some(r=>r.kind==="compacted"&&r.text)?rx(i)?{...t,awaitingSummary:!1}:null:{...t,awaitingSummary:!1,messages:t.messages.map((r,o)=>o===n?{...r,blocks:r.blocks.map(a=>a.kind==="compacted"?{...a,text:i}:a)}:r)}}function dI(t,e){const i=e.status&&!Cw.has(e.status)?Ew(t,e.taskId):t,n=e.toolUseId?Mw(i,e.toolUseId):void 0;if(!n)return i;const s=n.finish;return s&&s.taskId===e.taskId&&s.summary===e.summary?i:{...i,messages:i.messages.map(r=>({...r,blocks:r.blocks.map(o=>o.kind==="tool"&&o.id===n.id?{...o,finish:e}:o)}))}}function fI(t,e,i,n){const s=i&&Mw(t,i)||tI(t);if(s?.brief===e)return t;if(s&&s.brief===void 0)return{...t,messages:t.messages.map(u=>({...u,blocks:u.blocks.map(h=>h.kind==="tool"&&h.id===s.id?{...h,brief:e}:h)}))};const r=n?`skill-${n}`:`skill-${t.messages.length}`;if(t.messages.some(u=>u.id===r))return t;const o=JT(e),a=o?o.scope?`${o.scope}:${o.name}`:o.name:"";return{...t,messages:[...t.messages,{id:r,role:"assistant",blocks:[{kind:"tool",id:r,name:"Skill",argsJson:"",args:{skill:a},state:"done",brief:e}],streaming:!1}]}}function pI(t,e,i,n,s){switch(Ce(e.type)){case"message_start":{const r=Ce(Ct(e.message).id)||`m${t.messages.length}`;if(t.messages.some(a=>a.id===r))return t;const o=!n;return{...t,busy:o?!0:t.busy,exited:o&&!i?void 0:t.exited,turnStartedAt:o?t.turnStartedAt??s:t.turnStartedAt,messages:[...t.messages,{id:r,role:"assistant",blocks:[],streaming:!0,parent:i,speaker:n,partial:!0}]}}case"content_block_start":{const r=Ct(e.content_block),o=Ce(r.type);return jd(t,i,n,a=>o==="tool_use"?{...a,blocks:[...a.blocks,{kind:"tool",id:Ce(r.id),name:Ce(r.name),argsJson:"",args:void 0,state:"running"}]}:a)}case"content_block_delta":{const r=Ct(e.delta),o=Ce(r.type);if(o==="text_delta"){const a=Ce(r.text);return t={...t,turnDraft:(t.turnDraft??0)+w5(a)},jd(t,i,n,u=>({...u,blocks:sx(u.blocks,"text",a)}))}return o==="thinking_delta"?jd(t,i,n,a=>({...a,blocks:sx(a.blocks,"thinking",Ce(r.thinking))})):o==="input_json_delta"?(t={...t,turnDraft:(t.turnDraft??0)+w5(Ce(r.partial_json))},jd(t,i,n,a=>{const u=a.blocks.map(m=>m.kind).lastIndexOf("tool");if(u<0)return a;const h=[...a.blocks],p=h[u];return h[u]={...p,argsJson:p.argsJson+Ce(r.partial_json)},{...a,blocks:h}})):t}case"content_block_stop":return jd(t,i,n,r=>({...r,blocks:r.blocks.map(o=>{if(o.kind!=="tool"||o.args!==void 0||!o.argsJson)return o;try{return{...o,args:JSON.parse(o.argsJson)}}catch{return o}})}));case"message_delta":{const r=Ct(e.usage).output_tokens;return typeof r!="number"?t:{...t,turnTokens:(t.turnTokens??0)+r,turnDraft:0}}case"message_stop":return{...t,messages:t.messages.map(r=>r.streaming&&r.parent===i&&r.speaker?.id===n?.id?{...r,streaming:!1}:r)};default:return t}}function k5(t,e,i=[],n=Date.now(),s){const r=e.trim(),o=(O8.exec(r)??I8.exec(r))?.[1];return s&&t.messages.some(a=>a.turnId===s)?t:{...t,...o?{model:o,modelAsked:!0}:{},busy:!0,stopping:!1,stoppedAt:void 0,turnStartedAt:t.busy?t.turnStartedAt:n,turnTokens:t.busy?t.turnTokens:0,turnDraft:t.busy?t.turnDraft:0,failure:void 0,exited:void 0,messages:[...t.messages,{id:s?`u:${s}`:`u${t.messages.length}`,role:"user",blocks:[{kind:"text",text:e}],streaming:!1,...i.length?{attachments:i}:{},...s?{turnId:s,delivery:"sending"}:{},...Vu(e)?{relay:Vu(e)}:{}}]}}async function wc(t,e,i,n){let s=performance.now()+8;for(const r of e){if(n())throw new Error("Chat read cancelled");r.seq<=i||(t=qf(t,r.event),performance.now()>=s&&(await new Promise(o=>setTimeout(o,0)),s=performance.now()+8))}return t}class mI{windows=new Map;get(e){return this.windows.get(e)}hasEarlier(e){return this.windows.has(e)}forget(e){this.windows.delete(e)}set(e,i,n){n===null?this.windows.delete(e):this.windows.set(e,{events:i,before:n})}append(e,i){const n=this.windows.get(e);if(!n)return;const s=n.events.at(-1)?.seq??0;n.events.push(...i.filter(r=>r.seq>s))}}function C5(t,e){const i=e.messages.filter(n=>n.role==="user"&&!n.echo&&!n.takenUp&&!t.messages.some(s=>s.id===n.id||!!n.turnId&&s.turnId===n.turnId));return i.length?{...t,busy:t.busy||e.busy,messages:[...t.messages,...i]}:t}async function gI(t){const{id:e,key:i,catchUp:n,getState:s,publish:r,request:o,cancelled:a}=t;let{storedSeq:u}=t;if(!n.holds(i)){const M=await AO(e);if(a())return;M&&M.seq>=(u??0)&&(r(M.state),u=M.seq)}if(a())return;const h=n.begin(i,u),p=s();let m;if(h===0&&t.requestPage)try{m=await t.requestPage(null)}catch(M){if(!String(M).includes("not available on this backend"))throw M}const v=m?.events??await o(h);if(a())return;const _=h===0&&v?.length?{...Tc(),sessionId:p.sessionId}:p,x=m?.context??[];let S=await wc(_,x,0,a);if(S=await wc(S,v??[],h,a),a())return;const C=v?.length?v[v.length-1].seq:h,k=n.end(i,v??[]);for(const M of k)M.seq>C&&(S=qf(S,M.event));m?t.history?.set(e,k,m.before):t.history?.append(e,k),r(S),t.history?.hasEarlier(e)||bw({id:e,state:S,seq:n.mark(i),updatedAt:Date.now()})}async function vI(t){const{id:e,key:i,catchUp:n,getState:s,publish:r,request:o,cancelled:a,history:u,requestPage:h}=t,p=u?.get(e);if(!p||!h)return;const m=n.begin(i),[v,_]=await Promise.all([h(p.before),o(m)]);if(a())return;if(v.before!==null&&v.before>=p.before)throw new Error("History cursor did not advance");const x=[...v.events.filter(M=>M.seq<p.before),...p.events];let S=await wc({...Tc(),sessionId:s().sessionId},v.context,0,a);if(S=await wc(S,x,0,a),S=C5(S,s()),S=await wc(S,_,m,a),x.push(..._),a())return;S=C5(S,s());const C=x.at(-1)?.seq??m,k=n.end(i,_).filter(M=>M.seq>C);for(const M of k)S=qf(S,M.event);x.push(...k),u.set(e,x,v.before),S={...S,exited:s().exited},r(S),u.hasEarlier(e)||bw({id:e,state:S,seq:n.mark(i),updatedAt:Date.now()})}const fN="octiq.v2.conversations",_I=80,E5=3*1024*1024;function yI(){try{const t=JSON.parse(localStorage.getItem(fN)||"[]");return Array.isArray(t)?t.filter(e=>e&&typeof e.id=="string"&&Array.isArray(e.messages)).map(e=>typeof e.createdAt=="number"?e:{...e,createdAt:e.updatedAt??0}):[]}catch{return[]}}function Qs(t){const e=[...t].sort((s,r)=>r.updatedAt-s.updatedAt).slice(0,_I),i=[];let n=2;for(const s of e){let r=JSON.stringify(s),o=r.length+(i.length?1:0);n+o>E5&&(r=JSON.stringify({...s,messages:[],seq:void 0}),o=r.length+(i.length?1:0),n+o>E5)||(i.push(r),n+=o)}for(let s=i.length;s>=0;s--)try{localStorage.setItem(fN,`[${i.slice(0,s).join(",")}]`);return}catch{}}const pN="New chat";function ox(t){const e=t.replace(/\s+/g," ").trim();return e?e.length>48?`${e.slice(0,48)}…`:e:pN}function xI(t){const e=t.find(i=>i.role==="user");return ox(e?.blocks.map(i=>"text"in i?i.text:"").join(" ")??"")}function bI(t,e,i=!1){const n=(t??"").trim();return i&&n||n&&n!==pN?n:xI(e)}function wI(t){return[...t].sort((e,i)=>+!!i.pinned-+!!e.pinned||i.updatedAt-e.updatedAt)}function M5(t,e){return{...t??{},...e}}function SI(t,e){if(t.length!==e.length)return!1;const i=new Map(t.map(n=>[n.id,n]));return e.every(n=>{const s=i.get(n.id);return!!s&&s.projectId===n.projectId&&s.title===n.title&&s.latestResponse===n.latestResponse&&!!s.customTitle==!!n.customTitle&&s.sessionId===n.sessionId&&s.cwd===n.cwd&&s.modelId===n.modelId&&s.permission===n.permission&&s.createdAt===n.createdAt&&s.updatedAt===n.updatedAt&&s.seq===n.seq&&!!s.pinned==!!n.pinned&&(s.generation??0)===(n.generation??0)&&!!s.synced==!!n.synced})}function kI(t){return{id:t.id,projectId:t.projectId,title:t.title,latestResponse:t.latestResponse,customTitle:t.customTitle,sessionId:t.sessionId??null,cwd:t.cwd??null,modelId:t.modelId??null,access:t.permission??null,createdAt:t.createdAt,updatedAt:t.updatedAt,readAt:t.readAt,pinned:t.pinned??!1,generation:t.generation}}function CI(t,e,i){if(e.length===0)return[];const n=new Set(e.map(s=>s.id));return t.filter(s=>!s.synced&&!n.has(s.id)&&!i.has(s.id)).map(kI)}const mN=8e3,gN=1e3,vN=3e4,To=new Map;let k1=null,Ku=0,A5=!1;function Rd(t){_N([t])}function _N(t){let e=!1;for(const i of t)To.get(i.id)?.kind!=="remove"&&(To.set(i.id,{kind:"save",entry:i}),e=!0);e&&(Tw(),U0())}function L5(t,e,i=0,n){const s=To.get(t);s?.kind==="remove"&&s.key===e&&s.generation===i&&(s.entry!==void 0||n===void 0)||(To.set(t,{kind:"remove",id:t,key:e,generation:i,entry:n}),Tw(),U0())}function T5(t){To.get(t)?.kind==="remove"&&To.delete(t)}const hh=new Map;let C1=null,Yu=0;function EI(t,e){const i=hh.get(t);i!==void 0&&i>=e||(hh.set(t,e),Tw(),Lw())}function Lw(){for(const[t,e]of hh)MI(t,e)}function MI(t,e){let i=!1;const n=new Promise((s,r)=>{setTimeout(()=>{i||r(new Error("chat_mark_read was not acknowledged"))},mN)});Promise.race([he.invoke("chat_mark_read",{id:t,at:e}),n]).then(()=>{i=!0,hh.get(t)===e&&hh.delete(t),Yu=0}).catch(()=>{i=!0,AI()})}function AI(){C1||hh.size===0||(Yu=Yu===0?gN:Math.min(Yu*2,vN),C1=setTimeout(()=>{C1=null,Lw()},Yu))}function Tw(){A5||(A5=!0,he.onState(t=>{t==="open"&&(Ku=0,U0(),Yu=0,Lw())}))}function LI(){k1||To.size===0||(Ku=Ku===0?gN:Math.min(Ku*2,vN),k1=setTimeout(()=>{k1=null,U0()},Ku))}function U0(){for(const t of[...To.values()])TI(t)}function TI(t){const e=t.kind==="save"?t.entry.id:t.id,[i,n]=t.kind==="save"?["chat_index_save",{meta:t.entry}]:["chat_index_remove",{id:t.id,key:t.key,expectedGeneration:t.generation,meta:t.entry??null}];let s=!1;const r=new Promise((o,a)=>{setTimeout(()=>{s||a(new Error(`${i} was not acknowledged`))},mN)});Promise.race([he.invoke(i,n),r]).then(()=>{s=!0,To.get(e)===t&&To.delete(e),Ku=0}).catch(()=>{s=!0,LI()})}function lx(t,e){if(t.id===e)return!1;const i=t.readAt??t.createdAt;return t.updatedAt>i}function ri(t,e){try{return localStorage.setItem(t,e),!0}catch{return!1}}function jr(t){try{return localStorage.getItem(t)}catch{return null}}const yN="octiq.v2.chatPlaces",NI=80;let rc=null;function jI(t){if(!t||typeof t!="object")return;const e=t;if(typeof e.top!="number"||!Number.isFinite(e.top))return;const i={top:Math.max(0,e.top)};return typeof e.turn=="string"&&typeof e.delta=="number"&&Number.isFinite(e.delta)&&(i.turn=e.turn,i.delta=e.delta),i}function V0(){if(rc)return rc;rc=new Map;const t=jr(yN);if(!t)return rc;try{const e=JSON.parse(t);if(!Array.isArray(e))return rc;for(const i of e){if(!Array.isArray(i)||typeof i[0]!="string")continue;const n=jI(i[1]);n&&rc.set(i[0],n)}}catch{}return rc}function xN(){ri(yN,JSON.stringify([...V0()]))}function RI(t,e){const i=V0();if(i.delete(t),i.set(t,e),i.size>NI){const n=i.keys().next();n.done||i.delete(n.value)}xN()}function N5(t){return V0().get(t)}function bN(t){V0().delete(t)&&xN()}function j5(t,e){const i=Math.max(0,t);let n;for(const s of e)s.offset>i||(!n||s.offset>n.offset)&&(n=s);return n?{top:i,turn:n.id,delta:i-n.offset}:{top:i}}function E1(t,e,i){let n=t.top;if(t.turn!==void 0&&t.delta!==void 0){const s=e.find(r=>r.id===t.turn);s&&(n=s.offset+t.delta)}return Math.max(0,Math.min(n,Math.max(0,i)))}const wN="octiq.v2.dismissedFailures",DI=80;function SN(t){let e=2166136261;const i=`${t.title}\0${t.detail??""}`;for(let n=0;n<i.length;n++)e^=i.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(36)}let oc=null;function K0(){if(oc)return oc;oc=new Map;const t=jr(wN);if(!t)return oc;try{const e=JSON.parse(t);if(!Array.isArray(e))return oc;for(const i of e)Array.isArray(i)&&typeof i[0]=="string"&&typeof i[1]=="string"&&oc.set(i[0],i[1])}catch{}return oc}function kN(){ri(wN,JSON.stringify([...K0()]))}function BI(t,e){const i=K0();if(i.delete(t),i.set(t,SN(e)),i.size>DI){const n=i.keys().next();n.done||i.delete(n.value)}kN()}function OI(t,e){return K0().get(t)===SN(e)}function II(t){K0().delete(t)&&kN()}const CN="octiq.v2.deletedChats",PI=720*60*60*1e3,R5=200;let Iu=null;function Nw(){if(Iu)return Iu;try{const t=JSON.parse(localStorage.getItem(CN)||"[]");Iu=Array.isArray(t)?t.filter(e=>e&&typeof e.id=="string"&&typeof e.key=="string"&&typeof e.at=="number"&&(e.generation===void 0||typeof e.generation=="number")):[]}catch{Iu=[]}return Iu}function jw(t){Iu=t;try{localStorage.setItem(CN,JSON.stringify(t))}catch{}}function ax(t,e){const i=t.filter(n=>e-n.at<PI);return i.length<=R5?i:[...i].sort((n,s)=>n.at-s.at).slice(i.length-R5)}function zI(t,e,i=Date.now(),n=0,s){const r=ax(Nw(),i).filter(o=>o.id!==t);r.push({id:t,key:e,at:i,...n?{generation:n}:{},...s?{meta:s}:{}}),jw(ax(r,i))}function Rw(t=Date.now()){const e=Nw(),i=ax(e,t);return i.length!==e.length&&jw(i),i}function D5(t,e=Date.now()){return Rw(e).some(i=>i.id===t)}function $I(t=Date.now()){return new Set(Rw(t).map(e=>e.id))}function B5(t){const e=Nw();e.some(i=>i.id===t)&&jw(e.filter(i=>i.id!==t))}const EN="octiq.v2.notify",O5=120;function FI(t,e){return!t.hidden&&t.focused&&t.reading===e}function HI(t,e,i){return!t.enabled||t.permission!=="granted"?!1:!FI(e,i)}function MN(t){const e=t.replace(/\s+/g," ").trim();return e.length>O5?`${e.slice(0,O5)}…`:e}function WI(t,e){return[t.trim(),e.trim()].filter(Boolean).join(" · ")||"OctiqFlow"}function qI(t){const e=MN(t.detail),i=t.kind==="permission"?`Needs permission: ${e||"a tool call"}`:t.kind==="question"?`Asked: ${e||"a question"}`:e||"Finished.";return{kind:t.kind,conversationId:t.conversationId,title:WI(t.projectName,t.chatTitle),body:i,tag:`octiq:${t.conversationId}:${t.kind}`}}function UI(t){for(let e=t.length-1;e>=0;e--){const i=t[e];if(i.role!=="assistant")continue;const n=i.blocks.map(s=>s.kind==="text"?s.text:"").filter(Boolean).join(" ");if(n.trim())return MN(n)}return""}function VI(t){return typeof document>"u"?{hidden:!0,focused:!1,reading:t}:{hidden:document.hidden,focused:document.hasFocus(),reading:t}}function Y0(){return typeof window<"u"&&"Notification"in window}function cx(){return Y0()?Notification.permission:"denied"}function KI(){try{return localStorage.getItem(EN)==="1"}catch{return!1}}function M1(t){try{localStorage.setItem(EN,t?"1":"0")}catch{}}async function YI(){if(!Y0())return"denied";if(Notification.permission!=="default")return Notification.permission;try{return await Notification.requestPermission()}catch{return"denied"}}function GI(t,e){if(!(!Y0()||Notification.permission!=="granted"))try{const i=new Notification(t.title,{body:t.body,tag:t.tag,icon:"./icon-192.png",requireInteraction:t.kind!=="done"});i.onclick=()=>{window.focus(),i.close(),e(t.conversationId)}}catch{}}function QI(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),i=e.padEnd(Math.ceil(e.length/4)*4,"="),n=atob(i),s=new ArrayBuffer(n.length),r=new Uint8Array(s);for(let o=0;o<n.length;o++)r[o]=n.charCodeAt(o);return s}function I5(t){if(!t)return"";const e=new Uint8Array(t);let i="";for(const n of e)i+=String.fromCharCode(n);return btoa(i).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}const XI=["standalone","minimal-ui","fullscreen"];function AN(){if(typeof window>"u")return!1;try{return XI.some(t=>window.matchMedia?.(`(display-mode: ${t})`).matches===!0)||navigator.standalone===!0}catch{return!1}}function kh(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window}function LN(){return typeof navigator>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.userAgent.includes("Mac")&&navigator.maxTouchPoints>1}function ZI(t){const e=t.toJSON();return{endpoint:t.endpoint,p256dh:e.keys?.p256dh??I5(t.getKey("p256dh")),auth:e.keys?.auth??I5(t.getKey("auth"))}}async function JI(){if(!kh())return null;try{return await navigator.serviceWorker.register("./sw.js")}catch{return null}}async function e7(){if(!kh())return LN()&&!AN()?"needs-install":"unsupported";if((Notification.permission==="default"?await Notification.requestPermission():Notification.permission)!=="granted")return"denied";const e=await JI();if(!e)return"failed";try{const{key:i}=await he.invoke("push_key");if(!i)return"failed";const s=await e.pushManager.getSubscription()??await e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:QI(i)});return await he.invoke("push_subscribe",{...ZI(s)}),"on"}catch{return"failed"}}async function t7(){if(kh())try{const e=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();if(!e)return;await he.invoke("push_unsubscribe",{endpoint:e.endpoint}),await e.unsubscribe()}catch{}}async function i7(){if(!kh()||Notification.permission!=="granted")return!1;try{return!!await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription()}catch{return!1}}const n7="octiq-tap",s7=300*1e3;function r7(t,e=Date.now()){return Number.isFinite(t)&&e-t<s7}async function P5(t=Date.now()){if(typeof caches>"u")return null;try{const e=await caches.open(n7),[i]=await e.keys();if(!i)return null;let n=null;try{const s=await e.match(i);n=s?await s.json():null}finally{await e.delete(i)}return typeof n?.conversationId!="string"||!n.conversationId?null:r7(n.at??0,t)?n.conversationId:null}catch{return null}}function o7(t){kh()&&navigator.serviceWorker.controller?.postMessage({type:"reading",conversationId:t})}function l7(t,e){const i={};return(t[t.length-1]===""?[...t,""]:t).join((i.padRight?" ":"")+","+(i.padLeft===!1?"":" ")).trim()}const a7=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,c7=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,u7={};function z5(t,e){return(u7.jsx?c7:a7).test(t)}const h7=/[ \t\n\f\r]/g;function d7(t){return typeof t=="object"?t.type==="text"?$5(t.value):!1:$5(t)}function $5(t){return t.replace(h7,"")===""}class Uf{constructor(e,i,n){this.normal=i,this.property=e,n&&(this.space=n)}}Uf.prototype.normal={};Uf.prototype.property={};Uf.prototype.space=void 0;function TN(t,e){const i={},n={};for(const s of t)Object.assign(i,s.property),Object.assign(n,s.normal);return new Uf(i,n,e)}function ux(t){return t.toLowerCase()}class Rs{constructor(e,i){this.attribute=i,this.property=e}}Rs.prototype.attribute="";Rs.prototype.booleanish=!1;Rs.prototype.boolean=!1;Rs.prototype.commaOrSpaceSeparated=!1;Rs.prototype.commaSeparated=!1;Rs.prototype.defined=!1;Rs.prototype.mustUseProperty=!1;Rs.prototype.number=!1;Rs.prototype.overloadedBoolean=!1;Rs.prototype.property="";Rs.prototype.spaceSeparated=!1;Rs.prototype.space=void 0;let f7=0;const at=$c(),en=$c(),hx=$c(),Ae=$c(),oi=$c(),Sc=$c(),er=$c();function $c(){return 2**++f7}const dx=Object.freeze(Object.defineProperty({__proto__:null,boolean:at,booleanish:en,commaOrSpaceSeparated:er,commaSeparated:Sc,number:Ae,overloadedBoolean:hx,spaceSeparated:oi},Symbol.toStringTag,{value:"Module"})),A1=Object.keys(dx);class Dw extends Rs{constructor(e,i,n,s){let r=-1;if(super(e,i),F5(this,"space",s),typeof n=="number")for(;++r<A1.length;){const o=A1[r];F5(this,A1[r],(n&dx[o])===dx[o])}}}Dw.prototype.defined=!0;function F5(t,e,i){i&&(t[e]=i)}function Ch(t){const e={},i={};for(const[n,s]of Object.entries(t.properties)){const r=new Dw(n,t.transform(t.attributes||{},n),s,t.space);t.mustUseProperty&&t.mustUseProperty.includes(n)&&(r.mustUseProperty=!0),e[n]=r,i[ux(n)]=n,i[ux(r.attribute)]=n}return new Uf(e,i,t.space)}const NN=Ch({properties:{ariaActiveDescendant:null,ariaAtomic:en,ariaAutoComplete:null,ariaBusy:en,ariaChecked:en,ariaColCount:Ae,ariaColIndex:Ae,ariaColSpan:Ae,ariaControls:oi,ariaCurrent:null,ariaDescribedBy:oi,ariaDetails:null,ariaDisabled:en,ariaDropEffect:oi,ariaErrorMessage:null,ariaExpanded:en,ariaFlowTo:oi,ariaGrabbed:en,ariaHasPopup:null,ariaHidden:en,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:oi,ariaLevel:Ae,ariaLive:null,ariaModal:en,ariaMultiLine:en,ariaMultiSelectable:en,ariaOrientation:null,ariaOwns:oi,ariaPlaceholder:null,ariaPosInSet:Ae,ariaPressed:en,ariaReadOnly:en,ariaRelevant:null,ariaRequired:en,ariaRoleDescription:oi,ariaRowCount:Ae,ariaRowIndex:Ae,ariaRowSpan:Ae,ariaSelected:en,ariaSetSize:Ae,ariaSort:null,ariaValueMax:Ae,ariaValueMin:Ae,ariaValueNow:Ae,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function jN(t,e){return e in t?t[e]:e}function RN(t,e){return jN(t,e.toLowerCase())}const p7=Ch({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Sc,acceptCharset:oi,accessKey:oi,action:null,allow:null,allowFullScreen:at,allowPaymentRequest:at,allowUserMedia:at,alpha:at,alt:null,as:null,async:at,autoCapitalize:null,autoComplete:oi,autoFocus:at,autoPlay:at,blocking:oi,capture:null,charSet:null,checked:at,cite:null,className:oi,closedBy:null,colorSpace:null,cols:Ae,colSpan:Ae,command:null,commandFor:null,content:null,contentEditable:en,controls:at,controlsList:oi,coords:Ae|Sc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:at,defer:at,dir:null,dirName:null,disabled:at,download:hx,draggable:en,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:at,formTarget:null,headers:oi,height:Ae,hidden:hx,high:Ae,href:null,hrefLang:null,htmlFor:oi,httpEquiv:oi,id:null,imageSizes:null,imageSrcSet:null,inert:at,inputMode:null,integrity:null,is:null,isMap:at,itemId:null,itemProp:oi,itemRef:oi,itemScope:at,itemType:oi,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:at,low:Ae,manifest:null,max:null,maxLength:Ae,media:null,method:null,min:null,minLength:Ae,multiple:at,muted:at,name:null,nonce:null,noModule:at,noValidate:at,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:at,optimum:Ae,pattern:null,ping:oi,placeholder:null,playsInline:at,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:at,referrerPolicy:null,rel:oi,required:at,reversed:at,rows:Ae,rowSpan:Ae,sandbox:oi,scope:null,scoped:at,seamless:at,selected:at,shadowRootClonable:at,shadowRootCustomElementRegistry:at,shadowRootDelegatesFocus:at,shadowRootMode:null,shadowRootSerializable:at,shape:null,size:Ae,sizes:null,slot:null,span:Ae,spellCheck:en,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ae,step:null,style:null,tabIndex:Ae,target:null,title:null,translate:null,type:null,typeMustMatch:at,useMap:null,value:en,width:Ae,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:oi,axis:null,background:null,bgColor:null,border:Ae,borderColor:null,bottomMargin:Ae,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:at,declare:at,event:null,face:null,frame:null,frameBorder:null,hSpace:Ae,leftMargin:Ae,link:null,longDesc:null,lowSrc:null,marginHeight:Ae,marginWidth:Ae,noResize:at,noHref:at,noShade:at,noWrap:at,object:null,profile:null,prompt:null,rev:null,rightMargin:Ae,rules:null,scheme:null,scrolling:en,standby:null,summary:null,text:null,topMargin:Ae,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ae,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:at,disablePictureInPicture:at,disableRemotePlayback:at,exportParts:Sc,part:oi,prefix:null,property:null,results:Ae,security:null,unselectable:null},space:"html",transform:RN}),m7=Ch({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:er,accentHeight:Ae,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ae,amplitude:Ae,arabicForm:null,ascent:Ae,attributeName:null,attributeType:null,azimuth:Ae,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ae,by:null,calcMode:null,capHeight:Ae,className:oi,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ae,diffuseConstant:Ae,direction:null,display:null,dur:null,divisor:Ae,dominantBaseline:null,download:at,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ae,enableBackground:null,end:null,event:null,exponent:Ae,externalResourcesRequired:null,fill:null,fillOpacity:Ae,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Sc,g2:Sc,glyphName:Sc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ae,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ae,horizOriginX:Ae,horizOriginY:Ae,id:null,ideographic:Ae,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ae,k:Ae,k1:Ae,k2:Ae,k3:Ae,k4:Ae,kernelMatrix:er,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ae,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ae,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ae,overlineThickness:Ae,paintOrder:null,panose1:null,path:null,pathLength:Ae,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:oi,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ae,pointsAtY:Ae,pointsAtZ:Ae,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:er,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:er,rev:er,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:er,requiredFeatures:er,requiredFonts:er,requiredFormats:er,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ae,specularExponent:Ae,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ae,strikethroughThickness:Ae,string:null,stroke:null,strokeDashArray:er,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ae,strokeOpacity:Ae,strokeWidth:null,style:null,surfaceScale:Ae,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:er,tabIndex:Ae,tableValues:null,target:null,targetX:Ae,targetY:Ae,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:er,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ae,underlineThickness:Ae,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ae,values:null,vAlphabetic:Ae,vMathematical:Ae,vectorEffect:null,vHanging:Ae,vIdeographic:Ae,version:null,vertAdvY:Ae,vertOriginX:Ae,vertOriginY:Ae,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ae,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:jN}),DN=Ch({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),BN=Ch({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:RN}),ON=Ch({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),g7={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},v7=/[A-Z]/g,H5=/-[a-z]/g,_7=/^data[-\w.:]+$/i;function y7(t,e){const i=ux(e);let n=e,s=Rs;if(i in t.normal)return t.property[t.normal[i]];if(i.length>4&&i.slice(0,4)==="data"&&_7.test(e)){if(e.charAt(4)==="-"){const r=e.slice(5).replace(H5,b7);n="data"+r.charAt(0).toUpperCase()+r.slice(1)}else{const r=e.slice(4);if(!H5.test(r)){let o=r.replace(v7,x7);o.charAt(0)!=="-"&&(o="-"+o),e="data"+o}}s=Dw}return new s(n,e)}function x7(t){return"-"+t.toLowerCase()}function b7(t){return t.charAt(1).toUpperCase()}const w7=TN([NN,p7,DN,BN,ON],"html"),Bw=TN([NN,m7,DN,BN,ON],"svg");function S7(t){return t.join(" ").trim()}var Tu={},L1,W5;function k7(){if(W5)return L1;W5=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,e=/\n/g,i=/^\s*/,n=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,r=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,u=`
|
|
14
|
+
`,h="/",p="*",m="",v="comment",_="declaration";function x(C,k){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];k=k||{};var M=1,L=1;function N(H){var F=H.match(e);F&&(M+=F.length);var P=H.lastIndexOf(u);L=~P?H.length-P:L+H.length}function j(){var H={line:M,column:L};return function(F){return F.position=new R(H),G(),F}}function R(H){this.start=H,this.end={line:M,column:L},this.source=k.source}R.prototype.content=C;function z(H){var F=new Error(k.source+":"+M+":"+L+": "+H);if(F.reason=H,F.filename=k.source,F.line=M,F.column=L,F.source=C,!k.silent)throw F}function J(H){var F=H.exec(C);if(F){var P=F[0];return N(P),C=C.slice(P.length),F}}function G(){J(i)}function q(H){var F;for(H=H||[];F=X();)F!==!1&&H.push(F);return H}function X(){var H=j();if(!(h!=C.charAt(0)||p!=C.charAt(1))){for(var F=2;m!=C.charAt(F)&&(p!=C.charAt(F)||h!=C.charAt(F+1));)++F;if(F+=2,m===C.charAt(F-1))return z("End of comment missing");var P=C.slice(2,F-2);return L+=2,N(P),C=C.slice(F),L+=2,H({type:v,comment:P})}}function I(){var H=j(),F=J(n);if(F){if(X(),!J(s))return z("property missing ':'");var P=J(r),U=H({type:_,property:S(F[0].replace(t,m)),value:P?S(P[0].replace(t,m)):m});return J(o),U}}function T(){var H=[];q(H);for(var F;F=I();)F!==!1&&(H.push(F),q(H));return H}return G(),T()}function S(C){return C?C.replace(a,m):m}return L1=x,L1}var q5;function C7(){if(q5)return Tu;q5=1;var t=Tu&&Tu.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Tu,"__esModule",{value:!0}),Tu.default=i;const e=t(k7());function i(n,s){let r=null;if(!n||typeof n!="string")return r;const o=(0,e.default)(n),a=typeof s=="function";return o.forEach(u=>{if(u.type!=="declaration")return;const{property:h,value:p}=u;a?s(h,p,u):p&&(r=r||{},r[h]=p)}),r}return Tu}var Dd={},U5;function E7(){if(U5)return Dd;U5=1,Object.defineProperty(Dd,"__esModule",{value:!0}),Dd.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,e=/-([a-z])/g,i=/^[^-]+$/,n=/^-(webkit|moz|ms|o|khtml)-/,s=/^-(ms)-/,r=function(h){return!h||i.test(h)||t.test(h)},o=function(h,p){return p.toUpperCase()},a=function(h,p){return"".concat(p,"-")},u=function(h,p){return p===void 0&&(p={}),r(h)?h:(h=h.toLowerCase(),p.reactCompat?h=h.replace(s,a):h=h.replace(n,a),h.replace(e,o))};return Dd.camelCase=u,Dd}var Bd,V5;function M7(){if(V5)return Bd;V5=1;var t=Bd&&Bd.__importDefault||function(s){return s&&s.__esModule?s:{default:s}},e=t(C7()),i=E7();function n(s,r){var o={};return!s||typeof s!="string"||(0,e.default)(s,function(a,u){a&&u&&(o[(0,i.camelCase)(a,r)]=u)}),o}return n.default=n,Bd=n,Bd}var A7=M7();const L7=GT(A7),IN=PN("end"),Ow=PN("start");function PN(t){return e;function e(i){const n=i&&i.position&&i.position[t]||{};if(typeof n.line=="number"&&n.line>0&&typeof n.column=="number"&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset=="number"&&n.offset>-1?n.offset:void 0}}}function T7(t){const e=Ow(t),i=IN(t);if(e&&i)return{start:e,end:i}}function mf(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?K5(t.position):"start"in t||"end"in t?K5(t):"line"in t||"column"in t?fx(t):""}function fx(t){return Y5(t&&t.line)+":"+Y5(t&&t.column)}function K5(t){return fx(t&&t.start)+"-"+fx(t&&t.end)}function Y5(t){return t&&typeof t=="number"?t:1}class Zn extends Error{constructor(e,i,n){super(),typeof i=="string"&&(n=i,i=void 0);let s="",r={},o=!1;if(i&&("line"in i&&"column"in i?r={place:i}:"start"in i&&"end"in i?r={place:i}:"type"in i?r={ancestors:[i],place:i.position}:r={...i}),typeof e=="string"?s=e:!r.cause&&e&&(o=!0,s=e.message,r.cause=e),!r.ruleId&&!r.source&&typeof n=="string"){const u=n.indexOf(":");u===-1?r.ruleId=n:(r.source=n.slice(0,u),r.ruleId=n.slice(u+1))}if(!r.place&&r.ancestors&&r.ancestors){const u=r.ancestors[r.ancestors.length-1];u&&(r.place=u.position)}const a=r.place&&"start"in r.place?r.place.start:r.place;this.ancestors=r.ancestors||void 0,this.cause=r.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=a?a.line:void 0,this.name=mf(r.place)||"1:1",this.place=r.place||void 0,this.reason=this.message,this.ruleId=r.ruleId||void 0,this.source=r.source||void 0,this.stack=o&&r.cause&&typeof r.cause.stack=="string"?r.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Zn.prototype.file="";Zn.prototype.name="";Zn.prototype.reason="";Zn.prototype.message="";Zn.prototype.stack="";Zn.prototype.column=void 0;Zn.prototype.line=void 0;Zn.prototype.ancestors=void 0;Zn.prototype.cause=void 0;Zn.prototype.fatal=void 0;Zn.prototype.place=void 0;Zn.prototype.ruleId=void 0;Zn.prototype.source=void 0;const Iw={}.hasOwnProperty,N7=new Map,j7=/[A-Z]/g,R7=new Set(["table","tbody","thead","tfoot","tr"]),D7=new Set(["td","th"]),zN="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function B7(t,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const i=e.filePath||void 0;let n;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");n=W7(i,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");n=H7(i,e.jsx,e.jsxs)}const s={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:n,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:i,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?Bw:w7,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},r=$N(s,t,void 0);return r&&typeof r!="string"?r:s.create(t,s.Fragment,{children:r||void 0},void 0)}function $N(t,e,i){if(e.type==="element")return O7(t,e,i);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return I7(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return z7(t,e,i);if(e.type==="mdxjsEsm")return P7(t,e);if(e.type==="root")return $7(t,e,i);if(e.type==="text")return F7(t,e)}function O7(t,e,i){const n=t.schema;let s=n;e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(s=Bw,t.schema=s),t.ancestors.push(e);const r=HN(t,e.tagName,!1),o=q7(t,e);let a=zw(t,e);return R7.has(e.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!d7(u):!0})),FN(t,o,r,e),Pw(o,a),t.ancestors.pop(),t.schema=n,t.create(e,r,o,i)}function I7(t,e){if(e.data&&e.data.estree&&t.evaluater){const n=e.data.estree.body[0];return n.type,t.evaluater.evaluateExpression(n.expression)}Cf(t,e.position)}function P7(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);Cf(t,e.position)}function z7(t,e,i){const n=t.schema;let s=n;e.name==="svg"&&n.space==="html"&&(s=Bw,t.schema=s),t.ancestors.push(e);const r=e.name===null?t.Fragment:HN(t,e.name,!0),o=U7(t,e),a=zw(t,e);return FN(t,o,r,e),Pw(o,a),t.ancestors.pop(),t.schema=n,t.create(e,r,o,i)}function $7(t,e,i){const n={};return Pw(n,zw(t,e)),t.create(e,t.Fragment,n,i)}function F7(t,e){return e.value}function FN(t,e,i,n){typeof i!="string"&&i!==t.Fragment&&t.passNode&&(e.node=n)}function Pw(t,e){if(e.length>0){const i=e.length>1?e:e[0];i&&(t.children=i)}}function H7(t,e,i){return n;function n(s,r,o,a){const h=Array.isArray(o.children)?i:e;return a?h(r,o,a):h(r,o)}}function W7(t,e){return i;function i(n,s,r,o){const a=Array.isArray(r.children),u=Ow(n);return e(s,r,o,a,{columnNumber:u?u.column-1:void 0,fileName:t,lineNumber:u?u.line:void 0},void 0)}}function q7(t,e){const i={};let n,s;for(s in e.properties)if(s!=="children"&&Iw.call(e.properties,s)){const r=V7(t,s,e.properties[s]);if(r){const[o,a]=r;t.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&D7.has(e.tagName)?n=a:i[o]=a}}if(n){const r=i.style||(i.style={});r[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=n}return i}function U7(t,e){const i={};for(const n of e.attributes)if(n.type==="mdxJsxExpressionAttribute")if(n.data&&n.data.estree&&t.evaluater){const r=n.data.estree.body[0];r.type;const o=r.expression;o.type;const a=o.properties[0];a.type,Object.assign(i,t.evaluater.evaluateExpression(a.argument))}else Cf(t,e.position);else{const s=n.name;let r;if(n.value&&typeof n.value=="object")if(n.value.data&&n.value.data.estree&&t.evaluater){const a=n.value.data.estree.body[0];a.type,r=t.evaluater.evaluateExpression(a.expression)}else Cf(t,e.position);else r=n.value===null?!0:n.value;i[s]=r}return i}function zw(t,e){const i=[];let n=-1;const s=t.passKeys?new Map:N7;for(;++n<e.children.length;){const r=e.children[n];let o;if(t.passKeys){const u=r.type==="element"?r.tagName:r.type==="mdxJsxFlowElement"||r.type==="mdxJsxTextElement"?r.name:void 0;if(u){const h=s.get(u)||0;o=u+"-"+h,s.set(u,h+1)}}const a=$N(t,r,o);a!==void 0&&i.push(a)}return i}function V7(t,e,i){const n=y7(t.schema,e);if(!(i==null||typeof i=="number"&&Number.isNaN(i))){if(Array.isArray(i)&&(i=n.commaSeparated?l7(i):S7(i)),n.property==="style"){let s=typeof i=="object"?i:K7(t,String(i));return t.stylePropertyNameCase==="css"&&(s=Y7(s)),["style",s]}return[t.elementAttributeNameCase==="react"&&n.space?g7[n.property]||n.property:n.attribute,i]}}function K7(t,e){try{return L7(e,{reactCompat:!0})}catch(i){if(t.ignoreInvalidStyle)return{};const n=i,s=new Zn("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=t.filePath||void 0,s.url=zN+"#cannot-parse-style-attribute",s}}function HN(t,e,i){let n;if(!i)n={type:"Literal",value:e};else if(e.includes(".")){const s=e.split(".");let r=-1,o;for(;++r<s.length;){const a=z5(s[r])?{type:"Identifier",name:s[r]}:{type:"Literal",value:s[r]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(r&&a.type==="Literal"),optional:!1}:a}n=o}else n=z5(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(n.type==="Literal"){const s=n.value;return Iw.call(t.components,s)?t.components[s]:s}if(t.evaluater)return t.evaluater.evaluateExpression(n);Cf(t)}function Cf(t,e){const i=new Zn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw i.file=t.filePath||void 0,i.url=zN+"#cannot-handle-mdx-estrees-without-createevaluater",i}function Y7(t){const e={};let i;for(i in t)Iw.call(t,i)&&(e[G7(i)]=t[i]);return e}function G7(t){let e=t.replace(j7,Q7);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function Q7(t){return"-"+t.toLowerCase()}const T1={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},X7={};function $w(t,e){const i=X7,n=typeof i.includeImageAlt=="boolean"?i.includeImageAlt:!0,s=typeof i.includeHtml=="boolean"?i.includeHtml:!0;return WN(t,n,s)}function WN(t,e,i){if(Z7(t)){if("value"in t)return t.type==="html"&&!i?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return G5(t.children,e,i)}return Array.isArray(t)?G5(t,e,i):""}function G5(t,e,i){const n=[];let s=-1;for(;++s<t.length;)n[s]=WN(t[s],e,i);return n.join("")}function Z7(t){return!!(t&&typeof t=="object")}const Q5=document.createElement("i");function Fw(t){const e="&"+t+";";Q5.innerHTML=e;const i=Q5.textContent;return i.charCodeAt(i.length-1)===59&&t!=="semi"||i===e?!1:i}function or(t,e,i,n){const s=t.length;let r=0,o;if(e<0?e=-e>s?0:s+e:e=e>s?s:e,i=i>0?i:0,n.length<1e4)o=Array.from(n),o.unshift(e,i),t.splice(...o);else for(i&&t.splice(e,i);r<n.length;)o=n.slice(r,r+1e4),o.unshift(e,0),t.splice(...o),r+=1e4,e+=1e4}function Lr(t,e){return t.length>0?(or(t,t.length,0,e),t):e}const X5={}.hasOwnProperty;function qN(t){const e={};let i=-1;for(;++i<t.length;)J7(e,t[i]);return e}function J7(t,e){let i;for(i in e){const s=(X5.call(t,i)?t[i]:void 0)||(t[i]={}),r=e[i];let o;if(r)for(o in r){X5.call(s,o)||(s[o]=[]);const a=r[o];eP(s[o],Array.isArray(a)?a:a?[a]:[])}}}function eP(t,e){let i=-1;const n=[];for(;++i<e.length;)(e[i].add==="after"?t:n).push(e[i]);or(t,0,0,n)}function UN(t,e){const i=Number.parseInt(t,e);return i<9||i===11||i>13&&i<32||i>126&&i<160||i>55295&&i<57344||i>64975&&i<65008||(i&65535)===65535||(i&65535)===65534||i>1114111?"�":String.fromCodePoint(i)}function Qr(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const cs=Da(/[A-Za-z]/),Qn=Da(/[\dA-Za-z]/),tP=Da(/[#-'*+\--9=?A-Z^-~]/);function i0(t){return t!==null&&(t<32||t===127)}const px=Da(/\d/),iP=Da(/[\dA-Fa-f]/),nP=Da(/[!-/:-@[-`{-~]/);function tt(t){return t!==null&&t<-2}function hi(t){return t!==null&&(t<0||t===32)}function Et(t){return t===-2||t===-1||t===32}const G0=Da(new RegExp("\\p{P}|\\p{S}","u")),Nc=Da(/\s/);function Da(t){return e;function e(i){return i!==null&&i>-1&&t.test(String.fromCharCode(i))}}function Eh(t){const e=[];let i=-1,n=0,s=0;for(;++i<t.length;){const r=t.charCodeAt(i);let o="";if(r===37&&Qn(t.charCodeAt(i+1))&&Qn(t.charCodeAt(i+2)))s=2;else if(r<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(r))||(o=String.fromCharCode(r));else if(r>55295&&r<57344){const a=t.charCodeAt(i+1);r<56320&&a>56319&&a<57344?(o=String.fromCharCode(r,a),s=1):o="�"}else o=String.fromCharCode(r);o&&(e.push(t.slice(n,i),encodeURIComponent(o)),n=i+s+1,o=""),s&&(i+=s,s=0)}return e.join("")+t.slice(n)}function Dt(t,e,i,n){const s=n?n-1:Number.POSITIVE_INFINITY;let r=0;return o;function o(u){return Et(u)?(t.enter(i),a(u)):e(u)}function a(u){return Et(u)&&r++<s?(t.consume(u),a):(t.exit(i),e(u))}}const sP={tokenize:rP};function rP(t){const e=t.attempt(this.parser.constructs.contentInitial,n,s);let i;return e;function n(a){if(a===null){t.consume(a);return}return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),Dt(t,e,"linePrefix")}function s(a){return t.enter("paragraph"),r(a)}function r(a){const u=t.enter("chunkText",{contentType:"text",previous:i});return i&&(i.next=u),i=u,o(a)}function o(a){if(a===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(a);return}return tt(a)?(t.consume(a),t.exit("chunkText"),r):(t.consume(a),o)}}const oP={tokenize:lP},Z5={tokenize:aP};function lP(t){const e=this,i=[];let n=0,s,r,o;return a;function a(L){if(n<i.length){const N=i[n];return e.containerState=N[1],t.attempt(N[0].continuation,u,h)(L)}return h(L)}function u(L){if(n++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,s&&M();const N=e.events.length;let j=N,R;for(;j--;)if(e.events[j][0]==="exit"&&e.events[j][1].type==="chunkFlow"){R=e.events[j][1].end;break}k(n);let z=N;for(;z<e.events.length;)e.events[z][1].end={...R},z++;return or(e.events,j+1,0,e.events.slice(N)),e.events.length=z,h(L)}return a(L)}function h(L){if(n===i.length){if(!s)return v(L);if(s.currentConstruct&&s.currentConstruct.concrete)return x(L);e.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(Z5,p,m)(L)}function p(L){return s&&M(),k(n),v(L)}function m(L){return e.parser.lazy[e.now().line]=n!==i.length,o=e.now().offset,x(L)}function v(L){return e.containerState={},t.attempt(Z5,_,x)(L)}function _(L){return n++,i.push([e.currentConstruct,e.containerState]),v(L)}function x(L){if(L===null){s&&M(),k(0),t.consume(L);return}return s=s||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:r}),S(L)}function S(L){if(L===null){C(t.exit("chunkFlow"),!0),k(0),t.consume(L);return}return tt(L)?(t.consume(L),C(t.exit("chunkFlow")),n=0,e.interrupt=void 0,a):(t.consume(L),S)}function C(L,N){const j=e.sliceStream(L);if(N&&j.push(null),L.previous=r,r&&(r.next=L),r=L,s.defineSkip(L.start),s.write(j),e.parser.lazy[L.start.line]){let R=s.events.length;for(;R--;)if(s.events[R][1].start.offset<o&&(!s.events[R][1].end||s.events[R][1].end.offset>o))return;const z=e.events.length;let J=z,G,q;for(;J--;)if(e.events[J][0]==="exit"&&e.events[J][1].type==="chunkFlow"){if(G){q=e.events[J][1].end;break}G=!0}for(k(n),R=z;R<e.events.length;)e.events[R][1].end={...q},R++;or(e.events,J+1,0,e.events.slice(z)),e.events.length=R}}function k(L){let N=i.length;for(;N-- >L;){const j=i[N];e.containerState=j[1],j[0].exit.call(e,t)}i.length=L}function M(){s.write([null]),r=void 0,s=void 0,e.containerState._closeFlow=void 0}}function aP(t,e,i){return Dt(t,t.attempt(this.parser.constructs.document,e,i),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function dh(t){if(t===null||hi(t)||Nc(t))return 1;if(G0(t))return 2}function Q0(t,e,i){const n=[];let s=-1;for(;++s<t.length;){const r=t[s].resolveAll;r&&!n.includes(r)&&(e=r(e,i),n.push(r))}return e}const mx={name:"attention",resolveAll:cP,tokenize:uP};function cP(t,e){let i=-1,n,s,r,o,a,u,h,p;for(;++i<t.length;)if(t[i][0]==="enter"&&t[i][1].type==="attentionSequence"&&t[i][1]._close){for(n=i;n--;)if(t[n][0]==="exit"&&t[n][1].type==="attentionSequence"&&t[n][1]._open&&e.sliceSerialize(t[n][1]).charCodeAt(0)===e.sliceSerialize(t[i][1]).charCodeAt(0)){if((t[n][1]._close||t[i][1]._open)&&(t[i][1].end.offset-t[i][1].start.offset)%3&&!((t[n][1].end.offset-t[n][1].start.offset+t[i][1].end.offset-t[i][1].start.offset)%3))continue;u=t[n][1].end.offset-t[n][1].start.offset>1&&t[i][1].end.offset-t[i][1].start.offset>1?2:1;const m={...t[n][1].end},v={...t[i][1].start};J5(m,-u),J5(v,u),o={type:u>1?"strongSequence":"emphasisSequence",start:m,end:{...t[n][1].end}},a={type:u>1?"strongSequence":"emphasisSequence",start:{...t[i][1].start},end:v},r={type:u>1?"strongText":"emphasisText",start:{...t[n][1].end},end:{...t[i][1].start}},s={type:u>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},t[n][1].end={...o.start},t[i][1].start={...a.end},h=[],t[n][1].end.offset-t[n][1].start.offset&&(h=Lr(h,[["enter",t[n][1],e],["exit",t[n][1],e]])),h=Lr(h,[["enter",s,e],["enter",o,e],["exit",o,e],["enter",r,e]]),h=Lr(h,Q0(e.parser.constructs.insideSpan.null,t.slice(n+1,i),e)),h=Lr(h,[["exit",r,e],["enter",a,e],["exit",a,e],["exit",s,e]]),t[i][1].end.offset-t[i][1].start.offset?(p=2,h=Lr(h,[["enter",t[i][1],e],["exit",t[i][1],e]])):p=0,or(t,n-1,i-n+3,h),i=n+h.length-p-2;break}}for(i=-1;++i<t.length;)t[i][1].type==="attentionSequence"&&(t[i][1].type="data");return t}function uP(t,e){const i=this.parser.constructs.attentionMarkers.null,n=this.previous,s=dh(n);let r;return o;function o(u){return r=u,t.enter("attentionSequence"),a(u)}function a(u){if(u===r)return t.consume(u),a;const h=t.exit("attentionSequence"),p=dh(u),m=!p||p===2&&s||i.includes(u),v=!s||s===2&&p||i.includes(n);return h._open=!!(r===42?m:m&&(s||!v)),h._close=!!(r===42?v:v&&(p||!m)),e(u)}}function J5(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const hP={name:"autolink",tokenize:dP};function dP(t,e,i){let n=0;return s;function s(_){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(_),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),r}function r(_){return cs(_)?(t.consume(_),o):_===64?i(_):h(_)}function o(_){return _===43||_===45||_===46||Qn(_)?(n=1,a(_)):h(_)}function a(_){return _===58?(t.consume(_),n=0,u):(_===43||_===45||_===46||Qn(_))&&n++<32?(t.consume(_),a):(n=0,h(_))}function u(_){return _===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(_),t.exit("autolinkMarker"),t.exit("autolink"),e):_===null||_===32||_===60||i0(_)?i(_):(t.consume(_),u)}function h(_){return _===64?(t.consume(_),p):tP(_)?(t.consume(_),h):i(_)}function p(_){return Qn(_)?m(_):i(_)}function m(_){return _===46?(t.consume(_),n=0,p):_===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(_),t.exit("autolinkMarker"),t.exit("autolink"),e):v(_)}function v(_){if((_===45||Qn(_))&&n++<63){const x=_===45?v:m;return t.consume(_),x}return i(_)}}const Vf={partial:!0,tokenize:fP};function fP(t,e,i){return n;function n(r){return Et(r)?Dt(t,s,"linePrefix")(r):s(r)}function s(r){return r===null||tt(r)?e(r):i(r)}}const VN={continuation:{tokenize:mP},exit:gP,name:"blockQuote",tokenize:pP};function pP(t,e,i){const n=this;return s;function s(o){if(o===62){const a=n.containerState;return a.open||(t.enter("blockQuote",{_container:!0}),a.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(o),t.exit("blockQuoteMarker"),r}return i(o)}function r(o){return Et(o)?(t.enter("blockQuotePrefixWhitespace"),t.consume(o),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(o))}}function mP(t,e,i){const n=this;return s;function s(o){return Et(o)?Dt(t,r,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):r(o)}function r(o){return t.attempt(VN,e,i)(o)}}function gP(t){t.exit("blockQuote")}const KN={name:"characterEscape",tokenize:vP};function vP(t,e,i){return n;function n(r){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(r),t.exit("escapeMarker"),s}function s(r){return nP(r)?(t.enter("characterEscapeValue"),t.consume(r),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):i(r)}}const YN={name:"characterReference",tokenize:_P};function _P(t,e,i){const n=this;let s=0,r,o;return a;function a(m){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(m),t.exit("characterReferenceMarker"),u}function u(m){return m===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(m),t.exit("characterReferenceMarkerNumeric"),h):(t.enter("characterReferenceValue"),r=31,o=Qn,p(m))}function h(m){return m===88||m===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(m),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),r=6,o=iP,p):(t.enter("characterReferenceValue"),r=7,o=px,p(m))}function p(m){if(m===59&&s){const v=t.exit("characterReferenceValue");return o===Qn&&!Fw(n.sliceSerialize(v))?i(m):(t.enter("characterReferenceMarker"),t.consume(m),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return o(m)&&s++<r?(t.consume(m),p):i(m)}}const eE={partial:!0,tokenize:xP},tE={concrete:!0,name:"codeFenced",tokenize:yP};function yP(t,e,i){const n=this,s={partial:!0,tokenize:j};let r=0,o=0,a;return u;function u(R){return h(R)}function h(R){const z=n.events[n.events.length-1];return r=z&&z[1].type==="linePrefix"?z[2].sliceSerialize(z[1],!0).length:0,a=R,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),p(R)}function p(R){return R===a?(o++,t.consume(R),p):o<3?i(R):(t.exit("codeFencedFenceSequence"),Et(R)?Dt(t,m,"whitespace")(R):m(R))}function m(R){return R===null||tt(R)?(t.exit("codeFencedFence"),n.interrupt?e(R):t.check(eE,S,N)(R)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),v(R))}function v(R){return R===null||tt(R)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),m(R)):Et(R)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),Dt(t,_,"whitespace")(R)):R===96&&R===a?i(R):(t.consume(R),v)}function _(R){return R===null||tt(R)?m(R):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),x(R))}function x(R){return R===null||tt(R)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),m(R)):R===96&&R===a?i(R):(t.consume(R),x)}function S(R){return t.attempt(s,N,C)(R)}function C(R){return t.enter("lineEnding"),t.consume(R),t.exit("lineEnding"),k}function k(R){return r>0&&Et(R)?Dt(t,M,"linePrefix",r+1)(R):M(R)}function M(R){return R===null||tt(R)?t.check(eE,S,N)(R):(t.enter("codeFlowValue"),L(R))}function L(R){return R===null||tt(R)?(t.exit("codeFlowValue"),M(R)):(t.consume(R),L)}function N(R){return t.exit("codeFenced"),e(R)}function j(R,z,J){let G=0;return q;function q(F){return R.enter("lineEnding"),R.consume(F),R.exit("lineEnding"),X}function X(F){return R.enter("codeFencedFence"),Et(F)?Dt(R,I,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):I(F)}function I(F){return F===a?(R.enter("codeFencedFenceSequence"),T(F)):J(F)}function T(F){return F===a?(G++,R.consume(F),T):G>=o?(R.exit("codeFencedFenceSequence"),Et(F)?Dt(R,H,"whitespace")(F):H(F)):J(F)}function H(F){return F===null||tt(F)?(R.exit("codeFencedFence"),z(F)):J(F)}}}function xP(t,e,i){const n=this;return s;function s(o){return o===null?i(o):(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),r)}function r(o){return n.parser.lazy[n.now().line]?i(o):e(o)}}const N1={name:"codeIndented",tokenize:wP},bP={partial:!0,tokenize:SP};function wP(t,e,i){const n=this;return s;function s(h){return t.enter("codeIndented"),Dt(t,r,"linePrefix",5)(h)}function r(h){const p=n.events[n.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?o(h):i(h)}function o(h){return h===null?u(h):tt(h)?t.attempt(bP,o,u)(h):(t.enter("codeFlowValue"),a(h))}function a(h){return h===null||tt(h)?(t.exit("codeFlowValue"),o(h)):(t.consume(h),a)}function u(h){return t.exit("codeIndented"),e(h)}}function SP(t,e,i){const n=this;return s;function s(o){return n.parser.lazy[n.now().line]?i(o):tt(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s):Dt(t,r,"linePrefix",5)(o)}function r(o){const a=n.events[n.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(o):tt(o)?s(o):i(o)}}const kP={name:"codeText",previous:EP,resolve:CP,tokenize:MP};function CP(t){let e=t.length-4,i=3,n,s;if((t[i][1].type==="lineEnding"||t[i][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(n=i;++n<e;)if(t[n][1].type==="codeTextData"){t[i][1].type="codeTextPadding",t[e][1].type="codeTextPadding",i+=2,e-=2;break}}for(n=i-1,e++;++n<=e;)s===void 0?n!==e&&t[n][1].type!=="lineEnding"&&(s=n):(n===e||t[n][1].type==="lineEnding")&&(t[s][1].type="codeTextData",n!==s+2&&(t[s][1].end=t[n-1][1].end,t.splice(s+2,n-s-2),e-=n-s-2,n=s+2),s=void 0);return t}function EP(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function MP(t,e,i){let n=0,s,r;return o;function o(m){return t.enter("codeText"),t.enter("codeTextSequence"),a(m)}function a(m){return m===96?(t.consume(m),n++,a):(t.exit("codeTextSequence"),u(m))}function u(m){return m===null?i(m):m===32?(t.enter("space"),t.consume(m),t.exit("space"),u):m===96?(r=t.enter("codeTextSequence"),s=0,p(m)):tt(m)?(t.enter("lineEnding"),t.consume(m),t.exit("lineEnding"),u):(t.enter("codeTextData"),h(m))}function h(m){return m===null||m===32||m===96||tt(m)?(t.exit("codeTextData"),u(m)):(t.consume(m),h)}function p(m){return m===96?(t.consume(m),s++,p):s===n?(t.exit("codeTextSequence"),t.exit("codeText"),e(m)):(r.type="codeTextData",h(m))}}class AP{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,i){const n=i??Number.POSITIVE_INFINITY;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,i,n){const s=i||0;this.setCursor(Math.trunc(e));const r=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return n&&Od(this.left,n),r.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),Od(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Od(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const i=this.left.splice(e,Number.POSITIVE_INFINITY);Od(this.right,i.reverse())}else{const i=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);Od(this.left,i.reverse())}}}function Od(t,e){let i=0;if(e.length<1e4)t.push(...e);else for(;i<e.length;)t.push(...e.slice(i,i+1e4)),i+=1e4}function GN(t){const e={};let i=-1,n,s,r,o,a,u,h;const p=new AP(t);for(;++i<p.length;){for(;i in e;)i=e[i];if(n=p.get(i),i&&n[1].type==="chunkFlow"&&p.get(i-1)[1].type==="listItemPrefix"&&(u=n[1]._tokenizer.events,r=0,r<u.length&&u[r][1].type==="lineEndingBlank"&&(r+=2),r<u.length&&u[r][1].type==="content"))for(;++r<u.length&&u[r][1].type!=="content";)u[r][1].type==="chunkText"&&(u[r][1]._isInFirstContentOfListItem=!0,r++);if(n[0]==="enter")n[1].contentType&&(Object.assign(e,LP(p,i)),i=e[i],h=!0);else if(n[1]._container){for(r=i,s=void 0;r--;)if(o=p.get(r),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(s&&(p.get(s)[1].type="lineEndingBlank"),o[1].type="lineEnding",s=r);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;s&&(n[1].end={...p.get(s)[1].start},a=p.slice(s,i),a.unshift(n),p.splice(s,i-s+1,a))}}return or(t,0,Number.POSITIVE_INFINITY,p.slice(0)),!h}function LP(t,e){const i=t.get(e)[1],n=t.get(e)[2];let s=e-1;const r=[];let o=i._tokenizer;o||(o=n.parser[i.contentType](i.start),i._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,u=[],h={};let p,m,v=-1,_=i,x=0,S=0;const C=[S];for(;_;){for(;t.get(++s)[1]!==_;);r.push(s),_._tokenizer||(p=n.sliceStream(_),_.next||p.push(null),m&&o.defineSkip(_.start),_._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(p),_._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),m=_,_=_.next}for(_=i;++v<a.length;)a[v][0]==="exit"&&a[v-1][0]==="enter"&&a[v][1].type===a[v-1][1].type&&a[v][1].start.line!==a[v][1].end.line&&(S=v+1,C.push(S),_._tokenizer=void 0,_.previous=void 0,_=_.next);for(o.events=[],_?(_._tokenizer=void 0,_.previous=void 0):C.pop(),v=C.length;v--;){const k=a.slice(C[v],C[v+1]),M=r.pop();u.push([M,M+k.length-1]),t.splice(M,2,k)}for(u.reverse(),v=-1;++v<u.length;)h[x+u[v][0]]=x+u[v][1],x+=u[v][1]-u[v][0]-1;return h}const TP={resolve:jP,tokenize:RP},NP={partial:!0,tokenize:DP};function jP(t){return GN(t),t}function RP(t,e){let i;return n;function n(a){return t.enter("content"),i=t.enter("chunkContent",{contentType:"content"}),s(a)}function s(a){return a===null?r(a):tt(a)?t.check(NP,o,r)(a):(t.consume(a),s)}function r(a){return t.exit("chunkContent"),t.exit("content"),e(a)}function o(a){return t.consume(a),t.exit("chunkContent"),i.next=t.enter("chunkContent",{contentType:"content",previous:i}),i=i.next,s}}function DP(t,e,i){const n=this;return s;function s(o){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),Dt(t,r,"linePrefix")}function r(o){if(o===null||tt(o))return i(o);const a=n.events[n.events.length-1];return!n.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(o):t.interrupt(n.parser.constructs.flow,i,e)(o)}}function QN(t,e,i,n,s,r,o,a,u){const h=u||Number.POSITIVE_INFINITY;let p=0;return m;function m(k){return k===60?(t.enter(n),t.enter(s),t.enter(r),t.consume(k),t.exit(r),v):k===null||k===32||k===41||i0(k)?i(k):(t.enter(n),t.enter(o),t.enter(a),t.enter("chunkString",{contentType:"string"}),S(k))}function v(k){return k===62?(t.enter(r),t.consume(k),t.exit(r),t.exit(s),t.exit(n),e):(t.enter(a),t.enter("chunkString",{contentType:"string"}),_(k))}function _(k){return k===62?(t.exit("chunkString"),t.exit(a),v(k)):k===null||k===60||tt(k)?i(k):(t.consume(k),k===92?x:_)}function x(k){return k===60||k===62||k===92?(t.consume(k),_):_(k)}function S(k){return!p&&(k===null||k===41||hi(k))?(t.exit("chunkString"),t.exit(a),t.exit(o),t.exit(n),e(k)):p<h&&k===40?(t.consume(k),p++,S):k===41?(t.consume(k),p--,S):k===null||k===32||k===40||i0(k)?i(k):(t.consume(k),k===92?C:S)}function C(k){return k===40||k===41||k===92?(t.consume(k),S):S(k)}}function XN(t,e,i,n,s,r){const o=this;let a=0,u;return h;function h(_){return t.enter(n),t.enter(s),t.consume(_),t.exit(s),t.enter(r),p}function p(_){return a>999||_===null||_===91||_===93&&!u||_===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?i(_):_===93?(t.exit(r),t.enter(s),t.consume(_),t.exit(s),t.exit(n),e):tt(_)?(t.enter("lineEnding"),t.consume(_),t.exit("lineEnding"),p):(t.enter("chunkString",{contentType:"string"}),m(_))}function m(_){return _===null||_===91||_===93||tt(_)||a++>999?(t.exit("chunkString"),p(_)):(t.consume(_),u||(u=!Et(_)),_===92?v:m)}function v(_){return _===91||_===92||_===93?(t.consume(_),a++,m):m(_)}}function ZN(t,e,i,n,s,r){let o;return a;function a(v){return v===34||v===39||v===40?(t.enter(n),t.enter(s),t.consume(v),t.exit(s),o=v===40?41:v,u):i(v)}function u(v){return v===o?(t.enter(s),t.consume(v),t.exit(s),t.exit(n),e):(t.enter(r),h(v))}function h(v){return v===o?(t.exit(r),u(o)):v===null?i(v):tt(v)?(t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),Dt(t,h,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),p(v))}function p(v){return v===o||v===null||tt(v)?(t.exit("chunkString"),h(v)):(t.consume(v),v===92?m:p)}function m(v){return v===o||v===92?(t.consume(v),p):p(v)}}function gf(t,e){let i;return n;function n(s){return tt(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),i=!0,n):Et(s)?Dt(t,n,i?"linePrefix":"lineSuffix")(s):e(s)}}const BP={name:"definition",tokenize:IP},OP={partial:!0,tokenize:PP};function IP(t,e,i){const n=this;let s;return r;function r(_){return t.enter("definition"),o(_)}function o(_){return XN.call(n,t,a,i,"definitionLabel","definitionLabelMarker","definitionLabelString")(_)}function a(_){return s=Qr(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),_===58?(t.enter("definitionMarker"),t.consume(_),t.exit("definitionMarker"),u):i(_)}function u(_){return hi(_)?gf(t,h)(_):h(_)}function h(_){return QN(t,p,i,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(_)}function p(_){return t.attempt(OP,m,m)(_)}function m(_){return Et(_)?Dt(t,v,"whitespace")(_):v(_)}function v(_){return _===null||tt(_)?(t.exit("definition"),n.parser.defined.push(s),e(_)):i(_)}}function PP(t,e,i){return n;function n(a){return hi(a)?gf(t,s)(a):i(a)}function s(a){return ZN(t,r,i,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function r(a){return Et(a)?Dt(t,o,"whitespace")(a):o(a)}function o(a){return a===null||tt(a)?e(a):i(a)}}const zP={name:"hardBreakEscape",tokenize:$P};function $P(t,e,i){return n;function n(r){return t.enter("hardBreakEscape"),t.consume(r),s}function s(r){return tt(r)?(t.exit("hardBreakEscape"),e(r)):i(r)}}const FP={name:"headingAtx",resolve:HP,tokenize:WP};function HP(t,e){let i=t.length-2,n=3,s,r;return t[n][1].type==="whitespace"&&(n+=2),i-2>n&&t[i][1].type==="whitespace"&&(i-=2),t[i][1].type==="atxHeadingSequence"&&(n===i-1||i-4>n&&t[i-2][1].type==="whitespace")&&(i-=n+1===i?2:4),i>n&&(s={type:"atxHeadingText",start:t[n][1].start,end:t[i][1].end},r={type:"chunkText",start:t[n][1].start,end:t[i][1].end,contentType:"text"},or(t,n,i-n+1,[["enter",s,e],["enter",r,e],["exit",r,e],["exit",s,e]])),t}function WP(t,e,i){let n=0;return s;function s(p){return t.enter("atxHeading"),r(p)}function r(p){return t.enter("atxHeadingSequence"),o(p)}function o(p){return p===35&&n++<6?(t.consume(p),o):p===null||hi(p)?(t.exit("atxHeadingSequence"),a(p)):i(p)}function a(p){return p===35?(t.enter("atxHeadingSequence"),u(p)):p===null||tt(p)?(t.exit("atxHeading"),e(p)):Et(p)?Dt(t,a,"whitespace")(p):(t.enter("atxHeadingText"),h(p))}function u(p){return p===35?(t.consume(p),u):(t.exit("atxHeadingSequence"),a(p))}function h(p){return p===null||p===35||hi(p)?(t.exit("atxHeadingText"),a(p)):(t.consume(p),h)}}const qP=["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"],iE=["pre","script","style","textarea"],UP={concrete:!0,name:"htmlFlow",resolveTo:YP,tokenize:GP},VP={partial:!0,tokenize:XP},KP={partial:!0,tokenize:QP};function YP(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function GP(t,e,i){const n=this;let s,r,o,a,u;return h;function h(B){return p(B)}function p(B){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(B),m}function m(B){return B===33?(t.consume(B),v):B===47?(t.consume(B),r=!0,S):B===63?(t.consume(B),s=3,n.interrupt?e:D):cs(B)?(t.consume(B),o=String.fromCharCode(B),C):i(B)}function v(B){return B===45?(t.consume(B),s=2,_):B===91?(t.consume(B),s=5,a=0,x):cs(B)?(t.consume(B),s=4,n.interrupt?e:D):i(B)}function _(B){return B===45?(t.consume(B),n.interrupt?e:D):i(B)}function x(B){const ee="CDATA[";return B===ee.charCodeAt(a++)?(t.consume(B),a===ee.length?n.interrupt?e:I:x):i(B)}function S(B){return cs(B)?(t.consume(B),o=String.fromCharCode(B),C):i(B)}function C(B){if(B===null||B===47||B===62||hi(B)){const ee=B===47,ie=o.toLowerCase();return!ee&&!r&&iE.includes(ie)?(s=1,n.interrupt?e(B):I(B)):qP.includes(o.toLowerCase())?(s=6,ee?(t.consume(B),k):n.interrupt?e(B):I(B)):(s=7,n.interrupt&&!n.parser.lazy[n.now().line]?i(B):r?M(B):L(B))}return B===45||Qn(B)?(t.consume(B),o+=String.fromCharCode(B),C):i(B)}function k(B){return B===62?(t.consume(B),n.interrupt?e:I):i(B)}function M(B){return Et(B)?(t.consume(B),M):q(B)}function L(B){return B===47?(t.consume(B),q):B===58||B===95||cs(B)?(t.consume(B),N):Et(B)?(t.consume(B),L):q(B)}function N(B){return B===45||B===46||B===58||B===95||Qn(B)?(t.consume(B),N):j(B)}function j(B){return B===61?(t.consume(B),R):Et(B)?(t.consume(B),j):L(B)}function R(B){return B===null||B===60||B===61||B===62||B===96?i(B):B===34||B===39?(t.consume(B),u=B,z):Et(B)?(t.consume(B),R):J(B)}function z(B){return B===u?(t.consume(B),u=null,G):B===null||tt(B)?i(B):(t.consume(B),z)}function J(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||hi(B)?j(B):(t.consume(B),J)}function G(B){return B===47||B===62||Et(B)?L(B):i(B)}function q(B){return B===62?(t.consume(B),X):i(B)}function X(B){return B===null||tt(B)?I(B):Et(B)?(t.consume(B),X):i(B)}function I(B){return B===45&&s===2?(t.consume(B),P):B===60&&s===1?(t.consume(B),U):B===62&&s===4?(t.consume(B),$):B===63&&s===3?(t.consume(B),D):B===93&&s===5?(t.consume(B),K):tt(B)&&(s===6||s===7)?(t.exit("htmlFlowData"),t.check(VP,Y,T)(B)):B===null||tt(B)?(t.exit("htmlFlowData"),T(B)):(t.consume(B),I)}function T(B){return t.check(KP,H,Y)(B)}function H(B){return t.enter("lineEnding"),t.consume(B),t.exit("lineEnding"),F}function F(B){return B===null||tt(B)?T(B):(t.enter("htmlFlowData"),I(B))}function P(B){return B===45?(t.consume(B),D):I(B)}function U(B){return B===47?(t.consume(B),o="",V):I(B)}function V(B){if(B===62){const ee=o.toLowerCase();return iE.includes(ee)?(t.consume(B),$):I(B)}return cs(B)&&o.length<8?(t.consume(B),o+=String.fromCharCode(B),V):I(B)}function K(B){return B===93?(t.consume(B),D):I(B)}function D(B){return B===62?(t.consume(B),$):B===45&&s===2?(t.consume(B),D):I(B)}function $(B){return B===null||tt(B)?(t.exit("htmlFlowData"),Y(B)):(t.consume(B),$)}function Y(B){return t.exit("htmlFlow"),e(B)}}function QP(t,e,i){const n=this;return s;function s(o){return tt(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),r):i(o)}function r(o){return n.parser.lazy[n.now().line]?i(o):e(o)}}function XP(t,e,i){return n;function n(s){return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),t.attempt(Vf,e,i)}}const ZP={name:"htmlText",tokenize:JP};function JP(t,e,i){const n=this;let s,r,o;return a;function a(D){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(D),u}function u(D){return D===33?(t.consume(D),h):D===47?(t.consume(D),j):D===63?(t.consume(D),L):cs(D)?(t.consume(D),J):i(D)}function h(D){return D===45?(t.consume(D),p):D===91?(t.consume(D),r=0,x):cs(D)?(t.consume(D),M):i(D)}function p(D){return D===45?(t.consume(D),_):i(D)}function m(D){return D===null?i(D):D===45?(t.consume(D),v):tt(D)?(o=m,U(D)):(t.consume(D),m)}function v(D){return D===45?(t.consume(D),_):m(D)}function _(D){return D===62?P(D):D===45?v(D):m(D)}function x(D){const $="CDATA[";return D===$.charCodeAt(r++)?(t.consume(D),r===$.length?S:x):i(D)}function S(D){return D===null?i(D):D===93?(t.consume(D),C):tt(D)?(o=S,U(D)):(t.consume(D),S)}function C(D){return D===93?(t.consume(D),k):S(D)}function k(D){return D===62?P(D):D===93?(t.consume(D),k):S(D)}function M(D){return D===null||D===62?P(D):tt(D)?(o=M,U(D)):(t.consume(D),M)}function L(D){return D===null?i(D):D===63?(t.consume(D),N):tt(D)?(o=L,U(D)):(t.consume(D),L)}function N(D){return D===62?P(D):L(D)}function j(D){return cs(D)?(t.consume(D),R):i(D)}function R(D){return D===45||Qn(D)?(t.consume(D),R):z(D)}function z(D){return tt(D)?(o=z,U(D)):Et(D)?(t.consume(D),z):P(D)}function J(D){return D===45||Qn(D)?(t.consume(D),J):D===47||D===62||hi(D)?G(D):i(D)}function G(D){return D===47?(t.consume(D),P):D===58||D===95||cs(D)?(t.consume(D),q):tt(D)?(o=G,U(D)):Et(D)?(t.consume(D),G):P(D)}function q(D){return D===45||D===46||D===58||D===95||Qn(D)?(t.consume(D),q):X(D)}function X(D){return D===61?(t.consume(D),I):tt(D)?(o=X,U(D)):Et(D)?(t.consume(D),X):G(D)}function I(D){return D===null||D===60||D===61||D===62||D===96?i(D):D===34||D===39?(t.consume(D),s=D,T):tt(D)?(o=I,U(D)):Et(D)?(t.consume(D),I):(t.consume(D),H)}function T(D){return D===s?(t.consume(D),s=void 0,F):D===null?i(D):tt(D)?(o=T,U(D)):(t.consume(D),T)}function H(D){return D===null||D===34||D===39||D===60||D===61||D===96?i(D):D===47||D===62||hi(D)?G(D):(t.consume(D),H)}function F(D){return D===47||D===62||hi(D)?G(D):i(D)}function P(D){return D===62?(t.consume(D),t.exit("htmlTextData"),t.exit("htmlText"),e):i(D)}function U(D){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(D),t.exit("lineEnding"),V}function V(D){return Et(D)?Dt(t,K,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):K(D)}function K(D){return t.enter("htmlTextData"),o(D)}}const Hw={name:"labelEnd",resolveAll:nz,resolveTo:sz,tokenize:rz},ez={tokenize:oz},tz={tokenize:lz},iz={tokenize:az};function nz(t){let e=-1;const i=[];for(;++e<t.length;){const n=t[e][1];if(i.push(t[e]),n.type==="labelImage"||n.type==="labelLink"||n.type==="labelEnd"){const s=n.type==="labelImage"?4:2;n.type="data",e+=s}}return t.length!==i.length&&or(t,0,t.length,i),t}function sz(t,e){let i=t.length,n=0,s,r,o,a;for(;i--;)if(s=t[i][1],r){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;t[i][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(o){if(t[i][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(r=i,s.type!=="labelLink")){n=2;break}}else s.type==="labelEnd"&&(o=i);const u={type:t[r][1].type==="labelLink"?"link":"image",start:{...t[r][1].start},end:{...t[t.length-1][1].end}},h={type:"label",start:{...t[r][1].start},end:{...t[o][1].end}},p={type:"labelText",start:{...t[r+n+2][1].end},end:{...t[o-2][1].start}};return a=[["enter",u,e],["enter",h,e]],a=Lr(a,t.slice(r+1,r+n+3)),a=Lr(a,[["enter",p,e]]),a=Lr(a,Q0(e.parser.constructs.insideSpan.null,t.slice(r+n+4,o-3),e)),a=Lr(a,[["exit",p,e],t[o-2],t[o-1],["exit",h,e]]),a=Lr(a,t.slice(o+1)),a=Lr(a,[["exit",u,e]]),or(t,r,t.length,a),t}function rz(t,e,i){const n=this;let s=n.events.length,r,o;for(;s--;)if((n.events[s][1].type==="labelImage"||n.events[s][1].type==="labelLink")&&!n.events[s][1]._balanced){r=n.events[s][1];break}return a;function a(v){return r?r._inactive?m(v):(o=n.parser.defined.includes(Qr(n.sliceSerialize({start:r.end,end:n.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(v),t.exit("labelMarker"),t.exit("labelEnd"),u):i(v)}function u(v){return v===40?t.attempt(ez,p,o?p:m)(v):v===91?t.attempt(tz,p,o?h:m)(v):o?p(v):m(v)}function h(v){return t.attempt(iz,p,m)(v)}function p(v){return e(v)}function m(v){return r._balanced=!0,i(v)}}function oz(t,e,i){return n;function n(m){return t.enter("resource"),t.enter("resourceMarker"),t.consume(m),t.exit("resourceMarker"),s}function s(m){return hi(m)?gf(t,r)(m):r(m)}function r(m){return m===41?p(m):QN(t,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function o(m){return hi(m)?gf(t,u)(m):p(m)}function a(m){return i(m)}function u(m){return m===34||m===39||m===40?ZN(t,h,i,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):p(m)}function h(m){return hi(m)?gf(t,p)(m):p(m)}function p(m){return m===41?(t.enter("resourceMarker"),t.consume(m),t.exit("resourceMarker"),t.exit("resource"),e):i(m)}}function lz(t,e,i){const n=this;return s;function s(a){return XN.call(n,t,r,o,"reference","referenceMarker","referenceString")(a)}function r(a){return n.parser.defined.includes(Qr(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)))?e(a):i(a)}function o(a){return i(a)}}function az(t,e,i){return n;function n(r){return t.enter("reference"),t.enter("referenceMarker"),t.consume(r),t.exit("referenceMarker"),s}function s(r){return r===93?(t.enter("referenceMarker"),t.consume(r),t.exit("referenceMarker"),t.exit("reference"),e):i(r)}}const cz={name:"labelStartImage",resolveAll:Hw.resolveAll,tokenize:uz};function uz(t,e,i){const n=this;return s;function s(a){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(a),t.exit("labelImageMarker"),r}function r(a){return a===91?(t.enter("labelMarker"),t.consume(a),t.exit("labelMarker"),t.exit("labelImage"),o):i(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in n.parser.constructs?i(a):e(a)}}const hz={name:"labelStartLink",resolveAll:Hw.resolveAll,tokenize:dz};function dz(t,e,i){const n=this;return s;function s(o){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(o),t.exit("labelMarker"),t.exit("labelLink"),r}function r(o){return o===94&&"_hiddenFootnoteSupport"in n.parser.constructs?i(o):e(o)}}const j1={name:"lineEnding",tokenize:fz};function fz(t,e){return i;function i(n){return t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),Dt(t,e,"linePrefix")}}const Cg={name:"thematicBreak",tokenize:pz};function pz(t,e,i){let n=0,s;return r;function r(h){return t.enter("thematicBreak"),o(h)}function o(h){return s=h,a(h)}function a(h){return h===s?(t.enter("thematicBreakSequence"),u(h)):n>=3&&(h===null||tt(h))?(t.exit("thematicBreak"),e(h)):i(h)}function u(h){return h===s?(t.consume(h),n++,u):(t.exit("thematicBreakSequence"),Et(h)?Dt(t,a,"whitespace")(h):a(h))}}const Ts={continuation:{tokenize:_z},exit:xz,name:"list",tokenize:vz},mz={partial:!0,tokenize:bz},gz={partial:!0,tokenize:yz};function vz(t,e,i){const n=this,s=n.events[n.events.length-1];let r=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,o=0;return a;function a(_){const x=n.containerState.type||(_===42||_===43||_===45?"listUnordered":"listOrdered");if(x==="listUnordered"?!n.containerState.marker||_===n.containerState.marker:px(_)){if(n.containerState.type||(n.containerState.type=x,t.enter(x,{_container:!0})),x==="listUnordered")return t.enter("listItemPrefix"),_===42||_===45?t.check(Cg,i,h)(_):h(_);if(!n.interrupt||_===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),u(_)}return i(_)}function u(_){return px(_)&&++o<10?(t.consume(_),u):(!n.interrupt||o<2)&&(n.containerState.marker?_===n.containerState.marker:_===41||_===46)?(t.exit("listItemValue"),h(_)):i(_)}function h(_){return t.enter("listItemMarker"),t.consume(_),t.exit("listItemMarker"),n.containerState.marker=n.containerState.marker||_,t.check(Vf,n.interrupt?i:p,t.attempt(mz,v,m))}function p(_){return n.containerState.initialBlankLine=!0,r++,v(_)}function m(_){return Et(_)?(t.enter("listItemPrefixWhitespace"),t.consume(_),t.exit("listItemPrefixWhitespace"),v):i(_)}function v(_){return n.containerState.size=r+n.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(_)}}function _z(t,e,i){const n=this;return n.containerState._closeFlow=void 0,t.check(Vf,s,r);function s(a){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,Dt(t,e,"listItemIndent",n.containerState.size+1)(a)}function r(a){return n.containerState.furtherBlankLines||!Et(a)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,o(a)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,t.attempt(gz,e,o)(a))}function o(a){return n.containerState._closeFlow=!0,n.interrupt=void 0,Dt(t,t.attempt(Ts,e,i),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function yz(t,e,i){const n=this;return Dt(t,s,"listItemIndent",n.containerState.size+1);function s(r){const o=n.events[n.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===n.containerState.size?e(r):i(r)}}function xz(t){t.exit(this.containerState.type)}function bz(t,e,i){const n=this;return Dt(t,s,"listItemPrefixWhitespace",n.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(r){const o=n.events[n.events.length-1];return!Et(r)&&o&&o[1].type==="listItemPrefixWhitespace"?e(r):i(r)}}const nE={name:"setextUnderline",resolveTo:wz,tokenize:Sz};function wz(t,e){let i=t.length,n,s,r;for(;i--;)if(t[i][0]==="enter"){if(t[i][1].type==="content"){n=i;break}t[i][1].type==="paragraph"&&(s=i)}else t[i][1].type==="content"&&t.splice(i,1),!r&&t[i][1].type==="definition"&&(r=i);const o={type:"setextHeading",start:{...t[n][1].start},end:{...t[t.length-1][1].end}};return t[s][1].type="setextHeadingText",r?(t.splice(s,0,["enter",o,e]),t.splice(r+1,0,["exit",t[n][1],e]),t[n][1].end={...t[r][1].end}):t[n][1]=o,t.push(["exit",o,e]),t}function Sz(t,e,i){const n=this;let s;return r;function r(h){let p=n.events.length,m;for(;p--;)if(n.events[p][1].type!=="lineEnding"&&n.events[p][1].type!=="linePrefix"&&n.events[p][1].type!=="content"){m=n.events[p][1].type==="paragraph";break}return!n.parser.lazy[n.now().line]&&(n.interrupt||m)?(t.enter("setextHeadingLine"),s=h,o(h)):i(h)}function o(h){return t.enter("setextHeadingLineSequence"),a(h)}function a(h){return h===s?(t.consume(h),a):(t.exit("setextHeadingLineSequence"),Et(h)?Dt(t,u,"lineSuffix")(h):u(h))}function u(h){return h===null||tt(h)?(t.exit("setextHeadingLine"),e(h)):i(h)}}const kz={tokenize:Cz};function Cz(t){const e=this,i=t.attempt(Vf,n,t.attempt(this.parser.constructs.flowInitial,s,Dt(t,t.attempt(this.parser.constructs.flow,s,t.attempt(TP,s)),"linePrefix")));return i;function n(r){if(r===null){t.consume(r);return}return t.enter("lineEndingBlank"),t.consume(r),t.exit("lineEndingBlank"),e.currentConstruct=void 0,i}function s(r){if(r===null){t.consume(r);return}return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),e.currentConstruct=void 0,i}}const Ez={resolveAll:ej()},Mz=JN("string"),Az=JN("text");function JN(t){return{resolveAll:ej(t==="text"?Lz:void 0),tokenize:e};function e(i){const n=this,s=this.parser.constructs[t],r=i.attempt(s,o,a);return o;function o(p){return h(p)?r(p):a(p)}function a(p){if(p===null){i.consume(p);return}return i.enter("data"),i.consume(p),u}function u(p){return h(p)?(i.exit("data"),r(p)):(i.consume(p),u)}function h(p){if(p===null)return!0;const m=s[p];let v=-1;if(m)for(;++v<m.length;){const _=m[v];if(!_.previous||_.previous.call(n,n.previous))return!0}return!1}}}function ej(t){return e;function e(i,n){let s=-1,r;for(;++s<=i.length;)r===void 0?i[s]&&i[s][1].type==="data"&&(r=s,s++):(!i[s]||i[s][1].type!=="data")&&(s!==r+2&&(i[r][1].end=i[s-1][1].end,i.splice(r+2,s-r-2),s=r+2),r=void 0);return t?t(i,n):i}}function Lz(t,e){let i=0;for(;++i<=t.length;)if((i===t.length||t[i][1].type==="lineEnding")&&t[i-1][1].type==="data"){const n=t[i-1][1],s=e.sliceStream(n);let r=s.length,o=-1,a=0,u;for(;r--;){const h=s[r];if(typeof h=="string"){for(o=h.length;h.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(h===-2)u=!0,a++;else if(h!==-1){r++;break}}if(e._contentTypeTextTrailing&&i===t.length&&(a=0),a){const h={type:i===t.length||u||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:r?o:n.start._bufferIndex+o,_index:n.start._index+r,line:n.end.line,column:n.end.column-a,offset:n.end.offset-a},end:{...n.end}};n.end={...h.start},n.start.offset===n.end.offset?Object.assign(n,h):(t.splice(i,0,["enter",h,e],["exit",h,e]),i+=2)}i++}return t}const Tz={42:Ts,43:Ts,45:Ts,48:Ts,49:Ts,50:Ts,51:Ts,52:Ts,53:Ts,54:Ts,55:Ts,56:Ts,57:Ts,62:VN},Nz={91:BP},jz={[-2]:N1,[-1]:N1,32:N1},Rz={35:FP,42:Cg,45:[nE,Cg],60:UP,61:nE,95:Cg,96:tE,126:tE},Dz={38:YN,92:KN},Bz={[-5]:j1,[-4]:j1,[-3]:j1,33:cz,38:YN,42:mx,60:[hP,ZP],91:hz,92:[zP,KN],93:Hw,95:mx,96:kP},Oz={null:[mx,Ez]},Iz={null:[42,95]},Pz={null:[]},zz=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Iz,contentInitial:Nz,disable:Pz,document:Tz,flow:Rz,flowInitial:jz,insideSpan:Oz,string:Dz,text:Bz},Symbol.toStringTag,{value:"Module"}));function $z(t,e,i){let n={_bufferIndex:-1,_index:0,line:i&&i.line||1,column:i&&i.column||1,offset:i&&i.offset||0};const s={},r=[];let o=[],a=[];const u={attempt:z(j),check:z(R),consume:M,enter:L,exit:N,interrupt:z(R,{interrupt:!0})},h={code:null,containerState:{},defineSkip:S,events:[],now:x,parser:t,previous:null,sliceSerialize:v,sliceStream:_,write:m};let p=e.tokenize.call(h,u);return e.resolveAll&&r.push(e),h;function m(X){return o=Lr(o,X),C(),o[o.length-1]!==null?[]:(J(e,0),h.events=Q0(r,h.events,h),h.events)}function v(X,I){return Hz(_(X),I)}function _(X){return Fz(o,X)}function x(){const{_bufferIndex:X,_index:I,line:T,column:H,offset:F}=n;return{_bufferIndex:X,_index:I,line:T,column:H,offset:F}}function S(X){s[X.line]=X.column,q()}function C(){let X;for(;n._index<o.length;){const I=o[n._index];if(typeof I=="string")for(X=n._index,n._bufferIndex<0&&(n._bufferIndex=0);n._index===X&&n._bufferIndex<I.length;)k(I.charCodeAt(n._bufferIndex));else k(I)}}function k(X){p=p(X)}function M(X){tt(X)?(n.line++,n.column=1,n.offset+=X===-3?2:1,q()):X!==-1&&(n.column++,n.offset++),n._bufferIndex<0?n._index++:(n._bufferIndex++,n._bufferIndex===o[n._index].length&&(n._bufferIndex=-1,n._index++)),h.previous=X}function L(X,I){const T=I||{};return T.type=X,T.start=x(),h.events.push(["enter",T,h]),a.push(T),T}function N(X){const I=a.pop();return I.end=x(),h.events.push(["exit",I,h]),I}function j(X,I){J(X,I.from)}function R(X,I){I.restore()}function z(X,I){return T;function T(H,F,P){let U,V,K,D;return Array.isArray(H)?Y(H):"tokenize"in H?Y([H]):$(H);function $(re){return ge;function ge(Ee){const fe=Ee!==null&&re[Ee],Pe=Ee!==null&&re.null,De=[...Array.isArray(fe)?fe:fe?[fe]:[],...Array.isArray(Pe)?Pe:Pe?[Pe]:[]];return Y(De)(Ee)}}function Y(re){return U=re,V=0,re.length===0?P:B(re[V])}function B(re){return ge;function ge(Ee){return D=G(),K=re,re.partial||(h.currentConstruct=re),re.name&&h.parser.constructs.disable.null.includes(re.name)?ie():re.tokenize.call(I?Object.assign(Object.create(h),I):h,u,ee,ie)(Ee)}}function ee(re){return X(K,D),F}function ie(re){return D.restore(),++V<U.length?B(U[V]):P}}}function J(X,I){X.resolveAll&&!r.includes(X)&&r.push(X),X.resolve&&or(h.events,I,h.events.length-I,X.resolve(h.events.slice(I),h)),X.resolveTo&&(h.events=X.resolveTo(h.events,h))}function G(){const X=x(),I=h.previous,T=h.currentConstruct,H=h.events.length,F=Array.from(a);return{from:H,restore:P};function P(){n=X,h.previous=I,h.currentConstruct=T,h.events.length=H,a=F,q()}}function q(){n.line in s&&n.column<2&&(n.column=s[n.line],n.offset+=s[n.line]-1)}}function Fz(t,e){const i=e.start._index,n=e.start._bufferIndex,s=e.end._index,r=e.end._bufferIndex;let o;if(i===s)o=[t[i].slice(n,r)];else{if(o=t.slice(i,s),n>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(n):o.shift()}r>0&&o.push(t[s].slice(0,r))}return o}function Hz(t,e){let i=-1;const n=[];let s;for(;++i<t.length;){const r=t[i];let o;if(typeof r=="string")o=r;else switch(r){case-5:{o="\r";break}case-4:{o=`
|
|
15
|
+
`;break}case-3:{o=`\r
|
|
16
|
+
`;break}case-2:{o=e?" ":" ";break}case-1:{if(!e&&s)continue;o=" ";break}default:o=String.fromCharCode(r)}s=r===-2,n.push(o)}return n.join("")}function Wz(t){const n={constructs:qN([zz,...(t||{}).extensions||[]]),content:s(sP),defined:[],document:s(oP),flow:s(kz),lazy:{},string:s(Mz),text:s(Az)};return n;function s(r){return o;function o(a){return $z(n,r,a)}}}function qz(t){for(;!GN(t););return t}const sE=/[\0\t\n\r]/g;function Uz(){let t=1,e="",i=!0,n;return s;function s(r,o,a){const u=[];let h,p,m,v,_;for(r=e+(typeof r=="string"?r.toString():new TextDecoder(o||void 0).decode(r)),m=0,e="",i&&(r.charCodeAt(0)===65279&&m++,i=void 0);m<r.length;){if(sE.lastIndex=m,h=sE.exec(r),v=h&&h.index!==void 0?h.index:r.length,_=r.charCodeAt(v),!h){e=r.slice(m);break}if(_===10&&m===v&&n)u.push(-3),n=void 0;else switch(n&&(u.push(-5),n=void 0),m<v&&(u.push(r.slice(m,v)),t+=v-m),_){case 0:{u.push(65533),t++;break}case 9:{for(p=Math.ceil(t/4)*4,u.push(-2);t++<p;)u.push(-1);break}case 10:{u.push(-4),t=1;break}default:n=!0,t=1}m=v+1}return a&&(n&&u.push(-5),e&&u.push(e),u.push(null)),u}}const Vz=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Kz(t){return t.replace(Vz,Yz)}function Yz(t,e,i){if(e)return e;if(i.charCodeAt(0)===35){const s=i.charCodeAt(1),r=s===120||s===88;return UN(i.slice(r?2:1),r?16:10)}return Fw(i)||t}const tj={}.hasOwnProperty;function Gz(t,e,i){return e&&typeof e=="object"&&(i=e,e=void 0),Qz(i)(qz(Wz(i).document().write(Uz()(t,e,!0))))}function Qz(t){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(We),autolinkProtocol:G,autolinkEmail:G,atxHeading:r(jt),blockQuote:r(Pe),characterEscape:G,characterReference:G,codeFenced:r(De),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:r(De,o),codeText:r(He,o),codeTextData:G,data:G,codeFlowValue:G,definition:r(_e),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:r(Le),hardBreakEscape:r(di),hardBreakTrailing:r(di),htmlFlow:r(xt,o),htmlFlowData:G,htmlText:r(xt,o),htmlTextData:G,image:r(be),label:o,link:r(We),listItem:r(ve),listItemValue:v,listOrdered:r(Ze,m),listUnordered:r(Ze),paragraph:r(fi),reference:B,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:r(jt),strong:r(Mt),thematicBreak:r(gn)},exit:{atxHeading:u(),atxHeadingSequence:j,autolink:u(),autolinkEmail:fe,autolinkProtocol:Ee,blockQuote:u(),characterEscapeValue:q,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:re,characterReference:ge,codeFenced:u(C),codeFencedFence:S,codeFencedFenceInfo:_,codeFencedFenceMeta:x,codeFlowValue:q,codeIndented:u(k),codeText:u(F),codeTextData:q,data:q,definition:u(),definitionDestinationString:N,definitionLabelString:M,definitionTitleString:L,emphasis:u(),hardBreakEscape:u(I),hardBreakTrailing:u(I),htmlFlow:u(T),htmlFlowData:q,htmlText:u(H),htmlTextData:q,image:u(U),label:K,labelText:V,lineEnding:X,link:u(P),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:ee,resourceDestinationString:D,resourceTitleString:$,resource:Y,setextHeading:u(J),setextHeadingLineSequence:z,setextHeadingText:R,strong:u(),thematicBreak:u()}};ij(e,(t||{}).mdastExtensions||[]);const i={};return n;function n(de){let Me={type:"root",children:[]};const Ke={stack:[Me],tokenStack:[],config:e,enter:a,exit:h,buffer:o,resume:p,data:i},Je=[];let ot=-1;for(;++ot<de.length;)if(de[ot][1].type==="listOrdered"||de[ot][1].type==="listUnordered")if(de[ot][0]==="enter")Je.push(ot);else{const Gt=Je.pop();ot=s(de,Gt,ot)}for(ot=-1;++ot<de.length;){const Gt=e[de[ot][0]];tj.call(Gt,de[ot][1].type)&&Gt[de[ot][1].type].call(Object.assign({sliceSerialize:de[ot][2].sliceSerialize},Ke),de[ot][1])}if(Ke.tokenStack.length>0){const Gt=Ke.tokenStack[Ke.tokenStack.length-1];(Gt[1]||rE).call(Ke,void 0,Gt[0])}for(Me.position={start:ca(de.length>0?de[0][1].start:{line:1,column:1,offset:0}),end:ca(de.length>0?de[de.length-2][1].end:{line:1,column:1,offset:0})},ot=-1;++ot<e.transforms.length;)Me=e.transforms[ot](Me)||Me;return Me}function s(de,Me,Ke){let Je=Me-1,ot=-1,Gt=!1,wt,pt,Ht,gi;for(;++Je<=Ke;){const Tt=de[Je];switch(Tt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Tt[0]==="enter"?ot++:ot--,gi=void 0;break}case"lineEndingBlank":{Tt[0]==="enter"&&(wt&&!gi&&!ot&&!Ht&&(Ht=Je),gi=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:gi=void 0}if(!ot&&Tt[0]==="enter"&&Tt[1].type==="listItemPrefix"||ot===-1&&Tt[0]==="exit"&&(Tt[1].type==="listUnordered"||Tt[1].type==="listOrdered")){if(wt){let vi=Je;for(pt=void 0;vi--;){const Qt=de[vi];if(Qt[1].type==="lineEnding"||Qt[1].type==="lineEndingBlank"){if(Qt[0]==="exit")continue;pt&&(de[pt][1].type="lineEndingBlank",Gt=!0),Qt[1].type="lineEnding",pt=vi}else if(!(Qt[1].type==="linePrefix"||Qt[1].type==="blockQuotePrefix"||Qt[1].type==="blockQuotePrefixWhitespace"||Qt[1].type==="blockQuoteMarker"||Qt[1].type==="listItemIndent"))break}Ht&&(!pt||Ht<pt)&&(wt._spread=!0),wt.end=Object.assign({},pt?de[pt][1].start:Tt[1].end),de.splice(pt||Je,0,["exit",wt,Tt[2]]),Je++,Ke++}if(Tt[1].type==="listItemPrefix"){const vi={type:"listItem",_spread:!1,start:Object.assign({},Tt[1].start),end:void 0};wt=vi,de.splice(Je,0,["enter",vi,Tt[2]]),Je++,Ke++,Ht=void 0,gi=!0}}}return de[Me][1]._spread=Gt,Ke}function r(de,Me){return Ke;function Ke(Je){a.call(this,de(Je),Je),Me&&Me.call(this,Je)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(de,Me,Ke){this.stack[this.stack.length-1].children.push(de),this.stack.push(de),this.tokenStack.push([Me,Ke||void 0]),de.position={start:ca(Me.start),end:void 0}}function u(de){return Me;function Me(Ke){de&&de.call(this,Ke),h.call(this,Ke)}}function h(de,Me){const Ke=this.stack.pop(),Je=this.tokenStack.pop();if(Je)Je[0].type!==de.type&&(Me?Me.call(this,de,Je[0]):(Je[1]||rE).call(this,de,Je[0]));else throw new Error("Cannot close `"+de.type+"` ("+mf({start:de.start,end:de.end})+"): it’s not open");Ke.position.end=ca(de.end)}function p(){return $w(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function v(de){if(this.data.expectingFirstListItemValue){const Me=this.stack[this.stack.length-2];Me.start=Number.parseInt(this.sliceSerialize(de),10),this.data.expectingFirstListItemValue=void 0}}function _(){const de=this.resume(),Me=this.stack[this.stack.length-1];Me.lang=de}function x(){const de=this.resume(),Me=this.stack[this.stack.length-1];Me.meta=de}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const de=this.resume(),Me=this.stack[this.stack.length-1];Me.value=de.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const de=this.resume(),Me=this.stack[this.stack.length-1];Me.value=de.replace(/(\r?\n|\r)$/g,"")}function M(de){const Me=this.resume(),Ke=this.stack[this.stack.length-1];Ke.label=Me,Ke.identifier=Qr(this.sliceSerialize(de)).toLowerCase()}function L(){const de=this.resume(),Me=this.stack[this.stack.length-1];Me.title=de}function N(){const de=this.resume(),Me=this.stack[this.stack.length-1];Me.url=de}function j(de){const Me=this.stack[this.stack.length-1];if(!Me.depth){const Ke=this.sliceSerialize(de).length;Me.depth=Ke}}function R(){this.data.setextHeadingSlurpLineEnding=!0}function z(de){const Me=this.stack[this.stack.length-1];Me.depth=this.sliceSerialize(de).codePointAt(0)===61?1:2}function J(){this.data.setextHeadingSlurpLineEnding=void 0}function G(de){const Ke=this.stack[this.stack.length-1].children;let Je=Ke[Ke.length-1];(!Je||Je.type!=="text")&&(Je=Kt(),Je.position={start:ca(de.start),end:void 0},Ke.push(Je)),this.stack.push(Je)}function q(de){const Me=this.stack.pop();Me.value+=this.sliceSerialize(de),Me.position.end=ca(de.end)}function X(de){const Me=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ke=Me.children[Me.children.length-1];Ke.position.end=ca(de.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(Me.type)&&(G.call(this,de),q.call(this,de))}function I(){this.data.atHardBreak=!0}function T(){const de=this.resume(),Me=this.stack[this.stack.length-1];Me.value=de}function H(){const de=this.resume(),Me=this.stack[this.stack.length-1];Me.value=de}function F(){const de=this.resume(),Me=this.stack[this.stack.length-1];Me.value=de}function P(){const de=this.stack[this.stack.length-1];if(this.data.inReference){const Me=this.data.referenceType||"shortcut";de.type+="Reference",de.referenceType=Me,delete de.url,delete de.title}else delete de.identifier,delete de.label;this.data.referenceType=void 0}function U(){const de=this.stack[this.stack.length-1];if(this.data.inReference){const Me=this.data.referenceType||"shortcut";de.type+="Reference",de.referenceType=Me,delete de.url,delete de.title}else delete de.identifier,delete de.label;this.data.referenceType=void 0}function V(de){const Me=this.sliceSerialize(de),Ke=this.stack[this.stack.length-2];Ke.label=Kz(Me),Ke.identifier=Qr(Me).toLowerCase()}function K(){const de=this.stack[this.stack.length-1],Me=this.resume(),Ke=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ke.type==="link"){const Je=de.children;Ke.children=Je}else Ke.alt=Me}function D(){const de=this.resume(),Me=this.stack[this.stack.length-1];Me.url=de}function $(){const de=this.resume(),Me=this.stack[this.stack.length-1];Me.title=de}function Y(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function ee(de){const Me=this.resume(),Ke=this.stack[this.stack.length-1];Ke.label=Me,Ke.identifier=Qr(this.sliceSerialize(de)).toLowerCase(),this.data.referenceType="full"}function ie(de){this.data.characterReferenceType=de.type}function re(de){const Me=this.sliceSerialize(de),Ke=this.data.characterReferenceType;let Je;Ke?(Je=UN(Me,Ke==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Je=Fw(Me);const ot=this.stack[this.stack.length-1];ot.value+=Je}function ge(de){const Me=this.stack.pop();Me.position.end=ca(de.end)}function Ee(de){q.call(this,de);const Me=this.stack[this.stack.length-1];Me.url=this.sliceSerialize(de)}function fe(de){q.call(this,de);const Me=this.stack[this.stack.length-1];Me.url="mailto:"+this.sliceSerialize(de)}function Pe(){return{type:"blockquote",children:[]}}function De(){return{type:"code",lang:null,meta:null,value:""}}function He(){return{type:"inlineCode",value:""}}function _e(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Le(){return{type:"emphasis",children:[]}}function jt(){return{type:"heading",depth:0,children:[]}}function di(){return{type:"break"}}function xt(){return{type:"html",value:""}}function be(){return{type:"image",title:null,url:"",alt:null}}function We(){return{type:"link",title:null,url:"",children:[]}}function Ze(de){return{type:"list",ordered:de.type==="listOrdered",start:null,spread:de._spread,children:[]}}function ve(de){return{type:"listItem",spread:de._spread,checked:null,children:[]}}function fi(){return{type:"paragraph",children:[]}}function Mt(){return{type:"strong",children:[]}}function Kt(){return{type:"text",value:""}}function gn(){return{type:"thematicBreak"}}}function ca(t){return{line:t.line,column:t.column,offset:t.offset}}function ij(t,e){let i=-1;for(;++i<e.length;){const n=e[i];Array.isArray(n)?ij(t,n):Xz(t,n)}}function Xz(t,e){let i;for(i in e)if(tj.call(e,i))switch(i){case"canContainEols":{const n=e[i];n&&t[i].push(...n);break}case"transforms":{const n=e[i];n&&t[i].push(...n);break}case"enter":case"exit":{const n=e[i];n&&Object.assign(t[i],n);break}}}function rE(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+mf({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+mf({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+mf({start:e.start,end:e.end})+") is still open")}function Zz(t){const e=this;e.parser=i;function i(n){return Gz(n,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function Jz(t,e){const i={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,i),t.applyData(e,i)}function e9(t,e){const i={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,i),[t.applyData(e,i),{type:"text",value:`
|
|
17
|
+
`}]}function t9(t,e){const i=e.value?e.value+`
|
|
18
|
+
`:"",n={},s=e.lang?e.lang.split(/\s+/):[];s.length>0&&(n.className=["language-"+s[0]]);let r={type:"element",tagName:"code",properties:n,children:[{type:"text",value:i}]};return e.meta&&(r.data={meta:e.meta}),t.patch(e,r),r=t.applyData(e,r),r={type:"element",tagName:"pre",properties:{},children:[r]},t.patch(e,r),r}function i9(t,e){const i={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,i),t.applyData(e,i)}function n9(t,e){const i={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,i),t.applyData(e,i)}function s9(t,e){const i=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=String(e.identifier).toUpperCase(),s=Eh(n.toLowerCase()),r=t.footnoteOrder.indexOf(n);let o,a=t.footnoteCounts.get(n);a===void 0?(a=0,t.footnoteOrder.push(n),o=t.footnoteOrder.length):o=r+1,a+=1,t.footnoteCounts.set(n,a);const u={type:"element",tagName:"a",properties:{href:"#"+i+"fn-"+s,id:i+"fnref-"+s+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};t.patch(e,u);const h={type:"element",tagName:"sup",properties:{},children:[u]};return t.patch(e,h),t.applyData(e,h)}function r9(t,e){const i={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,i),t.applyData(e,i)}function o9(t,e){if(t.options.allowDangerousHtml){const i={type:"raw",value:e.value};return t.patch(e,i),t.applyData(e,i)}}function nj(t,e){const i=e.referenceType;let n="]";if(i==="collapsed"?n+="[]":i==="full"&&(n+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+n}];const s=t.all(e),r=s[0];r&&r.type==="text"?r.value="["+r.value:s.unshift({type:"text",value:"["});const o=s[s.length-1];return o&&o.type==="text"?o.value+=n:s.push({type:"text",value:n}),s}function l9(t,e){const i=String(e.identifier).toUpperCase(),n=t.definitionById.get(i);if(!n)return nj(t,e);const s={src:Eh(n.url||""),alt:e.alt};n.title!==null&&n.title!==void 0&&(s.title=n.title);const r={type:"element",tagName:"img",properties:s,children:[]};return t.patch(e,r),t.applyData(e,r)}function a9(t,e){const i={src:Eh(e.url)};e.alt!==null&&e.alt!==void 0&&(i.alt=e.alt),e.title!==null&&e.title!==void 0&&(i.title=e.title);const n={type:"element",tagName:"img",properties:i,children:[]};return t.patch(e,n),t.applyData(e,n)}function c9(t,e){const i={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,i);const n={type:"element",tagName:"code",properties:{},children:[i]};return t.patch(e,n),t.applyData(e,n)}function u9(t,e){const i=String(e.identifier).toUpperCase(),n=t.definitionById.get(i);if(!n)return nj(t,e);const s={href:Eh(n.url||"")};n.title!==null&&n.title!==void 0&&(s.title=n.title);const r={type:"element",tagName:"a",properties:s,children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function h9(t,e){const i={href:Eh(e.url)};e.title!==null&&e.title!==void 0&&(i.title=e.title);const n={type:"element",tagName:"a",properties:i,children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function d9(t,e,i){const n=t.all(e),s=i?f9(i):sj(e),r={},o=[];if(typeof e.checked=="boolean"){const p=n[0];let m;p&&p.type==="element"&&p.tagName==="p"?m=p:(m={type:"element",tagName:"p",properties:{},children:[]},n.unshift(m)),m.children.length>0&&m.children.unshift({type:"text",value:" "}),m.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),r.className=["task-list-item"]}let a=-1;for(;++a<n.length;){const p=n[a];(s||a!==0||p.type!=="element"||p.tagName!=="p")&&o.push({type:"text",value:`
|
|
19
|
+
`}),p.type==="element"&&p.tagName==="p"&&!s?o.push(...p.children):o.push(p)}const u=n[n.length-1];u&&(s||u.type!=="element"||u.tagName!=="p")&&o.push({type:"text",value:`
|
|
20
|
+
`});const h={type:"element",tagName:"li",properties:r,children:o};return t.patch(e,h),t.applyData(e,h)}function f9(t){let e=!1;if(t.type==="list"){e=t.spread||!1;const i=t.children;let n=-1;for(;!e&&++n<i.length;)e=sj(i[n])}return e}function sj(t){const e=t.spread;return e??t.children.length>1}function p9(t,e){const i={},n=t.all(e);let s=-1;for(typeof e.start=="number"&&e.start!==1&&(i.start=e.start);++s<n.length;){const o=n[s];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){i.className=["contains-task-list"];break}}const r={type:"element",tagName:e.ordered?"ol":"ul",properties:i,children:t.wrap(n,!0)};return t.patch(e,r),t.applyData(e,r)}function m9(t,e){const i={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,i),t.applyData(e,i)}function g9(t,e){const i={type:"root",children:t.wrap(t.all(e))};return t.patch(e,i),t.applyData(e,i)}function v9(t,e){const i={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,i),t.applyData(e,i)}function _9(t,e){const i=t.all(e),n=i.shift(),s=[];if(n){const o={type:"element",tagName:"thead",properties:{},children:t.wrap([n],!0)};t.patch(e.children[0],o),s.push(o)}if(i.length>0){const o={type:"element",tagName:"tbody",properties:{},children:t.wrap(i,!0)},a=Ow(e.children[1]),u=IN(e.children[e.children.length-1]);a&&u&&(o.position={start:a,end:u}),s.push(o)}const r={type:"element",tagName:"table",properties:{},children:t.wrap(s,!0)};return t.patch(e,r),t.applyData(e,r)}function y9(t,e,i){const n=i?i.children:void 0,r=(n?n.indexOf(e):1)===0?"th":"td",o=i&&i.type==="table"?i.align:void 0,a=o?o.length:e.children.length;let u=-1;const h=[];for(;++u<a;){const m=e.children[u],v={},_=o?o[u]:void 0;_&&(v.align=_);let x={type:"element",tagName:r,properties:v,children:[]};m&&(x.children=t.all(m),t.patch(m,x),x=t.applyData(m,x)),h.push(x)}const p={type:"element",tagName:"tr",properties:{},children:t.wrap(h,!0)};return t.patch(e,p),t.applyData(e,p)}function x9(t,e){const i={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,i),t.applyData(e,i)}const oE=9,lE=32;function b9(t){const e=String(t),i=/\r?\n|\r/g;let n=i.exec(e),s=0;const r=[];for(;n;)r.push(aE(e.slice(s,n.index),s>0,!0),n[0]),s=n.index+n[0].length,n=i.exec(e);return r.push(aE(e.slice(s),s>0,!1)),r.join("")}function aE(t,e,i){let n=0,s=t.length;if(e){let r=t.codePointAt(n);for(;r===oE||r===lE;)n++,r=t.codePointAt(n)}if(i){let r=t.codePointAt(s-1);for(;r===oE||r===lE;)s--,r=t.codePointAt(s-1)}return s>n?t.slice(n,s):""}function w9(t,e){const i={type:"text",value:b9(String(e.value))};return t.patch(e,i),t.applyData(e,i)}function S9(t,e){const i={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,i),t.applyData(e,i)}const k9={blockquote:Jz,break:e9,code:t9,delete:i9,emphasis:n9,footnoteReference:s9,heading:r9,html:o9,imageReference:l9,image:a9,inlineCode:c9,linkReference:u9,link:h9,listItem:d9,list:p9,paragraph:m9,root:g9,strong:v9,table:_9,tableCell:x9,tableRow:y9,text:w9,thematicBreak:S9,toml:Dm,yaml:Dm,definition:Dm,footnoteDefinition:Dm};function Dm(){}const rj=-1,X0=0,vf=1,n0=2,Ww=3,qw=4,Uw=5,Vw=6,oj=7,lj=8,aj=typeof self=="object"?self:globalThis,cE=(t,e)=>{switch(t){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+t)}return new aj[t](e)},C9=(t,e)=>{const i=(s,r)=>(t.set(r,s),s),n=s=>{if(t.has(s))return t.get(s);const[r,o]=e[s];switch(r){case X0:case rj:return i(o,s);case vf:{const a=i([],s);for(const u of o)a.push(n(u));return a}case n0:{const a=i({},s);for(const[u,h]of o)a[n(u)]=n(h);return a}case Ww:return i(new Date(o),s);case qw:{const{source:a,flags:u}=o;return i(new RegExp(a,u),s)}case Uw:{const a=i(new Map,s);for(const[u,h]of o)a.set(n(u),n(h));return a}case Vw:{const a=i(new Set,s);for(const u of o)a.add(n(u));return a}case oj:{const{name:a,message:u}=o;return i(typeof aj[a]=="function"?cE(a,u):new Error(u),s)}case lj:return i(BigInt(o),s);case"BigInt":return i(Object(BigInt(o)),s);case"ArrayBuffer":return i(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:a}=new Uint8Array(o);return i(new DataView(a),o)}}return i(cE(r,o),s)};return n},uE=t=>C9(new Map,t)(0),dc="",{toString:E9}={},{keys:M9}=Object,Id=t=>{const e=typeof t;if(e!=="object"||!t)return[X0,e];const i=E9.call(t).slice(8,-1);switch(i){case"Array":return[vf,dc];case"Object":return[n0,dc];case"Date":return[Ww,dc];case"RegExp":return[qw,dc];case"Map":return[Uw,dc];case"Set":return[Vw,dc];case"DataView":return[vf,i]}return i.includes("Array")?[vf,i]:t instanceof Error?[oj,t.name||"Error"]:[n0,i]},Bm=([t,e])=>t===X0&&(e==="function"||e==="symbol"),A9=(t,e,i,n)=>{const s=(o,a)=>{const u=n.push(o)-1;return i.set(a,u),u},r=o=>{if(i.has(o))return i.get(o);let[a,u]=Id(o);switch(a){case X0:{let p=o;switch(u){case"bigint":a=lj,p=o.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+u);p=null;break;case"undefined":return s([rj],o)}return s([a,p],o)}case vf:{if(u){let v=o;return u==="DataView"?v=new Uint8Array(o.buffer):u==="ArrayBuffer"&&(v=new Uint8Array(o)),s([u,[...v]],o)}const p=[],m=s([a,p],o);for(const v of o)p.push(r(v));return m}case n0:{if(u)switch(u){case"BigInt":return s([u,o.toString()],o);case"Boolean":case"Number":case"String":return s([u,o.valueOf()],o)}if(e&&"toJSON"in o)return r(o.toJSON());const p=[],m=s([a,p],o);for(const v of M9(o))(t||!Bm(Id(o[v])))&&p.push([r(v),r(o[v])]);return m}case Ww:return s([a,isNaN(o.getTime())?dc:o.toISOString()],o);case qw:{const{source:p,flags:m}=o;return s([a,{source:p,flags:m}],o)}case Uw:{const p=[],m=s([a,p],o);for(const[v,_]of o)(t||!(Bm(Id(v))||Bm(Id(_))))&&p.push([r(v),r(_)]);return m}case Vw:{const p=[],m=s([a,p],o);for(const v of o)(t||!Bm(Id(v)))&&p.push(r(v));return m}}const{message:h}=o;return s([a,{name:u,message:h}],o)};return r},hE=(t,{json:e,lossy:i}={})=>{const n=[];return A9(!(e||i),!!e,new Map,n)(t),n},s0=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?uE(hE(t,e)):structuredClone(t):(t,e)=>uE(hE(t,e));function L9(t,e){const i=[{type:"text",value:"↩"}];return e>1&&i.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),i}function T9(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function N9(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",i=t.options.footnoteBackContent||L9,n=t.options.footnoteBackLabel||T9,s=t.options.footnoteLabel||"Footnotes",r=t.options.footnoteLabelTagName||"h2",o=t.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let u=-1;for(;++u<t.footnoteOrder.length;){const h=t.footnoteById.get(t.footnoteOrder[u]);if(!h)continue;const p=t.all(h),m=String(h.identifier).toUpperCase(),v=Eh(m.toLowerCase());let _=0;const x=[],S=t.footnoteCounts.get(m);for(;S!==void 0&&++_<=S;){x.length>0&&x.push({type:"text",value:" "});let M=typeof i=="string"?i:i(u,_);typeof M=="string"&&(M={type:"text",value:M}),x.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+v+(_>1?"-"+_:""),dataFootnoteBackref:"",ariaLabel:typeof n=="string"?n:n(u,_),className:["data-footnote-backref"]},children:Array.isArray(M)?M:[M]})}const C=p[p.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const M=C.children[C.children.length-1];M&&M.type==="text"?M.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...x)}else p.push(...x);const k={type:"element",tagName:"li",properties:{id:e+"fn-"+v},children:t.wrap(p,!0)};t.patch(h,k),a.push(k)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:r,properties:{...s0(o),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
|
|
21
|
+
`},{type:"element",tagName:"ol",properties:{},children:t.wrap(a,!0)},{type:"text",value:`
|
|
22
|
+
`}]}}const Z0=(function(t){if(t==null)return B9;if(typeof t=="function")return J0(t);if(typeof t=="object")return Array.isArray(t)?j9(t):R9(t);if(typeof t=="string")return D9(t);throw new Error("Expected function, string, or object as test")});function j9(t){const e=[];let i=-1;for(;++i<t.length;)e[i]=Z0(t[i]);return J0(n);function n(...s){let r=-1;for(;++r<e.length;)if(e[r].apply(this,s))return!0;return!1}}function R9(t){const e=t;return J0(i);function i(n){const s=n;let r;for(r in t)if(s[r]!==e[r])return!1;return!0}}function D9(t){return J0(e);function e(i){return i&&i.type===t}}function J0(t){return e;function e(i,n,s){return!!(O9(i)&&t.call(this,i,typeof n=="number"?n:void 0,s||void 0))}}function B9(){return!0}function O9(t){return t!==null&&typeof t=="object"&&"type"in t}const cj=[],I9=!0,gx=!1,P9="skip";function uj(t,e,i,n){let s;typeof e=="function"&&typeof i!="function"?(n=i,i=e):s=e;const r=Z0(s),o=n?-1:1;a(t,void 0,[])();function a(u,h,p){const m=u&&typeof u=="object"?u:{};if(typeof m.type=="string"){const _=typeof m.tagName=="string"?m.tagName:typeof m.name=="string"?m.name:void 0;Object.defineProperty(v,"name",{value:"node ("+(u.type+(_?"<"+_+">":""))+")"})}return v;function v(){let _=cj,x,S,C;if((!e||r(u,h,p[p.length-1]||void 0))&&(_=z9(i(u,p)),_[0]===gx))return _;if("children"in u&&u.children){const k=u;if(k.children&&_[0]!==P9)for(S=(n?k.children.length:-1)+o,C=p.concat(k);S>-1&&S<k.children.length;){const M=k.children[S];if(x=a(M,S,C)(),x[0]===gx)return x;S=typeof x[1]=="number"?x[1]:S+o}}return _}}}function z9(t){return Array.isArray(t)?t:typeof t=="number"?[I9,t]:t==null?cj:[t]}function Kw(t,e,i,n){let s,r,o;typeof e=="function"&&typeof i!="function"?(r=void 0,o=e,s=i):(r=e,o=i,s=n),uj(t,r,a,s);function a(u,h){const p=h[h.length-1],m=p?p.children.indexOf(u):void 0;return o(u,m,p)}}const vx={}.hasOwnProperty,$9={};function F9(t,e){const i=e||$9,n=new Map,s=new Map,r=new Map,o={...k9,...i.handlers},a={all:h,applyData:W9,definitionById:n,footnoteById:s,footnoteCounts:r,footnoteOrder:[],handlers:o,one:u,options:i,patch:H9,wrap:U9};return Kw(t,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const m=p.type==="definition"?n:s,v=String(p.identifier).toUpperCase();m.has(v)||m.set(v,p)}}),a;function u(p,m){const v=p.type,_=a.handlers[v];if(vx.call(a.handlers,v)&&_)return _(a,p,m);if(a.options.passThrough&&a.options.passThrough.includes(v)){if("children"in p){const{children:S,...C}=p,k=s0(C);return k.children=a.all(p),k}return s0(p)}return(a.options.unknownHandler||q9)(a,p,m)}function h(p){const m=[];if("children"in p){const v=p.children;let _=-1;for(;++_<v.length;){const x=a.one(v[_],p);if(x){if(_&&v[_-1].type==="break"&&(!Array.isArray(x)&&x.type==="text"&&(x.value=dE(x.value)),!Array.isArray(x)&&x.type==="element")){const S=x.children[0];S&&S.type==="text"&&(S.value=dE(S.value))}Array.isArray(x)?m.push(...x):m.push(x)}}}return m}}function H9(t,e){t.position&&(e.position=T7(t))}function W9(t,e){let i=e;if(t&&t.data){const n=t.data.hName,s=t.data.hChildren,r=t.data.hProperties;if(typeof n=="string")if(i.type==="element")i.tagName=n;else{const o="children"in i?i.children:[i];i={type:"element",tagName:n,properties:{},children:o}}i.type==="element"&&r&&Object.assign(i.properties,s0(r)),"children"in i&&i.children&&s!==null&&s!==void 0&&(i.children=s)}return i}function q9(t,e){const i=e.data||{},n="value"in e&&!(vx.call(i,"hProperties")||vx.call(i,"hChildren"))?{type:"text",value:e.value}:{type:"element",tagName:"div",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function U9(t,e){const i=[];let n=-1;for(e&&i.push({type:"text",value:`
|
|
23
|
+
`});++n<t.length;)n&&i.push({type:"text",value:`
|
|
24
|
+
`}),i.push(t[n]);return e&&t.length>0&&i.push({type:"text",value:`
|
|
25
|
+
`}),i}function dE(t){let e=0,i=t.charCodeAt(e);for(;i===9||i===32;)e++,i=t.charCodeAt(e);return t.slice(e)}function fE(t,e){const i=F9(t,e),n=i.one(t,void 0),s=N9(i),r=Array.isArray(n)?{type:"root",children:n}:n||{type:"root",children:[]};return s&&r.children.push({type:"text",value:`
|
|
26
|
+
`},s),r}function V9(t,e){return t&&"run"in t?async function(i,n){const s=fE(i,{file:n,...e});await t.run(s,n)}:function(i,n){return fE(i,{file:n,...t||e})}}function pE(t){if(t)throw t}var R1,mE;function K9(){if(mE)return R1;mE=1;var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,i=Object.defineProperty,n=Object.getOwnPropertyDescriptor,s=function(h){return typeof Array.isArray=="function"?Array.isArray(h):e.call(h)==="[object Array]"},r=function(h){if(!h||e.call(h)!=="[object Object]")return!1;var p=t.call(h,"constructor"),m=h.constructor&&h.constructor.prototype&&t.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!p&&!m)return!1;var v;for(v in h);return typeof v>"u"||t.call(h,v)},o=function(h,p){i&&p.name==="__proto__"?i(h,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):h[p.name]=p.newValue},a=function(h,p){if(p==="__proto__")if(t.call(h,p)){if(n)return n(h,p).value}else return;return h[p]};return R1=function u(){var h,p,m,v,_,x,S=arguments[0],C=1,k=arguments.length,M=!1;for(typeof S=="boolean"&&(M=S,S=arguments[1]||{},C=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});C<k;++C)if(h=arguments[C],h!=null)for(p in h)m=a(S,p),v=a(h,p),S!==v&&(M&&v&&(r(v)||(_=s(v)))?(_?(_=!1,x=m&&s(m)?m:[]):x=m&&r(m)?m:{},o(S,{name:p,newValue:u(M,x,v)})):typeof v<"u"&&o(S,{name:p,newValue:v}));return S},R1}var Y9=K9();const D1=GT(Y9);function _x(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function G9(){const t=[],e={run:i,use:n};return e;function i(...s){let r=-1;const o=s.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...s);function a(u,...h){const p=t[++r];let m=-1;if(u){o(u);return}for(;++m<s.length;)(h[m]===null||h[m]===void 0)&&(h[m]=s[m]);s=h,p?Q9(p,a)(...h):o(null,...h)}}function n(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return t.push(s),e}}function Q9(t,e){let i;return n;function n(...o){const a=t.length>o.length;let u;a&&o.push(s);try{u=t.apply(this,o)}catch(h){const p=h;if(a&&i)throw p;return s(p)}a||(u&&u.then&&typeof u.then=="function"?u.then(r,s):u instanceof Error?s(u):r(u))}function s(o,...a){i||(i=!0,e(o,...a))}function r(o){s(null,o)}}const yo={basename:X9,dirname:Z9,extname:J9,join:e$,sep:"/"};function X9(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Kf(t);let i=0,n=-1,s=t.length,r;if(e===void 0||e.length===0||e.length>t.length){for(;s--;)if(t.codePointAt(s)===47){if(r){i=s+1;break}}else n<0&&(r=!0,n=s+1);return n<0?"":t.slice(i,n)}if(e===t)return"";let o=-1,a=e.length-1;for(;s--;)if(t.codePointAt(s)===47){if(r){i=s+1;break}}else o<0&&(r=!0,o=s+1),a>-1&&(t.codePointAt(s)===e.codePointAt(a--)?a<0&&(n=s):(a=-1,n=o));return i===n?n=o:n<0&&(n=t.length),t.slice(i,n)}function Z9(t){if(Kf(t),t.length===0)return".";let e=-1,i=t.length,n;for(;--i;)if(t.codePointAt(i)===47){if(n){e=i;break}}else n||(n=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function J9(t){Kf(t);let e=t.length,i=-1,n=0,s=-1,r=0,o;for(;e--;){const a=t.codePointAt(e);if(a===47){if(o){n=e+1;break}continue}i<0&&(o=!0,i=e+1),a===46?s<0?s=e:r!==1&&(r=1):s>-1&&(r=-1)}return s<0||i<0||r===0||r===1&&s===i-1&&s===n+1?"":t.slice(s,i)}function e$(...t){let e=-1,i;for(;++e<t.length;)Kf(t[e]),t[e]&&(i=i===void 0?t[e]:i+"/"+t[e]);return i===void 0?".":t$(i)}function t$(t){Kf(t);const e=t.codePointAt(0)===47;let i=i$(t,!e);return i.length===0&&!e&&(i="."),i.length>0&&t.codePointAt(t.length-1)===47&&(i+="/"),e?"/"+i:i}function i$(t,e){let i="",n=0,s=-1,r=0,o=-1,a,u;for(;++o<=t.length;){if(o<t.length)a=t.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(s===o-1||r===1))if(s!==o-1&&r===2){if(i.length<2||n!==2||i.codePointAt(i.length-1)!==46||i.codePointAt(i.length-2)!==46){if(i.length>2){if(u=i.lastIndexOf("/"),u!==i.length-1){u<0?(i="",n=0):(i=i.slice(0,u),n=i.length-1-i.lastIndexOf("/")),s=o,r=0;continue}}else if(i.length>0){i="",n=0,s=o,r=0;continue}}e&&(i=i.length>0?i+"/..":"..",n=2)}else i.length>0?i+="/"+t.slice(s+1,o):i=t.slice(s+1,o),n=o-s-1;s=o,r=0}else a===46&&r>-1?r++:r=-1}return i}function Kf(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const n$={cwd:s$};function s$(){return"/"}function yx(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function r$(t){if(typeof t=="string")t=new URL(t);else if(!yx(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return o$(t)}function o$(t){if(t.hostname!==""){const n=new TypeError('File URL host must be "localhost" or empty on darwin');throw n.code="ERR_INVALID_FILE_URL_HOST",n}const e=t.pathname;let i=-1;for(;++i<e.length;)if(e.codePointAt(i)===37&&e.codePointAt(i+1)===50){const n=e.codePointAt(i+2);if(n===70||n===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(e)}const B1=["history","path","basename","stem","extname","dirname"];class hj{constructor(e){let i;e?yx(e)?i={path:e}:typeof e=="string"||l$(e)?i={value:e}:i=e:i={},this.cwd="cwd"in i?"":n$.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<B1.length;){const r=B1[n];r in i&&i[r]!==void 0&&i[r]!==null&&(this[r]=r==="history"?[...i[r]]:i[r])}let s;for(s in i)B1.includes(s)||(this[s]=i[s])}get basename(){return typeof this.path=="string"?yo.basename(this.path):void 0}set basename(e){I1(e,"basename"),O1(e,"basename"),this.path=yo.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?yo.dirname(this.path):void 0}set dirname(e){gE(this.basename,"dirname"),this.path=yo.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?yo.extname(this.path):void 0}set extname(e){if(O1(e,"extname"),gE(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=yo.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){yx(e)&&(e=r$(e)),I1(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?yo.basename(this.path,this.extname):void 0}set stem(e){I1(e,"stem"),O1(e,"stem"),this.path=yo.join(this.dirname||"",e+(this.extname||""))}fail(e,i,n){const s=this.message(e,i,n);throw s.fatal=!0,s}info(e,i,n){const s=this.message(e,i,n);return s.fatal=void 0,s}message(e,i,n){const s=new Zn(e,i,n);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function O1(t,e){if(t&&t.includes(yo.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+yo.sep+"`")}function I1(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function gE(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function l$(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const a$=(function(t){const n=this.constructor.prototype,s=n[t],r=function(){return s.apply(r,arguments)};return Object.setPrototypeOf(r,n),r}),c$={}.hasOwnProperty;class Yw extends a${constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=G9()}copy(){const e=new Yw;let i=-1;for(;++i<this.attachers.length;){const n=this.attachers[i];e.use(...n)}return e.data(D1(!0,{},this.namespace)),e}data(e,i){return typeof e=="string"?arguments.length===2?($1("data",this.frozen),this.namespace[e]=i,this):c$.call(this.namespace,e)&&this.namespace[e]||void 0:e?($1("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[i,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);const s=i.call(e,...n);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const i=Om(e),n=this.parser||this.Parser;return P1("parse",n),n(String(i),i)}process(e,i){const n=this;return this.freeze(),P1("process",this.parser||this.Parser),z1("process",this.compiler||this.Compiler),i?s(void 0,i):new Promise(s);function s(r,o){const a=Om(e),u=n.parse(a);n.run(u,a,function(p,m,v){if(p||!m||!v)return h(p);const _=m,x=n.stringify(_,v);d$(x)?v.value=x:v.result=x,h(p,v)});function h(p,m){p||!m?o(p):r?r(m):i(void 0,m)}}}processSync(e){let i=!1,n;return this.freeze(),P1("processSync",this.parser||this.Parser),z1("processSync",this.compiler||this.Compiler),this.process(e,s),_E("processSync","process",i),n;function s(r,o){i=!0,pE(r),n=o}}run(e,i,n){vE(e),this.freeze();const s=this.transformers;return!n&&typeof i=="function"&&(n=i,i=void 0),n?r(void 0,n):new Promise(r);function r(o,a){const u=Om(i);s.run(e,u,h);function h(p,m,v){const _=m||e;p?a(p):o?o(_):n(void 0,_,v)}}}runSync(e,i){let n=!1,s;return this.run(e,i,r),_E("runSync","run",n),s;function r(o,a){pE(o),s=a,n=!0}}stringify(e,i){this.freeze();const n=Om(i),s=this.compiler||this.Compiler;return z1("stringify",s),vE(e),s(e,n)}use(e,...i){const n=this.attachers,s=this.namespace;if($1("use",this.frozen),e!=null)if(typeof e=="function")u(e,i);else if(typeof e=="object")Array.isArray(e)?a(e):o(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function r(h){if(typeof h=="function")u(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[p,...m]=h;u(p,m)}else o(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function o(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(h.plugins),h.settings&&(s.settings=D1(!0,s.settings,h.settings))}function a(h){let p=-1;if(h!=null)if(Array.isArray(h))for(;++p<h.length;){const m=h[p];r(m)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function u(h,p){let m=-1,v=-1;for(;++m<n.length;)if(n[m][0]===h){v=m;break}if(v===-1)n.push([h,...p]);else if(p.length>0){let[_,...x]=p;const S=n[v][1];_x(S)&&_x(_)&&(_=D1(!0,S,_)),n[v]=[h,_,...x]}}}}const u$=new Yw().freeze();function P1(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function z1(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function $1(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function vE(t){if(!_x(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function _E(t,e,i){if(!i)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Om(t){return h$(t)?t:new hj(t)}function h$(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function d$(t){return typeof t=="string"||f$(t)}function f$(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const p$="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",yE=[],xE={allowDangerousHtml:!0},m$=/^(https?|ircs?|mailto|xmpp)$/i,g$=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Gw(t){const e=v$(t),i=_$(t);return y$(e.runSync(e.parse(i),i),t)}function v$(t){const e=t.rehypePlugins||yE,i=t.remarkPlugins||yE,n=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...xE}:xE;return u$().use(Zz).use(i).use(V9,n).use(e)}function _$(t){const e=t.children||"",i=new hj;return typeof e=="string"&&(i.value=e),i}function y$(t,e){const i=e.allowedElements,n=e.allowElement,s=e.components,r=e.disallowedElements,o=e.skipHtml,a=e.unwrapDisallowed,u=e.urlTransform||x$;for(const p of g$)Object.hasOwn(e,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+p$+p.id,void 0);return Kw(t,h),B7(t,{Fragment:d.Fragment,components:s,ignoreInvalidStyle:!0,jsx:d.jsx,jsxs:d.jsxs,passKeys:!0,passNode:!0});function h(p,m,v){if(p.type==="raw"&&v&&typeof m=="number")return o?v.children.splice(m,1):v.children[m]={type:"text",value:p.value},m;if(p.type==="element"){let _;for(_ in T1)if(Object.hasOwn(T1,_)&&Object.hasOwn(p.properties,_)){const x=p.properties[_],S=T1[_];(S===null||S.includes(p.tagName))&&(p.properties[_]=u(String(x||""),_,p))}}if(p.type==="element"){let _=i?!i.includes(p.tagName):r?r.includes(p.tagName):!1;if(!_&&n&&typeof m=="number"&&(_=!n(p,m,v)),_&&v&&typeof m=="number")return a&&p.children?v.children.splice(m,1,...p.children):v.children.splice(m,1),m}}}function x$(t){const e=t.indexOf(":"),i=t.indexOf("?"),n=t.indexOf("#"),s=t.indexOf("/");return e===-1||s!==-1&&e>s||i!==-1&&e>i||n!==-1&&e>n||m$.test(t.slice(0,e))?t:""}function bE(t,e){const i=String(t);if(typeof e!="string")throw new TypeError("Expected character");let n=0,s=i.indexOf(e);for(;s!==-1;)n++,s=i.indexOf(e,s+e.length);return n}function b$(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function w$(t,e,i){const s=Z0((i||{}).ignore||[]),r=S$(e);let o=-1;for(;++o<r.length;)uj(t,"text",a);function a(h,p){let m=-1,v;for(;++m<p.length;){const _=p[m],x=v?v.children:void 0;if(s(_,x?x.indexOf(_):void 0,v))return;v=_}if(v)return u(h,p)}function u(h,p){const m=p[p.length-1],v=r[o][0],_=r[o][1];let x=0;const C=m.children.indexOf(h);let k=!1,M=[];v.lastIndex=0;let L=v.exec(h.value);for(;L;){const N=L.index,j={index:L.index,input:L.input,stack:[...p,h]};let R=_(...L,j);if(typeof R=="string"&&(R=R.length>0?{type:"text",value:R}:void 0),R===!1?v.lastIndex=N+1:(x!==N&&M.push({type:"text",value:h.value.slice(x,N)}),Array.isArray(R)?M.push(...R):R&&M.push(R),x=N+L[0].length,k=!0),!v.global)break;L=v.exec(h.value)}return k?(x<h.value.length&&M.push({type:"text",value:h.value.slice(x)}),m.children.splice(C,1,...M)):M=[h],C+M.length}}function S$(t){const e=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const i=!t[0]||Array.isArray(t[0])?t:[t];let n=-1;for(;++n<i.length;){const s=i[n];e.push([k$(s[0]),C$(s[1])])}return e}function k$(t){return typeof t=="string"?new RegExp(b$(t),"g"):t}function C$(t){return typeof t=="function"?t:function(){return t}}const F1="phrasing",H1=["autolink","link","image","label"];function E$(){return{transforms:[R$],enter:{literalAutolink:A$,literalAutolinkEmail:W1,literalAutolinkHttp:W1,literalAutolinkWww:W1},exit:{literalAutolink:j$,literalAutolinkEmail:N$,literalAutolinkHttp:L$,literalAutolinkWww:T$}}}function M$(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:F1,notInConstruct:H1},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:F1,notInConstruct:H1},{character:":",before:"[ps]",after:"\\/",inConstruct:F1,notInConstruct:H1}]}}function A$(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function W1(t){this.config.enter.autolinkProtocol.call(this,t)}function L$(t){this.config.exit.autolinkProtocol.call(this,t)}function T$(t){this.config.exit.data.call(this,t);const e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function N$(t){this.config.exit.autolinkEmail.call(this,t)}function j$(t){this.exit(t)}function R$(t){w$(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,D$],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),B$]],{ignore:["link","linkReference"]})}function D$(t,e,i,n,s){let r="";if(!dj(s)||(/^w/i.test(e)&&(i=e+i,e="",r="http://"),!O$(i)))return!1;const o=I$(i+n);if(!o[0])return!1;const a={type:"link",title:null,url:r+e+o[0],children:[{type:"text",value:e+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function B$(t,e,i,n){return!dj(n,!0)||/[-\d_]$/.test(i)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+i,children:[{type:"text",value:e+"@"+i}]}}function O$(t){const e=t.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[a-zA-Z\d]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[a-zA-Z\d]/.test(e[e.length-2])))}function I$(t){const e=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!e)return[t,void 0];t=t.slice(0,e.index);let i=e[0],n=i.indexOf(")");const s=bE(t,"(");let r=bE(t,")");for(;n!==-1&&s>r;)t+=i.slice(0,n+1),i=i.slice(n+1),n=i.indexOf(")"),r++;return[t,i]}function dj(t,e){const i=t.input.charCodeAt(t.index-1);return(t.index===0||Nc(i)||G0(i))&&(!e||i!==47)}fj.peek=V$;function P$(){this.buffer()}function z$(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function $$(){this.buffer()}function F$(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function H$(t){const e=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=Qr(this.sliceSerialize(t)).toLowerCase(),i.label=e}function W$(t){this.exit(t)}function q$(t){const e=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=Qr(this.sliceSerialize(t)).toLowerCase(),i.label=e}function U$(t){this.exit(t)}function V$(){return"["}function fj(t,e,i,n){const s=i.createTracker(n);let r=s.move("[^");const o=i.enter("footnoteReference"),a=i.enter("reference");return r+=s.move(i.safe(i.associationId(t),{after:"]",before:r})),a(),o(),r+=s.move("]"),r}function K$(){return{enter:{gfmFootnoteCallString:P$,gfmFootnoteCall:z$,gfmFootnoteDefinitionLabelString:$$,gfmFootnoteDefinition:F$},exit:{gfmFootnoteCallString:H$,gfmFootnoteCall:W$,gfmFootnoteDefinitionLabelString:q$,gfmFootnoteDefinition:U$}}}function Y$(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:i,footnoteReference:fj},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function i(n,s,r,o){const a=r.createTracker(o);let u=a.move("[^");const h=r.enter("footnoteDefinition"),p=r.enter("label");return u+=a.move(r.safe(r.associationId(n),{before:u,after:"]"})),p(),u+=a.move("]:"),n.children&&n.children.length>0&&(a.shift(4),u+=a.move((e?`
|
|
27
|
+
`:" ")+r.indentLines(r.containerFlow(n,a.current()),e?pj:G$))),h(),u}}function G$(t,e,i){return e===0?t:pj(t,e,i)}function pj(t,e,i){return(i?"":" ")+t}const Q$=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];mj.peek=tF;function X$(){return{canContainEols:["delete"],enter:{strikethrough:J$},exit:{strikethrough:eF}}}function Z$(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Q$}],handlers:{delete:mj}}}function J$(t){this.enter({type:"delete",children:[]},t)}function eF(t){this.exit(t)}function mj(t,e,i,n){const s=i.createTracker(n),r=i.enter("strikethrough");let o=s.move("~~");return o+=i.containerPhrasing(t,{...s.current(),before:o,after:"~"}),o+=s.move("~~"),r(),o}function tF(){return"~"}function iF(t){return t.length}function nF(t,e){const i=e||{},n=(i.align||[]).concat(),s=i.stringLength||iF,r=[],o=[],a=[],u=[];let h=0,p=-1;for(;++p<t.length;){const S=[],C=[];let k=-1;for(t[p].length>h&&(h=t[p].length);++k<t[p].length;){const M=sF(t[p][k]);if(i.alignDelimiters!==!1){const L=s(M);C[k]=L,(u[k]===void 0||L>u[k])&&(u[k]=L)}S.push(M)}o[p]=S,a[p]=C}let m=-1;if(typeof n=="object"&&"length"in n)for(;++m<h;)r[m]=wE(n[m]);else{const S=wE(n);for(;++m<h;)r[m]=S}m=-1;const v=[],_=[];for(;++m<h;){const S=r[m];let C="",k="";S===99?(C=":",k=":"):S===108?C=":":S===114&&(k=":");let M=i.alignDelimiters===!1?1:Math.max(1,u[m]-C.length-k.length);const L=C+"-".repeat(M)+k;i.alignDelimiters!==!1&&(M=C.length+M+k.length,M>u[m]&&(u[m]=M),_[m]=M),v[m]=L}o.splice(1,0,v),a.splice(1,0,_),p=-1;const x=[];for(;++p<o.length;){const S=o[p],C=a[p];m=-1;const k=[];for(;++m<h;){const M=S[m]||"";let L="",N="";if(i.alignDelimiters!==!1){const j=u[m]-(C[m]||0),R=r[m];R===114?L=" ".repeat(j):R===99?j%2?(L=" ".repeat(j/2+.5),N=" ".repeat(j/2-.5)):(L=" ".repeat(j/2),N=L):N=" ".repeat(j)}i.delimiterStart!==!1&&!m&&k.push("|"),i.padding!==!1&&!(i.alignDelimiters===!1&&M==="")&&(i.delimiterStart!==!1||m)&&k.push(" "),i.alignDelimiters!==!1&&k.push(L),k.push(M),i.alignDelimiters!==!1&&k.push(N),i.padding!==!1&&k.push(" "),(i.delimiterEnd!==!1||m!==h-1)&&k.push("|")}x.push(i.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return x.join(`
|
|
28
|
+
`)}function sF(t){return t==null?"":String(t)}function wE(t){const e=typeof t=="string"?t.codePointAt(0):0;return e===67||e===99?99:e===76||e===108?108:e===82||e===114?114:0}function rF(t,e,i,n){const s=i.enter("blockquote"),r=i.createTracker(n);r.move("> "),r.shift(2);const o=i.indentLines(i.containerFlow(t,r.current()),oF);return s(),o}function oF(t,e,i){return">"+(i?"":" ")+t}function lF(t,e){return SE(t,e.inConstruct,!0)&&!SE(t,e.notInConstruct,!1)}function SE(t,e,i){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return i;let n=-1;for(;++n<e.length;)if(t.includes(e[n]))return!0;return!1}function kE(t,e,i,n){let s=-1;for(;++s<i.unsafe.length;)if(i.unsafe[s].character===`
|
|
29
|
+
`&&lF(i.stack,i.unsafe[s]))return/[ \t]/.test(n.before)?"":" ";return`\\
|
|
30
|
+
`}function aF(t,e){const i=String(t);let n=i.indexOf(e),s=n,r=0,o=0;if(typeof e!="string")throw new TypeError("Expected substring");for(;n!==-1;)n===s?++r>o&&(o=r):r=1,s=n+e.length,n=i.indexOf(e,s);return o}function cF(t,e){return!!(e.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function uF(t){const e=t.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function hF(t,e,i,n){const s=uF(i),r=t.value||"",o=s==="`"?"GraveAccent":"Tilde";if(cF(t,i)){const m=i.enter("codeIndented"),v=i.indentLines(r,dF);return m(),v}const a=i.createTracker(n),u=s.repeat(Math.max(aF(r,s)+1,3)),h=i.enter("codeFenced");let p=a.move(u);if(t.lang){const m=i.enter(`codeFencedLang${o}`);p+=a.move(i.safe(t.lang,{before:p,after:" ",encode:["`"],...a.current()})),m()}if(t.lang&&t.meta){const m=i.enter(`codeFencedMeta${o}`);p+=a.move(" "),p+=a.move(i.safe(t.meta,{before:p,after:`
|
|
31
|
+
`,encode:["`"],...a.current()})),m()}return p+=a.move(`
|
|
32
|
+
`),r&&(p+=a.move(r+`
|
|
33
|
+
`)),p+=a.move(u),h(),p}function dF(t,e,i){return(i?"":" ")+t}function Qw(t){const e=t.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function fF(t,e,i,n){const s=Qw(i),r=s==='"'?"Quote":"Apostrophe",o=i.enter("definition");let a=i.enter("label");const u=i.createTracker(n);let h=u.move("[");return h+=u.move(i.safe(i.associationId(t),{before:h,after:"]",...u.current()})),h+=u.move("]: "),a(),!t.url||/[\0- \u007F]/.test(t.url)?(a=i.enter("destinationLiteral"),h+=u.move("<"),h+=u.move(i.safe(t.url,{before:h,after:">",...u.current()})),h+=u.move(">")):(a=i.enter("destinationRaw"),h+=u.move(i.safe(t.url,{before:h,after:t.title?" ":`
|
|
34
|
+
`,...u.current()}))),a(),t.title&&(a=i.enter(`title${r}`),h+=u.move(" "+s),h+=u.move(i.safe(t.title,{before:h,after:s,...u.current()})),h+=u.move(s),a()),o(),h}function pF(t){const e=t.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function Ef(t){return"&#x"+t.toString(16).toUpperCase()+";"}function r0(t,e,i){const n=dh(t),s=dh(e);return n===void 0?s===void 0?i==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:n===1?s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}gj.peek=mF;function gj(t,e,i,n){const s=pF(i),r=i.enter("emphasis"),o=i.createTracker(n),a=o.move(s);let u=o.move(i.containerPhrasing(t,{after:s,before:a,...o.current()}));const h=u.charCodeAt(0),p=r0(n.before.charCodeAt(n.before.length-1),h,s);p.inside&&(u=Ef(h)+u.slice(1));const m=u.charCodeAt(u.length-1),v=r0(n.after.charCodeAt(0),m,s);v.inside&&(u=u.slice(0,-1)+Ef(m));const _=o.move(s);return r(),i.attentionEncodeSurroundingInfo={after:v.outside,before:p.outside},a+u+_}function mF(t,e,i){return i.options.emphasis||"*"}function gF(t,e){let i=!1;return Kw(t,function(n){if("value"in n&&/\r?\n|\r/.test(n.value)||n.type==="break")return i=!0,gx}),!!((!t.depth||t.depth<3)&&$w(t)&&(e.options.setext||i))}function vF(t,e,i,n){const s=Math.max(Math.min(6,t.depth||1),1),r=i.createTracker(n);if(gF(t,i)){const p=i.enter("headingSetext"),m=i.enter("phrasing"),v=i.containerPhrasing(t,{...r.current(),before:`
|
|
35
|
+
`,after:`
|
|
36
|
+
`});return m(),p(),v+`
|
|
37
|
+
`+(s===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(`
|
|
38
|
+
`))+1))}const o="#".repeat(s),a=i.enter("headingAtx"),u=i.enter("phrasing");r.move(o+" ");let h=i.containerPhrasing(t,{before:"# ",after:`
|
|
39
|
+
`,...r.current()});return/^[\t ]/.test(h)&&(h=Ef(h.charCodeAt(0))+h.slice(1)),h=h?o+" "+h:o,i.options.closeAtx&&(h+=" "+o),u(),a(),h}vj.peek=_F;function vj(t){return t.value||""}function _F(){return"<"}_j.peek=yF;function _j(t,e,i,n){const s=Qw(i),r=s==='"'?"Quote":"Apostrophe",o=i.enter("image");let a=i.enter("label");const u=i.createTracker(n);let h=u.move("![");return h+=u.move(i.safe(t.alt,{before:h,after:"]",...u.current()})),h+=u.move("]("),a(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(a=i.enter("destinationLiteral"),h+=u.move("<"),h+=u.move(i.safe(t.url,{before:h,after:">",...u.current()})),h+=u.move(">")):(a=i.enter("destinationRaw"),h+=u.move(i.safe(t.url,{before:h,after:t.title?" ":")",...u.current()}))),a(),t.title&&(a=i.enter(`title${r}`),h+=u.move(" "+s),h+=u.move(i.safe(t.title,{before:h,after:s,...u.current()})),h+=u.move(s),a()),h+=u.move(")"),o(),h}function yF(){return"!"}yj.peek=xF;function yj(t,e,i,n){const s=t.referenceType,r=i.enter("imageReference");let o=i.enter("label");const a=i.createTracker(n);let u=a.move("![");const h=i.safe(t.alt,{before:u,after:"]",...a.current()});u+=a.move(h+"]["),o();const p=i.stack;i.stack=[],o=i.enter("reference");const m=i.safe(i.associationId(t),{before:u,after:"]",...a.current()});return o(),i.stack=p,r(),s==="full"||!h||h!==m?u+=a.move(m+"]"):s==="shortcut"?u=u.slice(0,-1):u+=a.move("]"),u}function xF(){return"!"}xj.peek=bF;function xj(t,e,i){let n=t.value||"",s="`",r=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(n);)s+="`";for(/[^ \r\n]/.test(n)&&(/^[ \r\n]/.test(n)&&/[ \r\n]$/.test(n)||/^`|`$/.test(n))&&(n=" "+n+" ");++r<i.unsafe.length;){const o=i.unsafe[r],a=i.compilePattern(o);let u;if(o.atBreak)for(;u=a.exec(n);){let h=u.index;n.charCodeAt(h)===10&&n.charCodeAt(h-1)===13&&h--,n=n.slice(0,h)+" "+n.slice(u.index+1)}}return s+n+s}function bF(){return"`"}function bj(t,e){const i=$w(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(i===t.url||"mailto:"+i===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}wj.peek=wF;function wj(t,e,i,n){const s=Qw(i),r=s==='"'?"Quote":"Apostrophe",o=i.createTracker(n);let a,u;if(bj(t,i)){const p=i.stack;i.stack=[],a=i.enter("autolink");let m=o.move("<");return m+=o.move(i.containerPhrasing(t,{before:m,after:">",...o.current()})),m+=o.move(">"),a(),i.stack=p,m}a=i.enter("link"),u=i.enter("label");let h=o.move("[");return h+=o.move(i.containerPhrasing(t,{before:h,after:"](",...o.current()})),h+=o.move("]("),u(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(u=i.enter("destinationLiteral"),h+=o.move("<"),h+=o.move(i.safe(t.url,{before:h,after:">",...o.current()})),h+=o.move(">")):(u=i.enter("destinationRaw"),h+=o.move(i.safe(t.url,{before:h,after:t.title?" ":")",...o.current()}))),u(),t.title&&(u=i.enter(`title${r}`),h+=o.move(" "+s),h+=o.move(i.safe(t.title,{before:h,after:s,...o.current()})),h+=o.move(s),u()),h+=o.move(")"),a(),h}function wF(t,e,i){return bj(t,i)?"<":"["}Sj.peek=SF;function Sj(t,e,i,n){const s=t.referenceType,r=i.enter("linkReference");let o=i.enter("label");const a=i.createTracker(n);let u=a.move("[");const h=i.containerPhrasing(t,{before:u,after:"]",...a.current()});u+=a.move(h+"]["),o();const p=i.stack;i.stack=[],o=i.enter("reference");const m=i.safe(i.associationId(t),{before:u,after:"]",...a.current()});return o(),i.stack=p,r(),s==="full"||!h||h!==m?u+=a.move(m+"]"):s==="shortcut"?u=u.slice(0,-1):u+=a.move("]"),u}function SF(){return"["}function Xw(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function kF(t){const e=Xw(t),i=t.options.bulletOther;if(!i)return e==="*"?"-":"*";if(i!=="*"&&i!=="+"&&i!=="-")throw new Error("Cannot serialize items with `"+i+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(i===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+i+"`) to be different");return i}function CF(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function kj(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function EF(t,e,i,n){const s=i.enter("list"),r=i.bulletCurrent;let o=t.ordered?CF(i):Xw(i);const a=t.ordered?o==="."?")":".":kF(i);let u=e&&i.bulletLastUsed?o===i.bulletLastUsed:!1;if(!t.ordered){const p=t.children?t.children[0]:void 0;if((o==="*"||o==="-")&&p&&(!p.children||!p.children[0])&&i.stack[i.stack.length-1]==="list"&&i.stack[i.stack.length-2]==="listItem"&&i.stack[i.stack.length-3]==="list"&&i.stack[i.stack.length-4]==="listItem"&&i.indexStack[i.indexStack.length-1]===0&&i.indexStack[i.indexStack.length-2]===0&&i.indexStack[i.indexStack.length-3]===0&&(u=!0),kj(i)===o&&p){let m=-1;for(;++m<t.children.length;){const v=t.children[m];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){u=!0;break}}}}u&&(o=a),i.bulletCurrent=o;const h=i.containerFlow(t,n);return i.bulletLastUsed=o,i.bulletCurrent=r,s(),h}function MF(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function AF(t,e,i,n){const s=MF(i);let r=i.bulletCurrent||Xw(i);e&&e.type==="list"&&e.ordered&&(r=(typeof e.start=="number"&&e.start>-1?e.start:1)+(i.options.incrementListMarker===!1?0:e.children.indexOf(t))+r);let o=r.length+1;(s==="tab"||s==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(o=Math.ceil(o/4)*4);const a=i.createTracker(n);a.move(r+" ".repeat(o-r.length)),a.shift(o);const u=i.enter("listItem"),h=i.indentLines(i.containerFlow(t,a.current()),p);return u(),h;function p(m,v,_){return v?(_?"":" ".repeat(o))+m:(_?r:r+" ".repeat(o-r.length))+m}}function LF(t,e,i,n){const s=i.enter("paragraph"),r=i.enter("phrasing"),o=i.containerPhrasing(t,n);return r(),s(),o}const TF=Z0(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function NF(t,e,i,n){return(t.children.some(function(o){return TF(o)})?i.containerPhrasing:i.containerFlow).call(i,t,n)}function jF(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}Cj.peek=RF;function Cj(t,e,i,n){const s=jF(i),r=i.enter("strong"),o=i.createTracker(n),a=o.move(s+s);let u=o.move(i.containerPhrasing(t,{after:s,before:a,...o.current()}));const h=u.charCodeAt(0),p=r0(n.before.charCodeAt(n.before.length-1),h,s);p.inside&&(u=Ef(h)+u.slice(1));const m=u.charCodeAt(u.length-1),v=r0(n.after.charCodeAt(0),m,s);v.inside&&(u=u.slice(0,-1)+Ef(m));const _=o.move(s+s);return r(),i.attentionEncodeSurroundingInfo={after:v.outside,before:p.outside},a+u+_}function RF(t,e,i){return i.options.strong||"*"}function DF(t,e,i,n){return i.safe(t.value,n)}function BF(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function OF(t,e,i){const n=(kj(i)+(i.options.ruleSpaces?" ":"")).repeat(BF(i));return i.options.ruleSpaces?n.slice(0,-1):n}const Ej={blockquote:rF,break:kE,code:hF,definition:fF,emphasis:gj,hardBreak:kE,heading:vF,html:vj,image:_j,imageReference:yj,inlineCode:xj,link:wj,linkReference:Sj,list:EF,listItem:AF,paragraph:LF,root:NF,strong:Cj,text:DF,thematicBreak:OF};function IF(){return{enter:{table:PF,tableData:CE,tableHeader:CE,tableRow:$F},exit:{codeText:FF,table:zF,tableData:q1,tableHeader:q1,tableRow:q1}}}function PF(t){const e=t._align;this.enter({type:"table",align:e.map(function(i){return i==="none"?null:i}),children:[]},t),this.data.inTable=!0}function zF(t){this.exit(t),this.data.inTable=void 0}function $F(t){this.enter({type:"tableRow",children:[]},t)}function q1(t){this.exit(t)}function CE(t){this.enter({type:"tableCell",children:[]},t)}function FF(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,HF));const i=this.stack[this.stack.length-1];i.type,i.value=e,this.exit(t)}function HF(t,e){return e==="|"?e:t}function WF(t){const e=t||{},i=e.tableCellPadding,n=e.tablePipeAlign,s=e.stringLength,r=i?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
40
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:o,tableCell:u,tableRow:a}};function o(_,x,S,C){return h(p(_,S,C),_.align)}function a(_,x,S,C){const k=m(_,S,C),M=h([k]);return M.slice(0,M.indexOf(`
|
|
41
|
+
`))}function u(_,x,S,C){const k=S.enter("tableCell"),M=S.enter("phrasing"),L=S.containerPhrasing(_,{...C,before:r,after:r});return M(),k(),L}function h(_,x){return nF(_,{align:x,alignDelimiters:n,padding:i,stringLength:s})}function p(_,x,S){const C=_.children;let k=-1;const M=[],L=x.enter("table");for(;++k<C.length;)M[k]=m(C[k],x,S);return L(),M}function m(_,x,S){const C=_.children;let k=-1;const M=[],L=x.enter("tableRow");for(;++k<C.length;)M[k]=u(C[k],_,x,S);return L(),M}function v(_,x,S){let C=Ej.inlineCode(_,x,S);return S.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function qF(){return{exit:{taskListCheckValueChecked:EE,taskListCheckValueUnchecked:EE,paragraph:VF}}}function UF(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:KF}}}function EE(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function VF(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const i=this.stack[this.stack.length-1];i.type;const n=i.children[0];if(n&&n.type==="text"){const s=e.children;let r=-1,o;for(;++r<s.length;){const a=s[r];if(a.type==="paragraph"){o=a;break}}o===i&&(n.value=n.value.slice(1),n.value.length===0?i.children.shift():i.position&&n.position&&typeof n.position.start.offset=="number"&&(n.position.start.column++,n.position.start.offset++,i.position.start=Object.assign({},n.position.start)))}}this.exit(t)}function KF(t,e,i,n){const s=t.children[0],r=typeof t.checked=="boolean"&&s&&s.type==="paragraph",o="["+(t.checked?"x":" ")+"] ",a=i.createTracker(n);r&&a.move(o);let u=Ej.listItem(t,e,i,{...n,...a.current()});return r&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),u;function h(p){return p+o}}function YF(){return[E$(),K$(),X$(),IF(),qF()]}function GF(t){return{extensions:[M$(),Y$(t),Z$(),WF(t),UF()]}}const QF={tokenize:iH,partial:!0},Mj={tokenize:nH,partial:!0},Aj={tokenize:sH,partial:!0},Lj={tokenize:rH,partial:!0},XF={tokenize:oH,partial:!0},Tj={name:"wwwAutolink",tokenize:eH,previous:jj},Nj={name:"protocolAutolink",tokenize:tH,previous:Rj},Cl={name:"emailAutolink",tokenize:JF,previous:Dj},Do={};function ZF(){return{text:Do}}let lc=48;for(;lc<123;)Do[lc]=Cl,lc++,lc===58?lc=65:lc===91&&(lc=97);Do[43]=Cl;Do[45]=Cl;Do[46]=Cl;Do[95]=Cl;Do[72]=[Cl,Nj];Do[104]=[Cl,Nj];Do[87]=[Cl,Tj];Do[119]=[Cl,Tj];function JF(t,e,i){const n=this;let s,r;return o;function o(m){return!xx(m)||!Dj.call(n,n.previous)||Zw(n.events)?i(m):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),a(m))}function a(m){return xx(m)?(t.consume(m),a):m===64?(t.consume(m),u):i(m)}function u(m){return m===46?t.check(XF,p,h)(m):m===45||m===95||Qn(m)?(r=!0,t.consume(m),u):p(m)}function h(m){return t.consume(m),s=!0,u}function p(m){return r&&s&&cs(n.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(m)):i(m)}}function eH(t,e,i){const n=this;return s;function s(o){return o!==87&&o!==119||!jj.call(n,n.previous)||Zw(n.events)?i(o):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(QF,t.attempt(Mj,t.attempt(Aj,r),i),i)(o))}function r(o){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(o)}}function tH(t,e,i){const n=this;let s="",r=!1;return o;function o(m){return(m===72||m===104)&&Rj.call(n,n.previous)&&!Zw(n.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),s+=String.fromCodePoint(m),t.consume(m),a):i(m)}function a(m){if(cs(m)&&s.length<5)return s+=String.fromCodePoint(m),t.consume(m),a;if(m===58){const v=s.toLowerCase();if(v==="http"||v==="https")return t.consume(m),u}return i(m)}function u(m){return m===47?(t.consume(m),r?h:(r=!0,u)):i(m)}function h(m){return m===null||i0(m)||hi(m)||Nc(m)||G0(m)?i(m):t.attempt(Mj,t.attempt(Aj,p),i)(m)}function p(m){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(m)}}function iH(t,e,i){let n=0;return s;function s(o){return(o===87||o===119)&&n<3?(n++,t.consume(o),s):o===46&&n===3?(t.consume(o),r):i(o)}function r(o){return o===null?i(o):e(o)}}function nH(t,e,i){let n,s,r;return o;function o(h){return h===46||h===95?t.check(Lj,u,a)(h):h===null||hi(h)||Nc(h)||h!==45&&G0(h)?u(h):(r=!0,t.consume(h),o)}function a(h){return h===95?n=!0:(s=n,n=void 0),t.consume(h),o}function u(h){return s||n||!r?i(h):e(h)}}function sH(t,e){let i=0,n=0;return s;function s(o){return o===40?(i++,t.consume(o),s):o===41&&n<i?r(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?t.check(Lj,e,r)(o):o===null||hi(o)||Nc(o)?e(o):(t.consume(o),s)}function r(o){return o===41&&n++,t.consume(o),s}}function rH(t,e,i){return n;function n(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(t.consume(a),n):a===38?(t.consume(a),r):a===93?(t.consume(a),s):a===60||a===null||hi(a)||Nc(a)?e(a):i(a)}function s(a){return a===null||a===40||a===91||hi(a)||Nc(a)?e(a):n(a)}function r(a){return cs(a)?o(a):i(a)}function o(a){return a===59?(t.consume(a),n):cs(a)?(t.consume(a),o):i(a)}}function oH(t,e,i){return n;function n(r){return t.consume(r),s}function s(r){return Qn(r)?i(r):e(r)}}function jj(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||hi(t)}function Rj(t){return!cs(t)}function Dj(t){return!(t===47||xx(t))}function xx(t){return t===43||t===45||t===46||t===95||Qn(t)}function Zw(t){let e=t.length,i=!1;for(;e--;){const n=t[e][1];if((n.type==="labelLink"||n.type==="labelImage")&&!n._balanced){i=!0;break}if(n._gfmAutolinkLiteralWalkedInto){i=!1;break}}return t.length>0&&!i&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),i}const lH={tokenize:mH,partial:!0};function aH(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:dH,continuation:{tokenize:fH},exit:pH}},text:{91:{name:"gfmFootnoteCall",tokenize:hH},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:cH,resolveTo:uH}}}}function cH(t,e,i){const n=this;let s=n.events.length;const r=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let o;for(;s--;){const u=n.events[s][1];if(u.type==="labelImage"){o=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return a;function a(u){if(!o||!o._balanced)return i(u);const h=Qr(n.sliceSerialize({start:o.end,end:n.now()}));return h.codePointAt(0)!==94||!r.includes(h.slice(1))?i(u):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(u),t.exit("gfmFootnoteCallLabelMarker"),e(u))}}function uH(t,e){let i=t.length;for(;i--;)if(t[i][1].type==="labelImage"&&t[i][0]==="enter"){t[i][1];break}t[i+1][1].type="data",t[i+3][1].type="gfmFootnoteCallLabelMarker";const n={type:"gfmFootnoteCall",start:Object.assign({},t[i+3][1].start),end:Object.assign({},t[t.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},t[i+3][1].end),end:Object.assign({},t[i+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const r={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},t[t.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},r.start),end:Object.assign({},r.end)},a=[t[i+1],t[i+2],["enter",n,e],t[i+3],t[i+4],["enter",s,e],["exit",s,e],["enter",r,e],["enter",o,e],["exit",o,e],["exit",r,e],t[t.length-2],t[t.length-1],["exit",n,e]];return t.splice(i,t.length-i+1,...a),t}function hH(t,e,i){const n=this,s=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let r=0,o;return a;function a(m){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(m),t.exit("gfmFootnoteCallLabelMarker"),u}function u(m){return m!==94?i(m):(t.enter("gfmFootnoteCallMarker"),t.consume(m),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",h)}function h(m){if(r>999||m===93&&!o||m===null||m===91||hi(m))return i(m);if(m===93){t.exit("chunkString");const v=t.exit("gfmFootnoteCallString");return s.includes(Qr(n.sliceSerialize(v)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(m),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):i(m)}return hi(m)||(o=!0),r++,t.consume(m),m===92?p:h}function p(m){return m===91||m===92||m===93?(t.consume(m),r++,h):h(m)}}function dH(t,e,i){const n=this,s=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let r,o=0,a;return u;function u(x){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(x),t.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(x){return x===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(x),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",p):i(x)}function p(x){if(o>999||x===93&&!a||x===null||x===91||hi(x))return i(x);if(x===93){t.exit("chunkString");const S=t.exit("gfmFootnoteDefinitionLabelString");return r=Qr(n.sliceSerialize(S)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(x),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),v}return hi(x)||(a=!0),o++,t.consume(x),x===92?m:p}function m(x){return x===91||x===92||x===93?(t.consume(x),o++,p):p(x)}function v(x){return x===58?(t.enter("definitionMarker"),t.consume(x),t.exit("definitionMarker"),s.includes(r)||s.push(r),Dt(t,_,"gfmFootnoteDefinitionWhitespace")):i(x)}function _(x){return e(x)}}function fH(t,e,i){return t.check(Vf,e,t.attempt(lH,e,i))}function pH(t){t.exit("gfmFootnoteDefinition")}function mH(t,e,i){const n=this;return Dt(t,s,"gfmFootnoteDefinitionIndent",5);function s(r){const o=n.events[n.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?e(r):i(r)}}function gH(t){let i=(t||{}).singleTilde;const n={name:"strikethrough",tokenize:r,resolveAll:s};return i==null&&(i=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function s(o,a){let u=-1;for(;++u<o.length;)if(o[u][0]==="enter"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._close){let h=u;for(;h--;)if(o[h][0]==="exit"&&o[h][1].type==="strikethroughSequenceTemporary"&&o[h][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[h][1].end.offset-o[h][1].start.offset){o[u][1].type="strikethroughSequence",o[h][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},o[h][1].start),end:Object.assign({},o[u][1].end)},m={type:"strikethroughText",start:Object.assign({},o[h][1].end),end:Object.assign({},o[u][1].start)},v=[["enter",p,a],["enter",o[h][1],a],["exit",o[h][1],a],["enter",m,a]],_=a.parser.constructs.insideSpan.null;_&&or(v,v.length,0,Q0(_,o.slice(h+1,u),a)),or(v,v.length,0,[["exit",m,a],["enter",o[u][1],a],["exit",o[u][1],a],["exit",p,a]]),or(o,h-1,u-h+3,v),u=h+v.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type==="strikethroughSequenceTemporary"&&(o[u][1].type="data");return o}function r(o,a,u){const h=this.previous,p=this.events;let m=0;return v;function v(x){return h===126&&p[p.length-1][1].type!=="characterEscape"?u(x):(o.enter("strikethroughSequenceTemporary"),_(x))}function _(x){const S=dh(h);if(x===126)return m>1?u(x):(o.consume(x),m++,_);if(m<2&&!i)return u(x);const C=o.exit("strikethroughSequenceTemporary"),k=dh(x);return C._open=!k||k===2&&!!S,C._close=!S||S===2&&!!k,a(x)}}}class vH{constructor(){this.map=[]}add(e,i,n){_H(this,e,i,n)}consume(e){if(this.map.sort(function(r,o){return r[0]-o[0]}),this.map.length===0)return;let i=this.map.length;const n=[];for(;i>0;)i-=1,n.push(e.slice(this.map[i][0]+this.map[i][1]),this.map[i][2]),e.length=this.map[i][0];n.push(e.slice()),e.length=0;let s=n.pop();for(;s;){for(const r of s)e.push(r);s=n.pop()}this.map.length=0}}function _H(t,e,i,n){let s=0;if(!(i===0&&n.length===0)){for(;s<t.map.length;){if(t.map[s][0]===e){t.map[s][1]+=i,t.map[s][2].push(...n);return}s+=1}t.map.push([e,i,n])}}function yH(t,e){let i=!1;const n=[];for(;e<t.length;){const s=t[e];if(i){if(s[0]==="enter")s[1].type==="tableContent"&&n.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const r=n.length-1;n[r]=n[r]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(i=!0);e+=1}return n}function xH(){return{flow:{null:{name:"table",tokenize:bH,resolveAll:wH}}}}function bH(t,e,i){const n=this;let s=0,r=0,o;return a;function a(q){let X=n.events.length-1;for(;X>-1;){const H=n.events[X][1].type;if(H==="lineEnding"||H==="linePrefix")X--;else break}const I=X>-1?n.events[X][1].type:null,T=I==="tableHead"||I==="tableRow"?R:u;return T===R&&n.parser.lazy[n.now().line]?i(q):T(q)}function u(q){return t.enter("tableHead"),t.enter("tableRow"),h(q)}function h(q){return q===124||(o=!0,r+=1),p(q)}function p(q){return q===null?i(q):tt(q)?r>1?(r=0,n.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(q),t.exit("lineEnding"),_):i(q):Et(q)?Dt(t,p,"whitespace")(q):(r+=1,o&&(o=!1,s+=1),q===124?(t.enter("tableCellDivider"),t.consume(q),t.exit("tableCellDivider"),o=!0,p):(t.enter("data"),m(q)))}function m(q){return q===null||q===124||hi(q)?(t.exit("data"),p(q)):(t.consume(q),q===92?v:m)}function v(q){return q===92||q===124?(t.consume(q),m):m(q)}function _(q){return n.interrupt=!1,n.parser.lazy[n.now().line]?i(q):(t.enter("tableDelimiterRow"),o=!1,Et(q)?Dt(t,x,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(q):x(q))}function x(q){return q===45||q===58?C(q):q===124?(o=!0,t.enter("tableCellDivider"),t.consume(q),t.exit("tableCellDivider"),S):j(q)}function S(q){return Et(q)?Dt(t,C,"whitespace")(q):C(q)}function C(q){return q===58?(r+=1,o=!0,t.enter("tableDelimiterMarker"),t.consume(q),t.exit("tableDelimiterMarker"),k):q===45?(r+=1,k(q)):q===null||tt(q)?N(q):j(q)}function k(q){return q===45?(t.enter("tableDelimiterFiller"),M(q)):j(q)}function M(q){return q===45?(t.consume(q),M):q===58?(o=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(q),t.exit("tableDelimiterMarker"),L):(t.exit("tableDelimiterFiller"),L(q))}function L(q){return Et(q)?Dt(t,N,"whitespace")(q):N(q)}function N(q){return q===124?x(q):q===null||tt(q)?!o||s!==r?j(q):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(q)):j(q)}function j(q){return i(q)}function R(q){return t.enter("tableRow"),z(q)}function z(q){return q===124?(t.enter("tableCellDivider"),t.consume(q),t.exit("tableCellDivider"),z):q===null||tt(q)?(t.exit("tableRow"),e(q)):Et(q)?Dt(t,z,"whitespace")(q):(t.enter("data"),J(q))}function J(q){return q===null||q===124||hi(q)?(t.exit("data"),z(q)):(t.consume(q),q===92?G:J)}function G(q){return q===92||q===124?(t.consume(q),J):J(q)}}function wH(t,e){let i=-1,n=!0,s=0,r=[0,0,0,0],o=[0,0,0,0],a=!1,u=0,h,p,m;const v=new vH;for(;++i<t.length;){const _=t[i],x=_[1];_[0]==="enter"?x.type==="tableHead"?(a=!1,u!==0&&(ME(v,e,u,h,p),p=void 0,u=0),h={type:"table",start:Object.assign({},x.start),end:Object.assign({},x.end)},v.add(i,0,[["enter",h,e]])):x.type==="tableRow"||x.type==="tableDelimiterRow"?(n=!0,m=void 0,r=[0,0,0,0],o=[0,i+1,0,0],a&&(a=!1,p={type:"tableBody",start:Object.assign({},x.start),end:Object.assign({},x.end)},v.add(i,0,[["enter",p,e]])),s=x.type==="tableDelimiterRow"?2:p?3:1):s&&(x.type==="data"||x.type==="tableDelimiterMarker"||x.type==="tableDelimiterFiller")?(n=!1,o[2]===0&&(r[1]!==0&&(o[0]=o[1],m=Im(v,e,r,s,void 0,m),r=[0,0,0,0]),o[2]=i)):x.type==="tableCellDivider"&&(n?n=!1:(r[1]!==0&&(o[0]=o[1],m=Im(v,e,r,s,void 0,m)),r=o,o=[r[1],i,0,0])):x.type==="tableHead"?(a=!0,u=i):x.type==="tableRow"||x.type==="tableDelimiterRow"?(u=i,r[1]!==0?(o[0]=o[1],m=Im(v,e,r,s,i,m)):o[1]!==0&&(m=Im(v,e,o,s,i,m)),s=0):s&&(x.type==="data"||x.type==="tableDelimiterMarker"||x.type==="tableDelimiterFiller")&&(o[3]=i)}for(u!==0&&ME(v,e,u,h,p),v.consume(e.events),i=-1;++i<e.events.length;){const _=e.events[i];_[0]==="enter"&&_[1].type==="table"&&(_[1]._align=yH(e.events,i))}return t}function Im(t,e,i,n,s,r){const o=n===1?"tableHeader":n===2?"tableDelimiter":"tableData",a="tableContent";i[0]!==0&&(r.end=Object.assign({},Pu(e.events,i[0])),t.add(i[0],0,[["exit",r,e]]));const u=Pu(e.events,i[1]);if(r={type:o,start:Object.assign({},u),end:Object.assign({},u)},t.add(i[1],0,[["enter",r,e]]),i[2]!==0){const h=Pu(e.events,i[2]),p=Pu(e.events,i[3]),m={type:a,start:Object.assign({},h),end:Object.assign({},p)};if(t.add(i[2],0,[["enter",m,e]]),n!==2){const v=e.events[i[2]],_=e.events[i[3]];if(v[1].end=Object.assign({},_[1].end),v[1].type="chunkText",v[1].contentType="text",i[3]>i[2]+1){const x=i[2]+1,S=i[3]-i[2]-1;t.add(x,S,[])}}t.add(i[3]+1,0,[["exit",m,e]])}return s!==void 0&&(r.end=Object.assign({},Pu(e.events,s)),t.add(s,0,[["exit",r,e]]),r=void 0),r}function ME(t,e,i,n,s){const r=[],o=Pu(e.events,i);s&&(s.end=Object.assign({},o),r.push(["exit",s,e])),n.end=Object.assign({},o),r.push(["exit",n,e]),t.add(i+1,0,r)}function Pu(t,e){const i=t[e],n=i[0]==="enter"?"start":"end";return i[1][n]}const SH={name:"tasklistCheck",tokenize:CH};function kH(){return{text:{91:SH}}}function CH(t,e,i){const n=this;return s;function s(u){return n.previous!==null||!n._gfmTasklistFirstContentOfListItem?i(u):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(u),t.exit("taskListCheckMarker"),r)}function r(u){return hi(u)?(t.enter("taskListCheckValueUnchecked"),t.consume(u),t.exit("taskListCheckValueUnchecked"),o):u===88||u===120?(t.enter("taskListCheckValueChecked"),t.consume(u),t.exit("taskListCheckValueChecked"),o):i(u)}function o(u){return u===93?(t.enter("taskListCheckMarker"),t.consume(u),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),a):i(u)}function a(u){return tt(u)?e(u):Et(u)?t.check({tokenize:EH},e,i)(u):i(u)}}function EH(t,e,i){return Dt(t,n,"whitespace");function n(s){return s===null?i(s):e(s)}}function MH(t){return qN([ZF(),aH(),gH(t),xH(),kH()])}const AH={};function Jw(t){const e=this,i=t||AH,n=e.data(),s=n.micromarkExtensions||(n.micromarkExtensions=[]),r=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),o=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);s.push(MH(i)),r.push(YF()),o.push(GF(i))}const LH="M13.72 11.10L12.00 1.40L10.28 11.10ZM13.93 12.17L17.73 3.08L11.04 10.31ZM13.53 13.19L21.64 7.60L12.10 10.06ZM12.65 13.83L22.49 13.51L13.14 10.43ZM11.55 13.89L20.01 18.94L13.81 11.29ZM10.60 13.35L14.99 22.17L13.90 12.38ZM10.10 12.38L9.01 22.17L13.40 13.35ZM10.19 11.29L3.99 18.94L12.45 13.89ZM10.86 10.43L1.51 13.51L11.35 13.83ZM11.90 10.06L2.36 7.60L10.47 13.19ZM12.96 10.31L6.27 3.08L10.07 12.17Z",TH={x:2.6,y:7.8,width:18.8,height:8.4,rx:4.2};function o0({agent:t,size:e=14}){const i=t==="claude"?"Claude":t==="codex"?"Codex":"pi.dev";return d.jsx("svg",{className:`agent-logo is-${t}`,width:e,height:e,viewBox:"0 0 24 24",role:"img","aria-label":i,children:t==="claude"?d.jsx("path",{d:LH,fill:"currentColor"}):t==="codex"?d.jsx("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",children:[0,60,120].map(n=>d.jsx("rect",{...TH,transform:`rotate(${n} 12 12)`},n))}):d.jsx("path",{d:"M4 7.5h16M8 7.5v11m8-11v8.8c0 1.8.8 2.7 2.4 2.7",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}const NH="mcp__octiq__ask_user",bx=[{opens:"The user closed this question",means:"closed without answering"},{opens:"The user did not answer in time",means:"not answered in time"},{opens:"The question timed out",means:"not answered in time"},{opens:"OctiqFlow is not reachable",means:"could not be asked"},{opens:"OctiqFlow could not be reached",means:"could not be asked"},{opens:"OctiqFlow gave no answer",means:"could not be asked"},{opens:"Nobody is watching OctiqFlow",means:"nobody was there to ask"},{opens:"No question was given",means:"nothing was asked"}];function jH(t,e){if(!e)return{question:t,answer:""};const i=bx.find(n=>e.startsWith(n.opens));return i?{question:t,answer:"",unanswered:i.means}:{question:t,answer:e}}function RH(t,e){if(!e)return t.map(i=>({question:i,answer:""}));if(!/(^|\n)A1:/.test(e)){const i=bx.find(n=>e.startsWith(n.opens));return i?t.map(n=>({question:n,answer:"",unanswered:i.means})):t.map(n=>({question:n,answer:e}))}return t.map((i,n)=>{const s=n+1,r=new RegExp(`(^|\\n)A${s}:`).exec(e);if(!r)return{question:i,answer:""};const o=e.slice(r.index+r[0].length),a=new RegExp(`(^|\\n)Q${s+1}:`).exec(o),u=(a?o.slice(0,a.index):o).trim(),h=bx.find(p=>u.startsWith(p.opens));return h?{question:i,answer:"",unanswered:h.means}:{question:i,answer:u}})}function DH(t,e,i){if(t!==NH)return null;const n=e&&typeof e=="object"?e:{},s=Array.isArray(n.questions)?n.questions:null,r=s?s.map(a=>a&&typeof a=="object"?a.question:void 0).filter(a=>typeof a=="string"&&a.trim().length>0).map(a=>a.trim()):typeof n.question=="string"&&n.question.trim()?[n.question.trim()]:[];if(r.length===0)return null;const o=(i??"").trim();return r.length===1?[jH(r[0],o)]:RH(r,o)}const BH=560,OH=900,IH=45;function PH(t,e){const i=t.replace(/^0+(?=\d)/,""),n=e.replace(/^0+(?=\d)/,"");return i.length!==n.length?i.length-n.length:i.localeCompare(n)}function zH(t,e){return PH(e,t)>=0?"up":"down"}function us({value:t}){const e=String(t),[i,n]=w.useState(null),[s,r]=w.useState(!1),o=w.useRef(e),a=/^\d+$/.test(e);if(w.useEffect(()=>r(!0),[]),w.useEffect(()=>{const m=o.current;if(e===m)return;o.current=e;const v=zH(m,e);n(x=>({from:m,direction:v,run:(x?.run??0)+1}));const _=setTimeout(()=>n(null),BH+OH);return()=>clearTimeout(_)},[e]),!s||!a)return d.jsx(d.Fragment,{children:e});const u=e.split(""),h=i?i.from.split(""):[],p=u.length-h.length;return d.jsxs("span",{className:`roll ${i?"is-fresh":""}`,children:[d.jsx("span",{className:"roll-sr",children:e}),u.map((m,v)=>{const _=i?h[v-p]??"":m;if(!i||_===m)return d.jsx("span",{className:"roll-digit","aria-hidden":"true",children:d.jsx("span",{className:"roll-cell",children:m})},v);const x=i.direction==="up"?(Number(m)+1)%10:(Number(m)+9)%10;return d.jsx("span",{className:"roll-digit","aria-hidden":"true",children:d.jsx("span",{className:`roll-stack is-${i.direction}`,style:{animationDelay:`${(u.length-1-v)*IH}ms`},children:i.direction==="up"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"roll-cell",children:_}),d.jsx("span",{className:"roll-cell",children:m}),d.jsx("span",{className:"roll-cell",children:x})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"roll-cell",children:x}),d.jsx("span",{className:"roll-cell",children:m}),d.jsx("span",{className:"roll-cell",children:_})]})})},v)})]},i?.run??0)}function ct({children:t}){const[e,i]=w.useState(!1),n=String(t).split(/(\d+)/);return w.useEffect(()=>i(!0),[]),e?d.jsx("span",{className:"roll-text",children:n.map((s,r)=>/^\d+$/.test(s)?d.jsx(us,{value:s},`number-${r}`):d.jsx("span",{className:"roll-static",children:s},`text-${r}`))}):d.jsx(d.Fragment,{children:t})}const $H=240,FH={add:"+",del:"−",ctx:" ",gap:" "};function HH({diff:t}){if(!t.added&&!t.removed)return null;const e=t.kind==="create";return d.jsxs("span",{className:"diff-stat",children:[t.added>0&&d.jsxs("span",{className:"diff-stat-add",children:["+",d.jsx(us,{value:t.added})]}),t.removed>0&&d.jsxs("span",{className:"diff-stat-del",children:["−",d.jsx(us,{value:t.removed})]}),d.jsx("span",{className:"diff-kind","data-kind":t.kind,title:e?"A file that did not exist before":"A file that did, changed",children:e?"A":"M"})]})}function Bj({diff:t}){const[e,i]=w.useState(!1),n=e?t.rows:t.rows.slice(0,$H),s=t.rows.length-n.length;return t.rows.length?d.jsxs("div",{className:`diff ${t.numbered?"":"is-plain"}`,children:[d.jsx("div",{className:"diff-body",children:n.map((r,o)=>r.kind==="gap"?d.jsx("div",{className:"diff-row is-gap",children:d.jsx("span",{className:"diff-gap",children:r.text})},o):d.jsxs("div",{className:`diff-row is-${r.kind}`,children:[t.numbered&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"diff-n",children:r.old??""}),d.jsx("span",{className:"diff-n",children:r.new??""})]}),d.jsx("span",{className:"diff-mark","aria-hidden":"true",children:FH[r.kind]}),d.jsx("span",{className:"diff-text",children:r.text===""?" ":r.text})]},o))}),s>0&&d.jsx("button",{className:"diff-more",type:"button",onClick:()=>i(!0),children:d.jsx(ct,{children:`Show ${s} more line${s===1?"":"s"}`})})]}):d.jsx("div",{className:"diff-none",children:"The file was written with the same content it already had."})}function AE(t){const e=t.args,i=t.details;for(const n of[i?.filePath,e?.file_path,e?.path,e?.notebook_path])if(typeof n=="string"&&n.trim())return n.trim();return""}function wx(t){const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e<=0?"":t.slice(0,e)}function WH(t){const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e<0?t:t.slice(e+1)}function qH(t){if(t.kind==="block")return t.block.kind==="tool"?wx(AE(t.block)):"";const e=[...t.tools,t.newest].map(i=>wx(AE(i)));return!e.length||e.some(i=>!i)?"":e.every(i=>i===e[0])?e[0]:""}function UH(t){return t.map(qH)}function VH(t){return t.split(/[/\\]/).filter(Boolean).slice(-2).join("/")||t}const KH={read:d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"}),d.jsx("path",{d:"M14 3v5h5"}),d.jsx("path",{d:"M9 13h6M9 17h4"})]}),edit:d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M12 20h9"}),d.jsx("path",{d:"M16.4 3.6a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z"})]}),run:d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M4 17l5-5-5-5"}),d.jsx("path",{d:"M12 19h8"})]}),search:d.jsxs(d.Fragment,{children:[d.jsx("circle",{cx:"11",cy:"11",r:"7"}),d.jsx("path",{d:"M20 20l-3.6-3.6"})]}),web:d.jsxs(d.Fragment,{children:[d.jsx("circle",{cx:"12",cy:"12",r:"9"}),d.jsx("path",{d:"M3 12h18"}),d.jsx("path",{d:"M12 3a15 15 0 0 1 0 18 15 15 0 0 1 0-18z"})]}),agent:d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M11 3l1.7 4.3L17 9l-4.3 1.7L11 15l-1.7-4.3L5 9l4.3-1.7z"}),d.jsx("path",{d:"M18 14.5l.7 1.8 1.8.7-1.8.7-.7 1.8-.7-1.8-1.8-.7 1.8-.7z"})]}),message:d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M11 3l1.7 4.3L17 9l-4.3 1.7L11 15l-1.7-4.3L5 9l4.3-1.7z"}),d.jsx("path",{d:"M18 14.5l.7 1.8 1.8.7-1.8.7-.7 1.8-.7-1.8-1.8-.7 1.8-.7z"})]}),skill:d.jsx("path",{d:"M9 6a2 2 0 1 1 4 0h3a1 1 0 0 1 1 1v3a2 2 0 1 1 0 4v3a1 1 0 0 1-1 1h-3a2 2 0 1 0-4 0H6a1 1 0 0 1-1-1v-3a2 2 0 1 0 0-4V7a1 1 0 0 1 1-1z"}),mcp:d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M9 3v5M15 3v5"}),d.jsx("path",{d:"M6 8h12v3a6 6 0 0 1-12 0z"}),d.jsx("path",{d:"M12 17v4"})]}),plan:d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M4 7l1.8 1.8L9 5.6"}),d.jsx("path",{d:"M4 16l1.8 1.8L9 14.6"}),d.jsx("path",{d:"M13 7h7M13 17h7"})]}),other:d.jsx("path",{d:"M14.6 6.3a1 1 0 0 0 0 1.4l1.7 1.7a1 1 0 0 0 1.4 0l3.8-3.8a6 6 0 0 1-7.9 7.9l-6.9 6.9a2.1 2.1 0 0 1-3-3l6.9-6.9a6 6 0 0 1 7.9-7.9z"})};function eS({kind:t}){return d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:KH[t]})}function YH({state:t}){return t==="running"?d.jsxs("span",{className:"tool-state is-running",children:[d.jsx("span",{className:"tool-spinner","aria-hidden":"true"}),"running"]}):t==="error"?d.jsx("span",{className:"tool-state is-error",children:"failed"}):t==="stopped"?d.jsx("span",{className:"tool-state is-stopped",children:"stopped"}):d.jsx("span",{className:"tool-state","aria-label":"done",children:d.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"M20 6L9 17l-5-5"})})})}function tS(t){const e=Math.max(0,Math.floor(t/1e3));if(e<60)return`${e}s`;const i=Math.floor(e/60);return i<60?`${i}m ${String(e%60).padStart(2,"0")}s`:`${Math.floor(i/60)}h ${String(i%60).padStart(2,"0")}m`}function GH(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e5?`${Math.round(t/1e3)}k`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(Math.max(0,Math.round(t)))}function QH({elapsedMs:t,tokens:e,approx:i,activity:n,thinking:s,effort:r}){const o=[];return typeof t=="number"&&o.push(tS(t)),e&&o.push(`↓ ${i?"~":""}${GH(e)} tokens`),o.push(n??(s?r?`thinking with ${r} effort`:"thinking…":"working…")),o.join(" · ")}const iS=w.createContext(new Set),XH=iS.Provider;function ZH(t){return w.useContext(iS).has(t)}function JH(){return w.useContext(iS)}function eW({tasks:t,busy:e,children:i}){const[,n]=w.useState(0),s=t.length>0&&!e;w.useEffect(()=>{if(!s)return;const a=setInterval(()=>n(u=>u+1),1e3);return()=>clearInterval(a)},[s]);const r=R8(t,Date.now());if(!r)return d.jsx(d.Fragment,{children:i});const o=r.count===1?r.label:`${r.label} +${r.count-1}`;return d.jsxs(d.Fragment,{children:[!e&&d.jsx("span",{className:"bgwork-dot","aria-hidden":"true"}),e&&d.jsxs(d.Fragment,{children:[i," · "]}),d.jsx("span",{className:"bgwork-said",role:"status",title:o,children:d.jsx(ct,{children:o})}),!e&&d.jsxs(d.Fragment,{children:[" · ",d.jsx("span",{className:"bgwork-time",children:tS(r.elapsedMs)})]})]})}function tW(){return!!navigator.clipboard?.writeText&&window.isSecureContext}function iW(t,e){const i=document.createRange();i.selectNodeContents(t);const n=window.getSelection();n?.removeAllRanges(),n?.addRange(i),t.setSelectionRange(0,e)}async function Yf(t){if(tW())try{return await navigator.clipboard.writeText(t),!0}catch{}const e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.contentEditable="true",e.style.cssText="position:fixed;top:0;left:0;width:1px;height:1px;padding:0;border:0;opacity:0;",document.body.appendChild(e);try{return/iPad|iPhone|iPod/.test(navigator.userAgent)?iW(e,t.length):e.select(),document.execCommand("copy")}catch{return!1}finally{e.remove()}}const Oj=w.createContext(()=>{}),Ij=w.createContext(()=>{});function ev(){return w.useContext(Oj)}function nW(){return w.useContext(Ij)}function l0({icon:t,idle:e,done:i,empty:n,partial:s,arm:r,read:o,className:a="sfp-act"}){const[u,h]=w.useState("idle"),[p,m]=w.useState(e),v=(_,x)=>{h(_),m(x),setTimeout(()=>{h("idle"),m(e)},1600)};return d.jsx("button",{className:`${a} is-${u}`,type:"button",title:p,"aria-label":p,onPointerEnter:r,onPointerDown:r,onFocus:r,onClick:async()=>{const _=o(),{text:x,partial:S}=_ instanceof Promise?await _:_;if(x===null||x===""){v("warn",n??"Nothing to copy");return}if(!await Yf(x)){v("failed","Could not copy");return}v(S?"warn":"done",S?s??i:i)},children:u==="done"?d.jsx(nS,{}):t})}function tv(){return d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("rect",{x:"9",y:"9",width:"12",height:"12",rx:"2"}),d.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function Pj(){return d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"}),d.jsx("path",{d:"M14 2v6h6"}),d.jsx("path",{d:"M8 13h8"}),d.jsx("path",{d:"M8 17h5"})]})}function nS(){return d.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"m20 6-11 11-5-5"})})}function zj({path:t,children:e,code:i=!1}){const n=ev(),[s,r]=w.useState(!1),o=async()=>{await Yf(t)&&(r(!0),setTimeout(()=>r(!1),1400))};return d.jsxs("span",{className:"prose-file-actions",children:[d.jsx("button",{className:`prose-path ${i?"is-code":""}`,type:"button",title:t,onClick:()=>n(t),children:e}),d.jsxs("span",{className:"prose-file-action-menu",role:"group","aria-label":`File actions for ${t}`,children:[d.jsxs("button",{className:`prose-file-action ${s?"is-copied":""}`,type:"button",title:s?"Path copied":`Copy path: ${t}`,"aria-label":s?"Path copied":`Copy path: ${t}`,onClick:()=>{o()},children:[s?d.jsx(nS,{}):d.jsx(tv,{}),d.jsx("span",{className:"prose-file-action-label",children:s?"Path copied":"Copy path"})]}),d.jsxs("button",{className:"prose-file-action",type:"button",title:`Open in OctiqFlow: ${t}`,"aria-label":`Open in OctiqFlow: ${t}`,onClick:()=>n(t),children:[d.jsx(sW,{}),d.jsx("span",{className:"prose-file-action-label",children:"Open in OctiqFlow"})]})]})]})}function sW(){return d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M14 3h7v7"}),d.jsx("path",{d:"m21 3-9 9"}),d.jsx("path",{d:"M19 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h6"})]})}function rW(t){if(!t?.startsWith("/"))return null;let e=t;try{e=decodeURIComponent(t)}catch{}return e.replace(/:\d+(?::\d+)?$/,"")}function sS({href:t,children:e,node:i,...n}){const s=rW(t);return s?d.jsx(zj,{path:s,children:e}):t?d.jsx("a",{...n,href:t,target:"_blank",rel:"noreferrer noopener",children:e}):d.jsx("span",{children:e})}const oW=new Set(["task","agent"]);function LE(t){if(t.args!==void 0)try{return JSON.stringify(t.args,null,2)}catch{}return t.argsJson||""}function TE(){return d.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"M9 5l7 7-7 7"})})}function $j({tool:t,agent:e,onOpenAgent:i,note:n,folder:s,open:r}){const o=!!e||oW.has(t.name.toLowerCase()),a=o&&!!i,u=Lc(t.name,t.args),h=aN(t.name,t.args),p=u.kind==="skill",m=u.kind==="mcp",v=nN(t.name,t.args,t.details),[_,x]=w.useState(()=>r??(!!v||o&&!a&&t.state==="running")),S=p&&t.brief?JT(t.brief):null,C=DH(t.name,t.args,t.result),k=!!C&&C.length>0,M=Sw(t.name,t.args,o),L=(u.kind==="read"||u.kind==="edit")&&u.label.includes("("),N=p?S?.summary??"":k||h||L?"":M,j=s&&wx(N)===s?WH(N):N,R=p?M:"",z=ZH(t.id)&&t.state==="done"&&!t.finish;return d.jsxs("div",{className:["tool",`tool-${t.state}`,p?"tool-skill":""].filter(Boolean).join(" "),children:[d.jsxs("div",{className:"tool-head-row",children:[d.jsxs("button",{className:"tool-head",onClick:()=>a?i():x(J=>!J),type:"button",title:a?"Open read-only agent chat":t.name,"aria-label":a?"Open read-only agent chat":void 0,children:[d.jsx("span",{className:"tool-icon","data-kind":u.kind,"aria-hidden":"true",children:d.jsx(eS,{kind:u.kind})}),d.jsxs("span",{className:"tool-copy",children:[d.jsxs("span",{className:"tool-identity",children:[d.jsx("span",{className:"tool-name",children:u.label}),u.scope&&d.jsx("span",{className:"tool-scope",children:u.scope}),R&&d.jsx("span",{className:"tool-args",children:R})]}),j&&d.jsx("span",{className:"tool-detail",title:j,children:d.jsx("bdi",{children:j})})]}),d.jsxs("span",{className:"tool-head-actions",children:[v&&d.jsx(HH,{diff:v}),t.finish?.status&&d.jsx("span",{className:"tool-finish","data-status":t.finish.status,children:t.finish.status}),z?d.jsxs("span",{className:"tool-state is-background",children:[d.jsx("span",{className:"tool-spinner","aria-hidden":"true"}),"in background"]}):d.jsx(YH,{state:t.state}),!a&&d.jsx("span",{className:`tool-caret ${_?"is-open":""}`,"aria-hidden":"true",children:d.jsx(TE,{})})]})]}),a&&d.jsx("button",{className:"tool-fold",onClick:()=>x(J=>!J),type:"button","aria-expanded":_,"aria-label":_?"Collapse this call":"Expand this call",title:_?"Collapse":"Expand",children:d.jsx("span",{className:`tool-caret ${_?"is-open":""}`,"aria-hidden":"true",children:d.jsx(TE,{})})})]}),C&&C.length>0&&d.jsx("div",{className:"tool-answer",children:C.map((J,G)=>d.jsxs("div",{className:"tool-answer-item",children:[d.jsx("div",{className:"tool-answer-q",children:C.length>1?`${G+1}. ${J.question}`:J.question}),!m&&(J.answer||J.unanswered)&&d.jsxs("div",{className:"tool-answer-row",children:[d.jsx("span",{className:"tool-answer-mark","aria-hidden":"true",children:"↳"}),J.answer?d.jsx("span",{className:"tool-answer-said",children:J.answer}):d.jsx("span",{className:"tool-answer-none",children:J.unanswered})]})]},G))}),_&&d.jsx("div",{className:"tool-expand",children:d.jsxs("div",{className:"tool-body",children:[e&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"tool-label",children:"working"}),e.body]}),v&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"tool-label",children:[t.state==="running"?"writing":v.kind==="create"?"new file":"changes",t.state!=="running"&&!v.numbered&&d.jsx("span",{className:"tool-note",children:"from the arguments"})]}),d.jsx(Bj,{diff:v})]}),S&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"tool-label",children:["instructions",S.dir&&d.jsx("span",{className:"tool-note",children:S.dir})]}),d.jsx("div",{className:"tool-brief prose",children:d.jsx(Gw,{remarkPlugins:[Jw],components:{a:sS},children:S.body})})]}),!v&&!S&&LE(t)&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"tool-label",children:"arguments"}),d.jsx("pre",{className:"tool-pre",children:LE(t)})]}),t.result!==void 0&&(!v||t.state==="error")&&(!p||t.state==="error")&&(!m||t.state==="error")&&(!k||t.state==="error")&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"tool-label",children:o?"report":"result"}),d.jsx("pre",{className:"tool-pre",children:t.result})]}),n&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"tool-label",children:"note"}),d.jsx("pre",{className:"tool-pre tool-note-body",children:n.body})]}),t.finish&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"tool-label",children:["finished",t.finish.outputFile&&d.jsx("span",{className:"tool-note",children:t.finish.outputFile})]}),d.jsx("pre",{className:"tool-pre",children:t.finish.summary})]})]})})]})}const lW=2e3;function aW(t){const[e,i]=w.useState();return w.useEffect(()=>{if(!t){i(void 0);return}const n=window.setTimeout(()=>i(t),lW);return()=>window.clearTimeout(n)},[t]),!!t&&e===t}function cW({tools:t,newest:e,folder:i,note:n}){const[s,r]=w.useState(!1),o=w.useMemo(()=>[...t,e],[t,e]),a=k8(o),u=M8(o),h=[...o].reverse().find(_=>_.state==="running"),p=aW(h?.id),m=h?Sw(h.name,h.args):"",v=a.state==="running"&&!p?"done":a.state;return d.jsxs("div",{className:`tool tool-group tool-${v} ${s?"is-open":""}`,children:[d.jsxs("button",{className:"tool-head tool-group-head",onClick:()=>r(_=>!_),type:"button","aria-expanded":s,title:s?"Hide these calls":`Show all ${a.count} calls`,children:[d.jsx("span",{className:"tool-summary-icon","data-kind":u.kind,"aria-hidden":"true",children:d.jsx(eS,{kind:u.kind})}),d.jsx("span",{className:"tool-summary",children:d.jsx(ct,{children:u.label})}),p&&d.jsx("span",{className:"tool-summary-live",title:m||"Working",children:m||"Working"}),p&&d.jsx("span",{className:"tool-summary-running","aria-label":"running",children:d.jsx("span",{className:"tool-spinner","aria-hidden":"true"})}),a.failed>0&&d.jsxs("span",{className:"tool-state tool-result-counts",children:[d.jsxs("span",{className:"tool-result-success",children:[a.success," success"]}),d.jsx("span",{"aria-hidden":"true",children:";"}),d.jsxs("span",{className:"tool-result-failed",children:[a.failed," failed"]})]})]}),s&&d.jsx("div",{className:"tool-group-body",children:o.map(_=>d.jsx($j,{tool:_,folder:i,note:_.id===e.id?n:void 0},_.id))})]})}const uW=new Set(["png","jpg","jpeg","gif","webp","svg"]);function Vi(t){return t.split("/").filter(Boolean).pop()??t}function Mh(t){const e=Vi(t),i=e.lastIndexOf(".");return i>0?e.slice(i+1).toLowerCase():""}function rS(t){return uW.has(Mh(t))}function Fj(t){return Mh(t)==="pdf"}function hW(t){const e=Mh(t);return e==="html"||e==="htm"}function dW(t){const e=new Map;for(const i of t){const n=Mh(i);e.set(n,(e.get(n)??0)+1)}return[...e.entries()].map(([i,n])=>({ext:i,count:n})).sort((i,n)=>i.ext===""!=(n.ext==="")?i.ext===""?1:-1:n.count-i.count||i.ext.localeCompare(n.ext))}function NE(t){return t===""?"no extension":`.${t}`}const Hj=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function a0(t){return String(t).padStart(2,"0")}function fW(t,e=new Date){if(t==null)return"";const i=new Date(t);if(Number.isNaN(i.getTime()))return"";if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate())return`${a0(i.getHours())}:${a0(i.getMinutes())}`;const s=`${i.getDate()} ${Hj[i.getMonth()]}`;return i.getFullYear()===e.getFullYear()?s:`${s} ${i.getFullYear()}`}function pW(t){if(t==null)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":`Modified ${e.getDate()} ${Hj[e.getMonth()]} ${e.getFullYear()} at ${a0(e.getHours())}:${a0(e.getMinutes())}`}var bl=QT();const mW=340,jE=260;function gW(){if(window.innerWidth<860)return 0;if(typeof document>"u")return jE;const t=getComputedStyle(document.documentElement).getPropertyValue("--nav-w");return Number.parseFloat(t)||jE}function RE(t,e,i){const n=i==="left"?0:gW(),s=Math.max(e.min,Math.min(e.max,window.innerWidth-n-mW));return Math.round(Math.min(s,Math.max(e.min,t)))}function Gf(t,e,i="right"){const[n,s]=w.useState(()=>Number(jr(t))||e.initial),[,r]=w.useState(0),[o,a]=w.useState(!1);w.useEffect(()=>{const p=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(p)},[]),w.useEffect(()=>{const p=()=>r(m=>m+1);return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[]);const u=RE(n,e,i),h=w.useCallback(p=>{p.preventDefault();const m=p.currentTarget;m.setPointerCapture(p.pointerId);const v=p.clientX,_=u;let x=_;const S=k=>{const M=k.clientX-v;x=RE(i==="left"?_+M:_-M,e,i),s(x)},C=()=>{m.removeEventListener("pointermove",S),m.removeEventListener("pointerup",C),m.removeEventListener("pointercancel",C),ri(t,String(x))};m.addEventListener("pointermove",S),m.addEventListener("pointerup",C),m.addEventListener("pointercancel",C)},[t,e,i,u]);return{width:u,startDrag:h,entered:o}}const vW=/\.(md|markdown|mdx)$/i,_W=/\.html?$/i;function oS(t,e){return e.kind==="image"?"image":e.kind==="video"?"video":e.kind!=="text"?"none":e.content.trim()?vW.test(t)?"prose":_W.test(t)?"page":"code":"code"}function yW(t,e){if(!e)return!1;const i=oS(t,e);return i==="prose"||i==="page"}function DE(t,e,i){const n=BE(t,e),s=i>e&&t[i-1]===`
|
|
42
|
+
`?i-1:i;return{from:n,to:Math.max(n,BE(t,s))}}function BE(t,e){let i=1;for(let n=0;n<e&&n<t.length;n++)t[n]===`
|
|
43
|
+
`&&i++;return i}function xW(t,e){const i=bW(t.path,e),n=t.from>0?t.to>t.from?`${i}:${t.from}-${t.to}`:`${i}:${t.from}`:i,s="`".repeat(Math.max(3,wW(t.text)+1));return`${n}
|
|
44
|
+
${s}${kW(i)}
|
|
45
|
+
${t.text}
|
|
46
|
+
${s}
|
|
47
|
+
|
|
48
|
+
`}function bW(t,e){if(!e)return t;const i=e.endsWith("/")?e:`${e}/`;return t.startsWith(i)?t.slice(i.length):t}function wW(t){let e=0,i=0;for(const n of t)i=n==="`"?i+1:0,i>e&&(e=i);return e}const SW={mjs:"js",cjs:"js",mts:"ts",cts:"ts",rs:"rust",py:"python",rb:"ruby",kt:"kotlin",cs:"csharp",yml:"yaml",sh:"bash",zsh:"bash",fish:"bash",h:"c",hpp:"cpp",cc:"cpp",markdown:"md",jsonc:"json"};function kW(t){const e=Mh(t);return e?SW[e]??e:""}const c0=new Set;function CW(t){return c0.add(t),()=>c0.delete(t)}function EW(t){for(const e of c0)e(t)}const MW=()=>c0.size>0,AW=300,zu=new Map;function u0(t,e){return`${t} ${e}`}function Wj(t,e){if(zu.delete(t),zu.set(t,e),zu.size>AW){const i=zu.keys().next();i.done||zu.delete(i.value)}}function qj(t){return zu.get(t)}const Uj=w.createContext(async()=>!1);function lS(){return w.useContext(Uj)}function LW({children:t}){const[e,i]=w.useState(null),n=w.useRef(null),s=w.useCallback(o=>new Promise(a=>{n.current?.(!1),n.current=a,i(o)}),[]),r=w.useCallback(o=>{n.current?.(o),n.current=null,i(null)},[]);return d.jsxs(Uj.Provider,{value:s,children:[t,e&&d.jsx(TW,{options:e,onAnswer:r})]})}function TW({options:t,onAnswer:e}){const i=w.useRef(null);return w.useEffect(()=>{i.current?.focus();const n=s=>{s.key==="Escape"&&(s.preventDefault(),e(!1))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e]),d.jsx("div",{className:"ask-scrim",onClick:()=>e(!1),children:d.jsxs("div",{className:"ask",role:"alertdialog","aria-modal":"true","aria-label":t.title,onClick:n=>n.stopPropagation(),children:[d.jsx("h2",{className:"ask-title",children:t.title}),t.body&&d.jsx("p",{className:"ask-body",children:t.body}),d.jsxs("div",{className:"ask-buttons",children:[d.jsx("button",{className:"ask-btn",type:"button",onClick:()=>e(!1),children:t.cancelLabel??"Cancel"}),d.jsx("button",{ref:i,className:`ask-btn is-primary ${t.danger?"is-danger":""}`,type:"button",onClick:()=>e(!0),children:t.confirmLabel??"OK"})]})]})})}let Sx=[],Vj=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,i=0;e<t.length;e++)(e%2?Vj:Sx).push(i=i+t[e])})();function NW(t){if(t<768)return!1;for(let e=0,i=Sx.length;;){let n=e+i>>1;if(t<Sx[n])i=n;else if(t>=Vj[n])e=n+1;else return!0;if(e==i)return!1}}function OE(t){return t>=127462&&t<=127487}const IE=8205;function jW(t,e,i=!0,n=!0){return(i?Kj:RW)(t,e,n)}function Kj(t,e,i){if(e==t.length)return e;e&&Yj(t.charCodeAt(e))&&Gj(t.charCodeAt(e-1))&&e--;let n=U1(t,e);for(e+=PE(n);e<t.length;){let s=U1(t,e);if(n==IE||s==IE||i&&NW(s))e+=PE(s),n=s;else if(OE(s)){let r=0,o=e-2;for(;o>=0&&OE(U1(t,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function RW(t,e,i){for(;e>1;){let n=Kj(t,e-2,i);if(n<e)return n;e--}return 0}function U1(t,e){let i=t.charCodeAt(e);if(!Gj(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return Yj(n)?(i-55296<<10)+(n-56320)+65536:i}function Yj(t){return t>=56320&&t<57344}function Gj(t){return t>=55296&&t<56320}function PE(t){return t<65536?1:2}let Vt=class Qj{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,i,n){[e,i]=fh(this,e,i);let s=[];return this.decompose(0,e,s,2),n.length&&n.decompose(0,n.length,s,3),this.decompose(i,this.length,s,1),xo.from(s,this.length-(i-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,i=this.length){[e,i]=fh(this,e,i);let n=[];return this.decompose(e,i,n,0),xo.from(n,i-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let i=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),s=new _f(this),r=new _f(e);for(let o=i,a=i;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(a+=s.value.length,s.done||a>=n)return!0}}iter(e=1){return new _f(this,e)}iterRange(e,i=this.length){return new Xj(this,e,i)}iterLines(e,i){let n;if(e==null)n=this.iter();else{i==null&&(i=this.lines+1);let s=this.line(e).from;n=this.iterRange(s,Math.max(s,i==this.lines+1?this.length:i<=1?0:this.line(i-1).to))}return new Zj(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Qj.empty:e.length<=32?new Ui(e):xo.from(Ui.split(e,[]))}};class Ui extends Vt{constructor(e,i=DW(e)){super(),this.text=e,this.length=i}get lines(){return this.text.length}get children(){return null}lineInner(e,i,n,s){for(let r=0;;r++){let o=this.text[r],a=s+o.length;if((i?n:a)>=e)return new BW(s,a,n,o);s=a+1,n++}}decompose(e,i,n,s){let r=e<=0&&i>=this.length?this:new Ui(zE(this.text,e,i),Math.min(i,this.length)-Math.max(0,e));if(s&1){let o=n.pop(),a=Eg(r.text,o.text.slice(),0,r.length);if(a.length<=32)n.push(new Ui(a,o.length+r.length));else{let u=a.length>>1;n.push(new Ui(a.slice(0,u)),new Ui(a.slice(u)))}}else n.push(r)}replace(e,i,n){if(!(n instanceof Ui))return super.replace(e,i,n);[e,i]=fh(this,e,i);let s=Eg(this.text,Eg(n.text,zE(this.text,0,e)),i),r=this.length+n.length-(i-e);return s.length<=32?new Ui(s,r):xo.from(Ui.split(s,[]),r)}sliceString(e,i=this.length,n=`
|
|
49
|
+
`){[e,i]=fh(this,e,i);let s="";for(let r=0,o=0;r<=i&&o<this.text.length;o++){let a=this.text[o],u=r+a.length;r>e&&o&&(s+=n),e<u&&i>r&&(s+=a.slice(Math.max(0,e-r),i-r)),r=u+1}return s}flatten(e){for(let i of this.text)e.push(i)}scanIdentical(){return 0}static split(e,i){let n=[],s=-1;for(let r of e)n.push(r),s+=r.length+1,n.length==32&&(i.push(new Ui(n,s)),n=[],s=-1);return s>-1&&i.push(new Ui(n,s)),i}}class xo extends Vt{constructor(e,i){super(),this.children=e,this.length=i,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,i,n,s){for(let r=0;;r++){let o=this.children[r],a=s+o.length,u=n+o.lines-1;if((i?u:a)>=e)return o.lineInner(e,i,n,s);s=a+1,n=u+1}}decompose(e,i,n,s){for(let r=0,o=0;o<=i&&r<this.children.length;r++){let a=this.children[r],u=o+a.length;if(e<=u&&i>=o){let h=s&((o<=e?1:0)|(u>=i?2:0));o>=e&&u<=i&&!h?n.push(a):a.decompose(e-o,i-o,n,h)}o=u+1}}replace(e,i,n){if([e,i]=fh(this,e,i),n.lines<this.lines)for(let s=0,r=0;s<this.children.length;s++){let o=this.children[s],a=r+o.length;if(e>=r&&i<=a){let u=o.replace(e-r,i-r,n),h=this.lines-o.lines+u.lines;if(u.lines<h>>4&&u.lines>h>>6){let p=this.children.slice();return p[s]=u,new xo(p,this.length-(i-e)+n.length)}return super.replace(r,a,u)}r=a+1}return super.replace(e,i,n)}sliceString(e,i=this.length,n=`
|
|
50
|
+
`){[e,i]=fh(this,e,i);let s="";for(let r=0,o=0;r<this.children.length&&o<=i;r++){let a=this.children[r],u=o+a.length;o>e&&r&&(s+=n),e<u&&i>o&&(s+=a.sliceString(e-o,i-o,n)),o=u+1}return s}flatten(e){for(let i of this.children)i.flatten(e)}scanIdentical(e,i){if(!(e instanceof xo))return 0;let n=0,[s,r,o,a]=i>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=i,r+=i){if(s==o||r==a)return n;let u=this.children[s],h=e.children[r];if(u!=h)return n+u.scanIdentical(h,i);n+=u.length+1}}static from(e,i=e.reduce((n,s)=>n+s.length+1,-1)){let n=0;for(let _ of e)n+=_.lines;if(n<32){let _=[];for(let x of e)x.flatten(_);return new Ui(_,i)}let s=Math.max(32,n>>5),r=s<<1,o=s>>1,a=[],u=0,h=-1,p=[];function m(_){let x;if(_.lines>r&&_ instanceof xo)for(let S of _.children)m(S);else _.lines>o&&(u>o||!u)?(v(),a.push(_)):_ instanceof Ui&&u&&(x=p[p.length-1])instanceof Ui&&_.lines+x.lines<=32?(u+=_.lines,h+=_.length+1,p[p.length-1]=new Ui(x.text.concat(_.text),x.length+1+_.length)):(u+_.lines>s&&v(),u+=_.lines,h+=_.length+1,p.push(_))}function v(){u!=0&&(a.push(p.length==1?p[0]:xo.from(p,h)),h=-1,u=p.length=0)}for(let _ of e)m(_);return v(),a.length==1?a[0]:new xo(a,i)}}Vt.empty=new Ui([""],0);function DW(t){let e=-1;for(let i of t)e+=i.length+1;return e}function Eg(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let a=t[r],u=s+a.length;u>=i&&(u>n&&(a=a.slice(0,n-s)),s<i&&(a=a.slice(i-s)),o?(e[e.length-1]+=a,o=!1):e.push(a)),s=u+1}return e}function zE(t,e,i){return Eg(t,[""],e,i)}class _f{constructor(e,i=1){this.dir=i,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[i>0?1:(e instanceof Ui?e.text.length:e.children.length)<<1]}nextInner(e,i){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,s=this.nodes[n],r=this.offsets[n],o=r>>1,a=s instanceof Ui?s.text.length:s.children.length;if(o==(i>0?a:0)){if(n==0)return this.done=!0,this.value="",this;i>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(i>0?0:1)){if(this.offsets[n]+=i,e==0)return this.lineBreak=!0,this.value=`
|
|
51
|
+
`,this;e--}else if(s instanceof Ui){let u=s.text[o+(i<0?-1:0)];if(this.offsets[n]+=i,u.length>Math.max(0,e))return this.value=e==0?u:i>0?u.slice(e):u.slice(0,u.length-e),this;e-=u.length}else{let u=s.children[o+(i<0?-1:0)];e>u.length?(e-=u.length,this.offsets[n]+=i):(i<0&&this.offsets[n]--,this.nodes.push(u),this.offsets.push(i>0?1:(u instanceof Ui?u.text.length:u.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Xj{constructor(e,i,n){this.value="",this.done=!1,this.cursor=new _f(e,i>n?-1:1),this.pos=i>n?e.length:0,this.from=Math.min(i,n),this.to=Math.max(i,n)}nextInner(e,i){if(i<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,i<0?this.pos-this.to:this.from-this.pos);let n=i<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*i,this.value=s.length<=n?s:i<0?s.slice(s.length-n):s.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Zj{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:i,lineBreak:n,value:s}=this.inner.next(e);return i&&this.afterBreak?(this.value="",this.afterBreak=!1):i?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Vt.prototype[Symbol.iterator]=function(){return this.iter()},_f.prototype[Symbol.iterator]=Xj.prototype[Symbol.iterator]=Zj.prototype[Symbol.iterator]=function(){return this});class BW{constructor(e,i,n,s){this.from=e,this.to=i,this.number=n,this.text=s}get length(){return this.to-this.from}}function fh(t,e,i){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,i))]}function An(t,e,i=!0,n=!0){return jW(t,e,i,n)}function OW(t){return t>=56320&&t<57344}function IW(t){return t>=55296&&t<56320}function aS(t,e){let i=t.charCodeAt(e);if(!IW(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return OW(n)?(i-55296<<10)+(n-56320)+65536:i}function PW(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function Jj(t){return t<65536?1:2}const kx=/\r\n?|\n/;var rr=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(rr||(rr={}));class Ao{constructor(e){this.sections=e}get length(){let e=0;for(let i=0;i<this.sections.length;i+=2)e+=this.sections[i];return e}get newLength(){let e=0;for(let i=0;i<this.sections.length;i+=2){let n=this.sections[i+1];e+=n<0?this.sections[i]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let i=0,n=0,s=0;i<this.sections.length;){let r=this.sections[i++],o=this.sections[i++];o<0?(e(n,s,r),s+=r):s+=o,n+=r}}iterChangedRanges(e,i=!1){Cx(this,e,i)}get invertedDesc(){let e=[];for(let i=0;i<this.sections.length;){let n=this.sections[i++],s=this.sections[i++];s<0?e.push(n,s):e.push(s,n)}return new Ao(e)}composeDesc(e){return this.empty?e:e.empty?this:e3(this,e)}mapDesc(e,i=!1){return e.empty?this:Ex(this,e,i)}mapPos(e,i=-1,n=rr.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let a=this.sections[o++],u=this.sections[o++],h=s+a;if(u<0){if(h>e)return r+(e-s);r+=a}else{if(n!=rr.Simple&&h>=e&&(n==rr.TrackDel&&s<e&&h>e||n==rr.TrackBefore&&s<e||n==rr.TrackAfter&&h>e))return null;if(h>e||h==e&&i<0&&!a)return e==s||i<0?r:r+u;r+=u}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,i=e){for(let n=0,s=0;n<this.sections.length&&s<=i;){let r=this.sections[n++],o=this.sections[n++],a=s+r;if(o>=0&&s<=i&&a>=e)return s<e&&a>i?"cover":!0;s=a}return!1}toString(){let e="";for(let i=0;i<this.sections.length;){let n=this.sections[i++],s=this.sections[i++];e+=(e?" ":"")+n+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(i=>typeof i!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ao(e)}static create(e){return new Ao(e)}}class fn extends Ao{constructor(e,i){super(e),this.inserted=i}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Cx(this,(i,n,s,r,o)=>e=e.replace(s,s+(n-i),o),!1),e}mapDesc(e,i=!1){return Ex(this,e,i,!0)}invert(e){let i=this.sections.slice(),n=[];for(let s=0,r=0;s<i.length;s+=2){let o=i[s],a=i[s+1];if(a>=0){i[s]=a,i[s+1]=o;let u=s>>1;for(;n.length<u;)n.push(Vt.empty);n.push(o?e.slice(r,r+o):Vt.empty)}r+=o}return new fn(i,n)}compose(e){return this.empty?e:e.empty?this:e3(this,e,!0)}map(e,i=!1){return e.empty?this:Ex(this,e,i,!0)}iterChanges(e,i=!1){Cx(this,e,i)}get desc(){return Ao.create(this.sections)}filter(e){let i=[],n=[],s=[],r=new Mf(this);e:for(let o=0,a=0;;){let u=o==e.length?1e9:e[o++];for(;a<u||a==u&&r.len==0;){if(r.done)break e;let p=Math.min(r.len,u-a);Yn(s,p,-1);let m=r.ins==-1?-1:r.off==0?r.ins:0;Yn(i,p,m),m>0&&Ca(n,i,r.text),r.forward(p),a+=p}let h=e[o++];for(;a<h;){if(r.done)break e;let p=Math.min(r.len,h-a);Yn(i,p,-1),Yn(s,p,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(p),a+=p}}return{changes:new fn(i,n),filtered:Ao.create(s)}}toJSON(){let e=[];for(let i=0;i<this.sections.length;i+=2){let n=this.sections[i],s=this.sections[i+1];s<0?e.push(n):s==0?e.push([n]):e.push([n].concat(this.inserted[i>>1].toJSON()))}return e}static of(e,i,n){let s=[],r=[],o=0,a=null;function u(p=!1){if(!p&&!s.length)return;o<i&&Yn(s,i-o,-1);let m=new fn(s,r);a=a?a.compose(m.map(a)):m,s=[],r=[],o=0}function h(p){if(Array.isArray(p))for(let m of p)h(m);else if(p instanceof fn){if(p.length!=i)throw new RangeError(`Mismatched change set length (got ${p.length}, expected ${i})`);u(),a=a?a.compose(p.map(a)):p}else{let{from:m,to:v=m,insert:_}=p;if(m>v||m<0||v>i)throw new RangeError(`Invalid change range ${m} to ${v} (in doc of length ${i})`);let x=_?typeof _=="string"?Vt.of(_.split(n||kx)):_:Vt.empty,S=x.length;if(m==v&&S==0)return;m<o&&u(),m>o&&Yn(s,m-o,-1),Yn(s,v-m,S),Ca(r,s,x),o=v}}return h(e),u(!a),a}static empty(e){return new fn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let i=[],n=[];for(let s=0;s<e.length;s++){let r=e[s];if(typeof r=="number")i.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,a)=>a&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)i.push(r[0],0);else{for(;n.length<s;)n.push(Vt.empty);n[s]=Vt.of(r.slice(1)),i.push(r[0],n[s].length)}}}return new fn(i,n)}static createSet(e,i){return new fn(e,i)}}function Yn(t,e,i,n=!1){if(e==0&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function Ca(t,e,i){if(i.length==0)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(Vt.empty);t.push(i)}}function Cx(t,e,i){let n=t.inserted;for(let s=0,r=0,o=0;o<t.sections.length;){let a=t.sections[o++],u=t.sections[o++];if(u<0)s+=a,r+=a;else{let h=s,p=r,m=Vt.empty;for(;h+=a,p+=u,u&&n&&(m=m.append(n[o-2>>1])),!(i||o==t.sections.length||t.sections[o+1]<0);)a=t.sections[o++],u=t.sections[o++];e(s,h,r,p,m),s=h,r=p}}}function Ex(t,e,i,n=!1){let s=[],r=n?[]:null,o=new Mf(t),a=new Mf(e);for(let u=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let h=Math.min(o.len,a.len);Yn(s,h,-1),o.forward(h),a.forward(h)}else if(a.ins>=0&&(o.ins<0||u==o.i||o.off==0&&(a.len<o.len||a.len==o.len&&!i))){let h=a.len;for(Yn(s,a.ins,-1);h;){let p=Math.min(o.len,h);o.ins>=0&&u<o.i&&o.len<=p&&(Yn(s,0,o.ins),r&&Ca(r,s,o.text),u=o.i),o.forward(p),h-=p}a.next()}else if(o.ins>=0){let h=0,p=o.len;for(;p;)if(a.ins==-1){let m=Math.min(p,a.len);h+=m,p-=m,a.forward(m)}else if(a.ins==0&&a.len<p)p-=a.len,a.next();else break;Yn(s,h,u<o.i?o.ins:0),r&&u<o.i&&Ca(r,s,o.text),u=o.i,o.forward(o.len-p)}else{if(o.done&&a.done)return r?fn.createSet(s,r):Ao.create(s);throw new Error("Mismatched change set lengths")}}}function e3(t,e,i=!1){let n=[],s=i?[]:null,r=new Mf(t),o=new Mf(e);for(let a=!1;;){if(r.done&&o.done)return s?fn.createSet(n,s):Ao.create(n);if(r.ins==0)Yn(n,r.len,0,a),r.next();else if(o.len==0&&!o.done)Yn(n,0,o.ins,a),s&&Ca(s,n,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let u=Math.min(r.len2,o.len),h=n.length;if(r.ins==-1){let p=o.ins==-1?-1:o.off?0:o.ins;Yn(n,u,p,a),s&&p&&Ca(s,n,o.text)}else o.ins==-1?(Yn(n,r.off?0:r.len,u,a),s&&Ca(s,n,r.textBit(u))):(Yn(n,r.off?0:r.len,o.off?0:o.ins,a),s&&!o.off&&Ca(s,n,o.text));a=(r.ins>u||o.ins>=0&&o.len>u)&&(a||n.length>h),r.forward2(u),o.forward(u)}}}}class Mf{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length?Vt.empty:e[i]}textBit(e){let{inserted:i}=this.set,n=this.i-2>>1;return n>=i.length&&!e?Vt.empty:i[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class wa{constructor(e,i,n,s){this.from=e,this.to=i,this.flags=n,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,i=-1){let n,s;return this.empty?n=s=e.mapPos(this.from,i):(n=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),n==this.from&&s==this.to?this:new wa(n,s,this.flags,this.goalColumn)}extend(e,i=e,n=0){if(e<=this.anchor&&i>=this.anchor)return Se.range(e,i,void 0,void 0,n);let s=Math.abs(e-this.anchor)>Math.abs(i-this.anchor)?e:i;return Se.range(this.anchor,s,void 0,void 0,n)}eq(e,i=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!i||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Se.range(e.anchor,e.head)}static create(e,i,n,s){return new wa(e,i,n,s)}}class Se{constructor(e,i){this.ranges=e,this.mainIndex=i}map(e,i=-1){return e.empty?this:Se.create(this.ranges.map(n=>n.map(e,i)),this.mainIndex)}eq(e,i=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],i))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new Se([this.main],0)}addRange(e,i=!0){return Se.create([e].concat(this.ranges),i?0:this.mainIndex+1)}replaceRange(e,i=this.mainIndex){let n=this.ranges.slice();return n[i]=e,Se.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Se(e.ranges.map(i=>wa.fromJSON(i)),e.main)}static single(e,i=e){return new Se([Se.range(e,i)],0)}static create(e,i=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,s=0;s<e.length;s++){let r=e[s];if(r.empty?r.from<=n:r.from<n)return Se.normalized(e.slice(),i);n=r.to}return new Se(e,i)}static cursor(e,i=0,n,s){return wa.create(e,e,(i==0?0:i<0?8:16)|(n==null?7:Math.min(6,n)),s)}static range(e,i,n,s,r){let o=s==null?7:Math.min(6,s);return!r&&e!=i&&(r=i<e?1:-1),r&&(o|=r<0?8:16),i<e?wa.create(i,e,o|32,n):wa.create(e,i,o,n)}static undirectionalRange(e,i){return wa.create(e,i,64,void 0)}static normalized(e,i=0){let n=e[i];e.sort((s,r)=>s.from-r.from),i=e.indexOf(n);for(let s=1;s<e.length;s++){let r=e[s],o=e[s-1];if(r.empty?r.from<=o.to:r.from<o.to){let a=o.from,u=Math.max(r.to,o.to);s<=i&&i--,e.splice(--s,2,r.anchor>r.head?Se.range(u,a):Se.range(a,u))}}return new Se(e,i)}}function t3(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let cS=0;class Fe{constructor(e,i,n,s,r){this.combine=e,this.compareInput=i,this.compare=n,this.isStatic=s,this.id=cS++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new Fe(e.combine||(i=>i),e.compareInput||((i,n)=>i===n),e.compare||(e.combine?(i,n)=>i===n:uS),!!e.static,e.enables)}of(e){return new Mg([],this,0,e)}compute(e,i){if(this.isStatic)throw new Error("Can't compute a static facet");return new Mg(e,this,1,i)}computeN(e,i){if(this.isStatic)throw new Error("Can't compute a static facet");return new Mg(e,this,2,i)}from(e,i){return i||(i=n=>n),this.compute([e],n=>i(n.field(e)))}}function uS(t,e){return t==e||t.length==e.length&&t.every((i,n)=>i===e[n])}class Mg{constructor(e,i,n,s){this.dependencies=e,this.facet=i,this.type=n,this.value=s,this.id=cS++}dynamicSlot(e){var i;let n=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,a=this.type==2,u=!1,h=!1,p=[];for(let m of this.dependencies)m=="doc"?u=!0:m=="selection"?h=!0:(((i=e[m.id])!==null&&i!==void 0?i:1)&1)==0&&p.push(e[m.id]);return{create(m){return m.values[o]=n(m),1},update(m,v){if(u&&v.docChanged||h&&(v.docChanged||v.selection)||Mx(m,p)){let _=n(m);if(a?!$E(_,m.values[o],s):!s(_,m.values[o]))return m.values[o]=_,1}return 0},reconfigure:(m,v)=>{let _,x=v.config.address[r];if(x!=null){let S=d0(v,x);if(this.dependencies.every(C=>C instanceof Fe?v.facet(C)===m.facet(C):C instanceof Bo?v.field(C,!1)==m.field(C,!1):!0)||(a?$E(_=n(m),S,s):s(_=n(m),S)))return m.values[o]=S,0}else _=n(m);return m.values[o]=_,1}}}get extension(){return this}}function $E(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function Mx(t,e){let i=!1;for(let n of e)yf(t,n)&1&&(i=!0);return i}function zW(t,e,i){let n=i.map(u=>t[u.id]),s=i.map(u=>u.type),r=n.filter(u=>!(u&1)),o=t[e.id]>>1;function a(u){let h=[];for(let p=0;p<n.length;p++){let m=d0(u,n[p]);if(s[p]==2)for(let v of m)h.push(v);else h.push(m)}return e.combine(h)}return{create(u){for(let h of n)yf(u,h);return u.values[o]=a(u),1},update(u,h){if(!Mx(u,r))return 0;let p=a(u);return e.compare(p,u.values[o])?0:(u.values[o]=p,1)},reconfigure(u,h){let p=Mx(u,n),m=h.config.facets[e.id],v=h.facet(e);if(m&&!p&&uS(i,m))return u.values[o]=v,0;let _=a(u);return e.compare(_,v)?(u.values[o]=v,0):(u.values[o]=_,1)}}}const Pm=Fe.define({static:!0});class Bo{constructor(e,i,n,s,r){this.id=e,this.createF=i,this.updateF=n,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let i=new Bo(cS++,e.create,e.update,e.compare||((n,s)=>n===s),e);return e.provide&&(i.provides=e.provide(i)),i}create(e){let i=e.facet(Pm).find(n=>n.field==this);return(i?.create||this.createF)(e)}slot(e){let i=e[this.id]>>1;return{create:n=>(n.values[i]=this.create(n),1),update:(n,s)=>{let r=n.values[i],o=this.updateF(r,s);return this.compareF(r,o)?0:(n.values[i]=o,1)},reconfigure:(n,s)=>{let r=n.facet(Pm),o=s.facet(Pm),a;return(a=r.find(u=>u.field==this))&&a!=o.find(u=>u.field==this)?(n.values[i]=a.create(n),1):s.config.address[this.id]!=null?(n.values[i]=s.field(this),0):(n.values[i]=this.create(n),1)}}}init(e){return[this,Pm.of({field:this,create:e})]}get extension(){return this}}const gc={lowest:4,low:3,default:2,high:1,highest:0};function Pd(t){return e=>new i3(e,t)}const Qf={highest:Pd(gc.highest),high:Pd(gc.high),default:Pd(gc.default),low:Pd(gc.low),lowest:Pd(gc.lowest)};class i3{constructor(e,i){this.inner=e,this.prec=i}get extension(){return this}}class Xf{of(e){return new Ax(this,e)}reconfigure(e){return Xf.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Ax{constructor(e,i){this.compartment=e,this.inner=i}get extension(){return this}}class h0{constructor(e,i,n,s,r,o){for(this.base=e,this.compartments=i,this.dynamicSlots=n,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let i=this.address[e.id];return i==null?e.default:this.staticValues[i>>1]}static resolve(e,i,n){let s=[],r=Object.create(null),o=new Map;for(let v of $W(e,i,o))v instanceof Bo?s.push(v):(r[v.facet.id]||(r[v.facet.id]=[])).push(v);let a=Object.create(null),u=[],h=[];for(let v of s)a[v.id]=h.length<<1,h.push(_=>v.slot(_));let p=n?.config.facets;for(let v in r){let _=r[v],x=_[0].facet,S=p&&p[v]||[];if(_.every(C=>C.type==0))if(a[x.id]=u.length<<1|1,uS(S,_))u.push(n.facet(x));else{let C=x.combine(_.map(k=>k.value));u.push(n&&x.compare(C,n.facet(x))?n.facet(x):C)}else{for(let C of _)C.type==0?(a[C.id]=u.length<<1|1,u.push(C.value)):(a[C.id]=h.length<<1,h.push(k=>C.dynamicSlot(k)));a[x.id]=h.length<<1,h.push(C=>zW(C,x,_))}}let m=h.map(v=>v(a));return new h0(e,o,m,a,u,r)}}function $W(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(o,a){let u=s.get(o);if(u!=null){if(u<=a)return;let h=n[u].indexOf(o);h>-1&&n[u].splice(h,1),o instanceof Ax&&i.delete(o.compartment)}if(s.set(o,a),Array.isArray(o))for(let h of o)r(h,a);else if(o instanceof Ax){if(i.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;i.set(o.compartment,h),r(h,a)}else if(o instanceof i3)r(o.inner,o.prec);else if(o instanceof Bo)n[a].push(o),o.provides&&r(o.provides,a);else if(o instanceof Mg)n[a].push(o),o.facet.extensions&&r(o.facet.extensions,gc.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(h==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,a)}}return r(t,gc.default),n.reduce((o,a)=>o.concat(a))}function yf(t,e){if(e&1)return 2;let i=e>>1,n=t.status[i];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function d0(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const n3=Fe.define(),Lx=Fe.define({combine:t=>t.some(e=>e),static:!0}),s3=Fe.define({combine:t=>t.length?t[0]:void 0,static:!0}),r3=Fe.define(),o3=Fe.define(),l3=Fe.define(),a3=Fe.define({combine:t=>t.length?t[0]:!1});class Ba{constructor(e,i){this.type=e,this.value=i}static define(){return new FW}}class FW{of(e){return new Ba(this,e)}}class HW{constructor(e){this.map=e}of(e){return new ci(this,e)}}class ci{constructor(e,i){this.type=e,this.value=i}map(e){let i=this.type.map(this.value,e);return i===void 0?void 0:i==this.value?this:new ci(this.type,i)}is(e){return this.type==e}static define(e={}){return new HW(e.map||(i=>i))}static mapEffects(e,i){if(!e.length)return e;let n=[];for(let s of e){let r=s.map(i);r&&n.push(r)}return n}}ci.reconfigure=ci.define();ci.appendConfig=ci.define();class pn{constructor(e,i,n,s,r,o){this.startState=e,this.changes=i,this.selection=n,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,n&&t3(n,i.newLength),r.some(a=>a.type==pn.time)||(this.annotations=r.concat(pn.time.of(Date.now())))}static create(e,i,n,s,r,o){return new pn(e,i,n,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let i of this.annotations)if(i.type==e)return i.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let i=this.annotation(pn.userEvent);return!!(i&&(i==e||i.length>e.length&&i.slice(0,e.length)==e&&i[e.length]=="."))}}pn.time=Ba.define();pn.userEvent=Ba.define();pn.addToHistory=Ba.define();pn.remote=Ba.define();function WW(t,e){let i=[];for(let n=0,s=0;;){let r,o;if(n<t.length&&(s==e.length||e[s]>=t[n]))r=t[n++],o=t[n++];else if(s<e.length)r=e[s++],o=e[s++];else return i;!i.length||i[i.length-1]<r?i.push(r,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function c3(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=fn.empty(e.changes.length),o=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):(n=t.selection)===null||n===void 0?void 0:n.map(s),effects:ci.mapEffects(t.effects,s).concat(ci.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Tx(t,e,i){let n=e.selection,s=ih(e.annotations);return e.userEvent&&(s=s.concat(pn.userEvent.of(e.userEvent))),{changes:e.changes instanceof fn?e.changes:fn.of(e.changes||[],i,t.facet(s3)),selection:n&&(n instanceof Se?n:Se.single(n.anchor,n.head)),effects:ih(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function u3(t,e,i){let n=Tx(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(i=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(i=!1);let o=!!e[r].sequential;n=c3(n,Tx(t,e[r],o?n.changes.newLength:t.doc.length),o)}let s=pn.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return UW(i?qW(s):s)}function qW(t){let e=t.startState,i=!0;for(let s of e.facet(r3)){let r=s(t);if(r===!1){i=!1;break}Array.isArray(r)&&(i=i===!0?r:WW(i,r))}if(i!==!0){let s,r;if(i===!1)r=t.changes.invertedDesc,s=fn.empty(e.doc.length);else{let o=t.changes.filter(i);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}t=pn.create(e,s,t.selection&&t.selection.map(r),ci.mapEffects(t.effects,r),t.annotations,t.scrollIntoView)}let n=e.facet(o3);for(let s=n.length-1;s>=0;s--){let r=n[s](t);r instanceof pn?t=r:Array.isArray(r)&&r.length==1&&r[0]instanceof pn?t=r[0]:t=u3(e,ih(r),!1)}return t}function UW(t){let e=t.startState,i=e.facet(l3),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=c3(n,Tx(e,r,t.changes.newLength),!0))}return n==t?t:pn.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}const VW=[];function ih(t){return t==null?VW:Array.isArray(t)?t:[t]}var Ki=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(Ki||(Ki={}));const KW=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Nx;try{Nx=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function YW(t){if(Nx)return Nx.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||KW.test(i)))return!0}return!1}function GW(t){return e=>{if(!/\S/.test(e))return Ki.Space;if(YW(e))return Ki.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return Ki.Word;return Ki.Other}}class It{constructor(e,i,n,s,r,o){this.config=e,this.doc=i,this.selection=n,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)yf(this,a<<1);this.computeSlot=null}field(e,i=!0){let n=this.config.address[e.id];if(n==null){if(i)throw new RangeError("Field is not present in this state");return}return yf(this,n),d0(this,n)}update(...e){return u3(this,e,!0)}applyTransaction(e){let i=this.config,{base:n,compartments:s}=i;for(let a of e.effects)a.is(Xf.reconfigure)?(i&&(s=new Map,i.compartments.forEach((u,h)=>s.set(h,u)),i=null),s.set(a.value.compartment,a.value.extension)):a.is(ci.reconfigure)?(i=null,n=a.value):a.is(ci.appendConfig)&&(i=null,n=ih(n).concat(a.value));let r;i?r=e.startState.values.slice():(i=h0.resolve(n,s,this),r=new It(i,this.doc,this.selection,i.dynamicSlots.map(()=>null),(u,h)=>h.reconfigure(u,this),null).values);let o=e.startState.facet(Lx)?e.newSelection:e.newSelection.asSingle();new It(i,e.newDoc,o,r,(a,u)=>u.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:e},range:Se.cursor(i.from+e.length)}))}changeByRange(e){let i=this.selection,n=e(i.ranges[0]),s=this.changes(n.changes),r=[n.range],o=ih(n.effects);for(let a=1;a<i.ranges.length;a++){let u=e(i.ranges[a]),h=this.changes(u.changes),p=h.map(s);for(let v=0;v<a;v++)r[v]=r[v].map(p);let m=s.mapDesc(h,!0);r.push(u.range.map(m)),s=s.compose(p),o=ci.mapEffects(o,p).concat(ci.mapEffects(ih(u.effects),m))}return{changes:s,selection:Se.create(r,i.mainIndex),effects:o}}changes(e=[]){return e instanceof fn?e:fn.of(e,this.doc.length,this.facet(It.lineSeparator))}toText(e){return Vt.of(e.split(this.facet(It.lineSeparator)||kx))}sliceDoc(e=0,i=this.doc.length){return this.doc.sliceString(e,i,this.lineBreak)}facet(e){let i=this.config.address[e.id];return i==null?e.default:(yf(this,i),d0(this,i))}toJSON(e){let i={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let s=e[n];s instanceof Bo&&this.config.address[s.id]!=null&&(i[n]=s.spec.toJSON(this.field(e[n]),this))}return i}static fromJSON(e,i={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(n){for(let r in n)if(Object.prototype.hasOwnProperty.call(e,r)){let o=n[r],a=e[r];s.push(o.init(u=>o.spec.fromJSON(a,u)))}}return It.create({doc:e.doc,selection:Se.fromJSON(e.selection),extensions:i.extensions?s.concat([i.extensions]):s})}static create(e={}){let i=h0.resolve(e.extensions||[],new Map),n=e.doc instanceof Vt?e.doc:Vt.of((e.doc||"").split(i.staticFacet(It.lineSeparator)||kx)),s=e.selection?e.selection instanceof Se?e.selection:Se.single(e.selection.anchor,e.selection.head):Se.single(0);return t3(s,n.length),i.staticFacet(Lx)||(s=s.asSingle()),new It(i,n,s,i.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(It.tabSize)}get lineBreak(){return this.facet(It.lineSeparator)||`
|
|
52
|
+
`}get readOnly(){return this.facet(a3)}phrase(e,...i){for(let n of this.facet(It.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return i.length&&(e=e.replace(/\$(\$|\d*)/g,(n,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>i.length?n:i[r-1]})),e}languageDataAt(e,i,n=-1){let s=[];for(let r of this.facet(n3))for(let o of r(this,i,n))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){let i=this.languageDataAt("wordChars",e);return GW(i.length?i[0]:"")}wordAt(e){let{text:i,from:n,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-n,a=e-n;for(;o>0;){let u=An(i,o,!1);if(r(i.slice(u,o))!=Ki.Word)break;o=u}for(;a<s;){let u=An(i,a);if(r(i.slice(a,u))!=Ki.Word)break;a=u}return o==a?null:Se.range(o+n,a+n)}}It.allowMultipleSelections=Lx;It.tabSize=Fe.define({combine:t=>t.length?t[0]:4});It.lineSeparator=s3;It.readOnly=a3;It.phrases=Fe.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every(s=>t[s]==e[s])}});It.languageData=n3;It.changeFilter=r3;It.transactionFilter=o3;It.transactionExtender=l3;Xf.reconfigure=ci.define();function Fc(t,e,i={}){let n={};for(let s of t)for(let r of Object.keys(s)){let o=s[r],a=n[r];if(a===void 0)n[r]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(i,r))n[r]=i[r](a,o);else throw new Error("Config merge conflict for field "+r)}for(let s in e)n[s]===void 0&&(n[s]=e[s]);return n}class jc{eq(e){return this==e}range(e,i=e){return jx.create(e,i,this)}}jc.prototype.startSide=jc.prototype.endSide=0;jc.prototype.point=!1;jc.prototype.mapMode=rr.TrackDel;function hS(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let jx=class h3{constructor(e,i,n){this.from=e,this.to=i,this.value=n}static create(e,i,n){return new h3(e,i,n)}};function Rx(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class dS{constructor(e,i,n,s){this.from=e,this.to=i,this.value=n,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,i,n,s=0){let r=n?this.to:this.from;for(let o=s,a=r.length;;){if(o==a)return o;let u=o+a>>1,h=r[u]-e||(n?this.value[u].endSide:this.value[u].startSide)-i;if(u==o)return h>=0?o:a;h>=0?a=u:o=u+1}}between(e,i,n,s){for(let r=this.findIndex(i,-1e9,!0),o=this.findIndex(n,1e9,!1,r);r<o;r++)if(s(this.from[r]+e,this.to[r]+e,this.value[r])===!1)return!1}map(e,i){let n=[],s=[],r=[],o=-1,a=-1;for(let u=0;u<this.value.length;u++){let h=this.value[u],p=this.from[u]+e,m=this.to[u]+e,v,_;if(p==m){let x=i.mapPos(p,h.startSide,h.mapMode);if(x==null||(v=_=x,h.startSide!=h.endSide&&(_=i.mapPos(p,h.endSide),_<v)))continue}else if(v=i.mapPos(p,h.startSide),_=i.mapPos(m,h.endSide),v>_||v==_&&h.startSide>0&&h.endSide<=0)continue;(_-v||h.endSide-h.startSide)<0||(o<0&&(o=v),h.point&&(a=Math.max(a,_-v)),n.push(h),s.push(v-o),r.push(_-o))}return{mapped:n.length?new dS(s,r,n,a):null,pos:o}}}class Rt{constructor(e,i,n,s){this.chunkPos=e,this.chunk=i,this.nextLayer=n,this.maxPoint=s}static create(e,i,n,s){return new Rt(e,i,n,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let i of this.chunk)e+=i.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:i=[],sort:n=!1,filterFrom:s=0,filterTo:r=this.length}=e,o=e.filter;if(i.length==0&&!o)return this;if(n&&(i=i.slice().sort(Rx)),this.isEmpty)return i.length?Rt.of(i):this;let a=new d3(this,null,-1).goto(0),u=0,h=[],p=new Rc;for(;a.value||u<i.length;)if(u<i.length&&(a.from-i[u].from||a.startSide-i[u].value.startSide)>=0){let m=i[u++];p.addInner(m.from,m.to,m.value)||h.push(m)}else a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(u==i.length||this.chunkEnd(a.chunkIndex)<i[u].from)&&(!o||s>this.chunkEnd(a.chunkIndex)||r<this.chunkPos[a.chunkIndex])&&p.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!o||s>a.to||r<a.from||o(a.from,a.to,a.value))&&(p.addInner(a.from,a.to,a.value)||h.push(jx.create(a.from,a.to,a.value))),a.next());return p.finishInner(this.nextLayer.isEmpty&&!h.length?Rt.empty:this.nextLayer.update({add:h,filter:o,filterFrom:s,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let i=[],n=[],s=-1;for(let o=0;o<this.chunk.length;o++){let a=this.chunkPos[o],u=this.chunk[o],h=e.touchesRange(a,a+u.length);if(h===!1)s=Math.max(s,u.maxPoint),i.push(u),n.push(e.mapPos(a));else if(h===!0){let{mapped:p,pos:m}=u.map(a,e);p&&(s=Math.max(s,p.maxPoint),i.push(p),n.push(m))}}let r=this.nextLayer.map(e);return i.length==0?r:new Rt(n,i,r||Rt.empty,s)}between(e,i,n){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s];if(i>=r&&e<=r+o.length&&o.between(r,e-r,i-r,n)===!1)return}this.nextLayer.between(e,i,n)}}iter(e=0){return Af.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,i=0){return Af.from(e).goto(i)}static compare(e,i,n,s,r=-1){let o=e.filter(m=>m.maxPoint>0||!m.isEmpty&&m.maxPoint>=r),a=i.filter(m=>m.maxPoint>0||!m.isEmpty&&m.maxPoint>=r),u=FE(o,a,n),h=new zd(o,u,r),p=new zd(a,u,r);n.iterGaps((m,v,_)=>HE(h,m,p,v,_,s)),n.empty&&n.length==0&&HE(h,0,p,0,0,s)}static eq(e,i,n=0,s){s==null&&(s=999999999);let r=e.filter(p=>!p.isEmpty&&i.indexOf(p)<0),o=i.filter(p=>!p.isEmpty&&e.indexOf(p)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let a=FE(r,o),u=new zd(r,a,0).goto(n),h=new zd(o,a,0).goto(n);for(;;){if(u.to!=h.to||!Dx(u.active,h.active)||u.point&&(!h.point||!hS(u.point,h.point)))return!1;if(u.to>s)return!0;u.next(),h.next()}}static spans(e,i,n,s,r=-1){let o=new zd(e,null,r).goto(i),a=i,u=o.openStart;for(;;){let h=Math.min(o.to,n);if(o.point){let p=o.activeForPoint(o.to),m=o.pointFrom<i?p.length+1:o.point.startSide<0?p.length:Math.min(p.length,u);s.point(a,h,o.point,p,m,o.pointRank),u=Math.min(o.openEnd(h),p.length)}else h>a&&(s.span(a,h,o.active,u),u=o.openEnd(h));if(o.to>n)return u+(o.point&&o.to>n?1:0);a=o.to,o.next()}}static of(e,i=!1){let n=new Rc;for(let s of e instanceof jx?[e]:i?QW(e):e)n.add(s.from,s.to,s.value);return n.finish()}static join(e){if(!e.length)return Rt.empty;let i=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let s=e[n];s!=Rt.empty;s=s.nextLayer)i=new Rt(s.chunkPos,s.chunk,i,Math.max(s.maxPoint,i.maxPoint));return i}}Rt.empty=new Rt([],[],null,-1);function QW(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Rx(e,n)>0)return t.slice().sort(Rx);e=n}return t}Rt.empty.nextLayer=Rt.empty;class Rc{finishChunk(e){this.chunks.push(new dS(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,i,n){this.addInner(e,i,n)||(this.nextLayer||(this.nextLayer=new Rc)).add(e,i,n)}addInner(e,i,n){let s=e-this.lastTo||n.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(i-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=i,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,i-e)),!0)}addChunk(e,i){if((e-this.lastTo||i.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,i.maxPoint),this.chunks.push(i),this.chunkPos.push(e);let n=i.value.length-1;return this.last=i.value[n],this.lastFrom=i.from[n]+e,this.lastTo=i.to[n]+e,!0}finish(){return this.finishInner(Rt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let i=Rt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,i}}function FE(t,e,i){let n=new Map;for(let r of t)for(let o=0;o<r.chunk.length;o++)r.chunk[o].maxPoint<=0&&n.set(r.chunk[o],r.chunkPos[o]);let s=new Set;for(let r of e)for(let o=0;o<r.chunk.length;o++){let a=n.get(r.chunk[o]);a!=null&&(i?i.mapPos(a):a)==r.chunkPos[o]&&!i?.touchesRange(a,a+r.chunk[o].length)&&s.add(r.chunk[o])}return s}class d3{constructor(e,i,n,s=0){this.layer=e,this.skip=i,this.minPoint=n,this.rank=s}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,i=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,i,!1),this}gotoInner(e,i,n){for(;this.chunkIndex<this.layer.chunk.length;){let s=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(s)||this.layer.chunkEnd(this.chunkIndex)<e||s.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let s=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],i,!0);(!n||this.rangeIndex<s)&&this.setRangeIndex(s)}this.next()}forward(e,i){(this.to-e||this.endSide-i)<0&&this.gotoInner(e,i,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],i=this.layer.chunk[this.chunkIndex],n=e+i.from[this.rangeIndex];if(this.from=n,this.to=e+i.to[this.rangeIndex],this.value=i.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Af{constructor(e){this.heap=e}static from(e,i=null,n=-1){let s=[];for(let r=0;r<e.length;r++)for(let o=e[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&s.push(new d3(o,i,n,r));return s.length==1?s[0]:new Af(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,i=-1e9){for(let n of this.heap)n.goto(e,i);for(let n=this.heap.length>>1;n>=0;n--)V1(this.heap,n);return this.next(),this}forward(e,i){for(let n of this.heap)n.forward(e,i);for(let n=this.heap.length>>1;n>=0;n--)V1(this.heap,n);(this.to-e||this.value.endSide-i)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),V1(this.heap,0)}}}function V1(t,e){for(let i=t[e];;){let n=(e<<1)+1;if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class zd{constructor(e,i,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Af.from(e,i,n)}goto(e,i=-1e9){return this.cursor.goto(e,i),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=i,this.openStart=-1,this.next(),this}forward(e,i){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-i)<0;)this.removeActive(this.minActive);this.cursor.forward(e,i)}removeActive(e){zm(this.active,e),zm(this.activeTo,e),zm(this.activeRank,e),this.minActive=WE(this.active,this.activeTo)}addActive(e){let i=0,{value:n,to:s,rank:r}=this.cursor;for(;i<this.activeRank.length&&(r-this.activeRank[i]||s-this.activeTo[i])>0;)i++;$m(this.active,i,n),$m(this.activeTo,i,s),$m(this.activeRank,i,r),e&&$m(e,i,this.cursor.from),this.minActive=WE(this.active,this.activeTo)}next(){let e=this.to,i=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),n&&zm(n,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(n),this.cursor.next();else if(i&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=r,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=r.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let s=n.length-1;s>=0&&n[s]<e;s--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let i=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&i.push(this.active[n]);return i.reverse()}openEnd(e){let i=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)i++;return i}}function HE(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,a=n,u=n-e,h=!!r.boundChange;for(let p=!1;;){let m=t.to+u-i.to,v=m||t.endSide-i.endSide,_=v<0?t.to+u:i.to,x=Math.min(_,o);if(t.point||i.point?(t.point&&i.point&&hS(t.point,i.point)&&Dx(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(a,x,t.point,i.point),p=!1):(p&&r.boundChange(a),x>a&&!Dx(t.active,i.active)&&r.compareRange(a,x,t.active,i.active),h&&x<o&&(m||t.openEnd(_)!=i.openEnd(_))&&(p=!0)),_>o)break;a=_,v<=0&&t.next(),v>=0&&i.next()}}function Dx(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!hS(t[i],e[i]))return!1;return!0}function zm(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function $m(t,e,i){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=i}function WE(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}function Ah(t,e,i=t.length){let n=0;for(let s=0;s<i&&s<t.length;)t.charCodeAt(s)==9?(n+=e-n%e,s++):(n++,s=An(t,s));return n}function Bx(t,e,i,n){for(let s=0,r=0;;){if(r>=e)return s;if(s==t.length)break;r+=t.charCodeAt(s)==9?i-r%i:1,s=An(t,s)}return n===!0?-1:t.length}const Ox="ͼ",qE=typeof Symbol>"u"?"__"+Ox:Symbol.for(Ox),Ix=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),UE=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class La{constructor(e,i){this.rules=[];let{finish:n}=i||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,a,u,h){let p=[],m=/^@(\w+)\b/.exec(o[0]),v=m&&m[1]=="keyframes";if(m&&a==null)return u.push(o[0]+";");for(let _ in a){let x=a[_];if(/&/.test(_))r(_.split(/,\s*/).map(S=>o.map(C=>S.replace(/&/,C))).reduce((S,C)=>S.concat(C)),x,u);else if(x&&typeof x=="object"){if(!m)throw new RangeError("The value of a property ("+_+") should be a primitive value.");r(s(_),x,p,v)}else x!=null&&p.push(_.replace(/_.*/,"").replace(/[A-Z]/g,S=>"-"+S.toLowerCase())+": "+x+";")}(p.length||v)&&u.push((n&&!m&&!h?o.map(n):o).join(", ")+" {"+p.join(" ")+"}")}for(let o in e)r(s(o),e[o],this.rules)}getRules(){return this.rules.join(`
|
|
53
|
+
`)}static newName(){let e=UE[qE]||1;return UE[qE]=e+1,Ox+e.toString(36)}static mount(e,i,n){let s=e[Ix],r=n&&n.nonce;s?r&&s.setNonce(r):s=new XW(e,r),s.mount(Array.isArray(i)?i:[i],e)}}let VE=new Map;class XW{constructor(e,i){let n=e.ownerDocument||e,s=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let r=VE.get(n);if(r)return e[Ix]=r;this.sheet=new s.CSSStyleSheet,VE.set(n,this)}else this.styleTag=n.createElement("style"),i&&this.styleTag.setAttribute("nonce",i);this.modules=[],e[Ix]=this}mount(e,i){let n=this.sheet,s=0,r=0;for(let o=0;o<e.length;o++){let a=e[o],u=this.modules.indexOf(a);if(u<r&&u>-1&&(this.modules.splice(u,1),r--,u=-1),u==-1){if(this.modules.splice(r++,0,a),n)for(let h=0;h<a.rules.length;h++)n.insertRule(a.rules[h],s++)}else{for(;r<u;)s+=this.modules[r++].rules.length;s+=a.rules.length,r++}}if(n)i.adoptedStyleSheets.indexOf(this.sheet)<0&&(i.adoptedStyleSheets=[this.sheet,...i.adoptedStyleSheets]);else{let o="";for(let u=0;u<this.modules.length;u++)o+=this.modules[u].getRules()+`
|
|
54
|
+
`;this.styleTag.textContent=o;let a=i.head||i;this.styleTag.parentNode!=a&&a.insertBefore(this.styleTag,a.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var Ta={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Lf={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ZW=typeof navigator<"u"&&/Mac/.test(navigator.platform),JW=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Pn=0;Pn<10;Pn++)Ta[48+Pn]=Ta[96+Pn]=String(Pn);for(var Pn=1;Pn<=24;Pn++)Ta[Pn+111]="F"+Pn;for(var Pn=65;Pn<=90;Pn++)Ta[Pn]=String.fromCharCode(Pn+32),Lf[Pn]=String.fromCharCode(Pn);for(var K1 in Ta)Lf.hasOwnProperty(K1)||(Lf[K1]=Ta[K1]);function eq(t){var e=ZW&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||JW&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",i=!e&&t.key||(t.shiftKey?Lf:Ta)[t.keyCode]||t.key||"Unidentified";return i=="Esc"&&(i="Escape"),i=="Del"&&(i="Delete"),i=="Left"&&(i="ArrowLeft"),i=="Up"&&(i="ArrowUp"),i=="Right"&&(i="ArrowRight"),i=="Down"&&(i="ArrowDown"),i}function xn(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,i=arguments[1];if(i&&typeof i=="object"&&i.nodeType==null&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var s=i[n];typeof s=="string"?t.setAttribute(n,s):s!=null&&(t[n]=s)}e++}for(;e<arguments.length;e++)f3(t,arguments[e]);return t}function f3(t,e){if(typeof e=="string")t.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)t.appendChild(e);else if(Array.isArray(e))for(var i=0;i<e.length;i++)f3(t,e[i]);else throw new RangeError("Unsupported child node: "+e)}let ls=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Px=typeof document<"u"?document:{documentElement:{style:{}}};const zx=/Edge\/(\d+)/.exec(ls.userAgent),p3=/MSIE \d/.test(ls.userAgent),$x=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ls.userAgent),iv=!!(p3||$x||zx),KE=!iv&&/gecko\/(\d+)/i.test(ls.userAgent),Y1=!iv&&/Chrome\/(\d+)/.exec(ls.userAgent),YE="webkitFontSmoothing"in Px.documentElement.style,Fx=!iv&&/Apple Computer/.test(ls.vendor),GE=Fx&&(/Mobile\/\w+/.test(ls.userAgent)||ls.maxTouchPoints>2);var Oe={mac:GE||/Mac/.test(ls.platform),windows:/Win/.test(ls.platform),linux:/Linux|X11/.test(ls.platform),ie:iv,ie_version:p3?Px.documentMode||6:$x?+$x[1]:zx?+zx[1]:0,gecko:KE,gecko_version:KE?+(/Firefox\/(\d+)/.exec(ls.userAgent)||[0,0])[1]:0,chrome:!!Y1,chrome_version:Y1?+Y1[1]:0,ios:GE,android:/Android\b/.test(ls.userAgent),webkit:YE,webkit_version:YE?+(/\bAppleWebKit\/(\d+)/.exec(ls.userAgent)||[0,0])[1]:0,safari:Fx,safari_version:Fx?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ls.userAgent)||[0,0])[1]:0,tabSize:Px.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function fS(t,e){for(let i in t)i=="class"&&e.class?e.class+=" "+t.class:i=="style"&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}const f0=Object.create(null);function pS(t,e,i){if(t==e)return!0;t||(t=f0),e||(e=f0);let n=Object.keys(t),s=Object.keys(e);if(n.length-0!=s.length-0)return!1;for(let r of n)if(r!=i&&(s.indexOf(r)==-1||t[r]!==e[r]))return!1;return!0}function tq(t,e){for(let i=t.attributes.length-1;i>=0;i--){let n=t.attributes[i].name;e[n]==null&&t.removeAttribute(n)}for(let i in e){let n=e[i];i=="style"?t.style.cssText=n:t.getAttribute(i)!=n&&t.setAttribute(i,n)}}function QE(t,e,i){let n=!1;if(e)for(let s in e)i&&s in i||(n=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(i)for(let s in i)e&&e[s]==i[s]||(n=!0,s=="style"?t.style.cssText=i[s]:t.setAttribute(s,i[s]));return n}function iq(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class Lh{eq(e){return!1}updateDOM(e,i,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,i,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var $n=(function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t})($n||($n={}));class _t extends jc{constructor(e,i,n,s){super(),this.startSide=e,this.endSide=i,this.widget=n,this.spec=s}get heightRelevant(){return!1}static mark(e){return new Zf(e)}static widget(e){let i=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return i+=n&&!e.inlineOrder?i>0?3e8:-4e8:i>0?1e8:-1e8,new Dc(e,i,i,n,e.widget||null,!1)}static replace(e){let i=!!e.block,n,s;if(e.isBlockGap)n=-5e8,s=4e8;else{let{start:r,end:o}=m3(e,i);n=(r?i?-3e8:-1:5e8)-1,s=(o?i?2e8:1:-6e8)+1}return new Dc(e,n,s,i,e.widget||null,!0)}static line(e){return new Jf(e)}static set(e,i=!1){return Rt.of(e,i)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}_t.none=Rt.empty;class Zf extends _t{constructor(e){let{start:i,end:n}=m3(e);super(i?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?fS(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||f0}eq(e){return this==e||e instanceof Zf&&this.tagName==e.tagName&&pS(this.attrs,e.attrs)}range(e,i=e){if(e>=i)throw new RangeError("Mark decorations may not be empty");return super.range(e,i)}}Zf.prototype.point=!1;class Jf extends _t{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Jf&&this.spec.class==e.spec.class&&pS(this.spec.attributes,e.spec.attributes)}range(e,i=e){if(i!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,i)}}Jf.prototype.mapMode=rr.TrackBefore;Jf.prototype.point=!0;class Dc extends _t{constructor(e,i,n,s,r,o){super(i,n,r,e),this.block=s,this.isReplace=o,this.mapMode=s?i<=0?rr.TrackBefore:rr.TrackAfter:rr.TrackDel}get type(){return this.startSide!=this.endSide?$n.WidgetRange:this.startSide<=0?$n.WidgetBefore:$n.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Dc&&nq(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,i=e){if(this.isReplace&&(e>i||e==i&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&i!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,i)}}Dc.prototype.point=!0;function m3(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return i==null&&(i=t.inclusive),n==null&&(n=t.inclusive),{start:i??e,end:n??e}}function nq(t,e){return t==e||!!(t&&e&&t.compare(e))}function nh(t,e,i,n=0){let s=i.length-1;s>=0&&i[s]+n>=t?i[s]=Math.max(i[s],e):i.push(t,e)}class Tf extends jc{constructor(e,i,n){super(),this.tagName=e,this.attributes=i,this.rank=n}eq(e){return e==this||e instanceof Tf&&this.tagName==e.tagName&&pS(this.attributes,e.attributes)}static create(e){return new Tf(e.tagName,e.attributes||f0,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,i=!1){return Rt.of(e,i)}}Tf.prototype.startSide=Tf.prototype.endSide=-1;function Nf(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Hx(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function xf(t,e){if(!e.anchorNode)return!1;try{return Hx(t,e.anchorNode)}catch{return!1}}function Ag(t){return t.nodeType==3?jf(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function bf(t,e,i,n){return i?XE(t,e,i,n,-1)||XE(t,e,i,n,1):!1}function Na(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function p0(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function XE(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:kl(t))){if(t.nodeName=="DIV")return!1;let r=t.parentNode;if(!r||r.nodeType!=1)return!1;e=Na(t)+(s<0?0:1),t=r}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?kl(t):0}else return!1}}function kl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function m0(t,e){let{left:i,right:n}=t;if(i==n)return t;let s=e?i:n;return{left:s,right:s,top:t.top,bottom:t.bottom}}function sq(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function g3(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}function rq(t,e,i,n,s,r,o,a){let u=t.ownerDocument,h=u.defaultView||window;for(let p=t,m=!1;p&&!m;)if(p.nodeType==1){let v,_=p==u.body,x=1,S=1;if(_)v=sq(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(p).position)&&(m=!0),p.scrollHeight<=p.clientHeight&&p.scrollWidth<=p.clientWidth){p=p.assignedSlot||p.parentNode;continue}let M=p.getBoundingClientRect();({scaleX:x,scaleY:S}=g3(p,M)),v={left:M.left,right:M.left+p.clientWidth*x,top:M.top,bottom:M.top+p.clientHeight*S}}let C=0,k=0;if(s=="nearest")e.top<v.top+o?(k=e.top-(v.top+o),i>0&&e.bottom>v.bottom+k&&(k=e.bottom-v.bottom+o)):e.bottom>v.bottom-o&&(k=e.bottom-v.bottom+o,i<0&&e.top-k<v.top&&(k=e.top-(v.top+o)));else{let M=e.bottom-e.top,L=v.bottom-v.top;k=(s=="center"&&M<=L?e.top+M/2-L/2:s=="start"||s=="center"&&i<0?e.top-o:e.bottom-L+o)-v.top}if(n=="nearest"?e.left<v.left+r?(C=e.left-(v.left+r),i>0&&e.right>v.right+C&&(C=e.right-v.right+r)):e.right>v.right-r&&(C=e.right-v.right+r,i<0&&e.left<v.left+C&&(C=e.left-(v.left+r))):C=(n=="center"?e.left+(e.right-e.left)/2-(v.right-v.left)/2:n=="start"==a?e.left-r:e.right-(v.right-v.left)+r)-v.left,C||k)if(_)h.scrollBy(C,k);else{let M=0,L=0;if(k){let N=p.scrollTop;p.scrollTop+=k/S,L=(p.scrollTop-N)*S}if(C){let N=p.scrollLeft;p.scrollLeft+=C/x,M=(p.scrollLeft-N)*x}e={left:e.left-M,top:e.top-L,right:e.right-M,bottom:e.bottom-L},M&&Math.abs(M-C)<1&&(n="nearest"),L&&Math.abs(L-k)<1&&(s="nearest")}if(_)break;(e.top<v.top||e.bottom>v.bottom||e.left<v.left||e.right>v.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),p=p.assignedSlot||p.parentNode}else if(p.nodeType==11)p=p.host;else break}function v3(t,e=!0){let i=t.ownerDocument,n=null,s=null;for(let r=t.parentNode;r&&!(r==i.body||(!e||n)&&s);)if(r.nodeType==1)!s&&r.scrollHeight>r.clientHeight&&(s=r),e&&!n&&r.scrollWidth>r.clientWidth&&(n=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:n,y:s}}class oq{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:i,focusNode:n}=e;this.set(i,Math.min(e.anchorOffset,i?kl(i):0),n,Math.min(e.focusOffset,n?kl(n):0))}set(e,i,n,s){this.anchorNode=e,this.anchorOffset=i,this.focusNode=n,this.focusOffset=s}}function _3(t){let e=[];for(let i=t;i;i=i.nodeType==11?i.host:i.parentNode)i.nodeType==1&&e.push({node:i,left:i.scrollLeft,top:i.scrollTop});return e}function y3(t,e=!0){for(let{node:i,left:n,top:s}of t)e&&i.scrollTop!=s&&(i.scrollTop=s),i.scrollLeft!=n&&(i.scrollLeft=n)}let fc=null;Oe.safari&&Oe.safari_version>=26&&(fc=!1);function x3(t){if(t.setActive)return t.setActive();if(fc)return t.focus(fc);let e=_3(t);t.focus(fc==null?{get preventScroll(){return fc={preventScroll:!0},!0}}:void 0),fc||(fc=!1,y3(e))}let ZE;function jf(t,e,i=e){let n=ZE||(ZE=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function sh(t,e,i,n){let s={key:e,code:e,keyCode:i,which:i,cancelable:!0};n&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=n);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,t.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,t.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function lq(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function aq(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,kl(i));;)if(n){if(i.nodeType!=1)return!1;let s=i.childNodes[n-1];s.contentEditable=="false"?n--:(i=s,n=kl(i))}else{if(i==t)return!0;n=Na(i),i=i.parentNode}}function b3(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function w3(t,e){for(let i=t,n=e;;){if(i.nodeType==3&&n>0)return{node:i,offset:n};if(i.nodeType==1&&n>0){if(i.contentEditable=="false")return null;i=i.childNodes[n-1],n=kl(i)}else if(i.parentNode&&!p0(i))n=Na(i),i=i.parentNode;else return null}}function S3(t,e){for(let i=t,n=e;;){if(i.nodeType==3&&n<i.nodeValue.length)return{node:i,offset:n};if(i.nodeType==1&&n<i.childNodes.length){if(i.contentEditable=="false")return null;i=i.childNodes[n],n=0}else if(i.parentNode&&!p0(i))n=Na(i)+1,i=i.parentNode;else return null}}class Gr{constructor(e,i,n=!0){this.node=e,this.offset=i,this.precise=n}static before(e,i){return new Gr(e.parentNode,Na(e),i)}static after(e,i){return new Gr(e.parentNode,Na(e)+1,i)}}var Mi=(function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t})(Mi||(Mi={}));const Bc=Mi.LTR,mS=Mi.RTL;function k3(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const cq=k3("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),uq=k3("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Wx=Object.create(null),uo=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Wx[e]=i,Wx[i]=-e}function C3(t){return t<=247?cq[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?uq[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const hq=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class wo{get dir(){return this.level%2?mS:Bc}constructor(e,i,n){this.from=e,this.to=i,this.level=n}side(e,i){return this.dir==i==e?this.to:this.from}forward(e,i){return e==(this.dir==i)}static find(e,i,n,s){let r=-1;for(let o=0;o<e.length;o++){let a=e[o];if(a.from<=i&&a.to>=i){if(a.level==n)return o;(r<0||(s!=0?s<0?a.from<i:a.to>i:e[r].level>a.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function E3(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.direction!=s.direction||!E3(n.inner,s.inner))return!1}return!0}const li=[];function dq(t,e,i,n,s){for(let r=0;r<=n.length;r++){let o=r?n[r-1].to:e,a=r<n.length?n[r].from:i,u=r?256:s;for(let h=o,p=u,m=u;h<a;h++){let v=C3(t.charCodeAt(h));v==512?v=p:v==8&&m==4&&(v=16),li[h]=v==4?2:v,v&7&&(m=v),p=v}for(let h=o,p=u,m=u;h<a;h++){let v=li[h];if(v==128)h<a-1&&p==li[h+1]&&p&24?v=li[h]=p:li[h]=256;else if(v==64){let _=h+1;for(;_<a&&li[_]==64;)_++;let x=h&&p==8||_<i&&li[_]==8?m==1?1:8:256;for(let S=h;S<_;S++)li[S]=x;h=_-1}else v==8&&m==1&&(li[h]=1);p=v,v&7&&(m=v)}}}function fq(t,e,i,n,s){let r=s==1?2:1;for(let o=0,a=0,u=0;o<=n.length;o++){let h=o?n[o-1].to:e,p=o<n.length?n[o].from:i;for(let m=h,v,_,x;m<p;m++)if(_=Wx[v=t.charCodeAt(m)])if(_<0){for(let S=a-3;S>=0;S-=3)if(uo[S+1]==-_){let C=uo[S+2],k=C&2?s:C&4?C&1?r:s:0;k&&(li[m]=li[uo[S]]=k),a=S;break}}else{if(uo.length==189)break;uo[a++]=m,uo[a++]=v,uo[a++]=u}else if((x=li[m])==2||x==1){let S=x==s;u=S?0:1;for(let C=a-3;C>=0;C-=3){let k=uo[C+2];if(k&2)break;if(S)uo[C+2]|=2;else{if(k&4)break;uo[C+2]|=4}}}}}function pq(t,e,i,n){for(let s=0,r=n;s<=i.length;s++){let o=s?i[s-1].to:t,a=s<i.length?i[s].from:e;for(let u=o;u<a;){let h=li[u];if(h==256){let p=u+1;for(;;)if(p==a){if(s==i.length)break;p=i[s++].to,a=s<i.length?i[s].from:e}else if(li[p]==256)p++;else break;let m=r==1,v=(p<e?li[p]:n)==1,_=m==v?m?1:2:n;for(let x=p,S=s,C=S?i[S-1].to:t;x>u;)x==C&&(x=i[--S].from,C=S?i[S-1].to:t),li[--x]=_;u=p}else r=h,u++}}}function qx(t,e,i,n,s,r,o){let a=n%2?2:1;if(n%2==s%2)for(let u=e,h=0;u<i;){let p=!0,m=!1;if(h==r.length||u<r[h].from){let S=li[u];S!=a&&(p=!1,m=S==16)}let v=!p&&a==1?[]:null,_=p?n:n+1,x=u;e:for(;;)if(h<r.length&&x==r[h].from){if(m)break e;let S=r[h];if(!p)for(let C=S.to,k=h+1;;){if(C==i)break e;if(k<r.length&&r[k].from==C)C=r[k++].to;else{if(li[C]==a)break e;break}}if(h++,v)v.push(S);else{S.from>u&&o.push(new wo(u,S.from,_));let C=S.direction==Bc!=!(_%2);Ux(t,C?n+1:n,s,S.inner,S.from,S.to,o),u=S.to}x=S.to}else{if(x==i||(p?li[x]!=a:li[x]==a))break;x++}v?qx(t,u,x,n+1,s,v,o):u<x&&o.push(new wo(u,x,_)),u=x}else for(let u=i,h=r.length;u>e;){let p=!0,m=!1;if(!h||u>r[h-1].to){let S=li[u-1];S!=a&&(p=!1,m=S==16)}let v=!p&&a==1?[]:null,_=p?n:n+1,x=u;e:for(;;)if(h&&x==r[h-1].to){if(m)break e;let S=r[--h];if(!p)for(let C=S.from,k=h;;){if(C==e)break e;if(k&&r[k-1].to==C)C=r[--k].from;else{if(li[C-1]==a)break e;break}}if(v)v.push(S);else{S.to<u&&o.push(new wo(S.to,u,_));let C=S.direction==Bc!=!(_%2);Ux(t,C?n+1:n,s,S.inner,S.from,S.to,o),u=S.from}x=S.from}else{if(x==e||(p?li[x-1]!=a:li[x-1]==a))break;x--}v?qx(t,x,u,n+1,s,v,o):x<u&&o.push(new wo(x,u,_)),u=x}}function Ux(t,e,i,n,s,r,o){let a=e%2?2:1;dq(t,s,r,n,a),fq(t,s,r,n,a),pq(s,r,n,a),qx(t,s,r,e,i,n,o)}function mq(t,e,i){if(!t)return[new wo(0,0,e==mS?1:0)];if(e==Bc&&!i.length&&!hq.test(t))return M3(t.length);if(i.length)for(;t.length>li.length;)li[li.length]=256;let n=[],s=e==Bc?0:1;return Ux(t,s,s,i,0,t.length,n),n}function M3(t){return[new wo(0,t,0)]}let A3="";function gq(t,e,i,n,s){var r;let o=n.head-t.from,a=wo.find(e,o,(r=n.bidiLevel)!==null&&r!==void 0?r:-1,n.assoc),u=e[a],h=u.side(s,i);if(o==h){let v=a+=s?1:-1;if(v<0||v>=e.length)return null;u=e[a=v],o=u.side(!s,i),h=u.side(s,i)}let p=An(t.text,o,u.forward(s,i));(p<u.from||p>u.to)&&(p=h),A3=t.text.slice(Math.min(o,p),Math.max(o,p));let m=a==(s?e.length-1:0)?null:e[a+(s?1:-1)];return m&&p==h&&m.level+(s?0:1)<u.level?Se.cursor(m.side(!s,i)+t.from,m.forward(s,i)?1:-1,m.level):Se.cursor(p+t.from,u.forward(s,i)?-1:1,u.level)}function vq(t,e,i){for(let n=e;n<i;n++){let s=C3(t.charCodeAt(n));if(s==1)return Bc;if(s==2||s==4)return mS}return Bc}const L3=Fe.define(),T3=Fe.define(),N3=Fe.define(),j3=Fe.define(),Vx=Fe.define(),R3=Fe.define(),D3=Fe.define(),gS=Fe.define(),vS=Fe.define(),B3=Fe.define({combine:t=>t.some(e=>e)}),O3=Fe.define({combine:t=>t.some(e=>e)}),I3=Fe.define();class rh{constructor(e,i,n,s,r,o=!1){this.range=e,this.y=i,this.x=n,this.yMargin=s,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new rh(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new rh(Se.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Fm=ci.define({map:(t,e)=>t.map(e)}),P3=ci.define();function So(t,e,i){let n=t.facet(j3);n.length?n[0](e):window.onerror&&window.onerror(String(e),i,void 0,void 0,e)||(i?console.error(i+":",e):console.error(e))}const _l=Fe.define({combine:t=>t.length?t[0]:!0});let _q=0;const Gu=Fe.define({combine(t){return t.filter((e,i)=>{for(let n=0;n<i;n++)if(t[n].plugin==e.plugin)return!1;return!0})}});class ds{constructor(e,i,n,s,r){this.id=e,this.create=i,this.domEventHandlers=n,this.domEventObservers=s,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(Gu.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Gu.of({plugin:this,arg:e}))}static define(e,i){const{eventHandlers:n,eventObservers:s,provide:r,decorations:o}=i||{};return new ds(_q++,e,n,s,a=>{let u=[];return o&&u.push(nv.of(h=>{let p=h.plugin(a);return p?o(p):_t.none})),r&&u.push(r(a)),u})}static fromClass(e,i){return ds.define((n,s)=>new e(n,s),i)}}class G1{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let i=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(i)}catch(n){if(So(i.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(i){So(e.state,i,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var i;if(!((i=this.value)===null||i===void 0)&&i.destroy)try{this.value.destroy()}catch(n){So(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const z3=Fe.define(),_S=Fe.define(),nv=Fe.define(),$3=Fe.define(),yS=Fe.define(),ep=Fe.define(),F3=Fe.define();function JE(t,e){let i=t.state.facet(F3);if(!i.length)return i;let n=i.map(r=>r instanceof Function?r(t):r),s=[];return Rt.spans(n,e.from,e.to,{point(){},span(r,o,a,u){let h=r-e.from,p=o-e.from,m=s;for(let v=a.length-1;v>=0;v--,u--){let _=a[v].spec.bidiIsolate,x;if(_==null&&(_=vq(e.text,h,p)),u>0&&m.length&&(x=m[m.length-1]).to==h&&x.direction==_)x.to=p,m=x.inner;else{let S={from:h,to:p,direction:_,inner:[]};m.push(S),m=S.inner}}}}),s}const H3=Fe.define();function W3(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(H3)){let o=r(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(i=Math.max(i,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const lf=Fe.define();class Rr{constructor(e,i,n,s){this.fromA=e,this.toA=i,this.fromB=n,this.toB=s}join(e){return new Rr(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let i=e.length,n=this;for(;i>0;i--){let s=e[i-1];if(!(s.fromA>n.toA)){if(s.toA<n.fromA)break;n=n.join(s),e.splice(i-1,1)}}return e.splice(i,0,n),e}static extendWithRanges(e,i){if(i.length==0)return e;let n=[];for(let s=0,r=0,o=0;;){let a=s<e.length?e[s].fromB:1e9,u=r<i.length?i[r]:1e9,h=Math.min(a,u);if(h==1e9)break;let p=h+o,m=h,v=p;for(;;)if(r<i.length&&i[r]<=m){let _=i[r+1];r+=2,m=Math.max(m,_);for(let x=s;x<e.length&&e[x].fromB<=m;x++)o=e[x].toA-e[x].toB;v=Math.max(v,_+o)}else if(s<e.length&&e[s].fromB<=m){let _=e[s++];m=Math.max(m,_.toB),v=Math.max(v,_.toA),o=_.toA-_.toB}else break;n.push(new Rr(p,v,h,m))}return n}}class g0{constructor(e,i,n){this.view=e,this.state=i,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=fn.empty(this.startState.doc.length);for(let r of n)this.changes=this.changes.compose(r.changes);let s=[];this.changes.iterChangedRanges((r,o,a,u)=>s.push(new Rr(r,o,a,u))),this.changedRanges=s}static create(e,i,n){return new g0(e,i,n)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const yq=[];class Pi{constructor(e,i,n=0){this.dom=e,this.length=i,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return yq}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let i=this.domAttrs;i&&tq(this.dom,i)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,i=this.posAtStart){let n=i;for(let s of this.children){if(s==e)return n;n+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,i,n){return null}domPosFor(e,i){let n=Na(this.dom),s=this.length?e>0:i>0;return new Gr(this.parent.dom,n+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof rv)return e;return null}static get(e){return e.cmTile}}class sv extends Pi{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let i=this.dom,n=null,s,r=e?.node==i?e:null,o=0;for(let a of this.children){if(a.sync(e),o+=a.length+a.breakAfter,s=n?n.nextSibling:i.firstChild,r&&s!=a.dom&&(r.written=!0),a.dom.parentNode==i)for(;s&&s!=a.dom;)s=eM(s);else i.insertBefore(a.dom,s);n=a.dom}for(s=n?n.nextSibling:i.firstChild,r&&s&&(r.written=!0);s;)s=eM(s);this.length=o}}function eM(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class rv extends sv{constructor(e,i){super(i),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let i=Pi.get(e);if(i&&this.owns(i))return i;e=e.parentNode}}blockTiles(e){for(let i=[],n=this,s=0,r=0;;)if(s==n.children.length){if(!i.length)return;n=n.parent,n.breakAfter&&r++,s=i.pop()}else{let o=n.children[s++];if(o instanceof wl)i.push(s),n=o,s=0;else{let a=r+o.length,u=e(o,r);if(u!==void 0)return u;r=a+o.breakAfter}}}resolveBlock(e,i){let n,s=-1,r,o=-1;if(this.blockTiles((a,u)=>{let h=u+a.length;if(e>=u&&e<=h){if(a.isWidget()&&i>=-1&&i<=1){if(a.flags&32)return!0;a.flags&16&&(n=void 0)}(u<e||e==h&&(i<-1?a.length:a.covers(1)))&&(!n||!a.isWidget()&&n.isWidget())&&(n=a,s=e-u),(h>e||e==u&&(i>1?a.length:a.covers(-1)))&&(!r||!a.isWidget()&&r.isWidget())&&(r=a,o=e-u)}}),!n&&!r)throw new Error("No tile at position "+e);return n&&i<0||!r?{tile:n,offset:s}:{tile:r,offset:o}}}class wl extends sv{constructor(e,i){super(e),this.wrapper=i}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,i){let n=new wl(i||document.createElement(e.tagName),e);return i||(n.flags|=4),n}}class ph extends sv{constructor(e,i){super(e),this.attrs=i}isLine(){return!0}static start(e,i,n){let s=new ph(i||document.createElement("div"),e);return(!i||!n)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,i,n){let s=null,r=-1,o=null,a=-1;function u(p,m){for(let v=0,_=0;v<p.children.length&&_<=m;v++){let x=p.children[v],S=_+x.length;S>=m&&(x.isComposite()?u(x,m-_):(!o||o.isHidden&&(i>0&&!(o.flags&32)||n&&bq(o,x)))&&(S>m||x.flags&32&&i<=1)?(o=x,a=m-_):(_<m||x.flags&16&&!x.isHidden&&i>=-1)&&(s=x,r=m-_)),_=S}}u(this,e);let h=(i<0?s:o)||s||o;return h?{tile:h,offset:h==s?r:a}:null}coordsIn(e,i,n){let s=this.resolveInline(e,i,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),i,n):xq(this)}domIn(e,i){let n=this.resolveInline(e,i);if(n){let{tile:s,offset:r}=n;if(this.dom.contains(s.dom))return s.isText()?new Gr(s.dom,Math.min(s.dom.nodeValue.length,r)):s.domPosFor(r,s.flags&16?1:s.flags&32?-1:i);let o=n.tile.parent,a=!1;for(let u of o.children){if(a)return new Gr(u.dom,0);u==n.tile&&(a=!0)}}return new Gr(this.dom,0)}}function xq(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=Ag(e);return i[i.length-1]||null}function bq(t,e){let i=t.coordsIn(0,1),n=e.coordsIn(0,1);return i&&n&&n.top<i.bottom}class Ns extends sv{constructor(e,i){super(e),this.mark=i}get domAttrs(){return this.mark.attrs}static of(e,i){let n=new Ns(i||document.createElement(e.tagName),e);return i||(n.flags|=4),n}}class vc extends Pi{constructor(e,i){super(e,i.length),this.text=i}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,i,n){let s=this.dom.nodeValue.length;e>s&&(e=s);let r=e,o=e,a=0;e==0&&i<0||e==s&&i>=0?Oe.chrome||Oe.gecko||(e?(r--,a=1):o<s&&(o++,a=-1)):i<0?r--:o<s&&o++;let u=jf(this.dom,r,o).getClientRects();if(!u.length)return null;let h=u[(a?a<0:i>=0)?0:u.length-1];return Oe.safari&&!a&&h.width==0&&(h=Array.prototype.find.call(u,p=>p.width)||h),n==null?h:m0(h,(a?a>0:i<0)==n)}static of(e,i){let n=new vc(i||document.createTextNode(e),e);return i||(n.flags|=2),n}}class Oc extends Pi{constructor(e,i,n,s){super(e,i,s),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,i){return this.coordsInWidget(e,i,!1)}coordsInWidget(e,i,n){let s=this.widget.coordsAt(this.dom,e,i);if(s)return s;if(n)return m0(this.dom.getBoundingClientRect(),this.length?e==0:i<=0);{let r=this.dom.getClientRects(),o=null;if(!r.length)return null;let a=this.flags&16?!0:this.flags&32?!1:e>0;for(let u=a?r.length-1:0;o=r[u],!(e>0?u==0:u==r.length-1||o.top<o.bottom);u+=a?-1:1);return m0(o,!a)}}get overrideDOMText(){if(!this.length)return Vt.empty;let{root:e}=this;if(!e)return Vt.empty;let i=this.posAtStart;return e.view.state.doc.slice(i,i+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,i,n,s,r){return r||(r=e.toDOM(i),e.editable||(r.contentEditable="false")),new Oc(r,n,e,s)}}class v0 extends Pi{constructor(e){let i=document.createElement("img");i.className="cm-widgetBuffer",i.setAttribute("aria-hidden","true"),super(i,0,e)}get isHidden(){return!0}get overrideDOMText(){return Vt.empty}coordsIn(e,i,n){let s=this.dom.getBoundingClientRect();return n==null?s:m0(s,i>0==n)}}class wq{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,i,n){let{tile:s,index:r,beforeBreak:o,parents:a}=this;for(;e||i>0;)if(s.isComposite())if(o){if(!e)break;n&&n.break(),e--,o=!1}else if(r==s.children.length){if(!e&&!a.length)break;n&&n.leave(s),o=!!s.breakAfter,{tile:s,index:r}=a.pop(),r++}else{let u=s.children[r],h=u.breakAfter;(i>0?u.length<=e:u.length<e)&&(!n||n.skip(u,0,u.length)!==!1||!u.isComposite)?(o=!!h,r++,e-=u.length):(a.push({tile:s,index:r}),s=u,r=0,n&&u.isComposite()&&n.enter(u))}else{let u=s.length;if(r<u&&e){let h=Math.min(e,u-r);n&&n.skip(s,r,r+h),e-=h,r+=h}if(r==u)o=!!s.breakAfter,{tile:s,index:r}=a.pop(),r++;else if(!e)break}return this.tile=s,this.index=r,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Sq{constructor(e,i,n,s){this.from=e,this.to=i,this.wrapper=n,this.rank=s}}class kq{constructor(e,i,n){this.cache=e,this.root=i,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,i,n,s){var r;this.flushBuffer();let o=this.ensureMarks(i,n),a=o.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let u=o.children[o.children.length-1]=new vc(a.dom,a.text+e);u.parent=o}else o.append(s||vc.of(e,(r=this.cache.find(vc))===null||r===void 0?void 0:r.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,i){let n=this.curLine;n.dom!=i.line.dom&&(n.setDOM(this.cache.reused.has(i.line)?Q1(i.line.dom):i.line.dom),this.cache.reused.set(i.line,2));let s=n;for(let a=i.marks.length-1;a>=0;a--){let u=i.marks[a],h=s.lastChild;if(h instanceof Ns&&h.mark.eq(u.mark))h.dom!=u.dom&&h.setDOM(Q1(u.dom)),s=h;else{if(this.cache.reused.get(u)){let m=Pi.get(u.dom);m&&m.setDOM(Q1(u.dom))}let p=Ns.of(u.mark,u.dom);s.append(p),s=p}this.cache.reused.set(u,2)}let r=Pi.get(e.text);r&&this.cache.reused.set(r,2);let o=new vc(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,s.append(o)}addInlineWidget(e,i,n){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let r=this.ensureMarks(i,n);!s&&!(e.flags&16)&&r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,i,n){this.flushBuffer(),this.ensureMarks(i,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let i=this.afterWidget||this.lastBlock;i.length+=e,this.pos+=e}addLineStart(e,i){var n;e||(e=q3);let s=ph.start(e,i||((n=this.cache.find(ph))===null||n===void 0?void 0:n.dom),!!i);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,i){var n;let s=this.curLine;for(let r=e.length-1;r>=0;r--){let o=e[r],a;if(i>0&&(a=s.lastChild)&&a instanceof Ns&&a.mark.eq(o))s=a,i--;else{let u=Ns.of(o,(n=this.cache.find(Ns,h=>h.mark.eq(o)))===null||n===void 0?void 0:n.dom);s.append(u),s=u,i=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!tM(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&tM(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(X1,0,32)||new Oc(X1.toDOM(),0,X1,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let i=e.rank*102+e.value.rank,n=new Sq(e.from,e.to,e.value,i),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-n.rank||this.wrappers[s-1].to-n.to)<0;)s--;this.wrappers.splice(s,0,n)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let i=this.root;for(let n of this.wrappers){let s=i.lastChild;if(n.from<this.pos&&s instanceof wl&&s.wrapper.eq(n.wrapper))i=s;else{let r=wl.of(n.wrapper,(e=this.cache.find(wl,o=>o.wrapper.eq(n.wrapper)))===null||e===void 0?void 0:e.dom);i.append(r),i=r}}return i}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let i=2|(e<0?16:32),n=this.cache.find(v0,void 0,1);return n&&(n.flags=i),n||new v0(i)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Cq{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:r,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=s;let a=this.textOff=Math.min(e,s.length);return r?null:s.slice(0,a)}let i=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,i);return this.textOff=i,n}}const _0=[Oc,ph,vc,Ns,v0,wl,rv];for(let t=0;t<_0.length;t++)_0[t].bucket=t;class Eq{constructor(e){this.view=e,this.buckets=_0.map(()=>[]),this.index=_0.map(()=>0),this.reused=new Map}add(e){let i=e.constructor.bucket,n=this.buckets[i];n.length<6?n.push(e):n[this.index[i]=(this.index[i]+1)%6]=e}find(e,i,n=2){let s=e.bucket,r=this.buckets[s],o=this.index[s];for(let a=0;a<r.length;a++){let u=(a+o)%r.length,h=r[u];if((!i||i(h))&&!this.reused.has(h))return r.splice(u,1),u<o&&this.index[s]--,this.reused.set(h,n),h}return null}findWidget(e,i,n){let s=this.buckets[0];if(s.length)for(let r=0,o=0;;r++){if(r==s.length){if(o)return null;o=1,r=0}let a=s[r];if(!this.reused.has(a)&&(o==0?a.widget.compare(e):a.widget.constructor==e.constructor&&e.updateDOM(a.dom,this.view,a.widget)))return s.splice(r,1),r<this.index[0]&&this.index[0]--,a.widget==e&&a.length==i&&(a.flags&497)==n?(this.reused.set(a,1),a):(this.reused.set(a,2),new Oc(a.dom,i,e,a.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,i=2){if(!this.reused.has(e))return this.reused.set(e,i),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class Mq{constructor(e,i,n,s,r){this.view=e,this.decorations=s,this.disallowBlockEffectsFor=r,this.openWidget=!1,this.openMarks=0,this.cache=new Eq(e),this.text=new Cq(e.state.doc),this.builder=new kq(this.cache,new rv(e,e.contentDOM),Rt.iter(n)),this.cache.reused.set(i,2),this.old=new wq(i),this.reuseWalker={skip:(o,a,u)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,i){let n=i&&this.getCompositionContext(i.text);for(let s=0,r=0,o=0;;){let a=o<e.length?e[o++]:null,u=a?a.fromA:this.old.root.length;if(u>s){let h=u-s;this.preserve(h,!o,!a),s=u,r+=h}if(!a)break;i&&a.fromA<=i.range.fromA&&a.toA>=i.range.toA?(this.forward(a.fromA,i.range.fromA,i.range.fromA<i.range.toA?1:-1),this.emit(r,i.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(i,n),this.text.skip(i.range.toB-i.range.fromB),this.forward(i.range.fromA,a.toA),this.emit(i.range.toB,a.toB)):(this.forward(a.fromA,a.toA),this.emit(r,a.toB)),r=a.toB,s=a.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,i,n){let s=Tq(this.old),r=this.openMarks;this.old.advance(e,n?1:-1,{skip:(o,a,u)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(u-a);else{let h=u>0||a<o.length?Oc.of(o.widget,this.view,u-a,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);h.flags&256?(h.flags&=-2,this.builder.addBlockWidget(h)):(this.builder.ensureLine(null),this.builder.addInlineWidget(h,s,r),r=s.length)}else if(o.isText())this.builder.ensureLine(null),!a&&u==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,s,r,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(a,u),s,r)),r=s.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof v0)this.cache.add(o);else if(o instanceof Ns)this.builder.ensureLine(null),this.builder.addMark(o,s,r),this.cache.reused.set(o,1),r=s.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Ns&&s.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?s.length&&(s.length=r=0):o instanceof Ns&&(s.shift(),r=Math.min(r,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,i){let n=null,s=this.builder,r=-1,o=Rt.spans(this.decorations,e,i,{point:(a,u,h,p,m,v)=>{if(h instanceof Dc){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(u>this.view.state.doc.lineAt(a).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=p.length,m>p.length)s.continueWidget(u-a);else{let _=h.widget||(h.block?mh.block:mh.inline),x=Aq(h),S=this.cache.findWidget(_,u-a,x)||Oc.of(_,this.view,u-a,x);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(n),s.addBlockWidget(S)):(s.ensureLine(n),s.addInlineWidget(S,p,m))}n=null}else n=Lq(n,h);u>a&&this.text.skip(u-a)},span:(a,u,h,p)=>{for(let m=a;m<u;){let v=this.text.next(Math.min(512,u-m));v==null?(s.addLineStartIfNotCovered(n),s.addBreak(),m++):(s.ensureLine(n),s.addText(v,h,m==a?p:h.length),m+=v.length),n=null}r=h.length}});r>-1&&(this.openWidget=o>r),this.openWidget||s.addLineStartIfNotCovered(n),this.openMarks=o}forward(e,i,n=1){i-e<=10?this.old.advance(i-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(i-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let i=[],n=null;for(let s=e.parentNode;;s=s.parentNode){let r=Pi.get(s);if(s==this.view.contentDOM)break;r instanceof Ns?i.push(r):r?.isLine()?n=r:r instanceof wl||(s.nodeName=="DIV"&&!n&&s!=this.view.contentDOM?n=new ph(s,q3):n||i.push(Ns.of(new Zf({tagName:s.nodeName.toLowerCase(),attributes:iq(s)}),s)))}return{line:n,marks:i}}}function tM(t,e){let i=n=>{for(let s of n.children)if((e?s.isText():s.length)||i(s))return!0;return!1};return i(t)}function Aq(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const q3={class:"cm-line"};function Lq(t,e){let i=e.spec.attributes,n=e.spec.class;return!i&&!n||(t||(t={class:"cm-line"}),i&&fS(i,t),n&&(t.class+=" "+n)),t}function Tq(t){let e=[];for(let i=t.parents.length;i>1;i--){let n=i==t.parents.length?t.tile:t.parents[i].tile;n instanceof Ns&&e.push(n.mark)}return e}function Q1(t){let e=Pi.get(t);return e&&e.setDOM(t.cloneNode()),t}class mh extends Lh{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}mh.inline=new mh("span");mh.block=new mh("div");const X1=new class extends Lh{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class iM{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=_t.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new rv(e,e.contentDOM),this.updateInner([new Rr(0,0,0,e.state.doc.length)],null)}update(e){var i;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:p,toA:m})=>m<this.minWidthFrom||p>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((i=this.domChanged)===null||i===void 0)&&i.newSel?s=this.domChanged.newSel.head:!zq(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let r=s>-1?jq(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:p,to:m}=this.hasComposition;n=new Rr(p,m,e.changes.mapPos(p,-1),e.changes.mapPos(m,1)).addToSet(n.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(Oe.ie||Oe.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,a=this.blockWrappers;this.updateDeco();let u=Bq(o,this.decorations,e.changes);u.length&&(n=Rr.extendWithRanges(n,u));let h=Iq(a,this.blockWrappers,e.changes);return h.length&&(n=Rr.extendWithRanges(n,h)),r&&!n.some(p=>p.fromA<=r.range.fromA&&p.toA>=r.range.toA)&&(n=r.range.addToSet(n.slice())),this.tile.flags&2&&n.length==0?!1:(this.updateInner(n,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,i){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(i||e.length){let o=this.tile,a=new Mq(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);i&&Pi.get(i.text)&&a.cache.reused.set(Pi.get(i.text),2),this.tile=a.run(e,i),Kx(o,a.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=Oe.chrome||Oe.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.tile.children)r.isWidget()&&r.widget instanceof Z1&&s.push(r.dom);n.updateGaps(s)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let i of e.transactions)for(let n of i.effects)n.is(P3)&&(this.editContextFormatting=n.value)}updateSelection(e=!1,i=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,s=this.view.root.activeElement,r=s==n,o=!r&&!(this.view.state.facet(_l)||n.tabIndex>-1)&&xf(n,this.view.observer.selectionRange)&&!(s&&n.contains(s));if(!(r||i||o))return;let a=this.forceSelection;this.forceSelection=!1;let u=this.view.state.selection.main,h,p;if(u.empty?p=h=this.inlineDOMNearPos(u.anchor,u.assoc||1):(p=this.inlineDOMNearPos(u.head,u.head==u.from?1:-1),h=this.inlineDOMNearPos(u.anchor,u.anchor==u.from?1:-1)),Oe.gecko&&u.empty&&!this.hasComposition&&Nq(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=p=new Gr(v,0),a=!0}let m=this.view.observer.selectionRange;(a||!m.focusNode||(!bf(h.node,h.offset,m.anchorNode,m.anchorOffset)||!bf(p.node,p.offset,m.focusNode,m.focusOffset))&&!this.suppressWidgetCursorChange(m,u))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&n.contains(m.focusNode)&&Pq(m.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let v=Nf(this.view.root);if(v)if(u.empty){if(Oe.gecko){let _=Rq(h.node,h.offset);if(_&&_!=3){let x=(_==1?w3:S3)(h.node,h.offset);x&&(h=new Gr(x.node,x.offset))}}v.collapse(h.node,h.offset),u.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=u.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(p.node,p.offset)}catch{}}else{let _=document.createRange();u.anchor>u.head&&([h,p]=[p,h]),_.setEnd(p.node,p.offset),_.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(_)}o&&this.view.root.activeElement==n&&(n.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,p)),this.impreciseAnchor=h.precise?null:new Gr(m.anchorNode,m.anchorOffset),this.impreciseHead=p.precise?null:new Gr(m.focusNode,m.focusOffset)}suppressWidgetCursorChange(e,i){return this.hasComposition&&i.empty&&bf(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==i.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,i=e.state.selection.main,n=Nf(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!n||!i.empty||!i.assoc||!n.modify)return;let o=this.lineAt(i.head,i.assoc);if(!o)return;let a=o.posAtStart;if(i.head==a||i.head==a+o.length)return;let u=this.coordsAt(i.head,-1),h=this.coordsAt(i.head,1);if(!u||!h||u.bottom>h.top)return;let p=this.domAtPos(i.head+i.assoc,i.assoc);n.collapse(p.node,p.offset),n.modify("move",i.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let m=e.observer.selectionRange;e.docView.posFromDOM(m.anchorNode,m.anchorOffset)!=i.from&&n.collapse(s,r)}posFromDOM(e,i){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=n.posAtStart;if(n.isComposite()){let r;if(e==n.dom)r=n.dom.childNodes[i];else{let o=kl(e)==0?0:i==0?-1:1;for(;;){let a=e.parentNode;if(a==n.dom)break;o==0&&a.firstChild!=a.lastChild&&(e==a.firstChild?o=-1:o=1),e=a}o<0?r=e:r=e.nextSibling}if(r==n.dom.firstChild)return s;for(;r&&!Pi.get(r);)r=r.nextSibling;if(!r)return s+n.length;for(let o=0,a=s;;o++){let u=n.children[o];if(u.dom==r)return a;a+=u.length+u.breakAfter}}else return n.isText()?e==n.dom?s+i:s+(i?n.length:0):s}domAtPos(e,i){let{tile:n,offset:s}=this.tile.resolveBlock(e,i);return n.isWidget()?n.domPosFor(s,i):n.domIn(s,i)}inlineDOMNearPos(e,i){let n,s=-1,r=!1,o,a=-1,u=!1;return this.tile.blockTiles((h,p)=>{if(h.isWidget()){if(h.flags&32&&p>=e)return!0;h.flags&16&&(r=!0)}else{let m=p+h.length;if(p<=e&&(n=h,s=e-p,r=m<e),m>=e&&!o&&(o=h,a=e-p,u=p>e),p>e&&o)return!0}}),!n&&!o?this.domAtPos(e,i):(r&&o?n=null:u&&n&&(o=null),n&&i<0||!o?n.domIn(s,i):o.domIn(a,i))}coordsAt(e,i,n){let{tile:s,offset:r}=this.tile.resolveBlock(e,i);return s.isWidget()?s.widget instanceof Z1?null:s.coordsInWidget(r,i,!0):s.coordsIn(r,i,n)}lineAt(e,i){let{tile:n}=this.tile.resolveBlock(e,i);return n.isLine()?n:null}coordsForChar(e){let{tile:i,offset:n}=this.tile.resolveBlock(e,1);if(!i.isLine())return null;function s(r,o){if(r.isComposite())for(let a of r.children){if(a.length>=o){let u=s(a,o);if(u)return u}if(o-=a.length,o<0)break}else if(r.isText()&&o<r.length){let a=An(r.text,o);if(a==o)return null;let u=jf(r.dom,o,a).getClientRects();for(let h=0;h<u.length;h++){let p=u[h];if(h==u.length-1||p.top<p.bottom&&p.left<p.right)return p}}return null}return s(i,n)}measureVisibleLineHeights(e){let i=[],{from:n,to:s}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,u=this.view.textDirection==Mi.LTR,h=0,p=(m,v,_)=>{for(let x=0;x<m.children.length&&!(v>s);x++){let S=m.children[x],C=v+S.length,k=S.dom.getBoundingClientRect(),{height:M}=k;if(_&&!x&&(h+=k.top-_.top),S instanceof wl)C>n&&p(S,v,k);else if(v>=n&&(h>0&&i.push(-h),i.push(M+h),h=0,o)){let L=S.dom.lastChild,N=L?Ag(L):[];if(N.length){let j=N[N.length-1],R=u?j.right-k.left:k.right-j.left;R>a&&(a=R,this.minWidth=r,this.minWidthFrom=v,this.minWidthTo=C)}}_&&x==m.children.length-1&&(h+=_.bottom-k.bottom),v=C+S.breakAfter}};return p(this.tile,0,null),i}textDirectionAt(e){let{tile:i}=this.tile.resolveBlock(e,1);return getComputedStyle(i.dom).direction=="rtl"?Mi.RTL:Mi.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let a=0,u;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let p=Ag(h.dom);if(p.length!=1)return;a+=p[0].width,u=p[0].height}if(a)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:a/o.length,textHeight:u}}});if(e)return e;let i=document.createElement("div"),n,s,r;return i.className="cm-line",i.style.width="99999px",i.style.position="absolute",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(i);let o=Ag(i.firstChild)[0];n=i.getBoundingClientRect().height,s=o&&o.width?o.width/27:7,r=o&&o.height?o.height:n,i.remove()}),{lineHeight:n,charWidth:s,textHeight:r}}computeBlockGapDeco(){let e=[],i=this.view.viewState;for(let n=0,s=0;;s++){let r=s==i.viewports.length?null:i.viewports[s],o=r?r.from-1:this.view.state.doc.length;if(o>n){let a=(i.lineBlockAt(o).bottom-i.lineBlockAt(n).top)/this.view.scaleY;e.push(_t.replace({widget:new Z1(a),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!r)break;n=r.to+1}return _t.set(e)}updateDeco(){let e=1,i=this.view.state.facet(nv).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),n=!1,s=this.view.state.facet(yS).map((r,o)=>{let a=typeof r=="function";return a&&(n=!0),a?r(this.view):r});for(s.length&&(this.dynamicDecorationMap[e++]=n,i.push(Rt.join(s))),this.decorations=[this.editContextFormatting,...i,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet($3).map(r=>typeof r=="function"?r(this.view):r)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(I3))try{if(h(this.view,e.range,e))return!0}catch(p){So(this.view.state,p,"scroll handler")}let{range:i}=e,n=this.coordsAt(i.head,i.assoc||(i.head>i.anchor?-1:1)),s;if(!n)return;!i.empty&&(s=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,s.left),top:Math.min(n.top,s.top),right:Math.max(n.right,s.right),bottom:Math.max(n.bottom,s.bottom)});let r=W3(this.view),o={left:n.left-r.left,top:n.top-r.top,right:n.right+r.right,bottom:n.bottom+r.bottom},{offsetWidth:a,offsetHeight:u}=this.view.scrollDOM;if(rq(this.view.scrollDOM,o,i.head<i.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,a),-a),Math.max(Math.min(e.yMargin,u),-u),this.view.textDirection==Mi.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.visualViewport.offsetTop)){let h=this.view.docView.lineAt(i.head,1);if(h){let p=_3(h.dom);h.dom.scrollIntoView({block:"nearest"}),y3(p,!1)}}}lineHasWidget(e){let i=n=>n.isWidget()||n.children.some(i);return i(this.tile.resolveBlock(e,1).tile)}destroy(){Kx(this.tile)}}function Kx(t,e){let i=e?.get(t);if(i!=1){i==null&&t.destroy();for(let n of t.children)Kx(n,e)}}function Nq(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function U3(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let n=w3(i.focusNode,i.focusOffset),s=S3(i.focusNode,i.focusOffset),r=n||s;if(s&&n&&s.node!=n.node){let a=Pi.get(s.node);if(!a||a.isText()&&a.text!=s.node.nodeValue)r=s;else if(t.docView.lastCompositionAfterCursor){let u=Pi.get(n.node);!u||u.isText()&&u.text!=n.node.nodeValue||(r=s)}}if(t.docView.lastCompositionAfterCursor=r!=n,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function jq(t,e,i){let n=U3(t,i);if(!n)return null;let{node:s,from:r,to:o}=n,a=s.nodeValue;if(/[\n\r]/.test(a)||t.state.doc.sliceString(n.from,n.to)!=a)return null;let u=e.invertedDesc;return{range:new Rr(u.mapPos(r),u.mapPos(o),r,o),text:s}}function Rq(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e<t.childNodes.length&&t.childNodes[e].contentEditable=="false"?2:0)}let Dq=class{constructor(){this.changes=[]}compareRange(e,i){nh(e,i,this.changes)}comparePoint(e,i){nh(e,i,this.changes)}boundChange(e){nh(e,e,this.changes)}};function Bq(t,e,i){let n=new Dq;return Rt.compare(t,e,i,n),n.changes}class Oq{constructor(){this.changes=[]}compareRange(e,i){nh(e,i,this.changes)}comparePoint(){}boundChange(e){nh(e,e,this.changes)}}function Iq(t,e,i){let n=new Oq;return Rt.compare(t,e,i,n),n.changes}function Pq(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(i.nodeType==1&&i.contentEditable=="false")return!0;return!1}function zq(t,e){let i=!1;return e&&t.iterChangedRanges((n,s)=>{n<e.to&&s>e.from&&(i=!0)}),i}class Z1 extends Lh{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function $q(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),r=e-s.from;if(s.length==0)return Se.cursor(e);r==0?i=1:r==s.length&&(i=-1);let o=r,a=r;i<0?o=An(s.text,r,!1):a=An(s.text,r);let u=n(s.text.slice(o,a));for(;o>0;){let h=An(s.text,o,!1);if(n(s.text.slice(h,o))!=u)break;o=h}for(;a<s.length;){let h=An(s.text,a);if(n(s.text.slice(a,h))!=u)break;a=h}return Se.undirectionalRange(o+s.from,a+s.from)}function Fq(t,e,i,n,s){let r=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>t.defaultLineHeight*1.5){let a=t.viewState.heightOracle.textHeight,u=Math.floor((s-i.top-(t.defaultLineHeight-a)*.5)/a);r+=u*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+Bx(o,r,t.state.tabSize)}function Yx(t,e,i){let n=t.lineBlockAt(e);if(Array.isArray(n.type)){let s;for(let r of n.type){if(r.from>e)break;if(!(r.to<e)){if(r.from<e&&r.to>e)return r;(!s||r.type==$n.Text&&(s.type!=r.type||(i<0?r.from<e:r.to>e)))&&(s=r)}}return s||n}return n}function Hq(t,e,i,n){let s=Yx(t,e.head,e.assoc||-1),r=!n||s.type!=$n.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(r){let o=t.dom.getBoundingClientRect(),a=t.textDirectionAt(s.from),u=t.posAtCoords({x:i==(a==Mi.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(u!=null)return Se.cursor(u,i?-1:1)}return Se.cursor(i?s.to:s.from,i?-1:1)}function nM(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=t.bidiSpans(s),o=t.textDirectionAt(s.from);for(let a=e,u=null;;){let h=gq(s,r,o,a,i),p=A3;if(!h){if(s.number==(i?t.state.doc.lines:1))return a;p=`
|
|
55
|
+
`,s=t.state.doc.line(s.number+(i?1:-1)),r=t.bidiSpans(s),h=t.visualLineSide(s,!i)}if(u){if(!u(p))return a}else{if(!n)return h;u=n(p)}a=h}}function Wq(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return r=>{let o=n(r);return s==Ki.Space&&(s=o),s==o}}function qq(t,e,i,n){let s=e.head,r=i?1:-1;if(s==(i?t.state.doc.length:0))return Se.cursor(s,e.assoc);let o=e.goalColumn,a,u=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?i:e.head==e.from)?1:-1)),p=t.documentTop;if(h)o==null&&(o=h.left-u.left),a=r<0?h.top:h.bottom;else{let x=t.viewState.lineBlockAt(s);o==null&&(o=Math.min(u.right-u.left,t.defaultCharacterWidth*(s-x.from))),a=(r<0?x.top:x.bottom)+p}let m=u.left+o,v=t.viewState.heightOracle.textHeight>>1,_=n??v;for(let x=0;;x+=v){let S=a+(_+x)*r,C=Gx(t,{x:m,y:S},!1,r);if(i?S>u.bottom:S<u.top)return Se.cursor(C.pos,C.assoc);let k=t.coordsAtPos(C.pos,C.assoc),M=k?(k.top+k.bottom)/2:0;if(!k||(i?M>a:M<a))return Se.cursor(C.pos,C.assoc,void 0,o)}}function wf(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,(r,o,a)=>{if(e>r&&e<o){let u=n||i||(e-r<o-e?-1:1);e=u<0?r:o,n=u}});if(!n)return e}}function V3(t,e){let i=null;for(let n=0;n<e.ranges.length;n++){let s=e.ranges[n],r=null;if(s.empty){let o=wf(t,s.from,0);o!=s.from&&(r=Se.cursor(o,-1))}else{let o=wf(t,s.from,-1),a=wf(t,s.to,1);(o!=s.from||a!=s.to)&&(s.undirectional?r=Se.undirectionalRange(s.from,s.to):r=Se.range(s.from==s.anchor?o:a,s.from==s.head?o:a))}r&&(i||(i=e.ranges.slice()),i[n]=r)}return i?Se.create(i,e.mainIndex):e}function J1(t,e,i){let n=wf(t.state.facet(ep).map(s=>s(t)),i.from,e.head>i.from?-1:1);return n==i.from?i:Se.cursor(n,n<i.from?1:-1)}class bo{constructor(e,i){this.pos=e,this.assoc=i}}function Gx(t,e,i,n){let s=t.contentDOM.getBoundingClientRect(),r=s.top+t.viewState.paddingTop,{x:o,y:a}=e,u=a-r,h;for(;;){if(u<0)return new bo(0,1);if(u>t.viewState.docHeight)return new bo(t.state.doc.length,-1);if(h=t.elementAtHeight(u),n==null)break;if(h.type==$n.Text){if(n<0?h.to<t.viewport.from:h.from>t.viewport.to)break;let v=t.docView.coordsAt(n<0?h.from:h.to,n>0?-1:1);if(v&&(n<0?v.top<=u+r:v.bottom>=u+r))break}let m=t.viewState.heightOracle.textHeight/2;u=n>0?h.bottom+m:h.top-m}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(i)return null;if(h.type==$n.Text){let m=Fq(t,s,h,o,a);return new bo(m,m==h.from?1:-1)}}if(h.type!=$n.Text)return u<(h.top+h.bottom)/2?new bo(h.from,1):new bo(h.to,-1);let p=t.docView.lineAt(h.from,2);return(!p||p.length!=h.length)&&(p=t.docView.lineAt(h.from,-2)),new Uq(t,o,a,t.textDirectionAt(h.from)).scanTile(p,h.from)}class Uq{constructor(e,i,n,s){this.view=e,this.x=i,this.y=n,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,i){let{line:n,spans:s}=this.bidiSpansAt(e);return s[wo.find(s,e-n.from,-1,i)].level==this.baseDir}dirAt(e,i){let{line:n,spans:s}=this.bidiSpansAt(e);return s[wo.find(s,e-n.from,-1,i)].dir}bidiIn(e,i){let{spans:n,line:s}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+s.from<i)}scan(e,i,n=!1){let s=0,r=e.length-1,o=new Set,a=this.bidiIn(e[0],e[r]),u,h,p=-1,m=1e9,v;e:for(;s<r;){let x=r-s,S=s+r>>1;t:if(o.has(S)){for(let M=1;M<x;M++){let L=S+M;if(L>=r&&(L-=x),!o.has(L)){S=L;break t}}break e}o.add(S);let C=i(S),k=0;if(C)for(let M=0;M<C.length;M++){let L=C[M];if(!(L.width==0&&C.length>1))if(L.bottom<this.y)(!u||u.bottom<L.bottom)&&(u=L),k=1;else if(L.top>this.y)(!h||h.top>L.top)&&(h=L),k=-1;else{let N=L.left>this.x?this.x-L.left:L.right<this.x?this.x-L.right:0,j=Math.abs(N);j<m&&(p=S,m=j,v=L),N&&(k=N<0==(this.baseDir==Mi.LTR)?-1:1)}}k==-1&&(!a||this.baseDirAt(e[S],1))?r=S:k==1&&(!a||this.baseDirAt(e[S+1],-1))&&(s=S+1)}if(!v){if(!h&&!u)return{i:e[0],after:!1};let x=u&&(!h||this.y-u.bottom<h.top-this.y)?u:h;return this.y=(x.top+x.bottom)/2,this.scan(e,i,!0)}if(m&&!n){let{top:x,bottom:S}=v;if(u&&u.bottom>(x+x+S)/3)return this.y=u.bottom-1,this.scan(e,i,!0);if(h&&h.top<(x+S+S)/3)return this.y=h.top+1,this.scan(e,i,!0)}let _=(a?this.dirAt(e[p],1):this.baseDir)==Mi.LTR;return{i:p,after:this.x>(v.left+v.right)/2==_}}scanText(e,i){let n=[];for(let r=0;r<e.length;r=An(e.text,r))n.push(i+r);n.push(i+e.length);let s=this.scan(n,r=>{let o=n[r]-i,a=n[r+1]-i;return jf(e.dom,o,a).getClientRects()});return s.after?new bo(n[s.i+1],-1):new bo(n[s.i],1)}scanTile(e,i){if(!e.length)return new bo(i,1);if(e.children.length==1){let a=e.children[0];if(a.isText())return this.scanText(a,i);if(a.isComposite())return this.scanTile(a,i)}let n=[i];for(let a=0,u=i;a<e.children.length;a++)n.push(u+=e.children[a].length);let s=this.scan(n,a=>{let u=e.children[a];return u.flags&48?null:(u.dom.nodeType==1?u.dom:jf(u.dom,0,u.length)).getClientRects()}),r=e.children[s.i],o=n[s.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):s.after?new bo(n[s.i+1],-1):new bo(o,1)}}const $u="";class Vq{constructor(e,i){this.points=e,this.view=i,this.text="",this.lineSeparator=i.state.facet(It.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=$u}readRange(e,i){if(!e)return this;let n=e.parentNode;for(let s=e;;){this.findPointBefore(n,s);let r=this.text.length;this.readNode(s);let o=Pi.get(s),a=s.nextSibling;if(a==i){o?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let u=Pi.get(a);(o&&u?o.breakAfter:(o?o.breakAfter:p0(s))||p0(a)&&(s.nodeName!="BR"||o?.isWidget())&&this.text.length>r)&&!Yq(a,i)&&this.lineBreak(),s=a}return this.findPointBefore(n,i),this}readTextNode(e){let i=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,i.length));for(let n=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,a;if(this.lineSeparator?(r=i.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(a=s.exec(i))&&(r=a.index,o=a[0].length),this.append(i.slice(n,r<0?i.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let u of this.points)u.node==e&&u.pos>this.text.length&&(u.pos-=o-1);n=r+o}}readNode(e){let i=Pi.get(e),n=i&&i.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let s=n.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,i){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==i&&(n.pos=this.text.length)}findPointInside(e,i){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Kq(e,n.node,n.offset)?i:0))}}function Kq(t,e,i){for(;;){if(!e||i<kl(e))return!1;if(e==t)return!0;i=Na(e)+1,e=e.parentNode}}function Yq(t,e){let i;for(;!(t==e||!t);t=t.nextSibling){let n=Pi.get(t);if(!n?.isWidget())return!1;n&&(i||(i=[])).push(n)}if(i)for(let n of i){let s=n.overrideDOMText;if(s?.length)return!1}return!0}class sM{constructor(e,i){this.node=e,this.offset=i,this.pos=-1}}class Gq{constructor(e,i,n,s){this.typeOver=s,this.bounds=null,this.text="",this.domChanged=i>-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView,a=e.state.selection;if(e.state.readOnly&&i>-1)this.newSel=null;else if(i>-1&&(this.bounds=K3(e.docView.tile,i,n,0))){let u=r||o?[]:Xq(e),h=new Vq(u,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=Zq(u,this.bounds.from)}else{let u=e.observer.selectionRange,h=r&&r.node==u.focusNode&&r.offset==u.focusOffset||!Hx(e.contentDOM,u.focusNode)?a.main.head:e.docView.posFromDOM(u.focusNode,u.focusOffset),p=o&&o.node==u.anchorNode&&o.offset==u.anchorOffset||!Hx(e.contentDOM,u.anchorNode)?a.main.anchor:e.docView.posFromDOM(u.anchorNode,u.anchorOffset),m=e.viewport;if((Oe.ios||Oe.chrome)&&h!=p&&Math.min(h,p)<=a.main.from&&Math.max(h,p)>=a.main.to&&(m.from>0||m.to<e.state.doc.length)){let v=Math.min(h,p),_=Math.max(h,p),x=m.from-v,S=m.to-_;(x==0||x==1||v==0)&&(S==0||S==-1||_==e.state.doc.length)&&(h=0,p=e.state.doc.length)}if(e.inputState.composing>-1&&a.ranges.length>1)this.newSel=a.replaceRange(Se.range(p,h));else if(e.lineWrapping&&p==h&&!(a.main.empty&&a.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),_=0;v&&(_=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=Se.create([Se.cursor(h,_)])}else this.newSel=Se.single(p,h)}}}function K3(t,e,i,n){if(t.isComposite()){let s=-1,r=-1,o=-1,a=-1;for(let u=0,h=n,p=n;u<t.children.length;u++){let m=t.children[u],v=h+m.length;if(h<e&&v>i)return K3(m,e,i,h);if(v>=e&&s==-1&&(s=u,r=h),h>i&&m.dom.parentNode==t.dom){o=u,a=p;break}p=v,h=v+m.breakAfter}return{from:r,to:a<0?n+t.length:a,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o<t.children.length&&o>=0?t.children[o].dom:null}}else return t.isText()?{from:n,to:n+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Y3(t,e){let i,{newSel:n}=e,{state:s}=t,r=s.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:a,to:u}=e.bounds,h=r.from,p=null;(o===8||Oe.android&&e.text.length<u-a)&&(h=r.to,p="end");let m=s.doc.sliceString(a,u,$u),v,_;!r.empty&&r.from>=a&&r.to<=u&&(e.typeOver||m!=e.text)&&m.slice(0,r.from-a)==e.text.slice(0,r.from-a)&&m.slice(r.to-a)==e.text.slice(v=e.text.length-(m.length-(r.to-a)))?i={from:r.from,to:r.to,insert:Vt.of(e.text.slice(r.from-a,v).split($u))}:(_=G3(m,e.text,h-a,p))&&(Oe.chrome&&o==13&&_.toB==_.from+2&&e.text.slice(_.from,_.toB)==$u+$u&&_.toB--,i={from:a+_.from,to:a+_.toA,insert:Vt.of(e.text.slice(_.from,_.toB).split($u))})}else n&&(!t.hasFocus&&s.facet(_l)||y0(n,r))&&(n=null);if(!i&&!n)return!1;if((Oe.mac||Oe.android)&&i&&i.from==i.to&&i.from==r.head-1&&/^\. ?$/.test(i.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(n&&i.insert.length==2&&(n=Se.single(n.main.anchor-1,n.main.head-1)),i={from:i.from,to:i.to,insert:Vt.of([i.insert.toString().replace("."," ")])}):s.doc.lineAt(r.from).to<r.to&&t.docView.lineHasWidget(r.to)&&t.inputState.insertingTextAt>Date.now()-50?i={from:r.from,to:r.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&i&&i.from==i.to&&i.from==r.head&&i.insert.toString()==`
|
|
56
|
+
`&&t.lineWrapping&&(n&&(n=Se.single(n.main.anchor-1,n.main.head-1)),i={from:r.from,to:r.to,insert:Vt.of([" "])}),i)return xS(t,i,n,o);if(n&&!y0(n,r)){let a=!1,u="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(a=!0),u=t.inputState.lastSelectionOrigin,u=="select.pointer"&&(n=V3(s.facet(ep).map(h=>h(t)),n))),t.dispatch({selection:n,scrollIntoView:a,userEvent:u}),!0}else return!1}function xS(t,e,i,n=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&sh(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>s.head)&&sh(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&sh(t.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,a=()=>o||(o=Qq(t,e,i));return t.state.facet(R3).some(u=>u(t,e.from,e.to,r,a))||t.dispatch(a()),!0}function Qq(t,e,i){let n,s=t.state,r=s.selection.main,o=-1;if(e.from==e.to&&e.from<r.from||e.from>r.to){let u=e.from<r.from?-1:1,h=u<0?r.from:r.to,p=wf(s.facet(ep).map(m=>m(t)),h,u);e.from==p&&(o=p)}if(o>-1)n={changes:e,selection:Se.cursor(e.from+e.insert.length,-1)};else if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let u=r.from<e.from?s.sliceDoc(r.from,e.from):"",h=r.to>e.to?s.sliceDoc(e.to,r.to):"";n=s.replaceSelection(t.state.toText(u+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let u=s.changes(e),h=i&&i.main.to<=u.newLength?i.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=r.to+10&&e.to>=r.to-10){let p=t.state.sliceDoc(e.from,e.to),m,v=i&&U3(t,i.main.head);if(v){let x=e.insert.length-(e.to-e.from);m={from:v.from,to:v.to-x}}else m=t.state.doc.lineAt(r.head);let _=r.to-e.to;n=s.changeByRange(x=>{if(x.from==r.from&&x.to==r.to)return{changes:u,range:h||x.map(u)};let S=x.to-_,C=S-p.length;if(t.state.sliceDoc(C,S)!=p||S>=m.from&&C<=m.to)return{range:x};let k=s.changes({from:C,to:S,insert:e.insert}),M=x.to-r.to;return{changes:k,range:h?Se.range(Math.max(0,h.anchor+M),Math.max(0,h.head+M)):x.map(k)}})}else n={changes:u,selection:h&&s.selection.replaceRange(h)}}let a="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,a+=".compose",t.inputState.compositionFirstChange&&(a+=".start",t.inputState.compositionFirstChange=!1)),s.update(n,{userEvent:a,scrollIntoView:!0})}function G3(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,a=e.length;for(;o>0&&a>0&&t.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(n=="end"){let u=Math.max(0,r-Math.min(o,a));i-=o+u-r}if(o<r&&t.length<e.length){let u=i<=r&&i>=o?r-i:0;r-=u,a=r+(a-o),o=r}else if(a<r){let u=i<=r&&i>=a?r-i:0;r-=u,o=r+(o-a),a=r}return{from:r,toA:o,toB:a}}function Xq(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;return i&&(e.push(new sM(i,n)),(s!=i||r!=n)&&e.push(new sM(s,r))),e}function Zq(t,e){if(t.length==0)return null;let i=t[0].pos,n=t.length==2?t[1].pos:i;return i>-1&&n>-1?Se.single(i+e,n+e):null}function y0(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class Jq{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&mU(e.contentDOM.ownerDocument)}handleEvent(e){!aU(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,i){let n=this.handlers[e];if(n){for(let s of n.observers)s(this.view,i);for(let s of n.handlers){if(i.defaultPrevented)break;if(s(this.view,i)){i.preventDefault();break}}}}ensureHandlers(e){let i=tU(e),n=this.handlers,s=this.view.contentDOM;for(let r in i)if(r!="scroll"){let o=!i[r].handlers.length,a=n[r];a&&o!=!a.handlers.length&&(s.removeEventListener(r,this.handleEvent),a=null),a||s.addEventListener(r,this.handleEvent,{passive:o})}for(let r in n)r!="scroll"&&!i[r]&&s.removeEventListener(r,this.handleEvent);this.handlers=i}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&X3.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Q3.some(i=>i.keyCode==e.keyCode)&&!e.ctrlKey||iU.indexOf(e.key)>-1&&e.ctrlKey)){let i={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return i.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&eU(this.view.win)&&(i.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:i},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let i=this.pendingIOSKey;return!i||i.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,sh(this.view.contentDOM,i.key,i.keyCode,i.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:Oe.safari&&!Oe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function eU(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function rM(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(s){So(i.state,s)}}}function tU(t){let e=Object.create(null);function i(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of t){let s=n.spec,r=s&&s.plugin.domEventHandlers,o=s&&s.plugin.domEventObservers;if(r)for(let a in r){let u=r[a];u&&i(a).handlers.push(rM(n.value,u))}if(o)for(let a in o){let u=o[a];u&&i(a).observers.push(rM(n.value,u))}}for(let n in Xr)i(n).handlers.push(Xr[n]);for(let n in fs)i(n).observers.push(fs[n]);return e}const Q3=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],iU="dthko",X3=[16,17,18,20,91,92,224,225],Hm=6;function Wm(t){return Math.max(0,t)*.7+8}function nU(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class sU{constructor(e,i,n,s){this.view=e,this.startEvent=i,this.style=n,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=i,this.scrollParents=v3(e.contentDOM),this.atoms=e.state.facet(ep).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=i.shiftKey,this.multiple=e.state.facet(It.allowMultipleSelections)&&rU(e,i),this.dragging=lU(e,i)&&eR(i)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&nU(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let i=0,n=0,s=0,r=0,o=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:a}=this.scrollParents.y.getBoundingClientRect());let u=W3(this.view);e.clientX-u.left<=s+Hm?i=-Wm(s-e.clientX):e.clientX+u.right>=o-Hm&&(i=Wm(e.clientX-o)),e.clientY-u.top<=r+Hm?n=-Wm(r-e.clientY):e.clientY+u.bottom>=a-Hm&&(n=Wm(e.clientY-a)),this.setScrollSpeed(i,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,i){this.scrollSpeed={x:e,y:i},e||i?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:i}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),i&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=i,i=0),(e||i)&&this.view.win.scrollBy(e,i),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:i}=this,n=V3(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(i.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(i=>i.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function rU(t,e){let i=t.state.facet(L3);return i.length?i[0](e):Oe.mac?e.metaKey:e.ctrlKey}function oU(t,e){let i=t.state.facet(T3);return i.length?i[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function lU(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=Nf(t.root);if(!n||n.rangeCount==0)return!0;let s=n.getRangeAt(0).getClientRects();for(let r=0;r<s.length;r++){let o=s[r];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function aU(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i=e.target,n;i!=t.contentDOM;i=i.parentNode)if(!i||i.nodeType==11||(n=Pi.get(i))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(e))return!1;return!0}const Xr=Object.create(null),fs=Object.create(null),Z3=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function cU(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{t.focus(),i.remove(),J3(t,i.value)},50)}function ov(t,e,i){for(let n of t.facet(e))i=n(i,t);return i}function J3(t,e){e=ov(t.state,gS,e);let{state:i}=t,n,s=1,r=i.toText(e),o=r.lines==i.selection.ranges.length;if(Qx!=null&&i.selection.ranges.every(u=>u.empty)&&Qx==r.toString()){let u=-1;n=i.changeByRange(h=>{let p=i.doc.lineAt(h.from);if(p.from==u)return{range:h};u=p.from;let m=i.toText((o?r.line(s++).text:e)+i.lineBreak);return{changes:{from:p.from,insert:m},range:Se.cursor(h.from+m.length)}})}else o?n=i.changeByRange(u=>{let h=r.line(s++);return{changes:{from:u.from,to:u.to,insert:h.text},range:Se.cursor(u.from+h.length)}}):n=i.replaceSelection(r);t.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}fs.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};fs.wheel=fs.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};Xr.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);fs.touchstart=(t,e)=>{let i=t.inputState,n=e.targetTouches[0];i.touchActive=!0,i.lastTouchTime=Date.now(),n&&(i.lastTouchX=n.clientX,i.lastTouchY=n.clientY),i.setSelectionOrigin("select.pointer")};fs.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};fs.touchend=(t,e)=>{t.inputState.touchActive=!1};Xr.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(N3))if(i=n(t,e),i)break;if(!i&&e.button==0&&(i=hU(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new sU(t,e,i,n)),n&&t.observer.ignore(()=>{x3(t.contentDOM);let r=t.root.activeElement;r&&!r.contains(t.contentDOM)&&r.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function oM(t,e,i,n){if(n==1)return Se.cursor(e,i);if(n==2)return $q(t.state,e,i);{let s=t.docView.lineAt(e,i),r=t.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,a=s?s.posAtEnd:r.to;return a<t.state.doc.length&&a==r.to&&a++,Se.undirectionalRange(o,a)}}const uU=Oe.ie&&Oe.ie_version<=11;let lM=null,aM=0,cM=0;function eR(t){if(!uU)return t.detail;let e=lM,i=cM;return lM=t,cM=Date.now(),aM=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(aM+1)%3:1}function hU(t,e){let i=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),n=eR(e),s=t.state.selection;return{update(r){r.docChanged&&(i.pos=r.changes.mapPos(i.pos),s=s.map(r.changes))},get(r,o,a){let u=t.posAndSideAtCoords({x:r.clientX,y:r.clientY},!1),h,p=oM(t,u.pos,u.assoc,n);if(i.pos!=u.pos&&!o){let m=oM(t,i.pos,i.assoc,n),v=Math.min(m.from,p.from),_=Math.max(m.to,p.to);p=v<p.from?Se.range(v,_,p.assoc):Se.range(_,v,p.assoc)}return o?s.replaceRange(s.main.extend(p.from,p.to,p.assoc)):a&&n==1&&s.ranges.length>1&&(h=dU(s,u.pos))?h:a?s.addRange(p):Se.create([p])}}}function dU(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return Se.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}Xr.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let r=s.posAtStart,o=r+s.length;(r>=i.to||o<=i.from)&&(i=Se.undirectionalRange(r,o))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",ov(t.state,vS,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Xr.dragend=t=>(t.inputState.draggedContent=null,!1);function uM(t,e,i,n){if(i=ov(t.state,gS,i),!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=t.inputState,o=n&&r&&oU(t,e)?{from:r.from,to:r.to}:null,a={from:s,insert:i},u=t.state.changes(o?[o,a]:a);t.focus(),t.dispatch({changes:u,selection:{anchor:u.mapPos(s,-1),head:u.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Xr.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),s=0,r=()=>{++s==i.length&&uM(t,e,n.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o<i.length;o++){let a=new FileReader;a.onerror=r,a.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(n[o]=a.result),r()},a.readAsText(i[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return uM(t,e,n,!0),!0}return!1};Xr.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=Z3?null:e.clipboardData;return i?(J3(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(cU(t),!1)};function fU(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),t.focus()},50)}function pU(t){let e=[],i=[],n=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),i.push(s));if(!e.length){let s=-1;for(let{from:r}of t.selection.ranges){let o=t.doc.lineAt(r);o.number>s&&(e.push(o.text),i.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),s=o.number}n=!0}return{text:ov(t,vS,e.join(t.lineBreak)),ranges:i,linewise:n}}let Qx=null;Xr.copy=Xr.cut=(t,e)=>{if(!xf(t.contentDOM,t.observer.selectionRange))return!1;let{text:i,ranges:n,linewise:s}=pU(t.state);if(!i&&!s)return!1;Qx=s?i:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=Z3?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",i),!0):(fU(t,i),!1)};const tR=Ba.define();function iR(t,e){let i=[];for(let n of t.facet(D3)){let s=n(t,e);s&&i.push(s)}return i.length?t.update({effects:i,annotations:tR.of(!0)}):null}function nR(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=iR(t.state,e);i?t.dispatch(i):t.update([])}},10)}fs.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),nR(t)};fs.blur=t=>{t.observer.clearSelectionRange(),nR(t)};fs.compositionstart=fs.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};fs.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};fs.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Xr.beforeinput=(t,e)=>{var i,n;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let r=(i=e.dataTransfer)===null||i===void 0?void 0:i.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let a=o[0],u=t.posAtDOM(a.startContainer,a.startOffset),h=t.posAtDOM(a.endContainer,a.endOffset);return xS(t,{from:u,to:h,insert:t.state.toText(r)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Q3.find(r=>r.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let r=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>fs.compositionend(t,e),20),!1};const hM=new Set;function mU(t){hM.has(t)||(hM.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const dM=["pre-wrap","normal","pre-line","break-spaces"];let gh=!1;function fM(){gh=!1}class gU{constructor(e){this.lineWrapping=e,this.doc=Vt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,i){let n=this.doc.lineAt(i).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((i-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return dM.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let i=!1;for(let n=0;n<e.length;n++){let s=e[n];s<0?n++:this.heightSamples[Math.floor(s*10)]||(i=!0,this.heightSamples[Math.floor(s*10)]=!0)}return i}refresh(e,i,n,s,r,o){let a=dM.indexOf(e)>-1,u=Math.abs(i-this.lineHeight)>.3||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=i,this.charWidth=n,this.textHeight=s,this.lineLength=r,u){this.heightSamples={};for(let h=0;h<o.length;h++){let p=o[h];p<0?h++:this.heightSamples[Math.floor(p*10)]=!0}}return u}}class vU{constructor(e,i){this.from=e,this.heights=i,this.index=0}get more(){return this.index<this.heights.length}}class Yr{constructor(e,i,n,s,r){this.from=e,this.length=i,this.top=n,this.height=s,this._content=r}get type(){return typeof this._content=="number"?$n.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Dc?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let i=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Yr(this.from,this.length+e.length,this.top,this.height+e.height,i)}}var mi=(function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t})(mi||(mi={}));const Lg=.001;class hs{constructor(e,i,n=2){this.length=e,this.height=i,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Lg&&(gh=!0),this.height=e)}replace(e,i,n){return hs.of(n)}decomposeLeft(e,i){i.push(this)}decomposeRight(e,i){i.push(this)}applyChanges(e,i,n,s){let r=this,o=n.doc;for(let a=s.length-1;a>=0;a--){let{fromA:u,toA:h,fromB:p,toB:m}=s[a],v=r.lineAt(u,mi.ByPosNoHeight,n.setDoc(i),0,0),_=v.to>=h?v:r.lineAt(h,mi.ByPosNoHeight,n,0,0);for(m+=_.to-h,h=_.to;a>0&&v.from<=s[a-1].toA;)u=s[a-1].fromA,p=s[a-1].fromB,a--,u<v.from&&(v=r.lineAt(u,mi.ByPosNoHeight,n,0,0));p+=v.from-u,u=v.from;let x=bS.build(n.setDoc(o),e,p,m);r=x0(r,r.replace(u,h,x))}return r.updateHeight(n,0)}static empty(){return new sr(0,0,0)}static of(e){if(e.length==1)return e[0];let i=0,n=e.length,s=0,r=0;for(;;)if(i==n)if(s>r*2){let a=e[i-1];a.break?e.splice(--i,1,a.left,null,a.right):e.splice(--i,1,a.left,a.right),n+=1+a.break,s-=a.size}else if(r>s*2){let a=e[n];a.break?e.splice(n,1,a.left,null,a.right):e.splice(n,1,a.left,a.right),n+=2+a.break,r-=a.size}else break;else if(s<r){let a=e[i++];a&&(s+=a.size)}else{let a=e[--n];a&&(r+=a.size)}let o=0;return e[i-1]==null?(o=1,i--):e[i]==null&&(o=1,n++),new yU(hs.of(e.slice(0,i)),o,hs.of(e.slice(n)))}}function x0(t,e){return t==e?t:(t.constructor!=e.constructor&&(gh=!0),e)}hs.prototype.size=1;const _U=_t.replace({});class sR extends hs{constructor(e,i,n){super(e,i),this.deco=n,this.spaceAbove=0}mainBlock(e,i){return new Yr(i,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,i,n,s){return this.spaceAbove&&e<n+this.spaceAbove?new Yr(s,0,n,this.spaceAbove,_U):this.mainBlock(n,s)}lineAt(e,i,n,s,r){let o=this.mainBlock(s,r);return this.spaceAbove?this.blockAt(0,n,s,r).join(o):o}forEachLine(e,i,n,s,r,o){e<=r+this.length&&i>=r&&o(this.lineAt(0,mi.ByPos,n,s,r))}setMeasuredHeight(e){let i=e.heights[e.index++];i<0?(this.spaceAbove=-i,i=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(i)}updateHeight(e,i=0,n=!1,s){return s&&s.from<=i&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class sr extends sR{constructor(e,i,n){super(e,i,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,i){return new Yr(i,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,i,n){let s=n[0];return n.length==1&&(s instanceof sr||s instanceof In&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof In?s=new sr(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):hs.of(n)}updateHeight(e,i=0,n=!1,s){return s&&s.from<=i&&s.more?this.setMeasuredHeight(s):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class In extends hs{constructor(e){super(e,0)}heightMetrics(e,i){let n=e.doc.lineAt(i).number,s=e.doc.lineAt(i+this.length).number,r=s-n+1,o,a=0;if(e.lineWrapping){let u=Math.min(this.height,e.lineHeight*r);o=u/r,this.length>r+1&&(a=(this.height-u)/(this.length-r-1))}else o=this.height/r;return{firstLine:n,lastLine:s,perLine:o,perChar:a}}blockAt(e,i,n,s){let{firstLine:r,lastLine:o,perLine:a,perChar:u}=this.heightMetrics(i,s);if(i.lineWrapping){let h=s+(e<i.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),p=i.doc.lineAt(h),m=a+p.length*u,v=Math.max(n,e-m/2);return new Yr(p.from,p.length,v,m,0)}else{let h=Math.max(0,Math.min(o-r,Math.floor((e-n)/a))),{from:p,length:m}=i.doc.line(r+h);return new Yr(p,m,n+a*h,a,0)}}lineAt(e,i,n,s,r){if(i==mi.ByHeight)return this.blockAt(e,n,s,r);if(i==mi.ByPosNoHeight){let{from:_,to:x}=n.doc.lineAt(e);return new Yr(_,x-_,0,0,0)}let{firstLine:o,perLine:a,perChar:u}=this.heightMetrics(n,r),h=n.doc.lineAt(e),p=a+h.length*u,m=h.number-o,v=s+a*m+u*(h.from-r-m);return new Yr(h.from,h.length,Math.max(s,Math.min(v,s+this.height-p)),p,0)}forEachLine(e,i,n,s,r,o){e=Math.max(e,r),i=Math.min(i,r+this.length);let{firstLine:a,perLine:u,perChar:h}=this.heightMetrics(n,r);for(let p=e,m=s;p<=i;){let v=n.doc.lineAt(p);if(p==e){let x=v.number-a;m+=u*x+h*(e-r-x)}let _=u+h*v.length;o(new Yr(v.from,v.length,m,_,0)),m+=_,p=v.to+1}}replace(e,i,n){let s=this.length-i;if(s>0){let r=n[n.length-1];r instanceof In?n[n.length-1]=new In(r.length+s):n.push(null,new In(s-1))}if(e>0){let r=n[0];r instanceof In?n[0]=new In(e+r.length):n.unshift(new In(e-1),null)}return hs.of(n)}decomposeLeft(e,i){i.push(new In(e-1),null)}decomposeRight(e,i){i.push(null,new In(this.length-e-1))}updateHeight(e,i=0,n=!1,s){let r=i+this.length;if(s&&s.from<=i+this.length&&s.more){let o=[],a=Math.max(i,s.from),u=-1;for(s.from>i&&o.push(new In(s.from-i-1).updateHeight(e,i));a<=r&&s.more;){let p=e.doc.lineAt(a).length;o.length&&o.push(null);let m=s.heights[s.index++],v=0;m<0&&(v=-m,m=s.heights[s.index++]),u==-1?u=m:Math.abs(m-u)>=Lg&&(u=-2);let _=new sr(p,m,v);_.outdated=!1,o.push(_),a+=p+1}a<=r&&o.push(null,new In(r-a).updateHeight(e,a));let h=hs.of(o);return(u<0||Math.abs(h.height-this.height)>=Lg||Math.abs(u-this.heightMetrics(e,i).perLine)>=Lg)&&(gh=!0),x0(this,h)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(i,i+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class yU extends hs{constructor(e,i,n){super(e.length+i+n.length,e.height+n.height,i|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,i,n,s){let r=n+this.left.height;return e<r?this.left.blockAt(e,i,n,s):this.right.blockAt(e,i,r,s+this.left.length+this.break)}lineAt(e,i,n,s,r){let o=s+this.left.height,a=r+this.left.length+this.break,u=i==mi.ByHeight?e<o:e<a,h=u?this.left.lineAt(e,i,n,s,r):this.right.lineAt(e,i,n,o,a);if(this.break||(u?h.to<a:h.from>a))return h;let p=i==mi.ByPosNoHeight?mi.ByPosNoHeight:mi.ByPos;return u?h.join(this.right.lineAt(a,p,n,o,a)):this.left.lineAt(a,p,n,s,r).join(h)}forEachLine(e,i,n,s,r,o){let a=s+this.left.height,u=r+this.left.length+this.break;if(this.break)e<u&&this.left.forEachLine(e,i,n,s,r,o),i>=u&&this.right.forEachLine(e,i,n,a,u,o);else{let h=this.lineAt(u,mi.ByPos,n,s,r);e<h.from&&this.left.forEachLine(e,h.from-1,n,s,r,o),h.to>=e&&h.from<=i&&o(h),i>h.to&&this.right.forEachLine(h.to+1,i,n,a,u,o)}}replace(e,i,n){let s=this.left.length+this.break;if(i<s)return this.balanced(this.left.replace(e,i,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-s,i-s,n));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let a of n)r.push(a);if(e>0&&pM(r,o-1),i<this.length){let a=r.length;this.decomposeRight(i,r),pM(r,a)}return hs.of(r)}decomposeLeft(e,i){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,i);i.push(this.left),this.break&&(n++,e>=n&&i.push(null)),e>n&&this.right.decomposeLeft(e-n,i)}decomposeRight(e,i){let n=this.left.length,s=n+this.break;if(e>=s)return this.right.decomposeRight(e-s,i);e<n&&this.left.decomposeRight(e,i),this.break&&e<s&&i.push(null),i.push(this.right)}balanced(e,i){return e.size>2*i.size||i.size>2*e.size?hs.of(this.break?[e,null,i]:[e,i]):(this.left=x0(this.left,e),this.right=x0(this.right,i),this.setHeight(e.height+i.height),this.outdated=e.outdated||i.outdated,this.size=e.size+i.size,this.length=e.length+this.break+i.length,this)}updateHeight(e,i=0,n=!1,s){let{left:r,right:o}=this,a=i+r.length+this.break,u=null;return s&&s.from<=i+r.length&&s.more?u=r=r.updateHeight(e,i,n,s):r.updateHeight(e,i,n),s&&s.from<=a+o.length&&s.more?u=o=o.updateHeight(e,a,n,s):o.updateHeight(e,a,n),u?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function pM(t,e){let i,n;t[e]==null&&(i=t[e-1])instanceof In&&(n=t[e+1])instanceof In&&t.splice(e-1,3,new In(i.length+1+n.length))}const xU=5;class bS{constructor(e,i){this.pos=e,this.oracle=i,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,i){if(this.lineStart>-1){let n=Math.min(i,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof sr?s.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new sr(n-this.pos,-1,0)),this.writtenTo=n,i>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=i}point(e,i,n){if(e<i||n.heightRelevant){let s=n.widget?n.widget.estimatedHeight:0,r=n.widget?n.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let o=i-e;n.block?this.addBlock(new sR(o,s,n)):(o||r||s>=xU)&&this.addLineDeco(s,r,o)}else i>e&&this.span(e,i);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:i}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=i,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new sr(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,i){let n=new In(i-e);return this.oracle.doc.lineAt(e).to==i&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof sr)return e;let i=new sr(0,-1,0);return this.nodes.push(i),i}addBlock(e){this.enterLine();let i=e.deco;i&&i.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,i&&i.endSide>0&&(this.covering=e)}addLineDeco(e,i,n){let s=this.ensureLine();s.length+=n,s.collapsed+=n,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=i,this.writtenTo=this.pos=this.pos+n}finish(e){let i=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(i instanceof sr)&&!this.isCovered?this.nodes.push(new sr(0,-1,0)):(this.writtenTo<this.pos||i==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let s of this.nodes)s instanceof sr&&s.updateHeight(this.oracle,n),n+=s?s.length:1;return this.nodes}static build(e,i,n,s){let r=new bS(n,e);return Rt.spans(i,n,s,r,0),r.finish(n)}}function bU(t,e,i){let n=new wU;return Rt.compare(t,e,i,n,0),n.changes}class wU{constructor(){this.changes=[]}compareRange(){}comparePoint(e,i,n,s){(e<i||n&&n.heightRelevant||s&&s.heightRelevant)&&nh(e,i,this.changes,5)}}function SU(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),a=Math.max(0,i.top),u=Math.min(s.innerHeight,i.bottom);for(let h=t.parentNode;h&&h!=n.body;)if(h.nodeType==1){let p=h,m=window.getComputedStyle(p);if((p.scrollHeight>p.clientHeight||p.scrollWidth>p.clientWidth)&&m.overflow!="visible"){let v=p.getBoundingClientRect();r=Math.max(r,v.left),o=Math.min(o,v.right),a=Math.max(a,v.top),u=Math.min(h==t.parentNode?s.innerHeight:u,v.bottom)}h=m.position=="absolute"||m.position=="fixed"?p.offsetParent:p.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:r-i.left,right:Math.max(r,o)-i.left,top:a-(i.top+e),bottom:Math.max(a,u)-(i.top+e)}}function kU(t){let e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||window;return e.left<i.innerWidth&&e.right>0&&e.top<i.innerHeight&&e.bottom>0}function CU(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class ey{constructor(e,i,n,s){this.from=e,this.to=i,this.size=n,this.displaySize=s}static same(e,i){if(e.length!=i.length)return!1;for(let n=0;n<e.length;n++){let s=e[n],r=i[n];if(s.from!=r.from||s.to!=r.to||s.size!=r.size)return!1}return!0}draw(e,i){return _t.replace({widget:new EU(this.displaySize*(i?e.scaleY:e.scaleX),i)}).range(this.from,this.to)}}class EU extends Lh{constructor(e,i){super(),this.size=e,this.vertical=i}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class mM{constructor(e,i){this.view=e,this.state=i,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=gM,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Mi.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=i.facet(_S).some(s=>typeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new gU(n),this.stateDeco=vM(i),this.heightMap=hs.empty().applyChanges(this.stateDeco,Vt.empty,this.heightOracle.setDoc(i.doc),[new Rr(0,0,0,i.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=_t.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:i}=this.state.selection;for(let n=0;n<=1;n++){let s=n?i.head:i.anchor;if(!e.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);e.push(new qm(r,o))}}return this.viewports=e.sort((n,s)=>n.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?gM:new wS(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(af(e,this.scaler))})}update(e,i=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=vM(this.state);let s=e.changedRanges,r=Rr.extendWithRanges(s,bU(n,this.stateDeco,e?e.changes:fn.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);fM(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||gh)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let u=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(i&&(i.range.head<u.from||i.range.head>u.to)||!this.viewportIsAppropriate(u))&&(u=this.getViewport(0,i));let h=u.from!=this.viewport.from||u.to!=this.viewport.to;this.viewport=u,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),i&&(this.scrollTarget=i),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(O3)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,i=e.contentDOM,n=window.getComputedStyle(i),s=this.heightOracle,r=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?Mi.RTL:Mi.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||this.mustMeasureContent==="refresh",a=i.getBoundingClientRect(),u=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let h=0,p=0;if(a.width&&a.height){let{scaleX:j,scaleY:R}=g3(i,a);(j>.005&&Math.abs(this.scaleX-j)>.005||R>.005&&Math.abs(this.scaleY-R)>.005)&&(this.scaleX=j,this.scaleY=R,h|=16,o=u=!0)}let m=(parseInt(n.paddingTop)||0)*this.scaleY,v=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=m||this.paddingBottom!=v)&&(this.paddingTop=m,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(u=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let _=v3(this.view.contentDOM,!1).y;_!=this.scrollParent&&(this.scrollParent=_,this.scrollAnchorHeight=-1,this.scrollOffset=0);let x=this.getScrollOffset();this.scrollOffset!=x&&(this.scrollAnchorHeight=-1,this.scrollOffset=x),this.scrolledToBottom=b3(this.scrollParent||e.win);let S=(this.printing?CU:SU)(i,this.paddingTop),C=S.top-this.pixelViewport.top,k=S.bottom-this.pixelViewport.bottom;this.pixelViewport=S;let M=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(M!=this.inView&&(this.inView=M,M&&(u=!0)),!this.inView&&!this.scrollTarget&&!kU(e.dom))return 0;let L=a.width;if((this.contentDOMWidth!=L||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),u){let j=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(j)&&(o=!0),o||s.lineWrapping&&Math.abs(L-this.contentDOMWidth)>s.charWidth){let{lineHeight:R,charWidth:z,textHeight:J}=e.docView.measureTextSize();o=R>0&&s.refresh(r,R,z,J,Math.max(5,L/z),j),o&&(e.docView.minWidth=0,h|=16)}C>0&&k>0?p=Math.max(C,k):C<0&&k<0&&(p=Math.min(C,k)),fM();for(let R of this.viewports){let z=R.from==this.viewport.from?j:e.docView.measureVisibleLineHeights(R);this.heightMap=(o?hs.empty().applyChanges(this.stateDeco,Vt.empty,this.heightOracle,[new Rr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new vU(R.from,z))}gh&&(h|=2)}let N=!this.viewportIsAppropriate(this.viewport,p)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return N&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(p,this.scrollTarget),h|=this.updateForViewport()),(h&2||N)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,i){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,u=new qm(s.lineAt(o-n*1e3,mi.ByHeight,r,0,0).from,s.lineAt(a+(1-n)*1e3,mi.ByHeight,r,0,0).to);if(i){let{head:h}=i.range;if(h<u.from||h>u.to){let p=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),m=s.lineAt(h,mi.ByPos,r,0,0),v;i.y=="center"?v=(m.top+m.bottom)/2-p/2:i.y=="start"||i.y=="nearest"&&h<u.from?v=m.top:v=m.bottom-p,u=new qm(s.lineAt(v-1e3/2,mi.ByHeight,r,0,0).from,s.lineAt(v+p+1e3/2,mi.ByHeight,r,0,0).to)}}return u}mapViewport(e,i){let n=i.mapPos(e.from,-1),s=i.mapPos(e.to,1);return new qm(this.heightMap.lineAt(n,mi.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,mi.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:i},n=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(e,mi.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(i,mi.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:a}=this;return(e==0||s<=o-Math.max(10,Math.min(-n,250)))&&(i==this.state.doc.length||r>=a+Math.max(10,Math.min(n,250)))&&s>o-2*1e3&&r<a+2*1e3}mapLineGaps(e,i){if(!e.length||i.empty)return e;let n=[];for(let s of e)i.touchesRange(s.from,s.to)||n.push(new ey(i.mapPos(s.from),i.mapPos(s.to),s.size,s.displaySize));return n}ensureLineGaps(e,i){let n=this.heightOracle.lineWrapping,s=n?1e4:2e3,r=s>>1,o=s<<1;if(this.defaultTextDirection!=Mi.LTR&&!n)return[];let a=[],u=(p,m,v,_)=>{if(m-p<r)return;let x=this.state.selection.main,S=[x.from];x.empty||S.push(x.to);for(let k of S)if(k>p&&k<m){u(p,k-10,v,_),u(k+10,m,v,_);return}let C=AU(e,k=>k.from>=v.from&&k.to<=v.to&&Math.abs(k.from-p)<r&&Math.abs(k.to-m)<r&&!S.some(M=>k.from<M&&k.to>M));if(!C){if(m<v.to&&i&&n&&i.visibleRanges.some(L=>L.from<=m&&L.to>=m)){let L=i.moveToLineBoundary(Se.cursor(m),!1,!0).head;L>p&&(m=L)}let k=this.gapSize(v,p,m,_),M=n||k<2e6?k:2e6;C=new ey(p,m,k,M)}a.push(C)},h=p=>{if(p.length<o||p.type!=$n.Text)return;let m=MU(p.from,p.to,this.stateDeco);if(m.total<o)return;let v=this.scrollTarget?this.scrollTarget.range.head:null,_,x;if(n){let S=s/this.heightOracle.lineLength*this.heightOracle.lineHeight,C,k;if(v!=null){let M=Vm(m,v),L=((this.visibleBottom-this.visibleTop)/2+S)/p.height;C=M-L,k=M+L}else C=(this.visibleTop-p.top-S)/p.height,k=(this.visibleBottom-p.top+S)/p.height;_=Um(m,C),x=Um(m,k)}else{let S=m.total*this.heightOracle.charWidth,C=s*this.heightOracle.charWidth,k=0;if(S>2e6)for(let R of e)R.from>=p.from&&R.from<p.to&&R.size!=R.displaySize&&R.from*this.heightOracle.charWidth+k<this.pixelViewport.left&&(k=R.size-R.displaySize);let M=this.pixelViewport.left+k,L=this.pixelViewport.right+k,N,j;if(v!=null){let R=Vm(m,v),z=((L-M)/2+C)/S;N=R-z,j=R+z}else N=(M-C)/S,j=(L+C)/S;_=Um(m,N),x=Um(m,j)}_>p.from&&u(p.from,_,p,m),x<p.to&&u(x,p.to,p,m)};for(let p of this.viewportLines)Array.isArray(p.type)?p.type.forEach(h):h(p);return a}gapSize(e,i,n,s){let r=Vm(s,n)-Vm(s,i);return this.heightOracle.lineWrapping?e.height*r:s.total*this.heightOracle.charWidth*r}updateLineGaps(e){ey.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=_t.set(e.map(i=>i.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let i=this.stateDeco;this.lineGaps.length&&(i=i.concat(this.lineGapDeco));let n=[];Rt.spans(i,this.viewport.from,this.viewport.to,{span(r,o){n.push({from:r,to:o})},point(){}},20);let s=0;if(n.length!=this.visibleRanges.length)s=12;else for(let r=0;r<n.length&&!(s&8);r++){let o=this.visibleRanges[r],a=n[r];(o.from!=a.from||o.to!=a.to)&&(s|=4,e&&e.mapPos(o.from,-1)==a.from&&e.mapPos(o.to,1)==a.to||(s|=8))}return this.visibleRanges=n,s}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(i=>i.from<=e&&i.to>=e)||af(this.heightMap.lineAt(e,mi.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(i=>i.top<=e&&i.bottom>=e)||af(this.heightMap.lineAt(this.scaler.fromDOM(e),mi.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let i=this.lineBlockAtHeight(e+8);return i.from>=this.viewport.from||this.viewportLines[0].top-e>200?i:this.viewportLines[0]}elementAtHeight(e){return af(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class qm{constructor(e,i){this.from=e,this.to=i}}function MU(t,e,i){let n=[],s=t,r=0;return Rt.spans(i,t,e,{span(){},point(o,a){o>s&&(n.push({from:s,to:o}),r+=o-s),s=a}},20),s<e&&(n.push({from:s,to:e}),r+=e-s),{total:r,ranges:n}}function Um({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let s=0;;s++){let{from:r,to:o}=e[s],a=o-r;if(n<=a)return r+n;n-=a}}function Vm(t,e){let i=0;for(let{from:n,to:s}of t.ranges){if(e<=s){i+=e-n;break}i+=s-n}return i/t.total}function AU(t,e){for(let i of t)if(e(i))return i}const gM={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function vM(t){let e=t.facet(nv).filter(n=>typeof n!="function"),i=t.facet(yS).filter(n=>typeof n!="function");return i.length&&e.push(Rt.join(i)),e}class wS{constructor(e,i,n){let s=0,r=0,o=0;this.viewports=n.map(({from:a,to:u})=>{let h=i.lineAt(a,mi.ByPos,e,0,0).top,p=i.lineAt(u,mi.ByPos,e,0,0).bottom;return s+=p-h,{from:a,to:u,top:h,bottom:p,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(i.height-s);for(let a of this.viewports)a.domTop=o+(a.top-r)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),r=a.bottom}toDOM(e){for(let i=0,n=0,s=0;;i++){let r=i<this.viewports.length?this.viewports[i]:null;if(!r||e<r.top)return s+(e-n)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);n=r.bottom,s=r.domBottom}}fromDOM(e){for(let i=0,n=0,s=0;;i++){let r=i<this.viewports.length?this.viewports[i]:null;if(!r||e<r.domTop)return n+(e-s)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);n=r.bottom,s=r.domBottom}}eq(e){return e instanceof wS?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((i,n)=>i.from==e.viewports[n].from&&i.to==e.viewports[n].to):!1}}function af(t,e){if(e.scale==1)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new Yr(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map(s=>af(s,e)):t._content)}const Km=Fe.define({combine:t=>t.join(" ")}),Xx=Fe.define({combine:t=>t.indexOf(!0)>-1}),Zx=La.newName(),rR=La.newName(),oR=La.newName(),lR={"&light":"."+rR,"&dark":"."+oR};function Jx(t,e,i){return new La(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,s=>{if(s=="&")return t;if(!i||!i[s])throw new RangeError(`Unsupported selector: ${s}`);return i[s]}):t+" "+n}})}const LU=Jx("."+Zx,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},lR),TU={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},ty=Oe.ie&&Oe.ie_version<=11;class NU{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new oq,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(i=>{for(let n of i)this.queue.push(n);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&i.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new RU(e),e.state.facet(_l)&&(e.contentDOM.editContext=this.editContext.editContext)),ty&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var i;((i=this.view.docView)===null||i===void 0?void 0:i.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(i=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),i.length>0&&i[i.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(i=>{i.length>0&&i[i.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((i,n)=>i!=e[n]))){this.gapIntersection.disconnect();for(let i of e)this.gapIntersection.observe(i);this.gaps=e}}onSelectionChange(e){let i=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,s=this.selectionRange;if(n.state.facet(_l)?n.root.activeElement!=this.dom:!xf(this.dom,s))return;let r=s.anchorNode&&n.docView.tile.nearest(s.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(e)){i||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!n.state.selection.main.empty&&s.focusNode&&bf(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,i=Nf(e.root);if(!i)return!1;let n=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&jU(this.view,i)||i;if(!n||this.selectionRange.eq(n))return!1;let s=xf(this.dom,n);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&aq(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),s&&(this.selectionChanged=!0),!0)}setSelectionRange(e,i){this.selectionRange.set(e.node,e.offset,i.node,i.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,i=null;for(let n=this.dom;n;)if(n.nodeType==1)!i&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:i||(i=this.scrollTargets.slice(0,e)),i&&i.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!i&&(i=this.scrollTargets.slice(0,e)),i){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=i)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,TU),ty&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),ty&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,i){var n;if(!this.delayedAndroidKey){let s=()=>{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&sh(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:i,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let i=-1,n=-1,s=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(s=!0),i==-1?{from:i,to:n}=o:(i=Math.min(o.from,i),n=Math.max(o.to,n)))}return{from:i,to:n,typeOver:s}}readChange(){let{from:e,to:i,typeOver:n}=this.processRecords(),s=this.selectionChanged&&xf(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new Gq(this.view,e,i,n);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let i=this.readChange();if(!i)return this.view.requestMeasure(),!1;let n=this.view.state,s=Y3(this.view,i);return this.view.state==n&&(i.domChanged||i.newSel&&!y0(this.view.state.selection,i.newSel.main))&&this.view.update([]),s}readMutation(e){let i=this.view.docView.tile.nearest(e.target);if(!i||i.isWidget())return null;if(i.markDirty(e.type=="attributes"),e.type=="childList"){let n=_M(i,e.previousSibling||e.target.previousSibling,-1),s=_M(i,e.nextSibling||e.target.nextSibling,1);return{from:n?i.posAfter(n):i.posAtStart,to:s?i.posBefore(s):i.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(_l)!=e.state.facet(_l)&&(e.view.contentDOM.editContext=e.state.facet(_l)?this.editContext.editContext:null))}destroy(){var e,i,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(i=this.gapIntersection)===null||i===void 0||i.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function _M(t,e,i){for(;e;){let n=Pi.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}function yM(t,e){let i=e.startContainer,n=e.startOffset,s=e.endContainer,r=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return bf(o.node,o.offset,s,r)&&([i,n,s,r]=[s,r,i,n]),{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}}function jU(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yM(t,s)}let i=null;function n(s){s.preventDefault(),s.stopImmediatePropagation(),i=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",n,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),i?yM(t,i):null}class RU{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let i=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let s=e.state.selection.main,{anchor:r,head:o}=s,a=this.toEditorPos(n.updateRangeStart),u=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:a,drifted:!1});let h=u-a>n.text.length;a==this.from&&r<this.from?a=r:u==this.to&&r>this.to&&(u=r);let p=G3(e.state.sliceDoc(a,u),n.text,(h?s.from:s.to)-a,h?"end":null);if(!p){let v=Se.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));y0(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let m={from:p.from+a,to:p.toA+a,insert:Vt.of(n.text.slice(p.from,p.toB).split(`
|
|
57
|
+
`))};if((Oe.mac||Oe.android)&&m.from==o-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(m={from:a,to:u,insert:Vt.of([n.text.replace("."," ")])}),this.pendingContextChange=m,!e.state.readOnly){let v=this.to-this.from+(m.to-m.from+m.insert.length);xS(e,m,Se.single(this.toEditorPos(n.selectionStart,v),this.toEditorPos(n.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),m.from<m.to&&!m.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(i.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(i.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let s=[],r=null;for(let o=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);o<a;o++){let u=e.coordsForChar(o);r=u&&new DOMRect(u.left,u.top,u.right-u.left,u.bottom-u.top)||r||new DOMRect,s.push(r)}i.updateCharacterBounds(n.rangeStart,s)},this.handlers.textformatupdate=n=>{let s=[];for(let r of n.getTextFormats()){let o=r.underlineStyle,a=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(a)){let u=this.toEditorPos(r.rangeStart),h=this.toEditorPos(r.rangeEnd);if(u<h){let p=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(a)?1:2}px`;s.push(_t.mark({attributes:{style:p}}).range(u,h))}}}e.dispatch({effects:P3.of(_t.set(s))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(e.state)}};for(let n in this.handlers)i.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{let s=Nf(n.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let i=0,n=!1,s=this.pendingContextChange;return e.changes.iterChanges((r,o,a,u,h)=>{if(n)return;let p=h.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(h)){s=this.pendingContextChange=null,i+=p,this.to+=p;return}else s=null,this.revertPending(e.state);if(r+=i,o+=i,o<=this.from)this.from+=p,this.to+=p;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+h.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),h.toString()),this.to+=p}i+=p}),s&&!n&&this.revertPending(e.state),!n}update(e){let i=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||i)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:i}=e.selection.main;this.from=Math.max(0,i-1e4),this.to=Math.min(e.doc.length,i+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let i=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(i.from),this.toContextPos(i.from+i.insert.length),e.doc.sliceString(i.from,i.to))}setSelection(e){let{main:i}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,i.anchor))),s=this.toContextPos(i.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(n,s)}rangeIsValid(e){let{head:i}=e.selection.main;return!(this.from>0&&i-this.from<500||this.to<e.doc.length&&this.to-i<500||this.to-this.from>1e4*3)}toEditorPos(e,i=this.to-this.from){e=Math.min(e,i);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let i=this.composing;return i&&i.drifted?i.contextBase+(e-i.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Ue{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var i;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(s=>s.forEach(r=>n(r,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||lq(e.parent)||document,this.viewState=new mM(this,e.state||It.create(e)),e.scrollTo&&e.scrollTo.is(Fm)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Gu).map(s=>new G1(s));for(let s of this.plugins)s.update(this);this.observer=new NU(this),this.inputState=new Jq(this),this.inputState.ensureHandlers(this.plugins),this.docView=new iM(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((i=document.fonts)===null||i===void 0)&&i.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let i=e.length==1&&e[0]instanceof pn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(i,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let i=!1,n=!1,s,r=this.state;for(let v of e){if(v.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=v.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,a=0,u=null;e.some(v=>v.annotation(tR))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,u=iR(r,o),u||(a=1));let h=this.observer.delayedAndroidKey,p=null;if(h?(this.observer.clearDelayedAndroidKey(),p=this.observer.readChange(),(p&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(p=null)):this.observer.clear(),r.facet(It.phrases)!=this.state.facet(It.phrases))return this.setState(r);s=g0.create(this,r,e),s.flags|=a;let m=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(m&&(m=m.map(v.changes)),v.scrollIntoView){let{main:_}=v.state.selection,{x,y:S}=this.state.facet(Ue.cursorScrollMargin);m=new rh(_.empty?_:Se.cursor(_.head,_.head>_.anchor?-1:1),"nearest","nearest",S,x)}for(let _ of v.effects)_.is(Fm)&&(m=_.value.clip(this.state))}this.viewState.update(s,m),this.bidiCache=b0.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),i=this.docView.update(s),this.state.facet(lf)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(i,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Km)!=s.state.facet(Km)&&(this.viewState.mustMeasureContent=!0),(i||n||m||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Vx))try{v(s)}catch(_){So(this.state,_,"update listener")}(u||p)&&Promise.resolve().then(()=>{u&&this.state==u.startState&&this.dispatch(u),p&&!Y3(this,p)&&h.force&&sh(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let i=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new mM(this,e),this.plugins=e.facet(Gu).map(n=>new G1(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new iM(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}i&&this.focus(),this.requestMeasure()}updatePlugins(e){let i=e.startState.facet(Gu),n=e.state.facet(Gu);if(i!=n){let s=[];for(let r of n){let o=i.indexOf(r);if(o<0)s.push(new G1(r));else{let a=this.plugins[o];a.mustUpdate=e,s.push(a)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s<this.plugins.length;s++)this.plugins[s].update(this);i!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let i=e.value;if(i&&i.docViewUpdate)try{i.docViewUpdate(this)}catch(n){So(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let i=null,n=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(b3(n||this.win))r=-1,o=this.viewState.heightMap.height;else{let _=this.viewState.scrollAnchorAt(s);r=_.from,o=_.top}this.updateState=1;let u=this.viewState.measure();if(!u&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];u&4||([this.measureRequests,h]=[h,this.measureRequests]);let p=h.map(_=>{try{return _.read(this)}catch(x){return So(this.state,x),xM}}),m=g0.create(this,this.state,[]),v=!1;m.flags|=u,i?i.flags|=u:i=m,this.updateState=2,m.empty||(this.updatePlugins(m),this.inputState.update(m),this.updateAttrs(),v=this.docView.update(m),v&&this.docViewUpdate());for(let _=0;_<h.length;_++)if(p[_]!=xM)try{let x=h[_];x.write&&x.write(p[_],this)}catch(x){So(this.state,x)}if(v&&this.docView.updateSelection(!0),!m.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let x=((r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o)/this.scaleY;if((x>1||x<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+x,n?r<0?n.scrollTop=n.scrollHeight:n.scrollTop+=x:this.win.scrollBy(0,x),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(i&&!i.empty)for(let a of this.state.facet(Vx))a(i)}get themeClasses(){return Zx+" "+(this.state.facet(Xx)?oR:rR)+" "+this.state.facet(Km)}updateAttrs(){let e=bM(this,z3,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),i={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(_l)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(i["aria-readonly"]="true"),bM(this,_S,i);let n=this.observer.ignore(()=>{let s=QE(this.contentDOM,this.contentAttrs,i),r=QE(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=i,n}showAnnouncements(e){let i=!0;for(let n of e)for(let s of n.effects)if(s.is(Ue.announce)){i&&(this.announceDOM.textContent=""),i=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(lf);let e=this.state.facet(Ue.cspNonce);La.mount(this.root,this.styleModules.concat(LU).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let i=0;i<this.measureRequests.length;i++)if(this.measureRequests[i].key===e.key){this.measureRequests[i]=e;return}}this.measureRequests.push(e)}}plugin(e){let i=this.pluginMap.get(e);return(i===void 0||i&&i.plugin!=e)&&this.pluginMap.set(e,i=this.plugins.find(n=>n.plugin==e)||null),i&&i.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,i,n){return J1(this,e,nM(this,e,i,n))}moveByGroup(e,i){return J1(this,e,nM(this,e,i,n=>Wq(this,e.head,n)))}visualLineSide(e,i){let n=this.bidiSpans(e),s=this.textDirectionAt(e.from),r=n[i?n.length-1:0];return Se.cursor(r.side(i,s)+e.from,r.forward(!i,s)?1:-1)}moveToLineBoundary(e,i,n=!0){return Hq(this,e,i,n)}moveVertically(e,i,n){return J1(this,e,qq(this,e,i,n))}domAtPos(e,i=1){return this.docView.domAtPos(e,i)}posAtDOM(e,i=0){return this.docView.posFromDOM(e,i)}posAtCoords(e,i=!0){this.readMeasured();let n=Gx(this,e,i);return n&&n.pos}posAndSideAtCoords(e,i=!0){return this.readMeasured(),Gx(this,e,i)}coordsAtPos(e,i=1){this.readMeasured();let n=this.state.doc.lineAt(e),s=this.bidiSpans(n),r=s[wo.find(s,e-n.from,-1,i)];return this.docView.coordsAt(e,i,r.dir==Mi.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(B3)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>DU)return M3(e.length);let i=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==i&&(r.fresh||E3(r.isolates,n=JE(this,e))))return r.order;n||(n=JE(this,e));let s=mq(e.text,i,n);return this.bidiCache.push(new b0(e.from,e.to,i,n,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{x3(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,i={}){var n,s,r,o;return Fm.of(new rh(typeof e=="number"?Se.cursor(e):e,(n=i.y)!==null&&n!==void 0?n:"nearest",(s=i.x)!==null&&s!==void 0?s:"nearest",(r=i.yMargin)!==null&&r!==void 0?r:5,(o=i.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:i}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Fm.of(new rh(Se.cursor(n.from),"start","start",n.top-e,i,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return ds.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ds.define(()=>({}),{eventObservers:e})}static theme(e,i){let n=La.newName(),s=[Km.of(n),lf.of(Jx(`.${n}`,e))];return i&&i.dark&&s.push(Xx.of(!0)),s}static baseTheme(e){return Qf.lowest(lf.of(Jx("."+Zx,e,lR)))}static findFromDOM(e){var i;let n=e.querySelector(".cm-content"),s=n&&Pi.get(n)||Pi.get(e);return((i=s?.root)===null||i===void 0?void 0:i.view)||null}}Ue.styleModule=lf;Ue.inputHandler=R3;Ue.clipboardInputFilter=gS;Ue.clipboardOutputFilter=vS;Ue.scrollHandler=I3;Ue.focusChangeEffect=D3;Ue.perLineTextDirection=B3;Ue.exceptionSink=j3;Ue.updateListener=Vx;Ue.editable=_l;Ue.mouseSelectionStyle=N3;Ue.dragMovesSelection=T3;Ue.clickAddsSelectionRange=L3;Ue.decorations=nv;Ue.blockWrappers=$3;Ue.outerDecorations=yS;Ue.atomicRanges=ep;Ue.bidiIsolatedRanges=F3;Ue.cursorScrollMargin=Fe.define({combine:t=>{let e=5,i=5;for(let n of t)typeof n=="number"?e=i=n:{x:e,y:i}=n;return{x:e,y:i}}});Ue.scrollMargins=H3;Ue.darkTheme=Xx;Ue.cspNonce=Fe.define({combine:t=>t.length?t[0]:""});Ue.contentAttributes=_S;Ue.editorAttributes=z3;Ue.lineWrapping=Ue.contentAttributes.of({class:"cm-lineWrapping"});Ue.announce=ci.define();const DU=4096,xM={};class b0{constructor(e,i,n,s,r,o){this.from=e,this.to=i,this.dir=n,this.isolates=s,this.fresh=r,this.order=o}static update(e,i){if(i.empty&&!e.some(r=>r.fresh))return e;let n=[],s=e.length?e[e.length-1].dir:Mi.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let o=e[r];o.dir==s&&!i.touchesRange(o.from,o.to)&&n.push(new b0(i.mapPos(o.from,1),i.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function bM(t,e,i){for(let n=t.state.facet(e),s=n.length-1;s>=0;s--){let r=n[s],o=typeof r=="function"?r(t):r;o&&fS(o,i)}return i}const BU=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function OU(t,e){const i=t.split(/-(?!$)/);let n=i[i.length-1];n=="Space"&&(n=" ");let s,r,o,a;for(let u=0;u<i.length-1;++u){const h=i[u];if(/^(cmd|meta|m)$/i.test(h))a=!0;else if(/^a(lt)?$/i.test(h))s=!0;else if(/^(c|ctrl|control)$/i.test(h))r=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?a=!0:r=!0;else throw new Error("Unrecognized modifier name: "+h)}return s&&(n="Alt-"+n),r&&(n="Ctrl-"+n),a&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function Ym(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),i!==!1&&e.shiftKey&&(t="Shift-"+t),t}const IU=Qf.default(Ue.domEventHandlers({keydown(t,e){return uR(cR(e.state),t,e,"editor")}})),aR=Fe.define({enables:IU}),wM=new WeakMap;function cR(t){let e=t.facet(aR),i=wM.get(e);return i||wM.set(e,i=$U(e.reduce((n,s)=>n.concat(s),[]))),i}function PU(t,e,i){return uR(cR(t.state),e,t,i)}let Sa=null;const zU=4e3;function $U(t,e=BU){let i=Object.create(null),n=Object.create(null),s=(o,a)=>{let u=n[o];if(u==null)n[o]=a;else if(u!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,a,u,h,p)=>{var m,v;let _=i[o]||(i[o]=Object.create(null)),x=a.split(/ (?!$)/).map(k=>OU(k,e));for(let k=1;k<x.length;k++){let M=x.slice(0,k).join(" ");s(M,!0),_[M]||(_[M]={preventDefault:!0,stopPropagation:!1,run:[L=>{let N=Sa={view:L,prefix:M,scope:o};return setTimeout(()=>{Sa==N&&(Sa=null)},zU),!0}]})}let S=x.join(" ");s(S,!1);let C=_[S]||(_[S]={preventDefault:!1,stopPropagation:!1,run:((v=(m=_._any)===null||m===void 0?void 0:m.run)===null||v===void 0?void 0:v.slice())||[]});u&&C.run.push(u),h&&(C.preventDefault=!0),p&&(C.stopPropagation=!0)};for(let o of t){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of a){let p=i[h]||(i[h]=Object.create(null));p._any||(p._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:m}=o;for(let v in p)p[v].run.push(_=>m(_,eb))}let u=o[e]||o.key;if(u)for(let h of a)r(h,u,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(h,"Shift-"+u,o.shift,o.preventDefault,o.stopPropagation)}return i}let eb=null;function uR(t,e,i,n){eb=e;let s=eq(e),r=aS(s,0),o=Jj(r)==s.length&&s!=" ",a="",u=!1,h=!1,p=!1;Sa&&Sa.view==i&&Sa.scope==n&&(a=Sa.prefix+" ",X3.indexOf(e.keyCode)<0&&(h=!0,Sa=null));let m=new Set,v=C=>{if(C){for(let k of C.run)if(!m.has(k)&&(m.add(k),k(i)))return C.stopPropagation&&(p=!0),!0;C.preventDefault&&(C.stopPropagation&&(p=!0),h=!0)}return!1},_=t[n],x,S;return _&&(v(_[a+Ym(s,e,!o)])?u=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(x=Ta[e.keyCode])&&x!=s?(v(_[a+Ym(x,e,!0)])||e.shiftKey&&(S=Lf[e.keyCode])!=s&&S!=x&&v(_[a+Ym(S,e,!1)]))&&(u=!0):o&&e.shiftKey&&v(_[a+Ym(s,e,!0)])&&(u=!0),!u&&v(_._any)&&(u=!0)),h&&(u=!0),u&&p&&e.stopPropagation(),eb=null,u}class kc{constructor(e,i,n,s,r){this.className=e,this.left=i,this.top=n,this.width=s,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,i){return i.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,i,n){if(n.empty){let s=e.coordsAtPos(n.head,n.assoc||1);if(!s)return[];let r=hR(e);return[new kc(i,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return FU(e,i,n)}}function hR(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Mi.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function SM(t,e,i,n){let s=t.coordsAtPos(e,i*2);if(!s)return n;let r=t.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,a=t.posAtCoords({x:r.left+1,y:o}),u=t.posAtCoords({x:r.right-1,y:o});return a==null||u==null?n:{from:Math.max(n.from,Math.min(a,u)),to:Math.min(n.to,Math.max(a,u))}}function FU(t,e,i){if(i.to<=t.viewport.from||i.from>=t.viewport.to)return[];let n=Math.max(i.from,t.viewport.from),s=Math.min(i.to,t.viewport.to),r=t.textDirection==Mi.LTR,o=t.contentDOM,a=o.getBoundingClientRect(),u=hR(t),h=o.querySelector(".cm-line"),p=h&&window.getComputedStyle(h),m=a.left+(p?parseInt(p.paddingLeft)+Math.min(0,parseInt(p.textIndent)):0),v=a.right-(p?parseInt(p.paddingRight):0),_=Yx(t,n,1),x=Yx(t,s,-1),S=_.type==$n.Text?_:null,C=x.type==$n.Text?x:null;if(S&&(t.lineWrapping||_.widgetLineBreaks)&&(S=SM(t,n,1,S)),C&&(t.lineWrapping||x.widgetLineBreaks)&&(C=SM(t,s,-1,C)),S&&C&&S.from==C.from&&S.to==C.to)return M(L(i.from,i.to,S));{let j=S?L(i.from,null,S):N(_,!1),R=C?L(null,i.to,C):N(x,!0),z=[];return(S||_).to<(C||x).from-(S&&C?1:0)||_.widgetLineBreaks>1&&j.bottom+t.defaultLineHeight/2<R.top?z.push(k(m,j.bottom,v,R.top)):j.bottom<R.top&&t.elementAtHeight((j.bottom+R.top)/2).type==$n.Text&&(j.bottom=R.top=(j.bottom+R.top)/2),M(j).concat(z).concat(M(R))}function k(j,R,z,J){return new kc(e,j-u.left,R-u.top,Math.max(0,z-j),J-R)}function M({top:j,bottom:R,horizontal:z}){let J=[];for(let G=0;G<z.length;G+=2)J.push(k(z[G],j,z[G+1],R));return J}function L(j,R,z){let J=1e9,G=-1e9,q=[];function X(H,F,P,U,V){let K=t.coordsAtPos(H,H==z.to?-2:2),D=t.coordsAtPos(P,P==z.from?2:-2);!K||!D||(J=Math.min(K.top,D.top,J),G=Math.max(K.bottom,D.bottom,G),V==Mi.LTR?q.push(r&&F?m:K.left,r&&U?v:D.right):q.push(!r&&U?m:D.left,!r&&F?v:K.right))}let I=j??z.from,T=R??z.to;for(let H of t.visibleRanges)if(H.to>I&&H.from<T)for(let F=Math.max(H.from,I),P=Math.min(H.to,T);;){let U=t.state.doc.lineAt(F);for(let V of t.bidiSpans(U)){let K=V.from+U.from,D=V.to+U.from;if(K>=P)break;D>F&&X(Math.max(K,F),j==null&&K<=I,Math.min(D,P),R==null&&D>=T,V.dir)}if(F=U.to+1,F>=P)break}return q.length==0&&X(I,j==null,T,R==null,t.textDirection),{top:J,bottom:G,horizontal:q}}function N(j,R){let z=a.top+(R?j.top:j.bottom);return{top:z,bottom:z,horizontal:[]}}}function HU(t,e){return t.constructor==e.constructor&&t.eq(e)}class WU{constructor(e,i){this.view=e,this.layer=i,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),i.above&&this.dom.classList.add("cm-layer-above"),i.class&&this.dom.classList.add(i.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),i.mount&&i.mount(this.dom,e)}update(e){e.startState.facet(Tg)!=e.state.facet(Tg)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let i=0,n=e.facet(Tg);for(;i<n.length&&n[i]!=this.layer;)i++;this.dom.style.zIndex=String((this.layer.above?150:-1)-i)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:i}=this.view;(e!=this.scaleX||i!=this.scaleY)&&(this.scaleX=e,this.scaleY=i,this.dom.style.transform=`scale(${1/e}, ${1/i})`)}draw(e){if(e.length!=this.drawn.length||e.some((i,n)=>!HU(i,this.drawn[n]))){let i=this.dom.firstChild,n=0;for(let s of e)s.update&&i&&s.constructor&&this.drawn[n].constructor&&s.update(i,this.drawn[n])?(i=i.nextSibling,n++):this.dom.insertBefore(s.draw(),i);for(;i;){let s=i.nextSibling;i.remove(),i=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tg=Fe.define();function dR(t){return[ds.define(e=>new WU(e,t)),Tg.of(t)]}const vh=Fe.define({combine(t){return Fc(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,i)=>Math.min(e,i),drawRangeCursor:(e,i)=>e||i})}});function qU(t={}){return[vh.of(t),UU,VU,YU,O3.of(!0)]}function fR(t){return t.startState.facet(vh)!=t.state.facet(vh)}const UU=dR({above:!0,markers(t){let{state:e}=t,i=e.facet(vh),n=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty||i.drawRangeCursor&&!(r&&Oe.ios&&i.iosSelectionHandles)){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=s.empty?s:Se.cursor(s.head,s.assoc);for(let u of kc.forRange(t,o,a))n.push(u)}}return n},update(t,e){t.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let i=fR(t);return i&&kM(t.state,e),t.docChanged||t.selectionSet||i},mount(t,e){kM(e.state,t)},class:"cm-cursorLayer"});function kM(t,e){e.style.animationDuration=t.facet(vh).cursorBlinkRate+"ms"}const VU=dR({above:!1,markers(t){let e=[],{main:i,ranges:n}=t.state.selection;for(let s of n)if(!s.empty)for(let r of kc.forRange(t,"cm-selectionBackground",s))e.push(r);if(Oe.ios&&!i.empty&&t.state.facet(vh).iosSelectionHandles){for(let s of kc.forRange(t,"cm-selectionHandle cm-selectionHandle-start",Se.cursor(i.from,1)))e.push(s);for(let s of kc.forRange(t,"cm-selectionHandle cm-selectionHandle-end",Se.cursor(i.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||fR(t)},class:"cm-selectionLayer"}),KU=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",YU=Qf.highest(Ue.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${KU} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function CM(t,e,i,n,s){e.lastIndex=0;for(let r=t.iterRange(i,n),o=i,a;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;a=e.exec(r.value);)s(o+a.index,a)}function GU(t,e){let i=t.visibleRanges;if(i.length==1&&i[0].from==t.viewport.from&&i[0].to==t.viewport.to)return i;let n=[];for(let{from:s,to:r}of i)s=Math.max(t.state.doc.lineAt(s).from,s-e),r=Math.min(t.state.doc.lineAt(r).to,r+e),n.length&&n[n.length-1].to>=s?n[n.length-1].to=r:n.push({from:s,to:r});return n}class QU{constructor(e){const{regexp:i,decoration:n,decorate:s,boundary:r,maxLength:o=1e3}=e;if(!i.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=i,s)this.addMatch=(a,u,h,p)=>s(p,h,h+a[0].length,a,u);else if(typeof n=="function")this.addMatch=(a,u,h,p)=>{let m=n(a,u,h);m&&p(h,h+a[0].length,m)};else if(n)this.addMatch=(a,u,h,p)=>p(h,h+a[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let i=new Rc,n=i.add.bind(i);for(let{from:s,to:r}of GU(e,this.maxLength))CM(e.state.doc,this.regexp,s,r,(o,a)=>this.addMatch(a,e,o,n));return i.finish()}updateDeco(e,i){let n=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,a,u)=>{u>=e.view.viewport.from&&a<=e.view.viewport.to&&(n=Math.min(a,n),s=Math.max(u,s))}),e.viewportMoved||s-n>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,i.map(e.changes),n,s):i}updateRange(e,i,n,s){for(let r of e.visibleRanges){let o=Math.max(r.from,n),a=Math.min(r.to,s);if(a>=o){let u=e.state.doc.lineAt(o),h=u.to<a?e.state.doc.lineAt(a):u,p=Math.max(r.from,u.from),m=Math.min(r.to,h.to);if(this.boundary){for(;o>u.from;o--)if(this.boundary.test(u.text[o-1-u.from])){p=o;break}for(;a<h.to;a++)if(this.boundary.test(h.text[a-h.from])){m=a;break}}let v=[],_,x=(S,C,k)=>v.push(k.range(S,C));if(u==h)for(this.regexp.lastIndex=p-u.from;(_=this.regexp.exec(u.text))&&_.index<m-u.from;)this.addMatch(_,e,_.index+u.from,x);else CM(e.state.doc,this.regexp,p,m,(S,C)=>this.addMatch(C,e,S,x));i=i.update({filterFrom:p,filterTo:m,filter:(S,C)=>S<p||C>m,add:v})}}return i}}const tb=/x/.unicode!=null?"gu":"g",XU=new RegExp(`[\0-\b
|
|
58
|
+
--\u2028\u2029\uFEFF-]`,tb),ZU={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let iy=null;function JU(){var t;if(iy==null&&typeof document<"u"&&document.body){let e=document.body.style;iy=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return iy||!1}const Ng=Fe.define({combine(t){let e=Fc(t,{render:null,specialChars:XU,addSpecialChars:null});return(e.replaceTabs=!JU())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,tb)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,tb)),e}});function eV(t={}){return[Ng.of(t),tV()]}let EM=null;function tV(){return EM||(EM=ds.fromClass(class{constructor(t){this.view=t,this.decorations=_t.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(Ng)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new QU({regexp:t.specialChars,decoration:(e,i,n)=>{let{doc:s}=i.state,r=aS(e[0],0);if(r==9){let o=s.lineAt(n),a=i.state.tabSize,u=Ah(o.text,a,n-o.from);return _t.replace({widget:new rV((a-u%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=_t.replace({widget:new sV(t,r)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(Ng);t.startState.facet(Ng)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}const iV="•";function nV(t){return t>=32?iV:t==10?"":String.fromCharCode(9216+t)}class sV extends Lh{constructor(e,i){super(),this.options=e,this.code=i}eq(e){return e.code==this.code}toDOM(e){let i=nV(this.code),n=e.state.phrase("Control character")+" "+(ZU[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,n,i);if(s)return s;let r=document.createElement("span");return r.textContent=i,r.title=n,r.setAttribute("aria-label",n),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class rV extends Lh{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function oV(){return aV}const lV=_t.line({class:"cm-activeLine"}),aV=ds.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(let n of t.state.selection.ranges){let s=t.lineBlockAt(n.head);s.from>e&&(i.push(lV.range(s.from)),e=s.from)}return _t.set(i)}},{decorations:t=>t.decorations}),ib=2e3;function cV(t,e,i){let n=Math.min(e.line,i.line),s=Math.max(e.line,i.line),r=[];if(e.off>ib||i.off>ib||e.col<0||i.col<0){let o=Math.min(e.off,i.off),a=Math.max(e.off,i.off);for(let u=n;u<=s;u++){let h=t.doc.line(u);h.length<=a&&r.push(Se.range(h.from+o,h.to+a))}}else{let o=Math.min(e.col,i.col),a=Math.max(e.col,i.col);for(let u=n;u<=s;u++){let h=t.doc.line(u),p=Bx(h.text,o,t.tabSize,!0);if(p<0)r.push(Se.cursor(h.to));else{let m=Bx(h.text,a,t.tabSize);r.push(Se.range(h.from+p,h.from+m))}}}return r}function uV(t,e){let i=t.coordsAtPos(t.viewport.from);return i?Math.round(Math.abs((i.left-e)/t.defaultCharacterWidth)):-1}function MM(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(i),s=i-n.from,r=s>ib?-1:s==n.length?uV(t,e.clientX):Ah(n.text,t.state.tabSize,i-n.from);return{line:n.number,col:r,off:s}}function hV(t,e){let i=MM(t,e),n=t.state.selection;return i?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(i.line).from),o=s.state.doc.lineAt(r);i={line:o.number,col:i.col,off:Math.min(i.off,o.length)},n=n.map(s.changes)}},get(s,r,o){let a=MM(t,s);if(!a)return n;let u=cV(t.state,i,a);return u.length?o?Se.create(u.concat(n.ranges)):Se.create(u):n}}:null}function dV(t){let e=(i=>i.altKey&&i.button==0);return Ue.mouseSelectionStyle.of((i,n)=>e(n)?hV(i,n):null)}const AM=Fe.define({combine(t){let e,i;for(let n of t)e=e||n.topContainer,i=i||n.bottomContainer;return{topContainer:e,bottomContainer:i}}});function pR(t,e){let i=t.plugin(mR),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}const mR=ds.fromClass(class{constructor(t){this.input=t.state.facet(w0),this.specs=this.input.filter(i=>i),this.panels=this.specs.map(i=>i(t));let e=t.state.facet(AM);this.top=new Gm(t,!0,e.topContainer),this.bottom=new Gm(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(i=>i.top)),this.bottom.sync(this.panels.filter(i=>!i.top));for(let i of this.panels)i.dom.classList.add("cm-panel"),i.mount&&i.mount()}update(t){let e=t.state.facet(AM);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Gm(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Gm(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(w0);if(i!=this.input){let n=i.filter(u=>u),s=[],r=[],o=[],a=[];for(let u of n){let h=this.specs.indexOf(u),p;h<0?(p=u(t.view),a.push(p)):(p=this.panels[h],p.update&&p.update(t)),s.push(p),(p.top?r:o).push(p)}this.specs=n,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let u of a)u.dom.classList.add("cm-panel"),u.mount&&u.mount()}else for(let n of this.panels)n.update&&n.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>Ue.scrollMargins.of(e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class Gm{constructor(e,i,n){this.view=e,this.top=i,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let i of this.panels)i.destroy&&e.indexOf(i)<0&&i.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let i=this.container||this.view.dom;i.insertBefore(this.dom,this.top?i.firstChild:null)}let e=this.dom.firstChild;for(let i of this.panels)if(i.dom.parentNode==this.dom){for(;e!=i.dom;)e=LM(e);e=e.nextSibling}else this.dom.insertBefore(i.dom,e);for(;e;)e=LM(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function LM(t){let e=t.nextSibling;return t.remove(),e}const w0=Fe.define({enables:mR});function fV(t,e){let i,n=new Promise(o=>i=o),s=o=>pV(o,e,i);t.state.field(ny,!1)?t.dispatch({effects:gR.of(s)}):t.dispatch({effects:ci.appendConfig.of(ny.init(()=>[s]))});let r=vR.of(s);return{close:r,result:n.then(o=>((t.win.queueMicrotask||(u=>t.win.setTimeout(u,10)))(()=>{t.state.field(ny).indexOf(s)>-1&&t.dispatch({effects:r})}),o))}}const ny=Bo.define({create(){return[]},update(t,e){for(let i of e.effects)i.is(gR)?t=[i.value].concat(t):i.is(vR)&&(t=t.filter(n=>n!=i.value));return t},provide:t=>w0.computeN([t],e=>e.field(t))}),gR=ci.define(),vR=ci.define();function pV(t,e,i){let n=e.content?e.content(t,()=>o(null)):null;if(!n){if(n=xn("form"),e.input){let a=xn("input",e.input);/^(text|password|number|email|tel|url)$/.test(a.type)&&a.classList.add("cm-textfield"),a.name||(a.name="input"),n.appendChild(xn("label",(e.label||"")+": ",a))}else n.appendChild(document.createTextNode(e.label||""));n.appendChild(document.createTextNode(" ")),n.appendChild(xn("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let s=n.nodeName=="FORM"?[n]:n.querySelectorAll("form");for(let a=0;a<s.length;a++){let u=s[a];u.addEventListener("keydown",h=>{h.keyCode==27?(h.preventDefault(),o(null)):h.keyCode==13&&(h.preventDefault(),o(u))}),u.addEventListener("submit",h=>{h.preventDefault(),o(u)})}let r=xn("div",n,xn("button",{onclick:()=>o(null),"aria-label":t.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(r.className=e.class),r.classList.add("cm-dialog");function o(a){r.contains(r.ownerDocument.activeElement)&&t.focus(),i(a)}return{dom:r,top:e.top,mount:()=>{if(e.focus){let a;typeof e.focus=="string"?a=n.querySelector(e.focus):a=n.querySelector("input")||n.querySelector("button"),a&&"select"in a?a.select():a&&"focus"in a&&a.focus()}}}}class ja extends jc{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}ja.prototype.elementClass="";ja.prototype.toDOM=void 0;ja.prototype.mapMode=rr.TrackBefore;ja.prototype.startSide=ja.prototype.endSide=-1;ja.prototype.point=!0;const jg=Fe.define(),mV=Fe.define(),Rg=Fe.define(),TM=Fe.define({combine:t=>t.some(e=>e)});function gV(t){return[vV]}const vV=ds.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Rg).map(e=>new jM(t,e)),this.fixed=!t.state.facet(TM);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,n=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(n<(i.to-i.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(TM)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let i=Rt.iter(this.view.state.facet(jg),this.view.viewport.from),n=[],s=this.gutters.map(r=>new _V(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(r.type)){let o=!0;for(let a of r.type)if(a.type==$n.Text&&o){nb(i,n,a.from);for(let u of s)u.line(this.view,a,n);o=!1}else if(a.widget)for(let u of s)u.widget(this.view,a)}else if(r.type==$n.Text){nb(i,n,r.from);for(let o of s)o.line(this.view,r,n)}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Rg),i=t.state.facet(Rg),n=t.docChanged||t.heightChanged||t.viewportChanged||!Rt.eq(t.startState.facet(jg),t.state.facet(jg),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let s of this.gutters)s.update(t)&&(n=!0);else{n=!0;let s=[];for(let r of i){let o=e.indexOf(r);o<0?s.push(new jM(this.view,r)):(this.gutters[o].update(t),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=s}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Ue.scrollMargins.of(e=>{let i=e.plugin(t);if(!i||i.gutters.length==0||!i.fixed)return null;let n=i.dom.offsetWidth*e.scaleX,s=i.domAfter?i.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Mi.LTR?{left:n,right:s}:{right:n,left:s}})});function NM(t){return Array.isArray(t)?t:[t]}function nb(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class _V{constructor(e,i,n){this.gutter=e,this.height=n,this.i=0,this.cursor=Rt.iter(e.markers,i.from)}addElement(e,i,n){let{gutter:s}=this,r=(i.top-this.height)/e.scaleY,o=i.height/e.scaleY;if(this.i==s.elements.length){let a=new _R(e,o,r,n);s.elements.push(a),s.dom.appendChild(a.dom)}else s.elements[this.i].update(e,o,r,n);this.height=i.bottom,this.i++}line(e,i,n){let s=[];nb(this.cursor,s,i.from),n.length&&(s=s.concat(n));let r=this.gutter.config.lineMarker(e,i,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,i,s)}widget(e,i){let n=this.gutter.config.widgetMarker(e,i.widget,i),s=n?[n]:null;for(let r of e.state.facet(mV)){let o=r(e,i.widget,i);o&&(s||(s=[])).push(o)}s&&this.addElement(e,i,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let i=e.elements.pop();e.dom.removeChild(i.dom),i.destroy()}}}class jM{constructor(e,i){this.view=e,this.config=i,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in i.domEventHandlers)this.dom.addEventListener(n,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let u=r.getBoundingClientRect();o=(u.top+u.bottom)/2}else o=s.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);i.domEventHandlers[n](e,a,s)&&s.preventDefault()});this.markers=NM(i.markers(e)),i.initialSpacer&&(this.spacer=new _R(e,0,0,[i.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let i=this.markers;if(this.markers=NM(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let n=e.view.viewport;return!Rt.eq(this.markers,i,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class _R{constructor(e,i,n,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,i,n,s)}update(e,i,n,s){this.height!=i&&(this.height=i,this.dom.style.height=i+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),yV(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,i){let n="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let a=o,u=r<i.length?i[r++]:null,h=!1;if(u){let p=u.elementClass;p&&(n+=" "+p);for(let m=o;m<this.markers.length;m++)if(this.markers[m].compare(u)){a=m,h=!0;break}}else a=this.markers.length;for(;o<a;){let p=this.markers[o++];if(p.toDOM){p.destroy(s);let m=s.nextSibling;s.remove(),s=m}}if(!u)break;u.toDOM&&(h?s=s.nextSibling:this.dom.insertBefore(u.toDOM(e),s)),h&&o++}this.dom.className=n,this.markers=i}destroy(){this.setMarkers(null,[])}}function yV(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}const xV=Fe.define(),bV=Fe.define(),Qu=Fe.define({combine(t){return Fc(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,i){let n=Object.assign({},e);for(let s in i){let r=n[s],o=i[s];n[s]=r?(a,u,h)=>r(a,u,h)||o(a,u,h):o}return n}})}});class sy extends ja{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function ry(t,e){return t.state.facet(Qu).formatNumber(e,t.state)}const wV=Rg.compute([Qu],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(xV)},lineMarker(e,i,n){return n.some(s=>s.toDOM)?null:new sy(ry(e,e.state.doc.lineAt(i.from).number))},widgetMarker:(e,i,n)=>{for(let s of e.state.facet(bV)){let r=s(e,i,n);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(Qu)!=e.state.facet(Qu),initialSpacer(e){return new sy(ry(e,RM(e.state.doc.lines)))},updateSpacer(e,i){let n=ry(i.view,RM(i.view.state.doc.lines));return n==e.number?e:new sy(n)},domEventHandlers:t.facet(Qu).domEventHandlers,side:"before"}));function SV(t={}){return[Qu.of(t),gV(),wV]}function RM(t){let e=9;for(;e<t;)e=e*10+9;return e}const kV=new class extends ja{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},CV=jg.compute(["selection"],t=>{let e=[],i=-1;for(let n of t.selection.ranges){let s=t.doc.lineAt(n.head).from;s>i&&(i=s,e.push(kV.range(s)))}return Rt.of(e)});function EV(){return CV}const MV=1024;let AV=0;class Dr{constructor(e,i){this.from=e,this.to=i}}class bt{constructor(e={}){this.id=AV++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=ps.match(e)),i=>{let n=e(i);return n===void 0?null:[this,n]}}}bt.closedBy=new bt({deserialize:t=>t.split(" ")});bt.openedBy=new bt({deserialize:t=>t.split(" ")});bt.group=new bt({deserialize:t=>t.split(" ")});bt.isolate=new bt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});bt.contextHash=new bt({perNode:!0});bt.lookAhead=new bt({perNode:!0});bt.mounted=new bt({perNode:!0});class oh{constructor(e,i,n,s=!1){this.tree=e,this.overlay=i,this.parser=n,this.bracketed=s}static get(e){return e&&e.props&&e.props[bt.mounted.id]}}const LV=Object.create(null);class ps{constructor(e,i,n,s=0){this.name=e,this.props=i,this.id=n,this.flags=s}static define(e){let i=e.props&&e.props.length?Object.create(null):LV,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new ps(e.name||"",i,e.id,n);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");i[r[0].id]=r[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let i=this.prop(bt.group);return i?i.indexOf(e)>-1:!1}return this.id==e}static match(e){let i=Object.create(null);for(let n in e)for(let s of n.split(" "))i[s]=e[n];return n=>{for(let s=n.prop(bt.group),r=-1;r<(s?s.length:0);r++){let o=i[r<0?n.name:s[r]];if(o)return o}}}}ps.none=new ps("",Object.create(null),0,8);class SS{constructor(e){this.types=e;for(let i=0;i<e.length;i++)if(e[i].id!=i)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let i=[];for(let n of this.types){let s=null;for(let r of e){let o=r(n);if(o){s||(s=Object.assign({},n.props));let a=o[1],u=o[0];u.combine&&u.id in s&&(a=u.combine(s[u.id],a)),s[u.id]=a}}i.push(s?new ps(n.name,s,n.id,n.flags):n)}return new SS(i)}}const Qm=new WeakMap,DM=new WeakMap;var ai;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(ai||(ai={}));class ui{constructor(e,i,n,s,r){if(this.type=e,this.children=i,this.positions=n,this.length=s,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,a]of r)this.props[typeof o=="number"?o:o.id]=a}}toString(){let e=oh.get(this);if(e&&!e.overlay)return e.tree.toString();let i="";for(let n of this.children){let s=n.toString();s&&(i&&(i+=","),i+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(i.length?"("+i+")":""):i}cursor(e=0){return new S0(this.topNode,e)}cursorAt(e,i=0,n=0){let s=Qm.get(this)||this.topNode,r=new S0(s);return r.moveTo(e,i),Qm.set(this,r._tree),r}get topNode(){return new Xn(this,0,0,null)}resolve(e,i=0){let n=Rf(Qm.get(this)||this.topNode,e,i,!1);return Qm.set(this,n),n}resolveInner(e,i=0){let n=Rf(DM.get(this)||this.topNode,e,i,!0);return DM.set(this,n),n}resolveStack(e,i=0){return jV(this,e,i)}iterate(e){let{enter:i,leave:n,from:s=0,to:r=this.length}=e,o=e.mode||0,a=(o&ai.IncludeAnonymous)>0;for(let u=this.cursor(o|ai.IncludeAnonymous);;){let h=!1;if(u.from<=r&&u.to>=s&&(!a&&u.type.isAnonymous||i(u)!==!1)){if(u.firstChild())continue;h=!0}for(;h&&n&&(a||!u.type.isAnonymous)&&n(u),!u.nextSibling();){if(!u.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let i in this.props)e.push([+i,this.props[i]]);return e}balance(e={}){return this.children.length<=8?this:ES(ps.none,this.children,this.positions,0,this.children.length,0,this.length,(i,n,s)=>new ui(this.type,i,n,s,this.propValues),e.makeTree||((i,n,s)=>new ui(ps.none,i,n,s)))}static build(e){return RV(e)}}ui.empty=new ui(ps.none,[],[],0);class kS{constructor(e,i){this.buffer=e,this.index=i}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new kS(this.buffer,this.index)}}class Ra{constructor(e,i,n){this.buffer=e,this.length=i,this.set=n}get type(){return ps.none}toString(){let e=[];for(let i=0;i<this.buffer.length;)e.push(this.childString(i)),i=this.buffer[i+3];return e.join(",")}childString(e){let i=this.buffer[e],n=this.buffer[e+3],s=this.set.types[i],r=s.name;if(/\W/.test(r)&&!s.isError&&(r=JSON.stringify(r)),e+=4,n==e)return r;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,i,n,s,r){let{buffer:o}=this,a=-1;for(let u=e;u!=i&&!(yR(r,s,o[u+1],o[u+2])&&(a=u,n>0));u=o[u+3]);return a}slice(e,i,n){let s=this.buffer,r=new Uint16Array(i-e),o=0;for(let a=e,u=0;a<i;){r[u++]=s[a++],r[u++]=s[a++]-n;let h=r[u++]=s[a++]-n;r[u++]=s[a++]-e,o=Math.max(o,h)}return new Ra(r,o,this.set)}}function yR(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function Rf(t,e,i,n){for(var s;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let o=!n&&t instanceof Xn&&t.index<0?null:t.parent;if(!o)return t;t=o}let r=n?0:ai.IgnoreOverlays;if(n)for(let o=t,a=o.parent;a;o=a,a=o.parent)o instanceof Xn&&o.index<0&&((s=a.enter(e,i,r))===null||s===void 0?void 0:s.from)!=o.from&&(t=a);for(;;){let o=t.enter(e,i,r);if(!o)return t;t=o}}class xR{cursor(e=0){return new S0(this,e)}getChild(e,i=null,n=null){let s=BM(this,e,i,n);return s.length?s[0]:null}getChildren(e,i=null,n=null){return BM(this,e,i,n)}resolve(e,i=0){return Rf(this,e,i,!1)}resolveInner(e,i=0){return Rf(this,e,i,!0)}matchContext(e){return sb(this.parent,e)}enterUnfinishedNodesBefore(e){let i=this.childBefore(e),n=this;for(;i;){let s=i.lastChild;if(!s||s.to!=i.to)break;s.type.isError&&s.from==s.to?(n=i,i=s.prevSibling):i=s}return n}get node(){return this}get next(){return this.parent}}class Xn extends xR{constructor(e,i,n,s){super(),this._tree=e,this.from=i,this.index=n,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,i,n,s,r=0){for(let o=this;;){for(let{children:a,positions:u}=o._tree,h=i>0?a.length:-1;e!=h;e+=i){let p=a[e],m=u[e]+o.from,v;if(!(!(r&ai.EnterBracketed&&p instanceof ui&&(v=oh.get(p))&&!v.overlay&&v.bracketed&&n>=m&&n<=m+p.length)&&!yR(s,n,m,m+p.length))){if(p instanceof Ra){if(r&ai.ExcludeBuffers)continue;let _=p.findChild(0,p.buffer.length,i,n-m,s);if(_>-1)return new ko(new TV(o,p,e,m),null,_)}else if(r&ai.IncludeAnonymous||!p.type.isAnonymous||CS(p)){let _;if(!(r&ai.IgnoreMounts)&&(_=oh.get(p))&&!_.overlay)return new Xn(_.tree,m,e,o);let x=new Xn(p,m,e,o);return r&ai.IncludeAnonymous||!x.type.isAnonymous?x:x.nextChild(i<0?p.children.length-1:0,i,n,s,r)}}}if(r&ai.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+i:e=i<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,i,n=0){let s;if(!(n&ai.IgnoreOverlays)&&(s=oh.get(this._tree))&&s.overlay){let r=e-this.from,o=n&ai.EnterBracketed&&s.bracketed;for(let{from:a,to:u}of s.overlay)if((i>0||o?a<=r:a<r)&&(i<0||o?u>=r:u>r))return new Xn(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,i,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function BM(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(i!=null){for(let o=!1;!o;)if(o=s.type.is(i),!s.nextSibling())return r}for(;;){if(n!=null&&s.type.is(n))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return n==null?r:[]}}function sb(t,e,i=e.length-1){for(let n=t;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class TV{constructor(e,i,n,s){this.parent=e,this.buffer=i,this.index=n,this.start=s}}class ko extends xR{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,i,n){super(),this.context=e,this._parent=i,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,i,n){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,i-this.context.start,n);return r<0?null:new ko(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,i,n=0){if(n&ai.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],i>0?1:-1,e-this.context.start,i);return r<0?null:new ko(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,i=e.buffer[this.index+3];return i<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new ko(this.context,this._parent,i):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,i=this._parent?this._parent.index+4:0;return this.index==i?this.externalSibling(-1):new ko(this.context,this._parent,e.findChild(i,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],i=[],{buffer:n}=this.context,s=this.index+4,r=n.buffer[this.index+3];if(r>s){let o=n.buffer[this.index+1];e.push(n.slice(s,r,o)),i.push(0)}return new ui(this.type,e,i,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function bR(t){if(!t.length)return null;let e=0,i=t[0];for(let r=1;r<t.length;r++){let o=t[r];(o.from>i.from||o.to<i.to)&&(i=o,e=r)}let n=i instanceof Xn&&i.index<0?null:i.parent,s=t.slice();return n?s[e]=n:s.splice(e,1),new NV(s,i)}class NV{constructor(e,i){this.heads=e,this.node=i}get next(){return bR(this.heads)}}function jV(t,e,i){let n=t.resolveInner(e,i),s=null;for(let r=n instanceof Xn?n:n.context.parent;r;r=r.parent)if(r.index<0){let o=r.parent;(s||(s=[n])).push(o.resolve(e,i)),r=o}else{let o=oh.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let a=new Xn(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[n])).push(Rf(a,e,i,!1))}}return s?bR(s):n}class S0{get name(){return this.type.name}constructor(e,i=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=i&~ai.EnterBracketed,e instanceof Xn)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,i){this.index=e;let{start:n,buffer:s}=this.buffer;return this.type=i||s.set.types[s.buffer[e]],this.from=n+s.buffer[e+1],this.to=n+s.buffer[e+2],!0}yield(e){return e?e instanceof Xn?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,i,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,i,n,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,i-this.buffer.start,n);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,i,n=this.mode){return this.buffer?n&ai.ExcludeBuffers?!1:this.enterChild(1,e,i):this.yield(this._tree.enter(e,i,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ai.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ai.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:i}=this.buffer,n=this.stack.length-1;if(e<0){let s=n<0?0:this.stack[n]+4;if(this.index!=s)return this.yieldBuf(i.findChild(s,this.index,-1,0,4))}else{let s=i.buffer[this.index+3];if(s<(n<0?i.buffer.length:i.buffer[this.stack[n]+3]))return this.yieldBuf(s)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let i,n,{buffer:s}=this;if(s){if(e>0){if(this.index<s.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(s.buffer.buffer[r+3]<this.index)return!1;({index:i,parent:n}=s)}else({index:i,_parent:n}=this._tree);for(;n;{index:i,_parent:n}=n)if(i>-1)for(let r=i+e,o=e<0?-1:n._tree.children.length;r!=o;r+=e){let a=n._tree.children[r];if(this.mode&ai.IncludeAnonymous||a instanceof Ra||!a.type.isAnonymous||CS(a))return!1}return!0}move(e,i){if(i&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,i=0){for(;(this.from==this.to||(i<1?this.from>=e:this.from>e)||(i>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,i););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,i=null,n=0;if(e&&e.context==this.buffer)e:for(let s=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;i=o,n=r+1;break e}s=this.stack[--r]}for(let s=n;s<this.stack.length;s++)i=new ko(this.buffer,i,this.stack[s]);return this.bufferNode=new ko(this.buffer,i,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,i){for(let n=0;;){let s=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&i&&i(this),s=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,s=!0}}}matchContext(e){if(!this.buffer)return sb(this.node.parent,e);let{buffer:i}=this.buffer,{types:n}=i.set;for(let s=e.length-1,r=this.stack.length-1;s>=0;r--){if(r<0)return sb(this._tree,e,s);let o=n[i.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}}function CS(t){return t.children.some(e=>e instanceof Ra||!e.type.isAnonymous||CS(e))}function RV(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:s=MV,reused:r=[],minRepeatType:o=n.types.length}=t,a=Array.isArray(i)?new kS(i,i.length):i,u=n.types,h=0,p=0;function m(j,R,z,J,G,q){let{id:X,start:I,end:T,size:H}=a,F=p,P=h;if(H<0)if(a.next(),H==-1){let $=r[X];z.push($),J.push(I-j);return}else if(H==-3){h=X;return}else if(H==-4){p=X;return}else throw new RangeError(`Unrecognized record size: ${H}`);let U=u[X],V,K,D=I-j;if(T-I<=s&&(K=C(a.pos-R,G))){let $=new Uint16Array(K.size-K.skip),Y=a.pos-K.size,B=$.length;for(;a.pos>Y;)B=k(K.start,$,B);V=new Ra($,T-K.start,n),D=K.start-j}else{let $=a.pos-H;a.next();let Y=[],B=[],ee=X>=o?X:-1,ie=0,re=T;for(;a.pos>$;)ee>=0&&a.id==ee&&a.size>=0?(a.end<=re-s&&(x(Y,B,I,ie,a.end,re,ee,F,P),ie=Y.length,re=a.end),a.next()):q>2500?v(I,$,Y,B):m(I,$,Y,B,ee,q+1);if(ee>=0&&ie>0&&ie<Y.length&&x(Y,B,I,ie,I,re,ee,F,P),Y.reverse(),B.reverse(),ee>-1&&ie>0){let ge=_(U,P);V=ES(U,Y,B,0,Y.length,0,T-I,ge,ge)}else V=S(U,Y,B,T-I,F-T,P)}z.push(V),J.push(D)}function v(j,R,z,J){let G=[],q=0,X=-1;for(;a.pos>R;){let{id:I,start:T,end:H,size:F}=a;if(F>4)a.next();else{if(X>-1&&T<X)break;X<0&&(X=H-s),G.push(I,T,H),q++,a.next()}}if(q){let I=new Uint16Array(q*4),T=G[G.length-2];for(let H=G.length-3,F=0;H>=0;H-=3)I[F++]=G[H],I[F++]=G[H+1]-T,I[F++]=G[H+2]-T,I[F++]=F;z.push(new Ra(I,G[2]-T,n)),J.push(T-j)}}function _(j,R){return(z,J,G)=>{let q=0,X=z.length-1,I,T;if(X>=0&&(I=z[X])instanceof ui){if(!X&&I.type==j&&I.length==G)return I;(T=I.prop(bt.lookAhead))&&(q=J[X]+I.length+T)}return S(j,z,J,G,q,R)}}function x(j,R,z,J,G,q,X,I,T){let H=[],F=[];for(;j.length>J;)H.push(j.pop()),F.push(R.pop()+z-G);j.push(S(n.types[X],H,F,q-G,I-q,T)),R.push(G-z)}function S(j,R,z,J,G,q,X){if(q){let I=[bt.contextHash,q];X=X?[I].concat(X):[I]}if(G>25){let I=[bt.lookAhead,G];X=X?[I].concat(X):[I]}return new ui(j,R,z,J,X)}function C(j,R){let z=a.fork(),J=0,G=0,q=0,X=z.end-s,I={size:0,start:0,skip:0};e:for(let T=z.pos-j;z.pos>T;){let H=z.size;if(z.id==R&&H>=0){I.size=J,I.start=G,I.skip=q,q+=4,J+=4,z.next();continue}let F=z.pos-H;if(H<0||F<T||z.start<X)break;let P=z.id>=o?4:0,U=z.start;for(z.next();z.pos>F;){if(z.size<0)if(z.size==-3||z.size==-4)P+=4;else break e;else z.id>=o&&(P+=4);z.next()}G=U,J+=H,q+=P}return(R<0||J==j)&&(I.size=J,I.start=G,I.skip=q),I.size>4?I:void 0}function k(j,R,z){let{id:J,start:G,end:q,size:X}=a;if(a.next(),X>=0&&J<o){let I=z;if(X>4){let T=a.pos-(X-4);for(;a.pos>T;)z=k(j,R,z)}R[--z]=I,R[--z]=q-j,R[--z]=G-j,R[--z]=J}else X==-3?h=J:X==-4&&(p=J);return z}let M=[],L=[];for(;a.pos>0;)m(t.start||0,t.bufferStart||0,M,L,-1,0);let N=(e=t.length)!==null&&e!==void 0?e:M.length?L[0]+M[0].length:0;return new ui(u[t.topID],M.reverse(),L.reverse(),N)}const OM=new WeakMap;function Dg(t,e){if(!t.isAnonymous||e instanceof Ra||e.type!=t)return 1;let i=OM.get(e);if(i==null){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof ui)){i=1;break}i+=Dg(t,n)}OM.set(e,i)}return i}function ES(t,e,i,n,s,r,o,a,u){let h=0;for(let x=n;x<s;x++)h+=Dg(t,e[x]);let p=Math.ceil(h*1.5/8),m=[],v=[];function _(x,S,C,k,M){for(let L=C;L<k;){let N=L,j=S[L],R=Dg(t,x[L]);for(L++;L<k;L++){let z=Dg(t,x[L]);if(R+z>=p)break;R+=z}if(L==N+1){if(R>p){let z=x[N];_(z.children,z.positions,0,z.children.length,S[N]+M);continue}m.push(x[N])}else{let z=S[L-1]+x[L-1].length-j;m.push(ES(t,x,S,N,L,j,z,null,u))}v.push(j+M-r)}}return _(e,i,n,s,0),(a||u)(m,v,o)}class Nle{constructor(){this.map=new WeakMap}setBuffer(e,i,n){let s=this.map.get(e);s||this.map.set(e,s=new Map),s.set(i,n)}getBuffer(e,i){let n=this.map.get(e);return n&&n.get(i)}set(e,i){e instanceof ko?this.setBuffer(e.context.buffer,e.index,i):e instanceof Xn&&this.map.set(e.tree,i)}get(e){return e instanceof ko?this.getBuffer(e.context.buffer,e.index):e instanceof Xn?this.map.get(e.tree):void 0}cursorSet(e,i){e.buffer?this.setBuffer(e.buffer.buffer,e.index,i):this.map.set(e.tree,i)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class Sl{constructor(e,i,n,s,r=!1,o=!1){this.from=e,this.to=i,this.tree=n,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,i=[],n=!1){let s=[new Sl(0,e.length,e,0,!1,n)];for(let r of i)r.to>e.length&&s.push(r);return s}static applyChanges(e,i,n=128){if(!i.length)return e;let s=[],r=1,o=e.length?e[0]:null;for(let a=0,u=0,h=0;;a++){let p=a<i.length?i[a]:null,m=p?p.fromA:1e9;if(m-u>=n)for(;o&&o.from<m;){let v=o;if(u>=v.from||m<=v.to||h){let _=Math.max(v.from,u)-h,x=Math.min(v.to,m)-h;v=_>=x?null:new Sl(_,x,v.tree,v.offset+h,a>0,!!p)}if(v&&s.push(v),o.to>m)break;o=r<e.length?e[r++]:null}if(!p)break;u=p.toA,h=p.toA-p.toB}return s}}class wR{startParse(e,i,n){return typeof e=="string"&&(e=new DV(e)),n=n?n.length?n.map(s=>new Dr(s.from,s.to)):[new Dr(0,0)]:[new Dr(0,e.length)],this.createParse(e,i||[],n)}parse(e,i,n){let s=this.startParse(e,i,n);for(;;){let r=s.advance();if(r)return r}}}class DV{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,i){return this.string.slice(e,i)}}function jle(t){return(e,i,n,s)=>new OV(e,t,i,n,s)}class IM{constructor(e,i,n,s,r,o){this.parser=e,this.parse=i,this.overlay=n,this.bracketed=s,this.target=r,this.from=o}}function PM(t){if(!t.length||t.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(t))}class BV{constructor(e,i,n,s,r,o,a,u){this.parser=e,this.predicate=i,this.mounts=n,this.index=s,this.start=r,this.bracketed=o,this.target=a,this.prev=u,this.depth=0,this.ranges=[]}}const rb=new bt({perNode:!0});class OV{constructor(e,i,n,s,r){this.nest=i,this.input=n,this.fragments=s,this.ranges=r,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let n=this.baseParse.advance();if(!n)return null;if(this.baseParse=null,this.baseTree=n,this.startInner(),this.stoppedAt!=null)for(let s of this.inner)s.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let n=this.baseTree;return this.stoppedAt!=null&&(n=new ui(n.type,n.children,n.positions,n.length,n.propValues.concat([[rb,this.stoppedAt]]))),n}let e=this.inner[this.innerDone],i=e.parse.advance();if(i){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[bt.mounted.id]=new oh(i,e.overlay,e.parser,e.bracketed),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let i=this.innerDone;i<this.inner.length;i++)this.inner[i].from<e&&(e=Math.min(e,this.inner[i].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let i=this.innerDone;i<this.inner.length;i++)this.inner[i].parse.stopAt(e)}startInner(){let e=new zV(this.fragments),i=null,n=null,s=new S0(new Xn(this.baseTree,this.ranges[0].from,0,null),ai.IncludeAnonymous|ai.IgnoreMounts);e:for(let r,o;;){let a=!0,u;if(this.stoppedAt!=null&&s.from>=this.stoppedAt)a=!1;else if(e.hasNode(s)){if(i){let h=i.mounts.find(p=>p.frag.from<=s.from&&p.frag.to>=s.to&&p.mount.overlay);if(h)for(let p of h.mount.overlay){let m=p.from+h.pos,v=p.to+h.pos;m>=s.from&&v<=s.to&&!i.ranges.some(_=>_.from<v&&_.to>m)&&i.ranges.push({from:m,to:v})}}a=!1}else if(n&&(o=IV(n.ranges,s.from,s.to)))a=o!=2;else if(!s.type.isAnonymous&&(r=this.nest(s,this.input))&&(s.from<s.to||!r.overlay)){s.tree||(PV(s),i&&i.depth++,n&&n.depth++);let h=e.findMounts(s.from,r.parser);if(typeof r.overlay=="function")i=new BV(r.parser,r.overlay,h,this.inner.length,s.from,!!r.bracketed,s.tree,i);else{let p=FM(this.ranges,r.overlay||(s.from<s.to?[new Dr(s.from,s.to)]:[]));p.length&&PM(p),(p.length||!r.overlay)&&this.inner.push(new IM(r.parser,p.length?r.parser.startParse(this.input,HM(h,p),p):r.parser.startParse(""),r.overlay?r.overlay.map(m=>new Dr(m.from-s.from,m.to-s.from)):null,!!r.bracketed,s.tree,p.length?p[0].from:s.from)),r.overlay?p.length&&(n={ranges:p,depth:0,prev:n}):a=!1}}else if(i&&(u=i.predicate(s))&&(u===!0&&(u=new Dr(s.from,s.to)),u.from<u.to)){let h=i.ranges.length-1;h>=0&&i.ranges[h].to==u.from?i.ranges[h]={from:i.ranges[h].from,to:u.to}:i.ranges.push(u)}if(a&&s.firstChild())i&&i.depth++,n&&n.depth++;else for(;!s.nextSibling();){if(!s.parent())break e;if(i&&!--i.depth){let h=FM(this.ranges,i.ranges);h.length&&(PM(h),this.inner.splice(i.index,0,new IM(i.parser,i.parser.startParse(this.input,HM(i.mounts,h),h),i.ranges.map(p=>new Dr(p.from-i.start,p.to-i.start)),i.bracketed,i.target,h[0].from))),i=i.prev}n&&!--n.depth&&(n=n.prev)}}}}function IV(t,e,i){for(let n of t){if(n.from>=i)break;if(n.to>e)return n.from<=e&&n.to>=i?2:1}return 0}function zM(t,e,i,n,s,r){if(e<i){let o=t.buffer[e+1];n.push(t.slice(e,i,o)),s.push(o-r)}}function PV(t){let{node:e}=t,i=[],n=e.context.buffer;do i.push(t.index),t.parent();while(!t.tree);let s=t.tree,r=s.children.indexOf(n),o=s.children[r],a=o.buffer,u=[r];function h(p,m,v,_,x,S){let C=i[S],k=[],M=[];zM(o,p,C,k,M,_);let L=a[C+1],N=a[C+2];u.push(k.length);let j=S?h(C+4,a[C+3],o.set.types[a[C]],L,N-L,S-1):e.toTree();return k.push(j),M.push(L-_),zM(o,a[C+3],m,k,M,_),new ui(v,k,M,x)}s.children[r]=h(0,a.length,ps.none,0,o.length,i.length-1);for(let p of u){let m=t.tree.children[p],v=t.tree.positions[p];t.yield(new Xn(m,v+t.from,p,t._tree))}}class $M{constructor(e,i){this.offset=i,this.done=!1,this.cursor=e.cursor(ai.IncludeAnonymous|ai.IgnoreMounts)}moveTo(e){let{cursor:i}=this,n=e-this.offset;for(;!this.done&&i.from<n;)if(!(i.to>=e&&i.enter(n,1,ai.IgnoreOverlays|ai.ExcludeBuffers)))if(i.to<=e)i.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let i=this.cursor.tree;;){if(i==e.tree)return!0;if(i.children.length&&i.positions[0]==0&&i.children[0]instanceof ui)i=i.children[0];else break}return!1}}class zV{constructor(e){var i;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let n=this.curFrag=e[0];this.curTo=(i=n.tree.prop(rb))!==null&&i!==void 0?i:n.to,this.inner=new $M(n.tree,-n.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let i=this.curFrag=this.fragments[this.fragI];this.curTo=(e=i.tree.prop(rb))!==null&&e!==void 0?e:i.to,this.inner=new $M(i.tree,-i.offset)}}findMounts(e,i){var n;let s=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let r=this.inner.cursor.node;r;r=r.parent){let o=(n=r.tree)===null||n===void 0?void 0:n.prop(bt.mounted);if(o&&o.parser==i)for(let a=this.fragI;a<this.fragments.length;a++){let u=this.fragments[a];if(u.from>=r.to)break;u.tree==this.curFrag.tree&&s.push({frag:u,pos:r.from-u.offset,mount:o})}}}return s}}function FM(t,e){let i=null,n=e;for(let s=1,r=0;s<t.length;s++){let o=t[s-1].to,a=t[s].from;for(;r<n.length;r++){let u=n[r];if(u.from>=a)break;u.to<=o||(i||(n=i=e.slice()),u.from<o?(i[r]=new Dr(u.from,o),u.to>a&&i.splice(r+1,0,new Dr(a,u.to))):u.to>a?i[r--]=new Dr(a,u.to):i.splice(r--,1))}}return n}function $V(t,e,i,n){let s=0,r=0,o=!1,a=!1,u=-1e9,h=[];for(;;){let p=s==t.length?1e9:o?t[s].to:t[s].from,m=r==e.length?1e9:a?e[r].to:e[r].from;if(o!=a){let v=Math.max(u,i),_=Math.min(p,m,n);v<_&&h.push(new Dr(v,_))}if(u=Math.min(p,m),u==1e9)break;p==u&&(o?(o=!1,s++):o=!0),m==u&&(a?(a=!1,r++):a=!0)}return h}function HM(t,e){let i=[];for(let{pos:n,mount:s,frag:r}of t){let o=n+(s.overlay?s.overlay[0].from:0),a=o+s.tree.length,u=Math.max(r.from,o),h=Math.min(r.to,a);if(s.overlay){let p=s.overlay.map(v=>new Dr(v.from+n,v.to+n)),m=$V(e,p,u,h);for(let v=0,_=u;;v++){let x=v==m.length,S=x?h:m[v].from;if(S>_&&i.push(new Sl(_,S,s.tree,-o,r.from>=_||r.openStart,r.to<=S||r.openEnd)),x)break;_=m[v].to}}else i.push(new Sl(u,h,s.tree,-o,r.from>=o||r.openStart,r.to<=a||r.openEnd))}return i}let FV=0;class Tr{constructor(e,i,n,s){this.name=e,this.set=i,this.base=n,this.modified=s,this.id=FV++}toString(){let{name:e}=this;for(let i of this.modified)i.name&&(e=`${i.name}(${e})`);return e}static define(e,i){let n=typeof e=="string"?e:"?";if(e instanceof Tr&&(i=e),i?.base)throw new Error("Can not derive from a modified tag");let s=new Tr(n,[],null,[]);if(s.set.push(s),i)for(let r of i.set)s.set.push(r);return s}static defineModifier(e){let i=new k0(e);return n=>n.modified.indexOf(i)>-1?n:k0.get(n.base||n,n.modified.concat(i).sort((s,r)=>s.id-r.id))}}let HV=0;class k0{constructor(e){this.name=e,this.instances=[],this.id=HV++}static get(e,i){if(!i.length)return e;let n=i[0].instances.find(a=>a.base==e&&WV(i,a.modified));if(n)return n;let s=[],r=new Tr(e.name,s,e,i);for(let a of i)a.instances.push(r);let o=qV(i);for(let a of e.set)if(!a.modified.length)for(let u of o)s.push(k0.get(a,u));return r}}function WV(t,e){return t.length==e.length&&t.every((i,n)=>i==e[n])}function qV(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(t[i]));return e.sort((i,n)=>n.length-i.length)}function UV(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let s of i.split(" "))if(s){let r=[],o=2,a=s;for(let m=0;;){if(a=="..."&&m>0&&m+3==s.length){o=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!v)throw new RangeError("Invalid path: "+s);if(r.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),m+=v[0].length,m==s.length)break;let _=s[m++];if(m==s.length&&_=="!"){o=0;break}if(_!="/")throw new RangeError("Invalid path: "+s);a=s.slice(m)}let u=r.length-1,h=r[u];if(!h)throw new RangeError("Invalid path: "+s);let p=new Df(n,o,u>0?r.slice(0,u):null);e[h]=p.sort(e[h])}}return SR.add(e)}const SR=new bt({combine(t,e){let i,n,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),i&&i.mode==s.mode&&!s.context&&!i.context)continue;let r=new Df(s.tags,s.mode,s.context);i?i.next=r:n=r,i=r}return n}});class Df{constructor(e,i,n,s){this.tags=e,this.mode=i,this.context=n,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Df.empty=new Df([],2,null);function kR(t,e){let i=Object.create(null);for(let r of t)if(!Array.isArray(r.tag))i[r.tag.id]=r.class;else for(let o of r.tag)i[o.id]=r.class;let{scope:n,all:s=null}=e||{};return{style:r=>{let o=s;for(let a of r)for(let u of a.set){let h=i[u.id];if(h){o=o?o+" "+h:h;break}}return o},scope:n}}function VV(t,e){let i=null;for(let n of t){let s=n.style(e);s&&(i=i?i+" "+s:s)}return i}function KV(t,e,i,n=0,s=t.length){let r=new YV(n,Array.isArray(e)?e:[e],i);r.highlightRange(t.cursor(),n,s,"",r.highlighters),r.flush(s)}class YV{constructor(e,i,n){this.at=e,this.highlighters=i,this.span=n,this.class=""}startSpan(e,i){i!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=i)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,i,n,s,r){let{type:o,from:a,to:u}=e;if(a>=n||u<=i)return;o.isTop&&(r=this.highlighters.filter(_=>!_.scope||_.scope(o)));let h=s,p=GV(e)||Df.empty,m=VV(r,p.tags);if(m&&(h&&(h+=" "),h+=m,p.mode==1&&(s+=(s?" ":"")+m)),this.startSpan(Math.max(i,a),h),p.opaque)return;let v=e.tree&&e.tree.prop(bt.mounted);if(v&&v.overlay){let _=e.node.enter(v.overlay[0].from+a,1),x=this.highlighters.filter(C=>!C.scope||C.scope(v.tree.type)),S=e.firstChild();for(let C=0,k=a;;C++){let M=C<v.overlay.length?v.overlay[C]:null,L=M?M.from+a:u,N=Math.max(i,k),j=Math.min(n,L);if(N<j&&S)for(;e.from<j&&(this.highlightRange(e,N,j,s,r),this.startSpan(Math.min(j,e.to),h),!(e.to>=L||!e.nextSibling())););if(!M||L>n)break;k=M.to+a,k>i&&(this.highlightRange(_.cursor(),Math.max(i,M.from+a),Math.min(n,k),"",x),this.startSpan(Math.min(n,k),h))}S&&e.parent()}else if(e.firstChild()){v&&(s="");do if(!(e.to<=i)){if(e.from>=n)break;this.highlightRange(e,i,n,s,r),this.startSpan(Math.min(n,e.to),h)}while(e.nextSibling());e.parent()}}}function GV(t){let e=t.type.prop(SR);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const Be=Tr.define,Xm=Be(),va=Be(),WM=Be(va),qM=Be(va),_a=Be(),Zm=Be(_a),oy=Be(_a),vo=Be(),ac=Be(vo),ho=Be(),fo=Be(),ob=Be(),$d=Be(ob),Jm=Be(),je={comment:Xm,lineComment:Be(Xm),blockComment:Be(Xm),docComment:Be(Xm),name:va,variableName:Be(va),typeName:WM,tagName:Be(WM),propertyName:qM,attributeName:Be(qM),className:Be(va),labelName:Be(va),namespace:Be(va),macroName:Be(va),literal:_a,string:Zm,docString:Be(Zm),character:Be(Zm),attributeValue:Be(Zm),number:oy,integer:Be(oy),float:Be(oy),bool:Be(_a),regexp:Be(_a),escape:Be(_a),color:Be(_a),url:Be(_a),keyword:ho,self:Be(ho),null:Be(ho),atom:Be(ho),unit:Be(ho),modifier:Be(ho),operatorKeyword:Be(ho),controlKeyword:Be(ho),definitionKeyword:Be(ho),moduleKeyword:Be(ho),operator:fo,derefOperator:Be(fo),arithmeticOperator:Be(fo),logicOperator:Be(fo),bitwiseOperator:Be(fo),compareOperator:Be(fo),updateOperator:Be(fo),definitionOperator:Be(fo),typeOperator:Be(fo),controlOperator:Be(fo),punctuation:ob,separator:Be(ob),bracket:$d,angleBracket:Be($d),squareBracket:Be($d),paren:Be($d),brace:Be($d),content:vo,heading:ac,heading1:Be(ac),heading2:Be(ac),heading3:Be(ac),heading4:Be(ac),heading5:Be(ac),heading6:Be(ac),contentSeparator:Be(vo),list:Be(vo),quote:Be(vo),emphasis:Be(vo),strong:Be(vo),link:Be(vo),monospace:Be(vo),strikethrough:Be(vo),inserted:Be(),deleted:Be(),changed:Be(),invalid:Be(),meta:Jm,documentMeta:Be(Jm),annotation:Be(Jm),processingInstruction:Be(Jm),definition:Tr.defineModifier("definition"),constant:Tr.defineModifier("constant"),function:Tr.defineModifier("function"),standard:Tr.defineModifier("standard"),local:Tr.defineModifier("local"),special:Tr.defineModifier("special")};for(let t in je){let e=je[t];e instanceof Tr&&(e.name=t)}kR([{tag:je.link,class:"tok-link"},{tag:je.heading,class:"tok-heading"},{tag:je.emphasis,class:"tok-emphasis"},{tag:je.strong,class:"tok-strong"},{tag:je.keyword,class:"tok-keyword"},{tag:je.atom,class:"tok-atom"},{tag:je.bool,class:"tok-bool"},{tag:je.url,class:"tok-url"},{tag:je.labelName,class:"tok-labelName"},{tag:je.inserted,class:"tok-inserted"},{tag:je.deleted,class:"tok-deleted"},{tag:je.literal,class:"tok-literal"},{tag:je.string,class:"tok-string"},{tag:je.number,class:"tok-number"},{tag:[je.regexp,je.escape,je.special(je.string)],class:"tok-string2"},{tag:je.variableName,class:"tok-variableName"},{tag:je.local(je.variableName),class:"tok-variableName tok-local"},{tag:je.definition(je.variableName),class:"tok-variableName tok-definition"},{tag:je.special(je.variableName),class:"tok-variableName2"},{tag:je.definition(je.propertyName),class:"tok-propertyName tok-definition"},{tag:je.typeName,class:"tok-typeName"},{tag:je.namespace,class:"tok-namespace"},{tag:je.className,class:"tok-className"},{tag:je.macroName,class:"tok-macroName"},{tag:je.propertyName,class:"tok-propertyName"},{tag:je.operator,class:"tok-operator"},{tag:je.comment,class:"tok-comment"},{tag:je.meta,class:"tok-meta"},{tag:je.invalid,class:"tok-invalid"},{tag:je.punctuation,class:"tok-punctuation"}]);var ly;const _c=new bt;function CR(t){return Fe.define({combine:t?e=>e.concat(t):void 0})}const QV=new bt;class Br{constructor(e,i,n=[],s=""){this.data=e,this.name=s,It.prototype.hasOwnProperty("tree")||Object.defineProperty(It.prototype,"tree",{get(){return No(this)}}),this.parser=i,this.extension=[xh.of(this),It.languageData.of((r,o,a)=>{let u=UM(r,o,a),h=u.type.prop(_c);if(!h)return[];let p=r.facet(h),m=u.type.prop(QV);if(m){let v=u.resolve(o-u.from,a);for(let _ of m)if(_.test(v,r)){let x=r.facet(_.facet);return _.type=="replace"?x:x.concat(p)}}return p})].concat(n)}isActiveAt(e,i,n=-1){return UM(e,i,n).type.prop(_c)==this.data}findRegions(e){let i=e.facet(xh);if(i?.data==this.data)return[{from:0,to:e.doc.length}];if(!i||!i.allowsNesting)return[];let n=[],s=(r,o)=>{if(r.prop(_c)==this.data){n.push({from:o,to:o+r.length});return}let a=r.prop(bt.mounted);if(a){if(a.tree.prop(_c)==this.data){if(a.overlay)for(let u of a.overlay)n.push({from:u.from+o,to:u.to+o});else n.push({from:o,to:o+r.length});return}else if(a.overlay){let u=n.length;if(s(a.tree,a.overlay[0].from+o),n.length>u)return}}for(let u=0;u<r.children.length;u++){let h=r.children[u];h instanceof ui&&s(h,r.positions[u]+o)}};return s(No(e),0),n}get allowsNesting(){return!0}}Br.setState=ci.define();function UM(t,e,i){let n=t.facet(xh),s=No(t).topNode;if(!n||n.allowsNesting)for(let r=s;r;r=r.enter(e,i,ai.ExcludeBuffers|ai.EnterBracketed))r.type.isTop&&(s=r);return s}class lb extends Br{constructor(e,i,n){super(e,i,[],n),this.parser=i}static define(e){let i=CR(e.languageData);return new lb(i,e.parser.configure({props:[_c.add(n=>n.isTop?i:void 0)]}),e.name)}configure(e,i){return new lb(this.data,this.parser.configure(e),i||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function No(t){let e=t.field(Br.state,!1);return e?e.tree:ui.empty}class XV{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,i){let n=this.cursorPos-this.string.length;return e<n||i>=this.cursorPos?this.doc.sliceString(e,i):this.string.slice(e-n,i-n)}}let Fd=null;class _h{constructor(e,i,n=[],s,r,o,a,u){this.parser=e,this.state=i,this.fragments=n,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=a,this.scheduleOn=u,this.parse=null,this.tempSkipped=[]}static create(e,i,n){return new _h(e,i,[],ui.empty,0,n,[],null)}startParse(){return this.parser.startParse(new XV(this.state.doc),this.fragments)}work(e,i){return i!=null&&i>=this.state.doc.length&&(i=void 0),this.tree!=ui.empty&&this.isDone(i??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),i!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>i)&&i<this.state.doc.length&&this.parse.stopAt(i);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(Sl.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(i??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,i;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(i=this.parse.advance()););}),this.treeLen=e,this.tree=i,this.fragments=this.withoutTempSkipped(Sl.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let i=Fd;Fd=this;try{return e()}finally{Fd=i}}withoutTempSkipped(e){for(let i;i=this.tempSkipped.pop();)e=VM(e,i.from,i.to);return e}changes(e,i){let{fragments:n,tree:s,treeLen:r,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let u=[];if(e.iterChangedRanges((h,p,m,v)=>u.push({fromA:h,toA:p,fromB:m,toB:v})),n=Sl.applyChanges(n,u),s=ui.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let h of this.skipped){let p=e.mapPos(h.from,1),m=e.mapPos(h.to,-1);p<m&&a.push({from:p,to:m})}}}return new _h(this.parser,i,n,s,r,o,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let i=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:s,to:r}=this.skipped[n];s<e.to&&r>e.from&&(this.fragments=VM(this.fragments,s,r),this.skipped.splice(n--,1))}return this.skipped.length>=i?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,i){this.skipped.push({from:e,to:i})}static getSkippingParser(e){return new class extends wR{createParse(i,n,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let u=Fd;if(u){for(let h of s)u.tempSkipped.push(h);e&&(u.scheduleOn=u.scheduleOn?Promise.all([u.scheduleOn,e]):e)}return this.parsedPos=o,new ui(ps.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let i=this.fragments;return this.treeLen>=e&&i.length&&i[0].from==0&&i[0].to>=e}static get(){return Fd}}function VM(t,e,i){return Sl.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class yh{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let i=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),i.viewport.to);return i.work(20,n)||i.takeTree(),new yh(i)}static init(e){let i=Math.min(3e3,e.doc.length),n=_h.create(e.facet(xh).parser,e,{from:0,to:i});return n.work(20,i)||n.takeTree(),new yh(n)}}Br.state=Bo.define({create:yh.init,update(t,e){for(let i of e.effects)if(i.is(Br.setState))return i.value;return e.startState.facet(xh)!=e.state.facet(xh)?yh.init(e.state):t.apply(e)}});let ER=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(ER=t=>{let e=-1,i=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const ay=typeof navigator<"u"&&(!((ly=navigator.scheduling)===null||ly===void 0)&&ly.isInputPending)?()=>navigator.scheduling.isInputPending():null,ZV=ds.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let i=this.view.state.field(Br.state).context;(i.updateViewport(e.view.viewport)||this.view.viewport.to>i.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(i)}scheduleWork(){if(this.working)return;let{state:e}=this.view,i=e.field(Br.state);(i.tree!=i.context.tree||!i.context.isDone(e.doc.length))&&(this.working=ER(this.work))}work(e){this.working=null;let i=Date.now();if(this.chunkEnd<i&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=i+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:s}}=this.view,r=n.field(Br.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!ay?Math.max(25,e.timeRemaining()-5):1e9),a=r.context.treeLen<s&&n.doc.length>s+1e3,u=r.context.work(()=>ay&&ay()||Date.now()>o,s+(a?0:1e5));this.chunkBudget-=Date.now()-i,(u||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Br.setState.of(new yh(r.context))})),this.chunkBudget>0&&!(u&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(i=>So(this.view.state,i)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xh=Fe.define({combine(t){return t.length?t[0]:null},enables:t=>[Br.state,ZV,Ue.contentAttributes.compute([t],e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}})]});class Dle{constructor(e,i=[]){this.language=e,this.support=i,this.extension=[e,i]}}class MR{constructor(e,i,n,s,r,o=void 0){this.name=e,this.alias=i,this.extensions=n,this.filename=s,this.loadFunc=r,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:i,support:n}=e;if(!i){if(!n)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");i=()=>Promise.resolve(n)}return new MR(e.name,(e.alias||[]).concat(e.name).map(s=>s.toLowerCase()),e.extensions||[],e.filename,i,n)}static matchFilename(e,i){for(let s of e)if(s.filename&&s.filename.test(i))return s;let n=/\.([^.]+)$/.exec(i);if(n){for(let s of e)if(s.extensions.indexOf(n[1])>-1)return s}return null}static matchLanguageName(e,i,n=!0){i=i.toLowerCase();for(let s of e)if(s.alias.some(r=>r==i))return s;if(n)for(let s of e)for(let r of s.alias){let o=i.indexOf(r);if(o>-1&&(r.length>2||!/\w/.test(i[o-1])&&!/\w/.test(i[o+r.length])))return s}return null}}const JV=Fe.define(),lv=Fe.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(i=>i!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(lv);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Bf(t,e){let i="",n=t.tabSize,s=t.facet(lv)[0];if(s==" "){for(;e>=n;)i+=" ",e-=n;s=" "}for(let r=0;r<e;r++)i+=s;return i}function MS(t,e){t instanceof It&&(t=new av(t));for(let n of t.state.facet(JV)){let s=n(t,e);if(s!==void 0)return s}let i=No(t.state);return i.length>=e?eK(t,i,e):null}class av{constructor(e,i={}){this.state=e,this.options=i,this.unit=Ic(e)}lineAt(e,i=1){let n=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=n.from&&s<=n.to?r&&s==e?{text:"",from:e}:(i<0?s<e:s<=e)?{text:n.text.slice(s-n.from),from:s}:{text:n.text.slice(0,s-n.from),from:n.from}:n}textAfterPos(e,i=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:s}=this.lineAt(e,i);return n.slice(e-s,Math.min(n.length,e+100-s))}column(e,i=1){let{text:n,from:s}=this.lineAt(e,i),r=this.countColumn(n,e-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(r+=o-this.countColumn(n,n.search(/\S|$/))),r}countColumn(e,i=e.length){return Ah(e,this.state.tabSize,i)}lineIndent(e,i=1){let{text:n,from:s}=this.lineAt(e,i),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const AR=new bt;function eK(t,e,i){let n=e.resolveStack(i),s=e.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(s!=n.node){let r=[];for(let o=s;o&&!(o.from<n.node.from||o.to>n.node.to||o.from==n.node.from&&o.type==n.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)n={node:r[o],next:n}}return LR(n,t,i)}function LR(t,e,i){for(let n=t;n;n=n.next){let s=iK(n.node);if(s)return s(AS.create(e,i,n))}return 0}function tK(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function iK(t){let e=t.type.prop(AR);if(e)return e;let i=t.firstChild,n;if(i&&(n=i.type.prop(bt.closedBy))){let s=t.lastChild,r=s&&n.indexOf(s.name)>-1;return o=>TR(o,!0,1,void 0,r&&!tK(o)?s.from:void 0)}return t.parent==null?nK:null}function nK(){return 0}class AS extends av{constructor(e,i,n){super(e.state,e.options),this.base=e,this.pos=i,this.context=n}get node(){return this.context.node}static create(e,i,n){return new AS(e,i,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let i=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(i.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(sK(n,e))break;i=this.state.doc.lineAt(n.from)}return this.lineIndent(i.from)}continue(){return LR(this.context.next,this.base,this.pos)}}function sK(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function rK(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;let s=t.options.simulateBreak,r=t.state.doc.lineAt(i.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let a=i.to;;){let u=e.childAfter(a);if(!u||u==n)return null;if(!u.type.isSkipped){if(u.from>=o)return null;let h=/^ */.exec(r.text.slice(i.to-r.from))[0].length;return{from:i.from,to:i.to+h}}a=u.to}}function Ble({closing:t,align:e=!0,units:i=1}){return n=>TR(n,e,i,t)}function TR(t,e,i,n,s){let r=t.textAfter,o=r.match(/^\s*/)[0].length,a=n&&r.slice(o,o+n.length)==n||s==t.pos+o,u=e?rK(t):null;return u?a?t.column(u.from):t.column(u.to):t.baseIndent+(a?0:t.unit*i)}const Ole=t=>t.baseIndent;function Ile({except:t,units:e=1}={}){return i=>{let n=t&&t.test(i.textAfter);return i.baseIndent+(n?0:e*i.unit)}}const oK=200;function lK(){return It.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let i=t.newDoc,{head:n}=t.newSelection.main,s=i.lineAt(n);if(n>s.from+oK)return t;let r=i.sliceString(s.from,n);if(!e.some(h=>h.test(r)))return t;let{state:o}=t,a=-1,u=[];for(let{head:h}of o.selection.ranges){let p=o.doc.lineAt(h);if(p.from==a)continue;a=p.from;let m=MS(o,p.from);if(m==null)continue;let v=/^\s*/.exec(p.text)[0],_=Bf(o,m);v!=_&&u.push({from:p.from,to:p.from+v.length,insert:_})}return u.length?[t,{changes:u,sequential:!0}]:t})}const Ple=Fe.define(),zle=new bt;function $le(t){let e=t.firstChild,i=t.lastChild;return e&&e.to<i.from?{from:e.to,to:i.type.isError?t.to:i.from}:null}class cv{constructor(e,i){this.specs=e;let n;function s(a){let u=La.newName();return(n||(n=Object.create(null)))["."+u]=a,u}const r=typeof i.all=="string"?i.all:i.all?s(i.all):void 0,o=i.scope;this.scope=o instanceof Br?a=>a.prop(_c)==o.data:o?a=>a==o:void 0,this.style=kR(e.map(a=>({tag:a.tag,class:a.class||s(Object.assign({},a,{tag:null}))})),{all:r}).style,this.module=n?new La(n):null,this.themeType=i.themeType}static define(e,i){return new cv(e,i||{})}}const ab=Fe.define(),aK=Fe.define({combine(t){return t.length?[t[0]]:null}});function cy(t){let e=t.facet(ab);return e.length?e:t.facet(aK)}function cK(t,e){let i=[hK],n;return t instanceof cv&&(t.module&&i.push(Ue.styleModule.of(t.module)),n=t.themeType),n?i.push(ab.computeN([Ue.darkTheme],s=>s.facet(Ue.darkTheme)==(n=="dark")?[t]:[])):i.push(ab.of(t)),i}class uK{constructor(e){this.markCache=Object.create(null),this.tree=No(e.state),this.decorations=this.buildDeco(e,cy(e.state)),this.decoratedTo=e.viewport.to}update(e){let i=No(e.state),n=cy(e.state),s=n!=cy(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);i.length<r.to&&!s&&i.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(i!=this.tree||e.viewportChanged||s)&&(this.tree=i,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=r.to)}buildDeco(e,i){if(!i||!this.tree.length)return _t.none;let n=new Rc;for(let{from:s,to:r}of e.visibleRanges)KV(this.tree,i,(o,a,u)=>{n.add(o,a,this.markCache[u]||(this.markCache[u]=_t.mark({class:u})))},s,r);return n.finish()}}const hK=Qf.high(ds.fromClass(uK,{decorations:t=>t.decorations})),dK=Ue.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),NR=1e4,jR="()[]{}",RR=Fe.define({combine(t){return Fc(t,{afterCursor:!0,brackets:jR,maxScanDistance:NR,renderMatch:mK})}}),fK=_t.mark({class:"cm-matchingBracket"}),pK=_t.mark({class:"cm-nonmatchingBracket"});function mK(t){let e=[],i=t.matched?fK:pK;return e.push(i.range(t.start.from,t.start.to)),t.end&&e.push(i.range(t.end.from,t.end.to)),e}function KM(t){let e=[],i=t.facet(RR);for(let n of t.selection.ranges){if(!n.empty)continue;let s=Co(t,n.head,-1,i)||n.head>0&&Co(t,n.head-1,1,i)||i.afterCursor&&(Co(t,n.head,1,i)||n.head<t.doc.length&&Co(t,n.head+1,-1,i));s&&(e=e.concat(i.renderMatch(s,t)))}return _t.set(e,!0)}const gK=ds.fromClass(class{constructor(t){this.paused=!1,this.decorations=KM(t.state)}update(t){(t.docChanged||t.selectionSet||this.paused)&&(t.view.composing?(this.decorations=this.decorations.map(t.changes),this.paused=!0):(this.decorations=KM(t.state),this.paused=!1))}},{decorations:t=>t.decorations}),vK=[gK,dK];function _K(t={}){return[RR.of(t),vK]}const yK=new bt;function cb(t,e,i){let n=t.prop(e<0?bt.openedBy:bt.closedBy);if(n)return n;if(t.name.length==1){let s=i.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[i[s+e]]}return null}function ub(t){let e=t.type.prop(yK);return e?e(t.node):t}function Co(t,e,i,n={}){let s=n.maxScanDistance||NR,r=n.brackets||jR,o=No(t),a=o.resolveInner(e,i);for(let u=a;u;u=u.parent){let h=cb(u.type,i,r);if(h&&u.from<u.to){let p=ub(u);if(p&&(i>0?e>=p.from&&e<p.to:e>p.from&&e<=p.to))return xK(t,e,i,u,p,h,r)}}return bK(t,e,i,o,a.type,s,r)}function xK(t,e,i,n,s,r,o){let a=n.parent,u={from:s.from,to:s.to},h=0,p=a?.cursor();if(p&&(i<0?p.childBefore(n.from):p.childAfter(n.to)))do if(i<0?p.to<=n.from:p.from>=n.to){if(h==0&&r.indexOf(p.type.name)>-1&&p.from<p.to){let m=ub(p);return{start:u,end:m?{from:m.from,to:m.to}:void 0,matched:!0}}else if(cb(p.type,i,o))h++;else if(cb(p.type,-i,o)){if(h==0){let m=ub(p);return{start:u,end:m&&m.from<m.to?{from:m.from,to:m.to}:void 0,matched:!1}}h--}}while(i<0?p.prevSibling():p.nextSibling());return{start:u,matched:!1}}function bK(t,e,i,n,s,r,o){if(i<0?!e:e==t.doc.length)return null;let a=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),u=o.indexOf(a);if(u<0||u%2==0!=i>0)return null;let h={from:i<0?e-1:e,to:i>0?e+1:e},p=t.doc.iterRange(e,i>0?t.doc.length:0),m=0;for(let v=0;!p.next().done&&v<=r;){let _=p.value;i<0&&(v+=_.length);let x=e+v*i;for(let S=i>0?0:_.length-1,C=i>0?_.length:-1;S!=C;S+=i){let k=o.indexOf(_[S]);if(!(k<0||n.resolveInner(x+S,1).type!=s))if(k%2==0==i>0)m++;else{if(m==1)return{start:h,end:{from:x+S,to:x+S+1},matched:k>>1==u>>1};m--}}i>0&&(v+=_.length)}return p.done?{start:h,matched:!1}:null}function YM(t,e,i,n=0,s=0){e==null&&(e=t.search(/[^\s\u00a0]/),e==-1&&(e=t.length));let r=s;for(let o=n;o<e;o++)t.charCodeAt(o)==9?r+=i-r%i:r++;return r}class DR{constructor(e,i,n,s){this.string=e,this.tabSize=i,this.indentUnit=n,this.overrideIndent=s,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let i=this.string.charAt(this.pos),n;if(typeof e=="string"?n=i==e:n=i&&(e instanceof RegExp?e.test(i):e(i)),n)return++this.pos,i}eatWhile(e){let i=this.pos;for(;this.eat(e););return this.pos>i}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let i=this.string.indexOf(e,this.pos);if(i>-1)return this.pos=i,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=YM(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:YM(this.string,null,this.tabSize)}match(e,i,n){if(typeof e=="string"){let s=o=>n?o.toLowerCase():o,r=this.string.substr(this.pos,e.length);return s(r)==s(e)?(i!==!1&&(this.pos+=e.length),!0):null}else{let s=this.string.slice(this.pos).match(e);return s&&s.index>0?null:(s&&i!==!1&&(this.pos+=s[0].length),s)}}current(){return this.string.slice(this.start,this.pos)}}function wK(t){return{name:t.name||"",token:t.token,blankLine:t.blankLine||(()=>{}),startState:t.startState||(()=>!0),copyState:t.copyState||SK,indent:t.indent||(()=>null),languageData:t.languageData||{},tokenTable:t.tokenTable||NS,mergeTokens:t.mergeTokens!==!1}}function SK(t){if(typeof t!="object")return t;let e={};for(let i in t){let n=t[i];e[i]=n instanceof Array?n.slice():n}return e}const GM=new WeakMap;class LS extends Br{constructor(e){let i=CR(e.languageData),n=wK(e),s,r=new class extends wR{createParse(o,a,u){return new CK(s,o,a,u)}};super(i,r,[],e.name),this.topNode=AK(i,this),s=this,this.streamParser=n,this.stateAfter=new bt({perNode:!0}),this.tokenTable=e.tokenTable?new PR(n.tokenTable):MK}static define(e){return new LS(e)}getIndent(e){let i,{overrideIndentation:n}=e.options;n&&(i=GM.get(e.state),i!=null&&i<e.pos-1e4&&(i=void 0));let s=TS(this,e.node.tree,e.node.from,e.node.from,i??e.pos),r,o;if(s?(o=s.state,r=s.pos+1):(o=this.streamParser.startState(e.unit),r=e.node.from),e.pos-r>1e4)return null;for(;r<e.pos;){let u=e.state.doc.lineAt(r),h=Math.min(e.pos,u.to);if(u.length){let p=n?n(u.from):-1,m=new DR(u.text,e.state.tabSize,e.unit,p<0?void 0:p);for(;m.pos<h-u.from;)OR(this.streamParser.token,m,o)}else this.streamParser.blankLine(o,e.unit);if(h==e.pos)break;r=u.to+1}let a=e.lineAt(e.pos);return n&&i==null&&GM.set(e.state,a.from),this.streamParser.indent(o,/^\s*(.*)/.exec(a.text)[1],e)}get allowsNesting(){return!1}}function TS(t,e,i,n,s){let r=i>=n&&i+e.length<=s&&e.prop(t.stateAfter);if(r)return{state:t.streamParser.copyState(r),pos:i+e.length};for(let o=e.children.length-1;o>=0;o--){let a=e.children[o],u=i+e.positions[o],h=a instanceof ui&&u<s&&TS(t,a,u,n,s);if(h)return h}return null}function BR(t,e,i,n,s){if(s&&i<=0&&n>=e.length)return e;!s&&i==0&&e.type==t.topNode&&(s=!0);for(let r=e.children.length-1;r>=0;r--){let o=e.positions[r],a=e.children[r],u;if(o<n&&a instanceof ui){if(!(u=BR(t,a,i-o,n-o,s)))break;return s?new ui(e.type,e.children.slice(0,r).concat(u),e.positions.slice(0,r+1),o+u.length):u}}return null}function kK(t,e,i,n,s){for(let r of e){let o=r.from+(r.openStart?25:0),a=r.to-(r.openEnd?25:0),u=o<=i&&a>i&&TS(t,r.tree,0-r.offset,i,a),h;if(u&&u.pos<=n&&(h=BR(t,r.tree,i+r.offset,u.pos+r.offset,!1)))return{state:u.state,tree:h}}return{state:t.streamParser.startState(s?Ic(s):4),tree:ui.empty}}class CK{constructor(e,i,n,s){this.lang=e,this.input=i,this.fragments=n,this.ranges=s,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=s[s.length-1].to;let r=_h.get(),o=s[0].from,{state:a,tree:u}=kK(e,n,o,this.to,r?.state);this.state=a,this.parsedPos=this.chunkStart=o+u.length;for(let h=0;h<u.children.length;h++)this.chunks.push(u.children[h]),this.chunkPos.push(u.positions[h]);r&&this.parsedPos<r.viewport.from-1e5&&s.some(h=>h.from<=r.viewport.from&&h.to>=r.viewport.from)&&(this.state=this.lang.streamParser.startState(Ic(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let e=_h.get(),i=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(i,this.chunkStart+512);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=i?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,i),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let i=this.input.chunk(e);if(this.input.lineChunks)i==`
|
|
59
|
+
`&&(i="");else{let n=i.indexOf(`
|
|
60
|
+
`);n>-1&&(i=i.slice(0,n))}return e+i.length<=this.to?i:i.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,i=this.lineAfter(e),n=e+i.length;for(let s=this.rangeIndex;;){let r=this.ranges[s].to;if(r>=n||(i=i.slice(0,r-(n-i.length)),s++,s==this.ranges.length))break;let o=this.ranges[s].from,a=this.lineAfter(o);i+=a,n=o+a.length}return{line:i,end:n}}skipGapsTo(e,i,n){for(;;){let s=this.ranges[this.rangeIndex].to,r=e+i;if(n>0?s>r:s>=r)break;let o=this.ranges[++this.rangeIndex].from;i+=o-s}return i}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,i,n,s){let r=4;if(this.ranges.length>1){s=this.skipGapsTo(i,s,1),i+=s;let a=this.chunk.length;s=this.skipGapsTo(n,s,-1),n+=s,r+=this.chunk.length-a}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&r==4&&o>=0&&this.chunk[o]==e&&this.chunk[o+2]==i?this.chunk[o+2]=n:this.chunk.push(e,i,n,r),s}parseLine(e){let{line:i,end:n}=this.nextLine(),s=0,{streamParser:r}=this.lang,o=new DR(i,e?e.state.tabSize:4,e?Ic(e.state):2);if(o.eol())r.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let a=OR(r.token,o,this.state);if(a&&(s=this.emitToken(this.lang.tokenTable.resolve(a),this.parsedPos+o.start,this.parsedPos+o.pos,s)),o.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=ui.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:EK,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new ui(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new ui(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function OR(t,e,i){e.start=e.pos;for(let n=0;n<10;n++){let s=t(e,i);if(e.pos>e.start)return s}throw new Error("Stream parser failed to advance stream.")}const NS=Object.create(null),Of=[ps.none],EK=new SS(Of),QM=[],XM=Object.create(null),IR=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])IR[t]=zR(NS,e);class PR{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),IR)}resolve(e){return e?this.table[e]||(this.table[e]=zR(this.extra,e)):0}}const MK=new PR(NS);function uy(t,e){QM.indexOf(t)>-1||(QM.push(t),console.warn(e))}function zR(t,e){let i=[];for(let a of e.split(" ")){let u=[];for(let h of a.split(".")){let p=t[h]||je[h];p?typeof p=="function"?u.length?u=u.map(p):uy(h,`Modifier ${h} used at start of tag`):u.length?uy(h,`Tag ${h} used as modifier`):u=Array.isArray(p)?p:[p]:uy(h,`Unknown highlighting tag ${h}`)}for(let h of u)i.push(h)}if(!i.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+i.map(a=>a.id),r=XM[s];if(r)return r.id;let o=XM[s]=ps.define({id:Of.length,name:n,props:[UV({[n]:i})]});return Of.push(o),o.id}function AK(t,e){let i=ps.define({id:Of.length,name:"Document",props:[_c.add(()=>t),AR.add(()=>n=>e.getIndent(n))],top:!0});return Of.push(i),i}Mi.RTL,Mi.LTR;const LK=t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),n=RS(t.state,i.from);return n.line?TK(t):n.block?jK(t):!1};function jS(t,e){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let s=t(e,i);return s?(n(i.update(s)),!0):!1}}const TK=jS(BK,0),NK=jS($R,0),jK=jS((t,e)=>$R(t,e,DK(e)),0);function RS(t,e){let i=t.languageDataAt("commentTokens",e,1);return i.length?i[0]:{}}const Hd=50;function RK(t,{open:e,close:i},n,s){let r=t.sliceDoc(n-Hd,n),o=t.sliceDoc(s,s+Hd),a=/\s*$/.exec(r)[0].length,u=/^\s*/.exec(o)[0].length,h=r.length-a;if(r.slice(h-e.length,h)==e&&o.slice(u,u+i.length)==i)return{open:{pos:n-a,margin:a&&1},close:{pos:s+u,margin:u&&1}};let p,m;s-n<=2*Hd?p=m=t.sliceDoc(n,s):(p=t.sliceDoc(n,n+Hd),m=t.sliceDoc(s-Hd,s));let v=/^\s*/.exec(p)[0].length,_=/\s*$/.exec(m)[0].length,x=m.length-_-i.length;return p.slice(v,v+e.length)==e&&m.slice(x,x+i.length)==i?{open:{pos:n+v+e.length,margin:/\s/.test(p.charAt(v+e.length))?1:0},close:{pos:s-_-i.length,margin:/\s/.test(m.charAt(x-1))?1:0}}:null}function DK(t){let e=[];for(let i of t.selection.ranges){let n=t.doc.lineAt(i.from),s=i.to<=n.to?n:t.doc.lineAt(i.to);s.from>n.from&&s.from==i.to&&(s=i.to==n.to+1?n:t.doc.lineAt(i.to-1));let r=e.length-1;r>=0&&e[r].to>n.from?e[r].to=s.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return e}function $R(t,e,i=e.selection.ranges){let n=i.map(r=>RS(e,r.from).block);if(!n.every(r=>r))return null;let s=i.map((r,o)=>RK(e,n[o],r.from,r.to));if(t!=2&&!s.every(r=>r))return{changes:e.changes(i.map((r,o)=>s[o]?[]:[{from:r.from,insert:n[o].open+" "},{from:r.to,insert:" "+n[o].close}]))};if(t!=1&&s.some(r=>r)){let r=[];for(let o=0,a;o<s.length;o++)if(a=s[o]){let u=n[o],{open:h,close:p}=a;r.push({from:h.pos-u.open.length,to:h.pos+h.margin},{from:p.pos-p.margin,to:p.pos+u.close.length})}return{changes:r}}return null}function BK(t,e,i=e.selection.ranges){let n=[],s=-1;e:for(let{from:r,to:o}of i){let a=n.length,u=1e9,h;for(let p=r;p<=o;){let m=e.doc.lineAt(p);if(h==null&&(h=RS(e,m.from).line,!h))continue e;if(m.from>s&&(r==o||o>m.from)){s=m.from;let v=/^\s*/.exec(m.text)[0].length,_=v==m.length,x=m.text.slice(v,v+h.length)==h?v:-1;v<m.text.length&&v<u&&(u=v),n.push({line:m,comment:x,token:h,indent:v,empty:_,single:!1})}p=m.to+1}if(u<1e9)for(let p=a;p<n.length;p++)n[p].indent<n[p].line.text.length&&(n[p].indent=u);n.length==a+1&&(n[a].single=!0)}if(t!=2&&n.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:a,token:u,indent:h,empty:p,single:m}of n)(m||!p)&&r.push({from:a.from+h,insert:u+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&n.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:a,token:u}of n)if(a>=0){let h=o.from+a,p=h+u.length;o.text[p-o.from]==" "&&p++,r.push({from:h,to:p})}return{changes:r}}return null}const hb=Ba.define(),OK=Ba.define(),IK=Fe.define(),FR=Fe.define({combine(t){return Fc(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,i)=>i},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,i)=>(n,s)=>e(n,s)||i(n,s)})}}),HR=Bo.define({create(){return Eo.empty},update(t,e){let i=e.state.facet(FR),n=e.annotation(hb);if(n){let u=js.fromTransaction(e,n.selection),h=n.side,p=h==0?t.undone:t.done;return u?p=C0(p,p.length,i.minDepth,u):p=UR(p,e.startState.selection),new Eo(h==0?n.rest:p,h==0?p:n.rest)}let s=e.annotation(OK);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(pn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let r=js.fromTransaction(e),o=e.annotation(pn.time),a=e.annotation(pn.userEvent);return r?t=t.addChanges(r,o,a,i,e):e.selection&&(t=t.addSelection(e.startState.selection,o,a,i.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Eo(t.done.map(js.fromJSON),t.undone.map(js.fromJSON))}});function PK(t={}){return[HR,FR.of(t),Ue.domEventHandlers({beforeinput(e,i){let n=e.inputType=="historyUndo"?WR:e.inputType=="historyRedo"?db:null;return n?(e.preventDefault(),n(i)):!1}})]}function uv(t,e){return function({state:i,dispatch:n}){if(!e&&i.readOnly)return!1;let s=i.field(HR,!1);if(!s)return!1;let r=s.pop(t,i,e);return r?(n(r),!0):!1}}const WR=uv(0,!1),db=uv(1,!1),zK=uv(0,!0),$K=uv(1,!0);class js{constructor(e,i,n,s,r){this.changes=e,this.effects=i,this.mapped=n,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new js(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,i,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(i=this.mapped)===null||i===void 0?void 0:i.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new js(e.changes&&fn.fromJSON(e.changes),[],e.mapped&&Ao.fromJSON(e.mapped),e.startSelection&&Se.fromJSON(e.startSelection),e.selectionsAfter.map(Se.fromJSON))}static fromTransaction(e,i){let n=Or;for(let s of e.startState.facet(IK)){let r=s(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new js(e.changes.invert(e.startState.doc),n,void 0,i||e.startState.selection,Or)}static selection(e){return new js(void 0,Or,void 0,void 0,e)}}function C0(t,e,i,n){let s=e+1>i+20?e-i-1:0,r=t.slice(s,e);return r.push(n),r}function FK(t,e){let i=[],n=!1;return t.iterChangedRanges((s,r)=>i.push(s,r)),e.iterChangedRanges((s,r,o,a)=>{for(let u=0;u<i.length;){let h=i[u++],p=i[u++];a>=h&&o<=p&&(n=!0)}}),n}function HK(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((i,n)=>i.empty!=e.ranges[n].empty).length===0}function qR(t,e){return t.length?e.length?t.concat(e):t:e}const Or=[],WK=200;function UR(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-WK));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),C0(t,t.length-1,1e9,i.setSelAfter(n)))}else return[js.selection([e])]}function qK(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function hy(t,e){if(!t.length)return t;let i=t.length,n=Or;for(;i;){let s=UK(t[i-1],e,n);if(s.changes&&!s.changes.empty||s.effects.length){let r=t.slice(0,i);return r[i-1]=s,r}else e=s.mapped,i--,n=s.selectionsAfter}return n.length?[js.selection(n)]:Or}function UK(t,e,i){let n=qR(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):Or,i);if(!t.changes)return js.selection(n);let s=t.changes.map(e),r=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(r):r;return new js(s,ci.mapEffects(t.effects,e),o,t.startSelection.map(r),n)}const VK=/^(input\.type|delete)($|\.)/;class Eo{constructor(e,i,n=0,s=void 0){this.done=e,this.undone=i,this.prevTime=n,this.prevUserEvent=s}isolate(){return this.prevTime?new Eo(this.done,this.undone):this}addChanges(e,i,n,s,r){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!n||VK.test(n))&&(!a.selectionsAfter.length&&i-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,FK(a.changes,e.changes))||n=="input.type.compose")?o=C0(o,o.length-1,s.minDepth,new js(e.changes.compose(a.changes),qR(ci.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,Or)):o=C0(o,o.length,s.minDepth,e),new Eo(o,Or,i,n)}addSelection(e,i,n,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:Or;return r.length>0&&i-this.prevTime<s&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&HK(r[r.length-1],e)?this:new Eo(UR(this.done,e),this.undone,i,n)}addMapping(e){return new Eo(hy(this.done,e),hy(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,i,n){let s=e==0?this.done:this.undone;if(s.length==0)return null;let r=s[s.length-1],o=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):i.selection);if(n&&r.selectionsAfter.length)return i.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:hb.of({side:e,rest:qK(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let a=s.length==1?Or:s.slice(0,s.length-1);return r.mapped&&(a=hy(a,r.mapped)),i.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:hb.of({side:e,rest:a,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}Eo.empty=new Eo(Or,Or);const KK=[{key:"Mod-z",run:WR,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:db,preventDefault:!0},{linux:"Ctrl-Shift-z",run:db,preventDefault:!0},{key:"Mod-u",run:zK,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:$K,preventDefault:!0}];function Th(t,e){return Se.create(t.ranges.map(e),t.mainIndex)}function Jr(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function eo({state:t,dispatch:e},i){let n=Th(t.selection,i);return n.eq(t.selection,!0)?!1:(e(Jr(t,n)),!0)}function hv(t,e){return Se.cursor(e?t.to:t.from)}function VR(t,e){return eo(t,i=>i.empty?t.moveByChar(i,e):hv(i,e))}function Jn(t){return t.textDirectionAt(t.state.selection.main.head)==Mi.LTR}const KR=t=>VR(t,!Jn(t)),YR=t=>VR(t,Jn(t));function GR(t,e){return eo(t,i=>i.empty?t.moveByGroup(i,e):hv(i,e))}const YK=t=>GR(t,!Jn(t)),GK=t=>GR(t,Jn(t));function QK(t,e,i){if(e.type.prop(i))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function dv(t,e,i){let n=No(t).resolveInner(e.head),s=i?bt.closedBy:bt.openedBy;for(let u=e.head;;){let h=i?n.childAfter(u):n.childBefore(u);if(!h)break;QK(t,h,s)?n=h:u=i?h.to:h.from}let r=n.type.prop(s),o,a;return r&&(o=i?Co(t,n.from,1):Co(t,n.to,-1))&&o.matched?a=i?o.end.to:o.end.from:a=i?n.to:n.from,Se.cursor(a,i?-1:1)}const XK=t=>eo(t,e=>dv(t.state,e,!Jn(t))),ZK=t=>eo(t,e=>dv(t.state,e,Jn(t)));function QR(t,e){return eo(t,i=>{if(!i.empty)return hv(i,e);let n=t.moveVertically(i,e);return n.head!=i.head?n:t.moveToLineBoundary(i,e)})}const XR=t=>QR(t,!1),ZR=t=>QR(t,!0);function JR(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,i=0,n=0,s;if(e){for(let r of t.state.facet(Ue.scrollMargins)){let o=r(t);o?.top&&(i=Math.max(o?.top,i)),o?.bottom&&(n=Math.max(o?.bottom,n))}s=t.scrollDOM.clientHeight-i-n}else s=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:i,marginBottom:n,selfScroll:e,height:Math.max(t.defaultLineHeight,s-5)}}function e4(t,e){let i=JR(t),{state:n}=t,s=Th(n.selection,o=>o.empty?t.moveVertically(o,e,i.height):hv(o,e));if(s.eq(n.selection))return!1;let r;if(i.selfScroll){let o=t.coordsAtPos(n.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),u=a.top+i.marginTop,h=a.bottom-i.marginBottom;o&&o.top>u&&o.bottom<h&&(r=Ue.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-u}))}return t.dispatch(Jr(n,s),{effects:r}),!0}const ZM=t=>e4(t,!1),fb=t=>e4(t,!0);function Oa(t,e,i){let n=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,i);if(s.head==e.head&&s.head!=(i?n.to:n.from)&&(s=t.moveToLineBoundary(e,i,!1)),!i&&s.head==n.from&&n.length){let r=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;r&&e.head!=n.from+r&&(s=Se.cursor(n.from+r))}return s}const JK=t=>eo(t,e=>Oa(t,e,!0)),eY=t=>eo(t,e=>Oa(t,e,!1)),tY=t=>eo(t,e=>Oa(t,e,!Jn(t))),iY=t=>eo(t,e=>Oa(t,e,Jn(t))),nY=t=>eo(t,e=>Se.cursor(t.lineBlockAt(e.head).from,1)),sY=t=>eo(t,e=>Se.cursor(t.lineBlockAt(e.head).to,-1));function rY(t,e,i){let n=!1,s=Th(t.selection,r=>{let o=Co(t,r.head,-1)||Co(t,r.head,1)||r.head>0&&Co(t,r.head-1,1)||r.head<t.doc.length&&Co(t,r.head+1,-1);if(!o||!o.end)return r;n=!0;let a=o.start.from==r.head?o.end.to:o.end.from;return Se.cursor(a)});return n?(e(Jr(t,s)),!0):!1}const oY=({state:t,dispatch:e})=>rY(t,e);function Pr(t,e,i){let n=Th(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=Se.range(s.head,s.anchor));let r=i(s);return Se.range(s.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return n.eq(t.state.selection)?!1:(t.dispatch(Jr(t.state,n)),!0)}function t4(t,e){return Pr(t,e,i=>t.moveByChar(i,e))}const i4=t=>t4(t,!Jn(t)),n4=t=>t4(t,Jn(t));function s4(t,e){return Pr(t,e,i=>t.moveByGroup(i,e))}const lY=t=>s4(t,!Jn(t)),aY=t=>s4(t,Jn(t)),cY=t=>{let e=!Jn(t);return Pr(t,e,i=>dv(t.state,i,e))},uY=t=>{let e=Jn(t);return Pr(t,e,i=>dv(t.state,i,e))};function r4(t,e){return Pr(t,e,i=>t.moveVertically(i,e))}const o4=t=>r4(t,!1),l4=t=>r4(t,!0);function a4(t,e){return Pr(t,e,i=>t.moveVertically(i,e,JR(t).height))}const JM=t=>a4(t,!1),eA=t=>a4(t,!0),hY=t=>Pr(t,!0,e=>Oa(t,e,!0)),dY=t=>Pr(t,!1,e=>Oa(t,e,!1)),fY=t=>{let e=!Jn(t);return Pr(t,e,i=>Oa(t,i,e))},pY=t=>{let e=Jn(t);return Pr(t,e,i=>Oa(t,i,e))},mY=t=>Pr(t,!1,e=>Se.cursor(t.lineBlockAt(e.head).from)),gY=t=>Pr(t,!0,e=>Se.cursor(t.lineBlockAt(e.head).to)),tA=({state:t,dispatch:e})=>(e(Jr(t,{anchor:0})),!0),iA=({state:t,dispatch:e})=>(e(Jr(t,{anchor:t.doc.length})),!0),nA=({state:t,dispatch:e})=>(e(Jr(t,{anchor:t.selection.main.anchor,head:0})),!0),sA=({state:t,dispatch:e})=>(e(Jr(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),vY=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),_Y=({state:t,dispatch:e})=>{let i=fv(t).map(({from:n,to:s})=>Se.undirectionalRange(n,Math.min(s+1,t.doc.length)));return e(t.update({selection:Se.create(i),userEvent:"select"})),!0},yY=({state:t,dispatch:e})=>{let i=Th(t.selection,n=>{let s=No(t),r=s.resolveStack(n.from,1);if(n.empty){let o=s.resolveStack(n.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:a}=o;if((a.from<n.from&&a.to>=n.to||a.to>n.to&&a.from<=n.from)&&o.next)return Se.undirectionalRange(a.from,a.to)}return n});return i.eq(t.selection)?!1:(e(Jr(t,i)),!0)};function c4(t,e){let{state:i}=t,n=i.selection,s=i.selection.ranges.slice();for(let r of i.selection.ranges){let o=i.doc.lineAt(r.head);if(e?o.to<t.state.doc.length:o.from>0)for(let a=r;;){let u=t.moveVertically(a,e);if(u.head<o.from||u.head>o.to){s.some(h=>h.head==u.head)||s.push(u);break}else{if(u.head==a.head)break;a=u}}}return s.length==n.ranges.length?!1:(t.dispatch(Jr(i,Se.create(s,s.length-1))),!0)}const xY=t=>c4(t,!1),bY=t=>c4(t,!0),wY=({state:t,dispatch:e})=>{let i=t.selection,n=null;return i.ranges.length>1?n=Se.create([i.main]):i.main.empty||(n=Se.create([Se.cursor(i.main.head)])),n?(e(Jr(t,n)),!0):!1};function tp(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:n}=t,s=n.changeByRange(r=>{let{from:o,to:a}=r;if(o==a){let u=e(r);u<o?(i="delete.backward",u=eg(t,u,!1)):u>o&&(i="delete.forward",u=eg(t,u,!0)),o=Math.min(o,u),a=Math.max(a,u)}else o=eg(t,o,!1),a=eg(t,a,!0);return o==a?{range:r}:{changes:{from:o,to:a},range:Se.cursor(o,o<r.head?-1:1)}});return s.changes.empty?!1:(t.dispatch(n.update(s,{scrollIntoView:!0,userEvent:i,effects:i=="delete.selection"?Ue.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function eg(t,e,i){if(t instanceof Ue)for(let n of t.state.facet(Ue.atomicRanges).map(s=>s(t)))n.between(e,e,(s,r)=>{s<e&&r>e&&(e=i?r:s)});return e}const u4=(t,e,i)=>tp(t,n=>{let s=n.from,{state:r}=t,o=r.doc.lineAt(s),a,u;if(i&&!e&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,s-o.from))){if(a[a.length-1]==" ")return s-1;let h=Ah(a,r.tabSize),p=h%Ic(r)||Ic(r);for(let m=0;m<p&&a[a.length-1-m]==" ";m++)s--;u=s}else u=An(o.text,s-o.from,e,e)+o.from,u==s&&o.number!=(e?r.doc.lines:1)?u+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(u-o.from,s-o.from))&&(u=An(o.text,u-o.from,!1,!1)+o.from);return u}),pb=t=>u4(t,!1,!0),h4=t=>u4(t,!0,!1),d4=(t,e)=>tp(t,i=>{let n=i.head,{state:s}=t,r=s.doc.lineAt(n),o=s.charCategorizer(n);for(let a=null;;){if(n==(e?r.to:r.from)){n==i.head&&r.number!=(e?s.doc.lines:1)&&(n+=e?1:-1);break}let u=An(r.text,n-r.from,e)+r.from,h=r.text.slice(Math.min(n,u)-r.from,Math.max(n,u)-r.from),p=o(h);if(a!=null&&p!=a)break;(h!=" "||n!=i.head)&&(a=p),n=u}return n}),f4=t=>d4(t,!1),SY=t=>d4(t,!0),kY=t=>tp(t,e=>{let i=t.lineBlockAt(e.head).to;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}),CY=t=>tp(t,e=>{let i=t.moveToLineBoundary(e,!1).head;return e.head>i?i:Math.max(0,e.head-1)}),EY=t=>tp(t,e=>{let i=t.moveToLineBoundary(e,!0).head;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}),MY=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:Vt.of(["",""])},range:Se.cursor(n.from)}));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0},AY=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(n=>{if(!n.empty||n.from==0||n.from==t.doc.length)return{range:n};let s=n.from,r=t.doc.lineAt(s),o=s==r.from?s-1:An(r.text,s-r.from,!1)+r.from,a=s==r.to?s+1:An(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:a,insert:t.doc.slice(s,a).append(t.doc.slice(o,s))},range:Se.cursor(a)}});return i.changes.empty?!1:(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function fv(t){let e=[],i=-1;for(let n of t.selection.ranges){let s=t.doc.lineAt(n.from),r=t.doc.lineAt(n.to);if(!n.empty&&n.to==r.from&&(r=t.doc.lineAt(n.to-1)),i>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(n)}else e.push({from:s.from,to:r.to,ranges:[n]});i=r.number+1}return e}function p4(t,e,i){if(t.readOnly)return!1;let n=[],s=[];for(let r of fv(t)){if(i?r.to==t.doc.length:r.from==0)continue;let o=t.doc.lineAt(i?r.to+1:r.from-1),a=o.length+1;if(i){n.push({from:r.to,to:o.to},{from:r.from,insert:o.text+t.lineBreak});for(let u of r.ranges)s.push(Se.range(Math.min(t.doc.length,u.anchor+a),Math.min(t.doc.length,u.head+a)))}else{n.push({from:o.from,to:r.from},{from:r.to,insert:t.lineBreak+o.text});for(let u of r.ranges)s.push(Se.range(u.anchor-a,u.head-a))}}return n.length?(e(t.update({changes:n,scrollIntoView:!0,selection:Se.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const LY=({state:t,dispatch:e})=>p4(t,e,!1),TY=({state:t,dispatch:e})=>p4(t,e,!0);function m4(t,e,i){if(t.readOnly)return!1;let n=[];for(let r of fv(t))i?n.push({from:r.from,insert:t.doc.slice(r.from,r.to)+t.lineBreak}):n.push({from:r.to,insert:t.lineBreak+t.doc.slice(r.from,r.to)});let s=t.changes(n);return e(t.update({changes:s,selection:t.selection.map(s,i?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const NY=({state:t,dispatch:e})=>m4(t,e,!1),jY=({state:t,dispatch:e})=>m4(t,e,!0),RY=t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(fv(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),n=Th(e.selection,s=>{let r;if(t.lineWrapping){let o=t.lineBlockAt(s.head),a=t.coordsAtPos(s.head,s.assoc||1);a&&(r=o.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,r)}).map(i);return t.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function DY(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i=No(t).resolveInner(e),n=i.childBefore(e),s=i.childAfter(e),r;return n&&s&&n.to<=e&&s.from>=e&&(r=n.type.prop(bt.closedBy))&&r.indexOf(s.name)>-1&&t.doc.lineAt(n.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(n.to,s.from))?{from:n.to,to:s.from}:null}const rA=g4(!1),BY=g4(!0);function g4(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let n=e.changeByRange(s=>{let{from:r,to:o}=s,a=e.doc.lineAt(r),u=!t&&r==o&&DY(e,r);t&&(r=o=(o<=a.to?a:e.doc.lineAt(o)).to);let h=new av(e,{simulateBreak:r,simulateDoubleBreak:!!u}),p=MS(h,r);for(p==null&&(p=Ah(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;u?{from:r,to:o}=u:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let m=["",Bf(e,p)];return u&&m.push(Bf(e,h.lineIndent(a.from,-1))),{changes:{from:r,to:o,insert:Vt.of(m)},range:Se.cursor(r+1+m[1].length)}});return i(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function DS(t,e){let i=-1;return t.changeByRange(n=>{let s=[];for(let o=n.from;o<=n.to;){let a=t.doc.lineAt(o);a.number>i&&(n.empty||n.to>a.from)&&(e(a,s,n),i=a.number),o=a.to+1}let r=t.changes(s);return{changes:s,range:Se.range(r.mapPos(n.anchor,1),r.mapPos(n.head,1))}})}const OY=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),n=new av(t,{overrideIndentation:r=>{let o=i[r];return o??-1}}),s=DS(t,(r,o,a)=>{let u=MS(n,r.from);if(u==null)return;/\S/.test(r.text)||(u=0);let h=/^\s*/.exec(r.text)[0],p=Bf(t,u);(h!=p||a.from<r.from+h.length)&&(i[r.from]=u,o.push({from:r.from,to:r.from+h.length,insert:p}))});return s.changes.empty||e(t.update(s,{userEvent:"indent"})),!0},v4=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(DS(t,(i,n)=>{n.push({from:i.from,insert:t.facet(lv)})}),{userEvent:"input.indent"})),!0),_4=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(DS(t,(i,n)=>{let s=/^\s*/.exec(i.text)[0];if(!s)return;let r=Ah(s,t.tabSize),o=0,a=Bf(t,Math.max(0,r-Ic(t)));for(;o<s.length&&o<a.length&&s.charCodeAt(o)==a.charCodeAt(o);)o++;n.push({from:i.from+o,to:i.from+s.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),IY=t=>(t.setTabFocusMode(),!0),PY=[{key:"Ctrl-b",run:KR,shift:i4,preventDefault:!0},{key:"Ctrl-f",run:YR,shift:n4},{key:"Ctrl-p",run:XR,shift:o4},{key:"Ctrl-n",run:ZR,shift:l4},{key:"Ctrl-a",run:nY,shift:mY},{key:"Ctrl-e",run:sY,shift:gY},{key:"Ctrl-d",run:h4},{key:"Ctrl-h",run:pb},{key:"Ctrl-k",run:kY},{key:"Ctrl-Alt-h",run:f4},{key:"Ctrl-o",run:MY},{key:"Ctrl-t",run:AY},{key:"Ctrl-v",run:fb}],zY=[{key:"ArrowLeft",run:KR,shift:i4,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:YK,shift:lY,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:tY,shift:fY,preventDefault:!0},{key:"ArrowRight",run:YR,shift:n4,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:GK,shift:aY,preventDefault:!0},{mac:"Cmd-ArrowRight",run:iY,shift:pY,preventDefault:!0},{key:"ArrowUp",run:XR,shift:o4,preventDefault:!0},{mac:"Cmd-ArrowUp",run:tA,shift:nA},{mac:"Ctrl-ArrowUp",run:ZM,shift:JM},{key:"ArrowDown",run:ZR,shift:l4,preventDefault:!0},{mac:"Cmd-ArrowDown",run:iA,shift:sA},{mac:"Ctrl-ArrowDown",run:fb,shift:eA},{key:"PageUp",run:ZM,shift:JM},{key:"PageDown",run:fb,shift:eA},{key:"Home",run:eY,shift:dY,preventDefault:!0},{key:"Mod-Home",run:tA,shift:nA},{key:"End",run:JK,shift:hY,preventDefault:!0},{key:"Mod-End",run:iA,shift:sA},{key:"Enter",run:rA,shift:rA},{key:"Mod-a",run:vY},{key:"Backspace",run:pb,shift:pb,preventDefault:!0},{key:"Delete",run:h4,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:f4,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:SY,preventDefault:!0},{mac:"Mod-Backspace",run:CY,preventDefault:!0},{mac:"Mod-Delete",run:EY,preventDefault:!0}].concat(PY.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),$Y=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:XK,shift:cY},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:ZK,shift:uY},{key:"Alt-ArrowUp",run:LY},{key:"Shift-Alt-ArrowUp",run:NY},{key:"Alt-ArrowDown",run:TY},{key:"Shift-Alt-ArrowDown",run:jY},{key:"Mod-Alt-ArrowUp",run:xY},{key:"Mod-Alt-ArrowDown",run:bY},{key:"Escape",run:wY},{key:"Mod-Enter",run:BY},{key:"Alt-l",mac:"Ctrl-l",run:_Y},{key:"Mod-i",run:yY,preventDefault:!0},{key:"Mod-[",run:_4},{key:"Mod-]",run:v4},{key:"Mod-Alt-\\",run:OY},{key:"Shift-Mod-k",run:RY},{key:"Shift-Mod-\\",run:oY},{key:"Mod-/",run:LK},{key:"Alt-A",mac:"Ctrl-A",run:NK},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IY}].concat(zY),FY={key:"Tab",run:v4,shift:_4},oA=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class bh{constructor(e,i,n=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,s),this.bufferStart=n,this.normalize=r?a=>r(oA(a)):oA,this.query=this.normalize(i)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return aS(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let i=PW(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Jj(e);let s=this.normalize(i);if(s.length)for(let r=0,o=n,a=!0;;r++){let u=s.charCodeAt(r),h=this.match(u,o,a,this.bufferPos+this.bufferStart,r==s.length-1);if(h)return this.value=h,this;if(r==s.length-1)break;a&&r<i.length&&i.charCodeAt(r)==u?o++:a=!1}}}match(e,i,n,s,r){let o=null;for(let a=0;a<this.matches.length;){let u=this.matches[a],h=!1;this.query.charCodeAt(u.index)==e&&(u.index==this.query.length-1?o={from:u.from,to:s,precise:r&&u.precise}:(u.index++,h=!0)),h?a++:this.matches.splice(a,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?o={from:i,to:s,precise:n&&r}:this.matches.push({from:i,index:1,precise:n})),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}}typeof Symbol<"u"&&(bh.prototype[Symbol.iterator]=function(){return this});const y4={from:-1,to:-1,match:/.*/.exec(""),precise:!0},BS="gm"+(/x/.unicode==null?"":"u");class x4{constructor(e,i,n,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=y4,/\\[sWDnr]|\n|\r|\[\^/.test(i))return new b4(e,i,n,s,r);this.re=new RegExp(i,BS+(n?.ignoreCase?"i":"")),this.test=n?.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=E0(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let i=this.matchPos<=this.to&&this.re.exec(this.curLine);if(i){let n=this.curLineStart+i.index,s=n+i[0].length;if(this.matchPos=E0(this.text,s+(n==s?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<s||n>this.value.to)&&(!this.test||this.test(n,s,i)))return this.value={from:n,to:s,precise:!0,match:i},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const dy=new WeakMap;class lh{constructor(e,i){this.from=e,this.text=i}get to(){return this.from+this.text.length}static get(e,i,n){let s=dy.get(e);if(!s||s.from>=n||s.to<=i){let a=new lh(i,e.sliceString(i,n));return dy.set(e,a),a}if(s.from==i&&s.to==n)return s;let{text:r,from:o}=s;return o>i&&(r=e.sliceString(i,o)+r,o=i),s.to<n&&(r+=e.sliceString(s.to,n)),dy.set(e,new lh(o,r)),new lh(i,r.slice(i-o,n-o))}}class b4{constructor(e,i,n,s,r){this.text=e,this.to=r,this.done=!1,this.value=y4,this.matchPos=E0(e,s),this.re=new RegExp(i,BS+(n?.ignoreCase?"i":"")),this.test=n?.test,this.flat=lh.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,i=this.re.exec(this.flat.text);if(i&&!i[0]&&i.index==e&&(this.re.lastIndex=e+1,i=this.re.exec(this.flat.text)),i){let n=this.flat.from+i.index,s=n+i[0].length;if((this.flat.to>=this.to||i.index+i[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,s,i)))return this.value={from:n,to:s,precise:!0,match:i},this.matchPos=E0(this.text,s+(n==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=lh.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(x4.prototype[Symbol.iterator]=b4.prototype[Symbol.iterator]=function(){return this});function HY(t){try{return new RegExp(t,BS),!0}catch{return!1}}function E0(t,e){if(e>=t.length)return e;let i=t.lineAt(e),n;for(;e<i.to&&(n=i.text.charCodeAt(e-i.from))>=56320&&n<57344;)e++;return e}const WY=t=>{let{state:e}=t,i=String(e.doc.lineAt(t.state.selection.main.head).number),{close:n,result:s}=fV(t,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:i},focus:!0,submitLabel:e.phrase("go")});return s.then(r=>{let o=r&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(r.elements.line.value);if(!o){t.dispatch({effects:n});return}let a=e.doc.lineAt(e.selection.main.head),[,u,h,p,m]=o,v=p?+p.slice(1):0,_=h?+h:a.number;if(h&&m){let C=_/100;u&&(C=C*(u=="-"?-1:1)+a.number/e.doc.lines),_=Math.round(e.doc.lines*C)}else h&&u&&(_=_*(u=="-"?-1:1)+a.number);let x=e.doc.line(Math.max(1,Math.min(e.doc.lines,_))),S=Se.cursor(x.from+Math.max(0,Math.min(v,x.length)));t.dispatch({effects:[n,Ue.scrollIntoView(S.from,{y:"center"})],selection:S})}),!0},qY={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},UY=Fe.define({combine(t){return Fc(t,qY,{highlightWordAroundCursor:(e,i)=>e||i,minSelectionLength:Math.min,maxMatches:Math.min})}});function VY(t){return[XY,QY]}const KY=_t.mark({class:"cm-selectionMatch"}),YY=_t.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function lA(t,e,i,n){return(i==0||t(e.sliceDoc(i-1,i))!=Ki.Word)&&(n==e.doc.length||t(e.sliceDoc(n,n+1))!=Ki.Word)}function GY(t,e,i,n){return t(e.sliceDoc(i,i+1))==Ki.Word&&t(e.sliceDoc(n-1,n))==Ki.Word}const QY=ds.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(UY),{state:i}=t,n=i.selection;if(n.ranges.length>1)return _t.none;let s=n.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return _t.none;let u=i.wordAt(s.head);if(!u)return _t.none;o=i.charCategorizer(s.head),r=i.sliceDoc(u.from,u.to)}else{let u=s.to-s.from;if(u<e.minSelectionLength||u>200)return _t.none;if(e.wholeWords){if(r=i.sliceDoc(s.from,s.to),o=i.charCategorizer(s.head),!(lA(o,i,s.from,s.to)&&GY(o,i,s.from,s.to)))return _t.none}else if(r=i.sliceDoc(s.from,s.to),!r)return _t.none}let a=[];for(let u of t.visibleRanges){let h=new bh(i.doc,r,u.from,u.to);for(;!h.next().done;){let{from:p,to:m}=h.value;if((!o||lA(o,i,p,m))&&(s.empty&&p<=s.from&&m>=s.to?a.push(YY.range(p,m)):(p>=s.to||m<=s.from)&&a.push(KY.range(p,m)),a.length>e.maxMatches))return _t.none}}return _t.set(a)}},{decorations:t=>t.decorations}),XY=Ue.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),ZY=({state:t,dispatch:e})=>{let{selection:i}=t,n=Se.create(i.ranges.map(s=>t.wordAt(s.head)||Se.cursor(s.head)),i.mainIndex);return n.eq(i)?!1:(e(t.update({selection:n})),!0)};function JY(t,e){let{main:i,ranges:n}=t.selection,s=t.wordAt(i.head),r=s&&s.from==i.from&&s.to==i.to;for(let o=!1,a=new bh(t.doc,e,n[n.length-1].to);;)if(a.next(),a.done){if(o)return null;a=new bh(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),o=!0}else{if(o&&n.some(u=>u.from==a.value.from))continue;if(r){let u=t.wordAt(a.value.from);if(!u||u.from!=a.value.from||u.to!=a.value.to)continue}return a.value}}const eG=({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some(r=>r.from===r.to))return ZY({state:t,dispatch:e});let n=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some(r=>t.sliceDoc(r.from,r.to)!=n))return!1;let s=JY(t,n);return s?(e(t.update({selection:t.selection.addRange(Se.range(s.from,s.to),!1),effects:Ue.scrollIntoView(s.to)})),!0):!1},Hc=Fe.define({combine(t){return Fc(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new mG(e),scrollToMatch:e=>Ue.scrollIntoView(e)})}});function tG(t){return t?[Hc.of(t),gb]:gb}class w4{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||HY(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(i,n)=>n=="n"?`
|
|
61
|
+
`:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new lG(this):new sG(this)}getCursor(e,i=0,n){let s=e.doc?e:It.create({doc:e});return n==null&&(n=s.doc.length),this.regexp?Hu(this,s,i,n):Fu(this,s,i,n)}}class S4{constructor(e){this.spec=e}}function iG(t,e,i){return(n,s,r,o)=>{if(i&&!i(n,s,r,o))return!1;let a=n>=o&&s<=o+r.length?r.slice(n-o,s-o):e.doc.sliceString(n,s);return t(a,e,n,s)}}function Fu(t,e,i,n){let s;return t.wholeWord&&(s=nG(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(s=iG(t.test,e,s)),new bh(e.doc,t.unquoted,i,n,t.caseSensitive?void 0:r=>r.toLowerCase(),s)}function nG(t,e){return(i,n,s,r)=>((r>i||r+s.length<n)&&(r=Math.max(0,i-2),s=t.sliceString(r,Math.min(t.length,n+2))),(e(M0(s,i-r))!=Ki.Word||e(A0(s,i-r))!=Ki.Word)&&(e(A0(s,n-r))!=Ki.Word||e(M0(s,n-r))!=Ki.Word))}class sG extends S4{constructor(e){super(e)}nextMatch(e,i,n){let s=Fu(this.spec,e,n,e.doc.length).nextOverlapping();if(s.done){let r=Math.min(e.doc.length,i+this.spec.unquoted.length);s=Fu(this.spec,e,0,r).nextOverlapping()}return s.done||s.value.from==i&&s.value.to==n?null:s.value}prevMatchInRange(e,i,n){for(let s=n;;){let r=Math.max(i,s-1e4-this.spec.unquoted.length),o=Fu(this.spec,e,r,s),a=null;for(;!o.nextOverlapping().done;)a=o.value;if(a)return a;if(r==i)return null;s-=1e4}}prevMatch(e,i,n){let s=this.prevMatchInRange(e,0,i);return s||(s=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=i||s.to!=n)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,i){let n=Fu(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=i)return null;s.push(n.value)}return s}highlight(e,i,n,s){let r=Fu(this.spec,e,Math.max(0,i-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function rG(t,e,i){return(n,s,r)=>(!i||i(n,s,r))&&t(r[0],e,n,s)}function Hu(t,e,i,n){let s;return t.wholeWord&&(s=oG(e.charCategorizer(e.selection.main.head))),t.test&&(s=rG(t.test,e,s)),new x4(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:s},i,n)}function M0(t,e){return t.slice(An(t,e,!1),e)}function A0(t,e){return t.slice(e,An(t,e))}function oG(t){return(e,i,n)=>!n[0].length||(t(M0(n.input,n.index))!=Ki.Word||t(A0(n.input,n.index))!=Ki.Word)&&(t(A0(n.input,n.index+n[0].length))!=Ki.Word||t(M0(n.input,n.index+n[0].length))!=Ki.Word)}class lG extends S4{nextMatch(e,i,n){let s=Hu(this.spec,e,n,e.doc.length).next();return s.done&&(s=Hu(this.spec,e,0,i).next()),s.done?null:s.value}prevMatchInRange(e,i,n){for(let s=1;;s++){let r=Math.max(i,n-s*1e4),o=Hu(this.spec,e,r,n),a=null;for(;!o.next().done;)a=o.value;if(a&&(r==i||a.from>r+10))return a;if(r==i)return null}}prevMatch(e,i,n){return this.prevMatchInRange(e,0,i)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(i,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let s=n.length;s>0;s--){let r=+n.slice(0,s);if(r>0&&r<e.match.length)return e.match[r]+n.slice(s)}return i})}matchAll(e,i){let n=Hu(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=i)return null;s.push(n.value)}return s}highlight(e,i,n,s){let r=Hu(this.spec,e,Math.max(0,i-250),Math.min(n+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const If=ci.define(),OS=ci.define(),Ma=Bo.define({create(t){return new fy(mb(t).create(),null)},update(t,e){for(let i of e.effects)i.is(If)?t=new fy(i.value.create(),t.panel):i.is(OS)&&(t=new fy(t.query,i.value?IS:null));return t},provide:t=>w0.from(t,e=>e.panel)});class fy{constructor(e,i){this.query=e,this.panel=i}}const aG=_t.mark({class:"cm-searchMatch"}),cG=_t.mark({class:"cm-searchMatch cm-searchMatch-selected"}),uG=ds.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Ma))}update(t){let e=t.state.field(Ma);(e!=t.startState.field(Ma)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return _t.none;let{view:i}=this,n=new Rc;for(let s=0,r=i.visibleRanges,o=r.length;s<o;s++){let{from:a,to:u}=r[s];for(;s<o-1&&u>r[s+1].from-500;)u=r[++s].to;t.highlight(i.state,a,u,(h,p)=>{let m=i.state.selection.ranges.some(v=>v.from==h&&v.to==p);n.add(h,p,m?cG:aG)})}return n.finish()}},{decorations:t=>t.decorations});function ip(t){return e=>{let i=e.state.field(Ma,!1);return i&&i.query.spec.valid?t(e,i):E4(e)}}const L0=ip((t,{query:e})=>{let{to:i}=t.state.selection.main,n=e.nextMatch(t.state,i,i);if(!n)return!1;let s=Se.single(n.from,n.to),r=t.state.facet(Hc);return t.dispatch({selection:s,effects:[PS(t,n),r.scrollToMatch(s.main,t)],userEvent:"select.search"}),C4(t),!0}),T0=ip((t,{query:e})=>{let{state:i}=t,{from:n}=i.selection.main,s=e.prevMatch(i,n,n);if(!s)return!1;let r=Se.single(s.from,s.to),o=t.state.facet(Hc);return t.dispatch({selection:r,effects:[PS(t,s),o.scrollToMatch(r.main,t)],userEvent:"select.search"}),C4(t),!0}),hG=ip((t,{query:e})=>{let i=e.matchAll(t.state,1e3);return!i||!i.length?!1:(t.dispatch({selection:Se.create(i.map(n=>Se.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),dG=({state:t,dispatch:e})=>{let i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:s}=i.main,r=[],o=0;for(let a=new bh(t.doc,t.sliceDoc(n,s));!a.next().done;){if(r.length>1e3)return!1;a.value.from==n&&(o=r.length),r.push(Se.range(a.value.from,a.value.to))}return e(t.update({selection:Se.create(r,o),userEvent:"select.search.matches"})),!0},aA=ip((t,{query:e})=>{let{state:i}=t,{from:n,to:s}=i.selection.main;if(i.readOnly)return!1;let r=e.nextMatch(i,n,n);if(!r)return!1;let o=r,a=[],u,h,p=[];o.precise?o.from==n&&o.to==s&&(h=i.toText(e.getReplacement(o)),a.push({from:o.from,to:o.to,insert:h}),o=e.nextMatch(i,o.from,o.to),p.push(Ue.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+"."))):o=e.nextMatch(i,o.from,o.to);let m=t.state.changes(a);return o&&(u=Se.single(o.from,o.to).map(m),p.push(PS(t,o)),p.push(i.facet(Hc).scrollToMatch(u.main,t))),t.dispatch({changes:m,selection:u,effects:p,userEvent:"input.replace"}),!0}),fG=ip((t,{query:e})=>{if(t.state.readOnly)return!1;let i=[];for(let s of e.matchAll(t.state,1e9)){let{from:r,to:o,precise:a}=s;a&&i.push({from:r,to:o,insert:e.getReplacement(s)})}if(!i.length)return!1;let n=t.state.phrase("replaced $ matches",i.length)+".";return t.dispatch({changes:i,effects:Ue.announce.of(n),userEvent:"input.replace.all"}),!0});function IS(t){return t.state.facet(Hc).createPanel(t)}function mb(t,e){var i,n,s,r,o;let a=t.selection.main,u=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!u)return e;let h=t.facet(Hc);return new w4({search:((i=e?.literal)!==null&&i!==void 0?i:h.literal)?u:u.replace(/\n/g,"\\n"),caseSensitive:(n=e?.caseSensitive)!==null&&n!==void 0?n:h.caseSensitive,literal:(s=e?.literal)!==null&&s!==void 0?s:h.literal,regexp:(r=e?.regexp)!==null&&r!==void 0?r:h.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function k4(t){let e=pR(t,IS);return e&&e.dom.querySelector("[main-field]")}function C4(t){let e=k4(t);e&&e==t.root.activeElement&&e.select()}const E4=t=>{let e=t.state.field(Ma,!1);if(e&&e.panel){let i=k4(t);if(i&&i!=t.root.activeElement){let n=mb(t.state,e.query.spec);n.valid&&t.dispatch({effects:If.of(n)}),i.focus(),i.select()}}else t.dispatch({effects:[OS.of(!0),e?If.of(mb(t.state,e.query.spec)):ci.appendConfig.of(gb)]});return!0},M4=t=>{let e=t.state.field(Ma,!1);if(!e||!e.panel)return!1;let i=pR(t,IS);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:OS.of(!1)}),!0},pG=[{key:"Mod-f",run:E4,scope:"editor search-panel"},{key:"F3",run:L0,shift:T0,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:L0,shift:T0,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:M4,scope:"editor search-panel"},{key:"Mod-Shift-l",run:dG},{key:"Mod-Alt-g",run:WY},{key:"Mod-d",run:eG,preventDefault:!0}];class mG{constructor(e){this.view=e;let i=this.query=e.state.field(Ma).query.spec;this.commit=this.commit.bind(this),this.searchField=xn("input",{value:i.search,placeholder:Xs(e,"Find"),"aria-label":Xs(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=xn("input",{value:i.replace,placeholder:Xs(e,"Replace"),"aria-label":Xs(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=xn("input",{type:"checkbox",name:"case",form:"",checked:i.caseSensitive,onchange:this.commit}),this.reField=xn("input",{type:"checkbox",name:"re",form:"",checked:i.regexp,onchange:this.commit}),this.wordField=xn("input",{type:"checkbox",name:"word",form:"",checked:i.wholeWord,onchange:this.commit});function n(s,r,o){return xn("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=xn("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,n("next",()=>L0(e),[Xs(e,"next")]),n("prev",()=>T0(e),[Xs(e,"previous")]),n("select",()=>hG(e),[Xs(e,"all")]),xn("label",null,[this.caseField,Xs(e,"match case")]),xn("label",null,[this.reField,Xs(e,"regexp")]),xn("label",null,[this.wordField,Xs(e,"by word")]),...e.state.readOnly?[]:[xn("br"),this.replaceField,n("replace",()=>aA(e),[Xs(e,"replace")]),n("replaceAll",()=>fG(e),[Xs(e,"replace all")])],xn("button",{name:"close",onclick:()=>M4(e),"aria-label":Xs(e,"close"),type:"button"},["×"])])}commit(){let e=new w4({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:If.of(e)}))}keydown(e){PU(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?T0:L0)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),aA(this.view))}update(e){for(let i of e.transactions)for(let n of i.effects)n.is(If)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Hc).top}}function Xs(t,e){return t.state.phrase(e)}const tg=30,ig=/[\s\.,:;?!]/;function PS(t,{from:e,to:i}){let n=t.state.doc.lineAt(e),s=t.state.doc.lineAt(i).to,r=Math.max(n.from,e-tg),o=Math.min(s,i+tg),a=t.state.sliceDoc(r,o);if(r!=n.from){for(let u=0;u<tg;u++)if(!ig.test(a[u+1])&&ig.test(a[u])){a=a.slice(u);break}}if(o!=s){for(let u=a.length-1;u>a.length-tg;u--)if(!ig.test(a[u-1])&&ig.test(a[u])){a=a.slice(0,u);break}}return Ue.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${n.number}.`)}const gG=Ue.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),gb=[Ma,Qf.low(uG),gG],vG="modulepreload",_G=function(t,e){return new URL(t,e).href},cA={},Ge=function(e,i,n){let s=Promise.resolve();if(i&&i.length>0){let h=function(p){return Promise.all(p.map(m=>Promise.resolve(m).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const o=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),u=a?.nonce||a?.getAttribute("nonce");s=h(i.map(p=>{if(p=_G(p,n),p in cA)return;cA[p]=!0;const m=p.endsWith(".css"),v=m?'[rel="stylesheet"]':"";if(n)for(let x=o.length-1;x>=0;x--){const S=o[x];if(S.href===p&&(!m||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${p}"]${v}`))return;const _=document.createElement("link");if(_.rel=m?"stylesheet":vG,m||(_.as="script"),_.crossOrigin="",_.href=p,u&&_.setAttribute("nonce",u),document.head.appendChild(_),m)return new Promise((x,S)=>{_.addEventListener("load",x),_.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${p}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})},Ft=t=>LS.define(t),yG={js:()=>Ge(()=>import("./index-CkSsGSUZ.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>t.javascript()),mjs:()=>Ge(()=>import("./index-CkSsGSUZ.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>t.javascript()),cjs:()=>Ge(()=>import("./index-CkSsGSUZ.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>t.javascript()),jsx:()=>Ge(()=>import("./index-CkSsGSUZ.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>t.javascript({jsx:!0})),ts:()=>Ge(()=>import("./index-CkSsGSUZ.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>t.javascript({typescript:!0})),mts:()=>Ge(()=>import("./index-CkSsGSUZ.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>t.javascript({typescript:!0})),cts:()=>Ge(()=>import("./index-CkSsGSUZ.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>t.javascript({typescript:!0})),tsx:()=>Ge(()=>import("./index-CkSsGSUZ.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>t.javascript({jsx:!0,typescript:!0})),json:()=>Ge(()=>import("./index-CrP4aOLs.js"),__vite__mapDeps([3,1]),import.meta.url).then(t=>t.json()),jsonc:()=>Ge(()=>import("./index-CrP4aOLs.js"),__vite__mapDeps([3,1]),import.meta.url).then(t=>t.json()),md:()=>Ge(()=>import("./index-BkI_sJNx.js"),__vite__mapDeps([4,2,5,1,6,0]),import.meta.url).then(t=>t.markdown()),markdown:()=>Ge(()=>import("./index-BkI_sJNx.js"),__vite__mapDeps([4,2,5,1,6,0]),import.meta.url).then(t=>t.markdown()),mdx:()=>Ge(()=>import("./index-BkI_sJNx.js"),__vite__mapDeps([4,2,5,1,6,0]),import.meta.url).then(t=>t.markdown()),html:()=>Ge(()=>import("./index-BJPOH430.js"),__vite__mapDeps([5,1,6,0,2]),import.meta.url).then(t=>t.html()),htm:()=>Ge(()=>import("./index-BJPOH430.js"),__vite__mapDeps([5,1,6,0,2]),import.meta.url).then(t=>t.html()),cshtml:()=>Ge(()=>import("./index-BJPOH430.js"),__vite__mapDeps([5,1,6,0,2]),import.meta.url).then(t=>t.html()),vue:()=>Ge(()=>import("./index-BJPOH430.js"),__vite__mapDeps([5,1,6,0,2]),import.meta.url).then(t=>t.html()),css:()=>Ge(()=>import("./index-DecdvRvX.js"),__vite__mapDeps([6,1]),import.meta.url).then(t=>t.css()),scss:()=>Ge(()=>import("./index-DecdvRvX.js"),__vite__mapDeps([6,1]),import.meta.url).then(t=>t.css()),less:()=>Ge(()=>import("./index-DecdvRvX.js"),__vite__mapDeps([6,1]),import.meta.url).then(t=>t.css()),rs:()=>Ge(()=>import("./index-C3qkbCLt.js"),__vite__mapDeps([7,1]),import.meta.url).then(t=>t.rust()),py:()=>Ge(()=>import("./index-B3amz3YD.js"),__vite__mapDeps([8,1,2]),import.meta.url).then(t=>t.python()),pyi:()=>Ge(()=>import("./index-B3amz3YD.js"),__vite__mapDeps([8,1,2]),import.meta.url).then(t=>t.python()),sql:()=>Ge(()=>import("./index-nLNkR2xP.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(t=>t.sql()),yaml:()=>Ge(()=>import("./index-Czi1vLYr.js"),__vite__mapDeps([10,1]),import.meta.url).then(t=>t.yaml()),yml:()=>Ge(()=>import("./index-Czi1vLYr.js"),__vite__mapDeps([10,1]),import.meta.url).then(t=>t.yaml()),sh:()=>Ge(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(t=>Ft(t.shell)),bash:()=>Ge(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(t=>Ft(t.shell)),zsh:()=>Ge(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(t=>Ft(t.shell)),fish:()=>Ge(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(t=>Ft(t.shell)),cs:()=>Ge(()=>import("./clike-B9uivgTg.js"),[],import.meta.url).then(t=>Ft(t.csharp)),c:()=>Ge(()=>import("./clike-B9uivgTg.js"),[],import.meta.url).then(t=>Ft(t.c)),h:()=>Ge(()=>import("./clike-B9uivgTg.js"),[],import.meta.url).then(t=>Ft(t.c)),cpp:()=>Ge(()=>import("./clike-B9uivgTg.js"),[],import.meta.url).then(t=>Ft(t.cpp)),hpp:()=>Ge(()=>import("./clike-B9uivgTg.js"),[],import.meta.url).then(t=>Ft(t.cpp)),java:()=>Ge(()=>import("./clike-B9uivgTg.js"),[],import.meta.url).then(t=>Ft(t.java)),kt:()=>Ge(()=>import("./clike-B9uivgTg.js"),[],import.meta.url).then(t=>Ft(t.kotlin)),swift:()=>Ge(()=>import("./swift-BzpIVaGY.js"),[],import.meta.url).then(t=>Ft(t.swift)),go:()=>Ge(()=>import("./go-CTD25R5P.js"),[],import.meta.url).then(t=>Ft(t.go)),rb:()=>Ge(()=>import("./ruby-B2Rjki9n.js"),[],import.meta.url).then(t=>Ft(t.ruby)),lua:()=>Ge(()=>import("./lua-VAEuO923.js"),[],import.meta.url).then(t=>Ft(t.lua)),toml:()=>Ge(()=>import("./toml-Bm5Em-hy.js"),[],import.meta.url).then(t=>Ft(t.toml)),xml:()=>Ge(()=>import("./xml-BQQZnNBQ.js"),[],import.meta.url).then(t=>Ft(t.xml)),svg:()=>Ge(()=>import("./xml-BQQZnNBQ.js"),[],import.meta.url).then(t=>Ft(t.xml)),xaml:()=>Ge(()=>import("./xml-BQQZnNBQ.js"),[],import.meta.url).then(t=>Ft(t.xml)),csproj:()=>Ge(()=>import("./xml-BQQZnNBQ.js"),[],import.meta.url).then(t=>Ft(t.xml)),diff:()=>Ge(()=>import("./diff-DbItnlRl.js"),[],import.meta.url).then(t=>Ft(t.diff)),patch:()=>Ge(()=>import("./diff-DbItnlRl.js"),[],import.meta.url).then(t=>Ft(t.diff)),ps1:()=>Ge(()=>import("./powershell-CFHJl5sT.js"),[],import.meta.url).then(t=>Ft(t.powerShell)),properties:()=>Ge(()=>import("./properties-C78fOPTZ.js"),[],import.meta.url).then(t=>Ft(t.properties)),ini:()=>Ge(()=>import("./properties-C78fOPTZ.js"),[],import.meta.url).then(t=>Ft(t.properties)),env:()=>Ge(()=>import("./properties-C78fOPTZ.js"),[],import.meta.url).then(t=>Ft(t.properties))},uA={dockerfile:()=>Ge(()=>import("./dockerfile-ZL4hHokT.js"),[],import.meta.url).then(t=>Ft(t.dockerFile)),makefile:()=>Ge(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(t=>Ft(t.shell)),".env":()=>Ge(()=>import("./properties-C78fOPTZ.js"),[],import.meta.url).then(t=>Ft(t.properties)),".gitignore":()=>Ge(()=>import("./properties-C78fOPTZ.js"),[],import.meta.url).then(t=>Ft(t.properties)),".dockerignore":()=>Ge(()=>import("./properties-C78fOPTZ.js"),[],import.meta.url).then(t=>Ft(t.properties)),".editorconfig":()=>Ge(()=>import("./properties-C78fOPTZ.js"),[],import.meta.url).then(t=>Ft(t.properties))};async function xG(t){const e=(t.split("/").pop()??t).toLowerCase(),i=uA[e]??uA[e.slice(0,e.indexOf(".",1))];if(i)return i();const n=e.lastIndexOf(".");if(n<=0)return null;const s=yG[e.slice(n+1)];return s?s():null}const bG=cv.define([{tag:[je.comment,je.lineComment,je.blockComment,je.docComment],color:"var(--syntax-comment)",fontStyle:"italic"},{tag:[je.keyword,je.modifier,je.controlKeyword,je.moduleKeyword],color:"var(--syntax-keyword)"},{tag:[je.string,je.special(je.string),je.regexp],color:"var(--syntax-string)"},{tag:[je.number,je.bool,je.null,je.atom],color:"var(--syntax-number)"},{tag:[je.function(je.variableName),je.function(je.propertyName),je.labelName],color:"var(--syntax-function)"},{tag:[je.typeName,je.className,je.namespace,je.self],color:"var(--syntax-type)"},{tag:[je.propertyName,je.attributeName],color:"var(--syntax-property)"},{tag:[je.variableName,je.definition(je.variableName)],color:"var(--fg-1)"},{tag:[je.operator,je.punctuation,je.separator,je.bracket],color:"var(--fg-2)"},{tag:[je.tagName],color:"var(--syntax-property)"},{tag:[je.heading],color:"var(--syntax-function)",fontWeight:"600"},{tag:[je.link,je.url],color:"var(--link)",textDecoration:"underline"},{tag:[je.emphasis],fontStyle:"italic"},{tag:[je.strong],fontWeight:"600"},{tag:[je.invalid],color:"var(--syntax-property)"}]),wG=Ue.theme({"&":{height:"100%",fontSize:"var(--ws-code-size)",backgroundColor:"var(--bg-0)",color:"var(--fg-1)"},".cm-scroller":{fontFamily:"var(--mono)",lineHeight:"1.7",overflow:"auto",paddingBottom:"calc(28px + env(safe-area-inset-bottom))"},".cm-content":{caretColor:"var(--accent)",padding:"10px 0 0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--accent)",borderLeftWidth:"2px"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:"color-mix(in srgb, var(--focus) 25%, transparent)"},".cm-gutters":{backgroundColor:"var(--bg-0)",color:"var(--fg-3)",border:"0",paddingRight:"4px"},".cm-activeLine":{backgroundColor:"color-mix(in srgb, var(--fg-0) 4%, transparent)"},".cm-activeLineGutter":{backgroundColor:"transparent",color:"var(--fg-2)"},".cm-selectionMatch":{backgroundColor:"color-mix(in srgb, var(--warn) 20%, transparent)"},".cm-matchingBracket, &.cm-focused .cm-matchingBracket":{backgroundColor:"color-mix(in srgb, var(--focus) 24%, transparent)",outline:"0"},".cm-panels":{backgroundColor:"var(--bg-sunken)",color:"var(--fg-1)"},".cm-panels input, .cm-panels button":{backgroundColor:"var(--bg-1)",color:"var(--fg-1)",border:"1px solid var(--border)",borderRadius:"var(--r-sm)",padding:"3px 6px",font:"inherit"}},{dark:!0});function SG({path:t,initialDoc:e,readOnly:i=!1,onChange:n,onSave:s,onSelect:r}){const o=w.useRef(null),a=w.useRef(null),u=w.useRef(n),h=w.useRef(s),p=w.useRef(r);return u.current=n,h.current=s,p.current=r,w.useEffect(()=>{const m=o.current;if(!m)return;const v=new Xf,_=It.create({doc:e,extensions:[SV(),EV(),oV(),eV(),PK(),qU(),dV(),lK(),_K(),VY(),tG({top:!0}),Ue.lineWrapping,lv.of(" "),cK(bG),wG,v.of([]),It.readOnly.of(i),Ue.editable.of(!i),Ue.contentAttributes.of({autocapitalize:"off",autocorrect:"off",spellcheck:"false"}),aR.of([{key:"Mod-s",preventDefault:!0,run:()=>(h.current(),!0)},{key:"Escape",run:M=>(M.contentDOM.blur(),!0)},...pG,...KK,...$Y,FY]),Ue.updateListener.of(M=>{if(M.docChanged&&u.current(M.state.doc.toString()),M.selectionSet||M.docChanged){const{from:L,to:N}=M.state.selection.main;p.current?.({from:L,to:N,text:L===N?"":M.state.doc.sliceString(L,N)})}})]}),x=new Ue({state:_,parent:m});a.current=x;const S=qj(u0("code",t));S&&x.dispatch({effects:S});const C=()=>Wj(u0("code",t),x.scrollSnapshot());x.scrollDOM.addEventListener("scroll",C,{passive:!0});let k=!0;return xG(t).then(M=>{!k||!M||x.dispatch({effects:v.reconfigure(M)})}).catch(()=>{}),()=>{k=!1,x.scrollDOM.removeEventListener("scroll",C),x.destroy(),a.current=null}},[t,i]),w.useEffect(()=>{const m=o.current;if(!m||typeof IntersectionObserver>"u")return;const v=new IntersectionObserver(_=>{_.some(x=>x.isIntersecting)&&a.current?.requestMeasure()});return v.observe(m),()=>v.disconnect()},[]),d.jsx("div",{className:"ws-cm",ref:o})}function A4({children:t}){return d.jsx("div",{className:"prose-table",children:d.jsx("table",{children:t})})}const kG={a:sS,table:A4};function CG(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} kB`:`${(t/(1024*1024)).toFixed(1)} MB`}function EG({path:t,preview:e,draft:i,onDraft:n,onSave:s,raw:r,generation:o,onProseRef:a,onSelect:u}){if(!e)return d.jsx("div",{className:"dots","aria-label":"loading"});const h=oS(t,e),p=r&&(h==="prose"||h==="page")?"code":h;return p==="image"?d.jsx(AG,{path:t}):p==="video"?d.jsx(LG,{path:t,size:e.size},`${t}:${o??0}`):p==="none"?d.jsx(T4,{path:t,preview:e}):p==="page"?d.jsx(MG,{path:t,html:i}):p==="prose"?d.jsx("div",{className:"prose panel-prose",ref:a,children:d.jsx(Gw,{remarkPlugins:[Jw],components:kG,children:i})}):d.jsx(SG,{path:t,initialDoc:e.content,readOnly:e.truncated,onChange:n,onSave:()=>s?.(),onSelect:u},`${t}:${o??0}`)}function L4({path:t}){const[e,i]=w.useState(!1),[n,s]=w.useState(null),[r,o]=w.useState(!1);async function a(){i(!0),s(null),o(!1);try{await he.invoke("open_file_native",{path:t}),o(!0)}catch(u){s(u instanceof Error?u.message:String(u))}finally{i(!1)}}return d.jsxs("div",{className:"native-open",children:[d.jsx("button",{className:"native-open-btn",type:"button",disabled:e,onClick:()=>{a()},children:e?"Opening…":"Open in default app"}),d.jsx("p",{className:"native-open-note",children:"On the computer running OctiqFlow"}),r&&d.jsx("p",{className:"native-open-status",role:"status",children:"Opened."}),n&&d.jsx("p",{className:"native-open-error",role:"alert",children:n})]})}function T4({path:t,preview:e,reason:i="Preview unavailable"}){const n=e.kind==="pdf"?"PDF document":"File";return d.jsxs("div",{className:"panel-unsupported",children:[d.jsxs("div",{className:"panel-unsupported-copy",children:[d.jsx("strong",{children:i}),d.jsxs("span",{children:[n," · ",d.jsx(ct,{children:CG(e.size)})]})]}),d.jsx(L4,{path:t},t)]})}function MG({path:t,html:e}){return d.jsx("iframe",{className:"panel-page",title:`${Vi(t)} — preview`,srcDoc:e,sandbox:"allow-scripts allow-popups",referrerPolicy:"no-referrer"})}function AG({path:t}){const[e,i]=w.useState(null),[n,s]=w.useState(null),r=w.useRef(null);return w.useEffect(()=>{let o=!0;return he.fetchFile(t).then(a=>{o&&(r.current=URL.createObjectURL(a),i(r.current))}).catch(a=>o&&s(a.message)),()=>{o=!1,r.current&&URL.revokeObjectURL(r.current)}},[t]),n?d.jsx("div",{className:"panel-error",children:n}):e?d.jsx("div",{className:"ws-image",children:d.jsx("img",{src:e,alt:Vi(t)})}):d.jsx("div",{className:"dots","aria-label":"loading"})}function LG({path:t,size:e}){const[i,n]=w.useState(!1);return i?d.jsx(T4,{path:t,preview:{kind:"video",content:"",truncated:!1,size:e},reason:"This video can’t play in this browser"}):d.jsx("div",{className:"ws-video",children:d.jsx("video",{src:he.fileUrl(t),controls:!0,playsInline:!0,preload:"metadata","aria-label":Vi(t),onError:()=>n(!0)})})}function TG(t,e){const[i,n]=w.useState("closed"),[s,r]=w.useState(null),o=w.useRef(null),a=w.useRef(!1),u=w.useRef(null);w.useLayoutEffect(()=>n("closed"),[e]),w.useLayoutEffect(()=>{const _=document.getElementById("dock"),x=_?.querySelector(".main:not([hidden])"),S=_?.closest(".app"),C=window.matchMedia("(max-width: 700px)");if(!_||!x||!t){r(null);return}const k=x.inert,M=window.visualViewport,L=()=>{C.matches&&M&&S?.style.setProperty("--reader-viewport-height",`${M.height}px`)},N=()=>{r(C.matches?x:null),C.matches?(_.dataset.readerChat=i,S?.classList.add("is-file-reading"),x.inert=i==="closed",L()):(delete _.dataset.readerChat,S?.classList.remove("is-file-reading"),x.inert=k)};return N(),C.addEventListener("change",N),M?.addEventListener("resize",L),()=>{C.removeEventListener("change",N),M?.removeEventListener("resize",L),x.inert=k,delete _.dataset.readerChat,S?.classList.remove("is-file-reading"),S?.style.removeProperty("--reader-viewport-height")}},[t,i]);function h(){s&&bl.flushSync(()=>n("half"))}function p(){document.activeElement instanceof HTMLElement&&s?.contains(document.activeElement)&&document.activeElement.blur(),bl.flushSync(()=>n("closed")),u.current?.focus({preventScroll:!0})}const m=s&&i!=="closed"?bl.createPortal(d.jsxs("header",{className:"reader-chat-head",children:[d.jsxs("button",{className:"reader-chat-resize",type:"button","aria-label":i==="large"?"Make chat smaller":"Expand chat","aria-expanded":i==="large",onClick:()=>{if(a.current){a.current=!1;return}n(i==="large"?"half":"large")},onPointerDown:_=>{a.current=!1,o.current=_.clientY,_.currentTarget.setPointerCapture(_.pointerId)},onPointerUp:_=>{const x=_.clientY-(o.current??_.clientY);o.current=null,!(Math.abs(x)<30)&&(a.current=!0,_.preventDefault(),x>0?p():n("large"))},onPointerCancel:()=>{o.current=null},children:[d.jsx("span",{className:"reader-chat-grip"}),"Chat"]}),d.jsxs("button",{type:"button",onClick:p,children:["Continue reading ",d.jsx("span",{"aria-hidden":"true",children:"⌄"})]})]}),s):null;return{show:h,collapse:p,size:i,controls:m,launcher:s&&i==="closed"?d.jsxs("button",{ref:u,className:"reader-chat-launch",type:"button",onClick:h,children:[d.jsx("span",{children:"Ask agent / discuss this file"}),d.jsx("span",{"aria-hidden":"true",children:"⌃"})]}):null}}function py(t,e){const i=t.getBoundingClientRect().top,n=Array.from(e.children),s=Math.max(0,n.findIndex(o=>o.getBoundingClientRect().bottom>i)),r=[s,s+1,s-1];return{scrollTop:t.scrollTop,blocks:r.flatMap(o=>{const a=n[o];return a?[{text:a.textContent??"",index:o,offset:a.getBoundingClientRect().top-i}]:[]})}}function NG(t,e,i){const n=Array.from(e.children);for(const s of i.blocks){if(!s.text)continue;const r=n.map((o,a)=>({el:o,index:a})).filter(({el:o})=>o.textContent===s.text).sort((o,a)=>Math.abs(o.index-s.index)-Math.abs(a.index-s.index))[0];if(r){t.scrollTop+=r.el.getBoundingClientRect().top-t.getBoundingClientRect().top-s.offset;return}}t.scrollTop=i.scrollTop}const jG="octiq.v2.fileWidth",RG={initial:480,min:320,max:760},DG="dock";function hA(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} kB`:`${(t/(1024*1024)).toFixed(1)} MB`}function BG({path:t,open:e,onClose:i}){const[n,s]=w.useState(null),[r,o]=w.useState(null),[a,u]=w.useState(""),[h,p]=w.useState(!1),[m,v]=w.useState(!1),[_,x]=w.useState(!1),[S,C]=w.useState(!1),[k,M]=w.useState(null),[L,N]=w.useState(0),j=TG(e,t),R=w.useRef(null),z=w.useRef(null),J=w.useRef(0),G=lS(),{width:q,startDrag:X,entered:I}=Gf(jG,RG),T=w.useRef(null),H=w.useRef(null),F=w.useRef(null),P=w.useRef(null),U=!!n&&a!==n.content,V=w.useRef(a),K=w.useRef(n?.content??"");V.current=a,K.current=n?.content??"";const D=!!n&&n.kind==="text"&&!n.truncated&&U,$=!!n&&!h&&oS(t,n)==="prose",Y=w.useCallback(async fe=>{const Pe=++J.current,De=V.current;try{const He=await he.invoke("read_file_preview",{path:t});if(Pe!==J.current)return;if(fe&&V.current!==De){C(!0);return}fe&&F.current&&H.current&&(R.current=py(F.current,H.current)),s(He),u(He.content??""),N(_e=>_e+1),M(null),C(!1),o(null),fe||p(!1)}catch(He){if(Pe!==J.current)return;o(String(He.message??He))}},[t]);w.useEffect(()=>(s(null),o(null),p(!1),M(null),R.current=null,z.current=null,Y(!1),()=>{J.current++}),[t,Y]),w.useLayoutEffect(()=>{const fe=F.current;if(!fe||!$)return;const Pe=qj(u0("prose",t));Pe&&(fe.scrollTop=Pe)},[t,$]),w.useLayoutEffect(()=>{$&&F.current&&H.current&&R.current&&NG(F.current,H.current,R.current)},[L,$,j.size]),w.useEffect(()=>{if(j.size!=="closed"||!z.current||!H.current)return;const fe=Array.from(H.current.children).find(De=>De.textContent?.includes(z.current));if(!fe)return;fe.classList.add("reader-return-highlight");const Pe=setTimeout(()=>fe.classList.remove("reader-return-highlight"),1800);return()=>{clearTimeout(Pe),fe.classList.remove("reader-return-highlight")}},[j.size]),w.useEffect(()=>{he.invoke("file_watch_paths",{paths:[t]}).catch(()=>{});const fe=he.on("file-changed",Pe=>{if(!(!Array.isArray(Pe)||!Pe.includes(t))){if(V.current!==K.current){C(!0);return}Y(!0)}});return()=>{fe(),he.invoke("file_watch_paths",{paths:[]}).catch(()=>{})}},[t,Y]);const B=w.useCallback(()=>{const fe=window.getSelection();if(!fe||fe.isCollapsed||fe.rangeCount===0)return M(null);const Pe=fe.getRangeAt(0),De=H.current;if(!De||!De.contains(Pe.commonAncestorContainer))return M(null);const He=fe.toString();if(!He.trim())return M(null);const _e=V.current.indexOf(He),jt=_e>=0&&V.current.lastIndexOf(He)===_e?DE(V.current,_e,_e+He.length):{from:0,to:0},di=Pe.getBoundingClientRect();M({quote:{path:t,text:He,...jt},x:di.left+di.width/2,y:di.top})},[t]);w.useEffect(()=>{const fe=()=>{requestAnimationFrame(B)};return document.addEventListener("selectionchange",fe),()=>document.removeEventListener("selectionchange",fe)},[B]);const ee=w.useCallback(fe=>{if(!fe.text.trim())return M(null);const Pe=V.current,De=P.current??OG(T.current);M({quote:{path:t,text:fe.text,...DE(Pe,fe.from,fe.to)},...De})},[t]),ie=w.useCallback(()=>{k&&(z.current=k.quote.text,F.current&&H.current&&(R.current=py(F.current,H.current)),j.show(),EW(k.quote),M(null))},[k,j]);w.useEffect(()=>{const fe=()=>{const De=document.activeElement;return!De||De===document.body||!!T.current?.contains(De)},Pe=De=>{if(fe()){if(De.key==="Escape"){if(k)return M(null);if(j.size!=="closed")return j.collapse();U||i()}De.key==="s"&&(De.metaKey||De.ctrlKey)&&(De.preventDefault(),re())}};return window.addEventListener("keydown",Pe),()=>window.removeEventListener("keydown",Pe)});async function re(){if(!(!D||m)){v(!0),o(null);try{await he.invoke("write_file",{path:t,content:a}),s(fe=>fe&&{...fe,content:a}),x(!0),setTimeout(()=>x(!1),1600)}catch(fe){o(String(fe.message??fe))}finally{v(!1)}}}async function ge(){U&&!await G({title:"Close without saving?",body:`Your changes to ${Vi(t)} will be lost.`,confirmLabel:"Discard changes",danger:!0})||i()}const Ee=typeof document>"u"?null:document.getElementById(DG);return Ee?d.jsxs(d.Fragment,{children:[bl.createPortal(d.jsxs(d.Fragment,{children:[d.jsx("div",{className:`fpanel-scrim ${I&&e?"is-open":""}`,onClick:()=>{ge()},"aria-hidden":"true"}),d.jsxs("aside",{ref:T,className:`fpanel ${I&&e?"is-open":""}`,"aria-label":Vi(t),style:{"--gitp-w":`${q}px`},onPointerUp:fe=>{P.current={x:fe.clientX,y:fe.clientY},B()},children:[d.jsx("div",{className:"gitp-resizer",role:"separator","aria-orientation":"vertical","aria-label":"Resize the file panel",onPointerDown:X}),d.jsxs("header",{className:"panel-head",children:[d.jsxs("div",{className:"panel-id",children:[d.jsxs("div",{className:"panel-name",children:[Vi(t),U&&d.jsx("span",{className:"panel-dirty",title:"Unsaved changes"})]}),d.jsx("div",{className:"panel-path",children:d.jsx("bdi",{children:t})})]}),d.jsxs("span",{className:"panel-acts",children:[d.jsx(l0,{className:"panel-act",icon:d.jsx(tv,{}),idle:"Copy the path",done:"Path copied",read:()=>({text:t})}),n?.kind==="text"&&d.jsx(l0,{className:"panel-act",icon:d.jsx(Pj,{}),idle:"Copy the whole file",done:"File copied",empty:"Nothing to copy — this file is empty",partial:"Copied what is on screen — the rest of the file was never read",read:()=>({text:a,partial:n.truncated})})]}),yW(t,n)&&d.jsx("button",{className:"panel-btn",type:"button",onClick:()=>p(fe=>!fe),children:h?"Preview":"Edit"}),n?.kind==="text"&&!n.truncated&&d.jsx("button",{className:"panel-btn is-primary",type:"button",onClick:re,disabled:!D||m,children:m?"Saving…":_?"Saved":"Save"}),d.jsx("button",{className:"panel-close",type:"button",onClick:()=>{ge()},"aria-label":"Close",children:"✕"})]}),r&&d.jsxs("div",{className:"panel-error",children:[r,d.jsx(L4,{path:t},t)]}),S&&d.jsxs("div",{className:"panel-warn is-stale",children:["This file changed on disk while you were editing it.",d.jsx("button",{className:"panel-inline-btn",type:"button",onClick:()=>{Y(!0)},children:"Reload and lose my changes"})]}),n?.truncated&&d.jsxs("div",{className:"panel-warn",children:["Showing the first ",d.jsx(ct,{children:hA(n.content.length)})," of"," ",d.jsx(ct,{children:hA(n.size)}),". Saving is off for this file — writing back what is on screen would cut the rest away."]}),d.jsxs("div",{className:"panel-body",ref:F,onScroll:fe=>{$&&(Wj(u0("prose",t),fe.currentTarget.scrollTop),H.current&&(R.current=py(fe.currentTarget,H.current)))},children:[!n&&!r&&d.jsx("div",{className:"dots","aria-label":"loading"}),n&&d.jsx(EG,{path:t,preview:n,draft:a,raw:h,generation:L,onDraft:u,onSave:()=>{re()},onSelect:ee,onProseRef:fe=>{H.current=fe}})]}),j.launcher]})]}),Ee),j.controls,k&&MW()&&bl.createPortal(d.jsxs("button",{className:"quote-btn reader-quote",type:"button",style:{left:`${k.x}px`,top:`${k.y}px`},onMouseDown:fe=>fe.preventDefault(),onPointerDown:fe=>fe.preventDefault(),onClick:ie,children:[d.jsx("span",{className:"quote-btn-plus","aria-hidden":"true",children:"+"}),"Add to chat",k.quote.from>0&&d.jsx("span",{className:"quote-btn-at",children:k.quote.to>k.quote.from?`${k.quote.from}–${k.quote.to}`:k.quote.from})]}),document.body)]}):null}function OG(t){if(!t)return{x:24,y:80};const e=t.getBoundingClientRect();return{x:e.left+e.width/2,y:e.top+40}}const vl=1,N4=8,dA=[1,1.5,2,3,4,6,8],IG=400;function zS(t){return Number.isFinite(t)?Math.min(N4,Math.max(vl,t)):vl}function ng(t,e){const i=zS(t);return(e>0?dA.find(s=>s>i+1e-6):[...dA].reverse().find(s=>s<i-1e-6))??i}function PG(t,e){return zS(t*Math.exp(-e/IG))}function zG(t,e,i,n){const s=n/i;return{x:e.x-(e.x-t.x)*s,y:e.y-(e.y-t.y)*s}}function $G(t,e,i,n){const s=(a,u)=>Math.max(0,(u*n-a)/2),r=s(e.w,i.w),o=s(e.h,i.h);return{x:Math.min(r,Math.max(-r,t.x)),y:Math.min(o,Math.max(-o,t.y))}}const Bg={x:0,y:0},fA=4,sg={scale:vl,pan:Bg};function j4({path:t,onClose:e}){const[i,n]=w.useState(null),[s,r]=w.useState(null),[o,a]=w.useState(sg),u=w.useRef(null),h=w.useRef(null),p=Fj(t);w.useEffect(()=>{let z=!0,J=null;return a(sg),he.fetchFile(t).then(G=>{z&&(J=URL.createObjectURL(G),n(J))}).catch(G=>z&&r(G.message)),()=>{z=!1,J&&URL.revokeObjectURL(J)}},[t]);const m=w.useCallback((z,J,G)=>{const q=zS(J),X=u.current,I=h.current,T={w:X?.clientWidth??0,h:X?.clientHeight??0},H={w:I?.offsetWidth??0,h:I?.offsetHeight??0};return{scale:q,pan:$G(zG(z.pan,G,z.scale,q),T,H,q)}},[]),v=w.useCallback((z,J=Bg)=>a(G=>m(G,z(G.scale),J)),[m]),_=w.useCallback((z,J)=>{const G=u.current?.getBoundingClientRect();return G?{x:z-(G.left+G.width/2),y:J-(G.top+G.height/2)}:Bg},[]);w.useEffect(()=>{const z=u.current;if(!z||p)return;const J=G=>{G.preventDefault();const q=G.ctrlKey?G.deltaY*3:G.deltaY;v(X=>PG(X,q),_(G.clientX,G.clientY))};return z.addEventListener("wheel",J,{passive:!1}),()=>z.removeEventListener("wheel",J)},[_,p,i,v]),w.useEffect(()=>{const z=J=>{if(J.key==="Escape")return e();if(p||J.metaKey||J.ctrlKey||J.altKey)return;const G=J.target;G&&(G.tagName==="INPUT"||G.tagName==="TEXTAREA"||G.isContentEditable)||(J.key==="+"||J.key==="="?v(q=>ng(q,1)):J.key==="-"||J.key==="_"?v(q=>ng(q,-1)):J.key==="0"&&a(sg))};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[e,p,v]);const x=w.useRef(new Map),S=w.useRef(null),C=w.useRef(null),k=w.useRef(!1),M=()=>{const[z,J]=[...x.current.values()];return Math.hypot(z.x-J.x,z.y-J.y)},L=()=>{const[z,J]=[...x.current.values()];return _((z.x+J.x)/2,(z.y+J.y)/2)};function N(z){if(!p){if(x.current.size===0&&(k.current=!1),x.current.set(z.pointerId,{x:z.clientX,y:z.clientY}),x.current.size===2){S.current=null,C.current=M(),k.current=!0;return}x.current.size>2||o.scale<=vl||(z.target.setPointerCapture?.(z.pointerId),S.current={id:z.pointerId,from:{x:z.clientX,y:z.clientY},pan:o.pan})}}function j(z){if(!x.current.has(z.pointerId))return;if(x.current.set(z.pointerId,{x:z.clientX,y:z.clientY}),C.current!==null&&x.current.size===2){const X=M(),I=C.current>0?X/C.current:1;C.current=X,v(T=>T*I,L());return}const J=S.current;if(!J||J.id!==z.pointerId)return;const G=z.clientX-J.from.x,q=z.clientY-J.from.y;(Math.abs(G)>fA||Math.abs(q)>fA)&&(k.current=!0),a(X=>m({...X,pan:{x:J.pan.x+G,y:J.pan.y+q}},X.scale,Bg))}function R(z){x.current.delete(z.pointerId),x.current.size<2&&(C.current=null),S.current?.id===z.pointerId&&(S.current=null)}return bl.createPortal(d.jsxs("div",{className:"viewer",onClick:()=>k.current?k.current=!1:e(),children:[d.jsxs("div",{className:"viewer-bar",onClick:z=>z.stopPropagation(),children:[d.jsx("span",{className:"viewer-name",children:Vi(t)}),!p&&i&&d.jsxs("div",{className:"viewer-zoom",children:[d.jsx("button",{className:"viewer-btn",type:"button",onClick:()=>v(z=>ng(z,-1)),disabled:o.scale<=vl,"aria-label":"Zoom out",title:"Zoom out (−)",children:"−"}),d.jsx("button",{className:"viewer-level",type:"button",onClick:()=>a(sg),disabled:o.scale<=vl,title:"Fit to screen (0)",children:d.jsx(ct,{children:`${Math.round(o.scale*10)/10}×`})}),d.jsx("button",{className:"viewer-btn",type:"button",onClick:()=>v(z=>ng(z,1)),disabled:o.scale>=N4,"aria-label":"Zoom in",title:"Zoom in (+)",children:"+"})]}),d.jsx("button",{className:"viewer-close",type:"button",onClick:e,"aria-label":"Close",children:"✕"})]}),s?d.jsx("div",{className:"viewer-error",children:s}):i?p?d.jsx("iframe",{className:"viewer-pdf",src:i,title:Vi(t)}):d.jsx("div",{className:`viewer-stage ${o.scale>vl?"is-zoomed":""}`,ref:u,onPointerDown:N,onPointerMove:j,onPointerUp:R,onPointerCancel:R,onDoubleClick:z=>v(J=>J>vl?vl:2,_(z.clientX,z.clientY)),children:d.jsx("img",{className:"viewer-img",ref:h,src:i,alt:Vi(t),draggable:!1,style:{transform:`translate(${o.pan.x}px, ${o.pan.y}px) scale(${o.scale})`},onClick:z=>z.stopPropagation()})}):d.jsx("div",{className:"dots","aria-label":"loading"})]}),document.body)}const FG=220;function HG({children:t}){const[e,i]=w.useState(null),[n,s]=w.useState(null),[r,o]=w.useState(null),a=w.useCallback(()=>{i(null),s(null)},[]),u=w.useCallback(h=>{if(hW(h)){s(null),i(null),he.openFileInBrowser(h);return}rS(h)||Fj(h)?(s(null),i(h)):(i(null),s(h),o(h))},[]);return w.useEffect(()=>{if(n)return;const h=setTimeout(()=>o(null),FG);return()=>clearTimeout(h)},[n]),d.jsx(Oj.Provider,{value:u,children:d.jsxs(Ij.Provider,{value:a,children:[t,e&&d.jsx(j4,{path:e,onClose:()=>i(null)}),r&&d.jsx(BG,{path:r,open:!!n,onClose:()=>s(null)})]})})}function R4({attachment:t}){const[e,i]=w.useState(t.url??null);return w.useEffect(()=>{if(t.url){i(t.url);return}let n=!0,s=null;return he.fetchFile(t.path).then(r=>{n&&(s=URL.createObjectURL(r),i(s))}).catch(()=>n&&i(null)),()=>{n=!1,s&&URL.revokeObjectURL(s)}},[t.path,t.url]),e?d.jsx("img",{className:"chip-thumb",src:e,alt:""}):d.jsx(qG,{})}function WG({files:t}){const e=ev();return t.length===0?null:d.jsx("div",{className:"sent-files",children:t.map(i=>d.jsxs("button",{className:`chip ${i.isImage?"is-image":""}`,type:"button",title:`${i.path} — click to open`,onClick:()=>e(i.path),children:[i.isImage?d.jsx(R4,{attachment:i}):d.jsx(UG,{}),d.jsx("span",{className:"chip-name",children:i.name})]},i.path))})}function qG(){return d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),d.jsx("circle",{cx:"8.5",cy:"9.5",r:"1.6"}),d.jsx("path",{d:"m4 17 4.5-4.5a2 2 0 0 1 2.8 0L16 17"}),d.jsx("path",{d:"m14 14 1.8-1.8a2 2 0 0 1 2.8 0L21 14.5"})]})}function UG(){return d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8Z"}),d.jsx("path",{d:"M14 3v5h5"})]})}function my(t){const e=Math.round(t/1e3);return e>=1e3?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${e}k`:String(Math.max(0,Math.round(t)))}const VG=42,KG=2.5,YG=320,pA=1500;function GG(){return window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1}function QG(t,e){const[i,n]=w.useState(()=>e?0:t.length),s=w.useRef(i),r=w.useRef(0),o=w.useRef(0),a=w.useRef(0),u=w.useRef(e);return s.current=i,e&&(u.current=!0),w.useEffect(()=>{if(GG()||!u.current){s.current!==t.length&&n(t.length);return}if(s.current>t.length){n(t.length);return}const h=p=>{const m=t.length-s.current;if(m<=0){o.current=0,r.current=0;return}const v=o.current?Math.min(p-o.current,100):16;if(o.current=p,m>pA){s.current=t.length-pA,n(s.current),a.current=requestAnimationFrame(h);return}const _=Math.min(YG,Math.max(VG,m/KG));r.current+=_*v/1e3;const x=Math.floor(r.current);x>=1&&(r.current-=x,s.current=Math.min(t.length,s.current+x),n(s.current)),a.current=requestAnimationFrame(h)};return a.current=requestAnimationFrame(h),()=>cancelAnimationFrame(a.current)},[t,e]),t.slice(0,i)}const D4=/^\s{0,3}(`{3,}|~{3,})(.*)$/;function XG(t){if(!t)return[];const e=t.split(`
|
|
62
|
+
`),i=[];let n=[],s=null;const r=()=>{n.length&&(i.push(n.join(`
|
|
63
|
+
`)),n=[])};for(const o of e){const a=D4.exec(o);if(s){n.push(o),a&&a[1][0]===s.marker&&a[1].length>=s.length&&!a[2].trim()&&(s=null,r());continue}if(a){r(),s={marker:a[1][0],length:a[1].length},n.push(o);continue}if(!o.trim()){r();continue}n.push(o)}return r(),i}function ZG(t){const e=t.split(`
|
|
64
|
+
`);let i=null;for(const n of e){const s=D4.exec(n);s&&(i?s[1][0]===i.marker&&s[1].length>=i.length&&!s[2].trim()&&(i=null):i={marker:s[1][0],length:s[1].length})}return i?`${t}
|
|
65
|
+
${i.marker.repeat(i.length)}`:t}function JG(t){const e=t.match(/\S+\s*|\s+/g);return e?e.map(i=>({type:"element",tagName:"span",properties:{className:["w"]},children:[{type:"text",value:i}]})):[]}function B4(t){if(!t.children?.length)return;const e=[];for(const i of t.children){if(i.type==="text"&&i.value){e.push(...JG(i.value));continue}if(i.tagName==="pre"||i.tagName==="code"){e.push(i);continue}B4(i),e.push(i)}t.children=e}function eQ(){return t=>B4(t)}function rg(t){const e=t.trim().replace(/,/g,""),i=/^([\d.]+)\s*([km]?)$/i.exec(e);if(!i)return 0;const n=Number(i[1]);if(!Number.isFinite(n))return 0;const s=i[2].toLowerCase();return Math.round(n*(s==="m"?1e6:s==="k"?1e3:1))}function tQ(t){return t.trim().replace(/^\||\|$/g,"").split("|").map(e=>e.trim())}const iQ=/^\|?[\s:-]+\|[\s|:-]*$/;function nQ(t){return/^#{1,3}\s*Context Usage/im.test(t)}function sQ(t){if(!nQ(t))return null;const e={categories:[],tools:[]};e.model=/\*\*Model:\*\*\s*([^\s*]+)/i.exec(t)?.[1];const i=/\*\*Tokens:\*\*\s*([\d.,]+\s*[km]?)\s*\/\s*([\d.,]+\s*[km]?)\s*\((\d+(?:\.\d+)?)%\)/i.exec(t);i&&(e.usedTokens=rg(i[1]),e.totalTokens=rg(i[2]),e.usedPercent=Number(i[3]));let n=null;for(const s of t.split(`
|
|
66
|
+
`)){const r=s.trim();if(!r.startsWith("|")){r&&(n=null);continue}if(iQ.test(r))continue;const o=tQ(r),a=o[0]?.toLowerCase();if(a==="category"){n="categories";continue}if(a==="tool"){n="tools";continue}n==="categories"&&o.length>=2?e.categories.push({label:o[0],tokens:rg(o[1]),percent:Number(o[2]?.replace("%",""))||0}):n==="tools"&&o.length>=3&&e.tools.push({name:o[0],server:o[1],tokens:rg(o[2])})}return e.categories.length?e:null}function rQ(t){const e=new Map;for(const i of t.tools){const n=e.get(i.server)??{tokens:0,count:0};n.tokens+=i.tokens,n.count+=1,e.set(i.server,n)}return[...e.entries()].map(([i,n])=>({server:i,...n})).sort((i,n)=>n.tokens-i.tokens)}const og=["#0a84ff","#5e5ce6","#bf5af2","#ff375f","#ff9f0a","#ffd426","#30d158","#64d2ff","#8e8e93"];function Wd(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(t>=1e4?0:1)}k`:String(t)}function oQ({report:t}){const[e,i]=w.useState(!1),n=t.categories.filter(o=>!/^free/i.test(o.label)),s=n.reduce((o,a)=>o+a.tokens,0)||1,r=rQ(t);return d.jsxs("div",{className:"ctxr",children:[d.jsxs("div",{className:"ctxr-head",children:[d.jsx("span",{className:"ctxr-total",children:d.jsx(ct,{children:t.usedTokens!==void 0&&t.totalTokens!==void 0?`${Wd(t.usedTokens)} of ${Wd(t.totalTokens)}`:"Context"})}),t.usedPercent!==void 0&&d.jsx("span",{className:"ctxr-pct",children:d.jsx(ct,{children:`${t.usedPercent}% full`})}),t.model&&d.jsx("span",{className:"ctxr-model",children:t.model})]}),d.jsx("div",{className:"ctxr-bar",role:"img","aria-label":"What is using the context",children:n.map((o,a)=>d.jsx("span",{className:"ctxr-seg",style:{width:`${o.tokens/s*100}%`,background:og[a%og.length]},title:`${o.label}: ${Wd(o.tokens)}`},o.label))}),d.jsx("ul",{className:"ctxr-legend",children:n.map((o,a)=>d.jsxs("li",{children:[d.jsx("span",{className:"ctxr-dot",style:{background:og[a%og.length]}}),d.jsx("span",{className:"ctxr-label",children:o.label}),d.jsx("span",{className:"ctxr-tokens",children:d.jsx(ct,{children:Wd(o.tokens)})}),d.jsx("span",{className:"ctxr-share",children:d.jsx(ct,{children:`${Math.round(o.tokens/s*100)}%`})})]},o.label))}),r.length>0&&d.jsxs("div",{className:"ctxr-servers",children:[d.jsx("button",{className:"ctxr-more",type:"button",onClick:()=>i(o=>!o),children:d.jsx(ct,{children:`${e?"Hide":"Show"} MCP servers · ${t.tools.length} tools`})}),e&&d.jsx("ul",{className:"ctxr-legend",children:r.map(o=>d.jsxs("li",{children:[d.jsx("span",{className:"ctxr-label",children:o.server}),d.jsx("span",{className:"ctxr-tokens",children:d.jsx(ct,{children:Wd(o.tokens)})}),d.jsx("span",{className:"ctxr-share",children:d.jsx(ct,{children:`${o.count} tools`})})]},o.server))})]})]})}const O4=88,gy=12,lQ=3,mA=t=>Math.max(1,Math.ceil(t.length/O4));function aQ(t,e){const i=t.slice(0,e),n=i.lastIndexOf(" ");return(n>e*.6?i.slice(0,n):i).trimEnd()}function cQ(t){const e=t.split(`
|
|
67
|
+
`);if(e.reduce((r,o)=>r+mA(o),0)<=gy+lQ)return{head:t,clipped:!1};const n=[];let s=0;for(const r of e){const o=mA(r);if(s+o>gy){n.length||n.push(aQ(r,gy*O4));break}n.push(r),s+=o}return{head:n.join(`
|
|
68
|
+
`).trimEnd(),clipped:!0}}const uQ=/^usage:\s*\/config\s+key=value/i,hQ=/^\s*([A-Za-z][A-Za-z0-9]*)=(.+)$/;function I4(t){const e=t.trim().split(`
|
|
69
|
+
`);if(!e.length||!uQ.test(e[0].trim()))return null;const i=[],n=new Set;for(const s of e.slice(1)){const r=hQ.exec(s);if(!r){if(s.trim())break;continue}const[,o,a]=r;if(n.has(o))continue;n.add(o);const u=a.trim()==="<value>"?[]:a.trim().split("|").filter(Boolean);i.push({key:o,options:u})}return i.length?i:null}const dQ=/^set\s+(.+?)\s+to\s+(.+?)\.?$/i;function fQ(t,e){const i=dQ.exec(t.trim());if(!i)return null;const n=i[1].replace(/\s+/g,"").toLowerCase(),s=i[2].trim();let r=null;for(const o of e)n.startsWith(o.toLowerCase())&&(!r||o.length>r.length)&&(r=o);return r?{key:r,value:s}:null}const gA=new Set(["ide","pr","api","url","id","mcp","cli","ui","ai"]);function pQ(t){const e=t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(" ").map(n=>gA.has(n)?n.toUpperCase():n),i=e[0]??"";return e[0]=gA.has(i.toLowerCase())?i:i.charAt(0).toUpperCase()+i.slice(1),e.join(" ")}const mQ=[{title:"The model",keys:["model","switchModelsOnFlag","thinking","outputStyle"]},{title:"What it may do",keys:["permissionMode","useAutoModeDuringPlan","checkpoints","gitignore","worktreeBaseRef"]},{title:"Workflows",keys:["workflows","workflowKeywordTriggerEnabled","workflowSizeGuideline"]},{title:"The window",keys:["theme","language","reduceMotion","progressBar","tips","turnDuration","verbose","recap"]},{title:"Editing",keys:["editor","externalEditorContext","autoConnectIde","chrome"]},{title:"Notifications",keys:["notifChannel","prStatus"]},{title:"The conversation",keys:["autoCompact","artifacts","copyFullResponse","defaultToAgentsView","leftArrowOpensAgents"]}];function gQ(t){const e=new Map(t.map(r=>[r.key,r])),i=[],n=new Set;for(const r of mQ){const o=r.keys.map(a=>e.get(a)).filter(a=>!!a);for(const a of o)n.add(a.key);o.length&&i.push({title:r.title,rows:o})}const s=t.filter(r=>!n.has(r.key));return s.length&&i.push({title:"Everything else",rows:s}),i}const P4=w.createContext({say:()=>{},said:[]});function vQ({say:t,said:e,readOnly:i=!1,children:n}){const s=w.useMemo(()=>({say:t,said:e,readOnly:i}),[t,e,i]);return d.jsx(P4.Provider,{value:s,children:n})}function _Q(t){return I4(t)!==null}function yQ({text:t}){const e=w.useMemo(()=>I4(t),[t]),i=w.useMemo(()=>e?gQ(e):[],[e]),{say:n,said:s,readOnly:r}=w.useContext(P4),o=w.useMemo(()=>{const a=new Map,u=e?.map(h=>h.key)??[];if(!u.length)return a;for(const h of s){const p=fQ(h,u);p&&a.set(p.key,p.value)}return a},[s,e]);return e?d.jsxs("div",{className:"cfg",children:[d.jsxs("div",{className:"cfg-head",children:[d.jsx("span",{className:"cfg-title",children:"Settings"}),d.jsx("span",{className:"cfg-note",children:d.jsx(ct,{children:r?"Read-only · change settings through the main chat":`${e.length} this agent takes · picking a value sends it`})})]}),i.map(a=>d.jsxs("section",{className:"cfg-group",children:[d.jsx("h4",{className:"cfg-group-head",children:a.title}),a.rows.map(u=>d.jsx(xQ,{row:u,value:o.get(u.key),onPick:n,readOnly:r},u.key))]},a.title))]}):null}function xQ({row:t,value:e,onPick:i,readOnly:n}){return d.jsxs("div",{className:"cfg-row",children:[d.jsxs("span",{className:"cfg-key",children:[pQ(t.key),d.jsx("code",{className:"cfg-code",children:t.key})]}),t.options.length?d.jsx("span",{className:"cfg-opts",children:t.options.map(s=>d.jsx("button",{type:"button",disabled:n,className:`cfg-opt ${e===s?"is-on":""}`,"aria-pressed":e===s,title:`/config ${t.key}=${s}`,onClick:()=>i(`/config ${t.key}=${s}`),children:s},s))}):d.jsx("span",{className:"cfg-free",children:d.jsxs("code",{className:"cfg-code",children:["/config ",t.key,"=…"]})})]})}const bQ=40,wQ=4e3,ah=new Map,N0=new Set,j0=new Map,vb=new Set;let _b=null;const Pf=(t,e)=>`${e}\0${t}`;function SQ(t,e){return ah.get(Pf(t,e))}function kQ(t,e){const i=new Map;for(const n of t){const s=ah.get(Pf(n,e));s!==void 0&&i.set(n,s)}return i}function z4(t,e){let i=!1;for(const n of t){const s=Pf(n,e);if(ah.has(s)||N0.has(s))continue;N0.add(s);let r=j0.get(e);r||j0.set(e,r=new Set),r.add(n),i=!0}i&&_b===null&&(_b=setTimeout(CQ,bQ))}function $4(t){return vb.add(t),()=>{vb.delete(t)}}function CQ(){_b=null;const t=[...j0.entries()];j0.clear();for(const[e,i]of t){const n=[...i];he.invoke("resolve_paths",{paths:n,cwd:e}).then(s=>{n.forEach((r,o)=>{const a=Pf(r,e);N0.delete(a),ah.set(a,s?.[o]??null)}),ah.size>wQ&&ah.clear();for(const r of vb)r()}).catch(()=>{for(const s of n)N0.delete(Pf(s,e))})}}const EQ="600px";function MQ({path:t}){const e=ev(),i=w.useRef(null),[n,s]=w.useState(!1),[r,o]=w.useState(null),[a,u]=w.useState(!1);return w.useEffect(()=>{const h=i.current;if(!h)return;if(typeof IntersectionObserver>"u"){s(!0);return}const p=new IntersectionObserver(m=>{m.some(v=>v.isIntersecting)&&(s(!0),p.disconnect())},{rootMargin:EQ});return p.observe(h),()=>p.disconnect()},[]),w.useEffect(()=>{if(!n)return;let h=!0,p=null;return he.fetchFile(t).then(m=>{h&&(p=URL.createObjectURL(m),o(p))}).catch(()=>h&&u(!0)),()=>{h=!1,p&&URL.revokeObjectURL(p)}},[n,t]),a?null:d.jsx("span",{className:"prose-shot",ref:i,children:r?d.jsx("button",{className:"prose-shot-btn",type:"button",title:`${Vi(t)} — click to see it full size`,onClick:()=>e(t),children:d.jsx("img",{src:r,alt:Vi(t)})}):d.jsx("span",{className:"prose-shot-wait","aria-hidden":"true"})})}const F4=w.createContext(""),AQ=F4.Provider;function LQ({path:t,code:e,children:i}){const n=w.useContext(F4),s=()=>t?SQ(t,n):void 0,r=w.useSyncExternalStore($4,s,s);if(w.useEffect(()=>{t&&z4([t],n)},[t,n]),!t||!r)return e?d.jsx("code",{children:i}):d.jsx(d.Fragment,{children:i});const o=rS(r),a=d.jsx(zj,{path:r,code:!!e,children:o?Vi(r):i});return o?d.jsxs(d.Fragment,{children:[a,d.jsx(MQ,{path:r})]}):a}const H4="octiq-path",TQ=String.raw`\/?(?:~|\.{1,2}|[\w.@+-]+)(?:\/[\w.@+-]+)+`,W4=String.raw`[\w][\w@+-]*\.[A-Za-z]\w{0,7}`,pv=String.raw`(?::\d+(?::\d+)?)?`,vA=new RegExp(`(?:${TQ}|${W4})${pv}`,"g"),NQ=new RegExp(`${pv}$`),jQ=new RegExp(`^${W4}${pv}$`),RQ=new RegExp(String.raw`[^/]\.[A-Za-z]\w{0,7}${pv}$`),DQ=/[.,;:!?]+$/;function q4(t){const e=[],i=(r,o)=>{if(!r)return;const a=e[e.length-1];!o&&a&&!a.path?a.text+=r:e.push(o?{text:r,path:o}:{text:r})};let n=0;vA.lastIndex=0;let s;for(;s=vA.exec(t);){const r=s[0].replace(DQ,""),o=r.includes("/")?RQ.test(r):jQ.test(r);!r||s.index<n||!o||(i(t.slice(n,s.index)),i(r,r.replace(NQ,"")),n=s.index+r.length)}return i(t.slice(n)),e.length?e:[{text:t}]}function U4(t,e,i){return{type:"element",tagName:H4,properties:i?{path:e,code:"1"}:{path:e},children:[{type:"text",value:t}]}}function BQ(t){const e=q4(t);return e.length===1&&!e[0].path?[{type:"text",value:t}]:e.map(i=>i.path?U4(i.text,i.path):{type:"text",value:i.text})}function OQ(t){const e=t.children?.length===1?t.children[0]:null;if(!e||e.type!=="text"||!e.value)return t;const i=e.value.trim(),n=q4(i);return n.length!==1||!n[0].path?t:U4(i,n[0].path,!0)}function V4(t){if(!t.children?.length||t.tagName==="pre"||t.tagName==="a")return;const e=[];for(const i of t.children){if(i.type==="text"&&i.value){e.push(...BQ(i.value));continue}if(i.tagName==="code"){e.push(OQ(i));continue}V4(i),e.push(i)}t.children=e}function _A(){return t=>V4(t)}const IQ=8;function K4(t){return t.name||t.id}function PQ(t){const e=new Map;for(const i of t){if(!i.speaker)continue;const n=K4(i.speaker);e.has(n)||e.set(n,e.size%IQ)}return e}function yA(t){const e=t.flatMap(i=>i.blocks).filter(i=>i.kind==="text").map(i=>i.text).join(" ").replace(/\s+/g," ").trim();return e?e.length>260?`${e.slice(0,257).trimEnd()}…`:e:""}function zQ(t){return t.flatMap((e,i)=>{if(e[0]?.role!=="user")return[];const n=t.slice(i+1).find(s=>s[0]?.role==="assistant");return[{id:e[0].id,prompt:yA(e)||"Message",reply:n?yA(n):""}]})}function $Q(t,e){return t.reduce((i,n)=>!i||Math.abs(n.offset-e)<Math.abs(i.offset-e)?n:i,void 0)}function FQ(t,e){return e<=1?0:t/e}const xA=3;function HQ(t){if(t===null)return 12;const n=Math.abs(t);return n>=xA?12:Math.round(12+20*.5*(1+Math.cos(Math.PI*n/xA)))}function WQ({turns:t,scrollerRef:e,innerRef:i,onJump:n}){const[s,r]=w.useState([]),[o,a]=w.useState(0),[u,h]=w.useState(null),p=w.useRef(0);w.useEffect(()=>{const k=e.current,M=i.current;if(!k||!M)return;const L=()=>{const R=k.getBoundingClientRect(),z=new Map([...k.querySelectorAll("[data-map-turn]")].map(G=>[G.dataset.mapTurn,G])),J=t.flatMap(G=>{const q=z.get(G.id);if(!q)return[];const X=k.scrollTop+q.getBoundingClientRect().top-R.top;return[{...G,offset:X}]});r(J.map((G,q)=>({...G,rank:FQ(q,J.length)}))),a(k.scrollTop+k.clientHeight/2)},N=()=>{cancelAnimationFrame(p.current),p.current=requestAnimationFrame(L)};L();const j=typeof ResizeObserver>"u"?void 0:new ResizeObserver(N);return j?.observe(k),j?.observe(M),window.addEventListener("resize",N),()=>{cancelAnimationFrame(p.current),j?.disconnect(),window.removeEventListener("resize",N)}},[i,e,t]),w.useEffect(()=>{const k=e.current;if(!k)return;const M=()=>{cancelAnimationFrame(p.current),p.current=requestAnimationFrame(()=>a(k.scrollTop+k.clientHeight/2))};return k.addEventListener("scroll",M,{passive:!0}),()=>{cancelAnimationFrame(p.current),k.removeEventListener("scroll",M)}},[e]);const m=w.useMemo(()=>s.find(k=>k.id===u),[u,s]),v=w.useMemo(()=>u===null?-1:s.findIndex(k=>k.id===u),[u,s]),_=w.useMemo(()=>$Q(s,o),[o,s]),x=Math.min(360,Math.max(5,s.length*5)),S=x/Math.max(s.length,1);if(t.length===0)return null;const C=k=>{const M=e.current;if(!M)return;n?.();const L=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;M.scrollTo({top:Math.max(0,k.offset-M.clientHeight*.2),behavior:L?"auto":"smooth"})};return d.jsx("aside",{className:"conversation-map","aria-label":"Conversation map",children:d.jsxs("div",{className:"conversation-map-body",style:{height:`${x}px`},children:[d.jsx("div",{className:"conversation-map-points",children:s.map((k,M)=>d.jsx("button",{className:`conversation-map-point ${_?.id===k.id?"is-current":""}`,type:"button",style:{top:`${k.rank*x}px`,height:`${S}px`,width:`${HQ(v<0?null:M-v)}px`},"aria-label":`Jump to message: ${k.prompt}`,"aria-current":_?.id===k.id?"location":void 0,onPointerEnter:()=>h(k.id),onPointerLeave:()=>h(null),onFocus:()=>h(k.id),onBlur:()=>h(null),onClick:()=>C(k)},k.id))}),m&&d.jsxs("div",{className:"conversation-map-preview","aria-hidden":"true",style:{top:`${m.rank*x+S/2-54}px`},children:[d.jsx("div",{className:"conversation-map-preview-title",children:m.prompt}),m.reply&&d.jsx("div",{className:"conversation-map-preview-body",children:m.reply})]})]})})}function qQ({user:t,message:e,onStart:i,onCancel:n,onRestore:s,onDismiss:r,footer:o,children:a}){const u=d.jsx("div",{className:"msg-body",children:a});if(!t)return u;const h=!!(e.echo||e.takenUp),p=h?"dispatched":e.queueLost?"failed":e.delivery,m=!!e.queueAction,v=e.queueAction==="cancel"?"Returning to composer…":e.queueAction==="start"||p==="starting"?"Sending next…":h?"Sent":p==="queued"?"Queued":p==="sending"?"Sending…":p==="dispatched"?"Awaiting agent confirmation":p==="failed"?"Not sent":e.turnId?"Delivery unconfirmed":void 0,_=p==="queued"?"Runs after the current reply. Send now stops that reply.":p==="dispatched"&&!h?"The message was handed off, but the agent has not confirmed receipt yet.":p==="failed"?"This message is no longer waiting. Restore it to edit or send again.":p==="unknown"?"Delivery could not be confirmed. Check the conversation before sending again.":void 0;return d.jsxs("div",{className:"message-bubble","data-noswipe":i||n||s||r?"":void 0,children:[u,(v||o)&&d.jsxs("div",{className:"message-delivery","data-delivery":p,"aria-busy":m,children:[d.jsx("span",{className:"message-delivery-status",role:"status",title:_,children:v}),d.jsxs("div",{className:"message-delivery-actions",role:"group","aria-label":"Message actions",children:[i&&d.jsx("button",{type:"button",disabled:m,title:"Stop the current reply and send this message next","aria-label":"Send this queued message now",onClick:i,children:"Send now"}),n&&d.jsx("button",{type:"button",disabled:m,title:"Return this message and its attachments to the composer","aria-label":"Take this queued message back to edit",onClick:n,children:"Edit"}),s&&d.jsx("button",{type:"button",onClick:s,children:"Restore to composer"}),r&&d.jsx("button",{type:"button",onClick:r,children:"Dismiss"}),o]})]}),_&&!h&&p!=="dispatched"&&d.jsx("p",{className:"message-delivery-detail",children:_}),e.queueError&&d.jsx("p",{className:"message-delivery-error",role:"alert",children:e.queueError})]})}const Y4=12;function UQ(t,e){const i=e?t.findIndex(s=>s.some(r=>r.id===e)):-1,n=i>=0?Math.max(0,i-1):Math.max(0,t.length-Y4);return t[n]?.[0].id??null}function VQ(t,e){return e===null?0:Math.max(0,t.findIndex(i=>i[0].id===e))}const bA="visualize",wA="";function KQ(t){const e=t.trim();if(!e.startsWith(bA)||!e.endsWith(wA))return null;try{const i=JSON.parse(e.slice(bA.length,-wA.length));return typeof i.path!="string"||!i.path.startsWith("/")||i.mode!==void 0&&i.mode!=="wide"||i.title!==void 0&&typeof i.title!="string"?null:{path:i.path,...i.mode==="wide"?{mode:"wide"}:{},...typeof i.title=="string"?{title:i.title}:{}}}catch{return null}}function YQ({reference:t}){const e=t.title||Vi(t.path);return d.jsxs("button",{className:"visualization-link",type:"button",title:t.path,onClick:()=>he.openFileInBrowser(t.path),children:[d.jsx("span",{"aria-hidden":"true",children:"↗"}),d.jsx("span",{children:e})]})}function GQ({children:t}){const[e,i]=w.useState(!1),n=w.useRef(null),s=t,r=/language-(\w+)/.exec(s?.props?.className??"")?.[1]??"";return d.jsxs("div",{className:"code",children:[d.jsxs("div",{className:"code-head",children:[d.jsx("span",{className:"code-lang",children:r||"text"}),d.jsx("button",{className:"code-copy",type:"button",onClick:async()=>{await Yf(n.current?.innerText??"")&&(i(!0),setTimeout(()=>i(!1),1400))},children:e?"copied":"copy"})]}),d.jsx("pre",{ref:n,children:t})]})}function wh({text:t,animate:e}){const i=QG(t,e),n=w.useMemo(()=>e?null:sQ(t),[t,e]);if(n)return d.jsx(oQ,{report:n});const s=e&&i.length<t.length,r=w.useMemo(()=>XG(i),[i]);return d.jsx("div",{className:`prose ${s?"is-typing":""}`,children:r.map((o,a)=>d.jsx(ZQ,{text:o,animate:e&&a===r.length-1},a))})}function QQ({updates:t,candidate:e,streaming:i}){const n=[...t,...e?[e]:[]];if(!n.length)return null;const s=i?n.at(-1):void 0,r=s?n.slice(0,-1):n,o=`${r.length} ${s?"earlier ":""}progress ${r.length===1?"update":"updates"}`;return d.jsxs("div",{className:`agent-progress ${i?"is-live":"is-settled"}`,children:[r.length>0&&d.jsxs("details",{className:"agent-progress-log",children:[d.jsxs("summary",{children:[d.jsx("span",{children:o}),d.jsx("span",{className:"agent-progress-order",children:"Oldest first"})]}),d.jsx("div",{className:"agent-progress-items",role:"region","aria-label":"Progress history, oldest first",tabIndex:0,children:d.jsx("ol",{className:"agent-progress-list",children:r.map((a,u)=>d.jsx("li",{className:"agent-progress-item",children:d.jsx(wh,{text:a,animate:!1})},`${u}:${a.slice(0,24)}`))})})]}),s&&d.jsxs("div",{className:"agent-progress-live",role:"status","aria-live":"polite",children:[d.jsx("span",{className:"agent-progress-pulse","aria-hidden":"true"}),d.jsxs("div",{className:"agent-progress-live-copy",children:[d.jsx("span",{className:"agent-progress-live-label",children:"Latest update"}),d.jsx(wh,{text:s,animate:!1})]})]})]})}const XQ={pre:GQ,table:A4,a:sS,[H4]:LQ},ZQ=w.memo(function({text:e,animate:i}){const n=KQ(e);return n?d.jsx(YQ,{reference:n}):d.jsx(Gw,{remarkPlugins:[Jw],rehypePlugins:i?[_A,eQ]:[_A],components:XQ,children:ZG(e)})});function JQ({block:t,animate:e,kids:i,agentByTool:n,onOpenAgent:s,note:r,folder:o}){if(t.kind==="text"&&_Q(t.text))return d.jsx(yQ,{text:t.text});if(t.kind==="text")return d.jsx(wh,{text:t.text,animate:!!e});if(t.kind==="compacted")return d.jsx(nX,{block:t});if(t.kind==="notice")return d.jsx(iX,{text:t.text});if(t.kind==="thinking")return null;const a=n?.get(t.id),u=i.get(t.id);return d.jsx($j,{tool:t,note:r,folder:o,agent:u?.length?{steps:u.length,body:d.jsx(Q4,{messages:u,kids:i,agentByTool:n,onOpenAgent:s})}:void 0,onOpenAgent:a&&s?()=>s(a):void 0})}function G4({blocks:t,streaming:e,kids:i,agentByTool:n,onOpenAgent:s}){const r=JH(),o=w.useMemo(()=>w8(t,h=>i.has(h.id)||r.has(h.id)),[t,i,r]),a=w.useMemo(()=>UH(o),[o]),u=t.length-1;return d.jsx(d.Fragment,{children:o.map((h,p)=>{const m=a[p],v=!!m&&m!==a[p-1],_=h.kind==="group"?h.tools[0]?.id??h.newest.id:h.index;return d.jsxs(w.Fragment,{children:[v&&d.jsx(eX,{dir:m}),h.kind==="group"?d.jsx(cW,{tools:h.tools,newest:h.newest,folder:m,note:h.note}):d.jsx(JQ,{block:h.block,animate:e&&h.index===u,kids:i,agentByTool:n,onOpenAgent:s,note:h.note,folder:m})]},_)})})}function eX({dir:t}){return d.jsxs("div",{className:"folder-head",title:t,children:[d.jsx(tX,{}),d.jsx("span",{className:"folder-head-name",children:VH(t)})]})}function tX(){return d.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"})})}function Q4({messages:t,kids:e,agentByTool:i,onOpenAgent:n}){const s=t.flatMap(o=>o.blocks),r=t.some(o=>o.streaming);return d.jsxs("div",{className:"subagent",children:[d.jsx(G4,{blocks:s,streaming:r,kids:e,agentByTool:i,onOpenAgent:n}),r&&s.length===0&&d.jsx("div",{className:"dots","aria-label":"working"})]})}function iX({text:t}){return d.jsx("div",{className:"cli-note",children:t})}function nX({block:t}){const[e,i]=w.useState(!1),n=!!t.text.trim(),s=[t.trigger==="manual"?"you asked":t.trigger?"context filled up":"",t.preTokens&&t.postTokens?`${my(t.preTokens)} → ${my(t.postTokens)} tokens`:t.preTokens?`${my(t.preTokens)} tokens summarised`:"",t.durationMs?`${Math.max(1,Math.round(t.durationMs/1e3))}s`:""].filter(Boolean);return d.jsxs("div",{className:`compacted ${e?"is-open":""}`,children:[d.jsx(X4,{children:n?d.jsxs("button",{type:"button",className:"compacted-label is-button","aria-expanded":e,onClick:()=>i(!e),children:[d.jsx(oX,{open:e}),"history summarised to make room",s.length>0&&d.jsx("span",{className:"compacted-facts",children:d.jsx(ct,{children:s.join(" · ")})})]}):d.jsxs("span",{className:"compacted-label",children:["history summarised to make room",s.length>0&&d.jsx("span",{className:"compacted-facts",children:d.jsx(ct,{children:s.join(" · ")})})]})}),e&&n&&d.jsx("div",{className:"compacted-body",children:d.jsx(wh,{text:t.text,animate:!1})})]})}function X4({children:t,running:e}){const i=`compacted-line ${e?"is-running":""}`;return d.jsxs("div",{className:"compacted-bar",children:[d.jsx("span",{className:i,"aria-hidden":"true",children:e&&d.jsx(sX,{})}),t,d.jsx("span",{className:i,"aria-hidden":"true"})]})}function sX(){return d.jsx("span",{className:"compacting-truck","aria-hidden":"true",children:d.jsxs("svg",{className:"compacting-truck-art",viewBox:"0 0 32 16",width:"28",height:"14",children:[d.jsxs("g",{className:"compacting-truck-load",fill:"currentColor",children:[d.jsx("rect",{x:"1.8",y:"4.6",width:"7.2",height:"5.8",rx:"0.7",opacity:"0.62"}),d.jsx("rect",{x:"9.6",y:"6.6",width:"6",height:"3.8",rx:"0.6",opacity:"0.85"})]}),d.jsx("rect",{x:"0.8",y:"10.4",width:"15.8",height:"1.5",rx:"0.5",fill:"currentColor"}),d.jsx("path",{d:"M16.2 11.9V6.2h5l4.4 4v1.7z",fill:"currentColor"}),d.jsx("path",{d:"M20.2 7.4h.9l2.9 2.6h-3.8z",fill:"var(--bg-1)"}),d.jsx("circle",{cx:"6.4",cy:"13.2",r:"1.8",fill:"currentColor"}),d.jsx("circle",{cx:"21.4",cy:"13.2",r:"1.8",fill:"currentColor"}),d.jsx("circle",{cx:"6.4",cy:"13.2",r:"0.65",fill:"var(--bg-1)"}),d.jsx("circle",{cx:"21.4",cy:"13.2",r:"0.65",fill:"var(--bg-1)"})]})})}function rX({since:t}){const[,e]=w.useState(0);w.useEffect(()=>{const n=setInterval(()=>e(s=>s+1),1e3);return()=>clearInterval(n)},[]);const i=Math.max(0,Math.round((Date.now()-t)/1e3));return d.jsx("div",{className:"compacted is-running",role:"status",children:d.jsx(X4,{running:!0,children:d.jsxs("span",{className:"compacted-label",children:["summarising history to make room",d.jsx("span",{className:"compacted-facts",children:d.jsx(ct,{children:`${i}s`})})]})})})}function oX({open:t}){return d.jsx("svg",{className:`compacted-chev ${t?"is-open":""}`,width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"m9 6 6 6-6 6"})})}function lX({text:t}){const[e,i]=w.useState(!1),{head:n,clipped:s}=w.useMemo(()=>cQ(t),[t]);return s?d.jsxs("div",{className:`clip ${e?"is-open":"is-cut"}`,children:[d.jsx(wh,{text:e?t:n,animate:!1}),d.jsx("button",{className:"clip-more",type:"button","aria-expanded":e,onClick:()=>i(!e),children:e?"show less":"show more"})]}):d.jsx(wh,{text:t,animate:!1})}function aX(){return d.jsxs("div",{className:"stopmark",role:"separator",children:[d.jsx("span",{className:"stopmark-rule","aria-hidden":"true"}),d.jsxs("span",{className:"stopmark-label",children:[d.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:d.jsx("rect",{x:"5",y:"5",width:"14",height:"14",rx:"3"})}),"You stopped this"]}),d.jsx("span",{className:"stopmark-rule","aria-hidden":"true"})]})}function cX({messages:t,kids:e,agentByTool:i,onOpenAgent:n,last:s,busy:r,tints:o,fresh:a,mapTurnId:u,hostName:h,onCancelQueued:p,onStartQueued:m,onRestoreUnsent:v,onDismissUnsent:_}){const x=t[0].role,S=t[0].speaker,C=t[0].to,k=t[0].relay,M=t[0].ranSkill,L=t.find(V=>V.replyTo)?.replyTo,N=t.some(V=>V.streaming),j=t.flatMap(V=>V.blocks),R=t.flatMap(V=>V.progress??[]),z=[...t].reverse().find(V=>V.codexCandidate)?.codexCandidate,J=j.filter(V=>V.kind==="text").map(V=>V.text).join(`
|
|
70
|
+
|
|
71
|
+
`).trim(),G=t[0],q=x==="user"&&t.some(V=>V.queueLost&&!V.echo&&!V.takenUp),X=x==="user"&&!q&&!G.echo&&!G.takenUp&&G.delivery==="queued",I=X?G.turnId:void 0,T=p&&I?()=>p(I):void 0,H=m&&I?()=>m(I):void 0,F=j.length>0&&j.every(V=>V.kind==="compacted"||V.kind==="notice"),P=w.useMemo(()=>{const V=new Map;for(const K of t)for(const D of K.attachments??[])V.set(D.path,D);return[...V.values()]},[t]);if(k)return d.jsxs("article",{className:"msg msg-relay",children:[d.jsx("span",{"aria-hidden":"true",children:"↳"})," ",k]});const U=S?o?.get(K4(S)):void 0;return d.jsxs("article",{className:`msg msg-${x} ${S?"msg-seat":""} ${X?"is-queued":""} ${a?"is-new":""}`,"data-tint":U,"data-map-turn":u,children:[x==="user"&&C&&d.jsxs("div",{className:"msg-to",children:["to ",C.name]}),x==="user"&&M&&d.jsx("div",{className:"msg-ran",title:"The skill this command resolved to",children:M}),x==="assistant"&&!F&&d.jsx("div",{className:"msg-role",children:S?d.jsxs(d.Fragment,{children:[d.jsx(o0,{agent:S.agent==="claude"?"claude":"codex",size:13}),S.name]}):h??"Claude"}),x==="assistant"&&L&&d.jsxs("div",{className:"msg-reply",title:`Replying to: ${L.preview}`,children:[d.jsx("span",{className:"msg-reply-label",children:"Replying to"}),d.jsx("span",{className:"msg-reply-preview",children:L.preview})]}),d.jsxs(qQ,{user:x==="user",message:G,onStart:H,onCancel:T,onRestore:(q||G.delivery==="unknown")&&!G.echo&&!G.takenUp&&v&&G.turnId?()=>v(G.turnId):void 0,onDismiss:q&&_&&G.turnId?()=>_(G.turnId):void 0,footer:x==="user"&&J?d.jsx(SA,{text:J,what:"message"}):void 0,children:[d.jsx(WG,{files:P}),x==="assistant"&&d.jsx(QQ,{updates:R,candidate:z,streaming:N}),x==="user"&&j.every(V=>V.kind==="text")?j.map((V,K)=>d.jsx(lX,{text:V.text},K)):d.jsx(G4,{blocks:j,streaming:N,kids:e,agentByTool:i,onOpenAgent:n}),N&&j.length===0&&d.jsx("div",{className:"dots","aria-label":"working"}),x==="assistant"&&!N&&!(r&&s)&&J&&d.jsx("div",{className:"msg-foot",children:d.jsx(SA,{text:J,what:"reply"})})]})]})}function SA({text:t,what:e}){const[i,n]=w.useState("idle");return d.jsx("div",{className:"msg-actions",children:d.jsxs("button",{className:`msg-copy ${i==="done"?"is-done":""}`,type:"button",title:`Copy this ${e}`,onClick:async()=>{const s=await Yf(t);n(s?"done":"failed"),setTimeout(()=>n("idle"),1600)},children:[i==="done"?d.jsx(hX,{}):d.jsx(uX,{}),i==="done"?"copied":i==="failed"?"could not copy":"copy"]})})}function uX(){return d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("rect",{x:"9",y:"9",width:"12",height:"12",rx:"2"}),d.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function hX(){return d.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"m20 6-11 11-5-5"})})}function dX(t){const e=[];for(const i of t){const n=e[e.length-1],s=i.role==="user"&&n?.[0].role==="user",r=i.replyTo?.id!==n?.[0].replyTo?.id&&(!!i.replyTo||!!n?.[0].replyTo);!(!!i.relay||!!n?.[0].relay||s||r)&&n&&n[0].role===i.role&&n[0].speaker?.id===i.speaker?.id?n.push(i):e.push([i])}return e}function fX(t){const e=w.useRef(null),i=w.useRef(new Set),n=w.useRef(0),s=t.map(a=>a[0].id),r=e.current;e.current=s;const o=pX(r,s);return o&&(i.current.add(o),n.current++),{fresh:i.current,nth:n.current}}function pX(t,e){if(!t||e.length!==t.length+1)return null;for(let i=0;i<t.length;i++)if(t[i]!==e[i])return null;return e[e.length-1]}const mX=280,gX=t=>1-Math.pow(1-t,5);function vX(t,e,i){const n=i<0?0:i>1?1:i;return t+(e-t)*gX(n)}const _X=8;function yX(){return typeof window>"u"?!1:!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}const qd=80;function xX(t){return!!t?.closest?.(".jump")}const bX=400,kA=6e3;function Ud(t){const e=t.getBoundingClientRect(),i=[];for(const n of t.querySelectorAll("[data-map-turn]")){const s=n.dataset.mapTurn;s&&i.push({id:s,offset:t.scrollTop+n.getBoundingClientRect().top-e.top})}return i}const wX=function({messages:e,busy:i,stoppedAt:n,compactingSince:s,conversationId:r,onSetting:o,agentByTool:a,onOpenAgent:u,hostName:h,onCancelQueued:p,onStartQueued:m,onRestoreUnsent:v,onDismissUnsent:_,hasEarlier:x=!1,loadingEarlier:S=!1,earlierError:C,onLoadEarlier:k}){const M=w.useRef(null),L=w.useRef(null),N=w.useRef(null),j=w.useRef(()=>{}),R=w.useRef(!1),z=w.useRef(null),J=w.useRef(!0),G=w.useRef(!1),[q,X]=w.useState(!1),I=w.useRef(0),T=w.useRef(r),H=w.useRef(null),F=w.useRef(0),P=w.useRef(null),U=()=>{I.current&&cancelAnimationFrame(I.current),I.current=0},V=()=>{window.clearTimeout(F.current),F.current=0;const be=H.current;H.current=null,be&&(be.at?RI(be.id,be.at):bN(be.id))},K=()=>{const be=L.current,We=T.current;if(!be||!We||I.current||P.current)return;const Ze=be.scrollHeight-be.scrollTop-be.clientHeight<qd;!Ze&&J.current||(H.current={id:We,at:Ze?null:j5(be.scrollTop,Ud(be))},window.clearTimeout(F.current),F.current=window.setTimeout(V,bX))},D=()=>{const be=L.current;if(!be)return;U();const We=be.scrollHeight-be.clientHeight,Ze=Math.max(be.clientHeight*1.5,400),ve=Math.max(be.scrollTop,We-Ze);if(We-ve<_X||yX()){be.scrollTop=be.scrollHeight;return}ve!==be.scrollTop&&(be.scrollTop=ve);const fi=performance.now(),Mt=be.closest(".focus-mode")?440:mX,Kt=gn=>{const de=(gn-fi)/Mt;if(be.scrollTop=vX(ve,be.scrollHeight-be.clientHeight,de),de<1){I.current=requestAnimationFrame(Kt);return}I.current=0,J.current&&(be.scrollTop=be.scrollHeight)};I.current=requestAnimationFrame(Kt)},$=()=>{J.current=!0,X(!1),P.current=null,T.current&&(H.current={id:T.current,at:null}),V(),D()};w.useEffect(()=>{const be=L.current;if(!be)return;let We=0;const Ze=Mt=>{xX(Mt?.target??null)||(G.current=!0,U(),P.current=null,window.clearTimeout(We),We=window.setTimeout(()=>G.current=!1,400))},ve=()=>{if(!G.current){K();return}Ze();const Mt=be.scrollHeight-be.scrollTop-be.clientHeight<qd;J.current=Mt,X(!Mt),K(),be.scrollTop<160&&j.current()},fi=()=>V();return be.addEventListener("scroll",ve,{passive:!0}),window.addEventListener("pagehide",fi),be.addEventListener("wheel",Ze,{passive:!0}),be.addEventListener("touchstart",Ze,{passive:!0}),be.addEventListener("touchmove",Ze,{passive:!0}),be.addEventListener("pointerdown",Ze,{passive:!0}),be.addEventListener("keydown",Ze),()=>{window.clearTimeout(We),U(),V(),window.removeEventListener("pagehide",fi),be.removeEventListener("scroll",ve),be.removeEventListener("wheel",Ze),be.removeEventListener("touchstart",Ze),be.removeEventListener("touchmove",Ze),be.removeEventListener("pointerdown",Ze),be.removeEventListener("keydown",Ze)}},[]),w.useLayoutEffect(()=>{const be=L.current;if(V(),T.current=r,!be)return;G.current=!1,U();const We=r?N5(r):void 0;if(!We){J.current=!0,X(!1),P.current=null,be.scrollTop=be.scrollHeight;return}J.current=!1,P.current={at:We,until:performance.now()+kA},be.scrollTop=E1(We,Ud(be),be.scrollHeight-be.clientHeight),X(be.scrollHeight-be.scrollTop-be.clientHeight>=qd)},[r]),w.useEffect(()=>{const be=L.current,We=N.current;if(!be||!We||typeof ResizeObserver>"u")return;const Ze=new ResizeObserver(()=>{if(J.current&&!I.current){be.scrollTop=be.scrollHeight;return}const ve=P.current;ve&&(performance.now()>ve.until?P.current=null:be.scrollTop=E1(ve.at,Ud(be),be.scrollHeight-be.clientHeight)),I.current||X(be.scrollHeight-be.scrollTop-be.clientHeight>=qd)});return Ze.observe(We),()=>Ze.disconnect()},[]);const{turns:Y,kids:B}=w.useMemo(()=>{const be=new Map,We=[];for(const Ze of e){if(!Ze.parent){We.push(Ze);continue}const ve=be.get(Ze.parent);ve?ve.push(Ze):be.set(Ze.parent,[Ze])}return{turns:dX(We),kids:be}},[e]),ee=()=>({id:r,ready:Y.length>0,first:UQ(Y,r?N5(r)?.turn:void 0)});let[ie,re]=w.useState(ee);(ie.id!==r||!ie.ready&&Y.length>0)&&(ie=ee(),re(ie),z.current=null);const ge=VQ(Y,ie.first),Ee=w.useMemo(()=>Y.slice(ge),[Y,ge]),fe=ge>0||x,Pe=async()=>{if(!fe||S||R.current)return;const be=L.current;if(!be)return;const We=r,Ze=Ud(be);let ve=j5(be.scrollTop,Ze);if(!ve.turn&&Ze[0]&&(ve={top:be.scrollTop,turn:Ze[0].id,delta:be.scrollTop-Ze[0].offset}),z.current={id:We,first:Ee[0]?.[0].id,at:ve},U(),J.current=!1,ge>0){re({id:We,ready:!0,first:Y[Math.max(0,ge-Y4)][0].id});return}R.current=!0;try{await k?.(),T.current===We&&re({id:We,ready:!0,first:null})}finally{R.current=!1}};j.current=()=>{C||Pe()},w.useLayoutEffect(()=>{const be=z.current,We=L.current;!be||be.id!==r||!We||be.first===Ee[0]?.[0].id||(z.current=null,We.scrollTop=E1(be.at,Ud(We),We.scrollHeight-We.clientHeight),P.current={at:be.at,until:performance.now()+kA},X(We.scrollHeight-We.scrollTop-We.clientHeight>=qd))},[Ee,r]);const De=w.useMemo(()=>PQ(e),[e]),{fresh:He,nth:_e}=fX(Y),Le=w.useMemo(()=>zQ(Ee),[Ee]),jt=()=>{U(),P.current=null,J.current=!1,X(!0)};w.useLayoutEffect(()=>{_e&&J.current&&D()},[_e]);const di=w.useMemo(()=>{const be=[];for(const We of e.slice(-40))if(We.role==="assistant")for(const Ze of We.blocks){if(Ze.kind!=="text")continue;const ve=Ze.text.trim();ve&&ve.length<=120&&be.push(ve)}return be},[e]),xt=w.useMemo(()=>({say:o??(()=>{}),said:di}),[o,di]);return d.jsxs("div",{className:"msgs",ref:L,children:[d.jsx(WQ,{turns:Le,scrollerRef:L,innerRef:N,onJump:jt}),d.jsxs(vQ,{say:xt.say,said:xt.said,readOnly:!o,children:[d.jsxs("div",{className:"msgs-inner",ref:N,children:[fe&&d.jsxs("div",{className:"history-more",children:[d.jsx("button",{type:"button",disabled:S,onClick:()=>{Pe()},children:S?"Loading earlier messages…":"Load earlier messages"}),C&&d.jsx("span",{role:"alert",children:"Could not load earlier messages. Try again."})]}),Ee.map((be,We)=>d.jsxs(w.Fragment,{children:[d.jsx(cX,{messages:be,kids:B,agentByTool:a,onOpenAgent:u,last:We===Ee.length-1,busy:i,tints:De,fresh:He.has(be[0].id),mapTurnId:be[0].role==="user"?be[0].id:void 0,hostName:h,onCancelQueued:p,onStartQueued:m,onRestoreUnsent:v,onDismissUnsent:_}),!!n&&be.some(Ze=>Ze.id===n)&&d.jsx(aX,{})]},be[0].id)),s!==void 0&&d.jsx(rX,{since:s}),d.jsx("div",{ref:M})]}),d.jsx("div",{className:"jump-slot","aria-hidden":!q,children:d.jsx("button",{type:"button",className:`jump ${q?"is-on":""}`,onClick:$,tabIndex:q?0:-1,title:"Jump to the end","aria-label":"Jump to the end",children:d.jsx(kX,{})})})]})]})},SX=w.memo(wX);function kX(){return d.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"m6 9 6 6 6-6"})})}function CX({messages:t,parent:e}){const i=new Map;for(const s of t){if(!s.parent)continue;const r=i.get(s.parent);r?r.push(s):i.set(s.parent,[s])}const n=i.get(e);return n?.length?d.jsx(Q4,{messages:n,kids:i}):null}function EX(t){const[e,i]=w.useState({loading:!1});return w.useEffect(()=>{if(!t){i({loading:!1});return}let n=!0;return i({loading:!0}),he.invoke("read_file_preview",{path:t}).then(s=>{if(n){if(s.kind!=="text"){i({loading:!1,error:`the run's output is ${s.kind}, not text`});return}i({loading:!1,text:s.content,truncated:s.truncated})}}).catch(s=>{n&&i({loading:!1,error:s instanceof Error?s.message:String(s)})}),()=>{n=!1}},[t]),e}function MX({label:t,value:e,rolling:i=!1}){return d.jsxs("div",{className:"focus-stat",children:[d.jsx("span",{className:"focus-stat-label",children:t}),d.jsx("span",{className:"focus-stat-value",children:i?d.jsx(ct,{children:e}):e})]})}function AX({run:t}){const e=EX(t.outputFile),i=t.workers??[];return d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"focus-note",children:"A workflow's agents run in their own processes, so their working is not on this conversation's stream. What they reported is below."}),i.length>0&&d.jsx("ul",{className:"focus-workers",children:i.map(n=>d.jsxs("li",{className:`focus-worker ${n.state==="done"?"is-done":"is-running"}`,children:[d.jsxs("div",{className:"focus-worker-head",children:[d.jsx("span",{className:"focus-worker-label",children:n.label||`agent ${n.index}`}),n.tokens!==void 0&&d.jsx("span",{className:"focus-worker-cost",children:d.jsx(ct,{children:`${n.tokens.toLocaleString()} tok`})})]}),n.resultPreview&&d.jsx("div",{className:"focus-worker-result",children:n.resultPreview})]},n.id))}),d.jsx("h4",{className:"focus-heading",children:"Result"}),e.loading&&d.jsx("div",{className:"focus-muted",children:"reading the run's output…"}),e.error&&d.jsxs("div",{className:"focus-muted",children:["could not read the output file — ",e.error]}),e.text!==void 0&&d.jsxs(d.Fragment,{children:[d.jsx("pre",{className:"focus-output",children:e.text}),e.truncated&&d.jsx("div",{className:"focus-muted",children:"…output truncated"})]}),!t.outputFile&&!e.loading&&d.jsx("div",{className:"focus-muted",children:t.summary??"this run wrote no output file"})]})}function LX({run:t,messages:e}){const i=t.toolUseId?d.jsx(CX,{messages:e,parent:t.toolUseId}):null;return i||d.jsxs("div",{className:"focus-muted",children:[t.status==="running"?"this agent has not written anything yet":"this agent sent no transcript — only its result came back",t.summary&&d.jsx("pre",{className:"focus-output",children:t.summary})]})}function TX({run:t,messages:e,onBack:i}){const n=[t.detail?{label:"kind",value:t.detail,rolling:!1}:void 0,t.tokens!==void 0?{label:"tokens",value:t.tokens.toLocaleString(),rolling:!0}:void 0,t.toolCalls!==void 0?{label:"tools",value:`${t.toolCalls}`,rolling:!0}:void 0,t.durationMs!==void 0?{label:"took",value:`${(t.durationMs/1e3).toFixed(1)}s`,rolling:!0}:void 0].filter(s=>!!s);return d.jsxs("div",{className:"focus",children:[d.jsxs("div",{className:"focus-bar",children:[d.jsx("button",{className:"focus-back",onClick:i,type:"button",children:"← conversation"}),d.jsx("span",{className:`focus-status is-${t.status}`,children:t.status})]}),d.jsxs("div",{className:"focus-scroll",children:[d.jsx("h3",{className:"focus-title",children:t.label}),n.length>0&&d.jsx("div",{className:"focus-stats",children:n.map(s=>d.jsx(MX,{label:s.label,value:s.value,rolling:s.rolling},s.label))}),t.kind==="local_workflow"?d.jsx(AX,{run:t}):d.jsx(LX,{run:t,messages:e})]})]})}function yb(t){if(t<6e4)return`${(t/1e3).toFixed(1)}s`;const e=Math.round(t/1e3);return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}function NX(t){return t<1e3?`${t}`:`${(t/1e3).toFixed(t<1e4?1:0)}k`}function jX(t){return/opus|sonnet|haiku|fable|gpt|codex/i.exec(t)?.[0].toLowerCase()??t}function RX(t){const[e,i]=w.useState(()=>Date.now());return w.useEffect(()=>{if(!t)return;i(Date.now());const n=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(n)},[t]),e}function Z4(t,e,i,n,s){return t?i?yb(Math.max(0,e-i)):"running…":[n!==void 0?NX(n):void 0,s!==void 0?yb(s):void 0].filter(Boolean).join(" · ")}function CA({worker:t,now:e}){const i=t.state!=="done",n=t.queuedAt&&t.startedAt&&t.startedAt-t.queuedAt>=1e3?t.startedAt-t.queuedAt:void 0;return d.jsxs("li",{className:`rail-row is-worker ${i?"is-running":"is-completed"}`,children:[d.jsx("span",{className:"rail-dot","aria-hidden":"true"}),d.jsxs("span",{className:"rail-body",children:[d.jsx("span",{className:"rail-label",children:t.label||`agent ${t.index}`}),d.jsxs("span",{className:"rail-meta",children:[t.model&&d.jsx("span",{className:"rail-kind",children:jX(t.model)}),t.attempt!==void 0&&t.attempt>1&&d.jsx("span",{className:"rail-retry",children:d.jsx(ct,{children:`retry ${t.attempt}`})}),n&&d.jsx("span",{className:"rail-kind",children:d.jsx(ct,{children:`queued ${yb(n)}`})}),d.jsx("span",{className:i?"rail-live":"rail-stats",children:d.jsx(ct,{children:Z4(i,e,t.startedAt,t.tokens,t.durationMs)})})]})]})]})}function DX({run:t,now:e}){const i=t.workers??[],n=t.phases??[],s=i.filter(r=>!n.some(o=>o.index===r.phaseIndex));return d.jsxs(d.Fragment,{children:[n.map(r=>{const o=i.filter(u=>u.phaseIndex===r.index);if(o.length===0)return null;const a=o.filter(u=>u.state!=="done").length;return d.jsxs("li",{className:"rail-phase",children:[d.jsxs("div",{className:"rail-phase-head",children:[d.jsx("span",{className:"rail-phase-title",children:r.title}),d.jsx("span",{className:"rail-phase-count",children:d.jsx(ct,{children:a>0?`${a}/${o.length}`:`${o.length}`})})]}),d.jsx("ul",{className:"rail-sub",children:o.map(u=>d.jsx(CA,{worker:u,now:e},u.id))})]},r.index)}),s.length>0&&d.jsxs("li",{className:"rail-phase",children:[d.jsx("div",{className:"rail-phase-head",children:d.jsx("span",{className:"rail-phase-title",children:"other"})}),d.jsx("ul",{className:"rail-sub",children:s.map(r=>d.jsx(CA,{worker:r,now:e},r.id))})]})]})}function BX({run:t,now:e,onOpen:i}){const n=t.status==="running";return d.jsxs("li",{className:`rail-run is-${t.status}`,children:[d.jsxs("button",{className:"rail-row",type:"button",onClick:()=>i?.(t.id),children:[d.jsx("span",{className:"rail-dot","aria-hidden":"true"}),d.jsxs("span",{className:"rail-body",children:[d.jsx("span",{className:"rail-label",children:t.label}),d.jsxs("span",{className:"rail-meta",children:[t.detail&&d.jsx("span",{className:"rail-kind",children:t.detail}),d.jsx("span",{className:n?"rail-live":"rail-stats",children:d.jsx(ct,{children:Z4(n,e,t.startedAt,t.tokens,t.durationMs)})})]})]})]}),(t.workers?.length??0)>0&&d.jsx("ul",{className:"rail-tree",children:d.jsx(DX,{run:t,now:e})})]})}function OX({count:t,open:e,onToggle:i}){return t===0?null:d.jsxs("button",{className:`icon-btn rail-toggle ${e?"is-on":""}`,type:"button","aria-expanded":e,"aria-label":`Agents in this chat — ${t}`,title:`${t} agent${t===1?"":"s"} this chat has started`,onClick:i,children:[d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M11 3l1.7 4.3L17 9l-4.3 1.7L11 15l-1.7-4.3L5 9l4.3-1.7z"}),d.jsx("path",{d:"M18 14.5l.7 1.8 1.8.7-1.8.7-.7 1.8-.7-1.8-1.8-.7 1.8-.7z"})]}),d.jsx("span",{className:"topbar-action-label",children:"Agents"}),d.jsx("span",{className:"rail-count",children:d.jsx(us,{value:t})})]})}function IX({agents:t,onOpen:e,onClose:i}){const n=t.filter(r=>r.status==="running").length,s=RX(n>0);return t.length===0?null:d.jsxs("aside",{className:"rail","aria-label":"agents",children:[d.jsxs("header",{className:"rail-head",children:[d.jsx("span",{className:"rail-title",children:"Agents"}),i&&d.jsx("button",{className:"rail-close",type:"button","aria-label":"Hide agents",onClick:i,children:"✕"})]}),d.jsx("ul",{className:"rail-list",children:t.map(r=>d.jsx(BX,{run:r,now:s,onOpen:e},r.id))}),d.jsx("div",{className:"rail-foot",children:d.jsx(ct,{children:n>0?`${n} running`:`${t.length} finished`})})]})}const J4=t=>t.replace(/\s+/g," ").trim();function PX(t){const e=/^\d{4}-\d{2}-\d{2}T\S+\s+(?:ERROR|WARN|WARNING)\s+(.+)$/is.exec(t.trim());return e?J4(e[1]):null}function zX(t){const e=J4(t);if(/collab spawn failed:.*agent thread limit reached/i.test(e))return{key:"agent-thread-limit",title:"A background agent could not start",detail:"The agent thread limit was reached. The current chat can keep going.",technical:t.trim()};if(/responses_websocket:.*failed to connect to websocket:.*504 Gateway Timeout/i.test(e))return{key:"codex-connection-timeout",title:"The Codex connection timed out",detail:"This was recorded in diagnostics. If the turn stops, send the message again.",technical:t.trim()};const i=PX(t);if(i){const n=i.replace(/^[\w.-]+(?:::[\w.-]+)*:\s*/,"");return{key:`provider:${n.toLocaleLowerCase()}`,title:"The agent reported a background issue",detail:n,technical:t.trim()}}return{key:`message:${e.toLocaleLowerCase()}`,title:e}}function $X(t){const e=new Map;for(const i of t){const n=zX(i),s=e.get(n.key);s?e.set(n.key,{...s,detail:n.detail??s.detail,technical:n.technical??s.technical,count:s.count+1}):e.set(n.key,{...n,count:1})}return[...e.values()]}function FX(){return d.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:[d.jsx("circle",{cx:"10",cy:"10",r:"7.25"}),d.jsx("path",{d:"M10 8.6v4.2",strokeLinecap:"round"}),d.jsx("circle",{cx:"10",cy:"5.9",r:".65",fill:"currentColor",stroke:"none"})]})}function HX(){return d.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:d.jsx("path",{d:"m4.5 6 3.5 3.5L11.5 6",strokeLinecap:"round",strokeLinejoin:"round"})})}function WX({notices:t,onClear:e}){const[i,n]=w.useState(!1),s=w.useMemo(()=>$X(t),[t]);if(s.length===0)return null;const r=t.length,o=s.every(h=>!!h.technical),a=r===1?s[0].title:`${r} ${o?"background notices":"notices"}`,u=r===1&&s[0].detail?s[0].detail:`${s.length} ${s.length===1?"kind":"kinds"}, grouped quietly`;return d.jsxs("section",{className:`chat-notices ${i?"is-open":""}`,"aria-label":"Background notices",children:[d.jsxs("div",{className:"chat-notices-bar",children:[d.jsxs("button",{className:"chat-notices-toggle",type:"button","aria-expanded":i,onClick:()=>n(h=>!h),children:[d.jsx("span",{className:"chat-notices-icon",children:d.jsx(FX,{})}),d.jsxs("span",{className:"chat-notices-copy",children:[d.jsx("span",{className:"chat-notices-title",children:a}),d.jsx("span",{className:"chat-notices-hint",children:u})]}),d.jsx("span",{className:"chat-notices-chevron",children:d.jsx(HX,{})})]}),d.jsx("button",{className:"chat-notices-clear",type:"button","aria-label":"Clear all background notices",title:"Clear all",onClick:e,children:"×"})]}),i&&d.jsx("div",{className:"chat-notices-panel",children:s.map(h=>d.jsxs("article",{className:"chat-notice-item",children:[d.jsxs("div",{className:"chat-notice-head",children:[d.jsx("span",{children:h.title}),h.count>1&&d.jsxs("span",{className:"chat-notice-count",children:[h.count," times"]})]}),h.detail&&d.jsx("p",{children:h.detail}),h.technical&&d.jsxs("details",{className:"chat-notice-technical",children:[d.jsx("summary",{children:"Technical details"}),d.jsx("pre",{children:h.technical})]})]},h.key))})]})}function lg(t){const[e,i]=w.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return w.useEffect(()=>{const n=window.matchMedia(t);i(n.matches);const s=r=>i(r.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[t]),e}const qX="(min-width: 701px)",UX="(min-width: 1180px)",VX="(min-width: 1500px)",EA="(max-width: 859.98px)",eD=18,KX=10,YX=24,MA=1.5,GX=350,QX=.4,AA=.5,XX=72;function ZX(t,e){return!e.open&&t.x>eD?null:{phase:"watching",opening:!e.open,from:t,at:t,width:e.width}}function JX(t,e){if(t.phase==="dropped")return t;const i={...t,at:e};if(t.phase==="swiping")return i;const n=e.x-t.from.x,s=e.y-t.from.y;if(e.t-t.from.t>GX)return{...i,phase:"dropped"};const r=Math.abs(n),o=Math.abs(s);return o>KX&&r<o*MA?{...i,phase:"dropped"}:r<YX?i:(t.opening?n<0:n>0)?{...i,phase:"dropped"}:r<o*MA?{...i,phase:"dropped"}:{...i,phase:"swiping"}}function tD(t){const e=t.at.x-t.from.x,i=t.opening?e/t.width:1+e/t.width;return Math.min(1,Math.max(0,i))}function eZ(t){if(t.phase!=="swiping")return null;const e=t.at.x-t.from.x,i=t.at.t-t.from.t,n=i>0?e/i:0;if(Math.abs(e)>=XX){if(n>AA)return"open";if(n<-AA)return"close"}return tD(t)>QX?"open":"close"}function tZ({enabled:t,open:e,onChange:i}){const n=w.useRef(e);n.current=e;const s=w.useRef(i);return s.current=i,w.useCallback(r=>{if(!(!r||!t))return iZ(r,()=>n.current,o=>s.current(o))},[t])}function iZ(t,e,i){let n=null,s=0;const r=()=>{n?.phase==="swiping"&&(s=Date.now()+700),n=null,t.removeAttribute("data-drawer-swiping"),t.style.removeProperty("--swipe-p")},o=m=>{if(r(),m.touches.length!==1)return;s=0;const v=m.touches[0],_=e();if(_){const S=window.getSelection();if(S&&S.rangeCount>0&&!S.isCollapsed)return}const x=t.querySelector(".sidebar")?.offsetWidth||t.clientWidth;n=ZX({x:v.clientX,y:v.clientY,t:m.timeStamp},{open:_,width:x}),n&&v.clientX<=eD&&m.cancelable&&m.preventDefault()},a=m=>{if(!n)return;if(m.touches.length!==1||!m.cancelable)return r();const v=m.touches[0];if(n=JX(n,{x:v.clientX,y:v.clientY,t:m.timeStamp}),n.phase==="dropped")return r();n.phase==="swiping"&&(m.preventDefault(),t.setAttribute("data-drawer-swiping",""),t.style.setProperty("--swipe-p",String(tD(n))))},u=m=>{const v=n&&eZ(n);v&&m.cancelable&&m.preventDefault(),r(),v&&v==="open"!==e()&&i(v==="open")},h=m=>{n?.phase!=="swiping"&&Date.now()>=s||(m.preventDefault(),m.stopImmediatePropagation())},p=m=>{n?.phase!=="swiping"&&(m.key==="Enter"||m.key===" ")&&(s=0)};return t.addEventListener("touchstart",o,{passive:!1}),t.addEventListener("touchmove",a,{passive:!1}),t.addEventListener("touchend",u,{passive:!1}),t.addEventListener("touchcancel",r,{passive:!0}),t.addEventListener("click",h,!0),t.addEventListener("dblclick",h,!0),t.addEventListener("keydown",p,!0),()=>{t.removeEventListener("touchstart",o),t.removeEventListener("touchmove",a),t.removeEventListener("touchend",u),t.removeEventListener("touchcancel",r),t.removeEventListener("click",h,!0),t.removeEventListener("dblclick",h,!0),t.removeEventListener("keydown",p,!0),r()}}let ya,Og=0;function xb(t,e){const i=++Og;ya?.skipTransition(),ya=void 0;const n=document.documentElement;delete n.dataset.zenTransition;let s=!1;const r=()=>{i!==Og||s||(s=!0,bl.flushSync(e))},o=()=>{i===Og&&(ya=void 0,delete n.dataset.zenTransition)},a=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(a||!document.startViewTransition){r(),a||document.querySelector(".app .main")?.animate?.([{opacity:.75},{opacity:1}],{duration:320,easing:"ease-out"});return}n.dataset.zenTransition=t;try{ya=document.startViewTransition(r),ya.ready.catch(()=>{}),ya.finished.then(o,()=>{r(),o()})}catch{r(),o()}}function LA(){Og++,ya?.skipTransition(),ya=void 0,delete document.documentElement.dataset.zenTransition}const nZ={opus:{color:"#b99cff",width:1.42,roundness:.42,bodyWidth:.96,beat:1.3},sonnet:{color:"#e07a59",width:1.46,roundness:.28,bodyWidth:.94,beat:1.05},haiku:{color:"#59c9c5",width:1.32,roundness:.24,bodyWidth:.76,beat:.8},fable:{color:"#e48db7",width:1.38,roundness:.16,bodyWidth:.9,beat:1.2},claude:{color:"#d97757",width:1.48,roundness:.38,bodyWidth:1.02,beat:1.15},astra:{color:"#d76bf0",width:1.4,roundness:.12,bodyWidth:.88,beat:.95},sol:{color:"#f1b84b",width:1.38,roundness:.45,bodyWidth:.98,beat:.9},terra:{color:"#78c892",width:1.56,roundness:.12,bodyWidth:1.12,beat:1.25},luna:{color:"#84a9ff",width:1.4,roundness:.4,bodyWidth:.8,beat:1.4},codex:{color:"#8eb3c3",width:1.44,roundness:.16,bodyWidth:.94,beat:1.1}};function sZ(t){return t==="pi"?"codex":t.startsWith("pi-")?t.slice(3):t}const rZ={opus:{ears:"M 17 43 Q 5 30 11 16 Q 28 18 34 31 Z M 66 31 Q 72 18 89 16 Q 95 30 83 43 Z",inner:"M 19 34 L 16 23 Q 26 25 28 31 Z M 72 31 Q 74 25 84 23 L 81 34 Z",fringe:"M 15 48 Q 10 27 28 21 L 29 9 L 42 19 L 50 5 L 58 19 L 72 9 L 72 22 Q 91 30 85 49 L 74 41 L 72 46 Q 63 41 60 32 Q 53 43 43 46 L 45 35 Q 33 46 25 42 L 23 49 Z",shine:"M 25 29 Q 35 25 41 28 M 59 25 L 65 28",mark:"M 50 17 L 54 24 L 50 31 L 46 24 Z"},sonnet:{ears:"M 16 46 Q 5 31 9 8 Q 29 13 37 32 Z M 63 32 Q 71 13 91 8 Q 95 31 84 46 Z",inner:"M 19 34 L 15 17 Q 27 21 29 31 Z M 71 31 Q 73 21 85 17 L 81 34 Z",fringe:"M 15 49 Q 10 28 29 21 Q 40 18 45 11 L 45 19 Q 55 16 59 8 Q 65 14 63 21 Q 89 24 85 49 L 74 42 L 72 48 Q 60 42 57 33 Q 49 44 37 45 L 41 35 Q 31 43 24 42 L 22 50 Z",shine:"M 25 30 Q 33 26 39 27 M 64 27 L 70 29",mark:"M 48 27 Q 44 22 48 19 Q 48 23 51 23 Q 55 18 55 17 Q 60 26 54 29 Q 51 31 48 27 Z"},haiku:{ears:"M 33 29 Q 8 33 7 8 Q 31 6 36 27 Z M 64 27 Q 68 6 93 8 Q 92 32 67 29 Z",inner:"M 16 16 Q 27 16 30 26 Q 20 26 16 16 Z M 70 26 Q 74 16 84 16 Q 80 26 70 26 Z",fringe:"M 15 48 Q 10 23 36 21 Q 42 12 55 13 L 51 20 Q 83 15 87 40 L 84 50 L 74 41 Q 64 47 55 37 Q 50 46 43 46 L 44 36 Q 35 48 24 42 L 21 49 Z",shine:"M 24 31 Q 33 25 40 28 M 65 29 L 72 32",mark:"M 50 32 Q 38 29 41 20 Q 52 21 50 32 Q 49 19 61 20 Q 61 30 50 32 Z"},fable:{ears:"M 20 40 Q 5 24 16 4 Q 31 9 34 30 Z M 66 30 Q 70 8 84 4 Q 96 24 80 40 Z",inner:"M 21 27 Q 16 17 19 12 Q 26 17 27 28 Z M 73 28 Q 74 17 81 12 Q 84 17 79 27 Z",fringe:"M 15 49 Q 9 28 30 21 Q 36 17 42 21 Q 51 13 61 20 Q 90 22 86 50 L 77 44 L 74 51 Q 59 44 53 34 Q 46 45 34 45 L 36 36 Q 29 42 23 44 L 22 51 Z",shine:"M 24 31 Q 31 27 36 28 M 61 27 Q 68 26 73 31",mark:"M 50 31 C 34 22 44 15 50 22 C 56 15 67 22 50 31 Z"},claude:{ears:"M 23 43 C 3 45 2 27 13 24 C 6 13 22 7 30 20 L 37 32 Z M 63 32 L 70 20 C 78 7 94 13 87 24 C 98 27 97 45 77 43 Z",inner:"M 16 30 Q 13 19 24 23 L 28 32 Z M 72 32 L 76 23 Q 87 19 84 30 Z",fringe:"M 15 49 Q 8 35 18 26 Q 22 16 36 21 Q 44 10 53 20 Q 64 13 71 23 Q 91 23 86 49 L 76 42 L 74 49 Q 62 46 58 35 Q 50 45 41 46 L 42 36 Q 30 46 25 43 L 23 50 Z",shine:"M 24 31 Q 30 27 36 29 M 62 28 L 69 30",mark:"M 50 19 V 30 M 44 22 L 56 27 M 45 28 L 55 21"},astra:{ears:"M 15 44 L 7 11 L 24 18 L 31 13 L 37 32 Z M 63 32 L 69 13 L 76 18 L 93 11 L 85 44 Z",inner:"M 19 34 L 15 22 L 27 28 Z M 73 28 L 85 22 L 81 34 Z",fringe:"M 15 50 Q 11 27 32 21 L 39 12 L 47 18 L 57 9 L 60 19 Q 88 21 87 48 L 78 42 L 75 50 Q 62 44 61 31 Q 50 48 38 46 L 42 34 Q 31 45 25 41 L 22 51 Z",shine:"M 24 31 L 35 27 M 66 27 L 74 32",mark:"M 52 16 L 55 22 L 62 24 L 55 27 L 52 34 L 49 27 L 42 24 L 49 22 Z"},sol:{ears:"M 22 45 L 6 36 L 13 28 L 7 14 L 24 18 L 31 9 L 38 30 Z M 62 30 L 69 9 L 76 18 L 93 14 L 87 28 L 94 36 L 78 45 Z",inner:"M 19 32 L 17 24 L 28 27 L 27 35 Z M 73 35 L 72 27 L 83 24 L 81 32 Z",fringe:"M 14 49 L 10 38 L 18 33 Q 18 22 35 21 L 41 12 L 46 19 L 56 7 L 60 20 L 69 16 L 70 23 Q 86 26 86 40 L 89 50 L 76 43 L 75 50 Q 61 45 56 34 Q 52 43 43 46 L 44 36 Q 32 47 25 43 L 22 51 Z",shine:"M 25 31 L 36 27 M 65 29 L 71 31",mark:"M 54 25 A 5 5 0 1 0 44 25 A 5 5 0 1 0 54 25 Z M 49 16 V 17 M 49 33 V 34 M 40 25 H 41 M 57 25 H 58"},terra:{ears:"M 31 33 Q 7 30 6 11 Q 30 8 38 29 Z M 62 29 Q 70 8 94 11 Q 93 30 69 33 Z",inner:"M 15 17 Q 26 16 31 28 Q 20 26 15 17 Z M 69 28 Q 74 16 85 17 Q 80 26 69 28 Z",fringe:"M 13 49 Q 8 24 31 22 L 31 17 L 42 20 Q 46 12 58 13 L 56 20 Q 82 16 89 39 L 86 51 L 75 43 L 74 50 Q 59 47 55 34 Q 48 45 36 46 L 39 35 Q 29 44 23 43 L 21 52 Z",shine:"M 23 32 Q 29 27 35 29 M 65 27 L 73 32",mark:"M 47 32 Q 41 19 59 19 Q 61 32 47 32 Z M 47 32 L 55 24"},luna:{ears:"M 23 40 Q 5 22 20 5 Q 24 19 37 29 Z M 63 29 Q 76 19 80 5 Q 95 22 77 40 Z",inner:"M 24 29 Q 17 22 20 15 Q 24 24 29 27 Z M 71 27 Q 76 24 80 15 Q 83 22 76 29 Z",fringe:"M 15 49 Q 10 24 34 20 Q 45 13 61 20 Q 88 22 86 49 L 75 43 L 74 50 Q 57 45 57 32 Q 49 46 35 47 L 40 34 Q 31 44 24 42 L 22 50 Z",shine:"M 24 30 Q 31 26 37 28 M 65 28 L 72 31",mark:"M 54 17 A 8 8 0 1 0 59 30 A 9 9 0 0 1 54 17 Z"},codex:{ears:"M 17 44 L 8 32 L 8 16 L 24 16 L 35 31 Z M 65 31 L 76 16 L 92 16 L 92 32 L 83 44 Z",inner:"M 16 23 H 22 L 28 31 L 21 33 L 16 29 Z M 72 31 L 78 23 H 84 V 29 L 79 33 Z",fringe:"M 14 49 Q 12 26 31 22 L 36 15 L 47 20 L 57 13 L 63 22 Q 86 23 86 48 L 76 42 L 74 49 Q 61 44 57 33 Q 48 45 37 45 L 40 35 Q 30 44 24 42 L 22 50 Z",shine:"M 24 31 L 35 28 M 64 28 L 72 31",mark:"M 45 20 L 39 25 L 45 30 M 55 20 L 61 25 L 55 30 M 52 20 L 48 30"}},oZ={idle:"M 43 75 Q 50 78 57 75 Q 56 84 50 84 Q 44 84 43 75 Z",still:"M 45 78 Q 50 81 55 78",think:"M 48 79 Q 53 76 58 78",work:"M 44 78 Q 49 81 56 76",asleep:"M 48 79 C 48 75 53 75 53 79 C 53 83 48 83 48 79 Z"};function $S({robot:t="sonnet",size:e=28,alert:i=!1,mood:n="idle",asleep:s=!1}){const r=sZ(t),o=rZ[r],a=`mascot-iris-${w.useId()}`,u=s?"asleep":n,h=u==="think",p=u==="work",m=p?8:r==="haiku"||r==="luna"||r==="fable"?12:11;return d.jsxs("span",{className:`mascot${i?" is-alert":""}${s?" is-asleep":""}`,"data-robot":t,"data-mood":n,"data-expression":u,style:{width:e,height:e,"--mascot-size":`${e}px`,"--robot-accent":nZ[r].color},"aria-hidden":"true",children:[d.jsxs("svg",{className:"mascot-avatar",viewBox:"0 0 100 100",width:e,height:e,fill:"none",focusable:"false",children:[d.jsx("defs",{children:d.jsxs("linearGradient",{id:a,x1:"0",y1:"0",x2:"0",y2:"1",children:[d.jsx("stop",{className:"mascot-iris-dark",offset:"0"}),d.jsx("stop",{className:"mascot-iris-color",offset:".65"}),d.jsx("stop",{className:"mascot-iris-light",offset:"1"})]})}),d.jsxs("g",{className:"mascot-avatar-character",children:[d.jsx("path",{className:"mascot-fur mascot-ears",d:o.ears}),d.jsx("path",{className:"mascot-ear-inner",d:o.inner}),d.jsx("path",{className:"mascot-collar",d:"M 33 81 Q 50 77 67 81 L 74 94 Q 51 101 26 94 Z"}),d.jsx("path",{className:"mascot-collar-fold",d:"M 32 84 L 48 92 L 41 97 L 28 92 Z M 68 84 L 52 92 L 59 97 L 72 92 Z"}),d.jsx("path",{className:"mascot-collar-gem",d:"M 50 87 L 54 92 L 50 97 L 46 92 Z"}),d.jsx("path",{className:"mascot-avatar-base",d:"M 16 49 C 14 28 29 20 50 20 C 71 20 86 28 84 49 L 89 63 L 82 65 L 85 73 L 77 73 C 72 85 61 91 50 91 C 39 91 28 85 23 73 L 15 73 L 18 65 L 11 63 Z"}),d.jsx("path",{className:"mascot-face-shadow",d:"M 14 61 L 20 64 L 18 70 L 26 70 Q 34 84 50 85 Q 68 85 78 71 L 83 72 L 77 73 C 72 85 61 91 50 91 C 39 91 28 85 23 73 L 15 73 L 18 65 L 11 63 Z"}),d.jsx("path",{className:"mascot-brow-shadow",d:"M 19 47 Q 25 34 50 34 Q 75 34 82 48 L 73 47 Q 62 49 55 42 Q 43 52 32 47 L 25 51 Z"}),d.jsx("path",{className:"mascot-fur mascot-fringe",d:o.fringe}),d.jsx("path",{className:"mascot-hair-shine",d:o.shine}),d.jsx("g",{className:`mascot-avatar-mark${r==="claude"||r==="codex"?" mascot-mark-lines":""}`,children:d.jsx("path",{d:o.mark})}),d.jsxs("g",{className:"mascot-avatar-face",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsxs("g",{className:"mascot-avatar-cheeks",children:[d.jsx("ellipse",{cx:"23",cy:"71",rx:"7",ry:"3.5"}),d.jsx("ellipse",{cx:"77",cy:"71",rx:"7",ry:"3.5"}),d.jsx("path",{className:"mascot-blush-lines",d:"M 20 70 L 19 72 M 24 70 L 23 72 M 76 70 L 75 72 M 80 70 L 79 72"})]}),d.jsx("g",{className:"mascot-avatar-eyes",children:s?d.jsxs("g",{className:"mascot-sleep-eyes",children:[d.jsx("path",{d:"M 25 59 Q 33 67 41 59 M 59 59 Q 67 67 75 59"}),d.jsx("path",{className:"mascot-lower-lash",d:"M 26 61 L 24 63 M 74 61 L 76 63"})]}):[33,67].map((v,_)=>{const x=h?57+_*2:59,S=v+(h?2:0);return d.jsxs("g",{children:[d.jsx("ellipse",{className:"mascot-eye-white",cx:v,cy:x,rx:"10",ry:m+1}),d.jsx("ellipse",{className:"mascot-avatar-eye",cx:S,cy:x+1,rx:"7.7",ry:m,fill:`url(#${a})`}),d.jsx("ellipse",{className:"mascot-pupil",cx:S,cy:x,rx:"3.4",ry:m*.66}),d.jsx("path",{className:"mascot-iris-glow",d:`M ${S-4.5} ${x+m-3} Q ${S} ${x+m} ${S+4.5} ${x+m-3}`}),d.jsx("ellipse",{className:"mascot-eye-glint",cx:S-2.7,cy:x-m*.43,rx:"3",ry:"3.4"}),d.jsx("circle",{className:"mascot-eye-glint mascot-eye-glint-small",cx:S+3.5,cy:x+4,r:"1.4"}),d.jsx("path",{className:"mascot-upper-lash",d:`M ${v-10} ${x-3} Q ${v-8} ${x-m-3} ${v+1} ${x-m-1} Q ${v+7} ${x-m} ${v+10} ${x-4}`}),d.jsx("path",{className:"mascot-lower-lash",d:`M ${v-6} ${x+m} Q ${v} ${x+m+2} ${v+5} ${x+m}`})]},v)})}),(h||p)&&d.jsxs("g",{className:"mascot-eyebrows",children:[d.jsx("path",{d:h?"M 26 43 Q 32 39 39 42":"M 26 45 L 39 48"}),d.jsx("path",{d:h?"M 61 45 Q 67 42 74 44":"M 61 48 L 74 45"})]}),d.jsx("path",{className:"mascot-nose",d:"M 48.5 71 Q 50 70 51.5 71 L 50 72 Z"}),d.jsx("path",{className:"mascot-avatar-mouth",d:oZ[u]}),u==="idle"&&d.jsx("path",{className:"mascot-tongue",d:"M 47 81 Q 50 78 53 81 Q 50 84 47 81 Z"})]})]})]}),t.startsWith("pi")&&d.jsx("span",{className:"mascot-provider-badge","data-provider-mark":"pi",children:"P"}),s&&d.jsx("span",{className:"mascot-z",children:"z"}),i&&d.jsx("span",{className:"mascot-task-dot"})]})}function TA(t){const e=t.replace(/\/+$/,""),i=e.lastIndexOf("/");return i<0?null:i===0?"/":e.slice(0,i)}function iD({start:t,title:e,onPick:i,onClose:n,files:s=!1}){const[r,o]=w.useState(t),[a,u]=w.useState(t),[h,p]=w.useState([]),[m,v]=w.useState(null),[_,x]=w.useState(!0),S=w.useCallback(k=>{o(k),u(k)},[]);w.useEffect(()=>{let k=!0;return x(!0),he.invoke("list_dir",{path:r}).then(M=>{if(!k)return;p((M??[]).filter(N=>N.is_dir||s)),v(null);const L=(M??[])[0];if(L&&!r.startsWith("/")){const N=TA(L.path);N&&(o(N),u(N))}}).catch(M=>{k&&(p([]),v(M.message))}).finally(()=>k&&x(!1)),()=>{k=!1}},[r,s]),w.useEffect(()=>{const k=M=>M.key==="Escape"&&n();return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[n]);const C=TA(r);return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"panel-scrim",onClick:n}),d.jsxs("div",{className:"fp-picker",role:"dialog","aria-label":e,children:[d.jsxs("header",{className:"fp-picker-head",children:[d.jsx("span",{className:"fp-picker-title",children:e}),d.jsx("button",{className:"panel-close",type:"button",onClick:n,"aria-label":"Close",children:"✕"})]}),d.jsxs("form",{className:"fp-picker-path",onSubmit:k=>{k.preventDefault(),S(a.trim())},children:[d.jsx("input",{className:"fp-picker-input",value:a,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",placeholder:"/path/to/folder",onChange:k=>u(k.target.value)}),d.jsx("button",{className:"panel-btn",type:"submit",children:"Go"})]}),m&&d.jsx("div",{className:"panel-error",children:m}),d.jsxs("div",{className:"fp-picker-body",children:[C&&d.jsxs("button",{className:"fp-picker-row is-up",type:"button",onClick:()=>S(C),children:[d.jsx(NA,{}),d.jsx("span",{className:"fp-picker-name",children:".."})]}),_&&h.length===0&&!m&&d.jsx("div",{className:"dots","aria-label":"loading"}),!_&&h.length===0&&!m&&d.jsx("div",{className:"fp-picker-empty",children:"No folders in here."}),h.map(k=>d.jsxs("button",{className:`fp-picker-row ${k.is_dir?"":"is-file"}`,type:"button",onClick:()=>k.is_dir?S(k.path):i(k.path),children:[k.is_dir?d.jsx(NA,{}):d.jsx(lZ,{}),d.jsx("span",{className:"fp-picker-name",children:k.name})]},k.path))]}),d.jsxs("footer",{className:"fp-picker-foot",children:[d.jsx("div",{className:"fp-picker-here",title:r,children:d.jsx("bdi",{children:r})}),!s&&d.jsx("button",{className:"panel-btn is-primary",type:"button",disabled:!r.startsWith("/"),onClick:()=>i(r),children:"Use this folder"})]})]})]})}function NA(){return d.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.7.9l.8 1.2a2 2 0 0 0 1.7.9H19a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"})})}function lZ(){return d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"}),d.jsx("path",{d:"M14 2v6h6"})]})}function aZ({onReference:t,onUpload:e}){return d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",role:"menuitem",className:"picker-item",onClick:t,children:[d.jsx("span",{className:"picker-name",children:"Reference a file"}),d.jsx("span",{className:"picker-model",children:"on the machine running the agents"})]}),d.jsxs("button",{type:"button",role:"menuitem",className:"picker-item",onClick:e,children:[d.jsx("span",{className:"picker-name",children:"Upload a file"}),d.jsx("span",{className:"picker-model",children:"from this device — up to 12 MB per file"})]})]})}function ml(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}const cZ={isRepo:!1,current:"",branches:[],isWorktree:!1};function uZ({projects:t,projectId:e,onProject:i,branch:n,branches:s=cZ,onBranch:r,newWorktree:o,onNewWorktree:a}){const u=t.filter(m=>ml(m.name)!=="general"),h=n&&!s.branches.includes(n)?[n,...s.branches]:s.branches,p=s.loading?"Finding branches…":s.error?"Branches unavailable":s.isRepo?n||s.current||"No branch":"No Git repository";return d.jsxs("div",{className:"work-location","aria-label":"Work location",children:[d.jsxs("label",{className:"work-location-field",title:"Project",children:[d.jsx(hZ,{}),d.jsx("span",{className:"sr-only",children:"Project"}),d.jsxs("select",{"aria-label":"Project",value:e??"",onChange:m=>i(m.target.value||null),children:[d.jsx("option",{value:"",children:"General"}),u.map(m=>d.jsx("option",{value:m.id,children:m.name},m.id))]})]}),d.jsx("span",{className:"work-location-divider","aria-hidden":"true"}),d.jsxs("label",{className:`work-location-field is-branch ${s.isRepo?"":"is-muted"}`,title:o?"Base branch":"Branch",children:[d.jsx(dZ,{}),d.jsx("span",{className:"sr-only",children:o?"Base branch":"Branch"}),d.jsxs("select",{"aria-label":o?"Base branch":"Branch",value:n,disabled:s.loading||!s.isRepo,onChange:m=>r(m.target.value),children:[!h.length&&d.jsx("option",{value:"",children:p}),h.map(m=>d.jsx("option",{value:m,children:m},m))]})]}),d.jsx("span",{className:"work-location-spacer"}),d.jsxs("label",{className:`worktree-choice ${s.isWorktree?"is-active":""}`,title:s.isWorktree?"This chat runs in a linked worktree":"Create a task branch in a new linked worktree",children:[d.jsx("input",{type:"checkbox",checked:o,disabled:!s.isRepo,onChange:m=>a(m.target.checked)}),d.jsx(fZ,{}),d.jsx("span",{children:"New worktree"})]}),s.error&&d.jsx("span",{className:"work-location-error",role:"status",children:s.error})]})}function hZ(){return d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M3 7.5h7l2 2h9v9.5H3z"}),d.jsx("path",{d:"M3 7.5V5h7l2 2h9v2.5"})]})}function dZ(){return d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("circle",{cx:"6",cy:"5",r:"2"}),d.jsx("circle",{cx:"18",cy:"7",r:"2"}),d.jsx("circle",{cx:"6",cy:"19",r:"2"}),d.jsx("path",{d:"M6 7v10M8 10h4a6 6 0 0 0 6-1"})]})}function fZ(){return d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("circle",{cx:"6",cy:"6",r:"2"}),d.jsx("circle",{cx:"18",cy:"6",r:"2"}),d.jsx("circle",{cx:"12",cy:"18",r:"2"}),d.jsx("path",{d:"M6 8v2a4 4 0 0 0 4 4h2M18 8v2a4 4 0 0 1-4 4h-2v2"})]})}function pZ(t){return`pasted.${(t.split("/")[1]||"png").replace("jpeg","jpg")}`}function nD(t){const e=t;return e?.message||e?.name||String(t??"no reason given")}function mZ(t){return t?.name==="NotAllowedError"?"Tap it again, then tap “Paste” when the browser asks. Or hold the box and choose Paste.":`The browser would not read the clipboard (${nD(t)}). Hold the box and choose Paste.`}async function gZ(t){const e=[];let i="";for(const n of t){const s=n.types.find(r=>r.startsWith("image/"));if(s){const r=await n.getType(s);e.push(new File([r],pZ(s),{type:s}));continue}n.types.includes("text/plain")&&(i+=await(await n.getType("text/plain")).text())}return{files:e,text:i}}const vy="blank:new",vZ=()=>({text:"",attached:[]});class _Z{held=new Map;keep(e,i){const n=e??vy;if(!i.text.trim()&&i.attached.length===0){this.held.delete(n);return}this.held.set(n,{text:i.text,attached:[...i.attached]})}take(e){const i=e??vy,n=this.held.get(i);return this.held.delete(i),n??vZ()}forget(e){this.held.delete(e??vy)}}function jA(t,e,i,n){const s=t.slice(i,n),r=(e==="codex"?/^([/$])(\S*)$/:/^(\/)(\S*)$/).exec(s);if(r)return{trigger:r[1],query:r[2],start:i,end:n}}function RA(t,e,i=t.length){const n=Math.max(0,Math.min(i,t.length));let s=n;for(;s>0&&!/\s/.test(t[s-1]);)s-=1;const r=t.slice(n).search(/\s/),o=r<0?t.length:n+r,a=jA(t,e,s,o);if(e==="claude")return s===0&&o===t.length?a:void 0;if(a)return a;let u=s;for(;u>0;){for(;u>0&&/\s/.test(t[u-1]);)u-=1;const h=u;for(;u>0&&!/\s/.test(t[u-1]);)u-=1;const p=jA(t,e,u,h);if(p)return p}}function DA(t,e){return e==="$"?t.replace(/^\//,"$"):t}function yZ(t,e,i){const n=e.end<t.length&&/\s/.test(t[e.end])?i.trimEnd():i;return{text:t.slice(0,e.start)+n+t.slice(e.end),caret:e.start+n.length}}function BA(t){const e=new Set,i=[];for(const n of t){const s=n.trim().replace(/^\/+/,"");!s||/\s/.test(s)||e.has(s.toLowerCase())||(e.add(s.toLowerCase()),i.push({id:s,label:`/${s}`,insert:`/${s} `}))}return i}const zf={claude:{id:"claude",name:"Claude",models:[{id:"claude:opus",agent:"claude",name:"Claude",model:"Opus latest",flag:"opus",hint:"for complex work · moving alias opus",composerStyle:"opus"},{id:"claude:sonnet",agent:"claude",name:"Claude",model:"Sonnet latest",flag:"sonnet",hint:"the everyday balance · moving alias sonnet",composerStyle:"sonnet"},{id:"claude:haiku",agent:"claude",name:"Claude",model:"Haiku latest",flag:"haiku",hint:"fastest for quick answers · moving alias haiku",composerStyle:"haiku"},{id:"claude:fable",agent:"claude",name:"Claude",model:"Fable latest",flag:"fable",hint:"for the toughest problems · moving alias fable",composerStyle:"fable"},{id:"claude:opus-5",agent:"claude",name:"Claude",model:"Opus 5",flag:"claude-opus-5",hint:"claude-opus-5",composerStyle:"opus"},{id:"claude:opus-4-8",agent:"claude",name:"Claude",model:"Opus 4.8",flag:"claude-opus-4-8",hint:"claude-opus-4-8",composerStyle:"opus"},{id:"claude:opus-4-7",agent:"claude",name:"Claude",model:"Opus 4.7",flag:"claude-opus-4-7",hint:"claude-opus-4-7",composerStyle:"opus"},{id:"claude:opus-4-6",agent:"claude",name:"Claude",model:"Opus 4.6",flag:"claude-opus-4-6",hint:"claude-opus-4-6",composerStyle:"opus"},{id:"claude:opus-4-5-20251101",agent:"claude",name:"Claude",model:"Opus 4.5",flag:"claude-opus-4-5-20251101",hint:"claude-opus-4-5-20251101",composerStyle:"opus"},{id:"claude:sonnet-5",agent:"claude",name:"Claude",model:"Sonnet 5",flag:"claude-sonnet-5",hint:"claude-sonnet-5",composerStyle:"sonnet"},{id:"claude:sonnet-4-6",agent:"claude",name:"Claude",model:"Sonnet 4.6",flag:"claude-sonnet-4-6",hint:"claude-sonnet-4-6",composerStyle:"sonnet"},{id:"claude:sonnet-4-5-20250929",agent:"claude",name:"Claude",model:"Sonnet 4.5",flag:"claude-sonnet-4-5-20250929",hint:"claude-sonnet-4-5-20250929",composerStyle:"sonnet"},{id:"claude:haiku-4-5-20251001",agent:"claude",name:"Claude",model:"Haiku 4.5",flag:"claude-haiku-4-5-20251001",hint:"claude-haiku-4-5-20251001",composerStyle:"haiku"},{id:"claude:default",agent:"claude",name:"Claude",model:"Default",flag:"",hint:"whatever the CLI picks",composerStyle:"claude"}],access:[{id:"read",label:"Plan",hint:"create a plan before making changes"},{id:"manual",label:"Manual",hint:"always ask before making changes"},{id:"edits",label:"Accept edits",hint:"automatically accept all file edits"},{id:"auto",label:"Auto",hint:"Claude handles permission decisions"},{id:"full",label:"Bypass permissions",hint:"run anything without asking",bypass:!0}],efforts:[{id:"low",label:"Low",short:"Low",hint:"quick answers, least thinking"},{id:"medium",label:"Medium",short:"Med",hint:"the usual balance"},{id:"high",label:"High",short:"High",hint:"thinks longer, costs more"},{id:"xhigh",label:"Very high",short:"V.high",hint:"for problems worth the wait"},{id:"max",label:"Max",short:"Max",hint:"everything it has"},{id:"ultracode",label:"Ultracode",short:"Ultra",hint:"max, and it fans work out to subagents"},{id:"auto",label:"Auto",short:"Auto",hint:"it picks the level itself, per turn"}],capabilities:{commands:"reported",liveSettings:{model:!0,effort:!0},cleanStart:!0},commands:BA,liveSettingCommand(t,e){if(e)return t==="model"?`/model ${e}`:`/effort ${e}`}},codex:{id:"codex",name:"Codex",models:[{id:"codex:astra",agent:"codex",name:"Codex",model:"Astra",flag:"gpt-6-astra",hint:"the frontier one",composerStyle:"astra"},{id:"codex:sol",agent:"codex",name:"Codex",model:"Sol",flag:"gpt-5.6-sol",hint:"the reliable workhorse",composerStyle:"sol"},{id:"codex:terra",agent:"codex",name:"Codex",model:"Terra",flag:"gpt-5.6-terra",hint:"the everyday balance",composerStyle:"terra"},{id:"codex:luna",agent:"codex",name:"Codex",model:"Luna",flag:"gpt-5.6-luna",hint:"fast and cheap",composerStyle:"luna"},{id:"codex:default",agent:"codex",name:"Codex",model:"Default",flag:"",hint:"whatever the CLI picks",composerStyle:"codex"}],access:[{id:"read",label:"Read-only",hint:"sandboxed, no writes"},{id:"auto",label:"Workspace write",hint:"writes in the project, asks when unsure"},{id:"full",label:"Danger: full access",hint:"no sandbox, no approvals"}],efforts:[{id:"low",label:"Low",short:"Low",hint:"quick answers"},{id:"medium",label:"Medium",short:"Med",hint:"the usual balance"},{id:"high",label:"High",short:"High",hint:"thinks longer, costs more"},{id:"xhigh",label:"Very high",short:"V.high",hint:"for problems worth the wait"},{id:"max",label:"Max",short:"Max",hint:"everything it has"}],capabilities:{commands:"loaded",liveSettings:{model:!1,effort:!1},cleanStart:!1},commands:BA,liveSettingCommand(){}},pi:{id:"pi",name:"pi.dev",models:[{id:"pi:astra",agent:"pi",name:"pi.dev",model:"Astra",flag:"gpt-6-astra",hint:"Codex through pi.dev",composerStyle:"pi-astra"},{id:"pi:sol",agent:"pi",name:"pi.dev",model:"Sol",flag:"gpt-5.6-sol",hint:"Codex through pi.dev",composerStyle:"pi-sol"},{id:"pi:terra",agent:"pi",name:"pi.dev",model:"Terra",flag:"gpt-5.6-terra",hint:"Codex through pi.dev",composerStyle:"pi-terra"},{id:"pi:luna",agent:"pi",name:"pi.dev",model:"Luna",flag:"gpt-5.6-luna",hint:"Codex through pi.dev",composerStyle:"pi-luna"},{id:"pi:default",agent:"pi",name:"pi.dev",model:"Default",flag:"",hint:"whatever Pi picks",composerStyle:"pi"}],access:[{id:"read",label:"Read-only",hint:"only read, search and list tools"},{id:"full",label:"Full access",hint:"Pi can run commands and edit files",bypass:!0}],efforts:[{id:"minimal",label:"Minimal",short:"Min",hint:"the least reasoning"},{id:"low",label:"Low",short:"Low",hint:"quick answers"},{id:"medium",label:"Medium",short:"Med",hint:"the usual balance"},{id:"high",label:"High",short:"High",hint:"thinks longer, costs more"},{id:"xhigh",label:"Very high",short:"V.high",hint:"for problems worth the wait"},{id:"max",label:"Max",short:"Max",hint:"everything it has"}],capabilities:{commands:"none",liveSettings:{model:!1,effort:!1},cleanStart:!1},commands(){return[]},liveSettingCommand(){}}};function Yi(t){return zf[t]}const Wc=Object.values(zf),Wu=Wc.flatMap(t=>t.models),R0=Object.fromEntries(Wc.map(t=>[t.id,t.name]));Object.fromEntries(Wc.map(t=>[t.id,t.access]));Object.fromEntries(Wc.map(t=>[t.id,t.efforts]));const bb=":model:";function xZ(t){return/^[A-Za-z0-9._-]{1,64}$/.test(t)}function _y(t){return/^gpt$/i.test(t)?"GPT":t&&t[0].toUpperCase()+t.slice(1)}function bZ(t,e,i){if(i?.trim())return i.trim().replace(/^Claude\s+/i,"");if(t==="claude"){const s=e.replace(/^claude-/,"").replace(/-\d{8}$/,"").split("-"),r=_y(s.shift()??e);return s.length?`${r} ${s.join(".")}`:r}const n=e.split("-");if(/^gpt$/i.test(n[0]??"")){const s=_y(n.shift()),r=n.shift()??"";return[s+(r?`-${r}`:""),...n.map(_y)].join(" ")}return e}function wZ(t,e){const i=e.toLowerCase();return t==="claude"?i.includes("opus")?"opus":i.includes("sonnet")?"sonnet":i.includes("haiku")?"haiku":i.includes("fable")?"fable":"claude":t==="codex"?i.includes("astra")?"astra":i.includes("sol")?"sol":i.includes("terra")?"terra":i.includes("luna")?"luna":"codex":i.includes("astra")?"pi-astra":i.includes("sol")?"pi-sol":i.includes("terra")?"pi-terra":i.includes("luna")?"pi-luna":"pi"}function mv(t,e,i,n){const s=e.trim();if(!xZ(s))return;const r=Yi(t).models.find(o=>o.flag===s);return r||{id:`${t}${bb}${encodeURIComponent(s)}`,agent:t,name:Yi(t).name,model:bZ(t,s,i),flag:s,hint:n?.trim()||s,composerStyle:wZ(t,s)}}function qu(t){if(!t)return;const e=Wu.find(s=>s.id===t);if(e)return e;const i=t.split(":")[0],n=t.indexOf(bb);if(zf[i]&&n>0)try{return mv(i,decodeURIComponent(t.slice(n+bb.length)))}catch{return}return zf[i]?.models[0]}function OA(t,e){const i=e.trim();return i?Yi(t).models.filter(r=>r.flag).find(r=>r.flag===i)??mv(t,i):Yi(t).models.find(r=>!r.flag)}function Vd(t,e){const i=Yi(t).access;return i.some(n=>n.id===e)?e:i[0].id}function SZ(t,e){return Yi(t).access.find(i=>i.id===e)?.label??e}function sD(t){return Yi(t).efforts.filter(e=>e.id!=="auto")}function IA(t,e){const i=Yi(t).efforts;return i.some(n=>n.id===e)?e:i[0].id}function kZ(t,e){return Yi(t).commands(e)}function CZ(t,e,i){return Yi(t).liveSettingCommand(e,i)}function EZ(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[i,n]of Object.entries(t)){if(Array.isArray(n)){const r=n.filter(o=>typeof o=="string");r.length&&(e[i]={claude:r});continue}if(!n||typeof n!="object"||Array.isArray(n))continue;const s={};for(const r of Object.keys(zf)){const o=n[r];if(Array.isArray(o)){const a=o.filter(u=>typeof u=="string");a.length&&(s[r]=a)}}Object.keys(s).length&&(e[i]=s)}return e}function MZ(t,e){const i=Yi(t).models.filter(u=>u.flag),n=t==="claude"?i.filter(u=>["opus","sonnet","haiku","fable"].includes(u.flag)):[],s=e.models.flatMap(u=>{const h=mv(t,u.model,u.displayName,u.description??u.model);return h?[h]:[]}),r=[],o=new Set,a=e.source==="bundled"?i:[];for(const u of[...n,...s,...a]){const h=u.flag.toLowerCase();!h||o.has(h)||(o.add(h),r.push(u))}return r}const yy=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,AZ=8e3,LZ=typeof navigator<"u"&&!!navigator.clipboard&&!!(navigator.clipboard.read||navigator.clipboard.readText);function TZ(t,e){const[i,n]=w.useState({}),[s,r]=w.useState({}),o=w.useRef(new Set),a=w.useCallback((p,m=!1)=>{p==="pi"||!m&&o.current.has(p)||(o.current.add(p),r(v=>({...v,[p]:{...v[p],loading:!0,error:void 0}})),he.invoke("agent_models",{agent:p}).then(v=>{n(_=>({..._,[p]:MZ(p,v)})),r(_=>({..._,[p]:{loading:!1,note:v.note??void 0}}))}).catch(v=>{r(_=>({..._,[p]:{loading:!1,error:String(v?.message??v)}}))}))},[]);w.useEffect(()=>{if(t)for(const p of["claude","codex"])e&&!e.includes(p)||a(p)},[t,e,a]);const u=w.useMemo(()=>Wc.flatMap(p=>i[p.id]??p.models),[i]),h=w.useCallback(p=>{o.current.delete(p),a(p,!0)},[a]);return{models:u,status:s,reload:h}}function rD({list:t,access:e,onPick:i}){const n=t.filter(o=>!o.bypass),s=t.find(o=>o.bypass),r=w.useRef(e===s?.id?n[n.length-1].id:e);return e!==s?.id&&(r.current=e),d.jsxs(d.Fragment,{children:[n.map(o=>d.jsxs("button",{type:"button",role:"menuitem",className:`picker-item ${o.id===e?"is-on":""}`,onClick:()=>i(o.id),children:[d.jsx("span",{className:"picker-name",children:o.label}),d.jsx("span",{className:"picker-model",children:o.hint}),o.id===e&&d.jsx("span",{className:"picker-tick","aria-hidden":"true",children:"✓"})]},o.id)),s&&d.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":e===s.id,className:`picker-item is-bypass ${e===s.id?"is-on":""}`,title:s.hint,onClick:()=>i(e===s.id?r.current:s.id),children:[d.jsx("span",{className:"picker-name",children:s.label}),d.jsx("span",{className:"picker-switch",children:e===s.id?"Enabled":"Enable"})]})]})}const PA=/\.(png|jpe?g|gif|webp)$/i,NZ=100;function oD(t){return`octiq.v2.history:${t||"new"}`}function zA(t){try{const e=JSON.parse(localStorage.getItem(oD(t))||"[]");return Array.isArray(e)?e.filter(i=>typeof i=="string"):[]}catch{return[]}}function jZ(t,e){try{localStorage.setItem(oD(t),JSON.stringify(e))}catch{}}function RZ(t,e,i,n,s){if(s==="older"){if(!t.length)return{index:e,text:i,draft:n};const o=Math.min(e+1,t.length-1);return{index:o,text:t[o],draft:e===-1?i:n}}if(e<0)return{index:e,text:i,draft:n};const r=e-1;return{index:r,text:r<0?n:t[r],draft:n}}function DZ(t,e){return[t.trim(),...e.map(i=>i.trim())].filter(Boolean).join(`
|
|
72
|
+
|
|
73
|
+
`)}function BZ({focusMode:t=!1,session:e,focusOn:i,choice:n,onChoice:s,access:r,onAccess:o,onSend:a,onStop:u,putBack:h,onPutBack:p,busy:m,disabled:v,started:_,commands:x,onCommandOpen:S,onReloadSkills:C,skillsStatus:k,contextTokens:M,contextWindow:L,activity:N,turnStartedAt:j,turnTokens:R,turnApprox:z,thinking:J,thought:G,background:q,effort:X,onEffort:I,lite:T,onLite:H,projects:F,projectId:P,onProject:U,branch:V,branches:K,onBranch:D,newWorktree:$,onNewWorktree:Y,showWorkLocation:B,cwd:ee,onTerminal:ie,terminalOpen:re,onRestart:ge,installed:Ee,model:fe,lastDurationMs:Pe,lastCostUsd:De}){const[He,_e]=w.useState(""),[Le,jt]=w.useState(!1);w.useEffect(()=>{jt(!1)},[t]);const[di,xt]=w.useState(0),[be,We]=w.useState(!1),[Ze,ve]=w.useState(!1),[fi,Mt]=w.useState(!1),[Kt,gn]=w.useState(0),de=Yi(n.agent),Me=de.access,Ke=de.efforts,Je=sD(n.agent),ot=Me.find(ae=>ae.id===r)??Me[0],Gt=Ke.find(ae=>ae.id===X)??Ke[Math.floor(Ke.length/2)],wt=w.useRef(null),pt=w.useRef(null),[Ht,gi]=w.useState(!1),[Tt,vi]=w.useState(!1),[Qt,vs]=w.useState([]),[lr,st]=w.useState(null),[Yt,Gi]=w.useState(null),[Ds,to]=w.useState(()=>zA(e)),[Bs,_s]=w.useState(-1);w.useEffect(()=>{to(zA(e)),_s(-1)},[e]);const ys=ae=>Ee!==void 0&&!Ee.includes(ae),zr=Ee!==void 0&&Ee.length===0,io=TZ(be||Ze,Ee),ar=w.useRef(""),[Al,Ll]=w.useState(!1),Os=w.useCallback((ae,ze=!1)=>{const it=RZ(Ds,Bs,He,ar.current,ae);if(ar.current=it.draft,_s(it.index),_e(it.text),!ze)return;xt(it.text.length);const Bt=wt.current;Bt?.focus({preventScroll:!0}),requestAnimationFrame(()=>{Bt&&Bt.setSelectionRange(Bt.value.length,Bt.value.length)})},[Ds,Bs,He]),$r=RA(He,n.agent,di),xs=$r?.query,Io=$r!==void 0;w.useEffect(()=>{Io&&S?.()},[Io,S]);const _i=xs===void 0?[]:(x??[]).filter(ae=>ae.id.toLowerCase().startsWith(xs.toLowerCase())).sort((ae,ze)=>+(ze.id.toLowerCase()===xs.toLowerCase())-+(ae.id.toLowerCase()===xs.toLowerCase())).slice(0,40),Ni=Io&&(_i.length>0||!!C),ht=xs!==void 0&&_i[Kt]?.id.toLowerCase()===xs.toLowerCase();w.useEffect(()=>{gn(ae=>ae<_i.length?ae:0)},[_i.length]);function Fn(ae){const ze=$r??RA(He,n.agent,wt.current?.selectionStart);if(!ze)return;const it=yZ(He,ze,DA(ae.insert,ze.trigger));_e(it.text),xt(it.caret),requestAnimationFrame(()=>{wt.current?.focus(),wt.current?.setSelectionRange(it.caret,it.caret)})}w.useEffect(()=>{const ae=wt.current;ae&&(ae.style.height="auto",ae.style.height=`${Math.min(ae.scrollHeight,420)}px`)},[He]);const $i=w.useCallback(async ae=>{for(const ze of ae){if(ze.size>12*1024*1024){st(`${ze.name}: file is larger than 12 MB`);continue}try{const it=await ze.arrayBuffer();let Bt="";const Xt=new Uint8Array(it);for(let ws=0;ws<Xt.length;ws+=8192)Bt+=String.fromCharCode(...Xt.subarray(ws,ws+8192));const Wn=(ze.type.split("/")[1]||"bin").replace("jpeg","jpg"),Pt=ze.name||`pasted.${Wn}`,yi=PA.test(Pt),zs=await he.invoke("save_attachment",{dataBase64:btoa(Bt),extension:Wn,filename:Pt});st(null),vs(ws=>[...ws,{path:zs,name:Pt,isImage:yi,url:yi?URL.createObjectURL(ze):void 0}])}catch(it){st(String(it.message??it))}}},[]),Is=w.useCallback(ae=>{const ze=wt.current;if(!ze){_e(it=>it+ae);return}ze.focus({preventScroll:!0}),ze.setRangeText(ae,ze.selectionStart,ze.selectionEnd,"end"),_e(ze.value)},[]);w.useEffect(()=>CW(ae=>Is(xW(ae,ee))),[Is,ee]);const bs=w.useCallback(async()=>{const ae=navigator.clipboard?.read?navigator.clipboard.read():null;st(null);const ze=it=>{st(mZ(it)),wt.current?.focus()};if(ae){let it;try{it=await ae}catch(Bt){ze(Bt);return}try{const{files:Bt,text:Xt}=await gZ(it);Bt.length&&await $i(Bt),Xt&&Is(Xt),!Bt.length&&!Xt&&st("There is nothing to paste.")}catch(Bt){st(`Could not read what is on the clipboard (${nD(Bt)}).`)}return}try{const it=await navigator.clipboard.readText();it?Is(it):st("There is nothing to paste.")}catch(it){ze(it)}},[$i,Is]),Po=w.useCallback(ae=>{st(null),vs(ze=>{const it=new Set(ze.map(Xt=>Xt.path)),Bt=ae.filter(Xt=>Xt&&!it.has(Xt)).map(Xt=>({path:Xt,name:Xt.split("/").filter(Boolean).pop()??Xt,isImage:PA.test(Xt)}));return[...ze,...Bt]})},[]),on=w.useCallback(ae=>{for(const ze of ae)ze.url&&URL.revokeObjectURL(ze.url)},[]),Ia=w.useCallback(()=>{Yt&&on(Yt.attached),Gi({text:He,attached:Qt}),_e(""),vs([]),st(null),_s(-1),ar.current="",wt.current?.focus()},[Qt,Yt,on,He]),no=w.useCallback(()=>{Yt&&(_e(Yt.text),vs(Yt.attached),Gi(null),wt.current?.focus())},[Yt]);w.useEffect(()=>{if(!Yt)return;if(He||Qt.length){on(Yt.attached),Gi(null);return}const ae=setTimeout(()=>{on(Yt.attached),Gi(null)},AZ);return()=>clearTimeout(ae)},[Qt.length,Yt,on,He]);const Hn=w.useRef({text:"",attached:[]});Hn.current={text:He,attached:Qt};const Fr=w.useRef(new _Z),Ps=w.useRef(e);w.useEffect(()=>{if(Ps.current===e)return;Fr.current.keep(Ps.current,Hn.current),Ps.current=e;const ae=Fr.current.take(e);_e(ae.text),vs(ae.attached),st(null),ar.current="",Gi(ze=>(ze&&on(ze.attached),null))},[e,on]);const pi=w.useRef(null);w.useEffect(()=>{!h?.length||pi.current===h||(pi.current=h,_e(ae=>DZ(ae,h.map(ze=>ze.text))),vs(ae=>{const ze=h.flatMap(it=>it.attachments);return[...ae,...ze.filter(it=>!ae.some(Bt=>Bt.path===it.path))]}),_s(-1),ar.current="",p?.())},[h,p]);const Ci=w.useRef(i);w.useEffect(()=>{Ci.current!==i&&(Ci.current=i,!(yy||v)&&wt.current?.focus())},[i,v]);function cr(ae){to(ze=>{const it=ze[0]===ae?ze:[ae,...ze].slice(0,NZ);return jZ(e,it),it}),_s(-1),ar.current=""}function es(){if(v)return;const ae="👌 OK";a(ae,[]),cr(ae)}function ln(){const ae=He.trim();!ae&&Qt.length===0||v||(a(ae,Qt),cr(ae),_e(""),on(Qt),vs([]),st(null))}return d.jsxs("div",{className:`composer ${t?"composer-focus":""} ${t&&Le?"focus-options-open":""}`,"data-composer-style":n.composerStyle,"data-model-id":n.id,children:[t&&d.jsx("div",{className:"focus-activity",role:"status",children:N||(m?"Working…":" ")}),!!G?.trim()&&d.jsx("div",{className:"think-live","aria-live":"off",children:d.jsx("span",{className:"think-live-text",children:G})}),d.jsxs("div",{className:"composer-hint",children:[d.jsx("span",{className:"composer-hint-said",children:d.jsx(eW,{tasks:q??[],busy:m,children:m?d.jsx(KZ,{since:j,tokens:R,approx:z,activity:N,thinking:J,effort:Gt.label.toLowerCase(),background:(q??[]).length>0,robot:n.composerStyle}):d.jsxs(d.Fragment,{children:[d.jsx($S,{robot:n.composerStyle,mood:"idle"}),N??(yy?"Enter for a new line":"Enter to send · Shift+Enter for a new line")]})})}),(fe||Pe!==void 0||De!==void 0)&&d.jsxs("span",{className:"composer-last",title:[fe&&`Model · ${fe}`,Pe!==void 0&&`Last turn · ${(Pe/1e3).toFixed(1)}s`,De!==void 0&&`Cost · $${De.toFixed(3)}`].filter(Boolean).join(`
|
|
74
|
+
`),children:[fe&&d.jsx("span",{className:"composer-last-model",children:fe}),Pe!==void 0&&d.jsxs("span",{className:"composer-last-item",children:[d.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("circle",{cx:"12",cy:"12",r:"9"}),d.jsx("path",{d:"M12 7v5l3 2"})]}),d.jsx(ct,{children:`${(Pe/1e3).toFixed(1)}s`})]}),De!==void 0&&d.jsx("span",{className:"composer-last-item",children:d.jsx(ct,{children:`$${De.toFixed(3)}`})})]}),d.jsxs("div",{className:"composer-history",role:"group","aria-label":"Sent message history",children:[d.jsx("button",{className:"history-step",type:"button","aria-label":"Show previous sent message",title:"Previous sent message",disabled:!Ds.length||Bs>=Ds.length-1,onPointerDown:ae=>ae.preventDefault(),onClick:()=>Os("older",!0),children:d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"m6 14 6-6 6 6"})})}),d.jsx("button",{className:"history-step",type:"button","aria-label":"Show next sent message",title:"Next sent message",disabled:Bs<0,onPointerDown:ae=>ae.preventDefault(),onClick:()=>Os("newer",!0),children:d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"m6 10 6 6 6-6"})})})]})]}),Ni&&d.jsxs("div",{className:"slash",children:[d.jsx("div",{className:"slash-head",children:d.jsx(ct,{children:_i.length?`${_i.length} command${_i.length===1?"":"s"} · ${ht?"Enter to send":"Tab to complete"}`:"No matching skills"})}),C&&d.jsxs("div",{className:"skill-reload",children:[d.jsx("button",{type:"button",disabled:k==="loading",onClick:C,children:k==="loading"?"Reloading…":"Reload skills"}),k&&k!=="loading"&&d.jsx("span",{role:"alert",children:k})]}),d.jsx("ul",{className:"slash-list",role:"listbox",children:_i.map((ae,ze)=>d.jsx("li",{children:d.jsx("button",{type:"button",role:"option","aria-selected":ze===Kt,className:`slash-item ${ze===Kt?"is-on":""}`,onMouseEnter:()=>gn(ze),onClick:()=>Fn(ae),children:DA(ae.label,$r?.trigger??"/")})},ae.id))})]}),Al&&d.jsx(iD,{start:ee??"",title:"Reference a file",files:!0,onPick:ae=>{Po([ae]),Ll(!1)},onClose:()=>Ll(!1)}),d.jsxs("div",{className:"composer-box",children:[(Qt.length>0||lr||Yt)&&d.jsxs("div",{className:"attach",children:[Qt.map(ae=>d.jsxs("span",{className:`chip ${ae.isImage?"is-image":""}`,title:ae.path,children:[ae.isImage?d.jsx(R4,{attachment:ae}):d.jsx(XZ,{}),d.jsx("span",{className:"chip-name",children:ae.name}),d.jsx("button",{className:"chip-x",type:"button","aria-label":`Remove ${ae.name}`,onClick:()=>{on([ae]),vs(ze=>ze.filter(it=>it.path!==ae.path))},children:"✕"})]},ae.path)),lr&&d.jsx("span",{className:"attach-error",children:lr}),Yt&&d.jsxs("span",{className:"attach-undo",children:["Cleared.",d.jsx("button",{className:"attach-undo-btn",type:"button",onClick:no,children:"Undo"})]})]}),d.jsx("div",{className:"composer-input-wrap",children:d.jsx("textarea",{ref:wt,className:"composer-input","aria-label":"Message",rows:2,value:He,placeholder:v?"Chat unavailable":`Ask ${n.name} to…`,disabled:v,onChange:ae=>{Bs>=0&&_s(-1),_e(ae.target.value),xt(ae.target.selectionStart)},onSelect:ae=>xt(ae.currentTarget.selectionStart),onPaste:ae=>{const ze=[...ae.clipboardData?.files??[]];ze.length&&(ae.preventDefault(),$i(ze))},onKeyDown:ae=>{if(Ni&&_i.length>0){if(ae.key==="ArrowDown"){ae.preventDefault(),gn(Pt=>(Pt+1)%_i.length);return}if(ae.key==="ArrowUp"){ae.preventDefault(),gn(Pt=>(Pt-1+_i.length)%_i.length);return}const Wn=ae.key==="Enter"&&!ae.shiftKey&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey;if(ae.key==="Tab"||Wn&&!ht){ae.preventDefault(),Fn(_i[Kt]);return}if(ae.key==="Escape"){ae.preventDefault(),_e("");return}}const ze=ae.currentTarget,it=ze.selectionStart===0&&ze.selectionEnd===0,Bt=!He.slice(0,ze.selectionStart).includes(`
|
|
75
|
+
`),Xt=!He.slice(ze.selectionEnd).includes(`
|
|
76
|
+
`);if(ae.key==="ArrowUp"&&Ds.length&&(Bs>=0||it&&Bt)){ae.preventDefault(),Os("older");return}if(ae.key==="ArrowDown"&&Bs>=0&&Xt){ae.preventDefault(),Os("newer");return}if(Bs>=0&&ae.key.length===1&&_s(-1),ae.key==="Enter"){if(ae.metaKey||ae.ctrlKey||ae.altKey){ae.preventDefault(),ze.setRangeText(`
|
|
77
|
+
`,ze.selectionStart,ze.selectionEnd,"end"),_e(ze.value);return}!ae.shiftKey&&!yy&&(ae.preventDefault(),ln())}}})}),d.jsxs("div",{className:"composer-row",children:[d.jsxs("div",{className:"picker composer-attach",children:[d.jsx("button",{className:"picker-btn attach-btn",type:"button","aria-haspopup":"menu","aria-expanded":Tt,"aria-label":"Attach",title:"Reference a file, or upload a file",onClick:()=>vi(ae=>!ae),children:d.jsx(QZ,{})}),Tt&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"picker-scrim",onClick:()=>vi(!1)}),d.jsx("div",{className:"picker-menu",role:"menu","aria-label":"Attach",children:d.jsx(aZ,{onReference:()=>{Ll(!0),vi(!1)},onUpload:()=>{pt.current?.click(),vi(!1)}})})]})]}),LZ&&d.jsx("button",{className:"picker-btn attach-btn",type:"button","aria-label":"Paste",title:"Paste from the clipboard",disabled:!!v,onClick:()=>{bs()},children:d.jsx(GZ,{})}),(!!He||Qt.length>0)&&d.jsx("button",{className:"picker-btn attach-btn clear-btn",type:"button","aria-label":"Clear the message",title:"Clear the message and its files",onClick:Ia,children:d.jsx(YZ,{})}),d.jsx("input",{ref:pt,className:"attach-input",type:"file",multiple:!0,onChange:ae=>{$i([...ae.target.files??[]]),ae.target.value=""}}),d.jsxs("div",{className:"composer-settings",children:[d.jsxs("div",{className:"picker",children:[d.jsxs("button",{className:"picker-btn model-trigger",type:"button","aria-haspopup":"menu","aria-expanded":be,title:`${n.name} · ${n.model}`,onClick:()=>We(ae=>!ae),children:[d.jsx(o0,{agent:n.agent}),n.model,d.jsx("span",{className:"picker-caret","aria-hidden":"true",children:"▾"})]}),be&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"picker-scrim",onClick:()=>We(!1)}),d.jsx("div",{className:"picker-menu is-models",role:"dialog","aria-label":"Model",children:d.jsx(lD,{choice:n,models:io.models,catalogStatus:io.status,onReloadModels:io.reload,onChoice:ae=>{s(ae),We(!1)},missing:ys,noAgents:zr,started:!!_,lite:T,onLite:H,onRestart:ge&&(()=>{ge(),We(!1)})})})]})]}),d.jsxs("div",{className:"picker",children:[d.jsxs("button",{className:`picker-btn perm-${ot.id}`,type:"button","aria-haspopup":"menu","aria-expanded":fi,title:ot.hint,onClick:()=>Mt(ae=>!ae),children:[ot.label,d.jsx("span",{className:"picker-caret","aria-hidden":"true",children:"▾"})]}),fi&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"picker-scrim",onClick:()=>Mt(!1)}),d.jsx("div",{className:"picker-menu",role:"menu",children:d.jsx(rD,{list:Me,access:r,onPick:ae=>{o(ae),Mt(!1)}})})]})]}),d.jsxs("div",{className:"picker",children:[d.jsxs("button",{className:"picker-btn eff-btn",type:"button","aria-haspopup":"dialog","aria-expanded":Ht,title:`Effort: ${Gt.label} — ${Gt.hint}`,onClick:()=>gi(ae=>!ae),children:[d.jsx(WZ,{at:Je.findIndex(ae=>ae.id===Gt.id),of:Je.length,auto:Gt.id==="auto"}),Gt.label]}),Ht&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"picker-scrim",onClick:()=>gi(!1)}),d.jsx("div",{className:"picker-menu is-effort",role:"dialog","aria-label":"Effort",children:d.jsx(UZ,{agent:n.agent,effort:X,onEffort:I,started:!!_})})]})]})]}),d.jsxs("button",{className:"picker-btn settings-toggle model-trigger",type:"button","aria-haspopup":"dialog","aria-expanded":Ze,title:"Model, access and effort",onClick:()=>ve(!0),children:[d.jsx(o0,{agent:n.agent}),n.model,d.jsx("span",{className:"picker-caret","aria-hidden":"true",children:"▾"})]}),ie&&d.jsx("button",{className:`picker-btn ${re?"is-on":""}`,type:"button",title:re?"Hide the terminal":"Open a terminal here",onClick:ie,children:d.jsx(ZZ,{})}),d.jsx("span",{className:"composer-gap"}),t&&d.jsx("button",{className:"picker-btn focus-options-toggle",type:"button","aria-label":Le?"Hide composer options":"Show composer options",title:Le?"Hide composer options":"Composer options","aria-expanded":Le,onClick:()=>xb("options",()=>jt(ae=>!ae)),children:d.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[d.jsx("circle",{cx:"5",cy:"12",r:"1.5"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.5"}),d.jsx("circle",{cx:"19",cy:"12",r:"1.5"})]})}),d.jsx(VZ,{tokens:M,window:L}),t&&d.jsx("button",{className:"focus-quick-response",type:"button","aria-label":"Send 👌 OK",title:"Send 👌 OK",disabled:!!v,onClick:es,children:d.jsx("span",{"aria-hidden":"true",children:"👌"})}),m&&d.jsx("button",{className:"send stop",type:"button",title:"Stop",onClick:u,children:d.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:d.jsx("rect",{x:"5",y:"5",width:"14",height:"14",rx:"2.5"})})}),d.jsx("button",{className:"send",type:"button",title:m?"Send anyway":"Send",disabled:!He.trim()||!!v,onClick:ln,children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"m5 12 7-7 7 7"}),d.jsx("path",{d:"M12 19V5"})]})})]}),Ze&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"sheet-scrim",onClick:()=>ve(!1)}),d.jsx(IZ,{choice:n,models:io.models,catalogStatus:io.status,onReloadModels:io.reload,onChoice:s,missing:ys,noAgents:zr,started:!!_,accessList:Me,access:r,onAccess:o,effort:X,onEffort:I,lite:T,onLite:H,onRestart:ge&&(()=>{ge(),ve(!1)}),onDone:()=>ve(!1)})]})]}),B&&d.jsx(uZ,{projects:F??[],projectId:P??null,onProject:U??(()=>{}),branch:V??"",branches:K,onBranch:D??(()=>{}),newWorktree:!!$,onNewWorktree:Y??(()=>{})})]})}function OZ(){return d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M20 11a8 8 0 1 0-2.3 6"}),d.jsx("path",{d:"M20 4.5V11h-6.5"})]})}function IZ({choice:t,models:e=Wc.flatMap(k=>k.models),catalogStatus:i={},onReloadModels:n=()=>{},onChoice:s,missing:r,noAgents:o,started:a,accessList:u,access:h,onAccess:p,effort:m,onEffort:v,lite:_,onLite:x,onRestart:S,onDone:C}){const[k,M]=w.useState("root"),[L,N]=w.useState(!1),j=q=>{N(!1),M(q)},R=()=>{N(!0),M("root")},z=Yi(t.agent).efforts.find(q=>q.id===m),J=u.find(q=>q.id===h),G=k==="root"?"Chat settings":k==="effort"?"Effort":"Access";return d.jsxs("div",{className:"sheet settings-sheet",role:"dialog","aria-label":"Chat settings",children:[d.jsxs("div",{className:"sheet-nav",children:[d.jsx("button",{type:"button",className:"sheet-nav-btn","aria-label":k==="root"?"Close":"Back",title:k==="root"?"Close":"Back",onClick:k==="root"?C:R,children:k==="root"?d.jsx($Z,{}):d.jsx(zZ,{})}),d.jsx("span",{className:"sheet-title",children:G})]}),d.jsxs("div",{className:`sheet-body sheet-page ${L?"is-back":""}`,children:[k==="root"&&d.jsxs("div",{className:"sheet-group",children:[d.jsx("div",{className:"sheet-head",children:"Model"}),d.jsx(lD,{rows:!0,choice:t,models:e,catalogStatus:i,onReloadModels:n,onChoice:s,missing:r,noAgents:o,started:a,lite:_,onLite:x,onRestart:S,afterList:d.jsxs("div",{className:"sheet-card",children:[d.jsx($A,{label:"Effort",value:z?.label,onClick:()=>j("effort")}),d.jsx($A,{label:"Access",value:J?.label,onClick:()=>j("access")})]})})]}),k==="effort"&&d.jsx("div",{className:"sheet-group",children:d.jsx(PZ,{agent:t.agent,effort:m,onEffort:v,started:a})}),k==="access"&&d.jsxs("div",{className:"sheet-group",children:[d.jsx("div",{className:"sheet-card",children:d.jsx(rD,{list:u,access:h,onPick:p})}),d.jsxs("div",{className:"sheet-foot-note",children:["A chat has no way to answer a permission prompt, so this is what"," ",R0[t.agent]," will do unattended."]})]})]},k)]})}function $A({label:t,value:e,onClick:i}){return d.jsxs("button",{type:"button",className:"sheet-link",onClick:i,children:[d.jsx("span",{className:"sheet-link-name",children:t}),d.jsx("span",{className:"sheet-link-value",children:e??"—"}),d.jsx(FZ,{})]})}function PZ({agent:t,effort:e,onEffort:i,started:n}){return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"sheet-card",children:Yi(t).efforts.map(s=>d.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":s.id===e,className:`picker-item ${s.id===e?"is-on":""}`,onClick:()=>{s.id!==e&&(s.id==="ultracode"&&aD(),i(s.id))},children:[d.jsx("span",{className:"picker-name",children:s.label}),d.jsx("span",{className:"picker-model",children:s.hint}),s.id===e&&d.jsx("span",{className:"picker-tick","aria-hidden":"true",children:"✓"})]},s.id))}),d.jsxs("div",{className:"sheet-foot-note",children:["Higher effort means more thorough answers, but takes longer and uses your limits faster.",n&&(Yi(t).capabilities.liveSettings.effort?" Changes this chat straight away.":" Applies from your next message.")]})]})}function zZ(){return d.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.1",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"m15 18-6-6 6-6"})})}function $Z(){return d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.1",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})}function FZ(){return d.jsx("svg",{className:"sheet-link-caret",width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"m9 18 6-6-6-6"})})}function lD({choice:t,models:e,catalogStatus:i,onReloadModels:n,onChoice:s,missing:r,noAgents:o,started:a,lite:u,onLite:h,onRestart:p,rows:m,afterList:v}){const[_,x]=w.useState(t.agent),[S,C]=w.useState(""),[k,M]=w.useState(!1);w.useEffect(()=>x(t.agent),[t.agent]),w.useEffect(()=>{C(""),M(!1)},[_]);const L=Wc.map(G=>G.id),N=e.filter(G=>G.agent===_&&G.flag),j=t.agent===_&&t.flag&&!N.some(G=>G.flag===t.flag)?[t,...N]:N,R=r(_),z=i[_],J=()=>{const G=S.trim(),q=mv(_,G);if(!q){M(!0);return}M(!1),s(q)};return d.jsxs("div",{className:"mp",children:[d.jsx("div",{className:"mp-tabs",role:"tablist","aria-label":"Agent",children:L.map(G=>d.jsxs("button",{type:"button",role:"tab","aria-selected":_===G,className:`mp-tab ${_===G?"is-on":""}`,disabled:r(G),onClick:()=>x(G),children:[d.jsx("span",{className:`mp-dot ${r(G)?"is-off":""}`,"aria-hidden":"true"}),d.jsx("span",{className:"mp-tab-name",children:R0[G]}),t.agent===G&&d.jsx("span",{className:"mp-tab-now",children:"in use"})]},G))}),d.jsx("div",{className:m?"mp-list":"mp-grid",role:"tabpanel","aria-label":R0[_],children:j.map(G=>{const q=G.id===t.id;return d.jsxs("button",{type:"button",className:`${m?"picker-item has-robot":"mp-card"} ${q?"is-on":""}`,"aria-pressed":q,disabled:R,title:`${G.model} · ${G.flag}`,onClick:()=>s(G),children:[d.jsx($S,{robot:G.composerStyle,mood:"idle",size:m?32:44}),d.jsx("span",{className:m?"picker-name":"mp-card-name",children:G.model}),m&&d.jsx("span",{className:"picker-model",children:G.hint}),q&&d.jsx("span",{className:m?"picker-tick":"mp-card-tick","aria-hidden":"true",children:"✓"})]},G.id)})}),d.jsxs("form",{className:`mp-exact ${k?"is-error":""}`,onSubmit:G=>{G.preventDefault(),J()},children:[d.jsx("input",{id:`exact-model-${_}`,"aria-label":"Exact model ID",value:S,disabled:R,spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:_==="claude"?"claude-opus-4-6":_==="codex"?"gpt-5.5":"model id",onChange:G=>{C(G.target.value),M(!1)}}),d.jsx("button",{type:"submit",disabled:R||!S.trim(),children:"Use exact ID"})]}),k&&d.jsx("div",{className:"mp-catalog is-warn",children:"Use 1–64 letters, numbers, dots, dashes, or underscores."}),z?.loading&&d.jsx("div",{className:"mp-catalog",children:"Refreshing available models…"}),!z?.loading&&z?.error&&d.jsxs("div",{className:"mp-catalog is-warn",title:z.error,children:["Could not refresh models. Showing built-in choices.",d.jsx("button",{type:"button",onClick:()=>n(_),children:"Try again"})]}),!z?.loading&&!z?.error&&z?.note&&d.jsx("div",{className:"mp-catalog",children:z.note}),v,Yi(_).capabilities.cleanStart&&d.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":u,className:`mp-lite ${u?"is-on":""}`,title:"Start without this machine's skills, hooks or other MCP servers",onClick:()=>h(!u),children:[d.jsxs("span",{className:"mp-lite-text",children:[d.jsx("span",{className:"mp-lite-name",children:"Clean start"}),d.jsx("span",{className:"mp-lite-hint",children:"No skills, hooks or other MCP — about half the context"})]}),d.jsx("span",{className:"picker-switch",children:u?"On":"Off"})]}),p&&d.jsxs("button",{type:"button",className:"mp-restart",onClick:p,children:[d.jsxs("span",{className:"mp-lite-text",children:[d.jsx("span",{className:"mp-lite-name",children:"Restart agent"}),d.jsx("span",{className:"mp-lite-hint",children:"Keeps the conversation — your next message picks up new MCP servers and plugins"})]}),d.jsx(OZ,{})]}),d.jsx(HZ,{tab:_,choice:t,gone:R,noAgents:o,started:a,lite:u})]})}function HZ({tab:t,choice:e,gone:i,noAgents:n,started:s,lite:r}){return n?d.jsx("div",{className:"mp-note is-warn",children:"No agent CLI on this machine — a chat cannot start"}):i?d.jsxs("div",{className:"mp-note is-warn",children:[R0[t]," is not on this machine — install it to use these"]}):s&&r&&Yi(t).capabilities.cleanStart&&e.agent===t?d.jsx("div",{className:"mp-note",children:"Clean start applies to your next new chat"}):s?d.jsx("div",{className:"mp-note",children:"Switching models keeps this chat — the next model receives the conversation so far"}):null}function WZ({at:t,of:e,auto:i}){const o=e*3.4-1.1999999999999997;return d.jsx("svg",{className:`eff-bars ${i?"is-auto":""}`,width:o,height:11,viewBox:`0 0 ${o} 11`,"aria-hidden":"true",children:Array.from({length:e},(a,u)=>{const h=3+u*8/Math.max(1,e-1);return d.jsx("rect",{className:i||u<=t?"is-lit":"",x:u*3.4,y:11-h,width:2.2,height:h,rx:1},u)})})}const qZ=2e3;let FA=0;function aD(){const t=document.body;t.classList.remove("is-ultra"),t.offsetWidth,t.classList.add("is-ultra"),window.clearTimeout(FA),FA=window.setTimeout(()=>t.classList.remove("is-ultra"),qZ)}function UZ({agent:t,effort:e,onEffort:i,started:n}){const s=sD(t),r=Yi(t).efforts.find(j=>j.id==="auto"),o=j=>{const R=s.findIndex(z=>z.id===j);return R<0?Math.floor(s.length/2):R},[a,u]=w.useState(e),h=w.useRef(e);w.useEffect(()=>{u(e),h.current=e},[e,t]);const p=a==="auto",[m,v]=w.useState(()=>o(e)),_=p?m:o(a);w.useEffect(()=>{a!=="auto"&&v(o(a))},[a,t]);const x=p&&r?r:s[_],S=a!==e,C=s.length-1,k=j=>j/Math.max(1,C)*100,M=j=>{const R=s[j].id;R==="ultracode"&&h.current!=="ultracode"&&aD(),h.current=R,v(j),u(R)},L=()=>{h.current!==e&&i(h.current)},N=()=>{const j=()=>{window.removeEventListener("pointerup",j),window.removeEventListener("pointercancel",j),L()};window.addEventListener("pointerup",j),window.addEventListener("pointercancel",j)};return d.jsxs("div",{className:`eff ${p?"is-auto":""} ${S?"is-draft":""}`,children:[n&&d.jsx("div",{className:"picker-note",children:Yi(t).capabilities.liveSettings.effort?"Changes this chat straight away":"Applies from your next message"}),d.jsxs("div",{className:"eff-head",children:[d.jsx("span",{className:"eff-name",children:x.label}),d.jsx("span",{className:"eff-hint",children:x.hint})]}),d.jsxs("div",{className:"eff-slide",children:[d.jsxs("div",{className:"eff-track","aria-hidden":"true",children:[d.jsx("span",{className:"eff-fill",style:{width:`${k(_)}%`}}),s.map((j,R)=>d.jsx("span",{className:`eff-stop ${!p&&R<=_?"is-past":""}`,style:{left:`${k(R)}%`}},j.id))]}),d.jsx("input",{className:"eff-range",type:"range",min:0,max:C,step:1,value:_,"aria-label":"Effort","aria-valuetext":x.label,onChange:j=>M(Number(j.target.value)),onPointerDown:N,onKeyUp:L})]}),d.jsx("div",{className:"eff-marks",children:s.map((j,R)=>d.jsx("button",{type:"button",className:`eff-mark ${!p&&R===_?"is-on":""}`,style:R===0?{left:0}:R===C?{right:0}:{left:`${k(R)}%`,transform:"translateX(-50%)"},title:`${j.label} — ${j.hint}`,onClick:()=>{M(R),L()},children:j.short},j.id))}),r&&d.jsxs("button",{type:"button",className:`eff-auto ${p?"is-on":""}`,role:"switch","aria-checked":p,onClick:()=>{const j=p?s[m].id:"auto";h.current=j,u(j),L()},children:[d.jsxs("span",{className:"eff-auto-text",children:[d.jsx("span",{className:"picker-name",children:r.label}),d.jsx("span",{className:"picker-model",children:p?`on — off goes back to ${s[m].label}`:r.hint})]}),d.jsx("span",{className:"eff-switch","aria-hidden":"true"})]})]})}function VZ({tokens:t,window:e}){if(!t||!e)return null;const i=Math.min(100,Math.round(t/e*100)),n=i>=90?"is-danger":i>=70?"is-warn":"",s=7,r=2*Math.PI*s;return d.jsxs("span",{className:`ctx ${n}`,title:`Context: ${HA(t)} of ${HA(e)} used (${i}%)`,children:[d.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",children:[d.jsx("circle",{className:"ctx-track",cx:"9",cy:"9",r:s,fill:"none",strokeWidth:"2.5"}),d.jsx("circle",{className:"ctx-fill",cx:"9",cy:"9",r:s,fill:"none",strokeWidth:"2.5",strokeLinecap:"round",strokeDasharray:`${i/100*r} ${r}`,transform:"rotate(-90 9 9)"})]}),d.jsx("span",{className:"ctx-val",children:d.jsx(ct,{children:`${i}%`})})]})}function KZ({since:t,tokens:e,approx:i,activity:n,thinking:s,effort:r,background:o,robot:a}){const[,u]=w.useState(0);return w.useEffect(()=>{const h=setInterval(()=>u(p=>p+1),1e3);return()=>clearInterval(h)},[]),d.jsxs(d.Fragment,{children:[d.jsx($S,{robot:a,alert:o,mood:s?"think":"work"}),t!==void 0&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-clock",children:tS(Date.now()-t)})," · "]}),d.jsx(ct,{children:QH({tokens:e,approx:i,activity:n,thinking:s,effort:r})})]})}function HA(t){return t>=1e6?`${(t/1e6).toFixed(t>=1e7?0:1)}M`:t>=1e3?`${Math.round(t/1e3)}k`:String(t)}function YZ(){return d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M4 7h16"}),d.jsx("path",{d:"M9.5 7V5.2a1.2 1.2 0 0 1 1.2-1.2h2.6a1.2 1.2 0 0 1 1.2 1.2V7"}),d.jsx("path",{d:"M6.5 7.5 7.3 19a1.8 1.8 0 0 0 1.8 1.7h5.8a1.8 1.8 0 0 0 1.8-1.7l.8-11.5"}),d.jsx("path",{d:"M10.5 11v6M13.5 11v6"})]})}function GZ(){return d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("rect",{x:"8",y:"2.5",width:"8",height:"4",rx:"1.3"}),d.jsx("path",{d:"M9 4.5H7a2 2 0 0 0-2 2V19a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6.5a2 2 0 0 0-2-2h-2"})]})}function QZ(){return d.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round","aria-hidden":"true",children:d.jsx("path",{d:"M12 5v14M5 12h14"})})}function XZ(){return d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"}),d.jsx("path",{d:"M14 2v6h6"})]})}function ZZ(){return d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"m5 8 4 4-4 4"}),d.jsx("path",{d:"M13 16h6"})]})}function JZ(){const[t,e]=w.useState("");return d.jsx("div",{className:"gate",children:d.jsxs("div",{className:"gate-card",children:[d.jsx("h1",{className:"gate-title",children:"Connect to OctiqFlow"}),d.jsxs("p",{className:"gate-body",children:["This browser needs the access token of the machine running OctiqFlow. It is printed in that machine's terminal at startup, and stored in ",d.jsx("code",{children:"web.json"})," inside its profile folder."]}),d.jsxs("form",{className:"gate-form",onSubmit:i=>{i.preventDefault(),t.trim()&&he.useToken(t)},children:[d.jsx("input",{className:"gate-input",value:t,onChange:i=>e(i.target.value),placeholder:"Paste the token",autoFocus:!0,spellCheck:!1,autoCapitalize:"none",autoCorrect:"off"}),d.jsx("button",{className:"gate-btn",type:"submit",disabled:!t.trim(),children:"Connect"})]}),d.jsxs("p",{className:"gate-hint",children:["Opening the full link the server prints — the one ending in ",d.jsx("code",{children:"?token=…"})," — does this for you and is remembered afterwards."]})]})})}function eJ({state:t}){if(t==="open"||t==="unauthorized")return null;const e=t==="connecting"?"Connecting to OctiqFlow":"Reconnecting to OctiqFlow";return d.jsx("span",{className:"connection-status",role:"status","aria-label":e,title:e,children:d.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("rect",{x:"2.5",y:"8.5",width:"5",height:"7",rx:"1.5"}),d.jsx("path",{className:"connection-status-link",d:"M9.5 12h5"}),d.jsx("rect",{x:"16.5",y:"8.5",width:"5",height:"7",rx:"1.5"})]})})}function tJ(t){return t?.reference?`Against ${t.reference}`:t?.command?`From ${t.command}`:""}const cD={unverified:"Unverified","nothing-yet":"No changes yet","to-commit":"To commit","to-merge":"To merge","to-push":"To push","to-release":"To release",released:"Released"};function iJ(t){return t?t.uncommitted>0?"to-commit":t.onTarget?t.commits>0&&!t.pushed?"to-push":xy(t):t.commits===0?t.merged?xy(t):"nothing-yet":t.merged?t.mergedRemote?xy(t):"to-push":"to-merge":"unverified"}function xy(t){return t.released===null||t.released===void 0?"unverified":t.released?"released":"to-release"}function nJ(t){return t==="released"?"ok":"quiet"}function uD(t,e={}){const i=iJ(t?.delivery);return e.waiting?{label:"Needs you",tone:"warn",stage:i}:e.busy?{label:"Working",tone:"accent",stage:i}:{label:cD[i],tone:nJ(i),stage:i}}function hD(t){const e=t?.steps??[];return e.length===0?"":`${e.filter(i=>i.state==="done").length}/${e.length}`}function dD(t){return t?t.exists?t.isRepo?t.isWorktree?"Task worktree":"Primary checkout":"Not a Git repository":t.isWorktree?"Task worktree (removed)":"Directory removed":"Unknown"}function sJ(t){if(!t||!t.isRepo)return"Unknown";if(!t.exists)return"Directory removed";const e=[];return e.push(t.changed===0?"Clean":`${t.changed} changed`),t.ahead>0&&e.push(`${t.ahead} to push`),t.behind>0&&e.push(`${t.behind} behind`),t.hasUpstream||e.push("no upstream"),e.join(" · ")}function rJ(t){return t?t.onTarget?`Working directly on ${t.target}`:t.mergedRemote?`In origin/${t.target}`:t.merged?`In ${t.target} locally — not pushed`:t.commits===0?`Nothing committed to merge into ${t.target} yet`:`Not in ${t.target}`:"Unverified"}function oJ(t){if(!t)return"Unverified";const e=[];return t.commits>0&&e.push(`${t.commits} commit${t.commits===1?"":"s"}`),t.uncommitted>0&&e.push(`${t.uncommitted} uncommitted`),e.length===0?"Nothing committed for this task":(t.pushed&&t.commits>0&&e.push("pushed"),e.join(" · "))}function lJ(t){return t?t.released===!0?"Released":t.released===!1?"Not in the released build":"Unverified":"Unverified"}function WA(t,e){if(!t)return"never";const i=Math.max(0,Math.round((e-t)/1e3));if(i<60)return"just now";const n=Math.round(i/60);if(n<60)return`${n}m ago`;const s=Math.round(n/60);if(s<24)return`${s}h ago`;const r=Math.round(s/24);return r===1?"yesterday":`${r}d ago`}const aJ="Not reported by the agent";function cJ({chatId:t,connected:e,busy:i,waiting:n}){const[s,r]=w.useState(),[o,a]=w.useState(!1),[u,h]=w.useState(!1),p=s?.chatId===t?s:void 0,m=w.useCallback(S=>{!t||!e||document.hidden||he.invoke("chat_task",{chatId:t,refresh:S}).then(r).catch(C=>{String(C).includes("not available on this backend")&&h(!0)})},[t,e]);w.useEffect(()=>{a(!1),m(!1)},[t,m]);const v=w.useRef(i);w.useEffect(()=>{v.current&&!i&&m(!0),v.current=i},[i,m]),w.useEffect(()=>{if(!t||!e)return;const S=he.on("chat-task",M=>{const L=M;L?.chatId===t&&r(L)}),C=he.on("git-status-changed",()=>m(!0)),k=()=>{document.hidden||m(!0)};return document.addEventListener("visibilitychange",k),()=>{S(),C(),document.removeEventListener("visibilitychange",k)}},[t,e,m]);const _=w.useCallback(S=>{he.invoke("chat_task_set_target",{chatId:t,branch:S,setBy:"user"}).then(r).catch(()=>{})},[t]),x=w.useCallback(S=>{const C=p?.projectId;C&&he.invoke("chat_task_set_release_check",{projectId:C,reference:S.reference??null,command:S.command??null}).then(()=>m(!0)).catch(()=>{})},[p?.projectId,m]);return!t||u?null:d.jsx(uJ,{status:p,busy:i,waiting:n,open:o,now:Date.now(),onToggle:()=>{const S=!o;a(S),S&&m(!0)},onTarget:_,onReleaseCheck:x})}function uJ({status:t,busy:e,waiting:i,open:n,now:s,onToggle:r,onTarget:o,onReleaseCheck:a}){const u=uD(t,{busy:e,waiting:i}),h=hD(t?.report),p=t?.workspace?.branch??"";return d.jsxs("div",{className:"chat-task",children:[d.jsxs("button",{type:"button",className:"chat-task-trigger","aria-expanded":n,"aria-label":`Task and workspace — ${u.label}${p?` on ${p}`:""}`,title:`${u.label}${p?` · ${p}`:""} — ${dD(t?.workspace)}`,onClick:r,children:[d.jsx("span",{className:"chat-task-dot","data-tone":u.tone,"aria-hidden":"true"}),d.jsx("span",{className:"chat-task-phase",children:u.label}),h&&d.jsx("span",{className:"chat-task-count",children:h}),p&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"chat-task-sep","aria-hidden":"true"}),d.jsx("span",{className:"chat-task-branch",children:p})]}),d.jsx("svg",{className:"chat-task-chevron",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"m6 9 6 6 6-6"})})]}),n&&d.jsx(hJ,{status:t,now:s,onClose:r,onTarget:o,onReleaseCheck:a})]})}function hJ({status:t,now:e,onClose:i,onTarget:n,onReleaseCheck:s}){const r=t?.report,o=t?.delivery,a=t?.workspace,u=uD(t).stage;return d.jsxs("div",{className:"chat-task-panel",role:"dialog","aria-label":"Task and workspace",children:[d.jsxs("div",{className:"chat-task-head",children:[d.jsx("strong",{children:"Task & workspace"}),d.jsx("button",{type:"button",className:"chat-task-close","aria-label":"Close",onClick:i,children:"×"})]}),d.jsx("p",{className:`chat-task-objective ${r?"":"is-missing"}`,children:r?.objective||aJ}),r?.nextStep&&d.jsx("p",{className:"chat-task-next",children:r.nextStep}),d.jsx("p",{className:"chat-task-source",children:r?`Reported by ${r.reportedBy||"the agent"} ${WA(r.reportedAt,e)}.`:"The agent has not reported a task here. Progress is not inferred from the conversation."}),r&&r.steps.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("h2",{children:["Plan · ",hD(r)," done"]}),d.jsx("ul",{className:"chat-task-steps",children:r.steps.map((h,p)=>d.jsxs("li",{"data-state":h.state,children:[d.jsx("span",{className:"chat-task-step-mark","aria-hidden":"true"}),d.jsx("span",{children:h.title})]},`${p}-${h.title}`))})]}),d.jsxs("div",{className:"chat-task-section-head",children:[d.jsx("h2",{children:"Delivery"}),d.jsx("span",{className:"chat-task-stage",children:cD[u]})]}),d.jsxs("dl",{className:"chat-task-fields",children:[d.jsx("dt",{children:"Commit"}),d.jsx("dd",{children:oJ(o)}),d.jsx("dt",{children:"Target"}),d.jsx("dd",{children:o?.target?d.jsx(fJ,{target:o.target,onTarget:n}):"Unknown"}),d.jsx("dt",{children:"Merge"}),d.jsx("dd",{children:rJ(o)}),d.jsx("dt",{children:"Release"}),d.jsxs("dd",{children:[lJ(o),o?.releaseNote&&d.jsx("span",{className:"chat-task-note",children:o.releaseNote}),t?.releaseCheck?d.jsx("span",{className:"chat-task-note",children:tJ(t.releaseCheck)}):s&&t?.projectId&&d.jsx(dJ,{onSave:s})]})]}),o&&d.jsxs("p",{className:"chat-task-source",children:["Checked ",WA(o.checkedAt,e)," with Git.",o.stale&&" The chat's own directory is gone; this was read from the primary checkout."]}),d.jsx("h2",{children:"Workspace"}),d.jsxs("dl",{className:"chat-task-fields",children:[d.jsx("dt",{children:"Branch"}),d.jsx("dd",{children:a?.branch||"Unknown"}),d.jsx("dt",{children:"Location"}),d.jsx("dd",{children:dD(a)}),d.jsx("dt",{children:"Git state"}),d.jsx("dd",{children:sJ(a)}),d.jsx("dt",{children:"Chat path"}),d.jsx("dd",{className:"chat-task-path",children:a?.cwd||"Not recorded"}),a?.primaryRoot&&a.primaryRoot!==a.repoRoot&&d.jsxs(d.Fragment,{children:[d.jsx("dt",{children:"Repository"}),d.jsx("dd",{className:"chat-task-path",children:a.primaryRoot})]})]})]})}function dJ({onSave:t}){const[e,i]=w.useState(!1),[n,s]=w.useState("reference"),[r,o]=w.useState("");return e?d.jsxs("form",{className:"chat-task-release-form",onSubmit:a=>{a.preventDefault();const u=r.trim();i(!1),u&&t(n==="reference"?{reference:u}:{command:u})},children:[d.jsxs("select",{"aria-label":"How a release is recognised",value:n,onChange:a=>s(a.target.value),children:[d.jsx("option",{value:"reference",children:"Git ref"}),d.jsx("option",{value:"command",children:"Command"})]}),d.jsx("input",{"aria-label":n==="reference"?"Release ref":"Release check command",placeholder:n==="reference"?"origin/release":"./scripts/octiq-check.sh",value:r,autoFocus:!0,onChange:a=>o(a.target.value),onKeyDown:a=>{a.key==="Escape"&&i(!1)}}),d.jsx("button",{type:"submit",children:"Save"}),d.jsx("span",{className:"chat-task-note",children:n==="reference"?"Released means the commit is an ancestor of this ref.":"The first commit hash this prints is taken as what is running."})]}):d.jsx("button",{type:"button",className:"chat-task-setup",onClick:()=>i(!0),children:"Set up a release check"})}function fJ({target:t,onTarget:e}){const[i,n]=w.useState(!1),[s,r]=w.useState(t);return e?i?d.jsxs("form",{className:"chat-task-target-form",onSubmit:o=>{o.preventDefault();const a=s.trim();n(!1),a&&a!==t&&e(a)},children:[d.jsx("input",{"aria-label":"Target branch",value:s,autoFocus:!0,onChange:o=>r(o.target.value),onKeyDown:o=>{o.key==="Escape"&&n(!1)}}),d.jsx("button",{type:"submit",children:"Set"})]}):d.jsxs("button",{type:"button",className:"chat-task-target",onClick:()=>{r(t),n(!0)},children:[t,d.jsx("span",{className:"chat-task-note",children:"change"})]}):d.jsx(d.Fragment,{children:t})}let Ig=null;function fD(){return Ig??=he.invoke("agent_history_list",{limit:600}).then(t=>t??[]).catch(t=>{throw Ig=null,new Error(pD(t))}),Ig}function pD(t){const e=t instanceof Error?t.message:String(t??"");return e.includes("desktop app")||e.toLowerCase().includes("not available")?"This OctiqFlow backend is older than this page — it does not know how to list past sessions yet. Rebuild and restart it.":e||"Could not read the agents' past sessions."}function pJ(){return Ig=null,fD()}function mJ(t){return he.invoke("agent_history_read",{agent:t.agent,sessionId:t.sessionId}).then(e=>e??[]).catch(e=>{throw new Error(pD(e))})}function gJ(t,e=Date.now()){let i=Tc();for(const n of t)i=qf(i,n,e);return{...i,busy:!1,status:void 0,activity:void 0}}function mD(t){const e=t.split("/").filter(Boolean);return e[e.length-1]??t}function wb(t,e){if(!t||!e)return!1;const i=t.replace(/\/+$/,""),n=e.replace(/\/+$/,"");return i===n||i.startsWith(`${n}/`)}const qA=new WeakMap;function vJ(t){let e=qA.get(t);return e||(e={title:t.title.toLowerCase(),cwd:t.cwd.toLowerCase(),rest:`${t.agent} ${t.model??""} ${t.origin??""}`.toLowerCase()},qA.set(t,e)),e}function _J(t,e){const i=[];let n=t.indexOf(e);for(;n!==-1&&i.length<12;)i.push([n,n+e.length]),n=t.indexOf(e,n+e.length);return i}function yJ(t,e){let i=0;for(const n of e){if(i=t.indexOf(n,i),i===-1)return!1;i+=1}return!0}function xJ(t){if(t.length<2)return t;const e=[...t].sort((n,s)=>n[0]-s[0]),i=[e[0]];for(const[n,s]of e.slice(1)){const r=i[i.length-1];n<=r[1]?r[1]=Math.max(r[1],s):i.push([n,s])}return i}const yc=1440*60*1e3;function UA(t,e){const i=e-t.updatedAt;return i<yc?2:i<7*yc?1:i<30*yc?.5:0}function bJ(t,e){const i=vJ(t),n=_J(i.title,e);return n.length>0?{score:n.some(([r])=>r===0||/[\s\-_/.]/.test(i.title[r-1]))?8:5,ranges:n}:mD(i.cwd).includes(e)?{score:4,ranges:[]}:i.cwd.includes(e)?{score:2,ranges:[]}:i.rest.includes(e)?{score:2,ranges:[]}:yJ(i.title,e)?{score:1,ranges:[]}:{score:0,ranges:[]}}function VA(t,e,i={}){const{agent:n,cwd:s,limit:r=40,now:o=Date.now()}=i,a=e.toLowerCase().split(/\s+/).filter(Boolean),u=[];for(const h of t){if(n&&h.agent!==n||s&&!wb(h.cwd,s))continue;if(a.length===0){u.push({session:h,score:UA(h,o),ranges:[]});continue}let p=0,m=[],v=!0;for(const _ of a){const x=bJ(h,_);if(x.score===0){v=!1;break}p+=x.score,m=m.concat(x.ranges)}v&&u.push({session:h,score:p+UA(h,o),ranges:xJ(m)})}return u.sort((h,p)=>p.score-h.score||p.session.updatedAt-h.session.updatedAt),u.slice(0,r)}function wJ(t,e=Date.now()){const i=e-t;return i<6e4?"just now":i<60*6e4?`${Math.floor(i/6e4)}m ago`:i<yc?`${Math.floor(i/(60*6e4))}h ago`:i<2*yc?"yesterday":i<7*yc?`${Math.floor(i/yc)}d ago`:new Date(t).toLocaleDateString(void 0,{day:"numeric",month:"short"})}const SJ=8;function kJ({projectPath:t,onResume:e}){const[i,n]=w.useState(!1),[s,r]=w.useState(""),[o,a]=w.useState("all"),[u,h]=w.useState(!0),[p,m]=w.useState(null),[v,_]=w.useState(null),[x,S]=w.useState(0),C=w.useRef(null);w.useEffect(()=>{let N=!0;return fD().then(j=>{N&&(m(j),_(null))},j=>{N&&(m([]),_(j.message))}),()=>{N=!1}},[]);const k=w.useMemo(()=>VA(p??[],s,{agent:o==="all"?void 0:o,cwd:u?t:void 0,limit:40}),[p,s,o,u,t]),M=w.useMemo(()=>!u||k.length>0||!p?0:VA(p,s,{agent:o==="all"?void 0:o,limit:40}).length,[u,k.length,p,s,o]);if(w.useEffect(()=>S(0),[s,o,u]),w.useEffect(()=>{C.current?.querySelector(".is-on")?.scrollIntoView({block:"nearest"})},[x]),!i)return d.jsxs("button",{className:"resume-open",type:"button",onClick:()=>n(!0),children:[d.jsx(MJ,{}),"Resume an earlier session",p&&p.length>0&&d.jsx("span",{className:"resume-count",children:d.jsx(us,{value:p.length})})]});const L=N=>S(j=>Math.min(Math.max(j+N,0),k.length-1));return d.jsxs("div",{className:"resume",children:[d.jsxs("div",{className:"resume-bar",children:[d.jsx("input",{className:"resume-input",value:s,autoFocus:!0,type:"search",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",placeholder:"Search Claude and Codex sessions",onChange:N=>r(N.target.value),onKeyDown:N=>{N.key==="ArrowDown"?(N.preventDefault(),L(1)):N.key==="ArrowUp"?(N.preventDefault(),L(-1)):N.key==="Enter"&&k[x]?(N.preventDefault(),e(k[x].session),n(!1)):N.key==="Escape"&&(N.preventDefault(),s?r(""):n(!1))}}),d.jsx("button",{className:"resume-close",type:"button",title:"Close the search",onClick:()=>n(!1),children:"✕"})]}),d.jsxs("div",{className:"resume-chips",children:[["all","claude","codex"].map(N=>d.jsx("button",{type:"button",className:`resume-chip ${o===N?"is-on":""}`,onClick:()=>a(N),children:N==="all"?"Both":N==="claude"?"Claude":"Codex"},N)),t&&d.jsx("button",{type:"button",className:`resume-chip is-scope ${u?"is-on":""}`,title:u?`Only sessions from ${t}`:"Sessions from every folder",onClick:()=>h(N=>!N),children:"This project"})]}),d.jsxs("div",{className:"resume-list",ref:C,style:{maxHeight:`${SJ*52}px`},children:[p===null&&d.jsx("div",{className:"resume-msg",children:"Reading what the agents remember…"}),v&&d.jsx("div",{className:"resume-msg is-bad",children:v}),p!==null&&!v&&k.length===0&&d.jsx("div",{className:"resume-msg",children:M>0?d.jsxs(d.Fragment,{children:["Nothing here."," ",d.jsx("button",{className:"resume-link",type:"button",onClick:()=>h(!1),children:d.jsx(ct,{children:`${M} in other folders`})})]}):"No session matches."}),k.map((N,j)=>d.jsxs("button",{type:"button",className:`resume-row ${j===x?"is-on":""}`,onMouseEnter:()=>S(j),onClick:()=>{e(N.session),n(!1)},children:[d.jsx("span",{className:`resume-tag is-${N.session.agent}`,children:N.session.agent==="claude"?"Claude":"Codex"}),d.jsxs("span",{className:"resume-main",children:[d.jsx("span",{className:"resume-title",children:d.jsx(CJ,{text:N.session.title,ranges:N.ranges})}),d.jsxs("span",{className:"resume-where",children:[d.jsx("bdi",{children:mD(N.session.cwd)||N.session.cwd}),N.session.model&&d.jsx("span",{className:"resume-dot",children:"·"}),N.session.model&&EJ(N.session.model),N.session.effort&&d.jsx("span",{className:"resume-dot",children:"·"}),N.session.effort]})]}),d.jsx("span",{className:"resume-when",children:d.jsx(ct,{children:wJ(N.session.updatedAt)})})]},`${N.session.agent}:${N.session.sessionId}`))]}),d.jsxs("div",{className:"resume-foot",children:[d.jsx("span",{children:"Picking one carries on that conversation, with its own model and effort."}),d.jsx("button",{className:"resume-link",type:"button",onClick:()=>{m(null),_(null),pJ().then(N=>m(N),N=>{m([]),_(N.message)})},children:"Look again"})]})]})}function CJ({text:t,ranges:e}){if(e.length===0)return d.jsx(d.Fragment,{children:t});const i=[];let n=0;for(const[s,r]of e){if(s>=t.length)break;s>n&&i.push(t.slice(n,s)),i.push(d.jsx("mark",{className:"resume-mark",children:t.slice(s,Math.min(r,t.length))},s)),n=Math.min(r,t.length)}return n<t.length&&i.push(t.slice(n)),d.jsx(d.Fragment,{children:i})}function EJ(t){const e=t.match(/(opus|sonnet|haiku|fable)/i);if(e)return e[1].toLowerCase();const i=t.match(/^(gpt-[\d.]+)/i);return i?i[1].toLowerCase():t}function MJ(){return d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),d.jsx("path",{d:"M3 3v5h5"}),d.jsx("path",{d:"M12 7v5l3 2"})]})}function gD(t){if(t.parent||t.relay)return;const e=t.blocks.flatMap(i=>i.kind==="text"?[i.text]:[]).join(`
|
|
78
|
+
`).trim()||(t.attachments?.length?"[Attachment]":"");if(e)return{id:t.id,speaker:t.role==="user"?"You":t.speaker?.name??"Assistant",text:e.length>420?`${e.slice(0,420).trimEnd()}…`:e}}function AJ(t){const e=[];for(let i=t.length-1;i>=0&&e.length<3;i--){const n=t[i],s=gD(n);s&&e.unshift(s)}return e}function Sb(t){for(let e=t.length-1;e>=0;e--){if(t[e].role==="user")continue;const i=gD(t[e]);if(i)return i}}async function LJ(t,e,i){const n=await t();if(i())return[];if(!n.events.length)return e;let s=await wc(Tc(),n.context,0,i);return s=await wc(s,n.events,0,i),s.messages}function TJ(t,e){const i=new Map(t.map((a,u)=>[a.id,{chat:a,children:[],descendants:[],rank:u}])),n=new Map;for(const a of t){const u=e.get(a.id);if(!u||u===a.id||!i.has(u))continue;let h=u;for(;h&&h!==a.id;)h=n.get(h);h||n.set(a.id,u)}const s=[];for(const a of i.values()){const u=n.get(a.chat.id);u?i.get(u).children.push(a):s.push(a)}const r=a=>i.get(a.chat.id).rank,o=a=>{a.children.forEach(o),a.children.sort((u,h)=>r(u)-r(h)),a.descendants=a.children.flatMap(u=>[u.chat,...u.descendants]);for(const u of a.children)i.get(a.chat.id).rank=Math.min(r(a),r(u))};return s.forEach(o),s.sort((a,u)=>r(a)-r(u))}const KA=["#f87171","#fb923c","#fbbf24","#a3e635","#34d399","#22d3ee","#60a5fa","#a78bfa","#f472b6","#94a3b8"];function YA(t){const e=t.trim();if(!e)return"";const i=e.startsWith("#")?e.slice(1):e;return/^[0-9a-f]{6}$/i.test(i)?`#${i.toLowerCase()}`:null}function FS(t){const e=t.color?.trim();if(e&&/^#[0-9a-f]{6}$/i.test(e))return e;const i=t.name||t.id;let n=0;for(let s=0;s<i.length;s+=1)n=n*31+i.charCodeAt(s)>>>0;return KA[n%KA.length]}const D0={runs:[],tasks:[],attempts:[],gates:[],messages:[]};function NJ(t){const e=new Map(t.runs.map(n=>[n.id,n.coordinatorChatKey])),i=new Map;for(const n of t.attempts){const s=e.get(n.runId);if(!s?.startsWith("chat:")||!n.workerChatKey.startsWith("chat:"))continue;const r=n.workerChatKey.slice(5),o=s.slice(5);r&&o&&r!==o&&i.set(r,o)}return i}function Pg(t,e){return!!t&&(t.startsWith("orch-")||e.has(t))}function GA(t,e){if(!t||!e.has(t))return null;const i=new Set([t]);let n=e.get(t);for(;e.has(n);){if(i.has(n))return null;i.add(n),n=e.get(n)}return i.has(n)?null:n}function jJ({deleting:t,disabled:e=!1,deleteMs:i,onDelete:n}){const s=t?"Cancel delete":"Delete this chat";return d.jsxs("button",{className:`icon-btn topbar-delete ${t?"is-going":""}`,type:"button","aria-label":s,title:s,disabled:e,onClick:n,children:[t?d.jsx(vD,{ms:i}):d.jsx(RJ,{}),d.jsx("span",{className:"topbar-action-label",children:s})]})}function vD({ms:t}){return d.jsxs("svg",{className:"chat-drain",width:"17",height:"17",viewBox:"0 0 16 16","aria-hidden":"true",children:[d.jsx("circle",{className:"chat-drain-track",cx:"8",cy:"8",r:"6.6"}),d.jsx("circle",{className:"chat-drain-arc",cx:"8",cy:"8",r:"6.6",style:{animationDuration:`${t}ms`}}),d.jsx("path",{className:"chat-drain-x",d:"M9.9 6.1 6.1 9.9M6.1 6.1l3.8 3.8"})]})}function RJ(){return d.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M4 7h16"}),d.jsx("path",{d:"M9 7V4h6v3"}),d.jsx("path",{d:"m6 7 1 13h10l1-13"}),d.jsx("path",{d:"M10 11v5M14 11v5"})]})}function DJ({chat:t,enabled:e,busy:i,getPreviewMessages:n,loadPreview:s,...r}){const o=w.useRef(null),a=w.useRef(void 0),[u,h]=w.useState(!1),p=w.useId(),m=()=>{clearTimeout(a.current),a.current=void 0},v=()=>{m(),h(!1)},_=()=>{m(),e&&(a.current=setTimeout(()=>h(!0),1500))},x=()=>{m(),a.current=setTimeout(()=>h(!1),160)};return w.useEffect(()=>(e||(clearTimeout(a.current),h(!1)),()=>clearTimeout(a.current)),[e]),w.useEffect(()=>{const S=C=>{C.key==="Escape"&&v()};return u&&document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[u]),d.jsxs(d.Fragment,{children:[d.jsx("button",{...r,ref:o,"aria-describedby":u&&e?p:void 0,onPointerEnter:S=>{S.pointerType==="mouse"&&_()},onPointerLeave:x,onFocus:S=>{S.currentTarget.matches(":focus-visible")&&_()},onBlur:v,onClick:S=>{v(),r.onClick?.(S)}}),u&&e&&d.jsx(BJ,{id:p,chat:t,anchor:o.current,messages:n?.(t.id),loadPreview:s,busy:i,onEnter:m,onLeave:x,onClose:v},t.id)]})}function BJ({id:t,chat:e,anchor:i,messages:n,loadPreview:s,busy:r,onEnter:o,onLeave:a,onClose:u}){const h=w.useRef(null),[p,m]=w.useState(e.messages),[v,_]=w.useState(n===void 0&&s?"loading":"ready"),[x,S]=w.useState({left:0,top:0}),C=n!==void 0;w.useEffect(()=>{if(C||!s){_("ready");return}let M=!1;_("loading");const L=setTimeout(()=>{M=!0,_("error")},8e3);return s(e,()=>M).then(N=>{M||(m(N),_("ready"))}).catch(()=>{M||_("error")}).finally(()=>clearTimeout(L)),()=>{M=!0,clearTimeout(L)}},[e.id,C,s]),w.useLayoutEffect(()=>{const M=()=>{const j=(i.closest(".chat")??i).getBoundingClientRect(),R=h.current.getBoundingClientRect(),z=j.right+12,J=z+R.width<=window.innerWidth-12?z:j.left-R.width-12;S({left:Math.max(12,Math.min(J,window.innerWidth-R.width-12)),top:Math.max(12,Math.min(j.top,window.innerHeight-R.height-12))})};M();const L=new ResizeObserver(M);L.observe(h.current),window.addEventListener("resize",u);const N=j=>{h.current?.contains(j.target)||u()};return document.addEventListener("scroll",N,!0),()=>{L.disconnect(),window.removeEventListener("resize",u),document.removeEventListener("scroll",N,!0)}},[i,u]);const k=AJ(n??p);return bl.createPortal(d.jsxs("div",{ref:h,id:t,role:"tooltip",className:"chat-preview",style:x,onPointerEnter:o,onPointerLeave:a,children:[d.jsxs("div",{className:"chat-preview-head",children:[d.jsx("strong",{children:e.title}),r&&d.jsx("span",{children:"Working…"})]}),d.jsx("div",{className:"chat-preview-label",children:"Latest conversation"}),k.map(M=>d.jsxs("div",{className:"chat-preview-message",children:[d.jsx("span",{children:M.speaker}),d.jsx("p",{children:M.text})]},M.id)),v==="loading"&&d.jsx("p",{className:"chat-preview-note",children:"Loading latest messages…"}),v==="error"&&d.jsx("p",{className:"chat-preview-note",children:"Preview unavailable. Open the chat to try again."}),v==="ready"&&!k.length&&d.jsx("p",{className:"chat-preview-note",children:"No messages yet."}),d.jsx("div",{className:"chat-preview-foot",children:"Click chat to open · Use ••• for actions"})]}),document.body)}function OJ(t){const e=[...(t.initial??"").trim()].slice(0,2).join("");return e?e.toLocaleUpperCase():[...t.name.trim()][0]?.toLocaleUpperCase()??"?"}function np({project:t,size:e="small",className:i=""}){const n=t.icon?.trim(),s={"--project-color":FS(t)};return d.jsx("span",{className:["project-avatar",`is-${e}`,n?"has-icon":"",i].filter(Boolean).join(" "),style:s,"aria-hidden":"true",children:n?d.jsx("img",{className:"project-avatar-image",src:n,alt:""}):d.jsx("span",{className:"project-avatar-text",children:OJ(t)})})}function QA({label:t,items:e,open:i,onOpenChange:n,className:s="",disabled:r=!1,icon:o}){const a=w.useRef(null),u=w.useId();return d.jsxs(d.Fragment,{children:[d.jsx("button",{ref:a,className:`sidebar-menu-trigger ${s}`,type:"button","aria-label":t,title:t,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?u:void 0,disabled:r,onClick:h=>{h.currentTarget.focus(),n(!i)},onKeyDown:h=>{(h.key==="ArrowDown"||h.key==="ArrowUp")&&(h.preventDefault(),n(!0))},children:o??d.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[d.jsx("circle",{cx:"5",cy:"12",r:"1.7"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.7"}),d.jsx("circle",{cx:"19",cy:"12",r:"1.7"})]})}),i&&!r&&d.jsx(IJ,{id:u,label:t,anchor:a,items:e,onClose:()=>n(!1)})]})}function IJ({id:t,label:e,anchor:i,items:n,onClose:s}){const r=w.useRef(null),o=w.useRef(!1),a=w.useRef(s);a.current=s,w.useLayoutEffect(()=>{const h=r.current,p=i.current;p.focus({preventScroll:!0}),h.showModal(),h.querySelector("button:not(:disabled)")?.focus({preventScroll:!0});const m=()=>{const S=p.getBoundingClientRect(),C=window.visualViewport,k=C?.offsetLeft??0,M=C?.offsetTop??0,L=C?.width??window.innerWidth,N=C?.height??window.innerHeight,j=h.getBoundingClientRect();h.style.left=`${Math.max(k+8,Math.min(S.right-j.width,k+L-j.width-8))}px`;const R=S.bottom+4,z=R+j.height<=M+N-8?R:S.top-j.height-4;h.style.top=`${Math.max(M+8,Math.min(z,M+N-j.height-8))}px`};m();const v=new ResizeObserver(m);v.observe(h);const _=()=>a.current(),x=S=>{(!(S.target instanceof Node)||!h.contains(S.target))&&_()};return window.addEventListener("resize",_),window.addEventListener("scroll",x,!0),window.visualViewport?.addEventListener("resize",_),()=>{v.disconnect(),h.close(),window.removeEventListener("resize",_),window.removeEventListener("scroll",x,!0),window.visualViewport?.removeEventListener("resize",_)}},[i]);const u=()=>{r.current?.close(),s()};return bl.createPortal(d.jsx("dialog",{ref:r,id:t,className:"sidebar-dropdown",role:"menu","aria-label":e,onCancel:h=>{h.preventDefault(),u()},onPointerDown:h=>{o.current=h.target===h.currentTarget},onClick:h=>{o.current&&h.target===h.currentTarget&&u(),o.current=!1},onKeyDown:h=>{if(h.key==="Tab"){u();return}if(!["ArrowDown","ArrowUp","Home","End"].includes(h.key))return;h.preventDefault();const p=[...h.currentTarget.querySelectorAll("button:not(:disabled)")],m=p.indexOf(document.activeElement),v=h.key==="Home"?0:h.key==="End"?p.length-1:(m+(h.key==="ArrowDown"?1:-1)+p.length)%p.length;p[v]?.focus()},children:n.map(h=>d.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,className:h.danger?"is-danger":void 0,disabled:h.disabled,onClick:()=>{h.keepOpen||u(),h.onSelect()},children:[h.icon,d.jsx("span",{children:h.label})]},h.id))}),document.body)}const XA=new Set,PJ=new Map,_D="octiq.chat.collapsed-agents";function zJ(){try{const t=JSON.parse(jr(_D)??"[]");return new Set(Array.isArray(t)?t.filter(e=>typeof e=="string"):[])}catch{return new Set}}function $J({projects:t,shelved:e,onShowShelved:i,deletedCount:n=0,onShowDeleted:s,conversations:r,currentConversation:o,running:a,busy:u,deleting:h=XA,leaving:p=XA,deleteMs:m=2e3,onPickConversation:v,getPreviewMessages:_,loadPreview:x,onNewChat:S,onDelete:C,onPin:k,onRename:M,onNewProject:L,searchChats:N,branches:j={},chatParents:R=PJ,onResize:z,foot:J}){const[G,q]=w.useState(zJ),[X,I]=w.useState(!1),[T,H]=w.useState(null),[F,P]=w.useState(null),[U,V]=w.useState(""),[K,D]=w.useState([]),[$,Y]=w.useState("idle"),B=w.useRef(void 0),ee=w.useRef({x:0,y:0}),ie=w.useRef(!1),re=w.useRef(new Set(r.map(ve=>ve.id))),ge=[...t,...e],Ee=new Map(ge.map(ve=>[ve.id,ve])),fe=new Map(r.map(ve=>[ve.id,ve])),Pe=U.trim(),De=[...Pe].length>=2,He=new Map(K.map(ve=>[ve.id,ve])),_e=De&&$==="ready"?K.flatMap(ve=>{const fi=fe.get(ve.id);return fi?[fi]:[]}):De?[]:r,Le=w.useMemo(()=>TJ(r,R),[r,R]),jt=De?_e.map(ve=>({chat:ve,children:[],descendants:[]})):Le,di=new Set;let xt=o?R.get(o):void 0;for(;xt&&!di.has(xt);)di.add(xt),xt=R.get(xt);const be=JSON.stringify([...di]);w.useEffect(()=>{const ve=JSON.parse(be);q(fi=>ve.some(Mt=>fi.has(Mt))?new Set([...fi].filter(Mt=>!ve.includes(Mt))):fi)},[o,be]),w.useEffect(()=>{ri(_D,JSON.stringify([...G]))},[G]),w.useEffect(()=>{re.current=new Set(r.map(ve=>ve.id))},[r]),w.useEffect(()=>()=>clearTimeout(B.current),[]),w.useEffect(()=>{if(!De){D([]),Y("idle");return}let ve=!0;D([]),Y("searching");const fi=setTimeout(()=>{N(Pe).then(Mt=>{ve&&(D(Mt),Y("ready"))}).catch(()=>{ve&&(D([]),Y("error"))})},180);return()=>{ve=!1,clearTimeout(fi)}},[De,N,Pe]);const We=()=>clearTimeout(B.current),Ze=({chat:ve,children:fi,descendants:Mt})=>{const Kt=!G.has(ve.id),gn=Mt.filter(st=>u.has(st.id)).length,de=Mt.filter(st=>lx(st,o)).length,Me=`chat-agents-${ve.id}`,Ke=fe.get(R.get(ve.id)??""),Je=h.has(ve.id),ot=p.has(ve.id),Gt=lx(ve,o),wt=Ee.get(ve.projectId),pt=wt?{"--chat-project-color":FS(wt)}:void 0,Ht=wt?.name??"Unknown project",gi=j[ve.projectId],Tt=gi?`${Ht} | ${gi}`:Ht,vi=qu(ve.modelId??null),Qt=De?He.get(ve.id):void 0,vs=Sb(_?.(ve.id)??ve.messages),lr=Je?"Deleting…":Qt?`${Qt.speaker}: ${Qt.excerpt}`:vs?.text??ve.latestResponse??(u.has(ve.id)?"Working…":"No response yet");return d.jsxs(HJ,{entering:!re.current.has(ve.id),leaving:ot,children:[d.jsxs("div",{className:["chat",ve.id===o?"is-on":"",a.has(ve.id)?"is-live":"",u.has(ve.id)?"is-busy":"",Je?"is-going":"",ot?"is-leaving":"",ve.pinned?"is-pinned":"",T===ve.id?"is-renaming":"",Gt?"is-unread":""].filter(Boolean).join(" "),style:pt,children:[T===ve.id?d.jsx("form",{className:"chat-rename",onSubmit:st=>{st.preventDefault();const Yt=st.currentTarget.elements.namedItem("chat-title");Yt instanceof HTMLInputElement&&Yt.value.trim()&&M(ve.id,Yt.value),H(null)},children:d.jsx("input",{name:"chat-title",className:"chat-rename-input",defaultValue:ve.title,"aria-label":"Chat title",maxLength:48,autoFocus:!0,onFocus:st=>st.currentTarget.select(),onBlur:st=>{st.currentTarget.value.trim()&&M(ve.id,st.currentTarget.value),H(null)},onKeyDown:st=>{st.key==="Escape"&&(st.preventDefault(),H(null))}})}):d.jsx(DJ,{chat:ve,enabled:!Je&&!ot&&!F,busy:u.has(ve.id),getPreviewMessages:_,loadPreview:x,className:"chat-btn",type:"button","aria-label":`${Gt?"Unread, ":""}${ve.title}, ${Ht}${gi?`, branch ${gi}`:""}${vi?`, ${vi.name} ${vi.model}`:""}`,disabled:ot,"aria-current":ve.id===o?"page":void 0,"aria-description":`${Ke?`Agent chat under ${Ke.title}. `:""}Hover to preview. Hold for chat actions.`,onPointerDown:st=>{We(),ie.current=!1,!(st.pointerType==="mouse"||Je||ot||!window.matchMedia("(max-width: 859.98px), (pointer: coarse)").matches)&&(ee.current={x:st.clientX,y:st.clientY},B.current=setTimeout(()=>{ie.current=!0,P(ve.id)},500))},onPointerMove:st=>{Math.hypot(st.clientX-ee.current.x,st.clientY-ee.current.y)>10&&We()},onPointerUp:We,onPointerCancel:We,onContextMenu:st=>{window.matchMedia("(max-width: 859.98px), (pointer: coarse)").matches&&(st.preventDefault(),We(),!Je&&!ot&&P(ve.id))},onClick:()=>{if(ie.current){ie.current=!1;return}v(ve)},children:d.jsxs("span",{className:"chat-summary",children:[d.jsxs("span",{className:"chat-heading",children:[Gt&&d.jsx("span",{className:"chat-unread-dot","aria-hidden":"true"}),d.jsx("span",{className:"chat-title",children:ve.title}),d.jsx("time",{className:"chat-time",dateTime:new Date(ve.updatedAt).toISOString(),title:new Date(ve.updatedAt).toLocaleString(),children:FJ(ve.updatedAt)})]}),d.jsx("span",{className:"chat-snippet",children:lr.replace(/\s+/g," ")}),d.jsxs("span",{className:"chat-meta",children:[d.jsxs("span",{className:"chat-project",children:[wt?d.jsx(np,{project:wt,size:"tiny"}):d.jsx("span",{className:"project-avatar is-tiny","aria-hidden":"true",children:"?"}),d.jsx("span",{className:"chat-project-name",title:Tt,children:Tt})]}),vi&&d.jsxs("span",{className:"chat-model",title:`Active model: ${vi.name} · ${vi.model}`,children:[d.jsx(o0,{agent:vi.agent,size:10}),d.jsx("span",{children:vi.model})]})]})]})}),d.jsxs("span",{className:"chat-indicators",children:[ve.pinned&&d.jsx("span",{className:"chat-mobile-pin",title:"Pinned","aria-label":"Pinned",children:d.jsx(eL,{})}),d.jsx("span",{className:"chat-mark","aria-hidden":"true",title:u.has(ve.id)?"working":a.has(ve.id)?"session running":void 0})]}),T!==ve.id&&d.jsx(QA,{className:"chat-actions-trigger",label:`Actions for ${ve.title}`,open:F===ve.id,onOpenChange:st=>P(st?ve.id:null),disabled:ot,icon:Je?d.jsx(vD,{ms:m}):void 0,items:[{id:"rename",label:"Rename chat",icon:d.jsx(VJ,{}),disabled:Je,onSelect:()=>H(ve.id)},{id:"pin",label:ve.pinned?"Unpin chat":"Pin chat",icon:d.jsx(eL,{}),disabled:Je,onSelect:()=>k(ve.id)},...Pg(ve.id,R)?[]:[{id:"delete",label:Je?"Cancel delete":"Delete chat",icon:d.jsx(JA,{}),danger:!0,keepOpen:!Je,onSelect:()=>C(ve.id)}]]}),fi.length>0&&d.jsxs("button",{className:"chat-children-toggle",type:"button","aria-label":`${Kt?"Collapse":"Expand"} agent chats for ${ve.title}`,"aria-expanded":Kt,"aria-controls":Me,disabled:ot,onClick:()=>q(st=>{const Yt=new Set(st);return Yt.has(ve.id)?Yt.delete(ve.id):Yt.add(ve.id),Yt}),children:[d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"m9 5 7 7-7 7"})}),d.jsxs("span",{children:[Mt.length," ",Mt.length===1?"agent":"agents"]}),gn>0&&d.jsxs("span",{className:"chat-children-working",children:[gn," working"]}),de>0&&d.jsxs("span",{className:"chat-children-unread",children:[de," unread"]})]})]}),fi.length>0&&d.jsx("ul",{className:"chat-children",id:Me,"aria-label":`Agent chats for ${ve.title}`,hidden:!Kt,children:Kt&&fi.map(Ze)})]},ve.id)};return d.jsxs("nav",{className:"sidebar task-sidebar","aria-label":"Chats",children:[d.jsxs("div",{className:"sidebar-toolbar",children:[d.jsxs("div",{className:"sidebar-head",children:[d.jsx("span",{className:"sidebar-title",children:"Chats"}),d.jsxs("button",{className:"sidebar-new-chat",type:"button",onClick:S,children:[d.jsx(ZA,{}),d.jsx("span",{children:"New chat"})]}),d.jsx(QA,{label:"Chat list actions",open:X,onOpenChange:I,items:[{id:"new-project",label:"New project",icon:d.jsx(ZA,{}),onSelect:L},...e.length?[{id:"shelved",label:`Shelved projects (${e.length})`,icon:d.jsx(UJ,{}),onSelect:i}]:[],...n&&s?[{id:"trash",label:`Deleted chats (${n})`,icon:d.jsx(JA,{}),onSelect:s}]:[]]})]}),d.jsx("div",{className:"sidebar-search-wrap",children:d.jsxs("label",{className:"sidebar-search",children:[d.jsx(WJ,{}),d.jsx("input",{type:"search",value:U,placeholder:"Search chats","aria-label":"Search chats",autoComplete:"off",spellCheck:!1,onChange:ve=>V(ve.target.value),onKeyDown:ve=>{ve.key!=="Escape"||!U||(ve.preventDefault(),V(""))}}),U&&d.jsx("button",{type:"button","aria-label":"Clear chat search",onClick:()=>V(""),children:d.jsx(qJ,{})})]})})]}),r.length?De&&$!=="ready"?d.jsxs("div",{className:"sidebar-empty",role:"status","aria-live":"polite",children:[d.jsx("span",{children:$==="error"?"Chat search is unavailable.":"Searching chats…"}),$==="error"&&d.jsx("button",{type:"button",onClick:()=>V(""),children:"Clear search"})]}):_e.length?d.jsx("ul",{className:"chat-list task-chat-list",children:jt.map(Ze)}):d.jsxs("div",{className:"sidebar-empty",role:"status","aria-live":"polite",children:[d.jsxs("span",{children:["No chats found for “",Pe,"”."]}),d.jsx("button",{type:"button",onClick:()=>V(""),children:"Clear search"})]}):d.jsxs("div",{className:"sidebar-empty",children:[d.jsx("span",{children:"No chats yet"}),d.jsx("button",{type:"button",onClick:S,children:"Start your first chat"})]}),J&&d.jsx("div",{className:"sidebar-slot is-foot",children:J}),z&&d.jsx("span",{className:"nav-resizer",onPointerDown:z,role:"separator","aria-orientation":"vertical","aria-label":"Resize the chat column"})]})}function FJ(t){const e=new Date(t),i=new Date;return e.toDateString()===i.toDateString()?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):(i.setDate(i.getDate()-1),e.toDateString()===i.toDateString()?"Yesterday":e.toLocaleDateString([],{month:"short",day:"numeric",...e.getFullYear()!==i.getFullYear()?{year:"numeric"}:{}}))}function HJ({entering:t,leaving:e,children:i}){const[n,s]=w.useState(()=>t&&!(typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches));return w.useEffect(()=>{if(!n)return;const r=requestAnimationFrame(()=>s(!1));return()=>cancelAnimationFrame(r)},[n]),d.jsx("li",{className:["chat-row",n?"is-entering":"",e?"is-leaving":""].filter(Boolean).join(" "),children:d.jsx("div",{className:"chat-row-content",children:i})})}function WJ(){return d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[d.jsx("circle",{cx:"11",cy:"11",r:"7"}),d.jsx("path",{d:"m20 20-4-4"})]})}function qJ(){return d.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:d.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})}function ZA(){return d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:d.jsx("path",{d:"M12 5v14M5 12h14"})})}function UJ(){return d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M4 7h16"}),d.jsx("path",{d:"M6 7v12h12V7"}),d.jsx("path",{d:"M3 4h18v3H3z"}),d.jsx("path",{d:"M10 11h4"})]})}function JA(){return d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M3 6h18"}),d.jsx("path",{d:"M8 6V4h8v2"}),d.jsx("path",{d:"m6 6 1 14h10l1-14"}),d.jsx("path",{d:"M10 10v6M14 10v6"})]})}function eL(){return d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M12 17v5"}),d.jsx("path",{d:"M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"})]})}function VJ(){return d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M12 20h9"}),d.jsx("path",{d:"M16.5 3.5a2.1 2.1 0 0 1 3 3L8 18l-4 1 1-4Z"})]})}async function KJ(t=!1){return await he.invoke("agent_installs",{refresh:t})}function YJ({projects:t,onRestored:e,onClose:i}){const[n,s]=w.useState(null),[r,o]=w.useState(null),[a,u]=w.useState(new Set),[h]=w.useState(t),p=async m=>{if(!(n||a.has(m.id))){s(m.id),o(null);try{await he.invoke("set_workspace_shelved",{id:m.id,shelved:!1}),u(v=>new Set(v).add(m.id)),e()}catch(v){o(String(v.message??v))}finally{s(null)}}};return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"panel-scrim",onClick:i}),d.jsxs("aside",{className:"panel",role:"dialog","aria-label":"Shelved projects",children:[d.jsxs("header",{className:"panel-head",children:[d.jsxs("div",{className:"panel-id",children:[d.jsx("div",{className:"panel-name",children:"Shelved projects"}),d.jsx("div",{className:"shelf-sub",children:d.jsx(ct,{children:`${h.length-a.size} put away · tap one to bring it back`})})]}),d.jsx("button",{className:"panel-close",type:"button",onClick:i,"aria-label":"Close",children:"×"})]}),r&&d.jsx("div",{className:"shelf-error",children:r}),d.jsx("div",{className:"shelf-grid",children:h.map(m=>{const v=a.has(m.id);return d.jsxs("button",{className:`shelf-card ${v?"is-done":""}`,type:"button",disabled:!!n||v,onClick:()=>{p(m)},children:[d.jsxs("span",{className:"shelf-card-head",children:[d.jsx(np,{project:m,size:"medium"}),d.jsx("span",{className:"shelf-card-name",children:m.name})]}),m.primary_path&&d.jsx("span",{className:"shelf-card-path",children:d.jsx("bdi",{children:m.primary_path})}),m.description&&d.jsx("span",{className:"shelf-card-desc",children:m.description}),d.jsx("span",{className:"shelf-card-act",children:v?"Back in the list":n===m.id?"Bringing back…":"Bring back"})]},m.id)})})]})]})}const GJ=1440*60*1e3;function QJ(t,e=Date.now()){const i=Math.max(0,Math.ceil((t+GJ-e)/6e4));return i>=120?`${Math.ceil(i/60)}h left`:i>=60?`1h ${i-60}m left`:`${i}m left`}function XJ({chats:t,projects:e,onRestore:i,onClose:n}){const[s,r]=w.useState(null),[o,a]=w.useState(null),[u,h]=w.useState(new Set),[p]=w.useState(t),m=new Map(e.map(_=>[_.id,_.name])),v=async _=>{if(!(s||u.has(_.id))){r(_.id),a(null);try{await i(_),h(x=>new Set(x).add(_.id))}catch(x){a(String(x.message??x))}finally{r(null)}}};return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"panel-scrim",onClick:n}),d.jsxs("aside",{className:"panel",role:"dialog","aria-label":"Deleted chats",children:[d.jsxs("header",{className:"panel-head",children:[d.jsxs("div",{className:"panel-id",children:[d.jsx("div",{className:"panel-name",children:"Deleted chats"}),d.jsx("div",{className:"shelf-sub",children:d.jsx(ct,{children:`${p.length-u.size} restorable · permanently deleted after 24 hours`})})]}),d.jsx("button",{className:"panel-close",type:"button",onClick:n,"aria-label":"Close",children:"×"})]}),o&&d.jsx("div",{className:"shelf-error",children:o}),d.jsx("div",{className:"shelf-grid",children:p.map(_=>{const x=u.has(_.id);return d.jsxs("button",{className:`shelf-card ${x?"is-done":""}`,type:"button",disabled:!!s||x,onClick:()=>{v(_)},children:[d.jsx("span",{className:"shelf-card-name",children:_.title||"New chat"}),d.jsxs("span",{className:"trash-card-meta",children:[m.get(_.projectId)??"Unknown project"," · ",QJ(_.deletedAt)]}),d.jsx("span",{className:"shelf-card-act",children:x?"Back in the list":s===_.id?"Restoring…":"Restore chat"})]},_.id)})})]})]})}function yD(t,e){for(let i=t.length-1;i>=0;i-=1)if(e(t[i]))return i;return-1}function kb(t,e){const i=new Map(t.map(r=>[r.id,r]));if(!i.has(e))return new Set;const n=new Set([e]);let s=!0;for(;s;){s=!1;for(const r of t){if(n.has(r.id))continue;const o=(r.sibling_ids??[]).some(u=>n.has(u)),a=[...n].some(u=>(i.get(u)?.sibling_ids??[]).includes(r.id));(o||a)&&(n.add(r.id),s=!0)}}return n}function ZJ(t,e,i,n){const s=t.map(p=>p.id),r=kb(t,e),o=kb(t,i);if(!r.size||!o.size||r.has(i))return s;const a=s.filter(p=>r.has(p)),u=s.filter(p=>!r.has(p)),h=n==="before"?u.findIndex(p=>o.has(p)):yD(u,p=>o.has(p));return h<0?s:(u.splice(h+(n==="after"?1:0),0,...a),u)}function JJ(t,e,i){const n=t.map(o=>o.id),s=kb(t,e);if(!s.size)return n;const r=i===-1?n.findIndex(o=>s.has(o))-1:yD(n,o=>s.has(o))+1;return r<0||r>=n.length?n:ZJ(t,e,n[r],i===-1?"before":"after")}function eee(t){return Object.entries(t??{}).sort(([e],[i])=>e.localeCompare(i)).map(([e,i])=>`${e}=${i}`).join(`
|
|
79
|
+
`)}function tee(t){const e={};for(const i of t.split(`
|
|
80
|
+
`)){const n=i.trim();if(!n||n.startsWith("#"))continue;const s=n.indexOf("="),r=(s===-1?n:n.slice(0,s)).trim(),o=s===-1?"":n.slice(s+1).trim();r&&(e[r]=o)}return e}function iee(t,e){const i=Object.keys(t),n=Object.keys(e);return i.length!==n.length?!1:i.every(s=>t[s]===e[s])}const nee=600,see=512*1024,ree=new Set(["image/png","image/jpeg","image/webp"]);function oee(t){return new Promise((e,i)=>{const n=new FileReader;n.onload=()=>typeof n.result=="string"?e(n.result):i(new Error("Could not read that image.")),n.onerror=()=>i(n.error??new Error("Could not read that image.")),n.readAsDataURL(t)})}function lee({project:t,projects:e,onChanged:i,onClose:n,onDeleted:s,backToSettings:r=!1}){const o=!t,[a,u]=w.useState(t?.name??""),[h,p]=w.useState(t?.description??""),[m,v]=w.useState(t?.initial??""),[_,x]=w.useState(t?.icon??""),[S,C]=w.useState(t?.color??""),[k,M]=w.useState(eee(t?.env)),[L,N]=w.useState(null),[j,R]=w.useState(!1),[z,J]=w.useState(null),[G,q]=w.useState(""),[X,I]=w.useState(""),T=w.useRef(null),H=lS(),F=t?.primary_path??"",P=t?.paths??[],U=new Set(t?.sibling_ids??[]),V=e.filter(_e=>U.has(_e.id)),K=e.filter(_e=>_e.id!==t?.id&&!U.has(_e.id)),D=t?e.filter(_e=>!!_e.shelved==!!t.shelved):[],$=t?D.findIndex(_e=>_e.id===t.id):-1,Y=YA(S),B=Y===null,ee=FS({id:t?.id??"new",name:a.trim()||t?.name||"project",color:B?t?.color:Y}),ie=async _e=>{R(!0),N(null);try{return await _e(),i(),!0}catch(Le){return N(String(Le.message??Le)),!1}finally{R(!1)}},re=w.useRef(!1);w.useEffect(()=>{if(o||!t)return;if(!re.current){re.current=!0;return}const _e=setTimeout(()=>{const Le=a.trim();Le&&Le!==t.name&&ie(()=>he.invoke("rename_workspace",{id:t.id,name:Le})),h!==(t.description??"")&&ie(()=>he.invoke("set_description",{id:t.id,description:h})),m!==(t.initial??"")&&ie(()=>he.invoke("set_workspace_initial",{id:t.id,initial:m}));const jt=YA(t.color??"")??"";Y!==null&&Y!==jt&&ie(()=>he.invoke("set_workspace_color",{id:t.id,color:Y}));const di=tee(k);iee(di,t.env??{})||ie(()=>he.invoke("set_workspace_env",{id:t.id,env:di}))},nee);return()=>clearTimeout(_e)},[a,h,m,S,k]);async function ge(_e){if(!(!t||!_e)){if(!ree.has(_e.type)){N("Choose a PNG, JPEG, or WebP image.");return}if(_e.size>see){N("Choose an image smaller than 512 KB.");return}try{const Le=await oee(_e);await ie(()=>he.invoke("set_workspace_icon",{id:t.id,icon:Le}))&&x(Le)}catch(Le){N(String(Le.message??Le))}}}async function Ee(){if(!t)return;await ie(()=>he.invoke("set_workspace_icon",{id:t.id,icon:""}))&&x("")}async function fe(_e){const Le=a.trim();if(!Le){N("Give the project a name first.");return}await ie(async()=>{await he.invoke("add_workspace",{name:Le,primaryPath:_e})})&&n()}function Pe(_e){const Le=z;if(J(null),!!_e){if(o){fe(_e);return}t&&ie(Le==="primary"?()=>he.invoke("set_primary_path",{id:t.id,path:_e}):()=>he.invoke("add_workspace_path",{id:t.id,path:_e}))}}function De(_e){if(!t)return;const Le=JJ(D,t.id,_e);ie(()=>he.invoke("reorder_workspaces",{orderedIds:Le}))}async function He(){if(!t||!X)return;await ie(()=>he.invoke("set_workspace_sibling",{id:t.id,siblingId:X,linked:!0}))&&I("")}return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"panel-scrim",onClick:n}),d.jsxs("aside",{className:"panel",role:"dialog","aria-label":o?"New project":t.name,children:[d.jsxs("header",{className:"panel-head",children:[d.jsxs("div",{className:"panel-id",children:[d.jsx("div",{className:"panel-name",children:o?"New project":"Project settings"}),!o&&d.jsx("div",{className:"panel-path",children:d.jsx("bdi",{children:t.primary_path})})]}),d.jsx("button",{className:"panel-close",type:"button",onClick:n,"aria-label":r?"Back to Settings":"Close",children:r?d.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"m15 18-6-6 6-6"})}):"✕"})]}),L&&d.jsx("div",{className:"panel-error",children:L}),d.jsxs("div",{className:"panel-body set-body",children:[d.jsxs("label",{className:"set-field",children:[d.jsx("span",{className:"set-label",children:"Name"}),d.jsx("input",{className:"set-input",value:a,autoFocus:o,placeholder:"performance",onChange:_e=>u(_e.target.value)})]}),!o&&d.jsxs("label",{className:"set-field",children:[d.jsx("span",{className:"set-label",children:"Description"}),d.jsx("input",{className:"set-input",value:h,placeholder:"what this project is",onChange:_e=>p(_e.target.value)})]}),!o&&t&&d.jsxs("div",{className:"set-field",children:[d.jsx("span",{className:"set-label",children:"Project identity"}),d.jsx("p",{className:"set-hint",children:"Icon, letters, and color identify this project throughout OctiqFlow."}),d.jsxs("div",{className:"project-icon-editor",children:[d.jsx(np,{project:{...t,name:a.trim()||t.name,initial:m,icon:_,color:B?t.color:Y},size:"large"}),d.jsxs("div",{className:"project-icon-actions",children:[d.jsx("button",{className:"set-row-btn",type:"button",disabled:j,onClick:()=>T.current?.click(),children:"Choose image"}),d.jsx("button",{className:"set-row-btn is-quiet",type:"button",disabled:j||!_,onClick:()=>{Ee()},children:"Remove"}),d.jsx("input",{ref:T,type:"file",hidden:!0,accept:"image/png,image/jpeg,image/webp",onChange:_e=>{const Le=_e.currentTarget.files?.[0];_e.currentTarget.value="",ge(Le)}})]})]}),d.jsxs("label",{className:"project-initial-field",children:[d.jsx("span",{children:"Fallback letters"}),d.jsx("input",{className:"set-input project-initial-input",value:m,maxLength:4,inputMode:"text",placeholder:(a.trim()[0]||"?").toLocaleUpperCase(),onChange:_e=>{v([..._e.target.value].slice(0,2).join(""))}})]}),d.jsxs("div",{className:"project-color-field",role:"group","aria-label":"Project color",children:[d.jsx("span",{children:"Project color"}),d.jsx("input",{className:"project-color-picker",type:"color",value:ee,"aria-label":"Choose project color",disabled:j,onChange:_e=>C(_e.target.value)}),d.jsx("input",{className:"set-input project-color-code",value:S,maxLength:7,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",placeholder:"#60a5fa","aria-label":"Project color hex code","aria-invalid":B||void 0,onChange:_e=>C(_e.target.value),onBlur:()=>{Y!==null&&S!==Y&&C(Y)},onKeyDown:_e=>{_e.key==="Enter"&&_e.currentTarget.blur()}}),d.jsx("button",{className:"set-row-btn project-color-auto",type:"button",disabled:j||!S.trim(),onClick:()=>C(""),children:"Automatic"}),B&&d.jsx("span",{className:"project-color-error",role:"alert",children:"Use six hex digits, for example #60a5fa."})]}),d.jsx("p",{className:"set-hint project-icon-note",children:"PNG, JPEG, or WebP up to 512 KB. Automatic color follows the project name."})]}),!o&&d.jsxs("label",{className:"set-field",children:[d.jsx("span",{className:"set-label",children:"Environment"}),d.jsx("textarea",{className:"set-input set-env",value:k,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",placeholder:"CLAUDE_CONFIG_DIR=~/.claude-novel",onChange:_e=>M(_e.target.value)}),d.jsx("p",{className:"set-hint",children:"Set on every terminal and chat started in this project. One per line, e.g. CLAUDE_CONFIG_DIR=~/.claude-novel"})]}),!o&&d.jsxs("div",{className:"set-field",children:[d.jsx("span",{className:"set-label",children:"Position"}),d.jsx("p",{className:"set-hint",children:"Drag this project in the sidebar, or move it here."}),d.jsxs("div",{className:"set-order",children:[d.jsx("button",{className:"set-row-btn",type:"button",disabled:j||$<=0,onClick:()=>De(-1),children:"Move up"}),d.jsxs("span",{className:"set-order-at",children:[$+1," of ",D.length]}),d.jsx("button",{className:"set-row-btn",type:"button",disabled:j||$<0||$>=D.length-1,onClick:()=>De(1),children:"Move down"})]})]}),!o&&t&&d.jsxs("div",{className:"set-field",children:[d.jsx("span",{className:"set-label",children:"Sibling projects"}),d.jsx("p",{className:"set-hint",children:"Link related projects in both directions. Linked active projects are kept together in the sidebar."}),V.length===0&&d.jsx("div",{className:"set-empty",children:"No sibling projects yet."}),V.map(_e=>d.jsxs("div",{className:"set-row",children:[d.jsx("span",{className:"set-project-name",children:_e.name}),_e.shelved&&d.jsx("span",{className:"set-project-state",children:"Shelved"}),d.jsx("button",{className:"set-row-btn is-quiet",type:"button",disabled:j,onClick:()=>{ie(()=>he.invoke("set_workspace_sibling",{id:t.id,siblingId:_e.id,linked:!1}))},children:"Unlink"})]},_e.id)),K.length>0&&d.jsxs("div",{className:"set-add set-sibling-add",children:[d.jsxs("select",{className:"set-input",value:X,"aria-label":"Project to link",onChange:_e=>I(_e.target.value),children:[d.jsx("option",{value:"",children:"Choose a project…"}),K.map(_e=>d.jsxs("option",{value:_e.id,children:[_e.name,_e.shelved?" · Shelved":""]},_e.id))]}),d.jsx("button",{className:"set-row-btn",type:"button",disabled:j||!X,onClick:()=>{He()},children:"Link"})]})]}),d.jsxs("div",{className:"set-field",children:[d.jsx("span",{className:"set-label",children:"Main folder"}),d.jsx("p",{className:"set-hint",children:"Chats start here."}),o?d.jsx("button",{className:"set-choose",type:"button",onClick:()=>J("primary"),children:"Choose a folder and create"}):d.jsxs("div",{className:"set-row",children:[d.jsx("span",{className:"set-path",title:F,children:d.jsx("bdi",{children:F})}),d.jsx("button",{className:"set-row-btn",type:"button",disabled:j,onClick:()=>J("primary"),children:"Change"})]})]}),!o&&d.jsxs("div",{className:"set-field",children:[d.jsx("span",{className:"set-label",children:"Also include"}),d.jsx("p",{className:"set-hint",children:"Other folders this project covers. Without them a chat cannot read or edit anything outside the main folder."}),P.length===0&&d.jsx("div",{className:"set-empty",children:"No other folders yet."}),P.map(_e=>d.jsxs("div",{className:"set-row",children:[d.jsx("span",{className:"set-path",title:_e,children:d.jsx("bdi",{children:_e})}),d.jsx("button",{className:"set-row-btn is-quiet",type:"button",disabled:j,title:"Remove this folder",onClick:()=>{ie(()=>he.invoke("remove_workspace_path",{id:t.id,path:_e}))},children:"Remove"})]},_e)),d.jsxs("form",{className:"set-add",onSubmit:_e=>{_e.preventDefault();const Le=G.trim();Le&&(q(""),ie(()=>he.invoke("add_workspace_path",{id:t.id,path:Le})))},children:[d.jsx("input",{className:"set-input",value:G,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",placeholder:"/path/to/another/folder",onChange:_e=>q(_e.target.value)}),d.jsx("button",{className:"set-row-btn",type:"button",onClick:()=>J("extra"),children:"Browse"}),d.jsx("button",{className:"set-row-btn",type:"submit",disabled:!G.trim()||j,children:"Add"})]})]}),!o&&d.jsxs("div",{className:"set-danger",children:[d.jsx("button",{className:"set-row-btn",type:"button",disabled:j,onClick:()=>{ie(()=>he.invoke("set_workspace_shelved",{id:t.id,shelved:!t.shelved})).then(n)},children:t.shelved?"Bring back":"Shelve"}),d.jsx("button",{className:"set-row-btn is-danger",type:"button",disabled:j,onClick:async()=>{await H({title:`Delete “${t.name}”?`,body:"It is removed from OctiqFlow only — the folders and files on disk are left exactly as they are.",confirmLabel:"Delete project",danger:!0})&&ie(()=>he.invoke("delete_workspace",{id:t.id})).then(()=>{s(t.id),n()})},children:"Delete project"})]}),!o&&d.jsx("p",{className:"set-note",children:"Shelving hides a project from the list without touching anything. Deleting removes it from OctiqFlow only — nothing on disk is changed."})]})]}),z&&d.jsx(iD,{start:F,title:z==="primary"?"Main folder":"Add a folder",onPick:Pe,onClose:()=>J(null)})]})}function tL(t,e){const i=t.replace(/\/\*[\s\S]*?\*\//g,""),n=new RegExp(`${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\{([^}]*)\\}`).exec(i);if(!n)return{};const s={};for(const r of n[1].split(";")){const o=r.indexOf(":");if(o<0)continue;const a=r.slice(0,o).trim();a.startsWith("--")&&(s[a.slice(2)]=r.slice(o+1).trim())}return s}function iL(t){return{light:tL(t,":root"),dark:tL(t,".dark")}}function nL(t){const e=/^oklch\(\s*([\d.]+%?)\s+([\d.]+)\s+([\d.]+)/i.exec(t.trim());if(!e)return null;const i=e[1].endsWith("%")?Number(e[1].slice(0,-1))/100:Number(e[1]),[n,s]=[Number(e[2]),Number(e[3])];return[i,n,s].some(Number.isNaN)?null:{l:i,c:n,h:s}}function aee(t,e){const i=Math.abs(((t-e)%360+360)%360);return Math.min(i,360-i)}function sL(t,e,i=35){let n=null;for(const a of["chart-1","chart-2","chart-3","chart-4","chart-5"]){const u=t[a]?nL(t[a]):null;if(!u||u.c<.05)continue;const h=aee(u.h,e);h<=i&&(!n||h<n.gap)&&(n={key:a,gap:h})}if(n)return t[n.key];const s=(t.primary?nL(t.primary):null)??{l:.72,c:.16},r=Math.min(.85,Math.max(.55,s.l)),o=Math.min(.2,Math.max(.12,s.c));return`oklch(${r.toFixed(4)} ${o.toFixed(4)} ${e})`}function cee(t,e){const i=/^([\d.]+)(rem|em|px)?$/.exec(t.trim());if(!i)return e;const n=Number(i[1]);return Number.isNaN(n)?e:i[2]==="rem"||i[2]==="em"?n*16:n}const ua=(t,e,i)=>`color-mix(in oklab, ${t} ${e}%, ${i})`;function HS(t){const e=t.background??"#1c1c1e",i=t.foreground??"#f5f5f7",n=t.card??e,s=t.primary??"#0a84ff",r=t.border??ua(i,20,e),o=t["muted-foreground"]??ua(i,60,e),a=cee(t.radius??"0.5rem",8),u=Math.min(2,a);return{"--bg-0":e,"--bg-1":n,"--bg-2":t["surface-raised"]??ua(n,84,i),"--bg-sunken":t.sidebar??ua(e,92,i),"--fg-0":i,"--fg-1":ua(i,86,e),"--fg-2":o,"--fg-3":ua(o,88,e),"--border":r,"--border-strong":ua(r,72,i),"--accent":s,"--accent-fg":t["primary-foreground"]??"#fff","--accent-tint":t["selection-tint"]??ua(s,18,"transparent"),"--ok":sL(t,145),"--warn":sL(t,85),"--danger":t.destructive??"#ff453a","--danger-fg":t["destructive-foreground"]??"#fff","--r-sm":`${a-u}px`,"--r-md":`${a+u}px`,"--r-lg":`${a+u*3}px`}}const uee=Object.keys(HS({})),hee=`/* OctiqFlow Light palette. */
|
|
81
|
+
:root {
|
|
82
|
+
--background: #f7f7f7;
|
|
83
|
+
--foreground: #171717;
|
|
84
|
+
--card: #ffffff;
|
|
85
|
+
--card-foreground: #171717;
|
|
86
|
+
--popover: #ffffff;
|
|
87
|
+
--popover-foreground: #171717;
|
|
88
|
+
--primary: #202020;
|
|
89
|
+
--primary-foreground: #ffffff;
|
|
90
|
+
--secondary: #efefef;
|
|
91
|
+
--surface-raised: #eeeeee;
|
|
92
|
+
--selection-tint: rgb(0 0 0 / 6%);
|
|
93
|
+
--secondary-foreground: #303030;
|
|
94
|
+
--muted: #efefef;
|
|
95
|
+
--muted-foreground: #626262;
|
|
96
|
+
--accent: #ebebeb;
|
|
97
|
+
--accent-foreground: #171717;
|
|
98
|
+
--destructive: #bb3543;
|
|
99
|
+
--destructive-foreground: #ffffff;
|
|
100
|
+
--border: #e0e0e0;
|
|
101
|
+
--input: #d4d4d4;
|
|
102
|
+
--ring: #3866da;
|
|
103
|
+
--chart-1: oklch(0.48 0.12 145);
|
|
104
|
+
--chart-2: oklch(0.48 0.12 85);
|
|
105
|
+
--chart-3: oklch(0.5 0.15 260);
|
|
106
|
+
--sidebar: #f2f2f2;
|
|
107
|
+
--radius: 0.625rem;
|
|
108
|
+
}
|
|
109
|
+
`,dee=`/* OctiqFlow Fun palette. Bright accents sit on a calm dark foundation so
|
|
110
|
+
long chats remain readable while the interface still feels playful. */
|
|
111
|
+
:root {
|
|
112
|
+
--background: oklch(0.9809 0.0025 228.7836);
|
|
113
|
+
--foreground: oklch(0.3211 0 0);
|
|
114
|
+
--card: oklch(1.0000 0 0);
|
|
115
|
+
--card-foreground: oklch(0.3211 0 0);
|
|
116
|
+
--popover: oklch(1.0000 0 0);
|
|
117
|
+
--popover-foreground: oklch(0.3211 0 0);
|
|
118
|
+
--primary: oklch(0.8677 0.0735 7.0855);
|
|
119
|
+
--primary-foreground: oklch(0 0 0);
|
|
120
|
+
--secondary: oklch(0.8148 0.0819 225.7537);
|
|
121
|
+
--secondary-foreground: oklch(0 0 0);
|
|
122
|
+
--muted: oklch(0.8828 0.0285 98.1033);
|
|
123
|
+
--muted-foreground: oklch(0.5382 0 0);
|
|
124
|
+
--accent: oklch(0.9680 0.2110 109.7692);
|
|
125
|
+
--accent-foreground: oklch(0 0 0);
|
|
126
|
+
--destructive: oklch(0.6368 0.2078 25.3313);
|
|
127
|
+
--destructive-foreground: oklch(1.0000 0 0);
|
|
128
|
+
--border: oklch(0.8699 0 0);
|
|
129
|
+
--input: oklch(0.8699 0 0);
|
|
130
|
+
--ring: oklch(0.8677 0.0735 7.0855);
|
|
131
|
+
--chart-1: oklch(0.8677 0.0735 7.0855);
|
|
132
|
+
--chart-2: oklch(0.8148 0.0819 225.7537);
|
|
133
|
+
--chart-3: oklch(0.9680 0.2110 109.7692);
|
|
134
|
+
--chart-4: oklch(0.8027 0.1355 349.2347);
|
|
135
|
+
--chart-5: oklch(0.7395 0.2268 142.8504);
|
|
136
|
+
--sidebar: oklch(0.9809 0.0025 228.7836);
|
|
137
|
+
--sidebar-foreground: oklch(0.3211 0 0);
|
|
138
|
+
--sidebar-primary: oklch(0.8677 0.0735 7.0855);
|
|
139
|
+
--sidebar-primary-foreground: oklch(0 0 0);
|
|
140
|
+
--sidebar-accent: oklch(0.9680 0.2110 109.7692);
|
|
141
|
+
--sidebar-accent-foreground: oklch(0 0 0);
|
|
142
|
+
--sidebar-border: oklch(0.8699 0 0);
|
|
143
|
+
--sidebar-ring: oklch(0.8677 0.0735 7.0855);
|
|
144
|
+
--radius: 0.5rem;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.dark {
|
|
148
|
+
--background: oklch(0.2303 0.0125 264.2926);
|
|
149
|
+
--foreground: oklch(0.9219 0 0);
|
|
150
|
+
--card: oklch(0.3210 0.0078 223.6661);
|
|
151
|
+
--card-foreground: oklch(0.9219 0 0);
|
|
152
|
+
--popover: oklch(0.3210 0.0078 223.6661);
|
|
153
|
+
--popover-foreground: oklch(0.9219 0 0);
|
|
154
|
+
--primary: oklch(0.8027 0.1355 349.2347);
|
|
155
|
+
--primary-foreground: oklch(0 0 0);
|
|
156
|
+
--secondary: oklch(0.7395 0.2268 142.8504);
|
|
157
|
+
--secondary-foreground: oklch(0 0 0);
|
|
158
|
+
--muted: oklch(0.3867 0 0);
|
|
159
|
+
--muted-foreground: oklch(0.7155 0 0);
|
|
160
|
+
--accent: oklch(0.8148 0.0819 225.7537);
|
|
161
|
+
--accent-foreground: oklch(0 0 0);
|
|
162
|
+
--destructive: oklch(0.6368 0.2078 25.3313);
|
|
163
|
+
--destructive-foreground: oklch(1.0000 0 0);
|
|
164
|
+
--border: oklch(0.3867 0 0);
|
|
165
|
+
--input: oklch(0.3867 0 0);
|
|
166
|
+
--ring: oklch(0.8027 0.1355 349.2347);
|
|
167
|
+
--chart-1: oklch(0.8027 0.1355 349.2347);
|
|
168
|
+
--chart-2: oklch(0.7395 0.2268 142.8504);
|
|
169
|
+
--chart-3: oklch(0.8148 0.0819 225.7537);
|
|
170
|
+
--chart-4: oklch(0.9680 0.2110 109.7692);
|
|
171
|
+
--chart-5: oklch(0.8652 0.1768 90.3816);
|
|
172
|
+
--sidebar: oklch(0.2303 0.0125 264.2926);
|
|
173
|
+
--sidebar-foreground: oklch(0.9219 0 0);
|
|
174
|
+
--sidebar-primary: oklch(0.8027 0.1355 349.2347);
|
|
175
|
+
--sidebar-primary-foreground: oklch(0 0 0);
|
|
176
|
+
--sidebar-accent: oklch(0.8148 0.0819 225.7537);
|
|
177
|
+
--sidebar-accent-foreground: oklch(0 0 0);
|
|
178
|
+
--sidebar-border: oklch(0.3867 0 0);
|
|
179
|
+
--sidebar-ring: oklch(0.8027 0.1355 349.2347);
|
|
180
|
+
--radius: 0.5rem;
|
|
181
|
+
}
|
|
182
|
+
`,Cb="light",Xu="dark",Eb="fun",B0=[{id:Cb,name:"Light",scheme:"light",tokens:iL(hee).light},{id:Xu,name:"Dark",scheme:"dark"},{id:Eb,name:"Fun",scheme:"dark",tokens:iL(dee).dark}],fee={bg:"#101010",sunken:"#141414",card:"#1b1b1b",accent:"#f5f5f5",fg:"#fafafa"};function pee(t){if(!t.tokens)return fee;const e=HS(t.tokens);return{bg:e["--bg-0"],sunken:e["--bg-sunken"],card:e["--bg-1"],accent:e["--accent"],fg:e["--fg-0"]}}const xD="octiq.theme",Mb="octiq-theme";function bD(){try{const t=localStorage.getItem(xD);return t===Cb||t==="one-light"?Cb:t===Eb||t==="candyland"?Eb:Xu}catch{return Xu}}function mee(t){return B0.find(e=>e.id===t)??B0.find(e=>e.id===Xu)}function wD(t){const e=mee(t),i=document.documentElement;if(e.tokens){for(const[n,s]of Object.entries(HS(e.tokens)))i.style.setProperty(n,s);i.setAttribute("data-theme",e.id)}else{for(const n of uee)i.style.removeProperty(n);i.removeAttribute("data-theme")}i.setAttribute("data-color-scheme",e.scheme);try{localStorage.setItem(xD,e.id)}catch{}window.dispatchEvent(new CustomEvent(Mb,{detail:e.id}))}const gee=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function vee(t,e){return gee.compare(t.name,e.name)||t.name.localeCompare(e.name)||t.id.localeCompare(e.id)}function _ee({current:t,onPick:e,notify:i,onNotify:n,projects:s,onProject:r,onClose:o}){const a=j=>{wD(j),e(j)},[u,h]=w.useState(cx),[p,m]=w.useState(""),[v,_]=w.useState(!1),[x,S]=w.useState("projects"),C=Y0()||kh()||LN(),k=async()=>{if(!v){_(!0),m("");try{if(i){await t7(),M1(!1),n(!1,!1);return}const j=await e7();if(h(cx()),j==="on"){M1(!0),n(!0,!0);return}if(j==="denied"){m("denied");return}if(j==="needs-install"){m("needs-install");return}const R=await YI();if(h(R),R!=="granted"){m("denied");return}M1(!0),n(!0,!1)}finally{_(!1)}}},M=i&&u==="granted",L=B0.find(j=>j.id===t)?.name??"Dark",N=[...s].sort(vee);return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"panel-scrim",onClick:o}),d.jsxs("aside",{className:"panel settings-page",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",children:[d.jsxs("header",{className:"panel-head settings-page-head",children:[d.jsxs("div",{className:"panel-id",children:[d.jsx("div",{className:"panel-name",id:"settings-title",children:"Settings"}),d.jsx("div",{className:"panel-path",children:"OctiqFlow preferences"})]}),d.jsx("button",{className:"panel-close",type:"button",onClick:o,"aria-label":"Close",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:d.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})})]}),d.jsxs("div",{className:"settings-layout",children:[d.jsxs("nav",{className:"settings-nav","aria-label":"Settings sections",children:[d.jsxs("div",{className:"settings-nav-list",children:[d.jsx(by,{section:"projects",label:"Projects",detail:`${s.length} ${s.length===1?"project":"projects"}`,active:x==="projects",onPick:S}),C&&d.jsx(by,{section:"notifications",label:"Notifications",detail:M?"On":"Off",active:x==="notifications",onPick:S}),d.jsx(by,{section:"appearance",label:"Appearance",detail:L,active:x==="appearance",onPick:S})]}),d.jsx("p",{className:"settings-nav-foot",children:"Changes apply automatically."})]}),d.jsxs("main",{className:"settings-content",children:[x==="projects"&&d.jsxs("section",{className:"settings-section","aria-labelledby":"settings-projects-title",children:[d.jsxs("header",{className:"settings-section-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"settings-projects-title",children:"Projects"}),d.jsx("p",{children:"Manage names, folders, environment, links, and visibility."})]}),d.jsxs("button",{className:"settings-primary",type:"button",onClick:()=>r("new"),children:[d.jsx(xee,{}),d.jsx("span",{children:"New project"})]})]}),s.length?d.jsx("div",{className:"settings-projects",children:N.map(j=>d.jsxs("button",{className:"settings-project",type:"button",onClick:()=>r(j.id),"aria-label":`Configure ${j.name}`,children:[d.jsx(np,{project:j,size:"medium"}),d.jsxs("span",{className:"settings-project-copy",children:[d.jsx("span",{className:"settings-project-name",children:j.name}),j.primary_path&&d.jsx("span",{className:"settings-project-path",title:j.primary_path,children:d.jsx("bdi",{children:j.primary_path})})]}),j.shelved&&d.jsx("span",{className:"settings-project-state",children:"Shelved"}),d.jsx(bee,{})]},j.id))}):d.jsxs("div",{className:"settings-empty",children:[d.jsx("strong",{children:"No projects yet"}),d.jsx("span",{children:"Create a project to give chats their own workspace."})]})]}),x==="notifications"&&C&&d.jsxs("section",{className:"settings-section","aria-labelledby":"settings-notifications-title",children:[d.jsx("header",{className:"settings-section-head",children:d.jsxs("div",{children:[d.jsx("h2",{id:"settings-notifications-title",children:"Notifications"}),d.jsx("p",{children:"Choose when OctiqFlow can bring a chat back to your attention."})]})}),d.jsxs("div",{className:"settings-control-row",children:[d.jsxs("div",{className:"settings-control-copy",children:[d.jsx("h3",{children:"Chat activity"}),d.jsx("p",{children:"Get a banner when a chat you are not watching finishes, needs permission, or asks you a question."})]}),d.jsxs("button",{className:`set-switch${M?" is-on":""}`,type:"button",role:"switch","aria-checked":M,disabled:v,onClick:k,children:[d.jsx("span",{className:"set-switch-track","aria-hidden":"true"}),d.jsx("span",{className:"set-switch-text",children:v?"…":M?"On":"Off"})]})]}),d.jsx("p",{className:"settings-note",children:"On a phone, alerts can arrive even while OctiqFlow is closed. Nothing appears for the chat currently on screen."}),p==="needs-install"&&d.jsxs("p",{className:"set-warn",children:["iPhone and iPad only allow notifications for an app on the home screen. Tap Share, then ",d.jsx("b",{children:"Add to Home Screen"}),", open OctiqFlow from there, and turn this on again."]}),(p==="denied"||u==="denied")&&d.jsx("p",{className:"set-warn",children:"This browser is blocking notifications for OctiqFlow. Allow them in the site settings and come back."}),p==="failed"&&d.jsx("p",{className:"set-warn",children:"Could not register for notifications. This needs an https address — a plain http one will not do, even on your own network."})]}),x==="appearance"&&d.jsxs("section",{className:"settings-section settings-appearance","aria-labelledby":"settings-appearance-title",children:[d.jsx("header",{className:"settings-section-head",children:d.jsxs("div",{children:[d.jsx("h2",{id:"settings-appearance-title",children:"Appearance"}),d.jsx("p",{children:"Keep it light, stay focused in dark, or add some colour with fun mode."})]})}),d.jsx("div",{className:"thm-grid",role:"radiogroup","aria-label":"Appearance",children:B0.map(j=>{const R=pee(j),z=j.id===t;return d.jsxs("button",{className:`thm${z?" is-on":""}`,type:"button",role:"radio","aria-checked":z,onClick:()=>a(j.id),children:[d.jsxs("span",{className:"thm-shot",style:{background:R.bg},"aria-hidden":"true",children:[d.jsx("span",{className:"thm-bar",style:{background:R.sunken}}),d.jsx("span",{className:"thm-card",style:{background:R.card}}),d.jsx("span",{className:"thm-line",style:{background:R.fg}}),d.jsx("span",{className:"thm-dot",style:{background:R.accent}})]}),d.jsx("span",{className:"thm-name",children:j.name})]},j.id)})})]})]})]})]})]})}function by({section:t,label:e,detail:i,active:n,onPick:s}){return d.jsxs("button",{className:`settings-nav-item${n?" is-on":""}`,type:"button","aria-current":n?"page":void 0,onClick:()=>s(t),children:[d.jsx(yee,{section:t}),d.jsxs("span",{className:"settings-nav-copy",children:[d.jsx("span",{children:e}),d.jsx("small",{children:i})]})]})}function yee({section:t}){return t==="projects"?d.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M3 7.5h7l2 2h9v9.5H3z"}),d.jsx("path",{d:"M3 7.5V5h7l2 2h6"})]}):t==="notifications"?d.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9"}),d.jsx("path",{d:"M10 21h4"})]}):d.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("circle",{cx:"12",cy:"12",r:"9"}),d.jsx("path",{d:"M12 3a9 9 0 0 0 0 18c2.2-2.2 3.3-5.2 3.3-9S14.2 5.2 12 3Z"}),d.jsx("path",{d:"M3 12h18"})]})}function xee(){return d.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:d.jsx("path",{d:"M12 5v14M5 12h14"})})}function bee(){return d.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"m9 18 6-6-6-6"})})}const wee=6e4,See=15e3,SD="octiq.v2.usage",kee=180,Cee=60,Eee=85;function Mee(){try{const t=JSON.parse(localStorage.getItem(SD)||"null");if(!t||typeof t!="object")return{claude:null,codex:null};const e=i=>i?.available?i:null;return{claude:e(t.claude),codex:e(t.codex)}}catch{return{claude:null,codex:null}}}function kD(t){return t>=Eee?"is-danger":t>=Cee?"is-warn":""}function Aee(t){if(!t)return"";const e=t-Date.now()/1e3;if(e<=0)return"resetting";const i=Math.floor(e/3600),n=Math.floor(e%3600/60);return i>=24?`resets in ${Math.floor(i/24)}d ${i%24}h`:i?`resets in ${i}h ${n}m`:`resets in ${n}m`}function Lee(){const[t,e]=w.useState(Mee),[i,n]=w.useState({claude:!0,codex:!0}),[s,r]=w.useState(null),o=w.useRef(null),a=w.useRef(0),u=w.useCallback(()=>{o.current&&clearTimeout(o.current),o.current=null},[]);w.useEffect(()=>u,[u]);const h=w.useCallback(async p=>{if(!(!p&&Date.now()-a.current<See)){a.current=Date.now();try{const m=await he.invoke("usage_summary"),v=(_,x)=>_?.available?_:x?.available?x:_??x??null;e(_=>{const x={claude:v(m?.claude,_.claude),codex:v(m?.codex,_.codex)};try{localStorage.setItem(SD,JSON.stringify({claude:x.claude?.available?x.claude:_.claude,codex:x.codex?.available?x.codex:_.codex}))}catch{}return x}),n({claude:!m?.claude?.available,codex:!m?.codex?.available})}catch{n({claude:!0,codex:!0})}}},[]);return w.useEffect(()=>{h(!0);const p=setInterval(()=>{h(!0)},wee),m=()=>document.visibilityState==="visible"&&void h(!1);return document.addEventListener("visibilitychange",m),window.addEventListener("focus",m),()=>{clearInterval(p),document.removeEventListener("visibilitychange",m),window.removeEventListener("focus",m)}},[h]),!t.claude&&!t.codex?null:d.jsxs("div",{className:"usage",onPointerEnter:p=>{p.pointerType==="mouse"&&(u(),r(m=>m??"hover"),h(!1))},onPointerLeave:p=>{p.pointerType==="mouse"&&(u(),o.current=setTimeout(()=>r(m=>m==="hover"?null:m),kee))},children:[d.jsxs("button",{className:"usage-btn",type:"button",title:"Highest plan usage — hover or tap for every window",onClick:()=>{u(),r(p=>p==="pin"?null:"pin"),h(!0)},children:[d.jsx(rL,{label:"CL",provider:t.claude,stale:i.claude}),d.jsx(rL,{label:"CX",provider:t.codex,stale:i.codex})]}),s&&d.jsxs(d.Fragment,{children:[s==="pin"&&d.jsx("div",{className:"usage-scrim",onClick:()=>r(null)}),d.jsxs("div",{className:"usage-pop",role:"dialog","aria-label":"Plan usage",children:[d.jsx(oL,{name:"Claude",provider:t.claude,stale:i.claude}),d.jsx(oL,{name:"Codex",provider:t.codex,stale:i.codex})]})]})]})}function Tee(t){const e=[];t?.fiveHour&&e.push({label:"5h",window:t.fiveHour}),t?.weekly&&e.push({label:"7d",window:t.weekly});for(const i of t?.models??[])e.push({label:i.name,window:i});return e.length===0?null:e.reduce((i,n)=>n.window.percent>i.window.percent?n:i)}function rL({label:t,provider:e,stale:i}){const n=Tee(e),s=n?Math.min(100,Math.max(0,n.window.percent)):0;return d.jsxs("span",{className:`usage-pill ${i?"is-stale":""} ${n?"":"is-empty"}`,children:[d.jsx("span",{className:"usage-tag",children:t}),n?d.jsxs("span",{className:"usage-num",children:[n.label&&d.jsx("span",{className:"usage-num-label",children:n.label}),d.jsx("span",{className:`usage-val ${kD(s)}`,children:d.jsx(ct,{children:`${Math.round(s)}%`})})]}):d.jsx("span",{className:"usage-val",children:"—"})]})}function oL({name:t,provider:e,stale:i}){return d.jsxs("section",{className:"usage-block",children:[d.jsxs("header",{className:"usage-block-head",children:[d.jsx("span",{className:"usage-block-name",children:t}),e?.plan&&d.jsx("span",{className:"usage-plan",children:e.plan}),i&&d.jsx("span",{className:"usage-stale",children:"last known"})]}),e?d.jsxs(d.Fragment,{children:[d.jsx(wy,{label:"5 hours",window:e.fiveHour}),d.jsx(wy,{label:"Week",window:e.weekly}),(e.models??[]).map(n=>d.jsx(wy,{label:`Week · ${n.name}`,window:n},n.name)),e.note&&d.jsx("div",{className:"usage-empty",children:e.note})]}):d.jsx("div",{className:"usage-empty",children:"No reading yet."})]})}function wy({label:t,window:e}){if(!e)return null;const i=Math.min(100,Math.max(0,e.percent));return d.jsxs("div",{className:"usage-row",children:[d.jsx("span",{className:"usage-row-label",children:t}),d.jsx("span",{className:`usage-track ${kD(i)}`,children:d.jsx("span",{className:"usage-fill",style:{width:`${i}%`}})}),d.jsx("span",{className:"usage-val",children:d.jsx(ct,{children:`${Number.isInteger(i)?i:i.toFixed(1)}%`})}),d.jsx("span",{className:"usage-reset",children:d.jsx(ct,{children:Aee(e.resetsAt)})})]})}const ch="octiq-git-changed";function Nee(t){const e=new Set;for(const i of t)for(const n of[i.primary_path,...i.paths??[]])n?.trim()&&e.add(n);return[...e]}function jee(t){return[...new Set(t.flatMap(e=>e.primary_path?.trim()?[e.primary_path]:[]))]}function Ree(t,e){const i=new Map(e.map(s=>[s.path,s])),n={};for(const s of t){if(!s.primary_path)continue;const r=i.get(s.primary_path);r?.is_repo&&r.branch&&(n[s.id]=r.branch)}return n}const Dee={added:{letter:"A",cls:"is-add"},deleted:{letter:"D",cls:"is-del"},renamed:{letter:"R",cls:"is-ren"},untracked:{letter:"U",cls:"is-new"}},Bee={letter:"M",cls:"is-mod"},CD=["rebase","merge","ff-only"],lL="octiq.v2.gitPullMode",Oee="octiq.v2.gitWidth",Iee={initial:380,min:280,max:680},Pee=/^(diff --git |index |--- |\+\+\+ |new file mode|deleted file mode|old mode|new mode|similarity index|dissimilarity index|rename from|rename to|copy from|copy to|Binary files )/;function ED(t){return t?[t.primary_path??"",...t.paths??[]].filter(e=>e.trim()!=="").join(`
|
|
183
|
+
`):""}function zee(t){const e=new Map;for(const i of t)!i.is_repo||!i.repo_root||e.has(i.repo_root)||e.set(i.repo_root,i);return[...e.values()]}function $ee(t){const e=t.lastIndexOf("/");return e<0?{dir:"",name:t}:{dir:t.slice(0,e),name:t.slice(e+1)}}function Fee({project:t,open:e,onToggle:i}){const[n,s]=w.useState([]),[r,o]=w.useState(null),a=t?.primary_path??"",u=ED(t),h=w.useMemo(()=>u?u.split(`
|
|
184
|
+
`):[],[u]);w.useEffect(()=>{if(h.length===0){s([]);return}let _=!0;const x=()=>{he.invoke("git_status_summary",{paths:h}).then(C=>{if(!_)return;const k=C??[];s(zee(k)),o(k.find(M=>M.is_repo&&M.path===a)??null)}).catch(()=>{_&&s([])})};window.addEventListener("focus",x),window.addEventListener(ch,x);const S=he.onState(C=>{C==="open"&&x()});return()=>{_=!1,window.removeEventListener("focus",x),window.removeEventListener(ch,x),S()}},[h,a]);const p=n.reduce((_,x)=>_+x.changed,0),m=n.reduce((_,x)=>_+x.ahead,0),v=w.useMemo(()=>{if(n.length===0)return[];const _=n.filter(x=>x.repo_root!==r?.repo_root);return r?[r,..._]:_},[n,r]);return d.jsxs("button",{className:`gitp-toggle ${e?"is-on":""}`,type:"button","aria-expanded":e,"aria-label":["Git",p>0?`${p} changed`:null,m>0?`${m} to push`:null].filter(Boolean).join(", "),title:t?[`Git — ${t.name}`,...v.map((_,x)=>{const S=_.repo_root.split("/").pop()??_.repo_root,C=[_.changed>0?`${_.changed} changed`:"clean",_.ahead>0?`↑${_.ahead} to push`:null].filter(Boolean).join(" · ");return`${S} · ${_.branch||"(detached)"} · ${C}${x===0&&r?" — this chat":""}`})].join(`
|
|
185
|
+
`):"Git",onClick:i,children:[d.jsx(Kee,{}),d.jsx("span",{className:"topbar-action-label",children:"Git"}),p>0&&d.jsx("span",{className:"gitp-badge",children:d.jsx(us,{value:p})}),m>0&&d.jsxs("span",{className:"gitp-badge is-ahead",children:["↑",d.jsx(us,{value:m})]})]})}function Hee({project:t,open:e,persistent:i=!1,onClose:n}){const[s,r]=w.useState(null),[o,a]=w.useState(null),[u,h]=w.useState(!1),[p,m]=w.useState({}),[v,_]=w.useState({}),[x,S]=w.useState(""),[C,k]=w.useState(null),[M,L]=w.useState(!1),{width:N,startDrag:j,entered:R}=Gf(Oee,Iee),[z,J]=w.useState(()=>{const Y=localStorage.getItem(lL);return CD.includes(Y)?Y:"rebase"}),G=ED(t),q=w.useMemo(()=>G?G.split(`
|
|
186
|
+
`):[],[G]),X=t?.id??null,I=w.useRef({}),T=w.useRef(!1),H=w.useCallback(async()=>{if(q.length===0){r([]);return}h(!0);let Y;try{Y=await he.invoke("git_changed_files",{paths:q})??[],a(null)}catch(re){r(null),a(String(re.message??re)),h(!1);return}r(Y),h(!1);const B=I.current,ee={};for(const re of Y)ee[re.root]=new Set((re.files??[]).map(ge=>ge.path));I.current=ee,_(re=>{const ge={};for(const Ee of Y){const fe=re[Ee.root],Pe=B[Ee.root],De=new Set;for(const He of Ee.files??[])(!Pe?.has(He.path)||fe?.has(He.path))&&De.add(He.path);ge[Ee.root]=De}return ge});const ie=await Promise.all(Y.map(re=>he.invoke("git_local_branches",{path:re.root}).then(ge=>ge?.is_repo?[re.root,ge.branches??[]]:null).catch(()=>null)));m(Object.fromEntries(ie.filter(re=>!!re)))},[q]);w.useEffect(()=>{I.current={},_({}),S(""),k(null),r(null),m({})},[X]),w.useEffect(()=>{H()},[H]),w.useEffect(()=>{const Y=()=>{T.current||H()};return window.addEventListener(ch,Y),()=>window.removeEventListener(ch,Y)},[H]);const F=w.useCallback(async(Y,B)=>{if(T.current)return;T.current=!0,L(!0),k({kind:"busy",text:Y,detail:""});let ee=!1;try{const ie=await B();k({kind:"ok",text:ie?.summary||"Done.",detail:ie?.output??""}),ee=!0}catch(ie){const re=String(ie.message??ie),[ge,...Ee]=re.split(`
|
|
187
|
+
`);k({kind:"err",text:ge||"That did not work.",detail:Ee.join(`
|
|
188
|
+
`).trim()})}finally{T.current=!1,L(!1)}await H(),ee&&window.dispatchEvent(new CustomEvent(ch))},[H]),P=w.useCallback((Y,B,ee)=>{_(ie=>{const re=new Set(ie[Y]??[]);return ee?re.add(B):re.delete(B),{...ie,[Y]:re}})},[]),U=w.useCallback((Y,B)=>{_(ee=>({...ee,[Y.root]:B?new Set((Y.files??[]).map(ie=>ie.path)):new Set}))},[]),V=w.useMemo(()=>{const Y=[];for(const B of s??[]){const ee=v[B.root],ie=(B.files??[]).filter(ge=>ee?.has(ge.path));if(ie.length===0)continue;const re=[];for(const ge of ie)re.push(ge.path),ge.old_path&&re.push(ge.old_path);Y.push({repo:B,files:ie,paths:re})}return Y},[s,v]),K=V.reduce((Y,B)=>Y+B.files.length,0),D=w.useMemo(()=>{let Y=0,B=0,ee=0;for(const ie of s??[])for(const re of ie.files??[])Y+=1,B+=re.added,ee+=re.removed;return{files:Y,additions:B,deletions:ee}},[s]),$=w.useCallback(()=>{const Y=x.trim();if(V.length===0)return;if(!Y){k({kind:"err",text:"Enter a commit message.",detail:""});return}const B=V.reduce((ee,ie)=>ee+ie.files.length,0);F(`Committing ${B} file${B===1?"":"s"}…`,async()=>{const ee=[],ie=[];for(const{repo:re,paths:ge}of V){const Ee=Vi(re.root);let fe;try{fe=await he.invoke("git_commit",{root:re.root,files:ge,message:Y})}catch(Pe){const De=String(Pe.message??Pe);throw new Error(V.length>1?`${Ee}: ${De}`:De)}ee.push(V.length>1?`${Ee}: ${fe.summary}`:fe.summary),fe.output&&ie.push(fe.output)}return S(""),{summary:ee.join(" · "),output:ie.join(`
|
|
189
|
+
`)}})},[x,V,F]);return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:`gitp-scrim ${R&&e?"is-open":""}`,onClick:n,"aria-hidden":"true"}),d.jsxs("aside",{className:`gitp-panel ${R&&e?"is-open":""} ${i?"is-persistent":""}`,"aria-label":"Git changes",style:{"--gitp-w":`${N}px`},children:[d.jsx("div",{className:"gitp-resizer",role:"separator","aria-orientation":"vertical","aria-label":"Resize the git panel",onPointerDown:j}),d.jsxs("header",{className:"gitp-head",children:[d.jsx("span",{className:"gitp-title",children:i?"Changes":"Git"}),d.jsx("span",{className:"gitp-project",children:t?.name??"No project"}),d.jsx("button",{className:"gitp-btn",type:"button",onClick:()=>{H()},disabled:M||u||q.length===0,children:u?"…":"Refresh"}),d.jsx("button",{className:"gitp-close",type:"button","aria-label":"Close",onClick:n,children:"✕"})]}),C&&d.jsxs("div",{className:`gitp-op is-${C.kind}`,role:C.kind==="err"?"alert":void 0,children:[d.jsx("div",{className:"gitp-op-line",children:C.text}),C.detail&&d.jsx("pre",{className:"gitp-op-detail",children:C.detail})]}),d.jsxs("div",{className:"gitp-body",children:[!o&&s!==null&&s.length>0&&d.jsxs("div",{className:"gitp-overview","aria-label":`${D.files} ${D.files===1?"changed file":"changed files"}`,children:[d.jsxs("span",{className:"gitp-overview-item is-files",children:[d.jsx("span",{className:"gitp-overview-value",children:d.jsx(us,{value:D.files})}),d.jsx("span",{className:"gitp-overview-label",children:D.files===1?"file changed":"files changed"})]}),d.jsxs("span",{className:"gitp-overview-item is-additions",children:["+",d.jsx(us,{value:D.additions})]}),d.jsxs("span",{className:"gitp-overview-item is-deletions",children:["−",d.jsx(us,{value:D.deletions})]})]}),q.length===0&&d.jsx("div",{className:"gitp-note",children:"This project has no folders to look at."}),o&&d.jsx("div",{className:"gitp-note is-err",children:o}),!o&&s!==null&&s.length===0&&q.length>0&&d.jsx("div",{className:"gitp-note",children:"No git repository in this project's folders."}),!o&&s===null&&u&&d.jsx("div",{className:"gitp-note",children:"Reading git…"}),(s??[]).map(Y=>d.jsx(Wee,{repo:Y,branches:p[Y.root]??[],checked:v[Y.root]??new Set,busy:M,pullMode:z,onPullMode:B=>{J(B),ri(lL,B)},onTick:P,onTickAll:U,onSwitch:B=>{F(`Switching ${Vi(Y.root)} to ${B}…`,()=>he.invoke("git_switch_branch",{root:Y.root,branch:B}))},onPull:()=>{F(`Pulling ${Vi(Y.root)}…`,()=>he.invoke("git_pull",{root:Y.root,mode:z}))},onPush:()=>{F(`Pushing ${Vi(Y.root)}…`,()=>he.invoke("git_push",{root:Y.root}))}},Y.root))]}),(s?.length??0)>0&&d.jsxs("div",{className:"gitp-commit",children:[d.jsx("textarea",{className:"gitp-msg",rows:2,placeholder:"Commit message",value:x,disabled:M,onChange:Y=>S(Y.target.value)}),d.jsx("button",{className:"gitp-btn is-primary",type:"button",onClick:$,disabled:M||K===0,children:d.jsx(ct,{children:K===0?"Commit":V.length>1?`Commit ${K} files in ${V.length} repos`:`Commit ${K} file${K===1?"":"s"}`})})]})]})]})}function Wee({repo:t,branches:e,checked:i,busy:n,pullMode:s,onPullMode:r,onTick:o,onTickAll:a,onSwitch:u,onPull:h,onPush:p}){const[m,v]=w.useState(null),_=t.files??[],x=_.filter(M=>i.has(M.path)).length,S=w.useRef(null);w.useEffect(()=>{S.current&&(S.current.indeterminate=x>0&&x<_.length)},[x,_.length]);const C=t.branch||"(detached)",k=e.filter(M=>M!==C);return d.jsxs("section",{className:"gitp-repo",children:[d.jsxs("header",{className:"gitp-repo-head",children:[_.length>0&&d.jsx("input",{ref:S,type:"checkbox",className:"gitp-check",checked:x===_.length,disabled:n,title:x===_.length?"Untick every file":"Tick every file",onChange:M=>a(t,M.target.checked)}),d.jsx("span",{className:"gitp-repo-name",title:t.root,children:Vi(t.root)}),k.length===0?d.jsx("span",{className:"gitp-branch",title:`On ${C}`,children:C}):d.jsxs("select",{className:"gitp-branch gitp-branch-pick",value:e.includes(C)?C:"",disabled:n,title:e.includes(C)?`On ${C} — pick a branch to switch to`:`HEAD is at ${C} — pick a branch to check out`,onChange:M=>{const L=M.target.value;L&&L!==C&&u(L)},children:[!e.includes(C)&&d.jsx("option",{value:"",children:C}),e.map(M=>d.jsx("option",{value:M,children:M},M))]}),d.jsxs("span",{className:"gitp-sync",children:[t.behind>0&&d.jsxs("span",{className:"gitp-behind",children:["↓",d.jsx(us,{value:t.behind})]}),t.ahead>0&&d.jsxs("span",{className:"gitp-ahead",children:["↑",d.jsx(us,{value:t.ahead})]})]})]}),d.jsxs("div",{className:"gitp-ops",children:[d.jsx("button",{className:"gitp-btn",type:"button",onClick:h,disabled:n||!t.has_upstream,title:t.has_upstream?`git pull --${s}`:"This branch does not track a remote branch yet. Push it first.",children:d.jsx(ct,{children:t.behind>0?`Pull ${t.behind}`:"Pull"})}),d.jsx("select",{className:"gitp-mode",value:s,disabled:n,"aria-label":"How Pull brings commits in",onChange:M=>r(M.target.value),children:CD.map(M=>d.jsx("option",{value:M,children:M},M))}),d.jsx("button",{className:"gitp-btn",type:"button",onClick:p,disabled:n,title:"git push",children:d.jsx(ct,{children:t.ahead>0?`Push ${t.ahead}`:"Push"})})]}),_.length===0?d.jsx("div",{className:"gitp-clean",children:"No uncommitted changes"}):d.jsx("ul",{className:"gitp-files",children:_.map(M=>d.jsx("li",{children:d.jsx(qee,{repo:t,file:M,ticked:i.has(M.path),busy:n,open:m===M.path,onTick:o,onOpen:()=>v(L=>L===M.path?null:M.path)})},M.path))})]})}function qee({repo:t,file:e,ticked:i,busy:n,open:s,onTick:r,onOpen:o}){const a=Dee[e.status]??Bee,u=$ee(e.path),h=e.status==="renamed"?e.display:u.dir;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`gitp-file ${s?"is-open":""}`,children:[d.jsx("input",{type:"checkbox",className:"gitp-check",checked:i,disabled:n,title:"Include in the next commit",onChange:p=>r(t.root,e.path,p.target.checked)}),d.jsxs("button",{className:"gitp-file-btn",type:"button",onClick:o,title:e.display,children:[d.jsx("span",{className:`gitp-st ${a.cls}`,children:a.letter}),d.jsxs("span",{className:"gitp-file-copy",children:[d.jsx("span",{className:"gitp-file-name",children:u.name}),h&&d.jsx("span",{className:"gitp-file-path",children:h})]}),d.jsx("span",{className:"gitp-counts",children:e.binary?d.jsx("span",{className:"gitp-bin",children:"bin"}):d.jsxs(d.Fragment,{children:[e.added>0&&d.jsxs("span",{className:"gitp-add-n",children:["+",d.jsx(us,{value:e.added})]}),e.removed>0&&d.jsxs("span",{className:"gitp-del-n",children:["−",d.jsx(us,{value:e.removed})]})]})})]})]}),s&&d.jsx(Uee,{repo:t,file:e})]})}function Uee({repo:t,file:e}){const[i,n]=w.useState(null),[s,r]=w.useState(null);if(w.useEffect(()=>{let a=!0;return n(null),r(null),he.invoke("git_file_diff",{root:t.root,file:e.path,untracked:e.untracked,oldPath:e.old_path??""}).then(u=>{a&&n(u)}).catch(u=>{a&&r(String(u.message??u))}),()=>{a=!1}},[t.root,e.path,e.untracked,e.old_path]),s)return d.jsx("div",{className:"gitp-note is-err",children:s});if(!i)return d.jsx("div",{className:"gitp-note",children:"Loading the diff…"});if(i.binary)return d.jsx("div",{className:"gitp-note",children:"Binary file — no text to show."});if(i.too_large)return d.jsx("div",{className:"gitp-note",children:"This diff is too big to show here."});const o=i.text.split(`
|
|
190
|
+
`).filter(a=>!Pee.test(a));return d.jsx("pre",{className:"gitp-diff",children:o.map((a,u)=>d.jsx("span",{className:`gitp-line ${Vee(a)}`,children:a||" "},u))})}function Vee(t){return t.startsWith("@@")?"is-hunk":t.startsWith("+")?"is-add":t.startsWith("-")?"is-del":""}function Kee(){return d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("circle",{cx:"6",cy:"5",r:"2.2"}),d.jsx("circle",{cx:"6",cy:"19",r:"2.2"}),d.jsx("circle",{cx:"18",cy:"9",r:"2.2"}),d.jsx("path",{d:"M6 7.2v9.6"}),d.jsx("path",{d:"M18 11.2a5 5 0 0 1-5 5H9.5"})]})}const WS=new Set(["planning","running","waiting"]);function Yee({open:t,onToggle:e,snapshot:i}){const n=i.runs.filter(o=>WS.has(o.status)).length,s=i.gates.filter(o=>o.status==="open").length,r=s||n;return d.jsxs("button",{className:`orch-toggle${t?" is-on":""}${s?" needs-decision":""}`,type:"button","aria-label":`Orchestrator${s?`, ${s} decisions waiting`:n?`, ${n} active runs`:""}`,"aria-expanded":t,title:"Orchestrator",onClick:e,children:[d.jsx(Jee,{}),d.jsx("span",{className:"topbar-action-label",children:"Orchestrator"}),r>0&&d.jsx("span",{className:"orch-toggle-count",children:r})]})}function Gee({project:t,coordinatorKey:e,currentCwd:i,onOpenChat:n,onClose:s,initialSnapshot:r=D0,readOnly:o=!1}){const[a,u]=w.useState(r),[h,p]=w.useState(r.runs[0]?.id??null),[m,v]=w.useState(r.runs.length===0&&!o),[_,x]=w.useState(""),[S,C]=w.useState(4),[k,M]=w.useState(!1),[L,N]=w.useState(null),[j,R]=w.useState({}),[z,J]=w.useState(!1),G=w.useCallback(async()=>{try{const K=await he.invoke("orchestration_snapshot");u(K??D0),N(null)}catch(K){N(ag(K))}},[]);w.useEffect(()=>{G();const K=he.on("orchestration-changed",()=>{G()}),D=he.onState($=>$==="open"&&void G());return()=>{K(),D()}},[G]);const q=w.useMemo(()=>a.runs.filter(K=>!t||K.workspaceId===t.id),[a.runs,t]);w.useEffect(()=>{if(m&&!o||h&&q.some(D=>D.id===h))return;const K=q.find(D=>WS.has(D.status))??q[0];p(K?.id??null),!K&&q.length===0&&v(!0)},[q,h,m,o]);const X=q.find(K=>K.id===h)??null,I=a.tasks.filter(K=>K.runId===X?.id),T=a.attempts.filter(K=>K.runId===X?.id),H=a.gates.filter(K=>K.runId===X?.id),F=a.messages.filter(K=>K.runId===X?.id),P=async()=>{if(!(o||!t||!e||!_.trim())){M(!0),N(null);try{const K=await he.invoke("orchestration_run_create",{actorChatKey:e,objective:_.trim(),workspaceId:t.id,rootPath:i||t.primary_path||"",maxConcurrent:S,startMaster:!0});x(""),p(K.id),v(!1),await G()}catch(K){N(ag(K))}finally{M(!1)}}},U=async(K,D)=>{if(!(o||!X||!D.trim())){M(!0),N(null);try{n(X.coordinatorChatKey,`For orchestration gate ${K.id}:
|
|
191
|
+
|
|
192
|
+
${K.question}
|
|
193
|
+
|
|
194
|
+
My answer: ${D.trim()}
|
|
195
|
+
|
|
196
|
+
Review this answer and coordinate the next step through orchestration_gate_resolve.`),R($=>({...$,[K.id]:""})),s()}catch($){N(ag($))}finally{M(!1)}}},V=async()=>{if(!(o||!X)){M(!0),N(null);try{await he.invoke("orchestration_run_stop",{actorChatKey:X.coordinatorChatKey,runId:X.id,reason:"Stopped by the person from the Orchestrator panel."}),J(!1),await G()}catch(K){N(ag(K))}finally{M(!1)}}};return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"panel-scrim",onClick:s}),d.jsxs("aside",{className:"panel orch-page",role:"dialog","aria-modal":"true","aria-labelledby":"orch-title",children:[d.jsxs("header",{className:"panel-head orch-page-head",children:[d.jsxs("div",{className:"panel-id",children:[d.jsx("div",{className:"panel-name",id:"orch-title",children:"Orchestrator"}),d.jsx("div",{className:"panel-path",children:t?.name??"All projects"})]}),d.jsx("button",{className:"panel-close",type:"button",onClick:s,"aria-label":"Close",children:d.jsx(ite,{})})]}),d.jsxs("div",{className:"orch-layout",children:[d.jsxs("nav",{className:"orch-runs","aria-label":"Orchestration runs",children:[d.jsxs("button",{className:`orch-new${m?" is-on":""}`,type:"button",disabled:o,onClick:()=>{v(!0),J(!1)},children:[d.jsx(tte,{}),"Start a run"]}),d.jsx("div",{className:"orch-run-list",children:q.map(K=>{const D=a.tasks.filter(B=>B.runId===K.id),$=D.filter(B=>B.status==="completed").length,Y=a.gates.filter(B=>B.runId===K.id&&B.status==="open").length;return d.jsxs("button",{className:`orch-run-pick${!m&&h===K.id?" is-on":""}`,type:"button",onClick:()=>{p(K.id),v(!1),J(!1)},children:[d.jsx(Ab,{status:K.status}),d.jsxs("span",{className:"orch-run-copy",children:[d.jsx("span",{children:K.objective}),d.jsxs("small",{children:[$,"/",D.length," tasks",Y>0?` · ${Y} waiting`:""]})]})]},K.id)})}),d.jsx("p",{className:"orch-runs-note",children:"The host owns task state. Agents report into it."})]}),d.jsxs("main",{className:"orch-content",children:[L&&d.jsx("div",{className:"orch-error",role:"alert",children:L}),o&&d.jsx("p",{className:"orch-empty",children:"This agent chat is read-only. Send instructions and decisions in the main chat."}),m&&!o?d.jsx(Qee,{project:t,hasCoordinator:!!e,objective:_,maxConcurrent:S,busy:k,onObjective:x,onConcurrency:C,onStart:()=>{P()}}):X?d.jsx(Xee,{run:X,tasks:I,attempts:T,gates:H,messages:F,answers:j,busy:k,readOnly:o,confirmStop:z,onAnswer:(K,D)=>R($=>({...$,[K]:D})),onResolve:(K,D)=>{U(K,D)},onOpenChat:n,onAskStop:()=>J(!0),onCancelStop:()=>J(!1),onStop:()=>{V()}}):d.jsx("div",{className:"orch-empty",children:"No runs in this project yet."})]})]})]})]})}function Qee({project:t,hasCoordinator:e,objective:i,maxConcurrent:n,busy:s,onObjective:r,onConcurrency:o,onStart:a}){const u=!!t&&e&&!!i.trim()&&!s;return d.jsxs("section",{className:"orch-start","aria-labelledby":"orch-start-title",children:[d.jsxs("div",{className:"orch-start-intro",children:[d.jsx(ete,{}),d.jsxs("div",{children:[d.jsx("h2",{id:"orch-start-title",children:"Give one agent the whole outcome."}),d.jsx("p",{children:"It will plan the dependency graph, open isolated worktrees, dispatch workers, and keep the run’s state outside their transcripts."})]})]}),d.jsxs("label",{className:"orch-field",children:[d.jsx("span",{children:"Outcome"}),d.jsx("textarea",{value:i,rows:6,autoFocus:!0,placeholder:"Ship the feature, including tests and a review-ready branch…",onChange:h=>r(h.target.value)})]}),d.jsxs("div",{className:"orch-start-row",children:[d.jsxs("label",{className:"orch-field orch-concurrency",children:[d.jsx("span",{children:"Worker limit"}),d.jsx("select",{value:n,onChange:h=>o(Number(h.target.value)),children:[1,2,3,4,6,8].map(h=>d.jsx("option",{value:h,children:h},h))})]}),d.jsxs("div",{className:"orch-launch-copy",children:[d.jsx("strong",{children:t?.name??"Choose a project"}),d.jsx("span",{children:e?"This chat becomes the master.":"Open a chat first; it becomes the master."})]}),d.jsx("button",{className:"orch-primary",type:"button",disabled:!u,onClick:a,children:s?"Starting…":"Start master run"})]})]})}function Xee({run:t,tasks:e,attempts:i,gates:n,messages:s,answers:r,busy:o,readOnly:a,confirmStop:u,onAnswer:h,onResolve:p,onOpenChat:m,onAskStop:v,onCancelStop:_,onStop:x}){const S=n.filter(N=>N.status==="open"),C=e.filter(N=>N.status==="completed").length,k=i.filter(N=>["preparing","running","blocked"].includes(N.status)).length,M=new Map(e.map(N=>[N.id,N.title])),L=new Map;for(const N of i){const j=L.get(N.taskId);(!j||N.number>j.number)&&L.set(N.taskId,N)}return d.jsxs("section",{className:"orch-run-detail","aria-labelledby":"orch-run-title",children:[d.jsxs("header",{className:"orch-run-head",children:[d.jsxs("div",{children:[d.jsxs("div",{className:"orch-status-line",children:[d.jsx(Ab,{status:t.status}),aL(t.status)]}),d.jsx("h2",{id:"orch-run-title",children:t.objective}),d.jsx("p",{children:t.rootPath})]}),!a&&WS.has(t.status)&&(u?d.jsxs("div",{className:"orch-stop-confirm",children:[d.jsx("span",{children:"Stop workers and cancel open tasks?"}),d.jsx("button",{type:"button",onClick:_,children:"Keep running"}),d.jsx("button",{className:"is-danger",type:"button",disabled:o,onClick:x,children:"Stop run"})]}):d.jsx("button",{className:"orch-quiet",type:"button",onClick:v,children:"Stop run"}))]}),d.jsxs("div",{className:"orch-metrics","aria-label":"Run status",children:[d.jsxs("div",{children:[d.jsxs("strong",{children:[C,d.jsxs("span",{children:["/",e.length]})]}),d.jsx("small",{children:"Tasks complete"})]}),d.jsxs("div",{children:[d.jsx("strong",{children:k}),d.jsx("small",{children:"Workers active"})]}),d.jsxs("div",{className:S.length?"needs-decision":"",children:[d.jsx("strong",{children:S.length}),d.jsx("small",{children:"Decisions waiting"})]}),d.jsxs("div",{children:[d.jsx("strong",{children:t.maxConcurrent}),d.jsx("small",{children:"Worker limit"})]})]}),S.length>0&&d.jsxs("section",{className:"orch-decisions","aria-labelledby":"orch-decisions-title",children:[d.jsx("h3",{id:"orch-decisions-title",children:"Decisions"}),S.map(N=>d.jsxs("article",{className:"orch-gate",children:[d.jsx("p",{children:N.question}),!a&&N.options.length>0&&d.jsx("div",{className:"orch-gate-options",children:N.options.map(j=>d.jsx("button",{type:"button",disabled:o,onClick:()=>p(N,j),children:j},j))}),!a&&d.jsxs("div",{className:"orch-gate-write",children:[d.jsx("input",{value:r[N.id]??"",placeholder:"Write a decision","aria-label":`Decision for ${N.question}`,onChange:j=>h(N.id,j.target.value)}),d.jsx("button",{type:"button",disabled:o||!(r[N.id]??"").trim(),onClick:()=>p(N,r[N.id]??""),children:"Send to main chat"})]})]},N.id))]}),d.jsxs("section",{className:"orch-ledger","aria-labelledby":"orch-ledger-title",children:[d.jsxs("div",{className:"orch-section-head",children:[d.jsx("h3",{id:"orch-ledger-title",children:"Execution ledger"}),d.jsx("span",{children:e.length?`${C} settled`:"Planning"})]}),e.length===0?d.jsxs("div",{className:"orch-planning",children:[d.jsx("span",{className:"orch-pulse"}),"The master is turning the outcome into tasks."]}):e.map(N=>{const j=L.get(N.id);return d.jsxs("article",{className:`orch-task is-${N.status}`,children:[d.jsx("div",{className:"orch-task-rail",children:d.jsx(Ab,{status:N.status})}),d.jsxs("div",{className:"orch-task-body",children:[d.jsxs("header",{children:[d.jsxs("div",{children:[d.jsx("h4",{children:N.title}),N.dependsOn.length>0&&d.jsxs("p",{children:["After ",N.dependsOn.map(R=>M.get(R)??R).join(", ")]})]}),d.jsx("span",{className:"orch-task-state",children:aL(N.status)})]}),d.jsx("p",{className:"orch-task-spec",children:N.spec}),j&&d.jsxs("div",{className:"orch-attempt",children:[d.jsxs("button",{type:"button",onClick:()=>m(j.workerChatKey),children:[j.agent," worker #",j.number]}),j.branch&&d.jsx("code",{children:j.branch}),j.isWorktree&&d.jsx("span",{children:"worktree"}),j.summary&&d.jsx("p",{children:j.summary})]}),!j&&N.result&&d.jsx("p",{className:"orch-task-result",children:N.result})]})]},N.id)})]}),s.length>0&&d.jsxs("section",{className:"orch-messages","aria-labelledby":"orch-messages-title",children:[d.jsxs("div",{className:"orch-section-head",children:[d.jsx("h3",{id:"orch-messages-title",children:"Coordination log"}),d.jsxs("span",{children:["Latest ",Math.min(s.length,6)]})]}),s.slice(-6).reverse().map(N=>d.jsxs("article",{children:[d.jsxs("div",{children:[d.jsx("strong",{children:N.subject}),d.jsxs("span",{children:[N.kind," · ",Zee(N.createdAt)]})]}),d.jsx("p",{children:N.body})]},N.id))]})]})}function Ab({status:t}){return d.jsx("span",{className:`orch-status is-${t}`,"aria-hidden":"true"})}function aL(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Zee(t){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(t)}function ag(t){return String(t?.message??t)}function Jee(){return d.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("circle",{cx:"12",cy:"5",r:"2.5"}),d.jsx("circle",{cx:"5",cy:"18",r:"2.5"}),d.jsx("circle",{cx:"19",cy:"18",r:"2.5"}),d.jsx("path",{d:"M12 7.5v4M12 11.5H5v4M12 11.5h7v4"})]})}function ete(){return d.jsxs("div",{className:"orch-glyph","aria-hidden":"true",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{}),d.jsx("i",{}),d.jsx("i",{})]})}function tte(){return d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:d.jsx("path",{d:"M12 5v14M5 12h14"})})}function ite(){return d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:d.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})}function nte(){const[t,e]=w.useState(D0);return w.useEffect(()=>{let i=!0,n=0;const s=()=>{const a=++n;he.invoke("orchestration_snapshot").then(u=>{i&&a===n&&e(u??D0)}).catch(()=>{})},r=he.on("orchestration-changed",s),o=he.onState(a=>a==="open"&&s());return s(),()=>{i=!1,r(),o()}},[]),t}function MD(t){const e=new Map;for(const i of t)e.has(i.slot)||e.set(i.slot,{slot:i.slot,versions:[]}),e.get(i.slot).versions.push(i);return[...e.values()]}const cg=t=>`octiq.preview.${t}.open`;function ste(t,e){const i=w.useRef(new Set),[n,s]=w.useState({key:"",images:[],error:"",open:!1});w.useEffect(()=>{if(!t)return;let a=!0,u=!1;async function h(){if(!(u||document.hidden)){u=!0;try{const m=await he.invoke("image_preview_list",{key:t});if(!a)return;const v=jr(cg(t)),_=v===null&&m.length>0&&!i.current.has(t);_&&(i.current.add(t),ri(cg(t),"1")),s(x=>{const S=x.key===t?x.open:v==="1";return x.key===t&&!x.error&&!_&&x.images.length===m.length&&x.images.every((C,k)=>C.id===m[k].id)?x:{key:t,images:m,error:"",open:_||S}})}catch(m){a&&s(v=>({key:t,images:v.key===t?v.images:[],open:v.key===t?v.open:jr(cg(t))==="1",error:m instanceof Error?m.message:"Previews could not be loaded."}))}finally{u=!1}}}h();const p=setInterval(()=>{h()},e?1200:8e3);return document.addEventListener("visibilitychange",h),()=>{a=!1,clearInterval(p),document.removeEventListener("visibilitychange",h)}},[t,e]);const r=n.key===t?n:{key:t,images:[],error:"",open:!1};function o(a){i.current.add(t),ri(cg(t),a?"1":"0"),s(u=>({...u.key===t?u:r,open:a}))}return{...r,setOpen:o}}const rte={initial:440,min:300,max:780};function ote({count:t,open:e,onClick:i}){return d.jsxs("button",{type:"button",className:`icon-btn sfp-toggle preview-toggle ${e?"is-on":""}`,"aria-label":`Open previews${t?` (${t})`:""}`,"aria-expanded":e,onClick:i,title:"Preview",children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":"true",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),d.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),d.jsx("path",{d:"m4 18 6-6 4 4 3-3 4 4"})]}),d.jsx("span",{className:"topbar-action-label",children:"Preview"}),t>0&&d.jsx("span",{children:t})]})}function cL({image:t,className:e}){const[i,n]=w.useState(""),[s,r]=w.useState(!1);return w.useEffect(()=>{let o=!0,a="";return n(""),r(!1),he.fetchFile(t.path).then(u=>{o&&(a=URL.createObjectURL(u),n(a))}).catch(()=>o&&r(!0)),()=>{o=!1,a&&URL.revokeObjectURL(a)}},[t.path]),s?d.jsx("span",{role:"status",children:"Image unavailable"}):i?d.jsx("img",{className:e,src:i,alt:t.title,draggable:!1,onError:()=>r(!0)}):d.jsx("span",{className:"preview-loading",children:"Loading…"})}function lte({document:t}){const[e,i]=w.useState("");function n(){i("");try{he.openFileInBrowser(t.path)}catch(s){i(s instanceof Error?s.message:"The document could not be opened.")}}return d.jsxs("div",{className:"html-preview-card",children:[d.jsx("span",{className:"html-preview-mark","aria-hidden":"true",children:"</>"}),d.jsx("strong",{children:t.title}),d.jsx("p",{children:"Open this document in a new tab. Your chat stays here."}),d.jsx("button",{type:"button",onClick:n,children:"Open HTML"}),e&&d.jsx("p",{className:"image-preview-error",role:"alert",children:e})]})}function ate({conversationKey:t,images:e,error:i,onClose:n}){const s=`octiq.preview.${t}.selection`,[r,o]=w.useState(()=>jr(s)||""),[a,u]=w.useState(1),[h,p]=w.useState(!1),{width:m,startDrag:v}=Gf("octiq.preview.width",rte),_=w.useMemo(()=>MD(e),[e]),x=e.find(L=>L.id===r)??e.at(-1),S=_.find(L=>L.slot===x?.slot)?.versions??[],C=S.findIndex(L=>L.id===x?.id),k=S.at(-1);w.useEffect(()=>{x&&x.id!==r&&(o(x.id),ri(s,x.id))},[x,r,s]),w.useEffect(()=>{u(1),p(!1)},[x?.id]),w.useEffect(()=>{function L(N){N.key==="Escape"&&!h&&n()}return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[n,h]);function M(L){o(L),ri(s,L)}return d.jsxs(d.Fragment,{children:[d.jsx("button",{className:"image-preview-scrim","aria-label":"Close previews",onClick:n}),d.jsxs("aside",{className:"image-preview-panel","aria-label":"Preview panel",style:{"--preview-width":`${m}px`},children:[d.jsx("div",{className:"image-preview-resize",onPointerDown:v,"aria-hidden":"true"}),d.jsxs("header",{className:"image-preview-header",children:[d.jsx("strong",{children:"Preview"}),d.jsx("span",{children:_.length?`${_.length} preview${_.length===1?"":"s"}`:""}),d.jsx("button",{type:"button",onClick:n,"aria-label":"Close preview",children:"✕"})]}),i&&d.jsx("p",{className:"image-preview-error",role:"status",children:i}),x?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"image-preview-caption",children:[d.jsx("strong",{title:x.title,children:x.title}),d.jsxs("label",{children:["Version ",d.jsx("select",{"aria-label":"Preview version",value:x.id,onChange:L=>M(L.target.value),children:S.map((L,N)=>d.jsxs("option",{value:L.id,children:[N+1,N===S.length-1?" (latest)":""]},L.id))})]})]}),k&&k.id!==x.id&&d.jsx("button",{type:"button",className:"image-preview-update",onClick:()=>M(k.id),children:"Newer version available · Show latest"}),x.kind==="html"?d.jsx(lte,{document:x},x.id):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:`image-preview-stage ${a>1?"is-zoomed":""}`,children:d.jsx("div",{className:"image-preview-picture",style:{width:`${a*100}%`,height:`${a*100}%`},children:d.jsx(cL,{image:x},x.id)})}),d.jsxs("div",{className:"image-preview-tools",children:[d.jsx("button",{type:"button","aria-label":"Zoom out",disabled:a<=1,onClick:()=>u(L=>Math.max(1,L-.5)),children:"−"}),d.jsx("button",{type:"button",title:"Fit image",onClick:()=>u(1),children:a===1?"Fit":`${a}×`}),d.jsx("button",{type:"button","aria-label":"Zoom in",disabled:a>=4,onClick:()=>u(L=>Math.min(4,L+.5)),children:"+"}),d.jsxs("span",{children:["v",C+1," / ",S.length]}),d.jsx("button",{type:"button",onClick:()=>p(!0),children:"Full screen"})]})]}),d.jsx("div",{className:"image-preview-strip","aria-label":"Preview items",children:_.map(L=>{const N=L.versions.at(-1);return d.jsxs("button",{type:"button",className:L.slot===x.slot?"is-selected":"","aria-label":`${N.title}, ${L.versions.length} version${L.versions.length===1?"":"s"}`,"aria-pressed":L.slot===x.slot,onClick:()=>M(N.id),children:[N.kind==="html"?d.jsxs("span",{className:"html-preview-thumbnail","aria-hidden":"true",children:["</>",d.jsx("small",{children:"HTML"})]}):d.jsx(cL,{image:N}),d.jsx("span",{children:N.title})]},L.slot)})}),h&&x.kind!=="html"&&d.jsx(j4,{path:x.path,onClose:()=>p(!1)},x.id)]}):d.jsxs("div",{className:"image-preview-empty",children:[d.jsx("strong",{children:"See what your agent is making"}),d.jsx("p",{children:"Ask your agent to share an image or HTML document here. New versions stay together so you can compare them."})]})]})]})}const cte=new Set(["mcp__octiq__pin_file","pin_file"]),ute=25,uL=24;function zg(t){return t.map(e=>e.path)}function hte(t){return dte(t).slice(0,ute)}function dte(t){for(let e=t.length-1;e>=0;e-=1){const i=t[e];if(!i.parent)for(let n=i.blocks.length-1;n>=0;n-=1){const s=i.blocks[n];if(s.kind!=="tool"||!cte.has(s.name.toLowerCase()))continue;const r=fte(s.args);if(r)return r}}return[]}function fte(t){if(!t||typeof t!="object")return null;const e=t.files;if(!Array.isArray(e))return null;const i=[],n=new Set;for(const s of e){if(!s||typeof s!="object")continue;const r=s,o=typeof r.path=="string"?r.path.trim():"";if(!o||n.has(o))continue;n.add(o);const a=pte(r.label),u=typeof r.why=="string"?r.why.trim():"",h=typeof r.line=="number"&&Number.isInteger(r.line)&&r.line>0?r.line:void 0;i.push({path:o,...a?{label:a}:{},...u?{why:u}:{},...h?{line:h}:{}})}return i}function pte(t){if(typeof t!="string")return"";const e=t.replace(/\s+/g," ").trim();return e.length>uL?`${e.slice(0,uL).trimEnd()}…`:e}const mte="octiq.v2.filesWidth",gte={initial:340,min:260,max:620},vte=1200,_te=8,Nu="*";function yte(t,e,i,n){const[s,r]=w.useState([]),[o,a]=w.useState(0),u=w.useRef(t);u.current=t;const h=`${t.length}:${t[0]?.id??""}`;w.useEffect(()=>{if(a(_=>_+1),!n||!i)return;const v=setInterval(()=>a(_=>_+1),vte);return()=>clearInterval(v)},[n,i,h]);const p=w.useMemo(()=>hte(u.current),[o]),m=w.useMemo(()=>zg(p).join(`
|
|
197
|
+
`),[p]);return w.useEffect(()=>{const v=()=>{const x=kQ(zg(p),e),S=[];for(const C of p){const k=x.get(C.path);typeof k=="string"&&S.push({...C,path:k})}r(C=>C.length===S.length&&C.every((k,M)=>k.path===S[M].path&&k.why===S[M].why&&k.label===S[M].label)?C:S)};v();const _=$4(v);return z4(zg(p),e),_},[m,e]),s}function xte(t,e,i){const[n,s]=w.useState(new Map),r=t.join(`
|
|
198
|
+
`);return w.useEffect(()=>{if(!e||t.length===0)return;let o=!0;return he.invoke("stat_paths",{paths:t}).then(a=>{o&&s(new Map(t.map((u,h)=>[u,a?.[h]??null])))}).catch(()=>{}),()=>{o=!1}},[r,e,i]),n}function bte({count:t,open:e,onToggle:i}){return t===0?null:d.jsxs("button",{className:`icon-btn sfp-toggle ${e?"is-on":""}`,type:"button","aria-expanded":e,"aria-label":`Files worth opening — ${t}`,title:`${t} file${t===1?"":"s"} worth opening`,onClick:i,children:[d.jsx(AD,{}),d.jsx("span",{className:"topbar-action-label",children:"Pinned files"}),d.jsx("span",{className:"sfp-count",children:d.jsx(us,{value:t})})]})}function wte({pins:t,open:e,busy:i,onClose:n}){const s=ev(),[r,o]=w.useState(""),[a,u]=w.useState(Nu),h=w.useMemo(()=>zg(t),[t]),p=xte(h,e,i),{width:m,startDrag:v,entered:_}=Gf(mte,gte),x=w.useMemo(()=>dW(h),[h]),S=r.trim().toLowerCase(),C=w.useMemo(()=>{let M=t;return a!==Nu&&(M=M.filter(L=>Mh(L.path)===a)),S&&(M=M.filter(L=>L.path.toLowerCase().includes(S)||(L.label??"").toLowerCase().includes(S)||(L.why??"").toLowerCase().includes(S))),M},[t,S,a]),k=a!==Nu&&!x.some(M=>M.ext===a);return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:`gitp-scrim ${_&&e?"is-open":""}`,onClick:n,"aria-hidden":"true"}),d.jsxs("aside",{className:`sfp-panel ${_&&e?"is-open":""}`,"aria-label":"Files worth opening",style:{"--gitp-w":`${m}px`},children:[d.jsx("div",{className:"gitp-resizer",role:"separator","aria-orientation":"vertical","aria-label":"Resize the files panel",onPointerDown:v}),d.jsxs("header",{className:"gitp-head",children:[d.jsx("span",{className:"gitp-title",children:"Files"}),d.jsx("span",{className:"gitp-project",children:d.jsx(ct,{children:C.length!==t.length?`${C.length} of ${t.length}`:`${t.length} to read`})}),d.jsx("button",{className:"gitp-close",type:"button","aria-label":"Close",onClick:n,children:"✕"})]}),t.length>=_te&&d.jsxs("div",{className:"sfp-filter",children:[d.jsx("input",{type:"search",value:r,placeholder:"Filter by name or reason","aria-label":"Filter files",onChange:M=>o(M.target.value)}),x.length>1&&d.jsxs("select",{className:"sfp-type",value:a,"aria-label":"Filter by file type",onChange:M=>u(M.target.value),children:[d.jsxs("option",{value:Nu,children:["All types (",t.length,")"]}),x.map(M=>d.jsxs("option",{value:M.ext,children:[NE(M.ext)," (",M.count,")"]},M.ext)),k&&d.jsxs("option",{value:a,children:[NE(a)," (0)"]})]})]}),d.jsxs("div",{className:"gitp-body sfp-body",children:[t.length===0&&d.jsx("div",{className:"gitp-note",children:"Nothing yet. Files show up here when the agent pins one worth reading."}),t.length>0&&C.length===0&&d.jsxs("div",{className:"gitp-note",children:["No file here matches that."," ",a!==Nu&&d.jsx("button",{className:"sfp-clear",type:"button",onClick:()=>u(Nu),children:"Show every type"})]}),d.jsx("ul",{className:"sfp-list",children:C.map(M=>d.jsx(kte,{pin:M,modified:p.get(M.path),onOpen:s},M.path))})]})]})]})}const Ste=2500;function kte({pin:t,modified:e,onOpen:i}){const n=rS(t.path),s=Cte(t.path);return d.jsxs("li",{className:"sfp-row",children:[d.jsxs("button",{className:`file sfp-pin ${n?"is-image":""}`,type:"button",title:t.path,onClick:()=>i(t.path),children:[d.jsx("span",{className:"file-icon","aria-hidden":"true",children:n?d.jsx(Ete,{}):d.jsx(AD,{})}),d.jsx("span",{className:"file-name",children:Vi(t.path)}),d.jsx("span",{className:"file-dir",children:d.jsx("bdi",{children:t.path.slice(0,t.path.length-Vi(t.path).length)})}),d.jsx("span",{className:"file-time",title:pW(e),children:d.jsx(ct,{children:fW(e)})}),(t.label||t.why||t.line)&&d.jsxs("span",{className:"sfp-why",children:[t.label&&d.jsx("span",{className:"sfp-label",children:t.label}),t.why,t.line?d.jsxs("span",{className:"sfp-line",children:[t.why?" ":"","line ",t.line]}):null]})]}),d.jsxs("span",{className:"sfp-acts",children:[d.jsx(l0,{icon:d.jsx(tv,{}),idle:"Copy the path",done:"Path copied",read:()=>({text:t.path})}),!n&&d.jsx(l0,{icon:d.jsx(Pj,{}),idle:"Copy what is in the file",done:"File copied",empty:"Nothing to copy — this file is not text",partial:"Copied the first part — the file is too big to read whole",arm:s.arm,read:s.read})]})]})}function Cte(t){const e=w.useRef(null),i=w.useRef(null),n=()=>e.current&&Date.now()-e.current.at<Ste?e.current.value:null,s=()=>{if(i.current)return i.current;const r=he.invoke("read_file_preview",{path:t}).then(o=>o?.kind==="text"?{text:o.content,partial:o.truncated}:{text:null}).catch(()=>({text:null})).then(o=>(e.current={at:Date.now(),value:o},i.current=null,o));return i.current=r,r};return{arm:()=>{n()||s()},read:()=>n()??s()}}function AD(){return d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"}),d.jsx("path",{d:"M14 2v6h6"})]})}function Ete(){return d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),d.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),d.jsx("path",{d:"m21 15-5-5L5 21"})]})}function Mte({expanded:t,onToggle:e}){return d.jsx("button",{className:`icon-btn chat-width-toggle ${t?"is-on":""}`,type:"button","aria-pressed":t,"aria-label":t?"Restore standard chat width":"Expand chat to full width",title:t?"Restore standard chat width":"Expand chat to full width",onClick:e,children:d.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsxs("g",{className:"chat-width-arrows chat-width-arrows-in",children:[d.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}),d.jsx("path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}),d.jsx("path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"}),d.jsx("path",{d:"M3 16v3a2 2 0 0 0 2 2h3"})]}),d.jsxs("g",{className:"chat-width-arrows chat-width-arrows-out",children:[d.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}),d.jsx("path",{d:"M21 8h-3a2 2 0 0 1-2-2V3"}),d.jsx("path",{d:"M16 21v-3a2 2 0 0 1 2-2h3"}),d.jsx("path",{d:"M3 16h3a2 2 0 0 1 2 2v3"})]})]})})}function Ate({show:t,onReload:e=()=>location.reload()}={}){const[i]=w.useState(()=>t??AN()),[n,s]=w.useState(!1);return i?d.jsxs("button",{className:`icon-btn installed-reload ${n?"is-spinning":""}`,type:"button","aria-label":"Reload",title:"Reload",onClick:()=>{s(!0),e()},children:[d.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M20 11a8 8 0 1 0-.6 4"}),d.jsx("path",{d:"M20 4v6h-6"})]}),d.jsx("span",{className:"topbar-action-label",children:"Reload"})]}):null}function Lte({chatId:t}){const[e,i]=w.useState("idle"),n=w.useRef(null),s=e==="done"?"Chat ID copied":e==="failed"?"Could not copy chat ID":"Copy chat ID";return w.useEffect(()=>()=>{n.current!==null&&clearTimeout(n.current)},[]),d.jsxs("button",{className:`icon-btn copy-chat-id is-${e}`,type:"button","aria-label":s,title:s,onClick:async()=>{i(await Yf(t)?"done":"failed"),n.current!==null&&clearTimeout(n.current),n.current=setTimeout(()=>i("idle"),1600)},children:[e==="done"?d.jsx(nS,{}):d.jsx(tv,{}),d.jsx("span",{className:"topbar-action-label",children:s})]})}function Tte({children:t,attentionCount:e=0,initiallyOpen:i=!1}){const[n,s]=w.useState(i),r=w.useId(),o=w.useRef(null),a=w.useRef(null);return w.useEffect(()=>{if(!n)return;function u(h){h.target instanceof Node&&!o.current?.contains(h.target)&&s(!1)}return document.addEventListener("pointerdown",u),()=>document.removeEventListener("pointerdown",u)},[n]),d.jsxs("div",{className:"mobile-actions",ref:o,onKeyDown:u=>{u.key!=="Escape"||!n||(u.preventDefault(),s(!1),a.current?.focus())},children:[d.jsxs("button",{ref:a,className:"icon-btn mobile-actions-trigger",type:"button","aria-label":e>0?`Chat actions, ${e} ${e===1?"item needs":"items need"} attention`:"Chat actions","aria-expanded":n,"aria-controls":r,title:"Chat actions",onClick:()=>s(u=>!u),children:[d.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[d.jsx("circle",{cx:"5",cy:"12",r:"1.7"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.7"}),d.jsx("circle",{cx:"19",cy:"12",r:"1.7"})]}),e>0&&d.jsx("span",{className:"mobile-actions-attention","aria-hidden":"true",children:e})]}),n&&d.jsx("div",{id:r,className:"mobile-actions-panel",role:"group","aria-label":"Chat actions",onClick:u=>{const h=u.target instanceof Element?u.target:null;h?.closest(".attention-trigger, .copy-chat-id, .open-beside-trigger")||h?.closest("button, a")&&s(!1)},children:t})]})}function Nte(t){if(!t||typeof t!="object")return null;const{id:e,label:i,command:n}=t;if(typeof e!="string"||typeof i!="string"||typeof n!="string")return null;const s={id:e.trim(),label:i.trim(),command:n.trim()};return s.id&&s.label&&s.command?s:null}function jte(t){if(!Array.isArray(t))return[];const e=[];for(const i of t){const n=Nte(i);n&&e.push(n)}return e}function Rte(t,e){return!!t.trim()&&!!e.trim()}function Dte(t,e,i){return t.label===e.trim()&&t.command===i.trim()}const Bte=t=>`term:${t}`;function Ote(t){const e=new Set(t.map(i=>i.name));for(let i=1;;i++){const n=`sh ${i}`;if(!e.has(n))return n}}function Ite(t,e){const i=new Set(e.map(n=>n.name));if(!i.has(t))return t;for(let n=2;;n++){const s=`${t} ${n}`;if(!i.has(s))return s}}function Pte(t,e){const i=t[e];if(i&&i.tabs.length)return i.tabs.some(s=>s.id===i.active)?i:{...i,active:i.tabs[0].id};const n=Bte(e);return{tabs:[{id:n,name:"sh 1"}],active:n,seq:i?.seq??1}}function hL(t,e,i={}){const n=`term:${e}:${t.seq}`,s=(i.name??"").trim(),r=(i.cmd??"").trim(),o={id:n,name:s?Ite(s,t.tabs):Ote(t.tabs)};return r&&(o.cmd=r),{tabs:[...t.tabs,o],active:n,seq:t.seq+1}}function zte(t,e){const i=t.tabs.findIndex(r=>r.id===e);if(i<0)return t;const n=t.tabs.filter(r=>r.id!==e);if(!n.length)return{...t,tabs:[],active:""};const s=t.active===e?n[Math.max(0,i-1)].id:t.active;return{...t,tabs:n,active:s}}function $te(t,e,i){const n=i.trim();return!n||!t.tabs.some(s=>s.id===e)?t:{...t,tabs:t.tabs.map(s=>s.id===e?{...s,name:n}:s)}}function Fte(t,e){return t.tabs.some(i=>i.id===e)?{...t,active:e}:t}function Hte(t){if(!t||typeof t!="object")return null;const e=t;if(!Array.isArray(e.tabs))return null;const i=[];for(const n of e.tabs){if(!n||typeof n!="object")return null;const{id:s,name:r,cmd:o}=n;if(typeof s!="string"||!s||typeof r!="string")return null;i.push(typeof o=="string"&&o?{id:s,name:r,cmd:o}:{id:s,name:r})}return{tabs:i,active:typeof e.active=="string"?e.active:"",seq:typeof e.seq=="number"&&e.seq>=0?e.seq:i.length}}function Wte(t){if(!t)return{};let e;try{e=JSON.parse(t)}catch{return{}}if(!e||typeof e!="object"||Array.isArray(e))return{};const i={};for(const[n,s]of Object.entries(e)){const r=Hte(s);r&&(i[n]=r)}return i}var LD=Object.defineProperty,qte=Object.getOwnPropertyDescriptor,Ute=(t,e)=>{for(var i in e)LD(t,i,{get:e[i],enumerable:!0})},zi=(t,e,i,n)=>{for(var s=n>1?void 0:n?qte(e,i):e,r=t.length-1,o;r>=0;r--)(o=t[r])&&(s=(n?o(e,i,s):o(s))||s);return n&&s&&LD(e,i,s),s},Ie=(t,e)=>(i,n)=>e(i,n,t),dL="Terminal input",Lb={get:()=>dL,set:t=>dL=t},fL="Too much output to announce, navigate to rows manually to read",Tb={get:()=>fL,set:t=>fL=t};function Vte(t){return t.replace(/\r?\n/g,"\r")}function Kte(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function Yte(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function Gte(t,e,i,n){if(t.stopPropagation(),t.clipboardData){let s=t.clipboardData.getData("text/plain");TD(s,e,i,n)}}function TD(t,e,i,n){t=Vte(t),t=Kte(t,i.decPrivateModes.bracketedPasteMode&&n.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(t,!0),e.value=""}function ND(t,e,i){let n=i.getBoundingClientRect(),s=t.clientX-n.left-10,r=t.clientY-n.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${s}px`,e.style.top=`${r}px`,e.style.zIndex="1000",e.focus()}function pL(t,e,i,n,s){ND(t,e,i),s&&n.rightClickSelect(t),e.value=n.selectionText,e.select()}function xa(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function gv(t,e=0,i=t.length){let n="";for(let s=e;s<i;++s){let r=t[s];r>65535?(r-=65536,n+=String.fromCharCode((r>>10)+55296)+String.fromCharCode(r%1024+56320)):n+=String.fromCharCode(r)}return n}var Qte=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,i){let n=e.length;if(!n)return 0;let s=0,r=0;if(this._interim){let o=e.charCodeAt(r++);56320<=o&&o<=57343?i[s++]=(this._interim-55296)*1024+o-56320+65536:(i[s++]=this._interim,i[s++]=o),this._interim=0}for(let o=r;o<n;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=n)return this._interim=a,s;let u=e.charCodeAt(o);56320<=u&&u<=57343?i[s++]=(a-55296)*1024+u-56320+65536:(i[s++]=a,i[s++]=u);continue}a!==65279&&(i[s++]=a)}return s}},Xte=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,i){let n=e.length;if(!n)return 0;let s=0,r,o,a,u,h=0,p=0;if(this.interim[0]){let _=!1,x=this.interim[0];x&=(x&224)===192?31:(x&240)===224?15:7;let S=0,C;for(;(C=this.interim[++S]&63)&&S<4;)x<<=6,x|=C;let k=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,M=k-S;for(;p<M;){if(p>=n)return 0;if(C=e[p++],(C&192)!==128){p--,_=!0;break}else this.interim[S++]=C,x<<=6,x|=C&63}_||(k===2?x<128?p--:i[s++]=x:k===3?x<2048||x>=55296&&x<=57343||x===65279||(i[s++]=x):x<65536||x>1114111||(i[s++]=x)),this.interim.fill(0)}let m=n-4,v=p;for(;v<n;){for(;v<m&&!((r=e[v])&128)&&!((o=e[v+1])&128)&&!((a=e[v+2])&128)&&!((u=e[v+3])&128);)i[s++]=r,i[s++]=o,i[s++]=a,i[s++]=u,v+=4;if(r=e[v++],r<128)i[s++]=r;else if((r&224)===192){if(v>=n)return this.interim[0]=r,s;if(o=e[v++],(o&192)!==128){v--;continue}if(h=(r&31)<<6|o&63,h<128){v--;continue}i[s++]=h}else if((r&240)===224){if(v>=n)return this.interim[0]=r,s;if(o=e[v++],(o&192)!==128){v--;continue}if(v>=n)return this.interim[0]=r,this.interim[1]=o,s;if(a=e[v++],(a&192)!==128){v--;continue}if(h=(r&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;i[s++]=h}else if((r&248)===240){if(v>=n)return this.interim[0]=r,s;if(o=e[v++],(o&192)!==128){v--;continue}if(v>=n)return this.interim[0]=r,this.interim[1]=o,s;if(a=e[v++],(a&192)!==128){v--;continue}if(v>=n)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=a,s;if(u=e[v++],(u&192)!==128){v--;continue}if(h=(r&7)<<18|(o&63)<<12|(a&63)<<6|u&63,h<65536||h>1114111)continue;i[s++]=h}}return s}},jD="",Ea=" ",sp=class RD{constructor(){this.fg=0,this.bg=0,this.extended=new O0}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new RD;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}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}},O0=class DD{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new DD(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ir=class BD extends sp{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new O0,this.combinedData=""}static fromCharData(e){let i=new BD;return i.setFromCharData(e),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?xa(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let i=!1;if(e[1].length>2)i=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(n-55296)*1024+s-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},mL="di$target",Nb="di$dependencies",Sy=new Map;function Zte(t){return t[Nb]||[]}function Ln(t){if(Sy.has(t))return Sy.get(t);let e=function(i,n,s){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Jte(e,i,s)};return e._id=t,Sy.set(t,e),e}function Jte(t,e,i){e[mL]===e?e[Nb].push({id:t,index:i}):(e[Nb]=[{id:t,index:i}],e[mL]=e)}var ms=Ln("BufferService"),OD=Ln("CoreMouseService"),qc=Ln("CoreService"),eie=Ln("CharsetService"),qS=Ln("InstantiationService"),ID=Ln("LogService"),gs=Ln("OptionsService"),PD=Ln("OscLinkService"),tie=Ln("UnicodeService"),rp=Ln("DecorationService"),jb=class{constructor(e,i,n){this._bufferService=e,this._optionsService=i,this._oscLinkService=n}provideLinks(e,i){let n=this._bufferService.buffer.lines.get(e-1);if(!n){i(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,o=new Ir,a=n.getTrimmedLength(),u=-1,h=-1,p=!1;for(let m=0;m<a;m++)if(!(h===-1&&!n.hasContent(m))){if(n.loadCell(m,o),o.hasExtendedAttrs()&&o.extended.urlId)if(h===-1){h=m,u=o.extended.urlId;continue}else p=o.extended.urlId!==u;else h!==-1&&(p=!0);if(p||h!==-1&&m===a-1){let v=this._oscLinkService.getLinkData(u)?.uri;if(v){let _={start:{x:h+1,y:e},end:{x:m+(!p&&m===a-1?1:0),y:e}},x=!1;if(!r?.allowNonHttpProtocols)try{let S=new URL(v);["http:","https:"].includes(S.protocol)||(x=!0)}catch{x=!0}x||s.push({text:v,range:_,activate:(S,C)=>r?r.activate(S,C,_):iie(S,C),hover:(S,C)=>r?.hover?.(S,C,_),leave:(S,C)=>r?.leave?.(S,C,_)})}p=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=m,u=o.extended.urlId):(h=-1,u=-1)}}i(s)}};jb=zi([Ie(0,ms),Ie(1,gs),Ie(2,PD)],jb);function iie(t,e){if(confirm(`Do you want to navigate to ${e}?
|
|
199
|
+
|
|
200
|
+
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var vv=Ln("CharSizeService"),El=Ln("CoreBrowserService"),US=Ln("MouseService"),Ml=Ln("RenderService"),nie=Ln("SelectionService"),zD=Ln("CharacterJoinerService"),Nh=Ln("ThemeService"),$D=Ln("LinkProviderService"),sie=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?gL.isErrorNoTelemetry(e)?new gL(e.message+`
|
|
201
|
+
|
|
202
|
+
`+e.stack):new Error(e.message+`
|
|
203
|
+
|
|
204
|
+
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(i=>{i(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)}},rie=new sie;function $g(t){oie(t)||rie.onUnexpectedError(t)}var Rb="Canceled";function oie(t){return t instanceof lie?!0:t instanceof Error&&t.name===Rb&&t.message===Rb}var lie=class extends Error{constructor(){super(Rb),this.name=this.message}};function aie(t){return new Error(`Illegal argument: ${t}`)}var gL=class Db extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof Db)return e;let i=new Db;return i.message=e.message,i.stack=e.stack,i}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},Bb=class FD extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,FD.prototype)}};function Zs(t,e=0){return t[t.length-(1+e)]}var cie;(t=>{function e(r){return r<0}t.isLessThan=e;function i(r){return r<=0}t.isLessThanOrEqual=i;function n(r){return r>0}t.isGreaterThan=n;function s(r){return r===0}t.isNeitherLessOrGreaterThan=s,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(cie||={});function uie(t,e){let i=this,n=!1,s;return function(){return n||(n=!0,e||(s=t.apply(i,arguments))),s}}var HD;(t=>{function e(N){return N&&typeof N=="object"&&typeof N[Symbol.iterator]=="function"}t.is=e;let i=Object.freeze([]);function n(){return i}t.empty=n;function*s(N){yield N}t.single=s;function r(N){return e(N)?N:s(N)}t.wrap=r;function o(N){return N||i}t.from=o;function*a(N){for(let j=N.length-1;j>=0;j--)yield N[j]}t.reverse=a;function u(N){return!N||N[Symbol.iterator]().next().done===!0}t.isEmpty=u;function h(N){return N[Symbol.iterator]().next().value}t.first=h;function p(N,j){let R=0;for(let z of N)if(j(z,R++))return!0;return!1}t.some=p;function m(N,j){for(let R of N)if(j(R))return R}t.find=m;function*v(N,j){for(let R of N)j(R)&&(yield R)}t.filter=v;function*_(N,j){let R=0;for(let z of N)yield j(z,R++)}t.map=_;function*x(N,j){let R=0;for(let z of N)yield*j(z,R++)}t.flatMap=x;function*S(...N){for(let j of N)yield*j}t.concat=S;function C(N,j,R){let z=R;for(let J of N)z=j(z,J);return z}t.reduce=C;function*k(N,j,R=N.length){for(j<0&&(j+=N.length),R<0?R+=N.length:R>N.length&&(R=N.length);j<R;j++)yield N[j]}t.slice=k;function M(N,j=Number.POSITIVE_INFINITY){let R=[];if(j===0)return[R,N];let z=N[Symbol.iterator]();for(let J=0;J<j;J++){let G=z.next();if(G.done)return[R,t.empty()];R.push(G.value)}return[R,{[Symbol.iterator](){return z}}]}t.consume=M;async function L(N){let j=[];for await(let R of N)j.push(R);return Promise.resolve(j)}t.asyncToArray=L})(HD||={});function Pc(t){if(HD.is(t)){let e=[];for(let i of t)if(i)try{i.dispose()}catch(n){e.push(n)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function hie(...t){return Ai(()=>Pc(t))}function Ai(t){return{dispose:uie(()=>{t()})}}var WD=class qD{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{Pc(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?qD.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(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};WD.DISABLE_DISPOSED_WARNING=!1;var Aa=WD,yt=class{constructor(){this._store=new Aa,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)}};yt.None=Object.freeze({dispose(){}});var Sh=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}},yl=typeof window=="object"?window:globalThis,Ob=class Ib{constructor(e){this.element=e,this.next=Ib.Undefined,this.prev=Ib.Undefined}};Ob.Undefined=new Ob(void 0);var Li=Ob,vL=class{constructor(){this._first=Li.Undefined,this._last=Li.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Li.Undefined}clear(){let e=this._first;for(;e!==Li.Undefined;){let i=e.next;e.prev=Li.Undefined,e.next=Li.Undefined,e=i}this._first=Li.Undefined,this._last=Li.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,i){let n=new Li(e);if(this._first===Li.Undefined)this._first=n,this._last=n;else if(i){let r=this._last;this._last=n,n.prev=r,r.next=n}else{let r=this._first;this._first=n,n.next=r,r.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==Li.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Li.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Li.Undefined&&e.next!==Li.Undefined){let i=e.prev;i.next=e.next,e.next.prev=i}else e.prev===Li.Undefined&&e.next===Li.Undefined?(this._first=Li.Undefined,this._last=Li.Undefined):e.next===Li.Undefined?(this._last=this._last.prev,this._last.next=Li.Undefined):e.prev===Li.Undefined&&(this._first=this._first.next,this._first.prev=Li.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Li.Undefined;)yield e.element,e=e.next}},die=globalThis.performance&&typeof globalThis.performance.now=="function",fie=class UD{static create(e){return new UD(e)}constructor(e){this._now=die&&e===!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}},zn;(t=>{t.None=()=>yt.None;function e(I,T){return m(I,()=>{},0,void 0,!0,void 0,T)}t.defer=e;function i(I){return(T,H=null,F)=>{let P=!1,U;return U=I(V=>{if(!P)return U?U.dispose():P=!0,T.call(H,V)},null,F),P&&U.dispose(),U}}t.once=i;function n(I,T,H){return h((F,P=null,U)=>I(V=>F.call(P,T(V)),null,U),H)}t.map=n;function s(I,T,H){return h((F,P=null,U)=>I(V=>{T(V),F.call(P,V)},null,U),H)}t.forEach=s;function r(I,T,H){return h((F,P=null,U)=>I(V=>T(V)&&F.call(P,V),null,U),H)}t.filter=r;function o(I){return I}t.signal=o;function a(...I){return(T,H=null,F)=>{let P=hie(...I.map(U=>U(V=>T.call(H,V))));return p(P,F)}}t.any=a;function u(I,T,H,F){let P=H;return n(I,U=>(P=T(P,U),P),F)}t.reduce=u;function h(I,T){let H,F={onWillAddFirstListener(){H=I(P.fire,P)},onDidRemoveLastListener(){H?.dispose()}},P=new Te(F);return T?.add(P),P.event}function p(I,T){return T instanceof Array?T.push(I):T&&T.add(I),I}function m(I,T,H=100,F=!1,P=!1,U,V){let K,D,$,Y=0,B,ee={leakWarningThreshold:U,onWillAddFirstListener(){K=I(re=>{Y++,D=T(D,re),F&&!$&&(ie.fire(D),D=void 0),B=()=>{let ge=D;D=void 0,$=void 0,(!F||Y>1)&&ie.fire(ge),Y=0},typeof H=="number"?(clearTimeout($),$=setTimeout(B,H)):$===void 0&&($=0,queueMicrotask(B))})},onWillRemoveListener(){P&&Y>0&&B?.()},onDidRemoveLastListener(){B=void 0,K.dispose()}},ie=new Te(ee);return V?.add(ie),ie.event}t.debounce=m;function v(I,T=0,H){return t.debounce(I,(F,P)=>F?(F.push(P),F):[P],T,void 0,!0,void 0,H)}t.accumulate=v;function _(I,T=(F,P)=>F===P,H){let F=!0,P;return r(I,U=>{let V=F||!T(U,P);return F=!1,P=U,V},H)}t.latch=_;function x(I,T,H){return[t.filter(I,T,H),t.filter(I,F=>!T(F),H)]}t.split=x;function S(I,T=!1,H=[],F){let P=H.slice(),U=I(D=>{P?P.push(D):K.fire(D)});F&&F.add(U);let V=()=>{P?.forEach(D=>K.fire(D)),P=null},K=new Te({onWillAddFirstListener(){U||(U=I(D=>K.fire(D)),F&&F.add(U))},onDidAddFirstListener(){P&&(T?setTimeout(V):V())},onDidRemoveLastListener(){U&&U.dispose(),U=null}});return F&&F.add(K),K.event}t.buffer=S;function C(I,T){return(H,F,P)=>{let U=T(new M);return I(function(V){let K=U.evaluate(V);K!==k&&H.call(F,K)},void 0,P)}}t.chain=C;let k=Symbol("HaltChainable");class M{constructor(){this.steps=[]}map(T){return this.steps.push(T),this}forEach(T){return this.steps.push(H=>(T(H),H)),this}filter(T){return this.steps.push(H=>T(H)?H:k),this}reduce(T,H){let F=H;return this.steps.push(P=>(F=T(F,P),F)),this}latch(T=(H,F)=>H===F){let H=!0,F;return this.steps.push(P=>{let U=H||!T(P,F);return H=!1,F=P,U?P:k}),this}evaluate(T){for(let H of this.steps)if(T=H(T),T===k)break;return T}}function L(I,T,H=F=>F){let F=(...K)=>V.fire(H(...K)),P=()=>I.on(T,F),U=()=>I.removeListener(T,F),V=new Te({onWillAddFirstListener:P,onDidRemoveLastListener:U});return V.event}t.fromNodeEventEmitter=L;function N(I,T,H=F=>F){let F=(...K)=>V.fire(H(...K)),P=()=>I.addEventListener(T,F),U=()=>I.removeEventListener(T,F),V=new Te({onWillAddFirstListener:P,onDidRemoveLastListener:U});return V.event}t.fromDOMEventEmitter=N;function j(I){return new Promise(T=>i(I)(T))}t.toPromise=j;function R(I){let T=new Te;return I.then(H=>{T.fire(H)},()=>{T.fire(void 0)}).finally(()=>{T.dispose()}),T.event}t.fromPromise=R;function z(I,T){return I(H=>T.fire(H))}t.forward=z;function J(I,T,H){return T(H),I(F=>T(F))}t.runAndSubscribe=J;class G{constructor(T,H){this._observable=T,this._counter=0,this._hasChanged=!1;let F={onWillAddFirstListener:()=>{T.addObserver(this)},onDidRemoveLastListener:()=>{T.removeObserver(this)}};this.emitter=new Te(F),H&&H.add(this.emitter)}beginUpdate(T){this._counter++}handlePossibleChange(T){}handleChange(T,H){this._hasChanged=!0}endUpdate(T){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function q(I,T){return new G(I,T).emitter.event}t.fromObservable=q;function X(I){return(T,H,F)=>{let P=0,U=!1,V={beginUpdate(){P++},endUpdate(){P--,P===0&&(I.reportChanges(),U&&(U=!1,T.call(H)))},handlePossibleChange(){},handleChange(){U=!0}};I.addObserver(V),I.reportChanges();let K={dispose(){I.removeObserver(V)}};return F instanceof Aa?F.add(K):Array.isArray(F)&&F.push(K),K}}t.fromObservableLight=X})(zn||={});var Pb=class zb{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${zb._idPool++}`,zb.all.add(this)}start(e){this._stopWatch=new fie,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Pb.all=new Set,Pb._idPool=0;var pie=Pb,mie=-1,VD=class KD{constructor(e,i,n=(KD._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=i,this.name=n,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,i){let n=this.threshold;if(n<=0||i<n)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=n*.5;let[r,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(r);let u=new _ie(a,r);this._errorHandler(u)}return()=>{let r=this._stacks.get(e.value)||0;this._stacks.set(e.value,r-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,i=0;for(let[n,s]of this._stacks)(!e||i<s)&&(e=[n,s],i=s);return e}};VD._idPool=1;var gie=VD,vie=class YD{constructor(e){this.value=e}static create(){let e=new Error;return new YD(e.stack??"")}print(){console.warn(this.value.split(`
|
|
205
|
+
`).slice(2).join(`
|
|
206
|
+
`))}},_ie=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},yie=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},xie=0,ky=class{constructor(e){this.value=e,this.id=xie++}},bie=2,wie,Te=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new gie(t?.onListenerError??$g,this._options?.leakWarningThreshold??mie):void 0,this._perfMon=this._options?._profName?new pie(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??=(t,e,i)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let o=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(o);let a=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],u=new yie(`${o}. HINT: Stack shows most frequent listener (${a[1]}-times)`,a[0]);return(this._options?.onListenerError||$g)(u),yt.None}if(this._disposed)return yt.None;e&&(t=t.bind(e));let n=new ky(t),s;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=vie.create(),s=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof ky?(this._deliveryQueue??=new Sie,this._listeners=[this._listeners,n]):this._listeners.push(n):(this._options?.onWillAddFirstListener?.(this),this._listeners=n,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=Ai(()=>{s?.(),this._removeListener(n)});return i instanceof Aa?i.add(r):Array.isArray(i)&&i.push(r),r},this._event}_removeListener(t){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 e=this._listeners,i=e.indexOf(t);if(i===-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--,e[i]=void 0;let n=this._deliveryQueue.current===this;if(this._size*bie<=e.length){let s=0;for(let r=0;r<e.length;r++)e[r]?e[s++]=e[r]:n&&(this._deliveryQueue.end--,s<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=s}}_deliver(t,e){if(!t)return;let i=this._options?.onListenerError||$g;if(!i){t.value(e);return}try{t.value(e)}catch(n){i(n)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof ky)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},Sie=class{constructor(){this.i=-1,this.end=0}enqueue(e,i,n){this.i=0,this.end=n,this.current=e,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},$b=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Te,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Te,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,i){if(this.getZoomLevel(i)===e)return;let n=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),e)}setFullscreen(e,i){if(this.isFullscreen(i)===e)return;let n=this.getWindowId(i);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};$b.INSTANCE=new $b;var VS=$b;function kie(t,e,i){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",i)}VS.INSTANCE.onDidChangeZoomLevel;function Cie(t){return VS.INSTANCE.getZoomFactor(t)}VS.INSTANCE.onDidChangeFullscreen;var jh=typeof navigator=="object"?navigator.userAgent:"",Fb=jh.indexOf("Firefox")>=0,Eie=jh.indexOf("AppleWebKit")>=0,KS=jh.indexOf("Chrome")>=0,Mie=!KS&&jh.indexOf("Safari")>=0;jh.indexOf("Electron/")>=0;jh.indexOf("Android")>=0;var Cy=!1;if(typeof yl.matchMedia=="function"){let t=yl.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=yl.matchMedia("(display-mode: fullscreen)");Cy=t.matches,kie(yl,t,({matches:i})=>{Cy&&e.matches||(Cy=i)})}var Zu="en",Hb=!1,Wb=!1,Fg=!1,GD=!1,ug,Hg=Zu,_L=Zu,Aie,fl,Cc=globalThis,ir;typeof Cc.vscode<"u"&&typeof Cc.vscode.process<"u"?ir=Cc.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(ir=process);var Lie=typeof ir?.versions?.electron=="string",Tie=Lie&&ir?.type==="renderer";if(typeof ir=="object"){Hb=ir.platform==="win32",Wb=ir.platform==="darwin",Fg=ir.platform==="linux",Fg&&ir.env.SNAP&&ir.env.SNAP_REVISION,ir.env.CI||ir.env.BUILD_ARTIFACTSTAGINGDIRECTORY,ug=Zu,Hg=Zu;let t=ir.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);ug=e.userLocale,_L=e.osLocale,Hg=e.resolvedLanguage||Zu,Aie=e.languagePack?.translationsConfigFile}catch{}GD=!0}else typeof navigator=="object"&&!Tie?(fl=navigator.userAgent,Hb=fl.indexOf("Windows")>=0,Wb=fl.indexOf("Macintosh")>=0,(fl.indexOf("Macintosh")>=0||fl.indexOf("iPad")>=0||fl.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Fg=fl.indexOf("Linux")>=0,fl?.indexOf("Mobi")>=0,Hg=globalThis._VSCODE_NLS_LANGUAGE||Zu,ug=navigator.language.toLowerCase(),_L=ug):console.error("Unable to resolve platform.");var QD=Hb,Lo=Wb,Nie=Fg,yL=GD,jo=fl,ha=Hg,jie;(t=>{function e(){return ha}t.value=e;function i(){return ha.length===2?ha==="en":ha.length>=3?ha[0]==="e"&&ha[1]==="n"&&ha[2]==="-":!1}t.isDefaultVariant=i;function n(){return ha==="en"}t.isDefault=n})(jie||={});var Rie=typeof Cc.postMessage=="function"&&!Cc.importScripts;(()=>{if(Rie){let t=[];Cc.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let n=0,s=t.length;n<s;n++){let r=t[n];if(r.id===i.data.vscodeScheduleAsyncWork){t.splice(n,1),r.callback();return}}});let e=0;return i=>{let n=++e;t.push({id:n,callback:i}),Cc.postMessage({vscodeScheduleAsyncWork:n},"*")}}return t=>setTimeout(t)})();var Die=!!(jo&&jo.indexOf("Chrome")>=0);jo&&jo.indexOf("Firefox")>=0;!Die&&jo&&jo.indexOf("Safari")>=0;jo&&jo.indexOf("Edg/")>=0;jo&&jo.indexOf("Android")>=0;var ju=typeof navigator=="object"?navigator:{};yL||document.queryCommandSupported&&document.queryCommandSupported("copy")||ju&&ju.clipboard&&ju.clipboard.writeText,yL||ju&&ju.clipboard&&ju.clipboard.readText;var YS=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,i){this._keyCodeToStr[e]=i,this._strToKeyCode[i.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Ey=new YS,xL=new YS,bL=new YS,Bie=new Array(230),XD;(t=>{function e(a){return Ey.keyCodeToStr(a)}t.toString=e;function i(a){return Ey.strToKeyCode(a)}t.fromString=i;function n(a){return xL.keyCodeToStr(a)}t.toUserSettingsUS=n;function s(a){return bL.keyCodeToStr(a)}t.toUserSettingsGeneral=s;function r(a){return xL.strToKeyCode(a)||bL.strToKeyCode(a)}t.fromUserSettings=r;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Ey.keyCodeToStr(a)}t.toElectronAccelerator=o})(XD||={});var Oie=class ZD{constructor(e,i,n,s,r){this.ctrlKey=e,this.shiftKey=i,this.altKey=n,this.metaKey=s,this.keyCode=r}equals(e){return e instanceof ZD&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",n=this.altKey?"1":"0",s=this.metaKey?"1":"0";return`K${e}${i}${n}${s}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Iie([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Iie=class{constructor(t){if(t.length===0)throw aie("chords");this.chords=t}getHashCode(){let t="";for(let e=0,i=this.chords.length;e<i;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function Pie(t){if(t.charCode){let i=String.fromCharCode(t.charCode).toUpperCase();return XD.fromString(i)}let e=t.keyCode;if(e===3)return 7;if(Fb)switch(e){case 59:return 85;case 60:if(Nie)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Lo)return 57;break}else if(Eie&&(Lo&&e===93||!Lo&&e===92))return 57;return Bie[e]||0}var zie=Lo?256:2048,$ie=512,Fie=1024,Hie=Lo?2048:256,wL=class{constructor(t){this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=Pie(e),this.code=e.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(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=zie),this.altKey&&(e|=$ie),this.shiftKey&&(e|=Fie),this.metaKey&&(e|=Hie),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new Oie(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},SL=new WeakMap;function Wie(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,i=t.parent.location;if(e.origin!=="null"&&i.origin!=="null"&&e.origin!==i.origin)return null}catch{return null}return t.parent}var qie=class{static getSameOriginWindowChain(t){let e=SL.get(t);if(!e){e=[],SL.set(t,e);let i=t,n;do n=Wie(i),n?e.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):e.push({window:new WeakRef(i),iframeElement:null}),i=n;while(i)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let i=0,n=0,s=this.getSameOriginWindowChain(t);for(let r of s){let o=r.window.deref();if(i+=o?.scrollY??0,n+=o?.scrollX??0,o===e||!r.iframeElement)break;let a=r.iframeElement.getBoundingClientRect();i+=a.top,n+=a.left}return{top:i,left:n}}},hg=class{constructor(e,i){this.timestamp=Date.now(),this.browserEvent=i,this.leftButton=i.button===0,this.middleButton=i.button===1,this.rightButton=i.button===2,this.buttons=i.buttons,this.target=i.target,this.detail=i.detail||1,i.type==="dblclick"&&(this.detail=2),this.ctrlKey=i.ctrlKey,this.shiftKey=i.shiftKey,this.altKey=i.altKey,this.metaKey=i.metaKey,typeof i.pageX=="number"?(this.posx=i.pageX,this.posy=i.pageY):(this.posx=i.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=i.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=qie.getPositionOfChildWindowRelativeToAncestorWindow(e,i.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},kL=class{constructor(e,i=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=i;let s=!1;if(KS){let r=navigator.userAgent.match(/Chrome\/(\d+)/);s=(r?parseInt(r[1]):123)<=122}if(e){let r=e,o=e,a=e.view?.devicePixelRatio||1;if(typeof r.wheelDeltaY<"u")s?this.deltaY=r.wheelDeltaY/(120*a):this.deltaY=r.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let u=e;u.deltaMode===u.DOM_DELTA_LINE?Fb&&!Lo?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof r.wheelDeltaX<"u")Mie&&QD?this.deltaX=-(r.wheelDeltaX/120):s?this.deltaX=r.wheelDeltaX/(120*a):this.deltaX=r.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let u=e;u.deltaMode===u.DOM_DELTA_LINE?Fb&&!Lo?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*a):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},JD=Object.freeze(function(t,e){let i=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(i)}}}),Uie;(t=>{function e(i){return i===t.None||i===t.Cancelled||i instanceof Vie?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:zn.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:JD})})(Uie||={});var Vie=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?JD:(this._emitter||(this._emitter=new Te),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},GS=class{constructor(e,i){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof i=="number"&&this.setIfNotSet(e,i)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,i){if(this._isDisposed)throw new Bb("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},i)}setIfNotSet(e,i){if(this._isDisposed)throw new Bb("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},i))}},Kie=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,i,n=globalThis){if(this.isDisposed)throw new Bb("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},i);this.disposable=Ai(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Yie;(t=>{async function e(n){let s,r=await Promise.all(n.map(o=>o.then(a=>a,a=>{s||(s=a)})));if(typeof s<"u")throw s;return r}t.settled=e;function i(n){return new Promise(async(s,r)=>{try{await n(s,r)}catch(o){r(o)}})}t.withAsyncBody=i})(Yie||={});var CL=class kr{static fromArray(e){return new kr(i=>{i.emitMany(e)})}static fromPromise(e){return new kr(async i=>{i.emitMany(await e)})}static fromPromises(e){return new kr(async i=>{await Promise.all(e.map(async n=>i.emitOne(await n)))})}static merge(e){return new kr(async i=>{await Promise.all(e.map(async n=>{for await(let s of n)i.emitOne(s)}))})}constructor(e,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new Te,queueMicrotask(async()=>{let n={emitOne:s=>this.emitOne(s),emitMany:s=>this.emitMany(s),reject:s=>this.reject(s)};try{await Promise.resolve(e(n)),this.resolve()}catch(s){this.reject(s)}finally{n.emitOne=void 0,n.emitMany=void 0,n.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await zn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,i){return new kr(async n=>{for await(let s of e)n.emitOne(i(s))})}map(e){return kr.map(this,e)}static filter(e,i){return new kr(async n=>{for await(let s of e)i(s)&&n.emitOne(s)})}filter(e){return kr.filter(this,e)}static coalesce(e){return kr.filter(e,i=>!!i)}coalesce(){return kr.coalesce(this)}static async toPromise(e){let i=[];for await(let n of e)i.push(n);return i}toPromise(){return kr.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};CL.EMPTY=CL.fromArray([]);var{getWindow:Mo,getWindowId:Gie,onDidRegisterWindow:Qie}=(function(){let t=new Map,e={window:yl,disposables:new Aa};t.set(yl.vscodeWindowId,e);let i=new Te,n=new Te,s=new Te;function r(o,a){return(typeof o=="number"?t.get(o):void 0)??(a?e:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:n.event,registerWindow(o){if(t.has(o.vscodeWindowId))return yt.None;let a=new Aa,u={window:o,disposables:a.add(new Aa)};return t.set(o.vscodeWindowId,u),a.add(Ai(()=>{t.delete(o.vscodeWindowId),n.fire(o)})),a.add(lt(o,bn.BEFORE_UNLOAD,()=>{s.fire(o)})),i.fire(u),a},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return t.has(o)},getWindowById:r,getWindow(o){let a=o;if(a?.ownerDocument?.defaultView)return a.ownerDocument.defaultView.window;let u=o;return u?.view?u.view.window:yl},getDocument(o){return Mo(o).document}}})(),Xie=class{constructor(e,i,n,s){this._node=e,this._type=i,this._handler=n,this._options=s||!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 lt(t,e,i,n){return new Xie(t,e,i,n)}var EL=function(t,e,i,n){return lt(t,e,i,n)},QS,Zie=class extends Kie{constructor(t){super(),this.defaultTarget=t&&Mo(t)}cancelAndSet(t,e,i){return super.cancelAndSet(t,e,i??this.defaultTarget)}},ML=class{constructor(e,i=0){this._runner=e,this.priority=i,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){$g(e)}}static sort(e,i){return i.priority-e.priority}};(function(){let t=new Map,e=new Map,i=new Map,n=new Map,s=r=>{i.set(r,!1);let o=t.get(r)??[];for(e.set(r,o),t.set(r,[]),n.set(r,!0);o.length>0;)o.sort(ML.sort),o.shift().execute();n.set(r,!1)};QS=(r,o,a=0)=>{let u=Gie(r),h=new ML(o,a),p=t.get(u);return p||(p=[],t.set(u,p)),p.push(h),i.get(u)||(i.set(u,!0),r.requestAnimationFrame(()=>s(u))),h}})();function Jie(t){let e=t.getBoundingClientRect(),i=Mo(t);return{left:e.left+i.scrollX,top:e.top+i.scrollY,width:e.width,height:e.height}}var bn={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"},ene=class{constructor(t){this.domNode=t,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(t){let e=As(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=As(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=As(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=As(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=As(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=As(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=As(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=As(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=As(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=As(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=As(t);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let e=As(t);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let e=As(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=As(t);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,e){this.domNode.classList.toggle(t,e),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,e){this.domNode.setAttribute(t,e)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function As(t){return typeof t=="number"?`${t}px`:t}function Sf(t){return new ene(t)}var e6=class{constructor(){this._hooks=new Aa,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,i){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(i)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,i,n,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let o=e;try{e.setPointerCapture(i),this._hooks.add(Ai(()=>{try{e.releasePointerCapture(i)}catch{}}))}catch{o=Mo(e)}this._hooks.add(lt(o,bn.POINTER_MOVE,a=>{if(a.buttons!==n){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(lt(o,bn.POINTER_UP,a=>this.stopMonitoring(!0)))}};function tne(t,e,i){let n=null,s=null;if(typeof i.value=="function"?(n="value",s=i.value,s.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(n="get",s=i.get),!s)throw new Error("not supported");let r=`$memoize$${e}`;i[n]=function(...o){return this.hasOwnProperty(r)||Object.defineProperty(this,r,{configurable:!1,enumerable:!1,writable:!1,value:s.apply(this,o)}),this[r]}}var _o;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(_o||={});var cf=class Kn extends yt{constructor(){super(),this.dispatched=!1,this.targets=new vL,this.ignoreTargets=new vL,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(zn.runAndSubscribe(Qie,({window:e,disposables:i})=>{i.add(lt(e.document,"touchstart",n=>this.onTouchStart(n),{passive:!1})),i.add(lt(e.document,"touchend",n=>this.onTouchEnd(e,n))),i.add(lt(e.document,"touchmove",n=>this.onTouchMove(n),{passive:!1}))},{window:yl,disposables:this._store}))}static addTarget(e){if(!Kn.isTouchDevice())return yt.None;Kn.INSTANCE||(Kn.INSTANCE=new Kn);let i=Kn.INSTANCE.targets.push(e);return Ai(i)}static ignoreTarget(e){if(!Kn.isTouchDevice())return yt.None;Kn.INSTANCE||(Kn.INSTANCE=new Kn);let i=Kn.INSTANCE.ignoreTargets.push(e);return Ai(i)}static isTouchDevice(){return"ontouchstart"in yl||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let n=0,s=e.targetTouches.length;n<s;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:i,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[i],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let o=this.newGestureEvent(_o.Start,r.target);o.pageX=r.pageX,o.pageY=r.pageY,this.dispatchEvent(o)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,i){let n=Date.now(),s=Object.keys(this.activeTouches).length;for(let r=0,o=i.changedTouches.length;r<o;r++){let a=i.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let u=this.activeTouches[a.identifier],h=Date.now()-u.initialTimeStamp;if(h<Kn.HOLD_DELAY&&Math.abs(u.initialPageX-Zs(u.rollingPageX))<30&&Math.abs(u.initialPageY-Zs(u.rollingPageY))<30){let p=this.newGestureEvent(_o.Tap,u.initialTarget);p.pageX=Zs(u.rollingPageX),p.pageY=Zs(u.rollingPageY),this.dispatchEvent(p)}else if(h>=Kn.HOLD_DELAY&&Math.abs(u.initialPageX-Zs(u.rollingPageX))<30&&Math.abs(u.initialPageY-Zs(u.rollingPageY))<30){let p=this.newGestureEvent(_o.Contextmenu,u.initialTarget);p.pageX=Zs(u.rollingPageX),p.pageY=Zs(u.rollingPageY),this.dispatchEvent(p)}else if(s===1){let p=Zs(u.rollingPageX),m=Zs(u.rollingPageY),v=Zs(u.rollingTimestamps)-u.rollingTimestamps[0],_=p-u.rollingPageX[0],x=m-u.rollingPageY[0],S=[...this.targets].filter(C=>u.initialTarget instanceof Node&&C.contains(u.initialTarget));this.inertia(e,S,n,Math.abs(_)/v,_>0?1:-1,p,Math.abs(x)/v,x>0?1:-1,m)}this.dispatchEvent(this.newGestureEvent(_o.End,u.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,i){let n=document.createEvent("CustomEvent");return n.initEvent(e,!1,!0),n.initialTarget=i,n.tapCount=0,n}dispatchEvent(e){if(e.type===_o.Tap){let i=new Date().getTime(),n=0;i-this._lastSetTapCountTime>Kn.CLEAR_TAP_COUNT_TIME?n=1:n=2,this._lastSetTapCountTime=i,e.tapCount=n}else(e.type===_o.Change||e.type===_o.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let n of this.ignoreTargets)if(n.contains(e.initialTarget))return;let i=[];for(let n of this.targets)if(n.contains(e.initialTarget)){let s=0,r=e.initialTarget;for(;r&&r!==n;)s++,r=r.parentElement;i.push([s,n])}i.sort((n,s)=>n[0]-s[0]);for(let[n,s]of i)s.dispatchEvent(e),this.dispatched=!0}}inertia(e,i,n,s,r,o,a,u,h){this.handle=QS(e,()=>{let p=Date.now(),m=p-n,v=0,_=0,x=!0;s+=Kn.SCROLL_FRICTION*m,a+=Kn.SCROLL_FRICTION*m,s>0&&(x=!1,v=r*s*m),a>0&&(x=!1,_=u*a*m);let S=this.newGestureEvent(_o.Change);S.translationX=v,S.translationY=_,i.forEach(C=>C.dispatchEvent(S)),x||this.inertia(e,i,p,s,r,o+v,a,u,h+_)})}onTouchMove(e){let i=Date.now();for(let n=0,s=e.changedTouches.length;n<s;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn("end of an UNKNOWN touch",r);continue}let o=this.activeTouches[r.identifier],a=this.newGestureEvent(_o.Change,o.initialTarget);a.translationX=r.pageX-Zs(o.rollingPageX),a.translationY=r.pageY-Zs(o.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(r.pageX),o.rollingPageY.push(r.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};cf.SCROLL_FRICTION=-.005,cf.HOLD_DELAY=700,cf.CLEAR_TAP_COUNT_TIME=400,zi([tne],cf,"isTouchDevice",1);var ine=cf,XS=class extends yt{onclick(e,i){this._register(lt(e,bn.CLICK,n=>i(new hg(Mo(e),n))))}onmousedown(e,i){this._register(lt(e,bn.MOUSE_DOWN,n=>i(new hg(Mo(e),n))))}onmouseover(e,i){this._register(lt(e,bn.MOUSE_OVER,n=>i(new hg(Mo(e),n))))}onmouseleave(e,i){this._register(lt(e,bn.MOUSE_LEAVE,n=>i(new hg(Mo(e),n))))}onkeydown(e,i){this._register(lt(e,bn.KEY_DOWN,n=>i(new wL(n))))}onkeyup(e,i){this._register(lt(e,bn.KEY_UP,n=>i(new wL(n))))}oninput(e,i){this._register(lt(e,bn.INPUT,i))}onblur(e,i){this._register(lt(e,bn.BLUR,i))}onfocus(e,i){this._register(lt(e,bn.FOCUS,i))}onchange(e,i){this._register(lt(e,bn.CHANGE,i))}ignoreGesture(e){return ine.ignoreTarget(e)}},AL=11,nne=class extends XS{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=AL+"px",this.domNode.style.height=AL+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new e6),this._register(EL(this.bgDomNode,bn.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(EL(this.domNode,bn.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new Zie),this._pointerdownScheduleRepeatTimer=this._register(new GS)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Mo(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},sne=class qb{constructor(e,i,n,s,r,o,a){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,n=n|0,s=s|0,r=r|0,o=o|0,a=a|0),this.rawScrollLeft=s,this.rawScrollTop=a,i<0&&(i=0),s+i>n&&(s=n-i),s<0&&(s=0),r<0&&(r=0),a+r>o&&(a=o-r),a<0&&(a=0),this.width=i,this.scrollWidth=n,this.scrollLeft=s,this.height=r,this.scrollHeight=o,this.scrollTop=a}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,i){return new qb(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new qb(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,i){let n=this.width!==e.width,s=this.scrollWidth!==e.scrollWidth,r=this.scrollLeft!==e.scrollLeft,o=this.height!==e.height,a=this.scrollHeight!==e.scrollHeight,u=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:i,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:s,scrollLeftChanged:r,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:u}}},rne=class extends yt{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new sne(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){let i=this._state.withScrollDimensions(t,e);this._setState(i,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let i=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let n;e?n=new TL(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):n=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=n}else{let i=this._state.withScrollPosition(t);this._smoothScrolling=TL.start(this._state,i,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 t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let i=this._state;i.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(i,e)))}},LL=class{constructor(e,i,n){this.scrollLeft=e,this.scrollTop=i,this.isDone=n}};function My(t,e){let i=e-t;return function(n){return t+i*ane(n)}}function one(t,e,i){return function(n){return n<i?t(n/i):e((n-i)/(1-i))}}var TL=class Ub{constructor(e,i,n,s){this.from=e,this.to=i,this.duration=s,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(e,i,n){if(Math.abs(e-i)>2.5*n){let s,r;return e<i?(s=e+.75*n,r=i-.75*n):(s=e-.75*n,r=i+.75*n),one(My(e,s),My(r,i),.33)}return My(e,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let i=(e-this.startTime)/this.duration;if(i<1){let n=this.scrollLeft(i),s=this.scrollTop(i);return new LL(n,s,!1)}return new LL(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,i,n){return Ub.start(e,i,n)}static start(e,i,n){n=n+10;let s=Date.now()-10;return new Ub(e,i,s,n)}};function lne(t){return Math.pow(t,3)}function ane(t){return 1-lne(1-t)}var cne=class extends yt{constructor(e,i,n){super(),this._visibility=e,this._visibleClassName=i,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new GS)}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":"")))}},une=140,t6=class extends XS{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 cne(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new e6),this._shouldRender=!0,this.domNode=Sf(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(lt(this.domNode.domNode,bn.POINTER_DOWN,i=>this._domNodePointerDown(i)))}_createArrow(e){let i=this._register(new nne(e));this.domNode.domNode.appendChild(i.bgDomNode),this.domNode.domNode.appendChild(i.domNode)}_createSlider(e,i,n,s){this.slider=Sf(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(i),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(lt(this.slider.domNode,bn.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.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 i=this.domNode.domNode.getClientRects()[0].top,n=i+this._scrollbarState.getSliderPosition(),s=i+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);n<=r&&r<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let i,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")i=e.offsetX,n=e.offsetY;else{let r=Jie(this.domNode.domNode);i=e.pageX-r.left,n=e.pageY-r.top}let s=this._pointerDownRelativePosition(i,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let i=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let o=this._sliderOrthogonalPointerPosition(r),a=Math.abs(o-n);if(QD&&a>une){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let u=this._sliderPointerPosition(r)-i;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(u))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let i={};this.writeScrollPosition(i,e),this._scrollable.setScrollPositionNow(i)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},i6=class Vb{constructor(e,i,n,s,r,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=s,this._scrollSize=r,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Vb(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let i=Math.round(e);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(e){let i=Math.round(e);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let i=Math.round(e);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,i,n,s,r){let o=Math.max(0,n-e),a=Math.max(0,o-2*i),u=s>0&&s>n;if(!u)return{computedAvailableSize:Math.round(o),computedIsNeeded:u,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(n*a/s))),p=(a-h)/(s-n),m=r*p;return{computedAvailableSize:Math.round(o),computedIsNeeded:u,computedSliderSize:Math.round(h),computedSliderRatio:p,computedSliderPosition:Math.round(m)}}_refreshComputedValues(){let e=Vb._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.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(e){if(!this._computedIsNeeded)return 0;let i=e-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let i=e-this._arrowSize,n=this._scrollPosition;return i<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+e;return Math.round(i/this._computedSliderRatio)}},hne=class extends t6{constructor(e,i,n){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:n,scrollbarState:new i6(i.horizontalHasArrows?i.arrowSize:0,i.horizontal===2?0:i.horizontalScrollbarSize,i.vertical===2?0:i.verticalScrollbarSize,s.width,s.scrollWidth,r.scrollLeft),visibility:i.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:i.scrollByPage}),i.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((i.horizontalScrollbarSize-i.horizontalSliderSize)/2),0,void 0,i.horizontalSliderSize)}_updateSlider(e,i){this.slider.setWidth(e),this.slider.setLeft(i)}_renderDomNode(e,i){this.domNode.setWidth(e),this.domNode.setHeight(i),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,i){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,i){e.scrollLeft=i}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}},dne=class extends t6{constructor(t,e,i){let n=t.getScrollDimensions(),s=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:i,scrollbarState:new i6(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,n.height,n.scrollHeight,s.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},fne=500,NL=50,pne=class{constructor(e,i,n){this.timestamp=e,this.deltaX=i,this.deltaY=n,this.score=0}},Kb=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,i=0,n=1,s=this._rear;do{let r=s===this._front?e:Math.pow(2,-n);if(e-=r,i+=this._memory[s].score*r,s===this._front)break;s=(this._capacity+s-1)%this._capacity,n++}while(!0);return i<=.5}acceptStandardWheelEvent(e){if(KS){let i=Mo(e.browserEvent),n=Cie(i);this.accept(Date.now(),e.deltaX*n,e.deltaY*n)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,i,n){let s=null,r=new pne(e,i,n);this._front===-1&&this._rear===-1?(this._memory[0]=r,this._front=0,this._rear=0):(s=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,s)}_computeScore(e,i){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),i){let s=Math.abs(e.deltaX),r=Math.abs(e.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),u=Math.max(Math.min(s,o),1),h=Math.max(Math.min(r,a),1),p=Math.max(s,o),m=Math.max(r,a);p%u===0&&m%h===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Kb.INSTANCE=new Kb;var mne=Kb,gne=class extends XS{constructor(t,e,i){super(),this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Te),this.onWillScroll=this._onWillScroll.event,this._options=_ne(e),this._scrollable=i,this._register(this._scrollable.onScroll(s=>{this._onWillScroll.fire(s),this._onDidScroll(s),this._onScroll.fire(s)}));let n={onMouseWheel:s=>this._onMouseWheel(s),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new dne(this._scrollable,this._options,n)),this._horizontalScrollbar=this._register(new hne(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(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Sf(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Sf(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Sf(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,s=>this._onMouseOver(s)),this.onmouseleave(this._listenOnDomNode,s=>this._onMouseLeave(s)),this._hideTimeout=this._register(new GS),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Pc(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,Lo&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new kL(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=Pc(this._mouseWheelToDispose),t)){let e=i=>{this._onMouseWheel(new kL(i))};this._mouseWheelToDispose.push(lt(this._listenOnDomNode,bn.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let e=mne.INSTANCE;e.acceptStandardWheelEvent(t);let i=!1;if(t.deltaY||t.deltaX){let s=t.deltaY*this._options.mouseWheelScrollSensitivity,r=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&r+s===0?r=s=0:Math.abs(s)>=Math.abs(r)?r=0:s=0),this._options.flipAxes&&([s,r]=[r,s]);let o=!Lo&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||o)&&!r&&(r=s,s=0),t.browserEvent&&t.browserEvent.altKey&&(r=r*this._options.fastScrollSensitivity,s=s*this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),u={};if(s){let h=NL*s,p=a.scrollTop-(h<0?Math.floor(h):Math.ceil(h));this._verticalScrollbar.writeScrollPosition(u,p)}if(r){let h=NL*r,p=a.scrollLeft-(h<0?Math.floor(h):Math.ceil(h));this._horizontalScrollbar.writeScrollPosition(u,p)}u=this._scrollable.validateScrollPosition(u),(a.scrollLeft!==u.scrollLeft||a.scrollTop!==u.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(u):this._scrollable.setScrollPositionNow(u),i=!0)}let n=i;!n&&this._options.alwaysConsumeMouseWheel&&(n=!0),!n&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(n=!0),n&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||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 t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,i=t.scrollLeft>0,n=i?" left":"",s=e?" top":"",r=i||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${n}`),this._topShadowDomNode.setClassName(`shadow${s}`),this._topLeftShadowDomNode.setClassName(`shadow${r}${s}${n}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){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(),fne)}},vne=class extends gne{constructor(e,i,n){super(e,i,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function _ne(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,Lo&&(e.className+=" mac"),e}var Yb=class extends yt{constructor(e,i,n,s,r,o,a,u){super(),this._bufferService=n,this._optionsService=a,this._renderService=u,this._onRequestScrollLines=this._register(new Te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new rne({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>QS(s.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new vne(i,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(p=>{this._scrollableElement.updateOptions({handleMouseWheel:!(p&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(zn.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Ai(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),i.appendChild(this._styleElement),this._register(Ai(()=>this._styleElement.remove())),this._register(zn.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
207
|
+
`)})),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(p=>this._handleScroll(p)))}scrollLines(e){let i=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:i.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,i){i&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!i,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 i=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=i-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=i,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Yb=zi([Ie(2,ms),Ie(3,El),Ie(4,OD),Ie(5,Nh),Ie(6,gs),Ie(7,Ml)],Yb);var Gb=class extends yt{constructor(e,i,n,s,r){super(),this._screenElement=e,this._bufferService=i,this._coreBrowserService=n,this._decorationService=s,this._renderService=r,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(o=>this._removeDecoration(o))),this._register(Ai(()=>{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 i=this._coreBrowserService.mainDocument.createElement("div");i.classList.add("xterm-decoration"),i.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(i.style.display="none"),this._refreshXPosition(e,i),i}_refreshStyle(e){let i=e.marker.line-this._bufferService.buffers.active.ydisp;if(i<0||i>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${i*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,i=e.element){if(!i)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?i.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":i.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};Gb=zi([Ie(1,ms),Ie(2,El),Ie(3,rp),Ie(4,Ml)],Gb);var yne=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 i of this._zones)if(i.color===e.options.overviewRulerOptions.color&&i.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(i,e.marker.line))return;if(this._lineAdjacentToZone(i,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(i,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,i){return i>=e.startBufferLine&&i<=e.endBufferLine}_lineAdjacentToZone(e,i,n){return i>=e.startBufferLine-this._linePadding[n||"full"]&&i<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,i){e.startBufferLine=Math.min(e.startBufferLine,i),e.endBufferLine=Math.max(e.endBufferLine,i)}},po={full:0,left:0,center:0,right:0},da={full:0,left:0,center:0,right:0},Kd={full:0,left:0,center:0,right:0},I0=class extends yt{constructor(e,i,n,s,r,o,a,u){super(),this._viewportElement=e,this._screenElement=i,this._bufferService=n,this._decorationService=s,this._renderService=r,this._optionsService=o,this._themeService=a,this._coreBrowserService=u,this._colorZoneStore=new yne,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(Ai(()=>this._canvas?.remove()));let h=this._canvas.getContext("2d");if(h)this._ctx=h;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),i=Math.ceil((this._canvas.width-1)/3);da.full=this._canvas.width,da.left=e,da.center=i,da.right=e,this._refreshDrawHeightConstants(),Kd.full=1,Kd.left=1,Kd.center=1+da.left,Kd.right=1+da.left+da.center}_refreshDrawHeightConstants(){po.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,i=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);po.left=i,po.center=i,po.right=i}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*po.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*po.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*po.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*po.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 i of this._decorationService.decorations)this._colorZoneStore.addDecoration(i);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let i of e)i.position!=="full"&&this._renderColorZone(i);for(let i of e)i.position==="full"&&this._renderColorZone(i);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(Kd[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-po[e.position||"full"]/2),da[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+po[e.position||"full"]))}_queueRefresh(e,i){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=i||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};I0=zi([Ie(2,ms),Ie(3,rp),Ie(4,Ml),Ie(5,gs),Ie(6,Nh),Ie(7,El)],I0);var we;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
|
|
208
|
+
`,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(we||={});var Wg;(t=>(t.PAD="",t.HOP="",t.BPH="",t.NBH="",t.IND="",t.NEL="
",t.SSA="",t.ESA="",t.HTS="",t.HTJ="",t.VTS="",t.PLD="",t.PLU="",t.RI="",t.SS2="",t.SS3="",t.DCS="",t.PU1="",t.PU2="",t.STS="",t.CCH="",t.MW="",t.SPA="",t.EPA="",t.SOS="",t.SGCI="",t.SCI="",t.CSI="",t.ST="",t.OSC="",t.PM="",t.APC=""))(Wg||={});var n6;(t=>t.ST=`${we.ESC}\\`)(n6||={});var Qb=class{constructor(e,i,n,s,r,o){this._textarea=e,this._compositionView=i,this._bufferService=n,this._optionsService=s,this._coreService=r,this._renderService=o,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 i={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;i.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(i.start,this._compositionPosition.start):n=this._textarea.value.substring(i.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let i=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(i,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let i=this._textarea.value,n=i.replace(e,"");this._dataAlreadySent=n,i.length>e.length?this._coreService.triggerDataEvent(n,!0):i.length<e.length?this._coreService.triggerDataEvent(`${we.DEL}`,!0):i.length===e.length&&i!==e&&this._coreService.triggerDataEvent(i,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let i=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=i*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Qb=zi([Ie(2,ms),Ie(3,gs),Ie(4,qc),Ie(5,Ml)],Qb);var wn=0,Sn=0,kn=0,Oi=0,jL={css:"#00000000",rgba:0},rn;(t=>{function e(s,r,o,a){return a!==void 0?`#${cc(s)}${cc(r)}${cc(o)}${cc(a)}`:`#${cc(s)}${cc(r)}${cc(o)}`}t.toCss=e;function i(s,r,o,a=255){return(s<<24|r<<16|o<<8|a)>>>0}t.toRgba=i;function n(s,r,o,a){return{css:t.toCss(s,r,o,a),rgba:t.toRgba(s,r,o,a)}}t.toColor=n})(rn||={});var Si;(t=>{function e(u,h){if(Oi=(h.rgba&255)/255,Oi===1)return{css:h.css,rgba:h.rgba};let p=h.rgba>>24&255,m=h.rgba>>16&255,v=h.rgba>>8&255,_=u.rgba>>24&255,x=u.rgba>>16&255,S=u.rgba>>8&255;wn=_+Math.round((p-_)*Oi),Sn=x+Math.round((m-x)*Oi),kn=S+Math.round((v-S)*Oi);let C=rn.toCss(wn,Sn,kn),k=rn.toRgba(wn,Sn,kn);return{css:C,rgba:k}}t.blend=e;function i(u){return(u.rgba&255)===255}t.isOpaque=i;function n(u,h,p){let m=qg.ensureContrastRatio(u.rgba,h.rgba,p);if(m)return rn.toColor(m>>24&255,m>>16&255,m>>8&255)}t.ensureContrastRatio=n;function s(u){let h=(u.rgba|255)>>>0;return[wn,Sn,kn]=qg.toChannels(h),{css:rn.toCss(wn,Sn,kn),rgba:h}}t.opaque=s;function r(u,h){return Oi=Math.round(h*255),[wn,Sn,kn]=qg.toChannels(u.rgba),{css:rn.toCss(wn,Sn,kn,Oi),rgba:rn.toRgba(wn,Sn,kn,Oi)}}t.opacity=r;function o(u,h){return Oi=u.rgba&255,r(u,Oi*h/255)}t.multiplyOpacity=o;function a(u){return[u.rgba>>24&255,u.rgba>>16&255,u.rgba>>8&255]}t.toColorRGB=a})(Si||={});var Ti;(t=>{let e,i;try{let s=document.createElement("canvas");s.width=1,s.height=1;let r=s.getContext("2d",{willReadFrequently:!0});r&&(e=r,e.globalCompositeOperation="copy",i=e.createLinearGradient(0,0,1,1))}catch{}function n(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return wn=parseInt(s.slice(1,2).repeat(2),16),Sn=parseInt(s.slice(2,3).repeat(2),16),kn=parseInt(s.slice(3,4).repeat(2),16),rn.toColor(wn,Sn,kn);case 5:return wn=parseInt(s.slice(1,2).repeat(2),16),Sn=parseInt(s.slice(2,3).repeat(2),16),kn=parseInt(s.slice(3,4).repeat(2),16),Oi=parseInt(s.slice(4,5).repeat(2),16),rn.toColor(wn,Sn,kn,Oi);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let r=s.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 wn=parseInt(r[1]),Sn=parseInt(r[2]),kn=parseInt(r[3]),Oi=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),rn.toColor(wn,Sn,kn,Oi);if(!e||!i)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=i,e.fillStyle=s,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[wn,Sn,kn,Oi]=e.getImageData(0,0,1,1).data,Oi!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:rn.toRgba(wn,Sn,kn,Oi),css:s}}t.toColor=n})(Ti||={});var rs;(t=>{function e(n){return i(n>>16&255,n>>8&255,n&255)}t.relativeLuminance=e;function i(n,s,r){let o=n/255,a=s/255,u=r/255,h=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),p=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),m=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4);return h*.2126+p*.7152+m*.0722}t.relativeLuminance2=i})(rs||={});var qg;(t=>{function e(o,a){if(Oi=(a&255)/255,Oi===1)return a;let u=a>>24&255,h=a>>16&255,p=a>>8&255,m=o>>24&255,v=o>>16&255,_=o>>8&255;return wn=m+Math.round((u-m)*Oi),Sn=v+Math.round((h-v)*Oi),kn=_+Math.round((p-_)*Oi),rn.toRgba(wn,Sn,kn)}t.blend=e;function i(o,a,u){let h=rs.relativeLuminance(o>>8),p=rs.relativeLuminance(a>>8);if(cl(h,p)<u){if(p<h){let _=n(o,a,u),x=cl(h,rs.relativeLuminance(_>>8));if(x<u){let S=s(o,a,u),C=cl(h,rs.relativeLuminance(S>>8));return x>C?_:S}return _}let m=s(o,a,u),v=cl(h,rs.relativeLuminance(m>>8));if(v<u){let _=n(o,a,u),x=cl(h,rs.relativeLuminance(_>>8));return v>x?m:_}return m}}t.ensureContrastRatio=i;function n(o,a,u){let h=o>>24&255,p=o>>16&255,m=o>>8&255,v=a>>24&255,_=a>>16&255,x=a>>8&255,S=cl(rs.relativeLuminance2(v,_,x),rs.relativeLuminance2(h,p,m));for(;S<u&&(v>0||_>0||x>0);)v-=Math.max(0,Math.ceil(v*.1)),_-=Math.max(0,Math.ceil(_*.1)),x-=Math.max(0,Math.ceil(x*.1)),S=cl(rs.relativeLuminance2(v,_,x),rs.relativeLuminance2(h,p,m));return(v<<24|_<<16|x<<8|255)>>>0}t.reduceLuminance=n;function s(o,a,u){let h=o>>24&255,p=o>>16&255,m=o>>8&255,v=a>>24&255,_=a>>16&255,x=a>>8&255,S=cl(rs.relativeLuminance2(v,_,x),rs.relativeLuminance2(h,p,m));for(;S<u&&(v<255||_<255||x<255);)v=Math.min(255,v+Math.ceil((255-v)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),S=cl(rs.relativeLuminance2(v,_,x),rs.relativeLuminance2(h,p,m));return(v<<24|_<<16|x<<8|255)>>>0}t.increaseLuminance=s;function r(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}t.toChannels=r})(qg||={});function cc(t){let e=t.toString(16);return e.length<2?"0"+e:e}function cl(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var xne=class extends sp{constructor(e,i,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=i,this._width=n}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()]}},P0=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Ir}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let i=[],n=e.translateToString(!0),s=0,r=0,o=0,a=e.getFg(0),u=e.getBg(0);for(let h=0;h<e.getTrimmedLength();h++)if(e.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==u){if(h-s>1){let p=this._getJoinedRanges(n,o,r,e,s);for(let m=0;m<p.length;m++)i.push(p[m])}s=h,o=r,a=this._workCell.fg,u=this._workCell.bg}r+=this._workCell.getChars().length||Ea.length}if(this._bufferService.cols-s>1){let h=this._getJoinedRanges(n,o,r,e,s);for(let p=0;p<h.length;p++)i.push(h[p])}return i}_getJoinedRanges(t,e,i,n,s){let r=t.substring(e,i),o=[];try{o=this._characterJoiners[0].handler(r)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let u=this._characterJoiners[a].handler(r);for(let h=0;h<u.length;h++)P0._mergeRanges(o,u[h])}catch(u){console.error(u)}return this._stringRangesToCellRanges(o,n,s),o}_stringRangesToCellRanges(t,e,i){let n=0,s=!1,r=0,o=t[n];if(o){for(let a=i;a<this._bufferService.cols;a++){let u=e.getWidth(a),h=e.getString(a).length||Ea.length;if(u!==0){if(!s&&o[0]<=r&&(o[0]=a,s=!0),o[1]<=r){if(o[1]=a,o=t[++n],!o)break;o[0]<=r?(o[0]=a,s=!0):s=!1}r+=h}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let i=!1;for(let n=0;n<t.length;n++){let s=t[n];if(i){if(e[1]<=s[0])return t[n-1][1]=e[1],t;if(e[1]<=s[1])return t[n-1][1]=Math.max(e[1],s[1]),t.splice(n,1),t;t.splice(n,1),n--}else{if(e[1]<=s[0])return t.splice(n,0,e),t;if(e[1]<=s[1])return s[0]=Math.min(e[0],s[0]),t;e[0]<s[1]&&(s[0]=Math.min(e[0],s[0]),i=!0);continue}}return i?t[t.length-1][1]=e[1]:t.push(e),t}};P0=zi([Ie(0,ms)],P0);function bne(t){return 57508<=t&&t<=57558}function wne(t){return 9472<=t&&t<=9631}function Sne(t){return bne(t)||wne(t)}function kne(){return{css:{canvas:dg(),cell:dg()},device:{canvas:dg(),cell:dg(),char:{width:0,height:0,left:0,top:0}}}}function dg(){return{width:0,height:0}}var Xb=class{constructor(e,i,n,s,r,o,a){this._document=e,this._characterJoinerService=i,this._optionsService=n,this._coreBrowserService=s,this._coreService=r,this._decorationService=o,this._themeService=a,this._workCell=new Ir,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,i,n){this._selectionStart=e,this._selectionEnd=i,this._columnSelectMode=n}createRow(e,i,n,s,r,o,a,u,h,p,m){let v=[],_=this._characterJoinerService.getJoinedCharacters(i),x=this._themeService.colors,S=e.getNoBgTrimmedLength();n&&S<o+1&&(S=o+1);let C,k=0,M="",L=0,N=0,j=0,R=0,z=!1,J=0,G=!1,q=0,X=0,I=[],T=p!==-1&&m!==-1;for(let H=0;H<S;H++){e.loadCell(H,this._workCell);let F=this._workCell.getWidth();if(F===0)continue;let P=!1,U=H>=X,V=H,K=this._workCell;if(_.length>0&&H===_[0][0]&&U){let Le=_.shift(),jt=this._isCellInSelection(Le[0],i);for(L=Le[0]+1;L<Le[1];L++)U&&=jt===this._isCellInSelection(L,i);U&&=!n||o<Le[0]||o>=Le[1],U?(P=!0,K=new xne(this._workCell,e.translateToString(!0,Le[0],Le[1]),Le[1]-Le[0]),V=Le[1]-1,F=K.getWidth()):X=Le[1]}let D=this._isCellInSelection(H,i),$=n&&H===o,Y=T&&H>=p&&H<=m,B=!1;this._decorationService.forEachDecorationAtCell(H,i,void 0,Le=>{B=!0});let ee=K.getChars()||Ea;if(ee===" "&&(K.isUnderline()||K.isOverline())&&(ee=" "),q=F*u-h.get(ee,K.isBold(),K.isItalic()),!C)C=this._document.createElement("span");else if(k&&(D&&G||!D&&!G&&K.bg===N)&&(D&&G&&x.selectionForeground||K.fg===j)&&K.extended.ext===R&&Y===z&&q===J&&!$&&!P&&!B&&U){K.isInvisible()?M+=Ea:M+=ee,k++;continue}else k&&(C.textContent=M),C=this._document.createElement("span"),k=0,M="";if(N=K.bg,j=K.fg,R=K.extended.ext,z=Y,J=q,G=D,P&&o>=H&&o<=V&&(o=H),!this._coreService.isCursorHidden&&$&&this._coreService.isCursorInitialized){if(I.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&I.push("xterm-cursor-blink"),I.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":I.push("xterm-cursor-outline");break;case"block":I.push("xterm-cursor-block");break;case"bar":I.push("xterm-cursor-bar");break;case"underline":I.push("xterm-cursor-underline");break}}if(K.isBold()&&I.push("xterm-bold"),K.isItalic()&&I.push("xterm-italic"),K.isDim()&&I.push("xterm-dim"),K.isInvisible()?M=Ea:M=K.getChars()||Ea,K.isUnderline()&&(I.push(`xterm-underline-${K.extended.underlineStyle}`),M===" "&&(M=" "),!K.isUnderlineColorDefault()))if(K.isUnderlineColorRGB())C.style.textDecorationColor=`rgb(${sp.toColorRGB(K.getUnderlineColor()).join(",")})`;else{let Le=K.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&K.isBold()&&Le<8&&(Le+=8),C.style.textDecorationColor=x.ansi[Le].css}K.isOverline()&&(I.push("xterm-overline"),M===" "&&(M=" ")),K.isStrikethrough()&&I.push("xterm-strikethrough"),Y&&(C.style.textDecoration="underline");let ie=K.getFgColor(),re=K.getFgColorMode(),ge=K.getBgColor(),Ee=K.getBgColorMode(),fe=!!K.isInverse();if(fe){let Le=ie;ie=ge,ge=Le;let jt=re;re=Ee,Ee=jt}let Pe,De,He=!1;this._decorationService.forEachDecorationAtCell(H,i,void 0,Le=>{Le.options.layer!=="top"&&He||(Le.backgroundColorRGB&&(Ee=50331648,ge=Le.backgroundColorRGB.rgba>>8&16777215,Pe=Le.backgroundColorRGB),Le.foregroundColorRGB&&(re=50331648,ie=Le.foregroundColorRGB.rgba>>8&16777215,De=Le.foregroundColorRGB),He=Le.options.layer==="top")}),!He&&D&&(Pe=this._coreBrowserService.isFocused?x.selectionBackgroundOpaque:x.selectionInactiveBackgroundOpaque,ge=Pe.rgba>>8&16777215,Ee=50331648,He=!0,x.selectionForeground&&(re=50331648,ie=x.selectionForeground.rgba>>8&16777215,De=x.selectionForeground)),He&&I.push("xterm-decoration-top");let _e;switch(Ee){case 16777216:case 33554432:_e=x.ansi[ge],I.push(`xterm-bg-${ge}`);break;case 50331648:_e=rn.toColor(ge>>16,ge>>8&255,ge&255),this._addStyle(C,`background-color:#${RL((ge>>>0).toString(16),"0",6)}`);break;default:fe?(_e=x.foreground,I.push("xterm-bg-257")):_e=x.background}switch(Pe||K.isDim()&&(Pe=Si.multiplyOpacity(_e,.5)),re){case 16777216:case 33554432:K.isBold()&&ie<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ie+=8),this._applyMinimumContrast(C,_e,x.ansi[ie],K,Pe,void 0)||I.push(`xterm-fg-${ie}`);break;case 50331648:let Le=rn.toColor(ie>>16&255,ie>>8&255,ie&255);this._applyMinimumContrast(C,_e,Le,K,Pe,De)||this._addStyle(C,`color:#${RL(ie.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(C,_e,x.foreground,K,Pe,De)||fe&&I.push("xterm-fg-257")}I.length&&(C.className=I.join(" "),I.length=0),!$&&!P&&!B&&U?k++:C.textContent=M,q!==this.defaultSpacing&&(C.style.letterSpacing=`${q}px`),v.push(C),H=V}return C&&k&&(C.textContent=M),v}_applyMinimumContrast(e,i,n,s,r,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||Sne(s.getCode()))return!1;let a=this._getContrastCache(s),u;if(!r&&!o&&(u=a.getColor(i.rgba,n.rgba)),u===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);u=Si.ensureContrastRatio(r||i,o||n,h),a.setColor((r||i).rgba,(o||n).rgba,u??null)}return u?(this._addStyle(e,`color:${u.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,i){e.setAttribute("style",`${e.getAttribute("style")||""}${i};`)}_isCellInSelection(e,i){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&i>=n[1]&&e<s[0]&&i<=s[1]:e<n[0]&&i>=n[1]&&e>=s[0]&&i<=s[1]:i>n[1]&&i<s[1]||n[1]===s[1]&&i===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&i===s[1]&&e<s[0]||n[1]<s[1]&&i===n[1]&&e>=n[0]}};Xb=zi([Ie(1,zD),Ie(2,gs),Ie(3,El),Ie(4,qc),Ie(5,rp),Ie(6,Nh)],Xb);function RL(t,e,i){for(;t.length<i;)t=e+t;return t}var Cne=class{constructor(e,i){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 n=e.createElement("span");n.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[n,s,r,o],this._container.appendChild(n),this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(o),i.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,i,n,s){e===this._font&&i===this._fontSize&&n===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=i,this._weight=n,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,i,n){let s=0;if(!i&&!n&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let a=this._measure(e,0);return a>0&&(this._flat[s]=a),a}let r=e;i&&(r+="B"),n&&(r+="I");let o=this._holey.get(r);if(o===void 0){let a=0;i&&(a|=1),n&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(r,o)}return o}_measure(e,i){let n=this._measureElements[i];return n.textContent=e.repeat(32),n.offsetWidth/32}},Ene=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,i,n,s=!1){if(this.selectionStart=i,this.selectionEnd=n,!i||!n||i[0]===n[0]&&i[1]===n[1]){this.clear();return}let r=e.buffers.active.ydisp,o=i[1]-r,a=n[1]-r,u=Math.max(o,0),h=Math.min(a,e.rows-1);if(u>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=u,this.viewportCappedEndRow=h,this.startCol=i[0],this.endCol=n[0]}isCellSelected(e,i,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?i>=this.startCol&&n>=this.viewportCappedStartRow&&i<this.endCol&&n<=this.viewportCappedEndRow:i<this.startCol&&n>=this.viewportCappedStartRow&&i>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&i>=this.startCol&&i<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&i<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&i>=this.startCol):!1}};function Mne(){return new Ene}var Ay="xterm-dom-renderer-owner-",Sr="xterm-rows",fg="xterm-fg-",DL="xterm-bg-",Yd="xterm-focus",pg="xterm-selection",Ane=1,Zb=class extends yt{constructor(e,i,n,s,r,o,a,u,h,p,m,v,_,x){super(),this._terminal=e,this._document=i,this._element=n,this._screenElement=s,this._viewportElement=r,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=p,this._bufferService=m,this._coreService=v,this._coreBrowserService=_,this._themeService=x,this._terminalClass=Ane++,this._rowElements=[],this._selectionRenderModel=Mne(),this.onRequestRedraw=this._register(new Te).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Sr),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(pg),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=kne(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(S=>this._injectCss(S))),this._injectCss(this._themeService.colors),this._rowFactory=u.createInstance(Xb,document),this._element.classList.add(Ay+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(S=>this._handleLinkHover(S))),this._register(this._linkifier2.onHideLinkUnderline(S=>this._handleLinkLeave(S))),this._register(Ai(()=>{this._element.classList.remove(Ay+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Cne(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 n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let i=`${this._terminalSelector} .${Sr} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=i,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 i=`${this._terminalSelector} .${Sr} { 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}`;i+=`${this._terminalSelector} .${Sr} .xterm-dim { color: ${Si.multiplyOpacity(e.foreground,.5).css};}`,i+=`${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 n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;i+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,i+=`@keyframes ${s} { 50% { box-shadow: none; }}`,i+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,i+=`${this._terminalSelector} .${Sr}.${Yd} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Sr}.${Yd} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Sr}.${Yd} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Sr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Sr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Sr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Sr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Sr} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,i+=`${this._terminalSelector} .${pg} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${pg} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${pg} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())i+=`${this._terminalSelector} .${fg}${o} { color: ${a.css}; }${this._terminalSelector} .${fg}${o}.xterm-dim { color: ${Si.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${DL}${o} { background-color: ${a.css}; }`;i+=`${this._terminalSelector} .${fg}257 { color: ${Si.opaque(e.background).css}; }${this._terminalSelector} .${fg}257.xterm-dim { color: ${Si.multiplyOpacity(Si.opaque(e.background),.5).css}; }${this._terminalSelector} .${DL}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=i}_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,i){for(let n=this._rowElements.length;n<=i;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>i;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,i){this._refreshRowElements(e,i),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(Yd),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Yd),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,i,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,i,n),this.renderRows(0,this._bufferService.rows-1),!e||!i||(this._selectionRenderModel.update(this._terminal,e,i,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,u=this._document.createDocumentFragment();if(n){let h=e[0]>i[0];u.appendChild(this._createSelectionElement(o,h?i[0]:e[0],h?e[0]:i[0],a-o+1))}else{let h=s===o?e[0]:0,p=o===r?i[0]:this._bufferService.cols;u.appendChild(this._createSelectionElement(o,h,p));let m=a-o-1;if(u.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,m)),o!==a){let v=r===a?i[0]:this._bufferService.cols;u.appendChild(this._createSelectionElement(a,0,v))}}this._selectionContainer.appendChild(u)}_createSelectionElement(e,i,n,s=1){let r=this._document.createElement("div"),o=i*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(n-i);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${o}px`,r.style.width=`${a}px`,r}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,i){let n=this._bufferService.buffer,s=n.ybase+n.y,r=Math.min(n.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,u=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=i;h++){let p=h+n.ydisp,m=this._rowElements[h],v=n.lines.get(p);if(!m||!v)break;m.replaceChildren(...this._rowFactory.createRow(v,p,p===s,a,u,r,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ay}${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,i,n,s,r,o){n<0&&(e=0),s<0&&(i=0);let a=this._bufferService.rows-1;n=Math.max(Math.min(n,a),0),s=Math.max(Math.min(s,a),0),r=Math.min(r,this._bufferService.cols);let u=this._bufferService.buffer,h=u.ybase+u.y,p=Math.min(u.x,r-1),m=this._optionsService.rawOptions.cursorBlink,v=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let x=n;x<=s;++x){let S=x+u.ydisp,C=this._rowElements[x],k=u.lines.get(S);if(!C||!k)break;C.replaceChildren(...this._rowFactory.createRow(k,S,S===h,v,_,p,m,this.dimensions.css.cell.width,this._widthCache,o?x===n?e:0:-1,o?(x===s?i:r)-1:-1))}}};Zb=zi([Ie(7,qS),Ie(8,vv),Ie(9,gs),Ie(10,ms),Ie(11,qc),Ie(12,El),Ie(13,Nh)],Zb);var Jb=class extends yt{constructor(e,i,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Te),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Tne(this._optionsService))}catch{this._measureStrategy=this._register(new Lne(e,i,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())}};Jb=zi([Ie(2,gs)],Jb);var s6=class extends yt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},Lne=class extends s6{constructor(t,e,i){super(),this._document=t,this._parentElement=e,this._optionsService=i,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}},Tne=class extends s6{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let i=this._ctx.measureText("W");if(!("width"in i&&"fontBoundingBoxAscent"in i&&"fontBoundingBoxDescent"in i))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}},Nne=class extends yt{constructor(e,i,n){super(),this._textarea=e,this._window=i,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new jne(this._window)),this._onDprChange=this._register(new Te),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Te),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(zn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(lt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(lt(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}},jne=class extends yt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Sh),this._onDprChange=this._register(new Te),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Ai(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=lt(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)}},Rne=class extends yt{constructor(){super(),this.linkProviders=[],this._register(Ai(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function ZS(t,e,i){let n=i.getBoundingClientRect(),s=t.getComputedStyle(i),r=parseInt(s.getPropertyValue("padding-left")),o=parseInt(s.getPropertyValue("padding-top"));return[e.clientX-n.left-r,e.clientY-n.top-o]}function Dne(t,e,i,n,s,r,o,a,u){if(!r)return;let h=ZS(t,e,i);if(h)return h[0]=Math.ceil((h[0]+(u?o/2:0))/o),h[1]=Math.ceil(h[1]/a),h[0]=Math.min(Math.max(h[0],1),n+(u?1:0)),h[1]=Math.min(Math.max(h[1],1),s),h}var ew=class{constructor(e,i){this._renderService=e,this._charSizeService=i}getCoords(e,i,n,s,r){return Dne(window,e,i,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,i){let n=ZS(window,e,i);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};ew=zi([Ie(0,Ml),Ie(1,vv)],ew);var Bne=class{constructor(e,i){this._renderCallback=e,this._coreBrowserService=i,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,i,n){this._rowCount=n,e=e!==void 0?e:0,i=i!==void 0?i: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,i):i,!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),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,i),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},r6={};Ute(r6,{getSafariVersion:()=>Ine,isChromeOS:()=>c6,isFirefox:()=>o6,isIpad:()=>Pne,isIphone:()=>zne,isLegacyEdge:()=>One,isLinux:()=>JS,isMac:()=>z0,isNode:()=>_v,isSafari:()=>l6,isWindows:()=>a6});var _v=typeof process<"u"&&"title"in process,op=_v?"node":navigator.userAgent,lp=_v?"node":navigator.platform,o6=op.includes("Firefox"),One=op.includes("Edge"),l6=/^((?!chrome|android).)*safari/i.test(op);function Ine(){if(!l6)return 0;let t=op.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var z0=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(lp),Pne=lp==="iPad",zne=lp==="iPhone",a6=["Windows","Win16","Win32","WinCE"].includes(lp),JS=lp.indexOf("Linux")>=0,c6=/\bCrOS\b/.test(op),u6=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),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(t){this._idleCallback=void 0;let e=0,i=0,n=t.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),i=Math.max(e,i),s=t.timeRemaining(),i*1.5>s){n-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-e))}ms`),this._start();return}n=s}this.clear()}},$ne=class extends u6{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let i=performance.now()+e;return{timeRemaining:()=>Math.max(0,i-performance.now())}}},Fne=class extends u6{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},$0=!_v&&"requestIdleCallback"in window?Fne:$ne,Hne=class{constructor(){this._queue=new $0}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},tw=class extends yt{constructor(e,i,n,s,r,o,a,u,h){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=r,this._coreBrowserService=u,this._renderer=this._register(new Sh),this._pausedResizeTask=new Hne,this._observerDisposable=this._register(new Sh),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 Te),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Te),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Te),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Te),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Bne((p,m)=>this._renderRows(p,m),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Wne(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Ai(()=>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(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.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(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,i),this._register(this._coreBrowserService.onWindowChange(p=>this._registerIntersectionObserver(p,i)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,i){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(i),this._observerDisposable.value=Ai(()=>n.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,i,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,i);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),i=Math.max(i,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,i,this._rowCount)}_renderRows(e,i){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,i);return}e=Math.min(e,this._rowCount-1),i=Math.min(i,this._rowCount-1),this._renderer.value.renderRows(e,i),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:i}),this._onRender.fire({start:e,end:i}),this._isNextRenderRedrawOnly=!0}}resize(e,i){this._rowCount=i,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(i=>this.refreshRows(i.start,i.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,i){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,i)):this._renderer.value.handleResize(e,i),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,i,n){this._selectionState.start=e,this._selectionState.end=i,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,i,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};tw=zi([Ie(2,gs),Ie(3,vv),Ie(4,qc),Ie(5,rp),Ie(6,ms),Ie(7,El),Ie(8,Nh)],tw);var Wne=class{constructor(t,e,i){this._coreBrowserService=t,this._coreService=e,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,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 t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function qne(t,e,i,n){let s=i.buffer.x,r=i.buffer.y;if(!i.buffer.hasScrollback)return Kne(s,r,t,e,i,n)+yv(r,e,i,n)+Yne(s,r,t,e,i,n);let o;if(r===e)return o=s>t?"D":"C",Ff(Math.abs(s-t),$f(o,n));o=r>e?"D":"C";let a=Math.abs(r-e),u=Vne(r>e?t:s,i)+(a-1)*i.cols+1+Une(r>e?s:t);return Ff(u,$f(o,n))}function Une(t,e){return t-1}function Vne(t,e){return e.cols-t}function Kne(t,e,i,n,s,r){return yv(e,n,s,r).length===0?"":Ff(d6(t,e,t,e-zc(e,s),!1,s).length,$f("D",r))}function yv(t,e,i,n){let s=t-zc(t,i),r=e-zc(e,i),o=Math.abs(s-r)-Gne(t,e,i);return Ff(o,$f(h6(t,e),n))}function Yne(t,e,i,n,s,r){let o;yv(e,n,s,r).length>0?o=n-zc(n,s):o=e;let a=n,u=Qne(t,e,i,n,s,r);return Ff(d6(t,o,i,a,u==="C",s).length,$f(u,r))}function Gne(t,e,i){let n=0,s=t-zc(t,i),r=e-zc(e,i);for(let o=0;o<Math.abs(s-r);o++){let a=h6(t,e)==="A"?-1:1;i.buffer.lines.get(s+a*o)?.isWrapped&&n++}return n}function zc(t,e){let i=0,n=e.buffer.lines.get(t),s=n?.isWrapped;for(;s&&t>=0&&t<e.rows;)i++,n=e.buffer.lines.get(--t),s=n?.isWrapped;return i}function Qne(t,e,i,n,s,r){let o;return yv(i,n,s,r).length>0?o=n-zc(n,s):o=e,t<i&&o<=n||t>=i&&o<n?"C":"D"}function h6(t,e){return t>e?"A":"B"}function d6(t,e,i,n,s,r){let o=t,a=e,u="";for(;(o!==i||a!==n)&&a>=0&&a<r.buffer.lines.length;)o+=s?1:-1,s&&o>r.cols-1?(u+=r.buffer.translateBufferLineToString(a,!1,t,o),o=0,t=0,a++):!s&&o<0&&(u+=r.buffer.translateBufferLineToString(a,!1,0,t+1),o=r.cols-1,t=o,a--);return u+r.buffer.translateBufferLineToString(a,!1,t,o)}function $f(t,e){let i=e?"O":"[";return we.ESC+i+t}function Ff(t,e){t=Math.floor(t);let i="";for(let n=0;n<t;n++)i+=e;return i}var Xne=class{constructor(t){this._bufferService=t,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 t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function BL(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var Ly=50,Zne=15,Jne=50,ese=500,tse=" ",ise=new RegExp(tse,"g"),iw=class extends yt{constructor(e,i,n,s,r,o,a,u,h){super(),this._element=e,this._screenElement=i,this._linkifier=n,this._bufferService=s,this._coreService=r,this._mouseService=o,this._optionsService=a,this._renderService=u,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ir,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Te),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Te),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Te),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=p=>this._handleMouseMove(p),this._mouseUpListener=p=>this._handleMouseUp(p),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(p=>this._handleTrim(p)),this._register(this._bufferService.buffers.onBufferActivate(p=>this._handleBufferActivate(p))),this.enable(),this._model=new Xne(this._bufferService),this._activeSelectionMode=0,this._register(Ai(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(p=>{p.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,i=this._model.finalSelectionEnd;return!e||!i?!1:e[0]!==i[0]||e[1]!==i[1]}get selectionText(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;if(!e||!i)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===i[0])return"";let r=e[0]<i[0]?e[0]:i[0],o=e[0]<i[0]?i[0]:e[0];for(let a=e[1];a<=i[1];a++){let u=n.translateBufferLineToString(a,!0,r,o);s.push(u)}}else{let r=e[1]===i[1]?i[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],r));for(let o=e[1]+1;o<=i[1]-1;o++){let a=n.lines.get(o),u=n.translateBufferLineToString(o,!0);a?.isWrapped?s[s.length-1]+=u:s.push(u)}if(e[1]!==i[1]){let o=n.lines.get(i[1]),a=n.translateBufferLineToString(i[1],!0,0,i[0]);o&&o.isWrapped?s[s.length-1]+=a:s.push(a)}}return s.map(r=>r.replace(ise," ")).join(a6?`\r
|
|
209
|
+
`:`
|
|
210
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),JS&&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 i=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!i?!1:this._areCoordsInSelection(i,n,s)}isCellInSelection(e,i){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,i],n,s)}_areCoordsInSelection(e,i,n){return e[1]>i[1]&&e[1]<n[1]||i[1]===n[1]&&e[1]===i[1]&&e[0]>=i[0]&&e[0]<n[0]||i[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||i[1]<n[1]&&e[1]===i[1]&&e[0]>=i[0]}_selectWordAtCursor(e,i){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=BL(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,i),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,i){this._model.clearSelection(),e=Math.max(e,0),i=Math.min(i,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,i],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let i=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(i)return i[0]--,i[1]--,i[1]+=this._bufferService.buffer.ydisp,i}_getMouseEventScrollAmount(e){let i=ZS(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return i>=0&&i<=n?0:(i>n&&(i-=n),i=Math.min(Math.max(i,-Ly),Ly),i/=Ly,i/Math.abs(i)+Math.round(i*(Zne-1)))}shouldForceSelection(e){return z0?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(),Jne)}_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 i=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);i&&i.length!==this._model.selectionStart[0]&&i.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let i=this._getMouseBufferCoords(e);i&&(this._activeSelectionMode=2,this._selectLineAt(i[1]))}shouldColumnSelect(e){return e.altKey&&!(z0&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let i=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 n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let s=n.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!i||i[0]!==this._model.selectionEnd[0]||i[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 i=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&i<ese&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let s=qne(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd,n=!!e&&!!i&&(e[0]!==i[0]||e[1]!==i[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,i,n);return}!e||!i||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||i[0]!==this._oldSelectionEnd[0]||i[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,i,n)}_fireOnSelectionChange(e,i,n){this._oldSelectionStart=e,this._oldSelectionEnd=i,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(i=>this._handleTrim(i))}_convertViewportColToCharacterIndex(e,i){let n=i;for(let s=0;i>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:r>1&&i!==s&&(n+=r-1)}return n}setSelection(e,i,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,i],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,i,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,o=r.lines.get(e[1]);if(!o)return;let a=r.translateBufferLineToString(e[1],!1),u=this._convertViewportColToCharacterIndex(o,e[0]),h=u,p=e[0]-u,m=0,v=0,_=0,x=0;if(a.charAt(u)===" "){for(;u>0&&a.charAt(u-1)===" ";)u--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let k=e[0],M=e[0];o.getWidth(k)===0&&(m++,k--),o.getWidth(M)===2&&(v++,M++);let L=o.getString(M).length;for(L>1&&(x+=L-1,h+=L-1);k>0&&u>0&&!this._isCharWordSeparator(o.loadCell(k-1,this._workCell));){o.loadCell(k-1,this._workCell);let N=this._workCell.getChars().length;this._workCell.getWidth()===0?(m++,k--):N>1&&(_+=N-1,u-=N-1),u--,k--}for(;M<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(M+1,this._workCell));){o.loadCell(M+1,this._workCell);let N=this._workCell.getChars().length;this._workCell.getWidth()===2?(v++,M++):N>1&&(x+=N-1,h+=N-1),h++,M++}}h++;let S=u+p-m+_,C=Math.min(this._bufferService.cols,h-u+m+v-_-x);if(!(!i&&a.slice(u,h).trim()==="")){if(n&&S===0&&o.getCodePoint(0)!==32){let k=r.lines.get(e[1]-1);if(k&&o.isWrapped&&k.getCodePoint(this._bufferService.cols-1)!==32){let M=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(M){let L=this._bufferService.cols-M.start;S-=L,C+=L}}}if(s&&S+C===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let k=r.lines.get(e[1]+1);if(k?.isWrapped&&k.getCodePoint(0)!==32){let M=this._getWordAt([0,e[1]+1],!1,!1,!0);M&&(C+=M.length)}}return{start:S,length:C}}}_selectWordAt(e,i){let n=this._getWordAt(e,i);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let i=this._getWordAt(e,!0);if(i){let n=e[1];for(;i.start<0;)i.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;i.start+i.length>this._bufferService.cols;)i.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?i.start:i.start+i.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let i=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:i.first},end:{x:this._bufferService.cols-1,y:i.last}};this._model.selectionStart=[0,i.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=BL(n,this._bufferService.cols)}};iw=zi([Ie(3,ms),Ie(4,qc),Ie(5,US),Ie(6,gs),Ie(7,Ml),Ie(8,El)],iw);var OL=class{constructor(){this._data={}}set(e,i,n){this._data[e]||(this._data[e]={}),this._data[e][i]=n}get(e,i){return this._data[e]?this._data[e][i]:void 0}clear(){this._data={}}},IL=class{constructor(){this._color=new OL,this._css=new OL}setCss(e,i,n){this._css.set(e,i,n)}getCss(e,i){return this._css.get(e,i)}setColor(e,i,n){this._color.set(e,i,n)}getColor(e,i){return this._color.get(e,i)}clear(){this._color.clear(),this._css.clear()}},hn=Object.freeze((()=>{let t=[Ti.toColor("#2e3436"),Ti.toColor("#cc0000"),Ti.toColor("#4e9a06"),Ti.toColor("#c4a000"),Ti.toColor("#3465a4"),Ti.toColor("#75507b"),Ti.toColor("#06989a"),Ti.toColor("#d3d7cf"),Ti.toColor("#555753"),Ti.toColor("#ef2929"),Ti.toColor("#8ae234"),Ti.toColor("#fce94f"),Ti.toColor("#729fcf"),Ti.toColor("#ad7fa8"),Ti.toColor("#34e2e2"),Ti.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let i=0;i<216;i++){let n=e[i/36%6|0],s=e[i/6%6|0],r=e[i%6];t.push({css:rn.toCss(n,s,r),rgba:rn.toRgba(n,s,r)})}for(let i=0;i<24;i++){let n=8+i*10;t.push({css:rn.toCss(n,n,n),rgba:rn.toRgba(n,n,n)})}return t})()),pc=Ti.toColor("#ffffff"),uf=Ti.toColor("#000000"),PL=Ti.toColor("#ffffff"),zL=uf,Gd={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},nse=pc,nw=class extends yt{constructor(e){super(),this._optionsService=e,this._contrastCache=new IL,this._halfContrastCache=new IL,this._onChangeColors=this._register(new Te),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:pc,background:uf,cursor:PL,cursorAccent:zL,selectionForeground:void 0,selectionBackgroundTransparent:Gd,selectionBackgroundOpaque:Si.blend(uf,Gd),selectionInactiveBackgroundTransparent:Gd,selectionInactiveBackgroundOpaque:Si.blend(uf,Gd),scrollbarSliderBackground:Si.opacity(pc,.2),scrollbarSliderHoverBackground:Si.opacity(pc,.4),scrollbarSliderActiveBackground:Si.opacity(pc,.5),overviewRulerBorder:pc,ansi:hn.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 i=this._colors;if(i.foreground=ni(e.foreground,pc),i.background=ni(e.background,uf),i.cursor=Si.blend(i.background,ni(e.cursor,PL)),i.cursorAccent=Si.blend(i.background,ni(e.cursorAccent,zL)),i.selectionBackgroundTransparent=ni(e.selectionBackground,Gd),i.selectionBackgroundOpaque=Si.blend(i.background,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundTransparent=ni(e.selectionInactiveBackground,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundOpaque=Si.blend(i.background,i.selectionInactiveBackgroundTransparent),i.selectionForeground=e.selectionForeground?ni(e.selectionForeground,jL):void 0,i.selectionForeground===jL&&(i.selectionForeground=void 0),Si.isOpaque(i.selectionBackgroundTransparent)&&(i.selectionBackgroundTransparent=Si.opacity(i.selectionBackgroundTransparent,.3)),Si.isOpaque(i.selectionInactiveBackgroundTransparent)&&(i.selectionInactiveBackgroundTransparent=Si.opacity(i.selectionInactiveBackgroundTransparent,.3)),i.scrollbarSliderBackground=ni(e.scrollbarSliderBackground,Si.opacity(i.foreground,.2)),i.scrollbarSliderHoverBackground=ni(e.scrollbarSliderHoverBackground,Si.opacity(i.foreground,.4)),i.scrollbarSliderActiveBackground=ni(e.scrollbarSliderActiveBackground,Si.opacity(i.foreground,.5)),i.overviewRulerBorder=ni(e.overviewRulerBorder,nse),i.ansi=hn.slice(),i.ansi[0]=ni(e.black,hn[0]),i.ansi[1]=ni(e.red,hn[1]),i.ansi[2]=ni(e.green,hn[2]),i.ansi[3]=ni(e.yellow,hn[3]),i.ansi[4]=ni(e.blue,hn[4]),i.ansi[5]=ni(e.magenta,hn[5]),i.ansi[6]=ni(e.cyan,hn[6]),i.ansi[7]=ni(e.white,hn[7]),i.ansi[8]=ni(e.brightBlack,hn[8]),i.ansi[9]=ni(e.brightRed,hn[9]),i.ansi[10]=ni(e.brightGreen,hn[10]),i.ansi[11]=ni(e.brightYellow,hn[11]),i.ansi[12]=ni(e.brightBlue,hn[12]),i.ansi[13]=ni(e.brightMagenta,hn[13]),i.ansi[14]=ni(e.brightCyan,hn[14]),i.ansi[15]=ni(e.brightWhite,hn[15]),e.extendedAnsi){let n=Math.min(i.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<n;s++)i.ansi[s+16]=ni(e.extendedAnsi[s],hn[s+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 i=0;i<this._restoreColors.ansi.length;++i)this._colors.ansi[i]=this._restoreColors.ansi[i];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()}}};nw=zi([Ie(0,gs)],nw);function ni(t,e){if(t!==void 0)try{return Ti.toColor(t)}catch{}return e}var sse=class{constructor(...e){this._entries=new Map;for(let[i,n]of e)this.set(i,n)}set(e,i){let n=this._entries.get(e);return this._entries.set(e,i),n}forEach(e){for(let[i,n]of this._entries.entries())e(i,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},rse=class{constructor(){this._services=new sse,this._services.set(qS,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let i=Zte(t).sort((r,o)=>r.index-o.index),n=[];for(let r of i){let o=this._services.get(r.id);if(!o)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${r.id._id}.`);n.push(o)}let s=i.length>0?i[0].index:e.length;if(e.length!==s)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${s+1} conflicts with ${e.length} static arguments`);return new t(...e,...n)}},ose={trace:0,debug:1,info:2,warn:3,error:4,off:5},lse="xterm.js: ",sw=class extends yt{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=ose[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let i=0;i<e.length;i++)typeof e[i]=="function"&&(e[i]=e[i]())}_log(e,i,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":lse)+i,...n)}trace(e,...i){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,i)}debug(e,...i){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,i)}info(e,...i){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,i)}warn(e,...i){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,i)}error(e,...i){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,i)}};sw=zi([Ie(0,gs)],sw);var $L=class extends yt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Te),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Te),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Te),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 i=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)i[n]=this._array[this._getCyclicIndex(n)];this._array=i,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let i=this._length;i<e;i++)this._array[i]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,i){this._array[this._getCyclicIndex(e)]=i}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,i,...n){if(i){for(let s=e;s<this._length-i;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+i)];this._length-=i,this.onDeleteEmitter.fire({index:e,amount:i})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<n.length;s++)this._array[this._getCyclicIndex(e+s)]=n[s];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,i,n){if(!(i<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let r=i-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let s=e+i+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<i;s++)this.set(e+s+n,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},vt=3,tn=Object.freeze(new sp),mg=0,Ty=2,hf=class f6{constructor(e,i,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*vt);let s=i||Ir.fromCharData([0,jD,1,0]);for(let r=0;r<e;++r)this.setCell(r,s);this.length=e}get(e){let i=this._data[e*vt+0],n=i&2097151;return[this._data[e*vt+1],i&2097152?this._combined[e]:n?xa(n):"",i>>22,i&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,i){this._data[e*vt+1]=i[0],i[1].length>1?(this._combined[e]=i[1],this._data[e*vt+0]=e|2097152|i[2]<<22):this._data[e*vt+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(e){return this._data[e*vt+0]>>22}hasWidth(e){return this._data[e*vt+0]&12582912}getFg(e){return this._data[e*vt+1]}getBg(e){return this._data[e*vt+2]}hasContent(e){return this._data[e*vt+0]&4194303}getCodePoint(e){let i=this._data[e*vt+0];return i&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i&2097151}isCombined(e){return this._data[e*vt+0]&2097152}getString(e){let i=this._data[e*vt+0];return i&2097152?this._combined[e]:i&2097151?xa(i&2097151):""}isProtected(e){return this._data[e*vt+2]&536870912}loadCell(e,i){return mg=e*vt,i.content=this._data[mg+0],i.fg=this._data[mg+1],i.bg=this._data[mg+2],i.content&2097152&&(i.combinedData=this._combined[e]),i.bg&268435456&&(i.extended=this._extendedAttrs[e]),i}setCell(e,i){i.content&2097152&&(this._combined[e]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[e]=i.extended),this._data[e*vt+0]=i.content,this._data[e*vt+1]=i.fg,this._data[e*vt+2]=i.bg}setCellFromCodepoint(e,i,n,s){s.bg&268435456&&(this._extendedAttrs[e]=s.extended),this._data[e*vt+0]=i|n<<22,this._data[e*vt+1]=s.fg,this._data[e*vt+2]=s.bg}addCodepointToCell(e,i,n){let s=this._data[e*vt+0];s&2097152?this._combined[e]+=xa(i):s&2097151?(this._combined[e]=xa(s&2097151)+xa(i),s&=-2097152,s|=2097152):s=i|1<<22,n&&(s&=-12582913,s|=n<<22),this._data[e*vt+0]=s}insertCells(e,i,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),i<this.length-e){let s=new Ir;for(let r=this.length-e-i-1;r>=0;--r)this.setCell(e+i+r,this.loadCell(e+r,s));for(let r=0;r<i;++r)this.setCell(e+r,n)}else for(let s=e;s<this.length;++s)this.setCell(s,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,i,n){if(e%=this.length,i<this.length-e){let s=new Ir;for(let r=0;r<this.length-e-i;++r)this.setCell(e+r,this.loadCell(e+i+r,s));for(let r=this.length-i;r<this.length;++r)this.setCell(r,n)}else for(let s=e;s<this.length;++s)this.setCell(s,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,i,n,s=!1){if(s){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,n);e<i&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,n);e<i&&e<this.length;)this.setCell(e++,n)}resize(e,i){if(e===this.length)return this._data.length*4*Ty<this._data.buffer.byteLength;let n=e*vt;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let s=new Uint32Array(n);s.set(this._data),this._data=s}for(let s=this.length;s<e;++s)this.setCell(s,i)}else{this._data=this._data.subarray(0,n);let s=Object.keys(this._combined);for(let o=0;o<s.length;o++){let a=parseInt(s[o],10);a>=e&&delete this._combined[a]}let r=Object.keys(this._extendedAttrs);for(let o=0;o<r.length;o++){let a=parseInt(r[o],10);a>=e&&delete this._extendedAttrs[a]}}return this.length=e,n*4*Ty<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ty<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,i=!1){if(i){for(let n=0;n<this.length;++n)this.isProtected(n)||this.setCell(n,e);return}this._combined={},this._extendedAttrs={};for(let n=0;n<this.length;++n)this.setCell(n,e)}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let i in e._combined)this._combined[i]=e._combined[i];this._extendedAttrs={};for(let i in e._extendedAttrs)this._extendedAttrs[i]=e._extendedAttrs[i];this.isWrapped=e.isWrapped}clone(){let e=new f6(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let i in this._combined)e._combined[i]=this._combined[i];for(let i in this._extendedAttrs)e._extendedAttrs[i]=this._extendedAttrs[i];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*vt+0]&4194303)return e+(this._data[e*vt+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*vt+0]&4194303||this._data[e*vt+2]&50331648)return e+(this._data[e*vt+0]>>22);return 0}copyCellsFrom(e,i,n,s,r){let o=e._data;if(r)for(let u=s-1;u>=0;u--){for(let h=0;h<vt;h++)this._data[(n+u)*vt+h]=o[(i+u)*vt+h];o[(i+u)*vt+2]&268435456&&(this._extendedAttrs[n+u]=e._extendedAttrs[i+u])}else for(let u=0;u<s;u++){for(let h=0;h<vt;h++)this._data[(n+u)*vt+h]=o[(i+u)*vt+h];o[(i+u)*vt+2]&268435456&&(this._extendedAttrs[n+u]=e._extendedAttrs[i+u])}let a=Object.keys(e._combined);for(let u=0;u<a.length;u++){let h=parseInt(a[u],10);h>=i&&(this._combined[h-i+n]=e._combined[h])}}translateToString(e,i,n,s){i=i??0,n=n??this.length,e&&(n=Math.min(n,this.getTrimmedLength())),s&&(s.length=0);let r="";for(;i<n;){let o=this._data[i*vt+0],a=o&2097151,u=o&2097152?this._combined[i]:a?xa(a):Ea;if(r+=u,s)for(let h=0;h<u.length;++h)s.push(i);i+=o>>22||1}return s&&s.push(i),r}};function ase(t,e,i,n,s,r){let o=[];for(let a=0;a<t.length-1;a++){let u=a,h=t.get(++u);if(!h.isWrapped)continue;let p=[t.get(a)];for(;u<t.length&&h.isWrapped;)p.push(h),h=t.get(++u);if(!r&&n>=a&&n<u){a+=p.length-1;continue}let m=0,v=Hf(p,m,e),_=1,x=0;for(;_<p.length;){let C=Hf(p,_,e),k=C-x,M=i-v,L=Math.min(k,M);p[m].copyCellsFrom(p[_],x,v,L,!1),v+=L,v===i&&(m++,v=0),x+=L,x===C&&(_++,x=0),v===0&&m!==0&&p[m-1].getWidth(i-1)===2&&(p[m].copyCellsFrom(p[m-1],i-1,v++,1,!1),p[m-1].setCell(i-1,s))}p[m].replaceCells(v,i,s);let S=0;for(let C=p.length-1;C>0&&(C>m||p[C].getTrimmedLength()===0);C--)S++;S>0&&(o.push(a+p.length-S),o.push(S)),a+=p.length-1}return o}function cse(t,e){let i=[],n=0,s=e[n],r=0;for(let o=0;o<t.length;o++)if(s===o){let a=e[++n];t.onDeleteEmitter.fire({index:o-r,amount:a}),o+=a-1,r+=a,s=e[++n]}else i.push(o);return{layout:i,countRemoved:r}}function use(t,e){let i=[];for(let n=0;n<e.length;n++)i.push(t.get(e[n]));for(let n=0;n<i.length;n++)t.set(n,i[n]);t.length=e.length}function hse(t,e,i){let n=[],s=t.map((u,h)=>Hf(t,h,e)).reduce((u,h)=>u+h),r=0,o=0,a=0;for(;a<s;){if(s-a<i){n.push(s-a);break}r+=i;let u=Hf(t,o,e);r>u&&(r-=u,o++);let h=t[o].getWidth(r-1)===2;h&&r--;let p=h?i-1:i;n.push(p),a+=p}return n}function Hf(t,e,i){if(e===t.length-1)return t[e].getTrimmedLength();let n=!t[e].hasContent(i-1)&&t[e].getWidth(i-1)===1,s=t[e+1].getWidth(0)===2;return n&&s?i-1:i}var p6=class m6{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=m6._nextId++,this._onDispose=this.register(new Te),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Pc(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};p6._nextId=1;var dse=p6,mn={},mc=mn.B;mn[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:"≥","{":"π","|":"≠","}":"£","~":"·"};mn.A={"#":"£"};mn.B=void 0;mn[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};mn.C=mn[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};mn.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};mn.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};mn.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};mn.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};mn.E=mn[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};mn.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};mn.H=mn[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};mn["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var FL=4294967295,HL=class{constructor(t,e,i){this._hasScrollback=t,this._optionsService=e,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=tn.clone(),this.savedCharset=mc,this.markers=[],this._nullCell=Ir.fromCharData([0,jD,1,0]),this._whitespaceCell=Ir.fromCharData([0,Ea,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new $0,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new $L(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new O0),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new O0),this._whitespaceCell}getBlankLine(t,e){return new hf(this._bufferService.cols,this.getNullCell(t),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let t=this.ybase+this.y-this.ydisp;return t>=0&&t<this._rows}_getCorrectBufferLength(t){if(!this._hasScrollback)return t;let e=t+this._optionsService.rawOptions.scrollback;return e>FL?FL:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=tn);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new $L(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let i=this.getNullCell(tn),n=0,s=this._getCorrectBufferLength(e);if(s>this.lines.maxLength&&(this.lines.maxLength=s),this.lines.length>0){if(this._cols<t)for(let o=0;o<this.lines.length;o++)n+=+this.lines.get(o).resize(t,i);let r=0;if(this._rows<e)for(let o=this._rows;o<e;o++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new hf(t,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+r+1?(this.ybase--,r++,this.ydisp>0&&this.ydisp--):this.lines.push(new hf(t,i)));else for(let o=this._rows;o>e;o--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(s<this.lines.maxLength){let o=this.lines.length-s;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=s}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),r&&(this.y+=r),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let r=0;r<this.lines.length;r++)n+=+this.lines.get(r).resize(t,i);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),n>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let i=this._optionsService.rawOptions.reflowCursorLine,n=ase(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(tn),i);if(n.length>0){let s=cse(this.lines,n);use(this.lines,s.layout),this._reflowLargerAdjustViewport(t,e,s.countRemoved)}}_reflowLargerAdjustViewport(t,e,i){let n=this.getNullCell(tn),s=i;for(;s-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new hf(t,n))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(t,e){let i=this._optionsService.rawOptions.reflowCursorLine,n=this.getNullCell(tn),s=[],r=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=t)continue;let u=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),u.unshift(a);if(!i){let L=this.ybase+this.y;if(L>=o&&L<o+u.length)continue}let h=u[u.length-1].getTrimmedLength(),p=hse(u,this._cols,t),m=p.length-u.length,v;this.ybase===0&&this.y!==this.lines.length-1?v=Math.max(0,this.y-this.lines.maxLength+m):v=Math.max(0,this.lines.length-this.lines.maxLength+m);let _=[];for(let L=0;L<m;L++){let N=this.getBlankLine(tn,!0);_.push(N)}_.length>0&&(s.push({start:o+u.length+r,newLines:_}),r+=_.length),u.push(..._);let x=p.length-1,S=p[x];S===0&&(x--,S=p[x]);let C=u.length-m-1,k=h;for(;C>=0;){let L=Math.min(k,S);if(u[x]===void 0)break;if(u[x].copyCellsFrom(u[C],k-L,S-L,L,!0),S-=L,S===0&&(x--,S=p[x]),k-=L,k===0){C--;let N=Math.max(C,0);k=Hf(u,N,this._cols)}}for(let L=0;L<u.length;L++)p[L]<t&&u[L].setCell(p[L],n);let M=m-v;for(;M-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+r)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+m,this.ybase+e-1)}if(s.length>0){let o=[],a=[];for(let S=0;S<this.lines.length;S++)a.push(this.lines.get(S));let u=this.lines.length,h=u-1,p=0,m=s[p];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+r);let v=0;for(let S=Math.min(this.lines.maxLength-1,u+r-1);S>=0;S--)if(m&&m.start>h+v){for(let C=m.newLines.length-1;C>=0;C--)this.lines.set(S--,m.newLines[C]);S++,o.push({index:h+1,amount:m.newLines.length}),v+=m.newLines.length,m=s[++p]}else this.lines.set(S,a[h--]);let _=0;for(let S=o.length-1;S>=0;S--)o[S].index+=_,this.lines.onInsertEmitter.fire(o[S]),_+=o[S].amount;let x=Math.max(0,u+r-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(t,e,i=0,n){let s=this.lines.get(t);return s?s.translateToString(e,i,n):""}getWrappedRangeForLine(t){let e=t,i=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:e,last:i}}setupTabStops(t){for(t!=null?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t<this._cols;t+=this._optionsService.rawOptions.tabStopWidth)this.tabs[t]=!0}prevStop(t){for(t==null&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t==null&&(t=this.x);!this.tabs[++t]&&t<this._cols;);return t>=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===t&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].dispose();this.markers.length=0,this._isClearing=!1}addMarker(t){let e=new dse(t);return this.markers.push(e),e.register(this.lines.onTrim(i=>{e.line-=i,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(i=>{e.line>=i.index&&(e.line+=i.amount)})),e.register(this.lines.onDelete(i=>{e.line>=i.index&&e.line<i.index+i.amount&&e.dispose(),e.line>i.index&&(e.line-=i.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},fse=class extends yt{constructor(e,i){super(),this._optionsService=e,this._bufferService=i,this._onBufferActivate=this._register(new Te),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 HL(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new HL(!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,i){this._normal.resize(e,i),this._alt.resize(e,i),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},g6=2,v6=1,rw=class extends yt{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new Te),this.onResize=this._onResize.event,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,g6),this.rows=Math.max(t.rawOptions.rows||0,v6),this.buffers=this._register(new fse(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let i=this.cols!==t,n=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:i,rowsChanged:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let i=this.buffer,n;n=this._cachedBlankLine,(!n||n.length!==this.cols||n.getFg(0)!==t.fg||n.getBg(0)!==t.bg)&&(n=i.getBlankLine(t,e),this._cachedBlankLine=n),n.isWrapped=e;let s=i.ybase+i.scrollTop,r=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;r===i.lines.length-1?o?i.lines.recycle().copyFrom(n):i.lines.push(n.clone()):i.lines.splice(r+1,0,n.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=r-s+1;i.lines.shiftElements(s+1,o-1,-1),i.lines.set(r,n.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(t,e){let i=this.buffer;if(t<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else t+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let n=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+t,i.ybase),0),n!==i.ydisp&&(e||this._onScroll.fire(i.ydisp))}};rw=zi([Ie(0,gs)],rw);var Ru={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:z0,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},pse=["normal","bold","100","200","300","400","500","600","700","800","900"],mse=class extends yt{constructor(e){super(),this._onOptionChange=this._register(new Te),this.onOptionChange=this._onOptionChange.event;let i={...Ru};for(let n in e)if(n in i)try{let s=e[n];i[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=i,this.options={...i},this._setupOptions(),this._register(Ai(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,i){return this.onOptionChange(n=>{n===e&&i(this.rawOptions[e])})}onMultipleOptionChange(e,i){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&i()})}_setupOptions(){let e=n=>{if(!(n in Ru))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},i=(n,s)=>{if(!(n in Ru))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:i.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,i){switch(e){case"cursorStyle":if(i||(i=Ru[e]),!gse(i))throw new Error(`"${i}" is not a valid value for ${e}`);break;case"wordSeparator":i||(i=Ru[e]);break;case"fontWeight":case"fontWeightBold":if(typeof i=="number"&&1<=i&&i<=1e3)break;i=pse.includes(i)?i:Ru[e];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw new Error(`${e} cannot be less than 1, value: ${i}`);break;case"minimumContrastRatio":i=Math.max(1,Math.min(21,Math.round(i*10)/10));break;case"scrollback":if(i=Math.min(i,4294967295),i<0)throw new Error(`${e} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&i!==0)throw new Error(`${e} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{};break}return i}};function gse(t){return t==="block"||t==="underline"||t==="bar"}function df(t,e=5){if(typeof t!="object")return t;let i=Array.isArray(t)?[]:{};for(let n in t)i[n]=e<=1?t[n]:t[n]&&df(t[n],e-1);return i}var WL=Object.freeze({insertMode:!1}),qL=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),ow=class extends yt{constructor(e,i,n){super(),this._bufferService=e,this._logService=i,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Te),this.onData=this._onData.event,this._onUserInput=this._register(new Te),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Te),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Te),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=df(WL),this.decPrivateModes=df(qL)}reset(){this.modes=df(WL),this.decPrivateModes=df(qL)}triggerDataEvent(e,i=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;i&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),i&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.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(i=>i.charCodeAt(0))),this._onBinary.fire(e))}};ow=zi([Ie(0,ms),Ie(1,ID),Ie(2,gs)],ow);var UL={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>t.button===4||t.action!==1?!1:(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>t.action!==32},DRAG:{events:23,restrict:t=>!(t.action===32&&t.button===3)},ANY:{events:31,restrict:t=>!0}};function Ny(t,e){let i=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(i|=64,i|=t.action):(i|=t.button&3,t.button&4&&(i|=64),t.button&8&&(i|=128),t.action===32?i|=32:t.action===0&&!e&&(i|=3)),i}var jy=String.fromCharCode,VL={DEFAULT:t=>{let e=[Ny(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${jy(e[0])}${jy(e[1])}${jy(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Ny(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Ny(t,!0)};${t.x};${t.y}${e}`}},lw=class extends yt{constructor(t,e,i){super(),this._bufferService=t,this._coreService=e,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Te),this.onProtocolChange=this._onProtocolChange.event;for(let n of Object.keys(UL))this.addProtocol(n,UL[n]);for(let n of Object.keys(VL))this.addEncoding(n,VL[n]);this.reset()}addProtocol(t,e){this._protocols[t]=e}addEncoding(t,e){this._encodings[t]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(t){if(!this._protocols[t])throw new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,e,i){if(t.deltaY===0||t.shiftKey||e===void 0||i===void 0)return 0;let n=e/i,s=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(s/=n+0,Math.abs(t.deltaY)<50&&(s*=.3),this._wheelPartialScroll+=s,s=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(s*=this._bufferService.rows),s}_applyScrollModifier(t,e){return e.altKey||e.ctrlKey||e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(t){if(t.col<0||t.col>=this._bufferService.cols||t.row<0||t.row>=this._bufferService.rows||t.button===4&&t.action===32||t.button===3&&t.action!==32||t.button!==4&&(t.action===2||t.action===3)||(t.col++,t.row++,t.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,t,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(t))return!1;let e=this._encodings[this._activeEncoding](t);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(t&1),up:!!(t&2),drag:!!(t&4),move:!!(t&8),wheel:!!(t&16)}}_equalEvents(t,e,i){if(i){if(t.x!==e.x||t.y!==e.y)return!1}else if(t.col!==e.col||t.row!==e.row)return!1;return!(t.button!==e.button||t.action!==e.action||t.ctrl!==e.ctrl||t.alt!==e.alt||t.shift!==e.shift)}};lw=zi([Ie(0,ms),Ie(1,qc),Ie(2,gs)],lw);var Ry=[[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]],vse=[[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]],dn;function _se(t,e){let i=0,n=e.length-1,s;if(t<e[0][0]||t>e[n][1])return!1;for(;n>=i;)if(s=i+n>>1,t>e[s][1])i=s+1;else if(t<e[s][0])n=s-1;else return!0;return!1}var yse=class{constructor(){if(this.version="6",!dn){dn=new Uint8Array(65536),dn.fill(1),dn[0]=0,dn.fill(0,1,32),dn.fill(0,127,160),dn.fill(2,4352,4448),dn[9001]=2,dn[9002]=2,dn.fill(2,11904,42192),dn[12351]=1,dn.fill(2,44032,55204),dn.fill(2,63744,64256),dn.fill(2,65040,65050),dn.fill(2,65072,65136),dn.fill(2,65280,65377),dn.fill(2,65504,65511);for(let e=0;e<Ry.length;++e)dn.fill(0,Ry[e][0],Ry[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?dn[e]:_se(e,vse)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,i){let n=this.wcwidth(e),s=n===0&&i!==0;if(s){let r=xc.extractWidth(i);r===0?s=!1:r>n&&(n=r)}return xc.createPropertyValue(0,n,s)}},xc=class Ug{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Te,this.onChange=this._onChange.event;let e=new yse;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,i,n=!1){return(e&16777215)<<3|(i&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let i=0,n=0,s=e.length;for(let r=0;r<s;++r){let o=e.charCodeAt(r);if(55296<=o&&o<=56319){if(++r>=s)return i+this.wcwidth(o);let h=e.charCodeAt(r);56320<=h&&h<=57343?o=(o-55296)*1024+h-56320+65536:i+=this.wcwidth(h)}let a=this.charProperties(o,n),u=Ug.extractWidth(a);Ug.extractShouldJoin(a)&&(u-=Ug.extractWidth(n)),i+=u,n=a}return i}charProperties(e,i){return this._activeProvider.charProperties(e,i)}},xse=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,i){this._charsets[e]=i,this.glevel===e&&(this.charset=i)}};function KL(t){let e=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1)?.get(t.cols-1),i=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);i&&e&&(i.isWrapped=e[3]!==0&&e[3]!==32)}var Qd=2147483647,bse=256,_6=class aw{constructor(e=32,i=32){if(this.maxLength=e,this.maxSubParamsLength=i,i>bse)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let i=new aw;if(!e.length)return i;for(let n=Array.isArray(e[0])?1:0;n<e.length;++n){let s=e[n];if(Array.isArray(s))for(let r=0;r<s.length;++r)i.addSubParam(s[r]);else i.addParam(s)}return i}clone(){let e=new aw(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let i=0;i<this.length;++i){e.push(this.params[i]);let n=this._subParamsIdx[i]>>8,s=this._subParamsIdx[i]&255;s-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,s))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>Qd?Qd:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>Qd?Qd:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let i=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-i>0?this._subParams.subarray(i,n):null}getSubParamsAll(){let e={};for(let i=0;i<this.length;++i){let n=this._subParamsIdx[i]>>8,s=this._subParamsIdx[i]&255;s-n>0&&(e[i]=this._subParams.slice(n,s))}return e}addDigit(e){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,s=n[i-1];n[i-1]=~s?Math.min(s*10+e,Qd):e}},Xd=[],wse=class{constructor(){this._state=0,this._active=Xd,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,i){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(i),{dispose:()=>{let s=n.indexOf(i);s!==-1&&n.splice(s,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=Xd}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=Xd,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Xd,!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,i,n){if(!this._active.length)this._handlerFb(this._id,"PUT",gv(e,i,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,i,n)}start(){this.reset(),this._state=1}put(e,i,n){if(this._state!==3){if(this._state===1)for(;i<n;){let s=e[i++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&n-i>0&&this._put(e,i,n)}}end(e,i=!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 n=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=i,r=this._stack.fallThrough,this._stack.paused=!1),!r&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Xd,this._id=-1,this._state=0}}},Js=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,i,n){this._hitLimit||(this._data+=gv(e,i,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let i=!1;if(this._hitLimit)i=!1;else if(e&&(i=this._handler(this._data),i instanceof Promise))return i.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,i}},Zd=[],Sse=class{constructor(){this._handlers=Object.create(null),this._active=Zd,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Zd}registerHandler(e,i){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(i),{dispose:()=>{let s=n.indexOf(i);s!==-1&&n.splice(s,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=Zd,this._ident=0}hook(e,i){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Zd,!this._active.length)this._handlerFb(this._ident,"HOOK",i);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(i)}put(e,i,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",gv(e,i,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,i,n)}unhook(e,i=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=i,r=this._stack.fallThrough,this._stack.paused=!1),!r&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Zd,this._ident=0}},ff=new _6;ff.addParam(0);var YL=class{constructor(t){this._handler=t,this._data="",this._params=ff,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():ff,this._data="",this._hitLimit=!1}put(t,e,i){this._hitLimit||(this._data+=gv(t,e,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(i=>(this._params=ff,this._data="",this._hitLimit=!1,i));return this._params=ff,this._data="",this._hitLimit=!1,e}},kse=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,i){this.table.fill(e<<4|i)}add(e,i,n,s){this.table[i<<8|e]=n<<4|s}addMany(e,i,n,s){for(let r=0;r<e.length;r++)this.table[i<<8|e[r]]=n<<4|s}},Ar=160,Cse=(function(){let t=new kse(4095),e=Array.apply(null,Array(256)).map((a,u)=>u),i=(a,u)=>e.slice(a,u),n=i(32,127),s=i(0,24);s.push(25),s.push.apply(s,i(28,32));let r=i(0,14),o;t.setDefault(1,0),t.addMany(n,0,2,0);for(o in r)t.addMany([24,26,153,154],o,3,0),t.addMany(i(128,144),o,3,0),t.addMany(i(144,152),o,3,0),t.add(156,o,0,0),t.add(27,o,11,1),t.add(157,o,4,8),t.addMany([152,158,159],o,0,7),t.add(155,o,11,3),t.add(144,o,11,9);return t.addMany(s,0,3,0),t.addMany(s,1,3,1),t.add(127,1,0,1),t.addMany(s,8,0,8),t.addMany(s,3,3,3),t.add(127,3,0,3),t.addMany(s,4,3,4),t.add(127,4,0,4),t.addMany(s,6,3,6),t.addMany(s,5,3,5),t.add(127,5,0,5),t.addMany(s,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(n,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(i(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(n,7,0,7),t.addMany(s,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(i(64,127),3,7,0),t.addMany(i(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(i(48,60),4,8,4),t.addMany(i(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(i(32,64),6,0,6),t.add(127,6,0,6),t.addMany(i(64,127),6,0,0),t.addMany(i(32,48),3,9,5),t.addMany(i(32,48),5,9,5),t.addMany(i(48,64),5,0,6),t.addMany(i(64,127),5,7,0),t.addMany(i(32,48),4,9,5),t.addMany(i(32,48),1,9,2),t.addMany(i(32,48),2,9,2),t.addMany(i(48,127),2,10,0),t.addMany(i(48,80),1,10,0),t.addMany(i(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(i(96,127),1,10,0),t.add(80,1,11,9),t.addMany(s,9,0,9),t.add(127,9,0,9),t.addMany(i(28,32),9,0,9),t.addMany(i(32,48),9,9,12),t.addMany(i(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(s,11,0,11),t.addMany(i(32,128),11,0,11),t.addMany(i(28,32),11,0,11),t.addMany(s,10,0,10),t.add(127,10,0,10),t.addMany(i(28,32),10,0,10),t.addMany(i(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(i(32,48),10,9,12),t.addMany(s,12,0,12),t.add(127,12,0,12),t.addMany(i(28,32),12,0,12),t.addMany(i(32,48),12,9,12),t.addMany(i(48,64),12,0,11),t.addMany(i(64,127),12,12,13),t.addMany(i(64,127),10,12,13),t.addMany(i(64,127),9,12,13),t.addMany(s,13,13,13),t.addMany(n,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(Ar,0,2,0),t.add(Ar,8,5,8),t.add(Ar,6,0,6),t.add(Ar,11,0,11),t.add(Ar,13,13,13),t})(),Ese=class extends yt{constructor(e=Cse){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 _6,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(i,n,s)=>{},this._executeHandlerFb=i=>{},this._csiHandlerFb=(i,n)=>{},this._escHandlerFb=i=>{},this._errorHandlerFb=i=>i,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Ai(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new wse),this._dcsParser=this._register(new Sse),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,i=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>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 r=0;r<e.intermediates.length;++r){let o=e.intermediates.charCodeAt(r);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(i[0]>s||s>i[1])throw new Error(`final must be in range ${i[0]} .. ${i[1]}`);return n<<=8,n|=s,n}identToString(e){let i=[];for(;e;)i.push(String.fromCharCode(e&255)),e>>=8;return i.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,i){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(i),{dispose:()=>{let r=s.indexOf(i);r!==-1&&s.splice(r,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,i){this._executeHandlers[e.charCodeAt(0)]=i}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,i){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(i),{dispose:()=>{let r=s.indexOf(i);r!==-1&&s.splice(r,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,i){return this._dcsParser.registerHandler(this._identifier(e),i)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,i){return this._oscParser.registerHandler(e,i)}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,i,n,s,r){this._parseStack.state=e,this._parseStack.handlers=i,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,i,n){let s=0,r=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let u=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&h>-1){for(;h>=0&&(a=u[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(n===!1&&h>-1){for(;h>=0&&(a=u[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(s!==24&&s!==26,n),a)return a;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],a=this._oscParser.end(s!==24&&s!==26,n),a)return a;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let u=o;u<i;++u){switch(s=e[u],r=this._transitions.table[this.currentState<<8|(s<160?s:Ar)],r>>4){case 2:for(let _=u+1;;++_){if(_>=i||(s=e[_])<32||s>126&&s<Ar){this._printHandler(e,u,_),u=_-1;break}if(++_>=i||(s=e[_])<32||s>126&&s<Ar){this._printHandler(e,u,_),u=_-1;break}if(++_>=i||(s=e[_])<32||s>126&&s<Ar){this._printHandler(e,u,_),u=_-1;break}if(++_>=i||(s=e[_])<32||s>126&&s<Ar){this._printHandler(e,u,_),u=_-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:u,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|s],p=h?h.length-1:-1;for(;p>=0&&(a=h[p](this._params),a!==!0);p--)if(a instanceof Promise)return this._preserveStack(3,h,p,r,u),a;p<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++u<i&&(s=e[u])>47&&s<60);u--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let m=this._escHandlers[this._collect<<8|s],v=m?m.length-1:-1;for(;v>=0&&(a=m[v](),a!==!0);v--)if(a instanceof Promise)return this._preserveStack(4,m,v,r,u),a;v<0&&this._escHandlerFb(this._collect<<8|s),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|s,this._params);break;case 13:for(let _=u+1;;++_)if(_>=i||(s=e[_])===24||s===26||s===27||s>127&&s<Ar){this._dcsParser.put(e,u,_),u=_-1;break}break;case 14:if(a=this._dcsParser.unhook(s!==24&&s!==26),a)return this._preserveStack(6,[],0,r,u),a;s===27&&(r|=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 _=u+1;;_++)if(_>=i||(s=e[_])<32||s>127&&s<Ar){this._oscParser.put(e,u,_),u=_-1;break}break;case 6:if(a=this._oscParser.end(s!==24&&s!==26),a)return this._preserveStack(5,[],0,r,u),a;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},Mse=/^([\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})$/,Ase=/^[\da-f]+$/;function GL(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let i=Mse.exec(e);if(i){let n=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/n*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/n*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/n*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),Ase.exec(e)&&[3,6,9,12].includes(e.length))){let i=e.length/3,n=[0,0,0];for(let s=0;s<3;++s){let r=parseInt(e.slice(i*s,i*s+i),16);n[s]=i===1?r<<4:i===2?r:i===3?r>>4:r>>8}return n}}function Dy(t,e){let i=t.toString(16),n=i.length<2?"0"+i:i;switch(e){case 4:return i[0];case 8:return n;case 12:return(n+n).slice(0,3);default:return n+n}}function Lse(t,e=16){let[i,n,s]=t;return`rgb:${Dy(i,e)}/${Dy(n,e)}/${Dy(s,e)}`}var Tse={"(":0,")":1,"*":2,"+":3,"-":1,".":2},fa=131072,QL=10;function XL(t,e){if(t>24)return e.setWinLines||!1;switch(t){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var ZL=5e3,JL=0,Nse=class extends yt{constructor(t,e,i,n,s,r,o,a,u=new Ese){super(),this._bufferService=t,this._charsetService=e,this._coreService=i,this._logService=n,this._optionsService=s,this._oscLinkService=r,this._coreMouseService=o,this._unicodeService=a,this._parser=u,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Qte,this._utf8Decoder=new Xte,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=tn.clone(),this._eraseAttrDataInternal=tn.clone(),this._onRequestBell=this._register(new Te),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Te),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Te),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Te),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Te),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Te),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Te),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Te),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Te),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Te),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Te),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Te),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 cw(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,p)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:p.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,p,m)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:p,data:m})}),this._parser.setDcsHandlerFallback((h,p,m)=>{p==="HOOK"&&(m=m.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:p,payload:m})}),this._parser.setPrintHandler((h,p,m)=>this.print(h,p,m)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(we.BEL,()=>this.bell()),this._parser.setExecuteHandler(we.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(we.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(we.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(we.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(we.BS,()=>this.backspace()),this._parser.setExecuteHandler(we.HT,()=>this.tab()),this._parser.setExecuteHandler(we.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(we.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Wg.IND,()=>this.index()),this._parser.setExecuteHandler(Wg.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Wg.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Js(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Js(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Js(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Js(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Js(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Js(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Js(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Js(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Js(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Js(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Js(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Js(h=>this.restoreCursorColor(h))),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 h in mn)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new YL((h,p)=>this.requestStatusString(h,p)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,i,n){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=i,this._parseStack.position=n}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),ZL))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${ZL} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let i,n=this._activeBuffer.x,s=this._activeBuffer.y,r=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(i),i;n=this._parseStack.cursorStartX,s=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>fa&&(r=this._parseStack.position+fa)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(h=>h.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<fa&&(this._parseBuffer=new Uint32Array(Math.min(t.length,fa))),o||this._dirtyRowTracker.clearRange(),t.length>fa)for(let h=r;h<t.length;h+=fa){let p=h+fa<t.length?h+fa:t.length,m=typeof t=="string"?this._stringDecoder.decode(t.substring(h,p),this._parseBuffer):this._utf8Decoder.decode(t.subarray(h,p),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,m))return this._preserveStack(n,s,m,h),this._logSlowResolvingAsync(i),i}else if(!o){let h=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,h))return this._preserveStack(n,s,h,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==n||this._activeBuffer.y!==s)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),u=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);u<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(u,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(t,e,i){let n,s,r=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,u=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,p=this._curAttrData,m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-e>0&&m.getWidth(this._activeBuffer.x-1)===2&&m.setCellFromCodepoint(this._activeBuffer.x-1,0,1,p);let v=this._parser.precedingJoinState;for(let _=e;_<i;++_){if(n=t[_],n<127&&r){let k=r[String.fromCharCode(n)];k&&(n=k.charCodeAt(0))}let x=this._unicodeService.charProperties(n,v);s=xc.extractWidth(x);let S=xc.extractShouldJoin(x),C=S?xc.extractWidth(v):0;if(v=x,o&&this._onA11yChar.fire(xa(n)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+s-C>a){if(u){let k=m,M=this._activeBuffer.x-C;for(this._activeBuffer.x=C,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),m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),C>0&&m instanceof hf&&m.copyCellsFrom(k,M,0,C,!1);M<a;)k.setCellFromCodepoint(M++,0,1,p)}else if(this._activeBuffer.x=a-1,s===2)continue}if(S&&this._activeBuffer.x){let k=m.getWidth(this._activeBuffer.x-1)?1:2;m.addCodepointToCell(this._activeBuffer.x-k,n,s);for(let M=s-C;--M>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,p);continue}if(h&&(m.insertCells(this._activeBuffer.x,s-C,this._activeBuffer.getNullCell(p)),m.getWidth(a-1)===2&&m.setCellFromCodepoint(a-1,0,1,p)),m.setCellFromCodepoint(this._activeBuffer.x++,n,s,p),s>0)for(;--s;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,p)}this._parser.precedingJoinState=v,this._activeBuffer.x<a&&i-e>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.setCellFromCodepoint(this._activeBuffer.x,0,1,p),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,i=>XL(i.params[0],this._optionsService.rawOptions.windowOptions)?e(i):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new YL(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new Js(e))}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 t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-t),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(t=this._bufferService.cols-1){this._activeBuffer.x=Math.min(t,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(t,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=t,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+e)}cursorUp(t){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,t.params[0]||1)):this._moveCursor(0,-(t.params[0]||1)),!0}cursorDown(t){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,t.params[0]||1)):this._moveCursor(0,t.params[0]||1),!0}cursorForward(t){return this._moveCursor(t.params[0]||1,0),!0}cursorBackward(t){return this._moveCursor(-(t.params[0]||1),0),!0}cursorNextLine(t){return this.cursorDown(t),this._activeBuffer.x=0,!0}cursorPrecedingLine(t){return this.cursorUp(t),this._activeBuffer.x=0,!0}cursorCharAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(t){return this._setCursor(t.length>=2?(t.params[1]||1)-1:0,(t.params[0]||1)-1),!0}charPosAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(t){return this._moveCursor(t.params[0]||1,0),!0}linePosAbsolute(t){return this._setCursor(this._activeBuffer.x,(t.params[0]||1)-1),!0}vPositionRelative(t){return this._moveCursor(0,t.params[0]||1),!0}hVPosition(t){return this.cursorPosition(t),!0}tabClear(t){let e=t.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let e=t.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,e,i,n=!1,s=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);r.replaceCells(e,i,this._activeBuffer.getNullCell(this._eraseAttrData()),s),n&&(r.isWrapped=!1)}_resetBufferLine(t,e=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),i.isWrapped=!1)}eraseInDisplay(t,e=!1){this._restrictCursor(this._bufferService.cols);let i;switch(t.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);i<this._bufferService.rows;i++)this._resetBufferLine(i,e);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+i)?.getTrimmedLength(););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,e);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(t,e=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-n+1;for(;e--;)this._activeBuffer.lines.splice(s-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=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;e--;)this._activeBuffer.lines.splice(i,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(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let e=t.params[0]||1;for(;e--;)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(t){let e=t.params[0]||1;for(;e--;)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(tn));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);n.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);n.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);n.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);n.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(t.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(t){let e=this._parser.precedingJoinState;if(!e)return!0;let i=t.params[0]||1,n=xc.extractWidth(e),s=this._activeBuffer.x-n,r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(s),o=new Uint32Array(r.length*i),a=0;for(let h=0;h<r.length;){let p=r.codePointAt(h)||0;o[a++]=p,h+=p>65535?2:1}let u=a;for(let h=1;h<i;++h)o.copyWithin(u,0,a),u+=a;return this.print(o,0,u),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(we.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(we.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(we.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(we.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(we.ESC+"[>83;40003;0c")),!0}_is(t){return(this._optionsService.rawOptions.termName+"").indexOf(t)===0}setMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,mc),this._charsetService.setgCharset(1,mc),this._charsetService.setgCharset(2,mc),this._charsetService.setgCharset(3,mc);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(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){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(),t.params[e]===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(t,e){let i;(S=>(S[S.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",S[S.SET=1]="SET",S[S.RESET=2]="RESET",S[S.PERMANENTLY_SET=3]="PERMANENTLY_SET",S[S.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(i||={});let n=this._coreService.decPrivateModes,{activeProtocol:s,activeEncoding:r}=this._coreMouseService,o=this._coreService,{buffers:a,cols:u}=this._bufferService,{active:h,alt:p}=a,m=this._optionsService.rawOptions,v=(S,C)=>(o.triggerDataEvent(`${we.ESC}[${e?"":"?"}${S};${C}$y`),!0),_=S=>S?1:2,x=t.params[0];return e?x===2?v(x,4):x===4?v(x,_(o.modes.insertMode)):x===12?v(x,3):x===20?v(x,_(m.convertEol)):v(x,0):x===1?v(x,_(n.applicationCursorKeys)):x===3?v(x,m.windowOptions.setWinLines?u===80?2:u===132?1:0:0):x===6?v(x,_(n.origin)):x===7?v(x,_(n.wraparound)):x===8?v(x,3):x===9?v(x,_(s==="X10")):x===12?v(x,_(m.cursorBlink)):x===25?v(x,_(!o.isCursorHidden)):x===45?v(x,_(n.reverseWraparound)):x===66?v(x,_(n.applicationKeypad)):x===67?v(x,4):x===1e3?v(x,_(s==="VT200")):x===1002?v(x,_(s==="DRAG")):x===1003?v(x,_(s==="ANY")):x===1004?v(x,_(n.sendFocus)):x===1005?v(x,4):x===1006?v(x,_(r==="SGR")):x===1015?v(x,4):x===1016?v(x,_(r==="SGR_PIXELS")):x===1048?v(x,1):x===47||x===1047||x===1049?v(x,_(h===p)):x===2004?v(x,_(n.bracketedPasteMode)):x===2026?v(x,_(n.synchronizedOutput)):v(x,0)}_updateAttrColor(t,e,i,n,s){return e===2?(t|=50331648,t&=-16777216,t|=sp.fromColorRGB([i,n,s])):e===5&&(t&=-50331904,t|=33554432|i&255),t}_extractColor(t,e,i){let n=[0,0,-1,0,0,0],s=0,r=0;do{if(n[r+s]=t.params[e+r],t.hasSubParams(e+r)){let o=t.getSubParams(e+r),a=0;do n[1]===5&&(s=1),n[r+a+1+s]=o[a];while(++a<o.length&&a+r+1+s<n.length);break}if(n[1]===5&&r+s>=2||n[1]===2&&r+s>=5)break;n[1]&&(s=1)}while(++r+e<t.length&&r+s<n.length);for(let o=2;o<n.length;++o)n[o]===-1&&(n[o]=0);switch(n[0]){case 38:i.fg=this._updateAttrColor(i.fg,n[1],n[3],n[4],n[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,n[1],n[3],n[4],n[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,n[1],n[3],n[4],n[5])}return r}_processUnderline(t,e){e.extended=e.extended.clone(),(!~t||t>5)&&(t=1),e.extended.underlineStyle=t,e.fg|=268435456,t===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(t){t.fg=tn.fg,t.bg=tn.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(t.length===1&&t.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=t.length,i,n=this._curAttrData;for(let s=0;s<e;s++)i=t.params[s],i>=30&&i<=37?(n.fg&=-50331904,n.fg|=16777216|i-30):i>=40&&i<=47?(n.bg&=-50331904,n.bg|=16777216|i-40):i>=90&&i<=97?(n.fg&=-50331904,n.fg|=16777216|i-90|8):i>=100&&i<=107?(n.bg&=-50331904,n.bg|=16777216|i-100|8):i===0?this._processSGR0(n):i===1?n.fg|=134217728:i===3?n.bg|=67108864:i===4?(n.fg|=268435456,this._processUnderline(t.hasSubParams(s)?t.getSubParams(s)[0]:1,n)):i===5?n.fg|=536870912:i===7?n.fg|=67108864:i===8?n.fg|=1073741824:i===9?n.fg|=2147483648:i===2?n.bg|=134217728:i===21?this._processUnderline(2,n):i===22?(n.fg&=-134217729,n.bg&=-134217729):i===23?n.bg&=-67108865:i===24?(n.fg&=-268435457,this._processUnderline(0,n)):i===25?n.fg&=-536870913:i===27?n.fg&=-67108865:i===28?n.fg&=-1073741825:i===29?n.fg&=2147483647:i===39?(n.fg&=-67108864,n.fg|=tn.fg&16777215):i===49?(n.bg&=-67108864,n.bg|=tn.bg&16777215):i===38||i===48||i===58?s+=this._extractColor(t,s,n):i===53?n.bg|=1073741824:i===55?n.bg&=-1073741825:i===59?(n.extended=n.extended.clone(),n.extended.underlineColor=-1,n.updateExtended()):i===100?(n.fg&=-67108864,n.fg|=tn.fg&16777215,n.bg&=-67108864,n.bg|=tn.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${we.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${we.ESC}[${e};${i}R`);break}return!0}deviceStatusPrivate(t){if(t.params[0]===6){let e=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${we.ESC}[?${e};${i}R`)}return!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=tn.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(t){let e=t.length===0?1:t.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){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 i=e%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(t){let e=t.params[0]||1,i;return(t.length<2||(i=t.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(t){if(!XL(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${we.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>QL&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>QL&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(t){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(t){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(t){return this._windowTitle=t,this._onTitleChange.fire(t),!0}setIconName(t){return this._iconName=t,!0}setOrReportIndexedColor(t){let e=[],i=t.split(";");for(;i.length>1;){let n=i.shift(),s=i.shift();if(/^\d+$/.exec(n)){let r=parseInt(n);if(eT(r))if(s==="?")e.push({type:0,index:r});else{let o=GL(s);o&&e.push({type:1,index:r,color:o})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(t){let e=t.indexOf(";");if(e===-1)return!0;let i=t.slice(0,e).trim(),n=t.slice(e+1);return n?this._createHyperlink(i,n):i.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let i=t.split(":"),n,s=i.findIndex(r=>r.startsWith("id="));return s!==-1&&(n=i[s].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:n,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,e){let i=t.split(";");for(let n=0;n<i.length&&!(e>=this._specialColors.length);++n,++e)if(i[n]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let s=GL(i[n]);s&&this._onColor.fire([{type:1,index:this._specialColors[e],color:s}])}return!0}setOrReportFgColor(t){return this._setOrReportSpecialColor(t,0)}setOrReportBgColor(t){return this._setOrReportSpecialColor(t,1)}setOrReportCursorColor(t){return this._setOrReportSpecialColor(t,2)}restoreIndexedColor(t){if(!t)return this._onColor.fire([{type:2}]),!0;let e=[],i=t.split(";");for(let n=0;n<i.length;++n)if(/^\d+$/.exec(i[n])){let s=parseInt(i[n]);eT(s)&&e.push({type:2,index:s})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(t){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(t){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(t){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,mc),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(Tse[t[0]],mn[t[1]]||mc),!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 t=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,t,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=tn.clone(),this._eraseAttrDataInternal=tn.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new Ir;t.content=1<<22|69,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let i=this._activeBuffer.ybase+this._activeBuffer.y+e,n=this._activeBuffer.lines.get(i);n&&(n.fill(t),n.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let i=o=>(this._coreService.triggerDataEvent(`${we.ESC}${o}${we.ESC}\\`),!0),n=this._bufferService.buffer,s=this._optionsService.rawOptions;return i(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[s.cursorStyle]-(s.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},cw=class{constructor(t){this._bufferService=t,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){t<this.start?this.start=t:t>this.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(JL=t,t=e,e=JL),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};cw=zi([Ie(0,ms)],cw);function eT(t){return 0<=t&&t<256}var jse=5e7,tT=12,Rse=50,Dse=class extends yt{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 Te),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,i){if(i!==void 0&&this._syncCalls>i){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 n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,i){if(this._pendingData>jse)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(i),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(i)}_innerWrite(e=0,i=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,i);if(r){let a=u=>performance.now()-n>=tT?setTimeout(()=>this._innerWrite(0,u)):this._innerWrite(n,u);r.catch(u=>(queueMicrotask(()=>{throw u}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=tT)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Rse&&(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()}},uw=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let i=this._bufferService.buffer;if(e.id===void 0){let u=i.addMarker(i.ybase+i.y),h={data:e,id:this._nextId++,lines:[u]};return u.onDispose(()=>this._removeMarkerFromLink(h,u)),this._dataByLinkId.set(h.id,h),h.id}let n=e,s=this._getEntryIdKey(n),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,i.ybase+i.y),r.id;let o=i.addMarker(i.ybase+i.y),a={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,i){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==i)){let s=this._bufferService.buffer.addMarker(i);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,i){let n=e.lines.indexOf(i);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};uw=zi([Ie(0,ms)],uw);var iT=!1,Bse=class extends yt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Sh),this._onBinary=this._register(new Te),this.onBinary=this._onBinary.event,this._onData=this._register(new Te),this.onData=this._onData.event,this._onLineFeed=this._register(new Te),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Te),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Te),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Te),this._instantiationService=new rse,this.optionsService=this._register(new mse(e)),this._instantiationService.setService(gs,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(rw)),this._instantiationService.setService(ms,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(sw)),this._instantiationService.setService(ID,this._logService),this.coreService=this._register(this._instantiationService.createInstance(ow)),this._instantiationService.setService(qc,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(lw)),this._instantiationService.setService(OD,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(xc)),this._instantiationService.setService(tie,this.unicodeService),this._charsetService=this._instantiationService.createInstance(xse),this._instantiationService.setService(eie,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(uw),this._instantiationService.setService(PD,this._oscLinkService),this._inputHandler=this._register(new Nse(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(zn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(zn.forward(this._bufferService.onResize,this._onResize)),this._register(zn.forward(this.coreService.onData,this._onData)),this._register(zn.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 Dse((i,n)=>this._inputHandler.parse(i,n))),this._register(zn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Te),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 i in e)this.optionsService.options[i]=e[i]}write(e,i){this._writeBuffer.write(e,i)}writeSync(e,i){this._logService.logLevel<=3&&!iT&&(this._logService.warn("writeSync is unreliable and will be removed soon."),iT=!0),this._writeBuffer.writeSync(e,i)}input(e,i=!0){this.coreService.triggerDataEvent(e,i)}resize(e,i){isNaN(e)||isNaN(i)||(e=Math.max(e,g6),i=Math.max(i,v6),this._bufferService.resize(e,i))}scroll(e,i=!1){this._bufferService.scroll(e,i)}scrollLines(e,i){this._bufferService.scrollLines(e,i)}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 i=e-this._bufferService.buffer.ydisp;i!==0&&this.scrollLines(i)}registerEscHandler(e,i){return this._inputHandler.registerEscHandler(e,i)}registerDcsHandler(e,i){return this._inputHandler.registerDcsHandler(e,i)}registerCsiHandler(e,i){return this._inputHandler.registerCsiHandler(e,i)}registerOscHandler(e,i){return this._inputHandler.registerOscHandler(e,i)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,i=this.optionsService.rawOptions.windowsPty;i&&i.buildNumber!==void 0&&i.buildNumber!==void 0?e=i.backend==="conpty"&&i.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(KL.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(KL(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ai(()=>{for(let i of e)i.dispose()})}}},Ose={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 Ise(t,e,i,n){let s={type:0,cancel:!1,key:void 0},r=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:t.key==="UIKeyInputUpArrow"?e?s.key=we.ESC+"OA":s.key=we.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?s.key=we.ESC+"OD":s.key=we.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?s.key=we.ESC+"OC":s.key=we.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?s.key=we.ESC+"OB":s.key=we.ESC+"[B");break;case 8:s.key=t.ctrlKey?"\b":we.DEL,t.altKey&&(s.key=we.ESC+s.key);break;case 9:if(t.shiftKey){s.key=we.ESC+"[Z";break}s.key=we.HT,s.cancel=!0;break;case 13:s.key=t.altKey?we.ESC+we.CR:we.CR,s.cancel=!0;break;case 27:s.key=we.ESC,t.altKey&&(s.key=we.ESC+we.ESC),s.cancel=!0;break;case 37:if(t.metaKey)break;r?s.key=we.ESC+"[1;"+(r+1)+"D":e?s.key=we.ESC+"OD":s.key=we.ESC+"[D";break;case 39:if(t.metaKey)break;r?s.key=we.ESC+"[1;"+(r+1)+"C":e?s.key=we.ESC+"OC":s.key=we.ESC+"[C";break;case 38:if(t.metaKey)break;r?s.key=we.ESC+"[1;"+(r+1)+"A":e?s.key=we.ESC+"OA":s.key=we.ESC+"[A";break;case 40:if(t.metaKey)break;r?s.key=we.ESC+"[1;"+(r+1)+"B":e?s.key=we.ESC+"OB":s.key=we.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(s.key=we.ESC+"[2~");break;case 46:r?s.key=we.ESC+"[3;"+(r+1)+"~":s.key=we.ESC+"[3~";break;case 36:r?s.key=we.ESC+"[1;"+(r+1)+"H":e?s.key=we.ESC+"OH":s.key=we.ESC+"[H";break;case 35:r?s.key=we.ESC+"[1;"+(r+1)+"F":e?s.key=we.ESC+"OF":s.key=we.ESC+"[F";break;case 33:t.shiftKey?s.type=2:t.ctrlKey?s.key=we.ESC+"[5;"+(r+1)+"~":s.key=we.ESC+"[5~";break;case 34:t.shiftKey?s.type=3:t.ctrlKey?s.key=we.ESC+"[6;"+(r+1)+"~":s.key=we.ESC+"[6~";break;case 112:r?s.key=we.ESC+"[1;"+(r+1)+"P":s.key=we.ESC+"OP";break;case 113:r?s.key=we.ESC+"[1;"+(r+1)+"Q":s.key=we.ESC+"OQ";break;case 114:r?s.key=we.ESC+"[1;"+(r+1)+"R":s.key=we.ESC+"OR";break;case 115:r?s.key=we.ESC+"[1;"+(r+1)+"S":s.key=we.ESC+"OS";break;case 116:r?s.key=we.ESC+"[15;"+(r+1)+"~":s.key=we.ESC+"[15~";break;case 117:r?s.key=we.ESC+"[17;"+(r+1)+"~":s.key=we.ESC+"[17~";break;case 118:r?s.key=we.ESC+"[18;"+(r+1)+"~":s.key=we.ESC+"[18~";break;case 119:r?s.key=we.ESC+"[19;"+(r+1)+"~":s.key=we.ESC+"[19~";break;case 120:r?s.key=we.ESC+"[20;"+(r+1)+"~":s.key=we.ESC+"[20~";break;case 121:r?s.key=we.ESC+"[21;"+(r+1)+"~":s.key=we.ESC+"[21~";break;case 122:r?s.key=we.ESC+"[23;"+(r+1)+"~":s.key=we.ESC+"[23~";break;case 123:r?s.key=we.ESC+"[24;"+(r+1)+"~":s.key=we.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?s.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?s.key=we.NUL:t.keyCode>=51&&t.keyCode<=55?s.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?s.key=we.DEL:t.keyCode===219?s.key=we.ESC:t.keyCode===220?s.key=we.FS:t.keyCode===221&&(s.key=we.GS);else if((!i||n)&&t.altKey&&!t.metaKey){let o=Ose[t.keyCode]?.[t.shiftKey?1:0];if(o)s.key=we.ESC+o;else if(t.keyCode>=65&&t.keyCode<=90){let a=t.ctrlKey?t.keyCode-64:t.keyCode+32,u=String.fromCharCode(a);t.shiftKey&&(u=u.toUpperCase()),s.key=we.ESC+u}else if(t.keyCode===32)s.key=we.ESC+(t.ctrlKey?we.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let a=t.code.slice(3,4);t.shiftKey||(a=a.toLowerCase()),s.key=we.ESC+a,s.cancel=!0}}else i&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(s.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?s.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(s.key=we.US),t.key==="@"&&(s.key=we.NUL));break}return s}var qi=0,Pse=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new $0,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new $0,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((r,o)=>this._getKey(r)-this._getKey(o)),i=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)n>=this._array.length||this._getKey(e[i])<=this._getKey(this._array[n])?(s[r]=e[i],i++):s[r]=this._array[n++];this._array=s,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 i=this._getKey(e);if(i===void 0||(qi=this._search(i),qi===-1)||this._getKey(this._array[qi])!==i)return!1;do if(this._array[qi]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(qi),!0;while(++qi<this._array.length&&this._getKey(this._array[qi])===i);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,o)=>r-o),i=0,n=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[i]===r?i++:n[s++]=this._array[r];this._array=n,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&&(qi=this._search(e),!(qi<0||qi>=this._array.length)&&this._getKey(this._array[qi])===e))do yield this._array[qi];while(++qi<this._array.length&&this._getKey(this._array[qi])===e)}forEachByKey(e,i){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(qi=this._search(e),!(qi<0||qi>=this._array.length)&&this._getKey(this._array[qi])===e))do i(this._array[qi]);while(++qi<this._array.length&&this._getKey(this._array[qi])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let i=0,n=this._array.length-1;for(;n>=i;){let s=i+n>>1,r=this._getKey(this._array[s]);if(r>e)n=s-1;else if(r<e)i=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return i}},By=0,nT=0,zse=class extends yt{constructor(){super(),this._decorations=new Pse(t=>t?.marker.line),this._onDecorationRegistered=this._register(new Te),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Te),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ai(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new $se(t);if(e){let i=e.marker.onDispose(()=>e.dispose()),n=e.onDispose(()=>{n.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),i.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,e,i){let n=0,s=0;for(let r of this._decorations.getKeyIterator(e))n=r.options.x??0,s=n+(r.options.width??1),t>=n&&t<s&&(!i||(r.options.layer??"bottom")===i)&&(yield r)}forEachDecorationAtCell(t,e,i,n){this._decorations.forEachByKey(e,s=>{By=s.options.x??0,nT=By+(s.options.width??1),t>=By&&t<nT&&(!i||(s.options.layer??"bottom")===i)&&n(s)})}},$se=class extends Aa{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new Te),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Te),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=t.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Ti.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ti.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Fse=1e3,Hse=class{constructor(e,i=Fse){this._renderCallback=e,this._debounceThresholdMS=i,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,i,n){this._rowCount=n,e=e!==void 0?e:0,i=i!==void 0?i: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,i):i;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-this._lastRefreshMs,o=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,i)}},sT=20,F0=class extends yt{constructor(t,e,i,n){super(),this._terminal=t,this._coreBrowserService=i,this._renderService=n,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let s=this._coreBrowserService.mainDocument;this._accessibilityContainer=s.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=s.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=s.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Hse(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(`
|
|
211
|
+
`))),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(lt(s,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ai(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<sT+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
|
|
212
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===sT+1&&(this._liveRegion.textContent+=Tb.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(t)||this._charsToConsume.push(t)}_refreshRows(t,e){this._liveRegionDebouncer.refresh(t,e,this._terminal.rows)}_renderRows(t,e){let i=this._terminal.buffer,n=i.lines.length.toString();for(let s=t;s<=e;s++){let r=i.lines.get(i.ydisp+s),o=[],a=r?.translateToString(!0,void 0,void 0,o)||"",u=(i.ydisp+s+1).toString(),h=this._rowElements[s];h&&(a.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=a,this._rowColumns.set(h,o)),h.setAttribute("aria-posinset",u),h.setAttribute("aria-setsize",n),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let i=t.target,n=this._rowElements[e===0?1:this._rowElements.length-2],s=i.getAttribute("aria-posinset"),r=e===0?"1":`${this._terminal.buffer.lines.length}`;if(s===r||t.relatedTarget!==n)return;let o,a;if(e===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let u=this._createAccessibilityTreeNode();this._rowElements.unshift(u),this._rowContainer.insertAdjacentElement("afterbegin",u)}else{let u=this._createAccessibilityTreeNode();this._rowElements.push(u),this._rowContainer.appendChild(u)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},i={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===i.node&&e.offset>i.offset)&&([e,i]=[i,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let n=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:n,offset:n.textContent?.length??0}),!this._rowContainer.contains(i.node))return;let s=({node:a,offset:u})=>{let h=a instanceof Text?a.parentNode:a,p=parseInt(h?.getAttribute("aria-posinset"),10)-1;if(isNaN(p))return console.warn("row is invalid. Race condition?"),null;let m=this._rowColumns.get(h);if(!m)return console.warn("columns is null. Race condition?"),null;let v=u<m.length?m[u]:m.slice(-1)[0]+1;return v>=this._terminal.cols&&(++p,v=0),{row:p,column:v}},r=s(e),o=s(i);if(!(!r||!o)){if(r.row>o.row||r.row===o.row&&r.column>=o.column)throw new Error("invalid range");this._terminal.select(r.column,r.row,(o.row-r.row)*this._terminal.cols-r.column+o.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let t=this._coreBrowserService.mainDocument.createElement("div");return t.setAttribute("role","listitem"),t.tabIndex=-1,this._refreshRowDimensions(t),t}_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 t=0;t<this._terminal.rows;t++)this._refreshRowDimensions(this._rowElements[t]),this._alignRowWidth(this._rowElements[t])}}_refreshRowDimensions(t){t.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(t){t.style.transform="";let e=t.getBoundingClientRect().width,i=this._rowColumns.get(t)?.slice(-1)?.[0];if(!i)return;let n=i*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${n/e})`}};F0=zi([Ie(1,qS),Ie(2,El),Ie(3,Ml)],F0);var hw=class extends yt{constructor(t,e,i,n,s){super(),this._element=t,this._mouseService=e,this._renderService=i,this._bufferService=n,this._linkProviderService=s,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Te),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Te),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Ai(()=>{Pc(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(lt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(lt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(lt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(lt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let i=t.composedPath();for(let n=0;n<i.length;n++){let s=i[n];if(s.classList.contains("xterm"))break;if(s.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized){this._clearCurrentLink(),this._askForLink(t,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){(!this._activeProviderReplies||!e)&&(this._activeProviderReplies?.forEach(n=>{n?.forEach(s=>{s.link.dispose&&s.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let i=!1;for(let[n,s]of this._linkProviderService.linkProviders.entries())e?this._activeProviderReplies?.get(n)&&(i=this._checkLinkProviderResult(n,t,i)):s.provideLinks(t.y,r=>{if(this._isMouseOut)return;let o=r?.map(a=>({link:a}));this._activeProviderReplies?.set(n,o),i=this._checkLinkProviderResult(n,t,i),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let i=new Set;for(let n=0;n<e.size;n++){let s=e.get(n);if(s)for(let r=0;r<s.length;r++){let o=s[r],a=o.link.range.start.y<t?0:o.link.range.start.x,u=o.link.range.end.y>t?this._bufferService.cols:o.link.range.end.x;for(let h=a;h<=u;h++){if(i.has(h)){s.splice(r--,1);break}i.add(h)}}}}_checkLinkProviderResult(t,e,i){if(!this._activeProviderReplies)return i;let n=this._activeProviderReplies.get(t),s=!1;for(let r=0;r<t;r++)(!this._activeProviderReplies.has(r)||this._activeProviderReplies.get(r))&&(s=!0);if(!s&&n){let r=n.find(o=>this._linkAtPosition(o.link,e));r&&(i=!0,this._handleNewLink(r))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let r=0;r<this._activeProviderReplies.size;r++){let o=this._activeProviderReplies.get(r)?.find(a=>this._linkAtPosition(a.link,e));if(o){i=!0,this._handleNewLink(o);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&Wse(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){!this._currentLink||!this._lastMouseEvent||(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Pc(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0?!0:t.link.decorations.underline,pointerCursor:t.link.decorations===void 0?!0:t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:i=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:i=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let n=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(n,s),this._lastMouseEvent)){let r=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);r&&this._askForLink(r,!1)}})))}_linkHover(t,e,i){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(i,e.text)}_fireUnderlineEvent(t,e){let i=t.range,n=this._bufferService.buffer.ydisp,s=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-n-1,i.end.x,i.end.y-n-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(s)}_linkLeave(t,e,i){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(i,e.text)}_linkAtPosition(t,e){let i=t.range.start.y*this._bufferService.cols+t.range.start.x,n=t.range.end.y*this._bufferService.cols+t.range.end.x,s=e.y*this._bufferService.cols+e.x;return i<=s&&s<=n}_positionFromMouseEvent(t,e,i){let n=i.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(n)return{x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,i,n,s){return{x1:t,y1:e,x2:i,y2:n,cols:this._bufferService.cols,fg:s}}};hw=zi([Ie(1,US),Ie(2,Ml),Ie(3,ms),Ie(4,$D)],hw);function Wse(t,e){return t.text===e.text&&t.range.start.x===e.range.start.x&&t.range.start.y===e.range.start.y&&t.range.end.x===e.range.end.x&&t.range.end.y===e.range.end.y}var qse=class extends Bse{constructor(e={}){super(e),this._linkifier=this._register(new Sh),this.browser=r6,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Sh),this._onCursorMove=this._register(new Te),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Te),this.onKey=this._onKey.event,this._onRender=this._register(new Te),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Te),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Te),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Te),this.onBell=this._onBell.event,this._onFocus=this._register(new Te),this._onBlur=this._register(new Te),this._onA11yCharEmitter=this._register(new Te),this._onA11yTabEmitter=this._register(new Te),this._onWillOpen=this._register(new Te),this._setup(),this._decorationService=this._instantiationService.createInstance(zse),this._instantiationService.setService(rp,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Rne),this._instantiationService.setService($D,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(jb)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(i=>this.refresh(i?.start??0,i?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(i=>this._reportWindowsOptions(i))),this._register(this._inputHandler.onColor(i=>this._handleColorEvent(i))),this._register(zn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(zn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(zn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(zn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(i=>this._afterResize(i.cols,i.rows))),this._register(Ai(()=>{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 i of e){let n,s="";switch(i.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+i.index}switch(i.type){case 0:let r=Si.toColorRGB(n==="ansi"?this._themeService.colors.ansi[i.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${we.ESC}]${s};${Lse(r)}${n6.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(o=>o.ansi[i.index]=rn.toColor(...i.color));else{let o=n;this._themeService.modifyColors(a=>a[o]=rn.toColor(...i.color))}break;case 2:this._themeService.restoreColor(i.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(F0,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(we.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(we.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,i=this.buffer.lines.get(e);if(!i)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=i.getWidth(n),o=this._renderService.dimensions.css.cell.width*r,a=this.buffer.y*this._renderService.dimensions.css.cell.height,u=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=u+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(lt(this.element,"copy",i=>{this.hasSelection()&&Yte(i,this._selectionService)}));let e=i=>Gte(i,this.textarea,this.coreService,this.optionsService);this._register(lt(this.textarea,"paste",e)),this._register(lt(this.element,"paste",e)),o6?this._register(lt(this.element,"mousedown",i=>{i.button===2&&pL(i,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(lt(this.element,"contextmenu",i=>{pL(i,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),JS&&this._register(lt(this.element,"auxclick",i=>{i.button===1&&ND(i,this.textarea,this.screenElement)}))}_bindKeys(){this._register(lt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(lt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(lt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(lt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(lt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(lt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(lt(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 i=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),i.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(lt(this.screenElement,"mousemove",r=>this.updateCursorStyle(r))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),i.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Lb.get()),c6||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",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Nne,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(El,this._coreBrowserService),this._register(lt(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(lt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Jb,this._document,this._helperContainer),this._instantiationService.setService(vv,this._charSizeService),this._themeService=this._instantiationService.createInstance(nw),this._instantiationService.setService(Nh,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(P0),this._instantiationService.setService(zD,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(tw,this.rows,this.screenElement)),this._instantiationService.setService(Ml,this._renderService),this._register(this._renderService.onRenderedViewportChange(r=>this._onRender.fire(r))),this.onResize(r=>this._renderService.resize(r.cols,r.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Qb,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(ew),this._instantiationService.setService(US,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(hw,this.screenElement));this.element.appendChild(i);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(Yb,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(r=>{super.scrollLines(r,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(iw,this.element,this.screenElement,s)),this._instantiationService.setService(nie,this._selectionService),this._register(this._selectionService.onRequestScrollLines(r=>this.scrollLines(r.amount,r.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(r=>this._renderService.handleSelectionChanged(r.start,r.end,r.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(r=>{this.textarea.value=r,this.textarea.focus(),this.textarea.select()})),this._register(zn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Gb,this.screenElement)),this._register(lt(this.element,"mousedown",r=>this._selectionService.handleMouseDown(r))),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(F0,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(I0,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(I0,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Zb,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,i=this.element;function n(o){let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let u,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(u=3,o.button!==void 0&&(u=o.button<3?o.button:3)):u=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,u=o.button<3?o.button:3;break;case"mousedown":h=1,u=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let p=o.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;h=p<0?0:1,u=4;break;default:return!1}return h===void 0||u===void 0||u>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:u,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:o=>(n(o),o.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(o)),wheel:o=>(n(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&n(o)},mousemove:o=>{o.buttons||n(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),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()),o&8?s.mousemove||(i.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(i.removeEventListener("mousemove",s.mousemove),s.mousemove=null),o&16?s.wheel||(i.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(i.removeEventListener("wheel",s.wheel),s.wheel=null),o&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),o&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(lt(i,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return n(o),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(o)})),this._register(lt(i,"wheel",o=>{if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(o,!0);let a=we.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(a,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,i){this._renderService?.refreshRows(e,i)}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,i){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,i),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 i=e-this._bufferService.buffer.ydisp;i!==0&&this.scrollLines(i)}paste(e){TD(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 i=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),i}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,i,n){this._selectionService.setSelection(e,i,n)}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,i){this._selectionService?.selectLines(e,i)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let i=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!i&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!i&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=Ise(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.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((n.key===we.ETX||n.key===we.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,i){let n=e.isMac&&!this.options.macOptionIsMeta&&i.altKey&&!i.ctrlKey&&!i.metaKey||e.isWindows&&i.altKey&&i.ctrlKey&&!i.metaKey||e.isWindows&&i.getModifierState("AltGraph");return i.type==="keypress"?n:n&&(!i.keyCode||i.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Use(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let i;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)i=e.charCode;else if(e.which===null||e.which===void 0)i=e.keyCode;else if(e.which!==0&&e.charCode!==0)i=e.which;else return!1;return!i||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(i=String.fromCharCode(i),this._onKey.fire({key:i,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i,!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 i=e.data;return this.coreService.triggerDataEvent(i,!0),this.cancel(e),!0}return!1}resize(e,i){if(e===this.cols&&i===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,i)}_afterResize(e,i){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(tn));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(we.ESC+"[I"):this.coreService.triggerDataEvent(we.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let i=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${we.ESC}[4;${n};${i}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${we.ESC}[6;${r};${s}t`);break}}cancel(e,i){if(!(!this.options.cancelEvents&&!i))return e.preventDefault(),e.stopPropagation(),!1}};function Use(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var Vse=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,i){let n={instance:i,dispose:i.dispose,isDisposed:!1};this._addons.push(n),i.dispose=()=>this._wrappedAddonDispose(n),i.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let i=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){i=n;break}if(i===-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(i,1)}},Kse=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,i){if(!(e<0||e>=this._line.length))return i?(this._line.loadCell(e,i),i):this._line.loadCell(e,new Ir)}translateToString(e,i,n){return this._line.translateToString(e,i,n)}},rT=class{constructor(t,e){this._buffer=t,this.type=e}init(t){return this._buffer=t,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(t){let e=this._buffer.lines.get(t);if(e)return new Kse(e)}getNullCell(){return new Ir}},Yse=class extends yt{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new Te),this.onBufferChange=this._onBufferChange.event,this._normal=new rT(this._core.buffers.normal,"normal"),this._alternate=new rT(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)}},Gse=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,i=>e(i.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(i,n)=>e(i,n.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}},Qse=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}},Xse=["cols","rows"],mo=0,Zse=class extends yt{constructor(t){super(),this._core=this._register(new qse(t)),this._addonManager=this._register(new Vse),this._publicOptions={...this._core.options};let e=n=>this._core.options[n],i=(n,s)=>{this._checkReadonlyOptions(n),this._core.options[n]=s};for(let n in this._core.options){let s={get:e.bind(this,n),set:i.bind(this,n)};Object.defineProperty(this._publicOptions,n,s)}}_checkReadonlyOptions(t){if(Xse.includes(t))throw new Error(`Option "${t}" 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 Gse(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Qse(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 Yse(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,i){this._verifyIntegers(t,e,i),this._core.select(t,e,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
|
|
213
|
+
`,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return Lb.get()},set promptLabel(t){Lb.set(t)},get tooMuchOutput(){return Tb.get()},set tooMuchOutput(t){Tb.set(t)}}}_verifyIntegers(...t){for(mo of t)if(mo===1/0||isNaN(mo)||mo%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(mo of t)if(mo&&(mo===1/0||isNaN(mo)||mo%1!==0||mo<0))throw new Error("This API only accepts positive integers")}};var Jse=2,ere=1,tre=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,i=window.getComputedStyle(this._terminal.element.parentElement),n=parseInt(i.getPropertyValue("height")),s=Math.max(0,parseInt(i.getPropertyValue("width"))),r=window.getComputedStyle(this._terminal.element),o={top:parseInt(r.getPropertyValue("padding-top")),bottom:parseInt(r.getPropertyValue("padding-bottom")),right:parseInt(r.getPropertyValue("padding-right")),left:parseInt(r.getPropertyValue("padding-left"))},a=o.top+o.bottom,u=o.right+o.left,h=n-a,p=s-u-e;return{cols:Math.max(Jse,Math.floor(p/t.css.cell.width)),rows:Math.max(ere,Math.floor(h/t.css.cell.height))}}};var ire=(t,e,i,n)=>{for(var s=e,r=t.length-1,o;r>=0;r--)(o=t[r])&&(s=o(s)||s);return s},nre=(t,e)=>(i,n)=>e(i,n,t),sre=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?oT.isErrorNoTelemetry(t)?new oT(t.message+`
|
|
214
|
+
|
|
215
|
+
`+t.stack):new Error(t.message+`
|
|
216
|
+
|
|
217
|
+
`+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},rre=new sre;function Oy(t){ore(t)||rre.onUnexpectedError(t)}var dw="Canceled";function ore(t){return t instanceof lre?!0:t instanceof Error&&t.name===dw&&t.message===dw}var lre=class extends Error{constructor(){super(dw),this.name=this.message}},oT=class fw extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof fw)return e;let i=new fw;return i.message=e.message,i.stack=e.stack,i}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},are;(t=>{function e(r){return r<0}t.isLessThan=e;function i(r){return r<=0}t.isLessThanOrEqual=i;function n(r){return r>0}t.isGreaterThan=n;function s(r){return r===0}t.isNeitherLessOrGreaterThan=s,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(are||={});function cre(t,e){let i=this,n=!1,s;return function(){return n||(n=!0,e||(s=t.apply(i,arguments))),s}}var y6;(t=>{function e(N){return N&&typeof N=="object"&&typeof N[Symbol.iterator]=="function"}t.is=e;let i=Object.freeze([]);function n(){return i}t.empty=n;function*s(N){yield N}t.single=s;function r(N){return e(N)?N:s(N)}t.wrap=r;function o(N){return N||i}t.from=o;function*a(N){for(let j=N.length-1;j>=0;j--)yield N[j]}t.reverse=a;function u(N){return!N||N[Symbol.iterator]().next().done===!0}t.isEmpty=u;function h(N){return N[Symbol.iterator]().next().value}t.first=h;function p(N,j){let R=0;for(let z of N)if(j(z,R++))return!0;return!1}t.some=p;function m(N,j){for(let R of N)if(j(R))return R}t.find=m;function*v(N,j){for(let R of N)j(R)&&(yield R)}t.filter=v;function*_(N,j){let R=0;for(let z of N)yield j(z,R++)}t.map=_;function*x(N,j){let R=0;for(let z of N)yield*j(z,R++)}t.flatMap=x;function*S(...N){for(let j of N)yield*j}t.concat=S;function C(N,j,R){let z=R;for(let J of N)z=j(z,J);return z}t.reduce=C;function*k(N,j,R=N.length){for(j<0&&(j+=N.length),R<0?R+=N.length:R>N.length&&(R=N.length);j<R;j++)yield N[j]}t.slice=k;function M(N,j=Number.POSITIVE_INFINITY){let R=[];if(j===0)return[R,N];let z=N[Symbol.iterator]();for(let J=0;J<j;J++){let G=z.next();if(G.done)return[R,t.empty()];R.push(G.value)}return[R,{[Symbol.iterator](){return z}}]}t.consume=M;async function L(N){let j=[];for await(let R of N)j.push(R);return Promise.resolve(j)}t.asyncToArray=L})(y6||={});function x6(t){if(y6.is(t)){let e=[];for(let i of t)if(i)try{i.dispose()}catch(n){e.push(n)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function b6(...t){return Gn(()=>x6(t))}function Gn(t){return{dispose:cre(()=>{t()})}}var w6=class S6{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{x6(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?S6.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(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};w6.DISABLE_DISPOSED_WARNING=!1;var uh=w6,Zr=class{constructor(){this._store=new uh,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Zr.None=Object.freeze({dispose(){}});var Jd=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},ek=typeof process<"u"&&"title"in process,xv=ek?"node":navigator.userAgent,ure=ek?"node":navigator.platform,hre=xv.includes("Firefox"),dre=xv.includes("Edge"),k6=/^((?!chrome|android).)*safari/i.test(xv);function fre(){if(!k6)return 0;let t=xv.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}ure.indexOf("Linux")>=0;var pre="",Cn=0,En=0,Mn=0,Ii=0,Cr={css:"#00000000",rgba:0},as;(t=>{function e(s,r,o,a){return a!==void 0?`#${uc(s)}${uc(r)}${uc(o)}${uc(a)}`:`#${uc(s)}${uc(r)}${uc(o)}`}t.toCss=e;function i(s,r,o,a=255){return(s<<24|r<<16|o<<8|a)>>>0}t.toRgba=i;function n(s,r,o,a){return{css:t.toCss(s,r,o,a),rgba:t.toRgba(s,r,o,a)}}t.toColor=n})(as||={});var pf;(t=>{function e(u,h){if(Ii=(h.rgba&255)/255,Ii===1)return{css:h.css,rgba:h.rgba};let p=h.rgba>>24&255,m=h.rgba>>16&255,v=h.rgba>>8&255,_=u.rgba>>24&255,x=u.rgba>>16&255,S=u.rgba>>8&255;Cn=_+Math.round((p-_)*Ii),En=x+Math.round((m-x)*Ii),Mn=S+Math.round((v-S)*Ii);let C=as.toCss(Cn,En,Mn),k=as.toRgba(Cn,En,Mn);return{css:C,rgba:k}}t.blend=e;function i(u){return(u.rgba&255)===255}t.isOpaque=i;function n(u,h,p){let m=Ec.ensureContrastRatio(u.rgba,h.rgba,p);if(m)return as.toColor(m>>24&255,m>>16&255,m>>8&255)}t.ensureContrastRatio=n;function s(u){let h=(u.rgba|255)>>>0;return[Cn,En,Mn]=Ec.toChannels(h),{css:as.toCss(Cn,En,Mn),rgba:h}}t.opaque=s;function r(u,h){return Ii=Math.round(h*255),[Cn,En,Mn]=Ec.toChannels(u.rgba),{css:as.toCss(Cn,En,Mn,Ii),rgba:as.toRgba(Cn,En,Mn,Ii)}}t.opacity=r;function o(u,h){return Ii=u.rgba&255,r(u,Ii*h/255)}t.multiplyOpacity=o;function a(u){return[u.rgba>>24&255,u.rgba>>16&255,u.rgba>>8&255]}t.toColorRGB=a})(pf||={});var mre;(t=>{let e,i;try{let s=document.createElement("canvas");s.width=1,s.height=1;let r=s.getContext("2d",{willReadFrequently:!0});r&&(e=r,e.globalCompositeOperation="copy",i=e.createLinearGradient(0,0,1,1))}catch{}function n(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return Cn=parseInt(s.slice(1,2).repeat(2),16),En=parseInt(s.slice(2,3).repeat(2),16),Mn=parseInt(s.slice(3,4).repeat(2),16),as.toColor(Cn,En,Mn);case 5:return Cn=parseInt(s.slice(1,2).repeat(2),16),En=parseInt(s.slice(2,3).repeat(2),16),Mn=parseInt(s.slice(3,4).repeat(2),16),Ii=parseInt(s.slice(4,5).repeat(2),16),as.toColor(Cn,En,Mn,Ii);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let r=s.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 Cn=parseInt(r[1]),En=parseInt(r[2]),Mn=parseInt(r[3]),Ii=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),as.toColor(Cn,En,Mn,Ii);if(!e||!i)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=i,e.fillStyle=s,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[Cn,En,Mn,Ii]=e.getImageData(0,0,1,1).data,Ii!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:as.toRgba(Cn,En,Mn,Ii),css:s}}t.toColor=n})(mre||={});var os;(t=>{function e(n){return i(n>>16&255,n>>8&255,n&255)}t.relativeLuminance=e;function i(n,s,r){let o=n/255,a=s/255,u=r/255,h=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),p=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),m=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4);return h*.2126+p*.7152+m*.0722}t.relativeLuminance2=i})(os||={});var Ec;(t=>{function e(o,a){if(Ii=(a&255)/255,Ii===1)return a;let u=a>>24&255,h=a>>16&255,p=a>>8&255,m=o>>24&255,v=o>>16&255,_=o>>8&255;return Cn=m+Math.round((u-m)*Ii),En=v+Math.round((h-v)*Ii),Mn=_+Math.round((p-_)*Ii),as.toRgba(Cn,En,Mn)}t.blend=e;function i(o,a,u){let h=os.relativeLuminance(o>>8),p=os.relativeLuminance(a>>8);if(ul(h,p)<u){if(p<h){let _=n(o,a,u),x=ul(h,os.relativeLuminance(_>>8));if(x<u){let S=s(o,a,u),C=ul(h,os.relativeLuminance(S>>8));return x>C?_:S}return _}let m=s(o,a,u),v=ul(h,os.relativeLuminance(m>>8));if(v<u){let _=n(o,a,u),x=ul(h,os.relativeLuminance(_>>8));return v>x?m:_}return m}}t.ensureContrastRatio=i;function n(o,a,u){let h=o>>24&255,p=o>>16&255,m=o>>8&255,v=a>>24&255,_=a>>16&255,x=a>>8&255,S=ul(os.relativeLuminance2(v,_,x),os.relativeLuminance2(h,p,m));for(;S<u&&(v>0||_>0||x>0);)v-=Math.max(0,Math.ceil(v*.1)),_-=Math.max(0,Math.ceil(_*.1)),x-=Math.max(0,Math.ceil(x*.1)),S=ul(os.relativeLuminance2(v,_,x),os.relativeLuminance2(h,p,m));return(v<<24|_<<16|x<<8|255)>>>0}t.reduceLuminance=n;function s(o,a,u){let h=o>>24&255,p=o>>16&255,m=o>>8&255,v=a>>24&255,_=a>>16&255,x=a>>8&255,S=ul(os.relativeLuminance2(v,_,x),os.relativeLuminance2(h,p,m));for(;S<u&&(v<255||_<255||x<255);)v=Math.min(255,v+Math.ceil((255-v)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),S=ul(os.relativeLuminance2(v,_,x),os.relativeLuminance2(h,p,m));return(v<<24|_<<16|x<<8|255)>>>0}t.increaseLuminance=s;function r(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}t.toChannels=r})(Ec||={});function uc(t){let e=t.toString(16);return e.length<2?"0"+e:e}function ul(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}function sn(t){if(!t)throw new Error("value must not be falsy");return t}function tk(t){return 57508<=t&&t<=57558}function gre(t){return 57520<=t&&t<=57527}function vre(t){return 57344<=t&&t<=63743}function _re(t){return 9472<=t&&t<=9631}function yre(t){return t>=128512&&t<=128591||t>=127744&&t<=128511||t>=128640&&t<=128767||t>=9728&&t<=9983||t>=9984&&t<=10175||t>=65024&&t<=65039||t>=129280&&t<=129535||t>=127462&&t<=127487}function xre(t,e,i,n){return e===1&&i>Math.ceil(n*1.5)&&t!==void 0&&t>255&&!yre(t)&&!tk(t)&&!vre(t)}function C6(t){return tk(t)||_re(t)}function bre(){return{css:{canvas:gg(),cell:gg()},device:{canvas:gg(),cell:gg(),char:{width:0,height:0,left:0,top:0}}}}function gg(){return{width:0,height:0}}function wre(t,e,i=0){return(t-(Math.round(e)*2-i))%(Math.round(e)*2)}var On=0,yn=0,go=!1,hl=!1,vg=!1,Ls,Iy=0,Sre=class{constructor(t,e,i,n,s,r){this._terminal=t,this._optionService=e,this._selectionRenderModel=i,this._decorationService=n,this._coreBrowserService=s,this._themeService=r,this.result={fg:0,bg:0,ext:0}}resolve(t,e,i,n){if(this.result.bg=t.bg,this.result.fg=t.fg,this.result.ext=t.bg&268435456?t.extended.ext:0,yn=0,On=0,hl=!1,go=!1,vg=!1,Ls=this._themeService.colors,Iy=0,t.getCode()!==0&&t.extended.underlineStyle===4){let s=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));Iy=e*n%(Math.round(s)*2)}if(this._decorationService.forEachDecorationAtCell(e,i,"bottom",s=>{s.backgroundColorRGB&&(yn=s.backgroundColorRGB.rgba>>8&16777215,hl=!0),s.foregroundColorRGB&&(On=s.foregroundColorRGB.rgba>>8&16777215,go=!0)}),vg=this._selectionRenderModel.isCellSelected(this._terminal,e,i),vg){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:yn=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:yn=(this.result.fg&16777215)<<8|255;break;default:yn=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:yn=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:yn=(this.result.bg&16777215)<<8|255;break}yn=Ec.blend(yn,(this._coreBrowserService.isFocused?Ls.selectionBackgroundOpaque:Ls.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else yn=(this._coreBrowserService.isFocused?Ls.selectionBackgroundOpaque:Ls.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(hl=!0,Ls.selectionForeground&&(On=Ls.selectionForeground.rgba>>8&16777215,go=!0),C6(t.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)On=(this._coreBrowserService.isFocused?Ls.selectionBackgroundOpaque:Ls.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:On=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:On=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:On=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:On=(this.result.fg&16777215)<<8|255;break;default:On=this._themeService.colors.foreground.rgba}On=Ec.blend(On,(this._coreBrowserService.isFocused?Ls.selectionBackgroundOpaque:Ls.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}go=!0}}this._decorationService.forEachDecorationAtCell(e,i,"top",s=>{s.backgroundColorRGB&&(yn=s.backgroundColorRGB.rgba>>8&16777215,hl=!0),s.foregroundColorRGB&&(On=s.foregroundColorRGB.rgba>>8&16777215,go=!0)}),hl&&(vg?yn=t.bg&-16777216&-134217729|yn|50331648:yn=t.bg&-16777216|yn|50331648),go&&(On=t.fg&-16777216&-67108865|On|50331648),this.result.fg&67108864&&(hl&&!go&&((this.result.bg&50331648)===0?On=this.result.fg&-134217728|Ls.background.rgba>>8&16777215&16777215|50331648:On=this.result.fg&-134217728|this.result.bg&67108863,go=!0),!hl&&go&&((this.result.fg&50331648)===0?yn=this.result.bg&-67108864|Ls.foreground.rgba>>8&16777215&16777215|50331648:yn=this.result.bg&-67108864|this.result.fg&67108863,hl=!0)),Ls=void 0,this.result.bg=hl?yn:this.result.bg,this.result.fg=go?On:this.result.fg,this.result.ext&=536870911,this.result.ext|=Iy<<29&3758096384}},kre=.5,E6=hre||dre?"bottom":"ideographic",Cre={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},Ere={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},Mre={"─":{1:"M0,.5 L1,.5"},"━":{3:"M0,.5 L1,.5"},"│":{1:"M.5,0 L.5,1"},"┃":{3:"M.5,0 L.5,1"},"┌":{1:"M0.5,1 L.5,.5 L1,.5"},"┏":{3:"M0.5,1 L.5,.5 L1,.5"},"┐":{1:"M0,.5 L.5,.5 L.5,1"},"┓":{3:"M0,.5 L.5,.5 L.5,1"},"└":{1:"M.5,0 L.5,.5 L1,.5"},"┗":{3:"M.5,0 L.5,.5 L1,.5"},"┘":{1:"M.5,0 L.5,.5 L0,.5"},"┛":{3:"M.5,0 L.5,.5 L0,.5"},"├":{1:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┣":{3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┤":{1:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┫":{3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┬":{1:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┳":{3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┴":{1:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┻":{3:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┼":{1:"M0,.5 L1,.5 M.5,0 L.5,1"},"╋":{3:"M0,.5 L1,.5 M.5,0 L.5,1"},"╴":{1:"M.5,.5 L0,.5"},"╸":{3:"M.5,.5 L0,.5"},"╵":{1:"M.5,.5 L.5,0"},"╹":{3:"M.5,.5 L.5,0"},"╶":{1:"M.5,.5 L1,.5"},"╺":{3:"M.5,.5 L1,.5"},"╷":{1:"M.5,.5 L.5,1"},"╻":{3:"M.5,.5 L.5,1"},"═":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"║":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╒":{1:(t,e)=>`M.5,1 L.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╓":{1:(t,e)=>`M${.5-t},1 L${.5-t},.5 L1,.5 M${.5+t},.5 L${.5+t},1`},"╔":{1:(t,e)=>`M1,${.5-e} L${.5-t},${.5-e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1`},"╕":{1:(t,e)=>`M0,${.5-e} L.5,${.5-e} L.5,1 M0,${.5+e} L.5,${.5+e}`},"╖":{1:(t,e)=>`M${.5+t},1 L${.5+t},.5 L0,.5 M${.5-t},.5 L${.5-t},1`},"╗":{1:(t,e)=>`M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M0,${.5-e} L${.5+t},${.5-e} L${.5+t},1`},"╘":{1:(t,e)=>`M.5,0 L.5,${.5+e} L1,${.5+e} M.5,${.5-e} L1,${.5-e}`},"╙":{1:(t,e)=>`M1,.5 L${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╚":{1:(t,e)=>`M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0 M1,${.5+e} L${.5-t},${.5+e} L${.5-t},0`},"╛":{1:(t,e)=>`M0,${.5+e} L.5,${.5+e} L.5,0 M0,${.5-e} L.5,${.5-e}`},"╜":{1:(t,e)=>`M0,.5 L${.5+t},.5 L${.5+t},0 M${.5-t},.5 L${.5-t},0`},"╝":{1:(t,e)=>`M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M0,${.5+e} L${.5+t},${.5+e} L${.5+t},0`},"╞":{1:(t,e)=>`M.5,0 L.5,1 M.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╟":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1 M${.5+t},.5 L1,.5`},"╠":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╡":{1:(t,e)=>`M.5,0 L.5,1 M0,${.5-e} L.5,${.5-e} M0,${.5+e} L.5,${.5+e}`},"╢":{1:(t,e)=>`M0,.5 L${.5-t},.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╣":{1:(t,e)=>`M${.5+t},0 L${.5+t},1 M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0`},"╤":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e} M.5,${.5+e} L.5,1`},"╥":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},1 M${.5+t},.5 L${.5+t},1`},"╦":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1`},"╧":{1:(t,e)=>`M.5,0 L.5,${.5-e} M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╨":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╩":{1:(t,e)=>`M0,${.5+e} L1,${.5+e} M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╪":{1:(t,e)=>`M.5,0 L.5,1 M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╫":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╬":{1:(t,e)=>`M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1 M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╱":{1:"M1,0 L0,1"},"╲":{1:"M0,0 L1,1"},"╳":{1:"M1,0 L0,1 M0,0 L1,1"},"╼":{1:"M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"╽":{1:"M.5,.5 L.5,0",3:"M.5,.5 L.5,1"},"╾":{1:"M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"╿":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┍":{1:"M.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┎":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┑":{1:"M.5,.5 L.5,1",3:"M.5,.5 L0,.5"},"┒":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┕":{1:"M.5,.5 L.5,0",3:"M.5,.5 L1,.5"},"┖":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┙":{1:"M.5,.5 L.5,0",3:"M.5,.5 L0,.5"},"┚":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,0"},"┝":{1:"M.5,0 L.5,1",3:"M.5,.5 L1,.5"},"┞":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┟":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┠":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1"},"┡":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"┢":{1:"M.5,.5 L.5,0",3:"M0.5,1 L.5,.5 L1,.5"},"┥":{1:"M.5,0 L.5,1",3:"M.5,.5 L0,.5"},"┦":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┧":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┨":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1"},"┩":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L0,.5"},"┪":{1:"M.5,.5 L.5,0",3:"M0,.5 L.5,.5 L.5,1"},"┭":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┮":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┯":{1:"M.5,.5 L.5,1",3:"M0,.5 L1,.5"},"┰":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"┱":{1:"M.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"┲":{1:"M.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"┵":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┶":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┷":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5"},"┸":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,0"},"┹":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"┺":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,.5 L1,.5"},"┽":{1:"M.5,0 L.5,1 M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┾":{1:"M.5,0 L.5,1 M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┿":{1:"M.5,0 L.5,1",3:"M0,.5 L1,.5"},"╀":{1:"M0,.5 L1,.5 M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"╁":{1:"M.5,.5 L.5,0 M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"╂":{1:"M0,.5 L1,.5",3:"M.5,0 L.5,1"},"╃":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"╄":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"╅":{1:"M.5,0 L.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"╆":{1:"M.5,0 L.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"╇":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0 M0,.5 L1,.5"},"╈":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"╉":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"╊":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"╌":{1:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"╍":{3:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"┄":{1:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┅":{3:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┈":{1:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"┉":{3:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"╎":{1:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"╏":{3:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"┆":{1:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┇":{3:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┊":{1:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"┋":{3:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"╭":{1:(t,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,1,.5`},"╮":{1:(t,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,0,.5`},"╯":{1:(t,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,0,.5`},"╰":{1:(t,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,1,.5`}},Wf={"":{d:"M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655",type:0},"":{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0},"":{d:"M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82",type:0},"":{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2},"":{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2},"":{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1},"":{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1},"":{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1},"":{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0},"":{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}};Wf[""]=Wf[""];Wf[""]=Wf[""];function Are(t,e,i,n,s,r,o,a){let u=Cre[e];if(u)return Lre(t,u,i,n,s,r),!0;let h=Ere[e];if(h)return Tre(t,h,i,n,s,r),!0;let p=Mre[e];if(p)return Nre(t,p,i,n,s,r,a),!0;let m=Wf[e];return m?(jre(t,m,i,n,s,r,o,a),!0):!1}function Lre(t,e,i,n,s,r){for(let o=0;o<e.length;o++){let a=e[o],u=s/8,h=r/8;t.fillRect(i+a.x*u,n+a.y*h,a.w*u,a.h*h)}}var lT=new Map;function Tre(t,e,i,n,s,r){let o=lT.get(e);o||(o=new Map,lT.set(e,o));let a=t.fillStyle;if(typeof a!="string")throw new Error(`Unexpected fillStyle type "${a}"`);let u=o.get(a);if(!u){let h=e[0].length,p=e.length,m=t.canvas.ownerDocument.createElement("canvas");m.width=h,m.height=p;let v=sn(m.getContext("2d")),_=new ImageData(h,p),x,S,C,k;if(a.startsWith("#"))x=parseInt(a.slice(1,3),16),S=parseInt(a.slice(3,5),16),C=parseInt(a.slice(5,7),16),k=a.length>7&&parseInt(a.slice(7,9),16)||1;else if(a.startsWith("rgba"))[x,S,C,k]=a.substring(5,a.length-1).split(",").map(M=>parseFloat(M));else throw new Error(`Unexpected fillStyle color format "${a}" when drawing pattern glyph`);for(let M=0;M<p;M++)for(let L=0;L<h;L++)_.data[(M*h+L)*4]=x,_.data[(M*h+L)*4+1]=S,_.data[(M*h+L)*4+2]=C,_.data[(M*h+L)*4+3]=e[M][L]*(k*255);v.putImageData(_,0,0),u=sn(t.createPattern(m,null)),o.set(a,u)}t.fillStyle=u,t.fillRect(i,n,s,r)}function Nre(t,e,i,n,s,r,o){t.strokeStyle=t.fillStyle;for(let[a,u]of Object.entries(e)){t.beginPath(),t.lineWidth=o*Number.parseInt(a);let h;if(typeof u=="function"){let p=.15/r*s;h=u(.15,p)}else h=u;for(let p of h.split(" ")){let m=p[0],v=M6[m];if(!v){console.error(`Could not find drawing instructions for "${m}"`);continue}let _=p.substring(1).split(",");!_[0]||!_[1]||v(t,A6(_,s,r,i,n,!0,o))}t.stroke(),t.closePath()}}function jre(t,e,i,n,s,r,o,a){let u=new Path2D;u.rect(i,n,s,r),t.clip(u),t.beginPath();let h=o/12;t.lineWidth=a*h;for(let p of e.d.split(" ")){let m=p[0],v=M6[m];if(!v){console.error(`Could not find drawing instructions for "${m}"`);continue}let _=p.substring(1).split(",");!_[0]||!_[1]||v(t,A6(_,s,r,i,n,!1,a,(e.leftPadding??0)*(h/2),(e.rightPadding??0)*(h/2)))}e.type===1?(t.strokeStyle=t.fillStyle,t.stroke()):t.fill(),t.closePath()}function aT(t,e,i=0){return Math.max(Math.min(t,e),i)}var M6={C:(t,e)=>t.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]),L:(t,e)=>t.lineTo(e[0],e[1]),M:(t,e)=>t.moveTo(e[0],e[1])};function A6(t,e,i,n,s,r,o,a=0,u=0){let h=t.map(p=>parseFloat(p)||parseInt(p));if(h.length<2)throw new Error("Too few arguments for instruction");for(let p=0;p<h.length;p+=2)h[p]*=e-a*o-u*o,r&&h[p]!==0&&(h[p]=aT(Math.round(h[p]+.5)-.5,e,0)),h[p]+=n+a*o;for(let p=1;p<h.length;p+=2)h[p]*=i,r&&h[p]!==0&&(h[p]=aT(Math.round(h[p]+.5)-.5,i,0)),h[p]+=s;return h}var cT=class{constructor(){this._data={}}set(t,e,i){this._data[t]||(this._data[t]={}),this._data[t][e]=i}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},uT=class{constructor(){this._data=new cT}set(t,e,i,n,s){this._data.get(t,e)||this._data.set(t,e,new cT),this._data.get(t,e).set(i,n,s)}get(t,e,i,n){return this._data.get(t,e)?.get(i,n)}clear(){this._data.clear()}},L6=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),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(t){this._idleCallback=void 0;let e=0,i=0,n=t.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),i=Math.max(e,i),s=t.timeRemaining(),i*1.5>s){n-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-e))}ms`),this._start();return}n=s}this.clear()}},Rre=class extends L6{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},Dre=class extends L6{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Bre=!ek&&"requestIdleCallback"in window?Dre:Rre,Ju=class T6{constructor(){this.fg=0,this.bg=0,this.extended=new N6}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new T6;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}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}},N6=class j6{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new j6(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ore=globalThis.performance&&typeof globalThis.performance.now=="function",Ire=class R6{static create(e){return new R6(e)}constructor(e){this._now=Ore&&e===!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}},xl;(t=>{t.None=()=>Zr.None;function e(I,T){return m(I,()=>{},0,void 0,!0,void 0,T)}t.defer=e;function i(I){return(T,H=null,F)=>{let P=!1,U;return U=I(V=>{if(!P)return U?U.dispose():P=!0,T.call(H,V)},null,F),P&&U.dispose(),U}}t.once=i;function n(I,T,H){return h((F,P=null,U)=>I(V=>F.call(P,T(V)),null,U),H)}t.map=n;function s(I,T,H){return h((F,P=null,U)=>I(V=>{T(V),F.call(P,V)},null,U),H)}t.forEach=s;function r(I,T,H){return h((F,P=null,U)=>I(V=>T(V)&&F.call(P,V),null,U),H)}t.filter=r;function o(I){return I}t.signal=o;function a(...I){return(T,H=null,F)=>{let P=b6(...I.map(U=>U(V=>T.call(H,V))));return p(P,F)}}t.any=a;function u(I,T,H,F){let P=H;return n(I,U=>(P=T(P,U),P),F)}t.reduce=u;function h(I,T){let H,F={onWillAddFirstListener(){H=I(P.fire,P)},onDidRemoveLastListener(){H?.dispose()}},P=new ki(F);return T?.add(P),P.event}function p(I,T){return T instanceof Array?T.push(I):T&&T.add(I),I}function m(I,T,H=100,F=!1,P=!1,U,V){let K,D,$,Y=0,B,ee={leakWarningThreshold:U,onWillAddFirstListener(){K=I(re=>{Y++,D=T(D,re),F&&!$&&(ie.fire(D),D=void 0),B=()=>{let ge=D;D=void 0,$=void 0,(!F||Y>1)&&ie.fire(ge),Y=0},typeof H=="number"?(clearTimeout($),$=setTimeout(B,H)):$===void 0&&($=0,queueMicrotask(B))})},onWillRemoveListener(){P&&Y>0&&B?.()},onDidRemoveLastListener(){B=void 0,K.dispose()}},ie=new ki(ee);return V?.add(ie),ie.event}t.debounce=m;function v(I,T=0,H){return t.debounce(I,(F,P)=>F?(F.push(P),F):[P],T,void 0,!0,void 0,H)}t.accumulate=v;function _(I,T=(F,P)=>F===P,H){let F=!0,P;return r(I,U=>{let V=F||!T(U,P);return F=!1,P=U,V},H)}t.latch=_;function x(I,T,H){return[t.filter(I,T,H),t.filter(I,F=>!T(F),H)]}t.split=x;function S(I,T=!1,H=[],F){let P=H.slice(),U=I(D=>{P?P.push(D):K.fire(D)});F&&F.add(U);let V=()=>{P?.forEach(D=>K.fire(D)),P=null},K=new ki({onWillAddFirstListener(){U||(U=I(D=>K.fire(D)),F&&F.add(U))},onDidAddFirstListener(){P&&(T?setTimeout(V):V())},onDidRemoveLastListener(){U&&U.dispose(),U=null}});return F&&F.add(K),K.event}t.buffer=S;function C(I,T){return(H,F,P)=>{let U=T(new M);return I(function(V){let K=U.evaluate(V);K!==k&&H.call(F,K)},void 0,P)}}t.chain=C;let k=Symbol("HaltChainable");class M{constructor(){this.steps=[]}map(T){return this.steps.push(T),this}forEach(T){return this.steps.push(H=>(T(H),H)),this}filter(T){return this.steps.push(H=>T(H)?H:k),this}reduce(T,H){let F=H;return this.steps.push(P=>(F=T(F,P),F)),this}latch(T=(H,F)=>H===F){let H=!0,F;return this.steps.push(P=>{let U=H||!T(P,F);return H=!1,F=P,U?P:k}),this}evaluate(T){for(let H of this.steps)if(T=H(T),T===k)break;return T}}function L(I,T,H=F=>F){let F=(...K)=>V.fire(H(...K)),P=()=>I.on(T,F),U=()=>I.removeListener(T,F),V=new ki({onWillAddFirstListener:P,onDidRemoveLastListener:U});return V.event}t.fromNodeEventEmitter=L;function N(I,T,H=F=>F){let F=(...K)=>V.fire(H(...K)),P=()=>I.addEventListener(T,F),U=()=>I.removeEventListener(T,F),V=new ki({onWillAddFirstListener:P,onDidRemoveLastListener:U});return V.event}t.fromDOMEventEmitter=N;function j(I){return new Promise(T=>i(I)(T))}t.toPromise=j;function R(I){let T=new ki;return I.then(H=>{T.fire(H)},()=>{T.fire(void 0)}).finally(()=>{T.dispose()}),T.event}t.fromPromise=R;function z(I,T){return I(H=>T.fire(H))}t.forward=z;function J(I,T,H){return T(H),I(F=>T(F))}t.runAndSubscribe=J;class G{constructor(T,H){this._observable=T,this._counter=0,this._hasChanged=!1;let F={onWillAddFirstListener:()=>{T.addObserver(this)},onDidRemoveLastListener:()=>{T.removeObserver(this)}};this.emitter=new ki(F),H&&H.add(this.emitter)}beginUpdate(T){this._counter++}handlePossibleChange(T){}handleChange(T,H){this._hasChanged=!0}endUpdate(T){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function q(I,T){return new G(I,T).emitter.event}t.fromObservable=q;function X(I){return(T,H,F)=>{let P=0,U=!1,V={beginUpdate(){P++},endUpdate(){P--,P===0&&(I.reportChanges(),U&&(U=!1,T.call(H)))},handlePossibleChange(){},handleChange(){U=!0}};I.addObserver(V),I.reportChanges();let K={dispose(){I.removeObserver(V)}};return F instanceof uh?F.add(K):Array.isArray(F)&&F.push(K),K}}t.fromObservableLight=X})(xl||={});var pw=class mw{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${mw._idPool++}`,mw.all.add(this)}start(e){this._stopWatch=new Ire,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};pw.all=new Set,pw._idPool=0;var Pre=pw,zre=-1,D6=class B6{constructor(e,i,n=(B6._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=i,this.name=n,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,i){let n=this.threshold;if(n<=0||i<n)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=n*.5;let[r,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(r);let u=new Hre(a,r);this._errorHandler(u)}return()=>{let r=this._stacks.get(e.value)||0;this._stacks.set(e.value,r-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,i=0;for(let[n,s]of this._stacks)(!e||i<s)&&(e=[n,s],i=s);return e}};D6._idPool=1;var $re=D6,Fre=class O6{constructor(e){this.value=e}static create(){let e=new Error;return new O6(e.stack??"")}print(){console.warn(this.value.split(`
|
|
218
|
+
`).slice(2).join(`
|
|
219
|
+
`))}},Hre=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},Wre=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},qre=0,Py=class{constructor(t){this.value=t,this.id=qre++}},Ure=2,Vre,ki=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new $re(t?.onListenerError??Oy,this._options?.leakWarningThreshold??zre):void 0,this._perfMon=this._options?._profName?new Pre(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??=(t,e,i)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let o=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(o);let a=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],u=new Wre(`${o}. HINT: Stack shows most frequent listener (${a[1]}-times)`,a[0]);return(this._options?.onListenerError||Oy)(u),Zr.None}if(this._disposed)return Zr.None;e&&(t=t.bind(e));let n=new Py(t),s;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=Fre.create(),s=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof Py?(this._deliveryQueue??=new Kre,this._listeners=[this._listeners,n]):this._listeners.push(n):(this._options?.onWillAddFirstListener?.(this),this._listeners=n,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=Gn(()=>{s?.(),this._removeListener(n)});return i instanceof uh?i.add(r):Array.isArray(i)&&i.push(r),r},this._event}_removeListener(t){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 e=this._listeners,i=e.indexOf(t);if(i===-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--,e[i]=void 0;let n=this._deliveryQueue.current===this;if(this._size*Ure<=e.length){let s=0;for(let r=0;r<e.length;r++)e[r]?e[s++]=e[r]:n&&(this._deliveryQueue.end--,s<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=s}}_deliver(t,e){if(!t)return;let i=this._options?.onListenerError||Oy;if(!i){t.value(e);return}try{t.value(e)}catch(n){i(n)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Py)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},Kre=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,i){this.i=0,this.end=i,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},hT={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},ef=2,tf,ma=class Uu{constructor(e,i,n){this._document=e,this._config=i,this._unicodeService=n,this._didWarmUp=!1,this._cacheMap=new uT,this._cacheMapCombined=new uT,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new Ju,this._textureSize=512,this._onAddTextureAtlasCanvas=new ki,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new ki,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=I6(e,this._config.deviceCellWidth*4+ef*2,this._config.deviceCellHeight+ef*2),this._tmpCtx=sn(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let e=new Bre;for(let i=33;i<126;i++)e.enqueue(()=>{if(!this._cacheMap.get(i,0,0,0)){let n=this._drawToCache(i,0,0,0,!1,void 0);this._cacheMap.set(i,0,0,0,n)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(Uu.maxAtlasPages&&this._pages.length>=Math.max(4,Uu.maxAtlasPages)){let i=this._pages.filter(h=>h.canvas.width*2<=(Uu.maxTextureSize||4096)).sort((h,p)=>p.canvas.width!==h.canvas.width?p.canvas.width-h.canvas.width:p.percentageUsed-h.percentageUsed),n=-1,s=0;for(let h=0;h<i.length;h++)if(i[h].canvas.width!==s)n=h,s=i[h].canvas.width;else if(h-n===3)break;let r=i.slice(n,n+4),o=r.map(h=>h.glyphs[0].texturePage).sort((h,p)=>h>p?1:-1),a=this.pages.length-r.length,u=this._mergePages(r,a);u.version++;for(let h=o.length-1;h>=0;h--)this._deletePage(o[h]);this.pages.push(u),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(u.canvas)}let e=new zy(this._document,this._textureSize);return this._pages.push(e),this._activePages.push(e),this._onAddTextureAtlasCanvas.fire(e.canvas),e}_mergePages(e,i){let n=e[0].canvas.width*2,s=new zy(this._document,n,e);for(let[r,o]of e.entries()){let a=r*o.canvas.width%n,u=Math.floor(r/2)*o.canvas.height;s.ctx.drawImage(o.canvas,a,u);for(let p of o.glyphs)p.texturePage=i,p.sizeClipSpace.x=p.size.x/n,p.sizeClipSpace.y=p.size.y/n,p.texturePosition.x+=a,p.texturePosition.y+=u,p.texturePositionClipSpace.x=p.texturePosition.x/n,p.texturePositionClipSpace.y=p.texturePosition.y/n;this._onRemoveTextureAtlasCanvas.fire(o.canvas);let h=this._activePages.indexOf(o);h!==-1&&this._activePages.splice(h,1)}return s}_deletePage(e){this._pages.splice(e,1);for(let i=e;i<this._pages.length;i++){let n=this._pages[i];for(let s of n.glyphs)s.texturePage--;n.version++}}getRasterizedGlyphCombinedChar(e,i,n,s,r,o){return this._getFromCacheMap(this._cacheMapCombined,e,i,n,s,r,o)}getRasterizedGlyph(e,i,n,s,r,o){return this._getFromCacheMap(this._cacheMap,e,i,n,s,r,o)}_getFromCacheMap(e,i,n,s,r,o,a){return tf=e.get(i,n,s,r),tf||(tf=this._drawToCache(i,n,s,r,o,a),e.set(i,n,s,r,tf)),tf}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw new Error("No color found for idx "+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,i,n,s){if(this._config.allowTransparency)return Cr;let r;switch(e){case 16777216:case 33554432:r=this._getColorFromAnsiIndex(i);break;case 50331648:let o=Ju.toColorRGB(i);r=as.toColor(o[0],o[1],o[2]);break;default:n?r=pf.opaque(this._config.colors.foreground):r=this._config.colors.background;break}return this._config.allowTransparency||(r=pf.opaque(r)),r}_getForegroundColor(e,i,n,s,r,o,a,u,h,p){let m=this._getMinimumContrastColor(e,i,n,s,r,o,a,h,u,p);if(m)return m;let v;switch(r){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&h&&o<8&&(o+=8),v=this._getColorFromAnsiIndex(o);break;case 50331648:let _=Ju.toColorRGB(o);v=as.toColor(_[0],_[1],_[2]);break;default:a?v=this._config.colors.background:v=this._config.colors.foreground}return this._config.allowTransparency&&(v=pf.opaque(v)),u&&(v=pf.multiplyOpacity(v,kre)),v}_resolveBackgroundRgba(e,i,n){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(i).rgba;case 50331648:return i<<8;default:return n?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,i,n,s){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&s&&i<8&&(i+=8),this._getColorFromAnsiIndex(i).rgba;case 50331648:return i<<8;default:return n?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,i,n,s,r,o,a,u,h,p){if(this._config.minimumContrastRatio===1||p)return;let m=this._getContrastCache(h),v=m.getColor(e,s);if(v!==void 0)return v||void 0;let _=this._resolveBackgroundRgba(i,n,a),x=this._resolveForegroundRgba(r,o,a,u),S=Ec.ensureContrastRatio(_,x,this._config.minimumContrastRatio/(h?2:1));if(!S){m.setColor(e,s,null);return}let C=as.toColor(S>>24&255,S>>16&255,S>>8&255);return m.setColor(e,s,C),C}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(e,i,n,s,r,o){let a=typeof e=="number"?String.fromCharCode(e):e;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display="none",o.append(this._tmpCanvas));let u=Math.min(this._config.deviceCellWidth*Math.max(a.length,2)+ef*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<u&&(this._tmpCanvas.width=u);let h=Math.min(this._config.deviceCellHeight+ef*4,this._textureSize);if(this._tmpCanvas.height<h&&(this._tmpCanvas.height=h),this._tmpCtx.save(),this._workAttributeData.fg=n,this._workAttributeData.bg=i,this._workAttributeData.extended.ext=s,!!this._workAttributeData.isInvisible())return hT;let p=!!this._workAttributeData.isBold(),m=!!this._workAttributeData.isInverse(),v=!!this._workAttributeData.isDim(),_=!!this._workAttributeData.isItalic(),x=!!this._workAttributeData.isUnderline(),S=!!this._workAttributeData.isStrikethrough(),C=!!this._workAttributeData.isOverline(),k=this._workAttributeData.getFgColor(),M=this._workAttributeData.getFgColorMode(),L=this._workAttributeData.getBgColor(),N=this._workAttributeData.getBgColorMode();if(m){let D=k;k=L,L=D;let $=M;M=N,N=$}let j=this._getBackgroundColor(N,L,m,v);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=j.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let R=p?this._config.fontWeightBold:this._config.fontWeight,z=_?"italic":"";this._tmpCtx.font=`${z} ${R} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=E6;let J=a.length===1&&tk(a.charCodeAt(0)),G=a.length===1&&gre(a.charCodeAt(0)),q=this._getForegroundColor(i,N,L,n,M,k,m,v,p,C6(a.charCodeAt(0)));this._tmpCtx.fillStyle=q.css;let X=G?0:ef*2,I=!1;this._config.customGlyphs!==!1&&(I=Are(this._tmpCtx,a,X,X,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let T=!J,H;if(typeof e=="number"?H=this._unicodeService.wcwidth(e):H=this._unicodeService.getStringCellWidth(e),x){this._tmpCtx.save();let D=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),$=D%2===1?.5:0;if(this._tmpCtx.lineWidth=D,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())T=!1,this._tmpCtx.strokeStyle=`rgb(${Ju.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{T=!1;let ge=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&ge<8&&(ge+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(ge).css}this._tmpCtx.beginPath();let Y=X,B=Math.ceil(X+this._config.deviceCharHeight)-$-(r?D*2:0),ee=B+D,ie=B+D*2,re=this._workAttributeData.getUnderlineVariantOffset();for(let ge=0;ge<H;ge++){this._tmpCtx.save();let Ee=Y+ge*this._config.deviceCellWidth,fe=Y+(ge+1)*this._config.deviceCellWidth,Pe=Ee+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(Ee,B),this._tmpCtx.lineTo(fe,B),this._tmpCtx.moveTo(Ee,ie),this._tmpCtx.lineTo(fe,ie);break;case 3:let De=D<=1?ie:Math.ceil(X+this._config.deviceCharHeight-D/2)-$,He=D<=1?B:Math.ceil(X+this._config.deviceCharHeight+D/2)-$,_e=new Path2D;_e.rect(Ee,B,this._config.deviceCellWidth,ie-B),this._tmpCtx.clip(_e),this._tmpCtx.moveTo(Ee-this._config.deviceCellWidth/2,ee),this._tmpCtx.bezierCurveTo(Ee-this._config.deviceCellWidth/2,He,Ee,He,Ee,ee),this._tmpCtx.bezierCurveTo(Ee,De,Pe,De,Pe,ee),this._tmpCtx.bezierCurveTo(Pe,He,fe,He,fe,ee),this._tmpCtx.bezierCurveTo(fe,De,fe+this._config.deviceCellWidth/2,De,fe+this._config.deviceCellWidth/2,ee);break;case 4:let Le=re===0?0:re>=D?D*2-re:D-re;re>=D||Le===0?(this._tmpCtx.setLineDash([Math.round(D),Math.round(D)]),this._tmpCtx.moveTo(Ee+Le,B),this._tmpCtx.lineTo(fe,B)):(this._tmpCtx.setLineDash([Math.round(D),Math.round(D)]),this._tmpCtx.moveTo(Ee,B),this._tmpCtx.lineTo(Ee+Le,B),this._tmpCtx.moveTo(Ee+Le+D,B),this._tmpCtx.lineTo(fe,B)),re=wre(fe-Ee,D,re);break;case 5:let jt=.6,di=.3,xt=fe-Ee,be=Math.floor(jt*xt),We=Math.floor(di*xt),Ze=xt-be-We;this._tmpCtx.setLineDash([be,We,Ze]),this._tmpCtx.moveTo(Ee,B),this._tmpCtx.lineTo(fe,B);break;default:this._tmpCtx.moveTo(Ee,B),this._tmpCtx.lineTo(fe,B);break}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!I&&this._config.fontSize>=12&&!this._config.allowTransparency&&a!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let ge=this._tmpCtx.measureText(a);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in ge&&ge.actualBoundingBoxDescent>0){this._tmpCtx.save();let Ee=new Path2D;Ee.rect(Y,B-Math.ceil(D/2),this._config.deviceCellWidth*H,ie-B+Math.ceil(D/2)),this._tmpCtx.clip(Ee),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=j.css,this._tmpCtx.strokeText(a,X,X+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(C){let D=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),$=D%2===1?.5:0;this._tmpCtx.lineWidth=D,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(X,X+$),this._tmpCtx.lineTo(X+this._config.deviceCharWidth*H,X+$),this._tmpCtx.stroke()}if(I||this._tmpCtx.fillText(a,X,X+this._config.deviceCharHeight),a==="_"&&!this._config.allowTransparency){let D=$y(this._tmpCtx.getImageData(X,X,this._config.deviceCellWidth,this._config.deviceCellHeight),j,q,T);if(D)for(let $=1;$<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=j.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(a,X,X+this._config.deviceCharHeight-$),D=$y(this._tmpCtx.getImageData(X,X,this._config.deviceCellWidth,this._config.deviceCellHeight),j,q,T),!!D);$++);}if(S){let D=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),$=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=D,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(X,X+Math.floor(this._config.deviceCharHeight/2)-$),this._tmpCtx.lineTo(X+this._config.deviceCharWidth*H,X+Math.floor(this._config.deviceCharHeight/2)-$),this._tmpCtx.stroke()}this._tmpCtx.restore();let F=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),P;if(this._config.allowTransparency?P=Yre(F):P=$y(F,j,q,T),P)return hT;let U=this._findGlyphBoundingBox(F,this._workBoundingBox,u,G,I,X),V,K;for(;;){if(this._activePages.length===0){let D=this._createNewPage();V=D,K=D.currentRow,K.height=U.size.y;break}V=this._activePages[this._activePages.length-1],K=V.currentRow;for(let D of this._activePages)U.size.y<=D.currentRow.height&&(V=D,K=D.currentRow);for(let D=this._activePages.length-1;D>=0;D--)for(let $ of this._activePages[D].fixedRows)$.height<=K.height&&U.size.y<=$.height&&(V=this._activePages[D],K=$);if(U.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new zy(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),V=this._overflowSizePage,K=this._overflowSizePage.currentRow,K.x+U.size.x>=V.canvas.width&&(K.x=0,K.y+=K.height,K.height=0);break}if(K.y+U.size.y>=V.canvas.height||K.height>U.size.y+2){let D=!1;if(V.currentRow.y+V.currentRow.height+U.size.y>=V.canvas.height){let $;for(let Y of this._activePages)if(Y.currentRow.y+Y.currentRow.height+U.size.y<Y.canvas.height){$=Y;break}if($)V=$;else if(Uu.maxAtlasPages&&this._pages.length>=Uu.maxAtlasPages&&K.y+U.size.y<=V.canvas.height&&K.height>=U.size.y&&K.x+U.size.x<=V.canvas.width)D=!0;else{let Y=this._createNewPage();V=Y,K=Y.currentRow,K.height=U.size.y,D=!0}}D||(V.currentRow.height>0&&V.fixedRows.push(V.currentRow),K={x:0,y:V.currentRow.y+V.currentRow.height,height:U.size.y},V.fixedRows.push(K),V.currentRow={x:0,y:K.y+K.height,height:0})}if(K.x+U.size.x<=V.canvas.width)break;K===V.currentRow?(K.x=0,K.y+=K.height,K.height=0):V.fixedRows.splice(V.fixedRows.indexOf(K),1)}return U.texturePage=this._pages.indexOf(V),U.texturePosition.x=K.x,U.texturePosition.y=K.y,U.texturePositionClipSpace.x=K.x/V.canvas.width,U.texturePositionClipSpace.y=K.y/V.canvas.height,U.sizeClipSpace.x/=V.canvas.width,U.sizeClipSpace.y/=V.canvas.height,K.height=Math.max(K.height,U.size.y),K.x+=U.size.x,V.ctx.putImageData(F,U.texturePosition.x-this._workBoundingBox.left,U.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,U.size.x,U.size.y),V.addGlyph(U),V.version++,U}_findGlyphBoundingBox(e,i,n,s,r,o){i.top=0;let a=s?this._config.deviceCellHeight:this._tmpCanvas.height,u=s?this._config.deviceCellWidth:n,h=!1;for(let p=0;p<a;p++){for(let m=0;m<u;m++){let v=p*this._tmpCanvas.width*4+m*4+3;if(e.data[v]!==0){i.top=p,h=!0;break}}if(h)break}i.left=0,h=!1;for(let p=0;p<o+u;p++){for(let m=0;m<a;m++){let v=m*this._tmpCanvas.width*4+p*4+3;if(e.data[v]!==0){i.left=p,h=!0;break}}if(h)break}i.right=u,h=!1;for(let p=o+u-1;p>=o;p--){for(let m=0;m<a;m++){let v=m*this._tmpCanvas.width*4+p*4+3;if(e.data[v]!==0){i.right=p,h=!0;break}}if(h)break}i.bottom=a,h=!1;for(let p=a-1;p>=0;p--){for(let m=0;m<u;m++){let v=p*this._tmpCanvas.width*4+m*4+3;if(e.data[v]!==0){i.bottom=p,h=!0;break}}if(h)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:i.right-i.left+1,y:i.bottom-i.top+1},sizeClipSpace:{x:i.right-i.left+1,y:i.bottom-i.top+1},offset:{x:-i.left+o+(s||r?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-i.top+o+(s||r?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},zy=class{constructor(t,e,i){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],i)for(let n of i)this._glyphs.push(...n.glyphs),this._usedPixels+=n._usedPixels;this.canvas=I6(t,e,e),this.ctx=sn(this.canvas.getContext("2d",{alpha:!0}))}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(t){this._glyphs.push(t),this._usedPixels+=t.size.x*t.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version++}};function $y(t,e,i,n){let s=e.rgba>>>24,r=e.rgba>>>16&255,o=e.rgba>>>8&255,a=i.rgba>>>24,u=i.rgba>>>16&255,h=i.rgba>>>8&255,p=Math.floor((Math.abs(s-a)+Math.abs(r-u)+Math.abs(o-h))/12),m=!0;for(let v=0;v<t.data.length;v+=4)t.data[v]===s&&t.data[v+1]===r&&t.data[v+2]===o||n&&Math.abs(t.data[v]-s)+Math.abs(t.data[v+1]-r)+Math.abs(t.data[v+2]-o)<p?t.data[v+3]=0:m=!1;return m}function Yre(t){for(let e=0;e<t.data.length;e+=4)if(t.data[e+3]>0)return!1;return!0}function I6(t,e,i){let n=t.createElement("canvas");return n.width=e,n.height=i,n}function Gre(t,e,i,n,s,r,o,a){let u={foreground:r.foreground,background:r.background,cursor:Cr,cursorAccent:Cr,selectionForeground:Cr,selectionBackgroundTransparent:Cr,selectionBackgroundOpaque:Cr,selectionInactiveBackgroundTransparent:Cr,selectionInactiveBackgroundOpaque:Cr,overviewRulerBorder:Cr,scrollbarSliderBackground:Cr,scrollbarSliderHoverBackground:Cr,scrollbarSliderActiveBackground:Cr,ansi:r.ansi.slice(),contrastCache:r.contrastCache,halfContrastCache:r.halfContrastCache};return{customGlyphs:s.customGlyphs,devicePixelRatio:o,deviceMaxTextureSize:a,letterSpacing:s.letterSpacing,lineHeight:s.lineHeight,deviceCellWidth:t,deviceCellHeight:e,deviceCharWidth:i,deviceCharHeight:n,fontFamily:s.fontFamily,fontSize:s.fontSize,fontWeight:s.fontWeight,fontWeightBold:s.fontWeightBold,allowTransparency:s.allowTransparency,drawBoldTextInBrightColors:s.drawBoldTextInBrightColors,minimumContrastRatio:s.minimumContrastRatio,colors:u}}function dT(t,e){for(let i=0;i<t.colors.ansi.length;i++)if(t.colors.ansi[i].rgba!==e.colors.ansi[i].rgba)return!1;return t.devicePixelRatio===e.devicePixelRatio&&t.customGlyphs===e.customGlyphs&&t.lineHeight===e.lineHeight&&t.letterSpacing===e.letterSpacing&&t.fontFamily===e.fontFamily&&t.fontSize===e.fontSize&&t.fontWeight===e.fontWeight&&t.fontWeightBold===e.fontWeightBold&&t.allowTransparency===e.allowTransparency&&t.deviceCharWidth===e.deviceCharWidth&&t.deviceCharHeight===e.deviceCharHeight&&t.drawBoldTextInBrightColors===e.drawBoldTextInBrightColors&&t.minimumContrastRatio===e.minimumContrastRatio&&t.colors.foreground.rgba===e.colors.foreground.rgba&&t.colors.background.rgba===e.colors.background.rgba}function Qre(t){return(t&50331648)===16777216||(t&50331648)===33554432}var Nr=[];function P6(t,e,i,n,s,r,o,a,u){let h=Gre(n,s,r,o,e,i,a,u);for(let v=0;v<Nr.length;v++){let _=Nr[v],x=_.ownedBy.indexOf(t);if(x>=0){if(dT(_.config,h))return _.atlas;_.ownedBy.length===1?(_.atlas.dispose(),Nr.splice(v,1)):_.ownedBy.splice(x,1);break}}for(let v=0;v<Nr.length;v++){let _=Nr[v];if(dT(_.config,h))return _.ownedBy.push(t),_.atlas}let p=t._core,m={atlas:new ma(document,h,p.unicodeService),config:h,ownedBy:[t]};return Nr.push(m),m.atlas}function fT(t){for(let e=0;e<Nr.length;e++){let i=Nr[e].ownedBy.indexOf(t);if(i!==-1){Nr[e].ownedBy.length===1?(Nr[e].atlas.dispose(),Nr.splice(e,1)):Nr[e].ownedBy.splice(i,1);break}}}var _g=600,Xre=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(t=_g){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=_g-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0){this._restartInterval(e);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=_g-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},_g)},t)}pause(){this.isCursorVisible=!0,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function pT(t,e,i){let n=new e.ResizeObserver(s=>{let r=s.find(u=>u.target===t);if(!r)return;if(!("devicePixelContentBoxSize"in r)){n?.disconnect(),n=void 0;return}let o=r.devicePixelContentBoxSize[0].inlineSize,a=r.devicePixelContentBoxSize[0].blockSize;o>0&&a>0&&i(o,a)});try{n.observe(t,{box:["device-pixel-content-box"]})}catch{n.disconnect(),n=void 0}return Gn(()=>n?.disconnect())}function Zre(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}var mT=class z6 extends Ju{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new N6,this.combinedData=""}static fromCharData(e){let i=new z6;return i.setFromCharData(e),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Zre(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let i=!1;if(e[1].length>2)i=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(n-55296)*1024+s-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},$6=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function F6(t,e,i){let n=sn(t.createProgram());if(t.attachShader(n,sn(gT(t,t.VERTEX_SHADER,e))),t.attachShader(n,sn(gT(t,t.FRAGMENT_SHADER,i))),t.linkProgram(n),t.getProgramParameter(n,t.LINK_STATUS))return n;console.error(t.getProgramInfoLog(n)),t.deleteProgram(n)}function gT(t,e,i){let n=sn(t.createShader(e));if(t.shaderSource(n,i),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS))return n;console.error(t.getShaderInfoLog(n)),t.deleteShader(n)}function Jre(t,e){let i=Math.min(t.length*2,e),n=new Float32Array(i);for(let s=0;s<t.length;s++)n[s]=t[s];return n}var eoe=class{constructor(t){this.texture=t,this.version=-1}},toe=`#version 300 es
|
|
220
|
+
layout (location = 0) in vec2 a_unitquad;
|
|
221
|
+
layout (location = 1) in vec2 a_cellpos;
|
|
222
|
+
layout (location = 2) in vec2 a_offset;
|
|
223
|
+
layout (location = 3) in vec2 a_size;
|
|
224
|
+
layout (location = 4) in float a_texpage;
|
|
225
|
+
layout (location = 5) in vec2 a_texcoord;
|
|
226
|
+
layout (location = 6) in vec2 a_texsize;
|
|
227
|
+
|
|
228
|
+
uniform mat4 u_projection;
|
|
229
|
+
uniform vec2 u_resolution;
|
|
230
|
+
|
|
231
|
+
out vec2 v_texcoord;
|
|
232
|
+
flat out int v_texpage;
|
|
233
|
+
|
|
234
|
+
void main() {
|
|
235
|
+
vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);
|
|
236
|
+
gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
|
|
237
|
+
v_texpage = int(a_texpage);
|
|
238
|
+
v_texcoord = a_texcoord + a_unitquad * a_texsize;
|
|
239
|
+
}`;function ioe(t){let e="";for(let i=1;i<t;i++)e+=` else if (v_texpage == ${i}) { outColor = texture(u_texture[${i}], v_texcoord); }`;return`#version 300 es
|
|
240
|
+
precision lowp float;
|
|
241
|
+
|
|
242
|
+
in vec2 v_texcoord;
|
|
243
|
+
flat in int v_texpage;
|
|
244
|
+
|
|
245
|
+
uniform sampler2D u_texture[${t}];
|
|
246
|
+
|
|
247
|
+
out vec4 outColor;
|
|
248
|
+
|
|
249
|
+
void main() {
|
|
250
|
+
if (v_texpage == 0) {
|
|
251
|
+
outColor = texture(u_texture[0], v_texcoord);
|
|
252
|
+
} ${e}
|
|
253
|
+
}`}var ga=11,Du=ga*Float32Array.BYTES_PER_ELEMENT,noe=2,Bi=0,wi,Fy=0,nf=0,soe=class extends Zr{constructor(t,e,i,n){super(),this._terminal=t,this._gl=e,this._dimensions=i,this._optionsService=n,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let s=this._gl;ma.maxAtlasPages===void 0&&(ma.maxAtlasPages=Math.min(32,sn(s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS))),ma.maxTextureSize=sn(s.getParameter(s.MAX_TEXTURE_SIZE))),this._program=sn(F6(s,toe,ioe(ma.maxAtlasPages))),this._register(Gn(()=>s.deleteProgram(this._program))),this._projectionLocation=sn(s.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=sn(s.getUniformLocation(this._program,"u_resolution")),this._textureLocation=sn(s.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let r=new Float32Array([0,0,1,0,0,1,1,1]),o=s.createBuffer();this._register(Gn(()=>s.deleteBuffer(o))),s.bindBuffer(s.ARRAY_BUFFER,o),s.bufferData(s.ARRAY_BUFFER,r,s.STATIC_DRAW),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let a=new Uint8Array([0,1,2,3]),u=s.createBuffer();this._register(Gn(()=>s.deleteBuffer(u))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,u),s.bufferData(s.ELEMENT_ARRAY_BUFFER,a,s.STATIC_DRAW),this._attributesBuffer=sn(s.createBuffer()),this._register(Gn(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,2,s.FLOAT,!1,Du,0),s.vertexAttribDivisor(2,1),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,s.FLOAT,!1,Du,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(3,1),s.enableVertexAttribArray(4),s.vertexAttribPointer(4,1,s.FLOAT,!1,Du,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(4,1),s.enableVertexAttribArray(5),s.vertexAttribPointer(5,2,s.FLOAT,!1,Du,5*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(5,1),s.enableVertexAttribArray(6),s.vertexAttribPointer(6,2,s.FLOAT,!1,Du,7*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(6,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,Du,9*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.useProgram(this._program);let h=new Int32Array(ma.maxAtlasPages);for(let p=0;p<ma.maxAtlasPages;p++)h[p]=p;s.uniform1iv(this._textureLocation,h),s.uniformMatrix4fv(this._projectionLocation,!1,$6),this._atlasTextures=[];for(let p=0;p<ma.maxAtlasPages;p++){let m=new eoe(sn(s.createTexture()));this._register(Gn(()=>s.deleteTexture(m.texture))),s.activeTexture(s.TEXTURE0+p),s.bindTexture(s.TEXTURE_2D,m.texture),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[p]=m}s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return this._atlas?this._atlas.beginFrame():!0}updateCell(t,e,i,n,s,r,o,a,u){this._updateCell(this._vertices.attributes,t,e,i,n,s,r,o,a,u)}_updateCell(t,e,i,n,s,r,o,a,u,h){if(Bi=(i*this._terminal.cols+e)*ga,n===0||n===void 0){t.fill(0,Bi,Bi+ga-1-noe);return}this._atlas&&(a&&a.length>1?wi=this._atlas.getRasterizedGlyphCombinedChar(a,s,r,o,!1,this._terminal.element):wi=this._atlas.getRasterizedGlyph(n,s,r,o,!1,this._terminal.element),Fy=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),s!==h&&wi.offset.x>Fy?(nf=wi.offset.x-Fy,t[Bi]=-(wi.offset.x-nf)+this._dimensions.device.char.left,t[Bi+1]=-wi.offset.y+this._dimensions.device.char.top,t[Bi+2]=(wi.size.x-nf)/this._dimensions.device.canvas.width,t[Bi+3]=wi.size.y/this._dimensions.device.canvas.height,t[Bi+4]=wi.texturePage,t[Bi+5]=wi.texturePositionClipSpace.x+nf/this._atlas.pages[wi.texturePage].canvas.width,t[Bi+6]=wi.texturePositionClipSpace.y,t[Bi+7]=wi.sizeClipSpace.x-nf/this._atlas.pages[wi.texturePage].canvas.width,t[Bi+8]=wi.sizeClipSpace.y):(t[Bi]=-wi.offset.x+this._dimensions.device.char.left,t[Bi+1]=-wi.offset.y+this._dimensions.device.char.top,t[Bi+2]=wi.size.x/this._dimensions.device.canvas.width,t[Bi+3]=wi.size.y/this._dimensions.device.canvas.height,t[Bi+4]=wi.texturePage,t[Bi+5]=wi.texturePositionClipSpace.x,t[Bi+6]=wi.texturePositionClipSpace.y,t[Bi+7]=wi.sizeClipSpace.x,t[Bi+8]=wi.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&xre(n,u,wi.size.x,this._dimensions.device.cell.width)&&(t[Bi+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let t=this._terminal,e=t.cols*t.rows*ga;this._vertices.count!==e?this._vertices.attributes=new Float32Array(e):this._vertices.attributes.fill(0);let i=0;for(;i<this._vertices.attributesBuffers.length;i++)this._vertices.count!==e?this._vertices.attributesBuffers[i]=new Float32Array(e):this._vertices.attributesBuffers[i].fill(0);this._vertices.count=e,i=0;for(let n=0;n<t.rows;n++)for(let s=0;s<t.cols;s++)this._vertices.attributes[i+9]=s/t.cols,this._vertices.attributes[i+10]=n/t.rows,i+=ga}handleResize(){let t=this._gl;t.useProgram(this._program),t.viewport(0,0,t.canvas.width,t.canvas.height),t.uniform2f(this._resolutionLocation,t.canvas.width,t.canvas.height),this.clear()}render(t){if(!this._atlas)return;let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let i=this._vertices.attributesBuffers[this._activeBuffer],n=0;for(let s=0;s<t.lineLengths.length;s++){let r=s*this._terminal.cols*ga,o=this._vertices.attributes.subarray(r,r+t.lineLengths[s]*ga);i.set(o,n),n+=o.length}e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,i.subarray(0,n),e.STREAM_DRAW);for(let s=0;s<this._atlas.pages.length;s++)this._atlas.pages[s].version!==this._atlasTextures[s].version&&this._bindAtlasPageTexture(e,this._atlas,s);e.drawElementsInstanced(e.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,n/ga)}setAtlas(t){this._atlas=t;for(let e of this._atlasTextures)e.version=-1}_bindAtlasPageTexture(t,e,i){t.activeTexture(t.TEXTURE0+i),t.bindTexture(t.TEXTURE_2D,this._atlasTextures[i].texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e.pages[i].canvas),t.generateMipmap(t.TEXTURE_2D),this._atlasTextures[i].version=e.pages[i].version}setDimensions(t){this._dimensions=t}},roe=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(t,e,i,n=!1){if(this.selectionStart=e,this.selectionEnd=i,!e||!i||e[0]===i[0]&&e[1]===i[1]){this.clear();return}let s=t.buffers.active.ydisp,r=e[1]-s,o=i[1]-s,a=Math.max(r,0),u=Math.min(o,t.rows-1);if(a>=t.rows||u<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=n,this.viewportStartRow=r,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=u,this.startCol=e[0],this.endCol=i[0]}isCellSelected(t,e,i){return this.hasSelection?(i-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&i>=this.viewportCappedStartRow&&e<this.endCol&&i<=this.viewportCappedEndRow:e<this.startCol&&i>=this.viewportCappedStartRow&&e>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&e>=this.startCol):!1}};function ooe(){return new roe}var H0=4,Vg=1,Kg=2,Hy=3,loe=2147483648,aoe=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=ooe()}resize(t,e){let i=t*e*H0;i!==this.cells.length&&(this.cells=new Uint32Array(i),this.lineLengths=new Uint32Array(e))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},coe=`#version 300 es
|
|
254
|
+
layout (location = 0) in vec2 a_position;
|
|
255
|
+
layout (location = 1) in vec2 a_size;
|
|
256
|
+
layout (location = 2) in vec4 a_color;
|
|
257
|
+
layout (location = 3) in vec2 a_unitquad;
|
|
258
|
+
|
|
259
|
+
uniform mat4 u_projection;
|
|
260
|
+
|
|
261
|
+
out vec4 v_color;
|
|
262
|
+
|
|
263
|
+
void main() {
|
|
264
|
+
vec2 zeroToOne = a_position + (a_unitquad * a_size);
|
|
265
|
+
gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
|
|
266
|
+
v_color = a_color;
|
|
267
|
+
}`,uoe=`#version 300 es
|
|
268
|
+
precision lowp float;
|
|
269
|
+
|
|
270
|
+
in vec4 v_color;
|
|
271
|
+
|
|
272
|
+
out vec4 outColor;
|
|
273
|
+
|
|
274
|
+
void main() {
|
|
275
|
+
outColor = v_color;
|
|
276
|
+
}`,gl=8,Wy=gl*Float32Array.BYTES_PER_ELEMENT,hoe=20*gl,vT=class{constructor(){this.attributes=new Float32Array(hoe),this.count=0}},dl=0,_T=0,yT=0,xT=0,bT=0,wT=0,ST=0,doe=class extends Zr{constructor(t,e,i,n){super(),this._terminal=t,this._gl=e,this._dimensions=i,this._themeService=n,this._vertices=new vT,this._verticesCursor=new vT;let s=this._gl;this._program=sn(F6(s,coe,uoe)),this._register(Gn(()=>s.deleteProgram(this._program))),this._projectionLocation=sn(s.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let r=new Float32Array([0,0,1,0,0,1,1,1]),o=s.createBuffer();this._register(Gn(()=>s.deleteBuffer(o))),s.bindBuffer(s.ARRAY_BUFFER,o),s.bufferData(s.ARRAY_BUFFER,r,s.STATIC_DRAW),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let a=new Uint8Array([0,1,2,3]),u=s.createBuffer();this._register(Gn(()=>s.deleteBuffer(u))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,u),s.bufferData(s.ELEMENT_ARRAY_BUFFER,a,s.STATIC_DRAW),this._attributesBuffer=sn(s.createBuffer()),this._register(Gn(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,s.FLOAT,!1,Wy,0),s.vertexAttribDivisor(0,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,Wy,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,4,s.FLOAT,!1,Wy,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(2,1),this._updateCachedColors(n.colors),this._register(this._themeService.onChangeColors(h=>{this._updateCachedColors(h),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(t){let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),e.uniformMatrix4fv(this._projectionLocation,!1,$6),e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,t.attributes,e.DYNAMIC_DRAW),e.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,t.count)}handleResize(){this._updateViewportRectangle()}setDimensions(t){this._dimensions=t}_updateCachedColors(t){this._bgFloat=this._colorToFloat32Array(t.background),this._cursorFloat=this._colorToFloat32Array(t.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(t){let e=this._terminal,i=this._vertices,n=1,s,r,o,a,u,h,p,m,v,_,x;for(s=0;s<e.rows;s++){for(o=-1,a=0,u=0,h=!1,r=0;r<e.cols;r++)p=(s*e.cols+r)*H0,m=t.cells[p+Vg],v=t.cells[p+Kg],_=!!(v&67108864),(m!==a||v!==u&&(h||_))&&((a!==0||h&&u!==0)&&(x=n++*gl,this._updateRectangle(i,x,u,a,o,r,s)),o=r,a=m,u=v,h=_);(a!==0||h&&u!==0)&&(x=n++*gl,this._updateRectangle(i,x,u,a,o,e.cols,s))}i.count=n}updateCursor(t){let e=this._verticesCursor,i=t.cursor;if(!i||i.style==="block"){e.count=0;return}let n,s=0;(i.style==="bar"||i.style==="outline")&&(n=s++*gl,this._addRectangleFloat(e.attributes,n,i.x*this._dimensions.device.cell.width,i.y*this._dimensions.device.cell.height,i.style==="bar"?i.dpr*i.cursorWidth:i.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(i.style==="underline"||i.style==="outline")&&(n=s++*gl,this._addRectangleFloat(e.attributes,n,i.x*this._dimensions.device.cell.width,(i.y+1)*this._dimensions.device.cell.height-i.dpr,i.width*this._dimensions.device.cell.width,i.dpr,this._cursorFloat)),i.style==="outline"&&(n=s++*gl,this._addRectangleFloat(e.attributes,n,i.x*this._dimensions.device.cell.width,i.y*this._dimensions.device.cell.height,i.width*this._dimensions.device.cell.width,i.dpr,this._cursorFloat),n=s++*gl,this._addRectangleFloat(e.attributes,n,(i.x+i.width)*this._dimensions.device.cell.width-i.dpr,i.y*this._dimensions.device.cell.height,i.dpr,this._dimensions.device.cell.height,this._cursorFloat)),e.count=s}_updateRectangle(t,e,i,n,s,r,o){if(i&67108864)switch(i&50331648){case 16777216:case 33554432:dl=this._themeService.colors.ansi[i&255].rgba;break;case 50331648:dl=(i&16777215)<<8;break;default:dl=this._themeService.colors.foreground.rgba}else switch(n&50331648){case 16777216:case 33554432:dl=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:dl=(n&16777215)<<8;break;default:dl=this._themeService.colors.background.rgba}t.attributes.length<e+4&&(t.attributes=Jre(t.attributes,this._terminal.rows*this._terminal.cols*gl)),_T=s*this._dimensions.device.cell.width,yT=o*this._dimensions.device.cell.height,xT=(dl>>24&255)/255,bT=(dl>>16&255)/255,wT=(dl>>8&255)/255,ST=1,this._addRectangle(t.attributes,e,_T,yT,(r-s)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,xT,bT,wT,ST)}_addRectangle(t,e,i,n,s,r,o,a,u,h){t[e]=i/this._dimensions.device.canvas.width,t[e+1]=n/this._dimensions.device.canvas.height,t[e+2]=s/this._dimensions.device.canvas.width,t[e+3]=r/this._dimensions.device.canvas.height,t[e+4]=o,t[e+5]=a,t[e+6]=u,t[e+7]=h}_addRectangleFloat(t,e,i,n,s,r,o){t[e]=i/this._dimensions.device.canvas.width,t[e+1]=n/this._dimensions.device.canvas.height,t[e+2]=s/this._dimensions.device.canvas.width,t[e+3]=r/this._dimensions.device.canvas.height,t[e+4]=o[0],t[e+5]=o[1],t[e+6]=o[2],t[e+7]=o[3]}_colorToFloat32Array(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(t.rgba&255)/255])}},foe=class extends Zr{constructor(t,e,i,n,s,r,o,a){super(),this._container=e,this._alpha=s,this._coreBrowserService=r,this._optionsService=o,this._themeService=a,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${i}-layer`),this._canvas.style.zIndex=n.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(u=>{this._refreshCharAtlas(t,u),this.reset(t)})),this._register(Gn(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=sn(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(t){}handleFocus(t){}handleCursorMove(t){}handleGridChanged(t,e,i){}handleSelectionChanged(t,e,i,n=!1){}_setTransparency(t,e){if(e===this._alpha)return;let i=this._canvas;this._alpha=e,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,i),this._refreshCharAtlas(t,this._themeService.colors),this.handleGridChanged(t,0,t.rows-1)}_refreshCharAtlas(t,e){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=P6(t,this._optionsService.rawOptions,e,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(t,e){this._deviceCellWidth=e.device.cell.width,this._deviceCellHeight=e.device.cell.height,this._deviceCharWidth=e.device.char.width,this._deviceCharHeight=e.device.char.height,this._deviceCharLeft=e.device.char.left,this._deviceCharTop=e.device.char.top,this._canvas.width=e.device.canvas.width,this._canvas.height=e.device.canvas.height,this._canvas.style.width=`${e.css.canvas.width}px`,this._canvas.style.height=`${e.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(t,this._themeService.colors)}_fillBottomLineAtCells(t,e,i=1){this._ctx.fillRect(t*this._deviceCellWidth,(e+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,i*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(t,e,i,n){this._alpha?this._ctx.clearRect(t*this._deviceCellWidth,e*this._deviceCellHeight,i*this._deviceCellWidth,n*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(t*this._deviceCellWidth,e*this._deviceCellHeight,i*this._deviceCellWidth,n*this._deviceCellHeight))}_fillCharTrueColor(t,e,i,n){this._ctx.font=this._getFont(t,!1,!1),this._ctx.textBaseline=E6,this._clipCell(i,n,e.getWidth()),this._ctx.fillText(e.getChars(),i*this._deviceCellWidth+this._deviceCharLeft,n*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(t,e,i){this._ctx.beginPath(),this._ctx.rect(t*this._deviceCellWidth,e*this._deviceCellHeight,i*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(t,e,i){let n=e?t.options.fontWeightBold:t.options.fontWeight;return`${i?"italic":""} ${n} ${t.options.fontSize*this._coreBrowserService.dpr}px ${t.options.fontFamily}`}},poe=class extends foe{constructor(t,e,i,n,s,r,o){super(i,t,"link",e,!0,s,r,o),this._register(n.onShowLinkUnderline(a=>this._handleShowLinkUnderline(a))),this._register(n.onHideLinkUnderline(a=>this._handleHideLinkUnderline(a)))}resize(t,e){super.resize(t,e),this._state=void 0}reset(t){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let t=this._state.y2-this._state.y1-1;t>0&&this._clearCells(0,this._state.y1+1,this._state.cols,t),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(t){if(t.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:t.fg!==void 0&&Qre(t.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[t.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,t.y1===t.y2)this._fillBottomLineAtCells(t.x1,t.y1,t.x2-t.x1);else{this._fillBottomLineAtCells(t.x1,t.y1,t.cols-t.x1);for(let e=t.y1+1;e<t.y2;e++)this._fillBottomLineAtCells(0,e,t.cols);this._fillBottomLineAtCells(0,t.y2,t.x2)}this._state=t}_handleHideLinkUnderline(t){this._clearCurrentLink()}},bc=typeof window=="object"?window:globalThis,gw=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ki,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ki,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,i){if(this.getZoomLevel(i)===e)return;let n=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),e)}setFullscreen(e,i){if(this.isFullscreen(i)===e)return;let n=this.getWindowId(i);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};gw.INSTANCE=new gw;var H6=gw;function moe(t,e,i){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",i)}H6.INSTANCE.onDidChangeZoomLevel;H6.INSTANCE.onDidChangeFullscreen;var Rh=typeof navigator=="object"?navigator.userAgent:"";Rh.indexOf("Firefox")>=0;Rh.indexOf("AppleWebKit")>=0;var goe=Rh.indexOf("Chrome")>=0;!goe&&Rh.indexOf("Safari")>=0;Rh.indexOf("Electron/")>=0;Rh.indexOf("Android")>=0;var qy=!1;if(typeof bc.matchMedia=="function"){let t=bc.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=bc.matchMedia("(display-mode: fullscreen)");qy=t.matches,moe(bc,t,({matches:i})=>{qy&&e.matches||(qy=i)})}var eh="en",Uy=!1,W6=!1,yg,Yg=eh,kT=eh,voe,pl,Mc=globalThis,nr;typeof Mc.vscode<"u"&&typeof Mc.vscode.process<"u"?nr=Mc.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(nr=process);var _oe=typeof nr?.versions?.electron=="string",yoe=_oe&&nr?.type==="renderer";if(typeof nr=="object"){nr.platform,nr.platform,Uy=nr.platform==="linux",Uy&&nr.env.SNAP&&nr.env.SNAP_REVISION,nr.env.CI||nr.env.BUILD_ARTIFACTSTAGINGDIRECTORY,yg=eh,Yg=eh;let t=nr.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);yg=e.userLocale,kT=e.osLocale,Yg=e.resolvedLanguage||eh,voe=e.languagePack?.translationsConfigFile}catch{}W6=!0}else typeof navigator=="object"&&!yoe?(pl=navigator.userAgent,pl.indexOf("Windows")>=0,pl.indexOf("Macintosh")>=0,(pl.indexOf("Macintosh")>=0||pl.indexOf("iPad")>=0||pl.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Uy=pl.indexOf("Linux")>=0,pl?.indexOf("Mobi")>=0,Yg=globalThis._VSCODE_NLS_LANGUAGE||eh,yg=navigator.language.toLowerCase(),kT=yg):console.error("Unable to resolve platform.");var CT=W6,Ro=pl,pa=Yg,xoe;(t=>{function e(){return pa}t.value=e;function i(){return pa.length===2?pa==="en":pa.length>=3?pa[0]==="e"&&pa[1]==="n"&&pa[2]==="-":!1}t.isDefaultVariant=i;function n(){return pa==="en"}t.isDefault=n})(xoe||={});var boe=typeof Mc.postMessage=="function"&&!Mc.importScripts;(()=>{if(boe){let t=[];Mc.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let n=0,s=t.length;n<s;n++){let r=t[n];if(r.id===i.data.vscodeScheduleAsyncWork){t.splice(n,1),r.callback();return}}});let e=0;return i=>{let n=++e;t.push({id:n,callback:i}),Mc.postMessage({vscodeScheduleAsyncWork:n},"*")}}return t=>setTimeout(t)})();var woe=!!(Ro&&Ro.indexOf("Chrome")>=0);Ro&&Ro.indexOf("Firefox")>=0;!woe&&Ro&&Ro.indexOf("Safari")>=0;Ro&&Ro.indexOf("Edg/")>=0;Ro&&Ro.indexOf("Android")>=0;var Bu=typeof navigator=="object"?navigator:{};CT||document.queryCommandSupported&&document.queryCommandSupported("copy")||Bu&&Bu.clipboard&&Bu.clipboard.writeText,CT||Bu&&Bu.clipboard&&Bu.clipboard.readText;var ik=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},Vy=new ik,ET=new ik,MT=new ik;new Array(230);var Soe;(t=>{function e(a){return Vy.keyCodeToStr(a)}t.toString=e;function i(a){return Vy.strToKeyCode(a)}t.fromString=i;function n(a){return ET.keyCodeToStr(a)}t.toUserSettingsUS=n;function s(a){return MT.keyCodeToStr(a)}t.toUserSettingsGeneral=s;function r(a){return ET.strToKeyCode(a)||MT.strToKeyCode(a)}t.fromUserSettings=r;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Vy.keyCodeToStr(a)}t.toElectronAccelerator=o})(Soe||={});var q6=Object.freeze(function(t,e){let i=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(i)}}}),koe;(t=>{function e(i){return i===t.None||i===t.Cancelled||i instanceof Coe?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:xl.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:q6})})(koe||={});var Coe=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?q6:(this._emitter||(this._emitter=new ki),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Eoe;(t=>{async function e(n){let s,r=await Promise.all(n.map(o=>o.then(a=>a,a=>{s||(s=a)})));if(typeof s<"u")throw s;return r}t.settled=e;function i(n){return new Promise(async(s,r)=>{try{await n(s,r)}catch(o){r(o)}})}t.withAsyncBody=i})(Eoe||={});var AT=class Er{static fromArray(e){return new Er(i=>{i.emitMany(e)})}static fromPromise(e){return new Er(async i=>{i.emitMany(await e)})}static fromPromises(e){return new Er(async i=>{await Promise.all(e.map(async n=>i.emitOne(await n)))})}static merge(e){return new Er(async i=>{await Promise.all(e.map(async n=>{for await(let s of n)i.emitOne(s)}))})}constructor(e,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new ki,queueMicrotask(async()=>{let n={emitOne:s=>this.emitOne(s),emitMany:s=>this.emitMany(s),reject:s=>this.reject(s)};try{await Promise.resolve(e(n)),this.resolve()}catch(s){this.reject(s)}finally{n.emitOne=void 0,n.emitMany=void 0,n.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await xl.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,i){return new Er(async n=>{for await(let s of e)n.emitOne(i(s))})}map(e){return Er.map(this,e)}static filter(e,i){return new Er(async n=>{for await(let s of e)i(s)&&n.emitOne(s)})}filter(e){return Er.filter(this,e)}static coalesce(e){return Er.filter(e,i=>!!i)}coalesce(){return Er.coalesce(this)}static async toPromise(e){let i=[];for await(let n of e)i.push(n);return i}toPromise(){return Er.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};AT.EMPTY=AT.fromArray([]);var{getWindow:Moe}=(function(){let t=new Map,e={window:bc,disposables:new uh};t.set(bc.vscodeWindowId,e);let i=new ki,n=new ki,s=new ki;function r(o,a){return(typeof o=="number"?t.get(o):void 0)??(a?e:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:n.event,registerWindow(o){if(t.has(o.vscodeWindowId))return Zr.None;let a=new uh,u={window:o,disposables:a.add(new uh)};return t.set(o.vscodeWindowId,u),a.add(Gn(()=>{t.delete(o.vscodeWindowId),n.fire(o)})),a.add(vw(o,Loe.BEFORE_UNLOAD,()=>{s.fire(o)})),i.fire(u),a},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return t.has(o)},getWindowById:r,getWindow(o){let a=o;if(a?.ownerDocument?.defaultView)return a.ownerDocument.defaultView.window;let u=o;return u?.view?u.view.window:bc},getDocument(o){return Moe(o).document}}})(),Aoe=class{constructor(t,e,i,n){this._node=t,this._type=e,this._handler=i,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 vw(t,e,i,n){return new Aoe(t,e,i,n)}var Loe={BEFORE_UNLOAD:"beforeunload"},Toe=class extends Zr{constructor(t,e,i,n,s,r,o,a,u){super(),this._terminal=t,this._characterJoinerService=e,this._charSizeService=i,this._coreBrowserService=n,this._coreService=s,this._decorationService=r,this._optionsService=o,this._themeService=a,this._cursorBlinkStateManager=new Jd,this._charAtlasDisposable=this._register(new Jd),this._observerDisposable=this._register(new Jd),this._model=new aoe,this._workCell=new mT,this._workCell2=new mT,this._rectangleRenderer=this._register(new Jd),this._glyphRenderer=this._register(new Jd),this._onChangeTextureAtlas=this._register(new ki),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new ki),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new ki),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new ki),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new ki),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let h={antialias:!1,depth:!1,preserveDrawingBuffer:u};if(this._gl=this._canvas.getContext("webgl2",h),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new Sre(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new poe(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=bre(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(vw(this._canvas,"webglcontextlost",p=>{console.log("webglcontextlost event received"),p.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(p)},3e3)})),this._register(vw(this._canvas,"webglcontextrestored",p=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,fT(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=pT(this._canvas,this._coreBrowserService.window,(p,m)=>this._setCanvasDevicePixelDimensions(p,m)),this._register(this._coreBrowserService.onWindowChange(p=>{this._observerDisposable.value=pT(this._canvas,p,(m,v)=>this._setCanvasDevicePixelDimensions(m,v))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(Gn(()=>{for(let p of this._renderLayers)p.dispose();this._canvas.parentElement?.removeChild(this._canvas),fT(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(t,e){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let i of this._renderLayers)i.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let t of this._renderLayers)t.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let t of this._renderLayers)t.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleSelectionChanged(t,e,i){for(let n of this._renderLayers)n.handleSelectionChanged(this._terminal,t,e,i);this._model.selection.update(this._core,t,e,i),this._requestRedrawViewport()}handleCursorMove(){for(let t of this._renderLayers)t.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new doe(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new soe(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let t=P6(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==t&&(this._onChangeTextureAtlas.fire(t.pages[0].canvas),this._charAtlasDisposable.value=b6(xl.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),xl.forward(t.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=t,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(t){this._model.clear(),t&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let t of this._renderLayers)t.reset(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(t,e){if(!this._isAttached)if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let i of this._renderLayers)i.handleGridChanged(this._terminal,t,e);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(t,e),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new Xre(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(t,e){let i=this._core,n=this._workCell,s,r,o,a,u,h,p=0,m=!0,v,_,x,S,C,k,M,L,N;t=LT(t,i.rows-1,0),e=LT(e,i.rows-1,0);let j=this._coreService.decPrivateModes.cursorStyle??i.options.cursorStyle??"block",R=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,z=R-i.buffer.ydisp,J=Math.min(this._terminal.buffer.active.cursorX,i.cols-1),G=-1,q=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let X=!1;for(r=t;r<=e;r++)for(o=r+i.buffer.ydisp,a=i.buffer.lines.get(o),this._model.lineLengths[r]=0,x=R===o,p=0,u=this._characterJoinerService.getJoinedCharacters(o),L=0;L<i.cols;L++){if(s=this._cellColorResolver.result.bg,a.loadCell(L,n),L===0&&(s=this._cellColorResolver.result.bg),h=!1,m=L>=p,v=L,u.length>0&&L===u[0][0]&&m){_=u.shift();let I=this._model.selection.isCellSelected(this._terminal,_[0],o);for(M=_[0]+1;M<_[1];M++)m&&=I===this._model.selection.isCellSelected(this._terminal,M,o);m&&=!x||J<_[0]||J>=_[1],m?(h=!0,n=new Noe(n,a.translateToString(!0,_[0],_[1]),_[1]-_[0]),v=_[1]-1):p=_[1]}if(S=n.getChars(),C=n.getCode(),M=(r*i.cols+L)*H0,this._cellColorResolver.resolve(n,L,o,this.dimensions.device.cell.width),q&&o===R&&(L===J&&(this._model.cursor={x:J,y:z,width:n.getWidth(),style:this._coreBrowserService.isFocused?j:i.options.cursorInactiveStyle,cursorWidth:i.options.cursorWidth,dpr:this._devicePixelRatio},G=J+n.getWidth()-1),L>=J&&L<=G&&(this._coreBrowserService.isFocused&&j==="block"||this._coreBrowserService.isFocused===!1&&i.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),C!==0&&(this._model.lineLengths[r]=L+1),!(this._model.cells[M]===C&&this._model.cells[M+Vg]===this._cellColorResolver.result.bg&&this._model.cells[M+Kg]===this._cellColorResolver.result.fg&&this._model.cells[M+Hy]===this._cellColorResolver.result.ext)&&(X=!0,S.length>1&&(C|=loe),this._model.cells[M]=C,this._model.cells[M+Vg]=this._cellColorResolver.result.bg,this._model.cells[M+Kg]=this._cellColorResolver.result.fg,this._model.cells[M+Hy]=this._cellColorResolver.result.ext,k=n.getWidth(),this._glyphRenderer.value.updateCell(L,r,C,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,S,k,s),h)){for(n=this._workCell,L++;L<=v;L++)N=(r*i.cols+L)*H0,this._glyphRenderer.value.updateCell(L,r,0,0,0,0,pre,0,0),this._model.cells[N]=0,this._model.cells[N+Vg]=this._cellColorResolver.result.bg,this._model.cells[N+Kg]=this._cellColorResolver.result.fg,this._model.cells[N+Hy]=this._cellColorResolver.result.ext;L--}}X&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(t,e){this._canvas.width===t&&this._canvas.height===e||(this._canvas.width=t,this._canvas.height=e,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let t=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:t,end:t})}},Noe=class extends Ju{constructor(t,e,i){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function LT(t,e,i=0){return Math.max(Math.min(t,e),i)}var TT="di$target",NT="di$dependencies",Ky=new Map;function Oo(t){if(Ky.has(t))return Ky.get(t);let e=function(i,n,s){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");joe(e,i,s)};return e._id=t,Ky.set(t,e),e}function joe(t,e,i){e[TT]===e?e[NT].push({id:t,index:i}):(e[NT]=[{id:t,index:i}],e[TT]=e)}Oo("BufferService");Oo("CoreMouseService");Oo("CoreService");Oo("CharsetService");Oo("InstantiationService");Oo("LogService");var Roe=Oo("OptionsService");Oo("OscLinkService");Oo("UnicodeService");Oo("DecorationService");var Doe={trace:0,debug:1,info:2,warn:3,error:4,off:5},Boe="xterm.js: ",jT=class extends Zr{constructor(t){super(),this._optionsService=t,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Doe[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let e=0;e<t.length;e++)typeof t[e]=="function"&&(t[e]=t[e]())}_log(t,e,i){this._evalLazyOptionalParams(i),t.call(console,(this._optionsService.options.logger?"":Boe)+e,...i)}trace(t,...e){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,t,e)}debug(t,...e){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,t,e)}info(t,...e){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,t,e)}warn(t,...e){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,t,e)}error(t,...e){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,t,e)}};jT=ire([nre(0,Roe)],jT);var Ooe=class extends Zr{constructor(t){if(k6&&fre()<16){let e={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",e))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=t,this._onChangeTextureAtlas=this._register(new ki),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new ki),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new ki),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new ki),this.onContextLoss=this._onContextLoss.event}activate(t){let e=t._core;if(!t.element){this._register(e.onWillOpen(()=>this.activate(t)));return}this._terminal=t;let i=e.coreService,n=e.optionsService,s=e,r=s._renderService,o=s._characterJoinerService,a=s._charSizeService,u=s._coreBrowserService,h=s._decorationService;s._logService;let p=s._themeService;this._renderer=this._register(new Toe(t,o,a,u,i,h,n,p,this._preserveDrawingBuffer)),this._register(xl.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(xl.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(xl.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(xl.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),r.setRenderer(this._renderer),this._register(Gn(()=>{if(this._terminal._core._store._isDisposed)return;let m=this._terminal._core._renderService;m.setRenderer(this._terminal._core._createRenderer()),m.handleResize(t.cols,t.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}};function Ioe(t){const e=document.createElement("span");e.style.cssText="position:fixed;left:-9999px;top:0;width:0;height:0",document.body.appendChild(e);const i=document.createElement("canvas");i.width=i.height=1;const n=i.getContext("2d",{willReadFrequently:!0});n&&(n.globalCompositeOperation="copy");try{return t.map(s=>{e.style.color=s;const r=getComputedStyle(e).color;if(!n)return r;n.fillStyle=r,n.fillRect(0,0,1,1);const[o,a,u,h]=n.getImageData(0,0,1,1).data;return h===255?`rgb(${o}, ${a}, ${u})`:`rgba(${o}, ${a}, ${u}, ${(h/255).toFixed(3)})`})}finally{e.remove()}}const xg=t=>`color-mix(in oklab, ${t} 78%, var(--fg-0))`;function RT(){const[t,e,i,n,s,r,o,a,u,h,p,m,v,_,x,S]=Ioe(["var(--bg-0)","var(--fg-1)","var(--fg-0)","color-mix(in oklab, var(--accent) 35%, transparent)","var(--bg-2)","var(--fg-3)","var(--fg-1)","var(--fg-0)","var(--danger)","var(--ok)","var(--warn)","var(--link)",xg("var(--danger)"),xg("var(--ok)"),xg("var(--warn)"),xg("var(--link)")]);return{background:t,foreground:e,cursor:i,selectionBackground:n,black:s,red:u,green:h,yellow:p,blue:m,white:o,brightBlack:r,brightRed:v,brightGreen:_,brightYellow:x,brightBlue:S,brightWhite:a,magenta:"#bf5af2",cyan:"#64d2ff",brightMagenta:"#da8fff",brightCyan:"#8be9ff"}}function Poe({id:t,cwd:e,cmd:i,env:n}){const s=w.useRef(null),r=w.useRef(null),o=w.useRef(null),a=w.useRef(n);a.current=n;const u=w.useCallback(()=>{const h=r.current;h&&he.invoke("pty_resize",{id:t,rows:h.rows,cols:h.cols}).catch(()=>{})},[t]);return w.useEffect(()=>{const h=()=>{r.current&&(r.current.options.theme=RT())};return window.addEventListener(Mb,h),()=>window.removeEventListener(Mb,h)},[]),w.useEffect(()=>{const h=s.current;if(!h)return;const p=new Zse({theme:RT(),fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',fontSize:12.5,lineHeight:1.3,cursorBlink:!0,scrollback:5e3,allowProposedApi:!0}),m=new tre;p.loadAddon(m),p.open(h);try{p.loadAddon(new Ooe)}catch{}m.fit(),r.current=p,o.current=m;const v=p.onData(M=>{he.invoke("pty_write",{id:t,data:M}).catch(()=>{})});let _=!1;const x=he.on("pty-output",M=>{M?.id===t&&_&&p.write(M.chunk)}),S=he.on("pty-restore",M=>{M?.id!==t||_||(M.trimmed&&p.write(`\r
|
|
277
|
+
\x1B[2m[octiq: output trimmed]\x1B[0m\r
|
|
278
|
+
`),M.data&&p.write(M.data),_=!0)});he.invoke("pty_spawn",{id:t,cwd:e,startCmd:i,env:a.current}).then(()=>(u(),he.invoke("pty_attach",{id:t}).catch(()=>{_=!0}))).catch(M=>{_=!0,p.writeln(`\r
|
|
279
|
+
\x1B[31mCould not start a shell: ${M.message}\x1B[0m`)});const C=()=>{m.fit(),u()};window.addEventListener("resize",C);const k=new ResizeObserver(C);return k.observe(h),()=>{k.disconnect(),window.removeEventListener("resize",C),v.dispose(),x(),S(),p.dispose(),r.current=null}},[t,e,i,u]),d.jsx("div",{className:"term",ref:s})}const DT="octiq.v2.terminals";function zoe({project:t,onCommandsChanged:e,onHide:i}){const[n,s]=w.useState(()=>{try{return Wte(localStorage.getItem(DT))}catch{return{}}}),[r,o]=w.useState(null),[a,u]=w.useState(null),[h,p]=w.useState(null),m=lS(),v=Pte(n,t.id),_=t.primary_path??"",x=jte(t.actions),S=v.tabs.find(j=>j.id===v.active),C=w.useCallback(j=>{s(R=>{const z={...R,[t.id]:j};try{localStorage.setItem(DT,JSON.stringify(z))}catch{}return z})},[t.id]),k=w.useCallback(j=>{he.invoke("pty_close",{id:j}).catch(()=>{});const R=zte(v,j);C(R),R.tabs.length||i()},[v,C,i]),M=w.useCallback(j=>{C(hL(v,t.id,{name:j.label,cmd:j.command}))},[v,t.id,C]),L=w.useCallback(async(j,R)=>{p(null);try{a&&a!=="new"?Dte(a,j,R)||(await he.invoke("update_action",{workspaceId:t.id,actionId:a.id,label:j,command:R}),e()):(await he.invoke("add_action",{workspaceId:t.id,label:j,command:R}),e()),u(null)}catch(z){p(String(z.message??z))}},[a,t.id,e]),N=w.useCallback(async j=>{if(await m({title:`Delete the “${j.label}” command?`,body:"Only the button goes. Any terminal it opened keeps running.",confirmLabel:"Delete command",danger:!0}))try{await he.invoke("delete_action",{workspaceId:t.id,actionId:j.id}),u(null),e()}catch(z){p(String(z.message??z))}},[m,t.id,e]);return d.jsxs("div",{className:"drawer",children:[d.jsxs("div",{className:"drawer-head",children:[d.jsx("span",{className:"drawer-title",children:t.name}),d.jsx("span",{className:"drawer-path",title:_,children:d.jsx("bdi",{children:_})}),d.jsx("button",{className:"drawer-close",type:"button",title:"Hide the terminal (every shell keeps running)",onClick:i,children:"✕"})]}),d.jsxs("div",{className:"term-tabs",role:"tablist",children:[v.tabs.map(j=>r===j.id?d.jsx("input",{className:"term-tab-name",defaultValue:j.name,autoFocus:!0,onFocus:R=>R.currentTarget.select(),onBlur:()=>o(null),onKeyDown:R=>{R.key==="Enter"&&(C($te(v,j.id,R.currentTarget.value)),o(null)),R.key==="Escape"&&o(null)}},j.id):d.jsxs("span",{className:`term-tab ${j.id===v.active?"is-active":""}`,children:[d.jsx("button",{type:"button",role:"tab","aria-selected":j.id===v.active,title:j.cmd?`Double-click to rename — running ${j.cmd}`:"Double-click to rename",onClick:()=>C(Fte(v,j.id)),onDoubleClick:()=>o(j.id),children:j.name}),d.jsx("button",{className:"term-tab-close",type:"button",title:"Close this terminal (ends what is running in it)",onClick:()=>k(j.id),children:"✕"})]},j.id)),d.jsx("button",{className:"term-tab-add",type:"button",title:"Another shell in this project",onClick:()=>C(hL(v,t.id)),children:"+"})]}),d.jsxs("div",{className:"cmd-bar",children:[x.map(j=>d.jsx("button",{className:"cmd-chip",type:"button",title:`${j.command} — double-click to edit`,onClick:()=>M(j),onDoubleClick:()=>{p(null),u(j)},children:j.label},j.id)),d.jsx("button",{className:"cmd-chip is-add",type:"button",title:"Save a command you run in this project",onClick:()=>{p(null),u("new")},children:"+ Command"})]}),a&&d.jsx($oe,{row:a==="new"?null:a,error:h,onSave:L,onDelete:a==="new"?void 0:()=>{N(a)},onCancel:()=>{p(null),u(null)}},a==="new"?"new":a.id),d.jsx(Poe,{id:v.active,cwd:_,cmd:S?.cmd,env:t.env??{}},v.active)]})}function $oe({row:t,error:e,onSave:i,onDelete:n,onCancel:s}){const[r,o]=w.useState(t?.label??""),[a,u]=w.useState(t?.command??""),h=Rte(r,a);return d.jsxs("form",{className:"cmd-form",onSubmit:p=>{p.preventDefault(),h&&i(r.trim(),a.trim())},onKeyDown:p=>{p.key==="Escape"&&s()},children:[d.jsx("input",{className:"cmd-form-label",placeholder:"dev","aria-label":"Button name",value:r,autoFocus:!0,onChange:p=>o(p.target.value)}),d.jsx("input",{className:"cmd-form-command",placeholder:"pnpm dev","aria-label":"Command to run",value:a,onChange:p=>u(p.target.value)}),d.jsx("button",{className:"cmd-form-save",type:"submit",disabled:!h,children:"Save"}),n&&d.jsx("button",{className:"cmd-form-delete",type:"button",onClick:n,children:"Delete"}),d.jsx("button",{className:"cmd-form-cancel",type:"button",onClick:s,children:"Cancel"}),e&&d.jsx("span",{className:"cmd-form-error",children:e})]})}const Yy=1200,Foe=8e3;function Hoe(t){const e=t??{},i=n=>{const s=e[n];return typeof s=="string"?s:""};return i("command")?{label:"command",body:i("command"),limit:Yy}:i("plan")?{label:"plan",body:i("plan"),limit:Foe}:i("content")?{label:"content",body:i("content"),limit:Yy}:typeof e.new_string=="string"?{label:"replacing with",body:e.new_string,limit:Yy}:null}function U6(t){const e=t.toolInput??{};for(const i of["file_path","filePath","path","notebook_path"]){const n=e[i];if(typeof n=="string"&&n)return n}return null}function Woe(t){const e=U6(t),i=t.toolName||"A tool";return e?`${i} — ${e}`:i}function qoe({ask:t,onAnswered:e}){const[i,n]=w.useState(null),s=U6(t),r=nN(t.toolName??"",t.toolInput),o=r?null:Hoe(t.toolInput),a=Lc(t.toolName??"",t.toolInput),u=async h=>{n(h);try{await he.invoke("permission_decide",{id:t.id,decision:h==="always"?"allow":h,remember:h==="always"})}catch{}e(t.id)};return d.jsxs("div",{className:"ask-card",role:"alertdialog","aria-label":"Permission needed",children:[d.jsxs("div",{className:"ask-card-head",children:[d.jsx("span",{className:"ask-card-dot","aria-hidden":"true"}),d.jsx("span",{className:"tool-icon","data-kind":a.kind,"aria-hidden":"true",children:d.jsx(eS,{kind:a.kind})}),d.jsxs("span",{className:"ask-card-title",children:["Claude wants to use ",d.jsx("strong",{children:t.toolName?a.label:"a tool"}),a.scope&&d.jsx("span",{className:"tool-scope",children:a.scope})]})]}),s&&d.jsx("div",{className:"ask-card-path",title:s,children:d.jsx("bdi",{children:s})}),r&&d.jsxs("div",{className:"ask-card-detail",children:[d.jsx("div",{className:"ask-card-label",children:r.kind==="create"?"writing":"changing"}),d.jsx(Bj,{diff:r})]}),o&&d.jsxs("div",{className:"ask-card-detail",children:[d.jsx("div",{className:"ask-card-label",children:o.label}),d.jsx("pre",{className:"ask-card-body",children:o.body.slice(0,o.limit)})]}),d.jsxs("div",{className:"ask-card-buttons",children:[d.jsx("button",{className:"ask-btn",type:"button",disabled:!!i,onClick:()=>{u("deny")},children:i==="deny"?"Denying…":"Deny"}),d.jsx("button",{className:"ask-btn",type:"button",disabled:!!i,title:t.toolName?.toLowerCase()==="bash"?"Stop asking about this program for the rest of this chat":"Stop asking about this tool for the rest of this chat",onClick:()=>{u("always")},children:i==="always"?"Allowing…":"Always"}),d.jsx("button",{className:"ask-btn is-primary",type:"button",disabled:!!i,onClick:()=>{u("allow")},children:i==="allow"?"Allowing…":"Allow once"})]}),d.jsx("p",{className:"ask-card-note",children:"The agent is paused until you answer. No answer within three minutes counts as Deny. “Always” lasts until this chat is stopped."})]})}const Uoe="Continue without sending any local data to an external service. Use only local tools and local reasoning for this task.",Voe="Continue with a materially safer alternative. Do not retry, work around, or bypass the blocked action.";function Koe(t){return t.kind==="external-data"?Uoe:Voe}function Yoe(t){const e=t.kind==="external-data"?"with the same content and destination only":"with the same files, scope, and intended effect only";return`I explicitly authorize one retry of the exact action that was just blocked. The blocked action was described as: ${t.summary} This authorization applies to that single retry, ${e}. Do not broaden it, and ask again before any later high-risk action.`}function Goe(t){const e=t.kind==="external-data"?"the same kind of data, purpose, and external destination":"the same kind of action, files or resources, scope, and intended effect";return`I explicitly authorize one retry of the exact action that was just blocked, and future actions matching it in this OctiqFlow project, including new chats and sessions. The blocked action was described as: ${t.summary} This continuing authorization is limited to ${e}. It does not authorize a different destination, broader scope, or materially different action. Do not ask again for a matching action. Ask again only if any of those boundaries change.`}function Qoe({block:t,onContinue:e,onAnswered:i,startOpen:n=!1}){const[s,r]=w.useState(n),[o,a]=w.useState(null),[u,h]=w.useState(""),p=async v=>{a(v),h("");try{v==="always"?await he.invoke("safety_block_authorize_project",{id:t.id}):await he.invoke("safety_block_dismiss",{id:t.id}),i(t.id);const _=v==="local"?Koe(t):v==="always"?Goe(t):Yoe(t);await e(_)}catch(_){h(String(_?.message??_)),a(null)}},m=t.kind==="external-data";return d.jsxs("div",{className:"ask-card safety-card",role:"alert","aria-label":t.title,children:[d.jsxs("div",{className:"safety-card-context",children:[d.jsx("span",{children:"Codex safety review"}),d.jsx("span",{className:"safety-card-ok",children:"OctiqFlow is okay"})]}),d.jsxs("div",{className:"ask-card-head",children:[d.jsx("span",{className:"safety-card-icon","aria-hidden":"true",children:"!"}),d.jsx("span",{className:"ask-card-title",children:d.jsx("strong",{children:t.title})})]}),d.jsx("div",{className:"safety-card-label",children:"Why it was blocked"}),d.jsx("p",{className:"safety-card-summary",children:t.summary}),d.jsx("p",{className:"safety-card-status",children:m?"OctiqFlow is still running. The command did not run, and no data was sent.":"OctiqFlow is still running. The blocked action made no changes."}),s&&d.jsxs("div",{className:"ask-card-detail safety-card-detail",children:[d.jsx("div",{className:"ask-card-label",children:"Technical details"}),d.jsx("pre",{className:"ask-card-body",children:t.detail})]}),d.jsxs("div",{className:"ask-card-buttons safety-card-buttons",children:[d.jsx("button",{className:"ask-btn is-primary",type:"button",disabled:!!o,onClick:()=>{p("local")},children:o==="local"?"Continuing…":m?"Keep it local":"Use safer approach"}),d.jsx("button",{className:"ask-btn",type:"button",disabled:!!o,"aria-expanded":s,onClick:()=>r(v=>!v),children:s?"Hide technical details":"Technical details"}),d.jsx("button",{className:"ask-btn safety-allow",type:"button",disabled:!!o,title:"Remember this exact authorization for future chats and sessions in this project",onClick:()=>{p("always")},children:o==="always"?"Saving…":"Always allow in this project"}),d.jsx("button",{className:"ask-btn safety-allow",type:"button",disabled:!!o,onClick:()=>{p("allow")},children:o==="allow"?"Authorizing…":"Allow once"})]}),u&&d.jsxs("p",{className:"ask-card-note safety-card-error",children:["Could not save authorization: ",u]}),d.jsx("p",{className:"ask-card-note",children:"“Always allow in this project” also applies to new chats and sessions in this project, only within the same stated boundaries. The rejected action cannot resume by itself, so either approval starts a new turn."})]})}function Xoe(t,e){return t.includes(e)?t.filter(i=>i!==e):[...t,e]}function Zoe(t,e,i){const n=t.filter(r=>e.includes(r)),s=i.trim();return s&&n.push(s),n.join(", ")}function BT(t){if(!Array.isArray(t))return[];const e=[];for(const i of t){if(typeof i=="string"){i.trim()&&e.push({label:i});continue}if(!i||typeof i!="object")continue;const n=i,s=typeof n.label=="string"?n.label:"";if(!s.trim())continue;const r=typeof n.description=="string"?n.description.trim():"";e.push(r?{label:s,description:r}:{label:s})}return e}function Joe(t){if(t.many)return Zoe(t.labels,t.ticked,t.text);const e=t.text.trim();return e||(t.chosen?.trim()??"")}function ele(t){return t.many?t.ticked.includes(t.label):t.text.trim()?!1:t.chosen===t.label}function V6(t,e){const i=t instanceof Error?t.message:String(t);return i.includes(e)&&i.includes("not available on this backend")}class _w extends Error{constructor(e,i){super(e),this.deliveredIds=i}deliveredIds}async function K6(t,e){const i=[];for(const n of e)try{if(await t("question_answer",n)!==!0)throw new Error("This question is no longer waiting. Your answer was not delivered; continue in the chat.");i.push(n.id)}catch(s){throw new _w(s instanceof Error?s.message:String(s),i)}}async function tle(t,e){let i;try{i=await t("question_answer_batch",{answers:e})}catch(n){if(!V6(n,"question_answer_batch"))throw n;return await K6(t,e),"delivered"}if(!i||typeof i!="object"||!("saved"in i)||i.saved!==!0)throw new Error("The server did not confirm your answers. They are still here; please retry.");return"saved"}const OT="The user closed this question without answering. Do not assume an answer — say what you need and stop, or continue in a way that does not depend on it.";function ile({questions:t,onDone:e,startOpen:i=!1,startPage:n=0}){const[s,r]=w.useState({}),[o,a]=w.useState({}),[u,h]=w.useState({}),[p,m]=w.useState(!1),[v,_]=w.useState(null),[x,S]=w.useState({}),C=ee=>ee.answer??x[ee.id],k=t.length>0&&t.every(ee=>C(ee)!==void 0),M=t.find(ee=>ee.error)?.error,L=M?"Answers need attention":k?"Answers saved · waiting for agent":"Agent is asking",[N,j]=w.useState(!i),[R,z]=w.useState(n),[J,G]=w.useState("fwd"),q=t.length,X=q>1,I=X?q+1:1,T=Math.min(R,I-1),H=X&&T===q,F=ee=>{ee<0||ee>=I||ee===T||(G(ee>T?"fwd":"back"),z(ee))},P=ee=>{if(C(ee)!==void 0)return C(ee);const ie=BT(ee.options);return Joe({many:!!ee.multiple&&ie.length>0,labels:ie.map(re=>re.label),ticked:o[ee.id]??[],chosen:s[ee.id],text:u[ee.id]??""})},U=t.reduce((ee,ie)=>{const re=P(ie);return re&&(ee[ie.id]=re),ee},{}),V=Object.keys(U).length,K=(ee,ie)=>{r(re=>{if(re[ee.id]!==ie)return{...re,[ee.id]:ie};const ge={...re};return delete ge[ee.id],ge})},D=async ee=>{if(p)return;m(!0),_(null);const ie=t.map(({id:re})=>({id:re,answer:ee[re]??OT}));try{if(await tle((ge,Ee)=>he.invoke(ge,Ee),ie)==="delivered"){e(ie.map(ge=>ge.id));return}S(Object.fromEntries(ie.map(({id:ge,answer:Ee})=>[ge,Ee])))}catch(re){re instanceof _w&&e(re.deliveredIds),_(re instanceof Error?re.message:String(re))}finally{m(!1)}},$=async()=>{if(p)return;m(!0),_(null);const ee=t.map(ie=>ie.id);try{try{await he.invoke("question_cancel",{ids:ee})}catch(ie){if(!V6(ie,"question_cancel"))throw ie;await K6((re,ge)=>he.invoke(re,ge),ee.map(re=>({id:re,answer:OT})))}e(ee)}catch(ie){ie instanceof _w&&e(ie.deliveredIds),_(ie instanceof Error?ie.message:String(ie))}finally{m(!1)}},Y=async()=>{if(!p){m(!0),_(null);try{await he.invoke("question_retry",{ids:t.map(ee=>ee.id)})}catch(ee){_(ee instanceof Error?ee.message:String(ee))}finally{m(!1)}}};if(N)return d.jsx("div",{className:"qa-card is-min",children:d.jsxs("button",{className:"qa-restore",type:"button",title:"Back to the questions",onClick:()=>j(!1),children:[d.jsx("span",{className:"qa-dot","aria-hidden":"true"}),d.jsxs("span",{className:"qa-min-copy",children:[d.jsx("span",{className:"qa-min-title",children:L}),d.jsx("span",{className:"qa-min-q",children:t[0]?.question??"For your answers"})]}),q>1&&d.jsx("span",{className:"qa-count",children:d.jsx(ct,{children:q+" questions"})}),d.jsx("span",{className:"qa-min-cue",children:k?"View":"Answer"})]})});if(k)return d.jsxs("div",{className:"qa-card",role:"status",children:[d.jsx("div",{className:"qa-head",children:d.jsx("span",{className:"qa-label",children:L})}),d.jsxs("div",{className:"qa-questions",children:[t.map(ee=>d.jsxs("section",{className:"qa-question-item",children:[d.jsx("p",{className:"qa-question",children:ee.question}),d.jsx("p",{className:"qa-hint",children:C(ee)})]},ee.id)),d.jsx("p",{className:"qa-hint",children:"Your answers are saved. You can leave this page while the agent continues."}),(v||M)&&d.jsx("p",{className:"qa-hint",role:"alert",children:v||M}),M&&t.some(ee=>ee.error&&ee.retryable!==!1)&&d.jsx("button",{className:"ask-btn is-primary",disabled:p,onClick:()=>{Y()},children:"Retry delivery"}),d.jsx("button",{className:"ask-btn",disabled:p,onClick:()=>{$()},children:"Cancel pending delivery"})]})]});const B=H||!X?d.jsx("button",{className:"ask-btn is-primary qa-submit",type:"button",disabled:p||V===0,onClick:()=>{D(U)},children:p?"Sending…":V===0?"Send answers":X?"Send "+V+" of "+q+" answers":"Send "+V+" answer"+(V===1?"":"s")}):d.jsx("button",{className:"ask-btn is-primary qa-submit qa-next",type:"button",disabled:p,onClick:()=>F(T+1),children:T===q-1?"Review answers":"Next question"});return d.jsxs("div",{className:"qa-card",role:"alertdialog","aria-label":q===1?"The agent has a question":"The agent has "+q+" questions",children:[d.jsxs("div",{className:"qa-head",children:[d.jsx("span",{className:"qa-dot","aria-hidden":"true"}),d.jsx("span",{className:"qa-label",children:L}),q>1&&d.jsx("span",{className:"qa-count",children:d.jsx(ct,{children:q+" questions"})}),d.jsx("button",{className:"qa-min-btn",type:"button",disabled:p,title:"Hide while you read","aria-label":"Hide this question while you read the conversation",onClick:()=>j(!0),children:"–"}),d.jsx("button",{className:"qa-close",type:"button",disabled:p,title:"Close without answering","aria-label":"Close without answering",onClick:()=>{$()},children:"×"})]}),v&&d.jsx("p",{className:"qa-hint",role:"alert",children:v}),d.jsxs("div",{className:"qa-questions",children:[H&&d.jsxs("section",{className:"qa-question-item qa-review is-"+J,children:[d.jsx("div",{className:"qa-question-number",children:"Review"}),d.jsx("p",{className:"qa-question",children:"Your answers"}),d.jsx("p",{className:"qa-hint",children:"Press a line to change it. Anything still blank goes back as declined."}),d.jsx("ul",{className:"qa-review-list",children:t.map((ee,ie)=>{const re=U[ee.id];return d.jsx("li",{children:d.jsxs("button",{className:"qa-review-row "+(re?"":"is-blank"),type:"button",disabled:p,title:"Back to question "+(ie+1),onClick:()=>F(ie),children:[d.jsx("span",{className:"qa-review-n","aria-hidden":"true",children:ie+1}),d.jsxs("span",{className:"qa-review-copy",children:[d.jsx("span",{className:"qa-review-q",children:ee.question}),d.jsx("span",{className:"qa-review-a",children:re??"Not answered"})]})]})},ee.id)})})]}),(H?[]:t.slice(T,T+1)).map(ee=>{const ie=BT(ee.options),re=ie.some(De=>De.description),ge=!!ee.multiple&&ie.length>0,Ee=o[ee.id]??[],fe=s[ee.id],Pe=C(ee)??u[ee.id]??"";return d.jsxs("section",{className:"qa-question-item is-"+J,children:[q>1&&d.jsxs("div",{className:"qa-question-number",children:["Question ",T+1," of ",q]}),d.jsx("p",{className:"qa-question",children:ee.question}),ie.length>0&&d.jsx("p",{className:"qa-hint",children:ge?"Pick as many as you like, or add your own answer":"Pick one or type another answer"}),ie.length>0&&d.jsx("div",{className:"qa-options "+(re?"is-detailed":""),role:ge?"group":"radiogroup","aria-label":ee.question,children:ie.map((De,He)=>{const _e=He===ee.recommended,Le=ele({many:ge,label:De.label,ticked:Ee,chosen:fe,text:Pe});return d.jsxs("button",{className:"qa-option "+(Le?"is-on ":"")+(_e?"is-tip ":"")+(ge?"is-many ":"")+(re?"is-detailed":""),type:"button",role:ge?"checkbox":"radio","aria-checked":Le,disabled:p||C(ee)!==void 0,onClick:()=>ge?a(jt=>({...jt,[ee.id]:Xoe(jt[ee.id]??[],De.label)})):K(ee,De.label),children:[ge&&d.jsx("span",{className:"qa-tick","aria-hidden":"true",children:Le?"✓":""}),d.jsxs("span",{className:"qa-option-text",children:[d.jsxs("span",{className:"qa-option-label",children:[De.label,_e&&d.jsx("span",{className:"qa-tip",children:"Suggested"})]}),De.description&&d.jsx("span",{className:"qa-option-desc",children:De.description})]})]},De.label)})}),d.jsx("div",{className:"qa-free",children:d.jsx("input",{className:"qa-input",value:Pe,autoFocus:ie.length===0,"aria-label":"Answer to: "+ee.question,placeholder:ie.length===0?"Your answer…":ge?"…and anything else":"…or say something else",disabled:p||C(ee)!==void 0,onChange:De=>h(He=>({...He,[ee.id]:De.target.value}))})})]},ee.id)})]}),X&&d.jsxs("div",{className:"qa-pager",children:[d.jsx("button",{className:"qa-page-arrow",type:"button",disabled:p||T===0,title:"Previous question","aria-label":"Previous question",onClick:()=>F(T-1),children:"‹"}),d.jsxs("div",{className:"qa-page-dots",children:[t.map((ee,ie)=>d.jsx("button",{className:"qa-page-dot "+(ie===T?"is-here ":"")+(U[ee.id]?"is-done":""),type:"button",disabled:p,"aria-current":ie===T,title:"Question "+(ie+1)+(U[ee.id]?" — answered":""),"aria-label":"Question "+(ie+1)+(U[ee.id]?", answered":", unanswered"),onClick:()=>F(ie)},ee.id)),d.jsx("button",{className:"qa-page-dot is-review "+(H?"is-here":""),type:"button",disabled:p,"aria-current":H,title:"Review your answers","aria-label":"Review your answers",onClick:()=>F(q)})]}),B]}),!X&&B]})}function IT({asks:t,safetyBlocks:e,questions:i,onPermissionAnswered:n,onSafetyAnswered:s,onQuestionsAnswered:r,onContinue:o}){return d.jsxs(d.Fragment,{children:[t.map(a=>d.jsx(qoe,{ask:a,onAnswered:n},a.id)),e.map(a=>d.jsx(Qoe,{block:a,onContinue:o,onAnswered:s},a.id)),i.length>0&&d.jsx(ile,{questions:i,onDone:r},i[0].id)]})}function nle({onOpenMain:t,busy:e=!1}){return d.jsxs("div",{className:"worker-chat-notice",role:"note","aria-label":"Read-only agent chat",children:[d.jsxs("div",{children:[d.jsx("strong",{children:e?"Agent is working · Read-only":"Read-only agent chat"}),d.jsx("p",{children:"Send instructions and requests in the main chat so the coordinating agent stays informed."}),!t&&d.jsx("p",{className:"worker-chat-unavailable",children:"The main chat is unavailable. This agent's conversation remains read-only."})]}),t&&d.jsx("button",{type:"button",onClick:t,children:"Open main chat"})]})}function th(t){return t.chatKey?.startsWith("chat:")&&t.chatKey.slice(5)||null}function PT(t){const e=new Map;for(const[i,n]of Object.entries(t))for(const s of n)e.set(s.id,{conversationId:i,item:s});return e}class sle{current={};generation=0;pending=null;edits=new Map;begin(){return this.pending=++this.generation,this.edits.clear(),this.pending}cancel(e){this.pending===e&&(this.pending=null,this.edits.clear())}replace(e){const i=typeof e=="function"?e(this.current):e;if(this.pending!==null){const n=PT(this.current),s=PT(i);for(const r of n.keys())s.has(r)||this.edits.set(r,null);for(const[r,o]of s){const a=n.get(r);(!a||a.item!==o.item||a.conversationId!==o.conversationId)&&this.edits.set(r,o)}}return this.current=i,i}add(e){const i=th(e);if(!i||!e.id)return this.current;this.pending!==null&&this.edits.set(e.id,{conversationId:i,item:e});const n=this.current[i]??[];return this.current={...this.current,[i]:n.some(s=>s.id===e.id)?n.map(s=>s.id===e.id?e:s):[...n,e]},this.current}remove(e){return e?(this.pending!==null&&this.edits.set(e,null),this.current=Object.fromEntries(Object.entries(this.current).map(([i,n])=>[i,n.filter(s=>s.id!==e)])),this.current):this.current}finish(e,i){if(this.pending!==e)return null;const n=new Map;for(const r of i??[]){const o=th(r);o&&r.id&&n.set(r.id,{conversationId:o,item:r})}for(const[r,o]of this.edits)o===null?n.delete(r):n.set(r,o);const s={};for(const{conversationId:r,item:o}of n.values())(s[r]??=[]).push(o);return this.current=s,this.cancel(e),s}}function Gy(){const[t]=w.useState(()=>new sle),[e,i]=w.useState(t.current),n=w.useCallback(s=>{i(t.replace(s))},[t]);return{store:t,items:e,setItems:n,publish:i}}function rle(t,e){const i=Gy(),n=Gy(),s=Gy(),{items:r,setItems:o}=i,{items:a,setItems:u}=n,{items:h,setItems:p}=s,m=w.useRef(e);return m.current=e,w.useEffect(()=>{if(t!=="open")return;function v(x,S){const C=x.store.begin();return he.invoke(S).then(k=>{const M=x.store.finish(C,k);M&&x.publish(M)}).catch(()=>{x.store.cancel(C)}),()=>x.store.cancel(C)}const _=[v(i,"permission_pending"),v(n,"safety_block_pending"),v(s,"question_pending")];return()=>_.forEach(x=>x())},[t]),w.useEffect(()=>{const v=he.on("permission-ask",L=>{const N=L?th(L):null;!N||!L.id||(m.current(L.id,"permission",N,Woe(L)),i.publish(i.store.add(L)))}),_=he.on("permission-expired",L=>{L?.id&&i.publish(i.store.remove(L.id))}),x=he.on("safety-blocked",L=>{const N=L?th(L):null;!N||!L.id||(m.current(L.id,"permission",N,L.title),n.publish(n.store.add(L)))}),S=he.on("safety-block-expired",L=>{L?.id&&n.publish(n.store.remove(L.id))}),C=he.on("user-question",L=>{const N=L?th(L):null;if(!N||!L.id)return;const j=L.batchSize&&L.batchSize>1?`${L.batchSize} questions · ${L.question}`:L.question??"";m.current(L.batch??L.id,"question",N,j),s.publish(s.store.add(L))}),k=he.on("question-expired",L=>{L?.id&&s.publish(s.store.remove(L.id))}),M=he.on("question-updated",L=>{!L?.id||!th(L)||s.publish(s.store.add(L))});return()=>{v(),_(),x(),S(),C(),k(),M()}},[]),{asks:r,setAsks:o,safetyBlocks:a,setSafetyBlocks:u,questions:h,setQuestions:p}}function ole(t){if(!t||typeof t!="object")return!1;const e=t;return e.type==="turn.started"?!0:e.type!=="stream_event"||!e.event||typeof e.event!="object"?!1:e.event.type==="message_start"}function lle(t,e){const i=new Set(e.queuedTurnIds);let n=!1;const s=t.messages.map(r=>{if(r.role!=="user"||!r.turnId||r.echo||r.takenUp||(r.delivery==="failed"||r.delivery==="unknown")&&!i.has(r.turnId))return r;if(r.delivery==="dispatched"&&!i.has(r.turnId))return e.live?r:(n=!0,{...r,delivery:"unknown",queueLost:void 0});const o=i.has(r.turnId)?r.delivery==="starting"?"starting":"queued":e.live?"unknown":"failed",a=o==="failed";return!!r.queueLost===a&&r.delivery===o?r:(n=!0,{...r,delivery:o,queueLost:a||void 0})});return n?{...t,messages:s}:t}class ale{pending=new Set;isPending(e,i){return this.pending.has(`${e}/${i}`)}async run(e){const{chatId:i,turnId:n,action:s,read:r,patch:o,invoke:a,refresh:u,reclaim:h}=e,p=`${i}/${n}`,m=r().messages.find(_=>_.turnId===n);if(this.pending.has(p)||!m||m.delivery!=="queued"||m.echo||m.takenUp||m.queueLost||m.queueAction)return;this.pending.add(p);const v=_=>o(x=>({...x,messages:x.messages.map(S=>S.turnId===n?{...S,..._}:S)}));v({queueAction:s,queueError:void 0});try{await a(s==="start"?"chat_start_queued":"chat_cancel_queued")===!0&&s==="cancel"?(h(m),o(x=>({...x,messages:x.messages.filter(S=>S.turnId!==n)}))):await u()}catch(_){await u().catch(()=>{r().messages.find(S=>S.turnId===n)?.delivery==="queued"&&v({delivery:"unknown"})}),v({queueError:String(_.message??_)})}finally{v({queueAction:void 0}),this.pending.delete(p)}}}function cle(t,e,i,n=()=>!1){const s=lle(e,i),r=new Map(e.messages.map((u,h)=>[u,s.messages[h]]));let o=!1;const a=t.messages.map(u=>{let h=r.get(u)??u;return h.queueAction&&!n(h)&&(h={...h,queueAction:void 0}),o||=h!==u,h});return o?{...t,messages:a}:t}function zT(t){let e=t.blocks.flatMap(s=>s.kind==="text"?[s.text]:[]).join(`
|
|
280
|
+
`).trim();const i=(t.attachments??[]).filter(s=>!s.isImage),n=`Files to look at:
|
|
281
|
+
${i.map(s=>`- ${s.path}`).join(`
|
|
282
|
+
`)}`;return i.length&&e.endsWith(n)&&(e=e.slice(0,-n.length).trimEnd()),{text:e,attachments:(t.attachments??[]).map(s=>({...s,isImage:!!s.isImage}))}}function ule(t,e,i){const n=new Map,s=new Set;let r;if(e.known)for(const[o,a]of Object.entries(e.chats)){if(!a.busy||a.stopping||VO({id:o,running:e.running}))continue;const u=t.get(o)??i;n.set(o,u);const h=u;i>=h?s.add(o):r=Math.min(r??h,h)}return{missing:n,interrupted:s,nextCheck:r}}function hle(t){const e=w.useRef(new Map),[i,n]=w.useState(new Set),{chats:s,running:r,known:o}=t;return w.useEffect(()=>{let a;const u=()=>{const h=Date.now(),p=ule(e.current,{chats:s,running:r,known:o},h);e.current=p.missing,n(m=>m.size===p.interrupted.size&&[...m].every(v=>p.interrupted.has(v))?m:p.interrupted),p.nextCheck!==void 0&&(a=setTimeout(u,Math.max(1,p.nextCheck-h)))};return u(),()=>{a!==void 0&&clearTimeout(a)}},[s,r,o]),new Set([...i].filter(a=>o&&s[a]?.busy&&!s[a]?.stopping&&!r.has(a)))}function dle(t){try{if(t.startsWith("#/split?")){const n=new URLSearchParams(t.slice(8)),s=n.get(n.get("focus")==="right"?"right":"left")||n.get("left")||n.get("right");return s?{chat:s}:{}}const e=/^#\/p\/([^/]+)(?:\/c\/([^/?]+))?$/.exec(t);if(e)return{project:decodeURIComponent(e[1]),...e[2]?{chat:decodeURIComponent(e[2])}:{}};const i=/^#\/c\/([^/?]+)$/.exec(t);return i?{chat:decodeURIComponent(i[1])}:{}}catch{return{}}}function fle(t){return t.project?`#/p/${encodeURIComponent(t.project)}${t.chat?`/c/${encodeURIComponent(t.chat)}`:""}`:t.chat?`#/c/${encodeURIComponent(t.chat)}`:""}function ple(t,e,i){const n=fle(i);return n===t.hash?!1:(e.replaceState(null,"",`${t.pathname}${t.search}${n}`),!0)}const mle="General";async function gle(t,e,i){const n=o=>ml(o.name)==="general",s=t.find(n);if(s)return{project:s,active:[...t],shelved:[...e]};const r=e.find(n);if(r){await i("set_workspace_shelved",{id:r.id,shelved:!1});const o={...r,shelved:!1};return{project:o,active:t.some(a=>a.id===r.id)?[...t]:[...t,o],shelved:e.filter(a=>a.id!==r.id)}}try{const o=await i("add_workspace",{name:mle,primaryPath:""});return{project:o,active:[...t,o],shelved:[...e]}}catch(o){const a=await i("list_workspaces"),u=a.find(n);if(!u)throw o;u.shelved&&await i("set_workspace_shelved",{id:u.id,shelved:!1});const h={...u,shelved:!1};return{project:h,active:[...a.filter(p=>!p.shelved&&p.id!==u.id),h],shelved:a.filter(p=>p.shelved&&p.id!==u.id)}}}const vle=16e4;function _le(t){if(t.parent)return;const e=t.blocks.flatMap(n=>n.kind==="text"||n.kind==="compacted"?[n.text]:[]).join(`
|
|
283
|
+
`).trim(),i=t.attachments?.map(n=>n.name||n.path);if(!(!e&&!i?.length))return{role:t.role,...t.speaker?.name?{name:t.speaker.name}:{},text:e,...i?.length?{attachments:i}:{}}}function yle(t){const e=t.flatMap(s=>{const r=_le(s);return r?[r]:[]});if(!e.length)return;const i=[];let n=2;for(let s=e.length-1;s>=0;s-=1){const r=JSON.stringify(e[s]).length+1;if(i.length&&n+r>vle)break;i.unshift(e[s]),n+=r}return i.length<e.length&&i.unshift({role:"assistant",name:"OctiqFlow",text:`${e.length-i.length} earlier turn(s) were omitted to fit the new model's context.`}),JSON.stringify(i)}function Y6(t){const e=G6(t);return/codex_core::session:\s*failed to record rollout items:\s*thread\s+[0-9a-f-]+\s+not found/i.test(e)||/Codex could not save some conversation history because its session record was unavailable/i.test(e)||/codex_core::util:\s*Custom tool call output is missing for call id:/i.test(e)||Q6(e)}function xle(t,e){return t==="exit"||!Y6(e)}function ble(t){const e=[];let i=!1;for(const n of t){const s=G6(n);if(wle(s)&&(i=!1),Q6(s)){i=!0;continue}i||Y6(s)||e.push(n)}return e}function G6(t){return t.replace(/\u001b\[[0-9;]*m/g,"")}function Q6(t){return/codex_core::tools::router:/i.test(t)}function wle(t){return/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\S*\s+(?:TRACE|DEBUG|INFO|WARN|ERROR)\b/.test(t)}function Sle(t){const[e,i]=w.useState(!1),n=w.useRef(null),s=e&&t,r=w.useCallback(()=>{n.current=document.activeElement instanceof HTMLElement?document.activeElement:null,xb("enter",()=>i(!0))},[]),o=w.useCallback(()=>{xb("exit",()=>{i(!1),requestAnimationFrame(()=>{const a=n.current;(a?.isConnected&&a.getClientRects().length?a:document.querySelector(".mobile-actions-trigger, .focus-mode-enter"))?.focus({preventScroll:!0})})})},[]);return w.useEffect(()=>{t||(LA(),i(!1))},[t]),w.useEffect(()=>()=>LA(),[]),w.useEffect(()=>{if(!s)return;document.querySelector(".focus-mode-exit")?.focus({preventScroll:!0});function a(u){u.key!=="Escape"||u.defaultPrevented||u.isComposing||[...document.querySelectorAll('[role="dialog"], [role="menu"], .picker-menu, .sheet-scrim, .slash, .modal-scrim')].some(p=>p.getClientRects().length>0)||(u.preventDefault(),o())}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[s,o]),{focusMode:s,enterFocus:r,exitFocus:o}}function $T({active:t=!1,onClick:e}){return d.jsxs("button",{className:t?"focus-mode-exit":"icon-btn focus-mode-enter",type:"button","aria-label":t?"Exit focus mode":"Enter focus mode",title:t?"Exit focus mode (Esc)":"Focus mode","aria-pressed":t,onClick:e,children:[d.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:t?"M9 4v5H4m16 0h-5V4M4 15h5v5m6 0v-5h5":"M9 4H4v5m11-5h5v5M4 15v5h5m6 0h5v-5"})}),d.jsx("span",{className:t?void 0:"topbar-action-label",children:t?"Exit focus":"Focus mode"})]})}const Ou={isRepo:!1,current:"",branches:[],isWorktree:!1},Ut=t=>`chat:${t}`,Qy=t=>t.startsWith("chat:")?t.slice(5):null;function FT(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`user-${crypto.randomUUID()}`:`user-${Date.now()}-${Math.random().toString(36).slice(2)}`}const Xy=2e3,kle=180,HT=new Set,WT=new Set,bg=Tc(),wg="octiq.v2.model",Sg="octiq.v2.access",Zy="octiq.v2.commands",sf="octiq.v2.effort",qT="octiq.v2.lite",Jy="octiq.v2.terminalOpen";function UT(){return dle(location.hash)}function Cle(t,e){ple(location,history,{project:t??void 0,chat:e??void 0})}const rf="octiq.v2.lastChat",ex="octiq.v2.gitColumn",VT="octiq.v2.navShut",Ele="octiq.v2.navWidth",Mle={initial:260,min:200,max:460},Ale=250,tx="octiq.v2.filesOpen",KT="octiq.v2.railShut",YT=220;function Lle(){const[t,e]=w.useState("connecting"),[i,n]=w.useState([]),[s,r]=w.useState({}),[o,a]=w.useState(null),[u,h]=w.useState([]),[p,m]=w.useState(!1),[v,_]=w.useState([]),[x,S]=w.useState(!1),[C,k]=w.useState([]),M=w.useRef(UT()),[L,N]=w.useState({}),[j,R]=w.useState(()=>new Set),[z,J]=w.useState(!1),[G,q]=w.useState(!1),[X,I]=w.useState(()=>yI().filter(A=>!D5(A.id))),[T,H]=w.useState(null),[F,P]=w.useState(""),[U,V]=w.useState(Ou),[K,D]=w.useState(!1),[$,Y]=w.useState(!1),[B,ee]=w.useState(null),[ie,re]=w.useState(null),[ge,Ee]=w.useState(null),fe=lg(qX),Pe=lg(UX),De=lg(VX),[He,_e]=w.useState(!1),Le=He&&fe,[jt,di]=w.useState(()=>localStorage.getItem(VT)==="1"),xt=lg(EA),{focusMode:be,enterFocus:We,exitFocus:Ze}=Sle(!(xt&&G)),ve=Gf(Ele,Mle,"left");w.useLayoutEffect(()=>{document.documentElement.style.setProperty("--nav-w",`${ve.width}px`)},[ve.width]);const fi=w.useRef(null),Mt=xt&&G,Kt=tZ({enabled:xt,open:Mt,onChange:A=>{A&&_e(!1),q(A)}});w.useEffect(()=>{(!fe||!xt)&&_e(A=>A&&!1)},[fe,xt]),w.useEffect(()=>{Ee(null)},[T]);const[gn,de]=w.useState(null),[Me,Ke]=w.useState(!1),[Je,ot]=w.useState(!1),Gt=nte(),wt=w.useMemo(()=>NJ(Gt),[Gt]),pt=Pg(T,wt),[Ht,gi]=w.useState(null),Tt=GA(T,wt),vi=X.find(A=>A.id===Tt),Qt=w.useMemo(()=>T&&!pt?[...wt.keys()].filter(A=>GA(A,wt)===T):[],[T,pt,wt]),[vs,lr]=w.useState(bD),[st,Yt]=w.useState(()=>localStorage.getItem(Jy)==="1"),[Gi,Ds]=w.useState(()=>{const A=jr(ex);return A!==null?A==="1":typeof window<"u"&&!window.matchMedia(EA).matches}),[to,Bs]=w.useState(Gi),_s=!xt,[ys,zr]=w.useState(()=>localStorage.getItem(tx)==="1"),[io,ar]=w.useState(ys),[Al,Ll]=w.useState(()=>localStorage.getItem(KT)==="1"),{asks:Os,setAsks:$r,safetyBlocks:xs,setSafetyBlocks:Io,questions:_i,setQuestions:Ni}=rle(t,(...A)=>Gc(...A)),[ht,Fn]=w.useState(()=>qu(jr(wg))??Wu[0]),[$i,Is]=w.useState(()=>{const A=jr(Sg),W={plan:"read",acceptEdits:"auto",edit:"auto",bypassPermissions:"full"};if(A&&W[A])return Vd(ht.agent,W[A]);const Z=["read","manual","edits","auto","full"];return Vd(ht.agent,Z.includes(A)?A:"read")}),[bs,Po]=w.useState(()=>jr(sf)??"medium"),[on,Ia]=w.useState(()=>jr(qT)==="1"),no=w.useCallback(A=>{Ia(A),ri(qT,A?"1":"0")},[]),[Hn,Fr]=w.useState({}),[Ps,pi]=w.useState({}),Ci=w.useRef({}),cr=w.useRef(new Set),es=w.useRef(new Map),ln=w.useRef(j);ln.current=j;const ae=w.useRef(L),ze=w.useRef(T);ze.current=T;const it=w.useRef(null),Bt=w.useRef(null),Xt=w.useCallback(()=>{it.current!==null&&(cancelAnimationFrame(it.current),it.current=null),Bt.current!==null&&(clearTimeout(Bt.current),Bt.current=null),N(ae.current)},[]),Wn=w.useCallback((A,W)=>{A!==ae.current&&(ae.current=A,Bt.current===null&&(Bt.current=setTimeout(()=>{Bt.current=null,Xt()},Ale)),W&&it.current===null&&(it.current=requestAnimationFrame(()=>{it.current=null,Xt()})))},[Xt]);w.useEffect(()=>{Xt()},[T,Xt]),w.useEffect(()=>()=>{it.current!==null&&cancelAnimationFrame(it.current),Bt.current!==null&&clearTimeout(Bt.current)},[]);const Pt=w.useRef(X);Pt.current=X;const yi=w.useRef($I()),zs=w.useRef(new Set),ws=w.useCallback(A=>{if(yi.current.add(A),$s.current.delete(A),ur.current.forget(A),Tn.current.delete(A),m5(A),an.current.forget(Ut(A)),A in ae.current){const W={...ae.current};delete W[A],Wn(W,!0)}delete Ci.current[A],cr.current.delete(A),es.current.delete(A),bN(A),II(A),H(W=>W===A?null:W);try{localStorage.getItem(rf)===A&&localStorage.removeItem(rf)}catch{}},[Wn]),Uc=w.useRef({}),Dh=w.useRef(()=>{}),an=w.useRef(new CO),$s=w.useRef(new Map),Tn=w.useRef(new Map),ur=w.useRef(new mI),ap=w.useCallback((A,W)=>LJ(()=>he.invoke("chat_page",{key:Ut(A.id),before:null}),A.messages,W),[]),[Vc,so]=w.useState({}),[Kc,cp]=w.useState(KI),[zo,up]=w.useState(!1);w.useEffect(()=>{i7().then(up)},[]);const Pa=w.useRef({on:Kc,push:zo,reading:T,list:X,projects:i,shelved:u});Pa.current={on:Kc,push:zo,reading:T,list:X,projects:i,shelved:u};const $o=w.useRef(()=>{}),hr=w.useRef(null),hp=w.useRef(new Set),Yc=w.useCallback((A,W,Z)=>{const{on:se,push:pe,reading:ke,list:Ne,projects:et,shelved:rt}=Pa.current;if(pe)return;const Ye=VI(ke);if(!HI({enabled:se,permission:cx()},Ye,W))return;const Re=Ne.find(Ot=>Ot.id===W),Ve=qI({kind:A,conversationId:W,projectName:[...et,...rt].find(Ot=>Ot.id===Re?.projectId)?.name??"",chatTitle:Re?.title??"",detail:Z});GI(Ve,Ot=>$o.current(Ot))},[]),Gc=w.useCallback((A,W,Z,se)=>{hp.current.has(A)||(hp.current.add(A),Yc(W,Z,se))},[Yc]);w.useEffect(()=>he.onState(e),[]);const Nn=w.useCallback(()=>{he.invoke("list_workspaces").then(A=>{const W=(A??[]).filter(Z=>!Z.shelved);n(W),h((A??[]).filter(Z=>Z.shelved)),a(Z=>{if(Z&&W.some(pe=>pe.id===Z))return Z;const se=M.current.project;if(se){const pe=W.find(ke=>ke.id===se||ml(ke.name)===ml(se));if(pe)return pe.id}return null})}).catch(()=>n([]))},[]);w.useEffect(Nn,[Nn]),w.useEffect(()=>{if(t!=="open")return;const A=[...i,...u],W=Nee(A),Z=jee(A);let se=!0;const pe=()=>{if(Z.length===0){r({});return}he.invoke("git_status_summary",{paths:Z}).then(et=>{se&&r(Ree(A,et??[]))}).catch(()=>{se&&r({})})},ke=()=>{pe()};he.invoke("git_watch_paths",{paths:W}).catch(()=>{}),pe(),window.addEventListener("focus",ke);const Ne=he.on("git-status-changed",()=>{window.dispatchEvent(new CustomEvent(ch)),pe()});return()=>{se=!1,window.removeEventListener("focus",ke),Ne()}},[t,i,u]);const Qc=w.useCallback(async()=>{const A=await gle(i,u,(W,Z)=>he.invoke(W,Z));return n(A.active),h(A.shelved),A.project},[i,u]),Xc=w.useCallback(A=>{KJ(A===!0).then(W=>k(W??[])).catch(()=>k([]))},[]);w.useEffect(Xc,[Xc]);const Fs=w.useMemo(()=>C.length>0?C.filter(A=>A.installed).map(A=>A.id):void 0,[C]);w.useEffect(()=>{if(!Fs||Fs.length===0||Fs.includes(ht.agent))return;const A=Wu.find(W=>Fs.includes(W.agent));A&&(Fn(A),ri(wg,A.id))},[Fs,ht.agent]);const Hr=w.useCallback(()=>{Promise.all([he.invoke("chat_index_list"),he.invoke("chat_index_deleted")]).then(([A,W])=>{Y(!0);const Z=W??[];_(Z);const se=new Set(Z.map(Re=>Re.id));for(const Re of Pt.current)se.has(Re.id)&&!zs.current.has(Re.id)&&ws(Re.id);if(se.size>0&&I(Re=>{const Ve=Re.filter(Ot=>!se.has(Ot.id)||zs.current.has(Ot.id));return Ve.length===Re.length?Re:(Qs(Ve),Ve)}),!A||A.length===0)return;const pe=Rw(),ke=new Set;for(const Re of pe){const Ve=A.find(Ot=>Ot.id===Re.id);Ve&&((Ve.generation??0)>(Re.generation??0)?(ke.add(Re.id),B5(Re.id),T5(Re.id),yi.current.delete(Re.id)):L5(Re.id,Re.key,Re.generation??0,Re.meta))}const Ne=new Set(pe.filter(Re=>!ke.has(Re.id)).map(Re=>Re.id)),et=new Set([...se,...Ne,...zs.current,...yi.current]);_N(CI(Pt.current,A,et));const rt=A.filter(Re=>!se.has(Re.id)&&!Ne.has(Re.id));if(rt.length===0)return;const Ye=new Set(rt.map(Re=>Re.id));for(const Re of rt)yi.current.delete(Re.id);for(const Re of Pt.current)Re.synced&&!Ye.has(Re.id)&&!se.has(Re.id)&&!zs.current.has(Re.id)&&ws(Re.id);I(Re=>{const Ve=new Map(Re.map(Un=>[Un.id,Un])),Ot=rt.map(Un=>{const Fi=Ve.get(Un.id);return{...Un,permission:Un.access??Fi?.permission,cwd:Un.cwd??Fi?.cwd,messages:Fi?.messages??[],seq:Fi?.seq,synced:!0}}),ji=Re.filter(Un=>!Ye.has(Un.id)&&(!Un.synced||zs.current.has(Un.id))),is=[...Ot,...ji];return SI(Re,is)?Re:(Qs(is),is)})}).catch(()=>{})},[ws]);w.useEffect(()=>{t==="open"&&Hr()},[t,Hr]),w.useEffect(()=>{let A=null;const W=he.on("chat-index-changed",()=>{A&&clearTimeout(A),A=setTimeout(Hr,250)});return()=>{W(),A&&clearTimeout(A)}},[Hr]);const Bh=w.useRef(new Set);w.useEffect(()=>{if(i.length===0)return;const A=new Set([...i,...u].map(Z=>Z.id)),W=X.map(Z=>Z.projectId).filter(Z=>!A.has(Z)&&!Bh.current.has(Z));if(W.length!==0){for(const Z of W)Bh.current.add(Z);Nn()}},[X,i,u,Nn]),w.useEffect(()=>{if(J(!1),t!=="open")return;let A=!0;return he.invoke("chat_list").then(W=>{if(!A)return;const Z=(W??[]).map(Qy).filter(se=>!!se);R(new Set(Z)),J(!0)}).catch(()=>{}),()=>{A=!1}},[t]);const mt=w.useCallback((A,W)=>{const Z=ae.current,se=Z[A]??bg,pe=W(se);pe!==se&&Wn({...Z,[A]:pe},A===ze.current)},[Wn]),[dp,Fo]=w.useState({}),Hs=w.useRef([]),Tl=w.useCallback((A,W,Z)=>{if(!Z||Hs.current.includes(W))return;const se=zT(Z);Hs.current=[...Hs.current.slice(-199),W],Fo(pe=>({...pe,[A]:[...pe[A]??[],se]}))},[]),za=w.useCallback(A=>{Fo(W=>{if(!W[A])return W;const Z={...W};return delete Z[A],Z})},[]),cn=w.useCallback((A,W,Z=!1)=>{const se=$s.current.get(A);if(se)return se.promise;const pe=Ut(A),ke={promise:Promise.resolve()};$s.current.set(A,ke);const Ne=()=>$s.current.get(A)!==ke||yi.current.has(A);return ke.promise=(Z?vI:gI)({id:A,key:pe,storedSeq:W,catchUp:an.current,history:ur.current,requestPage:et=>he.invoke("chat_page",{key:pe,before:et}),getState:()=>ae.current[A]??bg,publish:et=>mt(A,()=>et),request:et=>he.invoke("chat_since",{key:pe,after:et}),cancelled:Ne}).catch(et=>{throw Ne()||an.current.abandon(pe),et}).finally(()=>{$s.current.get(A)===ke&&$s.current.delete(A)}),ke.promise},[mt]),Oh=w.useCallback(async()=>{const A=ze.current;if(!(!A||!ur.current.hasEarlier(A))){so(W=>({...W,[A]:{loading:!0}}));try{await $s.current.get(A)?.promise,yi.current.has(A)||await cn(A,void 0,!0),so(W=>({...W,[A]:{loading:!1}}))}catch(W){so(Z=>({...Z,[A]:{loading:!1,error:String(W)}}))}}},[cn]);w.useEffect(()=>{if(t!=="open")return;const A=ze.current,W=new Set(ln.current);A&&W.add(A);for(const Z of W){if(Z!==A&&!an.current.holds(Ut(Z)))continue;const se=Pt.current.find(pe=>pe.id===Z)?.seq;cn(Z,se).catch(()=>{})}},[t,cn]),w.useEffect(()=>he.on("chat-event",A=>{const W=A&&Qy(A.key);if(!W)return;ole(A.event)&&R(se=>se.has(W)?se:new Set(se).add(W));const Z=an.current.live(A.key,A.seq,A.event);ur.current.append(W,Z);for(const se of Z){const pe=se.event;pe&&pe.type==="octiq_user_turn_cancelled"&&typeof pe.uuid=="string"&&Tl(W,pe.uuid,ae.current[W]?.messages.find(ke=>ke.turnId===pe.uuid)),mt(W,ke=>qf(ke,se.event))}}),[mt,Tl]),w.useEffect(()=>he.on("chat-status",A=>{const W=A&&Qy(A.key);if(W){if(A.kind==="access-refused"){Dh.current(W,A.text);return}A.kind==="exit"&&R(Z=>{if(!Z.has(W))return Z;const se=new Set(Z);return se.delete(W),se}),xle(A.kind,A.text)&&mt(W,Z=>A.kind==="exit"?{...Z,busy:!1,background:[],exited:{code:A.code}}:{...Z,notices:[...Z.notices,A.text].slice(-8)})}}),[mt]);const[Zc,Ih]=w.useState(()=>{try{return EZ(JSON.parse(localStorage.getItem(Zy)||"{}"))}catch{return{}}}),Nl=w.useRef(new Set),jl=w.useRef(new Set),[fp,vn]=w.useState({});w.useEffect(()=>{Ih(A=>{let W=A;for(const[Z,se]of Object.entries(L)){const pe=Ci.current[Z]?.projectId,ke=qu(Ci.current[Z]?.modelId??null)?.agent;if(!pe||!ke||!se.commands?.length)continue;const Ne=A[pe]?.[ke];Ne?.length===se.commands.length&&Ne.every((et,rt)=>et===se.commands[rt])||(W={...W,[pe]:{...W[pe],[ke]:se.commands}})}return W===A?A:(ri(Zy,JSON.stringify(W)),W)})},[L]),w.useEffect(()=>{const A=setTimeout(()=>{const W=Uo.current;for(const[Z,se]of Object.entries(ae.current))W.has(Z)||yi.current.has(Z)||$s.current.has(Z)||!an.current.holds(Ut(Z))||ur.current.hasEarlier(Z)||Tn.current.get(Z)===se||(Tn.current.set(Z,se),bw({id:Z,state:se,seq:an.current.mark(Ut(Z)),updatedAt:Date.now()}));I(Z=>{let se=Z,pe=!1;const ke=new Set;for(const[Ne,et]of Object.entries(L)){if(W.has(Ne)||yi.current.has(Ne)||$s.current.has(Ne)||ur.current.hasEarlier(Ne))continue;const rt=Ci.current[Ne];if(!rt||et.messages.length===0)continue;const Ye=se.find(Ve=>Ve.id===Ne);if(Ye&&Ye.messages===et.messages)continue;se=[M5(Ye,{...Ye??{},id:Ne,projectId:rt.projectId,title:bI(Ye?.title,et.messages,Ye?.customTitle),latestResponse:Sb(et.messages)?.text??Ye?.latestResponse,customTitle:Ye?.customTitle,sessionId:et.sessionId??Ye?.sessionId,cwd:et.cwd??Ye?.cwd,messages:et.messages,modelId:rt.modelId,permission:rt.access,createdAt:Ye?.createdAt??Date.now(),updatedAt:Ye?.updatedAt??Date.now(),seq:an.current.holds(Ut(Ne))?an.current.mark(Ut(Ne)):Ye?.seq}),...se.filter(Ve=>Ve.id!==Ne)],ke.add(Ne),pe=!0}if(!pe)return Z;Qs(se);for(const Ne of se)ke.has(Ne.id)&&Rd({id:Ne.id,projectId:Ne.projectId,title:Ne.title,latestResponse:Ne.latestResponse,customTitle:Ne.customTitle,sessionId:Ne.sessionId??null,cwd:Ne.cwd??null,modelId:Ne.modelId??null,access:Ne.permission??null,createdAt:Ne.createdAt,updatedAt:Ne.updatedAt,pinned:Ne.pinned??!1,generation:Ne.generation});return se})},700);return()=>clearTimeout(A)},[L]),w.useEffect(()=>{const A=i.find(W=>W.id===o);qo.current&&!hr.current&&Cle(A?ml(A.name):o,B??T),document.title=A?`${A.name} — OctiqFlow`:"OctiqFlow",T&&ri(rf,T)},[o,T,i,B]);const gt=w.useMemo(()=>i.find(A=>A.id===o)??null,[i,o]),$a=w.useCallback((A=!1)=>{if(ht.agent!=="codex"||!o||!gt?.primary_path)return;const W=`${o}:codex`;jl.current.has(W)||!A&&Nl.current.has(W)||(Nl.current.add(W),jl.current.add(W),vn(Z=>({...Z,[W]:"loading"})),he.invoke("codex_skills",{cwd:gt.primary_path}).then(Z=>{const se=Array.isArray(Z)?Z.filter(pe=>typeof pe=="string"):[];Ih(pe=>{const ke={...pe,[o]:{...pe[o],codex:se}};return ri(Zy,JSON.stringify(ke)),ke})}).then(()=>{vn(Z=>({...Z,[W]:""}))}).catch(()=>{vn(Z=>({...Z,[W]:"Could not load skills. Try again."})),Nl.current.delete(W)}).finally(()=>jl.current.delete(W)))},[ht.agent,gt,o]),Fa=w.useMemo(()=>wI(X),[X]),bv=w.useCallback(A=>he.invoke("chat_search",{query:A,limit:50}),[]),Qe=T&&L[T]||bg,Wr=w.useMemo(()=>X.find(A=>A.id===T),[X,T]);w.useEffect(()=>{if(!Wr||!lx(Wr,null))return;const A=Wr.id,W=Date.now();EI(A,W),I(Z=>{const se=Z.map(pe=>pe.id===A?{...pe,readAt:W}:pe);return Qs(se),se})},[Wr?.id,Wr?.updatedAt,Wr?.readAt]);const qn=Qe.cwd??Wr?.cwd??gt?.primary_path??"",qr=w.useMemo(()=>gt?{...gt,id:T?`${gt.id}:${T}`:gt.id,primary_path:qn||gt.primary_path}:null,[gt,T,qn]);w.useEffect(()=>{if(!gt||!qn){V(Ou),P(""),D(!1);return}let A=!0;return V(W=>({...W,loading:!0,error:void 0})),he.invoke("git_local_branches",{path:qn}).then(W=>{if(!A)return;const Z={isRepo:!!W?.is_repo,current:W?.current??"",branches:W?.branches??[],isWorktree:!!W?.is_worktree};V(Z),P(Z.current||Z.branches[0]||""),Z.isRepo||D(!1)}).catch(W=>{A&&(V({...Ou,error:String(W.message??W)}),P(""),D(!1))}),()=>{A=!1}},[gt,qn]);const pp=w.useCallback(A=>{T||(a(A),P(""),V(A?{...Ou,loading:!0}:Ou),D(!1),re(null))},[T]),mp=w.useMemo(()=>ble(Qe.notices),[Qe.notices]),Jc=w.useRef(new Set),gp=w.useRef(new ale),ro=w.useCallback(async A=>{const W=ae.current[A];if(!W)return;const Z=new Set(Jc.current),se=await he.invoke("chat_queue_state",{key:Ut(A)}),pe={...W,messages:W.messages.filter(ke=>!ke.turnId||!Z.has(ke.turnId)&&!Jc.current.has(ke.turnId))};mt(A,ke=>cle(ke,pe,se,Ne=>!!Ne.turnId&&gp.current.isPending(A,Ne.turnId)))},[mt]);w.useEffect(()=>{if(!T||t!=="open"||!z)return;const A=T;let W=!1;const Z=async()=>{const pe=ae.current[A];if(!(W||!pe?.messages.some(ke=>ke.role==="user"&&ke.turnId&&!ke.echo&&!ke.takenUp&&ke.delivery!=="unknown"&&ke.delivery!=="failed"))){W=!0;try{await ro(A)}catch{}finally{W=!1}}};Z();const se=setInterval(()=>{Z()},2e3);return()=>clearInterval(se)},[T,t,z,ro]);const dr=Qe.failure&&!Qe.failure.inline&&T&&!OI(T,Qe.failure)?Qe.failure:void 0,Ho=Qe.autoResume,Ws=ste(T?Ut(T):"",Qe.busy),fr=Ws.open,vp=yte(Qe.messages,qn,ys,Qe.busy),Ph=ge?Qe.agents.find(A=>A.id===ge):void 0,wv=w.useMemo(()=>{const A=new Map;for(const W of Qe.agents)W.toolUseId&&A.set(W.toolUseId,W.id);return A},[Qe.agents]);w.useEffect(()=>{if(!Qe.model||T&&cr.current.has(T))return;const A=OA(ht.agent,Qe.model);A&&A.id!==ht.id&&(Fn(A),T&&Ci.current[T]&&(Ci.current[T].modelId=A.id))},[Qe.model,ht.agent,ht.id,T]);const Sv=w.useMemo(()=>{const A=new Set;for(const W of j)L[W]?.busy&&A.add(W);return A},[j,L]),kv=w.useMemo(()=>j8(Qe.background),[Qe.background]),_p=w.useRef({});w.useEffect(()=>{for(const[A,W]of Object.entries(L)){const Z=_p.current[A];if(_p.current[A]=W.busy,Z&&!W.busy){Yc("done",A,UI(W.messages));const se=Pt.current.find(et=>et.id===A);if(!se)continue;const pe=Date.now(),ke=Sb(W.messages)?.text??se.latestResponse,Ne={...se,latestResponse:ke,updatedAt:pe};I(et=>{if(!et.find(Re=>Re.id===A))return et;const Ye=et.map(Re=>Re.id===A?{...Re,latestResponse:ke,updatedAt:pe}:Re);return Qs(Ye),Ye}),Rd({id:Ne.id,projectId:Ne.projectId,title:Ne.title,latestResponse:Ne.latestResponse,customTitle:Ne.customTitle,sessionId:Ne.sessionId??null,cwd:Ne.cwd??null,modelId:Ne.modelId??null,access:Ne.permission??null,createdAt:Ne.createdAt,updatedAt:Ne.updatedAt,pinned:Ne.pinned??!1,generation:Ne.generation})}}},[L,Yc]);const pr=w.useCallback(A=>{he.invoke("chat_stop",{key:Ut(A)}).catch(()=>{}),R(W=>{if(!W.has(A))return W;const Z=new Set(W);return Z.delete(A),Z})},[]),[Cv,Ev]=w.useState(0),yp=w.useCallback(()=>{ee(null),re(null),hr.current=null,a(null),H(null),P(""),V(Ou),D(!1),ri(rf,""),q(!1),Ev(A=>A+1)},[]),xp=w.useCallback(A=>{const Z=i.find(rt=>rt.primary_path&&wb(A.cwd,rt.primary_path)||(rt.paths??[]).some(Ye=>wb(A.cwd,Ye)))?.id??o;if(!Z)return;const se=(A.model?OA(A.agent,A.model):void 0)??Wu.find(rt=>rt.agent===A.agent&&!rt.flag)??Wu[0],pe=IA(A.agent,A.effort??bs),Ne=T&&(ae.current[T]?.messages.length??0)===0?T:crypto.randomUUID(),et=Vd(A.agent,$i);Ci.current[Ne]={projectId:Z,modelId:se.id,access:et},Fn(se),Po(pe),Is(et),ri(sf,pe),Fr(rt=>({...rt,[Ne]:A})),mt(Ne,rt=>({...rt,sessionId:A.sessionId,cwd:A.cwd})),pi(rt=>({...rt,[Ne]:!0})),mJ(A).then(rt=>{const Ye=gJ(rt);Ye.messages.length!==0&&mt(Ne,Re=>Re.messages.length>0?Re:{...Re,messages:Ye.messages,agents:Ye.agents})}).catch(rt=>{const Ye=rt instanceof Error?rt.message:String(rt);Fr(Re=>Re[Ne]?{...Re,[Ne]:{...Re[Ne],problem:Ye}}:Re)}).finally(()=>pi(rt=>{if(!rt[Ne])return rt;const Ye={...rt};return delete Ye[Ne],Ye})),a(Z),H(Ne),q(!1)},[i,o,T,$i,bs,mt]),Wo=w.useCallback(A=>{ee(null),re(null),hr.current=null;const W=qu(A.modelId??Ci.current[A.id]?.modelId??null)??Wu[0],Z=Vd(W.agent,A.permission??"read");if(Ci.current[A.id]={projectId:A.projectId,modelId:W.id,access:Z},!an.current.holds(Ut(A.id))&&!$s.current.has(A.id)){const se=ae.current;Wn({...se,[A.id]:{...Tc(),messages:A.messages,sessionId:se[A.id]?.sessionId??A.sessionId,cwd:se[A.id]?.cwd??A.cwd}},!0)}pi(se=>({...se,[A.id]:!0})),cn(A.id,A.seq).catch(()=>{}).finally(()=>{pi(se=>{if(!se[A.id])return se;const pe={...se};return delete pe[A.id],pe})}),a(A.projectId),H(A.id),A.modelId&&Fn(W),Is(Z),q(!1)},[cn,Wn]);w.useEffect(()=>{if(!("serviceWorker"in navigator))return;const A=W=>{const Z=W.data;Z?.type==="open-chat"&&typeof Z.conversationId=="string"&&($o.current(Z.conversationId),P5())};return navigator.serviceWorker.addEventListener("message",A),()=>navigator.serviceWorker.removeEventListener("message",A)},[]),w.useEffect(()=>{const A=()=>{document.hidden||P5().then(W=>{W&&$o.current(W)})};return A(),window.addEventListener("focus",A),window.addEventListener("pageshow",A),document.addEventListener("visibilitychange",A),()=>{window.removeEventListener("focus",A),window.removeEventListener("pageshow",A),document.removeEventListener("visibilitychange",A)}},[]),w.useEffect(()=>{const A=()=>o7(document.hidden?null:T);return A(),window.addEventListener("focus",A),window.addEventListener("blur",A),document.addEventListener("visibilitychange",A),()=>{window.removeEventListener("focus",A),window.removeEventListener("blur",A),document.removeEventListener("visibilitychange",A)}},[T]);const qo=w.useRef(!1);w.useEffect(()=>{if(qo.current)return;if(T){qo.current=!0;return}let A=null;try{A=localStorage.getItem(rf)}catch{}const W=M.current.chat??null,Z=W??A;if(!Z){qo.current=!0;return}if(D5(Z)){W&&ee(Z),qo.current=!0,M.current={};return}const se=X.find(pe=>pe.id===Z);if(!se){$&&(qo.current=!0,M.current={},W&&ee(Z));return}qo.current=!0,M.current={},W?$o.current(Z):Wo(se)},[X,T,Wo,$]);const Rl=(A,W)=>ri(A,W?"1":"0"),Mv=w.useCallback(A=>{di(!A),Rl(VT,!A)},[]),Av=w.useCallback(()=>{q(!1),_e(A=>!A)},[]),eu=w.useCallback(A=>{Ds(A),A&&(Bs(!0),zr(!1),Rl(tx,!1)),Rl(ex,A)},[]),Dl=w.useCallback(A=>{zr(A),A&&(ar(!0),Ds(!1),Rl(ex,!1)),Rl(tx,A)},[]),bp=w.useCallback(A=>{Ll(!A),Rl(KT,!A)},[]),tu=w.useCallback(()=>{_s||eu(!1)},[_s,eu]);w.useEffect(()=>{if(Gi)return;const A=setTimeout(()=>Bs(!1),YT);return()=>clearTimeout(A)},[Gi]),w.useEffect(()=>{if(ys)return;const A=setTimeout(()=>ar(!1),YT);return()=>clearTimeout(A)},[ys]);const Bl=nW(),Ol=w.useRef(null);w.useEffect(()=>{const A=Ol.current;Ol.current=o,!(!A||A===o)&&(tu(),Dl(!1),Bl())},[o,tu,Dl,Bl]);const zh=w.useCallback(A=>{Wo(A),tu(),Dl(!1),Bl()},[Wo,tu,Dl,Bl]);$o.current=A=>{const W=Pa.current.list.find(Z=>Z.id===A);W?zh(W):$?(hr.current=null,ee(A)):hr.current=A},w.useEffect(()=>{const A=hr.current;if(!A)return;const W=X.find(Z=>Z.id===A);if(!W){$&&(hr.current=null,ee(A));return}hr.current=null,zh(W)},[X,zh,$]),w.useEffect(()=>{const A=()=>{const W=UT();if(W.chat)$o.current(W.chat);else if(W.project){const Z=Pa.current.projects.find(se=>se.id===W.project||ml(se.name)===ml(W.project));Z&&(ee(null),a(Z.id),H(null))}};return window.addEventListener("popstate",A),window.addEventListener("hashchange",A),()=>{window.removeEventListener("popstate",A),window.removeEventListener("hashchange",A)}},[]);const Uo=w.useRef(new Map),[$h,Fh]=w.useState(HT),Il=w.useRef(new Map),[Hh,Vo]=w.useState(WT),iu=w.useCallback(A=>{const W=Uo.current.get(A);return W===void 0?!1:(Uo.current.delete(A),clearTimeout(W),Fh(Z=>{if(!Z.has(A))return Z;const se=new Set(Z);return se.delete(A),se.size?se:HT}),!0)},[]),Wh=w.useCallback(A=>{const W=Il.current.get(A);W!==void 0&&(Il.current.delete(A),clearTimeout(W)),zs.current.delete(A)&&(Vo(Z=>{if(!Z.has(A))return Z;const se=new Set(Z);return se.delete(A),se.size?se:WT}),I(Z=>{if(!Z.some(pe=>pe.id===A))return Z;const se=Z.filter(pe=>pe.id!==A);return Qs(se),se}))},[]),nu=w.useCallback(A=>{if(!iu(A))return;pr(A);const W=Pt.current.find(ke=>ke.id===A),Z=Date.now(),se=W?.generation??0,pe=W?{id:W.id,projectId:W.projectId,title:W.title,customTitle:W.customTitle,sessionId:W.sessionId??null,cwd:W.cwd??null,modelId:W.modelId??null,access:W.permission??null,createdAt:W.createdAt,updatedAt:W.updatedAt,pinned:W.pinned??!1,generation:se}:void 0;zI(A,Ut(A),Z,se,pe),zs.current.add(A),Vo(ke=>new Set(ke).add(A)),ws(A),L5(A,Ut(A),se,pe),window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?Wh(A):Il.current.set(A,setTimeout(()=>Wh(A),kle))},[iu,pr,ws,Wh]),qh=w.useCallback(A=>{iu(A)},[iu]),Uh=w.useCallback(A=>{if(!Pg(A,wt)){if(Uo.current.has(A)){qh(A);return}zs.current.has(A)||X.some(W=>W.id===A)&&(Uo.current.set(A,setTimeout(()=>nu(A),Xy)),Fh(W=>new Set(W).add(A)))}},[qh,nu,X,wt]),Ha=w.useCallback(A=>{const W=Pt.current.find(se=>se.id===A);if(!W)return;const Z=!W.pinned;Rd({id:W.id,projectId:W.projectId,title:W.title,latestResponse:W.latestResponse,customTitle:W.customTitle,sessionId:W.sessionId??null,cwd:W.cwd??null,modelId:W.modelId??null,access:W.permission??null,createdAt:W.createdAt,updatedAt:W.updatedAt,pinned:Z,generation:W.generation}),I(se=>{const pe=se.map(ke=>ke.id===A?{...ke,pinned:Z}:ke);return Qs(pe),pe})},[]),Wa=w.useCallback((A,W)=>{const Z=Pt.current.find(ke=>ke.id===A);if(!Z||!W.trim())return;const se=ox(W);if(Z.title===se&&Z.customTitle)return;const pe={...Z,title:se};Rd({id:pe.id,projectId:pe.projectId,title:pe.title,latestResponse:pe.latestResponse,customTitle:!0,sessionId:pe.sessionId??null,cwd:pe.cwd??null,modelId:pe.modelId??null,access:pe.permission??null,createdAt:pe.createdAt,updatedAt:pe.updatedAt,pinned:pe.pinned??!1,generation:pe.generation}),I(ke=>{const Ne=ke.map(et=>et.id===A?{...et,title:se,customTitle:!0}:et);return Qs(Ne),Ne})},[]),Lv=w.useCallback(async A=>{T5(A.id);const W=await he.invoke("chat_index_restore",{id:A.id});if(!W)throw new Error("This chat has passed its 24-hour restore window.");B5(A.id),yi.current.delete(A.id),_(Z=>Z.filter(se=>se.id!==A.id)),I(Z=>{const se=Z.find(Ne=>Ne.id===W.id),ke=[{...W,sessionId:W.sessionId??void 0,cwd:W.cwd??se?.cwd,modelId:W.modelId??void 0,permission:W.access??se?.permission,messages:se?.messages??[],seq:se?.seq,synced:!0},...Z.filter(Ne=>Ne.id!==W.id)];return Qs(ke),ke})},[]),qa=w.useRef(nu);qa.current=nu,w.useEffect(()=>{const A=()=>{for(const W of[...Uo.current.keys()])qa.current(W)};return window.addEventListener("pagehide",A),()=>window.removeEventListener("pagehide",A)},[]),w.useEffect(()=>()=>{for(const A of Il.current.values())clearTimeout(A);Il.current.clear()},[]);const Ko=w.useCallback(async(A,W=[])=>{if(pt)return;let Z=gt;if(!Z){try{Z=await Qc()}catch(Ve){re(`Could not open General: ${String(Ve.message??Ve)}`);return}if(!Z)return;a(Z.id),re(null)}const se=W.filter(Ve=>Ve.isImage).map(Ve=>Ve.path),pe=W.filter(Ve=>!Ve.isImage).map(Ve=>Ve.path);pe.length&&(A=`${A}
|
|
284
|
+
|
|
285
|
+
Files to look at:
|
|
286
|
+
${pe.map(Ve=>`- ${Ve}`).join(`
|
|
287
|
+
`)}`.trim());const ke=T??crypto.randomUUID();if(T||H(ke),A.trim()==="/clear"){const Ve=Ut(ke);ln.current.has(ke)&&he.invoke("chat_send",{key:Ve,text:A,recordUser:!1}).catch(()=>{}),he.invoke("chat_forget",{key:Ve}).catch(()=>{}),$s.current.delete(ke),ur.current.forget(ke),Tn.current.delete(ke),m5(ke),an.current.own(Ve),mt(ke,Ot=>({...Tc(),sessionId:Ot.sessionId})),I(Ot=>{const ji=Ot.map(is=>is.id===ke?{...is,messages:[],seq:0,updatedAt:Date.now()}:is);return Qs(ji),ji});return}const Ne=es.current.get(ke);if(Ne)try{await Ne}catch{return}const et=cr.current.has(ke),rt=et?yle(ae.current[ke]?.messages??[]):void 0;Ci.current[ke]={projectId:Z.id,modelId:ht.id,access:$i};const Ye=FT();mt(ke,Ve=>k5(Ve,A,W.map(Ot=>({path:Ot.path,name:Ot.name,isImage:!!Ot.isImage})),void 0,Ye)),Jc.current.add(Ye);const Re=Ve=>mt(ke,Ot=>({...Ot,busy:ln.current.has(ke)?Ot.busy:!1,messages:Ot.messages.map(ji=>ji.turnId===Ye&&!ji.echo&&!ji.takenUp?{...ji,delivery:"unknown",queueError:String(Ve.message??Ve)}:ji)}));try{const Ve=Pt.current.find(Wt=>Wt.id===ke),Ot=Ve?.cwd??ae.current[ke]?.cwd;let ji=Ot??Z.primary_path??"",is;if(!Ot&>&&ml(gt.name)!=="general")try{const Wt=await he.invoke("git_prepare_chat_workspace",{path:gt.primary_path??"",branch:F,newWorktree:K,prompt:A,chatId:ke});ji=Wt.cwd,P(Wt.branch),V(ns=>({isRepo:Wt.is_repo,current:Wt.branch,branches:Wt.branch&&!ns.branches.includes(Wt.branch)?[Wt.branch,...ns.branches]:ns.branches,isWorktree:Wt.is_worktree})),mt(ke,ns=>({...ns,cwd:ji}))}catch(Wt){is=Wt}const Un=Date.now(),Fi=M5(Ve,{...Ve??{},id:ke,projectId:Z.id,title:Ve?.title??ox(A),latestResponse:Ve?.latestResponse,customTitle:Ve?.customTitle,sessionId:ae.current[ke]?.sessionId??Ve?.sessionId,cwd:is?Ve?.cwd:ji,messages:ae.current[ke]?.messages??Ve?.messages??[],modelId:ht.id,permission:$i,createdAt:Ve?.createdAt??Un,updatedAt:Un,pinned:Ve?.pinned??!1,generation:Ve?.generation});if(I(Wt=>{const ns=[Fi,...Wt.filter($l=>$l.id!==ke)];return Qs(ns),ns}),Rd({id:Fi.id,projectId:Fi.projectId,title:Fi.title,latestResponse:Fi.latestResponse,customTitle:Fi.customTitle,sessionId:Fi.sessionId??null,cwd:Fi.cwd??null,modelId:Fi.modelId??null,access:Fi.permission??null,createdAt:Fi.createdAt,updatedAt:Fi.updatedAt,pinned:Fi.pinned??!1,generation:Fi.generation}),is){Re(is);return}if(!et&&ln.current.has(ke))try{await he.invoke("chat_send",{key:Ut(ke),text:A,images:se,turnId:Ye});return}catch(Wt){if(!String(Wt.message??Wt).includes("no such chat")){Re(Wt);return}}const Lp=et?null:ae.current[ke]?.sessionId??Pt.current.find(Wt=>Wt.id===ke)?.sessionId??null;an.current.holds(Ut(ke))||(Lp?await cn(ke,Pt.current.find(Wt=>Wt.id===ke)?.seq).catch(()=>{}):an.current.own(Ut(ke))),R(Wt=>new Set(Wt).add(ke));try{await he.invoke("chat_start",{key:Ut(ke),cwd:ji,extraDirs:Z.paths??[],env:Z.env??{},agent:ht.agent,model:ht.flag||null,access:$i,effort:bs,lite:on,images:se,prompt:A,handoff:rt??null,turnId:Ye,resume:Lp}),et&&cr.current.delete(ke)}catch(Wt){if(!et&&String(Wt.message??Wt).includes("already running"))try{await he.invoke("chat_send",{key:Ut(ke),text:A,images:se,turnId:Ye});return}catch(ns){Re(ns)}else Re(Wt);R(ns=>{const $l=new Set(ns);return $l.delete(ke),$l})}}finally{Jc.current.delete(Ye),ro(ke).catch(()=>{})}},[gt,Qc,F,K,ht,$i,bs,on,T,mt,cn,ro,pt]);w.useEffect(()=>{!Ht||Ht.id!==T||pt||(gi(null),Ko(Ht.text))},[Ht,T,pt,Ko]);const wp=w.useCallback(()=>{!T||!ln.current.has(T)||(mt(T,A=>({...A,stopping:!0})),he.invoke("chat_interrupt",{key:Ut(T)}).catch(()=>{}))},[T,mt]),Pl=w.useCallback((A,W)=>{if(!T||t!=="open")return;const Z=T;gp.current.run({chatId:Z,turnId:A,action:W,read:()=>ae.current[Z]??bg,patch:se=>mt(Z,se),invoke:se=>he.invoke(se,{key:Ut(Z),turnId:A}),refresh:async()=>{await cn(Z),await ro(Z)},reclaim:se=>Tl(Z,A,se)})},[T,t,mt,cn,ro,Tl]),Vh=w.useCallback(A=>Pl(A,"cancel"),[Pl]),Sp=w.useCallback(A=>Pl(A,"start"),[Pl]),kp=w.useCallback(A=>{if(!T)return;const W=ae.current[T];if(!W?.messages.some(se=>se.turnId===A&&(se.queueLost||se.delivery==="unknown")&&!se.echo&&!se.takenUp))return;const Z=W.messages.find(se=>se.turnId===A);Z&&Fo(se=>({...se,[T]:[...se[T]??[],zT(Z)]}))},[T]),Cp=w.useCallback(A=>{if(!T)return;const W=T;ae.current[W]?.messages.some(se=>se.turnId===A&&se.queueLost&&!se.echo&&!se.takenUp)&&he.invoke("chat_dismiss_unsent",{key:Ut(W),turnId:A}).then(se=>{se!==!1&&mt(W,pe=>({...pe,messages:pe.messages.filter(ke=>ke.turnId!==A)}))}).catch(se=>mt(W,pe=>({...pe,notices:[...pe.notices,String(se.message??se)]})))},[T,mt]),Ep=w.useCallback(A=>{if(!T||!ln.current.has(T))return!1;const W=FT();return mt(T,Z=>k5(Z,A,[],void 0,W)),he.invoke("chat_send",{key:Ut(T),text:A,turnId:W}).catch(()=>{}),!0},[T,mt]),Tv=w.useCallback(A=>{const W=ht;if(A.id===W.id)return;const Z=Vd(A.agent,$i);Fn(A),ri(wg,A.id),Z!==$i&&(Is(Z),ri(Sg,Z));const se=IA(A.agent,bs);if(se!==bs&&(Po(se),ri(sf,se)),T&&Ci.current[T]&&(Ci.current[T].modelId=A.id),!T||Qe.messages.length===0)return;const pe=T,ke=ae.current[pe]?.sessionId??Pt.current.find(Ye=>Ye.id===pe)?.sessionId;cr.current.add(pe);const Ne=(Ye,Re)=>{I(Ve=>{const Ot=Ve.map(ji=>ji.id===pe?{...ji,modelId:Ye.id,sessionId:Re}:ji);return Qs(Ot),Ot})},et=()=>{const Ye=qu(Ci.current[pe]?.modelId??null)??A;mt(pe,Re=>({...Re,sessionId:void 0,model:Ye.flag||void 0,modelAsked:!1,commands:void 0,contextTokens:void 0,contextWindow:void 0}))};if(Ne(A),et(),es.current.has(pe))return;const rt=(ln.current.has(pe)?he.invoke("chat_retarget",{key:Ut(pe)}):Promise.resolve()).then(()=>{R(Ye=>{if(!Ye.has(pe))return Ye;const Re=new Set(Ye);return Re.delete(pe),Re}),et()}).catch(Ye=>{throw cr.current.delete(pe),Fn(W),ri(wg,W.id),Is($i),ri(Sg,$i),Po(bs),ri(sf,bs),Ci.current[pe]&&(Ci.current[pe].modelId=W.id),Ne(W,ke),mt(pe,Re=>({...Re,sessionId:ke,model:W.flag||Re.model,notices:[...Re.notices,`Could not switch models: ${String(Ye?.message??Ye)}`].slice(-8)})),Ye}).finally(()=>es.current.delete(pe));es.current.set(pe,rt)},[Qe.messages.length,bs,$i,ht,T,mt]),Nv=w.useCallback(A=>{Po(A),ri(sf,A);const W=CZ(ht.agent,"effort",A);W&&Ep(W)||T&&pr(T)},[T,pr,ht.agent,Ep]),Mp=w.useCallback((A,W)=>{const Z=qu(Ci.current[A]?.modelId??null)?.agent??"claude";return SZ(Z,W)},[]),Kh=w.useCallback((A,W)=>{pr(A);const Z=Uc.current[A],se=Z?Mp(A,Z):"That access level";mt(A,pe=>({...pe,notices:[...pe.notices,`${se} needs a fresh agent: ${W}. The conversation is kept — say anything to carry on.`].slice(-8)}))},[pr,mt,Mp]);Dh.current=Kh;const ts=w.useCallback(()=>{const A=T;A&&(he.invoke("chat_restart",{key:Ut(A)}).catch(()=>pr(A)),R(W=>{if(!W.has(A))return W;const Z=new Set(W);return Z.delete(A),Z}),mt(A,W=>({...W,notices:[...W.notices,"Agent stopped. The conversation is kept — say anything to start a fresh one, with whatever MCP servers and plugins it can see now."].slice(-8)})))},[T,pr,mt]),Ua=hle({chats:L,running:j,known:z&&t==="open"}),zl=!!T&&Ua.has(T),Ap=w.useCallback(A=>{if(Is(A),ri(Sg,A),!T||(Ci.current[T]&&(Ci.current[T].access=A),!ln.current.has(T)))return;Uc.current[T]=A;const W=T;he.invoke("chat_set_access",{key:Ut(W),access:A}).catch(Z=>{const se=String(Z.message??Z);se.includes("no such chat")||Kh(W,se)})},[T,Kh]);if(t==="unauthorized")return d.jsx(JZ,{});const Yh=d.jsx(Lee,{}),Gh=d.jsxs(d.Fragment,{children:[d.jsx(OX,{count:Qe.agents.length,open:!Al&&!fr,onToggle:()=>{Ws.setOpen(!1),bp(fr||Al)}}),T&&d.jsx(ote,{count:MD(Ws.images).length,open:Ws.open,onClick:()=>Ws.setOpen(!Ws.open)}),d.jsx(bte,{count:vp.length,open:ys&&!fr,onToggle:()=>{Ws.setOpen(!1),Dl(fr||!ys)}}),d.jsx(Fee,{project:qr,open:Gi&&!fr,onToggle:()=>{Ws.setOpen(!1),eu(fr||!Gi)}}),d.jsx(Yee,{snapshot:Gt,open:Je,onToggle:()=>ot(A=>!A)}),gt&&!B&&d.jsx($T,{onClick:We}),fe&&xt&&d.jsx(Mte,{expanded:Le,onToggle:Av}),T&&d.jsxs(d.Fragment,{children:[d.jsx(Lte,{chatId:T}),!pt&&d.jsx(jJ,{deleting:$h.has(T),disabled:Hh.has(T),deleteMs:Xy,onDelete:()=>Uh(T)})]}),d.jsx(Ate,{}),d.jsxs("button",{className:"icon-btn",type:"button","aria-label":"Settings",title:"Settings",onClick:()=>Ke(!0),children:[d.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("circle",{cx:"12",cy:"12",r:"3"}),d.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.6a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),d.jsx("span",{className:"topbar-action-label",children:"Settings"})]}),d.jsxs("button",{className:"icon-btn new-chat",type:"button","aria-label":"Start new chat",title:"Start new chat",onClick:yp,children:[d.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:d.jsx("path",{d:"M12 5v14M5 12h14"})}),d.jsx("span",{className:"topbar-action-label",children:"New chat"})]}),De&&Yh]});return d.jsxs("div",{ref:Kt,className:`app ${Mt?"projects-screen":""} ${jt?"nav-shut":""} ${Le?"chat-wide":""} ${be?"focus-mode":""}`,children:[be&&d.jsx($T,{active:!0,onClick:Ze}),d.jsxs("header",{className:"topbar",children:[d.jsxs("div",{className:"topbar-leading",children:[d.jsxs("button",{className:"topbar-title",type:"button","aria-label":xt?Mt?"Chats":"Back to chats":jt?"Show chats":"Hide chats",title:xt?void 0:jt?"Show chats":"Hide chats","aria-expanded":xt?void 0:!jt,onClick:()=>{xt?(_e(!1),q(!0)):Le||Mv(jt)},disabled:xt?Mt:Le,children:[xt&&!Mt&&d.jsx("svg",{className:"topbar-back",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:d.jsx("path",{d:"m15 18-6-6 6-6"})}),!Mt&>?d.jsx(np,{project:gt,size:"medium",className:"topbar-project-avatar"}):d.jsx("img",{className:"topbar-logo",src:"./icon-192.png",alt:"","aria-hidden":"true"}),d.jsxs("span",{className:"topbar-identity",children:[d.jsx("span",{className:"topbar-name",children:Mt?"Chats":gt?.name??"OctiqFlow"}),d.jsxs("span",{className:"topbar-version",children:["v","0.1.52"]})]}),!xt&&d.jsx("span",{className:"topbar-caret","aria-hidden":"true",children:d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"m6 9 6 6 6-6"})})})]}),d.jsx(eJ,{state:t}),!Mt&&T&&d.jsx(cJ,{chatId:T,connected:t==="open",busy:Qe.busy&&!zl,waiting:(_i[T]?.length??0)+(Os[T]?.length??0)+(xs[T]?.length??0)>0})]}),d.jsx("div",{className:"topbar-actions",children:Mt?d.jsxs("button",{className:"projects-return",type:"button","aria-label":"Return to chat",title:"Return to chat",onClick:()=>q(!1),children:[d.jsx("span",{children:"Return to chat"}),d.jsx("svg",{className:"projects-return-icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"M5 12h14m-6-6 6 6-6 6"})})]}):Pe?Gh:d.jsx(Tte,{children:Gh})})]}),d.jsxs("div",{className:"body",id:"dock",children:[d.jsx($J,{projects:i,shelved:u,onShowShelved:()=>m(!0),deletedCount:v.length,onShowDeleted:()=>S(!0),conversations:Fa,chatParents:wt,getPreviewMessages:A=>an.current.holds(Ut(A))?L[A]?.messages:void 0,loadPreview:ap,currentConversation:T,running:j,busy:Sv,deleting:$h,leaving:Hh,deleteMs:Xy,onPickConversation:A=>{Wo(A)},onNewChat:yp,onDelete:Uh,onPin:Ha,onRename:Wa,onNewProject:()=>de("new"),searchChats:bv,branches:s,onResize:xt?void 0:ve.startDrag,foot:De?void 0:Yh}),d.jsx("main",{className:"main",hidden:Mt,ref:fi,children:B?d.jsxs("div",{className:"hero",role:"status",children:[d.jsx("h1",{className:"hero-title",children:"Chat unavailable"}),d.jsx("p",{children:"This chat was deleted or is no longer in this profile. Choose another chat from the chat list."})]}):d.jsxs(d.Fragment,{children:[T&&Ps[T]&&Qe.messages.length>0&&d.jsx("div",{className:"chat-sync-note",role:"status",children:"Updating conversation…"}),Qe.messages.length===0&&T&&Ps[T]?d.jsxs("div",{className:"hero is-waiting",children:[d.jsx("div",{className:"dots","aria-label":"opening"}),d.jsxs("p",{className:"hero-sub",children:["opening “",Hn[T]?.title??X.find(A=>A.id===T)?.title??"the session","”…"]})]}):Qe.messages.length===0&&pt?d.jsxs("div",{className:"hero",children:[d.jsx("h1",{className:"hero-title",children:"Agent conversation"}),d.jsx("p",{className:"hero-sub",children:"The agent's progress will appear here. Send instructions in the main chat."})]}):Qe.messages.length===0?d.jsxs("div",{className:`hero ${gt?"":"hero-start"}`,children:[d.jsx("h1",{className:"hero-title",children:gt?`What do you want to do in ${gt.name}?`:"What should we work on?"}),!gt&&ie&&d.jsx("p",{className:"hero-route-error",role:"alert",children:ie}),Qe.sessionId&&(T&&Hn[T]?d.jsxs("p",{className:"hero-sub",children:["continuing “",Hn[T].title,"” ·"," ",Yi(Hn[T].agent).name,Hn[T].problem&&d.jsxs("span",{className:"hero-warn",children:[" ","· could not read it back (",Hn[T].problem,"). Typing still carries on the session."]})]}):d.jsx("p",{className:"hero-sub",children:"continuing an earlier session"})),gt&&!pt&&d.jsx(kJ,{projectPath:qn,onResume:xp})]}):d.jsx("div",{className:"chat-body",children:d.jsx(AQ,{value:qn,children:d.jsx(XH,{value:kv,children:d.jsxs("div",{className:"chat-main",children:[d.jsx(SX,{messages:Qe.messages,hasEarlier:!!T&&ur.current.hasEarlier(T),loadingEarlier:!!T&&!!Vc[T]?.loading,earlierError:T?Vc[T]?.error:void 0,onLoadEarlier:Oh,busy:Qe.busy&&!zl,stoppedAt:Qe.stoppedAt,compactingSince:Qe.compactingSince,conversationId:T??void 0,hostName:Yi(ht.agent).name,onCancelQueued:!pt&&t==="open"?Vh:void 0,onStartQueued:!pt&&t==="open"?Sp:void 0,onRestoreUnsent:pt?void 0:kp,onDismissUnsent:pt?void 0:Cp,onSetting:pt?void 0:Ko,agentByTool:wv,onOpenAgent:Ee}),Ph&&d.jsx(TX,{run:Ph,messages:Qe.messages,onBack:()=>Ee(null)})]})})})}),(dr||Ho)&&T&&d.jsxs("div",{className:`failure ${dr?.outOfCredit||Ho?"is-quota":""}`,role:"alert",children:[dr&&!Ho&&d.jsx("button",{className:"failure-close",type:"button","aria-label":"Dismiss",onClick:()=>{BI(T,dr),mt(T,A=>({...A,failure:void 0}))},children:"×"}),d.jsx("div",{className:"failure-title",children:dr?.title??"Auto-resume scheduled"}),dr?.detail&&d.jsx("div",{className:"failure-detail",children:dr.detail}),Ho&&d.jsxs("div",{className:"auto-resume-row",children:[d.jsxs("span",{children:["OctiqFlow will resume this ",Ho.agent==="claude"?"Claude":Ho.agent==="codex"?"Codex":"Pi"," session around"," ",new Date(Ho.runAt*1e3).toLocaleString([],{dateStyle:"medium",timeStyle:"short"}),"."]}),!pt&&d.jsx("button",{className:"auto-resume-cancel",type:"button",onClick:()=>{he.invoke("chat_cancel_auto_resume",{key:Ut(T)}).catch(A=>{mt(T,W=>({...W,notices:[...W.notices,`Could not cancel auto-resume: ${String(A.message??A)}`]}))})},children:"Cancel auto-resume"})]}),dr?.link&&d.jsx("a",{className:"failure-link",href:dr.link,target:"_blank",rel:"noreferrer noopener",children:dr.link})]}),T&&mp.length>0&&d.jsx(WX,{notices:mp,onClear:()=>mt(T,A=>({...A,notices:[]}))}),T&&!pt&&d.jsx(IT,{asks:Os[T]??[],safetyBlocks:xs[T]??[],questions:_i[T]??[],onPermissionAnswered:A=>$r(W=>({...W,[T]:(W[T]??[]).filter(Z=>Z.id!==A)})),onSafetyAnswered:A=>Io(W=>({...W,[T]:(W[T]??[]).filter(Z=>Z.id!==A)})),onQuestionsAnswered:A=>Ni(W=>({...W,[T]:(W[T]??[]).filter(Z=>!A.includes(Z.id))})),onContinue:Ko}),st&&qr&&d.jsx(zoe,{project:qr,onCommandsChanged:Nn,onHide:()=>{Yt(!1),ri(Jy,"0")}},qr.id),Qt.map(A=>(Os[A]?.length??0)+(xs[A]?.length??0)>0&&d.jsxs("section",{"aria-label":"Agent safety approvals",children:[d.jsxs("p",{className:"worker-approval-context",children:["Approval for ",X.find(W=>W.id===A)?.title??"agent",". Follow-up instructions go through this main chat."]}),d.jsx(IT,{asks:Os[A]??[],safetyBlocks:xs[A]??[],questions:[],onPermissionAnswered:W=>$r(Z=>({...Z,[A]:(Z[A]??[]).filter(se=>se.id!==W)})),onSafetyAnswered:W=>Io(Z=>({...Z,[A]:(Z[A]??[]).filter(se=>se.id!==W)})),onQuestionsAnswered:()=>{},onContinue:W=>Ko(`For your worker chat ${A}:
|
|
288
|
+
|
|
289
|
+
${W}
|
|
290
|
+
|
|
291
|
+
Coordinate any follow-up through the orchestration tools.`)})]},A)),pt?d.jsx(nle,{busy:Qe.busy&&!zl,onOpenMain:vi?()=>Wo(vi):void 0}):d.jsx(BZ,{focusMode:be,session:T??void 0,focusOn:Cv,choice:ht,onChoice:Tv,started:Qe.messages.length>0,access:$i,onAccess:Ap,onSend:Ko,onStop:wp,putBack:T&&dp[T]||void 0,onPutBack:()=>T&&za(T),busy:Qe.busy&&!zl,installed:Fs,commands:kZ(ht.agent,o&&Zc[o]?.[ht.agent]||[]),onCommandOpen:$a,onReloadSkills:ht.agent==="codex"?()=>$a(!0):void 0,skillsStatus:fp[`${o}:codex`],contextTokens:Qe.contextTokens,contextWindow:Qe.contextWindow,activity:Qe.activity,turnStartedAt:Qe.turnStartedAt,turnTokens:W8(Qe),turnApprox:q8(Qe),thinking:F8(Qe),thought:H8(Qe),background:Qe.background,effort:bs,onEffort:Nv,lite:on,onLite:no,onRestart:T&&j.has(T)?ts:void 0,projects:i,projectId:gt&&ml(gt.name)!=="general"?gt.id:null,onProject:pp,branch:F,branches:U,onBranch:P,newWorktree:K,onNewWorktree:D,showWorkLocation:!T,cwd:qn,model:Qe.model,lastDurationMs:Qe.lastDurationMs,lastCostUsd:Qe.lastCostUsd,terminalOpen:st,onTerminal:gt&&!be?()=>Yt(A=>(ri(Jy,A?"0":"1"),!A)):void 0})]})}),!fr&&!Al&&Qe.agents.length>0&&d.jsx("aside",{className:"side",children:d.jsx(IX,{agents:Qe.agents,onOpen:Ee,onClose:()=>bp(!1)})}),to&&!fr&&qr&&d.jsx(Hee,{project:qr,open:Gi,persistent:_s,onClose:()=>eu(!1)}),fr&&T&&d.jsx(ate,{conversationKey:Ut(T),images:Ws.images,error:Ws.error,onClose:()=>Ws.setOpen(!1)},T),io&&!fr&&d.jsx(wte,{pins:vp,open:ys,busy:Qe.busy&&!zl,onClose:()=>Dl(!1)})]}),p&&d.jsx(YJ,{projects:u,onRestored:Nn,onClose:()=>m(!1)}),x&&d.jsx(XJ,{chats:v,projects:[...i,...u],onRestore:Lv,onClose:()=>S(!1)}),Me&&!gn&&d.jsx(_ee,{current:vs,onPick:lr,notify:Kc,onNotify:(A,W)=>{cp(A),up(A&&W)},projects:[...i,...u],onProject:de,onClose:()=>Ke(!1)}),Je&&d.jsx(Gee,{project:gt,coordinatorKey:T&&!pt?Ut(T):null,readOnly:pt,initialSnapshot:Gt,currentCwd:qn,onOpenChat:(A,W)=>{const Z=A.replace(/^chat:/,""),se=Pt.current.find(pe=>pe.id===Z);if(!se){if(W)throw new Error("The main chat is unavailable.");return}if(W){if(Pg(Z,wt))throw new Error("Send this decision in the main chat.");gi({id:Z,text:W})}Wo(se),ot(!1)},onClose:()=>ot(!1)}),gn&&d.jsx(lee,{project:gn==="new"?null:[...i,...u].find(A=>A.id===gn)??null,projects:[...i,...u],onChanged:Nn,onClose:()=>de(null),backToSettings:Me,onDeleted:A=>{I(W=>{const Z=W.filter(se=>se.projectId!==A);return Qs(Z),Z})}})]})}const hc=new URL(window.location.href);(hc.searchParams.has("pane")||hc.searchParams.has("side"))&&(hc.searchParams.delete("pane"),hc.searchParams.delete("side"),history.replaceState(null,"",hc.pathname+hc.search+hc.hash));wD(bD());wO.createRoot(document.getElementById("root")).render(d.jsx(w.StrictMode,{children:d.jsx(LW,{children:d.jsx(HG,{children:d.jsx(Lle,{})})})}));export{Ble as A,QV as B,Nle as C,pn as D,Se as E,Vt as F,Ba as G,_t as H,ai as I,Bo as J,Fe as K,Dle as L,rr as M,ps as N,MV as O,wR as P,jc as R,ci as S,Tr as T,Lh as W,lb as a,$le as b,Ile as c,bt as d,SS as e,zle as f,ui as g,No as h,AR as i,Ah as j,Qf as k,aR as l,Ue as m,Br as n,lv as o,jle as p,Ple as q,CR as r,UV as s,je as t,It as u,_c as v,MR as w,_h as x,yK as y,Ole as z};
|