glimmervoid 0.38.0 → 0.38.2

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.
Files changed (37) hide show
  1. package/dist/bin/glimmervoid.js +17 -15
  2. package/dist/chunks/{adapters-B-IkWl-r.js → adapters-CAHxZYT3.js} +4 -4
  3. package/dist/chunks/{adapters-Dt3vwxwY.js → adapters-DDjC7_vG.js} +1 -1
  4. package/dist/chunks/{agent-api-cli-BcZ9DLCF.js → agent-api-cli-B5Tm0wXO.js} +27 -8
  5. package/dist/chunks/{agent-api-cli-3hryuewm.js → agent-api-cli-BDu1CxZf.js} +1 -1
  6. package/dist/chunks/{agent-api-core--8WtU1xU.js → agent-api-core-B_mUSenR.js} +36 -4
  7. package/dist/chunks/{agent-setup-cli-BixDoCkF.js → agent-setup-cli-DmMfCw5O.js} +1 -1
  8. package/dist/chunks/{config-BHBZsCBc.js → browser-config-BrBT8269.js} +2 -217
  9. package/dist/chunks/config-CjawSOBk.js +219 -0
  10. package/dist/chunks/{config-store-DbfMbz4j.js → config-store-BUNZs4j7.js} +4 -3
  11. package/dist/chunks/config-store-MAVQhGMh.js +1 -0
  12. package/dist/chunks/{contracts-u40eJhaf.js → contracts-HVCEJfxs.js} +6 -239
  13. package/dist/chunks/factory-D7ryES9n.js +240 -0
  14. package/dist/chunks/{git-version-BpnTd8sU.js → git-version-rWZjF2Px.js} +1 -1
  15. package/dist/chunks/{grok-xFs6zIu4.js → grok-B6bsCgdd.js} +2 -2
  16. package/dist/chunks/{hook-tools-BkxllUHE.js → hook-tools-Dl7-r2Eb.js} +1 -1
  17. package/dist/chunks/{knowledge-graph-cli-DcspNqhz.js → knowledge-graph-cli-ByUJoKw_.js} +1 -1
  18. package/dist/chunks/{main-w01-P1oZ.js → main-BNSbP-Yk.js} +689 -523
  19. package/dist/chunks/{pair-cli-BdoyrDCr.js → pair-cli-DNp8i5L4.js} +2 -2
  20. package/dist/chunks/{remote-config-61zJ0hME.js → remote-config-C_s2pnLC.js} +1 -1
  21. package/dist/chunks/{rtk-hook-core-VrUafGAp.js → rtk-hook-core-B-MpzPin.js} +89 -83
  22. package/dist/chunks/rtk-resolver-BGE6Hd_L.js +1 -0
  23. package/dist/chunks/{rtk-resolver-C_micGrL.js → rtk-resolver-BgoPsEhT.js} +1 -1
  24. package/dist/chunks/{session-8Pv0y1vz.js → session-BlT68ppa.js} +5 -2
  25. package/dist/chunks/{session-routes-D-GZC-Sy.js → session-routes-CT1JrjoT.js} +1 -1
  26. package/dist/chunks/{settings-cli-DKJsm3AP.js → settings-cli-BbzxCyG5.js} +3 -3
  27. package/dist/chunks/{ssh-sign-cli-Dc2gOCwE.js → ssh-sign-cli-C74BGTQS.js} +2 -2
  28. package/dist/client/assets/index-B5uVtedd.css +1 -0
  29. package/dist/client/assets/index-b13-NGGS.js +275 -0
  30. package/dist/client/index.html +3 -2
  31. package/dist/server/index.js +1 -1
  32. package/dist/session/hook-tool-relay.js +1 -1
  33. package/package.json +3 -2
  34. package/dist/chunks/config-store-DYj3wYgw.js +0 -1
  35. package/dist/chunks/rtk-resolver-B8BPgN9L.js +0 -1
  36. package/dist/client/assets/index-BfqmOGgc.js +0 -275
  37. package/dist/client/assets/index-DxABp5yJ.css +0 -1
@@ -0,0 +1,275 @@
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)}})();function e(e){return e===`remote`?`remote`:`local`}function t(t,n){return e(n)===`local`||t!==`shutdown`}var n=Object.freeze({setTimeoutFn:(e,t)=>setTimeout(e,t),clearTimeoutFn:e=>clearTimeout(e),setIntervalFn:(e,t)=>setInterval(e,t),clearIntervalFn:e=>clearInterval(e)});function r(e){return typeof e!=`object`||!e||!(`unref`in e)||typeof e.unref!=`function`||e.unref(),e}function i({mode:e,delayMs:t,run:i,setTimeoutFn:a=n.setTimeoutFn,clearTimeoutFn:o=n.clearTimeoutFn,unref:s=!0}){let c=null;function l(){c&&=(o(c),null)}function u(){e===`leading`&&c||(l(),c=a(()=>{c=null,i()},t),s&&r(c))}return{schedule:u,cancel:l,get isArmed(){return c!==null}}}var a=Object.freeze({DORMANT:`DORMANT`,INITIALIZING:`INITIALIZING`,STARTING:`STARTING`,RUNNING:`RUNNING`,WAITING:`WAITING`,IDLE:`IDLE`,COMPLETE:`COMPLETE`,DONE:`DONE`,FAILED:`FAILED`}),o=Object.freeze({[a.DORMANT]:`Dormant`,[a.INITIALIZING]:`Preparing`,[a.STARTING]:`Starting`,[a.RUNNING]:`Working`,[a.WAITING]:`Needs Input`,[a.IDLE]:`Idle`,[a.COMPLETE]:`Complete`,[a.DONE]:`Exited`,[a.FAILED]:`Failed`}),s=Object.freeze({[a.DORMANT]:`○`,[a.INITIALIZING]:`◌`,[a.STARTING]:`◐`,[a.RUNNING]:`●`,[a.WAITING]:`◆`,[a.IDLE]:`◍`,[a.FAILED]:`▲`,[a.DONE]:`■`,[a.COMPLETE]:`◇`}),c=Object.freeze([a.INITIALIZING,a.STARTING,a.RUNNING,a.WAITING,a.IDLE,a.COMPLETE]),l=Object.freeze([a.DONE,a.FAILED]),u=Object.freeze([a.WAITING,a.IDLE,a.COMPLETE]);function d(e){return`Git tracks an old Glimmervoid post-turn report in ${e===1?`1 repository`:`${e} repositories`}. Nothing reads it, so run this to stop git tracking it and commit the deletion git then shows. Glimmervoid deletes the file itself on its next start:`}function f(e,t){return!e||e.toLowerCase().endsWith(`[bot]`)?null:`https://avatars.githubusercontent.com/${encodeURIComponent(e)}?s=${t*2}`}function p(e){return e.match(/[a-z0-9]/i)?.[0]?.toUpperCase()??`?`}function m(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n!=null&&(r.textContent=n),r}function h(e,t,n){let r=m(e,t);return r.innerHTML=n,r}function g(e,t){for(let[n,r]of t)e.style.setProperty(n,r)}function _({login:e,url:t,cssPx:n}){let r=m(`span`,`avatar`);r.style.width=`${n}px`,r.style.height=`${n}px`;let i=()=>m(`span`,`avatar-monogram`,p(e)),a=t===void 0?f(e,n):t;if(!a)return r.append(i()),r;let o=m(`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 v(e,t){let n=m(`span`,`avatar-stack`);for(let r of e){let e=_({login:r.login,url:r.url,cssPx:t});e.title=r.title,e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,r.title);let i=m(`span`,`avatar-badge`);i.dataset.tone=r.tone,e.append(i),n.append(e)}return n}function y(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 b(e,t){let n=e.querySelector(t);if(!(n instanceof HTMLElement))throw Error(`${t} matches no element`);return n}function x(e,t,n,r=t){if(!n){let n=m(`span`,e,t);return n.title=r,n}let i=m(`a`,e,t);return i.title=r,i.href=n,i.target=`_blank`,i.rel=`noopener`,i}var S={parked:`PARKED`,merging:`MERGING`};function C(e,t){return e===a.RUNNING&&t===!0}function ee(e,t=!1){let n=e,r=C(e,t),i=r?`Monitoring`:o[n]||e;return{glyph:s[n]||``,label:i.toUpperCase(),isMonitoring:r}}function te(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 ne(e,t,n){let r=m(`section`,`${e}-section`),i=m(`div`,`${e}-section-head`);return i.append(m(`h2`,`${e}-section-title`,t)),n&&i.append(m(`span`,`${e}-section-hint`,n)),r.append(i),r}function w(e,t,n,r){let i=m(`span`,`${e}-stat`);return r&&(i.dataset.tone=r),i.append(m(`span`,`${e}-stat-value`,n),m(`span`,`${e}-stat-label`,t)),i}function re(e){return Array.isArray(e?.projects)?e.projects:[]}function T(e){return!e||!!e.closest(`[hidden]`)}function ie(e){return navigator.clipboard?.writeText?navigator.clipboard.writeText(e):null}function ae(e,t){e&&t&&e.parentElement!==t&&(e._adoptHome||={parent:e.parentElement,next:e.nextElementSibling},t.appendChild(e))}function oe(e,t=null){let n=e?._adoptHome;n&&(delete e._adoptHome,n.parent?.isConnected?n.next&&n.next.parentElement===n.parent?n.parent.insertBefore(e,n.next):n.parent.appendChild(e):t&&t.appendChild(e))}var E=new Map;function D(e){return e.card?.dataset.session||e.nameEl?.textContent||``}function O(e){return typeof e==`string`?e:String(e)}function k(e){return typeof e==`string`?E.get(e):void 0}var se=document.getElementById(`sessions-container`),ce=document.getElementById(`aggregate-status`),le=Object.freeze({layout:`desktop`,activeView:`focus`,phoneScreen:null,focusedSessionId:null,selectedSessionId:null,borrowedCardId:null}),ue=e=>e||null,de=Object.freeze({setLayout:e=>({layout:e}),setActiveView:e=>({activeView:e}),setPhoneScreen:e=>({phoneScreen:ue(e)}),focusSession:e=>({focusedSessionId:ue(e)}),selectSession:e=>({selectedSessionId:ue(e)}),borrowCard:e=>({borrowedCardId:ue(e)})});function fe(e){let t=Object.freeze({...le,...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 le))throw Error(`ui-state: unknown key "${r}"`);Object.is(t[r],e[r])||n.push(r)}return n}function o(e,r){let i=de[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 pe=fe(),me=()=>pe.snapshot().activeView;function he(){return pe.snapshot().borrowedCardId}function ge(e,t,n,{className:r}={}){if(!e?.card||!n)return;let i=he();i&&i!==t&&_e();let a=e.card;a._cardHostClass&&a._cardHostClass!==r&&a.classList.remove(a._cardHostClass),a._cardHostClass=r||``,r&&a.classList.add(r),ae(a,n),pe.dispatch(`borrowCard`,t),e._ensureTerminalReady?.(),e._setBorrowed?.(!0),e._showPreferredFace?.()}function _e(){let e=he();if(pe.dispatch(`borrowCard`,null),!e)return null;let t=E.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,oe(n,se)),e}function ve(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 ye(e,t=`|`){return e.map(e=>Ge(e)).join(t)}function be(e,t){return typeof t==`bigint`?t.toString():t}var xe=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 Se(e){return new xe(e)}function Ce(e){return e==null}function we(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Te(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 Ee(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function De(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Oe(e){return De(e._zod.def)??e._zod.def.shape}function ke(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Ee(this,t,e),e},enumerable:!0,configurable:!0})}function Ae(e,t,n){t in e?Ee(e,t,n):e[t]=n}function je(e,t,n,r){let i=Oe(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?ke(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Ae(e,a,r?r(n.value,a):n.value))}}function Me(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?ke(e,n,()=>t[n]):Ae(e,n,r.value))}}function Ne(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Pe(e){return JSON.stringify(e)}function Fe(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Ie=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Le(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Re=Se(()=>{if(Ft.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function ze(e){if(Le(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Le(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Be(e){return ze(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Ve=new Set([`string`,`number`,`symbol`]),He=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function Ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function We(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function A(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 Ke(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var qe={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Je={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Ye(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 je(i,e,Xe(e,t)),We(e,Ne(n,{shape:i,checks:[]}))}function Xe(e,t){let n=Oe(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 Ze(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 je(a,e,Reflect.ownKeys(Oe(e)).filter(e=>!i.has(e))),We(e,Ne(n,{shape:a,checks:[]}))}function Qe(e,t){if(!ze(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Oe(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 We(e,Ne(e._zod.def,{shape:$e(e,t)}))}function $e(e,t){let n={};return je(n,e,Reflect.ownKeys(Oe(e))),Me(n,t),n}function et(e,t){if(!ze(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return We(e,Ne(e._zod.def,{shape:$e(e,t)}))}function tt(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 je(n,e,Reflect.ownKeys(Oe(e))),je(n,t,Reflect.ownKeys(Oe(t))),We(e,Ne(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function nt(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 je(o,t,Reflect.ownKeys(Oe(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),We(t,Ne(t._zod.def,{shape:o,checks:[]}))}function rt(e,t,n){let r=n?new Set(Xe(t,n)):void 0,i={};return je(i,t,Reflect.ownKeys(Oe(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),We(t,Ne(t._zod.def,{shape:i}))}function it(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 at(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 ot(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function st(e){return typeof e==`string`?e:e?.message}function ct(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function lt(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function ut(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:st(e.inst?._zod.def?.error?.(e))??st(a?.(e))??st(t?.error?.(e))??st(n.customError?.(e))??st(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 dt=/[\uD800-\uDBFF]/;function ft(e){let t=e.length;if(!dt.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 pt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function mt(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 ht(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function gt(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):bt(e,n,r.value)}}function _t(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function vt(e,t,n){return _t(e,t,n,!1)}function yt(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return _t(this,n,r(this))},set(e){_t(this,n,e)}})}return t}function bt(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:_t(this,t,n.bind(this))},set(e){_t(this,t,e)}})}function xt(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var St,Ct=!1,wt={configurable:!0,get(){Ct=!0}};function Tt(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&St!==e._zod?St=void 0:(St=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,wt);let e=Ct;Ct=!1;try{let r=n(this);return Ct?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Ct||=e,r}catch(n){throw delete this[t],Ct||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Et(e,t,n,r){let i=xt(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 Dt=`~constantCatch`;function Ot(e){let t=()=>e;return t[Dt]=!0,t}var kt,At={value:void 0,enumerable:!1},jt=`captureStackTrace`in Error?Error:null;function Mt(e){let t=jt;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return jt=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function j(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){At.value=new a(r);try{Object.defineProperty(n,"_zod",At)}finally{At.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),gt(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?Mt(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 Nt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Pt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(kt=globalThis).__zod_globalConfig??(kt.__zod_globalConfig={});var Ft=globalThis.__zod_globalConfig;function It(e){return e&&Object.assign(Ft,e),Ft}function eee(){let e=this._zod;return e.message??=JSON.stringify(e.def,be,2),e.message}function Lt(e){this._zod.message=e}var Rt={get:eee,set:Lt,enumerable:!0,configurable:!0},zt={value:void 0,enumerable:!1},Bt=new WeakSet([Object.prototype,Error.prototype]),Vt=(e,t)=>{e.name=`$ZodError`,zt.value=t,Object.defineProperty(e,"issues",zt),zt.value=void 0,Object.defineProperty(e,"message",Rt);let n=Object.getPrototypeOf(e);Bt.has(n)||(Bt.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})}}))},tee=j(`$ZodError`,Vt);j(`$ZodError`,Vt,void 0,{Parent:Error});function nee(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 ree(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?nee(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function iee(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 Ht(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ut=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 Nt;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>ut(e,o,It())));throw Ie(n,a?.callee??t),n}return s.value};return t},Wt=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=>ut(e,o,It())));throw Ie(n,a?.callee??t),n}return s.value};return t},Gt=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 Nt;return a.issues.length?Kt(e,a.issues,i):{success:!0,data:a.value}};function Kt(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>ut(e,n,It()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var qt=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?Kt(e,a.issues,i):{success:!0,data:a.value}},aee=Symbol.for(`zod.compile.invalid`),oee=Symbol.for(`zod.compile.fallback`),see=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==aee)return!0;if(r.definite===!0&&n===void 0)return!1}return Jt(e,t,n)});function Jt(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[oee]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Nt;return a.issues.length===0}var cee=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},Yt=e=>{let t=Ut(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Ht(n,a))};return n},Xt=e=>{let t=Ut(e),n=(e,r,i,a)=>t(e,r,i,Ht(n,a));return n},lee=e=>{let t=Wt(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Ht(n,a))};return n},uee=e=>{let t=Wt(e),n=async(e,r,i,a)=>await t(e,r,i,Ht(n,a));return n},dee=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Gt(e)(t,n,i)},fee=e=>(t,n,r)=>Gt(e)(t,n,r),Zt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return qt(e)(t,n,i)},Qt=e=>async(t,n,r)=>qt(e)(t,n,r),$t=/^[cC][0-9a-z]{6,}$/,en=/^[0-9a-z]+$/,tn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,nn=/^[0-9a-vA-V]{20}$/,rn=/^[A-Za-z0-9]{27}$/,pee=/^[a-zA-Z0-9_-]{21}$/;function mee(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var hee=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gee=/^([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})$/,an=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)$/,_ee=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,vee=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function yee(){return new RegExp(vee,`u`)}var on=/^(?:(?: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])$/,sn=/^(([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}|:))$/,cn=/^((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])$/,ln=/^(([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])$/,un=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,dn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,fn=/^https?$/,pn=/^\+[1-9]\d{6,14}$/,mn=`(?:(?:\\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 hn(e){return RegExp(`^${e}$`)}var gn=hn(mn);function _n(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 vn(e){return RegExp(`^${_n(e)}$`)}function yn(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${_n({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${_n({precision:e.precision})}`:n;return RegExp(`^${mn}T(?:${r})$`)}var bn=/^[\s\S]{0,}$/,xn=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Sn=/^-?\d+$/,Cn=/^-?\d+(?:\.\d+)?$/,wn=/^(?:true|false)$/i,Tn=/^null$/i,En=/^[^A-Z]*$/,Dn=/^[^a-z]*$/,On=j(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),kn=e=>{let t=e.value;return!Ce(t)&&t.length!==void 0},An={number:`number`,bigint:`bigint`,object:`date`},jn=j(`$ZodCheckLessThan`,(e,t)=>{On.init(e,t);let n=An[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:An[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=j(`$ZodCheckGreaterThan`,(e,t)=>{On.init(e,t);let n=An[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:An[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})}}),bee=j(`$ZodCheckMultipleOf`,(e,t)=>{On.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):Te(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})}}),xee=j(`$ZodCheckNumberFormat`,(e,t)=>{On.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=qe[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})}}),See=j(`$ZodCheckMaxLength`,(e,t)=>{var n;On.init(e,t),(n=e._zod.def).when??(n.when=kn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?ft(r):i)<=t.maximum)return;let a=pt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Cee=j(`$ZodCheckMinLength`,(e,t)=>{var n;On.init(e,t),(n=e._zod.def).when??(n.when=kn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?ft(r):i)>=t.minimum)return;let a=pt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),wee=j(`$ZodCheckLengthEquals`,(e,t)=>{var n;On.init(e,t),(n=e._zod.def).when??(n.when=kn),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?ft(r):i;if(a===t.length)return;let o=pt(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})}}),Nn=j(`$ZodCheckStringFormat`,(e,t)=>{var n,r;On.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=()=>{})}),Tee=j(`$ZodCheckRegex`,(e,t)=>{Nn.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})}}),Eee=j(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=En,Nn.init(e,t)}),Dee=j(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Dn,Nn.init(e,t)}),Oee=j(`$ZodCheckIncludes`,(e,t)=>{On.init(e,t);let n=Ue(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})}}),kee=j(`$ZodCheckStartsWith`,(e,t)=>{On.init(e,t);let n=RegExp(`^${Ue(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})}}),Aee=j(`$ZodCheckEndsWith`,(e,t)=>{On.init(e,t);let n=RegExp(`.*${Ue(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})}}),jee=j(`$ZodCheckOverwrite`,(e,t)=>{On.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Mee=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))}},Nee={major:4,minor:6,patch:7},Pn=j(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Nee;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=it(t),a;for(let o of n){if(o._zod.def.when){if(at(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 Nt;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(lt(t.issues,n,e),i||=it(t,n))});else{if(t.issues.length===n)continue;lt(t.issues,n,e),i||=it(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(it(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Nt;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 Nt;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return vt(this,`~standard`,In(this))},set"~standard"(e){_t(this,`~standard`,e)}}),Fn=(e,t)=>e.issues.length?{issues:e.issues.map(e=>ut(e,t,It()))}:{value:e.value};async function Pee(e,t){let n={async:!0};return Fn(await e._zod.run({value:t,issues:[]},n),n)}function In(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Fn(r,n)}catch{}return Pee(e,t)},vendor:`zod`,version:1}}var Ln=j(`$ZodString`,(e,t)=>{Pn.init(e,t),e._zod.pattern=t.pattern??bn,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}}),Rn=j(`$ZodStringFormat`,(e,t)=>{Nn.init(e,t),Ln.init(e,t)}),Fee=j(`$ZodGUID`,(e,t)=>{t.pattern??=gee,Rn.init(e,t)}),Iee=j(`$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??=an(e)}else t.pattern??=an();Rn.init(e,t)}),Lee=j(`$ZodEmail`,(e,t)=>{t.pattern??=_ee,Rn.init(e,t)});function zn(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Ree(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?zn(e)||2:zee(e,t)}function zee(e,t){if(!t.normalize&&t.protocol?.source===fn.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 Bee=/[\t\n\r]/g;function Bn(e){return e.replace(Bee,``)}function Vn(e,t){return t.lastIndex=0,t.test(e.hostname)}function Hn(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var Un=j(`$ZodURL`,(e,t)=>{Rn.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Ree(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=Bn(r);return}t.hostname&&!Vn(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&&!Hn(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:Bn(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Wn=j(`$ZodEmoji`,(e,t)=>{t.pattern??=yee(),Rn.init(e,t)}),Gn=j(`$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?pee:mee(t.length),Rn.init(e,t)}),Kn=j(`$ZodCUID`,(e,t)=>{t.pattern??=$t,Rn.init(e,t)}),qn=j(`$ZodCUID2`,(e,t)=>{t.pattern??=en,Rn.init(e,t)}),Jn=j(`$ZodULID`,(e,t)=>{t.pattern??=tn,Rn.init(e,t)}),Yn=j(`$ZodXID`,(e,t)=>{t.pattern??=nn,Rn.init(e,t)}),Xn=j(`$ZodKSUID`,(e,t)=>{t.pattern??=rn,Rn.init(e,t)}),Zn=j(`$ZodISODateTime`,(e,t)=>{t.pattern??=yn(t),Rn.init(e,t)}),Qn=j(`$ZodISODate`,(e,t)=>{t.pattern??=gn,Rn.init(e,t)}),$n=j(`$ZodISOTime`,(e,t)=>{t.pattern??=vn(t),Rn.init(e,t)}),er=j(`$ZodISODuration`,(e,t)=>{t.pattern??=hee,Rn.init(e,t)}),tr=j(`$ZodIPv4`,(e,t)=>{t.pattern??=on,Rn.init(e,t)}),nr=/^[0-9a-fA-F:.]+$/;function rr(e){return nr.test(e)?zn(`http://[${e}]`):!1}var ir=j(`$ZodIPv6`,(e,t)=>{t.pattern??=sn,Rn.init(e,t),e._zod.check=n=>{rr(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),ar=j(`$ZodCIDRv4`,(e,t)=>{t.pattern??=cn,Rn.init(e,t)});function or(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:rr(n)}var sr=j(`$ZodCIDRv6`,(e,t)=>{t.pattern??=ln,Rn.init(e,t),e._zod.check=n=>{or(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function cr(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var lr=/^[0-9a-zA-Z+/]*={0,2}$/,ur=j(`$ZodBase64`,(e,t)=>{t.pattern??=lr,Rn.init(e,t),e._zod.check=n=>{cr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),dr=/^[A-Za-z0-9_-]*$/;function fr(e){if(!dr.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return cr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var pr=j(`$ZodBase64URL`,(e,t)=>{t.pattern??=dr,Rn.init(e,t),e._zod.check=n=>{fr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),mr=j(`$ZodE164`,(e,t)=>{t.pattern??=pn,Rn.init(e,t)});function hr(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 gr=j(`$ZodJWT`,(e,t)=>{Rn.init(e,t),e._zod.check=n=>{hr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),_r=j(`$ZodNumber`,(e,t)=>{Pn.init(e,t),e._zod.pattern=Cn,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}}),vr=j(`$ZodNumberFormat`,(e,t)=>{xee.init(e,t),_r.init(e,t)}),yr=j(`$ZodBoolean`,(e,t)=>{Pn.init(e,t),e._zod.pattern=wn,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}}),br=j(`$ZodNull`,(e,t)=>{Pn.init(e,t),e._zod.pattern=Tn,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),xr=j(`$ZodUnknown`,(e,t)=>{Pn.init(e,t),e._zod.parse=e=>e}),Sr=j(`$ZodNever`,(e,t)=>{Pn.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Cr(e,t){let n=ct(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of ct(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,lt(n.issues,t,e),n}}return i(n,a)}}var wr=e=>Array.isArray(e)?e.length:-1;function Tr(e,t,n){e.issues.length&&t.issues.push(...ot(n,e.issues)),t.value[n]=e.value}var Er=j(`$ZodArray`,(e,t)=>{Pn.init(e,t);let n=Ft.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=>Tr(t,r,e)));else if(Tr(c,r,e),s&&c.issues.length!==0&&it(c))break}return o.length?Promise.all(o).then(()=>r):r},Cr(e,wr)});function Dr(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(...ot(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var Or=[];function kr(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Or,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=Ke(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Ar(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(it(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=>Dr(e,n,i,t,d,f))):Dr(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 jr=j(`$ZodObject`,(e,t)=>{Pn.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=Se(()=>kr(t));Tt(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)||Ee(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=Le,o=t.catchall,s,c=Ft.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(it(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=>Dr(n,t,e,r,a,o))):Dr(s,t,e,r,a,o)}return o?Ar(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Mr=j(`$ZodObjectJIT`,(e,t)=>{jr.init(e,t);let n=e._zod.parse,r=Se(()=>kr(t)),i=Ft.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Mee([`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)}]`:Pe(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=Le,c=!Ft.jitless,l=c&&Re.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?Ar([],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 Nr(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=>!it(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=>ut(e,r,It())))}),t)}var Pr=j(`$ZodUnion`,(e,t)=>{Pn.init(e,t),Tt(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),Tt(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Tt(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)))}),Tt(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=>we(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=>Nr(t,r,e,i)):Nr(o,r,e,i)}});function Fr(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 Ir=j(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Pr.init(e,t);let n=e._zod.parse;Tt(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)||Ee(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=De(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=Se(()=>Fr(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Le(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)}}),Lr=j(`$ZodIntersection`,(e,t)=>{Pn.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])=>zr(e,t,n)):zr(e,i,a)}});function Rr(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ze(e)&&ze(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=Rr(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=Rr(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 zr(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=Rr(t.value,n.value);if(!c.valid){if(it(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Br=j(`$ZodRecord`,(e,t)=>{Pn.init(e,t);let n=Ft.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!ze(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=>ut(e,i,It())),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(...ot(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...ot(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`&&Cn.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=>ut(e,i,It())),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(...ot(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...ot(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}}),Vr=j(`$ZodEnum`,(e,t)=>{Pn.init(e,t);let n=ve(t.entries),r=new Set(n);e._zod.values=r,Tt(e,`pattern`,e=>{let t=ve(e.def.entries).filter(e=>Ve.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Ue(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}}),Hr=j(`$ZodLiteral`,(e,t)=>{Pn.init(e,t);let n=new Set(t.values);e._zod.values=n,Tt(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?Ue(e):e?Ue(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}}),Ur=j(`$ZodTransform`,(e,t)=>{Pn.init(e,t),e._zod.optin=`optional`,Ft.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Pt(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 Nt;return n.value=i,n}});function Wr(e,t){return e.value=t.issues.length?void 0:t.value,e}var Gr=j(`$ZodOptional`,(e,t)=>{Pn.init(e,t),Tt(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,Tt(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),Tt(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${we(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=>Wr(e,t)):Wr(e,r)}return t.innerType._zod.run(e,n)}}),Kr=j(`$ZodExactOptional`,(e,t)=>{Gr.init(e,t),Tt(e,`values`,e=>e.def.innerType._zod.values),Tt(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),qr=j(`$ZodNullable`,(e,t)=>{Pn.init(e,t),Tt(e,`optin`,e=>e.def.innerType._zod.optin),Tt(e,`optout`,e=>e.def.innerType._zod.optout),Tt(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${we(t.source)}|null)$`):void 0}),Tt(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)}),Jr=j(`$ZodDefault`,(e,t)=>{Pn.init(e,t),e._zod.optin=`defaulted`,Tt(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=>Yr(e,t)):Yr(r,t)}});function Yr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Vee=j(`$ZodPrefault`,(e,t)=>{Pn.init(e,t),e._zod.optin=`defaulted`,Tt(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))}),Hee=j(`$ZodNonOptional`,(e,t)=>{Pn.init(e,t),Tt(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=>Xr(t,e)):Xr(i,e)}});function Xr(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 Zr(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>ut(e,r,It()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Uee=j(`$ZodCatch`,(e,t)=>{Pn.init(e,t),Tt(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),Tt(e,`optout`,e=>e.def.innerType._zod.optout),Tt(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=>Zr(e,r,t,n)):Zr(e,r,t,n)}}),Qr=j(`$ZodPipe`,(e,t)=>{Pn.init(e,t),Tt(e,`values`,e=>e.def.in._zod.values),Tt(e,`optin`,e=>e.def.in._zod.optin),Tt(e,`optout`,e=>e.def.out._zod.optout),Tt(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=>$r(e,t.in,n)):$r(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>$r(e,t.out,n)):$r(r,t.out,n)}});function $r(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 Wee=j(`$ZodPreprocess`,(e,t)=>{Qr.init(e,t)}),Gee=j(`$ZodReadonly`,(e,t)=>{Pn.init(e,t),Tt(e,`propValues`,e=>e.def.innerType._zod.propValues),Tt(e,`values`,e=>e.def.innerType._zod.values),Tt(e,`optin`,e=>e.def.innerType?._zod?.optin),Tt(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(ei):ei(r)}});function ei(e){return e.memo||(e.value=Object.freeze(e.value)),e}function Kee(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 xn({minimum:i,maximum:a}).source;let o=e._zod.pattern;return(r&&o===Cn?Sn:o)?.source}function ti(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=ti(r);return n&&e&&t&&t!==e?n.replace(we(e),()=>we(t)):n}if(t.options){let e=t.options.map(ti);if(e.every(Boolean))return`^(${e.map(e=>we(e)).join(`|`)})$`}return Kee(e)}var qee=j(`$ZodTemplateLiteral`,(e,t)=>{Pn.init(e,t);let n=[];for(let e of t.parts)if(typeof e==`object`&&e){let t=ti(e);if(!t)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);n.push(we(t))}else if(e===null||He.has(typeof e))n.push(Ue(`${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)}),Jee=j(`$ZodCustom`,(e,t)=>{On.init(e,t),Pn.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=>ni(t,n,r,e));ni(i,n,r,e)}});function ni(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(ht(e))}}var Yee=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},ri=`~memo`,ii=[];function ai(e){return typeof e==`object`&&!!e}function oi(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var si=new WeakMap,ci=0,li=1,ui=2;function di(e,t,n){let r=si.get(e);if(r!==void 0)return r?ui:ci;if(t.has(e))return ui;t.add(e);let i=ci,a=e=>{if(i!==ui&&e?._zod){let r=di(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=ci;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?li:o.value?._zod?di(o.value,t,n):ci;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=De(c);s(e?o(e,!0):li),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?di(r,t,!1):li);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),Xee(e,i)}function Xee(e,t){return t!==li&&si.set(e,t===ui),t}function Zee(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var fi,pi=[],Qee={alloc(e,t,n){let r=fi;if(!r)return n;fi=void 0;let i={value:n,issues:null};return r.set(t.value,i),pi.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`&&ete(n,e.value))throw new Yee;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=di(e,new Set,!1);if(i===ci)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===ui||r?n=!0:r=!0}let l=s.value;if(!ai(l))return t(s,c);let u=c[ri];u||(u={buckets:new WeakMap,backEdges:void 0},c[ri]=u);let d;i===c?d=a:(d=Zee(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(...oi(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;fi=d;let p=pi.length,m=t(s,c);fi=void 0;let h=pi.length>p?pi.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?oi(e.issues):ii),e)):(h&&(h.issues=m.issues.length?oi(m.issues):ii),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function $ee(){return Qee}function ete(e,t){let n=e[ri]?.backEdges;return n!==void 0&&ai(t)&&n.has(t)}var tte=()=>{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(mt(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Ge(e.values[0])}`:`Invalid option: expected one of ${ye(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`:``}: ${ye(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 nte(){return{localeError:tte()}}var mi,rte=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 ite(){return new rte}(mi=globalThis).__zod_globalRegistry??(mi.__zod_globalRegistry=ite());var hi=globalThis.__zod_globalRegistry;function gi(e){return e.checks&&=[...e.checks],e}function ate(e,t){return new e(gi({type:`string`,...A(t)}))}function ote(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...A(t)})}function ste(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...A(t)})}function cte(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...A(t)})}function lte(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...A(t)})}function ute(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...A(t)})}function dte(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...A(t)})}function _i(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...A(t)})}function fte(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...A(t)})}function pte(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...A(t)})}function mte(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...A(t)})}function hte(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...A(t)})}function gte(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...A(t)})}function _te(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...A(t)})}function vte(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...A(t)})}function yte(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...A(t)})}function bte(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...A(t)})}function xte(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...A(t)})}function Ste(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...A(t)})}function vi(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...A(t)})}function Cte(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...A(t)})}function wte(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...A(t)})}function Tte(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...A(t)})}function yi(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...A(t)})}function Ete(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...A(t)})}function Dte(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...A(t)})}function Ote(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...A(t)})}function kte(e,t){return new e(gi({type:`number`,checks:[],...A(t)}))}function Ate(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...A(t)})}function jte(e,t){return new e({type:`boolean`,...A(t)})}function Mte(e,t){return new e({type:`null`,...A(t)})}function Nte(e){return new e({type:`unknown`})}function Pte(e,t){return new e({type:`never`,...A(t)})}function bi(e,t){return new jn({check:`less_than`,...A(t),value:e,inclusive:!1})}function xi(e,t){return new jn({check:`less_than`,...A(t),value:e,inclusive:!0})}function Si(e,t){return new Mn({check:`greater_than`,...A(t),value:e,inclusive:!1})}function Ci(e,t){return new Mn({check:`greater_than`,...A(t),value:e,inclusive:!0})}function wi(e,t){return new bee({check:`multiple_of`,...A(t),value:e})}function Ti(e,t){return new See({check:`max_length`,...A(t),maximum:e})}function Ei(e,t){return new Cee({check:`min_length`,...A(t),minimum:e})}function Di(e,t){return new wee({check:`length_equals`,...A(t),length:e})}function Fte(e,t){return new Tee({check:`string_format`,format:`regex`,...A(t),pattern:e})}function Ite(e){return new Eee({check:`string_format`,format:`lowercase`,...A(e)})}function Lte(e){return new Dee({check:`string_format`,format:`uppercase`,...A(e)})}function Rte(e,t){return new Oee({check:`string_format`,format:`includes`,...A(t),includes:e})}function zte(e,t){return new kee({check:`string_format`,format:`starts_with`,...A(t),prefix:e})}function Bte(e,t){return new Aee({check:`string_format`,format:`ends_with`,...A(t),suffix:e})}function Oi(e){return new jee({check:`overwrite`,tx:e})}function Vte(e){return Oi(t=>t.normalize(e))}function Hte(){return Oi(e=>e.trim())}function Ute(){return Oi(e=>e.toLowerCase())}function ki(){return Oi(e=>e.toUpperCase())}function Ai(){return Oi(e=>Fe(e))}function ji(e,t,n){return new e({type:`array`,element:t,...A(n)})}function Mi(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...A(n)})}function Ni(e,t){let n=Wte(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(ht(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(ht(r))}},e(t.value,t)),t);return n}function Wte(e,t){let n=new On({check:`custom`,...A(t)});return n._zod.check=e,n}function Pi(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Ee(e,t,n[t]);return e}function Fi(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??hi,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 Ii(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 Li(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,Li(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Pi(o.schema,c),t.io===`input`&&qi(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 Ri(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function zi(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}/${Ri(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+Ri(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);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Bi(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;Bi(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 Vi=new Set([`type`,`properties`,`required`,`additionalProperties`]),Hi=[`oneOf`,`anyOf`];function Ui(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Wi(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Vi.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]??Ui(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Ee(n,r,e.length===1?e[0]:Wi(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=Ui(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 Gi(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Vi)if(t in e)return;let n=t.filter(e=>Hi.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Wi(t);else{let e=n[0],i=Hi.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=>Wi([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Pi(e,r))}function Ki(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)):Pi(i,s),Pi(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())Bi(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)??[])Gi(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)}Pi(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,Ee(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:Ji(t,`input`,e.processors),output:Ji(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function qi(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 qi(r.element,n);if(r.type===`set`)return qi(r.valueType,n);if(r.type===`lazy`)return qi(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 qi(r.innerType,n);if(r.type===`intersection`)return qi(r.left,n)||qi(r.right,n);if(r.type===`record`||r.type===`map`)return qi(r.keyType,n)||qi(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:qi(r.in,n)||qi(r.out,n);if(r.type===`object`){for(let e in r.shape)if(qi(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(qi(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(qi(e,n))return!0;return!!(r.rest&&qi(r.rest,n))}return!1}var Gte=(e,t={})=>n=>{let r=Fi({...n,processors:t});return Li(e,r),zi(r,e),Ki(r,e)},Ji=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Fi({...i??{},target:a,io:t,processors:n});return Li(e,o),zi(o,e),Ki(o,e)},Yi=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Xi=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Zi=(e,t)=>{Yi(e,`minimum`,t),Xi(e,`maximum`,t)},Qi=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},$i=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},ea=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},ta=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},na=(e,t)=>Yi(e,`minimum`,t.minimum),ra=(e,t)=>Xi(e,`maximum`,t.maximum),ia=e=>(t,n)=>{ta(t,n.format);let[r,i]=e[n.format];Yi(t,`minimum`,r),Xi(t,`maximum`,i)},aa={greater_than:(e,t)=>Yi(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Xi(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Qi(e,t.value),number_format:ia(qe),bigint_format:ia(Je),min_length:na,max_length:ra,length_equals:(e,t)=>Zi(e,t.length),min_size:na,max_size:ra,size_equals:(e,t)=>Zi(e,t.size),string_format:(e,t)=>{ta(e,t.format),t.pattern&&$i(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)=>ea(e,t.mime)};function oa(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)aa[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Yi(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Yi(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Xi(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Xi(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Qi(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&ea(t,i.mime);for(let e of i.patterns??[])$i(t,e);return t}var sa={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ca=new Map([[lr,un],[dr,dn]]),la=e=>ca.get(e)??e,ua=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=oa(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=sa[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(la);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}))])}},da=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=oa(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)):Ii(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}))])}},fa=(e,t,n,r)=>{n.type=`boolean`},pa=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},ma=(e,t,n,r)=>{n.not={}},ha=(e,t,n,r)=>{let i=e._zod.def,a=ve(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},ga=(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(Ii(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Ii(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}},_a=(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},va=(e,t,n,r)=>{Ii(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ya=(e,t,n,r)=>{Ii(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},ba=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=oa(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Li(a.element,t,{...r,path:[...r.path,`items`]})};function xa(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?xa(t.out):t.type===`catch`?xa(t.innerType):e._zod.optin}var Sa=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Ii(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Ee(i.properties,e,Li(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`?xa(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=Li(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ca=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Li(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},wa=(e,t,n,r)=>{let i=e._zod.def,a=Li(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Li(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 Ta(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=Ta(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=>Ta(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`)?Cn:Sn).source)),p}var Ea=new WeakMap;function Da(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 Ea.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Ta(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 Oa=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=oa(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Li(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Ee(i.patternProperties,la(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Li(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Ea.get(t);n||(n=[],Ea.set(t,n),t.deferred.push(()=>Da(t))),n.push(e)}i.additionalProperties=Li(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&xa(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))}},ka=(e,t,n,r)=>{let i=e._zod.def,a=Li(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`}]},Aa=(e,t,n,r)=>{let i=e._zod.def;Li(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ja=Symbol();function Ma(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Ii(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),ja):JSON.parse(o)}var Na=(e,t,n,r)=>{let i=e._zod.def;Li(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Ma(i.defaultValue,e,t,n,r);o!==ja&&(n.default=o)},Pa=(e,t,n,r)=>{let i=e._zod.def;Li(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Ma(i.defaultValue,e,t,n,r);o!==ja&&(n._prefault=o)},Fa=(e,t,n,r)=>{let i=e._zod.def;Li(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Ii(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Ia=(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;Li(o,t,r);let s=t.seen.get(e);s.ref=o},La=(e,t,n,r)=>{let i=e._zod.def;Li(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Ra=(e,t,n,r)=>{let i=e._zod.def;Li(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},za=new WeakSet([Object.prototype,Error.prototype]);function Ba(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 Va=j(`ZodError`,(e,t)=>{tee.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);za.has(n)||(za.add(n),Ba(n,`format`,e=>t=>iee(e,t)),Ba(n,`flatten`,e=>t=>ree(e,t)),Ba(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,be,2)}),Ba(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,be,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Ha=Ut(Va),Ua=Wt(Va),Wa=Gt(Va),Ga=qt(Va),Ka=Yt(Va),qa=Xt(Va),Ja=lee(Va),Ya=uee(Va),Xa=dee(Va),Kte=fee(Va),qte=Zt(Va),Jte=Qt(Va);function Yte(){Ft.localeError||It(nte())}function Za(){Ft.memoizer||It({memoizer:$ee()})}var Qa=j(`ZodType`,(e,t)=>(Yte(),Pn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Ne(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 We(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Xo(e,t))},superRefine(e,t){return this.check(Zo(e,t))},overwrite(e){return this.check(Oi(e))},optional(){return ko(this)},exactOptional(){return jo(this)},nullable(){return No(this)},nullish(){return ko(No(this))},nonoptional(e){return zo(this,e)},array(){return F(this)},or(e){return _o([this,e])},and(e){return xo(this,e)},transform(e){return Uo(this,Do(e))},default(e){return Fo(this,e)},prefault(e){return Lo(this,e)},catch(e){return Vo(this,e)},pipe(e){return Uo(this,e)},readonly(){return Ko(this)},describe(e){let t=this.clone();return hi.add(t,{description:e}),t},meta(...e){if(e.length===0)return hi.get(this);let t=this.clone();return hi.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 vt(this,`~standard`,{...In(this),jsonSchema:{input:Ji(this,`input`),output:Ji(this,`output`)}})},set"~standard"(e){_t(this,`~standard`,e)},parse:function e(t,n){return Ha(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ua(this,t,n,{callee:e})},safeParse(e,t){return Wa(this,e,t)},async safeParseAsync(e,t){return Ga(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){_t(this,`spa`,e)},validate(e,t){return see(this,e,t)},validateAsync(e,t){return cee(this,e,t)},encode:function e(t,n){return Ka(this,t,n,{callee:e})},decode:function e(t,n){return qa(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Ja(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Ya(this,t,n,{callee:e})},safeEncode(e,t){return Xa(this,e,t)},safeDecode(e,t){return Kte(this,e,t)},async safeEncodeAsync(e,t){return qte(this,e,t)},async safeDecodeAsync(e,t){return Jte(this,e,t)},toJSONSchema(e){return Gte(this,{})(e)},get description(){return hi.get(this)?.description},get _def(){return this._zod.def}}),$a=j(`_ZodString`,(e,t)=>{Ln.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ua(e,t,n,r)},yt({format:e=>oa(e).format??null,minLength:e=>oa(e).minimum??null,maxLength:e=>oa(e).maximum??null},{regex(...e){return this.check(Fte(...e))},includes(...e){return this.check(Rte(...e))},startsWith(...e){return this.check(zte(...e))},endsWith(...e){return this.check(Bte(...e))},min(...e){return this.check(Ei(...e))},max(...e){return this.check(Ti(...e))},length(...e){return this.check(Di(...e))},nonempty(...e){return this.check(Ei(1,...e))},lowercase(e){return this.check(Ite(e))},uppercase(e){return this.check(Lte(e))},trim(){return this.check(Hte())},normalize(...e){return this.check(Vte(...e))},toLowerCase(){return this.check(Ute())},toUpperCase(){return this.check(ki())},slugify(){return this.check(Ai())}})),Xte=j(`ZodString`,(e,t)=>{Ln.init(e,t),$a.init(e,t)},{email(e){return this.check(ote(ene,e))},url(e){return this.check(_i(ro,e))},jwt(e){return this.check(Tte(gne,e))},emoji(e){return this.check(fte(nne,e))},guid(e){return this.check(ste(tne,e))},uuid(e){return this.check(cte(no,e))},uuidv4(e){return this.check(lte(no,e))},uuidv6(e){return this.check(ute(no,e))},uuidv7(e){return this.check(dte(no,e))},nanoid(e){return this.check(pte(rne,e))},cuid(e){return this.check(mte(ine,e))},cuid2(e){return this.check(hte(ane,e))},ulid(e){return this.check(gte(one,e))},base64(e){return this.check(vi(ao,e))},base64url(e){return this.check(Cte(mne,e))},xid(e){return this.check(_te(sne,e))},ksuid(e){return this.check(vte(cne,e))},ipv4(e){return this.check(yte(lne,e))},ipv6(e){return this.check(bte(une,e))},cidrv4(e){return this.check(xte(dne,e))},cidrv6(e){return this.check(Ste(fne,e))},e164(e){return this.check(wte(hne,e))},datetime(e){return this.check(yi(to,e))},date(e){return this.check(Ete(Zte,e))},time(e){return this.check(Dte(Qte,e))},duration(e){return this.check(Ote($te,e))}});function M(e){return ate(Xte,e)}var eo=j(`ZodStringFormat`,(e,t)=>{Rn.init(e,t),$a.init(e,t)}),to=j(`ZodISODateTime`,(e,t)=>{Zn.init(e,t),eo.init(e,t)}),Zte=j(`ZodISODate`,(e,t)=>{Qn.init(e,t),eo.init(e,t)}),Qte=j(`ZodISOTime`,(e,t)=>{$n.init(e,t),eo.init(e,t)}),$te=j(`ZodISODuration`,(e,t)=>{er.init(e,t),eo.init(e,t)}),ene=j(`ZodEmail`,(e,t)=>{Lee.init(e,t),eo.init(e,t)}),tne=j(`ZodGUID`,(e,t)=>{Fee.init(e,t),eo.init(e,t)}),no=j(`ZodUUID`,(e,t)=>{Iee.init(e,t),eo.init(e,t)}),ro=j(`ZodURL`,(e,t)=>{Un.init(e,t),eo.init(e,t)});function io(e){return _i(ro,e)}var nne=j(`ZodEmoji`,(e,t)=>{Wn.init(e,t),eo.init(e,t)}),rne=j(`ZodNanoID`,(e,t)=>{Gn.init(e,t),eo.init(e,t)}),ine=j(`ZodCUID`,(e,t)=>{Kn.init(e,t),eo.init(e,t)}),ane=j(`ZodCUID2`,(e,t)=>{qn.init(e,t),eo.init(e,t)}),one=j(`ZodULID`,(e,t)=>{Jn.init(e,t),eo.init(e,t)}),sne=j(`ZodXID`,(e,t)=>{Yn.init(e,t),eo.init(e,t)}),cne=j(`ZodKSUID`,(e,t)=>{Xn.init(e,t),eo.init(e,t)}),lne=j(`ZodIPv4`,(e,t)=>{tr.init(e,t),eo.init(e,t)}),une=j(`ZodIPv6`,(e,t)=>{ir.init(e,t),eo.init(e,t)}),dne=j(`ZodCIDRv4`,(e,t)=>{ar.init(e,t),eo.init(e,t)}),fne=j(`ZodCIDRv6`,(e,t)=>{sr.init(e,t),eo.init(e,t)}),ao=j(`ZodBase64`,(e,t)=>{ur.init(e,t),eo.init(e,t)});function pne(e){return vi(ao,e)}var mne=j(`ZodBase64URL`,(e,t)=>{pr.init(e,t),eo.init(e,t)}),hne=j(`ZodE164`,(e,t)=>{mr.init(e,t),eo.init(e,t)}),gne=j(`ZodJWT`,(e,t)=>{gr.init(e,t),eo.init(e,t)}),oo=j(`ZodNumber`,(e,t)=>{_r.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>da(e,t,n,r),e.isFinite=!0},yt({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=oa(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=oa(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=oa(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>oa(e).format??null},{gt(e,t){return this.check(Si(e,t))},gte(e,t){return this.check(Ci(e,t))},min(e,t){return this.check(Ci(e,t))},lt(e,t){return this.check(bi(e,t))},lte(e,t){return this.check(xi(e,t))},max(e,t){return this.check(xi(e,t))},int(e){return this.check(so(e))},safe(e){return this.check(so(e))},positive(e){return this.check(Si(0,e))},nonnegative(e){return this.check(Ci(0,e))},negative(e){return this.check(bi(0,e))},nonpositive(e){return this.check(xi(0,e))},multipleOf(e,t){return this.check(wi(e,t))},step(e,t){return this.check(wi(e,t))},finite(){return this}}));function N(e){return kte(oo,e)}var _ne=j(`ZodNumberFormat`,(e,t)=>{vr.init(e,t),oo.init(e,t)});function so(e){return Ate(_ne,e)}var vne=j(`ZodBoolean`,(e,t)=>{yr.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fa(e,t,n,r)});function P(e){return jte(vne,e)}var yne=j(`ZodNull`,(e,t)=>{br.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pa(e,t,n,r)});function bne(e){return Mte(yne,e)}var co=j(`ZodUnknown`,(e,t)=>{xr.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function lo(){return Nte(co)}var uo=j(`ZodNever`,(e,t)=>{Sr.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ma(e,t,n,r)});function fo(e){return Pte(uo,e)}var po=j(`ZodArray`,(e,t)=>{Za(),Er.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ba(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Ei(e,t))},nonempty(e){return this.check(Ei(1,e))},max(e,t){return this.check(Ti(e,t))},length(e,t){return this.check(Di(e,t))},unwrap(){return this.element}});function F(e,t){return ji(po,e,t)}var mo=j(`ZodObject`,(e,t)=>{Za(),Mr.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sa(e,t,n,r),Et(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return R(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Ne(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Ne(this._zod.def,{catchall:lo()}))},loose(){return this.clone(Ne(this._zod.def,{catchall:lo()}))},strict(){return this.clone(Ne(this._zod.def,{catchall:fo()}))},strip(){return this.clone(Ne(this._zod.def,{catchall:void 0}))},extend(e){return Qe(this,e)},safeExtend(e){return et(this,e)},merge(e){return tt(this,e)},pick(e){return Ye(this,e)},omit(e){return Ze(this,e)},partial(...e){return nt(Oo,this,e[0])},exactPartial(...e){return nt(Ao,this,e[0],`exactPartial`)},required(...e){return rt(Ro,this,e[0])}});function I(e,t){return new mo({type:`object`,shape:e??{},...A(t)})}function L(e,t){return new mo({type:`object`,shape:e,catchall:fo(),...A(t)})}function ho(e,t){return new mo({type:`object`,shape:e,catchall:lo(),...A(t)})}var go=j(`ZodUnion`,(e,t)=>{Pr.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ca(e,t,n,r),e.options=t.options});function _o(e,t){return new go({type:`union`,options:e,...A(t)})}var vo=j(`ZodDiscriminatedUnion`,(e,t)=>{go.init(e,t),Ir.init(e,t)});function yo(e,t,n){return new vo({type:`union`,options:t,discriminator:e,...A(n)})}var bo=j(`ZodIntersection`,(e,t)=>{Lr.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wa(e,t,n,r)});function xo(e,t){return new bo({type:`intersection`,left:e,right:t})}var So=j(`ZodRecord`,(e,t)=>{Za(),Br.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oa(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Co(e,t,n){return!t||!t._zod?new So({type:`record`,keyType:M(),valueType:e,...A(t)}):new So({type:`record`,keyType:e,valueType:t,...A(n)})}var wo=j(`ZodEnum`,(e,t)=>{Vr.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ha(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 wo({...t,checks:[],...A(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 wo({...t,checks:[],...A(r),entries:i})}});function R(e,t){return new wo({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...A(t)})}var To=j(`ZodLiteral`,(e,t)=>{Hr.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ga(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 z(e,t){return new To({type:`literal`,values:Array.isArray(e)?e:[e],...A(t)})}var Eo=j(`ZodTransform`,(e,t)=>{Za(),Ur.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ya(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Pt(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(ht(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(ht(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Do(e){return new Eo({type:`transform`,transform:e})}var Oo=j(`ZodOptional`,(e,t)=>{Gr.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ra(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ko(e){return new Oo({type:`optional`,innerType:e})}var Ao=j(`ZodExactOptional`,(e,t)=>{Kr.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ra(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function jo(e){return new Ao({type:`optional`,innerType:e})}var Mo=j(`ZodNullable`,(e,t)=>{qr.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ka(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function No(e){return new Mo({type:`nullable`,innerType:e})}var Po=j(`ZodDefault`,(e,t)=>{Jr.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Na(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Fo(e,t){return new Po({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Be(t)}})}var Io=j(`ZodPrefault`,(e,t)=>{Vee.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lo(e,t){return new Io({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Be(t)}})}var Ro=j(`ZodNonOptional`,(e,t)=>{Hee.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Aa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zo(e,t){return new Ro({type:`nonoptional`,innerType:e,...A(t)})}var Bo=j(`ZodCatch`,(e,t)=>{Uee.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Vo(e,t){return new Bo({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Ot(t)})}var Ho=j(`ZodPipe`,(e,t)=>{Qr.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ia(e,t,n,r),e.in=t.in,e.out=t.out});function Uo(e,t){return new Ho({type:`pipe`,in:e,out:t})}var Wo=j(`ZodPreprocess`,(e,t)=>{Ho.init(e,t),Wee.init(e,t)}),Go=j(`ZodReadonly`,(e,t)=>{Gee.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>La(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ko(e){return new Go({type:`readonly`,innerType:e})}var qo=j(`ZodTemplateLiteral`,(e,t)=>{qee.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_a(e,t,n,r)});function Jo(e,t){return new qo({type:`template_literal`,parts:e,...A(t)})}var Yo=j(`ZodCustom`,(e,t)=>{Jee.init(e,t),Qa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>va(e,t,n,r)});function Xo(e,t={}){return Mi(Yo,e,t)}function Zo(e,t){return Ni(e,t)}function Qo(e,t){return new Wo({type:`pipe`,in:Do(e),out:t})}function $o(e){return yi(to,e)}var es=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,ts=/^[A-Za-z0-9][A-Za-z0-9._-]*\/[A-Za-z0-9][A-Za-z0-9._-]*$/,ns=/^[A-Za-z0-9_=-]+$/;function rs(e){let t=e.split(`/`);return t.length!==2||!t.every(e=>es.test(e))?null:[t[0],t[1]]}var is=I({attempt:N().int().positive(),limit:N().int().positive()}).refine(e=>e.attempt<=e.limit),as={error:M().nullable().optional(),nextAttemptAt:N().finite().nonnegative().nullable().optional(),retry:is.nullable().optional(),isRefreshing:P().optional(),refreshNotice:M().nullable().optional()},os=I({lane:R([`my-prs`,`team-review`,`issues`])}),ss=I({ok:P(),error:M().optional()}),cs=M().regex(ts),ls=M().regex(RegExp(`${ts.source.slice(0,-1)}#[1-9][0-9]*$`)),us=I({number:N().int().positive(),url:M().url(),title:M(),state:R([`open`,`draft`,`merged`,`closed`])});I({issue:I({closedByPullRequestsReferences:I({nodes:F(I({number:us.shape.number,url:us.shape.url,title:us.shape.title,state:R([`OPEN`,`MERGED`,`CLOSED`]),isDraft:P()}).nullable()).max(5)})}).nullable()});var ds={key:M(),repo:cs,number:N().int().positive(),title:M(),url:M().url(),labels:F(M()),assignees:F(M()),author:M(),comments:N().int().nonnegative(),createdAt:$o(),updatedAt:$o()},fs=R([`project`,`me`,`team`]),ps={...ds,sources:F(fs).nonempty().refine(e=>new Set(e).size===e.length),teams:F(cs),projectId:M().nullable(),pullRequests:F(us).max(5).default([])},ms=I(ps).refine(e=>e.key===`${e.repo}#${e.number}`),hs=I({...ps,sessionId:M().nullable().default(null)}).refine(e=>e.key===`${e.repo}#${e.number}`),gs=I({...ds,state:R([`open`,`closed`])});I({number:ds.number,title:ds.title,html_url:ds.url,state:R([`open`,`closed`]),labels:F(_o([M(),I({name:M()})])),assignees:F(I({login:M()})),user:I({login:M()}).nullable(),comments:ds.comments,created_at:ds.createdAt,updated_at:ds.updatedAt,repository_url:M().url().optional(),pull_request:lo().optional()}),I({items:F(lo()),total_count:N().int().nonnegative(),incomplete_results:P()}),I({ok:P(),items:F(gs),isComplete:P(),error:M()}),I({issues:F(ms),lastSyncAt:N().finite().nonnegative().nullable(),perRepoSync:Co(cs,I({lastSyncAt:N().finite().nonnegative().nullable(),ticks:N().int().nonnegative(),needsFullReconcile:P()})),sessionLinks:Co(ls,M()).default({}),pullRequestsFetchedAt:Co(ls,$o()).default({})});var _s=I({type:z(`issues-status`),ts:N().finite(),configured:P(),reason:M().nullable(),lastSyncAt:N().finite().nonnegative().nullable(),issues:F(hs),...as}).passthrough(),vs=/^[0-9a-f]{7,40}$/i,ys=/^[0-9a-f]{40}$/;function bs(e,{chars:t=7,validate:n=!1}={}){if(typeof e!=`string`||!e)return``;if(!n)return e.slice(0,t);let r=e.trim();return vs.test(r)?r.slice(0,t).toLowerCase():``}var B=M().regex(ys),xs=M().regex(/^[^/]+\/[^/]+$/);I({number:N().int().positive(),title:M(),html_url:M(),draft:P().optional(),created_at:M().optional(),updated_at:M().optional(),repository_url:M(),user:I({login:M(),type:R([`User`,`Bot`])}).passthrough(),pull_request:I({}).passthrough()}).passthrough(),I({number:N().int().positive(),title:M(),body:M(),url:M(),author:I({login:M(),is_bot:P().optional()}).passthrough(),isDraft:P(),isCrossRepository:P(),baseRefName:M(),baseRefOid:B,headRefName:M().optional(),headRefOid:B,additions:N().int().nonnegative(),deletions:N().int().nonnegative(),files:F(I({path:M(),additions:N().int().nonnegative(),deletions:N().int().nonnegative()}).passthrough())}).passthrough();var Ss=I({path:M(),line:N().int().positive(),side:R([`RIGHT`,`LEFT`]).default(`RIGHT`),body:M()}),Cs=Object.freeze({STAMP:`APPROVE`,COMMENT:`APPROVE WITH NITS`,NEEDS_YOU:`REQUEST CHANGES`}),ws=R([`APPROVE`,`APPROVE WITH NITS`,`REQUEST CHANGES`,`BLOCKED`]),Ts=Qo(e=>typeof e==`string`&&Object.hasOwn(Cs,e)?Cs[e]:e,ws),Es=R([`CRITICAL`,`HIGH`,`MEDIUM`,`LOW`]),Ds=Ss.extend({severity:Es.optional()}),Os=I({path:M().min(1),line:N().int().positive().nullable(),side:R([`RIGHT`,`LEFT`]),severity:Es,reviewer:M().min(1),disposition:R([`ACTIONABLE`,`NIT`,`AMBIGUOUS`]).nullable(),body:M().min(1)}),ks=I({goal:M().default(``),change:M(),checked:F(M()),gaps:F(M())});I({verdict:ws,head:B,summary:M(),assessment:ks.nullable(),findings:F(Os)}),I({body:M(),commit_id:B,comments:F(I({path:M().min(1),line:N().int().positive(),side:R([`RIGHT`,`LEFT`]).default(`RIGHT`),body:M().min(1)}))});var As=R([`APPROVE`,`COMMENT`]),js=R([`APPROVED`,`CHANGES_REQUESTED`,`COMMENTED`]),Ms=new Set([`APPROVED`,`CHANGES_REQUESTED`]),Ns=R([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]),xne=R([`SUCCESS`,`FAILURE`,`PENDING`,`ERROR`,`EXPECTED`]),Ps={requestSource:R([`direct`,`team`]).default(`team`),isDraft:P().optional(),checksState:xne.nullable().optional()},Fs=I({login:M().min(1),state:js,commit:B.nullable(),isViewer:P(),submittedAt:M().nullable().optional()});function Is(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`)}var Sne=I({head:B,base:B.optional(),verdict:ws,summary:M(),body:M(),comments:F(Ss),wasPosted:P()}),Ls=M().min(1).max(256).regex(ns),Cne=I({addressed:P(),reason:M().trim().min(1).max(4e3)}).strict(),Rs=I({id:Ls,path:M(),line:N().int().positive().nullable(),isResolved:P(),viewerCanResolve:P(),comments:I({pageInfo:I({hasNextPage:P(),endCursor:M().nullable().optional()}),nodes:F(I({body:M(),author:I({login:M()}).nullable(),viewerDidAuthor:P(),createdAt:M().datetime(),url:M().url(),originalCommit:I({oid:B}).nullable()}))})});I({data:I({node:I({comments:Rs.shape.comments}).nullable()}).nullable()}),I({pullRequest:I({reviewThreads:I({pageInfo:I({hasNextPage:P(),endCursor:M().nullable().optional()}),nodes:F(Rs)})}).nullable()}),I({data:I({resolveReviewThread:I({thread:I({id:Ls,isResolved:z(!0)})})}).nullable(),errors:F(lo()).optional()});var zs=I({id:Ls,path:M(),line:N().int().positive().nullable(),isResolved:P(),viewerCanResolve:P(),isNit:P(),url:M().url(),viewerComment:M().max(1500).optional(),lastReplyBody:M().max(1500).optional(),viewerCommentTruncated:P().optional(),lastReplyTruncated:P().optional(),lastReplyAuthor:M(),lastReplyAt:M().datetime(),judgement:Cne.extend({head:B,judgedAt:N().finite(),lastReplyAt:M().datetime()}).optional(),resolveError:M().optional(),resolveAttemptReplyAt:M().optional(),judgeAttempt:I({head:B,lastReplyAt:M(),retryAt:N().finite()}).optional(),unjudgeable:I({head:B,lastReplyAt:M(),reason:M().min(1)}).optional()});I({merge_base_commit:I({sha:B}),files:F(I({filename:M(),previous_filename:M().optional(),patch:M().optional()})).max(300)});var Bs=I({total:N().int().nonnegative(),resolved:N().int().nonnegative()}),Vs=I({...Ps,key:M(),repo:xs,number:N().int().positive(),title:M(),url:M(),author:M(),tier:R([`stamp`,`full`]),reasons:F(M()),reviewedHead:B,reviewedBase:B.optional(),verdict:Ts,summary:M(),assessment:ks.optional(),body:M(),comments:F(Ds),status:R([`ready`,`stale`,`posted`,`discarded`,`error`]),error:M().optional(),threads:F(zs).optional(),viewerThreads:Bs.optional(),githubReviews:F(Fs).optional(),reviewDecision:Ns.nullable().optional(),liveHead:B.optional(),prCreatedAt:M().optional(),reviewedAt:N().finite().optional(),postedAt:N().finite().optional(),postedEvent:As.optional(),priorReviewedHead:B.optional(),requeuedHead:B.optional()});function wne(e){return e.status===`posted`&&e.postedEvent===`COMMENT`}var Tne=R([`approve`,`approve-only`,`comment`,`discard`,`requeue`,`resolve-thread`]);function Hs(e){return e.action===`discard`||e.head!==void 0}var Ene=I({key:M().min(1),head:B.optional(),action:Tne,threadId:Ls.optional(),body:M(),comments:F(Ss)}).refine(e=>e.action!==`resolve-thread`||e.threadId!==void 0,{message:`resolve-thread requires threadId`,path:[`threadId`]}).refine(Hs,{message:`only discard may omit head`,path:[`head`]}),Dne=I({key:M(),ok:P(),error:M().optional(),warning:M().optional()}),One=I({sessionId:M().min(1),workDir:M().min(1),worktreePath:M().min(1),head:B,deadlineAt:N(),remainingAwakeMs:N().nonnegative().optional(),savedAt:N()}),Us=I({...Ps,reviewDecision:Ns.nullable().optional(),key:M(),repo:xs,number:N().int().positive(),title:M(),url:M(),author:M(),prCreatedAt:M().optional()}),kne=I({draft:Vs.nullable(),reviewedHead:B.nullable(),inFlight:P(),skipReason:M().nullable(),handReview:Us.optional(),reviewAttempts:N().int().nonnegative().default(0),resumable:One.nullable().optional(),reviewedAt:N().optional(),threads:F(zs).optional(),viewerThreads:Bs.optional(),autoResolvedThreadIds:F(Ls).optional(),githubReviews:F(Fs).optional(),reviewDecision:Ns.nullable().optional(),liveHead:B.optional(),requeuedHead:B.optional(),priorReview:Sne.optional(),discardedReviewHead:B.optional(),updatedAt:N().finite()});Co(M(),kne);var Ane=R([`preparing`,`checkout`,`reviewing`]),jne=I({at:N().finite(),tool:M(),detail:M()}),Mne=I({...Ps,reviewDecision:Ns.nullable().optional(),key:M(),repo:xs,number:N().int().positive(),title:M(),url:M(),author:M(),tier:R([`stamp`,`full`]),reasons:F(M()),head:B,phase:Ane,startedAt:N().finite(),deadlineAt:N().finite().nullable(),toolCalls:N().int().nonnegative(),recentSteps:F(jne),prCreatedAt:M().optional(),priorReviewedHead:B.optional()}),Ws=I({...as,type:z(`team-review-status`),ts:N().finite(),configured:P(),reason:M().nullable().optional(),drafts:F(Vs),inFlight:F(Mne),queued:F(Us).default([]),handReview:F(Us).default([]),team:I({org:M(),slug:M(),name:M(),avatarUrl:M()}).nullable().optional()}).passthrough(),Nne=R([`merged`,`draft`,`conflicts`,`behind`,`checks-failing`,`changes-requested`,`unresolved-threads`,`checks-pending`,`needs-approval`,`ready`,`unknown`]),Gs=N().int().nonnegative(),Ks=M().regex(ts),qs=Jo([Ks,`#`,M().regex(/^[1-9][0-9]*$/)]),Pne=Jo([qs,`@`,B]),Js=M().refine(e=>qs.safeParse(e).success),Ys=M().refine(e=>Pne.safeParse(e).success);yo(`outcome`,[L({outcome:z(`pushed`)}),L({outcome:R([`no-change`,`failed`,`stopped`,`timed-out`]),reason:M().min(1)})]);var Xs=L({outcome:R([`pushed`,`no-change`,`failed`,`stopped`,`timed-out`]),reason:M().min(1).optional(),at:N().finite()}),Fne=Xs.extend({key:Js,headRefOid:B,baseRefOid:B,consecutiveAttempts:N().int().min(1).optional()});L({keepMergeableKeys:F(Js),keepMergeableAttemptKeys:F(Ys),keepMergeableAttempts:F(Fne).default([]),mergeQueueKeys:F(Js).default([]),keepMergeablePushedHeadKeys:F(Ys).default([])});var Zs=L({repo:Ks,number:N().int().positive(),url:io(),source:R([`hook`,`sha`,`manual`]),linkedAt:N().finite()}),Qs=L({links:F(Zs).max(20),unlinkedKeys:F(Js).default([])}),Ine=I({repo:Ks,number:N().int().positive(),keepMergeable:P()}),$s=I({key:M(),ok:P(),error:M().optional()}),Lne=$s,Rne=I({repo:Ks,number:N().int().positive(),mergeWhenReady:P()}),zne=$s,ec=R([`MERGE`,`SQUASH`,`REBASE`]),Bne=I({path:M(),line:N().int().positive().nullable(),isOutdated:P(),url:io(),author:M().nullable(),excerpt:M(),commentCount:N().int().positive(),lastAuthor:M().nullable(),lastActivityAt:M()}),Vne=I({reviewer:M().nullable(),state:M(),submittedAt:M().nullable()}),Hne=I({outcome:R([`rebased`,`failed`]),at:N().finite(),message:M()}),Une=I({at:N().finite(),message:M()}),Wne=I({key:M(),repo:Ks,number:N().int().positive(),title:M(),url:io(),isDraft:P(),state:R([`OPEN`,`MERGED`,`CLOSED`]),createdAt:M(),mergedAt:M().nullable(),updatedAt:M(),baseRefName:M(),baseRefOid:B,headRefName:M().min(1),isCrossRepository:P(),headRefOid:B,isInMergeQueue:P(),mergeMethod:ec,mergeable:R([`MERGEABLE`,`CONFLICTING`,`UNKNOWN`]),mergeStateStatus:M(),reviewDecision:R([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]).nullable(),checks:I({state:R([`SUCCESS`,`FAILURE`,`PENDING`,`ERROR`,`EXPECTED`]).nullable(),failing:F(M()),pendingCount:Gs}),unresolvedThreads:Gs,threads:F(Bne),behindBy:Gs.nullable(),reviewRequests:F(I({name:M(),isTeam:P(),avatarUrl:M().nullable()})),approvals:Gs,reviews:F(Vne),stage:Nne,autoRebase:Hne.optional(),keepMergeable:P().optional(),keepMergeableAttempt:Xs.optional(),isKeepMergeableFixInFlight:P().optional(),mergeQueuePosition:N().int().positive().nullable().optional(),isMergeQueueHeldForRepairPush:P().optional(),mergeQueueFailure:Une.optional()}).refine(e=>e.key===`${e.repo}#${e.number}`),tc=I({...as,type:z(`my-prs-status`),ts:N().finite(),configured:P(),reason:M().nullable().optional(),viewer:M().nullable(),prs:F(Wne),truncatedNote:M().nullable().optional(),isKeepMergeableEnabled:P().optional(),isMergeQueueEnabled:P().optional()}).passthrough(),Gne=I({repo:Ks,number:N().int().positive(),headRefOid:B}),Kne=R([`merged`,`queued`,`auto-merge`,`unconfirmed`]),nc=I({key:M(),ok:P(),kind:Kne.optional(),error:M().optional()}),qne=_o([I({__typename:z(`CheckRun`),name:M(),conclusion:M().nullable(),status:M(),startedAt:M().nullish(),checkSuite:I({app:I({databaseId:N().int().nullish()}).nullish(),workflowRun:I({workflow:I({databaseId:N().int().nullish()})}).nullish()}).nullish()}),I({__typename:z(`StatusContext`),context:M(),state:M()})]),rc=I({hasNextPage:P(),endCursor:M().nullable()}),Jne=I({__typename:z(`PullRequest`),id:M().regex(ns),number:N().int().positive(),title:M(),url:io(),isDraft:P(),state:R([`OPEN`,`MERGED`,`CLOSED`]),createdAt:M(),mergedAt:M().nullable(),updatedAt:M(),baseRefName:M(),baseRefOid:B,headRefName:M().min(1),isCrossRepository:P(),headRefOid:B,isInMergeQueue:P(),mergeable:R([`MERGEABLE`,`CONFLICTING`,`UNKNOWN`]),mergeStateStatus:M(),reviewDecision:R([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]).nullable(),repository:I({nameWithOwner:Ks,viewerDefaultMergeMethod:ec}),commits:I({nodes:F(I({commit:I({statusCheckRollup:I({id:M().regex(ns).optional(),state:R([`SUCCESS`,`FAILURE`,`PENDING`,`ERROR`,`EXPECTED`]).nullable(),contexts:I({pageInfo:rc.optional(),nodes:F(qne)})}).nullable()})}))}),reviewThreads:I({pageInfo:I({hasNextPage:P()}),nodes:F(I({isResolved:P()}))}),reviewRequests:I({nodes:F(I({requestedReviewer:yo(`__typename`,[I({__typename:z(`User`),login:M()}),I({__typename:z(`Team`),slug:M(),avatarUrl:M().nullable(),organization:I({login:M()})}),I({__typename:R([`Bot`,`Mannequin`])})]).nullable()}))}),latestOpinionatedReviews:I({nodes:F(I({state:M()}))}),latestReviews:I({nodes:F(I({state:M(),submittedAt:M().nullable(),author:I({login:M()}).nullable()}))})}),ic=I({login:M()}).nullable();I({isResolved:P(),isOutdated:P(),path:M(),line:N().int().positive().nullable(),firstComment:I({totalCount:Gs,nodes:F(I({author:ic,bodyText:M(),url:io(),createdAt:M()}))}),lastComment:I({nodes:F(I({author:ic,createdAt:M()}))})}),I({data:I({repository:I({pullRequest:I({reviewThreads:I({pageInfo:I({hasNextPage:P(),endCursor:M().nullable()}),nodes:F(lo())})}).nullable()}).nullable()}),errors:F(lo()).optional()}),I({data:I({node:I({contexts:I({pageInfo:rc,nodes:F(lo())}).nullable()}).nullable()}).nullable(),errors:F(lo()).optional()}),I({data:I({repository:I({pullRequest:I({state:M(),isInMergeQueue:P(),autoMergeRequest:I({enabledAt:M().nullable()}).nullable()}).nullable()}).nullable()}),errors:F(lo()).optional()}),I({data:I({open:I({issueCount:Gs,nodes:F(lo())}),merged:I({issueCount:Gs,nodes:F(lo())})}),errors:F(lo()).optional()});var Yne=/[\x00-\x1f\x7f-\x9f]/,ac=M().refine(e=>!Yne.test(e)).trim().max(120);I({title:M().nullable()}).strict();var oc=R(a),sc=I({at:N().finite().nullable(),kind:M(),reason:M().nullable()}).passthrough(),cc=4e3,lc=1e3,Xne=2e3,Zne=I({question:M().min(1).max(lc),header:M().max(100).default(``),options:F(I({label:M().min(1).max(200),description:M().max(lc).default(``)})).min(1).max(8),multiSelect:P().default(!1)}),uc=I({requestId:_o([M().min(1).max(128),N().int()]),kind:R([`command`,`fileChange`,`permissions`,`tool`,`question`]),summary:M().max(cc),isSummaryTruncated:P(),toolName:M().max(200).optional(),questions:F(Zne).min(1).max(4).optional(),alwaysAllowSummary:M().max(cc).optional()}),Qne=Co(M().max(lc),M().max(Xne)),$ne=R([`accept`,`acceptForSession`,`decline`]),dc=I({id:M(),name:M(),taskTitle:ac.nullable().default(null),taskTitleIsCustom:P().default(!1),path:M(),agent:M(),state:oc,stateSince:N(),dangerouslySkipPermissions:P(),saneYolo:P().default(!1),ephemeral:P(),isWorktree:P(),isWorkspace:P().default(!1),isGuarded:P().default(!1),resumeSessionId:M().nullable(),activeAgents:N().int().nonnegative(),awaitingBackgroundTasks:P(),isCompacting:P().default(!1),isWaitingForMemory:P().default(!1),pendingWakeup:sc.nullable(),pendingPromptKind:M().nullable(),conversationApproval:uc.nullable().default(null),hasConversationBridge:P().default(!1),isConversationViewOn:P().default(!1),hasPlan:P().default(!1),mergeStatus:M().nullable(),mergeReason:M().nullable(),worktreeNotice:M().nullable(),effectiveBase:M().nullable(),linkedPrs:F(Zs).default([]),auditLog:F(lo())}).passthrough();I({namespace:z(`git`,{error:`namespace must be git`}),publicKey:M({error:`publicKey must be a string`}).min(1,{error:`publicKey must not be empty`}).max(16384,{error:`publicKey must be at most 16384 characters`}),payload:pne({error:`payload must be base64`})}).strict(),_o([I({ok:z(!0),signature:M()}).strict(),I({ok:z(!1),error:M()}).strict()]),I({projectId:M().trim().min(1).max(128).optional()}).strict(),I({intentId:M().trim().min(1).max(128)}).strict(),I({}).strict(),I({prompt:M({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:M({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:M({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(),I({note:M({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(),_o([I({ok:z(!0),pending:P()}).strict(),I({ok:z(!1),error:M()}).strict()]),I({id:dc.shape.id,name:dc.shape.name,agent:dc.shape.agent,state:dc.shape.state,ephemeral:dc.shape.ephemeral}).strict();var fc=4096;I({path:M({error:`path must be a string`}).min(1,{error:`path must not be empty`}).max(fc,{error:`path must be at most ${fc} characters`})}).strict();var pc=I({path:M(),name:M(),surfacedAt:N().finite()}).strict();I({commands:F(I({name:R([`push`,`spawn`,`attention`,`board`,`edit`]),answers:P(),reason:M().optional()}).strict()),guarded:P(),deadEnds:F(I({blocked:M(),route:M()}).strict())}).strict().extend({ok:z(!0)}).strict(),I({workId:M().regex(/^wrk-[0-9a-f]{16}$/).optional(),readyIntent:M().regex(/^wrk-[0-9a-f]{16}$/).optional()}).strict().refine(e=>!!e.workId!=!!e.readyIntent,`Expected exactly one work id or ready intent`),I({workId:M({error:`workId must be a string`}).regex(/^wrk-[0-9a-f]{16}$/,{error:`workId must match wrk-[0-9a-f]{16}`})}).strict(),yo(`ok`,[I({ok:z(!0),workId:M(),state:R([`open`,`cancelled`])}),I({ok:z(!1),reason:M()})]);var mc=R([`low`,`medium`,`high`,`critical`]),hc=R([`open`,`active`,`blocked`,`completed`,`cancelled`]),gc=R([`ready`,`waiting`,`active`,`blocked`,`done`]),ere=ho({total:N().int().nonnegative(),roots:N().int().nonnegative(),dependencies:N().int().nonnegative(),states:ho({open:N().int().nonnegative(),active:N().int().nonnegative(),blocked:N().int().nonnegative(),completed:N().int().nonnegative(),cancelled:N().int().nonnegative()}),readiness:ho({ready:N().int().nonnegative(),waiting:N().int().nonnegative(),active:N().int().nonnegative(),blocked:N().int().nonnegative(),done:N().int().nonnegative()}),risks:ho({low:N().int().nonnegative(),medium:N().int().nonnegative(),high:N().int().nonnegative(),critical:N().int().nonnegative()}),graphProblems:N().int().nonnegative(),scopeOverlaps:N().int().nonnegative(),scopeConflicts:N().int().nonnegative(),orphans:N().int().nonnegative(),unsynthesizedChildren:N().int().nonnegative()}),tre=ho({action:R([`steady`,`dispatch`,`continue`,`verify`,`synthesize`,`unblock`,`resolve-conflict`,`repair-navigation`,`refuse`]),reasons:F(M()),sources:F(ho({name:M(),ok:P(),detail:M()})),work:ho({stats:ere,ready:F(M()),active:F(M()),blocked:F(M()),completed:F(M()),conflicts:F(ho({left:M(),right:M(),scope:M()})),unsynthesized:F(lo())}).nullable(),consequences:ho({unverifiedCompletedWork:F(M())}).nullable(),verification:ho({state:M()}).nullable()});ho({work:F(ho({work:M(),state:hc,readiness:gc,owner:ho({session:M(),agent:M()}),last:ho({event:M(),at:M(),session:M(),reason:M().optional()}).nullable(),opened:ho({at:$o(),objective:M(),authority:ho({boundary:M()}),criteria:F(M()),risk:mc,parent:M().nullable(),dependsOn:F(M()),readScopes:F(M()),writeScopes:F(M())})})),scopeConflicts:F(ho({left:M(),right:M(),leftScope:M(),rightScope:M(),status:M()}))}),ho({version:z(1),event:z(`opened`),at:$o(),session:z(`glimmervoid-factory`),work:M().regex(/^wrk-[a-f0-9]{16}$/),id:M().regex(/^wev-[a-f0-9]{16}$/),parent:bne(),objective:M(),criteria:F(M()),risk:mc,state:z(`open`),authority:I({kind:z(`user-directed`),grantedBy:z(`operator`),boundary:M()}),writeScopes:F(M())}).extend({parent:M().regex(/^wrk-[a-f0-9]{16}$/)});function _c(e,t){return typeof e==`string`&&e.trim()?e.trim():t}function V(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}var vc=Object.freeze({min:1}),yc=Object.freeze({min:0,exclusiveMin:!0,label:`a positive number`}),bc=Object.freeze({min:0,label:`zero or more`}),xc=Object.freeze({min:0,max:300}),Sc=Object.freeze({min:1,max:60}),Cc=Object.freeze({min:.5,max:2}),wc=Object.freeze({flyingAnimalsMinGapSeconds:20,flyingAnimalsMaxGapSeconds:40,flyingAnimalsMinDurationSeconds:6.9,flyingAnimalsMaxDurationSeconds:11.5,flyingAnimalsScale:1,flyingAnimalsOnPhone:!0}),Tc=Object.freeze({min:64,max:16384}),Ec=Object.freeze({min:0,max:65536}),Dc=Object.freeze({min:0,max:65535}),Oc=Object.freeze({min:0,exclusiveMin:!0,max:2147483647/1e3}),nre=yc,rre=yc,kc=yc,Ac=yc,jc=yc,Mc=bc,Nc=yc,Pc=yc,Fc=yc,Ic=yc,Lc=yc,Rc=yc,zc=yc,ire=yc,are=yc,Bc=Object.freeze({min:60,max:21600,label:`between 60 and 21600`}),Vc=Object.freeze({min:1,label:`at least 1`}),Hc=Object.freeze({min:1,label:`at least 1`}),Uc=bc,Wc=Object.freeze({min:1,max:30,label:`between 1 and 30`}),Gc=Object.freeze({min:1,max:1440}),Kc=Object.freeze({min:1,max:3650}),qc=Object.freeze({min:30,max:3650}),Jc=Object.freeze({min:1,max:24}),Yc=yc,Xc=Object.freeze({scanIntervalMinutes:Gc,retainDays:Kc,warehouseRetainDays:qc,sessionBlockHours:Jc}),Zc=Object.freeze({min:15,max:600}),Qc=Object.freeze({min:5,max:120}),$c=Object.freeze({min:1,max:5}),el=Object.freeze({min:1,max:50});Object.freeze({NON_NEGATIVE_NUMBER_RANGE:bc,FACTORY_MAX_LIVE_WORKERS_RANGE:vc,FLYING_ANIMALS_GAP_RANGE:xc,FLYING_ANIMALS_DURATION_RANGE:Sc,FLYING_ANIMALS_SCALE_RANGE:Cc,CHANGE_MAP_NARRATOR_TIMEOUT_RANGE:Zc,KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE:Qc,PORT_RANGE:Dc,POSTHOG_ESCALATION_RANGE:zc,POSTHOG_FIX_TIMEOUT_RANGE:Bc,POSTHOG_INTERVAL_RANGE:Fc,POSTHOG_INVESTIGATION_TIMEOUT_RANGE:Lc,POSTHOG_MAX_CONCURRENT_RANGE:Ic,POSTHOG_MIN_USERS_RANGE:Rc,POSTHOG_TRAFFIC_BASELINE_RANGE:Wc,POSTHOG_TRAFFIC_COOLDOWN_RANGE:Uc,POSTHOG_TRAFFIC_MIN_USERS_RANGE:Hc,POSTHOG_TRAFFIC_MULTIPLIER_RANGE:Vc,REPLAY_BUFFER_KB_RANGE:Tc,MEMORY_RESERVE_MB_RANGE:Ec,TASK_TITLE_TIMEOUT_RANGE:Oc,USAGE_BUDGET_RANGE:Yc,USAGE_RETAIN_DAYS_RANGE:Kc,USAGE_SCAN_INTERVAL_RANGE:Gc,VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE:Mc,VISIONS_COOLDOWN_MS_RANGE:Ac,VISIONS_DISPATCH_TIMEOUT_RANGE:Nc,VISIONS_INTENT_THREAD_TTL_MS_RANGE:Pc,VISIONS_MAX_PER_HOUR_RANGE:jc,VISIONS_QUIET_MS_RANGE:kc,WORKFLOWS_MAX_ACTIONS_PER_POLL_RANGE:el,WORKFLOWS_MAX_CONCURRENT_SESSIONS_RANGE:$c});var tl={maxConcurrentInvestigations:Math.ceil,minUsersToInvestigate:Math.ceil,userEscalationThreshold:Math.ceil,trafficSpikeMinUsers:Math.ceil,trafficSpikeBaselineDays:Math.floor};[...Object.entries(tl).map(([e,t])=>({path:[`posthog`,e],min:1,round:t}))];var nl=Object.freeze([`auto`,`calculate`,`display`]),rl=Object.freeze([`codex`,`grok`]),il=Object.freeze([`dailyUsd`,`monthlyUsd`]),al=Object.freeze([`opened`,`checks-failed`,`review-requested`,`approved`,`commented`,`merged`]),ol=Object.freeze([`notify`,`spawn`,`label`,`comment`]),sl=2e4,cl=65536,ll=50,ul=/^[a-z0-9][a-z0-9-]{0,63}$/,dl=/[\x00-\x1f\x7f,]|^-/,fl=(e,t)=>{let n=`${e} must be an integer between ${t.min} and ${t.max}`;return N({error:n}).int({error:n}).min(t.min,{error:n}).max(t.max,{error:n})},pl=P({error:`workflows.enabled must be a boolean`}),ml=fl(`workflows.maxConcurrentSessions`,$c),hl=fl(`workflows.maxActionsPerPoll`,el),gl=(e,t)=>F(t,{error:`${e} must be an array`}).min(1,{error:`${e} must list at least one entry when present`}),_l=M({error:`a workflow label name must be a string`}).trim().min(1,{error:`a workflow label name must not be empty`}).max(ll,{error:`a workflow label name must be at most ${ll} characters`}).refine(e=>!dl.test(e),{error:`a workflow label name must not start with a dash or hold a comma or control character`}),vl=M({error:`a workflow comment body must be a string`}).min(1,{error:`a workflow comment body must not be empty`}).max(cl,{error:`a workflow comment body must be at most ${cl} characters`}).refine(e=>e.trim().length>0,{error:`a workflow comment body must not be blank`}),yl=R(al,{error:`workflows.rules[].trigger must be one of ${al.join(`, `)}`}),bl=yo(`type`,[L({type:z(`notify`)}),L({type:z(`spawn`),promptTemplate:M({error:`a spawn action needs a promptTemplate string`}).min(1,{error:`a spawn action promptTemplate must not be empty`}).max(sl,{error:`a spawn action promptTemplate must be at most ${sl} characters`}).refine(e=>e.trim().length>0,{error:`a spawn action promptTemplate must not be blank`})}),L({type:z(`label`),name:_l}),L({type:z(`comment`),body:vl})],{error:`workflows.rules[].actions[].type must be one of ${ol.join(`, `)}`}),xl=L({mine:P({error:`workflows.rules[].filters.mine must be a boolean`}).optional(),teamReviewRequested:P({error:`workflows.rules[].filters.teamReviewRequested must be a boolean`}).optional(),authors:gl(`workflows.rules[].filters.authors`,M({error:`workflows.rules[].filters.authors must hold GitHub logins`}).regex(es,{error:`workflows.rules[].filters.authors must hold GitHub logins`})).optional(),labels:gl(`workflows.rules[].filters.labels`,_l).optional(),baseBranches:gl(`workflows.rules[].filters.baseBranches`,M({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`}),Sl=M({error:`workflows.rules[].id must be a string`}).regex(ul,{error:`workflows.rules[].id must be 1 to 64 lowercase letters, digits and dashes, starting with a letter or digit`}),Cl=P({error:`workflows.rules[].enabled must be a boolean`}),wl=L({id:Sl,name:M({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:Cl.default(!1),repos:gl(`workflows.rules[].repos`,Ks),filters:xl.default({}),trigger:yl,actions:gl(`workflows.rules[].actions`,bl)},{error:`workflows.rules[] must be an object`}),Tl=L({enabled:pl.default(!0),maxConcurrentSessions:ml.default(2),maxActionsPerPoll:hl.default(20),rules:F(wl,{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())n.has(i.id)?t.addIssue({code:`custom`,path:[`rules`,r,`id`],message:`workflows.rules[${r}].id "${i.id}" is declared more than once`}):n.add(i.id)}),El=L({id:Sl,enabled:Cl},{error:`a dashboard update of workflows.rules[] carries only id and enabled`});L({enabled:pl.optional(),maxConcurrentSessions:ml.optional(),maxActionsPerPoll:hl.optional(),rules:F(El,{error:`workflows.rules must be an array`}).optional()},{error:`a dashboard update of workflows carries only enabled, maxConcurrentSessions, maxActionsPerPoll and rule toggles`});var Dl=N().int().nonnegative(),Ol=R([`SUCCESS`,`FAILURE`,`PENDING`,`ERROR`,`EXPECTED`]).nullable();Jne.extend({author:I({login:M()}).nullable(),labels:I({nodes:F(I({name:M()}))}),comments:I({totalCount:Dl})});var kl=L({polledAtMs:Dl,prs:F(L({repo:Ks,number:N().int().positive(),title:M(),url:io(),author:M().nullable(),state:R([`OPEN`,`MERGED`,`CLOSED`]),createdAt:M(),mergedAt:M().nullable(),isDraft:P(),isCrossRepository:P(),baseRefName:M(),headRefName:M().min(1),headRefOid:B,labels:F(M()),commentCount:Dl,reviewRequests:F(M()),checksState:Ol,reviewDecision:R([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]).nullable()}))});L({repos:Co(M().regex(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*$/),kl)});var Al=e=>P({error:`${e} must be a boolean`}).optional(),jl=(e,t=!1)=>{let n=M({error:`${e} must be a string`});return(t?n.transform(e=>e.trim()):n).optional()},Ml=e=>e.label?e.label:e.max==null?e.exclusiveMin?`greater than ${e.min}`:`at least ${e.min}`:`between ${e.min} and ${e.max}`,Nl=(e,t=yc)=>N({error:`${e} must be ${Ml(t)}`}).finite().refine(e=>!t.exclusiveMin||e>t.min,{message:`${e} must be ${Ml(t)}`}).refine(e=>t.exclusiveMin||e>=t.min,{message:`${e} must be ${Ml(t)}`}).refine(e=>t.max==null||e<=t.max,{message:`${e} must be ${Ml(t)}`}).optional(),Pl=(e,t)=>Nl(e,t).unwrap().int({error:`${e} must be a whole number ${Ml(t)}`}).optional(),Fl=(e,t)=>N({error:`${e} must be an integer between ${t.min} and ${t.max}`}).int({error:`${e} must be an integer between ${t.min} and ${t.max}`}).min(t.min,{error:`${e} must be an integer between ${t.min} and ${t.max}`}).max(t.max,{error:`${e} must be an integer between ${t.min} and ${t.max}`}).optional(),Il=(e,t)=>I(t,{error:`${e} must be an object`}).nullable().optional(),Ll=Object.freeze([`claude`,`codex`]),Rl=Object.freeze([`release`,`main`]),zl=Object.freeze([`report`,`fix`]);Il(`changeMap`,{narrator:Il(`changeMap.narrator`,{enabled:Al(`changeMap.narrator.enabled`),engine:R(Ll,{error:`changeMap.narrator.engine must be one of ${Ll.join(`, `)}`}).optional(),model:jl(`changeMap.narrator.model`,!0),timeoutSeconds:Fl(`changeMap.narrator.timeoutSeconds`,Zc)})}),I({refiner:I({enabled:Al(`taskTitle.refiner.enabled`),model:jl(`taskTitle.refiner.model`,!0),minIntervalSeconds:Nl(`taskTitle.refiner.minIntervalSeconds`,{min:0}),timeoutSeconds:Nl(`taskTitle.refiner.timeoutSeconds`,Oc)},{error:`taskTitle.refiner must be an object`}).nullable().optional()},{error:`taskTitle must be an object`}).nullable().optional();var Bl={enabled:Al(`branchGc.enabled`),worktrees:Al(`branchGc.worktrees`),prefixes:F(M({error:`branchGc.prefixes must be an array of strings`}).min(1,{error:`branchGc.prefixes entries must be non-empty strings`}),{error:`branchGc.prefixes must be an array of strings`}).optional(),dryRun:Al(`branchGc.dryRun`),staleDays:Nl(`branchGc.staleDays`,nre),deleteUnmerged:Al(`branchGc.deleteUnmerged`),intervalMs:Nl(`branchGc.intervalMs`,rre)},Vl=I(Bl,{error:`branchGc must be an object`});Il(`branchGc`,Bl),Vl.omit({prefixes:!0,dryRun:!0,worktrees:!0}).nullable().optional(),Object.freeze([`enabled`,`deleteUnmerged`]),Object.freeze([`staleDays`,`intervalMs`]),Il(`postTurnChecks`,{mode:R(zl,{error:`postTurnChecks.mode must be one of report, fix`}).optional()}),Il(`visions`,{enabled:Al(`visions.enabled`),autoFix:Al(`visions.autoFix`),projects:F(M({error:`visions.projects must be an array of strings`}),{error:`visions.projects must be an array of strings`}).optional(),dispatch:Il(`visions.dispatch`,{enabled:Al(`visions.dispatch.enabled`),model:jl(`visions.dispatch.model`,!0),quietMs:Pl(`visions.dispatch.quietMs`,kc),cooldownMs:Pl(`visions.dispatch.cooldownMs`,Ac),maxPerHour:Pl(`visions.dispatch.maxPerHour`,jc),activityMaxPerHour:Pl(`visions.dispatch.activityMaxPerHour`,Mc),dispatchTimeoutSeconds:Pl(`visions.dispatch.dispatchTimeoutSeconds`,Nc)}),intent:Il(`visions.intent`,{threadTtlMs:Pl(`visions.intent.threadTtlMs`,Pc)})}),I({teams:F(M({error:`github.teams must be an array of org/slug strings`}).refine(e=>rs(e)!==null,{message:`github.teams entries must be org/slug with valid GitHub segments`}),{error:`github.teams must be an array of org/slug strings`}).optional()},{error:`github must be an object`}).nullable().optional(),Il(`teamReview`,{enabled:Al(`teamReview.enabled`),autoRebaseMyPrs:Al(`teamReview.autoRebaseMyPrs`),keepMergeableEnabled:Al(`teamReview.keepMergeableEnabled`),mergeQueueEnabled:Al(`teamReview.mergeQueueEnabled`),keepMergeableTimeoutMinutes:Fl(`teamReview.keepMergeableTimeoutMinutes`,Qc),org:jl(`teamReview.org`,!0),team:jl(`teamReview.team`,!0),skill:jl(`teamReview.skill`,!0),reReviewAfterHours:Nl(`teamReview.reReviewAfterHours`),skipIdleAfterDays:Nl(`teamReview.skipIdleAfterDays`)}),Il(`benchmarks`,{enabled:Al(`benchmarks.enabled`)});var Hl=I({enabled:Al(`factory.enabled`),maxRisk:mc.optional(),maxLiveWorkers:N().int().min(vc.min).optional(),checks:F(M().trim().min(1)).optional(),protectedPaths:F(M().trim().min(1)).optional(),reviewerModel:M().trim().min(1).nullable().optional(),dailyBudgetUsd:N().finite().nonnegative().nullable().optional(),verifierModel:M().trim().min(1).nullable().optional(),mirrorHarnessRuns:Al(`factory.mirrorHarnessRuns`)}).nullable().optional();Il(`knowledgeGraph`,{enabled:Al(`knowledgeGraph.enabled`)});var Ul={intervalMinutes:Fc,maxConcurrentInvestigations:Ic,investigationTimeoutSeconds:Lc,fixTimeoutSeconds:Bc,minUsersToInvestigate:Rc,userEscalationThreshold:zc,recurrenceWindowDays:ire,transientRecurrenceLimit:are,trafficSpikeMultiplier:Vc,trafficSpikeMinUsers:Hc,trafficSpikeCooldownMinutes:Uc,trafficSpikeBaselineDays:Wc};Il(`posthog`,{enabled:Al(`posthog.enabled`),recurrenceDedupe:Al(`posthog.recurrenceDedupe`),trafficSpikeEnabled:Al(`posthog.trafficSpikeEnabled`),autoFix:Al(`posthog.autoFix`),host:jl(`posthog.host`,!0).refine(e=>e==null||!e||/^https?:\/\//i.test(e),{message:`posthog.host must be an http(s) URL`}),apiKey:jl(`posthog.apiKey`,!0),repoPath:jl(`posthog.repoPath`,!0),projects:_o([z(`all`),F(N({error:`posthog.projects must be "all" or an array of positive integer project ids`}).int({error:`posthog.projects must be "all" or an array of positive integer project ids`}).positive({error:`posthog.projects must be "all" or an array of positive integer project ids`}),{error:`posthog.projects must be "all" or an array of positive integer project ids`})],{error:`posthog.projects must be "all" or an array of positive integer project ids`}).optional(),projectMap:Co(M(),lo(),{error:`posthog.projectMap must be an object`}).optional(),...Object.fromEntries(Object.entries(Ul).map(([e,t])=>[e,Object.hasOwn(tl,e)?Pl(`posthog.${e}`,t):Nl(`posthog.${e}`,t)]))}),`${nl.join(`, `)}`,Object.fromEntries(rl.map(e=>[e,Al(`usage.vendors.${e}`)])),Object.fromEntries(il.map(e=>[e,N({error:`usage.budget.${e} must be a positive number or null`}).positive({error:`usage.budget.${e} must be a positive number or null`}).nullable().optional()])),Il(`telegram`,{botToken:jl(`telegram.botToken`,!0),chatId:jl(`telegram.chatId`,!0)}),I({enabled:Al(`ingest.enabled`)},{error:`ingest must be an object`}).passthrough().optional(),I({enabled:Al(`trace.enabled`)},{error:`trace must be an object`}).optional(),I({enabled:Al(`planReview.enabled`)},{error:`planReview must be an object`}).optional();var Wl=e=>F(M({error:`${e} must be an array of paths`}).trim().min(1,{error:`${e} must be an array of paths`}),{error:`${e} must be an array of paths`}).optional();I({unguardedRepos:Wl(`guardrails.unguardedRepos`),blockedPaths:Wl(`guardrails.blockedPaths`),unreadablePaths:Wl(`guardrails.unreadablePaths`)},{error:`guardrails must be an object`}).passthrough().optional();var Gl={enabled:Al(`telemetry.enabled`)};I(Gl,{error:`telemetry must be an object`}).strict().optional(),I(Gl,{error:`telemetry must be an object`}).passthrough().optional(),ho({records:F(ho({from:I({kind:M(),id:M()}),relation:M(),to:I({kind:M(),id:M()}),session:M().optional(),evidence:M().optional()}))});var Kl=F(M().min(1)).max(256),ql=I({projectId:M(),projectName:M(),headSha:M().nullable(),paused:P(),orchestrator:I({sessionId:M(),intentId:M(),state:oc}).nullable(),liveWorkers:F(I({workId:M(),sessionId:M()})).optional(),reviewing:F(M()).optional(),note:M().nullable().optional(),spentTodayUsd:N().finite().nonnegative().optional(),dailyBudgetUsd:N().finite().nonnegative().nullable().optional(),verifierIntentIds:F(M()).optional(),confirmedFlakesByIntent:Co(M().min(1),Kl).optional(),partialIntentIds:F(M()).optional(),factoryProfile:Hl.unwrap().unwrap().pick({checks:!0}).extend({focusedTestCommand:M().trim().min(1).optional(),widenableScopes:F(M().trim().min(1)).optional()}).optional(),error:M().nullable(),heading:I({action:tre.shape.action,reasons:F(M())}),orders:F(I({id:M(),objective:M(),openedAt:$o(),criteria:F(M()),boundary:M(),risk:mc,state:hc,readiness:gc,parent:M().nullable(),dependsOn:F(M()),writeScopes:F(M()),owner:M().nullable(),blockReason:M().nullable().optional(),parked:P().optional(),blockCount:N().int().nonnegative().optional(),lastEvent:I({event:M(),at:M(),session:M()}).nullable()})),conflicts:F(I({left:M(),right:M(),scope:M()})),unverifiedCompletedWork:F(M()),observedRun:I({recordDirectory:M(),outcome:M().nullable()}).optional()}),Jl=I({type:z(`factory-state`),ts:N().finite(),projects:F(ql)});I({arrivedAt:M(),state:Jl}),ho({outcome:R([`pass`,`partial`,`fail`]),failureClass:M().nullable().optional()});var Yl=16384;function Xl(e){return e!==`.`&&e!==`..`&&!/[/\\]/.test(e)}var Zl=M().trim().min(1).max(128).refine(Xl,`Invalid factory project id`),Ql=M().trim().min(1).max(4096),$l=M().trim().min(1).max(1024),eu=32,tu=M().trim().min(1).max(64),nu=[`**/package.json`,`**/package-lock.json`,`**/npm-shrinkwrap.json`,`**/yarn.lock`,`**/pnpm-lock.yaml`,`**/bun.lock`,`**/bun.lockb`,`**/.npmrc`,`**/.yarnrc`,`**/.yarnrc.yml`,`**/pnpm-workspace.yaml`,`**/.pnpmfile.cjs`,`**/tsconfig*.json`,`**/biome.json`,`**/biome.jsonc`,`**/vite.config.*`,`**/vitest.config.*`,`**/vitest.workspace.*`,`**/jest.config.*`,`**/.mocharc*`,`**/playwright.config.*`],ru=F(R(nu)).max(nu.length),iu=I({id:tu,objective:Ql,criteria:F(Ql).min(1).max(12),dependsOn:F(tu).max(eu),writeScopes:F($l).min(1).max(32)}),au=I({projectId:Zl,objective:Ql,criteria:F(Ql).min(1).max(12),risk:mc,boundary:Ql,writeScopes:F($l).max(32),tickets:F(iu).min(1).max(eu).optional(),floorAllowances:ru.optional()});au.omit({projectId:!0,floorAllowances:!0}).strict();var ou=I({projectId:M().max(128),ok:P(),workId:M().min(1).max(128).optional(),error:M().max(Yl).optional()}),su=I({projectId:Zl,action:R([`pause`,`resume`,`retry-parked`,`rerun-setup`]),intentId:M().trim().min(1).max(128).optional()}).refine(e=>e.action!==`retry-parked`||e.intentId!==void 0,{message:`Retry parked requires an intentId`,path:[`intentId`]}),cu=I({projectId:M().max(128),action:su.shape.action,ok:P(),reopenedWorkIds:F(M().min(1)).optional(),error:M().max(Yl).optional()}),lu=I({pass:P(),findings:F(M())}).strict();I({type:z(`result`),subtype:z(`success`),is_error:z(!1),structured_output:lu});var uu=I({id:M().min(1).max(1024),path:M().min(1).max(4096),line:M().min(1).regex(/^[^\n]*$/)});I({ledgerPath:M().min(1).max(4096).nullable(),ledgerBranch:M().min(1).max(1024).nullable(),paused:P(),trustedVerifications:F(I({id:M().min(1),sha:M().regex(/^[a-f0-9]{40,64}$/)})).optional(),trustedIntentCloses:F(M().min(1)).optional(),pendingVerifierTrusts:F(I({intentId:M().min(1),sha:M().regex(/^[a-f0-9]{40,64}$/),records:F(uu).min(1)})).optional(),trustedIntentIds:F(M().min(1)).optional(),intentWriteScopes:Co(M().min(1),F(M().min(1))).optional(),intentFloorAllowances:Co(M().min(1),ru).optional(),intentConfirmedFlakes:Co(M().min(1),Kl).optional(),intentScopeNeeds:Co(M().min(1),F(M().min(1)).max(256)).optional(),ticketedIntentIds:F(M().min(1)).optional(),pendingIntentTickets:Co(M().min(1),I({risk:mc,boundary:Ql,tickets:F(iu).min(1).max(eu)})).optional(),intentBaseShas:Co(M().min(1),M().regex(/^[a-f0-9]{40,64}$/)).optional(),factoryLandedShas:F(M().regex(/^[a-f0-9]{40,64}$/)).optional(),unlandedFactoryRecords:F(uu).optional(),ticketBlockCounts:Co(M().min(1),N().int().nonnegative()).optional(),notifiedIntentOutcomes:F(M().min(1)).optional()}),I({workId:M().min(1),event:M().min(1),sessionId:M().optional(),detail:M().optional()}),yo(`ok`,[I({ok:z(!0),sessionId:M()}),I({ok:z(!1),reason:M()})]);var du=2e4,fu=4e3,pu=524288,mu=1e4,hu=`ExitPlanMode`,gu=4096,_u=/^ {0,3}(#{1,6})[ \t]+(.*)$/;function vu(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 yu(e,{overlongLine:t}){if(t===`reject`&&e.length>4096)return null;let n=_u.exec(e.slice(0,gu));return n?{level:n[1].length,text:vu(n[2])}:null}var bu=I({plan:M().min(1),planFilePath:M().min(1),agent_id:M().min(1).optional(),agent_type:M().min(1).optional()}).passthrough();I({tool_name:z(hu),tool_input:bu,agent_id:M().min(1).optional(),agent_type:M().min(1).optional()}).passthrough(),I({plan:M(),planFilePath:M(),agentId:M().nullable(),agentType:M().nullable()}).extend({sessionId:M().min(1),revision:N().int().positive(),receivedAt:N().finite()});var xu=R(Object.freeze([`open`,`released`,`decided`,`closed`])),Su=R(Object.freeze([`approve`,`approve-accept-edits`,`revise`,`terminal`])),Cu=I({heading:M().max(fu).nullable(),comment:M().min(1).max(fu)}),wu=I({id:M().min(1),agentId:M().nullable(),revision:N().int().positive(),decision:Su,feedback:M().max(du).optional(),comments:F(Cu).max(40).optional(),plan:M().min(1).max(pu).optional()}),Tu=I({revision:N().int().positive(),receivedAt:N().finite(),chars:N().int().nonnegative(),title:M()}),Eu=I({revision:N().int().positive(),since:N().finite()}),Du=I({agentId:M().nullable(),agentType:M().nullable(),revisions:F(Tu),state:xu,openRevision:Eu.nullable(),approvedRevision:N().int().positive().nullable(),lastDecision:Su.nullable()});I({reviews:F(Du)});var Ou=I({agentId:M().nullable(),revision:N().int().nonnegative(),plan:M(),planFilePath:M(),receivedAt:N().finite()}),ku=I({id:M(),agentId:M().nullable(),agentType:M().nullable(),revision:N().int().positive(),receivedAt:N().finite(),state:xu,lastDecision:Su.nullable(),approvedRevision:N().int().positive().nullable(),chars:N().int().nonnegative(),title:M(),hasPlan:P()}),Au=I({id:M(),agentId:M().nullable(),planFilePath:M(),changedAt:N().finite()}),ju=I({id:M(),reviews:F(Du),body:Ou.nullable()});Object.freeze([`file`,`subsystem`,`co-change`,`hotspot`,`blast`,`untested`,`collision`,`link`]);var Mu=M().min(1),Nu=M().min(1),Pu=N().int().nonnegative(),Fu=F(Nu).max(20),Iu=R([`added`,`modified`,`deleted`,`renamed`,`untracked`]),Lu=L({factId:Mu,path:Nu,previousPath:Nu.optional(),status:Iu,isCommitted:P()}),Ru=L({factId:Mu,agentsPath:Nu,title:M(),paths:F(Nu).min(1)}),zu=L({factId:Mu,path:Nu,partner:Nu,support:Pu,confidence:N().min(0).max(1)}),Bu=L({factId:Mu,path:Nu,commitCount:Pu,fixCommitCount:Pu}),Vu=L({factId:Mu,path:Nu,directDependents:Fu,directDependentCount:Pu,transitiveDependentCount:Pu,dependentTests:Fu,dependentTestCount:Pu}),Hu=L({factId:Mu,path:Nu}),Uu=L({factId:Mu,path:Nu,otherSessionId:M().min(1),otherSessionName:M()}),Wu=L({factId:Mu,providerRepo:M().min(1),packageName:M().min(1),packageDir:M(),consumerManifest:Nu,versionSpec:M(),isLocalLink:P(),providerChangedPathCount:Pu,importers:Fu,importerCount:Pu,changedImporterCount:Pu}),Gu=L({name:M().min(1),root:M().min(1),sessionPathPrefix:M(),base:M().nullable(),files:F(Lu),subsystems:F(Ru),coChangeGaps:F(zu),hotspots:F(Bu),blastRadius:F(Vu),untestedFiles:F(Hu),collisions:F(Uu),links:F(Wu),error:M().nullable()}),Ku=L({text:M().min(1).max(600),factIds:F(Mu).min(1)}),qu=L({factsHash:M().min(1),model:M().nullable(),claims:F(Ku).max(12)}),Ju=R([`disabled`,`pending`,`ready`,`failed`]),Yu=L({sessionId:M().min(1),sig:M().nullable(),generatedAt:N().finite(),repos:F(Gu),narrative:qu.nullable(),narratorState:Ju,error:M().min(1).optional()}),Xu=4e3,Zu=I({ts:N().finite(),uuid:M().nullable(),parentUuid:M().nullable(),vendorSessionId:M().min(1),agentId:M().min(1).optional(),agentType:M().min(1).optional(),transcriptOffset:N().int().nonnegative().optional(),truncated:P().optional()}),Qu=yo(`kind`,[Zu.extend({kind:z(`prompt`),text:M()}),Zu.extend({kind:z(`expansion`),text:M(),toolUseId:M().min(1).optional()}),Zu.extend({kind:z(`thinking`),text:M()}),Zu.extend({kind:z(`assistant`),text:M()}),Zu.extend({kind:z(`tool_call`),toolUseId:M().min(1),name:M().min(1),input:lo()}),Zu.extend({kind:z(`tool_result`),toolUseId:M().min(1),content:M(),isError:P(),truncated:P()}),Zu.extend({kind:z(`session`),vendor:M().min(1),transcriptPath:M().min(1),reason:M().min(1).optional()}),Zu.extend({kind:z(`notice`),text:M().max(Xu)}),Zu.extend({kind:z(`raw`),line:M().max(Xu)})]);I({transcriptPath:M().min(1),vendorSessionId:M().min(1),offset:N().int().nonnegative(),ingestedSubagentPaths:F(M().min(1)),offsetByTranscriptPath:Co(M().min(1),N().int().nonnegative()).default({}),subagentOffsetByPath:Co(M().min(1),N().int().nonnegative()).default({})});var $u=R([`release`,`main`]),ed=R([`idle`,`running`,`staged`,`succeeded`,`failed`,`discarded`,`interrupted`]),td=R([`fetch`,`stage`,`install`,`link-deps`,`build`]),nd=I({id:td,status:R([`pending`,`running`,`succeeded`,`failed`]),startedAt:N().finite().nullable(),finishedAt:N().finite().nullable(),outputTail:F(M())}).strict(),rd=I({state:ed,fromSha:M().nullable(),toSha:M().nullable(),toVersion:M().nullable(),channel:$u,steps:F(nd),activeStep:td.nullable(),reason:M().nullable(),startedAt:N().finite().nullable(),finishedAt:N().finite().nullable(),failedAtHandOff:P().optional()}).strict(),id=rd.pick({state:!0,activeStep:!0,reason:!0,startedAt:!0,finishedAt:!0}),ad=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,od=/^[A-Za-z_][A-Za-z0-9_]*$/,sd=M().regex(/^[^/\s]+\/[^/\s]+$/),cd=N().finite(),ld=M().min(1),ud=Object.freeze([`CLAUDE_CODE_OAUTH_TOKEN`]),dd=M().regex(ad);function fd(e){return new Set(e.map(e=>e.id)).size===e.length}var pd=yo(`kind`,[L({kind:z(`manual`)}),L({kind:z(`github-merged-prs`),repo:sd,minBodies:N().int().min(1),limit:N().int().min(1).max(500)})]),md=yo(`kind`,[L({kind:z(`none`)}),L({kind:z(`pr-checkout`)})]),hd=L({promptTemplate:ld,output:R([`review-findings`,`json`]),timeoutSeconds:N().int().min(30).max(14400)}),gd=L({id:dd,env:Co(M().regex(od),M()).refine(e=>ud.every(t=>!Object.hasOwn(e,t)),{message:`arm env must not set ${ud.join(`, `)}; Glimmervoid injects it per cell`}).optional(),extraArgs:F(M()).optional(),setup:L({command:F(ld).min(1)}).optional()}),_d=yo(`kind`,[L({kind:z(`llm-judge-match`),model:ld})]);L({id:dd,title:ld,caseSource:pd,workspace:md,subject:hd,arms:F(gd).min(2).refine(fd,{message:`arm ids must be unique`}),baselineArm:dd,trials:N().int().min(1).max(20),scorer:_d}).refine(e=>e.arms.some(t=>t.id===e.baselineArm),{message:`baselineArm must name one of the arms`,path:[`baselineArm`]});var vd=L({id:dd,text:ld,tags:F(dd),path:ld.optional(),line:N().int().positive().optional()}),yd=yo(`kind`,[L({kind:z(`manual`)}),L({kind:z(`github-pr`),repo:sd,number:N().int().positive(),url:ld,minedAt:cd})]);L({id:dd,input:Co(M(),lo()),references:F(vd).min(1).refine(fd,{message:`reference ids must be unique`}),source:yd}),I({repo:sd,number:N().int().positive(),reviewedSha:B,baseSha:B,changedFiles:F(ld)});var bd=L({referenceId:dd,verdict:R([`found`,`partial`,`missed`]),findingIndexes:F(N().int().nonnegative())}),xd=R([`scored`,`invalid`,`error`]),Sd=L({caseId:dd,armId:dd,trial:N().int().min(1),status:xd,startedAt:cd,finishedAt:cd,degradedReasons:F(ld),findingCount:N().int().nonnegative(),judgements:F(bd),costUsd:N().finite().nonnegative().nullable(),error:ld.nullable()}),Cd=R([`running`,`completed`,`interrupted`,`failed`]);L({id:dd,suiteId:dd,status:Cd,startedAt:cd,finishedAt:cd.nullable(),error:ld.nullable(),cells:F(Sd)});var wd=N().min(0).max(1).nullable(),Td=L({trials:N().int().nonnegative(),recall:wd,recallByTag:Co(dd,wd),degraded:N().int().nonnegative(),invalid:N().int().nonnegative(),costUsd:N().finite().nonnegative().nullable()}),Ed=L({caseId:dd,arms:Co(dd,Td),deltaVsBaseline:Co(dd,N().min(-1).max(1).nullable())}),Dd=L({runId:dd,suiteId:dd,status:Cd,baselineArm:dd,armIds:F(dd),rows:F(Ed),totals:Co(dd,Td)}),Od=R([`mine`,`run`,`cancel`]),kd=I({suiteId:dd,action:Od}),Ad=I({suiteId:dd,action:Od,ok:P(),error:M().optional(),runId:dd.optional()}),jd=R([`setup`,`preflight`,`workspace`,`subject`,`judge`]),Md=I({suiteId:dd,runId:dd,caseId:dd.nullable(),armId:dd,trial:N().int().min(1),phase:jd,cellIndex:N().int().nonnegative(),cellCount:N().int().positive(),startedAt:cd}),Nd=I({id:dd,title:M(),error:M().nullable(),caseCount:N().int().nonnegative(),candidateCount:N().int().nonnegative(),armIds:F(dd),baselineArm:dd.nullable(),latestReport:Dd.nullable()}),Pd=I({type:z(`benchmark-status`),ts:cd,configured:P(),reason:M().nullable(),suites:F(Nd),inFlight:Md.nullable()}).passthrough(),Fd=I({__typename:M(),login:M()}).nullable();I({number:N().int().positive(),title:M(),url:ld,mergedAt:M().nullable(),reviewThreads:I({totalCount:N().int().nonnegative()}),reviews:I({totalCount:N().int().nonnegative()})});var Id=I({path:M(),line:N().int().positive().nullable(),originalLine:N().int().positive().nullable(),comments:I({nodes:F(I({databaseId:N().int().positive(),author:Fd,body:M(),createdAt:M(),originalCommit:I({oid:B}).nullable()}))})}),Ld=I({databaseId:N().int().positive(),author:Fd,body:M(),submittedAt:M().nullable(),commit:I({oid:B}).nullable()}),Rd=yo(`__typename`,[I({__typename:z(`BaseRefChangedEvent`),createdAt:M()}),I({__typename:z(`BaseRefForcePushedEvent`),createdAt:M(),beforeCommit:I({oid:B}).nullable()})]);I({author:Fd,baseRefOid:B,reviewThreads:I({pageInfo:I({hasNextPage:P()}),nodes:F(Id)}),reviews:I({pageInfo:I({hasNextPage:P()}),nodes:F(Ld)}),timelineItems:I({pageInfo:I({hasNextPage:P()}),nodes:F(Rd)})}),I({mergeBaseSha:B,changedFiles:F(ld),isFileListComplete:P()});var H=M().nullable().optional(),U=M(),zd=Qs.shape.unlinkedKeys.unwrap().element,Bd=/^https:\/\/github\.com\/([^/\s]+\/[^/\s]+)\/pull\/([0-9]+)(?:[/?#].*)?$/i;function Vd(e){let t=e.trim(),n=Bd.exec(t),r=n?`${n[1]}#${n[2]}`:t,i=zd.safeParse(r);return i.success?i.data:null}function W(e,t){return ho({type:z(e),...t})}function Hd(e={}){return ho(e)}var Ud=M().nullable(),Wd=N().finite(),Gd=Wd.optional(),Kd=Ud.optional(),qd=Hd(),Jd=F(lo()),Yd=N().int().positive(),Xd=M().min(1).max(fc),Zd=F(Hd({at:Wd,tool:M(),detail:M()}));I({id:M(),label:M(),command:M(),args:F(M()),resolvable:P().nullable()}).strict();var Qd=I({id:U,session:M(),taskTitle:ac.nullable().optional(),taskTitleIsCustom:P().optional(),path:M(),agent:M(),state:oc,stateSince:Wd,skipPerms:P(),saneYolo:P(),worktree:P(),workspace:P().optional(),guarded:P().optional(),resumeSessionId:Ud,ephemeral:P().optional(),linkedPrs:F(Zs).optional()}),$d=1e3,ef=RegExp(`^[^\0--Ÿ]+$`),tf=L({section:R([`committed`,`uncommitted`]),path:M().min(1).max(400).regex(ef),line:N().int().positive(),side:R([`old`,`new`]),note:M().min(1).max($d)}),nf=4096,rf=nf+2*(pu+du+80*fu),af=I({reason:M(),message:M()}),of=R([`npm-global`,`npx`,`clone`,`unknown`]),sf={updateAvailable:P(),current:Ud,latest:Ud,currentSha:Ud,latestSha:Ud,releaseUrl:Ud,command:M(),flavor:of,platform:M(),installedBranch:Ud,upstream:Ud,isTreeClean:P().nullable(),lastCheckAt:Wd,channel:$u,behindCount:N().int().nonnegative().nullable(),reason:Ud,journalSummary:id.nullable(),applyRefusal:af.nullable()};I(sf);var cf=8192,lf=I({name:M().max(128),stack:M().max(cf)}).strict(),uf=[`remove-session`,`kill`,`start-session`,`restart`,`force-restart`,`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 df(e){return W(e,{id:U,force:lo().optional()})}var ff=uf.map(df);yo(`type`,[W(`add-session`,{name:M(),path:M(),repos:F(M()).optional(),agent:M().optional(),dangerouslySkipPermissions:P().optional(),unguarded:P().optional()}),W(`list-conversations`,{id:U,requestId:H}),W(`resume-conversation`,{id:U,conversationId:M()}),W(`rename-session`,{id:U,newName:M()}),W(`get-workspace-repos`,{id:U,requestId:H}),W(`set-workspace-repos`,{id:U,repos:F(M()),requestId:H}),W(`set-session-title`,{id:U,title:ac}),W(`link-session-pr`,{id:U,key:zd}),W(`unlink-session-pr`,{id:U,key:zd}),W(`ping`,{requestId:H}),W(`get-settings`,{requestId:H}),W(`update-settings`,{settings:Co(M(),lo()),requestId:H}),W(`scan-repo-roots`,{requestId:H,includeSuggestions:P().optional()}),W(`list-agents`,{requestId:H,rescan:P().optional()}),W(`get-radar-report`,{issueId:_o([M(),N()]),requestId:H}),W(`radar-open-session`,{projectId:_o([M(),N()]),issueId:_o([M(),N()]),requestId:H}),W(`issue-detail`,{requestId:M().min(1),repo:cs,issueNumber:N().int().positive()}),W(`open-issue-session`,{requestId:H,projectId:M(),repo:cs,issueNumber:N().int().positive()}),W(`radar-issue-action`,{projectId:_o([M(),N()]),issueId:_o([M(),N()]),action:M(),requestId:H}),W(`open-team-review-session`,{requestId:H,key:zd}),W(`team-review-action`,{...Ene.shape,requestId:H}).refine(Hs,{message:`only discard may omit head`,path:[`head`]}),W(`factory-queue-intent`,{...au.shape,requestId:H}),W(`factory-control`,{...su.shape,requestId:H}),W(`benchmark-action`,{...kd.shape,requestId:H}),W(`my-pr-merge`,{...Gne.shape,requestId:H}),W(`my-pr-keep-mergeable`,{...Ine.shape,requestId:H}),W(`my-pr-merge-when-ready`,{...Rne.shape,requestId:H}),W(`github-polling-refresh`,{...os.shape,requestId:H}),W(`radar-archive-investigation`,{id:lo().optional(),requestId:H}),W(`request-usage-report`,{requestId:H,days:lo().optional(),force:lo().optional()}),W(`request-hooks-report`,{requestId:H}),W(`send-diff-annotations`,{id:U,annotations:F(tf).min(1).max(50),requestId:H}),W(`save-hook`,{hook:Co(M(),lo()),requestId:H}),W(`delete-hook`,{id:M(),requestId:H}),W(`shutdown`),W(`restart-server`),W(`focus-change`,{focused:P()}),W(`request-health-snapshot`),W(`update-check`),W(`update-apply`),W(`session-trace`,{id:U,requestId:H,after:N().int().nonnegative().default(0),endingAt:_o([N().int().nonnegative(),z(`tail`)]).optional()}),W(`session-plan`,{id:U,agentId:Ud,revision:Yd.optional(),draft:P().optional()}),W(`plan-decision`,wu.shape),W(`set-session-conversation-view`,{id:U,isOn:P()}),W(`conversation-approval`,{id:U,requestId:uc.shape.requestId,decision:$ne,answers:Qne.optional()}),W(`session-doc-read`,{id:U,path:Xd,requestId:H}),W(`session-doc-save`,{id:U,path:Xd,text:M(),baseHash:M().min(1),requestId:H}),W(`client-error`,lf.shape),W(`dismiss`,{id:U,force:lo().optional(),expectedState:oc.optional()}),...ff]),Object.freeze(`snapshot.hooks-report.save-hook-result.delete-hook-result.workspace-repos.set-workspace-repos-result.hooks-updated.state-change.session-added.session-removed.session-renamed.session-title.session-prs.session-modified.session-git.session-agents.session-wakeup.session-prompt.session-conversation.session-merge-status.session-worktree-blocked.session-worktree-warning.session-worktree-ready.session-diff.session-diff-error.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.session-docs-changed.session-docs-snapshot.session-doc-response.session-doc-save-result.notify.update-status.update-progress.post-turn-leftovers.error.session-error.settings.settings-error.settings-updated.pong.agents-listed.repo-roots-scanned.conversations.resume-conversation-ack.health-snapshot.radar-status.radar-investigation-activity.radar-investigation-finished.radar-report.radar-open-session-result.issue-detail-result.open-issue-session-result.open-team-review-session-result.radar-issue-action-result.team-review-action-result.benchmark-action-result.factory-queue-intent-result.factory-control-result.my-pr-merge-result.my-pr-keep-mergeable-result.my-pr-merge-when-ready-result.github-polling-refresh-result.radar-archive-investigation-result.team-review-status.benchmark-status.factory-state.my-prs-status.issues-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.shutting-down.restarting`.split(`.`));var pf=yo(`type`,[W(`snapshot`,{sessions:F(dc),serverBuild:Ud}),W(`hooks-report`,{requestId:H,ts:Gd,hooks:F(qd).optional(),builtin:F(qd).optional(),events:F(Hd({name:M(),matcher:Ud,description:M(),http:P().optional()})).optional(),projects:F(Hd({id:M(),name:M(),agent:M()})).optional(),limits:Hd({maxTimeoutSec:N().int().positive()}).optional(),error:Kd}),W(`save-hook-result`,{requestId:H,ok:P(),error:Kd,hook:qd.optional()}),W(`delete-hook-result`,{requestId:H,ok:P(),error:Kd,id:M().optional()}),W(`workspace-repos`,{requestId:H,id:U,ok:P(),repos:F(M()),error:Kd}),W(`set-workspace-repos-result`,{requestId:H,id:U,ok:P(),error:Kd}),W(`hooks-updated`,{count:N().int().nonnegative()}),W(`state-change`,{id:U,session:M(),from:oc,to:oc,event:M(),timestamp:Wd,skipPerms:P().optional(),saneYolo:P().optional()}),W(`session-added`,Qd.shape),W(`session-modified`,Qd.shape),W(`session-removed`,{id:U,session:M()}),W(`session-renamed`,{id:U,oldName:M(),newName:M()}),W(`session-title`,{id:U,taskTitle:ac.nullable(),isCustom:P()}),W(`session-prs`,{id:U,linkedPrs:F(Zs)}),W(`session-git`,{id:U,worktree:P()}),W(`session-agents`,{id:U,activeAgents:N().int().nonnegative(),awaitingBackgroundTasks:P(),timestamp:Wd}),W(`session-wakeup`,{id:U,pendingWakeup:sc.nullable(),timestamp:Wd}),W(`session-prompt`,{isCompacting:P().optional(),id:U,pendingPromptKind:Ud,timestamp:Wd}),W(`session-conversation`,{id:U,hasConversationBridge:P(),isConversationViewOn:P(),conversationApproval:uc.nullable()}),W(`session-merge-status`,{id:U,mergeStatus:M(),reason:Ud,parked:P(),timestamp:Wd}),W(`session-worktree-blocked`,{id:U,session:M(),branch:Ud,notice:Ud,timestamp:Wd}),W(`session-worktree-warning`,{id:U,session:M(),branch:Ud,notice:Ud,timestamp:Wd}),W(`session-worktree-ready`,{id:U,session:M(),branch:Ud,base:Ud,timestamp:Wd}),W(`session-diff`,{id:U,committed:Hd({stat:M(),diff:M()}),uncommitted:Hd({stat:M(),diff:M()}),hasCommits:P()}),W(`session-diff-error`,{id:U,message:M()}),W(`change-map`,{id:U,map:Yu}),W(`send-diff-annotations-result`,{requestId:H,ok:P(),error:Kd,pending:P().optional()}),W(`branch-sync-status`,{id:U,branch:Ud,upstream:Ud,state:M(),ahead:N().int().nonnegative(),behind:N().int().nonnegative(),fetched:P().nullable(),action:M().optional(),error:Kd}),W(`session-changed`,{id:U}),W(`post-turn-result`,{id:U,mode:M(),skipped:Ud,filesFixed:N().int().nonnegative(),findings:F(Hd({file:M(),rule:M(),count:N().int().nonnegative()})),timestamp:Wd}),W(`debug-state-response`,{id:U,payload:qd}),W(`session-trace-response`,{id:U,requestId:H,records:F(Qu),start:N().int().nonnegative(),next:N().int().nonnegative(),reset:P(),path:M()}),W(`session-trace-changed`,{id:U}),W(`session-plan-changed`,ku.shape),W(`session-plan-draft`,Au.shape),W(`session-plan-response`,ju.shape),W(`session-docs-changed`,{id:U,docs:F(pc)}),W(`session-docs-snapshot`,{sessions:Co(M(),F(pc))}),W(`session-doc-response`,{requestId:H,id:U,path:M(),ok:P(),text:M().optional(),hash:M().optional(),error:Kd}),W(`session-doc-save-result`,{requestId:H,id:U,path:M(),ok:P(),hash:M().optional(),conflict:P().optional(),error:Kd}),W(`notify`,{session:M(),category:M(),message:M(),escalationCount:N().int().nonnegative(),kind:z(`plan`).optional()}),W(`update-status`,sf),W(`update-progress`,{journal:rd}),W(`post-turn-leftovers`,{repositories:F(M()),command:M()}),W(`error`,{id:U.optional(),message:M(),requestId:H,scope:M().optional()}),W(`session-error`,{id:U.optional(),session:M(),message:M(),scope:M().optional()}),W(`settings`,{settings:qd,requestId:H}),W(`settings-error`,{message:M(),requestId:H}),W(`settings-updated`,{settings:qd,requestId:H}),W(`pong`,{requestId:H}),W(`agents-listed`,{requestId:H,agents:F(Hd({id:M(),label:M(),resolvable:P()}))}),W(`repo-roots-scanned`,{requestId:H,directories:F(Hd({root:M(),projects:F(Hd({name:M(),path:M()}))})),suggestions:F(Hd({path:M(),label:M(),gitRepoCount:N().int().nonnegative()})).optional(),error:M().optional()}),W(`conversations`,{requestId:H,id:Ud,current:Ud.optional(),conversations:F(Hd({id:M(),title:M(),cwd:M(),worktreePath:M(),worktreeName:M(),gitBranch:Ud,mtime:Wd})),error:M().optional()}),W(`resume-conversation-ack`,{id:U.optional(),resumeSessionId:Ud.optional(),ok:P(),error:M().optional(),requestId:H}),W(`health-snapshot`,{stats:qd}),W(`radar-status`,{ts:Wd,intervalMinutes:N(),projects:F(qd),investigations:F(qd)}),W(`radar-investigation-activity`,{projectId:_o([M(),N()]),issueId:M(),inFlight:z(!0),startedAt:Wd.nullable(),trail:Zd}),W(`radar-investigation-finished`,{projectId:_o([M(),N()]),issueId:M(),verdict:M(),summaryLine:Ud,startedAt:Wd.nullable(),trail:Zd}),W(`radar-report`,{requestId:H,ok:P(),found:P(),issueId:Ud,format:M().optional(),content:M().optional(),message:M().optional(),error:M().optional()}),W(`radar-open-session-result`,{requestId:H,ok:P(),error:Kd,sessionId:M().optional(),sessionName:M().optional(),pending:P().optional()}),W(`issue-detail-result`,{requestId:M().min(1),ok:P(),body:M().nullable(),error:M().nullable()}),W(`open-issue-session-result`,{requestId:H,ok:P(),error:Kd,sessionId:M().optional(),sessionName:M().optional(),pending:P().optional(),existing:P().optional()}),W(`open-team-review-session-result`,{requestId:H,ok:P(),error:Kd,key:zd.optional(),sessionId:M().optional(),sessionName:M().optional(),pending:P().optional(),existing:P().optional()}),W(`radar-issue-action-result`,{requestId:H,ok:P(),error:Kd,status:Ud.optional()}),W(`team-review-action-result`,{...Dne.shape,requestId:H}),W(`factory-queue-intent-result`,{...ou.shape,requestId:H}),W(`factory-control-result`,{...cu.shape,requestId:H}),W(`benchmark-action-result`,{...Ad.shape,requestId:H}),W(`my-pr-merge-result`,{...nc.shape,requestId:H}),W(`my-pr-keep-mergeable-result`,{...Lne.shape,requestId:H}),W(`my-pr-merge-when-ready-result`,{...zne.shape,requestId:H}),W(`github-polling-refresh-result`,{...ss.shape,requestId:H}),W(`radar-archive-investigation-result`,{requestId:H,ok:P(),error:Kd}),Ws,Pd,W(`factory-state`,Jl.shape),tc,_s,W(`usage-sessions`,{ts:Wd,pricingSource:Ud,sessions:F(Hd({id:U,tokens:N(),costUSD:N(),officialCostUSD:N().nullable().optional()}))}),W(`usage-report`,{requestId:H,ts:Gd,tz:M().optional(),blockHours:N().optional(),totals:qd.optional(),daily:Jd.optional(),models:Jd.optional(),sessions:Jd.optional(),blocks:Jd.optional(),activeBlock:lo().nullable().optional(),anomaly:lo().nullable().optional(),byLane:lo().optional(),planWindowLanes:lo().nullable().optional(),budget:lo().optional(),savings:lo().optional(),tokenLimit:lo().nullable().optional(),pricing:qd.optional(),scan:qd.optional(),warning:Kd,error:Kd}),W(`plan-limits`,{ts:Wd,fiveHour:lo().nullable(),sevenDay:lo().nullable(),source:M()}),W(`usage-budget-alert`,{scope:M(),periodKey:M(),threshold:N(),text:M(),ts:Wd}),W(`visions-findings`,{uri:M(),diagnostics:Jd,ts:Wd}),W(`visions-comments`,{uri:M(),comments:Jd,ts:Wd}),W(`visions-hand`,{uri:M(),hand:Ud,ts:Wd}),W(`visions-intent`,{projectId:Ud,intent:qd,ts:Wd}),W(`visions-fix`,{uri:M(),fix:qd,ts:Wd}),W(`visions-snapshot`,{documents:F(qd),intent:qd,fixes:F(qd),ts:Wd}),W(`ingest-activity`,{events:F(qd),overflow:N().int().nonnegative(),ts:Wd}),W(`ingest-snapshot`,{events:F(qd),sources:lo(),ts:Wd}),W(`client-trust`,{trust:R([`local`,`remote`])}),W(`shutting-down`),W(`restarting`)]),mf=/^\s*at .+:\d+:\d+\)?$|^[^@\s]*@.+:\d+:\d+$/;function hf(e){let t=e.stack??``,n=String(e);return(t.startsWith(n)?t.slice(n.length):t).split(`
56
+ `).filter(e=>mf.test(e)).join(`
57
+ `)}function gf(e){return e==null?null:e instanceof Error?{name:(e.name||`Error`).slice(0,128),stack:hf(e).slice(0,cf)}:{name:`NonError`,stack:``}}function _f(e){let t=new Set;return n=>{let r=gf(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 vf=[{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`}],yf=1/25,bf=3;function xf(e,t,n){return typeof e!=`number`||!Number.isFinite(e)?t:Math.min(n.max,Math.max(n.min,e))}function Sf(e){if(!Array.isArray(e))return[];let t=new Set(vf.map(e=>e.sprite));return[...new Set(e.filter(e=>typeof e==`string`&&t.has(e)))]}function Cf(e={}){let t=wc,n=xc,r=Sc,i=xf(e.flyingAnimalsMinGapSeconds,t.flyingAnimalsMinGapSeconds,n),a=xf(e.flyingAnimalsMaxGapSeconds,t.flyingAnimalsMaxGapSeconds,n),o=xf(e.flyingAnimalsMinDurationSeconds,t.flyingAnimalsMinDurationSeconds,r),s=xf(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:xf(e.flyingAnimalsScale,t.flyingAnimalsScale,Cc),flyingAnimalsOnPhone:typeof e.flyingAnimalsOnPhone==`boolean`?e.flyingAnimalsOnPhone:t.flyingAnimalsOnPhone,flyingAnimalsExcludedSprites:Sf(e.flyingAnimalsExcludedSprites)}}function wf(e){return vf.some(t=>!e.includes(t.sprite))}function Tf(e,t=-1,n=Math.random){let r=vf.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 Ef(e,t,n=Math.random,r){let i=r===void 0?Tf(e.flyingAnimalsExcludedSprites,t,n):vf.findIndex(e=>e.sprite===r);if(i===null||i<0)return null;let a=e.flyingAnimalsMinDurationSeconds+n()*(e.flyingAnimalsMaxDurationSeconds-e.flyingAnimalsMinDurationSeconds),o=1e3*(e.flyingAnimalsMinGapSeconds+n()*(e.flyingAnimalsMaxGapSeconds-e.flyingAnimalsMinGapSeconds)),s=n()*a,c=n(),l=n()<.5,u=n()<yf?bf:1;return{animalIndex:i,durationSeconds:a,gapMs:o,firstDelaySeconds:s,verticalProgress:c,isRightToLeft:l,arcProgress:(n()*2-1)*u}}function Df({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.`}var Of=68,kf=42,Af=768,jf=.68,Mf=64,Nf=5,Pf=8,Ff=85;function If(e,t,n){return Math.min(Math.max(e,t),n)}function Lf({viewportWidthPx:e,viewportHeightPx:t,verticalProgress:n,isRightToLeft:r=!1,arcProgress:i=0}){let a=If(e/Af,jf,1),o=(Nf+70*n*n)*t/100,s=Math.max(o,Mf),c=Ff*t/100,l=If(i*Pf*t/100,Mf-s,c-s),u=-.45*e,d=1.45*e;return{scale:a,spriteWidthPx:Of,spriteHeightPx:kf,topPx:s,startXpx:r?d:u,endXpx:r?u:d,facing:r?-1:1,arcPx:l}}function Rf(e,t){let n=Number.isFinite(t)&&t>0?t:1;return Math.max(1,Math.round(e*n))/n}function zf(e,t,n){let r=Rf(e.scale*t,n);return[[`--nyan-top`,`${e.topPx}px`],[`--nyan-scale`,String(r)],[`--nyan-width`,`${e.spriteWidthPx}px`],[`--nyan-height`,`${e.spriteHeightPx}px`],[`--nyan-start-x`,`${e.startXpx}px`],[`--nyan-end-x`,`${e.endXpx}px`],[`--nyan-facing`,String(e.facing)],[`--nyan-arc`,`${e.arcPx}px`],[`--nyan-travel`,`${Math.abs(e.endXpx-e.startXpx)/r}px`]]}var Bf=`chime`,Vf=`custom:`,Hf=`/custom-sounds`,Uf=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`}]}}),Wf=Object.freeze(Object.entries(Uf).map(([e,t])=>({id:e,label:t.label})));function Gf(e){return`${Vf}${e}`}function Kf(e){return`${Hf}/${encodeURIComponent(e)}`}function qf(e){return e.startsWith(Vf)&&e.slice(7)||null}function Jf(e){let t=(e??[]).map(e=>({id:Gf(e),label:e}));return[...Wf,...t]}function Yf(e,t){if(typeof e!=`string`)return Bf;if(Object.hasOwn(Uf,e))return e;let n=qf(e);return n&&(t===null||t.includes(n))?e:Bf}function Xf(e){return typeof e!=`object`||!e||!(`sounds`in e)||!Array.isArray(e.sounds)?[]:e.sounds.filter(e=>typeof e==`string`&&e!==``)}function Zf(e,t){try{let n=localStorage.getItem(e);return n===null?t:JSON.parse(n)}catch{return t}}function Qf(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}var $f=`glimmervoid-ui-prefs`,ep=`glimmervoid:sidebar-width`,tp=e=>t=>typeof t==`boolean`?t:e,np=e=>t=>typeof t==`string`?t:e,rp=e=>typeof e==`string`&&e?e:null,ip=e=>typeof e==`number`&&Number.isFinite(e)?e:null,ap=e=>t=>ip(t)??e,op=e=>Array.isArray(e)?[...new Set(e.filter(e=>typeof e==`string`&&e!==``))]:[],sp={soundEnabled:tp(!0),soundId:np(Bf),themeId:np(`phyrexian`),flyingAnimalsEnabled:tp(!1),flyingAnimalsMinGapSeconds:ap(wc.flyingAnimalsMinGapSeconds),flyingAnimalsMaxGapSeconds:ap(wc.flyingAnimalsMaxGapSeconds),flyingAnimalsMinDurationSeconds:ap(wc.flyingAnimalsMinDurationSeconds),flyingAnimalsMaxDurationSeconds:ap(wc.flyingAnimalsMaxDurationSeconds),flyingAnimalsScale:ap(wc.flyingAnimalsScale),flyingAnimalsOnPhone:tp(wc.flyingAnimalsOnPhone),flyingAnimalsExcludedSprites:Sf,notificationsEnabled:tp(!0),compactStatusLabels:tp(!1),sessionUsageChips:tp(!1),activeView:np(`focus`),lastFocusedSessionId:rp,railWidth:ip,reviewSidebarExpanded:tp(!1),reviewSidebarView:e=>e===`map`||e===`notes`?e:`diff`,prsQueueWidth:ip,prsQueueCollapsed:tp(!1),prsMode:e=>e===`mine`?`mine`:`team`,keptProjects:op,traceHiddenKinds:op,dismissedUpdate:rp,telemetryNoticeDismissed:tp(!1),radarAttentionAck:np(``),prsAttentionAck:np(``),usageAttentionAck:np(``),visionsAttentionAck:np(``)};function cp(e,t,n){e[t]=sp[t](n)}function lp(){let e=Zf($f,{}),t={};for(let n of Object.keys(sp))cp(t,n,e?.[n]);return t}function up(e){return lp()[e]}function dp(e,t){let n=lp();cp(n,e,t),Qf($f,n)}var fp=()=>up(`soundEnabled`),pp=e=>dp(`soundEnabled`,e),mp=()=>up(`soundId`),hp=e=>dp(`soundId`,e),gp=()=>up(`notificationsEnabled`),_p=e=>dp(`notificationsEnabled`,e),vp=()=>up(`compactStatusLabels`),yp=e=>dp(`compactStatusLabels`,e),bp=()=>up(`sessionUsageChips`),xp=e=>dp(`sessionUsageChips`,e),Sp=()=>up(`themeId`),Cp=e=>dp(`themeId`,e),wp=()=>up(`flyingAnimalsEnabled`),Tp=e=>dp(`flyingAnimalsEnabled`,e),Ep=()=>up(`activeView`),Dp=e=>dp(`activeView`,e),Op=()=>up(`railWidth`),kp=e=>dp(`railWidth`,e),Ap=()=>up(`reviewSidebarExpanded`),jp=e=>dp(`reviewSidebarExpanded`,e),Mp=()=>up(`reviewSidebarView`),Np=e=>dp(`reviewSidebarView`,e),Pp=()=>up(`prsQueueWidth`),Fp=e=>dp(`prsQueueWidth`,e),Ip=()=>up(`prsQueueCollapsed`),Lp=e=>dp(`prsQueueCollapsed`,e),Rp=()=>up(`prsMode`),zp=e=>dp(`prsMode`,e),Bp=()=>up(`keptProjects`),Vp=e=>dp(`keptProjects`,e),Hp=()=>up(`traceHiddenKinds`),Up=e=>dp(`traceHiddenKinds`,e),Wp=()=>up(`dismissedUpdate`),Gp=e=>dp(`dismissedUpdate`,e),Kp=()=>up(`telemetryNoticeDismissed`),qp=e=>dp(`telemetryNoticeDismissed`,e),Jp=()=>up(`radarAttentionAck`),Yp=e=>dp(`radarAttentionAck`,e),Xp=()=>up(`prsAttentionAck`),Zp=e=>dp(`prsAttentionAck`,e),Qp=()=>up(`usageAttentionAck`),$p=e=>dp(`usageAttentionAck`,e),em=()=>up(`visionsAttentionAck`),tm=e=>dp(`visionsAttentionAck`,e),nm=()=>up(`lastFocusedSessionId`),rm=e=>dp(`lastFocusedSessionId`,e),im=()=>ip(Zf(ep,null)),am=e=>Qf(ep,ip(e)),om=e=>dp(`flyingAnimalsMinGapSeconds`,e),sm=e=>dp(`flyingAnimalsMaxGapSeconds`,e),cm=e=>dp(`flyingAnimalsMinDurationSeconds`,e),lm=e=>dp(`flyingAnimalsMaxDurationSeconds`,e),um=e=>dp(`flyingAnimalsScale`,e),dm=e=>dp(`flyingAnimalsOnPhone`,e),fm=e=>dp(`flyingAnimalsExcludedSprites`,e),pm=()=>Cf(lp()),mm=()=>{let e=lp();return Object.fromEntries(Object.keys(wc).map(t=>[t,e[t]]))},hm=()=>Qf($f,{...lp(),...wc}),gm=Lf({viewportWidthPx:1440,viewportHeightPx:900,verticalProgress:0});function _m(e,t=``){let n=m(`div`,`flying-animal-preview ${t}`.trim());n.setAttribute(`aria-hidden`,`true`),n.style.setProperty(`--nyan-width`,`${gm.spriteWidthPx}px`),n.style.setProperty(`--nyan-height`,`${gm.spriteHeightPx}px`);let r=m(`div`,`flying-animal-preview-stage`);return r.append(m(`div`,`nyan-trail ${e.trail}`),m(`div`,`nyan-sprite ${e.sprite}`)),n.append(r),n}function vm(){let e=Tf(pm().flyingAnimalsExcludedSprites);return e===null?null:vf[e]??null}var ym=6e4,bm=18e5,xm=20;function Sm({attempt:e=1,baseMs:t=ym,maxMs:n=bm,retryAfterMs:r=null,random:i=Math.random,jitter:a=`full`}={}){if(typeof r==`number`&&Number.isFinite(r)&&r>0)return Math.min(r,n);let o=Math.max(0,Math.min(e,xm)-1),s=Math.min(n,t*2**o);return a===`none`?s:Math.round(a===`half`?s*(.5+.5*i()):i()*s)}var Cm=3e4;function wm(e,t=Math.random){return Sm({attempt:(typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):0)+1,baseMs:500,maxMs:Cm,random:t,jitter:`half`})}var Tm=0,Em=1,Dm=1e4;function Om(e){return typeof e!=`number`||!Number.isFinite(e)?!1:e>=Dm}function km({hasSocket:e,readyState:t,retryPending:n,connectingAgeMs:r=0,hiddenForMs:i}){return n?`retry-now`:!e||Om(i)?`connect`:t===Tm?r>1e4?`connect`:`wait`:t===Em?`probe`:`connect`}function Am(e){return e===`https:`?`wss:`:`ws:`}function jm(e,t){return`${Am(e?.protocol)}//${e.host}${t}`}var Mm=``,Nm=null;function ore(){return Mm}function Pm(){return Mm?Promise.resolve(Mm):Nm||(Nm=fetch(`/control-token`,{credentials:`same-origin`,cache:`no-store`}).then(e=>e.ok?e.json():null).then(e=>{let t=e?.token;return Mm=typeof t==`string`?t:``,Mm}).catch(()=>``).finally(()=>{Nm=null}),Nm)}function Fm(){Mm=``}function Im(e){return Mm?`${e}${e.includes(`?`)?`&`:`?`}token=${encodeURIComponent(Mm)}`:e}var Lm=null,Rm=null,zm=0,Bm=new Map,Vm=null,Hm=0,Um=!1,Wm=0,Gm=0,Km=null,qm=null;function sre(e){qm=e}function cre(e){Km=e}function G(e){return Lm?.readyState===WebSocket.OPEN&&(Lm.send(JSON.stringify(e)),!0)}function Jm(e){return Gm+=1,`${e}-${Gm}`}function Ym(e,t){let n=Jm(e);return new Promise((r,i)=>{let a=setTimeout(()=>{Bm.delete(n),i(Error(`Request timed out`))},5e3);Bm.set(n,{resolve:r,reject:i,timer:a}),Lm?.readyState===WebSocket.OPEN?Lm.send(JSON.stringify({type:e,requestId:n,...t})):(clearTimeout(a),Bm.delete(n),i(Error(`Not connected`)))})}function Xm(e){for(let t of Bm.values())clearTimeout(t.timer),t.reject(Error(e));Bm.clear()}function Zm(){let e=Lm;Lm=null,Xm(`Connection replaced`),e?.close(),zm=0,Qm()}function Qm(){if(Rm!==null&&(Rm!==null&&clearTimeout(Rm),Rm=null),!ore()&&!Um){Um=!0,Pm().finally(()=>{Um=!1,Qm()});return}if(Um)return;let e=Wm>0?`?since=${Wm}`:``,t=jm(location,Im(`/control${e}`)),n=new WebSocket(t);Lm=n,Hm=Date.now();let r=!1;n.addEventListener(`open`,()=>{r=!0,zm=0,qm&&qm(`connected`,`Connected`)}),n.addEventListener(`message`,e=>{if(Lm!==n)return;let t;try{t=JSON.parse(e.data)}catch{console.warn(`[control] Dropped malformed server JSON message`);return}let r=pf.safeParse(t);if(!r.success){console.warn(`[control] Dropped invalid server message: ${r.error.issues[0]?.message||`invalid payload`}`);return}let i=r.data;if(i.type===`snapshot`&&typeof i.seq!=`number`&&(Wm=0),typeof i.seq==`number`){if(i.seq<=Wm)return;Wm=i.seq}let a=typeof i.requestId==`string`?i.requestId:``,o=a?Bm.get(a):void 0;o?(clearTimeout(o.timer),Bm.delete(a),o.resolve(i)):Km&&Km(i)}),n.addEventListener(`close`,()=>{if(Lm!==n)return;Lm=null,Xm(`Connection closed`),r||Fm(),qm&&qm(`disconnected`,`Reconnecting`);let e=wm(zm);zm+=1,Rm=setTimeout(Qm,e)})}async function lre(e){if(qm&&qm(`connecting`,`Connecting`),Vm)return Vm;let t=km({hasSocket:!!Lm,readyState:Lm?.readyState??null,retryPending:Rm!==null,connectingAgeMs:Date.now()-Hm,hiddenForMs:e});if(t===`retry-now`)return Rm!==null&&clearTimeout(Rm),Rm=null,zm=0,Qm(),`reconnecting`;if(t===`connect`)return Zm(),`reconnecting`;if(t===`wait`)return`reconnecting`;let n=Lm;return Vm=Ym(`ping`,{}).then(()=>(qm&&qm(`verified`,`Connected`),`ok`)).catch(()=>(Lm===n&&n&&Zm(),`dead`)).finally(()=>{Vm=null}),Vm}var ure=`<h2 class="dialog-title" id="add-session-title">Add Session</h2>
58
+ <fieldset class="dialog-mode-controls" aria-label="Session kind">
59
+ <button type="button" class="dialog-mode-button" id="add-session-single-mode" aria-pressed="true">Single repo</button>
60
+ <button type="button" class="dialog-mode-button" id="add-session-workspace-mode" aria-pressed="false">Workspace</button>
61
+ </fieldset>
62
+ <label class="dialog-label" id="add-session-picker-label">
63
+ Pick a project:
64
+ <select class="dialog-input project-picker" id="add-session-picker">
65
+ <option value="" disabled selected>Scanning...</option>
66
+ </select>
67
+ </label>
68
+ <fieldset class="dialog-workspace-list" id="add-session-workspace-list" aria-label="Workspace repositories" hidden></fieldset>
69
+ <div class="dialog-repo-roots" id="add-session-repo-roots" hidden>
70
+ <p class="dialog-repo-roots-title" id="add-session-repo-roots-title">No repository roots yet</p>
71
+ <p class="dialog-repo-roots-desc">Add the folder that holds your git checkouts. Its repos show up right here.</p>
72
+ </div>
73
+ <label class="dialog-label" id="add-session-agent-label" hidden>
74
+ Agent
75
+ <select class="dialog-input" id="add-session-agent"></select>
76
+ </label>
77
+ <button type="button" class="dialog-advanced-toggle" id="add-session-advanced-toggle" aria-controls="add-session-advanced">Run in a folder outside your repository roots</button>
78
+ <div class="dialog-advanced-panel" id="add-session-advanced" hidden>
79
+ <label class="dialog-label">
80
+ Name
81
+ <input type="text" class="dialog-input" id="add-session-name" placeholder="my-project" autocomplete="off" spellcheck="false">
82
+ </label>
83
+ <label class="dialog-label" id="add-session-path-label">
84
+ Path
85
+ <input type="text" class="dialog-input" id="add-session-path" placeholder="C:\\Users\\...\\my-project" autocomplete="off" spellcheck="false">
86
+ </label>
87
+ </div>
88
+ <label class="dialog-label dialog-checkbox-label" id="add-session-skip-perms-label">
89
+ <input type="checkbox" class="dialog-checkbox" id="add-session-skip-perms">
90
+ <span>Skip permission prompts</span>
91
+ <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>
92
+ </label>
93
+ <label class="dialog-label dialog-checkbox-label" id="add-session-unguarded-label">
94
+ <input type="checkbox" class="dialog-checkbox" id="add-session-unguarded">
95
+ <span>Run without guardrails</span>
96
+ <span class="dialog-hint">Claude Code sessions run with guardrails that block writes to credentials and Glimmervoid's own state and hide credentials and other agents' settings. Turn this on only for work the guardrails cannot serve.</span>
97
+ </label>
98
+ <div class="dialog-error" id="add-session-error"></div>
99
+ <div class="dialog-actions">
100
+ <button type="button" class="btn-dialog btn-dialog-cancel" id="add-session-cancel">Cancel</button>
101
+ <button type="button" class="btn-dialog btn-dialog-confirm" id="add-session-confirm">Add</button>
102
+ </div>
103
+ `,$m=`claude-code`,dre=Object.freeze({"claude-code":``,codex:`Codex`,grok:`Grok`});function fre(e){if(typeof e!=`string`)return``;let t=e.trim();return!t||t===`claude-code`?``:dre[t]||t}function eh(e,{defaultId:t=$m}={}){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 pre=`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 th(e){let t=typeof e==`object`&&e?e:null;return t===null||!Array.isArray(t.agents)||t.error||eh(t.agents).options.length>0?{canSpawn:!0,guidance:``}:{canSpawn:!1,guidance:pre}}var mre={agent:`upcoming`,repoRoots:`upcoming`,firstSession:`upcoming`};function nh(e,t){return e<t?`done`:e===t?`current`:`upcoming`}function hre({agentListing:e,repoRoots:t}){let n=th(e).canSpawn?t.length===0?2:3:1;return{agent:nh(1,n),repoRoots:nh(2,n),firstSession:nh(3,n)}}function gre(e){return eh(typeof e==`object`&&e?e.agents:[]).options.map(e=>e.label).join(`, `)}function _re(e){return e===1?`1 git repo`:`${e} git repos`}function vre(e,t){let n=t.trim();return!n||e.includes(n)?null:[...e,n]}var rh=0,ih=`Could not read the current repository roots.`;function yre(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}async function bre(e){let t=await Ym(`get-settings`,{});if(t.type!==`settings`)return ih;let n=t.settings.repoRoots;if(!yre(n))return ih;let r=vre(n,e);if(!r)return null;let i=await Ym(`update-settings`,{settings:{repoRoots:r}});return i.type===`settings-error`?i.message:null}function ah({onAdded:e}){rh+=1;let t=`repo-roots-adder-path-${rh}`,n=m(`div`,`repo-roots-adder`),r=m(`div`,`repo-roots-adder-found`),i=m(`span`,`repo-roots-adder-label`,`FOUND ON THIS MACHINE`),a=m(`ul`,`repo-roots-adder-list`);r.append(i,a),r.hidden=!0;let o=m(`label`,`repo-roots-adder-label`,`TYPE A PATH`);o.htmlFor=t;let s=m(`div`,`repo-roots-adder-row`),c=m(`input`,`dialog-input repo-roots-adder-input`);c.id=t,c.type=`text`,c.placeholder=`~/src`,c.autocomplete=`off`,c.spellcheck=!1;let l=m(`button`,`btn-dialog btn-dialog-cancel`,`Add`);l.type=`button`,l.disabled=!0,s.append(c,l);let u=m(`p`,`repo-roots-adder-error`);u.setAttribute(`role`,`alert`),n.append(r,o,s,u);let d=!1;function f(e){d=e;for(let t of n.querySelectorAll(`button`))t.disabled=e;e||(l.disabled=c.value.trim()===``)}async function p(t){if(!d){f(!0),u.textContent=``;try{let n=await bre(t);if(n){u.textContent=n;return}c.value=``,e()}catch(e){u.textContent=`Could not save the folder: ${e instanceof Error?e.message:String(e)}`}finally{f(!1)}}}c.addEventListener(`input`,()=>{l.disabled=d||c.value.trim()===``}),c.addEventListener(`keydown`,e=>{e.key===`Enter`&&c.value.trim()!==``&&(e.preventDefault(),p(c.value.trim()))}),l.addEventListener(`click`,()=>{p(c.value.trim())});function h(e){a.textContent=``;for(let t of e){let e=m(`li`,`repo-roots-adder-suggestion`),n=m(`button`,`btn-dialog btn-dialog-cancel`,`Add`);n.type=`button`,n.setAttribute(`aria-label`,`Add ${t.label}`),n.addEventListener(`click`,()=>{p(t.path)}),e.append(m(`span`,`repo-roots-adder-path`,t.label),m(`span`,`repo-roots-adder-count`,_re(t.gitRepoCount)),n),a.append(e)}r.hidden=e.length===0,o.textContent=e.length>0?`OR TYPE A PATH`:`TYPE A PATH`}return{element:n,setSuggestions:h}}function xre(e){return[...document.querySelectorAll(`.dialog-overlay`)].at(-1)===e}function oh({dialogClass:e=`dialog`,closeOnBackdrop:t=!0,onEscape:n}={}){let r=document.activeElement,i=document.createElement(`div`);i.className=`dialog-overlay`;let a=document.createElement(`div`);a.className=e,i.appendChild(a),document.body.appendChild(i);function o(e){e.key===`Escape`&&(n?xre(i)&&n():s())}document.addEventListener(`keydown`,o);function s(){i.remove(),document.removeEventListener(`keydown`,o),r instanceof HTMLElement&&r.focus()}return t&&i.addEventListener(`click`,e=>{e.target===i&&s()}),{overlay:i,dialog:a,close:s}}function sh(e,t){e.setAttribute(`role`,`dialog`),e.setAttribute(`aria-modal`,`true`),e.setAttribute(`aria-labelledby`,t),Sre(e)}function ch({title:e,dialogClass:t=`dialog`,cancelLabel:n=`Cancel`}){let{overlay:r,dialog:i,close:a}=oh({dialogClass:t}),o=`dialog-title-${Math.random().toString(36).slice(2)}`,s=m(`h3`,`dialog-title`,e);s.id=o;let c=m(`div`,`dialog-actions`),l=m(`button`,`btn-dialog btn-dialog-cancel`,n);return c.append(l),i.append(s),sh(i,o),{overlay:r,dialog:i,close:a,titleEl:s,actions:c,btnCancel:l}}function lh({title:e,message:t,confirmLabel:n=`Confirm`,danger:r=!1,onConfirm:i}){let{dialog:a,close:o,actions:s,btnCancel:c}=ch({title:e}),l=m(`p`,`dialog-message`,t),u=m(`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 Sre(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];t.shiftKey&&document.activeElement===r?(t.preventDefault(),i.focus()):!t.shiftKey&&document.activeElement===i&&(t.preventDefault(),r.focus())})}function uh(e){return e instanceof Error?e.message:String(e)}function dh(e,t,n=!1){let r=m(`label`,`dialog-checkbox-label`),i=m(`input`);return i.type=`checkbox`,i.className=`dialog-checkbox`,i.value=t,i.checked=n,r.append(i,m(`span`,null,e)),r}function Cre(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}async function wre(e){let[t,n]=await Promise.all([Ym(`get-workspace-repos`,{id:e}),Ym(`scan-repo-roots`,{}).catch(()=>null)]);if(t.type!==`workspace-repos`)throw Error(`Unexpected reply`);if(!t.ok)throw Error(t.error||`Could not read the workspace`);let r=t.repos.map(e=>({name:Cre(e),path:e,isMember:!0})),i=new Set(t.repos),a=n?.type===`repo-roots-scanned`?n.directories:[];for(let e of a.flatMap(e=>e.projects))i.has(e.path)||(i.add(e.path),r.push({name:e.name,path:e.path,isMember:!1}));return r}function Tre(e){let{overlay:t,dialog:n,close:r,actions:i,btnCancel:a}=ch({title:`Workspace repositories`}),o=m(`p`,`dialog-message`,`Saving restarts the session and resumes its conversation. A removed repository keeps its workspace branch, so committed work survives.`),s=m(`fieldset`,`dialog-workspace-list`);s.setAttribute(`aria-label`,`Workspace repositories`),s.append(m(`div`,`dialog-hint`,`Loading repositories...`));let c=m(`div`,`dialog-hint`);c.setAttribute(`role`,`status`);let l=m(`div`,`dialog-error`),u=m(`button`,`btn-dialog btn-dialog-confirm`,`Save`);u.type=`button`,u.disabled=!0,i.append(u),n.append(o,s,c,l,i),a.addEventListener(`click`,r),requestAnimationFrame(()=>a.focus()),wre(e).then(e=>{if(t.isConnected){s.textContent=``;for(let t of e)s.append(dh(t.name,t.path,t.isMember));u.disabled=!1}}).catch(e=>{t.isConnected&&(s.textContent=``,l.textContent=`Could not load repositories: ${uh(e)}`)}),u.addEventListener(`click`,()=>{let n=[...s.querySelectorAll(`input:checked`)].map(e=>e.value);n.length<2?l.textContent=`Select at least two repositories.`:(l.textContent=``,u.disabled=!0,c.textContent=`Saving`,Ym(`set-workspace-repos`,{id:e,repos:n}).then(e=>{if(!t.isConnected)return;if(e.type===`set-workspace-repos-result`&&e.ok){r();return}let n=e.type===`set-workspace-repos-result`?e.error:null;l.textContent=n||`Could not update the workspace.`}).catch(e=>{t.isConnected&&(l.textContent=`Could not update the workspace: ${uh(e)}`)}).finally(()=>{c.textContent=``,u.disabled=!1}))})}function Ere(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 Dre(e,t){let n=0;for(let r of t)Ere(r,e)&&n++;return n}function Ore(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 fh(){let e=[];for(let[,t]of E)e.push(t.card.dataset.session??``);return e}function kre(e){return Dre(e,fh())}function ph(e){return Ore(e??``,fh())}var mh=60,hh=3600,gh=24,_h=1024,vh=_h*1024,yh=vh*1024,Are={compact:{second:e=>`${e}s`,minute:e=>`${e}m`,hour:e=>`${e}h`,day:e=>`${e}d`},abbreviated:{second:e=>`${e} sec`,minute:e=>`${e} min`,hour:e=>`${e} hr`,day:e=>`${e} ${e===1?`day`:`days`}`},spelled:{second:e=>`${e} ${e===1?`second`:`seconds`}`,minute:e=>`${e} ${e===1?`minute`:`minutes`}`,hour:e=>`${e} ${e===1?`hour`:`hours`}`,day:e=>`${e} ${e===1?`day`:`days`}`}},jre={rounding:`floor`,wording:`compact`,suffix:` ago`,justNowBelowSeconds:0};function bh(e){return String(e).padStart(2,`0`)}function xh(e,t){return Math.max(0,Math[t](e/1e3))}function Mre(e,t){let n=Are[t];if(e<mh)return n.second(e);let r=Math.floor(e/mh);if(r<60)return n.minute(r);let i=Math.floor(r/60);return i<gh?n.hour(i):n.day(Math.floor(i/gh))}function Sh(e,t){let n=xh(e,t.rounding);return n<t.justNowBelowSeconds?`just now`:`${Mre(n,t.wording)}${t.suffix}`}function Ch(e,{smallestUnit:t,dropsZeroRemainder:n}){let r=(e,t,r)=>n&&t===0?e:`${e} ${t}${r}`;if(t===`s`&&e<mh)return`${e}s`;if(t===`s`&&e<hh)return r(`${Math.floor(e/mh)}m`,e%mh,`s`);let i=Math.floor(e/mh);return i<60?`${i}m`:r(`${Math.floor(i/60)}h`,i%60,`m`)}function wh(e,{rounding:t,showsHours:n}){let r=xh(e,t),i=bh(r%mh),a=Math.floor(r/mh),o=Math.floor(r/hh);return!n||o===0?`${a}:${i}`:`${o}:${bh(a%60)}:${i}`}function Th(e,t){return e<_h?`${e} B`:t===`KB`||e<vh?`${(e/_h).toFixed(1)} KB`:e<yh?`${(e/vh).toFixed(1)} MB`:`${(e/yh).toFixed(2)} GB`}function Eh(e){let t=new Date(e);return`${t.getFullYear()}-${bh(t.getMonth()+1)}-${bh(t.getDate())}`}function Dh(e){return`${bh(e.getHours())}:${bh(e.getMinutes())}`}function Oh(e){return e.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}var Nre=320,Pre=8e3,kh=new Set;function Ah(e){kh.add(e)}var jh=(e,t)=>{for(let n of kh)n(e,t)},Fre=window.matchMedia?.(`(prefers-reduced-motion: reduce)`);function Mh(e){Fre?.matches||document.hidden||e?.animate&&e.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)`})}function Ire(e){if(!e||e.currentState!==a.RUNNING)return;let t=performance.now();e._lastOutputAt=t,!(t-(e._activityGate||0)<Nre)&&(e._activityGate=t,e._activity===`quiet`&&(e._activity=`active`,jh(e,`flag`)),jh(e,`beat`))}function Lre(e){if(!e||e.currentState!==a.RUNNING)return;let t=performance.now()-(e._lastOutputAt||0)>=Pre?`quiet`:`active`;e._activity!==t&&(e._activity=t,jh(e,`flag`))}function Nh(e,t){e&&(t&&(e._lastOutputAt=performance.now(),e._activityGate=0,e._activity=`active`),t||(e._activity=void 0),jh(e,`flag`))}var Rre=new Set([a.RUNNING,a.WAITING,a.STARTING,a.INITIALIZING]),zre=e=>Rre.has(e);function Ph(e){return zre(e.currentState)?wh(Date.now()-(e.stateSince||Date.now()),{rounding:`floor`,showsHours:!0}):``}function Fh(e){e.elapsedEl&&(e.elapsedEl.textContent=Ph(e))}var Ih=new Set;function Lh(e){return Ih.add(e),()=>Ih.delete(e)}function Rh(){for(let[,e]of E)Fh(e),Lre(e);for(let e of Ih)try{e()}catch{}}setInterval(()=>{document.hidden||Rh()},1e3),document.addEventListener(`visibilitychange`,()=>{document.hidden||Rh()});function zh(e){return Sh(Number(e)||0,{rounding:`round`,wording:`compact`,suffix:``,justNowBelowSeconds:0})}function Bh(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?`never`:`${zh(Date.now()-e)} ago`}var Bre=e=>`polled ${Bh(e)}`;function Vh(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=Bre){let a={el:e,ts:n,format:r};i(a),t.push(a)},onTick(e){n.push(e)},reset(){t=[],n=[]},ensure(){r||=Lh(a)}}}function Hh(e){let t=(Array.isArray(e)?e:[]).filter(e=>typeof e==`string`&&e!==``);return[...new Set(t)].sort().join(`|`)}function Vre(e,t){let n=typeof e==`string`?e:``,r=typeof t==`string`?t:``;return n===``?{shown:!1,acknowledged:``}:{shown:n!==r,acknowledged:r}}function Uh({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=Vre(e,r()?e:i);return a(t.acknowledged),t.shown},acknowledge(){a(n())}}}function Hre(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 Ure=`machine-updates`,Wre=`update-actions`,Gre={spiking:0,regressed:1,worsened:2,new:3,quiet:4},Kre={spiking:`crit`,regressed:`crit`,worsened:`warn`,new:`warn`,quiet:`dim`},qre=99,Jre={ROOT_CAUSE:`root cause`,NEEDS_HUMAN:`needs you`,TRANSIENT:`transient`,FIXED:`fixed`,ERROR:`error`};function Wh(e){return Array.isArray(e)?e.flatMap(e=>{let t=e,n=_c(t?.tool,``);return n?[{at:V(t?.at,0),tool:n,detail:_c(t?.detail,``)}]:[]}):[]}function Yre(e){return e.detail?`${e.tool} ${e.detail}`:e.tool}function Xre(e){let t=Wh(e?.trail).at(-1);return t?Yre(t):``}function Gh(e){let t=_c(e?.summaryLine,``);return e?.inFlight===!0&&Xre(e)||t}function Kh(e){return{inFlight:e?.inFlight===!0,startedAt:V(e?.startedAt,null),steps:Wh(e?.trail),verdict:_c(e?.verdict,``),summaryLine:_c(e?.summaryLine,``)}}function qh(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 Zre(e,t){let n=qh(e,t?.projectId,t?.issueId);return n?(n.inFlight=!0,n.startedAt=V(t?.startedAt,null),n.trail=Wh(t?.trail),!0):!1}function Jh(e){return{inFlight:!1,startedAt:V(e?.startedAt,null),steps:Wh(e?.trail),verdict:_c(e?.verdict,``),summaryLine:_c(e?.summaryLine,``)}}function Qre(e,t){return!e||!t?!1:String(t.projectId??``)===e.projectId&&String(t.issueId??``)===e.issueId}function $re(e,t){let n=qh(e,t?.projectId,t?.issueId);if(!n)return!1;let r=Jh(t);return n.inFlight=!1,n.startedAt=r.startedAt,n.trail=r.steps,n.verdict=r.verdict,n.summaryLine=r.summaryLine,!0}function Yh(e){return Jre[typeof e==`string`?e.toUpperCase():``]||String(e??``).toLowerCase()}function Xh(e){return wh(e,{rounding:`round`,showsHours:!1})}function Zh(e,t){return e==null?``:`+${Xh(t-e)}`}function eie(e){let t=e.steps.at(-1);return[e.steps.length,t?.at??0,t?.tool??``].join(`::`)}function tie(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: ${Yh(e.verdict)}`:`finished`}function nie(e){return Hre(e,{label:`PostHog monitoring`,tab:`PostHog`})}function rie(e){return V(e.intervalMinutes,null)!==null}function iie(e,t){return e==null||e.configured===!1?`placeholder`:t>0?`ready`:rie(e)?`placeholder`:`pending`}function aie(e){return Kre[e??``]||`dim`}function oie(e){if(typeof e?.lastSeen!=`string`)return null;let t=Date.parse(e.lastSeen);return!Number.isFinite(t)||t<=0?null:t}function sie(e){let t=_c(e?.status,``).trim().toLowerCase();return!t||t===`active`?``:t}function cie(e){return Array.isArray(e)?e.map(e=>Number(e)).filter(e=>Number.isFinite(e)):[]}function lie(e){return Array.isArray(e)?e.map(e=>typeof e==`number`?e:Number(e?.occurrences)).filter(e=>Number.isFinite(e)):[]}function uie(e,t=64,n=16){let r=cie(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 die(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 fie(e){return e.length===0?`0 polls, 0 to 0 occurrences`:`${e.length} polls, ${Math.min(...e)} to ${Math.max(...e)} occurrences`}function Qh(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 pie=3e5;function mie(e){let t=Number(e);return!Number.isFinite(t)||t<=0?pie:t*2}function hie(e){let t=e.split(/[\\/]+/).filter(Boolean);return t.length===0?``:t[t.length-1]}function $h(e){let t=hie(_c(e?.name,``));if(t)return t;let n=e?.projectId;return n==null||n===``?`project`:String(n)}function eg(e){let t=_c(e,``);return t?(t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``).split(`/`)[0].split(`@`).pop()??``).replace(/:\d+$/,``):``}function gie(e){let t=new Set,n=Array.isArray(e)?e:[];for(let e of n){let n=eg(e?.host);n&&t.add(n)}return t.size>1}function _ie(e,t,n={}){let r=Qh(e?.issues),i=_c(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>mie(n.intervalMs)?s:0;return{loud:r.active>0||r.spiking>0||!!i||c>0,counts:r,error:i,staleMs:c}}function vie(e,t,n={}){let r=[],i=[],a=Array.isArray(e)?e:[];for(let e of a){let a=_ie(e,t,n),o={project:e,...a};a.loud?r.push(o):i.push(o)}return{loud:r,quiet:i}}function yie(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:_c(e.issueId,``),projectId:e.projectId??null,projectLabel:_c(e.projectName,``),title:_c(e.title,`Untitled issue`),summaryLine:_c(e.summaryLine,``),url:_c(e.url,``),verdict:_c(e.verdict,`ERROR`).toUpperCase(),mode:_c(e.mode,`investigate`),prUrl:/^https:\/\/[^\s"'<>]{1,300}$/.test(_c(e.prUrl,``))?_c(e.prUrl,``):``,at:Number.isFinite(Number(e.at))?Number(e.at):0})).sort((e,t)=>t.at-e.at)}function bie(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 tg(e,t){let n=_c(e,``);if(n)return/^\d/.test(n)?`v${n}`:n;let r=bs(t,{validate:!0});return r?`commit ${r}`:``}function xie(e){return`Update available: ${tg(e?.current,e?.currentSha)} to ${tg(e?.latest,e?.latestSha)}`}function Sie({posthog:e}={}){let t=[],n=Array.isArray(e?.projects)?e.projects:[];for(let e of n){let n=_c(e?.projectId,_c(e?.name,`project`)),r=Array.isArray(e?.issues)?e.issues:[];for(let e=0;e<r.length;e++){let i=r[e],a=_c(i?.issueId,_c(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 Cie(e={}){return Hh(Sie(e))}function ng(e){return Gre[e??``]??qre}function wie(e){return Array.isArray(e)?e.map((e,t)=>({issue:e,index:t})).sort((e,t)=>{let n=ng(e.issue?.change)-ng(t.issue?.change);if(n!==0)return n;let r=V(t.issue?.users,0)-V(e.issue?.users,0);if(r!==0)return r;let i=V(t.issue?.occurrences,0)-V(e.issue?.occurrences,0);return i===0?e.index-t.index:i}).map(e=>e.issue):[]}function rg(e,{value:t,disabled:n=!1,selected:r=!1}={}){let i=m(`option`,null,e);return t!=null&&(i.value=t),n&&(i.disabled=!0),r&&(i.selected=!0),i}function Tie(e){return typeof e!=`object`||!e?!1:`skipPermissionsByDefault`in e&&e.skipPermissionsByDefault===!0}function ig(){let{dialog:e,close:t}=oh();e.innerHTML=ure,sh(e,`add-session-title`);let n=y(e,`#add-session-picker`,`select`),r=b(e,`#add-session-picker-label`),i=b(e,`#add-session-workspace-list`),a=y(e,`#add-session-single-mode`,`button`),o=y(e,`#add-session-workspace-mode`,`button`),s=b(e,`#add-session-agent-label`),c=y(e,`#add-session-agent`,`select`),l=b(e,`#add-session-repo-roots`),u=b(e,`#add-session-repo-roots-title`),d=y(e,`#add-session-advanced-toggle`,`button`),f=b(e,`#add-session-advanced`),p=y(e,`#add-session-name`,`input`),h=y(e,`#add-session-path`,`input`),g=b(e,`#add-session-path-label`),_=y(e,`#add-session-skip-perms`,`input`),v=y(e,`#add-session-unguarded`,`input`),x=b(e,`#add-session-error`),S=y(e,`#add-session-cancel`,`button`),C=y(e,`#add-session-confirm`,`button`),ee=!1;function te(e){ee=e,a.setAttribute(`aria-pressed`,String(!e)),o.setAttribute(`aria-pressed`,String(e)),r.hidden=e,i.hidden=!e,d.hidden=e,d.setAttribute(`aria-expanded`,String(e)),f.hidden=!e,g.hidden=e,e&&requestAnimationFrame(()=>p.focus())}a.addEventListener(`click`,()=>te(!1)),o.addEventListener(`click`,()=>te(!0)),d.setAttribute(`aria-expanded`,`false`),d.addEventListener(`click`,()=>{let e=f.hidden;f.hidden=!e,d.setAttribute(`aria-expanded`,String(e)),e&&requestAnimationFrame(()=>p.focus())});let ne=ah({onAdded:re});l.append(ne.element);function w(e){let t=e.type===`repo-roots-scanned`;u.textContent=t&&e.directories.length>0?`No projects in your repository roots yet`:`No repository roots yet`,ne.setSuggestions(t?e.suggestions??[]:[]),l.hidden=!1}function re(){return Ym(`scan-repo-roots`,{includeSuggestions:!0}).then(e=>{n.textContent=``,i.textContent=``,l.hidden=!0,n.appendChild(rg(`-- 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=m(`optgroup`);r.label=e.root;for(let n of e.projects){let e=kre(n.name),a=e>0?`${n.name} (${e} open)`:n.name;r.appendChild(rg(a,{value:JSON.stringify({name:n.name,path:n.path})})),i.appendChild(dh(n.name,n.path)),t=!0}n.appendChild(r)}t||(n.textContent=``,n.appendChild(rg(`No projects yet`,{disabled:!0,selected:!0})),i.textContent=`No projects yet.`,w(e))}).catch(()=>{n.textContent=``,n.appendChild(rg(`Scan failed`,{disabled:!0,selected:!0})),i.textContent=`Repository scan failed.`})}re(),n.addEventListener(`change`,()=>{try{let e=JSON.parse(n.value);p.value=ph(e.name),h.value=e.path}catch{}});let T=$m,ie=!1;function ae(e){ie=!0,C.disabled=!0;let t=m(`p`,`dialog-hint dialog-hint-warning`,e);t.id=`add-session-agent-guidance`,t.setAttribute(`role`,`status`),x.before(t)}Ym(`list-agents`,{}).then(e=>{let t=th(e);t.canSpawn||ae(t.guidance);let n=eh(e.type===`agents-listed`?e.agents:[]);if(T=n.selectedId,n.show){c.textContent=``;for(let e of n.options)c.appendChild(rg(e.label,{value:e.id,selected:e.id===n.selectedId}));s.hidden=!1}}).catch(()=>{}),c.addEventListener(`change`,()=>{T=c.value});let oe=!1;_.addEventListener(`change`,()=>{oe=!0}),Ym(`get-settings`,{}).then(e=>{oe||(_.checked=Tie(e.settings))}).catch(()=>{}),p.addEventListener(`input`,()=>{n.selectedIndex=0}),h.addEventListener(`input`,()=>{n.selectedIndex=0});function E(){if(ie)return;let e=p.value.trim(),n=h.value.trim();if(ee){let n=[...i.querySelectorAll(`input:checked`)].map(e=>e.value);if(!e||n.length<2){x.textContent=`Enter a name and select at least two repositories.`;return}let r={type:`add-session`,name:ph(e),path:n[0],repos:n,dangerouslySkipPermissions:_.checked,unguarded:v.checked};T&&T!==`claude-code`&&(r.agent=T),G(r),t();return}if(!e||!n){x.textContent=`Both fields are required. Select a project or use Advanced options.`;return}let r={type:`add-session`,name:ph(e),path:n,dangerouslySkipPermissions:_.checked,unguarded:v.checked};T&&T!==`claude-code`&&(r.agent=T),G(r),t()}S.addEventListener(`click`,t),C.addEventListener(`click`,E),p.addEventListener(`keydown`,e=>{e.key===`Enter`&&(ee&&E(),ee||h.focus())}),h.addEventListener(`keydown`,e=>{e.key===`Enter`&&E()}),requestAnimationFrame(()=>n.focus())}function ag({issueId:e,issueTitle:t,format:n,content:r,message:i,error:a}){let{dialog:o,close:s,actions:c,btnCancel:l}=ch({title:`Investigation report`,dialogClass:`dialog dialog-report`,cancelLabel:`Close`}),u=m(`div`,`dialog-report-meta`,t||e||``),d=null;if(n===`html`&&!a&&!i){let e=m(`iframe`,`dialog-report-frame`);e.setAttribute(`sandbox`,``),e.srcdoc=r||``,d=e}d||=m(`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 Eie({issueTitle:e,projectLabel:t,onOpenReport:n}){let{dialog:r,close:i,actions:a,btnCancel:o}=ch({title:`Investigation`,dialogClass:`dialog dialog-report`,cancelLabel:`Close`}),s=m(`div`,`dialog-report-meta`,t?`${t}: ${e}`:e),c=m(`p`,`dialog-trail-status`),l=m(`p`,`dialog-trail-summary`),u=m(`ol`,`dialog-trail-steps`),d=m(`p`,`dialog-trail-empty`,`No tool calls yet; the session is reading the issue.`),f=m(`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,h=``;function g(e){let t=u.scrollHeight-u.scrollTop-u.clientHeight<24,n=eie(e);if(h!==n){u.textContent=``;for(let t of e.steps){let n=m(`li`,`dialog-trail-step`);n.append(m(`span`,`dialog-trail-at`,Zh(e.startedAt,t.at)),m(`span`,`dialog-trail-tool`,t.tool),m(`span`,`dialog-trail-detail`,t.detail)),u.append(n)}h=n}d.hidden=e.steps.length>0||!e.inFlight,u.hidden=e.steps.length===0,t&&(u.scrollTop=u.scrollHeight)}function _(e){c.textContent=tie(e,Bh(e.startedAt))}function v(){p&&(_(p),c.dataset.tone=p.inFlight?`live`:`done`,l.textContent=p.summaryLine,l.hidden=!p.summaryLine,f.hidden=p.inFlight||!p.verdict,g(p))}let y=Lh(()=>{r.isConnected?p?.inFlight&&_(p):y()});return{update(e){p=e,v()},isOpen:()=>r.isConnected,close:()=>{y(),i()}}}function og(e,t=null){return`#settings/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`}function sg(e){return/^#settings(?:[/?]|$)/.test(e)}function cg(e){let t=e.trim();return t?`#settings?q=${encodeURIComponent(t)}`:`#settings`}function lg(e,t,n){let r=m(`a`,`settings-link`,n);return r.href=og(e,t),r}var Die=`npm install -g @anthropic-ai/claude-code`,Oie={done:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" role="img" aria-label="Done"><circle cx="12" cy="12" r="10"></circle><path d="M7.5 12.5l3 3 6-6.5"></path></svg>`,current:`<svg width="18" height="18" viewBox="0 0 24 24" role="img" aria-label="Needed"><path d="M12 3l9 9-9 9-9-9z" fill="currentColor"></path></svg>`,upcoming:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" role="img" aria-label="Not started"><circle cx="12" cy="12" r="10"></circle></svg>`},ug=null,dg=null,fg=null,pg=null,mg={steps:mre,agentSummary:``,repoRoots:[]},hg=0;function gg({title:e,state:t,summary:n,badge:r,body:i}){let a=m(`li`,`first-run-step`);a.dataset.state=t,t===`current`&&a.setAttribute(`aria-current`,`step`);let o=m(`div`,`first-run-step-head`),s=m(`span`,`first-run-step-icon`);if(s.innerHTML=Oie[t],o.append(s,m(`span`,`first-run-step-title`,e)),t===`done`&&n&&o.append(m(`span`,`first-run-step-summary`,n)),t===`current`&&r&&o.append(m(`span`,`first-run-step-badge`,r)),a.append(o),t!==`current`)return a;let c=m(`div`,`first-run-step-body`);return c.append(...i()),a.append(c),a}function kie(){let e=m(`div`,`first-run-step-actions`);return fg=m(`button`,`btn-dialog btn-dialog-cancel`,`Rescan`),fg.type=`button`,fg.addEventListener(`click`,()=>{vg({rescanAgents:!0})}),e.append(fg,m(`span`,`first-run-step-hint`,`Any other terminal agent can be added under customAgents.`)),[m(`p`,`first-run-step-text`,`No supported agent is on PATH. Install Claude Code, Codex or Grok, then rescan.`),m(`code`,`first-run-command`,Die),e]}function Aie(){let e=pg??ah({onAdded:()=>{vg({rescanAgents:!1})}});return pg=e,[m(`p`,`first-run-step-text`,`The folder that holds your git checkouts. Each subfolder becomes a project you can start a session in.`),e.element]}function jie(){let e=m(`div`,`first-run-step-actions`),t=m(`button`,`btn-dialog btn-dialog-confirm`,`+ Session`);t.type=`button`,t.addEventListener(`click`,ig);let n=m(`span`,`first-run-step-hint`,`Folders and agents can change later in `);return n.append(lg(`machine-sessions`,`repository-roots`,`Settings > Sessions`),`.`),e.append(t,n),[m(`p`,`first-run-step-text`,`Pick a project and an agent. The session runs in its own git worktree, so your checkout is never touched.`),e]}function _g(){if(!dg)return;let{steps:e,agentSummary:t,repoRoots:n}=mg;dg.replaceChildren(gg({title:`1. Agent CLI`,state:e.agent,summary:t,badge:`MISSING`,body:kie}),gg({title:`2. Repository roots`,state:e.repoRoots,summary:n.join(`, `),badge:`NEEDED`,body:Aie}),gg({title:`3. First session`,state:e.firstSession,summary:``,badge:``,body:jie}))}async function vg({rescanAgents:e}){hg+=1;let t=hg;fg&&(fg.disabled=!0);try{let[n,r]=await Promise.all([Ym(`list-agents`,e?{rescan:!0}:{}),Ym(`scan-repo-roots`,{includeSuggestions:!0})]);if(t!==hg)return;let i=r.type===`repo-roots-scanned`,a=i?r.directories.map(e=>e.root):[];mg={steps:hre({agentListing:n,repoRoots:a}),agentSummary:gre(n),repoRoots:a},_g(),pg?.setSuggestions(i?r.suggestions??[]:[])}catch{fg&&(fg.disabled=!1)}}function Mie(){if(ug)return ug;let e=m(`section`,`first-run-checklist`);e.setAttribute(`aria-labelledby`,`first-run-title`);let t=m(`h2`,`first-run-title`,`Get to your first session`);t.id=`first-run-title`,dg=m(`ol`,`first-run-steps`);let n=m(`p`,`first-run-footer`,`This list goes away once a session exists. Something off? Run `);return n.append(m(`code`,null,`glimmervoid doctor`),` in a terminal.`),e.append(m(`span`,`first-run-eyebrow`,`FIRST RUN`),t,m(`p`,`first-run-intro`,`Glimmervoid runs the agent CLIs you already have, inside the repositories you point it at. Two checks, then start.`),dg,n),ug=e,_g(),e}function yg(e,t){if(!t){ug?.parentElement===e&&(ug.hidden=!0);return}let n=Mie(),r=!n.hidden&&n.parentElement===e;n.parentElement!==e&&e.append(n),n.hidden=!1,r||vg({rescanAgents:!1})}function bg(){ug&&!ug.hidden&&ug.isConnected&&vg({rescanAgents:!1})}var Nie=new Set([`http:`,`https:`]);function xg(e){let t;try{t=new URL(e)}catch{return null}return Nie.has(t.protocol)?t.href:null}var Pie=2,Sg=8,Cg=/^ {0,3}(`{3,}|~{3,})([^`]*)$/,Fie=/^(\s*)(?:([-+*])|(\d+)[.)])\s+(.+)$/,wg=/^ {0,3}(?:(?:\*\s*){3,}|(?:-\s*){3,}|(?:_\s*){3,})$/,Iie=/^:?-{3,}:?$/,Lie=/^[A-Za-z0-9_+#.-]{1,32}$/;function Tg(e){return yu(e,{overlongLine:`reject`})}function Rie(e){let t=e.trim().split(/\s+/)[0]??``;return Lie.test(t)?t:``}function Eg(e,t){if(!t)return;let n=e.at(-1);n?.type===`text`?n.text+=t:e.push({type:`text`,text:t})}function zie(e,t){return e.startsWith(`**`,t)?`**`:e.startsWith(`__`,t)?`__`:null}function Bie(e,t){return e.startsWith(`*`,t)?`*`:e.startsWith(`_`,t)?`_`:null}function Dg(e,t,n){let r=e.indexOf(t,n);return r>n?r:-1}function Vie(e,t){let n=e.indexOf(t);return function(r){return n===-1?-1:(n>=r||(n=e.indexOf(t,r)),n)}}function Hie(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>Pie)return-1}return-1}function Uie(e,t,n){if(e[t]!==`[`)return null;let r=n(t+1);if(r<=t+1||e[r+1]!==`(`)return null;let i=Hie(e,r+2);return i===-1?null:{label:e.slice(t+1,r),target:e.slice(r+2,i),end:i+1}}function Og(e){let t=[],n=Vie(e,`]`),r=0;for(;r<e.length;){let i=Uie(e,r,n);if(i){let e=xg(i.target.trim());e&&t.push({type:`link`,href:e,children:Og(i.label)}),e||Eg(t,i.label),r=i.end;continue}if(e.startsWith("`",r)){let n=Dg(e,"`",r+1);if(n!==-1){t.push({type:`code`,text:e.slice(r+1,n)}),r=n+1;continue}}let a=zie(e,r);if(a){let n=Dg(e,a,r+a.length);if(n!==-1){t.push({type:`strong`,children:Og(e.slice(r+a.length,n))}),r=n+a.length;continue}}let o=Bie(e,r);if(o){let n=Dg(e,o,r+1);if(n!==-1){t.push({type:`emphasis`,children:Og(e.slice(r+1,n))}),r=n+1;continue}}Eg(t,e[r]),r++}return t}function kg(e){return e.map(e=>e.type===`text`||e.type===`code`?e.text:kg(e.children)).join(``)}var Wie=`plan-h-`;function Gie(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),`${Wie}${r===1?n:`${n}-${r}`}`}function Ag(e){if(typeof e!=`string`||!e.includes(`|`))return!1;let t=jg(e);return t.length<2?!1:t.every(e=>Iie.test(e))}function jg(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 Mg(e){let t=Fie.exec(e);return t?{indent:t[1].replace(/\t/g,` `).length,ordered:!!t[3],content:t[4]}:null}function Ng(e,t,n,r){let i=Mg(e[t]);if(!i)return null;let a=[],o=i.ordered,s=i.indent,c=t;for(;c<e.length;){let t=Mg(e[c]);if(!t||t.indent<s)break;if(t.indent>s){if(r>=Sg)break;let t=Ng(e,c,n,r+1);if(!t||a.length===0)break;a.at(-1)?.children.push(t.block),c=t.next}else{if(t.ordered!==o)break;a.push({children:[{type:`paragraph`,children:Og(t.content)}]}),c++}}return{block:{type:`list`,ordered:o,items:a},next:c}}function Kie(e,t){let n=e[t]??``;return n.trim()===``||Tg(n)||Cg.test(n)||wg.test(n)||Mg(n)||/^ {0,3}>/.test(n)?!0:t+1<e.length&&n.includes(`|`)&&Ag(e[t+1])}function Pg(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.trim()===``){i++;continue}let o=Cg.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:Rie(o[2]),text:t.join(`
104
+ `)});continue}let s=Tg(a);if(s){let e=Og(s.text);r.push({type:`heading`,level:s.level,id:Gie(kg(e),t),children:e}),i++;continue}if(wg.test(a)){r.push({type:`rule`}),i++;continue}if(i+1<e.length&&a.includes(`|`)&&Ag(e[i+1])){let t=jg(a).map(Og),n=[];for(i+=2;i<e.length&&e[i].includes(`|`)&&e[i].trim()!==``;)n.push(jg(e[i]).map(Og)),i++;r.push({type:`table`,header:t,rows:n});continue}let c=Ng(e,i,t,n);if(c){r.push(c.block),i=c.next;continue}if(n<Sg&&/^ {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:Pg(a,t,n+1)});continue}let l=[a.trim()];for(i++;i<e.length&&!Kie(e,i);)l.push(e[i].trim()),i++;r.push({type:`paragraph`,children:Og(l.join(` `))})}return r}function Fg(e){return Pg(e.replace(/\r\n?/g,`
105
+ `).split(`
106
+ `),{slugCounts:new Map},0)}function qie(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)t.type===`heading`?(r(),n={heading:kg(t.children),id:t.id,level:t.level,blocks:[t]}):n.blocks.push(t);return r(),t}function Ig(e,t){for(let n of t){if(n.type===`text`){e.append(document.createTextNode(n.text));continue}if(n.type===`code`){e.append(m(`code`,`plan-inline-code`,n.text));continue}if(n.type===`emphasis`){let t=m(`em`);Ig(t,n.children),e.append(t);continue}if(n.type===`strong`){let t=m(`strong`);Ig(t,n.children),e.append(t);continue}let t=m(`a`,`plan-link`);t.href=n.href,t.target=`_blank`,t.rel=`noopener noreferrer`,Ig(t,n.children),e.append(t)}}function Jie(e){let t=m(`li`);return Lg(t,e.children),t}function Lg(e,t){for(let n of t)if(n.type===`heading`){let t=m(`h${n.level}`,`plan-heading`);t.id=n.id,Ig(t,n.children),e.append(t)}else if(n.type===`paragraph`){let t=m(`p`,`plan-paragraph`);Ig(t,n.children),e.append(t)}else if(n.type===`list`){let t=n.ordered?m(`ol`,`plan-list`):m(`ul`,`plan-list`);t.append(...n.items.map(Jie)),e.append(t)}else if(n.type===`code`){let t=m(`pre`,`plan-code`),r=m(`code`,n.language?`language-${n.language}`:null,n.text);t.append(r),e.append(t)}else if(n.type===`table`){let t=m(`div`,`plan-table-wrap`),r=m(`table`,`plan-table`),i=m(`thead`),a=m(`tr`);for(let e of n.header){let t=m(`th`);Ig(t,e),a.append(t)}i.append(a);let o=m(`tbody`);for(let e of n.rows){let t=m(`tr`);for(let n of e){let e=m(`td`);Ig(e,n),t.append(e)}o.append(t)}r.append(i,o),t.append(r),e.append(t)}else if(n.type===`blockquote`){let t=m(`blockquote`,`plan-blockquote`);Lg(t,n.blocks),e.append(t)}else e.append(m(`hr`,`plan-rule`))}function Rg(e){let t=m(`div`,`plan-document`);return Lg(t,e),t}function Yie(e,{hasComment:t,isComposing:n,onComment:r,attachmentFor:i}){let a=m(`div`,`plan-document`),o=[];for(let s of e){let e=m(`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=m(`div`,`plan-section-head`),l=s.blocks[0],u=l?.type===`heading`;if(u&&Lg(c,[l]),u||(e.id=`plan-introduction`),!t(s)&&!n(s)){let e=m(`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=m(`div`,`plan-section-body`);Lg(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 Xie={added:`+`,removed:`-`,unchanged:` `,skipped:` `};function Zie(e){let t=m(`div`,`plan-diff`);for(let n of e.lines){let e=m(`div`,`plan-diff-line plan-diff-${n.kind}`),r=m(`span`,`plan-diff-gutter`,Xie[n.kind]);r.setAttribute(`aria-hidden`,`true`),e.append(r,m(`span`,`plan-diff-text`,n.text)),t.append(e)}return t}var zg=6e3,Qie=`Something went wrong. Details are hidden in streamer mode.`,$ie=400,eae=`×`,Bg=new WeakMap;function tae(){let e=document.getElementById(`notice-region`);return e||(e=m(`div`,`notice-region`),e.id=`notice-region`,e.setAttribute(`role`,`region`),e.setAttribute(`aria-label`,`Notifications`),document.body.appendChild(e)),e}function Vg(e){let t=Bg.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(),$ie))}function Hg(e,t={}){let n=document.documentElement.hasAttribute(`data-streamer`)?Qie:String(e),r=t.persist===!0,i=tae(),a=i.firstElementChild,o=a?Bg.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=y(a,`.notice-count`,`span`);return e.textContent=`x${o.count}`,e.hidden=!1,!r&&o.timer&&(clearTimeout(o.timer),o.timer=setTimeout(()=>Vg(a),zg)),a}let s=m(`div`,r?`notice is-persistent`:`notice`),c={message:n,count:1,timer:null,dismissed:!1};Bg.set(s,c),s.setAttribute(`role`,`alert`);let l=m(`span`,`notice-glyph`,`!`);l.setAttribute(`aria-hidden`,`true`);let u=m(`span`,`notice-msg`,n),d=m(`span`,`notice-count`);d.hidden=!0;let f=m(`button`,`notice-close`,eae);return f.type=`button`,f.setAttribute(`aria-label`,`Dismiss notification`),f.addEventListener(`click`,()=>Vg(s)),s.append(l,u,d,f),i.prepend(s),requestAnimationFrame(()=>s.classList.add(`is-visible`)),r||(c.timer=setTimeout(()=>Vg(s),zg)),s}var Ug=`glimmervoid-streamer-mode`,Wg=new Set,Gg=Zf(Ug,!1)===!0,Kg=null;function qg(e){document.documentElement.toggleAttribute(`data-streamer`,e),Kg?.setAttribute(`aria-pressed`,String(e))}qg(Gg);function Jg(){return Gg}function Yg(e){if(Qf(Ug,e),e!==Jg()){Gg=e,qg(e);for(let t of Wg)t(e)}}function Xg(e){return Wg.add(e),()=>Wg.delete(e)}async function Zg(e){try{let t=await Ym(`update-settings`,{settings:{streamerMode:e}});return t.type===`settings-error`?String(t.message):(Yg(e),``)}catch(e){return e?.message||`Failed to save streamer mode.`}}async function nae(){let e=!Jg();e&&Yg(!0);let t=await Zg(e);t&&Hg(t)}function Qg(){nae()}function rae(e){Kg=e,qg(Jg()),e.addEventListener(`click`,Qg)}var $g=new Map,e_=null;function t_(e){return $g.get(e)??[]}function n_(e){return t_(e).length>0}function r_(e){k(e)?.btnDocs.classList.toggle(`visible`,n_(e))}function i_(e){let t=t_(e.sessionId);e.select.replaceChildren(...t.map(t=>{let n=m(`option`,null,t.name);return n.value=t.path,n.selected=t.path===e.docPath,n})),e.select.hidden=t.length<2,e.title.textContent=t.find(t=>t.path===e.docPath)?.name??e.title.textContent}function a_(e){let t=t_(e.sessionId).some(t=>t.path===e.docPath);e.btnEdit.setAttribute(`aria-pressed`,String(e.mode===`edit`)),e.btnPreview.setAttribute(`aria-pressed`,String(e.mode===`preview`)),e.textarea.hidden=e.mode!==`edit`,e.preview.hidden=e.mode!==`preview`,e.select.disabled=e.isBusy,e.btnReload.disabled=e.isBusy||!t,e.btnSave.disabled=e.isBusy||!t||e.baseHash===null||!e.hasUnsavedChanges}function o_(e,t,n=`quiet`){e.status.textContent=t,e.status.dataset.tone=n}function s_(e){e.preview.replaceChildren(Rg(Fg(e.textarea.value)))}function iae(e,t){lh({title:e,message:`Your unsaved edits will be lost.`,confirmLabel:`Discard`,danger:!0,onConfirm:t})}function c_(e,t,n){e.hasUnsavedChanges?iae(t,n):n()}async function l_(e,t){e.docPath=t,e.isBusy=!0,e.baseHash=null,e.textarea.readOnly=!0,i_(e),o_(e,`Loading`),a_(e);let n=await Ym(`session-doc-read`,{id:e.sessionId,path:t}).catch(()=>null);if(e_!==e||e.docPath!==t)return;e.isBusy=!1,e.textarea.readOnly=!1;let r=n?.type===`session-doc-response`?n:null;!r?.ok||r.text===void 0||r.hash===void 0?(o_(e,r?.error||`Could not open this doc`,`warn`),a_(e)):(e.textarea.value=r.text,e.baseHash=r.hash,e.hasUnsavedChanges=!1,e.mode===`preview`&&s_(e),o_(e,``),a_(e))}async function u_(e){if(e.btnSave.disabled||e.baseHash===null)return;e.isBusy=!0,o_(e,`Saving`),a_(e);let t=e.docPath,n=e.textarea.value,r=await Ym(`session-doc-save`,{id:e.sessionId,path:t,text:n,baseHash:e.baseHash}).catch(()=>null);if(e_!==e||e.docPath!==t)return;e.isBusy=!1;let i=r?.type===`session-doc-save-result`?r:null;!i?.ok||i.hash===void 0?(o_(e,i?.conflict?`The agent changed this file since you opened it. Reload to see its version.`:i?.error||`Save failed`,`warn`),a_(e)):(e.baseHash=i.hash,e.hasUnsavedChanges=e.textarea.value!==n,o_(e,e.hasUnsavedChanges?`Unsaved changes`:`Saved`),a_(e))}function d_(e,t){e.mode=t,t===`preview`&&s_(e),a_(e),t===`edit`&&e.textarea.focus()}function f_(e,t){let n=m(`button`,`plan-control ${t}`,e);return n.type=`button`,n}function aae(e){let t=t_(e)[0];if(!t||e_)return;let n=()=>c_(b,`Close this doc?`,()=>b.close()),r=oh({dialogClass:`doc-editor`,closeOnBackdrop:!1,onEscape:n}),i=`doc-editor-title-${e}`,a=m(`h3`,`doc-editor-title`,t.name);a.id=i;let o=m(`select`,`plan-control doc-editor-picker`);o.setAttribute(`aria-label`,`Doc`);let s=m(`span`,`doc-editor-status`);s.setAttribute(`role`,`status`);let c=f_(`Edit`,`doc-editor-mode`),l=f_(`Preview`,`doc-editor-mode`),u=f_(`Reload`,`doc-editor-reload`),d=f_(`Save`,`doc-editor-save`),f=f_(`Close`,`doc-editor-close`),p=m(`div`,`doc-editor-modes`);p.append(c,l);let h=m(`div`,`doc-editor-actions`);h.append(s,u,d,f);let g=m(`div`,`doc-editor-header`);g.append(a,o,p,h);let _=m(`textarea`,`plan-editor doc-editor-text`);_.spellcheck=!0,_.setAttribute(`aria-labelledby`,i);let v=m(`div`,`doc-editor-preview`),y=m(`div`,`doc-editor-body`);y.append(_,v),r.dialog.append(g,y),sh(r.dialog,i);let b={sessionId:e,docPath:t.path,baseHash:null,hasUnsavedChanges:!1,isBusy:!1,mode:Jg()?`preview`:`edit`,title:a,select:o,textarea:_,preview:v,status:s,btnEdit:c,btnPreview:l,btnReload:u,btnSave:d,close:()=>{e_=null,r.close()}};e_=b,_.addEventListener(`input`,()=>{b.hasUnsavedChanges||(b.hasUnsavedChanges=!0,o_(b,`Unsaved changes`),a_(b))}),_.addEventListener(`keydown`,e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),u_(b))}),o.addEventListener(`change`,()=>{let e=o.value;o.value=b.docPath,c_(b,`Open another doc?`,()=>{l_(b,e)})}),c.addEventListener(`click`,()=>d_(b,`edit`)),l.addEventListener(`click`,()=>d_(b,`preview`)),u.addEventListener(`click`,()=>{c_(b,`Reload this doc?`,()=>{l_(b,b.docPath)})}),d.addEventListener(`click`,()=>{u_(b)}),f.addEventListener(`click`,n),l_(b,t.path),b.mode===`edit`&&_.focus()}function p_(e){e_&&e_.sessionId===e&&(i_(e_),a_(e_),!t_(e).some(e=>e.path===e_?.docPath)&&o_(e_,`This doc is no longer surfaced, so it cannot be saved.`,`warn`))}function oae(e){$g.set(e.id,e.docs),e.docs.length===0&&$g.delete(e.id),r_(e.id),p_(e.id)}function sae(e){let t=[...$g.keys()];$g.clear();for(let[t,n]of Object.entries(e.sessions))$g.set(t,n);for(let e of new Set([...t,...$g.keys()]))r_(e),p_(e)}var cae=/\bElectron\/\d/,lae=new Set([`localhost`,`127.0.0.1`]);function uae(e){return cae.test(e)}function dae({userAgent:e,pageHostname:t}){return uae(e)&&lae.has(t)}function m_(e){return xg(e)!==null}var fae=new Set([0,1]);function pae({button:e,opensInNewTab:t}){return t&&fae.has(e)}function h_(){return dae({userAgent:navigator.userAgent,pageHostname:location.hostname})}function g_(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function mae(e){try{let t=await Pm();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 __(e){!h_()||!m_(e)?g_(e):mae(e).then(t=>{t||g_(e)})}function v_(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&pae({button:e.button,opensInNewTab:t.target===`_blank`})&&m_(t.href)&&(e.preventDefault(),__(t.href))}function hae(e){h_()&&(e.addEventListener(`click`,v_,!0),e.addEventListener(`auxclick`,v_,!0))}var y_=Object.freeze({now:0,next:1,later:2,ready:3,working:4,resting:5}),gae=new Map(Object.entries({WAITING:{tier:`now`,"needs-you":`always`,"phone-triage":`always`,favicon:`always`},FAILED:{tier:`next`,"needs-you":`never`,"phone-triage":`always`,favicon:`never`},COMPLETE:{tier:`later`,"needs-you":`unseen`,"phone-triage":`always`,favicon:`always`},IDLE:{tier:`ready`,"needs-you":`never`,"phone-triage":`never`,favicon:`never`},RUNNING:{tier:`working`,"needs-you":`never`,"phone-triage":`always`,favicon:`never`},STARTING:{tier:`working`,"needs-you":`never`,"phone-triage":`never`,favicon:`never`},INITIALIZING:{tier:`working`,"needs-you":`never`,"phone-triage":`never`,favicon:`never`},DORMANT:{tier:`resting`,"needs-you":`never`,"phone-triage":`never`,favicon:`never`},DONE:{tier:`resting`,"needs-you":`never`,"phone-triage":`never`,favicon:`never`}}));function b_(e,t){let n=typeof e.state==`string`?gae.get(e.state):void 0;if(!n)return`resting`;let r=n[t];return r===`never`||r===`unseen`&&e.unseen!==!0?`resting`:n.tier}function x_(e,t){return y_[b_(e,t)]}function _ae(e,t){return[...e].map(([e,n])=>{let r=n.currentState||a.DORMANT;return{id:e,ui:n,name:t(n),isDormant:r===a.DORMANT,state:r,unseen:!1}})}function S_(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 vae(e,t){return e.length?e[((t==null?-1:e.indexOf(t))+1)%e.length]:null}function C_(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 w_({state:e,unseen:t}={}){return x_({state:e,unseen:t},`needs-you`)<y_.ready}function T_(e){let t={waitingCount:0,finishedCount:0};for(let n of e||[])w_(n||{})&&(n?.state===a.COMPLETE?t.finishedCount++:t.waitingCount++);return t}function E_({waitingCount:e,finishedCount:t}){let n=[];return e===1&&n.push(`1 NEEDS YOU`),e>1&&n.push(`${e} NEED YOU`),t>0&&n.push(`${t} FINISHED`),n.length===0?`ALL CLEAR`:n.join(`, `)}var yae=new Map([[`hand`,2]]),bae=1;function xae(e){return e?typeof e==`string`&&yae.get(e)||bae:0}function Sae(e){let t=!1,n=0;for(let r of e||[]){let e=xae(r);e<=n||(t=typeof r!=`string`||r,n=e)}return t}var D_=Object.freeze({idle:`#c084fc`,complete:`#4ade80`,waiting:`#fbbf24`});function Cae(e){let t=Array.isArray(e)?e:[],n=!1;for(let e of t){let t=b_(e||{},`favicon`);if(t===`now`)return`waiting`;t===`later`&&(n=!0)}return n?`complete`:`idle`}function wae(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="${D_[e]||D_.idle}"/>${e===`complete`?`<circle cx="25" cy="7" r="3" fill="#4ade80"/>`:``}</svg>`}function Tae(){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 Eae=Tae(),O_=`idle`;function k_(e){let t=Cae([...e.values()].map(({currentState:e})=>({state:e})));t!==O_&&(O_=t,Eae.href=`data:image/svg+xml,${encodeURIComponent(wae(t))}`)}function Dae(e,t){return Number.isFinite(e)?Math.round(Math.min(t.maxPx,Math.max(t.minPx,e))):null}function Oae(e,t){return e===`ArrowRight`?t:e===`ArrowLeft`?-t:null}function A_({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=Dae(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=Oae(e.key,a);if(n===null)return;e.preventDefault();let r=c(t.getBoundingClientRect().width+n);r!==null&&s(r)})}var j_=new Set(Bp());function M_(){Vp([...j_])}function N_(e){if(!e)return;let t=String(e);j_.has(t)||(j_.add(t),M_())}function P_(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),N_(i)}return[...j_].filter(e=>!n.has(e))}function F_(e){return!e||!j_.delete(String(e))?!1:(M_(),!0)}function kae(e,t=`explicit-state`){let n=t===`dormant-fallback`?e||a.DORMANT:e;return n===a.DORMANT?`start-session`:n===a.COMPLETE?`dismiss`:null}function Aae({previousState:e,nextState:t,isPhoneLayout:n,isDocumentVisible:r,isDocumentFocused:i,isActiveViewer:o,hasFocusInsideTerminal:s}){return t!==a.COMPLETE||!e||e===a.COMPLETE||!r?!1:n?o:i&&s}function jae(e,t){if(!e)return null;let n=t.get(e);return!n||(n.currentState||a.DORMANT)===a.DORMANT?null:e}function I_(){return pe.snapshot().selectedSessionId}function L_(e){pe.dispatch(`selectSession`,e)}function R_(e){return pe.subscribe((t,n)=>{n.includes(`selectedSessionId`)&&e(t.selectedSessionId)})}function z_(e,t=`explicit-state`){let n=E.get(e);if(!n)return null;let r=kae(n.currentState,t);return r&&G({type:r,id:e}),n}function B_(e,{rememberFocus:t=!0}={}){L_(e),t&&rm(e)}function V_(){return jae(nm(),E)}function H_(e=D){return _ae(E,e)}function U_(e,t){e&&G({type:`add-session`,name:ph(t),path:e})}function W_(e,t){let n=E.get(e);if(!n)return;let r=t||n.card?.dataset.merge||`none`;r!==`pending-review`&&r!==`parked`?G({type:`remove-session`,id:e}):lh({title:`Remove Session`,message:`"${D(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:()=>G({type:`remove-session`,id:e})})}var Mae=Object.freeze({[a.IDLE]:`compaction_restore_idle`,[a.COMPLETE]:`compaction_restore_complete`,[a.WAITING]:`compaction_restore_waiting`});function Nae(e){return Object.values(Mae).some(t=>t===e)}var Pae=new Set([`claude-code`,`codex`]),G_=`\x1B`,K_=`${G_}[200~`,q_=`${G_}[201~`,J_=400,Y_=4e3;function X_(e){return typeof e==`string`&&Pae.has(e)}function Z_(e,t){if(!X_(e))return null;let n=t.replace(/\r\n?/g,`
107
+ `).trim();return n?[{data:n.includes(`
108
+ `)?`${K_}${n}${q_}`:n,delayBeforeMs:0},{data:`\r`,delayBeforeMs:J_}]:null}function Q_(e){return X_(e)?[{data:G_,delayBeforeMs:0}]:null}function $_(e,t){return e===a.WAITING&&typeof t==`string`&&t!==``}function ev(e,t){return e.uuid??`${e.kind}-${e.ts}-${t}`}function tv(e){return typeof e.agentId==`string`}function nv(e,t,n){let r=e[e.length-1];if(r?.kind===`work`)return r;let i={kind:`work`,key:t,steps:[],thinkingCount:0,errorCount:0,startedAt:n,endedAt:n};return e.push(i),i}function rv(e,t){let n=e.get(t.toolUseId);return n?(n.isRunning=!1,!0):!1}function iv(e){let t=[],n=new Map,r=new Map;return e.forEach((e,i)=>{let a=ev(e,i);if(e.kind===`prompt`&&!tv(e))t.push({kind:`user`,key:a,text:e.text,at:e.ts});else if(e.kind===`assistant`&&!tv(e)){if(!e.text.trim())return;t.push({kind:`assistant`,key:a,text:e.text,at:e.ts})}else if(e.kind===`notice`)t.push({kind:`notice`,key:a,text:e.text,at:e.ts});else if(e.kind===`thinking`){let n=nv(t,a,e.ts);n.thinkingCount+=1,n.endedAt=e.ts}else if(e.kind===`tool_call`){let i=nv(t,a,e.ts),o={isRunning:!0};i.steps.push(o),i.endedAt=e.ts,n.set(e.toolUseId,o),r.set(e.toolUseId,i)}else if(e.kind===`tool_result`){if(!rv(n,e))return;let t=r.get(e.toolUseId);if(!t)return;t.endedAt=Math.max(t.endedAt,e.ts),e.isError&&(t.errorCount+=1)}}),t}function Fae(e){let t=Math.max(1,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:r===0?`${n}m`:`${n}m ${r}s`}function Iae(e){let t=e.steps.length,n=`${t} ${t===1?`step`:`steps`}`;if(av(e))return t>0?`Working, ${n}`:`Working`;let r=Fae(e.endedAt-e.startedAt);return t===0?`Thought for ${r}`:`Worked ${r}, ${n}${e.errorCount>0?`, ${e.errorCount} failed`:``}`}function av(e){return e.steps.some(e=>e.isRunning)}function Lae(e){return e.length<=Y_?e:e.slice(e.length-Y_)}var Rae=2,zae=1,Bae=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(Rae,Math.floor(u/e.css.cell.width)),rows:Math.max(zae,Math.floor(l/e.css.cell.height))}}},ov=Object.defineProperty,Vae=Object.getOwnPropertyDescriptor,Hae=(e,t)=>{for(var n in t)ov(e,n,{get:t[n],enumerable:!0})},sv=(e,t,n,r)=>{for(var i=r>1?void 0:r?Vae(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&&ov(t,n,i),i},K=(e,t)=>(n,r)=>t(n,r,e),cv=`Terminal input`,lv={get:()=>cv,set:e=>cv=e},uv=`Too much output to announce, navigate to rows manually to read`,dv={get:()=>uv,set:e=>uv=e};function fv(e){return e.replace(/\r?\n/g,`\r`)}function pv(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function mv(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function hv(e,t,n,r){e.stopPropagation(),e.clipboardData&&gv(e.clipboardData.getData(`text/plain`),t,n,r)}function gv(e,t,n,r){e=fv(e),e=pv(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function _v(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 vv(e,t,n,r,i){_v(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function yv(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function bv(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 xv=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)}else i!==65279&&(t[r++]=i)}return r}},Sv=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||(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}},Cv=``,wv=` `,Tv=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Ev}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}},Ev=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}},Dv=class e extends Tv{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ev,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?yv(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()]}},Ov=`di$target`,kv=`di$dependencies`,Av=new Map;function jv(e){return e[kv]||[]}function Mv(e){if(Av.has(e))return Av.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Uae(t,e,r)};return t._id=e,Av.set(e,t),t}function Uae(e,t,n){t[Ov]===t?t[kv].push({id:e,index:n}):(t[kv]=[{id:e,index:n}],t[Ov]=t)}var Nv=Mv(`BufferService`),Pv=Mv(`CoreMouseService`),Fv=Mv(`CoreService`),Wae=Mv(`CharsetService`),Iv=Mv(`InstantiationService`),Lv=Mv(`LogService`),Rv=Mv(`OptionsService`),zv=Mv(`OscLinkService`),Gae=Mv(`UnicodeService`),Bv=Mv(`DecorationService`),Vv=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 Dv,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):Kae(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)}};Vv=sv([K(0,Nv),K(1,Rv),K(2,zv)],Vv);function Kae(e,t){if(confirm(`Do you want to navigate to ${t}?
109
+
110
+ 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 Hv=Mv(`CharSizeService`),Uv=Mv(`CoreBrowserService`),Wv=Mv(`MouseService`),Gv=Mv(`RenderService`),qae=Mv(`SelectionService`),Kv=Mv(`CharacterJoinerService`),qv=Mv(`ThemeService`),Jv=Mv(`LinkProviderService`),Jae=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ey.isErrorNoTelemetry(e)?new ey(e.message+`
111
+
112
+ `+e.stack):Error(e.message+`
113
+
114
+ `+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 Yv(e){Zv(e)||Jae.onUnexpectedError(e)}var Xv=`Canceled`;function Zv(e){return e instanceof Qv||e instanceof Error&&e.name===Xv&&e.message===Xv}var Qv=class extends Error{constructor(){super(Xv),this.name=this.message}};function $v(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var ey=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`}},ty=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function ny(e,t=0){return e[e.length-(1+t)]}var ry;(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})(ry||={});var iy=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||ry.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};iy.empty=new iy(e=>{});function ay(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 oy;(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})(oy||={});var sy=null;function cy(e){return sy?.trackDisposable(e),e}function ly(e){sy?.markAsDisposed(e)}function uy(e,t){sy?.setParent(e,t)}function dy(e){return sy?.markAsSingleton(e),e}function fy(e){if(oy.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 py(...e){return my(()=>fy(e))}function my(e){let t=cy({dispose:ay(()=>{ly(t),e()})});return t}var hy=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,cy(this)}dispose(){this._isDisposed||(ly(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{fy(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return uy(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),uy(e,null))}};hy.DISABLE_DISPOSED_WARNING=!1;var gy=hy,_y=class{constructor(){this._store=new gy,cy(this),uy(this._store,this)}dispose(){ly(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};_y.None=Object.freeze({dispose(){}});var vy=class{constructor(){this._isDisposed=!1,cy(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&uy(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,ly(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&uy(e,null),e}},yy=typeof window==`object`?window:globalThis,by=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};by.Undefined=new by(void 0);var xy=by,Sy=class{constructor(){this._first=xy.Undefined,this._last=xy.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===xy.Undefined}clear(){let e=this._first;for(;e!==xy.Undefined;){let t=e.next;e.prev=xy.Undefined,e.next=xy.Undefined,e=t}this._first=xy.Undefined,this._last=xy.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new xy(e);if(this._first===xy.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!==xy.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==xy.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==xy.Undefined&&e.next!==xy.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===xy.Undefined&&e.next===xy.Undefined?(this._first=xy.Undefined,this._last=xy.Undefined):e.next===xy.Undefined?(this._last=this._last.prev,this._last.next=xy.Undefined):e.prev===xy.Undefined&&(this._first=this._first.next,this._first.prev=xy.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==xy.Undefined;)yield e.element,e=e.next}},Cy=globalThis.performance&&typeof globalThis.performance.now==`function`,wy=class e{static create(t){return new e(t)}constructor(e){this._now=Cy&&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}},Ty;(e=>{e.None=()=>_y.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(py(...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 q({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 q({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 q({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 q({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 q({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 S(e){let t=new q;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function ee(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=ee;class te{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 q(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 ne(e,t){return new te(e,t).emitter.event}e.fromObservable=ne;function w(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 gy?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=w})(Ty||={});var Ey=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 wy,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}}};Ey.all=new Set,Ey._idPool=0;var Dy=Ey,Oy=-1,ky=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 My(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}};ky._idPool=1;var Ay=ky,jy=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
115
+ `).slice(2).join(`
116
+ `))}},My=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},Ny=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},Py=0,Fy=class{constructor(e){this.value=e,this.id=Py++}},Iy=2,q=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Oy>0||this._options?.leakWarningThreshold?new Ay(e?.onListenerError??Yv,this._options?.leakWarningThreshold??Oy):void 0,this._perfMon=this._options?._profName?new Dy(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 Ny(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Yv)(n),_y.None}if(this._disposed)return _y.None;t&&(e=e.bind(t));let r=new Fy(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=jy.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Fy?(this._deliveryQueue??=new Ly,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=my(()=>{i?.(),this._removeListener(r)});return n instanceof gy?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*Iy<=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||Yv;if(!n)e.value(t);else 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 Fy)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}},Ly=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}},Ry=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new q,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}};Ry.INSTANCE=new Ry;var zy=Ry;function By(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}zy.INSTANCE.onDidChangeZoomLevel;function Vy(e){return zy.INSTANCE.getZoomFactor(e)}zy.INSTANCE.onDidChangeFullscreen;var Hy=typeof navigator==`object`?navigator.userAgent:``,Uy=Hy.indexOf(`Firefox`)>=0,Wy=Hy.indexOf(`AppleWebKit`)>=0,Gy=Hy.indexOf(`Chrome`)>=0,Ky=!Gy&&Hy.indexOf(`Safari`)>=0;Hy.indexOf(`Electron/`),Hy.indexOf(`Android`);var qy=!1;if(typeof yy.matchMedia==`function`){let e=yy.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=yy.matchMedia(`(display-mode: fullscreen)`);qy=e.matches,By(yy,e,({matches:e})=>{qy&&t.matches||(qy=e)})}function Jy(){return qy}var Yy=`en`,Xy=!1,Zy=!1,Qy=!1,$y=!1,eb=!1,tb=Yy,nb,rb=globalThis,ib;typeof rb.vscode<`u`&&typeof rb.vscode.process<`u`?ib=rb.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(ib=process);var ab=typeof ib?.versions?.electron==`string`&&ib?.type===`renderer`;if(typeof ib==`object`){Xy=ib.platform===`win32`,Zy=ib.platform===`darwin`,Qy=ib.platform===`linux`,Qy&&ib.env.SNAP&&ib.env.SNAP_REVISION,ib.env.CI||ib.env.BUILD_ARTIFACTSTAGINGDIRECTORY,tb=Yy;let e=ib.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,tb=t.resolvedLanguage||Yy,t.languagePack?.translationsConfigFile}catch{}$y=!0}else typeof navigator==`object`&&!ab?(nb=navigator.userAgent,Xy=nb.indexOf(`Windows`)>=0,Zy=nb.indexOf(`Macintosh`)>=0,(nb.indexOf(`Macintosh`)>=0||nb.indexOf(`iPad`)>=0||nb.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,Qy=nb.indexOf(`Linux`)>=0,nb?.indexOf(`Mobi`),eb=!0,tb=globalThis._VSCODE_NLS_LANGUAGE||Yy,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var ob=Xy,sb=Zy,cb=Qy,lb=$y;eb&&typeof rb.importScripts==`function`&&rb.origin;var ub=nb,db=tb,fb;(e=>{function t(){return db}e.value=t;function n(){return db.length===2?db===`en`:db.length>=3&&db[0]===`e`&&db[1]===`n`&&db[2]===`-`}e.isDefaultVariant=n;function r(){return db===`en`}e.isDefault=r})(fb||={});var pb=typeof rb.postMessage==`function`&&!rb.importScripts;(()=>{if(pb){let e=[];rb.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}),rb.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var mb=!!(ub&&ub.indexOf(`Chrome`)>=0);ub&&ub.indexOf(`Firefox`),!mb&&ub&&ub.indexOf(`Safari`),ub&&ub.indexOf(`Edg/`),ub&&ub.indexOf(`Android`);var hb=typeof navigator==`object`?navigator:{};lb||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||hb&&hb.clipboard&&hb.clipboard.writeText,lb||hb&&hb.clipboard&&hb.clipboard.readText,lb||Jy()||hb.keyboard,`ontouchstart`in yy||hb.maxTouchPoints,yy.PointerEvent&&(`ontouchstart`in yy||navigator.maxTouchPoints);var gb=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}},_b=new gb,vb=new gb,yb=new gb,bb=Array(230),xb;(e=>{function t(e){return _b.keyCodeToStr(e)}e.toString=t;function n(e){return _b.strToKeyCode(e)}e.fromString=n;function r(e){return vb.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return yb.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return vb.strToKeyCode(e)||yb.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 _b.keyCodeToStr(e)}e.toElectronAccelerator=o})(xb||={});var Sb=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 Cb([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Cb=class{constructor(e){if(e.length===0)throw $v(`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 wb(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return xb.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(Uy)switch(t){case 59:return 85;case 60:if(cb)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(sb)return 57}else if(Wy&&(sb&&t===93||!sb&&t===92))return 57;return bb[t]||0}var Tb=sb?256:2048,Eb=512,Db=1024,Ob=sb?2048:256,kb=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=wb(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|=Tb),this.altKey&&(t|=Eb),this.shiftKey&&(t|=Db),this.metaKey&&(t|=Ob),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Sb(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ab=new WeakMap;function jb(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 Mb=class{static getSameOriginWindowChain(e){let t=Ab.get(e);if(!t){t=[],Ab.set(e,t);let n=e,r;do r=jb(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}}},Nb=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=Mb.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Pb=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(Gy){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?Uy&&!sb?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=Ky&&ob?-(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?Uy&&!sb?-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()}},Fb=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Ib;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof Lb?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ty.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Fb})})(Ib||={});var Lb=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?Fb:(this._emitter||=new q,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},Rb=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 ty(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new ty(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},zb=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 ty(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=my(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Bb;(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})(Bb||={});var Vb=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 q,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 Ty.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())}};Vb.EMPTY=Vb.fromArray([]);function Hb(e){return Ub(e,0)}function Ub(e,t){switch(typeof e){case`object`:return e===null?Wb(349,t):Array.isArray(e)?Xae(e,t):Zae(e,t);case`string`:return Gb(e,t);case`boolean`:return Yae(e,t);case`number`:return Wb(e,t);case`undefined`:return Wb(937,t);default:return Wb(617,t)}}function Wb(e,t){return(t<<5)-t+e|0}function Yae(e,t){return Wb(e?433:863,t)}function Gb(e,t){t=Wb(149417,t);for(let n=0,r=e.length;n<r;n++)t=Wb(e.charCodeAt(n),t);return t}function Xae(e,t){return t=Wb(104579,t),e.reduce((e,t)=>Ub(t,e),t)}function Zae(e,t){return t=Wb(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=Gb(n,t),Ub(e[n],t)),t)}var{registerWindow:Qae,getWindow:Kb,getDocument:$ae,getWindows:eoe,getWindowsCount:toe,getWindowId:noe,getWindowById:roe,hasWindow:ioe,onDidRegisterWindow:aoe,onWillUnregisterWindow:ooe,onDidUnregisterWindow:soe}=function(){let e=new Map,t={window:yy,disposables:new gy};e.set(yy.vscodeWindowId,t);let n=new q,r=new q,i=new q;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 _y.None;let a=new gy,o={window:t,disposables:a.add(new gy)};return e.set(t.vscodeWindowId,o),a.add(my(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(J(t,Zb.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:yy},getDocument(e){return Kb(e).document}}}(),coe=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 J(e,t,n,r){return new coe(e,t,n,r)}function loe(e,t){return function(n){return t(new Nb(e,n))}}function uoe(e){return function(t){return e(new kb(t))}}var qb=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=loe(Kb(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=uoe(n)),J(e,t,i,r)},Jb,doe=class extends zb{constructor(e){super(),this.defaultTarget=e&&Kb(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Yb=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){Yv(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(Yb.sort),a.shift().execute();r.set(i,!1)};Jb=(t,r,a=0)=>{let o=noe(t),s=new Yb(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 Xb=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}};Xb.None=new Xb(0,0);function foe(e){let t=e.getBoundingClientRect(),n=Kb(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=Hb(n),a=r.get(i);if(a)a.users+=1;else{let o=new q,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(my(()=>{--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 Zb={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:Wy?`webkitAnimationStart`:`animationstart`,ANIMATION_END:Wy?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:Wy?`webkitAnimationIteration`:`animationiteration`},poe=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=Qb(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Qb(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Qb(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Qb(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Qb(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Qb(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Qb(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Qb(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Qb(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Qb(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Qb(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=Qb(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=Qb(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Qb(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 Qb(e){return typeof e==`number`?`${e}px`:e}function $b(e){return new poe(e)}var ex=class{constructor(){this._hooks=new gy,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(my(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=Kb(e)}this._hooks.add(J(a,Zb.POINTER_MOVE,e=>{e.buttons===n?(e.preventDefault(),this._pointerMoveCallback(e)):this.stopMonitoring(!0)})),this._hooks.add(J(a,Zb.POINTER_UP,e=>this.stopMonitoring(!0)))}};function moe(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 tx;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(tx||={});var nx=class e extends _y{constructor(){super(),this.dispatched=!1,this.targets=new Sy,this.ignoreTargets=new Sy,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ty.runAndSubscribe(aoe,({window:e,disposables:t})=>{t.add(J(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(J(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(J(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:yy,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=dy(new e),my(e.INSTANCE.targets.push(t))):_y.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=dy(new e),my(e.INSTANCE.ignoreTargets.push(t))):_y.None}static isTouchDevice(){return`ontouchstart`in yy||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(tx.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-ny(s.rollingPageX))<30&&Math.abs(s.initialPageY-ny(s.rollingPageY))<30){let e=this.newGestureEvent(tx.Tap,s.initialTarget);e.pageX=ny(s.rollingPageX),e.pageY=ny(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-ny(s.rollingPageX))<30&&Math.abs(s.initialPageY-ny(s.rollingPageY))<30){let e=this.newGestureEvent(tx.Contextmenu,s.initialTarget);e.pageX=ny(s.rollingPageX),e.pageY=ny(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=ny(s.rollingPageX),n=ny(s.rollingPageY),i=ny(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(tx.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===tx.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===tx.Change||t.type===tx.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=Jb(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(tx.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(tx.Change,i.initialTarget);a.translationX=r.pageX-ny(i.rollingPageX),a.translationY=r.pageY-ny(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)}};nx.SCROLL_FRICTION=-.005,nx.HOLD_DELAY=700,nx.CLEAR_TAP_COUNT_TIME=400,sv([moe],nx,`isTouchDevice`,1);var hoe=nx,rx=class extends _y{onclick(e,t){this._register(J(e,Zb.CLICK,n=>t(new Nb(Kb(e),n))))}onmousedown(e,t){this._register(J(e,Zb.MOUSE_DOWN,n=>t(new Nb(Kb(e),n))))}onmouseover(e,t){this._register(J(e,Zb.MOUSE_OVER,n=>t(new Nb(Kb(e),n))))}onmouseleave(e,t){this._register(J(e,Zb.MOUSE_LEAVE,n=>t(new Nb(Kb(e),n))))}onkeydown(e,t){this._register(J(e,Zb.KEY_DOWN,e=>t(new kb(e))))}onkeyup(e,t){this._register(J(e,Zb.KEY_UP,e=>t(new kb(e))))}oninput(e,t){this._register(J(e,Zb.INPUT,t))}onblur(e,t){this._register(J(e,Zb.BLUR,t))}onfocus(e,t){this._register(J(e,Zb.FOCUS,t))}onchange(e,t){this._register(J(e,Zb.CHANGE,t))}ignoreGesture(e){return hoe.ignoreTarget(e)}},ix=11,goe=class extends rx{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=ix+`px`,this.domNode.style.height=ix+`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 ex),this._register(qb(this.bgDomNode,Zb.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(qb(this.domNode,Zb.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new doe),this._pointerdownScheduleRepeatTimer=this._register(new Rb)}_arrowPointerDown(e){e.target&&e.target instanceof Element&&(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Kb(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},_oe=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}}},voe=class extends _y{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new _oe(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 sx(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=sx.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)))}},ax=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function ox(e,t){let n=t-e;return function(t){return e+n*xoe(t)}}function yoe(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var sx=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),yoe(ox(e,r),ox(i,t),.33)}return ox(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 ax(this.scrollLeft(t),this.scrollTop(t),!1):new ax(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 boe(e){return e**3}function xoe(e){return 1-boe(1-e)}var Soe=class extends _y{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 Rb)}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(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_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`:``)))}},Coe=140,cx=class extends rx{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 Soe(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new ex),this._shouldRender=!0,this.domNode=$b(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(J(this.domNode.domNode,Zb.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new goe(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=$b(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(J(this.slider.domNode,Zb.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=foe(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(ob&&a>Coe){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()}},lx=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)}},woe=class extends cx{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new lx(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}},Toe=class extends cx{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new lx(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}},Eoe=500,ux=50,dx=!0,Doe=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},fx=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(Gy){let t=Vy(Kb(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 Doe(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}};fx.INSTANCE=new fx;var Ooe=fx,koe=class extends rx{constructor(e,t,n){super(),this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new q),this.onWillScroll=this._onWillScroll.event,this._options=joe(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 Toe(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new woe(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=$b(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=$b(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=$b(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 Rb),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=fy(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,sb&&(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 Pb(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=fy(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(J(this._listenOnDomNode,Zb.MOUSE_WHEEL,e=>{this._onMouseWheel(new Pb(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=Ooe.INSTANCE;dx&&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=!sb&&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=ux*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=ux*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)&&(dx&&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(),Eoe)}},Aoe=class extends koe{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 joe(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,sb&&(t.className+=` mac`),t}var px=class extends _y{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new voe({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>Jb(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Aoe(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(Ty.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(my(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(my(()=>this._styleElement.remove())),this._register(Ty.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(`
117
+ `)})),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}};px=sv([K(2,Nv),K(3,Uv),K(4,Pv),K(5,qv),K(6,Rv),K(7,Gv)],px);var mx=class extends _y{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(my(()=>{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()}};mx=sv([K(1,Nv),K(2,Uv),K(3,Bv),K(4,Gv)],mx);var Moe=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)}},hx={full:0,left:0,center:0,right:0},gx={full:0,left:0,center:0,right:0},_x={full:0,left:0,center:0,right:0},vx=class extends _y{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 Moe,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(my(()=>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);gx.full=this._canvas.width,gx.left=e,gx.center=t,gx.right=e,this._refreshDrawHeightConstants(),_x.full=1,_x.left=1,_x.center=1+gx.left,_x.right=1+gx.left+gx.center}_refreshDrawHeightConstants(){hx.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);hx.left=t,hx.center=t,hx.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hx.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hx.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hx.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hx.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(_x[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-hx[e.position||`full`]/2),gx[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+hx[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}))}};vx=sv([K(2,Nv),K(3,Bv),K(4,Gv),K(5,Rv),K(6,qv),K(7,Uv)],vx);var Y;(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=`
118
+ `,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=``))(Y||={});var yx;(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=`Ÿ`))(yx||={});var bx;(e=>e.ST=`${Y.ESC}\\`)(bx||={});var xx=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(`${Y.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)}}};xx=sv([K(2,Nv),K(3,Rv),K(4,Fv),K(5,Gv)],xx);var Sx=0,Cx=0,wx=0,Tx=0,Ex={css:`#00000000`,rgba:0},Dx;(e=>{function t(e,t,n,r){return r===void 0?`#${Mx(e)}${Mx(t)}${Mx(n)}`:`#${Mx(e)}${Mx(t)}${Mx(n)}${Mx(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})(Dx||={});var Ox;(e=>{function t(e,t){if(Tx=(t.rgba&255)/255,Tx===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 Sx=a+Math.round((n-a)*Tx),Cx=o+Math.round((r-o)*Tx),wx=s+Math.round((i-s)*Tx),{css:Dx.toCss(Sx,Cx,wx),rgba:Dx.toRgba(Sx,Cx,wx)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=jx.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return Dx.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[Sx,Cx,wx]=jx.toChannels(t),{css:Dx.toCss(Sx,Cx,wx),rgba:t}}e.opaque=i;function a(e,t){return Tx=Math.round(t*255),[Sx,Cx,wx]=jx.toChannels(e.rgba),{css:Dx.toCss(Sx,Cx,wx,Tx),rgba:Dx.toRgba(Sx,Cx,wx,Tx)}}e.opacity=a;function o(e,t){return Tx=e.rgba&255,a(e,Tx*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(Ox||={});var kx;(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 Sx=parseInt(e.slice(1,2).repeat(2),16),Cx=parseInt(e.slice(2,3).repeat(2),16),wx=parseInt(e.slice(3,4).repeat(2),16),Dx.toColor(Sx,Cx,wx);case 5:return Sx=parseInt(e.slice(1,2).repeat(2),16),Cx=parseInt(e.slice(2,3).repeat(2),16),wx=parseInt(e.slice(3,4).repeat(2),16),Tx=parseInt(e.slice(4,5).repeat(2),16),Dx.toColor(Sx,Cx,wx,Tx);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 Sx=parseInt(r[1]),Cx=parseInt(r[2]),wx=parseInt(r[3]),Tx=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),Dx.toColor(Sx,Cx,wx,Tx);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[Sx,Cx,wx,Tx]=t.getImageData(0,0,1,1).data,Tx!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:Dx.toRgba(Sx,Cx,wx,Tx),css:e}}e.toColor=r})(kx||={});var Ax;(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})(Ax||={});var jx;(e=>{function t(e,t){if(Tx=(t&255)/255,Tx===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 Sx=a+Math.round((n-a)*Tx),Cx=o+Math.round((r-o)*Tx),wx=s+Math.round((i-s)*Tx),Dx.toRgba(Sx,Cx,wx)}e.blend=t;function n(e,t,n){let a=Ax.relativeLuminance(e>>8),o=Ax.relativeLuminance(t>>8);if(Nx(a,o)<n){if(o<a){let o=r(e,t,n),s=Nx(a,Ax.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>Nx(a,Ax.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=Nx(a,Ax.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>Nx(a,Ax.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=Nx(Ax.relativeLuminance2(o,s,c),Ax.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=Nx(Ax.relativeLuminance2(o,s,c),Ax.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=Nx(Ax.relativeLuminance2(o,s,c),Ax.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=Nx(Ax.relativeLuminance2(o,s,c),Ax.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})(jx||={});function Mx(e){let t=e.toString(16);return t.length<2?`0`+t:t}function Nx(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Noe=class extends Tv{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()]}},Px=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Dv}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||wv.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++)Px._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||wv.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}};Px=sv([K(0,Nv)],Px);function Poe(e){return 57508<=e&&e<=57558}function Foe(e){return 9472<=e&&e<=9631}function Ioe(e){return Poe(e)||Foe(e)}function Loe(){return{css:{canvas:Fx(),cell:Fx()},device:{canvas:Fx(),cell:Fx(),char:{width:0,height:0,left:0,top:0}}}}function Fx(){return{width:0,height:0}}var Ix=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 Dv,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,S=!1,C=0,ee=!1,te=0,ne=0,w=[],re=l!==-1&&u!==-1;for(let T=0;T<m;T++){e.loadCell(T,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let ie=!1,ae=T>=ne,oe=T,E=this._workCell;if(f.length>0&&T===f[0][0]&&ae){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)ae&&=i===this._isCellInSelection(v,t);ae&&=!n||a<r[0]||a>=r[1],ae?(ie=!0,E=new Noe(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),oe=r[1]-1,m=E.getWidth()):ne=r[1]}let D=this._isCellInSelection(T,t),O=n&&T===a,k=re&&T>=l&&T<=u,se=!1;this._decorationService.forEachDecorationAtCell(T,t,void 0,e=>{se=!0});let ce=E.getChars()||wv;if(ce===` `&&(E.isUnderline()||E.isOverline())&&(ce=`\xA0`),te=m*s-c.get(ce,E.isBold(),E.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(D&&ee||!D&&!ee&&E.bg===y)&&(D&&ee&&p.selectionForeground||E.fg===b)&&E.extended.ext===x&&k===S&&te===C&&!O&&!ie&&!se&&ae){E.isInvisible()?_+=wv:_+=ce,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=E.bg,b=E.fg,x=E.extended.ext,S=k,C=te,ee=D,ie&&a>=T&&a<=oe&&(a=T),!this._coreService.isCursorHidden&&O&&this._coreService.isCursorInitialized){if(w.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&w.push(`xterm-cursor-blink`),w.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:w.push(`xterm-cursor-outline`);break;case`block`:w.push(`xterm-cursor-block`);break;case`bar`:w.push(`xterm-cursor-bar`);break;case`underline`:w.push(`xterm-cursor-underline`)}}if(E.isBold()&&w.push(`xterm-bold`),E.isItalic()&&w.push(`xterm-italic`),E.isDim()&&w.push(`xterm-dim`),_=E.isInvisible()?wv:E.getChars()||wv,E.isUnderline()&&(w.push(`xterm-underline-${E.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!E.isUnderlineColorDefault())){if(E.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${Tv.toColorRGB(E.getUnderlineColor()).join(`,`)})`;else{let e=E.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&E.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}E.isOverline()&&(w.push(`xterm-overline`),_===` `&&(_=`\xA0`)),E.isStrikethrough()&&w.push(`xterm-strikethrough`),k&&(h.style.textDecoration=`underline`);let le=E.getFgColor(),ue=E.getFgColorMode(),de=E.getBgColor(),fe=E.getBgColorMode(),pe=!!E.isInverse();if(pe){let e=le;le=de,de=e;let t=ue;ue=fe,fe=t}let me,he,ge=!1;this._decorationService.forEachDecorationAtCell(T,t,void 0,e=>{e.options.layer!==`top`&&ge||(e.backgroundColorRGB&&(fe=50331648,de=e.backgroundColorRGB.rgba>>8&16777215,me=e.backgroundColorRGB),e.foregroundColorRGB&&(ue=50331648,le=e.foregroundColorRGB.rgba>>8&16777215,he=e.foregroundColorRGB),ge=e.options.layer===`top`)}),!ge&&D&&(me=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,de=me.rgba>>8&16777215,fe=50331648,ge=!0,p.selectionForeground&&(ue=50331648,le=p.selectionForeground.rgba>>8&16777215,he=p.selectionForeground)),ge&&w.push(`xterm-decoration-top`);let _e;switch(fe){case 16777216:case 33554432:_e=p.ansi[de],w.push(`xterm-bg-${de}`);break;case 50331648:_e=Dx.toColor(de>>16,de>>8&255,de&255),this._addStyle(h,`background-color:#${Lx((de>>>0).toString(16),`0`,6)}`);break;default:pe?(_e=p.foreground,w.push(`xterm-bg-257`)):_e=p.background}switch(me||E.isDim()&&(me=Ox.multiplyOpacity(_e,.5)),ue){case 16777216:case 33554432:E.isBold()&&le<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(le+=8),this._applyMinimumContrast(h,_e,p.ansi[le],E,me,void 0)||w.push(`xterm-fg-${le}`);break;case 50331648:let e=Dx.toColor(le>>16&255,le>>8&255,le&255);this._applyMinimumContrast(h,_e,e,E,me,he)||this._addStyle(h,`color:#${Lx(le.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,_e,p.foreground,E,me,he)||pe&&w.push(`xterm-fg-257`)}w.length&&=(h.className=w.join(` `),0),!O&&!ie&&!se&&ae?g++:h.textContent=_,te!==this.defaultSpacing&&(h.style.letterSpacing=`${te}px`),d.push(h),T=oe}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||Ioe(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=Ox.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]}};Ix=sv([K(1,Kv),K(2,Rv),K(3,Uv),K(4,Fv),K(5,Bv),K(6,qv)],Ix);function Lx(e,t,n){for(;e.length<n;)e=t+e;return e}var Roe=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}},zoe=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);s>=e.rows||c<0?this.clear():(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 Boe(){return new zoe}var Rx=`xterm-dom-renderer-owner-`,zx=`xterm-rows`,Bx=`xterm-fg-`,Vx=`xterm-bg-`,Hx=`xterm-focus`,Ux=`xterm-selection`,Voe=1,Wx=class extends _y{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=Voe++,this._rowElements=[],this._selectionRenderModel=Boe(),this.onRequestRedraw=this._register(new q).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(zx),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(Ux),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=Loe(),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(Ix,document),this._element.classList.add(Rx+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(my(()=>{this._element.classList.remove(Rx+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Roe(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} .${zx} 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} .${zx} { 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} .${zx} .xterm-dim { color: ${Ox.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} .${zx}.${Hx} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${zx}.${Hx} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${zx}.${Hx} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${zx} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${zx} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${zx} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${zx} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${zx} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ux} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ux} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ux} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${Bx}${n} { color: ${r.css}; }${this._terminalSelector} .${Bx}${n}.xterm-dim { color: ${Ox.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${Vx}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${Bx}257 { color: ${Ox.opaque(e.background).css}; }${this._terminalSelector} .${Bx}257.xterm-dim { color: ${Ox.multiplyOpacity(Ox.opaque(e.background),.5).css}; }${this._terminalSelector} .${Vx}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(Hx),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Hx),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`.${Rx}${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))}}};Wx=sv([K(7,Iv),K(8,Hv),K(9,Rv),K(10,Nv),K(11,Fv),K(12,Uv),K(13,qv)],Wx);var Gx=class extends _y{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Uoe(this._optionsService))}catch{this._measureStrategy=this._register(new Hoe(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())}};Gx=sv([K(2,Rv)],Gx);var Kx=class extends _y{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)}},Hoe=class extends Kx{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}},Uoe=class extends Kx{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}},Woe=class extends _y{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 Goe(this._window)),this._onDprChange=this._register(new q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(Ty.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(J(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(J(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}},Goe=class extends _y{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new vy),this._onDprChange=this._register(new q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(my(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=J(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)}},Koe=class extends _y{constructor(){super(),this.linkProviders=[],this._register(my(()=>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 qx(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 qoe(e,t,n,r,i,a,o,s,c){if(!a)return;let l=qx(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 Jx=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return qoe(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=qx(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])}}};Jx=sv([K(0,Gv),K(1,Hv)],Jx);var Joe=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=[]}},Yx={};Hae(Yx,{getSafariVersion:()=>nS,isChromeOS:()=>cS,isFirefox:()=>$x,isIpad:()=>iS,isIphone:()=>aS,isLegacyEdge:()=>eS,isLinux:()=>sS,isMac:()=>rS,isNode:()=>Xx,isSafari:()=>tS,isWindows:()=>oS});var Xx=typeof process<`u`&&`title`in process,Zx=Xx?`node`:navigator.userAgent,Qx=Xx?`node`:navigator.platform,$x=Zx.includes(`Firefox`),eS=Zx.includes(`Edge`),tS=/^((?!chrome|android).)*safari/i.test(Zx);function nS(){if(!tS)return 0;let e=Zx.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var rS=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(Qx),iS=Qx===`iPad`,aS=Qx===`iPhone`,oS=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(Qx),sS=Qx.indexOf(`Linux`)>=0,cS=/\bCrOS\b/.test(Zx),lS=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()}},uS=class extends lS{_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())}}},dS=class extends lS{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},fS=!Xx&&`requestIdleCallback`in window?dS:uS,pS=class{constructor(){this._queue=new fS}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},mS=class extends _y{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 vy),this._pausedResizeTask=new pS,this._observerDisposable=this._register(new vy),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 q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Joe((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new hS(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(my(()=>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=my(()=>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()}};mS=sv([K(2,Rv),K(3,Hv),K(4,Fv),K(5,Bv),K(6,Nv),K(7,Uv),K(8,qv)],mS);var hS=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 gS(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return yS(i,a,e,t,n,r)+bS(a,t,n,r)+xS(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,OS(Math.abs(i-e),DS(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return OS(vS(a>t?e:i,n)+(s-1)*n.cols+1+_S(a>t?i:e,n),DS(o,r))}function _S(e,t){return e-1}function vS(e,t){return t.cols-e}function yS(e,t,n,r,i,a){return bS(t,r,i,a).length===0?``:OS(ES(e,t,e,t-CS(t,i),!1,i).length,DS(`D`,a))}function bS(e,t,n,r){let i=e-CS(e,n),a=t-CS(t,n);return OS(Math.abs(i-a)-SS(e,t,n),DS(TS(e,t),r))}function xS(e,t,n,r,i,a){let o;o=bS(t,r,i,a).length>0?r-CS(r,i):t;let s=r,c=wS(e,t,n,r,i,a);return OS(ES(e,o,n,s,c===`C`,i).length,DS(c,a))}function SS(e,t,n){let r=0,i=e-CS(e,n),a=t-CS(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=TS(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function CS(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 wS(e,t,n,r,i,a){let o;return o=bS(n,r,i,a).length>0?r-CS(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function TS(e,t){return e>t?`A`:`B`}function ES(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 DS(e,t){let n=t?`O`:`[`;return Y.ESC+n+e}function OS(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var kS=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 AS(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 jS=50,MS=15,NS=50,PS=500,FS=RegExp(`\xA0`,`g`),IS=class extends _y{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 Dv,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new q),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 kS(this._bufferService),this._activeSelectionMode=0,this._register(my(()=>{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(FS,` `)).join(oS?`\r
119
+ `:`
120
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),sS&&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=AS(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=qx(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,-jS),jS),t/=jS,t/Math.abs(t)+Math.round(t*(MS-1)))}shouldForceSelection(e){return rS?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(),NS)}_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&&!(rS&&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<PS&&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=gS(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]);n?!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):this._oldHasSelection&&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=AS(n,this._bufferService.cols)}};IS=sv([K(3,Nv),K(4,Fv),K(5,Wv),K(6,Rv),K(7,Gv),K(8,Uv)],IS);var LS=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={}}},RS=class{constructor(){this._color=new LS,this._css=new LS}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()}},zS=Object.freeze((()=>{let e=[kx.toColor(`#2e3436`),kx.toColor(`#cc0000`),kx.toColor(`#4e9a06`),kx.toColor(`#c4a000`),kx.toColor(`#3465a4`),kx.toColor(`#75507b`),kx.toColor(`#06989a`),kx.toColor(`#d3d7cf`),kx.toColor(`#555753`),kx.toColor(`#ef2929`),kx.toColor(`#8ae234`),kx.toColor(`#fce94f`),kx.toColor(`#729fcf`),kx.toColor(`#ad7fa8`),kx.toColor(`#34e2e2`),kx.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:Dx.toCss(r,i,a),rgba:Dx.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:Dx.toCss(n,n,n),rgba:Dx.toRgba(n,n,n)})}return e})()),BS=kx.toColor(`#ffffff`),VS=kx.toColor(`#000000`),HS=kx.toColor(`#ffffff`),US=VS,WS={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},GS=BS,KS=class extends _y{constructor(e){super(),this._optionsService=e,this._contrastCache=new RS,this._halfContrastCache=new RS,this._onChangeColors=this._register(new q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:BS,background:VS,cursor:HS,cursorAccent:US,selectionForeground:void 0,selectionBackgroundTransparent:WS,selectionBackgroundOpaque:Ox.blend(VS,WS),selectionInactiveBackgroundTransparent:WS,selectionInactiveBackgroundOpaque:Ox.blend(VS,WS),scrollbarSliderBackground:Ox.opacity(BS,.2),scrollbarSliderHoverBackground:Ox.opacity(BS,.4),scrollbarSliderActiveBackground:Ox.opacity(BS,.5),overviewRulerBorder:BS,ansi:zS.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=qS(e.foreground,BS),t.background=qS(e.background,VS),t.cursor=Ox.blend(t.background,qS(e.cursor,HS)),t.cursorAccent=Ox.blend(t.background,qS(e.cursorAccent,US)),t.selectionBackgroundTransparent=qS(e.selectionBackground,WS),t.selectionBackgroundOpaque=Ox.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=qS(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Ox.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?qS(e.selectionForeground,Ex):void 0,t.selectionForeground===Ex&&(t.selectionForeground=void 0),Ox.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Ox.opacity(t.selectionBackgroundTransparent,.3)),Ox.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Ox.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=qS(e.scrollbarSliderBackground,Ox.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=qS(e.scrollbarSliderHoverBackground,Ox.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=qS(e.scrollbarSliderActiveBackground,Ox.opacity(t.foreground,.5)),t.overviewRulerBorder=qS(e.overviewRulerBorder,GS),t.ansi=zS.slice(),t.ansi[0]=qS(e.black,zS[0]),t.ansi[1]=qS(e.red,zS[1]),t.ansi[2]=qS(e.green,zS[2]),t.ansi[3]=qS(e.yellow,zS[3]),t.ansi[4]=qS(e.blue,zS[4]),t.ansi[5]=qS(e.magenta,zS[5]),t.ansi[6]=qS(e.cyan,zS[6]),t.ansi[7]=qS(e.white,zS[7]),t.ansi[8]=qS(e.brightBlack,zS[8]),t.ansi[9]=qS(e.brightRed,zS[9]),t.ansi[10]=qS(e.brightGreen,zS[10]),t.ansi[11]=qS(e.brightYellow,zS[11]),t.ansi[12]=qS(e.brightBlue,zS[12]),t.ansi[13]=qS(e.brightMagenta,zS[13]),t.ansi[14]=qS(e.brightCyan,zS[14]),t.ansi[15]=qS(e.brightWhite,zS[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]=qS(e.extendedAnsi[r],zS[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];else 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()}}};KS=sv([K(0,Rv)],KS);function qS(e,t){if(e!==void 0)try{return kx.toColor(e)}catch{}return t}var JS=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)}},YS=class{constructor(){this._services=new JS,this._services.set(Iv,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=jv(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)}},XS={trace:0,debug:1,info:2,warn:3,error:4,off:5},ZS=`xterm.js: `,QS=class extends _y{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),$S=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=XS[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?``:ZS)+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)}};QS=sv([K(0,Rv)],QS);var $S,eC=class extends _y{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new q),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}},tC=3,nC=Object.freeze(new Tv),rC=0,iC=2,aC=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*tC);let r=t||Dv.fromCharData([0,Cv,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*tC+0],n=t&2097151;return[this._data[e*tC+1],t&2097152?this._combined[e]:n?yv(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*tC+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*tC+0]=e|2097152|t[2]<<22):this._data[e*tC+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*tC+0]>>22}hasWidth(e){return this._data[e*tC+0]&12582912}getFg(e){return this._data[e*tC+1]}getBg(e){return this._data[e*tC+2]}hasContent(e){return this._data[e*tC+0]&4194303}getCodePoint(e){let t=this._data[e*tC+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*tC+0]&2097152}getString(e){let t=this._data[e*tC+0];return t&2097152?this._combined[e]:t&2097151?yv(t&2097151):``}isProtected(e){return this._data[e*tC+2]&536870912}loadCell(e,t){return rC=e*tC,t.content=this._data[rC+0],t.fg=this._data[rC+1],t.bg=this._data[rC+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*tC+0]=t.content,this._data[e*tC+1]=t.fg,this._data[e*tC+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*tC+0]=t|n<<22,this._data[e*tC+1]=r.fg,this._data[e*tC+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*tC+0];r&2097152?this._combined[e]+=yv(t):r&2097151?(this._combined[e]=yv(r&2097151)+yv(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*tC+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 Dv;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 Dv;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++;else 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*iC<this._data.buffer.byteLength;let n=e*tC;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*iC<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*iC<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);else{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*tC+0]&4194303)return e+(this._data[e*tC+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*tC+0]&4194303||this._data[e*tC+2]&50331648)return e+(this._data[e*tC+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<tC;e++)this._data[(n+i)*tC+e]=a[(t+i)*tC+e];a[(t+i)*tC+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<tC;e++)this._data[(n+i)*tC+e]=a[(t+i)*tC+e];a[(t+i)*tC+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*tC+0],n=e&2097151,a=e&2097152?this._combined[t]:n?yv(n):wv;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 oC(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=uC(u,d,t),p=1,m=0;for(;p<u.length;){let e=uC(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 sC(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 cC(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 lC(e,t,n){let r=[],i=e.map((n,r)=>uC(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=uC(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 uC(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 dC=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),fy(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};dC._nextId=1;var fC=dC,pC={},mC=pC.B;pC[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},pC.A={"#":`£`},pC.B=void 0,pC[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},pC.C=pC[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},pC.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},pC.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},pC.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},pC.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},pC.E=pC[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},pC.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},pC.H=pC[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},pC[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var hC=4294967295,gC=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=nC.clone(),this.savedCharset=mC,this.markers=[],this._nullCell=Dv.fromCharData([0,Cv,1,0]),this._whitespaceCell=Dv.fromCharData([0,wv,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new fS,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new eC(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 Ev),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 Ev),this._whitespaceCell}getBlankLine(e,t){return new aC(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>hC?hC:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=nC);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 eC(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(nC),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 aC(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 aC(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=oC(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(nC),n);if(r.length>0){let n=sC(this.lines,r);cC(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(nC),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new aC(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(nC),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=lC(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(nC,!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--,_=uC(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 fC(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)}},_C=class extends _y{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new q),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 gC(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new gC(!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)}},vC=2,yC=1,bC=class extends _y{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new q),this.onResize=this._onResize.event,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,vC),this.rows=Math.max(e.rawOptions.rows||0,yC),this.buffers=this._register(new _C(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))}};bC=sv([K(0,Rv)],bC);var xC={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:rS,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},SC=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],CC=class extends _y{constructor(e){super(),this._onOptionChange=this._register(new q),this.onOptionChange=this._onOptionChange.event;let t={...xC};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(my(()=>{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 xC))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in xC))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||=xC[e],!wC(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=xC[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=SC.includes(t)?t:xC[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 wC(e){return e===`block`||e===`underline`||e===`bar`}function TC(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]&&TC(e[r],t-1);return n}var EC=Object.freeze({insertMode:!1}),DC=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),OC=class extends _y{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 q),this.onData=this._onData.event,this._onUserInput=this._register(new q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=TC(EC),this.decPrivateModes=TC(DC)}reset(){this.modes=TC(EC),this.decPrivateModes=TC(DC)}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))}};OC=sv([K(0,Nv),K(1,Lv),K(2,Rv)],OC);var kC={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 AC(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 jC=String.fromCharCode,MC={DEFAULT:e=>{let t=[AC(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${jC(t[0])}${jC(t[1])}${jC(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${AC(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${AC(e,!0)};${e.x};${e.y}${t}`}},NC=class extends _y{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 q),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(kC))this.addProtocol(e,kC[e]);for(let e of Object.keys(MC))this.addEncoding(e,MC[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}};NC=sv([K(0,Nv),K(1,Fv),K(2,Rv)],NC);var PC=[[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]],FC=[[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]],IC;function LC(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 RC=class{constructor(){if(this.version=`6`,!IC){IC=new Uint8Array(65536),IC.fill(1),IC[0]=0,IC.fill(0,1,32),IC.fill(0,127,160),IC.fill(2,4352,4448),IC[9001]=2,IC[9002]=2,IC.fill(2,11904,42192),IC[12351]=1,IC.fill(2,44032,55204),IC.fill(2,63744,64256),IC.fill(2,65040,65050),IC.fill(2,65072,65136),IC.fill(2,65280,65377),IC.fill(2,65504,65511);for(let e=0;e<PC.length;++e)IC.fill(0,PC[e][0],PC[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?IC[e]:LC(e,FC)?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=zC.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return zC.createPropertyValue(0,n,r)}},zC=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new q,this.onChange=this._onChange.event;let e=new RC;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)}},BC=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 VC(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 HC=2147483647,UC=256,WC=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>UC)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;else{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>HC?HC: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>HC?HC: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,HC):e}},GC=[],KC=class{constructor(){this._state=0,this._active=GC,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=GC}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=GC,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||GC,!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`,bv(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=GC,this._id=-1,this._state=0}}},qC=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+=bv(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}},JC=[],YC=class{constructor(){this._handlers=Object.create(null),this._active=JC,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=JC}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=JC,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||JC,!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`,bv(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=JC,this._ident=0}},XC=new WC;XC.addParam(0);var ZC=class{constructor(e){this._handler=e,this._data=``,this._params=XC,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():XC,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=bv(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=XC,this._data=``,this._hitLimit=!1,e));return this._params=XC,this._data=``,this._hitLimit=!1,t}},QC=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}},$C=160,ew=function(){let e=new QC(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($C,0,2,0),e.add($C,8,5,8),e.add($C,6,0,6),e.add($C,11,0,11),e.add($C,13,13,13),e}(),tw=class extends _y{constructor(e=ew){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 WC,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(my(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new KC),this._dcsParser=this._register(new YC),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:$C)],i>>4){case 2:for(let i=n+1;;++i)if(i>=t||(r=e[i])<32||r>126&&r<$C||++i>=t||(r=e[i])<32||r>126&&r<$C||++i>=t||(r=e[i])<32||r>126&&r<$C||++i>=t||(r=e[i])<32||r>126&&r<$C){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<$C){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<$C){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}}},nw=/^([\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})$/,rw=/^[\da-f]+$/;function iw(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=nw.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),rw.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 aw(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 ow(e,t=16){let[n,r,i]=e;return`rgb:${aw(n,t)}/${aw(r,t)}/${aw(i,t)}`}var sw={"(":0,")":1,"*":2,"+":3,"-":1,".":2},cw=131072,lw=10;function uw(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 dw=5e3,fw=0,pw=class extends _y{constructor(e,t,n,r,i,a,o,s,c=new tw){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 xv,this._utf8Decoder=new Sv,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=nC.clone(),this._eraseAttrDataInternal=nC.clone(),this._onRequestBell=this._register(new q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new q),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 mw(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(Y.BEL,()=>this.bell()),this._parser.setExecuteHandler(Y.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Y.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Y.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Y.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Y.BS,()=>this.backspace()),this._parser.setExecuteHandler(Y.HT,()=>this.tab()),this._parser.setExecuteHandler(Y.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Y.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(yx.IND,()=>this.index()),this._parser.setExecuteHandler(yx.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(yx.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new qC(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new qC(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new qC(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new qC(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new qC(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new qC(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new qC(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new qC(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new qC(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new qC(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new qC(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new qC(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 pC)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 ZC((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`),dw))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${dw} 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>cw&&(a=this._parseStack.position+cw)}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<cw&&(this._parseBuffer=new Uint32Array(Math.min(e.length,cw))),o||this._dirtyRowTracker.clearRange(),e.length>cw)for(let t=a;t<e.length;t+=cw){let a=t+cw<e.length?t+cw: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=zC.extractWidth(t);let n=zC.extractShouldJoin(t),m=n?zC.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(yv(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 aC&&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)}else 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=>!uw(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new ZC(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new qC(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(nC));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=zC.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(Y.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(Y.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(Y.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(Y.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(Y.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,mC),this._charsetService.setgCharset(1,mC),this._charsetService.setgCharset(2,mC),this._charsetService.setgCharset(3,mC);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}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(`${Y.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|=Tv.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=nC.fg,e.bg=nC.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|=nC.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=nC.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|=nC.fg&16777215,r.bg&=-67108864,r.bg|=nC.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Y.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Y.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(`${Y.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=nC.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(!uw(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(`${Y.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>lw&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>lw&&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(hw(n)){if(r===`?`)t.push({type:0,index:n});else{let e=iw(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=iw(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]);hw(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,mC),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(sw[e[0]],pC[e[1]]||mC),!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=nC.clone(),this._eraseAttrDataInternal=nC.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 Dv;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(`${Y.ESC}${e}${Y.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)}},mw=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&&(fw=e,e=t,t=fw),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};mw=sv([K(0,Nv)],mw);function hw(e){return 0<=e&&e<256}var gw=5e7,_w=12,vw=50,yw=class extends _y{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 q),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>gw)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>=_w?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>=_w)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>vw&&(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()}},bw=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)))}};bw=sv([K(0,Nv)],bw);var xw=!1,Sw=class extends _y{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new vy),this._onBinary=this._register(new q),this.onBinary=this._onBinary.event,this._onData=this._register(new q),this.onData=this._onData.event,this._onLineFeed=this._register(new q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new q),this._instantiationService=new YS,this.optionsService=this._register(new CC(e)),this._instantiationService.setService(Rv,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(bC)),this._instantiationService.setService(Nv,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(QS)),this._instantiationService.setService(Lv,this._logService),this.coreService=this._register(this._instantiationService.createInstance(OC)),this._instantiationService.setService(Fv,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(NC)),this._instantiationService.setService(Pv,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(zC)),this._instantiationService.setService(Gae,this.unicodeService),this._charsetService=this._instantiationService.createInstance(BC),this._instantiationService.setService(Wae,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(bw),this._instantiationService.setService(zv,this._oscLinkService),this._inputHandler=this._register(new pw(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ty.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ty.forward(this._bufferService.onResize,this._onResize)),this._register(Ty.forward(this.coreService.onData,this._onData)),this._register(Ty.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 yw((e,t)=>this._inputHandler.parse(e,t))),this._register(Ty.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new q),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&&!xw&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),xw=!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,vC),t=Math.max(t,yC),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(VC.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(VC(this._bufferService),!1))),this._windowsWrappingHeuristics.value=my(()=>{for(let t of e)t.dispose()})}}},Cw={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 ww(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?Y.ESC+`OA`:Y.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?Y.ESC+`OD`:Y.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?Y.ESC+`OC`:Y.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?Y.ESC+`OB`:Y.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:Y.DEL,e.altKey&&(i.key=Y.ESC+i.key);break;case 9:if(e.shiftKey){i.key=Y.ESC+`[Z`;break}i.key=Y.HT,i.cancel=!0;break;case 13:i.key=e.altKey?Y.ESC+Y.CR:Y.CR,i.cancel=!0;break;case 27:i.key=Y.ESC,e.altKey&&(i.key=Y.ESC+Y.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?Y.ESC+`[1;`+(a+1)+`D`:t?Y.ESC+`OD`:Y.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?Y.ESC+`[1;`+(a+1)+`C`:t?Y.ESC+`OC`:Y.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?Y.ESC+`[1;`+(a+1)+`A`:t?Y.ESC+`OA`:Y.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?Y.ESC+`[1;`+(a+1)+`B`:t?Y.ESC+`OB`:Y.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=Y.ESC+`[2~`);break;case 46:i.key=a?Y.ESC+`[3;`+(a+1)+`~`:Y.ESC+`[3~`;break;case 36:i.key=a?Y.ESC+`[1;`+(a+1)+`H`:t?Y.ESC+`OH`:Y.ESC+`[H`;break;case 35:i.key=a?Y.ESC+`[1;`+(a+1)+`F`:t?Y.ESC+`OF`:Y.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?Y.ESC+`[5;`+(a+1)+`~`:Y.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?Y.ESC+`[6;`+(a+1)+`~`:Y.ESC+`[6~`;break;case 112:i.key=a?Y.ESC+`[1;`+(a+1)+`P`:Y.ESC+`OP`;break;case 113:i.key=a?Y.ESC+`[1;`+(a+1)+`Q`:Y.ESC+`OQ`;break;case 114:i.key=a?Y.ESC+`[1;`+(a+1)+`R`:Y.ESC+`OR`;break;case 115:i.key=a?Y.ESC+`[1;`+(a+1)+`S`:Y.ESC+`OS`;break;case 116:i.key=a?Y.ESC+`[15;`+(a+1)+`~`:Y.ESC+`[15~`;break;case 117:i.key=a?Y.ESC+`[17;`+(a+1)+`~`:Y.ESC+`[17~`;break;case 118:i.key=a?Y.ESC+`[18;`+(a+1)+`~`:Y.ESC+`[18~`;break;case 119:i.key=a?Y.ESC+`[19;`+(a+1)+`~`:Y.ESC+`[19~`;break;case 120:i.key=a?Y.ESC+`[20;`+(a+1)+`~`:Y.ESC+`[20~`;break;case 121:i.key=a?Y.ESC+`[21;`+(a+1)+`~`:Y.ESC+`[21~`;break;case 122:i.key=a?Y.ESC+`[23;`+(a+1)+`~`:Y.ESC+`[23~`;break;case 123:i.key=a?Y.ESC+`[24;`+(a+1)+`~`:Y.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=Y.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=Y.DEL:e.keyCode===219?i.key=Y.ESC:e.keyCode===220?i.key=Y.FS:e.keyCode===221&&(i.key=Y.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=Cw[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=Y.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=Y.ESC+n}else if(e.keyCode===32)i.key=Y.ESC+(e.ctrlKey?Y.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=Y.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=Y.US),e.key===`@`&&(i.key=Y.NUL))}return i}var Tw=0,Ew=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new fS,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new fS,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||(Tw=this._search(t),Tw===-1)||this._getKey(this._array[Tw])!==t)return!1;do if(this._array[Tw]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Tw),!0;while(++Tw<this._array.length&&this._getKey(this._array[Tw])===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&&(Tw=this._search(e),!(Tw<0||Tw>=this._array.length)&&this._getKey(this._array[Tw])===e))do yield this._array[Tw];while(++Tw<this._array.length&&this._getKey(this._array[Tw])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Tw=this._search(e),!(Tw<0||Tw>=this._array.length)&&this._getKey(this._array[Tw])===e))do t(this._array[Tw]);while(++Tw<this._array.length&&this._getKey(this._array[Tw])===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}},Dw=0,Ow=0,kw=class extends _y{constructor(){super(),this._decorations=new Ew(e=>e?.marker.line),this._onDecorationRegistered=this._register(new q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(my(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Aw(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=>{Dw=t.options.x??0,Ow=Dw+(t.options.width??1),e>=Dw&&e<Ow&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},Aw=class extends gy{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new q),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?kx.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?kx.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},jw=1e3,Mw=class{constructor(e,t=jw){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)}},Nw=20,Pw=class extends _y{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 Mw(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(`
121
+ `))),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(J(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(my(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<Nw+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
122
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Nw+1&&(this._liveRegion.textContent+=dv.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})`}};Pw=sv([K(1,Iv),K(2,Uv),K(3,Gv)],Pw);var Fw=class extends _y{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 q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(my(()=>{fy(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(J(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(J(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(J(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(J(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){this._activeLine!==e.y||this._wasResized?(this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1):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&&Iw(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,fy(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}}};Fw=sv([K(1,Wv),K(2,Gv),K(3,Nv),K(4,Jv)],Fw);function Iw(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 Lw=class extends Sw{constructor(e={}){super(e),this._linkifier=this._register(new vy),this.browser=Yx,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new vy),this._onCursorMove=this._register(new q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new q),this.onKey=this._onKey.event,this._onRender=this._register(new q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new q),this.onBell=this._onBell.event,this._onFocus=this._register(new q),this._onBlur=this._register(new q),this._onA11yCharEmitter=this._register(new q),this._onA11yTabEmitter=this._register(new q),this._onWillOpen=this._register(new q),this._setup(),this._decorationService=this._instantiationService.createInstance(kw),this._instantiationService.setService(Bv,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Koe),this._instantiationService.setService(Jv,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Vv)),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(Ty.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ty.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ty.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ty.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(my(()=>{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=Ox.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${Y.ESC}]${n};${ow(r)}${bx.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=Dx.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=Dx.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(Pw,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Y.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(Y.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(J(this.element,`copy`,e=>{this.hasSelection()&&mv(e,this._selectionService)}));let e=e=>hv(e,this.textarea,this.coreService,this.optionsService);this._register(J(this.textarea,`paste`,e)),this._register(J(this.element,`paste`,e)),$x?this._register(J(this.element,`mousedown`,e=>{e.button===2&&vv(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(J(this.element,`contextmenu`,e=>{vv(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),sS&&this._register(J(this.element,`auxclick`,e=>{e.button===1&&_v(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(J(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(J(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(J(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(J(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(J(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(J(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(J(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(J(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`,lv.get()),cS||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(Woe,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(Uv,this._coreBrowserService),this._register(J(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(J(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Gx,this._document,this._helperContainer),this._instantiationService.setService(Hv,this._charSizeService),this._themeService=this._instantiationService.createInstance(KS),this._instantiationService.setService(qv,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Px),this._instantiationService.setService(Kv,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(mS,this.rows,this.screenElement)),this._instantiationService.setService(Gv,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(xx,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Jx),this._instantiationService.setService(Wv,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Fw,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(px,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(IS,this.element,this.screenElement,r)),this._instantiationService.setService(qae,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(Ty.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(mx,this.screenElement)),this._register(J(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(Pw,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(vx,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(vx,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Wx,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(J(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(J(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=Y.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){gv(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=ww(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===Y.ETX||n.key===Y.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)&&(Rw(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){e===this.cols&&t===this.rows?this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure():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(nC));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(Y.ESC+`[I`):this.coreService.triggerDataEvent(Y.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(`${Y.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(`${Y.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};function Rw(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var zw=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)}},Bw=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 Dv)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Vw=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 Bw(t)}getNullCell(){return new Dv}},Hw=class extends _y{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new q),this.onBufferChange=this._onBufferChange.event,this._normal=new Vw(this._core.buffers.normal,`normal`),this._alternate=new Vw(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)}},Uw=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)}},Ww=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}},Gw=[`cols`,`rows`],Kw=0,qw=class extends _y{constructor(e){super(),this._core=this._register(new Lw(e)),this._addonManager=this._register(new zw),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(Gw.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 Uw(this._core),this._parser}get unicode(){return this._checkProposedApi(),new Ww(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 Hw(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
123
+ `,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 lv.get()},set promptLabel(e){lv.set(e)},get tooMuchOutput(){return dv.get()},set tooMuchOutput(e){dv.set(e)}}}_verifyIntegers(...e){for(Kw of e)if(Kw===1/0||isNaN(Kw)||Kw%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(Kw of e)if(Kw&&(Kw===1/0||isNaN(Kw)||Kw%1!=0||Kw<0))throw Error(`This API only accepts positive integers`)}},Jw=`CommitMono`,Yw=[400,700].map(e=>`${e} 14px ${Jw}`),Xw=`monospace`;function Zw(e){return e.trim().replace(/^['"]|['"]$/g,``)}function Qw(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=t?n:n.filter(e=>Zw(e)!==Jw);return r.length>0?r.join(`, `):Xw}function $w(e,t,n){return Promise.all(t.map(t=>e.load(t))).then(n,()=>void 0)}function eT(e,t){for(let n of e)n.term&&(n.term.options.fontFamily=t,n._syncGrid?.())}function tT(){return document.fonts?Yw.every(e=>document.fonts.check(e)):!1}function nT(){return Qw(getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`),tT())}function rT(e){document.fonts&&$w(document.fonts,Yw,e)}var iT=`(max-width: 768px)`,aT=`(pointer: coarse)`;function oT({coarse:e,narrowWidth:t}={}){return e===!0&&t===!0?`phone`:`desktop`}var sT=window.matchMedia?.(aT),cT=window.matchMedia?.(iT);function lT(){return oT({coarse:!!sT?.matches,narrowWidth:!!cT?.matches})}function uT(e){document.documentElement.dataset.layout!==e&&(document.documentElement.dataset.layout=e)}function dT(){pe.subscribe((e,t)=>{t.includes(`layout`)&&uT(e.layout)});let e=lT();uT(e),pe.dispatch(`setLayout`,e);let t=()=>pe.dispatch(`setLayout`,lT());return sT?.addEventListener?.(`change`,t),cT?.addEventListener?.(`change`,t),e}function fT(){return pe.snapshot().layout===`phone`}function pT(e){return pe.subscribe((t,n)=>{n.includes(`layout`)&&e(t.layout)})}var mT=`↑`,hT=`↓`,gT=`←`,_T=`→`,vT=`⌘`,yT=Array.from({length:9},(e,t)=>[`Digit${t+1}`,t+1]),bT=[{action:`next-attention`,keyCaptions:[`J`],label:`Jump to the next session needing you`,stepByCode:new Map([[`KeyJ`,0]])},{action:`rail-step`,keyCaptions:[mT,hT],label:`Previous / next session in the rail`,stepByCode:new Map([[`ArrowUp`,-1],[`ArrowDown`,1]])},{action:`view-step`,keyCaptions:[gT,_T],label:`Previous / next view tab`,stepByCode:new Map([[`ArrowLeft`,-1],[`ArrowRight`,1]]),unavailablePlatform:`other`},{action:`view-step`,keyCaptions:[`PgUp`,`PgDn`],label:`Previous / next view tab`,stepByCode:new Map([[`PageUp`,-1],[`PageDown`,1]]),unavailablePlatform:`mac`},{action:`session-nth`,keyCaptions:[`1..9`],label:`Jump to session 1 to 9`,stepByCode:new Map(yT)},{action:`new-session`,keyCaptions:[`0`],label:`Add a session`,stepByCode:new Map([[`Digit0`,0]])},{action:`merge`,keyCaptions:[`I`],label:`Merge the selected session`,stepByCode:new Map([[`KeyI`,0]])},{action:`resolve-or-resync`,keyCaptions:[`U`],label:`Resolve a parked merge, or resync the base branch`,stepByCode:new Map([[`KeyU`,0]])},{action:`streamer-mode`,keyCaptions:[`\\`],label:`Turn streamer mode on or off`,stepByCode:new Map([[`Backslash`,0]])}];function xT(e){return bT.filter(t=>t.unavailablePlatform!==e)}function ST(e){return/Mac|iPhone|iPad/.test(e)?`mac`:`other`}function CT(e,t){return e.ctrlKey||e.shiftKey?!1:t===`mac`?e.metaKey&&!e.altKey:e.altKey&&!e.metaKey}var wT=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`]);function TT(e){return wT.has(e.key)?e.key:e.code}function ET(e,t){if(!CT(e,t))return null;let n=TT(e);for(let e of xT(t)){let t=e.stepByCode.get(n);if(t!==void 0)return{action:e.action,step:t}}return null}function DT(e){return e===`mac`?vT:`Alt`}function OT(e,t){let n=xT(t).find(t=>t.action===e);if(!n)throw Error(`Unknown dashboard shortcut: ${e}`);return n}function kT(e,t){return[DT(t),OT(e,t).keyCaptions.join(` `)]}function AT(e,t){let[n,r]=kT(e,t);return t===`mac`?`${n}${r}`:`${n}+${r}`}function jT(e){let t=e===`mac`?`Meta`:`Alt`;return`ArrowUp ArrowDown ${t}+ArrowUp ${t}+ArrowDown`}function MT(e){let t=DT(e),n=e===`mac`?vT:`Ctrl`;return[{title:`Dashboard`,items:xT(e).map(e=>({combos:e.keyCaptions.map(e=>[t,e]),label:e.label}))},{title:`Navigation`,items:[{combos:[[mT],[hT]],label:`Move rail highlight (rail focused)`},{combos:[[gT],[_T]],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 NT=ST(navigator.userAgent);function PT(e,t){t.forEach((t,n)=>{n>0&&e.appendChild(m(`span`,`shortcut-sep`,`+`)),e.appendChild(m(`kbd`,`kbd`,t))})}function FT(e){let t=m(`span`,`shortcut-keys`);return PT(t,e),t}var IT=6,LT=262144,RT=16384,zT=()=>{};function BT(e,t){if(t.length<=RT)e.push(t);else for(let n=0;n<t.length;n+=RT)e.push(t.slice(n,n+RT))}function VT({budget:e=IT,maxChunkBytes:t=LT,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)BT(l,e),m+=e.length,a.readIdx++;else{m===0&&(BT(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++;else{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,zT);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);n?(n.write=t,n.live=!0):(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 HT=VT(),UT=.3,WT=null;function GT(){return Jf(WT)}function KT(e){return Yf(e,WT)}async function qT(){try{let e=await fetch(Hf,{credentials:`same-origin`,cache:`no-store`});e.ok&&(WT=Xf(await e.json()))}catch{}}function JT(){let e=new AudioContext;return e.state===`suspended`&&e.resume(),e}function YT(e,t){setTimeout(()=>e.close().catch(()=>{}),(t+.1)*1e3)}function XT(e){ZT(Uf[e]??Uf.chime)}function ZT(e){let t=JT(),n=t.createGain();n.gain.value=e.peakGain,n.connect(t.destination);let r=t.currentTime,i=0;for(let a of e.tones){let e=r+a.startSeconds,o=e+a.durationSeconds,s=t.createOscillator(),c=t.createGain();s.type=a.waveform,s.frequency.setValueAtTime(a.frequency,e),a.endFrequency&&s.frequency.exponentialRampToValueAtTime(a.endFrequency,o),c.gain.setValueAtTime(.001,e),c.gain.exponentialRampToValueAtTime(a.gain??1,e+.01),c.gain.exponentialRampToValueAtTime(.001,o),s.connect(c),c.connect(n),s.start(e),s.stop(o),i=Math.max(i,a.startSeconds+a.durationSeconds)}YT(t,i)}async function QT(e){try{let t=await fetch(Kf(e),{credentials:`same-origin`});return t.ok?await t.arrayBuffer():null}catch{return null}}async function $T(e){let t=await QT(e);if(!t)return!1;let n=JT();try{let e=await n.decodeAudioData(t),r=n.createGain();r.gain.value=UT,r.connect(n.destination);let i=n.createBufferSource();return i.buffer=e,i.connect(r),i.start(),YT(n,e.duration),!0}catch{return n.close().catch(()=>{}),!1}}var eE=[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 tE(){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<eE.length;i++){let a=r+i*n,o=e.createOscillator(),s=e.createGain();o.type=`square`,o.frequency.value=eE[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+eE.length*n;t.gain.setValueAtTime(.05,i-.05),t.gain.exponentialRampToValueAtTime(.001,i),setTimeout(()=>e.close().catch(()=>{}),(i-r+.1)*1e3)}catch{}}function nE(){try{XT(Bf)}catch{}}function rE(e){try{let t=KT(e),n=qf(t);if(!n){XT(t);return}$T(n).then(e=>{e||nE()})}catch{}}var iE={"--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)`},aE={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`},oE={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`,...iE,"--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:{...aE,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`,...iE,"--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:{...aE,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`,...iE,"--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:{...aE,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`}}},sE=`phyrexian`,cE=null;function lE(e){let t=oE[e];if(!t)return;let n=cE;cE=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`&&tE()}function uE(e){document.documentElement.toggleAttribute(`data-compact-status`,e)}function dE(e){document.documentElement.toggleAttribute(`data-show-usage`,e)}function fE(){let e=oE[cE||sE];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 pE(){return Object.entries(oE).map(([e,t])=>({id:e,label:t.label}))}var mE=N().int().min(1).max(500),hE=N().int().min(1).max(200);yo(`type`,[I({type:z(`input`),data:M()}),I({type:z(`claim`),cols:mE,rows:hE}),I({type:z(`unview`)})]);var gE=I({type:z(`pty-size`),cols:mE,rows:hE,seq:N().int().nonnegative()}),_E=`history`;R([`screen`,`deep`]);function vE(e){try{return JSON.parse(e)}catch{return null}}function yE(e){let t=gE.safeParse(vE(e));return t.success?t.data:null}function bE(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function xE(e){return!e||!Number.isInteger(e.cols)||!Number.isInteger(e.rows)?!1:e.cols>0&&e.rows>0}function SE(e){return{cols:Math.min(Math.max(e.cols,1),500),rows:Math.min(Math.max(e.rows,1),200)}}function CE({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&bE(e,n))}function wE({isDocumentVisible:e,isDocumentFocused:t,hasFocusInsideCard:n,hasWindowBlurredSinceFocus:r,isPhoneLayout:i}){return e?i||t?!0:n&&!r:!1}function TE({isDocumentVisible:e,isBorrowedCard:t,isTerminalFaceShown:n}){return!e||!t||!n}function EE({viewportTopLine:e,scrollbackLineCount:t,isDeepHistoryLoadedOrPending:n}){return e===0&&t>0&&t<5e3&&!n}function DE(e,t){let n=`/terminals/${encodeURIComponent(e)}`;return t?`${n}?${_E}=deep`:n}function OE({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:CE({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function kE({isActiveViewer:e,lastClaim:t,owedClaim:n}){return e?n??t:null}function AE({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!bE(e,t),s=xE(n)?SE(n):null,c=r&&!!s&&!bE(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:CE({authoritative:e,isActiveViewer:r,lastClaim:a})}}function jE(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function ME(e){let t=jE(e);return t===null?null:yE(t)}function NE(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=ME(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 PE=``,FE=`\x1B`,IE=`\r`,LE=new Map([[`deleteContentBackward`,PE],[`deleteByComposition`,PE],[`deleteCompositionText`,PE],[`deleteWordBackward`,FE],[`deleteSoftLineBackward`,FE],[`deleteHardLineBackward`,FE]]);function RE(e){return LE.get(e)??``}var zE=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function BE(e){return typeof e!=`string`||e===``||!zE.has(e)}function VE(e){return e?e.keyCode===229||e.key===`Process`:!1}function HE(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 PE.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,IE)}var UE=/https?:\/\/[^\s<>"']+/g,WE=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),GE={")":`(`,"]":`[`,"}":`{`};function KE(e,t){let n=0;for(let r of e)r===t&&n++;return n}function qE(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(WE.has(t)){e=e.slice(0,-1);continue}let n=GE[t];if(n&&KE(e,n)<KE(e,t))e=e.slice(0,-1);else return e}}function JE(e){let t=[];for(let n of e.matchAll(UE)){let e=qE(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var YE=50;function XE(){return{activate(e,t){__(t)},allowNonHttpProtocols:!1}}function ZE(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<YE;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<YE;)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 QE(e){return e.registerLinkProvider({provideLinks(t,n){let r=e.buffer?.active;if(!r)return n(void 0);let{text:i,cellAt:a}=ZE(r,t),o=[];for(let{start:e,end:t,url:n}of JE(i)){let r=a[e],i=a[t-1];r&&i&&o.push({range:{start:r,end:i},text:n,activate(e,t){__(t)}})}n(o.length?o:void 0)}})}var $E=`(?:password|passwd|pwd|token|api[_-]?key|secret|credential|auth[_-]?token|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|connection[_-]?string)`,eD=`(?:"[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s\\r\\n]+)`,tD=`[^\\S\\r\\n]`,nD=`${$E}${tD}*(?:=>|[:=])${tD}*`,rD=`[?&][A-Za-z0-9_.-]*`,iD=`[^\\r\\n;&|]{0,200}?`,aD=`(?:mysql|mysqldump|mysqladmin|mysqlshow|mariadb|mariadb-dump)`,oD=RegExp(`(${nD})${eD}`,`gi`),sD=RegExp(`(\\bBearer${tD}+)[A-Za-z0-9._~+/=-]{8,}`,`gi`),cD=[/\bAKIA[0-9A-Z]{16}\b/g,/\bgh[pousr]_[A-Za-z0-9]{16,}\b/g,/\bgithub_pat_[A-Za-z0-9_]{20,}\b/g,/\bsk-ant-[A-Za-z0-9_-]{20,}/g,/\bsk-[A-Za-z0-9_-]{20,}/g,/\bph[cx]_[A-Za-z0-9]{20,}\b/g,/\bxox[abprs]-[A-Za-z0-9-]{10,}\b/g,/\beyJ[A-Za-z0-9_=-]{6,}\.[A-Za-z0-9_=-]{6,}\.[A-Za-z0-9_=-]{4,}/g,/-----BEGIN(?:[A-Z0-9 ]+)? PRIVATE KEY-----/g],lD=[RegExp(`((?:^|\\s)--?${$E}${tD}+)${eD}`,`gi`),RegExp(`((?:^|\\s)-(?:pwd|pw)(?![a-z])${tD}*=?${tD}*)${eD}`,`g`),RegExp(`(-AsPlainText${tD}+)${eD}`,`gi`),RegExp(`((?:^|\\s)setx${tD}+[^\\s\\r\\n]*${$E}[^\\s\\r\\n]*${tD}+)${eD}`,`gi`)],uD=[RegExp(`(\\bauthorization${tD}*:${tD}*Basic${tD}+)[A-Za-z0-9+/=_-]{8,}`,`gi`),RegExp(`(\\bdocker${tD}+login\\b${iD}${tD}-p(?:${tD}+|=))${eD}`,`gi`),RegExp(`(\\bcurl\\b${iD}${tD}(?:--user|-u)(?:${tD}+|=)[^\\s:\\r\\n]+:)${eD}`,`gi`),RegExp(`(\\b${aD}\\b${iD}${tD}-p)${eD}`,`g`),/\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)[^\s@/]+(?=@)/gi];[...lD,...uD];var dD=[/-----END(?:[A-Z0-9 ]+)? PRIVATE KEY-----/g,/^([^\S\r\n]*)(?=[A-Za-z0-9+/]*[g-zG-Z+/])(?=[A-Za-z0-9+/=]{60,76}[^\S\r\n]*$)[A-Za-z0-9+/]+={0,2}(?=[^\S\r\n]*$)/gm],fD=RegExp(`(${rD}(?:${$E}|_key)=)[^&#\\s]+`,`gi`),pD=[oD,RegExp(`(\\b(?=[A-Z0-9_]*(?:SECRET|TOKEN|KEY|PASSWORD))[A-Z][A-Z0-9_]*=)${eD}`,`g`)],mD=[sD,...lD,...uD,...cD,...dD];function hD(e,t){return[...e.matchAll(t)].map(e=>({matchStart:e.index,valueStart:e.index+(e[1]??``).length,end:e.index+e[0].length}))}function gD(e,t){let n=0;return e.filter(e=>{for(;n<t.length&&t[n].end<=e.matchStart;)n+=1;let r=t.at(n);return!r||e.matchStart<r.matchStart})}function _D(e){let t=[];for(let n of e.toSorted((e,t)=>e.start-t.start)){let e=t.at(-1);e&&n.start<=e.end?e.end=Math.max(e.end,n.end):t.push({...n})}return t}function vD(e){let t=hD(e,fD);return _D([...t,...pD.flatMap(n=>gD(hD(e,n),t)),...mD.flatMap(t=>hD(e,t))].map(e=>({start:e.valueStart,end:e.end})))}var yD=`#808080`,bD=new WeakMap;function xD(e,t,n){return`${e}:${t}:${n}`}function SD(e){return xD(e.marker.line,e.x,e.width)}function CD(e,t){let n=t;for(;n>0&&t-n<63&&e.getLine(n)?.isWrapped;)n--;return n}function wD(e,t){let n=t;for(;n-t<63&&e.getLine(n+1)?.isWrapped;)n++;return n}function TD(e,t,n){let r=``;for(let i=t;i<=n;i++)r+=e.getLine(i)?.translateToString(!1)??``;return r}function ED(e,t,n,r){let i=``,a=[];for(let o=t;o<=n;o++){let t=e.getLine(o);if(!t)break;for(let e=0;e<t.length;e++){let n=t.getCell(e,r);if(!n)break;let s=n.getWidth();if(s===0)continue;let c=n.getChars()||` `;for(let t=0;t<c.length;t++)i+=c[t],a.push({line:o,x:e,width:s})}}return{text:i,cellAt:a}}function DD(e,t){let n=null;for(let r of t)n&&n.line===r.line?n.width=Math.max(n.width,r.x+r.width-n.x):(n={line:r.line,x:r.x,width:r.width},e.push(n))}function OD(e,t,n,r){let i=[];if(vD(TD(e,t,n)).length===0)return i;let{text:a,cellAt:o}=ED(e,t,n,r);for(let e of vD(a))DD(i,o.slice(e.start,e.end));return i}function kD(e,t){let n=e.getNullCell(),r=[],i=t;for(;i<e.length;){let t=wD(e,i);r.push(...OD(e,i,t,n)),i=t+1}return r}function AD(){return{masks:[],watermark:null,isFullRescanOwed:!0}}function jD(e){e.decoration.dispose(),e.marker.dispose()}function MD(e){for(let t of e.masks)jD(t);e.masks.length=0,e.watermark?.dispose(),e.watermark=null,e.isFullRescanOwed=!0}function ND(e,t){let n=e.watermark;return e.isFullRescanOwed||!n||n.isDisposed?0:Math.min(n.line,t.baseY)}function PD(e){let t=0;for(;t<e.masks.length&&e.masks[t].marker.isDisposed;)e.masks[t].decoration.dispose(),t++;t>0&&e.masks.splice(0,t)}function FD(e,t){let n=new Map,r=e.masks.at(-1);for(;r&&(r.marker.isDisposed||r.marker.line>=t);)e.masks.pop(),r.marker.isDisposed&&r.decoration.dispose(),r.marker.isDisposed||n.set(SD(r),r),r=e.masks.at(-1);return PD(e),n}function ID(e,t){let n={normal:AD(),alternate:AD()},r=e.cols;function i(t){return e.buffer.active.type===t}function a(t,n){if(!i(n)||t.isDisposed)return!1;let r=t.line-e.buffer.active.viewportY;return r>=0&&r<e.rows}function o(t,n,r){t.style.backgroundColor=e.options.theme?.foreground??yD,t.style.pointerEvents=`none`,t.style.display=a(n,r)?`block`:`none`}function s(e){for(let t of n[e].masks){let n=t.decoration.element;n&&o(n,t.marker,e)}}function c(t,n){let r=e.registerMarker(t.line-(n.baseY+n.cursorY));if(!r)return null;let i=e.registerDecoration({marker:r,x:t.x,width:t.width,layer:`top`});if(!i)return r.dispose(),null;let a=n.type;return i.onRender(e=>o(e,r,a)),{marker:r,decoration:i,x:t.x,width:t.width}}function l(){if(!Jg())return;let t=e.buffer.active,r=n[t.type],i=CD(t,ND(r,t)),a=FD(r,i);for(let e of kD(t,i)){let n=xD(e.line,e.x,e.width),i=a.get(n);a.delete(n);let o=i??c(e,t);o&&r.masks.push(o)}for(let e of a.values())jD(e);r.watermark?.dispose(),r.watermark=e.registerMarker(-t.cursorY)??null,r.isFullRescanOwed=!1}function u(){MD(n.normal),MD(n.alternate)}function d(){u(),r=e.cols,l()}let f=[e.onWriteParsed(l),e.onResize(({cols:e})=>{e!==r&&(r=e,n.normal.isFullRescanOwed=!0,n.alternate.isFullRescanOwed=!0,l())}),e.buffer.onBufferChange(e=>{MD(n.alternate),s(`normal`),e.type===`alternate`&&l()})],p=Xg(d);t.addEventListener(`abort`,()=>{p();for(let e of f)e.dispose();u(),bD.delete(e)},{once:!0}),bD.set(e,d)}function LD(e){bD.get(e)?.()}function RD({hasTerminal:e,isSocketOpen:t,isInputHeld:n}){return e?n||!t?`connecting`:`live`:`none`}async function zD(e,t){let n={"x-glimmervoid-upload-name":encodeURIComponent(t.name)};t.type&&(n[`content-type`]=t.type);try{let r=await fetch(`/upload/${encodeURIComponent(e)}`,{method:`POST`,body:t,headers:n});r.ok||Hg(await VD(r))}catch{Hg(`Upload failed`)}}async function BD(e,t){for(let n of t)await zD(e,n)}async function VD(e){try{let t=await e.json();if(t&&typeof t.error==`string`)return`Upload failed: ${t.error}`}catch{}return`Upload failed`}var HD=1.2,UD=.005;function WD(e,t){let n=Math.abs(t);return n<10?!1:n>Math.abs(e)*HD}function GD(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 KD(e,t,n){let r=e.length>=4?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function qD(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 JD({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function YD(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)-UD*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=GD(e.pendingPx+a,e.cellHeightPx);return{scrollLines:o,state:{velocityPxPerMs:i*r,lastMs:t,cellHeightPx:e.cellHeightPx,pendingPx:s}}}function XD(e,t){return e===`alternate`||!!t&&t!==`none`}function ZD(e,t){return!(e>0)||!(t>0)?0:e/t}var QD=1;function $D(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function eO(e,t){for(let n of e)if(n.identifier===t)return n;return null}function tO(e,t){if($D(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=()=>XD(t.buffer?.active?.type,t.modes?.mouseTrackingMode),m=()=>{let e=t.element?.querySelector(`.xterm-screen`);return ZD(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:QD,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}=YD(u,performance.now());u=a,i!==0&&t.scrollLines(i),u&&(i!==0&&t.buffer?.active?.viewportY===r?f():d=requestAnimationFrame(_))},v=(e,t,n)=>{u=JD({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=eO(e.touches,r);if(!u)return;if(!s){if(!WD(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=KD([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=KD(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=GD(c,m(),d?8:void 0);c=h,f!==0&&(d?g(f,u.clientX,u.clientY):t.scrollLines(f))},{passive:!1}),e.addEventListener(`touchend`,e=>{if(!s||p()){h();return}l=KD(l,o,e.timeStamp);let t=qD(l),n=c;h(),t!==0&&v(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}var nO=Object.defineProperty,rO=Object.getOwnPropertyDescriptor,iO=(e,t,n,r)=>{for(var i=r>1?void 0:r?rO(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&&nO(t,n,i),i},aO=(e,t)=>(n,r)=>t(n,r,e),oO=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?dO.isErrorNoTelemetry(e)?new dO(e.message+`
124
+
125
+ `+e.stack):Error(e.message+`
126
+
127
+ `+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 sO(e){lO(e)||oO.onUnexpectedError(e)}var cO=`Canceled`;function lO(e){return e instanceof uO||e instanceof Error&&e.name===cO&&e.message===cO}var uO=class extends Error{constructor(){super(cO),this.name=this.message}},dO=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`}},fO;(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})(fO||={});var pO=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||fO.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};pO.empty=new pO(e=>{});function mO(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 hO;(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})(hO||={});var gO=null;function _O(e){return gO?.trackDisposable(e),e}function vO(e){gO?.markAsDisposed(e)}function yO(e,t){gO?.setParent(e,t)}function bO(e){if(hO.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 xO(...e){return SO(()=>bO(e))}function SO(e){let t=_O({dispose:mO(()=>{vO(t),e()})});return t}var CO=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,_O(this)}dispose(){this._isDisposed||(vO(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{bO(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return yO(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),yO(e,null))}};CO.DISABLE_DISPOSED_WARNING=!1;var wO=CO,TO=class{constructor(){this._store=new wO,_O(this),yO(this._store,this)}dispose(){vO(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};TO.None=Object.freeze({dispose(){}});var EO=class{constructor(){this._isDisposed=!1,_O(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&yO(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,vO(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&yO(e,null),e}},DO=typeof process<`u`&&`title`in process,OO=DO?`node`:navigator.userAgent,kO=DO?`node`:navigator.platform,Yoe=OO.includes(`Firefox`),Xoe=OO.includes(`Edge`),AO=/^((?!chrome|android).)*safari/i.test(OO);function Zoe(){if(!AO)return 0;let e=OO.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(kO),[`Windows`,`Win16`,`Win32`,`WinCE`].includes(kO),kO.indexOf(`Linux`),/\bCrOS\b/.test(OO);var Qoe=``,jO=0,MO=0,NO=0,PO=0,FO={css:`#00000000`,rgba:0},IO;(e=>{function t(e,t,n,r){return r===void 0?`#${BO(e)}${BO(t)}${BO(n)}`:`#${BO(e)}${BO(t)}${BO(n)}${BO(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})(IO||={});var LO;(e=>{function t(e,t){if(PO=(t.rgba&255)/255,PO===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 jO=a+Math.round((n-a)*PO),MO=o+Math.round((r-o)*PO),NO=s+Math.round((i-s)*PO),{css:IO.toCss(jO,MO,NO),rgba:IO.toRgba(jO,MO,NO)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=zO.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return IO.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[jO,MO,NO]=zO.toChannels(t),{css:IO.toCss(jO,MO,NO),rgba:t}}e.opaque=i;function a(e,t){return PO=Math.round(t*255),[jO,MO,NO]=zO.toChannels(e.rgba),{css:IO.toCss(jO,MO,NO,PO),rgba:IO.toRgba(jO,MO,NO,PO)}}e.opacity=a;function o(e,t){return PO=e.rgba&255,a(e,PO*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(LO||={});var $oe;(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 jO=parseInt(e.slice(1,2).repeat(2),16),MO=parseInt(e.slice(2,3).repeat(2),16),NO=parseInt(e.slice(3,4).repeat(2),16),IO.toColor(jO,MO,NO);case 5:return jO=parseInt(e.slice(1,2).repeat(2),16),MO=parseInt(e.slice(2,3).repeat(2),16),NO=parseInt(e.slice(3,4).repeat(2),16),PO=parseInt(e.slice(4,5).repeat(2),16),IO.toColor(jO,MO,NO,PO);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 jO=parseInt(r[1]),MO=parseInt(r[2]),NO=parseInt(r[3]),PO=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),IO.toColor(jO,MO,NO,PO);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[jO,MO,NO,PO]=t.getImageData(0,0,1,1).data,PO!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:IO.toRgba(jO,MO,NO,PO),css:e}}e.toColor=r})($oe||={});var RO;(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})(RO||={});var zO;(e=>{function t(e,t){if(PO=(t&255)/255,PO===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 jO=a+Math.round((n-a)*PO),MO=o+Math.round((r-o)*PO),NO=s+Math.round((i-s)*PO),IO.toRgba(jO,MO,NO)}e.blend=t;function n(e,t,n){let a=RO.relativeLuminance(e>>8),o=RO.relativeLuminance(t>>8);if(VO(a,o)<n){if(o<a){let o=r(e,t,n),s=VO(a,RO.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>VO(a,RO.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=VO(a,RO.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>VO(a,RO.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=VO(RO.relativeLuminance2(o,s,c),RO.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=VO(RO.relativeLuminance2(o,s,c),RO.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=VO(RO.relativeLuminance2(o,s,c),RO.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=VO(RO.relativeLuminance2(o,s,c),RO.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})(zO||={});function BO(e){let t=e.toString(16);return t.length<2?`0`+t:t}function VO(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function HO(e){if(!e)throw Error(`value must not be falsy`);return e}function UO(e){return 57508<=e&&e<=57558}function ese(e){return 57520<=e&&e<=57527}function tse(e){return 57344<=e&&e<=63743}function nse(e){return 9472<=e&&e<=9631}function rse(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 ise(e,t,n,r){return t===1&&n>Math.ceil(r*1.5)&&e!==void 0&&e>255&&!rse(e)&&!UO(e)&&!tse(e)}function WO(e){return UO(e)||nse(e)}function ase(){return{css:{canvas:GO(),cell:GO()},device:{canvas:GO(),cell:GO(),char:{width:0,height:0,left:0,top:0}}}}function GO(){return{width:0,height:0}}function ose(e,t,n=0){return(e-(Math.round(t)*2-n))%(Math.round(t)*2)}var KO=0,qO=0,JO=!1,YO=!1,XO=!1,ZO,QO=0,sse=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,qO=0,KO=0,YO=!1,JO=!1,XO=!1,ZO=this._themeService.colors,QO=0,e.getCode()!==0&&e.extended.underlineStyle===4){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));QO=t*r%(Math.round(e)*2)}if(this._decorationService.forEachDecorationAtCell(t,n,`bottom`,e=>{e.backgroundColorRGB&&(qO=e.backgroundColorRGB.rgba>>8&16777215,YO=!0),e.foregroundColorRGB&&(KO=e.foregroundColorRGB.rgba>>8&16777215,JO=!0)}),XO=this._selectionRenderModel.isCellSelected(this._terminal,t,n),XO){if(this.result.fg&67108864||this.result.bg&50331648){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:qO=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:qO=(this.result.fg&16777215)<<8|255;break;default:qO=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:qO=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:qO=(this.result.bg&16777215)<<8|255}qO=zO.blend(qO,(this._coreBrowserService.isFocused?ZO.selectionBackgroundOpaque:ZO.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else qO=(this._coreBrowserService.isFocused?ZO.selectionBackgroundOpaque:ZO.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(YO=!0,ZO.selectionForeground&&(KO=ZO.selectionForeground.rgba>>8&16777215,JO=!0),WO(e.getCode())){if(this.result.fg&67108864&&!(this.result.bg&50331648))KO=(this._coreBrowserService.isFocused?ZO.selectionBackgroundOpaque:ZO.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:KO=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:KO=(this.result.bg&16777215)<<8|255}else switch(this.result.fg&50331648){case 16777216:case 33554432:KO=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:KO=(this.result.fg&16777215)<<8|255;break;default:KO=this._themeService.colors.foreground.rgba}KO=zO.blend(KO,(this._coreBrowserService.isFocused?ZO.selectionBackgroundOpaque:ZO.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}JO=!0}}this._decorationService.forEachDecorationAtCell(t,n,`top`,e=>{e.backgroundColorRGB&&(qO=e.backgroundColorRGB.rgba>>8&16777215,YO=!0),e.foregroundColorRGB&&(KO=e.foregroundColorRGB.rgba>>8&16777215,JO=!0)}),YO&&(qO=XO?e.bg&-150994944|qO|50331648:e.bg&-16777216|qO|50331648),JO&&(KO=e.fg&-83886080|KO|50331648),this.result.fg&67108864&&(YO&&!JO&&(KO=this.result.bg&50331648?this.result.fg&-134217728|this.result.bg&67108863:this.result.fg&-134217728|ZO.background.rgba>>8&16777215|50331648,JO=!0),!YO&&JO&&(qO=this.result.fg&50331648?this.result.bg&-67108864|this.result.fg&67108863:this.result.bg&-67108864|ZO.foreground.rgba>>8&16777215|50331648,YO=!0)),ZO=void 0,this.result.bg=YO?qO:this.result.bg,this.result.fg=JO?KO:this.result.fg,this.result.ext&=536870911,this.result.ext|=QO<<29&3758096384}},cse=.5,$O=Yoe||Xoe?`bottom`:`ideographic`,lse={"▀":[{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}]},use={"░":[[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]]},dse={"─":{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`}},ek={"":{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}};ek[``]=ek[``],ek[``]=ek[``];function fse(e,t,n,r,i,a,o,s){let c=lse[t];if(c)return pse(e,c,n,r,i,a),!0;let l=use[t];if(l)return mse(e,l,n,r,i,a),!0;let u=dse[t];if(u)return hse(e,u,n,r,i,a,s),!0;let d=ek[t];return d?(gse(e,d,n,r,i,a,o,s),!0):!1}function pse(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 tk=new Map;function mse(e,t,n,r,i,a){let o=tk.get(t);o||(o=new Map,tk.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=HO(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=HO(e.createPattern(i,null)),o.set(s,c)}e.fillStyle=c,e.fillRect(n,r,i,a)}function hse(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=rk[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,ik(l,i,a,n,r,!0,o))}e.stroke(),e.closePath()}}function gse(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=rk[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,ik(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 nk(e,t,n=0){return Math.max(Math.min(e,t),n)}var rk={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 ik(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]=nk(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]=nk(Math.round(l[e]+.5)-.5,n,0)),l[e]+=i;return l}var ak=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={}}},ok=class{constructor(){this._data=new ak}set(e,t,n,r,i){this._data.get(e,t)||this._data.set(e,t,new ak),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()}},sk=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()}},_se=class extends sk{_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())}}},vse=class extends sk{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},yse=!DO&&`requestIdleCallback`in window?vse:_se,ck=class e{constructor(){this.fg=0,this.bg=0,this.extended=new lk}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}},lk=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}},uk=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};uk.Undefined=new uk(void 0);var bse=globalThis.performance&&typeof globalThis.performance.now==`function`,xse=class e{static create(t){return new e(t)}constructor(e){this._now=bse&&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}},dk;(e=>{e.None=()=>TO.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(xO(...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 gk({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 gk({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 gk({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 gk({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 gk({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 S(e){let t=new gk;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function ee(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=ee;class te{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 gk(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 ne(e,t){return new te(e,t).emitter.event}e.fromObservable=ne;function w(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 wO?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=w})(dk||={});var fk=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 xse,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}}};fk.all=new Set,fk._idPool=0;var Sse=fk,pk=-1,mk=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 Tse(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}};mk._idPool=1;var Cse=mk,wse=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
128
+ `).slice(2).join(`
129
+ `))}},Tse=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},Ese=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},Dse=0,hk=class{constructor(e){this.value=e,this.id=Dse++}},Ose=2,gk=class{constructor(e){this._size=0,this._options=e,this._leakageMon=pk>0||this._options?.leakWarningThreshold?new Cse(e?.onListenerError??sO,this._options?.leakWarningThreshold??pk):void 0,this._perfMon=this._options?._profName?new Sse(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 Ese(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||sO)(n),TO.None}if(this._disposed)return TO.None;t&&(e=e.bind(t));let r=new hk(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=wse.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof hk?(this._deliveryQueue??=new kse,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=SO(()=>{i?.(),this._removeListener(r)});return n instanceof wO?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*Ose<=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||sO;if(!n)e.value(t);else 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 hk)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}},kse=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}},_k={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}},vk=2,yk,bk=class e{constructor(e,t,n){this._document=e,this._config=t,this._unicodeService=n,this._didWarmUp=!1,this._cacheMap=new ok,this._cacheMapCombined=new ok,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new ck,this._textureSize=512,this._onAddTextureAtlasCanvas=new gk,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new gk,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=Ck(e,this._config.deviceCellWidth*4+vk*2,this._config.deviceCellHeight+vk*2),this._tmpCtx=HO(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 yse;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 xk(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 xk(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 yk=e.get(t,n,r,i),yk||(yk=this._drawToCache(t,n,r,i,a,o),e.set(t,n,r,i,yk)),yk}_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 FO;let i;switch(e){case 16777216:case 33554432:i=this._getColorFromAnsiIndex(t);break;case 50331648:let e=ck.toColorRGB(t);i=IO.toColor(e[0],e[1],e[2]);break;default:i=n?LO.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(i=LO.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=ck.toColorRGB(a);d=IO.toColor(e[0],e[1],e[2]);break;default:d=o?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(d=LO.opaque(d)),s&&(d=LO.multiplyOpacity(d,cse)),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=zO.ensureContrastRatio(f,p,this._config.minimumContrastRatio/(c?2:1));if(!m){u.setColor(e,r,null);return}let h=IO.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)+vk*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<c&&(this._tmpCanvas.width=c);let l=Math.min(this._config.deviceCellHeight+vk*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 _k;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 S=u?this._config.fontWeightBold:this._config.fontWeight,C=p?`italic`:``;this._tmpCtx.font=`${C} ${S} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=$O;let ee=s.length===1&&UO(s.charCodeAt(0)),te=s.length===1&&ese(s.charCodeAt(0)),ne=this._getForegroundColor(n,b,y,r,v,_,d,f,u,WO(s.charCodeAt(0)));this._tmpCtx.fillStyle=ne.css;let w=te?0:vk*2,re=!1;this._config.customGlyphs!==!1&&(re=fse(this._tmpCtx,s,w,w,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let T=!ee,ie;if(ie=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())T=!1,this._tmpCtx.strokeStyle=`rgb(${ck.toColorRGB(this._workAttributeData.getUnderlineColor()).join(`,`)})`;else{T=!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=w,r=Math.ceil(w+this._config.deviceCharHeight)-t-(a?e*2:0),i=r+e,o=r+e*2,c=this._workAttributeData.getUnderlineVariantOffset();for(let a=0;a<ie;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(w+this._config.deviceCharHeight-e/2)-t,a=e<=1?r:Math.ceil(w+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=ose(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(),!re&&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*ie,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,w,w+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(w,w+t),this._tmpCtx.lineTo(w+this._config.deviceCharWidth*ie,w+t),this._tmpCtx.stroke()}if(re||this._tmpCtx.fillText(s,w,w+this._config.deviceCharHeight),s===`_`&&!this._config.allowTransparency){let e=Sk(this._tmpCtx.getImageData(w,w,this._config.deviceCellWidth,this._config.deviceCellHeight),x,ne,T);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,w,w+this._config.deviceCharHeight-t),e=Sk(this._tmpCtx.getImageData(w,w,this._config.deviceCellWidth,this._config.deviceCellHeight),x,ne,T),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(w,w+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(w+this._config.deviceCharWidth*ie,w+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let ae=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),oe;if(oe=this._config.allowTransparency?Ase(ae):Sk(ae,x,ne,T),oe)return _k;let E=this._findGlyphBoundingBox(ae,this._workBoundingBox,c,te,re,w),D,O;for(;;){if(this._activePages.length===0){let e=this._createNewPage();D=e,O=e.currentRow,O.height=E.size.y;break}D=this._activePages[this._activePages.length-1],O=D.currentRow;for(let e of this._activePages)E.size.y<=e.currentRow.height&&(D=e,O=e.currentRow);for(let e=this._activePages.length-1;e>=0;e--)for(let t of this._activePages[e].fixedRows)t.height<=O.height&&E.size.y<=t.height&&(D=this._activePages[e],O=t);if(E.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new xk(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),D=this._overflowSizePage,O=this._overflowSizePage.currentRow,O.x+E.size.x>=D.canvas.width&&(O.x=0,O.y+=O.height,O.height=0);break}if(O.y+E.size.y>=D.canvas.height||O.height>E.size.y+2){let t=!1;if(D.currentRow.y+D.currentRow.height+E.size.y>=D.canvas.height){let n;for(let e of this._activePages)if(e.currentRow.y+e.currentRow.height+E.size.y<e.canvas.height){n=e;break}if(n)D=n;else if(e.maxAtlasPages&&this._pages.length>=e.maxAtlasPages&&O.y+E.size.y<=D.canvas.height&&O.height>=E.size.y&&O.x+E.size.x<=D.canvas.width)t=!0;else{let e=this._createNewPage();D=e,O=e.currentRow,O.height=E.size.y,t=!0}}t||(D.currentRow.height>0&&D.fixedRows.push(D.currentRow),O={x:0,y:D.currentRow.y+D.currentRow.height,height:E.size.y},D.fixedRows.push(O),D.currentRow={x:0,y:O.y+O.height,height:0})}if(O.x+E.size.x<=D.canvas.width)break;O===D.currentRow?(O.x=0,O.y+=O.height,O.height=0):D.fixedRows.splice(D.fixedRows.indexOf(O),1)}return E.texturePage=this._pages.indexOf(D),E.texturePosition.x=O.x,E.texturePosition.y=O.y,E.texturePositionClipSpace.x=O.x/D.canvas.width,E.texturePositionClipSpace.y=O.y/D.canvas.height,E.sizeClipSpace.x/=D.canvas.width,E.sizeClipSpace.y/=D.canvas.height,O.height=Math.max(O.height,E.size.y),O.x+=E.size.x,D.ctx.putImageData(ae,E.texturePosition.x-this._workBoundingBox.left,E.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,E.size.x,E.size.y),D.addGlyph(E),D.version++,E}_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)}}}},xk=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=Ck(e,t,t),this.ctx=HO(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 Sk(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 Ase(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}function Ck(e,t,n){let r=e.createElement(`canvas`);return r.width=t,r.height=n,r}function jse(e,t,n,r,i,a,o,s){let c={foreground:a.foreground,background:a.background,cursor:FO,cursorAccent:FO,selectionForeground:FO,selectionBackgroundTransparent:FO,selectionBackgroundOpaque:FO,selectionInactiveBackgroundTransparent:FO,selectionInactiveBackgroundOpaque:FO,overviewRulerBorder:FO,scrollbarSliderBackground:FO,scrollbarSliderHoverBackground:FO,scrollbarSliderActiveBackground:FO,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 wk(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 Mse(e){return(e&50331648)==16777216||(e&50331648)==33554432}var Tk=[];function Ek(e,t,n,r,i,a,o,s,c){let l=jse(r,i,a,o,t,n,s,c);for(let t=0;t<Tk.length;t++){let n=Tk[t],r=n.ownedBy.indexOf(e);if(r>=0){if(wk(n.config,l))return n.atlas;n.ownedBy.length===1?(n.atlas.dispose(),Tk.splice(t,1)):n.ownedBy.splice(r,1);break}}for(let t=0;t<Tk.length;t++){let n=Tk[t];if(wk(n.config,l))return n.ownedBy.push(e),n.atlas}let u=e._core,d={atlas:new bk(document,l,u.unicodeService),config:l,ownedBy:[e]};return Tk.push(d),d.atlas}function Dk(e){for(let t=0;t<Tk.length;t++){let n=Tk[t].ownedBy.indexOf(e);if(n!==-1){Tk[t].ownedBy.length===1?(Tk[t].atlas.dispose(),Tk.splice(t,1)):Tk[t].ownedBy.splice(n,1);break}}}var Ok=600,Nse=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=Ok){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=Ok-(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=Ok-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e)}else this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},Ok)},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 kk(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 SO(()=>r?.disconnect())}function Pse(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var Ak=class e extends ck{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new lk,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?Pse(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()]}},jk=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function Mk(e,t,n){let r=HO(e.createProgram());if(e.attachShader(r,HO(Nk(e,e.VERTEX_SHADER,t))),e.attachShader(r,HO(Nk(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 Nk(e,t,n){let r=HO(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 Fse(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 Ise=class{constructor(e){this.texture=e,this.version=-1}},Lse=`#version 300 es
130
+ layout (location = 0) in vec2 a_unitquad;
131
+ layout (location = 1) in vec2 a_cellpos;
132
+ layout (location = 2) in vec2 a_offset;
133
+ layout (location = 3) in vec2 a_size;
134
+ layout (location = 4) in float a_texpage;
135
+ layout (location = 5) in vec2 a_texcoord;
136
+ layout (location = 6) in vec2 a_texsize;
137
+
138
+ uniform mat4 u_projection;
139
+ uniform vec2 u_resolution;
140
+
141
+ out vec2 v_texcoord;
142
+ flat out int v_texpage;
143
+
144
+ void main() {
145
+ vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);
146
+ gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
147
+ v_texpage = int(a_texpage);
148
+ v_texcoord = a_texcoord + a_unitquad * a_texsize;
149
+ }`;function Rse(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
150
+ precision lowp float;
151
+
152
+ in vec2 v_texcoord;
153
+ flat in int v_texpage;
154
+
155
+ uniform sampler2D u_texture[${e}];
156
+
157
+ out vec4 outColor;
158
+
159
+ void main() {
160
+ if (v_texpage == 0) {
161
+ outColor = texture(u_texture[0], v_texcoord);
162
+ } ${t}
163
+ }`}var Pk=11,Fk=Pk*Float32Array.BYTES_PER_ELEMENT,zse=2,Ik=0,Lk,Rk=0,zk=0,Bse=class extends TO{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;bk.maxAtlasPages===void 0&&(bk.maxAtlasPages=Math.min(32,HO(i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS))),bk.maxTextureSize=HO(i.getParameter(i.MAX_TEXTURE_SIZE))),this._program=HO(Mk(i,Lse,Rse(bk.maxAtlasPages))),this._register(SO(()=>i.deleteProgram(this._program))),this._projectionLocation=HO(i.getUniformLocation(this._program,`u_projection`)),this._resolutionLocation=HO(i.getUniformLocation(this._program,`u_resolution`)),this._textureLocation=HO(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(SO(()=>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(SO(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=HO(i.createBuffer()),this._register(SO(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,2,i.FLOAT,!1,Fk,0),i.vertexAttribDivisor(2,1),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,i.FLOAT,!1,Fk,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(3,1),i.enableVertexAttribArray(4),i.vertexAttribPointer(4,1,i.FLOAT,!1,Fk,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(4,1),i.enableVertexAttribArray(5),i.vertexAttribPointer(5,2,i.FLOAT,!1,Fk,5*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(5,1),i.enableVertexAttribArray(6),i.vertexAttribPointer(6,2,i.FLOAT,!1,Fk,7*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(6,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,Fk,9*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.useProgram(this._program);let l=new Int32Array(bk.maxAtlasPages);for(let e=0;e<bk.maxAtlasPages;e++)l[e]=e;i.uniform1iv(this._textureLocation,l),i.uniformMatrix4fv(this._projectionLocation,!1,jk),this._atlasTextures=[];for(let e=0;e<bk.maxAtlasPages;e++){let t=new Ise(HO(i.createTexture()));this._register(SO(()=>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){Ik=(n*this._terminal.cols+t)*Pk,r===0||r===void 0?e.fill(0,Ik,Ik+Pk-1-zse):this._atlas&&(Lk=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),Rk=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),i!==l&&Lk.offset.x>Rk?(zk=Lk.offset.x-Rk,e[Ik]=-(Lk.offset.x-zk)+this._dimensions.device.char.left,e[Ik+1]=-Lk.offset.y+this._dimensions.device.char.top,e[Ik+2]=(Lk.size.x-zk)/this._dimensions.device.canvas.width,e[Ik+3]=Lk.size.y/this._dimensions.device.canvas.height,e[Ik+4]=Lk.texturePage,e[Ik+5]=Lk.texturePositionClipSpace.x+zk/this._atlas.pages[Lk.texturePage].canvas.width,e[Ik+6]=Lk.texturePositionClipSpace.y,e[Ik+7]=Lk.sizeClipSpace.x-zk/this._atlas.pages[Lk.texturePage].canvas.width,e[Ik+8]=Lk.sizeClipSpace.y):(e[Ik]=-Lk.offset.x+this._dimensions.device.char.left,e[Ik+1]=-Lk.offset.y+this._dimensions.device.char.top,e[Ik+2]=Lk.size.x/this._dimensions.device.canvas.width,e[Ik+3]=Lk.size.y/this._dimensions.device.canvas.height,e[Ik+4]=Lk.texturePage,e[Ik+5]=Lk.texturePositionClipSpace.x,e[Ik+6]=Lk.texturePositionClipSpace.y,e[Ik+7]=Lk.sizeClipSpace.x,e[Ik+8]=Lk.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&ise(r,c,Lk.size.x,this._dimensions.device.cell.width)&&(e[Ik+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let e=this._terminal,t=e.cols*e.rows*Pk;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+=Pk}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*Pk,a=this._vertices.attributes.subarray(i,i+e.lineLengths[t]*Pk);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/Pk)}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}},Vse=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);s>=e.rows||c<0?this.clear():(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 Hse(){return new Vse}var Bk=4,Vk=1,Hk=2,Uk=3,Use=2147483648,Wse=class{constructor(){this.cells=new Uint32Array,this.lineLengths=new Uint32Array,this.selection=Hse()}resize(e,t){let n=e*t*Bk;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)}},Gse=`#version 300 es
164
+ layout (location = 0) in vec2 a_position;
165
+ layout (location = 1) in vec2 a_size;
166
+ layout (location = 2) in vec4 a_color;
167
+ layout (location = 3) in vec2 a_unitquad;
168
+
169
+ uniform mat4 u_projection;
170
+
171
+ out vec4 v_color;
172
+
173
+ void main() {
174
+ vec2 zeroToOne = a_position + (a_unitquad * a_size);
175
+ gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
176
+ v_color = a_color;
177
+ }`,Kse=`#version 300 es
178
+ precision lowp float;
179
+
180
+ in vec4 v_color;
181
+
182
+ out vec4 outColor;
183
+
184
+ void main() {
185
+ outColor = v_color;
186
+ }`,Wk=8,Gk=Wk*Float32Array.BYTES_PER_ELEMENT,qse=20*Wk,Kk=class{constructor(){this.attributes=new Float32Array(qse),this.count=0}},qk=0,Jk=0,Yk=0,Xk=0,Zk=0,Qk=0,$k=0,Jse=class extends TO{constructor(e,t,n,r){super(),this._terminal=e,this._gl=t,this._dimensions=n,this._themeService=r,this._vertices=new Kk,this._verticesCursor=new Kk;let i=this._gl;this._program=HO(Mk(i,Gse,Kse)),this._register(SO(()=>i.deleteProgram(this._program))),this._projectionLocation=HO(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(SO(()=>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(SO(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=HO(i.createBuffer()),this._register(SO(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,Gk,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,Gk,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,Gk,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,jk),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)*Bk,d=e.cells[u+Vk],f=e.cells[u+Hk],p=!!(f&67108864),(d!==s||f!==c&&(l||p))&&((s!==0||l&&c!==0)&&(m=r++*Wk,this._updateRectangle(n,m,c,s,o,a,i)),o=a,s=d,c=f,l=p);(s!==0||l&&c!==0)&&(m=r++*Wk,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++*Wk,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++*Wk,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++*Wk,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++*Wk,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:qk=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:qk=(n&16777215)<<8;break;default:qk=this._themeService.colors.foreground.rgba}else switch(r&50331648){case 16777216:case 33554432:qk=this._themeService.colors.ansi[r&255].rgba;break;case 50331648:qk=(r&16777215)<<8;break;default:qk=this._themeService.colors.background.rgba}e.attributes.length<t+4&&(e.attributes=Fse(e.attributes,this._terminal.rows*this._terminal.cols*Wk)),Jk=i*this._dimensions.device.cell.width,Yk=o*this._dimensions.device.cell.height,Xk=(qk>>24&255)/255,Zk=(qk>>16&255)/255,Qk=(qk>>8&255)/255,$k=1,this._addRectangle(e.attributes,t,Jk,Yk,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,Xk,Zk,Qk,$k)}_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])}},Yse=class extends TO{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(SO(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=HO(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=Ek(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=$O,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}`}},Xse=class extends Yse{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&&Mse(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()}},eA=typeof window==`object`?window:globalThis,tA=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new gk,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new gk,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}};tA.INSTANCE=new tA;var nA=tA;function Zse(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}nA.INSTANCE.onDidChangeZoomLevel,nA.INSTANCE.onDidChangeFullscreen;var rA=typeof navigator==`object`?navigator.userAgent:``;rA.indexOf(`Firefox`);var iA=rA.indexOf(`AppleWebKit`)>=0;!(rA.indexOf(`Chrome`)>=0)&&rA.indexOf(`Safari`),rA.indexOf(`Electron/`),rA.indexOf(`Android`);var aA=!1;if(typeof eA.matchMedia==`function`){let e=eA.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=eA.matchMedia(`(display-mode: fullscreen)`);aA=e.matches,Zse(eA,e,({matches:e})=>{aA&&t.matches||(aA=e)})}function Qse(){return aA}var oA=`en`,sA=!1,cA=!1,lA=!1,uA=oA,dA,fA=globalThis,pA;typeof fA.vscode<`u`&&typeof fA.vscode.process<`u`?pA=fA.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(pA=process);var $se=typeof pA?.versions?.electron==`string`&&pA?.type===`renderer`;if(typeof pA==`object`){pA.platform,pA.platform,sA=pA.platform===`linux`,sA&&pA.env.SNAP&&pA.env.SNAP_REVISION,pA.env.CI||pA.env.BUILD_ARTIFACTSTAGINGDIRECTORY,uA=oA;let e=pA.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,uA=t.resolvedLanguage||oA,t.languagePack?.translationsConfigFile}catch{}cA=!0}else typeof navigator==`object`&&!$se?(dA=navigator.userAgent,dA.indexOf(`Windows`),dA.indexOf(`Macintosh`),(dA.indexOf(`Macintosh`)>=0||dA.indexOf(`iPad`)>=0||dA.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,sA=dA.indexOf(`Linux`)>=0,dA?.indexOf(`Mobi`),lA=!0,uA=globalThis._VSCODE_NLS_LANGUAGE||oA,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var mA=cA;lA&&typeof fA.importScripts==`function`&&fA.origin;var hA=dA,gA=uA,ece;(e=>{function t(){return gA}e.value=t;function n(){return gA.length===2?gA===`en`:gA.length>=3&&gA[0]===`e`&&gA[1]===`n`&&gA[2]===`-`}e.isDefaultVariant=n;function r(){return gA===`en`}e.isDefault=r})(ece||={});var tce=typeof fA.postMessage==`function`&&!fA.importScripts;(()=>{if(tce){let e=[];fA.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}),fA.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var nce=!!(hA&&hA.indexOf(`Chrome`)>=0);hA&&hA.indexOf(`Firefox`),!nce&&hA&&hA.indexOf(`Safari`),hA&&hA.indexOf(`Edg/`),hA&&hA.indexOf(`Android`);var _A=typeof navigator==`object`?navigator:{};mA||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||_A&&_A.clipboard&&_A.clipboard.writeText,mA||_A&&_A.clipboard&&_A.clipboard.readText,mA||Qse()||_A.keyboard,`ontouchstart`in eA||_A.maxTouchPoints,eA.PointerEvent&&(`ontouchstart`in eA||navigator.maxTouchPoints);var vA=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}},yA=new vA,bA=new vA,xA=new vA;Array(230);var rce;(e=>{function t(e){return yA.keyCodeToStr(e)}e.toString=t;function n(e){return yA.strToKeyCode(e)}e.fromString=n;function r(e){return bA.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return xA.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return bA.strToKeyCode(e)||xA.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 yA.keyCodeToStr(e)}e.toElectronAccelerator=o})(rce||={});var SA=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),ice;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof ace?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:dk.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:SA})})(ice||={});var ace=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?SA:(this._emitter||=new gk,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var oce;(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})(oce||={});var CA=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 gk,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 dk.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())}};CA.EMPTY=CA.fromArray([]);function sce(e){return wA(e,0)}function wA(e,t){switch(typeof e){case`object`:return e===null?TA(349,t):Array.isArray(e)?lce(e,t):uce(e,t);case`string`:return EA(e,t);case`boolean`:return cce(e,t);case`number`:return TA(e,t);case`undefined`:return TA(937,t);default:return TA(617,t)}}function TA(e,t){return(t<<5)-t+e|0}function cce(e,t){return TA(e?433:863,t)}function EA(e,t){t=TA(149417,t);for(let n=0,r=e.length;n<r;n++)t=TA(e.charCodeAt(n),t);return t}function lce(e,t){return t=TA(104579,t),e.reduce((e,t)=>wA(t,e),t)}function uce(e,t){return t=TA(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=EA(n,t),wA(e[n],t)),t)}var{registerWindow:dce,getWindow:fce,getDocument:pce,getWindows:mce,getWindowsCount:hce,getWindowId:gce,getWindowById:_ce,hasWindow:vce,onDidRegisterWindow:yce,onWillUnregisterWindow:bce,onDidUnregisterWindow:xce}=function(){let e=new Map,t={window:eA,disposables:new wO};e.set(eA.vscodeWindowId,t);let n=new gk,r=new gk,i=new gk;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 TO.None;let a=new wO,o={window:t,disposables:a.add(new wO)};return e.set(t.vscodeWindowId,o),a.add(SO(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(DA(t,Cce.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:eA},getDocument(e){return fce(e).document}}}(),Sce=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 DA(e,t,n,r){return new Sce(e,t,n,r)}var OA=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}};OA.None=new OA(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=sce(n),a=r.get(i);if(a)a.users+=1;else{let o=new gk,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(SO(()=>{--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 Cce={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:iA?`webkitAnimationStart`:`animationstart`,ANIMATION_END:iA?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:iA?`webkitAnimationIteration`:`animationiteration`},wce=class extends TO{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 EO,this._charAtlasDisposable=this._register(new EO),this._observerDisposable=this._register(new EO),this._model=new Wse,this._workCell=new Ak,this._workCell2=new Ak,this._rectangleRenderer=this._register(new EO),this._glyphRenderer=this._register(new EO),this._onChangeTextureAtlas=this._register(new gk),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new gk),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new gk),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new gk),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new gk),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 sse(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new Xse(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=ase(),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(DA(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(DA(this._canvas,`webglcontextrestored`,e=>{console.warn(`webglcontextrestored event received`),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,Dk(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=kk(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=kk(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(SO(()=>{for(let e of this._renderLayers)e.dispose();this._canvas.parentElement?.removeChild(this._canvas),Dk(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 Jse(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new Bse(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=Ek(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=xO(dk.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),dk.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 Nse(()=>{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=kA(e,n.rows-1,0),t=kA(t,n.rows-1,0);let x=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??`block`,S=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,C=S-n.buffer.ydisp,ee=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),te=-1,ne=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let w=!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=S===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||ee<p[0]||ee>=p[1],d?(l=!0,r=new Tce(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)*Bk,this._cellColorResolver.resolve(r,y,o,this.dimensions.device.cell.width),ne&&o===S&&(y===ee&&(this._model.cursor={x:ee,y:C,width:r.getWidth(),style:this._coreBrowserService.isFocused?x:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},te=ee+r.getWidth()-1),y>=ee&&y<=te&&(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+Vk]!==this._cellColorResolver.result.bg||this._model.cells[v+Hk]!==this._cellColorResolver.result.fg||this._model.cells[v+Uk]!==this._cellColorResolver.result.ext)&&(w=!0,h.length>1&&(g|=Use),this._model.cells[v]=g,this._model.cells[v+Vk]=this._cellColorResolver.result.bg,this._model.cells[v+Hk]=this._cellColorResolver.result.fg,this._model.cells[v+Uk]=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)*Bk,this._glyphRenderer.value.updateCell(y,a,0,0,0,0,Qoe,0,0),this._model.cells[b]=0,this._model.cells[b+Vk]=this._cellColorResolver.result.bg,this._model.cells[b+Hk]=this._cellColorResolver.result.fg,this._model.cells[b+Uk]=this._cellColorResolver.result.ext;y--}}w&&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})}},Tce=class extends ck{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 kA(e,t,n=0){return Math.max(Math.min(e,t),n)}var AA=`di$target`,jA=`di$dependencies`,MA=new Map;function NA(e){if(MA.has(e))return MA.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Ece(t,e,r)};return t._id=e,MA.set(e,t),t}function Ece(e,t,n){t[AA]===t?t[jA].push({id:e,index:n}):(t[jA]=[{id:e,index:n}],t[AA]=t)}NA(`BufferService`),NA(`CoreMouseService`),NA(`CoreService`),NA(`CharsetService`),NA(`InstantiationService`),NA(`LogService`);var Dce=NA(`OptionsService`);NA(`OscLinkService`),NA(`UnicodeService`),NA(`DecorationService`);var Oce={trace:0,debug:1,info:2,warn:3,error:4,off:5},kce=`xterm.js: `,PA=class extends TO{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),Ace=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Oce[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?``:kce)+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)}};PA=iO([aO(0,Dce)],PA);var Ace,jce=class extends TO{constructor(e){if(AO&&Zoe()<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 gk),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new gk),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new gk),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new gk),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 wce(e,o,s,c,n,l,r,u,this._preserveDrawingBuffer)),this._register(dk.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(dk.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(dk.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(dk.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(SO(()=>{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 Mce(e){return e.needsReload?!0:e.wasAttachedWithoutLayout&&e.hasLayoutNow}function Nce(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 Pce=window.matchMedia?.(`(pointer: coarse)`).matches?4:12,FA=new Map;function IA(e){return e.clientWidth>0&&e.clientHeight>0}function LA(e){let t=e.webglAddon;if(!t)return;let n=[...e.term?.element?.querySelectorAll(`canvas`)??[]];e.webglAddon=null;try{t.dispose()}catch{}for(let e of n)e.getContext(`webgl2`)?.getExtension(`WEBGL_lose_context`)?.loseContext()}function RA(e){FA.delete(e),e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,LA(e)}function Fce(e){let t=[e],n=pe.snapshot().borrowedCardId,r=n?E.get(n):void 0;r&&t.push(r);for(let e of Nce([...FA.keys()],Pce,t))RA(e),e.needsWebGLReload=!0}function zA(e){e?.term&&Mce({needsReload:e.needsWebGLReload,wasAttachedWithoutLayout:e.webglAttachedWithoutLayout,hasLayoutNow:IA(e.termWrap)})&&VA(e,{isForced:!0})}function BA(){for(let e of FA.keys()){let t=e.term;if(e.webglAddon&&t)try{t.clearTextureAtlas(),t.refresh(0,t.rows-1)}catch{RA(e),e.needsWebGLReload=!0}}}function VA(e,t={}){try{if(e.webglAddon&&!e.needsWebGLReload&&!t.isForced){FA.delete(e),FA.set(e,!0);return}e.webglAddon&&(LA(e),FA.delete(e)),Fce(e);let n=new jce;n.onContextLoss(()=>{n.dispose(),e.webglAddon=null,FA.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=!IA(e.termWrap),FA.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,FA.delete(e)}}var Ice=1024,Lce=250,Rce=`(max-width: 768px)`,zce=12,Bce=14,Vce=5e4,HA=!1;function Hce(e){HA=e}var UA=!1;window.addEventListener(`blur`,()=>{UA=!0}),window.addEventListener(`focus`,()=>{UA=!1});function WA(e){let t=document.activeElement;return wE({isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),hasFocusInsideCard:t instanceof Node&&e.contains(t),hasWindowBlurredSinceFocus:UA,isPhoneLayout:fT()})}function GA(e,t){return TE({isDocumentVisible:document.visibilityState===`visible`,isBorrowedCard:pe.snapshot().borrowedCardId===t,isTerminalFaceShown:e.face===`terminal`})}var KA=new WeakMap,qA=new WeakSet;function Uce(e,t,n){let r=e.term;r&&EE({viewportTopLine:n,scrollbackLineCount:r.buffer.active.baseY,isDeepHistoryLoadedOrPending:qA.has(e)})&&(qA.add(e),KA.set(e,r.buffer.active.length-n),aj(t))}function JA(e,t){e._hasMissedOutputWhileHidden&&(GA(e,t)||(e._hasMissedOutputWhileHidden=!1,aj(t)))}document.addEventListener(`visibilitychange`,()=>{if(document.visibilityState!==`visible`)return;let e=pe.snapshot().borrowedCardId;if(!e)return;let t=E.get(e);t&&JA(t,e)});function Wce(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 YA(e,t){let n=(t instanceof Error?t.message:``)||String(t);console.error(`[clipboard:${e}]`,t),Hg(`Clipboard ${e} failed: ${n}`)}function XA(e,t){return E.get(e)===t&&!t.dataWs}function ZA(e){return e.querySelector(`:scope > .terminal-connecting`)}function Gce(e){if(ZA(e))return;let t=m(`div`,`terminal-connecting`);t.append(m(`span`,`terminal-connecting-label`,`Connecting`)),e.append(t)}function Kce(e){let t=ZA(e);if(!t)return;t.querySelector(`:scope > .terminal-connecting-animal`)?.remove();let n=vm();n&&t.prepend(_m(n,`terminal-connecting-animal`))}var QA=new Set;function qce(e){return QA.add(e),()=>QA.delete(e)}function Jce(){let e=0;for(let t of E.values())t.card.dataset.link===`connecting`&&e++;return e}function $A(e){let t=RD({hasTerminal:e.term!==null,isSocketOpen:e.dataWs?.readyState===WebSocket.OPEN,isInputHeld:rj});if(t===`none`){delete e.card.dataset.link,ej();return}let n=t===`connecting`&&e.card.dataset.link!==`connecting`;e.card.dataset.link=t,n&&Kce(e.termWrap),ej()}function ej(){for(let e of QA)e()}function tj(e,t,n,r){HT.unregister(e),t.dataWs=null,$A(t),t._resetGridClaim?.(),setTimeout(()=>{XA(e,t)&&Pm().catch(()=>{}).then(()=>{XA(e,t)&&nj(e,t,n)})},r)}function nj(e,t,n){let r=KA.get(t);KA.delete(t);let i=r!==void 0,a=!1,o=jm(location,Im(DE(e,i))),s=new WebSocket(o);s.binaryType=`arraybuffer`,t.dataWs=s,$A(t);let c=!1,l={hasSeenSize:!1,lastSeq:0};HT.register(e,(e,t)=>n.write(e,t)),s.addEventListener(`message`,o=>{if(t.dataWs!==s)return;let c=NE(o.data,l);if(c.kind===`bytes`){Ire(t);let i=a;if(a=!1,GA(t,e)){t._hasMissedOutputWhileHidden=!0;return}if(HT.enqueue(e,c.data),!i)return;let o=r??0;HT.enqueueAction(e,()=>{n.scrollToLine(Math.max(0,n.buffer.active.length-o))});return}if(c.kind===`attach-size`){t._hasMissedOutputWhileHidden=!1,a=i,i||qA.delete(t),l.hasSeenSize=!0,l.lastSeq=c.seq,n.reset(),LD(n),t.ptySize={cols:c.cols,rows:c.rows},t._syncGrid?.();return}if(c.kind!==`size`)return;l.lastSeq=c.seq;let u={cols:c.cols,rows:c.rows};HT.enqueueAction(e,()=>{t.ptySize=u,t._syncGrid?.()})}),s.addEventListener(`close`,()=>{if(t.dataWs!==s)return;c||Fm();let r=wm(t._dataWsRetryAttempt||0);t._dataWsRetryAttempt=(t._dataWsRetryAttempt||0)+1,tj(e,t,n,r)}),s.addEventListener(`open`,()=>{c=!0,t._dataWsRetryAttempt=0,$A(t),t._syncGrid?.({isActivationEdge:!0}),t._retryOwedGridClaim?.(),t._inputQueue?.length&&setTimeout(()=>{t.dataWs===s&&ij(t)},50)})}var rj=!1;function ij(e){let t=e._inputQueue,n=e.dataWs;if(!rj&&t?.length&&n?.readyState===WebSocket.OPEN){for(let e of t)n.send(JSON.stringify({type:`input`,data:e}));t.length=0}}function Yce(){rj=!0;for(let e of E.values())$A(e)}function Xce(){rj=!1;for(let e of E.values())$A(e),ij(e)}function aj(e){let t=k(e);if(typeof e!=`string`||!t?.term)return;let n=t.dataWs;t._dataWsRetryAttempt=0,tj(e,t,t.term,0),n?.close()}function oj(e,t,n){return!e||t==null||t===``?!1:(n?.fromSoftKeyboard||e._resetSoftKeyboardBuffer?.(),!rj&&!e._inputQueue?.length&&e.dataWs?.readyState===WebSocket.OPEN?(e.dataWs.send(JSON.stringify({type:`input`,data:t})),!0):e._inputQueue&&e._inputQueue.length<Ice?(e._inputQueue.push(t),!0):!1)}function sj(e,t){let n=window.matchMedia?.(Rce).matches?zce:Bce,r=new qw({cursorBlink:HA,fontSize:n,fontFamily:nT(),theme:fE(),scrollback:Vce,allowProposedApi:!0,linkHandler:XE()}),i=new Bae;r.loadAddon(i),Gce(e),r.open(e),QE(r),ID(r,t.abortController.signal),t.term=r,t.fitAddon=i,RA(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(!s||!WA(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=CE({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)},Lce)}function m(){l&&o===null&&f(l)}function h({isActivationEdge:e=!1}={}){let n=t.term;if(!n)return;let r=AE({authoritative:t.ptySize??null,applied:{cols:n.cols,rows:n.rows},proposal:d(),isActiveViewer:s,isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:c});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`}))):r.owedClaim&&(e&&f(r.owedClaim)||p(r.owedClaim))}function g(){let e=OE({authoritative:t.ptySize??null,isActiveViewer:s,isDocumentEngaged:WA(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(),l=kE({isActiveViewer:s,lastClaim:c,owedClaim:l}),c=null},t._retryOwedGridClaim=m,t._syncGridOnEngagementEdge=g,t._isActiveViewer=()=>s,t._setActiveViewer=e=>{s!==e&&(s=e,u(),l=null,e&&zA(t),h({isActivationEdge:!0}))},t.card.addEventListener(`focusin`,()=>{UA=!1,g()},{signal:t.abortController.signal}),VA(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=Wce(n)}catch(e){return YA(`osc52 decode`,e),!0}if(!(document.hasFocus()&&navigator.userActivation?.isActive!==!1))return!0;let i=ie(r);return i&&i.catch(e=>{YA(`osc52 write`,e)}),!0}),r.attachCustomKeyEventHandler(e=>{if(e.type!==`keydown`)return!0;if(document.body.dataset.activeView===`focus`&&ET(e,NT))return!1;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`c`&&r.hasSelection()){let e=r.getSelection();r.clearSelection();let t=ie(e);return t&&t.catch(e=>{YA(`copy`,e)}),!1}return n&&e.key===`v`?!1:n&&e.key===`Backspace`?(oj(t,`\x1B`),!1):!0}),Zce(e,r,t),tO(e,r)}function Zce(e,t,n){let r=t.textarea;if(!r)return;let i=``,a=()=>{i=r.value},o=()=>{i=``,fT()&&r.value!==``&&(r.value=``)};n._resetSoftKeyboardBuffer=o;let s=()=>{let e=HE(i,r.value);return i=r.value,e!==``&&(oj(n,e,{fromSoftKeyboard:!0}),t.scrollToBottom(),!0)},c=(t,n)=>{e.addEventListener(t,e=>{fT()?n(e):a()},!0)};c(`keydown`,e=>{VE(e)?e.stopPropagation():(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(!BE(e.inputType)){queueMicrotask(o);return}if(e.stopPropagation(),s())return;let r=RE(e.inputType);r!==``&&(oj(n,r,{fromSoftKeyboard:!0}),t.scrollToBottom())})}function cj(e,t){e._inputQueue=[];let n=e.term;n&&(n.onData(t=>{oj(e,t)}),n.onScroll(n=>{Uce(e,t,n)}),Qce(e.termWrap,t,e.abortController.signal),nj(t,e,n))}function lj(e){return!!e&&Array.from(e.types).includes(`Files`)}function Qce(e,t,n){e.addEventListener(`paste`,e=>{let n=e.clipboardData;n&&n.files.length!==0&&n.getData(`text/plain`)===``&&(e.preventDefault(),e.stopPropagation(),BD(t,Array.from(n.files)))},{capture:!0,signal:n}),e.addEventListener(`dragover`,e=>{lj(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},{signal:n}),e.addEventListener(`drop`,e=>{lj(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),BD(t,Array.from(e.dataTransfer.files)))},{capture:!0,signal:n})}function uj(e,t){e.term||(sj(e.termWrap,e),cj(e,t))}function dj(e){e?._syncGridOnEngagementEdge?.()}function fj(e,t){if(!e)return;uj(e,t),JA(e,t),zA(e);let n=e.term;n&&(n.refresh(0,n.rows-1),dj(e))}function pj(e,t,n){e&&(n&&uj(e,t),e._setActiveViewer?.(n))}var $ce=`conversation:`,ele=1e4,tle=48,nle=`, `,rle={command:`Run command?`,fileChange:`Apply file changes?`,permissions:`Grant permissions?`},ile=1;function ale(e){return e.conversationApproval!==null||$_(e.currentState,e.pendingPromptKind)}function mj(e,t,n,r,i=0){let a=n[i];a?setTimeout(()=>{k(e)===t?i>0&&ale(t)?r(`stopped-by-prompt`):oj(t,a.data)?mj(e,t,n,r,i+1):r(`unreachable`):r(`unreachable`)},a.delayBeforeMs):r(`sent`)}function ole({signal:e,sendControl:t,showTerminal:n}){let r=m(`div`,`conversation-face`);r.hidden=!0;let i=m(`div`,`conversation-log`);i.setAttribute(`role`,`log`),i.setAttribute(`aria-live`,`polite`);let o=m(`p`,`conversation-empty`,`No conversation yet. Messages appear here as the agent works.`),s=m(`div`,`conversation-approval`);s.hidden=!0;let c=m(`p`,`conversation-bridge-note`,`Restart this Codex session to connect it to the conversation view. Until then, use the terminal.`);c.hidden=!0;let l=m(`p`,`conversation-bridge-note`,`The session trace is unavailable, so there is nothing to show here. Use the terminal.`);l.hidden=!0;let u=m(`form`,`conversation-composer`),d=m(`textarea`,`conversation-input`);d.rows=2,d.placeholder=`Message the agent`,d.setAttribute(`aria-label`,`Message the agent`);let f=m(`div`,`conversation-composer-actions`),p=m(`span`,`conversation-status`);p.setAttribute(`role`,`status`);let h=m(`button`,`conversation-stop`,`Stop`);h.type=`button`,h.title=`Interrupt the current turn (Esc)`;let g=m(`button`,`conversation-terminal`,`Terminal`);g.type=`button`;let _=m(`button`,`conversation-send`,`Send`);_.type=`submit`,f.append(p,g,h,_),u.append(d,f),r.append(i,l,c,s,u);let v=null,y=[],b=0,x=!1,S=null,C=!1;function ee(){return v?k(v)??null:null}function te(e){p.textContent=e}function ne(){S&&clearTimeout(S.timeoutHandle),S=null}function w(){if(!v||r.hidden||!l.hidden)return;if(S){C=!0;return}let e=`${$ce}${ile++}`,n=x?b:null;t(n===null?{type:`session-trace`,id:v,requestId:e,endingAt:`tail`}:{type:`session-trace`,id:v,requestId:e,after:n})?(C=!1,S={requestId:e,after:n,timeoutHandle:setTimeout(()=>{S=null,w()},ele)}):te(`Conversation unavailable while disconnected.`)}function re(){return i.scrollHeight-i.scrollTop-i.clientHeight<=tle}function T(e){let t=m(`article`,`conversation-message conversation-${e.kind}`);return e.kind===`assistant`?(t.append(Rg(Fg(e.text))),t):(t.append(m(`p`,`conversation-text`,e.text)),t)}function ie(e){let t=m(`p`,`conversation-work`,Iae(e));return av(e)&&t.classList.add(`is-running`),e.errorCount>0&&t.classList.add(`has-error`),t}function ae(){let e=re(),t=iv(y).map(e=>e.kind===`work`?ie(e):T(e));i.replaceChildren(...t.length>0?t:[o]),e&&(i.scrollTop=i.scrollHeight)}function oe(e,t){let n=ee();if(!n||!v||!e){te(`Unable to reach this session.`);return}let r={sent:t,unreachable:`Unable to reach this session.`,"stopped-by-prompt":`Not sent: a prompt appeared, so the message was typed but not submitted. Check the terminal.`};mj(v,n,e,e=>te(r[e]))}function E(e,n,r){v&&te(t({type:`conversation-approval`,id:v,requestId:e.requestId,decision:n,...r?{answers:r}:{}})?`Answer sent.`:`Unable to send the answer while disconnected.`)}function D(e,t){let n=m(`button`,`conversation-approval-action`,e);return n.type=`button`,n.addEventListener(`click`,t),n}function O(e){return e.kind===`tool`?`Allow ${e.toolName??`this tool`}?`:rle[e.kind]??`Approve this request?`}function se(e){s.append(m(`p`,`conversation-approval-note`,`This request cannot be shown in full here. Read and answer it in the terminal.`));let t=m(`div`,`conversation-approval-actions`);t.append(D(`Open terminal`,()=>n()),D(`Decline`,()=>E(e,`decline`))),s.append(t)}function ce(e){if(s.append(m(`p`,`conversation-approval-title`,O(e)),m(`pre`,`conversation-approval-summary`,e.summary)),e.isSummaryTruncated){se(e);return}let t=m(`div`,`conversation-approval-actions`);t.append(D(`Approve`,()=>E(e,`accept`))),e.kind!==`tool`&&t.append(D(`Approve for session`,()=>E(e,`acceptForSession`))),e.alwaysAllowSummary&&(s.append(m(`p`,`conversation-approval-note`,`Always allow adds, for this session only: ${e.alwaysAllowSummary}`)),t.append(D(`Always allow`,()=>E(e,`acceptForSession`)))),t.append(D(`Decline`,()=>E(e,`decline`))),s.append(t)}function le(e){let t=m(`p`,`conversation-approval-title`,e.question);return e.header&&t.prepend(m(`span`,`conversation-question-header`,e.header)),t}function ue(e,t){s.append(le(t));let n=m(`div`,`conversation-question-options`);for(let r of t.options){let i=D(r.label,()=>E(e,`accept`,{[t.question]:r.label}));r.description&&(i.title=r.description),n.append(i)}let r=m(`div`,`conversation-approval-actions`);r.append(D(`Decline`,()=>E(e,`decline`))),s.append(n,r)}function de(e,t){let n=m(`form`,`conversation-question-form`);t.forEach((e,t)=>{let r=m(`fieldset`,`conversation-question`),i=m(`legend`,`conversation-question-text`,e.question);e.header&&i.prepend(m(`span`,`conversation-question-header`,e.header)),r.append(i);for(let n of e.options){let i=m(`label`,`conversation-question-option`),a=m(`input`);a.type=e.multiSelect?`checkbox`:`radio`,a.name=`question-${t}`,a.value=n.label,i.append(a,m(`span`,``,n.label)),n.description&&(i.title=n.description),r.append(i)}n.append(r)});let r=m(`div`,`conversation-approval-actions`),i=m(`button`,`conversation-approval-action`,`Send answers`);i.type=`submit`,r.append(i,D(`Decline`,()=>E(e,`decline`))),n.append(r),n.addEventListener(`submit`,r=>{r.preventDefault();let i={};t.forEach((e,t)=>{let r=[...n.querySelectorAll(`input[name="question-${t}"]:checked`)].map(e=>e.value);r.length>0&&(i[e.question]=r.join(nle))}),Object.keys(i).length===t.length?E(e,`accept`,i):te(`Answer every question first.`)}),s.append(n)}function fe(e){let t=e.questions??[];if(e.isSummaryTruncated||t.length===0){s.append(m(`p`,`conversation-approval-title`,`Claude Code has a question`),m(`pre`,`conversation-approval-summary`,e.summary)),se(e);return}let[n]=t;t.length===1&&!n.multiSelect?ue(e,n):de(e,t)}function pe(e){e.kind===`question`?fe(e):ce(e)}function me(){s.append(m(`p`,`conversation-approval-title`,`The agent is waiting on a prompt`)),s.append(m(`p`,`conversation-approval-note`,`Read and answer it in the terminal.`));let e=m(`div`,`conversation-approval-actions`);e.append(D(`Open terminal`,()=>n())),s.append(e)}function he(){let e=ee();s.replaceChildren();let t=e?.conversationApproval??null,n=e?$_(e.currentState,e.pendingPromptKind):!1,r=e?.agent===`codex`&&!e.hasConversationBridge;c.hidden=!r,s.hidden=!t&&!n,_.disabled=!s.hidden||r,e&&(t?pe(t):n&&me())}function ge(){let e=ee();h.disabled=e?.currentState!==a.RUNNING}u.addEventListener(`submit`,e=>{if(e.preventDefault(),_.disabled)return;let t=Z_(ee()?.agent,d.value);t&&(d.value=``,oe(t,`Sent.`))},{signal:e}),d.addEventListener(`keydown`,e=>{e.key!==`Enter`||e.shiftKey||e.isComposing||(e.preventDefault(),u.requestSubmit())},{signal:e}),h.addEventListener(`click`,()=>oe(Q_(ee()?.agent),`Interrupt sent.`),{signal:e}),g.addEventListener(`click`,()=>n(),{signal:e});function _e(e){v!==e&&(v=e,y=[],b=0,x=!1,ne(),te(``)),r.hidden=!1,l.hidden=!0,ae(),ye(),w()}function ve(){r.hidden=!0,ne()}function ye(){r.hidden||(he(),ge())}function be(e){if(!S||e.requestId!==S.requestId)return!1;let t=S;if(ne(),e.id!==v)return!0;let n=t.after!==null&&e.start===t.after&&!e.reset;return t.after!==null&&!n?(x=!1,y=[],w(),!0):(y=Lae(t.after===null?[...e.records]:[...y,...e.records]),b=e.next,x=!0,ae(),C&&w(),!0)}function xe(e){return!S||e.requestId!==S.requestId?!1:(ne(),C=!1,l.hidden=!1,!0)}function Se(e){e!==v||r.hidden||(l.hidden=!0,w())}return{el:r,show:_e,hide:ve,refresh:ye,applyTraceResponse:be,applyTraceError:xe,applyTraceChanged:Se}}function hj(e){return String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function gj(e){if(!e)return 0;let t=0;return e.listenerMismatch&&t++,e.orphanPty&&t++,e.destroyedReachable&&t++,t}function sle(e,t){return e||gj(t)>0}var cle={DORMANT:`DOR`,INITIALIZING:`INI`,STARTING:`STA`,RUNNING:`RUN`,WAITING:`WAI`,IDLE:`IDL`,COMPLETE:`CMP`,DONE:`DON`,FAILED:`FAI`},_j=null,vj=!1,yj=!1,bj=null,xj=null,Sj=null,Cj=`—`;function wj(e){return e==null?Cj:Th(e,`GB`)}function Tj(e){return e==null?Cj:Ch(e,{smallestUnit:`s`,dropsZeroRemainder:!1})}function lle(e){return e==null?Cj:`${Tj(Math.max(0,Math.round((Date.now()-e)/1e3)))} ago`}function ule(){let e=m(`div`,`health-footer`);e.dataset.expanded=`false`,e.hidden=!0;let t=m(`button`,`health-summary`);t.type=`button`,t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,`health-detail`);let n=m(`div`,`health-detail`);return n.id=`health-detail`,n.hidden=!0,t.addEventListener(`click`,()=>{yj=!yj,e.dataset.expanded=String(yj),t.setAttribute(`aria-expanded`,String(yj)),n.hidden=!yj,yj&&(G({type:`request-health-snapshot`}),Dj())}),e.append(t,n),bj=e,xj=t,Sj=n,e}function Ej(){if(!xj||!_j)return;let e=_j,t=gj(e.anomalies);xj.innerHTML=`
187
+ <span class="health-chev" aria-hidden="true">${yj?`▼`:`▲`}</span>
188
+ <span class="health-stat" title="V8 heap used"><span class="health-stat-label">Heap</span> ${wj(e.process.heapUsed)}</span>
189
+ <span class="health-stat" title="Resident set size (process memory)"><span class="health-stat-label">RSS</span> ${wj(e.process.rss)}</span>
190
+ <span class="health-stat" title="External buffers (PTY data lives here)"><span class="health-stat-label">Ext</span> ${wj(e.process.external)}</span>
191
+ <span class="health-stat" title="Active resources (handles + requests)"><span class="health-stat-label">Hdl</span> ${e.process.activeResources}</span>
192
+ <span class="health-stat" title="Memory headroom at the last start check, and starts held for memory"><span class="health-stat-label">Mem</span> ${wj(e.memoryGate?.headroomBytes)} / ${e.memoryGate?.heldStartCount??0} held</span>
193
+ <span class="health-stat" title="Sessions: alivePty / total"><span class="health-stat-label">Sess</span> ${e.sessions.alivePty}/${e.sessions.total}</span>
194
+ <span class="health-stat" title="WebSockets: control + data"><span class="health-stat-label">WS</span> ${e.websockets.control}+${e.websockets.data}</span>
195
+ <span class="health-stat" title="Server uptime"><span class="health-stat-label">Up</span> ${Tj(e.uptimeSeconds)}</span>
196
+ ${t>0?`<span class="health-anomaly" title="${t} anomaly type(s), expand for details">⚠ ${t}</span>`:``}
197
+ `}function Dj(){if(!Sj||!_j)return;let e=_j,t=e.process,n=e.websockets,r=e.sessions,i=e.anomalies,a=``;if(gj(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=`
198
+ <div class="health-section health-section-warn">
199
+ <div class="health-section-title">⚠ Anomalies</div>
200
+ ${e.map(e=>`<div class="health-row">${e}</div>`).join(``)}
201
+ </div>
202
+ `}let o=r.list.map(e=>{let t=[];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`
203
+ <tr>
204
+ <td>${hj(e.name)}</td>
205
+ <td class="health-mono">${cle[e.state]||e.state}</td>
206
+ <td class="health-mono">${e.hasPty?e.ptyPid:Cj}</td>
207
+ <td class="health-mono">${wj(e.outputBufferBytes)}</td>
208
+ <td class="health-mono">${e.outputBufferEntries}</td>
209
+ <td class="health-mono">${e.dataListenerCount}</td>
210
+ <td class="health-mono health-dim">${n}</td>
211
+ <td class="health-mono health-dim">${t.join(` `)||``}</td>
212
+ </tr>
213
+ `}).join(``);Sj.innerHTML=`
214
+ ${a}
215
+ <div class="health-section">
216
+ <div class="health-section-title">Process</div>
217
+ <div class="health-grid">
218
+ <div class="health-row"><span class="health-label">Heap used</span><span class="health-mono">${wj(t.heapUsed)}</span></div>
219
+ <div class="health-row"><span class="health-label">Heap total</span><span class="health-mono">${wj(t.heapTotal)}</span></div>
220
+ <div class="health-row"><span class="health-label">RSS</span><span class="health-mono">${wj(t.rss)}</span></div>
221
+ <div class="health-row"><span class="health-label">External</span><span class="health-mono">${wj(t.external)}</span></div>
222
+ <div class="health-row"><span class="health-label">Array buffers</span><span class="health-mono">${wj(t.arrayBuffers)}</span></div>
223
+ <div class="health-row"><span class="health-label">Active resources</span><span class="health-mono">${t.activeResources}</span></div>
224
+ <div class="health-row"><span class="health-label">Uptime</span><span class="health-mono">${Tj(e.uptimeSeconds)}</span></div>
225
+ </div>
226
+ </div>
227
+
228
+ <div class="health-section">
229
+ <div class="health-section-title">Memory gate</div>
230
+ <div class="health-grid">
231
+ <div class="health-row"><span class="health-label">Headroom</span><span class="health-mono">${wj(e.memoryGate?.headroomBytes)}</span></div>
232
+ <div class="health-row"><span class="health-label">Read</span><span class="health-mono">${lle(e.memoryGate?.headroomReadAtMs)}</span></div>
233
+ <div class="health-row"><span class="health-label">Starts held</span><span class="health-mono">${e.memoryGate?.heldStartCount??0}</span></div>
234
+ </div>
235
+ </div>
236
+
237
+ <div class="health-section">
238
+ <div class="health-section-title">WebSockets</div>
239
+ <div class="health-grid">
240
+ <div class="health-row"><span class="health-label">Control clients</span><span class="health-mono">${n.control}</span></div>
241
+ <div class="health-row"><span class="health-label">Data clients</span><span class="health-mono">${n.data}</span></div>
242
+ <div class="health-row"><span class="health-label">Tracked per session</span><span class="health-mono">${n.dataPerSessionTotal}</span></div>
243
+ </div>
244
+ </div>
245
+
246
+ <div class="health-section">
247
+ <div class="health-section-title">Sessions (${r.total} total · ${r.alivePty} alive PTY)</div>
248
+ <div class="health-row health-dim">Listeners ${r.totalDataListeners} · Output buffer ${wj(r.totalOutputBufferBytes)}</div>
249
+ <table class="health-table">
250
+ <thead>
251
+ <tr>
252
+ <th>Name</th><th>State</th><th>PID</th><th>Buffer</th><th>Entries</th><th>Listeners</th><th>Timers</th><th>Flags</th>
253
+ </tr>
254
+ </thead>
255
+ <tbody>${o||`<tr><td colspan="8" class="health-dim">No sessions</td></tr>`}</tbody>
256
+ </table>
257
+ </div>
258
+ `}function Oj(){if(!bj)return;let e=sle(vj,_j?.anomalies),t=bj.hidden;bj.hidden=!e,e&&t&&_j&&(Ej(),yj&&Dj())}function dle(e){vj=e,Oj()}function fle(e){if(bj)return bj;let t=ule();return e.appendChild(t),Oj(),t}function ple(e){_j=e,Oj(),bj&&!bj.hidden&&(Ej(),yj&&Dj())}function kj(e){return e.replace(/\r\n?/g,`
259
+ `).split(`
260
+ `)}function Aj(e){return{kind:`unchanged`,text:e}}function mle(e){return{kind:`skipped`,text:`${e} unchanged lines`}}function jj(e,t){return e.length<=7?e.map(t):[...e.slice(0,3).map(t),mle(e.length-6),...e.slice(e.length-3).map(t)]}function hle(e){return e}function gle(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(...jj(e.slice(n,r),hle)),n=r}return t}function _le(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;return r}function Mj(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 Nj(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;a[r]=e[o]===t[n]?a[r+i+1]+1:Math.max(a[r+i],a[r+1])}let o=[],s=0,c=0;for(;s<n&&c<r;)e[s]===t[c]?(o.push(Aj(e[s])),s++,c++):a[(s+1)*i+c]>=a[s*i+c+1]?(o.push({kind:`removed`,text:e[s]}),s++):(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 Pj(e,t){let n=kj(e),r=kj(t),i=_le(n,r),a=Mj(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:gle([...jj(n.slice(0,i),Aj),...Nj(o,s),...jj(n.slice(n.length-a),Aj)]),isTooLarge:!1}}var Fj=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function Ij(e){return e===`approve`||e===`approve-accept-edits`}function Lj(e){return(e.state===`decided`||e.state===`closed`)&&Ij(e.lastDecision)}function Rj(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&Lj(n)}function zj(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function Bj(e){let t=zj(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 Vj(e,t){return zj(e,t)?.openRevision?.revision??null}function Hj(e,t,n){if(n===null)return null;let r=zj(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function Uj(e,t){let n=t-e;return Number.isFinite(n)?Sh(n,{rounding:`floor`,wording:`abbreviated`,suffix:` ago`,justNowBelowSeconds:60}):`just now`}function Wj(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 Gj(e,t,n){let r=Wj(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return Fj.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function Kj(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 qj(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function Jj(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+nf}function Yj(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 ${fu} characters, so nothing was sent`:qj(e)>1e4?`the feedback composes more than the ${mu} characters the hook reply carries, so nothing was sent`:Jj(e)>rf?`the decision is larger than one control frame carries, so nothing was sent`:null}function Xj(e){return e?`, ${e}`:``}function Zj(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=Kj(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 Qj(e,t,n){let r=Zj(e,t,n);return r?`${r}${Xj(e.problem)}`:e.problem??``}function $j(e){let t=zj(e.state,e.selectedAgentId),n=Bj(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:Hj(e.state,t?.agentId??null,n),status:Qj(e,t,n),actions:Gj(e,t,n),modes:[{kind:`read`,label:`Read`,enabled:!0},{kind:`changes`,label:`Changes`,enabled:Hj(e.state,t?.agentId??null,n)!==null&&e.isDraft!==!0},{kind:`edit`,label:`Edit`,enabled:Wj(e,t,n)}]}}function eM(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 tM({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 nM=12,rM=8,iM=``,aM=48,oM=new Map;function sM(e,t){return JSON.stringify([e,t])}function cM(e){return e.id??iM}function lM(e,t){let n=oM.get(e);n||(n=new Map,oM.set(e,n));let r=sM(t.agentId,t.revision);for(n.delete(r),n.set(r,t.plan);n.size>nM;){let e=n.keys().next().value;if(typeof e!=`string`)break;n.delete(e)}}function uM(e){oM.delete(e)}function dM(e,t,n){return!e||n===null?null:oM.get(e)?.get(sM(t,n))??null}function fM(e){let t=m(`section`,`plan-face`);t.hidden=!0;let n=m(`header`,`plan-head`),r=m(`select`,`plan-heading-picker`);r.setAttribute(`aria-label`,`Plan section`);let i=m(`div`,`plan-view-panel`),a=m(`div`,`plan-sheet-head`),o=m(`button`,`plan-control plan-sheet-close`,`×`);o.type=`button`,o.setAttribute(`aria-label`,`Close`),a.append(m(`span`,null,`View`),o);let s=m(`div`,`plan-view-group plan-author-group`),c=m(`div`,`plan-tabs`);c.setAttribute(`role`,`tablist`),c.setAttribute(`aria-label`,`Plan author`),s.append(m(`span`,`plan-sheet-label`,`Author`),c);let l=m(`div`,`plan-view-group plan-revision-group`),u=m(`div`,`plan-revision-stepper`),d=m(`button`,`plan-control plan-revision-previous`,`‹`);d.type=`button`,d.setAttribute(`aria-label`,`Previous revision`);let f=m(`button`,`plan-control plan-revision-next`,`›`);f.type=`button`,f.setAttribute(`aria-label`,`Next revision`);let p=m(`span`,`plan-revision-label`),h=m(`span`,`plan-revision-age`);u.append(d,p,f,h);let g=m(`div`,`plan-revision-list`);g.setAttribute(`role`,`radiogroup`),g.setAttribute(`aria-label`,`Revision`),l.append(m(`span`,`plan-sheet-label`,`Revision`),u,g);let _=m(`div`,`plan-view-group plan-mode-group`),v=m(`div`,`plan-modes`);v.setAttribute(`role`,`radiogroup`),v.setAttribute(`aria-label`,`Show`),_.append(m(`span`,`plan-sheet-label`,`Show`),v);let y=m(`div`,`plan-head-spacer`),b=m(`div`,`plan-draft-notice`),x=m(`span`,`plan-draft-dot`);x.setAttribute(`aria-hidden`,`true`);let S=m(`button`,`plan-control plan-draft-chip`,`Peek draft`);S.type=`button`,b.append(x,S),i.append(a,s,l,_,y,b);let C=m(`button`,`plan-control plan-view-button`,`View`);C.type=`button`,C.setAttribute(`aria-haspopup`,`dialog`),C.setAttribute(`aria-expanded`,`false`);let ee=m(`button`,`plan-control plan-minimize-button`,`Minimize`);ee.type=`button`,ee.addEventListener(`click`,e.showTerminal),n.append(r,i,C,ee);let te=m(`div`,`plan-sheet-backdrop`),ne=m(`div`,`plan-body-layout`),w=m(`nav`,`plan-heading-rail`);w.setAttribute(`aria-label`,`Plan sections`);let re=m(`article`,`plan-reading-column`);ne.append(w,re);let T=m(`textarea`,`plan-editor`);T.setAttribute(`aria-label`,`Plan markdown`),T.spellcheck=!1;let ie=m(`footer`,`plan-action-bar`),ae=m(`span`,`plan-status`);ae.setAttribute(`role`,`status`);let oe=m(`div`,`plan-decision-slot`),E=m(`label`,`plan-accept-edits`),D=m(`input`,`plan-accept-edits-checkbox`);D.type=`checkbox`,E.append(D,m(`span`,null,`Accept edits`)),oe.append(E,ae),ie.append(oe);let O=new Map;for(let[e,t]of[[`terminal`,`Answer in terminal`],[`revise`,`Send feedback`],[`approve`,`Approve`]]){let n=m(`button`,`plan-action`,t);n.type=`button`,n.dataset.decision=e,n.addEventListener(`click`,()=>{n.disabled||nt(e)}),O.set(e,n),ie.append(n)}t.append(n,ne,ie,te);let k=null,se={reviews:[]},ce=null,le=null,ue=!0,de=``,fe=``,me=``,he=``,ge=!1,_e=null,ve=!1,ye=null,be=!1,xe=!1,Se=null,Ce=[],we=null,Te=null,Ee=new Map,De=new Map,Oe=new Map,ke=[],Ae=!1,je=null,Me=!1;function Ne(e,t=!0){Me=e,i.replaceChildren(...e?[a,_,l,s,b,y]:[a,s,l,_,y,b]),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))}i.dataset.open=String(e),te.dataset.open=String(e),C.setAttribute(`aria-expanded`,String(e)),ne.inert=e,ie.inert=e,r.inert=e,C.inert=e,ee.inert=e,e?(i.setAttribute(`role`,`dialog`),i.setAttribute(`aria-label`,`Plan view`),i.setAttribute(`aria-modal`,`true`),o.focus()):(i.removeAttribute(`role`),i.removeAttribute(`aria-modal`),t&&C.focus())}function Pe(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=Me;r[i].click(),!(a&&e!==v)&&(e===v||!Me)&&e.querySelector(`[aria-checked="true"], [aria-selected="true"]`)?.focus()})}let Fe=pe.subscribe((e,t)=>{t.includes(`layout`)&&Me&&Ne(!1,!1)});e.signal?.addEventListener(`abort`,Fe,{once:!0}),Pe(v),Pe(c),Pe(g),C.addEventListener(`click`,()=>Ne(!Me)),o.addEventListener(`click`,()=>Ne(!1)),te.addEventListener(`click`,()=>Ne(!1)),i.addEventListener(`keydown`,e=>{if(!Me)return;if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),Ne(!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);e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())});function Ie(e){re.querySelector(`#${CSS.escape(e)}`)?.scrollIntoView({behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`,block:`start`})}r.addEventListener(`change`,()=>Ie(r.value));function Le(){Ae=!1;let e=ke.map(e=>re.querySelector(`#${CSS.escape(e.dataset.headingId??``)}`)).filter(e=>e!==null),t=re.getBoundingClientRect().top-re.scrollTop,n=tM({headingOffsets:e.map(e=>e.getBoundingClientRect().top-t),scrollTop:re.scrollTop,isScrolledToEnd:re.scrollTop>0&&re.scrollTop+re.clientHeight>=re.scrollHeight-2,readingLineOffset:aM}),i=n===null?null:e[n]?.id??null;for(let e of ke)e.dataset.headingId===i?e.setAttribute(`aria-current`,`location`):e.removeAttribute(`aria-current`);i!==null&&(r.value=i)}function Re(){Ae||t.hidden||ke.length===0||(Ae=!0,requestAnimationFrame(Le))}re.addEventListener(`scroll`,Re,{passive:!0});function ze(){je=null,ve=!1,be=!1,xe=!1,Se=null}function Be(t){we=t,e.reportProblem(t),Dt()}function Ve(e){le=e,we=null,ze(),Ne(!1,Me),Dt()}function He(e){let t=se.reviews.find(e=>e.agentId===ce)?.revisions??[],n=t[t.findIndex(e=>e.revision===le)+e];n&&Ve(n.revision)}d.addEventListener(`click`,()=>He(-1)),f.addEventListener(`click`,()=>He(1));function Ue(e,t){return`${k??``}:${e??`main`}:${t??`latest`}`}function We(){return Ue(ce,le)}function A(e,t,n){return`${e??``}:${sM(t,n??0)}`}function Ge(){return A(k,ce,le)}function Ke(){return De.get(Ge())??null}function qe(){return Ke()?.size??0}function Je(){if(je===null)return!1;let e=De.get(je.target.bucketKey)?.get(je.target.sectionSlot)??``;return je.field.value.trim()!==e}function Ye(e){let t=De.get(e);if(!t)return[];let n=[];for(let e of Ce){let r=t.get(cM(e));r&&n.push({heading:e.heading,comment:r})}return n}function Xe(e,t){let n=t.trim(),r=De.get(e.bucketKey)??new Map;De.set(e.bucketKey,r),n.length===0&&r.delete(e.sectionSlot),n.length>0&&r.set(e.sectionSlot,n),r.size===0&&De.delete(e.bucketKey),Dt()}function Ze(e){if(xe||ge)return;let t={bucketKey:Ge(),sectionSlot:cM(e)},n=m(`div`,`plan-comment-composer`),r=m(`label`,`plan-comment-label`,`Comment on ${e.heading??`Introduction`}`),i=m(`textarea`,`plan-comment-input`);i.maxLength=fu,i.value=De.get(t.bucketKey)?.get(t.sectionSlot)??``,r.append(i);let a=m(`div`,`plan-comment-actions`),o=m(`button`,`plan-control plan-comment-cancel`,`Cancel`);o.type=`button`;let s=m(`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};je=c,i.addEventListener(`input`,Et),o.addEventListener(`click`,()=>{je===c&&(je=null,Dt())}),s.addEventListener(`click`,()=>{je===c&&(je=null),Xe(t,i.value)}),Dt(),i.focus()}function Qe(e){let t={bucketKey:Ge(),sectionSlot:cM(e)};if(je?.target.bucketKey===t.bucketKey&&je.target.sectionSlot===t.sectionSlot)return je.element;let n=Ke()?.get(t.sectionSlot);if(!n)return null;let r=m(`div`,`plan-comment-card`),i=m(`div`,`plan-comment-head`),a=m(`button`,`plan-control plan-comment-edit`,`Edit`);a.type=`button`,a.addEventListener(`click`,()=>Ze(e));let o=m(`button`,`plan-control plan-comment-remove`,`Remove`);return o.type=`button`,o.disabled=ge,a.disabled=ge,o.addEventListener(`click`,()=>Xe(t,``)),i.append(m(`span`,`plan-comment-label`,`Your comment`),a,o),r.append(i,m(`p`,`plan-comment-text`,n)),r}function $e(t,n,r={}){if(!k||n.revision===null||ge)return!1;let i=Yj(r);if(i!==null)return Be(i),!1;let a={agentId:n.agentId,revision:n.revision,decision:t,...r};return e.sendDecision(k,a)?(we=null,ge=!0,_e=Ij(t)?n:null,Dt(),!0):!1}function et(e){if(!ve)return{};let t=T.value;return t===dM(k,e.agentId,e.revision)?{}:{plan:t}}function tt(e){let t=A(k,e.agentId,e.revision),n=Ye(t);n.length!==0&&$e(`revise`,e,{comments:n})&&e.revision!==null&&(Te={bucketKey:t,agentId:e.agentId,revision:e.revision},Dt())}function nt(e){let t={agentId:ce,revision:le};e===`revise`?tt(t):$e(e===`approve`&&!E.hidden&&D.checked?`approve-accept-edits`:e,t,et(t))}function rt(e){je=null,ve=e===`edit`,be=e===`changes`,ve&&ye!==Ge()&&(T.value=dM(k,ce,le)??``,ye=Ge()),we=null,Dt()}function it(e){return`${e.kind}:${Ue(e.agentId,e.revision)}`}function at(e){for(Oe.set(it(e),e);Oe.size>rM;){let e=Oe.keys().next().value;if(typeof e!=`string`)break;Oe.delete(e)}}function ot(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 st(e){for(let[t,n]of Oe)if(ot(n,e))return Oe.delete(t),n;return null}function ct(){for(let[e,t]of Oe)if(t.kind===`draft`)return Oe.delete(e),t;return null}function lt(){if(Oe.size!==1)return null;let e=Oe.entries().next().value;return e?(Oe.delete(e[0]),e[1]):null}function ut(){if(!k)return;let t=We();de!==t&&e.requestPlan(k,ce,le??void 0)&&(de=t,at({kind:`selection`,agentId:ce,revision:le}))}function dt(){t.hidden||ut()}function ft(){return Hj(se,ce,le)}function pt(t){if(!k)return;let n=Ue(ce,t);me!==n&&e.requestPlan(k,ce,t)&&(me=n,at({kind:`diff-base`,agentId:ce,revision:t}))}function mt(){if(!k)return;let t=`${k}:${ce??`main`}`;he!==t&&e.requestDraft(k,ce)&&(he=t,at({kind:`draft`,agentId:ce,revision:null}))}function ht(e,t){return`${e??``}:${t??``}`}function gt(){return se.reviews.find(e=>e.agentId===ce)?.revisions.find(e=>e.revision===le)?.receivedAt??0}function _t(){let e=Ee.get(ht(k,ce));return e!==void 0&&e>gt()}function vt(){xe?(ze(),Dt()):(je=null,ve=!1,be=!1,mt(),Dt())}S.addEventListener(`click`,vt);function yt(e){w.replaceChildren(),r.replaceChildren(),ke=[];for(let t of e){let e=t.id??`plan-introduction`,n=t.heading??`Introduction`,i=m(`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(Ke()?.has(cM(t))===!0),ke.push(i),i.addEventListener(`click`,()=>Ie(e)),w.append(i);let a=m(`option`,null,n);a.value=e,r.append(a)}}function bt(e){let t=ft();if(t===null){re.append(m(`p`,`plan-loading`,`This is the first revision, so there is nothing to diff`));return}let n=dM(k,ce,t);if(n===null){re.append(m(`p`,`plan-loading`,`Loading the previous revision`)),pt(t);return}let r=Pj(n,e);r.isTooLarge?(re.append(m(`p`,`plan-loading`,`This diff is too large to show, so the newer revision stands alone`)),re.append(Rg(Fg(e)))):re.append(Zie(r))}function xt(e){if(re.replaceChildren(),ve){yt(Ce),re.append(T);return}if(e===null){if(Ce=[],yt(Ce),fe===We()){re.append(m(`p`,`plan-loading`,`This plan revision could not be loaded`));return}re.append(m(`p`,`plan-loading`,`Loading plan`)),ut();return}let t=Fg(e);if(Ce=qie(t),yt(Ce),be){bt(e);return}if(xe){re.append(Rg(t));return}let n=Ke();re.append(Yie(Ce,{hasComment:e=>n?.has(cM(e))===!0,isComposing:e=>je?.target.bucketKey===Ge()&&je.target.sectionSlot===cM(e),onComment:Ze,attachmentFor:Qe}))}function St(e){s.hidden=e.tabs.length<2,c.replaceChildren();for(let t of e.tabs){let e=m(`button`,`plan-tab`,t.label);e.type=`button`,e.setAttribute(`role`,Me?`radio`:`tab`),e.setAttribute(Me?`aria-checked`:`aria-selected`,String(t.selected)),e.tabIndex=t.selected?0:-1,e.addEventListener(`click`,()=>{ce=t.agentId,le=null,we=null,de=``,fe=``,me=``,he=``,ze(),Ne(!1,Me),Dt()}),c.append(e)}}function Ct(){return xe?Se:dM(k,ce,le)}function wt(e){return $j({state:se,selectedAgentId:ce,selectedRevision:le,body:e,isConnected:ue,isDecisionInFlight:ge,isDraft:xe,pendingCommentCount:qe(),hasUnsavedComment:Je(),problem:we})}function Tt(e){ae.textContent=e.status,ae.hidden=e.status.length===0;let t=e.actions.some(e=>e.kind===`approve`&&e.enabled);E.hidden=!t,D.disabled=!t;for(let t of e.actions){let e=O.get(t.kind);e&&(e.disabled=!t.enabled)}}function Et(){Tt(wt(Ct()))}function Dt(){let e=Me&&i.contains(document.activeElement),t=$j({state:se,selectedAgentId:ce,selectedRevision:le,body:null,isConnected:ue});(ce!==t.selectedAgentId||le!==t.selectedRevision)&&ze(),ce=t.selectedAgentId,le=t.selectedRevision,ye!==Ge()&&(ye=null);let n=Ct(),a=wt(n);St(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}`,h.textContent=c?Uj(c.receivedAt,l):``,d.disabled=s<=0,f.disabled=s<0||s>=a.revisions.length-1,g.replaceChildren();for(let e of[...a.revisions].reverse()){let t=m(`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(m(`span`,`plan-revision-name`,e.label),m(`span`,`plan-revision-age`,Uj(e.receivedAt,l))),e.isOpen&&t.append(m(`span`,`plan-revision-open`,`OPEN`)),t.addEventListener(`click`,()=>Ve(e.revision)),g.append(t)}v.replaceChildren();let _=ve?`edit`:be?`changes`:`read`,y=a.modes.find(e=>e.kind===_&&e.enabled)??a.modes[0];for(let e of a.modes){let t=m(`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===_)),t.tabIndex=e.kind===y.kind?0:-1,t.addEventListener(`click`,()=>{t.disabled||(rt(e.kind),v.querySelector(`[aria-checked="true"]`)?.focus())}),v.append(t)}b.hidden=!_t()&&!xe,S.hidden=b.hidden,S.setAttribute(`aria-pressed`,String(xe)),Tt(a),xt(n),r.disabled=ke.length===0,Re(),e&&!i.contains(document.activeElement)&&o.focus()}function Ot(t){_e!==null&&Rj(t,_e.agentId)&&(_e=null,ye=null,e.showTerminal())}function kt(e){je=null,e!==k&&(_e=null,ge=!1,we=null,Oe.clear()),Ne(!1,!1),k=e,t.hidden=!1,de=``,fe=``,Dt(),dt()}function At(){je=null,Ne(!1,!1),t.hidden=!0}function jt(e,t){return t.kind!==`selection`||e.agentId!==ce?!1:t.revision===null?le===null||le===e.revision:t.revision===le}function Mt(e){e.kind===`draft`?(he=``,Be(`the draft could not be read, so nothing was shown`)):e.kind===`diff-base`?me=``:fe=Ue(e.agentId,e.revision)}function j(e){Te!==null&&Vj(e,Te.agentId)!==Te.revision&&(De.delete(Te.bucketKey),Te=null)}function Nt(e){ge=!1,Pt({reviews:e.reviews});let t=e.body;if(!t){let e=lt()??ct();e!==null&&Mt(e);return}let n=st(t);if(t.revision===0){if(he=``,n===null||t.agentId!==ce)return;Se=t.plan,xe=!0}else lM(e.id,t),n!==null&&jt(t,n)&&(ce=t.agentId,le=t.revision,de=``,fe=``)}function Pt(e){let t=Vj(e,ce);t!==null&&t!==Vj(se,ce)&&(le=t,ze()),j(e),se=e,ge=!1,Ot(e)}function Ft(e){let n=!1;e.state&&Pt(e.state),e.draft&&Ee.set(ht(e.draft.id,e.draft.agentId),e.draft.changedAt),e.decisionRefused&&(_e=null,ge=!1,Te=null),typeof e.isConnected==`boolean`&&(n=e.isConnected&&!ue,ue=e.isConnected,n&&(de=``,fe=``,me=``,he=``,ge=!1)),e.requestFailed&&(fe=de),e.response&&Nt(e.response),t.hidden||Dt(),(n||e.decisionRefused)&&dt()}return{el:t,show:kt,hide:At,update:Ft}}var pM=`#plan/`;function mM(e){return`${pM}${encodeURIComponent(e)}`}function hM(e){if(!e.startsWith(pM))return null;let t=e.slice(6);if(!t||t.includes(`/`))return null;try{return decodeURIComponent(t)||null}catch{return null}}var gM=`http://www.w3.org/2000/svg`;function _M(e,t){let n=document.createElementNS(gM,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);return n}function vM(e,t){let n=document.createElementNS(gM,`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 yM(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 bM(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 xM(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:bM(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 SM(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:yM(r)});let r=e.repos.map(e=>xM(e,n));return{repos:!e.error&&r.every(e=>e.header.fileCount===0&&e.warnings.length===0&&!e.error)?[]: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]},error:e.error??null}}function CM(e,t,n,r){let i=m(`button`,n);return i.type=`button`,i.title=`Open ${e} in the diff`,i.addEventListener(`click`,()=>r(t)),i}function wM(e,t){let n=m(`section`,`review-map-repo`),r=m(`div`,`review-map-repo-head`);r.append(m(`strong`,`review-map-repo-name`,e.header.name)),n.append(r);let i=m(`div`,`review-map-summary`);if(i.append(m(`span`,``,`${e.header.committedCount} committed`)),i.append(m(`span`,``,`${e.header.uncommittedCount} uncommitted`)),i.append(m(`span`,``,`Base: ${bs(e.header.base,{chars:8})||`unknown`}`)),n.append(i),e.error&&n.append(m(`p`,`review-map-error`,e.error)),e.subsystems.length>0){let t=m(`div`,`review-map-subsystems`);for(let n of e.subsystems)t.append(m(`span`,`review-map-chip`,`${n.title} (${n.fileCount})`));n.append(t)}if(e.warnings.length>0){n.append(m(`h3`,`review-map-label`,`Signals`));let r=m(`div`,`review-map-warnings`);for(let n of e.warnings){let e=CM(n.path,n.openPath,`review-map-warning`,t);e.dataset.severity=String(n.severity),e.dataset.kind=n.kind,e.append(m(`span`,`review-map-warning-headline`,n.headline)),e.append(m(`span`,`review-map-detail`,n.detail)),r.append(e)}n.append(r)}if(e.files.length>0){n.append(m(`h3`,`review-map-label`,`Files`));let r=m(`div`,`review-map-files`);for(let n of e.files){let e=CM(n.path,n.openPath,`review-map-file`,t);e.dataset.status=n.status,e.append(m(`span`,`review-map-file-path`,n.path)),e.append(m(`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 TM(e,t){let n=m(`div`,`review-map`);if(e.error&&n.append(m(`p`,`review-map-error`,e.error)),e.narrative.status&&n.append(m(`p`,`review-map-narrative-status`,e.narrative.status)),e.narrative.claims.length>0){let t=m(`section`,`review-map-narrative`);t.append(m(`h3`,`review-map-label`,`Narrative`));for(let n of e.narrative.claims){let e=m(`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(wM(r,t));return n}function EM(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 DM(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);else{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`;else if(e.startsWith(`deleted file mode`))r.status=`deleted`;else if(e.startsWith(`rename from `))r.oldPath=e.slice(12),r.status=`renamed`;else if(e.startsWith(`rename to `))r.path=e.slice(10),r.status=`renamed`;else if(e.startsWith(`Binary files`))r.binary=!0;else 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)}}else 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)}}else if(e.startsWith(`@@`)){i={header:e,lines:[]},r.hunks.push(i);let t=EM(e);a=t?t.oldStart:null,o=t?t.newStart:null}else 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 OM(e,t,n,r){return`${e}:${r}:${n}:${t}`}function kM(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 AM(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 jM(e,t){return t===`merged`||t===`none`||e===`parked`&&t===`pending-review`}function MM(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 NM({status:e,mergeReason:t,fetched:n,hasDiffError:r,hasChanges:i,hasCommits:a,canMerge:o,isWorkspace:s,live:c,effectiveBase:l}){return e===`parked`&&t===`base-diverged`?{text:`Parked: base branch diverged`,namesMergeTarget:!1}:e===`parked`?{text:`Parked: merge conflict`,namesMergeTarget:!1}:e===`merging`?{text:`Merging`,namesMergeTarget:!1}:e===`merged`?{text:`Merged`,namesMergeTarget:!1}:r?{text:`Could not read changes`,namesMergeTarget:!1}:n?i?s?{text:`Changes in this worktree`,namesMergeTarget:!1}:o?{text:`Ready to merge into ${IM(l)}`,namesMergeTarget:!0}:c?a?{text:`Not ready to merge`,namesMergeTarget:!1}:{text:`Uncommitted changes`,namesMergeTarget:!1}:{text:`Session ended`,namesMergeTarget:!1}:{text:`No changes yet`,namesMergeTarget:!1}:{text:`Checking for changes`,namesMergeTarget:!1}}function PM(e,t){return e.namesMergeTarget?null:`merges into ${IM(t)}`}function FM({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 IM(e){return e||`base`}function LM(e,t){return`Merge into ${IM(e)}, push it, and rebase this worktree, then keep working (${t})`}function RM(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function zM(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function BM({status:e,hasCommits:t,live:n,state:r}){return e===`merging`||!t?null:!n&&(e===`parked`||e===`merged`)?`Session ended.`:!n||e===`parked`?null:r===`INITIALIZING`||r===`STARTING`?`Starting up. Mergeable once the session is live.`:null}function VM({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function HM(e){return e||`its upstream`}function UM(e){if(!e)return null;let t=e.branch||`Base branch`,{state:n,ahead:r,behind:i}=e,a=HM(e.upstream);return n===`no-upstream`?`${t}: no upstream`:n===`unknown`&&e.error&&e.action===void 0?`${t}: sync check failed: ${e.error}`: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 WM(e){return!e||e.fetched===!1?`recheck`:e.state===`ahead`||e.state===`behind`?`resync`:`recheck`}function GM(e,t,n){let r=n?` (${t})`:``;if(!e||WM(e)===`recheck`)return`Click to fetch and check again${r}`;let i=e.branch||`Base branch`,a=HM(e.upstream);return e.state===`behind`?`Click to fast-forward ${i} to ${a}${r}`:`Click to push ${i} to ${a}${r}`}function KM(e){return e?.state!==`in-sync`||e.fetched===!1}function qM({fetched:e,changedFileCount:t,view:n}){return!e||t===0?!1:n!==`diff`}function JM(e){if(e.error)return`Resync failed: ${e.error}`;let t=e.branch||`The base branch`,n=HM(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.`}var YM=new Set([`pending-review`,`parked`]),XM=600,ZM=AT(`merge`,NT),QM=AT(`resolve-or-resync`,NT),$M=260,eN=700,tN=new Map,nN=new Map,rN=new Map,iN=new Map,aN=new Map,oN=new Map,sN=new Set,cN=new Set,lN=new Set,uN=Mp(),dN=null,fN=null,pN=null,mN=null,hN=new Map,gN=null,_N=null,vN=null,yN=null,bN=null,xN=!1,SN=!1,CN=null,wN=null,TN=null,EN=null,DN=new Map,ON=null,kN=null,AN=null,jN=null,MN=null,NN=new Map,PN=null,FN=!1,IN=null;function LN(e,t){let n=m(`button`,`review-icon-button`);n.type=`button`,n.title=e,n.setAttribute(`aria-label`,e);let r=vM(16,16);return r.append(_M(`path`,{d:t,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})),n.append(r),n}function RN(){xN=!1,pN?.querySelector(`.review-more-menu`)?.remove(),pN?.querySelector(`.review-more-button`)?.setAttribute(`aria-expanded`,`false`)}function zN({panel:e}){if(fN=e,!fN)return;let t=fN,n=m(`div`,`review-sidebar-head`),r=m(`span`,`review-sidebar-title`,`Review`),i=e=>{t.toggleAttribute(`data-collapsed`,e),jp(!e)},a=m(`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=m(`button`,`review-header-tab`,t);n.type=`button`,n.addEventListener(`click`,()=>RP(e)),hN.set(e,n),a.append(n)}gN=m(`span`,`review-notes-count`),a.append(gN);let o=LN(`Close review`,`M6 3L11 8L6 13`);o.classList.add(`review-sidebar-close`),o.addEventListener(`click`,()=>i(!0)),n.append(r,a,o);let s=m(`div`,`review-sidebar-rail`),c=LN(`Open review`,`M10 3L5 8L10 13`);c.classList.add(`review-sidebar-open`),c.addEventListener(`click`,()=>i(!1)),vN=m(`div`,`review-rail-status`),yN=m(`span`,`review-rail-added`),bN=m(`span`,`review-rail-removed`),vN.append(yN,bN),_N=m(`span`,`review-rail-label`,`Review`),s.append(c,_N,vN),pN=m(`div`,`review-controls`),mN=m(`div`,`review-sidebar-body`),ON=m(`div`,`review-notes-footer`),kN=m(`button`,`review-btn review-btn-primary`,`Send notes`),kN.type=`button`,kN.title=`Paste the drafted review notes into this session as one message`,kN.addEventListener(`click`,wP),AN=m(`div`,`review-notes-status`),ON.append(AN,kN),MN=m(`div`,`review-notes-list`),jN=m(`div`,`review-notes-outcome`),jN.setAttribute(`role`,`status`);let l=m(`div`,`review-resize-handle`);l.setAttribute(`aria-hidden`,`true`),t.append(s,n,pN,mN,jN,ON,l),t.toggleAttribute(`data-collapsed`,!Ap()),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&xN&&(e.preventDefault(),RN(),pN?.querySelector(`.review-more-button`)?.focus())}),document.addEventListener(`pointerdown`,e=>{xN&&e.target instanceof Element&&(pN?.contains(e.target)&&e.target.closest(`.review-more-button, .review-more-menu`)||RN())});let u=0,d=0,f=e=>{let n=Math.max($M,Math.min(eN,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))},h=!1,g=e=>{if(!h)return;h=!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&&am(parseInt(n,10))};l.addEventListener(`pointerdown`,e=>{e.button===0&&(e.preventDefault(),u=e.clientX,d=t.getBoundingClientRect().width,l.setPointerCapture(e.pointerId),h=!0,document.documentElement.style.cursor=`col-resize`,document.documentElement.style.userSelect=`none`)}),l.addEventListener(`pointermove`,p),l.addEventListener(`pointerup`,g),l.addEventListener(`pointercancel`,g),l.addEventListener(`lostpointercapture`,g);let _=im();_!==null&&f(_),R_(e=>{xN=!1,cN.clear(),lN.clear(),dN=null,_P(),e&&cP(e),e&&!uP(e)&&dP(e),HP()}),HP()}function BN(e){fN&&(e?ae(fN,e):oe(fN))}function VN(e,t){let n=tN.get(e);tN.set(e,t),jM(n,t)&&(rN.delete(e),iN.delete(e),aN.delete(e),e===I_()&&lP(e)),e===I_()&&HP()}function HN(e,t,n=null){let r=tN.get(e)||`none`,i=t||`none`;if(nN.set(e,n),VN(e,i),YM.has(i)&&!YM.has(r)){let t=I_(),n=t?YM.has(tN.get(t)||`none`):!1;(!t||!E.has(t)||!n)&&L_(e)}}function UN(e,t,n=null){nN.set(e,n),VN(e,t||`none`)}function WN(e,t){let n=rN.get(e)??null;rN.set(e,t),iN.delete(e),e===I_()&&(JN(n,t),dN&&zP(dN,t),HP(),BP())}function GN(e,t){let n=O(e);n&&(iN.set(n,t),n===I_()&&HP())}function KN(e,t){let n=O(e);if(!n)return;let r=Yu.safeParse(t);r.success&&r.data.sessionId===n&&(aN.set(n,r.data),n===I_()&&HP())}function qN(e){return{committed:e?.committed?.diff||``,uncommitted:e?.uncommitted?.diff||``}}function JN(e,t){if(NN.size===0||!e)return;let n=kM(qN(e),qN(t),NN.keys());if(n.length!==0){for(let e of n)NN.delete(e);PN!==null&&n.includes(PN)&&(PN=null),IN=`${n.length} note${n.length===1?``:`s`} dropped because the diff changed.`}}function YN(e,t){let n=O(e),r=t;oN.set(n,r),r&&r.action!==void 0&&XN(n,r),n===I_()&&HP()}function XN(e,t){sN.delete(e),clearTimeout(EN??void 0),EN=null;let n=JM(t);TN=n?{forId:e,text:n,isError:!!t.error}:null,TN&&!TN.isError&&(EN=setTimeout(()=>{TN&&TN.forId===e&&(TN=null),HP()},5e3))}function ZN(e){let t=O(e);t&&t===I_()&&cP(t)}function QN(e){let t=O(e);if(t!==I_())return;let n=!rN.has(t)||iN.has(t),r=!aN.has(t)||$N(aN.get(t));n&&cP(t),r&&!n&&lP(t),HP()}function $N(e){return e?!!e.error||e.repos.some(e=>e.error!==null):!1}function eP(e){let t=O(e);tN.delete(t),nN.delete(t),rN.delete(t),iN.delete(t),aN.delete(t),oN.delete(t),sN.delete(t),TN&&TN.forId===t&&(clearTimeout(EN??void 0),TN=null),t===I_()?L_(null):HP()}function tP(){let e=I_();if(!e||uP(e))return!1;let t=E.get(e);if(!t)return!1;let n=tN.get(e)||`none`,r=!!rN.get(e)?.hasCommits,i=zM(n,nN.get(e)||null,aP(t.currentState,r));return FM({status:n,mergeReason:nN.get(e)||null,live:sP(t.currentState),isMergeRendered:i.isRendered,hasChanges:iP(e)})!==`merge`||!i.isEnabled?!1:(oP(e,t.currentState),!0)}function nP(){let e=I_();if(!e||uP(e))return!1;let t=E.get(e);if(!t)return!1;let n=tN.get(e)||`none`,r=nN.get(e)||null;return FM({status:n,mergeReason:r,live:sP(t.currentState),isMergeRendered:zM(n,r,!1).isRendered,hasChanges:iP(e)})===`resolve`&&(G({type:`resolve-session-merge`,id:e}),!0)}function rP(){let e=I_();return!e||!E.has(e)||uP(e)||pP(e)?!1:(mP(e),!0)}function iP(e){let t=rN.get(e)??null,n=[...DM(t?.committed?.diff||``),...DM(t?.uncommitted?.diff||``)];return VM({fetched:rN.has(e),changedFileCount:MM(n).files,hasCommits:!!t?.hasCommits})}function aP(e,t){return(u.includes(e)||e===a.RUNNING)&&t}function oP(e,t){t===a.RUNNING?lh({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:()=>G({type:`merge-continue-session`,id:e,force:!0})}):G({type:`merge-continue-session`,id:e})}function sP(e){return e!==a.DORMANT&&e!==a.DONE&&e!==a.FAILED}function cP(e){G({type:`request-session-diff`,id:e}),lP(e)}function lP(e){aN.has(e)||aN.set(e,null),G({type:`request-change-map`,id:e})}function uP(e){return E.get(e)?.card.dataset.workspace!==void 0}function dP(e){oN.set(e,null),G({type:`request-branch-sync`,id:e}),e===I_()&&HP()}function fP(e){sN.add(e),clearTimeout(EN??void 0),TN&&TN.forId===e&&(TN=null),G({type:`resync-branch`,id:e}),e===I_()&&HP()}function pP(e){return sN.has(e)||oN.get(e)===null}function mP(e){pP(e)||(WM(oN.get(e))===`resync`?fP(e):dP(e))}function hP(e,t){return t?{text:`Resyncing...`,loading:!0,error:!1}:TN&&TN.forId===e?{text:TN.text,loading:!1,error:TN.isError}:null}function gP(e,t){return e?.card?.dataset.session||t}function _P(){NN.clear(),PN=null,IN=null,FN=!1}function vP(e){return NN.get(e)??null}function yP(){return`${NN.size} note${NN.size===1?``:`s`} drafted`}function bP(e,t){let n=m(`div`,`review-notes-entry`),r=t.side===`old`?` (removed line)`:``;n.append(m(`span`,`review-notes-entry-where`,`${t.section} ${t.path}:${t.line}${r}`)),n.append(m(`span`,`review-notes-entry-note`,t.note));let i=m(`button`,`review-note-remove`,`Remove`);return i.type=`button`,i.title=`Drop this note`,i.addEventListener(`click`,()=>LP(e)),n.append(i),n}function xP(){if(MN){MN.replaceChildren(),MN.hidden=NN.size===0;for(let[e,t]of NN)MN.append(bP(e,t))}}function SP(){if(!ON||!kN||!AN)return;let e=I_(),t=!!e&&E.has(e);ON.hidden=!t||uN===`map`||NN.size===0,kN.disabled=FN||NN.size===0,AN.textContent=yP(),gN&&(gN.hidden=NN.size===0,gN.textContent=String(NN.size),gN.setAttribute(`aria-label`,yP())),jN&&(jN.textContent=FN?`Sending notes...`:IN,jN.hidden=!t||uN===`map`||!jN.textContent),xP(),uN===`notes`&&t&&CP()}function CP(){mN&&MN&&(mN.replaceChildren(),NN.size===0?UP(`No notes yet`,`Open the Diff tab and press note on a line to draft one.`):mN.append(MN))}function wP(){let e=I_();e&&!FN&&NN.size!==0&&(FN=!0,IN=null,SP(),Ym(`send-diff-annotations`,{id:e,annotations:[...NN.values()]}).then(DP,TP))}function TP(e){FN=!1;let t=e instanceof Error?e.message:``;IN=t?`Could not send the notes: ${t}.`:`Could not send the notes.`,SP()}function EP(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 DP(e){FN=!1,e.type!==`send-diff-annotations-result`||e.ok!==!0?(IN=EP(e),SP()):e.pending===!0?(IN=`Notes queued until the session wakes. They stay drafted here, and pressing Send notes again re-sends them.`,SP()):(IN=`Notes sent.`,NN.clear(),PN=null,HP())}function OP(e,t){let n=m(`div`,`review-note`);n.dataset.noteFor=e,n.append(m(`span`,`review-note-text`,t));let r=m(`button`,`review-note-remove`,`Remove`);return r.type=`button`,r.title=`Drop this note`,r.addEventListener(`click`,()=>LP(e)),n.append(r),n}function kP(e,t){let n=m(`div`,`review-note-editor`);n.dataset.editorFor=e;let r=m(`input`,`review-note-input`);r.type=`text`,r.value=t,r.maxLength=$d,r.placeholder=`Note for this line`,r.addEventListener(`keydown`,t=>{t.key===`Enter`?(t.preventDefault(),IP(e,r.value)):t.key===`Escape`&&(t.preventDefault(),FP())});let i=m(`button`,`review-note-save`,`Save`);i.type=`button`,i.addEventListener(`click`,()=>IP(e,r.value));let a=m(`button`,`review-note-cancel`,`Cancel`);return a.type=`button`,a.addEventListener(`click`,FP),n.append(r,i,a),n}function AP(e){let t=[],n=vP(e);return PN===e&&t.push(kP(e,n?n.note:``)),n&&t.push(OP(e,n.note)),t}function jP(e,t){let n=AP(t);return e.after(...n),n}function MP(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 NP(e){let t=DN.get(e);if(!t)return;let n=null;for(let r of t.rows){MP(r);let t=jP(r,e);for(let e of t){let t=e.querySelector(`input`);!n&&t instanceof HTMLInputElement&&(n=t)}}n&&(n.focus(),n.select())}function PP(e){let t=PN;PN=e,t&&t!==e&&NP(t),NP(e)}function FP(){let e=PN;e&&(PN=null,NP(e))}function IP(e,t){let n=DN.get(e);if(!n)return;let r=t.trim();r&&(NN.size>=50&&!NN.has(e)?(IN=`Only 50 notes can be sent at once.`,SP()):(NN.set(e,{...n.target,section:n.section,note:r}),IN=null,PN=null,NP(e),SP()))}function LP(e){NN.delete(e),IN=null,NP(e),SP()}function RP(e){uN=e,e!==`diff`&&(dN=null),Np(e),HP()}function zP(e,t){if(!t)return;let n=DM(t.committed?.diff),r=DM(t.uncommitted?.diff);for(let t of n)(t.path===e||t.oldPath===e)&&cN.add(`committed:${t.path}`);for(let t of r)(t.path===e||t.oldPath===e)&&cN.add(`uncommitted:${t.path}`)}function BP(){if(!mN||!dN)return;let e=mN.querySelectorAll(`.review-file`);for(let t of e)if(t.dataset.path===dN||t.dataset.oldPath===dN){t.scrollIntoView({block:`nearest`}),dN=null;return}}function VP(e){dN=e,zP(e,rN.get(I_()??``)),RP(`diff`),BP()}function HP(){if(!pN||!mN)return;pN.replaceChildren(),mN.replaceChildren();for(let[e,t]of hN)t.setAttribute(`aria-pressed`,String(uN===e));DN.clear(),SP(),_N&&(_N.hidden=!0),vN&&(vN.hidden=!0);let e=I_(),t=e?E.get(e):null;if(!e||!t){UP(`No session selected`,`Click a session name to review its changes here.`);return}let n=uP(e),r=tN.get(e)||`none`,i=nN.get(e)||null,a=t.currentState,o=YM.has(r),s=rN.has(e),c=s?rN.get(e):null,l=iN.get(e)??null,u=c?DM(c.committed?.diff||``):[],d=c?DM(c.uncommitted?.diff||``):[],f=!!c?.hasCommits,p=sP(a),h=zM(r,i,aP(a,f)),g=oN.get(e),_=sN.has(e),v=IM(t.effectiveBase),y=MM([...u,...d]),b=FM({status:r,mergeReason:i,live:p,hasChanges:VM({fetched:s,changedFileCount:y.files,hasCommits:f}),isMergeRendered:h.isRendered}),x=NM({status:r,mergeReason:i,fetched:s,hasDiffError:l!==null,hasChanges:y.files>0||f,hasCommits:f,canMerge:!n&&h.isEnabled,isWorkspace:n,live:p,effectiveBase:v}),S=m(`div`,`review-status-headline`);if(S.append(m(`span`,`review-status-text`,x.text)),!n&&!KM(g)){let t=UM(g);if(t){S.title=t;let n=LN(`Refresh branch sync`,`M13 6A5 5 0 1 0 13 10M13 2v4H9`);n.classList.add(`review-branch-sync-refresh`),n.title=GM(g,QM,b!==`resolve`),n.disabled=pP(e),n.setAttribute(`aria-description`,t),n.addEventListener(`click`,()=>mP(e)),S.append(m(`span`,`sr-only`,t),n)}}pN.append(S);let C=m(`div`,`review-status-meta`);if(qM({fetched:s,changedFileCount:y.files,view:uN})&&C.append(m(`span`,`review-status-files`,`${y.files} file${y.files===1?``:`s`}`),m(`span`,`review-status-added`,`+${y.added}`),m(`span`,`review-status-removed`,`-${y.removed}`),m(`span`,`review-status-spacer`)),!n&&KM(g)){let t=WP(e,b!==`resolve`);t&&C.append(t)}C.childElementCount>0&&pN.append(C),r===`parked`&&pN.append(m(`div`,`review-status-explanation`,RM(i))),_N&&(_N.hidden=!1),vN&&(vN.hidden=!1,vN.setAttribute(`aria-label`,`${x.text}, +${y.added}, -${y.removed}`),vN.title=x.text),yN&&(yN.textContent=`+${y.added}`),bN&&(bN.textContent=`-${y.removed}`);let ee=n?null:JP(e,{status:r,reviewable:o,mergeAction:h,live:p,state:a,effectiveBase:v,primaryAction:b});ee&&pN.append(ee);let te=n?null:hP(e,_),ne=!n&&b===`merge`&&!h.isEnabled?BM({status:r,hasCommits:f,live:p,state:a}):null;if(ne){let e=m(`div`,`review-control-reason`,ne);e.id=`review-merge-reason`,pN.append(e),pN.querySelector(`#review-merge-btn`)?.setAttribute(`aria-describedby`,e.id)}if(te?.text){let e=m(`div`,te.loading?`review-control-reason review-loading`:`review-control-reason`,te.text);e.id=`review-resync-reason`,te.error&&e.classList.add(`review-control-reason-error`),e.setAttribute(`role`,`status`),C.append(e),C.isConnected||pN.insertBefore(C,S.nextSibling),pN.querySelector(`.review-branch-sync-text, .review-branch-sync-refresh`)?.setAttribute(`aria-describedby`,e.id)}if(SN&&CN===e&&pN.append(m(`div`,`review-resolve-sent`,`Resolve prompt sent`)),uN!==`notes`){if(uN===`map`){let t=aN.get(e);if(!t){mN.append(m(`div`,`review-nochanges review-loading`,`Loading map...`));return}mN.append(TM(SM(t),VP))}else l?mN.append(m(`p`,`review-diff-error`,l)):(u.length>0&&mN.append(GP(`committed`,`Committed`,PM(x,v),u)),d.length>0&&mN.append(GP(`uncommitted`,`Uncommitted`,null,d)))}}function UP(e,t){if(!mN)return;let n=m(`div`,`review-empty`);n.append(m(`div`,`review-empty-title`,e),m(`div`,`review-empty-desc`,t)),mN.append(n)}function WP(e,t){let n=oN.get(e);if(n===void 0)return null;if(n===null)return m(`span`,`review-branch-sync-text review-loading`,`Checking branch sync...`);let r=UM(n)||`Base branch: sync state unknown`,i=LN(`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(m(`span`,`review-branch-sync-label`,r)),i.disabled=sN.has(e),n.state&&(i.dataset.syncState=n.state),n.fetched===!1&&(i.dataset.stale=`true`),i.title=GM(n,QM,t),i.addEventListener(`click`,()=>mP(e)),i}function GP(e,t,n,r){let i=m(`div`,`review-section`);i.dataset.kind=e;let a=MM(r),o=m(`div`,`review-section-head`),s=m(`div`,`review-section-id`);s.append(m(`span`,`review-section-label`,t)),n&&s.append(m(`span`,`review-section-meaning`,n)),o.append(s);let c=m(`div`,`review-section-stat`);c.append(m(`span`,`review-stat-files`,`${a.files} file${a.files===1?``:`s`}`)),c.append(m(`span`,`review-add`,`+${a.added}`),m(`span`,`review-del`,`-${a.removed}`)),o.append(c),i.append(o);let l=m(`div`,`review-diff`);for(let t of r)l.append(KP(t,e));return i.append(l),i}function KP(e,t){let n=`${t}:${e.path}`,r=cN.has(n),i=m(`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=m(`button`,`review-file-head`);a.type=`button`,a.setAttribute(`aria-expanded`,r?`true`:`false`);let o=m(`span`,`review-file-twisty`,r?`▾`:`▸`);o.setAttribute(`aria-hidden`,`true`),a.append(o,m(`span`,`review-file-path`,e.path));let s=m(`span`,`review-file-counts`);if(e.binary&&s.append(m(`span`,`review-bin`,`bin`)),e.binary||s.append(m(`span`,`review-add`,`+${e.added}`),m(`span`,`review-del`,`-${e.removed}`)),a.append(s),a.addEventListener(`click`,()=>{let e=cN.has(n);e&&cN.delete(n),e||cN.add(n),HP()}),i.append(a),!r)return i;let c=m(`div`,`review-file-body`);if(e.binary)return c.append(m(`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>=XM&&!lN.has(n)){u=!0;break}c.append(m(`div`,`review-hunk-head`,r.header));for(let i of r.lines){if(l>=XM&&!lN.has(n)){u=!0;break}let r=m(`div`,`review-line review-line-${i.type}`),a=i.type===`add`?`+`:i.type===`del`?`-`:i.type===`meta`?`\\`:` `;r.append(m(`span`,`review-line-gutter`,a)),r.append(m(`span`,`review-line-text`,i.text));let o=AM(e,i);if(c.append(r),l++,!o)continue;let s=OM(t,o.path,o.line,o.side),d=DN.get(s)??{target:o,section:t,rows:[]};d.rows.push(r),DN.set(s,d),r.dataset.noteKey=s;let f=m(`button`,`review-annotate`,`note`);f.type=`button`,f.title=`Note on ${o.path}:${o.line}`,f.addEventListener(`click`,()=>PP(s)),r.append(f),jP(r,s)}if(u)break}if(u){let e=m(`button`,`review-expand`,`Show the rest of this file`);e.type=`button`,e.addEventListener(`click`,()=>{lN.add(n),HP()}),c.append(e)}return i.append(c),i}function qP({id:e,label:t,shortcut:n,title:r,disabled:i=!1,danger:a=!1,onClick:o}){let s=m(`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 JP(e,{status:t,reviewable:n,mergeAction:r,live:i,state:a,effectiveBase:o,primaryAction:s}){let c=m(`div`,`review-actions`),l=s===`resolve`;s===`merge`&&c.append(qP({id:`review-merge-btn`,label:`Merge`,shortcut:ZM,title:LM(o,ZM),disabled:!r.isEnabled,onClick:()=>oP(e,a)})),l&&c.append(qP({label:`Resolve`,shortcut:QM,title:`Paste a resolve prompt into this session so the agent can finish the merge (${QM})`,onClick:()=>{G({type:`resolve-session-merge`,id:e}),SN=!0,CN=e,clearTimeout(wN??void 0),wN=setTimeout(()=>{SN=!1,CN=null,HP()},3e3),HP()}}));let u=m(`div`,`review-action-controls`);if(u.append(c),!n||i)return c.childElementCount>0?u:null;let d=LN(`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(xN)),d.setAttribute(`aria-controls`,`review-more-menu`),d.addEventListener(`click`,()=>{xN=!xN,HP(),(pN?.querySelector(xN?`.review-more-menu button:not(:disabled)`:`.review-more-button`)??pN?.querySelector(`.review-more-button`))?.focus()}),c.append(d),!xN)return u;let f=m(`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=qP({label:`Discard worktree`,danger:!0,disabled:t===`merging`,onClick:()=>{xN=!1,HP(),lh({title:`Discard worktree`,message:`Throw away the worktree changes for "${gP(E.get(e),e)}"? This cannot be undone.`,confirmLabel:`Discard`,onConfirm:()=>G({type:`discard-session-worktree`,id:e})})}});n.setAttribute(`role`,`menuitem`),f.append(n)}return u.append(f),u}var YP=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 XP(e){let t=e.split(/\r?\n/,1)[0]?.trim()??``;return t.length<=160?t:`${t.slice(0,157)}...`}function ZP(e,t){let n=YP[e];if(!n||!t||typeof t!=`object`||Array.isArray(t))return``;let r=t[n];return typeof r==`string`?XP(r):``}var QP=5e3;function $P(e){let t=e.match(/<command-name>([^<]*)<\/command-name>/)?.[1];return t===void 0||/[\r\n]/.test(t)?null:t.trim()||null}function eF(e,t){if(!e.toolUseId)return $P(e.text)??`context`;let n=t.get(e.toolUseId);return n?ZP(n.name,n.input)||n.name:`expansion`}function tF(e){return e.kind!==`expansion`||e.toolUseId?!1:$P(e.text)!==null}function nF(e){return e.kind===`prompt`||e.kind===`session`||tF(e)}function rF(e){return new TextEncoder().encode(e).byteLength}function iF(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(`
261
+ `)}var aF={prompt:`PROMPT`,expansion:`EXPANSION`,thinking:`THINKING`,assistant:`ASSISTANT`,tool_call:`TOOL`,tool_result:`RESULT`,session:`SESSION`,notice:`NOTICE`,raw:`RAW`},oF=[{kind:`thinking`,label:`Thinking`},{kind:`tool_result`,label:`Tool result`},{kind:`raw`,label:`Raw`}];function sF(e,t){if(e.kind===`prompt`)return{prefix:`Prompt: `,text:XP(e.text)};if(e.kind===`thinking`)return{prefix:`Thinking: `,text:XP(e.text)};if(e.kind===`assistant`)return{prefix:`Assistant: `,text:XP(e.text)};if(e.kind===`notice`)return{prefix:`Notice: `,text:XP(e.text)};if(e.kind===`raw`)return{prefix:`Raw: `,text:XP(e.line)};if(e.kind===`session`)return{prefix:`Session: `,text:`${e.vendor} ${e.vendorSessionId}`};if(e.kind===`expansion`)return{prefix:`Expansion: `,text:eF(e,t)};if(e.kind===`tool_call`){let t=ZP(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:`${rF(e.content)} bytes`}}function cF(e){if(!e.agentType)return``;let t=e.agentId?` ${e.agentId.slice(-6)}`:``;return`[${e.agentType}${t}] `}function lF(e,t){let n=sF(e,t),r=cF(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:aF[e.kind],text:`${r}${i}`,tone:o,badges:a}}function uF(e,t){return{record:e,...lF(e,t)}}function dF(e){return e.kind!==`tool_result`&&e.kind!==`expansion`?null:e.toolUseId||null}function fF(e,t){let n=dF(e);return!n||t.has(n)?null:n}function pF(e,t,n=1){e.set(t,(e.get(t)??0)+n)}function mF(e,t){let n=(e.get(t)??0)-1;n>0?e.set(t,n):e.delete(t)}function hF(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=dF(i.record);a&&t.has(a)&&(n.rows[r]=uF(i.record,e.toolCallByUseId))}}function gF(){return{turns:[],toolCallByUseId:new Map,unresolvedToolUseCounts:new Map}}function _F(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 vF(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`}`}, ${Th(i,`KB`)}, ${Xh(_F(e))}`}function yF(){return{rowCount:0,toolCallCount:0,errorCount:0,resultBytes:0}}function bF(e,t,n){e.metrics.rowCount+=n,t.record.kind===`tool_call`&&(e.metrics.toolCallCount+=n),t.record.kind===`tool_result`&&(e.metrics.resultBytes+=rF(t.record.content)*n,t.record.isError&&(e.metrics.errorCount+=n))}function xF(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=fF(i,e.toolCallByUseId);t&&pF(e.unresolvedToolUseCounts,t);let a=uF(i,e.toolCallByUseId);if(nF(i)){r={head:a,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:yF()},bF(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:yF()},e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:null,rows:[]})),r.rows.push(a),bF(r,a,1);let o=e.turns.length-1,s=n[n.length-1];s&&s.turnIndex===o?s.rows.push(a):n.push({turnIndex:o,isNewTurn:!1,head:null,rows:[a]})}return n}function SF(e,t){let n=gF();xF(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)||pF(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],hF(e,i),{newTurns:n.turns,mergedHead:c,mergedRows:l,needsRerender:i.size>0}}function CF(e){return e.rows.length+ +!!e.head}function wF(e){let t=0;for(let n of e.turns)t+=CF(n);return t}function TF(e,t){for(let n of t){if(n.record.kind===`tool_call`){e.toolCallByUseId.delete(n.record.toolUseId);continue}let t=dF(n.record);t&&mF(e.unresolvedToolUseCounts,t)}}function EF(e,t){TF(e,t.head?[t.head,...t.rows]:t.rows)}function DF(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);TF(e,i);for(let e of i)bF(n,e,-1);return n.rows=n.rows.slice(r),n.hasTrimmedRows=!0,r}function OF(e,t=QP){let n=wF(e),r=0;for(;n>t&&r<e.turns.length-1;){let t=e.turns[r];if(!t)break;n-=CF(t),EF(e,t),r+=1}return r>0&&(e.turns=e.turns.slice(r)),n<=t?{droppedTurnCount:r,droppedRowCount:0}:{droppedTurnCount:r,droppedRowCount:DF(e,n-t)}}function kF(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 AF(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 jF(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 MF(e,t=QP){return!e.selectedSessionId||!e.hasLoadedOnce||e.hasDroppedEarliestRows||e.residentRowCount>=t?!1:e.firstOffset>0}function NF(e,t=QP){return!MF(e,t)||e.hasPendingRequest||!e.selectedSessionId?null:{id:e.selectedSessionId,direction:`earlier`,after:0,endingAt:e.firstOffset}}function PF(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 FF(e){return e.hasSelectionChanged||e.isRenderedTraceStale||!e.hasRenderedOnce}function IF(e,t,n){return e!==0||t?null:n?.startedAt??null}function LF(e,t){return RF(e,t)?e.filter(e=>e!==t):[...e,t]}function RF(e,t){return e.includes(t)}function zF(e){return e?`No trace has been recorded for ${e.label}.`:`No sessions are available.`}var BF=1e4,VF=null,HF=null,UF=null,WF=null,GF=[],KF=!1,qF=Hp(),JF=null,YF=null,XF=[],ZF=null,QF=null,$F=null,eI=null,tI=!1;function nI(){return!!VF&&!T(VF)}function rI(){return XF.find(e=>e.id===ZF)??null}function iI(){eI&&=(clearTimeout(eI.timeoutHandle),null)}function aI(){eI=null,kI()}function oI(e){iI(),tI=!1,ZF=e,$F=e?{sessionId:e,grouping:gF(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,KF=!0}function sI(e){let t=AF(XF,QF,ZF,e);return QF&&t===QF&&(QF=null),t!==ZF&&(oI(t),!0)}function cI(e){if(!JF)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};JF(t)&&(eI={request:e,timeoutHandle:setTimeout(aI,BF)})}function lI(e=!1){if(!JF)return;let t=jF({selectedSessionId:ZF,isPanelVisible:e||nI(),hasPendingRequest:!!eI,hasLoadedOnce:$F?.hasLoadedOnce??!1,nextOffset:$F?.nextOffset??0});t&&cI(t)}function uI(){return{selectedSessionId:ZF,hasPendingRequest:!!eI,hasLoadedOnce:$F?.hasLoadedOnce??!1,hasDroppedEarliestRows:$F?.hasDroppedEarliestRows??!1,firstOffset:$F?.firstOffset??0,residentRowCount:$F?wF($F.grouping):0}}function dI(){if(!JF)return;let e=NF(uI());e&&cI(e)}function fI(e){XF.some(t=>t.id===e)&&e!==ZF&&(QF=null,oI(e),lI(),kI())}function pI(){let e=m(`label`,`trace-session-field`),t=m(`span`,`trace-session-label`,`Session`),n=m(`select`,`trace-session-select`);n.disabled=XF.length===0;for(let e of XF){let t=m(`option`,null,e.label);t.value=e.id,t.selected=e.id===ZF,n.append(t)}return n.addEventListener(`change`,()=>fI(n.value)),e.append(t,n),e}function mI(e){e.toggleAttribute(`data-hidden`,RF(qF,e.dataset.kind??``))}function hI(){if(UF)for(let e of UF.querySelectorAll(`.trace-row`))mI(e)}function gI(e){if(UF)for(let t of UF.querySelectorAll(`details`))t.open=e}function _I(){let e=m(`div`,`trace-filters`);for(let t of oF){let n=m(`button`,`trace-filter`,t.label);n.type=`button`;let r=()=>{n.setAttribute(`aria-pressed`,String(!RF(qF,t.kind)))};r(),n.addEventListener(`click`,()=>{qF=LF(qF,t.kind),Up(qF),r(),hI()}),e.append(n)}for(let[t,n]of[[`Expand all`,!0],[`Collapse all`,!1]]){let r=m(`button`,`trace-expand-control`,t);r.type=`button`,r.addEventListener(`click`,()=>{gI(n)}),e.append(r)}return e}function vI(){let e=ne(`trace`,`Session trace`,`Bodies load from the local trace file only when requested.`),t=m(`div`,`trace-controls`);t.append(pI());let n=$F?.filePath??``,r=m(`code`,`trace-path`,n);r.title=n,t.append(r);let i=$F?IF($F.firstOffset,$F.hasDroppedEarliestRows,$F.grouping.turns[0]):null;return i!==null&&t.append(m(`span`,`trace-session-start`,`Started ${new Date(i).toLocaleString()}`)),e.append(t,_I()),e}function yI(e){let t=m(`div`,`trace-copy-wrap`),n=m(`button`,`trace-copy`,`Copy`);n.type=`button`;let r=m(`span`,`trace-copy-status`);return r.setAttribute(`role`,`status`),n.addEventListener(`click`,()=>{let t=ie(e);t?(t.then(()=>{r.textContent=`Copied`}).catch(()=>{r.textContent=`Copy failed`}),setTimeout(()=>{r.textContent=``},1600)):r.textContent=`Copy failed`}),t.append(n,r),t}function bI(){let e=m(`div`,`trace-earlier-wrap`),t=m(`button`,`trace-load-earlier`,`Load earlier`);return t.type=`button`,t.addEventListener(`click`,()=>{dI()}),e.append(t),e}function xI(e,t,n=``){let r=m(`details`,`trace-row${n?` ${n}`:``}`);r.dataset.kind=e.kind,r.dataset.tone=e.tone,mI(r);let i=m(`summary`,`trace-row-summary`);i.append(m(`span`,`trace-offset`,Zh(t,e.record.ts)),m(`span`,`trace-kind`,e.tag),m(`span`,`trace-row-label`,e.text));for(let t of e.badges){let e=m(`span`,`trace-badge`,t);e.dataset.badge=t,i.append(e)}let a=m(`div`,`trace-row-body`);r.append(i,a);let o=!1;return r.addEventListener(`toggle`,()=>{if(!r.open||o)return;o=!0;let t=iF(e.record);a.append(yI(t),m(`pre`,`trace-row-pre`,t))}),r}function SI(e){return m(`span`,`trace-turn-metrics`,vF(e))}function CI(e,t){e&&t&&(t.textContent=vF(e))}function wI(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=Zh(t.startedAt,t.rows[e].record.ts))}}function TI(e,t,n){let r=xI(t,e.startedAt,`trace-turn-head`);return b(r,`.trace-row-summary`).append(n),r}function EI(e){let t=m(`section`,`trace-turn`),n=SI(e);if(e.head&&t.append(TI(e,e.head,n)),!e.head){let e=m(`h2`,`trace-leading-title`);e.append(m(`span`,`trace-leading-label`,`Before first prompt`),n),t.append(e)}let r=m(`div`,`trace-rows`);for(let t of e.rows)r.append(xI(t,e.startedAt));return e.hasTrimmedRows&&t.append(m(`p`,`trace-trimmed`,`Earlier rows trimmed`)),t.append(r),{section:t,rowsElement:r,metricsElement:n}}function DI(e){return e?eI?.request.id===e.id&&!$F?.hasLoadedOnce?`Loading trace.`:zF(e):zF(null)}function OI(){if(!VF)return;let e=m(`div`,`trace-content`);HF=vI(),e.append(HF),UF=null,WF=null,GF=[];let t=rI(),n=$F?.grouping.turns??[];if(!t||n.length===0){e.append(m(`p`,`trace-empty`,DI(t))),VF.replaceChildren(e),KF=!1;return}MF(uI())&&(WF=bI(),e.append(WF));let r=m(`div`,`trace-turns`);for(let e of n){let t=EI(e);GF.push(t),r.append(t.section)}UF=r,hI(),e.append(r),VF.replaceChildren(e),KF=!1}function kI(){VF&&(nI()?OI():KF=!0)}function AI(){if(!HF||!nI())return;let e=vI();HF.replaceWith(e),HF=e}function jI(e){if(!UF)return;let t=$F?.grouping.turns[e.turnIndex];if(!t)return;if(e.isNewTurn){let e=EI(t);GF.push(e),UF.append(e.section);return}let n=GF[e.turnIndex];if(n){for(let r of e.rows)n.rowsElement.append(xI(r,t.startedAt));CI(t,n.metricsElement)}}function MI(e){let t=e.parentElement;t&&!t.querySelector(`.trace-trimmed`)&&t.insertBefore(m(`p`,`trace-trimmed`,`Earlier rows trimmed`),e)}function NI(){MF(uI())?!WF&&UF?.parentElement&&(WF=bI(),UF.parentElement.insertBefore(WF,UF)):(WF?.remove(),WF=null)}function PI(){if(!$F)return;let e=OF($F.grouping);if(!(e.droppedTurnCount>0||e.droppedRowCount>0)){NI();return}let t=!$F.hasDroppedEarliestRows;if($F.hasDroppedEarliestRows=!0,GF=GF.slice(e.droppedTurnCount),UF)for(let t=0;t<e.droppedTurnCount;t+=1)UF.firstElementChild?.remove();let n=GF[0];if(n&&e.droppedRowCount>0){for(let t=0;t<e.droppedRowCount;t+=1)n.rowsElement.firstElementChild?.remove();MI(n.rowsElement),CI($F.grouping.turns[0],n.metricsElement)}t&&AI(),NI()}function FI(e){if(!$F)return;let t=xF($F.grouping,e);if(nI()&&!KF&&UF){for(let e of t)jI(e);PI()}else UF=null,PI(),nI()?OI():KF=!0}function II(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 LI(){tI&&!eI&&(tI=!1,lI())}function RI(e){if(!UF)return;let t=GF[0]??null,n=t?.rowsElement.parentElement??null,r=$F?.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=SI(r),o=TI(r,e.mergedHead,a);n.insertBefore(o,i),t.metricsElement=a}e.mergedHead||CI(r,t.metricsElement);let a=document.createDocumentFragment();for(let t of e.mergedRows)a.append(xI(t,r.startedAt));i.prepend(a),wI(i,r)}let i=document.createDocumentFragment(),a=[];for(let t of e.newTurns){let e=EI(t);a.push(e),i.append(e.section)}UF.prepend(i),GF.unshift(...a)}function zI(e){if(!$F)return;let t=SF($F.grouping,e),n=nI()&&!KF&&!!UF&&!t.needsRerender,r=VF?.parentElement??null,i=r?.scrollHeight??0,a=r?.scrollTop??0;n&&RI(t),PI(),n||kI(),n&&AI(),r&&(r.scrollTop=a+r.scrollHeight-i)}function BI(e){VF||(VF=m(`div`,`trace-panel`),e.append(VF),OI())}function VI(e){JF=e}function HI(e){YF=e}function UI(e){QF=e,YF?.()}function WI(e){XF=kF(e);let t=sI(nI());t&&lI(),(t||!HF)&&kI(),!t&&HF&&AI()}function GI(){if(!VF)return;let e=sI(!0);lI(!0),FF({hasSelectionChanged:e,isRenderedTraceStale:KF,hasRenderedOnce:!!HF})&&OI()}function KI(e){let t=II(e);if(!t)return;let n=PF({pendingRequest:eI?.request??null,resident:$F?{sessionId:$F.sessionId,firstOffset:$F.firstOffset,nextOffset:$F.nextOffset,hasLoadedOnce:$F.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});n===`ignore`?LI():(iI(),n===`stale`?LI():n===`reset`?(oI(t.id),$F&&($F.filePath=t.path),lI(),kI(),LI()):$F&&($F.filePath=t.path,n===`prepend`?($F.firstOffset=t.start,zI(t.records),LI()):(n===`seed`&&($F.hasLoadedOnce=!0,$F.firstOffset=t.start),$F.nextOffset=t.next,FI(t.records),LI())))}function qI(e){let t=e?.id;typeof t==`string`&&t===ZF&&nI()&&(eI?tI=!0:lI())}function JI(e){let t=e?.id;typeof t==`string`&&eI?.request.id===t&&(iI(),tI=!1,kI())}function YI(e){iI(),tI=!1,e?lI():kI()}var XI=`Estimated list prices, not a bill.`,ZI=`Enable in Settings.`,QI=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}]),$I=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],eL=/^(\d{4})-(\d{2})-(\d{2})$/,tL=new Set([`day`,`model`,`label`]),nL=new Set([`model`,`label`]);function rL(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function iL(e){return e.includes(`.`)?e.replace(/0+$/,``).replace(/\.$/,``):e}function aL(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e);return`${t<0?`-`:``}${rL(String(Math.abs(t)))}`}function oL(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}$${rL(r)}.${i}`}function sL(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}${iL((n/1e3).toFixed(1))}k`:n<999995e3?`${t}${iL((n/1e6).toFixed(2))}M`:`${t}${iL((n/1e9).toFixed(2))}B`}function cL(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:e>0&&e<.1?`<0.1%`:`${iL(e.toFixed(1))}%`}function lL(e){let t=Number(e?.costUSD);return Number.isFinite(t)&&t>0?`costUSD`:`tokens`}function uL(e){return e===`costUSD`?`share of cost`:`share of tokens`}function dL(e,t){let n=Number(e),r=Number(t);return!Number.isFinite(n)||!Number.isFinite(r)||r<=0?null:n/r*100}function fL(e){let t=eL.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=$I[Number(t[2])-1];return n?`${n} ${Number(t[3])}`:String(e)}function pL(e){let t=mL(e);return t.length===0?``:t.length===1?fL(t[0]):`${fL(t[0])} to ${fL(t[t.length-1])}`}function mL(e){return(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?e:e?.day).map(e=>String(e??``)).filter(e=>eL.test(e)).sort()}function hL(e){let t=Number(e?.ts);return!Number.isFinite(t)||t<=0?``:gL(t,typeof e?.tz==`string`&&e.tz?e.tz:null)}function gL(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`};t&&(n.timeZone=t);let r=_L(e,n);return eL.test(r)?r:_L(e,{year:`numeric`,month:`2-digit`,day:`2-digit`})}function _L(e,t){try{return new Intl.DateTimeFormat(`en-CA`,t).format(new Date(e))}catch{return``}}function vL(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`-`:Ch(Math.round(e)*60,{smallestUnit:`m`,dropsZeroRemainder:!0})}function yL(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return`-`;let n=new Date(t),r=$I[n.getMonth()];return r?`${r} ${n.getDate()} ${Dh(n)}`:`-`}function bL(e){if(!e||typeof e!=`object`)return[];let t=[];if(Number.isFinite(e.tokensPerMinute)){let n=Number.isFinite(e.tokensPerMinuteExCache)?`${sL(e.tokensPerMinuteExCache)} excluding cache`:``;t.push({label:`tokens per min`,value:sL(e.tokensPerMinute),sub:n})}return Number.isFinite(e.costPerHour)&&t.push({label:`cost per hour`,value:oL(e.costPerHour),sub:``}),t}function xL(e){if(!e||typeof e!=`object`)return``;let t=[];Number.isFinite(e.projectedTokens)&&t.push(`${sL(e.projectedTokens)} tokens`),Number.isFinite(e.projectedCostUSD)&&t.push(oL(e.projectedCostUSD));let n=Number.isFinite(e.remainingMinutes)?`${vL(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 SL(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 CL(e){return typeof e!=`number`||!Number.isFinite(e)?`ok`:e>=100?`crit`:e>=80?`warn`:`ok`}function wL(e){let t=V(e?.max,null);return t===null||t<=0?null:t}function TL(e){let t=wL(e),n=V(e?.pct,null);return t===null||n===null?null:n*100}function EL(e,t){let n=wL(t),r=V(e?.projectedTokens,null);return n===null||r===null?null:r/n*100}function DL(e){let t=TL(e);return t===null?``:`${Math.round(t)}% of ${sL(e?.max)} tokens, the largest completed block seen`}function OL(e,t){let n=EL(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 kL=Object.freeze([{key:`input`,label:`input`},{key:`output`,label:`output`},{key:`cacheCreate`,label:`cache write`},{key:`cacheRead`,label:`cache read`}]);function AL(e){let t=kL.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=dL(e.tokens,n)??0,r=sL(e.tokens);return{key:e.spec.key,label:e.spec.label,value:r,pct:t,title:`${e.spec.label} ${r}, ${cL(t)}`}})}var jL=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`}),ML=`Sessions spawned by Glimmervoid; terminal sessions count as other`,NL=`Claude sessions Glimmervoid spawned for its own work; plan share is estimated pro rata by cost`;function PL(e){let t=_c(e,``);return t?jL[t]||t:jL.other}function FL(e){let t=e?.byLane;return Array.isArray(t)?t.filter(e=>e&&typeof e.lane==`string`):[]}function IL(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`interactive`&&t!==`other`}function LL(e){return FL(e).some(e=>IL(e.lane))}var RL=Object.freeze({fiveHour:`This 5 hour block`,sevenDay:`7 day window`});function zL(e,t,n){let r=LR(e,t);return!r||r.resetsAtMs!==null&&r.resetsAtMs<=n?null:r.pct}function BL(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+V(t.costUSD,0),0),o=i.reduce((e,t)=>e+V(t.tokens,0),0),s=i.filter(e=>IL(e.lane)).map(e=>({lane:String(e.lane),label:PL(e.lane),tokens:V(e.tokens,0),costUSD:V(e.costUSD,0)})),c=s.reduce((e,t)=>e+t.costUSD,0),l=s.reduce((e,t)=>e+t.tokens,0),u=a>0?dL(c,a):dL(l,o),d=zL(n,e,r),f=u===null||d===null?null:u/100*d;return{key:e,label:RL[e],tokens:l,costUSD:c,sharePct:u,planPct:f,lanes:s}}function VL(e,t,n=Date.now()){let r=e?.planWindowLanes;return!r||typeof r!=`object`?[]:IR.map(e=>BL(e.key,r[e.key],t,n)).filter(e=>e!==null)}function HL(e){return e.planPct===null?``:`about ${cL(e.planPct)} of plan`}function UL(e){return e.lanes.filter(e=>e.costUSD>0||e.tokens>0).map(e=>`${e.label} ${e.costUSD>0?oL(e.costUSD):sL(e.tokens)}`).join(`, `)}var WL=`team-review`;function GL(e){if(!Array.isArray(e?.byLane))return null;let t=FL(e).find(e=>e.lane===WL),n=V(t?.costUSD,0),r=V(t?.tokens,0),i=lL(e?.totals),a=dL(i===`costUSD`?n:r,e?.totals?.[i]),o=a===null?``:`${cL(a)} of range ${i===`costUSD`?`cost`:`tokens`}`,s=[oL(n),o,KL(t?.sessions)].filter(Boolean).join(`, `);return{label:PL(WL),value:sL(r),sub:s}}function KL(e){let t=V(e,null);return t===null||t<=0?``:`${aL(t)} ${t===1?`session`:`sessions`}`}function qL(e){let t=e?.rtk;return!t||typeof t!=`object`||t.available!==!0?null:t}function JL(e){let t=e?.cache;return!t||typeof t!=`object`?null:t}function YL(e){return qL(e)!==null||JL(e)!==null}function XL(e){let t=qL(e);if(!t)return null;let n=V(t.commands,0),r=n===1?`command`:`commands`;return{value:`${sL(V(t.savedTokens,0))} tokens`,sub:`${cL(V(t.savingsPct,0))} avg across ${aL(n)} ${r}`}}function ZL(e){let t=JL(e);if(!t)return null;let n=sL(V(t.cacheReadTokens,0)),r=(Array.isArray(t.unpricedModels)?t.unpricedModels:[]).filter(e=>e),i=`${n} cache read tokens`;if(r.length===0)return{value:oL(V(t.savedUSD,0)),sub:i};let a=r.length===1?`model`:`models`;return{value:oL(V(t.savedUSD,0)),sub:`${i}, a floor (${r.length} unpriced ${a})`}}function QL(e){let t=e?.budget?.rows;return Array.isArray(t)?t.filter(e=>e&&V(e.budgetUsd,null)!==null):[]}function $L(e){return e===`monthly`?`this month`:`today`}function eR(e){return`${oL(V(e?.spentUsd,0))} of ${oL(V(e?.budgetUsd,0))}`}function tR(e){let t=V(e?.pct,null);return t===null?0:t}function nR(e){return`${$L(e?.scope)} spend against budget`}var rR=Object.freeze([{value:`day`,label:`Day`},{value:`week`,label:`Week`},{value:`month`,label:`Month`}]);function iR(e){let t=eL.exec(String(e??``));return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12):null}function aR(e){let t=iR(e);if(!t)return``;let n=(t.getDay()+6)%7;return t.setDate(t.getDate()-n),Eh(t)}function oR(e){let t=eL.exec(String(e??``));return t?`${t[1]}-${t[2]}`:``}function sR(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 cR(e,t){e.tokens+=V(t?.tokens,0),e.costUSD+=V(t?.costUSD,0),e.input+=V(t?.input,0),e.output+=V(t?.output,0),e.cacheCreate+=V(t?.cacheCreate,0),e.cacheRead+=V(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=oz(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+=V(t?.tokens,0),r.costUSD+=V(t?.costUSD,0),r.input+=V(t?.input,0),r.output+=V(t?.output,0),r.cacheCreate+=V(t?.cacheCreate,0),r.cacheRead+=V(t?.cacheRead,0),e.modelByName.set(n,r)}}function lR(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 uR(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)||sR(r);cR(i,e),n.set(r,i)}return Array.from(n.values()).map(lR)}function dR(e){return uR(e,aR)}function fR(e){return uR(e,oR)}function pR(e,t){return t===`week`?dR(e):t===`month`?fR(e):Array.isArray(e)?[...e]:[]}var mR=/^(\d{4})-(\d{2})$/;function hR(e,t){if(t===`month`){let t=mR.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=$I[Number(t[2])-1];return n?`${n} ${t[1]}`:String(e)}if(t===`week`){let t=fL(e);return t===`-`?t:`week of ${t}`}return fL(e)}function gR(e){return(Array.isArray(e)?e:[]).some(e=>e?.source===`history`)?`older days from local history`:``}var _R=Object.freeze([.05,.25,.5,.75]),vR=Object.freeze([`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`]);function yR(e,t){let n=V(e,0),r=V(t,0);if(n<=0||r<=0)return 0;let i=n/r,a=1;for(let e=0;e<_R.length;e+=1)i>=_R[e]&&(a=e+1);return a}function bR(e,{weeks:t=16,today:n=new Date}={}){let r=(Array.isArray(e)?e:[]).filter(e=>eL.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`&&eL.test(n)?n:Eh(o),c=iR(aR(s));if(!c)return{cells:[],max:0,weeks:0};let l=new Date(c.getFullYear(),c.getMonth(),c.getDate()-(t-1)*7,12),u=Eh(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,V(e.tokens,0)))}for(let e=0;e<t;e+=1)for(let t=0;t<7;t+=1){let n=Eh(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:V(r?.tokens,0),costUSD:V(r?.costUSD,0),source:r?.source===`history`?`history`:r?`live`:null,noData:a||o||!r&&p===null,tone:yR(r?.tokens,f)})}return{cells:d,max:f,weeks:t}}function xR(e){let t=fL(e?.day);if(e?.noData)return`${t}: no data`;let n=V(e?.tokens,0);return n<=0?`${t}: no usage`:`${t}: ${sL(n)} tokens, ${oL(V(e?.costUSD,0))}`}function SR(e){if(!e)return``;let t=V(e.baselineDays,null),n=t===null?`recent`:`${Math.round(t)} day`;return`Today is ${DR(e.ratio)} the ${n} average: ${oL(e.todayUsd)} against ${oL(e.baselineUsd)}.`}function CR(e){return e?`This block is burning ${DR(e.ratio)} the usual rate: ${sL(e.current)} tokens per minute against ${sL(e.baseline)}.`:``}function wR(e){return[SR(e?.daily),CR(e?.burn)].filter(Boolean).join(` `)}function TR(e){return e?.daily||e?.burn?`warn`:`ok`}function ER(e){return!!(e?.daily||e?.burn)}function DR(e){let t=V(e,null);return t===null?`-`:`${iL(t.toFixed(1))}x`}var OR=Object.freeze({claude:`Claude`,codex:`Codex`,grok:`Grok`});function kR(e){let t=_c(e,``);return t?OR[t]||t:OR.claude}function AR(e,t){return MR(t)?kR(e?.vendor):``}function jR(e){let t=e?.byVendor;return!t||typeof t!=`object`?[]:Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`).sort((e,n)=>V(t[n]?.tokens,0)-V(t[e]?.tokens,0)).map(e=>({vendor:e,label:kR(e),tokens:V(t[e]?.tokens,0),costUSD:V(t[e]?.costUSD,0)}))}function MR(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 NR=`Claude only`;function PR(e){return MR(e)?NR:``}var FR=36e5,IR=Object.freeze([{key:`fiveHour`,label:`5 hour`},{key:`sevenDay`,label:`7 day`}]);function LR(e,t){let n=e?.[t];if(!n||typeof n!=`object`)return null;let r=V(n.pct,null),i=V(n.resetsAtMs,null);return r===null&&i===null?null:{pct:r,resetsAtMs:i}}function RR(e){return IR.some(t=>LR(e,t.key)!==null)}function zR(e){return LR(e,`fiveHour`)?.pct??null}function BR(e){return e===`official`?`official, from Claude Code`:e===`estimated`?`estimated from the largest completed block`:``}function VR(e,t=null){let n=zR(t);if(n!==null)return CL(n);let r=CL(TL(e?.tokenLimit));return r===`ok`?CL(EL(e?.activeBlock?.projection,e?.tokenLimit)):r}function HR(e,t=null){let n=[],r=VR(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 QL(e)){let e=tR(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 Hh(n)}function UR(e){let t=V(e?.pct,null);return t===null?`-`:`${cL(t)} used`}function WR(e,t=Date.now()){let n=V(e,null);if(n===null||n<=0)return``;let r=(n-t)/6e4;return r<=0?`resetting now`:`resets in ${vL(r)}`}function GR(e,t=Date.now()){let n=V(e,null);return n===null||n<=0?``:`${Math.max(0,Math.round((t-n)/6e4))}m old`}function KR(e,t=Date.now()){let n=V(e,null);return n===null||n<=0||t-n>FR}function qR(e,t=Date.now()){if(!KR(e,t))return``;let n=GR(e,t);return n?`showing last-known usage (${n})`:`showing last-known usage`}function JR(e,t=``){let n=e?.source;if(n===`fetched`){let e=_c(t,``);return e?`Prices fetched from the public model price table, ${e}.`:`Prices fetched from the public model price table.`}if(n===`cache`){let e=_c(t,``);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 YR(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 XR(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 ZR(e){if(Array.isArray(e))return e.length;let t=Number(e);return Number.isFinite(t)?t:null}function QR(e){if(!e||typeof e!=`object`)return``;let t=[],n=ZR(e.dirs);if(n!==null&&t.push(`${aL(n)} transcript ${n===1?`directory`:`directories`}`),Number.isFinite(e.files)&&t.push(`${aL(e.files)} files`),Number.isFinite(e.entries)&&t.push(`${aL(e.entries)} entries`),Number.isFinite(e.lastScanMs)&&t.push(`last pass ${aL(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 $R(e){return _c(e?.error,``)}function ez(e){let t=_c(e?.warning,``);return t?`Glimmervoid could not read every transcript location: ${t}`:``}function tz(e){return $R(e)!==``}function nz(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return n==null||n===t}function rz(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 iz(e){return typeof e?.id==`string`&&e.id!==``}function az(e){let t=_c(e?.label,``);return iz(e)&&t?t:rz(e?.project)||t||`unknown project`}function oz(e){return _c(typeof e==`string`?e:e?.model,`unknown model`)}function sz(e){return String(e?.day??``)}function cz(e,t,n){if(!tL.has(t)){let n=Number(e?.[t]);return Number.isFinite(n)?n:0}return t===`day`?sz(e):n(e)}function lz(e,t,n,r=az){let i=Array.isArray(e)?[...e]:[],a=n===`asc`?1:-1;return i.sort((e,n)=>{let i=cz(e,t,r),o=cz(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 uz(e){return nL.has(e)?`asc`:`desc`}function dz(e,t){return e?.key===t?{key:t,dir:e.dir===`asc`?`desc`:`asc`}:{key:t,dir:uz(t)}}function fz(e,t){return e?.key===t?e.dir===`asc`?`ascending`:`descending`:`none`}var pz=Object.freeze({key:`lastTs`,dir:`desc`}),mz=Object.freeze({key:`tokens`,dir:`desc`}),hz=Object.freeze({key:`day`,dir:`desc`});function gz(e,t=pz){return lz(e,t.key,t.dir,az)}function _z(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 vz(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:`${aL(t)} hidden`}function yz(e,t=mz){return lz(e,t.key,t.dir,oz)}function bz(e,t=hz){return lz(e,t.key,t.dir,sz)}function xz(e,t){return(Array.isArray(e)?e:[]).find(e=>String(e?.day??``)===String(t??``))||null}function Sz(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 Cz(e){let t=V(e?.officialCostUSD,null);if(t!==null&&t>0)return{costUSD:t,source:`official`};let n=V(e?.costUSD,null);return n!==null&&n>0?{costUSD:n,source:`estimated`}:{costUSD:null,source:null}}function wz(e){let t=Number(e?.tokens);if(!Number.isFinite(t)||t<=0)return``;let{costUSD:n}=Cz(e);return n===null?sL(t):`${sL(t)} ${oL(n)}`}function Tz(e){let{source:t}=Cz(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`}function Ez(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)} ${t>1?`need`:`needs`} 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 Dz=!1,Oz=new Set;function kz(e){Dz=!!e,nB();for(let e of Oz)e(Dz)}function Az(e){return Oz.add(e),()=>Oz.delete(e)}function jz(){return Dz}var Mz=null;function Nz(e){Mz=e}var Pz=[{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:`guardrails-badge`,text:`guardrails`,title:`Guardrails on: credentials, Glimmervoid state and blocked folders are off-limits to this session`,ariaLabel:`Guardrails on`},{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 Fz({cls:e,text:t=``,title:n,ariaLabel:r,ariaHidden:i}){let a=m(`span`,e,t);return n&&(a.title=n),r&&a.setAttribute(`aria-label`,r),i&&a.setAttribute(`aria-hidden`,`true`),a}function Iz(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 Lz(e,t){t&&(e.dataset.saneYolo=``),t||delete e.dataset.saneYolo;let n=e.querySelector(`.perms-badge`);n&&Iz(n,t)}function Rz(e,t){let n=k(e);n&&Lz(n.card,t)}function zz(e,t,n,r={}){let i=n||a.INITIALIZING,o=m(`div`,`session-card`);o.dataset.id=e,o.dataset.session=t,o.dataset.state=i,r.skipPerms&&(o.dataset.skipPerms=``),r.saneYolo&&(o.dataset.saneYolo=``),r.worktree&&(o.dataset.worktree=``),r.workspace&&(o.dataset.workspace=``),r.guarded&&(o.dataset.guarded=``),r.path&&(o.dataset.path=String(r.path));let s=m(`div`,`session-card-header`),c=m(`span`,`session-name`,t);c.title=`Double-click or press F2 to rename`,c.tabIndex=0;let l=r.skipPerms?m(`span`,`perms-badge`):null;l&&Iz(l,r.saneYolo===!0);let u=m(`span`,`session-task-title`);Uz(u,r.taskTitle);let d=m(`span`,`session-pr-chips session-card-prs`);d.hidden=!0,Mz?.(d,e);let f=m(`span`,`card-elapsed`);f.setAttribute(`aria-hidden`,`true`);let p=m(`div`,`session-actions`),h=m(`div`,`session-overflow`),g=m(`button`,`btn-action btn-restart-menu visible`,`↻`);g.type=`button`,g.title=`Restart`,g.setAttribute(`aria-label`,`Restart`),g.setAttribute(`aria-haspopup`,`menu`),g.setAttribute(`aria-expanded`,`false`);let _=m(`div`,`session-overflow-menu`);_.id=`restart-menu-${e}`,_.setAttribute(`role`,`menu`),g.setAttribute(`aria-controls`,_.id);let v=Bz(`Restart`,`Keeps this conversation`,`overflow-restart`),y=Bz(`Restart fresh`,`Ends this conversation and starts a new one`,`overflow-restart-fresh`),b=Bz(`Resume conversation...`,`Pick an earlier conversation`,`overflow-resume`),x=Bz(`Edit repositories...`,`Add or remove repositories in this workspace`,`overflow-workspace-repos`),S=Bz(`Link pull request...`,`Show a pull request on this card`,`overflow-link-pr visible`),C=Bz(`Conversation view`,`Show this session as messages (experimental)`,`overflow-conversation-view`);C.setAttribute(`role`,`menuitemcheckbox`),C.setAttribute(`aria-checked`,`false`),S.onclick=()=>{_.classList.remove(`open`),g.setAttribute(`aria-expanded`,`false`),Vz(e)},_.append(v,y,b,x,C,S),h.append(g,_);let ee=m(`button`,`btn-action btn-debug`,`⚙`);ee.title=`Debug state`,ee.setAttribute(`aria-label`,`Debug session state`);let te=m(`button`,`btn-action btn-trace`,`≡`);te.type=`button`,te.title=`Trace`,te.setAttribute(`aria-label`,`Trace`);let ne=m(`button`,`btn-action btn-remove visible`,`×`);ne.type=`button`,ne.title=`Remove session`,ne.setAttribute(`aria-label`,`Remove session`);let w=m(`button`,`btn-action btn-face-plan`,`Plan`);w.type=`button`,w.title=`Show plan`;let re=m(`button`,`btn-action btn-face-plan btn-docs`,`Docs`);re.type=`button`,re.title=`Open docs the agent surfaced`;let T=m(`div`,`face-switch`);T.setAttribute(`role`,`group`),T.setAttribute(`aria-label`,`Card view`);let ie=m(`button`,`face-switch-option`,`Terminal`);ie.type=`button`,ie.setAttribute(`aria-pressed`,`true`);let ae=m(`button`,`face-switch-option`,`Conversation`);ae.type=`button`,ae.setAttribute(`aria-pressed`,`false`),T.append(ie,ae),p.append(T,re,w,ee,te,h,ne);let oe=m(`div`,`session-card-tags`),E=Pz.map(e=>Fz(e));l&&E.push(l),oe.append(...E),s.append(c,f,u,d,oe,p);let D=m(`div`,`terminal-wrap`);return o.append(s,D),{card:o,header:s,nameEl:c,elapsedEl:f,taskTitleEl:u,btnRestart:v,btnRestartFresh:y,btnRestartMenu:g,btnResume:b,btnWorkspaceRepos:x,btnConversationView:C,btnTrace:te,btnRemove:ne,btnPlan:w,btnDocs:re,btnDebug:ee,faceSwitch:T,btnFaceTerminal:ie,btnFaceConversation:ae,restartMenu:_,termWrap:D}}function Bz(e,t,n){let r=m(`button`,`overflow-item ${n}`);return r.type=`button`,r.setAttribute(`role`,`menuitem`),r.setAttribute(`aria-label`,e),r.append(m(`span`,`restart-menu-label`,e),m(`span`,`restart-menu-hint`,t)),r}function Vz(e){let{dialog:t,close:n,actions:r,btnCancel:i}=ch({title:`Link pull request`}),a=m(`p`,`dialog-message`,`Paste a GitHub pull request URL or owner/repo#number.`),o=m(`input`,`dialog-input`);o.type=`text`,o.placeholder=`owner/repo#123`,o.autocomplete=`off`,o.spellcheck=!1,o.setAttribute(`aria-label`,`Pull request URL or owner/repo#number`);let s=m(`div`,`dialog-error`);s.setAttribute(`role`,`alert`);let c=m(`button`,`btn-dialog btn-dialog-confirm`,`Link`);c.type=`button`,r.append(c),t.append(a,o,s,r);function l(){let t=Vd(o.value);t?G({type:`link-session-pr`,id:e,key:t})?n():s.textContent=`Not connected to the server.`:s.textContent=`Enter a github.com pull request URL or owner/repo#number.`}i.addEventListener(`click`,n),c.addEventListener(`click`,l),o.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),l())}),requestAnimationFrame(()=>o.focus())}function Hz(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 Uz(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 Wz(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&&G({type:`set-session-title`,id:t,title:r.value.trim()}),n.replaceChildren(),i!==null&&n.setAttribute(`role`,i),a!==null&&n.setAttribute(`tabindex`,a),Uz(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 Gz=`session-rename-input`;function Kz(e){return!!e?.querySelector(`.${Gz}`)}function qz(e,t){let n=e.renameTargetEl?.isConnected?e.renameTargetEl:e.nameEl;if(!n||Kz(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=Gz,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();else{for(let[,t]of E)if(t!==e&&t.card.dataset.session===n){i(),Hg(`Session "${n}" already exists.`);return}G({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 Jz=`<button type="button" class="debug-close" aria-label="Close debug overlay" title="Close">×</button>`;function Yz(e){return e?Oh(new Date(e)):`-`}function Xz(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function Zz(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${Xz(e.quietMs)})`:``}function Qz(e){let t=`<span class="debug-dim">${Yz(e.ts)}</span>`;if(e.kind===`signal`){let n=hj([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${hj(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=Zz(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${hj(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=hj(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${hj(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${hj(e.category||`?`)}: <span class="debug-dim">${hj(e.from||`?`)} → ${hj(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${hj(e.kind||`decision`)}</span>`}function $z(e,t){if(!e.debugOverlay)return;let n=t,r=Jz;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">${hj(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">${hj(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${Yz(e.timestamp)}</span> ${hj(e.from)} → ${hj(e.to)} <span class="debug-label">${hj(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?`${hj(a.signal)} (${hj(a.source||`?`)}${a.confidence?`/${hj(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">${hj(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 ${Xz(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">${hj(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">${Qz(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r}function eB(e,t){if(e.debugOpen){tB(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`${Jz}<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`)&&tB(e)}),G({type:`debug-state`,id:t})}function tB(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function nB(){for(let[,e]of E)e.btnDebug.classList.toggle(`visible`,Dz),e.btnTrace.classList.toggle(`visible`,Dz),!Dz&&e.debugOpen&&tB(e)}function rB(e){let t=typeof e.id==`string`?E.get(e.id):void 0;t?.debugOpen&&$z(t,e.payload)}function iB(e){k(e)?.debugOpen&&G({type:`debug-state`,id:e})}function aB({hasPlan:e,pendingPromptKind:t,hasOpenReview:n,hasApprovedReview:r=!1}){return e&&(n||t===`plan`&&!r)?`plan`:`terminal`}function oB({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}function sB(e,t){return t===a.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 cB(e,t,n){let r=c.includes(t)?`force-restart`:`restart`;return e===`restart-fresh`?{type:r,id:n,fresh:!0}:{type:r,id:n}}function lB(e,t,n){let r=()=>n.send(cB(e,n.readState(),t)),i=sB(e,n.readState());i?n.confirm({...i,onConfirm:r}):r()}var uB=`DORMANT`;function dB(e){return e?Sh(Date.now()-e,{rounding:`round`,wording:`compact`,suffix:` ago`,justNowBelowSeconds:60}):``}function fB(e,t,n){let r=m(`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,dB(e.mtime)].filter(Boolean).join(` · `);return r.innerHTML=`<span class="resume-item-title">${hj(e.title||e.id)}</span><span class="resume-item-meta">${hj(i)}${e.id===t?` · current`:``}</span>`,r.addEventListener(`click`,()=>n(e.id)),r}function pB(e,t={}){let n=(t.currentState||``)===uB,{overlay:r,dialog:i,close:a,actions:o,btnCancel:s}=ch({title:`Resume a conversation`,dialogClass:`dialog resume-dialog`}),c=m(`p`,`dialog-message`,`Pick a Claude conversation from this repo (any worktree) to continue in this card.`),l=m(`div`,`resume-list`);l.setAttribute(`role`,`listbox`),l.setAttribute(`aria-label`,`Resumable conversations`),l.append(m(`div`,`resume-empty`,`Loading conversations...`));let u=m(`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){G({type:`resume-conversation`,id:e,conversationId:t||``}),a(),t&&(n?G({type:`start-session`,id:e}):Hg(`Conversation will resume on this session's next restart.`))}s.addEventListener(`click`,a),u.addEventListener(`click`,()=>d(null)),requestAnimationFrame(()=>s.focus()),Ym(`list-conversations`,{id:e}).then(e=>{if(!r.isConnected)return;let t=e.type===`conversations`?e.conversations:[];if(l.innerHTML=``,e.error){l.append(m(`div`,`resume-empty`,`Could not list conversations: ${e.error}`));return}if(t.length===0){l.append(m(`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(fB(e,n,d))}).catch(e=>{r.isConnected&&(l.innerHTML=``,l.append(m(`div`,`resume-empty`,`Could not list conversations: ${uh(e)}`)))})}var mB={critical:s[a.FAILED],warning:s[a.WAITING],done:s[a.DONE],"":s[a.DORMANT]},hB=null,gB=null,_B=e=>e==null?``:String(e),vB=e=>c.includes(e),yB=e=>l.includes(e),bB=!1;function xB(e){return bB&&X_(e.agent)}function SB(e){return xB(e)&&e.isConversationViewOn&&e.isBorrowed}function CB(e){e.faceSwitch.classList.toggle(`visible`,SB(e)),e.btnConversationView.classList.toggle(`visible`,xB(e)),e.btnConversationView.setAttribute(`aria-checked`,String(e.isConversationViewOn)),e.btnFaceTerminal.setAttribute(`aria-pressed`,String(e.face===`terminal`)),e.btnFaceConversation.setAttribute(`aria-pressed`,String(e.face===`conversation`))}function wB(e){bB=e;for(let t of E.values())!e&&t.face===`conversation`&&t._showTerminalFace?.(),AB(t)}function TB(e){let t=k(e);return!t||!SB(t)?!1:(t.face=`conversation`,t.card.dataset.face=`conversation`,t.termWrap.hidden=!0,t.planFace.hide(),t.conversationFace.show(O(e)),AB(t),!0)}function EB(e,t){let n=k(e);if(!n)return;let r=n.isConversationViewOn;n.hasConversationBridge=t.hasConversationBridge,n.conversationApproval=t.conversationApproval,n.isConversationViewOn=t.isConversationViewOn,AB(n),n.conversationFace.refresh(),r!==t.isConversationViewOn&&(n.prefersConversation=t.isConversationViewOn,t.isConversationViewOn?TB(e):n.face===`conversation`&&n._showTerminalFace?.())}function DB(e){return k(e.id)?.conversationFace.applyTraceResponse(e)===!0}function OB(e){k(e.id)?.conversationFace.applyTraceError(e)}function kB(e){k(e)?.conversationFace.applyTraceChanged(O(e))}function AB(e){CB(e);let t=e.currentState,n=vB(t)||yB(t);e.btnRestart.classList.toggle(`visible`,n),e.btnRestartFresh.classList.toggle(`visible`,n),e.btnResume.classList.add(`visible`),e.btnWorkspaceRepos.classList.toggle(`visible`,e.card.dataset.workspace!==void 0),e.btnTrace.classList.toggle(`visible`,jz()),e.btnPlan.classList.toggle(`visible`,oB(e)!==`hidden`),e.btnRemove.classList.add(`visible`)}function jB(e){e.restartMenu.classList.remove(`open`),e.btnRestartMenu.setAttribute(`aria-expanded`,`false`)}function MB(e,t){Hz(e.taskTitleEl,()=>Wz(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),qz(e,t)}),e.nameEl.addEventListener(`click`,()=>{Kz(e.nameEl)||L_(t)}),e.nameEl.addEventListener(`keydown`,n=>{n.target===e.nameEl&&(n.key===`F2`||n.key===`Enter`)&&(n.preventDefault(),qz(e,t))});function n(n){jB(e),e.btnRestartMenu.focus(),lB(n,t,{readState:()=>e.currentState,send:G,confirm:lh})}e.btnRestart.addEventListener(`click`,()=>n(`restart`)),e.btnRestartFresh.addEventListener(`click`,()=>n(`restart-fresh`)),e.btnResume.addEventListener(`click`,()=>{jB(e),pB(t,{currentState:e.currentState})}),e.btnWorkspaceRepos.addEventListener(`click`,()=>{jB(e),Tre(t)}),e.btnTrace.addEventListener(`click`,()=>{jB(e),UI(t)}),e.btnDocs.addEventListener(`click`,()=>{jB(e),aae(t)}),e.btnConversationView.addEventListener(`click`,()=>{jB(e),G({type:`set-session-conversation-view`,id:t,isOn:!e.isConversationViewOn})}),e.btnFaceTerminal.addEventListener(`click`,()=>{e.prefersConversation=!1,e._showTerminalFace?.()}),e.btnFaceConversation.addEventListener(`click`,()=>{e.prefersConversation=!0,TB(t)}),e.btnPlan.addEventListener(`click`,()=>{let n=oB(e);n!==`hidden`&&(n===`face`?HB(t):location.hash=mM(t))}),e.btnRemove.addEventListener(`click`,()=>{jB(e);let n=e.card.dataset.session,r=e.card.dataset.merge,i=r===`pending-review`||r===`parked`;lh({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:()=>G({type:`remove-session`,id:t})})}),e.btnRestartMenu.addEventListener(`click`,t=>{t.stopPropagation();for(let[,t]of E)t!==e&&jB(t);let n=e.restartMenu.classList.toggle(`open`);e.btnRestartMenu.setAttribute(`aria-expanded`,String(n))});let r=[e.btnRestart,e.btnRestartFresh,e.btnResume,e.btnWorkspaceRepos,e.btnConversationView];function i(t){if(t.key!==`ArrowDown`&&t.key!==`ArrowUp`)return;t.preventDefault(),t.stopPropagation();for(let[,t]of E)t!==e&&jB(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(),jB(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&&jB(e)},{signal:e.abortController.signal}),e.termWrap.addEventListener(`mousedown`,()=>{(e.currentState===a.WAITING||e.currentState===a.COMPLETE)&&G({type:`dismiss`,id:t})}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),eB(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&tB(e)},{signal:e.abortController.signal})}function NB(e,t,n){let r=k(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&Uz(e,r.taskTitle)}}function PB(e){return typeof e==`string`&&E.has(e)}function FB(){return E.size}function IB(e){let t=e||{};t.cursorBlink!=null&&Hce(t.cursorBlink),t.debugMode!=null&&(kz(t.debugMode),dle(t.debugMode));for(let[,e]of E)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function LB(){eT(E.values(),nT())}function RB(){if(!ce)return;let e=0,t=0,n=0,r=0,i=0,o=0;for(let[,s]of E){o++;let c=s.currentState;c===a.WAITING?e++:c===a.FAILED?t++:c===a.DONE?n++:c===a.COMPLETE?r++:c===a.DORMANT&&i++}let{text:s,severity:c,alertCount:l}=Ez({waiting:e,failed:t,done:n,complete:r,dormant:i,total:o});if((s!==hB||c!==gB)&&(hB=s,gB=c,ce.dataset.severity=c,ce.textContent=``,ce.title=s,s)){let e=m(`span`,`aggregate-glyph`,mB[c]??mB[``]);e.setAttribute(`aria-hidden`,`true`),ce.append(e,m(`span`,`aggregate-text`,s))}document.title=l>0?`(${l}) Glimmervoid`:`Glimmervoid`}function zB(e,t,n,r={}){if(!se)return;let i=O(e),o=_B(n)||a.DORMANT,s=zz(i,_B(t),o,r),c=o===a.DORMANT;se.appendChild(s.card);let l;function u(){l.face=`terminal`,l.card.dataset.face=`terminal`,l.termWrap.hidden=!1,l.planFace.hide(),l.conversationFace.hide(),AB(l),fj(l,i)}let d=new AbortController,f=fM({signal:d.signal,requestPlan:(e,t,n)=>G({type:`session-plan`,id:e,agentId:t,revision:n}),requestDraft:(e,t)=>G({type:`session-plan`,id:e,agentId:t,draft:!0}),showTerminal:u,sendDecision:(e,t)=>G({type:`plan-decision`,id:e,...t}),reportProblem:e=>Hg(`${s.nameEl.textContent||i}: ${e}`)}),p=ole({signal:d.signal,sendControl:e=>G(e),showTerminal:()=>{l.prefersConversation=!1,u()}});return l={term:null,fitAddon:null,webglAddon:null,needsWebGLReload:!1,webglAttachedWithoutLayout:!1,dataWs:null,card:s.card,nameEl:s.nameEl,taskTitleEl:s.taskTitleEl,taskTitle:r.taskTitle??null,taskTitleIsCustom:r.taskTitleIsCustom??!1,elapsedEl:s.elapsedEl,path:_B(r.path),stateSince:typeof r.stateSince==`number`&&Number.isFinite(r.stateSince)?r.stateSince:Date.now(),restartMenu:s.restartMenu,termWrap:s.termWrap,btnDebug:s.btnDebug,btnRestart:s.btnRestart,btnRestartFresh:s.btnRestartFresh,btnRestartMenu:s.btnRestartMenu,btnResume:s.btnResume,btnWorkspaceRepos:s.btnWorkspaceRepos,btnConversationView:s.btnConversationView,btnTrace:s.btnTrace,btnPlan:s.btnPlan,faceSwitch:s.faceSwitch,btnFaceTerminal:s.btnFaceTerminal,btnFaceConversation:s.btnFaceConversation,btnDocs:s.btnDocs,btnRemove:s.btnRemove,debugOverlay:null,debugOpen:!1,abortController:d,currentState:o,face:`terminal`,isBorrowed:!1,hasPlan:!1,pendingPromptKind:null,planReviewState:{reviews:[]},planFace:f,conversationFace:p,prefersConversation:!1,conversationApproval:null,hasConversationBridge:!1,isConversationViewOn:!1},l._ensureTerminalReady=()=>fj(l,i),l._showTerminalFace=u,l._showPreferredFace=()=>{BB(l)===`plan`?HB(i):l.prefersConversation&&TB(i)||u()},l._setBorrowed=e=>{l.isBorrowed=e,AB(l)},s.card.append(f.el,p.el),E.set(i,l),MB(l,i),AB(l),l.btnDocs.classList.toggle(`visible`,n_(i)),o===a.RUNNING&&Nh(l,!0),c||(sj(s.termWrap,l),cj(l,i)),RB(),l}function BB(e){let t=e.planReviewState.reviews.some(e=>e.state===`open`),n=e.planReviewState.reviews.some(Lj);return aB({hasPlan:e.hasPlan,pendingPromptKind:e.pendingPromptKind,hasOpenReview:t,hasApprovedReview:n})}function VB(e){let t=k(e);return!t?.isBorrowed||BB(t)!==`plan`?!1:HB(e)}function HB(e){let t=k(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.conversationFace.hide(),t.planFace.show(O(e)),AB(t),!0)}function UB(e,t){let n=k(e);n&&(n.hasPlan=t===!0,AB(n),VB(e))}function WB(e){let t=k(e.id);t&&(t.planReviewState=eM(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),AB(t),VB(e.id))}function GB(e){let t=k(e.id);t&&t.planFace.update({draft:e})}function KB(e){let t=k(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),AB(t))}function qB(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return;let t=k(e.id);t&&(e.scope===`plan`?t.planFace.update({requestFailed:!0}):t.planFace.update({decisionRefused:!0}))}function JB(e){for(let[,t]of E)t.planFace.update({isConnected:e})}function YB(e,t){let n=k(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function XB(e,t){let n=k(e);if(!n)return;n.agent=typeof t==`string`?t:null,AB(n);let r=fre(t);$B(n,`.agent-badge`,`agent`,{on:r!==``,value:r,text:r})}function ZB(e,t){let n=k(e);n&&(t?n.card.dataset.worktree=``:delete n.card.dataset.worktree)}function QB(e,t){let n=k(e);n&&(t?n.card.dataset.guarded=``:delete n.card.dataset.guarded)}function $B(e,t,n,r){let{on:i,value:a=``,text:o,title:s}=r,c=e.card.querySelector(t);if(i)e.card.dataset[n]=a,c&&(o!==void 0&&(c.textContent=o),s!==void 0&&(c.title=s));else{if(delete e.card.dataset[n],!c)return;o!==void 0&&(c.textContent=``),s!==void 0&&c.removeAttribute(`title`)}}function eV(e,t){let n=k(e);n&&$B(n,`.session-card-prs`,`prAttention`,{on:t})}function tV(e,t,n=!1){let r=k(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=C(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function nV(e,t){let n=k(e);if(!n)return;let r=wz(t);$B(n,`.usage-badge`,`usage`,{on:!!r,text:r||``,title:r?Tz(t):void 0})}function rV(e,t,n){return t?{on:!0,value:`compacting`,title:`Context compaction in progress`,text:`compacting`}:e?{on:!0,value:_B(e),title:`Waiting on a permission or input prompt`,text:e===`plan`?`Plan ready`:e===`permission`?`permission`:`input`}:n?{on:!0,value:`memory`,title:`Held until Glimmervoid has enough free memory to start it`,text:`Waiting for memory`}:{on:!1,title:``,text:``}}function iV(e,t,n=!1,r=!1){let i=k(e);i&&(i.pendingPromptKind=typeof t==`string`?t:null,$B(i,`.prompt-badge`,`prompt`,rV(t,n,r)),i.conversationFace.refresh(),VB(e))}function aV(e){return e?`sleeping until ~${Dh(new Date(e))}`:`scheduled`}function oV(e,t){let n=k(e);n&&$B(n,`.wakeup-badge`,`wakeup`,{on:!!t,value:t?.kind||`wakeup`,text:aV(t?.at),title:t?.reason?`Scheduled revival: ${t.reason}`:`Scheduled revival pending`})}function sV(e,t){let n=k(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`;$B(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 cV(e,t){t===`pending-review`||t===`parked`||t===`merging`?e.dataset.merge=t:delete e.dataset.merge}function lV(e,t,n=null){let r=k(e),i=_B(t)||`none`;r&&cV(r.card,i),HN(O(e),i,_B(n)||null)}function uV(e,t,n=null){let r=k(e),i=_B(t)||`none`;r&&cV(r.card,i),UN(O(e),i,_B(n)||null)}function dV(e,t){WN(O(e),t)}function fV(e,t){let n=k(e);if(!n)return;let r=_B(t);n.card.dataset.session=r,n.nameEl.textContent=r}function pV(e){let t=k(e);t&&(tB(t),E.delete(O(e)),uM(O(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),t.dataWs&&t.dataWs.readyState<=WebSocket.OPEN&&t.dataWs.close(),RA(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),RB())}function mV(e,t,n){if(!t||!e.term)return;e.term.clear(),e.term.reset();let r=n===a.DONE?`Session complete`:`Session failed`,i=n===a.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 hV(e,t){e.term&&(t===a.DONE||t===a.FAILED)&&(e.term.clear(),e.term.reset())}function gV(e,t,n){let r=document.activeElement;return Aae({previousState:t,nextState:n,isPhoneLayout:fT(),isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),isActiveViewer:e._isActiveViewer?.()===!0,hasFocusInsideTerminal:r instanceof Node&&e.termWrap.contains(r)})}function _V(e,t,n,r=``){let i=k(e);if(!i)return;let o=_B(t),s=i.currentState;i.currentState=o,o!==a.RUNNING&&(i.awaitingBackgroundTasks=!1),i.conversationFace.refresh(),o!==s&&(i.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),Nh(i,o===a.RUNNING)),s===a.DORMANT&&o!==a.DORMANT&&uj(i,O(e)),i.card.dataset.state=o,i.card.toggleAttribute(`data-monitoring`,C(o,i.awaitingBackgroundTasks)),AB(i),(o===a.WAITING&&s!==a.WAITING||o===a.COMPLETE&&s!==a.COMPLETE)&&!Nae(r)&&fp()&&rE(mp()),gV(i,s,o)&&G({type:`dismiss`,id:O(e),expectedState:a.COMPLETE});let c=o===a.DONE||o===a.FAILED,l=s!==a.DONE&&s!==a.FAILED&&s!==a.INITIALIZING;c&&l&&(i.card.classList.remove(`completion-flash`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{i.card.classList.add(`completion-flash`),i.card.addEventListener(`animationend`,()=>i.card.classList.remove(`completion-flash`),{once:!0})})}),fp()&&rE(mp())),(o===a.DONE||o===a.FAILED)&&mV(i,l,o),o===a.INITIALIZING&&hV(i,s),RB(),Fh(i)}var vV=`(no path)`;function yV(e){if(!e)return vV;let t=String(e).replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return(n===-1?t:t.slice(n+1))||`(no path)`}function bV(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):vV,a=i.get(r);a||(a={key:r,label:r===`(no path)`?vV:yV(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:yV(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 xV(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}var SV=null,CV=`plan`;function wV(e){SV=e}function TV(e,t=``){let n=m(e,`session-row ${t}`.trim());return n.innerHTML=`<span class="session-row-glyph" aria-hidden="true"></span><span class="session-row-main"><span class="session-row-name"></span><span class="session-row-meta"><span class="session-row-label"></span><span class="session-row-merge"></span><span class="session-pr-chips session-row-prs" hidden></span></span></span><span class="session-row-elapsed" aria-hidden="true"></span>`,{row:n,refs:{glyph:b(n,`.session-row-glyph`),label:b(n,`.session-row-label`),name:b(n,`.session-row-name`),merge:b(n,`.session-row-merge`),prs:b(n,`.session-row-prs`),elapsed:b(n,`.session-row-elapsed`)}}}function EV(e,t){let n=m(`div`,`session-row-item`),r=m(`button`,`session-row-remove`,`x`);return r.type=`button`,r.title=`Remove session`,r.setAttribute(`aria-label`,`Remove session`),r.addEventListener(`click`,e=>{e.stopPropagation(),t()}),n.append(e,r),{item:n,removeButton:r}}function DV(e,t,n,r=!1,i=null){e.dataset.state=n,e.dataset.prompt=i??``;let{glyph:a,label:o,isMonitoring:s}=ee(n,r),c=i===CV?`Plan ready`:o;return e.toggleAttribute(`data-monitoring`,s),t.glyph.textContent=a,t.label.textContent=c,t.prs&&e.dataset.id&&SV?.(t.prs,e.dataset.id),c}function OV(e,t,{ui:n,state:r,name:i,unseen:a,mergeStatus:o}){e.toggleAttribute(`data-unseen`,a);let s=DV(e,t,r,n.awaitingBackgroundTasks,n.pendingPromptKind);t.name.textContent=i,t.name.append(m(`span`,`session-list-task-title`,n.taskTitle??``)),e.dataset.merge=o,t.merge.textContent=S[o]||``,e.dataset.activity=n._activity||``,t.elapsed.textContent=Ph(n);let c=[i,n.taskTitle,s].filter(Boolean).join(`, `);return e.setAttribute(`aria-label`,c),e.title=c,s}function kV(){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);e.set(r,i),i===a.COMPLETE?n&&n!==a.COMPLETE&&t.add(r):t.delete(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 AV=e=>e.ui.path,jV=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),MV=null,NV=null,PV=null,FV=null,IV=null,LV=null,RV=null,zV=!1,BV=null,VV=new Map,HV=new Map,UV=kV(),WV=new Map,GV=new Map,KV=null,qV=new Set;function JV(){return xV(XV(aH()),qV)}function YV(e){let t=KV;if(KV=e||null,t&&t!==KV){let e=HV.get(t);e&&(e.tabIndex=-1,e.setAttribute(`aria-selected`,`false`))}if(KV){let e=HV.get(KV);e&&(e.tabIndex=0,e.setAttribute(`aria-selected`,`true`))}}function XV(e){return bV(e,AV,P_(e,AV))}function ZV(e){let t=GV.get(e.key),n=WV.get(e.key);if(!t||!n){let r=Object.assign(m(`div`,`focus-rail-group`),{_addBtn:m(`button`,`focus-rail-group-add`,`+`),_forgetBtn:m(`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`,()=>U_(r.dataset.path,r.dataset.label));let a=r._forgetBtn;a.type=`button`,a.addEventListener(`click`,()=>{F_(r.dataset.path),dH()}),r.appendChild(a),r.appendChild(i),t=r,n=m(`div`,`focus-rail-list`),n.setAttribute(`role`,`listbox`),GV.set(e.key,t),WV.set(e.key,n)}b(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===vV,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 QV(){return zV}function $V(){return pe.snapshot().focusedSessionId}function eH({rail:e,center:t,resizer:n}){if(MV=e,PV=t,!MV||!PV)return;let r=MV,i=PV;rH(n),r.removeAttribute(`role`),r.removeAttribute(`aria-label`),r.setAttribute(`aria-keyshortcuts`,jT(NT)),NV=m(`button`,`focus-rail-head`),NV.type=`button`,NV.append(m(`span`,`focus-rail-head-count`),FT(kT(`next-attention`,NT))),NV.addEventListener(`click`,hH),mH(!1,E_({waitingCount:0,finishedCount:0})),r.append(NV),IV=m(`div`,`focus-empty`),IV.innerHTML=`<p class="focus-empty-title"></p><p class="focus-empty-desc"></p>`,LV=IV.querySelector(`.focus-empty-title`),RV=IV.querySelector(`.focus-empty-desc`),FV=m(`div`,`focus-card-slot`),i.append(IV,FV),r.addEventListener(`keydown`,iH)}var tH={minPx:180,maxPx:480},nH=16;function rH(e){e&&MV&&A_({resizer:e,column:MV,widthHost:MV,widthProperty:`--rail-width`,bounds:tH,keyStepPx:nH,getStoredWidth:Op,setStoredWidth:kp})}function iH(e){if(e.key===`Delete`||e.key===`Backspace`){let t=e.target instanceof HTMLElement?e.target:null,n=t?.dataset.id;if(!n||HV.get(n)!==t)return;e.preventDefault(),W_(n,VV.get(n));return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)return;let t=C_(JV(),KV,e.key===`ArrowDown`?1:-1);t!=null&&(e.preventDefault(),YV(t),HV.get(t)?.focus())}function aH(e=H_(oH)){for(let t of e)t.unseen=UV.isUnseen(t.id);return S_(e)}function oH(e){return e.nameEl?e.nameEl.textContent:e.card&&(e.card.dataset.session||e.card.dataset.id)||``}function sH(e){let{row:t,refs:n}=TV(`button`);t.type=`button`,t.dataset.id=e,t.setAttribute(`role`,`option`),t.addEventListener(`click`,()=>cH(e));let{item:r,removeButton:i}=EV(t,()=>W_(e,VV.get(e)));return r.setAttribute(`role`,`presentation`),i.tabIndex=-1,Object.assign(t,{_refs:n,_row:r})}function cH(e){z_(e)&&bH(e)}function lH(e,{id:t,ui:n,state:r,name:i,unseen:a}){let o=VV.get(t)||`none`;OV(e,e._refs,{ui:n,state:r,name:i??``,unseen:a,mergeStatus:o===`none`?``:o}),e.classList.toggle(`focused`,t===$V());let s=t===KV;e.setAttribute(`aria-selected`,String(s)),e.tabIndex=s?0:-1}function uH(e,t){if(!zV)return;let n=e?.card?.dataset.id,r=n?HV.get(n):null;r&&(t===`flag`?r.dataset.activity=e._activity||``:Mh(r._refs?.glyph))}Ah(uH),Lh(()=>{if(zV)for(let[e,t]of HV){let n=E.get(e);n&&(t._refs.elapsed.textContent=Ph(n))}});function dH(){if(!zV)return;let e=MV;if(!e)return;let t=H_(oH);UV.noteStates(t);let n=aH(t),r=XV(n),i=new Set,a=(e,t)=>{let n=e.map(e=>e.id).join(`,`),r=t._lastOrderKey===n&&t.childElementCount===e.length;for(let n of e){let{id:e}=n;i.add(e);let a=HV.get(e);a||(a=sH(e),HV.set(e,a)),lH(a,n),r||t.appendChild(a._row)}t._lastOrderKey=n},o=new Set(r.order);for(let t of r.groups){let{header:n,list:r}=ZV(t);e.appendChild(n),e.appendChild(r),a(t.rows,r)}for(let[e,t]of[...GV])o.has(e)||(t.remove(),WV.get(e)?.remove(),GV.delete(e),WV.delete(e));for(let[e,t]of HV)i.has(e)||(t._row.remove(),HV.delete(e),e===KV&&(KV=null));for(let e of[...VV.keys()])E.has(e)||VV.delete(e);let s=$V();if(s&&!E.has(s)){pe.dispatch(`focusSession`,null),KV=null;let e=n.find(e=>E.has(e.id));if(e){bH(e.id);return}}xH();let c=$V();if(c){let e=E.get(c);e&&e.card.parentElement!==FV&&vH(e,c)}pH()}function fH(){return aH().filter(w_).map(({id:e})=>e)}function pH(){let e=T_(aH());mH(e.waitingCount+e.finishedCount>0,E_(e))}function mH(e,t){NV&&(b(NV,`.focus-rail-head-count`).textContent=t,NV.disabled=!e,e?(NV.removeAttribute(`data-empty`),NV.removeAttribute(`aria-hidden`)):(NV.dataset.empty=``,NV.setAttribute(`aria-hidden`,`true`)))}function hH(){if(!zV)return;let e=fH();if(!e.length)return;let t=vae(e,BV);if(!t)return;BV=t;let n=E.get(t),r=t===$V();z_(t),bH(t),HV.get(t)?.scrollIntoView({block:`nearest`}),r&&_H(t),gH(n,t)}function gH(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{zV&&$V()===t&&e.term?.focus()}))}function _H(e){if(jV?.matches||document.hidden)return;let t=HV.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=E.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function vH(e,t){FV&&(ge(e,t,FV,{className:`focus-centered`}),pj(e,t,!0))}function yH(){let e=$V();e&&(he()===e&&_e(),pe.dispatch(`focusSession`,null))}function bH(e){zV&&E.has(e)&&e!==$V()&&(yH(),pe.dispatch(`focusSession`,e),KV=e,UV.acknowledge(e),B_(e),dH())}function xH(){if(!IV||!LV||!RV)return;let e=$V(),t=!!(e&&E.has(e)),n=E.size>0;IV.hidden=t,yg(IV,!n),LV.hidden=!n,RV.hidden=!n,!t&&n&&(LV.textContent=`No session selected`,RV.textContent=`Select a session from the rail on the left to focus it here.`)}function SH(e,t){VV.set(O(e),typeof t==`string`&&t?t:`none`),zV&&dH()}function CH(e){zV&&E.has(e)&&bH(e)}function wH(e){return!zV||!E.has(e)?!1:(bH(e),HB(e))}function TH(e){if(!zV)return;let t=JV()[e-1];t&&cH(t)}function EH(e){if(!zV)return;let t=C_(JV(),KV,e);t!=null&&(cH(t),HV.get(t)?.scrollIntoView({block:`nearest`}),gH(E.get(t),t))}function DH(){MV&&(zV=!0,yH(),KV=null,dH(),OH())}function OH(){if(!zV||$V())return;let e=V_();e&&bH(e)}function kH(){zV&&=(yH(),KV=null,!1)}var AH=`t-[0-9a-f]{8}`,jH=`No findings. Open a markdown file in a connected editor.`,MH=`No intent yet. The visions proposes one after its first pass.`,NH=`Unowned`,PH=RegExp(`^${AH}$`);function FH(){return{byProject:{},unowned:[]}}function IH(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`&&PH.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 LH(e){if(Array.isArray(e))return e.map(IH).filter(e=>e!==null);let t=IH(e);return t?[t]:[]}function RH(e){let t=e?.intent;if(!t||typeof t!=`object`)return FH();let n=t;if(!(Object.hasOwn(n,`byProject`)||Object.hasOwn(n,`unowned`)||Object.hasOwn(n,`global`)))return{byProject:{},unowned:LH(n)};let r=n.byProject&&typeof n.byProject==`object`?n.byProject:{},i=[];for(let[e,t]of Object.entries(r)){let n=LH(t);n.length!==0&&e&&i.push([e,n])}return{byProject:Object.fromEntries(i),unowned:LH(Object.hasOwn(n,`unowned`)?n.unowned:n.global)}}function zH(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 BH(e,t){let n=e||FH(),r=t?.intent;if(!r||typeof r!=`object`)return n;let i=r,a=zH(Array.isArray(i.threads)?LH(i.threads):LH(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 VH(e,t=null){let n=t&&typeof t.get==`function`?t.get(e):null;return typeof n==`string`&&n?n:e}function HH(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:KH(e,r)}))}function UH(e,t=null,n=Date.now()){let r=e||FH(),i=Object.entries(r.byProject||{}).filter(([e,t])=>e&&Array.isArray(t)&&t.length>0).map(([e,n])=>({projectId:e,label:VH(e,t),threads:n})).sort((e,t)=>e.label.localeCompare(t.label)).flatMap(({projectId:e,label:t,threads:r})=>HH(r,{key:e,label:t,now:n})),a=HH(Array.isArray(r.unowned)?r.unowned:[],{key:`unowned`,label:NH,now:n});return i.length+a.length>0?[...a,...i]:[{key:`unowned`,label:NH,text:MH,hasText:!1,active:!1,meta:``}]}function WH(e){return e?.text?`proposed by visions`:``}function GH(e,t=Date.now()){let n=Number(e);return!Number.isFinite(n)||n<=0?``:Sh(Number(t)-n,{rounding:`floor`,wording:`spelled`,suffix:` ago`,justNowBelowSeconds:60})}function KH(e,t=Date.now()){let n=WH(e);if(!n)return``;let r=typeof e?.id==`string`&&e.id?`thread ${e.id}, `:``,i=GH(e?.ts,t);return i?`${r}${n}, ${i}`:`${r}${n}`}function qH(e){let t=Number(e?.range?.start?.line);return!Number.isFinite(t)||t<0?`L?`:`L${Math.floor(t)+1}`}function JH(e){let t=Number(e?.range?.start?.character);return Number.isFinite(t)?t:0}function YH(e){let t=Number(e?.range?.start?.line);return Number.isFinite(t)?t:0}function XH(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 ZH(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(Math.floor(e),0):0}function QH(e){let t=ZH(e);return t===1?`1 finding`:`${t} findings`}function $H(e){let t=ZH(e);return t===1?`1 comment`:`${t} comments`}function eU(e){let t=ZH(e?.findings?.length),n=ZH(e?.comments?.length),r=typeof e?.hand==`string`&&e.hand?1:0,i=[];return r>0&&i.push(`raised hand`),t>0&&i.push(QH(t)),n>0&&i.push($H(n)),i.length>0?i.join(`, `):QH(0)}function tU(e){let t=typeof e==`string`?e.trim():``;return t?`Raised hand: ${t}`:``}function nU(e){return(typeof e?.hand==`string`?e.hand.trim():``)||null}function rU(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=nU(t);return i?(n.set(r,i),n):(n.delete(r),n)}function iU(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 aU=`hand`,oU=`unseen`,sU=`
262
+ `;function cU(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 lU(e,t){return cU(JSON.stringify([e,...t]))}function uU(e,t){return lU(`finding`,[e,qH(t),String(t.code??``),String(t.message??``)])}function dU(e,t){return lU(`comment`,[e,gU(t),String(t.message??``)])}function fU(e){return lU(`fix`,[e.uri,DU(e),e.code,e.message,OU(e)])}function pU(e){return lU(`intent`,[e.key,e.text,e.active])}function mU(e,t,n,r=[],i=null){let a=[...n].map(([e,t])=>lU(`hand`,[e,t])).sort(),o=new Set;for(let r of[...e.keys(),...t.keys(),...n.keys()])o.add(lU(`document`,[r]));for(let[t,n]of e)for(let e of n)o.add(uU(t,e));for(let[e,n]of t)for(let t of n)o.add(dU(e,t));for(let e of r)o.add(fU(e));for(let e of UH(i,null,0))e.hasText&&o.add(pU(e));let s=[...o].sort();return{signature:[...a,...s].join(sU),handEntries:a,contentEntries:s}}function hU(e,t){let n=new Set(t.split(sU));return e.handEntries.some(e=>!n.has(e))?aU:e.contentEntries.some(e=>!n.has(e))?oU:null}function gU(e){let t=Number(e?.line);return!Number.isFinite(t)||t<1?`L?`:`L${Math.floor(t)}`}function _U(e){return Array.isArray(e?.diagnostics)?e.diagnostics:[]}function vU(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=_U(t);return i.length===0?(n.delete(r),n):(n.set(r,i),n)}function yU(e){return Array.isArray(e?.comments)?e.comments:[]}function bU(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=yU(t);return i.length===0?(n.delete(r),n):(n.set(r,i),n)}function xU(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 SU(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 CU(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:XH(a)||a,hand:s,findings:[...c].sort((e,t)=>YH(e)-YH(t)||JH(e)-JH(t)),comments:[...l].sort((e,t)=>(Number(e?.line)||0)-(Number(t?.line)||0))})}return r.sort((e,t)=>wU(e.name,t.name)||wU(e.uri,t.uri)),r}function wU(e,t){return e<t?-1:+(e>t)}var TU=`No fixes yet. Silent fixes appear here once the lane applies or is refused one.`;function EU(e){let t=ZH(e);return t===1?`1 fix`:`${t} fixes`}function DU(e){let t=Number(e?.line);return!Number.isFinite(t)||t<0?`L?`:`L${Math.floor(t)+1}`}function OU(e){return e?.applied===!0?`applied`:`refused`}function kU(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 AU(e){let t=typeof e?.uri==`string`?e.uri:``,n=Number(e?.ts);return kU(e?.fix,{uri:t,ts:Number.isFinite(n)?n:0})}function jU(e,t,{max:n=20}={}){let r=AU(t);return r?[r,...e].slice(0,Math.max(0,Math.floor(n))):[...e]}function MU(e,{max:t=20}={}){let n=Array.isArray(e?.fixes)?e.fixes:[],r=[];for(let e of n){let t=kU(e);t&&r.push(t)}return r.slice(0,Math.max(0,Math.floor(t)))}var NU=`No activity yet. The ingest lane reports what your sessions and tools are doing.`,PU={terminal:`terminal`,agentLogs:`agent`,git:`git`,fs:`files`,shellHistory:`shell`,editor:`editor`};function FU(e){let t=typeof e==`string`?e:``;return PU[t]||t||`source`}function IU(e,t=Date.now()){let n=Number(e);return!Number.isFinite(n)||n<=0?``:Sh(Number(t)-n,jre)}function LU(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 RU(e){let t=Array.isArray(e?.events)?e.events:[],n=[];for(let e of t){let t=LU(e);t&&n.push(t)}return n}function zU(e){let t=Number(e?.overflow);return!Number.isFinite(t)||t<=0?0:Math.floor(t)}function BU(e){let t=ZH(e);return t<=0?``:t===1?`1 more event not shown`:`${t} more events not shown`}function VU(e,t){return[...e].sort((e,t)=>t.seq-e.seq).slice(0,Math.max(0,Math.floor(t)))}function HU(e,t,{max:n=100}={}){let r=RU(t);if(r.length===0)return VU(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 VU([...i.values()],n)}function UU(e,{max:t=100}={}){return VU(RU(e),t)}function WU(e){let t=ZH(e);return t===1?`1 event`:`${t} events`}function GU(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 KU=new Map,qU=new Map,JU=new Map,YU=FH(),XU=new Map,ZU=null,QU=null,$U=null,eW=null,tW=null,nW=[],rW=0,iW=null,aW=[],oW=null,sW=mU(KU,qU,JU,aW,YU),cW=em(),lW=Uh({getAck:()=>cW,setAck:e=>{cW=e,tm(e)},signature:()=>sW.signature,isLooking:()=>!T(ZU)});function uW(){let e=m(`section`,`visions-intent`);e.append(m(`h2`,`visions-intent-title`,`Intent`));let t=m(`div`,`visions-intent-list`);return e.append(t),$U={list:t},e}function dW(e){let t=m(`div`,`visions-intent-item`),n=m(`div`,`visions-intent-head`);n.append(m(`span`,`visions-intent-scope`,e.label),m(`span`,`visions-intent-meta`,e.meta));let r=m(`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 fW(){$U&&$U.list.replaceChildren(...UH(YU,XU).map(dW))}function pW(e){XU=e instanceof Map?e:new Map,fW()}function mW(e){let t=m(`section`,`visions-doc`),n=m(`div`,`visions-doc-head`),r=m(`h2`,`visions-doc-name`);if(r.textContent=e.name,r.title=e.uri,n.append(r,m(`span`,`visions-doc-count`,eU(e))),t.append(n),e.hand&&t.append(hW(e.hand)),e.findings.length>0){let n=m(`div`,`visions-findings`);for(let t of e.findings)n.append(_W(t));t.append(n)}if(e.comments.length>0){let n=m(`div`,`visions-comments`);for(let t of e.comments)n.append(gW(t));t.append(n)}return t}function hW(e){let t=m(`div`,`visions-hand`);return t.textContent=tU(e),t}function gW(e){let t=m(`div`,`visions-comment`),n=m(`div`,`visions-comment-head`);n.append(m(`span`,`visions-comment-chip`,`visions`)),n.append(m(`span`,`visions-comment-line`,gU(e))),t.append(n);let r=m(`p`,`visions-comment-message`);return r.textContent=e?.message==null?``:String(e.message),t.append(r),t}function _W(e){let t=m(`div`,`visions-finding`);t.append(m(`span`,`visions-finding-line`,qH(e)));let n=e?.code==null?``:String(e.code);n&&t.append(m(`span`,`visions-finding-code`,n));let r=m(`span`,`visions-finding-message`);return r.textContent=e?.message==null?``:String(e.message),t.append(r),t}function vW({force:e=!1}={}){if(!QU||!e&&T(ZU))return;QU.textContent=``;let t=CU(KU,qU,JU);if(t.length===0){let e=m(`p`,`visions-empty`,jH);if(tW===!1){let t=lg(`lanes-visions`,`visions-enabled`,`Enable Visions`);e.append(document.createTextNode(` `),t)}QU.append(e)}else for(let e of t)QU.append(mW(e))}function yW(e){tW=e?.visions?.enabled===!0,vW()}function bW(){let e=m(`section`,`visions-activity`),t=m(`div`,`visions-activity-head`);t.append(m(`h2`,`visions-activity-title`,`Activity`));let n=m(`span`,`visions-activity-count`);t.append(n),e.append(t);let r=m(`div`,`visions-activity-list`);e.append(r);let i=m(`p`,`visions-activity-overflow`);return e.append(i),iW={count:n,list:r,overflow:i},e}function xW(e,t){let n=m(`div`,`visions-activity-row`);n.append(m(`span`,`visions-activity-source`,FU(e.source))),n.append(m(`span`,`visions-activity-age`,IU(e.ts,t))),n.append(m(`span`,`visions-activity-scope`,GU(e)));let r=m(`span`,`visions-activity-summary`);return r.textContent=e.summary,n.append(r),n}function SW({force:e=!1}={}){if(!iW||!e&&T(ZU))return;let{count:t,list:n,overflow:r}=iW;if(t.textContent=WU(nW.length),n.textContent=``,nW.length===0){n.append(m(`p`,`visions-empty`,NU)),r.textContent=``;return}let i=Date.now();for(let e of nW)n.append(xW(e,i));r.textContent=BU(rW)}function CW(){let e=m(`section`,`visions-fixes`),t=m(`div`,`visions-fixes-head`);t.append(m(`h2`,`visions-fixes-title`,`Fixes`));let n=m(`span`,`visions-fixes-count`);t.append(n),e.append(t);let r=m(`div`,`visions-fixes-list`);return e.append(r),oW={count:n,list:r},e}function wW(e){let t=m(`div`,`visions-fix-row`);t.dataset.applied=e.applied?`yes`:`no`;let n=m(`span`,`visions-fix-file`);n.textContent=XH(e.uri)||e.uri,n.title=e.uri,t.append(n),t.append(m(`span`,`visions-fix-line`,DU(e))),t.append(m(`span`,`visions-fix-outcome`,OU(e))),t.append(m(`span`,`visions-fix-code`,e.code||``));let r=m(`span`,`visions-fix-message`);return r.textContent=e.message,t.append(r),t}function TW({force:e=!1}={}){if(!oW||!e&&T(ZU))return;let{count:t,list:n}=oW;if(t.textContent=EU(aW.length),n.textContent=``,aW.length===0)n.append(m(`p`,`visions-empty`,TU));else for(let e of aW)n.append(wW(e))}function EW(){sW=mU(KU,qU,JU,aW,YU),sW.signature!==``&&lW.refresh(),eW&&eW(hU(sW,cW))}function DW(e){eW=e,EW()}function OW(e){if(ZU)return ZU;let t=m(`div`,`visions-content`);t.append(uW());let n=m(`div`,`visions-feed`);return t.append(n),t.append(CW()),t.append(bW()),e.appendChild(t),ZU=t,QU=n,fW(),vW({force:!0}),TW({force:!0}),SW({force:!0}),t}function kW(){fW(),vW({force:!0}),TW({force:!0}),SW({force:!0})}function AW(){sW.signature!==``&&lW.acknowledge(),EW()}function jW(e){aW=jU(aW,e),TW(),EW()}function MW(e){KU=vU(KU,e),vW(),EW()}function NW(e){qU=bU(qU,e),vW(),EW()}function PW(e){JU=rU(JU,e),vW(),EW()}function FW(e){YU=BH(YU,e),fW(),EW()}function IW(e){nW=HU(nW,e),rW=zU(e),SW(),EW()}function LW(e){nW=UU(e),rW=0,SW(),EW()}function RW(e){KU=xU(e),qU=SU(e),JU=iU(e),YU=RH(e),aW=MU(e),fW(),vW(),TW(),EW()}var zW=Co(M(),lo());I({glimmervoidId:M().min(1),event:M().min(1),token:M().nullable().optional(),payload:zW}),I({id:M().min(1),name:M().min(1),event:M().min(1),matcher:M().optional(),type:R([`command`,`http`]),command:M().optional(),url:M().optional(),timeout:N().int().positive().optional(),enabled:P(),projects:F(M()).optional()}).passthrough();var BW=`Claude Code hooks injected into every session Glimmervoid spawns.`,VW=`Loading hooks`,HW=`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.`,UW=`Start from`,WW=`Filter by name, event or command`,GW=`Nothing matches that filter.`,KW=`Preview`,qW=`The entry this becomes in the per-session settings file.`,JW=`Duplicate`,YW=`Discard changes`,XW=`Close the editor and lose the unsaved changes?`,ZW=`Esc cancels. Ctrl+Enter saves.`,QW=`A change reaches a session at its next start or restart. Claude Code sessions only; Codex and Grok sessions do not read this file.`,$W=`Glimmervoid's own hooks`,eG=`Always present, read-only. Status detection depends on them.`,tG=`Your hooks`,nG=`New hook`,rG=`Edit hook`,iG=`Saved to config.json.`,aG=`All projects`,oG=`This event takes no matcher.`,sG=`Blank uses Claude Code's default for the event.`,cG=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.`}]),lG=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`}}]),uG=Object.freeze({hooks:[],builtin:[],events:[]});function dG(e){return!e||typeof e.error==`string`}function fG(e){return!e||typeof e.error!=`string`?``:e.error}function pG(e,t){let n=e?.[t];return Array.isArray(n)?n:uG[t]}var mG=e=>pG(e,`hooks`),hG=e=>pG(e,`builtin`),gG=e=>pG(e,`events`);function _G(e){let t=e?.limits?.maxTimeoutSec;return typeof t==`number`&&Number.isInteger(t)&&t>0?t:600}function vG(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function yG(e){let t=mG(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(hG(e).length),tone:null}]}function bG(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 xG(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 SG(e){return e.length>=4}function CG(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.event===n.event?e.hooks.push(n):t.push({event:n.event,hooks:[n]})}return t}function wG(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 TG(e){return`${e} copy`}function EG(e,t){return e.find(e=>e.name===t)||null}function DG(e,t){let n=EG(e,t);return n?n.matcher?`Matches ${n.matcher}. Blank matches every ${n.name}.`:oG:``}function OG(e){return e.type===`http`?e.url||``:e.command||``}function kG(e){let t=cG.find(t=>t.value===e);return t?t.label:String(e||``)}function AG(e){return!Number.isInteger(e.timeout)||Number(e.timeout)<=0?``:`${e.timeout}s timeout`}function jG(e,t){let n=Array.isArray(e.projects)?e.projects:[];return n.length===0?aG:n.map(e=>{let n=t.find(t=>t.id===e);return n?n.name:e}).join(`, `)}function MG(e){return e.matcher?`${e.event} / ${e.matcher}`:e.event}function NG(e){return MG(e)}function PG(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 FG(e){let t=e[0];return{id:null,name:``,event:t?t.name:``,matcher:``,type:`command`,command:``,url:``,timeout:``,enabled:!0,projects:[]}}function IG(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 LG(e,t,n=600){if(!e.name.trim())return`Give the hook a name.`;let r=EG(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 RG(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 zG(e,t){let n={...FG(t),...e.draft};return EG(t,n.event)||(n.event=FG(t).event),n}function BG(e,t){return JSON.stringify(RG(e))!==JSON.stringify(t)}function VG(e){return{...e,enabled:e.enabled===!1}}function HG(e){return`Delete the hook "${e.name}"? Sessions already running keep it until they restart.`}var UG=null,WG=null,GG=null,KG=null,qG=null,JG=null,YG=null,XG=null,ZG=!1,QG=null,$G=``,eK=new Set,tK=new Set,nK=!1,rK=(e,t)=>ne(`hooks`,e,t);function iK(e,t,n){let r=m(`p`,e,t);return n&&(r.dataset.tone=n),r}function aK(e,t,n,r){let i=m(`button`,e,t);return i.type=`button`,r&&i.setAttribute(`aria-label`,r),i.addEventListener(`click`,n),i}function oK(e){if(!GG)return null;let t=Jm(`hooks`);return GG({requestId:t,...e}),t}function sK(e,t,n){let r=m(`label`,`hooks-field`);return r.append(m(`span`,`hooks-field-label`,e),t),n&&r.append(m(`span`,`hooks-field-hint`,n)),r}function cK(e,t,n){let r=m(`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 lK(e,t){let n=m(`textarea`,`settings-view-input hooks-command`);return n.rows=3,n.value=e,n.spellcheck=!1,n.addEventListener(`input`,()=>t(n.value)),n}function uK(e,t,n){let r=m(`select`,`settings-view-input hooks-select`);for(let n of t){let t=m(`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 dK(e,t){let n=m(`div`,`hooks-type-row`);n.setAttribute(`role`,`radiogroup`);for(let r of cG){let i=m(`label`,`settings-view-toggle hooks-choice`),a=m(`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,m(`span`,null,r.label)),n.append(i)}return n}function fK(e,t){let n=m(`div`,`hooks-projects`);if(t.length===0)return n.append(m(`span`,`hooks-field-hint`,aG)),n;let r=m(`label`,`settings-view-project-choice hooks-choice`),i=m(`input`,`settings-view-checkbox`);i.type=`checkbox`,i.checked=e.projects.length===0,r.append(i,m(`span`,null,aG)),n.append(r);let a=[];for(let r of t){let t=m(`label`,`settings-view-project-choice hooks-choice`),o=m(`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,m(`span`,null,r.name)),r.agent!==`claude-code`&&(t.append(m(`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;else{for(let e of a)e.checked=!1;e.projects=[]}}),n}function pK(e){let t=m(`div`,`hooks-templates`);t.append(m(`span`,`hooks-templates-label`,UW));for(let n of lG){let r=aK(`hooks-chip`,n.label,()=>gK(null,zG(n,e)));r.title=n.summary,t.append(r)}return t}function mK(e){XG&&(XG.textContent=e||``,XG.hidden=!e)}function hK(e){let t=gG(UG),n=re(UG),r=rK(e.id?rG:nG,iG);r.classList.add(`hooks-editor`);let i=m(`form`,`hooks-form`);i.addEventListener(`submit`,e=>{e.preventDefault(),yK()}),i.addEventListener(`keydown`,e=>{e.key===`Escape`?(e.preventDefault(),vK()):e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),yK())}),e.id||i.append(pK(t));let a=m(`span`,`hooks-field-hint`,DG(t,e.event)),o=cK(e.matcher,``,t=>{e.matcher=t}),s=sK(`Command`,lK(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=sK(`URL`,cK(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=sK(`Matcher`,o,null);u.append(a);let d=()=>{let n=t.find(t=>t.name===e.event);a.textContent=DG(t,e.event),o.disabled=!!n&&!n.matcher,o.disabled&&(o.value=``,e.matcher=``)};d();let f=m(`input`,`settings-view-input hooks-timeout`);f.type=`number`,f.inputMode=`numeric`,f.min=`1`,f.max=String(_G(UG)),f.value=e.timeout,f.addEventListener(`input`,()=>{e.timeout=f.value});let p=m(`label`,`settings-view-toggle hooks-choice`),h=m(`input`,`settings-view-checkbox`);h.type=`checkbox`,h.checked=e.enabled,h.addEventListener(`change`,()=>{e.enabled=h.checked}),p.append(h,m(`span`,null,`Enabled`)),i.append(sK(`Name`,cK(e.name,`Lint after edits`,t=>{e.name=t}),null),sK(`Event`,uK(e,t,t=>{e.event=t,d()}),null),u,sK(`Type`,dK(e,t=>{e.type=t,l()}),null),s,c,sK(`Timeout (seconds)`,f,sG),sK(`Projects`,fK(e,n),null),sK(``,p,null)),XG=m(`p`,`hooks-editor-error`),XG.setAttribute(`role`,`alert`),XG.hidden=!0;let g=m(`div`,`hooks-editor-footer`),_=m(`span`,`hooks-editor-shortcut`,ZW),v=aK(`btn-dialog btn-dialog-cancel`,`Cancel`,vK),y=m(`button`,`btn-dialog btn-dialog-confirm`,e.id?`Save changes`:`Add hook`);return y.type=`submit`,g.append(XG,_,v,y),i.append(g),r.append(i),r}function gK(e,t=null){qG=t||(e?IG(e):FG(gG(UG))),JG=RG(e?IG(e):FG(gG(UG))),YG=hK(qG),AK({force:!0}),YG.scrollIntoView({block:`nearest`});let n=YG.querySelector(`input[type=text]`);n instanceof HTMLInputElement&&n.focus()}function _K(){qG=null,JG=null,YG=null,XG=null,ZG=!1,QG=null,nK=!0,AK({force:!0})}function vK(){!qG||!JG||!BG(qG,JG)?_K():lh({title:YW,message:XW,confirmLabel:`Discard`,danger:!0,onConfirm:_K})}function yK(){if(!qG||ZG)return;let e=LG(qG,gG(UG),_G(UG));e?mK(e):(ZG=!0,mK(``),QG=oK({type:`save-hook`,hook:RG(qG)}),QG||(ZG=!1))}function bK(e){let t=m(`details`,`hooks-preview`);t.open=eK.has(e.id),t.addEventListener(`toggle`,()=>{t.open?eK.add(e.id):eK.delete(e.id)});let n=m(`summary`,`hooks-preview-summary`,KW);n.title=qW;let r=m(`pre`,`hooks-preview-code`,wG(e));return t.append(n,r),t}function xK(e,{grouped:t=!1}={}){let n=re(UG),r=m(`article`,`hooks-row`);r.setAttribute(`aria-label`,e.name),e.enabled===!1&&(r.dataset.state=`off`);let i=m(`div`,`hooks-row-main`),a=m(`div`,`hooks-row-head`);a.append(m(`span`,`hooks-row-name`,e.name));let o=t?e.matcher||``:MG(e);o&&a.append(m(`span`,`hooks-row-event`,o));let s=m(`code`,`hooks-row-target`,OG(e));s.title=OG(e);let c=m(`p`,`hooks-row-meta`,[kG(e.type),AG(e),jG(e,n)].filter(Boolean).join(` / `));i.append(a,s,c);let l=PG(e,n);l.length>0&&i.append(iK(`hooks-row-meta`,`Scoped to a project no longer in config: ${l.join(`, `)}`,`warn`)),i.append(bK(e));let u=m(`div`,`hooks-row-actions`),d=m(`label`,`settings-view-toggle hooks-choice`),f=m(`input`,`settings-view-checkbox`);f.type=`checkbox`,f.checked=e.enabled!==!1,f.disabled=tK.has(e.id),f.setAttribute(`aria-label`,`${e.name} enabled`),f.addEventListener(`change`,()=>{tK.add(e.id),f.disabled=!0,oK({type:`save-hook`,hook:VG(e)})}),d.append(f,m(`span`,null,`On`));let p=aK(`hooks-btn`,`Edit`,()=>gK(e),`Edit ${e.name}`),h=aK(`hooks-btn`,JW,()=>{let t=IG({...e,name:TG(e.name)});t.id=null,gK(null,t)},`Duplicate ${e.name}`),g=aK(`hooks-btn hooks-btn-danger`,`Delete`,()=>{lh({title:`Delete hook`,message:HG(e),confirmLabel:`Delete`,danger:!0,onConfirm:()=>{tK.add(e.id),oK({type:`delete-hook`,id:e.id}),AK({force:!0})}})},`Delete ${e.name}`);return g.disabled=tK.has(e.id),u.append(d,p,h,g),r.append(i,u),r}function SK(e){let t=m(`article`,`hooks-row hooks-row-builtin`),n=m(`div`,`hooks-row-main`);return n.append(m(`span`,`hooks-row-event`,NG(e)),m(`p`,`hooks-row-meta`,e.purpose)),t.append(n),t}function CK(){let e=rK(`Hooks`,BW),t=m(`div`,`hooks-stats`);for(let e of yG(UG))t.append(w(`hooks`,e.label,e.value,e.tone));return e.append(t,iK(`hooks-meta`,QW)),e}function wK(){let e=m(`input`,`settings-view-input hooks-filter`);return e.type=`search`,e.value=$G,e.placeholder=WW,e.setAttribute(`aria-label`,WW),e.addEventListener(`input`,()=>{$G=e.value;let t=WG?.querySelector(`.hooks-list-yours`);t&&t.replaceWith(EK())}),e}function TK(){let e=m(`div`,`hooks-empty-state`);return e.append(iK(`hooks-empty`,HW),pK(gG(UG))),e}function EK(){let e=m(`div`,`hooks-list-yours`),t=mG(UG);if(t.length===0)return e.append(TK()),e;let n=xG(bG(t,gG(UG)),$G);if(n.length===0)return e.append(iK(`hooks-empty`,GW)),e;for(let t of CG(n)){let n=m(`div`,`hooks-group`);n.append(m(`h3`,`hooks-group-title`,t.event));let r=m(`div`,`hooks-list`);for(let e of t.hooks)r.append(xK(e,{grouped:!0}));n.append(r),e.append(n)}return e}function DK(){let e=rK(tG,null),t=aK(`hooks-btn hooks-btn-add`,`+ New hook`,()=>gK(null));t.disabled=!!qG;let n=e.querySelector(`.hooks-section-head`);return n&&n.append(t),SG(mG(UG))&&e.append(wK()),e.append(EK()),e}function OK(){let e=m(`details`,`hooks-builtin`),t=m(`summary`,`hooks-builtin-summary`);t.append(m(`span`,`hooks-section-title`,`${$W} (${hG(UG).length})`),m(`span`,`hooks-section-hint`,eG));let n=m(`div`,`hooks-list`);for(let e of hG(UG))n.append(SK(e));return e.append(t,n),e}function kK(){let e=m(`div`,`hooks-content`);return UG?dG(UG)?(e.append(iK(`hooks-warning`,fG(UG))),e):(e.append(CK()),YG&&e.append(YG),e.append(DK(),OK()),e):(e.append(iK(`hooks-empty`,VW)),e)}function AK({force:e=!1}={}){if(!WG||!e&&T(WG)||(WG.replaceChildren(kK()),!nK))return;nK=!1;let t=WG.querySelector(`.hooks-btn-add`);t instanceof HTMLButtonElement&&t.focus()}function jK(e){GG=e}function MK(){GG&&(KG=Jm(`hooks-report`),GG({type:`request-hooks-report`,requestId:KG}))}function NK(e){WG||(WG=m(`div`,`hooks-panel`),e.append(WG),AK({force:!0}))}function PK(){AK({force:!0})}function FK(e){vG(e,KG)&&(UG=e,tK.clear(),ZG=!1,AK())}function IK(e){let t=QG!==null&&e.requestId===QG;if(t&&(QG=null,ZG=!1),e.ok){t&&_K(),MK();return}let n=typeof e.error==`string`&&e.error?e.error:`Could not save the hook`;t?mK(n):(Hg(n,{persist:!0}),MK())}function LK(e){e.ok||Hg(typeof e.error==`string`&&e.error?e.error:`Could not delete the hook`,{persist:!0}),MK()}function RK(e,t,n){return{body:String(n||`Session needs attention`),tag:`glimmervoid-${e||``}-${t||``}`,renotify:!0,silent:!0}}var zK=4e3;function BK(e,t){return`glimmervoid-notify-claim-${e||``}-${t||``}`}function VK(e,t,n,r=zK){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 HK(){return typeof Notification>`u`?null:Notification}function UK(){return HK()!==null}function WK(){let e=HK();return e?e.permission:`unavailable`}async function GK(){let e=HK();if(!e)return`denied`;if(e.permission!=="default")return e.permission;try{return await e.requestPermission()}catch{return e.permission}}function KK(){let e=HK();e&&gp()&&e.permission==="default"&&GK()}function qK({session:e,category:t,message:n,kind:r,ignoreFocus:i=!1}={}){let a=HK();if(a&&gp()&&a.permission===`granted`&&!document.documentElement.hasAttribute(`data-streamer`)&&(i||typeof document>`u`||typeof document.hasFocus!=`function`||!document.hasFocus())&&VK(window.localStorage,BK(e,t),Date.now()))try{let i=new a(`Glimmervoid`,RK(e,t,n));i.onclick=()=>{window.focus(),r===`plan`&&typeof e==`string`&&(window.location.hash=mM(e)),i.close()}}catch{}}function JK(e){return e.filter(e=>!e.hasOwnPhoneScreen).map(e=>{let t=e.label.trim();return{id:e.view,label:t,glyph:e.glyph||t.charAt(0).toUpperCase(),el:e.el}})}function YK(e){return[...e||[]].map((e,t)=>({row:e,index:t})).sort((e,t)=>x_(e.row||{},`phone-triage`)-x_(t.row||{},`phone-triage`)||e.index-t.index).map(e=>e.row)}var XK=new Set;function ZK(e,t,n){let r=bV(e,t,n),i=r.groups.map(e=>({...e,rows:YK(e.rows)})),a={...r,groups:i};return{...a,visibleIds:xV(a,XK)}}var QK=e=>e.ui.path;function $K({onSelectSession:e}){let t=m(`div`,`phone-board`),n=m(`header`,`phone-topbar`),r=m(`div`,`phone-attention`);r.setAttribute(`role`,`status`),r.setAttribute(`aria-live`,`polite`);let i=m(`div`,`phone-board-list`),a=m(`div`,`phone-empty`),o=m(`p`,`phone-empty-title`,`No sessions`),s=m(`p`,`phone-empty-desc`,`Spawn a session to start watching.`);a.append(o,s),t.append(n,r,i,a);let c=new Map,l=new Map,u=new WeakMap,d=new WeakMap,f=new WeakMap,p=0;te(n);function h(t){let{row:n,refs:r}=TV(`button`);n.type=`button`,n.dataset.id=t,n.addEventListener(`click`,()=>e?.(t));let{item:i}=EV(n,()=>W_(t));return i.setAttribute(`role`,`listitem`),u.set(n,{refs:r,item:i}),n}function g(e){let t=m(`section`,`phone-board-group`);t.dataset.key=e;let n=m(`div`,`phone-board-group-header`),r=m(`span`,`phone-board-group-label`),i=m(`span`,`phone-board-group-count`),a=m(`button`,`phone-board-group-add`,`+`);a.type=`button`,a.addEventListener(`click`,()=>U_(t.dataset.path,t.dataset.label));let o=m(`button`,`phone-board-group-forget`,`x`);o.type=`button`,o.addEventListener(`click`,()=>{F_(t.dataset.path),C()});let s=m(`div`,`phone-board-group-rows`);return s.setAttribute(`role`,`list`),n.append(r,i,o,a),t.append(n,s),d.set(t,{header:n,label:r,count:i,addButton:a,forgetButton:o,rows:s}),t}function _(e,t){let n=u.get(e);if(!n)return;let{ui:r,state:i,unseen:a,name:o}=t;OV(e,n.refs,{ui:r,state:i,name:o,unseen:a,mergeStatus:r.card?.dataset.merge||``})}function v(e,t){let n=d.get(e);if(!n)return;let{header:r,label:i,count:a,addButton:o,forgetButton:s,rows:c}=n,l=t.key===vV,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}=kV();function S(){let e=H_();y(e);for(let t of e)t.unseen=x(t.id);return S_(e)}function C(){let e=S(),t=ZK(e,QK,P_(e,QK)),n=T_(e);p=n.waitingCount+n.finishedCount,r.textContent=E_(n),r.toggleAttribute(`data-lit`,p>0);let m=new Set(t.order),y=t.order.join(`,`),b=f.get(i)===y&&i.childElementCount===t.groups.length;for(let e of t.groups){let t=l.get(e.key);t||(t=g(e.key),l.set(e.key,t)),v(t,e),b||i.appendChild(t);let n=e.rows.map(e=>e.id).join(`,`),r=d.get(t);if(!r)continue;let a=f.get(r.rows)===n&&r.rows.childElementCount===e.rows.length;for(let t of e.rows){let e=c.get(t.id);e||(e=h(t.id),c.set(t.id,e)),_(e,t);let n=u.get(e);n&&(a||r.rows.appendChild(n.item))}f.set(r.rows,n)}f.set(i,y);for(let[e,t]of[...l])m.has(e)||(t.remove(),l.delete(e));let x=new Set(t.visibleIds);for(let[e,t]of[...c]){if(x.has(e))continue;let n=u.get(t);n&&n.item.remove(),c.delete(e)}let C=t.groups.length>0,ee=E.size===0;i.hidden=!C,a.hidden=C,yg(a,ee),o.hidden=ee,s.hidden=ee}function ee(e,t){let n=e.card?.dataset.id,r=n?c.get(n):void 0;r&&(t===`flag`?r.dataset.activity=e._activity||``:Mh(u.get(r)?.refs.glyph))}return Lh(()=>{for(let[e,t]of c){let n=E.get(e),r=u.get(t);n&&r&&(r.refs.elapsed.textContent=Ph(n))}}),{el:t,topBarEl:n,refresh:C,acknowledge:b,renderActivity:ee,getAttentionCount:()=>p}}var eq=`clipboard`,tq=`upload`,nq=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:eq,title:`Paste from the clipboard`}),Object.freeze({id:`upload-image`,label:`Image`,bytes:null,action:tq,accept:`image/*`,title:`Upload an image to this session`}),Object.freeze({id:`upload-file`,label:`File`,bytes:null,action:tq,title:`Upload a file to this session`})]);function rq(e){let t=nq.find(t=>t.id===e);return t?t.bytes:null}function iq(e){return!!e&&e.action===eq}function aq(e){return!!e&&e.action===`upload`}function oq({send:e,getSessionId:t}){let n=m(`div`,`phone-key-strip`);n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,`Terminal keys`);let r=null,i=null;for(let e of nq){let t=m(`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){aq(t)?o(t,n):iq(t)?sq(e):e(rq(t.id))}function o(e,t){i=t,r||(r=m(`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?.();a?c(a,n,i):Hg(`No session is open to upload to`)}async function c(e,t,n){n&&(n.disabled=!0),await zD(e,t),n&&(n.disabled=!1)}return n}function sq(e){let t=null;try{t=navigator.clipboard?.readText?.()}catch{Hg(`Paste needs clipboard permission`);return}t?t.then(t=>{t&&e(t)}).catch(()=>Hg(`Paste needs clipboard permission`)):Hg(`Paste is unavailable in this browser`)}var cq=`‹`;function lq({onBack:e}){let t=m(`div`,`phone-terminal`),n=m(`header`,`phone-topbar phone-terminal-bar`),r=m(`button`,`phone-back`,cq);r.type=`button`,r.setAttribute(`aria-label`,`Back to board`),r.addEventListener(`click`,()=>e?.());let i=m(`div`,`phone-terminal-identity`),o=m(`span`,`phone-terminal-name`);o.title=`Tap to rename`,o.addEventListener(`click`,()=>te());let s=m(`span`,`session-task-title session-list-task-title`);Hz(s,()=>ne());let c=m(`span`,`phone-terminal-identity-line`),l=m(`span`,`phone-terminal-badge`);l.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 u=y(l,`.phone-terminal-glyph`,`span`),d=y(l,`.phone-terminal-label`,`span`),f=y(l,`.phone-terminal-elapsed`,`span`);c.append(o,s),i.append(c,l);let p=m(`div`,`phone-terminal-actions`);n.append(r,i,p);let h=m(`div`,`phone-card-slot`),g=m(`div`,`phone-empty`);g.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 _=oq({send:S,getSessionId:()=>v});t.append(n,h,g,_);let v=null,b=null,x=null;function S(e){let t=v?E.get(v):null;t&&(oj(t,e)||Hg(`Session is not connected; key press was dropped`))}function C(){let e=v?E.get(v):null;e?.term&&e.term.focus()}h.addEventListener(`click`,C);function te(){let e=v?E.get(v):null;e&&v&&qz(e,v)}function ne(){let e=v?E.get(v):null;e&&v&&Wz(e,v)}function w(){let e=v?E.get(v):null,t=!!e;if(g.hidden=t,h.hidden=!t,_.hidden=!t,i.hidden=!t,!t){n.removeAttribute(`data-state`),n.removeAttribute(`data-monitoring`);return}let r=e.currentState||a.DORMANT;n.dataset.state=r;let{glyph:c,label:l,isMonitoring:p}=ee(r,e.awaitingBackgroundTasks);n.toggleAttribute(`data-monitoring`,p),Kz(o)||(o.textContent=e.card?.dataset.session||v),Uz(s,e.taskTitle),u.textContent=c,d.textContent=l,f.textContent=Ph(e)}function re(){x&&=(delete x.renameTargetEl,delete x.titleTargetEl,null),o.replaceChildren(),b&&=(oe(b),b.parentElement===p&&b.remove(),null)}function T(e){let t=E.get(e);t&&(v===e&&he()===e&&t.card.parentElement===h||(re(),v=e,ge(t,e,h,{className:`phone-centered`}),b=y(t.card,`.session-actions`,`div`),ae(b,p),t.renameTargetEl=o,t.titleTargetEl=s,x=t),w())}function ie(){re(),he()===v&&_e(),v=null,w()}function D(){if(!v){w();return}let e=E.get(v);e?e.card.parentElement===h?w():T(v):ie()}function O(){let e=v;e&&pj(E.get(e),e,!1)}function k(){D();let e=v;if(!e)return;let t=E.get(e);t&&pj(t,e,!0)}return Lh(()=>{let e=v?E.get(v):null;e&&(f.textContent=Ph(e))}),w(),{el:t,show:T,clear:ie,refresh:D,reveal:k,unview:O,getSessionId:()=>v}}var uq=`board`,dq=Object.freeze([{id:uq,label:`Board`,glyph:`▤`},{id:`terminal`,label:`Terminal`,glyph:`▸`},{id:`review`,label:`Review`,glyph:`◫`}]),fq=[],pq=new Map,mq=null,hq=new Map,gq=new Map,_q=new Map,vq=null,yq=null,bq=null,xq=null,Sq=null,Cq=new Map,wq=new Set,Tq={},Eq=!1,Dq=120,Oq=0,kq=0,Aq=`none`;function jq(){Oq=0,kq=0}function Mq(){let e=window.visualViewport;mq&&(!Eq||!e?mq.removeAttribute(`data-keyboard`):(mq.style.setProperty(`--phone-vh`,`${e.height}px`),mq.style.setProperty(`--phone-vv-top`,`${e.offsetTop}px`),e.width!==kq&&(kq=e.width,Oq=0),Oq=Math.max(Oq,e.height),Oq-e.height>Dq?mq.dataset.keyboard=`open`:mq.removeAttribute(`data-keyboard`)))}function Nq(e,t,n=`phone-nav-item`,r=`phone-nav-dot`){let i=m(`button`,n);i.type=`button`;let a=m(`span`,`phone-nav-glyph`,t);a.setAttribute(`aria-hidden`,`true`),i.append(a,m(`span`,`phone-nav-label`,e));let o=m(`span`,r);return o.setAttribute(`aria-hidden`,`true`),o.hidden=!0,i.appendChild(o),i}function Pq(e){return e?.querySelector(`.phone-nav-dot`)||null}function Fq(e,t){e&&(e.hidden=!t,typeof t==`string`&&(e.dataset.attention=t),typeof t!=`string`&&delete e.dataset.attention)}function Iq(){let e=[];for(let t of fq){if(wq.has(t.id))continue;let n=_q.get(t.id)||!1;e.push(n),Fq(Pq(Cq.get(t.id)),n)}Fq(Pq(xq),Sae(e))}function Lq(){let e=m(`div`,`phone-nav-more-menu`);e.hidden=!0;for(let t of fq){let n=Nq(t.label,t.glyph,`phone-nav-menu-item`,`phone-nav-dot phone-nav-menu-dot`);n.dataset.screen=t.id,n.hidden=wq.has(t.id),n.addEventListener(`click`,()=>{Rq(!1),Qq(t.id)}),Cq.set(t.id,n),e.appendChild(n)}return e}function Rq(e){Sq&&xq&&(Sq.hidden=!e,xq.setAttribute(`aria-expanded`,String(e)))}function zq(){return!!Sq&&!Sq.hidden}function Bq(){let e=m(`nav`,`phone-nav`);e.setAttribute(`aria-label`,`Screens`);for(let t of dq){let n=Nq(t.label,t.glyph);n.dataset.screen=t.id,n.addEventListener(`click`,()=>Qq(t.id)),hq.set(t.id,n),e.appendChild(n)}return xq=Nq(`More`,`⋯`),xq.setAttribute(`aria-expanded`,`false`),xq.addEventListener(`click`,()=>Rq(!zq())),e.appendChild(xq),Sq=Lq(),e.appendChild(Sq),e}function Vq(e,t,n){let r=m(`section`,`phone-screen`);return r.dataset.screen=e,r.setAttribute(`aria-label`,t),r.hidden=!0,n&&r.appendChild(n),gq.set(e,r),r}function Hq(){if(mq)return;vq=$K({onSelectSession:Uq}),Ah((e,t)=>{Eq&&vq?.renderActivity(e,t)}),yq=lq({onBack:()=>Qq(uq)}),bq=m(`div`,`phone-review`);let e=m(`div`,`phone-screens`),t={[uq]:vq.el,terminal:yq.el,review:bq};for(let n of dq)e.appendChild(Vq(n.id,n.label,t[n.id]));for(let t of fq){let n=m(`div`,`phone-panel phone-${t.id}`);pq.set(t.id,n),e.appendChild(Vq(t.id,t.label,n))}mq=m(`div`,`phone-shell`),mq.id=`phone-shell`,mq.append(e,Bq()),document.body.appendChild(mq),Iq(),window.visualViewport?.addEventListener(`resize`,Mq),window.visualViewport?.addEventListener(`scroll`,Mq),window.addEventListener(`popstate`,Jq),document.addEventListener(`click`,e=>{zq()&&Sq&&xq&&e.target instanceof Node&&(Sq.contains(e.target)||xq.contains(e.target)||Rq(!1))}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&zq()&&Rq(!1)})}function Uq(e){if(E.has(e)){if(!vq||!yq)throw Error(`Phone shell is not built`);z_(e,`dormant-fallback`),vq.acknowledge(e),B_(e),yq.show(e),Qq(`terminal`)}}function Wq(e){if(e===uq){Kq();return}let t={glimmervoidScreen:e};Aq===`none`?(history.pushState(t,``),Aq=`screen`):(history.replaceState(t,``),Aq=`screen`)}function Gq(){let e=qq(history.state);return e&&Zq(e)?(Aq=`screen`,e):(e&&history.replaceState(null,``),Aq=`none`,uq)}function Kq(){Aq!==`none`&&(Aq=`none`,history.back())}function qq(e){let t=e?.glimmervoidScreen;return typeof t==`string`?t:null}function Jq(e){if(!Eq)return;let t=pe.snapshot().phoneScreen;if(t&&Tq.canGoBack?.(t)){Aq=`none`,Wq(t),Tq.onBack?.(t),Xq(t);return}let n=qq(e.state);Aq=n?`screen`:`none`,Xq(n&&Zq(n)?n:uq)}function Yq(e,t){for(let[n,r]of e)n===t?r.setAttribute(`aria-current`,`page`):r.removeAttribute(`aria-current`)}function Xq(e){if(!xq||!yq)throw Error(`Phone shell is not built`);pe.dispatch(`setPhoneScreen`,e),Rq(!1);for(let[t,n]of gq)n.hidden=t!==e;Tq.onScreenShown?.(e),Yq(hq,e);let t=Cq.has(e);t&&xq.setAttribute(`aria-current`,`page`),t||xq.removeAttribute(`aria-current`),Yq(Cq,e),e===`terminal`?yq.reveal():yq.unview()}function Zq(e){return gq.has(e)&&!wq.has(e)}function Qq(e){mq&&Zq(e)&&(e!==pe.snapshot().phoneScreen&&Wq(e),Xq(e))}function $q(e){Tq=e||{},fq=Tq.panels||[]}function eJ({sessionId:e,linkedScreenId:t}={}){if(Eq)return;if(Hq(),!mq||!vq||!yq)throw Error(`Phone shell is not built`);Eq=!0,mq.hidden=!1;for(let e of Tq.headerControls||[])ae(e,vq.topBarEl);BN(bq);for(let e of fq)ae(e.el,pq.get(e.id)),e.el.hidden=!1;Mq(),e&&yq.show(e);let n=Gq();aJ(),t&&Zq(t)?Qq(t):e&&n===uq?(pe.dispatch(`setPhoneScreen`,uq),Qq(`terminal`)):Xq(n)}function tJ(){if(Eq){if(!mq||!yq)throw Error(`Phone shell is not built`);Eq=!1,yq.clear(),BN(null);for(let e of fq)oe(e.el);for(let e of Tq.headerControls||[])oe(e);Rq(!1),mq.hidden=!0,mq.removeAttribute(`data-keyboard`),jq(),Kq()}}function nJ(e){return!Eq||!vq||!yq||!E.has(e)?!1:(Uq(e),HB(e))}function rJ(){return Eq}function iJ(){return Eq&&yq?yq.getSessionId():null}function aJ(){if(!Eq)return;if(!vq||!yq)throw Error(`Phone shell is not built`);uJ(),vq.refresh(),yq.refresh(),pe.snapshot().phoneScreen===`terminal`&&!yq.getSessionId()&&Qq(uq);let e=Pq(hq.get(uq));e&&(e.hidden=vq.getAttentionCount()===0)}function oJ(e){return Eq?(Uq(e),!0):!1}function sJ(e){return!Eq||!Zq(e)?!1:(Qq(e),!0)}function cJ(e,t){t&&wq.delete(e),t||wq.add(e);let n=Cq.get(e);n&&(n.hidden=!t);let r=gq.get(e);r&&!t&&(r.hidden=!0),Iq(),!t&&Eq&&pe.snapshot().phoneScreen===e&&Qq(uq)}function lJ(e,t){_q.set(e,typeof t==`string`&&t?t:t===!0),Iq()}function uJ(){if(!yq)throw Error(`Phone shell is not built`);if(yq.getSessionId())return;let e=V_();e&&(yq.show(e),B_(e,{rememberFocus:!1}))}function dJ(e,t){return!!e?.error&&!e.isRefreshing&&typeof e.nextAttemptAt==`number`&&e.nextAttemptAt>t}function fJ(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 pJ(e,t,n){return e?.refreshNotice&&e.isRefreshing?e.refreshNotice:t||e?.isRefreshing?`Refreshing.`:n||e?.refreshNotice||``}var mJ={minPx:220,maxPx:720},hJ=16,gJ=new Set,_J=0;function vJ(e){let t=Ip();e.toggleAttribute(`data-queue-collapsed`,t),e.querySelector(`.pr-queue-toggle`)?.setAttribute(`aria-expanded`,String(!t));let n=Pp();n===null?e.style.removeProperty(`--pr-queue-width`):e.style.setProperty(`--pr-queue-width`,`${n}px`)}function yJ(){for(let e of gJ)e.isConnected?vJ(e):gJ.delete(e)}function bJ(e,t){let n=m(`div`,`pr-queue-head`);return e&&n.append(e),t&&n.append(t),n}function xJ(e){let t=m(`div`,`pr-queue-foot`);return e&&t.append(e),t}function SJ({queueLabel:e,scopeTabs:t,resizerLabel:n}){let r=m(`div`,`pr-columns`),i=m(`div`,`pr-queue-pane`),a=m(`nav`,`pr-queue`);a.id=`pr-queue-${++_J}`,a.setAttribute(`aria-label`,e);let o=m(`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=vM(16,16);s.append(_M(`rect`,{x:`1.5`,y:`2`,width:`13`,height:`12`,rx:`2`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`})),s.append(_M(`path`,{d:`M5.5 2V14`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`}));let c=_M(`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`,()=>{Lp(!Ip()),yJ()});let l=xJ(null);i.append(bJ(t,o),a,l);let u=m(`div`,`pr-queue-resizer`);u.setAttribute(`role`,`separator`),u.setAttribute(`aria-orientation`,`vertical`),u.setAttribute(`aria-label`,n),u.tabIndex=0;let d=m(`main`,`pr-detail-host`);return r.append(i,u,d),vJ(r),gJ.add(r),A_({resizer:u,column:i,widthHost:r,widthProperty:`--pr-queue-width`,bounds:mJ,keyStepPx:hJ,getStoredWidth:Pp,setStoredWidth:Fp}),{columns:r,queue:a,foot:l,detail:d}}var CJ={merged:`M5.45 5.154A4.25 4.25 0 0 0 9.25 7.5h1.378a2.251 2.251 0 1 1 0 1.5H9.25A5.734 5.734 0 0 1 5 7.123v3.505a2.25 2.25 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.95-.218ZM4.25 13.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm8.5-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0 .005V3.25Z`,draft:`M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 7.5a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Zm0-4.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Z`,conflict:`M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z`,behind:`M13.03 8.22a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L3.47 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018l2.97 2.97V3.75a.75.75 0 0 1 1.5 0v7.44l2.97-2.97a.75.75 0 0 1 1.06 0Z`,failed:`M2.343 13.657A8 8 0 1 1 13.658 2.343 8 8 0 0 1 2.343 13.657ZM6.03 4.97a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042L6.94 8 4.97 9.97a.749.749 0 0 0 .326 1.275.749.749 0 0 0 .734-.215L8 9.06l1.97 1.97a.749.749 0 0 0 1.275-.326.749.749 0 0 0-.215-.734L9.06 8l1.97-1.97a.749.749 0 0 0-.326-1.275.749.749 0 0 0-.734.215L8 6.94Z`,running:`M8 4a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z`,passed:`M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z`,ready:`M8 16A8 8 0 1 1 8 0a8 8 0 0 1 0 16Zm3.78-9.72a.751.751 0 0 0-.018-1.042.751.751 0 0 0-1.042-.018L6.75 9.19 5.28 7.72a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042l2 2a.75.75 0 0 0 1.06 0Z`,"changes-requested":`M1 1.75C1 .784 1.784 0 2.75 0h7.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16H2.75A1.75 1.75 0 0 1 1 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25V4.664a.25.25 0 0 0-.073-.177l-2.914-2.914a.25.25 0 0 0-.177-.073ZM8 3.25a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0V7h-1.5a.75.75 0 0 1 0-1.5h1.5V4A.75.75 0 0 1 8 3.25Zm-3 8a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75Z`,thread:`M1 2.75C1 1.784 1.784 1 2.75 1h10.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 13.25 12H9.06l-2.573 2.573A1.458 1.458 0 0 1 4 13.543V12H2.75A1.75 1.75 0 0 1 1 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h4.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z`,reviewer:`M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 13H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25v-8.5C0 1.784.784 1 1.75 1ZM1.5 2.75v8.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Zm5.28 1.72a.75.75 0 0 1 0 1.06L5.31 7l1.47 1.47a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-2-2a.75.75 0 0 1 0-1.06l2-2a.75.75 0 0 1 1.06 0Zm2.44 0a.75.75 0 0 1 1.06 0l2 2a.75.75 0 0 1 0 1.06l-2 2a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L10.69 7 9.22 5.53a.75.75 0 0 1 0-1.06Z`,"your-turn":`M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z`,queued:`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7-3.25v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5a.75.75 0 0 1 1.5 0Z`,fork:`M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z`,discarded:`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm9.78-2.22-5.5 5.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l5.5-5.5a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z`,stale:`M1.705 8.005a.75.75 0 0 1 .834.656 5.5 5.5 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7.002 7.002 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834ZM8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7.002 7.002 0 0 1 14.95 7.16a.75.75 0 0 1-1.49.178A5.5 5.5 0 0 0 8 2.5Z`,unknown:`M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.92 6.085h.001a.749.749 0 1 1-1.342-.67c.169-.339.436-.701.849-.977C6.845 4.16 7.369 4 8 4a2.756 2.756 0 0 1 1.637.525c.503.377.863.965.863 1.725 0 .448-.115.83-.329 1.15-.205.307-.47.513-.692.662-.109.072-.22.138-.313.195l-.006.004a6.24 6.24 0 0 0-.26.16.952.952 0 0 0-.276.245.75.75 0 0 1-1.248-.832c.184-.264.42-.489.692-.661.103-.067.207-.132.313-.195l.007-.004c.1-.061.182-.11.258-.161a.969.969 0 0 0 .277-.245C8.96 6.514 9 6.427 9 6.25a.612.612 0 0 0-.262-.525A1.27 1.27 0 0 0 8 5.5c-.369 0-.595.09-.74.187a1.01 1.01 0 0 0-.34.398ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z`,none:`M2 7.75A.75.75 0 0 1 2.75 7h10a.75.75 0 0 1 0 1.5h-10A.75.75 0 0 1 2 7.75Z`};function wJ(e,t){let n=vM(16,16);return n.classList.add(`pr-status-icon`),t&&(n.dataset.tone=t),n.append(_M(`path`,{d:CJ[e],fill:`currentColor`})),n}var TJ=1.2,EJ=1.55,DJ=.12,OJ=523.25,kJ=2,AJ=8,jJ=(e,t,n)=>({semitone:e,startBeat:t,beats:n}),MJ={melody:[jJ(7,4,.5),jJ(11,4.5,.5),jJ(12,5,3)],bass:[jJ(-5,4,1),jJ(-12,5,3)]},NJ=[{melody:[jJ(0,0,1),jJ(4,1,1),jJ(7,2,1),jJ(9,3,1)],bass:[jJ(-12,0,2),jJ(-8,2,2)]},{melody:[jJ(7,0,.67),jJ(7,.67,.67),jJ(7,1.33,.67),jJ(9,2,1),jJ(5,3,1)],bass:[jJ(-12,0,2),jJ(-7,2,2)]},{melody:[jJ(5,0,1),jJ(9,1,1),jJ(7,2,1),jJ(4,3,1)],bass:[jJ(-7,0,2),jJ(-12,2,2)]},{melody:[jJ(12,0,.5),jJ(7,.5,.5),jJ(12,1,.5),jJ(16,1.5,.5),jJ(16,2,1),jJ(14,3,1)],bass:[jJ(-12,0,2),jJ(-3,2,2)]},{melody:[jJ(4,0,1),jJ(7,1,1),jJ(4,2,.5),jJ(5,2.5,.5),jJ(7,3,.5),jJ(4,3.5,.5)],bass:[jJ(-8,0,2),jJ(-12,2,2)]}].map(e=>({melody:[...e.melody,...MJ.melody],bass:[...e.bass,...MJ.bass]}));function PJ(e,t){return OJ*2**((e+t)/12)}function FJ(e,t){let n=(e,n,r)=>e.map(e=>({frequency:PJ(e.semitone,t),startSeconds:EJ+e.startBeat*DJ,durationSeconds:e.beats*DJ,waveform:n,gain:r}));return[...n(e.melody,`square`,.2),...n(e.melody,`triangle`,.5),...n(e.bass,`triangle`,.6)]}var IJ=[{frequency:220,endFrequency:880,startSeconds:0,durationSeconds:.32,waveform:`triangle`,gain:.25},{frequency:160,endFrequency:45,startSeconds:TJ,durationSeconds:.28,waveform:`sine`,gain:1},{frequency:1400,endFrequency:380,startSeconds:TJ,durationSeconds:.06,waveform:`square`,gain:.12}];function LJ(e){let t=NJ[e%NJ.length],n=Math.min(e*kJ,AJ);return{peakGain:.1,tones:[...IJ,...FJ(t,n)]}}function RJ(e){return Math.round(Math.sqrt(2*e/780)*1e3)}function zJ(e,t,n=Math.random){return Math.round(e+n()*(t-e))}function BJ(e,t=Math.random){let n=[...e];for(let e=n.length-1;e>0;--e){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}var VJ=.6,HJ=.25,UJ=1.6;function WJ(e){return Math.min(VJ+e*HJ,UJ)}var GJ=[`var(--accent)`,`var(--state-running)`,`var(--state-idle)`,`var(--state-waiting)`,`var(--state-failed)`];function KJ(e,t=Math.random){let n=zJ(320,520,t),r=zJ(1800,2800,t);return[[`--confetti-start-x`,`${zJ(4,96,t)}%`],[`--confetti-x`,`${zJ(-140,140,t)}px`],[`--confetti-rise`,`${-zJ(20,55,t)}px`],[`--confetti-fall`,`${zJ(45,70,t)}vh`],[`--confetti-rise-ms`,`${n}ms`],[`--confetti-fall-ms`,`${r}ms`],[`--confetti-flight-ms`,`${n+r}ms`],[`--confetti-tilt`,`${zJ(0,180,t)}deg`],[`--confetti-spin`,`${zJ(-360,360,t)}deg`],[`--confetti-flutter-ms`,`${zJ(160,340,t)}ms`],[`--confetti-delay`,`${zJ(0,160,t)}ms`],[`--confetti-color`,GJ[e%GJ.length]]]}var qJ=`<svg viewBox="0 0 36 36" aria-hidden="true"><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="17"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="13"/><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="9"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="5"/></svg>`,JJ=`<svg viewBox="0 0 26 8" aria-hidden="true"><path class="merge-bullseye-dart-flight" d="M0 0L7 3V5L0 8L2 4Z"/><rect class="merge-bullseye-dart-shaft" x="6" y="3.3" width="8" height="1.4"/><rect class="merge-bullseye-dart-barrel" x="13" y="2.5" width="7" height="3" rx="1"/><path class="merge-bullseye-dart-tip" d="M20 3L26 4L20 5Z"/></svg>`;function YJ(){let e=h(`div`,`merge-bullseye-target`,qJ);return e.append(m(`span`,`merge-bullseye-ripple`)),e}function XJ(){let e=m(`div`,`merge-bullseye-dart-drift`),t=m(`div`,`merge-bullseye-dart-arc`),n=m(`div`,`merge-bullseye-dart-aim`);return n.append(h(`div`,`merge-bullseye-dart`,JJ)),t.append(n),e.append(t),e}function ZJ(){let e=m(`div`,`merge-bullseye-range`),t=m(`div`,`merge-bullseye-track`);return t.append(XJ()),e.append(YJ(),t),e}var QJ={title:`BULLSEYE!`,buildScene:ZJ},$J=6,eY=30,tY=-14,nY=16;function rY(e=Math.random){return[[`--crosshair-start-left`,`${zJ($J,eY,e)}%`],[`--crosshair-start-offset-y`,`${zJ(tY,nY,e)}px`]]}var iY=`<svg viewBox="0 0 26 40" aria-hidden="true"><path class="merge-headshot-target-body" d="M9 13H17L18 16Q25 18 25 24V40H1V24Q1 18 8 16Z"/><circle class="merge-headshot-target-head" cx="13" cy="7" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="7" r="3"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="2.5"/></svg>`,aY=`<svg viewBox="0 0 22 22" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="M11 0V5M11 17V22M0 11H5M17 11H22"/><circle class="merge-headshot-crosshair-dot" cx="11" cy="11" r="1"/></svg>`,oY=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 3L8 8M21 3L16 8M3 21L8 16M21 21L16 16"/></svg>`;function sY(){let e=m(`div`,`merge-headshot-sweep`);g(e,rY());let t=m(`div`,`merge-headshot-aim`);t.append(h(`div`,`merge-headshot-crosshair`,aY));let n=m(`div`,`merge-headshot-bob`);return n.append(t,h(`div`,`merge-headshot-hitmarker`,oY)),e.append(n),e}function cY(){let e=m(`div`,`merge-headshot-range`),t=m(`div`,`merge-headshot-track`);return t.append(sY()),e.append(h(`div`,`merge-headshot-target`,iY),t),e}var lY={title:`HEADSHOT!`,buildScene:cY},uY=[`10`,`J`,`Q`,`K`,`A`],dY=19,fY=5,pY=9,mY=780,hY=70,gY=70,_Y=35;function vY(e){let t=uY.length-1,n=e-t/2;return{offsetPx:n*dY,titleSpreadFraction:n/t,tiltDegrees:n*fY,bottomPx:pY-n**2,dealLeadMs:mY-e*hY,flipLeadMs:160+(t-e)*gY,waveDelayMs:e*_Y}}function yY(e){return[[`--card-offset`,`${e.offsetPx}px`],[`--card-title-spread`,String(e.titleSpreadFraction)],[`--card-tilt`,`${e.tiltDegrees}deg`],[`--card-bottom`,`${e.bottomPx}px`],[`--card-deal-lead-ms`,`${e.dealLeadMs}ms`],[`--card-flip-lead-ms`,`${e.flipLeadMs}ms`],[`--card-wave-delay-ms`,`${e.waveDelayMs}ms`]]}function bY(){return[[`--card-flip-ms`,`160ms`]]}var xY=`<svg viewBox="0 0 10 9" aria-hidden="true"><path d="M5 8.5C5 8.5 0 5.3 0 2.6C0 1.1 1.2 0 2.6 0C3.6 0 4.5 .6 5 1.4C5.5 .6 6.4 0 7.4 0C8.8 0 10 1.1 10 2.6C10 5.3 5 8.5 5 8.5Z"/></svg>`;function SY(e,t){let n=m(`div`,`merge-flush-deal`);g(n,yY(vY(t)));let r=m(`div`,`merge-flush-hop`),i=m(`div`,`merge-flush-card`),a=m(`div`,`merge-flush-face`);return a.append(m(`span`,`merge-flush-rank`,e)),a.insertAdjacentHTML(`beforeend`,xY),i.append(m(`div`,`merge-flush-back`),a),r.append(i),n.append(r),n}function CY(){let e=m(`div`,`merge-flush-table`);return g(e,bY()),e.append(...uY.map(SY)),e}var wY={title:`ROYAL FLUSH!`,buildScene:CY},TY=[1,2,3,4],EY=14,DY=3,OY=3,kY=10,AY=20,jY=2,MY=28,NY=18,PY=.01,FY=1.5,IY=2200,LY=1,RY=120,zY=.35,BY=4,VY=65,HY=145;function UY(e){return Math.round(e/(Math.PI*NY)*360)}function WY(e){return AY-e*jY}function GY(e){return e.rowIndex*EY+e.depthIndex*DY}function KY(e,t,n){return Array.from({length:n},(r,i)=>e+(t-e)*i/(n-1))}function qY(){return TY.flatMap((e,t)=>Array.from({length:e},(n,r)=>({rowIndex:t,depthIndex:e-1-r})))}function JY(e,t){let n=BJ(KY(15,105,e),t),r=BJ(KY(VY,HY,e),t);return n.map((e,n)=>({angleDegrees:e+zJ(-4,BY,t),depthScalePercent:Math.round(r[n])}))}function YY(e,t,n){let r=zJ(240,380,n),i=t.angleDegrees*Math.PI/180,a=r*Math.cos(i),o=(r*Math.sin(i))**2/1560,s=zJ(15,45,n),c=RJ(o),l=RJ(o+s),u=c+l,d=zJ(540,1080,n),f=a>=0?1:-1,p=GY(e);return{depthIndex:e.depthIndex,launchAngleDegrees:t.angleDegrees,distanceFromHeadPinPx:p,layer:WY(e.depthIndex),flyXPx:Math.round(a*u/1e3),peakRisePx:Math.round(o),landingDropPx:s,riseMs:c,fallMs:l,flightMs:u,spinDegrees:Math.round(f*d*u/1e3),glintMs:Math.round(180/d*1e3),depthScalePercent:t.depthScalePercent,delayMs:Math.round(p/zY)}}function XY(e=Math.random){let t=qY(),n=JY(t.length,e);return t.map((t,r)=>YY(t,n[r],e))}function ZY(e){return[[`--pin-left`,`${e.distanceFromHeadPinPx}px`],[`--pin-raise`,`${e.depthIndex*OY}px`],[`--pin-shade`,`${100-e.depthIndex*12}%`],[`--pin-fly-x`,`${e.flyXPx}px`],[`--pin-peak-y`,`${-e.peakRisePx}px`],[`--pin-land-y`,`${e.landingDropPx}px`],[`--pin-rise-ms`,`${e.riseMs}ms`],[`--pin-fall-ms`,`${e.fallMs}ms`],[`--pin-flight-ms`,`${e.flightMs}ms`],[`--pin-spin`,`${e.spinDegrees}deg`],[`--pin-glint-ms`,`${e.glintMs}ms`],[`--pin-depth-scale`,`${e.depthScalePercent}%`],[`--pin-depth-shade`,`${e.depthScalePercent-10}%`],[`--pin-delay`,`${e.delayMs}ms`],[`--pin-layer`,String(e.layer)]]}function QY(){return WY(FY)}function $Y(){return Math.max(...qY().map(GY))+kY}function eX(){let e=$Y(),t=MY+e+NY-LY;return[[`--ball-follow-px`,`${RY}px`],[`--ball-follow-ms`,`${Math.round(RY/zY)}ms`],[`--ball-follow-spin`,`${UY(RY)}deg`],[`--ball-size`,`${NY}px`],[`--ball-approach-spin`,`${IY}deg`],[`--ball-impact-inset`,`${t}px`],[`--ball-layer`,String(QY())],[`--rack-right`,`${MY}px`],[`--rack-width`,`${e}px`],[`--pin-width`,`${kY}px`]]}function tX(e=Math.random){return e()>=PY?null:vf[Math.floor(e()*vf.length)].sprite}var nX=`<svg viewBox="0 0 10 24" aria-hidden="true"><path class="merge-strike-pin-body" d="M5 0C7 0 7.6 2 7.2 4C6.9 5.6 6.3 6.6 6.4 8C6.6 10 9.6 12 9.6 16C9.6 19.5 8.4 22 7.6 24H2.4C1.6 22 .4 19.5 .4 16C.4 12 3.4 10 3.6 8C3.7 6.6 3.1 5.6 2.8 4C2.4 2 3 0 5 0Z"/><path class="merge-strike-pin-stripe" d="M3.1 5.2H6.9V6.2H3.1ZM3.4 7H6.6V8H3.4Z"/></svg>`;function rX(e){let t=m(`span`,`merge-strike-pin`);return t.append(h(`span`,`merge-strike-pin-arc`,nX)),g(t,ZY(e)),t}function iX(){let e=tX();if(!e)return m(`span`,`merge-strike-ball`);let t=m(`span`,`merge-strike-ball is-animal`);return t.append(m(`span`,`nyan-sprite ${e}`)),t}function aX(){let e=m(`div`,`merge-strike-lane`);g(e,eX());let t=m(`div`,`merge-strike-rack`);t.append(...XY().map(rX));let n=m(`div`,`merge-strike-track`);return n.append(iX()),e.append(t,n),e}var oX={title:`STRIKE!`,buildScene:aX},sX=20,cX=92,lX=23,uX=7,dX=-40;function fX(){let e=RJ(72),t=RJ(69),n=780*t/1e3;return{launchHeightPx:sX,peakHeightPx:cX,heightThroughRimPx:lX,heightLeavingNetPx:uX,heightOutOfCardPx:dX,riseMs:e,fallToRimMs:t,speedThroughRimPxPerSecond:n,netCatchMs:Math.round(32/n*1e3),dropMs:RJ(47)}}function pX(e=fX()){return[[`--ball-launch-y`,`${-e.launchHeightPx}px`],[`--ball-peak-y`,`${-e.peakHeightPx}px`],[`--ball-rim-y`,`${-e.heightThroughRimPx}px`],[`--ball-net-exit-y`,`${-e.heightLeavingNetPx}px`],[`--ball-drop-out-y`,`${-e.heightOutOfCardPx}px`],[`--ball-rise-ms`,`${e.riseMs}ms`],[`--ball-fall-to-rim-ms`,`${e.fallToRimMs}ms`],[`--ball-to-rim-ms`,`${e.riseMs+e.fallToRimMs}ms`],[`--ball-net-catch-ms`,`${e.netCatchMs}ms`],[`--ball-drop-ms`,`${e.dropMs}ms`]]}var mX=`<svg viewBox="0 0 40 48" aria-hidden="true"><rect class="merge-swish-pole" x="36" y="28" width="2" height="20"/><rect class="merge-swish-backboard" x="35" y="2" width="3" height="26" rx="1"/><path class="merge-swish-rim" d="M31 18H35M7 18A12 2.5 0 0 1 31 18"/></svg>`,hX=`<svg viewBox="0 0 40 48" aria-hidden="true"><g class="merge-swish-net"><path d="M8 18L12 32M13.5 18L15.5 32M19 18V32M24.5 18L22.5 32M30 18L26 32M9.5 23Q19 25 28.5 23M11 28Q19 29.5 27 28"/></g><path class="merge-swish-rim" d="M7 18A12 2.5 0 0 0 31 18"/></svg>`;function gX(){let e=m(`div`,`merge-swish-ball-drift`),t=m(`div`,`merge-swish-ball-arc`);return t.append(m(`span`,`merge-swish-ball`)),e.append(t),e}function _X(){let e=m(`div`,`merge-swish-court`);g(e,pX());let t=m(`div`,`merge-swish-track`);return t.append(gX()),e.append(h(`div`,`merge-swish-hoop-back`,mX),t,h(`div`,`merge-swish-hoop-front`,hX)),e}var vX=[oX,{title:`SWISH!`,buildScene:_X},QJ,lY,wY],yX=48,bX=5600,xX=20,SX=null,CX=[],wX=null,TX=!1,EX=0;function DX(e){let t=m(`span`,`merge-confetti-piece`),n=m(`span`,`merge-confetti-arc`);return n.append(m(`span`,`merge-confetti-paper`)),t.append(n),g(t,KJ(e)),t}function OX(e){let t=m(`p`,`merge-celebration-title`);return t.setAttribute(`aria-hidden`,`true`),Array.from(e).forEach((e,n)=>{let r=m(`span`,`merge-celebration-letter`,e);r.style.setProperty(`--letter-delay`,`${n*45}ms`),t.append(r)}),t}function kX(e,t){let n=t.firstElementChild,r=t.lastElementChild;n instanceof HTMLElement&&r instanceof HTMLElement&&(e.style.setProperty(`--celebration-title-width`,`${r.offsetLeft+r.offsetWidth-n.offsetLeft}px`),e.style.setProperty(`--celebration-title-center-y`,`${t.offsetTop+t.offsetHeight/2}px`))}function AX(e){let t=m(`div`,`merge-celebration-scene`);return t.setAttribute(`aria-hidden`,`true`),t.append(e.buildScene()),t}function jX(){return vX[Math.floor(Math.random()*vX.length)]}function MX(e){if(fp())try{ZT(LJ(e))}catch{}}function NX(e){let t=m(`ul`,`merge-celebration-details`);for(let n of e)t.append(m(`li`,`merge-celebration-detail`,n));return t}function PX(e,t,n){SX?.remove(),MX(n);let r=m(`div`,`merge-celebration`);r.setAttribute(`role`,`status`);let i=m(`div`,`merge-celebration-card`),a=m(`div`,`merge-celebration-stage`),o=OX(t.title);a.append(o,m(`p`,`merge-celebration-message`,e.message),NX(e.detailLines),AX(t));let s=m(`div`,`merge-confetti`);s.style.setProperty(`--confetti-scale`,String(WJ(n)));for(let e=0;e<yX;e+=1)s.append(DX(e));i.append(s,a),r.append(i),document.body.append(r),kX(a,o),SX=r,window.setTimeout(()=>{r.remove(),SX===r&&(SX=null)},bX)}function FX(e){return TX?`playing`:e?`queued`:`empty`}function IX(){if(!wX)return;let e=CX.length>0;wX.tray.dataset.state=FX(e),wX.count.textContent=e?String(CX.length):``,wX.button.disabled=TX||!e}function LX(){let e=CX.shift();TX=e!==void 0,IX(),e&&(PX(e.text,e.scene,EX),EX+=1,window.setTimeout(LX,bX))}function RX(e,t,n){wX={tray:e,button:t,count:n},t.addEventListener(`click`,()=>{EX=0,LX()}),IX()}function zX(e,t=jX()){CX.push({text:e,scene:t}),CX.length>xX&&CX.shift(),IX()}var BX={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},VX=new Set([`FAILURE`,`ERROR`]);function HX(e){return BX[e]}function UX(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&&VX.has(e.checks.state)?`Checks are failing`:e.stage===`ready`?null:`Not ready to merge yet`:`Closed`}function WX(e,t,n,r,i,a){return{isVisible:a&&(e.state===`OPEN`||t),isPressed:t,isDisabled:n,statusText:r||(n?`Saving...`:i)}}function GX(e,t,n=``){if(!t||!e.keepMergeable)return null;let r=KX(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 KX(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`),WX(e,!!e.keepMergeable,t,n,o,r)}function qX(e){return e?.isKeepMergeableEnabled!==!1}function JX(e){return e?.isMergeQueueEnabled!==!1}var YX={one:`st`,two:`nd`,few:`rd`,other:`th`},XX=new Intl.PluralRules(`en-US`,{type:`ordinal`});function ZX(e){return`${e}${YX[XX.select(e)]??`th`}`}function QX(e,t,n){return e===null?`Not queued`:t?`Repair pushed, waiting for you`:n?`Queued, the last merge failed and retries an hour later once it is ready`:`Queued, ${ZX(e)} in line for this repository`}function $X(e,t,n=``,r=!0){let i=e.mergeQueuePosition??null;return WX(e,i!==null,t,n,QX(i,!!e.isMergeQueueHeldForRepairPush,!!e.mergeQueueFailure),r)}var eZ=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],tZ=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],nZ={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`},rZ={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`},iZ={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`},aZ={merged:`merged`,draft:`draft`,conflicts:`conflict`,behind:`behind`,"checks-failing":`failed`,"changes-requested":`changes-requested`,"unresolved-threads":`thread`,"checks-pending":`running`,"needs-approval":`reviewer`,ready:`ready`,unknown:`unknown`};function oZ(e){let t=tc.safeParse(e);return t.success?t.data:null}function sZ(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 cZ(e){return eZ[e.rows.reduce((e,{pr:t})=>Math.min(e,eZ.indexOf(nZ[t.stage])),eZ.length-1)]}function lZ(e){let t=new Map(eZ.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of sZ(e)){let e=t.get(cZ(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return tZ.flatMap(e=>t.get(e)??[])}function uZ(e){return rZ[e]}function dZ(e){return iZ[e]}function fZ(e){return aZ[e]}function pZ(e){if(e.checks.failing.length>0){let t=e.checks.failing.length-3;return{label:`Checks`,tone:`danger`,icon:`failed`,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`,icon:`failed`,text:`Failing`}:e.checks.pendingCount>0?{label:`Checks`,tone:`wait`,icon:`running`,text:`${e.checks.pendingCount} running`}:e.checks.state===`PENDING`||e.checks.state===`EXPECTED`?{label:`Checks`,tone:`wait`,icon:`running`,text:`Running`}:e.checks.state===`SUCCESS`?{label:`Checks`,tone:`ok`,icon:`passed`,text:`Passing`}:{label:`Checks`,tone:`muted`,icon:`none`,text:`No checks`}}function mZ(e){return`${e} ${e===1?`approval`:`approvals`}`}function hZ(e){return e.reviewRequests.map(e=>e.name).join(`, `)}function gZ(e){let t=e.reviewRequests.length>0?`Requested: ${hZ(e)}`:`Approval required`;return e.approvals>0?`${t}, ${mZ(e.approvals)}`:t}function _Z(e){let t=e.approvals>0?mZ(e.approvals):`Approved`;return e.mergeStateStatus===`BLOCKED`?{label:`Review`,tone:`wait`,icon:`reviewer`,text:`${t}, merge blocked`}:{label:`Review`,tone:`ok`,icon:`passed`,text:t}}function vZ(e){return e.reviewDecision===`CHANGES_REQUESTED`?{label:`Review`,tone:`warn`,icon:`changes-requested`,text:`Changes requested`}:e.reviewDecision===`APPROVED`?_Z(e):e.reviewDecision===`REVIEW_REQUIRED`||e.mergeStateStatus===`BLOCKED`?{label:`Review`,tone:`wait`,icon:`reviewer`,text:gZ(e)}:e.reviewRequests.length>0?{label:`Review`,tone:`wait`,icon:`reviewer`,text:`Requested: ${hZ(e)}`}:{label:`Review`,tone:`muted`,icon:`none`,text:`No review requested`}}function yZ(e,t){return t?e.lastAuthor!==t:null}function bZ(e){let t=e.line===null?e.path:`${e.path}:${e.line}`;return e.isOutdated?`${t} (outdated)`:t}function xZ(e){let t=e.commentCount-1;return t===0?`No replies`:`${t} ${t===1?`reply`:`replies`}, last by ${e.lastAuthor??`a deleted account`}`}function SZ(e,t){let n=yZ(e,t);return n===null?null:n?{tone:`warn`,icon:`your-turn`,text:`Waiting on you`}:{tone:`wait`,icon:`reviewer`,text:`Waiting on reviewer`}}function CZ(e,t){return[...e.threads].sort((e,n)=>{let r=Number(yZ(n,t)===!0)-Number(yZ(e,t)===!0);return r===0?(Date.parse(n.lastActivityAt)||0)-(Date.parse(e.lastActivityAt)||0):r}).map(e=>({location:bZ(e),url:e.url,author:e.author??`a deleted account`,excerpt:e.excerpt,replySummary:xZ(e),lastActivityAt:e.lastActivityAt,waiting:SZ(e,t)}))}function wZ(e,t){if(e.unresolvedThreads===0)return{label:`Threads`,tone:`ok`,icon:`passed`,text:`None open`};let n=`${e.unresolvedThreads} unresolved`;if(!t||e.threads.length===0)return{label:`Threads`,tone:`warn`,icon:`thread`,text:n};let r=e.threads.filter(e=>yZ(e,t)).length;return r===0?{label:`Threads`,tone:`wait`,icon:`thread`,text:`${n}, all waiting on reviewers`}:{label:`Threads`,tone:`warn`,icon:`your-turn`,text:`${n}, ${r} waiting on you`}}function TZ(e){return e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?{label:`Conflicts`,tone:`danger`,icon:`conflict`,text:`Conflicts with ${e.baseRefName}`}:e.mergeable===`MERGEABLE`?{label:`Conflicts`,tone:`ok`,icon:`passed`,text:`None`}:{label:`Conflicts`,tone:`muted`,icon:`unknown`,text:`Not computed yet`}}function EZ(e){let t=e.behindBy!==null&&e.behindBy>0;return e.mergeStateStatus===`BEHIND`?{label:`Base`,tone:`warn`,icon:`behind`,text:t?`${e.behindBy} behind ${e.baseRefName}`:`Behind ${e.baseRefName}`}:e.behindBy===null?{label:`Base`,tone:`muted`,icon:`unknown`,text:`Unknown`}:t?{label:`Base`,tone:`muted`,icon:`behind`,text:`${e.behindBy} behind ${e.baseRefName}, update not required`}:{label:`Base`,tone:`ok`,icon:`passed`,text:`Up to date with ${e.baseRefName}`}}var DZ={APPROVED:{text:`Approved`,tone:`ok`,icon:`passed`},CHANGES_REQUESTED:{text:`Requested changes`,tone:`warn`,icon:`changes-requested`},COMMENTED:{text:`Commented`,tone:`muted`,icon:`thread`},DISMISSED:{text:`Dismissed`,tone:`muted`,icon:`discarded`},PENDING:{text:`Pending`,tone:`wait`,icon:`running`}};function OZ(e){return[...e.reviews].sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).map(e=>{let t=DZ[e.state]??{text:e.state.toLowerCase().replaceAll(`_`,` `),tone:`muted`,icon:`unknown`};return{reviewer:e.reviewer??`a deleted account`,text:t.text,tone:t.tone,icon:t.icon,submittedAt:e.submittedAt}})}function kZ(e,t=null){if(e.state===`MERGED`)return[];let n=[pZ(e),vZ(e),wZ(e,t),TZ(e),EZ(e)],r=e.autoRebase?[AZ(e,e.autoRebase)]:[],i=e.mergeQueueFailure?[{label:`Merge when ready`,tone:`danger`,icon:`failed`,text:`Merge failed: ${e.mergeQueueFailure.message}`}]:[];return[...n,...r,...i]}function AZ(e,t){return t.outcome===`rebased`?{label:`Auto-rebase`,tone:`ok`,icon:`passed`,text:t.message}:{label:`Auto-rebase`,tone:e.mergeStateStatus===`BEHIND`?`danger`:`warn`,icon:`failed`,text:t.message}}function jZ(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 MZ(e,t=0){if(!e)return[];let n=fJ(e,t),r=n?[{text:n,tone:`error`}]:[];return e.truncatedNote?[...r,{text:e.truncatedNote,tone:`info`}]:r}function NZ(e){return`${e.repo}#${e.number}`.toLowerCase()}function PZ(e){let t=new Map;for(let n of e)for(let e of n.links){let r=NZ(e),i=t.get(r)??[];i.at(-1)?.id!==n.id&&(i.push({id:n.id,title:n.title}),t.set(r,i))}return t}function FZ(e,t){let n=e.flatMap(e=>e.prs);return t&&n.some(e=>e.key===t)?t:n[0]?.key??null}function IZ(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))}var LZ=3;function RZ(e){if(e.length===1)return{message:`Merged ${e[0].key}`,detailLines:[e[0].title]};let t=e.slice(0,LZ).map(e=>`${e.key} ${e.title}`),n=e.length-t.length,r=n>0?[...t,`and ${n} more`]:t;return{message:`Merged ${e.length} pull requests`,detailLines:r}}var zZ={isVisible:!1,isDisabled:!0,statusText:``,tone:null},BZ={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 VZ(e,t){if(e.state!==`OPEN`)return zZ;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,...BZ[n.phase]};let r=UX(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 ${HX(e.mergeMethod)}`,tone:null}}function HZ(e){return`Merge ${e.key} "${e.title}" into ${e.baseRefName} with ${HX(e.mergeMethod)}, your default for this repository. Glimmervoid does not delete the branch.`}function UZ(e){let t=nc.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 WZ=null,GZ=null,KZ=null,qZ=null,JZ=null,YZ=null,XZ=null,ZZ=new Map,QZ=new Set,$Z=new Map,eQ=new Map,tQ=!1,nQ=null,rQ={label:`Keep mergeable`,pendingKeys:new Set,errorsByKey:new Map,controlState:(e,t,n,r)=>KX(e,t,n,r,Bh(e.keepMergeableAttempt?.at)),isFeatureEnabled:qX,save:async(e,t)=>{let n=await Ym(`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.`}},iQ={label:`Merge when ready`,pendingKeys:new Set,errorsByKey:new Map,controlState:$X,isFeatureEnabled:JX,save:async(e,t)=>{let n=await Ym(`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.`}},aQ=6e4,oQ=`No reply from the server. Check GitHub before trying again.`;function sQ(e,t){let n=m(`div`,`reviews-refresh-control`),r=m(`button`,`pr-action pr-action-ghost reviews-refresh-button`,`Refresh`);r.type=`button`;let i=m(`span`,`reviews-refresh-status`);i.setAttribute(`role`,`status`);let a=m(`p`,`my-pr-error reviews-retry-notice`);n.append(r,i);let o=null,s=!1,c=``,l=null;function u(){a.textContent=fJ(o,Date.now()),a.hidden!==!o?.error&&(a.hidden=!o?.error);let e=a.isConnected&&!T(t)&&!document.hidden&&a.getClientRects().length>0&&dJ(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=pJ(e,s,c),i.hidden=!i.textContent,u()}r.addEventListener(`click`,async()=>{if(!s){s=!0,c=``,d(o);try{let t=await Ym(`github-polling-refresh`,{lane:e});t.type===`github-polling-refresh-result`&&(c=t.ok?`Refreshed.`:t.error??`Could not refresh from GitHub.`)}catch(e){c=uh(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 cQ(e,t,n,r){ZZ.set(e,{head:t,phase:n,text:r}),CQ()}function lQ(e){if($Z.has(e.key))return;let t=Jm(`my-pr-merge`);if(!G({type:`my-pr-merge`,requestId:t,repo:e.repo,number:e.number,headRefOid:e.headRefOid})){cQ(e.key,e.headRefOid,`failed`,`Not connected to the server.`);return}let n=window.setTimeout(()=>{$Z.delete(e.key),cQ(e.key,e.headRefOid,`failed`,oQ)},aQ);$Z.set(e.key,{requestId:t,head:e.headRefOid,timer:n}),ZZ.set(e.key,{head:e.headRefOid,phase:`pending`,text:``}),CQ()}function uQ(e){let t=VZ(e,ZZ.get(e.key));if(!t.isVisible)return null;let n=m(`div`,`my-pr-merge`),r=m(`button`,`pr-action`,`Merge`);r.type=`button`,r.disabled=t.isDisabled;let i=m(`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`,()=>{lh({title:`Merge pull request`,message:HZ(e),confirmLabel:`Merge`,onConfirm:()=>lQ(e)})}),n.append(r,i),n}function dQ(e,t){let n=t.controlState(e,t.pendingKeys.has(e.key),t.errorsByKey.get(e.key),t.isFeatureEnabled(JZ));if(!n.isVisible)return null;let r=m(`div`,`my-pr-merge`),i=m(`button`,`pr-action`,t.label);i.type=`button`,i.disabled=n.isDisabled,i.setAttribute(`aria-pressed`,String(n.isPressed));let a=m(`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),CQ();try{let r=await t.save(e,!n.isPressed);r&&t.errorsByKey.set(e.key,r)}catch(n){t.errorsByKey.set(e.key,uh(n))}finally{t.pendingKeys.delete(e.key),CQ()}}}),r.append(i,a),r}function fQ(e,{hasGlyph:t}){let n=m(`span`,`my-pr-stage`);return n.dataset.tone=dZ(e.stage),t&&n.append(wJ(fZ(e.stage),dZ(e.stage))),n.append(uZ(e.stage)),n}function pQ(e,t){let n=m(`span`,`my-pr-requested`);n.append(m(`span`,null,`Requested`));let r=m(`span`,`avatar-stack`);for(let t of e.reviewRequests){let e=_({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,m(`span`,`my-pr-requested-names`,t.slice(11))),n}function mQ(){if(!WZ||!GZ||KZ?.isConnected)return;let e=SJ({queueLabel:`My pull requests`,scopeTabs:GZ,resizerLabel:`Resize pull request list`});KZ=e.queue,qZ=e.detail,WZ.replaceChildren(e.columns),XZ&&e.foot.append(XZ.control)}function hQ(e){if(!qZ)return;if(!e){qZ.replaceChildren(m(`p`,`pr-empty`,jZ(JZ)));return}let t=m(`article`,`pr-detail`),n=m(`div`,`pr-detail-heading`),r=m(`div`,`pr-detail-title`);r.append(x(`pr-link`,e.key,e.url),m(`h2`,null,e.title)),n.append(r,fQ(e,{hasGlyph:!0})),t.append(n);for(let n of[rQ,iQ]){let r=dQ(e,n);r&&t.append(r)}let i=kZ(e,JZ?.viewer??null);if(i.length>0){let n=m(`section`,`pr-readiness-section`);n.append(m(`h3`,`pr-section-heading`,`Merge readiness`));let r=m(`ul`,`pr-readiness`);for(let t of i){let n=m(`li`,`pr-readiness-row`),i=m(`span`,`pr-readiness-value`);t.label===`Review`&&t.text.startsWith(`Requested: `)&&i.append(pQ(e,t.text)),i.childNodes.length===0&&(i.textContent=t.text),n.append(wJ(t.icon,t.tone),m(`span`,`pr-readiness-label`,t.label),i),r.append(n)}n.append(r);let a=uQ(e);a&&n.append(a),t.append(n)}if(e.checks.failing.length>0){let n=m(`section`,`my-pr-failures`);n.append(m(`h3`,`pr-section-heading`,`Failing checks`));let r=m(`ul`,`my-pr-facts`);for(let t of e.checks.failing)r.append(m(`li`,null,t));n.append(r),t.append(n)}let a=OZ(e);if(a.length>0){let e=m(`section`,`pr-readiness-section`);e.append(m(`h3`,`pr-section-heading`,`Reviews`));let n=m(`ul`,`pr-readiness`);for(let e of a){let t=m(`li`,`pr-readiness-row`),r=Date.parse(e.submittedAt??``),i=Number.isFinite(r)?`${e.text} ${Bh(r)}`:e.text,a=m(`span`,`my-pr-reviewer`);a.append(v([{login:e.reviewer,tone:e.tone,title:e.reviewer,url:e.reviewer===`a deleted account`?null:void 0}],16),m(`span`,null,e.reviewer)),t.append(wJ(e.icon,e.tone),a,m(`span`,`pr-readiness-value`,i)),n.append(t)}e.append(n),t.append(e)}let o=CZ(e,JZ?.viewer??null);if(o.length>0){let e=m(`section`,`my-pr-threads-section`);e.append(m(`h3`,`pr-section-heading`,`Unresolved threads`));let n=m(`ul`,`my-pr-threads`);for(let e of o){let t=m(`li`,`my-pr-thread`),r=m(`div`,`my-pr-thread-heading`);if(r.append(x(`my-pr-thread-location`,e.location,e.url)),e.waiting){let t=m(`span`,`my-pr-stage`);t.dataset.tone=e.waiting.tone,t.append(wJ(e.waiting.icon,e.waiting.tone),e.waiting.text),r.append(t)}let i=m(`p`,`my-pr-thread-excerpt`);i.append(m(`strong`,null,e.author),` ${e.excerpt}`);let a=Date.parse(e.lastActivityAt),o=m(`p`,`my-pr-thread-meta`,Number.isFinite(a)?`${e.replySummary}, ${Bh(a)}`:e.replySummary);t.append(r,i,o),n.append(t)}e.append(n),t.append(e)}let s=m(`p`,`pr-detail-meta`);s.append(m(`span`,null,`Opened ${Bh(Date.parse(e.createdAt))}`),m(`span`,null,`${e.state===`MERGED`?`Merged`:`Updated`} ${Bh(Date.parse(e.state===`MERGED`?e.mergedAt??``:e.updatedAt))}`)),t.append(s),qZ.replaceChildren(t)}function gQ(){return[...eQ].flatMap(([e,t])=>{let n=E.get(e);return!n||t.length===0?[]:[{id:e,title:D(n)||e,links:t}]})}function _Q(e){let t=e.dataset.sessionId??``,n=E.get(t),r=b(e,`.session-row-name`);n&&(r.textContent=D(n)||t);let i=DV(e,{glyph:b(e,`.session-row-glyph`),label:b(e,`.session-row-label`)},n?.currentState||a.DORMANT,n?.awaitingBackgroundTasks,n?.pendingPromptKind),o=`Focus session ${r.textContent}, ${i}`;e.title=o,e.setAttribute(`aria-label`,o)}function vQ(e){let{row:t,refs:n}=TV(`button`,`my-pr-session-pill`);return t.type=`button`,t.dataset.sessionId=e.id,n.name.textContent=e.title,_Q(t),t.addEventListener(`click`,()=>nQ?.(e.id)),t}function yQ(e){if(!e||e.length===0)return null;let t=m(`div`,`my-pr-session-focus`);return t.append(...e.map(vQ)),t}function bQ(){for(let e of KZ?.querySelectorAll(`.my-pr-session-pill`)??[])_Q(e)}function xQ(){tQ||(tQ=!0,queueMicrotask(()=>{tQ=!1,CQ()}))}function SQ(e){eQ=e,xQ()}function CQ(){if(mQ(),!KZ)return;let e=JZ?.prs??[],t=lZ(e);YZ=FZ(t,YZ);let n=document.activeElement instanceof HTMLElement&&KZ.contains(document.activeElement)?document.activeElement.dataset.prKey:null,r=PZ(gQ()),i=t.filter(e=>e.rows.length>0).map(e=>{let t=m(`section`,`pr-queue-section`);t.append(m(`h3`,`pr-section-heading`,`${e.title} ${e.rows.length}`));for(let{pr:n,parentKey:i,depth:a}of e.rows){let e=m(`button`,`pr-queue-row`);e.type=`button`,e.dataset.prKey=n.key,i&&(e.style.paddingInlineStart=`${12+Math.min(a,6)*16}px`),e.setAttribute(`aria-current`,String(n.key===YZ)),e.title=`${n.key}: ${uZ(n.stage)}`;let o=m(`span`,`pr-queue-glyph`);o.append(wJ(fZ(n.stage),dZ(n.stage)));let s=m(`span`,`pr-queue-top`);s.append(m(`strong`,`pr-queue-ref`,n.key),m(`span`,`pr-queue-title`,n.title));let c=m(`span`,`pr-queue-bottom`);i&&c.append(m(`span`,`my-pr-stage`,`Stacked on ${i}`));let l=n.state===`MERGED`?n.mergedAt:null,u=l?`merged ${Bh(Date.parse(l))}`:`opened ${Bh(Date.parse(n.createdAt))}`;c.append(fQ(n,{hasGlyph:!1}),m(`span`,`pr-queue-elapsed`,u));let d=GX(n,rQ.isFeatureEnabled(JZ),Bh(n.keepMergeableAttempt?.at));if(d){let e=m(`span`,`my-pr-stage`,d.text);e.dataset.tone=d.tone,e.title=d.title,c.append(e)}e.append(o,s,c),e.addEventListener(`click`,()=>{YZ=n.key;for(let e of KZ?.querySelectorAll(`button[data-pr-key]`)??[])e.setAttribute(`aria-current`,String(e.dataset.prKey===YZ));hQ(n),document.documentElement.dataset.layout===`phone`&&qZ?.scrollIntoView({block:`start`,behavior:`smooth`})}),t.append(e);let f=yQ(r.get(NZ(n)));f&&(i&&(f.style.paddingInlineStart=`${36+Math.min(a,6)*16}px`),t.append(f))}return t});if(i.length===0&&KZ.replaceChildren(m(`p`,`pr-empty`,jZ(JZ))),i.length>0){let e=MZ(JZ,Date.now()).filter(e=>e.tone!==`error`).map(e=>m(`p`,e.tone===`error`?`my-pr-error`:`my-pr-note`,e.text));KZ.replaceChildren(...e,...i)}XZ&&(KZ.prepend(XZ.notice),XZ.update(JZ)),n&&[...KZ.querySelectorAll(`button[data-pr-key]`)].find(e=>e.dataset.prKey===n)?.focus({preventScroll:!0}),hQ(e.find(e=>e.key===YZ))}function wQ(e,t,n){return nQ=n?.openTerminal??null,WZ||(GZ=t,WZ=m(`div`,`pr-content`),e.append(WZ),XZ=sQ(`my-prs`,WZ),CQ(),WZ)}function TQ(){return JZ}function EQ(e){let t=oZ(e);if(!t)return;let n=IZ(JZ?.prs??null,t.prs);JZ=t,CQ(),DQ(n)}function DQ(e){let t=e.filter(e=>!QZ.has(e.key));if(t.length!==0){for(let e of t)QZ.add(e.key);zX(RZ(t))}}function OQ(e){let t=UZ(e);if(!t)return;let n=$Z.get(t.key);if(!n||n.requestId!==t.requestId)return;if(window.clearTimeout(n.timer),$Z.delete(t.key),!t.ok){cQ(t.key,n.head,`failed`,t.error||`The merge failed.`);return}if(cQ(t.key,n.head,t.kind??`unconfirmed`,``),t.kind!==`merged`)return;let r=JZ?.prs.find(e=>e.key===t.key);r&&DQ([r])}var kQ=Es.options.join(`|`),AQ=String.raw`\*\*(?:\[([^\]\n]+)\]\s+)?(${kQ})\*\*`;function jQ(e){return[...e.matchAll(new RegExp(AQ,`g`))].flatMap(e=>{let t=Es.safeParse(e[2]);return t.success?[t.data]:[]})}function MQ(e){let t=new RegExp(String.raw`^${AQ}\s*(?:\r?\n|$)`).exec(e);if(!t)return null;let n=Es.safeParse(t[2]);return n.success?{reviewer:t[1]??null,severity:n.data,length:t[0].length}:null}function NQ(e){let t=e.trimStart();return t.startsWith(`> [!NOTE]
263
+ > Automated review. Not written by a human.`)?t.slice(53).trim():e.trim()}var PQ={"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 FQ(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 IQ={APPROVE:{label:`You approved`,tone:`ok`,icon:`passed`},COMMENT:{label:`You commented`,tone:`muted`,icon:`thread`}},LQ={APPROVED:{label:`You approved`,tone:`ok`,icon:`passed`},CHANGES_REQUESTED:{label:`You requested changes`,tone:`wait`,icon:`changes-requested`},COMMENTED:{label:`You commented`,tone:`muted`,icon:`thread`}};function RQ(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?LQ[t.state]:null;if(!t)return IQ[e.postedEvent];let n=Date.parse(t.submittedAt??``);return Number.isNaN(n)||e.postedAt!==void 0&&e.postedAt>n?IQ[e.postedEvent]:LQ[t.state]}var zQ={"changes-requested":`changes-requested`,"checks-failing":`failed`,"checks-pending":`running`,draft:`draft`};function BQ(e){let{reason:t}=FQ(e),n=zQ[t];return n?{text:PQ[t],icon:n}:null}function VQ(e){return BQ(e)?.text??null}var HQ={discarded:{tone:`muted`,icon:`discarded`,meaning:`Not mine`},handReview:{tone:`warn`,icon:`fork`,meaning:`From a fork`}};function UQ(e,t){let n=VQ(t);return n?`${e}, ${n}`:e}function WQ(e){if(Is(e))return!0;let t=(e.githubReviews??[]).filter(e=>e.isViewer);return t.length===0||t.some(t=>t.commit===y$(e))}var GQ={tone:`warn`,icon:`your-turn`,meaning:`Comments resolved`};function KQ(e,t){let n=HQ[t];if(n)return n;if(t===`inReview`)return{tone:`wait`,icon:`running`,meaning:UQ(`In review`,e)};if(t===`queued`)return{tone:`muted`,icon:`queued`,meaning:UQ(`Queued`,e)};if(t===`settled`&&`reviewedHead`in e){let t=WQ(e)?RQ(e):null;return t?{tone:t.tone,icon:t.icon,meaning:t.label}:{tone:`ok`,icon:`passed`,meaning:`Others reviewed`}}if(t===`posted`&&`reviewedHead`in e){let t=RQ(e);return t?{tone:t.tone,icon:t.icon,meaning:t.label}:{tone:`muted`,icon:`none`,meaning:`Posted`}}if(t===`attention`&&`status`in e)return e.status===`error`?{tone:`danger`,icon:`failed`,meaning:`Review failed`}:{tone:`warn`,icon:`stale`,meaning:`Out of date`};let r=BQ(e);return r?{tone:`wait`,icon:r.icon,meaning:r.text}:t===`ready`&&`reviewedHead`in e&&YQ(e)?GQ:{tone:`warn`,icon:`your-turn`,meaning:`Waits on you`}}function qQ(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function JQ(e){return e.status===`posted`&&YQ(e)}function YQ(e){if(!qQ(e)||Is(e))return!1;let t=y$(e);return!(e.githubReviews??[]).some(e=>e.isViewer&&e.state===`APPROVED`&&e.commit===t)}function XQ(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 ZQ(e){return`${e} ${e===1?`comment`:`comments`}`}function QQ(e,t,n){let r=[`${X$(e.repo,e.number)}: ${e.title}`],i=`reviewedHead`in e?e.assessment?.goal.trim():``;if(i&&r.push(i),r.push(KQ(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(`
264
+ `);let a=XQ(e.viewerThreads);a&&r.push(a);let o=e.comments.length;e.status!==`error`&&r.push(`Automated review: ${d$(e.verdict)}, ${ZQ(o)}`);let s=D$(e);s&&r.push(`You ${p$[s.state]} at ${bs(s.approvedCommit)}${n.viewerApproval?` ${n.viewerApproval}`:``}; new commits since.`),(t===`attention`||t===`discarded`)&&r.push(d1(e));let c=j$(e,{isViewerShown:t!==`posted`});for(let[e,t]of c.entries())r.push(A$(t.text,n.githubReviews?.[e]??null));return r.join(`
265
+ `)}function $Q(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 e$(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:$Q({...e,ready:[],attention:[]})??``}}function t$(e){let t=e.trim();return t.endsWith(`.`)?t:`${t}.`}function n$({action:e,pullRequest:t,warning:n,isActedSelected:r}){let i=S1(e),a=`${t}: ${t$(i)}`;return n.trim()?{statusText:i,shouldAdvance:!1,notice:{text:`${a} ${t$(n)}`,tone:`error`}}:{statusText:i,shouldAdvance:r,notice:null}}function r$(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 i$(e,t,n){return n?X$(e,t):`#${t}`}var a$={CRITICAL:{filledCount:3,colorToken:`--state-failed`},HIGH:{filledCount:3,colorToken:`--state-waiting`},MEDIUM:{filledCount:2,colorToken:`--accent`},LOW:{filledCount:1,colorToken:`--text-dim`}},o$={APPROVE:`check`,"APPROVE WITH NITS":`dot`,"REQUEST CHANGES":`bar`,BLOCKED:`cross`},s$=`lanes-team-review`,c$=`team-review-enabled`,l$=Object.freeze({APPROVE:`approve`,"APPROVE WITH NITS":`approve with nits`,"REQUEST CHANGES":`request changes`,BLOCKED:`blocked`}),u$={APPROVE:`Approve`,"APPROVE WITH NITS":`Nits`,"REQUEST CHANGES":`Changes`,BLOCKED:`Blocked`};function d$(e){return u$[e]}var f$=Object.freeze({APPROVE:`ok`,"APPROVE WITH NITS":`info`,"REQUEST CHANGES":`warn`,BLOCKED:`crit`}),p$=Object.freeze({APPROVED:`approved`,CHANGES_REQUESTED:`requested changes`,COMMENTED:`commented`}),m$=Object.freeze({preparing:`fetching the diff`,checkout:`checking out the head`,reviewing:`agent reviewing`}),h$=Object.freeze({approve:`Approved on GitHub`,"approve-only":`Approved on GitHub`,comment:`Comment posted on GitHub`,discard:`Marked not mine. Not reviewed again until queued.`,requeue:`Queued. The next poll reviews it again.`,"resolve-thread":`Thread resolved on GitHub`}),g$=Object.freeze({approve:`Posting the approval`,"approve-only":`Posting the approval`,comment:`Posting the comment`,discard:`Marking not mine`,requeue:`Queueing the review`,"resolve-thread":`Resolving thread`});function _$(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=>b$(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[FQ(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(b$(r).length>0||JQ(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!T$(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[FQ(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 v$(e,t){return e.commit===t?e.isViewer||Ms.has(e.state):!1}function y$(e){return e.liveHead??e.reviewedHead}function b$(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function x$(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 S$(e){return(e.threads??[]).filter(e=>!e.isResolved&&(!e.isNit||e.resolveError)).map(t=>{let n=x$(t,y$(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 C$=40;function w$(e,t){return e.split(`
266
+ `).reduce((e,t)=>e+Math.max(1,Math.ceil(t.length/C$)),0)>t}function T$(e){return b$(e).length>0?!0:Is(e)?!1:YQ(e)?!0:!(e.githubReviews??[]).some(t=>v$(t,y$(e)))}function E$(e,t){let n=p$[e.state];return e.isViewer?e.commit===t?`you ${n}`:`you ${n} (older commit)`:`${n} by ${e.login}`}function D$(e){if(Is(e))return null;let t=(e.githubReviews??[]).filter(e=>e.isViewer&&Ms.has(e.state)).sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).at(0);if(!t?.commit||t.commit===y$(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 O$(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 ${bs(e.approvedCommit)}${t?` ${t}`:``}. It has new commits since`;return e.isReviewScopeSinceDecision?`${i}, so this review covers what changed after ${r}.`:`${i}.`}function k$(e){return e===`APPROVED`?`ok`:e===`CHANGES_REQUESTED`?`warn`:`muted`}function A$(e,t){return t?`${e}, ${t}`:e}function j$(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:k$(t.state),text:E$(t,y$(e)),submittedAt:t.submittedAt}))}function M$(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 N$(e){return[...e.ready,...e.attention].map(e=>e.key)}function P$({capturedOrder:e,actedKey:t,groups:n}){let r=N$(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 F$(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 I$(e){return a$[e]}function L$(e){return o$[e]}function R$(e){let t=jQ(e.body);return t.length>0?t:e.severity?[e.severity]:[]}function z$(e){let t=R$(e);return Es.options.find(e=>t.includes(e))??null}function B$(e){return z$(e)!==`LOW`}var V$=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(`.`)),H$=/^([\w.@~/-]+):\d+(?:-\d+)?$/;function U$(e){let t=H$.exec(e)?.[1];if(t===void 0)return!1;let n=t.slice(t.lastIndexOf(`/`)+1),r=n.lastIndexOf(`.`);return r<0?!1:V$.has(n.slice(r+1).toLowerCase())}var W$=/^```([^\n`]*)\n([\s\S]*?)^```[ \t]*(?=\r?$)/gm;function G$(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:U$(a)?`citation`:`code`}),n=i+r[0].length}return n<e.length&&t.push({text:e.slice(n),kind:`text`}),t}function K$(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:G$(e.slice(t?.[0].length??0))}})}function q$(e){let t=NQ(e),n=MQ(t),r=n?t.slice(n.length).trim():t,i=[],a=0;for(let e of r.matchAll(W$)){let t=e.index??0;i.push(...K$(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(...K$(r.slice(a).trim())),{tag:n?.reviewer??null,severity:n?.severity??null,paragraphs:i}}function J$(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 Y$(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 X$(e,t){return`${e}#${t}`}function Z$(e){return e===`full`?`full`:`light`}function Q$(e){return e.priorReviewedHead?`${Z$(e.tier)} review of changes since ${bs(e.priorReviewedHead)}`:`${Z$(e.tier)} review`}function $$(e){return e.reasons.join(`, `)}function e1(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 vle(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 t1(e){return e?{label:`Coverage`,preview:vle(e)}:{label:`Review audit`,preview:``}}var n1=`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.`,r1=new Set([`error`,`stale`,`discarded`,`posted`]);function i1(e){return r1.has(e)}function a1(e){let t=o1(e);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function o1(e){return l$[e]??String(e).toLowerCase()}function s1(e){return f$[e]??`dim`}function c1(e){return m$[e]??e}function l1(e,t){return`${Xh(t-e.startedAt)} elapsed`}function u1(e,t){let n=[l1(e,t)],r=e.deadlineAt===null?0:e.deadlineAt-t;return r>0&&n.push(`times out in ${Xh(r)}`),e.phase===`reviewing`&&n.push(`${e.toolCalls} ${e.toolCalls===1?`tool call`:`tool calls`}`),n.join(`, `)}function d1(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`?`Marked not mine. Not reviewed again until queued.`:e.error||e.summary||`The review failed.`}function f1(e,t){let n=t.side===`LEFT`?` (old)`:``;return`${e}:${t.line}${n}`}function p1(e){return f1(e.path,e)}function m1(e){return f1(e.path.split(`/`).filter(Boolean).at(-1)??e.path,e)}function h1(e,t){let n=e.trim();return n?t.trim()?`${n}\n\n${t}`:n:t}function g1(e){return{key:e,action:`discard`,body:``,comments:[]}}function _1(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 v1=Object.freeze({approve:`Approve and comment`,"approve-only":`Approve`,comment:`Comment`,discard:`Not mine`,requeue:`Queue review`,"resolve-thread":`Resolve`});function y1(e){return v1[e]}function b1(e){return e.status===`ready`?{footer:[`comment`,`approve-only`,`approve`],more:[`requeue`,`discard`]}:wne(e)?{footer:[`approve-only`],more:[`requeue`]}:e.status===`error`||e.status===`stale`?{footer:[`requeue`],more:[`discard`]}:i1(e.status)?{footer:[`requeue`],more:[]}:{footer:[],more:[]}}function x1(e){return g$[e]}function S1(e){return h$[e]}function C1(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 w1(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 T1(e){return e?.configured&&e.reason||null}function E1(e){return Hh(_$(e).ready.map(e=>`${e.key}@${e.reviewedHead}`))}function D1(e){return`${e.key}@${e.reviewedHead}:${e.status}:${e.summary}:${j$(e).map(e=>e.text).join(`, `)}`}function O1(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 k1(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(`
267
+ `)!==t.inFlight.map(e=>e.key).join(`
268
+ `)||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 A1=12e4,j1=`M4.5 0.5L8.5 5.5L4.5 10.5L0.5 5.5Z`,M1=`GitHub review`,N1=null,P1=null,F1=null,I1=null,L1=null,R1=null,z1=null,B1=null,V1=null,H1=null,U1=null,W1=null,G1=null,K1=null,q1=null,J1=new Map,Y1=Vh(()=>P1),X1=Vh(()=>P1),Z1=Vh(()=>P1),Q1=new WeakMap,$1=new Map,e0=new Map,t0=new Map,n0=Uh({getAck:Xp,setAck:Zp,signature:()=>E1(N1),isLooking:()=>!T(P1)});function yle(e){let t=I$(e),n=m(`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=vM(14,17);e.classList.add(`pr-severity-halo`),e.setAttribute(`viewBox`,`0 0 9 11`),e.append(_M(`path`,{d:j1,fill:`currentColor`})),n.append(e)}for(let e=0;e<3;e+=1){let r=vM(9,11),i=e<t.filledCount;r.append(_M(`path`,{d:j1,fill:i?`currentColor`:`none`,stroke:i?`currentColor`:`var(--border-hover)`,"stroke-width":`1`})),n.append(r)}return n}function ble(e){let{verdict:t}=e,n=m(`span`,`pr-verdict-seal`);n.dataset.tone=s1(t);let r=vM(20,20),i=L$(t);return r.append(_M(`circle`,{cx:`10`,cy:`10`,r:`8.5`,fill:i===`cross`?`currentColor`:`none`,stroke:`currentColor`,"stroke-width":`1.5`})),i===`check`&&r.append(_M(`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(_M(`circle`,{cx:`10`,cy:`10`,r:`2.4`,fill:`currentColor`})),i===`bar`&&r.append(_M(`path`,{d:`M6 10H14`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`})),i===`cross`&&r.append(_M(`path`,{d:`M7 7L13 13M13 7L7 13`,stroke:`var(--bg)`,"stroke-width":`1.8`,"stroke-linecap":`round`})),n.append(r,m(`span`,null,a1(t))),n}function xle(){let e=vM(16,16);return e.append(_M(`rect`,{x:`1`,y:`1`,width:`14`,height:`14`,rx:`2`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`})),e.append(_M(`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(_M(`circle`,{cx:`8`,cy:`11.6`,r:`0.9`,fill:`currentColor`})),e}function r0(e){return x(`pr-link`,X$(e.repo,e.number),e.url)}function i0(e){let t=typeof e==`string`?Date.parse(e):e;return typeof t!=`number`||!Number.isFinite(t)||t<=0?null:t}function a0(e,t){let n=i0(t);if(n===null)return null;let r=m(`span`,null,`${e}${e?` `:``}${Bh(n)}`);return r.dataset.ageAt=String(n),r.dataset.ageLabel=e,r}function o0(e){let t=Q1.get(e);t&&(e.title=t(),e.setAttribute(`aria-label`,e.title))}function Sle(){Z1.reset(),s0(P1)}Xg(Sle);function s0(e){if(e){for(let t of e.querySelectorAll(`.pr-queue-row`))Q1.has(t)&&(o0(t),Z1.onTick(()=>o0(t)));for(let t of e.querySelectorAll(`.pr-rereview-notice`)){let e=N1?.drafts.find(e=>e.key===t.dataset.reviewKey),n=e?D$(e):null;if(!n)continue;let r=()=>{t.textContent=O$(n,l0(n.submittedAt))};r(),Z1.onTick(r)}for(let t of e.querySelectorAll(`[data-review-title]`)){let e=t.dataset.reviewTitle??``,n=t.dataset.ageAt===void 0?null:Number(t.dataset.ageAt),r=()=>{let r=n===null?null:Bh(n),i=Jg()?A$(M1,r):A$(e,r);t.title=i,t.setAttribute(`aria-label`,i)};r(),Z1.onTick(r)}for(let t of e.querySelectorAll(`[data-age-at]`)){if(t.dataset.reviewTitle!==void 0)continue;let e=Number(t.dataset.ageAt),n=t.dataset.ageLabel??``;Z1.track(t,e,()=>`${n}${n?` `:``}${Bh(e)}`)}}}function c0(e,t,n,r=!0){let i=j$(e,{isViewerShown:r});if(i.length===0)return null;let a=m(`span`,t),o=v(i.map(e=>({login:e.login,tone:e.tone,title:A$(Jg()?M1:e.text,l0(e.submittedAt))})),n);for(let[e,t]of i.entries()){let n=o.children[e];if(!(n instanceof HTMLElement))continue;n.dataset.reviewTitle=t.text;let r=i0(t.submittedAt);r!==null&&(n.dataset.ageAt=String(r))}return a.append(o),a}function l0(e){let t=i0(e);return t===null?null:Bh(t)}function u0(e,t,n){let r=m(`span`,n);return r.append(_({login:e,cssPx:t}),m(`span`,`pr-author-login`,e)),r}function d0(e,t){return`${X$(e.repo,e.number)}\n${KQ(e,t).meaning}`}function Cle(e,t,n){let r=m(`button`,`pr-queue-row pr-queue-row-quiet`);r.type=`button`,r.dataset.reviewKey=e.key,r.setAttribute(`aria-current`,String(e.key===V1));let i=`reviewedHead`in e?D$(e):null;Q1.set(r,()=>Jg()?d0(e,t):QQ(e,t,{opened:l0(e.prCreatedAt),reviewed:`reviewedHead`in e?l0(e.reviewedAt):null,posted:`reviewedHead`in e?l0(e.postedAt):null,viewerApproval:l0(i?.submittedAt),githubReviews:`reviewedHead`in e?j$(e,{isViewerShown:t!==`posted`}).map(e=>l0(e.submittedAt)):[]})),o0(r);let a=m0(e,n);if(t===`inReview`){let t=e,n=m(`span`,`pr-queue-elapsed`);Y1.track(n,t.startedAt,()=>l1(t,Date.now())),a.append(n)}if(t===`queued`){let t=a0(``,e.prCreatedAt);t&&(t.classList.add(`pr-queue-elapsed`),a.append(t))}if(t!==`inReview`&&t!==`queued`){let t=e,n=a0(``,t.reviewedAt)??a0(``,t.prCreatedAt);n&&(n.classList.add(`pr-queue-elapsed`),a.append(n))}if(t===`discarded`)return r.classList.add(`pr-queue-row-compact`),r.append(a),f0(r,e.key),r;r.classList.remove(`pr-queue-row-quiet`);let o=KQ(e,t),s=m(`span`,`pr-queue-glyph`);s.append(wJ(o.icon,o.tone));let c=m(`span`,`pr-queue-bottom`);if(c.append(p0(o),u0(e.author,16,`pr-queue-author`)),e.requestSource===`direct`){let e=m(`span`,`pr-queue-direct`,`@`);e.title=`Requested from you directly`,c.append(e)}t===`inReview`&&c.append(m(`span`,`pr-phase-label`,c1(e.phase))),r.append(s,a,c);let l=t===`inReview`||t===`queued`?null:c0(e,`pr-queue-reviewers`,16,t!==`posted`);return l&&c.append(l),f0(r,e.key),r}function f0(e,t){e.addEventListener(`click`,()=>{V1=t,H1=null,g0(null);for(let e of L1?.querySelectorAll(`button[data-review-key]`)??[])e.setAttribute(`aria-current`,String(e.dataset.reviewKey===V1));W0(_$(N1)),Z1.reset(),s0(P1),document.documentElement.dataset.layout===`phone`&&z1?.scrollIntoView({block:`start`,behavior:`smooth`})})}function p0(e){let t=m(`span`,`my-pr-stage pr-queue-state`,e.meaning);return t.dataset.tone=e.tone,t}function m0(e,t){let n=m(`span`,`pr-queue-top`);return n.append(m(`strong`,`pr-queue-ref`,i$(e.repo,e.number,t)),m(`strong`,`pr-queue-ref-compact`,i$(e.repo,e.number,!1)),m(`span`,`pr-queue-title`,e.title)),n}function wle(e,t){let n=m(`section`,`pr-queue-section`);n.append(m(`h3`,`pr-section-heading`,`Review by hand ${e.length}`));for(let r of e){let e=x(`pr-queue-row`,``,r.url);Q1.set(e,()=>Jg()?d0(r,`handReview`):QQ(r,`handReview`,{opened:l0(r.prCreatedAt)})),o0(e);let i=KQ(r,`handReview`),a=m(`span`,`pr-queue-glyph`);a.append(wJ(i.icon,i.tone));let o=m(`span`,`pr-queue-bottom`);o.append(p0(i),u0(r.author,16,`pr-queue-author`)),e.append(a,m0(r,t),o),n.append(e)}return n}function h0({title:e,detail:t}){let n=m(`section`,`pr-caught-up`);n.setAttribute(`role`,`status`);let r=m(`strong`,`pr-caught-up-title`);return r.append(wJ(`ready`,`ok`),m(`span`,null,e)),n.append(r,m(`p`,`pr-caught-up-detail`,t)),n}function g0(e){U1=e,W1&&(W1.hidden=e===null,W1.textContent=e?.text??``,e&&(W1.dataset.tone=e.tone))}function _0(e,t,n,r){let i=m(`section`,`pr-queue-section`);i.append(m(`h3`,`pr-section-heading`,`${e} ${t.length}`));for(let e of t)i.append(Cle(e,n,r));return i}var Tle=`Open in session`,v0=`Preparing the branch and session.`;function y0(e,t,n){for(let r of document.querySelectorAll(`.pr-session-open-status`)){if(r.dataset.reviewKey!==e)continue;r.textContent=t,n&&(r.dataset.tone=n),n||delete r.dataset.tone;let i=r.parentElement?.querySelector(`.pr-session-open-button`);i&&(i.disabled=!1)}}function b0(e,t){let n=J1.get(e);n&&window.clearTimeout(n.timer),J1.set(e,{requestId:null,timer:0,text:t,tone:`error`}),y0(e,t,`error`)}function Ele(e,t,n){if(J1.get(e)?.requestId)return;let r=Jm(`open-team-review-session`);if(!G({type:`open-team-review-session`,requestId:r,key:e})){n.dataset.tone=`error`,n.textContent=`Not connected to the server.`;return}let i=window.setTimeout(()=>b0(e,`No reply from the server.`),A1);J1.set(e,{requestId:r,timer:i,text:v0,tone:`busy`}),t.disabled=!0,n.dataset.tone=`busy`,n.textContent=v0}function x0(e){let t=m(`div`,`pr-session-open`),n=m(`button`,`pr-action pr-session-open-button`,Tle);n.type=`button`;let r=J1.get(e.key);n.disabled=!!r?.requestId;let i=m(`span`,`pr-action-status pr-session-open-status`,r?.text??``);return i.dataset.reviewKey=e.key,r&&(i.dataset.tone=r.tone),i.setAttribute(`role`,`status`),i.setAttribute(`aria-live`,`polite`),n.addEventListener(`click`,()=>Ele(e.key,n,i)),t.append(n,i),t}function S0(e){let t=m(`div`,`pr-detail-heading`);t.dataset.signature=O1(e);let n=m(`div`,`pr-detail-title`);n.append(r0(e),m(`h2`,null,e.title));let r=m(`div`,`pr-detail-meta`);r.append(u0(e.author,20,`pr-detail-author`));let i=m(`span`,null,Q$(e));i.title=$$(e),r.append(i);let a=a0(`Opened`,e.prCreatedAt);if(a&&r.append(a),`reviewedHead`in e){let t=a0(`Reviewed`,e.reviewedAt);t&&r.append(t);let n=a0(`Posted`,e.postedAt);n&&r.append(n)}let o=`reviewedHead`in e?c0(e,`pr-detail-github`,20):null;if(o&&r.append(o),t.append(n,r,x0(e)),`reviewedHead`in e){let n=XQ(e.viewerThreads);if(n){let r=m(`p`,`pr-viewer-threads`,n);qQ(e)&&(r.dataset.state=`all-resolved`),t.append(r)}}let s=`reviewedHead`in e?D$(e):null;if(s){let n=m(`p`,`pr-rereview-notice`,O$(s,l0(s.submittedAt)));n.dataset.reviewKey=e.key,t.append(n)}return t}function C0(e,t){let n=e.querySelector(`:scope > .pr-detail-heading`);if(!n||n.dataset.signature===O1(t))return e;let r=S0(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 w0(e){return`${JSON.stringify(e.threads)}:${e.liveHead}:${e.status}:${e.reviewedHead}:${e.error??``}:${e.postedEvent??``}`}function T0(e,t){for(let n of t){if(n.kind===`text`){e.append(document.createTextNode(n.text));continue}if(n.kind===`code`){e.append(m(`code`,null,n.text));continue}let t=m(`span`,`pr-citation`,n.text);t.title=n.text,e.append(t)}return e}function E0(e,t){return T0(e,G$(t))}function D0(e,t,n){let r=m(`div`,`pr-assessment-part`);return n&&(r.dataset.tone=n),r.append(m(`h4`,`pr-assessment-title`,e),t),r}function O0(e){let t=m(`ul`,`pr-assessment-list`);for(let n of e)t.append(E0(m(`li`,null),n));return t}function k0(e){let t=e1(e.assessment);if(t.length===0)return[];let n=m(`section`,`pr-about-box`);n.setAttribute(`aria-label`,`About this PR`),n.append(m(`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(E0(m(`p`,t),e.text))}return[n]}function A0(e){let t=m(`section`,`pr-verdict-box`);t.setAttribute(`aria-label`,`Verdict`);let n=m(`div`,`pr-verdict-line`);return n.append(ble(e)),t.append(n),e.assessment?(t.append(E0(m(`p`,`pr-verdict-summary pr-verdict-reason`),e.summary)),t):(t.append(m(`p`,`pr-verdict-legacy`,n1)),t)}function j0(e){let t=m(`details`,`pr-disclosure pr-coverage`),n=m(`summary`,`pr-disclosure-summary`),r=t1(e.assessment);n.append(m(`span`,`pr-disclosure-label`,r.label),m(`span`,`pr-disclosure-preview`,r.preview)),t.append(n);let{assessment:i}=e;return i?(i.checked.length>0&&t.append(D0(`What the review checked`,O0(i.checked))),i.gaps.length>0&&t.append(D0(`Not covered`,O0(i.gaps),`warning`)),t):(t.append(E0(m(`p`,`pr-verdict-summary`),e.summary)),t)}function Dle(e){if(e.kind===`code`){let t=m(`pre`,`pr-comment-code`),n=m(`code`,null);return n.textContent=e.code,t.append(n),t}let t=m(`p`,`pr-comment-paragraph`);if(e.lead){let n=m(`strong`,`pr-comment-lead pr-comment-lead-${e.leadKind}`);e.leadKind===`question`&&n.append(xle()),n.append(e.lead),t.append(n,` `)}return T0(t,e.segments)}function Ole(e,t,n,r){let i=m(`article`,`pr-comment-card`),a=m(`input`,`pr-comment-checkbox`);a.type=`checkbox`,a.checked=n.has(t),a.setAttribute(`aria-label`,`Include comment on ${p1(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=m(`details`,`pr-comment-content`),s=m(`summary`,`pr-comment-header`),c=q$(e.body),l=z$(e);l&&s.append(yle(l));let u=m(`span`,`pr-comment-location`,m1(e));u.title=p1(e),s.append(u),s.append(m(`span`,`pr-comment-preview`,J$(c.paragraphs))),o.append(s);let d=m(`div`,`pr-comment-paragraphs`);for(let e of c.paragraphs)d.append(Dle(e));return o.append(d),o.open=l===`HIGH`||l===`CRITICAL`,i.append(a,o),i}var M0=`More review actions`,kle=`M3 8h0.01M8 8h0.01M13 8h0.01`,Ale=`Your comments are on GitHub. Approve adds an approval without posting them again.`;function N0(e,t,n,r){let i=N$(_$(N1));g0(null);let a=Jm(`team-review-action`);if(!G({type:`team-review-action`,requestId:a,...n}))return!1;let o=window.setTimeout(()=>{t0.delete(t.key),r(!1,`No reply from the server. Check GitHub before trying again.`)},A1);return t0.set(t.key,{requestId:a,action:n.action,origin:e,capturedOrder:i,pullRequest:X$(t.repo,t.number),timer:o,settle:r}),!0}function P0(e){let t=m(`footer`,`pr-footer`),n=L0(`discard`,()=>{t0.has(e.key)||(n.disabled=!0,i.dataset.tone=`busy`,i.textContent=x1(`discard`),!N0(`other`,e,g1(e.key),a)&&a(!1,`Not connected to the server.`))}),r=t0.has(e.key);n.disabled=r;let i=m(`span`,`pr-action-status`,r?x1(`discard`):``);i.setAttribute(`role`,`status`),i.setAttribute(`aria-live`,`polite`);let a=(t,r)=>{n.disabled=t,i.dataset.tone=t?`ok`:`error`,i.textContent=r,t||g0({text:`${X$(e.repo,e.number)}: ${r}`,tone:`error`})};return t.append(n,i),t}var F0=0;function I0(e,t){let n=m(`div`,`pr-detail-more`),r=m(`button`,`review-icon-button review-more-button`);r.type=`button`,r.title=M0,r.setAttribute(`aria-label`,M0),r.setAttribute(`aria-haspopup`,`menu`),r.setAttribute(`aria-expanded`,`false`);let i=vM(16,16);i.append(_M(`path`,{d:kle,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})),r.append(i),F0+=1;let a=m(`div`,`review-more-menu`);a.id=`pr-more-menu-${F0}`,a.setAttribute(`role`,`menu`),a.setAttribute(`aria-label`,M0),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`,()=>{a.hidden?l():c()});let u=[r];for(let n of e){let e=m(`button`,`review-btn`,y1(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 L0(e,t){let n=m(`button`,`pr-action`,y1(e));return n.type=`button`,n.dataset.action=e,n.addEventListener(`click`,()=>t(e)),n}function R0(e,t){e.querySelector(`:scope > .pr-detail-heading > .pr-detail-title`)?.append(t)}function jle(e){let t=m(`article`,`pr-detail`),n=m(`div`);n.dataset.reviewThreads=``,t.append(S0(e),...k0(e),n,A0(e)),z0(t,e);let r=m(`section`,`pr-posts`);r.setAttribute(`aria-label`,`Inline comments`);let i=m(`div`,`pr-posts-heading`);i.append(m(`h3`,null,`Inline comments`),m(`span`,null,String(e.comments.length))),r.append(i);let a=m(`details`,`pr-disclosure`),o=m(`summary`,`pr-disclosure-summary`),s=m(`span`,`pr-disclosure-preview`);o.append(m(`span`,`pr-disclosure-label`,`Review body`),s),a.append(o);let c=m(`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(`
269
+ `).length+1)),c.spellcheck=!0;let l=()=>{s.textContent=NQ(c.value).split(/\r?\n/).map(e=>e.trim()).find(Boolean)||`No review body`};c.addEventListener(`input`,l),l(),a.append(c);let u=m(`details`,`pr-disclosure`);u.append(m(`summary`,`pr-disclosure-summary`,`Add a note`));let d=m(`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)=>B$(e)?[t]:[])),p=m(`footer`,`pr-footer`),h=m(`span`,`pr-action-status`);h.setAttribute(`role`,`status`),h.setAttribute(`aria-live`,`polite`);let g=()=>{t0.has(e.key)||h.dataset.tone===`ok`||(h.textContent=``,delete h.dataset.tone)};for(let[t,n]of e.comments.entries())r.append(Ole(n,t,f,g));t.append(r,a,u,j0(e));let _=[],v=e=>{for(let t of _)t.disabled=e;t.dataset.busy=String(e)},y=(e,t)=>{v(e),h.dataset.tone=e?`ok`:`error`,h.textContent=t},b=t=>{if(t0.has(e.key))return;v(!0),h.dataset.tone=`busy`,h.textContent=x1(t);let n=e.comments.filter((e,t)=>f.has(t));N0(`ready`,e,_1(e,t,h1(d.value,c.value),n),y)||y(!1,`Not connected to the server.`)},x=b1(e),S=x.footer.map(e=>L0(e,b)),C=I0(x.more,b);return _.push(...S,...C.controls),R0(t,C.element),p.append(...S,h),t.append(p),{signature:D1(e),element:t,settle:y}}function Mle(e){let t=$1.get(e.key);if(t&&(t0.has(e.key)||t.signature===D1(e)))return z0(t.element,e),C0(t.element,e);let n=jle(e);return $1.set(e.key,n),n.element}function Nle(e,t){let n=m(`article`,`pr-detail`),r=m(`div`,`pr-detail-heading`),i=m(`div`,`pr-detail-title`);i.append(r0(e),m(`h2`,null,e.title));let a=m(`div`,`pr-detail-meta`);a.append(u0(e.author,20,`pr-detail-author`));let o=a0(`Opened`,e.prCreatedAt);return o&&a.append(o),r.append(i,a,x0(e)),n.append(r,m(`p`,`pr-attention-detail`,C1(t)),P0(e)),n}function Ple(e){let t=m(`article`,`pr-detail`);t.append(S0(e));let n=m(`section`,`pr-progress`);n.setAttribute(`aria-label`,`Review progress`);let r=m(`ol`,`pr-progress-tracker`);for(let t of Y$(e.phase)){let e=m(`li`,`pr-progress-stage`);e.dataset.state=t.state,e.append(m(`span`,`pr-progress-bar`),m(`span`,null,t.label)),r.append(e)}let i=m(`div`,`pr-progress-text`);X1.track(i,e.startedAt,()=>u1(e,Date.now())),n.append(r,i),t.append(n);let a=m(`section`,`pr-steps`);a.append(m(`h3`,null,`Latest agent steps`));let o=m(`ol`,`pr-step-list`);for(let t of e.recentSteps){let n=m(`li`,`pr-step`),r=m(`span`,`pr-step-detail`,t.detail);r.title=t.detail,n.append(m(`span`,`pr-step-at`,Zh(e.startedAt,t.at)),m(`span`,`pr-step-tool`,t.tool),r),o.append(n)}return a.append(o),t.append(a,P0(e)),t}function z0(e,t){if(t0.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(...V0(t)),n.dataset.reviewThreads=r)}function B0(e,t,n,r){let i=m(`div`,t?`pr-thread-message pr-thread-message-muted`:`pr-thread-message`);if(i.append(m(`p`,`pr-thread-body pr-thread-preview`,e)),!n&&!w$(e,t?3:8))return i;let a=m(`details`,`pr-thread-disclosure`);return a.append(m(`summary`,`pr-thread-expand`,t?`Expand comment`:`Expand reply`),m(`p`,`pr-thread-body`,e)),n&&a.append(x(`pr-link pr-thread-continues`,t?`Comment continues on GitHub`:`Reply continues on GitHub`,r)),i.append(a),i}function V0(e){let t=S$(e);if(t.length===0)return[];let n=m(`section`,`my-pr-threads-section`);n.append(m(`h3`,`pr-section-heading`,`Answered threads`));let r=m(`div`,`my-pr-threads`);for(let n of t){let t=m(`div`,`my-pr-thread pr-thread-card`),i=m(`div`,`my-pr-thread-heading pr-thread-heading`),a=m(`span`,`pr-thread-chip`,n.judgementLabel);a.dataset.tone=n.judgementTone,i.append(x(`pr-link my-pr-thread-location`,n.location,n.thread.url),a),t.append(i),n.judgementReason&&t.append(m(`p`,`my-pr-thread-meta`,n.judgementReason)),n.thread.viewerComment&&t.append(m(`div`,`my-pr-thread-meta`,`Your comment`),B0(n.thread.viewerComment,!0,n.thread.viewerCommentTruncated===!0,n.thread.url));let o=m(`div`,`pr-detail-meta pr-thread-reply-meta`);o.append(m(`span`,`pr-author-login`,n.thread.lastReplyAuthor),` replied`);let s=a0(``,n.thread.lastReplyAt);s&&o.append(s);let c=m(`span`,`pr-action-status`);c.setAttribute(`role`,`status`);let l=m(`button`,`pr-action`,`Resolve`);l.type=`button`,l.disabled=!n.canResolve||t0.has(e.key);let u=(e,t)=>{l.disabled=e||!n.canResolve,c.textContent=t,c.dataset.tone=e?`ok`:`error`};l.addEventListener(`click`,()=>{t0.has(e.key)||(l.disabled=!0,c.textContent=x1(`resolve-thread`),!N0(`other`,e,_1(e,`resolve-thread`,``,[],n.thread.id),u)&&u(!1,`Not connected to the server.`))}),t.append(o),n.thread.lastReplyBody&&t.append(B0(n.thread.lastReplyBody,!1,n.thread.lastReplyTruncated===!0,n.thread.url));let d=m(`footer`,`pr-thread-footer`);d.append(c,l),t.append(d),n.thread.resolveError&&t.append(m(`p`,`pr-attention-detail`,n.thread.resolveError)),r.append(t)}return n.append(r),[n]}function H0(e){let t=m(`article`,`pr-detail`);if(t.append(S0(e),...k0(e),...V0(e)),e.status===`posted`&&t.append(A0(e),j0(e)),e.status!==`posted`&&t.append(m(`p`,`pr-attention-detail`,d1(e))),!i1(e.status))return e0.set(e.key,{signature:w0(e),element:t,settle:()=>{}}),t;let n=m(`footer`,`pr-footer`),r=b1(e),i=m(`span`,`pr-action-status`,r.footer.includes(`approve-only`)?Ale:``);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(!t0.has(e.key)){for(let e of a)e.disabled=!0;i.dataset.tone=`busy`,i.textContent=x1(t),!N0(`other`,e,_1(e,t,``,[]),o)&&o(!1,`Not connected to the server.`)}},c=r.footer.map(e=>L0(e,s));if(a.push(...c),r.more.length>0){let e=I0(r.more,s);a.push(...e.controls),R0(t,e.element)}return n.append(...c,i),t.append(n),e0.set(e.key,{signature:w0(e),element:t,settle:o}),t}function U0(e){if(!i1(e.status)&&S$(e).length===0)return H0(e);let t=e0.get(e.key);return t&&(t0.has(e.key)||t.signature===w0(e))?C0(t.element,e):H0(e)}function W0(e){if(!z1)return;if(V1=F$(e,V1,H1!==null),!V1){if(H1!==null){let t=H1.actedKey;t&&![...e.ready,...e.attention].some(e=>e.key===t)&&(H1={actedKey:null}),z1.replaceChildren(h0(e$(e,H1.actedKey))),G1=null;return}z1.replaceChildren(),G1=null;return}let t=e.ready.find(e=>e.key===V1&&(b$(e).length>0||JQ(e)));if(t&&t.status!==`ready`){let e=`threads:${w0(t)}`,n=U0(t);if(G1===e&&z1.firstElementChild===n)return;z1.replaceChildren(n),G1=e;return}let n=[...e.ready,...e.noReviewNeeded].find(e=>e.key===V1&&e.status===`ready`);if(n){let e=`ready:${D1(n)}`,t=Mle(n);if(G1===e)return;z1.replaceChildren(t),G1=e;return}let r=e.inReview.find(e=>e.key===V1);if(r){X1.reset(),z1.replaceChildren(Ple(r)),G1=`inReview:${r.key}`;return}let i=e.queued.find(e=>e.key===V1);if(i){let t=`queued:${i.key}:${e.inReview.length}`;if(G1===t)return;z1.replaceChildren(Nle(i,e.inReview.length)),G1=t;return}let a=[...e.noReviewNeeded,...e.attention,...e.posted,...e.discarded].find(e=>e.key===V1);a&&(z1.replaceChildren(U0(a)),G1=`${a.status}:${a.key}`)}function Fle(){let e=m(`p`,`pr-empty`,w1(N1));return N1&&!N1.configured&&e.append(` `,lg(s$,c$,`Open Team review settings`)),e}function G0(){let e=T1(N1);return e?[m(`p`,`my-pr-note`,e)]:[]}function Ile(e){for(let t of[...$1.keys()])e.has(t)||t0.has(t)||$1.delete(t);let t=new Set(N1?.drafts.filter(e=>i1(e.status)).map(e=>e.key)??[]);for(let e of e0.keys())t.has(e)||t0.has(e)||e0.delete(e)}function Lle(){if(!P1||!F1||L1?.isConnected)return;let e=SJ({queueLabel:`Review queue`,scopeTabs:F1,resizerLabel:`Resize review queue`});L1=e.queue,W1=m(`p`,`pr-action-status pr-action-notice`),W1.setAttribute(`role`,`status`),W1.setAttribute(`aria-live`,`polite`),z1=m(`div`,`pr-detail-body`),e.detail.append(W1,z1),g0(U1),I1&&e.foot.append(I1.control),P1.replaceChildren(e.columns),G1=null,R1=null}function K0(e){if(!e)return;e.querySelector(`.pr-team-chip`)?.remove();let t=N1?.team;if(!t)return;let n=m(`span`,`pr-team-chip`);n.append(_({login:t.slug,url:t.avatarUrl,cssPx:16}),m(`span`,null,t.name)),e.insertBefore(n,e.querySelector(`.pr-queue-toggle`))}function q0(){let e=document.activeElement;return!(e instanceof HTMLElement)||!L1?.contains(e)?null:e.dataset.reviewKey??null}function J0(e){e&&L1&&[...L1.querySelectorAll(`button[data-review-key]`)].find(t=>t.dataset.reviewKey===e)?.focus({preventScroll:!0})}function Y0(){if(!P1)return;let e=q0(),t=_$(N1);if(Ile(new Set([...t.ready,...t.noReviewNeeded].map(e=>e.key))),Z1.reset(),!N1?.configured||!M$(t)&&H1===null){Y1.reset(),X1.reset();let e=bJ(F1);K0(e),P1.replaceChildren(e,...I1?[I1.notice]:[],...G0(),Fle(),xJ(I1?.control??null)),I1?.update(N1),L1=null,R1=null,z1=null,W1=null,B1=null,G1=null;return}if(Lle(),!L1)return;K0(P1.querySelector(`.pr-queue-head`)),V1=F$(t,V1,H1!==null);let n=r$(t),r=JSON.stringify([t,n,V1,T1(N1)]);if(r===R1){I1?.update(N1),W0(t),s0(P1);return}R1=r,Y1.reset();let i=[],a=$Q(t);a&&i.push(h0({title:`All caught up`,detail:a})),t.ready.length&&i.push(_0(`Ready`,t.ready,`ready`,n)),t.inReview.length&&(B1=_0(`In review`,t.inReview,`inReview`,n),i.push(B1)),t.queued.length&&i.push(_0(`Queued`,t.queued,`queued`,n)),t.noReviewNeeded.length&&i.push(_0(`Already reviewed`,t.noReviewNeeded,`settled`,n)),t.handReview.length&&i.push(wle(t.handReview,n)),t.attention.length&&i.push(_0(`Needs attention`,t.attention,`attention`,n)),t.posted.length&&i.push(_0(`Waiting on author`,t.posted,`posted`,n)),t.discarded.length&&i.push(_0(`Not mine`,t.discarded,`discarded`,n)),L1.replaceChildren(...I1?[I1.notice]:[],...G0(),...i),I1?.update(N1),J0(e),W0(t),s0(P1)}function X0(){K1&&K1(n0.refresh())}function Rle(){n0.acknowledge(),X0()}function zle(e){K1=e,X0()}function Ble(e,t,n){return q1=n?.openTerminal??q1,P1||(F1=t,P1=m(`div`,`pr-content`),e.append(P1),I1=sQ(`team-review`,P1),Y1.ensure(),X1.ensure(),Z1.ensure(),Y0(),P1)}function Vle(e){let t=Ws.safeParse(e);if(!t.success)return;let n=N1;N1=t.data,!(k1(n,t.data)&&Hle())&&(Y0(),X0())}function Hle(){if(!N1||!B1?.isConnected)return!1;Y1.reset(),Z1.reset();let e=q0(),t=_$(N1),n=_0(`In review`,t.inReview,`inReview`,r$(t));return B1.replaceWith(n),B1=n,J0(e),t.inReview.some(e=>e.key===V1)&&W0(t),s0(P1),!0}function Ule(e){let t=e.key;if(!t)return;let n=J1.get(t);n&&n.requestId===e.requestId&&(!e.ok||!e.sessionId?b0(t,e.error||`Could not open a session.`):(window.clearTimeout(n.timer),J1.delete(t),y0(t,``,null),q1?.(e.sessionId)))}function Wle(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.key!=`string`)return;let n=t0.get(t.key);if(!n||n.requestId!==t.requestId)return;if(window.clearTimeout(n.timer),t0.delete(t.key),n.action===`resolve-thread`){n.settle?.(t.ok===!0,typeof t.error==`string`?t.error:S1(n.action)),e0.delete(t.key),G1=null,t.ok===!0&&Y0();return}let r=(n.origin===`ready`?$1:e0).get(t.key);if(t.ok===!0){n.origin===`other`&&e0.delete(t.key);let e=n$({action:n.action,pullRequest:n.pullRequest,warning:typeof t.warning==`string`?t.warning:``,isActedSelected:V1===t.key});if((r?.settle??n.settle)?.(!0,e.statusText),(e.notice||e.shouldAdvance)&&g0(e.notice),!e.shouldAdvance)return;V1=P$({capturedOrder:n.capturedOrder,actedKey:t.key,groups:_$(N1)}),V1===null&&(H1={actedKey:t.key}),Y0()}else(r?.settle??n.settle)?.(!1,typeof t.error==`string`&&t.error?t.error:`The action failed.`)}var Z0=2,Gle=new Map,Q0={OPEN:0,MERGED:1,CLOSED:2};function Kle(e,t){return t?t.configured?t.error?e:new Map(t.prs.map(e=>[NZ(e),e])):Gle:e}function $0(e){return e?Q0[e.state]:Q0.OPEN}function qle(e,t){let n=`${e.repo}#${e.number}`,r=`#${e.number}`;return t?{key:n,numberText:r,url:t.url,hoverText:`${e.repo}: ${t.title} (${uZ(t.stage)})`,stage:{icon:fZ(t.stage),tone:dZ(t.stage),label:uZ(t.stage)}}:{key:n,numberText:r,url:e.url,hoverText:e.repo,stage:null}}function Jle(e,t){let n=e.map(e=>({link:e,pr:t.get(NZ(e))}));n.sort((e,t)=>$0(e.pr)-$0(t.pr)||t.link.linkedAt-e.link.linkedAt);let r=n.map(({link:e,pr:t})=>qle(e,t)),i=r.slice(Z0);return{chips:r.slice(0,Z0),overflowCount:i.length,overflowHoverText:i.map(e=>`${e.numberText} ${e.hoverText}`).join(`
270
+ `)}}var Yle=new Set([`checks-failing`,`changes-requested`,`unresolved-threads`,`conflicts`,`merged`]),e2=new Map,t2=new Map,n2=new Map,r2=new Map,i2=null,a2=!1,o2=0;function Xle(e){let t=[];for(let n of e2.get(e)??[]){let e=r2.get(NZ(n));e&&Yle.has(e.stage)&&t.push(e)}return t}function s2(e){return Hh(Xle(e).map(e=>`${e.key}@${e.stage}`))}function Zle(e){let{focusedSessionId:t,selectedSessionId:n}=pe.snapshot();return t===e||n===e}function Qle(e){let t=n2.get(e);if(t)return t;let n=Uh({getAck:()=>t2.get(e)??``,setAck:t=>t2.set(e,t),signature:()=>s2(e),isLooking:()=>Zle(e)});return n2.set(e,n),n}function c2(e){a2&&eV(e,Qle(e).refresh())}function $le(e,t){if(!a2)return;let n=t2.get(e);if(n!==void 0&&n!==t)return;let r=n2.get(e);r?r.acknowledge():t2.set(e,s2(e))}function eue(e){if(!(a2||!e?.configured||e.error)){a2=!0;for(let e of e2.keys())t2.set(e,s2(e))}}pe.subscribe((e,t)=>{if(t.includes(`focusedSessionId`)||t.includes(`selectedSessionId`))for(let t of new Set([e.focusedSessionId,e.selectedSessionId]))t&&n2.has(t)&&c2(t)});function tue(e){return document.querySelectorAll(`[data-pr-chips-for="${CSS.escape(e)}"]`)}function nue(e,t){e.stopPropagation(),!e.defaultPrevented&&(e.preventDefault(),__(t))}function l2(e,t){let n=t?m(`span`,`session-pr-chip`):x(`session-pr-chip`,``,e.url,e.hoverText);return n.title=e.hoverText,e.stage&&(n.dataset.tone=e.stage.tone,n.append(wJ(e.stage.icon,e.stage.tone))),n.append(e.numberText),t||n.setAttribute(`aria-label`,`Open pull request ${e.key}`),n.addEventListener(`click`,t=>nue(t,e.url)),n}function rue(e,t){let n=m(`button`,`session-pr-chip-unlink`,`×`);n.type=`button`,n.title=`Unlink ${e.key} from this session`,n.setAttribute(`aria-label`,`Unlink pull request ${e.key}`),n.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault(),G({type:`unlink-session-pr`,id:t,key:e.key})});let r=m(`span`,`session-pr-chip-item`);return r.append(l2(e,!1),n),r}function u2(e,t){let n=String(o2);if(e.dataset.prChipsFor===t&&e.dataset.prChipsRevision===n)return;e.dataset.prChipsFor=t,e.dataset.prChipsRevision=n;let r=Jle(e2.get(t)??[],r2),i=e.closest(`button`)!==null,a=r.chips.map(e=>i?l2(e,!0):rue(e,t));if(r.overflowCount>0){let e=m(`span`,`session-pr-chip-overflow`,`+${r.overflowCount}`);e.title=r.overflowHoverText,a.push(e)}e.hidden=a.length===0,e.replaceChildren(...a)}function d2(e){o2+=1;for(let t of e){let e=t.dataset.prChipsFor;e&&u2(t,e)}}function f2(e,t){let n=Qs.shape.links.safeParse(t??[]),r=s2(e);e2.set(e,n.success?n.data:[]),$le(e,r),d2(tue(e)),SQ(e2),c2(e)}function iue(e){e2.delete(e),t2.delete(e),n2.delete(e),SQ(e2)}function aue(){let e=TQ();if(e===i2)return;i2=e;let t=Kle(r2,e);if(t!==r2){r2=t,d2(document.querySelectorAll(`[data-pr-chips-for]`)),eue(e);for(let e of e2.keys())c2(e)}}var p2=null,m2=new Set;function h2(){p2?.setAttribute(`aria-pressed`,String(!fp()))}function g2(e){pp(e),h2();for(let t of m2)t(e)}function oue(e){m2.add(e)}function sue(e){p2=e,h2(),e.addEventListener(`click`,()=>g2(!fp()))}function cue(e){let t=new Set(e.partialIntentIds??[]),n=new Map;for(let r of e.orders){if(r.parent!==null)continue;let i=t.has(r.id);(i||r.state===`completed`)&&n.set(r.id,{intentId:r.id,objective:r.objective,merged:[],parked:[],confirmedFlakes:e.confirmedFlakesByIntent?.[r.id]??[],isPartial:i})}for(let t of e.orders){if(t.parent===null)continue;let e=n.get(t.parent);e&&(t.state===`completed`&&e.merged.push({id:t.id,objective:t.objective}),t.parked&&e.parked.push({id:t.id,objective:t.objective,need:t.blockReason??null}))}return[...n.values()]}function _2(e,t,n){return n.has(e.id)?`review`:e.state===`open`||e.state===`blocked`?`queue`:e.state===`active`?`workers`:e.state===`completed`?t.has(e.id)?`review`:`shipped`:null}function lue(e){let t=0;for(let n of e.owner??e.id)t=Math.imul(t,31)+n.charCodeAt(0)>>>0;return vf[t%vf.length]}function uue(e,t,n){return e.parked?`Parked`:t?`Scope conflict`:e.state===`blocked`?`Blocked`:e.state===`open`&&e.readiness===`waiting`?`Waiting on dependency`:n===`workers`?`Running`:n===`review`?`Unverified`:n===`shipped`?`Shipped`:`Ready`}function due(e,t){return e===null?null:e===a.RUNNING?`Planning`:e!==a.IDLE&&e!==a.COMPLETE?o[e]:t>0?`Waiting on workers`:`Idle`}function fue(e,t){let n=new Set,r=e;for(;r;){if(n.has(r.id))return null;if(n.add(r.id),r.parent===null)return r;r=t.get(r.parent)}return null}function pue(e,t){let n=e.orders.filter(e=>e.parent===null&&e.state!==`completed`&&e.state!==`cancelled`).sort((e,t)=>e.openedAt.localeCompare(t.openedAt)),r=new Set(e.orders.filter(e=>e.state===`active`).map(e=>e.parent)),i=n.find(t=>t.id===e.orchestrator?.intentId)??n.find(e=>r.has(e.id))??n[0]??null,a=i?e.orders.filter(e=>e.parent===i.id):[],o=new Set(e.reviewing??[]),s=new Set(e.unverifiedCompletedWork),c=new Set(e.conflicts.flatMap(e=>[e.left,e.right])),l=new Map(e.liveWorkers?.map(e=>[e.workId,e.sessionId])),u={queue:[],workers:[],review:[],shipped:[]},d=e.orders.filter(e=>e.parent===i?.id);for(let e of d){let n=_2(e,s,o);if(!n)continue;let r=c.has(e.id),i=r||e.state===`blocked`||e.state===`open`&&e.readiness===`waiting`;u[n].push({id:e.id,objective:e.objective,sessionId:l.get(e.id)??null,risk:e.risk,station:n,status:o.has(e.id)?`Reviewing`:uue(e,r,n),hasConflict:r,isHeld:i,isSelected:e.id===t,animal:lue(e)})}let f=new Map(e.orders.map(e=>[e.id,e])),p=t===null?void 0:f.get(t),m=p?fue(p,f):null,h=due(e.orchestrator?.state??null,e.liveWorkers?.length??0);return{paused:e.paused,spend:`Factory today: $${(e.spentTodayUsd??0).toFixed(2)} / ${e.dailyBudgetUsd==null?`unlimited`:`$${e.dailyBudgetUsd.toFixed(2)}`}`,note:e.note??null,digests:cue(e),intent:i?{id:i.id,objective:i.objective,criteria:i.criteria.map(e=>({text:e,isMet:i.state===`completed`})),shippedCount:u.shipped.length,childCount:a.length}:null,upNext:n.filter(e=>e.id!==i?.id).map(({id:e,objective:t})=>({id:e,objective:t})),orchestrator:e.error===null?{action:e.heading.action,reason:e.heading.reasons[0]??``,isException:!1,sessionId:e.orchestrator?.sessionId??null,stateLabel:h}:{action:`Exception`,reason:e.error,isException:!0,sessionId:e.orchestrator?.sessionId??null,stateLabel:h},stations:u,ledger:e.orders.flatMap(e=>e.lastEvent?[{orderId:e.id,...e.lastEvent}]:[]).sort((e,t)=>Date.parse(t.at)-Date.parse(e.at)).slice(0,50),selectedOrder:p?{id:p.id,intent:m?.objective??null,writeScopes:p.writeScopes,dependsOn:p.dependsOn,station:p.parent===null?`intent`:_2(p,s,o)??`cancelled`,owner:p.owner}:null}}function mue(e,t){return e.find(e=>e.projectId===t)||([...e].sort((e,t)=>e.projectName.localeCompare(t.projectName)||e.projectId.localeCompare(t.projectId))[0]??null)}var v2=null,y2=null,b2=null,x2=!1,S2=null,C2=null,w2=null,T2=0,E2=new Map,D2=new Map,O2=new Map,k2=new Set;function hue(e){let t=E2.get(e);if(t)return t;let n={objective:``,criteria:``,risk:`low`,boundary:``,writeScopes:``};return E2.set(e,n),n}var A2=`.factory-stack, .factory-pads, .factory-ledger, .factory-detail, .factory-intent-queue, .factory-criteria, .factory-digests`,gue=[[`[data-order-id]`,`orderId`],[`[data-factory-field]`,`factoryField`],[`[data-project-id]`,`projectId`]];function j2(e,t,n){let r=m(`button`,e,t);return r.type=`button`,r.addEventListener(`click`,n),r}function M2(e){let t=m(`p`,`factory-request-status`,e?.text??``);return t.setAttribute(`role`,`status`),t.dataset.error=String(e?.hasError===!0),t}function N2(e,t,n,r){let i=t===`factory-queue-intent`?D2:O2;if(i.get(e)?.requestId)return;T2+=1;let a=`factory-${T2}`,o=w2?.({...n,projectId:e,type:t,requestId:a})===!0;i.set(e,{requestId:o?a:null,text:o?r:`Not connected.`,hasError:!o,target:typeof n.intentId==`string`?n.intentId:typeof n.action==`string`?n.action:void 0}),R2()}function _ue(e,t,n){let r=m(`details`,`factory-floor-opt-in`);r.open=k2.has(e)||(t.floorAllowances?.length??0)>0,r.addEventListener(`toggle`,()=>{r.open?k2.add(e):k2.delete(e)});let i=m(`summary`,`factory-label factory-floor-opt-in-summary`,`Protected floor opt-in`);i.dataset.factoryField=`floor-opt-in`,r.append(i);let a=m(`fieldset`,`factory-floor-allowances`);a.append(m(`legend`,`sr-only`,`Protected floor opt-in`));for(let e of nu){let r=m(`label`,`factory-floor-allowance`),i=m(`input`);i.type=`checkbox`,i.value=e,i.dataset.factoryField=`floor:${e}`,i.checked=t.floorAllowances?.includes(e)===!0,i.disabled=n,i.addEventListener(`change`,()=>{let n=(t.floorAllowances??[]).filter(t=>t!==e),r=i.checked?[...n,e]:n;t.floorAllowances=nu.filter(e=>r.includes(e))}),r.append(i,m(`span`,null,e)),a.append(r)}return r.append(a),r}function vue(e){let t=hue(e),n=m(`form`,`factory-queue-form`),r=D2.get(e)?.requestId!=null;for(let[e,i,a,o]of[[`objective`,`Objective`,4096,2],[`criteria`,`Criteria, one per line`,49164,2],[`boundary`,`Authority boundary`,4096,1],[`writeScopes`,`Write scopes, one per line`,32800,2]]){let s=m(`label`,`factory-form-field`),c=m(`textarea`,`factory-form-input`);c.name=e,c.dataset.factoryField=e,c.maxLength=a,c.rows=o,c.required=e!==`writeScopes`,c.value=t[e],c.disabled=r,c.addEventListener(`input`,()=>{t[e]=c.value}),s.append(m(`span`,`factory-label`,i),c),n.append(s)}let i=m(`label`,`factory-form-field`),a=m(`select`,`factory-form-input`);a.name=`risk`,a.dataset.factoryField=`risk`,a.disabled=r;for(let e of au.shape.risk.options){let t=m(`option`,null,e);t.value=e,a.append(t)}a.value=t.risk,a.addEventListener(`change`,()=>{t.risk=au.shape.risk.parse(a.value)}),i.append(m(`span`,`factory-label`,`Risk`),a),n.append(_ue(e,t,r));let o=m(`button`,`factory-action`,`Queue intent`);return o.type=`submit`,o.disabled=!x2||r,n.insertBefore(i,n.children[2]??null),n.append(o,M2(D2.get(e))),n.addEventListener(`submit`,n=>{n.preventDefault();let r=au.safeParse({...t,projectId:e,criteria:t.criteria.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),writeScopes:t.writeScopes.split(/\r?\n/).map(e=>e.trim()).filter(Boolean)});r.success?N2(e,`factory-queue-intent`,r.data,`Queueing intent.`):(D2.set(e,{requestId:null,text:r.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `),hasError:!0}),R2())}),n}function yue(e,t){let n=m(`div`,`factory-controls`),r=O2.get(e);for(let i of[`pause`,`resume`]){let a=j2(`factory-action`,i===`pause`?`Pause`:`Resume`,()=>N2(e,`factory-control`,{action:i},i===`pause`?`Pausing factory.`:`Resuming factory.`));a.disabled=!x2||r?.requestId!=null||(i===`pause`?t:!t),n.append(a)}return n.append(M2(r?.target===`pause`||r?.target===`resume`?r:void 0)),n}function bue(e){let t=P2(`Project profile`,`factory-band factory-profile`),n=m(`dl`,`factory-profile-fields`),r=e.factoryProfile;for(let[e,t]of[[`Checks`,r?.checks?.join(`
271
+ `)??`not set`],[`Focused test command`,r?.focusedTestCommand??`not set`],[`Widenable scopes`,r?.widenableScopes?.join(`
272
+ `)??`not set`]])n.append(m(`dt`,`factory-label`,e),m(`dd`,null,t||`None`));if(t.append(n),e.observedRun)return t;let i=O2.get(e.projectId),a=m(`div`,`factory-controls`),o=j2(`factory-action`,`Re-run setup`,()=>N2(e.projectId,`factory-control`,{action:`rerun-setup`},`Running project setup.`));return o.dataset.factoryField=`rerun-setup`,o.disabled=!x2||i?.requestId!=null,a.append(o,M2(i?.target===`rerun-setup`?i:void 0)),t.append(a),t}function xue(e,t){let n=P2(`Intent digests`,`factory-band factory-digest-region`),r=m(`div`,`factory-digests`),i=O2.get(t.projectId);for(let n of e.digests){let e=m(`article`,`factory-digest`);e.append(m(`h3`,`factory-digest-title`,n.objective),m(`p`,`factory-count`,`${n.intentId}: ${n.isPartial?`Partial`:`Completed`}. ${n.merged.length} merged, ${n.parked.length} parked.`));let a=m(`ul`,`factory-digest-list factory-digest-merged`);for(let e of n.merged){let t=m(`li`,null,`${e.id}: ${e.objective}`);t.title=e.objective,a.append(t)}e.append(m(`h4`,`factory-label`,`Merged tickets`),a);let o=m(`ul`,`factory-digest-list`);for(let e of n.parked){let t=m(`li`);t.append(m(`span`,null,`${e.id}: ${e.objective}`),m(`p`,`factory-parked-need`,e.need??`Need not recorded.`)),o.append(t)}e.append(m(`h4`,`factory-label`,`Parked tickets`),o);let s=m(`ul`,`factory-digest-list`);for(let e of n.confirmedFlakes)s.append(m(`li`,null,e));if(n.confirmedFlakes.length===0&&s.append(m(`li`,`factory-empty`,`None`)),e.append(m(`h4`,`factory-label`,`Confirmed flakes`),s),n.isPartial&&!t.observedRun){let r=m(`div`,`factory-controls`),a=j2(`factory-action`,`Retry parked`,()=>N2(t.projectId,`factory-control`,{action:`retry-parked`,intentId:n.intentId},`Reopening parked tickets.`));a.dataset.factoryField=`retry-parked:${n.intentId}`,a.disabled=!x2||i?.requestId!=null,r.append(a,M2(i?.target===n.intentId?i:void 0)),e.append(r)}r.append(e)}return e.digests.length===0&&r.append(m(`p`,`factory-empty`,`No finished intents.`)),n.append(m(`p`,`factory-count`,e.spend),r),i?.target&&![`pause`,`resume`,`rerun-setup`].includes(i.target)&&!e.digests.some(e=>e.isPartial&&e.intentId===i.target)&&n.append(M2(i)),n}var Sue=[{id:`queue`,label:`Queue`,slots:3},{id:`workers`,label:`Workers`,slots:3},{id:`review`,label:`Review`,slots:2},{id:`shipped`,label:`Shipped`,slots:3}];function P2(e,t){let n=ne(`factory`,e);return n.classList.add(...t.split(` `)),n.setAttribute(`aria-label`,e),n}function F2(e,t){let n=m(`div`,`factory-sprite`);n.setAttribute(`role`,`img`),n.setAttribute(`aria-label`,t);let r=m(`span`,`nyan-sprite ${e}`);return r.setAttribute(`aria-hidden`,`true`),n.append(r),n}function Cue(e){C2=e,R2()}function I2(e,t,n){let r=j2(n,t,()=>Cue(e));return r.dataset.orderId=e,r.setAttribute(`aria-pressed`,String(C2===e)),r}function L2(e,t){let n=m(`div`,`factory-crate`);n.dataset.state=e.isHeld?`waiting`:e.station,n.dataset.selected=String(e.isSelected);let r=m(`div`,`factory-crate-id`),i=m(`span`,`factory-crate-risk`,e.risk);i.dataset.risk=e.risk,r.append(m(`span`,null,e.id),i),n.append(r,I2(e.id,e.objective,`factory-crate-title`));let a=e.sessionId;return a&&v2&&!t&&n.append(j2(`factory-action`,`Open terminal`,()=>v2?.(a))),e.station!==`workers`&&n.append(m(`span`,`factory-crate-note`,e.status)),n}function wue(e){return`Read-only mirror of the factory harness run at ${e.recordDirectory}. ${e.outcome?`Ended: ${e.outcome}.`:`No verdict yet.`}`}function Tue(e,t){let n=t.projectId,r=t.observedRun!==void 0,i=m(`div`,`factory-band factory-head`),a=P2(`Intent`,`factory-intent`);if(a.append(m(`p`,`factory-count`,e.spend)),e.intent){a.append(I2(e.intent.id,e.intent.objective,`factory-intent-title`));let t=m(`ul`,`factory-criteria`);for(let n of e.intent.criteria){let e=m(`li`,null,`${n.isMet?`[x]`:`[ ]`} ${n.text}`);e.dataset.met=String(n.isMet),t.append(e)}a.append(t,m(`p`,`factory-count`,`${e.intent.shippedCount} of ${e.intent.childCount} shipped`))}e.intent||a.append(m(`p`,`factory-empty`,`No open intent.`));let o=P2(`Orchestrator`,`factory-orchestrator`);o.dataset.state=e.orchestrator.isException?`failed`:e.paused?`paused`:`steady`;let s=m(`div`,`factory-heading`);s.append(m(`strong`,`factory-orchestrator-action`,e.orchestrator.action),m(`p`,`factory-reason`,e.orchestrator.reason)),e.note&&s.append(m(`p`,`factory-reason`,e.note));let c=m(`span`,`factory-paused-marker`,`[paused]`);c.hidden=!e.paused,s.append(c),t.observedRun&&s.append(m(`p`,`factory-reason`,wue(t.observedRun))),r||s.append(yue(n,e.paused));let l=F2(`is-owl`,`Orchestrator owl`),u=e.orchestrator.sessionId;if(u&&v2&&!r){let e=j2(`factory-action`,null,()=>v2?.(u));e.setAttribute(`aria-label`,`Open orchestrator terminal`),e.append(l),o.append(e)}(!u||!v2||r)&&o.append(l),e.orchestrator.stateLabel&&s.append(m(`span`,`factory-orchestrator-state`,e.orchestrator.stateLabel)),o.append(s);let d=P2(`Up next`,`factory-up-next`),f=m(`ol`,`factory-intent-queue`);for(let t of e.upNext){let e=m(`li`);e.append(I2(t.id,t.objective,`factory-next-title`)),f.append(e)}return d.append(f),e.upNext.length===0&&d.append(m(`p`,`factory-empty`,`No queued intents.`)),r||d.append(vue(n)),i.append(a,o,d),i}function Eue(e,t,n){let r=m(`section`,`factory-station factory-station-${e.id}`);r.setAttribute(`aria-label`,e.label);let i=m(`div`,`factory-station-head`);i.append(m(`h3`,`factory-label`,e.label),m(`span`,`factory-count`,String(t.length)));let a=m(`div`,e.id===`workers`?`factory-pads`:`factory-stack`);for(let r=0;r<Math.max(e.slots,t.length);r+=1){let i=t[r],o=m(`div`,`factory-open`,`Open slot`);if(e.id!==`workers`){a.append(i?L2(i,n):o);continue}let s=m(`div`,`factory-pad`);s.dataset.state=i?.hasConflict?`waiting`:i?`running`:`idle`,i&&s.append(F2(i.animal.sprite,i.animal.name)),i||s.append(m(`div`,`factory-sprite factory-sprite-empty`)),s.append(i?L2(i,n):o,m(`span`,`factory-pad-status`,i?.status??`Idle`)),a.append(s)}return r.append(i,a),r}function Due(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:Oh(t)}function Oue(e){let t=m(`div`,`factory-band factory-foot`),n=P2(`Ledger`,`factory-ledger-region`),r=m(`ol`,`factory-ledger`);for(let t of e.ledger){let e=m(`li`),n=m(`time`,`factory-ledger-time`,Due(t.at));n.dateTime=t.at,e.append(n,m(`span`,null,`${t.orderId} ${t.event} (${t.session})`)),r.append(e)}e.ledger.length===0&&r.append(m(`li`,`factory-empty`,`No ledger events.`)),n.append(r);let i=P2(`Selected ticket`,`factory-detail-region`),a=m(`div`,`factory-detail`),o=e.selectedOrder;if(o){let e=m(`dl`);for(let[t,n]of[[`Intent`,o.intent??`No parent intent`],[`Fence`,o.writeScopes.join(`, `)||`None`],[`After`,o.dependsOn.join(`, `)||`None`],[`Station`,o.station],[`Session`,o.owner??`Unassigned`]])e.append(m(`dt`,null,t),m(`dd`,null,n));a.append(e)}return o||a.append(m(`p`,`factory-empty`,`Select a ticket to inspect its boundaries.`)),i.append(a),t.append(n,m(`div`,`factory-seam`),i),t}function R2(){if(!y2)return;let e=document.activeElement instanceof HTMLElement?document.activeElement:null,t=e instanceof HTMLTextAreaElement?{start:e.selectionStart,end:e.selectionEnd}:null,n=[...y2.querySelectorAll(A2)].map(e=>e.scrollTop),r=document.createDocumentFragment(),i=m(`p`,`factory-connection`,x2?b2?``:`Waiting for the server.`:`Disconnected. Showing the last snapshot.`);i.setAttribute(`role`,`status`),r.append(i);let a=mue(b2?.projects??[],S2);if(!a){r.append(m(`p`,`factory-empty`,b2?`No repos holding coherence.config.json.`:`Waiting for Factory state.`)),y2.replaceChildren(r);return}if(S2!==a.projectId&&(C2=null),S2=a.projectId,b2&&b2.projects.length>1){let e=m(`div`,`factory-projects`);e.setAttribute(`aria-label`,`Factory projects`);for(let t of b2.projects){let n=j2(`factory-project`,t.projectName,()=>{S2=t.projectId,C2=null,R2()});n.dataset.projectId=t.projectId,n.setAttribute(`aria-pressed`,String(t.projectId===S2)),e.append(n)}r.append(e)}let o=pue(a,C2),s=m(`div`,`factory-console`),c=P2(`Floor`,`factory-band factory-floor-band`),l=m(`div`,`factory-pipe`);for(let e of Sue)l.append(Eue(e,o.stations[e.id],a.observedRun!==void 0));c.append(l),s.append(Tue(o,a),bue(a),xue(o,a),c,Oue(o)),r.append(s),y2.replaceChildren(r),[...y2.querySelectorAll(A2)].forEach((e,t)=>{e.scrollTop=n[t]??0});for(let[n,r]of gue){let i=e?.dataset[r];if(!i)continue;let a=[...y2.querySelectorAll(n)].find(e=>e.dataset[r]===i);a?.focus({preventScroll:!0}),a instanceof HTMLTextAreaElement&&t&&a.setSelectionRange(t.start,t.end)}}function kue(e,t){return v2=t?.openTerminal??null,y2||(y2=m(`div`,`factory-content`),e.append(y2),R2(),y2)}function Aue(e){b2=e,R2()}function jue(e){if(x2=e,!e)for(let e of[D2,O2])for(let[t,n]of e)n.requestId&&e.set(t,{...n,requestId:null,text:`Disconnected. Check the floor before submitting again.`,hasError:!0});R2()}function Mue(e){w2=e}function Nue(e){D2.get(e.projectId)?.requestId===e.requestId&&(D2.set(e.projectId,{requestId:null,text:e.ok?`Queued ${e.workId??`intent`}.`:e.error??`Could not queue intent.`,hasError:!e.ok}),e.ok&&E2.delete(e.projectId),R2())}function Pue(e){if(O2.get(e.projectId)?.requestId!==e.requestId)return;let t={pause:`Factory paused.`,resume:`Factory resumed.`,"rerun-setup":`Project setup finished.`,"retry-parked":`Reopened ${e.reopenedWorkIds?.length??0} parked tickets.`};O2.set(e.projectId,{...O2.get(e.projectId),requestId:null,text:e.ok?t[e.action]:e.error??`Could not update factory.`,hasError:!e.ok}),R2()}var Fue={mine:`Mine`,run:`Run`,cancel:`Cancel`},Iue={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},z2=null,B2=null,V2=null,H2=new Map,U2=new Map;function W2(e){return e===null?`n/a`:`${Math.round(e*100)}%`}function Lue(e){if(e===null)return`n/a`;let t=Math.round(e*100);return t>0?`+${t}`:String(t)}function Rue(e,t){V2?.({type:`benchmark-action`,requestId:Jm(`benchmark`),suiteId:e,action:t})===!0?(H2.set(e,t),U2.set(e,Iue[t]),q2()):(U2.set(e,`Not connected.`),q2())}function G2(e,t,n){let r=m(`button`,`bench-action-button`,Fue[t]);return r.type=`button`,r.disabled=n,r.addEventListener(`click`,()=>Rue(e.id,t)),r}function zue(e){let t=B2?.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 K2(e){let t=m(`td`,`bench-score`,W2(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 Bue(e){let t=e.armIds.filter(t=>t!==e.baselineArm),n=m(`table`,`bench-table`),r=m(`tr`);r.append(m(`th`,null,`Case`),...e.armIds.map(t=>m(`th`,null,t===e.baselineArm?`${t} (baseline)`:t))),r.append(...t.map(e=>m(`th`,null,`${e} vs baseline`))),n.append(r);for(let r of e.rows){let i=m(`tr`);i.append(m(`td`,`bench-case`,r.caseId),...e.armIds.map(e=>K2(r.arms[e]))),i.append(...t.map(e=>m(`td`,`bench-delta`,Lue(r.deltaVsBaseline[e]??null)))),n.append(i)}let i=[...new Set(e.armIds.flatMap(t=>Object.keys(e.totals[t]?.recallByTag??{})))].sort(),a=m(`tr`,`bench-total`);a.append(m(`td`,`bench-case`,`Paired recall`),...e.armIds.map(t=>K2(e.totals[t]))),n.append(a);for(let t of i){let r=m(`tr`,`bench-total`);r.append(m(`td`,`bench-case`,`Recall, ${t}`),...e.armIds.map(n=>m(`td`,`bench-score`,W2(e.totals[n]?.recallByTag[t]??null)))),n.append(r)}return n}function Vue(e){let t=m(`div`,`bench-suite`),n=B2?.inFlight?.suiteId===e.id,r=!!B2?.inFlight&&!n,i=H2.has(e.id),a=m(`div`,`bench-summary`);a.append(m(`span`,`bench-suite-title`,e.title),w(`bench`,e.caseCount===1?`case`:`cases`,String(e.caseCount)),w(`bench`,e.candidateCount===1?`candidate`:`candidates`,String(e.candidateCount)),w(`bench`,`arms`,String(e.armIds.length))),t.append(a);let o=m(`div`,`bench-controls`),s=B2?.configured===!0&&e.error===null;o.append(G2(e,`mine`,!s||i||n),G2(e,`run`,!s||i||n||r||e.caseCount===0),G2(e,`cancel`,i||!n));let c=m(`span`,`bench-status`,zue(e)||U2.get(e.id)||``);if(c.setAttribute(`role`,`status`),o.append(c),t.append(o),e.error)return t.append(m(`p`,`bench-error`,e.error)),t;let l=e.latestReport;return l?(t.append(m(`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(Bue(l)),t):(t.append(m(`p`,`bench-empty`,e.caseCount===0?`Move approved candidates into the cases folder, then choose Run.`:`No run yet.`)),t)}function q2(){if(!z2)return;z2.textContent=``;let e=ne(`bench`,`Benchmarks`,`Suites from the benchmarks folder of the Glimmervoid home, one run at a time.`);if(z2.append(e),!B2)z2.append(m(`p`,`bench-empty`,`Waiting for the server.`));else if(!B2.configured)z2.append(m(`p`,`bench-empty`,B2.reason||`Benchmarks are off.`));else if(B2.suites.length===0)z2.append(m(`p`,`bench-empty`,`No suites yet. Create a folder holding suite.json under benchmarks in the Glimmervoid home.`));else for(let e of B2.suites)z2.append(Vue(e))}function Hue(e){V2=e}function Uue(e){return z2||(z2=m(`div`,`bench-content`),e.append(z2),q2(),z2)}function Wue(e){if(!(e||H2.size===0)){for(let e of H2.keys())U2.set(e,`Connection lost.`);H2.clear(),q2()}}function Gue(e){B2=e,q2()}function Kue(e){H2.delete(e.suiteId);let t=B2?.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.`};U2.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),q2()}function que(e){return e?e.configured?`No open issues.`:e.reason??`Loading issues.`:`Loading issues.`}function J2(e,t){return t===`all`||e.sources.includes(t)}function Jue(e){return{all:e.length,me:e.filter(e=>J2(e,`me`)).length,team:e.filter(e=>J2(e,`team`)).length,project:e.filter(e=>J2(e,`project`)).length}}function Yue(e,t,n){let r=t.query.trim().toLowerCase().split(/\s+/).filter(Boolean),i=e.filter(e=>{if(!J2(e,t.scope)||t.repo&&e.repo!==t.repo||t.label&&!e.labels.includes(t.label)||t.hasSession&&(!e.sessionId||!n.has(e.sessionId))||t.hasPr&&e.pullRequests.length===0||t.isUnassignedOnly&&e.assignees.length>0)return!1;let i=[e.title,`#${e.number}`,e.repo,e.author,...e.labels,...e.assignees,...e.teams].join(` `).toLowerCase();return r.every(e=>i.includes(e))}),a=e=>Date.parse(e)||0,o=e=>t.sort===`comments`?e.comments:t.sort===`created`?a(e.createdAt):a(e.updatedAt);return i.sort((e,t)=>o(t)-o(e)||e.key.localeCompare(t.key))}function Xue(e){let t=new Map;for(let n of e){let e=t.get(n.repo)??[];e.push(n),t.set(n.repo,e)}return t}function Zue(e){return{repos:[...new Set(e.map(e=>e.repo))].sort(),labels:[...new Set(e.flatMap(e=>e.labels))].sort()}}function Que(e){let t=[e.query.trim()&&`search "${e.query.trim()}"`,e.repo,e.label,e.hasSession&&`has session`,e.hasPr&&`has PR`,e.isUnassignedOnly&&`unassigned`].filter(Boolean);return t.length===0?``:`Filtered by ${t.join(`, `)}.`}function Y2(e,t){let n=typeof e==`number`?e:Date.parse(e);if(!Number.isFinite(n))return`unknown`;let r=Math.round(Math.max(0,t-n)/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.round(r/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}function X2(e,t){let n=Y2(e,t);return n===`now`?`just now`:n===`unknown`?`at an unknown time`:`${n} ago`}var Z2=45e3,Q2=[{id:`all`,label:`All`},{id:`me`,label:`Mine`},{id:`team`,label:`Team`},{id:`project`,label:`Projects`}],$2={scope:`all`,repo:``,label:``,sort:`updated`,query:``,hasSession:!1,hasPr:!1,isUnassignedOnly:!1},e4=null,t4=null,n4=null,r4=null,i4=null,a4=null,o4=null,s4=null,c4=null,l4=null,u4=new Map,d4=!1,f4=null,p4=null,m4=new Map,h4=new Map,g4=new Map,_4=new Map,v4=new Map;function y4(e){return`${e.key}:${e.updatedAt}`}function b4(e){return e.sessionId?E.get(e.sessionId):void 0}function x4(e,t,n){let r=b4(t),i=r?.currentState??a.DORMANT,o=ee(i,r?.awaitingBackgroundTasks),s=r?`Session: ${o.label}`:`No session yet`,c=n?`${o.glyph} ${o.label}`:o.glyph;(e.dataset.state!==i||e.title!==s||e.textContent!==c)&&(e.dataset.state=i,e.title=s,e.setAttribute(`aria-label`,s),e.textContent=c)}function S4(e,t=!1){let n=m(`span`,t?`issues-state`:`pr-queue-glyph issues-state`);return x4(n,e,t),n}function C4(e){let t=b4(e);return t?D(t):`none yet`}function w4(e){return[...m4.values()].some(t=>t.issueKey===e.key)}function $ue(e){let t=m4.get(e);t&&(m4.delete(e),h4.set(t.issueKey,`No reply from the server.`),k4())}function ede(e){let t=m4.get(e);return t?(clearTimeout(t.timeoutHandle),m4.delete(e),t):null}function T4(e){let t=y4(e);if(_4.has(t)||[...g4.values()].some(e=>e.cacheKey===t))return;let n=Jm(`issue-detail`);v4.delete(t),p4?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})?g4.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{g4.delete(n),v4.set(t,`No reply from the server. Select the issue to load its description.`),k4()},Z2)}):v4.set(t,`Not connected. Select the issue to load its description.`)}function tde(e){let t=e.projectId;if(!t||b4(e)||w4(e))return;let n=Jm(`open-issue-session`);p4?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})?(m4.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>$ue(n),Z2)}),h4.set(e.key,`Opening session.`),k4()):(h4.set(e.key,`Not connected.`),k4())}function nde(e){let t=m(`button`,`pr-queue-row issue-row`);t.type=`button`,t.dataset.issueKey=e.key,t.setAttribute(`aria-current`,String(e.key===c4));let n=m(`span`,`pr-queue-top`);n.append(m(`span`,`pr-queue-ref`,`#${e.number}`),m(`span`,`pr-queue-title`,e.title||`Untitled issue`));let r=m(`span`,`pr-queue-bottom`);e.sources.includes(`me`)&&r.append(m(`span`,`issues-why`,`you`)),r.append(m(`span`,`issues-row-labels`,e.labels.join(`, `)));for(let t of e.pullRequests)r.append(m(`span`,`issues-row-pr`,`PR #${t.number}`));let i=m(`span`,`pr-queue-elapsed`,Y2(e.updatedAt,Date.now()));return i.dataset.issueAge=e.updatedAt,r.append(i),t.append(S4(e),n,r),t.addEventListener(`click`,()=>{c4=e.key,e4&&(e4.dataset.detailOpen=`true`),T4(e),j4(),r4&&(r4.scrollTop=0)}),t}function E4(e,t,n){let r=m(`dd`);r.append(...n),e.append(m(`dt`,null,t),r)}function D4(e){let t=m(`footer`,`pr-footer issues-detail-footer`),n=b4(e);if(n&&e.sessionId){let n=e.sessionId,r=m(`button`,`pr-action`,`Go to session`);r.type=`button`,r.addEventListener(`click`,()=>B_(n)),t.append(r)}if(e.projectId&&!n){let n=m(`button`,`pr-action`,`Open session`);n.type=`button`,n.disabled=w4(e),n.addEventListener(`click`,()=>tde(e)),t.append(n)}t.append(x(`pr-action pr-action-ghost`,`View on GitHub`,e.url));let r=h4.get(e.key),i=e.projectId?``:`Add a project for ${e.repo} in Settings to open sessions from here.`,a=m(`span`,`pr-action-status issue-open-status`,r??i);return a.setAttribute(`role`,`status`),w4(e)&&a.prepend(m(`span`,`issues-spinner`)),t.append(a),t}function O4(e,t){let n=m(`span`,null,X2(e,t));return n.dataset.issueAgo=e,n}function rde(){let e=r4?.querySelector(`.issues-detail`),t=c4?u4.get(c4):void 0;if(!e||!t)return;let n=e.querySelector(`.issues-facts .issues-state`);n&&x4(n,t,!0);let r=e.querySelector(`.issues-session-name`),i=C4(t);r&&r.textContent!==i&&(r.textContent=i);let a=String(!!b4(t));e.dataset.hasLiveSession!==a&&(e.dataset.hasLiveSession=a,e.querySelector(`.issues-detail-footer`)?.replaceWith(D4(t)))}function k4(){if(!r4)return;let e=l4?.issues.find(e=>e.key===c4);if(!e){r4.replaceChildren(m(`p`,`pr-empty`,`Pick an issue from the queue.`));return}let t=m(`article`,`pr-detail issues-detail`),n=m(`button`,`pr-action pr-action-ghost issues-back`,`Back to issues`);n.type=`button`,n.addEventListener(`click`,()=>{e4&&(e4.dataset.detailOpen=`false`),[...n4?.querySelectorAll(`[data-issue-key]`)??[]].find(e=>e.dataset.issueKey===c4)?.focus({preventScroll:!0})});let r=m(`header`,`pr-detail-heading`),i=m(`div`,`pr-detail-title`);i.append(x(`pr-link`,`${e.repo}#${e.number}`,e.url),m(`h2`,null,e.title||`Untitled issue`));let a=Date.now(),o=m(`div`,`pr-detail-meta`),s=m(`span`,null,`opened by ${e.author||`unknown`} `),c=m(`span`,null,`updated `);s.append(O4(e.createdAt,a)),c.append(O4(e.updatedAt,a)),o.append(s,c,m(`span`,null,`${e.comments} comments`)),e.sources.includes(`me`)&&o.append(m(`span`,`issues-why`,`assigned to you`));for(let t of e.teams)o.append(m(`span`,null,`mentions ${t}`));r.append(i,o);let l=m(`dl`,`issues-facts`);E4(l,`Repository`,[e.repo]),E4(l,`Labels`,[e.labels.join(`, `)||`none`]),E4(l,`Assignees`,[e.assignees.join(`, `)||`unassigned`]),t.dataset.hasLiveSession=String(!!b4(e)),E4(l,`Session`,[S4(e,!0),m(`span`,`issues-session-name`,C4(e))]);let u=e.pullRequests.flatMap(e=>{let t=m(`span`,`issues-pr-state`,e.state);return t.dataset.prState=e.state,[t,x(`issues-inline-link`,`#${e.number} ${e.title}`,e.url)]});E4(l,`Pull request`,u.length>0?u:[`none linked`]);let d=m(`section`,`issues-body-section`),f=y4(e),p=m(`div`,`issue-body`,_4.get(f)??v4.get(f)??`Loading description.`);_4.get(f)===``&&(p.textContent=`No description.`),p.setAttribute(`role`,`status`),d.append(m(`h3`,`pr-section-heading`,`Description`),p),t.append(n,r,l,d,D4(e)),r4.replaceChildren(t)}function A4(e,t,n,r){if(!e)return;let i=r&&!n.includes(r)?[...n,r].sort():n;e.replaceChildren(...[``,...i].map(e=>{let n=m(`option`,null,e||t);return n.value=e,n})),e.value=r}function j4(){d4=!1,M4(),k4()}function M4(){if(!e4||!n4||!t4)return;let e=l4?.issues??[],t=Jue(e);for(let e of Q2){t4.querySelector(`[data-scope="${e.id}"]`)?.setAttribute(`aria-selected`,String(e.id===$2.scope));let n=t4.querySelector(`[data-scope-count="${e.id}"]`);n&&(n.textContent=String(t[e.id]))}let n=Zue(e);A4(a4,`All repos`,n.repos,$2.repo),A4(o4,`All labels`,n.labels,$2.label),i4&&(i4.textContent=Que($2));let r=Yue(e,$2,new Set(E.keys())),i=document.activeElement instanceof HTMLElement&&n4.contains(document.activeElement)?document.activeElement.dataset.issueKey:null,a=[...Xue(r)].map(([e,t])=>{let n=m(`section`,`pr-queue-section`),r=m(`h3`,`pr-section-heading issues-repo-heading`,e);return t.some(e=>e.projectId)||r.append(m(`span`,`issues-repo-note`,`view only`)),r.append(m(`span`,`issues-repo-count`,String(t.length))),n.append(r,...t.map(nde)),n});n4.replaceChildren(...a),r.length===0&&n4.append(m(`p`,`pr-empty`,e.length>0?`No open issues match these filters. Clear the search or pick All.`:que(l4))),i&&[...n4.querySelectorAll(`[data-issue-key]`)].find(e=>e.dataset.issueKey===i)?.focus({preventScroll:!0}),c4&&!e.some(e=>e.key===c4)&&(c4=null,e4.dataset.detailOpen=`false`),f4?.update(l4),N4()}function ide(){let e=m(`div`,`issues-filters`),t=m(`div`,`issues-search-row`),n=m(`input`,`issues-search`);n.type=`search`,n.placeholder=`Search issues`,n.autocomplete=`off`,n.setAttribute(`aria-label`,`Search issues`),n.addEventListener(`input`,()=>{$2.query=n.value,j4()});let r=m(`button`,`pr-action pr-action-ghost`,`Filters`);r.type=`button`,r.setAttribute(`aria-expanded`,`false`),r.setAttribute(`aria-controls`,`issues-filters-panel`);let i=m(`div`,`issues-filters-panel`);i.id=`issues-filters-panel`,i.hidden=!0,r.addEventListener(`click`,()=>{i.hidden=!i.hidden,r.setAttribute(`aria-expanded`,String(!i.hidden))}),t.append(n,r);let a=m(`div`,`issues-filter-row`);function o(e){let t=m(`select`,`issues-field`);return t.setAttribute(`aria-label`,e),a.append(t),t}a4=o(`Repository`),a4.addEventListener(`change`,()=>{$2.repo=a4?.value??``,j4()}),o4=o(`Label`),o4.addEventListener(`change`,()=>{$2.label=o4?.value??``,j4()});let s=o(`Sort`);for(let[e,t]of[[`updated`,`Updated`],[`created`,`Newest`],[`comments`,`Most discussed`]]){let n=m(`option`,null,t);n.value=e??``,s.append(n)}s.addEventListener(`change`,()=>{$2.sort=s.value,j4()});let c=m(`div`,`issues-filter-row`);for(let[e,t]of[[`hasSession`,`Has session`],[`hasPr`,`Has PR`],[`isUnassignedOnly`,`Unassigned`]]){let n=m(`label`,`issues-toggle`),r=m(`input`);r.type=`checkbox`,r.addEventListener(`change`,()=>{$2[e]=r.checked,j4()}),n.append(r,` ${t}`),c.append(n)}return i4=m(`span`,`issues-filter-summary`),i4.setAttribute(`role`,`status`),i.append(a,c),e.append(t,i4,i),e}function N4(){if(!e4||e4.closest(`[hidden]`)||document.hidden)return;let e=Date.now();s4&&(s4.textContent=l4?.lastSyncAt?`Synced ${X2(l4.lastSyncAt,e)}.`:`Not synced yet.`);for(let t of e4.querySelectorAll(`[data-issue-age]`))t.textContent=Y2(t.dataset.issueAge??``,e);for(let t of e4.querySelectorAll(`[data-issue-ago]`))t.textContent=X2(t.dataset.issueAgo??``,e)}function ade(e){p4=e}function ode(e){if(e4)return e4;e4=m(`div`,`issues-content`),e4.dataset.detailOpen=`false`,e.append(e4),f4=sQ(`issues`,e4);let t=m(`div`,`pr-columns issues-columns`),n=m(`section`,`pr-queue-pane`);n.setAttribute(`aria-label`,`Issue queue`),t4=m(`div`,`pr-scope-tabs issues-scope-tabs`),t4.setAttribute(`role`,`tablist`),t4.setAttribute(`aria-label`,`Issue scope`);for(let e of Q2){let t=m(`span`,`issues-scope`);t.setAttribute(`role`,`presentation`);let n=m(`button`,`pr-scope-tab`,e.label);n.type=`button`,n.dataset.scope=e.id,n.setAttribute(`role`,`tab`),n.addEventListener(`click`,()=>{$2.scope=e.id,j4()});let r=m(`span`,`issues-scope-count`);r.dataset.scopeCount=e.id,t.append(n,r),t4.append(t)}n4=m(`nav`,`pr-queue`),n4.setAttribute(`aria-label`,`Issues`);let r=xJ(f4.control);return s4=m(`span`,`issues-sync`),s4.setAttribute(`role`,`status`),r.prepend(s4),r.append(f4.notice),n.append(bJ(t4),ide(),n4,r),r4=m(`section`,`pr-detail-host`),r4.setAttribute(`aria-label`,`Issue detail`),t.append(n,r4),e4.append(t),window.setInterval(N4,3e4),j4(),e4}function sde(){d4&&P4(),N4()}function P4(){if(T(e4))d4=!0;else if(d4=!1,rde(),$2.hasSession)M4();else for(let e of n4?.querySelectorAll(`[data-issue-key]`)??[]){let t=u4.get(e.dataset.issueKey??``),n=e.querySelector(`.issues-state`);t&&n&&x4(n,t,!1)}}function cde(e){if(!e){for(let e of m4.values())clearTimeout(e.timeoutHandle),h4.set(e.issueKey,`Connection lost.`);m4.clear();for(let e of g4.values())clearTimeout(e.timeoutHandle),v4.set(e.cacheKey,`Connection lost. Select the issue to load its description.`);g4.clear(),j4()}}function lde(e){let t=l4?.issues.find(e=>e.key===c4);l4=e,u4=new Map(e.issues.map(e=>[e.key,e]));let n=e.issues.find(e=>e.key===c4);n&&n.updatedAt!==t?.updatedAt&&T4(n),j4()}function ude(e){let t=g4.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),g4.delete(e.requestId),e.ok&&e.body!==null&&_4.set(t.cacheKey,e.body),(!e.ok||e.body===null)&&v4.set(t.cacheKey,e.error||`Could not load description. Select the issue to try again.`),k4())}function dde(e){if(typeof e.requestId!=`string`)return;let t=ede(e.requestId);if(!t)return;let n=t.issueKey;if(e.ok===!0){let r=typeof e.sessionName==`string`?e.sessionName:`issue #${t.issueNumber}`,i=e.pending===!0?` Prompt queued.`:``,a=e.existing===!0?`already open`:`created`;h4.set(n,`Session "${r}" ${a}.${i}`);let o=l4?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),j4();return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;h4.set(n,r),k4()}var fde=4e3;function pde({render:e,holdMs:t=fde,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(){o=null,i.size>0?s(!1):a&&(a=!1,e())}return{begin(e){i.add(e)},settle(e){i.delete(e),s(!0)},request(){i.size===0&&o===null?e():(a=!0,s(!1))},_state(){return{pending:i.size,held:a,armed:o!==null}}}}var F4=null,I4=null,L4=null,R4=null,z4=`http://www.w3.org/2000/svg`,B4=Uh({getAck:Jp,setAck:Yp,signature:()=>Cie({posthog:F4}),isLooking:()=>!T(I4)}),V4=pde({render:l3}),H4=new Set,U4=null,W4=new Map,G4=new WeakMap,mde=`this issue`,K4=Vh(()=>I4),hde={spiking:`spiking`,regressed:`regressed`,worsened:`worsened`,new:`new`,quiet:`quiet`},q4=[{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}],gde=q4.map(e=>e.track).join(` `),_de=q4.filter(e=>!e.isMagnitude).map(e=>e.phoneTrack).join(` `),vde=q4.findIndex(e=>e.startsActionCluster)+1;function J4(e){let t=m(`div`,e);return t.style.setProperty(`--radar-issue-grid`,gde),t.style.setProperty(`--radar-issue-grid-phone`,_de),t.style.setProperty(`--radar-issue-actions-start`,String(vde)),t}function Y4(e,t){let n=m(`span`,`radar-issue-magnitudes`),r=!1;for(let i of q4){let a=t(i);i.isMagnitude?(r||=(e.append(n),!0),n.append(a)):e.append(a)}}function X4(e){return Number.isFinite(e)?String(e):`0`}function yde(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?``:`elapsed ${zh(Date.now()-e)}`}function Z4(e){return typeof e?.issueId==`string`?e.issueId:``}function Q4(e,t){return[String(e??``),String(t??``)].join(`::`)}function bde(e,t,n){let r=W4.get(Q4(e,t));if(!r||!r.copy.isConnected)return!1;let i=Gh(n);return i?(r.summary||(r.summary=m(`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 $4(e,t,n){let r=Z4(e);if(!r)return;U4?.dialog.close();let i=Eie({issueTitle:String(e.title||r),projectLabel:n,onOpenReport:()=>t3(e)});U4={projectId:String(t??``),issueId:r,dialog:i},i.update(Kh(e))}function e3(){if(!U4)return;if(!U4.dialog.isOpen()){U4=null;return}let e=qh(F4,U4.projectId,U4.issueId);e&&U4.dialog.update(Kh(e))}function t3(e){let t=Z4(e);t&&Ym(`get-radar-report`,{issueId:t}).then(n=>{n.ok?n.found?ag({issueId:t,issueTitle:String(e.title??``),format:String(n.format??``),content:String(n.content||``)}):ag({issueId:t,issueTitle:String(e.title??``),message:String(n.message||`Report not found`)}):ag({issueId:t,issueTitle:String(e.title??``),error:String(n.error||`Could not read report`)})}).catch(n=>{ag({issueId:t,issueTitle:String(e.title??``),error:String(n?.message||`Could not read report`)})})}function n3(){let e=m(`div`,`radar-issue-actions`),t=m(`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=m(`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)=>{V4.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,V4.settle(e)};Ym(n,r).then(e=>{e.ok?(l(`ok`,s(e)),c&&c(e)):l(`error`,String(e.error||`Request failed`))}).catch(e=>l(`error`,String(e?.message||`Request failed`)))},showFollowUp:a,wrap:e}}function xde(e){let t=m(`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(),Fde(e)}),t}function Sde(e,t,n){let{addButton:r,request:i,showFollowUp:a,wrap:o}=n3(),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`,()=>$4(e,t,n)),e.inFlight||r(`Open session`,`Paste an investigation prompt into the mapped project session`,()=>{s(`radar-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`&&R4&&a(xde(e.sessionId))})}),r(`Resolve`,`Mark this issue resolved in PostHog`,()=>{s(`radar-issue-action`,{action:`resolve`},`Resolving in PostHog`,()=>`Marked resolved`)}),r(`Suppress`,`Suppress this issue in PostHog`,()=>{s(`radar-issue-action`,{action:`suppress`},`Suppressing in PostHog`,()=>`Marked suppressed`)}),o}function r3(e){return Jg()?mde:e}function i3(e){let t=G4.get(e);t&&(e.title=t(),e.setAttribute(`aria-label`,e.title))}function Cde(){if(I4)for(let e of I4.querySelectorAll(`.radar-issue-reportable`))i3(e)}Xg(Cde);function a3(e,t,n){e.classList.add(`radar-issue-reportable`),e.tabIndex=0,e.setAttribute(`role`,`button`),G4.set(e,t),i3(e),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 wde(e,t,n){let r=m(`div`,`radar-issue`);r.dataset.severity=aie(e.change);let i=m(`span`,`radar-stripe`);i.setAttribute(`aria-hidden`,`true`);let a=m(`span`,`radar-change`,hde[e.change??``]||String(e.change||`unknown`)),o=x(`radar-issue-title`,String(e.title||`Untitled issue`),e.url,String(e.title||``)),s=m(`span`,`radar-metric`);s.append(m(`span`,`radar-metric-value`,X4(e.occurrences)),m(`span`,`radar-metric-label`,`occ`));let c=m(`span`,`radar-metric`);c.append(m(`span`,`radar-metric-value`,X4(e.users)),m(`span`,`radar-metric-label`,`users`));let l=lie(e.history),u=uie(l,64,16),d=u?document.createElementNS(z4,`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(z4,`title`);e.textContent=fie(l);let t=document.createElementNS(z4,`polyline`);t.setAttribute(`points`,u),d.append(e,t)}let f=Gh(e),p=m(`span`,`radar-issue-copy`);p.append(o);let h=null;f&&(h=m(`span`,`radar-issue-summary`),h.textContent=f,p.append(h)),W4.set(Q4(t,e.issueId),{copy:p,summary:h});let g=m(`span`,`radar-issue-meta`),_=oie(e);if(_!==null){let e=m(`span`,`radar-issue-seen`);e.title=new Date(_).toLocaleString(),K4.track(e,_,Bh),g.append(e)}let v=sie(e);v&&g.append(m(`span`,`radar-issue-status`,v));let y=String(e.title||e.issueId);if(e.inFlight){let i=m(`span`,`radar-verdict`,`investigating`);i.dataset.verdict=`INVESTIGATING`,g.append(i);let a=typeof e.startedAt==`number`?e.startedAt:null;if(a!==null&&Number.isFinite(a)&&a>0){let e=m(`span`,`radar-issue-elapsed`);K4.track(e,a,yde),g.append(e)}Z4(e)&&a3(r,()=>`Watch the investigation of ${r3(y)}`,()=>$4(e,t,n))}if(!e.inFlight&&e.verdict){let t=m(`span`,`radar-verdict`,Yh(e.verdict));t.dataset.verdict=e.verdict,g.append(t),Z4(e)&&a3(r,()=>`View investigation report for ${r3(y)}`,()=>t3(e))}g.childElementCount>0&&p.append(g);let b=m(`span`,`radar-issue-trend`);d&&b.append(d);let S=die(l);if(S){let e=m(`span`,`radar-delta`,`${S.direction===`up`?`+`:S.direction===`down`?`-`:`=`}${S.percent}%`);e.dataset.direction=S.direction,b.append(e)}let C={stripe:i,change:a,copy:p,occurrences:s,users:c,trend:b};return Y4(r,e=>C[e.columnId]),Z4(e)&&r.append(Sde(e,t,n)),r}var o3=(e,t,n)=>w(`radar`,e,t,n);function Tde(e){return e.error?`poll failed: ${e.error}`:e.staleMs>0?`stale ${zh(e.staleMs)}`:``}function s3(e,t,{showHost:n,nameTag:r,nameClass:i,hostClass:a}){let o=m(r,i,$h(t));o.title=String(t.name||``),e.append(o);let s=n?eg(t.host):``;s&&e.append(m(`span`,a,s))}function Ede(){let e=J4(`radar-column-heads`);for(let t of q4){if(!t.headText){e.append(m(`span`));continue}let n=m(`span`,`radar-column-head`,t.headText);n.dataset.column=t.columnId,e.append(n)}return e}function Dde(e,t){let n=e.project,r=m(`div`,`radar-project`),i=wie(n.issues),a=Qh(i),o=m(`div`,`radar-project-head`);s3(o,n,{showHost:t,nameTag:`h3`,nameClass:`radar-project-name`,hostClass:`radar-project-host`}),r.append(o);let s=m(`div`,`radar-project-summary`);s.append(o3(a.active===1?`active issue`:`active issues`,X4(a.active))),s.append(o3(`spiking`,X4(a.spiking),a.spiking>0?`crit`:null)),s.append(o3(`needs you`,X4(a.needsHuman),a.needsHuman>0?`warn`:null));let c=Tde(e);if(c){let t=m(`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(Ede());let l=J4(`radar-issues`);for(let e of i)l.append(wde(e,n.projectId,$h(n)));return r.append(l),r}function Ode(e,t){let n=e.project,r=m(`div`,`radar-quiet-row`),i=m(`span`,`radar-quiet-dot`);return i.setAttribute(`aria-hidden`,`true`),r.append(i),s3(r,n,{showHost:t,nameTag:`span`,nameClass:`radar-quiet-name`,hostClass:`radar-quiet-host`}),r.append(m(`span`,`radar-quiet-count`,`0 issues`)),r}var c3=(e,t)=>ne(`radar`,e,t);function kde(){let e=m(`div`,`radar-issue`);return e.dataset.skeleton=``,Y4(e,e=>m(`span`,e.cellClass)),e}function Ade(){let e=J4(`radar-issues`);e.setAttribute(`aria-busy`,`true`),e.setAttribute(`aria-label`,`Loading issues`);for(let t=0;t<5;t+=1)e.append(kde());return e}function jde(e,t=`ready`){let n=c3(`Errors`);if(t===`pending`)return n.append(Ade()),n;if(t===`placeholder`||e.length===0){let e=m(`p`,`radar-unconfigured`,nie(F4)),t=lg(`lanes-posthog`,`posthog-enabled`,`PostHog settings`);return e.append(document.createTextNode(` `),t),n.append(e),n}let r=m(`div`,`radar-global-tick`),i=Number(F4?.intervalMinutes);K4.track(r,F4?.ts,e=>{let t=`polled ${Bh(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}=vie(e,Date.now(),{intervalMs:a}),c=gie(e);for(let e of o)n.append(Dde(e,c));if(s.length===0)return n;let l=m(`div`,`radar-quiet`);for(let e of s)l.append(Ode(e,c));return n.append(l),n}function Mde(e){let{addButton:t,request:n,wrap:r}=n3();return e.issueId&&t(`Open report`,`Open the investigation report for this issue`,()=>{t3({issueId:e.issueId,title:e.title})}),t(`Archive`,`Remove this investigation from the inbox`,()=>{n(`archive:${e.id}`,`radar-archive-investigation`,{id:e.id},`Archiving`,()=>`Archived`,()=>H4.add(e.id))}),r}function Nde(e){let t=m(`div`,`radar-investigation`),n=m(`span`,`radar-verdict`,Yh(e.verdict));n.dataset.verdict=e.verdict;let r=x(`radar-issue-title`,e.title,e.url),i=m(`span`,`radar-issue-copy`);if(i.append(r),e.summaryLine){let t=m(`span`,`radar-issue-summary`);t.textContent=e.summaryLine,i.append(t)}if(e.prUrl){let t=m(`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=m(`span`,`radar-verdict`,`fix`);e.dataset.mode=`fix`,t.append(e)}if(t.append(i),e.projectLabel){let n=m(`span`,`radar-investigation-project`);n.textContent=e.projectLabel,t.append(n)}if(e.at>0){let n=m(`span`,`radar-investigation-time`,Bh(e.at));n.title=new Date(e.at).toLocaleString(),t.append(n)}return t.append(Mde(e)),t}function Pde(e){let t=c3(`Investigations`,`completed, not yet archived`),n=m(`div`,`radar-investigations`);for(let t of e)n.append(Nde(t));return t.append(n),t}function Fde(e){R4&&R4(e)}function l3(){if(!I4)return;I4.textContent=``,W4.clear(),K4.reset();let e=re(F4),t=yie(F4,H4),n=iie(F4,e.length);I4.append(jde(e,n)),t.length>0&&I4.append(Pde(t))}function u3(){V4.request()}function d3(){L4&&L4(B4.refresh())}function Ide(){B4.acknowledge(),d3()}function Lde(e){L4=e,d3()}function Rde(e){R4=e}function zde(e){if(I4)return I4;let t=m(`div`,`radar-content`);return e.appendChild(t),I4=t,K4.ensure(),l3(),t}function Bde(e){F4=e,bie(F4,H4),u3(),d3(),e3()}function Vde(e){let t=qh(F4,e.projectId,e.issueId)?.inFlight===!0;if(!Zre(F4,e))return;e3();let n=qh(F4,e.projectId,e.issueId);t&&bde(e.projectId,e.issueId,n)||u3()}function Hde(e){U4?.dialog.isOpen()&&Qre(U4,e)&&U4.dialog.update(Jh(e))}function Ude(e){$re(F4,e)?(e3(),u3(),d3()):Hde(e)}function f3(e){return{skipPerms:e.skipPerms??e.dangerouslySkipPermissions??!1,saneYolo:e.saneYolo===!0,worktree:e.worktree??e.isWorktree??!1,workspace:e.workspace??e.isWorkspace??!1,guarded:e.guarded??e.isGuarded??!1,path:e.path,stateSince:e.stateSince,taskTitle:typeof e.taskTitle==`string`?e.taskTitle:null,taskTitleIsCustom:e.taskTitleIsCustom===!0}}var Wde=[{name:`glimmervoid`,state:a.RUNNING,awaitingBackgroundTasks:!1},{name:`glimmervoid (2)`,state:a.RUNNING,awaitingBackgroundTasks:!0},{name:`api`,state:a.WAITING,awaitingBackgroundTasks:!1},{name:`docs-site`,state:a.IDLE,awaitingBackgroundTasks:!1}];function Gde(){let e=m(`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 Wde){let{row:n,refs:r}=TV(`div`,`compact-status-preview-pill`);r.name.textContent=t.name,DV(n,r,t.state,t.awaitingBackgroundTasks),e.append(n)}return e}var p3=null,m3=null,h3=null,g3=null,_3=null,v3=-1,y3=null,b3={isRightToLeft:!1,arcProgress:0},x3=1;function S3(){if(!p3||y3===null)return;let e=Lf({viewportWidthPx:document.documentElement.clientWidth,viewportHeightPx:document.documentElement.clientHeight,verticalProgress:y3,...b3});g(p3,zf(e,x3,window.devicePixelRatio))}function C3(){_3!==null&&(clearTimeout(_3),_3=null)}function w3(e=wp()){return Df({isEnabled:e,hasReducedMotion:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,isPhone:fT(),options:pm()})}function T3(e){e.onanimationend=null,e.style.animation=`none`,g3&&(g3.style.animation=`none`),e.hidden=!0}function E3(e,t){if(!p3||!m3||!h3||!g3||w3())return;let n=pm();C3();let r=Ef(n,v3,Math.random,t);if(T3(p3),!r){_3=setTimeout(()=>E3(!1),1e3);return}y3=r.verticalProgress,b3={isRightToLeft:r.isRightToLeft,arcProgress:r.arcProgress},x3=n.flyingAnimalsScale,S3();let i=vf[r.animalIndex];m3.className=`nyan-sprite ${i.sprite}`,h3.className=`nyan-trail ${i.trail}`,v3=r.animalIndex,p3.hidden=!1,p3.offsetWidth,p3.style.animation=`nyan-fly ${r.durationSeconds}s linear`,g3.style.animation=`nyan-trail-hold ${r.durationSeconds}s linear`,e&&(p3.style.animationDelay=`-${r.firstDelaySeconds}s`,g3.style.animationDelay=`-${r.firstDelaySeconds}s`),p3.onanimationend=e=>{p3&&e.target===p3&&(T3(p3),_3=setTimeout(()=>E3(!1),r.gapMs))}}function D3(){if(p3||w3())return;p3=document.createElement(`div`),p3.className=`nyan-flight`,p3.setAttribute(`aria-hidden`,`true`);let e=document.createElement(`div`);e.className=`nyan-trail-window`,g3=document.createElement(`div`),g3.className=`nyan-trail-hold`,h3=document.createElement(`div`),g3.append(h3),e.append(g3),m3=document.createElement(`div`),p3.append(e,m3),document.body.appendChild(p3),window.addEventListener(`resize`,S3),window.addEventListener(`orientationchange`,S3),E3(!0)}function Kde(e){D3(),E3(!1,e)}function O3(){C3(),window.removeEventListener(`resize`,S3),window.removeEventListener(`orientationchange`,S3),p3?.remove(),p3=null,m3=null,h3=null,g3=null,v3=-1,y3=null}var k3=!1;function A3(e){let t=document.documentElement;if(k3||(k3=!0,pT(()=>A3(wp())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>A3(wp()))),e){if(t.dataset.flyingAnimals=`true`,w3(e)){O3();return}D3()}else delete t.dataset.flyingAnimals,O3()}function qde(){let e=m(`div`),t=m(`p`,`flying-animals-status`);t.id=`flying-animals-gallery-status`,t.setAttribute(`role`,`status`);let n=m(`div`,`flying-animals-gallery`);n.setAttribute(`aria-label`,`Animal gallery`);let r=[],i=()=>{let e=w3(),n=wf(pm().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=pm();for(let e of vf){let o=m(`article`,`flying-animal-tile`),s=_m(e),c=m(`label`,`flying-animal-include`),l=m(`input`,`settings-view-checkbox`);l.type=`checkbox`,l.checked=!a.flyingAnimalsExcludedSprites.includes(e.sprite),l.setAttribute(`aria-label`,`Include ${e.name}`),l.addEventListener(`change`,()=>{let t=new Set(pm().flyingAnimalsExcludedSprites);l.checked&&t.delete(e.sprite),l.checked||t.add(e.sprite),fm([...t]),A3(wp()),i()}),c.append(l,document.createTextNode(`Include`));let u=m(`button`,`btn-dialog btn-dialog-cancel`,`Fly now`);u.type=`button`,u.setAttribute(`aria-describedby`,t.id),u.addEventListener(`click`,()=>Kde(e.sprite)),r.push(u),o.append(s,m(`h2`,`flying-animal-name`,e.name),c,u),n.append(o)}return i(),e.append(t,n),e}var j3=`johncwaters/glimmervoid`,M3={scope:`browser`,access:`editable`,takesEffect:`now`},N3={scope:`browser`,access:`advanced`,takesEffect:`now`},X={scope:`machine`,access:`editable`,takesEffect:`now`},P3={scope:`machine`,access:`editable`,takesEffect:`new-sessions`},F3={scope:`machine`,access:`readout`,takesEffect:`now`},Z={scope:`machine`,access:`file-only`},I3=1e3,L3=60,R3=60,z3=I3*L3,B3=z3*R3,Jde=B3*24,Yde={label:`investigations`,storedPerDisplay:1},Xde={label:`sessions`,storedPerDisplay:1},Zde={label:`workers`,storedPerDisplay:1},Qde={label:`recurrences`,storedPerDisplay:1},$de={label:`actions`,storedPerDisplay:1},V3={label:`seconds`,storedPerDisplay:1},H3={label:`minutes`,storedPerDisplay:1},U3={label:`hours`,storedPerDisplay:1},W3={label:`days`,storedPerDisplay:1},G3={label:`seconds`,storedPerDisplay:I3,storedLabel:`ms`},K3={label:`minutes`,storedPerDisplay:z3,storedLabel:`ms`},q3={label:`minutes`,storedPerDisplay:L3,storedLabel:`seconds`},efe={label:`hours`,storedPerDisplay:B3,storedLabel:`ms`},tfe={label:`hours`,storedPerDisplay:R3,storedLabel:`minutes`},nfe={label:`days`,storedPerDisplay:Jde,storedLabel:`ms`},J3={label:`USD`,storedPerDisplay:1},Y3={label:`users`,storedPerDisplay:1},X3={label:`reviews per hour`,storedPerDisplay:1},Z3={label:`times`,storedPerDisplay:1},Q=`A tuning knob kept out of the Settings view; the default suits almost every install.`,Q3=`A diagnostic switch kept out of the Settings view; change it in config.json while investigating.`,$3=`Changes how the server process or its worktrees behave, so it is set in config.json with a restart or new sessions in mind.`,e6=`A structured value with no dashboard control; edit it in config.json.`,t6=`Never editable from the dashboard by rule; edit it in config.json.`,n6=`lanes`;function r6(e){return e.map(e=>({value:e,label:e[0].toUpperCase()+e.slice(1)}))}var rfe=Object.freeze({"machine-terminal":{title:`Terminal`,description:`Terminal behavior shared by dashboard clients.`},"machine-detection-sessions":{title:`Detection and sessions`,description:`Config-file-only detection, timing, worktree and process settings.`},"lanes-ingest":{title:`Ingest`,description:`The machine-context sources behind Visions.`}}),i6=Object.freeze([{id:`browser-appearance`,level:`browser`,title:`Appearance`,description:`How this browser draws the dashboard.`,legacyIds:[`browser-flying-animals`,`animals`,`flying-animals`],settings:[{id:`theme`,path:`pref:themeId`,title:`Theme`,description:`Color scheme for the dashboard.`,control:`select`,optionsFrom:`themes`,keywords:[`color`,`palette`],defaultValue:`phyrexian`,...M3},{id:`compact-status`,path:`pref:compactStatusLabels`,title:`Hide status words in sidebar`,description:`Hide status words in the sidebar and on the phone Board while keeping the colored status mark and the phone Plan ready badge.`,control:`toggle`,keywords:[`sidebar`,`status`,`compact`],defaultValue:!1,...M3},{id:`session-usage-chips`,path:`pref:sessionUsageChips`,title:`Show usage on session cards`,description:`Shows each card's transcript token count and CLI-reported cost when available, otherwise a calculated API list-price estimate.`,control:`toggle`,keywords:[`usage`,`cost`,`tokens`,`card`,`price`],defaultValue:!1,...M3},{id:`flying-animals`,path:`pref:flyingAnimalsEnabled`,title:`Flying animals`,description:`Show animated animals flying across the dashboard.`,control:`toggle`,keywords:[`animation`,`motion`,`animals`],defaultValue:!1,...M3},{id:`animals-min-gap`,path:`pref:flyingAnimalsMinGapSeconds`,title:`Time between flights: minimum`,description:`Shortest pause between flights.`,control:`number`,integer:!1,step:.1,range:xc,unit:V3,maximumSettingId:`animals-max-gap`,keywords:[`animals`,`frequency`],defaultValue:wc.flyingAnimalsMinGapSeconds,...N3},{id:`animals-max-gap`,path:`pref:flyingAnimalsMaxGapSeconds`,title:`Time between flights: maximum`,description:`Longest pause between flights.`,control:`number`,integer:!1,step:.1,range:xc,unit:V3,keywords:[`animals`,`frequency`],defaultValue:wc.flyingAnimalsMaxGapSeconds,...N3},{id:`animals-min-duration`,path:`pref:flyingAnimalsMinDurationSeconds`,title:`Flight duration: minimum`,description:`Shortest flight, for faster animals.`,control:`number`,integer:!1,step:.1,range:Sc,unit:V3,maximumSettingId:`animals-max-duration`,keywords:[`animals`,`speed`],defaultValue:wc.flyingAnimalsMinDurationSeconds,...N3},{id:`animals-max-duration`,path:`pref:flyingAnimalsMaxDurationSeconds`,title:`Flight duration: maximum`,description:`Longest flight, for slower animals.`,control:`number`,integer:!1,step:.1,range:Sc,unit:V3,keywords:[`animals`,`speed`],defaultValue:wc.flyingAnimalsMaxDurationSeconds,...N3},{id:`animals-scale`,path:`pref:flyingAnimalsScale`,title:`Size multiplier`,description:`Scale applied on top of the viewport size.`,control:`number`,integer:!1,step:.1,range:Cc,unit:Z3,keywords:[`animals`,`size`],defaultValue:wc.flyingAnimalsScale,...N3},{id:`animals-on-phone`,path:`pref:flyingAnimalsOnPhone`,title:`Show on phone layout`,description:`Allow flights on the phone layout.`,control:`toggle`,keywords:[`animals`,`mobile`],defaultValue:wc.flyingAnimalsOnPhone,...N3}]},{id:`browser-notifications`,level:`browser`,title:`Notifications`,description:`How this browser, and the Telegram bot shared by every lane, get your attention.`,settings:[{id:`alert-sounds-enabled`,path:`pref:soundEnabled`,title:`Alert sounds`,legacyIds:[{sectionId:`browser-appearance`,settingId:`alert-sounds-enabled`}],description:`Play sounds when a session needs attention and when a merge celebration plays. The same switch as the note button in the desktop header.`,control:`toggle`,keywords:[`audio`,`mute`,`sound`,`notification`],defaultValue:!0,...M3},{id:`alert-sound`,path:`pref:soundId`,title:`Alert sound`,legacyIds:[{sectionId:`browser-appearance`,settingId:`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`,...M3},{id:`desktop-notifications`,path:`pref:notificationsEnabled`,title:`Desktop notifications`,legacyIds:[{sectionId:`browser-appearance`,settingId:`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,...M3}]},{id:`machine-telegram`,level:`machine`,parent:`browser-notifications`,title:`Telegram`,description:`One bot shared by session, PR review and PostHog notifications.`,legacyIds:[`telegram`,`notifications`],settings:[{id:`telegram-bot-token`,path:`telegram.botToken`,title:`Bot token`,description:`Credential used by the shared Telegram bot. When GLIMMERVOID_TELEGRAM_BOT_TOKEN supplies it, this field is read-only.`,control:`password`,keywords:[`credential`,`api`],defaultValue:``,...X},{id:`telegram-chat-id`,path:`telegram.chatId`,title:`Chat id`,description:`Destination chat for enabled Telegram lanes.`,control:`text`,keywords:[`destination`,`channel`],defaultValue:``,...X},{id:`telegram-session-notifications`,path:`telegramNotifications`,title:`Send session notifications`,description:`Send session completion, input and failure alerts when no dashboard is open. Unacknowledged alerts also escalate after the phone escalation delay while a dashboard remains open.`,control:`toggle`,keywords:[`phone`,`off dashboard`],defaultValue:!1,...X}]},{id:`machine-sessions`,level:`machine`,title:`Sessions`,description:`How sessions start, where projects are found, and what the dashboard shows for them.`,legacyIds:[`machine-general`,`general`,`machine-repositories`,`repos`,`repositories`],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, and tell sessions that were mid-turn, or had a background agent, monitor or scheduled wakeup in flight, to continue.`,control:`toggle`,keywords:[`startup`,`conversation`],defaultValue:!0,...X},{id:`conversation-view`,path:`conversationView`,title:`Conversation view (experimental)`,description:`Let each Claude Code and Codex session turn on a Conversation face from its card menu, which renders the transcript as messages, approvals and a composer. Sessions stay on the terminal until you turn it on for them. A Claude Code session started while this is on can answer its permission prompts and questions there. A Codex session connects on its next start, through a local app-server so approvals can be answered from the dashboard; guarded Codex sessions and those that bypass Codex hook trust keep the terminal only.`,control:`toggle`,keywords:[`experimental`,`transcript`,`chat`,`codex`,`claude`],defaultValue:!1,...X},{id:`streamer-mode`,path:`streamerMode`,title:`Streamer mode`,description:`Hide sensitive details in the dashboard while screen sharing or streaming.`,control:`toggle`,keywords:[`streaming`,`screen share`,`privacy`],defaultValue:!1,...X},{id:`repository-roots`,path:`repoRoots`,title:`Repository roots`,description:`Directories scanned for projects when adding sessions.`,control:`list`,keywords:[`folders`,`project discovery`],defaultValue:[],listPlaceholder:`Repository root path`,listEmptyText:`No repository roots configured.`,...X},{id:`custom-agents`,path:`status:custom-agents`,title:`Custom agents`,description:`Extra agent CLIs a session can be spawned with, declared under customAgents in config.json.`,control:`readonly`,keywords:[`adapters`,`cli`],status:`custom-agents`,...F3}]},{id:`machine-guardrails`,level:`machine`,title:`Guardrails and unattended`,description:`What a guarded session may touch, and which unattended actions automated work may take. Claude Code sessions on Linux and macOS write anywhere this account can, except credentials, Glimmervoid's own state and the blocked folders here.`,legacyIds:[`lanes-unattended`,`unattended`],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,...X},{id:`sane-yolo`,path:`saneYolo`,title:`Sane YOLO`,description:`Block catastrophic commands in sessions that skip permission prompts when the cc-safety-net executable is available and trusted hooks are installed. Missing or untrusted hooks leave a session unprotected.`,control:`toggle`,keywords:[`permissions`,`yolo`,`safety`],defaultValue:!0,...P3},{id:`rtk-compression`,path:`rtk`,title:`rtk output compression`,description:`Compress Bash output with the rtk executable.`,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,...P3},{id:`post-turn-checks-mode`,path:`postTurnChecks.mode`,title:`Post-turn checks mode`,description:`Default mode for post-turn checks. Project and individual rule modes override it, so Report can still allow file fixes.`,control:`select`,options:r6(zl),keywords:[`quality`,`fixes`],defaultValue:`report`,...X},{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,...X},{id:`guardrails-unguarded-repos`,path:`guardrails.unguardedRepos`,title:`Unguarded repositories`,description:`Folders whose sessions run without guardrails. A session started in one of these folders, or below it, is not guarded.`,control:`list`,keywords:[`guardrails`,`opt out`,`dotfiles`],danger:!0,warning:`A session without guardrails can read credentials and write anywhere this account can.`,defaultValue:[],listPlaceholder:`Folder path`,listEmptyText:`Every repository is guarded.`,...P3},{id:`guardrails-blocked-paths`,path:`guardrails.blockedPaths`,title:`Blocked folders`,description:`Extra folders and files a guarded session cannot write, on top of credentials and Glimmervoid's own state. A leading ~ means the home folder.`,control:`list`,keywords:[`guardrails`,`block`,`protect`],defaultValue:[],listPlaceholder:`~/folder`,listEmptyText:`Only the built-in list is blocked.`,...P3},{id:`guardrails-unreadable-paths`,path:`guardrails.unreadablePaths`,title:`Unreadable folders`,description:`Extra folders and files a guarded session cannot read, on top of the built-in credential list. A leading ~ means the home folder.`,control:`list`,keywords:[`guardrails`,`secrets`,`credentials`],defaultValue:[],listPlaceholder:`~/folder`,listEmptyText:`Only the built-in credential list is unreadable.`,...P3}]},{id:`machine-updates`,level:`machine`,title:`Updates`,description:`See which Glimmervoid version is running, which one is newest, and update in one step.`,legacyIds:[`updates`],settings:[{id:`update-actions`,path:`status:update-actions`,title:`Status and actions`,legacyIds:[`update-summary`,`update-installed`,`update-latest`,`update-last-checked`].map(e=>({sectionId:`machine-updates`,settingId:e})),description:`Whether this install is up to date, the running and newest versions, the last check, and the update and restart actions.`,control:`readonly`,keywords:[`version`,`available`,`current`,`check`,`restart`,`commit`,`installed`,`release`,`failure`],status:`update-actions`,...F3},{id:`update-channel`,path:`updateChannel`,title:`Channel`,description:`Track tagged releases or the upstream of the checked-out branch.`,control:`select`,options:r6(Rl),keywords:[`release`,`branch`],defaultValue:`release`,...X},{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,...X}]},{id:`machine-usage`,level:`machine`,title:`Usage`,description:`Local transcript accounting and estimated-cost budgets.`,legacyIds:[`usage`],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`,...X},{id:`usage-retain-days`,path:`usage.retainDays`,title:`Retain transcript detail`,description:`How long live transcript detail stays available. A monthly budget keeps detail from the start of the current month when that is longer.`,control:`number`,range:Kc,unit:W3,keywords:[`history`,`retention`],defaultValue:90,...X},{id:`usage-daily-budget`,path:`usage.budget.dailyUsd`,title:`Daily budget`,description:`Estimated daily spend alert threshold. Alerts at 50%, 75% and 100% do not stop spending. Zero or below disables the threshold.`,control:`number`,range:Yc,unit:J3,keywords:[`spend`,`alert`],defaultValue:null,integer:!1,nullable:!0,zeroIsNull:!0,step:.01,...X},{id:`usage-monthly-budget`,path:`usage.budget.monthlyUsd`,title:`Monthly budget`,description:`Estimated monthly spend alert threshold. Alerts at 50%, 75% and 100% do not stop spending. Zero or below disables the threshold.`,control:`number`,range:Yc,unit:J3,keywords:[`spend`,`alert`],defaultValue:null,integer:!1,nullable:!0,zeroIsNull:!0,step:.01,...X}]},{id:n6,level:`lanes`,title:`Lanes`,description:`The background work Glimmervoid runs for you, one sub-section per lane.`,settings:[]},{id:`lanes-visions`,level:`lanes`,parent:n6,title:`Visions`,description:`Editor-buffer findings, bounded model comments, and the machine-context ingest behind them.`,legacyIds:[`visions`,`lanes-ingest`,`ingest`],settings:[{id:`visions-enabled`,path:`visions.enabled`,title:`Enable Visions`,description:`Set up supported editors detected on this machine, then show their buffer findings in the Visions view.`,control:`toggle`,keywords:[`editor`,`findings`,`lsp`],defaultValue:!1,...X},{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,...X},{id:`visions-max-per-hour`,path:`visions.dispatch.maxPerHour`,title:`Max per hour`,description:`Maximum review sessions dispatched per hour. One slot is reserved for edit reviews; activity-driven reviews take the rest, up to the activity cap set by visions.dispatch.activityMaxPerHour.`,control:`number`,range:yc,unit:X3,keywords:[`rate limit`,`reviews`],defaultValue:6,...X},{id:`visions-model`,path:`visions.dispatch.model`,title:`Model override`,description:`Leave blank to use the opus model alias.`,control:`text`,keywords:[`claude`,`override`],defaultValue:``,...X},{id:`visions-projects`,path:`visions.projects`,title:`Projects`,description:`Clear every selection, including unavailable projects, to accept buffers from every configured project.`,control:`projects`,keywords:[`repositories`,`filter`],defaultValue:[],...X},{id:`visions-auto-fix`,path:`visions.autoFix`,title:`Apply tier 1 fixes`,description:`Allow Visions to edit eligible open Markdown buffers, including inactive buffers, 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,...X},{id:`ingest-enabled`,path:`ingest.enabled`,title:`Enable machine context ingest`,description:`Enable the local activity feed behind Visions. Turning Visions on enables ingest unless ingest.enabled is explicitly false.`,control:`toggle`,keywords:[`events`,`activity`,`ingest`],defaultValue:!1,...X}]},{id:`lanes-posthog`,level:`lanes`,parent:n6,title:`PostHog`,description:`Error monitoring, investigations and traffic-spike alerts.`,legacyIds:[`posthog`],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,...X},{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`,...X},{id:`posthog-api-key`,path:`posthog.apiKey`,title:`Personal API key`,description:`Credential with read access to PostHog projects. When GLIMMERVOID_POSTHOG_API_KEY supplies it, this field is read-only.`,control:`password`,keywords:[`credential`,`token`],defaultValue:``,...X},{id:`posthog-projects`,path:`posthog.projects`,title:`Projects`,description:`PostHog project ids to monitor. config.json holds "all" or an array of ids, and an empty array monitors no project. In Settings that empty array shows as none, and an empty list saves "all".`,control:`list`,keywords:[`project ids`,`filter`],defaultValue:`all`,valueKind:`posthog-projects`,listPlaceholder:`Project id`,listEmptyText:`Every project the key can read.`,...X},{id:`posthog-interval`,path:`posthog.intervalMinutes`,title:`Poll interval`,description:`Delay between PostHog polling passes.`,control:`number`,integer:!1,step:`any`,range:yc,unit:H3,keywords:[`refresh`,`schedule`],defaultValue:15,...X},{id:`posthog-max-investigations`,path:`posthog.maxConcurrentInvestigations`,title:`Max concurrent investigations`,description:`Maximum investigation sessions running together.`,control:`number`,range:yc,unit:Yde,keywords:[`parallel`,`workers`],defaultValue:2,...X},{id:`posthog-min-users`,path:`posthog.minUsersToInvestigate`,title:`Min users to investigate`,description:`Minimum affected users for a new issue investigation. Regressions, worsening issues and eligible error spikes bypass this minimum.`,control:`number`,range:yc,unit:Y3,keywords:[`threshold`,`affected`],defaultValue:1,...X},{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,...X},{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,...X}]},{id:`lanes-team-review`,level:`lanes`,parent:n6,title:`Team review`,description:`Draft reviews of teammates' pull requests for you to post from the Reviews tab.`,legacyIds:[`team-review`,`reviews`],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,...X},{id:`github-teams`,path:`github.teams`,title:`GitHub teams`,description:`Teams to search for review requests and members, one org/slug per entry. Leave empty to fall back to the legacy teamReview.org and teamReview.team keys in config.json.`,control:`list`,keywords:[`github`,`teams`,`review requests`],defaultValue:[],listPlaceholder:`org/team-slug`,listEmptyText:`No GitHub teams configured.`,...X},{id:`team-review-re-review-after-hours`,path:`teamReview.reReviewAfterHours`,title:`Re-review after`,description:`When a reviewed PR has a new head, review it again after this long since its last review. Queue review runs it at any time.`,control:`number`,range:yc,unit:U3,keywords:[`review`,`delay`],defaultValue:24,integer:!1,step:.5,...X},{id:`team-review-skip-idle-after-days`,path:`teamReview.skipIdleAfterDays`,title:`Skip PRs idle for`,description:`Leave pull requests without GitHub activity for this long out of automatic review.`,control:`number`,range:yc,unit:W3,keywords:[`idle`,`activity`],defaultValue:14,integer:!1,step:.5,...X},{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:``,...X},{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,...X},{id:`team-review-keep-mergeable-enabled`,path:`teamReview.keepMergeableEnabled`,title:`Keep mergeable`,description:`Offer Keep mergeable on your pull requests: a guarded 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,...X},{id:`team-review-keep-mergeable-timeout`,path:`teamReview.keepMergeableTimeoutMinutes`,title:`Keep mergeable deadline`,description:`Longest a Keep mergeable repair session may run before it is stopped and nothing is pushed.`,control:`number`,range:Qc,unit:H3,keywords:[`timeout`,`repair`],defaultValue:30,...X},{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,...X}]},{id:`lanes-workflows`,level:`lanes`,parent:n6,title:`Workflows`,description:`Rules that act on pull request events in the repositories you choose.`,legacyIds:[`workflows`],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,...X},{id:`workflows-max-concurrent-sessions`,path:`workflows.maxConcurrentSessions`,title:`Concurrent agent sessions`,description:`Most workflow agent sessions running at once. Up to twenty later spawns wait for a free slot; additional spawns are dropped and logged.`,control:`number`,range:$c,unit:Xde,keywords:[`parallel`,`spawn`],defaultValue:2,...X},{id:`workflows-rules`,path:`status:workflow-rules`,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 guarded 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 under workflows.rules.`,control:`readonly`,keywords:[`pull requests`,`automation`,`github`,`rules`],status:`workflows`,...F3}]},{id:`lanes-factory`,level:`lanes`,parent:n6,title:`Factory`,description:`Read Coherence reports from repositories whose integration branch holds a coherence.config.json and show their status in the Factory tab.`,legacyIds:[`factory`],settings:[{id:`factory-enabled`,path:`factory.enabled`,title:`Enable the factory`,description:`Enable Coherence status polling and show the Factory tab. Off by default.`,control:`toggle`,keywords:[`orchestrator`,`intents`,`queue`,`coherence`,`guardrails`],defaultValue:!1,...X},{id:`factory-max-risk`,path:`factory.maxRisk`,title:`Worker risk ceiling`,description:`Highest risk admitted for a ticket.`,control:`select`,defaultValue:`medium`,options:[`low`,`medium`,`high`,`critical`].map(e=>({value:e,label:e})),keywords:[`risk`,`admission`],...X},{id:`factory-max-live-workers`,path:`factory.maxLiveWorkers`,title:`Live worker cap`,description:`Most live workers per factory project.`,control:`number`,range:vc,unit:Zde,defaultValue:2,keywords:[`workers`,`parallel`],...X},{id:`factory-checks`,path:`factory.checks`,title:`Worker checks`,description:`Commands glimmervoid runs before merging worker commits.`,control:`list`,defaultValue:[`npm run typecheck`,`npm run lint`,`npm test`],keywords:[`tests`,`checks`],listPlaceholder:`npm test`,listEmptyText:`No checks run before a merge.`,...X},{id:`factory-protected-paths`,path:`factory.protectedPaths`,title:`Protected paths`,description:`Repo-relative files, directory prefixes ending in /, or **/NAME basenames workers cannot change.`,control:`list`,defaultValue:[`coherence.config.json`,`.coherence/`,`package.json`,`package-lock.json`,`**/AGENTS.md`,`**/CLAUDE.md`,`**/CLAUDE.local.md`,`.claude/`,`.github/`],keywords:[`fence`,`scope`],listPlaceholder:`path, prefix/ or **/NAME`,listEmptyText:`Workers may change any path.`,...X},{id:`factory-reviewer-model`,path:`factory.reviewerModel`,title:`Reviewer model`,description:`Claude model for independent worker review. Blank uses the CLI default.`,control:`text`,defaultValue:null,nullable:!0,keywords:[`claude`,`review`],...X},{id:`factory-daily-budget`,path:`factory.dailyBudgetUsd`,title:`Factory daily budget`,description:`Factory lane spend ceiling. Blank means no ceiling. Needs usage tracking: with it off, dispatch refuses.`,control:`number`,range:bc,unit:J3,integer:!1,nullable:!0,step:.01,defaultValue:null,keywords:[`spend`,`budget`],...X},{id:`factory-verifier-model`,path:`factory.verifierModel`,title:`Verifier model`,description:`Claude model for independent intent verification. Blank uses the CLI default.`,control:`text`,nullable:!0,defaultValue:null,keywords:[`claude`,`verification`],...X},{id:`factory-mirror-harness-runs`,path:`factory.mirrorHarnessRuns`,title:`Mirror harness runs`,description:`Show the latest factory harness run as a read-only project in the Factory tab while it runs and for a day after. Needs factory.enabled on. The harness turns it off on the instance it boots.`,control:`toggle`,defaultValue:!0,keywords:[`harness`,`test`,`read-only`],...X}]},{id:`lanes-benchmarks`,level:`lanes`,parent:n6,title:`Benchmarks`,description:`Compare agent setups on frozen cases from the suites in the benchmarks folder of the Glimmervoid home.`,legacyIds:[`benchmarks`],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,...X}]},{id:`lanes-knowledge-graph`,level:`lanes`,parent:n6,title:`Knowledge graph (experimental)`,description:`A typed local graph of projects, tasks, notes, references and questions, driven from the glimmervoid kg command. Its SQLite database defaults to the Glimmervoid home; --db selects another path.`,legacyIds:[`knowledge-graph`],settings:[{id:`knowledge-graph-enabled`,path:`knowledgeGraph.enabled`,title:`Enable the knowledge graph`,description:`Allow the glimmervoid kg command. It reads Coherence ledgers to report where your tasks and the agents' tickets disagree, without modifying those ledgers. Graph writes go to the selected SQLite database, which can be inside a repository when --db names that path. Off by default.`,control:`toggle`,keywords:[`experimental`,`kg`,`tasks`,`notes`,`references`,`coherence`],defaultValue:!1,...X}]},{id:`lanes-change-map`,level:`lanes`,parent:n6,title:`Change map`,description:`Optional model narration for deterministic change facts.`,legacyIds:[`change-map`],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,...X},{id:`change-map-narrator-engine`,path:`changeMap.narrator.engine`,title:`Narrator engine`,description:`CLI used to generate change map claims.`,control:`select`,options:r6(Ll),keywords:[`claude`,`codex`],defaultValue:`claude`,...X},{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:``,...X}]},{id:`machine-privacy`,level:`machine`,title:`Privacy`,description:`What Glimmervoid sends about itself.`,legacyIds:[`privacy`,`telemetry`],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, per session token counts, models and estimated costs from the usage scan, and factory outcomes as the kind of decision, how it came out, its duration and attempt number, under a random install id. Never error messages, paths, repository or branch names, prompts, objectives 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,...X}]},{id:`browser-shortcuts`,level:`browser`,title:`Shortcuts and about`,description:`Keyboard reference and build information.`,legacyIds:[`shortcuts`],settings:[]}]),ife=Object.freeze([{id:`file-debug-mode`,path:`debugMode`,title:`Debug mode`,group:`machine-sessions`,description:`Show session-card diagnostics for state, transitions and detection signals.`,control:`toggle`,keywords:[`diagnostics`,`state`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q3,...Z},{id:`file-replay-buffer`,path:`replayBufferKB`,title:`Replay buffer`,group:`machine-terminal`,description:`PTY output retained for clients that reconnect or join late.`,control:`number`,range:Tc,unit:{label:`KB`,storedPerDisplay:1},keywords:[`history`,`backfill`],defaultValue:512,takesEffect:`new-sessions`,fileOnlyReason:Q,...Z},{id:`file-session-memory-reserve`,path:`sessionMemoryReserveMB`,title:`Session memory reserve`,group:`machine-sessions`,description:`Free memory an automatic session start waits for; 0 starts sessions without checking.`,control:`number`,range:Ec,unit:{label:`MB`,storedPerDisplay:1},keywords:[`memory`,`headroom`],defaultValue:600,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-check-memory-reserve`,path:`checkMemoryReserveMB`,title:`Check run memory reserve`,group:`machine-sessions`,description:`Free memory a factory check run waits for; 0 runs checks without checking.`,control:`number`,range:Ec,unit:{label:`MB`,storedPerDisplay:1},keywords:[`memory`,`factory`],defaultValue:1500,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-cursor-blink`,path:`cursorBlink`,title:`Cursor blink`,group:`machine-terminal`,description:`Blink the cursor in every terminal.`,control:`toggle`,keywords:[`caret`,`terminal`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-detect-background-agents`,path:`detectBackgroundAgents`,title:`Detect background agents`,group:`machine-detection-sessions`,description:`Hold completion while tracked background work is active.`,control:`toggle`,keywords:[`subagents`,`completion`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:Q3,...Z},{id:`file-record-signals`,path:`recordSignals`,title:`Record structural signals`,group:`machine-detection-sessions`,description:`Keep forensic status and hook recordings for each session. Full capture (capture.enabled) records these signals even when this is off.`,control:`toggle`,keywords:[`recordings`,`diagnostics`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:Q3,...Z},{id:`file-trace-enabled`,path:`trace.enabled`,title:`Capture session traces`,group:`machine-detection-sessions`,description:`Keep normalized Claude transcript traces for session debugging.`,control:`toggle`,keywords:[`transcripts`,`diagnostics`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:Q3,...Z},{id:`file-detect-scheduled-wakeups`,path:`detectScheduledWakeups`,title:`Detect scheduled wakeups`,group:`machine-detection-sessions`,description:`Surface advisory wakeup timing for scheduled sessions.`,control:`toggle`,keywords:[`schedule`,`sleep`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:Q3,...Z},{id:`file-worktree-auto-rebase`,path:`worktreeAutoRebase`,title:`Worktree auto-rebase`,group:`machine-detection-sessions`,description:`Rebase eligible session worktrees when the integration branch moves.`,control:`toggle`,keywords:[`git`,`branch`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:$3,...Z},{id:`file-worktree-sync-on-start`,path:`worktreeSyncOnStart`,title:`Worktree sync on start`,group:`machine-detection-sessions`,description:`Fetch origin and fast-forward the local integration branch before a session starts its worktree.`,control:`toggle`,keywords:[`git`,`fetch`,`fast-forward`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:$3,...Z},{id:`file-worktree-rerere`,path:`worktreeRerere`,title:`Worktree rerere`,group:`machine-detection-sessions`,description:`Reuse recorded Git conflict resolutions.`,control:`toggle`,keywords:[`git`,`conflicts`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:$3,...Z},{id:`file-integration-branch`,path:`integrationBranch`,title:`Integration branch`,group:`machine-detection-sessions`,description:`Base branch for session worktrees. Empty = each repo's default branch. Existing sessions are never retargeted.`,control:`text`,nullable:!0,keywords:[`git`,`merge`],defaultValue:null,takesEffect:`new-sessions`,fileOnlyReason:$3,...Z},{id:`file-worktree-root`,path:`worktreeRoot`,title:`Worktree root`,group:`machine-detection-sessions`,description:`Directory that contains session worktrees. Existing worktrees are never relocated.`,control:`text`,keywords:[`git`,`directory`],defaultValue:``,takesEffect:`new-sessions`,fileOnlyReason:$3,...Z},{id:`file-worktree-share`,path:`worktreeShare`,title:`Shared worktree paths`,group:`machine-detection-sessions`,description:`Local paths copied or linked during worktree preparation.`,control:`list`,keywords:[`files`,`context`],defaultValue:[`node_modules`,`.env`,`.env.local`,`.claude`],takesEffect:`new-sessions`,fileOnlyReason:t6,...Z},{id:`file-port`,path:`port`,title:`Local port`,group:`machine-detection-sessions`,description:`Port used by the local dashboard listener.`,control:`number`,range:Dc,unit:{label:`port`,storedPerDisplay:1},keywords:[`server`,`listener`],defaultValue:3e3,takesEffect:`restart`,fileOnlyReason:t6,...Z},{id:`file-notify-debounce-ms`,path:`notifyDebounceMs`,title:`Notification debounce`,group:`machine-detection-sessions`,description:`Delay used to coalesce notification state changes.`,control:`number`,integer:!1,step:`any`,range:yc,unit:G3,keywords:[`timer`,`alerts`],defaultValue:3e3,takesEffect:`new-sessions`,fileOnlyReason:Q,...Z},{id:`file-phone-escalation-ms`,path:`phoneEscalationMs`,title:`Phone escalation delay`,group:`machine-detection-sessions`,description:`Delay before off-dashboard escalation.`,control:`number`,integer:!1,step:`any`,range:yc,unit:K3,keywords:[`timer`,`telegram`],defaultValue:3e5,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-post-turn-checks`,path:`postTurnChecks`,title:`Post-turn checks`,group:`machine-detection-sessions`,description:`Deterministic checks run after eligible turns. The global mode is a default; project and individual rule modes can select fixes even when the global mode is report.`,control:`json`,keywords:[`quality`,`fixes`],defaultValue:{enabled:!0,mode:`report`,rules:{trailingWs:!0,finalNewline:!0,bom:!0,slop:!1}},takesEffect:`now`,fileOnlyReason:e6,...Z},{id:`file-branch-gc-enabled`,path:`branchGc.enabled`,title:`Branch cleanup`,group:`machine-detection-sessions`,description:`Enable cleanup of eligible session branches.`,control:`toggle`,keywords:[`git`,`cleanup`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:$3,...Z},{id:`file-branch-gc-worktrees`,path:`branchGc.worktrees`,title:`Local worktree cleanup`,group:`machine-detection-sessions`,description:`Enable cleanup of eligible local worktrees.`,control:`toggle`,keywords:[`git`,`worktree`,`cleanup`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:$3,...Z},{id:`file-branch-gc-prefixes`,path:`branchGc.prefixes`,title:`Branch cleanup prefixes`,group:`machine-detection-sessions`,description:`Branch prefixes that filter both remote branch cleanup and local worktree cleanup.`,control:`list`,keywords:[`git`,`branch`],defaultValue:[`glimmervoid/session/`,`worktree-agent-`],takesEffect:`now`,fileOnlyReason:$3,...Z},{id:`file-branch-gc-dry-run`,path:`branchGc.dryRun`,title:`Branch cleanup dry run`,group:`machine-detection-sessions`,description:`Report planned cleanup without deleting remote branches.`,control:`toggle`,keywords:[`git`,`safety`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:$3,...Z},{id:`file-branch-gc-stale-days`,path:`branchGc.staleDays`,title:`Branch stale days`,group:`machine-detection-sessions`,description:`Age threshold for orphan branch cleanup when unmerged deletion is on.`,control:`number`,integer:!1,step:`any`,range:yc,unit:W3,keywords:[`git`,`retention`],defaultValue:14,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-branch-gc-interval-ms`,path:`branchGc.intervalMs`,title:`Branch cleanup interval`,group:`machine-detection-sessions`,description:`Delay between branch cleanup passes.`,control:`number`,integer:!1,step:`any`,range:yc,unit:efe,keywords:[`git`,`schedule`],defaultValue:216e5,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-custom-agents`,path:`customAgents`,title:`Custom agents`,group:`machine-detection-sessions`,description:`Extra agent CLIs a session can be spawned with. The Sessions section lists the declared agents and whether each command resolves.`,control:`json`,keywords:[`adapters`,`cli`],defaultValue:[],takesEffect:`new-sessions`,fileOnlyReason:t6,...Z},{id:`file-task-title-refiner-enabled`,path:`taskTitle.refiner.enabled`,title:`Refine task titles`,group:`machine-detection-sessions`,description:`Keep session card titles useful when prompts change topic by asking a model for a short title.`,control:`toggle`,keywords:[`title`,`refiner`,`card`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-task-title-refiner-model`,path:`taskTitle.refiner.model`,title:`Task title model`,group:`machine-detection-sessions`,description:`Claude model alias the title refiner asks.`,control:`text`,keywords:[`title`,`refiner`,`model`],defaultValue:`haiku`,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-task-title-refiner-min-interval`,path:`taskTitle.refiner.minIntervalSeconds`,title:`Task title refresh interval`,group:`machine-detection-sessions`,description:`Shortest pause between two title refinements of one session.`,control:`number`,integer:!1,step:`any`,range:bc,unit:V3,keywords:[`title`,`refiner`,`interval`],defaultValue:60,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-task-title-refiner-timeout`,path:`taskTitle.refiner.timeoutSeconds`,title:`Task title timeout`,group:`machine-detection-sessions`,description:`Maximum time allowed for one title refinement.`,control:`number`,integer:!1,step:`any`,range:Oc,unit:V3,keywords:[`title`,`refiner`,`deadline`],defaultValue:60,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-codex`,path:`usage.vendors.codex`,title:`Track Codex usage`,group:`machine-usage`,description:`Include local Codex CLI transcripts in usage reports.`,control:`toggle`,keywords:[`openai`,`vendor`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-grok`,path:`usage.vendors.grok`,title:`Track Grok usage`,group:`machine-usage`,description:`Include local Grok CLI transcripts in usage reports.`,control:`toggle`,keywords:[`xai`,`vendor`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-fetch-pricing`,path:`usage.fetchPricing`,title:`Fetch current model prices`,group:`machine-usage`,description:`Load public model prices when usage tracking starts, using a cached table for up to one day. Falls back to cached or bundled prices if the fetch fails; no daily refresh runs while tracking continues.`,control:`toggle`,keywords:[`rates`,`models`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:Q,...Z},{id:`file-usage-plan-limits`,path:`usage.planLimits`,title:`Show plan limits`,group:`machine-usage`,description:`Read the Claude plan limit the CLI reports and show it beside usage.`,control:`toggle`,keywords:[`plan`,`limits`,`quota`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-rtk-savings`,path:`usage.rtkSavings`,title:`Estimate rtk savings`,group:`machine-usage`,description:`Estimate the tokens rtk output compression saved and show it in the Usage view.`,control:`toggle`,keywords:[`rtk`,`savings`,`tokens`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-scan-interval`,path:`usage.scanIntervalMinutes`,title:`Scan interval`,group:`machine-usage`,description:`Periodic transcript polling interval. Session activity can also trigger scans between timer ticks.`,control:`number`,range:Gc,unit:H3,keywords:[`poll`,`refresh`],defaultValue:5,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-warehouse-retain-days`,path:`usage.warehouseRetainDays`,title:`Retain usage history`,group:`machine-usage`,description:`How long the daily usage warehouse keeps rolled-up totals after transcript detail expires.`,control:`number`,range:Xc.warehouseRetainDays,unit:W3,keywords:[`history`,`warehouse`,`retention`],defaultValue:365,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-session-block-hours`,path:`usage.sessionBlockHours`,title:`Session block length`,group:`machine-usage`,description:`Length of the rolling block the Usage view groups activity into.`,control:`number`,range:Xc.sessionBlockHours,unit:U3,keywords:[`block`,`window`,`hours`],defaultValue:5,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-cost-mode`,path:`usage.costMode`,title:`Cost mode`,group:`machine-usage`,description:`Choose whether recorded costs, calculated costs or both can appear.`,control:`select`,options:r6(nl),keywords:[`pricing`,`estimate`],defaultValue:`auto`,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-extra-projects-dirs`,path:`usage.extraProjectsDirs`,title:`Extra transcript folders`,group:`machine-usage`,description:`Absolute paths of additional Claude projects folders the usage scan reads.`,control:`list`,keywords:[`transcripts`,`folders`,`scan`],defaultValue:[],takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-change-map-narrator-timeout`,path:`changeMap.narrator.timeoutSeconds`,title:`Narrator timeout`,group:`lanes-change-map`,description:`Maximum time allowed for one narration.`,control:`number`,range:Zc,unit:V3,keywords:[`deadline`,`narration`],defaultValue:90,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-visions-quiet-delay`,path:`visions.dispatch.quietMs`,title:`Quiet delay`,group:`lanes-visions`,description:`Editor quiet time before a scheduled review. Saves and blank-line boundaries can dispatch immediately, subject to the other review limits.`,control:`number`,range:yc,unit:G3,keywords:[`debounce`,`idle`],defaultValue:3e4,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-visions-cooldown`,path:`visions.dispatch.cooldownMs`,title:`Cooldown`,group:`lanes-visions`,description:`Minimum delay between reviews of the same document. Initial orientation reviews bypass this delay.`,control:`number`,range:yc,unit:K3,keywords:[`rate limit`,`delay`],defaultValue:3e5,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-visions-activity-max-per-hour`,path:`visions.dispatch.activityMaxPerHour`,title:`Activity max per hour`,group:`lanes-visions`,description:`Maximum activity-driven reviews dispatched per hour, capped at the overall hourly limit minus one to reserve an edit-review slot.`,control:`number`,range:bc,unit:X3,keywords:[`rate limit`,`events`],defaultValue:2,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-visions-dispatch-timeout`,path:`visions.dispatch.dispatchTimeoutSeconds`,title:`Dispatch timeout`,group:`lanes-visions`,description:`Maximum time allowed for one review session.`,control:`number`,range:yc,unit:q3,keywords:[`deadline`,`review`],defaultValue:180,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-visions-intent-thread-ttl`,path:`visions.intent.threadTtlMs`,title:`Intent thread lifetime`,group:`lanes-visions`,description:`How long an intent thread nobody advanced stays live before it retires.`,control:`number`,range:yc,unit:nfe,keywords:[`intent`,`decay`,`thread`],defaultValue:2592e5,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-ingest-terminal`,path:`ingest.sources.terminal.enabled`,title:`Terminal output source`,group:`lanes-ingest`,description:`Include terminal output in the ingest feed.`,control:`toggle`,keywords:[`pty`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-ingest-agent-logs`,path:`ingest.sources.agentLogs.enabled`,title:`Agent logs source`,group:`lanes-ingest`,description:`Include local agent logs in the ingest feed.`,control:`toggle`,keywords:[`transcript`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-ingest-git`,path:`ingest.sources.git.enabled`,title:`Git activity source`,group:`lanes-ingest`,description:`Include local Git activity in the ingest feed.`,control:`toggle`,keywords:[`commits`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-ingest-fs`,path:`ingest.sources.fs.enabled`,title:`File changes source`,group:`lanes-ingest`,description:`Include watched file changes in the ingest feed.`,control:`toggle`,keywords:[`filesystem`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-ingest-shell-history`,path:`ingest.sources.shellHistory.enabled`,title:`Shell history source`,group:`lanes-ingest`,description:`Include local shell history in the ingest feed.`,control:`toggle`,keywords:[`commands`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-ingest-editor`,path:`ingest.sources.editor.enabled`,title:`Editor events source`,group:`lanes-ingest`,description:`Include local editor events in the ingest feed.`,control:`toggle`,keywords:[`buffers`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-investigation-timeout`,path:`posthog.investigationTimeoutSeconds`,title:`Investigation timeout`,group:`lanes-posthog`,description:`Maximum time allowed for one investigation.`,control:`number`,integer:!1,step:`any`,range:yc,unit:q3,keywords:[`deadline`,`session`],defaultValue:900,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-escalation`,path:`posthog.userEscalationThreshold`,title:`Escalation threshold`,group:`lanes-posthog`,description:`Affected-user count that escalates an issue.`,control:`number`,range:yc,unit:Y3,keywords:[`threshold`,`severity`],defaultValue:25,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-fix-timeout`,path:`posthog.fixTimeoutSeconds`,title:`Fix timeout`,group:`lanes-posthog`,description:`Maximum time allowed for one fix session.`,control:`number`,integer:!1,step:`any`,range:Bc,unit:q3,keywords:[`deadline`,`repair`],defaultValue:1800,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-traffic-multiplier`,path:`posthog.trafficSpikeMultiplier`,title:`Spike multiplier`,group:`lanes-posthog`,description:`Baseline multiplier required to classify a traffic spike.`,control:`number`,integer:!1,step:`any`,range:Vc,unit:Z3,keywords:[`baseline`,`ratio`],defaultValue:3,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-traffic-min-users`,path:`posthog.trafficSpikeMinUsers`,title:`Min users to alert`,group:`lanes-posthog`,description:`Minimum recent unique users for an initial traffic-spike alert. Escalation and recovery alerts bypass this minimum.`,control:`number`,range:Hc,unit:Y3,keywords:[`threshold`,`analytics`],defaultValue:10,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-traffic-cooldown`,path:`posthog.trafficSpikeCooldownMinutes`,title:`Spike cooldown`,group:`lanes-posthog`,description:`Cooldown for new traffic spikes. Escalation and recovery alerts bypass it. Zero removes the time delay; repeated active-spike alerts are still suppressed.`,control:`number`,integer:!1,step:`any`,range:bc,unit:tfe,keywords:[`silence`,`delay`],defaultValue:360,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-traffic-baseline`,path:`posthog.trafficSpikeBaselineDays`,title:`Baseline window`,group:`lanes-posthog`,description:`Historical window used to calculate normal hourly traffic.`,control:`number`,range:Wc,unit:W3,keywords:[`history`,`analytics`],defaultValue:7,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-recurrence-dedupe`,path:`posthog.recurrenceDedupe`,title:`Deduplicate recurring issues`,group:`lanes-posthog`,description:`Treat an issue seen again inside the recurrence window as the same investigation instead of opening a new one.`,control:`toggle`,keywords:[`recurrence`,`dedupe`,`issues`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-recurrence-window-days`,path:`posthog.recurrenceWindowDays`,title:`Recurrence window`,group:`lanes-posthog`,description:`How far back an issue counts as a recurrence of an investigated one.`,control:`number`,integer:!1,step:`any`,range:yc,unit:W3,keywords:[`recurrence`,`window`],defaultValue:7,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-transient-recurrence-limit`,path:`posthog.transientRecurrenceLimit`,title:`Transient recurrence limit`,group:`lanes-posthog`,description:`How many times a transient issue may recur before it is investigated again.`,control:`number`,integer:!1,step:`any`,range:yc,unit:Qde,keywords:[`recurrence`,`transient`,`limit`],defaultValue:3,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-repo-path`,path:`posthog.repoPath`,title:`Repository path`,group:`lanes-posthog`,description:`Absolute path of the local checkout investigations read and fixes branch from, for every project the project map does not name.`,control:`text`,keywords:[`repository`,`checkout`,`path`],defaultValue:``,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-project-map`,path:`posthog.projectMap`,title:`Project map`,group:`lanes-posthog`,description:`PostHog project id to a label: the name shown for that project, and, when it is an absolute path to a checkout, the repository its issues are investigated in.`,control:`json`,keywords:[`projects`,`repositories`,`map`],defaultValue:{},takesEffect:`now`,fileOnlyReason:e6,...Z},{id:`file-team-review-org`,path:`teamReview.org`,title:`GitHub organization (legacy)`,group:`lanes-team-review`,description:`Organization login that owns the team, for example PostHog. Read only when github.teams is empty.`,control:`text`,keywords:[`github`,`owner`,`legacy`],defaultValue:``,takesEffect:`now`,fileOnlyReason:`A legacy key: github.teams names teams as org/slug entries and wins whenever it is set.`,...Z},{id:`file-team-review-team`,path:`teamReview.team`,title:`GitHub team (legacy)`,group:`lanes-team-review`,description:`Team slug whose members and review requests are polled. Read only when github.teams is empty.`,control:`text`,keywords:[`github`,`slug`,`legacy`],defaultValue:``,takesEffect:`now`,fileOnlyReason:`A legacy key: github.teams names teams as org/slug entries and wins whenever it is set.`,...Z},{id:`file-workflows-max-actions-per-poll`,path:`workflows.maxActionsPerPoll`,title:`Actions per poll`,group:`lanes-workflows`,description:`Most actions run in one poll. The rest are dropped and logged.`,control:`number`,range:el,unit:$de,keywords:[`cap`,`rate limit`],defaultValue:20,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-workflows-rules`,path:`workflows.rules`,title:`Workflow rule definitions`,group:`lanes-workflows`,description:`The rules the Workflows section switches on and off: each names its repositories, one pull request event, its filters and its actions.`,control:`json`,keywords:[`pull requests`,`automation`,`rules`],defaultValue:[],takesEffect:`now`,fileOnlyReason:`Rule definitions are written in config.json; the Workflows section only switches each rule on or off.`,...Z}]),a6=Object.freeze({sections:i6,fileOnly:ife}),afe=Object.freeze(Object.fromEntries(i6.flatMap(e=>(e.legacyIds??[]).map(t=>[t,e.id])))),ofe=Object.freeze(i6.reduce((e,t)=>{for(let n of t.settings)for(let r of n.legacyIds??[])e[r.sectionId]={...e[r.sectionId],[r.settingId]:t.id};return e},{}));function o6(e){let t=[],n=e=>{if(!e||typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};return t.push([e,n]),n},r=n(e);for(let e=t.pop();e;e=t.pop()){let[t,r]=e;for(let[e,i]of Object.entries(t))Object.defineProperty(r,e,{value:n(i),writable:!0,enumerable:!0,configurable:!0})}return r}function s6(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function sfe(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 c6(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)]=o6(n)}function l6(e){return e.flatMap(e=>e.settings)}function u6(e){return e.access===`file-only`||e.control===`readonly`}function cfe(e){let t=String(e??``).trim().toLowerCase();if(!t||t===`all`)return`all`;if(t===`none`)return[];let n=t.split(`,`).map(e=>e.trim());return n.every(e=>/^\d+$/.test(e)&&Number.isSafeInteger(Number(e))&&Number(e)>0)?n.map(Number):null}var lfe=6;function d6(e,t){return e.control===`number`&&typeof t==`number`?t/(e.unit?.storedPerDisplay??1):e.valueKind===`posthog-projects`?Array.isArray(t)?t.length===0?[`none`]:t.map(String):[]:o6(t)}function f6(e){return e.control===`number`&&(e.unit?.storedPerDisplay??1)!==1}function p6(e){return String(Number(e.toFixed(lfe)))}function m6(e,t){let n=d6(e,t);return e.valueKind===`posthog-projects`&&Array.isArray(n)?n.join(`, `)||`all`:typeof n==`number`&&e.unit?`${p6(n)} ${e.unit.label}`:JSON.stringify(n??null)}function h6(e,t){if(e.control===`number`){if(e.nullable&&(t==null||String(t).trim()===``))return null;let n=Number(t);if(e.zeroIsNull&&n<=0)return null;let r=n*(e.unit?.storedPerDisplay??1);return e.integer===!1?r:Math.round(r)}if(e.valueKind===`posthog-projects`)return cfe(Array.isArray(t)?t.join(`,`):t);if(e.control===`text`||e.control===`password`){let n=String(t??``).trim();return e.nullable&&!n?null:n}return o6(t)}function g6(e){return String(e||``).toLowerCase().match(/[a-z0-9]+/g)||[]}var ufe=3,dfe=2,ffe=1,pfe=3,mfe=30,hfe=16;function _6(e,t){return e===t?ufe:e.startsWith(t)?dfe:t.length>=pfe&&e.includes(t)?ffe:0}function v6(e,t,n){let r=0;for(let n of t){let t=Math.max(0,...e.map(e=>_6(e,n)));if(t===0)return 0;r+=t}return r*n}function y6(e){return e.options?.map(e=>e.label).join(`, `)??``}function b6(e){return w6(e.group??``)?.title??``}function x6(e,t,n){let r=v6(g6(e.title),n,1e3),i=v6(g6(e.keywords.join(` `)),n,100),a=v6(t,n,10),o=v6(g6(e.path),n,10),s=v6(g6(y6(e)),n,10),c=v6(g6(e.description),n,1);return r+i+a+o+s+c}function S6(e){return e.section?.title??``}function gfe(e,t){return Number(e.section===null)-Number(t.section===null)}function C6(e,t,n){return[[`title`,e.title],[`keywords`,e.keywords.join(` `)],[`section`,t?.title??b6(e)],[`description`,e.description],[`path`,e.path],[`options`,y6(e)]].flatMap(([e,t])=>{let r=[];for(let e of t.matchAll(/[a-z0-9]+/gi)){let t=e[0].toLowerCase();for(let i of n){if(_6(t,i)===0)continue;let n=e.index+t.indexOf(i);r.push({start:n,end:n+i.length})}}let i=[];for(let e of r.sort((e,t)=>e.start-t.start||e.end-t.end)){let t=i.at(-1);t&&e.start<=t.end?t.end=Math.max(t.end,e.end):i.push({...e})}return i.length?[{field:e,text:t,spans:i}]:[]})}function _fe(e,t,n=[]){let r=g6(t).slice(0,hfe);if(r.length===0)return[];let i=[];for(let t of e){let e=g6(t.title);for(let n of t.settings){let a=x6(n,e,r);a!==0&&i.push({section:t,setting:n,score:a,matches:C6(n,t,r)})}}for(let e of n){let t=x6(e,g6(b6(e)),r);t!==0&&i.push({section:null,setting:e,score:t,matches:C6(e,null,r)})}return i.sort((e,t)=>t.score-e.score||gfe(e,t)||S6(e).localeCompare(S6(t))||e.setting.title.localeCompare(t.setting.title)).slice(0,mfe)}function vfe(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=n[a]||a,c=(o?r[s]?.[o]:void 0)||s,l=t.find(e=>e.id===c);if(!l)return null;let u=o?l.settings.find(e=>e.id===o||e.legacyIds?.some(e=>e.settingId===o&&e.sectionId===s)):null;return o&&!u?null:{sectionId:c,settingId:u?.id||null,hash:`#settings/${c}${u?`/${u.id}`:``}`}}function yfe(e){let t=new Map,n=new Map;for(let r of[...l6(e.sections),...e.fileOnly])t.set(r.id,r),n.set(r.path,r);return{byId:t,byPath:n}}yfe(a6);function w6(e,t=a6){let n=t.sections.find(t=>t.id===e);return n?{title:n.title,description:n.description}:rfe[e]??null}function bfe({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}function T6(e,t){let n=new Set(e.map(e=>e.id)),r=[...new Set(t)].filter(e=>!n.has(e));return[...e,...r.map(e=>({id:e,name:`Unavailable project (${e})`}))]}var E6=new WeakMap,xfe=`Configured`,D6=`•`.repeat(12),Sfe=`Each line must be a positive whole-number PostHog project id, or the one word none.`,Cfe=3,wfe=200,Tfe=new Set([`customAgents`]),Efe=1e-9,Dfe=Object.freeze({now:`Applies now`,"new-sessions":`New sessions`,restart:`After restart`}),Ofe=Object.freeze({browser:`This browser`,machine:`This machine`});function O6(e,t){let n=t.secretSources;if(!n||typeof n!=`object`)return null;let r=n[e.path];return typeof r==`string`?r:null}function kfe(e){let t=e.rtkInstall;return t?.status===`installing`?`No rtk binary found. Glimmervoid is installing it into ~/.glimmervoid/bin now.`:e.rtkInstallSupported===!1?`No rtk binary found. Automatic installation is unavailable on this server platform; install a compatible binary manually.`:t?.status===`failed`?`No rtk binary found. The last install attempt failed: ${t.reason||`unknown reason`}. A save can retry after the ten-minute failure cooldown; saves during the cooldown skip installation.`:`No rtk binary found. Saving requests installation into ~/.glimmervoid/bin on supported server platforms, subject to installer eligibility.`}function k6(e){return e.control===`password`}function A6(e){return`${e.path}${xfe}`}function j6(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)=>j6(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)&&j6(e[n],t[n]))}function M6(e){return E6.get(e)||null}function N6(e){return Array.isArray(e)?e.map(e=>String(e)):[]}function Afe(e){return e.split(`
273
+ `).map(e=>e.trim()).filter(e=>e!==``)}function P6(e){let t=e.range;if(!t)return null;let n={min:Number(d6(e,t.min))};return t.max!=null&&(n.max=Number(d6(e,t.max))),t.exclusiveMin&&(n.exclusiveMin=!0),n}function jfe(e){let t=`Default ${m6(e,e.defaultValue)}`;return f6(e)?`${t}, stored as ${JSON.stringify(e.defaultValue)} ${e.unit?.storedLabel??``}`.trimEnd():t}function Mfe(e,t){let n=jfe(e),r=Tfe.has(e.path)?void 0:s6(t,e.path);if(r===void 0)return{currentText:null,defaultText:n,jsonFragment:null};let i={};return c6(i,e.path,r),{currentText:`Current ${m6(e,r)}`,defaultText:n,jsonFragment:JSON.stringify(i,null,2)}}function Nfe(e,t,n){let r=t??e.find(e=>e.id===n.group);if(!r)return w6(n.group??``)?.title??`config.json`;let i=e.find(e=>e.id===r.parent);return i?`${i.title} / ${r.title}`:r.title}function F6(e){let t=/^#settings(?:\?(.*))?$/.exec(String(e??``));if(!t)return null;let n=new URLSearchParams(t[1]??``).get(`q`)??``;return{query:Array.from(n.trim()).slice(0,wfe).join(``).trim()}}function Pfe(e,t){return e.filter(e=>e.parent===t)}function I6(e,t){let n=e.find(e=>e.id===t);return n?n.parent?e.find(e=>e.id===n.parent)??n:n:null}function Ffe(e){return e.filter(e=>!e.parent)}function Ife(e,t,n,r){return r?`hidden`:n.trim()?`search`:t&&I6(e,t)?`section`:`list`}function Lfe(e,t={}){let n={};for(let r of l6(e)){if(u6(r))continue;if(r.path.startsWith(`pref:`)){let e=r.path.slice(5),i=t.prefs?.[e]??t[r.path];n[r.path]=d6(r,i??r.defaultValue);continue}if(k6(r)){let e=s6(t,A6(r))===!0;n[r.path]=e?D6:``;continue}let e=s6(t,r.path);n[r.path]=d6(r,e??r.defaultValue)}return E6.set(n,o6(t)),n}function Rfe(e,t,n){let r=l6(e).filter(e=>u6(e)||e.path.startsWith(`pref:`)||O6(e,M6(t)||{})||k6(e)&&n[e.path]===D6?!1:!j6(t[e.path],n[e.path]));if(r.length===0)return{};let i=M6(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]=h6(e,n[e.path]);continue}if(!s.has(r)){let e=i[r];o[r]=e&&typeof e==`object`&&!Array.isArray(e)?o6(e):{},s.add(r)}let c=h6(e,n[e.path]);if(e.control===`projects`){let n=t[e.path];c=bfe({checked:Array.isArray(c)?c:[],stored:Array.isArray(n)?n:[],rendered:T6(a.map(e=>({id:e,name:e})),Array.isArray(n)?n:[]).map(e=>e.id)})}c6(o,e.path,c)}for(let t of l6(e))k6(t)&&sfe(o,A6(t));return delete o.secretSources,o}function zfe(e,t,n,r){return spe(Rfe(e,t,{...t,[n.path]:r}))}function Bfe(e){let t=e.unit?.label;return t?` of ${t}`:``}function L6(e){let t=P6(e);if(!t)return`Allowed range is unavailable.`;let n=`${e.integer!==!1&&!f6(e)?`whole number`:`number`}${Bfe(e)}`;return t.exclusiveMin&&t.min===0?`Must be a positive ${n}.`:t.max==null?`Must be a ${n} ${t.exclusiveMin?`above`:`of at least`} ${p6(t.min)}.`:`Must be a ${n} between ${p6(t.min)} and ${p6(t.max)}.`}function Vfe(e){return`Must be a multiple of ${m6(e,1)}.`}function Hfe(e){return Math.abs(e-Math.round(e))<Efe&&Number.isSafeInteger(Math.round(e))}function Ufe(e,t){return Number(h6({...e,integer:!1,nullable:!1,zeroIsNull:!1},t))}function R6(e,t){if(e.nullable&&(t==null||String(t).trim()===``))return null;let n=e.range;if(!n)return`Allowed range is unavailable.`;if(t==null||String(t).trim()===``)return L6(e);let r=Number(t);if(!Number.isFinite(r))return L6(e);if(e.zeroIsNull&&r<=0)return null;let i=Ufe(e,r);if(e.integer!==!1&&!Hfe(i))return f6(e)?Vfe(e):L6(e);let a=Number(h6(e,r));return n.exclusiveMin&&a<=n.min||!n.exclusiveMin&&a<n.min||n.max!=null&&a>n.max?L6(e):null}function Wfe(e,t,n=!1){return n?L6(e):R6(e,t.trim())}function Gfe(e,t){let n=t.trim();if(e.nullable&&n===``)return null;let r=Number(n);return e.zeroIsNull&&r<=0?null:r}function z6(e){if(e==null||e===``)return``;let t=Number(e);return Number.isFinite(t)?p6(t):String(e)}function Kfe(e,t){return Array.isArray(t)?e.valueKind===`posthog-projects`&&h6(e,t)===null?Sfe:null:`Must be a list.`}function qfe(e,t){let n={};for(let r of l6(e)){if(u6(r))continue;let e=null;r.control===`number`&&(e=R6(r,t[r.path])),r.control===`list`&&(e=Kfe(r,t[r.path])),r.control===`select`&&r.options&&!r.options.some(e=>e.value===t[r.path])&&(e=`Choose one of the available options.`),e&&(n[r.id]=e)}return Jfe(l6(e),t,n),n}function Jfe(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=t[r.path],o=t[i.path];Number(h6(r,a))>Number(h6(i,o))&&(n[r.id]=`Minimum must not exceed the maximum (${z6(o)}).`,n[i.id]=`Maximum must not be below the minimum (${z6(a)}).`)}}function Yfe(e,t){return l6(e).find(e=>e.id===t.maximumSettingId||e.maximumSettingId===t.id)}function Xfe(e,t,n){let r=Yfe(e,t);return qfe([{id:`scoped`,level:`machine`,title:``,description:``,settings:r?[t,r]:[t]}],n)[t.id]??null}function Zfe(e,t){return e.control===`number`?Gfe(e,t):e.control===`list`?Afe(t):t}function Qfe(e,t){return h6(e,e.control===`list`?N6(t):t)}function B6(e){return e?.isDirty===!0}function $fe(e,t,n,r,i,a=!1){if(!B6(n))return{kind:`unchanged`};let o=t.control===`number`?Wfe(t,r,a):null;if(o)return{kind:`invalid`,error:o};let s=Zfe(t,r);if(j6(h6(t,s),Qfe(t,n.base)))return{kind:`unchanged`};let c=Xfe(e,t,{...i,[t.path]:s});return c?{kind:`invalid`,error:c}:{kind:`changed`,value:s}}function V6(e){return k6(e)?``:d6(e,e.defaultValue)}function epe(e,t){return j6(t,V6(e))}function tpe(e){return e.presentation?e.presentation:(e.options?.length??0)<=Cfe?`segmented`:`select`}function npe(e){return Array.isArray(e)?e.length>0:typeof e==`string`?e.trim()!==``:e===!0}function H6(e,t){return e.danger===!0&&!!e.warning&&npe(t)}function U6(e,t){return H6(e,t)}function rpe(e){return e.title.charAt(0).toLowerCase()+e.title.slice(1)}function ipe(e){return k6(e)?`Reset removes the stored ${rpe(e)}. Anything that relies on it stops until a new one is saved.`:U6(e,V6(e))?e.warning??``:null}function W6(e){return[e.repos.join(`, `),e.trigger,e.actions.map(e=>e.type).join(`, `)].join(` `)}function ape(e){if(e==null)return[`No rules. Add workflows.rules to config.json.`];let t=Tl.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`,W6(e)].join(` `)):[`The workflows block is invalid, so no rule runs: ${t.error.issues[0]?.message??`unknown problem`}`]}function ope(e){let t=Tl.safeParse(e??{});return t.success?t.data.rules.map(e=>({id:e.id,name:e.name,isEnabled:e.enabled,summary:W6(e)})):[]}function spe(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`))}}var G6={ready:{label:`Ready`,meaning:`Ready to merge, or nothing left for you to do.`},passed:{label:`Passed`,meaning:`Checks passing, approved, or nothing open.`},failed:{label:`Failed`,meaning:`Checks failing, an automated review failed, or an auto-rebase failed.`},conflict:{label:`Conflict`,meaning:`Merge conflicts with the base branch.`},"your-turn":{label:`Your turn`,meaning:`Waiting on you: a review to give or a thread to answer.`},"changes-requested":{label:`Changes`,meaning:`A reviewer requested changes.`},thread:{label:`Threads`,meaning:`Unresolved review threads or comments.`},behind:{label:`Behind`,meaning:`The branch is behind its base.`},stale:{label:`Out of date`,meaning:`New commits landed since the automated review.`},fork:{label:`Fork`,meaning:`Opened from a fork, so it is reviewed by hand.`},running:{label:`Running`,meaning:`Checks or an automated review in progress.`},reviewer:{label:`Reviewer`,meaning:`Waiting on a reviewer.`},queued:{label:`Queued`,meaning:`Waiting for an automated review slot.`},draft:{label:`Draft`,meaning:`Still a draft.`},merged:{label:`Merged`,meaning:`Merged.`},discarded:{label:`Discarded`,meaning:`Review discarded or dismissed.`},unknown:{label:`Unknown`,meaning:`GitHub has not computed this yet.`},none:{label:`None`,meaning:`Nothing applies, such as no checks or no review requested.`}},K6=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:o[e],meaning:t}),cpe=Object.freeze([K6(a.DORMANT,`Not started yet.`),K6(a.INITIALIZING,`Setting up the worktree and launching the agent.`),K6(a.STARTING,`The agent is booting.`),K6(a.RUNNING,`The agent is mid-turn.`),K6(a.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),K6(a.WAITING,`Waiting on a permission prompt or your answer.`),K6(a.IDLE,`Ready for the next prompt.`),K6(a.COMPLETE,`Finished a turn you have not looked at yet.`),K6(a.DONE,`The agent process ended.`),K6(a.FAILED,`The agent failed to start or crashed.`)]);function q6(e,t){let n=m(`section`,`status-legend`),r=m(`dl`,`status-legend-rows`);return r.append(...t),n.append(m(`h2`,`status-legend-title`,e),r),n}function J6(e,t){let n=m(`div`,`status-legend-row`);return n.append(e,m(`dd`,`status-legend-meaning`,t)),n}function lpe(){return q6(`Status colors`,cpe.map(e=>{let t=m(`dt`,`status-legend-badge`),n=m(`span`,`status-legend-glyph`),r=m(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=J6(t,e.meaning);return DV(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function upe(){return q6(`Pull request icons`,Object.keys(G6).map(e=>{let t=G6[e],n=m(`dt`,`status-legend-badge`);return n.append(wJ(e),m(`span`,`status-legend-name`,t.label)),J6(n,t.meaning)}))}var dpe=2e4,$=null,Y6=null,X6=null,Z6=null,Q6=null,$6=null,e8=null,t8=`all`,n8=!1,r8=null,i8=hz,a8=mz,o8=pz,s8=!1,c8=null,l8=`day`,u8=new Set,d8=Uh({getAck:Qp,setAck:$p,signature:()=>HR($,X6),isLooking:()=>!T(Z6)}),f8=null,p8=null,m8=null,h8=null,g8=null,_8=null,v8=null,y8=null,b8=Vh(()=>Z6),x8=(e,t)=>ne(`usage`,e,t);function S8(e,t,n,r){let i=m(`div`,`usage-tile`);r&&r!==`ok`&&(i.dataset.tone=r);let a=m(`span`,`usage-tile-value`,t);i.append(a,m(`span`,`usage-tile-label`,e));let o=n?m(`span`,`usage-tile-sub`,n):null;return o&&i.append(o),{tile:i,valueEl:a,subEl:o}}function C8(e){let t=Number(e);return Number.isFinite(t)?Math.min(Math.max(t,0),100):0}function w8(e,t,n){let r=m(`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=m(`span`,`usage-meter-fill`);return r.append(i),T8(r,e),r}function T8(e,t){if(!e)return;let n=C8(t);e.setAttribute(`aria-valuenow`,String(Math.round(n)));let r=e.querySelector(`.usage-meter-fill`);r&&(r.style.width=`${n}%`)}function E8(e,t,n,r){let i=m(`div`,`usage-table-scroll`);i.dataset.usageTable=r;let a=m(`table`,`usage-table`),o=m(`thead`),s=m(`tr`);for(let i of e){let e=m(`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`,fz(t,a));let o=m(`button`,`usage-sort`,i.label);o.type=`button`,o.dataset.sortKey=a,o.addEventListener(`click`,()=>{c8={kind:`sort`,table:r,key:a},n(a)}),e.append(o),s.append(e)}o.append(s);let c=m(`tbody`);return a.append(o,c),i.append(a),{wrap:i,body:c}}function D8(e,t){for(let n of t){let t=m(`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 O8(e){let t=m(`div`,`usage-share`);if(!Number.isFinite(e))return t.append(m(`span`,`usage-share-text`,cL(e))),t;let n=m(`span`,`usage-share-bar`),r=m(`span`,`usage-share-fill`);return r.style.width=`${C8(e)}%`,n.append(r),t.append(n,m(`span`,`usage-share-text`,cL(e))),t}function k8(){if(!f8?.isConnected)return;let e=Number($?.ts);f8.textContent=Number.isFinite(e)&&e>0?`Report ${Bh(e)}`:``}function A8(){if(!p8?.isConnected)return;let e=Number(Y6?.ts);p8.textContent=Number.isFinite(e)&&e>0?`Sessions ${Bh(e)}`:``}function fpe(){let e=SL($?.activeBlock);e&&(h8?.isConnected&&(h8.textContent=`${e.pct}%`),g8?.isConnected&&(g8.textContent=`${vL(e.remainingMinutes)} left`),_8?.isConnected&&T8(_8,e.pct))}function ppe(e){let t=QI.find(t=>t.value===e);return t?t.days:null}function mpe(){let e=m(`div`,`usage-controls`),t=m(`label`,`usage-control`);t.append(m(`span`,`usage-control-label`,`Range`));let n=m(`select`,`usage-select`);for(let e of QI){let t=m(`option`,null,e.label);t.value=e.value,n.append(t)}n.value=t8,n.addEventListener(`change`,()=>{t8=n.value,R8()}),t.append(n);let r=m(`button`,`usage-refresh`,`Refresh`);r.type=`button`,r.title=`Re-read every transcript from the start`,r.addEventListener(`click`,()=>R8({force:!0}));let i=m(`span`,`usage-refresh-status`,``);return v8=r,y8=i,I8(),e.append(t,r,i),e}function hpe(){let e=x8(`Usage`,pL($?.daily||[]));e.append(mpe()),f8=m(`p`,`usage-meta`,``),e.append(f8),k8(),b8.onTick(k8);let t=ez($);t&&e.append(m(`p`,`usage-warning`,t));let n=XR($?.pricing?.missing);return n&&e.append(m(`p`,`usage-warning`,n)),e}function gpe(){if(!RR(X6))return null;let e=PR($?.totals),t=x8(`Plan limits`,e?`${BR(`official`)}, ${e}`:BR(`official`)),n=qR(X6?.ts);if(n){let e=m(`p`,`usage-meta`,n);e.dataset.tone=`warn`,t.append(e)}let r=m(`div`,`usage-plan`);for(let e of IR){let t=LR(X6,e.key);t&&r.append(_pe(e,t))}return t.append(r),m8=m(`p`,`usage-meta`,``),t.append(m8),j8(),b8.onTick(j8),t}function _pe(e,t){let n=m(`div`,`usage-plan-window`),r=m(`div`,`usage-plan-head`);r.append(m(`span`,`usage-plan-label`,e.label)),r.append(m(`span`,`usage-plan-used`,UR(t)));let i=m(`span`,`usage-plan-reset`,``);r.append(i),n.append(r),Number.isFinite(t.pct)&&n.append(w8(t.pct,CL(t.pct),`${e.label} plan limit used`));let a=()=>{i.isConnected&&(i.textContent=WR(t.resetsAtMs))};return a(),b8.onTick(a),n}function j8(){if(!m8?.isConnected)return;let e=GR(X6?.ts);m8.textContent=e?`Plan ${e}`:``}function vpe(){let e=VL($,X6),t=ype();if(e.length===0&&!t)return null;let n=x8(`Glimmervoid overhead`,e.length>0?NL:null);if(e.length>0){let t=m(`div`,`usage-tiles`);for(let n of e){let e=[HL(n),oL(n.costUSD)].filter(Boolean).join(`, `);t.append(S8(`${n.label}, share of Claude use`,cL(n.sharePct),e).tile)}n.append(t);for(let t of e){let e=UL(t);e&&n.append(m(`p`,`usage-meta`,`${t.label}: ${e}`))}}return t&&(n.append(m(`p`,`usage-meta`,`Selected range by lane. ${ML}`)),n.append(t)),n}function ype(){if(!LL($))return null;let e=FL($),t=e.reduce((e,t)=>e+(typeof t.costUSD==`number`&&Number.isFinite(t.costUSD)?t.costUSD:0),0),{wrap:n,body:r}=E8([{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=m(`tr`,`usage-row`);n.lane===`other`&&(e.dataset.lane=`other`),D8(e,[{text:PL(n.lane),className:`usage-lane-cell`},{text:oL(n.costUSD),numeric:!0},{text:sL(n.tokens),numeric:!0},{text:KL(n.sessions),numeric:!0},{node:O8(dL(n.costUSD,t)),className:`usage-share-cell`}]),r.append(e)}return n}function bpe(){let e=$?.activeBlock,t=$?.blockHours,n=typeof t==`number`&&Number.isFinite(t)?t:5,r=PR($?.totals),i=x8(`Current block`,r?`${n}h window, ${r}`:`${n}h window`);if(!e){i.append(m(`p`,`usage-empty`,`No active block.`));let e=M8();return e&&i.append(e),i}let a=VR($,X6),o=m(`div`,`usage-tiles`);o.append(S8(`block tokens`,sL(e.tokens??0),oL(e.costUSD??0),a).tile);for(let t of bL(e.burn))o.append(S8(t.label,t.value,t.sub,a).tile);let s=SL(e);if(s){let e=S8(`elapsed`,`${s.pct}%`,`${vL(s.remainingMinutes)} left`);h8=e.valueEl,g8=e.subEl,o.append(e.tile)}i.append(o),s&&(_8=w8(s.pct,`ok`,`Elapsed share of the current block window`),i.append(_8),b8.onTick(fpe));let c=xL(e.projection);if(c){let e=m(`p`,`usage-projection`,c);e.dataset.tone=a,i.append(e)}let l=M8();l&&i.append(l);let u=DL($?.tokenLimit);if(!u)return i;let d=TL($?.tokenLimit),f=VR($);i.append(w8(d,f,`Share of the largest completed block seen, estimated`));let p=m(`p`,`usage-meta`,u);p.dataset.tone=f,i.append(p),i.append(m(`p`,`usage-provenance`,BR(`estimated`)));let h=OL(e.projection,$?.tokenLimit);if(h){let e=m(`p`,`usage-meta`,h);e.dataset.tone=f,i.append(e)}return i}function M8(){let e=$?.anomaly;if(!ER(e))return null;let t=m(`p`,`usage-meta`,wR(e));return t.dataset.tone=TR(e),t}function xpe(){let e=Sz($?.blocks);if(e.length===0)return null;let t=PR($?.totals),n=x8(`Recent blocks`,t?`newest first, ${t}`:`newest first`),r=m(`div`,`usage-blocks`),i=e.reduce((e,t)=>Math.max(e,t.tokens),0);for(let t of e){let e=m(`div`,`usage-block`);t.isActive&&(e.dataset.active=`true`),e.append(m(`span`,`usage-block-label`,yL(t.startTs)));let n=m(`span`,`usage-block-bar`),a=m(`span`,`usage-block-fill`);a.style.width=`${C8(dL(t.tokens,i)??0)}%`,n.append(a),e.append(n),e.append(m(`span`,`usage-block-value`,`${sL(t.tokens)} ${oL(t.costUSD)}`)),r.append(e)}return n.append(r),n}function Spe(){let e=$?.totals||{},t=xz($?.daily,hL($)),n=x8(`Totals`,[XI,$?.tz?`TZ ${$.tz}`:``].filter(Boolean).join(` `)),r=VR($,X6),i=m(`div`,`usage-tiles`);i.append(S8(`today`,sL(t?.tokens??0),oL(t?.costUSD??0),r).tile),i.append(S8(`range total`,sL(e.tokens??0),oL(e.costUSD??0)).tile);let a=GL($);a&&i.append(S8(a.label,a.value,a.sub).tile),n.append(i);let o=Cpe(e);o&&n.append(o);let s=MR(e)?jR(e):[];if(s.length>0){let e=m(`div`,`usage-tiles usage-vendor-tiles`);for(let t of s)e.append(S8(t.label,sL(t.tokens),oL(t.costUSD)).tile);n.append(e)}return p8=m(`p`,`usage-meta`,``),n.append(p8),A8(),b8.onTick(A8),n}function Cpe(e){let t=AL(e);if(t.length===0)return null;let n=m(`div`,`usage-compo`),r=m(`div`,`usage-compo-bar`);r.setAttribute(`aria-hidden`,`true`);for(let e of t){if(e.pct<=0)continue;let t=m(`span`,`usage-compo-fill`);t.dataset.part=e.key,t.style.width=`${e.pct}%`,t.title=e.title,r.append(t)}let i=m(`div`,`usage-compo-legend`);for(let e of t){let t=m(`span`,`usage-compo-item`),n=m(`span`,`usage-compo-swatch`);n.dataset.part=e.key,t.append(n,m(`span`,`usage-compo-label`,e.label),m(`span`,`usage-compo-value`,e.value)),i.append(t)}return n.append(r,i),n}function wpe(){let e=$?.savings;if(!YL(e))return null;let t=x8(`Savings`,``),n=m(`div`,`usage-tiles`),r=XL(e);r&&n.append(S8(`rtk compression`,r.value,r.sub).tile);let i=ZL(e);return i&&n.append(S8(`Prompt cache`,i.value,i.sub).tile),t.append(n),t}function Tpe(){let e=QL($);if(e.length===0)return null;let t=x8(`Budgets`,`your own ceilings`),n=m(`div`,`usage-budgets`),r=lg(`machine-usage`,`usage-daily-budget`,`Budget settings`);n.appendChild(r);for(let t of e){let e=m(`div`,`usage-budget`),r=m(`div`,`usage-budget-head`);r.append(m(`span`,`usage-budget-label`,$L(t.scope))),r.append(m(`span`,`usage-budget-value`,eR(t))),r.append(m(`span`,`usage-budget-pct`,cL(tR(t)))),e.append(r),e.append(w8(tR(t),t.tone,nR(t))),n.append(e)}return t.append(n),t}function Epe(){let e=$?.daily||[],t=l8,n=bz(pR(e,t),i8),r=rR.find(e=>e.value===t)?.label||`Day`,i=x8(`Over time`,[gR(e)].filter(Boolean).join(`, `));if(i.append(Dpe()),n.length===0)return i.append(m(`p`,`usage-empty`,`No usage.`)),i;let a=kpe(e);a&&i.append(a);let{wrap:o,body:s}=E8([{label:r,key:`day`},{label:`Tokens`,numeric:!0,key:`tokens`},{label:`Cost`,numeric:!0,key:`costUSD`},{label:`Models`}],i8,e=>{i8=dz(i8,e),N8()},`day`);for(let e of n){let n=String(e.day??``),r=m(`tr`,`usage-row`);e.source===`history`&&(r.dataset.source=`history`);let i=yz(e.models),a=`${t}:${n}`,o=Ape(a,i.length);D8(r,[{node:Ope(e,t),title:n},{text:sL(e.tokens),numeric:!0},{text:oL(e.costUSD),numeric:!0},{node:o,className:`usage-toggle-cell`}]),s.append(r),i.length!==0&&u8.has(a)&&s.append(jpe(i))}return i.append(o),i}function Dpe(){let e=m(`div`,`usage-period`);e.setAttribute(`role`,`group`),e.setAttribute(`aria-label`,`Period`);for(let t of rR){let n=m(`button`,`usage-period-button`,t.label);n.type=`button`,n.dataset.periodView=t.value,n.setAttribute(`aria-pressed`,t.value===l8?`true`:`false`),n.addEventListener(`click`,()=>{l8!==t.value&&(l8=t.value,c8={kind:`period`,view:t.value},N8())}),e.append(n)}return e}function Ope(e,t){let n=m(`span`,`usage-period-cell`);return n.append(m(`span`,null,hR(e.day,t))),e.source===`history`&&n.append(m(`span`,`usage-history-tag`,`history`)),n}function kpe(e){let{cells:t,max:n}=bR(e,{today:hL($)});if(t.length===0||n<=0)return null;let r=m(`div`,`usage-heatmap-scroll`),i=m(`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=m(`div`,`usage-heatmap-days`);for(let e of vR)a.append(m(`span`,`usage-heatmap-day`,e));for(let e of t){let t=m(`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=xR(e),i.append(t)}return r.append(a,i),r}function Ape(e,t){if(t===0)return null;let n=m(`button`,`usage-toggle`,`Models`);return n.type=`button`,n.dataset.usageDay=e,n.setAttribute(`aria-expanded`,u8.has(e)?`true`:`false`),n.addEventListener(`click`,()=>{c8={kind:`day`,day:e},u8.has(e)?(u8.delete(e),N8()):(u8.add(e),N8())}),n}function jpe(e){let t=m(`tr`,`usage-row-breakdown`),n=m(`td`,`usage-models`);n.colSpan=4;for(let t of e){let e=m(`span`,`usage-model-chip`);e.append(m(`span`,`usage-model-name`,oz(t)),m(`span`,`usage-model-value`,`${sL(t.tokens)} ${oL(t.costUSD)}`)),n.append(e)}return t.append(n),t}function Mpe(e,t){let n=m(`span`,`usage-model-name-wrap`),r=AR(e,t);return r&&n.append(m(`span`,`usage-vendor-tag`,r)),n.append(m(`span`,null,oz(e))),n}function Npe(){let e=yz($?.models,a8),t=$?.totals||{},n=lL(t),r=x8(`By model`,uL(n));if(e.length===0)return r.append(m(`p`,`usage-empty`,`No models.`)),r;let{wrap:i,body:a}=E8([{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`}],a8,e=>{a8=dz(a8,e),N8()},`model`);for(let r of e){let e=m(`tr`,`usage-row`);D8(e,[{node:Mpe(r,t),className:`usage-model-cell`,title:oz(r)},{text:sL(r.tokens),numeric:!0},{text:oL(r.costUSD),numeric:!0},{node:O8(dL(r[n],t[n])),className:`usage-share-cell`},{text:sL(r.input),numeric:!0},{text:sL(r.output),numeric:!0},{text:sL(r.cacheCreate),numeric:!0},{text:sL(r.cacheRead),numeric:!0}]),a.append(e)}return r.append(i),r}function Ppe(){let e=gz($?.sessions,o8),t=_z(e,s8),n=$?.totals||{},r=lL(n),i=x8(`By session`,uL(r));if(e.length===0)return i.append(m(`p`,`usage-empty`,`No sessions.`)),i;let{wrap:a,body:o}=E8([{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`}],o8,e=>{o8=dz(o8,e),N8()},`session`);for(let e of t.rows){let t=m(`tr`,`usage-row`);iz(e)&&(t.dataset.managed=`true`);let i=az(e),a=m(`span`,`usage-ago`,``);D8(t,[{text:i,className:`usage-session-cell`,title:e.project?String(e.project):i},{text:sL(e.tokens),numeric:!0},{text:oL(e.costUSD),numeric:!0},{node:O8(dL(e[r],n[r])),className:`usage-share-cell`},{node:a,numeric:!0}]),b8.track(a,Number(e.lastTs),Bh),o.append(t)}return i.append(a),e.length>10&&i.append(Fpe(t.hiddenCount)),i}function Fpe(e){let t=m(`div`,`usage-overflow`),n=vz(e);n&&t.append(m(`p`,`usage-meta`,n));let r=m(`button`,`usage-toggle`,`All sessions`);return r.type=`button`,r.dataset.usageSessionsToggle=`true`,r.setAttribute(`aria-expanded`,s8?`true`:`false`),r.addEventListener(`click`,()=>{c8={kind:`sessions-toggle`},s8=!s8,N8()}),t.append(r),t}function Ipe(){let e=x8(`Not available`,``);return e.append(m(`p`,`usage-empty`,$R($))),e.append(m(`p`,`usage-empty`,ZI)),e}function Lpe(){f8=null,p8=null,m8=null,h8=null,g8=null,_8=null,v8=null,y8=null}function N8({force:e=!1}={}){if(!Z6||!e&&T(Z6))return;let t=Z6.parentElement,n=t?t.scrollTop:0;b8.reset(),Lpe(),Z6.textContent=``,Bpe(),t&&(t.scrollTop=n),Rpe()}function Rpe(){let e=c8;if(c8=null,!e)return;let t=zpe(e);if(!t||!Z6)return;let n=Z6.querySelector(t);n instanceof HTMLElement&&n.focus()}function zpe(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 Bpe(){if(!Z6)return;Z6.append(hpe());let e=gpe();if(tz($)){e&&Z6.append(e),Z6.append(Ipe());return}if(!$){e&&Z6.append(e),Z6.append(m(`p`,`usage-empty`,`Waiting for scan.`));return}let t=[e,Tpe()].filter(e=>e!==null);Z6.append(P8(`usage-band-now`,bpe(),t,{sideFirst:!0}));let n=[wpe()].filter(e=>e!==null);Z6.append(P8(`usage-band-spend`,Spe(),n));let r=[xpe()].filter(e=>e!==null);Z6.append(P8(`usage-band-trend`,Epe(),r));let i=vpe();i&&Z6.append(i),Z6.append(Npe(),Ppe())}function P8(e,t,n,{sideFirst:r=!1}={}){if(n.length===0)return t;let i=m(`div`,`usage-band ${e}`),a=m(`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 F8(){Q6&&Q6(d8.refresh())}function Vpe(){d8.acknowledge(),F8()}function I8(){v8&&(v8.disabled=n8),y8&&(y8.textContent=n8?`Refreshing`:``)}function L8(e){n8=e,I8(),r8&&=(clearTimeout(r8),null),e&&(r8=setTimeout(()=>{r8=null,n8=!1,I8()},dpe))}function Hpe(e){Q6=e,F8()}function Upe(e){$6=e}function R8({force:e=!1}={}){if(!$6)return;e8=Jm(`usage`);let t={type:`request-usage-report`,requestId:e8};e&&(t.force=!0);let n=ppe(t8);n!==null&&(t.days=n),L8(!0),$6(t)}function Wpe(e){if(Z6)return Z6;let t=m(`div`,`usage-content`);return e.appendChild(t),Z6=t,b8.ensure(),N8({force:!0}),t}function Gpe(){N8({force:!0})}function Kpe(e){Y6=e,$&&!tz($)&&p8?.isConnected?A8():N8()}function qpe(e){X6=e,N8(),F8()}function Jpe(e){nz(e,e8)&&(L8(!1),$=e,N8(),F8())}function Ype(){let e=$?.pricing||(Y6?{source:Y6.pricingSource}:null),t=YR(e?.fetchedAt),n=[JR(e,t!==null&&t>0?Bh(t):``)],r=$R($);r&&n.push(r);let i=QR($?.scan);return i&&n.push(i),n}var Xpe=Object.freeze({fetch:`Fetch`,stage:`Stage`,install:`Install dependencies`,"link-deps":`Link dependencies`,build:`Build`}),Zpe=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.`}),Qpe=Object.freeze([`unsupported-flavor`,`unsupported-platform`]),z8=`Not connected to the server. Reconnecting.`,B8=Object.freeze({requested:!1,failure:null});function V8(e,t){return t===`request-sent`?{requested:!0,failure:null}:t===`request-unsent`?{requested:!1,failure:z8}:t===`progress-frame`?B8:t===`error-frame`?e.requested?B8:e:e.failure===null?e:{requested:e.requested,failure:null}}function H8(e,t){return t?.state?t.state:e?.journalSummary?.state}function U8(e,t=null,n=null){return{actions:e,note:t,command:n}}function W8(e){let t=e?.applyRefusal;return t?Qpe.includes(t.reason):!1}function $pe({status:e,journal:t,request:n=B8}){let r=H8(e,t);if(n.failure)return U8([],n.failure);if(r===`running`||n.requested)return U8([]);if(r===`staged`)return U8([`restart`]);if(!e?.updateAvailable)return U8([`check`]);let i=e.applyRefusal;return i?i.reason===`target-already-checked-out`?U8([`restart`],i.message):W8(e)?U8([`check`],i.message,_c(e.command,null)):U8([`check`],i.message):U8([`update`])}function eme(e){return e?.journalSummary?.state===`staged`||e?.applyRefusal?.reason===`target-already-checked-out`}function tme(e){let t=tg(e?.latest,e?.latestSha)||`A new version`;if(eme(e))return{mode:`restart`,text:`${t} is ready. Restart to update, or it installs on the next start.`};if(e?.journalSummary?.state===`running`)return{mode:`link`,text:`Downloading ${t} in the background.`};let n=xie(e);return!e||e.applyRefusal===void 0||W8(e)?{mode:`command`,text:n}:{mode:`link`,text:n}}function G8(e){let t=_c(e,``);return t?`: ${t}`:``}var nme=new Set([`idle`,`staged`,`succeeded`,`discarded`]);function rme(e){return e.state===`failed`?`Update failed${G8(e.reason)}.`:e.state===`interrupted`?`Update interrupted${G8(e.reason)}.`:null}function K8(e){return Xpe[e]??e}function ime(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 ame(e){if(!e||nme.has(e.state))return null;let t=ime(e),n=t.stepId!==null&&t.stepId!==e.activeStep?t.stepId:null;return{state:e.state,terminalLine:rme(e),steps:e.steps.map(e=>({id:e.id,label:K8(e.id),status:e.status})),outputTail:t.lines,outputStepId:t.stepId,outputStepLabel:n===null?null:K8(n)}}var q8=6e5;function J8(e){return e.channel!==`main`||!Number.isInteger(e.behindCount)?``:`${e.behindCount} ${e.behindCount===1?`commit`:`commits`} behind`}function ome(e,t){let n=H8(e,t),r=tg(t?.toVersion,t?.toSha)||tg(e?.latest,e?.latestSha)||`the update`;if(n===`running`)return{tone:`running`,headline:`Downloading ${r} in the background. Glimmervoid keeps running.`};if(n===`staged`)return{tone:`staged`,headline:`${r} is ready. Restart to update now, or it installs on the next start.`};if(!e)return{tone:`unknown`,headline:`No update check has run yet.`};let i=tg(e.current,e.currentSha)||`an unknown version`;if(e.updateAvailable){let t=tg(e.latest,e.latestSha)||`a newer build`,n=J8(e);return{tone:`available`,headline:`Update available: ${i} to ${t}${n?` (${n})`:``}.`}}return _c(e.reason,``)?{tone:`unknown`,headline:`Running ${i}. The last check did not finish.`}:{tone:`current`,headline:`Up to date. Running ${i}.`}}function sme(e){if(!e)return`Update status unavailable.`;let t=tg(e.current,null)||`Unknown version`,n=bs(e.currentSha,{validate:!0}),r=_c(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 cme(e){return e?{label:tg(e.latest,e.latestSha)||`Latest target unknown`,behind:J8(e),releaseUrl:_c(e.releaseUrl,``)}:{label:`Update status unavailable.`,behind:``,releaseUrl:``}}function lme({status:e,checkForUpdates:t,now:n,lastAutoCheckAt:r}){if(t===!1||r!==null&&n-r<q8)return!1;let i=typeof e?.lastCheckAt==`number`?e.lastCheckAt:null;return i===null||n-i>=q8}function ume({status:e,checkForUpdates:t,relativeTime:n}){if(t===!1)return`Update checks are off.`;if(!e)return`No update check has run.`;let r=_c(e.reason,``);return r?Zpe[r]??`The last update check failed: ${r}.`:e.flavor===`unknown`?`The install flavor is unknown.`:n}var dme=Object.freeze({sounds:()=>GT(),themes:pE}),fme=2200,pme=1600,Y8=`browser-appearance`,mme=`browser-shortcuts`,hme=`flying-animals`,gme=Object.freeze({ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1});function _me(e){if(!e.optionsFrom)return e;let t=dme[e.optionsFrom]?.()??[];return{...e,options:t.map(e=>({value:e.id,label:e.label}))}}function X8(){return Object.freeze(a6.sections.map(e=>({...e,settings:e.settings.map(_me)})))}var Z8=X8(),Q8=!1,$8=null,e5=null,t5=null,n5=null,r5=null,i5=null,a5=null,o5=null,s5=Z8[0],c5={},l5={},u5=new Map,d5=new Map,f5=new Map,p5=new WeakMap,m5=Promise.resolve(),h5=new Map,g5=``,_5=null,v5=null,y5=B8,b5=()=>{},x5=null,S5=!1,C5=!1,w5=null,T5=new Set,E5=new Map;function vme(){return{themeId:Sp(),flyingAnimalsEnabled:wp(),...mm(),soundEnabled:fp(),soundId:KT(mp()),notificationsEnabled:gp(),compactStatusLabels:vp(),sessionUsageChips:bp()}}function D5(e){l5=Lfe(Z8,{...e,prefs:vme()})}function O5(e){return f5.has(e.id)?f5.get(e.id):l5[e.path]}function k5(e){return[e,...Pfe(Z8,e.id)]}function A5(e){return k5(e).flatMap(e=>e.settings)}function yme(e){return Z8.find(t=>t.settings.some(t=>t.id===e.id))??s5}function j5(e,t=null){history.replaceState(history.state,``,og(e,t))}function bme(e){requestAnimationFrame(()=>{let t=document.getElementById(e),n=t?.closest(`.settings-view-advanced-panel`);n&&(Q8=!0,n.hidden=!1,o5?.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 xme(e){for(let t of MT(NT)){let n=m(`div`,`shortcut-group`);n.appendChild(m(`div`,`shortcut-group-title`,t.title));let r=m(`dl`,`shortcut-rows`);for(let e of t.items){let t=m(`dt`,`shortcut-keys`);e.combos.forEach((e,n)=>{n>0&&t.appendChild(m(`span`,`shortcut-sep`,`/`)),PT(t,e)}),r.append(t,m(`dd`,`shortcut-label`,e.label))}n.appendChild(r),e.appendChild(n)}}function Sme(e){let t=m(`div`,`settings-about`),n=m(`span`,`settings-about-version`,`GLIMMERVOID `);n.appendChild(m(`span`,`settings-about-v`,`v0.38.2`));let r=m(`span`,`settings-about-links`),i=m(`a`,`settings-about-link`,`GitHub`);i.href=`https://github.com/${j3}`,i.target=`_blank`,i.rel=`noopener`;let a=m(`a`,`settings-about-link`,`Changelog`);a.href=`https://github.com/${j3}/blob/main/CHANGELOG.md`,a.target=`_blank`,a.rel=`noopener`,r.append(i,a),t.append(n,r),e.appendChild(t)}function M5(e){return Z8.flatMap(e=>e.settings).find(t=>t.id===e)??null}function Cme(e){if(l5[`pref:soundEnabled`]===e)return;l5[`pref:soundEnabled`]=e;let t=M5(`alert-sounds-enabled`);t&&o7(t)}var wme={"pref:flyingAnimalsMinGapSeconds":e=>om(Number(e)),"pref:flyingAnimalsMaxGapSeconds":e=>sm(Number(e)),"pref:flyingAnimalsMinDurationSeconds":e=>cm(Number(e)),"pref:flyingAnimalsMaxDurationSeconds":e=>lm(Number(e)),"pref:flyingAnimalsScale":e=>um(Number(e)),"pref:flyingAnimalsOnPhone":e=>dm(e===!0)};function Tme(e,t){if(e.path===`pref:compactStatusLabels`){yp(t===!0),uE(t===!0);return}if(e.path===`pref:sessionUsageChips`){xp(t===!0),dE(t===!0);return}if(e.path===`pref:themeId`){Cp(String(t)),lE(String(t));return}if(e.path===`pref:flyingAnimalsEnabled`){Tp(t===!0),A3(t===!0);return}let n=wme[e.path];n?(n(t),A3(wp())):e.path===`pref:soundEnabled`?g2(t===!0):e.path===`pref:soundId`?(hp(String(t)),rE(String(t))):e.path===`pref:notificationsEnabled`&&(_p(t===!0),t===!0&&GK().then(()=>o7(e,{force:!0})))}function N5(e,t){let n=d5.get(e.id);n!==void 0&&clearTimeout(n),d5.delete(e.id),t&&u5.set(e.id,t),t||u5.delete(e.id),s7(e)}function P5(e){N5(e,{tone:`saved`,text:`Saved`}),d5.set(e.id,window.setTimeout(()=>N5(e,null),fme))}function F5(e,t){h5.delete(e.id),e.path.startsWith(`pref:`)?(l5[e.path]=t,Tme(e,t),o7(e),P5(e)):f5.has(e.id)&&JSON.stringify(f5.get(e.id))===JSON.stringify(t)||(f5.set(e.id,t),N5(e,{tone:`saving`,text:`Saving`}),m5=m5.then(()=>Eme(e,t)))}async function Eme(e,t){let n=zfe(Z8,l5,e,t);if(Object.keys(n).length===0)f5.delete(e.id),N5(e,null),o7(e);else{N5(e,{tone:`saving`,text:`Saving`});try{let r=await Ym(`update-settings`,{settings:n});if(f5.get(e.id)===t&&f5.delete(e.id),r.type===`settings-error`){N5(e,{tone:`error`,text:String(r.message)}),o7(e,{force:!0});return}if(r.type!==`settings-updated`){N5(e,{tone:`error`,text:`The server did not confirm the save.`}),o7(e,{force:!0});return}O7(r.settings),P5(e)}catch(n){f5.get(e.id)===t&&f5.delete(e.id),N5(e,{tone:`error`,text:n?.message||`Failed to save the setting.`}),o7(e,{force:!0})}}}function I5(e,t){t&&h5.set(e.id,t),t||h5.delete(e.id),s7(e)}function Dme(e,t){if(!t.exclusiveMin)return t.min;if(e.integer!==!1)return t.min+1}function L5(e){return e?`On`:`Off`}function Ome(e){let t=m(`div`,`settings-view-toggle-wrap`),n=m(`label`,`settings-view-toggle`),r=m(`input`,`settings-view-checkbox`);r.type=`checkbox`,r.checked=O5(e)===!0,e.id===`desktop-notifications`&&!UK()&&(r.checked=!1,r.disabled=!0),r.setAttribute(`aria-labelledby`,e.id);let i=m(`span`,`settings-view-toggle-state`,L5(r.checked));return r.addEventListener(`change`,()=>{let t=r.checked;U6(e,t)?(r.checked=!1,i.textContent=L5(!1),lh({title:e.title,message:e.warning??``,confirmLabel:`Turn on`,danger:!0,onConfirm:()=>F5(e,!0)})):(i.textContent=L5(t),F5(e,t))}),n.append(r,i),t.appendChild(n),t}function R5(e,t,n){e.addEventListener(`blur`,t),e.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),t()):e.key===`Escape`&&(e.preventDefault(),n())})}function z5(e){return e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&[`text`,`number`,`password`].includes(e.type)}function B5(e,t){p5.set(t,{base:O5(e),isDirty:!1}),t.addEventListener(`input`,()=>{let e=p5.get(t);e&&(e.isDirty=!0)})}function V5(e,t,n){t.value!==n&&(t.value=n),p5.set(t,{base:O5(e),isDirty:!1}),I5(e,null)}function H5(e,t,n,r=!1){let i=p5.get(t);if(!i)return;let a=$fe(Z8,e,i,t.value,l5,r);a.kind===`invalid`?I5(e,a.error):a.kind===`unchanged`?V5(e,t,n):U6(e,a.value)?(V5(e,t,n),lh({title:e.title,message:e.warning??``,confirmLabel:`Save`,danger:!0,onConfirm:()=>F5(e,a.value)})):(p5.set(t,{base:a.value,isDirty:!1}),F5(e,a.value))}function kme(e){let t=m(`input`,`settings-view-input`);t.type=e.control===`password`?`password`:`text`;let n=()=>String(O5(e)??``);t.value=n(),e.control===`password`&&(t.value=``,t.placeholder=n()?`Configured`:`Not configured`);let r=O6(e,c5);return r&&(t.disabled=!0,t.setAttribute(`aria-description`,`Supplied by ${r}`)),t.autocomplete=`off`,t.spellcheck=!1,t.setAttribute(`aria-labelledby`,e.id),B5(e,t),R5(t,()=>{if(e.control===`password`){let n=t.value;if(n===``)return;V5(e,t,``),F5(e,n)}else H5(e,t,n())},()=>V5(e,t,e.control===`password`?``:n())),t}function Ame(e){let t=m(`input`,`settings-view-input`),n=P6(e);t.type=`number`;let r=()=>z6(O5(e));t.value=r(),t.step=e.integer===!1?String(e.step??`any`):`1`;let i=n?Dme(e,n):void 0;i!=null&&(t.min=String(i)),n?.max!=null&&(t.max=String(n.max)),t.autocomplete=`off`,t.setAttribute(`aria-labelledby`,e.id),B5(e,t),R5(t,()=>H5(e,t,r(),t.validity.badInput),()=>V5(e,t,r()));let a=e.unit?.label;if(!a)return t;let o=m(`div`,`settings-view-number`),s=m(`span`,`settings-view-unit`,a);return s.setAttribute(`aria-hidden`,`true`),t.setAttribute(`aria-description`,a),o.append(t,s),o}function U5(e,t){let n=[...e.querySelectorAll(`[role="radio"]`)],r=n.some(e=>e.dataset.value===t);for(let[e,i]of n.entries()){let n=i.dataset.value===t;i.setAttribute(`aria-checked`,String(n)),i.tabIndex=n||!r&&e===0?0:-1}}function W5(e,t,n){n!==String(O5(e))&&(U5(t,n),F5(e,n),U5(t,String(O5(e))))}function jme(e){let t=m(`div`,`settings-view-segmented`);t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-labelledby`,e.id);let n=e.options??[];for(let r of n){let n=m(`button`,`settings-view-segment`,r.label);n.type=`button`,n.dataset.value=r.value,n.setAttribute(`role`,`radio`),n.addEventListener(`click`,()=>W5(e,t,r.value)),t.appendChild(n)}return t.addEventListener(`keydown`,r=>{let i=gme[r.key];if(!i||n.length===0)return;r.preventDefault();let a=Math.max(0,n.findIndex(t=>t.value===String(O5(e)))),o=n[(a+i+n.length)%n.length];W5(e,t,o.value),t.querySelector(`[data-value="${CSS.escape(o.value)}"]`)?.focus()}),U5(t,String(O5(e))),t}function Mme(e){let t=m(`select`,`settings-view-input`);t.setAttribute(`aria-labelledby`,e.id);for(let n of e.options??[]){let e=m(`option`,null,n.label);e.value=n.value,t.appendChild(e)}return t.value=String(O5(e)),t.addEventListener(`change`,()=>F5(e,t.value)),t}function Nme(e,t){let n=e.valueKind===`posthog-projects`?`One project id per line, or none for no project. Shift+Enter adds a line.`:`One entry per line. Shift+Enter adds a line.`;return t.length>0||!e.listEmptyText?n:`${e.listEmptyText} ${n}`}function Pme(e){let t=m(`textarea`,`settings-view-input settings-view-list-input`),n=()=>N6(O5(e)),r=()=>n().join(`
274
+ `);t.rows=3,t.value=r(),t.autocomplete=`off`,t.spellcheck=!1,t.placeholder=e.listPlaceholder??``,t.setAttribute(`aria-labelledby`,e.id),B5(e,t),t.addEventListener(`blur`,()=>H5(e,t,r())),t.addEventListener(`keydown`,n=>{n.key===`Escape`?(n.preventDefault(),V5(e,t,r())):n.key!==`Enter`||n.shiftKey||(n.preventDefault(),H5(e,t,r()))});let i=m(`div`,`settings-view-list`);return i.append(t,m(`span`,`settings-view-list-hint`,Nme(e,n()))),i}function Fme(e){let t=m(`div`,`settings-view-projects`),n=O5(e),r=new Set(Array.isArray(n)?n:[]),i=Array.isArray(c5.projectChoices)?c5.projectChoices:[];i.length===0&&t.appendChild(m(`div`,`settings-empty`,`No configured projects are available.`));for(let n of T6(i,[...r])){let i=m(`label`,`settings-view-project-choice`),a=m(`input`,`settings-view-checkbox`);a.type=`checkbox`,a.checked=r.has(n.id),a.addEventListener(`change`,()=>{let t=O5(e),r=new Set(Array.isArray(t)?t:[]);a.checked&&r.add(n.id),a.checked||r.delete(n.id),F5(e,[...r])}),i.append(a,document.createTextNode(n.name)),t.appendChild(i)}return t}function G5(e,t,{isPrimary:n=!1,isEnabled:r=!0}={}){let i=m(`button`,`btn-dialog ${n?`btn-dialog-confirm`:`btn-dialog-cancel`} settings-update-button`,e);return i.type=`button`,i.disabled=!r,i.addEventListener(`click`,t),i}function K5(e){let t=m(`span`,`settings-update-action-status`,e??``);return t.setAttribute(`role`,`status`),t}function q5(e){let t=V8(y5,e);t!==y5&&(y5=t,A7())}function Ime(){q5(G({type:`update-apply`})?`request-sent`:`request-unsent`)}function J5(){x5=Date.now();let e=G({type:`update-check`});C5=e,w5=e?null:z8,A7()}function Lme(){return C5?`Checking for updates.`:w5}function Y5(){_5?(S5=!1,lme({status:_5,checkForUpdates:c5.checkForUpdates,now:Date.now(),lastAutoCheckAt:x5})&&J5()):S5=!0}function Rme(e){return e===`update`?G5(`Update`,Ime,{isPrimary:!0}):e===`restart`?G5(`Restart`,b5,{isPrimary:!0}):G5(`Check for updates`,J5,{isEnabled:!C5})}function zme(){let e=$pe({status:_5,journal:v5,request:y5}),t=m(`div`,`settings-update-actions`);if(e.actions.length>0){let n=m(`div`,`settings-update-buttons`);n.append(...e.actions.map(Rme)),t.appendChild(n)}let n=Lme();return n&&t.appendChild(K5(n)),e.note&&t.appendChild(K5(e.note)),e.command&&t.appendChild(m(`code`,`settings-update-command`,e.command)),t}function X5(e,...t){let n=m(`div`,`settings-update-fact`);return n.append(m(`span`,`settings-update-fact-label`,e),...t),n}function Bme(){let e=ame(v5);if(!e)return null;let t=m(`div`,`settings-update-progress`);t.dataset.state=e.state,t.setAttribute(`role`,`status`),e.terminalLine&&t.appendChild(m(`div`,`settings-update-terminal`,e.terminalLine));let n=m(`ol`,`settings-update-steps`);for(let t of e.steps){let e=m(`li`,`settings-update-step`);e.dataset.status=t.status,e.append(m(`span`,`settings-update-step-state`,t.status),m(`span`,`settings-update-step-label`,t.label)),n.appendChild(e)}if(t.appendChild(n),e.outputTail.length===0)return t;let r=m(`pre`,`settings-update-output`,e.outputTail.join(`
275
+ `));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(m(`div`,`settings-update-output-label`,i),r),t}function Vme(){let e=cme(_5),t=[e.label];if(e.behind&&t.push(m(`span`,`settings-update-behind`,e.behind)),e.releaseUrl){let n=m(`a`,`settings-link`,`View release`);n.href=e.releaseUrl,n.target=`_blank`,n.rel=`noopener noreferrer`,t.push(n)}return X5(`Latest`,...t)}function Hme(){let e=m(`div`,`settings-view-status-block settings-update-status`),t=ome(_5,v5),n=m(`div`,`settings-update-summary`,t.headline);n.dataset.tone=t.tone,e.appendChild(n),e.appendChild(X5(`Running`,sme(_5))),_5?.updateAvailable&&e.appendChild(Vme());let r=typeof _5?.lastCheckAt==`number`?_5.lastCheckAt:null,i=X5(`Last checked`,ume({status:_5,checkForUpdates:c5.checkForUpdates,relativeTime:Bh(r)}));r&&(i.title=new Date(r).toLocaleString()),e.appendChild(i),e.appendChild(zme());let a=Bme();return a&&e.appendChild(a),e}function Ume(e){return e===null?`not probed yet`:e?`resolved`:`not found on PATH`}function Wme(){let e=Array.isArray(c5.customAgents)?c5.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} ${Ume(e.resolvable)}`})}function Gme(){let e=m(`div`,`settings-view-status-block`);e.appendChild(m(`div`,`settings-section-title`,`Declared agents`));for(let t of Wme())e.appendChild(m(`div`,`settings-readonly`,t));return e}async function Kme(e,t){T5.add(e.id),E5.delete(e.id),k7();try{let n=await Ym(`update-settings`,{settings:{workflows:{rules:[{id:e.id,enabled:t}]}}});if(n.type===`settings-error`&&E5.set(e.id,String(n.message)),T5.delete(e.id),n.type===`settings-updated`){O7(n.settings);return}}catch(t){E5.set(e.id,t?.message||`Failed to save the rule.`)}T5.delete(e.id),k7()}function qme(e){return T5.has(e.id)?`Saving`:E5.get(e.id)??``}function Jme(e){let t=m(`div`,`settings-view-toggle-wrap`),n=m(`label`,`settings-view-toggle`),r=m(`input`,`settings-view-checkbox`);r.type=`checkbox`,r.checked=e.isEnabled,r.disabled=T5.has(e.id),r.setAttribute(`aria-label`,`Run rule ${e.name}`),r.addEventListener(`change`,()=>{Kme(e,r.checked)}),n.append(r,m(`span`,`settings-view-toggle-state`,L5(e.isEnabled)),m(`span`,`settings-readonly`,`${e.name} ${e.summary}`));let i=m(`span`,`settings-view-copy-status`,qme(e));return i.setAttribute(`role`,`status`),t.append(n,i),t}function Yme(){let e=m(`div`,`settings-view-status-block`);e.appendChild(m(`div`,`settings-section-title`,`Rules`));let t=ope(c5.workflows);if(t.length>0){for(let n of t)e.appendChild(Jme(n));return e}for(let t of ape(c5.workflows))e.appendChild(m(`div`,`settings-readonly`,t));return e}function Xme(){let e=m(`div`,`settings-view-status-block`);e.appendChild(m(`div`,`settings-section-title`,`Last report`));for(let t of Ype())e.appendChild(m(`div`,`settings-readonly`,t));return e}function Z5(e){return e.status===`update-actions`?Hme():e.status===`custom-agents`?Gme():e.status===`workflows`?Yme():m(`div`,`settings-readonly`,`Not available`)}function Zme(e){return e.control===`readonly`?Z5(e):e.control===`toggle`?Ome(e):e.control===`number`?Ame(e):e.control===`select`?tpe(e)===`segmented`?jme(e):Mme(e):e.control===`list`?Pme(e):e.control===`projects`?Fme(e):kme(e)}function Qme(e){let t=O6(e,c5);return t?`Supplied by ${t}. Change the server environment and restart to replace this credential.`:e.id===`desktop-notifications`&&!UK()?`Desktop notifications are unavailable for this page.`:e.id===`desktop-notifications`&&O5(e)===!0&&WK()===`denied`?`Blocked by the browser. Allow notifications for this site to enable them.`:e.status!==`rtk-install`||O5(e)!==!0||c5.rtkAvailable?``:kfe(c5)}function Q5(e){if(e.control===`readonly`)return null;if(e.status===`usage-last-report`){let e=Xme();return e.classList.add(`settings-view-status-slot`),e}let t=Qme(e);return t?m(`div`,`settings-view-warning settings-view-status-slot`,t):null}function $5(e,t){let n=m(`span`,`settings-view-chip`,t);return n.dataset.chip=e,n}function $me(e,t){let n=ie(e);return n?n.then(()=>t,()=>`Copy failed`):Promise.resolve(`Copy failed`)}function e7(e,t,{copiedText:n,textToCopy:r}){let i=m(`span`,`settings-view-copy-status`);i.setAttribute(`role`,`status`),t.type=`button`,t.addEventListener(`click`,async()=>{i.textContent=await $me(r(),n),setTimeout(()=>{i.textContent=``},pme)}),e.append(t,i)}function ehe(e){let t=m(`div`,`settings-view-setting-heading`),n=yme(e),r=m(`h2`,`settings-view-setting-title`,e.title);r.id=e.id,r.addEventListener(`click`,()=>j5(n.id,e.id));let i=m(`button`,`settings-view-copy-link`,`#`);return i.setAttribute(`aria-label`,`Copy link`),t.appendChild(r),e7(t,i,{copiedText:`Link copied`,textToCopy:()=>new URL(og(n.id,e.id),location.href).href}),t}function t7(e){let t=m(`div`,`settings-view-chips`);return t.append($5(`scope`,Ofe[e.scope]),$5(`effect`,Dfe[e.takesEffect])),t}function the(e){return e.control===`readonly`||O6(e,c5)?!1:!epe(e,O5(e))}function nhe(e){let t=m(`div`,`settings-view-control-foot`),n=m(`span`,`settings-view-save-status`);n.setAttribute(`role`,`status`);let r=m(`button`,`settings-view-reset`,`Reset`);return r.type=`button`,r.title=`Reset to the default value`,r.addEventListener(`click`,()=>{let t=V6(e),n=ipe(e);n===null?F5(e,t):lh({title:e.title,message:n,confirmLabel:`Reset`,danger:!0,onConfirm:()=>F5(e,t)})}),t.append(n,r),t}function n7(e,t){let n=e.querySelector(`.settings-view-save-status`),r=u5.get(t.id);n&&(n.textContent=r?.text??``,r&&(n.dataset.tone=r.tone),r||delete n.dataset.tone);let i=e.querySelector(`.settings-view-reset`);i&&(i.disabled=!the(t));let a=e.querySelector(`.settings-view-field-error`),o=h5.get(t.id);a&&!o&&a.remove(),a&&o&&(a.textContent=o),!a&&o&&e.querySelector(`.settings-view-setting-control`)?.appendChild(m(`div`,`settings-view-field-error`,o))}function r7(e){let t=m(`article`,`settings-view-setting`);t.dataset.settingId=e.id,e.control===`readonly`&&(t.dataset.readout=`true`);let n=m(`div`,`settings-view-setting-text`);n.append(ehe(e),m(`p`,`settings-view-setting-description`,e.description),t7(e));let r=m(`div`,`settings-view-setting-control`);r.appendChild(Zme(e)),e.control!==`readonly`&&r.appendChild(nhe(e)),t.append(n,r),e.id===`compact-status`&&t.appendChild(Gde()),H6(e,O5(e))&&t.appendChild(m(`div`,`settings-view-warning settings-warning`,e.warning));let i=Q5(e);return i&&t.appendChild(i),n7(t,e),t}function i7(e){return o5?.querySelector(`[data-setting-id="${e.id}"]`)??null}function rhe(e){let t=e.querySelector(`.settings-view-setting-control`);t&&(t.querySelector(`[role="radio"][aria-checked="true"]`)??t.querySelector(`input:not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled])`))?.focus()}function ihe(e,t){if(!z5(e)||!z5(t))return;e.disabled=t.disabled,e.placeholder=t.placeholder;let n=p5.get(t);n&&!B6(p5.get(e))&&(p5.set(e,{base:n.base,isDirty:!1}),e.value!==t.value&&(e.value=t.value))}function a7(e,t,n){if(e===n){ihe(e,t);return}let r=[...e.children],i=[...t.children];for(let[t,a]of i.entries()){let i=r[t];i?i.contains(n)?a7(i,a,n):i.replaceWith(a):e.appendChild(a)}for(let e of r.slice(i.length))e.remove()}function o7(e,{force:t=!1}={}){let n=i7(e);if(!n)return;let r=document.activeElement,i=n.contains(r),a=i&&!t&&z5(r)?r:null;(!a||!B6(p5.get(a)))&&h5.delete(e.id);let o=r7(e);a?a7(n,o,a):(n.replaceWith(o),i&&rhe(o))}function s7(e){let t=i7(e);t&&n7(t,e)}function c7(e){i7(e)?.querySelector(`.settings-view-setting-control`)?.replaceChildren(Z5(e))}function ahe(){for(let e of A5(s5))e.control===`readonly`?c7(e):o7(e)}function ohe(){let e=m(`button`,`btn-dialog btn-dialog-cancel`,`Reset all to defaults`);return e.type=`button`,e.addEventListener(`click`,()=>{hm(),D5(c5),A3(wp()),u7()}),e}function she(e){let t=m(`div`,`settings-view-advanced`),n=m(`button`,`dialog-advanced-toggle settings-view-advanced-toggle`,`Advanced`);n.type=`button`,n.setAttribute(`aria-expanded`,String(Q8)),n.setAttribute(`aria-controls`,`settings-view-advanced-panel`);let r=m(`div`,`dialog-advanced-panel settings-view-advanced-panel`);r.id=`settings-view-advanced-panel`,r.hidden=!Q8,n.addEventListener(`click`,()=>{Q8=!Q8,r.hidden=!Q8,n.setAttribute(`aria-expanded`,String(Q8))});for(let t of e)r.append(r7(t));return s5.id===Y8&&r.append(ohe()),t.append(n,r),t}function l7(e){let t=m(`div`,`settings-view-streamer-placeholder`),n=m(`button`,`btn-dialog btn-dialog-confirm`,`Turn off streamer mode`);n.type=`button`;let r=m(`span`,`settings-view-copy-status`,``);r.setAttribute(`role`,`status`),n.addEventListener(`click`,async()=>{n.disabled=!0,r.textContent=``;let e=await Zg(!1);n.disabled=!1,r.textContent=e}),t.append(m(`p`,`settings-view-section-description`,`Settings are hidden in streamer mode.`),n,r),e.appendChild(t)}Xg(()=>u7());function che(e){let t=m(`header`,`settings-view-subsection`),n=m(`h2`,`settings-view-subsection-title`,e.title);return n.addEventListener(`click`,()=>j5(e.id)),t.append(n,m(`p`,`settings-view-section-description`,e.description)),t}function lhe(e,t){for(let n of t.settings.filter(e=>e.access!==`advanced`))e.appendChild(r7(n)),n.id===hme&&e.appendChild(qde());let n=t.settings.filter(e=>e.access===`advanced`);n.length>0&&e.append(she(n))}function u7(){if(v7(),g5){g7();return}if(!o5)return;if(o5.textContent=``,Jg()){l7(o5);return}let e=m(`header`,`settings-view-section-header`),t=m(`h1`,`settings-view-section-title`,s5.title);if(t.tabIndex=-1,t.addEventListener(`click`,()=>j5(s5.id)),e.append(t,m(`p`,`settings-view-section-description`,s5.description)),o5.appendChild(e),s5.id===mme){let e=m(`div`,`shortcut-groups settings-view-shortcuts`);xme(e),o5.appendChild(e),o5.appendChild(lpe()),o5.appendChild(upe()),Sme(o5);return}let n=m(`div`,`settings-view-stack`);for(let e of k5(s5))e.id!==s5.id&&n.appendChild(che(e)),lhe(n,e);o5.appendChild(n)}function d7(e,{focusContent:t=!1,settingId:n=null,updateHash:r=!0,openPhoneSection:i=!0}={}){r&&g5&&(g5=``,r5&&(r5.value=``));let a=I6(Z8,e)??s5;s5.id!==a.id&&(Q8=!1),s5=a;let o=Z8.find(t=>t.id===e)??a;uhe(n5),i&&fT()&&(i5=o.id),u7(),T7(s5)&&w7(),s5.id===`machine-updates`&&Y5(),r&&j5(o.id,n),n&&bme(n),t&&o5?.querySelector(`h1`)?.focus()}function uhe(e){for(let t of e?.querySelectorAll(`[data-settings-section]`)||[]){let e=t.dataset.settingsSection===s5.id;t.setAttribute(`aria-current`,e?`page`:`false`)}}function f7(e){return e.section!==null}function p7(e){r5&&(r5.value=``,g5=``,x7(),d7(e.section.id,{settingId:e.setting.id}))}function m7(e){return _fe(a6.sections,e,a6.fileOnly)}function h7(e,t,n,r,i){let a=m(e,t),o=r.matches.find(e=>e.field===i),s=o?n.indexOf(o.text):-1;if(!o||s<0)return a.textContent=n,a;let c=0;for(let e of o.spans)a.append(n.slice(c,s+e.start),m(`mark`,`settings-view-search-highlight`,n.slice(s+e.start,s+e.end))),c=s+e.end;return a.append(n.slice(c)),a}function dhe(e,t){let{currentText:n,defaultText:r,jsonFragment:i}=Mfe(t.setting,c5);if(n!==null&&e.appendChild(m(`span`,`settings-view-search-current`,n)),e.append(m(`span`,`settings-view-search-default`,r),t7(t.setting),m(`p`,`settings-view-list-hint`,`Edit in config.json or with glimmervoid settings set.`)),i===null)return;let a=m(`div`,`settings-view-control-foot`);e7(a,m(`button`,`settings-view-copy-json`,`Copy as JSON`),{copiedText:`JSON copied`,textToCopy:()=>i}),e.appendChild(a)}function g7(){if(!o5)return;if(o5.textContent=``,Jg()){l7(o5);return}let e=m7(g5),t=m(`div`,`settings-view-section-header`);if(t.append(m(`h1`,`settings-view-section-title`,`Settings search`),m(`p`,`settings-view-section-description`,`${e.length} ${e.length===1?`result`:`results`} for "${g5}"`)),o5.appendChild(t),e.length===0){o5.appendChild(m(`p`,`settings-empty settings-view-search-empty`,`No settings found.`));return}let n=m(`ol`,`settings-view-search-results`);n.setAttribute(`aria-label`,`Settings search results`);for(let t of e){let e=m(`li`,`settings-view-search-result`);e.tabIndex=-1;let r=Nfe(Z8,t.section,t.setting);e.appendChild(h7(`p`,`settings-view-search-breadcrumb`,r,t,`section`));let i=h7(`span`,`settings-view-setting-title`,t.setting.title,t,`title`);if(f7(t)){let n=m(`button`,`settings-view-search-open`);n.type=`button`,n.appendChild(i),n.addEventListener(`click`,()=>p7(t)),e.appendChild(n)}f7(t)||(e.classList.add(`settings-view-search-file-only`),e.appendChild(i)),e.append(h7(`p`,`settings-view-setting-description`,t.setting.description,t,`description`),h7(`code`,`settings-view-key-path`,t.setting.path,t,`path`));let a=new Set([`title`,`description`,`path`,`section`]);if(!t.matches.some(e=>a.has(e.field))){let n=t.matches.find(e=>e.field===`options`)??t.matches.find(e=>e.field===`keywords`);n&&e.appendChild(h7(`p`,`settings-view-list-hint`,n.text,t,n.field))}f7(t)||dhe(e,t),n.appendChild(e)}o5.appendChild(n)}function _7(){return Ife(Z8,i5,g5,Jg())}function v7(){if(!t5)return;let e=_7();t5.dataset.settingsScreen=e,a5&&(a5.hidden=e!==`section`)}function y7(){return fT()&&_7()===`section`}function b7(){if(!y7())return;let e=s5.id;S7(``),n5?.querySelector(`[data-settings-section="${e}"]`)?.focus()}function x7(){if(!n5||!t5)return;let e=Ffe(Z8);n5.textContent=``;let t=m(`div`,`settings-view-nav-group`);for(let n of e){let e=m(`button`,`settings-view-nav-item`,n.title);e.type=`button`,e.dataset.settingsSection=n.id,e.addEventListener(`click`,()=>d7(n.id,{focusContent:fT()})),t.appendChild(e)}n5.appendChild(t),g5?(v7(),g7()):d7(s5.id,{updateHash:!1,openPhoneSection:!1})}function S7(e,{updateHash:t=!0}={}){g5=e.trim(),r5&&(r5.value=e),i5=null,t&&history.replaceState(history.state,``,cg(g5)),x7()}function C7(e){if(g5&&e.key===`Enter`&&e.target===r5){let t=m7(g5).find(f7);if(!t)return;e.preventDefault(),p7(t);return}if(e.key===`Escape`&&g5){if(!r5)return;e.preventDefault(),S7(``),r5.focus();return}if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`||!n5)return;let t=[...n5.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 fhe(e,{onRestart:t=()=>{}}={}){b5=t,oue(Cme),$8=e,$8.textContent=``,t5=m(`div`,`settings-view-shell`);let n=m(`div`,`settings-view-sidebar`);r5=m(`input`,`settings-view-search`),r5.type=`search`,r5.placeholder=`Search settings`,r5.setAttribute(`aria-label`,`Search settings`),n5=m(`nav`,`settings-view-nav`),n5.setAttribute(`role`,`navigation`),n5.setAttribute(`aria-label`,`Settings sections`),a5=m(`button`,`settings-view-back`,`Back`),a5.type=`button`,a5.hidden=!0,a5.setAttribute(`aria-label`,`Back to settings sections`),a5.addEventListener(`click`,b7),o5=m(`div`,`settings-view-content`),o5.setAttribute(`aria-live`,`polite`),r5.addEventListener(`input`,()=>{let e=r5;e&&S7(e.value)}),r5.addEventListener(`keydown`,C7),n5.addEventListener(`keydown`,C7),n.append(r5,a5,n5),t5.append(n,o5),$8.appendChild(t5),D5(c5),x7(),w7(),e5?.disconnect(),e5=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&w7()}),e5.observe($8)}function w7(){qT().then(phe)}function T7(e){return A5(e).some(e=>e.path===`pref:soundId`)}function phe(){if(Z8=X8(),s5=I6(Z8,s5.id)??Z8[0],l5[`pref:soundId`]=KT(mp()),g5){g7();return}let e=M5(`alert-sound`);e&&T7(s5)&&o7(e)}function E7(e=null,t=null){let n=F6(e??location.hash);n?S7(n.query):(S7(``,{updateHash:!1}),fT()&&!e?history.replaceState(history.state,``,cg(``)):d7(e||s5.id,{settingId:t}))}function D7(e){let t=F6(e);if(t){let e=cg(t.query);return{sectionId:e,settingId:null,hash:e}}return vfe(e,Z8,afe,ofe)}function O7(e){e&&(c5=e,D5(c5),g5?g7():ahe())}function mhe(e){k7()}function hhe(e,t){let n=t.querySelector(`.settings-view-status-slot`),r=Q5(e);n&&r&&n.replaceWith(r),n&&!r&&n.remove(),!n&&r&&t.appendChild(r)}function k7(){for(let e of A5(s5)){if(!e.status)continue;let t=i7(e);t&&(e.control===`readonly`?c7(e):hhe(e,t))}}function A7(){if(s5.id!==`machine-updates`)return;let e=M5(`update-actions`);e&&c7(e)}function ghe(e){_5=e,C5=!1,w5=null,y5=V8(y5,`status-frame`),A7(),S5&&s5.id===`machine-updates`&&Y5()}function _he(e){v5=e,y5=V8(y5,`progress-frame`),A7()}function vhe(){q5(`error-frame`),C5&&(C5=!1,A7())}function j7(){s5.id===Y8&&u7()}window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,j7),pT(()=>{i5=null,v7(),j7()});function yhe(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}}var bhe=`•`.repeat(8),M7=`[^/\\\\\\s"'\`<>:]+`,xhe=RegExp(`(?<![\\w./\\\\-])(?:/home/${M7}|/Users/${M7}|[A-Za-z]:[\\\\/]Users[\\\\/]${M7}|/root(?![\\w.-]))`,`g`);function She(e){let t=vD(e);if(t.length===0)return e;let n=``,r=0;for(let i of t)n+=e.slice(r,i.start)+bhe,r=i.end;return n+e.slice(r)}function Che(e){return e.replace(xhe,`~`)}function whe(e){return Che(She(e))}var N7=`.xterm, input, textarea, script, style, [contenteditable]:not([contenteditable="false"])`,P7=[`title`,`label`],F7=new WeakMap,I7=new WeakMap,L7=null;function R7(e){let t=e instanceof Element?e:e.parentElement;return!t||t.closest(N7)!==null}function The(e){let t=e.parentElement?.closest(`option`);return t!=null&&!t.hasAttribute(`value`)}function z7(e,t){if(t&&e===t.masked)return t;let n=whe(e);return n===e?null:{original:e,masked:n}}function B7(e){let t=The(e)?null:z7(e.data,F7.get(e));t?(F7.set(e,t),e.data!==t.masked&&(e.data=t.masked)):F7.delete(e)}function Ehe(e,t){let n=e.getAttribute(t),r=I7.get(e),i=n===null?null:z7(n,r?.get(t));if(!i){r?.delete(t);return}let a=r??new Map;a.set(t,i),I7.set(e,a),n!==i.masked&&e.setAttribute(t,i.masked)}function V7(e){for(let t of P7)Ehe(e,t)}function Dhe(e){return e instanceof Element&&e.matches(N7)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function H7(e){V7(e);let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,Dhe);for(let e=t.nextNode();e;e=t.nextNode())e instanceof Text&&B7(e),e instanceof Element&&V7(e)}function Ohe(e){R7(e)||(e instanceof Text&&B7(e),e instanceof Element&&H7(e))}function khe(e){e instanceof Element&&!R7(e)&&V7(e)}function Ahe(e){let t=new Set,n=new Set;for(let r of e){if(r.type===`childList`)for(let e of r.addedNodes)t.add(e);r.type===`characterData`&&t.add(r.target),r.type===`attributes`&&n.add(r.target)}for(let e of t)e.isConnected&&Ohe(e);for(let e of n)e.isConnected&&khe(e)}function jhe(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);U7(e);for(let e=t.nextNode();e;e=t.nextNode())U7(e)}function U7(e){if(e instanceof Text){let t=F7.get(e);t&&e.data===t.masked&&(e.data=t.original);return}if(!(e instanceof Element))return;let t=I7.get(e);if(t)for(let[n,r]of t)e.getAttribute(n)===r.masked&&e.setAttribute(n,r.original)}function Mhe(){if(L7)return;let e=new MutationObserver(t=>{Ahe(t),e.takeRecords()});H7(document.body),e.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:P7}),L7=e}function Nhe(){L7&&(L7.disconnect(),L7=null,jhe(document.body),F7=new WeakMap,I7=new WeakMap)}function W7(e){e?Mhe():Nhe()}function Phe(){W7(Jg()),Xg(W7)}function Fhe(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 Ihe(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function Lhe(e,t){return t||Ihe(e)?!1:Fhe(e)}var Rhe=2500;function zhe({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}var G7={teamReview:e=>e?.teamReview?.enabled===!0,posthog:e=>e?.posthog?.enabled===!0,visions:e=>e?.visions?.enabled===!0,usage:e=>e?.usage?.enabled!==!1,benchmarks:e=>e?.benchmarks?.enabled===!0,factory:e=>e?.factory?.enabled===!0};function K7(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=>{e.key===`ArrowLeft`?(e.preventDefault(),t(r[(r.indexOf(i)+r.length-1)%r.length],!0)):e.key===`ArrowRight`&&(e.preventDefault(),t(r[(r.indexOf(i)+1)%r.length],!0))}),n.append(a)}return n}function q7(){Rp()===`team`&&Rle()}function Bhe(e,t){let n=(e,t)=>{if(s(e),q7(),!t)return;let n=(e===`team`?r:i).querySelector(`[aria-selected="true"]`);n&&n.getClientRects().length>0?n.focus():(e===`team`?a:o).querySelector(`.pr-queue-toggle`)?.focus()},r=K7(`team`,n),i=K7(`mine`,n),a=document.createElement(`div`);a.className=`pr-mode-root`;let o=document.createElement(`div`);o.className=`pr-mode-root`,e.append(a,o),Ble(a,r,t),wQ(o,i,t);function s(e){yJ(),a.hidden=e!==`team`,o.hidden=e!==`mine`,zp(e)}s(Rp())}function Vhe(e,t){return t.isPhoneShellActive?t.phoneScreen===e:t.activeView===e}function Hhe(e,t){return e.flatMap(e=>!e.gate||!(`fromSettings`in e.gate)?[]:[{view:e,isAvailable:e.gate.fromSettings(t)}])}function Uhe(e){return{isActive:e===!0||typeof e==`string`,level:typeof e==`string`?e:null}}function J7(e,t){e?.refreshOn?.includes(t)&&e.refresh?.(t)}function Whe(e,t,n){for(let r of e)Vhe(r.view,t)&&J7(r,n)}function Ghe(e){let t=[{view:`focus`,label:`Focus`,panelClass:`focus-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,hasReviewSidebar:!0,mount:()=>eH({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:DH,deactivate:kH},{view:`prs`,label:`Reviews`,glyph:`⇅`,panelClass:`pr-view`,gate:{fromSettings:G7.teamReview},mount:t=>Bhe(t,{openTerminal:e.openTerminal}),attention:{subscribe:zle,acknowledge:q7}},{view:`issues`,label:`Issues`,glyph:`#`,panelClass:`issues-view`,mount:ode,refreshOn:[`shown`],refresh:sde,onConnectionChange:cde},{view:`usage`,label:`Usage`,glyph:`◔`,panelClass:`usage-view`,gate:{fromSettings:G7.usage},mount:Wpe,attention:{subscribe:Hpe,acknowledge:Vpe},refreshOn:[`shown`,`connected`,`usage-sessions`],refresh:e=>{e===`shown`&&Gpe(),R8()}},{view:`radar`,label:`Radar`,glyph:`◎`,panelClass:`radar-view`,gate:{fromSettings:G7.posthog},mount:zde,attention:{subscribe:Lde,acknowledge:Ide}},{view:`visions`,label:`Visions`,glyph:`◇`,panelClass:`visions-view`,gate:{fromSettings:G7.visions},mount:OW,attention:{subscribe:DW,acknowledge:()=>{AW(),kW()}}},{view:`hooks`,label:`Hooks`,glyph:`◈`,panelClass:`hooks-view`,mount:NK,refreshOn:[`shown`,`connected`,`hooks-updated`],refresh:e=>{e===`shown`&&PK(),MK()}},{view:`trace`,label:`Trace`,panelClass:`trace-view`,gate:{subscribe:Az},mount:BI,refreshOn:[`shown`],refresh:GI,onAvailabilityChange:e=>Rde(e?UI:null),onConnectionChange:YI},{view:`benchmarks`,label:`Bench`,panelClass:`bench-view`,gate:{fromSettings:G7.benchmarks},mount:Uue,onConnectionChange:Wue},{view:`factory`,label:`Factory`,panelClass:`factory-floor`,gate:{fromSettings:G7.factory},mount:t=>kue(t,{openTerminal:e.openTerminal}),onConnectionChange:jue},{view:`settings`,label:`Settings`,glyph:`@`,panelClass:`settings-view`,hasPanelChrome:!1,mount:t=>fhe(t,{onRestart:e.onRestart})}],n=y(document,`#app-main`,`main`),r=t.map(t=>{let r=m(`button`,`header-tab`,t.label);r.id=`tab-${t.view}`,r.type=`button`;let i=`view-${t.view}`;r.setAttribute(`role`,`tab`),r.setAttribute(`aria-controls`,i);let a=t.view===`focus`;r.setAttribute(`aria-selected`,String(a)),r.tabIndex=a?0:-1,t.glyph&&(r.dataset.phoneGlyph=t.glyph);let o=document.getElementById(i)??m(`section`);if(o.classList.add(t.panelClass),o.id=i,o.setAttribute(`role`,`tabpanel`),o.setAttribute(`aria-labelledby`,r.id),o.hidden=!0,o.parentElement||n.append(o),r.hidden=t.gate!==void 0,o.classList.toggle(`view-panel`,t.hasPanelChrome!==!1),t.attention){let n=m(`span`,`tab-activity`);n.id=`tab-${t.view}-activity`,n.setAttribute(`aria-hidden`,`true`),r.append(n),t.attention.subscribe(r=>{let{isActive:i,level:a}=Uhe(r);n.classList.toggle(`active`,i),a===null&&n.removeAttribute(`data-attention`),a!==null&&n.setAttribute(`data-attention`,a),e.setPhoneAttention(t.view,r)})}return{...t,tab:r,el:o}});return y(document,`#header-tabs`,`div`).replaceChildren(...r.map(e=>e.tab)),r}lE(Sp()),uE(vp()),dE(bp()),A3(wp()),dT(),hae(document);var Y7=y(document,`#connection-status`,`span`),X7=y(Y7,`.connection-label`,`span`),Z7=y(document,`#loading-screen`,`div`),Q7=y(document,`#loading-status`,`div`),$7=y(document,`#shutdown-screen`,`div`),e9=y(document,`#shutdown-status`,`div`),t9=!1,n9=null,r9=!1;function Khe(){let e=vm(),t=Z7.querySelector(`.loading-spinner`);e&&t&&t.replaceWith(_m(e,`loading-animal`))}Khe();function i9(){t9||n9===null||zhe({hasSnapshot:r9,connectingTerminalCount:Jce(),msSinceConnected:performance.now()-n9})===`reveal`&&a9()}qce(i9);function a9(){if(t9)return;t9=!0,Z7.classList.add(`fade-out`);let e=()=>Z7.remove();Z7.addEventListener(`transitionend`,e,{once:!0}),setTimeout(e,1e3)}function o9(e,t){Y7.dataset.state=`shutdown`,X7.textContent=e,Y7.title=e,T9.disabled=!0,e9.textContent=t,$7.classList.add(`active`)}var qhe=new Set([`disconnected`,`connecting`]);function s9(e,t,n){Y7.dataset.state=e,Y7.toggleAttribute(`data-reconnected`,n),X7.textContent=t,Y7.title=t}function Jhe(e,t){s9(e,t,e===`connected`&&qhe.has(Y7.dataset.state??``))}function Yhe(e,t){Y7.dataset.state!==`shutdown`&&s9(e===`verified`?`connected`:e,t,!1)}sre((e,t)=>{if(e===`connecting`||e===`verified`)Yhe(e,t);else{Jhe(e,t),JB(e===`connected`);for(let t of j9)t.onConnectionChange?.(e===`connected`);if(e===`connected`){if($7.classList.contains(`active`)){location.reload();return}bg(),document.body.classList.add(`app-ready`),!t9&&n9===null&&(n9=performance.now(),Q7.textContent=`Connecting to sessions...`,setTimeout(a9,Rhe)),i9(),J9(),h9(`connected`),Ym(`get-settings`,{}).then(e=>{e.settings&&(B9(e.settings),me()===`settings`&&O9(location.hash))}).catch(()=>{})}else e===`disconnected`&&$7.classList.contains(`active`)?e9.textContent=`Waiting for server...`:t9||(Q7.textContent=`Reconnecting to server...`)}});function c9(){P4(),bQ(),aJ()}function l9(){dH(),c9()}var u9=null;function Xhe(e){let t=yhe(u9,e);u9=t.knownBuild,t.reload&&location.reload()}function Zhe(e){pW(new Map(e.filter(e=>!e.ephemeral).map(e=>[e.id,e.name]))),mhe(e.filter(e=>!e.ephemeral).map(e=>({id:e.id,name:e.name,agent:e.agent,permissionMode:e.dangerouslySkipPermissions?`Skip permissions`:`Default`})));for(let t of e){t.ephemeral||N_(t.path),f2(t.id,t.linkedPrs);let e=PB(t.id);e&&_V(t.id,t.state,t.stateSince),e&&Rz(t.id,!!t.saneYolo),e&&QB(t.id,t.isGuarded),e||zB(t.id,t.name,t.state,f3(t)),NB(t.id,t.taskTitle,t.taskTitleIsCustom),XB(t.id,t.agent),uV(t.id,t.mergeStatus,t.mergeReason),YB(t.id,t.effectiveBase),tV(t.id,t.activeAgents,t.awaitingBackgroundTasks),oV(t.id,t.pendingWakeup),iV(t.id,t.pendingPromptKind,t.isCompacting,t.isWaitingForMemory),EB(t.id,t),UB(t.id,t.hasPlan),m9(t.id)}RB(),k_(E),dH(),OH(),c9(),d9(),k9(location.hash),r9=!0,i9()}function d9(){WI([...E].map(([e,t])=>({id:e,name:D(t)||e})))}function f9(e,t){UB(e,t?.hasPlan===!0),m9(e)}function Qhe(e){if(!PB(e.id))zB(e.id,e.session,e.to,f3({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),k_(E),P4();else if(e.to===a.DORMANT&&e.from!==a.DORMANT){let t=E.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,o=e.saneYolo??(r?r.dataset.saneYolo!==void 0:!1),s=r?r.dataset.path:void 0;pV(e.id),zB(e.id,e.session,a.DORMANT,f3({skipPerms:i,saneYolo:o,worktree:r?.dataset.worktree!==void 0,workspace:r?.dataset.workspace!==void 0,guarded:r?.dataset.guarded!==void 0,path:s,stateSince:e.timestamp,taskTitle:t?.taskTitle,taskTitleIsCustom:t?.taskTitleIsCustom})),XB(e.id,t?.agent),f9(e.id,t),l9(),QN(e.id),k_(E)}else _V(e.id,e.to,e.timestamp,e.event),e.saneYolo!==void 0&&Rz(e.id,e.saneYolo),k_(E),QN(e.id),l9(),iB(e.id),e.to===a.INITIALIZING&&(e.from===a.DONE||e.from===a.FAILED)&&aj(e.id)}var p9=new Map;function $he(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};p9.set(n.id,e),nV(n.id,e)}for(let e of[...p9.keys()])t.has(e)||(p9.delete(e),nV(e,null))}function m9(e){let t=p9.get(e);t&&nV(e,t)}Upe(G),jK(G),VI(G),ade(G),Hue(G),Mue(G),Nz(u2),wV(u2);function h9(e){Whe(j9,{isPhoneShellActive:rJ(),activeView:me(),phoneScreen:pe.snapshot().phoneScreen},e)}Xg(()=>h9(`settings-updated`));var ege={snapshot:e=>{Xhe(e.serverBuild),Zhe(e.sessions)},"hooks-report":e=>FK(e),"save-hook-result":e=>IK(e),"delete-hook-result":e=>LK(e),"state-change":e=>Qhe(e),"session-added":e=>{e.ephemeral||N_(e.path),f2(e.id,e.linkedPrs),PB(e.id)||(zB(e.id,e.session,e.state,f3(e)),XB(e.id,e.agent),m9(e.id)),k_(E),l9(),d9()},"session-removed":e=>{pV(e.id),eP(e.id),iue(e.id),k_(E),l9(),d9()},"session-title":e=>{NB(e.id,e.taskTitle,e.isCustom),l9()},"session-prs":e=>f2(e.id,e.linkedPrs),"session-renamed":e=>{fV(e.id,e.newName),c9(),d9()},"session-modified":e=>{e.ephemeral||N_(e.path);let t=E.get(String(e.id));pV(e.id),eP(e.id),f2(e.id,e.linkedPrs),zB(e.id,e.session,e.state,f3(e)),XB(e.id,e.agent),f9(e.id,t),k_(E),l9(),d9()},"session-git":e=>ZB(e.id,!!e.worktree),"session-agents":e=>{tV(e.id,e.activeAgents,e.awaitingBackgroundTasks),l9(),iB(e.id)},"session-wakeup":e=>oV(e.id,e.pendingWakeup),"session-prompt":e=>{iV(e.id,e.pendingPromptKind,e.isCompacting===!0,e.isWaitingForMemory===!0),c9()},"session-merge-status":e=>{lV(e.id,e.mergeStatus,e.reason),SH(e.id,e.mergeStatus),c9()},"session-worktree-blocked":e=>{Hg(`${e.session}: ${e.notice||`integration branch not found`}`,{persist:!0})},"session-worktree-warning":e=>{Hg(`${e.session}: ${e.notice||`base branch warning`}`)},"session-worktree-ready":e=>{YB(e.id,e.base)},"session-diff":e=>{dV(e.id,{committed:e.committed,uncommitted:e.uncommitted,hasCommits:e.hasCommits})},"session-diff-error":e=>{GN(e.id,e.message)},"change-map":e=>KN(e.id,e.map),"branch-sync-status":e=>YN(e.id,e),"session-changed":e=>ZN(e.id),"post-turn-result":e=>sV(e.id,e),"debug-state-response":e=>rB(e),"session-trace-response":e=>{DB(e)||KI(e)},"session-trace-changed":e=>{kB(e.id),qI(e)},"session-conversation":e=>{EB(e.id,e),c9()},"session-plan-changed":e=>{WB(e),c9()},"session-plan-draft":e=>{GB(e)},"session-plan-response":e=>{KB(e)},"session-docs-changed":e=>oae(e),"session-docs-snapshot":e=>sae(e),notify:e=>{qK(e),iB(e.session)},"update-status":e=>{ige(e),ghe(e)},"update-progress":e=>_he(e.journal),"post-turn-leftovers":e=>age(e),error:e=>{vhe(),JI(e),OB(e),qB(e),Hg(e.message,{persist:!0})},"session-error":e=>{qB(e),Hg(`${e.session}: ${e.message}`,{persist:!0})},"settings-updated":e=>{e.settings&&B9(e.settings),bg()},"health-snapshot":e=>{e.stats&&ple(e.stats)},"radar-status":e=>Bde(e),"radar-investigation-activity":e=>Vde(e),"radar-investigation-finished":e=>Ude(e),"team-review-status":e=>Vle(e),"my-prs-status":e=>{EQ(e),aue()},"factory-state":e=>Aue(e),"factory-queue-intent-result":e=>Nue(e),"factory-control-result":e=>Pue(e),"benchmark-status":e=>Gue(e),"benchmark-action-result":e=>Kue(e),"my-pr-merge-result":e=>OQ(e),"team-review-action-result":e=>Wle(e),"open-team-review-session-result":e=>Ule(e),"issues-status":e=>lde(e),"issue-detail-result":e=>ude(e),"open-issue-session-result":e=>dde(e),"usage-sessions":e=>{$he(e.sessions),Kpe(e)},"usage-report":e=>{Jpe(e),k7()},"plan-limits":e=>qpe(e),"usage-budget-alert":e=>qK({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0}),"visions-findings":e=>MW(e),"visions-comments":e=>NW(e),"visions-hand":e=>PW(e),"visions-intent":e=>FW(e),"visions-fix":e=>jW(e),"visions-snapshot":e=>RW(e),"ingest-activity":e=>IW(e),"ingest-snapshot":e=>LW(e),"client-trust":e=>fge(e.trust),"shutting-down":()=>o9(`Shutting down...`,`Shutting down sessions...`),restarting:()=>o9(`Restarting...`,`Restarting server...`)};function tge(e){let t=ege[e.type];t&&t(e)}cre(e=>{tge(e),h9(e.type)});var g9;function _9(e,t,n){e.onclick=()=>{let e=ie(n);e?e.then(()=>{t.textContent=`Copied`}).catch(()=>{t.textContent=`Copy failed`}):t.textContent=`Copy failed`}}var nge=lg(Ure,Wre,`Update`).href;function rge(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function ige(e){let t=y(document,`#update-banner`,`div`);if(!e.updateAvailable){t.hidden=!0;return}let{mode:n,text:r}=tme(e),i=rge(e),a=i&&n===`restart`?`${i}:ready`:i;if(g9!==void 0&&a===g9||a&&Wp()===a)return;let o=String(e.command??``);y(document,`#update-banner-text`,`span`).textContent=r,y(document,`#update-banner-cmd`,`code`).textContent=o;let s=y(document,`#update-banner-update`,`a`);s.href=nge,s.hidden=n!==`link`;let c=y(document,`#update-banner-restart`,`button`);c.hidden=n!==`restart`,c.onclick=q9;let l=y(document,`#update-banner-cmd`,`code`);l.hidden=n!==`command`;let u=y(document,`#update-banner-copy`,`button`);u.hidden=n!==`command`;let d=y(document,`#update-banner-copy-status`,`span`);d.hidden=n!==`command`,d.textContent=``;let f=y(document,`#update-banner-link`,`a`);f.hidden=!e.releaseUrl,f.href=typeof e.releaseUrl==`string`?e.releaseUrl:``,t.hidden=!1,_9(u,d,o),y(document,`#update-banner-dismiss`,`button`).onclick=()=>{g9=a,Gp(a),t.hidden=!0}}var v9=!1;function age({repositories:e,command:t}){let n=y(document,`#post-turn-leftovers-banner`,`div`);if(e.length===0){n.hidden=!0;return}if(v9)return;let r=y(document,`#post-turn-leftovers-copy-status`,`span`);y(document,`#post-turn-leftovers-text`,`span`).textContent=d(e.length),y(document,`#post-turn-leftovers-cmd`,`code`).textContent=t,r.textContent=``,n.hidden=!1,_9(y(document,`#post-turn-leftovers-copy`,`button`),r,t),y(document,`#post-turn-leftovers-dismiss`,`button`).onclick=()=>{v9=!0,n.hidden=!0}}var y9=y(document,`#telemetry-banner`,`div`);function b9(){qp(!0),y9.hidden=!0}function oge(e){y9.hidden=!Lhe(e,Kp())}var x9=y(document,`#telemetry-banner-settings`,`a`);x9.href=lg(`privacy`,`telemetry-enabled`,`Open settings`).href,x9.addEventListener(`click`,b9),y(document,`#telemetry-banner-dismiss`,`button`).addEventListener(`click`,b9),y(document,`#btn-add-session-header`,`button`).addEventListener(`click`,ig);var S9=y(document,`#btn-mute`,`button`);sue(S9);var C9=y(document,`#btn-streamer`,`button`);rae(C9),Phe();var w9=y(document,`#power-menu`,`div`),T9=y(document,`#btn-power`,`button`);function E9(){T9.setAttribute(`aria-expanded`,w9.classList.contains(`open`)?`true`:`false`)}T9.addEventListener(`click`,e=>{e.stopPropagation(),w9.classList.toggle(`open`),E9()}),document.addEventListener(`click`,e=>{e.target instanceof Node&&(w9.contains(e.target)||(w9.classList.remove(`open`),E9()))}),te(document.querySelector(`.header`));function sge(e){e&&E7(e),!sJ(`settings`)&&R9(`settings`,{section:e})}function D9(){sg(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}function cge(e){return e?(E7(e.sectionId,e.settingId),sJ(`settings`)||R9(`settings`,{section:e.sectionId,setting:e.settingId,persist:!1}),!0):!1}function O9(e){return cge(D7(e))}function k9(e){let t=hM(e);return t?!PB(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),rJ()?(nJ(t)||Hg(`No plan is stored for this session yet`),!0):(R9(`focus`,{persist:!1}),wH(t)||Hg(`No plan is stored for this session yet`),!0)):!1}function A9(e){return k9(e)?!0:O9(e)}function lge(e){e.newURL===location.href&&A9(location.hash)}document.addEventListener(`click`,e=>{if(!rJ()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&A9(t.hash)&&e.preventDefault()}),RX(y(document,`#celebration-tray`,`div`),y(document,`#btn-celebrations`,`button`),y(document,`#celebration-tray-count`,`span`)),y(document,`#btn-help`,`button`).addEventListener(`click`,()=>{sge(`browser-shortcuts`)});var j9=Ghe({onRestart:q9,openTerminal:e=>{oJ(e)||(R9(`focus`),CH(e))},openPlan:e=>{R9(`focus`),wH(e)},setPhoneAttention:lJ});zN({panel:document.getElementById(`review-sidebar`)});for(let e of j9)e.mount(e.el);function M9(e){return j9.find(t=>t.view===e)}function N9(e){return j9.some(t=>t.view===e&&!t.tab.hidden)}var P9=!0,F9=null;function I9(e){M9(e)?.attention?.acknowledge()}function L9(e){J7(M9(e),`shown`)}function R9(e,{section:t,setting:n,persist:r=!0}={}){if(!N9(e))return;let i=me();pe.dispatch(`setActiveView`,e),P9=r,r&&(F9=null),document.body.dataset.activeView=e,document.body.dataset.reviewSidebarHidden=String(M9(e)?.hasReviewSidebar!==!0),r&&Dp(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!==e&&M9(i)?.deactivate?.(),M9(e)?.activate?.(),L9(e),i===`settings`&&e!==`settings`&&D9(),e===`settings`&&t&&E7(t,n??null),I9(e)}function z9(e,t){let{view:n}=e;e.tab.hidden=!t,cJ(n,t),e.onAvailabilityChange?.(t),!rJ()&&(!t&&me()===n&&R9(`focus`),t&&F9===n&&R9(n))}function uge(e){for(let{view:t,isAvailable:n}of Hhe(j9,e))z9(t,n)}function B9(e){IB(e),O7(e),yW(e),uge(e),oge(e),Yg(e.streamerMode===!0),wB(e.conversationView===!0)}for(let e of j9)e.gate&&(z9(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>z9(e,t)));HI(()=>{N9(`trace`)&&(sJ(`trace`)||R9(`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 R9(r.view),r.tab}function dge(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`,()=>R9(t)),n.addEventListener(`keydown`,e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||(e.preventDefault(),V9(me(),e.key===`ArrowRight`?1:-1).focus()))})}var H9=Ep(),U9=D7(location.hash),W9=hM(location.hash);if(U9&&R9(`settings`,{section:U9.sectionId,setting:U9.settingId,persist:!1}),W9&&R9(`focus`,{persist:!1}),!U9&&!W9){let e=N9(H9);e||(F9=H9),R9(e?H9:`focus`,{persist:e})}$q({panels:JK(j9),onScreenShown:e=>{L9(e),e!==`settings`&&D9(),e===`settings`&&!sg(location.hash)&&E7(),I9(e)},canGoBack:e=>e===`settings`&&y7(),onBack:e=>{e===`settings`&&b7()},headerControls:[y(document,`.header-title`,`h1`),y(document,`#status-indicator`,`div`),y(document,`#celebration-tray`,`div`),y(document,`#btn-add-session-header`,`button`),y(document,`#btn-help`,`button`),S9,y(document,`#streamer-badge`,`span`),C9,w9]});function G9(e){if(e===`phone`){let e=$V();for(let e of j9)e.deactivate?.();let t=D7(location.hash);eJ({sessionId:e??void 0,linkedScreenId:t?`settings`:void 0}),t&&E7(t.sectionId,t.settingId);return}let t=iJ();tJ();let n=me();R9(N9(n)?n:`focus`,{persist:P9}),t&&CH(t)}fT()&&G9(`phone`),pT(G9),window.addEventListener(`hashchange`,lge);function K9({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){w9.classList.remove(`open`),E9();let o=FB();lh({title:t,message:o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i,confirmLabel:n,danger:r,onConfirm:()=>G({type:e})})}function q9(){K9({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}y(document,`#btn-restart`,`button`).addEventListener(`click`,q9);function fge(e){let n=t(`shutdown`,e);y(document,`#btn-shutdown`,`button`).hidden=!n,y(document,`#menu-divider-shutdown`,`div`).hidden=!n}y(document,`#btn-shutdown`,`button`).addEventListener(`click`,()=>{K9({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})});function pge(){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 mge({action:e,step:t}){switch(e){case`merge`:return tP(),!0;case`resolve-or-resync`:return nP()||rP(),!0;case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`next-attention`:return QV()?(hH(),!0):!1;case`rail-step`:return QV()?(EH(t),!0):!1;case`view-step`:return!fT()&&(dge(V9(me(),t)),!0);case`session-nth`:return QV()?(TH(t),!0):!1;case`streamer-mode`:return Qg(),!0}}document.addEventListener(`keydown`,e=>{if(e.repeat||pge())return;let t=ET(e,NT);t&&mge(t)&&e.preventDefault()});var hge=i({mode:`trailing`,delayMs:150,run:()=>{G({type:`focus-change`,focused:document.hasFocus()})}});function J9(){hge.schedule()}function Y9(){J9(),dj(k(he()))}window.addEventListener(`focus`,Y9),window.addEventListener(`blur`,Y9),document.addEventListener(`visibilitychange`,Y9);var X9=!1,Z9=null;function gge(){if(document.visibilityState!==`visible`)return 0;let e=Z9;return Z9=null,e===null?0:Date.now()-e}async function Q9(){let e=gge();if(!X9){X9=!0,Yce();try{if(await lre(e)===`ok`)return;for(let e of E.keys())aj(e)}finally{Xce(),X9=!1}}}document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`?(BA(),Q9()):Z9??=Date.now()}),window.addEventListener(`online`,Q9);var $9=_f(G);window.addEventListener(`error`,e=>$9(e.error)),window.addEventListener(`unhandledrejection`,e=>$9(e.reason)),window.addEventListener(`pageshow`,e=>{e.persisted&&(BA(),Q9())}),fle(y(document,`#health-footer-mount`,`div`)),KK(),rT(LB),Qm();