glimmervoid 0.30.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/bin/glimmervoid.js +144 -57
- package/dist/chunks/{adapters-Dho1VSY5.js → adapters-BU74M4QZ.js} +1 -1
- package/dist/chunks/{adapters-zPDx1Xox.js → adapters-CoC18rdt.js} +56 -31
- package/dist/chunks/agent-api-cli-V_BkYhBI.js +142 -0
- package/dist/chunks/agent-api-core-B3YI8SYs.js +192 -0
- package/dist/chunks/{agent-setup-cli-B5Atxr3F.js → agent-setup-cli-D4956BfN.js} +11 -28
- package/dist/chunks/backoff-DjVpfHk7.js +14 -0
- package/dist/chunks/child-process-safe-B3zcPdFM.js +2 -0
- package/dist/chunks/{child-process-safe-DRGsp0TE.js → child-process-safe-DDELk9XC.js} +3 -2
- package/dist/chunks/coerce-NSst8oRP.js +32 -0
- package/dist/chunks/{contracts-DGkKNh9W.js → config-CZ4H51D0.js} +374 -1684
- package/dist/chunks/{config-store-mm7MgzoL.js → config-store-BVtdHkDK.js} +594 -329
- package/dist/chunks/config-store-Cp62jN1O.js +2 -0
- package/dist/chunks/contracts-DXujp-Zn.js +2131 -0
- package/dist/chunks/git-version-CrLW4a6r.js +58 -0
- package/dist/chunks/{grok-DuU8xVLZ.js → grok-C4lzPFEg.js} +24 -21
- package/dist/chunks/{hook-relay-core-BHfYFnYV.js → hook-relay-core-DA_bz2KA.js} +10 -5
- package/dist/chunks/{hook-tools-pSJia7ks.js → hook-tools-UX2fmt81.js} +3 -5
- package/dist/chunks/{ingest-editor-core-BuI1gMF_.js → ingest-editor-core-vR6Wv6bP.js} +24 -13
- package/dist/chunks/json-core-dfa_7Fak.js +23 -0
- package/dist/chunks/json-file-oEH9vt-0.js +352 -0
- package/dist/chunks/knowledge-graph-cli-Bjy9_kv5.js +1354 -0
- package/dist/chunks/{loopback-post-C7C22eYi.js → loopback-post-DepQfdcM.js} +40 -26
- package/dist/chunks/{main-CuIZQPhZ.js → main-DSbpYn2Y.js} +27880 -19139
- package/dist/chunks/{node-pty-preflight-CK1knGIR.js → node-pty-preflight-C8QIlrtU.js} +4 -6
- package/dist/chunks/{pair-cli-w-gCAF-1.js → pair-cli-CKn-wUw9.js} +4 -3
- package/dist/chunks/paths-CeJl2Vcg.js +55 -0
- package/dist/chunks/{remote-config-C2ytQwrs.js → remote-config-DP44Ybt9.js} +37 -41
- package/dist/chunks/{rtk-hook-core-Bl6gYHPN.js → rtk-hook-core-BmEz2aq9.js} +3 -5
- package/dist/chunks/rtk-resolver-CIVLE_xk.js +2 -0
- package/dist/chunks/{rtk-resolver-CLo-gZzw.js → rtk-resolver-jJxy_Mrt.js} +2 -2
- package/dist/chunks/{runtime-paths-Ci_ksSkj.js → runtime-paths-BPoxENmK.js} +2 -6
- package/dist/chunks/runtime-paths-DU5jBEEO.js +2 -0
- package/dist/chunks/{sandbox-deps-Dd5-kZnf.js → sandbox-deps-DuaNFq7n.js} +16 -13
- package/dist/chunks/sandbox-proxy-core-hnQgKR0T.js +27 -0
- package/dist/chunks/{session-Cez8aIWg.js → session-B8fJb_Or.js} +25 -2
- package/dist/chunks/text-DoirglWV.js +21 -0
- package/dist/chunks/timer-deps-u2DAQLok.js +15 -0
- package/dist/chunks/{visions-cli-BXQFIBCX.js → visions-cli-BhFdym5n.js} +1 -1
- package/dist/chunks/{visions-setup-CvVnOe1r.js → visions-setup-CfgNHiG3.js} +20 -357
- package/dist/client/assets/index-C_XKsDFx.css +1 -0
- package/dist/client/assets/index-CoqWjYxP.js +254 -0
- package/dist/client/fonts/CommitMono-OFL.txt +92 -0
- package/dist/client/fonts/commit-mono-400-italic.woff2 +0 -0
- package/dist/client/fonts/commit-mono-400-regular.woff2 +0 -0
- package/dist/client/fonts/commit-mono-700-italic.woff2 +0 -0
- package/dist/client/fonts/commit-mono-700-regular.woff2 +0 -0
- package/dist/client/index.html +7 -24
- package/dist/client/octicons-LICENSE.txt +21 -0
- package/dist/scripts/postinstall-path-check.js +1 -1
- package/dist/server/index.js +3 -3
- package/dist/session/command-hook-relay.js +1 -1
- package/dist/session/hook-relay.js +3 -3
- package/dist/session/hook-tool-relay.js +2 -2
- package/dist/session/sandbox-open-launcher.js +79 -0
- package/dist/session/statusline-relay.js +8 -18
- package/dist/session/visions-relay.js +20 -11
- package/package.json +4 -1
- package/dist/chunks/agent-api-cli-D0MmtEdz.js +0 -71
- package/dist/chunks/agent-api-core-Dz0r21y9.js +0 -103
- package/dist/chunks/child-process-safe-DvQjXsgz.js +0 -2
- package/dist/chunks/config-store-CC8T3okC.js +0 -2
- package/dist/chunks/ingest-core-DWI1Mbu4.js +0 -342
- package/dist/chunks/rtk-resolver-CMQAidlI.js +0 -2
- package/dist/chunks/runtime-paths-JLrZ3wyi.js +0 -2
- package/dist/client/assets/index-B1MFijjb.css +0 -1
- package/dist/client/assets/index-CU1iPPdn.js +0 -249
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=3e4;function t(t,n=Math.random){let r=Math.min(500*2**(typeof t==`number`&&Number.isFinite(t)&&t>0?Math.floor(t):0),e);return Math.round(r*(.5+.5*n()))}var n=0,r=1,i=1e4;function a(e){return typeof e!=`number`||!Number.isFinite(e)?!1:e>=i}function o({hasSocket:e,readyState:t,retryPending:i,connectingAgeMs:o=0,hiddenForMs:s}){return i?`retry-now`:!e||a(s)?`connect`:t===n?o>1e4?`connect`:`wait`:t===r?`probe`:`connect`}function s(e){return e===`https:`?`wss:`:`ws:`}function c(e,t){return`${s(e?.protocol)}//${e.host}${t}`}var l=``,u=null;function d(){return l}function f(){return l?Promise.resolve(l):u||(u=fetch(`/control-token`,{credentials:`same-origin`,cache:`no-store`}).then(e=>e.ok?e.json():null).then(e=>{let t=e?.token;return l=typeof t==`string`?t:``,l}).catch(()=>``).finally(()=>{u=null}),u)}function p(){l=``}function m(e){return l?`${e}${e.includes(`?`)?`&`:`?`}token=${encodeURIComponent(l)}`:e}function h(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function g(e,t=`|`){return e.map(e=>ge(e)).join(t)}function _(e,t){return typeof t==`bigint`?t.toString():t}var v=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function y(e){return new v(e)}function b(e){return e==null}function x(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ee(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function te(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ne(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function re(e){return ne(e._zod.def)??e._zod.def.shape}function ie(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return te(this,t,e),e},enumerable:!0,configurable:!0})}function S(e,t,n){t in e?te(e,t,n):e[t]=n}function ae(e,t,n,r){let i=re(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?ie(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):S(e,a,r?r(n.value,a):n.value))}}function oe(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?ie(e,n,()=>t[n]):S(e,n,r.value))}}function se(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ce(e){return JSON.stringify(e)}function le(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var C=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var T=y(()=>{if(at.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function ue(e){if(w(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return w(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function de(e){return ue(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var fe=new Set([`string`,`number`,`symbol`]),pe=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function me(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function he(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function E(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ge(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function _e(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var ve={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ye={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function be(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return ae(i,e,xe(e,t)),he(e,se(n,{shape:i,checks:[]}))}function xe(e,t){let n=re(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Se(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(xe(e,t)),a={};return ae(a,e,Reflect.ownKeys(re(e)).filter(e=>!i.has(e))),he(e,se(n,{shape:a,checks:[]}))}function Ce(e,t){if(!ue(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=re(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return he(e,se(e._zod.def,{shape:we(e,t)}))}function we(e,t){let n={};return ae(n,e,Reflect.ownKeys(re(e))),oe(n,t),n}function Te(e,t){if(!ue(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return he(e,se(e._zod.def,{shape:we(e,t)}))}function Ee(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return ae(n,e,Reflect.ownKeys(re(e))),ae(n,t,Reflect.ownKeys(re(t))),he(e,se(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function De(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(xe(t,n)):void 0,o={};return ae(o,t,Reflect.ownKeys(re(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),he(t,se(t._zod.def,{shape:o,checks:[]}))}function Oe(e,t,n){let r=n?new Set(xe(t,n)):void 0,i={};return ae(i,t,Reflect.ownKeys(re(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),he(t,se(t._zod.def,{shape:i}))}function ke(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ae(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function je(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Me(e){return typeof e==`string`?e:e?.message}function Ne(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Pe(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Me(e.inst?._zod.def?.error?.(e))??Me(a?.(e))??Me(t?.error?.(e))??Me(n.customError?.(e))??Me(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var Fe=/[\uD800-\uDBFF]/;function Ie(e){let t=e.length;if(!Fe.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Le(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Re(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function ze(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Be(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):We(e,n,r.value)}}function Ve(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function He(e,t,n){return Ve(e,t,n,!1)}function Ue(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Ve(this,n,r(this))},set(e){Ve(this,n,e)}})}return t}function We(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ve(this,t,n.bind(this))},set(e){Ve(this,t,e)}})}function Ge(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Ke,qe=!1,Je={configurable:!0,get(){qe=!0}};function Ye(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Ke!==e._zod){Ke=void 0;return}Ke=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Je);let e=qe;qe=!1;try{let r=n(this);return qe?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),qe||=e,r}catch(n){throw delete this[t],qe||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Xe(e,t,n,r){let i=Ge(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var Ze=`~constantCatch`;function Qe(e){let t=()=>e;return t[Ze]=!0,t}var $e,et={value:void 0,enumerable:!1},tt=`captureStackTrace`in Error?Error:null;function nt(e){let t=tt;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return tt=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function D(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){et.value=new a(r);try{Object.defineProperty(n,"_zod",et)}finally{et.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Be(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?nt(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var rt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},it=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};($e=globalThis).__zod_globalConfig??($e.__zod_globalConfig={});var at=globalThis.__zod_globalConfig;function ot(e){return e&&Object.assign(at,e),at}function st(){let e=this._zod;return e.message??=JSON.stringify(e.def,_,2),e.message}function ct(e){this._zod.message=e}var lt={get:st,set:ct,enumerable:!0,configurable:!0},ut={value:void 0,enumerable:!1},dt=new WeakSet([Object.prototype,Error.prototype]),ft=(e,t)=>{e.name=`$ZodError`,ut.value=t,Object.defineProperty(e,"issues",ut),ut.value=void 0,Object.defineProperty(e,"message",lt);let n=Object.getPrototypeOf(e);dt.has(n)||(dt.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},pt=D(`$ZodError`,ft);D(`$ZodError`,ft,void 0,{Parent:Error});function mt(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function ht(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?mt(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function gt(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function _t(e,t){return{callee:t?.callee??e,Err:t?.Err}}var vt=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new rt;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Pe(e,o,ot())));throw C(n,a?.callee??t),n}return s.value};return t},yt=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Pe(e,o,ot())));throw C(n,a?.callee??t),n}return s.value};return t},bt=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new rt;return a.issues.length?xt(e,a.issues,i):{success:!0,data:a.value}};function xt(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Pe(e,n,ot()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var St=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?xt(e,a.issues,i):{success:!0,data:a.value}},Ct=Symbol.for(`zod.compile.invalid`),wt=Symbol.for(`zod.compile.fallback`),Tt=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Ct)return!0;if(r.definite===!0&&n===void 0)return!1}return Et(e,t,n)});function Et(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[wt]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new rt;return a.issues.length===0}var Dt=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Ot=e=>{let t=vt(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,_t(n,a))};return n},kt=e=>{let t=vt(e),n=(e,r,i,a)=>t(e,r,i,_t(n,a));return n},At=e=>{let t=yt(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,_t(n,a))};return n},jt=e=>{let t=yt(e),n=async(e,r,i,a)=>await t(e,r,i,_t(n,a));return n},Mt=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return bt(e)(t,n,i)},Nt=e=>(t,n,r)=>bt(e)(t,n,r),Pt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return St(e)(t,n,i)},Ft=e=>async(t,n,r)=>St(e)(t,n,r),It=/^[cC][0-9a-z]{6,}$/,Lt=/^[0-9a-z]+$/,Rt=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,zt=/^[0-9a-vA-V]{20}$/,Bt=/^[A-Za-z0-9]{27}$/,Vt=/^[a-zA-Z0-9_-]{21}$/;function Ht(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Ut=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Wt=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Gt=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Kt=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,qt=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Jt(){return new RegExp(qt,`u`)}var Yt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Xt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Zt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Qt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,eee=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tee=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,nee=/^https?$/,ree=/^\+[1-9]\d{6,14}$/,$t=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function iee(e){return RegExp(`^${e}$`)}var aee=iee($t);function en(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function tn(e){return RegExp(`^${en(e)}$`)}function nn(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${en({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${en({precision:e.precision})}`:n;return RegExp(`^${$t}T(?:${r})$`)}var rn=/^[\s\S]{0,}$/,an=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},on=/^-?\d+$/,sn=/^-?\d+(?:\.\d+)?$/,cn=/^(?:true|false)$/i,ln=/^[^A-Z]*$/,oee=/^[^a-z]*$/,un=D(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),dn=e=>{let t=e.value;return!b(t)&&t.length!==void 0},fn={number:`number`,bigint:`bigint`,object:`date`},pn=D(`$ZodCheckLessThan`,(e,t)=>{un.init(e,t);let n=fn[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:fn[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),mn=D(`$ZodCheckGreaterThan`,(e,t)=>{un.init(e,t);let n=fn[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:fn[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hn=D(`$ZodCheckMultipleOf`,(e,t)=>{un.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):ee(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),gn=D(`$ZodCheckNumberFormat`,(e,t)=>{un.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ve[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),_n=D(`$ZodCheckMaxLength`,(e,t)=>{var n;un.init(e,t),(n=e._zod.def).when??(n.when=dn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Ie(r):i)<=t.maximum)return;let a=Le(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),vn=D(`$ZodCheckMinLength`,(e,t)=>{var n;un.init(e,t),(n=e._zod.def).when??(n.when=dn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Ie(r):i)>=t.minimum)return;let a=Le(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),yn=D(`$ZodCheckLengthEquals`,(e,t)=>{var n;un.init(e,t),(n=e._zod.def).when??(n.when=dn),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Ie(r):i;if(a===t.length)return;let o=Le(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),bn=D(`$ZodCheckStringFormat`,(e,t)=>{var n,r;un.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),xn=D(`$ZodCheckRegex`,(e,t)=>{bn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Sn=D(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ln,bn.init(e,t)}),Cn=D(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=oee,bn.init(e,t)}),wn=D(`$ZodCheckIncludes`,(e,t)=>{un.init(e,t);let n=me(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Tn=D(`$ZodCheckStartsWith`,(e,t)=>{un.init(e,t);let n=RegExp(`^${me(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),En=D(`$ZodCheckEndsWith`,(e,t)=>{un.init(e,t);let n=RegExp(`.*${me(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Dn=D(`$ZodCheckOverwrite`,(e,t)=>{un.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),On=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
2
|
-
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
3
|
-
`)}\n};`)(...Object.values(this.closed))}},kn={major:4,minor:6,patch:5},An=D(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=kn;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=ke(t),a;for(let o of n){if(o._zod.def.when){if(Ae(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new rt;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Ne(t.issues,n,e),i||=ke(t,n))});else{if(t.issues.length===n)continue;Ne(t.issues,n,e),i||=ke(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(ke(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new rt;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new rt;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return He(this,`~standard`,Nn(this))},set"~standard"(e){Ve(this,`~standard`,e)}}),jn=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Pe(e,t,ot()))}:{value:e.value};async function Mn(e,t){let n={async:!0};return jn(await e._zod.run({value:t,issues:[]},n),n)}function Nn(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return jn(r,n)}catch{}return Mn(e,t)},vendor:`zod`,version:1}}var Pn=D(`$ZodString`,(e,t)=>{An.init(e,t),e._zod.pattern=t.pattern??rn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Fn=D(`$ZodStringFormat`,(e,t)=>{bn.init(e,t),Pn.init(e,t)}),see=D(`$ZodGUID`,(e,t)=>{t.pattern??=Wt,Fn.init(e,t)}),cee=D(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Gt(e)}else t.pattern??=Gt();Fn.init(e,t)}),lee=D(`$ZodEmail`,(e,t)=>{t.pattern??=Kt,Fn.init(e,t)});function In(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function uee(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?In(e)||2:dee(e,t)}function dee(e,t){if(!t.normalize&&t.protocol?.source===nee.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var fee=/[\t\n\r]/g;function Ln(e){return e.replace(fee,``)}function pee(e,t){return t.lastIndex=0,t.test(e.hostname)}function Rn(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var zn=D(`$ZodURL`,(e,t)=>{Fn.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=uee(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Ln(r);return}t.hostname&&!pee(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Rn(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Ln(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Bn=D(`$ZodEmoji`,(e,t)=>{t.pattern??=Jt(),Fn.init(e,t)}),Vn=D(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Vt:Ht(t.length),Fn.init(e,t)}),Hn=D(`$ZodCUID`,(e,t)=>{t.pattern??=It,Fn.init(e,t)}),Un=D(`$ZodCUID2`,(e,t)=>{t.pattern??=Lt,Fn.init(e,t)}),Wn=D(`$ZodULID`,(e,t)=>{t.pattern??=Rt,Fn.init(e,t)}),Gn=D(`$ZodXID`,(e,t)=>{t.pattern??=zt,Fn.init(e,t)}),Kn=D(`$ZodKSUID`,(e,t)=>{t.pattern??=Bt,Fn.init(e,t)}),qn=D(`$ZodISODateTime`,(e,t)=>{t.pattern??=nn(t),Fn.init(e,t)}),Jn=D(`$ZodISODate`,(e,t)=>{t.pattern??=aee,Fn.init(e,t)}),Yn=D(`$ZodISOTime`,(e,t)=>{t.pattern??=tn(t),Fn.init(e,t)}),Xn=D(`$ZodISODuration`,(e,t)=>{t.pattern??=Ut,Fn.init(e,t)}),Zn=D(`$ZodIPv4`,(e,t)=>{t.pattern??=Yt,Fn.init(e,t)}),Qn=/^[0-9a-fA-F:.]+$/;function $n(e){return Qn.test(e)?In(`http://[${e}]`):!1}var er=D(`$ZodIPv6`,(e,t)=>{t.pattern??=Xt,Fn.init(e,t),e._zod.check=n=>{$n(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),tr=D(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Zt,Fn.init(e,t)});function nr(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:$n(n)}var rr=D(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Qt,Fn.init(e,t),e._zod.check=n=>{nr(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function ir(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var ar=/^[0-9a-zA-Z+/]*={0,2}$/,or=D(`$ZodBase64`,(e,t)=>{t.pattern??=ar,Fn.init(e,t),e._zod.check=n=>{ir(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),sr=/^[A-Za-z0-9_-]*$/;function cr(e){if(!sr.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ir(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var lr=D(`$ZodBase64URL`,(e,t)=>{t.pattern??=sr,Fn.init(e,t),e._zod.check=n=>{cr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ur=D(`$ZodE164`,(e,t)=>{t.pattern??=ree,Fn.init(e,t)});function dr(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var fr=D(`$ZodJWT`,(e,t)=>{Fn.init(e,t),e._zod.check=n=>{dr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),pr=D(`$ZodNumber`,(e,t)=>{An.init(e,t),e._zod.pattern=sn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),mr=D(`$ZodNumberFormat`,(e,t)=>{gn.init(e,t),pr.init(e,t)}),hr=D(`$ZodBoolean`,(e,t)=>{An.init(e,t),e._zod.pattern=cn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),gr=D(`$ZodUnknown`,(e,t)=>{An.init(e,t),e._zod.parse=e=>e}),_r=D(`$ZodNever`,(e,t)=>{An.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function vr(e,t,n){e.issues.length&&t.issues.push(...je(n,e.issues)),t.value[n]=e.value}var yr=D(`$ZodArray`,(e,t)=>{An.init(e,t);let n=at.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>vr(t,r,e)));else if(vr(c,r,e),s&&c.issues.length!==0&&ke(c))break}return o.length?Promise.all(o).then(()=>r):r}});function br(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...je(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var xr=[];function Sr(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:xr,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=_e(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Cr(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(ke(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>br(e,n,i,t,d,f))):br(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var wr=D(`$ZodObject`,(e,t)=>{An.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=y(()=>Sr(t));Ye(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||te(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=w,o=t.catchall,s,c=at.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(ke(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>br(n,t,e,r,a,o))):br(s,t,e,r,a,o)}return o?Cr(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Tr=D(`$ZodObjectJIT`,(e,t)=>{wr.init(e,t);let n=e._zod.parse,r=y(()=>Sr(t)),i=at.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new On([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
4
|
-
let ${e}_ab = false;
|
|
5
|
-
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
6
|
-
const iss = ${e}.issues[i];
|
|
7
|
-
iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
|
|
8
|
-
payload.issues.push(iss);
|
|
9
|
-
if (iss.continue !== true) ${e}_ab = true;
|
|
10
|
-
}
|
|
11
|
-
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
12
|
-
payload.value = newResult;
|
|
13
|
-
return payload;
|
|
14
|
-
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:ce(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
|
|
15
|
-
const ${n}_present = ${i};
|
|
16
|
-
if (!${n}.issues.length || ${n}_present) {
|
|
17
|
-
if (${n}.issues.length) {${c(n,r)}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (${e}) {
|
|
21
|
-
newResult[${r}] = ${n}.value;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
`)}else f?(o.write(`
|
|
26
|
-
if (${n}.issues.length) {${c(n,r)}
|
|
27
|
-
}
|
|
28
|
-
`),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
|
|
29
|
-
if (${n}.value !== undefined || ${i}) {
|
|
30
|
-
newResult[${r}] = ${n}.value;
|
|
31
|
-
}
|
|
32
|
-
`)):o.write(`
|
|
33
|
-
const ${n}_present = ${i};
|
|
34
|
-
if (${n}.issues.length) {${c(n,r)}
|
|
35
|
-
}
|
|
36
|
-
if (!${n}_present && !${n}.issues.length) {
|
|
37
|
-
payload.issues.push({
|
|
38
|
-
code: "invalid_type",
|
|
39
|
-
expected: "nonoptional",
|
|
40
|
-
input: undefined,
|
|
41
|
-
path: [${r}]
|
|
42
|
-
});
|
|
43
|
-
if (ctx && ctx.abortEarly) {
|
|
44
|
-
payload.value = newResult;
|
|
45
|
-
return payload;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (${n}_present) {
|
|
50
|
-
newResult[${r}] = ${n}.value;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=w,c=!at.jitless,l=c&&T.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Cr([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Er(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!ke(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Pe(e,r,ot())))}),t)}var Dr=D(`$ZodUnion`,(e,t)=>{An.init(e,t),Ye(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),Ye(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Ye(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),Ye(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>x(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Er(t,r,e,i)):Er(o,r,e,i)}});function Or(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var kr=D(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Dr.init(e,t);let n=e._zod.parse;Ye(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||te(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=ne(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=y(()=>Or(t));e._zod.parse=(i,a)=>{let o=i.value;if(!w(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),Ar=D(`$ZodIntersection`,(e,t)=>{An.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Mr(e,t,n)):Mr(e,i,a)}});function jr(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ue(e)&&ue(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=jr(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=jr(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Mr(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=jr(t.value,n.value);if(!c.valid){if(ke(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Nr=D(`$ZodRecord`,(e,t)=>{An.init(e,t);let n=at.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!ue(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Pe(e,i,ot())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...je(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...je(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&sn.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>Pe(e,i,ot())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...je(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...je(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Pr=D(`$ZodEnum`,(e,t)=>{An.init(e,t);let n=h(t.entries),r=new Set(n);e._zod.values=r,Ye(e,`pattern`,e=>{let t=h(e.def.entries).filter(e=>fe.has(typeof e));return RegExp(t.length?`^(${t.map(e=>me(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Fr=D(`$ZodLiteral`,(e,t)=>{An.init(e,t);let n=new Set(t.values);e._zod.values=n,Ye(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?me(e):e?me(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Ir=D(`$ZodTransform`,(e,t)=>{An.init(e,t),e._zod.optin=`optional`,at.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new it(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new rt;return n.value=i,n}});function Lr(e,t){return e.value=t.issues.length?void 0:t.value,e}var Rr=D(`$ZodOptional`,(e,t)=>{An.init(e,t),Ye(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,Ye(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),Ye(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${x(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Lr(e,t)):Lr(e,r)}return t.innerType._zod.run(e,n)}}),zr=D(`$ZodExactOptional`,(e,t)=>{Rr.init(e,t),Ye(e,`values`,e=>e.def.innerType._zod.values),Ye(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Br=D(`$ZodNullable`,(e,t)=>{An.init(e,t),Ye(e,`optin`,e=>e.def.innerType._zod.optin),Ye(e,`optout`,e=>e.def.innerType._zod.optout),Ye(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${x(t.source)}|null)$`):void 0}),Ye(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Vr=D(`$ZodDefault`,(e,t)=>{An.init(e,t),e._zod.optin=`defaulted`,Ye(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Hr(e,t)):Hr(r,t)}});function Hr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ur=D(`$ZodPrefault`,(e,t)=>{An.init(e,t),e._zod.optin=`defaulted`,Ye(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Wr=D(`$ZodNonOptional`,(e,t)=>{An.init(e,t),Ye(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Gr(t,e)):Gr(i,e)}});function Gr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Kr(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Pe(e,r,ot()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var qr=D(`$ZodCatch`,(e,t)=>{An.init(e,t),Ye(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),Ye(e,`optout`,e=>e.def.innerType._zod.optout),Ye(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Kr(e,r,t,n)):Kr(e,r,t,n)}}),Jr=D(`$ZodPipe`,(e,t)=>{An.init(e,t),Ye(e,`values`,e=>e.def.in._zod.values),Ye(e,`optin`,e=>e.def.in._zod.optin),Ye(e,`optout`,e=>e.def.out._zod.optout),Ye(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Yr(e,t.in,n)):Yr(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Yr(e,t.out,n)):Yr(r,t.out,n)}});function Yr(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Xr=D(`$ZodPreprocess`,(e,t)=>{Jr.init(e,t)}),Zr=D(`$ZodReadonly`,(e,t)=>{An.init(e,t),Ye(e,`propValues`,e=>e.def.innerType._zod.propValues),Ye(e,`values`,e=>e.def.innerType._zod.values),Ye(e,`optin`,e=>e.def.innerType?._zod?.optin),Ye(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Qr):Qr(r)}});function Qr(e){return e.memo||(e.value=Object.freeze(e.value)),e}function $r(e){let t=e._zod.def,n=t.pattern,r=!!t.format?.includes(`int`),i,a;for(let e of t.checks??[]){let t=e._zod.def;t.pattern&&(n=t.pattern),r||=!!t.format?.includes(`int`);let o=t.minimum??t.length,s=t.maximum??t.length;o!==void 0&&(i===void 0||o>i)&&(i=o),s!==void 0&&(a===void 0||s<a)&&(a=s)}if(n)return n.source;if(i!==void 0&&a!==void 0&&i>a)return`(?!)`;if(i!==void 0||a!==void 0)return an({minimum:i,maximum:a}).source;let o=e._zod.pattern;return(r&&o===sn?on:o)?.source}function ei(e){let t=e._zod.def,n=e._zod.pattern?.source,r=t.innerType??e._zod.innerType;if(r){let e=r._zod.pattern?.source,t=ei(r);return n&&e&&t&&t!==e?n.replace(x(e),()=>x(t)):n}if(t.options){let e=t.options.map(ei);if(e.every(Boolean))return`^(${e.map(e=>x(e)).join(`|`)})$`}return $r(e)}var ti=D(`$ZodTemplateLiteral`,(e,t)=>{An.init(e,t);let n=[];for(let e of t.parts)if(typeof e==`object`&&e){let t=ei(e);if(!t)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);n.push(x(t))}else if(e===null||pe.has(typeof e))n.push(me(`${e}`));else throw Error(`Invalid template literal part: ${e}`);e._zod.pattern=RegExp(`^${n.join(``)}$`),e._zod.parse=(n,r)=>typeof n.value==`string`?(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:`invalid_format`,format:t.format??`template_literal`,pattern:e._zod.pattern.source}),n):(n.issues.push({input:n.value,inst:e,expected:`string`,code:`invalid_type`}),n)}),ni=D(`$ZodCustom`,(e,t)=>{un.init(e,t),An.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ri(t,n,r,e));ri(i,n,r,e)}});function ri(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(ze(e))}}var ii=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},ai=`~memo`,oi=[];function si(e){return typeof e==`object`&&!!e}function ci(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var li=new WeakMap,ui=0,di=1,fi=2;function pi(e,t,n){let r=li.get(e);if(r!==void 0)return r?fi:ui;if(t.has(e))return fi;t.add(e);let i=ui,a=e=>{if(i!==fi&&e?._zod){let r=pi(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=ui;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?di:o.value?._zod?pi(o.value,t,n):ui;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=ne(c);s(e?o(e,!0):di),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?pi(r,t,!1):di);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),mi(e,i)}function mi(e,t){return t!==di&&li.set(e,t===fi),t}function hi(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var gi,_i=[],vi={alloc(e,t,n){let r=gi;if(!r)return n;gi=void 0;let i={value:n,issues:null};return r.set(t.value,i),_i.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&bi(n,e.value))throw new ii;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=pi(e,new Set,!1);if(i===ui)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===fi||r?n=!0:r=!0}let l=s.value;if(!si(l))return t(s,c);let u=c[ai];u||(u={buckets:new WeakMap,backEdges:void 0},c[ai]=u);let d;i===c?d=a:(d=hi(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...ci(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;gi=d;let p=_i.length,m=t(s,c);gi=void 0;let h=_i.length>p?_i.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?ci(e.issues):oi),e)):(h&&(h.issues=m.issues.length?ci(m.issues):oi),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function yi(){return vi}function bi(e,t){let n=e[ai]?.backEdges;return n!==void 0&&si(t)&&n.has(t)}var xi=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Re(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${ge(e.values[0])}`:`Invalid option: expected one of ${g(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${g(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Si(){return{localeError:xi()}}var Ci,wi=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ti(){return new wi}(Ci=globalThis).__zod_globalRegistry??(Ci.__zod_globalRegistry=Ti());var Ei=globalThis.__zod_globalRegistry;function Di(e){return e.checks&&=[...e.checks],e}function Oi(e,t){return new e(Di({type:`string`,...E(t)}))}function ki(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...E(t)})}function Ai(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...E(t)})}function ji(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...E(t)})}function Mi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...E(t)})}function Ni(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...E(t)})}function Pi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...E(t)})}function Fi(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...E(t)})}function Ii(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...E(t)})}function Li(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...E(t)})}function Ri(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...E(t)})}function zi(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...E(t)})}function Bi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...E(t)})}function Vi(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...E(t)})}function Hi(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...E(t)})}function Ui(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...E(t)})}function Wi(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...E(t)})}function Gi(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...E(t)})}function Ki(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...E(t)})}function qi(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...E(t)})}function Ji(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...E(t)})}function Yi(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...E(t)})}function Xi(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...E(t)})}function Zi(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...E(t)})}function Qi(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...E(t)})}function $i(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...E(t)})}function ea(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...E(t)})}function ta(e,t){return new e(Di({type:`number`,checks:[],...E(t)}))}function na(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...E(t)})}function ra(e,t){return new e({type:`boolean`,...E(t)})}function ia(e){return new e({type:`unknown`})}function aa(e,t){return new e({type:`never`,...E(t)})}function oa(e,t){return new pn({check:`less_than`,...E(t),value:e,inclusive:!1})}function sa(e,t){return new pn({check:`less_than`,...E(t),value:e,inclusive:!0})}function ca(e,t){return new mn({check:`greater_than`,...E(t),value:e,inclusive:!1})}function la(e,t){return new mn({check:`greater_than`,...E(t),value:e,inclusive:!0})}function ua(e,t){return new hn({check:`multiple_of`,...E(t),value:e})}function da(e,t){return new _n({check:`max_length`,...E(t),maximum:e})}function fa(e,t){return new vn({check:`min_length`,...E(t),minimum:e})}function pa(e,t){return new yn({check:`length_equals`,...E(t),length:e})}function ma(e,t){return new xn({check:`string_format`,format:`regex`,...E(t),pattern:e})}function ha(e){return new Sn({check:`string_format`,format:`lowercase`,...E(e)})}function ga(e){return new Cn({check:`string_format`,format:`uppercase`,...E(e)})}function _a(e,t){return new wn({check:`string_format`,format:`includes`,...E(t),includes:e})}function va(e,t){return new Tn({check:`string_format`,format:`starts_with`,...E(t),prefix:e})}function ya(e,t){return new En({check:`string_format`,format:`ends_with`,...E(t),suffix:e})}function ba(e){return new Dn({check:`overwrite`,tx:e})}function xa(e){return ba(t=>t.normalize(e))}function Sa(){return ba(e=>e.trim())}function Ca(){return ba(e=>e.toLowerCase())}function wa(){return ba(e=>e.toUpperCase())}function Ta(){return ba(e=>le(e))}function Ea(e,t,n){return new e({type:`array`,element:t,...E(n)})}function Da(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...E(n)})}function Oa(e,t){let n=ka(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(ze(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(ze(r))}},e(t.value,t)),t);return n}function ka(e,t){let n=new un({check:`custom`,...E(t)});return n._zod.check=e,n}function Aa(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&te(e,t,n[t]);return e}function ja(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Ei,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Ma(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function Na(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Na(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Aa(o.schema,c),t.io===`input`&&Ua(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Pa(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Fa(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Pa(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Pa(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
54
|
-
|
|
55
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Ia(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Ia(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var La=new Set([`type`,`properties`,`required`,`additionalProperties`]),Ra=[`oneOf`,`anyOf`];function za(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Ba(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!La.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??za(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}te(n,r,e.length===1?e[0]:Ba(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=za(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Va(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of La)if(t in e)return;let n=t.filter(e=>Ra.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Ba(t);else{let e=n[0],i=Ra.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Ba([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Aa(e,r))}function Ha(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Aa(i,s),Aa(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Ia(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Va(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Aa(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,te(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Ga(t,`input`,e.processors),output:Ga(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ua(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ua(r.element,n);if(r.type===`set`)return Ua(r.valueType,n);if(r.type===`lazy`)return Ua(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Ua(r.innerType,n);if(r.type===`intersection`)return Ua(r.left,n)||Ua(r.right,n);if(r.type===`record`||r.type===`map`)return Ua(r.keyType,n)||Ua(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ua(r.in,n)||Ua(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ua(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ua(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ua(e,n))return!0;return!!(r.rest&&Ua(r.rest,n))}return!1}var Wa=(e,t={})=>n=>{let r=ja({...n,processors:t});return Na(e,r),Fa(r,e),Ha(r,e)},Ga=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ja({...i??{},target:a,io:t,processors:n});return Na(e,o),Fa(o,e),Ha(o,e)},Ka=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},qa=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Ja=(e,t)=>{Ka(e,`minimum`,t),qa(e,`maximum`,t)},Ya=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Xa=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Za=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Qa=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},$a=(e,t)=>Ka(e,`minimum`,t.minimum),eo=(e,t)=>qa(e,`maximum`,t.maximum),to=e=>(t,n)=>{Qa(t,n.format);let[r,i]=e[n.format];Ka(t,`minimum`,r),qa(t,`maximum`,i)},no={greater_than:(e,t)=>Ka(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>qa(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Ya(e,t.value),number_format:to(ve),bigint_format:to(ye),min_length:$a,max_length:eo,length_equals:(e,t)=>Ja(e,t.length),min_size:$a,max_size:eo,size_equals:(e,t)=>Ja(e,t.size),string_format:(e,t)=>{Qa(e,t.format),t.pattern&&Xa(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Za(e,t.mime)};function ro(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)no[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ka(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ka(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&qa(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&qa(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Ya(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Za(t,i.mime);for(let e of i.patterns??[])Xa(t,e);return t}var mee={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},hee=new Map([[ar,eee],[sr,tee]]),io=e=>hee.get(e)??e,gee=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=ro(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=mee[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(io);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},_ee=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=ro(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Ma(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},vee=(e,t,n,r)=>{n.type=`boolean`},yee=(e,t,n,r)=>{n.not={}},bee=(e,t,n,r)=>{let i=e._zod.def,a=h(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},xee=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Ma(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Ma(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},See=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},Cee=(e,t,n,r)=>{Ma(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},wee=(e,t,n,r)=>{Ma(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Tee=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=ro(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Na(a.element,t,{...r,path:[...r.path,`items`]})};function ao(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ao(t.out):t.type===`catch`?ao(t.innerType):e._zod.optin}var Eee=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Ma(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)te(i.properties,e,Na(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?ao(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Na(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Dee=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Na(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Oee=(e,t,n,r)=>{let i=e._zod.def,a=Na(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Na(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function oo(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=oo(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>oo(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?sn:on).source),p):p}var so=new WeakMap;function kee(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of so.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=oo(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var Aee=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=ro(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Na(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)te(i.patternProperties,io(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Na(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=so.get(t);n||(n=[],so.set(t,n),t.deferred.push(()=>kee(t))),n.push(e)}i.additionalProperties=Na(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&ao(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},jee=(e,t,n,r)=>{let i=e._zod.def,a=Na(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Mee=(e,t,n,r)=>{let i=e._zod.def;Na(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},co=Symbol();function lo(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Ma(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),co):JSON.parse(o)}var Nee=(e,t,n,r)=>{let i=e._zod.def;Na(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=lo(i.defaultValue,e,t,n,r);o!==co&&(n.default=o)},Pee=(e,t,n,r)=>{let i=e._zod.def;Na(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=lo(i.defaultValue,e,t,n,r);o!==co&&(n._prefault=o)},Fee=(e,t,n,r)=>{let i=e._zod.def;Na(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Ma(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Iee=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Na(o,t,r);let s=t.seen.get(e);s.ref=o},Lee=(e,t,n,r)=>{let i=e._zod.def;Na(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},uo=(e,t,n,r)=>{let i=e._zod.def;Na(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},fo=new WeakSet([Object.prototype,Error.prototype]);function po(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var mo=D(`ZodError`,(e,t)=>{pt.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);fo.has(n)||(fo.add(n),po(n,`format`,e=>t=>gt(e,t)),po(n,`flatten`,e=>t=>ht(e,t)),po(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,_,2)}),po(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,_,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),ho=vt(mo),go=yt(mo),_o=bt(mo),vo=St(mo),Ree=Ot(mo),yo=kt(mo),bo=At(mo),xo=jt(mo),So=Mt(mo),Co=Nt(mo),zee=Pt(mo),Bee=Ft(mo);function wo(){at.localeError||ot(Si())}function To(){at.memoizer||ot({memoizer:yi()})}var Eo=D(`ZodType`,(e,t)=>(wo(),An.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(se(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return he(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Vs(e,t))},superRefine(e,t){return this.check(Hs(e,t))},overwrite(e){return this.check(ba(e))},optional(){return bs(this)},exactOptional(){return Ss(this)},nullable(){return ws(this)},nullish(){return bs(ws(this))},nonoptional(e){return As(this,e)},array(){return j(this)},or(e){return ds([this,e])},and(e){return Wee(this,e)},transform(e){return Ps(this,vs(e))},default(e){return Es(this,e)},prefault(e){return Os(this,e)},catch(e){return Ms(this,e)},pipe(e){return Ps(this,e)},readonly(){return Ls(this)},describe(e){let t=this.clone();return Ei.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ei.get(this);let t=this.clone();return Ei.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return He(this,`~standard`,{...Nn(this),jsonSchema:{input:Ga(this,`input`),output:Ga(this,`output`)}})},set"~standard"(e){Ve(this,`~standard`,e)},parse:function e(t,n){return ho(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await go(this,t,n,{callee:e})},safeParse(e,t){return _o(this,e,t)},async safeParseAsync(e,t){return vo(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ve(this,`spa`,e)},validate(e,t){return Tt(this,e,t)},validateAsync(e,t){return Dt(this,e,t)},encode:function e(t,n){return Ree(this,t,n,{callee:e})},decode:function e(t,n){return yo(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await bo(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await xo(this,t,n,{callee:e})},safeEncode(e,t){return So(this,e,t)},safeDecode(e,t){return Co(this,e,t)},async safeEncodeAsync(e,t){return zee(this,e,t)},async safeDecodeAsync(e,t){return Bee(this,e,t)},toJSONSchema(e){return Wa(this,{})(e)},get description(){return Ei.get(this)?.description},get _def(){return this._zod.def}}),Do=D(`_ZodString`,(e,t)=>{Pn.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gee(e,t,n,r)},Ue({format:e=>ro(e).format??null,minLength:e=>ro(e).minimum??null,maxLength:e=>ro(e).maximum??null},{regex(...e){return this.check(ma(...e))},includes(...e){return this.check(_a(...e))},startsWith(...e){return this.check(va(...e))},endsWith(...e){return this.check(ya(...e))},min(...e){return this.check(fa(...e))},max(...e){return this.check(da(...e))},length(...e){return this.check(pa(...e))},nonempty(...e){return this.check(fa(1,...e))},lowercase(e){return this.check(ha(e))},uppercase(e){return this.check(ga(e))},trim(){return this.check(Sa())},normalize(...e){return this.check(xa(...e))},toLowerCase(){return this.check(Ca())},toUpperCase(){return this.check(wa())},slugify(){return this.check(Ta())}})),Oo=D(`ZodString`,(e,t)=>{Pn.init(e,t),Do.init(e,t)},{email(e){return this.check(ki(Po,e))},url(e){return this.check(Fi(Lo,e))},jwt(e){return this.check(Xi($o,e))},emoji(e){return this.check(Ii(zo,e))},guid(e){return this.check(Ai(Fo,e))},uuid(e){return this.check(ji(Io,e))},uuidv4(e){return this.check(Mi(Io,e))},uuidv6(e){return this.check(Ni(Io,e))},uuidv7(e){return this.check(Pi(Io,e))},nanoid(e){return this.check(Li(Bo,e))},cuid(e){return this.check(Ri(Vo,e))},cuid2(e){return this.check(zi(Ho,e))},ulid(e){return this.check(Bi(Uo,e))},base64(e){return this.check(qi(Xo,e))},base64url(e){return this.check(Ji(Zo,e))},xid(e){return this.check(Vi(Wo,e))},ksuid(e){return this.check(Hi(Go,e))},ipv4(e){return this.check(Ui(Ko,e))},ipv6(e){return this.check(Wi(qo,e))},cidrv4(e){return this.check(Gi(Jo,e))},cidrv6(e){return this.check(Ki(Yo,e))},e164(e){return this.check(Yi(Qo,e))},datetime(e){return this.check(Zi(Ao,e))},date(e){return this.check(Qi(jo,e))},time(e){return this.check($i(Mo,e))},duration(e){return this.check(ea(No,e))}});function O(e){return Oi(Oo,e)}var ko=D(`ZodStringFormat`,(e,t)=>{Fn.init(e,t),Do.init(e,t)}),Ao=D(`ZodISODateTime`,(e,t)=>{qn.init(e,t),ko.init(e,t)}),jo=D(`ZodISODate`,(e,t)=>{Jn.init(e,t),ko.init(e,t)}),Mo=D(`ZodISOTime`,(e,t)=>{Yn.init(e,t),ko.init(e,t)}),No=D(`ZodISODuration`,(e,t)=>{Xn.init(e,t),ko.init(e,t)}),Po=D(`ZodEmail`,(e,t)=>{lee.init(e,t),ko.init(e,t)}),Fo=D(`ZodGUID`,(e,t)=>{see.init(e,t),ko.init(e,t)}),Io=D(`ZodUUID`,(e,t)=>{cee.init(e,t),ko.init(e,t)}),Lo=D(`ZodURL`,(e,t)=>{zn.init(e,t),ko.init(e,t)});function Ro(e){return Fi(Lo,e)}var zo=D(`ZodEmoji`,(e,t)=>{Bn.init(e,t),ko.init(e,t)}),Bo=D(`ZodNanoID`,(e,t)=>{Vn.init(e,t),ko.init(e,t)}),Vo=D(`ZodCUID`,(e,t)=>{Hn.init(e,t),ko.init(e,t)}),Ho=D(`ZodCUID2`,(e,t)=>{Un.init(e,t),ko.init(e,t)}),Uo=D(`ZodULID`,(e,t)=>{Wn.init(e,t),ko.init(e,t)}),Wo=D(`ZodXID`,(e,t)=>{Gn.init(e,t),ko.init(e,t)}),Go=D(`ZodKSUID`,(e,t)=>{Kn.init(e,t),ko.init(e,t)}),Ko=D(`ZodIPv4`,(e,t)=>{Zn.init(e,t),ko.init(e,t)}),qo=D(`ZodIPv6`,(e,t)=>{er.init(e,t),ko.init(e,t)}),Jo=D(`ZodCIDRv4`,(e,t)=>{tr.init(e,t),ko.init(e,t)}),Yo=D(`ZodCIDRv6`,(e,t)=>{rr.init(e,t),ko.init(e,t)}),Xo=D(`ZodBase64`,(e,t)=>{or.init(e,t),ko.init(e,t)}),Zo=D(`ZodBase64URL`,(e,t)=>{lr.init(e,t),ko.init(e,t)}),Qo=D(`ZodE164`,(e,t)=>{ur.init(e,t),ko.init(e,t)}),$o=D(`ZodJWT`,(e,t)=>{fr.init(e,t),ko.init(e,t)}),es=D(`ZodNumber`,(e,t)=>{pr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_ee(e,t,n,r),e.isFinite=!0},Ue({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=ro(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=ro(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=ro(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>ro(e).format??null},{gt(e,t){return this.check(ca(e,t))},gte(e,t){return this.check(la(e,t))},min(e,t){return this.check(la(e,t))},lt(e,t){return this.check(oa(e,t))},lte(e,t){return this.check(sa(e,t))},max(e,t){return this.check(sa(e,t))},int(e){return this.check(ns(e))},safe(e){return this.check(ns(e))},positive(e){return this.check(ca(0,e))},nonnegative(e){return this.check(la(0,e))},negative(e){return this.check(oa(0,e))},nonpositive(e){return this.check(sa(0,e))},multipleOf(e,t){return this.check(ua(e,t))},step(e,t){return this.check(ua(e,t))},finite(){return this}}));function k(e){return ta(es,e)}var ts=D(`ZodNumberFormat`,(e,t)=>{mr.init(e,t),es.init(e,t)});function ns(e){return na(ts,e)}var rs=D(`ZodBoolean`,(e,t)=>{hr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vee(e,t,n,r)});function A(e){return ra(rs,e)}var is=D(`ZodUnknown`,(e,t)=>{gr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function as(){return ia(is)}var os=D(`ZodNever`,(e,t)=>{_r.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yee(e,t,n,r)});function ss(e){return aa(os,e)}var Vee=D(`ZodArray`,(e,t)=>{To(),yr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tee(e,t,n,r),e.element=t.element},{min(e,t){return this.check(fa(e,t))},nonempty(e){return this.check(fa(1,e))},max(e,t){return this.check(da(e,t))},length(e,t){return this.check(pa(e,t))},unwrap(){return this.element}});function j(e,t){return Ea(Vee,e,t)}var cs=D(`ZodObject`,(e,t)=>{To(),Tr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eee(e,t,n,r),Xe(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return P(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(se(this._zod.def,{catchall:e}))},passthrough(){return this.clone(se(this._zod.def,{catchall:as()}))},loose(){return this.clone(se(this._zod.def,{catchall:as()}))},strict(){return this.clone(se(this._zod.def,{catchall:ss()}))},strip(){return this.clone(se(this._zod.def,{catchall:void 0}))},extend(e){return Ce(this,e)},safeExtend(e){return Te(this,e)},merge(e){return Ee(this,e)},pick(e){return be(this,e)},omit(e){return Se(this,e)},partial(...e){return De(ys,this,e[0])},exactPartial(...e){return De(xs,this,e[0],`exactPartial`)},required(...e){return Oe(ks,this,e[0])}});function M(e,t){return new cs({type:`object`,shape:e??{},...E(t)})}function N(e,t){return new cs({type:`object`,shape:e,catchall:ss(),...E(t)})}function ls(e,t){return new cs({type:`object`,shape:e,catchall:as(),...E(t)})}var us=D(`ZodUnion`,(e,t)=>{Dr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dee(e,t,n,r),e.options=t.options});function ds(e,t){return new us({type:`union`,options:e,...E(t)})}var Hee=D(`ZodDiscriminatedUnion`,(e,t)=>{us.init(e,t),kr.init(e,t)});function fs(e,t,n){return new Hee({type:`union`,options:t,discriminator:e,...E(n)})}var Uee=D(`ZodIntersection`,(e,t)=>{Ar.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oee(e,t,n,r)});function Wee(e,t){return new Uee({type:`intersection`,left:e,right:t})}var ps=D(`ZodRecord`,(e,t)=>{To(),Nr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Aee(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ms(e,t,n){return!t||!t._zod?new ps({type:`record`,keyType:O(),valueType:e,...E(t)}):new ps({type:`record`,keyType:e,valueType:t,...E(n)})}var hs=D(`ZodEnum`,(e,t)=>{Pr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bee(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new hs({...t,checks:[],...E(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new hs({...t,checks:[],...E(r),entries:i})}});function P(e,t){return new hs({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...E(t)})}var gs=D(`ZodLiteral`,(e,t)=>{Fr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xee(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function F(e,t){return new gs({type:`literal`,values:Array.isArray(e)?e:[e],...E(t)})}var _s=D(`ZodTransform`,(e,t)=>{To(),Ir.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wee(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new it(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(ze(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(ze(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function vs(e){return new _s({type:`transform`,transform:e})}var ys=D(`ZodOptional`,(e,t)=>{Rr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bs(e){return new ys({type:`optional`,innerType:e})}var xs=D(`ZodExactOptional`,(e,t)=>{zr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ss(e){return new xs({type:`optional`,innerType:e})}var Cs=D(`ZodNullable`,(e,t)=>{Br.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jee(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ws(e){return new Cs({type:`nullable`,innerType:e})}var Ts=D(`ZodDefault`,(e,t)=>{Vr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nee(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Es(e,t){return new Ts({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():de(t)}})}var Ds=D(`ZodPrefault`,(e,t)=>{Ur.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pee(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Os(e,t){return new Ds({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():de(t)}})}var ks=D(`ZodNonOptional`,(e,t)=>{Wr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mee(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function As(e,t){return new ks({type:`nonoptional`,innerType:e,...E(t)})}var js=D(`ZodCatch`,(e,t)=>{qr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fee(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ms(e,t){return new js({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Qe(t)})}var Ns=D(`ZodPipe`,(e,t)=>{Jr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Iee(e,t,n,r),e.in=t.in,e.out=t.out});function Ps(e,t){return new Ns({type:`pipe`,in:e,out:t})}var Fs=D(`ZodPreprocess`,(e,t)=>{Ns.init(e,t),Xr.init(e,t)}),Is=D(`ZodReadonly`,(e,t)=>{Zr.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lee(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ls(e){return new Is({type:`readonly`,innerType:e})}var Rs=D(`ZodTemplateLiteral`,(e,t)=>{ti.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>See(e,t,n,r)});function zs(e,t){return new Rs({type:`template_literal`,parts:e,...E(t)})}var Bs=D(`ZodCustom`,(e,t)=>{ni.init(e,t),Eo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cee(e,t,n,r)});function Vs(e,t={}){return Da(Bs,e,t)}function Hs(e,t){return Oa(e,t)}function Us(e,t){return new Fs({type:`pipe`,in:vs(e),out:t})}var Ws=M({attempt:k().int().positive(),limit:k().int().positive()}).refine(e=>e.attempt<=e.limit),Gs={error:O().nullable().optional(),nextAttemptAt:k().finite().nonnegative().nullable().optional(),retry:Ws.nullable().optional(),isRefreshing:A().optional(),refreshNotice:O().nullable().optional()},Ks=M({lane:P([`my-prs`,`team-review`])}),qs=M({ok:A(),error:O().optional()}),Js=2e4,Ys=4e3,Xs=524288,Zs=1e4,Qs=`ExitPlanMode`,$s=M({plan:O().min(1),planFilePath:O().min(1),agent_id:O().min(1).optional(),agent_type:O().min(1).optional()}).passthrough();M({tool_name:F(Qs),tool_input:$s,agent_id:O().min(1).optional(),agent_type:O().min(1).optional()}).passthrough(),M({plan:O(),planFilePath:O(),agentId:O().nullable(),agentType:O().nullable()}).extend({sessionId:O().min(1),revision:k().int().positive(),receivedAt:k().finite()});var ec=P(Object.freeze([`open`,`released`,`decided`,`closed`])),tc=P(Object.freeze([`approve`,`approve-accept-edits`,`revise`,`terminal`])),nc=M({heading:O().max(Ys).nullable(),comment:O().min(1).max(Ys)}),rc=M({id:O().min(1),agentId:O().nullable(),revision:k().int().positive(),decision:tc,feedback:O().max(Js).optional(),comments:j(nc).max(40).optional(),plan:O().min(1).max(Xs).optional()}),ic=M({revision:k().int().positive(),receivedAt:k().finite(),chars:k().int().nonnegative(),title:O()}),ac=M({revision:k().int().positive(),since:k().finite()}),oc=M({agentId:O().nullable(),agentType:O().nullable(),revisions:j(ic),state:ec,openRevision:ac.nullable(),approvedRevision:k().int().positive().nullable(),lastDecision:tc.nullable()});M({reviews:j(oc)});var sc=M({agentId:O().nullable(),revision:k().int().nonnegative(),plan:O(),planFilePath:O(),receivedAt:k().finite()}),cc=M({id:O(),agentId:O().nullable(),agentType:O().nullable(),revision:k().int().positive(),receivedAt:k().finite(),state:ec,lastDecision:tc.nullable(),approvedRevision:k().int().positive().nullable(),chars:k().int().nonnegative(),title:O(),hasPlan:A()}),lc=M({id:O(),agentId:O().nullable(),planFilePath:O(),changedAt:k().finite()}),uc=M({id:O(),reviews:j(oc),body:sc.nullable()});Object.freeze([`file`,`subsystem`,`co-change`,`hotspot`,`blast`,`untested`,`collision`,`link`]);var dc=O().min(1),fc=O().min(1),pc=k().int().nonnegative(),mc=j(fc).max(20),hc=P([`added`,`modified`,`deleted`,`renamed`,`untracked`]),gc=N({factId:dc,path:fc,previousPath:fc.optional(),status:hc,isCommitted:A()}),_c=N({factId:dc,agentsPath:fc,title:O(),paths:j(fc).min(1)}),vc=N({factId:dc,path:fc,partner:fc,support:pc,confidence:k().min(0).max(1)}),yc=N({factId:dc,path:fc,commitCount:pc,fixCommitCount:pc}),bc=N({factId:dc,path:fc,directDependents:mc,directDependentCount:pc,transitiveDependentCount:pc,dependentTests:mc,dependentTestCount:pc}),xc=N({factId:dc,path:fc}),Sc=N({factId:dc,path:fc,otherSessionId:O().min(1),otherSessionName:O()}),Cc=N({factId:dc,providerRepo:O().min(1),packageName:O().min(1),packageDir:O(),consumerManifest:fc,versionSpec:O(),isLocalLink:A(),providerChangedPathCount:pc,importers:mc,importerCount:pc,changedImporterCount:pc}),wc=N({name:O().min(1),root:O().min(1),sessionPathPrefix:O(),base:O().nullable(),files:j(gc),subsystems:j(_c),coChangeGaps:j(vc),hotspots:j(yc),blastRadius:j(bc),untestedFiles:j(xc),collisions:j(Sc),links:j(Cc),error:O().nullable()}),Tc=N({text:O().min(1).max(600),factIds:j(dc).min(1)}),Ec=N({factsHash:O().min(1),model:O().nullable(),claims:j(Tc).max(12)}),Dc=P([`disabled`,`pending`,`ready`,`failed`]),Oc=N({sessionId:O().min(1),sig:O().nullable(),generatedAt:k().finite(),repos:j(wc),narrative:Ec.nullable(),narratorState:Dc,error:O().min(1).optional()}),I=Object.freeze({DORMANT:`DORMANT`,INITIALIZING:`INITIALIZING`,STARTING:`STARTING`,RUNNING:`RUNNING`,WAITING:`WAITING`,IDLE:`IDLE`,COMPLETE:`COMPLETE`,DONE:`DONE`,FAILED:`FAILED`}),kc=Object.freeze({[I.DORMANT]:`Dormant`,[I.INITIALIZING]:`Preparing`,[I.STARTING]:`Starting`,[I.RUNNING]:`Working`,[I.WAITING]:`Needs Input`,[I.IDLE]:`Idle`,[I.COMPLETE]:`Complete`,[I.DONE]:`Exited`,[I.FAILED]:`Failed`}),Ac=Object.freeze({[I.DORMANT]:`○`,[I.INITIALIZING]:`◌`,[I.STARTING]:`◐`,[I.RUNNING]:`●`,[I.WAITING]:`◆`,[I.IDLE]:`◍`,[I.FAILED]:`▲`,[I.DONE]:`■`,[I.COMPLETE]:`◇`}),jc=Object.freeze([I.INITIALIZING,I.STARTING,I.RUNNING,I.WAITING,I.IDLE,I.COMPLETE]),Mc=Object.freeze([I.DONE,I.FAILED]),Nc=Object.freeze([I.WAITING,I.IDLE,I.COMPLETE]),Pc=Object.freeze({Bash:`command`,Read:`file_path`,Edit:`file_path`,MultiEdit:`file_path`,Write:`file_path`,NotebookEdit:`notebook_path`,Grep:`pattern`,Glob:`pattern`,WebFetch:`url`,WebSearch:`query`,Task:`description`,Agent:`description`,Skill:`skill`});function Fc(e){let t=e.split(/\r?\n/,1)[0]?.trim()??``;return t.length<=160?t:`${t.slice(0,157)}...`}function Ic(e,t){let n=Pc[e];if(!n||!t||typeof t!=`object`||Array.isArray(t))return null;let r=t[n];return typeof r==`string`?r:null}function Lc(e,t){let n=Ic(e,t);return n===null?``:Fc(n)}var Rc=/[\x00-\x1f\x7f-\x9f]/,zc=RegExp(`${Rc.source}|[\\p{Cf}\\u2028\\u2029]`,`u`),Bc=O().refine(e=>!Rc.test(e)).trim().max(120);M({title:O().nullable()}).strict();var Vc=P(I),Hc=M({at:k().finite().nullable(),kind:O(),reason:O().nullable()}).passthrough(),Uc=e=>!zc.test(e),Wc=M({text:O().min(1).max(300).refine(Uc),options:j(O().min(1).max(80).refine(Uc)).min(1).max(8),multiSelect:A()}),Gc=M({toolName:O().max(160),summary:O().max(160),isComplete:A(),question:Wc.nullable().optional()}),Kc=M({id:O(),name:O(),taskTitle:Bc.nullable().default(null),taskTitleIsCustom:A().default(!1),path:O(),agent:O(),state:Vc,stateSince:k(),sleeping:A(),dangerouslySkipPermissions:A(),saneYolo:A().default(!1),ephemeral:A(),isWorktree:A(),isWorkspace:A().default(!1),resumeSessionId:O().nullable(),activeAgents:k().int().nonnegative(),awaitingBackgroundTasks:A(),hasEndedTurn:A().default(!1),pendingWakeup:Hc.nullable(),pendingPromptKind:O().nullable(),pendingPromptDetail:Gc.nullable().default(null),hasPlan:A().default(!1),mergeStatus:O().nullable(),mergeReason:O().nullable(),worktreeNotice:O().nullable(),effectiveBase:O().nullable(),auditLog:j(as())}).passthrough();function qc(e,t){return!e||!t?!e&&!t:e.text===t.text&&e.multiSelect===t.multiSelect&&e.options.length===t.options.length&&e.options.every((e,n)=>e===t.options[n])}M({prompt:O({error:`prompt must be a string`}).min(1,{error:`prompt must not be empty`}).max(2e4,{error:`prompt must be at most 20000 characters`}).refine(e=>!e.trimStart().startsWith(`-`),{message:`prompt must not start with a dash, which the agent CLI would read as an option`}),name:O({error:`name must be a string`}).min(1,{error:`name must not be empty`}).max(200,{error:`name must be at most 200 characters`}).optional(),agent:O({error:`agent must be a string`}).min(1,{error:`agent must not be empty`}).max(40,{error:`agent must be at most 40 characters`}).optional()}).strict(),M({note:O({error:`note must be a string`}).min(1,{error:`note must not be empty`}).max(500,{error:`note must be at most 500 characters`})}).strict(),ds([M({ok:F(!0),pending:A()}).strict(),M({ok:F(!1),error:O()}).strict()]),M({id:Kc.shape.id,name:Kc.shape.name,agent:Kc.shape.agent,state:Kc.shape.state,ephemeral:Kc.shape.ephemeral}).strict();var Jc=4e3,Yc=M({ts:k().finite(),uuid:O().nullable(),parentUuid:O().nullable(),vendorSessionId:O().min(1),agentId:O().min(1).optional(),agentType:O().min(1).optional(),transcriptOffset:k().int().nonnegative().optional(),truncated:A().optional()}),Xc=fs(`kind`,[Yc.extend({kind:F(`prompt`),text:O()}),Yc.extend({kind:F(`expansion`),text:O(),toolUseId:O().min(1).optional()}),Yc.extend({kind:F(`thinking`),text:O()}),Yc.extend({kind:F(`assistant`),text:O()}),Yc.extend({kind:F(`tool_call`),toolUseId:O().min(1),name:O().min(1),input:as()}),Yc.extend({kind:F(`tool_result`),toolUseId:O().min(1),content:O(),isError:A(),truncated:A()}),Yc.extend({kind:F(`session`),vendor:O().min(1),transcriptPath:O().min(1),reason:O().min(1).optional()}),Yc.extend({kind:F(`notice`),text:O().max(Jc)}),Yc.extend({kind:F(`raw`),line:O().max(Jc)})]);M({transcriptPath:O().min(1),vendorSessionId:O().min(1),offset:k().int().nonnegative(),ingestedSubagentPaths:j(O().min(1)),offsetByTranscriptPath:ms(O().min(1),k().int().nonnegative()).default({}),subagentOffsetByPath:ms(O().min(1),k().int().nonnegative()).default({})});var Zc=P([`release`,`main`]),Qc=P([`idle`,`running`,`staged`,`succeeded`,`failed`,`discarded`,`interrupted`]),$c=P([`fetch`,`stage`,`install`,`link-deps`,`build`]),el=M({id:$c,status:P([`pending`,`running`,`succeeded`,`failed`]),startedAt:k().finite().nullable(),finishedAt:k().finite().nullable(),outputTail:j(O())}).strict(),tl=M({state:Qc,fromSha:O().nullable(),toSha:O().nullable(),toVersion:O().nullable(),channel:Zc,steps:j(el),activeStep:$c.nullable(),reason:O().nullable(),startedAt:k().finite().nullable(),finishedAt:k().finite().nullable(),failedAtHandOff:A().optional()}).strict(),nl=tl.pick({state:!0,activeStep:!0,reason:!0,startedAt:!0,finishedAt:!0}),L=O().regex(/^[0-9a-f]{40}$/),rl=O().regex(/^[^/]+\/[^/]+$/);M({number:k().int().positive(),title:O(),html_url:O(),draft:A().optional(),created_at:O().optional(),updated_at:O().optional(),repository_url:O(),user:M({login:O(),type:P([`User`,`Bot`])}).passthrough(),pull_request:M({}).passthrough()}).passthrough(),M({number:k().int().positive(),title:O(),body:O(),url:O(),author:M({login:O(),is_bot:A().optional()}).passthrough(),isDraft:A(),isCrossRepository:A(),baseRefName:O(),baseRefOid:L,headRefOid:L,additions:k().int().nonnegative(),deletions:k().int().nonnegative(),files:j(M({path:O(),additions:k().int().nonnegative(),deletions:k().int().nonnegative()}).passthrough())}).passthrough();var il=M({path:O(),line:k().int().positive(),side:P([`RIGHT`,`LEFT`]).default(`RIGHT`),body:O()}),al=Object.freeze({STAMP:`APPROVE`,COMMENT:`APPROVE WITH NITS`,NEEDS_YOU:`REQUEST CHANGES`}),ol=P([`APPROVE`,`APPROVE WITH NITS`,`REQUEST CHANGES`,`BLOCKED`]),Gee=Us(e=>typeof e==`string`&&Object.hasOwn(al,e)?al[e]:e,ol),sl=P([`CRITICAL`,`HIGH`,`MEDIUM`,`LOW`]),Kee=il.extend({severity:sl.optional()}),qee=M({path:O().min(1),line:k().int().positive().nullable(),side:P([`RIGHT`,`LEFT`]),severity:sl,reviewer:O().min(1),disposition:P([`ACTIONABLE`,`NIT`,`AMBIGUOUS`]).nullable(),body:O().min(1)}),cl=M({goal:O().default(``),change:O(),checked:j(O()),gaps:j(O())});M({verdict:ol,head:L,summary:O(),assessment:cl.nullable(),findings:j(qee)}),M({body:O(),commit_id:L,comments:j(M({path:O().min(1),line:k().int().positive(),side:P([`RIGHT`,`LEFT`]).default(`RIGHT`),body:O().min(1)}))});var Jee=P([`APPROVE`,`COMMENT`]),Yee=P([`APPROVED`,`CHANGES_REQUESTED`,`COMMENTED`]),ll=new Set([`APPROVED`,`CHANGES_REQUESTED`]),ul=P([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]),Xee=P([`SUCCESS`,`FAILURE`,`PENDING`,`ERROR`,`EXPECTED`]),dl={requestSource:P([`direct`,`team`]).default(`team`),isDraft:A().optional(),checksState:Xee.nullable().optional()},fl=M({login:O().min(1),state:Yee,commit:L.nullable(),isViewer:A(),submittedAt:O().nullable().optional()});function pl(e){return e.reviewDecision!==`APPROVED`||e.requeuedHead!==void 0&&e.requeuedHead===(e.liveHead??e.reviewedHead)?!1:(e.githubReviews??[]).some(e=>e.isViewer&&e.state===`APPROVED`)}M({head:L,reviews:j(fl)});var Zee=M({head:L,verdict:ol,summary:O(),body:O(),comments:j(il),wasPosted:A()}),ml=O().min(1).max(256).regex(/^[A-Za-z0-9_=-]+$/),Qee=M({addressed:A(),reason:O().trim().min(1).max(4e3)}).strict(),hl=M({id:ml,path:O(),line:k().int().positive().nullable(),isResolved:A(),viewerCanResolve:A(),comments:M({pageInfo:M({hasNextPage:A(),endCursor:O().nullable().optional()}),nodes:j(M({body:O(),author:M({login:O()}).nullable(),viewerDidAuthor:A(),createdAt:O().datetime(),url:O().url(),originalCommit:M({oid:L}).nullable()}))})});M({data:M({node:M({comments:hl.shape.comments}).nullable()}).nullable()}),M({pullRequest:M({reviewThreads:M({pageInfo:M({hasNextPage:A(),endCursor:O().nullable().optional()}),nodes:j(hl)})}).nullable()}),M({data:M({resolveReviewThread:M({thread:M({id:ml,isResolved:F(!0)})})}).nullable(),errors:j(as()).optional()});var gl=M({id:ml,path:O(),line:k().int().positive().nullable(),isResolved:A(),viewerCanResolve:A(),isNit:A(),url:O().url(),viewerComment:O().max(1500).optional(),lastReplyBody:O().max(1500).optional(),viewerCommentTruncated:A().optional(),lastReplyTruncated:A().optional(),lastReplyAuthor:O(),lastReplyAt:O().datetime(),judgement:Qee.extend({head:L,judgedAt:k().finite(),lastReplyAt:O().datetime()}).optional(),resolveError:O().optional(),resolveAttemptReplyAt:O().optional(),judgeAttempt:M({head:L,lastReplyAt:O(),retryAt:k().finite()}).optional(),unjudgeable:M({head:L,lastReplyAt:O(),reason:O().min(1)}).optional()});M({merge_base_commit:M({sha:L}),files:j(M({filename:O(),previous_filename:O().optional(),patch:O().optional()})).max(300)});var _l=M({total:k().int().nonnegative(),resolved:k().int().nonnegative()}),vl=M({...dl,key:O(),repo:rl,number:k().int().positive(),title:O(),url:O(),author:O(),tier:P([`stamp`,`full`]),reasons:j(O()),reviewedHead:L,verdict:Gee,summary:O(),assessment:cl.optional(),body:O(),comments:j(Kee),status:P([`ready`,`stale`,`posted`,`discarded`,`error`]),error:O().optional(),threads:j(gl).optional(),viewerThreads:_l.optional(),githubReviews:j(fl).optional(),reviewDecision:ul.nullable().optional(),liveHead:L.optional(),prCreatedAt:O().optional(),reviewedAt:k().finite().optional(),postedAt:k().finite().optional(),postedEvent:Jee.optional(),priorReviewedHead:L.optional(),requeuedHead:L.optional()});function $ee(e){return e.status===`posted`&&e.postedEvent===`COMMENT`}var ete=P([`approve`,`approve-only`,`comment`,`discard`,`requeue`,`resolve-thread`]),tte=M({key:O().min(1),head:L,action:ete,threadId:ml.optional(),body:O(),comments:j(il)}).refine(e=>e.action!==`resolve-thread`||e.threadId!==void 0,{message:`resolve-thread requires threadId`,path:[`threadId`]}),nte=M({key:O(),ok:A(),error:O().optional(),warning:O().optional()}),rte=M({sessionId:O().min(1),workDir:O().min(1),worktreePath:O().min(1),head:L,deadlineAt:k(),remainingAwakeMs:k().nonnegative().optional(),savedAt:k()}),yl=M({...dl,reviewDecision:ul.nullable().optional(),key:O(),repo:rl,number:k().int().positive(),title:O(),url:O(),author:O(),prCreatedAt:O().optional()}),ite=M({draft:vl.nullable(),reviewedHead:L.nullable(),inFlight:A(),skipReason:O().nullable(),handReview:yl.optional(),reviewAttempts:k().int().nonnegative().default(0),resumable:rte.nullable().optional(),reviewedAt:k().optional(),threads:j(gl).optional(),viewerThreads:_l.optional(),autoResolvedThreadIds:j(ml).optional(),githubReviews:j(fl).optional(),reviewDecision:ul.nullable().optional(),liveHead:L.optional(),requeuedHead:L.optional(),priorReview:Zee.optional(),discardedReviewHead:L.optional(),updatedAt:k().finite()});ms(O(),ite);var ate=P([`preparing`,`checkout`,`reviewing`]),ote=M({at:k().finite(),tool:O(),detail:O()}),ste=M({...dl,reviewDecision:ul.nullable().optional(),key:O(),repo:rl,number:k().int().positive(),title:O(),url:O(),author:O(),tier:P([`stamp`,`full`]),reasons:j(O()),head:L,phase:ate,startedAt:k().finite(),deadlineAt:k().finite().nullable(),toolCalls:k().int().nonnegative(),recentSteps:j(ote),prCreatedAt:O().optional(),priorReviewedHead:L.optional()}),bl=M({...Gs,type:F(`team-review-status`),ts:k().finite(),configured:A(),reason:O().nullable().optional(),drafts:j(vl),inFlight:j(ste),queued:j(yl).default([]),handReview:j(yl).default([]),team:M({org:O(),slug:O(),name:O(),avatarUrl:O()}).nullable().optional()}).passthrough(),cte=P([`merged`,`draft`,`conflicts`,`behind`,`checks-failing`,`changes-requested`,`unresolved-threads`,`checks-pending`,`needs-approval`,`ready`,`unknown`]),xl=k().int().nonnegative(),Sl=O().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*\/[A-Za-z0-9][A-Za-z0-9._-]*$/),Cl=zs([Sl,`#`,O().regex(/^[1-9][0-9]*$/)]),lte=zs([Cl,`@`,L]),wl=O().refine(e=>Cl.safeParse(e).success),Tl=O().refine(e=>lte.safeParse(e).success);fs(`outcome`,[N({outcome:F(`pushed`)}),N({outcome:P([`no-change`,`failed`,`stopped`,`timed-out`]),reason:O().min(1)})]);var El=N({outcome:P([`pushed`,`no-change`,`failed`,`stopped`,`timed-out`]),reason:O().min(1).optional(),at:k().finite()}),Dl=El.extend({key:wl,headRefOid:L,baseRefOid:L});N({keepMergeableKeys:j(wl),keepMergeableAttemptKeys:j(Tl),keepMergeableAttempts:j(Dl).default([]),mergeQueueKeys:j(wl).default([]),keepMergeablePushedHeadKeys:j(Tl).default([])});var Ol=M({repo:Sl,number:k().int().positive(),keepMergeable:A()}),kl=M({key:O(),ok:A(),error:O().optional()}),Al=kl,jl=M({repo:Sl,number:k().int().positive(),mergeWhenReady:A()}),Ml=kl,Nl=P([`MERGE`,`SQUASH`,`REBASE`]),Pl=M({path:O(),line:k().int().positive().nullable(),isOutdated:A(),url:Ro(),author:O().nullable(),excerpt:O(),commentCount:k().int().positive(),lastAuthor:O().nullable(),lastActivityAt:O()}),Fl=M({reviewer:O().nullable(),state:O(),submittedAt:O().nullable()}),Il=M({outcome:P([`rebased`,`failed`]),at:k().finite(),message:O()}),Ll=M({key:O(),repo:Sl,number:k().int().positive(),title:O(),url:Ro(),isDraft:A(),state:P([`OPEN`,`MERGED`,`CLOSED`]),createdAt:O(),mergedAt:O().nullable(),updatedAt:O(),baseRefName:O(),baseRefOid:L,headRefName:O().min(1),isCrossRepository:A(),headRefOid:L,isInMergeQueue:A(),mergeMethod:Nl,mergeable:P([`MERGEABLE`,`CONFLICTING`,`UNKNOWN`]),mergeStateStatus:O(),reviewDecision:P([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]).nullable(),checks:M({state:P([`SUCCESS`,`FAILURE`,`PENDING`,`ERROR`,`EXPECTED`]).nullable(),failing:j(O()),pendingCount:xl}),unresolvedThreads:xl,threads:j(Pl),behindBy:xl.nullable(),reviewRequests:j(M({name:O(),isTeam:A(),avatarUrl:O().nullable()})),approvals:xl,reviews:j(Fl),stage:cte,autoRebase:Il.optional(),keepMergeable:A().optional(),keepMergeableAttempt:El.optional(),isKeepMergeableFixInFlight:A().optional(),mergeQueuePosition:k().int().positive().nullable().optional(),isMergeQueueHeldForRepairPush:A().optional()}).refine(e=>e.key===`${e.repo}#${e.number}`),Rl=M({...Gs,type:F(`my-prs-status`),ts:k().finite(),configured:A(),reason:O().nullable().optional(),viewer:O().nullable(),prs:j(Ll),truncatedNote:O().nullable().optional(),isKeepMergeableEnabled:A().optional(),isMergeQueueEnabled:A().optional()}).passthrough(),zl=M({repo:Sl,number:k().int().positive(),headRefOid:L}),Bl=P([`merged`,`queued`,`auto-merge`,`unconfirmed`]),Vl=M({key:O(),ok:A(),kind:Bl.optional(),error:O().optional()}),Hl=M({__typename:F(`CheckRun`),name:O(),conclusion:O().nullable(),status:O()}),Ul=M({__typename:F(`StatusContext`),context:O(),state:O()}),Wl=M({__typename:F(`PullRequest`),id:O().regex(/^[A-Za-z0-9_=-]+$/),number:k().int().positive(),title:O(),url:Ro(),isDraft:A(),state:P([`OPEN`,`MERGED`,`CLOSED`]),createdAt:O(),mergedAt:O().nullable(),updatedAt:O(),baseRefName:O(),baseRefOid:L,headRefName:O().min(1),isCrossRepository:A(),headRefOid:L,isInMergeQueue:A(),mergeable:P([`MERGEABLE`,`CONFLICTING`,`UNKNOWN`]),mergeStateStatus:O(),reviewDecision:P([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]).nullable(),repository:M({nameWithOwner:Sl,viewerDefaultMergeMethod:Nl}),commits:M({nodes:j(M({commit:M({statusCheckRollup:M({state:P([`SUCCESS`,`FAILURE`,`PENDING`,`ERROR`,`EXPECTED`]).nullable(),contexts:M({nodes:j(ds([Hl,Ul]))})}).nullable()})}))}),reviewThreads:M({pageInfo:M({hasNextPage:A()}),nodes:j(M({isResolved:A()}))}),reviewRequests:M({nodes:j(M({requestedReviewer:fs(`__typename`,[M({__typename:F(`User`),login:O()}),M({__typename:F(`Team`),slug:O(),avatarUrl:O().nullable(),organization:M({login:O()})}),M({__typename:P([`Bot`,`Mannequin`])})]).nullable()}))}),latestOpinionatedReviews:M({nodes:j(M({state:O()}))}),latestReviews:M({nodes:j(M({state:O(),submittedAt:O().nullable(),author:M({login:O()}).nullable()}))})}),Gl=M({login:O()}).nullable();M({isResolved:A(),isOutdated:A(),path:O(),line:k().int().positive().nullable(),firstComment:M({totalCount:xl,nodes:j(M({author:Gl,bodyText:O(),url:Ro(),createdAt:O()}))}),lastComment:M({nodes:j(M({author:Gl,createdAt:O()}))})}),M({data:M({repository:M({pullRequest:M({reviewThreads:M({pageInfo:M({hasNextPage:A(),endCursor:O().nullable()}),nodes:j(as())})}).nullable()}).nullable()}),errors:j(as()).optional()}),M({data:M({repository:M({pullRequest:M({state:O(),isInMergeQueue:A(),autoMergeRequest:M({enabledAt:O().nullable()}).nullable()}).nullable()}).nullable()}),errors:j(as()).optional()}),M({data:M({open:M({issueCount:xl,nodes:j(as())}),merged:M({issueCount:xl,nodes:j(as())})}),errors:j(as()).optional()});var Kl=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,ql=/^[A-Za-z_][A-Za-z0-9_]*$/,Jl=O().regex(/^[^/\s]+\/[^/\s]+$/),Yl=k().finite(),Xl=O().min(1),Zl=Object.freeze([`CLAUDE_CODE_OAUTH_TOKEN`]);Object.freeze([`human`,`bot`]);var Ql=O().regex(Kl);function $l(e){return new Set(e.map(e=>e.id)).size===e.length}var eu=fs(`kind`,[N({kind:F(`manual`)}),N({kind:F(`github-merged-prs`),repo:Jl,minBodies:k().int().min(1),limit:k().int().min(1).max(500)})]),tu=fs(`kind`,[N({kind:F(`none`)}),N({kind:F(`pr-checkout`)})]),nu=N({promptTemplate:Xl,output:P([`review-findings`,`json`]),timeoutSeconds:k().int().min(30).max(14400)}),ru=N({id:Ql,env:ms(O().regex(ql),O()).refine(e=>Zl.every(t=>!Object.hasOwn(e,t)),{message:`arm env must not set ${Zl.join(`, `)}; Glimmervoid injects it per cell`}).optional(),extraArgs:j(O()).optional(),setup:N({command:j(Xl).min(1)}).optional()}),iu=fs(`kind`,[N({kind:F(`llm-judge-match`),model:Xl})]);N({id:Ql,title:Xl,caseSource:eu,workspace:tu,subject:nu,arms:j(ru).min(2).refine($l,{message:`arm ids must be unique`}),baselineArm:Ql,trials:k().int().min(1).max(20),scorer:iu}).refine(e=>e.arms.some(t=>t.id===e.baselineArm),{message:`baselineArm must name one of the arms`,path:[`baselineArm`]});var au=N({id:Ql,text:Xl,tags:j(Ql),path:Xl.optional(),line:k().int().positive().optional()}),ou=fs(`kind`,[N({kind:F(`manual`)}),N({kind:F(`github-pr`),repo:Jl,number:k().int().positive(),url:Xl,minedAt:Yl})]);N({id:Ql,input:ms(O(),as()),references:j(au).min(1).refine($l,{message:`reference ids must be unique`}),source:ou}),M({repo:Jl,number:k().int().positive(),reviewedSha:L,baseSha:L,changedFiles:j(Xl)});var su=N({referenceId:Ql,verdict:P([`found`,`partial`,`missed`]),findingIndexes:j(k().int().nonnegative())}),cu=P([`scored`,`invalid`,`error`]),lu=N({caseId:Ql,armId:Ql,trial:k().int().min(1),status:cu,startedAt:Yl,finishedAt:Yl,degradedReasons:j(Xl),findingCount:k().int().nonnegative(),judgements:j(su),costUsd:k().finite().nonnegative().nullable(),error:Xl.nullable()}),uu=P([`running`,`completed`,`interrupted`,`failed`]);N({id:Ql,suiteId:Ql,status:uu,startedAt:Yl,finishedAt:Yl.nullable(),error:Xl.nullable(),cells:j(lu)});var du=k().min(0).max(1).nullable(),fu=N({trials:k().int().nonnegative(),recall:du,recallByTag:ms(Ql,du),degraded:k().int().nonnegative(),invalid:k().int().nonnegative(),costUsd:k().finite().nonnegative().nullable()}),pu=N({caseId:Ql,arms:ms(Ql,fu),deltaVsBaseline:ms(Ql,k().min(-1).max(1).nullable())}),mu=N({runId:Ql,suiteId:Ql,status:uu,baselineArm:Ql,armIds:j(Ql),rows:j(pu),totals:ms(Ql,fu)}),hu=P([`mine`,`run`,`cancel`]),gu=M({suiteId:Ql,action:hu}),_u=M({suiteId:Ql,action:hu,ok:A(),error:O().optional(),runId:Ql.optional()}),vu=P([`setup`,`preflight`,`workspace`,`subject`,`judge`]),yu=M({suiteId:Ql,runId:Ql,caseId:Ql.nullable(),armId:Ql,trial:k().int().min(1),phase:vu,cellIndex:k().int().nonnegative(),cellCount:k().int().positive(),startedAt:Yl}),bu=M({id:Ql,title:O(),error:O().nullable(),caseCount:k().int().nonnegative(),candidateCount:k().int().nonnegative(),armIds:j(Ql),baselineArm:Ql.nullable(),latestReport:mu.nullable()}),xu=M({type:F(`benchmark-status`),ts:Yl,configured:A(),reason:O().nullable(),suites:j(bu),inFlight:yu.nullable()}).passthrough(),Su=M({__typename:O(),login:O()}).nullable();M({number:k().int().positive(),title:O(),url:Xl,mergedAt:O().nullable(),reviewThreads:M({totalCount:k().int().nonnegative()}),reviews:M({totalCount:k().int().nonnegative()})});var Cu=M({path:O(),line:k().int().positive().nullable(),originalLine:k().int().positive().nullable(),comments:M({nodes:j(M({databaseId:k().int().positive(),author:Su,body:O(),createdAt:O(),originalCommit:M({oid:L}).nullable()}))})}),wu=M({databaseId:k().int().positive(),author:Su,body:O(),submittedAt:O().nullable(),commit:M({oid:L}).nullable()}),Tu=fs(`__typename`,[M({__typename:F(`BaseRefChangedEvent`),createdAt:O()}),M({__typename:F(`BaseRefForcePushedEvent`),createdAt:O(),beforeCommit:M({oid:L}).nullable()})]);M({author:Su,baseRefOid:L,reviewThreads:M({pageInfo:M({hasNextPage:A()}),nodes:j(Cu)}),reviews:M({pageInfo:M({hasNextPage:A()}),nodes:j(wu)}),timelineItems:M({pageInfo:M({hasNextPage:A()}),nodes:j(Tu)})}),M({mergeBaseSha:L,changedFiles:j(Xl),isFileListComplete:A()});var R=O().nullable().optional(),Eu=O();function z(e,t){return ls({type:F(e),...t})}function Du(e={}){return ls(e)}var Ou=O().nullable(),ku=k().finite(),Au=ku.optional(),ju=Ou.optional(),Mu=Du(),Nu=j(as()),Pu=k().int().positive(),Fu=j(Du({at:ku,tool:O(),detail:O()}));M({id:O(),label:O(),command:O(),args:j(O()),resolvable:A().nullable()}).strict();var Iu=M({id:Eu,session:O(),taskTitle:Bc.nullable().optional(),taskTitleIsCustom:A().optional(),path:O(),agent:O(),state:Vc,stateSince:ku,skipPerms:A(),saneYolo:A(),worktree:A(),workspace:A().optional(),resumeSessionId:Ou,ephemeral:A().optional()}),Lu=M({number:k().int().positive(),title:O(),labels:j(M({name:O(),color:O()}).passthrough()),url:O(),updatedAt:O()}).passthrough(),Ru=M({ts:ku,projectId:O(),issues:j(Lu),error:ju}),zu=1e3,Bu=RegExp(`^[^\0--]+$`),Vu=N({section:P([`committed`,`uncommitted`]),path:O().min(1).max(400).regex(Bu),line:k().int().positive(),side:P([`old`,`new`]),note:O().min(1).max(zu)}),Hu=4096,Uu=Hu+2*(Xs+Js+80*Ys),Wu=M({reason:O(),message:O()}),Gu=P([`npm-global`,`npx`,`clone`,`unknown`]),Ku={updateAvailable:A(),current:Ou,latest:Ou,currentSha:Ou,latestSha:Ou,releaseUrl:Ou,command:O(),flavor:Gu,platform:O(),installedBranch:Ou,upstream:Ou,isTreeClean:A().nullable(),lastCheckAt:ku,channel:Zc,behindCount:k().int().nonnegative().nullable(),reason:Ou,journalSummary:nl.nullable(),applyRefusal:Wu.nullable()};M(Ku),Object.freeze(`add-session.list-conversations.resume-conversation.remove-session.rename-session.set-session-title.reorder-sessions.ping.get-settings.update-settings.scan-repo-roots.list-agents.get-posthog-report.posthog-open-session.request-issues.open-issue-session.posthog-issue-action.team-review-action.benchmark-action.my-pr-merge.my-pr-keep-mergeable.my-pr-merge-when-ready.reviews-refresh.posthog-archive-investigation.request-usage-report.request-hooks-report.save-hook.delete-hook.kill.start-session.restart.force-restart.dismiss.sleep.wake.merge-session.finish-session.merge-continue-session.discard-session-worktree.resolve-session-merge.request-session-diff.request-change-map.send-diff-annotations.request-branch-sync.resync-branch.debug-state.session-trace.session-plan.plan-decision.shutdown.restart-server.focus-change.request-health-snapshot.update-check.update-apply.client-error`.split(`.`));var qu=8192,Ju=M({name:O().max(128),stack:O().max(qu)}).strict(),Yu=[`remove-session`,`kill`,`start-session`,`restart`,`force-restart`,`dismiss`,`sleep`,`wake`,`merge-session`,`finish-session`,`merge-continue-session`,`discard-session-worktree`,`resolve-session-merge`,`request-session-diff`,`request-change-map`,`request-branch-sync`,`resync-branch`,`debug-state`];function Xu(e){return z(e,{id:Eu,force:as().optional()})}var Zu=Yu.map(Xu);fs(`type`,[z(`add-session`,{name:O(),path:O(),repos:j(O()).optional(),agent:O().optional(),dangerouslySkipPermissions:A().optional()}),z(`list-conversations`,{id:Eu,requestId:R}),z(`resume-conversation`,{id:Eu,conversationId:O()}),z(`rename-session`,{id:Eu,newName:O()}),z(`set-session-title`,{id:Eu,title:Bc}),z(`reorder-sessions`,{order:j(Eu)}),z(`ping`,{requestId:R}),z(`get-settings`,{requestId:R}),z(`update-settings`,{settings:ms(O(),as()),requestId:R}),z(`scan-repo-roots`,{requestId:R}),z(`list-agents`,{requestId:R}),z(`get-posthog-report`,{issueId:ds([O(),k()]),requestId:R}),z(`posthog-open-session`,{projectId:ds([O(),k()]),issueId:ds([O(),k()]),requestId:R}),z(`request-issues`,{requestId:R,projectId:O()}),z(`open-issue-session`,{requestId:R,projectId:O(),issueNumber:k().int().positive()}),z(`posthog-issue-action`,{projectId:ds([O(),k()]),issueId:ds([O(),k()]),action:O(),requestId:R}),z(`team-review-action`,{...tte.shape,requestId:R}),z(`benchmark-action`,{...gu.shape,requestId:R}),z(`my-pr-merge`,{...zl.shape,requestId:R}),z(`my-pr-keep-mergeable`,{...Ol.shape,requestId:R}),z(`my-pr-merge-when-ready`,{...jl.shape,requestId:R}),z(`reviews-refresh`,{...Ks.shape,requestId:R}),z(`posthog-archive-investigation`,{id:as().optional(),requestId:R}),z(`request-usage-report`,{requestId:R,days:as().optional(),force:as().optional()}),z(`request-hooks-report`,{requestId:R}),z(`send-diff-annotations`,{id:Eu,annotations:j(Vu).min(1).max(50),requestId:R}),z(`save-hook`,{hook:ms(O(),as()),requestId:R}),z(`delete-hook`,{id:O(),requestId:R}),z(`shutdown`),z(`restart-server`),z(`focus-change`,{focused:A()}),z(`request-health-snapshot`),z(`update-check`),z(`update-apply`,{restartWhenStaged:A().optional(),confirmedSessionIds:j(O().min(1)).max(1e3).optional()}),z(`session-trace`,{id:Eu,after:k().int().nonnegative().default(0),endingAt:ds([k().int().nonnegative(),F(`tail`)]).optional()}),z(`session-plan`,{id:Eu,agentId:Ou,revision:Pu.optional(),draft:A().optional()}),z(`plan-decision`,rc.shape),z(`client-error`,Ju.shape),...Zu]),Object.freeze(`snapshot.hooks-report.save-hook-result.delete-hook-result.hooks-updated.state-change.session-added.session-removed.session-renamed.session-title.session-modified.session-git.session-agents.session-wakeup.session-prompt.session-sleep.session-wake.session-merge-status.session-worktree-blocked.session-worktree-warning.session-worktree-ready.session-diff.change-map.send-diff-annotations-result.branch-sync-status.session-changed.post-turn-result.debug-state-response.session-trace-response.session-trace-changed.session-plan-changed.session-plan-draft.session-plan-response.notify.update-status.update-progress.error.session-error.settings.settings-error.settings-updated.pong.agents-listed.repo-roots-scanned.conversations.resume-conversation-ack.health-snapshot.posthog-status.posthog-investigation-activity.posthog-investigation-finished.posthog-report.posthog-open-session-result.issues-report.open-issue-session-result.posthog-issue-action-result.team-review-action-result.benchmark-action-result.my-pr-merge-result.my-pr-keep-mergeable-result.my-pr-merge-when-ready-result.reviews-refresh-result.posthog-archive-investigation-result.team-review-status.benchmark-status.my-prs-status.branch-gc-status.usage-sessions.usage-report.plan-limits.usage-budget-alert.visions-findings.visions-comments.visions-hand.visions-intent.visions-fix.visions-snapshot.ingest-activity.ingest-snapshot.client-trust.sessions-reordered.shutting-down.restarting`.split(`.`));var Qu=fs(`type`,[z(`snapshot`,{sessions:j(Kc),serverBuild:Ou}),z(`hooks-report`,{requestId:R,ts:Au,hooks:j(Mu).optional(),builtin:j(Mu).optional(),events:j(Du({name:O(),matcher:Ou,description:O(),http:A().optional()})).optional(),projects:j(Du({id:O(),name:O(),agent:O()})).optional(),limits:Du({maxTimeoutSec:k().int().positive()}).optional(),error:ju}),z(`save-hook-result`,{requestId:R,ok:A(),error:ju,hook:Mu.optional()}),z(`delete-hook-result`,{requestId:R,ok:A(),error:ju,id:O().optional()}),z(`hooks-updated`,{count:k().int().nonnegative()}),z(`state-change`,{id:Eu,session:O(),from:Vc,to:Vc,event:O(),timestamp:ku,skipPerms:A().optional(),saneYolo:A().optional(),hasEndedTurn:A().optional()}),z(`session-added`,Iu.shape),z(`session-modified`,Iu.shape),z(`session-removed`,{id:Eu,session:O()}),z(`session-renamed`,{id:Eu,oldName:O(),newName:O()}),z(`session-title`,{id:Eu,taskTitle:Bc.nullable(),isCustom:A()}),z(`session-git`,{id:Eu,worktree:A()}),z(`session-agents`,{id:Eu,activeAgents:k().int().nonnegative(),awaitingBackgroundTasks:A(),timestamp:ku}),z(`session-wakeup`,{id:Eu,pendingWakeup:Hc.nullable(),timestamp:ku}),z(`session-prompt`,{id:Eu,pendingPromptKind:Ou,pendingPromptDetail:Gc.nullable().optional(),timestamp:ku}),z(`session-sleep`),z(`session-wake`),z(`session-merge-status`,{id:Eu,mergeStatus:O(),reason:Ou,parked:A(),timestamp:ku}),z(`session-worktree-blocked`,{id:Eu,session:O(),branch:Ou,notice:Ou,timestamp:ku}),z(`session-worktree-warning`,{id:Eu,session:O(),branch:Ou,notice:Ou,timestamp:ku}),z(`session-worktree-ready`,{id:Eu,session:O(),branch:Ou,base:Ou,timestamp:ku}),z(`session-diff`,{id:Eu,committed:Du({stat:O(),diff:O()}),uncommitted:Du({stat:O(),diff:O()}),hasCommits:A()}),z(`change-map`,{id:Eu,map:Oc}),z(`send-diff-annotations-result`,{requestId:R,ok:A(),error:ju,pending:A().optional()}),z(`branch-sync-status`,{id:Eu,branch:Ou,upstream:Ou,state:O(),ahead:k().int().nonnegative(),behind:k().int().nonnegative(),fetched:A().nullable(),action:O().optional(),error:ju}),z(`session-changed`,{id:Eu}),z(`post-turn-result`,{id:Eu,mode:O(),skipped:Ou,filesFixed:k().int().nonnegative(),findings:j(Du({file:O(),rule:O(),count:k().int().nonnegative()})),timestamp:ku}),z(`debug-state-response`,{id:Eu,payload:Mu}),z(`session-trace-response`,{id:Eu,records:j(Xc),start:k().int().nonnegative(),next:k().int().nonnegative(),reset:A(),path:O()}),z(`session-trace-changed`,{id:Eu}),z(`session-plan-changed`,cc.shape),z(`session-plan-draft`,lc.shape),z(`session-plan-response`,uc.shape),z(`notify`,{session:O(),category:O(),message:O(),escalationCount:k().int().nonnegative(),kind:F(`plan`).optional()}),z(`update-status`,Ku),z(`update-progress`,{journal:tl}),z(`error`,{id:Eu.optional(),message:O(),requestId:R,scope:O().optional()}),z(`session-error`,{id:Eu.optional(),session:O(),message:O(),scope:O().optional()}),z(`settings`,{settings:Mu,requestId:R}),z(`settings-error`,{message:O(),requestId:R}),z(`settings-updated`,{settings:Mu,requestId:R}),z(`pong`,{requestId:R}),z(`agents-listed`,{requestId:R,agents:j(Du({id:O(),label:O(),resolvable:A()}))}),z(`repo-roots-scanned`,{requestId:R,directories:j(Du({root:O(),projects:j(Du({name:O(),path:O()}))})),error:O().optional()}),z(`conversations`,{requestId:R,id:Ou,current:Ou.optional(),conversations:j(Du({id:O(),title:O(),cwd:O(),worktreePath:O(),worktreeName:O(),gitBranch:Ou,mtime:ku})),error:O().optional()}),z(`resume-conversation-ack`,{id:Eu.optional(),resumeSessionId:Ou.optional(),ok:A(),error:O().optional(),requestId:R}),z(`health-snapshot`,{stats:Mu}),z(`posthog-status`,{ts:ku,intervalMinutes:k(),projects:j(Mu),investigations:j(Mu)}),z(`posthog-investigation-activity`,{projectId:ds([O(),k()]),issueId:O(),inFlight:F(!0),startedAt:ku.nullable(),trail:Fu}),z(`posthog-investigation-finished`,{projectId:ds([O(),k()]),issueId:O(),verdict:O(),summaryLine:Ou,startedAt:ku.nullable(),trail:Fu}),z(`posthog-report`,{requestId:R,ok:A(),found:A(),issueId:Ou,format:O().optional(),content:O().optional(),message:O().optional(),error:O().optional()}),z(`posthog-open-session-result`,{requestId:R,ok:A(),error:ju,sessionId:O().optional(),sessionName:O().optional(),pending:A().optional()}),z(`issues-report`,{requestId:R,...Ru.shape}),z(`open-issue-session-result`,{requestId:R,ok:A(),error:ju,sessionId:O().optional(),sessionName:O().optional(),pending:A().optional()}),z(`posthog-issue-action-result`,{requestId:R,ok:A(),error:ju,status:Ou.optional()}),z(`team-review-action-result`,{...nte.shape,requestId:R}),z(`benchmark-action-result`,{..._u.shape,requestId:R}),z(`my-pr-merge-result`,{...Vl.shape,requestId:R}),z(`my-pr-keep-mergeable-result`,{...Al.shape,requestId:R}),z(`my-pr-merge-when-ready-result`,{...Ml.shape,requestId:R}),z(`reviews-refresh-result`,{...qs.shape,requestId:R}),z(`posthog-archive-investigation-result`,{requestId:R,ok:A(),error:ju}),bl,xu,Rl,z(`branch-gc-status`),z(`usage-sessions`,{ts:ku,pricingSource:Ou,sessions:j(Du({id:Eu,tokens:k(),costUSD:k(),officialCostUSD:k().nullable().optional()}))}),z(`usage-report`,{requestId:R,ts:Au,tz:O().optional(),blockHours:k().optional(),totals:Mu.optional(),daily:Nu.optional(),models:Nu.optional(),sessions:Nu.optional(),blocks:Nu.optional(),activeBlock:as().nullable().optional(),anomaly:as().nullable().optional(),byLane:as().optional(),planWindowLanes:as().nullable().optional(),budget:as().optional(),savings:as().optional(),tokenLimit:as().nullable().optional(),pricing:Mu.optional(),scan:Mu.optional(),warning:ju,error:ju}),z(`plan-limits`,{ts:ku,fiveHour:as().nullable(),sevenDay:as().nullable(),source:O()}),z(`usage-budget-alert`,{scope:O(),periodKey:O(),threshold:k(),text:O(),ts:ku}),z(`visions-findings`,{uri:O(),diagnostics:Nu,ts:ku}),z(`visions-comments`,{uri:O(),comments:Nu,ts:ku}),z(`visions-hand`,{uri:O(),hand:Ou,ts:ku}),z(`visions-intent`,{projectId:Ou,intent:Mu,ts:ku}),z(`visions-fix`,{uri:O(),fix:Mu,ts:ku}),z(`visions-snapshot`,{documents:j(Mu),intent:Mu,fixes:j(Mu),ts:ku}),z(`ingest-activity`,{events:j(Mu),overflow:k().int().nonnegative(),ts:ku}),z(`ingest-snapshot`,{events:j(Mu),sources:as(),ts:ku}),z(`client-trust`,{trust:P([`local`,`remote`])}),z(`sessions-reordered`,{order:j(Eu)}),z(`shutting-down`),z(`restarting`)]),$u=null,ed=null,td=0,nd=new Map,rd=null,id=0,ad=!1,od=0,sd=null,cd=null;function ld(e){cd=e}function ud(e){sd=e}function B(e){return $u?.readyState===WebSocket.OPEN&&($u.send(JSON.stringify(e)),!0)}function dd(e,t){let n=`${e}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise((r,i)=>{let a=setTimeout(()=>{nd.delete(n),i(Error(`Request timed out`))},5e3);if(nd.set(n,{resolve:r,reject:i,timer:a}),$u?.readyState!==WebSocket.OPEN){clearTimeout(a),nd.delete(n),i(Error(`Not connected`));return}$u.send(JSON.stringify({type:e,requestId:n,...t}))})}function fd(e){for(let t of nd.values())clearTimeout(t.timer),t.reject(Error(e));nd.clear()}function pd(){let e=$u;$u=null,fd(`Connection replaced`),e?.close(),td=0,md()}function md(){if(ed!==null&&(ed!==null&&clearTimeout(ed),ed=null),!d()&&!ad){ad=!0,f().finally(()=>{ad=!1,md()});return}if(ad)return;let e=od>0?`?since=${od}`:``,n=c(location,m(`/control${e}`)),r=new WebSocket(n);$u=r,id=Date.now();let i=!1;r.addEventListener(`open`,()=>{i=!0,td=0,cd&&cd(`connected`,`Connected`)}),r.addEventListener(`message`,e=>{if($u!==r)return;let t;try{t=JSON.parse(e.data)}catch{console.warn(`[control] Dropped malformed server JSON message`);return}let n=Qu.safeParse(t);if(!n.success){console.warn(`[control] Dropped invalid server message: ${n.error.issues[0]?.message||`invalid payload`}`);return}let i=n.data;if(i.type===`snapshot`&&typeof i.seq!=`number`&&(od=0),typeof i.seq==`number`){if(i.seq<=od)return;od=i.seq}let a=typeof i.requestId==`string`?i.requestId:``,o=a?nd.get(a):void 0;if(o){clearTimeout(o.timer),nd.delete(a),o.resolve(i);return}sd&&sd(i)}),r.addEventListener(`close`,()=>{if($u!==r)return;$u=null,fd(`Connection closed`),i||p(),cd&&cd(`disconnected`,`Reconnecting`);let e=t(td);td+=1,ed=setTimeout(md,e)})}async function hd(e){if(rd)return rd;let t=o({hasSocket:!!$u,readyState:$u?.readyState??null,retryPending:ed!==null,connectingAgeMs:Date.now()-id,hiddenForMs:e});if(t===`retry-now`)return ed!==null&&clearTimeout(ed),ed=null,td=0,md(),`reconnecting`;if(t===`connect`)return pd(),`reconnecting`;if(t===`wait`)return`reconnecting`;let n=$u;return rd=dd(`ping`,{}).then(()=>`ok`).catch(()=>($u===n&&n&&pd(),`dead`)).finally(()=>{rd=null}),rd}function gd(e,t){return!e||e.toLowerCase().endsWith(`[bot]`)?null:`https://avatars.githubusercontent.com/${encodeURIComponent(e)}?s=${t*2}`}function _d(e){return e.match(/[a-z0-9]/i)?.[0]?.toUpperCase()??`?`}function V(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n!=null&&(r.textContent=n),r}function vd({login:e,url:t,cssPx:n}){let r=V(`span`,`avatar`);r.style.width=`${n}px`,r.style.height=`${n}px`;let i=()=>V(`span`,`avatar-monogram`,_d(e)),a=t===void 0?gd(e,n):t;if(!a)return r.append(i()),r;let o=V(`img`);return o.src=a,o.width=n,o.height=n,o.loading=`lazy`,o.decoding=`async`,o.referrerPolicy=`no-referrer`,o.alt=``,o.addEventListener(`error`,()=>o.replaceWith(i()),{once:!0}),r.append(o),r}function yd(e,t){let n=V(`span`,`avatar-stack`);for(let r of e){let e=vd({login:r.login,url:r.url,cssPx:t});e.title=r.title,e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,r.title);let i=V(`span`,`avatar-badge`);i.dataset.tone=r.tone,e.append(i),n.append(e)}return n}function H(e,t,n){let r=e.querySelector(t);if(!r||r.tagName.toLowerCase()!==n)throw Error(`${t} does not match a <${n}>`);return r}function bd(e,t){let n=e.querySelector(t);if(!(n instanceof HTMLElement))throw Error(`${t} matches no element`);return n}function xd(e,t,n,r=t){if(!n){let n=V(`span`,e,t);return n.title=r,n}let i=V(`a`,e,t);return i.title=r,i.href=n,i.target=`_blank`,i.rel=`noopener`,i}var Sd={"pending-review":`REVIEW`,parked:`PARKED`,merging:`MERGING`};function Cd(e,t){return e===I.RUNNING&&t===!0}function wd(e,t=!1){let n=e,r=Cd(e,t),i=r?`Monitoring`:kc[n]||e;return{glyph:Ac[n]||``,label:i.toUpperCase(),isMonitoring:r}}function Td(e){if(!e)return;let t=null,n=()=>{t=null;let n=e.offsetHeight;n>0&&document.documentElement.style.setProperty(`--header-h`,`${n}px`)};new ResizeObserver(()=>{t===null&&(t=requestAnimationFrame(n))}).observe(e)}function Ed(e,t,n){let r=V(`section`,`${e}-section`),i=V(`div`,`${e}-section-head`);return i.append(V(`h2`,`${e}-section-title`,t)),n&&i.append(V(`span`,`${e}-section-hint`,n)),r.append(i),r}function Dd(e,t,n,r){let i=V(`span`,`${e}-stat`);return r&&(i.dataset.tone=r),i.append(V(`span`,`${e}-stat-value`,n),V(`span`,`${e}-stat-label`,t)),i}function Od(e){return Array.isArray(e?.projects)?e.projects:[]}function kd(e){return!e||!!e.closest(`[hidden]`)}function Ad(e){return navigator.clipboard?.writeText?navigator.clipboard.writeText(e):null}function jd(e,t){e&&t&&e.parentElement!==t&&(e._adoptHome||={parent:e.parentElement,next:e.nextElementSibling},t.appendChild(e))}function Md(e,t=null){let n=e?._adoptHome;if(n){if(delete e._adoptHome,!n.parent?.isConnected){t&&t.appendChild(e);return}if(n.next&&n.next.parentElement===n.parent){n.parent.insertBefore(e,n.next);return}n.parent.appendChild(e)}}function Nd(e){return String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}var Pd=`(max-width: 768px)`,Fd=`(pointer: coarse)`;function Id({coarse:e,narrowWidth:t}={}){return e===!0&&t===!0?`phone`:`desktop`}var Ld=Object.freeze({layout:`desktop`,activeView:`focus`,phoneScreen:null,focusedSessionId:null,selectedSessionId:null,borrowedCardId:null}),Rd=e=>e||null,zd=Object.freeze({setLayout:e=>({layout:e}),setActiveView:e=>({activeView:e}),setPhoneScreen:e=>({phoneScreen:Rd(e)}),focusSession:e=>({focusedSessionId:Rd(e)}),selectSession:e=>({selectedSessionId:Rd(e)}),borrowCard:e=>({borrowedCardId:Rd(e)})});function Bd(e){let t=Object.freeze({...Ld,...e}),n=new Set;function r(){return t}function i(e){return typeof e==`function`?(n.add(e),()=>n.delete(e)):()=>{}}function a(e){let n=[];for(let r of Object.keys(e)){if(!(r in Ld))throw Error(`ui-state: unknown key "${r}"`);Object.is(t[r],e[r])||n.push(r)}return n}function o(e,r){let i=zd[e];if(!i)throw Error(`ui-state: unknown action "${e}"`);let o=i(r),s=a(o);if(s.length===0)return t;let c=t;t=Object.freeze({...t,...o});for(let e of n)try{e(t,s,c)}catch{}return t}return{snapshot:r,subscribe:i,dispatch:o}}var Vd=Bd(),Hd=()=>Vd.snapshot().activeView,Ud=window.matchMedia?.(Fd),Wd=window.matchMedia?.(Pd);function Gd(){return Id({coarse:!!Ud?.matches,narrowWidth:!!Wd?.matches})}function Kd(e){document.documentElement.dataset.layout!==e&&(document.documentElement.dataset.layout=e)}function qd(){Vd.subscribe((e,t)=>{t.includes(`layout`)&&Kd(e.layout)});let e=Gd();Kd(e),Vd.dispatch(`setLayout`,e);let t=()=>Vd.dispatch(`setLayout`,Gd());return Ud?.addEventListener?.(`change`,t),Wd?.addEventListener?.(`change`,t),e}function Jd(){return Vd.snapshot().layout===`phone`}function Yd(e){return Vd.subscribe((t,n)=>{n.includes(`layout`)&&e(t.layout)})}var U=new Map;function Xd(e){return e.card?.dataset.session||e.nameEl?.textContent||``}function Zd(e){return typeof e==`string`?e:String(e)}function Qd(e){return typeof e==`string`?U.get(e):void 0}var $d=document.getElementById(`sessions-container`),ef=document.getElementById(`aggregate-status`);function tf({dialogClass:e=`dialog`,closeOnBackdrop:t=!0}={}){let n=document.activeElement,r=document.createElement(`div`);r.className=`dialog-overlay`;let i=document.createElement(`div`);i.className=e,r.appendChild(i),document.body.appendChild(r);function a(e){e.key===`Escape`&&o()}document.addEventListener(`keydown`,a);function o(){r.remove(),document.removeEventListener(`keydown`,a),n instanceof HTMLElement&&n.focus()}return t&&r.addEventListener(`click`,e=>{e.target===r&&o()}),{overlay:r,dialog:i,close:o}}function nf(e,t){e.setAttribute(`role`,`dialog`),e.setAttribute(`aria-modal`,`true`),e.setAttribute(`aria-labelledby`,t),of(e)}function rf({title:e,dialogClass:t=`dialog`,cancelLabel:n=`Cancel`}){let{overlay:r,dialog:i,close:a}=tf({dialogClass:t}),o=`dialog-title-${Math.random().toString(36).slice(2)}`,s=V(`h3`,`dialog-title`,e);s.id=o;let c=V(`div`,`dialog-actions`),l=V(`button`,`btn-dialog btn-dialog-cancel`,n);return c.append(l),i.append(s),nf(i,o),{overlay:r,dialog:i,close:a,titleEl:s,actions:c,btnCancel:l}}function af({title:e,message:t,confirmLabel:n=`Confirm`,danger:r=!1,onConfirm:i}){let{dialog:a,close:o,actions:s,btnCancel:c}=rf({title:e}),l=V(`p`,`dialog-message`,t),u=V(`button`,r?`btn-dialog btn-dialog-confirm btn-dialog-danger`:`btn-dialog btn-dialog-confirm`,n);s.append(u),a.append(l,s),c.addEventListener(`click`,o),u.addEventListener(`click`,()=>{o(),i?.()}),requestAnimationFrame(()=>c.focus())}function of(e){e.addEventListener(`keydown`,t=>{if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(`button, input, select, textarea, [tabindex]:not([tabindex="-1"])`)];if(n.length===0)return;let r=n[0],i=n[n.length-1];if(t.shiftKey&&document.activeElement===r){t.preventDefault(),i.focus();return}!t.shiftKey&&document.activeElement===i&&(t.preventDefault(),r.focus())})}function sf(e,t){return t===I.RUNNING?e===`restart-fresh`?{title:`Restart fresh`,message:`This agent is mid-turn. A fresh restart ends this conversation and starts a new one. Restart anyway?`,confirmLabel:`Restart fresh`,danger:!0}:{title:`Restart`,message:`This agent is mid-turn. Restarting interrupts the current turn and keeps this conversation. Restart anyway?`,confirmLabel:`Restart`,danger:!1}:null}function cf(e,t,n){let r=jc.includes(t)?`force-restart`:`restart`;return e===`restart-fresh`?{type:r,id:n,fresh:!0}:{type:r,id:n}}function lf(e,t,n){let r=()=>n.send(cf(e,n.readState(),t)),i=sf(e,n.readState());if(!i){r();return}n.confirm({...i,onConfirm:r})}var uf=320,df=8e3,ff=null;function pf(e){ff=e}function mf(e){if(!e||e.currentState!==I.RUNNING)return;let t=performance.now();e._lastOutputAt=t,!(t-(e._activityGate||0)<uf)&&(e._activityGate=t,e._activity===`quiet`&&(e._activity=`active`,ff?.(e,`flag`)),ff?.(e,`beat`))}function hf(e){if(!e||e.currentState!==I.RUNNING)return;let t=performance.now()-(e._lastOutputAt||0)>=df?`quiet`:`active`;e._activity!==t&&(e._activity=t,ff?.(e,`flag`))}function gf(e,t){e&&(t&&(e._lastOutputAt=performance.now(),e._activityGate=0,e._activity=`active`),t||(e._activity=void 0),ff?.(e,`flag`))}var _f=new Set([I.RUNNING,I.WAITING,I.STARTING,I.INITIALIZING]),vf=e=>_f.has(e);function yf(e){let t=Math.max(0,Math.floor(e/1e3)),n=t%60,r=Math.floor(t/60)%60,i=Math.floor(t/3600),a=e=>String(e).padStart(2,`0`);return i>0?`${i}:${a(r)}:${a(n)}`:`${r}:${a(n)}`}function bf(e){return vf(e.currentState)?yf(Date.now()-(e.stateSince||Date.now())):``}function xf(e){e.elapsedEl&&(e.elapsedEl.textContent=bf(e))}var Sf=new Set;function Cf(e){return Sf.add(e),()=>Sf.delete(e)}function wf(){for(let[,e]of U)xf(e),hf(e);for(let e of Sf)try{e()}catch{}}setInterval(()=>{document.hidden||wf()},1e3),document.addEventListener(`visibilitychange`,()=>{document.hidden||wf()});var Tf=2,Ef=1,Df=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(Tf,Math.floor(u/e.css.cell.width)),rows:Math.max(Ef,Math.floor(l/e.css.cell.height))}}},Of=Object.defineProperty,kf=Object.getOwnPropertyDescriptor,Af=(e,t)=>{for(var n in t)Of(e,n,{get:t[n],enumerable:!0})},jf=(e,t,n,r)=>{for(var i=r>1?void 0:r?kf(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Of(t,n,i),i},W=(e,t)=>(n,r)=>t(n,r,e),Mf=`Terminal input`,Nf={get:()=>Mf,set:e=>Mf=e},Pf=`Too much output to announce, navigate to rows manually to read`,Ff={get:()=>Pf,set:e=>Pf=e};function If(e){return e.replace(/\r?\n/g,`\r`)}function Lf(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function Rf(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function zf(e,t,n,r){e.stopPropagation(),e.clipboardData&&Bf(e.clipboardData.getData(`text/plain`),t,n,r)}function Bf(e,t,n,r){e=If(e),e=Lf(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Vf(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function Hf(e,t,n,r,i){Vf(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Uf(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Wf(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var Gf=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},Kf=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},qf=``,Jf=` `,Yf=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Xf}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 t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}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):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Xf=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}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 e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Zf=class e extends Yf{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Xf,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Uf(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 t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Qf=`di$target`,$f=`di$dependencies`,ep=new Map;function tp(e){return e[$f]||[]}function np(e){if(ep.has(e))return ep.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);rp(t,e,r)};return t._id=e,ep.set(e,t),t}function rp(e,t,n){t[Qf]===t?t[$f].push({id:e,index:n}):(t[$f]=[{id:e,index:n}],t[Qf]=t)}var ip=np(`BufferService`),ap=np(`CoreMouseService`),op=np(`CoreService`),sp=np(`CharsetService`),cp=np(`InstantiationService`),lp=np(`LogService`),up=np(`OptionsService`),dp=np(`OscLinkService`),fp=np(`UnicodeService`),pp=np(`DecorationService`),mp=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Zf,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):hp(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};mp=jf([W(0,ip),W(1,up),W(2,dp)],mp);function hp(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
56
|
-
|
|
57
|
-
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var gp=np(`CharSizeService`),_p=np(`CoreBrowserService`),vp=np(`MouseService`),yp=np(`RenderService`),bp=np(`SelectionService`),xp=np(`CharacterJoinerService`),Sp=np(`ThemeService`),Cp=np(`LinkProviderService`),wp=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Ap.isErrorNoTelemetry(e)?new Ap(e.message+`
|
|
58
|
-
|
|
59
|
-
`+e.stack):Error(e.message+`
|
|
60
|
-
|
|
61
|
-
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function Tp(e){Dp(e)||wp.onUnexpectedError(e)}var Ep=`Canceled`;function Dp(e){return e instanceof Op||e instanceof Error&&e.name===Ep&&e.message===Ep}var Op=class extends Error{constructor(){super(Ep),this.name=this.message}};function kp(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var Ap=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},jp=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function Mp(e,t=0){return e[e.length-(1+t)]}var Np;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Np||={});var Pp=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||Np.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};Pp.empty=new Pp(e=>{});function Fp(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var Ip;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})(Ip||={});var Lp=null;function Rp(e){return Lp?.trackDisposable(e),e}function zp(e){Lp?.markAsDisposed(e)}function Bp(e,t){Lp?.setParent(e,t)}function Vp(e){return Lp?.markAsSingleton(e),e}function Hp(e){if(Ip.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function Up(...e){return Wp(()=>Hp(e))}function Wp(e){let t=Rp({dispose:Fp(()=>{zp(t),e()})});return t}var Gp=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,Rp(this)}dispose(){this._isDisposed||(zp(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Hp(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return Bp(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),Bp(e,null))}};Gp.DISABLE_DISPOSED_WARNING=!1;var Kp=Gp,G=class{constructor(){this._store=new Kp,Rp(this),Bp(this._store,this)}dispose(){zp(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};G.None=Object.freeze({dispose(){}});var qp=class{constructor(){this._isDisposed=!1,Rp(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&Bp(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,zp(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&Bp(e,null),e}},Jp=typeof window==`object`?window:globalThis,Yp=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};Yp.Undefined=new Yp(void 0);var Xp=Yp,Zp=class{constructor(){this._first=Xp.Undefined,this._last=Xp.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Xp.Undefined}clear(){let e=this._first;for(;e!==Xp.Undefined;){let t=e.next;e.prev=Xp.Undefined,e.next=Xp.Undefined,e=t}this._first=Xp.Undefined,this._last=Xp.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new Xp(e);if(this._first===Xp.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==Xp.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Xp.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Xp.Undefined&&e.next!==Xp.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Xp.Undefined&&e.next===Xp.Undefined?(this._first=Xp.Undefined,this._last=Xp.Undefined):e.next===Xp.Undefined?(this._last=this._last.prev,this._last.next=Xp.Undefined):e.prev===Xp.Undefined&&(this._first=this._first.next,this._first.prev=Xp.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==Xp.Undefined;)yield e.element,e=e.next}},Qp=globalThis.performance&&typeof globalThis.performance.now==`function`,$p=class e{static create(t){return new e(t)}constructor(e){this._now=Qp&&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._now()-this._startTime:this._stopTime-this._startTime}},em;(e=>{e.None=()=>G.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(Up(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new K({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new K({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new K({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new K({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new K({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function ee(e){let t=new K;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=ee;function te(e,t){return e(e=>t.fire(e))}e.forward=te;function ne(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=ne;class re{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new K(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ie(e,t){return new re(e,t).emitter.event}e.fromObservable=ie;function S(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof Kp?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=S})(em||={});var tm=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new $p,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}}};tm.all=new Set,tm._idPool=0;var nm=tm,rm=-1,im=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new sm(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};im._idPool=1;var am=im,om=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
62
|
-
`).slice(2).join(`
|
|
63
|
-
`))}},sm=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},cm=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},lm=0,um=class{constructor(e){this.value=e,this.id=lm++}},dm=2,K=class{constructor(e){this._size=0,this._options=e,this._leakageMon=rm>0||this._options?.leakWarningThreshold?new am(e?.onListenerError??Tp,this._options?.leakWarningThreshold??rm):void 0,this._perfMon=this._options?._profName?new nm(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new cm(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Tp)(n),G.None}if(this._disposed)return G.None;t&&(e=e.bind(t));let r=new um(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=om.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof um?(this._deliveryQueue??=new fm,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=Wp(()=>{i?.(),this._removeListener(r)});return n instanceof Kp?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*dm<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||Tp;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners){if(this._listeners instanceof um)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}}this._perfMon?.stop()}hasListeners(){return this._size>0}},fm=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},pm=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new K,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new K,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};pm.INSTANCE=new pm;var mm=pm;function hm(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}mm.INSTANCE.onDidChangeZoomLevel;function gm(e){return mm.INSTANCE.getZoomFactor(e)}mm.INSTANCE.onDidChangeFullscreen;var _m=typeof navigator==`object`?navigator.userAgent:``,vm=_m.indexOf(`Firefox`)>=0,ym=_m.indexOf(`AppleWebKit`)>=0,bm=_m.indexOf(`Chrome`)>=0,xm=!bm&&_m.indexOf(`Safari`)>=0;_m.indexOf(`Electron/`),_m.indexOf(`Android`);var Sm=!1;if(typeof Jp.matchMedia==`function`){let e=Jp.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=Jp.matchMedia(`(display-mode: fullscreen)`);Sm=e.matches,hm(Jp,e,({matches:e})=>{Sm&&t.matches||(Sm=e)})}function Cm(){return Sm}var wm=`en`,Tm=!1,Em=!1,Dm=!1,Om=!1,km=!1,Am=wm,jm,Mm=globalThis,Nm;typeof Mm.vscode<`u`&&typeof Mm.vscode.process<`u`?Nm=Mm.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(Nm=process);var Pm=typeof Nm?.versions?.electron==`string`&&Nm?.type===`renderer`;if(typeof Nm==`object`){Tm=Nm.platform===`win32`,Em=Nm.platform===`darwin`,Dm=Nm.platform===`linux`,Dm&&Nm.env.SNAP&&Nm.env.SNAP_REVISION,Nm.env.CI||Nm.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Am=wm;let e=Nm.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,Am=t.resolvedLanguage||wm,t.languagePack?.translationsConfigFile}catch{}Om=!0}else typeof navigator==`object`&&!Pm?(jm=navigator.userAgent,Tm=jm.indexOf(`Windows`)>=0,Em=jm.indexOf(`Macintosh`)>=0,(jm.indexOf(`Macintosh`)>=0||jm.indexOf(`iPad`)>=0||jm.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,Dm=jm.indexOf(`Linux`)>=0,jm?.indexOf(`Mobi`),km=!0,Am=globalThis._VSCODE_NLS_LANGUAGE||wm,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var Fm=Tm,Im=Em,Lm=Dm,Rm=Om;km&&typeof Mm.importScripts==`function`&&Mm.origin;var zm=jm,Bm=Am,Vm;(e=>{function t(){return Bm}e.value=t;function n(){return Bm.length===2?Bm===`en`:Bm.length>=3&&Bm[0]===`e`&&Bm[1]===`n`&&Bm[2]===`-`}e.isDefaultVariant=n;function r(){return Bm===`en`}e.isDefault=r})(Vm||={});var Hm=typeof Mm.postMessage==`function`&&!Mm.importScripts;(()=>{if(Hm){let e=[];Mm.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),Mm.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var Um=!!(zm&&zm.indexOf(`Chrome`)>=0);zm&&zm.indexOf(`Firefox`),!Um&&zm&&zm.indexOf(`Safari`),zm&&zm.indexOf(`Edg/`),zm&&zm.indexOf(`Android`);var Wm=typeof navigator==`object`?navigator:{};Rm||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||Wm&&Wm.clipboard&&Wm.clipboard.writeText,Rm||Wm&&Wm.clipboard&&Wm.clipboard.readText,Rm||Cm()||Wm.keyboard,`ontouchstart`in Jp||Wm.maxTouchPoints,Jp.PointerEvent&&(`ontouchstart`in Jp||navigator.maxTouchPoints);var Gm=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Km=new Gm,qm=new Gm,Jm=new Gm,Ym=Array(230),Xm;(e=>{function t(e){return Km.keyCodeToStr(e)}e.toString=t;function n(e){return Km.strToKeyCode(e)}e.fromString=n;function r(e){return qm.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return Jm.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return qm.strToKeyCode(e)||Jm.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return Km.keyCodeToStr(e)}e.toElectronAccelerator=o})(Xm||={});var Zm=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Qm([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Qm=class{constructor(e){if(e.length===0)throw kp(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function $m(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return Xm.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(vm)switch(t){case 59:return 85;case 60:if(Lm)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Im)return 57}else if(ym&&(Im&&t===93||!Im&&t===92))return 57;return Ym[t]||0}var eh=Im?256:2048,th=512,nh=1024,rh=Im?2048:256,ih=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=$m(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=eh),this.altKey&&(t|=th),this.shiftKey&&(t|=nh),this.metaKey&&(t|=rh),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Zm(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},ah=new WeakMap;function oh(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var sh=class{static getSameOriginWindowChain(e){let t=ah.get(e);if(!t){t=[],ah.set(e,t);let n=e,r;do r=oh(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},ch=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=sh.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},lh=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(bm){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)this.deltaY=r?t.wheelDeltaY/(120*i):t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;this.deltaY=t.deltaMode===t.DOM_DELTA_LINE?vm&&!Im?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=xm&&Fm?-(t.wheelDeltaX/120):r?t.wheelDeltaX/(120*i):t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;this.deltaX=t.deltaMode===t.DOM_DELTA_LINE?vm&&!Im?-e.deltaX/3:-e.deltaX:-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(this.deltaY=r?e.wheelDelta/(120*i):e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},uh=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),dh;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof fh?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:em.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:uh})})(dh||={});var fh=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?uh:(this._emitter||=new K,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},ph=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new jp(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new jp(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},mh=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new jp(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=Wp(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var hh;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(hh||={});var gh=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new K,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.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 em.toPromise(this._onStateChanged.event)}while(1)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.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())}};gh.EMPTY=gh.fromArray([]);function _h(e){return vh(e,0)}function vh(e,t){switch(typeof e){case`object`:return e===null?yh(349,t):Array.isArray(e)?Sh(e,t):Ch(e,t);case`string`:return xh(e,t);case`boolean`:return bh(e,t);case`number`:return yh(e,t);case`undefined`:return yh(937,t);default:return yh(617,t)}}function yh(e,t){return(t<<5)-t+e|0}function bh(e,t){return yh(e?433:863,t)}function xh(e,t){t=yh(149417,t);for(let n=0,r=e.length;n<r;n++)t=yh(e.charCodeAt(n),t);return t}function Sh(e,t){return t=yh(104579,t),e.reduce((e,t)=>vh(t,e),t)}function Ch(e,t){return t=yh(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=xh(n,t),vh(e[n],t)),t)}var{registerWindow:ute,getWindow:wh,getDocument:dte,getWindows:fte,getWindowsCount:pte,getWindowId:Th,getWindowById:mte,hasWindow:hte,onDidRegisterWindow:Eh,onWillUnregisterWindow:gte,onDidUnregisterWindow:_te}=function(){let e=new Map,t={window:Jp,disposables:new Kp};e.set(Jp.vscodeWindowId,t);let n=new K,r=new K,i=new K;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return G.None;let a=new Kp,o={window:t,disposables:a.add(new Kp)};return e.set(t.vscodeWindowId,o),a.add(Wp(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(q(t,Ih.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:Jp},getDocument(e){return wh(e).document}}}(),Dh=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!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,null)}};function q(e,t,n,r){return new Dh(e,t,n,r)}function Oh(e,t){return function(n){return t(new ch(e,n))}}function kh(e){return function(t){return e(new ih(t))}}var Ah=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=Oh(wh(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=kh(n)),q(e,t,i,r)},jh,Mh=class extends mh{constructor(e){super(),this.defaultTarget=e&&wh(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Nh=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Tp(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(Nh.sort),a.shift().execute();r.set(i,!1)};jh=(t,r,a=0)=>{let o=Th(t),s=new Nh(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var Ph=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};Ph.None=new Ph(0,0);function Fh(e){let t=e.getBoundingClientRect(),n=wh(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=_h(n),a=r.get(i);if(a)a.users+=1;else{let o=new K,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(Wp(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var Ih={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:ym?`webkitAnimationStart`:`animationstart`,ANIMATION_END:ym?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:ym?`webkitAnimationIteration`:`animationiteration`},Lh=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=Rh(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Rh(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Rh(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Rh(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Rh(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Rh(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Rh(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Rh(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Rh(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Rh(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Rh(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=Rh(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=Rh(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Rh(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Rh(e){return typeof e==`number`?`${e}px`:e}function zh(e){return new Lh(e)}var Bh=class{constructor(){this._hooks=new Kp,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(Wp(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=wh(e)}this._hooks.add(q(a,Ih.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(q(a,Ih.POINTER_UP,e=>this.stopMonitoring(!0)))}};function Vh(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var Hh;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(Hh||={});var Uh=class e extends G{constructor(){super(),this.dispatched=!1,this.targets=new Zp,this.ignoreTargets=new Zp,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(em.runAndSubscribe(Eh,({window:e,disposables:t})=>{t.add(q(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(q(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(q(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:Jp,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=Vp(new e),Wp(e.INSTANCE.targets.push(t))):G.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=Vp(new e),Wp(e.INSTANCE.ignoreTargets.push(t))):G.None}static isTouchDevice(){return`ontouchstart`in Jp||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(Hh.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-Mp(s.rollingPageX))<30&&Math.abs(s.initialPageY-Mp(s.rollingPageY))<30){let e=this.newGestureEvent(Hh.Tap,s.initialTarget);e.pageX=Mp(s.rollingPageX),e.pageY=Mp(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-Mp(s.rollingPageX))<30&&Math.abs(s.initialPageY-Mp(s.rollingPageY))<30){let e=this.newGestureEvent(Hh.Contextmenu,s.initialTarget);e.pageX=Mp(s.rollingPageX),e.pageY=Mp(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=Mp(s.rollingPageX),n=Mp(s.rollingPageY),i=Mp(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(Hh.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===Hh.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Hh.Change||t.type===Hh.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=jh(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(Hh.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(Hh.Change,i.initialTarget);a.translationX=r.pageX-Mp(i.rollingPageX),a.translationY=r.pageY-Mp(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};Uh.SCROLL_FRICTION=-.005,Uh.HOLD_DELAY=700,Uh.CLEAR_TAP_COUNT_TIME=400,jf([Vh],Uh,`isTouchDevice`,1);var Wh=Uh,Gh=class extends G{onclick(e,t){this._register(q(e,Ih.CLICK,n=>t(new ch(wh(e),n))))}onmousedown(e,t){this._register(q(e,Ih.MOUSE_DOWN,n=>t(new ch(wh(e),n))))}onmouseover(e,t){this._register(q(e,Ih.MOUSE_OVER,n=>t(new ch(wh(e),n))))}onmouseleave(e,t){this._register(q(e,Ih.MOUSE_LEAVE,n=>t(new ch(wh(e),n))))}onkeydown(e,t){this._register(q(e,Ih.KEY_DOWN,e=>t(new ih(e))))}onkeyup(e,t){this._register(q(e,Ih.KEY_UP,e=>t(new ih(e))))}oninput(e,t){this._register(q(e,Ih.INPUT,t))}onblur(e,t){this._register(q(e,Ih.BLUR,t))}onfocus(e,t){this._register(q(e,Ih.FOCUS,t))}onchange(e,t){this._register(q(e,Ih.CHANGE,t))}ignoreGesture(e){return Wh.ignoreTarget(e)}},Kh=11,qh=class extends Gh{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=Kh+`px`,this.domNode.style.height=Kh+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new Bh),this._register(Ah(this.bgDomNode,Ih.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(Ah(this.domNode,Ih.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new Mh),this._pointerdownScheduleRepeatTimer=this._register(new ph)}_arrowPointerDown(e){e.target&&e.target instanceof Element&&(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,wh(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},Jh=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}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(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,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:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},Yh=class extends G{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Jh(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new $h(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=$h.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},Xh=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Zh(e,t){let n=t-e;return function(t){return e+n*tg(t)}}function Qh(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var $h=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,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,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),Qh(Zh(e,r),Zh(i,t),.33)}return Zh(e,t)}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 t=(e-this.startTime)/this.duration;return t<1?new Xh(this.scrollLeft(t),this.scrollTop(t),!1):new Xh(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){r+=10;let i=Date.now()-10;return new e(t,n,i,r)}};function eg(e){return e**3}function tg(e){return 1-eg(1-e)}var ng=class extends G{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new ph)}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||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`:``)))}},rg=140,ig=class extends Gh{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 ng(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Bh),this._shouldRender=!0,this.domNode=zh(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(q(this.domNode.domNode,Ih.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new qh(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=zh(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(q(this.slider.domNode,Ih.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=Fh(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(Fm&&a>rg){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},ag=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t&&(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t&&(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t&&(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},og=class extends ig{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new ag(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},sg=class extends ig{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new ag(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},cg=500,lg=50,ug=!0,dg=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},fg=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,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(1);return t<=.5}acceptStandardWheelEvent(e){if(bm){let t=gm(wh(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new dg(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=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]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){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),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};fg.INSTANCE=new fg;var pg=fg,mg=class extends Gh{constructor(e,t,n){super(),this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new K),this.onWillScroll=this._onWillScroll.event,this._options=gg(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new sg(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new og(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=zh(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=zh(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=zh(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,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new ph),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Hp(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Im&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new lh(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Hp(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(q(this._listenOnDomNode,Ih.MOUSE_WHEEL,e=>{this._onMouseWheel(new lh(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=pg.INSTANCE;ug&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!Im&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=lg*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=lg*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(ug&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),cg)}},hg=class extends mg{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function gg(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`&&e.horizontalHasArrows,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,Im&&(t.className+=` mac`),t}var _g=class extends G{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new K),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new Yh({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>jh(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new hg(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(em.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Wp(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(Wp(()=>this._styleElement.remove())),this._register(em.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
|
|
64
|
-
`)})),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(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};_g=jf([W(2,ip),W(3,_p),W(4,ap),W(5,Sp),W(6,up),W(7,yp)],_g);var vg=class extends G{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(Wp(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let 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=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};vg=jf([W(1,ip),W(2,_p),W(3,pp),W(4,yp)],vg);var yg=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},bg={full:0,left:0,center:0,right:0},xg={full:0,left:0,center:0,right:0},Sg={full:0,left:0,center:0,right:0},Cg=class extends G{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new yg,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(Wp(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);xg.full=this._canvas.width,xg.left=e,xg.center=t,xg.right=e,this._refreshDrawHeightConstants(),Sg.full=1,Sg.left=1,Sg.center=1+xg.left,Sg.right=1+xg.left+xg.center}_refreshDrawHeightConstants(){bg.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);bg.left=t,bg.center=t,bg.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*bg.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*bg.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*bg.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*bg.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 e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Sg[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-bg[e.position||`full`]/2),xg[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+bg[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Cg=jf([W(2,ip),W(3,pp),W(4,yp),W(5,up),W(6,Sp),W(7,_p)],Cg);var J;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=`
|
|
65
|
-
`,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))(J||={});var wg;(e=>(e.PAD=``,e.HOP=``,e.BPH=``,e.NBH=``,e.IND=``,e.NEL=`
`,e.SSA=``,e.ESA=``,e.HTS=``,e.HTJ=``,e.VTS=``,e.PLD=``,e.PLU=``,e.RI=``,e.SS2=``,e.SS3=``,e.DCS=``,e.PU1=``,e.PU2=``,e.STS=``,e.CCH=``,e.MW=``,e.SPA=``,e.EPA=``,e.SOS=``,e.SGCI=``,e.SCI=``,e.CSI=``,e.ST=``,e.OSC=``,e.PM=``,e.APC=``))(wg||={});var Tg;(e=>e.ST=`${J.ESC}\\`)(Tg||={});var Eg=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,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)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${J.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Eg=jf([W(2,ip),W(3,up),W(4,op),W(5,yp)],Eg);var Dg=0,Og=0,kg=0,Ag=0,jg={css:`#00000000`,rgba:0},Mg;(e=>{function t(e,t,n,r){return r===void 0?`#${Lg(e)}${Lg(t)}${Lg(n)}`:`#${Lg(e)}${Lg(t)}${Lg(n)}${Lg(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(Mg||={});var Ng;(e=>{function t(e,t){if(Ag=(t.rgba&255)/255,Ag===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return Dg=a+Math.round((n-a)*Ag),Og=o+Math.round((r-o)*Ag),kg=s+Math.round((i-s)*Ag),{css:Mg.toCss(Dg,Og,kg),rgba:Mg.toRgba(Dg,Og,kg)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=Ig.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return Mg.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[Dg,Og,kg]=Ig.toChannels(t),{css:Mg.toCss(Dg,Og,kg),rgba:t}}e.opaque=i;function a(e,t){return Ag=Math.round(t*255),[Dg,Og,kg]=Ig.toChannels(e.rgba),{css:Mg.toCss(Dg,Og,kg,Ag),rgba:Mg.toRgba(Dg,Og,kg,Ag)}}e.opacity=a;function o(e,t){return Ag=e.rgba&255,a(e,Ag*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(Ng||={});var Pg;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return Dg=parseInt(e.slice(1,2).repeat(2),16),Og=parseInt(e.slice(2,3).repeat(2),16),kg=parseInt(e.slice(3,4).repeat(2),16),Mg.toColor(Dg,Og,kg);case 5:return Dg=parseInt(e.slice(1,2).repeat(2),16),Og=parseInt(e.slice(2,3).repeat(2),16),kg=parseInt(e.slice(3,4).repeat(2),16),Ag=parseInt(e.slice(4,5).repeat(2),16),Mg.toColor(Dg,Og,kg,Ag);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.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 Dg=parseInt(r[1]),Og=parseInt(r[2]),kg=parseInt(r[3]),Ag=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),Mg.toColor(Dg,Og,kg,Ag);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[Dg,Og,kg,Ag]=t.getImageData(0,0,1,1).data,Ag!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:Mg.toRgba(Dg,Og,kg,Ag),css:e}}e.toColor=r})(Pg||={});var Fg;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(Fg||={});var Ig;(e=>{function t(e,t){if(Ag=(t&255)/255,Ag===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return Dg=a+Math.round((n-a)*Ag),Og=o+Math.round((r-o)*Ag),kg=s+Math.round((i-s)*Ag),Mg.toRgba(Dg,Og,kg)}e.blend=t;function n(e,t,n){let a=Fg.relativeLuminance(e>>8),o=Fg.relativeLuminance(t>>8);if(Rg(a,o)<n){if(o<a){let o=r(e,t,n),s=Rg(a,Fg.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>Rg(a,Fg.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=Rg(a,Fg.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>Rg(a,Fg.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Rg(Fg.relativeLuminance2(o,s,c),Fg.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=Rg(Fg.relativeLuminance2(o,s,c),Fg.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Rg(Fg.relativeLuminance2(o,s,c),Fg.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=Rg(Fg.relativeLuminance2(o,s,c),Fg.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(Ig||={});function Lg(e){let t=e.toString(16);return t.length<2?`0`+t:t}function Rg(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var zg=class extends Yf{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Bg=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Zf}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||Jf.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)Bg._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||Jf.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};Bg=jf([W(0,ip)],Bg);function Vg(e){return 57508<=e&&e<=57558}function Hg(e){return 9472<=e&&e<=9631}function Ug(e){return Vg(e)||Hg(e)}function Wg(){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}}var Kg=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new Zf,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,ee=!1,te=0,ne=!1,re=0,ie=0,S=[],ae=l!==-1&&u!==-1;for(let oe=0;oe<m;oe++){e.loadCell(oe,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let se=!1,ce=oe>=ie,le=oe,C=this._workCell;if(f.length>0&&oe===f[0][0]&&ce){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)ce&&=i===this._isCellInSelection(v,t);ce&&=!n||a<r[0]||a>=r[1],ce?(se=!0,C=new zg(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),le=r[1]-1,m=C.getWidth()):ie=r[1]}let w=this._isCellInSelection(oe,t),T=n&&oe===a,ue=ae&&oe>=l&&oe<=u,de=!1;this._decorationService.forEachDecorationAtCell(oe,t,void 0,e=>{de=!0});let fe=C.getChars()||Jf;if(fe===` `&&(C.isUnderline()||C.isOverline())&&(fe=`\xA0`),re=m*s-c.get(fe,C.isBold(),C.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(w&&ne||!w&&!ne&&C.bg===y)&&(w&&ne&&p.selectionForeground||C.fg===b)&&C.extended.ext===x&&ue===ee&&re===te&&!T&&!se&&!de&&ce){C.isInvisible()?_+=Jf:_+=fe,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=C.bg,b=C.fg,x=C.extended.ext,ee=ue,te=re,ne=w,se&&a>=oe&&a<=le&&(a=oe),!this._coreService.isCursorHidden&&T&&this._coreService.isCursorInitialized){if(S.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&S.push(`xterm-cursor-blink`),S.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:S.push(`xterm-cursor-outline`);break;case`block`:S.push(`xterm-cursor-block`);break;case`bar`:S.push(`xterm-cursor-bar`);break;case`underline`:S.push(`xterm-cursor-underline`)}}if(C.isBold()&&S.push(`xterm-bold`),C.isItalic()&&S.push(`xterm-italic`),C.isDim()&&S.push(`xterm-dim`),_=C.isInvisible()?Jf:C.getChars()||Jf,C.isUnderline()&&(S.push(`xterm-underline-${C.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!C.isUnderlineColorDefault())){if(C.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${Yf.toColorRGB(C.getUnderlineColor()).join(`,`)})`;else{let e=C.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&C.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}C.isOverline()&&(S.push(`xterm-overline`),_===` `&&(_=`\xA0`)),C.isStrikethrough()&&S.push(`xterm-strikethrough`),ue&&(h.style.textDecoration=`underline`);let pe=C.getFgColor(),me=C.getFgColorMode(),he=C.getBgColor(),E=C.getBgColorMode(),ge=!!C.isInverse();if(ge){let e=pe;pe=he,he=e;let t=me;me=E,E=t}let _e,ve,ye=!1;this._decorationService.forEachDecorationAtCell(oe,t,void 0,e=>{e.options.layer!==`top`&&ye||(e.backgroundColorRGB&&(E=50331648,he=e.backgroundColorRGB.rgba>>8&16777215,_e=e.backgroundColorRGB),e.foregroundColorRGB&&(me=50331648,pe=e.foregroundColorRGB.rgba>>8&16777215,ve=e.foregroundColorRGB),ye=e.options.layer===`top`)}),!ye&&w&&(_e=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,he=_e.rgba>>8&16777215,E=50331648,ye=!0,p.selectionForeground&&(me=50331648,pe=p.selectionForeground.rgba>>8&16777215,ve=p.selectionForeground)),ye&&S.push(`xterm-decoration-top`);let be;switch(E){case 16777216:case 33554432:be=p.ansi[he],S.push(`xterm-bg-${he}`);break;case 50331648:be=Mg.toColor(he>>16,he>>8&255,he&255),this._addStyle(h,`background-color:#${qg((he>>>0).toString(16),`0`,6)}`);break;default:ge?(be=p.foreground,S.push(`xterm-bg-257`)):be=p.background}switch(_e||C.isDim()&&(_e=Ng.multiplyOpacity(be,.5)),me){case 16777216:case 33554432:C.isBold()&&pe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(pe+=8),this._applyMinimumContrast(h,be,p.ansi[pe],C,_e,void 0)||S.push(`xterm-fg-${pe}`);break;case 50331648:let e=Mg.toColor(pe>>16&255,pe>>8&255,pe&255);this._applyMinimumContrast(h,be,e,C,_e,ve)||this._addStyle(h,`color:#${qg(pe.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,be,p.foreground,C,_e,ve)||ge&&S.push(`xterm-fg-257`)}S.length&&=(h.className=S.join(` `),0),!T&&!se&&!de&&ce?g++:h.textContent=_,re!==this.defaultSpacing&&(h.style.letterSpacing=`${re}px`),d.push(h),oe=le}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||Ug(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=Ng.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};Kg=jf([W(1,xp),W(2,up),W(3,_p),W(4,op),W(5,pp),W(6,Sp)],Kg);function qg(e,t,n){for(;e.length<n;)e=t+e;return e}var Jg=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},Yg=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function Xg(){return new Yg}var Zg=`xterm-dom-renderer-owner-`,Qg=`xterm-rows`,$g=`xterm-fg-`,e_=`xterm-bg-`,t_=`xterm-focus`,n_=`xterm-selection`,r_=1,i_=class extends G{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=r_++,this._rowElements=[],this._selectionRenderModel=Xg(),this.onRequestRedraw=this._register(new K).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(Qg),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(n_),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=Wg(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(Kg,document),this._element.classList.add(Zg+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(Wp(()=>{this._element.classList.remove(Zg+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Jg(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 e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Qg} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Qg} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Qg} .xterm-dim { color: ${Ng.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Qg}.${t_} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Qg}.${t_} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Qg}.${t_} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Qg} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Qg} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Qg} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Qg} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Qg} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${n_} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${n_} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${n_} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${$g}${n} { color: ${r.css}; }${this._terminalSelector} .${$g}${n}.xterm-dim { color: ${Ng.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${e_}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${$g}257 { color: ${Ng.opaque(e.background).css}; }${this._terminalSelector} .${$g}257.xterm-dim { color: ${Ng.multiplyOpacity(Ng.opaque(e.background),.5).css}; }${this._terminalSelector} .${e_}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(t_),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(t_),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Zg}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};i_=jf([W(7,cp),W(8,gp),W(9,up),W(10,ip),W(11,op),W(12,_p),W(13,Sp)],i_);var a_=class extends G{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new K),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new c_(this._optionsService))}catch{this._measureStrategy=this._register(new s_(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};a_=jf([W(2,up)],a_);var o_=class extends G{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},s_=class extends o_{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,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}},c_=class extends o_{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw 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}},l_=class extends G{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new u_(this._window)),this._onDprChange=this._register(new K),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new K),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(em.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(q(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(q(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}},u_=class extends G{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new qp),this._onDprChange=this._register(new K),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Wp(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=q(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)}},d_=class extends G{constructor(){super(),this.linkProviders=[],this._register(Wp(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function f_(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function p_(e,t,n,r,i,a,o,s,c){if(!a)return;let l=f_(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var m_=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return p_(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=f_(window,e,t);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])}}};m_=jf([W(0,yp),W(1,gp)],m_);var h_=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},g_={};Af(g_,{getSafariVersion:()=>C_,isChromeOS:()=>k_,isFirefox:()=>b_,isIpad:()=>T_,isIphone:()=>E_,isLegacyEdge:()=>x_,isLinux:()=>O_,isMac:()=>w_,isNode:()=>__,isSafari:()=>S_,isWindows:()=>D_});var __=typeof process<`u`&&`title`in process,v_=__?`node`:navigator.userAgent,y_=__?`node`:navigator.platform,b_=v_.includes(`Firefox`),x_=v_.includes(`Edge`),S_=/^((?!chrome|android).)*safari/i.test(v_);function C_(){if(!S_)return 0;let e=v_.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var w_=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(y_),T_=y_===`iPad`,E_=y_===`iPhone`,D_=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(y_),O_=y_.indexOf(`Linux`)>=0,k_=/\bCrOS\b/.test(v_),A_=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},j_=class extends A_{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},M_=class extends A_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},N_=!__&&`requestIdleCallback`in window?M_:j_,P_=class{constructor(){this._queue=new N_}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},F_=class extends G{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new qp),this._pausedResizeTask=new P_,this._observerDisposable=this._register(new qp),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 K),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new K),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new K),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new K),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new h_((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new I_(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Wp(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=Wp(()=>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,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};F_=jf([W(2,up),W(3,gp),W(4,op),W(5,pp),W(6,ip),W(7,_p),W(8,Sp)],F_);var I_=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function L_(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return B_(i,a,e,t,n,r)+V_(a,t,n,r)+H_(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,J_(Math.abs(i-e),q_(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return J_(z_(a>t?e:i,n)+(s-1)*n.cols+1+R_(a>t?i:e,n),q_(o,r))}function R_(e,t){return e-1}function z_(e,t){return t.cols-e}function B_(e,t,n,r,i,a){return V_(t,r,i,a).length===0?``:J_(K_(e,t,e,t-W_(t,i),!1,i).length,q_(`D`,a))}function V_(e,t,n,r){let i=e-W_(e,n),a=t-W_(t,n);return J_(Math.abs(i-a)-U_(e,t,n),q_(G_(e,t),r))}function H_(e,t,n,r,i,a){let o;o=V_(t,r,i,a).length>0?r-W_(r,i):t;let s=r,c=vte(e,t,n,r,i,a);return J_(K_(e,o,n,s,c===`C`,i).length,q_(c,a))}function U_(e,t,n){let r=0,i=e-W_(e,n),a=t-W_(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=G_(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function W_(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function vte(e,t,n,r,i,a){let o;return o=V_(n,r,i,a).length>0?r-W_(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function G_(e,t){return e>t?`A`:`B`}function K_(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function q_(e,t){let n=t?`O`:`[`;return J.ESC+n+e}function J_(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var yte=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Y_(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var X_=50,bte=15,xte=50,Ste=500,Cte=RegExp(`\xA0`,`g`),Z_=class extends G{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Zf,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new K),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new K),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new K),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new K),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new yte(this._bufferService),this._activeSelectionMode=0,this._register(Wp(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(Cte,` `)).join(D_?`\r
|
|
66
|
-
`:`
|
|
67
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),O_&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Y_(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=f_(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-X_),X_),t/=X_,t/Math.abs(t)+Math.round(t*(bte-1)))}shouldForceSelection(e){return w_?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(),xte)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(w_&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<Ste&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=L_(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(t||o.slice(s,c).trim()!==``){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);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 t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Y_(n,this._bufferService.cols)}};Z_=jf([W(3,ip),W(4,op),W(5,vp),W(6,up),W(7,yp),W(8,_p)],Z_);var Q_=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},$_=class{constructor(){this._color=new Q_,this._css=new Q_}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},ev=Object.freeze((()=>{let e=[Pg.toColor(`#2e3436`),Pg.toColor(`#cc0000`),Pg.toColor(`#4e9a06`),Pg.toColor(`#c4a000`),Pg.toColor(`#3465a4`),Pg.toColor(`#75507b`),Pg.toColor(`#06989a`),Pg.toColor(`#d3d7cf`),Pg.toColor(`#555753`),Pg.toColor(`#ef2929`),Pg.toColor(`#8ae234`),Pg.toColor(`#fce94f`),Pg.toColor(`#729fcf`),Pg.toColor(`#ad7fa8`),Pg.toColor(`#34e2e2`),Pg.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:Mg.toCss(r,i,a),rgba:Mg.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:Mg.toCss(n,n,n),rgba:Mg.toRgba(n,n,n)})}return e})()),tv=Pg.toColor(`#ffffff`),nv=Pg.toColor(`#000000`),rv=Pg.toColor(`#ffffff`),iv=nv,av={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},wte=tv,ov=class extends G{constructor(e){super(),this._optionsService=e,this._contrastCache=new $_,this._halfContrastCache=new $_,this._onChangeColors=this._register(new K),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:tv,background:nv,cursor:rv,cursorAccent:iv,selectionForeground:void 0,selectionBackgroundTransparent:av,selectionBackgroundOpaque:Ng.blend(nv,av),selectionInactiveBackgroundTransparent:av,selectionInactiveBackgroundOpaque:Ng.blend(nv,av),scrollbarSliderBackground:Ng.opacity(tv,.2),scrollbarSliderHoverBackground:Ng.opacity(tv,.4),scrollbarSliderActiveBackground:Ng.opacity(tv,.5),overviewRulerBorder:tv,ansi:ev.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=sv(e.foreground,tv),t.background=sv(e.background,nv),t.cursor=Ng.blend(t.background,sv(e.cursor,rv)),t.cursorAccent=Ng.blend(t.background,sv(e.cursorAccent,iv)),t.selectionBackgroundTransparent=sv(e.selectionBackground,av),t.selectionBackgroundOpaque=Ng.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=sv(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Ng.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?sv(e.selectionForeground,jg):void 0,t.selectionForeground===jg&&(t.selectionForeground=void 0),Ng.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Ng.opacity(t.selectionBackgroundTransparent,.3)),Ng.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Ng.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=sv(e.scrollbarSliderBackground,Ng.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=sv(e.scrollbarSliderHoverBackground,Ng.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=sv(e.scrollbarSliderActiveBackground,Ng.opacity(t.foreground,.5)),t.overviewRulerBorder=sv(e.overviewRulerBorder,wte),t.ansi=ev.slice(),t.ansi[0]=sv(e.black,ev[0]),t.ansi[1]=sv(e.red,ev[1]),t.ansi[2]=sv(e.green,ev[2]),t.ansi[3]=sv(e.yellow,ev[3]),t.ansi[4]=sv(e.blue,ev[4]),t.ansi[5]=sv(e.magenta,ev[5]),t.ansi[6]=sv(e.cyan,ev[6]),t.ansi[7]=sv(e.white,ev[7]),t.ansi[8]=sv(e.brightBlack,ev[8]),t.ansi[9]=sv(e.brightRed,ev[9]),t.ansi[10]=sv(e.brightGreen,ev[10]),t.ansi[11]=sv(e.brightYellow,ev[11]),t.ansi[12]=sv(e.brightBlue,ev[12]),t.ansi[13]=sv(e.brightMagenta,ev[13]),t.ansi[14]=sv(e.brightCyan,ev[14]),t.ansi[15]=sv(e.brightWhite,ev[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=sv(e.extendedAnsi[r],ev[r+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 e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];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()}}};ov=jf([W(0,up)],ov);function sv(e,t){if(e!==void 0)try{return Pg.toColor(e)}catch{}return t}var Tte=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Ete=class{constructor(){this._services=new Tte,this._services.set(cp,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=tp(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},Dte={trace:0,debug:1,info:2,warn:3,error:4,off:5},Ote=`xterm.js: `,cv=class extends G{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),kte=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Dte[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:Ote)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};cv=jf([W(0,up)],cv);var kte,lv=class extends G{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new K),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new K),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new K),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}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,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Y=3,uv=Object.freeze(new Yf),dv=0,fv=2,pv=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*Y);let r=t||Zf.fromCharData([0,qf,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*Y+0],n=t&2097151;return[this._data[e*Y+1],t&2097152?this._combined[e]:n?Uf(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*Y+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*Y+0]=e|2097152|t[2]<<22):this._data[e*Y+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*Y+0]>>22}hasWidth(e){return this._data[e*Y+0]&12582912}getFg(e){return this._data[e*Y+1]}getBg(e){return this._data[e*Y+2]}hasContent(e){return this._data[e*Y+0]&4194303}getCodePoint(e){let t=this._data[e*Y+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*Y+0]&2097152}getString(e){let t=this._data[e*Y+0];return t&2097152?this._combined[e]:t&2097151?Uf(t&2097151):``}isProtected(e){return this._data[e*Y+2]&536870912}loadCell(e,t){return dv=e*Y,t.content=this._data[dv+0],t.fg=this._data[dv+1],t.bg=this._data[dv+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*Y+0]=t.content,this._data[e*Y+1]=t.fg,this._data[e*Y+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*Y+0]=t|n<<22,this._data[e*Y+1]=r.fg,this._data[e*Y+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*Y+0];r&2097152?this._combined[e]+=Uf(t):r&2097151?(this._combined[e]=Uf(r&2097151)+Uf(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*Y+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new Zf;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new Zf;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,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,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&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),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*fv<this._data.buffer.byteLength;let n=e*Y;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*fv<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*fv<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Y+0]&4194303)return e+(this._data[e*Y+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Y+0]&4194303||this._data[e*Y+2]&50331648)return e+(this._data[e*Y+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<Y;e++)this._data[(n+i)*Y+e]=a[(t+i)*Y+e];a[(t+i)*Y+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<Y;e++)this._data[(n+i)*Y+e]=a[(t+i)*Y+e];a[(t+i)*Y+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*Y+0],n=e&2097151,a=e&2097152?this._combined[t]:n?Uf(n):Jf;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function Ate(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=mv(u,d,t),p=1,m=0;for(;p<u.length;){let e=mv(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function jte(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function Mte(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function Nte(e,t,n){let r=[],i=e.map((n,r)=>mv(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=mv(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function mv(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var hv=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new K),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Hp(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};hv._nextId=1;var Pte=hv,gv={},_v=gv.B;gv[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},gv.A={"#":`£`},gv.B=void 0,gv[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},gv.C=gv[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},gv.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},gv.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},gv.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},gv.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},gv.E=gv[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},gv.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},gv.H=gv[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},gv[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var vv=4294967295,yv=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=uv.clone(),this.savedCharset=_v,this.markers=[],this._nullCell=Zf.fromCharData([0,qf,1,0]),this._whitespaceCell=Zf.fromCharData([0,Jf,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new N_,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new lv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Xf),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Xf),this._whitespaceCell}getBlankLine(e,t){return new pv(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>vv?vv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=uv);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new lv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(uv),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new pv(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new pv(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=Ate(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(uv),n);if(r.length>0){let n=jte(this.lines,r);Mte(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(uv),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new pv(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(uv),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=Nte(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(uv,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=mv(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new Pte(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Fte=class extends G{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new K),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 yv(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new yv(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},bv=2,xv=1,Sv=class extends G{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new K),this.onResize=this._onResize.event,this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,bv),this.rows=Math.max(e.rawOptions.rows||0,xv),this.buffers=this._register(new Fte(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Sv=jf([W(0,up)],Sv);var Cv={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:w_,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},Ite=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],Lte=class extends G{constructor(e){super(),this._onOptionChange=this._register(new K),this.onOptionChange=this._onOptionChange.event;let t={...Cv};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Wp(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in Cv))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in Cv))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=Cv[e],!Rte(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=Cv[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=Ite.includes(t)?t:Cv[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function Rte(e){return e===`block`||e===`underline`||e===`bar`}function wv(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&wv(e[r],t-1);return n}var Tv=Object.freeze({insertMode:!1}),Ev=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Dv=class extends G{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new K),this.onData=this._onData.event,this._onUserInput=this._register(new K),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new K),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new K),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=wv(Tv),this.decPrivateModes=wv(Ev)}reset(){this.modes=wv(Tv),this.decPrivateModes=wv(Ev)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.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(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};Dv=jf([W(0,ip),W(1,lp),W(2,up)],Dv);var Ov={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function kv(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var Av=String.fromCharCode,jv={DEFAULT:e=>{let t=[kv(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${Av(t[0])}${Av(t[1])}${Av(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${kv(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${kv(e,!0)};${e.x};${e.y}${t}`}},Mv=class extends G{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new K),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(Ov))this.addProtocol(e,Ov[e]);for(let e of Object.keys(jv))this.addEncoding(e,jv[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};Mv=jf([W(0,ip),W(1,op),W(2,up)],Mv);var Nv=[[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]],zte=[[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]],Pv;function Bte(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var Vte=class{constructor(){if(this.version=`6`,!Pv){Pv=new Uint8Array(65536),Pv.fill(1),Pv[0]=0,Pv.fill(0,1,32),Pv.fill(0,127,160),Pv.fill(2,4352,4448),Pv[9001]=2,Pv[9002]=2,Pv.fill(2,11904,42192),Pv[12351]=1,Pv.fill(2,44032,55204),Pv.fill(2,63744,64256),Pv.fill(2,65040,65050),Pv.fill(2,65072,65136),Pv.fill(2,65280,65377),Pv.fill(2,65504,65511);for(let e=0;e<Nv.length;++e)Pv.fill(0,Nv[e][0],Nv[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Pv[e]:Bte(e,zte)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=Fv.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return Fv.createPropertyValue(0,n,r)}},Fv=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new K,this.onChange=this._onChange.event;let e=new Vte;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw 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(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},Hte=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Iv(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Lv=2147483647,Ute=256,Rv=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>Ute)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}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 Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>Lv?Lv:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>Lv?Lv:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,Lv):e}},zv=[],Wte=class{constructor(){this._state=0,this._active=zv,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,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=zv}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=zv,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||zv,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,Wf(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=zv,this._id=-1,this._state=0}}},Bv=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Wf(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},Vv=[],Gte=class{constructor(){this._handlers=Object.create(null),this._active=Vv,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Vv}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,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=Vv,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Vv,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,Wf(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Vv,this._ident=0}},Hv=new Rv;Hv.addParam(0);var Uv=class{constructor(e){this._handler=e,this._data=``,this._params=Hv,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Hv,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Wf(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=Hv,this._data=``,this._hitLimit=!1,e));return this._params=Hv,this._data=``,this._hitLimit=!1,t}},Kte=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},Wv=160,qte=function(){let e=new Kte(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Wv,0,2,0),e.add(Wv,8,5,8),e.add(Wv,6,0,6),e.add(Wv,11,0,11),e.add(Wv,13,13,13),e}(),Gv=class extends G{constructor(e=qte){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 Rv,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Wp(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Wte),this._dcsParser=this._register(new Gte),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:Wv)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<Wv){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<Wv){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<Wv){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<Wv){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),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|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<Wv){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<Wv){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=i&15}}},Kv=/^([\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})$/,qv=/^[\da-f]+$/;function Jv(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=Kv.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),qv.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function Yv(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function Xv(e,t=16){let[n,r,i]=e;return`rgb:${Yv(n,t)}/${Yv(r,t)}/${Yv(i,t)}`}var Zv={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Qv=131072,$v=10;function ey(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var ty=5e3,ny=0,ry=class extends G{constructor(e,t,n,r,i,a,o,s,c=new Gv){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Gf,this._utf8Decoder=new Kf,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=uv.clone(),this._eraseAttrDataInternal=uv.clone(),this._onRequestBell=this._register(new K),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new K),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new K),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new K),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new K),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new K),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new K),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new K),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new K),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new K),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new K),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new K),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 iy(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(J.BEL,()=>this.bell()),this._parser.setExecuteHandler(J.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(J.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(J.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(J.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(J.BS,()=>this.backspace()),this._parser.setExecuteHandler(J.HT,()=>this.tab()),this._parser.setExecuteHandler(J.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(J.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 Bv(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new Bv(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new Bv(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new Bv(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new Bv(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new Bv(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new Bv(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new Bv(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new Bv(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new Bv(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new Bv(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new Bv(e=>this.restoreCursorColor(e))),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 e in gv)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new Uv((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),ty))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${ty} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Qv&&(a=this._parseStack.position+Qv)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Qv&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Qv))),o||this._dirtyRowTracker.clearRange(),e.length>Qv)for(let t=a;t<e.length;t+=Qv){let a=t+Qv<e.length?t+Qv:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=Fv.extractWidth(t);let n=Fv.extractShouldJoin(t),m=n?Fv.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(Uf(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof pv&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!ey(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Uv(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Bv(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,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}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(uv));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=Fv.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent(J.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(J.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(J.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(J.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(J.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,_v),this._charsetService.setgCharset(1,_v),this._charsetService.setgCharset(2,_v),this._charsetService.setgCharset(3,_v);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}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${J.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=Yf.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=uv.fg,e.bg=uv.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=uv.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=uv.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=uv.fg&16777215,r.bg&=-67108864,r.bg|=uv.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${J.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${J.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${J.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=uv.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!ey(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${J.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>$v&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>$v&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(ay(n)){if(r===`?`)t.push({type:0,index:n});else{let e=Jv(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=Jv(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);ay(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,_v),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(Zv[e[0]],gv[e[1]]||_v),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=uv.clone(),this._eraseAttrDataInternal=uv.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Zf;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${J.ESC}${e}${J.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},iy=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(ny=e,e=t,t=ny),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};iy=jf([W(0,ip)],iy);function ay(e){return 0<=e&&e<256}var oy=5e7,sy=12,cy=50,ly=class extends G{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 K),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>oy)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=sy?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=sy)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>cy&&(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()}},uy=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);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)))}};uy=jf([W(0,ip)],uy);var dy=!1,Jte=class extends G{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new qp),this._onBinary=this._register(new K),this.onBinary=this._onBinary.event,this._onData=this._register(new K),this.onData=this._onData.event,this._onLineFeed=this._register(new K),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new K),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new K),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new K),this._instantiationService=new Ete,this.optionsService=this._register(new Lte(e)),this._instantiationService.setService(up,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Sv)),this._instantiationService.setService(ip,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(cv)),this._instantiationService.setService(lp,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Dv)),this._instantiationService.setService(op,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Mv)),this._instantiationService.setService(ap,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Fv)),this._instantiationService.setService(fp,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Hte),this._instantiationService.setService(sp,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(uy),this._instantiationService.setService(dp,this._oscLinkService),this._inputHandler=this._register(new ry(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(em.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(em.forward(this._bufferService.onResize,this._onResize)),this._register(em.forward(this.coreService.onData,this._onData)),this._register(em.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 ly((e,t)=>this._inputHandler.parse(e,t))),this._register(em.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new K),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!dy&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),dy=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,bv),t=Math.max(t,xv),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Iv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(Iv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Wp(()=>{for(let t of e)t.dispose()})}}},Yte={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 Xte(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?J.ESC+`OA`:J.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?J.ESC+`OD`:J.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?J.ESC+`OC`:J.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?J.ESC+`OB`:J.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:J.DEL,e.altKey&&(i.key=J.ESC+i.key);break;case 9:if(e.shiftKey){i.key=J.ESC+`[Z`;break}i.key=J.HT,i.cancel=!0;break;case 13:i.key=e.altKey?J.ESC+J.CR:J.CR,i.cancel=!0;break;case 27:i.key=J.ESC,e.altKey&&(i.key=J.ESC+J.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?J.ESC+`[1;`+(a+1)+`D`:t?J.ESC+`OD`:J.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?J.ESC+`[1;`+(a+1)+`C`:t?J.ESC+`OC`:J.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?J.ESC+`[1;`+(a+1)+`A`:t?J.ESC+`OA`:J.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?J.ESC+`[1;`+(a+1)+`B`:t?J.ESC+`OB`:J.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=J.ESC+`[2~`);break;case 46:i.key=a?J.ESC+`[3;`+(a+1)+`~`:J.ESC+`[3~`;break;case 36:i.key=a?J.ESC+`[1;`+(a+1)+`H`:t?J.ESC+`OH`:J.ESC+`[H`;break;case 35:i.key=a?J.ESC+`[1;`+(a+1)+`F`:t?J.ESC+`OF`:J.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?J.ESC+`[5;`+(a+1)+`~`:J.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?J.ESC+`[6;`+(a+1)+`~`:J.ESC+`[6~`;break;case 112:i.key=a?J.ESC+`[1;`+(a+1)+`P`:J.ESC+`OP`;break;case 113:i.key=a?J.ESC+`[1;`+(a+1)+`Q`:J.ESC+`OQ`;break;case 114:i.key=a?J.ESC+`[1;`+(a+1)+`R`:J.ESC+`OR`;break;case 115:i.key=a?J.ESC+`[1;`+(a+1)+`S`:J.ESC+`OS`;break;case 116:i.key=a?J.ESC+`[15;`+(a+1)+`~`:J.ESC+`[15~`;break;case 117:i.key=a?J.ESC+`[17;`+(a+1)+`~`:J.ESC+`[17~`;break;case 118:i.key=a?J.ESC+`[18;`+(a+1)+`~`:J.ESC+`[18~`;break;case 119:i.key=a?J.ESC+`[19;`+(a+1)+`~`:J.ESC+`[19~`;break;case 120:i.key=a?J.ESC+`[20;`+(a+1)+`~`:J.ESC+`[20~`;break;case 121:i.key=a?J.ESC+`[21;`+(a+1)+`~`:J.ESC+`[21~`;break;case 122:i.key=a?J.ESC+`[23;`+(a+1)+`~`:J.ESC+`[23~`;break;case 123:i.key=a?J.ESC+`[24;`+(a+1)+`~`:J.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=J.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=J.DEL:e.keyCode===219?i.key=J.ESC:e.keyCode===220?i.key=J.FS:e.keyCode===221&&(i.key=J.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=Yte[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=J.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=J.ESC+n}else if(e.keyCode===32)i.key=J.ESC+(e.ctrlKey?J.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=J.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=J.US),e.key===`@`&&(i.key=J.NUL))}return i}var fy=0,py=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new N_,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new N_,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((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(fy=this._search(t),fy===-1)||this._getKey(this._array[fy])!==t)return!1;do if(this._array[fy]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(fy),!0;while(++fy<this._array.length&&this._getKey(this._array[fy])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];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&&(fy=this._search(e),!(fy<0||fy>=this._array.length)&&this._getKey(this._array[fy])===e))do yield this._array[fy];while(++fy<this._array.length&&this._getKey(this._array[fy])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(fy=this._search(e),!(fy<0||fy>=this._array.length)&&this._getKey(this._array[fy])===e))do t(this._array[fy]);while(++fy<this._array.length&&this._getKey(this._array[fy])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},my=0,hy=0,gy=class extends G{constructor(){super(),this._decorations=new py(e=>e?.marker.line),this._onDecorationRegistered=this._register(new K),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new K),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Wp(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new _y(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{my=t.options.x??0,hy=my+(t.options.width??1),e>=my&&e<hy&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},_y=class extends Kp{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new K),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new K),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this._cachedBg=this.options.backgroundColor?Pg.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?Pg.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},vy=1e3,yy=class{constructor(e,t=vy){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},by=20,xy=class extends G{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new yy(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
68
|
-
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(q(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Wp(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<by+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
69
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===by+1&&(this._liveRegion.textContent+=Ff.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){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>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};xy=jf([W(1,cp),W(2,_p),W(3,yp)],xy);var Sy=class extends G{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new K),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new K),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Wp(()=>{Hp(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(q(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(q(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(q(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(q(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Cy(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Hp(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};Sy=jf([W(1,vp),W(2,yp),W(3,ip),W(4,Cp)],Sy);function Cy(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var wy=class extends Jte{constructor(e={}){super(e),this._linkifier=this._register(new qp),this.browser=g_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new qp),this._onCursorMove=this._register(new K),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new K),this.onKey=this._onKey.event,this._onRender=this._register(new K),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new K),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new K),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new K),this.onBell=this._onBell.event,this._onFocus=this._register(new K),this._onBlur=this._register(new K),this._onA11yCharEmitter=this._register(new K),this._onA11yTabEmitter=this._register(new K),this._onWillOpen=this._register(new K),this._setup(),this._decorationService=this._instantiationService.createInstance(gy),this._instantiationService.setService(pp,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(d_),this._instantiationService.setService(Cp,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(mp)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(em.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(em.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(em.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(em.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Wp(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=Ng.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${J.ESC}]${n};${Xv(r)}${Tg.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=Mg.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=Mg.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_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(xy,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(J.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(J.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(q(this.element,`copy`,e=>{this.hasSelection()&&Rf(e,this._selectionService)}));let e=e=>zf(e,this.textarea,this.coreService,this.optionsService);this._register(q(this.textarea,`paste`,e)),this._register(q(this.element,`paste`,e)),b_?this._register(q(this.element,`mousedown`,e=>{e.button===2&&Hf(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(q(this.element,`contextmenu`,e=>{Hf(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),O_&&this._register(q(this.element,`auxclick`,e=>{e.button===1&&Vf(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(q(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(q(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(q(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(q(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(q(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(q(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(q(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(q(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,Nf.get()),k_||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(l_,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(_p,this._coreBrowserService),this._register(q(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(q(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(a_,this._document,this._helperContainer),this._instantiationService.setService(gp,this._charSizeService),this._themeService=this._instantiationService.createInstance(ov),this._instantiationService.setService(Sp,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Bg),this._instantiationService.setService(xp,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(F_,this.rows,this.screenElement)),this._instantiationService.setService(yp,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(Eg,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(m_),this._instantiationService.setService(vp,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Sy,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(_g,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Z_,this.element,this.screenElement,r)),this._instantiationService.setService(bp,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(em.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(vg,this.screenElement)),this._register(q(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),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(xy,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Cg,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Cg,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(i_,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),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()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(q(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(q(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=J.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Bf(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 Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,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,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=Xte(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),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===J.ETX||n.key===J.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,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Ty(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(uv));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(J.ESC+`[I`):this.coreService.triggerDataEvent(J.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${J.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${J.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};function Ty(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Ey=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},Dy=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Zf)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Oy=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new Dy(t)}getNullCell(){return new Zf}},ky=class extends G{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new K),this.onBufferChange=this._onBufferChange.event,this._normal=new Oy(this._core.buffers.normal,`normal`),this._alternate=new Oy(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 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)}},Ay=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},jy=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}},My=[`cols`,`rows`],Ny=0,Py=class extends G{constructor(e){super(),this._core=this._register(new wy(e)),this._addonManager=this._register(new Ey),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(My.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw 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||=new Ay(this._core),this._parser}get unicode(){return this._checkProposedApi(),new jy(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._register(new ky(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
70
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Nf.get()},set promptLabel(e){Nf.set(e)},get tooMuchOutput(){return Ff.get()},set tooMuchOutput(e){Ff.set(e)}}}_verifyIntegers(...e){for(Ny of e)if(Ny===1/0||isNaN(Ny)||Ny%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(Ny of e)if(Ny&&(Ny===1/0||isNaN(Ny)||Ny%1!=0||Ny<0))throw Error(`This API only accepts positive integers`)}},Fy=`↑`,Iy=`↓`,Ly=`←`,Ry=`→`,zy=`⌘`,By={always:()=>!0,"calm-surface":e=>e.isCalmAvailable,"calm-view":e=>e.isCalmAvailable&&e.isCalmViewActive},Vy=Array.from({length:9},(e,t)=>[`Digit${t+1}`,t+1]),Hy=[{action:`next-attention`,keyCaptions:[`J`],label:`Jump to the next session needing you`,stepByCode:new Map([[`KeyJ`,0]]),availability:`always`},{action:`rail-step`,keyCaptions:[Fy,Iy],label:`Previous / next session in the rail`,stepByCode:new Map([[`ArrowUp`,-1],[`ArrowDown`,1]]),availability:`always`},{action:`view-step`,keyCaptions:[Ly,Ry],label:`Previous / next view tab`,stepByCode:new Map([[`ArrowLeft`,-1],[`ArrowRight`,1]]),availability:`always`,unavailablePlatform:`other`},{action:`view-step`,keyCaptions:[`PgUp`,`PgDn`],label:`Previous / next view tab`,stepByCode:new Map([[`PageUp`,-1],[`PageDown`,1]]),availability:`always`,unavailablePlatform:`mac`},{action:`session-nth`,keyCaptions:[`1..9`],label:`Jump to session 1 to 9`,stepByCode:new Map(Vy),availability:`always`},{action:`new-session`,keyCaptions:[`0`],label:`Add a session`,stepByCode:new Map([[`Digit0`,0]]),availability:`always`},{action:`merge`,keyCaptions:[`I`],label:`Merge the selected session`,stepByCode:new Map([[`KeyI`,0]]),availability:`always`},{action:`resolve-or-resync`,keyCaptions:[`U`],label:`Resolve a parked merge, or resync the base branch`,stepByCode:new Map([[`KeyU`,0]]),availability:`always`},{action:`calm-home`,keyCaptions:[`H`],label:`Go to the Calm view (Calm layout)`,stepByCode:new Map([[`KeyH`,0]]),availability:`calm-surface`,unavailablePlatform:`mac`},{action:`calm-terminal`,keyCaptions:[`T`],label:`Open the terminal of the open Calm panel (Calm layout)`,stepByCode:new Map([[`KeyT`,0]]),availability:`calm-view`,unavailablePlatform:`mac`}];function Uy(e){return Hy.filter(t=>t.unavailablePlatform!==e)}function Wy(e){return/Mac|iPhone|iPad/.test(e)?`mac`:`other`}function Gy(e,t){return e.ctrlKey||e.shiftKey?!1:t===`mac`?e.metaKey&&!e.altKey:e.altKey&&!e.metaKey}function Ky(e,t,n){if(!Gy(e,t))return null;for(let r of Uy(t)){if(!By[r.availability](n))continue;let t=r.stepByCode.get(e.code);if(t!==void 0)return{action:r.action,step:t}}return null}function qy(e){return e===`mac`?zy:`Alt`}function Jy(e,t){let n=Uy(t).find(t=>t.action===e);if(!n)throw Error(`Unknown dashboard shortcut: ${e}`);return n}function Yy(e,t){return[qy(t),Jy(e,t).keyCaptions.join(` `)]}function Xy(e,t){let[n,r]=Yy(e,t);return t===`mac`?`${n}${r}`:`${n}+${r}`}function Zte(e){let t=e===`mac`?`Meta`:`Alt`;return`ArrowUp ArrowDown ${t}+ArrowUp ${t}+ArrowDown`}function Qte(e){let t=qy(e),n=e===`mac`?zy:`Ctrl`;return[{title:`Dashboard`,items:Uy(e).map(e=>({combos:e.keyCaptions.map(e=>[t,e]),label:e.label}))},{title:`Navigation`,items:[{combos:[[Fy],[Iy]],label:`Move rail highlight (rail focused)`},{combos:[[Ly],[Ry]],label:`Switch view tab (tab focused)`}]},{title:`Terminal`,items:[{combos:[[n,`C`]],label:`Copy selection`},{combos:[[n,`V`]],label:`Paste`},{combos:[[n,`Backspace`]],label:`Delete previous word`}]},{title:`General`,items:[{combos:[[`Esc`]],label:`Close dialog / cancel rename`}]}]}var Zy=Wy(navigator.userAgent),Qy=()=>({isCalmAvailable:!1,isCalmViewActive:!1});function $te(e){Qy=e}function $y(){return Qy()}function eb(e,t){t.forEach((t,n)=>{n>0&&e.appendChild(V(`span`,`shortcut-sep`,`+`)),e.appendChild(V(`kbd`,`kbd`,t))})}function ene(e){let t=V(`span`,`shortcut-keys`);return eb(t,e),t}var tne=6,nne=262144,tb=16384,rne=()=>{};function nb(e,t){if(t.length<=tb){e.push(t);return}for(let n=0;n<t.length;n+=tb)e.push(t.slice(n,n+tb))}function rb({budget:e=tne,maxChunkBytes:t=nne,requestFrame:n,cancelFrame:r}={}){let i=n||(e=>requestAnimationFrame(e)),a=r||(e=>cancelAnimationFrame(e)),o=new Map,s=[],c=0,l=null;function u(){l===null&&(l=i(h))}function d(e){return e.readIdx<e.pending.length}function f(e){d(e)||(e.pending.length=0,e.readIdx=0,e.dirty=!1)}function p(e){return!!(e?.live&&e.dirty&&!e.inFlight&&d(e))}function m(){for(let e of o.values())if(p(e))return!0;return!1}function h(){l=null;let n=s.length,r=0;for(let i=0;i<n&&r<e;i++){let e=s[(c+i)%n],a=o.get(e);if(!p(a))continue;let l=[],m=0;for(;a.readIdx<a.pending.length;){let e=a.pending[a.readIdx];if(typeof e!=`string`){if(m>0)break;a.readIdx++,e.run();continue}let n=t-m;if(m+e.length<=t){nb(l,e),m+=e.length,a.readIdx++;continue}m===0&&(nb(l,e.slice(0,n)),m+=n,a.pending[a.readIdx]=e.slice(n));break}let h=l.pop();if(h===void 0){f(a),r++;continue}f(a),d(a)&&a.readIdx>=64&&(a.pending.splice(0,a.readIdx),a.readIdx=0),a.inFlight=!0;for(let e of l)a.write(e,rne);a.write(h,()=>{a.live&&(a.inFlight=!1,d(a)&&(a.dirty=!0,u()))}),r++}n>0&&(c=(c+1)%n),m()&&u()}return{register(e,t){let n=o.get(e);if(n){n.write=t,n.live=!0;return}o.set(e,{write:t,pending:[],readIdx:0,inFlight:!1,dirty:!1,live:!0}),s.push(e)},unregister(e){let t=o.get(e);if(!t)return;t.live=!1,o.delete(e);let n=s.indexOf(e);n!==-1&&s.splice(n,1),c>=s.length&&(c=0)},enqueue(e,t){let n=o.get(e);n&&t&&(n.pending.push(t),n.dirty=!0,u())},enqueueAction(e,t){let n=o.get(e);n&&(n.pending.push({run:t}),n.dirty=!0,u())},has(e){return o.has(e)},size(){return o.size},running(){return l!==null},stop(){l!==null&&(a(l),l=null)}}}var ib=rb(),ab=`chime`,ob=`custom:`,sb=`/custom-sounds`,cb=Object.freeze({chime:{label:`Chime`,peakGain:.12,tones:[{frequency:659.25,startSeconds:0,durationSeconds:.35,waveform:`sine`},{frequency:987.77,startSeconds:.14,durationSeconds:.5,waveform:`sine`}]},ping:{label:`Soft ping`,peakGain:.08,tones:[{frequency:1046.5,startSeconds:0,durationSeconds:.12,waveform:`triangle`},{frequency:1046.5,startSeconds:.13,durationSeconds:.12,waveform:`triangle`},{frequency:1318.51,startSeconds:.26,durationSeconds:.2,waveform:`triangle`}]},beep:{label:`Beep`,peakGain:.15,tones:[{frequency:880,startSeconds:0,durationSeconds:.2,waveform:`sine`}]}}),lb=Object.freeze(Object.entries(cb).map(([e,t])=>({id:e,label:t.label})));function ub(e){return`${ob}${e}`}function db(e){return`${sb}/${encodeURIComponent(e)}`}function fb(e){return e.startsWith(ob)&&e.slice(7)||null}function pb(e){let t=(e??[]).map(e=>({id:ub(e),label:e}));return[...lb,...t]}function mb(e,t){if(typeof e!=`string`)return ab;if(Object.hasOwn(cb,e))return e;let n=fb(e);return n&&(t===null||t.includes(n))?e:ab}function hb(e){return typeof e!=`object`||!e||!(`sounds`in e)||!Array.isArray(e.sounds)?[]:e.sounds.filter(e=>typeof e==`string`&&e!==``)}var gb=.3,_b=null;function vb(){return pb(_b)}function yb(e){return mb(e,_b)}async function bb(){try{let e=await fetch(sb,{credentials:`same-origin`,cache:`no-store`});e.ok&&(_b=hb(await e.json()))}catch{}}function xb(){let e=new AudioContext;return e.state===`suspended`&&e.resume(),e}function Sb(e,t){setTimeout(()=>e.close().catch(()=>{}),(t+.1)*1e3)}function Cb(e){let t=cb[e]??cb.chime,n=xb(),r=n.createGain();r.gain.value=t.peakGain,r.connect(n.destination);let i=n.currentTime,a=0;for(let e of t.tones){let t=i+e.startSeconds,o=t+e.durationSeconds,s=n.createOscillator(),c=n.createGain();s.type=e.waveform,s.frequency.value=e.frequency,c.gain.setValueAtTime(.001,t),c.gain.exponentialRampToValueAtTime(1,t+.01),c.gain.exponentialRampToValueAtTime(.001,o),s.connect(c),c.connect(r),s.start(t),s.stop(o),a=Math.max(a,e.startSeconds+e.durationSeconds)}Sb(n,a)}async function wb(e){try{let t=await fetch(db(e),{credentials:`same-origin`});return t.ok?await t.arrayBuffer():null}catch{return null}}async function Tb(e){let t=await wb(e);if(!t)return!1;let n=xb();try{let e=await n.decodeAudioData(t),r=n.createGain();r.gain.value=gb,r.connect(n.destination);let i=n.createBufferSource();return i.buffer=e,i.connect(r),i.start(),Sb(n,e.duration),!0}catch{return n.close().catch(()=>{}),!1}}var Eb=[659.25,830.61,987.77,1108.73,987.77,830.61,739.99,659.25,739.99,830.61,987.77,1108.73,987.77,830.61];function Db(){try{let e=new AudioContext;if(e.state===`suspended`&&e.resume(),e.state===`suspended`)return;let t=e.createGain();t.gain.value=.05,t.connect(e.destination);let n=.125,r=e.currentTime;for(let i=0;i<Eb.length;i++){let a=r+i*n,o=e.createOscillator(),s=e.createGain();o.type=`square`,o.frequency.value=Eb[i],s.gain.setValueAtTime(.001,a),s.gain.exponentialRampToValueAtTime(1,a+.01),s.gain.exponentialRampToValueAtTime(.001,a+n*.9),o.connect(s),s.connect(t),o.start(a),o.stop(a+n)}let i=r+Eb.length*n;t.gain.setValueAtTime(.05,i-.05),t.gain.exponentialRampToValueAtTime(.001,i),setTimeout(()=>e.close().catch(()=>{}),(i-r+.1)*1e3)}catch{}}function Ob(){try{Cb(ab)}catch{}}function kb(e){try{let t=yb(e),n=fb(t);if(!n){Cb(t);return}Tb(n).then(e=>{e||Ob()})}catch{}}var Ab={"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.06)`,"--state-running":`#22c55e`,"--state-running-bg":`rgba(34, 197, 94, 0.06)`,"--state-waiting":`#f59e0b`,"--state-waiting-bg":`rgba(245, 158, 11, 0.08)`,"--state-failed":`#ef4444`,"--state-failed-bg":`rgba(239, 68, 68, 0.06)`,"--state-initializing":`#6b7280`,"--state-initializing-bg":`rgba(107, 114, 128, 0.06)`,"--state-idle":`#eab308`,"--state-idle-bg":`rgba(234, 179, 8, 0.06)`},jb={background:`--bg-card`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`--border`,brightBlack:`--text-muted`,red:`#ef4444`,brightRed:`#f87171`,green:`#22c55e`,brightGreen:`#4ade80`,yellow:`#eab308`,brightYellow:`#facc15`,cyan:`#06b6d4`,brightCyan:`#22d3ee`},Mb={golgari:{label:`Golgari (Green/Black)`,colors:{"--bg":`#060b08`,"--bg-card":`#0a120e`,"--bg-header":`#081009`,"--bg-surface":`#0e1a12`,"--border":`#1a2e1f`,"--border-dim":`#122016`,"--border-hover":`#2a4a32`,"--text":`#b8ccbe`,"--text-dim":`#6a9070`,"--text-head":`#dceede`,"--text-muted":`#7a9a80`,"--accent":`#2dd4a0`,"--accent-dim":`#1a9a6e`,...Ab,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#2dd4a0`,"--state-done-bg":`rgba(45, 212, 160, 0.06)`,"--state-starting":`#a78bfa`,"--state-starting-bg":`rgba(167, 139, 250, 0.06)`,"--state-complete":`#34d399`,"--state-complete-bg":`rgba(52, 211, 153, 0.06)`},terminal:{...jb,foreground:`#c8dece`,blue:`--accent`,brightBlue:`#5ee8bc`,magenta:`#a855f7`,brightMagenta:`#c084fc`,white:`#c8dece`,brightWhite:`#e8f5ea`}},midnight:{label:`Midnight (Blue/Purple)`,colors:{"--bg":`#080816`,"--bg-card":`#0e0e20`,"--bg-header":`#0b0b1a`,"--bg-surface":`#131328`,"--border":`#1c1c38`,"--border-dim":`#141430`,"--border-hover":`#2a2a50`,"--text":`#b8b8d4`,"--text-dim":`#8585b3`,"--text-head":`#dcdcf0`,"--text-muted":`#7c7ca9`,"--accent":`#4f6ef7`,"--accent-dim":`#3a54c0`,...Ab,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#3b82f6`,"--state-done-bg":`rgba(59, 130, 246, 0.06)`,"--state-starting":`#a855f7`,"--state-starting-bg":`rgba(168, 85, 247, 0.06)`,"--state-complete":`#60a5fa`,"--state-complete-bg":`rgba(96, 165, 250, 0.06)`},terminal:{...jb,foreground:`#c8c8e0`,blue:`--accent`,brightBlue:`#60a5fa`,magenta:`#a855f7`,brightMagenta:`#c084fc`,white:`#c8c8e0`,brightWhite:`#e8e8ff`}},phyrexian:{label:`Phyrexian (Iridescent)`,colors:{"--bg":`#0a0810`,"--bg-card":`#100e18`,"--bg-header":`#0c0a14`,"--bg-surface":`#16122a`,"--border":`#2a2440`,"--border-dim":`#1e1a32`,"--border-hover":`#3e3660`,"--text":`#c8c0e0`,"--text-dim":`#8d82b9`,"--text-head":`#e8e0ff`,"--text-muted":`#8579b1`,"--accent":`#c084fc`,"--accent-dim":`#9656d6`,...Ab,"--state-monitoring":`#60a5fa`,"--state-monitoring-bg":`rgba(96, 165, 250, 0.08)`,"--state-done":`#67e8f9`,"--state-done-bg":`rgba(103, 232, 249, 0.06)`,"--state-starting":`#f472b6`,"--state-starting-bg":`rgba(244, 114, 182, 0.06)`,"--state-complete":`#34d399`,"--state-complete-bg":`rgba(52, 211, 153, 0.06)`},terminal:{...jb,foreground:`#c8c0e0`,blue:`#67e8f9`,brightBlue:`#a5f3fc`,magenta:`--accent`,brightMagenta:`#d8b4fe`,white:`#c8c0e0`,brightWhite:`#e8e0ff`}},compleated:{label:`Compleated (Light)`,colors:{"--bg":`#ece8e0`,"--bg-card":`#f7f4ee`,"--bg-header":`#f0ece4`,"--bg-surface":`#e4e0d6`,"--border":`#b8b0a0`,"--border-dim":`#ccc6b8`,"--border-hover":`#908878`,"--text":`#2a2622`,"--text-dim":`#5a5448`,"--text-head":`#0e0c0a`,"--text-muted":`#676157`,"--accent":`#0e0c0a`,"--accent-dim":`#2a2622`,"--state-running":`#16803c`,"--state-running-bg":`rgba(22, 128, 60, 0.08)`,"--state-waiting":`#b45309`,"--state-waiting-bg":`rgba(180, 83, 9, 0.08)`,"--state-failed":`#dc2626`,"--state-failed-bg":`rgba(220, 38, 38, 0.06)`,"--state-monitoring":`#0e7490`,"--state-monitoring-bg":`rgba(14, 116, 144, 0.08)`,"--state-done":`#1a1816`,"--state-done-bg":`rgba(26, 24, 22, 0.06)`,"--state-initializing":`#6b7280`,"--state-initializing-bg":`rgba(107, 114, 128, 0.06)`,"--state-idle":`#a16207`,"--state-idle-bg":`rgba(161, 98, 7, 0.06)`,"--state-starting":`#7c3aed`,"--state-starting-bg":`rgba(124, 58, 237, 0.06)`,"--state-complete":`#059669`,"--state-complete-bg":`rgba(5, 150, 105, 0.06)`},terminal:{background:`#faf8f4`,foreground:`#1a1816`,cursor:`#1a1816`,cursorAccent:`#faf8f4`,black:`#1a1816`,brightBlack:`#5a5448`,red:`#b91c1c`,brightRed:`#dc2626`,green:`#15803d`,brightGreen:`#16a34a`,yellow:`#92400e`,brightYellow:`#a16207`,blue:`#1d4ed8`,brightBlue:`#2563eb`,magenta:`#6d28d9`,brightMagenta:`#7c3aed`,cyan:`#0e7490`,brightCyan:`#0891b2`,white:`#5a5448`,brightWhite:`#3a3630`}},unicorn:{label:`Rainbow Unicorns (Dark)`,colors:{"--bg":`#191022`,"--bg-card":`#201730`,"--bg-header":`#1c1329`,"--bg-surface":`#281c3c`,"--border":`#3a2c52`,"--border-dim":`#2a2040`,"--border-hover":`#55407a`,"--text":`#d4c8e6`,"--text-dim":`#9a88b8`,"--text-head":`#ede4fa`,"--text-muted":`#a897c4`,"--accent":`#e8a3c4`,"--accent-dim":`#c4739e`,"--state-running":`#42d780`,"--state-running-bg":`rgba(66, 215, 128, 0.10)`,"--state-waiting":`#f79f3b`,"--state-waiting-bg":`rgba(247, 159, 59, 0.10)`,"--state-failed":`#f05442`,"--state-failed-bg":`rgba(240, 84, 66, 0.13)`,"--state-monitoring":`#2dd4bf`,"--state-monitoring-bg":`rgba(45, 212, 191, 0.08)`,"--state-done":`#f04ca4`,"--state-done-bg":`rgba(240, 76, 164, 0.13)`,"--state-initializing":`#8f87a6`,"--state-initializing-bg":`rgba(143, 135, 166, 0.08)`,"--state-idle":`#bcb02f`,"--state-idle-bg":`rgba(188, 176, 47, 0.08)`,"--state-starting":`#a17ef1`,"--state-starting-bg":`rgba(161, 126, 241, 0.08)`,"--state-complete":`#34baf4`,"--state-complete-bg":`rgba(52, 186, 244, 0.14)`},terminal:{background:`#201730`,foreground:`#d4c8e6`,cursor:`--accent`,cursorAccent:`#201730`,black:`#8c7dab`,brightBlack:`#9c8fb5`,red:`#e8887e`,brightRed:`#f4a89f`,green:`#86e0ab`,brightGreen:`#a3edc0`,yellow:`#f0c674`,brightYellow:`#f5d896`,blue:`#9cb3f0`,brightBlue:`#b5c8f5`,magenta:`#dd8ecf`,brightMagenta:`#e6a8dc`,cyan:`#7fd4d0`,brightCyan:`#a0e6e2`,white:`#d4c8e6`,brightWhite:`#f4ecfc`}},"posthog-light":{label:`PostHog (Light)`,colors:{"--bg":`#eeefe9`,"--bg-card":`#fdfdf8`,"--bg-header":`#eeefe9`,"--bg-surface":`#e5e7e0`,"--border":`#bfc1b7`,"--border-dim":`#d2d3cc`,"--border-hover":`#9ea096`,"--text":`#23251d`,"--text-dim":`#65675e`,"--text-head":`#111111`,"--text-muted":`#73756b`,"--accent":`#c03300`,"--accent-dim":`#8e2600`,"--state-running":`#4d7533`,"--state-running-bg":`rgba(77, 117, 51, 0.08)`,"--state-waiting":`#b17816`,"--state-waiting-bg":`rgba(177, 120, 22, 0.10)`,"--state-failed":`#8c0d3b`,"--state-failed-bg":`rgba(140, 13, 59, 0.07)`,"--state-monitoring":`#0e7490`,"--state-monitoring-bg":`rgba(14, 116, 144, 0.08)`,"--state-done":`#3e6b9e`,"--state-done-bg":`rgba(62, 107, 158, 0.08)`,"--state-initializing":`#73756b`,"--state-initializing-bg":`rgba(115, 117, 107, 0.07)`,"--state-idle":`#835c19`,"--state-idle-bg":`rgba(131, 92, 25, 0.07)`,"--state-starting":`#a621c8`,"--state-starting-bg":`rgba(166, 33, 200, 0.07)`,"--state-complete":`#34796f`,"--state-complete-bg":`rgba(52, 121, 111, 0.08)`},terminal:{background:`--bg-card`,foreground:`#23251d`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`#23251d`,brightBlack:`#65675e`,red:`#c03300`,brightRed:`#df6133`,green:`#4d7533`,brightGreen:`#6aa84f`,yellow:`#835c19`,brightYellow:`#b17816`,blue:`#3e6b9e`,brightBlue:`#2f80fa`,magenta:`#74108d`,brightMagenta:`#a621c8`,cyan:`#34796f`,brightCyan:`#30abc6`,white:`#4d4f46`,brightWhite:`#23251d`}},"posthog-dark":{label:`PostHog (Dark)`,colors:{"--bg":`#1e1f23`,"--bg-card":`#25262b`,"--bg-header":`#232429`,"--bg-surface":`#2d2e37`,"--border":`#3e424f`,"--border-dim":`#32343f`,"--border-hover":`#626674`,"--text":`#edeef4`,"--text-dim":`#aeb3c2`,"--text-head":`#fafafa`,"--text-muted":`#9ea096`,"--accent":`#f87a4c`,"--accent-dim":`#f54e00`,"--state-running":`#36c46f`,"--state-running-bg":`rgba(54, 196, 111, 0.08)`,"--state-waiting":`#f7a501`,"--state-waiting-bg":`rgba(247, 165, 1, 0.09)`,"--state-failed":`#f35454`,"--state-failed-bg":`rgba(243, 84, 84, 0.09)`,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#589df8`,"--state-done-bg":`rgba(88, 157, 248, 0.08)`,"--state-initializing":`#8f8f8c`,"--state-initializing-bg":`rgba(143, 143, 140, 0.07)`,"--state-idle":`#ffce5c`,"--state-idle-bg":`rgba(255, 206, 92, 0.07)`,"--state-starting":`#8567ff`,"--state-starting-bg":`rgba(133, 103, 255, 0.09)`,"--state-complete":`#29dbbb`,"--state-complete-bg":`rgba(41, 219, 187, 0.08)`},terminal:{background:`--bg-card`,foreground:`#edeef4`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`--border`,brightBlack:`--text-muted`,red:`#f35454`,brightRed:`#f87a4c`,green:`#36c46f`,brightGreen:`#96e5b6`,yellow:`#f7a501`,brightYellow:`#ffce5c`,blue:`#2f80fa`,brightBlue:`#9fc4ff`,magenta:`#8567ff`,brightMagenta:`#e2d6ff`,cyan:`#30abc6`,brightCyan:`#29dbbb`,white:`#aeb3c2`,brightWhite:`#fafafa`}}},Nb=`phyrexian`,Pb=null;function Fb(e){let t=Mb[e];if(!t)return;let n=Pb;Pb=e;let r=document.documentElement;r.dataset.theme=e;for(let[e,n]of Object.entries(t.colors))r.style.setProperty(e,n);e===`unicorn`&&n!==null&&n!==`unicorn`&&Db()}function Ib(e){document.documentElement.toggleAttribute(`data-compact-status`,e)}function Lb(e){document.documentElement.toggleAttribute(`data-show-usage`,e)}function Rb(){let e=Mb[Pb||Nb];if(!e)return{};let t=getComputedStyle(document.documentElement),n={};for(let[r,i]of Object.entries(e.terminal))n[r]=i.startsWith(`--`)?t.getPropertyValue(i).trim():i;return n}function zb(){return Object.entries(Mb).map(([e,t])=>({id:e,label:t.label}))}var Bb=k().int().min(1).max(500),Vb=k().int().min(1).max(200);fs(`type`,[M({type:F(`input`),data:O()}),M({type:F(`claim`),cols:Bb,rows:Vb}),M({type:F(`unview`)})]);var Hb=M({type:F(`pty-size`),cols:Bb,rows:Vb,seq:k().int().nonnegative()});function Ub(e){try{return JSON.parse(e)}catch{return null}}function Wb(e){let t=Hb.safeParse(Ub(e));return t.success?t.data:null}function Gb(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function Kb(e){return!e||!Number.isInteger(e.cols)||!Number.isInteger(e.rows)?!1:e.cols>0&&e.rows>0}function qb(e){return{cols:Math.min(Math.max(e.cols,1),500),rows:Math.min(Math.max(e.rows,1),200)}}function Jb({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&Gb(e,n))}function Yb({isDocumentVisible:e,isDocumentFocused:t,hasFocusInsideCard:n,hasWindowBlurredSinceFocus:r,isPhoneLayout:i}){return e?i||t?!0:n&&!r:!1}function Xb({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:Jb({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function Zb({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!Gb(e,t),s=Kb(n)?qb(n):null,c=r&&!!s&&!Gb(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:Jb({authoritative:e,isActiveViewer:r,lastClaim:a})}}function Qb(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function $b(e){let t=Qb(e);return t===null?null:Wb(t)}function ex(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=$b(e);return n?t.hasSeenSize?n.seq<=t.lastSeq?{kind:`stale`}:{kind:`size`,cols:n.cols,rows:n.rows,seq:n.seq}:{kind:`attach-size`,cols:n.cols,rows:n.rows,seq:n.seq}:{kind:`ignored`}}var tx=new Map([[`deleteContentBackward`,``],[`deleteByComposition`,``],[`deleteCompositionText`,``],[`deleteWordBackward`,`\x1B`],[`deleteSoftLineBackward`,`\x1B`],[`deleteHardLineBackward`,`\x1B`]]);function nx(e){return tx.get(e)??``}var rx=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function ix(e){return typeof e!=`string`||e===``||!rx.has(e)}function ax(e){return e?e.keyCode===229||e.key===`Process`:!1}function ox(e,t){let n=Array.from(e??``),r=Array.from(t??``),i=Math.min(n.length,r.length),a=0;for(;a<i&&n[a]===r[a];)a++;return``.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,`\r`)}var sx=new Set([`http:`,`https:`]);function cx(e){let t;try{t=new URL(e)}catch{return null}return sx.has(t.protocol)?t.href:null}var lx=/\bElectron\/\d/,ux=new Set([`localhost`,`127.0.0.1`]);function dx(e){return lx.test(e)}function fx({userAgent:e,pageHostname:t}){return dx(e)&&ux.has(t)}function px(e){return cx(e)!==null}var mx=new Set([0,1]);function hx({button:e,opensInNewTab:t}){return t&&mx.has(e)}function gx(){return fx({userAgent:navigator.userAgent,pageHostname:location.hostname})}function _x(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function vx(e){try{let t=await f();return(await fetch(`/open-external`,{method:`POST`,credentials:`same-origin`,cache:`no-store`,headers:{"content-type":`application/json`,"x-glimmervoid-page-token":t},body:JSON.stringify({url:e})})).ok}catch{return!1}}function yx(e){if(!gx()||!px(e)){_x(e);return}vx(e).then(t=>{t||_x(e)})}function bx(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&hx({button:e.button,opensInNewTab:t.target===`_blank`})&&px(t.href)&&(e.preventDefault(),yx(t.href))}function xx(e){gx()&&(e.addEventListener(`click`,bx,!0),e.addEventListener(`auxclick`,bx,!0))}var Sx=/https?:\/\/[^\s<>"']+/g,Cx=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),wx={")":`(`,"]":`[`,"}":`{`};function Tx(e,t){let n=0;for(let r of e)r===t&&n++;return n}function Ex(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(Cx.has(t)){e=e.slice(0,-1);continue}let n=wx[t];if(n&&Tx(e,n)<Tx(e,t)){e=e.slice(0,-1);continue}return e}}function Dx(e){let t=[];for(let n of e.matchAll(Sx)){let e=Ex(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var Ox=50;function kx(){return{activate(e,t){yx(t)},allowNonHttpProtocols:!1}}function Ax(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<Ox;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<Ox;)r++;let i=``,a=[];for(let t=n;t<=r;t++){let n=e.getLine(t);if(!n)break;for(let e=0;e<n.length;e++){let r=n.getCell(e);if(!r)break;if(r.getWidth()===0)continue;let o=r.getChars()||` `;for(let n=0;n<o.length;n++)i+=o[n],a.push({x:e+1,y:t+1})}}return{text:i,cellAt:a}}function jx(e){return e.registerLinkProvider({provideLinks(t,n){let r=e.buffer?.active;if(!r)return n(void 0);let{text:i,cellAt:a}=Ax(r,t),o=[];for(let{start:e,end:t,url:n}of Dx(i)){let r=a[e],i=a[t-1];r&&i&&o.push({range:{start:r,end:i},text:n,activate(e,t){yx(t)}})}n(o.length?o:void 0)}})}function Mx(e){return e===`\r`}var Nx=6e3,Px=400,Fx=`×`,Ix=new WeakMap;function Lx(){let e=document.getElementById(`notice-region`);return e||(e=V(`div`,`notice-region`),e.id=`notice-region`,e.setAttribute(`role`,`region`),e.setAttribute(`aria-label`,`Notifications`),document.body.appendChild(e)),e}function Rx(e){let t=Ix.get(e);t&&!t.dismissed&&(t.dismissed=!0,t.timer&&clearTimeout(t.timer),e.classList.add(`is-leaving`),e.addEventListener(`transitionend`,()=>e.remove(),{once:!0}),setTimeout(()=>e.remove(),Px))}function zx(e,t={}){let n=typeof e==`string`?e:String(e),r=t.persist===!0,i=Lx(),a=i.firstElementChild,o=a?Ix.get(a):null;if(o&&o.message===n&&!o.dismissed){if(!a)throw Error(`Toast state exists without a notice element`);o.count++;let e=H(a,`.notice-count`,`span`);return e.textContent=`x${o.count}`,e.hidden=!1,!r&&o.timer&&(clearTimeout(o.timer),o.timer=setTimeout(()=>Rx(a),Nx)),a}let s=V(`div`,r?`notice is-persistent`:`notice`),c={message:n,count:1,timer:null,dismissed:!1};Ix.set(s,c),s.setAttribute(`role`,`alert`);let l=V(`span`,`notice-glyph`,`!`);l.setAttribute(`aria-hidden`,`true`);let u=V(`span`,`notice-msg`,n),d=V(`span`,`notice-count`);d.hidden=!0;let f=V(`button`,`notice-close`,Fx);return f.type=`button`,f.setAttribute(`aria-label`,`Dismiss notification`),f.addEventListener(`click`,()=>Rx(s)),s.append(l,u,d,f),i.prepend(s),requestAnimationFrame(()=>s.classList.add(`is-visible`)),r||(c.timer=setTimeout(()=>Rx(s),Nx)),s}var Bx=1.2,Vx=.005;function Hx(e,t){let n=Math.abs(t);return n<10?!1:n>Math.abs(e)*Bx}function Ux(e,t,n=1/0){if(!(t>0))return{scrollLines:0,remainderPx:e};let r=Math.trunc(e/t),i=Math.max(-n,Math.min(n,r));return{scrollLines:i===0?0:-i,remainderPx:e-i*t}}function Wx(e,t,n){let r=e.length>=4?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function Gx(e){if(!e||e.length<2)return 0;let t=e[0],n=e[e.length-1],r=n.timestampMs-t.timestampMs;if(!(r>0))return 0;let i=(n.positionPx-t.positionPx)/r,a=Math.abs(i);if(!(a>=.08))return 0;let o=Math.min(a,5);return i<0?-o:o}function Kx({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function qx(e,t){if(!e)return{scrollLines:0,state:null};let n=t-e.lastMs;if(!(n>0))return{scrollLines:0,state:e};let r=Math.abs(e.velocityPxPerMs)-Vx*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=Ux(e.pendingPx+a,e.cellHeightPx);return{scrollLines:o,state:{velocityPxPerMs:i*r,lastMs:t,cellHeightPx:e.cellHeightPx,pendingPx:s}}}function Jx(e,t){return e===`alternate`||!!t&&t!==`none`}function Yx(e,t){return!(e>0)||!(t>0)?0:e/t}var Xx=1;function Zx(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function Qx(e,t){for(let n of e)if(n.identifier===t)return n;return null}function $x(e,t){if(Zx(t))return;let n=()=>document.documentElement.dataset.layout===`phone`,r=null,i=0,a=0,o=0,s=!1,c=0,l=[],u=null,d=null,f=()=>{d!==null&&cancelAnimationFrame(d),d=null,u=null},p=()=>Jx(t.buffer?.active?.type,t.modes?.mouseTrackingMode),m=()=>{let e=t.element?.querySelector(`.xterm-screen`);return Yx(e?.clientHeight||t.element?.clientHeight||0,t.rows)},h=()=>{r=null,s=!1,c=0,l=[]},g=(e,n,r)=>{let i=e<0?-1:1;for(let a=0;a<Math.abs(e);a++)t.element?.dispatchEvent(new WheelEvent(`wheel`,{deltaY:i,deltaMode:Xx,clientX:n,clientY:r,bubbles:!0,cancelable:!0}))},_=()=>{if(d=null,!u)return;if(!e.isConnected||!n()||p()){f();return}let r=t.buffer?.active?.viewportY,{scrollLines:i,state:a}=qx(u,performance.now());if(u=a,i!==0&&t.scrollLines(i),u){if(i!==0&&t.buffer?.active?.viewportY===r){f();return}d=requestAnimationFrame(_)}},v=(e,t,n)=>{u=Kx({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:m(),pendingPx:n}),u&&(d=requestAnimationFrame(_))};e.addEventListener(`touchstart`,e=>{if(f(),!n()||e.touches.length!==1){h();return}let t=e.touches[0];r=t.identifier,i=t.clientX,a=t.clientY,o=t.clientY,s=!1,c=0,l=[]},{passive:!0}),e.addEventListener(`touchmove`,e=>{if(r===null||!n())return;let u=Qx(e.touches,r);if(!u)return;if(!s){if(!Hx(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=Wx([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=Wx(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=Ux(c,m(),d?8:void 0);if(c=h,f!==0){if(d){g(f,u.clientX,u.clientY);return}t.scrollLines(f)}},{passive:!1}),e.addEventListener(`touchend`,e=>{if(!s||p()){h();return}l=Wx(l,o,e.timeStamp);let t=Gx(l),n=c;h(),t!==0&&v(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}var eS=Object.defineProperty,tS=Object.getOwnPropertyDescriptor,nS=(e,t,n,r)=>{for(var i=r>1?void 0:r?tS(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&eS(t,n,i),i},rS=(e,t)=>(n,r)=>t(n,r,e),iS=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?lS.isErrorNoTelemetry(e)?new lS(e.message+`
|
|
71
|
-
|
|
72
|
-
`+e.stack):Error(e.message+`
|
|
73
|
-
|
|
74
|
-
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function aS(e){sS(e)||iS.onUnexpectedError(e)}var oS=`Canceled`;function sS(e){return e instanceof cS||e instanceof Error&&e.name===oS&&e.message===oS}var cS=class extends Error{constructor(){super(oS),this.name=this.message}},lS=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},uS;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(uS||={});var dS=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||uS.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};dS.empty=new dS(e=>{});function fS(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var pS;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})(pS||={});var mS=null;function hS(e){return mS?.trackDisposable(e),e}function gS(e){mS?.markAsDisposed(e)}function _S(e,t){mS?.setParent(e,t)}function vS(e){if(pS.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function yS(...e){return bS(()=>vS(e))}function bS(e){let t=hS({dispose:fS(()=>{gS(t),e()})});return t}var xS=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,hS(this)}dispose(){this._isDisposed||(gS(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{vS(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return _S(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),_S(e,null))}};xS.DISABLE_DISPOSED_WARNING=!1;var SS=xS,CS=class{constructor(){this._store=new SS,hS(this),_S(this._store,this)}dispose(){gS(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};CS.None=Object.freeze({dispose(){}});var wS=class{constructor(){this._isDisposed=!1,hS(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&_S(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,gS(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&_S(e,null),e}},TS=typeof process<`u`&&`title`in process,ES=TS?`node`:navigator.userAgent,DS=TS?`node`:navigator.platform,OS=ES.includes(`Firefox`),kS=ES.includes(`Edge`),AS=/^((?!chrome|android).)*safari/i.test(ES);function jS(){if(!AS)return 0;let e=ES.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(DS),[`Windows`,`Win16`,`Win32`,`WinCE`].includes(DS),DS.indexOf(`Linux`),/\bCrOS\b/.test(ES);var MS=``,NS=0,PS=0,FS=0,IS=0,LS={css:`#00000000`,rgba:0},RS;(e=>{function t(e,t,n,r){return r===void 0?`#${US(e)}${US(t)}${US(n)}`:`#${US(e)}${US(t)}${US(n)}${US(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(RS||={});var zS;(e=>{function t(e,t){if(IS=(t.rgba&255)/255,IS===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return NS=a+Math.round((n-a)*IS),PS=o+Math.round((r-o)*IS),FS=s+Math.round((i-s)*IS),{css:RS.toCss(NS,PS,FS),rgba:RS.toRgba(NS,PS,FS)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=HS.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return RS.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[NS,PS,FS]=HS.toChannels(t),{css:RS.toCss(NS,PS,FS),rgba:t}}e.opaque=i;function a(e,t){return IS=Math.round(t*255),[NS,PS,FS]=HS.toChannels(e.rgba),{css:RS.toCss(NS,PS,FS,IS),rgba:RS.toRgba(NS,PS,FS,IS)}}e.opacity=a;function o(e,t){return IS=e.rgba&255,a(e,IS*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(zS||={});var BS;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return NS=parseInt(e.slice(1,2).repeat(2),16),PS=parseInt(e.slice(2,3).repeat(2),16),FS=parseInt(e.slice(3,4).repeat(2),16),RS.toColor(NS,PS,FS);case 5:return NS=parseInt(e.slice(1,2).repeat(2),16),PS=parseInt(e.slice(2,3).repeat(2),16),FS=parseInt(e.slice(3,4).repeat(2),16),IS=parseInt(e.slice(4,5).repeat(2),16),RS.toColor(NS,PS,FS,IS);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.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 NS=parseInt(r[1]),PS=parseInt(r[2]),FS=parseInt(r[3]),IS=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),RS.toColor(NS,PS,FS,IS);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[NS,PS,FS,IS]=t.getImageData(0,0,1,1).data,IS!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:RS.toRgba(NS,PS,FS,IS),css:e}}e.toColor=r})(BS||={});var VS;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(VS||={});var HS;(e=>{function t(e,t){if(IS=(t&255)/255,IS===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return NS=a+Math.round((n-a)*IS),PS=o+Math.round((r-o)*IS),FS=s+Math.round((i-s)*IS),RS.toRgba(NS,PS,FS)}e.blend=t;function n(e,t,n){let a=VS.relativeLuminance(e>>8),o=VS.relativeLuminance(t>>8);if(WS(a,o)<n){if(o<a){let o=r(e,t,n),s=WS(a,VS.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>WS(a,VS.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=WS(a,VS.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>WS(a,VS.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=WS(VS.relativeLuminance2(o,s,c),VS.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=WS(VS.relativeLuminance2(o,s,c),VS.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=WS(VS.relativeLuminance2(o,s,c),VS.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=WS(VS.relativeLuminance2(o,s,c),VS.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(HS||={});function US(e){let t=e.toString(16);return t.length<2?`0`+t:t}function WS(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function GS(e){if(!e)throw Error(`value must not be falsy`);return e}function KS(e){return 57508<=e&&e<=57558}function ine(e){return 57520<=e&&e<=57527}function ane(e){return 57344<=e&&e<=63743}function one(e){return 9472<=e&&e<=9631}function sne(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}function cne(e,t,n,r){return t===1&&n>Math.ceil(r*1.5)&&e!==void 0&&e>255&&!sne(e)&&!KS(e)&&!ane(e)}function qS(e){return KS(e)||one(e)}function lne(){return{css:{canvas:JS(),cell:JS()},device:{canvas:JS(),cell:JS(),char:{width:0,height:0,left:0,top:0}}}}function JS(){return{width:0,height:0}}function une(e,t,n=0){return(e-(Math.round(t)*2-n))%(Math.round(t)*2)}var YS=0,XS=0,ZS=!1,QS=!1,$S=!1,eC,tC=0,dne=class{constructor(e,t,n,r,i,a){this._terminal=e,this._optionService=t,this._selectionRenderModel=n,this._decorationService=r,this._coreBrowserService=i,this._themeService=a,this.result={fg:0,bg:0,ext:0}}resolve(e,t,n,r){if(this.result.bg=e.bg,this.result.fg=e.fg,this.result.ext=e.bg&268435456?e.extended.ext:0,XS=0,YS=0,QS=!1,ZS=!1,$S=!1,eC=this._themeService.colors,tC=0,e.getCode()!==0&&e.extended.underlineStyle===4){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));tC=t*r%(Math.round(e)*2)}if(this._decorationService.forEachDecorationAtCell(t,n,`bottom`,e=>{e.backgroundColorRGB&&(XS=e.backgroundColorRGB.rgba>>8&16777215,QS=!0),e.foregroundColorRGB&&(YS=e.foregroundColorRGB.rgba>>8&16777215,ZS=!0)}),$S=this._selectionRenderModel.isCellSelected(this._terminal,t,n),$S){if(this.result.fg&67108864||this.result.bg&50331648){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:XS=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:XS=(this.result.fg&16777215)<<8|255;break;default:XS=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:XS=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:XS=(this.result.bg&16777215)<<8|255}XS=HS.blend(XS,(this._coreBrowserService.isFocused?eC.selectionBackgroundOpaque:eC.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else XS=(this._coreBrowserService.isFocused?eC.selectionBackgroundOpaque:eC.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(QS=!0,eC.selectionForeground&&(YS=eC.selectionForeground.rgba>>8&16777215,ZS=!0),qS(e.getCode())){if(this.result.fg&67108864&&!(this.result.bg&50331648))YS=(this._coreBrowserService.isFocused?eC.selectionBackgroundOpaque:eC.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:YS=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:YS=(this.result.bg&16777215)<<8|255}else switch(this.result.fg&50331648){case 16777216:case 33554432:YS=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:YS=(this.result.fg&16777215)<<8|255;break;default:YS=this._themeService.colors.foreground.rgba}YS=HS.blend(YS,(this._coreBrowserService.isFocused?eC.selectionBackgroundOpaque:eC.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}ZS=!0}}this._decorationService.forEachDecorationAtCell(t,n,`top`,e=>{e.backgroundColorRGB&&(XS=e.backgroundColorRGB.rgba>>8&16777215,QS=!0),e.foregroundColorRGB&&(YS=e.foregroundColorRGB.rgba>>8&16777215,ZS=!0)}),QS&&(XS=$S?e.bg&-150994944|XS|50331648:e.bg&-16777216|XS|50331648),ZS&&(YS=e.fg&-83886080|YS|50331648),this.result.fg&67108864&&(QS&&!ZS&&(YS=this.result.bg&50331648?this.result.fg&-134217728|this.result.bg&67108863:this.result.fg&-134217728|eC.background.rgba>>8&16777215|50331648,ZS=!0),!QS&&ZS&&(XS=this.result.fg&50331648?this.result.bg&-67108864|this.result.fg&67108863:this.result.bg&-67108864|eC.foreground.rgba>>8&16777215|50331648,QS=!0)),eC=void 0,this.result.bg=QS?XS:this.result.bg,this.result.fg=ZS?YS:this.result.fg,this.result.ext&=536870911,this.result.ext|=tC<<29&3758096384}},fne=.5,nC=OS||kS?`bottom`:`ideographic`,pne={"▀":[{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}]},mne={"░":[[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]]},hne={"─":{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:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"║":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╒":{1:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╓":{1:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`},"╔":{1:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╕":{1:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`},"╖":{1:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`},"╗":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`},"╘":{1:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`},"╙":{1:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╚":{1:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`},"╛":{1:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`},"╜":{1:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`},"╝":{1:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`},"╞":{1:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╟":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`},"╠":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╡":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`},"╢":{1:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╣":{1:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`},"╤":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`},"╥":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`},"╦":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╧":{1:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╨":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╩":{1:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╪":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╫":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╬":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},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:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`},"╮":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`},"╯":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`},"╰":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`}},rC={"":{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}};rC[``]=rC[``],rC[``]=rC[``];function gne(e,t,n,r,i,a,o,s){let c=pne[t];if(c)return _ne(e,c,n,r,i,a),!0;let l=mne[t];if(l)return vne(e,l,n,r,i,a),!0;let u=hne[t];if(u)return yne(e,u,n,r,i,a,s),!0;let d=rC[t];return d?(bne(e,d,n,r,i,a,o,s),!0):!1}function _ne(e,t,n,r,i,a){for(let o=0;o<t.length;o++){let s=t[o],c=i/8,l=a/8;e.fillRect(n+s.x*c,r+s.y*l,s.w*c,s.h*l)}}var iC=new Map;function vne(e,t,n,r,i,a){let o=iC.get(t);o||(o=new Map,iC.set(t,o));let s=e.fillStyle;if(typeof s!=`string`)throw Error(`Unexpected fillStyle type "${s}"`);let c=o.get(s);if(!c){let n=t[0].length,r=t.length,i=e.canvas.ownerDocument.createElement(`canvas`);i.width=n,i.height=r;let a=GS(i.getContext(`2d`)),l=new ImageData(n,r),u,d,f,p;if(s.startsWith(`#`))u=parseInt(s.slice(1,3),16),d=parseInt(s.slice(3,5),16),f=parseInt(s.slice(5,7),16),p=s.length>7&&parseInt(s.slice(7,9),16)||1;else if(s.startsWith(`rgba`))[u,d,f,p]=s.substring(5,s.length-1).split(`,`).map(e=>parseFloat(e));else throw Error(`Unexpected fillStyle color format "${s}" when drawing pattern glyph`);for(let e=0;e<r;e++)for(let r=0;r<n;r++)l.data[(e*n+r)*4]=u,l.data[(e*n+r)*4+1]=d,l.data[(e*n+r)*4+2]=f,l.data[(e*n+r)*4+3]=t[e][r]*(p*255);a.putImageData(l,0,0),c=GS(e.createPattern(i,null)),o.set(s,c)}e.fillStyle=c,e.fillRect(n,r,i,a)}function yne(e,t,n,r,i,a,o){e.strokeStyle=e.fillStyle;for(let[s,c]of Object.entries(t)){e.beginPath(),e.lineWidth=o*Number.parseInt(s);let t;t=typeof c==`function`?c(.15,.15/a*i):c;for(let s of t.split(` `)){let t=s[0],c=oC[t];if(!c){console.error(`Could not find drawing instructions for "${t}"`);continue}let l=s.substring(1).split(`,`);!l[0]||!l[1]||c(e,sC(l,i,a,n,r,!0,o))}e.stroke(),e.closePath()}}function bne(e,t,n,r,i,a,o,s){let c=new Path2D;c.rect(n,r,i,a),e.clip(c),e.beginPath();let l=o/12;e.lineWidth=s*l;for(let o of t.d.split(` `)){let c=o[0],u=oC[c];if(!u){console.error(`Could not find drawing instructions for "${c}"`);continue}let d=o.substring(1).split(`,`);!d[0]||!d[1]||u(e,sC(d,i,a,n,r,!1,s,(t.leftPadding??0)*(l/2),(t.rightPadding??0)*(l/2)))}t.type===1?(e.strokeStyle=e.fillStyle,e.stroke()):e.fill(),e.closePath()}function aC(e,t,n=0){return Math.max(Math.min(e,t),n)}var oC={C:(e,t)=>e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]),L:(e,t)=>e.lineTo(t[0],t[1]),M:(e,t)=>e.moveTo(t[0],t[1])};function sC(e,t,n,r,i,a,o,s=0,c=0){let l=e.map(e=>parseFloat(e)||parseInt(e));if(l.length<2)throw Error(`Too few arguments for instruction`);for(let e=0;e<l.length;e+=2)l[e]*=t-s*o-c*o,a&&l[e]!==0&&(l[e]=aC(Math.round(l[e]+.5)-.5,t,0)),l[e]+=r+s*o;for(let e=1;e<l.length;e+=2)l[e]*=n,a&&l[e]!==0&&(l[e]=aC(Math.round(l[e]+.5)-.5,n,0)),l[e]+=i;return l}var cC=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},lC=class{constructor(){this._data=new cC}set(e,t,n,r,i){this._data.get(e,t)||this._data.set(e,t,new cC),this._data.get(e,t).set(n,r,i)}get(e,t,n,r){return this._data.get(e,t)?.get(n,r)}clear(){this._data.clear()}},uC=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},dC=class extends uC{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},fC=class extends uC{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},pC=!TS&&`requestIdleCallback`in window?fC:dC,mC=class e{constructor(){this.fg=0,this.bg=0,this.extended=new hC}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 t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}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):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},hC=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}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 e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},gC=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};gC.Undefined=new gC(void 0);var _C=globalThis.performance&&typeof globalThis.performance.now==`function`,vC=class e{static create(t){return new e(t)}constructor(e){this._now=_C&&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._now()-this._startTime:this._stopTime-this._startTime}},yC;(e=>{e.None=()=>CS.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(yS(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new jC({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new jC({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new jC({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new jC({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new jC({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function ee(e){let t=new jC;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=ee;function te(e,t){return e(e=>t.fire(e))}e.forward=te;function ne(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=ne;class re{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new jC(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ie(e,t){return new re(e,t).emitter.event}e.fromObservable=ie;function S(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof SS?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=S})(yC||={});var bC=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new vC,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}}};bC.all=new Set,bC._idPool=0;var xC=bC,SC=-1,CC=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new EC(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};CC._idPool=1;var wC=CC,TC=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
75
|
-
`).slice(2).join(`
|
|
76
|
-
`))}},EC=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},DC=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},OC=0,kC=class{constructor(e){this.value=e,this.id=OC++}},AC=2,jC=class{constructor(e){this._size=0,this._options=e,this._leakageMon=SC>0||this._options?.leakWarningThreshold?new wC(e?.onListenerError??aS,this._options?.leakWarningThreshold??SC):void 0,this._perfMon=this._options?._profName?new xC(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new DC(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||aS)(n),CS.None}if(this._disposed)return CS.None;t&&(e=e.bind(t));let r=new kC(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=TC.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof kC?(this._deliveryQueue??=new MC,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=bS(()=>{i?.(),this._removeListener(r)});return n instanceof SS?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*AC<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||aS;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners){if(this._listeners instanceof kC)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}}this._perfMon?.stop()}hasListeners(){return this._size>0}},MC=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},NC={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}},PC=2,FC,IC=class e{constructor(e,t,n){this._document=e,this._config=t,this._unicodeService=n,this._didWarmUp=!1,this._cacheMap=new lC,this._cacheMapCombined=new lC,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new mC,this._textureSize=512,this._onAddTextureAtlasCanvas=new jC,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new jC,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=BC(e,this._config.deviceCellWidth*4+PC*2,this._config.deviceCellHeight+PC*2),this._tmpCtx=GS(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(),!0)}_doWarmUp(){let e=new pC;for(let t=33;t<126;t++)e.enqueue(()=>{if(!this._cacheMap.get(t,0,0,0)){let e=this._drawToCache(t,0,0,0,!1,void 0);this._cacheMap.set(t,0,0,0,e)}})}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(e.maxAtlasPages&&this._pages.length>=Math.max(4,e.maxAtlasPages)){let t=this._pages.filter(t=>t.canvas.width*2<=(e.maxTextureSize||4096)).sort((e,t)=>t.canvas.width===e.canvas.width?t.percentageUsed-e.percentageUsed:t.canvas.width-e.canvas.width),n=-1,r=0;for(let e=0;e<t.length;e++)if(t[e].canvas.width!==r)n=e,r=t[e].canvas.width;else if(e-n===3)break;let i=t.slice(n,n+4),a=i.map(e=>e.glyphs[0].texturePage).sort((e,t)=>e>t?1:-1),o=this.pages.length-i.length,s=this._mergePages(i,o);s.version++;for(let e=a.length-1;e>=0;e--)this._deletePage(a[e]);this.pages.push(s),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(s.canvas)}let t=new LC(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(e,t){let n=e[0].canvas.width*2,r=new LC(this._document,n,e);for(let[i,a]of e.entries()){let e=i*a.canvas.width%n,o=Math.floor(i/2)*a.canvas.height;r.ctx.drawImage(a.canvas,e,o);for(let r of a.glyphs)r.texturePage=t,r.sizeClipSpace.x=r.size.x/n,r.sizeClipSpace.y=r.size.y/n,r.texturePosition.x+=e,r.texturePosition.y+=o,r.texturePositionClipSpace.x=r.texturePosition.x/n,r.texturePositionClipSpace.y=r.texturePosition.y/n;this._onRemoveTextureAtlasCanvas.fire(a.canvas);let s=this._activePages.indexOf(a);s!==-1&&this._activePages.splice(s,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let t=e;t<this._pages.length;t++){let e=this._pages[t];for(let t of e.glyphs)t.texturePage--;e.version++}}getRasterizedGlyphCombinedChar(e,t,n,r,i,a){return this._getFromCacheMap(this._cacheMapCombined,e,t,n,r,i,a)}getRasterizedGlyph(e,t,n,r,i,a){return this._getFromCacheMap(this._cacheMap,e,t,n,r,i,a)}_getFromCacheMap(e,t,n,r,i,a,o){return FC=e.get(t,n,r,i),FC||(FC=this._drawToCache(t,n,r,i,a,o),e.set(t,n,r,i,FC)),FC}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw Error(`No color found for idx `+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,t,n,r){if(this._config.allowTransparency)return LS;let i;switch(e){case 16777216:case 33554432:i=this._getColorFromAnsiIndex(t);break;case 50331648:let e=mC.toColorRGB(t);i=RS.toColor(e[0],e[1],e[2]);break;default:i=n?zS.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(i=zS.opaque(i)),i}_getForegroundColor(e,t,n,r,i,a,o,s,c,l){let u=this._getMinimumContrastColor(e,t,n,r,i,a,o,c,s,l);if(u)return u;let d;switch(i){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&c&&a<8&&(a+=8),d=this._getColorFromAnsiIndex(a);break;case 50331648:let e=mC.toColorRGB(a);d=RS.toColor(e[0],e[1],e[2]);break;default:d=o?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(d=zS.opaque(d)),s&&(d=zS.multiplyOpacity(d,fne)),d}_resolveBackgroundRgba(e,t,n){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,t,n,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&t<8&&(t+=8),this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,t,n,r,i,a,o,s,c,l){if(this._config.minimumContrastRatio===1||l)return;let u=this._getContrastCache(c),d=u.getColor(e,r);if(d!==void 0)return d||void 0;let f=this._resolveBackgroundRgba(t,n,o),p=this._resolveForegroundRgba(i,a,o,s),m=HS.ensureContrastRatio(f,p,this._config.minimumContrastRatio/(c?2:1));if(!m){u.setColor(e,r,null);return}let h=RS.toColor(m>>24&255,m>>16&255,m>>8&255);return u.setColor(e,r,h),h}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,n,r,i,a,o){let s=typeof t==`number`?String.fromCharCode(t):t;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display=`none`,o.append(this._tmpCanvas));let c=Math.min(this._config.deviceCellWidth*Math.max(s.length,2)+PC*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<c&&(this._tmpCanvas.width=c);let l=Math.min(this._config.deviceCellHeight+PC*4,this._textureSize);if(this._tmpCanvas.height<l&&(this._tmpCanvas.height=l),this._tmpCtx.save(),this._workAttributeData.fg=r,this._workAttributeData.bg=n,this._workAttributeData.extended.ext=i,this._workAttributeData.isInvisible())return NC;let u=!!this._workAttributeData.isBold(),d=!!this._workAttributeData.isInverse(),f=!!this._workAttributeData.isDim(),p=!!this._workAttributeData.isItalic(),m=!!this._workAttributeData.isUnderline(),h=!!this._workAttributeData.isStrikethrough(),g=!!this._workAttributeData.isOverline(),_=this._workAttributeData.getFgColor(),v=this._workAttributeData.getFgColorMode(),y=this._workAttributeData.getBgColor(),b=this._workAttributeData.getBgColorMode();if(d){let e=_;_=y,y=e;let t=v;v=b,b=t}let x=this._getBackgroundColor(b,y,d,f);this._tmpCtx.globalCompositeOperation=`copy`,this._tmpCtx.fillStyle=x.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation=`source-over`;let ee=u?this._config.fontWeightBold:this._config.fontWeight,te=p?`italic`:``;this._tmpCtx.font=`${te} ${ee} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=nC;let ne=s.length===1&&KS(s.charCodeAt(0)),re=s.length===1&&ine(s.charCodeAt(0)),ie=this._getForegroundColor(n,b,y,r,v,_,d,f,u,qS(s.charCodeAt(0)));this._tmpCtx.fillStyle=ie.css;let S=re?0:PC*2,ae=!1;this._config.customGlyphs!==!1&&(ae=gne(this._tmpCtx,s,S,S,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let oe=!ne,se;if(se=typeof t==`number`?this._unicodeService.wcwidth(t):this._unicodeService.getStringCellWidth(t),m){this._tmpCtx.save();let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;if(this._tmpCtx.lineWidth=e,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())oe=!1,this._tmpCtx.strokeStyle=`rgb(${mC.toColorRGB(this._workAttributeData.getUnderlineColor()).join(`,`)})`;else{oe=!1;let e=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&e<8&&(e+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(e).css}this._tmpCtx.beginPath();let n=S,r=Math.ceil(S+this._config.deviceCharHeight)-t-(a?e*2:0),i=r+e,o=r+e*2,c=this._workAttributeData.getUnderlineVariantOffset();for(let a=0;a<se;a++){this._tmpCtx.save();let s=n+a*this._config.deviceCellWidth,l=n+(a+1)*this._config.deviceCellWidth,u=s+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r),this._tmpCtx.moveTo(s,o),this._tmpCtx.lineTo(l,o);break;case 3:let n=e<=1?o:Math.ceil(S+this._config.deviceCharHeight-e/2)-t,a=e<=1?r:Math.ceil(S+this._config.deviceCharHeight+e/2)-t,d=new Path2D;d.rect(s,r,this._config.deviceCellWidth,o-r),this._tmpCtx.clip(d),this._tmpCtx.moveTo(s-this._config.deviceCellWidth/2,i),this._tmpCtx.bezierCurveTo(s-this._config.deviceCellWidth/2,a,s,a,s,i),this._tmpCtx.bezierCurveTo(s,n,u,n,u,i),this._tmpCtx.bezierCurveTo(u,a,l,a,l,i),this._tmpCtx.bezierCurveTo(l,n,l+this._config.deviceCellWidth/2,n,l+this._config.deviceCellWidth/2,i);break;case 4:let f=c===0?0:c>=e?e*2-c:e-c;c>=e||f===0?(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(s+f,r),this._tmpCtx.lineTo(l,r)):(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(s+f,r),this._tmpCtx.moveTo(s+f+e,r),this._tmpCtx.lineTo(l,r)),c=une(l-s,e,c);break;case 5:let p=l-s,m=Math.floor(.6*p),h=Math.floor(.3*p),g=p-m-h;this._tmpCtx.setLineDash([m,h,g]),this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r);break;default:this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r)}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!ae&&this._config.fontSize>=12&&!this._config.allowTransparency&&s!==` `){this._tmpCtx.save(),this._tmpCtx.textBaseline=`alphabetic`;let t=this._tmpCtx.measureText(s);if(this._tmpCtx.restore(),`actualBoundingBoxDescent`in t&&t.actualBoundingBoxDescent>0){this._tmpCtx.save();let t=new Path2D;t.rect(n,r-Math.ceil(e/2),this._config.deviceCellWidth*se,o-r+Math.ceil(e/2)),this._tmpCtx.clip(t),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=x.css,this._tmpCtx.strokeText(s,S,S+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(g){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(S,S+t),this._tmpCtx.lineTo(S+this._config.deviceCharWidth*se,S+t),this._tmpCtx.stroke()}if(ae||this._tmpCtx.fillText(s,S,S+this._config.deviceCharHeight),s===`_`&&!this._config.allowTransparency){let e=RC(this._tmpCtx.getImageData(S,S,this._config.deviceCellWidth,this._config.deviceCellHeight),x,ie,oe);if(e)for(let t=1;t<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=x.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(s,S,S+this._config.deviceCharHeight-t),e=RC(this._tmpCtx.getImageData(S,S,this._config.deviceCellWidth,this._config.deviceCellHeight),x,ie,oe),e);t++);}if(h){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),t=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(S,S+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(S+this._config.deviceCharWidth*se,S+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let ce=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),le;if(le=this._config.allowTransparency?zC(ce):RC(ce,x,ie,oe),le)return NC;let C=this._findGlyphBoundingBox(ce,this._workBoundingBox,c,re,ae,S),w,T;for(;;){if(this._activePages.length===0){let e=this._createNewPage();w=e,T=e.currentRow,T.height=C.size.y;break}w=this._activePages[this._activePages.length-1],T=w.currentRow;for(let e of this._activePages)C.size.y<=e.currentRow.height&&(w=e,T=e.currentRow);for(let e=this._activePages.length-1;e>=0;e--)for(let t of this._activePages[e].fixedRows)t.height<=T.height&&C.size.y<=t.height&&(w=this._activePages[e],T=t);if(C.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new LC(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),w=this._overflowSizePage,T=this._overflowSizePage.currentRow,T.x+C.size.x>=w.canvas.width&&(T.x=0,T.y+=T.height,T.height=0);break}if(T.y+C.size.y>=w.canvas.height||T.height>C.size.y+2){let t=!1;if(w.currentRow.y+w.currentRow.height+C.size.y>=w.canvas.height){let n;for(let e of this._activePages)if(e.currentRow.y+e.currentRow.height+C.size.y<e.canvas.height){n=e;break}if(n)w=n;else if(e.maxAtlasPages&&this._pages.length>=e.maxAtlasPages&&T.y+C.size.y<=w.canvas.height&&T.height>=C.size.y&&T.x+C.size.x<=w.canvas.width)t=!0;else{let e=this._createNewPage();w=e,T=e.currentRow,T.height=C.size.y,t=!0}}t||(w.currentRow.height>0&&w.fixedRows.push(w.currentRow),T={x:0,y:w.currentRow.y+w.currentRow.height,height:C.size.y},w.fixedRows.push(T),w.currentRow={x:0,y:T.y+T.height,height:0})}if(T.x+C.size.x<=w.canvas.width)break;T===w.currentRow?(T.x=0,T.y+=T.height,T.height=0):w.fixedRows.splice(w.fixedRows.indexOf(T),1)}return C.texturePage=this._pages.indexOf(w),C.texturePosition.x=T.x,C.texturePosition.y=T.y,C.texturePositionClipSpace.x=T.x/w.canvas.width,C.texturePositionClipSpace.y=T.y/w.canvas.height,C.sizeClipSpace.x/=w.canvas.width,C.sizeClipSpace.y/=w.canvas.height,T.height=Math.max(T.height,C.size.y),T.x+=C.size.x,w.ctx.putImageData(ce,C.texturePosition.x-this._workBoundingBox.left,C.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,C.size.x,C.size.y),w.addGlyph(C),w.version++,C}_findGlyphBoundingBox(e,t,n,r,i,a){t.top=0;let o=r?this._config.deviceCellHeight:this._tmpCanvas.height,s=r?this._config.deviceCellWidth:n,c=!1;for(let n=0;n<o;n++){for(let r=0;r<s;r++){let i=n*this._tmpCanvas.width*4+r*4+3;if(e.data[i]!==0){t.top=n,c=!0;break}}if(c)break}t.left=0,c=!1;for(let n=0;n<a+s;n++){for(let r=0;r<o;r++){let i=r*this._tmpCanvas.width*4+n*4+3;if(e.data[i]!==0){t.left=n,c=!0;break}}if(c)break}t.right=s,c=!1;for(let n=a+s-1;n>=a;n--){for(let r=0;r<o;r++){let i=r*this._tmpCanvas.width*4+n*4+3;if(e.data[i]!==0){t.right=n,c=!0;break}}if(c)break}t.bottom=o,c=!1;for(let n=o-1;n>=0;n--){for(let r=0;r<s;r++){let i=n*this._tmpCanvas.width*4+r*4+3;if(e.data[i]!==0){t.bottom=n,c=!0;break}}if(c)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:t.right-t.left+1,y:t.bottom-t.top+1},sizeClipSpace:{x:t.right-t.left+1,y:t.bottom-t.top+1},offset:{x:-t.left+a+(r||i?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-t.top+a+(r||i?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},LC=class{constructor(e,t,n){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],n)for(let e of n)this._glyphs.push(...e.glyphs),this._usedPixels+=e._usedPixels;this.canvas=BC(e,t,t),this.ctx=GS(this.canvas.getContext(`2d`,{alpha:!0}))}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(e){this._glyphs.push(e),this._usedPixels+=e.size.x*e.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 RC(e,t,n,r){let i=t.rgba>>>24,a=t.rgba>>>16&255,o=t.rgba>>>8&255,s=n.rgba>>>24,c=n.rgba>>>16&255,l=n.rgba>>>8&255,u=Math.floor((Math.abs(i-s)+Math.abs(a-c)+Math.abs(o-l))/12),d=!0;for(let t=0;t<e.data.length;t+=4)e.data[t]===i&&e.data[t+1]===a&&e.data[t+2]===o||r&&Math.abs(e.data[t]-i)+Math.abs(e.data[t+1]-a)+Math.abs(e.data[t+2]-o)<u?e.data[t+3]=0:d=!1;return d}function zC(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}function BC(e,t,n){let r=e.createElement(`canvas`);return r.width=t,r.height=n,r}function VC(e,t,n,r,i,a,o,s){let c={foreground:a.foreground,background:a.background,cursor:LS,cursorAccent:LS,selectionForeground:LS,selectionBackgroundTransparent:LS,selectionBackgroundOpaque:LS,selectionInactiveBackgroundTransparent:LS,selectionInactiveBackgroundOpaque:LS,overviewRulerBorder:LS,scrollbarSliderBackground:LS,scrollbarSliderHoverBackground:LS,scrollbarSliderActiveBackground:LS,ansi:a.ansi.slice(),contrastCache:a.contrastCache,halfContrastCache:a.halfContrastCache};return{customGlyphs:i.customGlyphs,devicePixelRatio:o,deviceMaxTextureSize:s,letterSpacing:i.letterSpacing,lineHeight:i.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:n,deviceCharHeight:r,fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontWeightBold:i.fontWeightBold,allowTransparency:i.allowTransparency,drawBoldTextInBrightColors:i.drawBoldTextInBrightColors,minimumContrastRatio:i.minimumContrastRatio,colors:c}}function HC(e,t){for(let n=0;n<e.colors.ansi.length;n++)if(e.colors.ansi[n].rgba!==t.colors.ansi[n].rgba)return!1;return e.devicePixelRatio===t.devicePixelRatio&&e.customGlyphs===t.customGlyphs&&e.lineHeight===t.lineHeight&&e.letterSpacing===t.letterSpacing&&e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontWeightBold===t.fontWeightBold&&e.allowTransparency===t.allowTransparency&&e.deviceCharWidth===t.deviceCharWidth&&e.deviceCharHeight===t.deviceCharHeight&&e.drawBoldTextInBrightColors===t.drawBoldTextInBrightColors&&e.minimumContrastRatio===t.minimumContrastRatio&&e.colors.foreground.rgba===t.colors.foreground.rgba&&e.colors.background.rgba===t.colors.background.rgba}function UC(e){return(e&50331648)==16777216||(e&50331648)==33554432}var WC=[];function GC(e,t,n,r,i,a,o,s,c){let l=VC(r,i,a,o,t,n,s,c);for(let t=0;t<WC.length;t++){let n=WC[t],r=n.ownedBy.indexOf(e);if(r>=0){if(HC(n.config,l))return n.atlas;n.ownedBy.length===1?(n.atlas.dispose(),WC.splice(t,1)):n.ownedBy.splice(r,1);break}}for(let t=0;t<WC.length;t++){let n=WC[t];if(HC(n.config,l))return n.ownedBy.push(e),n.atlas}let u=e._core,d={atlas:new IC(document,l,u.unicodeService),config:l,ownedBy:[e]};return WC.push(d),d.atlas}function KC(e){for(let t=0;t<WC.length;t++){let n=WC[t].ownedBy.indexOf(e);if(n!==-1){WC[t].ownedBy.length===1?(WC[t].atlas.dispose(),WC.splice(t,1)):WC[t].ownedBy.splice(n,1);break}}}var qC=600,JC=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout&&=(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),void 0),this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}))}_restartInterval(e=qC){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=qC-(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=qC-(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})},qC)},e)}pause(){this.isCursorVisible=!0,this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout&&=(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),void 0),this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function YC(e,t,n){let r=new t.ResizeObserver(t=>{let i=t.find(t=>t.target===e);if(!i)return;if(!(`devicePixelContentBoxSize`in i)){r?.disconnect(),r=void 0;return}let a=i.devicePixelContentBoxSize[0].inlineSize,o=i.devicePixelContentBoxSize[0].blockSize;a>0&&o>0&&n(a,o)});try{r.observe(e,{box:[`device-pixel-content-box`]})}catch{r.disconnect(),r=void 0}return bS(()=>r?.disconnect())}function XC(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var ZC=class e extends mC{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new hC,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?XC(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 t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},QC=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function $C(e,t,n){let r=GS(e.createProgram());if(e.attachShader(r,GS(ew(e,e.VERTEX_SHADER,t))),e.attachShader(r,GS(ew(e,e.FRAGMENT_SHADER,n))),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS))return r;console.error(e.getProgramInfoLog(r)),e.deleteProgram(r)}function ew(e,t,n){let r=GS(e.createShader(t));if(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS))return r;console.error(e.getShaderInfoLog(r)),e.deleteShader(r)}function tw(e,t){let n=Math.min(e.length*2,t),r=new Float32Array(n);for(let t=0;t<e.length;t++)r[t]=e[t];return r}var nw=class{constructor(e){this.texture=e,this.version=-1}},rw=`#version 300 es
|
|
77
|
-
layout (location = 0) in vec2 a_unitquad;
|
|
78
|
-
layout (location = 1) in vec2 a_cellpos;
|
|
79
|
-
layout (location = 2) in vec2 a_offset;
|
|
80
|
-
layout (location = 3) in vec2 a_size;
|
|
81
|
-
layout (location = 4) in float a_texpage;
|
|
82
|
-
layout (location = 5) in vec2 a_texcoord;
|
|
83
|
-
layout (location = 6) in vec2 a_texsize;
|
|
84
|
-
|
|
85
|
-
uniform mat4 u_projection;
|
|
86
|
-
uniform vec2 u_resolution;
|
|
87
|
-
|
|
88
|
-
out vec2 v_texcoord;
|
|
89
|
-
flat out int v_texpage;
|
|
90
|
-
|
|
91
|
-
void main() {
|
|
92
|
-
vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);
|
|
93
|
-
gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
|
|
94
|
-
v_texpage = int(a_texpage);
|
|
95
|
-
v_texcoord = a_texcoord + a_unitquad * a_texsize;
|
|
96
|
-
}`;function iw(e){let t=``;for(let n=1;n<e;n++)t+=` else if (v_texpage == ${n}) { outColor = texture(u_texture[${n}], v_texcoord); }`;return`#version 300 es
|
|
97
|
-
precision lowp float;
|
|
98
|
-
|
|
99
|
-
in vec2 v_texcoord;
|
|
100
|
-
flat in int v_texpage;
|
|
101
|
-
|
|
102
|
-
uniform sampler2D u_texture[${e}];
|
|
103
|
-
|
|
104
|
-
out vec4 outColor;
|
|
105
|
-
|
|
106
|
-
void main() {
|
|
107
|
-
if (v_texpage == 0) {
|
|
108
|
-
outColor = texture(u_texture[0], v_texcoord);
|
|
109
|
-
} ${t}
|
|
110
|
-
}`}var aw=11,ow=aw*Float32Array.BYTES_PER_ELEMENT,sw=2,cw=0,lw,uw=0,dw=0,fw=class extends CS{constructor(e,t,n,r){super(),this._terminal=e,this._gl=t,this._dimensions=n,this._optionsService=r,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array,attributesBuffers:[new Float32Array,new Float32Array]};let i=this._gl;IC.maxAtlasPages===void 0&&(IC.maxAtlasPages=Math.min(32,GS(i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS))),IC.maxTextureSize=GS(i.getParameter(i.MAX_TEXTURE_SIZE))),this._program=GS($C(i,rw,iw(IC.maxAtlasPages))),this._register(bS(()=>i.deleteProgram(this._program))),this._projectionLocation=GS(i.getUniformLocation(this._program,`u_projection`)),this._resolutionLocation=GS(i.getUniformLocation(this._program,`u_resolution`)),this._textureLocation=GS(i.getUniformLocation(this._program,`u_texture`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(bS(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(bS(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=GS(i.createBuffer()),this._register(bS(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,2,i.FLOAT,!1,ow,0),i.vertexAttribDivisor(2,1),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,i.FLOAT,!1,ow,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(3,1),i.enableVertexAttribArray(4),i.vertexAttribPointer(4,1,i.FLOAT,!1,ow,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(4,1),i.enableVertexAttribArray(5),i.vertexAttribPointer(5,2,i.FLOAT,!1,ow,5*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(5,1),i.enableVertexAttribArray(6),i.vertexAttribPointer(6,2,i.FLOAT,!1,ow,7*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(6,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,ow,9*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.useProgram(this._program);let l=new Int32Array(IC.maxAtlasPages);for(let e=0;e<IC.maxAtlasPages;e++)l[e]=e;i.uniform1iv(this._textureLocation,l),i.uniformMatrix4fv(this._projectionLocation,!1,QC),this._atlasTextures=[];for(let e=0;e<IC.maxAtlasPages;e++){let t=new nw(GS(i.createTexture()));this._register(bS(()=>i.deleteTexture(t.texture))),i.activeTexture(i.TEXTURE0+e),i.bindTexture(i.TEXTURE_2D,t.texture),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[e]=t}i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return!this._atlas||this._atlas.beginFrame()}updateCell(e,t,n,r,i,a,o,s,c){this._updateCell(this._vertices.attributes,e,t,n,r,i,a,o,s,c)}_updateCell(e,t,n,r,i,a,o,s,c,l){if(cw=(n*this._terminal.cols+t)*aw,r===0||r===void 0){e.fill(0,cw,cw+aw-1-sw);return}this._atlas&&(lw=s&&s.length>1?this._atlas.getRasterizedGlyphCombinedChar(s,i,a,o,!1,this._terminal.element):this._atlas.getRasterizedGlyph(r,i,a,o,!1,this._terminal.element),uw=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),i!==l&&lw.offset.x>uw?(dw=lw.offset.x-uw,e[cw]=-(lw.offset.x-dw)+this._dimensions.device.char.left,e[cw+1]=-lw.offset.y+this._dimensions.device.char.top,e[cw+2]=(lw.size.x-dw)/this._dimensions.device.canvas.width,e[cw+3]=lw.size.y/this._dimensions.device.canvas.height,e[cw+4]=lw.texturePage,e[cw+5]=lw.texturePositionClipSpace.x+dw/this._atlas.pages[lw.texturePage].canvas.width,e[cw+6]=lw.texturePositionClipSpace.y,e[cw+7]=lw.sizeClipSpace.x-dw/this._atlas.pages[lw.texturePage].canvas.width,e[cw+8]=lw.sizeClipSpace.y):(e[cw]=-lw.offset.x+this._dimensions.device.char.left,e[cw+1]=-lw.offset.y+this._dimensions.device.char.top,e[cw+2]=lw.size.x/this._dimensions.device.canvas.width,e[cw+3]=lw.size.y/this._dimensions.device.canvas.height,e[cw+4]=lw.texturePage,e[cw+5]=lw.texturePositionClipSpace.x,e[cw+6]=lw.texturePositionClipSpace.y,e[cw+7]=lw.sizeClipSpace.x,e[cw+8]=lw.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&cne(r,c,lw.size.x,this._dimensions.device.cell.width)&&(e[cw+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let e=this._terminal,t=e.cols*e.rows*aw;this._vertices.count===t?this._vertices.attributes.fill(0):this._vertices.attributes=new Float32Array(t);let n=0;for(;n<this._vertices.attributesBuffers.length;n++)this._vertices.count===t?this._vertices.attributesBuffers[n].fill(0):this._vertices.attributesBuffers[n]=new Float32Array(t);this._vertices.count=t,n=0;for(let t=0;t<e.rows;t++)for(let r=0;r<e.cols;r++)this._vertices.attributes[n+9]=r/e.cols,this._vertices.attributes[n+10]=t/e.rows,n+=aw}handleResize(){let e=this._gl;e.useProgram(this._program),e.viewport(0,0,e.canvas.width,e.canvas.height),e.uniform2f(this._resolutionLocation,e.canvas.width,e.canvas.height),this.clear()}render(e){if(!this._atlas)return;let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let n=this._vertices.attributesBuffers[this._activeBuffer],r=0;for(let t=0;t<e.lineLengths.length;t++){let i=t*this._terminal.cols*aw,a=this._vertices.attributes.subarray(i,i+e.lineLengths[t]*aw);n.set(a,r),r+=a.length}t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,n.subarray(0,r),t.STREAM_DRAW);for(let e=0;e<this._atlas.pages.length;e++)this._atlas.pages[e].version!==this._atlasTextures[e].version&&this._bindAtlasPageTexture(t,this._atlas,e);t.drawElementsInstanced(t.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,r/aw)}setAtlas(e){this._atlas=e;for(let e of this._atlasTextures)e.version=-1}_bindAtlasPageTexture(e,t,n){e.activeTexture(e.TEXTURE0+n),e.bindTexture(e.TEXTURE_2D,this._atlasTextures[n].texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.pages[n].canvas),e.generateMipmap(e.TEXTURE_2D),this._atlasTextures[n].version=t.pages[n].version}setDimensions(e){this._dimensions=e}},pw=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function mw(){return new pw}var hw=4,gw=1,_w=2,vw=3,yw=2147483648,bw=class{constructor(){this.cells=new Uint32Array,this.lineLengths=new Uint32Array,this.selection=mw()}resize(e,t){let n=e*t*hw;n!==this.cells.length&&(this.cells=new Uint32Array(n),this.lineLengths=new Uint32Array(t))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},xw=`#version 300 es
|
|
111
|
-
layout (location = 0) in vec2 a_position;
|
|
112
|
-
layout (location = 1) in vec2 a_size;
|
|
113
|
-
layout (location = 2) in vec4 a_color;
|
|
114
|
-
layout (location = 3) in vec2 a_unitquad;
|
|
115
|
-
|
|
116
|
-
uniform mat4 u_projection;
|
|
117
|
-
|
|
118
|
-
out vec4 v_color;
|
|
119
|
-
|
|
120
|
-
void main() {
|
|
121
|
-
vec2 zeroToOne = a_position + (a_unitquad * a_size);
|
|
122
|
-
gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
|
|
123
|
-
v_color = a_color;
|
|
124
|
-
}`,Sw=`#version 300 es
|
|
125
|
-
precision lowp float;
|
|
126
|
-
|
|
127
|
-
in vec4 v_color;
|
|
128
|
-
|
|
129
|
-
out vec4 outColor;
|
|
130
|
-
|
|
131
|
-
void main() {
|
|
132
|
-
outColor = v_color;
|
|
133
|
-
}`,Cw=8,ww=Cw*Float32Array.BYTES_PER_ELEMENT,Tw=20*Cw,Ew=class{constructor(){this.attributes=new Float32Array(Tw),this.count=0}},Dw=0,Ow=0,kw=0,Aw=0,jw=0,Mw=0,Nw=0,Pw=class extends CS{constructor(e,t,n,r){super(),this._terminal=e,this._gl=t,this._dimensions=n,this._themeService=r,this._vertices=new Ew,this._verticesCursor=new Ew;let i=this._gl;this._program=GS($C(i,xw,Sw)),this._register(bS(()=>i.deleteProgram(this._program))),this._projectionLocation=GS(i.getUniformLocation(this._program,`u_projection`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(bS(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(bS(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=GS(i.createBuffer()),this._register(bS(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,ww,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,ww,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,ww,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(2,1),this._updateCachedColors(r.colors),this._register(this._themeService.onChangeColors(e=>{this._updateCachedColors(e),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(e){let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,QC),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,e.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,e.count)}handleResize(){this._updateViewportRectangle()}setDimensions(e){this._dimensions=e}_updateCachedColors(e){this._bgFloat=this._colorToFloat32Array(e.background),this._cursorFloat=this._colorToFloat32Array(e.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(e){let t=this._terminal,n=this._vertices,r=1,i,a,o,s,c,l,u,d,f,p,m;for(i=0;i<t.rows;i++){for(o=-1,s=0,c=0,l=!1,a=0;a<t.cols;a++)u=(i*t.cols+a)*hw,d=e.cells[u+gw],f=e.cells[u+_w],p=!!(f&67108864),(d!==s||f!==c&&(l||p))&&((s!==0||l&&c!==0)&&(m=r++*Cw,this._updateRectangle(n,m,c,s,o,a,i)),o=a,s=d,c=f,l=p);(s!==0||l&&c!==0)&&(m=r++*Cw,this._updateRectangle(n,m,c,s,o,t.cols,i))}n.count=r}updateCursor(e){let t=this._verticesCursor,n=e.cursor;if(!n||n.style===`block`){t.count=0;return}let r,i=0;(n.style===`bar`||n.style===`outline`)&&(r=i++*Cw,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.style===`bar`?n.dpr*n.cursorWidth:n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(n.style===`underline`||n.style===`outline`)&&(r=i++*Cw,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,(n.y+1)*this._dimensions.device.cell.height-n.dpr,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat)),n.style===`outline`&&(r=i++*Cw,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat),r=i++*Cw,this._addRectangleFloat(t.attributes,r,(n.x+n.width)*this._dimensions.device.cell.width-n.dpr,n.y*this._dimensions.device.cell.height,n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),t.count=i}_updateRectangle(e,t,n,r,i,a,o){if(n&67108864)switch(n&50331648){case 16777216:case 33554432:Dw=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:Dw=(n&16777215)<<8;break;default:Dw=this._themeService.colors.foreground.rgba}else switch(r&50331648){case 16777216:case 33554432:Dw=this._themeService.colors.ansi[r&255].rgba;break;case 50331648:Dw=(r&16777215)<<8;break;default:Dw=this._themeService.colors.background.rgba}e.attributes.length<t+4&&(e.attributes=tw(e.attributes,this._terminal.rows*this._terminal.cols*Cw)),Ow=i*this._dimensions.device.cell.width,kw=o*this._dimensions.device.cell.height,Aw=(Dw>>24&255)/255,jw=(Dw>>16&255)/255,Mw=(Dw>>8&255)/255,Nw=1,this._addRectangle(e.attributes,t,Ow,kw,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,Aw,jw,Mw,Nw)}_addRectangle(e,t,n,r,i,a,o,s,c,l){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o,e[t+5]=s,e[t+6]=c,e[t+7]=l}_addRectangleFloat(e,t,n,r,i,a,o){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o[0],e[t+5]=o[1],e[t+6]=o[2],e[t+7]=o[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(e.rgba&255)/255])}},Fw=class extends CS{constructor(e,t,n,r,i,a,o,s){super(),this._container=t,this._alpha=i,this._coreBrowserService=a,this._optionsService=o,this._themeService=s,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-${n}-layer`),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(t=>{this._refreshCharAtlas(e,t),this.reset(e)})),this._register(bS(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=GS(this._canvas.getContext(`2d`,{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,n){}handleSelectionChanged(e,t,n,r=!1){}_setTransparency(e,t){if(t===this._alpha)return;let n=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,n),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=GC(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,n=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,n*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(e,t,n,r){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight))}_fillCharTrueColor(e,t,n,r){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=nC,this._clipCell(n,r,t.getWidth()),this._ctx.fillText(t.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,r*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,n){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,n){let r=t?e.options.fontWeightBold:e.options.fontWeight;return`${n?`italic`:``} ${r} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},Iw=class extends Fw{constructor(e,t,n,r,i,a,o){super(n,e,`link`,t,!0,i,a,o),this._register(r.onShowLinkUnderline(e=>this._handleShowLinkUnderline(e))),this._register(r.onHideLinkUnderline(e=>this._handleHideLinkUnderline(e)))}resize(e,t){super.resize(e,t),this._state=void 0}reset(e){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(e){if(e.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:e.fg!==void 0&&UC(e.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[e.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(let t=e.y1+1;t<e.y2;t++)this._fillBottomLineAtCells(0,t,e.cols);this._fillBottomLineAtCells(0,e.y2,e.x2)}this._state=e}_handleHideLinkUnderline(e){this._clearCurrentLink()}},Lw=typeof window==`object`?window:globalThis,Rw=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new jC,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new jC,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Rw.INSTANCE=new Rw;var zw=Rw;function Bw(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}zw.INSTANCE.onDidChangeZoomLevel,zw.INSTANCE.onDidChangeFullscreen;var Vw=typeof navigator==`object`?navigator.userAgent:``;Vw.indexOf(`Firefox`);var Hw=Vw.indexOf(`AppleWebKit`)>=0;!(Vw.indexOf(`Chrome`)>=0)&&Vw.indexOf(`Safari`),Vw.indexOf(`Electron/`),Vw.indexOf(`Android`);var Uw=!1;if(typeof Lw.matchMedia==`function`){let e=Lw.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=Lw.matchMedia(`(display-mode: fullscreen)`);Uw=e.matches,Bw(Lw,e,({matches:e})=>{Uw&&t.matches||(Uw=e)})}function Ww(){return Uw}var Gw=`en`,Kw=!1,qw=!1,Jw=!1,Yw=Gw,Xw,Zw=globalThis,Qw;typeof Zw.vscode<`u`&&typeof Zw.vscode.process<`u`?Qw=Zw.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(Qw=process);var $w=typeof Qw?.versions?.electron==`string`&&Qw?.type===`renderer`;if(typeof Qw==`object`){Qw.platform,Qw.platform,Kw=Qw.platform===`linux`,Kw&&Qw.env.SNAP&&Qw.env.SNAP_REVISION,Qw.env.CI||Qw.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Yw=Gw;let e=Qw.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,Yw=t.resolvedLanguage||Gw,t.languagePack?.translationsConfigFile}catch{}qw=!0}else typeof navigator==`object`&&!$w?(Xw=navigator.userAgent,Xw.indexOf(`Windows`),Xw.indexOf(`Macintosh`),(Xw.indexOf(`Macintosh`)>=0||Xw.indexOf(`iPad`)>=0||Xw.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,Kw=Xw.indexOf(`Linux`)>=0,Xw?.indexOf(`Mobi`),Jw=!0,Yw=globalThis._VSCODE_NLS_LANGUAGE||Gw,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var eT=qw;Jw&&typeof Zw.importScripts==`function`&&Zw.origin;var tT=Xw,nT=Yw,rT;(e=>{function t(){return nT}e.value=t;function n(){return nT.length===2?nT===`en`:nT.length>=3&&nT[0]===`e`&&nT[1]===`n`&&nT[2]===`-`}e.isDefaultVariant=n;function r(){return nT===`en`}e.isDefault=r})(rT||={});var iT=typeof Zw.postMessage==`function`&&!Zw.importScripts;(()=>{if(iT){let e=[];Zw.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),Zw.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var aT=!!(tT&&tT.indexOf(`Chrome`)>=0);tT&&tT.indexOf(`Firefox`),!aT&&tT&&tT.indexOf(`Safari`),tT&&tT.indexOf(`Edg/`),tT&&tT.indexOf(`Android`);var oT=typeof navigator==`object`?navigator:{};eT||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||oT&&oT.clipboard&&oT.clipboard.writeText,eT||oT&&oT.clipboard&&oT.clipboard.readText,eT||Ww()||oT.keyboard,`ontouchstart`in Lw||oT.maxTouchPoints,Lw.PointerEvent&&(`ontouchstart`in Lw||navigator.maxTouchPoints);var sT=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},cT=new sT,lT=new sT,uT=new sT;Array(230);var dT;(e=>{function t(e){return cT.keyCodeToStr(e)}e.toString=t;function n(e){return cT.strToKeyCode(e)}e.fromString=n;function r(e){return lT.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return uT.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return lT.strToKeyCode(e)||uT.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return cT.keyCodeToStr(e)}e.toElectronAccelerator=o})(dT||={});var fT=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),pT;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof mT?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:yC.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:fT})})(pT||={});var mT=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?fT:(this._emitter||=new jC,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var hT;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(hT||={});var gT=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new jC,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.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 yC.toPromise(this._onStateChanged.event)}while(1)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.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())}};gT.EMPTY=gT.fromArray([]);function _T(e){return vT(e,0)}function vT(e,t){switch(typeof e){case`object`:return e===null?yT(349,t):Array.isArray(e)?ST(e,t):CT(e,t);case`string`:return xT(e,t);case`boolean`:return bT(e,t);case`number`:return yT(e,t);case`undefined`:return yT(937,t);default:return yT(617,t)}}function yT(e,t){return(t<<5)-t+e|0}function bT(e,t){return yT(e?433:863,t)}function xT(e,t){t=yT(149417,t);for(let n=0,r=e.length;n<r;n++)t=yT(e.charCodeAt(n),t);return t}function ST(e,t){return t=yT(104579,t),e.reduce((e,t)=>vT(t,e),t)}function CT(e,t){return t=yT(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=xT(n,t),vT(e[n],t)),t)}var{registerWindow:xne,getWindow:wT,getDocument:Sne,getWindows:Cne,getWindowsCount:wne,getWindowId:Tne,getWindowById:Ene,hasWindow:Dne,onDidRegisterWindow:One,onWillUnregisterWindow:kne,onDidUnregisterWindow:Ane}=function(){let e=new Map,t={window:Lw,disposables:new SS};e.set(Lw.vscodeWindowId,t);let n=new jC,r=new jC,i=new jC;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return CS.None;let a=new SS,o={window:t,disposables:a.add(new SS)};return e.set(t.vscodeWindowId,o),a.add(bS(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(ET(t,OT.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:Lw},getDocument(e){return wT(e).document}}}(),TT=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!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,null)}};function ET(e,t,n,r){return new TT(e,t,n,r)}var DT=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};DT.None=new DT(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=_T(n),a=r.get(i);if(a)a.users+=1;else{let o=new jC,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(bS(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var OT={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:Hw?`webkitAnimationStart`:`animationstart`,ANIMATION_END:Hw?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:Hw?`webkitAnimationIteration`:`animationiteration`},kT=class extends CS{constructor(e,t,n,r,i,a,o,s,c){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._optionsService=o,this._themeService=s,this._cursorBlinkStateManager=new wS,this._charAtlasDisposable=this._register(new wS),this._observerDisposable=this._register(new wS),this._model=new bw,this._workCell=new ZC,this._workCell2=new ZC,this._rectangleRenderer=this._register(new wS),this._glyphRenderer=this._register(new wS),this._onChangeTextureAtlas=this._register(new jC),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new jC),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new jC),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new jC),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new jC),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`);let l={antialias:!1,depth:!1,preserveDrawingBuffer:c};if(this._gl=this._canvas.getContext(`webgl2`,l),!this._gl)throw Error(`WebGL2 not supported `+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new dne(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new Iw(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=lne(),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(ET(this._canvas,`webglcontextlost`,e=>{console.log(`webglcontextlost event received`),e.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn(`webgl context not restored; firing onContextLoss`),this._onContextLoss.fire(e)},3e3)})),this._register(ET(this._canvas,`webglcontextrestored`,e=>{console.warn(`webglcontextrestored event received`),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,KC(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=YC(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=YC(this._canvas,e,(e,t)=>this._setCanvasDevicePixelDimensions(e,t))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(bS(()=>{for(let e of this._renderLayers)e.dispose();this._canvas.parentElement?.removeChild(this._canvas),KC(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(e,t){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let e of this._renderLayers)e.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 e of this._renderLayers)e.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let e of this._renderLayers)e.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleSelectionChanged(e,t,n){for(let r of this._renderLayers)r.handleSelectionChanged(this._terminal,e,t,n);this._model.selection.update(this._core,e,t,n),this._requestRedrawViewport()}handleCursorMove(){for(let e of this._renderLayers)e.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new Pw(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new fw(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 e=GC(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!==e&&(this._onChangeTextureAtlas.fire(e.pages[0].canvas),this._charAtlasDisposable.value=yS(yC.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),yC.forward(e.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=e,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(e){this._model.clear(),e&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){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 n of this._renderLayers)n.handleGridChanged(this._terminal,e,t);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t),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 JC(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let n=this._core,r=this._workCell,i,a,o,s,c,l,u=0,d=!0,f,p,m,h,g,_,v,y,b;e=jT(e,n.rows-1,0),t=jT(t,n.rows-1,0);let x=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??`block`,ee=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,te=ee-n.buffer.ydisp,ne=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),re=-1,ie=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let S=!1;for(a=e;a<=t;a++)for(o=a+n.buffer.ydisp,s=n.buffer.lines.get(o),this._model.lineLengths[a]=0,m=ee===o,u=0,c=this._characterJoinerService.getJoinedCharacters(o),y=0;y<n.cols;y++){if(i=this._cellColorResolver.result.bg,s.loadCell(y,r),y===0&&(i=this._cellColorResolver.result.bg),l=!1,d=y>=u,f=y,c.length>0&&y===c[0][0]&&d){p=c.shift();let e=this._model.selection.isCellSelected(this._terminal,p[0],o);for(v=p[0]+1;v<p[1];v++)d&&=e===this._model.selection.isCellSelected(this._terminal,v,o);d&&=!m||ne<p[0]||ne>=p[1],d?(l=!0,r=new AT(r,s.translateToString(!0,p[0],p[1]),p[1]-p[0]),f=p[1]-1):u=p[1]}if(h=r.getChars(),g=r.getCode(),v=(a*n.cols+y)*hw,this._cellColorResolver.resolve(r,y,o,this.dimensions.device.cell.width),ie&&o===ee&&(y===ne&&(this._model.cursor={x:ne,y:te,width:r.getWidth(),style:this._coreBrowserService.isFocused?x:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},re=ne+r.getWidth()-1),y>=ne&&y<=re&&(this._coreBrowserService.isFocused&&x===`block`||this._coreBrowserService.isFocused===!1&&n.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)),g!==0&&(this._model.lineLengths[a]=y+1),(this._model.cells[v]!==g||this._model.cells[v+gw]!==this._cellColorResolver.result.bg||this._model.cells[v+_w]!==this._cellColorResolver.result.fg||this._model.cells[v+vw]!==this._cellColorResolver.result.ext)&&(S=!0,h.length>1&&(g|=yw),this._model.cells[v]=g,this._model.cells[v+gw]=this._cellColorResolver.result.bg,this._model.cells[v+_w]=this._cellColorResolver.result.fg,this._model.cells[v+vw]=this._cellColorResolver.result.ext,_=r.getWidth(),this._glyphRenderer.value.updateCell(y,a,g,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,h,_,i),l)){for(r=this._workCell,y++;y<=f;y++)b=(a*n.cols+y)*hw,this._glyphRenderer.value.updateCell(y,a,0,0,0,0,MS,0,0),this._model.cells[b]=0,this._model.cells[b+gw]=this._cellColorResolver.result.bg,this._model.cells[b+_w]=this._cellColorResolver.result.fg,this._model.cells[b+vw]=this._cellColorResolver.result.ext;y--}}S&&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(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},AT=class extends mC{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function jT(e,t,n=0){return Math.max(Math.min(e,t),n)}var MT=`di$target`,NT=`di$dependencies`,PT=new Map;function FT(e){if(PT.has(e))return PT.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);IT(t,e,r)};return t._id=e,PT.set(e,t),t}function IT(e,t,n){t[MT]===t?t[NT].push({id:e,index:n}):(t[NT]=[{id:e,index:n}],t[MT]=t)}FT(`BufferService`),FT(`CoreMouseService`),FT(`CoreService`),FT(`CharsetService`),FT(`InstantiationService`),FT(`LogService`);var LT=FT(`OptionsService`);FT(`OscLinkService`),FT(`UnicodeService`),FT(`DecorationService`);var RT={trace:0,debug:1,info:2,warn:3,error:4,off:5},zT=`xterm.js: `,BT=class extends CS{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),VT=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=RT[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:zT)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};BT=nS([rS(0,LT)],BT);var VT,HT=class extends CS{constructor(e){if(AS&&jS()<16&&!document.createElement(`canvas`).getContext(`webgl2`,{antialias:!1,depth:!1,preserveDrawingBuffer:!0}))throw Error(`Webgl2 is only supported on Safari 16 and above`);super(),this._preserveDrawingBuffer=e,this._onChangeTextureAtlas=this._register(new jC),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new jC),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new jC),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new jC),this.onContextLoss=this._onContextLoss.event}activate(e){let t=e._core;if(!e.element){this._register(t.onWillOpen(()=>this.activate(e)));return}this._terminal=e;let n=t.coreService,r=t.optionsService,i=t,a=i._renderService,o=i._characterJoinerService,s=i._charSizeService,c=i._coreBrowserService,l=i._decorationService;i._logService;let u=i._themeService;this._renderer=this._register(new kT(e,o,s,c,n,l,r,u,this._preserveDrawingBuffer)),this._register(yC.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(yC.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(yC.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(yC.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(bS(()=>{if(this._terminal._core._store._isDisposed)return;let t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.handleResize(e.cols,e.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}};function UT(e){return e.needsReload?!0:e.wasAttachedWithoutLayout&&e.hasLayoutNow}function WT(e,t,n=[]){let r=new Set(Array.isArray(n)?n:[n]),i=[];for(let n of e)e.length-i.length>=t&&!r.has(n)&&i.push(n);return i}var GT=window.matchMedia?.(`(pointer: coarse)`).matches?4:12,KT=new Map;function qT(e){return e.clientWidth>0&&e.clientHeight>0}function JT(e){if(KT.delete(e),e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,e.webglAddon){try{e.webglAddon.dispose()}catch{}e.webglAddon=null}}function YT(e){let t=[e],n=Vd.snapshot().borrowedCardId,r=n?U.get(n):void 0;r&&t.push(r);for(let e of WT([...KT.keys()],GT,t))JT(e),e.needsWebGLReload=!0}function XT(e){e?.term&&UT({needsReload:e.needsWebGLReload,wasAttachedWithoutLayout:e.webglAttachedWithoutLayout,hasLayoutNow:qT(e.termWrap)})&&QT(e,{isForced:!0})}function ZT(){for(let e of KT.keys()){let t=e.term;if(e.webglAddon&&t)try{t.clearTextureAtlas(),t.refresh(0,t.rows-1)}catch{JT(e),e.needsWebGLReload=!0}}}function QT(e,t={}){try{if(e.webglAddon&&!e.needsWebGLReload&&!t.isForced){KT.delete(e),KT.set(e,!0);return}e.webglAddon&&(e.webglAddon.dispose(),e.webglAddon=null,KT.delete(e)),YT(e);let n=new HT;n.onContextLoss(()=>{n.dispose(),e.webglAddon=null,KT.delete(e),e.needsWebGLReload=!0});let r=e.term;if(!r)throw Error(`webgl: the terminal was disposed before the addon loaded`);r.loadAddon(n),e.webglAddon=n,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!qT(e.termWrap),KT.set(e,!0),requestAnimationFrame(()=>{e.webglAddon===n&&e.term&&e.term.refresh(0,e.term.rows-1)})}catch{e.webglAddon=null,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,KT.delete(e)}}var $T=1024,eE=250,tE=`(max-width: 768px)`,nE=12,rE=14,iE=5e4,aE=!1;function oE(e){aE=e}var sE=!1;window.addEventListener(`blur`,()=>{sE=!0}),window.addEventListener(`focus`,()=>{sE=!1});function cE(e){let t=document.activeElement;return Yb({isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),hasFocusInsideCard:t instanceof Node&&e.contains(t),hasWindowBlurredSinceFocus:sE,isPhoneLayout:Jd()})}function lE(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new TextDecoder().decode(n)}function uE(e,t){let n=(t instanceof Error?t.message:``)||String(t);console.error(`[clipboard:${e}]`,t),zx(`Clipboard ${e} failed: ${n}`)}function dE(e,t){return U.get(e)===t&&!t.dataWs}function fE(e,t,n,r){ib.unregister(e),t.dataWs=null,t._resetGridClaim?.(),setTimeout(()=>{dE(e,t)&&f().catch(()=>{}).then(()=>{dE(e,t)&&pE(e,t,n)})},r)}function pE(e,n,r){let i=c(location,m(`/terminals/${encodeURIComponent(e)}`)),a=new WebSocket(i);a.binaryType=`arraybuffer`,n.dataWs=a;let o=!1,s={hasSeenSize:!1,lastSeq:0};ib.register(e,(e,t)=>r.write(e,t)),a.addEventListener(`message`,t=>{if(n.dataWs!==a)return;let i=ex(t.data,s);if(i.kind===`bytes`){mf(n),ib.enqueue(e,i.data);return}if(i.kind===`attach-size`){s.hasSeenSize=!0,s.lastSeq=i.seq,r.reset(),n.ptySize={cols:i.cols,rows:i.rows},n._syncGrid?.();return}if(i.kind!==`size`)return;s.lastSeq=i.seq;let o={cols:i.cols,rows:i.rows};ib.enqueueAction(e,()=>{n.ptySize=o,n._syncGrid?.()})}),a.addEventListener(`close`,()=>{if(n.dataWs!==a)return;o||p();let i=t(n._dataWsRetryAttempt||0);n._dataWsRetryAttempt=(n._dataWsRetryAttempt||0)+1,fE(e,n,r,i)}),a.addEventListener(`open`,()=>{o=!0,n._dataWsRetryAttempt=0,n._retryOwedGridClaim?.(),n._inputQueue?.length&&setTimeout(()=>{n.dataWs===a&&hE(n)},50)})}var mE=!1;function hE(e){let t=e._inputQueue,n=e.dataWs;if(!mE&&t?.length&&n?.readyState===WebSocket.OPEN){for(let e of t)n.send(JSON.stringify({type:`input`,data:e}));t.length=0}}function gE(){mE=!0}function _E(){mE=!1;for(let e of U.values())hE(e)}function vE(e){let t=Qd(e);if(typeof e!=`string`||!t?.term)return;let n=t.dataWs;t._dataWsRetryAttempt=0,fE(e,t,t.term,0),n?.close()}function yE(e,t,n){return!e||t==null||t===``?!1:(n?.fromSoftKeyboard||e._resetSoftKeyboardBuffer?.(),!mE&&!e._inputQueue?.length&&e.dataWs?.readyState===WebSocket.OPEN?(e.dataWs.send(JSON.stringify({type:`input`,data:t})),!0):e._inputQueue&&e._inputQueue.length<$T?(e._inputQueue.push(t),!0):!1)}function bE(e,t){let n=window.matchMedia?.(tE).matches?nE:rE,r=new Py({cursorBlink:aE,fontSize:n,fontFamily:`'Cascadia Code', 'Fira Code', 'Consolas', 'Menlo', monospace`,theme:Rb(),scrollback:iE,allowProposedApi:!0,linkHandler:kx()}),i=new Df;r.loadAddon(i),r.open(e),jx(r),t.term=r,t.fitAddon=i,JT(t);let a=null,o=null,s=!1,c=null,l=null;function u(){o!==null&&(clearTimeout(o),o=null)}function d(){if(!s)return null;let e=t.fitAddon;if(!e)return null;let n=e.proposeDimensions();return n?{cols:n.cols,rows:n.rows}:null}function f(e){if(!cE(t.card)||t.dataWs?.readyState!==WebSocket.OPEN)return!1;t.dataWs.send(JSON.stringify({type:`claim`,cols:e.cols,rows:e.rows})),c=e,l=null;let n=Jb({authoritative:t.ptySize??null,isActiveViewer:s,lastClaim:c});return t.card.dataset.grid=n?`following`:`exact`,!0}function p(e){u(),l=e,o=setTimeout(()=>{o=null,f(e)},eE)}function m(){l&&o===null&&f(l)}function h({isActivationEdge:e=!1}={}){let n=t.term;if(!n)return;let r=Zb({authoritative:t.ptySize??null,applied:{cols:n.cols,rows:n.rows},proposal:d(),isActiveViewer:s,isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:c});if(r.resizeTo&&n.resize(r.resizeTo.cols,r.resizeTo.rows),t.card.dataset.grid=r.isFollowing?`following`:`exact`,r.keepsPendingSettle||(u(),l=null),r.sendUnview){c=null,t.dataWs?.send(JSON.stringify({type:`unview`}));return}r.owedClaim&&(e&&f(r.owedClaim)||p(r.owedClaim))}function g(){let e=Xb({authoritative:t.ptySize??null,isActiveViewer:s,isDocumentEngaged:cE(t.card),isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:c});e!==`none`&&(u(),e===`rebid`&&(c=null),h({isActivationEdge:!0}))}let _=new ResizeObserver(()=>{a===null&&(a=requestAnimationFrame(()=>{a=null,h()}))});_.observe(e),t.resizeObserver=_,t._syncGrid=h,t._resetGridClaim=()=>{u(),c=null},t._retryOwedGridClaim=m,t._syncGridOnEngagementEdge=g,t._setActiveViewer=e=>{s!==e&&(s=e,u(),l=null,e&&XT(t),h({isActivationEdge:!0}))},t.card.addEventListener(`focusin`,()=>{sE=!1,g()},{signal:t.abortController.signal}),QT(t);let v=null;r.onScroll(()=>{v===null&&(v=requestAnimationFrame(()=>{v=null,t.term&&t.term.refresh(0,t.term.rows-1)}))}),r.parser.registerOscHandler(52,e=>{let t=e.indexOf(`;`);if(t<0)return!0;let n=e.slice(t+1);if(n===``||n===`?`)return!0;let r;try{r=lE(n)}catch(e){return uE(`osc52 decode`,e),!0}if(!(document.hasFocus()&&navigator.userActivation?.isActive!==!1))return!0;let i=Ad(r);return i&&i.catch(e=>{uE(`osc52 write`,e)}),!0}),r.attachCustomKeyEventHandler(e=>{if(e.type!==`keydown`)return!0;if(document.body.dataset.activeView===`focus`&&Ky(e,Zy,$y()))return!1;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`c`&&r.hasSelection()){let e=r.getSelection();r.clearSelection();let t=Ad(e);return t&&t.catch(e=>{uE(`copy`,e)}),!1}return n&&e.key===`v`?!1:n&&e.key===`Backspace`?(yE(t,`\x1B`),!1):!0}),xE(e,r,t),$x(e,r)}function xE(e,t,n){let r=t.textarea;if(!r)return;let i=``,a=()=>{i=r.value},o=()=>{i=``,Jd()&&r.value!==``&&(r.value=``)};n._resetSoftKeyboardBuffer=o;let s=()=>{let e=ox(i,r.value);return i=r.value,e!==``&&(yE(n,e,{fromSoftKeyboard:!0}),t.scrollToBottom(),!0)},c=(t,n)=>{e.addEventListener(t,e=>{if(!Jd()){a();return}n(e)},!0)};c(`keydown`,e=>{if(ax(e)){e.stopPropagation();return}s(),queueMicrotask(o)}),c(`compositionstart`,e=>{e.stopPropagation()}),c(`compositionupdate`,e=>{e.stopPropagation()}),c(`compositionend`,e=>{e.stopPropagation(),setTimeout(s,0)}),c(`input`,e=>{if(!ix(e.inputType)){queueMicrotask(o);return}if(e.stopPropagation(),s())return;let r=nx(e.inputType);r!==``&&(yE(n,r,{fromSoftKeyboard:!0}),t.scrollToBottom())})}var SE=new Set;function CE(e){return SE.add(e),()=>SE.delete(e)}function wE(e,t){e._inputQueue=[];let n=e.term;n&&(n.onData(n=>{if(!yE(e,n))return;let r=Mx(n);for(let e of SE)e(t,r)}),pE(t,e,n))}function TE(e,t){e.term||(bE(e.termWrap,e),wE(e,t))}function EE(e){e?._syncGridOnEngagementEdge?.()}function DE(e,t){if(!e)return;TE(e,t),XT(e);let n=e.term;n&&(n.refresh(0,n.rows-1),EE(e))}function OE(e,t,n){e&&(n&&TE(e,t),e._setActiveViewer?.(n))}function kE(e){let t=/^@@+ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return!Number.isFinite(n)||!Number.isFinite(r)?null:{oldStart:n,newStart:r}}function AE(e){let t=[];if(!e)return t;let n=String(e).split(/\r?\n/),r=null,i=null,a=null,o=null,s=()=>{if(a===null)return null;let e=a;return a=e+1,e},c=()=>{if(o===null)return null;let e=o;return o=e+1,e},l=e=>{let n={path:``,oldPath:null,status:`modified`,added:0,removed:0,binary:!1,hunks:[]};t.push(n),i=null;let r=/^diff --git a\/(.+?) b\/(.+)$/.exec(e);return r&&(n.oldPath=r[1]??null,n.path=r[2]??``),n};for(let e of n){if(e.startsWith(`diff --git `)){r=l(e);continue}if(!r){if(!e.startsWith(`--- `)&&!e.startsWith(`@@`))continue;r=l(`diff --git a/ b/`)}if(r){if(e.startsWith(`new file mode`)){r.status=`added`;continue}if(e.startsWith(`deleted file mode`)){r.status=`deleted`;continue}if(e.startsWith(`rename from `)){r.oldPath=e.slice(12),r.status=`renamed`;continue}if(e.startsWith(`rename to `)){r.path=e.slice(10),r.status=`renamed`;continue}if(e.startsWith(`Binary files`)){r.binary=!0;continue}if(!(e.startsWith(`index `)||e.startsWith(`similarity index`)||e.startsWith(`dissimilarity index`)||e.startsWith(`old mode`)||e.startsWith(`new mode`))){if(e.startsWith(`--- `)){if(e===`--- /dev/null`){r.status=`added`;continue}if(!r.path){let t=e.slice(4).replace(/^a\//,``);t&&t!==`/dev/null`&&(r.oldPath=r.oldPath||t)}continue}if(e.startsWith(`+++ `)){if(e===`+++ /dev/null`){r.status=`deleted`;continue}if(!r.path){let t=e.slice(4).replace(/^b\//,``);t&&t!==`/dev/null`&&(r.path=t)}continue}if(e.startsWith(`@@`)){i={header:e,lines:[]},r.hunks.push(i);let t=kE(e);a=t?t.oldStart:null,o=t?t.newStart:null;continue}if(i){if(e===``)continue;let t=e[0];if(t===`+`){i.lines.push({type:`add`,text:e.slice(1),oldLineNumber:null,newLineNumber:c()}),r.added++;continue}if(t===`-`){i.lines.push({type:`del`,text:e.slice(1),oldLineNumber:s(),newLineNumber:null}),r.removed++;continue}if(t===`\\`){i.lines.push({type:`meta`,text:e.slice(1).trim(),oldLineNumber:null,newLineNumber:null});continue}i.lines.push({type:`context`,text:t===` `?e.slice(1):e,oldLineNumber:s(),newLineNumber:c()})}}}}for(let e of t)e.path||=e.oldPath||`(unknown)`;return t}function jE(e,t,n,r){return`${e}:${r}:${n}:${t}`}function ME(e,t,n){if(!e)return[];let r=new Set;if(e.committed!==t.committed&&r.add(`committed`),e.uncommitted!==t.uncommitted&&r.add(`uncommitted`),r.size===0)return[];let i=[];for(let e of n)r.has(e.slice(0,e.indexOf(`:`)))&&i.push(e);return i}function NE(e,t){return t.type===`del`?t.oldLineNumber===null?null:{path:e.path,line:t.oldLineNumber,side:`old`}:t.newLineNumber===null?null:{path:e.path,line:t.newLineNumber,side:`new`}}function PE(e,t){return t===`merged`||t===`none`||e===`parked`&&t===`pending-review`}function FE(e){let t=0,n=0;for(let r of e||[])t+=r.added||0,n+=r.removed||0;return{files:(e||[]).length,added:t,removed:n}}function IE(e){let t=(Array.isArray(e)?e:[]).filter(e=>typeof e==`string`&&e!==``);return[...new Set(t)].sort().join(`|`)}function LE(e,t){let n=typeof e==`string`?e:``,r=typeof t==`string`?t:``;return n===``?{shown:!1,acknowledged:``}:{shown:n!==r,acknowledged:r}}function RE({getAck:e,setAck:t,signature:n,isLooking:r}){let i=e(),a=e=>{e!==i&&(i=e,t(e))};return{refresh(){let e=n(),t=LE(e,r()?e:i);return a(t.acknowledged),t.shown},acknowledge(){a(n())}}}function zE(e,t){return typeof e==`string`&&e.trim()?e.trim():t}function BE(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function VE(e,{label:t,tab:n}){if(!e)return`Waiting for ${t} status from the server.`;let r=typeof e.reason==`string`?e.reason.trim():``;return e.configured===!1&&r?`${t} is misconfigured: ${r}. Open Settings and its ${n} tab.`:e.configured===!1?`${t} is off. Open Settings and its ${n} tab to switch it on.`:`${t} is on. Waiting for the first poll.`}var HE=`machine-updates`,UE=`update-actions`,WE={spiking:0,regressed:1,worsened:2,new:3,quiet:4},GE={spiking:`crit`,regressed:`crit`,worsened:`warn`,new:`warn`,quiet:`dim`},KE=99,qE={ROOT_CAUSE:`root cause`,NEEDS_HUMAN:`needs you`,TRANSIENT:`transient`,FIXED:`fixed`,ERROR:`error`};function JE(e){return Array.isArray(e)?e.flatMap(e=>{let t=e,n=zE(t?.tool,``);return n?[{at:BE(t?.at,0),tool:n,detail:zE(t?.detail,``)}]:[]}):[]}function YE(e){return e.detail?`${e.tool} ${e.detail}`:e.tool}function XE(e){let t=JE(e?.trail).at(-1);return t?YE(t):``}function ZE(e){let t=zE(e?.summaryLine,``);return e?.inFlight===!0&&XE(e)||t}function QE(e){return{inFlight:e?.inFlight===!0,startedAt:BE(e?.startedAt,null),steps:JE(e?.trail),verdict:zE(e?.verdict,``),summaryLine:zE(e?.summaryLine,``)}}function $E(e,t,n){let r=String(t??``),i=String(n??``);if(!r||!i)return null;for(let t of Array.isArray(e?.projects)?e.projects:[])if(String(t?.projectId??``)===r){for(let e of Array.isArray(t.issues)?t.issues:[])if(String(e?.issueId??``)===i)return e}return null}function eD(e,t){let n=$E(e,t?.projectId,t?.issueId);return n?(n.inFlight=!0,n.startedAt=BE(t?.startedAt,null),n.trail=JE(t?.trail),!0):!1}function tD(e){return{inFlight:!1,startedAt:BE(e?.startedAt,null),steps:JE(e?.trail),verdict:zE(e?.verdict,``),summaryLine:zE(e?.summaryLine,``)}}function nD(e,t){return!e||!t?!1:String(t.projectId??``)===e.projectId&&String(t.issueId??``)===e.issueId}function rD(e,t){let n=$E(e,t?.projectId,t?.issueId);if(!n)return!1;let r=tD(t);return n.inFlight=!1,n.startedAt=r.startedAt,n.trail=r.steps,n.verdict=r.verdict,n.summaryLine=r.summaryLine,!0}function iD(e){return qE[typeof e==`string`?e.toUpperCase():``]||String(e??``).toLowerCase()}function aD(e){let t=Math.max(0,Math.round(e/1e3));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function oD(e,t){return e==null?``:`+${aD(t-e)}`}function sD(e){let t=e.steps.at(-1);return[e.steps.length,t?.at??0,t?.tool??``].join(`::`)}function cD(e,t){if(e.inFlight){let n=`${e.steps.length} ${e.steps.length===1?`step`:`steps`}`;return`investigating, ${e.startedAt?`started ${t}`:`starting`}, ${n}`}return e.verdict?`finished: ${iD(e.verdict)}`:`finished`}function lD(e){return VE(e,{label:`PostHog monitoring`,tab:`PostHog`})}function uD(e){return BE(e.intervalMinutes,null)!==null}function dD(e,t){return e==null||e.configured===!1?`placeholder`:t>0?`ready`:uD(e)?`placeholder`:`pending`}function fD(e){return GE[e??``]||`dim`}function pD(e){if(typeof e?.lastSeen!=`string`)return null;let t=Date.parse(e.lastSeen);return!Number.isFinite(t)||t<=0?null:t}function mD(e){let t=zE(e?.status,``).trim().toLowerCase();return!t||t===`active`?``:t}function hD(e){return Array.isArray(e)?e.map(e=>Number(e)).filter(e=>Number.isFinite(e)):[]}function gD(e){return Array.isArray(e)?e.map(e=>typeof e==`number`?e:Number(e?.occurrences)).filter(e=>Number.isFinite(e)):[]}function _D(e,t=64,n=16){let r=hD(e);if(r.length<2)return``;let i=Math.max(...r),a=Math.min(...r),o=t/(r.length-1),s=n/2,c=i-a;return r.map((e,t)=>{let r=t*o,i=c===0?s:n-(e-a)/c*n;return`${Number(r.toFixed(2))},${Number(i.toFixed(2))}`}).join(` `)}function vD(e){if(e.length<4)return null;let t=Math.floor(e.length/2),n=e.slice(0,t).reduce((e,t)=>e+t,0);if(n===0)return null;let r=e.slice(-t).reduce((e,t)=>e+t,0),i=Math.round(Math.abs(r-n)/Math.abs(n)*100);return r>n?{direction:`up`,percent:i}:r<n?{direction:`down`,percent:i}:{direction:`flat`,percent:i}}function yD(e){return e.length===0?`0 polls, 0 to 0 occurrences`:`${e.length} polls, ${Math.min(...e)} to ${Math.max(...e)} occurrences`}function bD(e){let t=Array.isArray(e)?e:[],n=0,r=0;for(let e of t)e?.change===`spiking`&&(n+=1),e?.verdict===`NEEDS_HUMAN`&&(r+=1);return{active:t.length,spiking:n,needsHuman:r}}var xD=3e5;function SD(e){let t=Number(e);return!Number.isFinite(t)||t<=0?xD:t*2}function CD(e){let t=e.split(/[\\/]+/).filter(Boolean);return t.length===0?``:t[t.length-1]}function wD(e){let t=CD(zE(e?.name,``));if(t)return t;let n=e?.projectId;return n==null||n===``?`project`:String(n)}function TD(e){let t=zE(e,``);return t?(t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``).split(`/`)[0].split(`@`).pop()??``).replace(/:\d+$/,``):``}function ED(e){let t=new Set,n=Array.isArray(e)?e:[];for(let e of n){let n=TD(e?.host);n&&t.add(n)}return t.size>1}function DD(e,t,n={}){let r=bD(e?.issues),i=zE(e?.error,``).slice(0,200),a=Number(t),o=Number(e?.lastTickAt),s=Number.isFinite(a)&&Number.isFinite(o)&&o>0?a-o:0,c=s>SD(n.intervalMs)?s:0;return{loud:r.active>0||r.spiking>0||!!i||c>0,counts:r,error:i,staleMs:c}}function OD(e,t,n={}){let r=[],i=[],a=Array.isArray(e)?e:[];for(let e of a){let a=DD(e,t,n),o={project:e,...a};if(a.loud){r.push(o);continue}i.push(o)}return{loud:r,quiet:i}}function kD(e,t=null){return(Array.isArray(e?.investigations)?e.investigations:[]).filter(e=>typeof e==`object`&&!!e).filter(e=>typeof e.id==`string`&&e.id!==``).filter(e=>e.archived!==!0).filter(e=>!t?.has(e.id)).map(e=>({id:e.id,issueId:zE(e.issueId,``),projectId:e.projectId??null,projectLabel:zE(e.projectName,``),title:zE(e.title,`Untitled issue`),summaryLine:zE(e.summaryLine,``),url:zE(e.url,``),verdict:zE(e.verdict,`ERROR`).toUpperCase(),mode:zE(e.mode,`investigate`),prUrl:/^https:\/\/[^\s"'<>]{1,300}$/.test(zE(e.prUrl,``))?zE(e.prUrl,``):``,at:Number.isFinite(Number(e.at))?Number(e.at):0})).sort((e,t)=>t.at-e.at)}function AD(e,t){if(!t||t.size===0)return t;let n=Array.isArray(e?.investigations)?e.investigations:[],r=new Set;for(let e of n){if(typeof e!=`object`||!e)continue;let{id:t}=e;typeof t==`string`&&r.add(t)}for(let e of[...t])r.has(e)||t.delete(e);return t}function jD(e){let t=zE(e,``);return/^[0-9a-f]{7,40}$/i.test(t)?t.slice(0,7).toLowerCase():``}function MD(e,t){let n=zE(e,``);if(n)return/^\d/.test(n)?`v${n}`:n;let r=jD(t);return r?`commit ${r}`:``}function ND(e){return`Update available: ${MD(e?.current,e?.currentSha)} to ${MD(e?.latest,e?.latestSha)}`}function PD({posthog:e}={}){let t=[],n=Array.isArray(e?.projects)?e.projects:[];for(let e of n){let n=zE(e?.projectId,zE(e?.name,`project`)),r=Array.isArray(e?.issues)?e.issues:[];for(let e=0;e<r.length;e++){let i=r[e],a=zE(i?.issueId,zE(i?.title,`#${e}`));i?.change===`spiking`&&t.push(`issue:${n}/${a}:spiking`),i?.verdict===`NEEDS_HUMAN`&&t.push(`issue:${n}/${a}:needs-human`)}}return t}function FD(e={}){return IE(PD(e))}function ID(e){return WE[e??``]??KE}function LD(e){return Array.isArray(e)?e.map((e,t)=>({issue:e,index:t})).sort((e,t)=>{let n=ID(e.issue?.change)-ID(t.issue?.change);if(n!==0)return n;let r=BE(t.issue?.users,0)-BE(e.issue?.users,0);if(r!==0)return r;let i=BE(t.issue?.occurrences,0)-BE(e.issue?.occurrences,0);return i===0?e.index-t.index:i}).map(e=>e.issue):[]}var RD=5e3;function zD(e){let t=e.match(/<command-name>([^<]*)<\/command-name>/)?.[1];return t===void 0||/[\r\n]/.test(t)?null:t.trim()||null}function BD(e,t){if(!e.toolUseId)return zD(e.text)??`context`;let n=t.get(e.toolUseId);return n?Lc(n.name,n.input)||n.name:`expansion`}function VD(e){return e.kind!==`expansion`||e.toolUseId?!1:zD(e.text)!==null}function HD(e){return e.kind===`prompt`||e.kind===`session`||VD(e)}function UD(e){return new TextEncoder().encode(e).byteLength}function WD(e){return e.kind===`prompt`||e.kind===`expansion`||e.kind===`thinking`||e.kind===`assistant`||e.kind===`notice`?e.text:e.kind===`tool_result`?e.content:e.kind===`raw`?e.line:e.kind===`tool_call`?JSON.stringify(e.input,null,2)??String(e.input??``):[`${e.vendor} ${e.vendorSessionId}`,e.transcriptPath,e.reason??``].filter(Boolean).join(`
|
|
134
|
-
`)}var GD={prompt:`PROMPT`,expansion:`EXPANSION`,thinking:`THINKING`,assistant:`ASSISTANT`,tool_call:`TOOL`,tool_result:`RESULT`,session:`SESSION`,notice:`NOTICE`,raw:`RAW`},KD=[{kind:`thinking`,label:`Thinking`},{kind:`tool_result`,label:`Tool result`},{kind:`raw`,label:`Raw`}];function qD(e,t){if(e.kind===`prompt`)return{prefix:`Prompt: `,text:Fc(e.text)};if(e.kind===`thinking`)return{prefix:`Thinking: `,text:Fc(e.text)};if(e.kind===`assistant`)return{prefix:`Assistant: `,text:Fc(e.text)};if(e.kind===`notice`)return{prefix:`Notice: `,text:Fc(e.text)};if(e.kind===`raw`)return{prefix:`Raw: `,text:Fc(e.line)};if(e.kind===`session`)return{prefix:`Session: `,text:`${e.vendor} ${e.vendorSessionId}`};if(e.kind===`expansion`)return{prefix:`Expansion: `,text:BD(e,t)};if(e.kind===`tool_call`){let t=Lc(e.name,e.input);return t?{prefix:`${e.name}: `,text:t}:{prefix:``,text:e.name}}return{prefix:`${t.get(e.toolUseId)?.name??`Tool`} result: `,text:`${UD(e.content)} bytes`}}function JD(e){if(!e.agentType)return``;let t=e.agentId?` ${e.agentId.slice(-6)}`:``;return`[${e.agentType}${t}] `}function YD(e,t){let n=qD(e,t),r=JD(e),i=e.kind===`tool_call`||e.kind===`tool_result`?`${n.prefix}${n.text}`:n.text,a=[],o=e.kind===`notice`?`muted`:`default`;if(e.kind===`tool_result`&&e.isError&&(o=`error`,a.push(`error`)),e.truncated===!0&&(o!==`error`&&(o=`muted`),a.push(`truncated`)),e.kind===`tool_result`){let n=t.get(e.toolUseId),r=n?e.ts-n.ts:NaN;Number.isFinite(r)&&r>=0&&a.push(r>1e3?`${(r/1e3).toFixed(1)}s`:`${Math.round(r)}ms`)}return{kind:e.kind,tag:GD[e.kind],text:`${r}${i}`,tone:o,badges:a}}function XD(e,t){return{record:e,...YD(e,t)}}function ZD(e){return e.kind!==`tool_result`&&e.kind!==`expansion`?null:e.toolUseId||null}function QD(e,t){let n=ZD(e);return!n||t.has(n)?null:n}function $D(e,t,n=1){e.set(t,(e.get(t)??0)+n)}function eO(e,t){let n=(e.get(t)??0)-1;if(n>0){e.set(t,n);return}e.delete(t)}function tO(e,t){if(t.size!==0)for(let n of e.turns)for(let r=0;r<n.rows.length;r+=1){let i=n.rows[r],a=ZD(i.record);a&&t.has(a)&&(n.rows[r]=XD(i.record,e.toolCallByUseId))}}function nO(){return{turns:[],toolCallByUseId:new Map,unresolvedToolUseCounts:new Map}}function rO(e){if(e.startedAt===null)return 0;let t=e.head?.record.ts??e.startedAt;for(let n of e.rows)t=Math.max(t,n.record.ts);return Math.max(0,t-e.startedAt)}function iO(e){let{rowCount:t,toolCallCount:n,errorCount:r,resultBytes:i}=e.metrics;return`${`${t} ${t===1?`row`:`rows`}`}, ${`${n} ${n===1?`tool`:`tools`}`}, ${`${r} ${r===1?`error`:`errors`}`}, ${i<1024?`${i} B`:`${(i/1024).toFixed(1)} KB`}, ${aD(rO(e))}`}function aO(){return{rowCount:0,toolCallCount:0,errorCount:0,resultBytes:0}}function oO(e,t,n){e.metrics.rowCount+=n,t.record.kind===`tool_call`&&(e.metrics.toolCallCount+=n),t.record.kind===`tool_result`&&(e.metrics.resultBytes+=UD(t.record.content)*n,t.record.isError&&(e.metrics.errorCount+=n))}function sO(e,t){for(let n of t)n.kind===`tool_call`&&e.toolCallByUseId.set(n.toolUseId,n);let n=[],r=e.turns[e.turns.length-1]??null;for(let i of t){let t=QD(i,e.toolCallByUseId);t&&$D(e.unresolvedToolUseCounts,t);let a=XD(i,e.toolCallByUseId);if(HD(i)){r={head:a,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:aO()},oO(r,a,1),e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:a,rows:[]});continue}r||(r={head:null,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:aO()},e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:null,rows:[]})),r.rows.push(a),oO(r,a,1);let o=e.turns.length-1,s=n[n.length-1];if(s&&s.turnIndex===o){s.rows.push(a);continue}n.push({turnIndex:o,isNewTurn:!1,head:null,rows:[a]})}return n}function cO(e,t){let n=nO();sO(n,t);let r=new Set;for(let[t,i]of n.toolCallByUseId)e.toolCallByUseId.has(t)||(e.toolCallByUseId.set(t,i),r.add(t));let i=new Set;for(let t of r)e.unresolvedToolUseCounts.delete(t)&&i.add(t);for(let[t,r]of n.unresolvedToolUseCounts)e.toolCallByUseId.has(t)||$D(e.unresolvedToolUseCounts,t,r);let a=n.turns[n.turns.length-1],o=e.turns[0],s=!!a&&!!o&&!o.head,c=s?a.head:null,l=s?a.rows:[];if(s){n.turns.pop();let e=a.startedAt,t=o.startedAt;e!==null&&(t===null||e<t)&&(o.startedAt=a.startedAt),o.head=c,o.rows=[...l,...o.rows],o.metrics={rowCount:a.metrics.rowCount+o.metrics.rowCount,toolCallCount:a.metrics.toolCallCount+o.metrics.toolCallCount,errorCount:a.metrics.errorCount+o.metrics.errorCount,resultBytes:a.metrics.resultBytes+o.metrics.resultBytes}}return e.turns=[...n.turns,...e.turns],tO(e,i),{newTurns:n.turns,mergedHead:c,mergedRows:l,needsRerender:i.size>0}}function lO(e){return e.rows.length+ +!!e.head}function uO(e){let t=0;for(let n of e.turns)t+=lO(n);return t}function dO(e,t){for(let n of t){if(n.record.kind===`tool_call`){e.toolCallByUseId.delete(n.record.toolUseId);continue}let t=ZD(n.record);t&&eO(e.unresolvedToolUseCounts,t)}}function fO(e,t){dO(e,t.head?[t.head,...t.rows]:t.rows)}function pO(e,t){let n=e.turns[0];if(!n)return 0;let r=Math.min(t,n.rows.length);if(r<=0)return 0;let i=n.rows.slice(0,r);dO(e,i);for(let e of i)oO(n,e,-1);return n.rows=n.rows.slice(r),n.hasTrimmedRows=!0,r}function mO(e,t=RD){let n=uO(e),r=0;for(;n>t&&r<e.turns.length-1;){let t=e.turns[r];if(!t)break;n-=lO(t),fO(e,t),r+=1}return r>0&&(e.turns=e.turns.slice(r)),n<=t?{droppedTurnCount:r,droppedRowCount:0}:{droppedTurnCount:r,droppedRowCount:pO(e,n-t)}}function hO(e){let t=[],n=new Set;for(let r of e)r.id&&r.name&&!n.has(r.id)&&(n.add(r.id),t.push({id:r.id,label:r.name}));return t}function gO(e,t,n,r=!0){return t&&e.some(e=>e.id===t)?t:n&&e.some(e=>e.id===n)?n:r?e[0]?.id??null:null}function _O(e){return!e.selectedSessionId||!e.isPanelVisible||e.hasPendingRequest?null:e.hasLoadedOnce?{id:e.selectedSessionId,direction:`forward`,after:e.nextOffset}:{id:e.selectedSessionId,direction:`tail`,after:0,endingAt:`tail`}}function vO(e,t=RD){return!e.selectedSessionId||!e.hasLoadedOnce||e.hasDroppedEarliestRows||e.residentRowCount>=t?!1:e.firstOffset>0}function yO(e,t=RD){return!vO(e,t)||e.hasPendingRequest||!e.selectedSessionId?null:{id:e.selectedSessionId,direction:`earlier`,after:0,endingAt:e.firstOffset}}function bO(e){let{pendingRequest:t,resident:n,reply:r}=e;return!t||t.id!==r.id?`ignore`:!n||n.sessionId!==r.id?`stale`:r.reset||r.next<r.start?`reset`:t.direction===`tail`?n.hasLoadedOnce?`stale`:`seed`:t.direction===`earlier`?n.firstOffset===t.endingAt?r.next===t.endingAt?`prepend`:`reset`:`stale`:n.nextOffset===t.after?r.start===t.after?`append`:`reset`:`stale`}function xO(e){return e.hasSelectionChanged||e.isRenderedTraceStale||!e.hasRenderedOnce}function SO(e,t,n){return e!==0||t?null:n?.startedAt??null}function CO(e,t){return wO(e,t)?e.filter(e=>e!==t):[...e,t]}function wO(e,t){return e.includes(t)}function TO(e){return e?`No trace has been recorded for ${e.label}.`:`No sessions are available.`}var EO=.32,DO=.6,OO=.88,kO=.98,AO=1.12,jO=2*Math.PI,MO={now:EO,next:DO,later:OO};function NO(e,t=0){let n=2166136261^t;for(let t=0;t<e.length;t+=1)n=Math.imul(n^e.charCodeAt(t),16777619);return(n>>>0)/4294967296}function PO(e,t){return t===`working`||t===`ready`?kO+NO(e,1)*.14000000000000012:MO[t]}function FO(e){let t=[];for(let{id:n,tier:r}of e)r!==`resting`&&t.push({id:n,tier:r,angle:NO(n)*jO,radius:PO(n,r)});if(t.length<2)return t;let n=[...t].sort((e,t)=>e.angle-t.angle),r=jO/n.length,i=n.reduce((e,t,i)=>Math.max(e,t.angle-jO+(n.length-i)*r),n[0].angle);return n.forEach((e,t)=>{e.angle=(i+t*r)%jO}),t}function IO(e){return e>640}function LO(e){return e.reviews.filter(e=>e.state===`open`&&e.openRevision!==null).sort((e,t)=>(t.openRevision?.since??0)-(e.openRevision?.since??0))[0]??null}function RO(e){return[...e].sort((e,t)=>(e.isDormant===t.isDormant?0:e.isDormant?1:-1)||String(e.name).localeCompare(String(t.name),void 0,{numeric:!0,sensitivity:`base`}))}function zO(e,t){return e.length?e[((t==null?-1:e.indexOf(t))+1)%e.length]:null}function BO(e,t,n){if(!e.length)return null;let r=n<0?-1:1,i=t==null?-1:e.indexOf(t);return e[((i===-1?r===1?-1:0:i)+r+e.length)%e.length]}function VO({state:e,unseen:t}={}){return e===`WAITING`||e===`COMPLETE`&&t===!0}function HO(e){let t=0;for(let n of e||[])VO(n||{})&&t++;return t}function UO(e){return e<=0?`ALL CLEAR`:e===1?`1 NEEDS YOU`:`${e} NEED YOU`}var WO=new Map([[`hand`,2]]),GO=1;function KO(e){return e?typeof e==`string`&&WO.get(e)||GO:0}function qO(e){let t=!1,n=0;for(let r of e||[]){let e=KO(r);e<=n||(t=typeof r!=`string`||r,n=e)}return t}var JO=`Estimated list prices, not a bill.`,YO=`Enable in Settings.`,XO=Object.freeze([{value:`7`,label:`Last 7 days`,days:7},{value:`30`,label:`Last 30 days`,days:30},{value:`90`,label:`Last 90 days`,days:90},{value:`all`,label:`All retained`,days:null}]),ZO=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],QO=/^(\d{4})-(\d{2})-(\d{2})$/,$O=new Set([`day`,`model`,`label`]),ek=new Set([`model`,`label`]);function tk(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function nk(e){return e.includes(`.`)?e.replace(/0+$/,``).replace(/\.$/,``):e}function rk(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e);return`${t<0?`-`:``}${tk(String(Math.abs(t)))}`}function ik(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.abs(e);if(t===0)return`$0.00`;let n=e<0?`-`:``;if(t<1e-4)return e<0?`above -$0.0001`:`<$0.0001`;if(t<.01)return`${n}$${t.toFixed(4)}`;let[r,i]=t.toFixed(2).split(`.`);return`${n}$${tk(r)}.${i}`}function ak(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=e<0?`-`:``,n=Math.abs(e);if(n<1e3){let e=Math.round(n);return`${e===0?``:t}${e}`}return n<999950?`${t}${nk((n/1e3).toFixed(1))}k`:n<999995e3?`${t}${nk((n/1e6).toFixed(2))}M`:`${t}${nk((n/1e9).toFixed(2))}B`}function ok(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:e>0&&e<.1?`<0.1%`:`${nk(e.toFixed(1))}%`}function sk(e){let t=Number(e?.costUSD);return Number.isFinite(t)&&t>0?`costUSD`:`tokens`}function ck(e){return e===`costUSD`?`share of cost`:`share of tokens`}function lk(e,t){let n=Number(e),r=Number(t);return!Number.isFinite(n)||!Number.isFinite(r)||r<=0?null:n/r*100}function uk(e){let t=QO.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=ZO[Number(t[2])-1];return n?`${n} ${Number(t[3])}`:String(e)}function dk(e){let t=fk(e);return t.length===0?``:t.length===1?uk(t[0]):`${uk(t[0])} to ${uk(t[t.length-1])}`}function fk(e){return(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?e:e?.day).map(e=>String(e??``)).filter(e=>QO.test(e)).sort()}function pk(e){let t=Number(e?.ts);return!Number.isFinite(t)||t<=0?``:mk(t,typeof e?.tz==`string`&&e.tz?e.tz:null)}function mk(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`};t&&(n.timeZone=t);let r=hk(e,n);return QO.test(r)?r:hk(e,{year:`numeric`,month:`2-digit`,day:`2-digit`})}function hk(e,t){try{return new Intl.DateTimeFormat(`en-CA`,t).format(new Date(e))}catch{return``}}function gk(e){if(typeof e!=`number`||!Number.isFinite(e)||e<0)return`-`;let t=Math.round(e);if(t<60)return`${t}m`;let n=Math.floor(t/60),r=t%60;return r===0?`${n}h`:`${n}h ${r}m`}function _k(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return`-`;let n=new Date(t),r=ZO[n.getMonth()];if(!r)return`-`;let i=String(n.getHours()).padStart(2,`0`),a=String(n.getMinutes()).padStart(2,`0`);return`${r} ${n.getDate()} ${i}:${a}`}function vk(e){if(!e||typeof e!=`object`)return[];let t=[];if(Number.isFinite(e.tokensPerMinute)){let n=Number.isFinite(e.tokensPerMinuteExCache)?`${ak(e.tokensPerMinuteExCache)} excluding cache`:``;t.push({label:`tokens per min`,value:ak(e.tokensPerMinute),sub:n})}return Number.isFinite(e.costPerHour)&&t.push({label:`cost per hour`,value:ik(e.costPerHour),sub:``}),t}function yk(e){if(!e||typeof e!=`object`)return``;let t=[];Number.isFinite(e.projectedTokens)&&t.push(`${ak(e.projectedTokens)} tokens`),Number.isFinite(e.projectedCostUSD)&&t.push(ik(e.projectedCostUSD));let n=Number.isFinite(e.remainingMinutes)?`${gk(e.remainingMinutes)} left in this block`:``;if(t.length===0)return n;let r=`-> ${t.join(`, `)} by block end`;return n?`${r}, ${n}`:r}function bk(e,t=Date.now()){let n=Number(e?.startTs),r=Number(e?.endTs);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)return null;let i=(r-n)/6e4,a=Math.min(Math.max((t-n)/6e4,0),i);return{totalMinutes:i,elapsedMinutes:a,remainingMinutes:Math.max(i-a,0),pct:Math.round(a/i*100)}}function xk(e){return typeof e!=`number`||!Number.isFinite(e)?`ok`:e>=100?`crit`:e>=80?`warn`:`ok`}function X(e){return typeof e!=`number`||!Number.isFinite(e)?null:e}function Sk(e){let t=X(e?.max);return t===null||t<=0?null:t}function Ck(e){let t=Sk(e),n=X(e?.pct);return t===null||n===null?null:n*100}function wk(e,t){let n=Sk(t),r=X(e?.projectedTokens);return n===null||r===null?null:r/n*100}function Tk(e){let t=Ck(e);return t===null?``:`${Math.round(t)}% of ${ak(e?.max)} tokens, the largest completed block seen`}function Ek(e,t){let n=wk(e,t);return n===null?``:n>=100?`On this burn rate the block ends past that reference, at ${Math.round(n)}% of it.`:`On this burn rate the block ends at ${Math.round(n)}% of that reference.`}var Dk=Object.freeze([{key:`input`,label:`input`},{key:`output`,label:`output`},{key:`cacheCreate`,label:`cache write`},{key:`cacheRead`,label:`cache read`}]);function Ok(e){let t=Dk.map(t=>{let n=Number(e?.[t.key]);return{spec:t,tokens:Number.isFinite(n)&&n>0?n:0}}),n=t.reduce((e,t)=>e+t.tokens,0);return n<=0?[]:t.map(e=>{let t=lk(e.tokens,n)??0,r=ak(e.tokens);return{key:e.spec.key,label:e.spec.label,value:r,pct:t,title:`${e.spec.label} ${r}, ${ok(t)}`}})}var kk=Object.freeze({interactive:`Interactive`,"pr-review":`PR review`,"team-review":`PR reviews`,posthog:`PostHog`,"my-prs":`Keep mergeable`,workflows:`Workflows`,"change-map":`Change map`,visions:`Visions`,benchmark:`Benchmarks`,"agent-spawn":`Agent API`,"task-title":`Task titles`,other:`Other`}),Ak=`Sessions spawned by Glimmervoid; terminal sessions count as other`,jk=`Claude sessions Glimmervoid spawned for its own work; plan share is estimated pro rata by cost`;function Mk(e){let t=typeof e==`string`?e.trim():``;return t?kk[t]||t:kk.other}function Nk(e){let t=e?.byLane;return Array.isArray(t)?t.filter(e=>e&&typeof e.lane==`string`):[]}function Pk(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`interactive`&&t!==`other`}function Fk(e){return Nk(e).some(e=>Pk(e.lane))}var Ik=Object.freeze({fiveHour:`This 5 hour block`,sevenDay:`7 day window`});function Lk(e,t,n){let r=LA(e,t);return!r||r.resetsAtMs!==null&&r.resetsAtMs<=n?null:r.pct}function Rk(e,t,n,r){if(!Array.isArray(t))return null;let i=t.filter(e=>e&&typeof e.lane==`string`),a=i.reduce((e,t)=>e+(X(t.costUSD)??0),0),o=i.reduce((e,t)=>e+(X(t.tokens)??0),0),s=i.filter(e=>Pk(e.lane)).map(e=>({lane:String(e.lane),label:Mk(e.lane),tokens:X(e.tokens)??0,costUSD:X(e.costUSD)??0})),c=s.reduce((e,t)=>e+t.costUSD,0),l=s.reduce((e,t)=>e+t.tokens,0),u=a>0?lk(c,a):lk(l,o),d=Lk(n,e,r),f=u===null||d===null?null:u/100*d;return{key:e,label:Ik[e],tokens:l,costUSD:c,sharePct:u,planPct:f,lanes:s}}function zk(e,t,n=Date.now()){let r=e?.planWindowLanes;return!r||typeof r!=`object`?[]:IA.map(e=>Rk(e.key,r[e.key],t,n)).filter(e=>e!==null)}function Bk(e){return e.planPct===null?``:`about ${ok(e.planPct)} of plan`}function Vk(e){return e.lanes.filter(e=>e.costUSD>0||e.tokens>0).map(e=>`${e.label} ${e.costUSD>0?ik(e.costUSD):ak(e.tokens)}`).join(`, `)}var Hk=`team-review`;function Uk(e){if(!Array.isArray(e?.byLane))return null;let t=Nk(e).find(e=>e.lane===Hk),n=X(t?.costUSD)??0,r=X(t?.tokens)??0,i=sk(e?.totals),a=lk(i===`costUSD`?n:r,e?.totals?.[i]),o=a===null?``:`${ok(a)} of range ${i===`costUSD`?`cost`:`tokens`}`,s=[ik(n),o,Wk(t?.sessions)].filter(Boolean).join(`, `);return{label:Mk(Hk),value:ak(r),sub:s}}function Wk(e){let t=X(e);return t===null||t<=0?``:`${rk(t)} ${t===1?`session`:`sessions`}`}function Gk(e){let t=e?.rtk;return!t||typeof t!=`object`||t.available!==!0?null:t}function Kk(e){let t=e?.cache;return!t||typeof t!=`object`?null:t}function qk(e){return Gk(e)!==null||Kk(e)!==null}function Jk(e){let t=Gk(e);if(!t)return null;let n=X(t.commands)??0,r=n===1?`command`:`commands`;return{value:`${ak(X(t.savedTokens)??0)} tokens`,sub:`${ok(X(t.savingsPct)??0)} avg across ${rk(n)} ${r}`}}function Yk(e){let t=Kk(e);if(!t)return null;let n=ak(X(t.cacheReadTokens)??0),r=(Array.isArray(t.unpricedModels)?t.unpricedModels:[]).filter(e=>e),i=`${n} cache read tokens`;if(r.length===0)return{value:ik(X(t.savedUSD)??0),sub:i};let a=r.length===1?`model`:`models`;return{value:ik(X(t.savedUSD)??0),sub:`${i}, a floor (${r.length} unpriced ${a})`}}function Xk(e){let t=e?.budget?.rows;return Array.isArray(t)?t.filter(e=>e&&X(e.budgetUsd)!==null):[]}function Zk(e){return e===`monthly`?`this month`:`today`}function Qk(e){return`${ik(X(e?.spentUsd)??0)} of ${ik(X(e?.budgetUsd)??0)}`}function $k(e){let t=X(e?.pct);return t===null?0:t}function eA(e){return`${Zk(e?.scope)} spend against budget`}var tA=Object.freeze([{value:`day`,label:`Day`},{value:`week`,label:`Week`},{value:`month`,label:`Month`}]);function nA(e){let t=QO.exec(String(e??``));return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12):null}function rA(e){return String(e).padStart(2,`0`)}function iA(e){return`${e.getFullYear()}-${rA(e.getMonth()+1)}-${rA(e.getDate())}`}function aA(e){let t=nA(e);if(!t)return``;let n=(t.getDay()+6)%7;return t.setDate(t.getDate()-n),iA(t)}function oA(e){let t=QO.exec(String(e??``));return t?`${t[1]}-${t[2]}`:``}function sA(e){return{key:e,tokens:0,costUSD:0,input:0,output:0,cacheCreate:0,cacheRead:0,days:0,sources:new Set,vendorSet:new Set,modelByName:new Map}}function cA(e,t){e.tokens+=X(t?.tokens)??0,e.costUSD+=X(t?.costUSD)??0,e.input+=X(t?.input)??0,e.output+=X(t?.output)??0,e.cacheCreate+=X(t?.cacheCreate)??0,e.cacheRead+=X(t?.cacheRead)??0,e.days+=1,e.sources.add(t?.source===`history`?`history`:`live`);let n=Array.isArray(t?.vendors)?t.vendors:[];for(let t of n)e.vendorSet.add(t);let r=t?.models||[];for(let t of r){t?.vendor&&e.vendorSet.add(t.vendor);let n=oj(t),r=e.modelByName.get(n)||{key:n,model:t?.model??n,vendor:t?.vendor,tokens:0,costUSD:0,input:0,output:0,cacheCreate:0,cacheRead:0};r.tokens+=X(t?.tokens)??0,r.costUSD+=X(t?.costUSD)??0,r.input+=X(t?.input)??0,r.output+=X(t?.output)??0,r.cacheCreate+=X(t?.cacheCreate)??0,r.cacheRead+=X(t?.cacheRead)??0,e.modelByName.set(n,r)}}function lA(e){let{modelByName:t,sources:n,vendorSet:r,...i}=e,a={...i};return a.day=e.key,a.models=Array.from(t.values()).sort((e,t)=>t.tokens-e.tokens),a.source=n.has(`live`)?`live`:`history`,a.vendors=Array.from(r).sort(),a}function uA(e,t){let n=new Map,r=Array.isArray(e)?e:[];for(let e of r){let r=t(e?.day);if(!r)continue;let i=n.get(r)||sA(r);cA(i,e),n.set(r,i)}return Array.from(n.values()).map(lA)}function dA(e){return uA(e,aA)}function fA(e){return uA(e,oA)}function pA(e,t){return t===`week`?dA(e):t===`month`?fA(e):Array.isArray(e)?[...e]:[]}var mA=/^(\d{4})-(\d{2})$/;function hA(e,t){if(t===`month`){let t=mA.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=ZO[Number(t[2])-1];return n?`${n} ${t[1]}`:String(e)}if(t===`week`){let t=uk(e);return t===`-`?t:`week of ${t}`}return uk(e)}function gA(e){return(Array.isArray(e)?e:[]).some(e=>e?.source===`history`)?`older days from local history`:``}var _A=Object.freeze([.05,.25,.5,.75]),vA=Object.freeze([`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`]);function yA(e,t){let n=X(e)??0,r=X(t)??0;if(n<=0||r<=0)return 0;let i=n/r,a=1;for(let e=0;e<_A.length;e+=1)i>=_A[e]&&(a=e+1);return a}function bA(e,{weeks:t=16,today:n=new Date}={}){let r=(Array.isArray(e)?e:[]).filter(e=>QO.test(String(e?.day??``))),i=new Map(r.map(e=>[String(e.day),e])),a=n instanceof Date?n:new Date(n),o=Number.isFinite(a.getTime())?a:new Date,s=typeof n==`string`&&QO.test(n)?n:iA(o),c=nA(aA(s));if(!c)return{cells:[],max:0,weeks:0};let l=new Date(c.getFullYear(),c.getMonth(),c.getDate()-(t-1)*7,12),u=iA(l),d=[],f=0,p=null;for(let e of r){let t=String(e.day);(p===null||t<p)&&(p=t),!(t<u||t>s)&&(f=Math.max(f,X(e.tokens)??0))}for(let e=0;e<t;e+=1)for(let t=0;t<7;t+=1){let n=iA(new Date(l.getFullYear(),l.getMonth(),l.getDate()+e*7+t,12)),r=i.get(n)||null,a=n>s,o=p!==null&&n<p;d.push({day:n,week:e,weekday:t,tokens:X(r?.tokens)??0,costUSD:X(r?.costUSD)??0,source:r?.source===`history`?`history`:r?`live`:null,noData:a||o||!r&&p===null,tone:yA(r?.tokens,f)})}return{cells:d,max:f,weeks:t}}function xA(e){let t=uk(e?.day);if(e?.noData)return`${t}: no data`;let n=X(e?.tokens)??0;return n<=0?`${t}: no usage`:`${t}: ${ak(n)} tokens, ${ik(X(e?.costUSD)??0)}`}function SA(e){if(!e)return``;let t=X(e.baselineDays),n=t===null?`recent`:`${Math.round(t)} day`;return`Today is ${DA(e.ratio)} the ${n} average: ${ik(e.todayUsd)} against ${ik(e.baselineUsd)}.`}function CA(e){return e?`This block is burning ${DA(e.ratio)} the usual rate: ${ak(e.current)} tokens per minute against ${ak(e.baseline)}.`:``}function wA(e){return[SA(e?.daily),CA(e?.burn)].filter(Boolean).join(` `)}function TA(e){return e?.daily||e?.burn?`warn`:`ok`}function EA(e){return!!(e?.daily||e?.burn)}function DA(e){let t=X(e);return t===null?`-`:`${nk(t.toFixed(1))}x`}var OA=Object.freeze({claude:`Claude`,codex:`Codex`,grok:`Grok`});function kA(e){let t=typeof e==`string`?e.trim():``;return t?OA[t]||t:OA.claude}function AA(e,t){return MA(t)?kA(e?.vendor):``}function jA(e){let t=e?.byVendor;return!t||typeof t!=`object`?[]:Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`).sort((e,n)=>(X(t[n]?.tokens)??0)-(X(t[e]?.tokens)??0)).map(e=>({vendor:e,label:kA(e),tokens:X(t[e]?.tokens)??0,costUSD:X(t[e]?.costUSD)??0}))}function MA(e){let t=e?.byVendor;if(!t||typeof t!=`object`)return!1;let n=Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`);return n.length>1||n.length===1&&n[0]!==`claude`}var NA=`Claude only`;function PA(e){return MA(e)?NA:``}var FA=36e5,IA=Object.freeze([{key:`fiveHour`,label:`5 hour`},{key:`sevenDay`,label:`7 day`}]);function LA(e,t){let n=e?.[t];if(!n||typeof n!=`object`)return null;let r=X(n.pct),i=X(n.resetsAtMs);return r===null&&i===null?null:{pct:r,resetsAtMs:i}}function RA(e){return IA.some(t=>LA(e,t.key)!==null)}function zA(e){return LA(e,`fiveHour`)?.pct??null}function BA(e){return e===`official`?`official, from Claude Code`:e===`estimated`?`estimated from the largest completed block`:``}function VA(e,t=null){let n=zA(t);if(n!==null)return xk(n);let r=xk(Ck(e?.tokenLimit));return r===`ok`?xk(wk(e?.activeBlock?.projection,e?.tokenLimit)):r}function HA(e,t=null){let n=[],r=VA(e,t);r!==`ok`&&n.push(`block:${r}`),e?.anomaly?.daily&&n.push(`anomaly:daily`),e?.anomaly?.burn&&n.push(`anomaly:burn`);for(let t of Xk(e)){let e=$k(t);if(e<90)continue;let r=typeof t?.scope==`string`&&t.scope?t.scope:`budget`;n.push(`budget:${r}:${e>=100?`over`:`near`}`)}return IE(n)}function UA(e){let t=X(e?.pct);return t===null?`-`:`${ok(t)} used`}function WA(e,t=Date.now()){let n=X(e);if(n===null||n<=0)return``;let r=(n-t)/6e4;return r<=0?`resetting now`:`resets in ${gk(r)}`}function GA(e,t=Date.now()){let n=X(e);return n===null||n<=0?``:`${Math.max(0,Math.round((t-n)/6e4))}m old`}function KA(e,t=Date.now()){let n=X(e);return n===null||n<=0||t-n>FA}function qA(e,t=Date.now()){if(!KA(e,t))return``;let n=GA(e,t);return n?`showing last-known usage (${n})`:`showing last-known usage`}function JA(e,t=``){let n=e?.source;if(n===`fetched`){let e=typeof t==`string`?t.trim():``;return e?`Prices fetched from the public model price table, ${e}.`:`Prices fetched from the public model price table.`}if(n===`cache`){let e=typeof t==`string`?t.trim():``;return e?`Prices from the cached public model price table, ${e}.`:`Prices from the cached public model price table.`}return n===`snapshot`?`Prices from the price table bundled with this Glimmervoid build.`:n===`unavailable`?`Model prices could not be loaded, so every cost below counts as zero.`:`Pricing source not reported yet.`}function YA(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`)return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function XA(e){let t=(Array.isArray(e)?e:[]).map(e=>String(e)).filter(e=>e);if(t.length===0)return``;let n=t.length===1?`model`:`models`;return`No price for ${t.length} ${n}: ${t.join(`, `)}. Their cost counts as zero here.`}function ZA(e){if(Array.isArray(e))return e.length;let t=Number(e);return Number.isFinite(t)?t:null}function QA(e){if(!e||typeof e!=`object`)return``;let t=[],n=ZA(e.dirs);if(n!==null&&t.push(`${rk(n)} transcript ${n===1?`directory`:`directories`}`),Number.isFinite(e.files)&&t.push(`${rk(e.files)} files`),Number.isFinite(e.entries)&&t.push(`${rk(e.entries)} entries`),Number.isFinite(e.lastScanMs)&&t.push(`last pass ${rk(e.lastScanMs)}ms`),t.length===0)return``;let r=`Scanned ${t.join(`, `)}.`;return e.partial===!0?`${r} Some files were skipped this pass and will be re-read on the next one.`:r}function $A(e){return typeof e?.error==`string`?e.error.trim():``}function ej(e){let t=typeof e?.warning==`string`?e.warning.trim():``;return t?`Glimmervoid could not read every transcript location: ${t}`:``}function tj(e){return $A(e)!==``}function nj(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return n==null||n===t}function rj(e){let t=String(e??``).trim();if(!t)return``;let n=t.split(/[\\/]+/).filter(e=>e);return n.length===0?t:n[n.length-1]}function ij(e){return typeof e?.id==`string`&&e.id!==``}function aj(e){let t=typeof e?.label==`string`?e.label.trim():``;return ij(e)&&t?t:rj(e?.project)||t||`unknown project`}function oj(e){let t=typeof e==`string`?e:e?.model;return(typeof t==`string`?t.trim():``)||`unknown model`}function sj(e){return String(e?.day??``)}function cj(e,t,n){if(!$O.has(t)){let n=Number(e?.[t]);return Number.isFinite(n)?n:0}return t===`day`?sj(e):n(e)}function lj(e,t,n,r=aj){let i=Array.isArray(e)?[...e]:[],a=n===`asc`?1:-1;return i.sort((e,n)=>{let i=cj(e,t,r),o=cj(n,t,r);if(typeof i==`string`||typeof o==`string`)return a*String(i).localeCompare(String(o));if(i!==o)return a*(i-o);let s=Number(e?.tokens),c=Number(n?.tokens),l=Number.isFinite(s)?s:0,u=Number.isFinite(c)?c:0;return l===u?r(e).localeCompare(r(n)):u-l})}function uj(e){return ek.has(e)?`asc`:`desc`}function dj(e,t){return e?.key===t?{key:t,dir:e.dir===`asc`?`desc`:`asc`}:{key:t,dir:uj(t)}}function fj(e,t){return e?.key===t?e.dir===`asc`?`ascending`:`descending`:`none`}var pj=Object.freeze({key:`lastTs`,dir:`desc`}),mj=Object.freeze({key:`tokens`,dir:`desc`}),hj=Object.freeze({key:`day`,dir:`desc`});function gj(e,t=pj){return lj(e,t.key,t.dir,aj)}function _j(e,t,n=10){if(!Array.isArray(e))return{rows:[],hiddenCount:0};let r=Number.isFinite(n)?Math.max(0,Math.floor(n)):10;return t||e.length<=r?{rows:e,hiddenCount:0}:{rows:e.slice(0,r),hiddenCount:e.length-r}}function vj(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:`${rk(t)} hidden`}function yj(e,t=mj){return lj(e,t.key,t.dir,oj)}function bj(e,t=hj){return lj(e,t.key,t.dir,sj)}function xj(e,t){return(Array.isArray(e)?e:[]).find(e=>String(e?.day??``)===String(t??``))||null}function Sj(e,t=8){return(Array.isArray(e)?e:[]).filter(e=>e&&e.isGap!==!0).sort((e,t)=>(Number(t?.startTs)||0)-(Number(e?.startTs)||0)).slice(0,Math.max(0,t)).map(e=>({startTs:Number(e.startTs),tokens:typeof e.tokens==`number`&&Number.isFinite(e.tokens)?e.tokens:0,costUSD:typeof e.costUSD==`number`&&Number.isFinite(e.costUSD)?e.costUSD:0,isActive:e.isActive===!0}))}function Cj(e){let t=X(e?.officialCostUSD);if(t!==null&&t>0)return{costUSD:t,source:`official`};let n=X(e?.costUSD);return n!==null&&n>0?{costUSD:n,source:`estimated`}:{costUSD:null,source:null}}function wj(e){let t=Number(e?.tokens);if(!Number.isFinite(t)||t<=0)return``;let{costUSD:n}=Cj(e);return n===null?ak(t):`${ak(t)} ${ik(n)}`}function Tj(e){let{source:t}=Cj(e);return t===`official`?`Tokens counted from the transcript; cost reported by Claude Code for this conversation`:`Tokens and estimated API list-price cost for this conversation`}var Ej=Object.freeze({"claude-code":{approve:[{data:`\r`}],dismissPrompt:[{data:`\x1B`}],instruct:e=>[{data:e,delayBeforeMs:0},{data:`\r`,delayBeforeMs:800}],answerWithOption:e=>[{data:String(e+1)}],answerWithText:(e,t)=>[{data:String(e+1),delayBeforeMs:0},{data:t,delayBeforeMs:800},{data:`\r`,delayBeforeMs:800}],reply:e=>[{data:e,delayBeforeMs:0},{data:`\r`,delayBeforeMs:300}]}});function Dj(e){return typeof e!=`string`||!Object.hasOwn(Ej,e)?null:Ej[e]}function Oj(e){return Dj(e)!==null}function jne(e){return Dj(e)?.approve??null}function Mne(e,t){let n=Dj(e);return n?{dismissPrompt:n.dismissPrompt,instruct:n.instruct(t)}:null}function kj(e){return Number.isInteger(e)&&e>=1&&e<=8}function Nne(e,t,n,r){let i=Dj(e);return!i||r||!kj(n)||!Number.isInteger(t)||t<0||t>=n?null:i.answerWithOption(t)}function Pne(e,t,n,r){let i=Dj(e);return!i||r||!kj(t)||!n.trim()?null:i.answerWithText(t,n)}function Fne(e,t){let n=Dj(e);return!n||!t.trim()?null:n.reply(t)}function Aj(e,t){return e===I.WAITING&&typeof t==`string`&&t!==``}function Ine({currentState:e,pendingPromptKind:t,elapsedMs:n}){return Aj(e,t)?n>=1e4?`give-up`:`wait`:`send`}function Lne(e){return e.state===I.COMPLETE||e.state===I.IDLE&&e.hasEndedTurn===!0}function jj(e){if(e.state===I.WAITING)return`now`;if(e.state===I.FAILED)return`next`;if(Lne(e))return`later`;switch(e.state){case I.IDLE:return`ready`;case I.RUNNING:case I.STARTING:case I.INITIALIZING:return`working`;default:return`resting`}}var Mj={now:0,next:1,later:2,ready:3,working:4,resting:5};function Nj(e){return e.map((e,t)=>({row:e,index:t,rank:Mj[jj(e)]})).filter(e=>e.rank<Mj.ready).sort((e,t)=>e.rank-t.rank||(e.row.stateSince??1/0)-(t.row.stateSince??1/0)||e.index-t.index).map(e=>e.row)}function Pj(e,t){return Nj(e).find(e=>jj(e)===`now`&&e.id!==t)??null}function Rne(e,t){return zO(Nj(e).map(e=>e.id),t)??null}function zne(e,t,n){return!t||e!==t?null:Pj(n,e)?.id??null}function Bne(e,t,n,r){if(!t||r||n-e.armedAtMs>=15e3)return`cancel`;let i=t.pendingPromptSummary!==void 0&&t.pendingPromptSummary!==e.armedPromptSummary;return t.state===I.WAITING&&i?`cancel`:t.stateSince===e.armedStateSince?`keep`:t.state===I.RUNNING?`fire`:`cancel`}var Vne=6e4;function Fj(e){let t=Math.floor(Math.max(0,e)/Vne);return t<1?`<1m`:gk(t)}function Hne(e){let t={now:0,next:0,later:0,ready:0,working:0};for(let n of e){let e=jj(n);e!==`resting`&&(t[e]+=1)}return t}function Une(e){return e?.question?.multiSelect===!1}function Wne(e){return e.pendingPromptKind===`plan`?{component:`plan`,canApprove:!1}:e.pendingPromptKind!==`permission`||!Oj(e.agent)?{component:`terminal`,canApprove:!1}:Une(e.pendingPromptDetail)?{component:`question`,canApprove:!1}:e.pendingPromptDetail?.toolName===`AskUserQuestion`?{component:`terminal`,canApprove:!1}:{component:`permission`,canApprove:e.pendingPromptDetail?.isComplete===!0}}function Ij(e){switch(jj(e)){case`now`:return Wne(e);case`next`:return{component:`failure`,canApprove:!1};case`later`:return{component:`review`,canApprove:!1};default:return{component:`terminal`,canApprove:!1}}}var Gne={permission:`wants to run`,question:`asks`,plan:`has a plan ready`,failure:`failed`,review:`waits for you`},Kne=new Map([[I.RUNNING,`is working`],[I.STARTING,`is working`],[I.INITIALIZING,`is working`],[I.IDLE,`has no task`],[I.DONE,`has exited`],[I.DORMANT,`is asleep`]]);function Lj(e,t){return t===`terminal`?Kne.get(e.state)??(jj(e)===`now`?`needs you`:`is quiet`):Gne[t]}function Rj(e,t,n,r){return e!==I.WAITING||t!==`permission`||!n||!r?!1:n.toolName===r.toolName&&n.summary===r.summary&&n.isComplete===r.isComplete&&qc(n.question,r.question)}function qne(e,t){return(e===I.COMPLETE||e===I.IDLE)&&t==null}function zj(e){return Oj(e.agent)}function Jne(e){return jj(e)===`ready`&&zj(e)}function Bj(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.kind!==`assistant`||n.agentId||n.agentType)continue;let r=n.text.trim();if(r)return r}return null}var Vj={now:`▲`,next:`■`,later:`✓`,ready:`○`,working:`·`,resting:`·`},Hj=null,Uj=()=>{},Wj=null,Gj=null,Kj=null,qj=null,Jj=!1,Yj=null,Xj=null,Zj=``,Qj=null,$j=null,eM=null,tM=null,nM=null,rM=null,iM=null,aM=null,oM=[],sM=new Map,Yne=15e3,cM=`The prompt is still open. Open Terminal to continue.`,lM=`Unable to send. Open Terminal to continue.`,uM=`The question changed. Open Terminal to continue.`,dM=`The session is busy. Open Terminal to continue.`,Xne=50,Zne=46/AO,Qne={desktop:`Click a light for its action. Lights on the rings are waiting for you; hollow outer lights are free for a new task; faint ones are working.`,phone:`Tap a light or a row for its action. Lights on the rings are waiting for you; hollow outer lights are free for a new task; faint ones are working.`};function fM(){return Wj!==null&&Wj===Hj&&!Jd()}function pM(){return[...U].map(([e,t])=>({id:e,name:Xd(t),state:t.currentState,stateSince:t.stateSince,agent:t.agent,pendingPromptKind:t.pendingPromptKind,pendingPromptDetail:t.pendingPromptDetail,hasEndedTurn:t.hasEndedTurn}))}function mM(e){return Gj?[...Gj.querySelectorAll(`.calm-light`)].find(t=>t.dataset.sessionId===e)??null:null}function hM(){if(Kj?.parentElement?.classList.remove(`calm-has-panel`),Kj?.remove(),qj?.remove(),qj=null,Kj=null,Yj=null,Xj=null,Zj=``,Qj=null,oM=[],Gj&&(Gj.inert=!1),aM?.isConnected){aM.focus();return}mM(aM?.dataset.sessionId)?.focus()}function gM(){let e=Kj!==null&&Wj?.kind===`phone`;e!==Jj&&(Jj=e,Wj?.navigation.onSheetOpenChange?.(e))}function _M(){hM(),gM()}function vM(){Yj&&sM.delete(Yj),_M()}function yM(e,t,n){if(sM.set(e,{text:t,recordedAtMs:Date.now(),promptSummary:n}),!Kj||Yj!==e)return;let r=Kj.querySelector(`.calm-status`);r&&(r.textContent=t)}function bM(e){return e?.question?.text??e?.summary}function $ne(e,t){let n=sM.get(e);if(!n)return``;let r=Date.now()-n.recordedAtMs>=Yne,i=t!==void 0&&t!==n.promptSummary;return!r&&!i?n.text:(sM.delete(e),``)}function ere(){for(let e of sM.keys())U.has(e)||sM.delete(e)}function xM(e,t,n){let r=V(`button`,t,e);return r.type=`button`,r.addEventListener(`click`,n),r}var tre={trace:`.calm-trace`,diff:`.calm-diff`,plan:`.calm-status`};function SM(e,t){let n=oM.findIndex(n=>n.id===e&&t.includes(n.kind));return n<0?null:oM.splice(n,1)[0].kind}function CM(e,t){if(t.classList.add(`calm-trace`),t.textContent=`Loading trace...`,!B({type:`session-trace`,id:e,endingAt:`tail`})){t.textContent=`Trace unavailable. Open Terminal to continue.`;return}oM.push({id:e,kind:`trace`})}function nre(e){if(!SM(e.id,[`trace`])||!Wj||Yj!==e.id||!Kj)return;let t=Kj.querySelector(`.calm-trace`);if(!t)return;if(Xj===`review`){t.textContent=Bj(e.records)??`No message has been recorded.`;return}let n=e.records.filter(e=>e.kind===`tool_call`),r=new Map(n.map(e=>[e.toolUseId,e])),i=Kj.dataset.tier===`ready`?Bj(e.records):null;if(i){t.replaceChildren(V(`div`,`calm-agent-message`,i));return}let a=Xj===`failure`?n:e.records;t.replaceChildren(...a.slice(-3).map(e=>V(`div`,`calm-trace-row`,YD(e,r).text))),a.length||(t.textContent=`No trace has been recorded.`)}function rre(e){let t=e.scope===`plan-decision`,n=SM(e.id,t?[`plan`]:[`trace`,`diff`]);if(!n||!Wj||Yj!==e.id||!Kj)return;let r=Kj.querySelector(tre[n]);r&&(r.textContent=e.message)}var ire={sentStatus:`Instruction sent.`,failedStatus:`Unable to send instruction.`,blockedStatusBefore:e=>Aj(e.currentState,e.pendingPromptKind)?cM:null};function wM(e,t,n,r,i,a=0){let o=n[a];if(!o){i(r.sentStatus);return}setTimeout(()=>{if(U.get(e)!==t){i(r.failedStatus);return}let s=r.blockedStatusBefore(t,a);if(s){i(s);return}if(!yE(t,o.data)){i(r.failedStatus);return}wM(e,t,n,r,i,a+1)},o.delayBeforeMs)}function TM(e,t,n,r,i){if(U.get(e)!==t){i(`Unable to send instruction.`);return}let a=Ine({currentState:t.currentState,pendingPromptKind:t.pendingPromptKind,elapsedMs:Date.now()-r});if(a===`give-up`){i(cM);return}if(a===`send`){wM(e,t,n,ire,i);return}setTimeout(()=>TM(e,t,n,r,i),200)}function EM(e,t,n){let r=V(`input`,`calm-input`);return r.type=`text`,r.placeholder=e,r.setAttribute(`aria-label`,t),r.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.isComposing&&r.value.trim()&&(e.preventDefault(),n(r))}),r}function are(e,t,n,r){let i=e.pendingPromptDetail?.question;if(!i)return;let a=t=>yM(e.id,t,bM(e.pendingPromptDetail)),o=()=>Rj(t.currentState,t.pendingPromptKind,t.pendingPromptDetail,e.pendingPromptDetail),s=[],c=()=>{for(let e of s)e.disabled=!0},l=V(`div`,`calm-options`);i.options.forEach((n,r)=>{let u=xM(n,`calm-option`,()=>{if(u.disabled)return;let n=Nne(e.agent,r,i.options.length,i.multiSelect);if(!n){a(lM);return}if(!o()){a(uM);return}if(DE(t,e.id),!n.every(e=>yE(t,e.data))){a(lM);return}c(),a(`Answer sent.`)});s.push(u),l.append(u)});let u=EM(`or type your own answer`,`Or type your own answer`,n=>{let r=Pne(e.agent,i.options.length,n.value,i.multiSelect);if(!r){a(lM);return}if(!o()){a(uM);return}DE(t,e.id),c(),a(`Sending answer...`),wM(e.id,t,r,{sentStatus:`Answer sent.`,failedStatus:lM,blockedStatusBefore:(e,t)=>t===0&&!o()?uM:null},a)});s.push(u),n.append(V(`h2`,`calm-question`,i.text),l),r.append(u)}function DM(e,t,n){let r=t=>yM(e.id,t,bM(e.pendingPromptDetail)),i=e=>qne(e.currentState,e.pendingPromptKind),a=EM(`next instruction`,`Next instruction`,n=>{let a=Fne(e.agent,n.value);if(!a){r(lM);return}if(!i(t)){r(dM);return}DE(t,e.id),n.disabled=!0,wM(e.id,t,a,{sentStatus:`Instruction sent.`,failedStatus:lM,blockedStatusBefore:(e,t)=>t===0&&!i(e)?dM:null},r),r(`Sending instruction...`)});n.append(a)}function OM(e){let t=U.get(e.id),n=Wj;if(!n||!t)return;let{root:r,navigation:i}=n;hM(),aM=document.activeElement instanceof HTMLElement?document.activeElement:null,Yj=e.id;let a=Ij(e);Xj=a.component,Zj=JSON.stringify([e,t.planReviewState]),Kj=V(`article`,`calm-panel`),Kj.dataset.tier=jj(e),Kj.setAttribute(`role`,`dialog`),Kj.setAttribute(`aria-modal`,`true`),Kj.setAttribute(`aria-label`,`${e.name}, ${a.component}`),of(Kj);let o=V(`header`,`calm-panel-header`),s=V(`span`,`calm-panel-title`,`${Vj[jj(e)]} ${e.name} ${Lj(e,a.component)}`);s.tabIndex=-1,o.append(s,xM(`Terminal`,`calm-link`,()=>jM(e.id))),o.append(xM(`Close`,`calm-link`,vM));let c=V(`div`,`calm-panel-body`),l=V(`div`,`calm-actions`),u=V(`span`,`calm-status`,$ne(e.id,bM(e.pendingPromptDetail)));u.setAttribute(`role`,`status`);let d=(e,t)=>{let n=xM(e,`calm-primary`,()=>{if(!n.disabled){if(t()===!1){u.textContent=lM;return}n.disabled=!0,u.textContent=`Action sent.`}});Qj=n,l.append(n)};if(a.component===`permission`){c.append(V(`div`,`calm-tool-name`,e.pendingPromptDetail?.toolName??``),V(`pre`,`calm-summary`,e.pendingPromptDetail?.summary??``)),a.canApprove||c.append(V(`p`,`calm-caption`,`Review the full request in the terminal.`));let n=()=>Rj(t.currentState,t.pendingPromptKind,t.pendingPromptDetail,e.pendingPromptDetail),r=jne(e.agent),i=t=>yM(e.id,t,bM(e.pendingPromptDetail));if(a.canApprove&&r){d(`Approve`,()=>n()?(DE(t,e.id),r.every(e=>yE(t,e.data))):!1);let a=EM(`or tell it what to do instead`,`Or tell it what to do instead`,r=>{let a=Mne(e.agent,r.value);if(!a){i(lM);return}if(!n()){i(`The prompt changed. Open Terminal to continue.`);return}if(DE(t,e.id),!a.dismissPrompt.every(e=>yE(t,e.data))){i(lM);return}r.disabled=!0,Qj&&(Qj.disabled=!0),i(`Sending instruction...`),TM(e.id,t,a.instruct,Date.now(),i)});l.append(a)}}if(a.component===`question`&&are(e,t,c,l),a.component===`plan`){let n=LO(t.planReviewState),r=n?.openRevision?.revision,a=n?.revisions.find(e=>e.revision===r)?.title;c.append(V(`p`,`calm-summary`,a||`Plan ready for review`)),n&&r&&d(`Approve plan`,()=>{let n=LO(t.planReviewState);return n?.openRevision?B({type:`plan-decision`,id:e.id,agentId:n.agentId,revision:n.openRevision.revision,decision:`approve`})?(oM.push({id:e.id,kind:`plan`}),!0):!1:(i.openPlan(e.id),!0)}),(!n||!r)&&d(`Open plan`,()=>(i.openPlan(e.id),!0)),l.append(xM(`Open plan`,`calm-link`,()=>i.openPlan(e.id)))}if(a.component===`failure`){c.append(V(`p`,`calm-summary`,`Exited with a failure`));let n=V(`div`,`calm-trace`);c.append(n),CM(e.id,n),d(`Resume`,()=>B(cf(`restart`,t.currentState,e.id)))}if(a.component===`terminal`&&CM(e.id,c),Jne(e)&&DM(e,t,l),a.component===`review`){let n=V(`div`,`calm-agent-message`),r=V(`div`,`calm-diff`,`Loading files...`);c.append(n,r),CM(e.id,n);let a=B({type:`request-session-diff`,id:e.id});a&&oM.push({id:e.id,kind:`diff`}),a||(r.textContent=`Diff unavailable. Open review to continue.`),d(`Open review`,()=>(i.openTerminal(e.id),!0)),zj(e)&&DM(e,t,l)}l.append(u),Kj.append(o,c,l),r.classList.add(`calm-has-panel`),r.append(sre()),r.append(Kj),Gj&&(Gj.inert=!0),s.focus(),gM()}function ore(e){if(!SM(e.id,[`diff`])||!Wj||Xj!==`review`||Yj!==e.id||!Kj)return;let t=Kj.querySelector(`.calm-diff`);if(!t)return;let n=AE(`${e.committed.diff}\n${e.uncommitted.diff}`),r=FE(n);if(!n.length){t.replaceChildren();return}t.replaceChildren(V(`p`,`calm-summary`,`${r.files} files / +${r.added} -${r.removed}`),...n.map(e=>V(`div`,`calm-file`,`${e.path} +${e.added} -${e.removed}`)))}function sre(){return qj=V(`div`,`calm-sheet-scrim`),qj.setAttribute(`aria-hidden`,`true`),qj.addEventListener(`click`,vM),qj}function cre(e){let t=Hne(e),n=V(`header`,`calm-header`);for(let e of[`now`,`next`,`later`,`ready`,`working`]){let r=V(`span`,`calm-count`,`${Vj[e]} ${t[e]} ${e}`);r.dataset.tier=e,n.append(r)}return n}function lre(e){return e.kind===`phone`?Xne:Zne}function ure(e,t){let n=lre(t),r=V(`div`,`calm-rings`),i=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);i.setAttribute(`viewBox`,`0 0 100 100`),i.setAttribute(`aria-hidden`,`true`);for(let[e,t]of[[`now`,EO],[`next`,DO],[`later`,OO]]){let a=document.createElementNS(i.namespaceURI,`circle`);for(let[r,i]of Object.entries({cx:`50`,cy:`50`,r:String(t*n),"data-tier":e}))a.setAttribute(r,i);i.append(a);let o=V(`span`,`calm-ring-label`,e.toUpperCase());o.style.top=`${50-t*n+2}%`,r.append(o)}r.prepend(i);let a=new Map(e.map(e=>[e.id,e])),o=t.kind===`desktop`&&IO(t.root.clientWidth);for(let t of FO(e.map(e=>({id:e.id,tier:jj(e)})))){let e=a.get(t.id);if(!e)continue;let i=xM(``,`calm-light`,()=>OM(e));if(i.dataset.tier=t.tier,i.dataset.sessionId=e.id,i.setAttribute(`aria-label`,`${e.name}, ${t.tier}`),i.title=e.name,i.style.left=`${50+Math.cos(t.angle)*t.radius*n}%`,i.dataset.labelSide=Math.cos(t.angle)<0?`left`:`right`,i.style.top=`${50+Math.sin(t.angle)*t.radius*n}%`,i.append(V(`span`,`calm-light-dot`)),o){let t=V(`span`,`calm-light-label`,e.name);t.append(V(`span`,`calm-light-context`,Lj(e,Ij(e).component))),i.append(t)}r.append(i)}return r}function dre(e){let t=V(`div`,`calm-now-list`);t.setAttribute(`aria-label`,`NOW sessions`);for(let n of Nj(e).filter(e=>jj(e)===`now`))t.append(xM(`${Vj.now} ${n.name}`,`calm-now-row`,()=>OM(n)));return t}function kM(e){return Fj(Date.now()-e)}function fre(e){let t=V(`div`,`calm-now-list`);t.setAttribute(`aria-label`,`NOW sessions`);for(let n of Nj(e).filter(e=>jj(e)===`now`)){let e=Lj(n,Ij(n).component),r=xM(``,`calm-now-row`,()=>OM(n));r.setAttribute(`aria-label`,`${n.name}, ${e}`);let i=V(`span`,`calm-now-glyph`,Vj.now);i.setAttribute(`aria-hidden`,`true`);let a=V(`span`,`calm-now-details`);a.append(V(`span`,`calm-now-name`,n.name),V(`span`,`calm-now-context`,e));let o=V(`span`,`calm-now-wait`);o.setAttribute(`aria-hidden`,`true`),typeof n.stateSince==`number`&&(o.dataset.stateSince=String(n.stateSince),o.textContent=kM(n.stateSince)),r.append(i,a,o),t.append(r)}return t}function pre(){if(Gj&&Wj?.kind===`phone`)for(let e of Gj.querySelectorAll(`.calm-now-wait[data-state-since]`))e.textContent=kM(Number(e.dataset.stateSince))}function AM(){if(LM())return;let e=pM();ere();let t=Wj;if(!t||t.kind===`desktop`&&Jd())return;let n=V(`div`,`calm-home`);n.append(ure(e,t)),n.append(t.kind===`phone`?fre(e):dre(e));let r=V(`footer`,`calm-footer`,Qne[t.kind]),i=V(`div`,`calm-field`);i.append(cre(e),n,r);let a=document.activeElement instanceof HTMLElement?document.activeElement.dataset.sessionId:null;if(Gj?.remove(),Gj=i,Gj.inert=Kj!==null,t.root.prepend(Gj),a&&!Kj&&mM(a)?.focus(),!Yj)return;let o=e.find(e=>e.id===Yj);if(!o){_M();return}let s=U.get(Yj);JSON.stringify([o,s?.planReviewState])!==Zj&&OM(o)}function jM(e){let t=Wj;t&&(t.navigation.openTerminal(e),t.kind===`desktop`&&Vd.snapshot().focusedSessionId===e&&($j=e))}function MM(e){OM(e),aM=mM(e.id)}function NM(e){if(Uj(),!fM())return!1;let t=pM().find(t=>t.id===e);return t?(MM(t),!0):!1}function PM(){return!fM()||!Kj||!Yj?!1:(jM(Yj),!0)}function FM(){if(!fM())return!1;let e=pM(),t=Rne(e,Yj??tM),n=e.find(e=>e.id===t);return n?(tM=n.id,MM(n),!0):!1}function IM(e){let t=zne(e,$j,pM());return t?($j=null,NM(t),!0):!1}function LM(){if(!eM)return!1;let e=U.get(eM.sessionId),t=e?{state:e.currentState,stateSince:e.stateSince,pendingPromptSummary:e.pendingPromptDetail?.summary}:null,n=Bne(eM,t,Date.now(),eM.hasOtherInputArrived);if(n===`keep`)return!1;let r=eM.sessionId;return eM=null,n===`cancel`||Jd()?!1:IM(r)}function RM(e){let t=U.get(e);t&&!Jd()&&e===$j&&(eM={sessionId:e,armedAtMs:Date.now(),armedStateSince:t.stateSince,armedPromptSummary:t.pendingPromptDetail?.summary,hasOtherInputArrived:!1})}function zM(e,t){if(t){RM(e);return}eM?.sessionId===e&&(eM.hasOtherInputArrived=!0,LM())}function BM(){$j=null,eM=null}function VM(){nM&&!nM.card.hidden&&(nM.wait.textContent=iM===null?``:`waiting ${Fj(Date.now()-iM)}`)}function HM(e){let t=V(`div`,`focus-now-peek`);t.hidden=!0;let n=V(`span`,`focus-now-peek-details`);n.id=`focus-now-peek-details`;let r=V(`span`,`focus-now-peek-glyph`,Vj.now);r.setAttribute(`aria-hidden`,`true`);let i=V(`span`,`focus-now-peek-name`),a=V(`span`,`focus-now-peek-context`),o=V(`span`,`focus-now-peek-wait`);n.append(r,i,a,o);let s=xM(`Open in Calm`,`focus-now-peek-open`,()=>{rM&&NM(rM)});s.setAttribute(`aria-describedby`,n.id),t.append(n,s),e.append(t),nM={card:t,name:i,context:a,wait:o},Cf(VM)}function UM(e,t){if(!nM)return;let n=e?Pj(pM(),t):null;nM.card.hidden=!n,rM=n?.id??null,iM=n?.stateSince??null,n&&(nM.name.textContent=n.name,nM.context.textContent=Lj(n,Ij(n).component),VM())}function WM(){return[...document.querySelectorAll(`[role="dialog"], .dialog-overlay`)].some(e=>e!==Kj&&e.getClientRects().length>0)}function GM(e,{openCalm:t,...n}){Hj={kind:`desktop`,root:e,navigation:n},Uj=t,new ResizeObserver(()=>AM()).observe(e),CE(zM),Cf(pre),Vd.subscribe((e,t)=>{let n=t.includes(`activeView`)&&e.activeView!==`focus`,r=t.includes(`focusedSessionId`)&&e.focusedSessionId!==eM?.sessionId;(n||r)&&(eM=null),t.includes(`focusedSessionId`)&&e.focusedSessionId!==$j&&($j=null)}),document.addEventListener(`keydown`,e=>{fM()&&Kj&&!e.isComposing&&e.key===`Escape`&&(e.target===document.body||e.target instanceof Node&&Kj.contains(e.target))&&!WM()&&(e.preventDefault(),vM())})}function KM(){Hj&&Wj?.kind!==`phone`&&(Wj=Hj,AM())}function qM(){Wj?.kind===`desktop`&&(_M(),Wj=null)}function JM(e,t){(Wj?.kind!==`phone`||Wj.root!==e)&&(_M(),Wj={kind:`phone`,root:e,navigation:t}),AM()}function YM(){Wj?.kind===`phone`&&Kj&&vM()}function XM(){Wj?.kind===`phone`&&(_M(),Wj=null)}function ZM(e){return e===`remote`?`remote`:`local`}function QM(e,t){return ZM(t)===`local`||e!==`shutdown`}function $M(){return Vd.snapshot().borrowedCardId}function eN(e,t,n,{className:r}={}){if(!e?.card||!n)return;let i=$M();i&&i!==t&&tN();let a=e.card;a._cardHostClass&&a._cardHostClass!==r&&a.classList.remove(a._cardHostClass),a._cardHostClass=r||``,r&&a.classList.add(r),jd(a,n),Vd.dispatch(`borrowCard`,t),e._ensureTerminalReady?.(),e._setBorrowed?.(!0),e._showPreferredFace?.()}function tN(){let e=$M();if(Vd.dispatch(`borrowCard`,null),!e)return null;let t=U.get(e);t?._showTerminalFace?.(),t?._setBorrowed?.(!1),t?._setActiveViewer?.(!1);let n=t?.card;return n?(n._cardHostClass&&n.classList.remove(n._cardHostClass),delete n._cardHostClass,Md(n,$d),e):e}var nN=/^\s*at .+:\d+:\d+\)?$|^[^@\s]*@.+:\d+:\d+$/;function rN(e){let t=e.stack??``,n=String(e);return(t.startsWith(n)?t.slice(n.length):t).split(`
|
|
135
|
-
`).filter(e=>nN.test(e)).join(`
|
|
136
|
-
`)}function iN(e){return e==null?null:e instanceof Error?{name:(e.name||`Error`).slice(0,128),stack:rN(e).slice(0,qu)}:{name:`NonError`,stack:``}}function aN(e){let t=new Set;return n=>{let r=iN(n);if(!r)return;let i=`${r.name}\n${r.stack}`;t.has(i)||t.size>=32||e({type:`client-error`,...r})&&t.add(i)}}var oN=`<h2 class="dialog-title" id="add-session-title">Add Session</h2>
|
|
137
|
-
<fieldset class="dialog-mode-controls" aria-label="Session kind">
|
|
138
|
-
<button type="button" class="dialog-mode-button" id="add-session-single-mode" aria-pressed="true">Single repo</button>
|
|
139
|
-
<button type="button" class="dialog-mode-button" id="add-session-workspace-mode" aria-pressed="false">Workspace</button>
|
|
140
|
-
</fieldset>
|
|
141
|
-
<label class="dialog-label" id="add-session-picker-label">
|
|
142
|
-
Pick a project:
|
|
143
|
-
<select class="dialog-input project-picker" id="add-session-picker">
|
|
144
|
-
<option value="" disabled selected>Scanning...</option>
|
|
145
|
-
</select>
|
|
146
|
-
</label>
|
|
147
|
-
<fieldset class="dialog-workspace-list" id="add-session-workspace-list" aria-label="Workspace repositories" hidden></fieldset>
|
|
148
|
-
<label class="dialog-label" id="add-session-agent-label" hidden>
|
|
149
|
-
Agent
|
|
150
|
-
<select class="dialog-input" id="add-session-agent"></select>
|
|
151
|
-
</label>
|
|
152
|
-
<button type="button" class="dialog-advanced-toggle" id="add-session-advanced-toggle">Advanced options</button>
|
|
153
|
-
<div class="dialog-advanced-panel" id="add-session-advanced" hidden>
|
|
154
|
-
<label class="dialog-label">
|
|
155
|
-
Name
|
|
156
|
-
<input type="text" class="dialog-input" id="add-session-name" placeholder="my-project" autocomplete="off" spellcheck="false">
|
|
157
|
-
</label>
|
|
158
|
-
<label class="dialog-label" id="add-session-path-label">
|
|
159
|
-
Path
|
|
160
|
-
<input type="text" class="dialog-input" id="add-session-path" placeholder="C:\\Users\\...\\my-project" autocomplete="off" spellcheck="false">
|
|
161
|
-
</label>
|
|
162
|
-
</div>
|
|
163
|
-
<label class="dialog-label dialog-checkbox-label" id="add-session-skip-perms-label">
|
|
164
|
-
<input type="checkbox" class="dialog-checkbox" id="add-session-skip-perms">
|
|
165
|
-
<span>Skip permission prompts</span>
|
|
166
|
-
<span class="dialog-hint">The agent edits files and runs shell commands without asking first, so a bad instruction or a hostile file in the repo can act on this machine unchecked. Leave this off unless you trust the repo and the task.</span>
|
|
167
|
-
</label>
|
|
168
|
-
<div class="dialog-error" id="add-session-error"></div>
|
|
169
|
-
<div class="dialog-actions">
|
|
170
|
-
<button type="button" class="btn-dialog btn-dialog-cancel" id="add-session-cancel">Cancel</button>
|
|
171
|
-
<button type="button" class="btn-dialog btn-dialog-confirm" id="add-session-confirm">Add</button>
|
|
172
|
-
</div>
|
|
173
|
-
`,sN=`claude-code`,cN={codex:`Codex`,grok:`Grok`};function lN(e){if(typeof e!=`string`)return``;let t=e.trim();return!t||t===`claude-code`?``:cN[t]||t}function uN(e,{defaultId:t=sN}={}){let n=(Array.isArray(e)?e:[]).filter(e=>e?.resolvable&&typeof e.id==`string`&&e.id).map(e=>{let t=String(e.id);return{id:t,label:typeof e.label==`string`&&e.label?e.label:t}}),r=n.some(e=>e.id===t)?t:n.length>0?n[0].id:t;return{show:n.length>1,options:n,selectedId:r}}var dN=`No supported agent CLI was found on the PATH Glimmervoid runs with. Install Claude Code (or another supported agent), make sure its command is on that PATH, then run glimmervoid doctor to confirm.`;function fN(e){let t=typeof e==`object`&&e?e:null;return t===null||!Array.isArray(t.agents)||t.error||uN(t.agents).options.length>0?{canSpawn:!0,guidance:``}:{canSpawn:!1,guidance:dN}}function pN(e,t){if(e===t)return!0;let n=`${t} (`;if(!e.startsWith(n)||!e.endsWith(`)`))return!1;let r=e.slice(n.length,-1);return/^\d+$/.test(r)}function mN(e,t){let n=0;for(let r of t)pN(r,e)&&n++;return n}function hN(e,t){let n=new Set(t);if(!n.has(e))return e;for(let t=2;t<1e3;t++){let r=`${e} (${t})`;if(!n.has(r))return r}return`${e} (${Date.now()})`}function gN(){let e=[];for(let[,t]of U)e.push(t.card.dataset.session??``);return e}function _N(e){return mN(e,gN())}function vN(e){return hN(e??``,gN())}function yN(e){let t=Math.max(0,Math.round((Number(e)||0)/1e3));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}d`}function bN(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?`never`:`${yN(Date.now()-e)} ago`}var xN=e=>`polled ${bN(e)}`;function SN(e){let t=[],n=[],r=null,i=e=>{let t=e.format(e.ts);e.el.textContent!==t&&(e.el.textContent=t)},a=()=>{let r=e();if(r&&!r.closest(`[hidden]`)){for(let e of t)i(e);for(let e of n)e()}};return{track(e,n,r=xN){let a={el:e,ts:n,format:r};i(a),t.push(a)},onTick(e){n.push(e)},reset(){t=[],n=[]},ensure(){r||=Cf(a)}}}function CN(e,{value:t,disabled:n=!1,selected:r=!1}={}){let i=V(`option`,null,e);return t!=null&&(i.value=t),n&&(i.disabled=!0),r&&(i.selected=!0),i}function wN(e){return typeof e!=`object`||!e?!1:`skipPermissionsByDefault`in e&&e.skipPermissionsByDefault===!0}function TN(){let{dialog:e,close:t}=tf();e.innerHTML=oN,nf(e,`add-session-title`);let n=H(e,`#add-session-picker`,`select`),r=bd(e,`#add-session-picker-label`),i=bd(e,`#add-session-workspace-list`),a=H(e,`#add-session-single-mode`,`button`),o=H(e,`#add-session-workspace-mode`,`button`),s=bd(e,`#add-session-agent-label`),c=H(e,`#add-session-agent`,`select`),l=H(e,`#add-session-advanced-toggle`,`button`),u=bd(e,`#add-session-advanced`),d=H(e,`#add-session-name`,`input`),f=H(e,`#add-session-path`,`input`),p=bd(e,`#add-session-path-label`),m=H(e,`#add-session-skip-perms`,`input`),h=bd(e,`#add-session-error`),g=H(e,`#add-session-cancel`,`button`),_=H(e,`#add-session-confirm`,`button`),v=!1;function y(e){v=e,a.setAttribute(`aria-pressed`,String(!e)),o.setAttribute(`aria-pressed`,String(e)),r.hidden=e,i.hidden=!e,l.hidden=e,l.setAttribute(`aria-expanded`,String(e)),u.hidden=!e,p.hidden=e,e&&requestAnimationFrame(()=>d.focus())}a.addEventListener(`click`,()=>y(!1)),o.addEventListener(`click`,()=>y(!0)),l.setAttribute(`aria-expanded`,`false`),l.addEventListener(`click`,()=>{let e=u.hidden;u.hidden=!e,l.setAttribute(`aria-expanded`,String(e)),e&&requestAnimationFrame(()=>d.focus())}),dd(`scan-repo-roots`,{}).then(e=>{n.textContent=``,n.appendChild(CN(`-- Select a project --`,{value:``,disabled:!0,selected:!0}));let t=!1,r=e.type===`repo-roots-scanned`?e.directories:[];for(let e of r){if(e.projects.length===0)continue;let r=V(`optgroup`);r.label=e.root;for(let n of e.projects){let e=_N(n.name),a=e>0?`${n.name} (${e} open)`:n.name;r.appendChild(CN(a,{value:JSON.stringify({name:n.name,path:n.path})}));let o=V(`label`,`dialog-checkbox-label`),s=V(`input`);s.type=`checkbox`,s.className=`dialog-checkbox`,s.value=n.path,o.append(s,V(`span`,null,n.name)),i.appendChild(o),t=!0}n.appendChild(r)}t||(n.textContent=``,n.appendChild(CN(`No projects found (configure repo roots in Settings)`,{disabled:!0,selected:!0})),i.textContent=`No projects found (configure repo roots in Settings).`)}).catch(()=>{n.textContent=``,n.appendChild(CN(`Scan failed`,{disabled:!0,selected:!0})),i.textContent=`Repository scan failed.`}),n.addEventListener(`change`,()=>{try{let e=JSON.parse(n.value);d.value=vN(e.name),f.value=e.path}catch{}});let b=sN,x=!1;function ee(e){x=!0,_.disabled=!0;let t=V(`p`,`dialog-hint dialog-hint-warning`,e);t.id=`add-session-agent-guidance`,t.setAttribute(`role`,`status`),h.before(t)}dd(`list-agents`,{}).then(e=>{let t=fN(e);t.canSpawn||ee(t.guidance);let n=uN(e.type===`agents-listed`?e.agents:[]);if(b=n.selectedId,n.show){c.textContent=``;for(let e of n.options)c.appendChild(CN(e.label,{value:e.id,selected:e.id===n.selectedId}));s.hidden=!1}}).catch(()=>{}),c.addEventListener(`change`,()=>{b=c.value});let te=!1;m.addEventListener(`change`,()=>{te=!0}),dd(`get-settings`,{}).then(e=>{te||(m.checked=wN(e.settings))}).catch(()=>{}),d.addEventListener(`input`,()=>{n.selectedIndex=0}),f.addEventListener(`input`,()=>{n.selectedIndex=0});function ne(){if(x)return;let e=d.value.trim(),n=f.value.trim();if(v){let n=[...i.querySelectorAll(`input:checked`)].map(e=>e.value);if(!e||n.length<2){h.textContent=`Enter a name and select at least two repositories.`;return}let r={type:`add-session`,name:vN(e),path:n[0],repos:n,dangerouslySkipPermissions:m.checked};b&&b!==`claude-code`&&(r.agent=b),B(r),t();return}if(!e||!n){h.textContent=`Both fields are required. Select a project or use Advanced options.`;return}let r={type:`add-session`,name:vN(e),path:n,dangerouslySkipPermissions:m.checked};b&&b!==`claude-code`&&(r.agent=b),B(r),t()}g.addEventListener(`click`,t),_.addEventListener(`click`,ne),d.addEventListener(`keydown`,e=>{e.key===`Enter`&&(v&&ne(),v||f.focus())}),f.addEventListener(`keydown`,e=>{e.key===`Enter`&&ne()}),requestAnimationFrame(()=>n.focus())}function EN({issueId:e,issueTitle:t,format:n,content:r,message:i,error:a}){let{dialog:o,close:s,actions:c,btnCancel:l}=rf({title:`Investigation report`,dialogClass:`dialog dialog-report`,cancelLabel:`Close`}),u=V(`div`,`dialog-report-meta`,t||e||``),d=null;if(n===`html`&&!a&&!i){let e=V(`iframe`,`dialog-report-frame`);e.setAttribute(`sandbox`,``),e.srcdoc=r||``,d=e}d||=V(`pre`,a?`dialog-report-body dialog-report-error`:`dialog-report-body`,a||i||r||``),o.append(u,d,c),l.addEventListener(`click`,s),requestAnimationFrame(()=>l.focus())}function DN({issueTitle:e,projectLabel:t,onOpenReport:n}){let{dialog:r,close:i,actions:a,btnCancel:o}=rf({title:`Investigation`,dialogClass:`dialog dialog-report`,cancelLabel:`Close`}),s=V(`div`,`dialog-report-meta`,t?`${t}: ${e}`:e),c=V(`p`,`dialog-trail-status`),l=V(`p`,`dialog-trail-summary`),u=V(`ol`,`dialog-trail-steps`),d=V(`p`,`dialog-trail-empty`,`No tool calls yet; the session is reading the issue.`),f=V(`button`,`btn-dialog btn-dialog-cancel`,`Open report`);f.type=`button`,f.hidden=!0,f.addEventListener(`click`,()=>{i(),n()}),a.prepend(f),r.append(s,c,l,u,d,a),o.addEventListener(`click`,i),requestAnimationFrame(()=>o.focus());let p=null,m=``;function h(e){let t=u.scrollHeight-u.scrollTop-u.clientHeight<24,n=sD(e);if(m!==n){u.textContent=``;for(let t of e.steps){let n=V(`li`,`dialog-trail-step`);n.append(V(`span`,`dialog-trail-at`,oD(e.startedAt,t.at)),V(`span`,`dialog-trail-tool`,t.tool),V(`span`,`dialog-trail-detail`,t.detail)),u.append(n)}m=n}d.hidden=e.steps.length>0||!e.inFlight,u.hidden=e.steps.length===0,t&&(u.scrollTop=u.scrollHeight)}function g(e){c.textContent=cD(e,bN(e.startedAt))}function _(){p&&(g(p),c.dataset.tone=p.inFlight?`live`:`done`,l.textContent=p.summaryLine,l.hidden=!p.summaryLine,f.hidden=p.inFlight||!p.verdict,h(p))}let v=Cf(()=>{if(!r.isConnected){v();return}p?.inFlight&&g(p)});return{update(e){p=e,_()},isOpen:()=>r.isConnected,close:()=>{v(),i()}}}function ON(e){return{prs:e?.teamReview?.enabled===!0,radar:e?.posthog?.enabled===!0,visions:e?.visions?.enabled===!0,usage:e?.usage?.enabled!==!1,benchmarks:e?.benchmarks?.enabled===!0,calm:e?.calmLayout===!0}}var kN=Object.freeze({idle:`#c084fc`,complete:`#4ade80`,waiting:`#fbbf24`});function AN(e){let t=Array.isArray(e)?e:[];for(let e of t)if(VO({state:e?.state}))return`waiting`;for(let e of t)if(e?.state===`COMPLETE`)return`complete`;return`idle`}function jN(e){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="6" fill="#0a0810"/><rect x="1" y="1" width="30" height="30" rx="5" fill="none" stroke="#2a2440" stroke-width="1"/><path d="M10 8 L22 16 L10 24Z" fill="${kN[e]||kN.idle}"/>${e===`complete`?`<circle cx="25" cy="7" r="3" fill="#4ade80"/>`:``}</svg>`}function MN(){let e=document.querySelector(`link[rel="icon"]`);if(e instanceof HTMLLinkElement)return e;let t=document.createElement(`link`);return t.rel=`icon`,t.type=`image/svg+xml`,document.head.append(t),t}var NN=MN(),PN=`idle`;function FN(e){let t=AN([...e.values()].map(({currentState:e})=>({state:e})));t!==PN&&(PN=t,NN.href=`data:image/svg+xml,${encodeURIComponent(jN(t))}`)}function IN(e,t){return Number.isFinite(e)?Math.round(Math.min(t.maxPx,Math.max(t.minPx,e))):null}function LN(e,t){return e===`ArrowRight`?t:e===`ArrowLeft`?-t:null}function RN({resizer:e,column:t,widthHost:n,widthProperty:r,bounds:i,keyStepPx:a,getStoredWidth:o,setStoredWidth:s}){e.setAttribute(`aria-valuemin`,String(i.minPx)),e.setAttribute(`aria-valuemax`,String(i.maxPx));let c=t=>{let a=IN(t,i);return a===null?null:(n.style.setProperty(r,`${a}px`),e.setAttribute(`aria-valuenow`,String(a)),a)},l=o();l!==null&&c(l);let u=0,d=0;e.addEventListener(`pointerdown`,n=>{n.button===0&&(u=n.clientX,d=t.getBoundingClientRect().width,e.setPointerCapture(n.pointerId),e.dataset.dragging=`true`,n.preventDefault())}),e.addEventListener(`pointermove`,t=>{e.hasPointerCapture(t.pointerId)&&c(d+(t.clientX-u))});let f=t=>{e.releasePointerCapture(t.pointerId),delete e.dataset.dragging};e.addEventListener(`pointerup`,t=>{e.hasPointerCapture(t.pointerId)&&(f(t),s(c(d+(t.clientX-u))))}),e.addEventListener(`pointercancel`,t=>{e.hasPointerCapture(t.pointerId)&&(f(t),c(d))}),e.addEventListener(`dblclick`,()=>{n.style.removeProperty(r),e.setAttribute(`aria-valuenow`,String(Math.round(t.getBoundingClientRect().width))),s(null)}),e.addEventListener(`keydown`,e=>{let n=LN(e.key,a);if(n===null)return;e.preventDefault();let r=c(t.getBoundingClientRect().width+n);r!==null&&s(r)})}var zN=Object.freeze({min:0,exclusiveMin:!0,label:`a positive number`}),BN=Object.freeze({min:0,label:`zero or more`}),VN=Object.freeze({min:0,max:300}),HN=Object.freeze({min:1,max:60}),UN=Object.freeze({min:.5,max:2}),WN=Object.freeze({min:64,max:16384}),GN=zN,KN=zN,qN=zN,JN=BN,YN=zN,XN=zN,ZN=zN,QN=zN,$N=zN,eP=zN,tP=zN,nP=Object.freeze({min:60,max:21600,label:`between 60 and 21600`}),rP=Object.freeze({min:1,label:`at least 1`}),iP=Object.freeze({min:1,label:`at least 1`}),aP=BN,oP=Object.freeze({min:1,max:30,label:`between 1 and 30`}),sP=Object.freeze({min:1,max:1440}),cP=Object.freeze({min:1,max:3650}),lP=Object.freeze({min:30,max:3650}),uP=Object.freeze({min:1,max:24}),dP=zN;Object.freeze({scanIntervalMinutes:sP,retainDays:cP,warehouseRetainDays:lP,sessionBlockHours:uP});var fP=Object.freeze({min:15,max:600}),pP=Object.freeze({min:5,max:120}),mP=Object.freeze({min:1,max:5}),hP=Object.freeze({min:1,max:50}),gP=Object.freeze({FLYING_ANIMALS_GAP_RANGE:VN,FLYING_ANIMALS_DURATION_RANGE:HN,FLYING_ANIMALS_SCALE_RANGE:UN,CHANGE_MAP_NARRATOR_TIMEOUT_RANGE:fP,KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE:pP,POSTHOG_ESCALATION_RANGE:tP,POSTHOG_FIX_TIMEOUT_RANGE:nP,POSTHOG_INTERVAL_RANGE:ZN,POSTHOG_INVESTIGATION_TIMEOUT_RANGE:$N,POSTHOG_MAX_CONCURRENT_RANGE:QN,POSTHOG_MIN_USERS_RANGE:eP,POSTHOG_TRAFFIC_BASELINE_RANGE:oP,POSTHOG_TRAFFIC_COOLDOWN_RANGE:aP,POSTHOG_TRAFFIC_MIN_USERS_RANGE:iP,POSTHOG_TRAFFIC_MULTIPLIER_RANGE:rP,REPLAY_BUFFER_KB_RANGE:WN,USAGE_BUDGET_RANGE:dP,USAGE_RETAIN_DAYS_RANGE:cP,USAGE_SCAN_INTERVAL_RANGE:sP,VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE:JN,VISIONS_COOLDOWN_MS_RANGE:KN,VISIONS_DISPATCH_TIMEOUT_RANGE:YN,VISIONS_INTENT_THREAD_TTL_MS_RANGE:XN,VISIONS_MAX_PER_HOUR_RANGE:qN,VISIONS_QUIET_MS_RANGE:GN,WORKFLOWS_MAX_ACTIONS_PER_POLL_RANGE:hP,WORKFLOWS_MAX_CONCURRENT_SESSIONS_RANGE:mP}),_P=[{name:`Nyan cat`,sprite:`is-cat`,trail:`is-rainbow`},{name:`Unicorn`,sprite:`is-unicorn`,trail:`is-sparkles`},{name:`Dragon`,sprite:`is-dragon`,trail:`is-embers`},{name:`Pig`,sprite:`is-pig`,trail:`is-hearts`},{name:`Whale`,sprite:`is-whale`,trail:`is-bubbles`},{name:`Fox`,sprite:`is-fox`,trail:`is-paws`},{name:`Frog`,sprite:`is-frog`,trail:`is-dust`},{name:`Penguin`,sprite:`is-penguin`,trail:`is-snow`},{name:`Bee`,sprite:`is-bee`,trail:`is-honey`},{name:`Owl`,sprite:`is-owl`,trail:`is-stars`},{name:`Cow`,sprite:`is-cow`,trail:`is-daisies`},{name:`Panda`,sprite:`is-panda`,trail:`is-bamboo`},{name:`Red panda`,sprite:`is-red-panda`,trail:`is-leaves`},{name:`Deer`,sprite:`is-deer`,trail:`is-acorns`},{name:`Horse`,sprite:`is-horse`,trail:`is-clover`},{name:`Sheep`,sprite:`is-sheep`,trail:`is-clouds`},{name:`Hamster`,sprite:`is-hamster`,trail:`is-seeds`},{name:`Giraffe`,sprite:`is-giraffe`,trail:`is-acacia`},{name:`Hedgehog`,sprite:`is-hedgehog`,trail:`is-logomarks`}],vP=Object.freeze({flyingAnimalsMinGapSeconds:20,flyingAnimalsMaxGapSeconds:40,flyingAnimalsMinDurationSeconds:6.9,flyingAnimalsMaxDurationSeconds:11.5,flyingAnimalsScale:1,flyingAnimalsOnPhone:!0});function yP(e,t,n){return typeof e!=`number`||!Number.isFinite(e)?t:Math.min(n.max,Math.max(n.min,e))}function bP(e){if(!Array.isArray(e))return[];let t=new Set(_P.map(e=>e.sprite));return[...new Set(e.filter(e=>typeof e==`string`&&t.has(e)))]}function xP(e={}){let t=vP,n=VN,r=HN,i=yP(e.flyingAnimalsMinGapSeconds,t.flyingAnimalsMinGapSeconds,n),a=yP(e.flyingAnimalsMaxGapSeconds,t.flyingAnimalsMaxGapSeconds,n),o=yP(e.flyingAnimalsMinDurationSeconds,t.flyingAnimalsMinDurationSeconds,r),s=yP(e.flyingAnimalsMaxDurationSeconds,t.flyingAnimalsMaxDurationSeconds,r);return{flyingAnimalsMinGapSeconds:Math.min(i,a),flyingAnimalsMaxGapSeconds:Math.max(i,a),flyingAnimalsMinDurationSeconds:Math.min(o,s),flyingAnimalsMaxDurationSeconds:Math.max(o,s),flyingAnimalsScale:yP(e.flyingAnimalsScale,t.flyingAnimalsScale,UN),flyingAnimalsOnPhone:typeof e.flyingAnimalsOnPhone==`boolean`?e.flyingAnimalsOnPhone:t.flyingAnimalsOnPhone,flyingAnimalsExcludedSprites:bP(e.flyingAnimalsExcludedSprites)}}function SP(e){return _P.some(t=>!e.includes(t.sprite))}function CP(e,t=-1,n=Math.random){let r=_P.flatMap((t,n)=>e.includes(t.sprite)?[]:[n]);if(r.length===0)return null;let i=r.length>1?r.filter(e=>e!==t):r,a=Math.min(1,Math.max(0,n()));return i[Math.min(i.length-1,Math.floor(a*i.length))]}function wP(e,t,n=Math.random,r){let i=r===void 0?CP(e.flyingAnimalsExcludedSprites,t,n):_P.findIndex(e=>e.sprite===r);if(i===null||i<0)return null;let a=e.flyingAnimalsMinDurationSeconds+n()*(e.flyingAnimalsMaxDurationSeconds-e.flyingAnimalsMinDurationSeconds);return{animalIndex:i,durationSeconds:a,gapMs:1e3*(e.flyingAnimalsMinGapSeconds+n()*(e.flyingAnimalsMaxGapSeconds-e.flyingAnimalsMinGapSeconds)),firstDelaySeconds:n()*a,verticalProgress:n()}}function TP({isEnabled:e,hasReducedMotion:t,isPhone:n,options:r}){return t?`Flights are disabled because reduced motion is enabled.`:e?n&&!r.flyingAnimalsOnPhone?`Turn on Show on phone layout to use Fly now here.`:null:`Turn on flying animals to use Fly now.`}function EP(e,t){try{let n=localStorage.getItem(e);return n===null?t:JSON.parse(n)}catch{return t}}function DP(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}var OP=`glimmervoid-ui-prefs`,kP=`glimmervoid:sidebar-width`,AP=e=>t=>typeof t==`boolean`?t:e,jP=e=>t=>typeof t==`string`?t:e,MP=e=>typeof e==`string`&&e?e:null,NP=e=>typeof e==`number`&&Number.isFinite(e)?e:null,PP=e=>t=>NP(t)??e,FP=e=>Array.isArray(e)?[...new Set(e.filter(e=>typeof e==`string`&&e!==``))]:[],IP={soundEnabled:AP(!0),soundId:jP(ab),themeId:jP(`phyrexian`),flyingAnimalsEnabled:AP(!1),flyingAnimalsMinGapSeconds:PP(vP.flyingAnimalsMinGapSeconds),flyingAnimalsMaxGapSeconds:PP(vP.flyingAnimalsMaxGapSeconds),flyingAnimalsMinDurationSeconds:PP(vP.flyingAnimalsMinDurationSeconds),flyingAnimalsMaxDurationSeconds:PP(vP.flyingAnimalsMaxDurationSeconds),flyingAnimalsScale:PP(vP.flyingAnimalsScale),flyingAnimalsOnPhone:AP(vP.flyingAnimalsOnPhone),flyingAnimalsExcludedSprites:bP,notificationsEnabled:AP(!0),compactStatusLabels:AP(!1),sessionUsageChips:AP(!1),activeView:jP(`focus`),lastFocusedSessionId:MP,railWidth:NP,reviewSidebarExpanded:AP(!1),reviewSidebarView:e=>e===`map`||e===`notes`?e:`diff`,prsQueueWidth:NP,prsQueueCollapsed:AP(!1),prsMode:e=>e===`mine`?`mine`:`team`,keptProjects:FP,traceHiddenKinds:FP,dismissedUpdate:MP,telemetryNoticeDismissed:AP(!1),radarAttentionAck:jP(``),prsAttentionAck:jP(``),usageAttentionAck:jP(``),visionsAttentionAck:jP(``)};function LP(e,t,n){e[t]=IP[t](n)}function RP(){let e=EP(OP,{}),t={};for(let n of Object.keys(IP))LP(t,n,e?.[n]);return t}function zP(e){return RP()[e]}function BP(e,t){let n=RP();LP(n,e,t),DP(OP,n)}var VP=()=>zP(`soundEnabled`),HP=e=>BP(`soundEnabled`,e),UP=()=>zP(`soundId`),WP=e=>BP(`soundId`,e),GP=()=>zP(`notificationsEnabled`),KP=e=>BP(`notificationsEnabled`,e),qP=()=>zP(`compactStatusLabels`),JP=e=>BP(`compactStatusLabels`,e),YP=()=>zP(`sessionUsageChips`),XP=e=>BP(`sessionUsageChips`,e),ZP=()=>zP(`themeId`),QP=e=>BP(`themeId`,e),$P=()=>zP(`flyingAnimalsEnabled`),eF=e=>BP(`flyingAnimalsEnabled`,e),tF=()=>zP(`activeView`),nF=e=>BP(`activeView`,e),rF=()=>zP(`railWidth`),iF=e=>BP(`railWidth`,e),aF=()=>zP(`reviewSidebarExpanded`),oF=e=>BP(`reviewSidebarExpanded`,e),sF=()=>zP(`reviewSidebarView`),cF=e=>BP(`reviewSidebarView`,e),lF=()=>zP(`prsQueueWidth`),uF=e=>BP(`prsQueueWidth`,e),dF=()=>zP(`prsQueueCollapsed`),fF=e=>BP(`prsQueueCollapsed`,e),pF=()=>zP(`prsMode`),mF=e=>BP(`prsMode`,e),hF=()=>zP(`keptProjects`),gF=e=>BP(`keptProjects`,e),_F=()=>zP(`traceHiddenKinds`),vF=e=>BP(`traceHiddenKinds`,e),yF=()=>zP(`dismissedUpdate`),bF=e=>BP(`dismissedUpdate`,e),xF=()=>zP(`telemetryNoticeDismissed`),SF=e=>BP(`telemetryNoticeDismissed`,e),CF=()=>zP(`radarAttentionAck`),wF=e=>BP(`radarAttentionAck`,e),TF=()=>zP(`prsAttentionAck`),EF=e=>BP(`prsAttentionAck`,e),DF=()=>zP(`usageAttentionAck`),OF=e=>BP(`usageAttentionAck`,e),kF=()=>zP(`visionsAttentionAck`),AF=e=>BP(`visionsAttentionAck`,e),jF=()=>zP(`lastFocusedSessionId`),MF=e=>BP(`lastFocusedSessionId`,e),NF=()=>NP(EP(kP,null)),PF=e=>DP(kP,NP(e)),FF=e=>BP(`flyingAnimalsMinGapSeconds`,e),IF=e=>BP(`flyingAnimalsMaxGapSeconds`,e),LF=e=>BP(`flyingAnimalsMinDurationSeconds`,e),RF=e=>BP(`flyingAnimalsMaxDurationSeconds`,e),zF=e=>BP(`flyingAnimalsScale`,e),BF=e=>BP(`flyingAnimalsOnPhone`,e),VF=e=>BP(`flyingAnimalsExcludedSprites`,e),HF=()=>xP(RP()),UF=()=>{let e=RP();return Object.fromEntries(Object.keys(vP).map(t=>[t,e[t]]))},WF=()=>DP(OP,{...RP(),...vP}),GF=new Set(hF());function KF(){gF([...GF])}function qF(e){if(!e)return;let t=String(e);GF.has(t)||(GF.add(t),KF())}function JF(e,t){let n=new Set;for(let r of e||[]){let e=t(r);if(!e)continue;let i=String(e);n.add(i),qF(i)}return[...GF].filter(e=>!n.has(e))}function YF(e){return!e||!GF.delete(String(e))?!1:(KF(),!0)}function XF(e,t){e&&B({type:`add-session`,name:vN(t),path:e})}function ZF(e,t){let n=U.get(e);if(!n)return;let r=t||n.card?.dataset.merge||`none`;if(r!==`pending-review`&&r!==`parked`){B({type:`remove-session`,id:e});return}af({title:`Remove Session`,message:`"${Xd(n)}" has unmerged worktree changes that will be permanently discarded if you remove it. Merge or review them first to keep them. Remove anyway?`,confirmLabel:`Discard & Remove`,onConfirm:()=>B({type:`remove-session`,id:e})})}function QF(e){if(!e)return 0;let t=0;return e.listenerMismatch&&t++,e.orphanPty&&t++,e.destroyedReachable&&t++,t}function $F(e,t){return e||QF(t)>0}var eI={DORMANT:`DOR`,INITIALIZING:`INI`,STARTING:`STA`,RUNNING:`RUN`,WAITING:`WAI`,IDLE:`IDL`,COMPLETE:`CMP`,DONE:`DON`,FAILED:`FAI`},tI=null,nI=!1,rI=!1,iI=null,aI=null,oI=null,sI=`—`;function cI(e){return e==null?sI:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(2)} GB`}function lI(e){return e==null?sI:e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function uI(){let e=V(`div`,`health-footer`);e.dataset.expanded=`false`,e.hidden=!0;let t=V(`button`,`health-summary`);t.type=`button`,t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,`health-detail`);let n=V(`div`,`health-detail`);return n.id=`health-detail`,n.hidden=!0,t.addEventListener(`click`,()=>{rI=!rI,e.dataset.expanded=String(rI),t.setAttribute(`aria-expanded`,String(rI)),n.hidden=!rI,rI&&(B({type:`request-health-snapshot`}),fI())}),e.append(t,n),iI=e,aI=t,oI=n,e}function dI(){if(!aI||!tI)return;let e=tI,t=QF(e.anomalies);aI.innerHTML=`
|
|
174
|
-
<span class="health-chev" aria-hidden="true">${rI?`▼`:`▲`}</span>
|
|
175
|
-
<span class="health-stat" title="V8 heap used"><span class="health-stat-label">Heap</span> ${cI(e.process.heapUsed)}</span>
|
|
176
|
-
<span class="health-stat" title="Resident set size (process memory)"><span class="health-stat-label">RSS</span> ${cI(e.process.rss)}</span>
|
|
177
|
-
<span class="health-stat" title="External buffers (PTY data lives here)"><span class="health-stat-label">Ext</span> ${cI(e.process.external)}</span>
|
|
178
|
-
<span class="health-stat" title="Active resources (handles + requests)"><span class="health-stat-label">Hdl</span> ${e.process.activeResources}</span>
|
|
179
|
-
<span class="health-stat" title="Sessions: alivePty / sleeping / total"><span class="health-stat-label">Sess</span> ${e.sessions.alivePty}/${e.sessions.sleeping}/${e.sessions.total}</span>
|
|
180
|
-
<span class="health-stat" title="WebSockets: control + data"><span class="health-stat-label">WS</span> ${e.websockets.control}+${e.websockets.data}</span>
|
|
181
|
-
<span class="health-stat" title="Server uptime"><span class="health-stat-label">Up</span> ${lI(e.uptimeSeconds)}</span>
|
|
182
|
-
${t>0?`<span class="health-anomaly" title="${t} anomaly type(s), expand for details">⚠ ${t}</span>`:``}
|
|
183
|
-
`}function fI(){if(!oI||!tI)return;let e=tI,t=e.process,n=e.websockets,r=e.sessions,i=e.anomalies,a=``;if(QF(i)>0){let e=[];i.listenerMismatch&&e.push(`Listener count mismatch: data WS listener leaked or missing`),i.orphanPty&&e.push(`Orphan PTY: session has live PTY but state is DONE/FAILED/DORMANT`),i.destroyedReachable&&e.push(`Destroyed session still reachable in sessions map`),a=`
|
|
184
|
-
<div class="health-section health-section-warn">
|
|
185
|
-
<div class="health-section-title">⚠ Anomalies</div>
|
|
186
|
-
${e.map(e=>`<div class="health-row">${e}</div>`).join(``)}
|
|
187
|
-
</div>
|
|
188
|
-
`}let o=r.list.map(e=>{let t=[];e.sleeping&&t.push(`sleeping`),e.autoKilled&&t.push(`autoKilled`),e.destroyed&&t.push(`destroyed`),e.pendingRestart&&t.push(`pendingRestart`);let n=Object.entries(e.timers).filter(([,e])=>e).map(([e])=>e).join(`,`)||`none`;return`
|
|
189
|
-
<tr>
|
|
190
|
-
<td>${Nd(e.name)}</td>
|
|
191
|
-
<td class="health-mono">${eI[e.state]||e.state}</td>
|
|
192
|
-
<td class="health-mono">${e.hasPty?e.ptyPid:sI}</td>
|
|
193
|
-
<td class="health-mono">${cI(e.outputBufferBytes)}</td>
|
|
194
|
-
<td class="health-mono">${e.outputBufferEntries}</td>
|
|
195
|
-
<td class="health-mono">${e.dataListenerCount}</td>
|
|
196
|
-
<td class="health-mono health-dim">${n}</td>
|
|
197
|
-
<td class="health-mono health-dim">${t.join(` `)||``}</td>
|
|
198
|
-
</tr>
|
|
199
|
-
`}).join(``);oI.innerHTML=`
|
|
200
|
-
${a}
|
|
201
|
-
<div class="health-section">
|
|
202
|
-
<div class="health-section-title">Process</div>
|
|
203
|
-
<div class="health-grid">
|
|
204
|
-
<div class="health-row"><span class="health-label">Heap used</span><span class="health-mono">${cI(t.heapUsed)}</span></div>
|
|
205
|
-
<div class="health-row"><span class="health-label">Heap total</span><span class="health-mono">${cI(t.heapTotal)}</span></div>
|
|
206
|
-
<div class="health-row"><span class="health-label">RSS</span><span class="health-mono">${cI(t.rss)}</span></div>
|
|
207
|
-
<div class="health-row"><span class="health-label">External</span><span class="health-mono">${cI(t.external)}</span></div>
|
|
208
|
-
<div class="health-row"><span class="health-label">Array buffers</span><span class="health-mono">${cI(t.arrayBuffers)}</span></div>
|
|
209
|
-
<div class="health-row"><span class="health-label">Active resources</span><span class="health-mono">${t.activeResources}</span></div>
|
|
210
|
-
<div class="health-row"><span class="health-label">Uptime</span><span class="health-mono">${lI(e.uptimeSeconds)}</span></div>
|
|
211
|
-
</div>
|
|
212
|
-
</div>
|
|
213
|
-
|
|
214
|
-
<div class="health-section">
|
|
215
|
-
<div class="health-section-title">WebSockets</div>
|
|
216
|
-
<div class="health-grid">
|
|
217
|
-
<div class="health-row"><span class="health-label">Control clients</span><span class="health-mono">${n.control}</span></div>
|
|
218
|
-
<div class="health-row"><span class="health-label">Data clients</span><span class="health-mono">${n.data}</span></div>
|
|
219
|
-
<div class="health-row"><span class="health-label">Tracked per session</span><span class="health-mono">${n.dataPerSessionTotal}</span></div>
|
|
220
|
-
</div>
|
|
221
|
-
</div>
|
|
222
|
-
|
|
223
|
-
<div class="health-section">
|
|
224
|
-
<div class="health-section-title">Sessions (${r.total} total · ${r.alivePty} alive PTY · ${r.sleeping} sleeping)</div>
|
|
225
|
-
<div class="health-row health-dim">Listeners ${r.totalDataListeners} · Output buffer ${cI(r.totalOutputBufferBytes)}</div>
|
|
226
|
-
<table class="health-table">
|
|
227
|
-
<thead>
|
|
228
|
-
<tr>
|
|
229
|
-
<th>Name</th><th>State</th><th>PID</th><th>Buffer</th><th>Entries</th><th>Listeners</th><th>Timers</th><th>Flags</th>
|
|
230
|
-
</tr>
|
|
231
|
-
</thead>
|
|
232
|
-
<tbody>${o||`<tr><td colspan="8" class="health-dim">No sessions</td></tr>`}</tbody>
|
|
233
|
-
</table>
|
|
234
|
-
</div>
|
|
235
|
-
`}function pI(){if(!iI)return;let e=$F(nI,tI?.anomalies),t=iI.hidden;iI.hidden=!e,e&&t&&tI&&(dI(),rI&&fI())}function mI(e){nI=e,pI()}function hI(e){if(iI)return iI;let t=uI();return e.appendChild(t),pI(),t}function gI(e){tI=e,pI(),iI&&!iI.hidden&&(dI(),rI&&fI())}function _I(e){return e.replace(/\r\n?/g,`
|
|
236
|
-
`).split(`
|
|
237
|
-
`)}function vI(e){return{kind:`unchanged`,text:e}}function yI(e){return{kind:`skipped`,text:`${e} unchanged lines`}}function bI(e,t){return e.length<=7?e.map(t):[...e.slice(0,3).map(t),yI(e.length-6),...e.slice(e.length-3).map(t)]}function xI(e){return e}function SI(e){let t=[],n=0;for(;n<e.length;){if(e[n].kind!==`unchanged`){t.push(e[n]),n++;continue}let r=n;for(;r<e.length&&e[r].kind===`unchanged`;)r++;t.push(...bI(e.slice(n,r),xI)),n=r}return t}function CI(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;return r}function wI(e,t,n){let r=Math.min(e.length,t.length)-n,i=0;for(;i<r&&e[e.length-1-i]===t[t.length-1-i];)i++;return i}function TI(e,t){let n=e.length,r=t.length;if(n===0)return t.map(e=>({kind:`added`,text:e}));if(r===0)return e.map(e=>({kind:`removed`,text:e}));let i=r+1,a=new Int32Array((n+1)*i);for(let o=n-1;o>=0;o--)for(let n=r-1;n>=0;n--){let r=o*i+n;if(e[o]===t[n]){a[r]=a[r+i+1]+1;continue}a[r]=Math.max(a[r+i],a[r+1])}let o=[],s=0,c=0;for(;s<n&&c<r;){if(e[s]===t[c]){o.push(vI(e[s])),s++,c++;continue}if(a[(s+1)*i+c]>=a[s*i+c+1]){o.push({kind:`removed`,text:e[s]}),s++;continue}o.push({kind:`added`,text:t[c]}),c++}for(;s<n;)o.push({kind:`removed`,text:e[s]}),s++;for(;c<r;)o.push({kind:`added`,text:t[c]}),c++;return o}function EI(e,t){let n=_I(e),r=_I(t),i=CI(n,r),a=wI(n,r,i),o=n.slice(i,n.length-a),s=r.slice(i,r.length-a);return o.length+s.length>2e3?{lines:[],isTooLarge:!0}:{lines:SI([...bI(n.slice(0,i),vI),...TI(o,s),...bI(n.slice(n.length-a),vI)]),isTooLarge:!1}}var DI=2,OI=8,kI=4096,AI=/^ {0,3}(#{1,6})[ \t]+(.*)$/,jI=/^ {0,3}(`{3,}|~{3,})([^`]*)$/,MI=/^(\s*)(?:([-+*])|(\d+)[.)])\s+(.+)$/,NI=/^ {0,3}(?:(?:\*\s*){3,}|(?:-\s*){3,}|(?:_\s*){3,})$/,PI=/^:?-{3,}:?$/,FI=/^[A-Za-z0-9_+#.-]{1,32}$/;function II(e){let t=e.trimEnd(),n=t.length;for(;n>0&&t[n-1]===`#`;)n--;if(n===t.length||n===0)return t;let r=t[n-1];return r!==` `&&r!==` `?t:t.slice(0,n).trimEnd()}function LI(e){if(e.length>kI)return null;let t=AI.exec(e);return t?{level:t[1].length,text:II(t[2])}:null}function RI(e){let t=e.trim().split(/\s+/)[0]??``;return FI.test(t)?t:``}function zI(e,t){if(!t)return;let n=e.at(-1);if(n?.type===`text`){n.text+=t;return}e.push({type:`text`,text:t})}function BI(e,t){return e.startsWith(`**`,t)?`**`:e.startsWith(`__`,t)?`__`:null}function VI(e,t){return e.startsWith(`*`,t)?`*`:e.startsWith(`_`,t)?`_`:null}function HI(e,t,n){let r=e.indexOf(t,n);return r>n?r:-1}function UI(e,t){let n=e.indexOf(t);return function(r){return n===-1?-1:(n>=r||(n=e.indexOf(t,r)),n)}}function WI(e,t){let n=1;for(let r=t;r<e.length;r++){let t=e[r];if(t===`(`&&n++,t===`)`&&n--,n===0)return r;if(n>DI)return-1}return-1}function GI(e,t,n){if(e[t]!==`[`)return null;let r=n(t+1);if(r<=t+1||e[r+1]!==`(`)return null;let i=WI(e,r+2);return i===-1?null:{label:e.slice(t+1,r),target:e.slice(r+2,i),end:i+1}}function KI(e){let t=[],n=UI(e,`]`),r=0;for(;r<e.length;){let i=GI(e,r,n);if(i){let e=cx(i.target.trim());e&&t.push({type:`link`,href:e,children:KI(i.label)}),e||zI(t,i.label),r=i.end;continue}if(e.startsWith("`",r)){let n=HI(e,"`",r+1);if(n!==-1){t.push({type:`code`,text:e.slice(r+1,n)}),r=n+1;continue}}let a=BI(e,r);if(a){let n=HI(e,a,r+a.length);if(n!==-1){t.push({type:`strong`,children:KI(e.slice(r+a.length,n))}),r=n+a.length;continue}}let o=VI(e,r);if(o){let n=HI(e,o,r+1);if(n!==-1){t.push({type:`emphasis`,children:KI(e.slice(r+1,n))}),r=n+1;continue}}zI(t,e[r]),r++}return t}function qI(e){return e.map(e=>e.type===`text`||e.type===`code`?e.text:qI(e.children)).join(``)}var JI=`plan-h-`;function YI(e,t){let n=e.toLowerCase().normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`section`,r=(t.slugCounts.get(n)??0)+1;return t.slugCounts.set(n,r),`${JI}${r===1?n:`${n}-${r}`}`}function XI(e){if(typeof e!=`string`||!e.includes(`|`))return!1;let t=ZI(e);return t.length<2?!1:t.every(e=>PI.test(e))}function ZI(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function QI(e){let t=MI.exec(e);return t?{indent:t[1].replace(/\t/g,` `).length,ordered:!!t[3],content:t[4]}:null}function $I(e,t,n,r){let i=QI(e[t]);if(!i)return null;let a=[],o=i.ordered,s=i.indent,c=t;for(;c<e.length;){let t=QI(e[c]);if(!t||t.indent<s)break;if(t.indent>s){if(r>=OI)break;let t=$I(e,c,n,r+1);if(!t||a.length===0)break;a.at(-1)?.children.push(t.block),c=t.next;continue}if(t.ordered!==o)break;a.push({children:[{type:`paragraph`,children:KI(t.content)}]}),c++}return{block:{type:`list`,ordered:o,items:a},next:c}}function eL(e,t){let n=e[t]??``;return n.trim()===``||LI(n)||jI.test(n)||NI.test(n)||QI(n)||/^ {0,3}>/.test(n)?!0:t+1<e.length&&n.includes(`|`)&&XI(e[t+1])}function tL(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.trim()===``){i++;continue}let o=jI.exec(a);if(o){let t=[],n=o[1][0],a=o[1].length;for(i++;i<e.length;){let r=/^ {0,3}(`{3,}|~{3,})\s*$/.exec(e[i]);if(r&&r[1][0]===n&&r[1].length>=a)break;t.push(e[i]),i++}i<e.length&&i++,r.push({type:`code`,language:RI(o[2]),text:t.join(`
|
|
238
|
-
`)});continue}let s=LI(a);if(s){let e=KI(s.text);r.push({type:`heading`,level:s.level,id:YI(qI(e),t),children:e}),i++;continue}if(NI.test(a)){r.push({type:`rule`}),i++;continue}if(i+1<e.length&&a.includes(`|`)&&XI(e[i+1])){let t=ZI(a).map(KI),n=[];for(i+=2;i<e.length&&e[i].includes(`|`)&&e[i].trim()!==``;)n.push(ZI(e[i]).map(KI)),i++;r.push({type:`table`,header:t,rows:n});continue}let c=$I(e,i,t,n);if(c){r.push(c.block),i=c.next;continue}if(n<OI&&/^ {0,3}>/.test(a)){let a=[];for(;i<e.length&&/^ {0,3}>/.test(e[i]);)a.push(e[i].replace(/^ {0,3}> ?/,``)),i++;r.push({type:`blockquote`,blocks:tL(a,t,n+1)});continue}let l=[a.trim()];for(i++;i<e.length&&!eL(e,i);)l.push(e[i].trim()),i++;r.push({type:`paragraph`,children:KI(l.join(` `))})}return r}function nL(e){return tL(e.replace(/\r\n?/g,`
|
|
239
|
-
`).split(`
|
|
240
|
-
`),{slugCounts:new Map},0)}function rL(e){let t=[],n={heading:null,id:null,level:0,blocks:[]},r=()=>{(n.heading!==null||n.blocks.length!==0)&&t.push(n)};for(let t of e){if(t.type!==`heading`){n.blocks.push(t);continue}r(),n={heading:qI(t.children),id:t.id,level:t.level,blocks:[t]}}return r(),t}function iL(e,t){for(let n of t){if(n.type===`text`){e.append(document.createTextNode(n.text));continue}if(n.type===`code`){e.append(V(`code`,`plan-inline-code`,n.text));continue}if(n.type===`emphasis`){let t=V(`em`);iL(t,n.children),e.append(t);continue}if(n.type===`strong`){let t=V(`strong`);iL(t,n.children),e.append(t);continue}let t=V(`a`,`plan-link`);t.href=n.href,t.target=`_blank`,t.rel=`noopener noreferrer`,iL(t,n.children),e.append(t)}}function aL(e){let t=V(`li`);return oL(t,e.children),t}function oL(e,t){for(let n of t){if(n.type===`heading`){let t=V(`h${n.level}`,`plan-heading`);t.id=n.id,iL(t,n.children),e.append(t);continue}if(n.type===`paragraph`){let t=V(`p`,`plan-paragraph`);iL(t,n.children),e.append(t);continue}if(n.type===`list`){let t=n.ordered?V(`ol`,`plan-list`):V(`ul`,`plan-list`);t.append(...n.items.map(aL)),e.append(t);continue}if(n.type===`code`){let t=V(`pre`,`plan-code`),r=V(`code`,n.language?`language-${n.language}`:null,n.text);t.append(r),e.append(t);continue}if(n.type===`table`){let t=V(`div`,`plan-table-wrap`),r=V(`table`,`plan-table`),i=V(`thead`),a=V(`tr`);for(let e of n.header){let t=V(`th`);iL(t,e),a.append(t)}i.append(a);let o=V(`tbody`);for(let e of n.rows){let t=V(`tr`);for(let n of e){let e=V(`td`);iL(e,n),t.append(e)}o.append(t)}r.append(i,o),t.append(r),e.append(t);continue}if(n.type===`blockquote`){let t=V(`blockquote`,`plan-blockquote`);oL(t,n.blocks),e.append(t);continue}e.append(V(`hr`,`plan-rule`))}}function sL(e){let t=V(`div`,`plan-document`);return oL(t,e),t}function cL(e,{hasComment:t,isComposing:n,onComment:r,attachmentFor:i}){let a=V(`div`,`plan-document`),o=[];for(let s of e){let e=V(`section`,`plan-section`);e.dataset.selected=`false`,e.addEventListener(`click`,()=>{for(let t of o)t.dataset.selected=String(t===e)}),o.push(e);let c=V(`div`,`plan-section-head`),l=s.blocks[0],u=l?.type===`heading`;if(u&&oL(c,[l]),u||(e.id=`plan-introduction`),!t(s)&&!n(s)){let e=V(`button`,`plan-section-comment`,`Comment`);e.type=`button`,e.setAttribute(`aria-label`,`Comment on ${s.heading??`Introduction`}`),e.addEventListener(`click`,()=>r(s)),c.append(e)}let d=V(`div`,`plan-section-body`);oL(d,u?s.blocks.slice(1):s.blocks),e.append(c,d);let f=i(s);f&&e.append(f),a.append(e)}return a}var lL={added:`+`,removed:`-`,unchanged:` `,skipped:` `};function uL(e){let t=V(`div`,`plan-diff`);for(let n of e.lines){let e=V(`div`,`plan-diff-line plan-diff-${n.kind}`),r=V(`span`,`plan-diff-gutter`,lL[n.kind]);r.setAttribute(`aria-hidden`,`true`),e.append(r,V(`span`,`plan-diff-text`,n.text)),t.append(e)}return t}var dL=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function fL(e){return e===`approve`||e===`approve-accept-edits`}function pL(e){return(e.state===`decided`||e.state===`closed`)&&fL(e.lastDecision)}function mL(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&pL(n)}function hL(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function gL(e){let t=hL(e.state,e.selectedAgentId);return t?e.selectedRevision&&t.revisions.some(t=>t.revision===e.selectedRevision)?e.selectedRevision:t.revisions.at(-1)?.revision??null:null}function _L(e,t){return hL(e,t)?.openRevision?.revision??null}function vL(e,t,n){if(n===null)return null;let r=hL(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function yL(e,t){let n=Math.max(0,t-e);if(!Number.isFinite(n)||n<6e4)return`just now`;let r=Math.floor(n/6e4);if(r<60)return`${r} min ago`;let i=Math.floor(r/60);if(i<24)return`${i} hr ago`;let a=Math.floor(i/24);return`${a} ${a===1?`day`:`days`} ago`}function bL(e,t,n){return t!==null&&t.state===`open`&&t.openRevision!==null&&t.openRevision.revision===n&&e.body!==null&&e.isConnected&&e.isDraft!==!0&&!e.isDecisionInFlight}function xL(e,t,n){let r=bL(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return dL.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function SL(e,t){return e.openRevision===null?t!==null&&e.approvedRevision===t?`Approved`:e.state===`released`?`Answer in the terminal`:e.state===`decided`?e.lastDecision===`revise`?`Feedback sent, waiting for the next revision`:`Approved`:`Closed`:e.openRevision.revision===t?``:`Rev ${e.openRevision.revision} is the one open`}function CL(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function wL(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+Hu}function TL(e){let t=e.plan;if(t!==void 0&&t.length===0)return`the edited plan is empty, so nothing was sent`;if(t!==void 0&&new TextEncoder().encode(t).byteLength>524288)return`the edited plan is over the plan size cap, so nothing was sent`;let n=e.comments??[];return n.length>40?`more than 40 section comments are pending, so nothing was sent`:n.find(e=>e.comment.length>4e3||(e.heading?.length??0)>4e3)?`a section comment is over ${Ys} characters, so nothing was sent`:CL(e)>1e4?`the feedback composes more than the ${Zs} characters the hook reply carries, so nothing was sent`:wL(e)>Uu?`the decision is larger than one control frame carries, so nothing was sent`:null}function EL(e){return e?`, ${e}`:``}function DL(e,t,n){if(!e.isConnected)return`Disconnected`;if(!t||n===null)return`No plan revision selected`;if(e.isDecisionInFlight)return`Sending your decision`;if(e.body===null)return`Loading`;if(e.isDraft===!0)return`Draft`;let r=SL(t,n);if(r)return r;if(e.hasUnsavedComment===!0)return`Save or cancel the open comment first.`;let i=e.pendingCommentCount??0;return i<=0?``:i===1?`1 comment to send. Remove it to approve.`:`${i} comments to send. Remove them to approve.`}function OL(e,t,n){let r=DL(e,t,n);return r?`${r}${EL(e.problem)}`:e.problem??``}function kL(e){let t=hL(e.state,e.selectedAgentId),n=gL(e);return{tabs:e.state.reviews.map(e=>({agentId:e.agentId,label:e.agentId===null?`Main`:e.agentType||`Agent`,selected:e===t})),revisions:(t?.revisions??[]).map(e=>({revision:e.revision,label:`Rev ${e.revision}`,isOpen:e.revision===t?.openRevision?.revision,receivedAt:e.receivedAt,selected:e.revision===n})),selectedAgentId:t?.agentId??null,selectedRevision:n,previousRevision:vL(e.state,t?.agentId??null,n),status:OL(e,t,n),actions:xL(e,t,n),modes:[{kind:`read`,label:`Read`,enabled:!0},{kind:`changes`,label:`Changes`,enabled:vL(e.state,t?.agentId??null,n)!==null&&e.isDraft!==!0},{kind:`edit`,label:`Edit`,enabled:bL(e,t,n)}]}}function AL(e,t){let n=e.reviews.findIndex(e=>e.agentId===t.agentId),r=[...(n===-1?null:e.reviews[n])?.revisions??[]],i=r.findIndex(e=>e.revision===t.revision),a={revision:t.revision,receivedAt:t.receivedAt,chars:t.chars,title:t.title};r[i===-1?r.length:i]=a,r.sort((e,t)=>e.revision-t.revision);let o={agentId:t.agentId,agentType:t.agentType,revisions:r,state:t.state,openRevision:t.state===`open`?{revision:t.revision,since:t.receivedAt}:null,approvedRevision:t.approvedRevision,lastDecision:t.lastDecision},s=[...e.reviews];return s[n===-1?s.length:n]=o,{reviews:s}}function jL({headingOffsets:e,scrollTop:t,isScrolledToEnd:n,readingLineOffset:r}){if(e.length===0)return null;if(n)return e.length-1;let i=t+r,a=0;for(let t=0;t<e.length&&!(e[t]>i);t++)a=t;return a}var ML=12,NL=8,PL=``,FL=48,IL=new Map;function LL(e,t){return JSON.stringify([e,t])}function RL(e){return e.id??PL}function zL(e,t){let n=IL.get(e);n||(n=new Map,IL.set(e,n));let r=LL(t.agentId,t.revision);for(n.delete(r),n.set(r,t.plan);n.size>ML;){let e=n.keys().next().value;if(typeof e!=`string`)break;n.delete(e)}}function BL(e){IL.delete(e)}function VL(e,t,n){return!e||n===null?null:IL.get(e)?.get(LL(t,n))??null}function HL(e){let t=V(`section`,`plan-face`);t.hidden=!0;let n=V(`header`,`plan-head`),r=V(`select`,`plan-heading-picker`);r.setAttribute(`aria-label`,`Plan section`);let i=V(`div`,`plan-view-panel`),a=V(`div`,`plan-sheet-head`),o=V(`button`,`plan-control plan-sheet-close`,`×`);o.type=`button`,o.setAttribute(`aria-label`,`Close`),a.append(V(`span`,null,`View`),o);let s=V(`div`,`plan-view-group plan-author-group`),c=V(`div`,`plan-tabs`);c.setAttribute(`role`,`tablist`),c.setAttribute(`aria-label`,`Plan author`),s.append(V(`span`,`plan-sheet-label`,`Author`),c);let l=V(`div`,`plan-view-group plan-revision-group`),u=V(`div`,`plan-revision-stepper`),d=V(`button`,`plan-control plan-revision-previous`,`‹`);d.type=`button`,d.setAttribute(`aria-label`,`Previous revision`);let f=V(`button`,`plan-control plan-revision-next`,`›`);f.type=`button`,f.setAttribute(`aria-label`,`Next revision`);let p=V(`span`,`plan-revision-label`),m=V(`span`,`plan-revision-age`);u.append(d,p,f,m);let h=V(`div`,`plan-revision-list`);h.setAttribute(`role`,`radiogroup`),h.setAttribute(`aria-label`,`Revision`),l.append(V(`span`,`plan-sheet-label`,`Revision`),u,h);let g=V(`div`,`plan-view-group plan-mode-group`),_=V(`div`,`plan-modes`);_.setAttribute(`role`,`radiogroup`),_.setAttribute(`aria-label`,`Show`),g.append(V(`span`,`plan-sheet-label`,`Show`),_);let v=V(`div`,`plan-head-spacer`),y=V(`div`,`plan-draft-notice`),b=V(`span`,`plan-draft-dot`);b.setAttribute(`aria-hidden`,`true`);let x=V(`button`,`plan-control plan-draft-chip`,`Peek draft`);x.type=`button`,y.append(b,x),i.append(a,s,l,g,v,y);let ee=V(`button`,`plan-control plan-view-button`,`View`);ee.type=`button`,ee.setAttribute(`aria-haspopup`,`dialog`),ee.setAttribute(`aria-expanded`,`false`);let te=V(`button`,`plan-control plan-minimize-button`,`Minimize`);te.type=`button`,te.addEventListener(`click`,e.showTerminal),n.append(r,i,ee,te);let ne=V(`div`,`plan-sheet-backdrop`),re=V(`div`,`plan-body-layout`),ie=V(`nav`,`plan-heading-rail`);ie.setAttribute(`aria-label`,`Plan sections`);let S=V(`article`,`plan-reading-column`);re.append(ie,S);let ae=V(`textarea`,`plan-editor`);ae.setAttribute(`aria-label`,`Plan markdown`),ae.spellcheck=!1;let oe=V(`footer`,`plan-action-bar`),se=V(`span`,`plan-status`);se.setAttribute(`role`,`status`);let ce=V(`div`,`plan-decision-slot`),le=V(`label`,`plan-accept-edits`),C=V(`input`,`plan-accept-edits-checkbox`);C.type=`checkbox`,le.append(C,V(`span`,null,`Accept edits`)),ce.append(le,se),oe.append(ce);let w=new Map;for(let[e,t]of[[`terminal`,`Answer in terminal`],[`revise`,`Send feedback`],[`approve`,`Approve`]]){let n=V(`button`,`plan-action`,t);n.type=`button`,n.dataset.decision=e,n.addEventListener(`click`,()=>{n.disabled||rt(e)}),w.set(e,n),oe.append(n)}t.append(n,re,oe,ne);let T=null,ue={reviews:[]},de=null,fe=null,pe=!0,me=``,he=``,E=``,ge=``,_e=!1,ve=null,ye=!1,be=null,xe=!1,Se=!1,Ce=null,we=[],Te=null,Ee=null,De=new Map,Oe=new Map,ke=new Map,Ae=[],je=!1,Me=null,Ne=!1;function Pe(e,t=!0){Ne=e,i.replaceChildren(...e?[a,g,l,s,y,v]:[a,s,l,g,v,y]),c.setAttribute(`role`,e?`radiogroup`:`tablist`);for(let t of c.querySelectorAll(`button`)){let n=t.getAttribute(`aria-selected`)===`true`||t.getAttribute(`aria-checked`)===`true`;t.setAttribute(`role`,e?`radio`:`tab`),t.removeAttribute(e?`aria-selected`:`aria-checked`),t.setAttribute(e?`aria-checked`:`aria-selected`,String(n))}if(i.dataset.open=String(e),ne.dataset.open=String(e),ee.setAttribute(`aria-expanded`,String(e)),re.inert=e,oe.inert=e,r.inert=e,ee.inert=e,te.inert=e,e){i.setAttribute(`role`,`dialog`),i.setAttribute(`aria-label`,`Plan view`),i.setAttribute(`aria-modal`,`true`),o.focus();return}i.removeAttribute(`role`),i.removeAttribute(`aria-modal`),t&&ee.focus()}function Fe(e){e.addEventListener(`keydown`,t=>{let n={ArrowLeft:-1,ArrowUp:-1,ArrowRight:1,ArrowDown:1}[t.key];if(n===void 0&&t.key!==`Home`&&t.key!==`End`)return;let r=[...e.querySelectorAll(`button:not(:disabled)`)];if(r.length===0)return;t.preventDefault();let i=(r.indexOf(document.activeElement)+(n??0)+r.length)%r.length;t.key===`Home`&&(i=0),t.key===`End`&&(i=r.length-1);let a=Ne;r[i].click(),!(a&&e!==_)&&(e===_||!Ne)&&e.querySelector(`[aria-checked="true"], [aria-selected="true"]`)?.focus()})}let Ie=Vd.subscribe((e,t)=>{t.includes(`layout`)&&Ne&&Pe(!1,!1)});e.signal?.addEventListener(`abort`,Ie,{once:!0}),Fe(_),Fe(c),Fe(h),ee.addEventListener(`click`,()=>Pe(!Ne)),o.addEventListener(`click`,()=>Pe(!1)),ne.addEventListener(`click`,()=>Pe(!1)),i.addEventListener(`keydown`,e=>{if(!Ne)return;if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),Pe(!1);return}if(e.key!==`Tab`)return;let t=[...i.querySelectorAll(`button:not(:disabled)`)].filter(e=>e.getClientRects().length>0&&e.tabIndex>=0),n=t[0],r=t.at(-1);if(e.shiftKey&&document.activeElement===n){e.preventDefault(),r?.focus();return}!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())});function Le(e){S.querySelector(`#${CSS.escape(e)}`)?.scrollIntoView({behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`,block:`start`})}r.addEventListener(`change`,()=>Le(r.value));function Re(){je=!1;let e=Ae.map(e=>S.querySelector(`#${CSS.escape(e.dataset.headingId??``)}`)).filter(e=>e!==null),t=S.getBoundingClientRect().top-S.scrollTop,n=jL({headingOffsets:e.map(e=>e.getBoundingClientRect().top-t),scrollTop:S.scrollTop,isScrolledToEnd:S.scrollTop>0&&S.scrollTop+S.clientHeight>=S.scrollHeight-2,readingLineOffset:FL}),i=n===null?null:e[n]?.id??null;for(let e of Ae){if(e.dataset.headingId===i){e.setAttribute(`aria-current`,`location`);continue}e.removeAttribute(`aria-current`)}i!==null&&(r.value=i)}function ze(){je||t.hidden||Ae.length===0||(je=!0,requestAnimationFrame(Re))}S.addEventListener(`scroll`,ze,{passive:!0});function Be(){Me=null,ye=!1,xe=!1,Se=!1,Ce=null}function Ve(t){Te=t,e.reportProblem(t),Ot()}function He(e){fe=e,Te=null,Be(),Pe(!1,Ne),Ot()}function Ue(e){let t=ue.reviews.find(e=>e.agentId===de)?.revisions??[],n=t[t.findIndex(e=>e.revision===fe)+e];n&&He(n.revision)}d.addEventListener(`click`,()=>Ue(-1)),f.addEventListener(`click`,()=>Ue(1));function We(e,t){return`${T??``}:${e??`main`}:${t??`latest`}`}function Ge(){return We(de,fe)}function Ke(e,t,n){return`${e??``}:${LL(t,n??0)}`}function qe(){return Ke(T,de,fe)}function Je(){return Oe.get(qe())??null}function Ye(){return Je()?.size??0}function Xe(){if(Me===null)return!1;let e=Oe.get(Me.target.bucketKey)?.get(Me.target.sectionSlot)??``;return Me.field.value.trim()!==e}function Ze(e){let t=Oe.get(e);if(!t)return[];let n=[];for(let e of we){let r=t.get(RL(e));r&&n.push({heading:e.heading,comment:r})}return n}function Qe(e,t){let n=t.trim(),r=Oe.get(e.bucketKey)??new Map;Oe.set(e.bucketKey,r),n.length===0&&r.delete(e.sectionSlot),n.length>0&&r.set(e.sectionSlot,n),r.size===0&&Oe.delete(e.bucketKey),Ot()}function $e(e){if(Se||_e)return;let t={bucketKey:qe(),sectionSlot:RL(e)},n=V(`div`,`plan-comment-composer`),r=V(`label`,`plan-comment-label`,`Comment on ${e.heading??`Introduction`}`),i=V(`textarea`,`plan-comment-input`);i.maxLength=Ys,i.value=Oe.get(t.bucketKey)?.get(t.sectionSlot)??``,r.append(i);let a=V(`div`,`plan-comment-actions`),o=V(`button`,`plan-control plan-comment-cancel`,`Cancel`);o.type=`button`;let s=V(`button`,`plan-control plan-comment-save`,`Save comment`);s.type=`button`,a.append(o,s),n.append(r,a);let c={target:t,element:n,field:i};Me=c,i.addEventListener(`input`,Dt),o.addEventListener(`click`,()=>{Me===c&&(Me=null,Ot())}),s.addEventListener(`click`,()=>{Me===c&&(Me=null),Qe(t,i.value)}),Ot(),i.focus()}function et(e){let t={bucketKey:qe(),sectionSlot:RL(e)};if(Me?.target.bucketKey===t.bucketKey&&Me.target.sectionSlot===t.sectionSlot)return Me.element;let n=Je()?.get(t.sectionSlot);if(!n)return null;let r=V(`div`,`plan-comment-card`),i=V(`div`,`plan-comment-head`),a=V(`button`,`plan-control plan-comment-edit`,`Edit`);a.type=`button`,a.addEventListener(`click`,()=>$e(e));let o=V(`button`,`plan-control plan-comment-remove`,`Remove`);return o.type=`button`,o.disabled=_e,a.disabled=_e,o.addEventListener(`click`,()=>Qe(t,``)),i.append(V(`span`,`plan-comment-label`,`Your comment`),a,o),r.append(i,V(`p`,`plan-comment-text`,n)),r}function tt(t,n,r={}){if(!T||n.revision===null||_e)return!1;let i=TL(r);if(i!==null)return Ve(i),!1;let a={agentId:n.agentId,revision:n.revision,decision:t,...r};return e.sendDecision(T,a)?(Te=null,_e=!0,ve=fL(t)?n:null,Ot(),!0):!1}function nt(e){if(!ye)return{};let t=ae.value;return t===VL(T,e.agentId,e.revision)?{}:{plan:t}}function D(e){let t=Ke(T,e.agentId,e.revision),n=Ze(t);n.length!==0&&tt(`revise`,e,{comments:n})&&e.revision!==null&&(Ee={bucketKey:t,agentId:e.agentId,revision:e.revision},Ot())}function rt(e){let t={agentId:de,revision:fe};if(e===`revise`){D(t);return}tt(e===`approve`&&!le.hidden&&C.checked?`approve-accept-edits`:e,t,nt(t))}function it(e){Me=null,ye=e===`edit`,xe=e===`changes`,ye&&be!==qe()&&(ae.value=VL(T,de,fe)??``,be=qe()),Te=null,Ot()}function at(e){return`${e.kind}:${We(e.agentId,e.revision)}`}function ot(e){for(ke.set(at(e),e);ke.size>NL;){let e=ke.keys().next().value;if(typeof e!=`string`)break;ke.delete(e)}}function st(e,t){return e.agentId===t.agentId?e.kind===`draft`?t.revision===0:t.revision===0?!1:e.revision===null||e.revision===t.revision:!1}function ct(e){for(let[t,n]of ke)if(st(n,e))return ke.delete(t),n;return null}function lt(){for(let[e,t]of ke)if(t.kind===`draft`)return ke.delete(e),t;return null}function ut(){if(ke.size!==1)return null;let e=ke.entries().next().value;return e?(ke.delete(e[0]),e[1]):null}function dt(){if(!T)return;let t=Ge();me!==t&&e.requestPlan(T,de,fe??void 0)&&(me=t,ot({kind:`selection`,agentId:de,revision:fe}))}function ft(){t.hidden||dt()}function pt(){return vL(ue,de,fe)}function mt(t){if(!T)return;let n=We(de,t);E!==n&&e.requestPlan(T,de,t)&&(E=n,ot({kind:`diff-base`,agentId:de,revision:t}))}function ht(){if(!T)return;let t=`${T}:${de??`main`}`;ge!==t&&e.requestDraft(T,de)&&(ge=t,ot({kind:`draft`,agentId:de,revision:null}))}function gt(e,t){return`${e??``}:${t??``}`}function _t(){return ue.reviews.find(e=>e.agentId===de)?.revisions.find(e=>e.revision===fe)?.receivedAt??0}function vt(){let e=De.get(gt(T,de));return e!==void 0&&e>_t()}function yt(){if(Se){Be(),Ot();return}Me=null,ye=!1,xe=!1,ht(),Ot()}x.addEventListener(`click`,yt);function bt(e){ie.replaceChildren(),r.replaceChildren(),Ae=[];for(let t of e){let e=t.id??`plan-introduction`,n=t.heading??`Introduction`,i=V(`button`,`plan-heading-link`,n);i.type=`button`,i.dataset.level=String(t.level),i.dataset.headingId=e,i.title=n,i.dataset.commented=String(Je()?.has(RL(t))===!0),Ae.push(i),i.addEventListener(`click`,()=>Le(e)),ie.append(i);let a=V(`option`,null,n);a.value=e,r.append(a)}}function xt(e){let t=pt();if(t===null){S.append(V(`p`,`plan-loading`,`This is the first revision, so there is nothing to diff`));return}let n=VL(T,de,t);if(n===null){S.append(V(`p`,`plan-loading`,`Loading the previous revision`)),mt(t);return}let r=EI(n,e);if(r.isTooLarge){S.append(V(`p`,`plan-loading`,`This diff is too large to show, so the newer revision stands alone`)),S.append(sL(nL(e)));return}S.append(uL(r))}function St(e){if(S.replaceChildren(),ye){bt(we),S.append(ae);return}if(e===null){if(we=[],bt(we),he===Ge()){S.append(V(`p`,`plan-loading`,`This plan revision could not be loaded`));return}S.append(V(`p`,`plan-loading`,`Loading plan`)),dt();return}let t=nL(e);if(we=rL(t),bt(we),xe){xt(e);return}if(Se){S.append(sL(t));return}let n=Je();S.append(cL(we,{hasComment:e=>n?.has(RL(e))===!0,isComposing:e=>Me?.target.bucketKey===qe()&&Me.target.sectionSlot===RL(e),onComment:$e,attachmentFor:et}))}function Ct(e){s.hidden=e.tabs.length<2,c.replaceChildren();for(let t of e.tabs){let e=V(`button`,`plan-tab`,t.label);e.type=`button`,e.setAttribute(`role`,Ne?`radio`:`tab`),e.setAttribute(Ne?`aria-checked`:`aria-selected`,String(t.selected)),e.tabIndex=t.selected?0:-1,e.addEventListener(`click`,()=>{de=t.agentId,fe=null,Te=null,me=``,he=``,E=``,ge=``,Be(),Pe(!1,Ne),Ot()}),c.append(e)}}function wt(){return Se?Ce:VL(T,de,fe)}function Tt(e){return kL({state:ue,selectedAgentId:de,selectedRevision:fe,body:e,isConnected:pe,isDecisionInFlight:_e,isDraft:Se,pendingCommentCount:Ye(),hasUnsavedComment:Xe(),problem:Te})}function Et(e){se.textContent=e.status,se.hidden=e.status.length===0;let t=e.actions.some(e=>e.kind===`approve`&&e.enabled);le.hidden=!t,C.disabled=!t;for(let t of e.actions){let e=w.get(t.kind);e&&(e.disabled=!t.enabled)}}function Dt(){Et(Tt(wt()))}function Ot(){let e=Ne&&i.contains(document.activeElement),t=kL({state:ue,selectedAgentId:de,selectedRevision:fe,body:null,isConnected:pe});(de!==t.selectedAgentId||fe!==t.selectedRevision)&&Be(),de=t.selectedAgentId,fe=t.selectedRevision,be!==qe()&&(be=null);let n=wt(),a=Tt(n);Ct(a);let s=a.revisions.findIndex(e=>e.selected),c=a.revisions[s],l=Date.now();u.hidden=a.revisions.length<2,p.textContent=`Rev ${s+1} of ${a.revisions.length}`,m.textContent=c?yL(c.receivedAt,l):``,d.disabled=s<=0,f.disabled=s<0||s>=a.revisions.length-1,h.replaceChildren();for(let e of[...a.revisions].reverse()){let t=V(`button`,`plan-revision-option`);t.type=`button`,t.dataset.revision=String(e.revision),t.setAttribute(`role`,`radio`),t.setAttribute(`aria-checked`,String(e.selected)),t.tabIndex=e.selected?0:-1,t.append(V(`span`,`plan-revision-name`,e.label),V(`span`,`plan-revision-age`,yL(e.receivedAt,l))),e.isOpen&&t.append(V(`span`,`plan-revision-open`,`OPEN`)),t.addEventListener(`click`,()=>He(e.revision)),h.append(t)}_.replaceChildren();let g=ye?`edit`:xe?`changes`:`read`,v=a.modes.find(e=>e.kind===g&&e.enabled)??a.modes[0];for(let e of a.modes){let t=V(`button`,`plan-control plan-mode`,e.label);t.type=`button`,t.dataset.mode=e.kind,t.disabled=!e.enabled,t.setAttribute(`role`,`radio`),t.setAttribute(`aria-checked`,String(e.kind===g)),t.tabIndex=e.kind===v.kind?0:-1,t.addEventListener(`click`,()=>{t.disabled||(it(e.kind),_.querySelector(`[aria-checked="true"]`)?.focus())}),_.append(t)}y.hidden=!vt()&&!Se,x.hidden=y.hidden,x.setAttribute(`aria-pressed`,String(Se)),Et(a),St(n),r.disabled=Ae.length===0,ze(),e&&!i.contains(document.activeElement)&&o.focus()}function kt(t){ve!==null&&mL(t,ve.agentId)&&(ve=null,be=null,e.showTerminal())}function At(e){Me=null,e!==T&&(ve=null,_e=!1,Te=null,ke.clear()),Pe(!1,!1),T=e,t.hidden=!1,me=``,he=``,Ot(),ft()}function jt(){Me=null,Pe(!1,!1),t.hidden=!0}function Mt(e,t){return t.kind!==`selection`||e.agentId!==de?!1:t.revision===null?fe===null||fe===e.revision:t.revision===fe}function Nt(e){if(e.kind===`draft`){ge=``,Ve(`the draft could not be read, so nothing was shown`);return}if(e.kind===`diff-base`){E=``;return}he=We(e.agentId,e.revision)}function Pt(e){Ee!==null&&_L(e,Ee.agentId)!==Ee.revision&&(Oe.delete(Ee.bucketKey),Ee=null)}function Ft(e){_e=!1,It({reviews:e.reviews});let t=e.body;if(!t){let e=ut()??lt();e!==null&&Nt(e);return}let n=ct(t);if(t.revision===0){if(ge=``,n===null||t.agentId!==de)return;Ce=t.plan,Se=!0;return}zL(e.id,t),n!==null&&Mt(t,n)&&(de=t.agentId,fe=t.revision,me=``,he=``)}function It(e){let t=_L(e,de);t!==null&&t!==_L(ue,de)&&(fe=t,Be()),Pt(e),ue=e,_e=!1,kt(e)}function Lt(e){let n=!1;e.state&&It(e.state),e.draft&&De.set(gt(e.draft.id,e.draft.agentId),e.draft.changedAt),e.decisionRefused&&(ve=null,_e=!1,Ee=null),typeof e.isConnected==`boolean`&&(n=e.isConnected&&!pe,pe=e.isConnected,n&&(me=``,he=``,E=``,ge=``,_e=!1)),e.requestFailed&&(he=me),e.response&&Ft(e.response),t.hidden||Ot(),(n||e.decisionRefused)&&ft()}return{el:t,show:At,hide:jt,update:Lt}}var UL=`#plan/`;function WL(e){return`${UL}${encodeURIComponent(e)}`}function GL(e){if(!e.startsWith(UL))return null;let t=e.slice(6);if(!t||t.includes(`/`))return null;try{return decodeURIComponent(t)||null}catch{return null}}var KL=`http://www.w3.org/2000/svg`;function qL(e,t){let n=document.createElementNS(KL,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);return n}function JL(e,t){let n=document.createElementNS(KL,`svg`);return n.setAttribute(`width`,String(e)),n.setAttribute(`height`,String(t)),n.setAttribute(`viewBox`,`0 0 ${e} ${t}`),n.setAttribute(`aria-hidden`,`true`),n}function YL(e){let t=JL(12,12);return t.classList.add(`state-glyph`),t.dataset.tone=e,e===`danger`&&t.append(qL(`path`,{d:`M2.5 2.5L9.5 9.5M9.5 2.5L2.5 9.5`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`})),e===`warn`&&t.append(qL(`path`,{d:`M6 1L11 6L6 11L1 6Z`,fill:`currentColor`})),e===`wait`&&t.append(qL(`circle`,{cx:`6`,cy:`6`,r:`4`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`})),e===`ok`&&t.append(qL(`path`,{d:`M2 6L4.5 8.5L10 3`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`})),e===`muted`&&t.append(qL(`path`,{d:`M3 6H9`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`})),t}function XL(e){let t=new Map;for(let n of e.files){let e=n.path.split(`/`);for(let r=0;r<e.length;r++){let i=e.slice(0,r).join(`/`),a=t.get(i);a!==void 0&&a.localeCompare(n.path)<=0||t.set(i,n.path)}}return t}function ZL(e,t){let n=[],r=new Set(e.files.map(e=>e.path));for(let i of e.links){let a=t.get(i.providerRepo),o=a?.firstChangedPathByDirectory.get(i.packageDir),s=o??i.importers.find(e=>r.has(e))??i.importers[0]??i.consumerManifest,c=o&&a?a.repo:e,l=i.importerCount===1?`file`:`files`,u=i.providerChangedPathCount===1?`file`:`files`,d=i.changedImporterCount===1?`file`:`files`,f=i.isLocalLink?`Linked locally (${i.versionSpec}), so ${i.providerRepo} changes reach it now.`:`Uses ${i.versionSpec} from the registry, so ${i.providerRepo} changes reach it only after a publish.`;i.providerChangedPathCount>0&&(f+=` ${i.providerRepo} changed ${i.providerChangedPathCount} ${u} in ${i.packageDir||`the repository root`}.`),i.changedImporterCount>0&&(f+=` ${i.changedImporterCount} importing ${d} changed here.`),n.push({factId:i.factId,kind:`link`,severity:6,path:s,openPath:`${c.sessionPathPrefix}${s}`,headline:`${e.name} imports ${i.packageName} from ${i.providerRepo} in ${i.importerCount} ${l}`,detail:f})}for(let t of e.collisions)n.push({factId:t.factId,kind:`collision`,severity:5,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`${t.path} is also changed in "${t.otherSessionName}"`,detail:`Another live session is changing this file.`});for(let t of e.coChangeGaps){let r=t.confidence>0?Math.round(t.support/t.confidence):0;n.push({factId:t.factId,kind:`co-change`,severity:4,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`Usually changes with ${t.partner} (${t.support} of ${r} commits)`,detail:`${t.partner} is absent from these changes.`})}for(let t of e.untestedFiles)n.push({factId:t.factId,kind:`untested`,severity:3,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`No test reaches ${t.path}`,detail:`No dependent test was found in the import graph.`});for(let t of e.hotspots)n.push({factId:t.factId,kind:`hotspot`,severity:2,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`${t.path} is a hotspot`,detail:`${t.fixCommitCount} of its last ${t.commitCount} commits were fixes.`});for(let t of e.blastRadius)t.transitiveDependentCount<10||n.push({factId:t.factId,kind:`blast`,severity:1,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`Wide blast radius: ${t.transitiveDependentCount} files depend on ${t.path}`,detail:`${t.directDependentCount} direct dependents; ${t.dependentTestCount} dependent tests.`});return n.sort((e,t)=>t.severity-e.severity||e.path.localeCompare(t.path)||e.factId.localeCompare(t.factId))}function QL(e,t){let n=new Map(e.blastRadius.map(e=>[e.path,e])),r=e.files.filter(e=>e.isCommitted).length;return{header:{name:e.name,fileCount:e.files.length,committedCount:r,uncommittedCount:e.files.length-r,base:e.base},subsystems:e.subsystems.map(e=>({title:e.title,fileCount:e.paths.length})),warnings:ZL(e,t),files:e.files.map(t=>({path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,status:t.status,isCommitted:t.isCommitted,dependentCount:n.get(t.path)?.transitiveDependentCount??0,testCount:n.get(t.path)?.dependentTestCount??0})),error:e.error}}function $L(e){let t=new Set(e.repos.flatMap(e=>e.links.map(e=>e.providerRepo))),n=new Map;for(let r of e.repos)t.has(r.name)&&!n.has(r.name)&&n.set(r.name,{repo:r,firstChangedPathByDirectory:XL(r)});let r=e.repos.map(e=>QL(e,n));return{repos:r,narrative:{state:e.narratorState,claims:e.narratorState===`ready`?e.narrative?.claims.map(e=>({text:e.text,factIds:e.factIds}))??[]:[],status:{disabled:null,pending:`Narrative is being prepared.`,ready:null,failed:`Narrative could not be prepared.`}[e.narratorState]},emptyState:!e.error&&r.every(e=>e.header.fileCount===0&&e.warnings.length===0)&&r.every(e=>!e.error)?`No changed files in this session.`:null,error:e.error??null}}function eR(e,t,n,r){let i=V(`button`,n);return i.type=`button`,i.title=`Open ${e} in the diff`,i.addEventListener(`click`,()=>r(t)),i}function tR(e,t){let n=V(`section`,`review-map-repo`),r=V(`div`,`review-map-repo-head`);r.append(V(`strong`,`review-map-repo-name`,e.header.name)),r.append(V(`span`,`review-map-count`,e.header.fileCount===1?`1 file`:`${e.header.fileCount} files`)),n.append(r);let i=V(`div`,`review-map-summary`);if(i.append(V(`span`,``,`${e.header.committedCount} committed`)),i.append(V(`span`,``,`${e.header.uncommittedCount} uncommitted`)),i.append(V(`span`,``,`Base: ${e.header.base?e.header.base.slice(0,8):`unknown`}`)),n.append(i),e.error&&n.append(V(`p`,`review-map-error`,e.error)),e.subsystems.length>0){let t=V(`div`,`review-map-subsystems`);for(let n of e.subsystems)t.append(V(`span`,`review-map-chip`,`${n.title} (${n.fileCount})`));n.append(t)}if(e.warnings.length>0){n.append(V(`h3`,`review-map-label`,`Signals`));let r=V(`div`,`review-map-warnings`);for(let n of e.warnings){let e=eR(n.path,n.openPath,`review-map-warning`,t);e.dataset.severity=String(n.severity),e.dataset.kind=n.kind,e.append(V(`span`,`review-map-warning-headline`,n.headline)),e.append(V(`span`,`review-map-detail`,n.detail)),r.append(e)}n.append(r)}if(e.files.length>0){n.append(V(`h3`,`review-map-label`,`Files`));let r=V(`div`,`review-map-files`);for(let n of e.files){let e=eR(n.path,n.openPath,`review-map-file`,t);e.dataset.status=n.status,e.append(V(`span`,`review-map-file-path`,n.path)),e.append(V(`span`,`review-map-file-meta`,`${n.status} · ${n.isCommitted?`committed`:`uncommitted`} · ${n.dependentCount} dependents · ${n.testCount} tests`)),r.append(e)}n.append(r)}return n}function nR(e,t){let n=V(`div`,`review-map`);if(e.error&&n.append(V(`p`,`review-map-error`,e.error)),e.emptyState&&n.append(V(`div`,`review-nochanges`,e.emptyState)),e.narrative.status&&n.append(V(`p`,`review-map-narrative-status`,e.narrative.status)),e.narrative.claims.length>0){let t=V(`section`,`review-map-narrative`);t.append(V(`h3`,`review-map-label`,`Narrative`));for(let n of e.narrative.claims){let e=V(`p`,`review-map-claim`,n.text);e.dataset.factIds=n.factIds.join(` `),t.append(e)}n.append(t)}for(let r of e.repos)n.append(tR(r,t));return n}function rR({status:e,mergeReason:t,fetched:n,hasChanges:r,hasCommits:i,canMerge:a,isWorkspace:o,live:s,effectiveBase:c}){return e===`parked`&&t===`base-diverged`?{text:`Parked: base branch diverged`}:e===`parked`?{text:`Parked: merge conflict`}:e===`merging`?{text:`Merging`}:e===`merged`?{text:`Merged`}:n?r?o?{text:`Changes in this worktree`}:a?{text:`Ready to merge into ${aR(c)}`}:s?i?{text:`Not ready to merge`}:{text:`Uncommitted changes`}:{text:`Session ended`}:{text:`No changes yet`}:{text:`Checking for changes`}}function iR({status:e,mergeReason:t,live:n,isMergeRendered:r,hasChanges:i}){return e===`parked`&&n&&t!==`base-diverged`?`resolve`:!i&&e!==`parked`&&e!==`merging`?`none`:r?`merge`:`none`}function aR(e){return e||`base`}function oR(e,t){return`Merge into ${aR(e)}, push it, and rebase this worktree, then keep working (${t})`}function sR(e){return`merges into ${aR(e)}`}function cR(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function lR(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function uR({status:e,mergeReason:t,fetched:n,hasCommits:r,live:i,state:a}){return e===`merging`?null:n?r?i?e===`parked`&&t===`base-diverged`?`Resync the base branch by hand before merging.`:e===`parked`?`Resolve the conflict, then merge.`:a===`INITIALIZING`||a===`STARTING`?`Starting up. Mergeable once the session is live.`:null:`Session ended.`:null:`Checking for changes...`}function dR({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function fR(e){return e||`its upstream`}function pR(e){if(!e)return null;let t=e.branch||`Base branch`,{state:n,ahead:r,behind:i}=e,a=fR(e.upstream);return n===`no-upstream`?`${t}: no upstream`:n===`unknown`?`${t}: sync state unknown vs ${a}`:n===`in-sync`?`${t}: in sync with ${a}`:n===`ahead`?`${t}: ${r} ahead of ${a}`:n===`behind`?`${t}: ${i} behind ${a}`:n===`diverged`?`${t}: ${r} ahead, ${i} behind ${a}`:null}function mR(e){return!e||e.fetched===!1?`recheck`:e.state===`ahead`||e.state===`behind`?`resync`:`recheck`}function hR(e,t,n){let r=n?` (${t})`:``;if(!e||mR(e)===`recheck`)return`Click to fetch and check again${r}`;let i=e.branch||`Base branch`,a=fR(e.upstream);return e.state===`behind`?`Click to fast-forward ${i} to ${a}${r}`:`Click to push ${i} to ${a}${r}`}function gR(e){return e?.state!==`in-sync`||e.fetched===!1}function _R({fetched:e,hasChanges:t,view:n,committedFiles:r,uncommittedFiles:i}){return e&&!t?!1:n!==`diff`||Number(r>0)+Number(i>0)!==1}function vR(e){if(e.error)return`Resync failed: ${e.error}`;let t=e.branch||`The base branch`,n=fR(e.upstream);return e.action===`fast-forwarded`?`Fast-forwarded ${t} to ${n}.`:e.action===`pushed`?`Pushed ${t} to ${n}.`:e.state===`diverged`?`${t} has diverged from ${n}. Resolve manually.`:e.state===`in-sync`?null:e.state===`no-upstream`?`${t} has no upstream to resync against.`:`Could not determine sync status.`}function yR(){return Vd.snapshot().selectedSessionId}function bR(e){Vd.dispatch(`selectSession`,e)}function xR(e){return Vd.subscribe((t,n)=>{n.includes(`selectedSessionId`)&&e(t.selectedSessionId)})}var SR=new Set([`pending-review`,`parked`]),CR=600,wR=Xy(`merge`,Zy),TR=Xy(`resolve-or-resync`,Zy),ER=260,DR=700,OR=new Map,kR=new Map,AR=new Map,jR=new Map,MR=new Map,NR=new Set,PR=new Set,FR=new Set,IR=sF(),LR=null,RR=null,zR=null,BR=null,VR=new Map,HR=null,UR=null,WR=null,GR=null,KR=null,qR=!1,JR=!1,YR=null,XR=null,ZR=null,QR=null,$R=new Map,ez=null,tz=null,nz=null,rz=null,iz=null,az=new Map,oz=null,sz=!1,cz=null;function lz(e,t){let n=V(`button`,`review-icon-button`);n.type=`button`,n.title=e,n.setAttribute(`aria-label`,e);let r=JL(16,16);return r.append(qL(`path`,{d:t,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})),n.append(r),n}function uz(){qR=!1,zR?.querySelector(`.review-more-menu`)?.remove(),zR?.querySelector(`.review-more-button`)?.setAttribute(`aria-expanded`,`false`)}function dz({panel:e}){if(RR=e,!RR)return;let t=RR,n=V(`div`,`review-sidebar-head`),r=V(`span`,`review-sidebar-title`,`Review`),i=e=>{t.toggleAttribute(`data-collapsed`,e),oF(!e)},a=V(`div`,`review-header-tabs`);a.setAttribute(`role`,`group`),a.setAttribute(`aria-label`,`Review view`);for(let[e,t]of[[`map`,`Map`],[`diff`,`Diff`],[`notes`,`Notes`]]){let n=V(`button`,`review-header-tab`,t);n.type=`button`,n.addEventListener(`click`,()=>lB(e)),VR.set(e,n),a.append(n)}HR=V(`span`,`review-notes-count`),a.append(HR);let o=lz(`Close review`,`M6 3L11 8L6 13`);o.classList.add(`review-sidebar-close`),o.addEventListener(`click`,()=>i(!0)),n.append(r,a,o);let s=V(`div`,`review-sidebar-rail`),c=lz(`Open review`,`M10 3L5 8L10 13`);c.classList.add(`review-sidebar-open`),c.addEventListener(`click`,()=>i(!1)),WR=V(`div`,`review-rail-status`),GR=V(`span`,`review-rail-added`),KR=V(`span`,`review-rail-removed`),WR.append(GR,KR),UR=V(`span`,`review-rail-label`,`Review`),s.append(c,UR,WR),zR=V(`div`,`review-controls`),BR=V(`div`,`review-sidebar-body`),ez=V(`div`,`review-notes-footer`),tz=V(`button`,`review-btn review-btn-primary`,`Send notes`),tz.type=`button`,tz.title=`Paste the drafted review notes into this session as one message`,tz.addEventListener(`click`,Yz),nz=V(`div`,`review-notes-status`),ez.append(nz,tz),iz=V(`div`,`review-notes-list`),rz=V(`div`,`review-notes-outcome`),rz.setAttribute(`role`,`status`);let l=V(`div`,`review-resize-handle`);l.setAttribute(`aria-hidden`,`true`),t.append(s,n,zR,BR,rz,ez,l),t.toggleAttribute(`data-collapsed`,!aF()),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&qR&&(e.preventDefault(),uz(),zR?.querySelector(`.review-more-button`)?.focus())}),document.addEventListener(`pointerdown`,e=>{qR&&e.target instanceof Element&&(zR?.contains(e.target)&&e.target.closest(`.review-more-button, .review-more-menu`)||uz())});let u=0,d=0,f=e=>{let n=Math.max(ER,Math.min(DR,e));return Number.isFinite(n)?(t.style.setProperty(`--sidebar-width`,`${n}px`),n):null},p=e=>{l.hasPointerCapture(e.pointerId)&&f(d+(u-e.clientX))},m=!1,h=e=>{if(!m)return;m=!1,l.hasPointerCapture(e.pointerId)&&l.releasePointerCapture(e.pointerId),document.documentElement.style.cursor=``,document.documentElement.style.userSelect=``;let n=t.style.getPropertyValue(`--sidebar-width`);n&&PF(parseInt(n,10))};l.addEventListener(`pointerdown`,e=>{e.button===0&&(e.preventDefault(),u=e.clientX,d=t.getBoundingClientRect().width,l.setPointerCapture(e.pointerId),m=!0,document.documentElement.style.cursor=`col-resize`,document.documentElement.style.userSelect=`none`)}),l.addEventListener(`pointermove`,p),l.addEventListener(`pointerup`,h),l.addEventListener(`pointercancel`,h),l.addEventListener(`lostpointercapture`,h);let g=NF();g!==null&&f(g),xR(e=>{qR=!1,PR.clear(),FR.clear(),LR=null,Hz(),e&&Mz(e),e&&!Pz(e)&&Fz(e),pB()}),pB()}function fz(e){if(RR){if(e){jd(RR,e);return}Md(RR)}}function pz(e,t){let n=OR.get(e);OR.set(e,t),PE(n,t)&&(AR.delete(e),jR.delete(e),e===yR()&&Nz(e)),e===yR()&&pB()}function mz(e,t,n=null){let r=OR.get(e)||`none`,i=t||`none`;if(kR.set(e,n),pz(e,i),SR.has(i)&&!SR.has(r)){let t=yR(),n=t?SR.has(OR.get(t)||`none`):!1;(!t||!U.has(t)||!n)&&bR(e)}}function hz(e,t,n=null){kR.set(e,n),pz(e,t||`none`)}function gz(e,t){let n=AR.get(e)??null;AR.set(e,t),e===yR()&&(yz(n,t),LR&&uB(LR,t),pB(),dB())}function _z(e,t){let n=Zd(e);if(!n)return;let r=Oc.safeParse(t);r.success&&r.data.sessionId===n&&(jR.set(n,r.data),n===yR()&&pB())}function vz(e){return{committed:e?.committed?.diff||``,uncommitted:e?.uncommitted?.diff||``}}function yz(e,t){if(az.size===0||!e)return;let n=ME(vz(e),vz(t),az.keys());if(n.length!==0){for(let e of n)az.delete(e);oz!==null&&n.includes(oz)&&(oz=null),cz=`${n.length} note${n.length===1?``:`s`} dropped because the diff changed.`}}function bz(e,t){let n=Zd(e),r=t;MR.set(n,r),r&&r.action!==void 0&&xz(n,r),n===yR()&&pB()}function xz(e,t){NR.delete(e),clearTimeout(QR??void 0),QR=null;let n=vR(t);ZR=n?{forId:e,text:n,isError:!!t.error}:null,ZR&&!ZR.isError&&(QR=setTimeout(()=>{ZR&&ZR.forId===e&&(ZR=null),pB()},5e3))}function Sz(e){let t=Zd(e);t&&t===yR()&&Mz(t)}function Cz(e){let t=Zd(e);t===yR()&&(AR.has(t)||Mz(t),jR.has(t)||Nz(t),pB())}function wz(e){let t=Zd(e);if(OR.delete(t),kR.delete(t),AR.delete(t),jR.delete(t),MR.delete(t),NR.delete(t),ZR&&ZR.forId===t&&(clearTimeout(QR??void 0),ZR=null),t===yR()){bR(null);return}pB()}function Tz(){let e=yR();if(!e||Pz(e))return!1;let t=U.get(e);if(!t)return!1;let n=OR.get(e)||`none`,r=!!AR.get(e)?.hasCommits,i=lR(n,kR.get(e)||null,kz(t.currentState,r));return iR({status:n,mergeReason:kR.get(e)||null,live:jz(t.currentState),isMergeRendered:i.isRendered,hasChanges:Oz(e)})!==`merge`||!i.isEnabled?!1:(Az(e,t.currentState),!0)}function Ez(){let e=yR();if(!e||Pz(e))return!1;let t=U.get(e);if(!t)return!1;let n=OR.get(e)||`none`,r=kR.get(e)||null;return iR({status:n,mergeReason:r,live:jz(t.currentState),isMergeRendered:lR(n,r,!1).isRendered,hasChanges:Oz(e)})===`resolve`&&(B({type:`resolve-session-merge`,id:e}),!0)}function Dz(){let e=yR();return!e||!U.has(e)||Pz(e)||Lz(e)?!1:(Rz(e),!0)}function Oz(e){let t=AR.get(e)??null,n=[...AE(t?.committed?.diff||``),...AE(t?.uncommitted?.diff||``)];return dR({fetched:AR.has(e),changedFileCount:FE(n).files,hasCommits:!!t?.hasCommits})}function kz(e,t){return(Nc.includes(e)||e===I.RUNNING)&&t}function Az(e,t){if(t!==I.RUNNING){B({type:`merge-continue-session`,id:e});return}af({title:`Merge while working`,message:`This session still looks like it is working. Merging rebases its worktree under it. Merge anyway?`,confirmLabel:`Merge anyway`,onConfirm:()=>B({type:`merge-continue-session`,id:e,force:!0})})}function jz(e){return e!==I.DORMANT&&e!==I.DONE&&e!==I.FAILED}function Mz(e){B({type:`request-session-diff`,id:e}),Nz(e)}function Nz(e){jR.has(e)||jR.set(e,null),B({type:`request-change-map`,id:e})}function Pz(e){return U.get(e)?.card.dataset.workspace!==void 0}function Fz(e){MR.set(e,null),B({type:`request-branch-sync`,id:e}),e===yR()&&pB()}function Iz(e){NR.add(e),clearTimeout(QR??void 0),ZR&&ZR.forId===e&&(ZR=null),B({type:`resync-branch`,id:e}),e===yR()&&pB()}function Lz(e){return NR.has(e)||MR.get(e)===null}function Rz(e){if(!Lz(e)){if(mR(MR.get(e))===`resync`){Iz(e);return}Fz(e)}}function zz(e,t){return t||!e?null:e.state===`no-upstream`?`No upstream configured.`:e.state===`unknown`?`Could not determine sync status.`:null}function Bz(e,t,n){if(n)return{text:`Resyncing...`,loading:!0,error:!1};if(ZR&&ZR.forId===e)return{text:ZR.text,loading:!1,error:ZR.isError};let r=zz(t,!1);return r?{text:r,loading:!1,error:!1}:null}function Vz(e,t){return e?.card?.dataset.session||t}function Hz(){az.clear(),oz=null,cz=null,sz=!1}function Uz(e){return az.get(e)??null}function Wz(){return`${az.size} note${az.size===1?``:`s`} drafted`}function Gz(e,t){let n=V(`div`,`review-notes-entry`),r=t.side===`old`?` (removed line)`:``;n.append(V(`span`,`review-notes-entry-where`,`${t.section} ${t.path}:${t.line}${r}`)),n.append(V(`span`,`review-notes-entry-note`,t.note));let i=V(`button`,`review-note-remove`,`Remove`);return i.type=`button`,i.title=`Drop this note`,i.addEventListener(`click`,()=>cB(e)),n.append(i),n}function Kz(){if(iz){iz.replaceChildren(),iz.hidden=az.size===0;for(let[e,t]of az)iz.append(Gz(e,t))}}function qz(){if(!ez||!tz||!nz)return;let e=yR(),t=!!e&&U.has(e);ez.hidden=!t||IR===`map`||az.size===0,tz.disabled=sz||az.size===0,nz.textContent=Wz(),HR&&(HR.hidden=az.size===0,HR.textContent=String(az.size),HR.setAttribute(`aria-label`,Wz())),rz&&(rz.textContent=sz?`Sending notes...`:cz,rz.hidden=!t||IR===`map`||!rz.textContent),Kz(),IR===`notes`&&t&&Jz()}function Jz(){if(BR&&iz){if(BR.replaceChildren(),az.size===0){mB(`No notes yet`,`Open the Diff tab and press note on a line to draft one.`);return}BR.append(iz)}}function Yz(){let e=yR();e&&!sz&&az.size!==0&&(sz=!0,cz=null,qz(),dd(`send-diff-annotations`,{id:e,annotations:[...az.values()]}).then(Qz,Xz))}function Xz(e){sz=!1;let t=e instanceof Error?e.message:``;cz=t?`Could not send the notes: ${t}.`:`Could not send the notes.`,qz()}function Zz(e){return e.type===`send-diff-annotations-result`&&typeof e.error==`string`&&e.error?e.error:e.type===`error`&&typeof e.message==`string`&&e.message?e.message:`Could not send the notes.`}function Qz(e){if(sz=!1,e.type!==`send-diff-annotations-result`||e.ok!==!0){cz=Zz(e),qz();return}if(e.pending===!0){cz=`Notes queued until the session wakes. They stay drafted here, and pressing Send notes again re-sends them.`,qz();return}cz=`Notes sent.`,az.clear(),oz=null,pB()}function $z(e,t){let n=V(`div`,`review-note`);n.dataset.noteFor=e,n.append(V(`span`,`review-note-text`,t));let r=V(`button`,`review-note-remove`,`Remove`);return r.type=`button`,r.title=`Drop this note`,r.addEventListener(`click`,()=>cB(e)),n.append(r),n}function eB(e,t){let n=V(`div`,`review-note-editor`);n.dataset.editorFor=e;let r=V(`input`,`review-note-input`);r.type=`text`,r.value=t,r.maxLength=zu,r.placeholder=`Note for this line`,r.addEventListener(`keydown`,t=>{if(t.key===`Enter`){t.preventDefault(),sB(e,r.value);return}t.key===`Escape`&&(t.preventDefault(),oB())});let i=V(`button`,`review-note-save`,`Save`);i.type=`button`,i.addEventListener(`click`,()=>sB(e,r.value));let a=V(`button`,`review-note-cancel`,`Cancel`);return a.type=`button`,a.addEventListener(`click`,oB),n.append(r,i,a),n}function tB(e){let t=[],n=Uz(e);return oz===e&&t.push(eB(e,n?n.note:``)),n&&t.push($z(e,n.note)),t}function nB(e,t){let n=tB(t);return e.after(...n),n}function rB(e){let t=e.nextElementSibling;for(;t instanceof HTMLElement&&(t.dataset.noteFor!==void 0||t.dataset.editorFor!==void 0);){let e=t.nextElementSibling;t.remove(),t=e}}function iB(e){let t=$R.get(e);if(!t)return;let n=null;for(let r of t.rows){rB(r);let t=nB(r,e);for(let e of t){let t=e.querySelector(`input`);!n&&t instanceof HTMLInputElement&&(n=t)}}n&&(n.focus(),n.select())}function aB(e){let t=oz;oz=e,t&&t!==e&&iB(t),iB(e)}function oB(){let e=oz;e&&(oz=null,iB(e))}function sB(e,t){let n=$R.get(e);if(!n)return;let r=t.trim();if(r){if(az.size>=50&&!az.has(e)){cz=`Only 50 notes can be sent at once.`,qz();return}az.set(e,{...n.target,section:n.section,note:r}),cz=null,oz=null,iB(e),qz()}}function cB(e){az.delete(e),cz=null,iB(e),qz()}function lB(e){IR=e,e!==`diff`&&(LR=null),cF(e),pB()}function uB(e,t){if(!t)return;let n=AE(t.committed?.diff),r=AE(t.uncommitted?.diff);for(let t of n)(t.path===e||t.oldPath===e)&&PR.add(`committed:${t.path}`);for(let t of r)(t.path===e||t.oldPath===e)&&PR.add(`uncommitted:${t.path}`)}function dB(){if(!BR||!LR)return;let e=BR.querySelectorAll(`.review-file`);for(let t of e)if(t.dataset.path===LR||t.dataset.oldPath===LR){t.scrollIntoView({block:`nearest`}),LR=null;return}}function fB(e){LR=e,uB(e,AR.get(yR()??``)),lB(`diff`),dB()}function pB(){if(!zR||!BR)return;zR.replaceChildren(),BR.replaceChildren();for(let[e,t]of VR)t.setAttribute(`aria-pressed`,String(IR===e));$R.clear(),qz(),UR&&(UR.hidden=!0),WR&&(WR.hidden=!0);let e=yR(),t=e?U.get(e):null;if(!e||!t){mB(`No session selected`,`Click a session name to review its changes here.`);return}let n=Pz(e),r=OR.get(e)||`none`,i=kR.get(e)||null,a=t.currentState,o=SR.has(r),s=AR.has(e),c=s?AR.get(e):null,l=c?AE(c.committed?.diff||``):[],u=c?AE(c.uncommitted?.diff||``):[],d=!!c?.hasCommits,f=jz(a),p=lR(r,i,kz(a,d)),m=MR.get(e),h=NR.has(e),g=aR(t.effectiveBase),_=FE([...l,...u]),v=dR({fetched:s,changedFileCount:_.files,hasCommits:d}),y=iR({status:r,mergeReason:i,live:f,hasChanges:v,isMergeRendered:p.isRendered}),b=rR({status:r,mergeReason:i,fetched:s,hasChanges:_.files>0||d,hasCommits:d,canMerge:!n&&p.isEnabled,isWorkspace:n,live:f,effectiveBase:g}),x=V(`div`,`review-status-headline`);if(x.append(V(`span`,`review-status-text`,b.text)),!n&&!gR(m)){let t=pR(m);if(t){x.title=t;let n=lz(`Refresh branch sync`,`M13 6A5 5 0 1 0 13 10M13 2v4H9`);n.classList.add(`review-branch-sync-refresh`),n.title=hR(m,TR,y!==`resolve`),n.disabled=Lz(e),n.setAttribute(`aria-description`,t),n.addEventListener(`click`,()=>Rz(e)),x.append(V(`span`,`sr-only`,t),n)}}zR.append(x);let ee=V(`div`,`review-status-meta`);if(_R({fetched:s,hasChanges:v,view:IR,committedFiles:l.length,uncommittedFiles:u.length})&&ee.append(V(`span`,`review-status-files`,`${_.files} file${_.files===1?``:`s`}`),V(`span`,`review-status-added`,`+${_.added}`),V(`span`,`review-status-removed`,`-${_.removed}`),V(`span`,`review-status-spacer`)),!n&&gR(m)){let t=hB(e,y!==`resolve`);t&&ee.append(t)}ee.childElementCount>0&&zR.append(ee),r===`parked`&&zR.append(V(`div`,`review-status-explanation`,cR(i))),UR&&(UR.hidden=!1),WR&&(WR.hidden=!1,WR.setAttribute(`aria-label`,`${b.text}, +${_.added}, -${_.removed}`),WR.title=b.text),GR&&(GR.textContent=`+${_.added}`),KR&&(KR.textContent=`-${_.removed}`);let te=n?null:yB(e,{status:r,reviewable:o,mergeAction:p,live:f,state:a,effectiveBase:g,primaryAction:y});te&&zR.append(te);let ne=n?null:Bz(e,m,h),re=!n&&y===`merge`&&!p.isEnabled?uR({status:r,mergeReason:i,fetched:s,hasCommits:d,live:f,state:a}):null,ie=!!re;if(re){let e=V(`div`,s?`review-control-reason`:`review-control-reason review-loading`,re);e.id=`review-merge-reason`,zR.append(e),zR.querySelector(`#review-merge-btn`)?.setAttribute(`aria-describedby`,e.id)}if(ne?.text){let e=V(`div`,ne.loading?`review-control-reason review-loading`:`review-control-reason`,ne.text);e.id=`review-resync-reason`,ne.error&&e.classList.add(`review-control-reason-error`),e.setAttribute(`role`,`status`),ee.append(e),ee.isConnected||zR.insertBefore(ee,x.nextSibling),zR.querySelector(`.review-branch-sync-text, .review-branch-sync-refresh`)?.setAttribute(`aria-describedby`,e.id)}if(JR&&YR===e&&zR.append(V(`div`,`review-resolve-sent`,`Resolve prompt sent`)),IR!==`notes`){if(IR===`map`){let t=jR.get(e);t&&BR.append(nR($L(t),fB)),t||BR.append(V(`div`,`review-nochanges review-loading`,`Loading map...`));return}if(l.length>0&&BR.append(gB(`committed`,`Committed`,sR(g),l)),l.length===0&&u.length===0&&!ie){let e=!s&&o?V(`div`,`review-nochanges review-loading`,`Loading diff...`):V(`div`,`review-nochanges`,`No changes in this worktree.`);BR.append(e)}u.length>0&&BR.append(gB(`uncommitted`,`Uncommitted`,``,u))}}function mB(e,t){if(!BR)return;let n=V(`div`,`review-empty`);n.append(V(`div`,`review-empty-title`,e),V(`div`,`review-empty-desc`,t)),BR.append(n)}function hB(e,t){let n=MR.get(e);if(n===void 0)return null;if(n===null)return V(`span`,`review-branch-sync-text review-loading`,`Checking branch sync...`);let r=pR(n)||`Base branch: sync state unknown`,i=lz(`Refresh branch sync`,`M13 6A5 5 0 1 0 13 10M13 2v4H9`);return i.className=`review-branch-sync-text`,i.removeAttribute(`aria-label`),i.append(V(`span`,`review-branch-sync-label`,r)),i.disabled=NR.has(e),n.state&&(i.dataset.syncState=n.state),n.fetched===!1&&(i.dataset.stale=`true`),i.title=hR(n,TR,t),i.addEventListener(`click`,()=>Rz(e)),i}function gB(e,t,n,r){let i=V(`div`,`review-section`);i.dataset.kind=e;let a=FE(r),o=V(`div`,`review-section-head`),s=V(`div`,`review-section-id`);s.append(V(`span`,`review-section-label`,t)),n&&s.append(V(`span`,`review-section-meaning`,n)),o.append(s);let c=V(`div`,`review-section-stat`);c.append(V(`span`,`review-stat-files`,`${a.files} file${a.files===1?``:`s`}`)),c.append(V(`span`,`review-add`,`+${a.added}`),V(`span`,`review-del`,`-${a.removed}`)),o.append(c),i.append(o);let l=V(`div`,`review-diff`);for(let t of r)l.append(_B(t,e));return i.append(l),i}function _B(e,t){let n=`${t}:${e.path}`,r=PR.has(n),i=V(`div`,`review-file`);i.dataset.path=e.path,e.oldPath&&(i.dataset.oldPath=e.oldPath),i.dataset.status=e.status,i.dataset.open=r?`true`:`false`;let a=V(`button`,`review-file-head`);a.type=`button`,a.setAttribute(`aria-expanded`,r?`true`:`false`);let o=V(`span`,`review-file-twisty`,r?`▾`:`▸`);o.setAttribute(`aria-hidden`,`true`),a.append(o,V(`span`,`review-file-path`,e.path));let s=V(`span`,`review-file-counts`);if(e.binary&&s.append(V(`span`,`review-bin`,`bin`)),e.binary||s.append(V(`span`,`review-add`,`+${e.added}`),V(`span`,`review-del`,`-${e.removed}`)),a.append(s),a.addEventListener(`click`,()=>{let e=PR.has(n);e&&PR.delete(n),e||PR.add(n),pB()}),i.append(a),!r)return i;let c=V(`div`,`review-file-body`);if(e.binary)return c.append(V(`div`,`review-file-binary`,`Binary file not shown`)),i.append(c),i;let l=0,u=!1;for(let r of e.hunks){if(l>=CR&&!FR.has(n)){u=!0;break}c.append(V(`div`,`review-hunk-head`,r.header));for(let i of r.lines){if(l>=CR&&!FR.has(n)){u=!0;break}let r=V(`div`,`review-line review-line-${i.type}`),a=i.type===`add`?`+`:i.type===`del`?`-`:i.type===`meta`?`\\`:` `;r.append(V(`span`,`review-line-gutter`,a)),r.append(V(`span`,`review-line-text`,i.text));let o=NE(e,i);if(c.append(r),l++,!o)continue;let s=jE(t,o.path,o.line,o.side),d=$R.get(s)??{target:o,section:t,rows:[]};d.rows.push(r),$R.set(s,d),r.dataset.noteKey=s;let f=V(`button`,`review-annotate`,`note`);f.type=`button`,f.title=`Note on ${o.path}:${o.line}`,f.addEventListener(`click`,()=>aB(s)),r.append(f),nB(r,s)}if(u)break}if(u){let e=V(`button`,`review-expand`,`Show the rest of this file`);e.type=`button`,e.addEventListener(`click`,()=>{FR.add(n),pB()}),c.append(e)}return i.append(c),i}function vB({id:e,label:t,shortcut:n,title:r,disabled:i=!1,danger:a=!1,onClick:o}){let s=V(`button`,a?`review-btn review-btn-danger`:`review-btn review-btn-primary`);return s.type=`button`,e&&(s.id=e),r&&(s.title=r),s.disabled=i,s.innerHTML=n?`${t} <kbd class="review-shortcut" aria-hidden="true">${n}</kbd>`:t,s.addEventListener(`click`,o),s}function yB(e,{status:t,reviewable:n,mergeAction:r,live:i,state:a,effectiveBase:o,primaryAction:s}){let c=V(`div`,`review-actions`),l=s===`resolve`;s===`merge`&&c.append(vB({id:`review-merge-btn`,label:`Merge`,shortcut:wR,title:oR(o,wR),disabled:!r.isEnabled,onClick:()=>Az(e,a)})),l&&c.append(vB({label:`Resolve`,shortcut:TR,title:`Paste a resolve prompt into this session so the agent can finish the merge (${TR})`,onClick:()=>{B({type:`resolve-session-merge`,id:e}),JR=!0,YR=e,clearTimeout(XR??void 0),XR=setTimeout(()=>{JR=!1,YR=null,pB()},3e3),pB()}}));let u=V(`div`,`review-action-controls`);if(u.append(c),!n||i)return c.childElementCount>0?u:null;let d=lz(`More review actions`,`M3 8h0.01M8 8h0.01M13 8h0.01`);if(d.classList.add(`review-more-button`),d.setAttribute(`aria-haspopup`,`menu`),d.setAttribute(`aria-expanded`,String(qR)),d.setAttribute(`aria-controls`,`review-more-menu`),d.addEventListener(`click`,()=>{qR=!qR,pB(),(zR?.querySelector(qR?`.review-more-menu button:not(:disabled)`:`.review-more-button`)??zR?.querySelector(`.review-more-button`))?.focus()}),c.append(d),!qR)return u;let f=V(`div`,`review-more-menu`);if(f.id=`review-more-menu`,f.setAttribute(`role`,`menu`),f.setAttribute(`aria-label`,`More review actions`),n&&!i){let n=vB({label:`Discard worktree`,danger:!0,disabled:t===`merging`,onClick:()=>{qR=!1,pB(),af({title:`Discard worktree`,message:`Throw away the worktree changes for "${Vz(U.get(e),e)}"? This cannot be undone.`,confirmLabel:`Discard`,onConfirm:()=>B({type:`discard-session-worktree`,id:e})})}});n.setAttribute(`role`,`menuitem`),f.append(n)}return u.append(f),u}var bB=1e4,xB=null,SB=null,CB=null,wB=null,TB=[],EB=!1,DB=_F(),OB=null,kB=null,AB=[],jB=null,MB=null,Z=null,NB=null,PB=!1;function FB(){return!!xB&&!kd(xB)}function IB(){return AB.find(e=>e.id===jB)??null}function LB(){NB&&=(clearTimeout(NB.timeoutHandle),null)}function RB(){NB=null,cV()}function zB(e){LB(),PB=!1,jB=e,Z=e?{sessionId:e,grouping:nO(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,EB=!0}function BB(e){let t=gO(AB,MB,jB,e);return MB&&t===MB&&(MB=null),t!==jB&&(zB(t),!0)}function VB(e){if(!OB)return;let t=e.endingAt===void 0?{type:`session-trace`,id:e.id,after:e.after}:{type:`session-trace`,id:e.id,endingAt:e.endingAt};OB(t)&&(NB={request:e,timeoutHandle:setTimeout(RB,bB)})}function HB(e=!1){if(!OB)return;let t=_O({selectedSessionId:jB,isPanelVisible:e||FB(),hasPendingRequest:!!NB,hasLoadedOnce:Z?.hasLoadedOnce??!1,nextOffset:Z?.nextOffset??0});t&&VB(t)}function UB(){return{selectedSessionId:jB,hasPendingRequest:!!NB,hasLoadedOnce:Z?.hasLoadedOnce??!1,hasDroppedEarliestRows:Z?.hasDroppedEarliestRows??!1,firstOffset:Z?.firstOffset??0,residentRowCount:Z?uO(Z.grouping):0}}function WB(){if(!OB)return;let e=yO(UB());e&&VB(e)}function GB(e){AB.some(t=>t.id===e)&&e!==jB&&(MB=null,zB(e),HB(),cV())}function KB(){let e=V(`label`,`trace-session-field`),t=V(`span`,`trace-session-label`,`Session`),n=V(`select`,`trace-session-select`);n.disabled=AB.length===0;for(let e of AB){let t=V(`option`,null,e.label);t.value=e.id,t.selected=e.id===jB,n.append(t)}return n.addEventListener(`change`,()=>GB(n.value)),e.append(t,n),e}function qB(e){e.toggleAttribute(`data-hidden`,wO(DB,e.dataset.kind??``))}function JB(){if(CB)for(let e of CB.querySelectorAll(`.trace-row`))qB(e)}function YB(e){if(CB)for(let t of CB.querySelectorAll(`details`))t.open=e}function XB(){let e=V(`div`,`trace-filters`);for(let t of KD){let n=V(`button`,`trace-filter`,t.label);n.type=`button`;let r=()=>{n.setAttribute(`aria-pressed`,String(!wO(DB,t.kind)))};r(),n.addEventListener(`click`,()=>{DB=CO(DB,t.kind),vF(DB),r(),JB()}),e.append(n)}for(let[t,n]of[[`Expand all`,!0],[`Collapse all`,!1]]){let r=V(`button`,`trace-expand-control`,t);r.type=`button`,r.addEventListener(`click`,()=>{YB(n)}),e.append(r)}return e}function ZB(){let e=Ed(`trace`,`Session trace`,`Bodies load from the local trace file only when requested.`),t=V(`div`,`trace-controls`);t.append(KB());let n=Z?.filePath??``,r=V(`code`,`trace-path`,n);r.title=n,t.append(r);let i=Z?SO(Z.firstOffset,Z.hasDroppedEarliestRows,Z.grouping.turns[0]):null;return i!==null&&t.append(V(`span`,`trace-session-start`,`Started ${new Date(i).toLocaleString()}`)),e.append(t,XB()),e}function QB(e){let t=V(`div`,`trace-copy-wrap`),n=V(`button`,`trace-copy`,`Copy`);n.type=`button`;let r=V(`span`,`trace-copy-status`);return r.setAttribute(`role`,`status`),n.addEventListener(`click`,()=>{let t=Ad(e);if(!t){r.textContent=`Copy failed`;return}t.then(()=>{r.textContent=`Copied`}).catch(()=>{r.textContent=`Copy failed`}),setTimeout(()=>{r.textContent=``},1600)}),t.append(n,r),t}function $B(){let e=V(`div`,`trace-earlier-wrap`),t=V(`button`,`trace-load-earlier`,`Load earlier`);return t.type=`button`,t.addEventListener(`click`,()=>{WB()}),e.append(t),e}function eV(e,t,n=``){let r=V(`details`,`trace-row${n?` ${n}`:``}`);r.dataset.kind=e.kind,r.dataset.tone=e.tone,qB(r);let i=V(`summary`,`trace-row-summary`);i.append(V(`span`,`trace-offset`,oD(t,e.record.ts)),V(`span`,`trace-kind`,e.tag),V(`span`,`trace-row-label`,e.text));for(let t of e.badges){let e=V(`span`,`trace-badge`,t);e.dataset.badge=t,i.append(e)}let a=V(`div`,`trace-row-body`);r.append(i,a);let o=!1;return r.addEventListener(`toggle`,()=>{if(!r.open||o)return;o=!0;let t=WD(e.record);a.append(QB(t),V(`pre`,`trace-row-pre`,t))}),r}function tV(e){return V(`span`,`trace-turn-metrics`,iO(e))}function nV(e,t){e&&t&&(t.textContent=iO(e))}function rV(e,t){let n=e.children,r=Math.min(t.rows.length,n.length);for(let e=0;e<r;e+=1){let r=n[e]?.querySelector(`.trace-offset`);r&&(r.textContent=oD(t.startedAt,t.rows[e].record.ts))}}function iV(e,t,n){let r=eV(t,e.startedAt,`trace-turn-head`);return bd(r,`.trace-row-summary`).append(n),r}function aV(e){let t=V(`section`,`trace-turn`),n=tV(e);if(e.head&&t.append(iV(e,e.head,n)),!e.head){let e=V(`h2`,`trace-leading-title`);e.append(V(`span`,`trace-leading-label`,`Before first prompt`),n),t.append(e)}let r=V(`div`,`trace-rows`);for(let t of e.rows)r.append(eV(t,e.startedAt));return e.hasTrimmedRows&&t.append(V(`p`,`trace-trimmed`,`Earlier rows trimmed`)),t.append(r),{section:t,rowsElement:r,metricsElement:n}}function oV(e){return e?NB?.request.id===e.id&&!Z?.hasLoadedOnce?`Loading trace.`:TO(e):TO(null)}function sV(){if(!xB)return;let e=V(`div`,`trace-content`);SB=ZB(),e.append(SB),CB=null,wB=null,TB=[];let t=IB(),n=Z?.grouping.turns??[];if(!t||n.length===0){e.append(V(`p`,`trace-empty`,oV(t))),xB.replaceChildren(e),EB=!1;return}vO(UB())&&(wB=$B(),e.append(wB));let r=V(`div`,`trace-turns`);for(let e of n){let t=aV(e);TB.push(t),r.append(t.section)}CB=r,JB(),e.append(r),xB.replaceChildren(e),EB=!1}function cV(){if(xB){if(!FB()){EB=!0;return}sV()}}function lV(){if(!SB||!FB())return;let e=ZB();SB.replaceWith(e),SB=e}function uV(e){if(!CB)return;let t=Z?.grouping.turns[e.turnIndex];if(!t)return;if(e.isNewTurn){let e=aV(t);TB.push(e),CB.append(e.section);return}let n=TB[e.turnIndex];if(n){for(let r of e.rows)n.rowsElement.append(eV(r,t.startedAt));nV(t,n.metricsElement)}}function dV(e){let t=e.parentElement;t&&!t.querySelector(`.trace-trimmed`)&&t.insertBefore(V(`p`,`trace-trimmed`,`Earlier rows trimmed`),e)}function fV(){if(!vO(UB())){wB?.remove(),wB=null;return}!wB&&CB?.parentElement&&(wB=$B(),CB.parentElement.insertBefore(wB,CB))}function pV(){if(!Z)return;let e=mO(Z.grouping);if(!(e.droppedTurnCount>0||e.droppedRowCount>0)){fV();return}let t=!Z.hasDroppedEarliestRows;if(Z.hasDroppedEarliestRows=!0,TB=TB.slice(e.droppedTurnCount),CB)for(let t=0;t<e.droppedTurnCount;t+=1)CB.firstElementChild?.remove();let n=TB[0];if(n&&e.droppedRowCount>0){for(let t=0;t<e.droppedRowCount;t+=1)n.rowsElement.firstElementChild?.remove();dV(n.rowsElement),nV(Z.grouping.turns[0],n.metricsElement)}t&&lV(),fV()}function mV(e){if(!Z)return;let t=sO(Z.grouping,e);if(FB()&&!EB&&CB){for(let e of t)uV(e);pV();return}if(CB=null,pV(),!FB()){EB=!0;return}sV()}function hV(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.id!=`string`||!Array.isArray(t.records)||typeof t.next!=`number`||typeof t.start!=`number`?null:{id:t.id,records:t.records,start:t.start,next:t.next,reset:t.reset===!0,path:typeof t.path==`string`?t.path:``}}function gV(){PB&&!NB&&(PB=!1,HB())}function _V(e){if(!CB)return;let t=TB[0]??null,n=t?.rowsElement.parentElement??null,r=Z?.grouping.turns[e.newTurns.length]??null;if((e.mergedHead||e.mergedRows.length>0)&&t&&n&&r){let i=t.rowsElement;if(e.mergedHead){n.querySelector(`.trace-leading-title`)?.remove();let a=tV(r),o=iV(r,e.mergedHead,a);n.insertBefore(o,i),t.metricsElement=a}e.mergedHead||nV(r,t.metricsElement);let a=document.createDocumentFragment();for(let t of e.mergedRows)a.append(eV(t,r.startedAt));i.prepend(a),rV(i,r)}let i=document.createDocumentFragment(),a=[];for(let t of e.newTurns){let e=aV(t);a.push(e),i.append(e.section)}CB.prepend(i),TB.unshift(...a)}function vV(e){if(!Z)return;let t=cO(Z.grouping,e),n=FB()&&!EB&&!!CB&&!t.needsRerender,r=xB?.parentElement??null,i=r?.scrollHeight??0,a=r?.scrollTop??0;n&&_V(t),pV(),n||cV(),n&&lV(),r&&(r.scrollTop=a+r.scrollHeight-i)}function yV(e){xB||(xB=V(`div`,`trace-panel`),e.append(xB),sV())}function bV(e){OB=e}function xV(e){kB=e}function SV(e){MB=e,kB?.()}function CV(e){AB=hO(e);let t=BB(FB());t&&HB(),(t||!SB)&&cV(),!t&&SB&&lV()}function wV(){if(!xB)return;let e=BB(!0);HB(!0),xO({hasSelectionChanged:e,isRenderedTraceStale:EB,hasRenderedOnce:!!SB})&&sV()}function TV(e){let t=hV(e);if(!t)return;let n=bO({pendingRequest:NB?.request??null,resident:Z?{sessionId:Z.sessionId,firstOffset:Z.firstOffset,nextOffset:Z.nextOffset,hasLoadedOnce:Z.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});if(n===`ignore`){gV();return}if(LB(),n===`stale`){gV();return}if(n===`reset`){zB(t.id),Z&&(Z.filePath=t.path),HB(),cV(),gV();return}if(Z){if(Z.filePath=t.path,n===`prepend`){Z.firstOffset=t.start,vV(t.records),gV();return}n===`seed`&&(Z.hasLoadedOnce=!0,Z.firstOffset=t.start),Z.nextOffset=t.next,mV(t.records),gV()}}function EV(e){let t=e?.id;if(typeof t==`string`&&t===jB&&FB()){if(NB){PB=!0;return}HB()}}function DV(e){let t=e?.id;typeof t==`string`&&NB?.request.id===t&&(LB(),PB=!1,cV())}function OV(e){if(LB(),PB=!1,!e){cV();return}HB()}function kV(e){let{waiting:t,failed:n,done:r,complete:i,dormant:a,total:o}=e,s=e=>e>1?`s`:``,c=r+i,l=t+n;return t>0?{text:`${t} session${s(t)} need input`,severity:`warning`,alertCount:l}:n>0?{text:`${n} session${s(n)} failed`,severity:`critical`,alertCount:l}:o>0&&c===o?{text:`All sessions exited`,severity:`done`,alertCount:l}:o>0&&a===o?{text:`${a} session${s(a)} dormant`,severity:``,alertCount:l}:{text:``,severity:``,alertCount:l}}var AV=!1,jV=new Set;function MV(e){AV=!!e,nH();for(let e of jV)e(AV)}function NV(e){return jV.add(e),()=>jV.delete(e)}function PV(){return AV}var FV=[{cls:`agent-badge`,title:`Agent CLI this session supervises`},{cls:`worktree-badge`,text:`worktree`,title:`Running in a linked git worktree`,ariaLabel:`Linked git worktree`},{cls:`post-turn-badge`,ariaHidden:!0},{cls:`usage-badge`,title:`Tokens and estimated API list-price cost for this conversation`},{cls:`wakeup-badge`},{cls:`prompt-badge`,title:`Waiting on a permission or input prompt`}];function IV({cls:e,text:t=``,title:n,ariaLabel:r,ariaHidden:i}){let a=V(`span`,e,t);return n&&(a.title=n),r&&a.setAttribute(`aria-label`,r),i&&a.setAttribute(`aria-hidden`,`true`),a}function LV(e,t){e.textContent=t?`SANE YOLO`:`YOLO`,e.title=t?`Skips permission prompts; Sane YOLO blocks catastrophic commands`:`Running with --dangerously-skip-permissions`}function RV(e,t){t&&(e.dataset.saneYolo=``),t||delete e.dataset.saneYolo;let n=e.querySelector(`.perms-badge`);n&&LV(n,t)}function zV(e,t){let n=Qd(e);n&&RV(n.card,t)}function BV(e,t,n,r={}){let i=n||I.INITIALIZING,a=V(`div`,`session-card`);a.dataset.id=e,a.dataset.session=t,a.dataset.state=i,r.skipPerms&&(a.dataset.skipPerms=``),r.saneYolo&&(a.dataset.saneYolo=``),r.worktree&&(a.dataset.worktree=``),r.workspace&&(a.dataset.workspace=``),r.path&&(a.dataset.path=String(r.path));let o=V(`div`,`session-card-header`),s=V(`span`,`session-name`,t);s.title=`Double-click or press F2 to rename`,s.tabIndex=0;let c=r.skipPerms?V(`span`,`perms-badge`):null;c&&LV(c,r.saneYolo===!0);let l=V(`span`,`session-task-title`);UV(l,r.taskTitle);let u=V(`span`,`card-elapsed`);u.setAttribute(`aria-hidden`,`true`);let d=V(`div`,`session-actions`),f=V(`div`,`session-overflow`),p=V(`button`,`btn-action btn-restart-menu visible`,`↻`);p.type=`button`,p.title=`Restart`,p.setAttribute(`aria-label`,`Restart`),p.setAttribute(`aria-haspopup`,`menu`),p.setAttribute(`aria-expanded`,`false`);let m=V(`div`,`session-overflow-menu`);m.id=`restart-menu-${e}`,m.setAttribute(`role`,`menu`),p.setAttribute(`aria-controls`,m.id);let h=VV(`Restart`,`Keeps this conversation`,`overflow-restart`),g=VV(`Restart fresh`,`Ends this conversation and starts a new one`,`overflow-restart-fresh`),_=VV(`Resume conversation...`,`Pick an earlier conversation`,`overflow-resume`);m.append(h,g,_),f.append(p,m);let v=V(`button`,`btn-action btn-debug`,`⚙`);v.title=`Debug state`,v.setAttribute(`aria-label`,`Debug session state`);let y=V(`button`,`btn-action btn-trace`,`≡`);y.type=`button`,y.title=`Trace`,y.setAttribute(`aria-label`,`Trace`);let b=V(`button`,`btn-action btn-remove visible`,`×`);b.type=`button`,b.title=`Remove session`,b.setAttribute(`aria-label`,`Remove session`);let x=V(`button`,`btn-action btn-face-plan`,`Plan`);x.type=`button`,x.title=`Show plan`,d.append(x,v,y,f,b);let ee=V(`div`,`session-card-tags`),te=FV.map(e=>IV(e));c&&te.push(c),ee.append(...te),o.append(s,u,l,ee,d);let ne=V(`div`,`terminal-wrap`);return a.append(o,ne),{card:a,header:o,nameEl:s,elapsedEl:u,taskTitleEl:l,btnRestart:h,btnRestartFresh:g,btnRestartMenu:p,btnResume:_,btnTrace:y,btnRemove:b,btnPlan:x,btnDebug:v,restartMenu:m,termWrap:ne}}function VV(e,t,n){let r=V(`button`,`overflow-item ${n}`);return r.type=`button`,r.setAttribute(`role`,`menuitem`),r.setAttribute(`aria-label`,e),r.append(V(`span`,`restart-menu-label`,e),V(`span`,`restart-menu-hint`,t)),r}function HV(e,t){e.tabIndex=0,e.setAttribute(`role`,`button`),e.addEventListener(`click`,t),e.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())})}function UV(e,t){e.title=t??``,t&&e.removeAttribute(`aria-label`),t||e.setAttribute(`aria-label`,`Describe the task`),!e.querySelector(`input`)&&(e.textContent=t??``)}function WV(e,t){let n=e.titleTargetEl?.isConnected?e.titleTargetEl:e.taskTitleEl;if(n.querySelector(`input`))return;let r=document.createElement(`input`);r.type=`text`,r.className=`session-title-input`,r.setAttribute(`aria-label`,`Task`),r.value=e.taskTitleIsCustom?e.taskTitle??``:``,r.placeholder=e.taskTitle??`What is this session working on?`,r.maxLength=120;let i=n.getAttribute(`role`),a=n.getAttribute(`tabindex`);n.removeAttribute(`role`),n.removeAttribute(`tabindex`),n.replaceChildren(r),r.focus(),r.select();function o(o){r.removeEventListener(`blur`,s),r.removeEventListener(`keydown`,c),o&&B({type:`set-session-title`,id:t,title:r.value.trim()}),n.replaceChildren(),i!==null&&n.setAttribute(`role`,i),a!==null&&n.setAttribute(`tabindex`,a),UV(n,e.taskTitle)}function s(){o(!0)}function c(e){e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),o(!0)),e.key===`Escape`&&(e.preventDefault(),o(!1))}r.addEventListener(`blur`,s),r.addEventListener(`keydown`,c)}var GV=`session-rename-input`;function KV(e){return!!e?.querySelector(`.${GV}`)}function qV(e,t){let n=e.renameTargetEl?.isConnected?e.renameTargetEl:e.nameEl;if(!n||KV(n))return;let r=e.card?.dataset.session??n.textContent??``;function i(){let t=e.card?.dataset.session??r;n.textContent=t,e.nameEl&&e.nameEl!==n&&(e.nameEl.textContent=t)}let a=document.createElement(`input`);a.type=`text`,a.className=GV,a.value=r,a.maxLength=64,n.textContent=``,n.appendChild(a),a.focus(),a.select();function o(){let n=a.value.trim();if(c(),!n||n===r){i();return}for(let[,t]of U)if(t!==e&&t.card.dataset.session===n){i(),zx(`Session "${n}" already exists.`);return}B({type:`rename-session`,id:t,newName:n}),i()}function s(){c(),i()}function c(){a.removeEventListener(`blur`,o),a.removeEventListener(`keydown`,l)}function l(e){e.key===`Enter`&&(e.preventDefault(),o()),e.key===`Escape`&&(e.preventDefault(),s()),e.stopPropagation()}a.addEventListener(`blur`,o),a.addEventListener(`keydown`,l)}var JV=`<button type="button" class="debug-close" aria-label="Close debug overlay" title="Close">×</button>`;function YV(e){return e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):`-`}function XV(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function ZV(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${XV(e.quietMs)})`:``}function QV(e){let t=`<span class="debug-dim">${YV(e.ts)}</span>`;if(e.kind===`signal`){let n=Nd([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${Nd(e.event||``)}</span>`:e.action===`gate-held`?`${t} ${n} → held <span class="debug-dim">(${Number(e.active)||0} bg)</span>`:`${t} ${n} → <span class="debug-dim">no-op</span>`}if(e.kind===`gate`){let n=(e.repeats??0)>1?` <span class="debug-dim">x${Number(e.repeats)}</span>`:``,r=ZV(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${Nd(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=Nd(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${Nd(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${Nd(e.category||`?`)}: <span class="debug-dim">${Nd(e.from||`?`)} → ${Nd(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${Nd(e.kind||`decision`)}</span>`}function $V(e,t){if(!e.debugOverlay)return;let n=t,r=JV;if(r+=`<div class="debug-section"><div class="debug-section-title">State</div>`,r+=`<div class="debug-field"><span class="debug-label">Current:</span> <span class="debug-value">${Nd(n.state)}</span></div>`,r+=`</div>`,r+=`<div class="debug-section"><div class="debug-section-title">Transitions (last ${n.transitions.length})</div>`,n.transitions.length===0&&(r+=`<div class="debug-field debug-dim">No transitions recorded</div>`),n.transitions.length>0)for(let e of n.transitions){let t=e.detail&&typeof e.detail==`object`?e.detail:null,n=t?[t.signal,t.source,t.deferred?`deferred`:null].filter(Boolean):[],i=n.length>0?` <span class="debug-dim">${Nd(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${YV(e.timestamp)}</span> ${Nd(e.from)} → ${Nd(e.to)} <span class="debug-label">${Nd(e.event)}</span>${i}</div>`}r+=`</div>`;let i=n.detection||{},a=i.lastSignal,o=i.titleState||{};r+=`<div class="debug-section"><div class="debug-section-title">Detection</div>`,r+=`<div class="debug-field"><span class="debug-label">Last signal:</span> <span class="debug-value">${a?`${Nd(a.signal)} (${Nd(a.source||`?`)}${a.confidence?`/${Nd(a.confidence)}`:``})`:`none`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Hooks injected:</span> <span class="debug-value">${i.hooksInjected?`yes`:`no`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Hook seen:</span> <span class="debug-value">${i.hookSeen?`yes`:`no (degraded → title)`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Title state:</span> <span class="debug-value">${Nd(o.lastKind||`none`)}${o.hasSeenSpinner?` · spun`:``}</span></div>`,r+=`</div>`;let s=i.agents||{},c=i.gate;r+=`<div class="debug-section"><div class="debug-section-title">Agents</div>`,r+=`<div class="debug-field"><span class="debug-label">Active:</span> <span class="debug-value">${Number(s.active)||0} (counted ${Number(s.counted)||0}, declared ${Number(s.declared)||0})</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Idle:</span> <span class="debug-value">${Number(s.idleNames)||0} names, ${Number(s.idleTasks)||0} tasks</span></div>`;let l=c?`held ${XV(c.heldForMs)} (seq ${Number(c.seq)||0}, lastActivity ${Number(c.lastActivitySeq)||0})`:`none`;r+=`<div class="debug-field"><span class="debug-label">Gate:</span> <span class="debug-value">${Nd(l)}</span></div>`,r+=`</div>`;let u=Array.isArray(n.decisions)?n.decisions:[];r+=`<div class="debug-section"><div class="debug-section-title">Decisions (last ${u.length})</div>`,u.length===0&&(r+=`<div class="debug-field debug-dim">No decisions recorded</div>`);for(let e of u)r+=`<div class="debug-field">${QV(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r}function eH(e,t){if(e.debugOpen){tH(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`${JV}<div class="debug-field debug-dim">Loading...</div>`,e.card.appendChild(n),e.debugOverlay=n,e.debugOpen=!0,n.addEventListener(`click`,t=>{t.stopPropagation(),t.target instanceof Element&&t.target.closest(`.debug-close`)&&tH(e)}),B({type:`debug-state`,id:t})}function tH(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function nH(){for(let[,e]of U)e.btnDebug.classList.toggle(`visible`,AV),e.btnTrace.classList.toggle(`visible`,AV),!AV&&e.debugOpen&&tH(e)}function rH(e){let t=typeof e.id==`string`?U.get(e.id):void 0;t?.debugOpen&&$V(t,e.payload)}function iH(e){Qd(e)?.debugOpen&&B({type:`debug-state`,id:e})}function aH({hasPlan:e,pendingPromptKind:t,hasOpenReview:n,hasApprovedReview:r=!1}){return e&&(n||t===`plan`&&!r)?`plan`:`terminal`}function oH({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}var sH=`DORMANT`;function cH(e){if(!e)return``;let t=Math.max(0,Math.round((Date.now()-e)/1e3));if(t<60)return`just now`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function lH(e,t,n){let r=V(`button`,`resume-item`);r.type=`button`,r.setAttribute(`role`,`option`),e.id===t&&r.classList.add(`resume-item-current`);let i=[e.worktreeName,e.gitBranch?e.gitBranch.replace(/^refs\/heads\//,``):null,cH(e.mtime)].filter(Boolean).join(` · `);return r.innerHTML=`<span class="resume-item-title">${Nd(e.title||e.id)}</span><span class="resume-item-meta">${Nd(i)}${e.id===t?` · current`:``}</span>`,r.addEventListener(`click`,()=>n(e.id)),r}function uH(e,t={}){let n=(t.currentState||``)===sH,{overlay:r,dialog:i,close:a,actions:o,btnCancel:s}=rf({title:`Resume a conversation`,dialogClass:`dialog resume-dialog`}),c=V(`p`,`dialog-message`,`Pick a Claude conversation from this repo (any worktree) to continue in this card.`),l=V(`div`,`resume-list`);l.setAttribute(`role`,`listbox`),l.setAttribute(`aria-label`,`Resumable conversations`),l.append(V(`div`,`resume-empty`,`Loading conversations...`));let u=V(`button`,`btn-dialog btn-dialog-cancel`,`Start fresh`);u.title=`Clear any resume binding so this card starts a new conversation`,o.prepend(u),i.append(c,l,o);function d(t){if(B({type:`resume-conversation`,id:e,conversationId:t||``}),a(),t){if(!n){zx(`Conversation will resume on this session's next restart.`);return}B({type:`start-session`,id:e})}}s.addEventListener(`click`,a),u.addEventListener(`click`,()=>d(null)),requestAnimationFrame(()=>s.focus()),dd(`list-conversations`,{id:e}).then(e=>{if(!r.isConnected)return;let t=e.type===`conversations`?e.conversations:[];if(l.innerHTML=``,e.error){l.append(V(`div`,`resume-empty`,`Could not list conversations: ${e.error}`));return}if(t.length===0){l.append(V(`div`,`resume-empty`,`No prior conversations found for this repo.`));return}let n=e.type===`conversations`?e.current??null:null;for(let e of t)l.append(lH(e,n,d))}).catch(e=>{if(!r.isConnected)return;l.innerHTML=``;let t=e instanceof Error?e.message:String(e);l.append(V(`div`,`resume-empty`,`Could not list conversations: ${t}`))})}var dH={critical:`✕`,warning:`▲`,done:`✓`,"":`▸`},fH=null,pH=null,mH=e=>e==null?``:String(e),hH=e=>jc.includes(e),gH=e=>Mc.includes(e);function _H(e){let t=e.currentState,n=hH(t)||gH(t);e.btnRestart.classList.toggle(`visible`,n),e.btnRestartFresh.classList.toggle(`visible`,n),e.btnResume.classList.add(`visible`),e.btnTrace.classList.toggle(`visible`,PV()),e.btnPlan.classList.toggle(`visible`,oH(e)!==`hidden`),e.btnRemove.classList.add(`visible`)}function vH(e){e.restartMenu.classList.remove(`open`),e.btnRestartMenu.setAttribute(`aria-expanded`,`false`)}function yH(e,t){HV(e.taskTitleEl,()=>WV(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),qV(e,t)}),e.nameEl.addEventListener(`click`,()=>{KV(e.nameEl)||bR(t)}),e.nameEl.addEventListener(`keydown`,n=>{n.target===e.nameEl&&(n.key===`F2`||n.key===`Enter`)&&(n.preventDefault(),qV(e,t))});function n(n){vH(e),e.btnRestartMenu.focus(),lf(n,t,{readState:()=>e.currentState,send:B,confirm:af})}e.btnRestart.addEventListener(`click`,()=>n(`restart`)),e.btnRestartFresh.addEventListener(`click`,()=>n(`restart-fresh`)),e.btnResume.addEventListener(`click`,()=>{vH(e),uH(t,{currentState:e.currentState})}),e.btnTrace.addEventListener(`click`,()=>{vH(e),SV(t)}),e.btnPlan.addEventListener(`click`,()=>{let n=oH(e);if(n!==`hidden`){if(n===`face`){kH(t);return}location.hash=WL(t)}}),e.btnRemove.addEventListener(`click`,()=>{vH(e);let n=e.card.dataset.session,r=e.card.dataset.merge,i=r===`pending-review`||r===`parked`;af({title:`Remove Session`,message:i?`"${n}" has unmerged worktree changes that will be permanently discarded if you remove it. Merge or review them first to keep them. Remove anyway?`:`Remove session "${n}"?`,confirmLabel:i?`Discard & Remove`:`Remove`,onConfirm:()=>B({type:`remove-session`,id:t})})}),e.btnRestartMenu.addEventListener(`click`,t=>{t.stopPropagation();for(let[,t]of U)t!==e&&vH(t);let n=e.restartMenu.classList.toggle(`open`);e.btnRestartMenu.setAttribute(`aria-expanded`,String(n))});let r=[e.btnRestart,e.btnRestartFresh,e.btnResume];function i(t){if(t.key!==`ArrowDown`&&t.key!==`ArrowUp`)return;t.preventDefault(),t.stopPropagation();for(let[,t]of U)t!==e&&vH(t);e.restartMenu.classList.add(`open`),e.btnRestartMenu.setAttribute(`aria-expanded`,`true`);let n=r.filter(e=>e.classList.contains(`visible`)),i=document.activeElement,a=i instanceof HTMLButtonElement?n.indexOf(i):-1;n[((t.key===`ArrowDown`?a+1:a<0?n.length-1:a-1)+n.length)%n.length]?.focus()}e.btnRestartMenu.addEventListener(`keydown`,i),e.restartMenu.addEventListener(`keydown`,i),document.addEventListener(`keydown`,t=>{t.key===`Escape`&&e.restartMenu.classList.contains(`open`)&&(t.preventDefault(),vH(e),e.btnRestartMenu.focus())},{signal:e.abortController.signal}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;!e.restartMenu.contains(n)&&n!==e.btnRestartMenu&&vH(e)},{signal:e.abortController.signal}),e.termWrap.addEventListener(`mousedown`,()=>{(e.currentState===I.WAITING||e.currentState===I.COMPLETE)&&B({type:`dismiss`,id:t})}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),eH(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&tH(e)},{signal:e.abortController.signal})}function bH(e,t,n){let r=Qd(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&UV(e,r.taskTitle)}}function xH(e){return typeof e==`string`&&U.has(e)}function SH(){return U.size}function CH(){return[...U.keys()]}function wH(e){let t=e||{};t.cursorBlink!=null&&oE(t.cursorBlink),t.debugMode!=null&&(MV(t.debugMode),mI(t.debugMode));for(let[,e]of U)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function TH(){if(!ef)return;let e=0,t=0,n=0,r=0,i=0,a=0;for(let[,o]of U){a++;let s=o.currentState;if(s===I.WAITING){e++;continue}if(s===I.FAILED){t++;continue}if(s===I.DONE){n++;continue}if(s===I.COMPLETE){r++;continue}s===I.DORMANT&&i++}let{text:o,severity:s,alertCount:c}=kV({waiting:e,failed:t,done:n,complete:r,dormant:i,total:a});if((o!==fH||s!==pH)&&(fH=o,pH=s,ef.dataset.severity=s,ef.textContent=``,o)){let e=V(`span`,`aggregate-glyph`,dH[s]??dH[``]);e.setAttribute(`aria-hidden`,`true`),ef.append(e,document.createTextNode(o))}document.title=c>0?`(${c}) Glimmervoid`:`Glimmervoid`}function EH(e,t,n,r={}){if(!$d)return;let i=Zd(e),a=mH(n)||I.DORMANT,o=BV(i,mH(t),a,r),s=a===I.DORMANT;$d.appendChild(o.card);let c;function l(){c.face=`terminal`,c.card.dataset.face=`terminal`,c.termWrap.hidden=!1,c.planFace.hide(),_H(c),DE(c,i)}let u=new AbortController,d=HL({signal:u.signal,requestPlan:(e,t,n)=>B({type:`session-plan`,id:e,agentId:t,revision:n}),requestDraft:(e,t)=>B({type:`session-plan`,id:e,agentId:t,draft:!0}),showTerminal:l,sendDecision:(e,t)=>B({type:`plan-decision`,id:e,...t}),reportProblem:e=>zx(`${o.nameEl.textContent||i}: ${e}`)});return c={term:null,fitAddon:null,webglAddon:null,needsWebGLReload:!1,webglAttachedWithoutLayout:!1,dataWs:null,card:o.card,nameEl:o.nameEl,taskTitleEl:o.taskTitleEl,taskTitle:r.taskTitle??null,taskTitleIsCustom:r.taskTitleIsCustom??!1,hasEndedTurn:!1,elapsedEl:o.elapsedEl,path:mH(r.path),stateSince:typeof r.stateSince==`number`&&Number.isFinite(r.stateSince)?r.stateSince:Date.now(),restartMenu:o.restartMenu,termWrap:o.termWrap,btnDebug:o.btnDebug,btnRestart:o.btnRestart,btnRestartFresh:o.btnRestartFresh,btnRestartMenu:o.btnRestartMenu,btnResume:o.btnResume,btnTrace:o.btnTrace,btnPlan:o.btnPlan,btnRemove:o.btnRemove,debugOverlay:null,debugOpen:!1,abortController:u,currentState:a,face:`terminal`,isBorrowed:!1,hasPlan:!1,pendingPromptKind:null,pendingPromptDetail:null,planReviewState:{reviews:[]},planFace:d},c._ensureTerminalReady=()=>DE(c,i),c._showTerminalFace=l,c._showPreferredFace=()=>{if(DH(c)===`plan`){kH(i);return}l()},c._setBorrowed=e=>{c.isBorrowed=e,_H(c)},o.card.append(d.el),U.set(i,c),yH(c,i),_H(c),a===I.RUNNING&&gf(c,!0),s||(bE(o.termWrap,c),wE(c,i)),TH(),c}function DH(e){let t=e.planReviewState.reviews.some(e=>e.state===`open`),n=e.planReviewState.reviews.some(pL);return aH({hasPlan:e.hasPlan,pendingPromptKind:e.pendingPromptKind,hasOpenReview:t,hasApprovedReview:n})}function OH(e){let t=Qd(e);return!t?.isBorrowed||DH(t)!==`plan`?!1:kH(e)}function kH(e){let t=Qd(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.planFace.show(Zd(e)),_H(t),!0)}function AH(e,t){let n=Qd(e);n&&(n.hasPlan=t===!0,_H(n),OH(e))}function jH(e){let t=Qd(e.id);t&&(t.planReviewState=AL(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),_H(t),OH(e.id))}function MH(e){let t=Qd(e.id);t&&t.planFace.update({draft:e})}function NH(e){let t=Qd(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),_H(t))}function PH(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return;let t=Qd(e.id);if(t){if(e.scope===`plan`){t.planFace.update({requestFailed:!0});return}t.planFace.update({decisionRefused:!0})}}function FH(e){for(let[,t]of U)t.planFace.update({isConnected:e})}function IH(e,t){let n=Qd(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function LH(e,t){let n=Qd(e);if(!n)return;n.agent=typeof t==`string`?t:null;let r=lN(t);zH(n,`.agent-badge`,`agent`,{on:r!==``,value:r,text:r})}function RH(e,t){let n=Qd(e);if(n){if(t){n.card.dataset.worktree=``;return}delete n.card.dataset.worktree}}function zH(e,t,n,r){let{on:i,value:a=``,text:o,title:s}=r,c=e.card.querySelector(t);if(!i){if(delete e.card.dataset[n],!c)return;o!==void 0&&(c.textContent=``),s!==void 0&&c.removeAttribute(`title`);return}e.card.dataset[n]=a,c&&(o!==void 0&&(c.textContent=o),s!==void 0&&(c.title=s))}function BH(e,t){let n=Qd(e);n&&(n.hasEndedTurn=t)}function VH(e,t,n=!1){let r=Qd(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=Cd(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function HH(e,t){let n=Qd(e);if(!n)return;let r=wj(t);zH(n,`.usage-badge`,`usage`,{on:!!r,text:r||``,title:r?Tj(t):void 0})}function UH(e,t,n=null){let r=Qd(e);r&&(r.pendingPromptKind=typeof t==`string`?t:null,r.pendingPromptDetail=n,zH(r,`.prompt-badge`,`prompt`,{on:!!t,value:mH(t),text:t===`plan`?`Plan ready`:t===`permission`?`permission`:`input`}),OH(e))}function WH(e){if(!e)return`scheduled`;let t=new Date(e);return`sleeping until ~${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function GH(e,t){let n=Qd(e);n&&zH(n,`.wakeup-badge`,`wakeup`,{on:!!t,value:t?.kind||`wakeup`,text:WH(t?.at),title:t?.reason?`Scheduled revival: ${t.reason}`:`Scheduled revival pending`})}function KH(e,t){let n=Qd(e);if(!n)return;let r=Array.isArray(t.findings)?t.findings:[],i=t.filesFixed||0,a=null,o=0;!t.skipped&&t.mode===`fix`&&i>0&&(a=`fixed`,o=i),!t.skipped&&t.mode===`report`&&r.length>0&&(a=`flagged`,o=new Set(r.map(e=>e.file)).size);let s={};for(let e of r)s[e.rule]=(s[e.rule]||0)+(e.count||0);let c=Object.keys(s).map(e=>`${e}: ${s[e]}`).join(`, `),l=a===`fixed`?`auto-fixed`:`flagged`;zH(n,`.post-turn-badge`,`pt`,{on:!!a,value:a||void 0,text:`${a===`fixed`?`✓`:`⚠`} ${o}`,title:`Post-turn ${l} ${o} file(s)${c?` (${c})`:``}`})}function qH(e,t){if(t===`pending-review`||t===`parked`||t===`merging`){e.dataset.merge=t;return}delete e.dataset.merge}function JH(e,t,n=null){let r=Qd(e),i=mH(t)||`none`;r&&qH(r.card,i),mz(Zd(e),i,mH(n)||null)}function YH(e,t,n=null){let r=Qd(e),i=mH(t)||`none`;r&&qH(r.card,i),hz(Zd(e),i,mH(n)||null)}function XH(e,t){gz(Zd(e),t)}function ZH(e,t){let n=Qd(e);if(!n)return;let r=mH(t);n.card.dataset.session=r,n.nameEl.textContent=r}function QH(e){let t=Qd(e);t&&(tH(t),U.delete(Zd(e)),BL(Zd(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),t.dataWs&&t.dataWs.readyState<=WebSocket.OPEN&&t.dataWs.close(),JT(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),TH())}function $H(e,t,n){if(!t||!e.term)return;e.term.clear(),e.term.reset();let r=n===I.DONE?`Session complete`:`Session failed`,i=n===I.DONE?`\x1B[34m`:`\x1B[31m`;e.term.write(`\r\n\x1b[2m${i} ${r}\x1b[0m\r\n\r\n\x1b[2m Press Restart to start a new session.\x1b[0m\r\n`)}function eU(e,t){e.term&&(t===I.DONE||t===I.FAILED)&&(e.term.clear(),e.term.reset())}function tU(e,t,n){let r=Qd(e);if(!r)return;let i=mH(t),a=r.currentState;r.currentState=i,i!==I.RUNNING&&(r.awaitingBackgroundTasks=!1),i!==a&&(r.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),gf(r,i===I.RUNNING)),a===I.DORMANT&&i!==I.DORMANT&&TE(r,Zd(e)),r.card.dataset.state=i,r.card.toggleAttribute(`data-monitoring`,Cd(i,r.awaitingBackgroundTasks)),_H(r),(i===I.WAITING&&a!==I.WAITING||i===I.COMPLETE&&a!==I.COMPLETE)&&VP()&&kb(UP());let o=i===I.DONE||i===I.FAILED,s=a!==I.DONE&&a!==I.FAILED&&a!==I.INITIALIZING;o&&s&&(r.card.classList.remove(`completion-flash`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{r.card.classList.add(`completion-flash`),r.card.addEventListener(`animationend`,()=>r.card.classList.remove(`completion-flash`),{once:!0})})}),VP()&&kb(UP())),(i===I.DONE||i===I.FAILED)&&$H(r,s,i),i===I.INITIALIZING&&eU(r,a),TH(),xf(r)}var nU=`(no path)`;function rU(e){if(!e)return nU;let t=String(e).replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return(n===-1?t:t.slice(n+1))||`(no path)`}function iU(e,t,n){let r=Array.isArray(e)?e:[],i=new Map;for(let e of r){let n=t(e),r=n?String(n):nU,a=i.get(r);a||(a={key:r,label:r===`(no path)`?nU:rU(r),title:r,rows:[]},i.set(r,a)),a.rows.push(e)}if(n)for(let e of n){if(!e)continue;let t=String(e);t===`(no path)`||i.has(t)||i.set(t,{key:t,label:rU(t),title:t,rows:[]})}let a=[...i.values()];return a.sort((e,t)=>e.label.localeCompare(t.label,void 0,{numeric:!0,sensitivity:`base`})||e.key.localeCompare(t.key)),{flat:i.size<=1,order:a.map(e=>e.key),groups:a}}function aU(e,t){if(!e||!Array.isArray(e.groups))return[];let n=t||new Set,r=[];if(e.flat){for(let t of e.groups)for(let e of t.rows)r.push(e.id);return r}let i=new Map(e.groups.map(e=>[e.key,e]));for(let t of e.order){if(n.has(t))continue;let e=i.get(t);if(e)for(let t of e.rows)r.push(t.id)}return r}function oU(e,t){let n=V(e,t);return n.innerHTML=`<span class="focus-pill-name"></span><span class="focus-pill-badge"><span class="focus-pill-glyph"></span><span class="focus-pill-label"></span></span><span class="focus-pill-merge"></span>`,{pill:n,refs:{glyph:bd(n,`.focus-pill-glyph`),label:bd(n,`.focus-pill-label`),name:bd(n,`.focus-pill-name`),merge:bd(n,`.focus-pill-merge`)}}}function sU(e,t,n,r=!1){e.dataset.state=n;let{glyph:i,label:a,isMonitoring:o}=wd(n,r);return e.toggleAttribute(`data-monitoring`,o),t.glyph.textContent=i,t.label.textContent=a,a}var cU=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),lU=window.matchMedia?.(`(hover: none) and (min-width: 769px)`),uU=null,dU=null,fU=null,pU=null,mU=null,hU=null,gU=null,_U=null,vU=!1,yU=null,bU=new Map,xU=new Map,SU=new Map,CU=new Map,wU=null,TU=new Set;function EU(){return aU(OU(),TU)}function DU(e){let t=wU;if(wU=e||null,t&&t!==wU){let e=xU.get(t);e&&(e.tabIndex=-1,e.setAttribute(`aria-selected`,`false`))}if(wU){let e=xU.get(wU);e&&(e.tabIndex=0,e.setAttribute(`aria-selected`,`true`))}}function OU(){let e=RU();return iU(e,e=>e.ui.path,JF(e,e=>e.ui.path))}function kU(e){let t=CU.get(e.key),n=SU.get(e.key);if(!t||!n){let r=Object.assign(V(`div`,`focus-rail-group`),{_addBtn:V(`button`,`focus-rail-group-add`,`+`),_forgetBtn:V(`button`,`focus-rail-group-remove`,`×`)});r.dataset.key=e.key,r.innerHTML=`<span class="focus-rail-group-label"></span><span class="focus-rail-group-rule" aria-hidden="true"></span>`;let i=r._addBtn;i.type=`button`,i.addEventListener(`click`,()=>XF(r.dataset.path,r.dataset.label));let a=r._forgetBtn;a.type=`button`,a.addEventListener(`click`,()=>{YF(r.dataset.path),GU()}),r.appendChild(a),r.appendChild(i),t=r,n=V(`div`,`focus-rail-list`),n.setAttribute(`role`,`listbox`),CU.set(e.key,t),SU.set(e.key,n)}bd(t,`.focus-rail-group-label`).textContent=e.label,t.title=e.title,t.dataset.path=e.key,t.dataset.label=e.label;let r=e.key===nU,i=e.rows.length===0;return t._addBtn.hidden=r,r||(t._addBtn.title=`Add a session to ${e.label}`,t._addBtn.setAttribute(`aria-label`,`Add a session to ${e.label}`)),t._forgetBtn.hidden=r||!i,!r&&i&&(t._forgetBtn.title=`Remove ${e.label} from the rail`,t._forgetBtn.setAttribute(`aria-label`,`Remove ${e.label} from the rail`)),t.toggleAttribute(`data-empty`,i),n.setAttribute(`aria-label`,`${e.label} sessions`),{header:t,list:n}}function AU(){return vU}function jU(){return mU}function MU(){return Vd.snapshot().focusedSessionId}function NU({rail:e,center:t,resizer:n}){if(uU=e,fU=t,!uU||!fU)return;let r=uU,i=fU;IU(n),r.removeAttribute(`role`),r.removeAttribute(`aria-label`),r.setAttribute(`aria-keyshortcuts`,Zte(Zy)),dU=V(`button`,`focus-rail-head`),dU.type=`button`,dU.append(V(`span`,`focus-rail-head-count`),ene(Yy(`next-attention`,Zy))),dU.addEventListener(`click`,XU),YU(!1,UO(0)),r.append(dU),hU=V(`div`,`focus-empty`),hU.innerHTML=`<p class="focus-empty-title"></p><p class="focus-empty-desc"></p>`,gU=hU.querySelector(`.focus-empty-title`),_U=hU.querySelector(`.focus-empty-desc`),pU=V(`div`,`focus-card-slot`),mU=V(`div`,`focus-header-accessory-slot`),i.append(mU,hU,pU),r.addEventListener(`keydown`,LU)}var PU={minPx:180,maxPx:480},FU=16;function IU(e){e&&uU&&RN({resizer:e,column:uU,widthHost:uU,widthProperty:`--rail-width`,bounds:PU,keyStepPx:FU,getStoredWidth:rF,setStoredWidth:iF})}function LU(e){if(e.key===`Delete`||e.key===`Backspace`){let t=e.target instanceof HTMLElement?e.target:null,n=t?.dataset.id;if(!n||xU.get(n)!==t)return;e.preventDefault(),ZF(n,bU.get(n));return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)return;let t=BO(EU(),wU,e.key===`ArrowDown`?1:-1);t!=null&&(e.preventDefault(),DU(t),xU.get(t)?.focus())}function RU(){return RO([...U.entries()].map(([e,t])=>({id:e,ui:t,name:zU(t),isDormant:(t.currentState||I.DORMANT)===I.DORMANT})))}function zU(e){return e.nameEl?e.nameEl.textContent:e.card&&(e.card.dataset.session||e.card.dataset.id)||``}function BU(e){let{pill:t,refs:n}=oU(`button`,`focus-pill`);t.type=`button`,t.dataset.id=e,t.setAttribute(`role`,`option`);let r=Object.assign(t,{_refs:n,_row:null});r.addEventListener(`click`,()=>VU(e));let i=V(`div`,`focus-pill-row`);i.setAttribute(`role`,`presentation`);let a=V(`button`,`focus-pill-remove`,`×`);return a.type=`button`,a.tabIndex=-1,lU?.matches||a.setAttribute(`aria-hidden`,`true`),a.title=`Remove session`,a.addEventListener(`click`,t=>{t.stopPropagation(),ZF(e,bU.get(e))}),i.append(r,a),r._row=i,r}function VU(e){let t=U.get(e);t&&(t.currentState===I.DORMANT&&B({type:`start-session`,id:e}),HU(e),tW(e))}function HU(e){U.get(e)?.currentState===I.COMPLETE&&B({type:`dismiss`,id:e})}function UU(e,t,n){let r=n.currentState||I.DORMANT,i=e.dataset.state;r!==I.COMPLETE&&e.removeAttribute(`data-unseen`),r===I.COMPLETE&&i&&i!==I.COMPLETE&&(e.dataset.unseen=``);let a=sU(e,e._refs,r,n.awaitingBackgroundTasks),o=[zU(n),n.taskTitle,a].filter(Boolean).join(`, `);e.setAttribute(`aria-label`,o),e.title=o,e._refs.name.textContent=zU(n);let s=bU.get(t)||`none`;e.dataset.merge=s===`none`?``:s,e._refs.merge.textContent=Sd[s]||``,e.dataset.activity=n._activity||``,e.classList.toggle(`focused`,t===MU());let c=t===wU;e.setAttribute(`aria-selected`,String(c)),e.tabIndex=c?0:-1}function WU(e,t){if(!vU)return;let n=e?.card?.dataset.id,r=n?xU.get(n):null;if(!r)return;if(t===`flag`){r.dataset.activity=e._activity||``;return}if(cU?.matches||document.hidden)return;let i=r._refs?.glyph;i?.animate&&i.animate([{transform:`scale(1)`,opacity:.65},{transform:`scale(1.35)`,opacity:1,offset:.3},{transform:`scale(1)`,opacity:.9}],{duration:300,easing:`cubic-bezier(0.22, 1, 0.36, 1)`})}pf(WU);function GU(){if(!vU)return;let e=uU;if(!e)return;let t=RU(),n=iU(t,e=>e.ui.path,JF(t,e=>e.ui.path)),r=new Set,i=(e,t)=>{let n=e.map(e=>e.id).join(`,`),i=t._lastOrderKey===n&&t.childElementCount===e.length;for(let{id:n,ui:a}of e){r.add(n);let e=xU.get(n);e||(e=BU(n),xU.set(n,e)),UU(e,n,a),!i&&e._row&&t.appendChild(e._row)}t._lastOrderKey=n},a=new Set(n.order);for(let t of n.groups){let{header:n,list:r}=kU(t);e.appendChild(n),e.appendChild(r),i(t.rows,r)}for(let[e,t]of[...CU])a.has(e)||(t.remove(),SU.get(e)?.remove(),CU.delete(e),SU.delete(e));for(let[e,t]of xU)r.has(e)||((t._row||t).remove(),xU.delete(e),e===wU&&(wU=null));for(let e of[...bU.keys()])U.has(e)||bU.delete(e);let o=MU();if(o&&!U.has(o)){Vd.dispatch(`focusSession`,null),wU=null;let e=t.find(e=>U.has(e.id));if(e){tW(e.id);return}}nW();let s=MU();if(s){let e=U.get(s);e&&e.card.parentElement!==pU&&$U(e,s)}JU()}function KU(){return RU().map(({id:e,ui:t})=>({id:e,state:t.currentState||I.DORMANT,unseen:!!xU.get(e)?.hasAttribute(`data-unseen`)}))}function qU(){return KU().filter(VO).map(({id:e})=>e)}function JU(){let e=HO(KU());YU(e>0,UO(e))}function YU(e,t){if(dU){if(bd(dU,`.focus-rail-head-count`).textContent=t,dU.disabled=!e,e){dU.removeAttribute(`data-empty`),dU.removeAttribute(`aria-hidden`);return}dU.dataset.empty=``,dU.setAttribute(`aria-hidden`,`true`)}}function XU(){if(!vU)return;let e=qU();if(!e.length)return;let t=zO(e,yU);if(!t)return;yU=t;let n=U.get(t),r=t===MU();HU(t),tW(t),xU.get(t)?.scrollIntoView({block:`nearest`}),r&&QU(t),ZU(n,t)}function ZU(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{vU&&MU()===t&&e.term?.focus()}))}function QU(e){if(cU?.matches||document.hidden)return;let t=xU.get(e);t?.animate&&t.animate([{transform:`scale(1)`},{transform:`scale(1.045)`,offset:.3},{transform:`scale(1)`}],{duration:360,easing:`cubic-bezier(0.22, 1, 0.36, 1)`});let n=U.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function $U(e,t){pU&&(eN(e,t,pU,{className:`focus-centered`}),OE(e,t,!0))}function eW(){let e=MU();e&&($M()===e&&tN(),Vd.dispatch(`focusSession`,null))}function tW(e){vU&&U.has(e)&&e!==MU()&&(eW(),Vd.dispatch(`focusSession`,e),wU=e,MF(e),xU.get(e)?.removeAttribute(`data-unseen`),bR(e),GU())}function nW(){if(!hU||!gU||!_U)return;let e=MU(),t=!!(e&&U.has(e));if(hU.hidden=t,t)return;let n=U.size>0;gU.textContent=n?`No session selected`:`Nothing to focus`,_U.textContent=n?iW():`Spawn a session to start watching.`}function rW(){return uU?.closest(`.focus-view`)?.dataset.rail===`off`}function iW(){return rW()?`Pick a session in Calm to focus it here.`:`Select a session from the rail on the left to focus it here.`}function aW(e){let t=uU?.closest(`.focus-view`);t&&(e&&t.removeAttribute(`data-rail`),e||(t.dataset.rail=`off`),nW())}function oW(e,t){bU.set(Zd(e),typeof t==`string`&&t?t:`none`),vU&&GU()}function sW(e){vU&&U.has(e)&&tW(e)}function cW(e){return!vU||!U.has(e)?!1:(tW(e),kH(e))}function lW(e){if(!vU)return;let t=EU()[e-1];t&&VU(t)}function uW(e){if(!vU)return;let t=BO(EU(),wU,e);t!=null&&(VU(t),xU.get(t)?.scrollIntoView({block:`nearest`}),ZU(U.get(t),t))}function dW(){uU&&(vU=!0,eW(),wU=null,GU(),fW())}function fW(){if(!vU||MU())return;let e=jF();if(!e)return;let t=U.get(e);t&&(t.currentState||I.DORMANT)!==I.DORMANT&&tW(e)}function pW(){vU&&=(eW(),wU=null,!1)}function mW(e,t,n){let r=V(`a`,`settings-link`,n);return r.href=`#settings/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,r}var hW=`t-[0-9a-f]{8}`,gW=`No findings. Open a markdown file in a connected editor.`,_W=`No intent yet. The visions proposes one after its first pass.`,vW=`Unowned`,yW=RegExp(`^${hW}$`);function bW(){return{byProject:{},unowned:[]}}function xW(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.text==`string`?t.text:``;if(!n)return null;let r=Number(t.ts),i=Number(t.hits);return{id:typeof t.id==`string`&&yW.test(t.id)?t.id:null,text:n,uris:Array.isArray(t.uris)?t.uris.filter(e=>typeof e==`string`&&e!==``):[],ts:Number.isFinite(r)&&r>0?r:0,hits:Number.isInteger(i)&&i>0?i:1}}function SW(e){if(Array.isArray(e))return e.map(xW).filter(e=>e!==null);let t=xW(e);return t?[t]:[]}function CW(e){let t=e?.intent;if(!t||typeof t!=`object`)return bW();let n=t;if(!(Object.hasOwn(n,`byProject`)||Object.hasOwn(n,`unowned`)||Object.hasOwn(n,`global`)))return{byProject:{},unowned:SW(n)};let r=n.byProject&&typeof n.byProject==`object`?n.byProject:{},i=[];for(let[e,t]of Object.entries(r)){let n=SW(t);n.length!==0&&e&&i.push([e,n])}return{byProject:Object.fromEntries(i),unowned:SW(Object.hasOwn(n,`unowned`)?n.unowned:n.global)}}function wW(e,t){let n=typeof t?.id==`string`?t.id:null;if(!n)return e;let r=e.findIndex(e=>e.id===n);return r<=0?e:[e[r],...e.slice(0,r),...e.slice(r+1)]}function TW(e,t){let n=e||bW(),r=t?.intent;if(!r||typeof r!=`object`)return n;let i=r,a=wW(Array.isArray(i.threads)?SW(i.threads):SW(i),i.active),o=typeof t?.projectId==`string`&&t.projectId?t.projectId:null;if(!o)return{byProject:{...n.byProject},unowned:a};let s={...n.byProject};return a.length===0&&delete s[o],a.length>0&&(s[o]=a),{byProject:s,unowned:n.unowned}}function EW(e,t=null){let n=t&&typeof t.get==`function`?t.get(e):null;return typeof n==`string`&&n?n:e}function DW(e,{key:t,label:n,now:r}){return e.map((e,i)=>({key:`${t}:${e.id||i}`,label:n,text:e.text,hasText:!0,active:i===0,meta:jW(e,r)}))}function OW(e,t=null,n=Date.now()){let r=e||bW(),i=Object.entries(r.byProject||{}).filter(([e,t])=>e&&Array.isArray(t)&&t.length>0).map(([e,n])=>({projectId:e,label:EW(e,t),threads:n})).sort((e,t)=>e.label.localeCompare(t.label)).flatMap(({projectId:e,label:t,threads:r})=>DW(r,{key:e,label:t,now:n})),a=DW(Array.isArray(r.unowned)?r.unowned:[],{key:`unowned`,label:vW,now:n});return i.length+a.length>0?[...a,...i]:[{key:`unowned`,label:vW,text:_W,hasText:!1,active:!1,meta:``}]}function kW(e){return e?.text?`proposed by visions`:``}function AW(e,t=Date.now()){let n=Number(e);if(!Number.isFinite(n)||n<=0)return``;let r=Math.floor(Math.max(0,Number(t)-n)/6e4);if(r<1)return`just now`;if(r===1)return`1 minute ago`;if(r<60)return`${r} minutes ago`;let i=Math.floor(r/60);if(i===1)return`1 hour ago`;if(i<24)return`${i} hours ago`;let a=Math.floor(i/24);return a===1?`1 day ago`:`${a} days ago`}function jW(e,t=Date.now()){let n=kW(e);if(!n)return``;let r=typeof e?.id==`string`&&e.id?`thread ${e.id}, `:``,i=AW(e?.ts,t);return i?`${r}${n}, ${i}`:`${r}${n}`}function MW(e){let t=Number(e?.range?.start?.line);return!Number.isFinite(t)||t<0?`L?`:`L${Math.floor(t)+1}`}function NW(e){let t=Number(e?.range?.start?.character);return Number.isFinite(t)?t:0}function PW(e){let t=Number(e?.range?.start?.line);return Number.isFinite(t)?t:0}function FW(e){let t=typeof e==`string`?e:``;if(!t)return``;let n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);if(!r)return t;try{return decodeURIComponent(r)}catch{return r}}function IW(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(Math.floor(e),0):0}function LW(e){let t=IW(e);return t===1?`1 finding`:`${t} findings`}function RW(e){let t=IW(e);return t===1?`1 comment`:`${t} comments`}function zW(e){let t=IW(e?.findings?.length),n=IW(e?.comments?.length),r=typeof e?.hand==`string`&&e.hand?1:0,i=[];return r>0&&i.push(`raised hand`),t>0&&i.push(LW(t)),n>0&&i.push(RW(n)),i.length>0?i.join(`, `):LW(0)}function BW(e){let t=typeof e==`string`?e.trim():``;return t?`Raised hand: ${t}`:``}function VW(e){return(typeof e?.hand==`string`?e.hand.trim():``)||null}function HW(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=VW(t);return i?(n.set(r,i),n):(n.delete(r),n)}function UW(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=typeof e?.hand==`string`?e.hand.trim():``;n&&r&&t.set(n,r)}return t}var WW=`hand`,GW=`unseen`,KW=`
|
|
241
|
-
`;function qW(e){let t=2166136261,n=3266489909;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);t=Math.imul(t^i,16777619)>>>0,n=Math.imul(n^i,2246822507)>>>0}return`${t.toString(36).padStart(7,`0`)}${n.toString(36).padStart(7,`0`)}`}function JW(e,t){return qW(JSON.stringify([e,...t]))}function YW(e,t){return JW(`finding`,[e,MW(t),String(t.code??``),String(t.message??``)])}function XW(e,t){return JW(`comment`,[e,tG(t),String(t.message??``)])}function ZW(e){return JW(`fix`,[e.uri,fG(e),e.code,e.message,pG(e)])}function QW(e){return JW(`intent`,[e.key,e.text,e.active])}function $W(e,t,n,r=[],i=null){let a=[...n].map(([e,t])=>JW(`hand`,[e,t])).sort(),o=new Set;for(let r of[...e.keys(),...t.keys(),...n.keys()])o.add(JW(`document`,[r]));for(let[t,n]of e)for(let e of n)o.add(YW(t,e));for(let[e,n]of t)for(let t of n)o.add(XW(e,t));for(let e of r)o.add(ZW(e));for(let e of OW(i,null,0))e.hasText&&o.add(QW(e));let s=[...o].sort();return{signature:[...a,...s].join(KW),handEntries:a,contentEntries:s}}function eG(e,t){let n=new Set(t.split(KW));return e.handEntries.some(e=>!n.has(e))?WW:e.contentEntries.some(e=>!n.has(e))?GW:null}function tG(e){let t=Number(e?.line);return!Number.isFinite(t)||t<1?`L?`:`L${Math.floor(t)}`}function nG(e){return Array.isArray(e?.diagnostics)?e.diagnostics:[]}function rG(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=nG(t);return i.length===0?(n.delete(r),n):(n.set(r,i),n)}function iG(e){return Array.isArray(e?.comments)?e.comments:[]}function aG(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=iG(t);return i.length===0?(n.delete(r),n):(n.set(r,i),n)}function oG(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=Array.isArray(e?.diagnostics)?e.diagnostics:[];n&&r.length!==0&&t.set(n,r)}return t}function sG(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=Array.isArray(e?.comments)?e.comments:[];n&&r.length!==0&&t.set(n,r)}return t}function cG(e,t=new Map,n=new Map){let r=[],i=new Set([...e.keys(),...t.keys(),...n.keys()]);for(let a of i){let i=e.get(a),o=t.get(a),s=n.get(a)||null,c=Array.isArray(i)?i:[],l=Array.isArray(o)?o:[];(c.length!==0||l.length!==0||s)&&r.push({uri:a,name:FW(a)||a,hand:s,findings:[...c].sort((e,t)=>PW(e)-PW(t)||NW(e)-NW(t)),comments:[...l].sort((e,t)=>(Number(e?.line)||0)-(Number(t?.line)||0))})}return r.sort((e,t)=>lG(e.name,t.name)||lG(e.uri,t.uri)),r}function lG(e,t){return e<t?-1:+(e>t)}var uG=`No fixes yet. Silent fixes appear here once the lane applies or is refused one.`;function dG(e){let t=IW(e);return t===1?`1 fix`:`${t} fixes`}function fG(e){let t=Number(e?.line);return!Number.isFinite(t)||t<0?`L?`:`L${Math.floor(t)+1}`}function pG(e){return e?.applied===!0?`applied`:`refused`}function mG(e,{uri:t=``,ts:n=0}={}){if(!e||typeof e!=`object`)return null;let r=e,i=typeof r.message==`string`?r.message.trim():``;if(!i)return null;let a=Number(r.line),o=Number(r.ts??n);return{uri:typeof r.uri==`string`&&r.uri?r.uri:t,code:typeof r.code==`string`?r.code:``,line:Number.isFinite(a)&&a>0?Math.floor(a):0,message:i,applied:r.applied===!0,ts:Number.isFinite(o)&&o>0?o:0}}function hG(e){let t=typeof e?.uri==`string`?e.uri:``,n=Number(e?.ts);return mG(e?.fix,{uri:t,ts:Number.isFinite(n)?n:0})}function gG(e,t,{max:n=20}={}){let r=hG(t);return r?[r,...e].slice(0,Math.max(0,Math.floor(n))):[...e]}function _G(e,{max:t=20}={}){let n=Array.isArray(e?.fixes)?e.fixes:[],r=[];for(let e of n){let t=mG(e);t&&r.push(t)}return r.slice(0,Math.max(0,Math.floor(t)))}var vG=`No activity yet. The ingest lane reports what your sessions and tools are doing.`,yG={terminal:`terminal`,agentLogs:`agent`,git:`git`,fs:`files`,shellHistory:`shell`,editor:`editor`};function bG(e){let t=typeof e==`string`?e:``;return yG[t]||t||`source`}function xG(e,t=Date.now()){let n=Number(e);if(!Number.isFinite(n)||n<=0)return``;let r=Math.max(0,Math.floor((Number(t)-n)/1e3));if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function SG(e){if(!e||typeof e!=`object`)return null;let t=e,n=Number(t.seq);if(!Number.isFinite(n))return null;let r=typeof t.summary==`string`?t.summary.trim():``;if(!r)return null;let i=Number(t.ts),a=t.scope&&typeof t.scope==`object`?t.scope:{};return{seq:Math.floor(n),source:typeof t.source==`string`?t.source:``,kind:typeof t.kind==`string`?t.kind:``,ts:Number.isFinite(i)&&i>0?i:0,summary:r,root:typeof a.root==`string`&&a.root?a.root:null,sessionId:typeof a.sessionId==`string`&&a.sessionId?a.sessionId:null}}function CG(e){let t=Array.isArray(e?.events)?e.events:[],n=[];for(let e of t){let t=SG(e);t&&n.push(t)}return n}function wG(e){let t=Number(e?.overflow);return!Number.isFinite(t)||t<=0?0:Math.floor(t)}function TG(e){let t=IW(e);return t<=0?``:t===1?`1 more event not shown`:`${t} more events not shown`}function EG(e,t){return[...e].sort((e,t)=>t.seq-e.seq).slice(0,Math.max(0,Math.floor(t)))}function DG(e,t,{max:n=100}={}){let r=CG(t);if(r.length===0)return EG(e,n);let i=new Map;for(let t of e)i.set(t.seq,t);for(let e of r)i.set(e.seq,e);return EG([...i.values()],n)}function OG(e,{max:t=100}={}){return EG(CG(e),t)}function kG(e){let t=IW(e);return t===1?`1 event`:`${t} events`}function AG(e){if(!e?.root)return`machine`;let t=e.root.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n===-1?t:t.slice(n+1)}var jG=new Map,MG=new Map,NG=new Map,PG=bW(),FG=new Map,IG=null,LG=null,RG=null,zG=null,BG=null,VG=[],HG=0,UG=null,WG=[],GG=null,KG=$W(jG,MG,NG,WG,PG),qG=kF(),JG=RE({getAck:()=>qG,setAck:e=>{qG=e,AF(e)},signature:()=>KG.signature,isLooking:()=>!kd(IG)});function YG(){let e=V(`section`,`visions-intent`);e.append(V(`h2`,`visions-intent-title`,`Intent`));let t=V(`div`,`visions-intent-list`);return e.append(t),RG={list:t},e}function XG(e){let t=V(`div`,`visions-intent-item`),n=V(`div`,`visions-intent-head`);n.append(V(`span`,`visions-intent-scope`,e.label),V(`span`,`visions-intent-meta`,e.meta));let r=V(`p`,`visions-intent-text`,e.text);return r.classList.toggle(`visions-intent-none`,!e.hasText),t.classList.toggle(`visions-intent-active`,e.active===!0),t.append(n,r),t}function ZG(){RG&&RG.list.replaceChildren(...OW(PG,FG).map(XG))}function QG(e){FG=e instanceof Map?e:new Map,ZG()}function $G(e){let t=V(`section`,`visions-doc`),n=V(`div`,`visions-doc-head`),r=V(`h2`,`visions-doc-name`);if(r.textContent=e.name,r.title=e.uri,n.append(r,V(`span`,`visions-doc-count`,zW(e))),t.append(n),e.hand&&t.append(eK(e.hand)),e.findings.length>0){let n=V(`div`,`visions-findings`);for(let t of e.findings)n.append(nK(t));t.append(n)}if(e.comments.length>0){let n=V(`div`,`visions-comments`);for(let t of e.comments)n.append(tK(t));t.append(n)}return t}function eK(e){let t=V(`div`,`visions-hand`);return t.textContent=BW(e),t}function tK(e){let t=V(`div`,`visions-comment`),n=V(`div`,`visions-comment-head`);n.append(V(`span`,`visions-comment-chip`,`visions`)),n.append(V(`span`,`visions-comment-line`,tG(e))),t.append(n);let r=V(`p`,`visions-comment-message`);return r.textContent=e?.message==null?``:String(e.message),t.append(r),t}function nK(e){let t=V(`div`,`visions-finding`);t.append(V(`span`,`visions-finding-line`,MW(e)));let n=e?.code==null?``:String(e.code);n&&t.append(V(`span`,`visions-finding-code`,n));let r=V(`span`,`visions-finding-message`);return r.textContent=e?.message==null?``:String(e.message),t.append(r),t}function rK({force:e=!1}={}){if(!LG||!e&&kd(IG))return;LG.textContent=``;let t=cG(jG,MG,NG);if(t.length===0){let e=V(`p`,`visions-empty`,gW);if(BG===!1){let t=mW(`lanes-visions`,`visions-enabled`,`Enable Visions`);e.append(document.createTextNode(` `),t)}LG.append(e);return}for(let e of t)LG.append($G(e))}function iK(e){BG=e?.visions?.enabled===!0,rK()}function aK(){let e=V(`section`,`visions-activity`),t=V(`div`,`visions-activity-head`);t.append(V(`h2`,`visions-activity-title`,`Activity`));let n=V(`span`,`visions-activity-count`);t.append(n),e.append(t);let r=V(`div`,`visions-activity-list`);e.append(r);let i=V(`p`,`visions-activity-overflow`);return e.append(i),UG={count:n,list:r,overflow:i},e}function oK(e,t){let n=V(`div`,`visions-activity-row`);n.append(V(`span`,`visions-activity-source`,bG(e.source))),n.append(V(`span`,`visions-activity-age`,xG(e.ts,t))),n.append(V(`span`,`visions-activity-scope`,AG(e)));let r=V(`span`,`visions-activity-summary`);return r.textContent=e.summary,n.append(r),n}function sK({force:e=!1}={}){if(!UG||!e&&kd(IG))return;let{count:t,list:n,overflow:r}=UG;if(t.textContent=kG(VG.length),n.textContent=``,VG.length===0){n.append(V(`p`,`visions-empty`,vG)),r.textContent=``;return}let i=Date.now();for(let e of VG)n.append(oK(e,i));r.textContent=TG(HG)}function cK(){let e=V(`section`,`visions-fixes`),t=V(`div`,`visions-fixes-head`);t.append(V(`h2`,`visions-fixes-title`,`Fixes`));let n=V(`span`,`visions-fixes-count`);t.append(n),e.append(t);let r=V(`div`,`visions-fixes-list`);return e.append(r),GG={count:n,list:r},e}function lK(e){let t=V(`div`,`visions-fix-row`);t.dataset.applied=e.applied?`yes`:`no`;let n=V(`span`,`visions-fix-file`);n.textContent=FW(e.uri)||e.uri,n.title=e.uri,t.append(n),t.append(V(`span`,`visions-fix-line`,fG(e))),t.append(V(`span`,`visions-fix-outcome`,pG(e))),t.append(V(`span`,`visions-fix-code`,e.code||``));let r=V(`span`,`visions-fix-message`);return r.textContent=e.message,t.append(r),t}function uK({force:e=!1}={}){if(!GG||!e&&kd(IG))return;let{count:t,list:n}=GG;if(t.textContent=dG(WG.length),n.textContent=``,WG.length===0){n.append(V(`p`,`visions-empty`,uG));return}for(let e of WG)n.append(lK(e))}function dK(){KG=$W(jG,MG,NG,WG,PG),KG.signature!==``&&JG.refresh(),zG&&zG(eG(KG,qG))}function fK(e){zG=e,dK()}function pK(e){if(IG)return IG;let t=V(`div`,`visions-content`);t.append(YG());let n=V(`div`,`visions-feed`);return t.append(n),t.append(cK()),t.append(aK()),e.appendChild(t),IG=t,LG=n,ZG(),rK({force:!0}),uK({force:!0}),sK({force:!0}),t}function mK(){ZG(),rK({force:!0}),uK({force:!0}),sK({force:!0})}function hK(){KG.signature!==``&&JG.acknowledge(),dK()}function gK(e){WG=gG(WG,e),uK(),dK()}function _K(e){jG=rG(jG,e),rK(),dK()}function vK(e){MG=aG(MG,e),rK(),dK()}function yK(e){NG=HW(NG,e),rK(),dK()}function bK(e){PG=TW(PG,e),ZG(),dK()}function xK(e){VG=DG(VG,e),HG=wG(e),sK(),dK()}function SK(e){VG=OG(e),HG=0,sK(),dK()}function CK(e){jG=oG(e),MG=sG(e),NG=UW(e),PG=CW(e),WG=_G(e),ZG(),rK(),uK(),dK()}var wK=`Claude Code hooks injected into every session Glimmervoid spawns.`,TK=`Loading hooks`,EK=`No hooks yet. A hook runs a command, or calls a URL, when a Claude Code event fires in a Glimmervoid session. Start from one of these, or add your own.`,DK=`Start from`,OK=`Filter by name, event or command`,kK=`Nothing matches that filter.`,AK=`Preview`,jK=`The entry this becomes in the per-session settings file.`,MK=`Duplicate`,NK=`Discard changes`,PK=`Close the editor and lose the unsaved changes?`,FK=`Esc cancels. Ctrl+Enter saves.`,IK=`A change reaches a session at its next start or restart. Claude Code sessions only; Codex and Grok sessions do not read this file.`,LK=`Glimmervoid's own hooks`,RK=`Always present, read-only. Status detection depends on them.`,zK=`Your hooks`,BK=`New hook`,VK=`Edit hook`,HK=`Saved to config.json.`,UK=`All projects`,WK=`This event takes no matcher.`,GK=`Blank uses Claude Code's default for the event.`,KK=Object.freeze([{value:`command`,label:`Command`,hint:`Run a shell command. It receives the event JSON on stdin.`},{value:`http`,label:`HTTP`,hint:`POST the event JSON to a URL.`}]),qK=Object.freeze([{id:`lint`,label:`Lint after edits`,summary:`PostToolUse on Edit|Write`,draft:{name:`Lint after edits`,event:`PostToolUse`,matcher:`Edit|Write`,type:`command`,command:`npx biome check --write "$(jq -r .tool_input.file_path)"`}},{id:`notify`,label:`Notify on Stop`,summary:`Stop, command`,draft:{name:`Notify on Stop`,event:`Stop`,matcher:``,type:`command`,command:`command -v notify-send >/dev/null 2>&1 && notify-send "Claude finished a turn" || { command -v osascript >/dev/null 2>&1 && osascript -e 'display notification "Claude finished a turn" with title "Claude Code"'; }`}},{id:`guard`,label:`Guard destructive Bash`,summary:`PreToolUse on Bash, exit 2 blocks`,draft:{name:`Guard destructive Bash`,event:`PreToolUse`,matcher:`Bash`,type:`command`,command:`jq -r .tool_input.command | grep -Eq "rm -rf|git push --force" && exit 2 || exit 0`}},{id:`log`,label:`Log every prompt`,summary:`UserPromptSubmit, appends JSON`,draft:{name:`Log every prompt`,event:`UserPromptSubmit`,matcher:``,type:`command`,command:`cat >> ~/.claude/prompts.jsonl`}}]),JK=Object.freeze({hooks:[],builtin:[],events:[]});function YK(e){return!e||typeof e.error==`string`}function XK(e){return!e||typeof e.error!=`string`?``:e.error}function ZK(e,t){let n=e?.[t];return Array.isArray(n)?n:JK[t]}var QK=e=>ZK(e,`hooks`),$K=e=>ZK(e,`builtin`),eq=e=>ZK(e,`events`);function tq(e){let t=e?.limits?.maxTimeoutSec;return typeof t==`number`&&Number.isInteger(t)&&t>0?t:600}function nq(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function rq(e){let t=QK(e),n=t.filter(e=>e.enabled!==!1).length;return[{label:`yours`,value:String(t.length),tone:null},{label:`enabled`,value:String(n),tone:t.length>0&&n===0?`warn`:null},{label:`built in`,value:String($K(e).length),tone:null}]}function iq(e,t){let n=new Map(t.map((e,t)=>[e.name,t])),r=e=>n.get(e.event)??t.length;return[...e].sort((e,t)=>{let n=r(e)-r(t);return n===0?String(e.name).localeCompare(String(t.name)):n})}function aq(e,t){let n=String(t||``).trim().toLowerCase();return n?e.filter(e=>[e.name,e.event,e.matcher,e.command,e.url].some(e=>typeof e==`string`&&e.toLowerCase().includes(n))):e}function oq(e){return e.length>=4}function sq(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.event===n.event){e.hooks.push(n);continue}t.push({event:n.event,hooks:[n]})}return t}function cq(e){let t=e.type===`http`?{type:`http`,url:e.url||``}:{type:`command`,command:e.command||``};Number.isInteger(e.timeout)&&Number(e.timeout)>0&&(t.timeout=e.timeout);let n=e.matcher?{matcher:e.matcher,hooks:[t]}:{hooks:[t]};return JSON.stringify({hooks:{[e.event]:[n]}},null,2)}function lq(e){return`${e} copy`}function uq(e,t){return e.find(e=>e.name===t)||null}function dq(e,t){let n=uq(e,t);return n?n.matcher?`Matches ${n.matcher}. Blank matches every ${n.name}.`:WK:``}function fq(e){return e.type===`http`?e.url||``:e.command||``}function pq(e){let t=KK.find(t=>t.value===e);return t?t.label:String(e||``)}function mq(e){return!Number.isInteger(e.timeout)||Number(e.timeout)<=0?``:`${e.timeout}s timeout`}function hq(e,t){let n=Array.isArray(e.projects)?e.projects:[];return n.length===0?UK:n.map(e=>{let n=t.find(t=>t.id===e);return n?n.name:e}).join(`, `)}function gq(e){return e.matcher?`${e.event} / ${e.matcher}`:e.event}function _q(e){return e.matcher?`${e.event} / ${e.matcher}`:e.event}function vq(e,t){let n=Array.isArray(e.projects)?e.projects:[],r=new Set(t.map(e=>e.id));return n.filter(e=>!r.has(e))}function yq(e){let t=e[0];return{id:null,name:``,event:t?t.name:``,matcher:``,type:`command`,command:``,url:``,timeout:``,enabled:!0,projects:[]}}function bq(e){return{id:e.id??null,name:e.name||``,event:e.event||``,matcher:e.matcher||``,type:e.type===`http`?`http`:`command`,command:e.command||``,url:e.url||``,timeout:Number.isInteger(e.timeout)?String(e.timeout):``,enabled:e.enabled!==!1,projects:Array.isArray(e.projects)?[...e.projects]:[]}}function xq(e,t,n=600){if(!e.name.trim())return`Give the hook a name.`;let r=uq(t,e.event);if(!r)return`Pick an event.`;if(e.matcher.trim()&&!r.matcher)return`${r.name} takes no matcher.`;if(e.type===`http`&&r.http===!1)return`${r.name} does not support HTTP hooks.`;if(e.type===`command`&&!e.command.trim())return`Enter the command to run.`;if(e.type===`http`&&!/^https?:\/\/\S+$/i.test(e.url.trim()))return`Enter a URL starting with http:// or https://.`;if(e.timeout.trim()!==``){let t=Number(e.timeout);if(!Number.isInteger(t)||t<1||t>n)return`Timeout must be a whole number of seconds from 1 to ${n}.`}return null}function Sq(e){let t={name:e.name.trim(),event:e.event,type:e.type,enabled:e.enabled!==!1};return e.id&&(t.id=e.id),e.matcher.trim()&&(t.matcher=e.matcher.trim()),e.type===`command`&&(t.command=e.command.trim()),e.type===`http`&&(t.url=e.url.trim()),e.timeout.trim()!==``&&(t.timeout=Number(e.timeout)),e.projects.length>0&&(t.projects=[...e.projects]),t}function Cq(e,t){let n={...yq(t),...e.draft};return uq(t,n.event)||(n.event=yq(t).event),n}function wq(e,t){return JSON.stringify(Sq(e))!==JSON.stringify(t)}function Tq(e){return{...e,enabled:e.enabled===!1}}function Eq(e){return`Delete the hook "${e.name}"? Sessions already running keep it until they restart.`}var Dq=null,Oq=null,kq=null,Aq=0,jq=null,Mq=null,Nq=null,Pq=null,Fq=null,Iq=!1,Lq=null,Rq=``,zq=new Set,Bq=new Set,Vq=!1,Hq=(e,t)=>Ed(`hooks`,e,t);function Uq(e,t,n){let r=V(`p`,e,t);return n&&(r.dataset.tone=n),r}function Wq(e,t,n,r){let i=V(`button`,e,t);return i.type=`button`,r&&i.setAttribute(`aria-label`,r),i.addEventListener(`click`,n),i}function Gq(e){if(!kq)return null;Aq+=1;let t=`hooks-${Aq}`;return kq({requestId:t,...e}),t}function Kq(e,t,n){let r=V(`label`,`hooks-field`);return r.append(V(`span`,`hooks-field-label`,e),t),n&&r.append(V(`span`,`hooks-field-hint`,n)),r}function qq(e,t,n){let r=V(`input`,`settings-view-input`);return r.type=`text`,r.value=e,r.autocomplete=`off`,r.spellcheck=!1,t&&(r.placeholder=t),r.addEventListener(`input`,()=>n(r.value)),r}function Jq(e,t){let n=V(`textarea`,`settings-view-input hooks-command`);return n.rows=3,n.value=e,n.spellcheck=!1,n.addEventListener(`input`,()=>t(n.value)),n}function Yq(e,t,n){let r=V(`select`,`settings-view-input hooks-select`);for(let n of t){let t=V(`option`,null,n.name);t.value=n.name,t.title=n.description,n.name===e.event&&(t.selected=!0),r.append(t)}return r.addEventListener(`change`,()=>n(r.value)),r}function Xq(e,t){let n=V(`div`,`hooks-type-row`);n.setAttribute(`role`,`radiogroup`);for(let r of KK){let i=V(`label`,`settings-view-toggle hooks-choice`),a=V(`input`,`settings-view-checkbox`);a.type=`radio`,a.name=`hooks-type`,a.value=r.value,a.checked=e.type===r.value,a.title=r.hint,a.addEventListener(`change`,()=>{a.checked&&t(r.value)}),i.append(a,V(`span`,null,r.label)),n.append(i)}return n}function Zq(e,t){let n=V(`div`,`hooks-projects`);if(t.length===0)return n.append(V(`span`,`hooks-field-hint`,UK)),n;let r=V(`label`,`settings-view-project-choice hooks-choice`),i=V(`input`,`settings-view-checkbox`);i.type=`checkbox`,i.checked=e.projects.length===0,r.append(i,V(`span`,null,UK)),n.append(r);let a=[];for(let r of t){let t=V(`label`,`settings-view-project-choice hooks-choice`),o=V(`input`,`settings-view-checkbox`);o.type=`checkbox`,o.value=r.id,o.checked=e.projects.includes(r.id),o.addEventListener(`change`,()=>{e.projects=a.filter(e=>e.checked).map(e=>e.value),i.checked=e.projects.length===0}),a.push(o),t.append(o,V(`span`,null,r.name)),r.agent!==`claude-code`&&(t.append(V(`span`,`hooks-choice-note`,r.agent)),t.title=`Not a Claude Code project: this hook will not reach its sessions.`),n.append(t)}return i.addEventListener(`change`,()=>{if(!i.checked){i.checked=e.projects.length===0;return}for(let e of a)e.checked=!1;e.projects=[]}),n}function Qq(e){let t=V(`div`,`hooks-templates`);t.append(V(`span`,`hooks-templates-label`,DK));for(let n of qK){let r=Wq(`hooks-chip`,n.label,()=>tJ(null,Cq(n,e)));r.title=n.summary,t.append(r)}return t}function $q(e){Fq&&(Fq.textContent=e||``,Fq.hidden=!e)}function eJ(e){let t=eq(Dq),n=Od(Dq),r=Hq(e.id?VK:BK,HK);r.classList.add(`hooks-editor`);let i=V(`form`,`hooks-form`);i.addEventListener(`submit`,e=>{e.preventDefault(),iJ()}),i.addEventListener(`keydown`,e=>{if(e.key===`Escape`){e.preventDefault(),rJ();return}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),iJ())}),e.id||i.append(Qq(t));let a=V(`span`,`hooks-field-hint`,dq(t,e.event)),o=qq(e.matcher,``,t=>{e.matcher=t}),s=Kq(`Command`,Jq(e.command,t=>{e.command=t}),`Runs through the shell with the event JSON on stdin. Exit 2 blocks the action where the event allows it.`),c=Kq(`URL`,qq(e.url,`http://127.0.0.1:8080/hook`,t=>{e.url=t}),`Claude Code POSTs the event JSON to it.`),l=()=>{s.hidden=e.type!==`command`,c.hidden=e.type!==`http`};l();let u=Kq(`Matcher`,o,null);u.append(a);let d=()=>{let n=t.find(t=>t.name===e.event);a.textContent=dq(t,e.event),o.disabled=!!n&&!n.matcher,o.disabled&&(o.value=``,e.matcher=``)};d();let f=V(`input`,`settings-view-input hooks-timeout`);f.type=`number`,f.inputMode=`numeric`,f.min=`1`,f.max=String(tq(Dq)),f.value=e.timeout,f.addEventListener(`input`,()=>{e.timeout=f.value});let p=V(`label`,`settings-view-toggle hooks-choice`),m=V(`input`,`settings-view-checkbox`);m.type=`checkbox`,m.checked=e.enabled,m.addEventListener(`change`,()=>{e.enabled=m.checked}),p.append(m,V(`span`,null,`Enabled`)),i.append(Kq(`Name`,qq(e.name,`Lint after edits`,t=>{e.name=t}),null),Kq(`Event`,Yq(e,t,t=>{e.event=t,d()}),null),u,Kq(`Type`,Xq(e,t=>{e.type=t,l()}),null),s,c,Kq(`Timeout (seconds)`,f,GK),Kq(`Projects`,Zq(e,n),null),Kq(``,p,null)),Fq=V(`p`,`hooks-editor-error`),Fq.setAttribute(`role`,`alert`),Fq.hidden=!0;let h=V(`div`,`hooks-editor-footer`),g=V(`span`,`hooks-editor-shortcut`,FK),_=Wq(`btn-dialog btn-dialog-cancel`,`Cancel`,rJ),v=V(`button`,`btn-dialog btn-dialog-confirm`,e.id?`Save changes`:`Add hook`);return v.type=`submit`,h.append(Fq,g,_,v),i.append(h),r.append(i),r}function tJ(e,t=null){Mq=t||(e?bq(e):yq(eq(Dq))),Nq=Sq(e?bq(e):yq(eq(Dq))),Pq=eJ(Mq),hJ({force:!0}),Pq.scrollIntoView({block:`nearest`});let n=Pq.querySelector(`input[type=text]`);n instanceof HTMLInputElement&&n.focus()}function nJ(){Mq=null,Nq=null,Pq=null,Fq=null,Iq=!1,Lq=null,Vq=!0,hJ({force:!0})}function rJ(){if(!Mq||!Nq||!wq(Mq,Nq)){nJ();return}af({title:NK,message:PK,confirmLabel:`Discard`,danger:!0,onConfirm:nJ})}function iJ(){if(!Mq||Iq)return;let e=xq(Mq,eq(Dq),tq(Dq));if(e){$q(e);return}Iq=!0,$q(``),Lq=Gq({type:`save-hook`,hook:Sq(Mq)}),Lq||(Iq=!1)}function aJ(e){let t=V(`details`,`hooks-preview`);t.open=zq.has(e.id),t.addEventListener(`toggle`,()=>{if(t.open){zq.add(e.id);return}zq.delete(e.id)});let n=V(`summary`,`hooks-preview-summary`,AK);n.title=jK;let r=V(`pre`,`hooks-preview-code`,cq(e));return t.append(n,r),t}function oJ(e,{grouped:t=!1}={}){let n=Od(Dq),r=V(`article`,`hooks-row`);r.setAttribute(`aria-label`,e.name),e.enabled===!1&&(r.dataset.state=`off`);let i=V(`div`,`hooks-row-main`),a=V(`div`,`hooks-row-head`);a.append(V(`span`,`hooks-row-name`,e.name));let o=t?e.matcher||``:gq(e);o&&a.append(V(`span`,`hooks-row-event`,o));let s=V(`code`,`hooks-row-target`,fq(e));s.title=fq(e);let c=V(`p`,`hooks-row-meta`,[pq(e.type),mq(e),hq(e,n)].filter(Boolean).join(` / `));i.append(a,s,c);let l=vq(e,n);l.length>0&&i.append(Uq(`hooks-row-meta`,`Scoped to a project no longer in config: ${l.join(`, `)}`,`warn`)),i.append(aJ(e));let u=V(`div`,`hooks-row-actions`),d=V(`label`,`settings-view-toggle hooks-choice`),f=V(`input`,`settings-view-checkbox`);f.type=`checkbox`,f.checked=e.enabled!==!1,f.disabled=Bq.has(e.id),f.setAttribute(`aria-label`,`${e.name} enabled`),f.addEventListener(`change`,()=>{Bq.add(e.id),f.disabled=!0,Gq({type:`save-hook`,hook:Tq(e)})}),d.append(f,V(`span`,null,`On`));let p=Wq(`hooks-btn`,`Edit`,()=>tJ(e),`Edit ${e.name}`),m=Wq(`hooks-btn`,MK,()=>{let t=bq({...e,name:lq(e.name)});t.id=null,tJ(null,t)},`Duplicate ${e.name}`),h=Wq(`hooks-btn hooks-btn-danger`,`Delete`,()=>{af({title:`Delete hook`,message:Eq(e),confirmLabel:`Delete`,danger:!0,onConfirm:()=>{Bq.add(e.id),Gq({type:`delete-hook`,id:e.id}),hJ({force:!0})}})},`Delete ${e.name}`);return h.disabled=Bq.has(e.id),u.append(d,p,m,h),r.append(i,u),r}function sJ(e){let t=V(`article`,`hooks-row hooks-row-builtin`),n=V(`div`,`hooks-row-main`);return n.append(V(`span`,`hooks-row-event`,_q(e)),V(`p`,`hooks-row-meta`,e.purpose)),t.append(n),t}function cJ(){let e=Hq(`Hooks`,wK),t=V(`div`,`hooks-stats`);for(let e of rq(Dq))t.append(Dd(`hooks`,e.label,e.value,e.tone));return e.append(t,Uq(`hooks-meta`,IK)),e}function lJ(){let e=V(`input`,`settings-view-input hooks-filter`);return e.type=`search`,e.value=Rq,e.placeholder=OK,e.setAttribute(`aria-label`,OK),e.addEventListener(`input`,()=>{Rq=e.value;let t=Oq?.querySelector(`.hooks-list-yours`);t&&t.replaceWith(dJ())}),e}function uJ(){let e=V(`div`,`hooks-empty-state`);return e.append(Uq(`hooks-empty`,EK),Qq(eq(Dq))),e}function dJ(){let e=V(`div`,`hooks-list-yours`),t=QK(Dq);if(t.length===0)return e.append(uJ()),e;let n=aq(iq(t,eq(Dq)),Rq);if(n.length===0)return e.append(Uq(`hooks-empty`,kK)),e;for(let t of sq(n)){let n=V(`div`,`hooks-group`);n.append(V(`h3`,`hooks-group-title`,t.event));let r=V(`div`,`hooks-list`);for(let e of t.hooks)r.append(oJ(e,{grouped:!0}));n.append(r),e.append(n)}return e}function fJ(){let e=Hq(zK,null),t=Wq(`hooks-btn hooks-btn-add`,`+ New hook`,()=>tJ(null));t.disabled=!!Mq;let n=e.querySelector(`.hooks-section-head`);return n&&n.append(t),oq(QK(Dq))&&e.append(lJ()),e.append(dJ()),e}function pJ(){let e=V(`details`,`hooks-builtin`),t=V(`summary`,`hooks-builtin-summary`);t.append(V(`span`,`hooks-section-title`,`${LK} (${$K(Dq).length})`),V(`span`,`hooks-section-hint`,RK));let n=V(`div`,`hooks-list`);for(let e of $K(Dq))n.append(sJ(e));return e.append(t,n),e}function mJ(){let e=V(`div`,`hooks-content`);return Dq?YK(Dq)?(e.append(Uq(`hooks-warning`,XK(Dq))),e):(e.append(cJ()),Pq&&e.append(Pq),e.append(fJ(),pJ()),e):(e.append(Uq(`hooks-empty`,TK)),e)}function hJ({force:e=!1}={}){if(!Oq||!e&&kd(Oq)||(Oq.replaceChildren(mJ()),!Vq))return;Vq=!1;let t=Oq.querySelector(`.hooks-btn-add`);t instanceof HTMLButtonElement&&t.focus()}function gJ(e){kq=e}function _J(){kq&&(Aq+=1,jq=`hooks-report-${Aq}`,kq({type:`request-hooks-report`,requestId:jq}))}function vJ(e){Oq||(Oq=V(`div`,`hooks-panel`),e.append(Oq),hJ({force:!0}))}function yJ(){hJ({force:!0})}function bJ(e){nq(e,jq)&&(Dq=e,Bq.clear(),Iq=!1,hJ())}function xJ(e){let t=Lq!==null&&e.requestId===Lq;if(t&&(Lq=null,Iq=!1),e.ok){t&&nJ(),_J();return}let n=typeof e.error==`string`&&e.error?e.error:`Could not save the hook`;if(t){$q(n);return}zx(n,{persist:!0}),_J()}function SJ(e){e.ok||zx(typeof e.error==`string`&&e.error?e.error:`Could not delete the hook`,{persist:!0}),_J()}function CJ(e,t,n){return{body:String(n||`Session needs attention`),tag:`glimmervoid-${e||``}-${t||``}`,renotify:!0,silent:!0}}var wJ=4e3;function TJ(e,t){return`glimmervoid-notify-claim-${e||``}-${t||``}`}function EJ(e,t,n,r=wJ){try{let i=e.getItem(t);if(i){let e=Number(i);if(Number.isFinite(e)&&n-e<r)return!1}return e.setItem(t,String(n)),!0}catch{return!0}}function DJ(){return typeof Notification>`u`?null:Notification}function OJ(){return DJ()!==null}function kJ(){let e=DJ();return e?e.permission:`unavailable`}async function AJ(){let e=DJ();if(!e)return`denied`;if(e.permission!=="default")return e.permission;try{return await e.requestPermission()}catch{return e.permission}}function jJ(){let e=DJ();e&&GP()&&e.permission==="default"&&AJ()}function MJ({session:e,category:t,message:n,kind:r,ignoreFocus:i=!1}={}){let a=DJ();if(a&&GP()&&a.permission===`granted`&&(i||typeof document>`u`||typeof document.hasFocus!=`function`||!document.hasFocus())&&EJ(window.localStorage,TJ(e,t),Date.now()))try{let i=new a(`Glimmervoid`,CJ(e,t,n));i.onclick=()=>{window.focus(),r===`plan`&&typeof e==`string`&&(window.location.hash=WL(e)),i.close()}}catch{}}var NJ=[{name:`glimmervoid`,state:I.RUNNING,awaitingBackgroundTasks:!1},{name:`glimmervoid (2)`,state:I.RUNNING,awaitingBackgroundTasks:!0},{name:`api`,state:I.WAITING,awaitingBackgroundTasks:!1},{name:`docs-site`,state:I.IDLE,awaitingBackgroundTasks:!1}];function PJ(){let e=V(`div`,`compact-status-preview`);e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,`Example sidebar sessions showing how status appears with this setting`);for(let t of NJ){let{pill:n,refs:r}=oU(`div`,`focus-pill compact-status-preview-pill`);r.name.textContent=t.name,sU(n,r,t.state,t.awaitingBackgroundTasks),e.append(n)}return e}var FJ=61.2,IJ=37.8,LJ=768,RJ=.68,zJ=64,BJ=5;function VJ(e,t,n){return Math.min(Math.max(e,t),n)}function HJ({viewportWidthPx:e,viewportHeightPx:t,verticalProgress:n}){let r=VJ(e/LJ,RJ,1),i=(BJ+70*n*n)*t/100;return{scale:r,spriteWidthPx:FJ,spriteHeightPx:IJ,topPx:Math.max(i,zJ),startXpx:-.45*e,endXpx:1.45*e}}function UJ(e,t){return[[`--nyan-top`,`${e.topPx}px`],[`--nyan-scale`,String(e.scale*t)],[`--nyan-width`,`${e.spriteWidthPx}px`],[`--nyan-height`,`${e.spriteHeightPx}px`],[`--nyan-start-x`,`${e.startXpx}px`],[`--nyan-end-x`,`${e.endXpx}px`]]}var WJ=null,GJ=null,KJ=null,qJ=null,JJ=-1,YJ=null,XJ=1;function ZJ(){if(!WJ||YJ===null)return;let e=HJ({viewportWidthPx:document.documentElement.clientWidth,viewportHeightPx:document.documentElement.clientHeight,verticalProgress:YJ});for(let[t,n]of UJ(e,XJ))WJ.style.setProperty(t,n)}function QJ(){qJ!==null&&(clearTimeout(qJ),qJ=null)}function $J(e=$P()){return TP({isEnabled:e,hasReducedMotion:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,isPhone:Jd(),options:HF()})}function eY(e,t){if(!WJ||!GJ||!KJ||$J())return;let n=HF();QJ();let r=wP(n,JJ,Math.random,t);if(WJ.onanimationend=null,WJ.style.animation=`none`,!r){qJ=setTimeout(()=>eY(!1),1e3);return}YJ=r.verticalProgress,XJ=n.flyingAnimalsScale,ZJ();let i=_P[r.animalIndex];GJ.className=`nyan-sprite ${i.sprite}`,KJ.className=`nyan-trail ${i.trail}`,JJ=r.animalIndex,WJ.offsetWidth,WJ.style.animation=`nyan-fly ${r.durationSeconds}s linear`,e&&(WJ.style.animationDelay=`-${r.firstDelaySeconds}s`),WJ.onanimationend=e=>{WJ&&e.target===WJ&&(WJ.onanimationend=null,WJ.style.animation=`none`,qJ=setTimeout(()=>eY(!1),r.gapMs))}}function tY(){WJ||$J()||(WJ=document.createElement(`div`),WJ.className=`nyan-flight`,WJ.setAttribute(`aria-hidden`,`true`),KJ=document.createElement(`div`),GJ=document.createElement(`div`),WJ.append(KJ,GJ),document.body.appendChild(WJ),window.addEventListener(`resize`,ZJ),window.addEventListener(`orientationchange`,ZJ),eY(!0))}function nY(e){tY(),eY(!1,e)}function rY(){QJ(),window.removeEventListener(`resize`,ZJ),window.removeEventListener(`orientationchange`,ZJ),WJ?.remove(),WJ=null,GJ=null,KJ=null,JJ=-1,YJ=null}var iY=!1;function aY(e){let t=document.documentElement;if(iY||(iY=!0,Yd(()=>aY($P())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>aY($P()))),e){if(t.dataset.flyingAnimals=`true`,$J(e)){rY();return}tY();return}delete t.dataset.flyingAnimals,rY()}function oY(){let e=V(`div`),t=V(`p`,`flying-animals-status`);t.id=`flying-animals-gallery-status`,t.setAttribute(`role`,`status`);let n=V(`div`,`flying-animals-gallery`);n.setAttribute(`aria-label`,`Animal gallery`);let r=[],i=()=>{let e=$J(),n=SP(HF().flyingAnimalsExcludedSprites);t.textContent=[e,n?``:`No animals are included, so automatic flights are paused.`].filter(Boolean).join(` `);for(let t of r)t.disabled=e!==null},a=HF(),o=HJ({viewportWidthPx:1440,viewportHeightPx:900,verticalProgress:0});for(let e of _P){let s=V(`article`,`flying-animal-tile`),c=V(`div`,`flying-animal-preview`);c.setAttribute(`aria-hidden`,`true`),c.style.setProperty(`--nyan-width`,`${o.spriteWidthPx}px`),c.style.setProperty(`--nyan-height`,`${o.spriteHeightPx}px`);let l=V(`div`,`flying-animal-preview-stage`);l.append(V(`div`,`nyan-trail ${e.trail}`),V(`div`,`nyan-sprite ${e.sprite}`)),c.append(l);let u=V(`label`,`flying-animal-include`),d=V(`input`,`settings-view-checkbox`);d.type=`checkbox`,d.checked=!a.flyingAnimalsExcludedSprites.includes(e.sprite),d.setAttribute(`aria-label`,`Include ${e.name}`),d.addEventListener(`change`,()=>{let t=new Set(HF().flyingAnimalsExcludedSprites);d.checked&&t.delete(e.sprite),d.checked||t.add(e.sprite),VF([...t]),aY($P()),i()}),u.append(d,document.createTextNode(`Include`));let f=V(`button`,`btn-dialog btn-dialog-cancel`,`Fly now`);f.type=`button`,f.setAttribute(`aria-describedby`,t.id),f.addEventListener(`click`,()=>nY(e.sprite)),r.push(f),s.append(c,V(`h2`,`flying-animal-name`,e.name),u,f),n.append(s)}return i(),e.append(t,n),e}var sY=`johncwaters/glimmervoid`,cY=Object.freeze([`opened`,`checks-failed`,`review-requested`,`approved`,`commented`,`merged`]),lY=Object.freeze([`notify`,`spawn`,`label`,`comment`]),uY=2e4,dY=65536,fY=/^[a-z0-9][a-z0-9-]{0,63}$/,pY=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,mY=/[\x00-\x1f\x7f,]|^-/,hY=(e,t)=>{let n=`${e} must be an integer between ${t.min} and ${t.max}`;return k({error:n}).int({error:n}).min(t.min,{error:n}).max(t.max,{error:n})},gY=A({error:`workflows.enabled must be a boolean`}),_Y=hY(`workflows.maxConcurrentSessions`,mP),vY=hY(`workflows.maxActionsPerPoll`,hP),yY=(e,t)=>j(t,{error:`${e} must be an array`}).min(1,{error:`${e} must list at least one entry when present`}),bY=O({error:`a workflow label name must be a string`}).trim().min(1,{error:`a workflow label name must not be empty`}).max(50,{error:`a workflow label name must be at most 50 characters`}).refine(e=>!mY.test(e),{error:`a workflow label name must not start with a dash or hold a comma or control character`}),xY=O({error:`a workflow comment body must be a string`}).min(1,{error:`a workflow comment body must not be empty`}).max(dY,{error:`a workflow comment body must be at most ${dY} characters`}).refine(e=>e.trim().length>0,{error:`a workflow comment body must not be blank`}),SY=P(cY,{error:`workflows.rules[].trigger must be one of ${cY.join(`, `)}`}),CY=fs(`type`,[N({type:F(`notify`)}),N({type:F(`spawn`),promptTemplate:O({error:`a spawn action needs a promptTemplate string`}).min(1,{error:`a spawn action promptTemplate must not be empty`}).max(uY,{error:`a spawn action promptTemplate must be at most ${uY} characters`}).refine(e=>e.trim().length>0,{error:`a spawn action promptTemplate must not be blank`})}),N({type:F(`label`),name:bY}),N({type:F(`comment`),body:xY})],{error:`workflows.rules[].actions[].type must be one of ${lY.join(`, `)}`}),wY=N({mine:A({error:`workflows.rules[].filters.mine must be a boolean`}).optional(),teamReviewRequested:A({error:`workflows.rules[].filters.teamReviewRequested must be a boolean`}).optional(),authors:yY(`workflows.rules[].filters.authors`,O({error:`workflows.rules[].filters.authors must hold GitHub logins`}).regex(pY,{error:`workflows.rules[].filters.authors must hold GitHub logins`})).optional(),labels:yY(`workflows.rules[].filters.labels`,bY).optional(),baseBranches:yY(`workflows.rules[].filters.baseBranches`,O({error:`workflows.rules[].filters.baseBranches must hold branch names`}).min(1,{error:`workflows.rules[].filters.baseBranches must hold branch names`})).optional()},{error:`workflows.rules[].filters must be an object`}),TY=O({error:`workflows.rules[].id must be a string`}).regex(fY,{error:`workflows.rules[].id must be 1 to 64 lowercase letters, digits and dashes, starting with a letter or digit`}),EY=A({error:`workflows.rules[].enabled must be a boolean`}),DY=N({id:TY,name:O({error:`workflows.rules[].name must be a string`}).trim().min(1,{error:`workflows.rules[].name must not be empty`}).max(80,{error:`workflows.rules[].name must be at most 80 characters`}),enabled:EY.default(!1),repos:yY(`workflows.rules[].repos`,Sl),filters:wY.default({}),trigger:SY,actions:yY(`workflows.rules[].actions`,CY)},{error:`workflows.rules[] must be an object`}),OY=N({enabled:gY.default(!0),maxConcurrentSessions:_Y.default(2),maxActionsPerPoll:vY.default(20),rules:j(DY,{error:`workflows.rules must be an array`}).default([])},{error:`workflows must be an object`}).superRefine((e,t)=>{let n=new Set;for(let[r,i]of e.rules.entries()){if(!n.has(i.id)){n.add(i.id);continue}t.addIssue({code:`custom`,path:[`rules`,r,`id`],message:`workflows.rules[${r}].id "${i.id}" is declared more than once`})}}),kY=N({id:TY,enabled:EY},{error:`a dashboard update of workflows.rules[] carries only id and enabled`});N({enabled:gY.optional(),maxConcurrentSessions:_Y.optional(),maxActionsPerPoll:vY.optional(),rules:j(kY,{error:`workflows.rules must be an array`}).optional()},{error:`a dashboard update of workflows carries only enabled, maxConcurrentSessions, maxActionsPerPoll and rule toggles`});var AY=k().int().nonnegative(),jY=P([`SUCCESS`,`FAILURE`,`PENDING`,`ERROR`,`EXPECTED`]).nullable();Wl.extend({author:M({login:O()}).nullable(),labels:M({nodes:j(M({name:O()}))}),comments:M({totalCount:AY})});var MY=N({polledAtMs:AY,prs:j(N({repo:Sl,number:k().int().positive(),title:O(),url:Ro(),author:O().nullable(),state:P([`OPEN`,`MERGED`,`CLOSED`]),createdAt:O(),mergedAt:O().nullable(),isDraft:A(),isCrossRepository:A(),baseRefName:O(),headRefName:O().min(1),headRefOid:L,labels:j(O()),commentCount:AY,reviewRequests:j(O()),checksState:jY,reviewDecision:P([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]).nullable()}))});N({repos:ms(O().regex(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*$/),MY)});var NY=Object.freeze({general:`machine-general`,updates:`machine-updates`,terminal:`machine-terminal`,repos:`machine-repositories`,repositories:`machine-repositories`,advanced:`machine-detection-sessions`,detection:`machine-detection-sessions`,telegram:`machine-telegram`,notifications:`machine-telegram`,"change-map":`lanes-change-map`,visions:`lanes-visions`,ingest:`lanes-ingest`,posthog:`lanes-posthog`,"team-review":`lanes-team-review`,reviews:`lanes-team-review`,benchmarks:`lanes-benchmarks`,workflows:`lanes-workflows`,usage:`machine-usage`,privacy:`machine-privacy`,telemetry:`machine-privacy`,shortcuts:`browser-shortcuts`,animals:`browser-flying-animals`,"flying-animals":`browser-flying-animals`,unattended:`lanes-unattended`}),PY=Object.freeze({"browser-appearance":Object.freeze({"flying-animals":`browser-flying-animals`})}),FY=Object.freeze([{id:`browser-appearance`,level:`browser`,title:`Appearance and alerts`,description:`Preferences stored only in this browser.`,settings:[{id:`theme`,path:`pref:themeId`,title:`Theme`,description:`Color scheme for the dashboard.`,control:`select`,optionsFrom:`themes`,keywords:[`color`,`palette`],defaultValue:`phyrexian`},{id:`compact-status`,path:`pref:compactStatusLabels`,title:`Hide status words in sidebar`,description:`Show only the colored status dot in the sidebar. Phone status labels stay visible.`,control:`toggle`,keywords:[`sidebar`,`status`,`compact`],defaultValue:!1},{id:`session-usage-chips`,path:`pref:sessionUsageChips`,title:`Show usage on session cards`,description:`Shows each card's token count and estimated API list-price cost.`,control:`toggle`,keywords:[`usage`,`cost`,`tokens`,`card`,`price`],defaultValue:!1},{id:`alert-sound`,path:`pref:soundId`,title:`Alert sound`,description:`Sound played when a session needs attention. Your own .ogg, .mp3, .wav, .m4a or .webm files dropped into the sounds folder of the Glimmervoid home (~/.glimmervoid/sounds/, or $GLIMMERVOID_HOME/sounds/) are listed after the built-in sounds. Glimmervoid never creates that folder, so make it yourself; new files show up the next time Settings opens.`,control:`select`,optionsFrom:`sounds`,keywords:[`audio`,`notification`,`custom`],defaultValue:`chime`},{id:`desktop-notifications`,path:`pref:notificationsEnabled`,title:`Desktop notifications`,description:`Raise a browser notification when a session needs attention while this dashboard is in the background.`,control:`toggle`,keywords:[`browser`,`attention`],defaultValue:!0}]},{id:`browser-flying-animals`,level:`browser`,title:`Flying animals`,description:`Choose your flying animals. Changes apply immediately in this browser.`,settings:[{id:`flying-animals`,path:`pref:flyingAnimalsEnabled`,title:`Flying animals`,description:`Show animated animals flying across the dashboard.`,control:`toggle`,keywords:[`animation`,`motion`],defaultValue:!1},{id:`animals-min-gap`,path:`pref:flyingAnimalsMinGapSeconds`,title:`Time between flights: minimum (seconds)`,description:`Shortest pause between flights.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_GAP_RANGE`,maximumSettingId:`animals-max-gap`,keywords:[`animals`,`frequency`],defaultValue:vP.flyingAnimalsMinGapSeconds},{id:`animals-max-gap`,path:`pref:flyingAnimalsMaxGapSeconds`,title:`Time between flights: maximum (seconds)`,description:`Longest pause between flights.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_GAP_RANGE`,keywords:[`animals`,`frequency`],defaultValue:vP.flyingAnimalsMaxGapSeconds},{id:`animals-min-duration`,path:`pref:flyingAnimalsMinDurationSeconds`,title:`Flight duration: minimum (seconds)`,description:`Shortest flight, for faster animals.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_DURATION_RANGE`,maximumSettingId:`animals-max-duration`,keywords:[`animals`,`speed`],defaultValue:vP.flyingAnimalsMinDurationSeconds},{id:`animals-max-duration`,path:`pref:flyingAnimalsMaxDurationSeconds`,title:`Flight duration: maximum (seconds)`,description:`Longest flight, for slower animals.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_DURATION_RANGE`,keywords:[`animals`,`speed`],defaultValue:vP.flyingAnimalsMaxDurationSeconds},{id:`animals-scale`,path:`pref:flyingAnimalsScale`,title:`Size multiplier`,description:`Scale applied on top of the viewport size.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_SCALE_RANGE`,keywords:[`animals`,`size`],defaultValue:vP.flyingAnimalsScale},{id:`animals-on-phone`,path:`pref:flyingAnimalsOnPhone`,title:`Show on phone layout`,description:`Allow flights on the phone layout.`,control:`toggle`,advanced:!0,keywords:[`animals`,`mobile`],defaultValue:vP.flyingAnimalsOnPhone}]},{id:`browser-shortcuts`,level:`browser`,title:`Shortcuts and about`,description:`Keyboard reference and build information.`,settings:[]},{id:`machine-general`,level:`machine`,title:`General`,description:`Machine-wide session startup and diagnostics.`,settings:[{id:`auto-resume`,path:`autoResume`,title:`Auto-resume sessions on startup`,description:`Resume conversations that were live when Glimmervoid last shut down or crashed.`,control:`toggle`,keywords:[`startup`,`conversation`],defaultValue:!0},{id:`debug-mode`,path:`debugMode`,title:`Debug mode`,description:`Show session-card diagnostics for state, transitions and detection signals.`,control:`toggle`,keywords:[`diagnostics`,`state`],defaultValue:!1},{id:`calm-layout`,path:`calmLayout`,title:`Calm layout (experimental)`,description:`Replace the Focus rail with a priority view that surfaces only sessions needing you. Applies to every browser on this machine.`,control:`toggle`,keywords:[`experimental`,`attention`,`priority`],defaultValue:!1}],unattendedLinks:[{settingId:`skip-permissions-by-default`,title:`Skip permission prompts by default`},{settingId:`rtk-compression`,title:`rtk output compression`}]},{id:`machine-updates`,level:`machine`,title:`Updates`,description:`See which Glimmervoid version is running, which one is newest, and update in one step.`,settings:[{id:`update-summary`,path:`checkForUpdates`,title:`Status`,description:`Whether this install is up to date, and what an update would move it to.`,control:`readonly`,keywords:[`version`,`available`,`current`],status:`update-summary`},{id:`update-actions`,path:`checkForUpdates`,title:`Actions`,description:`Update and restart stages the newest build, then restarts to run it. Update without restart stages it for a later restart.`,control:`readonly`,keywords:[`check`,`restart`],status:`update-actions`},{id:`update-installed`,path:`checkForUpdates`,title:`Running version`,description:`The version, commit, branch and checkout state running now.`,control:`readonly`,keywords:[`version`,`commit`,`installed`],status:`update-installed`},{id:`update-latest`,path:`updateChannel`,title:`Latest version`,description:`The newest target found on the selected update channel.`,control:`readonly`,keywords:[`release`,`commit`],status:`update-latest`},{id:`update-last-checked`,path:`checkForUpdates`,title:`Last checked`,description:`The most recent update check, or why automatic checks are off.`,control:`readonly`,keywords:[`time`,`failure`],status:`update-last-checked`},{id:`update-channel`,path:`updateChannel`,title:`Channel`,description:`Track tagged releases or the upstream of the checked-out branch.`,control:`select`,options:[{value:`release`,label:`Release`},{value:`main`,label:`Main`}],keywords:[`release`,`branch`],defaultValue:`release`},{id:`check-updates`,path:`checkForUpdates`,title:`Check for updates automatically`,description:`Check for a newer Glimmervoid at launch, while a dashboard is connected, and when this page opens.`,control:`toggle`,keywords:[`release`,`github`],defaultValue:!0}]},{id:`machine-terminal`,level:`machine`,title:`Terminal`,description:`Terminal behavior shared by dashboard clients.`,settings:[{id:`replay-buffer`,path:`replayBufferKB`,title:`Replay buffer (KB)`,description:`PTY output retained for clients that reconnect or join late.`,control:`number`,range:`REPLAY_BUFFER_KB_RANGE`,keywords:[`history`,`backfill`],defaultValue:512},{id:`cursor-blink`,path:`cursorBlink`,title:`Cursor blink`,description:`Blink the cursor in every terminal.`,control:`toggle`,keywords:[`caret`,`terminal`],defaultValue:!1}]},{id:`machine-detection-sessions`,level:`machine`,title:`Detection and sessions`,description:`Config-file-only detection, timing, worktree and process settings.`,settings:[{id:`file-detect-background-agents`,path:`detectBackgroundAgents`,title:`Detect background agents`,description:`Hold completion while tracked background work is active.`,control:`readonly`,keywords:[`subagents`,`completion`],fileOnly:!0},{id:`file-record-signals`,path:`recordSignals`,title:`Record structural signals`,description:`Keep forensic status and hook recordings.`,control:`readonly`,keywords:[`recordings`,`diagnostics`],fileOnly:!0},{id:`file-trace-enabled`,path:`trace.enabled`,title:`Capture session traces`,description:`Keep normalized Claude transcript traces for session debugging.`,control:`readonly`,keywords:[`transcripts`,`diagnostics`],fileOnly:!0},{id:`file-anti-slop-prompt`,path:`antiSlopPrompt`,title:`Anti-slop prompt`,description:`Append the configured quality prompt to session instructions.`,control:`readonly`,keywords:[`quality`,`instructions`],fileOnly:!0},{id:`file-detect-scheduled-wakeups`,path:`detectScheduledWakeups`,title:`Detect scheduled wakeups`,description:`Surface advisory wakeup timing for scheduled sessions.`,control:`readonly`,keywords:[`schedule`,`sleep`],fileOnly:!0},{id:`file-worktree-auto-rebase`,path:`worktreeAutoRebase`,title:`Worktree auto-rebase`,description:`Rebase eligible session worktrees when the integration branch moves.`,control:`readonly`,keywords:[`git`,`branch`],fileOnly:!0},{id:`file-worktree-rerere`,path:`worktreeRerere`,title:`Worktree rerere`,description:`Reuse recorded Git conflict resolutions.`,control:`readonly`,keywords:[`git`,`conflicts`],fileOnly:!0},{id:`file-integration-branch`,path:`integrationBranch`,title:`Integration branch`,description:`Base branch for session worktrees. Empty = each repo's default branch.`,control:`readonly`,keywords:[`git`,`merge`],fileOnly:!0},{id:`file-worktree-root`,path:`worktreeRoot`,title:`Worktree root`,description:`Directory that contains session worktrees.`,control:`readonly`,keywords:[`git`,`directory`],fileOnly:!0},{id:`file-worktree-share`,path:`worktreeShare`,title:`Shared worktree paths`,description:`Local paths copied or linked into worktrees.`,control:`readonly`,keywords:[`files`,`context`],fileOnly:!0},{id:`file-port`,path:`port`,title:`Local port`,description:`Port used by the local dashboard listener.`,control:`readonly`,keywords:[`server`,`listener`],fileOnly:!0},{id:`file-auto-recover-seconds`,path:`autoRecoverSeconds`,title:`Auto-recovery delay`,description:`Delay before an interrupted state can recover.`,control:`readonly`,keywords:[`timer`,`recovery`],fileOnly:!0},{id:`file-input-grace-seconds`,path:`inputGraceSeconds`,title:`Input grace period`,description:`Grace window around operator input.`,control:`readonly`,keywords:[`timer`,`prompt`],fileOnly:!0},{id:`file-prompt-detection-ms`,path:`promptDetectionMs`,title:`Prompt detection delay`,description:`Timing threshold used by prompt detection.`,control:`readonly`,keywords:[`timer`,`detection`],fileOnly:!0},{id:`file-notify-debounce-ms`,path:`notifyDebounceMs`,title:`Notification debounce`,description:`Delay used to coalesce notification state changes.`,control:`readonly`,keywords:[`timer`,`alerts`],fileOnly:!0},{id:`file-phone-escalation-ms`,path:`phoneEscalationMs`,title:`Phone escalation delay`,description:`Delay before off-dashboard escalation.`,control:`readonly`,keywords:[`timer`,`telegram`],fileOnly:!0},{id:`file-post-turn-checks`,path:`postTurnChecks`,title:`Post-turn checks`,description:`Deterministic checks run after eligible turns. They only report findings unless mode is fix.`,control:`readonly`,keywords:[`quality`,`fixes`],fileOnly:!0},{id:`file-branch-gc-enabled`,path:`branchGc.enabled`,title:`Branch cleanup`,description:`Enable cleanup of eligible session branches.`,control:`readonly`,keywords:[`git`,`cleanup`],fileOnly:!0},{id:`file-branch-gc-worktrees`,path:`branchGc.worktrees`,title:`Local worktree cleanup`,description:`Enable cleanup of eligible local worktrees.`,control:`readonly`,keywords:[`git`,`worktree`,`cleanup`],fileOnly:!0},{id:`file-branch-gc-prefixes`,path:`branchGc.prefixes`,title:`Branch cleanup prefixes`,description:`Remote branch prefixes eligible for cleanup.`,control:`readonly`,keywords:[`git`,`branch`],fileOnly:!0},{id:`file-branch-gc-dry-run`,path:`branchGc.dryRun`,title:`Branch cleanup dry run`,description:`Report planned cleanup without deleting remote branches.`,control:`readonly`,keywords:[`git`,`safety`],fileOnly:!0},{id:`file-branch-gc-stale-days`,path:`branchGc.staleDays`,title:`Branch stale days`,description:`Age threshold for orphan branch cleanup when unmerged deletion is on.`,control:`readonly`,keywords:[`git`,`retention`],fileOnly:!0},{id:`file-branch-gc-interval-ms`,path:`branchGc.intervalMs`,title:`Branch cleanup interval`,description:`Delay between branch cleanup passes.`,control:`readonly`,keywords:[`git`,`schedule`],fileOnly:!0},{id:`file-custom-agents`,path:`customAgents`,title:`Custom agents`,description:`Extra agent CLIs a session can be spawned with.`,control:`readonly`,keywords:[`adapters`,`cli`],fileOnly:!0,status:`custom-agents`}]},{id:`machine-repositories`,level:`machine`,title:`Repositories`,description:`Project discovery roots for new sessions.`,settings:[{id:`repository-roots`,path:`repoRoots`,title:`Repository roots`,description:`Directories scanned for projects when adding sessions.`,control:`list`,keywords:[`folders`,`project discovery`],defaultValue:[]}]},{id:`machine-telegram`,level:`machine`,title:`Telegram`,description:`One bot shared by session, PR review and PostHog notifications.`,settings:[{id:`telegram-bot-token`,path:`telegram.botToken`,title:`Bot token`,description:`Credential used by the shared Telegram bot.`,control:`password`,keywords:[`credential`,`api`],defaultValue:``},{id:`telegram-chat-id`,path:`telegram.chatId`,title:`Chat id`,description:`Destination chat for enabled Telegram lanes.`,control:`text`,keywords:[`destination`,`channel`],defaultValue:``},{id:`telegram-session-notifications`,path:`telegramNotifications`,title:`Send session notifications`,description:`Ping when a session completes, needs input or fails and no dashboard is open.`,control:`toggle`,keywords:[`phone`,`off dashboard`],defaultValue:!1}]},{id:`machine-usage`,level:`machine`,title:`Usage`,description:`Local transcript accounting and estimated-cost budgets.`,settings:[{id:`usage-enabled`,path:`usage.enabled`,title:`Track token usage`,description:`Read local CLI transcripts and roll them into the Usage view and session chips.`,control:`toggle`,keywords:[`tokens`,`cost`],defaultValue:!0,status:`usage-last-report`},{id:`usage-codex`,path:`usage.vendors.codex`,title:`Track Codex usage`,description:`Include local Codex CLI transcripts in usage reports.`,control:`toggle`,keywords:[`openai`,`vendor`],defaultValue:!0},{id:`usage-grok`,path:`usage.vendors.grok`,title:`Track Grok usage`,description:`Include local Grok CLI transcripts in usage reports.`,control:`toggle`,keywords:[`xai`,`vendor`],defaultValue:!0},{id:`usage-fetch-pricing`,path:`usage.fetchPricing`,title:`Fetch current model prices`,description:`Refresh the public price table daily instead of relying only on the bundled snapshot.`,control:`toggle`,keywords:[`rates`,`models`],defaultValue:!0},{id:`usage-scan-interval`,path:`usage.scanIntervalMinutes`,title:`Scan interval (minutes)`,description:`Delay between completed transcript scans.`,control:`number`,range:`USAGE_SCAN_INTERVAL_RANGE`,keywords:[`poll`,`refresh`],defaultValue:5},{id:`usage-retain-days`,path:`usage.retainDays`,title:`Retain transcript detail (days)`,description:`How long live transcript detail stays available.`,control:`number`,range:`USAGE_RETAIN_DAYS_RANGE`,keywords:[`history`,`retention`],defaultValue:90},{id:`usage-cost-mode`,path:`usage.costMode`,title:`Cost mode`,description:`Choose whether recorded costs, calculated costs or both can appear.`,control:`select`,options:[{value:`auto`,label:`Auto`},{value:`calculate`,label:`Calculate`},{value:`display`,label:`Display`}],keywords:[`pricing`,`estimate`],defaultValue:`auto`},{id:`usage-daily-budget`,path:`usage.budget.dailyUsd`,title:`Daily budget (USD)`,description:`Estimated daily spend ceiling. Zero or below means no ceiling.`,control:`number`,range:`USAGE_BUDGET_RANGE`,keywords:[`spend`,`alert`],defaultValue:null,integer:!1,nullable:!0,zeroIsNull:!0,step:.01},{id:`usage-monthly-budget`,path:`usage.budget.monthlyUsd`,title:`Monthly budget (USD)`,description:`Estimated monthly spend ceiling. Zero or below means no ceiling.`,control:`number`,range:`USAGE_BUDGET_RANGE`,keywords:[`spend`,`alert`],defaultValue:null,integer:!1,nullable:!0,zeroIsNull:!0,step:.01}]},{id:`machine-privacy`,level:`machine`,title:`Privacy`,description:`What Glimmervoid sends about itself.`,settings:[{id:`telemetry-enabled`,path:`telemetry.enabled`,title:`Send anonymous usage and error data`,description:`Version, platform, app starts, daily activity, session starts and ends with agent kind, exit kind and duration, errors as their type, error code and scrubbed stack frames, and per session token counts, models and estimated costs from the usage scan, under a random install id. Never error messages, paths, repository or branch names, prompts or terminal output. GLIMMERVOID_TELEMETRY=0, DO_NOT_TRACK=1 or CI=true turn it off regardless.`,control:`toggle`,keywords:[`telemetry`,`analytics`,`tracking`,`opt out`],defaultValue:!0}]},{id:`lanes-change-map`,level:`lanes`,title:`Change map`,description:`Optional model narration for deterministic change facts.`,settings:[{id:`change-map-narrator-enabled`,path:`changeMap.narrator.enabled`,title:`Enable narration`,description:`Add cited model claims to the change map.`,control:`toggle`,keywords:[`review`,`claims`],defaultValue:!1},{id:`change-map-narrator-engine`,path:`changeMap.narrator.engine`,title:`Narrator engine`,description:`CLI used to generate change map claims.`,control:`select`,options:[{value:`claude`,label:`Claude`},{value:`codex`,label:`Codex`}],keywords:[`claude`,`codex`],defaultValue:`claude`},{id:`change-map-narrator-model`,path:`changeMap.narrator.model`,title:`Narrator model`,description:`Blank uses the engine default: haiku for Claude, the configured Codex model for Codex.`,control:`text`,keywords:[`claude`,`codex`,`haiku`],defaultValue:``},{id:`change-map-narrator-timeout`,path:`changeMap.narrator.timeoutSeconds`,title:`Narrator timeout (seconds)`,description:`Maximum time allowed for one narration.`,control:`number`,range:`CHANGE_MAP_NARRATOR_TIMEOUT_RANGE`,keywords:[`deadline`,`narration`],defaultValue:90}]},{id:`lanes-visions`,level:`lanes`,title:`Visions`,description:`Editor-buffer findings and bounded model comments.`,settings:[{id:`visions-enabled`,path:`visions.enabled`,title:`Enable Visions`,description:`Wires every editor on this machine, then shows their buffers findings in the Visions view.`,control:`toggle`,keywords:[`editor`,`findings`,`lsp`],defaultValue:!1},{id:`visions-dispatch-enabled`,path:`visions.dispatch.enabled`,title:`Enable model comments`,description:`Start bounded review sessions for local editor buffers.`,control:`toggle`,keywords:[`review`,`dispatch`],defaultValue:!1},{id:`visions-quiet-delay`,path:`visions.dispatch.quietMs`,title:`Quiet delay (ms)`,description:`Required editor quiet time before dispatch.`,control:`number`,range:`VISIONS_QUIET_MS_RANGE`,keywords:[`debounce`,`idle`],defaultValue:3e4},{id:`visions-cooldown`,path:`visions.dispatch.cooldownMs`,title:`Cooldown (ms)`,description:`Minimum delay between review dispatches.`,control:`number`,range:`VISIONS_COOLDOWN_MS_RANGE`,keywords:[`rate limit`,`delay`],defaultValue:3e5},{id:`visions-max-per-hour`,path:`visions.dispatch.maxPerHour`,title:`Max per hour`,description:`Maximum review sessions dispatched per hour.`,control:`number`,range:`VISIONS_MAX_PER_HOUR_RANGE`,keywords:[`rate limit`,`reviews`],defaultValue:6},{id:`visions-activity-max-per-hour`,path:`visions.dispatch.activityMaxPerHour`,title:`Activity max per hour`,description:`Maximum activity-driven reviews dispatched per hour.`,control:`number`,range:`VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE`,keywords:[`rate limit`,`events`],defaultValue:2},{id:`visions-dispatch-timeout`,path:`visions.dispatch.dispatchTimeoutSeconds`,title:`Dispatch timeout (seconds)`,description:`Maximum time allowed for one review session.`,control:`number`,range:`VISIONS_DISPATCH_TIMEOUT_RANGE`,keywords:[`deadline`,`review`],defaultValue:180},{id:`visions-intent-thread-ttl`,path:`visions.intent.threadTtlMs`,title:`Intent thread lifetime (ms)`,description:`How long an intent thread nobody advanced stays live before it retires.`,control:`number`,range:`VISIONS_INTENT_THREAD_TTL_MS_RANGE`,keywords:[`intent`,`decay`,`thread`],defaultValue:2592e5},{id:`visions-model`,path:`visions.dispatch.model`,title:`Model override`,description:`Leave blank to use the configured Claude Code default.`,control:`text`,keywords:[`claude`,`override`],defaultValue:``},{id:`visions-projects`,path:`visions.projects`,title:`Projects`,description:`Leave every project clear to accept buffers from every configured project.`,control:`projects`,keywords:[`repositories`,`filter`],defaultValue:[]},{id:`visions-auto-fix`,path:`visions.autoFix`,title:`Apply tier 1 fixes`,description:`Allow Visions to edit the active buffer without asking.`,control:`toggle`,keywords:[`automatic`,`edits`],danger:!0,warning:`Enabling this control lets Visions edit eligible buffers without a carbon unit present.`,defaultValue:!1}]},{id:`lanes-ingest`,level:`lanes`,title:`Ingest`,description:`Machine-context ingest behind Visions.`,settings:[{id:`ingest-enabled`,path:`ingest.enabled`,title:`Enable machine context ingest`,description:`Enable the local activity feed behind Visions. Turning Visions on turns this on for you.`,control:`toggle`,keywords:[`events`,`activity`],defaultValue:!1},{id:`ingest-terminal`,path:`ingest.sources.terminal.enabled`,title:`Terminal output source`,description:`Include terminal output in the ingest feed.`,control:`toggle`,keywords:[`pty`,`source`],defaultValue:!1},{id:`ingest-agent-logs`,path:`ingest.sources.agentLogs.enabled`,title:`Agent logs source`,description:`Include local agent logs in the ingest feed.`,control:`toggle`,keywords:[`transcript`,`source`],defaultValue:!1},{id:`ingest-git`,path:`ingest.sources.git.enabled`,title:`Git activity source`,description:`Include local Git activity in the ingest feed.`,control:`toggle`,keywords:[`commits`,`source`],defaultValue:!1},{id:`ingest-fs`,path:`ingest.sources.fs.enabled`,title:`File changes source`,description:`Include watched file changes in the ingest feed.`,control:`toggle`,keywords:[`filesystem`,`source`],defaultValue:!1},{id:`ingest-shell-history`,path:`ingest.sources.shellHistory.enabled`,title:`Shell history source`,description:`Include local shell history in the ingest feed.`,control:`toggle`,keywords:[`commands`,`source`],defaultValue:!1},{id:`ingest-editor`,path:`ingest.sources.editor.enabled`,title:`Editor events source`,description:`Include local editor events in the ingest feed.`,control:`toggle`,keywords:[`buffers`,`source`],defaultValue:!1}]},{id:`lanes-posthog`,level:`lanes`,title:`PostHog`,description:`Error monitoring, investigations and traffic-spike alerts.`,settings:[{id:`posthog-enabled`,path:`posthog.enabled`,title:`Enable PostHog monitoring`,description:`Poll PostHog error tracking and investigate issues that move.`,control:`toggle`,keywords:[`errors`,`monitoring`],defaultValue:!1},{id:`posthog-host`,path:`posthog.host`,title:`Host`,description:`PostHog cloud or self-hosted HTTP URL.`,control:`text`,keywords:[`url`,`server`],defaultValue:`https://us.posthog.com`},{id:`posthog-api-key`,path:`posthog.apiKey`,title:`Personal API key`,description:`Credential with read access to PostHog projects.`,control:`password`,keywords:[`credential`,`token`],defaultValue:``},{id:`posthog-projects`,path:`posthog.projects`,title:`Projects`,description:`Use all or a comma-separated list of numeric PostHog project ids.`,control:`text`,keywords:[`project ids`,`filter`],defaultValue:`all`,valueKind:`posthog-projects`},{id:`posthog-interval`,path:`posthog.intervalMinutes`,title:`Poll interval (minutes)`,description:`Delay between PostHog polling passes.`,control:`number`,range:`POSTHOG_INTERVAL_RANGE`,keywords:[`refresh`,`schedule`],defaultValue:15},{id:`posthog-max-investigations`,path:`posthog.maxConcurrentInvestigations`,title:`Max concurrent investigations`,description:`Maximum investigation sessions running together.`,control:`number`,range:`POSTHOG_MAX_CONCURRENT_RANGE`,keywords:[`parallel`,`workers`],defaultValue:2},{id:`posthog-investigation-timeout`,path:`posthog.investigationTimeoutSeconds`,title:`Investigation timeout (seconds)`,description:`Maximum time allowed for one investigation.`,control:`number`,range:`POSTHOG_INVESTIGATION_TIMEOUT_RANGE`,keywords:[`deadline`,`session`],defaultValue:900},{id:`posthog-min-users`,path:`posthog.minUsersToInvestigate`,title:`Min users to investigate`,description:`Minimum affected users before an issue is investigated.`,control:`number`,range:`POSTHOG_MIN_USERS_RANGE`,keywords:[`threshold`,`affected`],defaultValue:1},{id:`posthog-escalation`,path:`posthog.userEscalationThreshold`,title:`Escalation threshold (users)`,description:`Affected-user count that escalates an issue.`,control:`number`,range:`POSTHOG_ESCALATION_RANGE`,keywords:[`threshold`,`severity`],defaultValue:25},{id:`posthog-fix-timeout`,path:`posthog.fixTimeoutSeconds`,title:`Fix timeout (seconds)`,description:`Maximum time allowed for one fix session.`,control:`number`,range:`POSTHOG_FIX_TIMEOUT_RANGE`,keywords:[`deadline`,`repair`],defaultValue:1800},{id:`posthog-traffic-enabled`,path:`posthog.trafficSpikeEnabled`,title:`Traffic spike alerts`,description:`Ping when recent unique users exceed a project baseline.`,control:`toggle`,keywords:[`analytics`,`alert`],defaultValue:!0},{id:`posthog-traffic-multiplier`,path:`posthog.trafficSpikeMultiplier`,title:`Spike multiplier`,description:`Baseline multiplier required to classify a traffic spike.`,control:`number`,range:`POSTHOG_TRAFFIC_MULTIPLIER_RANGE`,keywords:[`baseline`,`ratio`],defaultValue:3},{id:`posthog-traffic-min-users`,path:`posthog.trafficSpikeMinUsers`,title:`Min users to alert`,description:`Minimum recent unique users required for a traffic alert.`,control:`number`,range:`POSTHOG_TRAFFIC_MIN_USERS_RANGE`,keywords:[`threshold`,`analytics`],defaultValue:10},{id:`posthog-traffic-cooldown`,path:`posthog.trafficSpikeCooldownMinutes`,title:`Spike cooldown (minutes)`,description:`Minimum delay between traffic alerts. Zero disables muting.`,control:`number`,range:`POSTHOG_TRAFFIC_COOLDOWN_RANGE`,keywords:[`silence`,`delay`],defaultValue:360},{id:`posthog-traffic-baseline`,path:`posthog.trafficSpikeBaselineDays`,title:`Baseline window (days)`,description:`Historical window used to calculate normal hourly traffic.`,control:`number`,range:`POSTHOG_TRAFFIC_BASELINE_RANGE`,keywords:[`history`,`analytics`],defaultValue:7},{id:`posthog-auto-fix`,path:`posthog.autoFix`,title:`Attempt fixes for major issues`,description:`Allow an isolated agent to fix an issue, push a branch and open a pull request.`,control:`toggle`,keywords:[`automatic`,`pull request`],danger:!0,warning:`Enabling this control lets PostHog fixes commit, push and open pull requests automatically.`,defaultValue:!1}]},{id:`lanes-team-review`,level:`lanes`,title:`Team review`,description:`Draft reviews of teammates' pull requests for you to post from the Reviews tab.`,settings:[{id:`team-review-enabled`,path:`teamReview.enabled`,title:`Enable team review`,description:`Poll open pull requests from the team and draft a review of each one. Nothing is posted until you choose Approve or Comment.`,control:`toggle`,keywords:[`pull requests`,`github`],defaultValue:!1},{id:`team-review-org`,path:`teamReview.org`,title:`GitHub organization`,description:`Organization login that owns the team, for example PostHog.`,control:`text`,keywords:[`github`,`owner`],defaultValue:``},{id:`team-review-team`,path:`teamReview.team`,title:`GitHub team`,description:`Team slug whose members and review requests are polled.`,control:`text`,keywords:[`github`,`slug`],defaultValue:``},{id:`team-review-re-review-after-hours`,path:`teamReview.reReviewAfterHours`,title:`Re-review after (hours)`,description:`When a reviewed PR has a new head, review it again after this many hours since its last review. Queue review runs it at any time.`,control:`number`,range:`POSTHOG_INTERVAL_RANGE`,keywords:[`review`,`delay`],defaultValue:24,integer:!1,step:.5},{id:`team-review-skip-idle-after-days`,path:`teamReview.skipIdleAfterDays`,title:`Skip PRs idle for (days)`,description:`Leave pull requests without GitHub activity for this long out of automatic review.`,control:`number`,range:`POSTHOG_INTERVAL_RANGE`,keywords:[`idle`,`activity`],defaultValue:14,integer:!1,step:.5},{id:`team-review-skill`,path:`teamReview.skill`,title:`Review skill`,description:`Name of a Claude Code skill installed for the review agent, for example your own PR review skill. Leave empty to let the agent review with whatever skills it has.`,control:`text`,keywords:[`skill`,`claude code`,`pr review`],defaultValue:``},{id:`team-review-auto-rebase-my-prs`,path:`teamReview.autoRebaseMyPrs`,title:`Keep my pull requests rebased`,description:`On each poll, rebase your open, non-draft pull requests that are behind their base branch. A pull request with conflicts or checks still running is left alone, and a failed rebase is not retried until you push again.`,control:`toggle`,keywords:[`rebase`,`update branch`,`behind`,`my prs`],danger:!0,warning:`Enabling this control rewrites your pull request branches on GitHub. Pull before you push from a local checkout of one.`,defaultValue:!1},{id:`team-review-keep-mergeable-enabled`,path:`teamReview.keepMergeableEnabled`,title:`Keep mergeable`,description:`Offer Keep mergeable on your pull requests: a sandboxed agent repairs conflicts and failing checks and pushes the repair. Off hides the control and starts no repair; the pull requests you chose stay chosen for when you turn it back on.`,control:`toggle`,keywords:[`repair`,`conflicts`,`my prs`],defaultValue:!0},{id:`team-review-keep-mergeable-timeout`,path:`teamReview.keepMergeableTimeoutMinutes`,title:`Keep mergeable deadline (minutes)`,description:`Longest a Keep mergeable repair session may run before it is stopped and nothing is pushed.`,control:`number`,range:`KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE`,keywords:[`timeout`,`repair`],defaultValue:30},{id:`team-review-merge-queue-enabled`,path:`teamReview.mergeQueueEnabled`,title:`Merge when ready`,description:`Offer Merge when ready on your pull requests: queued pull requests are rebased when behind and merged once ready, one per repository per poll. Off hides the control and merges nothing; the queue is kept for when you turn it back on.`,control:`toggle`,keywords:[`merge queue`,`auto merge`,`my prs`],defaultValue:!0}]},{id:`lanes-benchmarks`,level:`lanes`,title:`Benchmarks`,description:`Compare agent setups on frozen cases from the suites in the benchmarks folder of the Glimmervoid home.`,settings:[{id:`benchmarks-enabled`,path:`benchmarks.enabled`,title:`Enable benchmarks`,description:`Show the Bench tab. Nothing runs until you choose Mine or Run there.`,control:`toggle`,keywords:[`eval`,`arms`,`recall`,`compare`],defaultValue:!1}]},{id:`lanes-workflows`,level:`lanes`,title:`Workflows`,description:`Rules that act on pull request events in the repositories you choose.`,settings:[{id:`workflows-enabled`,path:`workflows.enabled`,title:`Run workflows`,description:`Poll the repositories your enabled rules watch and run their actions. Off stops polling and every action, whatever each rule says.`,control:`toggle`,keywords:[`pull requests`,`automation`,`master switch`],defaultValue:!0},{id:`workflows-max-concurrent-sessions`,path:`workflows.maxConcurrentSessions`,title:`Concurrent agent sessions`,description:`Most workflow agent sessions running at once. Later spawns wait for a free slot.`,control:`number`,range:`WORKFLOWS_MAX_CONCURRENT_SESSIONS_RANGE`,keywords:[`parallel`,`spawn`],defaultValue:2},{id:`workflows-max-actions-per-poll`,path:`workflows.maxActionsPerPoll`,title:`Actions per poll`,description:`Most actions run in one poll. The rest are dropped and logged.`,control:`number`,range:`WORKFLOWS_MAX_ACTIONS_PER_POLL_RANGE`,keywords:[`cap`,`rate limit`],defaultValue:20},{id:`workflows-rules`,path:`workflows`,title:`Workflow rules`,description:`Each rule watches repositories for one pull request event (opened, checks-failed, review-requested, approved, commented or merged), narrows it by author, labels, base branch, your own pull requests or a review request to your team, and then notifies you, labels or comments on the pull request, or starts a sandboxed agent session that pushes nothing. Rules start disabled. Turn each rule on or off here; everything else about a rule is set in config.json.`,control:`readonly`,keywords:[`pull requests`,`automation`,`github`,`rules`],fileOnly:!0,status:`workflows`}]},{id:`lanes-unattended`,level:`lanes`,title:`Unattended actions`,description:`Controls that let automated work change repositories or install executable tooling.`,settings:[{id:`skip-permissions-by-default`,path:`skipPermissionsByDefault`,title:`Skip permission prompts by default`,description:`Start sessions whose project sets no permission choice with the agent CLI permission bypass flag.`,control:`toggle`,keywords:[`permissions`,`yolo`,`dangerously`],danger:!0,warning:`Enabling this control lets agents edit files and run shell commands without asking, and restarts running sessions that inherit it.`,defaultValue:!1},{id:`sane-yolo`,path:`saneYolo`,title:`Sane YOLO`,description:`Block catastrophic commands (deleting home or root, discarding uncommitted work, force pushes, disk wipes, infrastructure destroy) in sessions that skip permission prompts. Applies to sessions created after the change.`,control:`toggle`,keywords:[`permissions`,`yolo`,`safety`],defaultValue:!0},{id:`branch-gc-delete-unmerged`,path:`branchGc.deleteUnmerged`,title:`Delete unmerged branches`,description:`Also delete stale remote branches with no merge proof. Off keeps every unmerged branch.`,control:`toggle`,keywords:[`git`,`cleanup`,`orphan`],danger:!0,warning:`Enabling this control lets branch cleanup delete stale remote branches without merge proof.`,defaultValue:!1},{id:`post-turn-checks-mode`,path:`postTurnChecks.mode`,title:`Post-turn checks mode`,description:`Report findings or let post-turn checks fix eligible files.`,control:`select`,options:[{value:`report`,label:`Report`},{value:`fix`,label:`Fix`}],keywords:[`quality`,`fixes`],defaultValue:`report`},{id:`agent-api-enabled`,path:`agentApi.enabled`,title:`Agent API`,description:`Expose the per-session agent endpoint to running sessions.`,control:`toggle`,keywords:[`session`,`localhost`],danger:!0,warning:`Enabling this control lets a running session spawn sibling sessions, flag itself and read the board through a per-session token on localhost, and it applies to sessions spawned after the change.`,defaultValue:!1},{id:`rtk-compression`,path:`rtk`,title:`rtk output compression`,description:`Compress Bash output for newly spawned or restarted sessions.`,control:`toggle`,keywords:[`bash`,`tokens`],danger:!0,status:`rtk-install`,warning:`Enabling this control permits Glimmervoid to install the pinned rtk executable automatically.`,defaultValue:!1}]}]);function IY(e){return[e.repos.join(`, `),e.trigger,e.actions.map(e=>e.type).join(`, `)].join(` `)}function LY(e){if(e==null)return[`No rules. Add workflows.rules to config.json.`];let t=OY.safeParse(e);return t.success?t.data.rules.length===0?[`No rules. Add workflows.rules to config.json.`]:t.data.rules.map(e=>[e.name,e.enabled?`enabled`:`disabled`,IY(e)].join(` `)):[`The workflows block is invalid, so no rule runs: ${t.error.issues[0]?.message??`unknown problem`}`]}function RY(e){let t=OY.safeParse(e??{});return t.success?t.data.rules.map(e=>({id:e.id,name:e.name,isEnabled:e.enabled,summary:IY(e)})):[]}function zY(e){let t=e.workflows;return typeof t!=`object`||!t||Array.isArray(t)?e:{...e,workflows:Object.fromEntries(Object.entries(t).filter(([e])=>e!==`rules`))}}function BY({checked:e=[],stored:t=[],rendered:n=[]}={}){let r=new Set(n),i=[...e];for(let e of t)typeof e==`string`&&e.trim()&&(r.has(e)||i.includes(e)||i.push(e));return i}var VY=new WeakMap,HY=`Configured`,UY=`•`.repeat(12);function WY(e){return e.control===`password`}function GY(e){return`${e.path}${HY}`}function KY(e){return Array.isArray(e)?e.map(KY):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,KY(t)]))}function qY(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function JY(e,t){let n=t.split(`.`),r=e;for(let e of n.slice(0,-1)){if(!r||typeof r!=`object`)return;r=r[e]}r&&typeof r==`object`&&delete r[n.at(-1)]}function YY(e,t,n){let r=t.split(`.`),i=e;for(let e of r.slice(0,-1))(!i[e]||typeof i[e]!=`object`||Array.isArray(i[e]))&&(i[e]={}),i=i[e];i[r.at(-1)]=KY(n)}function XY(e){return e.flatMap(e=>e.settings||[])}function ZY(e){return e.fileOnly||e.control===`readonly`}function QY(e){return String(e||``).toLowerCase().match(/[a-z0-9]+/g)||[]}function $Y(e,t,n){return t.every(t=>e.includes(t))?t.length*n:0}function eX(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>eX(e,t[n]));if(!e||!t||typeof e!=`object`||typeof t!=`object`)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&eX(e[n],t[n]))}function tX(e,t){return e.valueKind===`posthog-projects`?Array.isArray(t)?t.join(`, `):t??`all`:KY(t)}function nX(e,t){if(e.control===`number`){if(e.nullable&&(t==null||String(t).trim()===``))return null;let n=Number(t);return e.zeroIsNull&&n<=0?null:n}if(e.valueKind===`posthog-projects`){let e=String(t??``).trim();return!e||e.toLowerCase()===`all`?`all`:e.split(`,`).map(e=>Number(e.trim())).filter(Number.isFinite)}return e.control===`text`||e.control===`password`?String(t??``).trim():KY(t)}function rX(e){return VY.get(e)||null}function iX(e,t={}){let n={};for(let r of XY(e)){if(ZY(r))continue;if(r.path.startsWith(`pref:`)){let e=r.path.slice(5),i=t.prefs?.[e]??t[r.path];n[r.path]=tX(r,i??r.defaultValue);continue}if(WY(r)){let e=qY(t,GY(r))===!0;n[r.path]=e?UY:``;continue}let e=qY(t,r.path);n[r.path]=tX(r,e??r.defaultValue)}return VY.set(n,KY(t)),n}function aX(e,t,n,r,i={}){let{rehydrateSectionIds:a=[]}=i,o=iX(e,t),s=iX(e,t);if(!n||!r)return{original:o,edited:s};let c=new Set(a);for(let t of e)if(!c.has(t.id)&&t.settings.some(e=>!e.path.startsWith(`pref:`)&&!eX(n[e.path],r[e.path])))for(let e of t.settings)o[e.path]=KY(n[e.path]),s[e.path]=KY(r[e.path]);return{original:o,edited:s}}function oX(e,t,n){let r=XY(e).filter(e=>ZY(e)||e.path.startsWith(`pref:`)||WY(e)&&n[e.path]===UY?!1:!eX(t[e.path],n[e.path]));if(r.length===0)return{};let i=rX(t)||{},a=(Array.isArray(i.projectChoices)?i.projectChoices:[]).map(e=>e.id).filter(e=>typeof e==`string`),o={},s=new Set;for(let e of r){let[r]=e.path.split(`.`);if(!e.path.includes(`.`)){o[r]=nX(e,n[e.path]);continue}if(!s.has(r)){let e=i[r];o[r]=e&&typeof e==`object`&&!Array.isArray(e)?KY(e):{},s.add(r)}let c=nX(e,n[e.path]);if(e.control===`projects`){let n=t[e.path];c=BY({checked:Array.isArray(c)?c:[],stored:Array.isArray(n)?n:[],rendered:a})}YY(o,e.path,c)}for(let t of XY(e))WY(t)&&JY(o,GY(t));return o}function sX(e,t){let n=t.integer===!1?`number`:`whole number`;return e.exclusiveMin?`Must be a positive ${n}.`:e.max==null?`Must be a ${n} of at least ${e.min}.`:`Must be a ${n} between ${e.min} and ${e.max}.`}function cX(e,t,n){if(e.nullable&&(t==null||String(t).trim()===``))return null;let r=Number(t),i=n[e.range??``];return i?!Number.isFinite(r)||e.integer!==!1&&!Number.isInteger(r)?sX(i,e):i.exclusiveMin&&r<=i.min?e.zeroIsNull&&r<=0?null:sX(i,e):!i.exclusiveMin&&r<i.min||i.max!=null&&r>i.max?sX(i,e):null:`Allowed range is unavailable.`}function lX(e){let t=String(e??``).trim();if(!t||t.toLowerCase()===`all`)return null;let n=t.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length>0&&n.every(e=>/^\d+$/.test(e)&&Number(e)>0)?null:`Must be "all" or a comma-separated list of positive numeric ids.`}function uX(e,t,n={}){let r={};for(let i of XY(e)){if(ZY(i))continue;let e=null;i.control===`number`&&(e=cX(i,t[i.path],n)),i.valueKind===`posthog-projects`&&(e=lX(t[i.path])),i.control===`select`&&!i.options.some(e=>e.value===t[i.path])&&(e=`Choose one of the available options.`),e&&(r[i.id]=e)}return dX(XY(e),t,r),r}function dX(e,t,n){for(let r of e){let i=e.find(e=>e.id===r.maximumSettingId);if(!i||n[r.id]||n[i.id])continue;let a=Number(t[r.path]),o=Number(t[i.path]);a>o&&(n[r.id]=`Minimum must not exceed the maximum (${o}).`,n[i.id]=`Maximum must not be below the minimum (${a}).`)}}function fX(e,t){return XY(e).find(e=>e.id===t.maximumSettingId||e.maximumSettingId===t.id)}function pX(e){let t={browser:[],machine:[],lanes:[],projects:[]};for(let n of e)t[n.level]||(t[n.level]=[]),t[n.level].push(n);return t}function mX(e,t){let n=QY(t);if(n.length===0)return[];let r=[];for(let t of e){let e=QY(t.title);for(let i of t.settings||[]){let a=$Y(QY(i.title),n,1e3),o=$Y(QY((i.keywords||[]).join(` `)),n,100),s=$Y(e,n,10),c=$Y(QY(i.description),n,1),l=a+o+s+c;l!==0&&r.push({section:t,setting:i,score:l})}}return r.sort((e,t)=>t.score-e.score||e.section.title.localeCompare(t.section.title)||e.setting.title.localeCompare(t.setting.title)).slice(0,30)}function hX(e,t,n={},r={}){let i=/^#settings\/([^/]+)(?:\/([^/]+))?$/.exec(String(e||``));if(!i)return null;let a,o;try{a=decodeURIComponent(i[1]),o=i[2]?decodeURIComponent(i[2]):null}catch{return null}let s=(o?r[a]?.[o]:void 0)||n[a]||a,c=t.find(e=>e.id===s);if(!c)return null;let l=o?(c.settings||[]).find(e=>e.id===o):null;return o&&!l?null:{sectionId:s,settingId:l?.id||null,hash:`#settings/${s}${l?`/${l.id}`:``}`}}function gX(e){let t=`lanes-unattended`,n=e.find(e=>e.id===t);if(!n)return[...e];let r=e.filter(e=>e.id!==t),i=r.findLastIndex(e=>e.level===`lanes`);return r.splice(i+1,0,n),r}function _X(e,t,n){return{id:`project-${e}-${t}`,projectId:e,...n}}function vX(e){return String(e||``).replace(/\s+\(\d+\)$/,``)}function yX(e){return String(e||``).replace(/[\\/]+$/,``).split(/[\\/]/).at(-1)||``}function bX(e){return yX(e?.path)||vX(e?.name)||e?.id}function xX(e=[]){return e.filter(e=>typeof e?.id==`string`&&e.id).map(e=>({id:`project-${e.id}`,level:`projects`,title:bX(e),description:`Settings scoped to this configured project.`,caption:(e.recordNames?.length??0)>1?`Cards: ${e.recordNames?.join(`, `)}`:``,project:e,settings:[_X(e.id,`agent`,{path:`project:${e.id}:agent`,title:`Agent`,description:`Agent configured for this project.`,control:`readonly`,keywords:[`cli`,`runtime`],value:e.agent||`Not available in the current dashboard payload`}),_X(e.id,`permission-mode`,{path:`project:${e.id}:permission-mode`,title:`Default permission mode`,description:`Permission mode used for newly spawned sessions.`,control:`readonly`,keywords:[`approval`,`sandbox`],value:e.permissionMode||`Not available in the current dashboard payload`}),_X(e.id,`codex-hook-trust`,{path:`projects.${e.id}.codexBypassHookTrust`,title:`Codex hook trust bypass`,description:`Configured only on this project record.`,control:`readonly`,keywords:[`hooks`,`codex`],fileOnly:!0})]}))}function SX(e=[]){let t=new Set;return e.filter(e=>typeof e?.id!=`string`||!e.id?!1:!e.path||!t.has(e.path)&&(t.add(e.path),!0))}function CX(e=[],t=[]){let n=new Map(t.filter(e=>typeof e?.id==`string`&&e.id).map(e=>[e.id,e]));return e.map(e=>{let r=n.get(e?.id),i=e?.path||r?.path,a=t.filter(e=>i&&e?.path===i).map(e=>e?.name).filter(e=>typeof e==`string`&&e!==``);return{...r,...e,path:i,recordNames:[...new Set(a)]}})}function wX(e,t){return e.danger===!0&&!!e.warning&&t===!0}function TX(e,t){return e.find(e=>e.id===t)||e[0]||null}var EX=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:kc[e],meaning:t}),DX=Object.freeze([EX(I.DORMANT,`Not started yet.`),EX(I.INITIALIZING,`Setting up the worktree and launching the agent.`),EX(I.STARTING,`The agent is booting.`),EX(I.RUNNING,`The agent is mid-turn.`),EX(I.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),EX(I.WAITING,`Waiting on a permission prompt or your answer.`),EX(I.IDLE,`Ready for the next prompt.`),EX(I.COMPLETE,`Finished a turn you have not looked at yet.`),EX(I.DONE,`The agent process ended.`),EX(I.FAILED,`The agent failed to start or crashed.`)]);function OX(){let e=V(`section`,`status-legend`);e.appendChild(V(`h2`,`status-legend-title`,`Status colors`));let t=V(`dl`,`status-legend-rows`);for(let e of DX){let n=V(`div`,`status-legend-row`),r=V(`dt`,`status-legend-badge`),i=V(`span`,`status-legend-glyph`),a=V(`span`,`status-legend-name`);i.setAttribute(`aria-hidden`,`true`),r.append(i,a),sU(n,{glyph:i,label:a},e.state,e.awaitingBackgroundTasks),n.append(r,V(`dd`,`status-legend-meaning`,e.meaning)),t.appendChild(n)}return e.appendChild(t),e}var kX=2e4,Q=null,AX=null,jX=null,MX=null,NX=null,PX=null,FX=0,IX=null,LX=`all`,RX=!1,zX=null,BX=hj,VX=mj,HX=pj,UX=!1,WX=null,GX=`day`,KX=new Set,qX=RE({getAck:DF,setAck:OF,signature:()=>HA(Q,jX),isLooking:()=>!kd(MX)}),JX=null,YX=null,XX=null,ZX=null,QX=null,$X=null,eZ=null,tZ=null,nZ=SN(()=>MX),rZ=(e,t)=>Ed(`usage`,e,t);function iZ(e,t,n,r){let i=V(`div`,`usage-tile`);r&&r!==`ok`&&(i.dataset.tone=r);let a=V(`span`,`usage-tile-value`,t);i.append(a,V(`span`,`usage-tile-label`,e));let o=n?V(`span`,`usage-tile-sub`,n):null;return o&&i.append(o),{tile:i,valueEl:a,subEl:o}}function aZ(e){let t=Number(e);return Number.isFinite(t)?Math.min(Math.max(t,0),100):0}function oZ(e,t,n){let r=V(`div`,`usage-meter`);r.dataset.tone=String(t),r.setAttribute(`role`,`progressbar`),r.setAttribute(`aria-valuemin`,`0`),r.setAttribute(`aria-valuemax`,`100`),r.setAttribute(`aria-label`,n);let i=V(`span`,`usage-meter-fill`);return r.append(i),sZ(r,e),r}function sZ(e,t){if(!e)return;let n=aZ(t);e.setAttribute(`aria-valuenow`,String(Math.round(n)));let r=e.querySelector(`.usage-meter-fill`);r&&(r.style.width=`${n}%`)}function cZ(e,t,n,r){let i=V(`div`,`usage-table-scroll`);i.dataset.usageTable=r;let a=V(`table`,`usage-table`),o=V(`thead`),s=V(`tr`);for(let i of e){let e=V(`th`,i.numeric?`usage-num`:null);if(e.scope=`col`,!i.key){e.textContent=i.label,s.append(e);continue}let a=i.key;e.setAttribute(`aria-sort`,fj(t,a));let o=V(`button`,`usage-sort`,i.label);o.type=`button`,o.dataset.sortKey=a,o.addEventListener(`click`,()=>{WX={kind:`sort`,table:r,key:a},n(a)}),e.append(o),s.append(e)}o.append(s);let c=V(`tbody`);return a.append(o,c),i.append(a),{wrap:i,body:c}}function lZ(e,t){for(let n of t){let t=V(`td`,n.numeric?`usage-num`:n.className||null,n.node?null:n.text);n.node&&t.append(n.node),n.title&&(t.title=n.title),n.span&&(t.colSpan=n.span),e.append(t)}}function uZ(e){let t=V(`div`,`usage-share`);if(!Number.isFinite(e))return t.append(V(`span`,`usage-share-text`,ok(e))),t;let n=V(`span`,`usage-share-bar`),r=V(`span`,`usage-share-fill`);return r.style.width=`${aZ(e)}%`,n.append(r),t.append(n,V(`span`,`usage-share-text`,ok(e))),t}function dZ(){if(!JX?.isConnected)return;let e=Number(Q?.ts);JX.textContent=Number.isFinite(e)&&e>0?`Report ${bN(e)}`:``}function fZ(){if(!YX?.isConnected)return;let e=Number(AX?.ts);YX.textContent=Number.isFinite(e)&&e>0?`Sessions ${bN(e)}`:``}function pZ(){let e=bk(Q?.activeBlock);e&&(ZX?.isConnected&&(ZX.textContent=`${e.pct}%`),QX?.isConnected&&(QX.textContent=`${gk(e.remainingMinutes)} left`),$X?.isConnected&&sZ($X,e.pct))}function mZ(e){let t=XO.find(t=>t.value===e);return t?t.days:null}function hZ(){let e=V(`div`,`usage-controls`),t=V(`label`,`usage-control`);t.append(V(`span`,`usage-control-label`,`Range`));let n=V(`select`,`usage-select`);for(let e of XO){let t=V(`option`,null,e.label);t.value=e.value,n.append(t)}n.value=LX,n.addEventListener(`change`,()=>{LX=n.value,ZZ()}),t.append(n);let r=V(`button`,`usage-refresh`,`Refresh`);r.type=`button`,r.title=`Re-read every transcript from the start`,r.addEventListener(`click`,()=>ZZ({force:!0}));let i=V(`span`,`usage-refresh-status`,``);return eZ=r,tZ=i,qZ(),e.append(t,r,i),e}function gZ(){let e=rZ(`Usage`,dk(Q?.daily||[]));e.append(hZ()),JX=V(`p`,`usage-meta`,``),e.append(JX),dZ(),nZ.onTick(dZ);let t=ej(Q);t&&e.append(V(`p`,`usage-warning`,t));let n=XA(Q?.pricing?.missing);return n&&e.append(V(`p`,`usage-warning`,n)),e}function _Z(){if(!RA(jX))return null;let e=PA(Q?.totals),t=rZ(`Plan limits`,e?`${BA(`official`)}, ${e}`:BA(`official`)),n=qA(jX?.ts);if(n){let e=V(`p`,`usage-meta`,n);e.dataset.tone=`warn`,t.append(e)}let r=V(`div`,`usage-plan`);for(let e of IA){let t=LA(jX,e.key);t&&r.append(vZ(e,t))}return t.append(r),XX=V(`p`,`usage-meta`,``),t.append(XX),yZ(),nZ.onTick(yZ),t}function vZ(e,t){let n=V(`div`,`usage-plan-window`),r=V(`div`,`usage-plan-head`);r.append(V(`span`,`usage-plan-label`,e.label)),r.append(V(`span`,`usage-plan-used`,UA(t)));let i=V(`span`,`usage-plan-reset`,``);r.append(i),n.append(r),Number.isFinite(t.pct)&&n.append(oZ(t.pct,xk(t.pct),`${e.label} plan limit used`));let a=()=>{i.isConnected&&(i.textContent=WA(t.resetsAtMs))};return a(),nZ.onTick(a),n}function yZ(){if(!XX?.isConnected)return;let e=GA(jX?.ts);XX.textContent=e?`Plan ${e}`:``}function bZ(){let e=zk(Q,jX),t=xZ();if(e.length===0&&!t)return null;let n=rZ(`Glimmervoid overhead`,e.length>0?jk:null);if(e.length>0){let t=V(`div`,`usage-tiles`);for(let n of e){let e=[Bk(n),ik(n.costUSD)].filter(Boolean).join(`, `);t.append(iZ(`${n.label}, share of Claude use`,ok(n.sharePct),e).tile)}n.append(t);for(let t of e){let e=Vk(t);e&&n.append(V(`p`,`usage-meta`,`${t.label}: ${e}`))}}return t&&(n.append(V(`p`,`usage-meta`,`Selected range by lane. ${Ak}`)),n.append(t)),n}function xZ(){if(!Fk(Q))return null;let e=Nk(Q),t=e.reduce((e,t)=>e+(typeof t.costUSD==`number`&&Number.isFinite(t.costUSD)?t.costUSD:0),0),{wrap:n,body:r}=cZ([{label:`Lane`},{label:`Cost`,numeric:!0},{label:`Tokens`,numeric:!0},{label:`Sessions`,numeric:!0},{label:`Share`,numeric:!0}],null,()=>{},`lane`);for(let n of e){let e=V(`tr`,`usage-row`);n.lane===`other`&&(e.dataset.lane=`other`),lZ(e,[{text:Mk(n.lane),className:`usage-lane-cell`},{text:ik(n.costUSD),numeric:!0},{text:ak(n.tokens),numeric:!0},{text:Wk(n.sessions),numeric:!0},{node:uZ(lk(n.costUSD,t)),className:`usage-share-cell`}]),r.append(e)}return n}function SZ(){let e=Q?.activeBlock,t=Q?.blockHours,n=typeof t==`number`&&Number.isFinite(t)?t:5,r=PA(Q?.totals),i=rZ(`Current block`,r?`${n}h window, ${r}`:`${n}h window`);if(!e){i.append(V(`p`,`usage-empty`,`No active block.`));let e=CZ();return e&&i.append(e),i}let a=VA(Q,jX),o=V(`div`,`usage-tiles`);o.append(iZ(`block tokens`,ak(e.tokens??0),ik(e.costUSD??0),a).tile);for(let t of vk(e.burn))o.append(iZ(t.label,t.value,t.sub,a).tile);let s=bk(e);if(s){let e=iZ(`elapsed`,`${s.pct}%`,`${gk(s.remainingMinutes)} left`);ZX=e.valueEl,QX=e.subEl,o.append(e.tile)}i.append(o),s&&($X=oZ(s.pct,`ok`,`Elapsed share of the current block window`),i.append($X),nZ.onTick(pZ));let c=yk(e.projection);if(c){let e=V(`p`,`usage-projection`,c);e.dataset.tone=a,i.append(e)}let l=CZ();l&&i.append(l);let u=Tk(Q?.tokenLimit);if(!u)return i;let d=Ck(Q?.tokenLimit),f=VA(Q);i.append(oZ(d,f,`Share of the largest completed block seen, estimated`));let p=V(`p`,`usage-meta`,u);p.dataset.tone=f,i.append(p),i.append(V(`p`,`usage-provenance`,BA(`estimated`)));let m=Ek(e.projection,Q?.tokenLimit);if(m){let e=V(`p`,`usage-meta`,m);e.dataset.tone=f,i.append(e)}return i}function CZ(){let e=Q?.anomaly;if(!EA(e))return null;let t=V(`p`,`usage-meta`,wA(e));return t.dataset.tone=TA(e),t}function wZ(){let e=Sj(Q?.blocks);if(e.length===0)return null;let t=PA(Q?.totals),n=rZ(`Recent blocks`,t?`newest first, ${t}`:`newest first`),r=V(`div`,`usage-blocks`),i=e.reduce((e,t)=>Math.max(e,t.tokens),0);for(let t of e){let e=V(`div`,`usage-block`);t.isActive&&(e.dataset.active=`true`),e.append(V(`span`,`usage-block-label`,_k(t.startTs)));let n=V(`span`,`usage-block-bar`),a=V(`span`,`usage-block-fill`);a.style.width=`${aZ(lk(t.tokens,i)??0)}%`,n.append(a),e.append(n),e.append(V(`span`,`usage-block-value`,`${ak(t.tokens)} ${ik(t.costUSD)}`)),r.append(e)}return n.append(r),n}function TZ(){let e=Q?.totals||{},t=xj(Q?.daily,pk(Q)),n=rZ(`Totals`,[JO,Q?.tz?`TZ ${Q.tz}`:``].filter(Boolean).join(` `)),r=VA(Q,jX),i=V(`div`,`usage-tiles`);i.append(iZ(`today`,ak(t?.tokens??0),ik(t?.costUSD??0),r).tile),i.append(iZ(`range total`,ak(e.tokens??0),ik(e.costUSD??0)).tile);let a=Uk(Q);a&&i.append(iZ(a.label,a.value,a.sub).tile),n.append(i);let o=EZ(e);o&&n.append(o);let s=MA(e)?jA(e):[];if(s.length>0){let e=V(`div`,`usage-tiles usage-vendor-tiles`);for(let t of s)e.append(iZ(t.label,ak(t.tokens),ik(t.costUSD)).tile);n.append(e)}return YX=V(`p`,`usage-meta`,``),n.append(YX),fZ(),nZ.onTick(fZ),n}function EZ(e){let t=Ok(e);if(t.length===0)return null;let n=V(`div`,`usage-compo`),r=V(`div`,`usage-compo-bar`);r.setAttribute(`aria-hidden`,`true`);for(let e of t){if(e.pct<=0)continue;let t=V(`span`,`usage-compo-fill`);t.dataset.part=e.key,t.style.width=`${e.pct}%`,t.title=e.title,r.append(t)}let i=V(`div`,`usage-compo-legend`);for(let e of t){let t=V(`span`,`usage-compo-item`),n=V(`span`,`usage-compo-swatch`);n.dataset.part=e.key,t.append(n,V(`span`,`usage-compo-label`,e.label),V(`span`,`usage-compo-value`,e.value)),i.append(t)}return n.append(r,i),n}function DZ(){let e=Q?.savings;if(!qk(e))return null;let t=rZ(`Savings`,``),n=V(`div`,`usage-tiles`),r=Jk(e);r&&n.append(iZ(`rtk compression`,r.value,r.sub).tile);let i=Yk(e);return i&&n.append(iZ(`Prompt cache`,i.value,i.sub).tile),t.append(n),t}function OZ(){let e=Xk(Q);if(e.length===0)return null;let t=rZ(`Budgets`,`your own ceilings`),n=V(`div`,`usage-budgets`),r=mW(`machine-usage`,`usage-daily-budget`,`Budget settings`);n.appendChild(r);for(let t of e){let e=V(`div`,`usage-budget`),r=V(`div`,`usage-budget-head`);r.append(V(`span`,`usage-budget-label`,Zk(t.scope))),r.append(V(`span`,`usage-budget-value`,Qk(t))),r.append(V(`span`,`usage-budget-pct`,ok($k(t)))),e.append(r),e.append(oZ($k(t),t.tone,eA(t))),n.append(e)}return t.append(n),t}function kZ(){let e=Q?.daily||[],t=GX,n=bj(pA(e,t),BX),r=tA.find(e=>e.value===t)?.label||`Day`,i=rZ(`Over time`,[gA(e)].filter(Boolean).join(`, `));if(i.append(AZ()),n.length===0)return i.append(V(`p`,`usage-empty`,`No usage.`)),i;let a=MZ(e);a&&i.append(a);let{wrap:o,body:s}=cZ([{label:r,key:`day`},{label:`Tokens`,numeric:!0,key:`tokens`},{label:`Cost`,numeric:!0,key:`costUSD`},{label:`Models`}],BX,e=>{BX=dj(BX,e),BZ()},`day`);for(let e of n){let n=String(e.day??``),r=V(`tr`,`usage-row`);e.source===`history`&&(r.dataset.source=`history`);let i=yj(e.models),a=`${t}:${n}`,o=mre(a,i.length);lZ(r,[{node:jZ(e,t),title:n},{text:ak(e.tokens),numeric:!0},{text:ik(e.costUSD),numeric:!0},{node:o,className:`usage-toggle-cell`}]),s.append(r),i.length!==0&&KX.has(a)&&s.append(NZ(i))}return i.append(o),i}function AZ(){let e=V(`div`,`usage-period`);e.setAttribute(`role`,`group`),e.setAttribute(`aria-label`,`Period`);for(let t of tA){let n=V(`button`,`usage-period-button`,t.label);n.type=`button`,n.dataset.periodView=t.value,n.setAttribute(`aria-pressed`,t.value===GX?`true`:`false`),n.addEventListener(`click`,()=>{GX!==t.value&&(GX=t.value,WX={kind:`period`,view:t.value},BZ())}),e.append(n)}return e}function jZ(e,t){let n=V(`span`,`usage-period-cell`);return n.append(V(`span`,null,hA(e.day,t))),e.source===`history`&&n.append(V(`span`,`usage-history-tag`,`history`)),n}function MZ(e){let{cells:t,max:n}=bA(e,{today:pk(Q)});if(t.length===0||n<=0)return null;let r=V(`div`,`usage-heatmap-scroll`),i=V(`div`,`usage-heatmap`);i.setAttribute(`role`,`img`),i.setAttribute(`aria-label`,`Daily usage for the trailing ${Math.max(...t.map(e=>e.week))+1} weeks`);let a=V(`div`,`usage-heatmap-days`);for(let e of vA)a.append(V(`span`,`usage-heatmap-day`,e));for(let e of t){let t=V(`span`,`usage-heatmap-cell`);t.dataset.tone=String(e.tone),e.noData&&(t.dataset.noData=`true`),e.source===`history`&&(t.dataset.source=`history`),t.style.gridColumn=String(e.week+1),t.style.gridRow=String(e.weekday+1),t.title=xA(e),i.append(t)}return r.append(a,i),r}function mre(e,t){if(t===0)return null;let n=V(`button`,`usage-toggle`,`Models`);return n.type=`button`,n.dataset.usageDay=e,n.setAttribute(`aria-expanded`,KX.has(e)?`true`:`false`),n.addEventListener(`click`,()=>{if(WX={kind:`day`,day:e},KX.has(e)){KX.delete(e),BZ();return}KX.add(e),BZ()}),n}function NZ(e){let t=V(`tr`,`usage-row-breakdown`),n=V(`td`,`usage-models`);n.colSpan=4;for(let t of e){let e=V(`span`,`usage-model-chip`);e.append(V(`span`,`usage-model-name`,oj(t)),V(`span`,`usage-model-value`,`${ak(t.tokens)} ${ik(t.costUSD)}`)),n.append(e)}return t.append(n),t}function PZ(e,t){let n=V(`span`,`usage-model-name-wrap`),r=AA(e,t);return r&&n.append(V(`span`,`usage-vendor-tag`,r)),n.append(V(`span`,null,oj(e))),n}function FZ(){let e=yj(Q?.models,VX),t=Q?.totals||{},n=sk(t),r=rZ(`By model`,ck(n));if(e.length===0)return r.append(V(`p`,`usage-empty`,`No models.`)),r;let{wrap:i,body:a}=cZ([{label:`Model`,key:`model`},{label:`Tokens`,numeric:!0,key:`tokens`},{label:`Cost`,numeric:!0,key:`costUSD`},{label:`Share`,numeric:!0},{label:`Input`,numeric:!0,key:`input`},{label:`Output`,numeric:!0,key:`output`},{label:`Cache write`,numeric:!0,key:`cacheCreate`},{label:`Cache read`,numeric:!0,key:`cacheRead`}],VX,e=>{VX=dj(VX,e),BZ()},`model`);for(let r of e){let e=V(`tr`,`usage-row`);lZ(e,[{node:PZ(r,t),className:`usage-model-cell`,title:oj(r)},{text:ak(r.tokens),numeric:!0},{text:ik(r.costUSD),numeric:!0},{node:uZ(lk(r[n],t[n])),className:`usage-share-cell`},{text:ak(r.input),numeric:!0},{text:ak(r.output),numeric:!0},{text:ak(r.cacheCreate),numeric:!0},{text:ak(r.cacheRead),numeric:!0}]),a.append(e)}return r.append(i),r}function IZ(){let e=gj(Q?.sessions,HX),t=_j(e,UX),n=Q?.totals||{},r=sk(n),i=rZ(`By session`,ck(r));if(e.length===0)return i.append(V(`p`,`usage-empty`,`No sessions.`)),i;let{wrap:a,body:o}=cZ([{label:`Session`,key:`label`},{label:`Tokens`,numeric:!0,key:`tokens`},{label:`Cost`,numeric:!0,key:`costUSD`},{label:`Share`,numeric:!0},{label:`Last activity`,numeric:!0,key:`lastTs`}],HX,e=>{HX=dj(HX,e),BZ()},`session`);for(let e of t.rows){let t=V(`tr`,`usage-row`);ij(e)&&(t.dataset.managed=`true`);let i=aj(e),a=V(`span`,`usage-ago`,``);lZ(t,[{text:i,className:`usage-session-cell`,title:e.project?String(e.project):i},{text:ak(e.tokens),numeric:!0},{text:ik(e.costUSD),numeric:!0},{node:uZ(lk(e[r],n[r])),className:`usage-share-cell`},{node:a,numeric:!0}]),nZ.track(a,Number(e.lastTs),bN),o.append(t)}return i.append(a),e.length>10&&i.append(LZ(t.hiddenCount)),i}function LZ(e){let t=V(`div`,`usage-overflow`),n=vj(e);n&&t.append(V(`p`,`usage-meta`,n));let r=V(`button`,`usage-toggle`,`All sessions`);return r.type=`button`,r.dataset.usageSessionsToggle=`true`,r.setAttribute(`aria-expanded`,UX?`true`:`false`),r.addEventListener(`click`,()=>{WX={kind:`sessions-toggle`},UX=!UX,BZ()}),t.append(r),t}function RZ(){let e=rZ(`Not available`,``);return e.append(V(`p`,`usage-empty`,$A(Q))),e.append(V(`p`,`usage-empty`,YO)),e}function zZ(){JX=null,YX=null,XX=null,ZX=null,QX=null,$X=null,eZ=null,tZ=null}function BZ({force:e=!1}={}){if(!MX||!e&&kd(MX))return;let t=MX.parentElement,n=t?t.scrollTop:0;nZ.reset(),zZ(),MX.textContent=``,UZ(),t&&(t.scrollTop=n),VZ()}function VZ(){let e=WX;if(WX=null,!e)return;let t=HZ(e);if(!t||!MX)return;let n=MX.querySelector(t);n instanceof HTMLElement&&n.focus()}function HZ(e){return e.kind===`day`?`.usage-toggle[data-usage-day="${CSS.escape(e.day)}"]`:e.kind===`period`?`.usage-period-button[data-period-view="${CSS.escape(e.view)}"]`:e.kind===`sessions-toggle`?`.usage-toggle[data-usage-sessions-toggle="true"]`:e.kind===`sort`?`[data-usage-table="${CSS.escape(e.table)}"] .usage-sort[data-sort-key="${CSS.escape(e.key)}"]`:null}function UZ(){if(!MX)return;MX.append(gZ());let e=_Z();if(tj(Q)){e&&MX.append(e),MX.append(RZ());return}if(!Q){e&&MX.append(e),MX.append(V(`p`,`usage-empty`,`Waiting for scan.`));return}let t=[e,OZ()].filter(e=>e!==null);MX.append(WZ(`usage-band-now`,SZ(),t,{sideFirst:!0}));let n=[DZ()].filter(e=>e!==null);MX.append(WZ(`usage-band-spend`,TZ(),n));let r=[wZ()].filter(e=>e!==null);MX.append(WZ(`usage-band-trend`,kZ(),r));let i=bZ();i&&MX.append(i),MX.append(FZ(),IZ())}function WZ(e,t,n,{sideFirst:r=!1}={}){if(n.length===0)return t;let i=V(`div`,`usage-band ${e}`),a=V(`div`,`usage-band-col`);for(let e of n)a.append(e);return r?(i.append(a,t),i):(i.append(t,a),i)}function GZ(){NX&&NX(qX.refresh())}function KZ(){qX.acknowledge(),GZ()}function qZ(){eZ&&(eZ.disabled=RX),tZ&&(tZ.textContent=RX?`Refreshing`:``)}function JZ(e){RX=e,qZ(),zX&&=(clearTimeout(zX),null),e&&(zX=setTimeout(()=>{zX=null,RX=!1,qZ()},kX))}function YZ(e){NX=e,GZ()}function XZ(e){PX=e}function ZZ({force:e=!1}={}){if(!PX)return;FX+=1,IX=`usage-${FX}`;let t={type:`request-usage-report`,requestId:IX};e&&(t.force=!0);let n=mZ(LX);n!==null&&(t.days=n),JZ(!0),PX(t)}function QZ(e){if(MX)return MX;let t=V(`div`,`usage-content`);return e.appendChild(t),MX=t,nZ.ensure(),BZ({force:!0}),t}function $Z(){BZ({force:!0})}function eQ(e){if(AX=e,Q&&!tj(Q)&&YX?.isConnected){fZ();return}BZ()}function tQ(e){jX=e,BZ(),GZ()}function nQ(e){nj(e,IX)&&(JZ(!1),Q=e,BZ(),GZ())}function rQ(){let e=Q?.pricing||(AX?{source:AX.pricingSource}:null),t=YA(e?.fetchedAt),n=[JA(e,t!==null&&t>0?bN(t):``)],r=$A(Q);r&&n.push(r);let i=QA(Q?.scan);return i&&n.push(i),n}var iQ=Object.freeze({fetch:`Fetch`,stage:`Stage`,install:`Install dependencies`,"link-deps":`Link dependencies`,build:`Build`}),aQ=Object.freeze({"branch-count-unavailable":`The last check could not compare the checked-out branch with its upstream.`,"branch-diverged":`The checked-out branch has diverged from its upstream.`,"fetch-failed":`The last update check could not fetch the upstream branch.`,"main-channel-requires-clone":`The main channel requires a clone install.`,"no-branch":`The last update check found no checked-out branch.`,"no-upstream":`The checked-out branch has no upstream.`,"release-already-checked-out":`The checkout already contains the latest release. Restart to run it.`,"release-check-failed":`The last release check failed.`,"remote-tip-unavailable":`The last update check could not resolve the upstream branch tip.`,"update-check-failed":`The last update check failed.`}),oQ=Object.freeze([`unsupported-flavor`,`unsupported-platform`]),sQ=`Not connected to the server. Reconnecting.`,cQ=Object.freeze({requested:!1,failure:null});function lQ(e){return typeof e==`string`?e.trim():``}function uQ(e,t){return t===`request-sent`?{requested:!0,failure:null}:t===`request-unsent`?{requested:!1,failure:sQ}:t===`progress-frame`?cQ:t===`error-frame`?e.requested?cQ:e:e.failure===null?e:{requested:e.requested,failure:null}}function dQ(e,t){return t?.state?t.state:e?.journalSummary?.state}function fQ(e){return{enabled:!1,reason:e}}function pQ(){return{enabled:!0,reason:null}}function mQ({status:e,journal:t,request:n=cQ}){let r=dQ(e,t)===`running`||n.requested,i=r?fQ(`Wait for update staging to finish.`):pQ();if(n.failure)return{update:fQ(n.failure),restart:i};if(r)return{update:fQ(`Wait for the current update to finish.`),restart:i};if(!e)return{update:fQ(`Update status unavailable. Check for updates.`),restart:i};let a=e.applyRefusal;return a?{update:fQ(a.message),restart:i}:{update:pQ(),restart:i}}function hQ(e){let t=e?.applyRefusal;return t===void 0?`command`:t===null?`link`:oQ.includes(t.reason)?`command`:`link`}function gQ(e){let t=lQ(e);return t?`: ${t}`:``}function _Q(e){return e.state===`staged`?`Update staged. Restart to hand it off${gQ(e.reason)}.`:e.state===`succeeded`?`Update succeeded at restart${gQ(e.reason)}.`:e.state===`failed`?`Update failed${gQ(e.reason)}.`:e.state===`discarded`?`Update discarded${gQ(e.reason)}.`:e.state===`interrupted`?`Update interrupted${gQ(e.reason)}.`:null}function vQ(e){return iQ[e]??e}function yQ(e){let t=e.steps.find(t=>t.id===e.activeStep);if(t&&t.outputTail.length>0)return{stepId:t.id,lines:t.outputTail};let n=e.steps.findLast(e=>e.outputTail.length>0);return n?{stepId:n.id,lines:n.outputTail}:{stepId:null,lines:[]}}function bQ(e){if(!e||e.state===`idle`)return null;let t=yQ(e),n=t.stepId!==null&&t.stepId!==e.activeStep?t.stepId:null;return{state:e.state,terminalLine:_Q(e),steps:e.steps.map(e=>({id:e.id,label:vQ(e.id),status:e.status})),outputTail:t.lines,outputStepId:t.stepId,outputStepLabel:n===null?null:vQ(n)}}var xQ=6e5;function SQ(e){return e.channel!==`main`||!Number.isInteger(e.behindCount)?``:`${e.behindCount} ${e.behindCount===1?`commit`:`commits`} behind`}function CQ(e,t){let n=dQ(e,t),r=MD(t?.toVersion,t?.toSha)||MD(e?.latest,e?.latestSha)||`the update`;if(n===`running`)return{tone:`running`,headline:`Updating to ${r}. Glimmervoid keeps running until the restart.`};if(n===`staged`)return{tone:`staged`,headline:`${r} is staged. Restart to finish updating.`};if(!e)return{tone:`unknown`,headline:`No update check has run yet.`};let i=MD(e.current,e.currentSha)||`an unknown version`;if(e.updateAvailable){let t=MD(e.latest,e.latestSha)||`a newer build`,n=SQ(e);return{tone:`available`,headline:`Update available: ${i} to ${t}${n?` (${n})`:``}.`}}return lQ(e.reason)?{tone:`unknown`,headline:`Running ${i}. The last check did not finish.`}:{tone:`current`,headline:`Up to date. Running ${i}.`}}function wQ(e){if(!e)return`Update status unavailable.`;let t=MD(e.current,null)||`Unknown version`,n=jD(e.currentSha),r=lQ(e.installedBranch);return[t,[n?`commit ${n}`:``,r?`on ${r}`:``].filter(Boolean).join(` `),e.isTreeClean===!0?`clean checkout`:e.isTreeClean===!1?`uncommitted local changes`:``].filter(Boolean).join(`, `)}function TQ(e){return e?{label:MD(e.latest,e.latestSha)||`Latest target unknown`,behind:SQ(e),releaseUrl:lQ(e.releaseUrl)}:{label:`Update status unavailable.`,behind:``,releaseUrl:``}}function EQ({status:e,checkForUpdates:t,now:n,lastAutoCheckAt:r}){if(t===!1||r!==null&&n-r<xQ)return!1;let i=typeof e?.lastCheckAt==`number`?e.lastCheckAt:null;return i===null||n-i>=xQ}function DQ({status:e,checkForUpdates:t,relativeTime:n}){if(t===!1)return`Update checks are off.`;if(!e)return`No update check has run.`;let r=lQ(e.reason);return r?aQ[r]??`The last update check failed: ${r}.`:e.flavor===`unknown`?`The install flavor is unknown.`:n}var OQ=gP,kQ=Object.freeze({sounds:()=>vb(),themes:zb});function AQ(e){if(!e.optionsFrom)return e;let t=kQ[e.optionsFrom]?.()??[];return{...e,options:t.map(e=>({value:e.id,label:e.label}))}}function jQ(){return Object.freeze(FY.map(e=>({...e,settings:e.settings.map(AQ)})))}var MQ=jQ(),NQ=gX(MQ),PQ=Object.freeze({browser:`This browser`,machine:`Machine`,lanes:`Lanes`,projects:`Projects`}),FQ=!1,IQ=null,LQ=null,RQ=null,zQ=null,BQ=null,VQ=null,HQ=null,UQ=null,WQ=null,GQ=null,KQ=null,$=NQ[0],qQ={},JQ=[],YQ=[],XQ=new Map,ZQ=null,QQ=null,$Q=``,e$=``,t$=null,n$=null,r$=null,i$=null,a$=cQ,o$=()=>{},s$=e=>{e([])},c$=null,l$=!1,u$=new Set,d$=new Map;function f$(){return{themeId:ZP(),flyingAnimalsEnabled:$P(),...UF(),soundId:yb(UP()),notificationsEnabled:GP(),compactStatusLabels:qP(),sessionUsageChips:YP()}}function p$(e){let t={...e,prefs:f$()};ZQ=iX(NQ,t),QQ=iX(NQ,t)}function m$(e){return e.control===`readonly`?e.value:QQ?.[e.path]??e.defaultValue}function h$(e){return e.settings.some(e=>!e.path.startsWith(`pref:`)&&JSON.stringify(ZQ?.[e.path])!==JSON.stringify(QQ?.[e.path]))}function g$(e,t=null){return`#settings/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`}function _$(e,t=null){history.replaceState(history.state,``,g$(e,t))}function v$(e){requestAnimationFrame(()=>{let t=document.getElementById(e),n=t?.closest(`.settings-view-advanced-panel`);n&&(FQ=!0,n.hidden=!1,KQ?.querySelector(`.settings-view-advanced-toggle`)?.setAttribute(`aria-expanded`,`true`));let r=t?.closest(`.settings-view-setting`);r&&(r.scrollIntoView({block:`center`}),r.classList.remove(`settings-view-setting-flash`),requestAnimationFrame(()=>r.classList.add(`settings-view-setting-flash`)))})}function y$(){let e=xX(YQ);NQ=gX([...MQ,...e]),$=TX(NQ,$?.id)??$}function b$(e){let t=Array.isArray(e)?e:[];for(let e of t)typeof e?.id==`string`&&e.id&&XQ.set(e.id,{...XQ.get(e.id),...e});YQ=CX(SX(JQ),[...XQ.values()])}function x$(e){for(let t of Qte(Zy)){let n=V(`div`,`shortcut-group`);n.appendChild(V(`div`,`shortcut-group-title`,t.title));let r=V(`dl`,`shortcut-rows`);for(let e of t.items){let t=V(`dt`,`shortcut-keys`);e.combos.forEach((e,n)=>{n>0&&t.appendChild(V(`span`,`shortcut-sep`,`/`)),eb(t,e)}),r.append(t,V(`dd`,`shortcut-label`,e.label))}n.appendChild(r),e.appendChild(n)}}function S$(e){let t=V(`div`,`settings-about`),n=V(`span`,`settings-about-version`,`GLIMMERVOID `);n.appendChild(V(`span`,`settings-about-v`,`v0.30.0`));let r=V(`span`,`settings-about-links`),i=V(`a`,`settings-about-link`,`GitHub`);i.href=`https://github.com/${sY}`,i.target=`_blank`,i.rel=`noopener`;let a=V(`a`,`settings-about-link`,`Changelog`);a.href=`https://github.com/${sY}/blob/main/CHANGELOG.md`,a.target=`_blank`,a.rel=`noopener`,r.append(i,a),t.append(n,r),e.appendChild(t)}function C$(){for(let[e,t]of Object.entries(UF()))ZQ&&(ZQ[`pref:${e}`]=t),QQ&&(QQ[`pref:${e}`]=t)}var w$={"pref:flyingAnimalsMinGapSeconds":e=>FF(Number(e)),"pref:flyingAnimalsMaxGapSeconds":e=>IF(Number(e)),"pref:flyingAnimalsMinDurationSeconds":e=>LF(Number(e)),"pref:flyingAnimalsMaxDurationSeconds":e=>RF(Number(e)),"pref:flyingAnimalsScale":e=>zF(Number(e)),"pref:flyingAnimalsOnPhone":e=>BF(e===!0)};function T$(e,t){if(e.path===`pref:compactStatusLabels`){JP(t===!0),Ib(t===!0);return}if(e.path===`pref:sessionUsageChips`){XP(t===!0),Lb(t===!0);return}if(e.path===`pref:themeId`){QP(t),Fb(t);return}if(e.path===`pref:flyingAnimalsEnabled`){eF(t),aY(t);return}let n=w$[e.path];if(n){let r=uX([$],QQ??{},OQ);if(r[e.id])return;n(t);let i=fX([$],e),a=i&&w$[i.path];i&&a&&!r[i.id]&&a(QQ?.[i.path]),aY($P());return}if(e.path===`pref:soundId`){WP(t),kb(t);return}e.path===`pref:notificationsEnabled`&&(KP(t),t&&AJ().then(p1))}function E$(){if(!KQ||!QQ)return;KQ.querySelector(`.settings-view-footer`)?.remove();let e=n1(uX([$],QQ,OQ));e&&KQ.appendChild(e)}function D$(e,t,{rerender:n=!0}={}){if(QQ){if(QQ[e.path]=t,$Q=``,e.path.startsWith(`pref:`)&&ZQ&&(ZQ[e.path]=t,T$(e,t)),n){p1();return}E$()}}function O$(e,t){if(!t.exclusiveMin)return t.min;if(e.integer!==!1)return t.min+1}function k$(e){let t=V(`div`,`settings-view-toggle-wrap`),n=V(`label`,`settings-view-toggle`),r=V(`input`,`settings-view-checkbox`);return r.type=`checkbox`,r.checked=m$(e)===!0,e.id===`desktop-notifications`&&!OJ()&&(r.checked=!1,r.disabled=!0),r.setAttribute(`aria-labelledby`,e.id),r.addEventListener(`change`,()=>D$(e,r.checked)),n.append(r,V(`span`,`settings-view-toggle-state`,r.checked?`On`:`Off`)),t.appendChild(n),t}function A$(e){let t=V(`input`,`settings-view-input`);return t.type=e.control??`text`,t.value=String(m$(e)??``),e.control===`password`&&(t.placeholder=`No credential stored`),t.autocomplete=`off`,t.spellcheck=!1,t.setAttribute(`aria-labelledby`,e.id),t.addEventListener(`input`,()=>D$(e,t.value,{rerender:!1})),t}function j$(e){let t=V(`input`,`settings-view-input`),n=OQ[e.range??``];t.type=`number`,t.value=String(m$(e)??``),t.step=String(e.step??1);let r=O$(e,n);return r!=null&&(t.min=String(r)),n.max!=null&&(t.max=String(n.max)),t.autocomplete=`off`,t.setAttribute(`aria-labelledby`,e.id),e.commitOnChange?(t.addEventListener(`change`,()=>D$(e,t.value.trim()===``?e.defaultValue:t.value)),t):(t.addEventListener(`input`,()=>D$(e,t.value,{rerender:!1})),t)}function M$(e){let t=V(`select`,`settings-view-input`);t.setAttribute(`aria-labelledby`,e.id);for(let n of e.options){let e=V(`option`,null,n.label);e.value=n.value,t.appendChild(e)}return t.value=String(m$(e)),t.addEventListener(`change`,()=>D$(e,t.value)),t}function N$(e){let t=V(`div`,`settings-view-list`),n=m$(e),r=Array.isArray(n)?n:[];r.length===0&&t.appendChild(V(`div`,`settings-empty`,`No repository roots configured.`));for(let[n,i]of r.entries()){let a=V(`div`,`settings-root-item`),o=V(`span`,`settings-root-path`,i);o.title=i;let s=V(`button`,`btn-settings-remove`,`×`);s.type=`button`,s.title=`Remove`,s.setAttribute(`aria-label`,`Remove ${i}`),s.addEventListener(`click`,()=>{D$(e,r.filter((e,t)=>t!==n))}),a.append(o,s),t.appendChild(a)}let i=V(`div`,`settings-add-row`),a=V(`input`,`settings-view-input settings-root-input`);a.type=`text`,a.autocomplete=`off`,a.spellcheck=!1,a.placeholder=`Repository root path`;let o=V(`button`,`btn-dialog btn-dialog-confirm btn-settings-add`,`Add`);o.type=`button`;let s=()=>{let t=a.value.trim();t&&(r.some(e=>e.toLowerCase()===t.toLowerCase())||D$(e,[...r,t]))};return o.addEventListener(`click`,s),a.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),s())}),i.append(a,o),t.appendChild(i),t}function P$(e){let t=V(`div`,`settings-view-projects`),n=m$(e),r=new Set(Array.isArray(n)?n:[]),i=Array.isArray(qQ.projectChoices)?qQ.projectChoices:[];i.length===0&&t.appendChild(V(`div`,`settings-empty`,`No configured projects are available.`));for(let n of i){let i=V(`label`,`settings-view-project-choice`),a=V(`input`,`settings-view-checkbox`);a.type=`checkbox`,a.checked=r.has(n.id),a.addEventListener(`change`,()=>{let t=new Set(r);a.checked&&t.add(n.id),a.checked||t.delete(n.id),D$(e,[...t])}),i.append(a,document.createTextNode(n.name)),t.appendChild(i)}return t}function F$(e){let t=V(`div`,`settings-view-file-only`);return t.append(V(`code`,`settings-view-key-path`,e.path)),t.append(V(`span`,`settings-view-file-caption`,`Configured in config.json`)),t}function I$(){let e=CQ(r$,i$),t=V(`div`,`settings-readonly settings-update-readout settings-update-summary`,e.headline);return t.dataset.tone=e.tone,t}function L$(){return V(`div`,`settings-readonly settings-update-readout`,wQ(r$))}function R$(){let e=TQ(r$),t=V(`div`,`settings-readonly settings-update-readout`);if(t.appendChild(V(`span`,`settings-update-latest-label`,e.label)),e.behind&&t.appendChild(V(`span`,`settings-update-behind`,e.behind)),!e.releaseUrl)return t;let n=V(`a`,`settings-link`,`View release`);return n.href=e.releaseUrl,n.target=`_blank`,n.rel=`noopener noreferrer`,t.appendChild(n),t}function z$(){let e=typeof r$?.lastCheckAt==`number`?r$.lastCheckAt:null,t=V(`div`,`settings-readonly settings-update-readout`,DQ({status:r$,checkForUpdates:qQ.checkForUpdates,relativeTime:bN(e)}));return e&&(t.title=new Date(e).toLocaleString()),t}function B$(e,t,{decision:n={enabled:!0,reason:null},isPrimary:r=!1}={}){let i=V(`button`,`btn-dialog ${r?`btn-dialog-confirm`:`btn-dialog-cancel`} settings-update-button`,e);return i.type=`button`,i.disabled=!n.enabled,i.addEventListener(`click`,t),i}function V$(e){let t=V(`span`,`settings-update-action-status`,e??``);return t.setAttribute(`role`,`status`),t}function H$(e){let t=uQ(a$,e);t!==a$&&(a$=t,F1())}function U$({restartWhenStaged:e,confirmedSessionIds:t}){H$(B({type:`update-apply`,restartWhenStaged:e,confirmedSessionIds:t})?`request-sent`:`request-unsent`)}function W$(){c$=Date.now(),B({type:`update-check`})}function G$(){if(!r$){l$=!0;return}l$=!1,EQ({status:r$,checkForUpdates:qQ.checkForUpdates,now:Date.now(),lastAutoCheckAt:c$})&&W$()}function K$(){let e=mQ({status:r$,journal:i$,request:a$}),t=V(`div`,`settings-update-actions settings-update-readout`),n=V(`div`,`settings-update-buttons`);return n.append(B$(`Update and restart`,()=>s$(e=>U$({restartWhenStaged:!0,confirmedSessionIds:e})),{decision:e.update,isPrimary:!0}),B$(`Update without restart`,()=>U$({restartWhenStaged:!1}),{decision:e.update}),B$(`Check for updates`,W$),B$(`Restart`,o$,{decision:e.restart})),t.append(n,V$(e.update.reason)),t}function q$(e){return e.status===`update-summary`?I$():e.status===`update-installed`?L$():e.status===`update-latest`?R$():e.status===`update-last-checked`?z$():e.status===`update-actions`?K$():V(`div`,`settings-readonly`,String(e.value||`Not configured`))}function J$(e){return e.fileOnly?F$(e):e.control===`readonly`?q$(e):e.control===`toggle`?k$(e):e.control===`number`?j$(e):e.control===`select`?M$(e):e.control===`list`?N$(e):e.control===`projects`?P$(e):A$(e)}function Y$(e){if(e.id===`desktop-notifications`&&!OJ())return`Desktop notifications are unavailable for this page.`;if(e.id===`desktop-notifications`&&m$(e)&&kJ()===`denied`)return`Blocked by the browser. Allow notifications for this site to enable them.`;if(e.status!==`rtk-install`||!m$(e)||qQ.rtkAvailable)return``;let t=qQ.rtkInstall||{status:`idle`};return t.status===`installing`?`No rtk binary found. Glimmervoid is installing it into ~/.glimmervoid/bin now.`:t.status===`failed`?`No rtk binary found. The last install attempt failed: ${t.reason||`unknown reason`}. Glimmervoid retries on the next save.`:`No rtk binary found. Glimmervoid will install it into ~/.glimmervoid/bin when you save.`}function X$(e){if(e.status===`custom-agents`)return a1();if(e.status===`workflows`)return l1();if(e.status===`usage-last-report`)return u1();if(e.status===`update-actions`)return Z$();if(e.status?.startsWith(`update-`))return null;let t=Y$(e);return t?V(`div`,`settings-view-warning settings-view-status-slot`,t):null}function Z$(){let e=bQ(i$);if(!e)return null;let t=V(`div`,`settings-update-progress settings-view-status-block settings-view-status-slot`);t.dataset.state=e.state,t.setAttribute(`role`,`status`),e.terminalLine&&t.appendChild(V(`div`,`settings-update-terminal`,e.terminalLine));let n=V(`ol`,`settings-update-steps`);for(let t of e.steps){let e=V(`li`,`settings-update-step`);e.dataset.status=t.status,e.append(V(`span`,`settings-update-step-state`,t.status),V(`span`,`settings-update-step-label`,t.label)),n.appendChild(e)}if(t.appendChild(n),e.outputTail.length===0)return t;let r=V(`pre`,`settings-update-output`,e.outputTail.join(`
|
|
242
|
-
`));if(e.outputStepId&&(r.dataset.step=e.outputStepId),!e.outputStepLabel)return t.appendChild(r),t;let i=`Output from ${e.outputStepLabel}`;return r.setAttribute(`aria-label`,i),t.append(V(`div`,`settings-update-output-label`,i),r),t}function Q$(e){let t=V(`div`,`settings-view-setting-heading`),n=V(`h2`,`settings-view-setting-title`,e.title);n.id=e.id,n.addEventListener(`click`,()=>_$($.id,e.id));let r=V(`button`,`settings-view-copy-link`,`#`);r.type=`button`,r.setAttribute(`aria-label`,`Copy link`);let i=V(`span`,`settings-view-copy-status`);return i.setAttribute(`role`,`status`),r.addEventListener(`click`,async()=>{let t=new URL(g$($.id,e.id),location.href).href;try{await navigator.clipboard.writeText(t),i.textContent=`Link copied`}catch{i.textContent=`Copy failed`}setTimeout(()=>{i.textContent=``},1600)}),t.append(n,r,i),t}function $$(e,t){let n=V(`article`,`settings-view-setting`);n.append(Q$(e),V(`p`,`settings-view-setting-description`,e.description)),n.appendChild(J$(e)),e.id===`compact-status`&&n.appendChild(PJ()),wX(e,m$(e))&&n.appendChild(V(`div`,`settings-view-warning settings-warning`,e.warning));let r=X$(e);return r&&n.appendChild(r),t[e.id]&&n.appendChild(V(`div`,`settings-view-field-error`,t[e.id])),n}function e1(){if(QQ&&ZQ){for(let e of $.settings)QQ[e.path]=structuredClone(ZQ[e.path]);$Q=``,p1()}}async function t1(){let e=$,t=[e],n=uX(t,QQ??{},OQ);if(Object.keys(n).length>0){$Q=`Fix the highlighted settings before saving.`,p1();return}let r=zY(oX(t,ZQ??{},QQ??{}));if(Object.keys(r).length!==0)try{let t=await dd(`update-settings`,{settings:r});if(t.type===`settings-error`){if($!==e)return;$Q=String(t.message),p1();return}t.settings&&j1(t.settings,{rehydrateSectionIds:[e.id]})}catch(t){if($!==e)return;$Q=t?.message||`Failed to save settings.`,p1()}}function n1(e){let t=h$($);if($.level===`browser`||!t&&!$Q)return null;let n=V(`footer`,`settings-view-footer`),r=V(`div`,`settings-view-footer-error`,$Q);if(r.setAttribute(`role`,`status`),n.appendChild(r),!t)return n;let i=V(`div`,`settings-view-footer-actions`),a=V(`button`,`btn-dialog btn-dialog-cancel`,`Revert`);a.type=`button`,a.addEventListener(`click`,e1);let o=V(`button`,`btn-dialog btn-dialog-confirm`,`Save`);return o.type=`button`,o.disabled=Object.keys(e).length>0,o.addEventListener(`click`,t1),i.append(a,o),n.appendChild(i),n}function r1(e){return e===null?`not probed yet`:e?`resolved`:`not found on PATH`}function i1(){let e=Array.isArray(qQ.customAgents)?qQ.customAgents:[];return e.length===0?[`None declared. Add customAgents to config.json.`]:e.map(e=>{let t=e.args.length>0?`${e.command} ${e.args.join(` `)}`:e.command;return`${e.id} ${e.label} ${t} ${r1(e.resolvable)}`})}function a1(){let e=V(`div`,`settings-view-status-block settings-view-status-slot`);e.appendChild(V(`div`,`settings-section-title`,`Declared agents`));for(let t of i1())e.appendChild(V(`div`,`settings-readonly`,t));return e}async function o1(e,t){u$.add(e.id),d$.delete(e.id),P1();try{let n=await dd(`update-settings`,{settings:{workflows:{rules:[{id:e.id,enabled:t}]}}});if(n.type===`settings-error`&&d$.set(e.id,String(n.message)),u$.delete(e.id),n.type!==`settings-error`&&n.settings){j1(n.settings);return}}catch(t){d$.set(e.id,t?.message||`Failed to save the rule.`)}u$.delete(e.id),P1()}function s1(e){return u$.has(e.id)?`Saving`:d$.get(e.id)??``}function c1(e){let t=V(`div`,`settings-view-toggle-wrap`),n=V(`label`,`settings-view-toggle`),r=V(`input`,`settings-view-checkbox`);r.type=`checkbox`,r.checked=e.isEnabled,r.disabled=u$.has(e.id),r.setAttribute(`aria-label`,`Run rule ${e.name}`),r.addEventListener(`change`,()=>{o1(e,r.checked)}),n.append(r,V(`span`,`settings-view-toggle-state`,e.isEnabled?`On`:`Off`),V(`span`,`settings-readonly`,`${e.name} ${e.summary}`));let i=V(`span`,`settings-view-copy-status`,s1(e));return i.setAttribute(`role`,`status`),t.append(n,i),t}function l1(){let e=V(`div`,`settings-view-status-block settings-view-status-slot`);e.appendChild(V(`div`,`settings-section-title`,`Rules`));let t=RY(qQ.workflows);if(t.length>0){for(let n of t)e.appendChild(c1(n));return e}for(let t of LY(qQ.workflows))e.appendChild(V(`div`,`settings-readonly`,t));return e}function u1(){let e=V(`div`,`settings-view-status-block settings-view-status-slot`);e.appendChild(V(`div`,`settings-section-title`,`Last report`));let t=rQ();for(let n of t)e.appendChild(V(`div`,`settings-readonly`,n));return e}function d1(){let e=V(`button`,`btn-dialog btn-dialog-cancel`,`Reset to defaults`);return e.type=`button`,e.addEventListener(`click`,()=>{WF(),C$(),aY($P()),p1()}),e}function f1(e,t){let n=V(`div`,`settings-view-advanced`),r=V(`button`,`dialog-advanced-toggle settings-view-advanced-toggle`,`Advanced`);r.type=`button`,r.setAttribute(`aria-expanded`,String(FQ)),r.setAttribute(`aria-controls`,`settings-view-advanced-panel`);let i=V(`div`,`dialog-advanced-panel settings-view-advanced-panel`);i.id=`settings-view-advanced-panel`,i.hidden=!FQ,r.addEventListener(`click`,()=>{FQ=!FQ,i.hidden=!FQ,r.setAttribute(`aria-expanded`,String(FQ))});for(let n of e)i.append($$(n,t));return $.id===`browser-flying-animals`&&i.append(d1()),n.append(r,i),n}function p1(){if(!KQ||!QQ)return;KQ.textContent=``;let e=V(`header`,`settings-view-section-header`),t=V(`div`,`settings-view-title-row`),n=V(`h1`,`settings-view-section-title`,$.title);if(n.tabIndex=-1,n.addEventListener(`click`,()=>_$($.id)),t.append(n),t.append(V(`span`,`settings-view-level`,PQ[$.level]||$.level)),e.append(t,V(`p`,`settings-view-section-description`,$.description)),$.caption&&e.appendChild(V(`p`,`settings-view-section-caption`,$.caption)),KQ.appendChild(e),$.id===`browser-shortcuts`){let e=V(`div`,`shortcut-groups settings-view-shortcuts`);x$(e),KQ.appendChild(e),KQ.appendChild(OX()),S$(KQ);return}let r=uX([$],QQ,OQ),i=V(`div`,`settings-view-stack`);for(let e of $.settings.filter(e=>!e.advanced))i.appendChild($$(e,r));$.id===`browser-flying-animals`&&i.append(oY());let a=$.settings.filter(e=>e.advanced);a.length>0&&i.append(f1(a,r));for(let e of $.unattendedLinks||[]){let t=V(`div`,`settings-view-unattended-link`);t.append(document.createTextNode(`${e.title}: `));let n=V(`a`,null,`Enabled in Unattended actions`);n.href=g$(`lanes-unattended`,e.settingId),t.appendChild(n),i.appendChild(t)}KQ.appendChild(i);let o=n1(r);o&&KQ.appendChild(o)}function m1(e,{focusContent:t=!1,settingId:n=null,updateHash:r=!0}={}){$.id!==e&&(FQ=!1),$=TX(NQ,e)??$,$Q=``,h1(zQ),h1(WQ),HQ&&(HQ.textContent=$.title,VQ&&(VQ.title=$.title)),UQ&&(UQ.textContent=PQ[$.level]||$.level),p1(),E1($)&&T1(),$.id===`machine-updates`&&G$(),r&&_$($.id,n),n&&v$(n),t&&KQ?.querySelector(`h1`)?.focus()}function h1(e){for(let t of e?.querySelectorAll(`[data-settings-section]`)||[]){let e=t.dataset.settingsSection===$.id;t.setAttribute(`aria-current`,e?`page`:`false`)}}function g1(e){x1(!1),BQ&&(BQ.value=``,e$=``,S1(),m1(e.section.id,{settingId:e.setting.id}))}function _1(e,t){if(t.length===0){e.appendChild(V(`div`,`settings-empty settings-view-search-empty`,`No settings found.`));return}let n=new Map;for(let e of t)n.has(e.section.id)||n.set(e.section.id,[]),n.get(e.section.id)?.push(e);for(let t of n.values()){let n=t[0].section,r=V(`div`,`settings-view-nav-group`);r.appendChild(V(`div`,`settings-view-nav-label`,`${n.title} (${PQ[n.level]})`));for(let e of t){let t=V(`button`,`settings-view-nav-item settings-view-search-result`,e.setting.title);t.type=`button`,t.addEventListener(`click`,()=>g1(e)),r.appendChild(t)}e.appendChild(r)}}function v1(e,t,{groupClassName:n,headingClassName:r,createButton:i}){for(let a of[`browser`,`machine`,`lanes`,`projects`]){if(t[a].length===0)continue;let o=V(`div`,n);o.appendChild(V(`div`,r,PQ[a]));for(let e of t[a])o.appendChild(i(e));e.appendChild(o)}}function y1(e){WQ&&(WQ.textContent=``,v1(WQ,e,{groupClassName:`settings-view-section-picker-group`,headingClassName:`settings-view-section-picker-heading`,createButton(e){let t=V(`button`,`settings-view-section-option`,e.title);return t.type=`button`,t.dataset.settingsSection=e.id,t.addEventListener(`click`,()=>{x1(!1),m1(e.id)}),t}}),h1(WQ))}function b1(){return!!WQ&&!WQ.hidden}function x1(e,{returnFocus:t=!0}={}){if(!WQ||!VQ)return;let n=b1();if(WQ.hidden=!e,VQ.setAttribute(`aria-expanded`,String(e)),e){y1(pX(NQ)),requestAnimationFrame(()=>{let e=WQ?.querySelector(`[aria-current="page"]`);e instanceof HTMLElement&&e.focus()});return}t&&n&&VQ.focus()}function S1(){if(!zQ||!GQ||!RQ)return;let e=pX(NQ);if(zQ.textContent=``,GQ.textContent=``,RQ.dataset.searching=String(!!e$),GQ.hidden=!e$,e$){let e=mX(NQ,e$);_1(zQ,e),_1(GQ,e);return}v1(zQ,e,{groupClassName:`settings-view-nav-group`,headingClassName:`settings-view-nav-label`,createButton(e){let t=V(`button`,`settings-view-nav-item`,e.title);return t.type=`button`,t.dataset.settingsSection=e.id,t.addEventListener(`click`,()=>m1(e.id)),t}}),y1(e),m1($.id,{updateHash:!1})}function C1(e){if(e$&&e.key===`Enter`){let t=mX(NQ,e$)[0];if(!t)return;e.preventDefault(),g1(t);return}if(e.key===`Escape`&&e$){if(!BQ)return;e.preventDefault(),BQ.value=``,e$=``,S1(),BQ.focus();return}if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`||!zQ)return;let t=[...zQ.querySelectorAll(`[data-settings-section]`)].filter(e=>e instanceof HTMLElement),n=document.activeElement;if(!(n instanceof HTMLElement))return;let r=t.indexOf(n);r<0||(e.preventDefault(),t[(r+(e.key===`ArrowDown`?1:-1)+t.length)%t.length].focus())}function w1(e,{onRestart:t=()=>{},onConfirmUpdateAndRestart:n=e=>{e([])}}={}){o$=t,s$=n,IQ=e,IQ.textContent=``,RQ=V(`div`,`settings-view-shell`);let r=V(`div`,`settings-view-sidebar`);BQ=V(`input`,`settings-view-search`),BQ.type=`search`,BQ.placeholder=`Search settings`,BQ.setAttribute(`aria-label`,`Search settings`),zQ=V(`nav`,`settings-view-nav`),zQ.setAttribute(`role`,`navigation`),zQ.setAttribute(`aria-label`,`Settings sections`),VQ=V(`button`,`settings-view-section-button`),VQ.type=`button`,VQ.setAttribute(`aria-expanded`,`false`),VQ.setAttribute(`aria-controls`,`settings-section-picker`),HQ=V(`span`,`settings-view-section-button-title`),UQ=V(`span`,`settings-view-section-button-level`);let i=V(`span`,`settings-view-section-button-chevron`,`⌄`);i.setAttribute(`aria-hidden`,`true`),VQ.append(HQ,UQ,i),WQ=V(`div`,`settings-view-section-picker`),WQ.id=`settings-section-picker`,WQ.hidden=!0,WQ.setAttribute(`role`,`dialog`),WQ.setAttribute(`aria-label`,`Settings sections`),GQ=V(`nav`,`settings-view-phone-results`),GQ.hidden=!0,GQ.setAttribute(`aria-label`,`Settings search results`),KQ=V(`div`,`settings-view-content`),KQ.setAttribute(`aria-live`,`polite`),BQ.addEventListener(`input`,()=>{let e=BQ;e&&(e$=e.value.trim(),S1())}),BQ.addEventListener(`keydown`,C1),zQ.addEventListener(`keydown`,C1),GQ.addEventListener(`keydown`,C1),VQ.addEventListener(`click`,()=>x1(!b1())),t$&&document.removeEventListener(`click`,t$),n$&&document.removeEventListener(`keydown`,n$),t$=e=>{b1()&&e.target instanceof Node&&(WQ?.contains(e.target)||VQ?.contains(e.target)||x1(!1))},n$=e=>{e.key===`Escape`&&b1()&&(e.preventDefault(),x1(!1))},document.addEventListener(`click`,t$),document.addEventListener(`keydown`,n$),r.append(BQ,VQ,zQ,WQ),RQ.append(r,GQ,KQ),IQ.appendChild(RQ),p$(qQ),S1(),T1(),LQ?.disconnect(),LQ=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&T1()}),LQ.observe(IQ)}function T1(){bb().then(D1)}function E1(e){return e.settings.some(e=>e.path===`pref:soundId`)}function D1(){MQ=jQ(),y$();let e=yb(UP());ZQ&&(ZQ[`pref:soundId`]=e),QQ&&(QQ[`pref:soundId`]=e),E1($)&&p1()}function O1({returnFocus:e=!0}={}){x1(!1,{returnFocus:e})}function k1(e=null,t=null){m1(e||$.id,{settingId:t})}function A1(e){return hX(e,NQ,NY,PY)}function j1(e,t={}){let{rehydrateSectionIds:n=[]}=t;if(!e)return;qQ=e,JQ=Array.isArray(qQ.projectChoices)?qQ.projectChoices:[],b$(qQ.projectChoices),y$();let r={...qQ,prefs:f$()},i=aX(NQ,r,ZQ,QQ,{rehydrateSectionIds:n});ZQ=i.original,QQ=i.edited,$Q=``,zQ&&S1(),p1()}function M1(e){return document.getElementById(e.id)?.closest(`.settings-view-setting`)??null}function N1(e,t){let n=t.querySelector(`.settings-view-status-slot`),r=X$(e);n&&r&&n.replaceWith(r),n&&!r&&n.remove(),!n&&r&&t.appendChild(r)}function P1(){for(let e of $.settings||[]){if(!e.status)continue;let t=M1(e);t&&N1(e,t)}}function F1(){if($.id===`machine-updates`)for(let e of $.settings||[]){if(!e.status?.startsWith(`update-`))continue;let t=M1(e);t&&(t.querySelector(`.settings-update-readout`)?.replaceWith(J$(e)),N1(e,t))}}function I1(e){r$=e,a$=uQ(a$,`status-frame`),F1(),l$&&$.id===`machine-updates`&&G$()}function L1(e){i$=e,a$=uQ(a$,`progress-frame`),F1()}function R1(){H$(`error-frame`)}function z1(e){b$(e),y$(),zQ&&S1()}function B1(){$.id===`browser-flying-animals`&&p1()}window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,B1),Yd(B1);function V1(){let e=new Map,t=new Set;function n(n){let r=new Set(n.map(e=>e.id));for(let{id:r,state:i}of n){let n=e.get(r);if(e.set(r,i),i!==I.COMPLETE){t.delete(r);continue}n&&n!==I.COMPLETE&&t.add(r)}for(let n of e.keys())r.has(n)||(e.delete(n),t.delete(n))}function r(e){t.delete(e)}function i(e){return t.has(e)}return{noteStates:n,acknowledge:r,isUnseen:i}}var H1=Object.freeze({WAITING:0,FAILED:1,COMPLETE:2,RUNNING:3}),U1=4;function W1(e){let t=typeof e==`string`?H1[e]:void 0;return t===void 0?U1:t}function G1(e){return[...e||[]].map((e,t)=>({row:e,index:t})).sort((e,t)=>W1(e.row?.state)-W1(t.row?.state)||e.index-t.index).map(e=>e.row)}var K1=new Set;function q1(e,t,n){let r=iU(e,t,n),i=r.groups.map(e=>({...e,rows:G1(e.rows)})),a={...r,groups:i};return{...a,visibleIds:aU(a,K1)}}var J1=e=>e.ui.path;function Y1({onSelectSession:e}){let t=V(`div`,`phone-board`),n=V(`header`,`phone-topbar`),r=V(`div`,`phone-attention`);r.setAttribute(`role`,`status`),r.setAttribute(`aria-live`,`polite`);let i=V(`div`,`phone-calm calm-view`);i.hidden=!0;let a=V(`div`,`phone-board-list`),o=V(`div`,`phone-empty`);o.innerHTML=`<p class="phone-empty-title"></p><p class="phone-empty-desc"></p>`;let s=H(o,`.phone-empty-title`,`p`),c=H(o,`.phone-empty-desc`,`p`);t.append(n,r,i,a,o);let l=new Map,u=new Map,d=new WeakMap,f=new WeakMap,p=new WeakMap,m=0;Td(n);function h(t){let n=V(`button`,`phone-row`);n.type=`button`,n.dataset.id=t,n.innerHTML=`<span class="phone-row-glyph" aria-hidden="true"></span><span class="phone-row-main"><span class="phone-row-name"></span><span class="phone-row-meta"><span class="phone-row-badge"></span><span class="phone-row-merge"></span></span></span><span class="phone-row-elapsed" aria-hidden="true"></span>`;let r={glyph:H(n,`.phone-row-glyph`,`span`),name:H(n,`.phone-row-name`,`span`),badge:H(n,`.phone-row-badge`,`span`),merge:H(n,`.phone-row-merge`,`span`),elapsed:H(n,`.phone-row-elapsed`,`span`)};n.addEventListener(`click`,()=>e?.(t));let i=V(`div`,`phone-row-item`);i.setAttribute(`role`,`listitem`);let a=V(`button`,`phone-row-remove`,`x`);return a.type=`button`,a.title=`Remove session`,a.setAttribute(`aria-label`,`Remove session`),a.addEventListener(`click`,e=>{e.stopPropagation(),ZF(t)}),i.append(n,a),d.set(n,{refs:r,item:i}),n}function g(e){let t=V(`section`,`phone-board-group`);t.dataset.key=e;let n=V(`div`,`phone-board-group-header`),r=V(`span`,`phone-board-group-label`),i=V(`span`,`phone-board-group-count`),a=V(`button`,`phone-board-group-add`,`+`);a.type=`button`,a.addEventListener(`click`,()=>XF(t.dataset.path,t.dataset.label));let o=V(`button`,`phone-board-group-forget`,`x`);o.type=`button`,o.addEventListener(`click`,()=>{YF(t.dataset.path),te()});let s=V(`div`,`phone-board-group-rows`);return s.setAttribute(`role`,`list`),n.append(r,i,o,a),t.append(n,s),f.set(t,{header:n,label:r,count:i,addButton:a,forgetButton:o,rows:s}),t}function _(e,t){let n=d.get(e);if(!n)return;let{ui:r,state:i,unseen:a}=t,{glyph:o,label:s,isMonitoring:c}=wd(i,r.awaitingBackgroundTasks),l=r.pendingPromptKind===`plan`?`Plan ready`:s,u=t.name;e.dataset.state=i,e.toggleAttribute(`data-monitoring`,c),e.dataset.prompt=r.pendingPromptKind??``,e.toggleAttribute(`data-unseen`,a),n.refs.glyph.textContent=o,n.refs.name.textContent=u;let f=V(`span`,`session-list-task-title`,r.taskTitle??``);n.refs.name.append(f),n.refs.name.title=[u,r.taskTitle].filter(Boolean).join(` | `),n.refs.badge.textContent=l;let p=r.card?.dataset.merge||``;e.dataset.merge=p,n.refs.merge.textContent=Sd[p]||``,n.refs.elapsed.textContent=bf(r),e.setAttribute(`aria-label`,`${u}, ${l}`)}function v(e,t){let n=f.get(e);if(!n)return;let{header:r,label:i,count:a,addButton:o,forgetButton:s,rows:c}=n,l=t.key===nU,u=t.rows.length===0;e.dataset.path=t.key,e.dataset.label=t.label,e.toggleAttribute(`data-empty`,u),r.title=t.title,i.textContent=t.label,a.textContent=String(t.rows.length),a.title=`${t.rows.length} ${t.rows.length===1?`session`:`sessions`}`,o.hidden=l,s.hidden=l||!u,l||(o.title=`Add a session to ${t.label}`,o.setAttribute(`aria-label`,`Add a session to ${t.label}`)),!l&&u&&(s.title=`Remove ${t.label} from the Board`,s.setAttribute(`aria-label`,`Remove ${t.label} from the Board`)),c.setAttribute(`aria-label`,`${t.label} sessions`)}let{noteStates:y,acknowledge:b,isUnseen:x}=V1();function ee(){let e=[...U.entries()].map(([e,t])=>({id:e,ui:t,name:Xd(t),isDormant:(t.currentState||I.DORMANT)===I.DORMANT,state:t.currentState||I.DORMANT,unseen:!1}));y(e);for(let t of e)t.unseen=x(t.id);return RO(e)}function te(){let e=ee(),t=q1(e,J1,JF(e,J1));m=HO(e),r.textContent=UO(m),r.toggleAttribute(`data-lit`,m>0);let n=new Set(t.order),i=t.order.join(`,`),y=p.get(a)===i&&a.childElementCount===t.groups.length;for(let e of t.groups){let t=u.get(e.key);t||(t=g(e.key),u.set(e.key,t)),v(t,e),y||a.appendChild(t);let n=e.rows.map(e=>e.id).join(`,`),r=f.get(t);if(!r)continue;let i=p.get(r.rows)===n&&r.rows.childElementCount===e.rows.length;for(let t of e.rows){let e=l.get(t.id);e||(e=h(t.id),l.set(t.id,e)),_(e,t);let n=d.get(e);n&&(i||r.rows.appendChild(n.item))}p.set(r.rows,n)}p.set(a,i);for(let[e,t]of[...u])n.has(e)||(t.remove(),u.delete(e));let b=new Set(t.visibleIds);for(let[e,t]of[...l]){if(b.has(e))continue;let n=d.get(t);n&&n.item.remove(),l.delete(e)}let x=t.groups.length>0;a.hidden=!x,o.hidden=x,!x&&(s.textContent=`No sessions`,c.textContent=`Spawn a session to start watching.`)}Cf(()=>{for(let[e,t]of l){let n=U.get(e),r=d.get(t);n&&r&&(r.refs.elapsed.textContent=bf(n))}});function ne(e){i.hidden=!e,t.toggleAttribute(`data-calm`,e)}return{el:t,topBarEl:n,calmEl:i,setCalmShown:ne,refresh:te,acknowledge:b,getAttentionCount:()=>m}}var X1=`glimmervoidCalmSheet`,Z1=Object.freeze({[X1]:!0});function Q1(e){return typeof e!=`object`||!e?!1:X1 in e}function $1({poppedState:e,isCalmSheetOpen:t,isOwnSheetPopPending:n}){if(n)return`own-sheet-pop`;let r=Q1(e);return r&&t?`adopt-sheet-entry`:r?`consume-stray-sheet-entry`:t?`close-sheet`:`navigate`}function e0({pushedEntry:e,isOwnSheetPopPending:t}){return e===`none`?t?`defer-until-own-pop`:`push-sheet-entry`:`keep-history`}function t0({pushedEntry:e,topState:t,isOwnSheetPopPending:n}){return!n&&e===`calm-sheet`&&Q1(t)}var n0=`clipboard`,r0=`upload`,i0=Object.freeze([Object.freeze({id:`esc`,label:`Esc`,bytes:`\x1B`,title:`Send Escape`}),Object.freeze({id:`tab`,label:`Tab`,bytes:` `,title:`Send Tab`}),Object.freeze({id:`up`,label:`Up`,bytes:`\x1B[A`,title:`Arrow up`}),Object.freeze({id:`down`,label:`Down`,bytes:`\x1B[B`,title:`Arrow down`}),Object.freeze({id:`paste`,label:`Paste`,bytes:null,action:n0,title:`Paste from the clipboard`}),Object.freeze({id:`upload-image`,label:`Image`,bytes:null,action:r0,accept:`image/*`,title:`Upload an image to this session`}),Object.freeze({id:`upload-file`,label:`File`,bytes:null,action:r0,title:`Upload a file to this session`})]);function a0(e){let t=i0.find(t=>t.id===e);return t?t.bytes:null}function o0(e){return!!e&&e.action===`clipboard`}function s0(e){return!!e&&e.action===`upload`}function c0({send:e,getSessionId:t}){let n=V(`div`,`phone-key-strip`);n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,`Terminal keys`);let r=null,i=null;for(let e of i0){let t=V(`button`,`phone-key`,e.label);t.type=`button`,t.dataset.key=e.id,t.title=e.title,t.addEventListener(`pointerdown`,e=>e.preventDefault()),t.addEventListener(`click`,()=>a(e,t)),n.appendChild(t)}function a(t,n){if(s0(t)){o(t,n);return}if(o0(t)){u0(e);return}e(a0(t.id))}function o(e,t){i=t,r||(r=V(`input`,`phone-file-picker`),r.type=`file`,r.hidden=!0,r.addEventListener(`change`,s),n.appendChild(r)),e.accept&&(r.accept=e.accept),e.accept||r.removeAttribute(`accept`),r.click()}function s(){let e=r;if(!e)return;let n=e.files?e.files[0]:null;if(e.value=``,!n)return;let a=t?.();if(!a){zx(`No session is open to upload to`);return}c(a,n,i)}async function c(e,t,n){n&&(n.disabled=!0);let r={"x-glimmervoid-upload-name":encodeURIComponent(t.name)};t.type&&(r[`content-type`]=t.type);try{let n=await fetch(`/upload/${encodeURIComponent(e)}`,{method:`POST`,body:t,headers:r});n.ok||zx(await l0(n))}catch{zx(`Upload failed`)}finally{n&&(n.disabled=!1)}}return n}async function l0(e){try{let t=await e.json();if(t&&typeof t.error==`string`)return`Upload failed: ${t.error}`}catch{}return`Upload failed`}function u0(e){let t=null;try{t=navigator.clipboard?.readText?.()}catch{zx(`Paste needs clipboard permission`);return}if(!t){zx(`Paste is unavailable in this browser`);return}t.then(t=>{t&&e(t)}).catch(()=>zx(`Paste needs clipboard permission`))}var d0=`‹`;function f0({onBack:e}){let t=V(`div`,`phone-terminal`),n=V(`header`,`phone-topbar phone-terminal-bar`),r=V(`button`,`phone-back`,d0);r.type=`button`,r.setAttribute(`aria-label`,`Back to board`),r.addEventListener(`click`,()=>e?.());let i=V(`div`,`phone-terminal-identity`),a=V(`span`,`phone-terminal-name`);a.title=`Tap to rename`,a.addEventListener(`click`,()=>x());let o=V(`span`,`session-task-title session-list-task-title`);HV(o,()=>ee());let s=V(`span`,`phone-terminal-identity-line`),c=V(`span`,`phone-terminal-badge`);c.innerHTML=`<span class="phone-terminal-glyph" aria-hidden="true"></span><span class="phone-terminal-label"></span><span class="phone-terminal-elapsed" aria-hidden="true"></span>`;let l=H(c,`.phone-terminal-glyph`,`span`),u=H(c,`.phone-terminal-label`,`span`),d=H(c,`.phone-terminal-elapsed`,`span`);s.append(a,o),i.append(s,c);let f=V(`div`,`phone-terminal-actions`);n.append(r,i,f);let p=V(`div`,`phone-card-slot`),m=V(`div`,`phone-empty`);m.innerHTML=`<p class="phone-empty-title">No session selected</p><p class="phone-empty-desc">Select a session from the board to watch it here.</p>`;let h=c0({send:y,getSessionId:()=>g});t.append(n,p,m,h);let g=null,_=null,v=null;function y(e){let t=g?U.get(g):null;t&&(yE(t,e)||zx(`Session is not connected; key press was dropped`))}function b(){let e=g?U.get(g):null;e?.term&&e.term.focus()}p.addEventListener(`click`,b);function x(){let e=g?U.get(g):null;e&&g&&qV(e,g)}function ee(){let e=g?U.get(g):null;e&&g&&WV(e,g)}function te(){let e=g?U.get(g):null,t=!!e;if(m.hidden=t,p.hidden=!t,h.hidden=!t,i.hidden=!t,!t){n.removeAttribute(`data-state`),n.removeAttribute(`data-monitoring`);return}let r=e.currentState||I.DORMANT;n.dataset.state=r;let{glyph:s,label:c,isMonitoring:f}=wd(r,e.awaitingBackgroundTasks);n.toggleAttribute(`data-monitoring`,f),KV(a)||(a.textContent=e.card?.dataset.session||g),UV(o,e.taskTitle),l.textContent=s,u.textContent=c,d.textContent=bf(e)}function ne(){v&&=(delete v.renameTargetEl,delete v.titleTargetEl,null),a.replaceChildren(),_&&=(Md(_),_.parentElement===f&&_.remove(),null)}function re(e){let t=U.get(e);if(t){if(g===e&&$M()===e&&t.card.parentElement===p){te();return}ne(),g=e,eN(t,e,p,{className:`phone-centered`}),_=H(t.card,`.session-actions`,`div`),jd(_,f),t.renameTargetEl=a,t.titleTargetEl=o,v=t,te()}}function ie(){ne(),$M()===g&&tN(),g=null,te()}function S(){if(!g){te();return}let e=U.get(g);if(!e){ie();return}if(e.card.parentElement!==p){re(g);return}te()}function ae(){let e=g;e&&OE(U.get(e),e,!1)}function oe(){S();let e=g;if(!e)return;let t=U.get(e);t&&OE(t,e,!0)}return Cf(()=>{let e=g?U.get(g):null;e&&(d.textContent=bf(e))}),te(),{el:t,show:re,clear:ie,refresh:S,reveal:oe,unview:ae,getSessionId:()=>g}}var p0=`board`,m0=Object.freeze([{id:p0,label:`Board`,glyph:`▤`},{id:`terminal`,label:`Terminal`,glyph:`▸`},{id:`review`,label:`Review`,glyph:`◫`},{id:`prs`,label:`PR reviews`,glyph:`⇅`,nested:!0},{id:`issues`,label:`Issues`,glyph:`#`,nested:!0},{id:`usage`,label:`Usage`,glyph:`◔`,nested:!0},{id:`radar`,label:`Radar`,glyph:`◎`,nested:!0},{id:`visions`,label:`Visions`,glyph:`◇`,nested:!0},{id:`hooks`,label:`Hooks`,glyph:`◈`,nested:!0},{id:`trace`,label:`Trace`,glyph:`T`,nested:!0},{id:`settings`,label:`Settings`,glyph:`@`,nested:!0}]),h0=null,g0=new Map,_0=new Map,v0=new Map,y0=null,b0=null,x0=null,S0=null,C0=null,w0=null,T0=null,E0=null,D0=null,O0=null,k0=null,A0=null,j0=null,M0=null,N0=null,P0=null,F0=null,I0=null,L0=null,R0=null,z0=null,B0=new Map,V0=new Set,H0={},U0=!1,W0=120,G0=0,K0=0,q0=`none`,J0=!1,Y0=!1,X0=!1,Z0={openTerminal:e=>d2(e),openPlan:e=>{O2(e)},onSheetOpenChange:e=>_2(e)};function Q0(){G0=0,K0=0}function $0(){let e=window.visualViewport;if(h0){if(!U0){h0.removeAttribute(`data-keyboard`);return}if(!e){h0.removeAttribute(`data-keyboard`);return}if(h0.style.setProperty(`--phone-vh`,`${e.height}px`),h0.style.setProperty(`--phone-vv-top`,`${e.offsetTop}px`),e.width!==K0&&(K0=e.width,G0=0),G0=Math.max(G0,e.height),G0-e.height>W0){h0.dataset.keyboard=`open`;return}h0.removeAttribute(`data-keyboard`)}}function e2(e,t,n){let r=V(`span`,`phone-nav-glyph`);r.setAttribute(`aria-hidden`,`true`),r.textContent=t;let i=V(`span`,`phone-nav-label`);i.textContent=n,e.append(r,i)}function t2(e,t,n=`phone-nav-item`,r=`phone-nav-dot`){let i=V(`button`,n);i.type=`button`,e2(i,t,e);let a=V(`span`,r);return a.setAttribute(`aria-hidden`,`true`),a.hidden=!0,i.appendChild(a),i}function n2(e){return e?.querySelector(`.phone-nav-dot`)||null}function r2(e,t){e&&(e.hidden=!t,typeof t==`string`&&(e.dataset.attention=t),typeof t!=`string`&&delete e.dataset.attention)}function i2(){let e=[];for(let t of m0){if(!t.nested||V0.has(t.id))continue;let n=v0.get(t.id)||!1;e.push(n),r2(n2(B0.get(t.id)),n)}r2(n2(R0),qO(e))}function a2(){let e=V(`div`,`phone-nav-more-menu`);e.hidden=!0;for(let t of m0){if(!t.nested)continue;let n=t2(t.label,t.glyph,`phone-nav-menu-item`,`phone-nav-dot phone-nav-menu-dot`);n.dataset.screen=t.id,n.hidden=V0.has(t.id),n.addEventListener(`click`,()=>{o2(!1),S2(t.id)}),B0.set(t.id,n),e.appendChild(n)}return e}function o2(e){z0&&R0&&(z0.hidden=!e,R0.setAttribute(`aria-expanded`,String(e)))}function s2(){return!!z0&&!z0.hidden}function c2(){let e=V(`nav`,`phone-nav`);e.setAttribute(`aria-label`,`Screens`);for(let t of m0){if(t.nested)continue;let n=t2(t.label,t.glyph);n.dataset.screen=t.id,n.addEventListener(`click`,()=>S2(t.id)),g0.set(t.id,n),e.appendChild(n)}return R0=t2(`More`,`⋯`),R0.setAttribute(`aria-expanded`,`false`),R0.addEventListener(`click`,()=>o2(!s2())),e.appendChild(R0),z0=a2(),e.appendChild(z0),e}function l2(e,t,n){let r=V(`section`,`phone-screen`);return r.dataset.screen=e,r.setAttribute(`aria-label`,t),r.hidden=!0,n&&r.appendChild(n),_0.set(e,r),r}function u2(){if(h0)return;y0=Y1({onSelectSession:e=>d2(e)}),y0.setCalmShown(X0),b0=f0({onBack:()=>S2(p0)}),x0=V(`div`,`phone-review`),S0=V(`div`,`phone-radar`),w0=V(`div`,`phone-prs`),E0=V(`div`,`phone-issues`),O0=V(`div`,`phone-usage`),A0=V(`div`,`phone-visions`),j0=V(`div`,`phone-hooks`),P0=V(`div`,`phone-trace`),I0=V(`div`,`phone-settings`);let e=V(`div`,`phone-screens`),t={[p0]:y0.el,terminal:b0.el,review:x0,radar:S0,prs:w0,issues:E0,usage:O0,visions:A0,hooks:j0,trace:P0,settings:I0};for(let n of m0)e.appendChild(l2(n.id,n.label,t[n.id]));h0=V(`div`,`phone-shell`),h0.id=`phone-shell`,h0.append(e,c2()),document.body.appendChild(h0),i2(),window.visualViewport?.addEventListener(`resize`,$0),window.visualViewport?.addEventListener(`scroll`,$0),window.addEventListener(`popstate`,y2),document.addEventListener(`click`,e=>{s2()&&z0&&R0&&e.target instanceof Node&&(z0.contains(e.target)||R0.contains(e.target)||o2(!1))}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&s2()&&o2(!1)})}function d2(e){let t=U.get(e);if(!t)return;if(!y0||!b0)throw Error(`Phone shell is not built`);let n=t.currentState||I.DORMANT;n===I.DORMANT&&B({type:`start-session`,id:e}),n===I.COMPLETE&&B({type:`dismiss`,id:e}),y0.acknowledge(e),bR(e),MF(e),b0.show(e),S2(`terminal`)}function f2(e){if(e===p0){if(q0===`none`)return;q0=`none`,history.back();return}let t={glimmervoidScreen:e};if(q0!==`none`){history.replaceState(t,``),q0=`screen`;return}history.pushState(t,``),q0=`screen`}function p2(){if(Q1(history.state))return q0=`calm-sheet`,g2(),p0;let e=v2(history.state);return e&&_0.has(e)&&!V0.has(e)?(q0=`screen`,e):(e&&history.replaceState(null,``),q0=`none`,p0)}function m2(){q0!==`none`&&(q0=`none`,history.back())}function h2(){e0({pushedEntry:q0,isOwnSheetPopPending:Y0})===`push-sheet-entry`&&(history.pushState(Z1,``),q0=`calm-sheet`)}function g2(){t0({pushedEntry:q0,topState:history.state,isOwnSheetPopPending:Y0})&&(q0=`none`,Y0=!0,history.back())}function _2(e){if(J0=e,e){h2();return}g2()}function v2(e){let t=e?.glimmervoidScreen;return typeof t==`string`?t:null}function y2(e){let t=Y0;if(Y0=!1,!U0)return;let n=$1({poppedState:e.state,isCalmSheetOpen:J0,isOwnSheetPopPending:t});if(n===`own-sheet-pop`){J0&&h2();return}if(n===`adopt-sheet-entry`){q0=`calm-sheet`;return}if(n===`consume-stray-sheet-entry`){q0=`calm-sheet`,g2();return}if(n===`close-sheet`){q0=`none`,YM();return}let r=v2(e.state);q0=r?`screen`:`none`,x2(r&&_0.has(r)&&!V0.has(r)?r:p0)}function b2(e,t){for(let[n,r]of e){if(n===t){r.setAttribute(`aria-current`,`page`);continue}r.removeAttribute(`aria-current`)}}function x2(e){if(!R0||!b0)throw Error(`Phone shell is not built`);Vd.dispatch(`setPhoneScreen`,e),o2(!1),H0.onScreenShown?.(e);for(let[t,n]of _0)n.hidden=t!==e;E2(),b2(g0,e);let t=B0.has(e);if(t&&R0.setAttribute(`aria-current`,`page`),t||R0.removeAttribute(`aria-current`),b2(B0,e),e===`terminal`){b0.reveal();return}b0.unview()}function S2(e){h0&&_0.has(e)&&(V0.has(e)||(e!==Vd.snapshot().phoneScreen&&f2(e),x2(e)))}function C2(e){H0=e||{},C0=H0.radarPanelEl||null,T0=H0.prsPanelEl||null,D0=H0.issuesPanelEl||null,k0=H0.usagePanelEl||null,M0=H0.visionsPanelEl||null,N0=H0.hooksPanelEl||null,F0=H0.tracePanelEl||null,L0=H0.settingsPanelEl||null}function w2({sessionId:e}={}){if(U0)return;if(u2(),!h0||!y0||!b0)throw Error(`Phone shell is not built`);U0=!0,h0.hidden=!1;for(let e of H0.headerControls||[])jd(e,y0.topBarEl);fz(x0),jd(C0,S0),C0&&(C0.hidden=!1),jd(T0,w0),T0&&(T0.hidden=!1),jd(D0,E0),D0&&(D0.hidden=!1),jd(k0,O0),k0&&(k0.hidden=!1),jd(M0,A0),M0&&(M0.hidden=!1),jd(N0,j0),N0&&(N0.hidden=!1),jd(F0,P0),F0&&(F0.hidden=!1),jd(L0,I0),L0&&(L0.hidden=!1),$0(),e&&b0.show(e);let t=p2();if(M2(),e&&t===p0){Vd.dispatch(`setPhoneScreen`,p0),S2(`terminal`);return}x2(t)}function T2(){if(U0){if(!h0||!b0)throw Error(`Phone shell is not built`);U0=!1,E2(),O1({returnFocus:!1}),b0.clear(),fz(null),C0&&Md(C0),T0&&Md(T0),D0&&Md(D0),k0&&Md(k0),M0&&Md(M0),N0&&Md(N0),F0&&Md(F0),L0&&Md(L0);for(let e of H0.headerControls||[])Md(e);o2(!1),h0.hidden=!0,h0.removeAttribute(`data-keyboard`),Q0(),m2()}}function E2(){if(y0){if(!(U0&&X0&&Vd.snapshot().phoneScreen===p0)){XM();return}JM(y0.calmEl,Z0)}}function D2(e){X0=e,y0?.setCalmShown(e),E2()}function O2(e){return!U0||!y0||!b0||!U.has(e)?!1:(d2(e),kH(e))}function k2(){return U0}function A2(e){return U0&&Vd.snapshot().phoneScreen===e}function j2(){return U0&&b0?b0.getSessionId():null}function M2(){if(!U0)return;if(!y0||!b0)throw Error(`Phone shell is not built`);I2(),y0.refresh(),b0.refresh(),Vd.snapshot().phoneScreen===`terminal`&&!b0.getSessionId()&&S2(p0);let e=n2(g0.get(p0));e&&(e.hidden=y0.getAttentionCount()===0)}function N2(e){return!U0||!_0.has(e)||V0.has(e)?!1:(S2(e),!0)}function P2(e,t){t&&V0.delete(e),t||V0.add(e);let n=B0.get(e);n&&(n.hidden=!t);let r=_0.get(e);r&&!t&&(r.hidden=!0),i2(),!t&&U0&&Vd.snapshot().phoneScreen===e&&S2(p0)}function F2(e,t){v0.set(e,typeof t==`string`&&t?t:t===!0),i2()}function I2(){if(!b0)throw Error(`Phone shell is not built`);if(b0.getSessionId())return;let e=jF();if(!e)return;let t=U.get(e);t&&(t.currentState||I.DORMANT)!==I.DORMANT&&(b0.show(e),bR(e))}function L2(e,t){return!!e?.error&&!e.isRefreshing&&typeof e.nextAttemptAt==`number`&&e.nextAttemptAt>t}function R2(e,t){if(!e?.error)return null;let n=`Could not reach GitHub: ${e.error.trim().replace(/[.!]+$/,``)}.`;if(e.isRefreshing)return`${n} Refreshing.`;if(typeof e.nextAttemptAt!=`number`)return n;let r=Math.max(0,Math.ceil((e.nextAttemptAt-t)/1e3));return r===0?`${n} Retrying now.`:e.retry?`${n} Retrying in ${r}s (${e.retry.attempt} of ${e.retry.limit}).`:`${n} Next try in ${r>=60?`${Math.ceil(r/60)} min`:`${r}s`}.`}function z2(e,t,n){return e?.refreshNotice&&e.isRefreshing?e.refreshNotice:t||e?.isRefreshing?`Refreshing.`:n||e?.refreshNotice||``}var B2={minPx:220,maxPx:720},V2=16,H2=new Set,U2=0;function W2(e){let t=dF();e.toggleAttribute(`data-queue-collapsed`,t),e.querySelector(`.pr-queue-toggle`)?.setAttribute(`aria-expanded`,String(!t));let n=lF();if(n===null){e.style.removeProperty(`--pr-queue-width`);return}e.style.setProperty(`--pr-queue-width`,`${n}px`)}function G2(){for(let e of H2){if(!e.isConnected){H2.delete(e);continue}W2(e)}}function K2(e,t){let n=V(`div`,`pr-queue-head`);return e&&n.append(e),t&&n.append(t),n}function q2({queueLabel:e,scopeTabs:t,resizerLabel:n}){let r=V(`div`,`pr-columns`),i=V(`div`,`pr-queue-pane`),a=V(`nav`,`pr-queue`);a.id=`pr-queue-${++U2}`,a.setAttribute(`aria-label`,e);let o=V(`button`,`pr-queue-toggle`);o.type=`button`,o.setAttribute(`aria-label`,`Review queue`),o.setAttribute(`aria-controls`,a.id),o.title=`Collapse or expand the review queue`;let s=JL(16,16);s.append(qL(`rect`,{x:`1.5`,y:`2`,width:`13`,height:`12`,rx:`2`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`})),s.append(qL(`path`,{d:`M5.5 2V14`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`}));let c=qL(`path`,{d:`M11 6L9 8L11 10`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`,"stroke-linecap":`round`,"stroke-linejoin":`round`});c.classList.add(`pr-queue-chevron`),s.append(c),o.append(s),o.addEventListener(`click`,()=>{fF(!dF()),G2()}),i.append(K2(t,o),a);let l=V(`div`,`pr-queue-resizer`);l.setAttribute(`role`,`separator`),l.setAttribute(`aria-orientation`,`vertical`),l.setAttribute(`aria-label`,n),l.tabIndex=0;let u=V(`main`,`pr-detail-host`);return r.append(i,l,u),W2(r),H2.add(r),RN({resizer:l,column:i,widthHost:r,widthProperty:`--pr-queue-width`,bounds:B2,keyStepPx:V2,getStoredWidth:lF,setStoredWidth:uF}),{columns:r,queue:a,detail:u}}var J2=48,Y2=[`var(--accent)`,`var(--state-running)`,`var(--state-idle)`,`var(--state-waiting)`,`var(--state-failed)`],X2=2600,Z2=null;function Q2(e){let t=V(`span`,`merge-confetti-piece`),n=Math.round((Math.random()-.5)*520),r=Math.round(180+Math.random()*220);return t.style.setProperty(`--confetti-x`,`${n}px`),t.style.setProperty(`--confetti-rise`,`${-r}px`),t.style.setProperty(`--confetti-spin`,`${Math.round((Math.random()-.5)*1080)}deg`),t.style.setProperty(`--confetti-delay`,`${Math.round(Math.random()*160)}ms`),t.style.background=Y2[e%Y2.length],t}function $2(e){Z2?.remove();let t=V(`div`,`merge-celebration`);t.setAttribute(`role`,`status`);let n=V(`div`,`merge-confetti`);for(let e=0;e<J2;e+=1)n.append(Q2(e));t.append(n,V(`p`,`merge-celebration-message`,e)),document.body.append(t),Z2=t,window.setTimeout(()=>{t.remove(),Z2===t&&(Z2=null)},X2)}var e4={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},t4=new Set([`FAILURE`,`ERROR`]);function n4(e){return e4[e]}function r4(e){return e.state===`MERGED`?`Already merged`:e.state===`OPEN`?e.isDraft?`Drafts cannot be merged`:e.isInMergeQueue?`Already in the merge queue`:e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?`Resolve the merge conflicts first`:e.checks.failing.length>0||e.checks.state!==null&&t4.has(e.checks.state)?`Checks are failing`:e.stage===`ready`?null:`Not ready to merge yet`:`Closed`}function i4(e,t,n,r,i,a){return{isVisible:a&&(e.state===`OPEN`||t),isPressed:t,isDisabled:n,statusText:r||(n?`Saving...`:i)}}function a4(e,t,n=``){if(!t||!e.keepMergeable)return null;let r=o4(e,!1,``,!0,n).statusText;if(e.isKeepMergeableFixInFlight)return{text:`Repairing`,tone:`warn`,title:r};let i=e.keepMergeableAttempt;return!i||i.outcome===`pushed`||i.outcome===`stopped`?null:{text:`Repair failed`,tone:`danger`,title:r}}function o4(e,t,n=``,r=!0,i=``){let a=e.keepMergeableAttempt,o=e.keepMergeable?`On`:`Off`;if(e.keepMergeable&&a&&a.outcome!==`pushed`&&a.outcome!==`stopped`){let e=i?` (${i})`:``;o=`Keep mergeable failed: ${a.reason??`The attempt produced no repair`}${e}`}return e.isKeepMergeableFixInFlight&&(o=`Keep mergeable is running`),i4(e,!!e.keepMergeable,t,n,o,r)}function s4(e){return e?.isKeepMergeableEnabled!==!1}function c4(e){return e?.isMergeQueueEnabled!==!1}var l4={one:`st`,two:`nd`,few:`rd`,other:`th`},u4=new Intl.PluralRules(`en-US`,{type:`ordinal`});function d4(e){return`${e}${l4[u4.select(e)]??`th`}`}function f4(e,t){return e===null?`Not queued`:t?`Repair pushed, waiting for you`:`Queued, ${d4(e)} in line for this repository`}function p4(e,t,n=``,r=!0){let i=e.mergeQueuePosition??null;return i4(e,i!==null,t,n,f4(i,!!e.isMergeQueueHeldForRepairPush),r)}var m4=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],h4=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],g4={conflicts:`Needs you`,behind:`Needs you`,"checks-failing":`Needs you`,"changes-requested":`Needs you`,"unresolved-threads":`Needs you`,"checks-pending":`Waiting`,"needs-approval":`Waiting`,unknown:`Waiting`,ready:`Ready to merge`,draft:`Drafts`,merged:`Merged today`},_4={merged:`Merged`,draft:`Draft`,conflicts:`Merge conflicts`,behind:`Behind base`,"checks-failing":`Checks failing`,"changes-requested":`Changes requested`,"unresolved-threads":`Unresolved threads`,"checks-pending":`Checks running`,"needs-approval":`Needs approval`,ready:`Ready to merge`,unknown:`Status unknown`},v4={merged:`muted`,draft:`muted`,conflicts:`danger`,behind:`warn`,"checks-failing":`danger`,"changes-requested":`warn`,"unresolved-threads":`warn`,"checks-pending":`wait`,"needs-approval":`wait`,ready:`ok`,unknown:`muted`};function y4(e){let t=Rl.safeParse(e);return t.success?t.data:null}function b4(e){let t=e.filter(e=>e.state===`OPEN`&&!e.isCrossRepository),n=new Map(t.map(e=>[JSON.stringify([e.repo.toLowerCase(),e.headRefName]),e])),r=new Map,i=[];for(let t of e){let e=t.state===`OPEN`?n.get(JSON.stringify([t.repo.toLowerCase(),t.baseRefName])):void 0;if(!e||e.key===t.key){i.push(t);continue}let a=r.get(e.key)??[];a.push(t),r.set(e.key,a)}let a=[],o=new Set;for(let t of[...i,...e]){if(o.has(t.key))continue;let e=[],n=[{pr:t,parentKey:null,depth:0}];for(;n.length>0;){let t=n.pop();if(!t||o.has(t.pr.key))continue;o.add(t.pr.key),e.push(t);let i=r.get(t.pr.key)??[];for(let e=i.length-1;e>=0;--e)n.push({pr:i[e],parentKey:t.pr.key,depth:t.depth+1})}a.push({root:t,rows:e})}return a}function x4(e){return m4[e.rows.reduce((e,{pr:t})=>Math.min(e,m4.indexOf(g4[t.stage])),m4.length-1)]}function S4(e){let t=new Map(m4.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of b4(e)){let e=t.get(x4(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return h4.flatMap(e=>t.get(e)??[])}function C4(e){return _4[e]}function w4(e){return v4[e]}function T4(e){if(e.checks.failing.length>0){let t=e.checks.failing.length-3;return{label:`Checks`,tone:`danger`,text:`${e.checks.failing.length} failing: ${e.checks.failing.slice(0,3).join(`, `)}${t>0?` and ${t} more`:``}`}}return e.checks.state===`FAILURE`||e.checks.state===`ERROR`?{label:`Checks`,tone:`danger`,text:`Failing`}:e.checks.pendingCount>0?{label:`Checks`,tone:`wait`,text:`${e.checks.pendingCount} running`}:e.checks.state===`PENDING`||e.checks.state===`EXPECTED`?{label:`Checks`,tone:`wait`,text:`Running`}:e.checks.state===`SUCCESS`?{label:`Checks`,tone:`ok`,text:`Passing`}:{label:`Checks`,tone:`muted`,text:`No checks`}}function E4(e){return`${e} ${e===1?`approval`:`approvals`}`}function D4(e){return e.reviewRequests.map(e=>e.name).join(`, `)}function O4(e){let t=e.reviewRequests.length>0?`Requested: ${D4(e)}`:`Approval required`;return e.approvals>0?`${t}, ${E4(e.approvals)}`:t}function k4(e){let t=e.approvals>0?E4(e.approvals):`Approved`;return e.mergeStateStatus===`BLOCKED`?{label:`Review`,tone:`wait`,text:`${t}, merge blocked`}:{label:`Review`,tone:`ok`,text:t}}function A4(e){return e.reviewDecision===`CHANGES_REQUESTED`?{label:`Review`,tone:`warn`,text:`Changes requested`}:e.reviewDecision===`APPROVED`?k4(e):e.reviewDecision===`REVIEW_REQUIRED`||e.mergeStateStatus===`BLOCKED`?{label:`Review`,tone:`wait`,text:O4(e)}:e.reviewRequests.length>0?{label:`Review`,tone:`wait`,text:`Requested: ${D4(e)}`}:{label:`Review`,tone:`muted`,text:`No review requested`}}function j4(e,t){return t?e.lastAuthor!==t:null}function M4(e){let t=e.line===null?e.path:`${e.path}:${e.line}`;return e.isOutdated?`${t} (outdated)`:t}function N4(e){let t=e.commentCount-1;return t===0?`No replies`:`${t} ${t===1?`reply`:`replies`}, last by ${e.lastAuthor??`a deleted account`}`}function P4(e,t){let n=j4(e,t);return n===null?null:n?{tone:`warn`,text:`Waiting on you`}:{tone:`wait`,text:`Waiting on reviewer`}}function F4(e,t){return[...e.threads].sort((e,n)=>{let r=Number(j4(n,t)===!0)-Number(j4(e,t)===!0);return r===0?(Date.parse(n.lastActivityAt)||0)-(Date.parse(e.lastActivityAt)||0):r}).map(e=>({location:M4(e),url:e.url,author:e.author??`a deleted account`,excerpt:e.excerpt,replySummary:N4(e),lastActivityAt:e.lastActivityAt,waiting:P4(e,t)}))}function I4(e,t){if(e.unresolvedThreads===0)return{label:`Threads`,tone:`ok`,text:`None open`};let n=`${e.unresolvedThreads} unresolved`;if(!t||e.threads.length===0)return{label:`Threads`,tone:`warn`,text:n};let r=e.threads.filter(e=>j4(e,t)).length;return r===0?{label:`Threads`,tone:`wait`,text:`${n}, all waiting on reviewers`}:{label:`Threads`,tone:`warn`,text:`${n}, ${r} waiting on you`}}function L4(e){return e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?{label:`Conflicts`,tone:`danger`,text:`Conflicts with ${e.baseRefName}`}:e.mergeable===`MERGEABLE`?{label:`Conflicts`,tone:`ok`,text:`None`}:{label:`Conflicts`,tone:`muted`,text:`Not computed yet`}}function R4(e){let t=e.behindBy!==null&&e.behindBy>0;return e.mergeStateStatus===`BEHIND`?{label:`Base`,tone:`warn`,text:t?`${e.behindBy} behind ${e.baseRefName}`:`Behind ${e.baseRefName}`}:e.behindBy===null?{label:`Base`,tone:`muted`,text:`Unknown`}:t?{label:`Base`,tone:`muted`,text:`${e.behindBy} behind ${e.baseRefName}, update not required`}:{label:`Base`,tone:`ok`,text:`Up to date with ${e.baseRefName}`}}var z4={APPROVED:{text:`Approved`,tone:`ok`},CHANGES_REQUESTED:{text:`Requested changes`,tone:`warn`},COMMENTED:{text:`Commented`,tone:`muted`},DISMISSED:{text:`Dismissed`,tone:`muted`},PENDING:{text:`Pending`,tone:`wait`}};function B4(e){return[...e.reviews].sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).map(e=>{let t=z4[e.state]??{text:e.state.toLowerCase().replaceAll(`_`,` `),tone:`muted`};return{reviewer:e.reviewer??`a deleted account`,text:t.text,tone:t.tone,submittedAt:e.submittedAt}})}function V4(e,t=null){if(e.state===`MERGED`)return[];let n=[T4(e),A4(e),I4(e,t),L4(e),R4(e)];return e.autoRebase?[...n,{label:`Auto-rebase`,tone:e.autoRebase.outcome===`rebased`?`ok`:`danger`,text:e.autoRebase.message}]:n}function H4(e){return e?e.configured?e.error&&e.prs.length===0?`Pull requests will show here once GitHub answers.`:`No open or recently merged pull requests found.`:`Enable Team review and set its GitHub organization in settings to see your pull requests.`:`Waiting for your pull requests.`}function U4(e,t=0){if(!e)return[];let n=R2(e,t),r=n?[{text:n,tone:`error`}]:[];return e.truncatedNote?[...r,{text:e.truncatedNote,tone:`info`}]:r}function W4(e,t){let n=e.flatMap(e=>e.prs);return t&&n.some(e=>e.key===t)?t:n[0]?.key??null}function G4(e,t){if(!e)return[];let n=new Set(e.filter(e=>e.state===`OPEN`).map(e=>e.key));return t.filter(e=>e.state===`MERGED`&&n.has(e.key))}function K4(e){return e.length===1?`Merged ${e[0].key}`:`Merged ${e.length} pull requests`}var q4={isVisible:!1,isDisabled:!0,statusText:``,tone:null},J4={merged:{statusText:`Merged on GitHub. Refreshing the list.`,tone:`ok`},queued:{statusText:`Added to the merge queue. Refreshing the list.`,tone:`ok`},"auto-merge":{statusText:`Auto-merge enabled. GitHub merges it once its requirements pass.`,tone:`ok`},unconfirmed:{statusText:`GitHub accepted the request but did not confirm a merge. Check GitHub.`,tone:null}};function Y4(e,t){if(e.state!==`OPEN`)return q4;let n=t?.head===e.headRefOid?t:void 0;if(n?.phase===`pending`)return{isVisible:!0,isDisabled:!0,statusText:`Merging on GitHub`,tone:`busy`};if(n&&n.phase!==`failed`)return{isVisible:!0,isDisabled:!0,...J4[n.phase]};let r=r4(e);return r?{isVisible:!0,isDisabled:!0,statusText:r,tone:null}:n?.phase===`failed`?{isVisible:!0,isDisabled:!1,statusText:n.text,tone:`error`}:{isVisible:!0,isDisabled:!1,statusText:`Merges into ${e.baseRefName} with ${n4(e.mergeMethod)}`,tone:null}}function X4(e){return`Merge ${e.key} "${e.title}" into ${e.baseRefName} with ${n4(e.mergeMethod)}, your default for this repository. Glimmervoid does not delete the branch.`}function Z4(e){let t=Vl.safeParse(e);if(!t.success)return null;let n=e&&typeof e==`object`&&`requestId`in e?e.requestId:null;return typeof n==`string`?{...t.data,requestId:n}:null}var Q4=null,$4=null,e3=null,t3=null,n3=null,r3=null,i3=null,a3=new Map,o3=new Set,s3=new Map,c3={label:`Keep mergeable`,pendingKeys:new Set,errorsByKey:new Map,controlState:(e,t,n,r)=>o4(e,t,n,r,bN(e.keepMergeableAttempt?.at)),isFeatureEnabled:s4,save:async(e,t)=>{let n=await dd(`my-pr-keep-mergeable`,{repo:e.repo,number:e.number,keepMergeable:t});if(n.type!==`my-pr-keep-mergeable-result`||n.key!==e.key)throw Error(`Unexpected keep mergeable reply.`);return n.ok?null:n.error??`Could not save Keep mergeable.`}},l3={label:`Merge when ready`,pendingKeys:new Set,errorsByKey:new Map,controlState:p4,isFeatureEnabled:c4,save:async(e,t)=>{let n=await dd(`my-pr-merge-when-ready`,{repo:e.repo,number:e.number,mergeWhenReady:t});if(n.type!==`my-pr-merge-when-ready-result`||n.key!==e.key)throw Error(`Unexpected merge when ready reply.`);return n.ok?null:n.error??`Could not save Merge when ready.`}},u3=6e4,d3=`No reply from the server. Check GitHub before trying again.`;function f3(e,t){let n=V(`div`,`reviews-refresh-control`),r=V(`button`,`pr-action reviews-refresh-button`,`Refresh`);r.type=`button`;let i=V(`span`,`reviews-refresh-status`);i.setAttribute(`role`,`status`);let a=V(`p`,`my-pr-error reviews-retry-notice`);n.append(r,i);let o=null,s=!1,c=``,l=null;function u(){a.textContent=R2(o,Date.now()),a.hidden!==!o?.error&&(a.hidden=!o?.error);let e=a.isConnected&&!kd(t)&&!document.hidden&&a.getClientRects().length>0&&L2(o,Date.now());!e&&l!==null&&(window.clearInterval(l),l=null),e&&l===null&&(l=window.setInterval(u,1e3))}function d(e){e!==o&&(c=``),o=e,r.disabled=s||!!e?.isRefreshing||!e?.configured,i.textContent=z2(e,s,c),i.hidden=!i.textContent,u()}r.addEventListener(`click`,async()=>{if(!s){s=!0,c=``,d(o);try{let t=await dd(`reviews-refresh`,{lane:e});t.type===`reviews-refresh-result`&&(c=t.ok?`Refreshed.`:t.error??`Could not refresh from GitHub.`)}catch(e){c=e instanceof Error?e.message:String(e)}finally{s=!1,d(o)}}});let f=new MutationObserver(u);f.observe(t,{attributes:!0,subtree:!0,attributeFilter:[`hidden`,`data-queue-collapsed`]});for(let e=t.parentElement;e;e=e.parentElement)f.observe(e,{attributes:!0,attributeFilter:[`hidden`,`data-queue-collapsed`]});return document.addEventListener(`visibilitychange`,u),{control:n,notice:a,update:d}}function p3(e,t,n,r){a3.set(e,{head:t,phase:n,text:r}),x3()}function m3(e){if(s3.has(e.key))return;let t=`my-pr-merge-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;if(!B({type:`my-pr-merge`,requestId:t,repo:e.repo,number:e.number,headRefOid:e.headRefOid})){p3(e.key,e.headRefOid,`failed`,`Not connected to the server.`);return}let n=window.setTimeout(()=>{s3.delete(e.key),p3(e.key,e.headRefOid,`failed`,d3)},u3);s3.set(e.key,{requestId:t,head:e.headRefOid,timer:n}),a3.set(e.key,{head:e.headRefOid,phase:`pending`,text:``}),x3()}function h3(e){let t=Y4(e,a3.get(e.key));if(!t.isVisible)return null;let n=V(`div`,`my-pr-merge`),r=V(`button`,`pr-action`,`Merge`);r.type=`button`,r.disabled=t.isDisabled;let i=V(`span`,`pr-action-status`,t.statusText);return i.setAttribute(`role`,`status`),i.setAttribute(`aria-live`,`polite`),t.tone&&(i.dataset.tone=t.tone),r.addEventListener(`click`,()=>{af({title:`Merge pull request`,message:X4(e),confirmLabel:`Merge`,onConfirm:()=>m3(e)})}),n.append(r,i),n}function g3(e,t){let n=t.controlState(e,t.pendingKeys.has(e.key),t.errorsByKey.get(e.key),t.isFeatureEnabled(n3));if(!n.isVisible)return null;let r=V(`div`,`my-pr-merge`),i=V(`button`,`pr-action`,t.label);i.type=`button`,i.disabled=n.isDisabled,i.setAttribute(`aria-pressed`,String(n.isPressed));let a=V(`span`,`pr-action-status`,n.statusText);return a.setAttribute(`role`,`status`),a.setAttribute(`aria-live`,`polite`),i.addEventListener(`click`,async()=>{if(!t.pendingKeys.has(e.key)){t.pendingKeys.add(e.key),t.errorsByKey.delete(e.key),x3();try{let r=await t.save(e,!n.isPressed);r&&t.errorsByKey.set(e.key,r)}catch(n){t.errorsByKey.set(e.key,n instanceof Error?n.message:String(n))}finally{t.pendingKeys.delete(e.key),x3()}}}),r.append(i,a),r}function _3(e,{hasGlyph:t}){let n=V(`span`,`my-pr-stage`);return n.dataset.tone=w4(e.stage),t&&n.append(YL(w4(e.stage))),n.append(C4(e.stage)),n}function v3(e,t){let n=V(`span`,`my-pr-requested`);n.append(V(`span`,null,`Requested`));let r=V(`span`,`avatar-stack`);for(let t of e.reviewRequests){let e=vd({login:t.name,url:t.isTeam?t.avatarUrl:void 0,cssPx:16});e.title=t.name,e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,t.name),r.append(e)}return n.append(r,V(`span`,`my-pr-requested-names`,t.slice(11))),n}function y3(){if(!Q4||!$4||e3?.isConnected)return;let e=q2({queueLabel:`My pull requests`,scopeTabs:$4,resizerLabel:`Resize pull request list`});e3=e.queue,t3=e.detail,Q4.replaceChildren(e.columns);let t=Q4.querySelector(`.pr-queue-head`);i3&&t&&t.insertBefore(i3.control,t.querySelector(`.pr-queue-toggle`))}function b3(e){if(!t3)return;if(!e){t3.replaceChildren(V(`p`,`pr-empty`,H4(n3)));return}let t=V(`article`,`pr-detail`),n=V(`div`,`pr-detail-heading`),r=V(`div`,`pr-detail-title`);r.append(xd(`pr-link`,e.key,e.url),V(`h2`,null,e.title)),n.append(r,_3(e,{hasGlyph:!0})),t.append(n);for(let n of[c3,l3]){let r=g3(e,n);r&&t.append(r)}let i=V4(e,n3?.viewer??null);if(i.length>0){let n=V(`section`,`pr-readiness-section`);n.append(V(`h3`,`pr-section-heading`,`Merge readiness`));let r=V(`ul`,`pr-readiness`);for(let t of i){let n=V(`li`,`pr-readiness-row`),i=V(`span`,`pr-readiness-value`);t.label===`Review`&&t.text.startsWith(`Requested: `)&&i.append(v3(e,t.text)),i.childNodes.length===0&&(i.textContent=t.text),n.append(YL(t.tone),V(`span`,`pr-readiness-label`,t.label),i),r.append(n)}n.append(r);let a=h3(e);a&&n.append(a),t.append(n)}if(e.checks.failing.length>0){let n=V(`section`,`my-pr-failures`);n.append(V(`h3`,`pr-section-heading`,`Failing checks`));let r=V(`ul`,`my-pr-facts`);for(let t of e.checks.failing)r.append(V(`li`,null,t));n.append(r),t.append(n)}let a=B4(e);if(a.length>0){let e=V(`section`,`pr-readiness-section`);e.append(V(`h3`,`pr-section-heading`,`Reviews`));let n=V(`ul`,`pr-readiness`);for(let e of a){let t=V(`li`,`pr-readiness-row`),r=Date.parse(e.submittedAt??``),i=Number.isFinite(r)?`${e.text} ${bN(r)}`:e.text,a=V(`span`,`my-pr-reviewer`);a.append(yd([{login:e.reviewer,tone:e.tone,title:e.reviewer,url:e.reviewer===`a deleted account`?null:void 0}],16),V(`span`,null,e.reviewer)),t.append(YL(e.tone),a,V(`span`,`pr-readiness-value`,i)),n.append(t)}e.append(n),t.append(e)}let o=F4(e,n3?.viewer??null);if(o.length>0){let e=V(`section`,`my-pr-threads-section`);e.append(V(`h3`,`pr-section-heading`,`Unresolved threads`));let n=V(`ul`,`my-pr-threads`);for(let e of o){let t=V(`li`,`my-pr-thread`),r=V(`div`,`my-pr-thread-heading`);if(r.append(xd(`my-pr-thread-location`,e.location,e.url)),e.waiting){let t=V(`span`,`my-pr-stage`);t.dataset.tone=e.waiting.tone,t.append(YL(e.waiting.tone),e.waiting.text),r.append(t)}let i=V(`p`,`my-pr-thread-excerpt`);i.append(V(`strong`,null,e.author),` ${e.excerpt}`);let a=Date.parse(e.lastActivityAt),o=V(`p`,`my-pr-thread-meta`,Number.isFinite(a)?`${e.replySummary}, ${bN(a)}`:e.replySummary);t.append(r,i,o),n.append(t)}e.append(n),t.append(e)}let s=V(`p`,`pr-detail-meta`);s.append(V(`span`,null,`Opened ${bN(Date.parse(e.createdAt))}`),V(`span`,null,`${e.state===`MERGED`?`Merged`:`Updated`} ${bN(Date.parse(e.state===`MERGED`?e.mergedAt??``:e.updatedAt))}`)),t.append(s),t3.replaceChildren(t)}function x3(){if(y3(),!e3)return;let e=n3?.prs??[],t=S4(e);r3=W4(t,r3);let n=document.activeElement instanceof HTMLElement&&e3.contains(document.activeElement)?document.activeElement.dataset.prKey:null,r=t.filter(e=>e.rows.length>0).map(e=>{let t=V(`section`,`pr-queue-section`);t.append(V(`h3`,`pr-section-heading`,`${e.title} ${e.rows.length}`));for(let{pr:n,parentKey:r,depth:i}of e.rows){let e=V(`button`,`pr-queue-row`);e.type=`button`,e.dataset.prKey=n.key,r&&(e.style.paddingInlineStart=`${12+Math.min(i,6)*16}px`),e.setAttribute(`aria-current`,String(n.key===r3)),e.title=`${n.key}: ${C4(n.stage)}`;let a=V(`span`,`pr-queue-glyph`);a.append(YL(w4(n.stage)));let o=V(`span`,`pr-queue-top`);o.append(V(`strong`,`pr-queue-ref`,n.key),V(`span`,`pr-queue-title`,n.title));let s=V(`span`,`pr-queue-bottom`);r&&s.append(V(`span`,`my-pr-stage`,`Stacked on ${r}`)),s.append(_3(n,{hasGlyph:!1}),V(`span`,`pr-queue-elapsed`,`opened ${bN(Date.parse(n.createdAt))}`));let c=a4(n,c3.isFeatureEnabled(n3),bN(n.keepMergeableAttempt?.at));if(c){let e=V(`span`,`my-pr-stage`,c.text);e.dataset.tone=c.tone,e.title=c.title,s.append(e)}e.append(a,o,s),e.addEventListener(`click`,()=>{r3=n.key;for(let e of e3?.querySelectorAll(`button[data-pr-key]`)??[])e.setAttribute(`aria-current`,String(e.dataset.prKey===r3));b3(n),document.documentElement.dataset.layout===`phone`&&t3?.scrollIntoView({block:`start`,behavior:`smooth`})}),t.append(e)}return t});if(r.length===0&&e3.replaceChildren(V(`p`,`pr-empty`,H4(n3))),r.length>0){let e=U4(n3,Date.now()).filter(e=>e.tone!==`error`).map(e=>V(`p`,e.tone===`error`?`my-pr-error`:`my-pr-note`,e.text));e3.replaceChildren(...e,...r)}i3&&(e3.prepend(i3.notice),i3.update(n3)),n&&[...e3.querySelectorAll(`button[data-pr-key]`)].find(e=>e.dataset.prKey===n)?.focus({preventScroll:!0}),b3(e.find(e=>e.key===r3))}function S3(e,t){return Q4||($4=t,Q4=V(`div`,`pr-content`),e.append(Q4),i3=f3(`my-prs`,Q4),x3(),Q4)}function C3(e){let t=y4(e);if(!t)return;let n=G4(n3?.prs??null,t.prs);n3=t,x3(),w3(n)}function w3(e){let t=e.filter(e=>!o3.has(e.key));if(t.length!==0){for(let e of t)o3.add(e.key);$2(K4(t))}}function T3(e){let t=Z4(e);if(!t)return;let n=s3.get(t.key);if(!n||n.requestId!==t.requestId)return;if(window.clearTimeout(n.timer),s3.delete(t.key),!t.ok){p3(t.key,n.head,`failed`,t.error||`The merge failed.`);return}if(p3(t.key,n.head,t.kind??`unconfirmed`,``),t.kind!==`merged`)return;let r=n3?.prs.find(e=>e.key===t.key);r&&w3([r])}var E3=sl.options.join(`|`),D3=String.raw`\*\*\[([^\]\n]+)\]\s+(${E3})\*\*`;function O3(e){return[...e.matchAll(new RegExp(D3,`g`))].flatMap(e=>{let t=sl.safeParse(e[2]);return t.success?[t.data]:[]})}function k3(e){let t=new RegExp(String.raw`^${D3}\s*(?:\r?\n|$)`).exec(e);if(!t)return null;let n=sl.safeParse(t[2]);return n.success?{reviewer:t[1]??``,severity:n.data,length:t[0].length}:null}function A3(e){let t=e.trimStart();return t.startsWith(`> [!NOTE]
|
|
243
|
-
> Automated review. Not written by a human.`)?t.slice(53).trim():e.trim()}var j3={"direct-request":`Needs you`,"team-request":`Ready`,"changes-requested":`Author to fix`,"checks-failing":`Checks failing`,"checks-pending":`Checks running`,draft:`Draft`,"review-available":`Ready`,approved:`Approved`};function M3(e){return e.isDraft?{band:`not-ready`,reason:`draft`}:e.reviewDecision===`CHANGES_REQUESTED`?{band:`waiting-on-author`,reason:`changes-requested`}:e.checksState===`FAILURE`||e.checksState===`ERROR`?{band:`waiting-on-author`,reason:`checks-failing`}:e.checksState===`PENDING`||e.checksState===`EXPECTED`?{band:`not-ready`,reason:`checks-pending`}:e.requestSource===`direct`&&e.reviewDecision===`REVIEW_REQUIRED`?{band:`blocking-others`,reason:`direct-request`}:e.reviewDecision===`APPROVED`?{band:`actionable`,reason:`approved`}:{band:`actionable`,reason:e.requestSource===`direct`?`review-available`:`team-request`}}var N3={APPROVE:{label:`You approved`,tone:`ok`},COMMENT:{label:`You commented`,tone:`muted`}},P3={APPROVED:{label:`You approved`,tone:`ok`},CHANGES_REQUESTED:{label:`You requested changes`,tone:`wait`},COMMENTED:{label:`You commented`,tone:`muted`}};function F3(e){let t=(e.githubReviews??[]).filter(e=>e.isViewer).sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).at(0);if(!e.postedEvent)return t?P3[t.state]:null;if(!t)return N3[e.postedEvent];let n=Date.parse(t.submittedAt??``);return Number.isNaN(n)||e.postedAt!==void 0&&e.postedAt>n?N3[e.postedEvent]:P3[t.state]}var I3=new Set([`changes-requested`,`checks-failing`,`checks-pending`,`draft`]);function L3(e){let{reason:t}=M3(e);return I3.has(t)?j3[t]:null}var R3={discarded:{tone:`muted`,meaning:`Discarded`},handReview:{tone:`warn`,meaning:`From a fork`}};function z3(e,t){let n=L3(t);return n?`${e}, ${n}`:e}function B3(e){if(pl(e))return!0;let t=(e.githubReviews??[]).filter(e=>e.isViewer);return t.length===0||t.some(t=>t.commit===h6(e))}var V3={tone:`warn`,meaning:`Comments resolved`};function H3(e,t){let n=R3[t];if(n)return n;if(t===`inReview`)return{tone:`wait`,meaning:z3(`In review`,e)};if(t===`queued`)return{tone:`muted`,meaning:z3(`Queued`,e)};if(t===`settled`&&`reviewedHead`in e){let t=B3(e)?F3(e):null;return t?{tone:t.tone,meaning:t.label}:{tone:`ok`,meaning:`Others reviewed`}}if(t===`posted`&&`reviewedHead`in e){let t=F3(e);return t?{tone:t.tone,meaning:t.label}:{tone:`muted`,meaning:`Posted`}}if(t===`attention`&&`status`in e)return e.status===`error`?{tone:`danger`,meaning:`Review failed`}:{tone:`warn`,meaning:`Out of date`};let r=L3(e);return r?{tone:`wait`,meaning:r}:t===`ready`&&`reviewedHead`in e&&G3(e)?V3:{tone:`warn`,meaning:`Waits on you`}}function U3(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function W3(e){return e.status===`posted`&&G3(e)}function G3(e){if(!U3(e)||pl(e))return!1;let t=h6(e);return!(e.githubReviews??[]).some(e=>e.isViewer&&e.state===`APPROVED`&&e.commit===t)}function K3(e){return!e||e.total===0?null:e.total===1?e.resolved===1?`Your 1 comment resolved`:`Your 1 comment unresolved`:e.resolved===e.total?`All ${e.total} of your comments resolved`:`${e.resolved} of ${e.total} of your comments resolved`}function q3(e){return`${e} ${e===1?`comment`:`comments`}`}function J3(e,t,n){let r=[`${K6(e.repo,e.number)}: ${e.title}`],i=`reviewedHead`in e?e.assessment?.goal.trim():``;if(i&&r.push(i),r.push(H3(e,t).meaning),n.opened&&r.push(`Opened ${n.opened}`),n.reviewed&&r.push(`Reviewed ${n.reviewed}`),n.posted&&r.push(`Posted ${n.posted}`),!(`reviewedHead`in e))return r.join(`
|
|
244
|
-
`);let a=K3(e.viewerThreads);a&&r.push(a);let o=e.comments.length;e.status!==`error`&&r.push(`Automated review: ${s6(e.verdict)}, ${q3(o)}`);let s=C6(e);s&&r.push(`You ${l6[s.state]} at ${s.approvedCommit.slice(0,7)}${n.viewerApproval?` ${n.viewerApproval}`:``}; new commits since.`),(t===`attention`||t===`discarded`)&&r.push(c8(e));let c=D6(e,{isViewerShown:t!==`posted`});for(let[e,t]of c.entries())r.push(E6(t.text,n.githubReviews?.[e]??null));return r.join(`
|
|
245
|
-
`)}function Y3(e){if(e.ready.length+e.attention.length+e.handReview.length>0)return null;let t=e.inReview.length+e.queued.length;return t===0?`Nothing needs you right now.`:`Nothing needs you right now. ${t} ${t===1?`review is`:`reviews are`} still running.`}function X3(e,t){if([...e.ready,...e.attention].filter(e=>e.key!==t).length>0)return{title:`New pull requests need you`,detail:`Pick one from the queue.`};let n=e.handReview.length;return n>0?{title:`Drafts all handled`,detail:`${n} ${n===1?`pull request needs`:`pull requests need`} review by hand.`}:{title:`All caught up`,detail:Y3({...e,ready:[],attention:[]})??``}}function Z3(e){let t=e.trim();return t.endsWith(`.`)?t:`${t}.`}function Q3({action:e,pullRequest:t,warning:n,isActedSelected:r}){let i=v8(e),a=`${t}: ${Z3(i)}`;return n.trim()?{statusText:i,shouldAdvance:!1,notice:{text:`${a} ${Z3(n)}`,tone:`error`}}:r?{statusText:i,shouldAdvance:!0,notice:{text:a,tone:`ok`}}:{statusText:i,shouldAdvance:!1,notice:null}}function $3(e){let t=[...e.ready,...e.noReviewNeeded,...e.inReview,...e.queued,...e.handReview,...e.attention,...e.posted,...e.discarded];return new Set(t.map(e=>e.repo)).size>1}function e6(e,t,n){return n?K6(e,t):`#${t}`}var t6={CRITICAL:{filledCount:3,colorToken:`--state-failed`},HIGH:{filledCount:3,colorToken:`--state-waiting`},MEDIUM:{filledCount:2,colorToken:`--accent`},LOW:{filledCount:1,colorToken:`--text-dim`}},n6={APPROVE:`check`,"APPROVE WITH NITS":`dot`,"REQUEST CHANGES":`bar`,BLOCKED:`cross`},r6=`lanes-team-review`,i6=`team-review-enabled`,a6=Object.freeze({APPROVE:`approve`,"APPROVE WITH NITS":`approve with nits`,"REQUEST CHANGES":`request changes`,BLOCKED:`blocked`}),o6={APPROVE:`Approve`,"APPROVE WITH NITS":`Nits`,"REQUEST CHANGES":`Changes`,BLOCKED:`Blocked`};function s6(e){return o6[e]}var c6=Object.freeze({APPROVE:`ok`,"APPROVE WITH NITS":`info`,"REQUEST CHANGES":`warn`,BLOCKED:`crit`});Object.freeze({stale:`stale`,error:`error`,discarded:`discarded`});var l6=Object.freeze({APPROVED:`approved`,CHANGES_REQUESTED:`requested changes`,COMMENTED:`commented`}),u6=Object.freeze({preparing:`fetching the diff`,checkout:`checking out the head`,reviewing:`agent reviewing`}),d6=Object.freeze({approve:`Approved on GitHub`,"approve-only":`Approved on GitHub`,comment:`Comment posted on GitHub`,discard:`Draft discarded`,requeue:`Queued. The next poll reviews it again.`,"resolve-thread":`Thread resolved on GitHub`}),f6=Object.freeze({approve:`Posting the approval`,"approve-only":`Posting the approval`,comment:`Posting the comment`,discard:`Discarding the draft`,requeue:`Queueing the review`,"resolve-thread":`Resolving thread`});function p6(e){let t={ready:[],noReviewNeeded:[],inReview:[],queued:[],handReview:[],attention:[],posted:[],discarded:[]};if(!e)return t;let n={"blocking-others":[],actionable:[],"waiting-on-author":[],"not-ready":[]},r={"blocking-others":[],actionable:[],"waiting-on-author":[],"not-ready":[]},i=[`blocking-others`,`actionable`,`waiting-on-author`,`not-ready`],a=new Set(e.inFlight.map(e=>e.key));t.inReview.push(...e.inFlight);let o=new Set(e.drafts.filter(e=>g6(e).length>0).map(e=>e.key));t.handReview.push(...e.handReview.filter(e=>!a.has(e.key)&&!o.has(e.key)));let s=new Set(t.handReview.map(e=>e.key));for(let t of e.queued)a.has(t.key)||s.has(t.key)||r[M3(t).band].push(t);for(let e of i)t.queued.push(...r[e]);let c=new Set(t.queued.map(e=>e.key));for(let r of e.drafts){if(a.has(r.key)||c.has(r.key)||s.has(r.key))continue;if(g6(r).length>0||W3(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!x6(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[M3(r).band].push(r),(r.status===`stale`||r.status===`error`)&&!e&&t.attention.push(r),r.status===`posted`&&t.posted.push(r),r.status===`discarded`&&t.discarded.push(r)}for(let e of i)t.ready.push(...n[e]);return t}function m6(e,t){return e.commit===t?e.isViewer||ll.has(e.state):!1}function h6(e){return e.liveHead??e.reviewedHead}function g6(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function _6(e,t){if(e.isNit)return{label:`Automatic resolution failed`,reason:``,tone:`warn`};let n=e.judgement?.head===t&&e.judgement.lastReplyAt===e.lastReplyAt?e.judgement:void 0;if(n)return{label:n.addressed?`Addressed`:`Not addressed`,reason:n.reason,tone:n.addressed?`ok`:`warn`};let r=e.unjudgeable?.head===t&&e.unjudgeable.lastReplyAt===e.lastReplyAt?e.unjudgeable:void 0;return r?{label:`Auto-check skipped`,reason:r.reason,tone:`muted`}:{label:`Auto-check pending`,reason:``,tone:`muted`}}function v6(e){return(e.threads??[]).filter(e=>!e.isResolved&&(!e.isNit||e.resolveError)).map(t=>{let n=_6(t,h6(e));return{thread:t,location:t.line===null?t.path:`${t.path}:${t.line}`,judgementLabel:n.label,judgementReason:n.reason,judgementTone:n.tone,judgementText:n.reason?`${n.label}: ${n.reason}`:n.label,canResolve:t.viewerCanResolve}})}var y6=40;function b6(e,t){return e.split(`
|
|
246
|
-
`).reduce((e,t)=>e+Math.max(1,Math.ceil(t.length/y6)),0)>t}function x6(e){return g6(e).length>0?!0:pl(e)?!1:G3(e)?!0:!(e.githubReviews??[]).some(t=>m6(t,h6(e)))}function S6(e,t){let n=l6[e.state];return e.isViewer?e.commit===t?`you ${n}`:`you ${n} (older commit)`:`${n} by ${e.login}`}function C6(e){if(pl(e))return null;let t=(e.githubReviews??[]).filter(e=>e.isViewer&&ll.has(e.state)).sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).at(0);if(!t?.commit||t.commit===h6(e)||t.state===`COMMENTED`)return null;let n=Date.parse(t.submittedAt??``);return e.reviewedAt!==void 0&&n>e.reviewedAt?null:{approvedCommit:t.commit,submittedAt:t.submittedAt,state:t.state,isReviewScopeSinceDecision:e.priorReviewedHead===t.commit}}function w6(e,t){let n=e.state===`APPROVED`?`approved this`:`requested changes`,r=e.state===`APPROVED`?`your approval`:`your request for changes`,i=`You ${n} at ${e.approvedCommit.slice(0,7)}${t?` ${t}`:``}. It has new commits since`;return e.isReviewScopeSinceDecision?`${i}, so this review covers what changed after ${r}.`:`${i}.`}function T6(e){return e===`APPROVED`?`ok`:e===`CHANGES_REQUESTED`?`warn`:`muted`}function E6(e,t){return t?`${e}, ${t}`:e}function D6(e,{isViewerShown:t=!0}={}){return(e.githubReviews??[]).filter(e=>t||!e.isViewer).sort((e,t)=>Number(t.isViewer)-Number(e.isViewer)).map(t=>({login:t.login,tone:T6(t.state),text:S6(t,h6(e)),submittedAt:t.submittedAt}))}function O6(e){return e.ready.length+e.noReviewNeeded.length+e.inReview.length+e.queued.length+e.handReview.length+e.attention.length+e.posted.length+e.discarded.length>0}function k6(e){return[...e.ready,...e.attention].map(e=>e.key)}function A6({capturedOrder:e,actedKey:t,groups:n}){let r=k6(n).filter(e=>e!==t),i=new Set(r);return e.slice(e.indexOf(t)+1).find(e=>i.has(e))||(e.find(e=>i.has(e))??r[0]??null)}function j6(e,t,n=!1){if(n&&t===null)return null;let r=[...e.ready,...e.inReview,...e.queued,...e.noReviewNeeded,...e.attention,...e.posted,...e.discarded];return t&&r.some(e=>e.key===t)?t:r[0]?.key??null}function M6(e){return t6[e]}function N6(e){return n6[e]}function P6(e){let t=O3(e.body);return t.length>0?t:e.severity?[e.severity]:[]}function F6(e){let t=P6(e);return sl.options.find(e=>t.includes(e))??null}function I6(e){return F6(e)!==`LOW`}var L6=new Set(`ts.tsx.js.jsx.mjs.cjs.json.jsonc.css.scss.less.html.md.mdx.py.go.rs.rb.java.kt.kts.swift.c.h.cc.cpp.hpp.cs.php.sh.bash.zsh.yml.yaml.toml.ini.sql.vue.svelte.astro.lock.txt.ex.exs.erl.scala.dart.lua.tf.proto.graphql.gql.xml.gradle`.split(`.`)),R6=/^([\w.@~/-]+):\d+(?:-\d+)?$/;function z6(e){let t=R6.exec(e)?.[1];if(t===void 0)return!1;let n=t.slice(t.lastIndexOf(`/`)+1),r=n.lastIndexOf(`.`);return r<0?!1:L6.has(n.slice(r+1).toLowerCase())}var B6=/^```([^\n`]*)\n([\s\S]*?)^```[ \t]*(?=\r?$)/gm;function V6(e){let t=[],n=0;for(let r of e.matchAll(/`([^`\n]+)`/g)){let i=r.index??0;i>n&&t.push({text:e.slice(n,i),kind:`text`});let a=r[1]??``;t.push({text:a,kind:z6(a)?`citation`:`code`}),n=i+r[0].length}return n<e.length&&t.push({text:e.slice(n),kind:`text`}),t}function H6(e){return e.split(/\r?\n\s*\r?\n/).filter(Boolean).map(e=>{let t=e.match(/^(Suggested fix:|Fix:|Open question[.,:])\s*/),n=t?.[1]??``;return{kind:`prose`,lead:n,leadKind:n.startsWith(`Open question`)?`question`:n?`fix`:null,segments:V6(e.slice(t?.[0].length??0))}})}function U6(e){let t=A3(e),n=k3(t),r=n?t.slice(n.length).trim():t,i=[],a=0;for(let e of r.matchAll(B6)){let t=e.index??0;i.push(...H6(r.slice(a,t).trim()));let n=(e[1]??``).trim().split(/\s+/)[0]||null;i.push({kind:`code`,language:n,code:(e[2]??``).replace(/\r?\n$/,``)}),a=t+e[0].length}return i.push(...H6(r.slice(a).trim())),{tag:n?.reviewer??null,severity:n?.severity??null,paragraphs:i}}function W6(e){let t=e.find(e=>e.kind===`prose`);if(!t)return`Open comment`;let n=`${t.lead} ${t.segments.map(e=>e.text).join(``)}`.trim(),r=n.search(/[.!?](?=\s|$)/);return(r<0?n:n.slice(0,r+1))||`Open comment`}function G6(e){let t=[`Fetch the diff`,`Check out the head`,`Review`,`Draft ready`],n={preparing:0,checkout:1,reviewing:2}[e];return t.map((e,t)=>({label:e,state:t<n?`done`:t===n?`active`:`todo`}))}function K6(e,t){return`${e}#${t}`}function q6(e){return e===`full`?`full`:`light`}function J6(e){return e.priorReviewedHead?`${q6(e.tier)} review of changes since ${e.priorReviewedHead.slice(0,7)}`:`${q6(e.tier)} review`}function Y6(e){return e.reasons.join(`, `)}function X6(e){if(!e)return[];let t=[],n=e.goal.trim(),r=e.change.trim();return n&&t.push({kind:`goal`,text:n}),r&&t.push({kind:`change`,text:r}),t}function Z6(e){if(!e)return`No coverage notes`;let t=e.checked.length,n=e.gaps.length,r=[];return t>0&&r.push(`${t} ${t===1?`check`:`checks`}`),n>0&&r.push(`${n} not covered`),r.join(`, `)||`No coverage notes`}function Q6(e){return e?{label:`Coverage`,preview:Z6(e)}:{label:`Review audit`,preview:``}}var $6=`This review ran before plain summaries existed, so only its verdict and findings remain. The audit log shows what it checked. Queue review to get a plain summary.`,e8=new Set([`error`,`stale`,`discarded`,`posted`]);function t8(e){return e8.has(e)}function n8(e){let t=r8(e);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function r8(e){return a6[e]??String(e).toLowerCase()}function i8(e){return c6[e]??`dim`}function a8(e){return u6[e]??e}function o8(e,t){return`${aD(t-e.startedAt)} elapsed`}function s8(e,t){let n=[o8(e,t)],r=e.deadlineAt===null?0:e.deadlineAt-t;return r>0&&n.push(`times out in ${aD(r)}`),e.phase===`reviewing`&&n.push(`${e.toolCalls} ${e.toolCalls===1?`tool call`:`tool calls`}`),n.join(`, `)}function c8(e){return e.status===`stale`?`Out of date. Automatic review runs at the next poll after the configured wait. Queue review bypasses the wait.`:e.status===`discarded`?`Not reviewed again until queued.`:e.error||e.summary||`The review failed.`}function l8(e,t){let n=t.side===`LEFT`?` (old)`:``;return`${e}:${t.line}${n}`}function u8(e){return l8(e.path,e)}function d8(e){return l8(e.path.split(`/`).filter(Boolean).at(-1)??e.path,e)}function f8(e,t){let n=e.trim();return n?t.trim()?`${n}\n\n${t}`:n:t}function p8(e,t,n,r,i){return t===`approve-only`?{key:e.key,head:e.reviewedHead,action:t,body:``,comments:[]}:{key:e.key,head:e.reviewedHead,action:t,body:n,...i?{threadId:i}:{},comments:r.map(({path:e,line:t,side:n,body:r})=>({path:e,line:t,side:n,body:r}))}}var m8=Object.freeze({approve:`Approve and comment`,"approve-only":`Approve`,comment:`Comment`,discard:`Discard`,requeue:`Queue review`,"resolve-thread":`Resolve`});function h8(e){return m8[e]}function g8(e){return e.status===`ready`?{footer:[`comment`,`approve-only`,`approve`],more:[`requeue`,`discard`]}:$ee(e)?{footer:[`approve-only`],more:[`requeue`]}:t8(e.status)?{footer:[`requeue`],more:[]}:{footer:[],more:[]}}function _8(e){return f6[e]}function v8(e){return d6[e]}function y8(e){return e===0?`Picked for review. It starts on the next poll.`:`Waiting for a free review slot. It starts as soon as ${e===1?`the review`:`one of the ${e} reviews`} in progress finishes.`}function b8(e){return e?e.configured?e.error?`Review drafts will show here once GitHub answers.`:`No review drafts yet. New teammate pull requests show up here after the next poll.`:e.reason?`Team review is not running: ${e.reason}.`:`Team review is off.`:`Waiting for the team review lane.`}function x8(e){return e?.configured&&e.reason||null}function S8(e){return IE(p6(e).ready.map(e=>`${e.key}@${e.reviewedHead}`))}function C8(e){return`${e.key}@${e.reviewedHead}:${e.status}:${e.summary}:${D6(e).map(e=>e.text).join(`, `)}`}function w8(e){return`reviewedHead`in e?JSON.stringify([e.prCreatedAt,e.reviewedAt,e.postedAt,e.githubReviews,e.liveHead,e.priorReviewedHead,e.viewerThreads]):JSON.stringify([e.prCreatedAt,e.priorReviewedHead])}function T8(e,t){return!e||e.error!==t.error||e.nextAttemptAt!==t.nextAttemptAt||JSON.stringify(e.retry)!==JSON.stringify(t.retry)||e.isRefreshing!==t.isRefreshing||e.refreshNotice!==t.refreshNotice||JSON.stringify(e.team)!==JSON.stringify(t.team)||e.configured!==t.configured||e.reason!==t.reason||e.inFlight.map(e=>e.key).join(`
|
|
247
|
-
`)!==t.inFlight.map(e=>e.key).join(`
|
|
248
|
-
`)||JSON.stringify(e.handReview)!==JSON.stringify(t.handReview)||JSON.stringify(e.queued)!==JSON.stringify(t.queued)?!1:JSON.stringify(e.drafts)===JSON.stringify(t.drafts)}var E8=12e4,D8=`M4.5 0.5L8.5 5.5L4.5 10.5L0.5 5.5Z`,O8=null,k8=null,A8=null,j8=null,M8=null,N8=null,P8=null,F8=null,I8=null,L8=null,R8=null,z8=null,B8=null,V8=null,H8=SN(()=>k8),U8=SN(()=>k8),W8=SN(()=>k8),G8=new WeakMap,K8=new Map,q8=new Map,J8=new Map,Y8=RE({getAck:TF,setAck:EF,signature:()=>S8(O8),isLooking:()=>!kd(k8)});function X8(e){let t=M6(e),n=V(`span`,`pr-severity-meter`);if(n.setAttribute(`role`,`img`),n.setAttribute(`aria-label`,`${e.toLowerCase()} severity`),n.style.color=`var(${t.colorToken})`,e===`CRITICAL`){let e=JL(14,17);e.classList.add(`pr-severity-halo`),e.setAttribute(`viewBox`,`0 0 9 11`),e.append(qL(`path`,{d:D8,fill:`currentColor`})),n.append(e)}for(let e=0;e<3;e+=1){let r=JL(9,11),i=e<t.filledCount;r.append(qL(`path`,{d:D8,fill:i?`currentColor`:`none`,stroke:i?`currentColor`:`var(--border-hover)`,"stroke-width":`1`})),n.append(r)}return n}function Z8(e){let{verdict:t}=e,n=V(`span`,`pr-verdict-seal`);n.dataset.tone=i8(t);let r=JL(20,20),i=N6(t);return r.append(qL(`circle`,{cx:`10`,cy:`10`,r:`8.5`,fill:i===`cross`?`currentColor`:`none`,stroke:`currentColor`,"stroke-width":`1.5`})),i===`check`&&r.append(qL(`path`,{d:`M6 10.5L8.7 13L14 7.5`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`})),i===`dot`&&r.append(qL(`circle`,{cx:`10`,cy:`10`,r:`2.4`,fill:`currentColor`})),i===`bar`&&r.append(qL(`path`,{d:`M6 10H14`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`})),i===`cross`&&r.append(qL(`path`,{d:`M7 7L13 13M13 7L7 13`,stroke:`var(--bg)`,"stroke-width":`1.8`,"stroke-linecap":`round`})),n.append(r,V(`span`,null,n8(t))),n}function Q8(){let e=JL(16,16);return e.append(qL(`rect`,{x:`1`,y:`1`,width:`14`,height:`14`,rx:`2`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`})),e.append(qL(`path`,{d:`M6 6.2C6 4.9 7 4.2 8 4.2C9.1 4.2 10 5 10 6C10 7.4 8 7.4 8 9.2`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`,"stroke-linecap":`round`})),e.append(qL(`circle`,{cx:`8`,cy:`11.6`,r:`0.9`,fill:`currentColor`})),e}function $8(e){return xd(`pr-link`,K6(e.repo,e.number),e.url)}function e5(e){let t=typeof e==`string`?Date.parse(e):e;return typeof t!=`number`||!Number.isFinite(t)||t<=0?null:t}function t5(e,t){let n=e5(t);if(n===null)return null;let r=V(`span`,null,`${e}${e?` `:``}${bN(n)}`);return r.dataset.ageAt=String(n),r.dataset.ageLabel=e,r}function n5(e){if(e){for(let t of e.querySelectorAll(`.pr-queue-row`)){let e=G8.get(t);if(!e)continue;let n=()=>{t.title=e(),t.setAttribute(`aria-label`,t.title)};n(),W8.onTick(n)}for(let t of e.querySelectorAll(`.pr-rereview-notice`)){let e=O8?.drafts.find(e=>e.key===t.dataset.reviewKey),n=e?C6(e):null;if(!n)continue;let r=()=>{t.textContent=w6(n,i5(n.submittedAt))};r(),W8.onTick(r)}for(let t of e.querySelectorAll(`[data-age-at]`)){let e=Number(t.dataset.ageAt),n=t.dataset.reviewTitle;if(n!==void 0){let r=()=>{let r=E6(n,bN(e));t.title=r,t.setAttribute(`aria-label`,r)};r(),W8.onTick(r);continue}let r=t.dataset.ageLabel??``;W8.track(t,e,()=>`${r}${r?` `:``}${bN(e)}`)}}}function r5(e,t,n,r=!0){let i=D6(e,{isViewerShown:r});if(i.length===0)return null;let a=V(`span`,t),o=yd(i.map(e=>({login:e.login,tone:e.tone,title:E6(e.text,i5(e.submittedAt))})),n);for(let[e,t]of i.entries()){let n=o.children[e];if(!(n instanceof HTMLElement)||!t.submittedAt)continue;let r=e5(t.submittedAt);r!==null&&(n.dataset.ageAt=String(r),n.dataset.reviewTitle=t.text)}return a.append(o),a}function i5(e){let t=e5(e);return t===null?null:bN(t)}function a5(e,t,n){let r=V(`span`,n);return r.append(vd({login:e,cssPx:t}),V(`span`,null,e)),r}function hre(e,t,n){let r=V(`button`,`pr-queue-row pr-queue-row-quiet`);r.type=`button`,r.dataset.reviewKey=e.key,r.setAttribute(`aria-current`,String(e.key===I8));let i=`reviewedHead`in e?C6(e):null,a=()=>J3(e,t,{opened:i5(e.prCreatedAt),reviewed:`reviewedHead`in e?i5(e.reviewedAt):null,posted:`reviewedHead`in e?i5(e.postedAt):null,viewerApproval:i5(i?.submittedAt),githubReviews:`reviewedHead`in e?D6(e,{isViewerShown:t!==`posted`}).map(e=>i5(e.submittedAt)):[]});r.title=a(),r.setAttribute(`aria-label`,r.title),G8.set(r,a);let o=c5(e,n);if(t===`inReview`){let t=e,n=V(`span`,`pr-queue-elapsed`);H8.track(n,t.startedAt,()=>o8(t,Date.now())),o.append(n)}if(t===`queued`){let t=t5(``,e.prCreatedAt);t&&(t.classList.add(`pr-queue-elapsed`),o.append(t))}if(t!==`inReview`&&t!==`queued`){let t=e,n=t5(``,t.reviewedAt)??t5(``,t.prCreatedAt);n&&(n.classList.add(`pr-queue-elapsed`),o.append(n))}if(t===`discarded`)return r.classList.add(`pr-queue-row-compact`),r.append(o),o5(r,e.key),r;r.classList.remove(`pr-queue-row-quiet`);let s=H3(e,t),c=V(`span`,`pr-queue-glyph`);c.append(YL(s.tone));let l=V(`span`,`pr-queue-bottom`);if(l.append(s5(s),a5(e.author,16,`pr-queue-author`)),e.requestSource===`direct`){let e=V(`span`,`pr-queue-direct`,`@`);e.title=`Requested from you directly`,l.append(e)}t===`inReview`&&l.append(V(`span`,`pr-phase-label`,a8(e.phase))),r.append(c,o,l);let u=t===`inReview`||t===`queued`?null:r5(e,`pr-queue-reviewers`,16,t!==`posted`);return u&&l.append(u),o5(r,e.key),r}function o5(e,t){e.addEventListener(`click`,()=>{I8=t,L8=null,u5(null);for(let e of M8?.querySelectorAll(`button[data-review-key]`)??[])e.setAttribute(`aria-current`,String(e.dataset.reviewKey===I8));N5(p6(O8)),W8.reset(),n5(k8),document.documentElement.dataset.layout===`phone`&&P8?.scrollIntoView({block:`start`,behavior:`smooth`})})}function s5(e){let t=V(`span`,`my-pr-stage pr-queue-state`,e.meaning);return t.dataset.tone=e.tone,t}function c5(e,t){let n=V(`span`,`pr-queue-top`);return n.append(V(`strong`,`pr-queue-ref`,e6(e.repo,e.number,t)),V(`strong`,`pr-queue-ref-compact`,e6(e.repo,e.number,!1)),V(`span`,`pr-queue-title`,e.title)),n}function gre(e,t){let n=V(`section`,`pr-queue-section`);n.append(V(`h3`,`pr-section-heading`,`Review by hand ${e.length}`));for(let r of e){let e=xd(`pr-queue-row`,``,r.url),i=()=>J3(r,`handReview`,{opened:i5(r.prCreatedAt)});e.title=i(),G8.set(e,i);let a=H3(r,`handReview`),o=V(`span`,`pr-queue-glyph`);o.append(YL(a.tone));let s=V(`span`,`pr-queue-bottom`);s.append(s5(a),a5(r.author,16,`pr-queue-author`)),e.append(o,c5(r,t),s),n.append(e)}return n}function l5({title:e,detail:t}){let n=V(`section`,`pr-caught-up`);n.setAttribute(`role`,`status`);let r=V(`strong`,`pr-caught-up-title`);return r.append(YL(`ok`),V(`span`,null,e)),n.append(r,V(`p`,`pr-caught-up-detail`,t)),n}function u5(e){R8=e,z8&&(z8.hidden=e===null,z8.textContent=e?.text??``,e&&(z8.dataset.tone=e.tone))}function d5(e,t,n,r){let i=V(`section`,`pr-queue-section`);i.append(V(`h3`,`pr-section-heading`,`${e} ${t.length}`));for(let e of t)i.append(hre(e,n,r));return i}function f5(e){let t=V(`div`,`pr-detail-heading`);t.dataset.signature=w8(e);let n=V(`div`,`pr-detail-title`);n.append($8(e),V(`h2`,null,e.title));let r=V(`div`,`pr-detail-meta`);r.append(a5(e.author,20,`pr-detail-author`));let i=V(`span`,null,J6(e));i.title=Y6(e),r.append(i);let a=t5(`Opened`,e.prCreatedAt);if(a&&r.append(a),`reviewedHead`in e){let t=t5(`Reviewed`,e.reviewedAt);t&&r.append(t);let n=t5(`Posted`,e.postedAt);n&&r.append(n)}let o=`reviewedHead`in e?r5(e,`pr-detail-github`,20):null;if(o&&r.append(o),t.append(n,r),`reviewedHead`in e){let n=K3(e.viewerThreads);if(n){let r=V(`p`,`pr-viewer-threads`,n);U3(e)&&(r.dataset.state=`all-resolved`),t.append(r)}}let s=`reviewedHead`in e?C6(e):null;if(s){let n=V(`p`,`pr-rereview-notice`,w6(s,i5(s.submittedAt)));n.dataset.reviewKey=e.key,t.append(n)}return t}function p5(e,t){let n=e.querySelector(`:scope > .pr-detail-heading`);if(!n||n.dataset.signature===w8(t))return e;let r=f5(t),i=n.querySelector(`:scope > .pr-detail-title > .pr-detail-more`);return i&&r.querySelector(`:scope > .pr-detail-title`)?.append(i),n.replaceWith(r),e}function m5(e){return`${JSON.stringify(e.threads)}:${e.liveHead}:${e.status}:${e.reviewedHead}:${e.error??``}:${e.postedEvent??``}`}function h5(e,t){for(let n of t){if(n.kind===`text`){e.append(document.createTextNode(n.text));continue}if(n.kind===`code`){e.append(V(`code`,null,n.text));continue}let t=V(`span`,`pr-citation`,n.text);t.title=n.text,e.append(t)}return e}function g5(e,t){return h5(e,V6(t))}function _5(e,t,n){let r=V(`div`,`pr-assessment-part`);return n&&(r.dataset.tone=n),r.append(V(`h4`,`pr-assessment-title`,e),t),r}function v5(e){let t=V(`ul`,`pr-assessment-list`);for(let n of e)t.append(g5(V(`li`,null),n));return t}function y5(e){let t=X6(e.assessment);if(t.length===0)return[];let n=V(`section`,`pr-about-box`);n.setAttribute(`aria-label`,`About this PR`),n.append(V(`h3`,`pr-assessment-title`,`About this PR`));for(let e of t){let t=e.kind===`goal`?`pr-verdict-summary pr-about-goal`:`pr-verdict-summary`;n.append(g5(V(`p`,t),e.text))}return[n]}function b5(e){let t=V(`section`,`pr-verdict-box`);t.setAttribute(`aria-label`,`Verdict`);let n=V(`div`,`pr-verdict-line`);return n.append(Z8(e)),t.append(n),e.assessment?(t.append(g5(V(`p`,`pr-verdict-summary pr-verdict-reason`),e.summary)),t):(t.append(V(`p`,`pr-verdict-legacy`,$6)),t)}function x5(e){let t=V(`details`,`pr-disclosure pr-coverage`),n=V(`summary`,`pr-disclosure-summary`),r=Q6(e.assessment);n.append(V(`span`,`pr-disclosure-label`,r.label),V(`span`,`pr-disclosure-preview`,r.preview)),t.append(n);let{assessment:i}=e;return i?(i.checked.length>0&&t.append(_5(`What the review checked`,v5(i.checked))),i.gaps.length>0&&t.append(_5(`Not covered`,v5(i.gaps),`warning`)),t):(t.append(g5(V(`p`,`pr-verdict-summary`),e.summary)),t)}function _re(e){if(e.kind===`code`){let t=V(`pre`,`pr-comment-code`),n=V(`code`,null);return n.textContent=e.code,t.append(n),t}let t=V(`p`,`pr-comment-paragraph`);if(e.lead){let n=V(`strong`,`pr-comment-lead pr-comment-lead-${e.leadKind}`);e.leadKind===`question`&&n.append(Q8()),n.append(e.lead),t.append(n,` `)}return h5(t,e.segments)}function vre(e,t,n,r){let i=V(`article`,`pr-comment-card`),a=V(`input`,`pr-comment-checkbox`);a.type=`checkbox`,a.checked=n.has(t),a.setAttribute(`aria-label`,`Include comment on ${u8(e)}`),a.addEventListener(`change`,()=>{a.checked&&n.add(t),a.checked||n.delete(t),i.dataset.included=String(a.checked),r()}),i.dataset.included=String(a.checked);let o=V(`details`,`pr-comment-content`),s=V(`summary`,`pr-comment-header`),c=U6(e.body),l=F6(e);l&&s.append(X8(l));let u=V(`span`,`pr-comment-location`,d8(e));u.title=u8(e),s.append(u),s.append(V(`span`,`pr-comment-preview`,W6(c.paragraphs))),o.append(s);let d=V(`div`,`pr-comment-paragraphs`);for(let e of c.paragraphs)d.append(_re(e));return o.append(d),o.open=l===`HIGH`||l===`CRITICAL`,i.append(a,o),i}var S5=`More review actions`,yre=`M3 8h0.01M8 8h0.01M13 8h0.01`,bre=`Your comments are on GitHub. Approve adds an approval without posting them again.`;function C5(e,t,n,r,i,a,o){let s=k6(p6(O8));u5(null);let c=`team-review-action-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;if(!B({type:`team-review-action`,requestId:c,...p8(t,n,r,i,o)}))return!1;let l=window.setTimeout(()=>{J8.delete(t.key),a(!1,`No reply from the server. Check GitHub before trying again.`)},E8);return J8.set(t.key,{requestId:c,action:n,origin:e,capturedOrder:s,pullRequest:K6(t.repo,t.number),timer:l,settle:a}),!0}var w5=0;function T5(e,t){let n=V(`div`,`pr-detail-more`),r=V(`button`,`review-icon-button review-more-button`);r.type=`button`,r.title=S5,r.setAttribute(`aria-label`,S5),r.setAttribute(`aria-haspopup`,`menu`),r.setAttribute(`aria-expanded`,`false`);let i=JL(16,16);i.append(qL(`path`,{d:yre,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})),r.append(i),w5+=1;let a=V(`div`,`review-more-menu`);a.id=`pr-more-menu-${w5}`,a.setAttribute(`role`,`menu`),a.setAttribute(`aria-label`,S5),a.hidden=!0,r.setAttribute(`aria-controls`,a.id);let o=e=>{e.key===`Escape`&&(e.preventDefault(),c(),r.focus())},s=e=>{e.target instanceof Node&&n.contains(e.target)||c()};function c(){a.hidden=!0,r.setAttribute(`aria-expanded`,`false`),document.removeEventListener(`keydown`,o),document.removeEventListener(`pointerdown`,s)}let l=()=>{a.hidden=!1,r.setAttribute(`aria-expanded`,`true`),document.addEventListener(`keydown`,o),document.addEventListener(`pointerdown`,s),a.querySelector(`button:not(:disabled)`)?.focus()};r.addEventListener(`click`,()=>{if(a.hidden){l();return}c()});let u=[r];for(let n of e){let e=V(`button`,n===`discard`?`review-btn review-btn-danger`:`review-btn`,h8(n));e.type=`button`,e.dataset.action=n,e.setAttribute(`role`,`menuitem`),e.addEventListener(`click`,()=>{c(),t(n)}),u.push(e),a.append(e)}return n.append(r,a),{element:n,controls:u}}function E5(e,t){let n=V(`button`,`pr-action`,h8(e));return n.type=`button`,n.dataset.action=e,n.addEventListener(`click`,()=>t(e)),n}function D5(e,t){e.querySelector(`:scope > .pr-detail-heading > .pr-detail-title`)?.append(t)}function xre(e){let t=V(`article`,`pr-detail`),n=V(`div`);n.dataset.reviewThreads=``,t.append(f5(e),...y5(e),n,b5(e)),O5(t,e);let r=V(`section`,`pr-posts`);r.setAttribute(`aria-label`,`Inline comments`);let i=V(`div`,`pr-posts-heading`);i.append(V(`h3`,null,`Inline comments`),V(`span`,null,String(e.comments.length))),r.append(i);let a=V(`details`,`pr-disclosure`),o=V(`summary`,`pr-disclosure-summary`),s=V(`span`,`pr-disclosure-preview`);o.append(V(`span`,`pr-disclosure-label`,`Review body`),s),a.append(o);let c=V(`textarea`,`pr-body-input`);c.setAttribute(`aria-label`,`Review body`),c.value=e.body,c.rows=Math.min(10,Math.max(3,e.body.split(`
|
|
249
|
-
`).length+1)),c.spellcheck=!0;let l=()=>{s.textContent=A3(c.value).split(/\r?\n/).map(e=>e.trim()).find(Boolean)||`No review body`};c.addEventListener(`input`,l),l(),a.append(c);let u=V(`details`,`pr-disclosure`);u.append(V(`summary`,`pr-disclosure-summary`,`Add a note`));let d=V(`textarea`,`pr-body-input pr-note-input`);d.setAttribute(`aria-label`,`Your note`),d.rows=2,d.spellcheck=!0,d.placeholder=`Posts above the automated-review note`,u.append(d);let f=new Set(e.comments.flatMap((e,t)=>I6(e)?[t]:[])),p=V(`footer`,`pr-footer`),m=V(`span`,`pr-action-status`);m.setAttribute(`role`,`status`),m.setAttribute(`aria-live`,`polite`);let h=()=>{J8.has(e.key)||m.dataset.tone===`ok`||(m.textContent=``,delete m.dataset.tone)};for(let[t,n]of e.comments.entries())r.append(vre(n,t,f,h));t.append(r,a,u,x5(e));let g=[],_=e=>{for(let t of g)t.disabled=e;t.dataset.busy=String(e)},v=(e,t)=>{_(e),m.dataset.tone=e?`ok`:`error`,m.textContent=t},y=t=>{if(J8.has(e.key))return;_(!0),m.dataset.tone=`busy`,m.textContent=_8(t);let n=e.comments.filter((e,t)=>f.has(t));C5(`ready`,e,t,f8(d.value,c.value),n,v)||v(!1,`Not connected to the server.`)},b=g8(e),x=b.footer.map(e=>E5(e,y)),ee=T5(b.more,y);return g.push(...x,...ee.controls),D5(t,ee.element),p.append(...x,m),t.append(p),{signature:C8(e),element:t,settle:v}}function Sre(e){let t=K8.get(e.key);if(t&&(J8.has(e.key)||t.signature===C8(e)))return O5(t.element,e),p5(t.element,e);let n=xre(e);return K8.set(e.key,n),n.element}function Cre(e,t){let n=V(`article`,`pr-detail`),r=V(`div`,`pr-detail-heading`),i=V(`div`,`pr-detail-title`);i.append($8(e),V(`h2`,null,e.title));let a=V(`div`,`pr-detail-meta`);a.append(a5(e.author,20,`pr-detail-author`));let o=t5(`Opened`,e.prCreatedAt);return o&&a.append(o),r.append(i,a),n.append(r,V(`p`,`pr-attention-detail`,y8(t))),n}function wre(e){let t=V(`article`,`pr-detail`);t.append(f5(e));let n=V(`section`,`pr-progress`);n.setAttribute(`aria-label`,`Review progress`);let r=V(`ol`,`pr-progress-tracker`);for(let t of G6(e.phase)){let e=V(`li`,`pr-progress-stage`);e.dataset.state=t.state,e.append(V(`span`,`pr-progress-bar`),V(`span`,null,t.label)),r.append(e)}let i=V(`div`,`pr-progress-text`);U8.track(i,e.startedAt,()=>s8(e,Date.now())),n.append(r,i),t.append(n);let a=V(`section`,`pr-steps`);a.append(V(`h3`,null,`Latest agent steps`));let o=V(`ol`,`pr-step-list`);for(let t of e.recentSteps){let n=V(`li`,`pr-step`),r=V(`span`,`pr-step-detail`,t.detail);r.title=t.detail,n.append(V(`span`,`pr-step-at`,oD(e.startedAt,t.at)),V(`span`,`pr-step-tool`,t.tool),r),o.append(n)}return a.append(o),t.append(a),t}function O5(e,t){if(J8.has(t.key))return;let n=e.querySelector(`:scope > [data-review-threads]`),r=JSON.stringify([t.liveHead,t.threads]);n&&n.dataset.reviewThreads!==r&&(n.replaceChildren(...A5(t)),n.dataset.reviewThreads=r)}function k5(e,t,n,r){let i=V(`div`,t?`pr-thread-message pr-thread-message-muted`:`pr-thread-message`);if(i.append(V(`p`,`pr-thread-body pr-thread-preview`,e)),!n&&!b6(e,t?3:8))return i;let a=V(`details`,`pr-thread-disclosure`);return a.append(V(`summary`,`pr-thread-expand`,t?`Expand comment`:`Expand reply`),V(`p`,`pr-thread-body`,e)),n&&a.append(xd(`pr-link pr-thread-continues`,t?`Comment continues on GitHub`:`Reply continues on GitHub`,r)),i.append(a),i}function A5(e){let t=v6(e);if(t.length===0)return[];let n=V(`section`,`my-pr-threads-section`);n.append(V(`h3`,`pr-section-heading`,`Answered threads`));let r=V(`div`,`my-pr-threads`);for(let n of t){let t=V(`div`,`my-pr-thread pr-thread-card`),i=V(`div`,`my-pr-thread-heading pr-thread-heading`),a=V(`span`,`pr-thread-chip`,n.judgementLabel);a.dataset.tone=n.judgementTone,i.append(xd(`pr-link my-pr-thread-location`,n.location,n.thread.url),a),t.append(i),n.judgementReason&&t.append(V(`p`,`my-pr-thread-meta`,n.judgementReason)),n.thread.viewerComment&&t.append(V(`div`,`my-pr-thread-meta`,`Your comment`),k5(n.thread.viewerComment,!0,n.thread.viewerCommentTruncated===!0,n.thread.url));let o=V(`div`,`pr-detail-meta pr-thread-reply-meta`,`${n.thread.lastReplyAuthor} replied`),s=t5(``,n.thread.lastReplyAt);s&&o.append(s);let c=V(`span`,`pr-action-status`);c.setAttribute(`role`,`status`);let l=V(`button`,`pr-action`,`Resolve`);l.type=`button`,l.disabled=!n.canResolve||J8.has(e.key);let u=(e,t)=>{l.disabled=e||!n.canResolve,c.textContent=t,c.dataset.tone=e?`ok`:`error`};l.addEventListener(`click`,()=>{J8.has(e.key)||(l.disabled=!0,c.textContent=_8(`resolve-thread`),!C5(`other`,e,`resolve-thread`,``,[],u,n.thread.id)&&u(!1,`Not connected to the server.`))}),t.append(o),n.thread.lastReplyBody&&t.append(k5(n.thread.lastReplyBody,!1,n.thread.lastReplyTruncated===!0,n.thread.url));let d=V(`footer`,`pr-thread-footer`);d.append(c,l),t.append(d),n.thread.resolveError&&t.append(V(`p`,`pr-attention-detail`,n.thread.resolveError)),r.append(t)}return n.append(r),[n]}function j5(e){let t=V(`article`,`pr-detail`);if(t.append(f5(e),...y5(e),...A5(e)),e.status===`posted`&&t.append(b5(e),x5(e)),e.status!==`posted`&&t.append(V(`p`,`pr-attention-detail`,c8(e))),!t8(e.status))return q8.set(e.key,{signature:m5(e),element:t,settle:()=>{}}),t;let n=V(`footer`,`pr-footer`),r=g8(e),i=V(`span`,`pr-action-status`,r.footer.includes(`approve-only`)?bre:``);i.setAttribute(`role`,`status`),i.setAttribute(`aria-live`,`polite`);let a=[],o=(e,t)=>{for(let t of a)t.disabled=e;i.dataset.tone=e?`ok`:`error`,i.textContent=t},s=t=>{if(!J8.has(e.key)){for(let e of a)e.disabled=!0;i.dataset.tone=`busy`,i.textContent=_8(t),!C5(`other`,e,t,``,[],o)&&o(!1,`Not connected to the server.`)}},c=r.footer.map(e=>E5(e,s));if(a.push(...c),r.more.length>0){let e=T5(r.more,s);a.push(...e.controls),D5(t,e.element)}return n.append(...c,i),t.append(n),q8.set(e.key,{signature:m5(e),element:t,settle:o}),t}function M5(e){if(!t8(e.status)&&v6(e).length===0)return j5(e);let t=q8.get(e.key);return t&&(J8.has(e.key)||t.signature===m5(e))?p5(t.element,e):j5(e)}function N5(e){if(!P8)return;if(I8=j6(e,I8,L8!==null),!I8){if(L8!==null){let t=L8.actedKey;t&&![...e.ready,...e.attention].some(e=>e.key===t)&&(L8={actedKey:null}),P8.replaceChildren(l5(X3(e,L8.actedKey))),B8=null;return}P8.replaceChildren(),B8=null;return}let t=e.ready.find(e=>e.key===I8&&(g6(e).length>0||W3(e)));if(t&&t.status!==`ready`){let e=`threads:${m5(t)}`,n=M5(t);if(B8===e&&P8.firstElementChild===n)return;P8.replaceChildren(n),B8=e;return}let n=[...e.ready,...e.noReviewNeeded].find(e=>e.key===I8&&e.status===`ready`);if(n){let e=`ready:${C8(n)}`,t=Sre(n);if(B8===e)return;P8.replaceChildren(t),B8=e;return}let r=e.inReview.find(e=>e.key===I8);if(r){U8.reset(),P8.replaceChildren(wre(r)),B8=`inReview:${r.key}`;return}let i=e.queued.find(e=>e.key===I8);if(i){let t=`queued:${i.key}:${e.inReview.length}`;if(B8===t)return;P8.replaceChildren(Cre(i,e.inReview.length)),B8=t;return}let a=[...e.noReviewNeeded,...e.attention,...e.posted,...e.discarded].find(e=>e.key===I8);a&&(P8.replaceChildren(M5(a)),B8=`${a.status}:${a.key}`)}function Tre(){let e=V(`p`,`pr-empty`,b8(O8));return O8&&!O8.configured&&e.append(` `,mW(r6,i6,`Open Team review settings`)),e}function P5(){let e=x8(O8);return e?[V(`p`,`my-pr-note`,e)]:[]}function Ere(e){for(let t of[...K8.keys()])e.has(t)||J8.has(t)||K8.delete(t);let t=new Set(O8?.drafts.filter(e=>t8(e.status)).map(e=>e.key)??[]);for(let e of q8.keys())t.has(e)||J8.has(e)||q8.delete(e)}function Dre(){if(!k8||!A8||M8?.isConnected)return;let e=q2({queueLabel:`Review queue`,scopeTabs:A8,resizerLabel:`Resize review queue`});M8=e.queue,z8=V(`p`,`pr-action-status pr-action-notice`),z8.setAttribute(`role`,`status`),z8.setAttribute(`aria-live`,`polite`),P8=V(`div`,`pr-detail-body`),e.detail.append(z8,P8),u5(R8),k8.replaceChildren(e.columns),B8=null,N8=null}function F5(e){if(!e)return;j8&&(e.insertBefore(j8.control,e.querySelector(`.pr-queue-toggle`)),j8.update(O8)),e.querySelector(`.pr-team-chip`)?.remove();let t=O8?.team;if(!t)return;let n=V(`span`,`pr-team-chip`);n.append(vd({login:t.slug,url:t.avatarUrl,cssPx:16}),V(`span`,null,t.name)),e.insertBefore(n,e.querySelector(`.pr-queue-toggle`))}function I5(){let e=document.activeElement;return!(e instanceof HTMLElement)||!M8?.contains(e)?null:e.dataset.reviewKey??null}function L5(e){e&&M8&&[...M8.querySelectorAll(`button[data-review-key]`)].find(t=>t.dataset.reviewKey===e)?.focus({preventScroll:!0})}function R5(){if(!k8)return;let e=I5(),t=p6(O8);if(Ere(new Set([...t.ready,...t.noReviewNeeded].map(e=>e.key))),W8.reset(),!O8?.configured||!O6(t)&&L8===null){H8.reset(),U8.reset();let e=K2(A8);F5(e),k8.replaceChildren(e,...j8?[j8.notice]:[],...P5(),Tre()),j8?.update(O8),M8=null,N8=null,P8=null,z8=null,F8=null,B8=null;return}if(Dre(),!M8)return;F5(k8.querySelector(`.pr-queue-head`)),I8=j6(t,I8,L8!==null);let n=$3(t),r=JSON.stringify([t,n,I8,x8(O8)]);if(r===N8){j8?.update(O8),N5(t),n5(k8);return}N8=r,H8.reset();let i=[],a=Y3(t);a&&i.push(l5({title:`All caught up`,detail:a})),t.ready.length&&i.push(d5(`Ready`,t.ready,`ready`,n)),t.inReview.length&&(F8=d5(`In review`,t.inReview,`inReview`,n),i.push(F8)),t.queued.length&&i.push(d5(`Queued`,t.queued,`queued`,n)),t.noReviewNeeded.length&&i.push(d5(`Already reviewed`,t.noReviewNeeded,`settled`,n)),t.handReview.length&&i.push(gre(t.handReview,n)),t.attention.length&&i.push(d5(`Needs attention`,t.attention,`attention`,n)),t.posted.length&&i.push(d5(`Waiting on author`,t.posted,`posted`,n)),t.discarded.length&&i.push(d5(`Discarded`,t.discarded,`discarded`,n)),M8.replaceChildren(...j8?[j8.notice]:[],...P5(),...i),j8?.update(O8),L5(e),N5(t),n5(k8)}function z5(){V8&&V8(Y8.refresh())}function Ore(){Y8.acknowledge(),z5()}function kre(e){V8=e,z5()}function Are(e,t){return k8||(A8=t,k8=V(`div`,`pr-content`),e.append(k8),j8=f3(`team-review`,k8),H8.ensure(),U8.ensure(),W8.ensure(),R5(),k8)}function jre(e){let t=bl.safeParse(e);if(!t.success)return;let n=O8;O8=t.data,!(T8(n,t.data)&&Mre())&&(R5(),z5())}function Mre(){if(!O8||!F8?.isConnected)return!1;H8.reset(),W8.reset();let e=I5(),t=p6(O8),n=d5(`In review`,t.inReview,`inReview`,$3(t));return F8.replaceWith(n),F8=n,L5(e),t.inReview.some(e=>e.key===I8)&&N5(t),n5(k8),!0}function Nre(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.key!=`string`)return;let n=J8.get(t.key);if(!n||n.requestId!==t.requestId)return;if(window.clearTimeout(n.timer),J8.delete(t.key),n.action===`resolve-thread`){n.settle?.(t.ok===!0,typeof t.error==`string`?t.error:v8(n.action)),q8.delete(t.key),B8=null,t.ok===!0&&R5();return}let r=(n.origin===`ready`?K8:q8).get(t.key);if(t.ok===!0){n.origin===`other`&&q8.delete(t.key);let e=Q3({action:n.action,pullRequest:n.pullRequest,warning:typeof t.warning==`string`?t.warning:``,isActedSelected:I8===t.key});if((r?.settle??n.settle)?.(!0,e.statusText),e.notice&&u5(e.notice),!e.shouldAdvance)return;I8=A6({capturedOrder:n.capturedOrder,actedKey:t.key,groups:p6(O8)}),I8===null&&(L8={actedKey:t.key}),R5();return}(r?.settle??n.settle)?.(!1,typeof t.error==`string`&&t.error?t.error:`The action failed.`)}var Pre={mine:`Mine`,run:`Run`,cancel:`Cancel`},Fre={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},B5=null,V5=null,H5=null,U5=0,W5=new Map,G5=new Map;function K5(e){return e===null?`n/a`:`${Math.round(e*100)}%`}function Ire(e){if(e===null)return`n/a`;let t=Math.round(e*100);return t>0?`+${t}`:String(t)}function Lre(e,t){if(U5+=1,H5?.({type:`benchmark-action`,requestId:`benchmark-${U5}`,suiteId:e,action:t})!==!0){G5.set(e,`Not connected.`),Y5();return}W5.set(e,t),G5.set(e,Fre[t]),Y5()}function q5(e,t,n){let r=V(`button`,`bench-action-button`,Pre[t]);return r.type=`button`,r.disabled=n,r.addEventListener(`click`,()=>Lre(e.id,t)),r}function Rre(e){let t=V5?.inFlight;if(!t||t.suiteId!==e.id)return``;let n=t.caseId?`case ${t.caseId}, `:``;return`Cell ${t.cellIndex+1} of ${t.cellCount}: ${n}arm ${t.armId}, trial ${t.trial}, ${t.phase}.`}function J5(e){let t=V(`td`,`bench-score`,K5(e?.recall??null));return e&&e.invalid>0&&(t.title=`${e.invalid} invalid or failed cell(s)`),e&&e.degraded>0&&(t.dataset.degraded=`true`),t}function zre(e){let t=e.armIds.filter(t=>t!==e.baselineArm),n=V(`table`,`bench-table`),r=V(`tr`);r.append(V(`th`,null,`Case`),...e.armIds.map(t=>V(`th`,null,t===e.baselineArm?`${t} (baseline)`:t))),r.append(...t.map(e=>V(`th`,null,`${e} vs baseline`))),n.append(r);for(let r of e.rows){let i=V(`tr`);i.append(V(`td`,`bench-case`,r.caseId),...e.armIds.map(e=>J5(r.arms[e]))),i.append(...t.map(e=>V(`td`,`bench-delta`,Ire(r.deltaVsBaseline[e]??null)))),n.append(i)}let i=[...new Set(e.armIds.flatMap(t=>Object.keys(e.totals[t]?.recallByTag??{})))].sort(),a=V(`tr`,`bench-total`);a.append(V(`td`,`bench-case`,`Paired recall`),...e.armIds.map(t=>J5(e.totals[t]))),n.append(a);for(let t of i){let r=V(`tr`,`bench-total`);r.append(V(`td`,`bench-case`,`Recall, ${t}`),...e.armIds.map(n=>V(`td`,`bench-score`,K5(e.totals[n]?.recallByTag[t]??null)))),n.append(r)}return n}function Bre(e){let t=V(`div`,`bench-suite`),n=V5?.inFlight?.suiteId===e.id,r=!!V5?.inFlight&&!n,i=W5.has(e.id),a=V(`div`,`bench-summary`);a.append(V(`span`,`bench-suite-title`,e.title),Dd(`bench`,e.caseCount===1?`case`:`cases`,String(e.caseCount)),Dd(`bench`,e.candidateCount===1?`candidate`:`candidates`,String(e.candidateCount)),Dd(`bench`,`arms`,String(e.armIds.length))),t.append(a);let o=V(`div`,`bench-controls`),s=V5?.configured===!0&&e.error===null;o.append(q5(e,`mine`,!s||i||n),q5(e,`run`,!s||i||n||r||e.caseCount===0),q5(e,`cancel`,i||!n));let c=V(`span`,`bench-status`,Rre(e)||G5.get(e.id)||``);if(c.setAttribute(`role`,`status`),o.append(c),t.append(o),e.error)return t.append(V(`p`,`bench-error`,e.error)),t;let l=e.latestReport;return l?(t.append(V(`p`,`bench-run-line`,`Latest run ${l.runId}: ${l.status}. Only cases every arm scored count toward paired recall.`)),l.rows.length>0&&t.append(zre(l)),t):(t.append(V(`p`,`bench-empty`,e.caseCount===0?`Move approved candidates into the cases folder, then choose Run.`:`No run yet.`)),t)}function Y5(){if(!B5)return;B5.textContent=``;let e=Ed(`bench`,`Benchmarks`,`Suites from the benchmarks folder of the Glimmervoid home, one run at a time.`);if(B5.append(e),!V5){B5.append(V(`p`,`bench-empty`,`Waiting for the server.`));return}if(!V5.configured){B5.append(V(`p`,`bench-empty`,V5.reason||`Benchmarks are off.`));return}if(V5.suites.length===0){B5.append(V(`p`,`bench-empty`,`No suites yet. Create a folder holding suite.json under benchmarks in the Glimmervoid home.`));return}for(let e of V5.suites)B5.append(Bre(e))}function Vre(e){H5=e}function Hre(e){return B5||(B5=V(`div`,`bench-content`),e.append(B5),Y5(),B5)}function Ure(e){if(!(e||W5.size===0)){for(let e of W5.keys())G5.set(e,`Connection lost.`);W5.clear(),Y5()}}function Wre(e){V5=e,Y5()}function Gre(e){W5.delete(e.suiteId);let t=V5?.suites.find(t=>t.id===e.suiteId)?.candidateCount??0,n={mine:`Mining finished. ${t} candidate${t===1?``:`s`} awaiting approval in the candidates folder.`,run:`Run ${e.runId??``} started.`,cancel:`Run cancelled.`};G5.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),Y5()}function Kre(e){return{open:e.length,labeled:e.filter(e=>e.labels.length>0).length}}function X5({hasProjects:e}){return e?`Press Refresh to load open issues.`:`No projects configured. Add a project in Settings.`}var Z5=45e3,Q5=null,$5=[],e7=``,t7=null,n7=null,r7=0,i7=new Map,a7=new Map,o7=new Map,s7=new Map;function c7(e){return r7+=1,`${e}-${r7}`}function l7(){n7&&=(clearTimeout(n7.timeoutHandle),null)}function qre(e){n7?.projectId===e&&(n7=null,s7.set(e,`No reply from the server. Press Refresh to try again.`),d7())}function Jre(e){let t=a7.get(e);t&&(a7.delete(e),o7.set(u7(t.projectId,t.issueNumber),`No reply from the server.`),d7())}function Yre(e){let t=a7.get(e);return t?(clearTimeout(t.timeoutHandle),a7.delete(e),t):null}function u7(e,t){return`${e}:${t}`}function Xre(e){let t=Date.parse(e);return Number.isFinite(t)?`updated ${bN(t)}`:`updated unknown`}function Zre(e,t){let n=V(`div`,`issue-row`),r=V(`span`,`issue-number`,`#${t.number}`),i=xd(`issue-title`,t.title||`Untitled issue`,t.url),a=V(`span`,`issue-age`,Xre(t.updatedAt));n.append(r,i,a);let o=V(`div`,`issue-labels`);for(let e of t.labels){let t=V(`span`,`issue-label-chip`,e.name);e.color&&t.style.setProperty(`--issue-label-color`,`#${e.color}`),o.append(t)}t.labels.length>0&&n.append(o);let s=V(`div`,`issue-action`),c=V(`button`,`issue-open-button`,`Open session`);c.type=`button`;let l=u7(e,t.number);c.disabled=[...a7.values()].some(n=>n.projectId===e&&n.issueNumber===t.number),c.addEventListener(`click`,()=>{let n=c7(`open-issue-session`);if(!t7?.({type:`open-issue-session`,requestId:n,projectId:e,issueNumber:t.number})){o7.set(l,`Not connected.`),d7();return}a7.set(n,{projectId:e,issueNumber:t.number,timeoutHandle:setTimeout(()=>Jre(n),Z5)}),o7.set(l,`Opening session.`),d7()});let u=V(`span`,`issue-open-status`,o7.get(l)||``);return u.setAttribute(`role`,`status`),s.append(c,u),n.append(s),n}function Qre(e,t){let n=V(`div`,`issues-project`),r=Kre(t.issues),i=V(`div`,`issues-summary`);if(i.append(Dd(`issues`,r.open===1?`open issue`:`open issues`,String(r.open)),Dd(`issues`,`labeled`,String(r.labeled)),V(`span`,`issues-refreshed`,`refreshed ${bN(t.ts)}`)),n.append(i),t.error)return n.append(V(`p`,`issues-error`,t.error)),n;if(t.issues.length===0)return n.append(V(`p`,`issues-empty`,`No open issues.`)),n;let a=V(`div`,`issue-rows`);for(let n of t.issues)a.append(Zre(e,n));return n.append(a),n}function d7(){if(!Q5)return;Q5.textContent=``;let e=Ed(`issues`,`GitHub issues`,`Open issues ordered by last update on GitHub.`),t=V(`div`,`issues-controls`),n=V(`select`,`issues-project-picker`);n.setAttribute(`aria-label`,`GitHub issues project`);for(let e of $5){let t=V(`option`,null,e.name);t.value=e.id,t.selected=e.id===e7,n.append(t)}n.disabled=$5.length===0,n.addEventListener(`change`,()=>{e7=n.value,d7()});let r=V(`button`,`issues-refresh-button`,`Refresh`);r.type=`button`,r.disabled=!e7||n7?.projectId===e7,r.addEventListener(`click`,()=>{if(!e7)return;let e=e7,t=c7(`request-issues`);if(l7(),!t7?.({type:`request-issues`,requestId:t,projectId:e})){i7.set(e,{issues:[],error:`Not connected.`,ts:Date.now()}),d7();return}s7.delete(e),n7={projectId:e,timeoutHandle:setTimeout(()=>qre(e),Z5)},d7()});let i=V(`span`,`issues-refresh-status`,n7?.projectId===e7?`Loading issues.`:s7.get(e7)||``);if(i.setAttribute(`role`,`status`),t.append(n,r,i),e.append(t),Q5.append(e),$5.length===0){Q5.append(V(`p`,`issues-placeholder`,X5({hasProjects:!1})));return}let a=i7.get(e7);if(!a){Q5.append(V(`p`,`issues-placeholder`,X5({hasProjects:!0})));return}Q5.append(Qre(e7,a))}function $re(e){t7=e}function eie(e){return Q5||(Q5=V(`div`,`issues-content`),e.append(Q5),d7(),Q5)}function tie(e){if(!e){for(let e of a7.values())clearTimeout(e.timeoutHandle),o7.set(u7(e.projectId,e.issueNumber),`Connection lost.`);a7.clear(),n7&&s7.set(n7.projectId,`Connection lost.`),l7(),d7()}}function nie(e){$5=e,$5.some(e=>e.id===e7)||(e7=$5[0]?.id||``),d7()}function rie(e){i7.set(e.projectId,{issues:e.issues,error:e.error||``,ts:e.ts}),s7.delete(e.projectId),n7?.projectId===e.projectId&&l7(),d7()}function iie(e){if(typeof e.requestId!=`string`)return;let t=Yre(e.requestId);if(!t)return;let n=u7(t.projectId,t.issueNumber);if(e.ok===!0){let r=typeof e.sessionName==`string`?e.sessionName:`issue #${t.issueNumber}`,i=e.pending===!0?` Prompt queued.`:``;o7.set(n,`Session "${r}" created.${i}`),d7();return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;o7.set(n,r),d7()}function f7(e,t){let n=document.createElement(`div`);n.className=`pr-scope-tabs`,n.setAttribute(`role`,`tablist`),n.setAttribute(`aria-label`,`Reviews scope`);let r=[`team`,`mine`];for(let i of r){let a=document.createElement(`button`);a.className=`pr-scope-tab`,a.type=`button`,a.setAttribute(`role`,`tab`),a.setAttribute(`aria-selected`,String(i===e)),a.tabIndex=i===e?0:-1,a.textContent=i===`team`?`Team`:`Mine`,a.addEventListener(`click`,()=>t(i,!1)),a.addEventListener(`keydown`,e=>{if(e.key===`ArrowLeft`){e.preventDefault(),t(r[(r.indexOf(i)+r.length-1)%r.length],!0);return}e.key===`ArrowRight`&&(e.preventDefault(),t(r[(r.indexOf(i)+1)%r.length],!0))}),n.append(a)}return n}function p7(){pF()===`team`&&Ore()}function aie(e){let t=(e,t)=>{if(o(e),p7(),!t)return;let s=(e===`team`?n:r).querySelector(`[aria-selected="true"]`);if(s&&s.getClientRects().length>0){s.focus();return}(e===`team`?i:a).querySelector(`.pr-queue-toggle`)?.focus()},n=f7(`team`,t),r=f7(`mine`,t),i=document.createElement(`div`);i.className=`pr-mode-root`;let a=document.createElement(`div`);a.className=`pr-mode-root`,e.append(i,a),Are(i,n),S3(a,r);function o(e){G2(),i.hidden=e!==`team`,a.hidden=e!==`mine`,mF(e)}o(pF())}var oie=4e3;function sie({render:e,holdMs:t=oie,setTimer:n=setTimeout,clearTimer:r=clearTimeout}){let i=new Set,a=!1,o=null;function s(e){(o===null||e)&&(o!==null&&r(o),o=n(c,t))}function c(){if(o=null,i.size>0){s(!1);return}a&&(a=!1,e())}return{begin(e){i.add(e)},settle(e){i.delete(e),s(!0)},request(){if(i.size===0&&o===null){e();return}a=!0,s(!1)},_state(){return{pending:i.size,held:a,armed:o!==null}}}}var m7=null,h7=null,g7=null,_7=null,v7=`http://www.w3.org/2000/svg`,y7=RE({getAck:CF,setAck:wF,signature:()=>FD({posthog:m7}),isLooking:()=>!kd(h7)}),b7=sie({render:z7}),x7=new Set,S7=null,C7=new Map,w7=SN(()=>h7),cie={spiking:`spiking`,regressed:`regressed`,worsened:`worsened`,new:`new`,quiet:`quiet`},T7=[{columnId:`stripe`,headText:``,cellClass:`radar-stripe`,track:`auto`,phoneTrack:`auto`,isMagnitude:!1,startsActionCluster:!1},{columnId:`change`,headText:``,cellClass:`radar-change`,track:`auto`,phoneTrack:`minmax(68px, auto)`,isMagnitude:!1,startsActionCluster:!1},{columnId:`copy`,headText:``,cellClass:`radar-issue-copy`,track:`minmax(0, 1fr)`,phoneTrack:`minmax(0, 1fr)`,isMagnitude:!1,startsActionCluster:!0},{columnId:`occurrences`,headText:`Occurrences`,cellClass:`radar-metric`,track:`max-content`,phoneTrack:``,isMagnitude:!0,startsActionCluster:!1},{columnId:`users`,headText:`Users`,cellClass:`radar-metric`,track:`max-content`,phoneTrack:``,isMagnitude:!0,startsActionCluster:!1},{columnId:`trend`,headText:`Trend`,cellClass:`radar-issue-trend`,track:`max-content`,phoneTrack:``,isMagnitude:!0,startsActionCluster:!1}],lie=T7.map(e=>e.track).join(` `),uie=T7.filter(e=>!e.isMagnitude).map(e=>e.phoneTrack).join(` `),die=T7.findIndex(e=>e.startsActionCluster)+1;function E7(e){let t=V(`div`,e);return t.style.setProperty(`--radar-issue-grid`,lie),t.style.setProperty(`--radar-issue-grid-phone`,uie),t.style.setProperty(`--radar-issue-actions-start`,String(die)),t}function D7(e,t){let n=V(`span`,`radar-issue-magnitudes`),r=!1;for(let i of T7){let a=t(i);if(!i.isMagnitude){e.append(a);continue}r||=(e.append(n),!0),n.append(a)}}function O7(e){return Number.isFinite(e)?String(e):`0`}function fie(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?``:`elapsed ${yN(Date.now()-e)}`}function k7(e){return typeof e?.issueId==`string`?e.issueId:``}function A7(e,t){return[String(e??``),String(t??``)].join(`::`)}function pie(e,t,n){let r=C7.get(A7(e,t));if(!r||!r.copy.isConnected)return!1;let i=ZE(n);return i?(r.summary||(r.summary=V(`span`,`radar-issue-summary`),r.copy.insertBefore(r.summary,r.copy.querySelector(`.radar-issue-meta`))),r.summary.textContent=i,!0):(r.summary?.remove(),r.summary=null,!0)}function j7(e,t,n){let r=k7(e);if(!r)return;S7?.dialog.close();let i=DN({issueTitle:String(e.title||r),projectLabel:n,onOpenReport:()=>N7(e)});S7={projectId:String(t??``),issueId:r,dialog:i},i.update(QE(e))}function M7(){if(!S7)return;if(!S7.dialog.isOpen()){S7=null;return}let e=$E(m7,S7.projectId,S7.issueId);e&&S7.dialog.update(QE(e))}function N7(e){let t=k7(e);t&&dd(`get-posthog-report`,{issueId:t}).then(n=>{if(!n.ok){EN({issueId:t,issueTitle:String(e.title??``),error:String(n.error||`Could not read report`)});return}if(!n.found){EN({issueId:t,issueTitle:String(e.title??``),message:String(n.message||`Report not found`)});return}EN({issueId:t,issueTitle:String(e.title??``),format:String(n.format??``),content:String(n.content||``)})}).catch(n=>{EN({issueId:t,issueTitle:String(e.title??``),error:String(n?.message||`Could not read report`)})})}function P7(){let e=V(`div`,`radar-issue-actions`),t=V(`span`,`radar-issue-action-status`);t.setAttribute(`role`,`status`),e.append(t);let n=[],r=null,i=()=>{r?.remove(),r=null},a=t=>{i(),r=t,e.append(t)},o=e=>{for(let t of n)t.disabled=e};return{addButton:(r,i,a)=>{let o=V(`button`,`radar-issue-action`,r);return o.type=`button`,o.title=i,o.addEventListener(`click`,e=>{e.stopPropagation(),a()}),n.push(o),e.insertBefore(o,t),o},request:(e,n,r,a,s,c=null)=>{b7.begin(e),o(!0),i(),t.dataset.tone=`busy`,t.textContent=a;let l=(n,r)=>{o(!1),i(),t.dataset.tone=n,t.textContent=r,b7.settle(e)};dd(n,r).then(e=>{if(!e.ok){l(`error`,String(e.error||`Request failed`));return}l(`ok`,s(e)),c&&c(e)}).catch(e=>l(`error`,String(e?.message||`Request failed`)))},showFollowUp:a,wrap:e}}function mie(e){let t=V(`button`,`radar-issue-action radar-open-trace`,`Open trace`);return t.type=`button`,t.title=`Open the session trace`,t.addEventListener(`click`,t=>{t.stopPropagation(),Die(e)}),t}function hie(e,t,n){let{addButton:r,request:i,showFollowUp:a,wrap:o}=P7(),s=(n,r,a,o,s=null)=>i(`${n}:${e.issueId}`,n,{projectId:t,issueId:e.issueId,...r},a,o,s);return e.inFlight&&r(`View investigation`,`Watch the running investigation`,()=>j7(e,t,n)),e.inFlight||r(`Open session`,`Paste an investigation prompt into the mapped project session`,()=>{s(`posthog-open-session`,{},`Opening session`,e=>e.pending?`Starting ${String(e.sessionName||`session`)}; the prompt lands when it is up`:`Prompt pasted into ${String(e.sessionName||`the session`)}; press Enter there`,e=>{typeof e.sessionId==`string`&&_7&&a(mie(e.sessionId))})}),r(`Resolve`,`Mark this issue resolved in PostHog`,()=>{s(`posthog-issue-action`,{action:`resolve`},`Resolving in PostHog`,()=>`Marked resolved`)}),r(`Suppress`,`Suppress this issue in PostHog`,()=>{s(`posthog-issue-action`,{action:`suppress`},`Suppressing in PostHog`,()=>`Marked suppressed`)}),o}function F7(e,t,n){e.classList.add(`radar-issue-reportable`),e.tabIndex=0,e.setAttribute(`role`,`button`),e.setAttribute(`aria-label`,t),e.title=t,e.addEventListener(`click`,e=>{e.target instanceof Element&&(e.target.closest(`a, button`)||n())}),e.addEventListener(`keydown`,t=>{t.target===e&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n())})}function gie(e,t,n){let r=V(`div`,`radar-issue`);r.dataset.severity=fD(e.change);let i=V(`span`,`radar-stripe`);i.setAttribute(`aria-hidden`,`true`);let a=V(`span`,`radar-change`,cie[e.change??``]||String(e.change||`unknown`)),o=xd(`radar-issue-title`,String(e.title||`Untitled issue`),e.url,String(e.title||``)),s=V(`span`,`radar-metric`);s.append(V(`span`,`radar-metric-value`,O7(e.occurrences)),V(`span`,`radar-metric-label`,`occ`));let c=V(`span`,`radar-metric`);c.append(V(`span`,`radar-metric-value`,O7(e.users)),V(`span`,`radar-metric-label`,`users`));let l=gD(e.history),u=_D(l,64,16),d=u?document.createElementNS(v7,`svg`):null;if(d){d.classList.add(`radar-sparkline`),d.setAttribute(`viewBox`,`0 0 64 16`),d.setAttribute(`width`,`64`),d.setAttribute(`height`,`16`),d.setAttribute(`role`,`img`),d.setAttribute(`focusable`,`false`);let e=document.createElementNS(v7,`title`);e.textContent=yD(l);let t=document.createElementNS(v7,`polyline`);t.setAttribute(`points`,u),d.append(e,t)}let f=ZE(e),p=V(`span`,`radar-issue-copy`);p.append(o);let m=null;f&&(m=V(`span`,`radar-issue-summary`),m.textContent=f,p.append(m)),C7.set(A7(t,e.issueId),{copy:p,summary:m});let h=V(`span`,`radar-issue-meta`),g=pD(e);if(g!==null){let e=V(`span`,`radar-issue-seen`);e.title=new Date(g).toLocaleString(),w7.track(e,g,bN),h.append(e)}let _=mD(e);_&&h.append(V(`span`,`radar-issue-status`,_));let v=String(e.title||e.issueId);if(e.inFlight){let i=V(`span`,`radar-verdict`,`investigating`);i.dataset.verdict=`INVESTIGATING`,h.append(i);let a=typeof e.startedAt==`number`?e.startedAt:null;if(a!==null&&Number.isFinite(a)&&a>0){let e=V(`span`,`radar-issue-elapsed`);w7.track(e,a,fie),h.append(e)}k7(e)&&F7(r,`Watch the investigation of ${v}`,()=>j7(e,t,n))}if(!e.inFlight&&e.verdict){let t=V(`span`,`radar-verdict`,iD(e.verdict));t.dataset.verdict=e.verdict,h.append(t),k7(e)&&F7(r,`View investigation report for ${v}`,()=>N7(e))}h.childElementCount>0&&p.append(h);let y=V(`span`,`radar-issue-trend`);d&&y.append(d);let b=vD(l);if(b){let e=V(`span`,`radar-delta`,`${b.direction===`up`?`+`:b.direction===`down`?`-`:`=`}${b.percent}%`);e.dataset.direction=b.direction,y.append(e)}let x={stripe:i,change:a,copy:p,occurrences:s,users:c,trend:y};return D7(r,e=>x[e.columnId]),k7(e)&&r.append(hie(e,t,n)),r}var I7=(e,t,n)=>Dd(`radar`,e,t,n);function _ie(e){return e.error?`poll failed: ${e.error}`:e.staleMs>0?`stale ${yN(e.staleMs)}`:``}function L7(e,t,{showHost:n,nameTag:r,nameClass:i,hostClass:a}){let o=V(r,i,wD(t));o.title=String(t.name||``),e.append(o);let s=n?TD(t.host):``;s&&e.append(V(`span`,a,s))}function vie(){let e=E7(`radar-column-heads`);for(let t of T7){if(!t.headText){e.append(V(`span`));continue}let n=V(`span`,`radar-column-head`,t.headText);n.dataset.column=t.columnId,e.append(n)}return e}function yie(e,t){let n=e.project,r=V(`div`,`radar-project`),i=LD(n.issues),a=bD(i),o=V(`div`,`radar-project-head`);L7(o,n,{showHost:t,nameTag:`h3`,nameClass:`radar-project-name`,hostClass:`radar-project-host`}),r.append(o);let s=V(`div`,`radar-project-summary`);s.append(I7(a.active===1?`active issue`:`active issues`,O7(a.active))),s.append(I7(`spiking`,O7(a.spiking),a.spiking>0?`crit`:null)),s.append(I7(`needs you`,O7(a.needsHuman),a.needsHuman>0?`warn`:null));let c=_ie(e);if(c){let t=V(`span`,`radar-project-alert`,c);t.dataset.tone=e.error?`crit`:`warn`,s.append(t)}if(r.append(s),i.length===0)return r;r.append(vie());let l=E7(`radar-issues`);for(let e of i)l.append(gie(e,n.projectId,wD(n)));return r.append(l),r}function bie(e,t){let n=e.project,r=V(`div`,`radar-quiet-row`),i=V(`span`,`radar-quiet-dot`);return i.setAttribute(`aria-hidden`,`true`),r.append(i),L7(r,n,{showHost:t,nameTag:`span`,nameClass:`radar-quiet-name`,hostClass:`radar-quiet-host`}),r.append(V(`span`,`radar-quiet-count`,`0 issues`)),r}var R7=(e,t)=>Ed(`radar`,e,t);function xie(){let e=V(`div`,`radar-issue`);return e.dataset.skeleton=``,D7(e,e=>V(`span`,e.cellClass)),e}function Sie(){let e=E7(`radar-issues`);e.setAttribute(`aria-busy`,`true`),e.setAttribute(`aria-label`,`Loading issues`);for(let t=0;t<5;t+=1)e.append(xie());return e}function Cie(e,t=`ready`){let n=R7(`Errors`);if(t===`pending`)return n.append(Sie()),n;if(t===`placeholder`||e.length===0){let e=V(`p`,`radar-unconfigured`,lD(m7)),t=mW(`lanes-posthog`,`posthog-enabled`,`PostHog settings`);return e.append(document.createTextNode(` `),t),n.append(e),n}let r=V(`div`,`radar-global-tick`),i=Number(m7?.intervalMinutes);w7.track(r,m7?.ts,e=>{let t=`polled ${bN(e)}`;return!Number.isFinite(i)||i<=0?t:`${t}, every ${i}m`}),n.append(r);let a=i>0?i*6e4:0,{loud:o,quiet:s}=OD(e,Date.now(),{intervalMs:a}),c=ED(e);for(let e of o)n.append(yie(e,c));if(s.length===0)return n;let l=V(`div`,`radar-quiet`);for(let e of s)l.append(bie(e,c));return n.append(l),n}function wie(e){let{addButton:t,request:n,wrap:r}=P7();return e.issueId&&t(`Open report`,`Open the investigation report for this issue`,()=>{N7({issueId:e.issueId,title:e.title})}),t(`Archive`,`Remove this investigation from the inbox`,()=>{n(`archive:${e.id}`,`posthog-archive-investigation`,{id:e.id},`Archiving`,()=>`Archived`,()=>x7.add(e.id))}),r}function Tie(e){let t=V(`div`,`radar-investigation`),n=V(`span`,`radar-verdict`,iD(e.verdict));n.dataset.verdict=e.verdict;let r=xd(`radar-issue-title`,e.title,e.url),i=V(`span`,`radar-issue-copy`);if(i.append(r),e.summaryLine){let t=V(`span`,`radar-issue-summary`);t.textContent=e.summaryLine,i.append(t)}if(e.prUrl){let t=V(`a`,`radar-investigation-pr`,`fix PR`);t.href=e.prUrl,t.target=`_blank`,t.rel=`noopener`,t.title=e.prUrl,i.append(t)}if(t.append(n),e.mode===`fix`){let e=V(`span`,`radar-verdict`,`fix`);e.dataset.mode=`fix`,t.append(e)}if(t.append(i),e.projectLabel){let n=V(`span`,`radar-investigation-project`);n.textContent=e.projectLabel,t.append(n)}if(e.at>0){let n=V(`span`,`radar-investigation-time`,bN(e.at));n.title=new Date(e.at).toLocaleString(),t.append(n)}return t.append(wie(e)),t}function Eie(e){let t=R7(`Investigations`,`completed, not yet archived`),n=V(`div`,`radar-investigations`);for(let t of e)n.append(Tie(t));return t.append(n),t}function Die(e){_7&&_7(e)}function z7(){if(!h7)return;h7.textContent=``,C7.clear(),w7.reset();let e=Od(m7),t=kD(m7,x7),n=dD(m7,e.length);h7.append(Cie(e,n)),t.length>0&&h7.append(Eie(t))}function B7(){b7.request()}function V7(){g7&&g7(y7.refresh())}function Oie(){y7.acknowledge(),V7()}function kie(e){g7=e,V7()}function Aie(e){_7=e}function jie(e){if(h7)return h7;let t=V(`div`,`radar-content`);return e.appendChild(t),h7=t,w7.ensure(),z7(),t}function Mie(e){m7=e,AD(m7,x7),B7(),V7(),M7()}function Nie(e){let t=$E(m7,e.projectId,e.issueId)?.inFlight===!0;if(!eD(m7,e))return;M7();let n=$E(m7,e.projectId,e.issueId);t&&pie(e.projectId,e.issueId,n)||B7()}function Pie(e){S7?.dialog.isOpen()&&nD(S7,e)&&S7.dialog.update(tD(e))}function Fie(e){if(!rD(m7,e)){Pie(e);return}M7(),B7(),V7()}function Iie(e,t){return typeof t!=`string`||t===``?{knownBuild:e,reload:!1}:e==null?{knownBuild:t,reload:!1}:e===t?{knownBuild:e,reload:!1}:{knownBuild:t,reload:!0}}function Lie(e){if(typeof e!=`object`||!e||!(`telemetry`in e))return!1;let{telemetry:t}=e;return typeof t!=`object`||!t||!(`enabled`in t)?!1:t.enabled===!0}function Rie(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function zie(e,t){return t||Rie(e)?!1:Lie(e)}Fb(ZP()),Ib(qP()),Lb(YP()),aY($P()),qd(),xx(document);var H7=H(document,`#connection-status`,`span`),U7=H(H7,`.connection-label`,`span`),W7=H(document,`#loading-screen`,`div`),Bie=H(document,`#loading-status`,`div`),G7=H(document,`#shutdown-screen`,`div`),K7=H(document,`#shutdown-status`,`div`),q7=!1;function Vie(){if(q7)return;q7=!0,document.body.classList.add(`app-ready`),W7.classList.add(`fade-out`);let e=()=>W7.remove();W7.addEventListener(`transitionend`,e,{once:!0}),setTimeout(e,1e3)}function J7(e){e&&(K7.textContent=e),G7.classList.add(`active`)}ld((e,t)=>{if(H7.dataset.state=e,U7.textContent=t,H7.title=t,OV(e===`connected`),FH(e===`connected`),tie(e===`connected`),Ure(e===`connected`),e===`connected`){if(G7.classList.contains(`active`)){location.reload();return}Vie(),J9(),i9(),r9(),dd(`get-settings`,{}).then(e=>{e.settings&&(wH(e.settings),j1(e.settings),iK(e.settings),B9(e.settings),c9(e.settings),Hd()===`settings`&&g9(location.hash))}).catch(()=>{});return}if(e===`disconnected`&&G7.classList.contains(`active`)){K7.textContent=`Waiting for server...`;return}q7||(Bie.textContent=`Reconnecting to server...`)});function Y7(){M2(),AM(),Z7()}var X7=!1;function Z7(){UM(X7&&AU()&&!Jd(),MU())}var Q7=null;function Hie(e){let t=Iie(Q7,e);Q7=t.knownBuild,t.reload&&location.reload()}function Uie(e){QG(new Map(e.filter(e=>!e.ephemeral).map(e=>[e.id,e.name]))),z1(e.filter(e=>!e.ephemeral).map(e=>({id:e.id,name:e.name,agent:e.agent,permissionMode:e.dangerouslySkipPermissions?`Skip permissions`:`Default`}))),nie(e.filter(e=>!e.ephemeral).map(e=>({id:e.id,name:e.name})));for(let t of e){t.ephemeral||qF(t.path);let e=xH(t.id);e&&tU(t.id,t.state,t.stateSince),e&&zV(t.id,!!t.saneYolo),e||EH(t.id,t.name,t.state,{skipPerms:!!t.dangerouslySkipPermissions,saneYolo:!!t.saneYolo,worktree:!!t.isWorktree,workspace:!!t.isWorkspace,path:t.path,stateSince:t.stateSince}),bH(t.id,t.taskTitle,t.taskTitleIsCustom),LH(t.id,t.agent),YH(t.id,t.mergeStatus,t.mergeReason),IH(t.id,t.effectiveBase),VH(t.id,t.activeAgents,t.awaitingBackgroundTasks),BH(t.id,t.hasEndedTurn),GH(t.id,t.pendingWakeup),UH(t.id,t.pendingPromptKind,t.pendingPromptDetail),AH(t.id,t.hasPlan),n9(t.id)}TH(),FN(U),AU()&&(GU(),fW()),Y7(),$7(),_9(location.hash)}function $7(){CV([...U].map(([e,t])=>({id:e,name:Xd(t)||e})))}function e9(e,t){AH(e,t?.hasPlan===!0),n9(e)}function Wie(e){if(!xH(e.id)){EH(e.id,e.session,e.to,{skipPerms:!!e.skipPerms,saneYolo:!!e.saneYolo,stateSince:e.timestamp}),FN(U);return}if(e.to===I.DORMANT&&e.from!==I.DORMANT){let t=U.get(String(e.id)),n=document.querySelector(`.session-card[data-id="${CSS.escape(String(e.id))}"]`),r=n instanceof HTMLElement?n:null,i=r?r.dataset.skipPerms!==void 0:!1,a=e.saneYolo??(r?r.dataset.saneYolo!==void 0:!1),o=r?r.dataset.path:void 0;QH(e.id),EH(e.id,e.session,I.DORMANT,{skipPerms:i,saneYolo:a,path:o,stateSince:e.timestamp,taskTitle:t?.taskTitle,taskTitleIsCustom:t?.taskTitleIsCustom}),LH(e.id,t?.agent),e9(e.id,t),AU()&&GU(),Y7(),Cz(e.id),FN(U);return}tU(e.id,e.to,e.timestamp),e.hasEndedTurn!==void 0&&BH(e.id,e.hasEndedTurn),e.saneYolo!==void 0&&zV(e.id,e.saneYolo),FN(U),Cz(e.id),AU()&&GU(),Y7(),iH(e.id),e.to===I.INITIALIZING&&(e.from===I.DONE||e.from===I.FAILED)&&vE(e.id)}var t9=new Map;function Gie(e){let t=new Set;for(let n of e){if(!n?.id)continue;t.add(n.id);let e={tokens:n.tokens,costUSD:n.costUSD,officialCostUSD:n.officialCostUSD};t9.set(n.id,e),HH(n.id,e)}for(let e of[...t9.keys()])t.has(e)||(t9.delete(e),HH(e,null))}function n9(e){let t=t9.get(e);t&&HH(e,t)}XZ(B),gJ(B),bV(B),$re(B),Vre(B);function Kie(){return k2()?A2(`hooks`):Hd()===`hooks`}function r9(){Kie()&&_J()}function qie(){return k2()?A2(`usage`):Hd()===`usage`}function i9(){qie()&&ZZ()}var Jie={snapshot:e=>{Hie(e.serverBuild),Uie(e.sessions)},"hooks-report":e=>bJ(e),"save-hook-result":e=>xJ(e),"delete-hook-result":e=>SJ(e),"hooks-updated":()=>r9(),"state-change":e=>Wie(e),"session-added":e=>{e.ephemeral||qF(e.path),xH(e.id)||(EH(e.id,e.session,e.state,{skipPerms:!!e.skipPerms,saneYolo:!!e.saneYolo,worktree:!!e.worktree,workspace:!!e.workspace,path:e.path,stateSince:e.stateSince,taskTitle:typeof e.taskTitle==`string`?e.taskTitle:null,taskTitleIsCustom:e.taskTitleIsCustom===!0}),LH(e.id,e.agent),n9(e.id)),FN(U),AU()&&GU(),Y7(),$7()},"session-removed":e=>{QH(e.id),wz(e.id),FN(U),AU()&&GU(),Y7(),$7()},"session-title":e=>{bH(e.id,e.taskTitle,e.isCustom),AU()&&GU(),Y7()},"session-renamed":e=>{ZH(e.id,e.newName),Y7(),$7()},"session-modified":e=>{e.ephemeral||qF(e.path);let t=U.get(String(e.id));QH(e.id),wz(e.id),EH(e.id,e.session,e.state,{skipPerms:!!e.skipPerms,saneYolo:!!e.saneYolo,worktree:!!e.worktree,workspace:!!e.workspace,path:e.path,stateSince:e.stateSince,taskTitle:typeof e.taskTitle==`string`?e.taskTitle:null,taskTitleIsCustom:e.taskTitleIsCustom===!0}),LH(e.id,e.agent),e9(e.id,t),FN(U),AU()&&GU(),Y7(),$7()},"session-git":e=>RH(e.id,!!e.worktree),"session-agents":e=>{VH(e.id,e.activeAgents,e.awaitingBackgroundTasks),AU()&&GU(),Y7(),iH(e.id)},"session-wakeup":e=>GH(e.id,e.pendingWakeup),"session-prompt":e=>{UH(e.id,e.pendingPromptKind,e.pendingPromptDetail??null),Y7()},"session-merge-status":e=>{JH(e.id,e.mergeStatus,e.reason),oW(e.id,e.mergeStatus),Y7()},"session-worktree-blocked":e=>{zx(`${e.session}: ${e.notice||`integration branch not found`}`,{persist:!0})},"session-worktree-warning":e=>{zx(`${e.session}: ${e.notice||`base branch warning`}`)},"session-worktree-ready":e=>{IH(e.id,e.base)},"session-diff":e=>{ore(e),XH(e.id,{committed:e.committed,uncommitted:e.uncommitted,hasCommits:e.hasCommits})},"change-map":e=>_z(e.id,e.map),"branch-sync-status":e=>bz(e.id,e),"session-changed":e=>Sz(e.id),"post-turn-result":e=>KH(e.id,e),"debug-state-response":e=>rH(e),"session-trace-response":e=>{nre(e),TV(e)},"session-trace-changed":e=>EV(e),"session-plan-changed":e=>{jH(e),Y7()},"session-plan-draft":e=>{MH(e)},"session-plan-response":e=>{NH(e)},notify:e=>{MJ(e),iH(e.session)},"update-status":e=>{Qie(e),I1(e)},"update-progress":e=>L1(e.journal),error:e=>{rre(e),R1(),DV(e),PH(e),zx(e.message,{persist:!0})},"session-error":e=>{PH(e),zx(`${e.session}: ${e.message}`,{persist:!0})},"settings-updated":e=>{e.settings&&(wH(e.settings),j1(e.settings),iK(e.settings),B9(e.settings,{isLiveSettingsChange:!0}),c9(e.settings))},"health-snapshot":e=>{e.stats&&gI(e.stats)},"posthog-status":e=>Mie(e),"posthog-investigation-activity":e=>Nie(e),"posthog-investigation-finished":e=>Fie(e),"team-review-status":e=>jre(e),"my-prs-status":e=>C3(e),"benchmark-status":e=>Wre(e),"benchmark-action-result":e=>Gre(e),"my-pr-merge-result":e=>T3(e),"team-review-action-result":e=>Nre(e),"issues-report":e=>rie(e),"open-issue-session-result":e=>iie(e),"usage-sessions":e=>{Gie(e.sessions),eQ(e),i9()},"usage-report":e=>{nQ(e),P1()},"plan-limits":e=>tQ(e),"usage-budget-alert":e=>MJ({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0}),"visions-findings":e=>_K(e),"visions-comments":e=>vK(e),"visions-hand":e=>yK(e),"visions-intent":e=>bK(e),"visions-fix":e=>gK(e),"visions-snapshot":e=>CK(e),"ingest-activity":e=>xK(e),"ingest-snapshot":e=>SK(e),"client-trust":e=>yae(e.trust),"shutting-down":()=>{H7.dataset.state=`shutdown`,U7.textContent=`Shutting down...`,H7.title=`Shutting down...`,H(document,`#btn-power`,`button`).disabled=!0,J7(`Shutting down sessions...`)},restarting:()=>{H7.dataset.state=`shutdown`,U7.textContent=`Restarting...`,H7.title=`Restarting...`,H(document,`#btn-power`,`button`).disabled=!0,J7(`Restarting server...`)}};function Yie(e){let t=Jie[e.type];t&&t(e)}ud(e=>{Yie(e)});var a9=!1,Xie=mW(HE,UE,`Update`).href;function Zie(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function Qie(e){let t=H(document,`#update-banner`,`div`);if(!e.updateAvailable){t.hidden=!0;return}if(a9)return;let n=Zie(e);if(n&&yF()===n)return;let r=String(e.command??``);H(document,`#update-banner-text`,`span`).textContent=ND(e),H(document,`#update-banner-cmd`,`code`).textContent=r;let i=hQ(e),a=H(document,`#update-banner-update`,`a`);a.href=Xie,a.hidden=i!==`link`;let o=H(document,`#update-banner-cmd`,`code`);o.hidden=i!==`command`;let s=H(document,`#update-banner-copy`,`button`);s.hidden=i!==`command`;let c=H(document,`#update-banner-copy-status`,`span`);c.hidden=i!==`command`,c.textContent=``;let l=H(document,`#update-banner-link`,`a`);l.hidden=!e.releaseUrl,l.href=typeof e.releaseUrl==`string`?e.releaseUrl:``,t.hidden=!1,s.onclick=()=>{let e=Ad(r);if(!e){c.textContent=`Copy failed`;return}e.then(()=>{c.textContent=`Copied`}).catch(()=>{c.textContent=`Copy failed`})},H(document,`#update-banner-dismiss`,`button`).onclick=()=>{a9=!0,bF(n),t.hidden=!0}}var o9=H(document,`#telemetry-banner`,`div`);function s9(){SF(!0),o9.hidden=!0}function c9(e){o9.hidden=!zie(e,xF())}var l9=H(document,`#telemetry-banner-settings`,`a`);l9.href=mW(`privacy`,`telemetry-enabled`,`Open settings`).href,l9.addEventListener(`click`,s9),H(document,`#telemetry-banner-dismiss`,`button`).addEventListener(`click`,s9),H(document,`#btn-add-session-header`,`button`).addEventListener(`click`,TN);var u9=H(document,`#btn-mute`,`button`);function d9(){u9.setAttribute(`aria-pressed`,String(!VP()))}d9(),u9.addEventListener(`click`,()=>{HP(!VP()),d9()});var f9=H(document,`#power-menu`,`div`),p9=H(document,`#btn-power`,`button`);function m9(){p9.setAttribute(`aria-expanded`,f9.classList.contains(`open`)?`true`:`false`)}p9.addEventListener(`click`,e=>{e.stopPropagation(),f9.classList.toggle(`open`),m9()}),document.addEventListener(`click`,e=>{e.target instanceof Node&&(f9.contains(e.target)||(f9.classList.remove(`open`),m9()))}),Td(document.querySelector(`.header`));function $ie(e){e&&k1(e),!N2(`settings`)&&I9(`settings`,{section:e})}function h9(){location.hash.startsWith(`#settings/`)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}function eae(e){return e?(k1(e.sectionId,e.settingId),N2(`settings`)||I9(`settings`,{section:e.sectionId,setting:e.settingId,persist:!1}),!0):!1}function g9(e){return eae(A1(e))}function _9(e){let t=GL(e);return t?!xH(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),k2()?(O2(t)||zx(`No plan is stored for this session yet`),!0):(I9(`focus`,{persist:!1}),cW(t)||zx(`No plan is stored for this session yet`),!0)):!1}function v9(e){return _9(e)?!0:g9(e)}function tae(){return v9(location.hash)}document.addEventListener(`click`,e=>{if(!k2()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&v9(t.hash)&&e.preventDefault()}),H(document,`#btn-help`,`button`).addEventListener(`click`,()=>{$ie(`browser-shortcuts`)});var y9=H(document,`#view-calm`,`section`),nae=H(document,`#tab-calm`,`button`),rae=H(document,`#view-focus`,`section`),b9=H(document,`#view-radar`,`section`),x9=H(document,`#view-prs`,`section`),S9=H(document,`#view-issues`,`section`),C9=H(document,`#view-usage`,`section`),w9=H(document,`#view-visions`,`section`),T9=H(document,`#view-hooks`,`section`),E9=H(document,`#view-trace`,`section`),D9=H(document,`#view-benchmarks`,`section`),O9=H(document,`#view-settings`,`section`),iae=H(document,`#tab-focus`,`button`),aae=H(document,`#tab-radar`,`button`),oae=H(document,`#tab-prs`,`button`),sae=H(document,`#tab-issues`,`button`),cae=H(document,`#tab-usage`,`button`),lae=H(document,`#tab-visions`,`button`),uae=H(document,`#tab-hooks`,`button`),dae=H(document,`#tab-trace`,`button`),fae=H(document,`#tab-benchmarks`,`button`),pae=H(document,`#tab-settings`,`button`),mae=H(document,`#tab-radar-activity`,`span`),hae=H(document,`#tab-prs-activity`,`span`),gae=H(document,`#tab-usage-activity`,`span`),k9=H(document,`#tab-visions-activity`,`span`);kie(e=>{mae.classList.toggle(`active`,e),F2(`radar`,e)}),kre(e=>{hae.classList.toggle(`active`,e),F2(`prs`,e)}),YZ(e=>{gae.classList.toggle(`active`,e),F2(`usage`,e)}),fK(e=>{let t=e!==null;k9.classList.toggle(`active`,t),t||k9.removeAttribute(`data-attention`),t&&k9.setAttribute(`data-attention`,e),F2(`visions`,e)}),NU({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),dz({panel:document.getElementById(`review-sidebar`)}),jie(b9),aie(x9),eie(S9),QZ(C9),pK(w9),vJ(T9),yV(E9),Hre(D9),w1(O9,{onRestart:K9,onConfirmUpdateAndRestart:vae}),GM(y9,{openTerminal:e=>{I9(`focus`),sW(e)},openPlan:e=>{I9(`focus`),cW(e)},openCalm:()=>I9(`calm`)});var A9=jU();A9&&HM(A9),Vd.subscribe((e,t)=>{t.includes(`focusedSessionId`)&&Z7()});var j9=[{view:`calm`,tab:nae,el:y9},{view:`focus`,tab:iae,el:rae},{view:`prs`,tab:oae,el:x9},{view:`issues`,tab:sae,el:S9},{view:`usage`,tab:cae,el:C9},{view:`radar`,tab:aae,el:b9},{view:`visions`,tab:lae,el:w9},{view:`hooks`,tab:uae,el:T9},{view:`trace`,tab:dae,el:E9},{view:`benchmarks`,tab:fae,el:D9},{view:`settings`,tab:pae,el:O9}];function M9(e){return j9.some(t=>t.view===e&&!t.tab.hidden)}var N9=!0,P9=null;function F9(e){e===`radar`&&Oie(),e===`prs`&&p7(),e===`usage`&&KZ(),e===`visions`&&(hK(),mK())}function I9(e,{section:t,setting:n,persist:r=!0}={}){if(!M9(e))return;let i=Hd();Vd.dispatch(`setActiveView`,e),N9=r,r&&(P9=null),document.body.dataset.activeView=e,r&&nF(e);for(let t of j9){let n=t.view===e;t.el&&(t.el.hidden=!n),t.tab.setAttribute(`aria-selected`,String(n)),t.tab.tabIndex=n?0:-1}i===`focus`&&e!==`focus`&&pW(),e===`focus`&&dW(),i===`calm`&&e!==`calm`&&qM(),e===`calm`&&KM(),e===`usage`&&($Z(),ZZ()),e===`hooks`&&(yJ(),_J()),e===`trace`&&wV(),i===`settings`&&e!==`settings`&&h9(),e===`settings`&&t&&k1(t,n??null),F9(e),Z7()}var L9=!1;function R9(e,t){let n=j9.find(t=>t.view===e);n&&(n.tab.hidden=!t,P2(e,t),e===`trace`&&(L9=t,Aie(t?SV:null)),!k2()&&(!t&&Hd()===e&&I9(`focus`),t&&P9===e&&I9(e)))}var z9=null;function B9(e,{isLiveSettingsChange:t=!1}={}){let n=ON(e),r=t&&z9===!1&&n.calm;z9=n.calm,X7=n.calm,D2(n.calm),aW(!n.calm),Z7();for(let[e,t]of Object.entries(n))R9(e,t);!r||Hd()!==`focus`||Jd()||GL(location.hash)||I9(`calm`)}for(let e of Object.keys(ON(null)))R9(e,!1);NV(e=>R9(`trace`,e)),R9(`trace`,!1),xV(()=>{L9&&(N2(`trace`)||I9(`trace`))});function V9(e,t){let n=j9.filter(e=>!e.tab.hidden),r=n[(n.findIndex(t=>t.view===e)+t+n.length)%n.length];return I9(r.view),r.tab}function _ae(e){j9.some(e=>e.tab===document.activeElement)&&e.focus()}for(let e=0;e<j9.length;e++){let{view:t,tab:n}=j9[e];n.addEventListener(`click`,()=>I9(t)),n.addEventListener(`keydown`,e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||(e.preventDefault(),V9(Hd(),e.key===`ArrowRight`?1:-1).focus()))})}var H9=tF(),U9=A1(location.hash),W9=GL(location.hash);if(U9&&I9(`settings`,{section:U9.sectionId,setting:U9.settingId,persist:!1}),W9&&I9(`focus`,{persist:!1}),!U9&&!W9){let e=M9(H9);e||(P9=H9),I9(e?H9:`focus`,{persist:e})}C2({radarPanelEl:b9,prsPanelEl:x9,issuesPanelEl:S9,usagePanelEl:C9,visionsPanelEl:w9,hooksPanelEl:T9,tracePanelEl:E9,settingsPanelEl:O9,onScreenShown:e=>{e===`usage`&&($Z(),ZZ()),e===`hooks`&&(yJ(),_J()),e===`trace`&&wV(),e!==`settings`&&h9(),e===`settings`&&!location.hash.startsWith(`#settings/`)&&k1(),F9(e)},headerControls:[H(document,`.header-title`,`h1`),H(document,`#status-indicator`,`div`),H(document,`#btn-add-session-header`,`button`),H(document,`#btn-help`,`button`),u9,f9]});function G9(e){if(e===`phone`){let e=MU();pW(),qM(),BM(),Z7(),w2({sessionId:e??void 0});return}let t=j2();T2();let n=Hd();I9(M9(n)?n:`focus`,{persist:N9}),t&&sW(t)}Jd()&&G9(`phone`),Yd(G9),window.addEventListener(`hashchange`,tae);function K9(){f9.classList.remove(`open`),m9();let e=SH();af({title:`Restart Server`,message:e>0?`Kill ${e} session${e>1?`s`:``} and restart the server?`:`Restart the server?`,confirmLabel:`Restart`,danger:!1,onConfirm:()=>B({type:`restart-server`})})}function vae(e){let t=CH(),n=t.length;if(n===0){e(t);return}af({title:`Update and restart`,message:`Glimmervoid restarts once the update is staged, which kills ${n} running session${n>1?`s`:``}. Continue?`,confirmLabel:`Update and restart`,danger:!1,onConfirm:()=>e(t)})}H(document,`#btn-restart`,`button`).addEventListener(`click`,K9);function yae(e){let t=QM(`shutdown`,e);H(document,`#btn-shutdown`,`button`).hidden=!t,H(document,`#menu-divider-shutdown`,`div`).hidden=!t}H(document,`#btn-shutdown`,`button`).addEventListener(`click`,()=>{f9.classList.remove(`open`),m9();let e=SH();af({title:`Shut Down Server`,message:e>0?`Kill ${e} session${e>1?`s`:``} and shut down the server?`:`Shut down the server?`,confirmLabel:`Shut Down`,danger:!0,onConfirm:()=>B({type:`shutdown`})})});function bae(){let e=document.activeElement;return e instanceof HTMLElement?e.isContentEditable?!0:(e.tagName===`INPUT`||e.tagName===`TEXTAREA`)&&!e.classList.contains(`xterm-helper-textarea`):!1}function xae({action:e,step:t}){switch(e){case`merge`:return Tz(),!0;case`resolve-or-resync`:return Ez()||Dz(),!0;case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`next-attention`:return Hd()===`calm`?FM():AU()?(XU(),!0):!1;case`rail-step`:return AU()?(uW(t),!0):!1;case`view-step`:return!Jd()&&(_ae(V9(Hd(),t)),!0);case`session-nth`:return AU()?(lW(t),!0):!1;case`calm-home`:return!Jd()&&(I9(`calm`),!0);case`calm-terminal`:return PM()}}$te(()=>({isCalmAvailable:X7,isCalmViewActive:Hd()===`calm`})),document.addEventListener(`keydown`,e=>{if(e.repeat||bae())return;let t=Ky(e,Zy,$y());t&&xae(t)&&e.preventDefault()});var q9=null;function J9(){q9!==null&&clearTimeout(q9),q9=setTimeout(()=>{B({type:`focus-change`,focused:document.hasFocus()})},150)}function Y9(){J9(),EE(Qd($M()))}window.addEventListener(`focus`,Y9),window.addEventListener(`blur`,Y9),document.addEventListener(`visibilitychange`,Y9);var X9=!1,Z9=null;function Sae(){if(document.visibilityState!==`visible`)return 0;let e=Z9;return Z9=null,e===null?0:Date.now()-e}async function Q9(){let e=Sae();if(!X9){X9=!0,gE();try{if(await hd(e)===`ok`)return;for(let e of U.keys())vE(e)}finally{_E(),X9=!1}}}document.addEventListener(`visibilitychange`,()=>{if(document.visibilityState!==`visible`){Z9??=Date.now();return}ZT(),Q9()}),window.addEventListener(`online`,Q9);var $9=aN(B);window.addEventListener(`error`,e=>$9(e.error)),window.addEventListener(`unhandledrejection`,e=>$9(e.reason)),window.addEventListener(`pageshow`,e=>{e.persisted&&(ZT(),Q9())}),hI(H(document,`#health-footer-mount`,`div`)),jJ(),md();
|